From 900ca221a9d28b9c0e02435b82af5ba5564fecfe Mon Sep 17 00:00:00 2001 From: Elune <201507802@qq.com> Date: Tue, 10 Dec 2019 18:59:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../me/zhengjie/rest/GenConfigController.java | 4 +-- .../me/zhengjie/rest/GeneratorController.java | 14 +++++----- .../me/zhengjie/service/GeneratorService.java | 6 ++-- .../me/zhengjie/repository/LogRepository.java | 3 +- .../java/me/zhengjie/rest/LogController.java | 17 ++++++----- .../mnt/service/impl/DeployServiceImpl.java | 6 ++-- .../monitor/rest/ServerController.java | 8 +++--- .../monitor/rest/VisitsController.java | 8 +++--- .../quartz/rest/QuartzJobController.java | 22 +++++++-------- .../modules/security/rest/AuthController.java | 10 +++---- .../security/rest/OnlineController.java | 6 ++-- .../security/service/OnlineUserService.java | 2 +- .../modules/system/rest/DeptController.java | 13 ++++----- .../modules/system/rest/DictController.java | 14 +++++----- .../system/rest/DictDetailController.java | 14 +++++----- .../modules/system/rest/JobController.java | 12 ++++---- .../modules/system/rest/MenuController.java | 16 +++++------ .../modules/system/rest/RoleController.java | 22 +++++++-------- .../modules/system/rest/UserController.java | 28 +++++++++---------- .../template/generator/admin/Controller.ftl | 16 +++++------ .../me/zhengjie/rest/AliPayController.java | 4 +-- .../me/zhengjie/rest/EmailController.java | 10 +++---- .../zhengjie/rest/LocalStorageController.java | 16 +++++------ .../me/zhengjie/rest/PictureController.java | 8 +++--- .../me/zhengjie/rest/QiniuController.java | 24 ++++++++-------- .../rest/VerificationCodeController.java | 12 ++++---- 26 files changed, 156 insertions(+), 159 deletions(-) diff --git a/eladmin-generator/src/main/java/me/zhengjie/rest/GenConfigController.java b/eladmin-generator/src/main/java/me/zhengjie/rest/GenConfigController.java index daf6d2817..934c51315 100644 --- a/eladmin-generator/src/main/java/me/zhengjie/rest/GenConfigController.java +++ b/eladmin-generator/src/main/java/me/zhengjie/rest/GenConfigController.java @@ -26,13 +26,13 @@ public GenConfigController(GenConfigService genConfigService) { @ApiOperation("查询") @GetMapping(value = "/{tableName}") - public ResponseEntity get(@PathVariable String tableName){ + public ResponseEntity get(@PathVariable String tableName){ return new ResponseEntity<>(genConfigService.find(tableName), HttpStatus.OK); } @ApiOperation("修改") @PutMapping - public ResponseEntity emailConfig(@Validated @RequestBody GenConfig genConfig){ + public ResponseEntity emailConfig(@Validated @RequestBody GenConfig genConfig){ return new ResponseEntity<>(genConfigService.update(genConfig.getTableName(), genConfig),HttpStatus.OK); } } diff --git a/eladmin-generator/src/main/java/me/zhengjie/rest/GeneratorController.java b/eladmin-generator/src/main/java/me/zhengjie/rest/GeneratorController.java index 26988e717..1270cc29c 100644 --- a/eladmin-generator/src/main/java/me/zhengjie/rest/GeneratorController.java +++ b/eladmin-generator/src/main/java/me/zhengjie/rest/GeneratorController.java @@ -38,13 +38,13 @@ public GeneratorController(GeneratorService generatorService, GenConfigService g @ApiOperation("查询数据库数据") @GetMapping(value = "/tables/all") - public ResponseEntity getTables(){ + public ResponseEntity getTables(){ return new ResponseEntity<>(generatorService.getTables(), HttpStatus.OK); } @ApiOperation("查询数据库数据") @GetMapping(value = "/tables") - public ResponseEntity getTables(@RequestParam(defaultValue = "") String name, + public ResponseEntity getTables(@RequestParam(defaultValue = "") String name, @RequestParam(defaultValue = "0")Integer page, @RequestParam(defaultValue = "10")Integer size){ int[] startEnd = PageUtil.transToStartEnd(page+1, size); @@ -53,7 +53,7 @@ public ResponseEntity getTables(@RequestParam(defaultValue = "") String name, @ApiOperation("查询字段数据") @GetMapping(value = "/columns") - public ResponseEntity getTables(@RequestParam String tableName){ + public ResponseEntity getTables(@RequestParam String tableName){ List columnInfos = generatorService.getColumns(tableName); // 异步同步表信息 generatorService.sync(columnInfos); @@ -62,14 +62,14 @@ public ResponseEntity getTables(@RequestParam String tableName){ @ApiOperation("保存字段数据") @PutMapping - public ResponseEntity save(@RequestBody List columnInfos){ + public ResponseEntity save(@RequestBody List columnInfos){ generatorService.save(columnInfos); - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity<>(HttpStatus.OK); } @ApiOperation("生成代码") @PostMapping(value = "/{tableName}/{type}") - public ResponseEntity generator(@PathVariable String tableName, @PathVariable Integer type, HttpServletRequest request, HttpServletResponse response){ + public ResponseEntity generator(@PathVariable String tableName, @PathVariable Integer type, HttpServletRequest request, HttpServletResponse response){ if(!generatorEnabled && type == 0){ throw new BadRequestException("此环境不允许生成代码,请选择预览或者下载查看!"); } @@ -84,6 +84,6 @@ public ResponseEntity generator(@PathVariable String tableName, @PathVariable In break; default: throw new BadRequestException("没有这个选项"); } - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity<>(HttpStatus.OK); } } diff --git a/eladmin-generator/src/main/java/me/zhengjie/service/GeneratorService.java b/eladmin-generator/src/main/java/me/zhengjie/service/GeneratorService.java index 860d1afab..c8c407fde 100644 --- a/eladmin-generator/src/main/java/me/zhengjie/service/GeneratorService.java +++ b/eladmin-generator/src/main/java/me/zhengjie/service/GeneratorService.java @@ -61,14 +61,14 @@ public interface GeneratorService { * @param columns 字段信息 * @return / */ - ResponseEntity preview(GenConfig genConfig, List columns); + ResponseEntity preview(GenConfig genConfig, List columns); /** * 打包下载 * @param genConfig 配置信息 * @param columns 字段信息 - * @param request - * @param response + * @param request / + * @param response / */ void download(GenConfig genConfig, List columns, HttpServletRequest request, HttpServletResponse response); } diff --git a/eladmin-logging/src/main/java/me/zhengjie/repository/LogRepository.java b/eladmin-logging/src/main/java/me/zhengjie/repository/LogRepository.java index b838165fc..e5eefe999 100644 --- a/eladmin-logging/src/main/java/me/zhengjie/repository/LogRepository.java +++ b/eladmin-logging/src/main/java/me/zhengjie/repository/LogRepository.java @@ -27,10 +27,9 @@ public interface LogRepository extends JpaRepository, JpaSpecification /** * 根据日志类型删除信息 - * @param logType + * @param logType 日志类型 */ @Query(nativeQuery = true,value = "delete from log where log_type = ?1") @Modifying - @Transactional void deleteByLogType(String logType); } diff --git a/eladmin-logging/src/main/java/me/zhengjie/rest/LogController.java b/eladmin-logging/src/main/java/me/zhengjie/rest/LogController.java index 6e2dc6a42..2b9320c82 100644 --- a/eladmin-logging/src/main/java/me/zhengjie/rest/LogController.java +++ b/eladmin-logging/src/main/java/me/zhengjie/rest/LogController.java @@ -11,7 +11,6 @@ import org.springframework.http.ResponseEntity; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.*; - import javax.servlet.http.HttpServletResponse; import java.io.IOException; @@ -50,14 +49,14 @@ public void errorDownload(HttpServletResponse response, LogQueryCriteria criteri @GetMapping @ApiOperation("日志查询") @PreAuthorize("@el.check()") - public ResponseEntity getLogs(LogQueryCriteria criteria, Pageable pageable){ + public ResponseEntity getLogs(LogQueryCriteria criteria, Pageable pageable){ criteria.setLogType("INFO"); return new ResponseEntity<>(logService.queryAll(criteria,pageable), HttpStatus.OK); } @GetMapping(value = "/user") @ApiOperation("用户日志查询") - public ResponseEntity getUserLogs(LogQueryCriteria criteria, Pageable pageable){ + public ResponseEntity getUserLogs(LogQueryCriteria criteria, Pageable pageable){ criteria.setLogType("INFO"); criteria.setBlurry(SecurityUtils.getUsername()); return new ResponseEntity<>(logService.queryAllByUser(criteria,pageable), HttpStatus.OK); @@ -66,7 +65,7 @@ public ResponseEntity getUserLogs(LogQueryCriteria criteria, Pageable pageable){ @GetMapping(value = "/error") @ApiOperation("错误日志查询") @PreAuthorize("@el.check()") - public ResponseEntity getErrorLogs(LogQueryCriteria criteria, Pageable pageable){ + public ResponseEntity getErrorLogs(LogQueryCriteria criteria, Pageable pageable){ criteria.setLogType("ERROR"); return new ResponseEntity<>(logService.queryAll(criteria,pageable), HttpStatus.OK); } @@ -74,24 +73,24 @@ public ResponseEntity getErrorLogs(LogQueryCriteria criteria, Pageable pageable) @GetMapping(value = "/error/{id}") @ApiOperation("日志异常详情查询") @PreAuthorize("@el.check()") - public ResponseEntity getErrorLogs(@PathVariable Long id){ + public ResponseEntity getErrorLogs(@PathVariable Long id){ return new ResponseEntity<>(logService.findByErrDetail(id), HttpStatus.OK); } @DeleteMapping(value = "/del/error") @Log("删除所有ERROR日志") @ApiOperation("删除所有ERROR日志") @PreAuthorize("@el.check()") - public ResponseEntity delAllByError(){ + public ResponseEntity delAllByError(){ logService.delAllByError(); - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity<>(HttpStatus.OK); } @DeleteMapping(value = "/del/info") @Log("删除所有INFO日志") @ApiOperation("删除所有INFO日志") @PreAuthorize("@el.check()") - public ResponseEntity delAllByInfo(){ + public ResponseEntity delAllByInfo(){ logService.delAllByInfo(); - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity<>(HttpStatus.OK); } } diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/impl/DeployServiceImpl.java b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/impl/DeployServiceImpl.java index f85f66782..eeecb119e 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/impl/DeployServiceImpl.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/impl/DeployServiceImpl.java @@ -183,7 +183,8 @@ private void sleep(int second) { private void backupApp(ExecuteShellUtil executeShellUtil, String ip, String fileSavePath, String appName, String backupPath, Long id) { String deployDate = DateUtil.format(new Date(), DatePattern.PURE_DATETIME_PATTERN); StringBuilder sb = new StringBuilder(); - if (!backupPath.endsWith(FILE_SEPARATOR)&&!backupPath.endsWith("\\")) { + String endsWith = "\\"; + if (!backupPath.endsWith(FILE_SEPARATOR)&&!backupPath.endsWith(endsWith)) { backupPath += FILE_SEPARATOR; } backupPath += appName + FILE_SEPARATOR + deployDate + "\n"; @@ -259,8 +260,7 @@ public String serverStatus(Deploy resources) { } private boolean checkFile(ExecuteShellUtil executeShellUtil, AppDto appDTO) { - StringBuilder sb = new StringBuilder("find ").append(appDTO.getDeployPath()).append(" -name ").append(appDTO.getName()); - String result = executeShellUtil.executeForResult(sb.toString()); + String result = executeShellUtil.executeForResult("find " + appDTO.getDeployPath() + " -name " + appDTO.getName()); return result.indexOf("/tcp:")>0; } diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/monitor/rest/ServerController.java b/eladmin-system/src/main/java/me/zhengjie/modules/monitor/rest/ServerController.java index c6a963fbf..4c1fef468 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/monitor/rest/ServerController.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/monitor/rest/ServerController.java @@ -32,7 +32,7 @@ public ServerController(ServerService serverService) { @Log("查询服务监控") @ApiOperation("查询服务监控") @PreAuthorize("@el.check('server:list')") - public ResponseEntity getServers(ServerQueryCriteria criteria, Pageable pageable){ + public ResponseEntity getServers(ServerQueryCriteria criteria, Pageable pageable){ return new ResponseEntity<>(serverService.queryAll(criteria,pageable),HttpStatus.OK); } @@ -40,7 +40,7 @@ public ResponseEntity getServers(ServerQueryCriteria criteria, Pageable pageable @Log("新增服务监控") @ApiOperation("新增服务监控") @PreAuthorize("@el.check('server:add')") - public ResponseEntity create(@Validated @RequestBody Server resources){ + public ResponseEntity create(@Validated @RequestBody Server resources){ return new ResponseEntity<>(serverService.create(resources),HttpStatus.CREATED); } @@ -48,9 +48,9 @@ public ResponseEntity create(@Validated @RequestBody Server resources){ @Log("修改服务监控") @ApiOperation("修改服务监控") @PreAuthorize("@el.check('server:edit')") - public ResponseEntity update(@Validated @RequestBody Server resources){ + public ResponseEntity update(@Validated @RequestBody Server resources){ serverService.update(resources); - return new ResponseEntity(HttpStatus.NO_CONTENT); + return new ResponseEntity<>(HttpStatus.NO_CONTENT); } @DeleteMapping(value = "/{id}") diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/monitor/rest/VisitsController.java b/eladmin-system/src/main/java/me/zhengjie/modules/monitor/rest/VisitsController.java index 077ee3d4f..26374f752 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/monitor/rest/VisitsController.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/monitor/rest/VisitsController.java @@ -28,20 +28,20 @@ public VisitsController(VisitsService visitsService) { @PostMapping @ApiOperation("创建访问记录") - public ResponseEntity create(){ + public ResponseEntity create(){ visitsService.count(RequestHolder.getHttpServletRequest()); - return new ResponseEntity(HttpStatus.CREATED); + return new ResponseEntity<>(HttpStatus.CREATED); } @GetMapping @ApiOperation("查询") - public ResponseEntity get(){ + public ResponseEntity get(){ return new ResponseEntity<>(visitsService.get(),HttpStatus.OK); } @GetMapping(value = "/chartData") @ApiOperation("查询图表数据") - public ResponseEntity getChartData(){ + public ResponseEntity getChartData(){ return new ResponseEntity<>(visitsService.getChartData(),HttpStatus.OK); } } diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/quartz/rest/QuartzJobController.java b/eladmin-system/src/main/java/me/zhengjie/modules/quartz/rest/QuartzJobController.java index e0d664889..afb79f142 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/quartz/rest/QuartzJobController.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/quartz/rest/QuartzJobController.java @@ -40,7 +40,7 @@ public QuartzJobController(QuartzJobService quartzJobService) { @ApiOperation("查询定时任务") @GetMapping @PreAuthorize("@el.check('timing:list')") - public ResponseEntity getJobs(JobQueryCriteria criteria, Pageable pageable){ + public ResponseEntity getJobs(JobQueryCriteria criteria, Pageable pageable){ return new ResponseEntity<>(quartzJobService.queryAll(criteria,pageable), HttpStatus.OK); } @@ -63,7 +63,7 @@ public void downloadLog(HttpServletResponse response, JobQueryCriteria criteria) @ApiOperation("查询任务执行日志") @GetMapping(value = "/logs") @PreAuthorize("@el.check('timing:list')") - public ResponseEntity getJobLogs(JobQueryCriteria criteria, Pageable pageable){ + public ResponseEntity getJobLogs(JobQueryCriteria criteria, Pageable pageable){ return new ResponseEntity<>(quartzJobService.queryAllLog(criteria,pageable), HttpStatus.OK); } @@ -71,7 +71,7 @@ public ResponseEntity getJobLogs(JobQueryCriteria criteria, Pageable pageable){ @ApiOperation("新增定时任务") @PostMapping @PreAuthorize("@el.check('timing:add')") - public ResponseEntity create(@Validated @RequestBody QuartzJob resources){ + public ResponseEntity create(@Validated @RequestBody QuartzJob resources){ if (resources.getId() != null) { throw new BadRequestException("A new "+ ENTITY_NAME +" cannot already have an ID"); } @@ -82,35 +82,35 @@ public ResponseEntity create(@Validated @RequestBody QuartzJob resources){ @ApiOperation("修改定时任务") @PutMapping @PreAuthorize("@el.check('timing:edit')") - public ResponseEntity update(@Validated(QuartzJob.Update.class) @RequestBody QuartzJob resources){ + public ResponseEntity update(@Validated(QuartzJob.Update.class) @RequestBody QuartzJob resources){ quartzJobService.update(resources); - return new ResponseEntity(HttpStatus.NO_CONTENT); + return new ResponseEntity<>(HttpStatus.NO_CONTENT); } @Log("更改定时任务状态") @ApiOperation("更改定时任务状态") @PutMapping(value = "/{id}") @PreAuthorize("@el.check('timing:edit')") - public ResponseEntity updateIsPause(@PathVariable Long id){ + public ResponseEntity updateIsPause(@PathVariable Long id){ quartzJobService.updateIsPause(quartzJobService.findById(id)); - return new ResponseEntity(HttpStatus.NO_CONTENT); + return new ResponseEntity<>(HttpStatus.NO_CONTENT); } @Log("执行定时任务") @ApiOperation("执行定时任务") @PutMapping(value = "/exec/{id}") @PreAuthorize("@el.check('timing:edit')") - public ResponseEntity execution(@PathVariable Long id){ + public ResponseEntity execution(@PathVariable Long id){ quartzJobService.execution(quartzJobService.findById(id)); - return new ResponseEntity(HttpStatus.NO_CONTENT); + return new ResponseEntity<>(HttpStatus.NO_CONTENT); } @Log("删除定时任务") @ApiOperation("删除定时任务") @DeleteMapping(value = "/{id}") @PreAuthorize("@el.check('timing:del')") - public ResponseEntity delete(@PathVariable Long id){ + public ResponseEntity delete(@PathVariable Long id){ quartzJobService.delete(quartzJobService.findById(id)); - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity<>(HttpStatus.OK); } } diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/security/rest/AuthController.java b/eladmin-system/src/main/java/me/zhengjie/modules/security/rest/AuthController.java index 34c05e5bc..9336b3a5a 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/security/rest/AuthController.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/security/rest/AuthController.java @@ -70,7 +70,7 @@ public AuthController(SecurityProperties properties, RedisUtils redisUtils, User @ApiOperation("登录授权") @AnonymousAccess @PostMapping(value = "/login") - public ResponseEntity login(@Validated @RequestBody AuthUser authUser, HttpServletRequest request){ + public ResponseEntity login(@Validated @RequestBody AuthUser authUser, HttpServletRequest request){ // 密码解密 RSA rsa = new RSA(privateKey, null); String password = new String(rsa.decrypt(authUser.getPassword(), KeyType.PrivateKey)); @@ -108,7 +108,7 @@ public ResponseEntity login(@Validated @RequestBody AuthUser authUser, HttpServl @ApiOperation("获取用户信息") @GetMapping(value = "/info") - public ResponseEntity getUserInfo(){ + public ResponseEntity getUserInfo(){ JwtUser jwtUser = (JwtUser)userDetailsService.loadUserByUsername(SecurityUtils.getUsername()); return ResponseEntity.ok(jwtUser); } @@ -116,7 +116,7 @@ public ResponseEntity getUserInfo(){ @AnonymousAccess @ApiOperation("获取验证码") @GetMapping(value = "/code") - public ResponseEntity getCode(){ + public ResponseEntity getCode(){ // 算术类型 https://gitee.com/whvse/EasyCaptcha ArithmeticCaptcha captcha = new ArithmeticCaptcha(111, 36); // 几位数运算,默认是两位 @@ -137,8 +137,8 @@ public ResponseEntity getCode(){ @ApiOperation("退出登录") @AnonymousAccess @DeleteMapping(value = "/logout") - public ResponseEntity logout(HttpServletRequest request){ + public ResponseEntity logout(HttpServletRequest request){ onlineUserService.logout(tokenProvider.getToken(request)); - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity<>(HttpStatus.OK); } } diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/security/rest/OnlineController.java b/eladmin-system/src/main/java/me/zhengjie/modules/security/rest/OnlineController.java index 22e3dbe89..4a128a7ed 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/security/rest/OnlineController.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/security/rest/OnlineController.java @@ -30,7 +30,7 @@ public OnlineController(OnlineUserService onlineUserService) { @ApiOperation("查询在线用户") @GetMapping @PreAuthorize("@el.check()") - public ResponseEntity getAll(String filter, Pageable pageable){ + public ResponseEntity getAll(String filter, Pageable pageable){ return new ResponseEntity<>(onlineUserService.getAll(filter, pageable),HttpStatus.OK); } @@ -45,8 +45,8 @@ public void download(HttpServletResponse response, String filter) throws IOExcep @ApiOperation("踢出用户") @DeleteMapping(value = "/{key}") @PreAuthorize("@el.check()") - public ResponseEntity delete(@PathVariable String key) throws Exception { + public ResponseEntity delete(@PathVariable String key) throws Exception { onlineUserService.kickOut(key); - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity<>(HttpStatus.OK); } } diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/security/service/OnlineUserService.java b/eladmin-system/src/main/java/me/zhengjie/modules/security/service/OnlineUserService.java index 21d2bcabf..cc568f00b 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/security/service/OnlineUserService.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/security/service/OnlineUserService.java @@ -136,7 +136,7 @@ public OnlineUser getOne(String key) { /** * 检测用户是否在之前已经登录,已经登录踢下线 - * @param userName + * @param userName 用户名 */ public void checkLoginOnUser(String userName, String igoreToken){ List onlineUsers = getAll(userName); diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/DeptController.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/DeptController.java index d7547337b..51c72ef7d 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/DeptController.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/DeptController.java @@ -15,7 +15,6 @@ import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; - import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.util.List; @@ -52,7 +51,7 @@ public void download(HttpServletResponse response, DeptQueryCriteria criteria) t @ApiOperation("查询部门") @GetMapping @PreAuthorize("@el.check('user:list','dept:list')") - public ResponseEntity getDepts(DeptQueryCriteria criteria){ + public ResponseEntity getDepts(DeptQueryCriteria criteria){ // 数据权限 criteria.setIds(dataScope.getDeptIds()); List deptDtos = deptService.queryAll(criteria); @@ -63,7 +62,7 @@ public ResponseEntity getDepts(DeptQueryCriteria criteria){ @ApiOperation("新增部门") @PostMapping @PreAuthorize("@el.check('dept:add')") - public ResponseEntity create(@Validated @RequestBody Dept resources){ + public ResponseEntity create(@Validated @RequestBody Dept resources){ if (resources.getId() != null) { throw new BadRequestException("A new "+ ENTITY_NAME +" cannot already have an ID"); } @@ -74,21 +73,21 @@ public ResponseEntity create(@Validated @RequestBody Dept resources){ @ApiOperation("修改部门") @PutMapping @PreAuthorize("@el.check('dept:edit')") - public ResponseEntity update(@Validated(Dept.Update.class) @RequestBody Dept resources){ + public ResponseEntity update(@Validated(Dept.Update.class) @RequestBody Dept resources){ deptService.update(resources); - return new ResponseEntity(HttpStatus.NO_CONTENT); + return new ResponseEntity<>(HttpStatus.NO_CONTENT); } @Log("删除部门") @ApiOperation("删除部门") @DeleteMapping(value = "/{id}") @PreAuthorize("@el.check('dept:del')") - public ResponseEntity delete(@PathVariable Long id){ + public ResponseEntity delete(@PathVariable Long id){ try { deptService.delete(id); }catch (Throwable e){ ThrowableUtil.throwForeignKeyException(e, "该部门存在岗位或者角色关联,请取消关联后再试"); } - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity<>(HttpStatus.OK); } } \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/DictController.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/DictController.java index 3751296ac..4c38adc5f 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/DictController.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/DictController.java @@ -46,7 +46,7 @@ public void download(HttpServletResponse response, DictQueryCriteria criteria) t @ApiOperation("查询字典") @GetMapping(value = "/all") @PreAuthorize("@el.check('dict:list')") - public ResponseEntity all(){ + public ResponseEntity all(){ return new ResponseEntity<>(dictService.queryAll(new DictQueryCriteria()),HttpStatus.OK); } @@ -54,7 +54,7 @@ public ResponseEntity all(){ @ApiOperation("查询字典") @GetMapping @PreAuthorize("@el.check('dict:list')") - public ResponseEntity getDicts(DictQueryCriteria resources, Pageable pageable){ + public ResponseEntity getDicts(DictQueryCriteria resources, Pageable pageable){ return new ResponseEntity<>(dictService.queryAll(resources,pageable),HttpStatus.OK); } @@ -62,7 +62,7 @@ public ResponseEntity getDicts(DictQueryCriteria resources, Pageable pageable){ @ApiOperation("新增字典") @PostMapping @PreAuthorize("@el.check('dict:add')") - public ResponseEntity create(@Validated @RequestBody Dict resources){ + public ResponseEntity create(@Validated @RequestBody Dict resources){ if (resources.getId() != null) { throw new BadRequestException("A new "+ ENTITY_NAME +" cannot already have an ID"); } @@ -73,17 +73,17 @@ public ResponseEntity create(@Validated @RequestBody Dict resources){ @ApiOperation("修改字典") @PutMapping @PreAuthorize("@el.check('dict:edit')") - public ResponseEntity update(@Validated(Dict.Update.class) @RequestBody Dict resources){ + public ResponseEntity update(@Validated(Dict.Update.class) @RequestBody Dict resources){ dictService.update(resources); - return new ResponseEntity(HttpStatus.NO_CONTENT); + return new ResponseEntity<>(HttpStatus.NO_CONTENT); } @Log("删除字典") @ApiOperation("删除字典") @DeleteMapping(value = "/{id}") @PreAuthorize("@el.check('dict:del')") - public ResponseEntity delete(@PathVariable Long id){ + public ResponseEntity delete(@PathVariable Long id){ dictService.delete(id); - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity<>(HttpStatus.OK); } } \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/DictDetailController.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/DictDetailController.java index 0c463994b..9638d9d5b 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/DictDetailController.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/DictDetailController.java @@ -38,7 +38,7 @@ public DictDetailController(DictDetailService dictDetailService) { @Log("查询字典详情") @ApiOperation("查询字典详情") @GetMapping - public ResponseEntity getDictDetails(DictDetailQueryCriteria criteria, + public ResponseEntity getDictDetails(DictDetailQueryCriteria criteria, @PageableDefault(sort = {"sort"}, direction = Sort.Direction.ASC) Pageable pageable){ return new ResponseEntity<>(dictDetailService.queryAll(criteria,pageable),HttpStatus.OK); } @@ -46,7 +46,7 @@ public ResponseEntity getDictDetails(DictDetailQueryCriteria criteria, @Log("查询多个字典详情") @ApiOperation("查询多个字典详情") @GetMapping(value = "/map") - public ResponseEntity getDictDetailMaps(DictDetailQueryCriteria criteria, + public ResponseEntity getDictDetailMaps(DictDetailQueryCriteria criteria, @PageableDefault(sort = {"sort"}, direction = Sort.Direction.ASC) Pageable pageable){ String[] names = criteria.getDictName().split(","); Map map = new HashMap<>(names.length); @@ -61,7 +61,7 @@ public ResponseEntity getDictDetailMaps(DictDetailQueryCriteria criteria, @ApiOperation("新增字典详情") @PostMapping @PreAuthorize("@el.check('dict:add')") - public ResponseEntity create(@Validated @RequestBody DictDetail resources){ + public ResponseEntity create(@Validated @RequestBody DictDetail resources){ if (resources.getId() != null) { throw new BadRequestException("A new "+ ENTITY_NAME +" cannot already have an ID"); } @@ -72,17 +72,17 @@ public ResponseEntity create(@Validated @RequestBody DictDetail resources){ @ApiOperation("修改字典详情") @PutMapping @PreAuthorize("@el.check('dict:edit')") - public ResponseEntity update(@Validated(DictDetail.Update.class) @RequestBody DictDetail resources){ + public ResponseEntity update(@Validated(DictDetail.Update.class) @RequestBody DictDetail resources){ dictDetailService.update(resources); - return new ResponseEntity(HttpStatus.NO_CONTENT); + return new ResponseEntity<>(HttpStatus.NO_CONTENT); } @Log("删除字典详情") @ApiOperation("删除字典详情") @DeleteMapping(value = "/{id}") @PreAuthorize("@el.check('dict:del')") - public ResponseEntity delete(@PathVariable Long id){ + public ResponseEntity delete(@PathVariable Long id){ dictDetailService.delete(id); - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity<>(HttpStatus.OK); } } \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/JobController.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/JobController.java index 58b15aaf3..911ceeb51 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/JobController.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/JobController.java @@ -52,7 +52,7 @@ public void download(HttpServletResponse response, JobQueryCriteria criteria) th @ApiOperation("查询岗位") @GetMapping @PreAuthorize("@el.check('job:list','user:list')") - public ResponseEntity getJobs(JobQueryCriteria criteria, Pageable pageable){ + public ResponseEntity getJobs(JobQueryCriteria criteria, Pageable pageable){ // 数据权限 criteria.setDeptIds(dataScope.getDeptIds()); return new ResponseEntity<>(jobService.queryAll(criteria, pageable),HttpStatus.OK); @@ -62,7 +62,7 @@ public ResponseEntity getJobs(JobQueryCriteria criteria, Pageable pageable){ @ApiOperation("新增岗位") @PostMapping @PreAuthorize("@el.check('job:add')") - public ResponseEntity create(@Validated @RequestBody Job resources){ + public ResponseEntity create(@Validated @RequestBody Job resources){ if (resources.getId() != null) { throw new BadRequestException("A new "+ ENTITY_NAME +" cannot already have an ID"); } @@ -73,21 +73,21 @@ public ResponseEntity create(@Validated @RequestBody Job resources){ @ApiOperation("修改岗位") @PutMapping @PreAuthorize("@el.check('job:edit')") - public ResponseEntity update(@Validated(Job.Update.class) @RequestBody Job resources){ + public ResponseEntity update(@Validated(Job.Update.class) @RequestBody Job resources){ jobService.update(resources); - return new ResponseEntity(HttpStatus.NO_CONTENT); + return new ResponseEntity<>(HttpStatus.NO_CONTENT); } @Log("删除岗位") @ApiOperation("删除岗位") @DeleteMapping(value = "/{id}") @PreAuthorize("@el.check('job:del')") - public ResponseEntity delete(@PathVariable Long id){ + public ResponseEntity delete(@PathVariable Long id){ try { jobService.delete(id); }catch (Throwable e){ ThrowableUtil.throwForeignKeyException(e, "该岗位存在用户关联,请取消关联后再试"); } - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity<>(HttpStatus.OK); } } \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/MenuController.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/MenuController.java index 5e8179b79..fd15fcabf 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/MenuController.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/MenuController.java @@ -58,7 +58,7 @@ public void download(HttpServletResponse response, MenuQueryCriteria criteria) t @ApiOperation("获取前端所需菜单") @GetMapping(value = "/build") - public ResponseEntity buildMenus(){ + public ResponseEntity buildMenus(){ UserDto user = userService.findByName(SecurityUtils.getUsername()); List menuDtoList = menuService.findByRoles(roleService.findByUsersId(user.getId())); List menuDtos = (List) menuService.buildTree(menuDtoList).get("content"); @@ -68,7 +68,7 @@ public ResponseEntity buildMenus(){ @ApiOperation("返回全部的菜单") @GetMapping(value = "/tree") @PreAuthorize("@el.check('menu:list','roles:list')") - public ResponseEntity getMenuTree(){ + public ResponseEntity getMenuTree(){ return new ResponseEntity<>(menuService.getMenuTree(menuService.findByPid(0L)),HttpStatus.OK); } @@ -76,7 +76,7 @@ public ResponseEntity getMenuTree(){ @ApiOperation("查询菜单") @GetMapping @PreAuthorize("@el.check('menu:list')") - public ResponseEntity getMenus(MenuQueryCriteria criteria){ + public ResponseEntity getMenus(MenuQueryCriteria criteria){ List menuDtoList = menuService.queryAll(criteria); return new ResponseEntity<>(menuService.buildTree(menuDtoList),HttpStatus.OK); } @@ -85,7 +85,7 @@ public ResponseEntity getMenus(MenuQueryCriteria criteria){ @ApiOperation("新增菜单") @PostMapping @PreAuthorize("@el.check('menu:add')") - public ResponseEntity create(@Validated @RequestBody Menu resources){ + public ResponseEntity create(@Validated @RequestBody Menu resources){ if (resources.getId() != null) { throw new BadRequestException("A new "+ ENTITY_NAME +" cannot already have an ID"); } @@ -96,21 +96,21 @@ public ResponseEntity create(@Validated @RequestBody Menu resources){ @ApiOperation("修改菜单") @PutMapping @PreAuthorize("@el.check('menu:edit')") - public ResponseEntity update(@Validated(Menu.Update.class) @RequestBody Menu resources){ + public ResponseEntity update(@Validated(Menu.Update.class) @RequestBody Menu resources){ menuService.update(resources); - return new ResponseEntity(HttpStatus.NO_CONTENT); + return new ResponseEntity<>(HttpStatus.NO_CONTENT); } @Log("删除菜单") @ApiOperation("删除菜单") @DeleteMapping(value = "/{id}") @PreAuthorize("@el.check('menu:del')") - public ResponseEntity delete(@PathVariable Long id){ + public ResponseEntity delete(@PathVariable Long id){ List menuList = menuService.findByPid(id); Set menuSet = new HashSet<>(); menuSet.add(menuService.findOne(id)); menuSet = menuService.getDeleteMenus(menuList, menuSet); menuService.delete(menuSet); - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity<>(HttpStatus.OK); } } diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/RoleController.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/RoleController.java index 5143725a0..39def419a 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/RoleController.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/RoleController.java @@ -50,7 +50,7 @@ public RoleController(RoleService roleService, UserService userService) { @ApiOperation("获取单个role") @GetMapping(value = "/{id}") @PreAuthorize("@el.check('roles:list')") - public ResponseEntity getRoles(@PathVariable Long id){ + public ResponseEntity getRoles(@PathVariable Long id){ return new ResponseEntity<>(roleService.findById(id), HttpStatus.OK); } @@ -65,7 +65,7 @@ public void download(HttpServletResponse response, RoleQueryCriteria criteria) t @ApiOperation("返回全部的角色") @GetMapping(value = "/all") @PreAuthorize("@el.check('roles:list','user:add','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); } @@ -73,13 +73,13 @@ public ResponseEntity getAll(@PageableDefault(value = 2000, sort = {"level"}, di @ApiOperation("查询角色") @GetMapping @PreAuthorize("@el.check('roles:list')") - public ResponseEntity getRoles(RoleQueryCriteria criteria, Pageable pageable){ + public ResponseEntity getRoles(RoleQueryCriteria criteria, Pageable pageable){ return new ResponseEntity<>(roleService.queryAll(criteria,pageable),HttpStatus.OK); } @ApiOperation("获取用户级别") @GetMapping(value = "/level") - public ResponseEntity getLevel(){ + public ResponseEntity getLevel(){ UserDto user = userService.findByName(SecurityUtils.getUsername()); List levels = roleService.findByUsersId(user.getId()).stream().map(RoleSmallDto::getLevel).collect(Collectors.toList()); return new ResponseEntity<>(Dict.create().set("level", Collections.min(levels)),HttpStatus.OK); @@ -89,7 +89,7 @@ public ResponseEntity getLevel(){ @ApiOperation("新增角色") @PostMapping @PreAuthorize("@el.check('roles:add')") - public ResponseEntity create(@Validated @RequestBody Role resources){ + public ResponseEntity create(@Validated @RequestBody Role resources){ if (resources.getId() != null) { throw new BadRequestException("A new "+ ENTITY_NAME +" cannot already have an ID"); } @@ -100,30 +100,30 @@ public ResponseEntity create(@Validated @RequestBody Role resources){ @ApiOperation("修改角色") @PutMapping @PreAuthorize("@el.check('roles:edit')") - public ResponseEntity update(@Validated(Role.Update.class) @RequestBody Role resources){ + public ResponseEntity update(@Validated(Role.Update.class) @RequestBody Role resources){ roleService.update(resources); - return new ResponseEntity(HttpStatus.NO_CONTENT); + return new ResponseEntity<>(HttpStatus.NO_CONTENT); } @Log("修改角色菜单") @ApiOperation("修改角色菜单") @PutMapping(value = "/menu") @PreAuthorize("@el.check('roles:edit')") - public ResponseEntity updateMenu(@RequestBody Role resources){ + public ResponseEntity updateMenu(@RequestBody Role resources){ roleService.updateMenu(resources,roleService.findById(resources.getId())); - return new ResponseEntity(HttpStatus.NO_CONTENT); + return new ResponseEntity<>(HttpStatus.NO_CONTENT); } @Log("删除角色") @ApiOperation("删除角色") @DeleteMapping(value = "/{id}") @PreAuthorize("@el.check('roles:del')") - public ResponseEntity delete(@PathVariable Long id){ + public ResponseEntity delete(@PathVariable Long id){ try { roleService.delete(id); }catch (Throwable e){ ThrowableUtil.throwForeignKeyException(e, "该角色存在用户关联,请取消关联后再试"); } - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity<>(HttpStatus.OK); } } diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/UserController.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/UserController.java index 08a1d54e7..3c6dcc291 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/UserController.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/UserController.java @@ -73,7 +73,7 @@ public void download(HttpServletResponse response, UserQueryCriteria criteria) t @ApiOperation("查询用户") @GetMapping @PreAuthorize("@el.check('user:list')") - public ResponseEntity getUsers(UserQueryCriteria criteria, Pageable pageable){ + public ResponseEntity getUsers(UserQueryCriteria criteria, Pageable pageable){ Set deptSet = new HashSet<>(); Set result = new HashSet<>(); if (!ObjectUtils.isEmpty(criteria.getDeptId())) { @@ -107,7 +107,7 @@ public ResponseEntity getUsers(UserQueryCriteria criteria, Pageable pageable){ @ApiOperation("新增用户") @PostMapping @PreAuthorize("@el.check('user:add')") - public ResponseEntity create(@Validated @RequestBody User resources){ + public ResponseEntity create(@Validated @RequestBody User resources){ checkLevel(resources); // 默认密码 123456 resources.setPassword(passwordEncoder.encode("123456")); @@ -118,29 +118,29 @@ public ResponseEntity create(@Validated @RequestBody User resources){ @ApiOperation("修改用户") @PutMapping @PreAuthorize("@el.check('user:edit')") - public ResponseEntity update(@Validated(User.Update.class) @RequestBody User resources){ + public ResponseEntity update(@Validated(User.Update.class) @RequestBody User resources){ checkLevel(resources); userService.update(resources); - return new ResponseEntity(HttpStatus.NO_CONTENT); + return new ResponseEntity<>(HttpStatus.NO_CONTENT); } @Log("修改用户:个人中心") @ApiOperation("修改用户:个人中心") @PutMapping(value = "center") - public ResponseEntity center(@Validated(User.Update.class) @RequestBody User resources){ + public ResponseEntity center(@Validated(User.Update.class) @RequestBody User resources){ UserDto userDto = userService.findByName(SecurityUtils.getUsername()); if(!resources.getId().equals(userDto.getId())){ throw new BadRequestException("不能修改他人资料"); } userService.updateCenter(resources); - return new ResponseEntity(HttpStatus.NO_CONTENT); + return new ResponseEntity<>(HttpStatus.NO_CONTENT); } @Log("删除用户") @ApiOperation("删除用户") @DeleteMapping(value = "/{id}") @PreAuthorize("@el.check('user:del')") - public ResponseEntity delete(@PathVariable Long id){ + public ResponseEntity delete(@PathVariable Long id){ UserDto user = userService.findByName(SecurityUtils.getUsername()); Integer currentLevel = Collections.min(roleService.findByUsersId(user.getId()).stream().map(RoleSmallDto::getLevel).collect(Collectors.toList())); Integer optLevel = Collections.min(roleService.findByUsersId(id).stream().map(RoleSmallDto::getLevel).collect(Collectors.toList())); @@ -149,12 +149,12 @@ public ResponseEntity delete(@PathVariable Long id){ throw new BadRequestException("角色权限不足"); } userService.delete(id); - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity<>(HttpStatus.OK); } @ApiOperation("修改密码") @PostMapping(value = "/updatePass") - public ResponseEntity updatePass(@RequestBody UserPassVo passVo){ + public ResponseEntity updatePass(@RequestBody UserPassVo passVo){ // 密码解密 RSA rsa = new RSA(privateKey, null); String oldPass = new String(rsa.decrypt(passVo.getOldPass(), KeyType.PrivateKey)); @@ -167,20 +167,20 @@ public ResponseEntity updatePass(@RequestBody UserPassVo passVo){ throw new BadRequestException("新密码不能与旧密码相同"); } userService.updatePass(user.getUsername(),passwordEncoder.encode(newPass)); - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity<>(HttpStatus.OK); } @ApiOperation("修改头像") @PostMapping(value = "/updateAvatar") - public ResponseEntity updateAvatar(@RequestParam MultipartFile file){ + public ResponseEntity updateAvatar(@RequestParam MultipartFile file){ userService.updateAvatar(file); - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity<>(HttpStatus.OK); } @Log("修改邮箱") @ApiOperation("修改邮箱") @PostMapping(value = "/updateEmail/{code}") - public ResponseEntity updateEmail(@PathVariable String code,@RequestBody User user){ + public ResponseEntity updateEmail(@PathVariable String code,@RequestBody User user){ // 密码解密 RSA rsa = new RSA(privateKey, null); String password = new String(rsa.decrypt(user.getPassword(), KeyType.PrivateKey)); @@ -191,7 +191,7 @@ public ResponseEntity updateEmail(@PathVariable String code,@RequestBody User us VerificationCode verificationCode = new VerificationCode(code, ElAdminConstant.RESET_MAIL,"email",user.getEmail()); verificationCodeService.validated(verificationCode); userService.updateEmail(userDto.getUsername(),user.getEmail()); - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity<>(HttpStatus.OK); } /** diff --git a/eladmin-system/src/main/resources/template/generator/admin/Controller.ftl b/eladmin-system/src/main/resources/template/generator/admin/Controller.ftl index 173093c64..4a933e21e 100644 --- a/eladmin-system/src/main/resources/template/generator/admin/Controller.ftl +++ b/eladmin-system/src/main/resources/template/generator/admin/Controller.ftl @@ -41,7 +41,7 @@ public class ${className}Controller { @Log("查询${apiAlias}") @ApiOperation("查询${apiAlias}") @PreAuthorize("@el.check('${changeClassName}:list')") - public ResponseEntity get${className}s(${className}QueryCriteria criteria, Pageable pageable){ + public ResponseEntity get${className}s(${className}QueryCriteria criteria, Pageable pageable){ return new ResponseEntity<>(${changeClassName}Service.queryAll(criteria,pageable),HttpStatus.OK); } @@ -49,7 +49,7 @@ public class ${className}Controller { @Log("新增${apiAlias}") @ApiOperation("新增${apiAlias}") @PreAuthorize("@el.check('${changeClassName}:add')") - public ResponseEntity create(@Validated @RequestBody ${className} resources){ + public ResponseEntity create(@Validated @RequestBody ${className} resources){ return new ResponseEntity<>(${changeClassName}Service.create(resources),HttpStatus.CREATED); } @@ -57,26 +57,26 @@ public class ${className}Controller { @Log("修改${apiAlias}") @ApiOperation("修改${apiAlias}") @PreAuthorize("@el.check('${changeClassName}:edit')") - public ResponseEntity update(@Validated @RequestBody ${className} resources){ + public ResponseEntity update(@Validated @RequestBody ${className} resources){ ${changeClassName}Service.update(resources); - return new ResponseEntity(HttpStatus.NO_CONTENT); + return new ResponseEntity<>(HttpStatus.NO_CONTENT); } @DeleteMapping(value = "/{${pkChangeColName}}") @Log("删除${apiAlias}") @ApiOperation("删除${apiAlias}") @PreAuthorize("@el.check('${changeClassName}:del')") - public ResponseEntity delete(@PathVariable ${pkColumnType} ${pkChangeColName}){ + public ResponseEntity delete(@PathVariable ${pkColumnType} ${pkChangeColName}){ ${changeClassName}Service.delete(${pkChangeColName}); - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity<>(HttpStatus.OK); } @Log("多选删除${apiAlias}") @ApiOperation("多选删除${apiAlias}") @PreAuthorize("@el.check('${changeClassName}:del')") @DeleteMapping - public ResponseEntity deleteAll(@RequestBody ${pkColumnType}[] ids) { + public ResponseEntity deleteAll(@RequestBody ${pkColumnType}[] ids) { ${changeClassName}Service.deleteAll(ids); - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity<>(HttpStatus.OK); } } \ No newline at end of file diff --git a/eladmin-tools/src/main/java/me/zhengjie/rest/AliPayController.java b/eladmin-tools/src/main/java/me/zhengjie/rest/AliPayController.java index 5fc027849..f95241d7a 100644 --- a/eladmin-tools/src/main/java/me/zhengjie/rest/AliPayController.java +++ b/eladmin-tools/src/main/java/me/zhengjie/rest/AliPayController.java @@ -47,10 +47,10 @@ public ResponseEntity get(){ @Log("配置支付宝") @ApiOperation("配置支付宝") @PutMapping - public ResponseEntity payConfig(@Validated @RequestBody AlipayConfig alipayConfig){ + public ResponseEntity payConfig(@Validated @RequestBody AlipayConfig alipayConfig){ alipayConfig.setId(1L); alipayService.update(alipayConfig); - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity<>(HttpStatus.OK); } @Log("支付宝PC网页支付") diff --git a/eladmin-tools/src/main/java/me/zhengjie/rest/EmailController.java b/eladmin-tools/src/main/java/me/zhengjie/rest/EmailController.java index f4892e5f0..a203c9747 100644 --- a/eladmin-tools/src/main/java/me/zhengjie/rest/EmailController.java +++ b/eladmin-tools/src/main/java/me/zhengjie/rest/EmailController.java @@ -28,23 +28,23 @@ public EmailController(EmailService emailService) { } @GetMapping - public ResponseEntity get(){ + public ResponseEntity get(){ return new ResponseEntity<>(emailService.find(),HttpStatus.OK); } @Log("配置邮件") @PutMapping @ApiOperation("配置邮件") - public ResponseEntity emailConfig(@Validated @RequestBody EmailConfig emailConfig){ + public ResponseEntity emailConfig(@Validated @RequestBody EmailConfig emailConfig){ emailService.update(emailConfig,emailService.find()); - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity<>(HttpStatus.OK); } @Log("发送邮件") @PostMapping @ApiOperation("发送邮件") - public ResponseEntity send(@Validated @RequestBody EmailVo emailVo) throws Exception { + public ResponseEntity send(@Validated @RequestBody EmailVo emailVo) throws Exception { emailService.send(emailVo,emailService.find()); - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity<>(HttpStatus.OK); } } diff --git a/eladmin-tools/src/main/java/me/zhengjie/rest/LocalStorageController.java b/eladmin-tools/src/main/java/me/zhengjie/rest/LocalStorageController.java index 0dce020f3..2c7ef2aba 100644 --- a/eladmin-tools/src/main/java/me/zhengjie/rest/LocalStorageController.java +++ b/eladmin-tools/src/main/java/me/zhengjie/rest/LocalStorageController.java @@ -34,7 +34,7 @@ public LocalStorageController(LocalStorageService localStorageService) { @ApiOperation("查询文件") @GetMapping @PreAuthorize("@el.check('storage:list')") - public ResponseEntity getLocalStorages(LocalStorageQueryCriteria criteria, Pageable pageable){ + public ResponseEntity getLocalStorages(LocalStorageQueryCriteria criteria, Pageable pageable){ return new ResponseEntity<>(localStorageService.queryAll(criteria,pageable),HttpStatus.OK); } @@ -49,31 +49,31 @@ public void download(HttpServletResponse response, LocalStorageQueryCriteria cri @ApiOperation("上传文件") @PostMapping @PreAuthorize("@el.check('storage:add')") - public ResponseEntity create(@RequestParam String name, @RequestParam("file") MultipartFile file){ + public ResponseEntity create(@RequestParam String name, @RequestParam("file") MultipartFile file){ return new ResponseEntity<>(localStorageService.create(name, file),HttpStatus.CREATED); } @ApiOperation("修改文件") @PutMapping @PreAuthorize("@el.check('storage:edit')") - public ResponseEntity update(@Validated @RequestBody LocalStorage resources){ + public ResponseEntity update(@Validated @RequestBody LocalStorage resources){ localStorageService.update(resources); - return new ResponseEntity(HttpStatus.NO_CONTENT); + return new ResponseEntity<>(HttpStatus.NO_CONTENT); } @ApiOperation("删除文件") @DeleteMapping(value = "/{id}") @PreAuthorize("@el.check('storage:del')") - public ResponseEntity delete(@PathVariable Long id){ + public ResponseEntity delete(@PathVariable Long id){ localStorageService.delete(id); - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity<>(HttpStatus.OK); } @Log("多选删除") @DeleteMapping @ApiOperation("多选删除") - public ResponseEntity deleteAll(@RequestBody Long[] ids) { + public ResponseEntity deleteAll(@RequestBody Long[] ids) { localStorageService.deleteAll(ids); - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity<>(HttpStatus.OK); } } \ No newline at end of file diff --git a/eladmin-tools/src/main/java/me/zhengjie/rest/PictureController.java b/eladmin-tools/src/main/java/me/zhengjie/rest/PictureController.java index 8a7852f44..05913d96e 100644 --- a/eladmin-tools/src/main/java/me/zhengjie/rest/PictureController.java +++ b/eladmin-tools/src/main/java/me/zhengjie/rest/PictureController.java @@ -38,7 +38,7 @@ public PictureController(PictureService pictureService) { @PreAuthorize("@el.check('pictures:list')") @GetMapping @ApiOperation("查询图片") - public ResponseEntity getRoles(PictureQueryCriteria criteria, Pageable pageable){ + public ResponseEntity getRoles(PictureQueryCriteria criteria, Pageable pageable){ return new ResponseEntity<>(pictureService.queryAll(criteria,pageable),HttpStatus.OK); } @@ -54,7 +54,7 @@ public void download(HttpServletResponse response, PictureQueryCriteria criteria @PreAuthorize("@el.check('pictures:add')") @PostMapping @ApiOperation("上传图片") - public ResponseEntity upload(@RequestParam MultipartFile file){ + public ResponseEntity upload(@RequestParam MultipartFile file){ String userName = SecurityUtils.getUsername(); Picture picture = pictureService.upload(file,userName); Map map = new HashMap<>(3); @@ -68,9 +68,9 @@ public ResponseEntity upload(@RequestParam MultipartFile file){ @ApiOperation("删除图片") @PreAuthorize("@el.check('pictures:del')") @DeleteMapping(value = "/{id}") - public ResponseEntity delete(@PathVariable Long id) { + public ResponseEntity delete(@PathVariable Long id) { pictureService.delete(pictureService.findById(id)); - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity<>(HttpStatus.OK); } @Log("多选删除图片") diff --git a/eladmin-tools/src/main/java/me/zhengjie/rest/QiniuController.java b/eladmin-tools/src/main/java/me/zhengjie/rest/QiniuController.java index ad44571b3..66bba898c 100644 --- a/eladmin-tools/src/main/java/me/zhengjie/rest/QiniuController.java +++ b/eladmin-tools/src/main/java/me/zhengjie/rest/QiniuController.java @@ -37,17 +37,17 @@ public QiniuController(QiNiuService qiNiuService) { } @GetMapping(value = "/config") - public ResponseEntity get(){ + public ResponseEntity get(){ return new ResponseEntity<>(qiNiuService.find(), HttpStatus.OK); } @Log("配置七牛云存储") @ApiOperation("配置七牛云存储") @PutMapping(value = "/config") - public ResponseEntity emailConfig(@Validated @RequestBody QiniuConfig qiniuConfig){ + public ResponseEntity emailConfig(@Validated @RequestBody QiniuConfig qiniuConfig){ qiNiuService.update(qiniuConfig); qiNiuService.update(qiniuConfig.getType()); - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity<>(HttpStatus.OK); } @Log("导出数据") @@ -60,14 +60,14 @@ public void download(HttpServletResponse response, QiniuQueryCriteria criteria) @Log("查询文件") @ApiOperation("查询文件") @GetMapping - public ResponseEntity getRoles(QiniuQueryCriteria criteria, Pageable pageable){ + public ResponseEntity getRoles(QiniuQueryCriteria criteria, Pageable pageable){ return new ResponseEntity<>(qiNiuService.queryAll(criteria,pageable),HttpStatus.OK); } @Log("上传文件") @ApiOperation("上传文件") @PostMapping - public ResponseEntity upload(@RequestParam MultipartFile file){ + public ResponseEntity upload(@RequestParam MultipartFile file){ QiniuContent qiniuContent = qiNiuService.upload(file,qiNiuService.find()); Map map = new HashMap<>(3); map.put("id",qiniuContent.getId()); @@ -79,15 +79,15 @@ public ResponseEntity upload(@RequestParam MultipartFile file){ @Log("同步七牛云数据") @ApiOperation("同步七牛云数据") @PostMapping(value = "/synchronize") - public ResponseEntity synchronize(){ + public ResponseEntity synchronize(){ qiNiuService.synchronize(qiNiuService.find()); - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity<>(HttpStatus.OK); } @Log("下载文件") @ApiOperation("下载文件") @GetMapping(value = "/download/{id}") - public ResponseEntity download(@PathVariable Long id){ + public ResponseEntity download(@PathVariable Long id){ Map map = new HashMap<>(1); map.put("url", qiNiuService.download(qiNiuService.findByContentId(id),qiNiuService.find())); return new ResponseEntity<>(map,HttpStatus.OK); @@ -96,16 +96,16 @@ public ResponseEntity download(@PathVariable Long id){ @Log("删除文件") @ApiOperation("删除文件") @DeleteMapping(value = "/{id}") - public ResponseEntity delete(@PathVariable Long id){ + public ResponseEntity delete(@PathVariable Long id){ qiNiuService.delete(qiNiuService.findByContentId(id),qiNiuService.find()); - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity<>(HttpStatus.OK); } @Log("删除多张图片") @ApiOperation("删除多张图片") @DeleteMapping - public ResponseEntity deleteAll(@RequestBody Long[] ids) { + public ResponseEntity deleteAll(@RequestBody Long[] ids) { qiNiuService.deleteAll(ids, qiNiuService.find()); - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity<>(HttpStatus.OK); } } diff --git a/eladmin-tools/src/main/java/me/zhengjie/rest/VerificationCodeController.java b/eladmin-tools/src/main/java/me/zhengjie/rest/VerificationCodeController.java index bffa0948e..4657f0cc6 100644 --- a/eladmin-tools/src/main/java/me/zhengjie/rest/VerificationCodeController.java +++ b/eladmin-tools/src/main/java/me/zhengjie/rest/VerificationCodeController.java @@ -31,29 +31,29 @@ public VerificationCodeController(VerificationCodeService verificationCodeServic @PostMapping(value = "/resetEmail") @ApiOperation("重置邮箱,发送验证码") - public ResponseEntity resetEmail(@RequestBody VerificationCode code) throws Exception { + public ResponseEntity resetEmail(@RequestBody VerificationCode code) throws Exception { code.setScenes(ElAdminConstant.RESET_MAIL); EmailVo emailVo = verificationCodeService.sendEmail(code); emailService.send(emailVo,emailService.find()); - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity<>(HttpStatus.OK); } @PostMapping(value = "/email/resetPass") @ApiOperation("重置密码,发送验证码") - public ResponseEntity resetPass(@RequestParam String email) throws Exception { + public ResponseEntity resetPass(@RequestParam String email) throws Exception { VerificationCode code = new VerificationCode(); code.setType("email"); code.setValue(email); code.setScenes(ElAdminConstant.RESET_MAIL); EmailVo emailVo = verificationCodeService.sendEmail(code); emailService.send(emailVo,emailService.find()); - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity<>(HttpStatus.OK); } @GetMapping(value = "/validated") @ApiOperation("验证码验证") - public ResponseEntity validated(VerificationCode code){ + public ResponseEntity validated(VerificationCode code){ verificationCodeService.validated(code); - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity<>(HttpStatus.OK); } }