Skip to content

Commit 415ac6d

Browse files
committed
bugfix/修复部分错误
1 parent e694bba commit 415ac6d

File tree

5 files changed

+27
-153
lines changed

5 files changed

+27
-153
lines changed

pmhub-auth/src/main/java/com/laigeoffer/pmhub/auth/config/SecurityConfig.java

-143
This file was deleted.

pmhub-auth/src/main/java/com/laigeoffer/pmhub/auth/controller/LoginController.java

+14
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.laigeoffer.pmhub.auth.controller;
22

33
import com.laigeoffer.pmhub.auth.service.SysLoginService;
4+
import com.laigeoffer.pmhub.base.core.config.redis.RedisService;
45
import com.laigeoffer.pmhub.base.core.constant.Constants;
56
import com.laigeoffer.pmhub.base.core.core.domain.AjaxResult;
67
import com.laigeoffer.pmhub.base.core.core.domain.R;
@@ -37,6 +38,9 @@ public class LoginController {
3738
@Autowired
3839
private SysLoginService sysLoginService;
3940

41+
@Autowired
42+
private RedisService redisService;
43+
4044
@PostMapping("login")
4145
public AjaxResult login(@RequestBody LoginBody form) {
4246
AjaxResult ajax = success();
@@ -80,4 +84,14 @@ public R<?> register(@RequestBody RegisterBody registerBody) {
8084
}
8185

8286

87+
/**
88+
* 刷新 redis
89+
* @return
90+
*/
91+
@PostMapping("refreshRedis")
92+
public R<?> refreshRedis() {
93+
redisService.flushAll();
94+
return R.ok();
95+
}
96+
8397
}

pmhub-base/pmhub-base-core/src/main/java/com/laigeoffer/pmhub/base/core/config/redis/RedisService.java

+11-4
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@
22

33
import cn.hutool.core.util.ObjectUtil;
44
import org.springframework.beans.factory.annotation.Autowired;
5-
import org.springframework.data.redis.core.BoundSetOperations;
6-
import org.springframework.data.redis.core.HashOperations;
7-
import org.springframework.data.redis.core.RedisTemplate;
8-
import org.springframework.data.redis.core.ValueOperations;
5+
import org.springframework.data.redis.core.*;
96
import org.springframework.stereotype.Component;
107

118
import java.util.*;
@@ -261,4 +258,14 @@ public Map<String,Object> getCacheKv(String pattern){
261258
}
262259
return kv;
263260
}
261+
262+
/**
263+
* 删除所有缓存数据(慎用)
264+
*/
265+
public void flushAll() {
266+
redisTemplate.execute((RedisCallback<Object>) connection -> {
267+
connection.flushDb();
268+
return "OK";
269+
});
270+
}
264271
}

pmhub-base/pmhub-base-security/src/main/java/com/laigeoffer/pmhub/base/security/utils/SecurityUtils.java

-6
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,6 @@ public static LoginUser getLoginUser() {
6262
}
6363
}
6464

65-
/**
66-
* 获取Authentication
67-
*/
68-
// public static Authentication getAuthentication() {
69-
// return SecurityContextHolder.getContext().getAuthentication();
70-
// }
7165

7266
/**
7367
* 生成BCryptPasswordEncoder密码

pmhub-modules/pmhub-system/src/main/java/com/laigeoffer/pmhub/system/controller/SysUserController.java

+2
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,8 @@ public R<LoginUser> info(@PathVariable("username") String username) {
303303
loginUser.setUser(sysUser);
304304
loginUser.setRoles(roles);
305305
loginUser.setPermissions(permissions);
306+
loginUser.setUserId(sysUser.getUserId());
307+
loginUser.setDeptId(sysUser.getDeptId());
306308

307309

308310
return R.ok(loginUser);

0 commit comments

Comments
 (0)