Merge branch 'master' of http://121.40.234.130:8899/root/nl-sso-server
This commit is contained in:
@@ -32,6 +32,7 @@ public class CorsFilter implements Filter {
|
||||
response.setHeader("Access-Control-Max-Age", "3600");
|
||||
// 允许的header参数
|
||||
response.setHeader("Access-Control-Allow-Headers", "x-requested-with,satoken");
|
||||
response.setHeader("Access-Control-Allow-Credentials", "true");
|
||||
|
||||
// 如果是预检请求,直接返回
|
||||
if (OPTIONS.equals(request.getMethod())) {
|
||||
|
||||
@@ -42,6 +42,7 @@ import org.nl.modules.system.service.RoleService;
|
||||
import org.nl.modules.system.service.UserService;
|
||||
import org.nl.modules.system.service.dto.UserDto;
|
||||
import org.nl.modules.wql.core.bean.WQLObject;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@@ -130,7 +131,6 @@ public class AuthorizationController {
|
||||
put("token", "Bearer " + StpUtil.getTokenValue());
|
||||
put("user", user);
|
||||
}};
|
||||
|
||||
// 保存在线信息
|
||||
// onlineUserService.save(userDto, StpUtil.getTokenValue(), request);
|
||||
return ResponseEntity.ok(authInfo);
|
||||
@@ -154,6 +154,17 @@ public class AuthorizationController {
|
||||
return ResponseEntity.ok(jsonObject);
|
||||
}
|
||||
|
||||
@ApiOperation("获取指定用户信息")
|
||||
@GetMapping(value = "/userInfo")
|
||||
public ResponseEntity<Object> getUserInfo(Long loginId) {
|
||||
if (loginId != null){
|
||||
WQLObject userTab = WQLObject.getWQLObject("sys_user");
|
||||
JSONObject user = userTab.query("user_id = '" + loginId + "'").uniqueResult(0);
|
||||
return ResponseEntity.ok(user);
|
||||
}
|
||||
return ResponseEntity.noContent().build();
|
||||
}
|
||||
|
||||
@ApiOperation("获取验证码")
|
||||
@GetMapping(value = "/code")
|
||||
public ResponseEntity<Object> getCode() {
|
||||
|
||||
@@ -7,14 +7,12 @@ import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.nl.modules.logging.annotation.Log;
|
||||
import org.nl.modules.system.domain.Role;
|
||||
import org.nl.modules.system.domain.vo.RoleVo;
|
||||
import org.nl.modules.system.service.RoleService;
|
||||
import org.nl.modules.wql.core.bean.WQLObject;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
@@ -22,8 +20,8 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2018-12-03
|
||||
* @author ludj
|
||||
* @date 2022-12-05
|
||||
*/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@@ -33,22 +31,6 @@ public class RoleController {
|
||||
|
||||
private final RoleService roleService;
|
||||
|
||||
private static final String ENTITY_NAME = "role";
|
||||
|
||||
@ApiOperation("获取单个role")
|
||||
@GetMapping(value = "/{id}")
|
||||
@SaCheckPermission("roles:list")
|
||||
public ResponseEntity<Object> query(@PathVariable Long id) {
|
||||
return new ResponseEntity<>(roleService.findById(id), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ApiOperation("获取单个role")
|
||||
@GetMapping(value = "/all")
|
||||
// @SaCheckPermission("roles:list")
|
||||
public ResponseEntity<Object> query() {
|
||||
List<RoleVo> roles = roleService.findRoles(null, RoleVo.class);
|
||||
return new ResponseEntity<>(roles, HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ApiOperation("查询角色")
|
||||
@GetMapping
|
||||
@@ -61,28 +43,27 @@ public class RoleController {
|
||||
@Log("新增角色")
|
||||
@ApiOperation("新增角色")
|
||||
@PostMapping
|
||||
@SaCheckPermission("roles:add")
|
||||
public ResponseEntity<Object> create(@Validated @RequestBody Role resources) {
|
||||
// roleService.create(resources);
|
||||
// @SaCheckPermission("roles:add")
|
||||
public ResponseEntity<Object> create(@RequestBody JSONObject param) {
|
||||
roleService.create(param);
|
||||
return new ResponseEntity<>(HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
/* @Log("修改角色")
|
||||
@ApiOperation("修改角色")
|
||||
@PutMapping
|
||||
@SaCheckPermission("roles:edit")
|
||||
public ResponseEntity<Object> update(@Validated(Role.Update.class) @RequestBody Role resources) {
|
||||
getLevels(resources.getLevel());
|
||||
roleService.update(resources);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
*/
|
||||
@Log("修改角色")
|
||||
@ApiOperation("修改角色")
|
||||
@PutMapping
|
||||
// @SaCheckPermission("roles:edit")
|
||||
public ResponseEntity<Object> update(@RequestBody JSONObject param) {
|
||||
roleService.update(param);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@Log("修改角色菜单")
|
||||
@ApiOperation("修改角色菜单")
|
||||
@PutMapping(value = "/menu")
|
||||
// @SaCheckPermission("roles:edit")
|
||||
public ResponseEntity<Object> updateMenu(@RequestBody JSONObject form) {
|
||||
String role_id = form.getString("id");
|
||||
String role_id = form.getString("role_id");
|
||||
JSONArray menus = form.getJSONArray("menus");
|
||||
WQLObject rmTab = WQLObject.getWQLObject("sys_roles_menus");
|
||||
rmTab.delete("role_id = " + role_id + "");
|
||||
|
||||
@@ -44,15 +44,6 @@ public interface RoleService {
|
||||
*/
|
||||
JSONObject queryAll(Map whereJson, Pageable page);
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
* @param id /
|
||||
* @return /
|
||||
*/
|
||||
<T> List<T> findRoles(Long id, Class<T>target);
|
||||
|
||||
RoleDto findById(Long id);
|
||||
|
||||
/**
|
||||
* 创建
|
||||
* @param form /
|
||||
@@ -61,9 +52,9 @@ public interface RoleService {
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
* @param resources /
|
||||
* @param form /
|
||||
*/
|
||||
void update(Role resources);
|
||||
void update(JSONObject form);
|
||||
|
||||
/**
|
||||
* 删除
|
||||
@@ -71,46 +62,6 @@ public interface RoleService {
|
||||
*/
|
||||
void delete(Set<Long> ids);
|
||||
|
||||
/**
|
||||
* 根据用户ID查询
|
||||
* @param id 用户ID
|
||||
* @return /
|
||||
*/
|
||||
List<RoleSmallDto> findByUsersId(Long id);
|
||||
|
||||
/**
|
||||
* 根据角色查询角色级别
|
||||
* @param roles /
|
||||
* @return /
|
||||
*/
|
||||
Integer findByRoles(Set<Role> roles);
|
||||
|
||||
/**
|
||||
* 修改绑定的菜单
|
||||
* @param resources /
|
||||
* @param roleDTO /
|
||||
*/
|
||||
void updateMenu(Role resources, RoleDto roleDTO);
|
||||
|
||||
/**
|
||||
* 解绑菜单
|
||||
* @param id /
|
||||
*/
|
||||
void untiedMenu(Long id);
|
||||
/**
|
||||
* 查询全部
|
||||
* @param criteria 条件
|
||||
* @return /
|
||||
*/
|
||||
List<RoleDto> queryAll(RoleQueryCriteria criteria);
|
||||
|
||||
|
||||
/**
|
||||
* 获取用户权限信息
|
||||
* @param user 用户信息
|
||||
* @return 权限信息
|
||||
*/
|
||||
// List<String> mapToGrantedAuthorities(UserDto user);
|
||||
|
||||
/**
|
||||
* 通过id获取用户的权限
|
||||
@@ -119,6 +70,4 @@ public interface RoleService {
|
||||
*/
|
||||
List<String> getPermissionList(JSONObject userDto);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ import java.util.Map;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@CacheConfig(cacheNames = "codeDetail")
|
||||
public class CodeDetailServiceImpl implements CodeDetailService {
|
||||
@Override
|
||||
public JSONObject queryAll(Map form, Pageable pageable) {
|
||||
|
||||
@@ -15,21 +15,19 @@
|
||||
*/
|
||||
package org.nl.modules.system.service.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.nl.modules.common.utils.enums.DataScopeEnum;
|
||||
import org.nl.modules.system.domain.Dept;
|
||||
import org.nl.modules.system.domain.User;
|
||||
import org.nl.modules.system.service.DataService;
|
||||
import org.nl.modules.system.service.DeptService;
|
||||
import org.nl.modules.system.service.RoleService;
|
||||
import org.nl.modules.system.service.dto.RoleSmallDto;
|
||||
import org.nl.modules.system.service.dto.UserDto;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
@@ -39,7 +37,6 @@ import java.util.*;
|
||||
**/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@CacheConfig(cacheNames = "data")
|
||||
public class DataServiceImpl implements DataService {
|
||||
|
||||
private final RoleService roleService;
|
||||
@@ -51,7 +48,6 @@ public class DataServiceImpl implements DataService {
|
||||
* @return /
|
||||
*/
|
||||
@Override
|
||||
@Cacheable(key = "'user:' + #p0.id")
|
||||
public List<Long> getDeptIds(User user) {
|
||||
// 用于存储部门id
|
||||
Set<Long> deptIds = new HashSet<>();
|
||||
|
||||
@@ -57,7 +57,6 @@ import java.util.stream.Collectors;
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@CacheConfig(cacheNames = "dept")
|
||||
public class DeptServiceImpl implements DeptService {
|
||||
|
||||
private final RedisUtils redisUtils;
|
||||
|
||||
@@ -32,7 +32,6 @@ import org.nl.modules.wql.WQL;
|
||||
import org.nl.modules.wql.core.bean.WQLObject;
|
||||
import org.nl.modules.wql.util.WqlUtil;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -41,18 +40,17 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2019-04-10
|
||||
*/
|
||||
* @author Zheng Jie
|
||||
* @date 2019-04-10
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@CacheConfig(cacheNames = "dict")
|
||||
public class DictDetailServiceImpl implements DictDetailService {
|
||||
|
||||
private final RedisUtils redisUtils;
|
||||
|
||||
@Override
|
||||
public Map<String,Object> queryAll(DictDetailQueryCriteria criteria, Pageable pageable) {
|
||||
public Map<String, Object> queryAll(DictDetailQueryCriteria criteria, Pageable pageable) {
|
||||
JSONObject map = new JSONObject();
|
||||
map.put("flag", "2");
|
||||
map.put("code", criteria.getCode());
|
||||
@@ -67,7 +65,7 @@ public class DictDetailServiceImpl implements DictDetailService {
|
||||
// 校验是否已经有标签
|
||||
JSONObject object = wo.query("label = '" + resources.getLabel() + "' " +
|
||||
"AND code = '" + resources.getDictCode() + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isNotEmpty(object)) throw new BadRequestException("标签["+ resources.getLabel() + "]已存在");
|
||||
if (ObjectUtil.isNotEmpty(object)) throw new BadRequestException("标签[" + resources.getLabel() + "]已存在");
|
||||
JSONObject dictObj = wo.query("code = '" + resources.getDictCode() + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(dictObj.getString("label"))) {
|
||||
// 空就赋值
|
||||
@@ -116,7 +114,6 @@ public class DictDetailServiceImpl implements DictDetailService {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Cacheable(key = "'name:' + #p0")
|
||||
public List<DictDto> getDictByName(String name) {
|
||||
List<DictDto> dictDtos = this.findByDictName(name);
|
||||
return dictDtos;
|
||||
@@ -143,9 +140,10 @@ public class DictDetailServiceImpl implements DictDetailService {
|
||||
dictTab.delete(json);
|
||||
}
|
||||
|
||||
public void delCaches(DictDto dict){
|
||||
public void delCaches(DictDto dict) {
|
||||
redisUtils.del("dict::name:" + dict.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public DictDto findById(Long dict_id) {
|
||||
WQLObject wo = WQLObject.getWQLObject("sys_dict");
|
||||
|
||||
@@ -48,7 +48,6 @@ import java.util.*;
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
//@CacheConfig(cacheNames = "dict")
|
||||
public class DictServiceImpl implements DictService {
|
||||
|
||||
private final RedisUtils redisUtils;
|
||||
|
||||
@@ -29,7 +29,6 @@ import java.util.stream.Collectors;
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@CacheConfig(cacheNames = "menu")
|
||||
public class MenuServiceImpl implements MenuService {
|
||||
|
||||
|
||||
@@ -101,7 +100,6 @@ public class MenuServiceImpl implements MenuService {
|
||||
|
||||
|
||||
@Override
|
||||
// @Cacheable(key = "'id:' + #p0")
|
||||
public MenuDto findById(String id) {
|
||||
WQLObject menuTab = WQLObject.getWQLObject("sys_menu");
|
||||
JSONObject json = menuTab.query("menu_id = '" + id + "'").uniqueResult(0);
|
||||
@@ -115,7 +113,6 @@ public class MenuServiceImpl implements MenuService {
|
||||
* @return /
|
||||
*/
|
||||
@Override
|
||||
// @Cacheable(key = "'user:' + #p0")
|
||||
public List<MenuDto> findByUser(String currentUserId) {
|
||||
JSONArray arr = WQL.getWO("QSYS_MENU01").addParam("flag", "4").addParam("user_id", String.valueOf(currentUserId)).process().getResultJSONArray(0);
|
||||
List<MenuDto> list = new ArrayList<>();
|
||||
|
||||
@@ -15,46 +15,37 @@
|
||||
*/
|
||||
package org.nl.modules.system.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.nl.modules.common.utils.CacheKey;
|
||||
import org.nl.modules.common.utils.RedisUtils;
|
||||
import org.nl.modules.common.exception.BadRequestException;
|
||||
import org.nl.modules.common.utils.SecurityUtils;
|
||||
import org.nl.modules.system.domain.Role;
|
||||
import org.nl.modules.system.domain.User;
|
||||
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.tools.MapOf;
|
||||
import org.nl.modules.wql.WQL;
|
||||
import org.nl.modules.wql.core.bean.ResultBean;
|
||||
import org.nl.modules.wql.core.bean.WQLObject;
|
||||
import org.nl.modules.wql.util.WqlUtil;
|
||||
import org.nl.wms.util.IdUtil;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.transaction.support.TransactionTemplate;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2018-12-03
|
||||
* @author ludj
|
||||
* @date 2022-12-05
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@CacheConfig(cacheNames = "role")
|
||||
public class RoleServiceImpl implements RoleService {
|
||||
|
||||
private final RedisUtils redisUtils;
|
||||
|
||||
@Override
|
||||
public JSONObject queryAll(Map whereJson, Pageable page) {
|
||||
WQLObject wo = WQLObject.getWQLObject("sys_role");
|
||||
@@ -71,35 +62,19 @@ public class RoleServiceImpl implements RoleService {
|
||||
return json;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RoleDto> queryAll(RoleQueryCriteria criteria) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Cacheable(key = "'id:' + #p0")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public <T> List<T> findRoles(Long id,Class<T> target) {
|
||||
String sql = "is_used = '1' and is_delete = '0' ";
|
||||
if (id != null){
|
||||
sql=sql+"role_id = '"+id+"'";
|
||||
}
|
||||
JSONArray array = WQLObject.getWQLObject("sys_role").query(sql).getResultJSONArray(0);
|
||||
return array.toJavaList(target);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RoleDto findById(Long id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void create(JSONObject form) {
|
||||
//角色表【sys_role】
|
||||
//判断角色名字是否存在
|
||||
String name = form.getString("name");
|
||||
if (StrUtil.isEmpty(name)) throw new BadRequestException("角色名字不能为空!");
|
||||
WQLObject roleTab = WQLObject.getWQLObject("sys_role");
|
||||
|
||||
//判断角色名字是否存在
|
||||
JSONObject json = roleTab.query("name = '" + name + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isNotEmpty(json)) throw new BadRequestException("角色【" + name + "】已存在!");
|
||||
|
||||
|
||||
String role_id = IdUtil.getStringId();
|
||||
form.put("role_id", role_id);
|
||||
form.put("create_id", SecurityUtils.getCurrentUserId());
|
||||
@@ -109,24 +84,26 @@ public class RoleServiceImpl implements RoleService {
|
||||
form.put("update_name", SecurityUtils.getCurrentNickName());
|
||||
form.put("update_time", DateUtil.now());
|
||||
roleTab.insert(form);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(Role resources) {
|
||||
public void update(JSONObject form) {
|
||||
WQLObject roleTab = WQLObject.getWQLObject("sys_role");
|
||||
//判断角色名字是否存在
|
||||
String name = form.getString("name");
|
||||
if (StrUtil.isEmpty(name)) throw new BadRequestException("角色名字不能为空!");
|
||||
|
||||
}
|
||||
JSONObject json = roleTab.query("name = '" + name + "' and role_id <> '" + form.getString("role_id") + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isNotEmpty(json)) throw new BadRequestException("角色【" + name + "】已存在!");
|
||||
|
||||
@Override
|
||||
public void updateMenu(Role resources, RoleDto roleDTO) {
|
||||
String now = DateUtil.now();
|
||||
form.put("update_id", StpUtil.getLoginIdAsLong());
|
||||
form.put("update_time", now);
|
||||
form.put("update_optname", SecurityUtils.getCurrentNickName());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void untiedMenu(Long menuId) {
|
||||
|
||||
roleTab.update(form);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -141,21 +118,6 @@ public class RoleServiceImpl implements RoleService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RoleSmallDto> findByUsersId(Long id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer findByRoles(Set<Role> roles) {
|
||||
Set<RoleDto> roleDtos = new HashSet<>();
|
||||
for (Role role : roles) {
|
||||
roleDtos.add(findById(role.getId()));
|
||||
}
|
||||
return Collections.min(roleDtos.stream().map(RoleDto::getLevel).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
@Override
|
||||
// @Cacheable(key = "'auth:' + #p0.id")
|
||||
public List<String> getPermissionList(JSONObject userDto) {
|
||||
List<String> permission = new LinkedList<>();
|
||||
// 查看是否为管理员
|
||||
@@ -171,21 +133,4 @@ public class RoleServiceImpl implements RoleService {
|
||||
return permission;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 清理缓存
|
||||
*
|
||||
* @param id /
|
||||
*/
|
||||
public void delCaches(Long id, List<User> users) {
|
||||
// users = CollectionUtil.isEmpty(users) ? userRepository.findByRoleId(id) : users;
|
||||
if (CollectionUtil.isNotEmpty(users)) {
|
||||
// users.forEach(item -> userCacheClean.cleanUserCache(item.getUsername()));
|
||||
Set<Long> userIds = users.stream().map(User::getId).collect(Collectors.toSet());
|
||||
redisUtils.delByKeys(CacheKey.DATA_USER, userIds);
|
||||
redisUtils.delByKeys(CacheKey.MENU_USER, userIds);
|
||||
redisUtils.delByKeys(CacheKey.ROLE_AUTH, userIds);
|
||||
}
|
||||
redisUtils.del(CacheKey.ROLE_ID + id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,21 +22,22 @@ import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson.serializer.SerializeConfig;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.SneakyThrows;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.nl.modules.common.config.FileProperties;
|
||||
import org.nl.modules.common.exception.EntityExistException;
|
||||
import org.nl.modules.common.exception.EntityNotFoundException;
|
||||
import org.nl.modules.common.utils.*;
|
||||
import org.nl.modules.common.utils.CacheKey;
|
||||
import org.nl.modules.common.utils.FileUtil;
|
||||
import org.nl.modules.common.utils.RedisUtils;
|
||||
import org.nl.modules.common.utils.SecurityUtils;
|
||||
import org.nl.modules.common.utils.dto.CurrentUser;
|
||||
import org.nl.modules.security.service.OnlineUserService;
|
||||
import org.nl.modules.system.domain.User;
|
||||
import org.nl.modules.system.service.DeptService;
|
||||
import org.nl.modules.system.service.UserRelateService;
|
||||
import org.nl.modules.system.service.UserService;
|
||||
|
||||
import org.nl.modules.system.service.dto.UserQueryCriteria;
|
||||
import org.nl.modules.tools.MapOf;
|
||||
import org.nl.modules.wql.WQL;
|
||||
@@ -44,17 +45,13 @@ import org.nl.modules.wql.core.bean.ResultBean;
|
||||
import org.nl.modules.wql.core.bean.WQLObject;
|
||||
import org.nl.modules.wql.util.WqlUtil;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -64,7 +61,6 @@ import java.util.stream.Collectors;
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@CacheConfig(cacheNames = "user")
|
||||
public class UserServiceImpl implements UserService {
|
||||
|
||||
private final FileProperties properties;
|
||||
@@ -124,7 +120,6 @@ public class UserServiceImpl implements UserService {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Cacheable(key = "'id:' + #p0")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public User findById(long id) {
|
||||
JSONObject result = WQLObject.getWQLObject("sys_user").query("user_id = '" + id + "'").uniqueResult(0);
|
||||
@@ -228,7 +223,6 @@ public class UserServiceImpl implements UserService {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Cacheable(key = "'username:' + #p0")
|
||||
public User findByName(String userName) {
|
||||
JSONObject result = WQLObject.getWQLObject("sys_user").query("userName = '" + userName + "'").uniqueResult(0);
|
||||
if (result == null) {
|
||||
|
||||
@@ -4,6 +4,8 @@ import cn.hutool.db.Db;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.modules.wql.WQLCore;
|
||||
import org.nl.modules.wql.util.SpringContextHolder;
|
||||
import org.springframework.jdbc.datasource.DataSourceUtils;
|
||||
|
||||
import javax.naming.Context;
|
||||
import javax.naming.InitialContext;
|
||||
import javax.naming.NamingException;
|
||||
@@ -78,8 +80,8 @@ public class DBPoolSpring {
|
||||
Connection conn = null;
|
||||
try {
|
||||
DataSource dataSource = SpringContextHolder.getBean(name);
|
||||
conn=Db.use(dataSource).getConnection();
|
||||
// conn = DataSourceUtils.getConnection(dataSource);
|
||||
// conn=Db.use(dataSource).getConnection();
|
||||
conn = DataSourceUtils.getConnection(dataSource);
|
||||
} catch (Exception e) {
|
||||
log.error("不能获得Spring连接池中的数据库连接:" + e.toString());
|
||||
}
|
||||
@@ -120,9 +122,10 @@ public class DBPoolSpring {
|
||||
// conn.close();
|
||||
// }
|
||||
DataSource dataSource = (DataSource) SpringContextHolder.getBean(name);
|
||||
// DataSourceUtils.releaseConnection(conn, dataSource);
|
||||
DataSourceUtils.releaseConnection(conn, dataSource);
|
||||
|
||||
Db.use(dataSource).closeConnection(conn);
|
||||
|
||||
/* Db.use(dataSource).closeConnection(conn);*/
|
||||
// } catch (SQLException e) {
|
||||
// log.error("数据库连接关闭:"+e.toString() );
|
||||
// }
|
||||
|
||||
Reference in New Issue
Block a user