|
|
@@ -1,6 +1,7 @@
|
|
|
package com.roma.romaapi.service;
|
|
|
|
|
|
import com.roma.romaapi.dao.ApiDao;
|
|
|
+import com.roma.romaapi.utils.CommonUtil;
|
|
|
import com.roma.romaapi.utils.JWTUtil;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
|
@@ -23,6 +24,8 @@ public class ApiService {
|
|
|
SecurityUtils securityUtils;
|
|
|
@Autowired
|
|
|
JWTUtil jwtUtil;
|
|
|
+ @Autowired
|
|
|
+ CommonUtil commonUtil;
|
|
|
// 登录方法
|
|
|
public Map<String, Object> login(Map<String, String[]> maps) {
|
|
|
// 请求参数,获取验证码,验证码token,用户名,密码
|
|
|
@@ -72,4 +75,19 @@ public class ApiService {
|
|
|
|
|
|
return map;
|
|
|
}
|
|
|
+
|
|
|
+ // 获取头部用户信息
|
|
|
+ public Map<String, Object> userInfo(String headerToken) {
|
|
|
+ String userId = commonUtil.getUserIdByHeaderAuthorization(headerToken);
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ if (userId.length() > 0) {
|
|
|
+ // 获取用户信息
|
|
|
+ Map<String, Object> userInfo = apiDao.userInfoByIdQueryForMap(userId);
|
|
|
+ if (userInfo.containsKey("admin_name")) {
|
|
|
+ map.put("userName", userInfo.get("admin_name"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return map;
|
|
|
+ }
|
|
|
}
|