Commit e13759a1 by 墨竹

feat:bug修改

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