Commit d6cebe55 authored by 赵啸非's avatar 赵啸非

修改门户登录redistoken生成方案

parent 7fe649b7
......@@ -12,6 +12,7 @@ import com.mortals.framework.util.DateUtils;
import com.mortals.framework.util.StringUtils;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.common.code.YesNoEnum;
import com.mortals.xhx.common.key.Constant;
import com.mortals.xhx.common.pdu.SitePdu;
import com.mortals.xhx.feign.model.IApiModelFeign;
import com.mortals.xhx.feign.rsp.ApiResp;
......@@ -60,13 +61,15 @@ public class LoginController extends BaseCRUDJsonBodyMappingController<UserServi
loginForm.validate();
userEntity = userService.doLogin(loginName, password, ip);
userEntity.setLastLoginAddress(ip);
List<MenuEntity> menuList = menuService.findTreeMenuByUser(userEntity);
userEntity.setMenuList(menuList);
userEntity.setLoginTime(System.currentTimeMillis());
userEntity.setToken(IdUtil.fastSimpleUUID());
String tmpToken = userEntity.getId() + ":" + IdUtil.fastSimpleUUID();
userEntity.setToken(tmpToken);
userEntity.setExpireTime(DateUtils.addCurrDate(7).getTime());
String token = authTokenService.createToken(userEntity);
data.put("token", token);
List<MenuEntity> menuList = menuService.findTreeMenuByUser(userEntity);
userEntity.setMenuList(menuList);
data.put("user", userEntity);
if(StringUtils.isNotEmpty(userEntity.getAreaCodes())){
SitePdu sitePdu = new SitePdu();
......@@ -81,11 +84,15 @@ public class LoginController extends BaseCRUDJsonBodyMappingController<UserServi
data.put("siteList", apiResp.getData().get("data"));
}
recordSysLog(request, userEntity, "用户登录系统成功!");
ret.put(KEY_RESULT_DATA, data);
ret.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS);
ret.put(KEY_RESULT_MSG, "用户登录系统成功!");
//测试模糊获取所有redis中当前用户token
Set<String> hkeys = cacheService.hkeys(Constant.LOGIN_TOKEN_KEY + userEntity.getId() + ":*");
log.info("loginKeys:{}",JSON.toJSONString(hkeys));
return ret.toJSONString();
} catch (Exception e) {
log.error("login error ", e);
......
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