Browse Source

1. 仪表板:下载没反应

zhangheng 3 năm trước cách đây
mục cha
commit
70b89f9b29

+ 16 - 2
server/src/main/java/edp/davinci/controller/StatisticController.java

@@ -24,15 +24,18 @@ import edp.davinci.core.common.ResultMap;
 import edp.davinci.dto.statistic.DavinciStatisticDurationInfo;
 import edp.davinci.dto.statistic.DavinciStatisticTerminalInfo;
 import edp.davinci.dto.statistic.DavinciStatisticVisitorOperationInfo;
+import edp.davinci.dto.statistic.DavinciStatisticVisitorOperationInfoCopy;
 import edp.davinci.service.StatisticService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiResponse;
 import io.swagger.annotations.ApiResponses;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.MediaType;
 import org.springframework.http.ResponseEntity;
+import org.springframework.util.StringUtils;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -40,6 +43,8 @@ import org.springframework.web.bind.annotation.RestController;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.validation.Valid;
+import java.util.ArrayList;
+import java.util.List;
 
 @Api(value = "/statistic", tags = "statistic", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
 @ApiResponses(@ApiResponse(code = 404, message = "statistic not found"))
@@ -76,10 +81,19 @@ public class StatisticController {
 
     @ApiOperation(value = "collect visitor operation info ")
     @PostMapping(value = "/visitoroperation", consumes = MediaType.APPLICATION_JSON_VALUE)
-    public ResponseEntity collectVisitorOperationInfo(@Valid @RequestBody ValidList<DavinciStatisticVisitorOperationInfo> visitorOperationInfos,
+    public ResponseEntity collectVisitorOperationInfo(@Valid @RequestBody ValidList<DavinciStatisticVisitorOperationInfoCopy> visitorOperationInfos,
                                               HttpServletRequest request){
 
-        statisticService.insert(visitorOperationInfos, DavinciStatisticVisitorOperationInfo.class);
+        // 转换 string to Integer
+        List<DavinciStatisticVisitorOperationInfo> davinciStatisticVisitorOperationInfoList = new ArrayList<DavinciStatisticVisitorOperationInfo>();
+
+        for(DavinciStatisticVisitorOperationInfoCopy davinciStatisticVisitorOperationInfoCopy:visitorOperationInfos){
+            DavinciStatisticVisitorOperationInfo statisticVisitorOperationInfo = new DavinciStatisticVisitorOperationInfo();
+            BeanUtils.copyProperties(davinciStatisticVisitorOperationInfoCopy,statisticVisitorOperationInfo);
+            statisticVisitorOperationInfo.setUser_id(Long.getLong(davinciStatisticVisitorOperationInfoCopy.getUser_id()));
+            davinciStatisticVisitorOperationInfoList.add(statisticVisitorOperationInfo);
+        }
+        statisticService.insert(davinciStatisticVisitorOperationInfoList, DavinciStatisticVisitorOperationInfo.class);
 
         return ResponseEntity.ok(new ResultMap(tokenUtils).successAndRefreshToken(request));
     }

+ 62 - 0
server/src/main/java/edp/davinci/dto/statistic/DavinciStatisticVisitorOperationInfoCopy.java

@@ -0,0 +1,62 @@
+package edp.davinci.dto.statistic;
+
+import edp.core.consts.Consts;
+import lombok.Data;
+
+import javax.validation.constraints.Min;
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Pattern;
+import java.time.LocalDateTime;
+import java.util.List;
+
+@Data
+@NotNull(message = "Visitor operation info cannot be null")
+public class DavinciStatisticVisitorOperationInfoCopy {
+
+    @NotNull
+    private String user_id;
+
+    @NotBlank
+    @Pattern(regexp = Consts.REG_EMAIL_FORMAT, message = "Illegal email format")
+    private String email;
+
+    @NotBlank
+    private String action;
+
+    @Min(value = 1L)
+    private Long org_id;
+
+    @Min(value = 1L)
+    private Long project_id;
+
+    private String project_name;
+
+    private String viz_type;
+
+    @Min(value = 1L)
+    private Long viz_id;
+
+    private String viz_name;
+
+    @Min(value = 1L)
+    private Long sub_viz_id;
+
+    private String sub_viz_name;
+
+    @Min(value = 1L)
+    private Long widget_id;
+
+    private String widget_name;
+
+    private List<Object> variables;
+
+    private List<Object> filters;
+
+    private List<Object> groups;
+
+    @NotNull
+    private LocalDateTime create_time;
+
+}
+