refactor: 去除缓存
This commit is contained in:
@@ -232,10 +232,9 @@ app:
|
||||
qiniu:
|
||||
# 文件大小 /M
|
||||
max-size: 15
|
||||
email:
|
||||
captchaSetting:
|
||||
# 邮箱验证码有效时间/秒
|
||||
expiration: 300
|
||||
captcha:
|
||||
# 验证码有效时间/秒
|
||||
expireTime: 300
|
||||
## 启用debug
|
||||
#debug: true
|
||||
#logging:
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@ package cn.odboy.core.controller.system;
|
||||
|
||||
import cn.odboy.base.CsResultVo;
|
||||
import cn.odboy.core.dal.dataobject.system.SystemDeptTb;
|
||||
import cn.odboy.core.service.system.ookkoko.SystemDeptService;
|
||||
import cn.odboy.core.service.system.SystemDeptService;
|
||||
import cn.odboy.core.dal.model.system.CreateSystemDeptArgs;
|
||||
import cn.odboy.core.dal.model.system.QuerySystemDeptArgs;
|
||||
import cn.odboy.util.PageUtil;
|
||||
|
||||
+3
-5
@@ -1,7 +1,6 @@
|
||||
package cn.odboy.core.controller.system;
|
||||
|
||||
import cn.odboy.base.CsResultVo;
|
||||
import cn.odboy.core.service.system.SystemDictApi;
|
||||
import cn.odboy.core.dal.dataobject.system.SystemDictTb;
|
||||
import cn.odboy.core.service.system.SystemDictService;
|
||||
import cn.odboy.core.dal.model.system.CreateSystemDictArgs;
|
||||
@@ -26,21 +25,20 @@ import java.util.Set;
|
||||
@Api(tags = "系统:字典管理")
|
||||
@RequestMapping("/api/dict")
|
||||
public class SystemDictController {
|
||||
private final SystemDictApi systemDictApi;
|
||||
private final SystemDictService systemDictService;
|
||||
|
||||
@ApiOperation("导出字典数据")
|
||||
@GetMapping(value = "/download")
|
||||
@PreAuthorize("@el.check('dict:list')")
|
||||
public void exportDict(HttpServletResponse response, QuerySystemDictArgs criteria) throws IOException {
|
||||
systemDictService.downloadDictExcel(systemDictApi.describeDictList(criteria), response);
|
||||
systemDictService.downloadDictExcel(systemDictService.describeDictList(criteria), response);
|
||||
}
|
||||
|
||||
@ApiOperation("查询字典")
|
||||
@PostMapping(value = "/queryAllDict")
|
||||
@PreAuthorize("@el.check('dict:list')")
|
||||
public ResponseEntity<List<SystemDictTb>> queryAllDict() {
|
||||
return new ResponseEntity<>(systemDictApi.describeDictList(new QuerySystemDictArgs()), HttpStatus.OK);
|
||||
return new ResponseEntity<>(systemDictService.describeDictList(new QuerySystemDictArgs()), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ApiOperation("查询字典")
|
||||
@@ -48,7 +46,7 @@ public class SystemDictController {
|
||||
@PreAuthorize("@el.check('dict:list')")
|
||||
public ResponseEntity<CsResultVo<List<SystemDictTb>>> queryDict(QuerySystemDictArgs criteria) {
|
||||
Page<SystemDictTb> page = new Page<>(criteria.getPage(), criteria.getSize());
|
||||
return new ResponseEntity<>(systemDictApi.describeDictPage(criteria, page), HttpStatus.OK);
|
||||
return new ResponseEntity<>(systemDictService.describeDictPage(criteria, page), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ApiOperation("新增字典")
|
||||
|
||||
+2
-4
@@ -1,7 +1,6 @@
|
||||
package cn.odboy.core.controller.system;
|
||||
|
||||
import cn.odboy.base.CsResultVo;
|
||||
import cn.odboy.core.service.system.SystemDictDetailApi;
|
||||
import cn.odboy.core.dal.dataobject.system.SystemDictDetailTb;
|
||||
import cn.odboy.core.service.system.SystemDictDetailService;
|
||||
import cn.odboy.core.dal.model.system.CreateSystemDictDetailArgs;
|
||||
@@ -26,13 +25,12 @@ import java.util.Map;
|
||||
@RequestMapping("/api/dictDetail")
|
||||
public class SystemDictDetailController {
|
||||
private final SystemDictDetailService systemDictDetailService;
|
||||
private final SystemDictDetailApi systemDictDetailApi;
|
||||
|
||||
@ApiOperation("查询字典详情")
|
||||
@GetMapping
|
||||
public ResponseEntity<CsResultVo<List<SystemDictDetailTb>>> queryDictDetailListByArgs(QuerySystemDictDetailArgs criteria) {
|
||||
Page<Object> page = new Page<>(criteria.getPage(), criteria.getSize());
|
||||
return new ResponseEntity<>(systemDictDetailApi.queryDictDetailListByArgs(criteria, page), HttpStatus.OK);
|
||||
return new ResponseEntity<>(systemDictDetailService.queryDictDetailListByArgs(criteria, page), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ApiOperation("查询多个字典详情")
|
||||
@@ -41,7 +39,7 @@ public class SystemDictDetailController {
|
||||
String[] names = dictName.split("[,,]");
|
||||
Map<String, List<SystemDictDetailTb>> dictMap = new HashMap<>(16);
|
||||
for (String name : names) {
|
||||
dictMap.put(name, systemDictDetailApi.describeDictDetailListByName(name));
|
||||
dictMap.put(name, systemDictDetailService.describeDictDetailListByName(name));
|
||||
}
|
||||
return new ResponseEntity<>(dictMap, HttpStatus.OK);
|
||||
}
|
||||
|
||||
+4
-6
@@ -1,7 +1,6 @@
|
||||
package cn.odboy.core.controller.system;
|
||||
|
||||
import cn.odboy.core.dal.dataobject.system.SystemEmailConfigTb;
|
||||
import cn.odboy.core.service.system.SystemEmailApi;
|
||||
import cn.odboy.core.service.system.SystemEmailService;
|
||||
import cn.odboy.core.dal.model.system.SendSystemEmailArgs;
|
||||
import io.swagger.annotations.Api;
|
||||
@@ -23,26 +22,25 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
@RequestMapping("api/email")
|
||||
@Api(tags = "工具:邮件管理")
|
||||
public class SystemEmailController {
|
||||
private final SystemEmailApi emailApi;
|
||||
private final SystemEmailService emailService;
|
||||
private final SystemEmailService systemEmailService;
|
||||
|
||||
@ApiOperation("查询配置")
|
||||
@PostMapping(value = "/describeEmailConfig")
|
||||
public ResponseEntity<SystemEmailConfigTb> describeEmailConfig() {
|
||||
return new ResponseEntity<>(emailApi.describeEmailConfig(), HttpStatus.OK);
|
||||
return new ResponseEntity<>(systemEmailService.describeEmailConfig(), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ApiOperation("配置邮件")
|
||||
@PostMapping(value = "/modifyEmailConfig")
|
||||
public ResponseEntity<Object> modifyEmailConfig(@Validated @RequestBody SystemEmailConfigTb emailConfig) throws Exception {
|
||||
emailService.modifyEmailConfigOnPassChange(emailConfig);
|
||||
systemEmailService.modifyEmailConfigOnPassChange(emailConfig);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ApiOperation("发送邮件")
|
||||
@PostMapping(value = "/sendEmail")
|
||||
public ResponseEntity<Object> sendEmail(@Validated @RequestBody SendSystemEmailArgs sendEmailRequest) {
|
||||
emailService.sendEmail(sendEmailRequest);
|
||||
systemEmailService.sendEmail(sendEmailRequest);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
+3
-5
@@ -1,7 +1,6 @@
|
||||
package cn.odboy.core.controller.system;
|
||||
|
||||
import cn.odboy.base.CsResultVo;
|
||||
import cn.odboy.core.service.system.SystemJobApi;
|
||||
import cn.odboy.core.dal.dataobject.system.SystemJobTb;
|
||||
import cn.odboy.core.service.system.SystemJobService;
|
||||
import cn.odboy.core.dal.model.system.CreateSystemJobArgs;
|
||||
@@ -27,14 +26,13 @@ import java.util.Set;
|
||||
@Api(tags = "系统:岗位管理")
|
||||
@RequestMapping("/api/job")
|
||||
public class SystemJobController {
|
||||
private final SystemJobApi systemJobApi;
|
||||
private final SystemJobService systemJobService;
|
||||
|
||||
@ApiOperation("导出岗位数据")
|
||||
@GetMapping(value = "/download")
|
||||
@PreAuthorize("@el.check('job:list')")
|
||||
public void exportJob(HttpServletResponse response, QuerySystemJobArgs criteria) throws IOException {
|
||||
systemJobService.downloadJobExcel(systemJobApi.describeJobList(criteria), response);
|
||||
systemJobService.downloadJobExcel(systemJobService.describeJobList(criteria), response);
|
||||
}
|
||||
|
||||
@ApiOperation("查询岗位")
|
||||
@@ -42,7 +40,7 @@ public class SystemJobController {
|
||||
@PreAuthorize("@el.check('job:list','user:list')")
|
||||
public ResponseEntity<CsResultVo<List<SystemJobTb>>> queryJob(QuerySystemJobArgs criteria) {
|
||||
Page<SystemJobTb> page = new Page<>(criteria.getPage(), criteria.getSize());
|
||||
return new ResponseEntity<>(systemJobApi.describeJobPage(criteria, page), HttpStatus.OK);
|
||||
return new ResponseEntity<>(systemJobService.describeJobPage(criteria, page), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ApiOperation("新增岗位")
|
||||
@@ -66,7 +64,7 @@ public class SystemJobController {
|
||||
@PreAuthorize("@el.check('job:del')")
|
||||
public ResponseEntity<Object> removeJobByIds(@RequestBody Set<Long> ids) {
|
||||
// 验证是否被用户关联
|
||||
systemJobApi.verifyBindRelationByIds(ids);
|
||||
systemJobService.verifyBindRelationByIds(ids);
|
||||
systemJobService.removeJobByIds(ids);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
+2
-4
@@ -3,7 +3,6 @@ package cn.odboy.core.controller.system;
|
||||
import cn.odboy.base.CsResultVo;
|
||||
import cn.odboy.constant.FileTypeEnum;
|
||||
import cn.odboy.core.dal.dataobject.system.SystemLocalStorageTb;
|
||||
import cn.odboy.core.service.system.SystemLocalStorageApi;
|
||||
import cn.odboy.core.service.system.SystemLocalStorageService;
|
||||
import cn.odboy.core.dal.model.system.QuerySystemLocalStorageArgs;
|
||||
import cn.odboy.exception.BadRequestException;
|
||||
@@ -29,21 +28,20 @@ import java.util.List;
|
||||
@RequestMapping("/api/localStorage")
|
||||
public class SystemLocalStorageController {
|
||||
private final SystemLocalStorageService localStorageService;
|
||||
private final SystemLocalStorageApi localStorageApi;
|
||||
|
||||
@ApiOperation("查询文件")
|
||||
@GetMapping
|
||||
@PreAuthorize("@el.check('storage:list')")
|
||||
public ResponseEntity<CsResultVo<List<SystemLocalStorageTb>>> queryFile(QuerySystemLocalStorageArgs criteria) {
|
||||
Page<SystemLocalStorageTb> page = new Page<>(criteria.getPage(), criteria.getSize());
|
||||
return new ResponseEntity<>(localStorageApi.describeLocalStoragePage(criteria, page), HttpStatus.OK);
|
||||
return new ResponseEntity<>(localStorageService.describeLocalStoragePage(criteria, page), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ApiOperation("导出数据")
|
||||
@GetMapping(value = "/download")
|
||||
@PreAuthorize("@el.check('storage:list')")
|
||||
public void exportFile(HttpServletResponse response, QuerySystemLocalStorageArgs criteria) throws IOException {
|
||||
localStorageService.downloadExcel(localStorageApi.describeLocalStorageList(criteria), response);
|
||||
localStorageService.downloadExcel(localStorageService.describeLocalStorageList(criteria), response);
|
||||
}
|
||||
|
||||
@ApiOperation("上传文件")
|
||||
|
||||
+16
-18
@@ -2,7 +2,6 @@ package cn.odboy.core.controller.system;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.odboy.base.CsResultVo;
|
||||
import cn.odboy.core.service.system.SystemMenuApi;
|
||||
import cn.odboy.core.dal.dataobject.system.SystemMenuTb;
|
||||
import cn.odboy.core.dal.model.system.SystemMenuVo;
|
||||
import cn.odboy.core.framework.permission.core.SecurityHelper;
|
||||
@@ -30,29 +29,28 @@ import java.util.stream.Collectors;
|
||||
@RequestMapping("/api/menus")
|
||||
public class SystemMenuController {
|
||||
private static final String ENTITY_NAME = "menu";
|
||||
private final SystemMenuApi systemMenuApi;
|
||||
private final SystemMenuService systemMenuService;
|
||||
|
||||
@ApiOperation("导出菜单数据")
|
||||
@GetMapping(value = "/download")
|
||||
@PreAuthorize("@el.check('menu:list')")
|
||||
public void exportMenu(HttpServletResponse response, QuerySystemMenuArgs criteria) throws Exception {
|
||||
systemMenuService.downloadMenuExcel(systemMenuApi.describeMenuList(criteria, false), response);
|
||||
systemMenuService.downloadMenuExcel(systemMenuService.describeMenuList(criteria, false), response);
|
||||
}
|
||||
|
||||
@PostMapping(value = "/buildMenus")
|
||||
@ApiOperation("获取前端所需菜单")
|
||||
public ResponseEntity<List<SystemMenuVo>> buildMenus() {
|
||||
List<SystemMenuTb> menuList = systemMenuApi.describeMenuListByUserId(SecurityHelper.getCurrentUserId());
|
||||
List<SystemMenuTb> menus = systemMenuApi.buildMenuTree(menuList);
|
||||
return new ResponseEntity<>(systemMenuApi.buildMenuVo(menus), HttpStatus.OK);
|
||||
List<SystemMenuTb> menuList = systemMenuService.describeMenuListByUserId(SecurityHelper.getCurrentUserId());
|
||||
List<SystemMenuTb> menus = systemMenuService.buildMenuTree(menuList);
|
||||
return new ResponseEntity<>(systemMenuService.buildMenuVo(menus), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ApiOperation("返回全部的菜单")
|
||||
@PostMapping(value = "/describeMenuListByPid")
|
||||
@PreAuthorize("@el.check('menu:list','roles:list')")
|
||||
public ResponseEntity<List<SystemMenuTb>> describeMenuListByPid(@RequestParam Long pid) {
|
||||
return new ResponseEntity<>(systemMenuApi.describeMenuListByPid(pid), HttpStatus.OK);
|
||||
return new ResponseEntity<>(systemMenuService.describeMenuListByPid(pid), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ApiOperation("根据菜单ID返回所有子节点ID,包含自身ID")
|
||||
@@ -60,9 +58,9 @@ public class SystemMenuController {
|
||||
@PreAuthorize("@el.check('menu:list','roles:list')")
|
||||
public ResponseEntity<Object> describeChildMenuSet(@RequestParam Long id) {
|
||||
Set<SystemMenuTb> menuSet = new HashSet<>();
|
||||
List<SystemMenuTb> menuList = systemMenuApi.describeMenuListByPid(id);
|
||||
menuSet.add(systemMenuApi.describeMenuById(id));
|
||||
menuSet = systemMenuApi.describeChildMenuSet(menuList, menuSet);
|
||||
List<SystemMenuTb> menuList = systemMenuService.describeMenuListByPid(id);
|
||||
menuSet.add(systemMenuService.describeMenuById(id));
|
||||
menuSet = systemMenuService.describeChildMenuSet(menuList, menuSet);
|
||||
Set<Long> ids = menuSet.stream().map(SystemMenuTb::getId).collect(Collectors.toSet());
|
||||
return new ResponseEntity<>(ids, HttpStatus.OK);
|
||||
}
|
||||
@@ -71,7 +69,7 @@ public class SystemMenuController {
|
||||
@ApiOperation("查询菜单")
|
||||
@PreAuthorize("@el.check('menu:list')")
|
||||
public ResponseEntity<CsResultVo<List<SystemMenuTb>>> queryMenu(QuerySystemMenuArgs criteria) throws Exception {
|
||||
List<SystemMenuTb> menuList = systemMenuApi.describeMenuList(criteria, true);
|
||||
List<SystemMenuTb> menuList = systemMenuService.describeMenuList(criteria, true);
|
||||
return new ResponseEntity<>(PageUtil.toPage(menuList), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@@ -82,8 +80,8 @@ public class SystemMenuController {
|
||||
Set<SystemMenuTb> menus = new LinkedHashSet<>();
|
||||
if (CollectionUtil.isNotEmpty(ids)) {
|
||||
for (Long id : ids) {
|
||||
SystemMenuTb menu = systemMenuApi.describeMenuById(id);
|
||||
List<SystemMenuTb> menuList = systemMenuApi.describeSuperiorMenuList(menu, new ArrayList<>());
|
||||
SystemMenuTb menu = systemMenuService.describeMenuById(id);
|
||||
List<SystemMenuTb> menuList = systemMenuService.describeSuperiorMenuList(menu, new ArrayList<>());
|
||||
for (SystemMenuTb data : menuList) {
|
||||
if (data.getId().equals(menu.getPid())) {
|
||||
data.setSubCount(data.getSubCount() - 1);
|
||||
@@ -93,9 +91,9 @@ public class SystemMenuController {
|
||||
}
|
||||
// 编辑菜单时不显示自己以及自己下级的数据,避免出现PID数据环形问题
|
||||
menus = menus.stream().filter(i -> !ids.contains(i.getId())).collect(Collectors.toSet());
|
||||
return new ResponseEntity<>(systemMenuApi.buildMenuTree(new ArrayList<>(menus)), HttpStatus.OK);
|
||||
return new ResponseEntity<>(systemMenuService.buildMenuTree(new ArrayList<>(menus)), HttpStatus.OK);
|
||||
}
|
||||
return new ResponseEntity<>(systemMenuApi.describeMenuListByPid(null), HttpStatus.OK);
|
||||
return new ResponseEntity<>(systemMenuService.describeMenuListByPid(null), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ApiOperation("新增菜单")
|
||||
@@ -123,9 +121,9 @@ public class SystemMenuController {
|
||||
public ResponseEntity<Object> removeMenuByIds(@RequestBody Set<Long> ids) {
|
||||
Set<SystemMenuTb> menuSet = new HashSet<>();
|
||||
for (Long id : ids) {
|
||||
List<SystemMenuTb> menuList = systemMenuApi.describeMenuListByPid(id);
|
||||
menuSet.add(systemMenuApi.describeMenuById(id));
|
||||
menuSet = systemMenuApi.describeChildMenuSet(menuList, menuSet);
|
||||
List<SystemMenuTb> menuList = systemMenuService.describeMenuListByPid(id);
|
||||
menuSet.add(systemMenuService.describeMenuById(id));
|
||||
menuSet = systemMenuService.describeChildMenuSet(menuList, menuSet);
|
||||
}
|
||||
systemMenuService.removeMenuByIds(menuSet);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
package cn.odboy.core.controller.system;
|
||||
|
||||
import cn.odboy.core.service.system.SystemMonitorApi;
|
||||
import cn.odboy.core.service.system.SystemMonitorService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -17,7 +17,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
@RequestMapping("/api/monitor")
|
||||
public class SystemMonitorController {
|
||||
|
||||
private final SystemMonitorApi serverService;
|
||||
private final SystemMonitorService serverService;
|
||||
|
||||
@PostMapping(value = "/describeServerMonitorInfo")
|
||||
@ApiOperation("查询服务监控")
|
||||
|
||||
+3
-7
@@ -3,9 +3,7 @@ package cn.odboy.core.controller.system;
|
||||
import cn.odboy.base.CsResultVo;
|
||||
import cn.odboy.core.dal.dataobject.system.SystemQiniuConfigTb;
|
||||
import cn.odboy.core.dal.dataobject.system.SystemQiniuContentTb;
|
||||
import cn.odboy.core.service.system.SystemQiniuConfigApi;
|
||||
import cn.odboy.core.service.system.SystemQiniuConfigService;
|
||||
import cn.odboy.core.service.system.SystemQiniuContentApi;
|
||||
import cn.odboy.core.service.system.SystemQiniuContentService;
|
||||
import cn.odboy.core.dal.model.system.QuerySystemQiniuArgs;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
@@ -36,13 +34,11 @@ import java.util.Map;
|
||||
public class SystemQiniuController {
|
||||
private final SystemQiniuContentService qiniuContentService;
|
||||
private final SystemQiniuConfigService qiNiuConfigService;
|
||||
private final SystemQiniuConfigApi qiniuConfigApi;
|
||||
private final SystemQiniuContentApi qiniuContentApi;
|
||||
|
||||
@ApiOperation("查询七牛云存储配置")
|
||||
@PostMapping(value = "/describeQiniuConfig")
|
||||
public ResponseEntity<SystemQiniuConfigTb> describeQiniuConfig() {
|
||||
return new ResponseEntity<>(qiniuConfigApi.describeQiniuConfig(), HttpStatus.OK);
|
||||
return new ResponseEntity<>(qiNiuConfigService.describeQiniuConfig(), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ApiOperation("配置七牛云存储")
|
||||
@@ -56,14 +52,14 @@ public class SystemQiniuController {
|
||||
@ApiOperation("导出数据")
|
||||
@GetMapping(value = "/download")
|
||||
public void exportQiNiu(HttpServletResponse response, QuerySystemQiniuArgs criteria) throws IOException {
|
||||
qiniuContentService.downloadExcel(qiniuContentApi.describeQiniuContentList(criteria), response);
|
||||
qiniuContentService.downloadExcel(qiniuContentService.describeQiniuContentList(criteria), response);
|
||||
}
|
||||
|
||||
@ApiOperation("查询文件")
|
||||
@GetMapping
|
||||
public ResponseEntity<CsResultVo<List<SystemQiniuContentTb>>> queryQiNiu(QuerySystemQiniuArgs criteria) {
|
||||
Page<SystemQiniuContentTb> page = new Page<>(criteria.getPage(), criteria.getSize());
|
||||
return new ResponseEntity<>(qiniuContentApi.describeQiniuContentPage(criteria, page), HttpStatus.OK);
|
||||
return new ResponseEntity<>(qiniuContentService.describeQiniuContentPage(criteria, page), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ApiOperation("上传文件")
|
||||
|
||||
+4
-6
@@ -4,7 +4,6 @@ import cn.odboy.base.CsResultVo;
|
||||
import cn.odboy.context.SpringBeanHolder;
|
||||
import cn.odboy.core.dal.dataobject.system.SystemQuartzJobTb;
|
||||
import cn.odboy.core.dal.dataobject.system.SystemQuartzLogTb;
|
||||
import cn.odboy.core.service.system.SystemQuartzJobApi;
|
||||
import cn.odboy.core.service.system.SystemQuartzJobService;
|
||||
import cn.odboy.core.dal.model.system.QuerySystemQuartzJobArgs;
|
||||
import cn.odboy.core.dal.model.system.UpdateSystemQuartzJobArgs;
|
||||
@@ -34,28 +33,27 @@ import java.util.Set;
|
||||
public class SystemQuartzJobController {
|
||||
private static final String ENTITY_NAME = "quartzJob";
|
||||
private final SystemQuartzJobService systemQuartzJobService;
|
||||
private final SystemQuartzJobApi systemQuartzJobApi;
|
||||
|
||||
@ApiOperation("查询定时任务")
|
||||
@GetMapping
|
||||
@PreAuthorize("@el.check('timing:list')")
|
||||
public ResponseEntity<CsResultVo<List<SystemQuartzJobTb>>> queryQuartzJob(QuerySystemQuartzJobArgs criteria) {
|
||||
Page<SystemQuartzJobTb> page = new Page<>(criteria.getPage(), criteria.getSize());
|
||||
return new ResponseEntity<>(systemQuartzJobApi.describeQuartzJobPage(criteria, page), HttpStatus.OK);
|
||||
return new ResponseEntity<>(systemQuartzJobService.describeQuartzJobPage(criteria, page), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ApiOperation("导出任务数据")
|
||||
@GetMapping(value = "/download")
|
||||
@PreAuthorize("@el.check('timing:list')")
|
||||
public void exportQuartzJob(HttpServletResponse response, QuerySystemQuartzJobArgs criteria) throws IOException {
|
||||
systemQuartzJobService.downloadQuartzJobExcel(systemQuartzJobApi.describeQuartzJobList(criteria), response);
|
||||
systemQuartzJobService.downloadQuartzJobExcel(systemQuartzJobService.describeQuartzJobList(criteria), response);
|
||||
}
|
||||
|
||||
@ApiOperation("导出日志数据")
|
||||
@GetMapping(value = "/logs/download")
|
||||
@PreAuthorize("@el.check('timing:list')")
|
||||
public void exportQuartzJobLog(HttpServletResponse response, QuerySystemQuartzJobArgs criteria) throws IOException {
|
||||
systemQuartzJobService.downloadQuartzLogExcel(systemQuartzJobApi.describeQuartzLogList(criteria), response);
|
||||
systemQuartzJobService.downloadQuartzLogExcel(systemQuartzJobService.describeQuartzLogList(criteria), response);
|
||||
}
|
||||
|
||||
@ApiOperation("查询任务执行日志")
|
||||
@@ -63,7 +61,7 @@ public class SystemQuartzJobController {
|
||||
@PreAuthorize("@el.check('timing:list')")
|
||||
public ResponseEntity<CsResultVo<List<SystemQuartzLogTb>>> queryQuartzJobLog(QuerySystemQuartzJobArgs criteria) {
|
||||
Page<SystemQuartzLogTb> page = new Page<>(criteria.getPage(), criteria.getSize());
|
||||
return new ResponseEntity<>(systemQuartzJobApi.describeQuartzLogPage(criteria, page), HttpStatus.OK);
|
||||
return new ResponseEntity<>(systemQuartzJobService.describeQuartzLogPage(criteria, page), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ApiOperation("新增定时任务")
|
||||
|
||||
+6
-8
@@ -2,7 +2,6 @@ package cn.odboy.core.controller.system;
|
||||
|
||||
import cn.hutool.core.lang.Dict;
|
||||
import cn.odboy.base.CsResultVo;
|
||||
import cn.odboy.core.service.system.SystemRoleApi;
|
||||
import cn.odboy.core.dal.dataobject.system.SystemRoleTb;
|
||||
import cn.odboy.core.framework.permission.core.SecurityHelper;
|
||||
import cn.odboy.core.service.system.SystemRoleService;
|
||||
@@ -32,28 +31,27 @@ import java.util.stream.Collectors;
|
||||
@Api(tags = "系统:角色管理")
|
||||
@RequestMapping("/api/roles")
|
||||
public class SystemRoleController {
|
||||
private final SystemRoleApi systemRoleApi;
|
||||
private final SystemRoleService systemRoleService;
|
||||
|
||||
@ApiOperation("获取单个role")
|
||||
@PostMapping(value = "/describeRoleById")
|
||||
@PreAuthorize("@el.check('roles:list')")
|
||||
public ResponseEntity<SystemRoleTb> describeRoleById(@RequestBody SystemRoleTb args) {
|
||||
return new ResponseEntity<>(systemRoleApi.describeRoleById(args.getId()), HttpStatus.OK);
|
||||
return new ResponseEntity<>(systemRoleService.describeRoleById(args.getId()), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ApiOperation("导出角色数据")
|
||||
@GetMapping(value = "/download")
|
||||
@PreAuthorize("@el.check('role:list')")
|
||||
public void exportRole(HttpServletResponse response, QuerySystemRoleArgs criteria) throws IOException {
|
||||
systemRoleService.downloadRoleExcel(systemRoleApi.describeRoleList(criteria), response);
|
||||
systemRoleService.downloadRoleExcel(systemRoleService.describeRoleList(criteria), response);
|
||||
}
|
||||
|
||||
@ApiOperation("返回全部的角色")
|
||||
@PostMapping(value = "/describeRoleList")
|
||||
@PreAuthorize("@el.check('roles:list','user:add','user:edit')")
|
||||
public ResponseEntity<List<SystemRoleTb>> describeRoleList() {
|
||||
return new ResponseEntity<>(systemRoleApi.describeRoleList(), HttpStatus.OK);
|
||||
return new ResponseEntity<>(systemRoleService.describeRoleList(), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ApiOperation("查询角色")
|
||||
@@ -61,7 +59,7 @@ public class SystemRoleController {
|
||||
@PreAuthorize("@el.check('roles:list')")
|
||||
public ResponseEntity<CsResultVo<List<SystemRoleTb>>> describeRolePage(QuerySystemRoleArgs criteria) {
|
||||
Page<Object> page = new Page<>(criteria.getPage(), criteria.getSize());
|
||||
return new ResponseEntity<>(systemRoleApi.describeRolePage(criteria, page), HttpStatus.OK);
|
||||
return new ResponseEntity<>(systemRoleService.describeRolePage(criteria, page), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ApiOperation("获取用户级别")
|
||||
@@ -107,7 +105,7 @@ public class SystemRoleController {
|
||||
checkRoleLevels(role.getLevel());
|
||||
}
|
||||
// 验证是否被用户关联
|
||||
systemRoleApi.verifyBindRelationByIds(ids);
|
||||
systemRoleService.verifyBindRelationByIds(ids);
|
||||
systemRoleService.removeRoleByIds(ids);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
@@ -118,7 +116,7 @@ public class SystemRoleController {
|
||||
* @return /
|
||||
*/
|
||||
private int checkRoleLevels(Integer level) {
|
||||
List<Integer> levels = systemRoleApi.describeRoleListByUsersId(SecurityHelper.getCurrentUserId()).stream().map(SystemRoleTb::getLevel).collect(Collectors.toList());
|
||||
List<Integer> levels = systemRoleService.describeRoleListByUsersId(SecurityHelper.getCurrentUserId()).stream().map(SystemRoleTb::getLevel).collect(Collectors.toList());
|
||||
int min = Collections.min(levels);
|
||||
if (level != null) {
|
||||
if (level < min) {
|
||||
|
||||
+14
-15
@@ -4,7 +4,7 @@ import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.odboy.base.CsResultVo;
|
||||
import cn.odboy.base.CsSelectOptionItemVo;
|
||||
import cn.odboy.core.service.system.*;
|
||||
import cn.odboy.core.service.system.ookkoko.SystemDataService;
|
||||
import cn.odboy.core.service.system.SystemDataService;
|
||||
import cn.odboy.core.constant.system.SystemCaptchaBizEnum;
|
||||
import cn.odboy.core.dal.dataobject.system.SystemDeptTb;
|
||||
import cn.odboy.core.dal.dataobject.system.SystemRoleTb;
|
||||
@@ -13,7 +13,7 @@ import cn.odboy.core.dal.model.system.UpdateSystemUserPasswordArgs;
|
||||
import cn.odboy.core.framework.permission.core.SecurityHelper;
|
||||
import cn.odboy.core.framework.properties.AppProperties;
|
||||
import cn.odboy.core.dal.model.system.QuerySystemUserArgs;
|
||||
import cn.odboy.core.service.system.ookkoko.SystemDeptService;
|
||||
import cn.odboy.core.service.system.SystemDeptService;
|
||||
import cn.odboy.exception.BadRequestException;
|
||||
import cn.odboy.util.PageUtil;
|
||||
import cn.odboy.util.RsaEncryptUtil;
|
||||
@@ -46,8 +46,7 @@ public class SystemUserController {
|
||||
private final SystemUserService systemUserService;
|
||||
private final SystemDataService systemDataService;
|
||||
private final SystemDeptService systemDeptService;
|
||||
private final SystemRoleApi systemRoleApi;
|
||||
private final SystemUserApi systemUserApi;
|
||||
private final SystemRoleService systemRoleService;
|
||||
private final SystemCaptchaService verificationCodeService;
|
||||
private final AppProperties properties;
|
||||
|
||||
@@ -55,7 +54,7 @@ public class SystemUserController {
|
||||
@GetMapping(value = "/download")
|
||||
@PreAuthorize("@el.check('user:list')")
|
||||
public void downloadUserExcel(HttpServletResponse response, QuerySystemUserArgs criteria) throws IOException {
|
||||
systemUserService.downloadUserExcel(systemUserApi.describeUserList(criteria), response);
|
||||
systemUserService.downloadUserExcel(systemUserService.describeUserList(criteria), response);
|
||||
}
|
||||
|
||||
@ApiOperation("查询用户")
|
||||
@@ -71,18 +70,18 @@ public class SystemUserController {
|
||||
criteria.getDeptIds().addAll(systemDeptService.describeChildDeptIdListByDeptIds(data));
|
||||
}
|
||||
// 数据权限
|
||||
List<Long> dataScopes = systemDataService.describeDeptIdListByUserIdWithDeptId(systemUserApi.describeUserByUsername(SecurityHelper.getCurrentUsername()));
|
||||
List<Long> dataScopes = systemDataService.describeDeptIdListByUserIdWithDeptId(systemUserService.describeUserByUsername(SecurityHelper.getCurrentUsername()));
|
||||
// criteria.getDeptIds() 不为空并且数据权限不为空则取交集
|
||||
if (!CollectionUtils.isEmpty(criteria.getDeptIds()) && !CollectionUtils.isEmpty(dataScopes)) {
|
||||
// 取交集
|
||||
criteria.getDeptIds().retainAll(dataScopes);
|
||||
if (!CollectionUtil.isEmpty(criteria.getDeptIds())) {
|
||||
return new ResponseEntity<>(systemUserApi.describeUserPage(criteria, page), HttpStatus.OK);
|
||||
return new ResponseEntity<>(systemUserService.describeUserPage(criteria, page), HttpStatus.OK);
|
||||
}
|
||||
} else {
|
||||
// 否则取并集
|
||||
criteria.getDeptIds().addAll(dataScopes);
|
||||
return new ResponseEntity<>(systemUserApi.describeUserPage(criteria, page), HttpStatus.OK);
|
||||
return new ResponseEntity<>(systemUserService.describeUserPage(criteria, page), HttpStatus.OK);
|
||||
}
|
||||
return new ResponseEntity<>(PageUtil.emptyData(), HttpStatus.OK);
|
||||
}
|
||||
@@ -122,10 +121,10 @@ public class SystemUserController {
|
||||
@PreAuthorize("@el.check('user:del')")
|
||||
public ResponseEntity<Object> removeUserByIds(@RequestBody Set<Long> ids) {
|
||||
for (Long id : ids) {
|
||||
Integer currentLevel = Collections.min(systemRoleApi.describeRoleListByUsersId(SecurityHelper.getCurrentUserId()).stream().map(SystemRoleTb::getLevel).collect(Collectors.toList()));
|
||||
Integer optLevel = Collections.min(systemRoleApi.describeRoleListByUsersId(id).stream().map(SystemRoleTb::getLevel).collect(Collectors.toList()));
|
||||
Integer currentLevel = Collections.min(systemRoleService.describeRoleListByUsersId(SecurityHelper.getCurrentUserId()).stream().map(SystemRoleTb::getLevel).collect(Collectors.toList()));
|
||||
Integer optLevel = Collections.min(systemRoleService.describeRoleListByUsersId(id).stream().map(SystemRoleTb::getLevel).collect(Collectors.toList()));
|
||||
if (currentLevel > optLevel) {
|
||||
throw new BadRequestException("角色权限不足,不能删除:" + systemUserApi.describeUserById(id).getUsername());
|
||||
throw new BadRequestException("角色权限不足,不能删除:" + systemUserService.describeUserById(id).getUsername());
|
||||
}
|
||||
}
|
||||
systemUserService.removeUserByIds(ids);
|
||||
@@ -137,7 +136,7 @@ public class SystemUserController {
|
||||
public ResponseEntity<Object> modifyUserPasswordByUsername(@RequestBody UpdateSystemUserPasswordArgs passVo) throws Exception {
|
||||
String oldPass = RsaEncryptUtil.decryptByPrivateKey(properties.getRsa().getPrivateKey(), passVo.getOldPass());
|
||||
String newPass = RsaEncryptUtil.decryptByPrivateKey(properties.getRsa().getPrivateKey(), passVo.getNewPass());
|
||||
SystemUserTb user = systemUserApi.describeUserByUsername(SecurityHelper.getCurrentUsername());
|
||||
SystemUserTb user = systemUserService.describeUserByUsername(SecurityHelper.getCurrentUsername());
|
||||
if (!passwordEncoder.matches(oldPass, user.getPassword())) {
|
||||
throw new BadRequestException("修改失败,旧密码错误");
|
||||
}
|
||||
@@ -166,7 +165,7 @@ public class SystemUserController {
|
||||
@PostMapping(value = "/modifyUserEmailByUsername/{code}")
|
||||
public ResponseEntity<Object> modifyUserEmailByUsername(@PathVariable String code, @RequestBody SystemUserTb resources) throws Exception {
|
||||
String password = RsaEncryptUtil.decryptByPrivateKey(properties.getRsa().getPrivateKey(), resources.getPassword());
|
||||
SystemUserTb user = systemUserApi.describeUserByUsername(SecurityHelper.getCurrentUsername());
|
||||
SystemUserTb user = systemUserService.describeUserByUsername(SecurityHelper.getCurrentUsername());
|
||||
if (!passwordEncoder.matches(password, user.getPassword())) {
|
||||
throw new BadRequestException("密码错误");
|
||||
}
|
||||
@@ -181,8 +180,8 @@ public class SystemUserController {
|
||||
* @param resources /
|
||||
*/
|
||||
private void checkLevel(SystemUserTb resources) {
|
||||
Integer currentLevel = Collections.min(systemRoleApi.describeRoleListByUsersId(SecurityHelper.getCurrentUserId()).stream().map(SystemRoleTb::getLevel).collect(Collectors.toList()));
|
||||
Integer optLevel = systemRoleApi.describeDeptLevelByRoles(resources.getRoles());
|
||||
Integer currentLevel = Collections.min(systemRoleService.describeRoleListByUsersId(SecurityHelper.getCurrentUserId()).stream().map(SystemRoleTb::getLevel).collect(Collectors.toList()));
|
||||
Integer optLevel = systemRoleService.describeDeptLevelByRoles(resources.getRoles());
|
||||
if (currentLevel > optLevel) {
|
||||
throw new BadRequestException("角色权限不足");
|
||||
}
|
||||
|
||||
+7
-7
@@ -5,9 +5,9 @@ import cn.odboy.core.dal.model.system.SystemUserJwtVo;
|
||||
import cn.odboy.core.dal.redis.system.SystemUserJwtApi;
|
||||
import cn.odboy.core.dal.redis.system.SystemUserJwtService;
|
||||
import cn.odboy.core.dal.dataobject.system.SystemUserTb;
|
||||
import cn.odboy.core.service.system.ookkoko.SystemDataService;
|
||||
import cn.odboy.core.service.system.SystemRoleApi;
|
||||
import cn.odboy.core.service.system.SystemUserApi;
|
||||
import cn.odboy.core.service.system.SystemDataService;
|
||||
import cn.odboy.core.service.system.SystemRoleService;
|
||||
import cn.odboy.core.service.system.SystemUserService;
|
||||
import cn.odboy.exception.BadRequestException;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -20,8 +20,8 @@ import java.util.List;
|
||||
@RequiredArgsConstructor
|
||||
@Service("userDetailsService")
|
||||
public class UserDetailsHandler implements UserDetailsService {
|
||||
private final SystemRoleApi systemRoleApi;
|
||||
private final SystemUserApi systemUserApi;
|
||||
private final SystemRoleService systemRoleService;
|
||||
private final SystemUserService systemUserService;
|
||||
private final SystemDataService systemDataService;
|
||||
private final SystemUserJwtService systemUserJwtService;
|
||||
private final SystemUserJwtApi systemUserJwtApi;
|
||||
@@ -30,7 +30,7 @@ public class UserDetailsHandler implements UserDetailsService {
|
||||
public SystemUserJwtVo loadUserByUsername(String username) {
|
||||
SystemUserJwtVo userJwtVo = systemUserJwtApi.describeUserJwtModelByUsername(username);
|
||||
if (userJwtVo == null) {
|
||||
SystemUserTb user = systemUserApi.describeUserByUsername(username);
|
||||
SystemUserTb user = systemUserService.describeUserByUsername(username);
|
||||
if (user == null) {
|
||||
throw new BadRequestException("用户不存在");
|
||||
} else {
|
||||
@@ -38,7 +38,7 @@ public class UserDetailsHandler implements UserDetailsService {
|
||||
throw new BadRequestException("账号未激活!");
|
||||
}
|
||||
// 获取用户的权限
|
||||
List<SystemRoleCodeVo> authorities = systemRoleApi.buildUserRolePermissions(user);
|
||||
List<SystemRoleCodeVo> authorities = systemRoleService.buildUserRolePermissions(user);
|
||||
// 初始化JwtUserDto
|
||||
userJwtVo = new SystemUserJwtVo(user, systemDataService.describeDeptIdListByUserIdWithDeptId(user), authorities);
|
||||
// 添加缓存数据
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@ import java.util.Collections;
|
||||
@RequiredArgsConstructor
|
||||
public class SystemCaptchaServiceImpl implements SystemCaptchaService {
|
||||
private final RedisHelper redisHelper;
|
||||
@Value("${app.email.captchaSetting.expiration}")
|
||||
@Value("${app.captcha.expireTime}")
|
||||
private Long expiration;
|
||||
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package cn.odboy.core.service.system.ookkoko;
|
||||
package cn.odboy.core.service.system;
|
||||
|
||||
|
||||
import cn.odboy.core.dal.dataobject.system.SystemUserTb;
|
||||
+10
-16
@@ -1,18 +1,18 @@
|
||||
package cn.odboy.core.service.system.ookkoko;
|
||||
package cn.odboy.core.service.system;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.odboy.core.constant.system.SystemDataScopeEnum;
|
||||
import cn.odboy.core.dal.redis.system.SystemRedisKey;
|
||||
import cn.odboy.core.dal.dataobject.system.SystemDeptTb;
|
||||
import cn.odboy.core.dal.dataobject.system.SystemRoleTb;
|
||||
import cn.odboy.core.dal.dataobject.system.SystemUserTb;
|
||||
import cn.odboy.core.service.system.SystemRoleApi;
|
||||
import cn.odboy.redis.RedisHelper;
|
||||
import cn.odboy.core.dal.redis.system.SystemRedisKey;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 数据权限服务实现
|
||||
@@ -20,8 +20,7 @@ import java.util.concurrent.TimeUnit;
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class SystemDataServiceImpl implements SystemDataService {
|
||||
private final RedisHelper redisHelper;
|
||||
private final SystemRoleApi systemRoleApi;
|
||||
private final SystemRoleService systemRoleService;
|
||||
private final SystemDeptService systemDeptService;
|
||||
|
||||
/**
|
||||
@@ -33,11 +32,9 @@ public class SystemDataServiceImpl implements SystemDataService {
|
||||
@Override
|
||||
public List<Long> describeDeptIdListByUserIdWithDeptId(SystemUserTb user) {
|
||||
String key = SystemRedisKey.DATA_USER + user.getId();
|
||||
List<Long> ids = redisHelper.getList(key, Long.class);
|
||||
if (CollUtil.isEmpty(ids)) {
|
||||
Set<Long> deptIds = new HashSet<>();
|
||||
// 查询用户角色
|
||||
List<SystemRoleTb> roleList = systemRoleApi.describeRoleListByUsersId(user.getId());
|
||||
List<SystemRoleTb> roleList = systemRoleService.describeRoleListByUsersId(user.getId());
|
||||
// 获取对应的部门ID
|
||||
for (SystemRoleTb role : roleList) {
|
||||
SystemDataScopeEnum dataScopeEnum = SystemDataScopeEnum.find(role.getDataScope());
|
||||
@@ -52,10 +49,7 @@ public class SystemDataServiceImpl implements SystemDataService {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
ids = new ArrayList<>(deptIds);
|
||||
redisHelper.set(key, ids, 1, TimeUnit.DAYS);
|
||||
}
|
||||
return ids;
|
||||
return new ArrayList<>(deptIds);
|
||||
}
|
||||
|
||||
/**
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package cn.odboy.core.service.system.ookkoko;
|
||||
package cn.odboy.core.service.system;
|
||||
|
||||
import cn.odboy.base.CsResultVo;
|
||||
import cn.odboy.core.dal.dataobject.system.SystemDeptTb;
|
||||
+31
-57
@@ -1,4 +1,4 @@
|
||||
package cn.odboy.core.service.system.ookkoko;
|
||||
package cn.odboy.core.service.system;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
@@ -6,17 +6,14 @@ import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.odboy.base.CsResultVo;
|
||||
import cn.odboy.core.constant.system.SystemDataScopeEnum;
|
||||
import cn.odboy.core.dal.model.system.QuerySystemDeptArgs;
|
||||
import cn.odboy.core.dal.mysql.system.SystemRoleMapper;
|
||||
import cn.odboy.core.dal.redis.system.SystemRedisKey;
|
||||
import cn.odboy.core.dal.dataobject.system.SystemDeptTb;
|
||||
import cn.odboy.core.dal.dataobject.system.SystemUserTb;
|
||||
import cn.odboy.core.dal.mysql.system.SystemDeptMapper;
|
||||
import cn.odboy.core.dal.mysql.system.SystemUserMapper;
|
||||
import cn.odboy.core.dal.model.system.CreateSystemDeptArgs;
|
||||
import cn.odboy.core.dal.model.system.QuerySystemDeptArgs;
|
||||
import cn.odboy.core.dal.mysql.system.SystemDeptMapper;
|
||||
import cn.odboy.core.dal.mysql.system.SystemRoleMapper;
|
||||
import cn.odboy.core.dal.mysql.system.SystemUserMapper;
|
||||
import cn.odboy.core.framework.permission.core.SecurityHelper;
|
||||
import cn.odboy.exception.BadRequestException;
|
||||
import cn.odboy.redis.RedisHelper;
|
||||
import cn.odboy.util.ClassUtil;
|
||||
import cn.odboy.util.FileUtil;
|
||||
import cn.odboy.util.StringUtil;
|
||||
@@ -24,21 +21,24 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class SystemDeptServiceImpl extends ServiceImpl<SystemDeptMapper, SystemDeptTb> implements SystemDeptService {
|
||||
private final SystemDeptMapper deptMapper;
|
||||
private final SystemUserMapper userMapper;
|
||||
private final RedisHelper redisHelper;
|
||||
private final SystemRoleMapper roleMapper;
|
||||
private final SystemDeptMapper systemDeptMapper;
|
||||
private final SystemUserMapper systemUserMapper;
|
||||
private final SystemRoleMapper systemRoleMapper;
|
||||
|
||||
|
||||
@Override
|
||||
@@ -47,8 +47,6 @@ public class SystemDeptServiceImpl extends ServiceImpl<SystemDeptMapper, SystemD
|
||||
save(BeanUtil.copyProperties(resources, SystemDeptTb.class));
|
||||
// 清理缓存
|
||||
updateSubCnt(resources.getPid());
|
||||
// 清理自定义角色权限的DataScope缓存
|
||||
delCaches(resources.getPid());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -66,17 +64,13 @@ public class SystemDeptServiceImpl extends ServiceImpl<SystemDeptMapper, SystemD
|
||||
// 更新父节点中子节点数目
|
||||
updateSubCnt(oldPid);
|
||||
updateSubCnt(newPid);
|
||||
// 清理缓存
|
||||
delCaches(resources.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void removeDeptByIds(Set<SystemDeptTb> deptSet) {
|
||||
for (SystemDeptTb dept : deptSet) {
|
||||
// 清理缓存
|
||||
delCaches(dept.getId());
|
||||
deptMapper.deleteById(dept.getId());
|
||||
systemDeptMapper.deleteById(dept.getId());
|
||||
updateSubCnt(dept.getPid());
|
||||
}
|
||||
}
|
||||
@@ -97,24 +91,11 @@ public class SystemDeptServiceImpl extends ServiceImpl<SystemDeptMapper, SystemD
|
||||
|
||||
private void updateSubCnt(Long deptId) {
|
||||
if (deptId != null) {
|
||||
int count = deptMapper.getDeptCountByPid(deptId);
|
||||
deptMapper.updateSubCountById(count, deptId);
|
||||
int count = systemDeptMapper.getDeptCountByPid(deptId);
|
||||
systemDeptMapper.updateSubCountById(count, deptId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 清理缓存
|
||||
*
|
||||
* @param id /
|
||||
*/
|
||||
public void delCaches(Long id) {
|
||||
List<SystemUserTb> users = userMapper.queryUserListByDeptId(id);
|
||||
// 删除数据权限
|
||||
redisHelper.delByKeys(SystemRedisKey.DATA_USER, users.stream().map(SystemUserTb::getId).collect(Collectors.toSet()));
|
||||
redisHelper.del(SystemRedisKey.DEPT_ID + id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 筛选出 list 中没有父部门(即 pid 不在其他部门 id 列表中的部门)的部门列表
|
||||
*/
|
||||
@@ -158,7 +139,7 @@ public class SystemDeptServiceImpl extends ServiceImpl<SystemDeptMapper, SystemD
|
||||
}
|
||||
// 数据权限
|
||||
criteria.setIds(SecurityHelper.getCurrentUserDataScope());
|
||||
List<SystemDeptTb> list = deptMapper.queryDeptListByArgs(criteria);
|
||||
List<SystemDeptTb> list = systemDeptMapper.queryDeptListByArgs(criteria);
|
||||
// 如果为空,就代表为自定义权限或者本级权限,就需要去重,不理解可以注释掉,看查询结果
|
||||
if (StringUtil.isBlank(dataScopeType)) {
|
||||
return deduplication(list);
|
||||
@@ -168,30 +149,24 @@ public class SystemDeptServiceImpl extends ServiceImpl<SystemDeptMapper, SystemD
|
||||
|
||||
@Override
|
||||
public SystemDeptTb describeDeptById(Long id) {
|
||||
String key = SystemRedisKey.DEPT_ID + id;
|
||||
SystemDeptTb dept = redisHelper.get(key, SystemDeptTb.class);
|
||||
if (dept == null) {
|
||||
dept = deptMapper.selectById(id);
|
||||
redisHelper.set(key, dept, 1, TimeUnit.DAYS);
|
||||
}
|
||||
return dept;
|
||||
return systemDeptMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SystemDeptTb> describeDeptListByPid(long pid) {
|
||||
return deptMapper.queryDeptListByPid(pid);
|
||||
return systemDeptMapper.queryDeptListByPid(pid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<SystemDeptTb> describeDeptByRoleId(Long id) {
|
||||
return deptMapper.queryDeptSetByRoleId(id);
|
||||
return systemDeptMapper.queryDeptSetByRoleId(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<SystemDeptTb> describeRelationDeptSet(List<SystemDeptTb> menuList, Set<SystemDeptTb> deptSet) {
|
||||
for (SystemDeptTb dept : menuList) {
|
||||
deptSet.add(dept);
|
||||
List<SystemDeptTb> deptList = deptMapper.queryDeptListByPid(dept.getId());
|
||||
List<SystemDeptTb> deptList = systemDeptMapper.queryDeptListByPid(dept.getId());
|
||||
if (CollUtil.isNotEmpty(deptList)) {
|
||||
describeRelationDeptSet(deptList, deptSet);
|
||||
}
|
||||
@@ -202,26 +177,25 @@ public class SystemDeptServiceImpl extends ServiceImpl<SystemDeptMapper, SystemD
|
||||
@Override
|
||||
public List<Long> describeChildDeptIdListByDeptIds(List<SystemDeptTb> deptList) {
|
||||
List<Long> list = new ArrayList<>();
|
||||
deptList.forEach(dept -> {
|
||||
if (dept != null && dept.getEnabled()) {
|
||||
List<SystemDeptTb> deptList1 = deptMapper.queryDeptListByPid(dept.getId());
|
||||
for (SystemDeptTb systemDeptTb : deptList) {
|
||||
if (systemDeptTb != null && systemDeptTb.getEnabled()) {
|
||||
List<SystemDeptTb> deptList1 = systemDeptMapper.queryDeptListByPid(systemDeptTb.getId());
|
||||
if (CollUtil.isNotEmpty(deptList1)) {
|
||||
list.addAll(describeChildDeptIdListByDeptIds(deptList1));
|
||||
}
|
||||
list.add(dept.getId());
|
||||
list.add(systemDeptTb.getId());
|
||||
}
|
||||
}
|
||||
);
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SystemDeptTb> describeSuperiorDeptListByPid(SystemDeptTb dept, List<SystemDeptTb> deptList) {
|
||||
if (dept.getPid() == null) {
|
||||
deptList.addAll(deptMapper.queryDeptListByPidIsNull());
|
||||
deptList.addAll(systemDeptMapper.queryDeptListByPidIsNull());
|
||||
return deptList;
|
||||
}
|
||||
deptList.addAll(deptMapper.queryDeptListByPid(dept.getPid()));
|
||||
deptList.addAll(systemDeptMapper.queryDeptListByPid(dept.getPid()));
|
||||
return describeSuperiorDeptListByPid(describeDeptById(dept.getPid()), deptList);
|
||||
}
|
||||
|
||||
@@ -263,10 +237,10 @@ public class SystemDeptServiceImpl extends ServiceImpl<SystemDeptMapper, SystemD
|
||||
@Override
|
||||
public void verifyBindRelationByIds(Set<SystemDeptTb> deptSet) {
|
||||
Set<Long> deptIds = deptSet.stream().map(SystemDeptTb::getId).collect(Collectors.toSet());
|
||||
if (userMapper.getUserCountByDeptIds(deptIds) > 0) {
|
||||
if (systemUserMapper.getUserCountByDeptIds(deptIds) > 0) {
|
||||
throw new BadRequestException("所选部门存在用户关联,请解除后再试!");
|
||||
}
|
||||
if (roleMapper.getRoleCountByDeptIds(deptIds) > 0) {
|
||||
if (systemRoleMapper.getRoleCountByDeptIds(deptIds) > 0) {
|
||||
throw new BadRequestException("所选部门存在角色关联,请解除后再试!");
|
||||
}
|
||||
}
|
||||
-27
@@ -1,27 +0,0 @@
|
||||
package cn.odboy.core.service.system;
|
||||
|
||||
import cn.odboy.base.CsResultVo;
|
||||
import cn.odboy.core.dal.dataobject.system.SystemDictTb;
|
||||
import cn.odboy.core.dal.model.system.QuerySystemDictArgs;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface SystemDictApi {
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param criteria 条件
|
||||
* @param page 分页参数
|
||||
* @return /
|
||||
*/
|
||||
CsResultVo<List<SystemDictTb>> describeDictPage(QuerySystemDictArgs criteria, Page<SystemDictTb> page);
|
||||
|
||||
/**
|
||||
* 查询全部数据
|
||||
*
|
||||
* @param criteria /
|
||||
* @return /
|
||||
*/
|
||||
List<SystemDictTb> describeDictList(QuerySystemDictArgs criteria);
|
||||
}
|
||||
-30
@@ -1,30 +0,0 @@
|
||||
package cn.odboy.core.service.system;
|
||||
|
||||
import cn.odboy.base.CsResultVo;
|
||||
import cn.odboy.core.dal.dataobject.system.SystemDictTb;
|
||||
import cn.odboy.core.dal.mysql.system.SystemDictMapper;
|
||||
import cn.odboy.core.dal.model.system.QuerySystemDictArgs;
|
||||
import cn.odboy.util.PageUtil;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class SystemDictApiImpl implements SystemDictApi {
|
||||
private final SystemDictMapper dictMapper;
|
||||
|
||||
@Override
|
||||
public CsResultVo<List<SystemDictTb>> describeDictPage(QuerySystemDictArgs criteria, Page<SystemDictTb> page) {
|
||||
IPage<SystemDictTb> dicts = dictMapper.queryDictPageByArgs(criteria, page);
|
||||
return PageUtil.toPage(dicts);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SystemDictTb> describeDictList(QuerySystemDictArgs criteria) {
|
||||
return dictMapper.queryDictPageByArgs(criteria, PageUtil.getCount(dictMapper)).getRecords();
|
||||
}
|
||||
}
|
||||
-27
@@ -1,27 +0,0 @@
|
||||
package cn.odboy.core.service.system;
|
||||
|
||||
import cn.odboy.base.CsResultVo;
|
||||
import cn.odboy.core.dal.dataobject.system.SystemDictDetailTb;
|
||||
import cn.odboy.core.dal.model.system.QuerySystemDictDetailArgs;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface SystemDictDetailApi {
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param criteria 条件
|
||||
* @param page 分页参数
|
||||
* @return /
|
||||
*/
|
||||
CsResultVo<List<SystemDictDetailTb>> queryDictDetailListByArgs(QuerySystemDictDetailArgs criteria, Page<Object> page);
|
||||
|
||||
/**
|
||||
* 根据字典名称获取字典详情
|
||||
*
|
||||
* @param name 字典名称
|
||||
* @return /
|
||||
*/
|
||||
List<SystemDictDetailTb> describeDictDetailListByName(String name);
|
||||
}
|
||||
-39
@@ -1,39 +0,0 @@
|
||||
package cn.odboy.core.service.system;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.odboy.base.CsResultVo;
|
||||
import cn.odboy.core.dal.redis.system.SystemRedisKey;
|
||||
import cn.odboy.core.dal.dataobject.system.SystemDictDetailTb;
|
||||
import cn.odboy.core.dal.mysql.system.SystemDictDetailMapper;
|
||||
import cn.odboy.core.dal.model.system.QuerySystemDictDetailArgs;
|
||||
import cn.odboy.redis.RedisHelper;
|
||||
import cn.odboy.util.PageUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class SystemDictDetailApiImpl implements SystemDictDetailApi {
|
||||
private final SystemDictDetailMapper dictDetailMapper;
|
||||
private final RedisHelper redisHelper;
|
||||
|
||||
@Override
|
||||
public CsResultVo<List<SystemDictDetailTb>> queryDictDetailListByArgs(QuerySystemDictDetailArgs criteria, Page<Object> page) {
|
||||
return PageUtil.toPage(dictDetailMapper.queryDictDetailListByArgs(criteria, page));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SystemDictDetailTb> describeDictDetailListByName(String name) {
|
||||
String key = SystemRedisKey.DICT_NAME + name;
|
||||
List<SystemDictDetailTb> dictDetails = redisHelper.getList(key, SystemDictDetailTb.class);
|
||||
if (CollUtil.isEmpty(dictDetails)) {
|
||||
dictDetails = dictDetailMapper.queryDictDetailListByDictName(name);
|
||||
redisHelper.set(key, dictDetails, 1, TimeUnit.DAYS);
|
||||
}
|
||||
return dictDetails;
|
||||
}
|
||||
}
|
||||
+20
@@ -1,8 +1,12 @@
|
||||
package cn.odboy.core.service.system;
|
||||
|
||||
import cn.odboy.base.CsResultVo;
|
||||
import cn.odboy.core.dal.dataobject.system.SystemDictDetailTb;
|
||||
import cn.odboy.core.dal.model.system.CreateSystemDictDetailArgs;
|
||||
import cn.odboy.core.dal.model.system.QuerySystemDictDetailArgs;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public interface SystemDictDetailService extends IService<SystemDictDetailTb> {
|
||||
@@ -27,4 +31,20 @@ public interface SystemDictDetailService extends IService<SystemDictDetailTb> {
|
||||
* @param id /
|
||||
*/
|
||||
void removeDictDetailById(Long id);
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param criteria 条件
|
||||
* @param page 分页参数
|
||||
* @return /
|
||||
*/
|
||||
CsResultVo<List<SystemDictDetailTb>> queryDictDetailListByArgs(QuerySystemDictDetailArgs criteria, Page<Object> page);
|
||||
|
||||
/**
|
||||
* 根据字典名称获取字典详情
|
||||
*
|
||||
* @param name 字典名称
|
||||
* @return /
|
||||
*/
|
||||
List<SystemDictDetailTb> describeDictDetailListByName(String name);
|
||||
}
|
||||
+16
-18
@@ -1,24 +1,23 @@
|
||||
package cn.odboy.core.service.system;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.odboy.core.dal.redis.system.SystemRedisKey;
|
||||
import cn.odboy.base.CsResultVo;
|
||||
import cn.odboy.core.dal.dataobject.system.SystemDictDetailTb;
|
||||
import cn.odboy.core.dal.dataobject.system.SystemDictTb;
|
||||
import cn.odboy.core.dal.mysql.system.SystemDictDetailMapper;
|
||||
import cn.odboy.core.dal.mysql.system.SystemDictMapper;
|
||||
import cn.odboy.core.dal.model.system.CreateSystemDictDetailArgs;
|
||||
import cn.odboy.redis.RedisHelper;
|
||||
import cn.odboy.core.dal.model.system.QuerySystemDictDetailArgs;
|
||||
import cn.odboy.core.dal.mysql.system.SystemDictDetailMapper;
|
||||
import cn.odboy.util.PageUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class SystemDictDetailServiceImpl extends ServiceImpl<SystemDictDetailMapper, SystemDictDetailTb> implements SystemDictDetailService {
|
||||
private final SystemDictMapper dictMapper;
|
||||
private final RedisHelper redisHelper;
|
||||
|
||||
private final SystemDictDetailMapper systemDictDetailMapper;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@@ -26,8 +25,6 @@ public class SystemDictDetailServiceImpl extends ServiceImpl<SystemDictDetailMap
|
||||
SystemDictDetailTb dictDetail = BeanUtil.copyProperties(resources, SystemDictDetailTb.class);
|
||||
dictDetail.setDictId(resources.getDict().getId());
|
||||
save(dictDetail);
|
||||
// 清理缓存
|
||||
delCaches(dictDetail);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -37,22 +34,23 @@ public class SystemDictDetailServiceImpl extends ServiceImpl<SystemDictDetailMap
|
||||
resources.setId(dictDetail.getId());
|
||||
// 更新数据
|
||||
saveOrUpdate(resources);
|
||||
// 清理缓存
|
||||
delCaches(dictDetail);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void removeDictDetailById(Long id) {
|
||||
SystemDictDetailTb dictDetail = getById(id);
|
||||
removeById(id);
|
||||
// 清理缓存
|
||||
delCaches(dictDetail);
|
||||
}
|
||||
|
||||
public void delCaches(SystemDictDetailTb dictDetail) {
|
||||
SystemDictTb dict = dictMapper.selectById(dictDetail.getDictId());
|
||||
redisHelper.del(SystemRedisKey.DICT_NAME + dict.getName());
|
||||
|
||||
@Override
|
||||
public CsResultVo<List<SystemDictDetailTb>> queryDictDetailListByArgs(QuerySystemDictDetailArgs criteria, Page<Object> page) {
|
||||
return PageUtil.toPage(systemDictDetailMapper.queryDictDetailListByArgs(criteria, page));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SystemDictDetailTb> describeDictDetailListByName(String name) {
|
||||
return systemDictDetailMapper.queryDictDetailListByDictName(name);
|
||||
}
|
||||
}
|
||||
|
||||
+20
@@ -1,7 +1,10 @@
|
||||
package cn.odboy.core.service.system;
|
||||
|
||||
import cn.odboy.base.CsResultVo;
|
||||
import cn.odboy.core.dal.dataobject.system.SystemDictTb;
|
||||
import cn.odboy.core.dal.model.system.CreateSystemDictArgs;
|
||||
import cn.odboy.core.dal.model.system.QuerySystemDictArgs;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
@@ -40,4 +43,21 @@ public interface SystemDictService extends IService<SystemDictTb> {
|
||||
* @throws IOException /
|
||||
*/
|
||||
void downloadDictExcel(List<SystemDictTb> queryAll, HttpServletResponse response) throws IOException;
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param criteria 条件
|
||||
* @param page 分页参数
|
||||
* @return /
|
||||
*/
|
||||
CsResultVo<List<SystemDictTb>> describeDictPage(QuerySystemDictArgs criteria, Page<SystemDictTb> page);
|
||||
|
||||
/**
|
||||
* 查询全部数据
|
||||
*
|
||||
* @param criteria /
|
||||
* @return /
|
||||
*/
|
||||
List<SystemDictTb> describeDictList(QuerySystemDictArgs criteria);
|
||||
}
|
||||
+19
-15
@@ -2,6 +2,8 @@ package cn.odboy.core.service.system;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.odboy.base.CsResultVo;
|
||||
import cn.odboy.core.dal.model.system.QuerySystemDictArgs;
|
||||
import cn.odboy.core.dal.redis.system.SystemRedisKey;
|
||||
import cn.odboy.core.dal.dataobject.system.SystemDictDetailTb;
|
||||
import cn.odboy.core.dal.dataobject.system.SystemDictTb;
|
||||
@@ -10,6 +12,9 @@ import cn.odboy.core.dal.mysql.system.SystemDictMapper;
|
||||
import cn.odboy.core.dal.model.system.CreateSystemDictArgs;
|
||||
import cn.odboy.redis.RedisHelper;
|
||||
import cn.odboy.util.FileUtil;
|
||||
import cn.odboy.util.PageUtil;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -22,9 +27,8 @@ import java.util.*;
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class SystemDictServiceImpl extends ServiceImpl<SystemDictMapper, SystemDictTb> implements SystemDictService {
|
||||
private final SystemDictMapper dictMapper;
|
||||
private final SystemDictDetailMapper dictDetailMapper;
|
||||
private final RedisHelper redisHelper;
|
||||
private final SystemDictMapper systemDictMapper;
|
||||
private final SystemDictDetailMapper systemDictDetailMapper;
|
||||
|
||||
|
||||
@Override
|
||||
@@ -36,8 +40,6 @@ public class SystemDictServiceImpl extends ServiceImpl<SystemDictMapper, SystemD
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void modifyDictById(SystemDictTb resources) {
|
||||
// 清理缓存
|
||||
delCaches(resources);
|
||||
SystemDictTb dict = getById(resources.getId());
|
||||
dict.setName(resources.getName());
|
||||
dict.setDescription(resources.getDescription());
|
||||
@@ -47,22 +49,17 @@ public class SystemDictServiceImpl extends ServiceImpl<SystemDictMapper, SystemD
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void removeDictByIds(Set<Long> ids) {
|
||||
// 清理缓存
|
||||
List<SystemDictTb> dicts = dictMapper.selectByIds(ids);
|
||||
for (SystemDictTb dict : dicts) {
|
||||
delCaches(dict);
|
||||
}
|
||||
// 删除字典
|
||||
dictMapper.deleteByIds(ids);
|
||||
systemDictMapper.deleteByIds(ids);
|
||||
// 删除字典详情
|
||||
dictDetailMapper.deleteDictDetailByDictIds(ids);
|
||||
systemDictDetailMapper.deleteDictDetailByDictIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void downloadDictExcel(List<SystemDictTb> dicts, HttpServletResponse response) throws IOException {
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
for (SystemDictTb dict : dicts) {
|
||||
List<SystemDictDetailTb> dictDetails = dictDetailMapper.queryDictDetailListByDictName(dict.getName());
|
||||
List<SystemDictDetailTb> dictDetails = systemDictDetailMapper.queryDictDetailListByDictName(dict.getName());
|
||||
if (CollectionUtil.isNotEmpty(dictDetails)) {
|
||||
for (SystemDictDetailTb dictDetail : dictDetails) {
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
@@ -86,7 +83,14 @@ public class SystemDictServiceImpl extends ServiceImpl<SystemDictMapper, SystemD
|
||||
FileUtil.downloadExcel(list, response);
|
||||
}
|
||||
|
||||
public void delCaches(SystemDictTb dict) {
|
||||
redisHelper.del(SystemRedisKey.DICT_NAME + dict.getName());
|
||||
@Override
|
||||
public CsResultVo<List<SystemDictTb>> describeDictPage(QuerySystemDictArgs criteria, Page<SystemDictTb> page) {
|
||||
IPage<SystemDictTb> dicts = systemDictMapper.queryDictPageByArgs(criteria, page);
|
||||
return PageUtil.toPage(dicts);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SystemDictTb> describeDictList(QuerySystemDictArgs criteria) {
|
||||
return systemDictMapper.queryDictPageByArgs(criteria, PageUtil.getCount(systemDictMapper)).getRecords();
|
||||
}
|
||||
}
|
||||
-13
@@ -1,13 +0,0 @@
|
||||
package cn.odboy.core.service.system;
|
||||
|
||||
import cn.odboy.core.dal.dataobject.system.SystemEmailConfigTb;
|
||||
|
||||
public interface SystemEmailApi {
|
||||
|
||||
/**
|
||||
* 查询配置
|
||||
*
|
||||
* @return EmailConfig 邮件配置
|
||||
*/
|
||||
SystemEmailConfigTb describeEmailConfig();
|
||||
}
|
||||
-22
@@ -1,22 +0,0 @@
|
||||
package cn.odboy.core.service.system;
|
||||
|
||||
import cn.odboy.core.dal.dataobject.system.SystemEmailConfigTb;
|
||||
import cn.odboy.core.dal.mysql.system.SystemEmailConfigMapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@CacheConfig(cacheNames = "email")
|
||||
public class SystemEmailApiImpl implements SystemEmailApi {
|
||||
private final SystemEmailConfigMapper emailConfigMapper;
|
||||
|
||||
@Override
|
||||
@Cacheable(key = "'config'")
|
||||
public SystemEmailConfigTb describeEmailConfig() {
|
||||
SystemEmailConfigTb emailConfig = emailConfigMapper.selectById(1L);
|
||||
return emailConfig == null ? new SystemEmailConfigTb() : emailConfig;
|
||||
}
|
||||
}
|
||||
+8
@@ -22,4 +22,12 @@ public interface SystemEmailService extends IService<SystemEmailConfigTb> {
|
||||
* @param sendEmailRequest 邮件发送的内容
|
||||
*/
|
||||
void sendEmail(SendSystemEmailArgs sendEmailRequest);
|
||||
|
||||
|
||||
/**
|
||||
* 查询配置
|
||||
*
|
||||
* @return EmailConfig 邮件配置
|
||||
*/
|
||||
SystemEmailConfigTb describeEmailConfig();
|
||||
}
|
||||
|
||||
+9
-9
@@ -11,24 +11,18 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.cache.annotation.CachePut;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "email")
|
||||
public class SystemEmailServiceImpl extends ServiceImpl<SystemEmailConfigMapper, SystemEmailConfigTb> implements SystemEmailService {
|
||||
@Lazy
|
||||
@Autowired
|
||||
private SystemEmailService emailService;
|
||||
@Autowired
|
||||
private SystemEmailApi emailApi;
|
||||
|
||||
@Override
|
||||
@CachePut(key = "'config'")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void modifyEmailConfigOnPassChange(SystemEmailConfigTb emailConfig) throws Exception {
|
||||
SystemEmailConfigTb localConfig = emailApi.describeEmailConfig();
|
||||
SystemEmailConfigTb localConfig = describeEmailConfig();
|
||||
if (!emailConfig.getPassword().equals(localConfig.getPassword())) {
|
||||
// 对称加密
|
||||
emailConfig.setPassword(DesEncryptUtil.desEncrypt(emailConfig.getPassword()));
|
||||
@@ -41,7 +35,7 @@ public class SystemEmailServiceImpl extends ServiceImpl<SystemEmailConfigMapper,
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void sendEmail(SendSystemEmailArgs sendEmailRequest) {
|
||||
SystemEmailConfigTb emailConfig = emailApi.describeEmailConfig();
|
||||
SystemEmailConfigTb emailConfig = describeEmailConfig();
|
||||
if (emailConfig.getId() == null) {
|
||||
throw new BadRequestException("请先配置,再操作");
|
||||
}
|
||||
@@ -83,4 +77,10 @@ public class SystemEmailServiceImpl extends ServiceImpl<SystemEmailConfigMapper,
|
||||
throw new BadRequestException("邮件发送失败");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public SystemEmailConfigTb describeEmailConfig() {
|
||||
SystemEmailConfigTb emailConfig = getById(1L);
|
||||
return emailConfig == null ? new SystemEmailConfigTb() : emailConfig;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
package cn.odboy.core.service.system;
|
||||
|
||||
import cn.odboy.base.CsResultVo;
|
||||
import cn.odboy.core.dal.dataobject.system.SystemJobTb;
|
||||
import cn.odboy.core.dal.model.system.QuerySystemJobArgs;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public interface SystemJobApi {
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param criteria 条件
|
||||
* @param page 分页参数
|
||||
* @return /
|
||||
*/
|
||||
CsResultVo<List<SystemJobTb>> describeJobPage(QuerySystemJobArgs criteria, Page<SystemJobTb> page);
|
||||
|
||||
/**
|
||||
* 查询全部数据
|
||||
*
|
||||
* @param criteria /
|
||||
* @return /
|
||||
*/
|
||||
List<SystemJobTb> describeJobList(QuerySystemJobArgs criteria);
|
||||
|
||||
|
||||
/**
|
||||
* 验证是否被用户关联
|
||||
*
|
||||
* @param ids /
|
||||
*/
|
||||
void verifyBindRelationByIds(Set<Long> ids);
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
*
|
||||
* @param id /
|
||||
* @return /
|
||||
*/
|
||||
SystemJobTb describeJobById(Long id);
|
||||
}
|
||||
-55
@@ -1,55 +0,0 @@
|
||||
package cn.odboy.core.service.system;
|
||||
|
||||
import cn.odboy.base.CsResultVo;
|
||||
import cn.odboy.core.dal.redis.system.SystemRedisKey;
|
||||
import cn.odboy.core.dal.dataobject.system.SystemJobTb;
|
||||
import cn.odboy.core.dal.mysql.system.SystemJobMapper;
|
||||
import cn.odboy.core.dal.mysql.system.SystemUserMapper;
|
||||
import cn.odboy.core.dal.model.system.QuerySystemJobArgs;
|
||||
import cn.odboy.exception.BadRequestException;
|
||||
import cn.odboy.redis.RedisHelper;
|
||||
import cn.odboy.util.PageUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class SystemJobApiImpl implements SystemJobApi {
|
||||
private final SystemJobMapper jobMapper;
|
||||
private final SystemUserMapper userMapper;
|
||||
private final RedisHelper redisHelper;
|
||||
|
||||
@Override
|
||||
public CsResultVo<List<SystemJobTb>> describeJobPage(QuerySystemJobArgs criteria, Page<SystemJobTb> page) {
|
||||
return PageUtil.toPage(jobMapper.queryJobPageByArgs(criteria, page));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SystemJobTb> describeJobList(QuerySystemJobArgs criteria) {
|
||||
return jobMapper.queryJobPageByArgs(criteria, PageUtil.getCount(jobMapper)).getRecords();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SystemJobTb describeJobById(Long id) {
|
||||
String key = SystemRedisKey.JOB_ID + id;
|
||||
SystemJobTb job = redisHelper.get(key, SystemJobTb.class);
|
||||
if (job == null) {
|
||||
job = jobMapper.selectById(id);
|
||||
redisHelper.set(key, job, 1, TimeUnit.DAYS);
|
||||
}
|
||||
return job;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void verifyBindRelationByIds(Set<Long> ids) {
|
||||
if (userMapper.getUserCountByJobIds(ids) > 0) {
|
||||
throw new BadRequestException("所选的岗位中存在用户关联,请解除关联再试!");
|
||||
}
|
||||
}
|
||||
}
|
||||
+34
@@ -1,7 +1,10 @@
|
||||
package cn.odboy.core.service.system;
|
||||
|
||||
import cn.odboy.base.CsResultVo;
|
||||
import cn.odboy.core.dal.dataobject.system.SystemJobTb;
|
||||
import cn.odboy.core.dal.model.system.CreateSystemJobArgs;
|
||||
import cn.odboy.core.dal.model.system.QuerySystemJobArgs;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
@@ -40,5 +43,36 @@ public interface SystemJobService extends IService<SystemJobTb> {
|
||||
* @throws IOException /
|
||||
*/
|
||||
void downloadJobExcel(List<SystemJobTb> jobs, HttpServletResponse response) throws IOException;
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param criteria 条件
|
||||
* @param page 分页参数
|
||||
* @return /
|
||||
*/
|
||||
CsResultVo<List<SystemJobTb>> describeJobPage(QuerySystemJobArgs criteria, Page<SystemJobTb> page);
|
||||
|
||||
/**
|
||||
* 查询全部数据
|
||||
*
|
||||
* @param criteria /
|
||||
* @return /
|
||||
*/
|
||||
List<SystemJobTb> describeJobList(QuerySystemJobArgs criteria);
|
||||
|
||||
|
||||
/**
|
||||
* 验证是否被用户关联
|
||||
*
|
||||
* @param ids /
|
||||
*/
|
||||
void verifyBindRelationByIds(Set<Long> ids);
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
*
|
||||
* @param id /
|
||||
* @return /
|
||||
*/
|
||||
SystemJobTb describeJobById(Long id);
|
||||
}
|
||||
+37
-16
@@ -1,33 +1,39 @@
|
||||
package cn.odboy.core.service.system;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.odboy.core.dal.redis.system.SystemRedisKey;
|
||||
import cn.odboy.base.CsResultVo;
|
||||
import cn.odboy.core.dal.dataobject.system.SystemJobTb;
|
||||
import cn.odboy.core.dal.mysql.system.SystemJobMapper;
|
||||
import cn.odboy.core.dal.model.system.CreateSystemJobArgs;
|
||||
import cn.odboy.core.dal.model.system.QuerySystemJobArgs;
|
||||
import cn.odboy.core.dal.mysql.system.SystemJobMapper;
|
||||
import cn.odboy.core.dal.mysql.system.SystemUserMapper;
|
||||
import cn.odboy.exception.BadRequestException;
|
||||
import cn.odboy.exception.EntityExistException;
|
||||
import cn.odboy.redis.RedisHelper;
|
||||
import cn.odboy.util.FileUtil;
|
||||
import cn.odboy.util.PageUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class SystemJobServiceImpl extends ServiceImpl<SystemJobMapper, SystemJobTb> implements SystemJobService {
|
||||
private final SystemJobMapper jobMapper;
|
||||
private final RedisHelper redisHelper;
|
||||
|
||||
private final SystemJobMapper systemJobMapper;
|
||||
private final SystemUserMapper systemUserMapper;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void saveJob(CreateSystemJobArgs resources) {
|
||||
SystemJobTb job = jobMapper.getJobByName(resources.getName());
|
||||
SystemJobTb job = systemJobMapper.getJobByName(resources.getName());
|
||||
if (job != null) {
|
||||
throw new EntityExistException(SystemJobTb.class, "name", resources.getName());
|
||||
}
|
||||
@@ -38,22 +44,18 @@ public class SystemJobServiceImpl extends ServiceImpl<SystemJobMapper, SystemJob
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void modifyJobById(SystemJobTb resources) {
|
||||
SystemJobTb job = getById(resources.getId());
|
||||
SystemJobTb old = jobMapper.getJobByName(resources.getName());
|
||||
SystemJobTb old = systemJobMapper.getJobByName(resources.getName());
|
||||
if (old != null && !old.getId().equals(resources.getId())) {
|
||||
throw new EntityExistException(SystemJobTb.class, "name", resources.getName());
|
||||
}
|
||||
resources.setId(job.getId());
|
||||
saveOrUpdate(resources);
|
||||
// 删除缓存
|
||||
delCaches(resources.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void removeJobByIds(Set<Long> ids) {
|
||||
removeBatchByIds(ids);
|
||||
// 删除缓存
|
||||
ids.forEach(this::delCaches);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -70,7 +72,26 @@ public class SystemJobServiceImpl extends ServiceImpl<SystemJobMapper, SystemJob
|
||||
}
|
||||
|
||||
|
||||
public void delCaches(Long id) {
|
||||
redisHelper.del(SystemRedisKey.JOB_ID + id);
|
||||
@Override
|
||||
public CsResultVo<List<SystemJobTb>> describeJobPage(QuerySystemJobArgs criteria, Page<SystemJobTb> page) {
|
||||
return PageUtil.toPage(systemJobMapper.queryJobPageByArgs(criteria, page));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SystemJobTb> describeJobList(QuerySystemJobArgs criteria) {
|
||||
return systemJobMapper.queryJobPageByArgs(criteria, PageUtil.getCount(systemJobMapper)).getRecords();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SystemJobTb describeJobById(Long id) {
|
||||
return systemJobMapper.selectById(id);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void verifyBindRelationByIds(Set<Long> ids) {
|
||||
if (systemUserMapper.getUserCountByJobIds(ids) > 0) {
|
||||
throw new BadRequestException("所选的岗位中存在用户关联,请解除关联再试!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
-28
@@ -1,28 +0,0 @@
|
||||
package cn.odboy.core.service.system;
|
||||
|
||||
import cn.odboy.base.CsResultVo;
|
||||
import cn.odboy.core.dal.dataobject.system.SystemLocalStorageTb;
|
||||
import cn.odboy.core.dal.model.system.QuerySystemLocalStorageArgs;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface SystemLocalStorageApi {
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param criteria 条件
|
||||
* @param page 分页参数
|
||||
* @return /
|
||||
*/
|
||||
CsResultVo<List<SystemLocalStorageTb>> describeLocalStoragePage(QuerySystemLocalStorageArgs criteria, Page<SystemLocalStorageTb> page);
|
||||
|
||||
/**
|
||||
* 查询全部数据
|
||||
*
|
||||
* @param criteria 条件
|
||||
* @return /
|
||||
*/
|
||||
List<SystemLocalStorageTb> describeLocalStorageList(QuerySystemLocalStorageArgs criteria);
|
||||
}
|
||||
-28
@@ -1,28 +0,0 @@
|
||||
package cn.odboy.core.service.system;
|
||||
|
||||
import cn.odboy.base.CsResultVo;
|
||||
import cn.odboy.core.dal.dataobject.system.SystemLocalStorageTb;
|
||||
import cn.odboy.core.dal.mysql.system.SystemLocalStorageMapper;
|
||||
import cn.odboy.core.dal.model.system.QuerySystemLocalStorageArgs;
|
||||
import cn.odboy.util.PageUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class SystemLocalStorageApiImpl implements SystemLocalStorageApi {
|
||||
private final SystemLocalStorageMapper localStorageMapper;
|
||||
|
||||
@Override
|
||||
public CsResultVo<List<SystemLocalStorageTb>> describeLocalStoragePage(QuerySystemLocalStorageArgs criteria, Page<SystemLocalStorageTb> page) {
|
||||
return PageUtil.toPage(localStorageMapper.queryLocalStoragePageByArgs(criteria, page));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SystemLocalStorageTb> describeLocalStorageList(QuerySystemLocalStorageArgs criteria) {
|
||||
return localStorageMapper.queryLocalStoragePageByArgs(criteria, PageUtil.getCount(localStorageMapper)).getRecords();
|
||||
}
|
||||
}
|
||||
+20
@@ -1,6 +1,9 @@
|
||||
package cn.odboy.core.service.system;
|
||||
|
||||
import cn.odboy.base.CsResultVo;
|
||||
import cn.odboy.core.dal.dataobject.system.SystemLocalStorageTb;
|
||||
import cn.odboy.core.dal.model.system.QuerySystemLocalStorageArgs;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@@ -41,4 +44,21 @@ public interface SystemLocalStorageService extends IService<SystemLocalStorageTb
|
||||
* @throws IOException /
|
||||
*/
|
||||
void downloadExcel(List<SystemLocalStorageTb> localStorages, HttpServletResponse response) throws IOException;
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param criteria 条件
|
||||
* @param page 分页参数
|
||||
* @return /
|
||||
*/
|
||||
CsResultVo<List<SystemLocalStorageTb>> describeLocalStoragePage(QuerySystemLocalStorageArgs criteria, Page<SystemLocalStorageTb> page);
|
||||
|
||||
/**
|
||||
* 查询全部数据
|
||||
*
|
||||
* @param criteria 条件
|
||||
* @return /
|
||||
*/
|
||||
List<SystemLocalStorageTb> describeLocalStorageList(QuerySystemLocalStorageArgs criteria);
|
||||
}
|
||||
+15
-1
@@ -1,12 +1,16 @@
|
||||
package cn.odboy.core.service.system;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.odboy.base.CsResultVo;
|
||||
import cn.odboy.core.dal.dataobject.system.SystemLocalStorageTb;
|
||||
import cn.odboy.core.dal.model.system.QuerySystemLocalStorageArgs;
|
||||
import cn.odboy.core.dal.mysql.system.SystemLocalStorageMapper;
|
||||
import cn.odboy.core.framework.properties.AppProperties;
|
||||
import cn.odboy.exception.BadRequestException;
|
||||
import cn.odboy.util.FileUtil;
|
||||
import cn.odboy.util.PageUtil;
|
||||
import cn.odboy.util.StringUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -25,7 +29,7 @@ import java.util.Map;
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class SystemLocalStorageServiceImpl extends ServiceImpl<SystemLocalStorageMapper, SystemLocalStorageTb> implements SystemLocalStorageService {
|
||||
private final SystemLocalStorageMapper localStorageMapper;
|
||||
private final SystemLocalStorageMapper systemLocalStorageMapper;
|
||||
private final AppProperties properties;
|
||||
|
||||
@Override
|
||||
@@ -91,4 +95,14 @@ public class SystemLocalStorageServiceImpl extends ServiceImpl<SystemLocalStorag
|
||||
}
|
||||
FileUtil.downloadExcel(list, response);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CsResultVo<List<SystemLocalStorageTb>> describeLocalStoragePage(QuerySystemLocalStorageArgs criteria, Page<SystemLocalStorageTb> page) {
|
||||
return PageUtil.toPage(systemLocalStorageMapper.queryLocalStoragePageByArgs(criteria, page));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SystemLocalStorageTb> describeLocalStorageList(QuerySystemLocalStorageArgs criteria) {
|
||||
return systemLocalStorageMapper.queryLocalStoragePageByArgs(criteria, PageUtil.getCount(systemLocalStorageMapper)).getRecords();
|
||||
}
|
||||
}
|
||||
|
||||
-78
@@ -1,78 +0,0 @@
|
||||
package cn.odboy.core.service.system;
|
||||
|
||||
import cn.odboy.core.dal.dataobject.system.SystemMenuTb;
|
||||
import cn.odboy.core.dal.model.system.QuerySystemMenuArgs;
|
||||
import cn.odboy.core.dal.model.system.SystemMenuVo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public interface SystemMenuApi {
|
||||
/**
|
||||
* 查询全部数据
|
||||
*
|
||||
* @param criteria 条件
|
||||
* @param isQuery /
|
||||
* @return /
|
||||
* @throws Exception /
|
||||
*/
|
||||
List<SystemMenuTb> describeMenuList(QuerySystemMenuArgs criteria, Boolean isQuery) throws Exception;
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
*
|
||||
* @param id /
|
||||
* @return /
|
||||
*/
|
||||
SystemMenuTb describeMenuById(long id);
|
||||
|
||||
/**
|
||||
* 获取所有子节点,包含自身ID
|
||||
*
|
||||
* @param menuList /
|
||||
* @param menuSet /
|
||||
* @return /
|
||||
*/
|
||||
Set<SystemMenuTb> describeChildMenuSet(List<SystemMenuTb> menuList, Set<SystemMenuTb> menuSet);
|
||||
|
||||
/**
|
||||
* 构建菜单树
|
||||
*
|
||||
* @param menus 原始数据
|
||||
* @return /
|
||||
*/
|
||||
List<SystemMenuTb> buildMenuTree(List<SystemMenuTb> menus);
|
||||
|
||||
/**
|
||||
* 构建菜单树
|
||||
*
|
||||
* @param menus /
|
||||
* @return /
|
||||
*/
|
||||
List<SystemMenuVo> buildMenuVo(List<SystemMenuTb> menus);
|
||||
|
||||
/**
|
||||
* 懒加载菜单数据
|
||||
*
|
||||
* @param pid /
|
||||
* @return /
|
||||
*/
|
||||
List<SystemMenuTb> describeMenuListByPid(Long pid);
|
||||
|
||||
/**
|
||||
* 根据ID获取同级与上级数据
|
||||
*
|
||||
* @param menu /
|
||||
* @param objects /
|
||||
* @return /
|
||||
*/
|
||||
List<SystemMenuTb> describeSuperiorMenuList(SystemMenuTb menu, List<SystemMenuTb> objects);
|
||||
|
||||
/**
|
||||
* 根据当前用户获取菜单
|
||||
*
|
||||
* @param currentUserId /
|
||||
* @return /
|
||||
*/
|
||||
List<SystemMenuTb> describeMenuListByUserId(Long currentUserId);
|
||||
}
|
||||
-205
@@ -1,205 +0,0 @@
|
||||
package cn.odboy.core.service.system;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.odboy.core.dal.redis.system.SystemRedisKey;
|
||||
import cn.odboy.core.dal.dataobject.system.SystemMenuTb;
|
||||
import cn.odboy.core.dal.dataobject.system.SystemRoleTb;
|
||||
import cn.odboy.core.dal.model.system.SystemMenuVo;
|
||||
import cn.odboy.core.dal.mysql.system.SystemMenuMapper;
|
||||
import cn.odboy.core.dal.model.system.SystemMenuMetaVo;
|
||||
import cn.odboy.core.dal.model.system.QuerySystemMenuArgs;
|
||||
import cn.odboy.redis.RedisHelper;
|
||||
import cn.odboy.util.ClassUtil;
|
||||
import cn.odboy.util.StringUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class SystemMenuApiImpl implements SystemMenuApi {
|
||||
private final SystemMenuMapper menuMapper;
|
||||
private final SystemRoleApi systemRoleApi;
|
||||
private final SystemRoleService systemRoleService;
|
||||
private final RedisHelper redisHelper;
|
||||
|
||||
@Override
|
||||
public List<SystemMenuTb> describeMenuList(QuerySystemMenuArgs criteria, Boolean isQuery) throws Exception {
|
||||
if (Boolean.TRUE.equals(isQuery)) {
|
||||
criteria.setPidIsNull(true);
|
||||
List<Field> fields = ClassUtil.getAllFields(criteria.getClass(), new ArrayList<>());
|
||||
for (Field field : fields) {
|
||||
//设置对象的访问权限,保证对private的属性的访问
|
||||
field.setAccessible(true);
|
||||
Object val = field.get(criteria);
|
||||
if ("pidIsNull".equals(field.getName())) {
|
||||
continue;
|
||||
}
|
||||
// 如果有查询条件,则不指定pidIsNull
|
||||
if (ObjectUtil.isNotNull(val)) {
|
||||
criteria.setPidIsNull(null);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return menuMapper.queryMenuListByArgs(criteria);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SystemMenuTb describeMenuById(long id) {
|
||||
String key = SystemRedisKey.MENU_ID + id;
|
||||
SystemMenuTb menu = redisHelper.get(key, SystemMenuTb.class);
|
||||
if (menu == null) {
|
||||
menu = menuMapper.selectById(id);
|
||||
redisHelper.set(key, menu, 1, TimeUnit.DAYS);
|
||||
}
|
||||
return menu;
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户角色改变时需清理缓存
|
||||
*
|
||||
* @param currentUserId /
|
||||
* @return /
|
||||
*/
|
||||
@Override
|
||||
public List<SystemMenuTb> describeMenuListByUserId(Long currentUserId) {
|
||||
String key = SystemRedisKey.MENU_USER + currentUserId;
|
||||
List<SystemMenuTb> menus = redisHelper.getList(key, SystemMenuTb.class);
|
||||
if (CollUtil.isEmpty(menus)) {
|
||||
List<SystemRoleTb> roles = systemRoleApi.describeRoleListByUsersId(currentUserId);
|
||||
Set<Long> roleIds = roles.stream().map(SystemRoleTb::getId).collect(Collectors.toSet());
|
||||
menus = new ArrayList<>(menuMapper.queryMenuSetByRoleIdsAndType(roleIds, 2));
|
||||
redisHelper.set(key, menus, 1, TimeUnit.DAYS);
|
||||
}
|
||||
return menus;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<SystemMenuTb> describeChildMenuSet(List<SystemMenuTb> menuList, Set<SystemMenuTb> menuSet) {
|
||||
for (SystemMenuTb menu : menuList) {
|
||||
menuSet.add(menu);
|
||||
List<SystemMenuTb> menus = menuMapper.queryMenuListByPidOrderByMenuSort(menu.getId());
|
||||
if (CollUtil.isNotEmpty(menus)) {
|
||||
describeChildMenuSet(menus, menuSet);
|
||||
}
|
||||
}
|
||||
return menuSet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SystemMenuTb> describeMenuListByPid(Long pid) {
|
||||
List<SystemMenuTb> menus;
|
||||
if (pid != null && !pid.equals(0L)) {
|
||||
menus = menuMapper.queryMenuListByPidOrderByMenuSort(pid);
|
||||
} else {
|
||||
menus = menuMapper.queryMenuListByPidIsNullOrderByMenuSort();
|
||||
}
|
||||
return menus;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SystemMenuTb> describeSuperiorMenuList(SystemMenuTb menu, List<SystemMenuTb> menus) {
|
||||
if (menu.getPid() == null) {
|
||||
menus.addAll(menuMapper.queryMenuListByPidIsNullOrderByMenuSort());
|
||||
return menus;
|
||||
}
|
||||
menus.addAll(menuMapper.queryMenuListByPidOrderByMenuSort(menu.getPid()));
|
||||
return describeSuperiorMenuList(describeMenuById(menu.getPid()), menus);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SystemMenuTb> buildMenuTree(List<SystemMenuTb> menus) {
|
||||
List<SystemMenuTb> trees = new ArrayList<>();
|
||||
Set<Long> ids = new HashSet<>();
|
||||
for (SystemMenuTb menu : menus) {
|
||||
if (menu.getPid() == null) {
|
||||
trees.add(menu);
|
||||
}
|
||||
for (SystemMenuTb it : menus) {
|
||||
if (menu.getId().equals(it.getPid())) {
|
||||
if (menu.getChildren() == null) {
|
||||
menu.setChildren(new ArrayList<>());
|
||||
}
|
||||
menu.getChildren().add(it);
|
||||
ids.add(it.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (CollUtil.isNotEmpty(trees)) {
|
||||
trees = menus.stream().filter(s -> !ids.contains(s.getId())).collect(Collectors.toList());
|
||||
}
|
||||
return trees;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SystemMenuVo> buildMenuVo(List<SystemMenuTb> menus) {
|
||||
List<SystemMenuVo> list = new LinkedList<>();
|
||||
menus.forEach(menu -> {
|
||||
if (menu != null) {
|
||||
List<SystemMenuTb> menuList = menu.getChildren();
|
||||
SystemMenuVo menuVo = new SystemMenuVo();
|
||||
menuVo.setName(ObjectUtil.isNotEmpty(menu.getComponentName()) ? menu.getComponentName() : menu.getTitle());
|
||||
// 一级目录需要加斜杠,不然会报警告
|
||||
menuVo.setPath(menu.getPid() == null ? "/" + menu.getPath() : menu.getPath());
|
||||
menuVo.setHidden(menu.getHidden());
|
||||
// 如果不是外链
|
||||
if (!menu.getIFrame()) {
|
||||
if (menu.getPid() == null) {
|
||||
menuVo.setComponent(StringUtil.isEmpty(menu.getComponent()) ? "Layout" : menu.getComponent());
|
||||
// 如果不是一级菜单,并且菜单类型为目录,则代表是多级菜单
|
||||
} else if (menu.getType() == 0) {
|
||||
menuVo.setComponent(StringUtil.isEmpty(menu.getComponent()) ? "ParentView" : menu.getComponent());
|
||||
} else if (StringUtil.isNoneBlank(menu.getComponent())) {
|
||||
menuVo.setComponent(menu.getComponent());
|
||||
}
|
||||
}
|
||||
menuVo.setMeta(new SystemMenuMetaVo(menu.getTitle(), menu.getIcon(), !menu.getCache()));
|
||||
if (CollectionUtil.isNotEmpty(menuList)) {
|
||||
menuVo.setAlwaysShow(true);
|
||||
menuVo.setRedirect("noredirect");
|
||||
menuVo.setChildren(buildMenuVo(menuList));
|
||||
// 处理是一级菜单并且没有子菜单的情况
|
||||
} else if (menu.getPid() == null) {
|
||||
SystemMenuVo menuVo1 = getMenuVo(menu, menuVo);
|
||||
menuVo.setName(null);
|
||||
menuVo.setMeta(null);
|
||||
menuVo.setComponent("Layout");
|
||||
List<SystemMenuVo> list1 = new ArrayList<>();
|
||||
list1.add(menuVo1);
|
||||
menuVo.setChildren(list1);
|
||||
}
|
||||
list.add(menuVo);
|
||||
}
|
||||
}
|
||||
);
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 MenuResponse
|
||||
*
|
||||
* @param menu /
|
||||
* @param menuVo /
|
||||
* @return /
|
||||
*/
|
||||
private static SystemMenuVo getMenuVo(SystemMenuTb menu, SystemMenuVo menuVo) {
|
||||
SystemMenuVo menuVo1 = new SystemMenuVo();
|
||||
menuVo1.setMeta(menuVo.getMeta());
|
||||
// 非外链
|
||||
if (!menu.getIFrame()) {
|
||||
menuVo1.setPath("index");
|
||||
menuVo1.setName(menuVo.getName());
|
||||
menuVo1.setComponent(menuVo.getComponent());
|
||||
} else {
|
||||
menuVo1.setPath(menu.getPath());
|
||||
}
|
||||
return menuVo1;
|
||||
}
|
||||
}
|
||||
+68
@@ -1,6 +1,8 @@
|
||||
package cn.odboy.core.service.system;
|
||||
|
||||
import cn.odboy.core.dal.dataobject.system.SystemMenuTb;
|
||||
import cn.odboy.core.dal.model.system.QuerySystemMenuArgs;
|
||||
import cn.odboy.core.dal.model.system.SystemMenuVo;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
@@ -43,5 +45,71 @@ public interface SystemMenuService extends IService<SystemMenuTb> {
|
||||
*/
|
||||
void downloadMenuExcel(List<SystemMenuTb> menus, HttpServletResponse response) throws IOException;
|
||||
|
||||
/**
|
||||
* 查询全部数据
|
||||
*
|
||||
* @param criteria 条件
|
||||
* @param isQuery /
|
||||
* @return /
|
||||
* @throws Exception /
|
||||
*/
|
||||
List<SystemMenuTb> describeMenuList(QuerySystemMenuArgs criteria, Boolean isQuery) throws Exception;
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
*
|
||||
* @param id /
|
||||
* @return /
|
||||
*/
|
||||
SystemMenuTb describeMenuById(long id);
|
||||
|
||||
/**
|
||||
* 获取所有子节点,包含自身ID
|
||||
*
|
||||
* @param menuList /
|
||||
* @param menuSet /
|
||||
* @return /
|
||||
*/
|
||||
Set<SystemMenuTb> describeChildMenuSet(List<SystemMenuTb> menuList, Set<SystemMenuTb> menuSet);
|
||||
|
||||
/**
|
||||
* 构建菜单树
|
||||
*
|
||||
* @param menus 原始数据
|
||||
* @return /
|
||||
*/
|
||||
List<SystemMenuTb> buildMenuTree(List<SystemMenuTb> menus);
|
||||
|
||||
/**
|
||||
* 构建菜单树
|
||||
*
|
||||
* @param menus /
|
||||
* @return /
|
||||
*/
|
||||
List<SystemMenuVo> buildMenuVo(List<SystemMenuTb> menus);
|
||||
|
||||
/**
|
||||
* 懒加载菜单数据
|
||||
*
|
||||
* @param pid /
|
||||
* @return /
|
||||
*/
|
||||
List<SystemMenuTb> describeMenuListByPid(Long pid);
|
||||
|
||||
/**
|
||||
* 根据ID获取同级与上级数据
|
||||
*
|
||||
* @param menu /
|
||||
* @param objects /
|
||||
* @return /
|
||||
*/
|
||||
List<SystemMenuTb> describeSuperiorMenuList(SystemMenuTb menu, List<SystemMenuTb> objects);
|
||||
|
||||
/**
|
||||
* 根据当前用户获取菜单
|
||||
*
|
||||
* @param currentUserId /
|
||||
* @return /
|
||||
*/
|
||||
List<SystemMenuTb> describeMenuListByUserId(Long currentUserId);
|
||||
}
|
||||
|
||||
+183
-32
@@ -1,38 +1,46 @@
|
||||
package cn.odboy.core.service.system;
|
||||
|
||||
import cn.odboy.core.service.system.SystemRoleApi;
|
||||
import cn.odboy.core.dal.redis.system.SystemRedisKey;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.odboy.core.constant.TransferProtocolConst;
|
||||
import cn.odboy.core.dal.dataobject.system.SystemMenuTb;
|
||||
import cn.odboy.core.dal.dataobject.system.SystemRoleTb;
|
||||
import cn.odboy.core.dal.dataobject.system.SystemUserTb;
|
||||
import cn.odboy.core.dal.model.system.QuerySystemMenuArgs;
|
||||
import cn.odboy.core.dal.model.system.SystemMenuMetaVo;
|
||||
import cn.odboy.core.dal.model.system.SystemMenuVo;
|
||||
import cn.odboy.core.dal.mysql.system.SystemMenuMapper;
|
||||
import cn.odboy.core.dal.mysql.system.SystemRoleMenuMapper;
|
||||
import cn.odboy.core.dal.mysql.system.SystemUserMapper;
|
||||
import cn.odboy.exception.BadRequestException;
|
||||
import cn.odboy.exception.EntityExistException;
|
||||
import cn.odboy.redis.RedisHelper;
|
||||
import cn.odboy.util.ClassUtil;
|
||||
import cn.odboy.util.FileUtil;
|
||||
import cn.odboy.util.StringUtil;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class SystemMenuServiceImpl extends ServiceImpl<SystemMenuMapper, SystemMenuTb> implements SystemMenuService {
|
||||
private final SystemMenuMapper menuMapper;
|
||||
private final SystemRoleMenuMapper roleMenuMapper;
|
||||
private final SystemUserMapper userMapper;
|
||||
private final SystemRoleApi systemRoleApi;
|
||||
private final RedisHelper redisHelper;
|
||||
private final SystemMenuMapper systemMenuMapper;
|
||||
private final SystemRoleMenuMapper systemRoleMenuMapper;
|
||||
private final SystemUserMapper systemUserMapper;
|
||||
private final SystemRoleService systemRoleService;
|
||||
|
||||
private static final String YES_STR = "是";
|
||||
private static final String NO_STR = "否";
|
||||
@@ -41,11 +49,11 @@ public class SystemMenuServiceImpl extends ServiceImpl<SystemMenuMapper, SystemM
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void saveMenu(SystemMenuTb resources) {
|
||||
if (menuMapper.getMenuByTitle(resources.getTitle()) != null) {
|
||||
if (systemMenuMapper.getMenuByTitle(resources.getTitle()) != null) {
|
||||
throw new EntityExistException(SystemMenuTb.class, "title", resources.getTitle());
|
||||
}
|
||||
if (StringUtil.isNotBlank(resources.getComponentName())) {
|
||||
if (menuMapper.getMenuByComponentName(resources.getComponentName()) != null) {
|
||||
if (systemMenuMapper.getMenuByComponentName(resources.getComponentName()) != null) {
|
||||
throw new EntityExistException(SystemMenuTb.class, "componentName", resources.getComponentName());
|
||||
}
|
||||
}
|
||||
@@ -76,7 +84,7 @@ public class SystemMenuServiceImpl extends ServiceImpl<SystemMenuMapper, SystemM
|
||||
throw new BadRequestException(TransferProtocolConst.PREFIX_HTTPS_BAD_REQUEST);
|
||||
}
|
||||
}
|
||||
SystemMenuTb menu1 = menuMapper.getMenuByTitle(resources.getTitle());
|
||||
SystemMenuTb menu1 = systemMenuMapper.getMenuByTitle(resources.getTitle());
|
||||
|
||||
if (menu1 != null && !menu1.getId().equals(menu.getId())) {
|
||||
throw new EntityExistException(SystemMenuTb.class, "title", resources.getTitle());
|
||||
@@ -91,7 +99,7 @@ public class SystemMenuServiceImpl extends ServiceImpl<SystemMenuMapper, SystemM
|
||||
Long newPid = resources.getPid();
|
||||
|
||||
if (StringUtil.isNotBlank(resources.getComponentName())) {
|
||||
menu1 = menuMapper.getMenuByComponentName(resources.getComponentName());
|
||||
menu1 = systemMenuMapper.getMenuByComponentName(resources.getComponentName());
|
||||
if (menu1 != null && !menu1.getId().equals(menu.getId())) {
|
||||
throw new EntityExistException(SystemMenuTb.class, "componentName", resources.getComponentName());
|
||||
}
|
||||
@@ -112,8 +120,6 @@ public class SystemMenuServiceImpl extends ServiceImpl<SystemMenuMapper, SystemM
|
||||
// 计算父级菜单节点数目
|
||||
updateSubCnt(oldPid);
|
||||
updateSubCnt(newPid);
|
||||
// 清理缓存
|
||||
delCaches(resources.getId());
|
||||
}
|
||||
|
||||
|
||||
@@ -121,10 +127,8 @@ public class SystemMenuServiceImpl extends ServiceImpl<SystemMenuMapper, SystemM
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void removeMenuByIds(Set<SystemMenuTb> menuSet) {
|
||||
for (SystemMenuTb menu : menuSet) {
|
||||
// 清理缓存
|
||||
delCaches(menu.getId());
|
||||
roleMenuMapper.deleteByMenuId(menu.getId());
|
||||
menuMapper.deleteById(menu.getId());
|
||||
systemRoleMenuMapper.deleteByMenuId(menu.getId());
|
||||
systemMenuMapper.deleteById(menu.getId());
|
||||
updateSubCnt(menu.getPid());
|
||||
}
|
||||
}
|
||||
@@ -149,23 +153,170 @@ public class SystemMenuServiceImpl extends ServiceImpl<SystemMenuMapper, SystemM
|
||||
|
||||
private void updateSubCnt(Long menuId) {
|
||||
if (menuId != null) {
|
||||
int count = menuMapper.getMenuCountByPid(menuId);
|
||||
menuMapper.updateSubCntByMenuId(count, menuId);
|
||||
int count = systemMenuMapper.getMenuCountByPid(menuId);
|
||||
systemMenuMapper.updateSubCntByMenuId(count, menuId);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SystemMenuTb> describeMenuList(QuerySystemMenuArgs criteria, Boolean isQuery) throws Exception {
|
||||
if (Boolean.TRUE.equals(isQuery)) {
|
||||
criteria.setPidIsNull(true);
|
||||
List<Field> fields = ClassUtil.getAllFields(criteria.getClass(), new ArrayList<>());
|
||||
for (Field field : fields) {
|
||||
//设置对象的访问权限,保证对private的属性的访问
|
||||
field.setAccessible(true);
|
||||
Object val = field.get(criteria);
|
||||
if ("pidIsNull".equals(field.getName())) {
|
||||
continue;
|
||||
}
|
||||
// 如果有查询条件,则不指定pidIsNull
|
||||
if (ObjectUtil.isNotNull(val)) {
|
||||
criteria.setPidIsNull(null);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return systemMenuMapper.queryMenuListByArgs(criteria);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SystemMenuTb describeMenuById(long id) {
|
||||
return systemMenuMapper.selectById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 清理缓存
|
||||
* 用户角色改变时需清理缓存
|
||||
*
|
||||
* @param id 菜单ID
|
||||
* @param currentUserId /
|
||||
* @return /
|
||||
*/
|
||||
public void delCaches(Long id) {
|
||||
List<SystemUserTb> users = userMapper.queryUserListByMenuId(id);
|
||||
redisHelper.del(SystemRedisKey.MENU_ID + id);
|
||||
redisHelper.delByKeys(SystemRedisKey.MENU_USER, users.stream().map(SystemUserTb::getId).collect(Collectors.toSet()));
|
||||
// 清除 Role 缓存
|
||||
List<SystemRoleTb> roles = systemRoleApi.describeRoleListByMenuId(id);
|
||||
redisHelper.delByKeys(SystemRedisKey.ROLE_ID, roles.stream().map(SystemRoleTb::getId).collect(Collectors.toSet()));
|
||||
@Override
|
||||
public List<SystemMenuTb> describeMenuListByUserId(Long currentUserId) {
|
||||
List<SystemRoleTb> roles = systemRoleService.describeRoleListByUsersId(currentUserId);
|
||||
Set<Long> roleIds = roles.stream().map(SystemRoleTb::getId).collect(Collectors.toSet());
|
||||
return new ArrayList<>(systemMenuMapper.queryMenuSetByRoleIdsAndType(roleIds, 2));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<SystemMenuTb> describeChildMenuSet(List<SystemMenuTb> menuList, Set<SystemMenuTb> menuSet) {
|
||||
for (SystemMenuTb menu : menuList) {
|
||||
menuSet.add(menu);
|
||||
List<SystemMenuTb> menus = systemMenuMapper.queryMenuListByPidOrderByMenuSort(menu.getId());
|
||||
if (CollUtil.isNotEmpty(menus)) {
|
||||
describeChildMenuSet(menus, menuSet);
|
||||
}
|
||||
}
|
||||
return menuSet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SystemMenuTb> describeMenuListByPid(Long pid) {
|
||||
List<SystemMenuTb> menus;
|
||||
if (pid != null && !pid.equals(0L)) {
|
||||
menus = systemMenuMapper.queryMenuListByPidOrderByMenuSort(pid);
|
||||
} else {
|
||||
menus = systemMenuMapper.queryMenuListByPidIsNullOrderByMenuSort();
|
||||
}
|
||||
return menus;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SystemMenuTb> describeSuperiorMenuList(SystemMenuTb menu, List<SystemMenuTb> menus) {
|
||||
if (menu.getPid() == null) {
|
||||
menus.addAll(systemMenuMapper.queryMenuListByPidIsNullOrderByMenuSort());
|
||||
return menus;
|
||||
}
|
||||
menus.addAll(systemMenuMapper.queryMenuListByPidOrderByMenuSort(menu.getPid()));
|
||||
return describeSuperiorMenuList(describeMenuById(menu.getPid()), menus);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SystemMenuTb> buildMenuTree(List<SystemMenuTb> menus) {
|
||||
List<SystemMenuTb> trees = new ArrayList<>();
|
||||
Set<Long> ids = new HashSet<>();
|
||||
for (SystemMenuTb menu : menus) {
|
||||
if (menu.getPid() == null) {
|
||||
trees.add(menu);
|
||||
}
|
||||
for (SystemMenuTb it : menus) {
|
||||
if (menu.getId().equals(it.getPid())) {
|
||||
if (menu.getChildren() == null) {
|
||||
menu.setChildren(new ArrayList<>());
|
||||
}
|
||||
menu.getChildren().add(it);
|
||||
ids.add(it.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (CollUtil.isNotEmpty(trees)) {
|
||||
trees = menus.stream().filter(s -> !ids.contains(s.getId())).collect(Collectors.toList());
|
||||
}
|
||||
return trees;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SystemMenuVo> buildMenuVo(List<SystemMenuTb> menus) {
|
||||
List<SystemMenuVo> list = new LinkedList<>();
|
||||
menus.forEach(menu -> {
|
||||
if (menu != null) {
|
||||
List<SystemMenuTb> menuList = menu.getChildren();
|
||||
SystemMenuVo menuVo = new SystemMenuVo();
|
||||
menuVo.setName(ObjectUtil.isNotEmpty(menu.getComponentName()) ? menu.getComponentName() : menu.getTitle());
|
||||
// 一级目录需要加斜杠,不然会报警告
|
||||
menuVo.setPath(menu.getPid() == null ? "/" + menu.getPath() : menu.getPath());
|
||||
menuVo.setHidden(menu.getHidden());
|
||||
// 如果不是外链
|
||||
if (!menu.getIFrame()) {
|
||||
if (menu.getPid() == null) {
|
||||
menuVo.setComponent(StringUtil.isEmpty(menu.getComponent()) ? "Layout" : menu.getComponent());
|
||||
// 如果不是一级菜单,并且菜单类型为目录,则代表是多级菜单
|
||||
} else if (menu.getType() == 0) {
|
||||
menuVo.setComponent(StringUtil.isEmpty(menu.getComponent()) ? "ParentView" : menu.getComponent());
|
||||
} else if (StringUtil.isNoneBlank(menu.getComponent())) {
|
||||
menuVo.setComponent(menu.getComponent());
|
||||
}
|
||||
}
|
||||
menuVo.setMeta(new SystemMenuMetaVo(menu.getTitle(), menu.getIcon(), !menu.getCache()));
|
||||
if (CollectionUtil.isNotEmpty(menuList)) {
|
||||
menuVo.setAlwaysShow(true);
|
||||
menuVo.setRedirect("noredirect");
|
||||
menuVo.setChildren(buildMenuVo(menuList));
|
||||
// 处理是一级菜单并且没有子菜单的情况
|
||||
} else if (menu.getPid() == null) {
|
||||
SystemMenuVo menuVo1 = getMenuVo(menu, menuVo);
|
||||
menuVo.setName(null);
|
||||
menuVo.setMeta(null);
|
||||
menuVo.setComponent("Layout");
|
||||
List<SystemMenuVo> list1 = new ArrayList<>();
|
||||
list1.add(menuVo1);
|
||||
menuVo.setChildren(list1);
|
||||
}
|
||||
list.add(menuVo);
|
||||
}
|
||||
}
|
||||
);
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 MenuResponse
|
||||
*
|
||||
* @param menu /
|
||||
* @param menuVo /
|
||||
* @return /
|
||||
*/
|
||||
private static SystemMenuVo getMenuVo(SystemMenuTb menu, SystemMenuVo menuVo) {
|
||||
SystemMenuVo menuVo1 = new SystemMenuVo();
|
||||
menuVo1.setMeta(menuVo.getMeta());
|
||||
// 非外链
|
||||
if (!menu.getIFrame()) {
|
||||
menuVo1.setPath("index");
|
||||
menuVo1.setName(menuVo.getName());
|
||||
menuVo1.setComponent(menuVo.getComponent());
|
||||
} else {
|
||||
menuVo1.setPath(menu.getPath());
|
||||
}
|
||||
return menuVo1;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@ package cn.odboy.core.service.system;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface SystemMonitorApi {
|
||||
public interface SystemMonitorService {
|
||||
|
||||
/**
|
||||
* 查询服务器监控信息
|
||||
+1
-1
@@ -24,7 +24,7 @@ import java.util.*;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class SystemMonitorApiImpl implements SystemMonitorApi {
|
||||
public class SystemMonitorServiceImpl implements SystemMonitorService {
|
||||
private final DecimalFormat df = new DecimalFormat("0.00");
|
||||
|
||||
@Override
|
||||
-13
@@ -1,13 +0,0 @@
|
||||
package cn.odboy.core.service.system;
|
||||
|
||||
import cn.odboy.core.dal.dataobject.system.SystemQiniuConfigTb;
|
||||
|
||||
public interface SystemQiniuConfigApi {
|
||||
|
||||
/**
|
||||
* 查询配置
|
||||
*
|
||||
* @return QiniuConfig
|
||||
*/
|
||||
SystemQiniuConfigTb describeQiniuConfig();
|
||||
}
|
||||
-22
@@ -1,22 +0,0 @@
|
||||
package cn.odboy.core.service.system;
|
||||
|
||||
import cn.odboy.core.dal.dataobject.system.SystemQiniuConfigTb;
|
||||
import cn.odboy.core.dal.mysql.system.SystemQiniuConfigMapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@CacheConfig(cacheNames = "qiNiu")
|
||||
public class SystemQiniuConfigApiImpl implements SystemQiniuConfigApi {
|
||||
private final SystemQiniuConfigMapper qiniuConfigMapper;
|
||||
|
||||
@Override
|
||||
@Cacheable(key = "'config'")
|
||||
public SystemQiniuConfigTb describeQiniuConfig() {
|
||||
SystemQiniuConfigTb qiniuConfig = qiniuConfigMapper.selectById(1L);
|
||||
return qiniuConfig == null ? new SystemQiniuConfigTb() : qiniuConfig;
|
||||
}
|
||||
}
|
||||
+7
@@ -19,4 +19,11 @@ public interface SystemQiniuConfigService extends IService<SystemQiniuConfigTb>
|
||||
* @param type 类型
|
||||
*/
|
||||
void modifyQiniuConfigType(String type);
|
||||
|
||||
/**
|
||||
* 查询配置
|
||||
*
|
||||
* @return QiniuConfig
|
||||
*/
|
||||
SystemQiniuConfigTb describeQiniuConfig();
|
||||
}
|
||||
|
||||
+10
-4
@@ -8,18 +8,17 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@CacheConfig(cacheNames = "qiNiu")
|
||||
public class SystemQiniuConfigServiceImpl extends ServiceImpl<SystemQiniuConfigMapper, SystemQiniuConfigTb> implements SystemQiniuConfigService {
|
||||
|
||||
private final SystemQiniuConfigMapper systemQiniuConfigMapper;
|
||||
|
||||
@Override
|
||||
@CacheEvict(key = "'config'")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void saveQiniuConfig(SystemQiniuConfigTb qiniuConfig) {
|
||||
qiniuConfig.setId(1L);
|
||||
@@ -30,11 +29,18 @@ public class SystemQiniuConfigServiceImpl extends ServiceImpl<SystemQiniuConfigM
|
||||
}
|
||||
|
||||
@Override
|
||||
@CacheEvict(key = "'config'")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void modifyQiniuConfigType(String type) {
|
||||
SystemQiniuConfigTb qiniuConfig = getById(1L);
|
||||
qiniuConfig.setType(type);
|
||||
saveOrUpdate(qiniuConfig);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public SystemQiniuConfigTb describeQiniuConfig() {
|
||||
SystemQiniuConfigTb qiniuConfig = systemQiniuConfigMapper.selectById(1L);
|
||||
return qiniuConfig == null ? new SystemQiniuConfigTb() : qiniuConfig;
|
||||
}
|
||||
}
|
||||
|
||||
-28
@@ -1,28 +0,0 @@
|
||||
package cn.odboy.core.service.system;
|
||||
|
||||
import cn.odboy.base.CsResultVo;
|
||||
import cn.odboy.core.dal.dataobject.system.SystemQiniuContentTb;
|
||||
import cn.odboy.core.dal.model.system.QuerySystemQiniuArgs;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface SystemQiniuContentApi {
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param criteria 条件
|
||||
* @param page 分页参数
|
||||
* @return /
|
||||
*/
|
||||
CsResultVo<List<SystemQiniuContentTb>> describeQiniuContentPage(QuerySystemQiniuArgs criteria, Page<SystemQiniuContentTb> page);
|
||||
|
||||
/**
|
||||
* 查询全部
|
||||
*
|
||||
* @param criteria 条件
|
||||
* @return /
|
||||
*/
|
||||
List<SystemQiniuContentTb> describeQiniuContentList(QuerySystemQiniuArgs criteria);
|
||||
}
|
||||
-30
@@ -1,30 +0,0 @@
|
||||
package cn.odboy.core.service.system;
|
||||
|
||||
import cn.odboy.base.CsResultVo;
|
||||
import cn.odboy.core.dal.dataobject.system.SystemQiniuContentTb;
|
||||
import cn.odboy.core.dal.mysql.system.SystemQiniuContentMapper;
|
||||
import cn.odboy.core.dal.model.system.QuerySystemQiniuArgs;
|
||||
import cn.odboy.util.PageUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@CacheConfig(cacheNames = "qiNiu")
|
||||
public class SystemQiniuContentApiImpl implements SystemQiniuContentApi {
|
||||
private final SystemQiniuContentMapper qiniuContentMapper;
|
||||
|
||||
@Override
|
||||
public CsResultVo<List<SystemQiniuContentTb>> describeQiniuContentPage(QuerySystemQiniuArgs criteria, Page<SystemQiniuContentTb> page) {
|
||||
return PageUtil.toPage(qiniuContentMapper.queryQiniuContentPageByArgs(criteria, page));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SystemQiniuContentTb> describeQiniuContentList(QuerySystemQiniuArgs criteria) {
|
||||
return qiniuContentMapper.queryQiniuContentPageByArgs(criteria, PageUtil.getCount(qiniuContentMapper)).getRecords();
|
||||
}
|
||||
}
|
||||
+19
@@ -1,6 +1,9 @@
|
||||
package cn.odboy.core.service.system;
|
||||
|
||||
import cn.odboy.base.CsResultVo;
|
||||
import cn.odboy.core.dal.dataobject.system.SystemQiniuContentTb;
|
||||
import cn.odboy.core.dal.model.system.QuerySystemQiniuArgs;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@@ -53,4 +56,20 @@ public interface SystemQiniuContentService extends IService<SystemQiniuContentTb
|
||||
* @param id 文件id
|
||||
*/
|
||||
void removeFileById(Long id);
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param criteria 条件
|
||||
* @param page 分页参数
|
||||
* @return /
|
||||
*/
|
||||
CsResultVo<List<SystemQiniuContentTb>> describeQiniuContentPage(QuerySystemQiniuArgs criteria, Page<SystemQiniuContentTb> page);
|
||||
|
||||
/**
|
||||
* 查询全部
|
||||
*
|
||||
* @param criteria 条件
|
||||
* @return /
|
||||
*/
|
||||
List<SystemQiniuContentTb> describeQiniuContentList(QuerySystemQiniuArgs criteria);
|
||||
}
|
||||
|
||||
+24
-12
@@ -1,12 +1,16 @@
|
||||
package cn.odboy.core.service.system;
|
||||
|
||||
import cn.odboy.base.CsResultVo;
|
||||
import cn.odboy.core.dal.dataobject.system.SystemQiniuConfigTb;
|
||||
import cn.odboy.core.dal.dataobject.system.SystemQiniuContentTb;
|
||||
import cn.odboy.core.dal.model.system.QuerySystemQiniuArgs;
|
||||
import cn.odboy.core.dal.mysql.system.SystemQiniuContentMapper;
|
||||
import cn.odboy.core.util.QiniuUtil;
|
||||
import cn.odboy.exception.BadRequestException;
|
||||
import cn.odboy.util.FileUtil;
|
||||
import cn.odboy.util.PageUtil;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.qiniu.common.QiniuException;
|
||||
import com.qiniu.http.Response;
|
||||
@@ -32,11 +36,9 @@ import java.util.Map;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@CacheConfig(cacheNames = "qiNiu")
|
||||
public class SystemQiniuContentServiceImpl extends ServiceImpl<SystemQiniuContentMapper, SystemQiniuContentTb> implements SystemQiniuContentService {
|
||||
private final SystemQiniuContentMapper qiniuContentMapper;
|
||||
private final SystemQiniuConfigApi qiniuConfigApi;
|
||||
|
||||
private final SystemQiniuContentMapper systemQiniuContentMapper;
|
||||
private final SystemQiniuConfigService systemQiniuConfigService;
|
||||
@Value("${app.oss.qiniu.max-size}")
|
||||
private Long maxSize;
|
||||
|
||||
@@ -44,7 +46,7 @@ public class SystemQiniuContentServiceImpl extends ServiceImpl<SystemQiniuConten
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public SystemQiniuContentTb uploadFile(MultipartFile file) {
|
||||
FileUtil.checkSize(maxSize, file.getSize());
|
||||
SystemQiniuConfigTb qiniuConfig = qiniuConfigApi.describeQiniuConfig();
|
||||
SystemQiniuConfigTb qiniuConfig = systemQiniuConfigService.describeQiniuConfig();
|
||||
if (qiniuConfig.getId() == null) {
|
||||
throw new BadRequestException("请先添加相应配置,再操作");
|
||||
}
|
||||
@@ -55,14 +57,14 @@ public class SystemQiniuContentServiceImpl extends ServiceImpl<SystemQiniuConten
|
||||
String upToken = auth.uploadToken(qiniuConfig.getBucket());
|
||||
try {
|
||||
String key = file.getOriginalFilename();
|
||||
if (qiniuContentMapper.getQiniuContentByName(key) != null) {
|
||||
if (systemQiniuContentMapper.getQiniuContentByName(key) != null) {
|
||||
key = QiniuUtil.getKey(key);
|
||||
}
|
||||
Response response = uploadManager.put(file.getBytes(), key, upToken);
|
||||
// 解析上传成功的结果
|
||||
DefaultPutRet putRet = JSON.parseObject(response.bodyString(), DefaultPutRet.class);
|
||||
String fileNameNoExt = FileUtil.getPrefix(putRet.key);
|
||||
SystemQiniuContentTb content = qiniuContentMapper.getQiniuContentByName(fileNameNoExt);
|
||||
SystemQiniuContentTb content = systemQiniuContentMapper.getQiniuContentByName(fileNameNoExt);
|
||||
if (content == null) {
|
||||
// 存入数据库
|
||||
SystemQiniuContentTb qiniuContent = new SystemQiniuContentTb();
|
||||
@@ -82,7 +84,7 @@ public class SystemQiniuContentServiceImpl extends ServiceImpl<SystemQiniuConten
|
||||
|
||||
@Override
|
||||
public String createFilePreviewUrl(SystemQiniuContentTb content) {
|
||||
SystemQiniuConfigTb qiniuConfig = qiniuConfigApi.describeQiniuConfig();
|
||||
SystemQiniuConfigTb qiniuConfig = systemQiniuConfigService.describeQiniuConfig();
|
||||
String finalUrl;
|
||||
String type = "公开";
|
||||
if (type.equals(content.getType())) {
|
||||
@@ -99,8 +101,8 @@ public class SystemQiniuContentServiceImpl extends ServiceImpl<SystemQiniuConten
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void removeFileById(Long id) {
|
||||
SystemQiniuConfigTb qiniuConfig = qiniuConfigApi.describeQiniuConfig();
|
||||
SystemQiniuContentTb qiniuContent = qiniuContentMapper.selectById(id);
|
||||
SystemQiniuConfigTb qiniuConfig = systemQiniuConfigService.describeQiniuConfig();
|
||||
SystemQiniuContentTb qiniuContent = systemQiniuContentMapper.selectById(id);
|
||||
if (qiniuContent == null) {
|
||||
throw new BadRequestException("文件不存在");
|
||||
}
|
||||
@@ -120,7 +122,7 @@ public class SystemQiniuContentServiceImpl extends ServiceImpl<SystemQiniuConten
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void synchronize() {
|
||||
SystemQiniuConfigTb qiniuConfig = qiniuConfigApi.describeQiniuConfig();
|
||||
SystemQiniuConfigTb qiniuConfig = systemQiniuConfigService.describeQiniuConfig();
|
||||
if (qiniuConfig.getId() == null) {
|
||||
throw new BadRequestException("请先添加相应配置,再操作");
|
||||
}
|
||||
@@ -143,7 +145,7 @@ public class SystemQiniuContentServiceImpl extends ServiceImpl<SystemQiniuConten
|
||||
for (FileInfo item : items) {
|
||||
String filename = FileUtil.getPrefix(item.key);
|
||||
String suffix = FileUtil.getSuffix(item.key);
|
||||
if (qiniuContentMapper.getQiniuContentByName(filename) == null) {
|
||||
if (systemQiniuContentMapper.getQiniuContentByName(filename) == null) {
|
||||
qiniuContent = new SystemQiniuContentTb();
|
||||
qiniuContent.setSize(FileUtil.getSize(Integer.parseInt(String.valueOf(item.fsize))));
|
||||
qiniuContent.setSuffix(suffix);
|
||||
@@ -183,4 +185,14 @@ public class SystemQiniuContentServiceImpl extends ServiceImpl<SystemQiniuConten
|
||||
}
|
||||
FileUtil.downloadExcel(list, response);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CsResultVo<List<SystemQiniuContentTb>> describeQiniuContentPage(QuerySystemQiniuArgs criteria, Page<SystemQiniuContentTb> page) {
|
||||
return PageUtil.toPage(systemQiniuContentMapper.queryQiniuContentPageByArgs(criteria, page));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SystemQiniuContentTb> describeQiniuContentList(QuerySystemQiniuArgs criteria) {
|
||||
return systemQiniuContentMapper.queryQiniuContentPageByArgs(criteria, PageUtil.getCount(systemQiniuContentMapper)).getRecords();
|
||||
}
|
||||
}
|
||||
|
||||
-45
@@ -1,45 +0,0 @@
|
||||
package cn.odboy.core.service.system;
|
||||
|
||||
import cn.odboy.base.CsResultVo;
|
||||
import cn.odboy.core.dal.dataobject.system.SystemQuartzJobTb;
|
||||
import cn.odboy.core.dal.dataobject.system.SystemQuartzLogTb;
|
||||
import cn.odboy.core.dal.model.system.QuerySystemQuartzJobArgs;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface SystemQuartzJobApi {
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param criteria 条件
|
||||
* @param page 分页参数
|
||||
* @return /
|
||||
*/
|
||||
CsResultVo<List<SystemQuartzJobTb>> describeQuartzJobPage(QuerySystemQuartzJobArgs criteria, Page<SystemQuartzJobTb> page);
|
||||
|
||||
/**
|
||||
* 查询全部
|
||||
*
|
||||
* @param criteria 条件
|
||||
* @return /
|
||||
*/
|
||||
List<SystemQuartzJobTb> describeQuartzJobList(QuerySystemQuartzJobArgs criteria);
|
||||
|
||||
/**
|
||||
* 分页查询日志
|
||||
*
|
||||
* @param criteria 条件
|
||||
* @param page 分页参数
|
||||
* @return /
|
||||
*/
|
||||
CsResultVo<List<SystemQuartzLogTb>> describeQuartzLogPage(QuerySystemQuartzJobArgs criteria, Page<SystemQuartzLogTb> page);
|
||||
|
||||
/**
|
||||
* 查询全部
|
||||
*
|
||||
* @param criteria 条件
|
||||
* @return /
|
||||
*/
|
||||
List<SystemQuartzLogTb> describeQuartzLogList(QuerySystemQuartzJobArgs criteria);
|
||||
}
|
||||
-41
@@ -1,41 +0,0 @@
|
||||
package cn.odboy.core.service.system;
|
||||
|
||||
import cn.odboy.base.CsResultVo;
|
||||
import cn.odboy.core.dal.dataobject.system.SystemQuartzJobTb;
|
||||
import cn.odboy.core.dal.dataobject.system.SystemQuartzLogTb;
|
||||
import cn.odboy.core.dal.mysql.system.SystemQuartzJobMapper;
|
||||
import cn.odboy.core.dal.mysql.system.SystemQuartzLogMapper;
|
||||
import cn.odboy.core.dal.model.system.QuerySystemQuartzJobArgs;
|
||||
import cn.odboy.util.PageUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class SystemQuartzJobApiImpl implements SystemQuartzJobApi {
|
||||
private final SystemQuartzJobMapper quartzJobMapper;
|
||||
private final SystemQuartzLogMapper quartzLogMapper;
|
||||
|
||||
@Override
|
||||
public CsResultVo<List<SystemQuartzJobTb>> describeQuartzJobPage(QuerySystemQuartzJobArgs criteria, Page<SystemQuartzJobTb> page) {
|
||||
return PageUtil.toPage(quartzJobMapper.queryQuartzJobPageByArgs(criteria, page));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CsResultVo<List<SystemQuartzLogTb>> describeQuartzLogPage(QuerySystemQuartzJobArgs criteria, Page<SystemQuartzLogTb> page) {
|
||||
return PageUtil.toPage(quartzLogMapper.queryQuartzLogPageByArgs(criteria, page));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SystemQuartzJobTb> describeQuartzJobList(QuerySystemQuartzJobArgs criteria) {
|
||||
return quartzJobMapper.queryQuartzJobPageByArgs(criteria, PageUtil.getCount(quartzJobMapper)).getRecords();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SystemQuartzLogTb> describeQuartzLogList(QuerySystemQuartzJobArgs criteria) {
|
||||
return quartzLogMapper.queryQuartzLogPageByArgs(criteria, PageUtil.getCount(quartzLogMapper)).getRecords();
|
||||
}
|
||||
}
|
||||
+37
@@ -1,8 +1,11 @@
|
||||
package cn.odboy.core.service.system;
|
||||
|
||||
import cn.odboy.base.CsResultVo;
|
||||
import cn.odboy.core.dal.dataobject.system.SystemQuartzJobTb;
|
||||
import cn.odboy.core.dal.dataobject.system.SystemQuartzLogTb;
|
||||
import cn.odboy.core.dal.model.system.QuerySystemQuartzJobArgs;
|
||||
import cn.odboy.core.dal.model.system.UpdateSystemQuartzJobArgs;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
@@ -72,4 +75,38 @@ public interface SystemQuartzJobService extends IService<SystemQuartzJobTb> {
|
||||
* @throws InterruptedException /
|
||||
*/
|
||||
void startSubQuartJob(String[] tasks) throws InterruptedException;
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param criteria 条件
|
||||
* @param page 分页参数
|
||||
* @return /
|
||||
*/
|
||||
CsResultVo<List<SystemQuartzJobTb>> describeQuartzJobPage(QuerySystemQuartzJobArgs criteria, Page<SystemQuartzJobTb> page);
|
||||
|
||||
/**
|
||||
* 查询全部
|
||||
*
|
||||
* @param criteria 条件
|
||||
* @return /
|
||||
*/
|
||||
List<SystemQuartzJobTb> describeQuartzJobList(QuerySystemQuartzJobArgs criteria);
|
||||
|
||||
/**
|
||||
* 分页查询日志
|
||||
*
|
||||
* @param criteria 条件
|
||||
* @param page 分页参数
|
||||
* @return /
|
||||
*/
|
||||
CsResultVo<List<SystemQuartzLogTb>> describeQuartzLogPage(QuerySystemQuartzJobArgs criteria, Page<SystemQuartzLogTb> page);
|
||||
|
||||
/**
|
||||
* 查询全部
|
||||
*
|
||||
* @param criteria 条件
|
||||
* @return /
|
||||
*/
|
||||
List<SystemQuartzLogTb> describeQuartzLogList(QuerySystemQuartzJobArgs criteria);
|
||||
}
|
||||
|
||||
+26
-3
@@ -3,8 +3,10 @@ package cn.odboy.core.service.system;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.odboy.base.CsResultVo;
|
||||
import cn.odboy.core.dal.dataobject.system.SystemQuartzJobTb;
|
||||
import cn.odboy.core.dal.dataobject.system.SystemQuartzLogTb;
|
||||
import cn.odboy.core.dal.model.system.QuerySystemQuartzJobArgs;
|
||||
import cn.odboy.core.dal.mysql.system.SystemQuartzJobMapper;
|
||||
import cn.odboy.core.dal.mysql.system.SystemQuartzLogMapper;
|
||||
import cn.odboy.core.framework.quartz.core.QuartzManage;
|
||||
@@ -12,7 +14,9 @@ import cn.odboy.core.dal.model.system.UpdateSystemQuartzJobArgs;
|
||||
import cn.odboy.exception.BadRequestException;
|
||||
import cn.odboy.redis.RedisHelper;
|
||||
import cn.odboy.util.FileUtil;
|
||||
import cn.odboy.util.PageUtil;
|
||||
import cn.odboy.util.StringUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.quartz.CronExpression;
|
||||
@@ -26,9 +30,8 @@ import java.util.*;
|
||||
@RequiredArgsConstructor
|
||||
@Service(value = "quartzJobService")
|
||||
public class SystemQuartzJobServiceImpl extends ServiceImpl<SystemQuartzJobMapper, SystemQuartzJobTb> implements SystemQuartzJobService {
|
||||
|
||||
private final SystemQuartzJobMapper quartzJobMapper;
|
||||
private final SystemQuartzLogMapper quartzLogMapper;
|
||||
private final SystemQuartzJobMapper systemQuartzJobMapper;
|
||||
private final SystemQuartzLogMapper systemQuartzLogMapper;
|
||||
private final QuartzManage quartzManage;
|
||||
private final RedisHelper redisHelper;
|
||||
|
||||
@@ -157,4 +160,24 @@ public class SystemQuartzJobServiceImpl extends ServiceImpl<SystemQuartzJobMappe
|
||||
}
|
||||
FileUtil.downloadExcel(list, response);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CsResultVo<List<SystemQuartzJobTb>> describeQuartzJobPage(QuerySystemQuartzJobArgs criteria, Page<SystemQuartzJobTb> page) {
|
||||
return PageUtil.toPage(systemQuartzJobMapper.queryQuartzJobPageByArgs(criteria, page));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CsResultVo<List<SystemQuartzLogTb>> describeQuartzLogPage(QuerySystemQuartzJobArgs criteria, Page<SystemQuartzLogTb> page) {
|
||||
return PageUtil.toPage(systemQuartzLogMapper.queryQuartzLogPageByArgs(criteria, page));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SystemQuartzJobTb> describeQuartzJobList(QuerySystemQuartzJobArgs criteria) {
|
||||
return systemQuartzJobMapper.queryQuartzJobPageByArgs(criteria, PageUtil.getCount(systemQuartzJobMapper)).getRecords();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SystemQuartzLogTb> describeQuartzLogList(QuerySystemQuartzJobArgs criteria) {
|
||||
return systemQuartzLogMapper.queryQuartzLogPageByArgs(criteria, PageUtil.getCount(systemQuartzLogMapper)).getRecords();
|
||||
}
|
||||
}
|
||||
|
||||
-86
@@ -1,86 +0,0 @@
|
||||
package cn.odboy.core.service.system;
|
||||
|
||||
import cn.odboy.base.CsResultVo;
|
||||
import cn.odboy.core.dal.dataobject.system.SystemRoleTb;
|
||||
import cn.odboy.core.dal.dataobject.system.SystemUserTb;
|
||||
import cn.odboy.core.dal.model.system.QuerySystemRoleArgs;
|
||||
import cn.odboy.core.dal.model.system.SystemRoleCodeVo;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public interface SystemRoleApi {
|
||||
|
||||
/**
|
||||
* 查询全部数据
|
||||
*
|
||||
* @return /
|
||||
*/
|
||||
List<SystemRoleTb> describeRoleList();
|
||||
|
||||
/**
|
||||
* 查询全部
|
||||
*
|
||||
* @param criteria 条件
|
||||
* @return /
|
||||
*/
|
||||
List<SystemRoleTb> describeRoleList(QuerySystemRoleArgs criteria);
|
||||
|
||||
/**
|
||||
* 待条件分页查询
|
||||
*
|
||||
* @param criteria 条件
|
||||
* @param page 分页参数
|
||||
* @return /
|
||||
*/
|
||||
CsResultVo<List<SystemRoleTb>> describeRolePage(QuerySystemRoleArgs criteria, Page<Object> page);
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
*
|
||||
* @param id /
|
||||
* @return /
|
||||
*/
|
||||
SystemRoleTb describeRoleById(long id);
|
||||
|
||||
|
||||
/**
|
||||
* 根据用户ID查询
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return /
|
||||
*/
|
||||
List<SystemRoleTb> describeRoleListByUsersId(Long userId);
|
||||
|
||||
/**
|
||||
* 根据角色查询角色级别
|
||||
*
|
||||
* @param roles /
|
||||
* @return /
|
||||
*/
|
||||
Integer describeDeptLevelByRoles(Set<SystemRoleTb> roles);
|
||||
|
||||
/**
|
||||
* 获取用户权限信息
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 权限信息
|
||||
*/
|
||||
List<SystemRoleCodeVo> buildUserRolePermissions(SystemUserTb user);
|
||||
|
||||
/**
|
||||
* 验证是否被用户关联
|
||||
*
|
||||
* @param ids /
|
||||
*/
|
||||
void verifyBindRelationByIds(Set<Long> ids);
|
||||
|
||||
/**
|
||||
* 根据菜单Id查询
|
||||
*
|
||||
* @param menuId /
|
||||
* @return /
|
||||
*/
|
||||
List<SystemRoleTb> describeRoleListByMenuId(Long menuId);
|
||||
}
|
||||
-121
@@ -1,121 +0,0 @@
|
||||
package cn.odboy.core.service.system;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.odboy.base.CsResultVo;
|
||||
import cn.odboy.core.dal.redis.system.SystemRedisKey;
|
||||
import cn.odboy.core.dal.dataobject.system.SystemMenuTb;
|
||||
import cn.odboy.core.dal.dataobject.system.SystemRoleTb;
|
||||
import cn.odboy.core.dal.dataobject.system.SystemUserTb;
|
||||
import cn.odboy.core.dal.mysql.system.SystemRoleMapper;
|
||||
import cn.odboy.core.dal.mysql.system.SystemUserMapper;
|
||||
import cn.odboy.core.dal.model.system.QuerySystemRoleArgs;
|
||||
import cn.odboy.core.dal.model.system.SystemRoleCodeVo;
|
||||
import cn.odboy.exception.BadRequestException;
|
||||
import cn.odboy.redis.RedisHelper;
|
||||
import cn.odboy.util.PageUtil;
|
||||
import cn.odboy.util.StringUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class SystemRoleApiImpl implements SystemRoleApi {
|
||||
private final SystemRoleMapper roleMapper;
|
||||
private final SystemUserMapper userMapper;
|
||||
private final RedisHelper redisHelper;
|
||||
|
||||
@Override
|
||||
public List<SystemRoleTb> describeRoleList() {
|
||||
return roleMapper.queryRoleList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SystemRoleTb> describeRoleList(QuerySystemRoleArgs criteria) {
|
||||
return roleMapper.queryRoleListByArgs(criteria);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CsResultVo<List<SystemRoleTb>> describeRolePage(QuerySystemRoleArgs criteria, Page<Object> page) {
|
||||
criteria.setOffset(page.offset());
|
||||
List<SystemRoleTb> roles = roleMapper.queryRoleListByArgs(criteria);
|
||||
Long total = roleMapper.getRoleCountByArgs(criteria);
|
||||
return PageUtil.toPage(roles, total);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SystemRoleTb describeRoleById(long id) {
|
||||
String key = SystemRedisKey.ROLE_ID + id;
|
||||
SystemRoleTb role = redisHelper.get(key, SystemRoleTb.class);
|
||||
if (role == null) {
|
||||
role = roleMapper.selectById(id);
|
||||
redisHelper.set(key, role, 1, TimeUnit.DAYS);
|
||||
}
|
||||
return role;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SystemRoleTb> describeRoleListByUsersId(Long userId) {
|
||||
String key = SystemRedisKey.ROLE_USER + userId;
|
||||
List<SystemRoleTb> roles = redisHelper.getList(key, SystemRoleTb.class);
|
||||
if (CollUtil.isEmpty(roles)) {
|
||||
roles = roleMapper.queryRoleListByUserId(userId);
|
||||
redisHelper.set(key, roles, 1, TimeUnit.DAYS);
|
||||
}
|
||||
return roles;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer describeDeptLevelByRoles(Set<SystemRoleTb> roles) {
|
||||
if (CollUtil.isEmpty(roles)) {
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
Set<SystemRoleTb> roleSet = new HashSet<>();
|
||||
for (SystemRoleTb role : roles) {
|
||||
roleSet.add(describeRoleById(role.getId()));
|
||||
}
|
||||
return Collections.min(roleSet.stream().map(SystemRoleTb::getLevel).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SystemRoleCodeVo> buildUserRolePermissions(SystemUserTb user) {
|
||||
String key = SystemRedisKey.ROLE_AUTH + user.getId();
|
||||
List<SystemRoleCodeVo> authorityList = redisHelper.getList(key, SystemRoleCodeVo.class);
|
||||
if (CollUtil.isEmpty(authorityList)) {
|
||||
Set<String> permissions = new HashSet<>();
|
||||
// 如果是管理员直接返回
|
||||
if (user.getIsAdmin()) {
|
||||
permissions.add("admin");
|
||||
return permissions.stream().map(SystemRoleCodeVo::new)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
List<SystemRoleTb> roles = roleMapper.queryRoleListByUserId(user.getId());
|
||||
permissions = roles.stream().flatMap(role -> role.getMenus().stream())
|
||||
.map(SystemMenuTb::getPermission)
|
||||
.filter(StringUtil::isNotBlank).collect(Collectors.toSet());
|
||||
authorityList = permissions.stream().map(SystemRoleCodeVo::new)
|
||||
.collect(Collectors.toList());
|
||||
redisHelper.set(key, authorityList, 1, TimeUnit.HOURS);
|
||||
}
|
||||
return authorityList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void verifyBindRelationByIds(Set<Long> ids) {
|
||||
if (userMapper.getUserCountByRoleIds(ids) > 0) {
|
||||
throw new BadRequestException("所选角色存在用户关联,请解除关联再试!");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SystemRoleTb> describeRoleListByMenuId(Long menuId) {
|
||||
return roleMapper.queryRoleListByMenuId(menuId);
|
||||
}
|
||||
}
|
||||
+75
@@ -1,7 +1,12 @@
|
||||
package cn.odboy.core.service.system;
|
||||
|
||||
import cn.odboy.base.CsResultVo;
|
||||
import cn.odboy.core.dal.dataobject.system.SystemRoleTb;
|
||||
import cn.odboy.core.dal.dataobject.system.SystemUserTb;
|
||||
import cn.odboy.core.dal.model.system.CreateSystemRoleArgs;
|
||||
import cn.odboy.core.dal.model.system.QuerySystemRoleArgs;
|
||||
import cn.odboy.core.dal.model.system.SystemRoleCodeVo;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
@@ -50,5 +55,75 @@ public interface SystemRoleService extends IService<SystemRoleTb> {
|
||||
* @throws IOException /
|
||||
*/
|
||||
void downloadRoleExcel(List<SystemRoleTb> roles, HttpServletResponse response) throws IOException;
|
||||
/**
|
||||
* 查询全部数据
|
||||
*
|
||||
* @return /
|
||||
*/
|
||||
List<SystemRoleTb> describeRoleList();
|
||||
|
||||
/**
|
||||
* 查询全部
|
||||
*
|
||||
* @param criteria 条件
|
||||
* @return /
|
||||
*/
|
||||
List<SystemRoleTb> describeRoleList(QuerySystemRoleArgs criteria);
|
||||
|
||||
/**
|
||||
* 待条件分页查询
|
||||
*
|
||||
* @param criteria 条件
|
||||
* @param page 分页参数
|
||||
* @return /
|
||||
*/
|
||||
CsResultVo<List<SystemRoleTb>> describeRolePage(QuerySystemRoleArgs criteria, Page<Object> page);
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
*
|
||||
* @param id /
|
||||
* @return /
|
||||
*/
|
||||
SystemRoleTb describeRoleById(long id);
|
||||
|
||||
|
||||
/**
|
||||
* 根据用户ID查询
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return /
|
||||
*/
|
||||
List<SystemRoleTb> describeRoleListByUsersId(Long userId);
|
||||
|
||||
/**
|
||||
* 根据角色查询角色级别
|
||||
*
|
||||
* @param roles /
|
||||
* @return /
|
||||
*/
|
||||
Integer describeDeptLevelByRoles(Set<SystemRoleTb> roles);
|
||||
|
||||
/**
|
||||
* 获取用户权限信息
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 权限信息
|
||||
*/
|
||||
List<SystemRoleCodeVo> buildUserRolePermissions(SystemUserTb user);
|
||||
|
||||
/**
|
||||
* 验证是否被用户关联
|
||||
*
|
||||
* @param ids /
|
||||
*/
|
||||
void verifyBindRelationByIds(Set<Long> ids);
|
||||
|
||||
/**
|
||||
* 根据菜单Id查询
|
||||
*
|
||||
* @param menuId /
|
||||
* @return /
|
||||
*/
|
||||
List<SystemRoleTb> describeRoleListByMenuId(Long menuId);
|
||||
}
|
||||
|
||||
+97
-44
@@ -3,48 +3,58 @@ package cn.odboy.core.service.system;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.odboy.core.dal.redis.system.SystemUserJwtService;
|
||||
import cn.odboy.core.dal.redis.system.SystemRedisKey;
|
||||
import cn.odboy.base.CsResultVo;
|
||||
import cn.odboy.core.dal.dataobject.system.SystemMenuTb;
|
||||
import cn.odboy.core.dal.dataobject.system.SystemRoleTb;
|
||||
import cn.odboy.core.dal.dataobject.system.SystemUserTb;
|
||||
import cn.odboy.core.dal.model.system.CreateSystemRoleArgs;
|
||||
import cn.odboy.core.dal.model.system.QuerySystemRoleArgs;
|
||||
import cn.odboy.core.dal.model.system.SystemRoleCodeVo;
|
||||
import cn.odboy.core.dal.mysql.system.SystemRoleDeptMapper;
|
||||
import cn.odboy.core.dal.mysql.system.SystemRoleMapper;
|
||||
import cn.odboy.core.dal.mysql.system.SystemRoleMenuMapper;
|
||||
import cn.odboy.core.dal.mysql.system.SystemUserMapper;
|
||||
import cn.odboy.core.dal.model.system.CreateSystemRoleArgs;
|
||||
import cn.odboy.core.dal.redis.system.SystemUserJwtService;
|
||||
import cn.odboy.exception.BadRequestException;
|
||||
import cn.odboy.exception.EntityExistException;
|
||||
import cn.odboy.redis.RedisHelper;
|
||||
import cn.odboy.util.FileUtil;
|
||||
import cn.odboy.util.PageUtil;
|
||||
import cn.odboy.util.StringUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class SystemRoleServiceImpl extends ServiceImpl<SystemRoleMapper, SystemRoleTb> implements SystemRoleService {
|
||||
private final SystemRoleMapper roleMapper;
|
||||
private final SystemRoleDeptMapper roleDeptMapper;
|
||||
private final SystemRoleMenuMapper roleMenuMapper;
|
||||
private final SystemUserMapper userMapper;
|
||||
private final SystemRoleMapper systemRoleMapper;
|
||||
private final SystemRoleDeptMapper systemRoleDeptMapper;
|
||||
private final SystemRoleMenuMapper systemRoleMenuMapper;
|
||||
private final SystemUserMapper systemUserMapper;
|
||||
private final SystemUserJwtService systemUserJwtService;
|
||||
private final RedisHelper redisHelper;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void saveRole(CreateSystemRoleArgs resources) {
|
||||
if (roleMapper.getRoleByName(resources.getName()) != null) {
|
||||
if (systemRoleMapper.getRoleByName(resources.getName()) != null) {
|
||||
throw new EntityExistException(SystemRoleTb.class, "name", resources.getName());
|
||||
}
|
||||
save(BeanUtil.copyProperties(resources, SystemRoleTb.class));
|
||||
// 判断是否有部门数据,若有,则需创建关联
|
||||
if (CollectionUtil.isNotEmpty(resources.getDepts())) {
|
||||
roleDeptMapper.insertBatchWithRoleId(resources.getDepts(), resources.getId());
|
||||
systemRoleDeptMapper.insertBatchWithRoleId(resources.getDepts(), resources.getId());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +62,7 @@ public class SystemRoleServiceImpl extends ServiceImpl<SystemRoleMapper, SystemR
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void modifyRoleById(SystemRoleTb resources) {
|
||||
SystemRoleTb role = getById(resources.getId());
|
||||
SystemRoleTb role1 = roleMapper.getRoleByName(resources.getName());
|
||||
SystemRoleTb role1 = systemRoleMapper.getRoleByName(resources.getName());
|
||||
if (role1 != null && !role1.getId().equals(role.getId())) {
|
||||
throw new EntityExistException(SystemRoleTb.class, "name", resources.getName());
|
||||
}
|
||||
@@ -64,39 +74,31 @@ public class SystemRoleServiceImpl extends ServiceImpl<SystemRoleMapper, SystemR
|
||||
// 更新
|
||||
saveOrUpdate(role);
|
||||
// 删除关联部门数据
|
||||
roleDeptMapper.deleteByRoleId(resources.getId());
|
||||
systemRoleDeptMapper.deleteByRoleId(resources.getId());
|
||||
// 判断是否有部门数据,若有,则需更新关联
|
||||
if (CollectionUtil.isNotEmpty(resources.getDepts())) {
|
||||
roleDeptMapper.insertBatchWithRoleId(resources.getDepts(), resources.getId());
|
||||
systemRoleDeptMapper.insertBatchWithRoleId(resources.getDepts(), resources.getId());
|
||||
}
|
||||
// 更新相关缓存
|
||||
delCaches(role.getId(), null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modifyBindMenuById(SystemRoleTb role) {
|
||||
List<SystemUserTb> users = userMapper.queryUserListByRoleId(role.getId());
|
||||
List<SystemUserTb> users = systemUserMapper.queryUserListByRoleId(role.getId());
|
||||
// 更新菜单
|
||||
roleMenuMapper.deleteByRoleId(role.getId());
|
||||
systemRoleMenuMapper.deleteByRoleId(role.getId());
|
||||
// 判断是否为空
|
||||
if (CollUtil.isNotEmpty(role.getMenus())) {
|
||||
roleMenuMapper.insertBatchWithRoleId(role.getMenus(), role.getId());
|
||||
systemRoleMenuMapper.insertBatchWithRoleId(role.getMenus(), role.getId());
|
||||
}
|
||||
// 更新缓存
|
||||
delCaches(role.getId(), users);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void removeRoleByIds(Set<Long> ids) {
|
||||
for (Long id : ids) {
|
||||
// 更新相关缓存
|
||||
delCaches(id, null);
|
||||
}
|
||||
removeBatchByIds(ids);
|
||||
// 删除角色部门关联数据、角色菜单关联数据
|
||||
roleDeptMapper.deleteByRoleIds(ids);
|
||||
roleMenuMapper.deleteByRoleIds(ids);
|
||||
systemRoleDeptMapper.deleteByRoleIds(ids);
|
||||
systemRoleMenuMapper.deleteByRoleIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -113,21 +115,72 @@ public class SystemRoleServiceImpl extends ServiceImpl<SystemRoleMapper, SystemR
|
||||
FileUtil.downloadExcel(list, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 清理缓存
|
||||
*
|
||||
* @param id /
|
||||
*/
|
||||
public void delCaches(Long id, List<SystemUserTb> users) {
|
||||
users = CollectionUtil.isEmpty(users) ? userMapper.queryUserListByRoleId(id) : users;
|
||||
if (CollectionUtil.isNotEmpty(users)) {
|
||||
users.forEach(item -> systemUserJwtService.cleanUserJwtModelCacheByUsername(item.getUsername()));
|
||||
Set<Long> userIds = users.stream().map(SystemUserTb::getId).collect(Collectors.toSet());
|
||||
redisHelper.delByKeys(SystemRedisKey.DATA_USER, userIds);
|
||||
redisHelper.delByKeys(SystemRedisKey.MENU_USER, userIds);
|
||||
redisHelper.delByKeys(SystemRedisKey.ROLE_AUTH, userIds);
|
||||
redisHelper.delByKeys(SystemRedisKey.ROLE_USER, userIds);
|
||||
@Override
|
||||
public List<SystemRoleTb> describeRoleList() {
|
||||
return systemRoleMapper.queryRoleList();
|
||||
}
|
||||
redisHelper.del(SystemRedisKey.ROLE_ID + id);
|
||||
|
||||
@Override
|
||||
public List<SystemRoleTb> describeRoleList(QuerySystemRoleArgs criteria) {
|
||||
return systemRoleMapper.queryRoleListByArgs(criteria);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CsResultVo<List<SystemRoleTb>> describeRolePage(QuerySystemRoleArgs criteria, Page<Object> page) {
|
||||
criteria.setOffset(page.offset());
|
||||
List<SystemRoleTb> roles = systemRoleMapper.queryRoleListByArgs(criteria);
|
||||
Long total = systemRoleMapper.getRoleCountByArgs(criteria);
|
||||
return PageUtil.toPage(roles, total);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SystemRoleTb describeRoleById(long id) {
|
||||
return systemRoleMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SystemRoleTb> describeRoleListByUsersId(Long userId) {
|
||||
return systemRoleMapper.queryRoleListByUserId(userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer describeDeptLevelByRoles(Set<SystemRoleTb> roles) {
|
||||
if (CollUtil.isEmpty(roles)) {
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
Set<SystemRoleTb> roleSet = new HashSet<>();
|
||||
for (SystemRoleTb role : roles) {
|
||||
roleSet.add(describeRoleById(role.getId()));
|
||||
}
|
||||
return Collections.min(roleSet.stream().map(SystemRoleTb::getLevel).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SystemRoleCodeVo> buildUserRolePermissions(SystemUserTb user) {
|
||||
Set<String> permissions = new HashSet<>();
|
||||
// 如果是管理员直接返回
|
||||
if (user.getIsAdmin()) {
|
||||
permissions.add("admin");
|
||||
return permissions.stream().map(SystemRoleCodeVo::new)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
List<SystemRoleTb> roles = systemRoleMapper.queryRoleListByUserId(user.getId());
|
||||
permissions = roles.stream().flatMap(role -> role.getMenus().stream())
|
||||
.map(SystemMenuTb::getPermission)
|
||||
.filter(StringUtil::isNotBlank).collect(Collectors.toSet());
|
||||
return permissions.stream().map(SystemRoleCodeVo::new)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void verifyBindRelationByIds(Set<Long> ids) {
|
||||
if (systemUserMapper.getUserCountByRoleIds(ids) > 0) {
|
||||
throw new BadRequestException("所选角色存在用户关联,请解除关联再试!");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SystemRoleTb> describeRoleListByMenuId(Long menuId) {
|
||||
return systemRoleMapper.queryRoleListByMenuId(menuId);
|
||||
}
|
||||
}
|
||||
|
||||
-45
@@ -1,45 +0,0 @@
|
||||
package cn.odboy.core.service.system;
|
||||
|
||||
import cn.odboy.base.CsResultVo;
|
||||
import cn.odboy.core.dal.dataobject.system.SystemUserTb;
|
||||
import cn.odboy.core.dal.model.system.QuerySystemUserArgs;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface SystemUserApi {
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
*
|
||||
* @param id ID
|
||||
* @return /
|
||||
*/
|
||||
SystemUserTb describeUserById(long id);
|
||||
|
||||
/**
|
||||
* 根据用户名查询
|
||||
*
|
||||
* @param username /
|
||||
* @return /
|
||||
*/
|
||||
SystemUserTb describeUserByUsername(String username);
|
||||
|
||||
/**
|
||||
* 查询全部
|
||||
*
|
||||
* @param criteria 条件
|
||||
* @param page 分页参数
|
||||
* @return /
|
||||
*/
|
||||
CsResultVo<List<SystemUserTb>> describeUserPage(QuerySystemUserArgs criteria, Page<Object> page);
|
||||
|
||||
/**
|
||||
* 查询全部不分页
|
||||
*
|
||||
* @param criteria 条件
|
||||
* @return /
|
||||
*/
|
||||
List<SystemUserTb> describeUserList(QuerySystemUserArgs criteria);
|
||||
|
||||
}
|
||||
-53
@@ -1,53 +0,0 @@
|
||||
package cn.odboy.core.service.system;
|
||||
|
||||
import cn.odboy.base.CsResultVo;
|
||||
import cn.odboy.core.dal.redis.system.SystemRedisKey;
|
||||
import cn.odboy.core.dal.dataobject.system.SystemUserTb;
|
||||
import cn.odboy.core.dal.mysql.system.SystemUserMapper;
|
||||
import cn.odboy.core.dal.model.system.QuerySystemUserArgs;
|
||||
import cn.odboy.redis.RedisHelper;
|
||||
import cn.odboy.util.PageUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class SystemUserApiImpl implements SystemUserApi {
|
||||
private final SystemUserMapper userMapper;
|
||||
private final RedisHelper redisHelper;
|
||||
|
||||
@Override
|
||||
public CsResultVo<List<SystemUserTb>> describeUserPage(QuerySystemUserArgs criteria, Page<Object> page) {
|
||||
criteria.setOffset(page.offset());
|
||||
List<SystemUserTb> users = userMapper.queryUserPageByArgs(criteria, PageUtil.getCount(userMapper)).getRecords();
|
||||
Long total = userMapper.getUserCountByArgs(criteria);
|
||||
return PageUtil.toPage(users, total);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SystemUserTb> describeUserList(QuerySystemUserArgs criteria) {
|
||||
return userMapper.queryUserPageByArgs(criteria, PageUtil.getCount(userMapper)).getRecords();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public SystemUserTb describeUserById(long id) {
|
||||
String key = SystemRedisKey.USER_ID + id;
|
||||
SystemUserTb user = redisHelper.get(key, SystemUserTb.class);
|
||||
if (user == null) {
|
||||
user = userMapper.selectById(id);
|
||||
redisHelper.set(key, user, 1, TimeUnit.DAYS);
|
||||
}
|
||||
return user;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SystemUserTb describeUserByUsername(String username) {
|
||||
return userMapper.getUserByUsername(username);
|
||||
}
|
||||
}
|
||||
+37
@@ -1,6 +1,9 @@
|
||||
package cn.odboy.core.service.system;
|
||||
|
||||
import cn.odboy.base.CsResultVo;
|
||||
import cn.odboy.core.dal.dataobject.system.SystemUserTb;
|
||||
import cn.odboy.core.dal.model.system.QuerySystemUserArgs;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@@ -80,4 +83,38 @@ public interface SystemUserService extends IService<SystemUserTb> {
|
||||
* @param password 密码
|
||||
*/
|
||||
void resetUserPasswordByIds(Set<Long> ids, String password);
|
||||
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
*
|
||||
* @param id ID
|
||||
* @return /
|
||||
*/
|
||||
SystemUserTb describeUserById(long id);
|
||||
|
||||
/**
|
||||
* 根据用户名查询
|
||||
*
|
||||
* @param username /
|
||||
* @return /
|
||||
*/
|
||||
SystemUserTb describeUserByUsername(String username);
|
||||
|
||||
/**
|
||||
* 查询全部
|
||||
*
|
||||
* @param criteria 条件
|
||||
* @param page 分页参数
|
||||
* @return /
|
||||
*/
|
||||
CsResultVo<List<SystemUserTb>> describeUserPage(QuerySystemUserArgs criteria, Page<Object> page);
|
||||
|
||||
/**
|
||||
* 查询全部不分页
|
||||
*
|
||||
* @param criteria 条件
|
||||
* @return /
|
||||
*/
|
||||
List<SystemUserTb> describeUserList(QuerySystemUserArgs criteria);
|
||||
}
|
||||
|
||||
+71
-62
@@ -1,42 +1,50 @@
|
||||
package cn.odboy.core.service.system;
|
||||
|
||||
import cn.odboy.core.dal.redis.system.SystemUserJwtService;
|
||||
import cn.odboy.core.dal.redis.system.SystemUserOnlineService;
|
||||
import cn.odboy.core.dal.redis.system.SystemRedisKey;
|
||||
import cn.odboy.base.CsResultVo;
|
||||
import cn.odboy.core.dal.dataobject.system.SystemJobTb;
|
||||
import cn.odboy.core.dal.dataobject.system.SystemRoleTb;
|
||||
import cn.odboy.core.dal.dataobject.system.SystemUserTb;
|
||||
import cn.odboy.core.dal.model.system.QuerySystemUserArgs;
|
||||
import cn.odboy.core.dal.mysql.system.SystemUserJobMapper;
|
||||
import cn.odboy.core.dal.mysql.system.SystemUserMapper;
|
||||
import cn.odboy.core.dal.mysql.system.SystemUserRoleMapper;
|
||||
import cn.odboy.core.dal.redis.system.SystemRedisKey;
|
||||
import cn.odboy.core.dal.redis.system.SystemUserJwtService;
|
||||
import cn.odboy.core.dal.redis.system.SystemUserOnlineService;
|
||||
import cn.odboy.core.framework.permission.core.SecurityHelper;
|
||||
import cn.odboy.core.framework.properties.AppProperties;
|
||||
import cn.odboy.exception.BadRequestException;
|
||||
import cn.odboy.exception.EntityExistException;
|
||||
import cn.odboy.redis.RedisHelper;
|
||||
import cn.odboy.util.FileUtil;
|
||||
import cn.odboy.util.PageUtil;
|
||||
import cn.odboy.util.StringUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class SystemUserServiceImpl extends ServiceImpl<SystemUserMapper, SystemUserTb> implements SystemUserService {
|
||||
private final SystemUserMapper userMapper;
|
||||
private final SystemUserJobMapper userJobMapper;
|
||||
private final SystemUserRoleMapper userRoleMapper;
|
||||
private final SystemUserMapper systemUserMapper;
|
||||
private final SystemUserJobMapper systemUserJobMapper;
|
||||
private final SystemUserRoleMapper systemUserRoleMapper;
|
||||
private final AppProperties properties;
|
||||
private final RedisHelper redisHelper;
|
||||
private final SystemUserJwtService systemUserJwtService;
|
||||
private final SystemUserOnlineService systemUserOnlineService;
|
||||
|
||||
@@ -44,29 +52,29 @@ public class SystemUserServiceImpl extends ServiceImpl<SystemUserMapper, SystemU
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void saveUser(SystemUserTb resources) {
|
||||
resources.setDeptId(resources.getDept().getId());
|
||||
if (userMapper.getUserByUsername(resources.getUsername()) != null) {
|
||||
if (systemUserMapper.getUserByUsername(resources.getUsername()) != null) {
|
||||
throw new EntityExistException(SystemUserTb.class, "username", resources.getUsername());
|
||||
}
|
||||
if (userMapper.getUserByEmail(resources.getEmail()) != null) {
|
||||
if (systemUserMapper.getUserByEmail(resources.getEmail()) != null) {
|
||||
throw new EntityExistException(SystemUserTb.class, "email", resources.getEmail());
|
||||
}
|
||||
if (userMapper.getUserByPhone(resources.getPhone()) != null) {
|
||||
if (systemUserMapper.getUserByPhone(resources.getPhone()) != null) {
|
||||
throw new EntityExistException(SystemUserTb.class, "phone", resources.getPhone());
|
||||
}
|
||||
save(resources);
|
||||
// 保存用户岗位
|
||||
userJobMapper.insertBatchWithUserId(resources.getJobs(), resources.getId());
|
||||
systemUserJobMapper.insertBatchWithUserId(resources.getJobs(), resources.getId());
|
||||
// 保存用户角色
|
||||
userRoleMapper.insertBatchWithUserId(resources.getRoles(), resources.getId());
|
||||
systemUserRoleMapper.insertBatchWithUserId(resources.getRoles(), resources.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void modifyUserById(SystemUserTb resources) {
|
||||
SystemUserTb user = getById(resources.getId());
|
||||
SystemUserTb user1 = userMapper.getUserByUsername(resources.getUsername());
|
||||
SystemUserTb user2 = userMapper.getUserByEmail(resources.getEmail());
|
||||
SystemUserTb user3 = userMapper.getUserByPhone(resources.getPhone());
|
||||
SystemUserTb user1 = systemUserMapper.getUserByUsername(resources.getUsername());
|
||||
SystemUserTb user2 = systemUserMapper.getUserByEmail(resources.getEmail());
|
||||
SystemUserTb user3 = systemUserMapper.getUserByPhone(resources.getPhone());
|
||||
if (user1 != null && !user.getId().equals(user1.getId())) {
|
||||
throw new EntityExistException(SystemUserTb.class, "username", resources.getUsername());
|
||||
}
|
||||
@@ -76,17 +84,6 @@ public class SystemUserServiceImpl extends ServiceImpl<SystemUserMapper, SystemU
|
||||
if (user3 != null && !user.getId().equals(user3.getId())) {
|
||||
throw new EntityExistException(SystemUserTb.class, "phone", resources.getPhone());
|
||||
}
|
||||
// 如果用户的角色改变
|
||||
if (!resources.getRoles().equals(user.getRoles())) {
|
||||
redisHelper.del(SystemRedisKey.DATA_USER + resources.getId());
|
||||
redisHelper.del(SystemRedisKey.MENU_USER + resources.getId());
|
||||
redisHelper.del(SystemRedisKey.ROLE_AUTH + resources.getId());
|
||||
redisHelper.del(SystemRedisKey.ROLE_USER + resources.getId());
|
||||
}
|
||||
// 修改部门会影响 数据权限
|
||||
if (!Objects.equals(resources.getDept(), user.getDept())) {
|
||||
redisHelper.del(SystemRedisKey.DATA_USER + resources.getId());
|
||||
}
|
||||
// 如果用户被禁用,则清除用户登录信息
|
||||
if (!resources.getEnabled()) {
|
||||
systemUserOnlineService.kickOutByUsername(resources.getUsername());
|
||||
@@ -102,21 +99,21 @@ public class SystemUserServiceImpl extends ServiceImpl<SystemUserMapper, SystemU
|
||||
user.setNickName(resources.getNickName());
|
||||
user.setGender(resources.getGender());
|
||||
saveOrUpdate(user);
|
||||
// 清除缓存
|
||||
delCaches(user.getId(), user.getUsername());
|
||||
// 清除用户登录缓存
|
||||
flushLoginCacheInfo(user.getUsername());
|
||||
// 更新用户岗位
|
||||
userJobMapper.deleteByUserId(resources.getId());
|
||||
userJobMapper.insertBatchWithUserId(resources.getJobs(), resources.getId());
|
||||
systemUserJobMapper.deleteByUserId(resources.getId());
|
||||
systemUserJobMapper.insertBatchWithUserId(resources.getJobs(), resources.getId());
|
||||
// 更新用户角色
|
||||
userRoleMapper.deleteByUserId(resources.getId());
|
||||
userRoleMapper.insertBatchWithUserId(resources.getRoles(), resources.getId());
|
||||
systemUserRoleMapper.deleteByUserId(resources.getId());
|
||||
systemUserRoleMapper.insertBatchWithUserId(resources.getRoles(), resources.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void modifyUserCenterInfoById(SystemUserTb resources) {
|
||||
SystemUserTb user = getById(resources.getId());
|
||||
SystemUserTb user1 = userMapper.getUserByPhone(resources.getPhone());
|
||||
SystemUserTb user1 = systemUserMapper.getUserByPhone(resources.getPhone());
|
||||
if (user1 != null && !user.getId().equals(user1.getId())) {
|
||||
throw new EntityExistException(SystemUserTb.class, "phone", resources.getPhone());
|
||||
}
|
||||
@@ -124,8 +121,7 @@ public class SystemUserServiceImpl extends ServiceImpl<SystemUserMapper, SystemU
|
||||
user.setPhone(resources.getPhone());
|
||||
user.setGender(resources.getGender());
|
||||
saveOrUpdate(user);
|
||||
// 清理缓存
|
||||
delCaches(user.getId(), user.getUsername());
|
||||
flushLoginCacheInfo(user.getUsername());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -134,35 +130,35 @@ public class SystemUserServiceImpl extends ServiceImpl<SystemUserMapper, SystemU
|
||||
for (Long id : ids) {
|
||||
// 清理缓存
|
||||
SystemUserTb user = getById(id);
|
||||
delCaches(user.getId(), user.getUsername());
|
||||
flushLoginCacheInfo(user.getUsername());
|
||||
}
|
||||
userMapper.deleteByIds(ids);
|
||||
systemUserMapper.deleteByIds(ids);
|
||||
// 删除用户岗位
|
||||
userJobMapper.deleteByUserIds(ids);
|
||||
systemUserJobMapper.deleteByUserIds(ids);
|
||||
// 删除用户角色
|
||||
userRoleMapper.deleteByUserIds(ids);
|
||||
systemUserRoleMapper.deleteByUserIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void modifyUserPasswordByUsername(String username, String pass) {
|
||||
userMapper.updatePasswordByUsername(username, pass, new Date());
|
||||
flushCache(username);
|
||||
systemUserMapper.updatePasswordByUsername(username, pass, new Date());
|
||||
flushLoginCacheInfo(username);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void resetUserPasswordByIds(Set<Long> ids, String password) {
|
||||
List<SystemUserTb> users = userMapper.selectByIds(ids);
|
||||
List<SystemUserTb> users = systemUserMapper.selectByIds(ids);
|
||||
// 清除缓存
|
||||
users.forEach(user -> {
|
||||
// 清除缓存
|
||||
flushCache(user.getUsername());
|
||||
flushLoginCacheInfo(user.getUsername());
|
||||
// 强制退出
|
||||
systemUserOnlineService.kickOutByUsername(user.getUsername());
|
||||
});
|
||||
// 重置密码
|
||||
userMapper.updatePasswordByUserIds(password, ids);
|
||||
systemUserMapper.updatePasswordByUserIds(password, ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -176,7 +172,7 @@ public class SystemUserServiceImpl extends ServiceImpl<SystemUserMapper, SystemU
|
||||
if (fileType != null && !image.contains(fileType)) {
|
||||
throw new BadRequestException("文件格式错误!, 仅支持 " + image + " 格式");
|
||||
}
|
||||
SystemUserTb user = userMapper.getUserByUsername(SecurityHelper.getCurrentUsername());
|
||||
SystemUserTb user = systemUserMapper.getUserByUsername(SecurityHelper.getCurrentUsername());
|
||||
String oldPath = user.getAvatarPath();
|
||||
File file = FileUtil.upload(multipartFile, properties.getFile().getPath().getAvatar());
|
||||
user.setAvatarPath(Objects.requireNonNull(file).getPath());
|
||||
@@ -186,7 +182,7 @@ public class SystemUserServiceImpl extends ServiceImpl<SystemUserMapper, SystemU
|
||||
FileUtil.del(oldPath);
|
||||
}
|
||||
@NotBlank String username = user.getUsername();
|
||||
flushCache(username);
|
||||
flushLoginCacheInfo(username);
|
||||
return new HashMap<>(1) {{
|
||||
put("avatar", file.getName());
|
||||
}};
|
||||
@@ -195,8 +191,8 @@ public class SystemUserServiceImpl extends ServiceImpl<SystemUserMapper, SystemU
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void modifyUserEmailByUsername(String username, String email) {
|
||||
userMapper.updateEmailByUsername(username, email);
|
||||
flushCache(username);
|
||||
systemUserMapper.updateEmailByUsername(username, email);
|
||||
flushLoginCacheInfo(username);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -219,22 +215,35 @@ public class SystemUserServiceImpl extends ServiceImpl<SystemUserMapper, SystemU
|
||||
FileUtil.downloadExcel(list, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 清理缓存
|
||||
*
|
||||
* @param id /
|
||||
*/
|
||||
public void delCaches(Long id, String username) {
|
||||
redisHelper.del(SystemRedisKey.USER_ID + id);
|
||||
flushCache(username);
|
||||
}
|
||||
|
||||
/**
|
||||
* 清理 登陆时 用户缓存信息
|
||||
*
|
||||
* @param username /
|
||||
*/
|
||||
private void flushCache(String username) {
|
||||
private void flushLoginCacheInfo(String username) {
|
||||
systemUserJwtService.cleanUserJwtModelCacheByUsername(username);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CsResultVo<List<SystemUserTb>> describeUserPage(QuerySystemUserArgs criteria, Page<Object> page) {
|
||||
criteria.setOffset(page.offset());
|
||||
List<SystemUserTb> users = systemUserMapper.queryUserPageByArgs(criteria, PageUtil.getCount(systemUserMapper)).getRecords();
|
||||
Long total = systemUserMapper.getUserCountByArgs(criteria);
|
||||
return PageUtil.toPage(users, total);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SystemUserTb> describeUserList(QuerySystemUserArgs criteria) {
|
||||
return systemUserMapper.queryUserPageByArgs(criteria, PageUtil.getCount(systemUserMapper)).getRecords();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SystemUserTb describeUserById(long id) {
|
||||
return systemUserMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SystemUserTb describeUserByUsername(String username) {
|
||||
return systemUserMapper.getUserByUsername(username);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user