Commit e13759a1 by 墨竹

feat:bug修改

parent 6452dad1
package com.gic.haoban.manage.web.auth;
import com.alibaba.fastjson.JSON;
import com.gic.haoban.common.utils.EntityUtil;
import com.gic.haoban.manage.api.dto.LoginDTO;
import com.gic.redis.data.util.RedisUtil;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.lang3.StringUtils;
......@@ -21,6 +23,7 @@ import java.util.concurrent.TimeUnit;
*
* @author hua
*/
@Deprecated
public class AuthRequestUtil {
private static final Logger logger = LoggerFactory.getLogger(AuthRequestUtil.class);
......@@ -43,8 +46,8 @@ public class AuthRequestUtil {
if (StringUtils.isBlank(token)) {
return null;
}
Object cache = RedisUtil.getCache(token);
return cache;
//为了做兼容
return EntityUtil.changeEntityByJSON(LoginDTO.class, RedisUtil.getCache(token));
}
private static void setLoginUserLastToken(String token, Object obj) {
......@@ -104,16 +107,18 @@ public class AuthRequestUtil {
RedisUtil.delCache(token);
}
public static void setAppLoginUser(Object obj,String token) {
public static void setAppLoginUser(Object obj, String token) {
RedisUtil.setCache(token, obj, 30L, TimeUnit.DAYS);
getResponse().setHeader("token", token);
//setLoginUserLastToken(token, obj);
}
public static void setAppFakeLoginUser(Object obj) {
String token = getRequest().getHeader("token");
RedisUtil.setCache(token, obj, 30L, TimeUnit.DAYS);
getResponse().setHeader("token", token);
}
public static HttpSession getSession() {
HttpSession session = null;
try {
......@@ -138,9 +143,9 @@ public class AuthRequestUtil {
public static Object getLoginUser() {
Cookie[] cookies = AuthRequestUtil.getRequest().getCookies();
String token = "";
if(cookies != null){
if (cookies != null) {
for (Cookie cookie : cookies) {
if(cookie.getName().equals("token")){
if (cookie.getName().equals("token")) {
token = cookie.getValue();
}
}
......
package com.gic.haoban.manage.web.controller;
import com.gic.haoban.auth.api.dto.DisplayRelationShortInfoDTO;
import com.gic.haoban.common.utils.AuthWebRequestUtil;
import com.gic.haoban.common.utils.EntityUtil;
import com.gic.haoban.common.utils.HaobanResponse;
import com.gic.haoban.manage.api.dto.LoginDTO;
import com.gic.haoban.manage.web.auth.AuthRequestUtil;
import com.gic.haoban.manage.web.errCode.HaoBanErrCode;
import org.apache.commons.collections.CollectionUtils;
......@@ -35,7 +36,8 @@ public class WebBaseController {
public HaobanResponse resultResponse(HaoBanErrCode errCode) {
return resultResponse(errCode, null, null);
}
public HaobanResponse resultResponse(HaoBanErrCode errCode, String message,Object data,String detailError) {
public HaobanResponse resultResponse(HaoBanErrCode errCode, String message, Object data, String detailError) {
HaobanResponse response = new HaobanResponse();
response.setMessage(message);
response.setDetailError(detailError);
......@@ -43,38 +45,35 @@ public class WebBaseController {
return response;
}
/**
* 获取登陆信息
*
* @return
*/
protected LoginDTO getLoginUser() {
LoginDTO login = (LoginDTO) AuthRequestUtil.getLoginUser();
return login;
//为了做兼容
Object loginUser = AuthWebRequestUtil.getLoginUser();
return EntityUtil.changeEntityByJSON(LoginDTO.class, loginUser);
}
public boolean haveRight(List<DisplayRelationShortInfoDTO> list){
public boolean haveRight(List<DisplayRelationShortInfoDTO> list) {
List<String> groupList = new ArrayList<String>();
List<String> storeList = new ArrayList<String>();
List<String> clerkList = new ArrayList<String>();
if(list==null){
if (list == null) {
return false;
}
for(DisplayRelationShortInfoDTO showDto :list){
if(showDto.getGroupId()!=null){
for (DisplayRelationShortInfoDTO showDto : list) {
if (showDto.getGroupId() != null) {
groupList.add(showDto.getGroupId());
}
if(showDto.getStoreId()!=null){
if (showDto.getStoreId() != null) {
storeList.add(showDto.getStoreId());
}
if(showDto.getClerkId()!=null){
if (showDto.getClerkId() != null) {
clerkList.add(showDto.getClerkId());
}
}
if(CollectionUtils.isEmpty(groupList) && CollectionUtils.isEmpty(storeList) && CollectionUtils.isEmpty(clerkList)){
return false;
}
return true;
return !CollectionUtils.isEmpty(groupList) || !CollectionUtils.isEmpty(storeList) || !CollectionUtils.isEmpty(clerkList);
}
}
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