Commit 5b9213f2 authored by Zheng Jie's avatar Zheng Jie
Browse files

代码优化

parent a74cf51c
...@@ -23,10 +23,7 @@ import me.zhengjie.modules.mnt.service.DeployHistoryService; ...@@ -23,10 +23,7 @@ import me.zhengjie.modules.mnt.service.DeployHistoryService;
import me.zhengjie.modules.mnt.service.dto.DeployHistoryDto; import me.zhengjie.modules.mnt.service.dto.DeployHistoryDto;
import me.zhengjie.modules.mnt.service.dto.DeployHistoryQueryCriteria; import me.zhengjie.modules.mnt.service.dto.DeployHistoryQueryCriteria;
import me.zhengjie.modules.mnt.service.mapstruct.DeployHistoryMapper; import me.zhengjie.modules.mnt.service.mapstruct.DeployHistoryMapper;
import me.zhengjie.utils.FileUtil; import me.zhengjie.utils.*;
import me.zhengjie.utils.PageUtil;
import me.zhengjie.utils.QueryHelp;
import me.zhengjie.utils.ValidationUtil;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -47,7 +44,7 @@ public class DeployHistoryServiceImpl implements DeployHistoryService { ...@@ -47,7 +44,7 @@ public class DeployHistoryServiceImpl implements DeployHistoryService {
private final DeployHistoryMapper deployhistoryMapper; private final DeployHistoryMapper deployhistoryMapper;
@Override @Override
public Object queryAll(DeployHistoryQueryCriteria criteria, Pageable pageable){ public PageResult<DeployHistoryDto> queryAll(DeployHistoryQueryCriteria criteria, Pageable pageable){
Page<DeployHistory> page = deployhistoryRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); Page<DeployHistory> page = deployhistoryRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
return PageUtil.toPage(page.map(deployhistoryMapper::toDto)); return PageUtil.toPage(page.map(deployhistoryMapper::toDto));
} }
......
...@@ -68,7 +68,7 @@ public class DeployServiceImpl implements DeployService { ...@@ -68,7 +68,7 @@ public class DeployServiceImpl implements DeployService {
@Override @Override
public Object queryAll(DeployQueryCriteria criteria, Pageable pageable) { public PageResult<DeployDto> queryAll(DeployQueryCriteria criteria, Pageable pageable) {
Page<Deploy> page = deployRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder), pageable); Page<Deploy> page = deployRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder), pageable);
return PageUtil.toPage(page.map(deployMapper::toDto)); return PageUtil.toPage(page.map(deployMapper::toDto));
} }
......
...@@ -23,10 +23,7 @@ import me.zhengjie.modules.mnt.service.dto.ServerDeployDto; ...@@ -23,10 +23,7 @@ import me.zhengjie.modules.mnt.service.dto.ServerDeployDto;
import me.zhengjie.modules.mnt.service.dto.ServerDeployQueryCriteria; import me.zhengjie.modules.mnt.service.dto.ServerDeployQueryCriteria;
import me.zhengjie.modules.mnt.service.mapstruct.ServerDeployMapper; import me.zhengjie.modules.mnt.service.mapstruct.ServerDeployMapper;
import me.zhengjie.modules.mnt.util.ExecuteShellUtil; import me.zhengjie.modules.mnt.util.ExecuteShellUtil;
import me.zhengjie.utils.FileUtil; import me.zhengjie.utils.*;
import me.zhengjie.utils.PageUtil;
import me.zhengjie.utils.QueryHelp;
import me.zhengjie.utils.ValidationUtil;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -47,7 +44,7 @@ public class ServerDeployServiceImpl implements ServerDeployService { ...@@ -47,7 +44,7 @@ public class ServerDeployServiceImpl implements ServerDeployService {
private final ServerDeployMapper serverDeployMapper; private final ServerDeployMapper serverDeployMapper;
@Override @Override
public Object queryAll(ServerDeployQueryCriteria criteria, Pageable pageable){ public PageResult<ServerDeployDto> queryAll(ServerDeployQueryCriteria criteria, Pageable pageable){
Page<ServerDeploy> page = serverDeployRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); Page<ServerDeploy> page = serverDeployRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
return PageUtil.toPage(page.map(serverDeployMapper::toDto)); return PageUtil.toPage(page.map(serverDeployMapper::toDto));
} }
......
...@@ -22,8 +22,10 @@ import lombok.extern.slf4j.Slf4j; ...@@ -22,8 +22,10 @@ import lombok.extern.slf4j.Slf4j;
import me.zhengjie.annotation.Log; import me.zhengjie.annotation.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.dto.JobQueryCriteria; import me.zhengjie.modules.quartz.service.dto.JobQueryCriteria;
import me.zhengjie.utils.PageResult;
import me.zhengjie.utils.SpringContextHolder; import me.zhengjie.utils.SpringContextHolder;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
...@@ -52,7 +54,7 @@ public class QuartzJobController { ...@@ -52,7 +54,7 @@ public class QuartzJobController {
@ApiOperation("查询定时任务") @ApiOperation("查询定时任务")
@GetMapping @GetMapping
@PreAuthorize("@el.check('timing:list')") @PreAuthorize("@el.check('timing:list')")
public ResponseEntity<Object> queryQuartzJob(JobQueryCriteria criteria, Pageable pageable){ public ResponseEntity<PageResult<QuartzJob>> queryQuartzJob(JobQueryCriteria criteria, Pageable pageable){
return new ResponseEntity<>(quartzJobService.queryAll(criteria,pageable), HttpStatus.OK); return new ResponseEntity<>(quartzJobService.queryAll(criteria,pageable), HttpStatus.OK);
} }
...@@ -73,7 +75,7 @@ public class QuartzJobController { ...@@ -73,7 +75,7 @@ public class QuartzJobController {
@ApiOperation("查询任务执行日志") @ApiOperation("查询任务执行日志")
@GetMapping(value = "/logs") @GetMapping(value = "/logs")
@PreAuthorize("@el.check('timing:list')") @PreAuthorize("@el.check('timing:list')")
public ResponseEntity<Object> queryQuartzJobLog(JobQueryCriteria criteria, Pageable pageable){ public ResponseEntity<PageResult<QuartzLog>> queryQuartzJobLog(JobQueryCriteria criteria, Pageable pageable){
return new ResponseEntity<>(quartzJobService.queryAllLog(criteria,pageable), HttpStatus.OK); return new ResponseEntity<>(quartzJobService.queryAllLog(criteria,pageable), HttpStatus.OK);
} }
......
...@@ -18,6 +18,7 @@ package me.zhengjie.modules.quartz.service; ...@@ -18,6 +18,7 @@ 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.domain.QuartzLog;
import me.zhengjie.modules.quartz.service.dto.JobQueryCriteria; import me.zhengjie.modules.quartz.service.dto.JobQueryCriteria;
import me.zhengjie.utils.PageResult;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
...@@ -36,7 +37,7 @@ public interface QuartzJobService { ...@@ -36,7 +37,7 @@ public interface QuartzJobService {
* @param pageable 分页参数 * @param pageable 分页参数
* @return / * @return /
*/ */
Object queryAll(JobQueryCriteria criteria, Pageable pageable); PageResult<QuartzJob> queryAll(JobQueryCriteria criteria, Pageable pageable);
/** /**
* 查询全部 * 查询全部
...@@ -51,7 +52,7 @@ public interface QuartzJobService { ...@@ -51,7 +52,7 @@ public interface QuartzJobService {
* @param pageable 分页参数 * @param pageable 分页参数
* @return / * @return /
*/ */
Object queryAllLog(JobQueryCriteria criteria, Pageable pageable); PageResult<QuartzLog> queryAllLog(JobQueryCriteria criteria, Pageable pageable);
/** /**
* 查询全部 * 查询全部
......
...@@ -50,12 +50,12 @@ public class QuartzJobServiceImpl implements QuartzJobService { ...@@ -50,12 +50,12 @@ public class QuartzJobServiceImpl implements QuartzJobService {
private final RedisUtils redisUtils; private final RedisUtils redisUtils;
@Override @Override
public Object queryAll(JobQueryCriteria criteria, Pageable pageable){ public PageResult<QuartzJob> queryAll(JobQueryCriteria criteria, Pageable pageable){
return PageUtil.toPage(quartzJobRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable)); return PageUtil.toPage(quartzJobRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable));
} }
@Override @Override
public Object queryAllLog(JobQueryCriteria criteria, Pageable pageable){ public PageResult<QuartzLog> queryAllLog(JobQueryCriteria criteria, Pageable pageable){
return PageUtil.toPage(quartzLogRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable)); return PageUtil.toPage(quartzLogRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable));
} }
......
...@@ -44,6 +44,7 @@ import org.springframework.security.authentication.UsernamePasswordAuthenticatio ...@@ -44,6 +44,7 @@ import org.springframework.security.authentication.UsernamePasswordAuthenticatio
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.core.Authentication; import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.userdetails.UserDetails;
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 javax.annotation.Resource; import javax.annotation.Resource;
...@@ -113,7 +114,7 @@ public class AuthorizationController { ...@@ -113,7 +114,7 @@ public class AuthorizationController {
@ApiOperation("获取用户信息") @ApiOperation("获取用户信息")
@GetMapping(value = "/info") @GetMapping(value = "/info")
public ResponseEntity<Object> getUserInfo() { public ResponseEntity<UserDetails> getUserInfo() {
return ResponseEntity.ok(SecurityUtils.getCurrentUser()); return ResponseEntity.ok(SecurityUtils.getCurrentUser());
} }
......
...@@ -19,7 +19,9 @@ import io.swagger.annotations.Api; ...@@ -19,7 +19,9 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import me.zhengjie.modules.security.service.OnlineUserService; import me.zhengjie.modules.security.service.OnlineUserService;
import me.zhengjie.modules.security.service.dto.OnlineUserDto;
import me.zhengjie.utils.EncryptUtils; import me.zhengjie.utils.EncryptUtils;
import me.zhengjie.utils.PageResult;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
...@@ -43,7 +45,7 @@ public class OnlineController { ...@@ -43,7 +45,7 @@ public class OnlineController {
@ApiOperation("查询在线用户") @ApiOperation("查询在线用户")
@GetMapping @GetMapping
@PreAuthorize("@el.check()") @PreAuthorize("@el.check()")
public ResponseEntity<Object> queryOnlineUser(String filter, Pageable pageable){ public ResponseEntity<PageResult<OnlineUserDto>> queryOnlineUser(String filter, Pageable pageable){
return new ResponseEntity<>(onlineUserService.getAll(filter, pageable),HttpStatus.OK); return new ResponseEntity<>(onlineUserService.getAll(filter, pageable),HttpStatus.OK);
} }
......
...@@ -25,6 +25,7 @@ import me.zhengjie.modules.system.domain.Dept; ...@@ -25,6 +25,7 @@ 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.dto.DeptQueryCriteria; import me.zhengjie.modules.system.service.dto.DeptQueryCriteria;
import me.zhengjie.utils.PageResult;
import me.zhengjie.utils.PageUtil; import me.zhengjie.utils.PageUtil;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
...@@ -57,22 +58,22 @@ public class DeptController { ...@@ -57,22 +58,22 @@ public class DeptController {
@ApiOperation("查询部门") @ApiOperation("查询部门")
@GetMapping @GetMapping
@PreAuthorize("@el.check('user:list','dept:list')") @PreAuthorize("@el.check('user:list','dept:list')")
public ResponseEntity<Object> queryDept(DeptQueryCriteria criteria) throws Exception { public ResponseEntity<PageResult<DeptDto>> queryDept(DeptQueryCriteria criteria) throws Exception {
List<DeptDto> deptDtos = deptService.queryAll(criteria, true); List<DeptDto> depts = deptService.queryAll(criteria, true);
return new ResponseEntity<>(PageUtil.toPage(deptDtos, deptDtos.size()),HttpStatus.OK); return new ResponseEntity<>(PageUtil.toPage(depts, depts.size()),HttpStatus.OK);
} }
@ApiOperation("查询部门:根据ID获取同级与上级数据") @ApiOperation("查询部门:根据ID获取同级与上级数据")
@PostMapping("/superior") @PostMapping("/superior")
@PreAuthorize("@el.check('user:list','dept:list')") @PreAuthorize("@el.check('user:list','dept:list')")
public ResponseEntity<Object> getDeptSuperior(@RequestBody List<Long> ids) { public ResponseEntity<Object> getDeptSuperior(@RequestBody List<Long> ids) {
Set<DeptDto> deptDtos = new LinkedHashSet<>(); Set<DeptDto> deptSet = new LinkedHashSet<>();
for (Long id : ids) { for (Long id : ids) {
DeptDto deptDto = deptService.findById(id); DeptDto deptDto = deptService.findById(id);
List<DeptDto> depts = deptService.getSuperior(deptDto, new ArrayList<>()); List<DeptDto> depts = deptService.getSuperior(deptDto, new ArrayList<>());
deptDtos.addAll(depts); deptSet.addAll(depts);
} }
return new ResponseEntity<>(deptService.buildTree(new ArrayList<>(deptDtos)),HttpStatus.OK); return new ResponseEntity<>(deptService.buildTree(new ArrayList<>(deptSet)),HttpStatus.OK);
} }
@Log("新增部门") @Log("新增部门")
......
...@@ -22,7 +22,10 @@ import me.zhengjie.annotation.Log; ...@@ -22,7 +22,10 @@ import me.zhengjie.annotation.Log;
import me.zhengjie.exception.BadRequestException; 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.DictQueryCriteria; import me.zhengjie.modules.system.service.dto.DictQueryCriteria;
import me.zhengjie.utils.PageResult;
import me.zhengjie.utils.PageUtil;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
...@@ -31,6 +34,7 @@ import org.springframework.validation.annotation.Validated; ...@@ -31,6 +34,7 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
import java.util.List;
import java.util.Set; import java.util.Set;
/** /**
...@@ -56,14 +60,14 @@ public class DictController { ...@@ -56,14 +60,14 @@ public class DictController {
@ApiOperation("查询字典") @ApiOperation("查询字典")
@GetMapping(value = "/all") @GetMapping(value = "/all")
@PreAuthorize("@el.check('dict:list')") @PreAuthorize("@el.check('dict:list')")
public ResponseEntity<Object> queryAllDict(){ public ResponseEntity<List<DictDto>> queryAllDict(){
return new ResponseEntity<>(dictService.queryAll(new DictQueryCriteria()),HttpStatus.OK); return new ResponseEntity<>(dictService.queryAll(new DictQueryCriteria()),HttpStatus.OK);
} }
@ApiOperation("查询字典") @ApiOperation("查询字典")
@GetMapping @GetMapping
@PreAuthorize("@el.check('dict:list')") @PreAuthorize("@el.check('dict:list')")
public ResponseEntity<Object> queryDict(DictQueryCriteria resources, Pageable pageable){ public ResponseEntity<PageResult<DictDto>> queryDict(DictQueryCriteria resources, Pageable pageable){
return new ResponseEntity<>(dictService.queryAll(resources,pageable),HttpStatus.OK); return new ResponseEntity<>(dictService.queryAll(resources,pageable),HttpStatus.OK);
} }
......
...@@ -24,6 +24,7 @@ import me.zhengjie.modules.system.domain.DictDetail; ...@@ -24,6 +24,7 @@ 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.DictDetailDto;
import me.zhengjie.modules.system.service.dto.DictDetailQueryCriteria; import me.zhengjie.modules.system.service.dto.DictDetailQueryCriteria;
import me.zhengjie.utils.PageResult;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort; import org.springframework.data.domain.Sort;
import org.springframework.data.web.PageableDefault; import org.springframework.data.web.PageableDefault;
...@@ -51,8 +52,8 @@ public class DictDetailController { ...@@ -51,8 +52,8 @@ public class DictDetailController {
@ApiOperation("查询字典详情") @ApiOperation("查询字典详情")
@GetMapping @GetMapping
public ResponseEntity<Object> queryDictDetail(DictDetailQueryCriteria criteria, public ResponseEntity<PageResult<DictDetailDto>> queryDictDetail(DictDetailQueryCriteria criteria,
@PageableDefault(sort = {"dictSort"}, direction = Sort.Direction.ASC) Pageable pageable){ @PageableDefault(sort = {"dictSort"}, direction = Sort.Direction.ASC) Pageable pageable){
return new ResponseEntity<>(dictDetailService.queryAll(criteria,pageable),HttpStatus.OK); return new ResponseEntity<>(dictDetailService.queryAll(criteria,pageable),HttpStatus.OK);
} }
......
...@@ -22,7 +22,9 @@ import me.zhengjie.annotation.Log; ...@@ -22,7 +22,9 @@ import me.zhengjie.annotation.Log;
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.dto.JobDto;
import me.zhengjie.modules.system.service.dto.JobQueryCriteria; import me.zhengjie.modules.system.service.dto.JobQueryCriteria;
import me.zhengjie.utils.PageResult;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
...@@ -56,7 +58,7 @@ public class JobController { ...@@ -56,7 +58,7 @@ public class JobController {
@ApiOperation("查询岗位") @ApiOperation("查询岗位")
@GetMapping @GetMapping
@PreAuthorize("@el.check('job:list','user:list')") @PreAuthorize("@el.check('job:list','user:list')")
public ResponseEntity<Object> queryJob(JobQueryCriteria criteria, Pageable pageable){ public ResponseEntity<PageResult<JobDto>> queryJob(JobQueryCriteria criteria, Pageable pageable){
return new ResponseEntity<>(jobService.queryAll(criteria, pageable),HttpStatus.OK); return new ResponseEntity<>(jobService.queryAll(criteria, pageable),HttpStatus.OK);
} }
......
...@@ -22,10 +22,12 @@ import lombok.RequiredArgsConstructor; ...@@ -22,10 +22,12 @@ import lombok.RequiredArgsConstructor;
import me.zhengjie.annotation.Log; import me.zhengjie.annotation.Log;
import me.zhengjie.modules.system.domain.Menu; import me.zhengjie.modules.system.domain.Menu;
import me.zhengjie.exception.BadRequestException; import me.zhengjie.exception.BadRequestException;
import me.zhengjie.modules.system.domain.vo.MenuVo;
import me.zhengjie.modules.system.service.MenuService; import me.zhengjie.modules.system.service.MenuService;
import me.zhengjie.modules.system.service.dto.MenuDto; import me.zhengjie.modules.system.service.dto.MenuDto;
import me.zhengjie.modules.system.service.dto.MenuQueryCriteria; import me.zhengjie.modules.system.service.dto.MenuQueryCriteria;
import me.zhengjie.modules.system.service.mapstruct.MenuMapper; import me.zhengjie.modules.system.service.mapstruct.MenuMapper;
import me.zhengjie.utils.PageResult;
import me.zhengjie.utils.PageUtil; import me.zhengjie.utils.PageUtil;
import me.zhengjie.utils.SecurityUtils; import me.zhengjie.utils.SecurityUtils;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
...@@ -61,16 +63,16 @@ public class MenuController { ...@@ -61,16 +63,16 @@ public class MenuController {
@GetMapping(value = "/build") @GetMapping(value = "/build")
@ApiOperation("获取前端所需菜单") @ApiOperation("获取前端所需菜单")
public ResponseEntity<Object> buildMenus(){ public ResponseEntity<List<MenuVo>> buildMenus(){
List<MenuDto> menuDtoList = menuService.findByUser(SecurityUtils.getCurrentUserId()); List<MenuDto> menuDtoList = menuService.findByUser(SecurityUtils.getCurrentUserId());
List<MenuDto> menuDtos = menuService.buildTree(menuDtoList); List<MenuDto> menus = menuService.buildTree(menuDtoList);
return new ResponseEntity<>(menuService.buildMenus(menuDtos),HttpStatus.OK); return new ResponseEntity<>(menuService.buildMenus(menus),HttpStatus.OK);
} }
@ApiOperation("返回全部的菜单") @ApiOperation("返回全部的菜单")
@GetMapping(value = "/lazy") @GetMapping(value = "/lazy")
@PreAuthorize("@el.check('menu:list','roles:list')") @PreAuthorize("@el.check('menu:list','roles:list')")
public ResponseEntity<Object> queryAllMenu(@RequestParam Long pid){ public ResponseEntity<List<MenuDto>> queryAllMenu(@RequestParam Long pid){
return new ResponseEntity<>(menuService.getMenus(pid),HttpStatus.OK); return new ResponseEntity<>(menuService.getMenus(pid),HttpStatus.OK);
} }
...@@ -89,7 +91,7 @@ public class MenuController { ...@@ -89,7 +91,7 @@ public class MenuController {
@GetMapping @GetMapping
@ApiOperation("查询菜单") @ApiOperation("查询菜单")
@PreAuthorize("@el.check('menu:list')") @PreAuthorize("@el.check('menu:list')")
public ResponseEntity<Object> queryMenu(MenuQueryCriteria criteria) throws Exception { public ResponseEntity<PageResult<MenuDto>> queryMenu(MenuQueryCriteria criteria) throws Exception {
List<MenuDto> menuDtoList = menuService.queryAll(criteria, true); List<MenuDto> menuDtoList = menuService.queryAll(criteria, true);
return new ResponseEntity<>(PageUtil.toPage(menuDtoList, menuDtoList.size()),HttpStatus.OK); return new ResponseEntity<>(PageUtil.toPage(menuDtoList, menuDtoList.size()),HttpStatus.OK);
} }
...@@ -97,7 +99,7 @@ public class MenuController { ...@@ -97,7 +99,7 @@ public class MenuController {
@ApiOperation("查询菜单:根据ID获取同级与上级数据") @ApiOperation("查询菜单:根据ID获取同级与上级数据")
@PostMapping("/superior") @PostMapping("/superior")
@PreAuthorize("@el.check('menu:list')") @PreAuthorize("@el.check('menu:list')")
public ResponseEntity<Object> getMenuSuperior(@RequestBody List<Long> ids) { public ResponseEntity<List<MenuDto>> getMenuSuperior(@RequestBody List<Long> ids) {
Set<MenuDto> menuDtos = new LinkedHashSet<>(); Set<MenuDto> menuDtos = new LinkedHashSet<>();
if(CollectionUtil.isNotEmpty(ids)){ if(CollectionUtil.isNotEmpty(ids)){
for (Long id : ids) { for (Long id : ids) {
......
...@@ -26,6 +26,7 @@ import me.zhengjie.modules.system.service.RoleService; ...@@ -26,6 +26,7 @@ import me.zhengjie.modules.system.service.RoleService;
import me.zhengjie.modules.system.service.dto.RoleDto; import me.zhengjie.modules.system.service.dto.RoleDto;
import me.zhengjie.modules.system.service.dto.RoleQueryCriteria; import me.zhengjie.modules.system.service.dto.RoleQueryCriteria;
import me.zhengjie.modules.system.service.dto.RoleSmallDto; import me.zhengjie.modules.system.service.dto.RoleSmallDto;
import me.zhengjie.utils.PageResult;
import me.zhengjie.utils.SecurityUtils; import me.zhengjie.utils.SecurityUtils;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
...@@ -57,7 +58,7 @@ public class RoleController { ...@@ -57,7 +58,7 @@ public class RoleController {
@ApiOperation("获取单个role") @ApiOperation("获取单个role")
@GetMapping(value = "/{id}") @GetMapping(value = "/{id}")
@PreAuthorize("@el.check('roles:list')") @PreAuthorize("@el.check('roles:list')")
public ResponseEntity<Object> findRoleById(@PathVariable Long id){ public ResponseEntity<RoleDto> findRoleById(@PathVariable Long id){
return new ResponseEntity<>(roleService.findById(id), HttpStatus.OK); return new ResponseEntity<>(roleService.findById(id), HttpStatus.OK);
} }
...@@ -71,14 +72,14 @@ public class RoleController { ...@@ -71,14 +72,14 @@ public class RoleController {
@ApiOperation("返回全部的角色") @ApiOperation("返回全部的角色")
@GetMapping(value = "/all") @GetMapping(value = "/all")
@PreAuthorize("@el.check('roles:list','user:add','user:edit')") @PreAuthorize("@el.check('roles:list','user:add','user:edit')")
public ResponseEntity<Object> queryAllRole(){ public ResponseEntity<List<RoleDto>> queryAllRole(){
return new ResponseEntity<>(roleService.queryAll(),HttpStatus.OK); return new ResponseEntity<>(roleService.queryAll(),HttpStatus.OK);
} }
@ApiOperation("查询角色") @ApiOperation("查询角色")
@GetMapping @GetMapping
@PreAuthorize("@el.check('roles:list')") @PreAuthorize("@el.check('roles:list')")
public ResponseEntity<Object> queryRole(RoleQueryCriteria criteria, Pageable pageable){ public ResponseEntity<PageResult<RoleDto>> queryRole(RoleQueryCriteria criteria, Pageable pageable){
return new ResponseEntity<>(roleService.queryAll(criteria,pageable),HttpStatus.OK); return new ResponseEntity<>(roleService.queryAll(criteria,pageable),HttpStatus.OK);
} }
......
...@@ -100,7 +100,7 @@ public class UserController { ...@@ -100,7 +100,7 @@ public class UserController {
criteria.getDeptIds().addAll(dataScopes); criteria.getDeptIds().addAll(dataScopes);
return new ResponseEntity<>(userService.queryAll(criteria,pageable),HttpStatus.OK); return new ResponseEntity<>(userService.queryAll(criteria,pageable),HttpStatus.OK);
} }
return new ResponseEntity<>(PageUtil.toPage(null,0),HttpStatus.OK); return new ResponseEntity<>(PageUtil.noData(),HttpStatus.OK);
} }
@Log("新增用户") @Log("新增用户")
......
...@@ -111,8 +111,8 @@ public interface DeptService { ...@@ -111,8 +111,8 @@ public interface DeptService {
/** /**
* 获取 * 获取
* @param deptList * @param deptList /
* @return * @return /
*/ */
List<Long> getDeptChildren(List<Dept> deptList); List<Long> getDeptChildren(List<Dept> deptList);
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
package me.zhengjie.modules.system.service; 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.vo.MenuVo;
import me.zhengjie.modules.system.service.dto.MenuDto; import me.zhengjie.modules.system.service.dto.MenuDto;
import me.zhengjie.modules.system.service.dto.MenuQueryCriteria; import me.zhengjie.modules.system.service.dto.MenuQueryCriteria;
...@@ -78,7 +79,7 @@ public interface MenuService { ...@@ -78,7 +79,7 @@ public interface MenuService {
* @param menuDtos / * @param menuDtos /
* @return / * @return /
*/ */
Object buildMenus(List<MenuDto> menuDtos); List<MenuVo> buildMenus(List<MenuDto> menuDtos);
/** /**
* 根据ID查询 * 根据ID查询
......
...@@ -21,6 +21,7 @@ import me.zhengjie.modules.system.service.dto.RoleDto; ...@@ -21,6 +21,7 @@ import me.zhengjie.modules.system.service.dto.RoleDto;
import me.zhengjie.modules.system.service.dto.RoleQueryCriteria; import me.zhengjie.modules.system.service.dto.RoleQueryCriteria;
import me.zhengjie.modules.system.service.dto.RoleSmallDto; import me.zhengjie.modules.system.service.dto.RoleSmallDto;
import me.zhengjie.modules.system.service.dto.UserDto; import me.zhengjie.modules.system.service.dto.UserDto;
import me.zhengjie.utils.PageResult;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
...@@ -97,7 +98,7 @@ public interface RoleService { ...@@ -97,7 +98,7 @@ public interface RoleService {
* @param pageable 分页参数 * @param pageable 分页参数
* @return / * @return /
*/ */
Object queryAll(RoleQueryCriteria criteria, Pageable pageable); PageResult<RoleDto> queryAll(RoleQueryCriteria criteria, Pageable pageable);
/** /**
* 查询全部 * 查询全部
......
...@@ -74,7 +74,7 @@ public class RoleServiceImpl implements RoleService { ...@@ -74,7 +74,7 @@ public class RoleServiceImpl implements RoleService {
} }
@Override @Override
public Object queryAll(RoleQueryCriteria criteria, Pageable pageable) { public PageResult<RoleDto> queryAll(RoleQueryCriteria criteria, Pageable pageable) {
Page<Role> page = roleRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder), pageable); Page<Role> page = roleRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder), pageable);
return PageUtil.toPage(page.map(roleMapper::toDto)); return PageUtil.toPage(page.map(roleMapper::toDto));
} }
......
...@@ -41,7 +41,7 @@ public class EmailController { ...@@ -41,7 +41,7 @@ public class EmailController {
private final EmailService emailService; private final EmailService emailService;
@GetMapping @GetMapping
public ResponseEntity<Object> queryEmailConfig(){ public ResponseEntity<EmailConfig> queryEmailConfig(){
return new ResponseEntity<>(emailService.find(),HttpStatus.OK); return new ResponseEntity<>(emailService.find(),HttpStatus.OK);
} }
......
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