package com.alatus.web;
import com.alatus.result.Result;
import com.alatus.result.SummaryData;
import com.alatus.service.StatisticService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class SummaryController {
@Resource
private StatisticService statisticService;
@GetMapping(value = "/api/summary/data")
public Result getSummary(){
SummaryData summaryData = statisticService.loadSummary();
return Result.OK(summaryData);
}
}
package com.alatus.web;
import com.alatus.result.Result;
import com.alatus.result.SummaryData;
import com.alatus.service.StatisticService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class SummaryController {
@Resource
private StatisticService statisticService;
@GetMapping(value = "/api/summary/data")
public Result getSummary(){
SummaryData summaryData = statisticService.loadSummary();
return Result.OK(summaryData);
}
}
package com.alatus.service;
import com.alatus.result.SummaryData;
public interface StatisticService {
SummaryData loadSummary();
}
package com.alatus.service;
import com.alatus.result.SummaryData;
public interface StatisticService {
SummaryData loadSummary();
}
package com.alatus.service.impl;
import com.alatus.manager.StatisticManager;
import com.alatus.result.SummaryData;
import com.alatus.service.StatisticService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
@Service
public class StatisticServiceImpl implements StatisticService {
@Resource
private StatisticManager statisticManager;
@Override
public SummaryData loadSummary() {
return statisticManager.loadSummaryData();
}
}
package com.alatus.service.impl;
import com.alatus.manager.StatisticManager;
import com.alatus.result.SummaryData;
import com.alatus.service.StatisticService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
@Service
public class StatisticServiceImpl implements StatisticService {
@Resource
private StatisticManager statisticManager;
@Override
public SummaryData loadSummary() {
return statisticManager.loadSummaryData();
}
}
package com.alatus.manager;
import com.alatus.mapper.TActivityMapper;
import com.alatus.mapper.TClueMapper;
import com.alatus.mapper.TCustomerMapper;
import com.alatus.mapper.TTranMapper;
import com.alatus.result.SummaryData;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Component;
import java.math.BigDecimal;
@Component
public class StatisticManager {
@Resource
private TActivityMapper tActivityMapper;
@Resource
private TClueMapper tClueMapper;
@Resource
private TCustomerMapper tCustomerMapper;
@Resource
private TTranMapper tTranMapper;
public SummaryData loadSummaryData() {
//有效的市场活动总数
Integer effectiveActivityCount = 0;
//总的市场活动数
Integer totalActivityCount = 0;
//线索总数
Integer totalClueCount = 0;
//客户总数
Integer totalCustomerCount = 0;
//成功的交易额
BigDecimal successTranAmount = new BigDecimal(0);
//总的交易额(包含成功和不成功的)
BigDecimal totalTranAmount = new BigDecimal(0);
return SummaryData.builder()
.effectiveActivityCount(effectiveActivityCount)
.totalActivityCount(totalActivityCount)
.totalClueCount(totalClueCount)
.totalCustomerCount(totalCustomerCount)
.successTranAmount(successTranAmount)
.totalTranAmount(totalTranAmount)
.build();
}
}
package com.alatus.manager;
import com.alatus.mapper.TActivityMapper;
import com.alatus.mapper.TClueMapper;
import com.alatus.mapper.TCustomerMapper;
import com.alatus.mapper.TTranMapper;
import com.alatus.result.SummaryData;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Component;
import java.math.BigDecimal;
@Component
public class StatisticManager {
@Resource
private TActivityMapper tActivityMapper;
@Resource
private TClueMapper tClueMapper;
@Resource
private TCustomerMapper tCustomerMapper;
@Resource
private TTranMapper tTranMapper;
public SummaryData loadSummaryData() {
//有效的市场活动总数
Integer effectiveActivityCount = 0;
//总的市场活动数
Integer totalActivityCount = 0;
//线索总数
Integer totalClueCount = 0;
//客户总数
Integer totalCustomerCount = 0;
//成功的交易额
BigDecimal successTranAmount = new BigDecimal(0);
//总的交易额(包含成功和不成功的)
BigDecimal totalTranAmount = new BigDecimal(0);
return SummaryData.builder()
.effectiveActivityCount(effectiveActivityCount)
.totalActivityCount(totalActivityCount)
.totalClueCount(totalClueCount)
.totalCustomerCount(totalCustomerCount)
.successTranAmount(successTranAmount)
.totalTranAmount(totalTranAmount)
.build();
}
}
package com.alatus.result;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.math.BigDecimal;
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Data
public class SummaryData {
//有效的市场活动总数
private Integer effectiveActivityCount;
//总的市场活动数
private Integer totalActivityCount;
//线索总数
private Integer totalClueCount;
//客户总数
private Integer totalCustomerCount;
//成功的交易额
private BigDecimal successTranAmount;
//总的交易额(包含成功和不成功的)
private BigDecimal totalTranAmount;
}
package com.alatus.result;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.math.BigDecimal;
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Data
public class SummaryData {
//有效的市场活动总数
private Integer effectiveActivityCount;
//总的市场活动数
private Integer totalActivityCount;
//线索总数
private Integer totalClueCount;
//客户总数
private Integer totalCustomerCount;
//成功的交易额
private BigDecimal successTranAmount;
//总的交易额(包含成功和不成功的)
private BigDecimal totalTranAmount;
}