Browse Source

添加getInfo接口

lyhzzz 3 năm trước cách đây
mục cha
commit
d7876bf481

+ 1 - 0
src/main/java/com/fdkankan/manage/config/SaTokenConfigure.java

@@ -86,6 +86,7 @@ public class SaTokenConfigure {
         if(!redisUtil.hasKey(String.format(RedisKey.TOKEN_V3,StpUtil.getTokenValue()))){
             throw new BusinessException(ErrorCode.USER_NOT_LOGIN);
         }
+        redisUtil.expire(String.format(RedisKey.TOKEN_V3,StpUtil.getTokenValue()),21600);
         StpUtil.checkLogin();
     }
 

+ 23 - 4
src/main/java/com/fdkankan/manage/controller/SysUserController.java

@@ -1,17 +1,21 @@
 package com.fdkankan.manage.controller;
 
 
+import cn.dev33.satoken.stp.StpUtil;
 import com.fdkankan.common.constant.ErrorCode;
 import com.fdkankan.common.exception.BusinessException;
 import com.fdkankan.common.response.ResultData;
+import com.fdkankan.manage.entity.SysRole;
+import com.fdkankan.manage.entity.SysUser;
+import com.fdkankan.manage.service.ISysRoleService;
 import com.fdkankan.manage.service.ISysUserService;
 import com.fdkankan.manage.vo.request.SysUserParam;
+import com.fdkankan.manage.vo.response.ManageLoginResponse;
+import com.fdkankan.manage.vo.response.SysUserVo;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.util.StringUtils;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 /**
  * 系统用户
@@ -22,6 +26,21 @@ public class SysUserController  extends BaseController{
 
     @Autowired
     ISysUserService sysUserService;
+    @Autowired
+    ISysRoleService sysRoleService;
+
+
+    @GetMapping("/getInfo")
+    public ResultData getInfo(){
+        String loginId = (String) StpUtil.getLoginId();
+        SysUser sysUser = sysUserService.getById(Long.valueOf(loginId));
+        SysUserVo userVo = new SysUserVo();
+        SysRole role = sysRoleService.getById(sysUser.getRoleId());
+        userVo.setRoleId(role.getId());
+        userVo.setRoleName(role.getRoleName());
+        BeanUtils.copyProperties(sysUser,userVo);
+        return ResultData.ok(userVo);
+    }
 
     @PostMapping("/add")
     public ResultData add(@RequestBody SysUserParam param){