Commit 7eba9641 authored by zhengjie's avatar zhengjie
Browse files

去除实时控制台功能,查询方式修改成注解方式

parent e6c23f81
...@@ -4,10 +4,8 @@ import lombok.extern.slf4j.Slf4j; ...@@ -4,10 +4,8 @@ import lombok.extern.slf4j.Slf4j;
import me.zhengjie.aop.log.Log; import me.zhengjie.aop.log.Log;
import me.zhengjie.exception.BadRequestException; import me.zhengjie.exception.BadRequestException;
import me.zhengjie.modules.quartz.domain.QuartzJob; import me.zhengjie.modules.quartz.domain.QuartzJob;
import me.zhengjie.modules.quartz.domain.QuartzLog;
import me.zhengjie.modules.quartz.service.QuartzJobService; import me.zhengjie.modules.quartz.service.QuartzJobService;
import me.zhengjie.modules.quartz.service.query.QuartzJobQueryService; import me.zhengjie.modules.quartz.service.dto.JobQueryCriteria;
import me.zhengjie.modules.quartz.service.query.QuartzLogQueryService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
...@@ -30,29 +28,17 @@ public class QuartzJobController { ...@@ -30,29 +28,17 @@ public class QuartzJobController {
@Autowired @Autowired
private QuartzJobService quartzJobService; private QuartzJobService quartzJobService;
@Autowired
private QuartzJobQueryService quartzJobQueryService;
@Autowired
private QuartzLogQueryService quartzLogQueryService;
@Log("查询定时任务") @Log("查询定时任务")
@GetMapping(value = "/jobs") @GetMapping(value = "/jobs")
@PreAuthorize("hasAnyRole('ADMIN','JOB_ALL','JOB_SELECT')") @PreAuthorize("hasAnyRole('ADMIN','JOB_ALL','JOB_SELECT')")
public ResponseEntity getJobs(QuartzJob resources, Pageable pageable){ public ResponseEntity getJobs(JobQueryCriteria criteria, Pageable pageable){
return new ResponseEntity(quartzJobQueryService.queryAll(resources,pageable), HttpStatus.OK); return new ResponseEntity(quartzJobService.queryAll(criteria,pageable), HttpStatus.OK);
} }
/**
* 查询定时任务日志
* @param resources
* @param pageable
* @return
*/
@GetMapping(value = "/jobLogs") @GetMapping(value = "/jobLogs")
@PreAuthorize("hasAnyRole('ADMIN','JOB_ALL','JOB_SELECT')") @PreAuthorize("hasAnyRole('ADMIN','JOB_ALL','JOB_SELECT')")
public ResponseEntity getJobLogs(QuartzLog resources, Pageable pageable){ public ResponseEntity getJobLogs(JobQueryCriteria criteria, Pageable pageable){
return new ResponseEntity(quartzLogQueryService.queryAll(resources,pageable), HttpStatus.OK); return new ResponseEntity(quartzJobService.queryAllLog(criteria,pageable), HttpStatus.OK);
} }
@Log("新增定时任务") @Log("新增定时任务")
......
package me.zhengjie.modules.quartz.service; package me.zhengjie.modules.quartz.service;
import me.zhengjie.modules.quartz.domain.QuartzJob; import me.zhengjie.modules.quartz.domain.QuartzJob;
import me.zhengjie.modules.quartz.domain.QuartzLog;
import me.zhengjie.modules.quartz.service.dto.JobQueryCriteria;
import org.springframework.cache.annotation.CacheConfig; import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CacheEvict; import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable; import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.domain.Pageable;
/** /**
* @author jie * @author jie
...@@ -12,6 +15,23 @@ import org.springframework.cache.annotation.Cacheable; ...@@ -12,6 +15,23 @@ import org.springframework.cache.annotation.Cacheable;
@CacheConfig(cacheNames = "quartzJob") @CacheConfig(cacheNames = "quartzJob")
public interface QuartzJobService { public interface QuartzJobService {
/**
* queryAll quartzJob
* @param criteria
* @param pageable
* @return
*/
@Cacheable(keyGenerator = "keyGenerator")
Object queryAll(JobQueryCriteria criteria, Pageable pageable);
/**
* queryAll quartzLog
* @param criteria
* @param pageable
* @return
*/
Object queryAllLog(JobQueryCriteria criteria, Pageable pageable);
/** /**
* create * create
* @param resources * @param resources
......
package me.zhengjie.modules.quartz.service.dto;
import lombok.Data;
import me.zhengjie.annotation.Query;
/**
* @author jie
* @date 2019-6-4 10:33:02
*/
@Data
public class JobQueryCriteria {
@Query(type = Query.Type.INNER_LIKE)
private String jobName;
@Query
private Boolean isSuccess;
}
...@@ -3,11 +3,16 @@ package me.zhengjie.modules.quartz.service.impl; ...@@ -3,11 +3,16 @@ package me.zhengjie.modules.quartz.service.impl;
import me.zhengjie.exception.BadRequestException; import me.zhengjie.exception.BadRequestException;
import me.zhengjie.modules.quartz.domain.QuartzJob; import me.zhengjie.modules.quartz.domain.QuartzJob;
import me.zhengjie.modules.quartz.repository.QuartzJobRepository; import me.zhengjie.modules.quartz.repository.QuartzJobRepository;
import me.zhengjie.modules.quartz.repository.QuartzLogRepository;
import me.zhengjie.modules.quartz.service.QuartzJobService; import me.zhengjie.modules.quartz.service.QuartzJobService;
import me.zhengjie.modules.quartz.service.dto.JobQueryCriteria;
import me.zhengjie.modules.quartz.utils.QuartzManage; import me.zhengjie.modules.quartz.utils.QuartzManage;
import me.zhengjie.utils.PageUtil;
import me.zhengjie.utils.QueryHelp;
import me.zhengjie.utils.ValidationUtil; import me.zhengjie.utils.ValidationUtil;
import org.quartz.CronExpression; import org.quartz.CronExpression;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
...@@ -24,9 +29,21 @@ public class QuartzJobServiceImpl implements QuartzJobService { ...@@ -24,9 +29,21 @@ public class QuartzJobServiceImpl implements QuartzJobService {
@Autowired @Autowired
private QuartzJobRepository quartzJobRepository; private QuartzJobRepository quartzJobRepository;
@Autowired
private QuartzLogRepository quartzLogRepository;
@Autowired @Autowired
private QuartzManage quartzManage; private QuartzManage quartzManage;
@Override
public Object queryAll(JobQueryCriteria criteria, Pageable pageable){
return PageUtil.toPage(quartzJobRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable));
}
public Object queryAllLog(JobQueryCriteria criteria, Pageable pageable){
return PageUtil.toPage(quartzLogRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable));
}
@Override @Override
public QuartzJob findById(Long id) { public QuartzJob findById(Long id) {
Optional<QuartzJob> quartzJob = quartzJobRepository.findById(id); Optional<QuartzJob> quartzJob = quartzJobRepository.findById(id);
......
package me.zhengjie.modules.quartz.service.query;
import me.zhengjie.modules.quartz.domain.QuartzJob;
import me.zhengjie.modules.quartz.repository.QuartzJobRepository;
import me.zhengjie.utils.PageUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import java.util.ArrayList;
import java.util.List;
/**
* @author jie
* @date 2019-01-07
*/
@Service
@CacheConfig(cacheNames = "quartzJob")
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
public class QuartzJobQueryService {
@Autowired
private QuartzJobRepository quartzJobRepository;
@Cacheable(keyGenerator = "keyGenerator")
public Object queryAll(QuartzJob quartzJob, Pageable pageable){
return PageUtil.toPage(quartzJobRepository.findAll(new Spec(quartzJob),pageable));
}
class Spec implements Specification<QuartzJob> {
private QuartzJob quartzJob;
public Spec(QuartzJob quartzJob){
this.quartzJob = quartzJob;
}
@Override
public Predicate toPredicate(Root<QuartzJob> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder cb) {
List<Predicate> list = new ArrayList<Predicate>();
if(!ObjectUtils.isEmpty(quartzJob.getJobName())){
/**
* 模糊
*/
list.add(cb.like(root.get("jobName").as(String.class),"%"+quartzJob.getJobName()+"%"));
}
Predicate[] p = new Predicate[list.size()];
return cb.and(list.toArray(p));
}
}
}
package me.zhengjie.modules.quartz.service.query;
import me.zhengjie.modules.quartz.domain.QuartzLog;
import me.zhengjie.modules.quartz.repository.QuartzLogRepository;
import me.zhengjie.utils.PageUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import java.util.ArrayList;
import java.util.List;
/**
* @author jie
* @date 2019-01-07
*/
@Service
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
public class QuartzLogQueryService {
@Autowired
private QuartzLogRepository quartzLogRepository;
public Object queryAll(QuartzLog quartzLog, Pageable pageable){
return PageUtil.toPage(quartzLogRepository.findAll(new Spec(quartzLog),pageable));
}
class Spec implements Specification<QuartzLog> {
private QuartzLog quartzLog;
public Spec(QuartzLog quartzLog){
this.quartzLog = quartzLog;
}
@Override
public Predicate toPredicate(Root<QuartzLog> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder cb) {
List<Predicate> list = new ArrayList<Predicate>();
if(!ObjectUtils.isEmpty(quartzLog.getJobName())){
/**
* 模糊
*/
list.add(cb.like(root.get("jobName").as(String.class),"%"+quartzLog.getJobName()+"%"));
}
if (!ObjectUtils.isEmpty(quartzLog.getIsSuccess())) {
list.add(cb.equal(root.get("isSuccess").as(Boolean.class), quartzLog.getIsSuccess()));
}
Predicate[] p = new Predicate[list.size()];
return cb.and(list.toArray(p));
}
}
}
...@@ -6,7 +6,7 @@ import me.zhengjie.exception.BadRequestException; ...@@ -6,7 +6,7 @@ import me.zhengjie.exception.BadRequestException;
import me.zhengjie.modules.system.domain.Dept; import me.zhengjie.modules.system.domain.Dept;
import me.zhengjie.modules.system.service.DeptService; import me.zhengjie.modules.system.service.DeptService;
import me.zhengjie.modules.system.service.dto.DeptDTO; import me.zhengjie.modules.system.service.dto.DeptDTO;
import me.zhengjie.modules.system.service.query.DeptQueryService; import me.zhengjie.modules.system.service.dto.DeptQueryCriteria;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
...@@ -14,7 +14,6 @@ import org.springframework.security.access.prepost.PreAuthorize; ...@@ -14,7 +14,6 @@ import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.List; import java.util.List;
import java.util.Set;
/** /**
* @author jie * @author jie
...@@ -27,9 +26,6 @@ public class DeptController { ...@@ -27,9 +26,6 @@ public class DeptController {
@Autowired @Autowired
private DeptService deptService; private DeptService deptService;
@Autowired
private DeptQueryService deptQueryService;
@Autowired @Autowired
private DataScope dataScope; private DataScope dataScope;
...@@ -38,10 +34,10 @@ public class DeptController { ...@@ -38,10 +34,10 @@ public class DeptController {
@Log("查询部门") @Log("查询部门")
@GetMapping(value = "/dept") @GetMapping(value = "/dept")
@PreAuthorize("hasAnyRole('ADMIN','USER_ALL','USER_SELECT','DEPT_ALL','DEPT_SELECT')") @PreAuthorize("hasAnyRole('ADMIN','USER_ALL','USER_SELECT','DEPT_ALL','DEPT_SELECT')")
public ResponseEntity getDepts(DeptDTO resources){ public ResponseEntity getDepts(DeptQueryCriteria criteria){
// 数据权限 // 数据权限
Set<Long> deptIds = dataScope.getDeptIds(); criteria.setIds(dataScope.getDeptIds());
List<DeptDTO> deptDTOS = deptQueryService.queryAll(resources, deptIds); List<DeptDTO> deptDTOS = deptService.queryAll(criteria);
return new ResponseEntity(deptService.buildTree(deptDTOS),HttpStatus.OK); return new ResponseEntity(deptService.buildTree(deptDTOS),HttpStatus.OK);
} }
......
...@@ -5,7 +5,6 @@ import me.zhengjie.exception.BadRequestException; ...@@ -5,7 +5,6 @@ import me.zhengjie.exception.BadRequestException;
import me.zhengjie.modules.system.domain.Dict; import me.zhengjie.modules.system.domain.Dict;
import me.zhengjie.modules.system.service.DictService; import me.zhengjie.modules.system.service.DictService;
import me.zhengjie.modules.system.service.dto.DictDTO; import me.zhengjie.modules.system.service.dto.DictDTO;
import me.zhengjie.modules.system.service.query.DictQueryService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
...@@ -25,16 +24,13 @@ public class DictController { ...@@ -25,16 +24,13 @@ public class DictController {
@Autowired @Autowired
private DictService dictService; private DictService dictService;
@Autowired
private DictQueryService dictQueryService;
private static final String ENTITY_NAME = "dict"; private static final String ENTITY_NAME = "dict";
@Log("查询字典") @Log("查询字典")
@GetMapping(value = "/dict") @GetMapping(value = "/dict")
@PreAuthorize("hasAnyRole('ADMIN','DICT_ALL','DICT_SELECT')") @PreAuthorize("hasAnyRole('ADMIN','DICT_ALL','DICT_SELECT')")
public ResponseEntity getDicts(DictDTO resources, Pageable pageable){ public ResponseEntity getDicts(DictDTO resources, Pageable pageable){
return new ResponseEntity(dictQueryService.queryAll(resources,pageable),HttpStatus.OK); return new ResponseEntity(dictService.queryAll(resources,pageable),HttpStatus.OK);
} }
@Log("新增字典") @Log("新增字典")
......
...@@ -4,8 +4,7 @@ import me.zhengjie.aop.log.Log; ...@@ -4,8 +4,7 @@ import me.zhengjie.aop.log.Log;
import me.zhengjie.exception.BadRequestException; import me.zhengjie.exception.BadRequestException;
import me.zhengjie.modules.system.domain.DictDetail; import me.zhengjie.modules.system.domain.DictDetail;
import me.zhengjie.modules.system.service.DictDetailService; import me.zhengjie.modules.system.service.DictDetailService;
import me.zhengjie.modules.system.service.dto.DictDetailDTO; import me.zhengjie.modules.system.service.dto.DictDetailQueryCriteria;
import me.zhengjie.modules.system.service.query.DictDetailQueryService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort; import org.springframework.data.domain.Sort;
...@@ -27,16 +26,13 @@ public class DictDetailController { ...@@ -27,16 +26,13 @@ public class DictDetailController {
@Autowired @Autowired
private DictDetailService dictDetailService; private DictDetailService dictDetailService;
@Autowired
private DictDetailQueryService dictDetailQueryService;
private static final String ENTITY_NAME = "dictDetail"; private static final String ENTITY_NAME = "dictDetail";
@Log("查询字典详情") @Log("查询字典详情")
@GetMapping(value = "/dictDetail") @GetMapping(value = "/dictDetail")
public ResponseEntity getDictDetails(DictDetailDTO resources, public ResponseEntity getDictDetails(DictDetailQueryCriteria criteria,
@PageableDefault(value = 10, sort = {"sort"}, direction = Sort.Direction.ASC) Pageable pageable){ @PageableDefault(value = 10, sort = {"sort"}, direction = Sort.Direction.ASC) Pageable pageable){
return new ResponseEntity(dictDetailQueryService.queryAll(resources,pageable),HttpStatus.OK); return new ResponseEntity(dictDetailService.queryAll(criteria,pageable),HttpStatus.OK);
} }
@Log("新增字典详情") @Log("新增字典详情")
......
...@@ -5,7 +5,7 @@ import me.zhengjie.config.DataScope; ...@@ -5,7 +5,7 @@ import me.zhengjie.config.DataScope;
import me.zhengjie.exception.BadRequestException; import me.zhengjie.exception.BadRequestException;
import me.zhengjie.modules.system.domain.Job; import me.zhengjie.modules.system.domain.Job;
import me.zhengjie.modules.system.service.JobService; import me.zhengjie.modules.system.service.JobService;
import me.zhengjie.modules.system.service.query.JobQueryService; import me.zhengjie.modules.system.service.dto.JobQueryCriteria;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
...@@ -27,9 +27,6 @@ public class JobController { ...@@ -27,9 +27,6 @@ public class JobController {
@Autowired @Autowired
private JobService jobService; private JobService jobService;
@Autowired
private JobQueryService jobQueryService;
@Autowired @Autowired
private DataScope dataScope; private DataScope dataScope;
...@@ -38,13 +35,11 @@ public class JobController { ...@@ -38,13 +35,11 @@ public class JobController {
@Log("查询岗位") @Log("查询岗位")
@GetMapping(value = "/job") @GetMapping(value = "/job")
@PreAuthorize("hasAnyRole('ADMIN','USERJOB_ALL','USERJOB_SELECT','USER_ALL','USER_SELECT')") @PreAuthorize("hasAnyRole('ADMIN','USERJOB_ALL','USERJOB_SELECT','USER_ALL','USER_SELECT')")
public ResponseEntity getJobs(@RequestParam(required = false) String name, public ResponseEntity getJobs(JobQueryCriteria criteria,
@RequestParam(required = false) Long deptId,
@RequestParam(required = false) Boolean enabled,
Pageable pageable){ Pageable pageable){
// 数据权限 // 数据权限
Set<Long> deptIds = dataScope.getDeptIds(); criteria.setDeptIds(dataScope.getDeptIds());
return new ResponseEntity(jobQueryService.queryAll(name, enabled , deptIds, deptId, pageable),HttpStatus.OK); return new ResponseEntity(jobService.queryAll(criteria, pageable),HttpStatus.OK);
} }
@Log("新增岗位") @Log("新增岗位")
......
...@@ -2,15 +2,13 @@ package me.zhengjie.modules.system.rest; ...@@ -2,15 +2,13 @@ package me.zhengjie.modules.system.rest;
import me.zhengjie.aop.log.Log; import me.zhengjie.aop.log.Log;
import me.zhengjie.modules.system.domain.Menu; import me.zhengjie.modules.system.domain.Menu;
import me.zhengjie.modules.system.domain.User;
import me.zhengjie.exception.BadRequestException; import me.zhengjie.exception.BadRequestException;
import me.zhengjie.modules.system.service.MenuService; import me.zhengjie.modules.system.service.MenuService;
import me.zhengjie.modules.system.service.RoleService; import me.zhengjie.modules.system.service.RoleService;
import me.zhengjie.modules.system.service.UserService; import me.zhengjie.modules.system.service.UserService;
import me.zhengjie.modules.system.service.dto.CommonQueryCriteria;
import me.zhengjie.modules.system.service.dto.MenuDTO; import me.zhengjie.modules.system.service.dto.MenuDTO;
import me.zhengjie.modules.system.service.dto.UserDTO; import me.zhengjie.modules.system.service.dto.UserDTO;
import me.zhengjie.modules.system.service.mapper.MenuMapper;
import me.zhengjie.modules.system.service.query.MenuQueryService;
import me.zhengjie.utils.SecurityUtils; import me.zhengjie.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
...@@ -31,18 +29,12 @@ public class MenuController { ...@@ -31,18 +29,12 @@ public class MenuController {
@Autowired @Autowired
private MenuService menuService; private MenuService menuService;
@Autowired
private MenuQueryService menuQueryService;
@Autowired @Autowired
private UserService userService; private UserService userService;
@Autowired @Autowired
private RoleService roleService; private RoleService roleService;
@Autowired
private MenuMapper menuMapper;
private static final String ENTITY_NAME = "menu"; private static final String ENTITY_NAME = "menu";
/** /**
...@@ -70,8 +62,8 @@ public class MenuController { ...@@ -70,8 +62,8 @@ public class MenuController {
@Log("查询菜单") @Log("查询菜单")
@GetMapping(value = "/menus") @GetMapping(value = "/menus")
@PreAuthorize("hasAnyRole('ADMIN','MENU_ALL','MENU_SELECT')") @PreAuthorize("hasAnyRole('ADMIN','MENU_ALL','MENU_SELECT')")
public ResponseEntity getMenus(@RequestParam(required = false) String name){ public ResponseEntity getMenus(CommonQueryCriteria criteria){
List<MenuDTO> menuDTOList = menuQueryService.queryAll(name); List<MenuDTO> menuDTOList = menuService.queryAll(criteria);
return new ResponseEntity(menuService.buildTree(menuDTOList),HttpStatus.OK); return new ResponseEntity(menuService.buildTree(menuDTOList),HttpStatus.OK);
} }
......
...@@ -4,8 +4,8 @@ import me.zhengjie.aop.log.Log; ...@@ -4,8 +4,8 @@ import me.zhengjie.aop.log.Log;
import me.zhengjie.modules.system.domain.Permission; import me.zhengjie.modules.system.domain.Permission;
import me.zhengjie.exception.BadRequestException; import me.zhengjie.exception.BadRequestException;
import me.zhengjie.modules.system.service.PermissionService; import me.zhengjie.modules.system.service.PermissionService;
import me.zhengjie.modules.system.service.dto.CommonQueryCriteria;
import me.zhengjie.modules.system.service.dto.PermissionDTO; import me.zhengjie.modules.system.service.dto.PermissionDTO;
import me.zhengjie.modules.system.service.query.PermissionQueryService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
...@@ -26,9 +26,6 @@ public class PermissionController { ...@@ -26,9 +26,6 @@ public class PermissionController {
@Autowired @Autowired
private PermissionService permissionService; private PermissionService permissionService;
@Autowired
private PermissionQueryService permissionQueryService;
private static final String ENTITY_NAME = "permission"; private static final String ENTITY_NAME = "permission";
/** /**
...@@ -44,8 +41,8 @@ public class PermissionController { ...@@ -44,8 +41,8 @@ public class PermissionController {
@Log("查询权限") @Log("查询权限")
@GetMapping(value = "/permissions") @GetMapping(value = "/permissions")
@PreAuthorize("hasAnyRole('ADMIN','PERMISSION_ALL','PERMISSION_SELECT')") @PreAuthorize("hasAnyRole('ADMIN','PERMISSION_ALL','PERMISSION_SELECT')")
public ResponseEntity getPermissions(@RequestParam(required = false) String name){ public ResponseEntity getPermissions(CommonQueryCriteria criteria){
List<PermissionDTO> permissionDTOS = permissionQueryService.queryAll(name); List<PermissionDTO> permissionDTOS = permissionService.queryAll(criteria);
return new ResponseEntity(permissionService.buildTree(permissionDTOS),HttpStatus.OK); return new ResponseEntity(permissionService.buildTree(permissionDTOS),HttpStatus.OK);
} }
......
...@@ -4,11 +4,9 @@ import cn.hutool.core.lang.Dict; ...@@ -4,11 +4,9 @@ import cn.hutool.core.lang.Dict;
import me.zhengjie.aop.log.Log; import me.zhengjie.aop.log.Log;
import me.zhengjie.modules.system.domain.Role; import me.zhengjie.modules.system.domain.Role;
import me.zhengjie.exception.BadRequestException; import me.zhengjie.exception.BadRequestException;
import me.zhengjie.modules.system.domain.User;
import me.zhengjie.modules.system.service.RoleService; import me.zhengjie.modules.system.service.RoleService;
import me.zhengjie.modules.system.service.dto.RoleDTO; import me.zhengjie.modules.system.service.dto.CommonQueryCriteria;
import me.zhengjie.modules.system.service.dto.RoleSmallDTO; import me.zhengjie.modules.system.service.dto.RoleSmallDTO;
import me.zhengjie.modules.system.service.query.RoleQueryService;
import me.zhengjie.utils.SecurityUtils; import me.zhengjie.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
...@@ -19,10 +17,8 @@ import org.springframework.http.ResponseEntity; ...@@ -19,10 +17,8 @@ import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
...@@ -36,9 +32,6 @@ public class RoleController { ...@@ -36,9 +32,6 @@ public class RoleController {
@Autowired @Autowired
private RoleService roleService; private RoleService roleService;
@Autowired
private RoleQueryService roleQueryService;
private static final String ENTITY_NAME = "role"; private static final String ENTITY_NAME = "role";
/** /**
...@@ -59,15 +52,14 @@ public class RoleController { ...@@ -59,15 +52,14 @@ public class RoleController {
@GetMapping(value = "/roles/all") @GetMapping(value = "/roles/all")
@PreAuthorize("hasAnyRole('ADMIN','ROLES_ALL','USER_ALL','USER_CREATE','USER_EDIT')") @PreAuthorize("hasAnyRole('ADMIN','ROLES_ALL','USER_ALL','USER_CREATE','USER_EDIT')")
public ResponseEntity getAll(@PageableDefault(value = 2000, sort = {"level"}, direction = Sort.Direction.ASC) Pageable pageable){ public ResponseEntity getAll(@PageableDefault(value = 2000, sort = {"level"}, direction = Sort.Direction.ASC) Pageable pageable){
return new ResponseEntity(roleService.queryAll(pageable),HttpStatus.OK);
return new ResponseEntity(roleQueryService.queryAll(pageable),HttpStatus.OK);
} }
@Log("查询角色") @Log("查询角色")
@GetMapping(value = "/roles") @GetMapping(value = "/roles")
@PreAuthorize("hasAnyRole('ADMIN','ROLES_ALL','ROLES_SELECT')") @PreAuthorize("hasAnyRole('ADMIN','ROLES_ALL','ROLES_SELECT')")
public ResponseEntity getRoles(@RequestParam(required = false) String name, Pageable pageable){ public ResponseEntity getRoles(CommonQueryCriteria criteria, Pageable pageable){
return new ResponseEntity(roleQueryService.queryAll(name,pageable),HttpStatus.OK); return new ResponseEntity(roleService.queryAll(criteria,pageable),HttpStatus.OK);
} }
@GetMapping(value = "/roles/level") @GetMapping(value = "/roles/level")
......
...@@ -4,18 +4,16 @@ import me.zhengjie.aop.log.Log; ...@@ -4,18 +4,16 @@ import me.zhengjie.aop.log.Log;
import me.zhengjie.config.DataScope; import me.zhengjie.config.DataScope;
import me.zhengjie.domain.Picture; import me.zhengjie.domain.Picture;
import me.zhengjie.domain.VerificationCode; import me.zhengjie.domain.VerificationCode;
import me.zhengjie.modules.system.domain.Role;
import me.zhengjie.modules.system.domain.User; import me.zhengjie.modules.system.domain.User;
import me.zhengjie.exception.BadRequestException; import me.zhengjie.exception.BadRequestException;
import me.zhengjie.modules.system.service.DeptService; import me.zhengjie.modules.system.service.DeptService;
import me.zhengjie.modules.system.service.RoleService; import me.zhengjie.modules.system.service.RoleService;
import me.zhengjie.modules.system.service.dto.RoleSmallDTO; import me.zhengjie.modules.system.service.dto.RoleSmallDTO;
import me.zhengjie.modules.system.service.dto.UserQueryCriteria;
import me.zhengjie.service.PictureService; import me.zhengjie.service.PictureService;
import me.zhengjie.service.VerificationCodeService; import me.zhengjie.service.VerificationCodeService;
import me.zhengjie.utils.*; import me.zhengjie.utils.*;
import me.zhengjie.modules.system.service.UserService; import me.zhengjie.modules.system.service.UserService;
import me.zhengjie.modules.system.service.dto.UserDTO;
import me.zhengjie.modules.system.service.query.UserQueryService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
...@@ -41,9 +39,6 @@ public class UserController { ...@@ -41,9 +39,6 @@ public class UserController {
@Autowired @Autowired
private UserService userService; private UserService userService;
@Autowired
private UserQueryService userQueryService;
@Autowired @Autowired
private PictureService pictureService; private PictureService pictureService;
...@@ -59,19 +54,16 @@ public class UserController { ...@@ -59,19 +54,16 @@ public class UserController {
@Autowired @Autowired
private VerificationCodeService verificationCodeService; private VerificationCodeService verificationCodeService;
private static final String ENTITY_NAME = "user";
@Log("查询用户") @Log("查询用户")
@GetMapping(value = "/users") @GetMapping(value = "/users")
@PreAuthorize("hasAnyRole('ADMIN','USER_ALL','USER_SELECT')") @PreAuthorize("hasAnyRole('ADMIN','USER_ALL','USER_SELECT')")
public ResponseEntity getUsers(UserDTO userDTO, Pageable pageable){ public ResponseEntity getUsers(UserQueryCriteria criteria, Pageable pageable){
Set<Long> deptSet = new HashSet<>(); Set<Long> deptSet = new HashSet<>();
Set<Long> result = new HashSet<>(); Set<Long> result = new HashSet<>();
if (!ObjectUtils.isEmpty(userDTO.getDeptId())) { if (!ObjectUtils.isEmpty(criteria.getDeptId())) {
deptSet.add(userDTO.getDeptId()); deptSet.add(criteria.getDeptId());
deptSet.addAll(dataScope.getDeptChildren(deptService.findByPid(userDTO.getDeptId()))); deptSet.addAll(dataScope.getDeptChildren(deptService.findByPid(criteria.getDeptId())));
} }
// 数据权限 // 数据权限
...@@ -85,14 +77,16 @@ public class UserController { ...@@ -85,14 +77,16 @@ public class UserController {
result.retainAll(deptIds); result.retainAll(deptIds);
// 若无交集,则代表无数据权限 // 若无交集,则代表无数据权限
criteria.setDeptIds(result);
if(result.size() == 0){ if(result.size() == 0){
return new ResponseEntity(PageUtil.toPage(null,0),HttpStatus.OK); return new ResponseEntity(PageUtil.toPage(null,0),HttpStatus.OK);
} else return new ResponseEntity(userQueryService.queryAll(userDTO,result,pageable),HttpStatus.OK); } else return new ResponseEntity(userService.queryAll(criteria,pageable),HttpStatus.OK);
// 否则取并集 // 否则取并集
} else { } else {
result.addAll(deptSet); result.addAll(deptSet);
result.addAll(deptIds); result.addAll(deptIds);
return new ResponseEntity(userQueryService.queryAll(userDTO,result,pageable),HttpStatus.OK); criteria.setDeptIds(result);
return new ResponseEntity(userService.queryAll(criteria,pageable),HttpStatus.OK);
} }
} }
......
...@@ -2,6 +2,7 @@ package me.zhengjie.modules.system.service; ...@@ -2,6 +2,7 @@ package me.zhengjie.modules.system.service;
import me.zhengjie.modules.system.domain.Dept; import me.zhengjie.modules.system.domain.Dept;
import me.zhengjie.modules.system.service.dto.DeptDTO; import me.zhengjie.modules.system.service.dto.DeptDTO;
import me.zhengjie.modules.system.service.dto.DeptQueryCriteria;
import org.springframework.cache.annotation.CacheConfig; import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CacheEvict; import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable; import org.springframework.cache.annotation.Cacheable;
...@@ -16,6 +17,14 @@ import java.util.Set; ...@@ -16,6 +17,14 @@ import java.util.Set;
@CacheConfig(cacheNames = "dept") @CacheConfig(cacheNames = "dept")
public interface DeptService { public interface DeptService {
/**
* queryAll
* @param criteria
* @return
*/
@Cacheable(keyGenerator = "keyGenerator")
List<DeptDTO> queryAll(DeptQueryCriteria criteria);
/** /**
* findById * findById
* @param id * @param id
......
...@@ -2,9 +2,11 @@ package me.zhengjie.modules.system.service; ...@@ -2,9 +2,11 @@ package me.zhengjie.modules.system.service;
import me.zhengjie.modules.system.domain.DictDetail; import me.zhengjie.modules.system.domain.DictDetail;
import me.zhengjie.modules.system.service.dto.DictDetailDTO; import me.zhengjie.modules.system.service.dto.DictDetailDTO;
import me.zhengjie.modules.system.service.dto.DictDetailQueryCriteria;
import org.springframework.cache.annotation.CacheConfig; import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CacheEvict; import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable; import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.domain.Pageable;
/** /**
* @author jie * @author jie
...@@ -42,4 +44,7 @@ public interface DictDetailService { ...@@ -42,4 +44,7 @@ public interface DictDetailService {
*/ */
@CacheEvict(allEntries = true) @CacheEvict(allEntries = true)
void delete(Long id); void delete(Long id);
@Cacheable(keyGenerator = "keyGenerator")
Object queryAll(DictDetailQueryCriteria criteria, Pageable pageable);
} }
\ No newline at end of file
...@@ -5,6 +5,7 @@ import me.zhengjie.modules.system.service.dto.DictDTO; ...@@ -5,6 +5,7 @@ import me.zhengjie.modules.system.service.dto.DictDTO;
import org.springframework.cache.annotation.CacheConfig; import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CacheEvict; import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable; import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.domain.Pageable;
/** /**
* @author jie * @author jie
...@@ -13,6 +14,15 @@ import org.springframework.cache.annotation.Cacheable; ...@@ -13,6 +14,15 @@ import org.springframework.cache.annotation.Cacheable;
@CacheConfig(cacheNames = "dict") @CacheConfig(cacheNames = "dict")
public interface DictService { public interface DictService {
/**
* 查询
* @param dict
* @param pageable
* @return
*/
@Cacheable(keyGenerator = "keyGenerator")
Object queryAll(DictDTO dict, Pageable pageable);
/** /**
* findById * findById
* @param id * @param id
......
...@@ -2,9 +2,11 @@ package me.zhengjie.modules.system.service; ...@@ -2,9 +2,11 @@ package me.zhengjie.modules.system.service;
import me.zhengjie.modules.system.domain.Job; import me.zhengjie.modules.system.domain.Job;
import me.zhengjie.modules.system.service.dto.JobDTO; import me.zhengjie.modules.system.service.dto.JobDTO;
import me.zhengjie.modules.system.service.dto.JobQueryCriteria;
import org.springframework.cache.annotation.CacheConfig; import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CacheEvict; import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable; import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.domain.Pageable;
/** /**
* @author jie * @author jie
...@@ -42,4 +44,12 @@ public interface JobService { ...@@ -42,4 +44,12 @@ public interface JobService {
*/ */
@CacheEvict(allEntries = true) @CacheEvict(allEntries = true)
void delete(Long id); void delete(Long id);
/**
* queryAll
* @param criteria
* @param pageable
* @return
*/
Object queryAll(JobQueryCriteria criteria, Pageable pageable);
} }
\ No newline at end of file
...@@ -2,6 +2,7 @@ package me.zhengjie.modules.system.service; ...@@ -2,6 +2,7 @@ package me.zhengjie.modules.system.service;
import me.zhengjie.modules.system.domain.Menu; import me.zhengjie.modules.system.domain.Menu;
import me.zhengjie.modules.system.domain.Role; import me.zhengjie.modules.system.domain.Role;
import me.zhengjie.modules.system.service.dto.CommonQueryCriteria;
import me.zhengjie.modules.system.service.dto.MenuDTO; import me.zhengjie.modules.system.service.dto.MenuDTO;
import me.zhengjie.modules.system.service.dto.RoleSmallDTO; import me.zhengjie.modules.system.service.dto.RoleSmallDTO;
import org.springframework.cache.annotation.CacheConfig; import org.springframework.cache.annotation.CacheConfig;
...@@ -18,6 +19,14 @@ import java.util.Set; ...@@ -18,6 +19,14 @@ import java.util.Set;
@CacheConfig(cacheNames = "menu") @CacheConfig(cacheNames = "menu")
public interface MenuService { public interface MenuService {
/**
* queryAll
* @param criteria
* @return
*/
@Cacheable(keyGenerator = "keyGenerator")
List<MenuDTO> queryAll(CommonQueryCriteria criteria);
/** /**
* get * get
* @param id * @param id
......
package me.zhengjie.modules.system.service; package me.zhengjie.modules.system.service;
import me.zhengjie.modules.system.domain.Permission; import me.zhengjie.modules.system.domain.Permission;
import me.zhengjie.modules.system.service.dto.CommonQueryCriteria;
import me.zhengjie.modules.system.service.dto.PermissionDTO; import me.zhengjie.modules.system.service.dto.PermissionDTO;
import org.springframework.cache.annotation.CacheConfig; import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CacheEvict; import org.springframework.cache.annotation.CacheEvict;
...@@ -68,4 +69,12 @@ public interface PermissionService { ...@@ -68,4 +69,12 @@ public interface PermissionService {
*/ */
@Cacheable(keyGenerator = "keyGenerator") @Cacheable(keyGenerator = "keyGenerator")
Object buildTree(List<PermissionDTO> permissionDTOS); Object buildTree(List<PermissionDTO> permissionDTOS);
/**
* queryAll
* @param criteria
* @return
*/
@Cacheable(keyGenerator = "keyGenerator")
List<PermissionDTO> queryAll(CommonQueryCriteria criteria);
} }
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment