refactor(system): 重构系统模块中的部门、字典、菜单等服务方法命名和实现
- 统一将修改方法名从 modify* 改为 update* - 统一将删除方法名从 remove* 改为 delete* - 统一将查询方法名从 query* 改为 search* 或 list* - 重构部门服务中的树形结构构建逻辑 - 优化部门上级数据查询方法实现 - 调整数据权限查询方法命名 - 删除未使用的导入和方法 - 修复部门关联验证中的用户查询服务依赖
This commit is contained in:
@@ -32,6 +32,7 @@
|
|||||||
- 搜索(分页)功能:search + 名词
|
- 搜索(分页)功能:search + 名词
|
||||||
- 统计计数:count + By + 条件
|
- 统计计数:count + By + 条件
|
||||||
- 存在检查:exists + By + 条件
|
- 存在检查:exists + By + 条件
|
||||||
|
- 增删改:save/delete/update
|
||||||
- 例子: 查询分页、查询列表的方法
|
- 例子: 查询分页、查询列表的方法
|
||||||
- 分页:searchUser(args, page)
|
- 分页:searchUser(args, page)
|
||||||
- 列表:listUser + (args)
|
- 列表:listUser + (args)
|
||||||
@@ -44,6 +45,47 @@
|
|||||||
- 单个:getUser + by + (args)
|
- 单个:getUser + by + (args)
|
||||||
- 统计计数:count + By + (args)
|
- 统计计数:count + By + (args)
|
||||||
|
|
||||||
|
#### 编码规范:举例说明
|
||||||
|
|
||||||
|
1. getUser - 简单查询
|
||||||
|
核心: 获取单个特定实体。
|
||||||
|
|
||||||
|
- 输入: 通常是一个唯一标识符(如ID 123)。
|
||||||
|
- 筛选: 非常精确,只匹配一个。
|
||||||
|
- 返回: 单个对象或文档,包含该用户的完整/详细信息。
|
||||||
|
- 示例: getUser(123) -> 返回 {id: 123, name: “Alice”, email: “...”}
|
||||||
|
|
||||||
|
2. listUsers - 列表查询
|
||||||
|
核心: 获取一个符合简单条件的实体集合,通常是有限的、预定义的。
|
||||||
|
|
||||||
|
- 输入: 可能没有参数,或只有非常简单的过滤条件(如 status=‘active’)。
|
||||||
|
- 筛选: 简单、常规。
|
||||||
|
- 返回: 一个数组/列表,包含多个用户的基本信息(通常是摘要字段,非完整详情)。
|
||||||
|
- 通常不分页,或隐式返回所有符合条件的(数据量预期不大)。
|
||||||
|
- 示例: listUsers() -> 返回 [{id: 1, name: “Alice”}, {id: 2, name: “Bob”}]
|
||||||
|
- 示例: listUsers({role: ‘admin’}) -> 返回所有管理员用户的列表。
|
||||||
|
|
||||||
|
3. queryUsersByCondition - 复杂查询
|
||||||
|
核心: 基于多个、可能较复杂的条件进行筛选。
|
||||||
|
|
||||||
|
- 输入: 一个组合条件对象,可能涉及多个字段的比较(如 age > 18 AND department = ‘Sales’ AND joinDate < ‘2023-01-01’)。
|
||||||
|
- 筛选: 复杂、灵活,类似数据库的WHERE子句。
|
||||||
|
- 返回: 一个匹配条件的数组/列表。
|
||||||
|
- 分页: 可能分页,也可能不分页。关键是它的侧重点在于复杂的“筛选”能力,而非分页机制。(这是标准,但是对于此项目来说,定为不分页的,复杂条件的,列表查询服务)
|
||||||
|
- 示例: queryUsersByCondition({minAge: 18, department: ‘Sales’, hasCertification: true})
|
||||||
|
|
||||||
|
4. searchUsers - 搜索(分页)功能
|
||||||
|
核心: 针对大量数据进行模糊匹配、全文检索,并强制包含分页机制以管理性能。
|
||||||
|
|
||||||
|
- 输入:
|
||||||
|
- 搜索关键词(可能对多个字段进行模糊匹配)。
|
||||||
|
- 分页参数(pageNumber, pageSize 或 limit, offset)。
|
||||||
|
- 可能附加的其他过滤条件。
|
||||||
|
- 筛选: 通常包含文本搜索(如 name LIKE ‘%Al%’),结果可能按相关性排序。
|
||||||
|
- 返回: 一个分页响应对象,而不仅仅是数组。
|
||||||
|
- 包含:data(当前页的数据列表)、total(总匹配数)、page(当前页)、pageSize(每页大小)等元数据。
|
||||||
|
- 示例: searchUsers({keyword: ‘Al’, page: 1, pageSize: 20}) -> 返回 {data: […], total: 45, page: 1, pageSize: 20}
|
||||||
|
|
||||||
#### 主要特性
|
#### 主要特性
|
||||||
|
|
||||||
- 使用最新技术栈,社区资源丰富。
|
- 使用最新技术栈,社区资源丰富。
|
||||||
|
|||||||
+4
-24
@@ -24,11 +24,8 @@ import cn.odboy.system.service.SystemDeptService;
|
|||||||
import cn.odboy.util.KitPageUtil;
|
import cn.odboy.util.KitPageUtil;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.LinkedHashSet;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
@@ -53,7 +50,7 @@ public class SystemDeptController {
|
|||||||
@GetMapping(value = "/download")
|
@GetMapping(value = "/download")
|
||||||
@PreAuthorize("@el.check('dept:list')")
|
@PreAuthorize("@el.check('dept:list')")
|
||||||
public void exportDept(HttpServletResponse response, SystemQueryDeptArgs criteria) throws Exception {
|
public void exportDept(HttpServletResponse response, SystemQueryDeptArgs criteria) throws Exception {
|
||||||
systemDeptService.exportDeptExcel(systemDeptService.queryAllDept(criteria, false), response);
|
systemDeptService.exportDeptExcel(systemDeptService.queryAllDeptByArgs(criteria, false), response);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("查询部门")
|
@ApiOperation("查询部门")
|
||||||
@@ -62,7 +59,7 @@ public class SystemDeptController {
|
|||||||
public ResponseEntity<KitPageResult<SystemDeptTb>> queryDept(
|
public ResponseEntity<KitPageResult<SystemDeptTb>> queryDept(
|
||||||
@Validated @RequestBody KitPageArgs<SystemQueryDeptArgs> args) throws Exception {
|
@Validated @RequestBody KitPageArgs<SystemQueryDeptArgs> args) throws Exception {
|
||||||
SystemQueryDeptArgs criteria = args.getArgs();
|
SystemQueryDeptArgs criteria = args.getArgs();
|
||||||
List<SystemDeptTb> depts = systemDeptService.queryAllDept(criteria, true);
|
List<SystemDeptTb> depts = systemDeptService.queryAllDeptByArgs(criteria, true);
|
||||||
return ResponseEntity.ok(KitPageUtil.toPage(depts));
|
return ResponseEntity.ok(KitPageUtil.toPage(depts));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,24 +68,7 @@ public class SystemDeptController {
|
|||||||
@PreAuthorize("@el.check('user:list','dept:list')")
|
@PreAuthorize("@el.check('user:list','dept:list')")
|
||||||
public ResponseEntity<KitPageResult<SystemDeptTb>> queryDeptSuperiorTree(@RequestBody List<Long> ids,
|
public ResponseEntity<KitPageResult<SystemDeptTb>> queryDeptSuperiorTree(@RequestBody List<Long> ids,
|
||||||
@RequestParam(defaultValue = "false") Boolean exclude) {
|
@RequestParam(defaultValue = "false") Boolean exclude) {
|
||||||
Set<SystemDeptTb> deptSet = new LinkedHashSet<>();
|
return ResponseEntity.ok(systemDeptService.searchDeptTree(ids, exclude));
|
||||||
for (Long id : ids) {
|
|
||||||
// 同级数据
|
|
||||||
SystemDeptTb dept = systemDeptService.getDeptById(id);
|
|
||||||
// 上级数据
|
|
||||||
List<SystemDeptTb> depts = systemDeptService.querySuperiorDeptListByPid(dept, new ArrayList<>());
|
|
||||||
if (exclude) {
|
|
||||||
for (SystemDeptTb data : depts) {
|
|
||||||
if (data.getId().equals(dept.getPid())) {
|
|
||||||
data.setSubCount(data.getSubCount() - 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 编辑部门时不显示自己以及自己下级的数据, 避免出现PID数据环形问题
|
|
||||||
depts = depts.stream().filter(i -> !ids.contains(i.getId())).collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
deptSet.addAll(depts);
|
|
||||||
}
|
|
||||||
return ResponseEntity.ok(systemDeptService.buildDeptTree(new ArrayList<>(deptSet)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("新增部门")
|
@ApiOperation("新增部门")
|
||||||
@@ -115,7 +95,7 @@ public class SystemDeptController {
|
|||||||
Set<SystemDeptTb> depts = systemDeptService.traverseDeptByIdWithPids(ids);
|
Set<SystemDeptTb> depts = systemDeptService.traverseDeptByIdWithPids(ids);
|
||||||
// 验证是否被角色或用户关联
|
// 验证是否被角色或用户关联
|
||||||
systemDeptService.verifyBindRelationByIds(depts);
|
systemDeptService.verifyBindRelationByIds(depts);
|
||||||
systemDeptService.removeDeptByIds(depts);
|
systemDeptService.deleteDeptByIds(depts);
|
||||||
return ResponseEntity.ok(null);
|
return ResponseEntity.ok(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -72,7 +72,7 @@ public class SystemDictController {
|
|||||||
} else {
|
} else {
|
||||||
page = new Page<>(criteria.getPage(), criteria.getSize());
|
page = new Page<>(criteria.getPage(), criteria.getSize());
|
||||||
}
|
}
|
||||||
return ResponseEntity.ok(systemDictService.queryDictByArgs(criteria, page));
|
return ResponseEntity.ok(systemDictService.searchDict(criteria, page));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("新增字典")
|
@ApiOperation("新增字典")
|
||||||
@@ -87,7 +87,7 @@ public class SystemDictController {
|
|||||||
@PostMapping(value = "/modifyDictById")
|
@PostMapping(value = "/modifyDictById")
|
||||||
@PreAuthorize("@el.check('dict:edit')")
|
@PreAuthorize("@el.check('dict:edit')")
|
||||||
public ResponseEntity<Void> modifyDictById(@Validated(SystemDictTb.Update.class) @RequestBody SystemDictTb args) {
|
public ResponseEntity<Void> modifyDictById(@Validated(SystemDictTb.Update.class) @RequestBody SystemDictTb args) {
|
||||||
systemDictService.modifyDictById(args);
|
systemDictService.updateDictById(args);
|
||||||
return ResponseEntity.ok(null);
|
return ResponseEntity.ok(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,7 +95,7 @@ public class SystemDictController {
|
|||||||
@PostMapping(value = "/removeDictByIds")
|
@PostMapping(value = "/removeDictByIds")
|
||||||
@PreAuthorize("@el.check('dict:del')")
|
@PreAuthorize("@el.check('dict:del')")
|
||||||
public ResponseEntity<Void> removeDictByIds(@RequestBody Set<Long> ids) {
|
public ResponseEntity<Void> removeDictByIds(@RequestBody Set<Long> ids) {
|
||||||
systemDictService.removeDictByIds(ids);
|
systemDictService.deleteDictByIds(ids);
|
||||||
return ResponseEntity.ok(null);
|
return ResponseEntity.ok(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-4
@@ -60,7 +60,7 @@ public class SystemDictDetailController {
|
|||||||
@Validated @RequestBody KitPageArgs<SystemQueryDictDetailArgs> args) {
|
@Validated @RequestBody KitPageArgs<SystemQueryDictDetailArgs> args) {
|
||||||
SystemQueryDictDetailArgs criteria = args.getArgs();
|
SystemQueryDictDetailArgs criteria = args.getArgs();
|
||||||
Page<SystemDictDetailTb> page = new Page<>(args.getPage(), args.getSize());
|
Page<SystemDictDetailTb> page = new Page<>(args.getPage(), args.getSize());
|
||||||
return ResponseEntity.ok(systemDictDetailService.queryDictDetailByArgs(criteria, page));
|
return ResponseEntity.ok(systemDictDetailService.searchDictDetail(criteria, page));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("查询多个字典详情")
|
@ApiOperation("查询多个字典详情")
|
||||||
@@ -69,7 +69,7 @@ public class SystemDictDetailController {
|
|||||||
String[] names = dictName.split("[,, ]");
|
String[] names = dictName.split("[,, ]");
|
||||||
Map<String, List<SystemDictDetailVo>> dictMap = new HashMap<>(16);
|
Map<String, List<SystemDictDetailVo>> dictMap = new HashMap<>(16);
|
||||||
for (String name : names) {
|
for (String name : names) {
|
||||||
dictMap.put(name, systemDictDetailService.queryDictDetailByName(name));
|
dictMap.put(name, systemDictDetailService.listDictDetailByName(name));
|
||||||
}
|
}
|
||||||
return ResponseEntity.ok(dictMap);
|
return ResponseEntity.ok(dictMap);
|
||||||
}
|
}
|
||||||
@@ -87,7 +87,7 @@ public class SystemDictDetailController {
|
|||||||
@PreAuthorize("@el.check('dict:edit')")
|
@PreAuthorize("@el.check('dict:edit')")
|
||||||
public ResponseEntity<Void> modifyDictDetailById(
|
public ResponseEntity<Void> modifyDictDetailById(
|
||||||
@Validated(SystemDictDetailTb.Update.class) @RequestBody SystemDictDetailTb args) {
|
@Validated(SystemDictDetailTb.Update.class) @RequestBody SystemDictDetailTb args) {
|
||||||
systemDictDetailService.modifyDictDetailById(args);
|
systemDictDetailService.updateDictDetailById(args);
|
||||||
return ResponseEntity.ok(null);
|
return ResponseEntity.ok(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,7 +95,7 @@ public class SystemDictDetailController {
|
|||||||
@PostMapping(value = "/removeDictDetailById")
|
@PostMapping(value = "/removeDictDetailById")
|
||||||
@PreAuthorize("@el.check('dict:del')")
|
@PreAuthorize("@el.check('dict:del')")
|
||||||
public ResponseEntity<Void> removeDictDetailById(@RequestBody SystemDictDetailTb args) {
|
public ResponseEntity<Void> removeDictDetailById(@RequestBody SystemDictDetailTb args) {
|
||||||
systemDictDetailService.removeDictDetailById(args.getId());
|
systemDictDetailService.deleteDictDetailById(args.getId());
|
||||||
return ResponseEntity.ok(null);
|
return ResponseEntity.ok(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -49,7 +49,7 @@ public class SystemEmailController {
|
|||||||
@PostMapping(value = "/modifyEmailConfig")
|
@PostMapping(value = "/modifyEmailConfig")
|
||||||
public ResponseEntity<Void> modifyEmailConfig(@Validated @RequestBody SystemEmailConfigTb emailConfig)
|
public ResponseEntity<Void> modifyEmailConfig(@Validated @RequestBody SystemEmailConfigTb emailConfig)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
systemEmailService.modifyEmailConfig(emailConfig);
|
systemEmailService.updateEmailConfigById(emailConfig);
|
||||||
return ResponseEntity.ok(null);
|
return ResponseEntity.ok(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -82,7 +82,7 @@ public class SystemJobController {
|
|||||||
@PostMapping(value = "/modifyJobById")
|
@PostMapping(value = "/modifyJobById")
|
||||||
@PreAuthorize("@el.check('job:edit')")
|
@PreAuthorize("@el.check('job:edit')")
|
||||||
public ResponseEntity<Void> modifyJobById(@Validated(SystemJobTb.Update.class) @RequestBody SystemJobTb args) {
|
public ResponseEntity<Void> modifyJobById(@Validated(SystemJobTb.Update.class) @RequestBody SystemJobTb args) {
|
||||||
systemJobService.modifyJobById(args);
|
systemJobService.updateJobById(args);
|
||||||
return ResponseEntity.ok(null);
|
return ResponseEntity.ok(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -89,7 +89,7 @@ public class SystemLocalStorageController {
|
|||||||
@PostMapping(value = "/modifyLocalStorageById")
|
@PostMapping(value = "/modifyLocalStorageById")
|
||||||
@PreAuthorize("@el.check('storage:edit')")
|
@PreAuthorize("@el.check('storage:edit')")
|
||||||
public ResponseEntity<Void> modifyLocalStorageById(@Validated @RequestBody SystemLocalStorageTb args) {
|
public ResponseEntity<Void> modifyLocalStorageById(@Validated @RequestBody SystemLocalStorageTb args) {
|
||||||
localStorageService.modifyLocalStorageById(args);
|
localStorageService.updateLocalStorageById(args);
|
||||||
return ResponseEntity.ok(null);
|
return ResponseEntity.ok(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -114,7 +114,7 @@ public class SystemMenuController {
|
|||||||
public ResponseEntity<List<SystemMenuTb>> queryMenuSuperior(@RequestBody List<Long> ids) {
|
public ResponseEntity<List<SystemMenuTb>> queryMenuSuperior(@RequestBody List<Long> ids) {
|
||||||
Set<SystemMenuTb> menus;
|
Set<SystemMenuTb> menus;
|
||||||
if (CollectionUtil.isNotEmpty(ids)) {
|
if (CollectionUtil.isNotEmpty(ids)) {
|
||||||
menus = new LinkedHashSet<>(systemMenuService.queryMenuByIds(ids));
|
menus = new LinkedHashSet<>(systemMenuService.listMenuByIds(ids));
|
||||||
for (SystemMenuTb menu : menus) {
|
for (SystemMenuTb menu : menus) {
|
||||||
List<SystemMenuTb> menuList = systemMenuService.querySuperiorMenuList(menu, new ArrayList<>());
|
List<SystemMenuTb> menuList = systemMenuService.querySuperiorMenuList(menu, new ArrayList<>());
|
||||||
for (SystemMenuTb data : menuList) {
|
for (SystemMenuTb data : menuList) {
|
||||||
@@ -146,7 +146,7 @@ public class SystemMenuController {
|
|||||||
@PostMapping(value = "/modifyMenuById")
|
@PostMapping(value = "/modifyMenuById")
|
||||||
@PreAuthorize("@el.check('menu:edit')")
|
@PreAuthorize("@el.check('menu:edit')")
|
||||||
public ResponseEntity<Void> modifyMenuById(@Validated(SystemMenuTb.Update.class) @RequestBody SystemMenuTb args) {
|
public ResponseEntity<Void> modifyMenuById(@Validated(SystemMenuTb.Update.class) @RequestBody SystemMenuTb args) {
|
||||||
systemMenuService.modifyMenuById(args);
|
systemMenuService.updateMenuById(args);
|
||||||
return ResponseEntity.ok(null);
|
return ResponseEntity.ok(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -104,7 +104,7 @@ public class SystemQuartzJobController {
|
|||||||
@Validated(SystemQuartzJobTb.Update.class) @RequestBody SystemUpdateQuartzJobArgs args) {
|
@Validated(SystemQuartzJobTb.Update.class) @RequestBody SystemUpdateQuartzJobArgs args) {
|
||||||
// 验证Bean是不是合法的, 合法的定时任务 Bean 需要用 @Service 定义
|
// 验证Bean是不是合法的, 合法的定时任务 Bean 需要用 @Service 定义
|
||||||
checkBean(args.getBeanName());
|
checkBean(args.getBeanName());
|
||||||
systemQuartzJobService.modifyQuartzJobResumeCron(args);
|
systemQuartzJobService.updateQuartzJobResumeCron(args);
|
||||||
return ResponseEntity.ok(null);
|
return ResponseEntity.ok(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -103,7 +103,7 @@ public class SystemRoleController {
|
|||||||
@PreAuthorize("@el.check('roles:edit')")
|
@PreAuthorize("@el.check('roles:edit')")
|
||||||
public ResponseEntity<Void> modifyRoleById(@Validated(SystemRoleTb.Update.class) @RequestBody SystemRoleVo args) {
|
public ResponseEntity<Void> modifyRoleById(@Validated(SystemRoleTb.Update.class) @RequestBody SystemRoleVo args) {
|
||||||
checkRoleLevels(args.getLevel());
|
checkRoleLevels(args.getLevel());
|
||||||
systemRoleService.modifyRoleById(args);
|
systemRoleService.updateRoleById(args);
|
||||||
return ResponseEntity.ok(null);
|
return ResponseEntity.ok(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,7 +113,7 @@ public class SystemRoleController {
|
|||||||
public ResponseEntity<Void> modifyBindMenuById(@RequestBody SystemRoleVo args) {
|
public ResponseEntity<Void> modifyBindMenuById(@RequestBody SystemRoleVo args) {
|
||||||
SystemRoleTb role = systemRoleService.getRoleById(args.getId());
|
SystemRoleTb role = systemRoleService.getRoleById(args.getId());
|
||||||
checkRoleLevels(role.getLevel());
|
checkRoleLevels(role.getLevel());
|
||||||
systemRoleService.modifyBindMenuById(args);
|
systemRoleService.updateBindMenuById(args);
|
||||||
return ResponseEntity.ok(null);
|
return ResponseEntity.ok(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+8
-8
@@ -98,12 +98,12 @@ public class SystemUserController {
|
|||||||
if (!ObjectUtils.isEmpty(criteria.getDeptId())) {
|
if (!ObjectUtils.isEmpty(criteria.getDeptId())) {
|
||||||
criteria.getDeptIds().add(criteria.getDeptId());
|
criteria.getDeptIds().add(criteria.getDeptId());
|
||||||
// 先查找是否存在子节点
|
// 先查找是否存在子节点
|
||||||
List<SystemDeptTb> data = systemDeptService.queryDeptByPid(criteria.getDeptId());
|
List<SystemDeptTb> data = systemDeptService.listDeptByPid(criteria.getDeptId());
|
||||||
// 然后把子节点的ID都加入到集合中
|
// 然后把子节点的ID都加入到集合中
|
||||||
criteria.getDeptIds().addAll(systemDeptService.queryChildDeptIdListByDeptIds(data));
|
criteria.getDeptIds().addAll(systemDeptService.queryChildDeptIdByDeptIds(data));
|
||||||
}
|
}
|
||||||
// 数据权限
|
// 数据权限
|
||||||
List<Long> dataScopes = systemDataService.findDeptIdListByArgs(
|
List<Long> dataScopes = systemDataService.queryDeptIdByArgs(
|
||||||
systemUserService.getUserByUsername(KitSecurityHelper.getCurrentUsername()));
|
systemUserService.getUserByUsername(KitSecurityHelper.getCurrentUsername()));
|
||||||
// criteria.getDeptIds() 不为空并且数据权限不为空则取交集
|
// criteria.getDeptIds() 不为空并且数据权限不为空则取交集
|
||||||
if (!CollectionUtils.isEmpty(criteria.getDeptIds()) && !CollectionUtils.isEmpty(dataScopes)) {
|
if (!CollectionUtils.isEmpty(criteria.getDeptIds()) && !CollectionUtils.isEmpty(dataScopes)) {
|
||||||
@@ -136,7 +136,7 @@ public class SystemUserController {
|
|||||||
@PreAuthorize("@el.check('user:edit')")
|
@PreAuthorize("@el.check('user:edit')")
|
||||||
public ResponseEntity<Object> modifyUserById(@Validated(SystemUserTb.Update.class) @RequestBody SystemUserVo args) {
|
public ResponseEntity<Object> modifyUserById(@Validated(SystemUserTb.Update.class) @RequestBody SystemUserVo args) {
|
||||||
checkLevel(args);
|
checkLevel(args);
|
||||||
systemUserService.modifyUserById(args);
|
systemUserService.updateUserById(args);
|
||||||
return ResponseEntity.ok(null);
|
return ResponseEntity.ok(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -147,7 +147,7 @@ public class SystemUserController {
|
|||||||
if (!args.getId().equals(KitSecurityHelper.getCurrentUserId())) {
|
if (!args.getId().equals(KitSecurityHelper.getCurrentUserId())) {
|
||||||
throw new BadRequestException("不能修改他人资料");
|
throw new BadRequestException("不能修改他人资料");
|
||||||
}
|
}
|
||||||
systemUserService.modifyUserCenterInfoById(args);
|
systemUserService.updateUserCenterInfoById(args);
|
||||||
return ResponseEntity.ok(null);
|
return ResponseEntity.ok(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -186,7 +186,7 @@ public class SystemUserController {
|
|||||||
if (passwordEncoder.matches(newPass, user.getPassword())) {
|
if (passwordEncoder.matches(newPass, user.getPassword())) {
|
||||||
throw new BadRequestException("新密码不能与旧密码相同");
|
throw new BadRequestException("新密码不能与旧密码相同");
|
||||||
}
|
}
|
||||||
systemUserService.modifyUserPasswordByUsername(user.getUsername(), passwordEncoder.encode(newPass));
|
systemUserService.updateUserPasswordByUsername(user.getUsername(), passwordEncoder.encode(newPass));
|
||||||
return ResponseEntity.ok(null);
|
return ResponseEntity.ok(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -201,7 +201,7 @@ public class SystemUserController {
|
|||||||
@ApiOperation("修改头像")
|
@ApiOperation("修改头像")
|
||||||
@PostMapping(value = "/modifyUserAvatar")
|
@PostMapping(value = "/modifyUserAvatar")
|
||||||
public ResponseEntity<Object> modifyUserAvatar(@RequestParam MultipartFile avatar) {
|
public ResponseEntity<Object> modifyUserAvatar(@RequestParam MultipartFile avatar) {
|
||||||
return ResponseEntity.ok(systemUserService.modifyUserAvatar(avatar));
|
return ResponseEntity.ok(systemUserService.updateUserAvatar(avatar));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("修改邮箱")
|
@ApiOperation("修改邮箱")
|
||||||
@@ -215,7 +215,7 @@ public class SystemUserController {
|
|||||||
throw new BadRequestException("密码错误");
|
throw new BadRequestException("密码错误");
|
||||||
}
|
}
|
||||||
systemEmailService.checkEmailCaptcha(SystemCaptchaBizEnum.EMAIL_RESET_EMAIL_CODE, args.getEmail(), code);
|
systemEmailService.checkEmailCaptcha(SystemCaptchaBizEnum.EMAIL_RESET_EMAIL_CODE, args.getEmail(), code);
|
||||||
systemUserService.modifyUserEmailByUsername(user.getUsername(), args.getEmail());
|
systemUserService.updateUserEmailByUsername(user.getUsername(), args.getEmail());
|
||||||
return ResponseEntity.ok(null);
|
return ResponseEntity.ok(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
-64
@@ -15,14 +15,8 @@
|
|||||||
*/
|
*/
|
||||||
package cn.odboy.system.dal.mysql;
|
package cn.odboy.system.dal.mysql;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
|
||||||
import cn.odboy.system.dal.dataobject.SystemMenuTb;
|
import cn.odboy.system.dal.dataobject.SystemMenuTb;
|
||||||
import cn.odboy.system.dal.model.SystemQueryMenuArgs;
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import java.util.List;
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -33,62 +27,4 @@ import org.apache.ibatis.annotations.Mapper;
|
|||||||
@Mapper
|
@Mapper
|
||||||
public interface SystemMenuMapper extends BaseMapper<SystemMenuTb> {
|
public interface SystemMenuMapper extends BaseMapper<SystemMenuTb> {
|
||||||
|
|
||||||
default void updateMenuSubCntByMenuId(Long count, Long menuId) {
|
|
||||||
if (count != null) {
|
|
||||||
LambdaUpdateWrapper<SystemMenuTb> wrapper = new LambdaUpdateWrapper<>();
|
|
||||||
wrapper.eq(SystemMenuTb::getId, menuId);
|
|
||||||
wrapper.set(SystemMenuTb::getSubCount, count);
|
|
||||||
update(wrapper);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
default SystemMenuTb getMenuByComponentName(String componentName) {
|
|
||||||
LambdaQueryWrapper<SystemMenuTb> wrapper = new LambdaQueryWrapper<>();
|
|
||||||
wrapper.eq(SystemMenuTb::getComponentName, componentName);
|
|
||||||
return selectOne(wrapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
default SystemMenuTb getMenuByTitle(String title) {
|
|
||||||
LambdaQueryWrapper<SystemMenuTb> wrapper = new LambdaQueryWrapper<>();
|
|
||||||
wrapper.eq(SystemMenuTb::getTitle, title);
|
|
||||||
return selectOne(wrapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
default Long countMenuByPid(Long pid) {
|
|
||||||
LambdaQueryWrapper<SystemMenuTb> wrapper = new LambdaQueryWrapper<>();
|
|
||||||
wrapper.eq(SystemMenuTb::getPid, pid);
|
|
||||||
return selectCount(wrapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
default List<SystemMenuTb> selectMenuByArgs(SystemQueryMenuArgs criteria) {
|
|
||||||
LambdaQueryWrapper<SystemMenuTb> wrapper = new LambdaQueryWrapper<>();
|
|
||||||
if (criteria != null) {
|
|
||||||
wrapper.isNull(criteria.getPidIsNull() != null, SystemMenuTb::getPid);
|
|
||||||
wrapper.eq(criteria.getPid() != null, SystemMenuTb::getPid, criteria.getPid());
|
|
||||||
wrapper.and(StrUtil.isNotBlank(criteria.getBlurry()),
|
|
||||||
c -> c.like(SystemMenuTb::getTitle, criteria.getBlurry()).or()
|
|
||||||
.like(SystemMenuTb::getComponentName, criteria.getBlurry()).or()
|
|
||||||
.like(SystemMenuTb::getPermission, criteria.getBlurry()));
|
|
||||||
if (CollUtil.isNotEmpty(criteria.getCreateTime()) && criteria.getCreateTime().size() >= 2) {
|
|
||||||
wrapper.between(SystemMenuTb::getCreateTime, criteria.getCreateTime().get(0),
|
|
||||||
criteria.getCreateTime().get(1));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
wrapper.orderByAsc(SystemMenuTb::getMenuSort);
|
|
||||||
return selectList(wrapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
default List<SystemMenuTb> selectMenuByPid(Long pid) {
|
|
||||||
LambdaQueryWrapper<SystemMenuTb> wrapper = new LambdaQueryWrapper<>();
|
|
||||||
wrapper.eq(SystemMenuTb::getPid, pid);
|
|
||||||
wrapper.orderByAsc(SystemMenuTb::getMenuSort);
|
|
||||||
return selectList(wrapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
default List<SystemMenuTb> selectMenuByPidIsNull() {
|
|
||||||
LambdaQueryWrapper<SystemMenuTb> wrapper = new LambdaQueryWrapper<>();
|
|
||||||
wrapper.isNull(SystemMenuTb::getPid);
|
|
||||||
wrapper.orderByAsc(SystemMenuTb::getMenuSort);
|
|
||||||
return selectList(wrapper);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
-21
@@ -15,11 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package cn.odboy.system.dal.mysql;
|
package cn.odboy.system.dal.mysql;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
|
||||||
import cn.odboy.system.dal.dataobject.SystemRoleTb;
|
import cn.odboy.system.dal.dataobject.SystemRoleTb;
|
||||||
import cn.odboy.system.dal.model.SystemQueryRoleArgs;
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
@@ -31,21 +27,4 @@ import org.apache.ibatis.annotations.Mapper;
|
|||||||
@Mapper
|
@Mapper
|
||||||
public interface SystemRoleMapper extends BaseMapper<SystemRoleTb> {
|
public interface SystemRoleMapper extends BaseMapper<SystemRoleTb> {
|
||||||
|
|
||||||
default Long countRoleByArgs(SystemQueryRoleArgs criteria) {
|
|
||||||
LambdaQueryWrapper<SystemRoleTb> wrapper = new LambdaQueryWrapper<>();
|
|
||||||
if (criteria != null) {
|
|
||||||
wrapper.and(StrUtil.isNotBlank(criteria.getBlurry()),
|
|
||||||
c -> c.like(SystemRoleTb::getName, criteria.getBlurry()).or()
|
|
||||||
.like(SystemRoleTb::getDescription, criteria.getBlurry()));
|
|
||||||
if (CollUtil.isNotEmpty(criteria.getCreateTime()) && criteria.getCreateTime().size() >= 2) {
|
|
||||||
wrapper.between(SystemRoleTb::getCreateTime, criteria.getCreateTime().get(0),
|
|
||||||
criteria.getCreateTime().get(1));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return selectCount(wrapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
default SystemRoleTb getRoleById(Long roleId) {
|
|
||||||
return selectById(roleId);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
-45
@@ -34,51 +34,6 @@ import org.apache.ibatis.annotations.Mapper;
|
|||||||
@Mapper
|
@Mapper
|
||||||
public interface SystemUserMapper extends BaseMapper<SystemUserTb> {
|
public interface SystemUserMapper extends BaseMapper<SystemUserTb> {
|
||||||
|
|
||||||
default SystemUserTb getUserByUsername(String username) {
|
|
||||||
LambdaQueryWrapper<SystemUserTb> wrapper = new LambdaQueryWrapper<>();
|
|
||||||
wrapper.eq(SystemUserTb::getUsername, username);
|
|
||||||
wrapper.eq(SystemUserTb::getEnabled, 1);
|
|
||||||
return selectOne(wrapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
default Long countUserByJobIds(Set<Long> jobIds) {
|
|
||||||
if (CollUtil.isEmpty(jobIds)) {
|
|
||||||
return 0L;
|
|
||||||
}
|
|
||||||
// 需要通过用户岗位关联表查询,这里暂时返回0
|
|
||||||
// 实际实现需要在Service层通过关联查询
|
|
||||||
return 0L;
|
|
||||||
}
|
|
||||||
|
|
||||||
default Long countUserByRoleIds(Set<Long> roleIds) {
|
|
||||||
if (CollUtil.isEmpty(roleIds)) {
|
|
||||||
return 0L;
|
|
||||||
}
|
|
||||||
// 需要通过用户角色关联表查询,这里暂时返回0
|
|
||||||
// 实际实现需要在Service层通过关联查询
|
|
||||||
return 0L;
|
|
||||||
}
|
|
||||||
|
|
||||||
default long countUserByDeptIds(Set<Long> deptIds) {
|
|
||||||
LambdaQueryWrapper<SystemUserTb> wrapper = new LambdaQueryWrapper<>();
|
|
||||||
wrapper.in(SystemUserTb::getDeptId, deptIds);
|
|
||||||
return selectCount(wrapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
default SystemUserTb getUserByEmail(String email) {
|
|
||||||
LambdaQueryWrapper<SystemUserTb> wrapper = new LambdaQueryWrapper<>();
|
|
||||||
wrapper.eq(SystemUserTb::getEmail, email);
|
|
||||||
wrapper.eq(SystemUserTb::getEnabled, 1);
|
|
||||||
return selectOne(wrapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
default SystemUserTb getUserByPhone(String phone) {
|
|
||||||
LambdaQueryWrapper<SystemUserTb> wrapper = new LambdaQueryWrapper<>();
|
|
||||||
wrapper.eq(SystemUserTb::getPhone, phone);
|
|
||||||
wrapper.eq(SystemUserTb::getEnabled, 1);
|
|
||||||
return selectOne(wrapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
default void updateUserPasswordByUsername(String username, String password) {
|
default void updateUserPasswordByUsername(String username, String password) {
|
||||||
LambdaUpdateWrapper<SystemUserTb> wrapper = new LambdaUpdateWrapper<>();
|
LambdaUpdateWrapper<SystemUserTb> wrapper = new LambdaUpdateWrapper<>();
|
||||||
wrapper.eq(SystemUserTb::getUsername, username);
|
wrapper.eq(SystemUserTb::getUsername, username);
|
||||||
|
|||||||
+1
-1
@@ -59,7 +59,7 @@ public class UserDetailsHandler implements UserDetailsService {
|
|||||||
// 获取用户的权限
|
// 获取用户的权限
|
||||||
List<SystemRoleCodeVo> authorities = systemRoleService.buildUserRolePermissions(user);
|
List<SystemRoleCodeVo> authorities = systemRoleService.buildUserRolePermissions(user);
|
||||||
// 初始化JwtUserDto
|
// 初始化JwtUserDto
|
||||||
userJwtVo = new SystemUserJwtVo(user, systemDataService.findDeptIdListByArgs(user), authorities);
|
userJwtVo = new SystemUserJwtVo(user, systemDataService.queryDeptIdByArgs(user), authorities);
|
||||||
// 添加缓存数据
|
// 添加缓存数据
|
||||||
systemUserInfoDAO.saveUserLoginInfoByUserName(username, userJwtVo);
|
systemUserInfoDAO.saveUserLoginInfoByUserName(username, userJwtVo);
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-5
@@ -49,7 +49,7 @@ public class SystemDataService {
|
|||||||
* @param user /
|
* @param user /
|
||||||
* @return /
|
* @return /
|
||||||
*/
|
*/
|
||||||
public List<Long> findDeptIdListByArgs(SystemUserTb user) {
|
public List<Long> queryDeptIdByArgs(SystemUserTb user) {
|
||||||
List<Long> deptIds = new ArrayList<>();
|
List<Long> deptIds = new ArrayList<>();
|
||||||
// 查询用户角色
|
// 查询用户角色
|
||||||
List<SystemRoleVo> roleList = systemRoleService.queryRoleByUsersId(user.getId());
|
List<SystemRoleVo> roleList = systemRoleService.queryRoleByUsersId(user.getId());
|
||||||
@@ -61,7 +61,7 @@ public class SystemDataService {
|
|||||||
deptIds.add(user.getDept().getId());
|
deptIds.add(user.getDept().getId());
|
||||||
break;
|
break;
|
||||||
case CUSTOMIZE:
|
case CUSTOMIZE:
|
||||||
deptIds.addAll(this.findCustomDataPermissionList(deptIds, role));
|
deptIds.addAll(this.queryCustomDataPermissionByArgs(deptIds, role));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
@@ -77,13 +77,13 @@ public class SystemDataService {
|
|||||||
* @param role 角色
|
* @param role 角色
|
||||||
* @return 数据权限ID
|
* @return 数据权限ID
|
||||||
*/
|
*/
|
||||||
private List<Long> findCustomDataPermissionList(List<Long> deptIds, SystemRoleTb role) {
|
private List<Long> queryCustomDataPermissionByArgs(List<Long> deptIds, SystemRoleTb role) {
|
||||||
List<SystemDeptTb> deptList = systemRoleDeptService.selectDeptByRoleId(role.getId());
|
List<SystemDeptTb> deptList = systemRoleDeptService.selectDeptByRoleId(role.getId());
|
||||||
for (SystemDeptTb dept : deptList) {
|
for (SystemDeptTb dept : deptList) {
|
||||||
deptIds.add(dept.getId());
|
deptIds.add(dept.getId());
|
||||||
List<SystemDeptTb> deptChildren = systemDeptService.queryDeptByPid(dept.getId());
|
List<SystemDeptTb> deptChildren = systemDeptService.listDeptByPid(dept.getId());
|
||||||
if (CollUtil.isNotEmpty(deptChildren)) {
|
if (CollUtil.isNotEmpty(deptChildren)) {
|
||||||
deptIds.addAll(systemDeptService.queryChildDeptIdListByDeptIds(deptChildren));
|
deptIds.addAll(systemDeptService.queryChildDeptIdByDeptIds(deptChildren));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return deptIds;
|
return deptIds;
|
||||||
|
|||||||
+43
-43
@@ -29,7 +29,6 @@ import cn.odboy.system.dal.model.SystemProductLineTreeVo;
|
|||||||
import cn.odboy.system.dal.model.SystemProductLineVo;
|
import cn.odboy.system.dal.model.SystemProductLineVo;
|
||||||
import cn.odboy.system.dal.model.SystemQueryDeptArgs;
|
import cn.odboy.system.dal.model.SystemQueryDeptArgs;
|
||||||
import cn.odboy.system.dal.mysql.SystemDeptMapper;
|
import cn.odboy.system.dal.mysql.SystemDeptMapper;
|
||||||
import cn.odboy.system.dal.mysql.SystemUserMapper;
|
|
||||||
import cn.odboy.system.framework.permission.core.KitSecurityHelper;
|
import cn.odboy.system.framework.permission.core.KitSecurityHelper;
|
||||||
import cn.odboy.util.KitClassUtil;
|
import cn.odboy.util.KitClassUtil;
|
||||||
import cn.odboy.util.KitFileUtil;
|
import cn.odboy.util.KitFileUtil;
|
||||||
@@ -58,7 +57,7 @@ public class SystemDeptService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private SystemDeptMapper systemDeptMapper;
|
private SystemDeptMapper systemDeptMapper;
|
||||||
@Autowired
|
@Autowired
|
||||||
private SystemUserMapper systemUserMapper;
|
private SystemUserService systemUserService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private SystemRoleService systemRoleService;
|
private SystemRoleService systemRoleService;
|
||||||
|
|
||||||
@@ -99,7 +98,7 @@ public class SystemDeptService {
|
|||||||
* @param deptSet /
|
* @param deptSet /
|
||||||
*/
|
*/
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void removeDeptByIds(Set<SystemDeptTb> deptSet) {
|
public void deleteDeptByIds(Set<SystemDeptTb> deptSet) {
|
||||||
for (SystemDeptTb dept : deptSet) {
|
for (SystemDeptTb dept : deptSet) {
|
||||||
systemDeptMapper.deleteById(dept.getId());
|
systemDeptMapper.deleteById(dept.getId());
|
||||||
this.updateDeptSubCnt(dept.getPid());
|
this.updateDeptSubCnt(dept.getPid());
|
||||||
@@ -138,7 +137,7 @@ public class SystemDeptService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public long countDeptByPid(Long pid) {
|
private long countDeptByPid(Long pid) {
|
||||||
LambdaQueryWrapper<SystemDeptTb> wrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<SystemDeptTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
wrapper.eq(SystemDeptTb::getPid, pid);
|
wrapper.eq(SystemDeptTb::getPid, pid);
|
||||||
return systemDeptMapper.selectCount(wrapper);
|
return systemDeptMapper.selectCount(wrapper);
|
||||||
@@ -160,7 +159,7 @@ public class SystemDeptService {
|
|||||||
return deptList;
|
return deptList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<SystemDeptTb> queryDeptByArgs(SystemQueryDeptArgs criteria) {
|
private List<SystemDeptTb> queryDeptByArgs(SystemQueryDeptArgs criteria) {
|
||||||
LambdaQueryWrapper<SystemDeptTb> wrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<SystemDeptTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
if (criteria != null) {
|
if (criteria != null) {
|
||||||
wrapper.in(CollUtil.isNotEmpty(criteria.getIds()), SystemDeptTb::getId, criteria.getIds());
|
wrapper.in(CollUtil.isNotEmpty(criteria.getIds()), SystemDeptTb::getId, criteria.getIds());
|
||||||
@@ -185,7 +184,7 @@ public class SystemDeptService {
|
|||||||
* @return /
|
* @return /
|
||||||
* @throws Exception /
|
* @throws Exception /
|
||||||
*/
|
*/
|
||||||
public List<SystemDeptTb> queryAllDept(SystemQueryDeptArgs criteria, Boolean isQuery) throws Exception {
|
public List<SystemDeptTb> queryAllDeptByArgs(SystemQueryDeptArgs criteria, Boolean isQuery) throws Exception {
|
||||||
String dataScopeType = KitSecurityHelper.getDataScopeType();
|
String dataScopeType = KitSecurityHelper.getDataScopeType();
|
||||||
if (isQuery) {
|
if (isQuery) {
|
||||||
if (dataScopeType.equals(SystemDataScopeEnum.ALL.getValue())) {
|
if (dataScopeType.equals(SystemDataScopeEnum.ALL.getValue())) {
|
||||||
@@ -229,16 +228,6 @@ public class SystemDeptService {
|
|||||||
return systemDeptMapper.selectById(id);
|
return systemDeptMapper.selectById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据PID查询
|
|
||||||
*
|
|
||||||
* @param pid /
|
|
||||||
* @return /
|
|
||||||
*/
|
|
||||||
public List<SystemDeptTb> queryDeptByPid(long pid) {
|
|
||||||
return this.selectDeptByPid(pid);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取部门下所有关联的部门
|
* 获取部门下所有关联的部门
|
||||||
*
|
*
|
||||||
@@ -246,30 +235,24 @@ public class SystemDeptService {
|
|||||||
* @param depts /
|
* @param depts /
|
||||||
* @return /
|
* @return /
|
||||||
*/
|
*/
|
||||||
public Set<SystemDeptTb> queryRelationDeptSet(List<SystemDeptTb> deptTbList, Set<SystemDeptTb> depts) {
|
private Set<SystemDeptTb> queryRelationDeptByArgs(List<SystemDeptTb> deptTbList, Set<SystemDeptTb> depts) {
|
||||||
for (SystemDeptTb dept : deptTbList) {
|
for (SystemDeptTb dept : deptTbList) {
|
||||||
depts.add(dept);
|
depts.add(dept);
|
||||||
List<SystemDeptTb> deptList = this.selectDeptByPid(dept.getId());
|
List<SystemDeptTb> deptList = this.listDeptByPid(dept.getId());
|
||||||
if (CollUtil.isNotEmpty(deptList)) {
|
if (CollUtil.isNotEmpty(deptList)) {
|
||||||
queryRelationDeptSet(deptList, depts);
|
queryRelationDeptByArgs(deptList, depts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return depts;
|
return depts;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public List<Long> queryChildDeptIdByDeptIds(List<SystemDeptTb> deptList) {
|
||||||
* 获取
|
|
||||||
*
|
|
||||||
* @param deptList 、
|
|
||||||
* @return 、
|
|
||||||
*/
|
|
||||||
public List<Long> queryChildDeptIdListByDeptIds(List<SystemDeptTb> deptList) {
|
|
||||||
List<Long> list = new ArrayList<>();
|
List<Long> list = new ArrayList<>();
|
||||||
for (SystemDeptTb systemDeptTb : deptList) {
|
for (SystemDeptTb systemDeptTb : deptList) {
|
||||||
if (systemDeptTb != null && systemDeptTb.getEnabled()) {
|
if (systemDeptTb != null && systemDeptTb.getEnabled()) {
|
||||||
List<SystemDeptTb> deptList1 = this.selectDeptByPid(systemDeptTb.getId());
|
List<SystemDeptTb> deptList1 = this.listDeptByPid(systemDeptTb.getId());
|
||||||
if (CollUtil.isNotEmpty(deptList1)) {
|
if (CollUtil.isNotEmpty(deptList1)) {
|
||||||
list.addAll(queryChildDeptIdListByDeptIds(deptList1));
|
list.addAll(queryChildDeptIdByDeptIds(deptList1));
|
||||||
}
|
}
|
||||||
list.add(systemDeptTb.getId());
|
list.add(systemDeptTb.getId());
|
||||||
}
|
}
|
||||||
@@ -284,16 +267,16 @@ public class SystemDeptService {
|
|||||||
* @param deptList /
|
* @param deptList /
|
||||||
* @return /
|
* @return /
|
||||||
*/
|
*/
|
||||||
public List<SystemDeptTb> querySuperiorDeptListByPid(SystemDeptTb dept, List<SystemDeptTb> deptList) {
|
private List<SystemDeptTb> querySuperiorDeptByPid(SystemDeptTb dept, List<SystemDeptTb> deptList) {
|
||||||
if (dept.getPid() == null) {
|
if (dept.getPid() == null) {
|
||||||
deptList.addAll(this.selectDeptByPidIsNull());
|
deptList.addAll(this.listRootDept());
|
||||||
return deptList;
|
return deptList;
|
||||||
}
|
}
|
||||||
deptList.addAll(this.selectDeptByPid(dept.getPid()));
|
deptList.addAll(this.listDeptByPid(dept.getPid()));
|
||||||
return querySuperiorDeptListByPid(this.getDeptById(dept.getPid()), deptList);
|
return querySuperiorDeptByPid(this.getDeptById(dept.getPid()), deptList);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<SystemDeptTb> selectDeptByPidIsNull() {
|
private List<SystemDeptTb> listRootDept() {
|
||||||
LambdaQueryWrapper<SystemDeptTb> wrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<SystemDeptTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
wrapper.isNull(SystemDeptTb::getPid);
|
wrapper.isNull(SystemDeptTb::getPid);
|
||||||
return systemDeptMapper.selectList(wrapper);
|
return systemDeptMapper.selectList(wrapper);
|
||||||
@@ -302,10 +285,28 @@ public class SystemDeptService {
|
|||||||
/**
|
/**
|
||||||
* 构建树形数据
|
* 构建树形数据
|
||||||
*
|
*
|
||||||
* @param deptList /
|
|
||||||
* @return /
|
* @return /
|
||||||
*/
|
*/
|
||||||
public KitPageResult<SystemDeptTb> buildDeptTree(List<SystemDeptTb> deptList) {
|
public KitPageResult<SystemDeptTb> searchDeptTree(List<Long> ids, Boolean exclude) {
|
||||||
|
Set<SystemDeptTb> deptSet1 = new LinkedHashSet<>();
|
||||||
|
for (Long id : ids) {
|
||||||
|
// 同级数据
|
||||||
|
SystemDeptTb dept = this.getDeptById(id);
|
||||||
|
// 上级数据
|
||||||
|
List<SystemDeptTb> depts = this.querySuperiorDeptByPid(dept, new ArrayList<>());
|
||||||
|
if (exclude) {
|
||||||
|
for (SystemDeptTb data : depts) {
|
||||||
|
if (data.getId().equals(dept.getPid())) {
|
||||||
|
data.setSubCount(data.getSubCount() - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 编辑部门时不显示自己以及自己下级的数据, 避免出现PID数据环形问题
|
||||||
|
depts = depts.stream().filter(i -> !ids.contains(i.getId())).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
deptSet1.addAll(depts);
|
||||||
|
}
|
||||||
|
ArrayList<SystemDeptTb> deptList = new ArrayList<>(deptSet1);
|
||||||
|
// 构建部门树
|
||||||
Set<SystemDeptTb> trees = new LinkedHashSet<>();
|
Set<SystemDeptTb> trees = new LinkedHashSet<>();
|
||||||
Set<SystemDeptTb> deptSet = new LinkedHashSet<>();
|
Set<SystemDeptTb> deptSet = new LinkedHashSet<>();
|
||||||
List<String> deptNames = deptList.stream().map(SystemDeptTb::getName).collect(Collectors.toList());
|
List<String> deptNames = deptList.stream().map(SystemDeptTb::getName).collect(Collectors.toList());
|
||||||
@@ -346,7 +347,7 @@ public class SystemDeptService {
|
|||||||
*/
|
*/
|
||||||
public void verifyBindRelationByIds(Set<SystemDeptTb> deptSet) {
|
public void verifyBindRelationByIds(Set<SystemDeptTb> deptSet) {
|
||||||
Set<Long> deptIds = deptSet.stream().map(SystemDeptTb::getId).collect(Collectors.toSet());
|
Set<Long> deptIds = deptSet.stream().map(SystemDeptTb::getId).collect(Collectors.toSet());
|
||||||
if (systemUserMapper.countUserByDeptIds(deptIds) > 0) {
|
if (systemUserService.countUserByDeptIds(deptIds) > 0) {
|
||||||
throw new BadRequestException("所选部门存在用户关联,请解除后再试!");
|
throw new BadRequestException("所选部门存在用户关联,请解除后再试!");
|
||||||
}
|
}
|
||||||
if (systemRoleService.countRoleByDeptIds(deptIds) > 0) {
|
if (systemRoleService.countRoleByDeptIds(deptIds) > 0) {
|
||||||
@@ -354,7 +355,7 @@ public class SystemDeptService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<SystemDeptTb> selectEnabledDepts() {
|
private List<SystemDeptTb> listEnabledDepts() {
|
||||||
LambdaQueryWrapper<SystemDeptTb> wrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<SystemDeptTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
wrapper.eq(SystemDeptTb::getEnabled, 1);
|
wrapper.eq(SystemDeptTb::getEnabled, 1);
|
||||||
return systemDeptMapper.selectList(wrapper);
|
return systemDeptMapper.selectList(wrapper);
|
||||||
@@ -371,16 +372,16 @@ public class SystemDeptService {
|
|||||||
// 根部门
|
// 根部门
|
||||||
depts.add(this.getDeptById(id));
|
depts.add(this.getDeptById(id));
|
||||||
// 子部门
|
// 子部门
|
||||||
List<SystemDeptTb> deptList = queryDeptByPid(id);
|
List<SystemDeptTb> deptList = listDeptByPid(id);
|
||||||
if (CollectionUtil.isNotEmpty(deptList)) {
|
if (CollectionUtil.isNotEmpty(deptList)) {
|
||||||
depts = queryRelationDeptSet(deptList, depts);
|
depts = queryRelationDeptByArgs(deptList, depts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return depts;
|
return depts;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<SystemProductLineVo> queryDeptSelectDataSource() {
|
public List<SystemProductLineVo> queryDeptSelectDataSource() {
|
||||||
List<SystemDeptTb> depts = this.selectEnabledDepts();
|
List<SystemDeptTb> depts = this.listEnabledDepts();
|
||||||
return buildDeptSelectOptions(depts);
|
return buildDeptSelectOptions(depts);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -429,7 +430,7 @@ public class SystemDeptService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<SystemProductLineTreeVo> queryDeptSelectProDataSource() {
|
public List<SystemProductLineTreeVo> queryDeptSelectProDataSource() {
|
||||||
List<SystemDeptTb> depts = this.selectEnabledDepts();
|
List<SystemDeptTb> depts = this.listEnabledDepts();
|
||||||
// 获取所有部门并按父子关系组织
|
// 获取所有部门并按父子关系组织
|
||||||
Map<Long, SystemDeptTb> deptMap =
|
Map<Long, SystemDeptTb> deptMap =
|
||||||
depts.stream().collect(Collectors.toMap(SystemDeptTb::getId, Function.identity()));
|
depts.stream().collect(Collectors.toMap(SystemDeptTb::getId, Function.identity()));
|
||||||
@@ -477,10 +478,9 @@ public class SystemDeptService {
|
|||||||
return vo;
|
return vo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<SystemDeptTb> selectDeptByPid(long pid) {
|
public List<SystemDeptTb> listDeptByPid(long pid) {
|
||||||
LambdaQueryWrapper<SystemDeptTb> wrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<SystemDeptTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
wrapper.eq(SystemDeptTb::getPid, pid);
|
wrapper.eq(SystemDeptTb::getPid, pid);
|
||||||
return systemDeptMapper.selectList(wrapper);
|
return systemDeptMapper.selectList(wrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+9
-10
@@ -64,7 +64,7 @@ public class SystemDictDetailService {
|
|||||||
* @param args /
|
* @param args /
|
||||||
*/
|
*/
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void modifyDictDetailById(SystemDictDetailTb args) {
|
public void updateDictDetailById(SystemDictDetailTb args) {
|
||||||
SystemDictDetailTb dictDetail = systemDictDetailMapper.selectById(args.getId());
|
SystemDictDetailTb dictDetail = systemDictDetailMapper.selectById(args.getId());
|
||||||
args.setId(dictDetail.getId());
|
args.setId(dictDetail.getId());
|
||||||
systemDictDetailMapper.insertOrUpdate(args);
|
systemDictDetailMapper.insertOrUpdate(args);
|
||||||
@@ -76,7 +76,7 @@ public class SystemDictDetailService {
|
|||||||
* @param id /
|
* @param id /
|
||||||
*/
|
*/
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void removeDictDetailById(Long id) {
|
public void deleteDictDetailById(Long id) {
|
||||||
systemDictDetailMapper.deleteById(id);
|
systemDictDetailMapper.deleteById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,13 +89,13 @@ public class SystemDictDetailService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<SystemDictDetailTb> selectByDictId(Long dictId) {
|
private List<SystemDictDetailTb> listDictDetailByDictId(Long dictId) {
|
||||||
LambdaQueryWrapper<SystemDictDetailTb> wrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<SystemDictDetailTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
wrapper.eq(SystemDictDetailTb::getDictId, dictId);
|
wrapper.eq(SystemDictDetailTb::getDictId, dictId);
|
||||||
return systemDictDetailMapper.selectList(wrapper);
|
return systemDictDetailMapper.selectList(wrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
private IPage<SystemDictDetailTb> selectDictDetailByArgs(List<Long> dictIds, Page<SystemDictDetailTb> page) {
|
private IPage<SystemDictDetailTb> searchDictDetailByArgs(List<Long> dictIds, Page<SystemDictDetailTb> page) {
|
||||||
LambdaQueryWrapper<SystemDictDetailTb> wrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<SystemDictDetailTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
wrapper.in(CollUtil.isNotEmpty(dictIds), SystemDictDetailTb::getDictId, dictIds);
|
wrapper.in(CollUtil.isNotEmpty(dictIds), SystemDictDetailTb::getDictId, dictIds);
|
||||||
return systemDictDetailMapper.selectPage(page, wrapper);
|
return systemDictDetailMapper.selectPage(page, wrapper);
|
||||||
@@ -108,14 +108,14 @@ public class SystemDictDetailService {
|
|||||||
* @param page 分页参数
|
* @param page 分页参数
|
||||||
* @return /
|
* @return /
|
||||||
*/
|
*/
|
||||||
public KitPageResult<SystemDictDetailVo> queryDictDetailByArgs(SystemQueryDictDetailArgs args,
|
public KitPageResult<SystemDictDetailVo> searchDictDetail(SystemQueryDictDetailArgs args,
|
||||||
Page<SystemDictDetailTb> page) {
|
Page<SystemDictDetailTb> page) {
|
||||||
IPage<SystemDictDetailVo> iPage = new Page<>();
|
IPage<SystemDictDetailVo> iPage = new Page<>();
|
||||||
List<Long> dictIds = new ArrayList<>();
|
List<Long> dictIds = new ArrayList<>();
|
||||||
List<SystemDictTb> dictTbs = new ArrayList<>();
|
List<SystemDictTb> dictTbs = new ArrayList<>();
|
||||||
|
|
||||||
if (args == null) {
|
if (args == null) {
|
||||||
dictTbs.addAll(systemDictService.selectList(null));
|
dictTbs.addAll(systemDictService.listAll());
|
||||||
dictIds = dictTbs.stream().map(SystemDictTb::getId).collect(Collectors.toList());
|
dictIds = dictTbs.stream().map(SystemDictTb::getId).collect(Collectors.toList());
|
||||||
} else {
|
} else {
|
||||||
String dictName = args.getDictName();
|
String dictName = args.getDictName();
|
||||||
@@ -132,7 +132,7 @@ public class SystemDictDetailService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Map<Long, SystemDictTb> id2ItemMap = dictTbs.stream().collect(Collectors.toMap(SystemDictTb::getId, i -> i));
|
Map<Long, SystemDictTb> id2ItemMap = dictTbs.stream().collect(Collectors.toMap(SystemDictTb::getId, i -> i));
|
||||||
iPage = this.selectDictDetailByArgs(dictIds, page)
|
iPage = this.searchDictDetailByArgs(dictIds, page)
|
||||||
.convert(i -> BeanUtil.copyProperties(i, SystemDictDetailVo.class));
|
.convert(i -> BeanUtil.copyProperties(i, SystemDictDetailVo.class));
|
||||||
for (SystemDictDetailVo record : iPage.getRecords()) {
|
for (SystemDictDetailVo record : iPage.getRecords()) {
|
||||||
record.setDict(id2ItemMap.get(record.getDictId()));
|
record.setDict(id2ItemMap.get(record.getDictId()));
|
||||||
@@ -146,7 +146,7 @@ public class SystemDictDetailService {
|
|||||||
* @param name 字典名称
|
* @param name 字典名称
|
||||||
* @return /
|
* @return /
|
||||||
*/
|
*/
|
||||||
public List<SystemDictDetailVo> queryDictDetailByName(String name) {
|
public List<SystemDictDetailVo> listDictDetailByName(String name) {
|
||||||
if (StrUtil.isBlank(name)) {
|
if (StrUtil.isBlank(name)) {
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
@@ -154,11 +154,10 @@ public class SystemDictDetailService {
|
|||||||
if (systemDictTb == null) {
|
if (systemDictTb == null) {
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
return this.selectByDictId(systemDictTb.getId()).stream().map(m -> {
|
return this.listDictDetailByDictId(systemDictTb.getId()).stream().map(m -> {
|
||||||
SystemDictDetailVo detailVo = BeanUtil.copyProperties(m, SystemDictDetailVo.class);
|
SystemDictDetailVo detailVo = BeanUtil.copyProperties(m, SystemDictDetailVo.class);
|
||||||
detailVo.setDict(systemDictTb);
|
detailVo.setDict(systemDictTb);
|
||||||
return detailVo;
|
return detailVo;
|
||||||
}).collect(Collectors.toList());
|
}).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+11
-28
@@ -64,7 +64,7 @@ public class SystemDictService {
|
|||||||
* @param args /
|
* @param args /
|
||||||
*/
|
*/
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void modifyDictById(SystemDictTb args) {
|
public void updateDictById(SystemDictTb args) {
|
||||||
SystemDictTb dict = systemDictMapper.selectById(args.getId());
|
SystemDictTb dict = systemDictMapper.selectById(args.getId());
|
||||||
dict.setName(args.getName());
|
dict.setName(args.getName());
|
||||||
dict.setDescription(args.getDescription());
|
dict.setDescription(args.getDescription());
|
||||||
@@ -77,7 +77,7 @@ public class SystemDictService {
|
|||||||
* @param ids /
|
* @param ids /
|
||||||
*/
|
*/
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void removeDictByIds(Set<Long> ids) {
|
public void deleteDictByIds(Set<Long> ids) {
|
||||||
// 删除字典
|
// 删除字典
|
||||||
systemDictMapper.deleteByIds(ids);
|
systemDictMapper.deleteByIds(ids);
|
||||||
// 删除字典详情
|
// 删除字典详情
|
||||||
@@ -94,7 +94,7 @@ public class SystemDictService {
|
|||||||
public void exportDictExcel(List<SystemDictTb> dicts, HttpServletResponse response) throws IOException {
|
public void exportDictExcel(List<SystemDictTb> dicts, HttpServletResponse response) throws IOException {
|
||||||
List<Map<String, Object>> list = new ArrayList<>();
|
List<Map<String, Object>> list = new ArrayList<>();
|
||||||
for (SystemDictTb dict : dicts) {
|
for (SystemDictTb dict : dicts) {
|
||||||
List<SystemDictDetailVo> dictDetails = systemDictDetailService.queryDictDetailByName(dict.getName());
|
List<SystemDictDetailVo> dictDetails = systemDictDetailService.listDictDetailByName(dict.getName());
|
||||||
if (CollectionUtil.isNotEmpty(dictDetails)) {
|
if (CollectionUtil.isNotEmpty(dictDetails)) {
|
||||||
for (SystemDictDetailTb dictDetail : dictDetails) {
|
for (SystemDictDetailTb dictDetail : dictDetails) {
|
||||||
Map<String, Object> map = new LinkedHashMap<>();
|
Map<String, Object> map = new LinkedHashMap<>();
|
||||||
@@ -125,22 +125,11 @@ public class SystemDictService {
|
|||||||
* @param page 分页参数
|
* @param page 分页参数
|
||||||
* @return /
|
* @return /
|
||||||
*/
|
*/
|
||||||
public KitPageResult<SystemDictTb> queryDictByArgs(SystemQueryDictArgs args, Page<SystemDictTb> page) {
|
public KitPageResult<SystemDictTb> searchDict(SystemQueryDictArgs args, Page<SystemDictTb> page) {
|
||||||
return KitPageUtil.toPage(this.selectDictByArgs(args, page));
|
LambdaQueryWrapper<SystemDictTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
}
|
injectQueryParams(args, wrapper);
|
||||||
|
Page<SystemDictTb> selectPage = systemDictMapper.selectPage(page, wrapper);
|
||||||
/**
|
return KitPageUtil.toPage(selectPage);
|
||||||
* 查询全部数据
|
|
||||||
*
|
|
||||||
* @param args /
|
|
||||||
* @return /
|
|
||||||
*/
|
|
||||||
public List<SystemDictTb> queryDictByArgs(SystemQueryDictArgs args) {
|
|
||||||
return this.selectDictByArgs(args);
|
|
||||||
}
|
|
||||||
|
|
||||||
public SystemDictTb getById(int id) {
|
|
||||||
return systemDictMapper.selectById(id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void injectQueryParams(SystemQueryDictArgs args, LambdaQueryWrapper<SystemDictTb> wrapper) {
|
private void injectQueryParams(SystemQueryDictArgs args, LambdaQueryWrapper<SystemDictTb> wrapper) {
|
||||||
@@ -150,25 +139,19 @@ public class SystemDictService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<SystemDictTb> selectDictByArgs(SystemQueryDictArgs args) {
|
public List<SystemDictTb> queryDictByArgs(SystemQueryDictArgs args) {
|
||||||
LambdaQueryWrapper<SystemDictTb> wrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<SystemDictTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
injectQueryParams(args, wrapper);
|
injectQueryParams(args, wrapper);
|
||||||
return systemDictMapper.selectList(wrapper);
|
return systemDictMapper.selectList(wrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<SystemDictTb> selectDictByArgs(SystemQueryDictArgs args, Page<SystemDictTb> page) {
|
|
||||||
LambdaQueryWrapper<SystemDictTb> wrapper = new LambdaQueryWrapper<>();
|
|
||||||
injectQueryParams(args, wrapper);
|
|
||||||
return systemDictMapper.selectList(page, wrapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
public SystemDictTb getByName(String name) {
|
public SystemDictTb getByName(String name) {
|
||||||
LambdaQueryWrapper<SystemDictTb> wrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<SystemDictTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
wrapper.eq(SystemDictTb::getName, name);
|
wrapper.eq(SystemDictTb::getName, name);
|
||||||
return systemDictMapper.selectOne(wrapper);
|
return systemDictMapper.selectOne(wrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<SystemDictTb> selectList(LambdaQueryWrapper<SystemDictTb> wrapper) {
|
public List<SystemDictTb> listAll() {
|
||||||
return systemDictMapper.selectList(wrapper);
|
return systemDictMapper.selectList(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -54,7 +54,7 @@ public class SystemEmailService {
|
|||||||
* @param emailConfig 邮箱配置
|
* @param emailConfig 邮箱配置
|
||||||
*/
|
*/
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void modifyEmailConfig(SystemEmailConfigTb emailConfig) throws Exception {
|
public void updateEmailConfigById(SystemEmailConfigTb emailConfig) throws Exception {
|
||||||
SystemEmailConfigTb systemEmailConfigTb = getLastEmailConfig();
|
SystemEmailConfigTb systemEmailConfigTb = getLastEmailConfig();
|
||||||
if (!emailConfig.getPassword().equals(systemEmailConfigTb.getPassword())) {
|
if (!emailConfig.getPassword().equals(systemEmailConfigTb.getPassword())) {
|
||||||
// 对称加密
|
// 对称加密
|
||||||
|
|||||||
+3
-3
@@ -47,7 +47,7 @@ public class SystemJobService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private SystemJobMapper systemJobMapper;
|
private SystemJobMapper systemJobMapper;
|
||||||
@Autowired
|
@Autowired
|
||||||
private SystemUserMapper systemUserMapper;
|
private SystemUserService systemUserService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建
|
* 创建
|
||||||
@@ -69,7 +69,7 @@ public class SystemJobService {
|
|||||||
* @param args /
|
* @param args /
|
||||||
*/
|
*/
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void modifyJobById(SystemJobTb args) {
|
public void updateJobById(SystemJobTb args) {
|
||||||
SystemJobTb job = systemJobMapper.selectById(args.getId());
|
SystemJobTb job = systemJobMapper.selectById(args.getId());
|
||||||
SystemJobTb old = this.getJobByName(args.getName());
|
SystemJobTb old = this.getJobByName(args.getName());
|
||||||
if (old != null && !old.getId().equals(args.getId())) {
|
if (old != null && !old.getId().equals(args.getId())) {
|
||||||
@@ -135,7 +135,7 @@ public class SystemJobService {
|
|||||||
* @param ids /
|
* @param ids /
|
||||||
*/
|
*/
|
||||||
public void verifyBindRelationByIds(Set<Long> ids) {
|
public void verifyBindRelationByIds(Set<Long> ids) {
|
||||||
if (systemUserMapper.countUserByJobIds(ids) > 0) {
|
if (systemUserService.countUserByJobIds(ids) > 0) {
|
||||||
throw new BadRequestException("所选的岗位中存在用户关联, 请解除关联再试!");
|
throw new BadRequestException("所选的岗位中存在用户关联, 请解除关联再试!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -99,7 +99,7 @@ public class SystemLocalStorageService {
|
|||||||
* @param args 文件信息
|
* @param args 文件信息
|
||||||
*/
|
*/
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void modifyLocalStorageById(SystemLocalStorageTb args) {
|
public void updateLocalStorageById(SystemLocalStorageTb args) {
|
||||||
SystemLocalStorageTb localStorage = systemLocalStorageMapper.selectById(args.getId());
|
SystemLocalStorageTb localStorage = systemLocalStorageMapper.selectById(args.getId());
|
||||||
localStorage.copy(args);
|
localStorage.copy(args);
|
||||||
systemLocalStorageMapper.insertOrUpdate(localStorage);
|
systemLocalStorageMapper.insertOrUpdate(localStorage);
|
||||||
|
|||||||
+68
-14
@@ -34,6 +34,7 @@ import cn.odboy.system.dal.mysql.SystemRoleMenuMapper;
|
|||||||
import cn.odboy.util.KitClassUtil;
|
import cn.odboy.util.KitClassUtil;
|
||||||
import cn.odboy.util.KitFileUtil;
|
import cn.odboy.util.KitFileUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -71,11 +72,11 @@ public class SystemMenuService {
|
|||||||
*/
|
*/
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void saveMenu(SystemMenuTb args) {
|
public void saveMenu(SystemMenuTb args) {
|
||||||
if (systemMenuMapper.getMenuByTitle(args.getTitle()) != null) {
|
if (this.getMenuByTitle(args.getTitle()) != null) {
|
||||||
throw new BadRequestException("菜单标题已存在");
|
throw new BadRequestException("菜单标题已存在");
|
||||||
}
|
}
|
||||||
if (StrUtil.isNotBlank(args.getComponentName())) {
|
if (StrUtil.isNotBlank(args.getComponentName())) {
|
||||||
if (systemMenuMapper.getMenuByComponentName(args.getComponentName()) != null) {
|
if (this.getMenuByComponentName(args.getComponentName()) != null) {
|
||||||
throw new BadRequestException("菜单组件名称已存在");
|
throw new BadRequestException("菜单组件名称已存在");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -101,7 +102,7 @@ public class SystemMenuService {
|
|||||||
* @param args /
|
* @param args /
|
||||||
*/
|
*/
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void modifyMenuById(SystemMenuTb args) {
|
public void updateMenuById(SystemMenuTb args) {
|
||||||
if (args.getId().equals(args.getPid())) {
|
if (args.getId().equals(args.getPid())) {
|
||||||
throw new BadRequestException("上级不能为自己");
|
throw new BadRequestException("上级不能为自己");
|
||||||
}
|
}
|
||||||
@@ -112,7 +113,7 @@ public class SystemMenuService {
|
|||||||
throw new BadRequestException(TransferProtocolConst.PREFIX_HTTPS_BAD_REQUEST);
|
throw new BadRequestException(TransferProtocolConst.PREFIX_HTTPS_BAD_REQUEST);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SystemMenuTb menu1 = systemMenuMapper.getMenuByTitle(args.getTitle());
|
SystemMenuTb menu1 = this.getMenuByTitle(args.getTitle());
|
||||||
if (menu1 != null && !menu1.getId().equals(menu.getId())) {
|
if (menu1 != null && !menu1.getId().equals(menu.getId())) {
|
||||||
throw new BadRequestException("菜单标题已存在");
|
throw new BadRequestException("菜单标题已存在");
|
||||||
}
|
}
|
||||||
@@ -123,7 +124,7 @@ public class SystemMenuService {
|
|||||||
Long oldPid = menu.getPid();
|
Long oldPid = menu.getPid();
|
||||||
Long newPid = args.getPid();
|
Long newPid = args.getPid();
|
||||||
if (StrUtil.isNotBlank(args.getComponentName())) {
|
if (StrUtil.isNotBlank(args.getComponentName())) {
|
||||||
menu1 = systemMenuMapper.getMenuByComponentName(args.getComponentName());
|
menu1 = this.getMenuByComponentName(args.getComponentName());
|
||||||
if (menu1 != null && !menu1.getId().equals(menu.getId())) {
|
if (menu1 != null && !menu1.getId().equals(menu.getId())) {
|
||||||
throw new BadRequestException("菜单组件名称已存在");
|
throw new BadRequestException("菜单组件名称已存在");
|
||||||
}
|
}
|
||||||
@@ -206,8 +207,11 @@ public class SystemMenuService {
|
|||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void updateMenuSubCnt(Long menuId) {
|
public void updateMenuSubCnt(Long menuId) {
|
||||||
if (menuId != null) {
|
if (menuId != null) {
|
||||||
long count = systemMenuMapper.countMenuByPid(menuId);
|
long count = this.countMenuByPid(menuId);
|
||||||
systemMenuMapper.updateMenuSubCntByMenuId(count, menuId);
|
LambdaUpdateWrapper<SystemMenuTb> wrapper = new LambdaUpdateWrapper<>();
|
||||||
|
wrapper.eq(SystemMenuTb::getId, menuId);
|
||||||
|
wrapper.set(SystemMenuTb::getSubCount, count);
|
||||||
|
systemMenuMapper.update(wrapper);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -237,7 +241,7 @@ public class SystemMenuService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return systemMenuMapper.selectMenuByArgs(criteria);
|
return this.queryMenuByArgs(criteria);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -262,7 +266,7 @@ public class SystemMenuService {
|
|||||||
public Set<SystemMenuTb> queryChildMenu(List<SystemMenuTb> menuList, Set<SystemMenuTb> menuSet) {
|
public Set<SystemMenuTb> queryChildMenu(List<SystemMenuTb> menuList, Set<SystemMenuTb> menuSet) {
|
||||||
for (SystemMenuTb menu : menuList) {
|
for (SystemMenuTb menu : menuList) {
|
||||||
menuSet.add(menu);
|
menuSet.add(menu);
|
||||||
List<SystemMenuTb> menus = systemMenuMapper.selectMenuByPid(menu.getId());
|
List<SystemMenuTb> menus = this.getMenuByPid(menu.getId());
|
||||||
if (CollUtil.isNotEmpty(menus)) {
|
if (CollUtil.isNotEmpty(menus)) {
|
||||||
queryChildMenu(menus, menuSet);
|
queryChildMenu(menus, menuSet);
|
||||||
}
|
}
|
||||||
@@ -279,9 +283,9 @@ public class SystemMenuService {
|
|||||||
public List<SystemMenuTb> queryMenuByPid(Long pid) {
|
public List<SystemMenuTb> queryMenuByPid(Long pid) {
|
||||||
List<SystemMenuTb> menus;
|
List<SystemMenuTb> menus;
|
||||||
if (pid != null && !pid.equals(0L)) {
|
if (pid != null && !pid.equals(0L)) {
|
||||||
menus = systemMenuMapper.selectMenuByPid(pid);
|
menus = this.getMenuByPid(pid);
|
||||||
} else {
|
} else {
|
||||||
menus = systemMenuMapper.selectMenuByPidIsNull();
|
menus = this.listRootMenu();
|
||||||
}
|
}
|
||||||
return menus;
|
return menus;
|
||||||
}
|
}
|
||||||
@@ -295,10 +299,10 @@ public class SystemMenuService {
|
|||||||
*/
|
*/
|
||||||
public List<SystemMenuTb> querySuperiorMenuList(SystemMenuTb menu, List<SystemMenuTb> menus) {
|
public List<SystemMenuTb> querySuperiorMenuList(SystemMenuTb menu, List<SystemMenuTb> menus) {
|
||||||
if (menu.getPid() == null) {
|
if (menu.getPid() == null) {
|
||||||
menus.addAll(systemMenuMapper.selectMenuByPidIsNull());
|
menus.addAll(this.listRootMenu());
|
||||||
return menus;
|
return menus;
|
||||||
}
|
}
|
||||||
menus.addAll(systemMenuMapper.selectMenuByPid(menu.getPid()));
|
menus.addAll(this.getMenuByPid(menu.getPid()));
|
||||||
return querySuperiorMenuList(systemMenuMapper.selectById(menu.getPid()), menus);
|
return querySuperiorMenuList(systemMenuMapper.selectById(menu.getPid()), menus);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -401,7 +405,57 @@ public class SystemMenuService {
|
|||||||
return menuVo1;
|
return menuVo1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<SystemMenuTb> queryMenuByIds(List<Long> ids) {
|
public List<SystemMenuTb> listMenuByIds(List<Long> ids) {
|
||||||
return systemMenuMapper.selectByIds(ids);
|
return systemMenuMapper.selectByIds(ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private SystemMenuTb getMenuByComponentName(String componentName) {
|
||||||
|
LambdaQueryWrapper<SystemMenuTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.eq(SystemMenuTb::getComponentName, componentName);
|
||||||
|
return systemMenuMapper.selectOne(wrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
private SystemMenuTb getMenuByTitle(String title) {
|
||||||
|
LambdaQueryWrapper<SystemMenuTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.eq(SystemMenuTb::getTitle, title);
|
||||||
|
return systemMenuMapper.selectOne(wrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Long countMenuByPid(Long pid) {
|
||||||
|
LambdaQueryWrapper<SystemMenuTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.eq(SystemMenuTb::getPid, pid);
|
||||||
|
return systemMenuMapper.selectCount(wrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<SystemMenuTb> queryMenuByArgs(SystemQueryMenuArgs criteria) {
|
||||||
|
LambdaQueryWrapper<SystemMenuTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
if (criteria != null) {
|
||||||
|
wrapper.isNull(criteria.getPidIsNull() != null, SystemMenuTb::getPid);
|
||||||
|
wrapper.eq(criteria.getPid() != null, SystemMenuTb::getPid, criteria.getPid());
|
||||||
|
wrapper.and(StrUtil.isNotBlank(criteria.getBlurry()),
|
||||||
|
c -> c.like(SystemMenuTb::getTitle, criteria.getBlurry()).or()
|
||||||
|
.like(SystemMenuTb::getComponentName, criteria.getBlurry()).or()
|
||||||
|
.like(SystemMenuTb::getPermission, criteria.getBlurry()));
|
||||||
|
if (CollUtil.isNotEmpty(criteria.getCreateTime()) && criteria.getCreateTime().size() >= 2) {
|
||||||
|
wrapper.between(SystemMenuTb::getCreateTime, criteria.getCreateTime().get(0),
|
||||||
|
criteria.getCreateTime().get(1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
wrapper.orderByAsc(SystemMenuTb::getMenuSort);
|
||||||
|
return systemMenuMapper.selectList(wrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<SystemMenuTb> getMenuByPid(Long pid) {
|
||||||
|
LambdaQueryWrapper<SystemMenuTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.eq(SystemMenuTb::getPid, pid);
|
||||||
|
wrapper.orderByAsc(SystemMenuTb::getMenuSort);
|
||||||
|
return systemMenuMapper.selectList(wrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<SystemMenuTb> listRootMenu() {
|
||||||
|
LambdaQueryWrapper<SystemMenuTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.isNull(SystemMenuTb::getPid);
|
||||||
|
wrapper.orderByAsc(SystemMenuTb::getMenuSort);
|
||||||
|
return systemMenuMapper.selectList(wrapper);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -28,7 +28,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* OSS存储 服务类
|
* OSS存储接口
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @author codegen
|
* @author codegen
|
||||||
|
|||||||
+1
-1
@@ -78,7 +78,7 @@ public class SystemQuartzJobService {
|
|||||||
* @param args /
|
* @param args /
|
||||||
*/
|
*/
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void modifyQuartzJobResumeCron(SystemUpdateQuartzJobArgs args) {
|
public void updateQuartzJobResumeCron(SystemUpdateQuartzJobArgs args) {
|
||||||
if (!CronExpression.isValidExpression(args.getCronExpression())) {
|
if (!CronExpression.isValidExpression(args.getCronExpression())) {
|
||||||
throw new BadRequestException("cron表达式格式错误");
|
throw new BadRequestException("cron表达式格式错误");
|
||||||
}
|
}
|
||||||
|
|||||||
+31
-18
@@ -21,21 +21,20 @@ import cn.hutool.core.collection.CollectionUtil;
|
|||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.odboy.base.KitPageResult;
|
import cn.odboy.base.KitPageResult;
|
||||||
import cn.odboy.framework.exception.BadRequestException;
|
import cn.odboy.framework.exception.BadRequestException;
|
||||||
import cn.odboy.system.dal.dataobject.SystemMenuTb;
|
|
||||||
import cn.odboy.system.dal.dataobject.SystemRoleTb;
|
|
||||||
import cn.odboy.system.dal.dataobject.SystemUserTb;
|
|
||||||
import cn.odboy.system.dal.dataobject.SystemRoleMenuTb;
|
|
||||||
import cn.odboy.system.dal.dataobject.SystemRoleDeptTb;
|
|
||||||
import cn.odboy.system.dal.dataobject.SystemUserRoleTb;
|
|
||||||
import cn.odboy.system.dal.dataobject.SystemDeptTb;
|
import cn.odboy.system.dal.dataobject.SystemDeptTb;
|
||||||
|
import cn.odboy.system.dal.dataobject.SystemMenuTb;
|
||||||
|
import cn.odboy.system.dal.dataobject.SystemRoleDeptTb;
|
||||||
|
import cn.odboy.system.dal.dataobject.SystemRoleMenuTb;
|
||||||
|
import cn.odboy.system.dal.dataobject.SystemRoleTb;
|
||||||
|
import cn.odboy.system.dal.dataobject.SystemUserRoleTb;
|
||||||
|
import cn.odboy.system.dal.dataobject.SystemUserTb;
|
||||||
import cn.odboy.system.dal.model.SystemCreateRoleArgs;
|
import cn.odboy.system.dal.model.SystemCreateRoleArgs;
|
||||||
import cn.odboy.system.dal.model.SystemQueryRoleArgs;
|
import cn.odboy.system.dal.model.SystemQueryRoleArgs;
|
||||||
import cn.odboy.system.dal.model.SystemRoleCodeVo;
|
import cn.odboy.system.dal.model.SystemRoleCodeVo;
|
||||||
import cn.odboy.system.dal.model.SystemRoleVo;
|
import cn.odboy.system.dal.model.SystemRoleVo;
|
||||||
import cn.odboy.system.dal.mysql.SystemRoleMapper;
|
|
||||||
import cn.odboy.system.dal.mysql.SystemUserMapper;
|
|
||||||
import cn.odboy.system.dal.mysql.SystemRoleMenuMapper;
|
|
||||||
import cn.odboy.system.dal.mysql.SystemRoleDeptMapper;
|
import cn.odboy.system.dal.mysql.SystemRoleDeptMapper;
|
||||||
|
import cn.odboy.system.dal.mysql.SystemRoleMapper;
|
||||||
|
import cn.odboy.system.dal.mysql.SystemRoleMenuMapper;
|
||||||
import cn.odboy.system.dal.mysql.SystemUserRoleMapper;
|
import cn.odboy.system.dal.mysql.SystemUserRoleMapper;
|
||||||
import cn.odboy.util.KitFileUtil;
|
import cn.odboy.util.KitFileUtil;
|
||||||
import cn.odboy.util.KitPageUtil;
|
import cn.odboy.util.KitPageUtil;
|
||||||
@@ -64,8 +63,6 @@ public class SystemRoleService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private SystemRoleMenuService systemRoleMenuService;
|
private SystemRoleMenuService systemRoleMenuService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private SystemUserMapper systemUserMapper;
|
|
||||||
@Autowired
|
|
||||||
private SystemRoleDeptService systemRoleDeptService;
|
private SystemRoleDeptService systemRoleDeptService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private SystemRoleMenuMapper systemRoleMenuMapper;
|
private SystemRoleMenuMapper systemRoleMenuMapper;
|
||||||
@@ -73,6 +70,8 @@ public class SystemRoleService {
|
|||||||
private SystemRoleDeptMapper systemRoleDeptMapper;
|
private SystemRoleDeptMapper systemRoleDeptMapper;
|
||||||
@Autowired
|
@Autowired
|
||||||
private SystemUserRoleMapper systemUserRoleMapper;
|
private SystemUserRoleMapper systemUserRoleMapper;
|
||||||
|
@Autowired
|
||||||
|
private SystemUserService systemUserService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建
|
* 创建
|
||||||
@@ -103,7 +102,7 @@ public class SystemRoleService {
|
|||||||
* @param args /
|
* @param args /
|
||||||
*/
|
*/
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void modifyRoleById(SystemRoleVo args) {
|
public void updateRoleById(SystemRoleVo args) {
|
||||||
SystemRoleVo role = BeanUtil.copyProperties(systemRoleMapper.selectById(args.getId()), SystemRoleVo.class);
|
SystemRoleVo role = BeanUtil.copyProperties(systemRoleMapper.selectById(args.getId()), SystemRoleVo.class);
|
||||||
SystemRoleTb role1 = this.getRoleByName(args.getName());
|
SystemRoleTb role1 = this.getRoleByName(args.getName());
|
||||||
if (role1 != null && !role1.getId().equals(role.getId())) {
|
if (role1 != null && !role1.getId().equals(role.getId())) {
|
||||||
@@ -129,7 +128,7 @@ public class SystemRoleService {
|
|||||||
*
|
*
|
||||||
* @param role /
|
* @param role /
|
||||||
*/
|
*/
|
||||||
public void modifyBindMenuById(SystemRoleVo role) {
|
public void updateBindMenuById(SystemRoleVo role) {
|
||||||
// 更新菜单
|
// 更新菜单
|
||||||
systemRoleMenuService.deleteRoleMenuByRoleId(role.getId());
|
systemRoleMenuService.deleteRoleMenuByRoleId(role.getId());
|
||||||
// 判断是否为空
|
// 判断是否为空
|
||||||
@@ -228,7 +227,7 @@ public class SystemRoleService {
|
|||||||
public KitPageResult<SystemRoleVo> queryRoleByArgs(SystemQueryRoleArgs criteria, Page<Object> page) {
|
public KitPageResult<SystemRoleVo> queryRoleByArgs(SystemQueryRoleArgs criteria, Page<Object> page) {
|
||||||
criteria.setOffset(page.offset());
|
criteria.setOffset(page.offset());
|
||||||
List<SystemRoleVo> roles = this.queryRoleByArgs(criteria);
|
List<SystemRoleVo> roles = this.queryRoleByArgs(criteria);
|
||||||
Long total = systemRoleMapper.countRoleByArgs(criteria);
|
Long total = this.countRoleByArgs(criteria);
|
||||||
return KitPageUtil.toPage(roles, total);
|
return KitPageUtil.toPage(roles, total);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -296,7 +295,7 @@ public class SystemRoleService {
|
|||||||
* @param ids /
|
* @param ids /
|
||||||
*/
|
*/
|
||||||
public void verifyBindRelationByIds(Set<Long> ids) {
|
public void verifyBindRelationByIds(Set<Long> ids) {
|
||||||
if (systemUserMapper.countUserByRoleIds(ids) > 0) {
|
if (systemUserService.countUserByRoleIds(ids) > 0) {
|
||||||
throw new BadRequestException("所选角色存在用户关联, 请解除关联再试!");
|
throw new BadRequestException("所选角色存在用户关联, 请解除关联再试!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -353,14 +352,14 @@ public class SystemRoleService {
|
|||||||
* @param deptIds 部门ID集合
|
* @param deptIds 部门ID集合
|
||||||
* @return /
|
* @return /
|
||||||
*/
|
*/
|
||||||
public Integer countRoleByDeptIds(Set<Long> deptIds) {
|
public Long countRoleByDeptIds(Set<Long> deptIds) {
|
||||||
if (CollUtil.isEmpty(deptIds)) {
|
if (CollUtil.isEmpty(deptIds)) {
|
||||||
return 0;
|
return 0L;
|
||||||
}
|
}
|
||||||
|
|
||||||
LambdaQueryWrapper<SystemRoleDeptTb> wrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<SystemRoleDeptTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
wrapper.in(SystemRoleDeptTb::getDeptId, deptIds);
|
wrapper.in(SystemRoleDeptTb::getDeptId, deptIds);
|
||||||
return systemRoleDeptMapper.selectCount(wrapper).intValue();
|
return systemRoleDeptMapper.selectCount(wrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -387,4 +386,18 @@ public class SystemRoleService {
|
|||||||
|
|
||||||
return roleVo;
|
return roleVo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Long countRoleByArgs(SystemQueryRoleArgs criteria) {
|
||||||
|
LambdaQueryWrapper<SystemRoleTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
if (criteria != null) {
|
||||||
|
wrapper.and(StrUtil.isNotBlank(criteria.getBlurry()),
|
||||||
|
c -> c.like(SystemRoleTb::getName, criteria.getBlurry()).or()
|
||||||
|
.like(SystemRoleTb::getDescription, criteria.getBlurry()));
|
||||||
|
if (CollUtil.isNotEmpty(criteria.getCreateTime()) && criteria.getCreateTime().size() >= 2) {
|
||||||
|
wrapper.between(SystemRoleTb::getCreateTime, criteria.getCreateTime().get(0),
|
||||||
|
criteria.getCreateTime().get(1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return systemRoleMapper.selectCount(wrapper);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+45
-30
@@ -31,12 +31,12 @@ import cn.odboy.system.dal.dataobject.SystemUserRoleTb;
|
|||||||
import cn.odboy.system.dal.dataobject.SystemUserTb;
|
import cn.odboy.system.dal.dataobject.SystemUserTb;
|
||||||
import cn.odboy.system.dal.model.SystemQueryUserArgs;
|
import cn.odboy.system.dal.model.SystemQueryUserArgs;
|
||||||
import cn.odboy.system.dal.model.SystemUserVo;
|
import cn.odboy.system.dal.model.SystemUserVo;
|
||||||
import cn.odboy.system.dal.mysql.SystemUserMapper;
|
import cn.odboy.system.dal.mysql.SystemDeptMapper;
|
||||||
import cn.odboy.system.dal.mysql.SystemUserJobMapper;
|
|
||||||
import cn.odboy.system.dal.mysql.SystemUserRoleMapper;
|
|
||||||
import cn.odboy.system.dal.mysql.SystemJobMapper;
|
import cn.odboy.system.dal.mysql.SystemJobMapper;
|
||||||
import cn.odboy.system.dal.mysql.SystemRoleMapper;
|
import cn.odboy.system.dal.mysql.SystemRoleMapper;
|
||||||
import cn.odboy.system.dal.mysql.SystemDeptMapper;
|
import cn.odboy.system.dal.mysql.SystemUserJobMapper;
|
||||||
|
import cn.odboy.system.dal.mysql.SystemUserMapper;
|
||||||
|
import cn.odboy.system.dal.mysql.SystemUserRoleMapper;
|
||||||
import cn.odboy.system.dal.redis.SystemUserInfoDAO;
|
import cn.odboy.system.dal.redis.SystemUserInfoDAO;
|
||||||
import cn.odboy.system.dal.redis.SystemUserOnlineInfoDAO;
|
import cn.odboy.system.dal.redis.SystemUserOnlineInfoDAO;
|
||||||
import cn.odboy.system.framework.permission.core.KitSecurityHelper;
|
import cn.odboy.system.framework.permission.core.KitSecurityHelper;
|
||||||
@@ -97,13 +97,13 @@ public class SystemUserService {
|
|||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void saveUser(SystemUserVo args) {
|
public void saveUser(SystemUserVo args) {
|
||||||
args.setDeptId(args.getDept().getId());
|
args.setDeptId(args.getDept().getId());
|
||||||
if (systemUserMapper.getUserByUsername(args.getUsername()) != null) {
|
if (this.getUserByUsername(args.getUsername()) != null) {
|
||||||
throw new BadRequestException("用户名已存在");
|
throw new BadRequestException("用户名已存在");
|
||||||
}
|
}
|
||||||
if (systemUserMapper.getUserByEmail(args.getEmail()) != null) {
|
if (this.getUserByEmail(args.getEmail()) != null) {
|
||||||
throw new BadRequestException("邮箱已存在");
|
throw new BadRequestException("邮箱已存在");
|
||||||
}
|
}
|
||||||
if (systemUserMapper.getUserByPhone(args.getPhone()) != null) {
|
if (this.getUserByPhone(args.getPhone()) != null) {
|
||||||
throw new BadRequestException("手机号已存在");
|
throw new BadRequestException("手机号已存在");
|
||||||
}
|
}
|
||||||
systemUserMapper.insert(args);
|
systemUserMapper.insert(args);
|
||||||
@@ -120,11 +120,11 @@ public class SystemUserService {
|
|||||||
* @throws Exception /
|
* @throws Exception /
|
||||||
*/
|
*/
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void modifyUserById(SystemUserVo args) {
|
public void updateUserById(SystemUserVo args) {
|
||||||
SystemUserTb user = systemUserMapper.selectById(args.getId());
|
SystemUserTb user = systemUserMapper.selectById(args.getId());
|
||||||
SystemUserTb user1 = systemUserMapper.getUserByUsername(args.getUsername());
|
SystemUserTb user1 = this.getUserByUsername(args.getUsername());
|
||||||
SystemUserTb user2 = systemUserMapper.getUserByEmail(args.getEmail());
|
SystemUserTb user2 = this.getUserByEmail(args.getEmail());
|
||||||
SystemUserTb user3 = systemUserMapper.getUserByPhone(args.getPhone());
|
SystemUserTb user3 = this.getUserByPhone(args.getPhone());
|
||||||
if (user1 != null && !user.getId().equals(user1.getId())) {
|
if (user1 != null && !user.getId().equals(user1.getId())) {
|
||||||
throw new BadRequestException("用户名已存在");
|
throw new BadRequestException("用户名已存在");
|
||||||
}
|
}
|
||||||
@@ -163,9 +163,9 @@ public class SystemUserService {
|
|||||||
* @param args /
|
* @param args /
|
||||||
*/
|
*/
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void modifyUserCenterInfoById(SystemUserTb args) {
|
public void updateUserCenterInfoById(SystemUserTb args) {
|
||||||
SystemUserTb user = systemUserMapper.selectById(args.getId());
|
SystemUserTb user = systemUserMapper.selectById(args.getId());
|
||||||
SystemUserTb user1 = systemUserMapper.getUserByPhone(args.getPhone());
|
SystemUserTb user1 = this.getUserByPhone(args.getPhone());
|
||||||
if (user1 != null && !user.getId().equals(user1.getId())) {
|
if (user1 != null && !user.getId().equals(user1.getId())) {
|
||||||
throw new BadRequestException("手机号已存在");
|
throw new BadRequestException("手机号已存在");
|
||||||
}
|
}
|
||||||
@@ -202,7 +202,7 @@ public class SystemUserService {
|
|||||||
* @param encryptPassword 密码
|
* @param encryptPassword 密码
|
||||||
*/
|
*/
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void modifyUserPasswordByUsername(String username, String encryptPassword) {
|
public void updateUserPasswordByUsername(String username, String encryptPassword) {
|
||||||
systemUserMapper.updateUserPasswordByUsername(username, encryptPassword);
|
systemUserMapper.updateUserPasswordByUsername(username, encryptPassword);
|
||||||
systemUserInfoDAO.deleteUserLoginInfoByUserName(username);
|
systemUserInfoDAO.deleteUserLoginInfoByUserName(username);
|
||||||
}
|
}
|
||||||
@@ -234,8 +234,8 @@ public class SystemUserService {
|
|||||||
* @return /
|
* @return /
|
||||||
*/
|
*/
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public Map<String, String> modifyUserAvatar(MultipartFile multipartFile) {
|
public Map<String, String> updateUserAvatar(MultipartFile multipartFile) {
|
||||||
SystemUserTb user = systemUserMapper.getUserByUsername(KitSecurityHelper.getCurrentUsername());
|
SystemUserTb user = this.getUserByUsername(KitSecurityHelper.getCurrentUsername());
|
||||||
String username = user.getUsername();
|
String username = user.getUsername();
|
||||||
if (StrUtil.isBlank(username)) {
|
if (StrUtil.isBlank(username)) {
|
||||||
throw new BadRequestException("异常用户数据, 请联系管理员处理");
|
throw new BadRequestException("异常用户数据, 请联系管理员处理");
|
||||||
@@ -269,7 +269,7 @@ public class SystemUserService {
|
|||||||
* @param email 邮箱
|
* @param email 邮箱
|
||||||
*/
|
*/
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void modifyUserEmailByUsername(String username, String email) {
|
public void updateUserEmailByUsername(String username, String email) {
|
||||||
systemUserMapper.updateUserEmailByUsername(username, email);
|
systemUserMapper.updateUserEmailByUsername(username, email);
|
||||||
systemUserInfoDAO.deleteUserLoginInfoByUserName(username);
|
systemUserInfoDAO.deleteUserLoginInfoByUserName(username);
|
||||||
}
|
}
|
||||||
@@ -344,16 +344,6 @@ public class SystemUserService {
|
|||||||
return systemUserMapper.selectById(id);
|
return systemUserMapper.selectById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据用户名查询
|
|
||||||
*
|
|
||||||
* @param username /
|
|
||||||
* @return /
|
|
||||||
*/
|
|
||||||
public SystemUserTb getUserByUsername(String username) {
|
|
||||||
return systemUserMapper.getUserByUsername(username);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<KitSelectOptionVo> queryUserMetadataOptions(KitPageArgs<SystemQueryUserArgs> args) {
|
public List<KitSelectOptionVo> queryUserMetadataOptions(KitPageArgs<SystemQueryUserArgs> args) {
|
||||||
SystemQueryUserArgs criteria = args.getArgs();
|
SystemQueryUserArgs criteria = args.getArgs();
|
||||||
LambdaQueryWrapper<SystemUserTb> wrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<SystemUserTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
@@ -439,7 +429,6 @@ public class SystemUserService {
|
|||||||
if (CollUtil.isEmpty(jobIds)) {
|
if (CollUtil.isEmpty(jobIds)) {
|
||||||
return 0L;
|
return 0L;
|
||||||
}
|
}
|
||||||
|
|
||||||
LambdaQueryWrapper<SystemUserJobTb> wrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<SystemUserJobTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
wrapper.in(SystemUserJobTb::getJobId, jobIds);
|
wrapper.in(SystemUserJobTb::getJobId, jobIds);
|
||||||
return systemUserJobMapper.selectCount(wrapper);
|
return systemUserJobMapper.selectCount(wrapper);
|
||||||
@@ -455,7 +444,6 @@ public class SystemUserService {
|
|||||||
if (CollUtil.isEmpty(roleIds)) {
|
if (CollUtil.isEmpty(roleIds)) {
|
||||||
return 0L;
|
return 0L;
|
||||||
}
|
}
|
||||||
|
|
||||||
LambdaQueryWrapper<SystemUserRoleTb> wrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<SystemUserRoleTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
wrapper.in(SystemUserRoleTb::getRoleId, roleIds);
|
wrapper.in(SystemUserRoleTb::getRoleId, roleIds);
|
||||||
return systemUserRoleMapper.selectCount(wrapper);
|
return systemUserRoleMapper.selectCount(wrapper);
|
||||||
@@ -468,7 +456,7 @@ public class SystemUserService {
|
|||||||
* @return /
|
* @return /
|
||||||
*/
|
*/
|
||||||
public SystemUserVo getUserVoByUsername(String username) {
|
public SystemUserVo getUserVoByUsername(String username) {
|
||||||
SystemUserTb user = systemUserMapper.getUserByUsername(username);
|
SystemUserTb user = this.getUserByUsername(username);
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -547,4 +535,31 @@ public class SystemUserService {
|
|||||||
|
|
||||||
return userVo;
|
return userVo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SystemUserTb getUserByUsername(String username) {
|
||||||
|
LambdaQueryWrapper<SystemUserTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.eq(SystemUserTb::getUsername, username);
|
||||||
|
wrapper.eq(SystemUserTb::getEnabled, 1);
|
||||||
|
return systemUserMapper.selectOne(wrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
public long countUserByDeptIds(Set<Long> deptIds) {
|
||||||
|
LambdaQueryWrapper<SystemUserTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.in(SystemUserTb::getDeptId, deptIds);
|
||||||
|
return systemUserMapper.selectCount(wrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SystemUserTb getUserByEmail(String email) {
|
||||||
|
LambdaQueryWrapper<SystemUserTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.eq(SystemUserTb::getEmail, email);
|
||||||
|
wrapper.eq(SystemUserTb::getEnabled, 1);
|
||||||
|
return systemUserMapper.selectOne(wrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SystemUserTb getUserByPhone(String phone) {
|
||||||
|
LambdaQueryWrapper<SystemUserTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.eq(SystemUserTb::getPhone, phone);
|
||||||
|
wrapper.eq(SystemUserTb::getEnabled, 1);
|
||||||
|
return systemUserMapper.selectOne(wrapper);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
package cn.odboy;
|
package cn.odboy;
|
||||||
|
|
||||||
import cn.odboy.framework.monitor.service.KitHealthCheckPointService;
|
import cn.odboy.framework.monitor.service.KitHealthCheckPointService;
|
||||||
import cn.odboy.system.service.SystemDictService;
|
import cn.odboy.system.dal.mysql.SystemDictMapper;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
@@ -25,7 +25,7 @@ import org.springframework.stereotype.Component;
|
|||||||
public class HealthCheckPointer implements KitHealthCheckPointService {
|
public class HealthCheckPointer implements KitHealthCheckPointService {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private SystemDictService systemDictService;
|
private SystemDictMapper systemDictMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 系统准备就绪
|
* 系统准备就绪
|
||||||
@@ -40,6 +40,6 @@ public class HealthCheckPointer implements KitHealthCheckPointService {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public ResponseEntity<?> doLiveness() {
|
public ResponseEntity<?> doLiveness() {
|
||||||
return ResponseEntity.ok(systemDictService.getById(1));
|
return ResponseEntity.ok(systemDictMapper.selectById(1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user