This commit is contained in:
2022-09-21 10:48:36 +08:00
parent d02f83da25
commit 3cd336d1cc
12 changed files with 29 additions and 48 deletions

View File

@@ -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 "";
}

View File

@@ -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<Object> 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);
}

View File

@@ -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);

View File

@@ -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<String> getPermissionList(Object o, String s) {
return roleService.getPermissionList((String) o);
return roleService.getPermissionList((String) StpUtil.getLoginId());
}
/**
* 获取用户角色
* @param o
* @param s
* @return
*/
@Override
public List<String> getRoleList(Object o, String s) {
return null;

View File

@@ -84,8 +84,7 @@ public class UserController {
criteria.getDeptIds().addAll(deptService.getDeptChildren(deptService.findByPid(criteria.getDeptId())));
}
// 数据权限
// List<Long> dataScopes = dataService.getDeptIds(userService.findByName(SecurityUtils.getCurrentUsername()));
List<Long> dataScopes = dataService.getDeptIds(userService.findByName(""));
List<Long> 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<Object> 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("密码错误");
// }

View File

@@ -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);
}
}

View File

@@ -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);
}

View File

@@ -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 + "'");
// 然后添加

View File

@@ -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);

View File

@@ -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);

View File

@@ -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<String> getPermissionList(String id) {
List<String> permission = new LinkedList<>();
HashMap<String, String> map = new HashMap<>();

View File

@@ -184,8 +184,7 @@ public class UserServiceImpl implements UserService {
@Override
@Transactional(rollbackFor = Exception.class)
public Map<String, String> 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());