From 3cd336d1ccd3d661d753ad7155a40017381fea9d Mon Sep 17 00:00:00 2001 From: "DESKTOP-BE1EA0I\\14194" <1419499670@qq.com> Date: Wed, 21 Sep 2022 10:48:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/org/nl/aspect/LogAspect.java | 4 ++-- .../src/main/java/org/nl/rest/LogController.java | 4 ++-- .../mnt/service/impl/DeployServiceImpl.java | 2 +- .../security/satoken/StpInterfaceImpl.java | 15 ++------------- .../nl/modules/system/rest/UserController.java | 6 ++---- .../service/impl/CodeDetailServiceImpl.java | 7 ++++--- .../system/service/impl/GenCodeServiceImpl.java | 7 ++++--- .../system/service/impl/GridFieldServiceImpl.java | 10 ++++------ .../system/service/impl/GridServiceImpl.java | 7 +++---- .../system/service/impl/ParamServiceImpl.java | 7 +++---- .../system/service/impl/RoleServiceImpl.java | 5 +---- .../system/service/impl/UserServiceImpl.java | 3 +-- 12 files changed, 29 insertions(+), 48 deletions(-) diff --git a/nladmin-logging/src/main/java/org/nl/aspect/LogAspect.java b/nladmin-logging/src/main/java/org/nl/aspect/LogAspect.java index 610001c85..a9b5c2475 100644 --- a/nladmin-logging/src/main/java/org/nl/aspect/LogAspect.java +++ b/nladmin-logging/src/main/java/org/nl/aspect/LogAspect.java @@ -28,6 +28,7 @@ import org.aspectj.lang.reflect.MethodSignature; import org.nl.domain.Log; import org.nl.service.LogService; import org.nl.utils.RequestHolder; +import org.nl.utils.SecurityUtils; import org.nl.utils.StringUtils; import org.springframework.stereotype.Component; import org.springframework.web.bind.annotation.RequestBody; @@ -139,8 +140,7 @@ public class LogAspect { public String getUsername() { try { -// return SecurityUtils.getCurrentUsername(); - return ""; + return SecurityUtils.getCurrentUsername(); }catch (Exception e){ return ""; } diff --git a/nladmin-logging/src/main/java/org/nl/rest/LogController.java b/nladmin-logging/src/main/java/org/nl/rest/LogController.java index 22b474e44..bc9612e7c 100644 --- a/nladmin-logging/src/main/java/org/nl/rest/LogController.java +++ b/nladmin-logging/src/main/java/org/nl/rest/LogController.java @@ -21,6 +21,7 @@ import lombok.RequiredArgsConstructor; import org.nl.annotation.Log; import org.nl.service.LogService; import org.nl.service.dto.LogQueryCriteria; +import org.nl.utils.SecurityUtils; import org.springframework.data.domain.Pageable; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; @@ -49,8 +50,7 @@ public class LogController { // @ApiOperation("用户日志查询") public ResponseEntity queryUserLog(LogQueryCriteria criteria, Pageable pageable){ criteria.setLogType("INFO"); -// criteria.setBlurry(SecurityUtils.getCurrentUsername()); - criteria.setBlurry(""); + criteria.setBlurry(SecurityUtils.getCurrentUsername()); return new ResponseEntity<>(logService.queryAllByUser(criteria,pageable), HttpStatus.OK); } diff --git a/nladmin-system/src/main/java/org/nl/modules/mnt/service/impl/DeployServiceImpl.java b/nladmin-system/src/main/java/org/nl/modules/mnt/service/impl/DeployServiceImpl.java index 772de6699..6b9f7b6aa 100644 --- a/nladmin-system/src/main/java/org/nl/modules/mnt/service/impl/DeployServiceImpl.java +++ b/nladmin-system/src/main/java/org/nl/modules/mnt/service/impl/DeployServiceImpl.java @@ -204,7 +204,7 @@ public class DeployServiceImpl implements DeployService { //还原信息入库 DeployHistory deployHistory = new DeployHistory(); deployHistory.setAppName(appName); -// deployHistory.setDeployUser(SecurityUtils.getCurrentUsername()); + deployHistory.setDeployUser(SecurityUtils.getCurrentUsername()); deployHistory.setIp(ip); deployHistory.setDeployId(id); deployHistoryService.create(deployHistory); diff --git a/nladmin-system/src/main/java/org/nl/modules/security/satoken/StpInterfaceImpl.java b/nladmin-system/src/main/java/org/nl/modules/security/satoken/StpInterfaceImpl.java index 9f8eece41..070435b9e 100644 --- a/nladmin-system/src/main/java/org/nl/modules/security/satoken/StpInterfaceImpl.java +++ b/nladmin-system/src/main/java/org/nl/modules/security/satoken/StpInterfaceImpl.java @@ -1,6 +1,7 @@ package org.nl.modules.security.satoken; import cn.dev33.satoken.stp.StpInterface; +import cn.dev33.satoken.stp.StpUtil; import org.nl.modules.system.service.RoleService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -18,23 +19,11 @@ public class StpInterfaceImpl implements StpInterface { @Autowired private RoleService roleService; - /** - * 权限校验 - 获取用户权限 - * @param o - * @param s - * @return - */ @Override public List getPermissionList(Object o, String s) { - return roleService.getPermissionList((String) o); + return roleService.getPermissionList((String) StpUtil.getLoginId()); } - /** - * 获取用户角色 - * @param o - * @param s - * @return - */ @Override public List getRoleList(Object o, String s) { return null; diff --git a/nladmin-system/src/main/java/org/nl/modules/system/rest/UserController.java b/nladmin-system/src/main/java/org/nl/modules/system/rest/UserController.java index ba2b9953e..bb8b55fe2 100644 --- a/nladmin-system/src/main/java/org/nl/modules/system/rest/UserController.java +++ b/nladmin-system/src/main/java/org/nl/modules/system/rest/UserController.java @@ -84,8 +84,7 @@ public class UserController { criteria.getDeptIds().addAll(deptService.getDeptChildren(deptService.findByPid(criteria.getDeptId()))); } // 数据权限 -// List dataScopes = dataService.getDeptIds(userService.findByName(SecurityUtils.getCurrentUsername())); - List dataScopes = dataService.getDeptIds(userService.findByName("")); + List dataScopes = dataService.getDeptIds(userService.findByName(SecurityUtils.getCurrentUsername())); // criteria.getDeptIds() 不为空并且数据权限不为空则取交集 if (!CollectionUtils.isEmpty(criteria.getDeptIds()) && !CollectionUtils.isEmpty(dataScopes)){ // 取交集 @@ -178,8 +177,7 @@ public class UserController { @PostMapping(value = "/updateEmail/{code}") public ResponseEntity updateEmail(@PathVariable String code,@RequestBody User user) throws Exception { String password = RsaUtils.decryptByPrivateKey(RsaProperties.privateKey,user.getPassword()); -// UserDto userDto = userService.findByName(SecurityUtils.getCurrentUsername()); - UserDto userDto = userService.findByName(""); + UserDto userDto = userService.findByName(SecurityUtils.getCurrentUsername()); // if(!passwordEncoder.matches(password, userDto.getPassword())){ // throw new BadRequestException("密码错误"); // } diff --git a/nladmin-system/src/main/java/org/nl/modules/system/service/impl/CodeDetailServiceImpl.java b/nladmin-system/src/main/java/org/nl/modules/system/service/impl/CodeDetailServiceImpl.java index eecdda2ed..48255c335 100644 --- a/nladmin-system/src/main/java/org/nl/modules/system/service/impl/CodeDetailServiceImpl.java +++ b/nladmin-system/src/main/java/org/nl/modules/system/service/impl/CodeDetailServiceImpl.java @@ -2,9 +2,10 @@ package org.nl.modules.system.service.impl; import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.IdUtil; -import lombok.RequiredArgsConstructor; import com.alibaba.fastjson.JSONObject; +import lombok.RequiredArgsConstructor; import org.nl.modules.system.service.CodeDetailService; +import org.nl.utils.SecurityUtils; import org.nl.wql.core.bean.ResultBean; import org.nl.wql.core.bean.WQLObject; import org.nl.wql.util.WqlUtil; @@ -47,7 +48,7 @@ public class CodeDetailServiceImpl implements CodeDetailService { json.put("code_rule_id",dict.get("id")); json.put("is_active","1"); json.put("is_delete","0"); -// json.put("create_by",SecurityUtils.getCurrentUsername()); + json.put("create_by", SecurityUtils.getCurrentUsername()); json.put("create_time", now); if(form.get("type").equals("02")){ Date date = DateUtil.date(); @@ -68,7 +69,7 @@ public class CodeDetailServiceImpl implements CodeDetailService { public void update(JSONObject json) { String now = DateUtil.now(); json.put("update_time",now); -// json.put("update_by", SecurityUtils.getCurrentUsername()); + json.put("update_by", SecurityUtils.getCurrentUsername()); WQLObject.getWQLObject("sys_code_rule_detail").update(json); } } diff --git a/nladmin-system/src/main/java/org/nl/modules/system/service/impl/GenCodeServiceImpl.java b/nladmin-system/src/main/java/org/nl/modules/system/service/impl/GenCodeServiceImpl.java index 1d2b24b5b..56233947e 100644 --- a/nladmin-system/src/main/java/org/nl/modules/system/service/impl/GenCodeServiceImpl.java +++ b/nladmin-system/src/main/java/org/nl/modules/system/service/impl/GenCodeServiceImpl.java @@ -3,11 +3,12 @@ package org.nl.modules.system.service.impl; import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.StrUtil; -import lombok.RequiredArgsConstructor; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; +import lombok.RequiredArgsConstructor; import org.nl.exception.BadRequestException; import org.nl.modules.system.service.GenCodeService; +import org.nl.utils.SecurityUtils; import org.nl.wql.core.bean.ResultBean; import org.nl.wql.core.bean.WQLObject; import org.nl.wql.util.WqlUtil; @@ -63,7 +64,7 @@ public class GenCodeServiceImpl implements GenCodeService { json.put("name", form.get("name")); json.put("is_active", "1"); json.put("is_delete", "0"); -// json.put("create_by", SecurityUtils.getCurrentUsername()); + json.put("create_by", SecurityUtils.getCurrentUsername()); json.put("create_time", now); WQLObject.getWQLObject("sys_code_rule").insert(json); } @@ -87,7 +88,7 @@ public class GenCodeServiceImpl implements GenCodeService { } String now = DateUtil.now(); json.put("update_time", now); -// json.put("update_by", SecurityUtils.getCurrentUsername()); + json.put("update_by", SecurityUtils.getCurrentUsername()); WQLObject.getWQLObject("sys_code_rule").update(json); } diff --git a/nladmin-system/src/main/java/org/nl/modules/system/service/impl/GridFieldServiceImpl.java b/nladmin-system/src/main/java/org/nl/modules/system/service/impl/GridFieldServiceImpl.java index 5b6271645..0f7600083 100644 --- a/nladmin-system/src/main/java/org/nl/modules/system/service/impl/GridFieldServiceImpl.java +++ b/nladmin-system/src/main/java/org/nl/modules/system/service/impl/GridFieldServiceImpl.java @@ -10,6 +10,7 @@ import lombok.extern.slf4j.Slf4j; import org.nl.exception.BadRequestException; import org.nl.modules.system.service.GridFieldService; import org.nl.modules.system.service.dto.GridFieldDto; +import org.nl.utils.SecurityUtils; import org.nl.wql.WQL; import org.nl.wql.core.bean.WQLObject; import org.nl.wql.util.WqlUtil; @@ -45,8 +46,7 @@ public class GridFieldServiceImpl implements GridFieldService { @Override @Transactional(rollbackFor = Exception.class) public void create(GridFieldDto dto) { -// String currentUsername = SecurityUtils.getCurrentUsername(); - String currentUsername = ""; + String currentUsername = SecurityUtils.getCurrentUsername(); String now = DateUtil.now(); dto.setId(IdUtil.simpleUUID()); @@ -74,8 +74,7 @@ public class GridFieldServiceImpl implements GridFieldService { GridFieldDto entity = this.findById(dto.getId()); if (entity == null) throw new BadRequestException("被删除或无权限,操作失败!"); -// String currentUsername = SecurityUtils.getCurrentUsername(); - String currentUsername = ""; + String currentUsername = SecurityUtils.getCurrentUsername(); String now = DateUtil.now(); dto.setUpdate_time(now); dto.setUpdate_by(currentUsername); @@ -103,8 +102,7 @@ public class GridFieldServiceImpl implements GridFieldService { String grid_id = json.getString("grid_id"); JSONArray fieldDatas = json.getJSONArray("gridFieldData"); WQLObject wo = WQLObject.getWQLObject("sys_grid_field"); -// String currentUsername = SecurityUtils.getCurrentUsername(); - String currentUsername = ""; + String currentUsername = SecurityUtils.getCurrentUsername(); // 先删除原先所有的数据 wo.delete("grid_id = '" + grid_id + "'"); // 然后添加 diff --git a/nladmin-system/src/main/java/org/nl/modules/system/service/impl/GridServiceImpl.java b/nladmin-system/src/main/java/org/nl/modules/system/service/impl/GridServiceImpl.java index 8965c74b4..b811dfe04 100644 --- a/nladmin-system/src/main/java/org/nl/modules/system/service/impl/GridServiceImpl.java +++ b/nladmin-system/src/main/java/org/nl/modules/system/service/impl/GridServiceImpl.java @@ -9,6 +9,7 @@ import lombok.extern.slf4j.Slf4j; import org.nl.exception.BadRequestException; import org.nl.modules.system.service.GridService; import org.nl.modules.system.service.dto.GridDto; +import org.nl.utils.SecurityUtils; import org.nl.wql.core.bean.ResultBean; import org.nl.wql.core.bean.WQLObject; import org.nl.wql.util.WqlUtil; @@ -42,8 +43,7 @@ public class GridServiceImpl implements GridService { @Override @Transactional(rollbackFor = Exception.class) public void create(GridDto dto) { -// String currentUsername = SecurityUtils.getCurrentUsername(); - String currentUsername = ""; + String currentUsername = SecurityUtils.getCurrentUsername(); String now = DateUtil.now(); dto.setId(IdUtil.simpleUUID()); @@ -71,8 +71,7 @@ public class GridServiceImpl implements GridService { GridDto entity = this.findById(dto.getId()); if (entity == null) throw new BadRequestException("被删除或无权限,操作失败!"); -// String currentUsername = SecurityUtils.getCurrentUsername(); - String currentUsername = ""; + String currentUsername = SecurityUtils.getCurrentUsername(); String now = DateUtil.now(); dto.setUpdate_time(now); dto.setUpdate_by(currentUsername); diff --git a/nladmin-system/src/main/java/org/nl/modules/system/service/impl/ParamServiceImpl.java b/nladmin-system/src/main/java/org/nl/modules/system/service/impl/ParamServiceImpl.java index 608052e42..4bbfab01e 100644 --- a/nladmin-system/src/main/java/org/nl/modules/system/service/impl/ParamServiceImpl.java +++ b/nladmin-system/src/main/java/org/nl/modules/system/service/impl/ParamServiceImpl.java @@ -12,6 +12,7 @@ import org.nl.exception.BadRequestException; import org.nl.modules.system.service.ParamService; import org.nl.modules.system.service.dto.ParamDto; import org.nl.utils.FileUtil; +import org.nl.utils.SecurityUtils; import org.nl.wql.core.bean.ResultBean; import org.nl.wql.core.bean.WQLObject; import org.nl.wql.util.WqlUtil; @@ -71,8 +72,7 @@ public class ParamServiceImpl implements ParamService { @Override @Transactional(rollbackFor = Exception.class) public void create(ParamDto dto) { -// String currentUsername = SecurityUtils.getCurrentUsername(); - String currentUsername = ""; + String currentUsername = SecurityUtils.getCurrentUsername(); String now = DateUtil.now(); dto.setId(IdUtil.simpleUUID()); @@ -92,8 +92,7 @@ public class ParamServiceImpl implements ParamService { ParamDto entity = this.findById(dto.getId()); if (entity == null) throw new BadRequestException("被删除或无权限,操作失败!"); -// String currentUsername = SecurityUtils.getCurrentUsername(); - String currentUsername = ""; + String currentUsername = SecurityUtils.getCurrentUsername(); String now = DateUtil.now(); dto.setUpdate_time(now); dto.setUpdate_by(currentUsername); diff --git a/nladmin-system/src/main/java/org/nl/modules/system/service/impl/RoleServiceImpl.java b/nladmin-system/src/main/java/org/nl/modules/system/service/impl/RoleServiceImpl.java index a60f98f60..ab052e230 100644 --- a/nladmin-system/src/main/java/org/nl/modules/system/service/impl/RoleServiceImpl.java +++ b/nladmin-system/src/main/java/org/nl/modules/system/service/impl/RoleServiceImpl.java @@ -16,14 +16,12 @@ package org.nl.modules.system.service.impl; import cn.hutool.core.collection.CollectionUtil; -import cn.hutool.core.util.StrUtil; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import lombok.RequiredArgsConstructor; import org.nl.exception.BadRequestException; import org.nl.exception.EntityExistException; import org.nl.modules.security.service.UserCacheClean; -import org.nl.modules.system.domain.Menu; import org.nl.modules.system.domain.Role; import org.nl.modules.system.domain.User; import org.nl.modules.system.repository.RoleRepository; @@ -32,7 +30,6 @@ import org.nl.modules.system.service.RoleService; import org.nl.modules.system.service.dto.RoleDto; import org.nl.modules.system.service.dto.RoleQueryCriteria; import org.nl.modules.system.service.dto.RoleSmallDto; -import org.nl.modules.system.service.dto.UserDto; import org.nl.modules.system.service.mapstruct.RoleMapper; import org.nl.modules.system.service.mapstruct.RoleSmallMapper; import org.nl.utils.*; @@ -183,7 +180,7 @@ public class RoleServiceImpl implements RoleService { // } @Override - @Cacheable(key = "'auth:' + #p0.id") + @Cacheable(key = "'auth:' + #p0") public List getPermissionList(String id) { List permission = new LinkedList<>(); HashMap map = new HashMap<>(); diff --git a/nladmin-system/src/main/java/org/nl/modules/system/service/impl/UserServiceImpl.java b/nladmin-system/src/main/java/org/nl/modules/system/service/impl/UserServiceImpl.java index 82b354223..3cc25208e 100644 --- a/nladmin-system/src/main/java/org/nl/modules/system/service/impl/UserServiceImpl.java +++ b/nladmin-system/src/main/java/org/nl/modules/system/service/impl/UserServiceImpl.java @@ -184,8 +184,7 @@ public class UserServiceImpl implements UserService { @Override @Transactional(rollbackFor = Exception.class) public Map updateAvatar(MultipartFile multipartFile) { -// User user = userRepository.findByUsername(SecurityUtils.getCurrentUsername()); - User user = userRepository.findByUsername(""); + User user = userRepository.findByUsername(SecurityUtils.getCurrentUsername()); String oldPath = user.getAvatarPath(); File file = FileUtil.upload(multipartFile, properties.getPath().getAvatar()); user.setAvatarPath(Objects.requireNonNull(file).getPath());