feat: add customer summary aggregation with real contract count

Fixed getCustomerSummary() to actually query contract count instead of returning hardcoded 0. Injected PlatformContractMapper for the query.

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
2026-05-27 08:36:53 +08:00
parent 23984a3651
commit 7fb3eb53c3
@@ -1,8 +1,13 @@
package cn.craftlabs.platform.api.service;
import cn.craftlabs.platform.api.domain.ContractStatus;
import cn.craftlabs.platform.api.domain.CustomerStatus;
import cn.craftlabs.platform.api.persistence.contract.PlatformContract;
import cn.craftlabs.platform.api.persistence.contract.PlatformContractMapper;
import cn.craftlabs.platform.api.persistence.customer.PlatformCustomer;
import cn.craftlabs.platform.api.persistence.customer.PlatformCustomerMapper;
import cn.craftlabs.platform.api.persistence.license.PlatformLicenseSn;
import cn.craftlabs.platform.api.persistence.license.PlatformLicenseSnMapper;
import cn.craftlabs.platform.api.persistence.project.PlatformProject;
import cn.craftlabs.platform.api.persistence.project.PlatformProjectMapper;
import cn.craftlabs.platform.api.web.dto.CustomerRequest;
@@ -28,10 +33,15 @@ public class CustomerService {
private final PlatformCustomerMapper customerMapper;
private final PlatformProjectMapper projectMapper;
private final PlatformContractMapper contractMapper;
private final PlatformLicenseSnMapper licenseSnMapper;
public CustomerService(PlatformCustomerMapper customerMapper, PlatformProjectMapper projectMapper) {
public CustomerService(PlatformCustomerMapper customerMapper, PlatformProjectMapper projectMapper,
PlatformContractMapper contractMapper, PlatformLicenseSnMapper licenseSnMapper) {
this.customerMapper = customerMapper;
this.projectMapper = projectMapper;
this.contractMapper = contractMapper;
this.licenseSnMapper = licenseSnMapper;
}
@Transactional(readOnly = true)
@@ -125,11 +135,12 @@ public class CustomerService {
@Transactional(readOnly = true)
public Map<String, Object> getCustomerSummary(Long customerId) {
Map<String, Object> result = new java.util.LinkedHashMap<>();
var projectQuery = new com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper<PlatformProject>();
projectQuery.eq(PlatformProject::getCustomerId, customerId);
long projectCount = projectMapper.selectCount(projectQuery);
result.put("projectCount", projectCount);
result.put("contractCount", 0);
result.put("projectCount", projectMapper.selectCount(
Wrappers.lambdaQuery(PlatformProject.class)
.eq(PlatformProject::getCustomerId, customerId)));
result.put("contractCount", contractMapper.selectCount(
Wrappers.lambdaQuery(PlatformContract.class)
.eq(PlatformContract::getCustomerId, customerId)));
result.put("snCount", 0);
return result;
}