Ver código fonte

4个统计合并成1个接口

lrf 8 meses atrás
pai
commit
fcd18f3204
1 arquivos alterados com 24 adições e 36 exclusões
  1. 24 36
      src/main/java/com/free/controller/IndexController.java

+ 24 - 36
src/main/java/com/free/controller/IndexController.java

@@ -13,6 +13,7 @@ import com.free.utils.JwtUtil;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 
+import java.util.HashMap;
 import java.util.Map;
 
 import org.springframework.beans.factory.annotation.Autowired;
@@ -31,46 +32,33 @@ public class IndexController {
   @Autowired
   private UserService userService;
 
-  // 1.转人工申请待处理数量(不区分用户)
-  @ApiOperation("查询当前转人工申请待处理数量")
-  @GetMapping("/needAgreeNum")
-  public Object getNeedAgreeNum() {
-    QueryWrapper qw = new QueryWrapper<>();
-    qw.eq("is_agree", TransferApplyController.TransferApplyNotAgree);
-    Long num = transferApplyService.count(qw);
-    return ResponseFormat.success(num);
-  }
-
-  // 2.转人工申请未结束数量(区分用户,管理员查所有)
-  @ApiOperation("查询当前转人工申请待关闭数量")
-  @GetMapping("/needCloseNum")
-  public Object getNeedCloseNum() {
-    QueryWrapper qw = new QueryWrapper<>();
-    qw.eq("is_agree", TransferApplyController.TransferApplyAgree);
-    qw.eq("is_close", TransferApplyController.TransferApplyNotClose);
+  @ApiOperation("首页统计接口")
+  @GetMapping("")
+  public Object index() {
+    Map returnData = new HashMap<>();
+    // 1.转人工申请待处理数量(不区分用户)
+    QueryWrapper qw1 = new QueryWrapper<>();
+    qw1.eq("is_agree", TransferApplyController.TransferApplyNotAgree);
+    Long num1 = transferApplyService.count(qw1);
+    returnData.put("n1", num1);
+    // 2.转人工申请未结束数量(区分用户,管理员查所有)
+    QueryWrapper qw2 = new QueryWrapper<>();
+    qw2.eq("is_agree", TransferApplyController.TransferApplyAgree);
+    qw2.eq("is_close", TransferApplyController.TransferApplyNotClose);
     Map userInfo = JwtUtil.getDetails(null);
     String type = (String) userInfo.get("type");
     if (!LoginController.adminLoginType.equals(type)) {
       String customer_id = (String) userInfo.get("id");
-      qw.eq("customer_id", customer_id);
+      qw2.eq("customer_id", customer_id);
     }
-    Long num = transferApplyService.count(qw);
-    return ResponseFormat.success(num);
-  }
-
-  // 3.题库数量
-  @ApiOperation("查询当前题库数量")
-  @GetMapping("/questionNum")
-  public Object getQuestionNum() {
-    Long num = questionService.count();
-    return ResponseFormat.success(num);
-  }
-
-  // 4.用户数量
-  @ApiOperation("查询当前用户总数")
-  @GetMapping("/questionNum")
-  public Object getUserNum() {
-    Long num = userService.count();
-    return ResponseFormat.success(num);
+    Long num2 = transferApplyService.count(qw2);
+    returnData.put("n2", num2);
+    // 3.题库数量
+    Long num3 = questionService.count();
+    returnData.put("n3", num3);
+    // 4.用户数量
+    Long num4 = userService.count();
+    returnData.put("n4", num4);
+    return ResponseFormat.success(returnData);
   }
 }