Commit 42bf0f18 by guanchen

添加不读cache的接口

修复时间字段bug
parent e28d883e
...@@ -33,6 +33,14 @@ public class UserController { ...@@ -33,6 +33,14 @@ public class UserController {
return userManager.getRelationByUserId(user.getUserId()); return userManager.getRelationByUserId(user.getUserId());
} }
@RequestMapping(value = "/relation/nocache", method = RequestMethod.POST)
public Result<User> getRelationNoCache(@RequestBody @Valid User user, @RequestHeader HttpHeaders headers) {
if (logger.isInfoEnabled()) {
logger.info("getRelation userId:{},header:{},time:{}", user.getUserId(), headers.keySet().toArray(), LocalDateTime.now());
}
return userManager.getRelationNoCache(user.getUserId());
}
@RequestMapping(value = "/relation/delete", method = RequestMethod.POST) @RequestMapping(value = "/relation/delete", method = RequestMethod.POST)
public Result<String> deletrRelation(@RequestBody @Valid User user, @RequestHeader HttpHeaders headers) { public Result<String> deletrRelation(@RequestBody @Valid User user, @RequestHeader HttpHeaders headers) {
if (logger.isInfoEnabled()) { if (logger.isInfoEnabled()) {
......
...@@ -298,4 +298,11 @@ public class UserManager { ...@@ -298,4 +298,11 @@ public class UserManager {
private int updateCengjiRelation(String from, String to) { private int updateCengjiRelation(String from, String to) {
return userService.updateCengjiRelation(from, to); return userService.updateCengjiRelation(from, to);
} }
public Result<User> getRelationNoCache(int userId) {
User resutrnUser = userService.getRelationByUserIdRealtime(userId);
Result<User> result = new Result<User>();
result.setData(resutrnUser);
return result;
}
} }
...@@ -255,7 +255,7 @@ public class AgentRewardQueueTask { ...@@ -255,7 +255,7 @@ public class AgentRewardQueueTask {
int sourceUserLevel = partnerAccountService.getOneByUserId(message.getSourceUserId()).getPartnerLevel(); int sourceUserLevel = partnerAccountService.getOneByUserId(message.getSourceUserId()).getPartnerLevel();
AgentReward agentReward = new AgentReward(); AgentReward agentReward = new AgentReward();
agentReward.setRewardType(message.getRewardType()); agentReward.setRewardType(message.getRewardType());
agentReward.setRechargeTime(DateUtils.parse(message.getRechargeTime(), DateUtils.FORMAT_SHORT)); agentReward.setRechargeTime(DateUtils.parse(message.getRechargeTime(), DateUtils.FORMAT_LONG));
agentReward.setSourceUserId(message.getSourceUserId()); agentReward.setSourceUserId(message.getSourceUserId());
agentReward.setReferenceId(Long.parseLong(message.getReferenceId())); agentReward.setReferenceId(Long.parseLong(message.getReferenceId()));
agentReward.setAgentId(agent.getAgentId()); agentReward.setAgentId(agent.getAgentId());
......
package com.lanren.huhu.partner.service; import com.lanren.huhu.partner.domain.PartnerAccount;import com.lanren.huhu.partner.domain.UserAgent;import com.lanren.huhu.partner.model.ParentAgent;import com.lanren.huhu.partner.model.User; import java.util.List; /** * @author houseme * @date 2019-06-28 18:35 * @Project partner * @Package com.lanren.huhu.partner.service * @File: UserService */public interface UserService { /** * @description: 根据用户id, 查找一个用户的全部合伙人上级 和 代理商上级(此处为层级关系 非平推关系) * 缓存用户邀请关系和代理商关系数据 * 缓存不能带有构造方法的Bean 所以只能返回User的Bean * 包装Result在Cacheable注解的方法之外进行操作 * 注意 !!!!!!!! 这个方法是按输入用户的邀请关系链上查找 第一个有agent_level<=4的代理商身份的邀请人, 然后再走他的代理关系 * 注意 !!!!!!!! 如果需要获取一个代理商的上级代理 需要从UserAgentService里的方法获取 * @param userId * @return User * @throws * @author chen * @date 2019-06-26 20:01 */ User getRelationByUserId(Integer userId); List<ParentAgent> getAgentListByUserId(Integer userId, String parentColumnName); /** * 清理用户缓存 */ boolean deleteRalationByUserId(Integer userId); /*** * PartnerAccount * * 根据用户id查询账户信息 * @param userId * @return PartnerAccount */ PartnerAccount getPartnerAccountByUserId(Integer userId); /** * @description: 根据用户id查询全部直属下级合伙人 * @param userId * @return List<PartnerAccount> * @author chen * @date 2019-06-28 11:49 */ List<PartnerAccount> getPartnerAccountChildListByUserId(Integer userId); /*** * UserAgent * 根据用户id查询账户信息 * @param userId * @return */ UserAgent getUserAgentByUserId(Integer userId); /** * @description: 根据用户id查询全部直属下级代理商 * @param userId * @return List<PartnerAccount> * @author chen * @date 2019-06-28 11:49 */ List<UserAgent> getUserAgentChildListByUserId(Integer userId, String parentColumnName); int updatePartnerRelation(String from, String to); int updatePingtuiRelation(String from, String to); int updateCengjiRelation(String from, String to); PartnerAccount getPartnerAccountByPhone(String phone);} package com.lanren.huhu.partner.service; import com.lanren.huhu.partner.domain.PartnerAccount;import com.lanren.huhu.partner.domain.UserAgent;import com.lanren.huhu.partner.model.ParentAgent;import com.lanren.huhu.partner.model.User; import java.util.List; /** * @author houseme * @date 2019-06-28 18:35 * @Project partner * @Package com.lanren.huhu.partner.service * @File: UserService */public interface UserService { /** * @description: 根据用户id, 查找一个用户的全部合伙人上级 和 代理商上级(此处为层级关系 非平推关系) * 缓存用户邀请关系和代理商关系数据 * 缓存不能带有构造方法的Bean 所以只能返回User的Bean * 包装Result在Cacheable注解的方法之外进行操作 * 注意 !!!!!!!! 这个方法是按输入用户的邀请关系链上查找 第一个有agent_level<=4的代理商身份的邀请人, 然后再走他的代理关系 * 注意 !!!!!!!! 如果需要获取一个代理商的上级代理 需要从UserAgentService里的方法获取 * @param userId * @return User * @throws * @author chen * @date 2019-06-26 20:01 */ User getRelationByUserId(Integer userId); List<ParentAgent> getAgentListByUserId(Integer userId, String parentColumnName); /** * 清理用户缓存 */ boolean deleteRalationByUserId(Integer userId); /*** * PartnerAccount * * 根据用户id查询账户信息 * @param userId * @return PartnerAccount */ PartnerAccount getPartnerAccountByUserId(Integer userId); /** * @description: 根据用户id查询全部直属下级合伙人 * @param userId * @return List<PartnerAccount> * @author chen * @date 2019-06-28 11:49 */ List<PartnerAccount> getPartnerAccountChildListByUserId(Integer userId); /*** * UserAgent * 根据用户id查询账户信息 * @param userId * @return */ UserAgent getUserAgentByUserId(Integer userId); /** * @description: 根据用户id查询全部直属下级代理商 * @param userId * @return List<PartnerAccount> * @author chen * @date 2019-06-28 11:49 */ List<UserAgent> getUserAgentChildListByUserId(Integer userId, String parentColumnName); int updatePartnerRelation(String from, String to); int updatePingtuiRelation(String from, String to); int updateCengjiRelation(String from, String to); PartnerAccount getPartnerAccountByPhone(String phone); User getRelationByUserIdRealtime(Integer userId);}
\ No newline at end of file \ No newline at end of file
......
...@@ -58,6 +58,11 @@ public class UserServiceImpl implements UserService { ...@@ -58,6 +58,11 @@ public class UserServiceImpl implements UserService {
@Cacheable @Cacheable
public User getRelationByUserId(Integer userId) { public User getRelationByUserId(Integer userId) {
logger.info("UserServiceImpl get user relation from database, userId: {}", userId); logger.info("UserServiceImpl get user relation from database, userId: {}", userId);
return getRelationByUserIdRealtime(userId);
}
@Override
public User getRelationByUserIdRealtime(Integer userId) {
User user = new User(); User user = new User();
user.setUserId(userId); user.setUserId(userId);
user.setPartnerList((ArrayList<ParentPartner>) getPartnerListByUserId(userId)); user.setPartnerList((ArrayList<ParentPartner>) getPartnerListByUserId(userId));
...@@ -66,7 +71,7 @@ public class UserServiceImpl implements UserService { ...@@ -66,7 +71,7 @@ public class UserServiceImpl implements UserService {
return user; return user;
} }
@Override @Override
@CacheEvict(key = "#userId") @CacheEvict(key = "#userId")
public boolean deleteRalationByUserId(Integer userId) { public boolean deleteRalationByUserId(Integer userId) {
logger.info("UserServiceImpl delete user relation cache, userId: {}", userId); logger.info("UserServiceImpl delete user relation cache, userId: {}", userId);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment