| @@ -129,7 +129,7 @@ public class BaseController { | |||||
| if (baseuser.getRealUser() == null) { | if (baseuser.getRealUser() == null) { | ||||
| throw new MallinkException(ErrorCode.USER_IS_EMPTY); | throw new MallinkException(ErrorCode.USER_IS_EMPTY); | ||||
| } | } | ||||
| WxCUser user = (WxCUser) baseuser.getRealUser(); | |||||
| WxCUser user = baseuser.getObjectFromMap(WxCUser.class); | |||||
| TenantEntity tenantEntity = getTenantInfo(); | TenantEntity tenantEntity = getTenantInfo(); | ||||
| if (user.getTenantId() == null) { | if (user.getTenantId() == null) { | ||||
| user.setTenantId(tenantEntity.getTenantId()); | user.setTenantId(tenantEntity.getTenantId()); | ||||
| @@ -1,5 +1,6 @@ | |||||
| package com.iformall.domain.po.base; | package com.iformall.domain.po.base; | ||||
| import com.alibaba.fastjson.JSONObject; | |||||
| import com.baomidou.mybatisplus.annotation.TableField; | import com.baomidou.mybatisplus.annotation.TableField; | ||||
| import com.iformall.utils.Constant; | import com.iformall.utils.Constant; | ||||
| import com.iformall.utils.UserUtil; | import com.iformall.utils.UserUtil; | ||||
| @@ -8,6 +9,8 @@ import lombok.EqualsAndHashCode; | |||||
| import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
| import java.util.Date; | import java.util.Date; | ||||
| import java.util.LinkedHashMap; | |||||
| import java.util.Map; | |||||
| import java.util.UUID; | import java.util.UUID; | ||||
| /** | /** | ||||
| @@ -29,9 +32,13 @@ public class BaseCUserEntity extends TenantEntity { | |||||
| @io.swagger.annotations.ApiModelProperty(value="用户过期时间",name="expireTime") | @io.swagger.annotations.ApiModelProperty(value="用户过期时间",name="expireTime") | ||||
| private Date 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) | @TableField(exist = false) | ||||
| private Object realUser; | |||||
| private Map realUser; | |||||
| public <T> T getObjectFromMap(Class<T> clazz) { | |||||
| return JSONObject.parseObject(JSONObject.toJSONString(realUser), clazz); | |||||
| } | |||||
| /** | /** | ||||
| * 是否是会员 | * 是否是会员 | ||||
| @@ -1,8 +1,12 @@ | |||||
| package com.iformall.service.cuser.wx; | package com.iformall.service.cuser.wx; | ||||
| import java.util.Map; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.stereotype.Service; | 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.WxCUser; | ||||
| import com.iformall.domain.po.base.BaseCUserEntity; | import com.iformall.domain.po.base.BaseCUserEntity; | ||||
| import com.iformall.mapper.WxCUserMapper; | import com.iformall.mapper.WxCUserMapper; | ||||
| @@ -22,7 +26,7 @@ public class WxCUserServiceAdapter implements CUserServiceApapter{ | |||||
| entity.setExpireTime(wxCUser.getExpireTime()); | entity.setExpireTime(wxCUser.getExpireTime()); | ||||
| entity.setUserId(wxCUser.getUserId()); | entity.setUserId(wxCUser.getUserId()); | ||||
| entity.setToken(wxCUser.getToken()); | entity.setToken(wxCUser.getToken()); | ||||
| entity.setRealUser(wxCUser); | |||||
| entity.setRealUser(JSON.parseObject(JSON.toJSONString(wxCUser, SerializerFeature.WriteNullStringAsEmpty, SerializerFeature.WriteNullNumberAsZero, SerializerFeature.WriteMapNullValue), Map.class)); | |||||
| return entity; | return entity; | ||||
| } | } | ||||