BD团队more接口 新增缓存逻辑
This commit is contained in:
parent
bb23ff48e3
commit
6c2ff98b5e
@ -1,10 +1,13 @@
|
||||
package com.red.circle.other.app.command.bd.query;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.red.circle.component.redis.service.RedisService;
|
||||
import com.red.circle.framework.core.asserts.ResponseAssert;
|
||||
import com.red.circle.other.app.convertor.user.UserProfileAppConvertor;
|
||||
import com.red.circle.other.app.dto.clientobject.BdIncomeDetailCO;
|
||||
import com.red.circle.other.app.dto.clientobject.BdIncomeDetailMemberCO;
|
||||
import com.red.circle.other.app.dto.clientobject.BdTeamMemberDetailCO;
|
||||
import com.red.circle.other.app.dto.clientobject.BdTeamOverviewCO;
|
||||
import com.red.circle.other.app.dto.cmd.BdTeamMemberDetailQueryCmd;
|
||||
import com.red.circle.other.domain.gateway.user.UserProfileGateway;
|
||||
import com.red.circle.other.infra.database.mongo.dto.team.TeamBillMemberTarget;
|
||||
@ -30,6 +33,7 @@ import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@ -49,6 +53,7 @@ public class BdTeamMemberDetailQryExe {
|
||||
private final UserProfileGateway userProfileGateway;
|
||||
private final UserProfileAppConvertor userProfileAppConvertor;
|
||||
private final TeamProfileService teamProfileService;
|
||||
private final RedisService redisService;
|
||||
|
||||
/**
|
||||
* 执行查询
|
||||
@ -57,15 +62,29 @@ public class BdTeamMemberDetailQryExe {
|
||||
String type = cmd.getType();
|
||||
Long targetId = cmd.getTargetId();
|
||||
|
||||
if ("AGENCY".equals(type)) {
|
||||
// Agency视角:查询单个team的数据
|
||||
return queryAgencyDetail(targetId);
|
||||
} else if ("BD".equals(type)) {
|
||||
// BD视角:查询该BD下所有team的汇总数据
|
||||
return queryBdDetail(targetId);
|
||||
// 缓存查询
|
||||
String cacheKey = "bdteam:detail:" + type + ":" + targetId;
|
||||
BdTeamMemberDetailCO cached = redisService.getStringToObject(cacheKey, BdTeamMemberDetailCO.class);
|
||||
if (cached != null) {
|
||||
return cached;
|
||||
}
|
||||
|
||||
return new BdTeamMemberDetailCO();
|
||||
// 查询数据
|
||||
BdTeamMemberDetailCO result;
|
||||
if ("AGENCY".equals(type)) {
|
||||
// Agency视角:查询单个team的数据
|
||||
result = queryAgencyDetail(targetId);
|
||||
} else if ("BD".equals(type)) {
|
||||
// BD视角:查询该BD下所有team的汇总数据
|
||||
result = queryBdDetail(targetId);
|
||||
} else {
|
||||
result = new BdTeamMemberDetailCO();
|
||||
}
|
||||
|
||||
// 缓存结果(1分钟)
|
||||
redisService.setString(cacheKey, JSON.toJSONString(result), 1, TimeUnit.MINUTES);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user