Explorar el Código

新增统计接口

zhangchen hace 1 día
padre
commit
1033406c98

+ 20 - 0
alien-entity/src/main/java/shop/alien/entity/store/vo/RegisteredLawyerUserCountVo.java

@@ -0,0 +1,20 @@
+package shop.alien.entity.store.vo;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * 律师端注册用户数量统计
+ */
+@Data
+@ApiModel(value = "RegisteredLawyerUserCountVo", description = "律师端注册用户数量统计")
+public class RegisteredLawyerUserCountVo implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @ApiModelProperty("律师端注册用户总数(lawyer_user 表,未逻辑删除)")
+    private Long registeredLawyerUserCount;
+}

+ 20 - 0
alien-entity/src/main/java/shop/alien/entity/store/vo/RegisteredStoreUserCountVo.java

@@ -0,0 +1,20 @@
+package shop.alien.entity.store.vo;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * 店铺端注册用户数量统计
+ */
+@Data
+@ApiModel(value = "RegisteredStoreUserCountVo", description = "店铺端注册用户数量统计")
+public class RegisteredStoreUserCountVo implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @ApiModelProperty("店铺端注册用户总数(store_user 表,未逻辑删除)")
+    private Long registeredStoreUserCount;
+}

+ 20 - 0
alien-entity/src/main/java/shop/alien/entity/store/vo/RegisteredUserCountVo.java

@@ -0,0 +1,20 @@
+package shop.alien.entity.store.vo;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * C 端注册用户数量统计
+ */
+@Data
+@ApiModel(value = "RegisteredUserCountVo", description = "注册用户数量统计")
+public class RegisteredUserCountVo implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @ApiModelProperty("注册用户总数(life_user 表,未逻辑删除)")
+    private Long registeredUserCount;
+}

+ 79 - 0
alien-store/src/main/java/shop/alien/store/controller/RegisteredUserStatisticsController.java

@@ -0,0 +1,79 @@
+package shop.alien.store.controller;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiOperationSupport;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.http.MediaType;
+import org.springframework.web.bind.annotation.CrossOrigin;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import shop.alien.entity.result.R;
+import shop.alien.entity.store.vo.RegisteredLawyerUserCountVo;
+import shop.alien.entity.store.vo.RegisteredStoreUserCountVo;
+import shop.alien.entity.store.vo.RegisteredUserCountVo;
+import shop.alien.store.service.RegisteredUserStatisticsService;
+
+/**
+ * 各端注册用户数量统计
+ */
+@Api(tags = {"注册用户统计"})
+@Slf4j
+@CrossOrigin
+@RestController
+@RequestMapping("/registeredUserStatistics")
+@RequiredArgsConstructor
+public class RegisteredUserStatisticsController {
+
+    private final RegisteredUserStatisticsService registeredUserStatisticsService;
+
+    @ApiOperation("查询 C 端注册用户数量")
+    @ApiOperationSupport(order = 1)
+    @GetMapping("/count")
+    public R<RegisteredUserCountVo> countRegisteredUsers() {
+        log.info("RegisteredUserStatisticsController.countRegisteredUsers");
+        return R.data(registeredUserStatisticsService.countRegisteredUsers());
+    }
+
+    @ApiOperation(value = "查询 C 端注册用户数量", notes = "响应体仅为数字字符串,Content-Type: text/plain")
+    @ApiOperationSupport(order = 2)
+    @GetMapping(value = "/countPlain", produces = MediaType.TEXT_PLAIN_VALUE)
+    public String countRegisteredUsersPlain() {
+        log.info("RegisteredUserStatisticsController.countRegisteredUsersPlain");
+        return String.valueOf(registeredUserStatisticsService.countRegisteredUserTotal());
+    }
+
+    @ApiOperation("查询店铺端注册用户数量")
+    @ApiOperationSupport(order = 3)
+    @GetMapping("/store/count")
+    public R<RegisteredStoreUserCountVo> countRegisteredStoreUsers() {
+        log.info("RegisteredUserStatisticsController.countRegisteredStoreUsers");
+        return R.data(registeredUserStatisticsService.countRegisteredStoreUsers());
+    }
+
+    @ApiOperation(value = "查询店铺端注册用户数量", notes = "响应体仅为数字字符串,Content-Type: text/plain")
+    @ApiOperationSupport(order = 4)
+    @GetMapping(value = "/store/countPlain", produces = MediaType.TEXT_PLAIN_VALUE)
+    public String countRegisteredStoreUsersPlain() {
+        log.info("RegisteredUserStatisticsController.countRegisteredStoreUsersPlain");
+        return String.valueOf(registeredUserStatisticsService.countRegisteredStoreUserTotal());
+    }
+
+    @ApiOperation("查询律师端注册用户数量")
+    @ApiOperationSupport(order = 5)
+    @GetMapping("/lawyer/count")
+    public R<RegisteredLawyerUserCountVo> countRegisteredLawyerUsers() {
+        log.info("RegisteredUserStatisticsController.countRegisteredLawyerUsers");
+        return R.data(registeredUserStatisticsService.countRegisteredLawyerUsers());
+    }
+
+    @ApiOperation(value = "查询律师端注册用户数量", notes = "响应体仅为数字字符串,Content-Type: text/plain")
+    @ApiOperationSupport(order = 6)
+    @GetMapping(value = "/lawyer/countPlain", produces = MediaType.TEXT_PLAIN_VALUE)
+    public String countRegisteredLawyerUsersPlain() {
+        log.info("RegisteredUserStatisticsController.countRegisteredLawyerUsersPlain");
+        return String.valueOf(registeredUserStatisticsService.countRegisteredLawyerUserTotal());
+    }
+}

