Sfoglia il codice sorgente

fix wxcuser cache

release_toaliyun_real
xiaohanzi 5 anni fa
parent
commit
8706e6e4b3
3 ha cambiato i file con 15 aggiunte e 4 eliminazioni
  1. +1
    -1
      mallinkCApi/src/main/java/com/iformall/controller/BaseController.java
  2. +9
    -2
      mallinkService/src/main/java/com/iformall/domain/po/base/BaseCUserEntity.java
  3. +5
    -1
      mallinkService/src/main/java/com/iformall/service/cuser/wx/WxCUserServiceAdapter.java

+ 1
- 1
mallinkCApi/src/main/java/com/iformall/controller/BaseController.java Vedi File

@@ -129,7 +129,7 @@ public class BaseController {
if (baseuser.getRealUser() == null) {
throw new MallinkException(ErrorCode.USER_IS_EMPTY);
}
WxCUser user = (WxCUser) baseuser.getRealUser();
WxCUser user = baseuser.getObjectFromMap(WxCUser.class);
TenantEntity tenantEntity = getTenantInfo();
if (user.getTenantId() == null) {
user.setTenantId(tenantEntity.getTenantId());


+ 9
- 2
mallinkService/src/main/java/com/iformall/domain/po/base/BaseCUserEntity.java Vedi File

@@ -1,5 +1,6 @@
package com.iformall.domain.po.base;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.annotation.TableField;
import com.iformall.utils.Constant;
import com.iformall.utils.UserUtil;
@@ -8,6 +9,8 @@ import lombok.EqualsAndHashCode;
import org.apache.commons.lang3.StringUtils;

import java.util.Date;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.UUID;

/**
@@ -29,9 +32,13 @@ public class BaseCUserEntity extends TenantEntity {
@io.swagger.annotations.ApiModelProperty(value="用户过期时间",name="expireTime")
private Date expireTime;
@io.swagger.annotations.ApiModelProperty(value="真实对象如wxCUser",name="realUser")
@io.swagger.annotations.ApiModelProperty(value="真实对象如wxCUser,因为放到缓存之后,实体会变为map,索性就存map",name="realUser")
@TableField(exist = false)
private Object realUser;
private Map realUser;
public <T> T getObjectFromMap(Class<T> clazz) {
return JSONObject.parseObject(JSONObject.toJSONString(realUser), clazz);
}

/**
* 是否是会员


+ 5
- 1
mallinkService/src/main/java/com/iformall/service/cuser/wx/WxCUserServiceAdapter.java Vedi File

@@ -1,8 +1,12 @@
package com.iformall.service.cuser.wx;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.iformall.domain.po.WxCUser;
import com.iformall.domain.po.base.BaseCUserEntity;
import com.iformall.mapper.WxCUserMapper;
@@ -22,7 +26,7 @@ public class WxCUserServiceAdapter implements CUserServiceApapter{
entity.setExpireTime(wxCUser.getExpireTime());
entity.setUserId(wxCUser.getUserId());
entity.setToken(wxCUser.getToken());
entity.setRealUser(wxCUser);
entity.setRealUser(JSON.parseObject(JSON.toJSONString(wxCUser, SerializerFeature.WriteNullStringAsEmpty, SerializerFeature.WriteNullNumberAsZero, SerializerFeature.WriteMapNullValue), Map.class));
return entity;
}



Caricamento…
Annulla
Salva