Commit 818e8ee1 by guanchen

修复缓存bug

parent 2dcd2caf
......@@ -3,6 +3,8 @@ package com.lanren.huhu.partner.controller;
import com.lanren.huhu.partner.manager.UserManager;
import com.lanren.huhu.partner.model.User;
import com.lanren.huhu.partner.result.Result;
import com.lanren.huhu.partner.service.PartnerAccountService;
import com.lanren.huhu.partner.util.PartnerTreeUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -22,6 +24,8 @@ public class UserController {
@Autowired
private UserManager userManager;
@Autowired
private PartnerAccountService partnerAccountService;
@RequestMapping(value = "/relation", method = RequestMethod.POST)
public Result<User> getRelation(@RequestBody @Valid User user, @RequestHeader HttpHeaders headers) {
......@@ -51,7 +55,8 @@ public class UserController {
logger.info("changeRelation userId:{},header:{},time:{}", user.getUserId(), headers.keySet().toArray(), LocalDateTime.now());
}
Result<String> result = new Result<String>();
if (userManager.changeRelation(user.getUserId())) {
PartnerTreeUtil partnerTreeUtil = new PartnerTreeUtil();
if (partnerTreeUtil.findPartnerChiledren(user.getUserId(), partnerAccountService, userManager)) {
result.setData("用户刷新成功");
} else {
result.setCode(500);
......
......@@ -7,7 +7,6 @@ import com.lanren.huhu.partner.model.ParentPartner;
import com.lanren.huhu.partner.model.User;
import com.lanren.huhu.partner.service.PartnerAccountService;
import com.lanren.huhu.partner.service.UserAgentService;
import com.lanren.huhu.partner.util.PartnerTreeUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -45,6 +44,7 @@ public class UserManager {
*/
@Cacheable
public User getRelationByUserId(Integer userId) {
logger.info("new a user object ");
if (logger.isDebugEnabled()) {
logger.info("new a user object ");
}
......@@ -220,9 +220,14 @@ public class UserManager {
* 根据输入的用户id, 刷新这个用户以及他邀请关系的所有下级的邀请关系
* @param userId
* @return
*/
public boolean changeRelation(int userId) {
PartnerTreeUtil partnerTreeUtil = new PartnerTreeUtil();
return partnerTreeUtil.findPartnerChiledren(userId, partnerAccountService, this);
}
*
* 废弃掉这个方法, 这个方法中new出的util对象, 会使用UserManager.this调用加上 清缓存 和 重写缓存 注解的方法
* 这样是不走缓存的, 也清不掉缓存的
*
* 改为从上级调用 从controller中
*/
// public boolean changeRelation(int userId) {
// PartnerTreeUtil partnerTreeUtil = new PartnerTreeUtil();
// return partnerTreeUtil.findPartnerChiledren(userId, partnerAccountService, this);
// }
}
......@@ -25,8 +25,6 @@ public class User extends BaseModel {
@Min(value = 1, message = "userId 需要大于0")
private int userId;
private int level;
private ArrayList<ParentPartner> partnerList;
private ArrayList<ParentAgent> agentList;
......
......@@ -53,6 +53,7 @@ public class PartnerTreeUtil {
* @param tree
*/
private void recursiveSet(PartnerTree tree) {
logger.info("do recursiveSet for userId: {}", tree.getUserId());
if (logger.isDebugEnabled()) {
logger.info("do recursiveSet for userId: {}", tree.getUserId());
}
......
......@@ -3,7 +3,7 @@ spring:
banner-mode: "off"
datasource:
#连接MySQL
url: @mysql.server@?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&allowMultiQueries=true
url: @mysql.server@?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&allowMultiQueries=true&serverTimezone=Asia/Shanghai
username: @mysql.username@
password: @mysql.password@
driver-class-name: com.mysql.cj.jdbc.Driver
......
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