|
|
|
@@ -9,6 +9,7 @@ import com.iformall.domain.po.WxAppinfo; |
|
|
|
import com.iformall.domain.po.WxCUser; |
|
|
|
import com.iformall.domain.po.WxCUserBasicInfo; |
|
|
|
import com.iformall.exception.MallinkException; |
|
|
|
import com.iformall.service.CUserTokenService; |
|
|
|
import com.iformall.service.WxAppinfoService; |
|
|
|
import com.iformall.service.WxCUserBasicInfoService; |
|
|
|
import com.iformall.service.WxCUserService; |
|
|
|
@@ -20,6 +21,7 @@ import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.beans.factory.annotation.Qualifier; |
|
|
|
import org.springframework.data.redis.core.RedisTemplate; |
|
|
|
import org.springframework.data.redis.core.ValueOperations; |
|
|
|
import org.springframework.web.bind.WebDataBinder; |
|
|
|
import org.springframework.web.bind.annotation.InitBinder; |
|
|
|
import org.springframework.web.bind.annotation.RestController; |
|
|
|
@@ -31,6 +33,7 @@ import java.beans.PropertyEditorSupport; |
|
|
|
import java.text.ParseException; |
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.concurrent.TimeUnit; |
|
|
|
|
|
|
|
@RestController |
|
|
|
public class BaseController { |
|
|
|
@@ -48,11 +51,14 @@ public class BaseController { |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private WxCUserBasicInfoService wxCUserBasicInfoService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private CUserTokenService cUserTokenService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
@Qualifier("baseCUserTokenRedisTemplate") |
|
|
|
RedisTemplate<String, BaseCUserEntity> baseCUserTokenRedisTemplate; |
|
|
|
|
|
|
|
|
|
|
|
@InitBinder |
|
|
|
public void InitBinder(WebDataBinder dataBinder) { |
|
|
|
dataBinder.registerCustomEditor(Date.class, new PropertyEditorSupport() { |
|
|
|
@@ -93,11 +99,11 @@ public class BaseController { |
|
|
|
return tenantEntity; |
|
|
|
} |
|
|
|
|
|
|
|
public Long getUserId() { |
|
|
|
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); |
|
|
|
Long cUserId = (Long) request.getAttribute(Constant.LOGIN_USER_KEY); |
|
|
|
return cUserId; |
|
|
|
} |
|
|
|
// public Long getUserId() { |
|
|
|
// HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); |
|
|
|
// Long cUserId = (Long) request.getAttribute(Constant.LOGIN_USER_KEY); |
|
|
|
// return cUserId; |
|
|
|
// } |
|
|
|
|
|
|
|
public Long getMemberId() throws Exception { |
|
|
|
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); |
|
|
|
@@ -113,8 +119,10 @@ public class BaseController { |
|
|
|
* 请尽量多用getTenantId, getUserId |
|
|
|
*/ |
|
|
|
public WxCUser getWxCUser() { |
|
|
|
Long cUserId = getUserId(); |
|
|
|
WxCUser user = wxCUserService.getById(cUserId); |
|
|
|
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); |
|
|
|
WxCUser user = (WxCUser) request.getAttribute(Constant.REQUEST_WX_C_USER_KEY); |
|
|
|
// Long cUserId = getUserId(); |
|
|
|
// WxCUser user = wxCUserService.getById(cUserId); |
|
|
|
if (user == null) { |
|
|
|
throw new MallinkException(ErrorCode.USER_IS_EMPTY); |
|
|
|
} |
|
|
|
@@ -127,7 +135,7 @@ public class BaseController { |
|
|
|
} |
|
|
|
return user; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* |
|
|
|
*/ |
|
|
|
|