refactor(cutejava-system):重构系统模块代码
- 更新了多个控制器、Mapper接口和Redis DAO的命名 - 优化了部分方法名称,提高了代码可读性 - 移除了冗余代码,简化了部分逻辑
This commit is contained in:
+7
-10
@@ -13,20 +13,17 @@ https://github.com/odboy-tianjun/cutejava
|
|||||||
#### 编码规范
|
#### 编码规范
|
||||||
|
|
||||||
- 和数据库表一一对应的类, 以`Tb`结尾
|
- 和数据库表一一对应的类, 以`Tb`结尾
|
||||||
- 前端请求参数类名, 以`Args`结尾
|
- API请求参数类名, 以`Args`结尾
|
||||||
- 返回给前端的数据类名, 以`Vo`结尾
|
- API响应参数类名, 以`Vo`结尾
|
||||||
- 事件驱动类名,以`Event`结尾
|
- 事件驱动类名,以`Event`结尾
|
||||||
- 消息队列/Socket传输类名,以`Message`结尾
|
- 消息队列/Socket传输类名,以`Message`结尾
|
||||||
- 原框架以外的所有辅助类的类名, 以`Cs`开头
|
- 常用的辅助类的类名, 以`Cs`开头
|
||||||
- 查询分页、查询列表的方法,一律为同一个方法名
|
- 查询分页、查询列表的方法,一律为同一个方法名
|
||||||
- 查询分页:queryUserListByArgs(args, page)
|
- 查询分页:queryUser(args, page)
|
||||||
- 查询列表:queryUserListByArgs(args)
|
- 查询列表:queryUser(args)
|
||||||
- MapperXml:这样mapper.xml文件中的实现方法只需要写一个queryUserListByArgs
|
- MapperXml:这样mapper.xml文件中的实现方法只需要写一个queryUser
|
||||||
- Mapper层查询方法,统一使用以下命名规则
|
|
||||||
- 分页、列表:query{TableName}ListByArgs
|
|
||||||
- 精确查询:get{TableName}{By FieldName}
|
|
||||||
- 统计数量:get{具体语义}Count{By FieldName}
|
|
||||||
- 枚举类名,以`Enum`结尾
|
- 枚举类名,以`Enum`结尾
|
||||||
|
- 拒绝过度包装
|
||||||
|
|
||||||
#### 主要特性
|
#### 主要特性
|
||||||
|
|
||||||
|
|||||||
+4
-4
@@ -5,7 +5,7 @@ import cn.odboy.core.dal.dataobject.system.SystemDeptTb;
|
|||||||
import cn.odboy.core.dal.model.system.CreateSystemDeptArgs;
|
import cn.odboy.core.dal.model.system.CreateSystemDeptArgs;
|
||||||
import cn.odboy.core.dal.model.system.QuerySystemDeptArgs;
|
import cn.odboy.core.dal.model.system.QuerySystemDeptArgs;
|
||||||
import cn.odboy.core.service.system.SystemDeptService;
|
import cn.odboy.core.service.system.SystemDeptService;
|
||||||
import cn.odboy.util.PageUtil;
|
import cn.odboy.util.CsPageUtil;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
@@ -33,15 +33,15 @@ public class SystemDeptController {
|
|||||||
@GetMapping(value = "/download")
|
@GetMapping(value = "/download")
|
||||||
@PreAuthorize("@el.check('dept:list')")
|
@PreAuthorize("@el.check('dept:list')")
|
||||||
public void exportDept(HttpServletResponse response, QuerySystemDeptArgs criteria) throws Exception {
|
public void exportDept(HttpServletResponse response, QuerySystemDeptArgs criteria) throws Exception {
|
||||||
systemDeptService.downloadDeptExcel(systemDeptService.queryDeptList(criteria, false), response);
|
systemDeptService.exportDeptExcel(systemDeptService.queryAllDept(criteria, false), response);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("查询部门")
|
@ApiOperation("查询部门")
|
||||||
@GetMapping
|
@GetMapping
|
||||||
@PreAuthorize("@el.check('user:list','dept:list')")
|
@PreAuthorize("@el.check('user:list','dept:list')")
|
||||||
public ResponseEntity<CsResultVo<List<SystemDeptTb>>> queryDeptPage(QuerySystemDeptArgs criteria) throws Exception {
|
public ResponseEntity<CsResultVo<List<SystemDeptTb>>> queryDeptPage(QuerySystemDeptArgs criteria) throws Exception {
|
||||||
List<SystemDeptTb> depts = systemDeptService.queryDeptList(criteria, true);
|
List<SystemDeptTb> depts = systemDeptService.queryAllDept(criteria, true);
|
||||||
return new ResponseEntity<>(PageUtil.toPage(depts), HttpStatus.OK);
|
return new ResponseEntity<>(CsPageUtil.toPage(depts), HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("查询部门:根据ID获取同级与上级数据")
|
@ApiOperation("查询部门:根据ID获取同级与上级数据")
|
||||||
|
|||||||
+3
-3
@@ -31,14 +31,14 @@ public class SystemDictController {
|
|||||||
@GetMapping(value = "/download")
|
@GetMapping(value = "/download")
|
||||||
@PreAuthorize("@el.check('dict:list')")
|
@PreAuthorize("@el.check('dict:list')")
|
||||||
public void exportDict(HttpServletResponse response, QuerySystemDictArgs criteria) throws IOException {
|
public void exportDict(HttpServletResponse response, QuerySystemDictArgs criteria) throws IOException {
|
||||||
systemDictService.downloadDictExcel(systemDictService.queryDictList(criteria), response);
|
systemDictService.exportDictExcel(systemDictService.queryDictByArgs(criteria), response);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("查询字典")
|
@ApiOperation("查询字典")
|
||||||
@PostMapping(value = "/queryAllDict")
|
@PostMapping(value = "/queryAllDict")
|
||||||
@PreAuthorize("@el.check('dict:list')")
|
@PreAuthorize("@el.check('dict:list')")
|
||||||
public ResponseEntity<List<SystemDictTb>> queryAllDict() {
|
public ResponseEntity<List<SystemDictTb>> queryAllDict() {
|
||||||
return new ResponseEntity<>(systemDictService.queryDictList(new QuerySystemDictArgs()), HttpStatus.OK);
|
return new ResponseEntity<>(systemDictService.queryDictByArgs(new QuerySystemDictArgs()), HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("查询字典")
|
@ApiOperation("查询字典")
|
||||||
@@ -46,7 +46,7 @@ public class SystemDictController {
|
|||||||
@PreAuthorize("@el.check('dict:list')")
|
@PreAuthorize("@el.check('dict:list')")
|
||||||
public ResponseEntity<CsResultVo<List<SystemDictTb>>> queryDict(QuerySystemDictArgs criteria) {
|
public ResponseEntity<CsResultVo<List<SystemDictTb>>> queryDict(QuerySystemDictArgs criteria) {
|
||||||
Page<SystemDictTb> page = new Page<>(criteria.getPage(), criteria.getSize());
|
Page<SystemDictTb> page = new Page<>(criteria.getPage(), criteria.getSize());
|
||||||
return new ResponseEntity<>(systemDictService.queryDictPage(criteria, page), HttpStatus.OK);
|
return new ResponseEntity<>(systemDictService.queryDictByArgs(criteria, page), HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("新增字典")
|
@ApiOperation("新增字典")
|
||||||
|
|||||||
+14
-15
@@ -8,7 +8,7 @@ import cn.odboy.core.dal.model.system.SystemMenuVo;
|
|||||||
import cn.odboy.core.framework.permission.core.SecurityHelper;
|
import cn.odboy.core.framework.permission.core.SecurityHelper;
|
||||||
import cn.odboy.core.service.system.SystemMenuService;
|
import cn.odboy.core.service.system.SystemMenuService;
|
||||||
import cn.odboy.exception.BadRequestException;
|
import cn.odboy.exception.BadRequestException;
|
||||||
import cn.odboy.util.PageUtil;
|
import cn.odboy.util.CsPageUtil;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
@@ -28,14 +28,13 @@ import java.util.stream.Collectors;
|
|||||||
@Api(tags = "系统:菜单管理")
|
@Api(tags = "系统:菜单管理")
|
||||||
@RequestMapping("/api/menus")
|
@RequestMapping("/api/menus")
|
||||||
public class SystemMenuController {
|
public class SystemMenuController {
|
||||||
private static final String ENTITY_NAME = "menu";
|
|
||||||
private final SystemMenuService systemMenuService;
|
private final SystemMenuService systemMenuService;
|
||||||
|
|
||||||
@ApiOperation("导出菜单数据")
|
@ApiOperation("导出菜单数据")
|
||||||
@GetMapping(value = "/download")
|
@GetMapping(value = "/download")
|
||||||
@PreAuthorize("@el.check('menu:list')")
|
@PreAuthorize("@el.check('menu:list')")
|
||||||
public void exportMenu(HttpServletResponse response, QuerySystemMenuArgs criteria) throws Exception {
|
public void exportMenu(HttpServletResponse response, QuerySystemMenuArgs criteria) throws Exception {
|
||||||
systemMenuService.downloadMenuExcel(systemMenuService.queryMenuList(criteria, false), response);
|
systemMenuService.exportMenuExcel(systemMenuService.queryAllMenu(criteria, false), response);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping(value = "/buildMenus")
|
@PostMapping(value = "/buildMenus")
|
||||||
@@ -50,7 +49,7 @@ public class SystemMenuController {
|
|||||||
@PostMapping(value = "/queryMenuListByPid")
|
@PostMapping(value = "/queryMenuListByPid")
|
||||||
@PreAuthorize("@el.check('menu:list','roles:list')")
|
@PreAuthorize("@el.check('menu:list','roles:list')")
|
||||||
public ResponseEntity<List<SystemMenuTb>> queryMenuListByPid(@RequestParam Long pid) {
|
public ResponseEntity<List<SystemMenuTb>> queryMenuListByPid(@RequestParam Long pid) {
|
||||||
return new ResponseEntity<>(systemMenuService.queryMenuListByPid(pid), HttpStatus.OK);
|
return new ResponseEntity<>(systemMenuService.queryMenuByPid(pid), HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("根据菜单ID返回所有子节点ID,包含自身ID")
|
@ApiOperation("根据菜单ID返回所有子节点ID,包含自身ID")
|
||||||
@@ -58,9 +57,9 @@ public class SystemMenuController {
|
|||||||
@PreAuthorize("@el.check('menu:list','roles:list')")
|
@PreAuthorize("@el.check('menu:list','roles:list')")
|
||||||
public ResponseEntity<Set<Long>> queryChildMenuSet(@RequestParam Long id) {
|
public ResponseEntity<Set<Long>> queryChildMenuSet(@RequestParam Long id) {
|
||||||
Set<SystemMenuTb> menuSet = new HashSet<>();
|
Set<SystemMenuTb> menuSet = new HashSet<>();
|
||||||
List<SystemMenuTb> menuList = systemMenuService.queryMenuListByPid(id);
|
List<SystemMenuTb> menuList = systemMenuService.queryMenuByPid(id);
|
||||||
menuSet.add(systemMenuService.queryMenuById(id));
|
menuSet.add(systemMenuService.getMenuById(id));
|
||||||
menuSet = systemMenuService.queryChildMenuSet(menuList, menuSet);
|
menuSet = systemMenuService.queryChildMenu(menuList, menuSet);
|
||||||
Set<Long> ids = menuSet.stream().map(SystemMenuTb::getId).collect(Collectors.toSet());
|
Set<Long> ids = menuSet.stream().map(SystemMenuTb::getId).collect(Collectors.toSet());
|
||||||
return new ResponseEntity<>(ids, HttpStatus.OK);
|
return new ResponseEntity<>(ids, HttpStatus.OK);
|
||||||
}
|
}
|
||||||
@@ -69,8 +68,8 @@ public class SystemMenuController {
|
|||||||
@ApiOperation("查询菜单")
|
@ApiOperation("查询菜单")
|
||||||
@PreAuthorize("@el.check('menu:list')")
|
@PreAuthorize("@el.check('menu:list')")
|
||||||
public ResponseEntity<CsResultVo<List<SystemMenuTb>>> queryMenu(QuerySystemMenuArgs criteria) throws Exception {
|
public ResponseEntity<CsResultVo<List<SystemMenuTb>>> queryMenu(QuerySystemMenuArgs criteria) throws Exception {
|
||||||
List<SystemMenuTb> menuList = systemMenuService.queryMenuList(criteria, true);
|
List<SystemMenuTb> menuList = systemMenuService.queryAllMenu(criteria, true);
|
||||||
return new ResponseEntity<>(PageUtil.toPage(menuList), HttpStatus.OK);
|
return new ResponseEntity<>(CsPageUtil.toPage(menuList), HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("查询菜单:根据ID获取同级与上级数据")
|
@ApiOperation("查询菜单:根据ID获取同级与上级数据")
|
||||||
@@ -80,7 +79,7 @@ public class SystemMenuController {
|
|||||||
Set<SystemMenuTb> menus = new LinkedHashSet<>();
|
Set<SystemMenuTb> menus = new LinkedHashSet<>();
|
||||||
if (CollectionUtil.isNotEmpty(ids)) {
|
if (CollectionUtil.isNotEmpty(ids)) {
|
||||||
for (Long id : ids) {
|
for (Long id : ids) {
|
||||||
SystemMenuTb menu = systemMenuService.queryMenuById(id);
|
SystemMenuTb menu = systemMenuService.getMenuById(id);
|
||||||
List<SystemMenuTb> menuList = systemMenuService.querySuperiorMenuList(menu, new ArrayList<>());
|
List<SystemMenuTb> menuList = systemMenuService.querySuperiorMenuList(menu, new ArrayList<>());
|
||||||
for (SystemMenuTb data : menuList) {
|
for (SystemMenuTb data : menuList) {
|
||||||
if (data.getId().equals(menu.getPid())) {
|
if (data.getId().equals(menu.getPid())) {
|
||||||
@@ -93,7 +92,7 @@ public class SystemMenuController {
|
|||||||
menus = menus.stream().filter(i -> !ids.contains(i.getId())).collect(Collectors.toSet());
|
menus = menus.stream().filter(i -> !ids.contains(i.getId())).collect(Collectors.toSet());
|
||||||
return new ResponseEntity<>(systemMenuService.buildMenuTree(new ArrayList<>(menus)), HttpStatus.OK);
|
return new ResponseEntity<>(systemMenuService.buildMenuTree(new ArrayList<>(menus)), HttpStatus.OK);
|
||||||
}
|
}
|
||||||
return new ResponseEntity<>(systemMenuService.queryMenuListByPid(null), HttpStatus.OK);
|
return new ResponseEntity<>(systemMenuService.queryMenuByPid(null), HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("新增菜单")
|
@ApiOperation("新增菜单")
|
||||||
@@ -101,7 +100,7 @@ public class SystemMenuController {
|
|||||||
@PreAuthorize("@el.check('menu:add')")
|
@PreAuthorize("@el.check('menu:add')")
|
||||||
public ResponseEntity<Void> saveMenu(@Validated @RequestBody SystemMenuTb resources) {
|
public ResponseEntity<Void> saveMenu(@Validated @RequestBody SystemMenuTb resources) {
|
||||||
if (resources.getId() != null) {
|
if (resources.getId() != null) {
|
||||||
throw new BadRequestException("A new " + ENTITY_NAME + " cannot already have an ID");
|
throw new BadRequestException("无效参数id");
|
||||||
}
|
}
|
||||||
systemMenuService.saveMenu(resources);
|
systemMenuService.saveMenu(resources);
|
||||||
return new ResponseEntity<>(HttpStatus.CREATED);
|
return new ResponseEntity<>(HttpStatus.CREATED);
|
||||||
@@ -121,9 +120,9 @@ public class SystemMenuController {
|
|||||||
public ResponseEntity<Void> removeMenuByIds(@RequestBody Set<Long> ids) {
|
public ResponseEntity<Void> removeMenuByIds(@RequestBody Set<Long> ids) {
|
||||||
Set<SystemMenuTb> menuSet = new HashSet<>();
|
Set<SystemMenuTb> menuSet = new HashSet<>();
|
||||||
for (Long id : ids) {
|
for (Long id : ids) {
|
||||||
List<SystemMenuTb> menuList = systemMenuService.queryMenuListByPid(id);
|
List<SystemMenuTb> menuList = systemMenuService.queryMenuByPid(id);
|
||||||
menuSet.add(systemMenuService.queryMenuById(id));
|
menuSet.add(systemMenuService.getMenuById(id));
|
||||||
menuSet = systemMenuService.queryChildMenuSet(menuList, menuSet);
|
menuSet = systemMenuService.queryChildMenu(menuList, menuSet);
|
||||||
}
|
}
|
||||||
systemMenuService.removeMenuByIds(menuSet);
|
systemMenuService.removeMenuByIds(menuSet);
|
||||||
return new ResponseEntity<>(HttpStatus.OK);
|
return new ResponseEntity<>(HttpStatus.OK);
|
||||||
|
|||||||
+26
-25
@@ -13,7 +13,7 @@ import cn.odboy.core.framework.permission.core.SecurityHelper;
|
|||||||
import cn.odboy.core.framework.properties.AppProperties;
|
import cn.odboy.core.framework.properties.AppProperties;
|
||||||
import cn.odboy.core.service.system.*;
|
import cn.odboy.core.service.system.*;
|
||||||
import cn.odboy.exception.BadRequestException;
|
import cn.odboy.exception.BadRequestException;
|
||||||
import cn.odboy.util.PageUtil;
|
import cn.odboy.util.CsPageUtil;
|
||||||
import cn.odboy.util.RsaEncryptUtil;
|
import cn.odboy.util.RsaEncryptUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
@@ -51,8 +51,8 @@ public class SystemUserController {
|
|||||||
@ApiOperation("导出用户数据")
|
@ApiOperation("导出用户数据")
|
||||||
@GetMapping(value = "/download")
|
@GetMapping(value = "/download")
|
||||||
@PreAuthorize("@el.check('user:list')")
|
@PreAuthorize("@el.check('user:list')")
|
||||||
public void downloadUserExcel(HttpServletResponse response, QuerySystemUserArgs criteria) throws IOException {
|
public void exportUserExcel(HttpServletResponse response, QuerySystemUserArgs criteria) throws IOException {
|
||||||
systemUserService.downloadUserExcel(systemUserService.queryUserList(criteria), response);
|
systemUserService.exportUserExcel(systemUserService.queryUserByArgs(criteria), response);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("查询用户")
|
@ApiOperation("查询用户")
|
||||||
@@ -63,25 +63,25 @@ 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.queryDeptListByPid(criteria.getDeptId());
|
List<SystemDeptTb> data = systemDeptService.queryDeptByPid(criteria.getDeptId());
|
||||||
// 然后把子节点的ID都加入到集合中
|
// 然后把子节点的ID都加入到集合中
|
||||||
criteria.getDeptIds().addAll(systemDeptService.queryChildDeptIdListByDeptIds(data));
|
criteria.getDeptIds().addAll(systemDeptService.queryChildDeptIdListByDeptIds(data));
|
||||||
}
|
}
|
||||||
// 数据权限
|
// 数据权限
|
||||||
List<Long> dataScopes = systemDataService.queryDeptIdListByArgs(systemUserService.queryUserByUsername(SecurityHelper.getCurrentUsername()));
|
List<Long> dataScopes = systemDataService.queryDeptIdListByArgs(systemUserService.getUserByUsername(SecurityHelper.getCurrentUsername()));
|
||||||
// criteria.getDeptIds() 不为空并且数据权限不为空则取交集
|
// criteria.getDeptIds() 不为空并且数据权限不为空则取交集
|
||||||
if (!CollectionUtils.isEmpty(criteria.getDeptIds()) && !CollectionUtils.isEmpty(dataScopes)) {
|
if (!CollectionUtils.isEmpty(criteria.getDeptIds()) && !CollectionUtils.isEmpty(dataScopes)) {
|
||||||
// 取交集
|
// 取交集
|
||||||
criteria.getDeptIds().retainAll(dataScopes);
|
criteria.getDeptIds().retainAll(dataScopes);
|
||||||
if (!CollectionUtil.isEmpty(criteria.getDeptIds())) {
|
if (!CollectionUtil.isEmpty(criteria.getDeptIds())) {
|
||||||
return new ResponseEntity<>(systemUserService.queryUserPage(criteria, page), HttpStatus.OK);
|
return new ResponseEntity<>(systemUserService.queryUserByArgs(criteria, page), HttpStatus.OK);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// 否则取并集
|
// 否则取并集
|
||||||
criteria.getDeptIds().addAll(dataScopes);
|
criteria.getDeptIds().addAll(dataScopes);
|
||||||
return new ResponseEntity<>(systemUserService.queryUserPage(criteria, page), HttpStatus.OK);
|
return new ResponseEntity<>(systemUserService.queryUserByArgs(criteria, page), HttpStatus.OK);
|
||||||
}
|
}
|
||||||
return new ResponseEntity<>(PageUtil.emptyData(), HttpStatus.OK);
|
return new ResponseEntity<>(CsPageUtil.emptyData(), HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("新增用户")
|
@ApiOperation("新增用户")
|
||||||
@@ -119,10 +119,10 @@ public class SystemUserController {
|
|||||||
@PreAuthorize("@el.check('user:del')")
|
@PreAuthorize("@el.check('user:del')")
|
||||||
public ResponseEntity<Object> removeUserByIds(@RequestBody Set<Long> ids) {
|
public ResponseEntity<Object> removeUserByIds(@RequestBody Set<Long> ids) {
|
||||||
for (Long id : ids) {
|
for (Long id : ids) {
|
||||||
Integer currentLevel = Collections.min(systemRoleService.queryRoleListByUsersId(SecurityHelper.getCurrentUserId()).stream().map(SystemRoleTb::getLevel).collect(Collectors.toList()));
|
Integer currentLevel = Collections.min(systemRoleService.queryRoleByUsersId(SecurityHelper.getCurrentUserId()).stream().map(SystemRoleTb::getLevel).collect(Collectors.toList()));
|
||||||
Integer optLevel = Collections.min(systemRoleService.queryRoleListByUsersId(id).stream().map(SystemRoleTb::getLevel).collect(Collectors.toList()));
|
Integer optLevel = Collections.min(systemRoleService.queryRoleByUsersId(id).stream().map(SystemRoleTb::getLevel).collect(Collectors.toList()));
|
||||||
if (currentLevel > optLevel) {
|
if (currentLevel > optLevel) {
|
||||||
throw new BadRequestException("角色权限不足,不能删除:" + systemUserService.queryUserById(id).getUsername());
|
throw new BadRequestException("角色权限不足,不能删除:" + systemUserService.getUserById(id).getUsername());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
systemUserService.removeUserByIds(ids);
|
systemUserService.removeUserByIds(ids);
|
||||||
@@ -134,7 +134,7 @@ public class SystemUserController {
|
|||||||
public ResponseEntity<Object> modifyUserPasswordByUsername(@RequestBody UpdateSystemUserPasswordArgs passVo) throws Exception {
|
public ResponseEntity<Object> modifyUserPasswordByUsername(@RequestBody UpdateSystemUserPasswordArgs passVo) throws Exception {
|
||||||
String oldPass = RsaEncryptUtil.decryptByPrivateKey(properties.getRsa().getPrivateKey(), passVo.getOldPass());
|
String oldPass = RsaEncryptUtil.decryptByPrivateKey(properties.getRsa().getPrivateKey(), passVo.getOldPass());
|
||||||
String newPass = RsaEncryptUtil.decryptByPrivateKey(properties.getRsa().getPrivateKey(), passVo.getNewPass());
|
String newPass = RsaEncryptUtil.decryptByPrivateKey(properties.getRsa().getPrivateKey(), passVo.getNewPass());
|
||||||
SystemUserTb user = systemUserService.queryUserByUsername(SecurityHelper.getCurrentUsername());
|
SystemUserTb user = systemUserService.getUserByUsername(SecurityHelper.getCurrentUsername());
|
||||||
if (!passwordEncoder.matches(oldPass, user.getPassword())) {
|
if (!passwordEncoder.matches(oldPass, user.getPassword())) {
|
||||||
throw new BadRequestException("修改失败,旧密码错误");
|
throw new BadRequestException("修改失败,旧密码错误");
|
||||||
}
|
}
|
||||||
@@ -163,7 +163,7 @@ public class SystemUserController {
|
|||||||
@PostMapping(value = "/modifyUserEmailByUsername/{code}")
|
@PostMapping(value = "/modifyUserEmailByUsername/{code}")
|
||||||
public ResponseEntity<Object> modifyUserEmailByUsername(@PathVariable String code, @RequestBody SystemUserTb resources) throws Exception {
|
public ResponseEntity<Object> modifyUserEmailByUsername(@PathVariable String code, @RequestBody SystemUserTb resources) throws Exception {
|
||||||
String password = RsaEncryptUtil.decryptByPrivateKey(properties.getRsa().getPrivateKey(), resources.getPassword());
|
String password = RsaEncryptUtil.decryptByPrivateKey(properties.getRsa().getPrivateKey(), resources.getPassword());
|
||||||
SystemUserTb user = systemUserService.queryUserByUsername(SecurityHelper.getCurrentUsername());
|
SystemUserTb user = systemUserService.getUserByUsername(SecurityHelper.getCurrentUsername());
|
||||||
if (!passwordEncoder.matches(password, user.getPassword())) {
|
if (!passwordEncoder.matches(password, user.getPassword())) {
|
||||||
throw new BadRequestException("密码错误");
|
throw new BadRequestException("密码错误");
|
||||||
}
|
}
|
||||||
@@ -178,8 +178,8 @@ public class SystemUserController {
|
|||||||
* @param resources /
|
* @param resources /
|
||||||
*/
|
*/
|
||||||
private void checkLevel(SystemUserTb resources) {
|
private void checkLevel(SystemUserTb resources) {
|
||||||
Integer currentLevel = Collections.min(systemRoleService.queryRoleListByUsersId(SecurityHelper.getCurrentUserId()).stream().map(SystemRoleTb::getLevel).collect(Collectors.toList()));
|
Integer currentLevel = Collections.min(systemRoleService.queryRoleByUsersId(SecurityHelper.getCurrentUserId()).stream().map(SystemRoleTb::getLevel).collect(Collectors.toList()));
|
||||||
Integer optLevel = systemRoleService.queryDeptLevelByRoles(resources.getRoles());
|
Integer optLevel = systemRoleService.getDeptLevelByRoles(resources.getRoles());
|
||||||
if (currentLevel > optLevel) {
|
if (currentLevel > optLevel) {
|
||||||
throw new BadRequestException("角色权限不足");
|
throw new BadRequestException("角色权限不足");
|
||||||
}
|
}
|
||||||
@@ -190,16 +190,17 @@ public class SystemUserController {
|
|||||||
@PreAuthorize("@el.check('user:list')")
|
@PreAuthorize("@el.check('user:list')")
|
||||||
public ResponseEntity<List<CsSelectOptionItemVo>> queryUserMetadataOptions(@Validated @RequestBody QuerySystemUserArgs criteria) {
|
public ResponseEntity<List<CsSelectOptionItemVo>> queryUserMetadataOptions(@Validated @RequestBody QuerySystemUserArgs criteria) {
|
||||||
int maxPageSize = 50;
|
int maxPageSize = 50;
|
||||||
return new ResponseEntity<>(systemUserService.page(new Page<>(criteria.getPage(), maxPageSize), new LambdaQueryWrapper<SystemUserTb>()
|
LambdaQueryWrapper<SystemUserTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
.and(c -> {
|
wrapper.and(c -> {
|
||||||
c.eq(SystemUserTb::getPhone, criteria.getBlurry());
|
c.eq(SystemUserTb::getPhone, criteria.getBlurry());
|
||||||
c.or();
|
c.or();
|
||||||
c.eq(SystemUserTb::getEmail, criteria.getBlurry());
|
c.eq(SystemUserTb::getEmail, criteria.getBlurry());
|
||||||
c.or();
|
c.or();
|
||||||
c.like(SystemUserTb::getUsername, criteria.getBlurry());
|
c.like(SystemUserTb::getUsername, criteria.getBlurry());
|
||||||
c.or();
|
c.or();
|
||||||
c.like(SystemUserTb::getNickName, criteria.getBlurry());
|
c.like(SystemUserTb::getNickName, criteria.getBlurry());
|
||||||
})
|
});
|
||||||
|
return new ResponseEntity<>(systemUserService.queryUserByBlurry(wrapper, new Page<>(criteria.getPage(), maxPageSize)
|
||||||
).getRecords().stream().map(m -> {
|
).getRecords().stream().map(m -> {
|
||||||
Map<String, Object> ext = new HashMap<>(1);
|
Map<String, Object> ext = new HashMap<>(1);
|
||||||
ext.put("id", m.getId());
|
ext.put("id", m.getId());
|
||||||
|
|||||||
+7
-2
@@ -12,11 +12,16 @@ import java.util.List;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字典明细 Mapper
|
||||||
|
*
|
||||||
|
* @author odboy
|
||||||
|
*/
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface SystemDictDetailMapper extends BaseMapper<SystemDictDetailTb> {
|
public interface SystemDictDetailMapper extends BaseMapper<SystemDictDetailTb> {
|
||||||
List<SystemDictDetailTb> queryDictDetailListByDictName(@Param("name") String name);
|
IPage<SystemDictDetailTb> selectDictDetailByArgs(@Param("criteria") QuerySystemDictDetailArgs criteria, Page<Object> page);
|
||||||
|
|
||||||
IPage<SystemDictDetailTb> queryDictDetailListByArgs(@Param("criteria") QuerySystemDictDetailArgs criteria, Page<Object> page);
|
List<SystemDictDetailTb> selectDictDetailByArgs(@Param("criteria") QuerySystemDictDetailArgs criteria);
|
||||||
|
|
||||||
void deleteDictDetailByDictIds(@Param("dictIds") Set<Long> dictIds);
|
void deleteDictDetailByDictIds(@Param("dictIds") Set<Long> dictIds);
|
||||||
}
|
}
|
||||||
|
|||||||
+11
-1
@@ -8,7 +8,17 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字典 Mapper
|
||||||
|
*
|
||||||
|
* @author odboy
|
||||||
|
*/
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface SystemDictMapper extends BaseMapper<SystemDictTb> {
|
public interface SystemDictMapper extends BaseMapper<SystemDictTb> {
|
||||||
IPage<SystemDictTb> queryDictPageByArgs(@Param("criteria") QuerySystemDictArgs criteria, Page<SystemDictTb> page);
|
IPage<SystemDictTb> selectDictByArgs(@Param("criteria") QuerySystemDictArgs criteria, Page<SystemDictTb> page);
|
||||||
|
|
||||||
|
List<SystemDictTb> selectDictByArgs(@Param("criteria") QuerySystemDictArgs criteria);
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -19,7 +19,7 @@ import cn.hutool.core.bean.BeanUtil;
|
|||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.util.ReflectUtil;
|
import cn.hutool.core.util.ReflectUtil;
|
||||||
import cn.odboy.base.CsResultVo;
|
import cn.odboy.base.CsResultVo;
|
||||||
import cn.odboy.util.PageUtil;
|
import cn.odboy.util.CsPageUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
@@ -163,7 +163,7 @@ public interface CsMpMapper<E> extends BaseMapper<E> {
|
|||||||
pageSize = pageSize <= 0 ? 10 : pageSize;
|
pageSize = pageSize <= 0 ? 10 : pageSize;
|
||||||
IPage<E> pageInfo = wrapper.page(new Page<>(pageNumber, pageSize));
|
IPage<E> pageInfo = wrapper.page(new Page<>(pageNumber, pageSize));
|
||||||
if (CollUtil.isEmpty(pageInfo.getRecords())) {
|
if (CollUtil.isEmpty(pageInfo.getRecords())) {
|
||||||
return PageUtil.emptyListData();
|
return CsPageUtil.emptyListData();
|
||||||
}
|
}
|
||||||
return new CsResultVo<>(BeanUtil.copyToList(pageInfo.getRecords(), clazz), pageInfo.getTotal());
|
return new CsResultVo<>(BeanUtil.copyToList(pageInfo.getRecords(), clazz), pageInfo.getTotal());
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-13
@@ -16,18 +16,7 @@
|
|||||||
<result column="name" property="name" jdbcType="VARCHAR"/>
|
<result column="name" property="name" jdbcType="VARCHAR"/>
|
||||||
</association>
|
</association>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
<select id="queryDictDetailListByDictName" resultMap="BaseResultMap">
|
<select id="selectDictDetailByArgs" resultMap="BaseResultMap">
|
||||||
select
|
|
||||||
dd.id, dd.label, dd.`value`, dd.`dict_sort`, dd.create_by, dd.update_by, dd.create_time, dd.update_time,
|
|
||||||
d.id as dict_id, d.name
|
|
||||||
from system_dict_detail dd, system_dict d
|
|
||||||
where dd.dict_id = d.id
|
|
||||||
<if test="name != null and name != ''">
|
|
||||||
and d.name = #{name}
|
|
||||||
</if>
|
|
||||||
order by dd.dict_sort
|
|
||||||
</select>
|
|
||||||
<select id="queryDictDetailListByArgs" resultMap="BaseResultMap">
|
|
||||||
select
|
select
|
||||||
dd.id, dd.label, dd.`value`, dd.`dict_sort`, dd.create_by, dd.update_by, dd.create_time, dd.update_time,
|
dd.id, dd.label, dd.`value`, dd.`dict_sort`, dd.create_by, dd.update_by, dd.create_time, dd.update_time,
|
||||||
d.id as dict_id, d.name
|
d.id as dict_id, d.name
|
||||||
@@ -39,7 +28,7 @@
|
|||||||
<if test="criteria.label != null and criteria.label != ''">
|
<if test="criteria.label != null and criteria.label != ''">
|
||||||
and dd.label = #{criteria.label}
|
and dd.label = #{criteria.label}
|
||||||
</if>
|
</if>
|
||||||
order by dd.dict_sort, dd.dict_id desc
|
order by dd.dict_sort
|
||||||
</select>
|
</select>
|
||||||
<delete id="deleteDictDetailByDictIds">
|
<delete id="deleteDictDetailByDictIds">
|
||||||
delete from system_dict_detail
|
delete from system_dict_detail
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||||
<mapper namespace="cn.odboy.core.dal.mysql.system.SystemDictMapper">
|
<mapper namespace="cn.odboy.core.dal.mysql.system.SystemDictMapper">
|
||||||
<select id="queryDictPageByArgs" resultType="cn.odboy.core.dal.dataobject.system.SystemDictTb">
|
<select id="selectDictByArgs" resultType="cn.odboy.core.dal.dataobject.system.SystemDictTb">
|
||||||
SELECT
|
SELECT
|
||||||
*
|
*
|
||||||
from system_dict d
|
from system_dict d
|
||||||
|
|||||||
@@ -0,0 +1,50 @@
|
|||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||||
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
||||||
|
<style>
|
||||||
|
@page {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body style="margin: 0px;
|
||||||
|
padding: 0px;
|
||||||
|
font: 100% SimSun, Microsoft YaHei, Times New Roman, Verdana, Arial, Helvetica, sans-serif;
|
||||||
|
color: #000;">
|
||||||
|
<div style="height: auto;
|
||||||
|
width: 820px;
|
||||||
|
min-width: 820px;
|
||||||
|
margin: 0 auto;
|
||||||
|
margin-top: 20px;
|
||||||
|
border: 1px solid #eee;">
|
||||||
|
<div style="padding: 10px;padding-bottom: 0px;">
|
||||||
|
<p style="margin-bottom: 10px;padding-bottom: 0px;">尊敬的用户,您好:</p>
|
||||||
|
<p style="text-indent: 2em; margin-bottom: 10px;">您正在申请邮箱验证,您的验证码为:</p>
|
||||||
|
<p style="text-align: center;
|
||||||
|
font-family: Times New Roman;
|
||||||
|
font-size: 22px;
|
||||||
|
color: #C60024;
|
||||||
|
padding: 20px 0px;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
font-weight: bold;
|
||||||
|
background: #ebebeb;">${code}</p>
|
||||||
|
<div class="foot-hr hr" style="margin: 0 auto;
|
||||||
|
z-index: 111;
|
||||||
|
width: 800px;
|
||||||
|
margin-top: 30px;
|
||||||
|
border-top: 1px solid #DA251D;">
|
||||||
|
</div>
|
||||||
|
<div style="text-align: center;
|
||||||
|
font-size: 12px;
|
||||||
|
padding: 20px 0px;
|
||||||
|
font-family: Microsoft YaHei;">
|
||||||
|
Copyright ©${.now?string("yyyy")} <a hover="color: #DA251D;" style="color: #999;"
|
||||||
|
href="https://github.com/odboy-tianjun/cutejava" target="_blank">CuteJava</a>
|
||||||
|
后台管理系统 All Rights Reserved.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,71 @@
|
|||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||||
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
||||||
|
<style>
|
||||||
|
@page {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body style="margin: 0px;
|
||||||
|
padding: 0px;
|
||||||
|
font: 100% SimSun, Microsoft YaHei, Times New Roman, Verdana, Arial, Helvetica, sans-serif;
|
||||||
|
color: #000;">
|
||||||
|
<div style="height: auto;
|
||||||
|
margin: 0 auto;
|
||||||
|
margin-top: 20px;
|
||||||
|
padding: 20px;
|
||||||
|
border: 1px solid #eee;">
|
||||||
|
<div>
|
||||||
|
<p style="margin-bottom: 10px;">任务信息:</p>
|
||||||
|
<table style="border-collapse: collapse;">
|
||||||
|
<tr>
|
||||||
|
<th style="padding: .65em;background: #666;border: 1px solid #777;color: #fff;">任务名称</th>
|
||||||
|
<th style="padding: .65em;background: #666;border: 1px solid #777;color: #fff;">Bean名称</th>
|
||||||
|
<th style="padding: .65em;background: #666;border: 1px solid #777;color: #fff;">执行方法</th>
|
||||||
|
<th style="padding: .65em;background: #666;border: 1px solid #777;color: #fff;">参数内容</th>
|
||||||
|
<th style="padding: .65em;background: #666;border: 1px solid #777;color: #fff;">Cron表达式</th>
|
||||||
|
<th style="padding: .65em;background: #666;border: 1px solid #777;color: #fff;">描述内容</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td style="padding: .65em;border: 1px solid#777;">${task.jobName}</td>
|
||||||
|
<td style="padding: .65em;border: 1px solid#777;">${task.beanName}</td>
|
||||||
|
<td style="padding: .65em;border: 1px solid#777;">${task.methodName}</td>
|
||||||
|
<td style="padding: .65em;border: 1px solid#777;">${(task.params)!""}</td>
|
||||||
|
<td style="padding: .65em;border: 1px solid#777;">${task.cronExpression}</td>
|
||||||
|
<td style="padding: .65em;border: 1px solid#777;">${(task.description)!""}</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<p style="margin-bottom: 10px;">异常信息:</p>
|
||||||
|
<pre style="position: relative;
|
||||||
|
padding: 15px;
|
||||||
|
line-height: 20px;
|
||||||
|
border-left: 5px solid #ddd;
|
||||||
|
color: #333;
|
||||||
|
font-family: Courier New, serif;
|
||||||
|
font-size: 12px">
|
||||||
|
${msg}
|
||||||
|
</pre>
|
||||||
|
</div>
|
||||||
|
<div class="foot-hr hr" style="margin: 0 auto;
|
||||||
|
z-index: 111;
|
||||||
|
width: 800px;
|
||||||
|
margin-top: 30px;
|
||||||
|
border-top: 1px solid #DA251D;">
|
||||||
|
</div>
|
||||||
|
<div style="text-align: center;
|
||||||
|
font-size: 12px;
|
||||||
|
padding: 20px 0px;
|
||||||
|
font-family: Microsoft YaHei;">
|
||||||
|
Copyright ©${.now?string("yyyy")} <a hover="color: #DA251D;" style="color: #999;"
|
||||||
|
href="https://github.com/odboy-tianjun/cutejava" target="_blank">CuteJava</a>
|
||||||
|
后台管理系统 All Rights Reserved.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Reference in New Issue
Block a user