feat: 首页统计

This commit is contained in:
caiyuchao
2025-07-15 19:47:02 +08:00
parent 7e04f2df4b
commit b17835039e
7 changed files with 68 additions and 1 deletions

View File

@@ -16,6 +16,7 @@ import org.agt.framework.ip.core.utils.AreaUtils;
import org.agt.module.license.controller.admin.customer.vo.CustomerPageReqVO;
import org.agt.module.license.controller.admin.customer.vo.CustomerRespVO;
import org.agt.module.license.controller.admin.customer.vo.CustomerSaveReqVO;
import org.agt.module.license.controller.admin.customer.vo.DashboardRespVO;
import org.agt.module.license.dal.dataobject.customer.CustomerDO;
import org.agt.module.license.service.customer.CustomerService;
import org.springframework.security.access.prepost.PreAuthorize;
@@ -44,6 +45,13 @@ public class CustomerController {
@Resource
private CustomerService customerService;
@GetMapping("/dashboard")
@Operation(summary = "获得首页数据")
public CommonResult<DashboardRespVO> dashboard() {
DashboardRespVO result = customerService.dashboard();
return success(result);
}
@PostMapping("/create")
@Operation(summary = "创建客户")
@PreAuthorize("@ss.hasPermission('license:customer:create')")

View File

@@ -0,0 +1,26 @@
package org.agt.module.license.controller.admin.customer.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
/**
* @description: dashboard vo
* @author: cyc
* @since: 2025-07-15
*/
@Schema(description = "首页 - dashboard Response VO")
@Data
public class DashboardRespVO {
@Schema(description = "客户数量")
private Long customerCount;
@Schema(description = "项目数量")
private Long projectCount;
@Schema(description = "license数量")
private Long licenseCount;
@Schema(description = "用户数量")
private Long userCount;
}

View File

@@ -41,4 +41,6 @@ public interface CustomerMapper extends BaseMapperX<CustomerDO> {
}
Integer selectMaxCode();
}
Long selectUserCount();
}

View File

@@ -4,6 +4,7 @@ import jakarta.validation.Valid;
import org.agt.framework.common.pojo.PageResult;
import org.agt.module.license.controller.admin.customer.vo.CustomerPageReqVO;
import org.agt.module.license.controller.admin.customer.vo.CustomerSaveReqVO;
import org.agt.module.license.controller.admin.customer.vo.DashboardRespVO;
import org.agt.module.license.dal.dataobject.customer.CustomerDO;
import java.util.List;
@@ -15,6 +16,8 @@ import java.util.List;
*/
public interface CustomerService {
DashboardRespVO dashboard();
/**
* 创建客户
*

View File

@@ -6,8 +6,11 @@ import org.agt.framework.common.pojo.PageResult;
import org.agt.framework.common.util.object.BeanUtils;
import org.agt.module.license.controller.admin.customer.vo.CustomerPageReqVO;
import org.agt.module.license.controller.admin.customer.vo.CustomerSaveReqVO;
import org.agt.module.license.controller.admin.customer.vo.DashboardRespVO;
import org.agt.module.license.dal.dataobject.customer.CustomerDO;
import org.agt.module.license.dal.mysql.customer.CustomerMapper;
import org.agt.module.license.dal.mysql.license.LicenseMapper;
import org.agt.module.license.dal.mysql.project.ProjectMapper;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
@@ -30,6 +33,25 @@ public class CustomerServiceImpl implements CustomerService {
@Resource
private CustomerMapper customerMapper;
@Resource
private ProjectMapper projectMapper;
@Resource
private LicenseMapper licenseMapper;
@Override
public DashboardRespVO dashboard() {
Long customerCount = customerMapper.selectCount();
Long projectCount = projectMapper.selectCount();
Long licenseCount = licenseMapper.selectCount();
DashboardRespVO dashboardRespVO = new DashboardRespVO();
dashboardRespVO.setCustomerCount(customerCount);
dashboardRespVO.setProjectCount(projectCount);
dashboardRespVO.setLicenseCount(licenseCount);
dashboardRespVO.setUserCount(customerMapper.selectUserCount());
return dashboardRespVO;
}
@Override
public Long createCustomer(CustomerSaveReqVO createReqVO) {
// 校验客户名称和编号是否唯一

View File

@@ -108,4 +108,6 @@ public class LicenseServiceImpl implements LicenseService {
}
return true;
}
}

View File

@@ -6,4 +6,8 @@
SELECT max(`code` + 0) from lic_customer;
</select>
<select id="selectUserCount" resultType="Long">
select count(*) - 1 from system_users WHERE deleted = 0;
</select>
</mapper>