+ 23 - 0
alien-store/src/main/java/shop/alien/store/service/RegisteredUserStatisticsService.java

@@ -0,0 +1,23 @@
+package shop.alien.store.service;
+
+import shop.alien.entity.store.vo.RegisteredLawyerUserCountVo;
+import shop.alien.entity.store.vo.RegisteredStoreUserCountVo;
+import shop.alien.entity.store.vo.RegisteredUserCountVo;
+
+/**
+ * 各端注册用户数量统计
+ */
+public interface RegisteredUserStatisticsService {
+
+    RegisteredUserCountVo countRegisteredUsers();
+
+    long countRegisteredUserTotal();
+
+    RegisteredStoreUserCountVo countRegisteredStoreUsers();
+
+    long countRegisteredStoreUserTotal();
+
+    RegisteredLawyerUserCountVo countRegisteredLawyerUsers();
+
+    long countRegisteredLawyerUserTotal();
+}

+ 70 - 0
alien-store/src/main/java/shop/alien/store/service/impl/RegisteredUserStatisticsServiceImpl.java

@@ -0,0 +1,70 @@
+package shop.alien.store.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+import shop.alien.entity.store.LawyerUser;
+import shop.alien.entity.store.LifeUser;
+import shop.alien.entity.store.StoreUser;
+import shop.alien.entity.store.vo.RegisteredLawyerUserCountVo;
+import shop.alien.entity.store.vo.RegisteredStoreUserCountVo;
+import shop.alien.entity.store.vo.RegisteredUserCountVo;
+import shop.alien.mapper.LawyerUserMapper;
+import shop.alien.mapper.LifeUserMapper;
+import shop.alien.mapper.StoreUserMapper;
+import shop.alien.store.service.RegisteredUserStatisticsService;
+
+@Slf4j
+@Service
+@RequiredArgsConstructor
+public class RegisteredUserStatisticsServiceImpl implements RegisteredUserStatisticsService {
+
+    private final LifeUserMapper lifeUserMapper;
+    private final StoreUserMapper storeUserMapper;
+    private final LawyerUserMapper lawyerUserMapper;
+
+    @Override
+    public RegisteredUserCountVo countRegisteredUsers() {
+        RegisteredUserCountVo vo = new RegisteredUserCountVo();
+        vo.setRegisteredUserCount(countRegisteredUserTotal());
+        return vo;
+    }
+
+    @Override
+    public long countRegisteredUserTotal() {
+        return toLong(lifeUserMapper.selectCount(new LambdaQueryWrapper<LifeUser>()));
+    }
+
+    @Override
+    public RegisteredStoreUserCountVo countRegisteredStoreUsers() {
+        RegisteredStoreUserCountVo vo = new RegisteredStoreUserCountVo();
+        vo.setRegisteredStoreUserCount(countRegisteredStoreUserTotal());
+        return vo;
+    }
+
+    @Override
+    public long countRegisteredStoreUserTotal() {
+        long total = toLong(storeUserMapper.selectCount(new LambdaQueryWrapper<StoreUser>()));
+        log.info("RegisteredUserStatisticsServiceImpl.countRegisteredStoreUserTotal total={}", total);
+        return total;
+    }
+
+    @Override
+    public RegisteredLawyerUserCountVo countRegisteredLawyerUsers() {
+        RegisteredLawyerUserCountVo vo = new RegisteredLawyerUserCountVo();
+        vo.setRegisteredLawyerUserCount(countRegisteredLawyerUserTotal());
+        return vo;
+    }
+
+    @Override
+    public long countRegisteredLawyerUserTotal() {
+        long total = toLong(lawyerUserMapper.selectCount(new LambdaQueryWrapper<LawyerUser>()));
+        log.info("RegisteredUserStatisticsServiceImpl.countRegisteredLawyerUserTotal total={}", total);
+        return total;
+    }
+
+    private static long toLong(Number count) {
+        return count != null ? count.longValue() : 0L;
+    }
+}