From bcf31e3683a921e8826a79d9331a318a0ce9472f Mon Sep 17 00:00:00 2001 From: "20932067@zju.edu.cn" Date: Fri, 19 Feb 2021 15:33:37 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E5=8C=96=E6=89=80=E6=9C=89ja?= =?UTF-8?q?va=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/hchyun/HchYunServletInitializer.java | 8 +- .../controller/common/CaptchaController.java | 6 +- .../controller/common/CommonController.java | 12 +- .../monitor/SysLogininforController.java | 6 +- .../monitor/SysOperlogController.java | 4 +- .../monitor/SysUserOnlineController.java | 2 +- .../web/controller/system/FileController.java | 4 +- .../controller/system/RegularController.java | 8 +- .../system/SysConfigController.java | 10 +- .../controller/system/SysDeptController.java | 12 +- .../system/SysDictDataController.java | 8 +- .../system/SysDictTypeController.java | 10 +- .../controller/system/SysLoginController.java | 6 +- .../controller/system/SysMenuController.java | 10 +- .../system/SysNoticeController.java | 6 +- .../controller/system/SysPostController.java | 8 +- .../system/SysProfileController.java | 12 +- .../controller/system/SysRoleController.java | 12 +- .../controller/system/SysUserController.java | 26 +- .../web/controller/tool/TestController.java | 12 +- .../hchyun/common/annotation/DataScope.java | 5 +- .../hchyun/common/annotation/DataSource.java | 8 +- .../com/hchyun/common/annotation/Excel.java | 24 +- .../com/hchyun/common/annotation/Excels.java | 5 +- .../com/hchyun/common/annotation/Log.java | 11 +- .../common/annotation/RepeatSubmit.java | 6 +- .../hchyun/common/config/HchYunConfig.java | 1 - .../com/hchyun/common/constant/Constants.java | 7 +- .../hchyun/common/constant/GenConstants.java | 179 ++++-- .../hchyun/common/constant/HttpStatus.java | 5 +- .../common/constant/ScheduleConstants.java | 34 +- .../hchyun/common/constant/UserConstants.java | 65 +- .../core/controller/HcyBaseController.java | 3 +- .../hchyun/common/core/entity/BaseEntity.java | 4 +- .../hchyun/common/core/entity/TreeEntity.java | 55 +- .../hchyun/common/core/entity/TreeSelect.java | 45 +- .../common/core/entity/entity/SysDept.java | 160 ++--- .../core/entity/entity/SysDictData.java | 133 ++-- .../core/entity/entity/SysDictType.java | 70 +-- .../common/core/entity/entity/SysMenu.java | 6 +- .../common/core/entity/entity/SysRole.java | 34 +- .../common/core/entity/entity/SysUser.java | 248 ++++---- .../common/core/entity/model/LoginBody.java | 29 +- .../common/core/entity/model/LoginUser.java | 93 +-- .../hchyun/common/core/page/PageDomain.java | 51 +- .../common/core/page/TableDataInfo.java | 55 +- .../hchyun/common/core/page/TableSupport.java | 11 +- .../hchyun/common/core/text/CharsetKit.java | 65 +- .../com/hchyun/common/core/text/Convert.java | 573 +++++++----------- .../hchyun/common/enums/BusinessStatus.java | 6 +- .../com/hchyun/common/enums/BusinessType.java | 7 +- .../hchyun/common/enums/DataSourceType.java | 5 +- .../com/hchyun/common/enums/HttpMethod.java | 16 +- .../com/hchyun/common/enums/OperatorType.java | 5 +- .../com/hchyun/common/enums/UserStatus.java | 14 +- .../common/exception/BaseException.java | 41 +- .../common/exception/CustomException.java | 20 +- .../common/exception/DemoModeException.java | 8 +- .../common/exception/UtilException.java | 14 +- .../common/exception/file/FileException.java | 8 +- .../FileNameLengthLimitExceededException.java | 10 +- .../file/FileSizeLimitExceededException.java | 10 +- .../file/InvalidExtensionException.java | 36 +- .../common/exception/job/TaskException.java | 17 +- .../exception/user/CaptchaException.java | 8 +- .../user/CaptchaExpireException.java | 8 +- .../common/exception/user/UserException.java | 8 +- .../user/UserPasswordNotMatchException.java | 8 +- .../common/filter/RepeatableFilter.java | 25 +- .../filter/RepeatedlyRequestWrapper.java | 30 +- .../com/hchyun/common/filter/XssFilter.java | 42 +- .../filter/XssHttpServletRequestWrapper.java | 47 +- .../java/com/hchyun/common/utils/Arith.java | 55 +- .../com/hchyun/common/utils/DateUtils.java | 9 +- .../com/hchyun/common/utils/DictUtils.java | 101 ++- .../hchyun/common/utils/ExceptionUtil.java | 16 +- .../com/hchyun/common/utils/LogUtils.java | 11 +- .../com/hchyun/common/utils/MessageUtils.java | 8 +- .../com/hchyun/common/utils/ServerResult.java | 8 +- .../com/hchyun/common/utils/ServletUtils.java | 61 +- .../com/hchyun/common/utils/StringUtils.java | 7 +- .../java/com/hchyun/common/utils/Threads.java | 62 +- .../hchyun/common/utils/VerifyCodeUtils.java | 80 +-- .../hchyun/common/utils/bean/BeanUtils.java | 58 +- .../common/utils/file/FileUploadUtils.java | 1 - .../common/utils/file/MimeTypeUtils.java | 23 +- .../hchyun/common/utils/html/EscapeUtil.java | 81 +-- .../hchyun/common/utils/html/HTMLFilter.java | 211 +++---- .../hchyun/common/utils/http/HttpHelper.java | 33 +- .../hchyun/common/utils/http/HttpUtils.java | 148 ++--- .../hchyun/common/utils/ip/AddressUtils.java | 8 +- .../com/hchyun/common/utils/ip/IpUtils.java | 89 +-- .../hchyun/common/utils/poi/ExcelUtil.java | 3 +- .../common/utils/reflect/ReflectUtils.java | 221 +++---- .../com/hchyun/common/utils/sign/Base64.java | 128 ++-- .../hchyun/common/utils/sign/Md5Utils.java | 38 +- .../common/utils/spring/SpringUtils.java | 49 +- .../com/hchyun/common/utils/sql/SqlUtil.java | 14 +- .../com/hchyun/common/utils/uuid/IdUtils.java | 25 +- .../com/hchyun/common/utils/uuid/UUID.java | 163 ++--- .../framework/aspectj/DataScopeAspect.java | 68 +-- .../framework/aspectj/DataSourceAspect.java | 28 +- .../hchyun/framework/aspectj/LogAspect.java | 83 +-- .../framework/config/ApplicationConfig.java | 7 +- .../framework/config/CaptchaConfig.java | 13 +- .../hchyun/framework/config/DruidConfig.java | 52 +- .../config/FastJson2JsonRedisSerializer.java | 30 +- .../hchyun/framework/config/FilterConfig.java | 14 +- .../framework/config/KaptchaTextCreator.java | 38 +- .../framework/config/MyBatisConfig.java | 48 +- .../hchyun/framework/config/RedisConfig.java | 10 +- .../framework/config/ResourcesConfig.java | 2 +- .../hchyun/framework/config/ServerConfig.java | 14 +- .../framework/config/ThreadPoolConfig.java | 16 +- .../config/properties/DruidProperties.java | 8 +- .../com/hchyun/framework/dao/AsyncDao.java | 20 +- .../framework/dao/factory/AsyncFactory.java | 41 +- .../datasource/DynamicDataSource.java | 12 +- .../DynamicDataSourceContextHolder.java | 16 +- .../interceptor/RepeatSubmitInterceptor.java | 20 +- .../filter/JwtAuthenticationTokenFilter.java | 12 +- .../handle/AuthenticationEntryPointImpl.java | 9 +- .../handle/LogoutSuccessHandlerImpl.java | 14 +- .../hchyun/framework/web/domain/Server.java | 79 +-- .../framework/web/domain/server/Cpu.java | 41 +- .../framework/web/domain/server/Jvm.java | 51 +- .../framework/web/domain/server/Mem.java | 26 +- .../framework/web/domain/server/Sys.java | 35 +- .../framework/web/domain/server/SysFile.java | 47 +- .../web/service/PermissionService.java | 85 ++- .../web/service/SysPermissionService.java | 30 +- .../web/service/UserDetailsServiceImpl.java | 20 +- .../hchyun/generator/config/GenConfig.java | 47 +- .../controller/ApiclassController.java | 23 +- .../controller/AssociatedController.java | 28 +- .../generator/controller/GenController.java | 34 +- .../controller/InterTableController.java | 6 +- .../controller/ModuleController.java | 20 +- .../generator/controller/QueryController.java | 28 +- .../controller/UniQueryController.java | 16 +- .../hchyun/generator/dao/AssociatedDao.java | 7 +- .../generator/dao/GenTableColumnDao.java | 18 +- .../com/hchyun/generator/dao/GenTableDao.java | 24 +- .../hchyun/generator/dao/InterTableDao.java | 6 +- .../com/hchyun/generator/dao/ModuleDao.java | 17 +- .../com/hchyun/generator/dao/QueryDao.java | 2 +- .../com/hchyun/generator/dao/UniQueryDao.java | 20 +- .../com/hchyun/generator/entity/Apiclass.java | 4 +- .../hchyun/generator/entity/AssColumn.java | 210 +++---- .../com/hchyun/generator/entity/GenTable.java | 279 +++++---- .../com/hchyun/generator/entity/UniCon.java | 8 +- .../com/hchyun/generator/entity/UniQuery.java | 6 +- .../generator/service/ApiclassService.java | 17 +- .../generator/service/AssociatedService.java | 12 +- .../service/IGenTableColumnService.java | 14 +- .../generator/service/IGenTableService.java | 33 +- .../generator/service/InterTableService.java | 12 +- .../generator/service/ModuleService.java | 17 +- .../generator/service/UniQueryService.java | 17 +- .../service/impl/ApiclassServiceImpl.java | 84 +-- .../service/impl/AssociatedServiceImpl.java | 6 +- .../impl/GenTableColumnServiceImpl.java | 75 ++- .../service/impl/GenTableServiceImpl.java | 8 +- .../service/impl/ModuleServiceImpl.java | 84 +-- .../service/impl/QueryServiceImpl.java | 4 +- .../service/impl/UniQueryServiceImpl.java | 70 +-- .../generator/util/InterTableUtils.java | 22 +- .../hchyun/generator/util/MapExcelUtil.java | 4 +- .../generator/util/VelocityInitializer.java | 16 +- .../hchyun/generator/util/VelocityUtils.java | 104 ++-- .../hchyun/quartz/config/ScheduleConfig.java | 24 +- .../quartz/controller/SysJobController.java | 36 +- .../controller/SysJobLogController.java | 23 +- .../java/com/hchyun/quartz/dao/SysJobDao.java | 20 +- .../com/hchyun/quartz/dao/SysJobLogDao.java | 16 +- .../java/com/hchyun/quartz/entity/SysJob.java | 122 ++-- .../com/hchyun/quartz/entity/SysJobLog.java | 118 ++-- .../quartz/service/ISysJobLogService.java | 16 +- .../hchyun/quartz/service/ISysJobService.java | 28 +- .../service/impl/SysJobLogServiceImpl.java | 34 +- .../service/impl/SysJobServiceImpl.java | 102 ++-- .../java/com/hchyun/quartz/task/RyTask.java | 14 +- .../hchyun/quartz/util/AbstractQuartzJob.java | 36 +- .../com/hchyun/quartz/util/CronUtils.java | 30 +- .../com/hchyun/quartz/util/JobInvokeUtil.java | 95 ++- .../QuartzDisallowConcurrentExecution.java | 9 +- .../quartz/util/QuartzJobExecution.java | 9 +- .../com/hchyun/quartz/util/ScheduleUtils.java | 30 +- hchyun/hchyun-system/pom.xml | 5 + .../com/hchyun/system/dao/RegularDao.java | 18 +- .../com/hchyun/system/dao/SysConfigDao.java | 20 +- .../com/hchyun/system/dao/SysDeptDao.java | 34 +- .../com/hchyun/system/dao/SysDictDataDao.java | 28 +- .../com/hchyun/system/dao/SysDictTypeDao.java | 24 +- .../hchyun/system/dao/SysLogininforDao.java | 14 +- .../com/hchyun/system/dao/SysMenuDao.java | 8 +- .../com/hchyun/system/dao/SysNoticeDao.java | 18 +- .../com/hchyun/system/dao/SysOperLogDao.java | 14 +- .../com/hchyun/system/dao/SysPostDao.java | 28 +- .../com/hchyun/system/dao/SysRoleDeptDao.java | 14 +- .../com/hchyun/system/dao/SysRoleMenuDao.java | 12 +- .../com/hchyun/system/dao/SysUserDao.java | 28 +- .../com/hchyun/system/dao/SysUserPostDao.java | 14 +- .../com/hchyun/system/dao/SysUserRoleDao.java | 20 +- .../com/hchyun/system/entity/Regular.java | 81 +-- .../com/hchyun/system/entity/SysConfig.java | 82 +-- .../com/hchyun/system/entity/SysFile.java | 27 +- .../hchyun/system/entity/SysLogininfor.java | 96 +-- .../com/hchyun/system/entity/SysNotice.java | 80 +-- .../com/hchyun/system/entity/SysOperLog.java | 176 +++--- .../com/hchyun/system/entity/SysPost.java | 92 +-- .../com/hchyun/system/entity/SysRoleDept.java | 35 +- .../com/hchyun/system/entity/SysRoleMenu.java | 35 +- .../hchyun/system/entity/SysUserOnline.java | 85 ++- .../com/hchyun/system/entity/SysUserPost.java | 35 +- .../com/hchyun/system/entity/SysUserRole.java | 35 +- .../com/hchyun/system/entity/vo/MetaVo.java | 32 +- .../com/hchyun/system/entity/vo/RouterVo.java | 54 +- .../hchyun/system/service/FileService.java | 1 + .../system/service/ISysConfigService.java | 20 +- .../system/service/ISysDeptService.java | 30 +- .../system/service/ISysDictDataService.java | 20 +- .../system/service/ISysDictTypeService.java | 24 +- .../system/service/ISysLogininforService.java | 12 +- .../system/service/ISysMenuService.java | 38 +- .../system/service/ISysNoticeService.java | 20 +- .../system/service/ISysOperLogService.java | 14 +- .../system/service/ISysPostService.java | 28 +- .../system/service/ISysRoleService.java | 38 +- .../system/service/ISysUserOnlineService.java | 21 +- .../system/service/ISysUserService.java | 46 +- .../hchyun/system/service/RegularService.java | 18 +- .../system/service/impl/FileServiceImpl.java | 100 +-- .../service/impl/SysDeptServiceImpl.java | 129 ++-- .../service/impl/SysDictDataServiceImpl.java | 47 +- .../service/impl/SysDictTypeServiceImpl.java | 84 +-- .../impl/SysLogininforServiceImpl.java | 24 +- .../service/impl/SysMenuServiceImpl.java | 194 +++--- .../service/impl/SysNoticeServiceImpl.java | 36 +- .../service/impl/SysOperLogServiceImpl.java | 29 +- .../service/impl/SysPostServiceImpl.java | 73 +-- .../service/impl/SysRoleServiceImpl.java | 124 ++-- .../impl/SysUserOnlineServiceImpl.java | 48 +- .../service/impl/SysUserServiceImpl.java | 189 +++--- .../com/hchyun/system/utils/FtpUtils.java | 19 +- .../java/com/hchyun/test/MapExcelUtil.java | 4 +- .../test/controller/AssFatherController.java | 20 +- .../test/controller/ResultsController.java | 24 +- .../hchyun/test/controller/StuController.java | 22 +- .../java/com/hchyun/test/controller/Test.java | 4 +- .../test/controller/TestTreeController.java | 13 +- .../com/hchyun/test/dao/AssFatherDao.java | 15 +- .../java/com/hchyun/test/dao/ResultsDao.java | 2 +- .../main/java/com/hchyun/test/dao/StuDao.java | 28 +- .../java/com/hchyun/test/dao/TestTreeDao.java | 18 +- .../com/hchyun/test/entity/AssFather.java | 49 +- .../java/com/hchyun/test/entity/AssSun.java | 29 +- .../java/com/hchyun/test/entity/Results.java | 73 +-- .../main/java/com/hchyun/test/entity/Stu.java | 81 +-- .../java/com/hchyun/test/entity/TestTree.java | 47 +- .../hchyun/test/service/AssFatherService.java | 17 +- .../hchyun/test/service/ResultsService.java | 17 +- .../com/hchyun/test/service/StuService.java | 17 +- .../hchyun/test/service/TestTreeService.java | 17 +- .../service/impl/AssFatherServiceImpl.java | 84 +-- .../test/service/impl/ResultsServiceImpl.java | 84 +-- .../test/service/impl/StuServiceImpl.java | 104 ++-- .../service/impl/TestTreeServiceImpl.java | 84 +-- .../java/com/hchyun/test/test/Maptest.java | 78 +-- 269 files changed, 4856 insertions(+), 6169 deletions(-) diff --git a/hchyun/hchyun-admin/src/main/java/com/hchyun/HchYunServletInitializer.java b/hchyun/hchyun-admin/src/main/java/com/hchyun/HchYunServletInitializer.java index 0780010..499c72f 100644 --- a/hchyun/hchyun-admin/src/main/java/com/hchyun/HchYunServletInitializer.java +++ b/hchyun/hchyun-admin/src/main/java/com/hchyun/HchYunServletInitializer.java @@ -5,14 +5,12 @@ import org.springframework.boot.web.servlet.support.SpringBootServletInitializer /** * web容器中进行部署 - * + * * @author hchyun */ -public class HchYunServletInitializer extends SpringBootServletInitializer -{ +public class HchYunServletInitializer extends SpringBootServletInitializer { @Override - protected SpringApplicationBuilder configure(SpringApplicationBuilder application) - { + protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { return application.sources(HchYunApplication.class); } } diff --git a/hchyun/hchyun-admin/src/main/java/com/hchyun/web/controller/common/CaptchaController.java b/hchyun/hchyun-admin/src/main/java/com/hchyun/web/controller/common/CaptchaController.java index 3f8d593..0152fd3 100644 --- a/hchyun/hchyun-admin/src/main/java/com/hchyun/web/controller/common/CaptchaController.java +++ b/hchyun/hchyun-admin/src/main/java/com/hchyun/web/controller/common/CaptchaController.java @@ -66,14 +66,14 @@ public class CaptchaController { // 转换流信息写出 FastByteArrayOutputStream os = new FastByteArrayOutputStream(); try { - ImageIO.write(image, "jpg" , os); + ImageIO.write(image, "jpg", os); } catch (IOException e) { return AjaxResult.error(e.getMessage()); } AjaxResult ajax = AjaxResult.success(); - ajax.put("uuid" , uuid); - ajax.put("img" , Base64.encode(os.toByteArray())); + ajax.put("uuid", uuid); + ajax.put("img", Base64.encode(os.toByteArray())); return ajax; } } diff --git a/hchyun/hchyun-admin/src/main/java/com/hchyun/web/controller/common/CommonController.java b/hchyun/hchyun-admin/src/main/java/com/hchyun/web/controller/common/CommonController.java index 59875c9..b8e38b1 100644 --- a/hchyun/hchyun-admin/src/main/java/com/hchyun/web/controller/common/CommonController.java +++ b/hchyun/hchyun-admin/src/main/java/com/hchyun/web/controller/common/CommonController.java @@ -47,14 +47,14 @@ public class CommonController { response.setCharacterEncoding("utf-8"); response.setContentType("multipart/form-data"); - response.setHeader("Content-Disposition" , + response.setHeader("Content-Disposition", "attachment;fileName=" + FileUtils.setFileDownloadHeader(request, realFileName)); FileUtils.writeBytes(filePath, response.getOutputStream()); if (delete) { FileUtils.deleteFile(filePath); } } catch (Exception e) { - log.error("下载文件失败" , e); + log.error("下载文件失败", e); } } @@ -70,9 +70,9 @@ public class CommonController { String fileName = FileUploadUtils.upload(filePath, file); String url = serverConfig.getUrl() + fileName; AjaxResult ajax = AjaxResult.success(); - ajax.put("fileName" , fileName); - ajax.put("url" , url); - ajax.put("addres","/test"); + ajax.put("fileName", fileName); + ajax.put("url", url); + ajax.put("addres", "/test"); return ajax; } catch (Exception e) { return AjaxResult.error(e.getMessage()); @@ -92,7 +92,7 @@ public class CommonController { String downloadName = StringUtils.substringAfterLast(downloadPath, "/"); response.setCharacterEncoding("utf-8"); response.setContentType("multipart/form-data"); - response.setHeader("Content-Disposition" , + response.setHeader("Content-Disposition", "attachment;fileName=" + FileUtils.setFileDownloadHeader(request, downloadName)); FileUtils.writeBytes(downloadPath, response.getOutputStream()); } diff --git a/hchyun/hchyun-admin/src/main/java/com/hchyun/web/controller/monitor/SysLogininforController.java b/hchyun/hchyun-admin/src/main/java/com/hchyun/web/controller/monitor/SysLogininforController.java index 86a6db0..26868aa 100644 --- a/hchyun/hchyun-admin/src/main/java/com/hchyun/web/controller/monitor/SysLogininforController.java +++ b/hchyun/hchyun-admin/src/main/java/com/hchyun/web/controller/monitor/SysLogininforController.java @@ -37,7 +37,7 @@ public class SysLogininforController extends BaseController { return getDataTable(list); } - @Log(title = "登录日志" , businessType = BusinessType.EXPORT) + @Log(title = "登录日志", businessType = BusinessType.EXPORT) @PreAuthorize("@ss.hasPermi('monitor:logininfor:export')") @GetMapping("/export") public AjaxResult export(SysLogininfor logininfor) { @@ -47,14 +47,14 @@ public class SysLogininforController extends BaseController { } @PreAuthorize("@ss.hasPermi('monitor:logininfor:remove')") - @Log(title = "登录日志" , businessType = BusinessType.DELETE) + @Log(title = "登录日志", businessType = BusinessType.DELETE) @DeleteMapping("/{infoIds}") public AjaxResult remove(@PathVariable Long[] infoIds) { return toAjax(logininforService.deleteLogininforByIds(infoIds)); } @PreAuthorize("@ss.hasPermi('monitor:logininfor:remove')") - @Log(title = "登录日志" , businessType = BusinessType.CLEAN) + @Log(title = "登录日志", businessType = BusinessType.CLEAN) @DeleteMapping("/clean") public AjaxResult clean() { logininforService.cleanLogininfor(); diff --git a/hchyun/hchyun-admin/src/main/java/com/hchyun/web/controller/monitor/SysOperlogController.java b/hchyun/hchyun-admin/src/main/java/com/hchyun/web/controller/monitor/SysOperlogController.java index 6f55ad2..d9fc61c 100644 --- a/hchyun/hchyun-admin/src/main/java/com/hchyun/web/controller/monitor/SysOperlogController.java +++ b/hchyun/hchyun-admin/src/main/java/com/hchyun/web/controller/monitor/SysOperlogController.java @@ -37,7 +37,7 @@ public class SysOperlogController extends BaseController { return getDataTable(list); } - @Log(title = "操作日志" , businessType = BusinessType.EXPORT) + @Log(title = "操作日志", businessType = BusinessType.EXPORT) @PreAuthorize("@ss.hasPermi('monitor:operlog:export')") @GetMapping("/export") public AjaxResult export(SysOperLog operLog) { @@ -52,7 +52,7 @@ public class SysOperlogController extends BaseController { return toAjax(operLogService.deleteOperLogByIds(operIds)); } - @Log(title = "操作日志" , businessType = BusinessType.CLEAN) + @Log(title = "操作日志", businessType = BusinessType.CLEAN) @PreAuthorize("@ss.hasPermi('monitor:operlog:remove')") @DeleteMapping("/clean") public AjaxResult clean() { diff --git a/hchyun/hchyun-admin/src/main/java/com/hchyun/web/controller/monitor/SysUserOnlineController.java b/hchyun/hchyun-admin/src/main/java/com/hchyun/web/controller/monitor/SysUserOnlineController.java index 35c5bcc..80d5cfd 100644 --- a/hchyun/hchyun-admin/src/main/java/com/hchyun/web/controller/monitor/SysUserOnlineController.java +++ b/hchyun/hchyun-admin/src/main/java/com/hchyun/web/controller/monitor/SysUserOnlineController.java @@ -70,7 +70,7 @@ public class SysUserOnlineController extends BaseController { * 强退用户 */ @PreAuthorize("@ss.hasPermi('monitor:online:forceLogout')") - @Log(title = "在线用户" , businessType = BusinessType.FORCE) + @Log(title = "在线用户", businessType = BusinessType.FORCE) @DeleteMapping("/{tokenId}") public AjaxResult forceLogout(@PathVariable String tokenId) { redisCache.deleteObject(Constants.LOGIN_TOKEN_KEY + tokenId); diff --git a/hchyun/hchyun-admin/src/main/java/com/hchyun/web/controller/system/FileController.java b/hchyun/hchyun-admin/src/main/java/com/hchyun/web/controller/system/FileController.java index 6e32175..58e0f16 100644 --- a/hchyun/hchyun-admin/src/main/java/com/hchyun/web/controller/system/FileController.java +++ b/hchyun/hchyun-admin/src/main/java/com/hchyun/web/controller/system/FileController.java @@ -191,9 +191,9 @@ public class FileController extends HcyBaseController { public AjaxResult download(@PathVariable Long fileId, HttpServletRequest request, HttpServletResponse response) { try { ServerResult serverResult = fileService.downloadFile(fileId); - if (serverResult.isStart()){ + if (serverResult.isStart()) { return AjaxResult.success(serverResult.getData().getFileName()); - }else { + } else { return AjaxResult.error(serverResult.getMsg()); } } catch (RuntimeException e) { diff --git a/hchyun/hchyun-admin/src/main/java/com/hchyun/web/controller/system/RegularController.java b/hchyun/hchyun-admin/src/main/java/com/hchyun/web/controller/system/RegularController.java index 5803c0a..735fc4a 100644 --- a/hchyun/hchyun-admin/src/main/java/com/hchyun/web/controller/system/RegularController.java +++ b/hchyun/hchyun-admin/src/main/java/com/hchyun/web/controller/system/RegularController.java @@ -70,7 +70,7 @@ public class RegularController extends HcyBaseController { * @return */ @PreAuthorize("@ss.hasPermi('system:regular:export')") - @Log(title = "校验规则" , businessType = BusinessType.EXPORT) + @Log(title = "校验规则", businessType = BusinessType.EXPORT) @GetMapping("/export") public AjaxResult export(Regular regular) { try { @@ -116,7 +116,7 @@ public class RegularController extends HcyBaseController { * @return */ @PreAuthorize("@ss.hasPermi('system:regular:add')") - @Log(title = "校验规则" , businessType = BusinessType.INSERT) + @Log(title = "校验规则", businessType = BusinessType.INSERT) @PostMapping public AjaxResult add(@RequestBody Regular regular) { try { @@ -151,7 +151,7 @@ public class RegularController extends HcyBaseController { * @return */ @PreAuthorize("@ss.hasPermi('system:regular:edit')") - @Log(title = "校验规则" , businessType = BusinessType.UPDATE) + @Log(title = "校验规则", businessType = BusinessType.UPDATE) @PutMapping public AjaxResult edit(@RequestBody Regular regular) { try { @@ -186,7 +186,7 @@ public class RegularController extends HcyBaseController { * @return */ @PreAuthorize("@ss.hasPermi('system:regular:remove')") - @Log(title = "校验规则" , businessType = BusinessType.DELETE) + @Log(title = "校验规则", businessType = BusinessType.DELETE) @DeleteMapping("/{ids}") public AjaxResult remove(@PathVariable Long[] ids) { try { diff --git a/hchyun/hchyun-admin/src/main/java/com/hchyun/web/controller/system/SysConfigController.java b/hchyun/hchyun-admin/src/main/java/com/hchyun/web/controller/system/SysConfigController.java index 56424d1..4f5cdb4 100644 --- a/hchyun/hchyun-admin/src/main/java/com/hchyun/web/controller/system/SysConfigController.java +++ b/hchyun/hchyun-admin/src/main/java/com/hchyun/web/controller/system/SysConfigController.java @@ -47,7 +47,7 @@ public class SysConfigController extends BaseController { return getDataTable(list); } - @Log(title = "参数管理" , businessType = BusinessType.EXPORT) + @Log(title = "参数管理", businessType = BusinessType.EXPORT) @PreAuthorize("@ss.hasPermi('system:config:export')") @GetMapping("/export") public AjaxResult export(SysConfig config) { @@ -77,7 +77,7 @@ public class SysConfigController extends BaseController { * 新增参数配置 */ @PreAuthorize("@ss.hasPermi('system:config:add')") - @Log(title = "参数管理" , businessType = BusinessType.INSERT) + @Log(title = "参数管理", businessType = BusinessType.INSERT) @PostMapping @RepeatSubmit public AjaxResult add(@Validated @RequestBody SysConfig config) { @@ -92,7 +92,7 @@ public class SysConfigController extends BaseController { * 修改参数配置 */ @PreAuthorize("@ss.hasPermi('system:config:edit')") - @Log(title = "参数管理" , businessType = BusinessType.UPDATE) + @Log(title = "参数管理", businessType = BusinessType.UPDATE) @PutMapping public AjaxResult edit(@Validated @RequestBody SysConfig config) { if (UserConstants.NOT_UNIQUE.equals(configService.checkConfigKeyUnique(config))) { @@ -106,7 +106,7 @@ public class SysConfigController extends BaseController { * 删除参数配置 */ @PreAuthorize("@ss.hasPermi('system:config:remove')") - @Log(title = "参数管理" , businessType = BusinessType.DELETE) + @Log(title = "参数管理", businessType = BusinessType.DELETE) @DeleteMapping("/{configIds}") public AjaxResult remove(@PathVariable Long[] configIds) { return toAjax(configService.deleteConfigByIds(configIds)); @@ -116,7 +116,7 @@ public class SysConfigController extends BaseController { * 清空缓存 */ @PreAuthorize("@ss.hasPermi('system:config:remove')") - @Log(title = "参数管理" , businessType = BusinessType.CLEAN) + @Log(title = "参数管理", businessType = BusinessType.CLEAN) @DeleteMapping("/clearCache") public AjaxResult clearCache() { configService.clearCache(); diff --git a/hchyun/hchyun-admin/src/main/java/com/hchyun/web/controller/system/SysDeptController.java b/hchyun/hchyun-admin/src/main/java/com/hchyun/web/controller/system/SysDeptController.java index 29c3e82..1a4bf05 100644 --- a/hchyun/hchyun-admin/src/main/java/com/hchyun/web/controller/system/SysDeptController.java +++ b/hchyun/hchyun-admin/src/main/java/com/hchyun/web/controller/system/SysDeptController.java @@ -51,7 +51,7 @@ public class SysDeptController extends BaseController { */ @PreAuthorize("@ss.hasPermi('system:dept:list')") @GetMapping("/list/exclude/{deptId}") - public AjaxResult excludeChild(@PathVariable(value = "deptId" , required = false) Long deptId) { + public AjaxResult excludeChild(@PathVariable(value = "deptId", required = false) Long deptId) { List depts = deptService.selectDeptList(new SysDept()); Iterator it = depts.iterator(); while (it.hasNext()) { @@ -89,8 +89,8 @@ public class SysDeptController extends BaseController { public AjaxResult roleDeptTreeselect(@PathVariable("roleId") Long roleId) { List depts = deptService.selectDeptList(new SysDept()); AjaxResult ajax = AjaxResult.success(); - ajax.put("checkedKeys" , deptService.selectDeptListByRoleId(roleId)); - ajax.put("depts" , deptService.buildDeptTreeSelect(depts)); + ajax.put("checkedKeys", deptService.selectDeptListByRoleId(roleId)); + ajax.put("depts", deptService.buildDeptTreeSelect(depts)); return ajax; } @@ -98,7 +98,7 @@ public class SysDeptController extends BaseController { * 新增部门 */ @PreAuthorize("@ss.hasPermi('system:dept:add')") - @Log(title = "部门管理" , businessType = BusinessType.INSERT) + @Log(title = "部门管理", businessType = BusinessType.INSERT) @PostMapping public AjaxResult add(@Validated @RequestBody SysDept dept) { if (UserConstants.NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept))) { @@ -112,7 +112,7 @@ public class SysDeptController extends BaseController { * 修改部门 */ @PreAuthorize("@ss.hasPermi('system:dept:edit')") - @Log(title = "部门管理" , businessType = BusinessType.UPDATE) + @Log(title = "部门管理", businessType = BusinessType.UPDATE) @PutMapping public AjaxResult edit(@Validated @RequestBody SysDept dept) { if (UserConstants.NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept))) { @@ -131,7 +131,7 @@ public class SysDeptController extends BaseController { * 删除部门 */ @PreAuthorize("@ss.hasPermi('system:dept:remove')") - @Log(title = "部门管理" , businessType = BusinessType.DELETE) + @Log(title = "部门管理", businessType = BusinessType.DELETE) @DeleteMapping("/{deptId}") public AjaxResult remove(@PathVariable Long deptId) { if (deptService.hasChildByDeptId(deptId)) { diff --git a/hchyun/hchyun-admin/src/main/java/com/hchyun/web/controller/system/SysDictDataController.java b/hchyun/hchyun-admin/src/main/java/com/hchyun/web/controller/system/SysDictDataController.java index 8df0102..e646d4c 100644 --- a/hchyun/hchyun-admin/src/main/java/com/hchyun/web/controller/system/SysDictDataController.java +++ b/hchyun/hchyun-admin/src/main/java/com/hchyun/web/controller/system/SysDictDataController.java @@ -46,7 +46,7 @@ public class SysDictDataController extends BaseController { return getDataTable(list); } - @Log(title = "字典数据" , businessType = BusinessType.EXPORT) + @Log(title = "字典数据", businessType = BusinessType.EXPORT) @PreAuthorize("@ss.hasPermi('system:dict:export')") @GetMapping("/export") public AjaxResult export(SysDictData dictData) { @@ -76,7 +76,7 @@ public class SysDictDataController extends BaseController { * 新增字典类型 */ @PreAuthorize("@ss.hasPermi('system:dict:add')") - @Log(title = "字典数据" , businessType = BusinessType.INSERT) + @Log(title = "字典数据", businessType = BusinessType.INSERT) @PostMapping public AjaxResult add(@Validated @RequestBody SysDictData dict) { dict.setCreateBy(SecurityUtils.getUserId()); @@ -87,7 +87,7 @@ public class SysDictDataController extends BaseController { * 修改保存字典类型 */ @PreAuthorize("@ss.hasPermi('system:dict:edit')") - @Log(title = "字典数据" , businessType = BusinessType.UPDATE) + @Log(title = "字典数据", businessType = BusinessType.UPDATE) @PutMapping public AjaxResult edit(@Validated @RequestBody SysDictData dict) { dict.setUpdateBy(SecurityUtils.getUserId()); @@ -98,7 +98,7 @@ public class SysDictDataController extends BaseController { * 删除字典类型 */ @PreAuthorize("@ss.hasPermi('system:dict:remove')") - @Log(title = "字典类型" , businessType = BusinessType.DELETE) + @Log(title = "字典类型", businessType = BusinessType.DELETE) @DeleteMapping("/{dictCodes}") public AjaxResult remove(@PathVariable Long[] dictCodes) { return toAjax(dictDataService.deleteDictDataByIds(dictCodes)); diff --git a/hchyun/hchyun-admin/src/main/java/com/hchyun/web/controller/system/SysDictTypeController.java b/hchyun/hchyun-admin/src/main/java/com/hchyun/web/controller/system/SysDictTypeController.java index 9f494eb..6523d20 100644 --- a/hchyun/hchyun-admin/src/main/java/com/hchyun/web/controller/system/SysDictTypeController.java +++ b/hchyun/hchyun-admin/src/main/java/com/hchyun/web/controller/system/SysDictTypeController.java @@ -43,7 +43,7 @@ public class SysDictTypeController extends BaseController { return getDataTable(list); } - @Log(title = "字典类型" , businessType = BusinessType.EXPORT) + @Log(title = "字典类型", businessType = BusinessType.EXPORT) @PreAuthorize("@ss.hasPermi('system:dict:export')") @GetMapping("/export") public AjaxResult export(SysDictType dictType) { @@ -65,7 +65,7 @@ public class SysDictTypeController extends BaseController { * 新增字典类型 */ @PreAuthorize("@ss.hasPermi('system:dict:add')") - @Log(title = "字典类型" , businessType = BusinessType.INSERT) + @Log(title = "字典类型", businessType = BusinessType.INSERT) @PostMapping public AjaxResult add(@Validated @RequestBody SysDictType dict) { if (UserConstants.NOT_UNIQUE.equals(dictTypeService.checkDictTypeUnique(dict))) { @@ -79,7 +79,7 @@ public class SysDictTypeController extends BaseController { * 修改字典类型 */ @PreAuthorize("@ss.hasPermi('system:dict:edit')") - @Log(title = "字典类型" , businessType = BusinessType.UPDATE) + @Log(title = "字典类型", businessType = BusinessType.UPDATE) @PutMapping public AjaxResult edit(@Validated @RequestBody SysDictType dict) { if (UserConstants.NOT_UNIQUE.equals(dictTypeService.checkDictTypeUnique(dict))) { @@ -93,7 +93,7 @@ public class SysDictTypeController extends BaseController { * 删除字典类型 */ @PreAuthorize("@ss.hasPermi('system:dict:remove')") - @Log(title = "字典类型" , businessType = BusinessType.DELETE) + @Log(title = "字典类型", businessType = BusinessType.DELETE) @DeleteMapping("/{dictIds}") public AjaxResult remove(@PathVariable Long[] dictIds) { return toAjax(dictTypeService.deleteDictTypeByIds(dictIds)); @@ -103,7 +103,7 @@ public class SysDictTypeController extends BaseController { * 清空缓存 */ @PreAuthorize("@ss.hasPermi('system:dict:remove')") - @Log(title = "字典类型" , businessType = BusinessType.CLEAN) + @Log(title = "字典类型", businessType = BusinessType.CLEAN) @DeleteMapping("/clearCache") public AjaxResult clearCache() { dictTypeService.clearCache(); diff --git a/hchyun/hchyun-admin/src/main/java/com/hchyun/web/controller/system/SysLoginController.java b/hchyun/hchyun-admin/src/main/java/com/hchyun/web/controller/system/SysLoginController.java index 07fca91..bb21ef0 100644 --- a/hchyun/hchyun-admin/src/main/java/com/hchyun/web/controller/system/SysLoginController.java +++ b/hchyun/hchyun-admin/src/main/java/com/hchyun/web/controller/system/SysLoginController.java @@ -69,9 +69,9 @@ public class SysLoginController { // 权限集合 Set permissions = permissionService.getMenuPermission(user); AjaxResult ajax = AjaxResult.success(); - ajax.put("user" , user); - ajax.put("roles" , roles); - ajax.put("permissions" , permissions); + ajax.put("user", user); + ajax.put("roles", roles); + ajax.put("permissions", permissions); return ajax; } diff --git a/hchyun/hchyun-admin/src/main/java/com/hchyun/web/controller/system/SysMenuController.java b/hchyun/hchyun-admin/src/main/java/com/hchyun/web/controller/system/SysMenuController.java index 70e3d00..ebc69a6 100644 --- a/hchyun/hchyun-admin/src/main/java/com/hchyun/web/controller/system/SysMenuController.java +++ b/hchyun/hchyun-admin/src/main/java/com/hchyun/web/controller/system/SysMenuController.java @@ -81,8 +81,8 @@ public class SysMenuController extends BaseController { LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest()); List menus = menuService.selectMenuList(loginUser.getUser().getUserId()); AjaxResult ajax = AjaxResult.success(); - ajax.put("checkedKeys" , menuService.selectMenuListByRoleId(roleId)); - ajax.put("menus" , menuService.buildMenuTreeSelect(menus)); + ajax.put("checkedKeys", menuService.selectMenuListByRoleId(roleId)); + ajax.put("menus", menuService.buildMenuTreeSelect(menus)); return ajax; } @@ -90,7 +90,7 @@ public class SysMenuController extends BaseController { * 新增菜单 */ @PreAuthorize("@ss.hasPermi('system:menu:add')") - @Log(title = "菜单管理" , businessType = BusinessType.INSERT) + @Log(title = "菜单管理", businessType = BusinessType.INSERT) @PostMapping public AjaxResult add(@Validated @RequestBody SysMenu menu) { if (UserConstants.NOT_UNIQUE.equals(menuService.checkMenuNameUnique(menu))) { @@ -107,7 +107,7 @@ public class SysMenuController extends BaseController { * 修改菜单 */ @PreAuthorize("@ss.hasPermi('system:menu:edit')") - @Log(title = "菜单管理" , businessType = BusinessType.UPDATE) + @Log(title = "菜单管理", businessType = BusinessType.UPDATE) @PutMapping public AjaxResult edit(@Validated @RequestBody SysMenu menu) { if (UserConstants.NOT_UNIQUE.equals(menuService.checkMenuNameUnique(menu))) { @@ -126,7 +126,7 @@ public class SysMenuController extends BaseController { * 删除菜单 */ @PreAuthorize("@ss.hasPermi('system:menu:remove')") - @Log(title = "菜单管理" , businessType = BusinessType.DELETE) + @Log(title = "菜单管理", businessType = BusinessType.DELETE) @DeleteMapping("/{menuId}") public AjaxResult remove(@PathVariable("menuId") Long menuId) { if (menuService.hasChildByMenuId(menuId)) { diff --git a/hchyun/hchyun-admin/src/main/java/com/hchyun/web/controller/system/SysNoticeController.java b/hchyun/hchyun-admin/src/main/java/com/hchyun/web/controller/system/SysNoticeController.java index a4601a7..6a2cf37 100644 --- a/hchyun/hchyun-admin/src/main/java/com/hchyun/web/controller/system/SysNoticeController.java +++ b/hchyun/hchyun-admin/src/main/java/com/hchyun/web/controller/system/SysNoticeController.java @@ -57,7 +57,7 @@ public class SysNoticeController extends BaseController { * 新增通知公告 */ @PreAuthorize("@ss.hasPermi('system:notice:add')") - @Log(title = "通知公告" , businessType = BusinessType.INSERT) + @Log(title = "通知公告", businessType = BusinessType.INSERT) @PostMapping public AjaxResult add(@Validated @RequestBody SysNotice notice) { notice.setCreateBy(SecurityUtils.getUserId()); @@ -68,7 +68,7 @@ public class SysNoticeController extends BaseController { * 修改通知公告 */ @PreAuthorize("@ss.hasPermi('system:notice:edit')") - @Log(title = "通知公告" , businessType = BusinessType.UPDATE) + @Log(title = "通知公告", businessType = BusinessType.UPDATE) @PutMapping public AjaxResult edit(@Validated @RequestBody SysNotice notice) { notice.setUpdateBy(SecurityUtils.getUserId()); @@ -79,7 +79,7 @@ public class SysNoticeController extends BaseController { * 删除通知公告 */ @PreAuthorize("@ss.hasPermi('system:notice:remove')") - @Log(title = "通知公告" , businessType = BusinessType.DELETE) + @Log(title = "通知公告", businessType = BusinessType.DELETE) @DeleteMapping("/{noticeIds}") public AjaxResult remove(@PathVariable Long[] noticeIds) { return toAjax(noticeService.deleteNoticeByIds(noticeIds)); diff --git a/hchyun/hchyun-admin/src/main/java/com/hchyun/web/controller/system/SysPostController.java b/hchyun/hchyun-admin/src/main/java/com/hchyun/web/controller/system/SysPostController.java index 9a59620..87d3520 100644 --- a/hchyun/hchyun-admin/src/main/java/com/hchyun/web/controller/system/SysPostController.java +++ b/hchyun/hchyun-admin/src/main/java/com/hchyun/web/controller/system/SysPostController.java @@ -46,7 +46,7 @@ public class SysPostController extends BaseController { return getDataTable(list); } - @Log(title = "岗位管理" , businessType = BusinessType.EXPORT) + @Log(title = "岗位管理", businessType = BusinessType.EXPORT) @PreAuthorize("@ss.hasPermi('system:post:export')") @GetMapping("/export") public AjaxResult export(SysPost post) { @@ -68,7 +68,7 @@ public class SysPostController extends BaseController { * 新增岗位 */ @PreAuthorize("@ss.hasPermi('system:post:add')") - @Log(title = "岗位管理" , businessType = BusinessType.INSERT) + @Log(title = "岗位管理", businessType = BusinessType.INSERT) @PostMapping public AjaxResult add(@Validated @RequestBody SysPost post) { if (UserConstants.NOT_UNIQUE.equals(postService.checkPostNameUnique(post))) { @@ -84,7 +84,7 @@ public class SysPostController extends BaseController { * 修改岗位 */ @PreAuthorize("@ss.hasPermi('system:post:edit')") - @Log(title = "岗位管理" , businessType = BusinessType.UPDATE) + @Log(title = "岗位管理", businessType = BusinessType.UPDATE) @PutMapping public AjaxResult edit(@Validated @RequestBody SysPost post) { if (UserConstants.NOT_UNIQUE.equals(postService.checkPostNameUnique(post))) { @@ -100,7 +100,7 @@ public class SysPostController extends BaseController { * 删除岗位 */ @PreAuthorize("@ss.hasPermi('system:post:remove')") - @Log(title = "岗位管理" , businessType = BusinessType.DELETE) + @Log(title = "岗位管理", businessType = BusinessType.DELETE) @DeleteMapping("/{postIds}") public AjaxResult remove(@PathVariable Long[] postIds) { return toAjax(postService.deletePostByIds(postIds)); diff --git a/hchyun/hchyun-admin/src/main/java/com/hchyun/web/controller/system/SysProfileController.java b/hchyun/hchyun-admin/src/main/java/com/hchyun/web/controller/system/SysProfileController.java index 59d8385..999dcee 100644 --- a/hchyun/hchyun-admin/src/main/java/com/hchyun/web/controller/system/SysProfileController.java +++ b/hchyun/hchyun-admin/src/main/java/com/hchyun/web/controller/system/SysProfileController.java @@ -46,15 +46,15 @@ public class SysProfileController extends BaseController { LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest()); SysUser user = loginUser.getUser(); AjaxResult ajax = AjaxResult.success(user); - ajax.put("roleGroup" , userService.selectUserRoleGroup(loginUser.getUsername())); - ajax.put("postGroup" , userService.selectUserPostGroup(loginUser.getUsername())); + ajax.put("roleGroup", userService.selectUserRoleGroup(loginUser.getUsername())); + ajax.put("postGroup", userService.selectUserPostGroup(loginUser.getUsername())); return ajax; } /** * 修改用户 */ - @Log(title = "个人信息" , businessType = BusinessType.UPDATE) + @Log(title = "个人信息", businessType = BusinessType.UPDATE) @PutMapping public AjaxResult updateProfile(@RequestBody SysUser user) { if (userService.updateUserProfile(user) > 0) { @@ -73,7 +73,7 @@ public class SysProfileController extends BaseController { /** * 重置密码 */ - @Log(title = "个人信息" , businessType = BusinessType.UPDATE) + @Log(title = "个人信息", businessType = BusinessType.UPDATE) @PutMapping("/updatePwd") public AjaxResult updatePwd(String oldPassword, String newPassword) { LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest()); @@ -97,7 +97,7 @@ public class SysProfileController extends BaseController { /** * 头像上传 */ - @Log(title = "用户头像" , businessType = BusinessType.UPDATE) + @Log(title = "用户头像", businessType = BusinessType.UPDATE) @PostMapping("/avatar") public AjaxResult avatar(@RequestParam("avatarfile") MultipartFile file) throws IOException { if (!file.isEmpty()) { @@ -105,7 +105,7 @@ public class SysProfileController extends BaseController { String avatar = FileUploadUtils.upload(HchYunConfig.getAvatarPath(), file); if (userService.updateUserAvatar(loginUser.getUsername(), avatar)) { AjaxResult ajax = AjaxResult.success(); - ajax.put("imgUrl" , avatar); + ajax.put("imgUrl", avatar); // 更新缓存用户头像 loginUser.getUser().setAvatar(avatar); tokenService.setLoginUser(loginUser); diff --git a/hchyun/hchyun-admin/src/main/java/com/hchyun/web/controller/system/SysRoleController.java b/hchyun/hchyun-admin/src/main/java/com/hchyun/web/controller/system/SysRoleController.java index 8fb36ea..82206f5 100644 --- a/hchyun/hchyun-admin/src/main/java/com/hchyun/web/controller/system/SysRoleController.java +++ b/hchyun/hchyun-admin/src/main/java/com/hchyun/web/controller/system/SysRoleController.java @@ -61,7 +61,7 @@ public class SysRoleController extends BaseController { return getDataTable(list); } - @Log(title = "角色管理" , businessType = BusinessType.EXPORT) + @Log(title = "角色管理", businessType = BusinessType.EXPORT) @PreAuthorize("@ss.hasPermi('system:role:export')") @GetMapping("/export") public AjaxResult export(SysRole role) { @@ -83,7 +83,7 @@ public class SysRoleController extends BaseController { * 新增角色 */ @PreAuthorize("@ss.hasPermi('system:role:add')") - @Log(title = "角色管理" , businessType = BusinessType.INSERT) + @Log(title = "角色管理", businessType = BusinessType.INSERT) @PostMapping public AjaxResult add(@Validated @RequestBody SysRole role) { if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleNameUnique(role))) { @@ -100,7 +100,7 @@ public class SysRoleController extends BaseController { * 修改保存角色 */ @PreAuthorize("@ss.hasPermi('system:role:edit')") - @Log(title = "角色管理" , businessType = BusinessType.UPDATE) + @Log(title = "角色管理", businessType = BusinessType.UPDATE) @PutMapping public AjaxResult edit(@Validated @RequestBody SysRole role) { roleService.checkRoleAllowed(role); @@ -128,7 +128,7 @@ public class SysRoleController extends BaseController { * 修改保存数据权限 */ @PreAuthorize("@ss.hasPermi('system:role:edit')") - @Log(title = "角色管理" , businessType = BusinessType.UPDATE) + @Log(title = "角色管理", businessType = BusinessType.UPDATE) @PutMapping("/dataScope") public AjaxResult dataScope(@RequestBody SysRole role) { roleService.checkRoleAllowed(role); @@ -139,7 +139,7 @@ public class SysRoleController extends BaseController { * 状态修改 */ @PreAuthorize("@ss.hasPermi('system:role:edit')") - @Log(title = "角色管理" , businessType = BusinessType.UPDATE) + @Log(title = "角色管理", businessType = BusinessType.UPDATE) @PutMapping("/changeStatus") public AjaxResult changeStatus(@RequestBody SysRole role) { roleService.checkRoleAllowed(role); @@ -151,7 +151,7 @@ public class SysRoleController extends BaseController { * 删除角色 */ @PreAuthorize("@ss.hasPermi('system:role:remove')") - @Log(title = "角色管理" , businessType = BusinessType.DELETE) + @Log(title = "角色管理", businessType = BusinessType.DELETE) @DeleteMapping("/{roleIds}") public AjaxResult remove(@PathVariable Long[] roleIds) { return toAjax(roleService.deleteRoleByIds(roleIds)); diff --git a/hchyun/hchyun-admin/src/main/java/com/hchyun/web/controller/system/SysUserController.java b/hchyun/hchyun-admin/src/main/java/com/hchyun/web/controller/system/SysUserController.java index 9924b92..9e9c140 100644 --- a/hchyun/hchyun-admin/src/main/java/com/hchyun/web/controller/system/SysUserController.java +++ b/hchyun/hchyun-admin/src/main/java/com/hchyun/web/controller/system/SysUserController.java @@ -64,7 +64,7 @@ public class SysUserController extends BaseController { return getDataTable(list); } - @Log(title = "用户管理" , businessType = BusinessType.EXPORT) + @Log(title = "用户管理", businessType = BusinessType.EXPORT) @PreAuthorize("@ss.hasPermi('system:user:export')") @GetMapping("/export") public AjaxResult export(SysUser user) { @@ -73,7 +73,7 @@ public class SysUserController extends BaseController { return util.exportExcel(list, "用户数据"); } - @Log(title = "用户管理" , businessType = BusinessType.IMPORT) + @Log(title = "用户管理", businessType = BusinessType.IMPORT) @PreAuthorize("@ss.hasPermi('system:user:import')") @PostMapping("/importData") public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception { @@ -95,16 +95,16 @@ public class SysUserController extends BaseController { * 根据用户编号获取详细信息 */ @PreAuthorize("@ss.hasPermi('system:user:query')") - @GetMapping(value = {"/" , "/{userId}"}) - public AjaxResult getInfo(@PathVariable(value = "userId" , required = false) Long userId) { + @GetMapping(value = {"/", "/{userId}"}) + public AjaxResult getInfo(@PathVariable(value = "userId", required = false) Long userId) { AjaxResult ajax = AjaxResult.success(); List roles = roleService.selectRoleAll(1); - ajax.put("roles" , SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList())); - ajax.put("posts" , postService.selectPostAll()); + ajax.put("roles", SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList())); + ajax.put("posts", postService.selectPostAll()); if (StringUtils.isNotNull(userId)) { ajax.put(AjaxResult.DATA_TAG, userService.selectUserById(userId)); - ajax.put("postIds" , postService.selectPostListByUserId(userId)); - ajax.put("roleIds" , roleService.selectRoleListByUserId(userId)); + ajax.put("postIds", postService.selectPostListByUserId(userId)); + ajax.put("roleIds", roleService.selectRoleListByUserId(userId)); } return ajax; } @@ -113,7 +113,7 @@ public class SysUserController extends BaseController { * 新增用户 */ @PreAuthorize("@ss.hasPermi('system:user:add')") - @Log(title = "用户管理" , businessType = BusinessType.INSERT) + @Log(title = "用户管理", businessType = BusinessType.INSERT) @PostMapping public AjaxResult add(@Validated @RequestBody SysUser user) { if (UserConstants.NOT_UNIQUE.equals(userService.checkUserNameUnique(user.getUserName()))) { @@ -132,7 +132,7 @@ public class SysUserController extends BaseController { * 修改用户 */ @PreAuthorize("@ss.hasPermi('system:user:edit')") - @Log(title = "用户管理" , businessType = BusinessType.UPDATE) + @Log(title = "用户管理", businessType = BusinessType.UPDATE) @PutMapping public AjaxResult edit(@Validated @RequestBody SysUser user) { userService.checkUserAllowed(user); @@ -149,7 +149,7 @@ public class SysUserController extends BaseController { * 删除用户 */ @PreAuthorize("@ss.hasPermi('system:user:remove')") - @Log(title = "用户管理" , businessType = BusinessType.DELETE) + @Log(title = "用户管理", businessType = BusinessType.DELETE) @DeleteMapping("/{userIds}") public AjaxResult remove(@PathVariable Long[] userIds) { return toAjax(userService.deleteUserByIds(userIds)); @@ -159,7 +159,7 @@ public class SysUserController extends BaseController { * 重置密码 */ @PreAuthorize("@ss.hasPermi('system:user:resetPwd')") - @Log(title = "用户管理" , businessType = BusinessType.UPDATE) + @Log(title = "用户管理", businessType = BusinessType.UPDATE) @PutMapping("/resetPwd") public AjaxResult resetPwd(@RequestBody SysUser user) { userService.checkUserAllowed(user); @@ -172,7 +172,7 @@ public class SysUserController extends BaseController { * 状态修改 */ @PreAuthorize("@ss.hasPermi('system:user:edit')") - @Log(title = "用户管理" , businessType = BusinessType.UPDATE) + @Log(title = "用户管理", businessType = BusinessType.UPDATE) @PutMapping("/changeStatus") public AjaxResult changeStatus(@RequestBody SysUser user) { userService.checkUserAllowed(user); diff --git a/hchyun/hchyun-admin/src/main/java/com/hchyun/web/controller/tool/TestController.java b/hchyun/hchyun-admin/src/main/java/com/hchyun/web/controller/tool/TestController.java index 8185712..dbef017 100644 --- a/hchyun/hchyun-admin/src/main/java/com/hchyun/web/controller/tool/TestController.java +++ b/hchyun/hchyun-admin/src/main/java/com/hchyun/web/controller/tool/TestController.java @@ -33,8 +33,8 @@ public class TestController extends BaseController { private final static Map users = new LinkedHashMap(); { - users.put(1, new UserEntity(1, "admin" , "admin123" , "15888888888")); - users.put(2, new UserEntity(2, "ry" , "admin123" , "15666666666")); + users.put(1, new UserEntity(1, "admin", "admin123", "15888888888")); + users.put(2, new UserEntity(2, "ry", "admin123", "15666666666")); } @ApiOperation("获取用户列表") @@ -45,7 +45,7 @@ public class TestController extends BaseController { } @ApiOperation("获取用户详细") - @ApiImplicitParam(name = "userId" , value = "用户ID" , required = true, dataType = "int" , paramType = "path") + @ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "int", paramType = "path") @GetMapping("/{userId}") public AjaxResult getUser(@PathVariable Integer userId) { if (!users.isEmpty() && users.containsKey(userId)) { @@ -56,7 +56,7 @@ public class TestController extends BaseController { } @ApiOperation("新增用户") - @ApiImplicitParam(name = "userEntity" , value = "新增用户信息" , dataType = "UserEntity") + @ApiImplicitParam(name = "userEntity", value = "新增用户信息", dataType = "UserEntity") @PostMapping("/save") public AjaxResult save(UserEntity user) { if (StringUtils.isNull(user) || StringUtils.isNull(user.getUserId())) { @@ -66,7 +66,7 @@ public class TestController extends BaseController { } @ApiOperation("更新用户") - @ApiImplicitParam(name = "userEntity" , value = "新增用户信息" , dataType = "UserEntity") + @ApiImplicitParam(name = "userEntity", value = "新增用户信息", dataType = "UserEntity") @PutMapping("/update") public AjaxResult update(UserEntity user) { if (StringUtils.isNull(user) || StringUtils.isNull(user.getUserId())) { @@ -80,7 +80,7 @@ public class TestController extends BaseController { } @ApiOperation("删除用户信息") - @ApiImplicitParam(name = "userId" , value = "用户ID" , required = true, dataType = "int" , paramType = "path") + @ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "int", paramType = "path") @DeleteMapping("/{userId}") public AjaxResult delete(@PathVariable Integer userId) { if (!users.isEmpty() && users.containsKey(userId)) { diff --git a/hchyun/hchyun-common/src/main/java/com/hchyun/common/annotation/DataScope.java b/hchyun/hchyun-common/src/main/java/com/hchyun/common/annotation/DataScope.java index b4915a2..d9c0869 100644 --- a/hchyun/hchyun-common/src/main/java/com/hchyun/common/annotation/DataScope.java +++ b/hchyun/hchyun-common/src/main/java/com/hchyun/common/annotation/DataScope.java @@ -8,14 +8,13 @@ import java.lang.annotation.Target; /** * 数据权限过滤注解 - * + * * @author hchyun */ @Target(ElementType.METHOD) @Retention(RetentionPolicy.RUNTIME) @Documented -public @interface DataScope -{ +public @interface DataScope { /** * 部门表的别名 */ diff --git a/hchyun/hchyun-common/src/main/java/com/hchyun/common/annotation/DataSource.java b/hchyun/hchyun-common/src/main/java/com/hchyun/common/annotation/DataSource.java index b54f3aa..f954375 100644 --- a/hchyun/hchyun-common/src/main/java/com/hchyun/common/annotation/DataSource.java +++ b/hchyun/hchyun-common/src/main/java/com/hchyun/common/annotation/DataSource.java @@ -6,21 +6,21 @@ import java.lang.annotation.Inherited; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; + import com.hchyun.common.enums.DataSourceType; /** * 自定义多数据源切换注解 - * + *

* 优先级:先方法,后类,如果方法覆盖了类上的数据源类型,以方法的为准,否则以类上的为准 * * @author hchyun */ -@Target({ ElementType.METHOD, ElementType.TYPE }) +@Target({ElementType.METHOD, ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) @Documented @Inherited -public @interface DataSource -{ +public @interface DataSource { /** * 切换数据源名称 */ diff --git a/hchyun/hchyun-common/src/main/java/com/hchyun/common/annotation/Excel.java b/hchyun/hchyun-common/src/main/java/com/hchyun/common/annotation/Excel.java index 18c055f..f95157e 100644 --- a/hchyun/hchyun-common/src/main/java/com/hchyun/common/annotation/Excel.java +++ b/hchyun/hchyun-common/src/main/java/com/hchyun/common/annotation/Excel.java @@ -8,18 +8,16 @@ import java.math.BigDecimal; /** * 自定义导出Excel数据注解 - * + * * @author hchyun */ @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.FIELD) -public @interface Excel -{ +public @interface Excel { /** * 导出时在excel中排序 */ // public int sort() default Integer.MAX_VALUE; - public int sort() default 1; /** @@ -113,34 +111,28 @@ public @interface Excel */ Type type() default Type.ALL; - public enum Type - { + public enum Type { ALL(0), EXPORT(1), IMPORT(2); private final int value; - Type(int value) - { + Type(int value) { this.value = value; } - public int value() - { + public int value() { return this.value; } } - public enum ColumnType - { + public enum ColumnType { NUMERIC(0), STRING(1); private final int value; - ColumnType(int value) - { + ColumnType(int value) { this.value = value; } - public int value() - { + public int value() { return this.value; } } diff --git a/hchyun/hchyun-common/src/main/java/com/hchyun/common/annotation/Excels.java b/hchyun/hchyun-common/src/main/java/com/hchyun/common/annotation/Excels.java index 5e3d330..71166c8 100644 --- a/hchyun/hchyun-common/src/main/java/com/hchyun/common/annotation/Excels.java +++ b/hchyun/hchyun-common/src/main/java/com/hchyun/common/annotation/Excels.java @@ -7,12 +7,11 @@ import java.lang.annotation.Target; /** * Excel注解集 - * + * * @author hchyun */ @Target(ElementType.FIELD) @Retention(RetentionPolicy.RUNTIME) -public @interface Excels -{ +public @interface Excels { Excel[] value(); } diff --git a/hchyun/hchyun-common/src/main/java/com/hchyun/common/annotation/Log.java b/hchyun/hchyun-common/src/main/java/com/hchyun/common/annotation/Log.java index d8bea72..6d173ae 100644 --- a/hchyun/hchyun-common/src/main/java/com/hchyun/common/annotation/Log.java +++ b/hchyun/hchyun-common/src/main/java/com/hchyun/common/annotation/Log.java @@ -5,22 +5,21 @@ import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; + import com.hchyun.common.enums.BusinessType; import com.hchyun.common.enums.OperatorType; /** * 自定义操作日志记录注解 - * - * @author hchyun * + * @author hchyun */ -@Target({ ElementType.PARAMETER, ElementType.METHOD }) +@Target({ElementType.PARAMETER, ElementType.METHOD}) @Retention(RetentionPolicy.RUNTIME) @Documented -public @interface Log -{ +public @interface Log { /** - * 模块 + * 模块 */ public String title() default ""; diff --git a/hchyun/hchyun-common/src/main/java/com/hchyun/common/annotation/RepeatSubmit.java b/hchyun/hchyun-common/src/main/java/com/hchyun/common/annotation/RepeatSubmit.java index 2401184..2d0cf99 100644 --- a/hchyun/hchyun-common/src/main/java/com/hchyun/common/annotation/RepeatSubmit.java +++ b/hchyun/hchyun-common/src/main/java/com/hchyun/common/annotation/RepeatSubmit.java @@ -9,15 +9,13 @@ import java.lang.annotation.Target; /** * 自定义注解防止表单重复提交 - * - * @author hchyun * + * @author hchyun */ @Inherited @Target(ElementType.METHOD) @Retention(RetentionPolicy.RUNTIME) @Documented -public @interface RepeatSubmit -{ +public @interface RepeatSubmit { } diff --git a/hchyun/hchyun-common/src/main/java/com/hchyun/common/config/HchYunConfig.java b/hchyun/hchyun-common/src/main/java/com/hchyun/common/config/HchYunConfig.java index ac13aa5..132c81c 100644 --- a/hchyun/hchyun-common/src/main/java/com/hchyun/common/config/HchYunConfig.java +++ b/hchyun/hchyun-common/src/main/java/com/hchyun/common/config/HchYunConfig.java @@ -91,7 +91,6 @@ public class HchYunConfig { } - /** * 获取头像上传路径 */ diff --git a/hchyun/hchyun-common/src/main/java/com/hchyun/common/constant/Constants.java b/hchyun/hchyun-common/src/main/java/com/hchyun/common/constant/Constants.java index 4c39157..43c1021 100644 --- a/hchyun/hchyun-common/src/main/java/com/hchyun/common/constant/Constants.java +++ b/hchyun/hchyun-common/src/main/java/com/hchyun/common/constant/Constants.java @@ -2,11 +2,10 @@ package com.hchyun.common.constant; /** * 通用常量信息 - * + * * @author hchyun */ -public class Constants -{ +public class Constants { /** * UTF-8 字符集 */ @@ -61,7 +60,7 @@ public class Constants * 登录用户 redis key */ public static final String LOGIN_TOKEN_KEY = "login_tokens:"; - + /** * 防重提交 redis key */ diff --git a/hchyun/hchyun-common/src/main/java/com/hchyun/common/constant/GenConstants.java b/hchyun/hchyun-common/src/main/java/com/hchyun/common/constant/GenConstants.java index ed3ff41..45f033e 100644 --- a/hchyun/hchyun-common/src/main/java/com/hchyun/common/constant/GenConstants.java +++ b/hchyun/hchyun-common/src/main/java/com/hchyun/common/constant/GenConstants.java @@ -2,121 +2,194 @@ package com.hchyun.common.constant; /** * 代码生成通用常量 - * + * * @author hchyun */ -public class GenConstants -{ - /** 单表(增删改查) */ +public class GenConstants { + /** + * 单表(增删改查) + */ public static final String TPL_CRUD = "crud"; - /** 树表(增删改查) */ + /** + * 树表(增删改查) + */ public static final String TPL_TREE = "tree"; - /** 主子表(增删改查) */ + /** + * 主子表(增删改查) + */ public static final String TPL_SUB = "sub"; - /** 关联查询(增删改查) */ + /** + * 关联查询(增删改查) + */ public static final String TPL_ASS = "ass"; - /** 树编码字段 */ + /** + * 树编码字段 + */ public static final String TREE_CODE = "treeCode"; - /** 树父编码字段 */ + /** + * 树父编码字段 + */ public static final String TREE_PARENT_CODE = "treeParentCode"; - /** 树名称字段 */ + /** + * 树名称字段 + */ public static final String TREE_NAME = "treeName"; - /** 上级菜单ID字段 */ + /** + * 上级菜单ID字段 + */ public static final String PARENT_MENU_ID = "parentMenuId"; - /** 上级菜单名称字段 */ + /** + * 上级菜单名称字段 + */ public static final String PARENT_MENU_NAME = "parentMenuName"; - /** 数据库字符串类型 */ - public static final String[] COLUMNTYPE_STR = { "char", "varchar", "nvarchar", "varchar2", "tinytext", "text", - "mediumtext", "longtext" }; + /** + * 数据库字符串类型 + */ + public static final String[] COLUMNTYPE_STR = {"char", "varchar", "nvarchar", "varchar2", "tinytext", "text", + "mediumtext", "longtext"}; - /** 数据库文本类型 */ - public static final String[] COLUMNTYPE_TEXT = { "tinytext", "text", "mediumtext", "longtext" }; + /** + * 数据库文本类型 + */ + public static final String[] COLUMNTYPE_TEXT = {"tinytext", "text", "mediumtext", "longtext"}; - /** 数据库时间类型 */ - public static final String[] COLUMNTYPE_TIME = { "datetime", "time", "date", "timestamp" }; + /** + * 数据库时间类型 + */ + public static final String[] COLUMNTYPE_TIME = {"datetime", "time", "date", "timestamp"}; - /** 数据库数字类型 */ - public static final String[] COLUMNTYPE_NUMBER = { "tinyint", "smallint", "mediumint", "int", "number", "integer", - "bit", "bigint", "float", "float", "double", "decimal" }; + /** + * 数据库数字类型 + */ + public static final String[] COLUMNTYPE_NUMBER = {"tinyint", "smallint", "mediumint", "int", "number", "integer", + "bit", "bigint", "float", "float", "double", "decimal"}; - /** 页面不需要编辑字段 */ - public static final String[] COLUMNNAME_NOT_EDIT = { "id", "create_by", "create_time", "del_flag" }; + /** + * 页面不需要编辑字段 + */ + public static final String[] COLUMNNAME_NOT_EDIT = {"id", "create_by", "create_time", "del_flag"}; - /** 页面不需要显示的列表字段 */ - public static final String[] COLUMNNAME_NOT_LIST = { "id", "create_by", "create_time", "del_flag", "update_by", - "update_time" }; + /** + * 页面不需要显示的列表字段 + */ + public static final String[] COLUMNNAME_NOT_LIST = {"id", "create_by", "create_time", "del_flag", "update_by", + "update_time"}; - /** 页面不需要查询字段 */ - public static final String[] COLUMNNAME_NOT_QUERY = { "id", "create_by", "create_time", "del_flag", "update_by", - "update_time", "remark" }; + /** + * 页面不需要查询字段 + */ + public static final String[] COLUMNNAME_NOT_QUERY = {"id", "create_by", "create_time", "del_flag", "update_by", + "update_time", "remark"}; - /** Entity基类字段 */ - public static final String[] BASE_ENTITY = { "createBy", "createTime", "updateBy", "updateTime", "remark" }; + /** + * Entity基类字段 + */ + public static final String[] BASE_ENTITY = {"createBy", "createTime", "updateBy", "updateTime", "remark"}; - /** Tree基类字段 */ - public static final String[] TREE_ENTITY = { "parentName", "parentId", "orderNum", "ancestors", "children" }; + /** + * Tree基类字段 + */ + public static final String[] TREE_ENTITY = {"parentName", "parentId", "orderNum", "ancestors", "children"}; - /** 文本框 */ + /** + * 文本框 + */ public static final String HTML_INPUT = "input"; - /** 文本域 */ + /** + * 文本域 + */ public static final String HTML_TEXTAREA = "textarea"; - /** 下拉框 */ + /** + * 下拉框 + */ public static final String HTML_SELECT = "select"; - /** 单选框 */ + /** + * 单选框 + */ public static final String HTML_RADIO = "radio"; - /** 复选框 */ + /** + * 复选框 + */ public static final String HTML_CHECKBOX = "checkbox"; - /** 日期控件 */ + /** + * 日期控件 + */ public static final String HTML_DATETIME = "datetime"; - /** 图片上传控件 */ + /** + * 图片上传控件 + */ public static final String HTML_IMAGE_UPLOAD = "imageUpload"; - /** 文件上传控件 */ + /** + * 文件上传控件 + */ public static final String HTML_FILE_UPLOAD = "fileUpload"; - /** 富文本控件 */ + /** + * 富文本控件 + */ public static final String HTML_EDITOR = "editor"; - /** 字符串类型 */ + /** + * 字符串类型 + */ public static final String TYPE_STRING = "String"; - /** 整型 */ + /** + * 整型 + */ public static final String TYPE_INTEGER = "Integer"; - /** 长整型 */ + /** + * 长整型 + */ public static final String TYPE_LONG = "Long"; - /** 浮点型 */ + /** + * 浮点型 + */ public static final String TYPE_DOUBLE = "Double"; - /** 高精度计算类型 */ + /** + * 高精度计算类型 + */ public static final String TYPE_BIGDECIMAL = "BigDecimal"; - /** 时间类型 */ + /** + * 时间类型 + */ public static final String TYPE_DATE = "Date"; - /** 模糊查询 */ + /** + * 模糊查询 + */ public static final String QUERY_LIKE = "LIKE"; - /** 精确查询 */ + /** + * 精确查询 + */ public static final String QUERY_EQ = "EQ"; - /** 需要 */ + /** + * 需要 + */ public static final String REQUIRE = "1"; - /** 不需要 */ + /** + * 不需要 + */ public static final String NO_REQUIRE = "0"; } diff --git a/hchyun/hchyun-common/src/main/java/com/hchyun/common/constant/HttpStatus.java b/hchyun/hchyun-common/src/main/java/com/hchyun/common/constant/HttpStatus.java index 3416f26..16ca8d5 100644 --- a/hchyun/hchyun-common/src/main/java/com/hchyun/common/constant/HttpStatus.java +++ b/hchyun/hchyun-common/src/main/java/com/hchyun/common/constant/HttpStatus.java @@ -2,11 +2,10 @@ package com.hchyun.common.constant; /** * 返回状态码 - * + * * @author hchyun */ -public class HttpStatus -{ +public class HttpStatus { /** * 操作成功 */ diff --git a/hchyun/hchyun-common/src/main/java/com/hchyun/common/constant/ScheduleConstants.java b/hchyun/hchyun-common/src/main/java/com/hchyun/common/constant/ScheduleConstants.java index 2930cf4..ec71a15 100644 --- a/hchyun/hchyun-common/src/main/java/com/hchyun/common/constant/ScheduleConstants.java +++ b/hchyun/hchyun-common/src/main/java/com/hchyun/common/constant/ScheduleConstants.java @@ -2,30 +2,38 @@ package com.hchyun.common.constant; /** * 任务调度通用常量 - * + * * @author hchyun */ -public class ScheduleConstants -{ +public class ScheduleConstants { public static final String TASK_CLASS_NAME = "TASK_CLASS_NAME"; - /** 执行目标key */ + /** + * 执行目标key + */ public static final String TASK_PROPERTIES = "TASK_PROPERTIES"; - /** 默认 */ + /** + * 默认 + */ public static final String MISFIRE_DEFAULT = "0"; - /** 立即触发执行 */ + /** + * 立即触发执行 + */ public static final String MISFIRE_IGNORE_MISFIRES = "1"; - /** 触发一次执行 */ + /** + * 触发一次执行 + */ public static final String MISFIRE_FIRE_AND_PROCEED = "2"; - /** 不触发立即执行 */ + /** + * 不触发立即执行 + */ public static final String MISFIRE_DO_NOTHING = "3"; - public enum Status - { + public enum Status { /** * 正常 */ @@ -37,13 +45,11 @@ public class ScheduleConstants private String value; - private Status(String value) - { + private Status(String value) { this.value = value; } - public String getValue() - { + public String getValue() { return value; } } diff --git a/hchyun/hchyun-common/src/main/java/com/hchyun/common/constant/UserConstants.java b/hchyun/hchyun-common/src/main/java/com/hchyun/common/constant/UserConstants.java index 8d110ee..8a88288 100644 --- a/hchyun/hchyun-common/src/main/java/com/hchyun/common/constant/UserConstants.java +++ b/hchyun/hchyun-common/src/main/java/com/hchyun/common/constant/UserConstants.java @@ -2,59 +2,88 @@ package com.hchyun.common.constant; /** * 用户常量信息 - * + * * @author hchyun */ -public class UserConstants -{ +public class UserConstants { /** * 平台内系统用户的唯一标志 */ public static final String SYS_USER = "SYS_USER"; - /** 正常状态 */ + /** + * 正常状态 + */ public static final String NORMAL = "0"; - /** 异常状态 */ + /** + * 异常状态 + */ public static final String EXCEPTION = "1"; - /** 用户封禁状态 */ + /** + * 用户封禁状态 + */ public static final String USER_DISABLE = "1"; - /** 角色封禁状态 */ + /** + * 角色封禁状态 + */ public static final String ROLE_DISABLE = "1"; - /** 部门正常状态 */ + /** + * 部门正常状态 + */ public static final String DEPT_NORMAL = "0"; - /** 部门停用状态 */ + /** + * 部门停用状态 + */ public static final String DEPT_DISABLE = "1"; - /** 字典正常状态 */ + /** + * 字典正常状态 + */ public static final String DICT_NORMAL = "0"; - /** 是否为系统默认(是) */ + /** + * 是否为系统默认(是) + */ public static final String YES = "Y"; - /** 是否菜单外链(是) */ + /** + * 是否菜单外链(是) + */ public static final String YES_FRAME = "0"; - /** 是否菜单外链(否) */ + /** + * 是否菜单外链(否) + */ public static final String NO_FRAME = "1"; - /** 菜单类型(目录) */ + /** + * 菜单类型(目录) + */ public static final String TYPE_DIR = "M"; - /** 菜单类型(菜单) */ + /** + * 菜单类型(菜单) + */ public static final String TYPE_MENU = "C"; - /** 菜单类型(按钮) */ + /** + * 菜单类型(按钮) + */ public static final String TYPE_BUTTON = "F"; - /** Layout组件标识 */ + /** + * Layout组件标识 + */ public final static String LAYOUT = "Layout"; - /** 校验返回结果码 */ + /** + * 校验返回结果码 + */ public final static String UNIQUE = "0"; public final static String NOT_UNIQUE = "1"; } diff --git a/hchyun/hchyun-common/src/main/java/com/hchyun/common/core/controller/HcyBaseController.java b/hchyun/hchyun-common/src/main/java/com/hchyun/common/core/controller/HcyBaseController.java index 013084a..a1dbc28 100644 --- a/hchyun/hchyun-common/src/main/java/com/hchyun/common/core/controller/HcyBaseController.java +++ b/hchyun/hchyun-common/src/main/java/com/hchyun/common/core/controller/HcyBaseController.java @@ -52,7 +52,7 @@ public class HcyBaseController { /** * 设置请求分页数据 */ - public void startPage(Map map) { + public void startPage(Map map) { PageDomain pageDomain = TableSupport.buildPageRequest(); Integer pageNum = (Integer) map.get("pageNum"); Integer pageSize = (Integer) map.get("pageSize"); @@ -76,7 +76,6 @@ public class HcyBaseController { } - // /** // * 响应返回结果 // * diff --git a/hchyun/hchyun-common/src/main/java/com/hchyun/common/core/entity/BaseEntity.java b/hchyun/hchyun-common/src/main/java/com/hchyun/common/core/entity/BaseEntity.java index 6eef589..312ec43 100644 --- a/hchyun/hchyun-common/src/main/java/com/hchyun/common/core/entity/BaseEntity.java +++ b/hchyun/hchyun-common/src/main/java/com/hchyun/common/core/entity/BaseEntity.java @@ -31,7 +31,7 @@ public class BaseEntity implements Serializable { /** * 创建时间 */ - @Excel(name = "创建时间",dateFormat = "yyyy-MM-dd HH:mm:ss",sort = Integer.MAX_VALUE-1) + @Excel(name = "创建时间", dateFormat = "yyyy-MM-dd HH:mm:ss", sort = Integer.MAX_VALUE - 1) @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") private Date createTime; @@ -43,7 +43,7 @@ public class BaseEntity implements Serializable { /** * 更新时间 */ - @Excel(name = "更新时间",dateFormat = "yyyy-MM-dd HH:mm:ss",sort = Integer.MAX_VALUE) + @Excel(name = "更新时间", dateFormat = "yyyy-MM-dd HH:mm:ss", sort = Integer.MAX_VALUE) @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") private Date updateTime; diff --git a/hchyun/hchyun-common/src/main/java/com/hchyun/common/core/entity/TreeEntity.java b/hchyun/hchyun-common/src/main/java/com/hchyun/common/core/entity/TreeEntity.java index 21874b0..e215a1c 100644 --- a/hchyun/hchyun-common/src/main/java/com/hchyun/common/core/entity/TreeEntity.java +++ b/hchyun/hchyun-common/src/main/java/com/hchyun/common/core/entity/TreeEntity.java @@ -5,75 +5,74 @@ import java.util.List; /** * Tree基类 - * + * * @author hchyun */ -public class TreeEntity extends BaseEntity -{ +public class TreeEntity extends BaseEntity { - /** 父菜单名称 */ + /** + * 父菜单名称 + */ private String parentName; - /** 父菜单ID */ + /** + * 父菜单ID + */ private Long parentId; - /** 显示顺序 */ + /** + * 显示顺序 + */ private Integer orderNum; - /** 祖级列表 */ + /** + * 祖级列表 + */ private String ancestors; - /** 子部门 */ + /** + * 子部门 + */ private List children = new ArrayList<>(); - public String getParentName() - { + public String getParentName() { return parentName; } - public void setParentName(String parentName) - { + public void setParentName(String parentName) { this.parentName = parentName; } - public Long getParentId() - { + public Long getParentId() { return parentId; } - public void setParentId(Long parentId) - { + public void setParentId(Long parentId) { this.parentId = parentId; } - public Integer getOrderNum() - { + public Integer getOrderNum() { return orderNum; } - public void setOrderNum(Integer orderNum) - { + public void setOrderNum(Integer orderNum) { this.orderNum = orderNum; } - public String getAncestors() - { + public String getAncestors() { return ancestors; } - public void setAncestors(String ancestors) - { + public void setAncestors(String ancestors) { this.ancestors = ancestors; } - public List getChildren() - { + public List getChildren() { return children; } - public void setChildren(List children) - { + public void setChildren(List children) { this.children = children; } } diff --git a/hchyun/hchyun-common/src/main/java/com/hchyun/common/core/entity/TreeSelect.java b/hchyun/hchyun-common/src/main/java/com/hchyun/common/core/entity/TreeSelect.java index 89acdc5..6a98fc7 100644 --- a/hchyun/hchyun-common/src/main/java/com/hchyun/common/core/entity/TreeSelect.java +++ b/hchyun/hchyun-common/src/main/java/com/hchyun/common/core/entity/TreeSelect.java @@ -3,75 +3,72 @@ package com.hchyun.common.core.entity; import java.io.Serializable; import java.util.List; import java.util.stream.Collectors; + import com.fasterxml.jackson.annotation.JsonInclude; import com.hchyun.common.core.entity.entity.SysDept; import com.hchyun.common.core.entity.entity.SysMenu; /** * Treeselect树结构实体类 - * + * * @author hchyun */ -public class TreeSelect implements Serializable -{ +public class TreeSelect implements Serializable { - /** 节点ID */ + /** + * 节点ID + */ private Long id; - /** 节点名称 */ + /** + * 节点名称 + */ private String label; - /** 子节点 */ + /** + * 子节点 + */ @JsonInclude(JsonInclude.Include.NON_EMPTY) private List children; - public TreeSelect() - { + public TreeSelect() { } - public TreeSelect(SysDept dept) - { + public TreeSelect(SysDept dept) { this.id = dept.getDeptId(); this.label = dept.getDeptName(); this.children = dept.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList()); } - public TreeSelect(SysMenu menu) - { + public TreeSelect(SysMenu menu) { this.id = menu.getMenuId(); this.label = menu.getMenuName(); this.children = menu.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList()); } - public Long getId() - { + public Long getId() { return id; } - public void setId(Long id) - { + public void setId(Long id) { this.id = id; } - public String getLabel() - { + public String getLabel() { return label; } - public void setLabel(String label) - { + public void setLabel(String label) { this.label = label; } - public List getChildren() - { + public List getChildren() { return children; } - public void setChildren(List children) - { + public void setChildren(List children) { this.children = children; } } diff --git a/hchyun/hchyun-common/src/main/java/com/hchyun/common/core/entity/entity/SysDept.java b/hchyun/hchyun-common/src/main/java/com/hchyun/common/core/entity/entity/SysDept.java index 17d6f47..ee7027d 100644 --- a/hchyun/hchyun-common/src/main/java/com/hchyun/common/core/entity/entity/SysDept.java +++ b/hchyun/hchyun-common/src/main/java/com/hchyun/common/core/entity/entity/SysDept.java @@ -5,198 +5,198 @@ import java.util.List; import javax.validation.constraints.Email; import javax.validation.constraints.NotBlank; import javax.validation.constraints.Size; + import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; import com.hchyun.common.core.entity.BaseEntity; /** * 部门表 sys_dept - * + * * @author hchyun */ -public class SysDept extends BaseEntity -{ +public class SysDept extends BaseEntity { - /** 部门ID */ + /** + * 部门ID + */ private Long deptId; - /** 父部门ID */ + /** + * 父部门ID + */ private Long parentId; - /** 祖级列表 */ + /** + * 祖级列表 + */ private String ancestors; - /** 部门名称 */ + /** + * 部门名称 + */ private String deptName; - /** 显示顺序 */ + /** + * 显示顺序 + */ private String orderNum; - /** 负责人 */ + /** + * 负责人 + */ private String leader; - /** 联系电话 */ + /** + * 联系电话 + */ private String phone; - /** 邮箱 */ + /** + * 邮箱 + */ private String email; - /** 部门状态:0正常,1停用 */ + /** + * 部门状态:0正常,1停用 + */ private String status; - /** 删除标志(0代表存在 2代表删除) */ + /** + * 删除标志(0代表存在 2代表删除) + */ private String delFlag; - /** 父部门名称 */ + /** + * 父部门名称 + */ private String parentName; - - /** 子部门 */ + + /** + * 子部门 + */ private List children = new ArrayList(); - public Long getDeptId() - { + public Long getDeptId() { return deptId; } - public void setDeptId(Long deptId) - { + public void setDeptId(Long deptId) { this.deptId = deptId; } - public Long getParentId() - { + public Long getParentId() { return parentId; } - public void setParentId(Long parentId) - { + public void setParentId(Long parentId) { this.parentId = parentId; } - public String getAncestors() - { + public String getAncestors() { return ancestors; } - public void setAncestors(String ancestors) - { + public void setAncestors(String ancestors) { this.ancestors = ancestors; } @NotBlank(message = "部门名称不能为空") @Size(min = 0, max = 30, message = "部门名称长度不能超过30个字符") - public String getDeptName() - { + public String getDeptName() { return deptName; } - public void setDeptName(String deptName) - { + public void setDeptName(String deptName) { this.deptName = deptName; } @NotBlank(message = "显示顺序不能为空") - public String getOrderNum() - { + public String getOrderNum() { return orderNum; } - public void setOrderNum(String orderNum) - { + public void setOrderNum(String orderNum) { this.orderNum = orderNum; } - public String getLeader() - { + public String getLeader() { return leader; } - public void setLeader(String leader) - { + public void setLeader(String leader) { this.leader = leader; } @Size(min = 0, max = 11, message = "联系电话长度不能超过11个字符") - public String getPhone() - { + public String getPhone() { return phone; } - public void setPhone(String phone) - { + public void setPhone(String phone) { this.phone = phone; } @Email(message = "邮箱格式不正确") @Size(min = 0, max = 50, message = "邮箱长度不能超过50个字符") - public String getEmail() - { + public String getEmail() { return email; } - public void setEmail(String email) - { + public void setEmail(String email) { this.email = email; } - public String getStatus() - { + public String getStatus() { return status; } - public void setStatus(String status) - { + public void setStatus(String status) { this.status = status; } - public String getDelFlag() - { + public String getDelFlag() { return delFlag; } - public void setDelFlag(String delFlag) - { + public void setDelFlag(String delFlag) { this.delFlag = delFlag; } - public String getParentName() - { + public String getParentName() { return parentName; } - public void setParentName(String parentName) - { + public void setParentName(String parentName) { this.parentName = parentName; } - public List getChildren() - { + public List getChildren() { return children; } - public void setChildren(List children) - { + public void setChildren(List children) { this.children = children; } @Override public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("deptId", getDeptId()) - .append("parentId", getParentId()) - .append("ancestors", getAncestors()) - .append("deptName", getDeptName()) - .append("orderNum", getOrderNum()) - .append("leader", getLeader()) - .append("phone", getPhone()) - .append("email", getEmail()) - .append("status", getStatus()) - .append("delFlag", getDelFlag()) - .append("createBy", getCreateBy()) - .append("createTime", getCreateTime()) - .append("updateBy", getUpdateBy()) - .append("updateTime", getUpdateTime()) - .toString(); + return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) + .append("deptId", getDeptId()) + .append("parentId", getParentId()) + .append("ancestors", getAncestors()) + .append("deptName", getDeptName()) + .append("orderNum", getOrderNum()) + .append("leader", getLeader()) + .append("phone", getPhone()) + .append("email", getEmail()) + .append("status", getStatus()) + .append("delFlag", getDelFlag()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .toString(); } } diff --git a/hchyun/hchyun-common/src/main/java/com/hchyun/common/core/entity/entity/SysDictData.java b/hchyun/hchyun-common/src/main/java/com/hchyun/common/core/entity/entity/SysDictData.java index 99f5dce..f63d3eb 100644 --- a/hchyun/hchyun-common/src/main/java/com/hchyun/common/core/entity/entity/SysDictData.java +++ b/hchyun/hchyun-common/src/main/java/com/hchyun/common/core/entity/entity/SysDictData.java @@ -2,6 +2,7 @@ package com.hchyun.common.core.entity.entity; import javax.validation.constraints.NotBlank; import javax.validation.constraints.Size; + import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; import com.hchyun.common.annotation.Excel; @@ -11,166 +12,164 @@ import com.hchyun.common.core.entity.BaseEntity; /** * 字典数据表 sys_dict_data - * + * * @author hchyun */ -public class SysDictData extends BaseEntity -{ +public class SysDictData extends BaseEntity { - /** 字典编码 */ + /** + * 字典编码 + */ @Excel(name = "字典编码", cellType = ColumnType.NUMERIC) private Long dictCode; - /** 字典排序 */ + /** + * 字典排序 + */ @Excel(name = "字典排序", cellType = ColumnType.NUMERIC) private Long dictSort; - /** 字典标签 */ + /** + * 字典标签 + */ @Excel(name = "字典标签") private String dictLabel; - /** 字典键值 */ + /** + * 字典键值 + */ @Excel(name = "字典键值") private String dictValue; - /** 字典类型 */ + /** + * 字典类型 + */ @Excel(name = "字典类型") private String dictType; - /** 样式属性(其他样式扩展) */ + /** + * 样式属性(其他样式扩展) + */ private String cssClass; - /** 表格字典样式 */ + /** + * 表格字典样式 + */ private String listClass; - /** 是否默认(Y是 N否) */ + /** + * 是否默认(Y是 N否) + */ @Excel(name = "是否默认", readConverterExp = "Y=是,N=否") private String isDefault; - /** 状态(0正常 1停用) */ + /** + * 状态(0正常 1停用) + */ @Excel(name = "状态", readConverterExp = "0=正常,1=停用") private String status; - public Long getDictCode() - { + public Long getDictCode() { return dictCode; } - public void setDictCode(Long dictCode) - { + public void setDictCode(Long dictCode) { this.dictCode = dictCode; } - public Long getDictSort() - { + public Long getDictSort() { return dictSort; } - public void setDictSort(Long dictSort) - { + public void setDictSort(Long dictSort) { this.dictSort = dictSort; } @NotBlank(message = "字典标签不能为空") @Size(min = 0, max = 100, message = "字典标签长度不能超过100个字符") - public String getDictLabel() - { + public String getDictLabel() { return dictLabel; } - public void setDictLabel(String dictLabel) - { + public void setDictLabel(String dictLabel) { this.dictLabel = dictLabel; } @NotBlank(message = "字典键值不能为空") @Size(min = 0, max = 100, message = "字典键值长度不能超过100个字符") - public String getDictValue() - { + public String getDictValue() { return dictValue; } - public void setDictValue(String dictValue) - { + public void setDictValue(String dictValue) { this.dictValue = dictValue; } @NotBlank(message = "字典类型不能为空") @Size(min = 0, max = 100, message = "字典类型长度不能超过100个字符") - public String getDictType() - { + public String getDictType() { return dictType; } - public void setDictType(String dictType) - { + public void setDictType(String dictType) { this.dictType = dictType; } @Size(min = 0, max = 100, message = "样式属性长度不能超过100个字符") - public String getCssClass() - { + public String getCssClass() { return cssClass; } - public void setCssClass(String cssClass) - { + public void setCssClass(String cssClass) { this.cssClass = cssClass; } - public String getListClass() - { + public String getListClass() { return listClass; } - public void setListClass(String listClass) - { + public void setListClass(String listClass) { this.listClass = listClass; } - public boolean getDefault() - { + public boolean getDefault() { return UserConstants.YES.equals(this.isDefault) ? true : false; } - public String getIsDefault() - { + public String getIsDefault() { return isDefault; } - public void setIsDefault(String isDefault) - { + public void setIsDefault(String isDefault) { this.isDefault = isDefault; } - public String getStatus() - { + public String getStatus() { return status; } - public void setStatus(String status) - { + public void setStatus(String status) { this.status = status; } - + @Override public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("dictCode", getDictCode()) - .append("dictSort", getDictSort()) - .append("dictLabel", getDictLabel()) - .append("dictValue", getDictValue()) - .append("dictType", getDictType()) - .append("cssClass", getCssClass()) - .append("listClass", getListClass()) - .append("isDefault", getIsDefault()) - .append("status", getStatus()) - .append("createBy", getCreateBy()) - .append("createTime", getCreateTime()) - .append("updateBy", getUpdateBy()) - .append("updateTime", getUpdateTime()) - .append("remark", getRemark()) - .toString(); + return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) + .append("dictCode", getDictCode()) + .append("dictSort", getDictSort()) + .append("dictLabel", getDictLabel()) + .append("dictValue", getDictValue()) + .append("dictType", getDictType()) + .append("cssClass", getCssClass()) + .append("listClass", getListClass()) + .append("isDefault", getIsDefault()) + .append("status", getStatus()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("remark", getRemark()) + .toString(); } } diff --git a/hchyun/hchyun-common/src/main/java/com/hchyun/common/core/entity/entity/SysDictType.java b/hchyun/hchyun-common/src/main/java/com/hchyun/common/core/entity/entity/SysDictType.java index 4c81342..e8f16a7 100644 --- a/hchyun/hchyun-common/src/main/java/com/hchyun/common/core/entity/entity/SysDictType.java +++ b/hchyun/hchyun-common/src/main/java/com/hchyun/common/core/entity/entity/SysDictType.java @@ -2,6 +2,7 @@ package com.hchyun.common.core.entity.entity; import javax.validation.constraints.NotBlank; import javax.validation.constraints.Size; + import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; import com.hchyun.common.annotation.Excel; @@ -10,85 +11,84 @@ import com.hchyun.common.core.entity.BaseEntity; /** * 字典类型表 sys_dict_type - * + * * @author hchyun */ -public class SysDictType extends BaseEntity -{ +public class SysDictType extends BaseEntity { - /** 字典主键 */ + /** + * 字典主键 + */ @Excel(name = "字典主键", cellType = ColumnType.NUMERIC) private Long dictId; - /** 字典名称 */ + /** + * 字典名称 + */ @Excel(name = "字典名称") private String dictName; - /** 字典类型 */ + /** + * 字典类型 + */ @Excel(name = "字典类型") private String dictType; - /** 状态(0正常 1停用) */ + /** + * 状态(0正常 1停用) + */ @Excel(name = "状态", readConverterExp = "0=正常,1=停用") private String status; - public Long getDictId() - { + public Long getDictId() { return dictId; } - public void setDictId(Long dictId) - { + public void setDictId(Long dictId) { this.dictId = dictId; } @NotBlank(message = "字典名称不能为空") @Size(min = 0, max = 100, message = "字典类型名称长度不能超过100个字符") - public String getDictName() - { + public String getDictName() { return dictName; } - public void setDictName(String dictName) - { + public void setDictName(String dictName) { this.dictName = dictName; } @NotBlank(message = "字典类型不能为空") @Size(min = 0, max = 100, message = "字典类型类型长度不能超过100个字符") - public String getDictType() - { + public String getDictType() { return dictType; } - public void setDictType(String dictType) - { + public void setDictType(String dictType) { this.dictType = dictType; } - public String getStatus() - { + public String getStatus() { return status; } - public void setStatus(String status) - { + public void setStatus(String status) { this.status = status; } - + @Override public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("dictId", getDictId()) - .append("dictName", getDictName()) - .append("dictType", getDictType()) - .append("status", getStatus()) - .append("createBy", getCreateBy()) - .append("createTime", getCreateTime()) - .append("updateBy", getUpdateBy()) - .append("updateTime", getUpdateTime()) - .append("remark", getRemark()) - .toString(); + return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) + .append("dictId", getDictId()) + .append("dictName", getDictName()) + .append("dictType", getDictType()) + .append("status", getStatus()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("remark", getRemark()) + .toString(); } } diff --git a/hchyun/hchyun-common/src/main/java/com/hchyun/common/core/entity/entity/SysMenu.java b/hchyun/hchyun-common/src/main/java/com/hchyun/common/core/entity/entity/SysMenu.java index a7988ef..6889425 100644 --- a/hchyun/hchyun-common/src/main/java/com/hchyun/common/core/entity/entity/SysMenu.java +++ b/hchyun/hchyun-common/src/main/java/com/hchyun/common/core/entity/entity/SysMenu.java @@ -96,13 +96,13 @@ public class SysMenu extends BaseEntity { public SysMenu() { } - public SysMenu(Long uqId,String uqName,Long create) { + public SysMenu(Long uqId, String uqName, Long create) { parentId = 6L; menuName = uqName; orderNum = "0"; - path = "data/"+uqId; + path = "data/" + uqId; component = "tool/query/queryDate"; - isFrame="1"; + isFrame = "1"; isCache = "0"; menuType = "C"; visible = "0"; diff --git a/hchyun/hchyun-common/src/main/java/com/hchyun/common/core/entity/entity/SysRole.java b/hchyun/hchyun-common/src/main/java/com/hchyun/common/core/entity/entity/SysRole.java index c93e69b..3fb5d47 100644 --- a/hchyun/hchyun-common/src/main/java/com/hchyun/common/core/entity/entity/SysRole.java +++ b/hchyun/hchyun-common/src/main/java/com/hchyun/common/core/entity/entity/SysRole.java @@ -20,7 +20,7 @@ public class SysRole extends BaseEntity { /** * 角色ID */ - @Excel(name = "角色序号" , cellType = ColumnType.NUMERIC) + @Excel(name = "角色序号", cellType = ColumnType.NUMERIC) private Long roleId; /** @@ -44,7 +44,7 @@ public class SysRole extends BaseEntity { /** * 数据范围(1:所有数据权限;2:自定义数据权限;3:本部门数据权限;4:本部门及以下数据权限) */ - @Excel(name = "数据范围" , readConverterExp = "1=所有数据权限,2=自定义数据权限,3=本部门数据权限,4=本部门及以下数据权限") + @Excel(name = "数据范围", readConverterExp = "1=所有数据权限,2=自定义数据权限,3=本部门数据权限,4=本部门及以下数据权限") private String dataScope; /** @@ -60,7 +60,7 @@ public class SysRole extends BaseEntity { /** * 角色状态(0正常 1停用) */ - @Excel(name = "角色状态" , readConverterExp = "0=正常,1=停用") + @Excel(name = "角色状态", readConverterExp = "0=正常,1=停用") private String status; /** @@ -216,20 +216,20 @@ public class SysRole extends BaseEntity { @Override public String toString() { return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) - .append("roleId" , getRoleId()) - .append("roleName" , getRoleName()) - .append("roleKey" , getRoleKey()) - .append("roleSort" , getRoleSort()) - .append("dataScope" , getDataScope()) - .append("menuCheckStrictly" , isMenuCheckStrictly()) - .append("deptCheckStrictly" , isDeptCheckStrictly()) - .append("status" , getStatus()) - .append("delFlag" , getDelFlag()) - .append("createBy" , getCreateBy()) - .append("createTime" , getCreateTime()) - .append("updateBy" , getUpdateBy()) - .append("updateTime" , getUpdateTime()) - .append("remark" , getRemark()) + .append("roleId", getRoleId()) + .append("roleName", getRoleName()) + .append("roleKey", getRoleKey()) + .append("roleSort", getRoleSort()) + .append("dataScope", getDataScope()) + .append("menuCheckStrictly", isMenuCheckStrictly()) + .append("deptCheckStrictly", isDeptCheckStrictly()) + .append("status", getStatus()) + .append("delFlag", getDelFlag()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("remark", getRemark()) .toString(); } } diff --git a/hchyun/hchyun-common/src/main/java/com/hchyun/common/core/entity/entity/SysUser.java b/hchyun/hchyun-common/src/main/java/com/hchyun/common/core/entity/entity/SysUser.java index 80b314c..5ac0c8a 100644 --- a/hchyun/hchyun-common/src/main/java/com/hchyun/common/core/entity/entity/SysUser.java +++ b/hchyun/hchyun-common/src/main/java/com/hchyun/common/core/entity/entity/SysUser.java @@ -5,6 +5,7 @@ import java.util.List; import javax.validation.constraints.Email; import javax.validation.constraints.NotBlank; import javax.validation.constraints.Size; + import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; import com.fasterxml.jackson.annotation.JsonIgnore; @@ -17,312 +18,307 @@ import com.hchyun.common.core.entity.BaseEntity; /** * 用户对象 sys_user - * + * * @author hchyun */ -public class SysUser extends BaseEntity -{ +public class SysUser extends BaseEntity { - /** 用户ID */ + /** + * 用户ID + */ @Excel(name = "用户序号", cellType = ColumnType.NUMERIC, prompt = "用户编号") private Long userId; - /** 部门ID */ + /** + * 部门ID + */ @Excel(name = "部门编号", type = Type.IMPORT) private Long deptId; - /** 用户账号 */ + /** + * 用户账号 + */ @Excel(name = "登录名称") private String userName; - /** 用户昵称 */ + /** + * 用户昵称 + */ @Excel(name = "用户名称") private String nickName; - /** 用户邮箱 */ + /** + * 用户邮箱 + */ @Excel(name = "用户邮箱") private String email; - /** 手机号码 */ + /** + * 手机号码 + */ @Excel(name = "手机号码") private String phonenumber; - /** 用户性别 */ + /** + * 用户性别 + */ @Excel(name = "用户性别", readConverterExp = "0=男,1=女,2=未知") private String sex; - /** 用户头像 */ + /** + * 用户头像 + */ private String avatar; - /** 密码 */ + /** + * 密码 + */ private String password; - /** 盐加密 */ + /** + * 盐加密 + */ private String salt; - /** 帐号状态(0正常 1停用) */ + /** + * 帐号状态(0正常 1停用) + */ @Excel(name = "帐号状态", readConverterExp = "0=正常,1=停用") private String status; - /** 删除标志(0代表存在 2代表删除) */ + /** + * 删除标志(0代表存在 2代表删除) + */ private String delFlag; - /** 最后登录IP */ + /** + * 最后登录IP + */ @Excel(name = "最后登录IP", type = Type.EXPORT) private String loginIp; - /** 最后登录时间 */ + /** + * 最后登录时间 + */ @Excel(name = "最后登录时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", type = Type.EXPORT) private Date loginDate; - /** 部门对象 */ + /** + * 部门对象 + */ @Excels({ - @Excel(name = "部门名称", targetAttr = "deptName", type = Type.EXPORT), - @Excel(name = "部门负责人", targetAttr = "leader", type = Type.EXPORT) + @Excel(name = "部门名称", targetAttr = "deptName", type = Type.EXPORT), + @Excel(name = "部门负责人", targetAttr = "leader", type = Type.EXPORT) }) private SysDept dept; - /** 角色对象 */ + /** + * 角色对象 + */ private List roles; - /** 角色组 */ + /** + * 角色组 + */ private Long[] roleIds; - /** 岗位组 */ + /** + * 岗位组 + */ private Long[] postIds; - public SysUser() - { + public SysUser() { } - public SysUser(Long userId) - { + public SysUser(Long userId) { this.userId = userId; } - public Long getUserId() - { + public Long getUserId() { return userId; } - public void setUserId(Long userId) - { + public void setUserId(Long userId) { this.userId = userId; } - public boolean isAdmin() - { + public boolean isAdmin() { return isAdmin(this.userId); } - public static boolean isAdmin(Long userId) - { + public static boolean isAdmin(Long userId) { return userId != null && 1L == userId; } - public Long getDeptId() - { + public Long getDeptId() { return deptId; } - public void setDeptId(Long deptId) - { + public void setDeptId(Long deptId) { this.deptId = deptId; } @Size(min = 0, max = 30, message = "用户昵称长度不能超过30个字符") - public String getNickName() - { + public String getNickName() { return nickName; } - public void setNickName(String nickName) - { + public void setNickName(String nickName) { this.nickName = nickName; } @NotBlank(message = "用户账号不能为空") @Size(min = 0, max = 30, message = "用户账号长度不能超过30个字符") - public String getUserName() - { + public String getUserName() { return userName; } - public void setUserName(String userName) - { + public void setUserName(String userName) { this.userName = userName; } @Email(message = "邮箱格式不正确") @Size(min = 0, max = 50, message = "邮箱长度不能超过50个字符") - public String getEmail() - { + public String getEmail() { return email; } - public void setEmail(String email) - { + public void setEmail(String email) { this.email = email; } @Size(min = 0, max = 11, message = "手机号码长度不能超过11个字符") - public String getPhonenumber() - { + public String getPhonenumber() { return phonenumber; } - public void setPhonenumber(String phonenumber) - { + public void setPhonenumber(String phonenumber) { this.phonenumber = phonenumber; } - public String getSex() - { + public String getSex() { return sex; } - public void setSex(String sex) - { + public void setSex(String sex) { this.sex = sex; } - public String getAvatar() - { + public String getAvatar() { return avatar; } - public void setAvatar(String avatar) - { + public void setAvatar(String avatar) { this.avatar = avatar; } - @JsonIgnore + @JsonIgnore @JsonProperty - public String getPassword() - { + public String getPassword() { return password; } - public void setPassword(String password) - { + public void setPassword(String password) { this.password = password; } - public String getSalt() - { + public String getSalt() { return salt; } - public void setSalt(String salt) - { + public void setSalt(String salt) { this.salt = salt; } - public String getStatus() - { + public String getStatus() { return status; } - public void setStatus(String status) - { + public void setStatus(String status) { this.status = status; } - public String getDelFlag() - { + public String getDelFlag() { return delFlag; } - public void setDelFlag(String delFlag) - { + public void setDelFlag(String delFlag) { this.delFlag = delFlag; } - public String getLoginIp() - { + public String getLoginIp() { return loginIp; } - public void setLoginIp(String loginIp) - { + public void setLoginIp(String loginIp) { this.loginIp = loginIp; } - public Date getLoginDate() - { + public Date getLoginDate() { return loginDate; } - public void setLoginDate(Date loginDate) - { + public void setLoginDate(Date loginDate) { this.loginDate = loginDate; } - public SysDept getDept() - { + public SysDept getDept() { return dept; } - public void setDept(SysDept dept) - { + public void setDept(SysDept dept) { this.dept = dept; } - public List getRoles() - { + public List getRoles() { return roles; } - public void setRoles(List roles) - { + public void setRoles(List roles) { this.roles = roles; } - public Long[] getRoleIds() - { + public Long[] getRoleIds() { return roleIds; } - public void setRoleIds(Long[] roleIds) - { + public void setRoleIds(Long[] roleIds) { this.roleIds = roleIds; } - public Long[] getPostIds() - { + public Long[] getPostIds() { return postIds; } - public void setPostIds(Long[] postIds) - { + public void setPostIds(Long[] postIds) { this.postIds = postIds; } @Override public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("userId", getUserId()) - .append("deptId", getDeptId()) - .append("userName", getUserName()) - .append("nickName", getNickName()) - .append("email", getEmail()) - .append("phonenumber", getPhonenumber()) - .append("sex", getSex()) - .append("avatar", getAvatar()) - .append("password", getPassword()) - .append("salt", getSalt()) - .append("status", getStatus()) - .append("delFlag", getDelFlag()) - .append("loginIp", getLoginIp()) - .append("loginDate", getLoginDate()) - .append("createBy", getCreateBy()) - .append("createTime", getCreateTime()) - .append("updateBy", getUpdateBy()) - .append("updateTime", getUpdateTime()) - .append("remark", getRemark()) - .append("dept", getDept()) - .toString(); + return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) + .append("userId", getUserId()) + .append("deptId", getDeptId()) + .append("userName", getUserName()) + .append("nickName", getNickName()) + .append("email", getEmail()) + .append("phonenumber", getPhonenumber()) + .append("sex", getSex()) + .append("avatar", getAvatar()) + .append("password", getPassword()) + .append("salt", getSalt()) + .append("status", getStatus()) + .append("delFlag", getDelFlag()) + .append("loginIp", getLoginIp()) + .append("loginDate", getLoginDate()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("remark", getRemark()) + .append("dept", getDept()) + .toString(); } } diff --git a/hchyun/hchyun-common/src/main/java/com/hchyun/common/core/entity/model/LoginBody.java b/hchyun/hchyun-common/src/main/java/com/hchyun/common/core/entity/model/LoginBody.java index 033483d..be2f93f 100644 --- a/hchyun/hchyun-common/src/main/java/com/hchyun/common/core/entity/model/LoginBody.java +++ b/hchyun/hchyun-common/src/main/java/com/hchyun/common/core/entity/model/LoginBody.java @@ -2,11 +2,10 @@ package com.hchyun.common.core.entity.model; /** * 用户登录对象 - * + * * @author hchyun */ -public class LoginBody -{ +public class LoginBody { /** * 用户名 */ @@ -27,43 +26,35 @@ public class LoginBody */ private String uuid = ""; - public String getUsername() - { + public String getUsername() { return username; } - public void setUsername(String username) - { + public void setUsername(String username) { this.username = username; } - public String getPassword() - { + public String getPassword() { return password; } - public void setPassword(String password) - { + public void setPassword(String password) { this.password = password; } - public String getCode() - { + public String getCode() { return code; } - public void setCode(String code) - { + public void setCode(String code) { this.code = code; } - public String getUuid() - { + public String getUuid() { return uuid; } - public void setUuid(String uuid) - { + public void setUuid(String uuid) { this.uuid = uuid; } } diff --git a/hchyun/hchyun-common/src/main/java/com/hchyun/common/core/entity/model/LoginUser.java b/hchyun/hchyun-common/src/main/java/com/hchyun/common/core/entity/model/LoginUser.java index ea9afe0..7740264 100644 --- a/hchyun/hchyun-common/src/main/java/com/hchyun/common/core/entity/model/LoginUser.java +++ b/hchyun/hchyun-common/src/main/java/com/hchyun/common/core/entity/model/LoginUser.java @@ -2,6 +2,7 @@ package com.hchyun.common.core.entity.model; import java.util.Collection; import java.util.Set; + import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.userdetails.UserDetails; import com.fasterxml.jackson.annotation.JsonIgnore; @@ -9,11 +10,10 @@ import com.hchyun.common.core.entity.entity.SysUser; /** * 登录用户身份权限 - * + * * @author hchyun */ -public class LoginUser implements UserDetails -{ +public class LoginUser implements UserDetails { /** @@ -61,36 +61,30 @@ public class LoginUser implements UserDetails */ private SysUser user; - public String getToken() - { + public String getToken() { return token; } - public void setToken(String token) - { + public void setToken(String token) { this.token = token; } - public LoginUser() - { + public LoginUser() { } - public LoginUser(SysUser user, Set permissions) - { + public LoginUser(SysUser user, Set permissions) { this.user = user; this.permissions = permissions; } @JsonIgnore @Override - public String getPassword() - { + public String getPassword() { return user.getPassword(); } @Override - public String getUsername() - { + public String getUsername() { return user.getUserName(); } @@ -99,130 +93,109 @@ public class LoginUser implements UserDetails */ @JsonIgnore @Override - public boolean isAccountNonExpired() - { + public boolean isAccountNonExpired() { return true; } /** * 指定用户是否解锁,锁定的用户无法进行身份验证 - * + * * @return */ @JsonIgnore @Override - public boolean isAccountNonLocked() - { + public boolean isAccountNonLocked() { return true; } /** * 指示是否已过期的用户的凭据(密码),过期的凭据防止认证 - * + * * @return */ @JsonIgnore @Override - public boolean isCredentialsNonExpired() - { + public boolean isCredentialsNonExpired() { return true; } /** * 是否可用 ,禁用的用户不能身份验证 - * + * * @return */ @JsonIgnore @Override - public boolean isEnabled() - { + public boolean isEnabled() { return true; } - public Long getLoginTime() - { + public Long getLoginTime() { return loginTime; } - public void setLoginTime(Long loginTime) - { + public void setLoginTime(Long loginTime) { this.loginTime = loginTime; } - public String getIpaddr() - { + public String getIpaddr() { return ipaddr; } - public void setIpaddr(String ipaddr) - { + public void setIpaddr(String ipaddr) { this.ipaddr = ipaddr; } - public String getLoginLocation() - { + public String getLoginLocation() { return loginLocation; } - public void setLoginLocation(String loginLocation) - { + public void setLoginLocation(String loginLocation) { this.loginLocation = loginLocation; } - public String getBrowser() - { + public String getBrowser() { return browser; } - public void setBrowser(String browser) - { + public void setBrowser(String browser) { this.browser = browser; } - public String getOs() - { + public String getOs() { return os; } - public void setOs(String os) - { + public void setOs(String os) { this.os = os; } - public Long getExpireTime() - { + public Long getExpireTime() { return expireTime; } - public void setExpireTime(Long expireTime) - { + public void setExpireTime(Long expireTime) { this.expireTime = expireTime; } - public Set getPermissions() - { + public Set getPermissions() { return permissions; } - public void setPermissions(Set permissions) - { + public void setPermissions(Set permissions) { this.permissions = permissions; } - public SysUser getUser() - { + public SysUser getUser() { return user; } - public void setUser(SysUser user) - { + public void setUser(SysUser user) { this.user = user; } @Override - public Collection getAuthorities() - { + public Collection getAuthorities() { return null; } } diff --git a/hchyun/hchyun-common/src/main/java/com/hchyun/common/core/page/PageDomain.java b/hchyun/hchyun-common/src/main/java/com/hchyun/common/core/page/PageDomain.java index c2e6bdb..082a774 100644 --- a/hchyun/hchyun-common/src/main/java/com/hchyun/common/core/page/PageDomain.java +++ b/hchyun/hchyun-common/src/main/java/com/hchyun/common/core/page/PageDomain.java @@ -4,69 +4,66 @@ import com.hchyun.common.utils.StringUtils; /** * 分页数据 - * + * * @author hchyun */ -public class PageDomain -{ - /** 当前记录起始索引 */ +public class PageDomain { + /** + * 当前记录起始索引 + */ private Integer pageNum; - /** 每页显示记录数 */ + /** + * 每页显示记录数 + */ private Integer pageSize; - /** 排序列 */ + /** + * 排序列 + */ private String orderByColumn; - /** 排序的方向desc或者asc */ + /** + * 排序的方向desc或者asc + */ private String isAsc = "asc"; - public String getOrderBy() - { - if (StringUtils.isEmpty(orderByColumn)) - { + public String getOrderBy() { + if (StringUtils.isEmpty(orderByColumn)) { return ""; } return StringUtils.toUnderScoreCase(orderByColumn) + " " + isAsc; } - public Integer getPageNum() - { + public Integer getPageNum() { return pageNum; } - public void setPageNum(Integer pageNum) - { + public void setPageNum(Integer pageNum) { this.pageNum = pageNum; } - public Integer getPageSize() - { + public Integer getPageSize() { return pageSize; } - public void setPageSize(Integer pageSize) - { + public void setPageSize(Integer pageSize) { this.pageSize = pageSize; } - public String getOrderByColumn() - { + public String getOrderByColumn() { return orderByColumn; } - public void setOrderByColumn(String orderByColumn) - { + public void setOrderByColumn(String orderByColumn) { this.orderByColumn = orderByColumn; } - public String getIsAsc() - { + public String getIsAsc() { return isAsc; } - public void setIsAsc(String isAsc) - { + public void setIsAsc(String isAsc) { this.isAsc = isAsc; } } diff --git a/hchyun/hchyun-common/src/main/java/com/hchyun/common/core/page/TableDataInfo.java b/hchyun/hchyun-common/src/main/java/com/hchyun/common/core/page/TableDataInfo.java index bafb1a1..b3b495f 100644 --- a/hchyun/hchyun-common/src/main/java/com/hchyun/common/core/page/TableDataInfo.java +++ b/hchyun/hchyun-common/src/main/java/com/hchyun/common/core/page/TableDataInfo.java @@ -5,81 +5,78 @@ import java.util.List; /** * 表格分页数据对象 - * + * * @author hchyun */ -public class TableDataInfo implements Serializable -{ +public class TableDataInfo implements Serializable { - /** 总记录数 */ + /** + * 总记录数 + */ private long total; - /** 列表数据 */ + /** + * 列表数据 + */ private List rows; - /** 消息状态码 */ + /** + * 消息状态码 + */ private int code; - /** 消息内容 */ + /** + * 消息内容 + */ private String msg; /** * 表格数据对象 */ - public TableDataInfo() - { + public TableDataInfo() { } /** * 分页 - * - * @param list 列表数据 + * + * @param list 列表数据 * @param total 总记录数 */ - public TableDataInfo(List list, int total) - { + public TableDataInfo(List list, int total) { this.rows = list; this.total = total; } - public long getTotal() - { + public long getTotal() { return total; } - public void setTotal(long total) - { + public void setTotal(long total) { this.total = total; } - public List getRows() - { + public List getRows() { return rows; } - public void setRows(List rows) - { + public void setRows(List rows) { this.rows = rows; } - public int getCode() - { + public int getCode() { return code; } - public void setCode(int code) - { + public void setCode(int code) { this.code = code; } - public String getMsg() - { + public String getMsg() { return msg; } - public void setMsg(String msg) - { + public void setMsg(String msg) { this.msg = msg; } } diff --git a/hchyun/hchyun-common/src/main/java/com/hchyun/common/core/page/TableSupport.java b/hchyun/hchyun-common/src/main/java/com/hchyun/common/core/page/TableSupport.java index 8c1cf08..725977d 100644 --- a/hchyun/hchyun-common/src/main/java/com/hchyun/common/core/page/TableSupport.java +++ b/hchyun/hchyun-common/src/main/java/com/hchyun/common/core/page/TableSupport.java @@ -4,11 +4,10 @@ import com.hchyun.common.utils.ServletUtils; /** * 表格数据处理 - * + * * @author hchyun */ -public class TableSupport -{ +public class TableSupport { /** * 当前记录起始索引 */ @@ -32,8 +31,7 @@ public class TableSupport /** * 封装分页对象 */ - public static PageDomain getPageDomain() - { + public static PageDomain getPageDomain() { PageDomain pageDomain = new PageDomain(); pageDomain.setPageNum(ServletUtils.getParameterToInt(PAGE_NUM)); pageDomain.setPageSize(ServletUtils.getParameterToInt(PAGE_SIZE)); @@ -42,8 +40,7 @@ public class TableSupport return pageDomain; } - public static PageDomain buildPageRequest() - { + public static PageDomain buildPageRequest() { return getPageDomain(); } } diff --git a/hchyun/hchyun-common/src/main/java/com/hchyun/common/core/text/CharsetKit.java b/hchyun/hchyun-common/src/main/java/com/hchyun/common/core/text/CharsetKit.java index 2bc9a8c..4bc1bde 100644 --- a/hchyun/hchyun-common/src/main/java/com/hchyun/common/core/text/CharsetKit.java +++ b/hchyun/hchyun-common/src/main/java/com/hchyun/common/core/text/CharsetKit.java @@ -2,75 +2,81 @@ package com.hchyun.common.core.text; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; + import com.hchyun.common.utils.StringUtils; /** * 字符集工具类 - * + * * @author hchyun */ -public class CharsetKit -{ - /** ISO-8859-1 */ +public class CharsetKit { + /** + * ISO-8859-1 + */ public static final String ISO_8859_1 = "ISO-8859-1"; - /** UTF-8 */ + /** + * UTF-8 + */ public static final String UTF_8 = "UTF-8"; - /** GBK */ + /** + * GBK + */ public static final String GBK = "GBK"; - /** ISO-8859-1 */ + /** + * ISO-8859-1 + */ public static final Charset CHARSET_ISO_8859_1 = Charset.forName(ISO_8859_1); - /** UTF-8 */ + /** + * UTF-8 + */ public static final Charset CHARSET_UTF_8 = Charset.forName(UTF_8); - /** GBK */ + /** + * GBK + */ public static final Charset CHARSET_GBK = Charset.forName(GBK); /** * 转换为Charset对象 - * + * * @param charset 字符集,为空则返回默认字符集 * @return Charset */ - public static Charset charset(String charset) - { + public static Charset charset(String charset) { return StringUtils.isEmpty(charset) ? Charset.defaultCharset() : Charset.forName(charset); } /** * 转换字符串的字符集编码 - * - * @param source 字符串 - * @param srcCharset 源字符集,默认ISO-8859-1 + * + * @param source 字符串 + * @param srcCharset 源字符集,默认ISO-8859-1 * @param destCharset 目标字符集,默认UTF-8 * @return 转换后的字符集 */ - public static String convert(String source, String srcCharset, String destCharset) - { + public static String convert(String source, String srcCharset, String destCharset) { return convert(source, Charset.forName(srcCharset), Charset.forName(destCharset)); } /** * 转换字符串的字符集编码 - * - * @param source 字符串 - * @param srcCharset 源字符集,默认ISO-8859-1 + * + * @param source 字符串 + * @param srcCharset 源字符集,默认ISO-8859-1 * @param destCharset 目标字符集,默认UTF-8 * @return 转换后的字符集 */ - public static String convert(String source, Charset srcCharset, Charset destCharset) - { - if (null == srcCharset) - { + public static String convert(String source, Charset srcCharset, Charset destCharset) { + if (null == srcCharset) { srcCharset = StandardCharsets.ISO_8859_1; } - if (null == destCharset) - { + if (null == destCharset) { srcCharset = StandardCharsets.UTF_8; } - if (StringUtils.isEmpty(source) || srcCharset.equals(destCharset)) - { + if (StringUtils.isEmpty(source) || srcCharset.equals(destCharset)) { return source; } return new String(source.getBytes(srcCharset), destCharset); @@ -79,8 +85,7 @@ public class CharsetKit /** * @return 系统字符集编码 */ - public static String systemCharset() - { + public static String systemCharset() { return Charset.defaultCharset().name(); } } diff --git a/hchyun/hchyun-common/src/main/java/com/hchyun/common/core/text/Convert.java b/hchyun/hchyun-common/src/main/java/com/hchyun/common/core/text/Convert.java index 2fd1342..cb9bbc9 100644 --- a/hchyun/hchyun-common/src/main/java/com/hchyun/common/core/text/Convert.java +++ b/hchyun/hchyun-common/src/main/java/com/hchyun/common/core/text/Convert.java @@ -6,32 +6,29 @@ import java.nio.ByteBuffer; import java.nio.charset.Charset; import java.text.NumberFormat; import java.util.Set; + import com.hchyun.common.utils.StringUtils; /** * 类型转换器 - * + * * @author hchyun */ -public class Convert -{ +public class Convert { /** * 转换为字符串
* 如果给定的值为null,或者转换失败,返回默认值
* 转换失败不会报错 - * - * @param value 被转换的值 + * + * @param value 被转换的值 * @param defaultValue 转换错误时的默认值 * @return 结果 */ - public static String toStr(Object value, String defaultValue) - { - if (null == value) - { + public static String toStr(Object value, String defaultValue) { + if (null == value) { return defaultValue; } - if (value instanceof String) - { + if (value instanceof String) { return (String) value; } return value.toString(); @@ -41,12 +38,11 @@ public class Convert * 转换为字符串
* 如果给定的值为null,或者转换失败,返回默认值null
* 转换失败不会报错 - * + * * @param value 被转换的值 * @return 结果 */ - public static String toStr(Object value) - { + public static String toStr(Object value) { return toStr(value, null); } @@ -54,19 +50,16 @@ public class Convert * 转换为字符
* 如果给定的值为null,或者转换失败,返回默认值
* 转换失败不会报错 - * - * @param value 被转换的值 + * + * @param value 被转换的值 * @param defaultValue 转换错误时的默认值 * @return 结果 */ - public static Character toChar(Object value, Character defaultValue) - { - if (null == value) - { + public static Character toChar(Object value, Character defaultValue) { + if (null == value) { return defaultValue; } - if (value instanceof Character) - { + if (value instanceof Character) { return (Character) value; } @@ -78,12 +71,11 @@ public class Convert * 转换为字符
* 如果给定的值为null,或者转换失败,返回默认值null
* 转换失败不会报错 - * + * * @param value 被转换的值 * @return 结果 */ - public static Character toChar(Object value) - { + public static Character toChar(Object value) { return toChar(value, null); } @@ -91,36 +83,28 @@ public class Convert * 转换为byte
* 如果给定的值为null,或者转换失败,返回默认值
* 转换失败不会报错 - * - * @param value 被转换的值 + * + * @param value 被转换的值 * @param defaultValue 转换错误时的默认值 * @return 结果 */ - public static Byte toByte(Object value, Byte defaultValue) - { - if (value == null) - { + public static Byte toByte(Object value, Byte defaultValue) { + if (value == null) { return defaultValue; } - if (value instanceof Byte) - { + if (value instanceof Byte) { return (Byte) value; } - if (value instanceof Number) - { + if (value instanceof Number) { return ((Number) value).byteValue(); } final String valueStr = toStr(value, null); - if (StringUtils.isEmpty(valueStr)) - { + if (StringUtils.isEmpty(valueStr)) { return defaultValue; } - try - { + try { return Byte.parseByte(valueStr); - } - catch (Exception e) - { + } catch (Exception e) { return defaultValue; } } @@ -129,12 +113,11 @@ public class Convert * 转换为byte
* 如果给定的值为null,或者转换失败,返回默认值null
* 转换失败不会报错 - * + * * @param value 被转换的值 * @return 结果 */ - public static Byte toByte(Object value) - { + public static Byte toByte(Object value) { return toByte(value, null); } @@ -142,36 +125,28 @@ public class Convert * 转换为Short
* 如果给定的值为null,或者转换失败,返回默认值
* 转换失败不会报错 - * - * @param value 被转换的值 + * + * @param value 被转换的值 * @param defaultValue 转换错误时的默认值 * @return 结果 */ - public static Short toShort(Object value, Short defaultValue) - { - if (value == null) - { + public static Short toShort(Object value, Short defaultValue) { + if (value == null) { return defaultValue; } - if (value instanceof Short) - { + if (value instanceof Short) { return (Short) value; } - if (value instanceof Number) - { + if (value instanceof Number) { return ((Number) value).shortValue(); } final String valueStr = toStr(value, null); - if (StringUtils.isEmpty(valueStr)) - { + if (StringUtils.isEmpty(valueStr)) { return defaultValue; } - try - { + try { return Short.parseShort(valueStr.trim()); - } - catch (Exception e) - { + } catch (Exception e) { return defaultValue; } } @@ -180,12 +155,11 @@ public class Convert * 转换为Short
* 如果给定的值为null,或者转换失败,返回默认值null
* 转换失败不会报错 - * + * * @param value 被转换的值 * @return 结果 */ - public static Short toShort(Object value) - { + public static Short toShort(Object value) { return toShort(value, null); } @@ -193,32 +167,25 @@ public class Convert * 转换为Number
* 如果给定的值为空,或者转换失败,返回默认值
* 转换失败不会报错 - * - * @param value 被转换的值 + * + * @param value 被转换的值 * @param defaultValue 转换错误时的默认值 * @return 结果 */ - public static Number toNumber(Object value, Number defaultValue) - { - if (value == null) - { + public static Number toNumber(Object value, Number defaultValue) { + if (value == null) { return defaultValue; } - if (value instanceof Number) - { + if (value instanceof Number) { return (Number) value; } final String valueStr = toStr(value, null); - if (StringUtils.isEmpty(valueStr)) - { + if (StringUtils.isEmpty(valueStr)) { return defaultValue; } - try - { + try { return NumberFormat.getInstance().parse(valueStr); - } - catch (Exception e) - { + } catch (Exception e) { return defaultValue; } } @@ -227,12 +194,11 @@ public class Convert * 转换为Number
* 如果给定的值为空,或者转换失败,返回默认值null
* 转换失败不会报错 - * + * * @param value 被转换的值 * @return 结果 */ - public static Number toNumber(Object value) - { + public static Number toNumber(Object value) { return toNumber(value, null); } @@ -240,36 +206,28 @@ public class Convert * 转换为int
* 如果给定的值为空,或者转换失败,返回默认值
* 转换失败不会报错 - * - * @param value 被转换的值 + * + * @param value 被转换的值 * @param defaultValue 转换错误时的默认值 * @return 结果 */ - public static Integer toInt(Object value, Integer defaultValue) - { - if (value == null) - { + public static Integer toInt(Object value, Integer defaultValue) { + if (value == null) { return defaultValue; } - if (value instanceof Integer) - { + if (value instanceof Integer) { return (Integer) value; } - if (value instanceof Number) - { + if (value instanceof Number) { return ((Number) value).intValue(); } final String valueStr = toStr(value, null); - if (StringUtils.isEmpty(valueStr)) - { + if (StringUtils.isEmpty(valueStr)) { return defaultValue; } - try - { + try { return Integer.parseInt(valueStr.trim()); - } - catch (Exception e) - { + } catch (Exception e) { return defaultValue; } } @@ -278,54 +236,48 @@ public class Convert * 转换为int
* 如果给定的值为null,或者转换失败,返回默认值null
* 转换失败不会报错 - * + * * @param value 被转换的值 * @return 结果 */ - public static Integer toInt(Object value) - { + public static Integer toInt(Object value) { return toInt(value, null); } /** * 转换为Integer数组
- * + * * @param str 被转换的值 * @return 结果 */ - public static Integer[] toIntArray(String str) - { + public static Integer[] toIntArray(String str) { return toIntArray(",", str); } /** * 转换为Long数组
- * + * * @param str 被转换的值 * @return 结果 */ - public static Long[] toLongArray(String str) - { + public static Long[] toLongArray(String str) { return toLongArray(",", str); } /** * 转换为Integer数组
- * + * * @param split 分隔符 * @param split 被转换的值 * @return 结果 */ - public static Integer[] toIntArray(String split, String str) - { - if (StringUtils.isEmpty(str)) - { - return new Integer[] {}; + public static Integer[] toIntArray(String split, String str) { + if (StringUtils.isEmpty(str)) { + return new Integer[]{}; } String[] arr = str.split(split); final Integer[] ints = new Integer[arr.length]; - for (int i = 0; i < arr.length; i++) - { + for (int i = 0; i < arr.length; i++) { final Integer v = toInt(arr[i], 0); ints[i] = v; } @@ -334,21 +286,18 @@ public class Convert /** * 转换为Long数组
- * + * * @param split 分隔符 - * @param str 被转换的值 + * @param str 被转换的值 * @return 结果 */ - public static Long[] toLongArray(String split, String str) - { - if (StringUtils.isEmpty(str)) - { - return new Long[] {}; + public static Long[] toLongArray(String split, String str) { + if (StringUtils.isEmpty(str)) { + return new Long[]{}; } String[] arr = str.split(split); final Long[] longs = new Long[arr.length]; - for (int i = 0; i < arr.length; i++) - { + for (int i = 0; i < arr.length; i++) { final Long v = toLong(arr[i], null); longs[i] = v; } @@ -357,24 +306,22 @@ public class Convert /** * 转换为String数组
- * + * * @param str 被转换的值 * @return 结果 */ - public static String[] toStrArray(String str) - { + public static String[] toStrArray(String str) { return toStrArray(",", str); } /** * 转换为String数组
- * + * * @param split 分隔符 * @param split 被转换的值 * @return 结果 */ - public static String[] toStrArray(String split, String str) - { + public static String[] toStrArray(String split, String str) { return str.split(split); } @@ -382,37 +329,29 @@ public class Convert * 转换为long
* 如果给定的值为空,或者转换失败,返回默认值
* 转换失败不会报错 - * - * @param value 被转换的值 + * + * @param value 被转换的值 * @param defaultValue 转换错误时的默认值 * @return 结果 */ - public static Long toLong(Object value, Long defaultValue) - { - if (value == null) - { + public static Long toLong(Object value, Long defaultValue) { + if (value == null) { return defaultValue; } - if (value instanceof Long) - { + if (value instanceof Long) { return (Long) value; } - if (value instanceof Number) - { + if (value instanceof Number) { return ((Number) value).longValue(); } final String valueStr = toStr(value, null); - if (StringUtils.isEmpty(valueStr)) - { + if (StringUtils.isEmpty(valueStr)) { return defaultValue; } - try - { + try { // 支持科学计数法 return new BigDecimal(valueStr.trim()).longValue(); - } - catch (Exception e) - { + } catch (Exception e) { return defaultValue; } } @@ -421,12 +360,11 @@ public class Convert * 转换为long
* 如果给定的值为null,或者转换失败,返回默认值null
* 转换失败不会报错 - * + * * @param value 被转换的值 * @return 结果 */ - public static Long toLong(Object value) - { + public static Long toLong(Object value) { return toLong(value, null); } @@ -434,37 +372,29 @@ public class Convert * 转换为double
* 如果给定的值为空,或者转换失败,返回默认值
* 转换失败不会报错 - * - * @param value 被转换的值 + * + * @param value 被转换的值 * @param defaultValue 转换错误时的默认值 * @return 结果 */ - public static Double toDouble(Object value, Double defaultValue) - { - if (value == null) - { + public static Double toDouble(Object value, Double defaultValue) { + if (value == null) { return defaultValue; } - if (value instanceof Double) - { + if (value instanceof Double) { return (Double) value; } - if (value instanceof Number) - { + if (value instanceof Number) { return ((Number) value).doubleValue(); } final String valueStr = toStr(value, null); - if (StringUtils.isEmpty(valueStr)) - { + if (StringUtils.isEmpty(valueStr)) { return defaultValue; } - try - { + try { // 支持科学计数法 return new BigDecimal(valueStr.trim()).doubleValue(); - } - catch (Exception e) - { + } catch (Exception e) { return defaultValue; } } @@ -473,12 +403,11 @@ public class Convert * 转换为double
* 如果给定的值为空,或者转换失败,返回默认值null
* 转换失败不会报错 - * + * * @param value 被转换的值 * @return 结果 */ - public static Double toDouble(Object value) - { + public static Double toDouble(Object value) { return toDouble(value, null); } @@ -486,36 +415,28 @@ public class Convert * 转换为Float
* 如果给定的值为空,或者转换失败,返回默认值
* 转换失败不会报错 - * - * @param value 被转换的值 + * + * @param value 被转换的值 * @param defaultValue 转换错误时的默认值 * @return 结果 */ - public static Float toFloat(Object value, Float defaultValue) - { - if (value == null) - { + public static Float toFloat(Object value, Float defaultValue) { + if (value == null) { return defaultValue; } - if (value instanceof Float) - { + if (value instanceof Float) { return (Float) value; } - if (value instanceof Number) - { + if (value instanceof Number) { return ((Number) value).floatValue(); } final String valueStr = toStr(value, null); - if (StringUtils.isEmpty(valueStr)) - { + if (StringUtils.isEmpty(valueStr)) { return defaultValue; } - try - { + try { return Float.parseFloat(valueStr.trim()); - } - catch (Exception e) - { + } catch (Exception e) { return defaultValue; } } @@ -524,12 +445,11 @@ public class Convert * 转换为Float
* 如果给定的值为空,或者转换失败,返回默认值null
* 转换失败不会报错 - * + * * @param value 被转换的值 * @return 结果 */ - public static Float toFloat(Object value) - { + public static Float toFloat(Object value) { return toFloat(value, null); } @@ -537,29 +457,24 @@ public class Convert * 转换为boolean
* String支持的值为:true、false、yes、ok、no,1,0 如果给定的值为空,或者转换失败,返回默认值
* 转换失败不会报错 - * - * @param value 被转换的值 + * + * @param value 被转换的值 * @param defaultValue 转换错误时的默认值 * @return 结果 */ - public static Boolean toBool(Object value, Boolean defaultValue) - { - if (value == null) - { + public static Boolean toBool(Object value, Boolean defaultValue) { + if (value == null) { return defaultValue; } - if (value instanceof Boolean) - { + if (value instanceof Boolean) { return (Boolean) value; } String valueStr = toStr(value, null); - if (StringUtils.isEmpty(valueStr)) - { + if (StringUtils.isEmpty(valueStr)) { return defaultValue; } valueStr = valueStr.trim().toLowerCase(); - switch (valueStr) - { + switch (valueStr) { case "true": return true; case "false": @@ -583,47 +498,39 @@ public class Convert * 转换为boolean
* 如果给定的值为空,或者转换失败,返回默认值null
* 转换失败不会报错 - * + * * @param value 被转换的值 * @return 结果 */ - public static Boolean toBool(Object value) - { + public static Boolean toBool(Object value) { return toBool(value, null); } /** * 转换为Enum对象
* 如果给定的值为空,或者转换失败,返回默认值
- * - * @param clazz Enum的Class - * @param value 值 + * + * @param clazz Enum的Class + * @param value 值 * @param defaultValue 默认值 * @return Enum */ - public static > E toEnum(Class clazz, Object value, E defaultValue) - { - if (value == null) - { + public static > E toEnum(Class clazz, Object value, E defaultValue) { + if (value == null) { return defaultValue; } - if (clazz.isAssignableFrom(value.getClass())) - { + if (clazz.isAssignableFrom(value.getClass())) { @SuppressWarnings("unchecked") E myE = (E) value; return myE; } final String valueStr = toStr(value, null); - if (StringUtils.isEmpty(valueStr)) - { + if (StringUtils.isEmpty(valueStr)) { return defaultValue; } - try - { + try { return Enum.valueOf(clazz, valueStr); - } - catch (Exception e) - { + } catch (Exception e) { return defaultValue; } } @@ -631,13 +538,12 @@ public class Convert /** * 转换为Enum对象
* 如果给定的值为空,或者转换失败,返回默认值null
- * + * * @param clazz Enum的Class * @param value 值 * @return Enum */ - public static > E toEnum(Class clazz, Object value) - { + public static > E toEnum(Class clazz, Object value) { return toEnum(clazz, value, null); } @@ -645,36 +551,28 @@ public class Convert * 转换为BigInteger
* 如果给定的值为空,或者转换失败,返回默认值
* 转换失败不会报错 - * - * @param value 被转换的值 + * + * @param value 被转换的值 * @param defaultValue 转换错误时的默认值 * @return 结果 */ - public static BigInteger toBigInteger(Object value, BigInteger defaultValue) - { - if (value == null) - { + public static BigInteger toBigInteger(Object value, BigInteger defaultValue) { + if (value == null) { return defaultValue; } - if (value instanceof BigInteger) - { + if (value instanceof BigInteger) { return (BigInteger) value; } - if (value instanceof Long) - { + if (value instanceof Long) { return BigInteger.valueOf((Long) value); } final String valueStr = toStr(value, null); - if (StringUtils.isEmpty(valueStr)) - { + if (StringUtils.isEmpty(valueStr)) { return defaultValue; } - try - { + try { return new BigInteger(valueStr); - } - catch (Exception e) - { + } catch (Exception e) { return defaultValue; } } @@ -683,12 +581,11 @@ public class Convert * 转换为BigInteger
* 如果给定的值为空,或者转换失败,返回默认值null
* 转换失败不会报错 - * + * * @param value 被转换的值 * @return 结果 */ - public static BigInteger toBigInteger(Object value) - { + public static BigInteger toBigInteger(Object value) { return toBigInteger(value, null); } @@ -696,44 +593,34 @@ public class Convert * 转换为BigDecimal
* 如果给定的值为空,或者转换失败,返回默认值
* 转换失败不会报错 - * - * @param value 被转换的值 + * + * @param value 被转换的值 * @param defaultValue 转换错误时的默认值 * @return 结果 */ - public static BigDecimal toBigDecimal(Object value, BigDecimal defaultValue) - { - if (value == null) - { + public static BigDecimal toBigDecimal(Object value, BigDecimal defaultValue) { + if (value == null) { return defaultValue; } - if (value instanceof BigDecimal) - { + if (value instanceof BigDecimal) { return (BigDecimal) value; } - if (value instanceof Long) - { + if (value instanceof Long) { return new BigDecimal((Long) value); } - if (value instanceof Double) - { + if (value instanceof Double) { return new BigDecimal((Double) value); } - if (value instanceof Integer) - { + if (value instanceof Integer) { return new BigDecimal((Integer) value); } final String valueStr = toStr(value, null); - if (StringUtils.isEmpty(valueStr)) - { + if (StringUtils.isEmpty(valueStr)) { return defaultValue; } - try - { + try { return new BigDecimal(valueStr); - } - catch (Exception e) - { + } catch (Exception e) { return defaultValue; } } @@ -742,65 +629,55 @@ public class Convert * 转换为BigDecimal
* 如果给定的值为空,或者转换失败,返回默认值
* 转换失败不会报错 - * + * * @param value 被转换的值 * @return 结果 */ - public static BigDecimal toBigDecimal(Object value) - { + public static BigDecimal toBigDecimal(Object value) { return toBigDecimal(value, null); } /** * 将对象转为字符串
* 1、Byte数组和ByteBuffer会被转换为对应字符串的数组 2、对象数组会调用Arrays.toString方法 - * + * * @param obj 对象 * @return 字符串 */ - public static String utf8Str(Object obj) - { + public static String utf8Str(Object obj) { return str(obj, CharsetKit.CHARSET_UTF_8); } /** * 将对象转为字符串
* 1、Byte数组和ByteBuffer会被转换为对应字符串的数组 2、对象数组会调用Arrays.toString方法 - * - * @param obj 对象 + * + * @param obj 对象 * @param charsetName 字符集 * @return 字符串 */ - public static String str(Object obj, String charsetName) - { + public static String str(Object obj, String charsetName) { return str(obj, Charset.forName(charsetName)); } /** * 将对象转为字符串
* 1、Byte数组和ByteBuffer会被转换为对应字符串的数组 2、对象数组会调用Arrays.toString方法 - * - * @param obj 对象 + * + * @param obj 对象 * @param charset 字符集 * @return 字符串 */ - public static String str(Object obj, Charset charset) - { - if (null == obj) - { + public static String str(Object obj, Charset charset) { + if (null == obj) { return null; } - if (obj instanceof String) - { + if (obj instanceof String) { return (String) obj; - } - else if (obj instanceof byte[] || obj instanceof Byte[]) - { + } else if (obj instanceof byte[] || obj instanceof Byte[]) { return str((Byte[]) obj, charset); - } - else if (obj instanceof ByteBuffer) - { + } else if (obj instanceof ByteBuffer) { return str((ByteBuffer) obj, charset); } return obj.toString(); @@ -808,32 +685,28 @@ public class Convert /** * 将byte数组转为字符串 - * - * @param bytes byte数组 + * + * @param bytes byte数组 * @param charset 字符集 * @return 字符串 */ - public static String str(byte[] bytes, String charset) - { + public static String str(byte[] bytes, String charset) { return str(bytes, StringUtils.isEmpty(charset) ? Charset.defaultCharset() : Charset.forName(charset)); } /** * 解码字节码 - * - * @param data 字符串 + * + * @param data 字符串 * @param charset 字符集,如果此字段为空,则解码的结果取决于平台 * @return 解码后的字符串 */ - public static String str(byte[] data, Charset charset) - { - if (data == null) - { + public static String str(byte[] data, Charset charset) { + if (data == null) { return null; } - if (null == charset) - { + if (null == charset) { return new String(data); } return new String(data, charset); @@ -841,15 +714,13 @@ public class Convert /** * 将编码的byteBuffer数据转换为字符串 - * - * @param data 数据 + * + * @param data 数据 * @param charset 字符集,如果为空使用当前系统字符集 * @return 字符串 */ - public static String str(ByteBuffer data, String charset) - { - if (data == null) - { + public static String str(ByteBuffer data, String charset) { + if (data == null) { return null; } @@ -858,56 +729,48 @@ public class Convert /** * 将编码的byteBuffer数据转换为字符串 - * - * @param data 数据 + * + * @param data 数据 * @param charset 字符集,如果为空使用当前系统字符集 * @return 字符串 */ - public static String str(ByteBuffer data, Charset charset) - { - if (null == charset) - { + public static String str(ByteBuffer data, Charset charset) { + if (null == charset) { charset = Charset.defaultCharset(); } return charset.decode(data).toString(); } // ----------------------------------------------------------------------- 全角半角转换 + /** * 半角转全角 - * + * * @param input String. * @return 全角字符串. */ - public static String toSBC(String input) - { + public static String toSBC(String input) { return toSBC(input, null); } /** * 半角转全角 - * - * @param input String + * + * @param input String * @param notConvertSet 不替换的字符集合 * @return 全角字符串. */ - public static String toSBC(String input, Set notConvertSet) - { + public static String toSBC(String input, Set notConvertSet) { char c[] = input.toCharArray(); - for (int i = 0; i < c.length; i++) - { - if (null != notConvertSet && notConvertSet.contains(c[i])) - { + for (int i = 0; i < c.length; i++) { + if (null != notConvertSet && notConvertSet.contains(c[i])) { // 跳过不替换的字符 continue; } - if (c[i] == ' ') - { + if (c[i] == ' ') { c[i] = '\u3000'; - } - else if (c[i] < '\177') - { + } else if (c[i] < '\177') { c[i] = (char) (c[i] + 65248); } @@ -917,39 +780,32 @@ public class Convert /** * 全角转半角 - * + * * @param input String. * @return 半角字符串 */ - public static String toDBC(String input) - { + public static String toDBC(String input) { return toDBC(input, null); } /** * 替换全角为半角 - * - * @param text 文本 + * + * @param text 文本 * @param notConvertSet 不替换的字符集合 * @return 替换后的字符 */ - public static String toDBC(String text, Set notConvertSet) - { + public static String toDBC(String text, Set notConvertSet) { char c[] = text.toCharArray(); - for (int i = 0; i < c.length; i++) - { - if (null != notConvertSet && notConvertSet.contains(c[i])) - { + for (int i = 0; i < c.length; i++) { + if (null != notConvertSet && notConvertSet.contains(c[i])) { // 跳过不替换的字符 continue; } - if (c[i] == '\u3000') - { + if (c[i] == '\u3000') { c[i] = ' '; - } - else if (c[i] > '\uFF00' && c[i] < '\uFF5F') - { + } else if (c[i] > '\uFF00' && c[i] < '\uFF5F') { c[i] = (char) (c[i] - 65248); } } @@ -960,35 +816,30 @@ public class Convert /** * 数字金额大写转换 先写个完整的然后将如零拾替换成零 - * + * * @param n 数字 * @return 中文大写数字 */ - public static String digitUppercase(double n) - { - String[] fraction = { "角", "分" }; - String[] digit = { "零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖" }; - String[][] unit = { { "元", "万", "亿" }, { "", "拾", "佰", "仟" } }; + public static String digitUppercase(double n) { + String[] fraction = {"角", "分"}; + String[] digit = {"零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖"}; + String[][] unit = {{"元", "万", "亿"}, {"", "拾", "佰", "仟"}}; String head = n < 0 ? "负" : ""; n = Math.abs(n); String s = ""; - for (int i = 0; i < fraction.length; i++) - { + for (int i = 0; i < fraction.length; i++) { s += (digit[(int) (Math.floor(n * 10 * Math.pow(10, i)) % 10)] + fraction[i]).replaceAll("(零.)+", ""); } - if (s.length() < 1) - { + if (s.length() < 1) { s = "整"; } int integerPart = (int) Math.floor(n); - for (int i = 0; i < unit[0].length && integerPart > 0; i++) - { + for (int i = 0; i < unit[0].length && integerPart > 0; i++) { String p = ""; - for (int j = 0; j < unit[1].length && n > 0; j++) - { + for (int j = 0; j < unit[1].length && n > 0; j++) { p = digit[integerPart % 10] + unit[1][j] + p; integerPart = integerPart / 10; } diff --git a/hchyun/hchyun-common/src/main/java/com/hchyun/common/enums/BusinessStatus.java b/hchyun/hchyun-common/src/main/java/com/hchyun/common/enums/BusinessStatus.java index 4559dd4..d6a0d5b 100644 --- a/hchyun/hchyun-common/src/main/java/com/hchyun/common/enums/BusinessStatus.java +++ b/hchyun/hchyun-common/src/main/java/com/hchyun/common/enums/BusinessStatus.java @@ -2,12 +2,10 @@ package com.hchyun.common.enums; /** * 操作状态 - * - * @author hchyun * + * @author hchyun */ -public enum BusinessStatus -{ +public enum BusinessStatus { /** * 成功 */ diff --git a/hchyun/hchyun-common/src/main/java/com/hchyun/common/enums/BusinessType.java b/hchyun/hchyun-common/src/main/java/com/hchyun/common/enums/BusinessType.java index c7758cb..26094d2 100644 --- a/hchyun/hchyun-common/src/main/java/com/hchyun/common/enums/BusinessType.java +++ b/hchyun/hchyun-common/src/main/java/com/hchyun/common/enums/BusinessType.java @@ -2,11 +2,10 @@ package com.hchyun.common.enums; /** * 业务操作类型 - * + * * @author hchyun */ -public enum BusinessType -{ +public enum BusinessType { /** * 其它 */ @@ -51,7 +50,7 @@ public enum BusinessType * 生成代码 */ GENCODE, - + /** * 清空数据 */ diff --git a/hchyun/hchyun-common/src/main/java/com/hchyun/common/enums/DataSourceType.java b/hchyun/hchyun-common/src/main/java/com/hchyun/common/enums/DataSourceType.java index d30c1e2..188741a 100644 --- a/hchyun/hchyun-common/src/main/java/com/hchyun/common/enums/DataSourceType.java +++ b/hchyun/hchyun-common/src/main/java/com/hchyun/common/enums/DataSourceType.java @@ -2,11 +2,10 @@ package com.hchyun.common.enums; /** * 数据源 - * + * * @author hchyun */ -public enum DataSourceType -{ +public enum DataSourceType { /** * 主库 */ diff --git a/hchyun/hchyun-common/src/main/java/com/hchyun/common/enums/HttpMethod.java b/hchyun/hchyun-common/src/main/java/com/hchyun/common/enums/HttpMethod.java index 2f23955..5534787 100644 --- a/hchyun/hchyun-common/src/main/java/com/hchyun/common/enums/HttpMethod.java +++ b/hchyun/hchyun-common/src/main/java/com/hchyun/common/enums/HttpMethod.java @@ -2,6 +2,7 @@ package com.hchyun.common.enums; import java.util.HashMap; import java.util.Map; + import org.springframework.lang.Nullable; /** @@ -9,28 +10,23 @@ import org.springframework.lang.Nullable; * * @author hchyun */ -public enum HttpMethod -{ +public enum HttpMethod { GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS, TRACE; private static final Map mappings = new HashMap<>(16); - static - { - for (HttpMethod httpMethod : values()) - { + static { + for (HttpMethod httpMethod : values()) { mappings.put(httpMethod.name(), httpMethod); } } @Nullable - public static HttpMethod resolve(@Nullable String method) - { + public static HttpMethod resolve(@Nullable String method) { return (method != null ? mappings.get(method) : null); } - public boolean matches(String method) - { + public boolean matches(String method) { return (this == resolve(method)); } } diff --git a/hchyun/hchyun-common/src/main/java/com/hchyun/common/enums/OperatorType.java b/hchyun/hchyun-common/src/main/java/com/hchyun/common/enums/OperatorType.java index e6ca342..00eda49 100644 --- a/hchyun/hchyun-common/src/main/java/com/hchyun/common/enums/OperatorType.java +++ b/hchyun/hchyun-common/src/main/java/com/hchyun/common/enums/OperatorType.java @@ -2,11 +2,10 @@ package com.hchyun.common.enums; /** * 操作人类别 - * + * * @author hchyun */ -public enum OperatorType -{ +public enum OperatorType { /** * 其它 */ diff --git a/hchyun/hchyun-common/src/main/java/com/hchyun/common/enums/UserStatus.java b/hchyun/hchyun-common/src/main/java/com/hchyun/common/enums/UserStatus.java index 5641844..072d3bf 100644 --- a/hchyun/hchyun-common/src/main/java/com/hchyun/common/enums/UserStatus.java +++ b/hchyun/hchyun-common/src/main/java/com/hchyun/common/enums/UserStatus.java @@ -2,29 +2,25 @@ package com.hchyun.common.enums; /** * 用户状态 - * + * * @author hchyun */ -public enum UserStatus -{ +public enum UserStatus { OK("0", "正常"), DISABLE("1", "停用"), DELETED("2", "删除"); private final String code; private final String info; - UserStatus(String code, String info) - { + UserStatus(String code, String info) { this.code = code; this.info = info; } - public String getCode() - { + public String getCode() { return code; } - public String getInfo() - { + public String getInfo() { return info; } } diff --git a/hchyun/hchyun-common/src/main/java/com/hchyun/common/exception/BaseException.java b/hchyun/hchyun-common/src/main/java/com/hchyun/common/exception/BaseException.java index 4332f0b..8233594 100644 --- a/hchyun/hchyun-common/src/main/java/com/hchyun/common/exception/BaseException.java +++ b/hchyun/hchyun-common/src/main/java/com/hchyun/common/exception/BaseException.java @@ -5,11 +5,10 @@ import com.hchyun.common.utils.StringUtils; /** * 基础异常 - * + * * @author hchyun */ -public class BaseException extends RuntimeException -{ +public class BaseException extends RuntimeException { /** @@ -32,66 +31,54 @@ public class BaseException extends RuntimeException */ private String defaultMessage; - public BaseException(String module, String code, Object[] args, String defaultMessage) - { + public BaseException(String module, String code, Object[] args, String defaultMessage) { this.module = module; this.code = code; this.args = args; this.defaultMessage = defaultMessage; } - public BaseException(String module, String code, Object[] args) - { + public BaseException(String module, String code, Object[] args) { this(module, code, args, null); } - public BaseException(String module, String defaultMessage) - { + public BaseException(String module, String defaultMessage) { this(module, null, null, defaultMessage); } - public BaseException(String code, Object[] args) - { + public BaseException(String code, Object[] args) { this(null, code, args, null); } - public BaseException(String defaultMessage) - { + public BaseException(String defaultMessage) { this(null, null, null, defaultMessage); } @Override - public String getMessage() - { + public String getMessage() { String message = null; - if (!StringUtils.isEmpty(code)) - { + if (!StringUtils.isEmpty(code)) { message = MessageUtils.message(code, args); } - if (message == null) - { + if (message == null) { message = defaultMessage; } return message; } - public String getModule() - { + public String getModule() { return module; } - public String getCode() - { + public String getCode() { return code; } - public Object[] getArgs() - { + public Object[] getArgs() { return args; } - public String getDefaultMessage() - { + public String getDefaultMessage() { return defaultMessage; } } diff --git a/hchyun/hchyun-common/src/main/java/com/hchyun/common/exception/CustomException.java b/hchyun/hchyun-common/src/main/java/com/hchyun/common/exception/CustomException.java index 03affaa..67d88ba 100644 --- a/hchyun/hchyun-common/src/main/java/com/hchyun/common/exception/CustomException.java +++ b/hchyun/hchyun-common/src/main/java/com/hchyun/common/exception/CustomException.java @@ -2,42 +2,36 @@ package com.hchyun.common.exception; /** * 自定义异常 - * + * * @author hchyun */ -public class CustomException extends RuntimeException -{ +public class CustomException extends RuntimeException { private Integer code; private String message; - public CustomException(String message) - { + public CustomException(String message) { this.message = message; } - public CustomException(String message, Integer code) - { + public CustomException(String message, Integer code) { this.message = message; this.code = code; } - public CustomException(String message, Throwable e) - { + public CustomException(String message, Throwable e) { super(message, e); this.message = message; } @Override - public String getMessage() - { + public String getMessage() { return message; } - public Integer getCode() - { + public Integer getCode() { return code; } } diff --git a/hchyun/hchyun-common/src/main/java/com/hchyun/common/exception/DemoModeException.java b/hchyun/hchyun-common/src/main/java/com/hchyun/common/exception/DemoModeException.java index f1c8935..aca20ab 100644 --- a/hchyun/hchyun-common/src/main/java/com/hchyun/common/exception/DemoModeException.java +++ b/hchyun/hchyun-common/src/main/java/com/hchyun/common/exception/DemoModeException.java @@ -2,14 +2,12 @@ package com.hchyun.common.exception; /** * 演示模式异常 - * + * * @author hchyun */ -public class DemoModeException extends RuntimeException -{ +public class DemoModeException extends RuntimeException { - public DemoModeException() - { + public DemoModeException() { } } diff --git a/hchyun/hchyun-common/src/main/java/com/hchyun/common/exception/UtilException.java b/hchyun/hchyun-common/src/main/java/com/hchyun/common/exception/UtilException.java index 30e29ba..da508df 100644 --- a/hchyun/hchyun-common/src/main/java/com/hchyun/common/exception/UtilException.java +++ b/hchyun/hchyun-common/src/main/java/com/hchyun/common/exception/UtilException.java @@ -2,25 +2,21 @@ package com.hchyun.common.exception; /** * 工具类异常 - * + * * @author hchyun */ -public class UtilException extends RuntimeException -{ +public class UtilException extends RuntimeException { private static final long serialVersionUID = 8247610319171014183L; - public UtilException(Throwable e) - { + public UtilException(Throwable e) { super(e.getMessage(), e); } - public UtilException(String message) - { + public UtilException(String message) { super(message); } - public UtilException(String message, Throwable throwable) - { + public UtilException(String message, Throwable throwable) { super(message, throwable); } } diff --git a/hchyun/hchyun-common/src/main/java/com/hchyun/common/exception/file/FileException.java b/hchyun/hchyun-common/src/main/java/com/hchyun/common/exception/file/FileException.java index 3657c65..239e824 100644 --- a/hchyun/hchyun-common/src/main/java/com/hchyun/common/exception/file/FileException.java +++ b/hchyun/hchyun-common/src/main/java/com/hchyun/common/exception/file/FileException.java @@ -4,15 +4,13 @@ import com.hchyun.common.exception.BaseException; /** * 文件信息异常类 - * + * * @author hchyun */ -public class FileException extends BaseException -{ +public class FileException extends BaseException { - public FileException(String code, Object[] args) - { + public FileException(String code, Object[] args) { super("file", code, args, null); } diff --git a/hchyun/hchyun-common/src/main/java/com/hchyun/common/exception/file/FileNameLengthLimitExceededException.java b/hchyun/hchyun-common/src/main/java/com/hchyun/common/exception/file/FileNameLengthLimitExceededException.java index 901d5cc..5df44f0 100644 --- a/hchyun/hchyun-common/src/main/java/com/hchyun/common/exception/file/FileNameLengthLimitExceededException.java +++ b/hchyun/hchyun-common/src/main/java/com/hchyun/common/exception/file/FileNameLengthLimitExceededException.java @@ -2,15 +2,13 @@ package com.hchyun.common.exception.file; /** * 文件名称超长限制异常类 - * + * * @author hchyun */ -public class FileNameLengthLimitExceededException extends FileException -{ +public class FileNameLengthLimitExceededException extends FileException { - public FileNameLengthLimitExceededException(int defaultFileNameLength) - { - super("upload.filename.exceed.length", new Object[] { defaultFileNameLength }); + public FileNameLengthLimitExceededException(int defaultFileNameLength) { + super("upload.filename.exceed.length", new Object[]{defaultFileNameLength}); } } diff --git a/hchyun/hchyun-common/src/main/java/com/hchyun/common/exception/file/FileSizeLimitExceededException.java b/hchyun/hchyun-common/src/main/java/com/hchyun/common/exception/file/FileSizeLimitExceededException.java index fad80f1..9e86475 100644 --- a/hchyun/hchyun-common/src/main/java/com/hchyun/common/exception/file/FileSizeLimitExceededException.java +++ b/hchyun/hchyun-common/src/main/java/com/hchyun/common/exception/file/FileSizeLimitExceededException.java @@ -2,15 +2,13 @@ package com.hchyun.common.exception.file; /** * 文件名大小限制异常类 - * + * * @author hchyun */ -public class FileSizeLimitExceededException extends FileException -{ +public class FileSizeLimitExceededException extends FileException { - public FileSizeLimitExceededException(long defaultMaxSize) - { - super("upload.exceed.maxSize", new Object[] { defaultMaxSize }); + public FileSizeLimitExceededException(long defaultMaxSize) { + super("upload.exceed.maxSize", new Object[]{defaultMaxSize}); } } diff --git a/hchyun/hchyun-common/src/main/java/com/hchyun/common/exception/file/InvalidExtensionException.java b/hchyun/hchyun-common/src/main/java/com/hchyun/common/exception/file/InvalidExtensionException.java index 58d75fb..e8f9aca 100644 --- a/hchyun/hchyun-common/src/main/java/com/hchyun/common/exception/file/InvalidExtensionException.java +++ b/hchyun/hchyun-common/src/main/java/com/hchyun/common/exception/file/InvalidExtensionException.java @@ -1,70 +1,60 @@ package com.hchyun.common.exception.file; import java.util.Arrays; + import org.apache.commons.fileupload.FileUploadException; /** * 文件上传 误异常类 - * + * * @author hchyun */ -public class InvalidExtensionException extends FileUploadException -{ +public class InvalidExtensionException extends FileUploadException { private String[] allowedExtension; private String extension; private String filename; - public InvalidExtensionException(String[] allowedExtension, String extension, String filename) - { + public InvalidExtensionException(String[] allowedExtension, String extension, String filename) { super("filename : [" + filename + "], extension : [" + extension + "], allowed extension : [" + Arrays.toString(allowedExtension) + "]"); this.allowedExtension = allowedExtension; this.extension = extension; this.filename = filename; } - public String[] getAllowedExtension() - { + public String[] getAllowedExtension() { return allowedExtension; } - public String getExtension() - { + public String getExtension() { return extension; } - public String getFilename() - { + public String getFilename() { return filename; } - public static class InvalidImageExtensionException extends InvalidExtensionException - { + public static class InvalidImageExtensionException extends InvalidExtensionException { - public InvalidImageExtensionException(String[] allowedExtension, String extension, String filename) - { + public InvalidImageExtensionException(String[] allowedExtension, String extension, String filename) { super(allowedExtension, extension, filename); } } - public static class InvalidFlashExtensionException extends InvalidExtensionException - { + public static class InvalidFlashExtensionException extends InvalidExtensionException { - public InvalidFlashExtensionException(String[] allowedExtension, String extension, String filename) - { + public InvalidFlashExtensionException(String[] allowedExtension, String extension, String filename) { super(allowedExtension, extension, filename); } } - public static class InvalidMediaExtensionException extends InvalidExtensionException - { + public static class InvalidMediaExtensionException extends InvalidExtensionException { - public InvalidMediaExtensionException(String[] allowedExtension, String extension, String filename) - { + public InvalidMediaExtensionException(String[] allowedExtension, String extension, String filename) { super(allowedExtension, extension, filename); } } diff --git a/hchyun/hchyun-common/src/main/java/com/hchyun/common/exception/job/TaskException.java b/hchyun/hchyun-common/src/main/java/com/hchyun/common/exception/job/TaskException.java index b55c096..4643314 100644 --- a/hchyun/hchyun-common/src/main/java/com/hchyun/common/exception/job/TaskException.java +++ b/hchyun/hchyun-common/src/main/java/com/hchyun/common/exception/job/TaskException.java @@ -2,33 +2,28 @@ package com.hchyun.common.exception.job; /** * 计划策略异常 - * + * * @author hchyun */ -public class TaskException extends Exception -{ +public class TaskException extends Exception { private Code code; - public TaskException(String msg, Code code) - { + public TaskException(String msg, Code code) { this(msg, code, null); } - public TaskException(String msg, Code code, Exception nestedEx) - { + public TaskException(String msg, Code code, Exception nestedEx) { super(msg, nestedEx); this.code = code; } - public Code getCode() - { + public Code getCode() { return code; } - public enum Code - { + public enum Code { TASK_EXISTS, NO_TASK_EXISTS, TASK_ALREADY_STARTED, UNKNOWN, CONFIG_ERROR, TASK_NODE_NOT_AVAILABLE } } \ No newline at end of file diff --git a/hchyun/hchyun-common/src/main/java/com/hchyun/common/exception/user/CaptchaException.java b/hchyun/hchyun-common/src/main/java/com/hchyun/common/exception/user/CaptchaException.java index 49c9054..c52c0d9 100644 --- a/hchyun/hchyun-common/src/main/java/com/hchyun/common/exception/user/CaptchaException.java +++ b/hchyun/hchyun-common/src/main/java/com/hchyun/common/exception/user/CaptchaException.java @@ -2,15 +2,13 @@ package com.hchyun.common.exception.user; /** * 验证码错误异常类 - * + * * @author hchyun */ -public class CaptchaException extends UserException -{ +public class CaptchaException extends UserException { - public CaptchaException() - { + public CaptchaException() { super("user.jcaptcha.error", null); } } diff --git a/hchyun/hchyun-common/src/main/java/com/hchyun/common/exception/user/CaptchaExpireException.java b/hchyun/hchyun-common/src/main/java/com/hchyun/common/exception/user/CaptchaExpireException.java index 2a029e3..d7f107c 100644 --- a/hchyun/hchyun-common/src/main/java/com/hchyun/common/exception/user/CaptchaExpireException.java +++ b/hchyun/hchyun-common/src/main/java/com/hchyun/common/exception/user/CaptchaExpireException.java @@ -2,15 +2,13 @@ package com.hchyun.common.exception.user; /** * 验证码失效异常类 - * + * * @author hchyun */ -public class CaptchaExpireException extends UserException -{ +public class CaptchaExpireException extends UserException { - public CaptchaExpireException() - { + public CaptchaExpireException() { super("user.jcaptcha.expire", null); } } diff --git a/hchyun/hchyun-common/src/main/java/com/hchyun/common/exception/user/UserException.java b/hchyun/hchyun-common/src/main/java/com/hchyun/common/exception/user/UserException.java index 05286c5..be37541 100644 --- a/hchyun/hchyun-common/src/main/java/com/hchyun/common/exception/user/UserException.java +++ b/hchyun/hchyun-common/src/main/java/com/hchyun/common/exception/user/UserException.java @@ -4,15 +4,13 @@ import com.hchyun.common.exception.BaseException; /** * 用户信息异常类 - * + * * @author hchyun */ -public class UserException extends BaseException -{ +public class UserException extends BaseException { - public UserException(String code, Object[] args) - { + public UserException(String code, Object[] args) { super("user", code, args, null); } } diff --git a/hchyun/hchyun-common/src/main/java/com/hchyun/common/exception/user/UserPasswordNotMatchException.java b/hchyun/hchyun-common/src/main/java/com/hchyun/common/exception/user/UserPasswordNotMatchException.java index cf59fad..c6e36b3 100644 --- a/hchyun/hchyun-common/src/main/java/com/hchyun/common/exception/user/UserPasswordNotMatchException.java +++ b/hchyun/hchyun-common/src/main/java/com/hchyun/common/exception/user/UserPasswordNotMatchException.java @@ -2,15 +2,13 @@ package com.hchyun.common.exception.user; /** * 用户密码不正确或不符合规范异常类 - * + * * @author hchyun */ -public class UserPasswordNotMatchException extends UserException -{ +public class UserPasswordNotMatchException extends UserException { - public UserPasswordNotMatchException() - { + public UserPasswordNotMatchException() { super("user.password.not.match", null); } } diff --git a/hchyun/hchyun-common/src/main/java/com/hchyun/common/filter/RepeatableFilter.java b/hchyun/hchyun-common/src/main/java/com/hchyun/common/filter/RepeatableFilter.java index e780f47..6803b8a 100644 --- a/hchyun/hchyun-common/src/main/java/com/hchyun/common/filter/RepeatableFilter.java +++ b/hchyun/hchyun-common/src/main/java/com/hchyun/common/filter/RepeatableFilter.java @@ -8,45 +8,38 @@ import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletRequest; + import org.springframework.http.MediaType; import com.hchyun.common.utils.StringUtils; /** * Repeatable 过滤器 - * + * * @author hchyun */ -public class RepeatableFilter implements Filter -{ +public class RepeatableFilter implements Filter { @Override - public void init(FilterConfig filterConfig) throws ServletException - { + public void init(FilterConfig filterConfig) throws ServletException { } @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) - throws IOException, ServletException - { + throws IOException, ServletException { ServletRequest requestWrapper = null; if (request instanceof HttpServletRequest && StringUtils.equalsAnyIgnoreCase(request.getContentType(), - MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_JSON_UTF8_VALUE)) - { + MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_JSON_UTF8_VALUE)) { requestWrapper = new RepeatedlyRequestWrapper((HttpServletRequest) request, response); } - if (null == requestWrapper) - { + if (null == requestWrapper) { chain.doFilter(request, response); - } - else - { + } else { chain.doFilter(requestWrapper, response); } } @Override - public void destroy() - { + public void destroy() { } } diff --git a/hchyun/hchyun-common/src/main/java/com/hchyun/common/filter/RepeatedlyRequestWrapper.java b/hchyun/hchyun-common/src/main/java/com/hchyun/common/filter/RepeatedlyRequestWrapper.java index 993db0d..a9d7647 100644 --- a/hchyun/hchyun-common/src/main/java/com/hchyun/common/filter/RepeatedlyRequestWrapper.java +++ b/hchyun/hchyun-common/src/main/java/com/hchyun/common/filter/RepeatedlyRequestWrapper.java @@ -9,19 +9,18 @@ import javax.servlet.ServletInputStream; import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequestWrapper; + import com.hchyun.common.utils.http.HttpHelper; /** * 构建可重复读取inputStream的request - * + * * @author hchyun */ -public class RepeatedlyRequestWrapper extends HttpServletRequestWrapper -{ +public class RepeatedlyRequestWrapper extends HttpServletRequestWrapper { private final byte[] body; - public RepeatedlyRequestWrapper(HttpServletRequest request, ServletResponse response) throws IOException - { + public RepeatedlyRequestWrapper(HttpServletRequest request, ServletResponse response) throws IOException { super(request); request.setCharacterEncoding("UTF-8"); response.setCharacterEncoding("UTF-8"); @@ -30,41 +29,34 @@ public class RepeatedlyRequestWrapper extends HttpServletRequestWrapper } @Override - public BufferedReader getReader() throws IOException - { + public BufferedReader getReader() throws IOException { return new BufferedReader(new InputStreamReader(getInputStream())); } @Override - public ServletInputStream getInputStream() throws IOException - { + public ServletInputStream getInputStream() throws IOException { final ByteArrayInputStream bais = new ByteArrayInputStream(body); - return new ServletInputStream() - { + return new ServletInputStream() { @Override - public int read() throws IOException - { + public int read() throws IOException { return bais.read(); } @Override - public boolean isFinished() - { + public boolean isFinished() { return false; } @Override - public boolean isReady() - { + public boolean isReady() { return false; } @Override - public void setReadListener(ReadListener readListener) - { + public void setReadListener(ReadListener readListener) { } }; diff --git a/hchyun/hchyun-common/src/main/java/com/hchyun/common/filter/XssFilter.java b/hchyun/hchyun-common/src/main/java/com/hchyun/common/filter/XssFilter.java index 7abaa80..922305e 100644 --- a/hchyun/hchyun-common/src/main/java/com/hchyun/common/filter/XssFilter.java +++ b/hchyun/hchyun-common/src/main/java/com/hchyun/common/filter/XssFilter.java @@ -13,15 +13,15 @@ import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; + import com.hchyun.common.utils.StringUtils; /** * 防止XSS攻击的过滤器 - * + * * @author hchyun */ -public class XssFilter implements Filter -{ +public class XssFilter implements Filter { /** * 排除链接 */ @@ -33,32 +33,26 @@ public class XssFilter implements Filter public boolean enabled = false; @Override - public void init(FilterConfig filterConfig) throws ServletException - { + public void init(FilterConfig filterConfig) throws ServletException { String tempExcludes = filterConfig.getInitParameter("excludes"); String tempEnabled = filterConfig.getInitParameter("enabled"); - if (StringUtils.isNotEmpty(tempExcludes)) - { + if (StringUtils.isNotEmpty(tempExcludes)) { String[] url = tempExcludes.split(","); - for (int i = 0; url != null && i < url.length; i++) - { + for (int i = 0; url != null && i < url.length; i++) { excludes.add(url[i]); } } - if (StringUtils.isNotEmpty(tempEnabled)) - { + if (StringUtils.isNotEmpty(tempEnabled)) { enabled = Boolean.valueOf(tempEnabled); } } @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) - throws IOException, ServletException - { + throws IOException, ServletException { HttpServletRequest req = (HttpServletRequest) request; HttpServletResponse resp = (HttpServletResponse) response; - if (handleExcludeURL(req, resp)) - { + if (handleExcludeURL(req, resp)) { chain.doFilter(request, response); return; } @@ -66,23 +60,18 @@ public class XssFilter implements Filter chain.doFilter(xssRequest, response); } - private boolean handleExcludeURL(HttpServletRequest request, HttpServletResponse response) - { - if (!enabled) - { + private boolean handleExcludeURL(HttpServletRequest request, HttpServletResponse response) { + if (!enabled) { return true; } - if (excludes == null || excludes.isEmpty()) - { + if (excludes == null || excludes.isEmpty()) { return false; } String url = request.getServletPath(); - for (String pattern : excludes) - { + for (String pattern : excludes) { Pattern p = Pattern.compile("^" + pattern); Matcher m = p.matcher(url); - if (m.find()) - { + if (m.find()) { return true; } } @@ -90,8 +79,7 @@ public class XssFilter implements Filter } @Override - public void destroy() - { + public void destroy() { } } \ No newline at end of file diff --git a/hchyun/hchyun-common/src/main/java/com/hchyun/common/filter/XssHttpServletRequestWrapper.java b/hchyun/hchyun-common/src/main/java/com/hchyun/common/filter/XssHttpServletRequestWrapper.java index 140fe64..f205af7 100644 --- a/hchyun/hchyun-common/src/main/java/com/hchyun/common/filter/XssHttpServletRequestWrapper.java +++ b/hchyun/hchyun-common/src/main/java/com/hchyun/common/filter/XssHttpServletRequestWrapper.java @@ -6,6 +6,7 @@ import javax.servlet.ReadListener; import javax.servlet.ServletInputStream; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequestWrapper; + import org.apache.commons.io.IOUtils; import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; @@ -14,29 +15,24 @@ import com.hchyun.common.utils.html.EscapeUtil; /** * XSS过滤处理 - * + * * @author hchyun */ -public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper -{ +public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper { /** * @param request */ - public XssHttpServletRequestWrapper(HttpServletRequest request) - { + public XssHttpServletRequestWrapper(HttpServletRequest request) { super(request); } @Override - public String[] getParameterValues(String name) - { + public String[] getParameterValues(String name) { String[] values = super.getParameterValues(name); - if (values != null) - { + if (values != null) { int length = values.length; String[] escapseValues = new String[length]; - for (int i = 0; i < length; i++) - { + for (int i = 0; i < length; i++) { // 防xss攻击和过滤前后空格 escapseValues[i] = EscapeUtil.clean(values[i]).trim(); } @@ -46,46 +42,38 @@ public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper } @Override - public ServletInputStream getInputStream() throws IOException - { + public ServletInputStream getInputStream() throws IOException { // 非json类型,直接返回 - if (!isJsonRequest()) - { + if (!isJsonRequest()) { return super.getInputStream(); } // 为空,直接返回 String json = IOUtils.toString(super.getInputStream(), "utf-8"); - if (StringUtils.isEmpty(json)) - { + if (StringUtils.isEmpty(json)) { return super.getInputStream(); } // xss过滤 json = EscapeUtil.clean(json).trim(); final ByteArrayInputStream bis = new ByteArrayInputStream(json.getBytes("utf-8")); - return new ServletInputStream() - { + return new ServletInputStream() { @Override - public boolean isFinished() - { + public boolean isFinished() { return true; } @Override - public boolean isReady() - { + public boolean isReady() { return true; } @Override - public void setReadListener(ReadListener readListener) - { + public void setReadListener(ReadListener readListener) { } @Override - public int read() throws IOException - { + public int read() throws IOException { return bis.read(); } }; @@ -93,11 +81,10 @@ public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper /** * 是否是Json请求 - * + * * @param request */ - public boolean isJsonRequest() - { + public boolean isJsonRequest() { String header = super.getHeader(HttpHeaders.CONTENT_TYPE); return MediaType.APPLICATION_JSON_VALUE.equalsIgnoreCase(header) || MediaType.APPLICATION_JSON_UTF8_VALUE.equalsIgnoreCase(header); diff --git a/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/Arith.java b/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/Arith.java index eb8e53a..c098352 100644 --- a/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/Arith.java +++ b/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/Arith.java @@ -5,28 +5,30 @@ import java.math.RoundingMode; /** * 精确的浮点数运算 - * + * * @author hchyun */ -public class Arith -{ +public class Arith { - /** 默认除法运算精度 */ + /** + * 默认除法运算精度 + */ private static final int DEF_DIV_SCALE = 10; - /** 这个类不能实例化 */ - private Arith() - { + /** + * 这个类不能实例化 + */ + private Arith() { } /** * 提供精确的加法运算。 + * * @param v1 被加数 * @param v2 加数 * @return 两个参数的和 */ - public static double add(double v1, double v2) - { + public static double add(double v1, double v2) { BigDecimal b1 = new BigDecimal(Double.toString(v1)); BigDecimal b2 = new BigDecimal(Double.toString(v2)); return b1.add(b2).doubleValue(); @@ -34,12 +36,12 @@ public class Arith /** * 提供精确的减法运算。 + * * @param v1 被减数 * @param v2 减数 * @return 两个参数的差 */ - public static double sub(double v1, double v2) - { + public static double sub(double v1, double v2) { BigDecimal b1 = new BigDecimal(Double.toString(v1)); BigDecimal b2 = new BigDecimal(Double.toString(v2)); return b1.subtract(b2).doubleValue(); @@ -47,12 +49,12 @@ public class Arith /** * 提供精确的乘法运算。 + * * @param v1 被乘数 * @param v2 乘数 * @return 两个参数的积 */ - public static double mul(double v1, double v2) - { + public static double mul(double v1, double v2) { BigDecimal b1 = new BigDecimal(Double.toString(v1)); BigDecimal b2 = new BigDecimal(Double.toString(v2)); return b1.multiply(b2).doubleValue(); @@ -61,34 +63,32 @@ public class Arith /** * 提供(相对)精确的除法运算,当发生除不尽的情况时,精确到 * 小数点以后10位,以后的数字四舍五入。 + * * @param v1 被除数 * @param v2 除数 * @return 两个参数的商 */ - public static double div(double v1, double v2) - { + public static double div(double v1, double v2) { return div(v1, v2, DEF_DIV_SCALE); } /** * 提供(相对)精确的除法运算。当发生除不尽的情况时,由scale参数指 * 定精度,以后的数字四舍五入。 - * @param v1 被除数 - * @param v2 除数 + * + * @param v1 被除数 + * @param v2 除数 * @param scale 表示表示需要精确到小数点以后几位。 * @return 两个参数的商 */ - public static double div(double v1, double v2, int scale) - { - if (scale < 0) - { + public static double div(double v1, double v2, int scale) { + if (scale < 0) { throw new IllegalArgumentException( "The scale must be a positive integer or zero"); } BigDecimal b1 = new BigDecimal(Double.toString(v1)); BigDecimal b2 = new BigDecimal(Double.toString(v2)); - if (b1.compareTo(BigDecimal.ZERO) == 0) - { + if (b1.compareTo(BigDecimal.ZERO) == 0) { return BigDecimal.ZERO.doubleValue(); } return b1.divide(b2, scale, RoundingMode.HALF_UP).doubleValue(); @@ -96,14 +96,13 @@ public class Arith /** * 提供精确的小数位四舍五入处理。 - * @param v 需要四舍五入的数字 + * + * @param v 需要四舍五入的数字 * @param scale 小数点后保留几位 * @return 四舍五入后的结果 */ - public static double round(double v, int scale) - { - if (scale < 0) - { + public static double round(double v, int scale) { + if (scale < 0) { throw new IllegalArgumentException( "The scale must be a positive integer or zero"); } diff --git a/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/DateUtils.java b/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/DateUtils.java index e386c1a..7ea9d39 100644 --- a/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/DateUtils.java +++ b/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/DateUtils.java @@ -24,9 +24,9 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils { public static String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss"; private static String[] parsePatterns = { - "yyyy-MM-dd" , "yyyy-MM-dd HH:mm:ss" , "yyyy-MM-dd HH:mm" , "yyyy-MM" , - "yyyy/MM/dd" , "yyyy/MM/dd HH:mm:ss" , "yyyy/MM/dd HH:mm" , "yyyy/MM" , - "yyyy.MM.dd" , "yyyy.MM.dd HH:mm:ss" , "yyyy.MM.dd HH:mm" , "yyyy.MM"}; + "yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "yyyy-MM", + "yyyy/MM/dd", "yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm", "yyyy/MM", + "yyyy.MM.dd", "yyyy.MM.dd HH:mm:ss", "yyyy.MM.dd HH:mm", "yyyy.MM"}; /** * 获取当前Date型日期 @@ -45,7 +45,8 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils { public static String getDate() { return dateTimeNow(YYYY_MM_DD); } - public static String getDate(String time){ + + public static String getDate(String time) { try { return new SimpleDateFormat(YYYY_MM_DD).parse(time).toString(); } catch (ParseException e) { diff --git a/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/DictUtils.java b/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/DictUtils.java index 2f9b863..3931db9 100644 --- a/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/DictUtils.java +++ b/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/DictUtils.java @@ -2,6 +2,7 @@ package com.hchyun.common.utils; import java.util.Collection; import java.util.List; + import com.hchyun.common.constant.Constants; import com.hchyun.common.core.entity.entity.SysDictData; import com.hchyun.common.core.redis.RedisCache; @@ -9,11 +10,10 @@ import com.hchyun.common.utils.spring.SpringUtils; /** * 字典工具类 - * + * * @author hchyun */ -public class DictUtils -{ +public class DictUtils { /** * 分隔符 */ @@ -21,26 +21,23 @@ public class DictUtils /** * 设置字典缓存 - * - * @param key 参数键 + * + * @param key 参数键 * @param dictDatas 字典数据列表 */ - public static void setDictCache(String key, List dictDatas) - { + public static void setDictCache(String key, List dictDatas) { SpringUtils.getBean(RedisCache.class).setCacheObject(getCacheKey(key), dictDatas); } /** * 获取字典缓存 - * + * * @param key 参数键 * @return dictDatas 字典数据列表 */ - public static List getDictCache(String key) - { + public static List getDictCache(String key) { Object cacheObj = SpringUtils.getBean(RedisCache.class).getCacheObject(getCacheKey(key)); - if (StringUtils.isNotNull(cacheObj)) - { + if (StringUtils.isNotNull(cacheObj)) { List dictDatas = StringUtils.cast(cacheObj); return dictDatas; } @@ -49,61 +46,50 @@ public class DictUtils /** * 根据字典类型和字典值获取字典标签 - * - * @param dictType 字典类型 + * + * @param dictType 字典类型 * @param dictValue 字典值 * @return 字典标签 */ - public static String getDictLabel(String dictType, String dictValue) - { + public static String getDictLabel(String dictType, String dictValue) { return getDictLabel(dictType, dictValue, SEPARATOR); } /** * 根据字典类型和字典标签获取字典值 - * - * @param dictType 字典类型 + * + * @param dictType 字典类型 * @param dictLabel 字典标签 * @return 字典值 */ - public static String getDictValue(String dictType, String dictLabel) - { + public static String getDictValue(String dictType, String dictLabel) { return getDictValue(dictType, dictLabel, SEPARATOR); } /** * 根据字典类型和字典值获取字典标签 - * - * @param dictType 字典类型 + * + * @param dictType 字典类型 * @param dictValue 字典值 * @param separator 分隔符 * @return 字典标签 */ - public static String getDictLabel(String dictType, String dictValue, String separator) - { + public static String getDictLabel(String dictType, String dictValue, String separator) { StringBuilder propertyString = new StringBuilder(); List datas = getDictCache(dictType); - if (StringUtils.containsAny(separator, dictValue) && StringUtils.isNotEmpty(datas)) - { - for (SysDictData dict : datas) - { - for (String value : dictValue.split(separator)) - { - if (value.equals(dict.getDictValue())) - { + if (StringUtils.containsAny(separator, dictValue) && StringUtils.isNotEmpty(datas)) { + for (SysDictData dict : datas) { + for (String value : dictValue.split(separator)) { + if (value.equals(dict.getDictValue())) { propertyString.append(dict.getDictLabel() + separator); break; } } } - } - else - { - for (SysDictData dict : datas) - { - if (dictValue.equals(dict.getDictValue())) - { + } else { + for (SysDictData dict : datas) { + if (dictValue.equals(dict.getDictValue())) { return dict.getDictLabel(); } } @@ -113,37 +99,28 @@ public class DictUtils /** * 根据字典类型和字典标签获取字典值 - * - * @param dictType 字典类型 + * + * @param dictType 字典类型 * @param dictLabel 字典标签 * @param separator 分隔符 * @return 字典值 */ - public static String getDictValue(String dictType, String dictLabel, String separator) - { + public static String getDictValue(String dictType, String dictLabel, String separator) { StringBuilder propertyString = new StringBuilder(); List datas = getDictCache(dictType); - if (StringUtils.containsAny(separator, dictLabel) && StringUtils.isNotEmpty(datas)) - { - for (SysDictData dict : datas) - { - for (String label : dictLabel.split(separator)) - { - if (label.equals(dict.getDictLabel())) - { + if (StringUtils.containsAny(separator, dictLabel) && StringUtils.isNotEmpty(datas)) { + for (SysDictData dict : datas) { + for (String label : dictLabel.split(separator)) { + if (label.equals(dict.getDictLabel())) { propertyString.append(dict.getDictValue() + separator); break; } } } - } - else - { - for (SysDictData dict : datas) - { - if (dictLabel.equals(dict.getDictLabel())) - { + } else { + for (SysDictData dict : datas) { + if (dictLabel.equals(dict.getDictLabel())) { return dict.getDictValue(); } } @@ -154,20 +131,18 @@ public class DictUtils /** * 清空字典缓存 */ - public static void clearDictCache() - { + public static void clearDictCache() { Collection keys = SpringUtils.getBean(RedisCache.class).keys(Constants.SYS_DICT_KEY + "*"); SpringUtils.getBean(RedisCache.class).deleteObject(keys); } /** * 设置cache key - * + * * @param configKey 参数键 * @return 缓存键key */ - public static String getCacheKey(String configKey) - { + public static String getCacheKey(String configKey) { return Constants.SYS_DICT_KEY + configKey; } } diff --git a/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/ExceptionUtil.java b/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/ExceptionUtil.java index 6723b2a..08902dd 100644 --- a/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/ExceptionUtil.java +++ b/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/ExceptionUtil.java @@ -2,6 +2,7 @@ package com.hchyun.common.utils; import java.io.PrintWriter; import java.io.StringWriter; + import org.apache.commons.lang3.exception.ExceptionUtils; /** @@ -9,30 +10,25 @@ import org.apache.commons.lang3.exception.ExceptionUtils; * * @author hchyun */ -public class ExceptionUtil -{ +public class ExceptionUtil { /** * 获取exception的详细错误信息。 */ - public static String getExceptionMessage(Throwable e) - { + public static String getExceptionMessage(Throwable e) { StringWriter sw = new StringWriter(); e.printStackTrace(new PrintWriter(sw, true)); String str = sw.toString(); return str; } - public static String getRootErrorMseeage(Exception e) - { + public static String getRootErrorMseeage(Exception e) { Throwable root = ExceptionUtils.getRootCause(e); root = (root == null ? e : root); - if (root == null) - { + if (root == null) { return ""; } String msg = root.getMessage(); - if (msg == null) - { + if (msg == null) { return "null"; } return StringUtils.defaultString(msg); diff --git a/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/LogUtils.java b/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/LogUtils.java index 1e3f7d3..3d86a5a 100644 --- a/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/LogUtils.java +++ b/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/LogUtils.java @@ -2,15 +2,12 @@ package com.hchyun.common.utils; /** * 处理并记录日志文件 - * + * * @author hchyun */ -public class LogUtils -{ - public static String getBlock(Object msg) - { - if (msg == null) - { +public class LogUtils { + public static String getBlock(Object msg) { + if (msg == null) { msg = ""; } return "[" + msg.toString() + "]"; diff --git a/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/MessageUtils.java b/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/MessageUtils.java index e460633..d017af9 100644 --- a/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/MessageUtils.java +++ b/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/MessageUtils.java @@ -6,11 +6,10 @@ import com.hchyun.common.utils.spring.SpringUtils; /** * 获取i18n资源文件 - * + * * @author hchyun */ -public class MessageUtils -{ +public class MessageUtils { /** * 根据消息键和参数 获取消息 委托给spring messageSource * @@ -18,8 +17,7 @@ public class MessageUtils * @param args 参数 * @return 获取国际化翻译值 */ - public static String message(String code, Object... args) - { + public static String message(String code, Object... args) { MessageSource messageSource = SpringUtils.getBean(MessageSource.class); return messageSource.getMessage(code, args, LocaleContextHolder.getLocale()); } diff --git a/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/ServerResult.java b/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/ServerResult.java index 4bfee68..09563a0 100644 --- a/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/ServerResult.java +++ b/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/ServerResult.java @@ -17,20 +17,20 @@ public class ServerResult { public ServerResult() { } - public ServerResult( boolean start, T data, Integer count) { + public ServerResult(boolean start, T data, Integer count) { this.data = data; this.count = count; this.start = start; this.msg = "操作成功"; } - public ServerResult(boolean start,T data) { + public ServerResult(boolean start, T data) { this.data = data; this.start = start; this.msg = "操作成功"; } - public ServerResult(boolean start,T data,String sheetName) { + public ServerResult(boolean start, T data, String sheetName) { this.data = data; this.start = start; this.sheetName = sheetName; @@ -50,7 +50,7 @@ public class ServerResult { this.sheetName = sheetName; } - public ServerResult(boolean start){ + public ServerResult(boolean start) { this.start = start; } diff --git a/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/ServletUtils.java b/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/ServletUtils.java index ed55e64..eaeaba4 100644 --- a/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/ServletUtils.java +++ b/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/ServletUtils.java @@ -4,6 +4,7 @@ import java.io.IOException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; + import org.springframework.web.context.request.RequestAttributes; import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletRequestAttributes; @@ -11,91 +12,78 @@ import com.hchyun.common.core.text.Convert; /** * 客户端工具类 - * + * * @author hchyun */ -public class ServletUtils -{ +public class ServletUtils { /** * 获取String参数 */ - public static String getParameter(String name) - { + public static String getParameter(String name) { return getRequest().getParameter(name); } /** * 获取String参数 */ - public static String getParameter(String name, String defaultValue) - { + public static String getParameter(String name, String defaultValue) { return Convert.toStr(getRequest().getParameter(name), defaultValue); } /** * 获取Integer参数 */ - public static Integer getParameterToInt(String name) - { + public static Integer getParameterToInt(String name) { return Convert.toInt(getRequest().getParameter(name)); } /** * 获取Integer参数 */ - public static Integer getParameterToInt(String name, Integer defaultValue) - { + public static Integer getParameterToInt(String name, Integer defaultValue) { return Convert.toInt(getRequest().getParameter(name), defaultValue); } /** * 获取request */ - public static HttpServletRequest getRequest() - { + public static HttpServletRequest getRequest() { return getRequestAttributes().getRequest(); } /** * 获取response */ - public static HttpServletResponse getResponse() - { + public static HttpServletResponse getResponse() { return getRequestAttributes().getResponse(); } /** * 获取session */ - public static HttpSession getSession() - { + public static HttpSession getSession() { return getRequest().getSession(); } - public static ServletRequestAttributes getRequestAttributes() - { + public static ServletRequestAttributes getRequestAttributes() { RequestAttributes attributes = RequestContextHolder.getRequestAttributes(); return (ServletRequestAttributes) attributes; } /** * 将字符串渲染到客户端 - * + * * @param response 渲染对象 - * @param string 待渲染的字符串 + * @param string 待渲染的字符串 * @return null */ - public static String renderString(HttpServletResponse response, String string) - { - try - { + public static String renderString(HttpServletResponse response, String string) { + try { response.setStatus(200); response.setContentType("application/json"); response.setCharacterEncoding("utf-8"); response.getWriter().print(string); - } - catch (IOException e) - { + } catch (IOException e) { e.printStackTrace(); } return null; @@ -103,32 +91,27 @@ public class ServletUtils /** * 是否是Ajax异步请求 - * + * * @param request */ - public static boolean isAjaxRequest(HttpServletRequest request) - { + public static boolean isAjaxRequest(HttpServletRequest request) { String accept = request.getHeader("accept"); - if (accept != null && accept.indexOf("application/json") != -1) - { + if (accept != null && accept.indexOf("application/json") != -1) { return true; } String xRequestedWith = request.getHeader("X-Requested-With"); - if (xRequestedWith != null && xRequestedWith.indexOf("XMLHttpRequest") != -1) - { + if (xRequestedWith != null && xRequestedWith.indexOf("XMLHttpRequest") != -1) { return true; } String uri = request.getRequestURI(); - if (StringUtils.inStringIgnoreCase(uri, ".json", ".xml")) - { + if (StringUtils.inStringIgnoreCase(uri, ".json", ".xml")) { return true; } String ajax = request.getParameter("__ajax"); - if (StringUtils.inStringIgnoreCase(ajax, "json", "xml")) - { + if (StringUtils.inStringIgnoreCase(ajax, "json", "xml")) { return true; } return false; diff --git a/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/StringUtils.java b/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/StringUtils.java index aff43d8..ef02502 100644 --- a/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/StringUtils.java +++ b/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/StringUtils.java @@ -394,14 +394,15 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils { /** * 分割sql字符串 + * * @param str * @return */ - public static String sqlFormat(String str){ + public static String sqlFormat(String str) { String[] strList = str.split("_"); String sqlStr = ""; - for (String s:strList) { - sqlStr +=s.substring(0,1); + for (String s : strList) { + sqlStr += s.substring(0, 1); } return sqlStr; } diff --git a/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/Threads.java b/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/Threads.java index e978b2b..eeb8ffe 100644 --- a/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/Threads.java +++ b/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/Threads.java @@ -5,29 +5,25 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * 线程相关工具类. - * + * * @author hchyun */ -public class Threads -{ +public class Threads { private static final Logger logger = LoggerFactory.getLogger(Threads.class); /** * sleep等待,单位为毫秒 */ - public static void sleep(long milliseconds) - { - try - { + public static void sleep(long milliseconds) { + try { Thread.sleep(milliseconds); - } - catch (InterruptedException e) - { + } catch (InterruptedException e) { return; } } @@ -39,24 +35,17 @@ public class Threads * 如果仍人超時,則強制退出. * 另对在shutdown时线程本身被调用中断做了处理. */ - public static void shutdownAndAwaitTermination(ExecutorService pool) - { - if (pool != null && !pool.isShutdown()) - { + public static void shutdownAndAwaitTermination(ExecutorService pool) { + if (pool != null && !pool.isShutdown()) { pool.shutdown(); - try - { - if (!pool.awaitTermination(120, TimeUnit.SECONDS)) - { + try { + if (!pool.awaitTermination(120, TimeUnit.SECONDS)) { pool.shutdownNow(); - if (!pool.awaitTermination(120, TimeUnit.SECONDS)) - { + if (!pool.awaitTermination(120, TimeUnit.SECONDS)) { logger.info("Pool did not terminate"); } } - } - catch (InterruptedException ie) - { + } catch (InterruptedException ie) { pool.shutdownNow(); Thread.currentThread().interrupt(); } @@ -66,33 +55,22 @@ public class Threads /** * 打印线程异常信息 */ - public static void printException(Runnable r, Throwable t) - { - if (t == null && r instanceof Future) - { - try - { + public static void printException(Runnable r, Throwable t) { + if (t == null && r instanceof Future) { + try { Future future = (Future) r; - if (future.isDone()) - { + if (future.isDone()) { future.get(); } - } - catch (CancellationException ce) - { + } catch (CancellationException ce) { t = ce; - } - catch (ExecutionException ee) - { + } catch (ExecutionException ee) { t = ee.getCause(); - } - catch (InterruptedException ie) - { + } catch (InterruptedException ie) { Thread.currentThread().interrupt(); } } - if (t != null) - { + if (t != null) { logger.error(t.getMessage(), t); } } diff --git a/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/VerifyCodeUtils.java b/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/VerifyCodeUtils.java index 5a9fa2a..03c0036 100644 --- a/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/VerifyCodeUtils.java +++ b/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/VerifyCodeUtils.java @@ -16,11 +16,10 @@ import javax.imageio.ImageIO; /** * 验证码工具类 - * + * * @author hchyun */ -public class VerifyCodeUtils -{ +public class VerifyCodeUtils { // 使用到Algerian字体,系统里没有的话需要安装字体,字体只显示大写,去掉了1,0,i,o几个容易混淆的字符 public static final String VERIFY_CODES = "123456789ABCDEFGHJKLMNPQRSTUVWXYZ"; @@ -28,33 +27,29 @@ public class VerifyCodeUtils /** * 使用系统默认字符源生成验证码 - * + * * @param verifySize 验证码长度 * @return */ - public static String generateVerifyCode(int verifySize) - { + public static String generateVerifyCode(int verifySize) { return generateVerifyCode(verifySize, VERIFY_CODES); } /** * 使用指定源生成验证码 - * + * * @param verifySize 验证码长度 - * @param sources 验证码字符源 + * @param sources 验证码字符源 * @return */ - public static String generateVerifyCode(int verifySize, String sources) - { - if (sources == null || sources.length() == 0) - { + public static String generateVerifyCode(int verifySize, String sources) { + if (sources == null || sources.length() == 0) { sources = VERIFY_CODES; } int codesLen = sources.length(); Random rand = new Random(System.currentTimeMillis()); StringBuilder verifyCode = new StringBuilder(verifySize); - for (int i = 0; i < verifySize; i++) - { + for (int i = 0; i < verifySize; i++) { verifyCode.append(sources.charAt(rand.nextInt(codesLen - 1))); } return verifyCode.toString(); @@ -62,26 +57,24 @@ public class VerifyCodeUtils /** * 输出指定验证码图片流 - * + * * @param w * @param h * @param os * @param code * @throws IOException */ - public static void outputImage(int w, int h, OutputStream os, String code) throws IOException - { + public static void outputImage(int w, int h, OutputStream os, String code) throws IOException { int verifySize = code.length(); BufferedImage image = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); Random rand = new Random(); Graphics2D g2 = image.createGraphics(); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); Color[] colors = new Color[5]; - Color[] colorSpaces = new Color[] { Color.WHITE, Color.CYAN, Color.GRAY, Color.LIGHT_GRAY, Color.MAGENTA, - Color.ORANGE, Color.PINK, Color.YELLOW }; + Color[] colorSpaces = new Color[]{Color.WHITE, Color.CYAN, Color.GRAY, Color.LIGHT_GRAY, Color.MAGENTA, + Color.ORANGE, Color.PINK, Color.YELLOW}; float[] fractions = new float[colors.length]; - for (int i = 0; i < colors.length; i++) - { + for (int i = 0; i < colors.length; i++) { colors[i] = colorSpaces[rand.nextInt(colorSpaces.length)]; fractions[i] = rand.nextFloat(); } @@ -97,8 +90,7 @@ public class VerifyCodeUtils // 绘制干扰线 Random random = new Random(); g2.setColor(getRandColor(160, 200));// 设置线条的颜色 - for (int i = 0; i < 20; i++) - { + for (int i = 0; i < 20; i++) { int x = random.nextInt(w - 1); int y = random.nextInt(h - 1); int xl = random.nextInt(6) + 1; @@ -109,8 +101,7 @@ public class VerifyCodeUtils // 添加噪点 float yawpRate = 0.05f;// 噪声率 int area = (int) (yawpRate * w * h); - for (int i = 0; i < area; i++) - { + for (int i = 0; i < area; i++) { int x = random.nextInt(w); int y = random.nextInt(h); int rgb = getRandomIntColor(); @@ -124,8 +115,7 @@ public class VerifyCodeUtils Font font = new Font("Algerian", Font.ITALIC, fontSize); g2.setFont(font); char[] chars = code.toCharArray(); - for (int i = 0; i < verifySize; i++) - { + for (int i = 0; i < verifySize; i++) { AffineTransform affine = new AffineTransform(); affine.setToRotation(Math.PI / 4 * rand.nextDouble() * (rand.nextBoolean() ? 1 : -1), (w / verifySize) * i + fontSize / 2, h / 2); @@ -137,8 +127,7 @@ public class VerifyCodeUtils ImageIO.write(image, "jpg", os); } - private static Color getRandColor(int fc, int bc) - { + private static Color getRandColor(int fc, int bc) { if (fc > 255) { fc = 255; } @@ -151,36 +140,30 @@ public class VerifyCodeUtils return new Color(r, g, b); } - private static int getRandomIntColor() - { + private static int getRandomIntColor() { int[] rgb = getRandomRgb(); int color = 0; - for (int c : rgb) - { + for (int c : rgb) { color = color << 8; color = color | c; } return color; } - private static int[] getRandomRgb() - { + private static int[] getRandomRgb() { int[] rgb = new int[3]; - for (int i = 0; i < 3; i++) - { + for (int i = 0; i < 3; i++) { rgb[i] = random.nextInt(255); } return rgb; } - private static void shear(Graphics g, int w1, int h1, Color color) - { + private static void shear(Graphics g, int w1, int h1, Color color) { shearX(g, w1, h1, color); shearY(g, w1, h1, color); } - private static void shearX(Graphics g, int w1, int h1, Color color) - { + private static void shearX(Graphics g, int w1, int h1, Color color) { int period = random.nextInt(2); @@ -188,13 +171,11 @@ public class VerifyCodeUtils int frames = 1; int phase = random.nextInt(2); - for (int i = 0; i < h1; i++) - { + for (int i = 0; i < h1; i++) { double d = (double) (period >> 1) * Math.sin((double) i / (double) period + (6.2831853071795862D * (double) phase) / (double) frames); g.copyArea(0, i, w1, 1, (int) d, 0); - if (borderGap) - { + if (borderGap) { g.setColor(color); g.drawLine((int) d, i, 0, i); g.drawLine((int) d + w1, i, w1, i); @@ -203,21 +184,18 @@ public class VerifyCodeUtils } - private static void shearY(Graphics g, int w1, int h1, Color color) - { + private static void shearY(Graphics g, int w1, int h1, Color color) { int period = random.nextInt(40) + 10; // 50; boolean borderGap = true; int frames = 20; int phase = 7; - for (int i = 0; i < w1; i++) - { + for (int i = 0; i < w1; i++) { double d = (double) (period >> 1) * Math.sin((double) i / (double) period + (6.2831853071795862D * (double) phase) / (double) frames); g.copyArea(i, 0, 1, h1, 0, (int) d); - if (borderGap) - { + if (borderGap) { g.setColor(color); g.drawLine(i, (int) d, i, 0); g.drawLine(i, (int) d + h1, i, h1); diff --git a/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/bean/BeanUtils.java b/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/bean/BeanUtils.java index 1ad46e5..22229d2 100644 --- a/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/bean/BeanUtils.java +++ b/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/bean/BeanUtils.java @@ -8,46 +8,46 @@ import java.util.regex.Pattern; /** * Bean 工具类 - * + * * @author hchyun */ -public class BeanUtils extends org.springframework.beans.BeanUtils -{ - /** Bean方法名中属性名开始的下标 */ +public class BeanUtils extends org.springframework.beans.BeanUtils { + /** + * Bean方法名中属性名开始的下标 + */ private static final int BEAN_METHOD_PROP_INDEX = 3; - /** * 匹配getter方法的正则表达式 */ + /** + * 匹配getter方法的正则表达式 + */ private static final Pattern GET_PATTERN = Pattern.compile("get(\\p{javaUpperCase}\\w*)"); - /** * 匹配setter方法的正则表达式 */ + /** + * 匹配setter方法的正则表达式 + */ private static final Pattern SET_PATTERN = Pattern.compile("set(\\p{javaUpperCase}\\w*)"); /** * Bean属性复制工具方法。 - * + * * @param dest 目标对象 - * @param src 源对象 + * @param src 源对象 */ - public static void copyBeanProp(Object dest, Object src) - { - try - { + public static void copyBeanProp(Object dest, Object src) { + try { copyProperties(src, dest); - } - catch (Exception e) - { + } catch (Exception e) { e.printStackTrace(); } } /** * 获取对象的setter方法。 - * + * * @param obj 对象 * @return 对象的setter方法列表 */ - public static List getSetterMethods(Object obj) - { + public static List getSetterMethods(Object obj) { // setter方法列表 List setterMethods = new ArrayList(); @@ -56,11 +56,9 @@ public class BeanUtils extends org.springframework.beans.BeanUtils // 查找setter方法 - for (Method method : methods) - { + for (Method method : methods) { Matcher m = SET_PATTERN.matcher(method.getName()); - if (m.matches() && (method.getParameterTypes().length == 1)) - { + if (m.matches() && (method.getParameterTypes().length == 1)) { setterMethods.add(method); } } @@ -70,23 +68,20 @@ public class BeanUtils extends org.springframework.beans.BeanUtils /** * 获取对象的getter方法。 - * + * * @param obj 对象 * @return 对象的getter方法列表 */ - public static List getGetterMethods(Object obj) - { + public static List getGetterMethods(Object obj) { // getter方法列表 List getterMethods = new ArrayList(); // 获取所有方法 Method[] methods = obj.getClass().getMethods(); // 查找getter方法 - for (Method method : methods) - { + for (Method method : methods) { Matcher m = GET_PATTERN.matcher(method.getName()); - if (m.matches() && (method.getParameterTypes().length == 0)) - { + if (m.matches() && (method.getParameterTypes().length == 0)) { getterMethods.add(method); } } @@ -97,14 +92,13 @@ public class BeanUtils extends org.springframework.beans.BeanUtils /** * 检查Bean方法名中的属性名是否相等。
* 如getName()和setName()属性名一样,getName()和setAge()属性名不一样。 - * + * * @param m1 方法名1 * @param m2 方法名2 * @return 属性名一样返回true,否则返回false */ - public static boolean isMethodPropEquals(String m1, String m2) - { + public static boolean isMethodPropEquals(String m1, String m2) { return m1.substring(BEAN_METHOD_PROP_INDEX).equals(m2.substring(BEAN_METHOD_PROP_INDEX)); } } diff --git a/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/file/FileUploadUtils.java b/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/file/FileUploadUtils.java index 39aeef7..011a391 100644 --- a/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/file/FileUploadUtils.java +++ b/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/file/FileUploadUtils.java @@ -129,7 +129,6 @@ public class FileUploadUtils { } /** - * * @param uploadDir * @param fileName * @return diff --git a/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/file/MimeTypeUtils.java b/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/file/MimeTypeUtils.java index deb20ef..3c403b8 100644 --- a/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/file/MimeTypeUtils.java +++ b/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/file/MimeTypeUtils.java @@ -2,11 +2,10 @@ package com.hchyun.common.utils.file; /** * 媒体类型工具类 - * + * * @author hchyun */ -public class MimeTypeUtils -{ +public class MimeTypeUtils { public static final String IMAGE_PNG = "image/png"; public static final String IMAGE_JPG = "image/jpg"; @@ -16,13 +15,13 @@ public class MimeTypeUtils public static final String IMAGE_BMP = "image/bmp"; public static final String IMAGE_GIF = "image/gif"; - - public static final String[] IMAGE_EXTENSION = { "bmp", "gif", "jpg", "jpeg", "png" }; - public static final String[] FLASH_EXTENSION = { "swf", "flv" }; + public static final String[] IMAGE_EXTENSION = {"bmp", "gif", "jpg", "jpeg", "png"}; - public static final String[] MEDIA_EXTENSION = { "swf", "flv", "mp3", "wav", "wma", "wmv", "mid", "avi", "mpg", - "asf", "rm", "rmvb" }; + public static final String[] FLASH_EXTENSION = {"swf", "flv"}; + + public static final String[] MEDIA_EXTENSION = {"swf", "flv", "mp3", "wav", "wma", "wmv", "mid", "avi", "mpg", + "asf", "rm", "rmvb"}; public static final String[] DEFAULT_ALLOWED_EXTENSION = { // 图片 @@ -32,12 +31,10 @@ public class MimeTypeUtils // 压缩文件 "rar", "zip", "gz", "bz2", // pdf - "pdf" }; + "pdf"}; - public static String getExtension(String prefix) - { - switch (prefix) - { + public static String getExtension(String prefix) { + switch (prefix) { case IMAGE_PNG: return "png"; case IMAGE_JPG: diff --git a/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/html/EscapeUtil.java b/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/html/EscapeUtil.java index 43ff522..4e638b0 100644 --- a/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/html/EscapeUtil.java +++ b/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/html/EscapeUtil.java @@ -4,20 +4,17 @@ import com.hchyun.common.utils.StringUtils; /** * 转义和反转义工具类 - * + * * @author hchyun */ -public class EscapeUtil -{ +public class EscapeUtil { public static final String RE_HTML_MARK = "(<[^<]*?>)|(<[\\s]*?/[^<]*?>)|(<[^<]*?/[\\s]*?>)"; private static final char[][] TEXT = new char[64][]; - static - { - for (int i = 0; i < 64; i++) - { - TEXT[i] = new char[] { (char) i }; + static { + for (int i = 0; i < 64; i++) { + TEXT[i] = new char[]{(char) i}; } // special HTML characters @@ -30,61 +27,52 @@ public class EscapeUtil /** * 转义文本中的HTML字符为安全的字符 - * + * * @param text 被转义的文本 * @return 转义后的文本 */ - public static String escape(String text) - { + public static String escape(String text) { return encode(text); } /** * 还原被转义的HTML特殊字符 - * + * * @param content 包含转义符的HTML内容 * @return 转换后的字符串 */ - public static String unescape(String content) - { + public static String unescape(String content) { return decode(content); } /** * 清除所有HTML标签,但是不删除标签内的内容 - * + * * @param content 文本 * @return 清除标签后的文本 */ - public static String clean(String content) - { + public static String clean(String content) { return new HTMLFilter().filter(content); } /** * Escape编码 - * + * * @param text 被编码的文本 * @return 编码后的字符 */ - private static String encode(String text) - { + private static String encode(String text) { int len; - if ((text == null) || ((len = text.length()) == 0)) - { + if ((text == null) || ((len = text.length()) == 0)) { return StringUtils.EMPTY; } StringBuilder buffer = new StringBuilder(len + (len >> 2)); char c; - for (int i = 0; i < len; i++) - { + for (int i = 0; i < len; i++) { c = text.charAt(i); - if (c < 64) - { + if (c < 64) { buffer.append(TEXT[c]); - } - else - { + } else { buffer.append(c); } } @@ -93,47 +81,35 @@ public class EscapeUtil /** * Escape解码 - * + * * @param content 被转义的内容 * @return 解码后的字符串 */ - public static String decode(String content) - { - if (StringUtils.isEmpty(content)) - { + public static String decode(String content) { + if (StringUtils.isEmpty(content)) { return content; } StringBuilder tmp = new StringBuilder(content.length()); int lastPos = 0, pos = 0; char ch; - while (lastPos < content.length()) - { + while (lastPos < content.length()) { pos = content.indexOf("%", lastPos); - if (pos == lastPos) - { - if (content.charAt(pos + 1) == 'u') - { + if (pos == lastPos) { + if (content.charAt(pos + 1) == 'u') { ch = (char) Integer.parseInt(content.substring(pos + 2, pos + 6), 16); tmp.append(ch); lastPos = pos + 6; - } - else - { + } else { ch = (char) Integer.parseInt(content.substring(pos + 1, pos + 3), 16); tmp.append(ch); lastPos = pos + 3; } - } - else - { - if (pos == -1) - { + } else { + if (pos == -1) { tmp.append(content.substring(lastPos)); lastPos = content.length(); - } - else - { + } else { tmp.append(content.substring(lastPos, pos)); lastPos = pos; } @@ -142,8 +118,7 @@ public class EscapeUtil return tmp.toString(); } - public static void main(String[] args) - { + public static void main(String[] args) { String html = ""; // String html = "ipt>alert(\"XSS\")ipt>"; // String html = "<123"; diff --git a/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/html/HTMLFilter.java b/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/html/HTMLFilter.java index a42a290..0b7998f 100644 --- a/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/html/HTMLFilter.java +++ b/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/html/HTMLFilter.java @@ -15,8 +15,7 @@ import java.util.regex.Pattern; * * @author hchyun */ -public final class HTMLFilter -{ +public final class HTMLFilter { /** * regex flag union representing /si modifiers in php **/ @@ -100,8 +99,7 @@ public final class HTMLFilter /** * Default constructor. */ - public HTMLFilter() - { + public HTMLFilter() { vAllowed = new HashMap<>(); final ArrayList a_atts = new ArrayList<>(); @@ -122,13 +120,13 @@ public final class HTMLFilter vAllowed.put("i", no_atts); vAllowed.put("em", no_atts); - vSelfClosingTags = new String[] { "img" }; - vNeedClosingTags = new String[] { "a", "b", "strong", "i", "em" }; - vDisallowed = new String[] {}; - vAllowedProtocols = new String[] { "http", "mailto", "https" }; // no ftp. - vProtocolAtts = new String[] { "src", "href" }; - vRemoveBlanks = new String[] { "a", "b", "strong", "i", "em" }; - vAllowedEntities = new String[] { "amp", "gt", "lt", "quot" }; + vSelfClosingTags = new String[]{"img"}; + vNeedClosingTags = new String[]{"a", "b", "strong", "i", "em"}; + vDisallowed = new String[]{}; + vAllowedProtocols = new String[]{"http", "mailto", "https"}; // no ftp. + vProtocolAtts = new String[]{"src", "href"}; + vRemoveBlanks = new String[]{"a", "b", "strong", "i", "em"}; + vAllowedEntities = new String[]{"amp", "gt", "lt", "quot"}; stripComment = true; encodeQuotes = true; alwaysMakeTags = false; @@ -140,8 +138,7 @@ public final class HTMLFilter * @param conf map containing configuration. keys match field names. */ @SuppressWarnings("unchecked") - public HTMLFilter(final Map conf) - { + public HTMLFilter(final Map conf) { assert conf.containsKey("vAllowed") : "configuration requires vAllowed"; assert conf.containsKey("vSelfClosingTags") : "configuration requires vSelfClosingTags"; @@ -165,20 +162,17 @@ public final class HTMLFilter alwaysMakeTags = conf.containsKey("alwaysMakeTags") ? (Boolean) conf.get("alwaysMakeTags") : true; } - private void reset() - { + private void reset() { vTagCounts.clear(); } // --------------------------------------------------------------- // my versions of some PHP library functions - public static String chr(final int decimal) - { + public static String chr(final int decimal) { return String.valueOf((char) decimal); } - public static String htmlSpecialChars(final String s) - { + public static String htmlSpecialChars(final String s) { String result = s; result = regexReplace(P_AMP, "&", result); result = regexReplace(P_QUOTE, """, result); @@ -195,8 +189,7 @@ public final class HTMLFilter * @param input text (i.e. submitted by a user) than may contain html * @return "clean" version of input, with only valid, whitelisted html elements allowed */ - public String filter(final String input) - { + public String filter(final String input) { reset(); String s = input; @@ -213,22 +206,18 @@ public final class HTMLFilter return s; } - public boolean isAlwaysMakeTags() - { + public boolean isAlwaysMakeTags() { return alwaysMakeTags; } - public boolean isStripComments() - { + public boolean isStripComments() { return stripComment; } - private String escapeComments(final String s) - { + private String escapeComments(final String s) { final Matcher m = P_COMMENTS.matcher(s); final StringBuffer buf = new StringBuffer(); - if (m.find()) - { + if (m.find()) { final String match = m.group(1); // (.*?) m.appendReplacement(buf, Matcher.quoteReplacement("")); } @@ -237,10 +226,8 @@ public final class HTMLFilter return buf.toString(); } - private String balanceHTML(String s) - { - if (alwaysMakeTags) - { + private String balanceHTML(String s) { + if (alwaysMakeTags) { // // try and form html // @@ -249,9 +236,7 @@ public final class HTMLFilter s = regexReplace(P_BODY_TO_END, "<$1>", s); s = regexReplace(P_XML_CONTENT, "$1<$2", s); - } - else - { + } else { // // escape stray brackets // @@ -269,13 +254,11 @@ public final class HTMLFilter return s; } - private String checkTags(String s) - { + private String checkTags(String s) { Matcher m = P_TAGS.matcher(s); final StringBuffer buf = new StringBuffer(); - while (m.find()) - { + while (m.find()) { String replaceStr = m.group(1); replaceStr = processTag(replaceStr); m.appendReplacement(buf, Matcher.quoteReplacement(replaceStr)); @@ -285,10 +268,8 @@ public final class HTMLFilter // these get tallied in processTag // (remember to reset before subsequent calls to filter method) final StringBuilder sBuilder = new StringBuilder(buf.toString()); - for (String key : vTagCounts.keySet()) - { - for (int ii = 0; ii < vTagCounts.get(key); ii++) - { + for (String key : vTagCounts.keySet()) { + for (int ii = 0; ii < vTagCounts.get(key); ii++) { sBuilder.append(""); } } @@ -297,18 +278,14 @@ public final class HTMLFilter return s; } - private String processRemoveBlanks(final String s) - { + private String processRemoveBlanks(final String s) { String result = s; - for (String tag : vRemoveBlanks) - { - if (!P_REMOVE_PAIR_BLANKS.containsKey(tag)) - { + for (String tag : vRemoveBlanks) { + if (!P_REMOVE_PAIR_BLANKS.containsKey(tag)) { P_REMOVE_PAIR_BLANKS.putIfAbsent(tag, Pattern.compile("<" + tag + "(\\s[^>]*)?>")); } result = regexReplace(P_REMOVE_PAIR_BLANKS.get(tag), "", result); - if (!P_REMOVE_SELF_BLANKS.containsKey(tag)) - { + if (!P_REMOVE_SELF_BLANKS.containsKey(tag)) { P_REMOVE_SELF_BLANKS.putIfAbsent(tag, Pattern.compile("<" + tag + "(\\s[^>]*)?/>")); } result = regexReplace(P_REMOVE_SELF_BLANKS.get(tag), "", result); @@ -317,25 +294,19 @@ public final class HTMLFilter return result; } - private static String regexReplace(final Pattern regex_pattern, final String replacement, final String s) - { + private static String regexReplace(final Pattern regex_pattern, final String replacement, final String s) { Matcher m = regex_pattern.matcher(s); return m.replaceAll(replacement); } - private String processTag(final String s) - { + private String processTag(final String s) { // ending tags Matcher m = P_END_TAG.matcher(s); - if (m.find()) - { + if (m.find()) { final String name = m.group(1).toLowerCase(); - if (allowed(name)) - { - if (false == inArray(name, vSelfClosingTags)) - { - if (vTagCounts.containsKey(name)) - { + if (allowed(name)) { + if (false == inArray(name, vSelfClosingTags)) { + if (vTagCounts.containsKey(name)) { vTagCounts.put(name, vTagCounts.get(name) - 1); return ""; } @@ -345,35 +316,30 @@ public final class HTMLFilter // starting tags m = P_START_TAG.matcher(s); - if (m.find()) - { + if (m.find()) { final String name = m.group(1).toLowerCase(); final String body = m.group(2); String ending = m.group(3); // debug( "in a starting tag, name='" + name + "'; body='" + body + "'; ending='" + ending + "'" ); - if (allowed(name)) - { + if (allowed(name)) { final StringBuilder params = new StringBuilder(); final Matcher m2 = P_QUOTED_ATTRIBUTES.matcher(body); final Matcher m3 = P_UNQUOTED_ATTRIBUTES.matcher(body); final List paramNames = new ArrayList<>(); final List paramValues = new ArrayList<>(); - while (m2.find()) - { + while (m2.find()) { paramNames.add(m2.group(1)); // ([a-z0-9]+) paramValues.add(m2.group(3)); // (.*?) } - while (m3.find()) - { + while (m3.find()) { paramNames.add(m3.group(1)); // ([a-z0-9]+) paramValues.add(m3.group(3)); // ([^\"\\s']+) } String paramName, paramValue; - for (int ii = 0; ii < paramNames.size(); ii++) - { + for (int ii = 0; ii < paramNames.size(); ii++) { paramName = paramNames.get(ii).toLowerCase(); paramValue = paramValues.get(ii); @@ -381,72 +347,55 @@ public final class HTMLFilter // debug( "paramValue='" + paramValue + "'" ); // debug( "allowed? " + vAllowed.get( name ).contains( paramName ) ); - if (allowedAttribute(name, paramName)) - { - if (inArray(paramName, vProtocolAtts)) - { + if (allowedAttribute(name, paramName)) { + if (inArray(paramName, vProtocolAtts)) { paramValue = processParamProtocol(paramValue); } params.append(' ').append(paramName).append("=\"").append(paramValue).append("\""); } } - if (inArray(name, vSelfClosingTags)) - { + if (inArray(name, vSelfClosingTags)) { ending = " /"; } - if (inArray(name, vNeedClosingTags)) - { + if (inArray(name, vNeedClosingTags)) { ending = ""; } - if (ending == null || ending.length() < 1) - { - if (vTagCounts.containsKey(name)) - { + if (ending == null || ending.length() < 1) { + if (vTagCounts.containsKey(name)) { vTagCounts.put(name, vTagCounts.get(name) + 1); - } - else - { + } else { vTagCounts.put(name, 1); } - } - else - { + } else { ending = " /"; } return "<" + name + params + ending + ">"; - } - else - { + } else { return ""; } } // comments m = P_COMMENT.matcher(s); - if (!stripComment && m.find()) - { + if (!stripComment && m.find()) { return "<" + m.group() + ">"; } return ""; } - private String processParamProtocol(String s) - { + private String processParamProtocol(String s) { s = decodeEntities(s); final Matcher m = P_PROTOCOL.matcher(s); - if (m.find()) - { + if (m.find()) { final String protocol = m.group(1); - if (!inArray(protocol, vAllowedProtocols)) - { + if (!inArray(protocol, vAllowedProtocols)) { // bad protocol, turn into local anchor link instead s = "#" + s.substring(protocol.length() + 1); - if (s.startsWith("#//")) - { + if (s.startsWith("#//")) { s = "#" + s.substring(3); } } @@ -455,13 +404,11 @@ public final class HTMLFilter return s; } - private String decodeEntities(String s) - { + private String decodeEntities(String s) { StringBuffer buf = new StringBuffer(); Matcher m = P_ENTITY.matcher(s); - while (m.find()) - { + while (m.find()) { final String match = m.group(1); final int decimal = Integer.decode(match).intValue(); m.appendReplacement(buf, Matcher.quoteReplacement(chr(decimal))); @@ -471,8 +418,7 @@ public final class HTMLFilter buf = new StringBuffer(); m = P_ENTITY_UNICODE.matcher(s); - while (m.find()) - { + while (m.find()) { final String match = m.group(1); final int decimal = Integer.valueOf(match, 16).intValue(); m.appendReplacement(buf, Matcher.quoteReplacement(chr(decimal))); @@ -482,8 +428,7 @@ public final class HTMLFilter buf = new StringBuffer(); m = P_ENCODE.matcher(s); - while (m.find()) - { + while (m.find()) { final String match = m.group(1); final int decimal = Integer.valueOf(match, 16).intValue(); m.appendReplacement(buf, Matcher.quoteReplacement(chr(decimal))); @@ -495,14 +440,12 @@ public final class HTMLFilter return s; } - private String validateEntities(final String s) - { + private String validateEntities(final String s) { StringBuffer buf = new StringBuffer(); // validate entities throughout the string Matcher m = P_VALID_ENTITIES.matcher(s); - while (m.find()) - { + while (m.find()) { final String one = m.group(1); // ([^&;]*) final String two = m.group(2); // (?=(;|&|$)) m.appendReplacement(buf, Matcher.quoteReplacement(checkEntity(one, two))); @@ -512,14 +455,11 @@ public final class HTMLFilter return encodeQuotes(buf.toString()); } - private String encodeQuotes(final String s) - { - if (encodeQuotes) - { + private String encodeQuotes(final String s) { + if (encodeQuotes) { StringBuffer buf = new StringBuffer(); Matcher m = P_VALID_QUOTES.matcher(s); - while (m.find()) - { + while (m.find()) { final String one = m.group(1); // (>|^) final String two = m.group(2); // ([^<]+?) final String three = m.group(3); // (<|$) @@ -528,43 +468,34 @@ public final class HTMLFilter } m.appendTail(buf); return buf.toString(); - } - else - { + } else { return s; } } - private String checkEntity(final String preamble, final String term) - { + private String checkEntity(final String preamble, final String term) { return ";".equals(term) && isValidEntity(preamble) ? '&' + preamble : "&" + preamble; } - private boolean isValidEntity(final String entity) - { + private boolean isValidEntity(final String entity) { return inArray(entity, vAllowedEntities); } - private static boolean inArray(final String s, final String[] array) - { - for (String item : array) - { - if (item != null && item.equals(s)) - { + private static boolean inArray(final String s, final String[] array) { + for (String item : array) { + if (item != null && item.equals(s)) { return true; } } return false; } - private boolean allowed(final String name) - { + private boolean allowed(final String name) { return (vAllowed.isEmpty() || vAllowed.containsKey(name)) && !inArray(name, vDisallowed); } - private boolean allowedAttribute(final String name, final String paramName) - { + private boolean allowedAttribute(final String name, final String paramName) { return allowed(name) && (vAllowed.isEmpty() || vAllowed.get(name).contains(paramName)); } } \ No newline at end of file diff --git a/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/http/HttpHelper.java b/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/http/HttpHelper.java index e2c1941..e047ae9 100644 --- a/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/http/HttpHelper.java +++ b/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/http/HttpHelper.java @@ -6,46 +6,35 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.nio.charset.Charset; import javax.servlet.ServletRequest; + import org.apache.commons.lang3.exception.ExceptionUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * 通用http工具封装 - * + * * @author hchyun */ -public class HttpHelper -{ +public class HttpHelper { private static final Logger LOGGER = LoggerFactory.getLogger(HttpHelper.class); - public static String getBodyString(ServletRequest request) - { + public static String getBodyString(ServletRequest request) { StringBuilder sb = new StringBuilder(); BufferedReader reader = null; - try (InputStream inputStream = request.getInputStream()) - { + try (InputStream inputStream = request.getInputStream()) { reader = new BufferedReader(new InputStreamReader(inputStream, Charset.forName("UTF-8"))); String line = ""; - while ((line = reader.readLine()) != null) - { + while ((line = reader.readLine()) != null) { sb.append(line); } - } - catch (IOException e) - { + } catch (IOException e) { LOGGER.warn("getBodyString出现问题!"); - } - finally - { - if (reader != null) - { - try - { + } finally { + if (reader != null) { + try { reader.close(); - } - catch (IOException e) - { + } catch (IOException e) { LOGGER.error(ExceptionUtils.getMessage(e)); } } diff --git a/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/http/HttpUtils.java b/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/http/HttpUtils.java index a6b1824..3e7248f 100644 --- a/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/http/HttpUtils.java +++ b/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/http/HttpUtils.java @@ -16,45 +16,42 @@ import javax.net.ssl.SSLContext; import javax.net.ssl.SSLSession; import javax.net.ssl.TrustManager; import javax.net.ssl.X509TrustManager; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.hchyun.common.constant.Constants; /** * 通用http发送方法 - * + * * @author hchyun */ -public class HttpUtils -{ +public class HttpUtils { private static final Logger log = LoggerFactory.getLogger(HttpUtils.class); /** * 向指定 URL 发送GET方法的请求 * - * @param url 发送请求的 URL + * @param url 发送请求的 URL * @param param 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。 * @return 所代表远程资源的响应结果 */ - public static String sendGet(String url, String param) - { + public static String sendGet(String url, String param) { return sendGet(url, param, Constants.UTF8); } /** * 向指定 URL 发送GET方法的请求 * - * @param url 发送请求的 URL - * @param param 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。 + * @param url 发送请求的 URL + * @param param 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。 * @param contentType 编码类型 * @return 所代表远程资源的响应结果 */ - public static String sendGet(String url, String param, String contentType) - { + public static String sendGet(String url, String param, String contentType) { StringBuilder result = new StringBuilder(); BufferedReader in = null; - try - { + try { String urlNameString = url + "?" + param; log.info("sendGet - {}", urlNameString); URL realUrl = new URL(urlNameString); @@ -65,39 +62,24 @@ public class HttpUtils connection.connect(); in = new BufferedReader(new InputStreamReader(connection.getInputStream(), contentType)); String line; - while ((line = in.readLine()) != null) - { + while ((line = in.readLine()) != null) { result.append(line); } log.info("recv - {}", result); - } - catch (ConnectException e) - { + } catch (ConnectException e) { log.error("调用HttpUtils.sendGet ConnectException, url=" + url + ",param=" + param, e); - } - catch (SocketTimeoutException e) - { + } catch (SocketTimeoutException e) { log.error("调用HttpUtils.sendGet SocketTimeoutException, url=" + url + ",param=" + param, e); - } - catch (IOException e) - { + } catch (IOException e) { log.error("调用HttpUtils.sendGet IOException, url=" + url + ",param=" + param, e); - } - catch (Exception e) - { + } catch (Exception e) { log.error("调用HttpsUtil.sendGet Exception, url=" + url + ",param=" + param, e); - } - finally - { - try - { - if (in != null) - { + } finally { + try { + if (in != null) { in.close(); } - } - catch (Exception ex) - { + } catch (Exception ex) { log.error("调用in.close Exception, url=" + url + ",param=" + param, ex); } } @@ -107,17 +89,15 @@ public class HttpUtils /** * 向指定 URL 发送POST方法的请求 * - * @param url 发送请求的 URL + * @param url 发送请求的 URL * @param param 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。 * @return 所代表远程资源的响应结果 */ - public static String sendPost(String url, String param) - { + public static String sendPost(String url, String param) { PrintWriter out = null; BufferedReader in = null; StringBuilder result = new StringBuilder(); - try - { + try { String urlNameString = url; log.info("sendPost - {}", urlNameString); URL realUrl = new URL(urlNameString); @@ -134,58 +114,40 @@ public class HttpUtils out.flush(); in = new BufferedReader(new InputStreamReader(conn.getInputStream(), "utf-8")); String line; - while ((line = in.readLine()) != null) - { + while ((line = in.readLine()) != null) { result.append(line); } log.info("recv - {}", result); - } - catch (ConnectException e) - { + } catch (ConnectException e) { log.error("调用HttpUtils.sendPost ConnectException, url=" + url + ",param=" + param, e); - } - catch (SocketTimeoutException e) - { + } catch (SocketTimeoutException e) { log.error("调用HttpUtils.sendPost SocketTimeoutException, url=" + url + ",param=" + param, e); - } - catch (IOException e) - { + } catch (IOException e) { log.error("调用HttpUtils.sendPost IOException, url=" + url + ",param=" + param, e); - } - catch (Exception e) - { + } catch (Exception e) { log.error("调用HttpsUtil.sendPost Exception, url=" + url + ",param=" + param, e); - } - finally - { - try - { - if (out != null) - { + } finally { + try { + if (out != null) { out.close(); } - if (in != null) - { + if (in != null) { in.close(); } - } - catch (IOException ex) - { + } catch (IOException ex) { log.error("调用in.close Exception, url=" + url + ",param=" + param, ex); } } return result.toString(); } - public static String sendSSLPost(String url, String param) - { + public static String sendSSLPost(String url, String param) { StringBuilder result = new StringBuilder(); String urlNameString = url + "?" + param; - try - { + try { log.info("sendSSLPost - {}", urlNameString); SSLContext sc = SSLContext.getInstance("SSL"); - sc.init(null, new TrustManager[] { new TrustAnyTrustManager() }, new java.security.SecureRandom()); + sc.init(null, new TrustManager[]{new TrustAnyTrustManager()}, new java.security.SecureRandom()); URL console = new URL(urlNameString); HttpsURLConnection conn = (HttpsURLConnection) console.openConnection(); conn.setRequestProperty("accept", "*/*"); @@ -202,60 +164,44 @@ public class HttpUtils InputStream is = conn.getInputStream(); BufferedReader br = new BufferedReader(new InputStreamReader(is)); String ret = ""; - while ((ret = br.readLine()) != null) - { - if (ret != null && !"".equals(ret.trim())) - { + while ((ret = br.readLine()) != null) { + if (ret != null && !"".equals(ret.trim())) { result.append(new String(ret.getBytes("ISO-8859-1"), "utf-8")); } } log.info("recv - {}", result); conn.disconnect(); br.close(); - } - catch (ConnectException e) - { + } catch (ConnectException e) { log.error("调用HttpUtils.sendSSLPost ConnectException, url=" + url + ",param=" + param, e); - } - catch (SocketTimeoutException e) - { + } catch (SocketTimeoutException e) { log.error("调用HttpUtils.sendSSLPost SocketTimeoutException, url=" + url + ",param=" + param, e); - } - catch (IOException e) - { + } catch (IOException e) { log.error("调用HttpUtils.sendSSLPost IOException, url=" + url + ",param=" + param, e); - } - catch (Exception e) - { + } catch (Exception e) { log.error("调用HttpsUtil.sendSSLPost Exception, url=" + url + ",param=" + param, e); } return result.toString(); } - private static class TrustAnyTrustManager implements X509TrustManager - { + private static class TrustAnyTrustManager implements X509TrustManager { @Override - public void checkClientTrusted(X509Certificate[] chain, String authType) - { + public void checkClientTrusted(X509Certificate[] chain, String authType) { } @Override - public void checkServerTrusted(X509Certificate[] chain, String authType) - { + public void checkServerTrusted(X509Certificate[] chain, String authType) { } @Override - public X509Certificate[] getAcceptedIssuers() - { - return new X509Certificate[] {}; + public X509Certificate[] getAcceptedIssuers() { + return new X509Certificate[]{}; } } - private static class TrustAnyHostnameVerifier implements HostnameVerifier - { + private static class TrustAnyHostnameVerifier implements HostnameVerifier { @Override - public boolean verify(String hostname, SSLSession session) - { + public boolean verify(String hostname, SSLSession session) { return true; } } diff --git a/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/ip/AddressUtils.java b/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/ip/AddressUtils.java index 0d94737..8752053 100644 --- a/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/ip/AddressUtils.java +++ b/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/ip/AddressUtils.java @@ -30,17 +30,17 @@ public class AddressUtils { } if (HchYunConfig.isAddressEnabled()) { try { - String rspStr = HttpUtils.sendGet(IP_URL, "ip=" + ip + "&json=true" , Constants.GBK); + String rspStr = HttpUtils.sendGet(IP_URL, "ip=" + ip + "&json=true", Constants.GBK); if (StringUtils.isEmpty(rspStr)) { - log.error("获取地理位置异常 {}" , ip); + log.error("获取地理位置异常 {}", ip); return UNKNOWN; } JSONObject obj = JSONObject.parseObject(rspStr); String region = obj.getString("pro"); String city = obj.getString("city"); - return String.format("%s %s" , region, city); + return String.format("%s %s", region, city); } catch (Exception e) { - log.error("获取地理位置异常 {}" , ip); + log.error("获取地理位置异常 {}", ip); } } return address; diff --git a/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/ip/IpUtils.java b/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/ip/IpUtils.java index 5771568..a409d33 100644 --- a/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/ip/IpUtils.java +++ b/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/ip/IpUtils.java @@ -3,57 +3,47 @@ package com.hchyun.common.utils.ip; import java.net.InetAddress; import java.net.UnknownHostException; import javax.servlet.http.HttpServletRequest; + import com.hchyun.common.utils.StringUtils; import com.hchyun.common.utils.html.EscapeUtil; /** * 获取IP方法 - * + * * @author hchyun */ -public class IpUtils -{ - public static String getIpAddr(HttpServletRequest request) - { - if (request == null) - { +public class IpUtils { + public static String getIpAddr(HttpServletRequest request) { + if (request == null) { return "unknown"; } String ip = request.getHeader("x-forwarded-for"); - if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) - { + if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { ip = request.getHeader("Proxy-Client-IP"); } - if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) - { + if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { ip = request.getHeader("X-Forwarded-For"); } - if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) - { + if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { ip = request.getHeader("WL-Proxy-Client-IP"); } - if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) - { + if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { ip = request.getHeader("X-Real-IP"); } - if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) - { + if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { ip = request.getRemoteAddr(); } return "0:0:0:0:0:0:0:1".equals(ip) ? "127.0.0.1" : EscapeUtil.clean(ip); } - public static boolean internalIp(String ip) - { + public static boolean internalIp(String ip) { byte[] addr = textToNumericFormatV4(ip); return internalIp(addr) || "127.0.0.1".equals(ip); } - private static boolean internalIp(byte[] addr) - { - if (StringUtils.isNull(addr) || addr.length < 2) - { + private static boolean internalIp(byte[] addr) { + if (StringUtils.isNull(addr) || addr.length < 2) { return true; } final byte b0 = addr[0]; @@ -67,18 +57,15 @@ public class IpUtils // 192.168.x.x/16 final byte SECTION_5 = (byte) 0xC0; final byte SECTION_6 = (byte) 0xA8; - switch (b0) - { + switch (b0) { case SECTION_1: return true; case SECTION_2: - if (b1 >= SECTION_3 && b1 <= SECTION_4) - { + if (b1 >= SECTION_3 && b1 <= SECTION_4) { return true; } case SECTION_5: - switch (b1) - { + switch (b1) { case SECTION_6: return true; } @@ -89,25 +76,21 @@ public class IpUtils /** * 将IPv4地址转换成字节 - * + * * @param text IPv4地址 * @return byte 字节 */ - public static byte[] textToNumericFormatV4(String text) - { - if (text.length() == 0) - { + public static byte[] textToNumericFormatV4(String text) { + if (text.length() == 0) { return null; } byte[] bytes = new byte[4]; String[] elements = text.split("\\.", -1); - try - { + try { long l; int i; - switch (elements.length) - { + switch (elements.length) { case 1: l = Long.parseLong(elements[0]); if ((l < 0L) || (l > 4294967295L)) { @@ -133,8 +116,7 @@ public class IpUtils bytes[3] = (byte) (int) (l & 0xFF); break; case 3: - for (i = 0; i < 2; ++i) - { + for (i = 0; i < 2; ++i) { l = Integer.parseInt(elements[i]); if ((l < 0L) || (l > 255L)) { return null; @@ -149,8 +131,7 @@ public class IpUtils bytes[3] = (byte) (int) (l & 0xFF); break; case 4: - for (i = 0; i < 4; ++i) - { + for (i = 0; i < 4; ++i) { l = Integer.parseInt(elements[i]); if ((l < 0L) || (l > 255L)) { return null; @@ -161,34 +142,24 @@ public class IpUtils default: return null; } - } - catch (NumberFormatException e) - { + } catch (NumberFormatException e) { return null; } return bytes; } - public static String getHostIp() - { - try - { + public static String getHostIp() { + try { return InetAddress.getLocalHost().getHostAddress(); - } - catch (UnknownHostException e) - { + } catch (UnknownHostException e) { } return "127.0.0.1"; } - public static String getHostName() - { - try - { + public static String getHostName() { + try { return InetAddress.getLocalHost().getHostName(); - } - catch (UnknownHostException e) - { + } catch (UnknownHostException e) { } return "未知"; } diff --git a/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/poi/ExcelUtil.java b/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/poi/ExcelUtil.java index 66ad8e5..771cde3 100644 --- a/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/poi/ExcelUtil.java +++ b/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/poi/ExcelUtil.java @@ -736,7 +736,8 @@ public class ExcelUtil { return o; } - /** todo + /** + * todo * 得到所有定义字段 */ private void createExcelField() { diff --git a/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/reflect/ReflectUtils.java b/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/reflect/ReflectUtils.java index 1e80d72..dc405c8 100644 --- a/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/reflect/ReflectUtils.java +++ b/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/reflect/ReflectUtils.java @@ -7,6 +7,7 @@ import java.lang.reflect.Modifier; import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; import java.util.Date; + import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.Validate; import org.apache.poi.ss.usermodel.DateUtil; @@ -17,12 +18,11 @@ import com.hchyun.common.utils.DateUtils; /** * 反射工具类. 提供调用getter/setter方法, 访问私有变量, 调用私有方法, 获取泛型类型Class, 被AOP过的真实类等工具函数. - * + * * @author hchyun */ @SuppressWarnings("rawtypes") -public class ReflectUtils -{ +public class ReflectUtils { private static final String SETTER_PREFIX = "set"; private static final String GETTER_PREFIX = "get"; @@ -36,13 +36,11 @@ public class ReflectUtils * 支持多级,如:对象名.对象名.方法 */ @SuppressWarnings("unchecked") - public static E invokeGetter(Object obj, String propertyName) - { + public static E invokeGetter(Object obj, String propertyName) { Object object = obj; - for (String name : StringUtils.split(propertyName, ".")) - { + for (String name : StringUtils.split(propertyName, ".")) { String getterMethodName = GETTER_PREFIX + StringUtils.capitalize(name); - object = invokeMethod(object, getterMethodName, new Class[] {}, new Object[] {}); + object = invokeMethod(object, getterMethodName, new Class[]{}, new Object[]{}); } return (E) object; } @@ -51,21 +49,16 @@ public class ReflectUtils * 调用Setter方法, 仅匹配方法名。 * 支持多级,如:对象名.对象名.方法 */ - public static void invokeSetter(Object obj, String propertyName, E value) - { + public static void invokeSetter(Object obj, String propertyName, E value) { Object object = obj; String[] names = StringUtils.split(propertyName, "."); - for (int i = 0; i < names.length; i++) - { - if (i < names.length - 1) - { + for (int i = 0; i < names.length; i++) { + if (i < names.length - 1) { String getterMethodName = GETTER_PREFIX + StringUtils.capitalize(names[i]); - object = invokeMethod(object, getterMethodName, new Class[] {}, new Object[] {}); - } - else - { + object = invokeMethod(object, getterMethodName, new Class[]{}, new Object[]{}); + } else { String setterMethodName = SETTER_PREFIX + StringUtils.capitalize(names[i]); - invokeMethodByName(object, setterMethodName, new Object[] { value }); + invokeMethodByName(object, setterMethodName, new Object[]{value}); } } } @@ -74,21 +67,16 @@ public class ReflectUtils * 直接读取对象属性值, 无视private/protected修饰符, 不经过getter函数. */ @SuppressWarnings("unchecked") - public static E getFieldValue(final Object obj, final String fieldName) - { + public static E getFieldValue(final Object obj, final String fieldName) { Field field = getAccessibleField(obj, fieldName); - if (field == null) - { + if (field == null) { logger.debug("在 [" + obj.getClass() + "] 中,没有找到 [" + fieldName + "] 字段 "); return null; } E result = null; - try - { + try { result = (E) field.get(obj); - } - catch (IllegalAccessException e) - { + } catch (IllegalAccessException e) { logger.error("不可能抛出的异常{}", e.getMessage()); } return result; @@ -97,21 +85,16 @@ public class ReflectUtils /** * 直接设置对象属性值, 无视private/protected修饰符, 不经过setter函数. */ - public static void setFieldValue(final Object obj, final String fieldName, final E value) - { + public static void setFieldValue(final Object obj, final String fieldName, final E value) { Field field = getAccessibleField(obj, fieldName); - if (field == null) - { + if (field == null) { // throw new IllegalArgumentException("在 [" + obj.getClass() + "] 中,没有找到 [" + fieldName + "] 字段 "); logger.debug("在 [" + obj.getClass() + "] 中,没有找到 [" + fieldName + "] 字段 "); return; } - try - { + try { field.set(obj, value); - } - catch (IllegalAccessException e) - { + } catch (IllegalAccessException e) { logger.error("不可能抛出的异常: {}", e.getMessage()); } } @@ -123,24 +106,18 @@ public class ReflectUtils */ @SuppressWarnings("unchecked") public static E invokeMethod(final Object obj, final String methodName, final Class[] parameterTypes, - final Object[] args) - { - if (obj == null || methodName == null) - { + final Object[] args) { + if (obj == null || methodName == null) { return null; } Method method = getAccessibleMethod(obj, methodName, parameterTypes); - if (method == null) - { + if (method == null) { logger.debug("在 [" + obj.getClass() + "] 中,没有找到 [" + methodName + "] 方法 "); return null; } - try - { + try { return (E) method.invoke(obj, args); - } - catch (Exception e) - { + } catch (Exception e) { String msg = "method: " + method + ", obj: " + obj + ", args: " + args + ""; throw convertReflectionExceptionToUnchecked(msg, e); } @@ -152,64 +129,42 @@ public class ReflectUtils * 只匹配函数名,如果有多个同名函数调用第一个。 */ @SuppressWarnings("unchecked") - public static E invokeMethodByName(final Object obj, final String methodName, final Object[] args) - { + public static E invokeMethodByName(final Object obj, final String methodName, final Object[] args) { Method method = getAccessibleMethodByName(obj, methodName, args.length); - if (method == null) - { + if (method == null) { // 如果为空不报错,直接返回空。 logger.debug("在 [" + obj.getClass() + "] 中,没有找到 [" + methodName + "] 方法 "); return null; } - try - { + try { // 类型转换(将参数数据类型转换为目标方法参数类型) Class[] cs = method.getParameterTypes(); - for (int i = 0; i < cs.length; i++) - { - if (args[i] != null && !args[i].getClass().equals(cs[i])) - { - if (cs[i] == String.class) - { + for (int i = 0; i < cs.length; i++) { + if (args[i] != null && !args[i].getClass().equals(cs[i])) { + if (cs[i] == String.class) { args[i] = Convert.toStr(args[i]); - if (StringUtils.endsWith((String) args[i], ".0")) - { + if (StringUtils.endsWith((String) args[i], ".0")) { args[i] = StringUtils.substringBefore((String) args[i], ".0"); } - } - else if (cs[i] == Integer.class) - { + } else if (cs[i] == Integer.class) { args[i] = Convert.toInt(args[i]); - } - else if (cs[i] == Long.class) - { + } else if (cs[i] == Long.class) { args[i] = Convert.toLong(args[i]); - } - else if (cs[i] == Double.class) - { + } else if (cs[i] == Double.class) { args[i] = Convert.toDouble(args[i]); - } - else if (cs[i] == Float.class) - { + } else if (cs[i] == Float.class) { args[i] = Convert.toFloat(args[i]); - } - else if (cs[i] == Date.class) - { - if (args[i] instanceof String) - { + } else if (cs[i] == Date.class) { + if (args[i] instanceof String) { args[i] = DateUtils.parseDate(args[i]); - } - else - { + } else { args[i] = DateUtil.getJavaDate((Double) args[i]); } } } } return (E) method.invoke(obj, args); - } - catch (Exception e) - { + } catch (Exception e) { String msg = "method: " + method + ", obj: " + obj + ", args: " + args + ""; throw convertReflectionExceptionToUnchecked(msg, e); } @@ -219,24 +174,18 @@ public class ReflectUtils * 循环向上转型, 获取对象的DeclaredField, 并强制设置为可访问. * 如向上转型到Object仍无法找到, 返回null. */ - public static Field getAccessibleField(final Object obj, final String fieldName) - { + public static Field getAccessibleField(final Object obj, final String fieldName) { // 为空不报错。直接返回 null - if (obj == null) - { + if (obj == null) { return null; } Validate.notBlank(fieldName, "fieldName can't be blank"); - for (Class superClass = obj.getClass(); superClass != Object.class; superClass = superClass.getSuperclass()) - { - try - { + for (Class superClass = obj.getClass(); superClass != Object.class; superClass = superClass.getSuperclass()) { + try { Field field = superClass.getDeclaredField(fieldName); makeAccessible(field); return field; - } - catch (NoSuchFieldException e) - { + } catch (NoSuchFieldException e) { continue; } } @@ -250,24 +199,18 @@ public class ReflectUtils * 用于方法需要被多次调用的情况. 先使用本函数先取得Method,然后调用Method.invoke(Object obj, Object... args) */ public static Method getAccessibleMethod(final Object obj, final String methodName, - final Class... parameterTypes) - { + final Class... parameterTypes) { // 为空不报错。直接返回 null - if (obj == null) - { + if (obj == null) { return null; } Validate.notBlank(methodName, "methodName can't be blank"); - for (Class searchType = obj.getClass(); searchType != Object.class; searchType = searchType.getSuperclass()) - { - try - { + for (Class searchType = obj.getClass(); searchType != Object.class; searchType = searchType.getSuperclass()) { + try { Method method = searchType.getDeclaredMethod(methodName, parameterTypes); makeAccessible(method); return method; - } - catch (NoSuchMethodException e) - { + } catch (NoSuchMethodException e) { continue; } } @@ -280,21 +223,16 @@ public class ReflectUtils * 只匹配函数名。 * 用于方法需要被多次调用的情况. 先使用本函数先取得Method,然后调用Method.invoke(Object obj, Object... args) */ - public static Method getAccessibleMethodByName(final Object obj, final String methodName, int argsNum) - { + public static Method getAccessibleMethodByName(final Object obj, final String methodName, int argsNum) { // 为空不报错。直接返回 null - if (obj == null) - { + if (obj == null) { return null; } Validate.notBlank(methodName, "methodName can't be blank"); - for (Class searchType = obj.getClass(); searchType != Object.class; searchType = searchType.getSuperclass()) - { + for (Class searchType = obj.getClass(); searchType != Object.class; searchType = searchType.getSuperclass()) { Method[] methods = searchType.getDeclaredMethods(); - for (Method method : methods) - { - if (method.getName().equals(methodName) && method.getParameterTypes().length == argsNum) - { + for (Method method : methods) { + if (method.getName().equals(methodName) && method.getParameterTypes().length == argsNum) { makeAccessible(method); return method; } @@ -306,11 +244,9 @@ public class ReflectUtils /** * 改变private/protected的方法为public,尽量不调用实际改动的语句,避免JDK的SecurityManager抱怨。 */ - public static void makeAccessible(Method method) - { + public static void makeAccessible(Method method) { if ((!Modifier.isPublic(method.getModifiers()) || !Modifier.isPublic(method.getDeclaringClass().getModifiers())) - && !method.isAccessible()) - { + && !method.isAccessible()) { method.setAccessible(true); } } @@ -318,11 +254,9 @@ public class ReflectUtils /** * 改变private/protected的成员变量为public,尽量不调用实际改动的语句,避免JDK的SecurityManager抱怨。 */ - public static void makeAccessible(Field field) - { + public static void makeAccessible(Field field) { if ((!Modifier.isPublic(field.getModifiers()) || !Modifier.isPublic(field.getDeclaringClass().getModifiers()) - || Modifier.isFinal(field.getModifiers())) && !field.isAccessible()) - { + || Modifier.isFinal(field.getModifiers())) && !field.isAccessible()) { field.setAccessible(true); } } @@ -332,8 +266,7 @@ public class ReflectUtils * 如无法找到, 返回Object.class. */ @SuppressWarnings("unchecked") - public static Class getClassGenricType(final Class clazz) - { + public static Class getClassGenricType(final Class clazz) { return getClassGenricType(clazz, 0); } @@ -341,26 +274,22 @@ public class ReflectUtils * 通过反射, 获得Class定义中声明的父类的泛型参数的类型. * 如无法找到, 返回Object.class. */ - public static Class getClassGenricType(final Class clazz, final int index) - { + public static Class getClassGenricType(final Class clazz, final int index) { Type genType = clazz.getGenericSuperclass(); - if (!(genType instanceof ParameterizedType)) - { + if (!(genType instanceof ParameterizedType)) { logger.debug(clazz.getSimpleName() + "'s superclass not ParameterizedType"); return Object.class; } Type[] params = ((ParameterizedType) genType).getActualTypeArguments(); - if (index >= params.length || index < 0) - { + if (index >= params.length || index < 0) { logger.debug("Index: " + index + ", Size of " + clazz.getSimpleName() + "'s Parameterized Type: " + params.length); return Object.class; } - if (!(params[index] instanceof Class)) - { + if (!(params[index] instanceof Class)) { logger.debug(clazz.getSimpleName() + " not set the actual class on superclass generic parameter"); return Object.class; } @@ -368,18 +297,14 @@ public class ReflectUtils return (Class) params[index]; } - public static Class getUserClass(Object instance) - { - if (instance == null) - { + public static Class getUserClass(Object instance) { + if (instance == null) { throw new RuntimeException("Instance must not be null"); } Class clazz = instance.getClass(); - if (clazz != null && clazz.getName().contains(CGLIB_CLASS_SEPARATOR)) - { + if (clazz != null && clazz.getName().contains(CGLIB_CLASS_SEPARATOR)) { Class superClass = clazz.getSuperclass(); - if (superClass != null && !Object.class.equals(superClass)) - { + if (superClass != null && !Object.class.equals(superClass)) { return superClass; } } @@ -390,15 +315,11 @@ public class ReflectUtils /** * 将反射时的checked exception转换为unchecked exception. */ - public static RuntimeException convertReflectionExceptionToUnchecked(String msg, Exception e) - { + public static RuntimeException convertReflectionExceptionToUnchecked(String msg, Exception e) { if (e instanceof IllegalAccessException || e instanceof IllegalArgumentException - || e instanceof NoSuchMethodException) - { + || e instanceof NoSuchMethodException) { return new IllegalArgumentException(msg, e); - } - else if (e instanceof InvocationTargetException) - { + } else if (e instanceof InvocationTargetException) { return new RuntimeException(msg, ((InvocationTargetException) e).getTargetException()); } return new RuntimeException(msg, e); diff --git a/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/sign/Base64.java b/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/sign/Base64.java index bd04aea..3521397 100644 --- a/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/sign/Base64.java +++ b/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/sign/Base64.java @@ -2,75 +2,63 @@ package com.hchyun.common.utils.sign; /** * Base64工具类 - * + * * @author hchyun */ -public final class Base64 -{ - static private final int BASELENGTH = 128; - static private final int LOOKUPLENGTH = 64; - static private final int TWENTYFOURBITGROUP = 24; - static private final int EIGHTBIT = 8; - static private final int SIXTEENBIT = 16; - static private final int FOURBYTE = 4; - static private final int SIGN = -128; - static private final char PAD = '='; - static final private byte[] base64Alphabet = new byte[BASELENGTH]; - static final private char[] lookUpBase64Alphabet = new char[LOOKUPLENGTH]; +public final class Base64 { + static private final int BASELENGTH = 128; + static private final int LOOKUPLENGTH = 64; + static private final int TWENTYFOURBITGROUP = 24; + static private final int EIGHTBIT = 8; + static private final int SIXTEENBIT = 16; + static private final int FOURBYTE = 4; + static private final int SIGN = -128; + static private final char PAD = '='; + static final private byte[] base64Alphabet = new byte[BASELENGTH]; + static final private char[] lookUpBase64Alphabet = new char[LOOKUPLENGTH]; - static - { - for (int i = 0; i < BASELENGTH; ++i) - { + static { + for (int i = 0; i < BASELENGTH; ++i) { base64Alphabet[i] = -1; } - for (int i = 'Z'; i >= 'A'; i--) - { + for (int i = 'Z'; i >= 'A'; i--) { base64Alphabet[i] = (byte) (i - 'A'); } - for (int i = 'z'; i >= 'a'; i--) - { + for (int i = 'z'; i >= 'a'; i--) { base64Alphabet[i] = (byte) (i - 'a' + 26); } - for (int i = '9'; i >= '0'; i--) - { + for (int i = '9'; i >= '0'; i--) { base64Alphabet[i] = (byte) (i - '0' + 52); } base64Alphabet['+'] = 62; base64Alphabet['/'] = 63; - for (int i = 0; i <= 25; i++) - { + for (int i = 0; i <= 25; i++) { lookUpBase64Alphabet[i] = (char) ('A' + i); } - for (int i = 26, j = 0; i <= 51; i++, j++) - { + for (int i = 26, j = 0; i <= 51; i++, j++) { lookUpBase64Alphabet[i] = (char) ('a' + j); } - for (int i = 52, j = 0; i <= 61; i++, j++) - { + for (int i = 52, j = 0; i <= 61; i++, j++) { lookUpBase64Alphabet[i] = (char) ('0' + j); } lookUpBase64Alphabet[62] = (char) '+'; lookUpBase64Alphabet[63] = (char) '/'; } - private static boolean isWhiteSpace(char octect) - { + private static boolean isWhiteSpace(char octect) { return (octect == 0x20 || octect == 0xd || octect == 0xa || octect == 0x9); } - private static boolean isPad(char octect) - { + private static boolean isPad(char octect) { return (octect == PAD); } - private static boolean isData(char octect) - { + private static boolean isData(char octect) { return (octect < BASELENGTH && base64Alphabet[octect] != -1); } @@ -80,16 +68,13 @@ public final class Base64 * @param binaryData Array containing binaryData * @return Encoded Base64 array */ - public static String encode(byte[] binaryData) - { - if (binaryData == null) - { + public static String encode(byte[] binaryData) { + if (binaryData == null) { return null; } int lengthDataBits = binaryData.length * EIGHTBIT; - if (lengthDataBits == 0) - { + if (lengthDataBits == 0) { return ""; } @@ -105,8 +90,7 @@ public final class Base64 int encodedIndex = 0; int dataIndex = 0; - for (int i = 0; i < numberTriplets; i++) - { + for (int i = 0; i < numberTriplets; i++) { b1 = binaryData[dataIndex++]; b2 = binaryData[dataIndex++]; b3 = binaryData[dataIndex++]; @@ -125,8 +109,7 @@ public final class Base64 } // form integral number of 6-bit groups - if (fewerThan24bits == EIGHTBIT) - { + if (fewerThan24bits == EIGHTBIT) { b1 = binaryData[dataIndex]; k = (byte) (b1 & 0x03); byte val1 = ((b1 & SIGN) == 0) ? (byte) (b1 >> 2) : (byte) ((b1) >> 2 ^ 0xc0); @@ -134,9 +117,7 @@ public final class Base64 encodedData[encodedIndex++] = lookUpBase64Alphabet[k << 4]; encodedData[encodedIndex++] = PAD; encodedData[encodedIndex++] = PAD; - } - else if (fewerThan24bits == SIXTEENBIT) - { + } else if (fewerThan24bits == SIXTEENBIT) { b1 = binaryData[dataIndex]; b2 = binaryData[dataIndex + 1]; l = (byte) (b2 & 0x0f); @@ -159,10 +140,8 @@ public final class Base64 * @param encoded string containing Base64 data * @return Array containind decoded data. */ - public static byte[] decode(String encoded) - { - if (encoded == null) - { + public static byte[] decode(String encoded) { + if (encoded == null) { return null; } @@ -170,15 +149,13 @@ public final class Base64 // remove white spaces int len = removeWhiteSpace(base64Data); - if (len % FOURBYTE != 0) - { + if (len % FOURBYTE != 0) { return null;// should be divisible by four } int numberQuadruple = (len / FOURBYTE); - if (numberQuadruple == 0) - { + if (numberQuadruple == 0) { return new byte[0]; } @@ -191,12 +168,10 @@ public final class Base64 int dataIndex = 0; decodedData = new byte[(numberQuadruple) * 3]; - for (; i < numberQuadruple - 1; i++) - { + for (; i < numberQuadruple - 1; i++) { if (!isData((d1 = base64Data[dataIndex++])) || !isData((d2 = base64Data[dataIndex++])) - || !isData((d3 = base64Data[dataIndex++])) || !isData((d4 = base64Data[dataIndex++]))) - { + || !isData((d3 = base64Data[dataIndex++])) || !isData((d4 = base64Data[dataIndex++]))) { return null; } // if found "no data" just return null @@ -210,8 +185,7 @@ public final class Base64 decodedData[encodedIndex++] = (byte) (b3 << 6 | b4); } - if (!isData((d1 = base64Data[dataIndex++])) || !isData((d2 = base64Data[dataIndex++]))) - { + if (!isData((d1 = base64Data[dataIndex++])) || !isData((d2 = base64Data[dataIndex++]))) { return null;// if found "no data" just return null } @@ -220,10 +194,8 @@ public final class Base64 d3 = base64Data[dataIndex++]; d4 = base64Data[dataIndex++]; - if (!isData((d3)) || !isData((d4))) - {// Check if they are PAD characters - if (isPad(d3) && isPad(d4)) - { + if (!isData((d3)) || !isData((d4))) {// Check if they are PAD characters + if (isPad(d3) && isPad(d4)) { if ((b2 & 0xf) != 0)// last 4 bits should be zero { return null; @@ -232,9 +204,7 @@ public final class Base64 System.arraycopy(decodedData, 0, tmp, 0, i * 3); tmp[encodedIndex] = (byte) (b1 << 2 | b2 >> 4); return tmp; - } - else if (!isPad(d3) && isPad(d4)) - { + } else if (!isPad(d3) && isPad(d4)) { b3 = base64Alphabet[d3]; if ((b3 & 0x3) != 0)// last 2 bits should be zero { @@ -245,14 +215,10 @@ public final class Base64 tmp[encodedIndex++] = (byte) (b1 << 2 | b2 >> 4); tmp[encodedIndex] = (byte) (((b2 & 0xf) << 4) | ((b3 >> 2) & 0xf)); return tmp; - } - else - { + } else { return null; } - } - else - { // No PAD e.g 3cQl + } else { // No PAD e.g 3cQl b3 = base64Alphabet[d3]; b4 = base64Alphabet[d4]; decodedData[encodedIndex++] = (byte) (b1 << 2 | b2 >> 4); @@ -269,20 +235,16 @@ public final class Base64 * @param data the byte array of base64 data (with WS) * @return the new length */ - private static int removeWhiteSpace(char[] data) - { - if (data == null) - { + private static int removeWhiteSpace(char[] data) { + if (data == null) { return 0; } // count characters that's not whitespace int newSize = 0; int len = data.length; - for (int i = 0; i < len; i++) - { - if (!isWhiteSpace(data[i])) - { + for (int i = 0; i < len; i++) { + if (!isWhiteSpace(data[i])) { data[newSize++] = data[i]; } } diff --git a/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/sign/Md5Utils.java b/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/sign/Md5Utils.java index 2ed3b4a..554869e 100644 --- a/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/sign/Md5Utils.java +++ b/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/sign/Md5Utils.java @@ -1,49 +1,41 @@ package com.hchyun.common.utils.sign; import java.security.MessageDigest; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * Md5加密方法 - * + * * @author hchyun */ -public class Md5Utils -{ +public class Md5Utils { private static final Logger log = LoggerFactory.getLogger(Md5Utils.class); - private static byte[] md5(String s) - { + private static byte[] md5(String s) { MessageDigest algorithm; - try - { + try { algorithm = MessageDigest.getInstance("MD5"); algorithm.reset(); algorithm.update(s.getBytes("UTF-8")); byte[] messageDigest = algorithm.digest(); return messageDigest; - } - catch (Exception e) - { + } catch (Exception e) { log.error("MD5 Error...", e); } return null; } - private static final String toHex(byte hash[]) - { - if (hash == null) - { + private static final String toHex(byte hash[]) { + if (hash == null) { return null; } StringBuffer buf = new StringBuffer(hash.length * 2); int i; - for (i = 0; i < hash.length; i++) - { - if ((hash[i] & 0xff) < 0x10) - { + for (i = 0; i < hash.length; i++) { + if ((hash[i] & 0xff) < 0x10) { buf.append("0"); } buf.append(Long.toString(hash[i] & 0xff, 16)); @@ -51,14 +43,10 @@ public class Md5Utils return buf.toString(); } - public static String hash(String s) - { - try - { + public static String hash(String s) { + try { return new String(toHex(md5(s)).getBytes("UTF-8"), "UTF-8"); - } - catch (Exception e) - { + } catch (Exception e) { log.error("not supported charset...{}", e); return s; } diff --git a/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/spring/SpringUtils.java b/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/spring/SpringUtils.java index 5650e61..4e4dfba 100644 --- a/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/spring/SpringUtils.java +++ b/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/spring/SpringUtils.java @@ -12,26 +12,25 @@ import com.hchyun.common.utils.StringUtils; /** * spring工具类 方便在非spring管理环境中获取bean - * + * * @author hchyun */ @Component -public final class SpringUtils implements BeanFactoryPostProcessor, ApplicationContextAware -{ - /** Spring应用上下文环境 */ +public final class SpringUtils implements BeanFactoryPostProcessor, ApplicationContextAware { + /** + * Spring应用上下文环境 + */ private static ConfigurableListableBeanFactory beanFactory; private static ApplicationContext applicationContext; @Override - public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException - { + public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { SpringUtils.beanFactory = beanFactory; } @Override - public void setApplicationContext(ApplicationContext applicationContext) throws BeansException - { + public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { SpringUtils.applicationContext = applicationContext; } @@ -41,11 +40,9 @@ public final class SpringUtils implements BeanFactoryPostProcessor, ApplicationC * @param name * @return Object 一个以所给名字注册的bean的实例 * @throws org.springframework.beans.BeansException - * */ @SuppressWarnings("unchecked") - public static T getBean(String name) throws BeansException - { + public static T getBean(String name) throws BeansException { return (T) beanFactory.getBean(name); } @@ -55,10 +52,8 @@ public final class SpringUtils implements BeanFactoryPostProcessor, ApplicationC * @param clz * @return * @throws org.springframework.beans.BeansException - * */ - public static T getBean(Class clz) throws BeansException - { + public static T getBean(Class clz) throws BeansException { T result = (T) beanFactory.getBean(clz); return result; } @@ -69,8 +64,7 @@ public final class SpringUtils implements BeanFactoryPostProcessor, ApplicationC * @param name * @return boolean */ - public static boolean containsBean(String name) - { + public static boolean containsBean(String name) { return beanFactory.containsBean(name); } @@ -80,10 +74,8 @@ public final class SpringUtils implements BeanFactoryPostProcessor, ApplicationC * @param name * @return boolean * @throws org.springframework.beans.factory.NoSuchBeanDefinitionException - * */ - public static boolean isSingleton(String name) throws NoSuchBeanDefinitionException - { + public static boolean isSingleton(String name) throws NoSuchBeanDefinitionException { return beanFactory.isSingleton(name); } @@ -91,10 +83,8 @@ public final class SpringUtils implements BeanFactoryPostProcessor, ApplicationC * @param name * @return Class 注册对象的类型 * @throws org.springframework.beans.factory.NoSuchBeanDefinitionException - * */ - public static Class getType(String name) throws NoSuchBeanDefinitionException - { + public static Class getType(String name) throws NoSuchBeanDefinitionException { return beanFactory.getType(name); } @@ -104,22 +94,19 @@ public final class SpringUtils implements BeanFactoryPostProcessor, ApplicationC * @param name * @return * @throws org.springframework.beans.factory.NoSuchBeanDefinitionException - * */ - public static String[] getAliases(String name) throws NoSuchBeanDefinitionException - { + public static String[] getAliases(String name) throws NoSuchBeanDefinitionException { return beanFactory.getAliases(name); } /** * 获取aop代理对象 - * + * * @param invoker * @return */ @SuppressWarnings("unchecked") - public static T getAopProxy(T invoker) - { + public static T getAopProxy(T invoker) { return (T) AopContext.currentProxy(); } @@ -128,8 +115,7 @@ public final class SpringUtils implements BeanFactoryPostProcessor, ApplicationC * * @return 当前的环境配置 */ - public static String[] getActiveProfiles() - { + public static String[] getActiveProfiles() { return applicationContext.getEnvironment().getActiveProfiles(); } @@ -138,8 +124,7 @@ public final class SpringUtils implements BeanFactoryPostProcessor, ApplicationC * * @return 当前的环境配置 */ - public static String getActiveProfile() - { + public static String getActiveProfile() { final String[] activeProfiles = getActiveProfiles(); return StringUtils.isNotEmpty(activeProfiles) ? activeProfiles[0] : null; } diff --git a/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/sql/SqlUtil.java b/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/sql/SqlUtil.java index 2fc2fe1..ff67668 100644 --- a/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/sql/SqlUtil.java +++ b/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/sql/SqlUtil.java @@ -5,11 +5,10 @@ import com.hchyun.common.utils.StringUtils; /** * sql操作工具类 - * + * * @author hchyun */ -public class SqlUtil -{ +public class SqlUtil { /** * 仅支持字母、数字、下划线、空格、逗号、小数点(支持多个字段排序) */ @@ -18,10 +17,8 @@ public class SqlUtil /** * 检查字符,防止注入绕过 */ - public static String escapeOrderBySql(String value) - { - if (StringUtils.isNotEmpty(value) && !isValidOrderBySql(value)) - { + public static String escapeOrderBySql(String value) { + if (StringUtils.isNotEmpty(value) && !isValidOrderBySql(value)) { throw new BaseException("参数不符合规范,不能进行查询"); } return value; @@ -30,8 +27,7 @@ public class SqlUtil /** * 验证 order by 语法是否符合规范 */ - public static boolean isValidOrderBySql(String value) - { + public static boolean isValidOrderBySql(String value) { return value.matches(SQL_PATTERN); } } diff --git a/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/uuid/IdUtils.java b/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/uuid/IdUtils.java index ce841f0..fc5779b 100644 --- a/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/uuid/IdUtils.java +++ b/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/uuid/IdUtils.java @@ -2,48 +2,43 @@ package com.hchyun.common.utils.uuid; /** * ID生成器工具类 - * + * * @author hchyun */ -public class IdUtils -{ +public class IdUtils { /** * 获取随机UUID - * + * * @return 随机UUID */ - public static String randomUUID() - { + public static String randomUUID() { return UUID.randomUUID().toString(); } /** * 简化的UUID,去掉了横线 - * + * * @return 简化的UUID,去掉了横线 */ - public static String simpleUUID() - { + public static String simpleUUID() { return UUID.randomUUID().toString(true); } /** * 获取随机UUID,使用性能更好的ThreadLocalRandom生成UUID - * + * * @return 随机UUID */ - public static String fastUUID() - { + public static String fastUUID() { return UUID.fastUUID().toString(); } /** * 简化的UUID,去掉了横线,使用性能更好的ThreadLocalRandom生成UUID - * + * * @return 简化的UUID,去掉了横线 */ - public static String fastSimpleUUID() - { + public static String fastSimpleUUID() { return UUID.fastUUID().toString(true); } } diff --git a/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/uuid/UUID.java b/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/uuid/UUID.java index 6dbb7a7..3f2873f 100644 --- a/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/uuid/UUID.java +++ b/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/uuid/UUID.java @@ -5,6 +5,7 @@ import java.security.NoSuchAlgorithmException; import java.security.SecureRandom; import java.util.Random; import java.util.concurrent.ThreadLocalRandom; + import com.hchyun.common.exception.UtilException; /** @@ -12,41 +13,39 @@ import com.hchyun.common.exception.UtilException; * * @author hchyun */ -public final class UUID implements java.io.Serializable, Comparable -{ +public final class UUID implements java.io.Serializable, Comparable { private static final long serialVersionUID = -1185015143654744140L; /** * SecureRandom 的单例 - * */ - private static class Holder - { + private static class Holder { static final SecureRandom numberGenerator = getSecureRandom(); } - /** 此UUID的最高64有效位 */ + /** + * 此UUID的最高64有效位 + */ private final long mostSigBits; - /** 此UUID的最低64有效位 */ + /** + * 此UUID的最低64有效位 + */ private final long leastSigBits; /** * 私有构造 - * + * * @param data 数据 */ - private UUID(byte[] data) - { + private UUID(byte[] data) { long msb = 0; long lsb = 0; assert data.length == 16 : "data must be 16 bytes in length"; - for (int i = 0; i < 8; i++) - { + for (int i = 0; i < 8; i++) { msb = (msb << 8) | (data[i] & 0xff); } - for (int i = 8; i < 16; i++) - { + for (int i = 8; i < 16; i++) { lsb = (lsb << 8) | (data[i] & 0xff); } this.mostSigBits = msb; @@ -56,43 +55,39 @@ public final class UUID implements java.io.Serializable, Comparable /** * 使用指定的数据构造新的 UUID。 * - * @param mostSigBits 用于 {@code UUID} 的最高有效 64 位 + * @param mostSigBits 用于 {@code UUID} 的最高有效 64 位 * @param leastSigBits 用于 {@code UUID} 的最低有效 64 位 */ - public UUID(long mostSigBits, long leastSigBits) - { + public UUID(long mostSigBits, long leastSigBits) { this.mostSigBits = mostSigBits; this.leastSigBits = leastSigBits; } /** * 获取类型 4(伪随机生成的)UUID 的静态工厂。 使用加密的本地线程伪随机数生成器生成该 UUID。 - * + * * @return 随机生成的 {@code UUID} */ - public static UUID fastUUID() - { + public static UUID fastUUID() { return randomUUID(false); } /** * 获取类型 4(伪随机生成的)UUID 的静态工厂。 使用加密的强伪随机数生成器生成该 UUID。 - * + * * @return 随机生成的 {@code UUID} */ - public static UUID randomUUID() - { + public static UUID randomUUID() { return randomUUID(true); } /** * 获取类型 4(伪随机生成的)UUID 的静态工厂。 使用加密的强伪随机数生成器生成该 UUID。 - * + * * @param isSecure 是否使用{@link SecureRandom}如果是可以获得更安全的随机码,否则可以得到更好的性能 * @return 随机生成的 {@code UUID} */ - public static UUID randomUUID(boolean isSecure) - { + public static UUID randomUUID(boolean isSecure) { final Random ng = isSecure ? Holder.numberGenerator : getRandom(); byte[] randomBytes = new byte[16]; @@ -108,18 +103,13 @@ public final class UUID implements java.io.Serializable, Comparable * 根据指定的字节数组获取类型 3(基于名称的)UUID 的静态工厂。 * * @param name 用于构造 UUID 的字节数组。 - * * @return 根据指定数组生成的 {@code UUID} */ - public static UUID nameUUIDFromBytes(byte[] name) - { + public static UUID nameUUIDFromBytes(byte[] name) { MessageDigest md; - try - { + try { md = MessageDigest.getInstance("MD5"); - } - catch (NoSuchAlgorithmException nsae) - { + } catch (NoSuchAlgorithmException nsae) { throw new InternalError("MD5 not supported"); } byte[] md5Bytes = md.digest(name); @@ -136,17 +126,13 @@ public final class UUID implements java.io.Serializable, Comparable * @param name 指定 {@code UUID} 字符串 * @return 具有指定值的 {@code UUID} * @throws IllegalArgumentException 如果 name 与 {@link #toString} 中描述的字符串表示形式不符抛出此异常 - * */ - public static UUID fromString(String name) - { + public static UUID fromString(String name) { String[] components = name.split("-"); - if (components.length != 5) - { + if (components.length != 5) { throw new IllegalArgumentException("Invalid UUID string: " + name); } - for (int i = 0; i < 5; i++) - { + for (int i = 0; i < 5; i++) { components[i] = "0x" + components[i]; } @@ -168,8 +154,7 @@ public final class UUID implements java.io.Serializable, Comparable * * @return 此 UUID 的 128 位值中的最低有效 64 位。 */ - public long getLeastSignificantBits() - { + public long getLeastSignificantBits() { return leastSigBits; } @@ -178,8 +163,7 @@ public final class UUID implements java.io.Serializable, Comparable * * @return 此 UUID 的 128 位值中最高有效 64 位。 */ - public long getMostSignificantBits() - { + public long getMostSignificantBits() { return mostSigBits; } @@ -196,8 +180,7 @@ public final class UUID implements java.io.Serializable, Comparable * * @return 此 {@code UUID} 的版本号 */ - public int version() - { + public int version() { // Version is bits masked by 0x000000000000F000 in MS long return (int) ((mostSigBits >> 12) & 0x0f); } @@ -215,8 +198,7 @@ public final class UUID implements java.io.Serializable, Comparable * * @return 此 {@code UUID} 相关联的变体号 */ - public int variant() - { + public int variant() { // This field is composed of a varying number of bits. // 0 - - Reserved for NCS backward compatibility // 1 0 - The IETF aka Leach-Salz variant (used by this class) @@ -238,8 +220,7 @@ public final class UUID implements java.io.Serializable, Comparable * * @throws UnsupportedOperationException 如果此 {@code UUID} 不是 version 为 1 的 UUID。 */ - public long timestamp() throws UnsupportedOperationException - { + public long timestamp() throws UnsupportedOperationException { checkTimeBase(); return (mostSigBits & 0x0FFFL) << 48// | ((mostSigBits >> 16) & 0x0FFFFL) << 32// @@ -256,11 +237,9 @@ public final class UUID implements java.io.Serializable, Comparable * UnsupportedOperationException。 * * @return 此 {@code UUID} 的时钟序列 - * * @throws UnsupportedOperationException 如果此 UUID 的 version 不为 1 */ - public int clockSequence() throws UnsupportedOperationException - { + public int clockSequence() throws UnsupportedOperationException { checkTimeBase(); return (int) ((leastSigBits & 0x3FFF000000000000L) >>> 48); } @@ -275,11 +254,9 @@ public final class UUID implements java.io.Serializable, Comparable * 如果此 UUID 不是基于时间的 UUID,则此方法抛出 UnsupportedOperationException。 * * @return 此 {@code UUID} 的节点值 - * * @throws UnsupportedOperationException 如果此 UUID 的 version 不为 1 */ - public long node() throws UnsupportedOperationException - { + public long node() throws UnsupportedOperationException { checkTimeBase(); return leastSigBits & 0x0000FFFFFFFFFFFFL; } @@ -289,7 +266,7 @@ public final class UUID implements java.io.Serializable, Comparable * *

* UUID 的字符串表示形式由此 BNF 描述: - * + * *

      * {@code
      * UUID                   = ----
@@ -302,15 +279,14 @@ public final class UUID implements java.io.Serializable, Comparable
      * hexDigit               = [0-9a-fA-F]
      * }
      * 
- * + * * * * @return 此{@code UUID} 的字符串表现形式 * @see #toString(boolean) */ @Override - public String toString() - { + public String toString() { return toString(false); } @@ -319,7 +295,7 @@ public final class UUID implements java.io.Serializable, Comparable * *

* UUID 的字符串表示形式由此 BNF 描述: - * + * *

      * {@code
      * UUID                   = ----
@@ -332,37 +308,32 @@ public final class UUID implements java.io.Serializable, Comparable
      * hexDigit               = [0-9a-fA-F]
      * }
      * 
- * + * * * * @param isSimple 是否简单模式,简单模式为不带'-'的UUID字符串 * @return 此{@code UUID} 的字符串表现形式 */ - public String toString(boolean isSimple) - { + public String toString(boolean isSimple) { final StringBuilder builder = new StringBuilder(isSimple ? 32 : 36); // time_low builder.append(digits(mostSigBits >> 32, 8)); - if (false == isSimple) - { + if (false == isSimple) { builder.append('-'); } // time_mid builder.append(digits(mostSigBits >> 16, 4)); - if (false == isSimple) - { + if (false == isSimple) { builder.append('-'); } // time_high_and_version builder.append(digits(mostSigBits, 4)); - if (false == isSimple) - { + if (false == isSimple) { builder.append('-'); } // variant_and_sequence builder.append(digits(leastSigBits >> 48, 4)); - if (false == isSimple) - { + if (false == isSimple) { builder.append('-'); } // node @@ -377,8 +348,7 @@ public final class UUID implements java.io.Serializable, Comparable * @return UUID 的哈希码值。 */ @Override - public int hashCode() - { + public int hashCode() { long hilo = mostSigBits ^ leastSigBits; return ((int) (hilo >> 32)) ^ (int) hilo; } @@ -389,14 +359,11 @@ public final class UUID implements java.io.Serializable, Comparable * 当且仅当参数不为 {@code null}、而是一个 UUID 对象、具有与此 UUID 相同的 varriant、包含相同的值(每一位均相同)时,结果才为 {@code true}。 * * @param obj 要与之比较的对象 - * * @return 如果对象相同,则返回 {@code true};否则返回 {@code false} */ @Override - public boolean equals(Object obj) - { - if ((null == obj) || (obj.getClass() != UUID.class)) - { + public boolean equals(Object obj) { + if ((null == obj) || (obj.getClass() != UUID.class)) { return false; } UUID id = (UUID) obj; @@ -412,13 +379,10 @@ public final class UUID implements java.io.Serializable, Comparable * 如果两个 UUID 不同,且第一个 UUID 的最高有效字段大于第二个 UUID 的对应字段,则第一个 UUID 大于第二个 UUID。 * * @param val 与此 UUID 比较的 UUID - * * @return 在此 UUID 小于、等于或大于 val 时,分别返回 -1、0 或 1。 - * */ @Override - public int compareTo(UUID val) - { + public int compareTo(UUID val) { // The ordering is intentionally set up so that the UUIDs // can simply be numerically compared as two numbers return (this.mostSigBits < val.mostSigBits ? -1 : // @@ -430,15 +394,15 @@ public final class UUID implements java.io.Serializable, Comparable // ------------------------------------------------------------------------------------------------------------------- // Private method start + /** * 返回指定数字对应的hex值 - * - * @param val 值 + * + * @param val 值 * @param digits 位 * @return 值 */ - private static String digits(long val, int digits) - { + private static String digits(long val, int digits) { long hi = 1L << (digits * 4); return Long.toHexString(hi | (val & (hi - 1))).substring(1); } @@ -446,27 +410,21 @@ public final class UUID implements java.io.Serializable, Comparable /** * 检查是否为time-based版本UUID */ - private void checkTimeBase() - { - if (version() != 1) - { + private void checkTimeBase() { + if (version() != 1) { throw new UnsupportedOperationException("Not a time-based UUID"); } } /** * 获取{@link SecureRandom},类提供加密的强随机数生成器 (RNG) - * + * * @return {@link SecureRandom} */ - public static SecureRandom getSecureRandom() - { - try - { + public static SecureRandom getSecureRandom() { + try { return SecureRandom.getInstance("SHA1PRNG"); - } - catch (NoSuchAlgorithmException e) - { + } catch (NoSuchAlgorithmException e) { throw new UtilException(e); } } @@ -474,11 +432,10 @@ public final class UUID implements java.io.Serializable, Comparable /** * 获取随机数生成器对象
* ThreadLocalRandom是JDK 7之后提供并发产生随机数,能够解决多个线程发生的竞争争夺。 - * + * * @return {@link ThreadLocalRandom} */ - public static ThreadLocalRandom getRandom() - { + public static ThreadLocalRandom getRandom() { return ThreadLocalRandom.current(); } } diff --git a/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/aspectj/DataScopeAspect.java b/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/aspectj/DataScopeAspect.java index b18e5b6..d03e564 100644 --- a/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/aspectj/DataScopeAspect.java +++ b/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/aspectj/DataScopeAspect.java @@ -1,6 +1,7 @@ package com.hchyun.framework.aspectj; import java.lang.reflect.Method; + import org.aspectj.lang.JoinPoint; import org.aspectj.lang.Signature; import org.aspectj.lang.annotation.Aspect; @@ -25,8 +26,7 @@ import com.hchyun.framework.web.service.TokenService; */ @Aspect @Component -public class DataScopeAspect -{ +public class DataScopeAspect { /** * 全部数据权限 */ @@ -59,32 +59,26 @@ public class DataScopeAspect // 配置织入点 @Pointcut("@annotation(com.hchyun.common.annotation.DataScope)") - public void dataScopePointCut() - { + public void dataScopePointCut() { } @Before("dataScopePointCut()") - public void doBefore(JoinPoint point) throws Throwable - { + public void doBefore(JoinPoint point) throws Throwable { handleDataScope(point); } - protected void handleDataScope(final JoinPoint joinPoint) - { + protected void handleDataScope(final JoinPoint joinPoint) { // 获得注解 DataScope controllerDataScope = getAnnotationLog(joinPoint); - if (controllerDataScope == null) - { + if (controllerDataScope == null) { return; } // 获取当前的用户 LoginUser loginUser = SpringUtils.getBean(TokenService.class).getLoginUser(ServletUtils.getRequest()); - if (StringUtils.isNotNull(loginUser)) - { + if (StringUtils.isNotNull(loginUser)) { SysUser currentUser = loginUser.getUser(); // 如果是超级管理员,则不过滤数据 - if (StringUtils.isNotNull(currentUser) && !currentUser.isAdmin()) - { + if (StringUtils.isNotNull(currentUser) && !currentUser.isAdmin()) { dataScopeFilter(joinPoint, currentUser, controllerDataScope.deptAlias(), controllerDataScope.userAlias()); } @@ -95,56 +89,40 @@ public class DataScopeAspect * 数据范围过滤 * * @param joinPoint 切点 - * @param user 用户 + * @param user 用户 * @param userAlias 别名 */ - public static void dataScopeFilter(JoinPoint joinPoint, SysUser user, String deptAlias, String userAlias) - { + public static void dataScopeFilter(JoinPoint joinPoint, SysUser user, String deptAlias, String userAlias) { StringBuilder sqlString = new StringBuilder(); - for (SysRole role : user.getRoles()) - { + for (SysRole role : user.getRoles()) { String dataScope = role.getDataScope(); - if (DATA_SCOPE_ALL.equals(dataScope)) - { + if (DATA_SCOPE_ALL.equals(dataScope)) { sqlString = new StringBuilder(); break; - } - else if (DATA_SCOPE_CUSTOM.equals(dataScope)) - { + } else if (DATA_SCOPE_CUSTOM.equals(dataScope)) { sqlString.append(StringUtils.format( " OR {}.dept_id IN ( SELECT dept_id FROM sys_role_dept WHERE role_id = {} ) ", deptAlias, role.getRoleId())); - } - else if (DATA_SCOPE_DEPT.equals(dataScope)) - { + } else if (DATA_SCOPE_DEPT.equals(dataScope)) { sqlString.append(StringUtils.format(" OR {}.dept_id = {} ", deptAlias, user.getDeptId())); - } - else if (DATA_SCOPE_DEPT_AND_CHILD.equals(dataScope)) - { + } else if (DATA_SCOPE_DEPT_AND_CHILD.equals(dataScope)) { sqlString.append(StringUtils.format( " OR {}.dept_id IN ( SELECT dept_id FROM sys_dept WHERE dept_id = {} or find_in_set( {} , ancestors ) )", deptAlias, user.getDeptId(), user.getDeptId())); - } - else if (DATA_SCOPE_SELF.equals(dataScope)) - { - if (StringUtils.isNotBlank(userAlias)) - { + } else if (DATA_SCOPE_SELF.equals(dataScope)) { + if (StringUtils.isNotBlank(userAlias)) { sqlString.append(StringUtils.format(" OR {}.user_id = {} ", userAlias, user.getUserId())); - } - else - { + } else { // 数据权限为仅本人且没有userAlias别名不查询任何数据 sqlString.append(" OR 1=0 "); } } } - if (StringUtils.isNotBlank(sqlString.toString())) - { + if (StringUtils.isNotBlank(sqlString.toString())) { Object params = joinPoint.getArgs()[0]; - if (StringUtils.isNotNull(params) && params instanceof BaseEntity) - { + if (StringUtils.isNotNull(params) && params instanceof BaseEntity) { BaseEntity baseEntity = (BaseEntity) params; baseEntity.getParams().put(DATA_SCOPE, " AND (" + sqlString.substring(4) + ")"); } @@ -154,14 +132,12 @@ public class DataScopeAspect /** * 是否存在注解,如果存在就获取 */ - private DataScope getAnnotationLog(JoinPoint joinPoint) - { + private DataScope getAnnotationLog(JoinPoint joinPoint) { Signature signature = joinPoint.getSignature(); MethodSignature methodSignature = (MethodSignature) signature; Method method = methodSignature.getMethod(); - if (method != null) - { + if (method != null) { return method.getAnnotation(DataScope.class); } return null; diff --git a/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/aspectj/DataSourceAspect.java b/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/aspectj/DataSourceAspect.java index d065c81..c2ed067 100644 --- a/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/aspectj/DataSourceAspect.java +++ b/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/aspectj/DataSourceAspect.java @@ -1,6 +1,7 @@ package com.hchyun.framework.aspectj; import java.util.Objects; + import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.annotation.Around; import org.aspectj.lang.annotation.Aspect; @@ -17,39 +18,32 @@ import com.hchyun.framework.datasource.DynamicDataSourceContextHolder; /** * 多数据源处理 - * + * * @author hchyun */ @Aspect @Order(1) @Component -public class DataSourceAspect -{ +public class DataSourceAspect { protected Logger logger = LoggerFactory.getLogger(getClass()); @Pointcut("@annotation(com.hchyun.common.annotation.DataSource)" + "|| @within(com.hchyun.common.annotation.DataSource)") - public void dsPointCut() - { + public void dsPointCut() { } @Around("dsPointCut()") - public Object around(ProceedingJoinPoint point) throws Throwable - { + public Object around(ProceedingJoinPoint point) throws Throwable { DataSource dataSource = getDataSource(point); - if (StringUtils.isNotNull(dataSource)) - { + if (StringUtils.isNotNull(dataSource)) { DynamicDataSourceContextHolder.setDataSourceType(dataSource.value().name()); } - try - { + try { return point.proceed(); - } - finally - { + } finally { // 销毁数据源 在执行方法之后 DynamicDataSourceContextHolder.clearDataSourceType(); } @@ -58,12 +52,10 @@ public class DataSourceAspect /** * 获取需要切换的数据源 */ - public DataSource getDataSource(ProceedingJoinPoint point) - { + public DataSource getDataSource(ProceedingJoinPoint point) { MethodSignature signature = (MethodSignature) point.getSignature(); DataSource dataSource = AnnotationUtils.findAnnotation(signature.getMethod(), DataSource.class); - if (Objects.nonNull(dataSource)) - { + if (Objects.nonNull(dataSource)) { return dataSource; } diff --git a/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/aspectj/LogAspect.java b/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/aspectj/LogAspect.java index 279bb8f..ab2d263 100644 --- a/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/aspectj/LogAspect.java +++ b/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/aspectj/LogAspect.java @@ -4,6 +4,7 @@ import java.lang.reflect.Method; import java.util.Map; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; + import org.aspectj.lang.JoinPoint; import org.aspectj.lang.Signature; import org.aspectj.lang.annotation.AfterReturning; @@ -32,19 +33,17 @@ import com.hchyun.system.entity.SysOperLog; /** * 操作日志记录处理 - * + * * @author hchyun */ @Aspect @Component -public class LogAspect -{ +public class LogAspect { private static final Logger log = LoggerFactory.getLogger(LogAspect.class); // 配置织入点 @Pointcut("@annotation(com.hchyun.common.annotation.Log)") - public void logPointCut() - { + public void logPointCut() { } /** @@ -53,31 +52,26 @@ public class LogAspect * @param joinPoint 切点 */ @AfterReturning(pointcut = "logPointCut()", returning = "jsonResult") - public void doAfterReturning(JoinPoint joinPoint, Object jsonResult) - { + public void doAfterReturning(JoinPoint joinPoint, Object jsonResult) { handleLog(joinPoint, null, jsonResult); } /** * 拦截异常操作 - * + * * @param joinPoint 切点 - * @param e 异常 + * @param e 异常 */ @AfterThrowing(value = "logPointCut()", throwing = "e") - public void doAfterThrowing(JoinPoint joinPoint, Exception e) - { + public void doAfterThrowing(JoinPoint joinPoint, Exception e) { handleLog(joinPoint, e, null); } - protected void handleLog(final JoinPoint joinPoint, final Exception e, Object jsonResult) - { - try - { + protected void handleLog(final JoinPoint joinPoint, final Exception e, Object jsonResult) { + try { // 获得注解 Log controllerLog = getAnnotationLog(joinPoint); - if (controllerLog == null) - { + if (controllerLog == null) { return; } @@ -94,13 +88,11 @@ public class LogAspect operLog.setJsonResult(JSON.toJSONString(jsonResult)); operLog.setOperUrl(ServletUtils.getRequest().getRequestURI()); - if (loginUser != null) - { + if (loginUser != null) { operLog.setOperName(loginUser.getUsername()); } - if (e != null) - { + if (e != null) { operLog.setStatus(BusinessStatus.FAIL.ordinal()); operLog.setErrorMsg(StringUtils.substring(e.getMessage(), 0, 2000)); } @@ -114,9 +106,7 @@ public class LogAspect getControllerMethodDescription(joinPoint, controllerLog, operLog); // 保存数据库 AsyncDao.me().execute(AsyncFactory.recordOper(operLog)); - } - catch (Exception exp) - { + } catch (Exception exp) { // 记录本地异常日志 log.error("==前置通知异常=="); log.error("异常信息:{}", exp.getMessage()); @@ -126,13 +116,12 @@ public class LogAspect /** * 获取注解中对方法的描述信息 用于Controller层注解 - * - * @param log 日志 + * + * @param log 日志 * @param operLog 操作日志 * @throws Exception */ - public void getControllerMethodDescription(JoinPoint joinPoint, Log log, SysOperLog operLog) throws Exception - { + public void getControllerMethodDescription(JoinPoint joinPoint, Log log, SysOperLog operLog) throws Exception { // 设置action动作 operLog.setBusinessType(log.businessType().ordinal()); // 设置标题 @@ -140,8 +129,7 @@ public class LogAspect // 设置操作人类别 operLog.setOperatorType(log.operatorType().ordinal()); // 是否需要保存request,参数和值 - if (log.isSaveRequestData()) - { + if (log.isSaveRequestData()) { // 获取参数的信息,传入到数据库中。 setRequestValue(joinPoint, operLog); } @@ -149,20 +137,16 @@ public class LogAspect /** * 获取请求的参数,放到log中 - * + * * @param operLog 操作日志 * @throws Exception 异常 */ - private void setRequestValue(JoinPoint joinPoint, SysOperLog operLog) throws Exception - { + private void setRequestValue(JoinPoint joinPoint, SysOperLog operLog) throws Exception { String requestMethod = operLog.getRequestMethod(); - if (HttpMethod.PUT.name().equals(requestMethod) || HttpMethod.POST.name().equals(requestMethod)) - { + if (HttpMethod.PUT.name().equals(requestMethod) || HttpMethod.POST.name().equals(requestMethod)) { String params = argsArrayToString(joinPoint.getArgs()); operLog.setOperParam(StringUtils.substring(params, 0, 2000)); - } - else - { + } else { Map paramsMap = (Map) ServletUtils.getRequest().getAttribute(HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE); operLog.setOperParam(StringUtils.substring(paramsMap.toString(), 0, 2000)); } @@ -171,14 +155,12 @@ public class LogAspect /** * 是否存在注解,如果存在就获取 */ - private Log getAnnotationLog(JoinPoint joinPoint) throws Exception - { + private Log getAnnotationLog(JoinPoint joinPoint) throws Exception { Signature signature = joinPoint.getSignature(); MethodSignature methodSignature = (MethodSignature) signature; Method method = methodSignature.getMethod(); - if (method != null) - { + if (method != null) { return method.getAnnotation(Log.class); } return null; @@ -187,15 +169,11 @@ public class LogAspect /** * 参数拼装 */ - private String argsArrayToString(Object[] paramsArray) - { + private String argsArrayToString(Object[] paramsArray) { String params = ""; - if (paramsArray != null && paramsArray.length > 0) - { - for (int i = 0; i < paramsArray.length; i++) - { - if (!isFilterObject(paramsArray[i])) - { + if (paramsArray != null && paramsArray.length > 0) { + for (int i = 0; i < paramsArray.length; i++) { + if (!isFilterObject(paramsArray[i])) { Object jsonObj = JSON.toJSON(paramsArray[i]); params += jsonObj.toString() + " "; } @@ -206,12 +184,11 @@ public class LogAspect /** * 判断是否需要过滤的对象。 - * + * * @param o 对象信息。 * @return 如果是需要过滤的对象,则返回true;否则返回false。 */ - public boolean isFilterObject(final Object o) - { + public boolean isFilterObject(final Object o) { return o instanceof MultipartFile || o instanceof HttpServletRequest || o instanceof HttpServletResponse; } } diff --git a/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/config/ApplicationConfig.java b/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/config/ApplicationConfig.java index 6cfaf79..e20f7b8 100644 --- a/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/config/ApplicationConfig.java +++ b/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/config/ApplicationConfig.java @@ -1,6 +1,7 @@ package com.hchyun.framework.config; import java.util.TimeZone; + import org.mybatis.spring.annotation.MapperScan; import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer; import org.springframework.context.annotation.Bean; @@ -17,14 +18,12 @@ import org.springframework.context.annotation.EnableAspectJAutoProxy; @EnableAspectJAutoProxy(exposeProxy = true) // 指定要扫描的dao类的包的路径 @MapperScan("com.hchyun.**.dao") -public class ApplicationConfig -{ +public class ApplicationConfig { /** * 时区配置 */ @Bean - public Jackson2ObjectMapperBuilderCustomizer jacksonObjectMapperCustomization() - { + public Jackson2ObjectMapperBuilderCustomizer jacksonObjectMapperCustomization() { return jacksonObjectMapperBuilder -> jacksonObjectMapperBuilder.timeZone(TimeZone.getDefault()); } } diff --git a/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/config/CaptchaConfig.java b/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/config/CaptchaConfig.java index 6b0372f..47e74d0 100644 --- a/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/config/CaptchaConfig.java +++ b/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/config/CaptchaConfig.java @@ -1,23 +1,23 @@ package com.hchyun.framework.config; import java.util.Properties; + import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import com.google.code.kaptcha.impl.DefaultKaptcha; import com.google.code.kaptcha.util.Config; + import static com.google.code.kaptcha.Constants.*; /** * 验证码配置 - * + * * @author hchyun */ @Configuration -public class CaptchaConfig -{ +public class CaptchaConfig { @Bean(name = "captchaProducer") - public DefaultKaptcha getKaptchaBean() - { + public DefaultKaptcha getKaptchaBean() { DefaultKaptcha defaultKaptcha = new DefaultKaptcha(); Properties properties = new Properties(); // 是否有边框 默认为true 我们可以自己设置yes,no @@ -44,8 +44,7 @@ public class CaptchaConfig } @Bean(name = "captchaProducerMath") - public DefaultKaptcha getKaptchaBeanMath() - { + public DefaultKaptcha getKaptchaBeanMath() { DefaultKaptcha defaultKaptcha = new DefaultKaptcha(); Properties properties = new Properties(); // 是否有边框 默认为true 我们可以自己设置yes,no diff --git a/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/config/DruidConfig.java b/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/config/DruidConfig.java index dfe8987..be8b330 100644 --- a/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/config/DruidConfig.java +++ b/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/config/DruidConfig.java @@ -9,6 +9,7 @@ import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.sql.DataSource; + import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.web.servlet.FilterRegistrationBean; @@ -26,16 +27,14 @@ import com.hchyun.framework.datasource.DynamicDataSource; /** * druid 配置多数据源 - * + * * @author hchyun */ @Configuration -public class DruidConfig -{ +public class DruidConfig { @Bean @ConfigurationProperties("spring.datasource.druid.master") - public DataSource masterDataSource(DruidProperties druidProperties) - { + public DataSource masterDataSource(DruidProperties druidProperties) { DruidDataSource dataSource = DruidDataSourceBuilder.create().build(); return druidProperties.dataSource(dataSource); } @@ -43,49 +42,42 @@ public class DruidConfig @Bean @ConfigurationProperties("spring.datasource.druid.slave") @ConditionalOnProperty(prefix = "spring.datasource.druid.slave", name = "enabled", havingValue = "true") - public DataSource slaveDataSource(DruidProperties druidProperties) - { + public DataSource slaveDataSource(DruidProperties druidProperties) { DruidDataSource dataSource = DruidDataSourceBuilder.create().build(); return druidProperties.dataSource(dataSource); } @Bean(name = "dynamicDataSource") @Primary - public DynamicDataSource dataSource(DataSource masterDataSource) - { + public DynamicDataSource dataSource(DataSource masterDataSource) { Map targetDataSources = new HashMap<>(); targetDataSources.put(DataSourceType.MASTER.name(), masterDataSource); setDataSource(targetDataSources, DataSourceType.SLAVE.name(), "slaveDataSource"); return new DynamicDataSource(masterDataSource, targetDataSources); } - + /** * 设置数据源 - * + * * @param targetDataSources 备选数据源集合 - * @param sourceName 数据源名称 - * @param beanName bean名称 + * @param sourceName 数据源名称 + * @param beanName bean名称 */ - public void setDataSource(Map targetDataSources, String sourceName, String beanName) - { - try - { + public void setDataSource(Map targetDataSources, String sourceName, String beanName) { + try { DataSource dataSource = SpringUtils.getBean(beanName); targetDataSources.put(sourceName, dataSource); - } - catch (Exception e) - { + } catch (Exception e) { } } /** * 去除监控页面底部的广告 */ - @SuppressWarnings({ "rawtypes", "unchecked" }) + @SuppressWarnings({"rawtypes", "unchecked"}) @Bean @ConditionalOnProperty(name = "spring.datasource.druid.statViewServlet.enabled", havingValue = "true") - public FilterRegistrationBean removeDruidFilterRegistrationBean(DruidStatProperties properties) - { + public FilterRegistrationBean removeDruidFilterRegistrationBean(DruidStatProperties properties) { // 获取web监控页面的参数 DruidStatProperties.StatViewServlet config = properties.getStatViewServlet(); // 提取common.js的配置路径 @@ -93,16 +85,14 @@ public class DruidConfig String commonJsPattern = pattern.replaceAll("\\*", "js/common.js"); final String filePath = "support/http/resources/js/common.js"; // 创建filter进行过滤 - Filter filter = new Filter() - { + Filter filter = new Filter() { @Override - public void init(javax.servlet.FilterConfig filterConfig) throws ServletException - { + public void init(javax.servlet.FilterConfig filterConfig) throws ServletException { } + @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) - throws IOException, ServletException - { + throws IOException, ServletException { chain.doFilter(request, response); // 重置缓冲区,响应头不会被重置 response.resetBuffer(); @@ -113,9 +103,9 @@ public class DruidConfig text = text.replaceAll("powered.*?shrek.wang", ""); response.getWriter().write(text); } + @Override - public void destroy() - { + public void destroy() { } }; FilterRegistrationBean registrationBean = new FilterRegistrationBean(); diff --git a/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/config/FastJson2JsonRedisSerializer.java b/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/config/FastJson2JsonRedisSerializer.java index 7017ef6..faaa3d2 100644 --- a/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/config/FastJson2JsonRedisSerializer.java +++ b/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/config/FastJson2JsonRedisSerializer.java @@ -9,15 +9,15 @@ import org.springframework.data.redis.serializer.RedisSerializer; import org.springframework.data.redis.serializer.SerializationException; import com.alibaba.fastjson.parser.ParserConfig; import org.springframework.util.Assert; + import java.nio.charset.Charset; /** * Redis使用FastJson序列化 - * + * * @author hchyun */ -public class FastJson2JsonRedisSerializer implements RedisSerializer -{ +public class FastJson2JsonRedisSerializer implements RedisSerializer { @SuppressWarnings("unused") private ObjectMapper objectMapper = new ObjectMapper(); @@ -25,32 +25,26 @@ public class FastJson2JsonRedisSerializer implements RedisSerializer private Class clazz; - static - { + static { ParserConfig.getGlobalInstance().setAutoTypeSupport(true); } - public FastJson2JsonRedisSerializer(Class clazz) - { + public FastJson2JsonRedisSerializer(Class clazz) { super(); this.clazz = clazz; } @Override - public byte[] serialize(T t) throws SerializationException - { - if (t == null) - { + public byte[] serialize(T t) throws SerializationException { + if (t == null) { return new byte[0]; } return JSON.toJSONString(t, SerializerFeature.WriteClassName).getBytes(DEFAULT_CHARSET); } @Override - public T deserialize(byte[] bytes) throws SerializationException - { - if (bytes == null || bytes.length <= 0) - { + public T deserialize(byte[] bytes) throws SerializationException { + if (bytes == null || bytes.length <= 0) { return null; } String str = new String(bytes, DEFAULT_CHARSET); @@ -58,14 +52,12 @@ public class FastJson2JsonRedisSerializer implements RedisSerializer return JSON.parseObject(str, clazz); } - public void setObjectMapper(ObjectMapper objectMapper) - { + public void setObjectMapper(ObjectMapper objectMapper) { Assert.notNull(objectMapper, "'objectMapper' must not be null"); this.objectMapper = objectMapper; } - protected JavaType getJavaType(Class clazz) - { + protected JavaType getJavaType(Class clazz) { return TypeFactory.defaultInstance().constructType(clazz); } } diff --git a/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/config/FilterConfig.java b/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/config/FilterConfig.java index eaab8d3..3475e21 100644 --- a/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/config/FilterConfig.java +++ b/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/config/FilterConfig.java @@ -3,6 +3,7 @@ package com.hchyun.framework.config; import java.util.HashMap; import java.util.Map; import javax.servlet.DispatcherType; + import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.web.servlet.FilterRegistrationBean; import org.springframework.context.annotation.Bean; @@ -17,8 +18,7 @@ import com.hchyun.common.utils.StringUtils; * @author hchyun */ @Configuration -public class FilterConfig -{ +public class FilterConfig { @Value("${xss.enabled}") private String enabled; @@ -28,10 +28,9 @@ public class FilterConfig @Value("${xss.urlPatterns}") private String urlPatterns; - @SuppressWarnings({ "rawtypes", "unchecked" }) + @SuppressWarnings({"rawtypes", "unchecked"}) @Bean - public FilterRegistrationBean xssFilterRegistration() - { + public FilterRegistrationBean xssFilterRegistration() { FilterRegistrationBean registration = new FilterRegistrationBean(); registration.setDispatcherTypes(DispatcherType.REQUEST); registration.setFilter(new XssFilter()); @@ -45,10 +44,9 @@ public class FilterConfig return registration; } - @SuppressWarnings({ "rawtypes", "unchecked" }) + @SuppressWarnings({"rawtypes", "unchecked"}) @Bean - public FilterRegistrationBean someFilterRegistration() - { + public FilterRegistrationBean someFilterRegistration() { FilterRegistrationBean registration = new FilterRegistrationBean(); registration.setFilter(new RepeatableFilter()); registration.addUrlPatterns("/*"); diff --git a/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/config/KaptchaTextCreator.java b/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/config/KaptchaTextCreator.java index e93efe3..f45f856 100644 --- a/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/config/KaptchaTextCreator.java +++ b/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/config/KaptchaTextCreator.java @@ -1,69 +1,55 @@ package com.hchyun.framework.config; import java.util.Random; + import com.google.code.kaptcha.text.impl.DefaultTextCreator; /** * 验证码文本生成器 - * + * * @author hchyun */ -public class KaptchaTextCreator extends DefaultTextCreator -{ +public class KaptchaTextCreator extends DefaultTextCreator { private static final String[] CNUMBERS = "0,1,2,3,4,5,6,7,8,9,10".split(","); @Override - public String getText() - { + public String getText() { Integer result = 0; Random random = new Random(); int x = random.nextInt(10); int y = random.nextInt(10); StringBuilder suChinese = new StringBuilder(); int randomoperands = (int) Math.round(Math.random() * 2); - if (randomoperands == 0) - { + if (randomoperands == 0) { result = x * y; suChinese.append(CNUMBERS[x]); suChinese.append("*"); suChinese.append(CNUMBERS[y]); - } - else if (randomoperands == 1) - { - if (!(x == 0) && y % x == 0) - { + } else if (randomoperands == 1) { + if (!(x == 0) && y % x == 0) { result = y / x; suChinese.append(CNUMBERS[y]); suChinese.append("/"); suChinese.append(CNUMBERS[x]); - } - else - { + } else { result = x + y; suChinese.append(CNUMBERS[x]); suChinese.append("+"); suChinese.append(CNUMBERS[y]); } - } - else if (randomoperands == 2) - { - if (x >= y) - { + } else if (randomoperands == 2) { + if (x >= y) { result = x - y; suChinese.append(CNUMBERS[x]); suChinese.append("-"); suChinese.append(CNUMBERS[y]); - } - else - { + } else { result = y - x; suChinese.append(CNUMBERS[y]); suChinese.append("-"); suChinese.append(CNUMBERS[x]); } - } - else - { + } else { result = x + y; suChinese.append(CNUMBERS[x]); suChinese.append("+"); diff --git a/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/config/MyBatisConfig.java b/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/config/MyBatisConfig.java index bdcbd86..4cde916 100644 --- a/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/config/MyBatisConfig.java +++ b/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/config/MyBatisConfig.java @@ -5,6 +5,7 @@ import java.util.ArrayList; import java.util.HashSet; import java.util.List; import javax.sql.DataSource; + import org.apache.ibatis.io.VFS; import org.apache.ibatis.session.SqlSessionFactory; import org.mybatis.spring.SqlSessionFactoryBean; @@ -24,74 +25,57 @@ import org.springframework.util.ClassUtils; /** * Mybatis支持*匹配扫描包 - * + * * @author hchyun */ @Configuration -public class MyBatisConfig -{ +public class MyBatisConfig { @Autowired private Environment env; static final String DEFAULT_RESOURCE_PATTERN = "**/*.class"; - public static String setTypeAliasesPackage(String typeAliasesPackage) - { + public static String setTypeAliasesPackage(String typeAliasesPackage) { ResourcePatternResolver resolver = (ResourcePatternResolver) new PathMatchingResourcePatternResolver(); MetadataReaderFactory metadataReaderFactory = new CachingMetadataReaderFactory(resolver); List allResult = new ArrayList(); - try - { - for (String aliasesPackage : typeAliasesPackage.split(",")) - { + try { + for (String aliasesPackage : typeAliasesPackage.split(",")) { List result = new ArrayList(); aliasesPackage = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX + ClassUtils.convertClassNameToResourcePath(aliasesPackage.trim()) + "/" + DEFAULT_RESOURCE_PATTERN; Resource[] resources = resolver.getResources(aliasesPackage); - if (resources != null && resources.length > 0) - { + if (resources != null && resources.length > 0) { MetadataReader metadataReader = null; - for (Resource resource : resources) - { - if (resource.isReadable()) - { + for (Resource resource : resources) { + if (resource.isReadable()) { metadataReader = metadataReaderFactory.getMetadataReader(resource); - try - { + try { result.add(Class.forName(metadataReader.getClassMetadata().getClassName()).getPackage().getName()); - } - catch (ClassNotFoundException e) - { + } catch (ClassNotFoundException e) { e.printStackTrace(); } } } } - if (result.size() > 0) - { + if (result.size() > 0) { HashSet hashResult = new HashSet(result); allResult.addAll(hashResult); } } - if (allResult.size() > 0) - { + if (allResult.size() > 0) { typeAliasesPackage = String.join(",", (String[]) allResult.toArray(new String[0])); - } - else - { + } else { throw new RuntimeException("mybatis typeAliasesPackage 路径扫描错误,参数typeAliasesPackage:" + typeAliasesPackage + "未找到任何包"); } - } - catch (IOException e) - { + } catch (IOException e) { e.printStackTrace(); } return typeAliasesPackage; } @Bean - public SqlSessionFactory sqlSessionFactory(DataSource dataSource) throws Exception - { + public SqlSessionFactory sqlSessionFactory(DataSource dataSource) throws Exception { String typeAliasesPackage = env.getProperty("mybatis.typeAliasesPackage"); String mapperLocations = env.getProperty("mybatis.mapperLocations"); String configLocation = env.getProperty("mybatis.configLocation"); diff --git a/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/config/RedisConfig.java b/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/config/RedisConfig.java index 67ccf23..87699c7 100644 --- a/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/config/RedisConfig.java +++ b/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/config/RedisConfig.java @@ -13,17 +13,15 @@ import com.fasterxml.jackson.databind.ObjectMapper; /** * redis配置 - * + * * @author hchyun */ @Configuration @EnableCaching -public class RedisConfig extends CachingConfigurerSupport -{ +public class RedisConfig extends CachingConfigurerSupport { @Bean - @SuppressWarnings(value = { "unchecked", "rawtypes" }) - public RedisTemplate redisTemplate(RedisConnectionFactory connectionFactory) - { + @SuppressWarnings(value = {"unchecked", "rawtypes"}) + public RedisTemplate redisTemplate(RedisConnectionFactory connectionFactory) { RedisTemplate template = new RedisTemplate<>(); template.setConnectionFactory(connectionFactory); diff --git a/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/config/ResourcesConfig.java b/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/config/ResourcesConfig.java index 90afbbf..d8bd9b6 100644 --- a/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/config/ResourcesConfig.java +++ b/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/config/ResourcesConfig.java @@ -56,7 +56,7 @@ public class ResourcesConfig implements WebMvcConfigurer { // 设置访问源请求方法 config.addAllowedMethod("*"); // 对接口配置跨域设置 - source.registerCorsConfiguration("/**" , config); + source.registerCorsConfiguration("/**", config); return new CorsFilter(source); } } \ No newline at end of file diff --git a/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/config/ServerConfig.java b/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/config/ServerConfig.java index ad4ad79..0e807ad 100644 --- a/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/config/ServerConfig.java +++ b/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/config/ServerConfig.java @@ -1,30 +1,28 @@ package com.hchyun.framework.config; import javax.servlet.http.HttpServletRequest; + import org.springframework.stereotype.Component; import com.hchyun.common.utils.ServletUtils; /** * 服务相关配置 - * + * * @author hchyun */ @Component -public class ServerConfig -{ +public class ServerConfig { /** * 获取完整的请求路径,包括:域名,端口,上下文访问路径 - * + * * @return 服务地址 */ - public String getUrl() - { + public String getUrl() { HttpServletRequest request = ServletUtils.getRequest(); return getDomain(request); } - public static String getDomain(HttpServletRequest request) - { + public static String getDomain(HttpServletRequest request) { StringBuffer url = request.getRequestURL(); String contextPath = request.getServletContext().getContextPath(); return url.delete(url.length() - request.getRequestURI().length(), url.length()).append(contextPath).toString(); diff --git a/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/config/ThreadPoolConfig.java b/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/config/ThreadPoolConfig.java index a70d246..0305ffb 100644 --- a/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/config/ThreadPoolConfig.java +++ b/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/config/ThreadPoolConfig.java @@ -3,6 +3,7 @@ package com.hchyun.framework.config; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledThreadPoolExecutor; import java.util.concurrent.ThreadPoolExecutor; + import org.apache.commons.lang3.concurrent.BasicThreadFactory; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -15,8 +16,7 @@ import com.hchyun.common.utils.Threads; * @author hchyun **/ @Configuration -public class ThreadPoolConfig -{ +public class ThreadPoolConfig { // 核心线程池大小 private int corePoolSize = 50; @@ -30,8 +30,7 @@ public class ThreadPoolConfig private int keepAliveSeconds = 300; @Bean(name = "threadPoolTaskExecutor") - public ThreadPoolTaskExecutor threadPoolTaskExecutor() - { + public ThreadPoolTaskExecutor threadPoolTaskExecutor() { ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); executor.setMaxPoolSize(maxPoolSize); executor.setCorePoolSize(corePoolSize); @@ -46,14 +45,11 @@ public class ThreadPoolConfig * 执行周期性或定时任务 */ @Bean(name = "scheduledExecutorService") - protected ScheduledExecutorService scheduledExecutorService() - { + protected ScheduledExecutorService scheduledExecutorService() { return new ScheduledThreadPoolExecutor(corePoolSize, - new BasicThreadFactory.Builder().namingPattern("schedule-pool-%d").daemon(true).build()) - { + new BasicThreadFactory.Builder().namingPattern("schedule-pool-%d").daemon(true).build()) { @Override - protected void afterExecute(Runnable r, Throwable t) - { + protected void afterExecute(Runnable r, Throwable t) { super.afterExecute(r, t); Threads.printException(r, t); } diff --git a/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/config/properties/DruidProperties.java b/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/config/properties/DruidProperties.java index 8e545ce..210614f 100644 --- a/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/config/properties/DruidProperties.java +++ b/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/config/properties/DruidProperties.java @@ -6,12 +6,11 @@ import com.alibaba.druid.pool.DruidDataSource; /** * druid 配置属性 - * + * * @author hchyun */ @Configuration -public class DruidProperties -{ +public class DruidProperties { @Value("${spring.datasource.druid.initialSize}") private int initialSize; @@ -45,8 +44,7 @@ public class DruidProperties @Value("${spring.datasource.druid.testOnReturn}") private boolean testOnReturn; - public DruidDataSource dataSource(DruidDataSource datasource) - { + public DruidDataSource dataSource(DruidDataSource datasource) { /** 配置初始化大小、最小、最大 */ datasource.setInitialSize(initialSize); datasource.setMaxActive(maxActive); diff --git a/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/dao/AsyncDao.java b/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/dao/AsyncDao.java index 8b4cb65..fe2bde8 100644 --- a/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/dao/AsyncDao.java +++ b/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/dao/AsyncDao.java @@ -3,16 +3,16 @@ package com.hchyun.framework.dao; import java.util.TimerTask; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; + import com.hchyun.common.utils.Threads; import com.hchyun.common.utils.spring.SpringUtils; /** * 异步任务管理器 - * + * * @author hchyun */ -public class AsyncDao -{ +public class AsyncDao { /** * 操作延迟10毫秒 */ @@ -26,30 +26,28 @@ public class AsyncDao /** * 单例模式 */ - private AsyncDao(){} + private AsyncDao() { + } private static AsyncDao me = new AsyncDao(); - public static AsyncDao me() - { + public static AsyncDao me() { return me; } /** * 执行任务 - * + * * @param task 任务 */ - public void execute(TimerTask task) - { + public void execute(TimerTask task) { executor.schedule(task, OPERATE_DELAY_TIME, TimeUnit.MILLISECONDS); } /** * 停止任务线程池 */ - public void shutdown() - { + public void shutdown() { Threads.shutdownAndAwaitTermination(executor); } } diff --git a/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/dao/factory/AsyncFactory.java b/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/dao/factory/AsyncFactory.java index 6bc242c..7993aab 100644 --- a/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/dao/factory/AsyncFactory.java +++ b/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/dao/factory/AsyncFactory.java @@ -1,6 +1,7 @@ package com.hchyun.framework.dao.factory; import java.util.TimerTask; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.hchyun.common.constant.Constants; @@ -17,32 +18,28 @@ import eu.bitwalker.useragentutils.UserAgent; /** * 异步工厂(产生任务用) - * + * * @author hchyun */ -public class AsyncFactory -{ +public class AsyncFactory { private static final Logger sys_user_logger = LoggerFactory.getLogger("sys-user"); /** * 记录登录信息 - * + * * @param username 用户名 - * @param status 状态 - * @param message 消息 - * @param args 列表 + * @param status 状态 + * @param message 消息 + * @param args 列表 * @return 任务task */ public static TimerTask recordLogininfor(final String username, final String status, final String message, - final Object... args) - { + final Object... args) { final UserAgent userAgent = UserAgent.parseUserAgentString(ServletUtils.getRequest().getHeader("User-Agent")); final String ip = IpUtils.getIpAddr(ServletUtils.getRequest()); - return new TimerTask() - { + return new TimerTask() { @Override - public void run() - { + public void run() { String address = AddressUtils.getRealAddressByIP(ip); StringBuilder s = new StringBuilder(); s.append(LogUtils.getBlock(ip)); @@ -65,12 +62,9 @@ public class AsyncFactory logininfor.setOs(os); logininfor.setMsg(message); // 日志状态 - if (Constants.LOGIN_SUCCESS.equals(status) || Constants.LOGOUT.equals(status)) - { + if (Constants.LOGIN_SUCCESS.equals(status) || Constants.LOGOUT.equals(status)) { logininfor.setStatus(Constants.SUCCESS); - } - else if (Constants.LOGIN_FAIL.equals(status)) - { + } else if (Constants.LOGIN_FAIL.equals(status)) { logininfor.setStatus(Constants.FAIL); } // 插入数据 @@ -81,17 +75,14 @@ public class AsyncFactory /** * 操作日志记录 - * + * * @param operLog 操作日志信息 * @return 任务task */ - public static TimerTask recordOper(final SysOperLog operLog) - { - return new TimerTask() - { + public static TimerTask recordOper(final SysOperLog operLog) { + return new TimerTask() { @Override - public void run() - { + public void run() { // 远程查询操作地点 operLog.setOperLocation(AddressUtils.getRealAddressByIP(operLog.getOperIp())); SpringUtils.getBean(ISysOperLogService.class).insertOperlog(operLog); diff --git a/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/datasource/DynamicDataSource.java b/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/datasource/DynamicDataSource.java index 077f199..d2715d1 100644 --- a/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/datasource/DynamicDataSource.java +++ b/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/datasource/DynamicDataSource.java @@ -2,25 +2,23 @@ package com.hchyun.framework.datasource; import java.util.Map; import javax.sql.DataSource; + import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource; /** * 动态数据源 - * + * * @author hchyun */ -public class DynamicDataSource extends AbstractRoutingDataSource -{ - public DynamicDataSource(DataSource defaultTargetDataSource, Map targetDataSources) - { +public class DynamicDataSource extends AbstractRoutingDataSource { + public DynamicDataSource(DataSource defaultTargetDataSource, Map targetDataSources) { super.setDefaultTargetDataSource(defaultTargetDataSource); super.setTargetDataSources(targetDataSources); super.afterPropertiesSet(); } @Override - protected Object determineCurrentLookupKey() - { + protected Object determineCurrentLookupKey() { return DynamicDataSourceContextHolder.getDataSourceType(); } } \ No newline at end of file diff --git a/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/datasource/DynamicDataSourceContextHolder.java b/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/datasource/DynamicDataSourceContextHolder.java index 2b260bb..4e971b9 100644 --- a/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/datasource/DynamicDataSourceContextHolder.java +++ b/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/datasource/DynamicDataSourceContextHolder.java @@ -5,24 +5,22 @@ import org.slf4j.LoggerFactory; /** * 数据源切换处理 - * + * * @author hchyun */ -public class DynamicDataSourceContextHolder -{ +public class DynamicDataSourceContextHolder { public static final Logger log = LoggerFactory.getLogger(DynamicDataSourceContextHolder.class); /** * 使用ThreadLocal维护变量,ThreadLocal为每个使用该变量的线程提供独立的变量副本, - * 所以每一个线程都可以独立地改变自己的副本,而不会影响其它线程所对应的副本。 + * 所以每一个线程都可以独立地改变自己的副本,而不会影响其它线程所对应的副本。 */ private static final ThreadLocal CONTEXT_HOLDER = new ThreadLocal<>(); /** * 设置数据源的变量 */ - public static void setDataSourceType(String dsType) - { + public static void setDataSourceType(String dsType) { log.info("切换到{}数据源", dsType); CONTEXT_HOLDER.set(dsType); } @@ -30,16 +28,14 @@ public class DynamicDataSourceContextHolder /** * 获得数据源的变量 */ - public static String getDataSourceType() - { + public static String getDataSourceType() { return CONTEXT_HOLDER.get(); } /** * 清空数据源变量 */ - public static void clearDataSourceType() - { + public static void clearDataSourceType() { CONTEXT_HOLDER.remove(); } } diff --git a/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/interceptor/RepeatSubmitInterceptor.java b/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/interceptor/RepeatSubmitInterceptor.java index b73762f..d8bf0bd 100644 --- a/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/interceptor/RepeatSubmitInterceptor.java +++ b/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/interceptor/RepeatSubmitInterceptor.java @@ -3,6 +3,7 @@ package com.hchyun.framework.interceptor; import java.lang.reflect.Method; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; + import org.springframework.stereotype.Component; import org.springframework.web.method.HandlerMethod; import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; @@ -17,29 +18,22 @@ import com.hchyun.common.utils.ServletUtils; * @author hchyun */ @Component -public abstract class RepeatSubmitInterceptor extends HandlerInterceptorAdapter -{ +public abstract class RepeatSubmitInterceptor extends HandlerInterceptorAdapter { @Override - public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception - { - if (handler instanceof HandlerMethod) - { + public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { + if (handler instanceof HandlerMethod) { HandlerMethod handlerMethod = (HandlerMethod) handler; Method method = handlerMethod.getMethod(); RepeatSubmit annotation = method.getAnnotation(RepeatSubmit.class); - if (annotation != null) - { - if (this.isRepeatSubmit(request)) - { + if (annotation != null) { + if (this.isRepeatSubmit(request)) { AjaxResult ajaxResult = AjaxResult.error("不允许重复提交,请稍后再试"); ServletUtils.renderString(response, JSONObject.toJSONString(ajaxResult)); return false; } } return true; - } - else - { + } else { return super.preHandle(request, response, handler); } } diff --git a/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/security/filter/JwtAuthenticationTokenFilter.java b/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/security/filter/JwtAuthenticationTokenFilter.java index cdc193f..cce40dd 100644 --- a/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/security/filter/JwtAuthenticationTokenFilter.java +++ b/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/security/filter/JwtAuthenticationTokenFilter.java @@ -5,6 +5,7 @@ import javax.servlet.FilterChain; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; import org.springframework.security.core.context.SecurityContextHolder; @@ -19,22 +20,19 @@ import com.hchyun.framework.web.service.TokenService; /** * todo token 拦截器 * token过滤器 验证token有效性 - * + * * @author hchyun */ @Component -public class JwtAuthenticationTokenFilter extends OncePerRequestFilter -{ +public class JwtAuthenticationTokenFilter extends OncePerRequestFilter { @Autowired private TokenService tokenService; @Override protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) - throws ServletException, IOException - { + throws ServletException, IOException { LoginUser loginUser = tokenService.getLoginUser(request); - if (StringUtils.isNotNull(loginUser) && StringUtils.isNull(SecurityUtils.getAuthentication())) - { + if (StringUtils.isNotNull(loginUser) && StringUtils.isNull(SecurityUtils.getAuthentication())) { tokenService.verifyToken(loginUser); UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(loginUser, null, loginUser.getAuthorities()); authenticationToken.setDetails(new WebAuthenticationDetailsSource().buildDetails(request)); diff --git a/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/security/handle/AuthenticationEntryPointImpl.java b/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/security/handle/AuthenticationEntryPointImpl.java index fcf0ee5..324740c 100644 --- a/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/security/handle/AuthenticationEntryPointImpl.java +++ b/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/security/handle/AuthenticationEntryPointImpl.java @@ -4,6 +4,7 @@ import java.io.IOException; import java.io.Serializable; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; + import org.springframework.security.core.AuthenticationException; import org.springframework.security.web.AuthenticationEntryPoint; import org.springframework.stereotype.Component; @@ -15,18 +16,16 @@ import com.hchyun.common.utils.StringUtils; /** * 认证失败处理类 返回未授权 - * + * * @author hchyun */ @Component -public class AuthenticationEntryPointImpl implements AuthenticationEntryPoint, Serializable -{ +public class AuthenticationEntryPointImpl implements AuthenticationEntryPoint, Serializable { private static final long serialVersionUID = -8970718410437077606L; @Override public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException e) - throws IOException - { + throws IOException { int code = HttpStatus.UNAUTHORIZED; String msg = StringUtils.format("请求访问:{},认证失败,无法访问系统资源", request.getRequestURI()); ServletUtils.renderString(response, JSON.toJSONString(AjaxResult.error(code, msg))); diff --git a/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/security/handle/LogoutSuccessHandlerImpl.java b/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/security/handle/LogoutSuccessHandlerImpl.java index 7053c45..3d6cd01 100644 --- a/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/security/handle/LogoutSuccessHandlerImpl.java +++ b/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/security/handle/LogoutSuccessHandlerImpl.java @@ -4,6 +4,7 @@ import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Configuration; import org.springframework.security.core.Authentication; @@ -21,27 +22,24 @@ import com.hchyun.framework.web.service.TokenService; /** * 自定义退出处理类 返回成功 - * + * * @author hchyun */ @Configuration -public class LogoutSuccessHandlerImpl implements LogoutSuccessHandler -{ +public class LogoutSuccessHandlerImpl implements LogoutSuccessHandler { @Autowired private TokenService tokenService; /** * 退出处理 - * + * * @return */ @Override public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) - throws IOException, ServletException - { + throws IOException, ServletException { LoginUser loginUser = tokenService.getLoginUser(request); - if (StringUtils.isNotNull(loginUser)) - { + if (StringUtils.isNotNull(loginUser)) { String userName = loginUser.getUsername(); // 删除用户缓存记录 tokenService.delLoginUser(loginUser.getToken()); diff --git a/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/web/domain/Server.java b/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/web/domain/Server.java index 118706e..98d193f 100644 --- a/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/web/domain/Server.java +++ b/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/web/domain/Server.java @@ -4,6 +4,7 @@ import java.net.UnknownHostException; import java.util.LinkedList; import java.util.List; import java.util.Properties; + import com.hchyun.common.utils.Arith; import com.hchyun.common.utils.ip.IpUtils; import com.hchyun.framework.web.domain.server.Cpu; @@ -23,13 +24,12 @@ import oshi.util.Util; /** * 服务器相关信息 - * + * * @author hchyun */ -public class Server -{ +public class Server { private static final int OSHI_WAIT_SECOND = 1000; - + /** * CPU相关信息 */ @@ -55,58 +55,47 @@ public class Server */ private List sysFiles = new LinkedList(); - public Cpu getCpu() - { + public Cpu getCpu() { return cpu; } - public void setCpu(Cpu cpu) - { + public void setCpu(Cpu cpu) { this.cpu = cpu; } - public Mem getMem() - { + public Mem getMem() { return mem; } - public void setMem(Mem mem) - { + public void setMem(Mem mem) { this.mem = mem; } - public Jvm getJvm() - { + public Jvm getJvm() { return jvm; } - public void setJvm(Jvm jvm) - { + public void setJvm(Jvm jvm) { this.jvm = jvm; } - public Sys getSys() - { + public Sys getSys() { return sys; } - public void setSys(Sys sys) - { + public void setSys(Sys sys) { this.sys = sys; } - public List getSysFiles() - { + public List getSysFiles() { return sysFiles; } - public void setSysFiles(List sysFiles) - { + public void setSysFiles(List sysFiles) { this.sysFiles = sysFiles; } - public void copyTo() throws Exception - { + public void copyTo() throws Exception { SystemInfo si = new SystemInfo(); HardwareAbstractionLayer hal = si.getHardware(); @@ -124,8 +113,7 @@ public class Server /** * 设置CPU信息 */ - private void setCpuInfo(CentralProcessor processor) - { + private void setCpuInfo(CentralProcessor processor) { // CPU信息 long[] prevTicks = processor.getSystemCpuLoadTicks(); Util.sleep(OSHI_WAIT_SECOND); @@ -150,8 +138,7 @@ public class Server /** * 设置内存信息 */ - private void setMemInfo(GlobalMemory memory) - { + private void setMemInfo(GlobalMemory memory) { mem.setTotal(memory.getTotal()); mem.setUsed(memory.getTotal() - memory.getAvailable()); mem.setFree(memory.getAvailable()); @@ -160,8 +147,7 @@ public class Server /** * 设置服务器信息 */ - private void setSysInfo() - { + private void setSysInfo() { Properties props = System.getProperties(); sys.setComputerName(IpUtils.getHostName()); sys.setComputerIp(IpUtils.getHostIp()); @@ -173,8 +159,7 @@ public class Server /** * 设置Java虚拟机 */ - private void setJvmInfo() throws UnknownHostException - { + private void setJvmInfo() throws UnknownHostException { Properties props = System.getProperties(); jvm.setTotal(Runtime.getRuntime().totalMemory()); jvm.setMax(Runtime.getRuntime().maxMemory()); @@ -186,12 +171,10 @@ public class Server /** * 设置磁盘信息 */ - private void setSysFiles(OperatingSystem os) - { + private void setSysFiles(OperatingSystem os) { FileSystem fileSystem = os.getFileSystem(); List fsArray = fileSystem.getFileStores(); - for (OSFileStore fs : fsArray) - { + for (OSFileStore fs : fsArray) { long free = fs.getUsableSpace(); long total = fs.getTotalSpace(); long used = total - free; @@ -209,31 +192,23 @@ public class Server /** * 字节转换 - * + * * @param size 字节大小 * @return 转换后值 */ - public String convertFileSize(long size) - { + public String convertFileSize(long size) { long kb = 1024; long mb = kb * 1024; long gb = mb * 1024; - if (size >= gb) - { + if (size >= gb) { return String.format("%.1f GB", (float) size / gb); - } - else if (size >= mb) - { + } else if (size >= mb) { float f = (float) size / mb; return String.format(f > 100 ? "%.0f MB" : "%.1f MB", f); - } - else if (size >= kb) - { + } else if (size >= kb) { float f = (float) size / kb; return String.format(f > 100 ? "%.0f KB" : "%.1f KB", f); - } - else - { + } else { return String.format("%d B", size); } } diff --git a/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/web/domain/server/Cpu.java b/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/web/domain/server/Cpu.java index 4d80232..2992c0b 100644 --- a/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/web/domain/server/Cpu.java +++ b/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/web/domain/server/Cpu.java @@ -4,11 +4,10 @@ import com.hchyun.common.utils.Arith; /** * CPU相关信息 - * + * * @author hchyun */ -public class Cpu -{ +public class Cpu { /** * 核心数 */ @@ -39,63 +38,51 @@ public class Cpu */ private double free; - public int getCpuNum() - { + public int getCpuNum() { return cpuNum; } - public void setCpuNum(int cpuNum) - { + public void setCpuNum(int cpuNum) { this.cpuNum = cpuNum; } - public double getTotal() - { + public double getTotal() { return Arith.round(Arith.mul(total, 100), 2); } - public void setTotal(double total) - { + public void setTotal(double total) { this.total = total; } - public double getSys() - { + public double getSys() { return Arith.round(Arith.mul(sys / total, 100), 2); } - public void setSys(double sys) - { + public void setSys(double sys) { this.sys = sys; } - public double getUsed() - { + public double getUsed() { return Arith.round(Arith.mul(used / total, 100), 2); } - public void setUsed(double used) - { + public void setUsed(double used) { this.used = used; } - public double getWait() - { + public double getWait() { return Arith.round(Arith.mul(wait / total, 100), 2); } - public void setWait(double wait) - { + public void setWait(double wait) { this.wait = wait; } - public double getFree() - { + public double getFree() { return Arith.round(Arith.mul(free / total, 100), 2); } - public void setFree(double free) - { + public void setFree(double free) { this.free = free; } } diff --git a/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/web/domain/server/Jvm.java b/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/web/domain/server/Jvm.java index ccd1ecc..f1fddf8 100644 --- a/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/web/domain/server/Jvm.java +++ b/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/web/domain/server/Jvm.java @@ -1,16 +1,16 @@ package com.hchyun.framework.web.domain.server; import java.lang.management.ManagementFactory; + import com.hchyun.common.utils.Arith; import com.hchyun.common.utils.DateUtils; /** * JVM相关信息 - * + * * @author hchyun */ -public class Jvm -{ +public class Jvm { /** * 当前JVM占用的内存总数(M) */ @@ -36,87 +36,72 @@ public class Jvm */ private String home; - public double getTotal() - { + public double getTotal() { return Arith.div(total, (1024 * 1024), 2); } - public void setTotal(double total) - { + public void setTotal(double total) { this.total = total; } - public double getMax() - { + public double getMax() { return Arith.div(max, (1024 * 1024), 2); } - public void setMax(double max) - { + public void setMax(double max) { this.max = max; } - public double getFree() - { + public double getFree() { return Arith.div(free, (1024 * 1024), 2); } - public void setFree(double free) - { + public void setFree(double free) { this.free = free; } - public double getUsed() - { + public double getUsed() { return Arith.div(total - free, (1024 * 1024), 2); } - public double getUsage() - { + public double getUsage() { return Arith.mul(Arith.div(total - free, total, 4), 100); } /** * 获取JDK名称 */ - public String getName() - { + public String getName() { return ManagementFactory.getRuntimeMXBean().getVmName(); } - public String getVersion() - { + public String getVersion() { return version; } - public void setVersion(String version) - { + public void setVersion(String version) { this.version = version; } - public String getHome() - { + public String getHome() { return home; } - public void setHome(String home) - { + public void setHome(String home) { this.home = home; } /** * JDK启动时间 */ - public String getStartTime() - { + public String getStartTime() { return DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, DateUtils.getServerStartDate()); } /** * JDK运行时间 */ - public String getRunTime() - { + public String getRunTime() { return DateUtils.getDatePoor(DateUtils.getNowDate(), DateUtils.getServerStartDate()); } } diff --git a/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/web/domain/server/Mem.java b/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/web/domain/server/Mem.java index 8a0ee5e..64f21fa 100644 --- a/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/web/domain/server/Mem.java +++ b/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/web/domain/server/Mem.java @@ -4,11 +4,10 @@ import com.hchyun.common.utils.Arith; /** * 內存相关信息 - * + * * @author hchyun */ -public class Mem -{ +public class Mem { /** * 内存总量 */ @@ -24,38 +23,31 @@ public class Mem */ private double free; - public double getTotal() - { + public double getTotal() { return Arith.div(total, (1024 * 1024 * 1024), 2); } - public void setTotal(long total) - { + public void setTotal(long total) { this.total = total; } - public double getUsed() - { + public double getUsed() { return Arith.div(used, (1024 * 1024 * 1024), 2); } - public void setUsed(long used) - { + public void setUsed(long used) { this.used = used; } - public double getFree() - { + public double getFree() { return Arith.div(free, (1024 * 1024 * 1024), 2); } - public void setFree(long free) - { + public void setFree(long free) { this.free = free; } - public double getUsage() - { + public double getUsage() { return Arith.mul(Arith.div(used, total, 4), 100); } } diff --git a/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/web/domain/server/Sys.java b/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/web/domain/server/Sys.java index 20357d6..8d9dc7d 100644 --- a/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/web/domain/server/Sys.java +++ b/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/web/domain/server/Sys.java @@ -2,11 +2,10 @@ package com.hchyun.framework.web.domain.server; /** * 系统相关信息 - * + * * @author hchyun */ -public class Sys -{ +public class Sys { /** * 服务器名称 */ @@ -32,53 +31,43 @@ public class Sys */ private String osArch; - public String getComputerName() - { + public String getComputerName() { return computerName; } - public void setComputerName(String computerName) - { + public void setComputerName(String computerName) { this.computerName = computerName; } - public String getComputerIp() - { + public String getComputerIp() { return computerIp; } - public void setComputerIp(String computerIp) - { + public void setComputerIp(String computerIp) { this.computerIp = computerIp; } - public String getUserDir() - { + public String getUserDir() { return userDir; } - public void setUserDir(String userDir) - { + public void setUserDir(String userDir) { this.userDir = userDir; } - public String getOsName() - { + public String getOsName() { return osName; } - public void setOsName(String osName) - { + public void setOsName(String osName) { this.osName = osName; } - public String getOsArch() - { + public String getOsArch() { return osArch; } - public void setOsArch(String osArch) - { + public void setOsArch(String osArch) { this.osArch = osArch; } } diff --git a/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/web/domain/server/SysFile.java b/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/web/domain/server/SysFile.java index a609d39..4d0be1c 100644 --- a/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/web/domain/server/SysFile.java +++ b/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/web/domain/server/SysFile.java @@ -2,11 +2,10 @@ package com.hchyun.framework.web.domain.server; /** * 系统文件相关信息 - * + * * @author hchyun */ -public class SysFile -{ +public class SysFile { /** * 盘符路径 */ @@ -42,73 +41,59 @@ public class SysFile */ private double usage; - public String getDirName() - { + public String getDirName() { return dirName; } - public void setDirName(String dirName) - { + public void setDirName(String dirName) { this.dirName = dirName; } - public String getSysTypeName() - { + public String getSysTypeName() { return sysTypeName; } - public void setSysTypeName(String sysTypeName) - { + public void setSysTypeName(String sysTypeName) { this.sysTypeName = sysTypeName; } - public String getTypeName() - { + public String getTypeName() { return typeName; } - public void setTypeName(String typeName) - { + public void setTypeName(String typeName) { this.typeName = typeName; } - public String getTotal() - { + public String getTotal() { return total; } - public void setTotal(String total) - { + public void setTotal(String total) { this.total = total; } - public String getFree() - { + public String getFree() { return free; } - public void setFree(String free) - { + public void setFree(String free) { this.free = free; } - public String getUsed() - { + public String getUsed() { return used; } - public void setUsed(String used) - { + public void setUsed(String used) { this.used = used; } - public double getUsage() - { + public double getUsage() { return usage; } - public void setUsage(double usage) - { + public void setUsage(double usage) { this.usage = usage; } } diff --git a/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/web/service/PermissionService.java b/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/web/service/PermissionService.java index 1db5519..4261263 100644 --- a/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/web/service/PermissionService.java +++ b/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/web/service/PermissionService.java @@ -1,6 +1,7 @@ package com.hchyun.framework.web.service; import java.util.Set; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; @@ -11,16 +12,19 @@ import com.hchyun.common.utils.StringUtils; /** * RuoYi首创 自定义权限实现,ss取自SpringSecurity首字母 - * + * * @author hchyun */ @Service("ss") -public class PermissionService -{ - /** 所有权限标识 */ +public class PermissionService { + /** + * 所有权限标识 + */ private static final String ALL_PERMISSION = "*:*:*"; - /** 管理员角色权限标识 */ + /** + * 管理员角色权限标识 + */ private static final String SUPER_ADMIN = "admin"; private static final String ROLE_DELIMETER = ","; @@ -32,19 +36,16 @@ public class PermissionService /** * 验证用户是否具备某权限 - * + * * @param permission 权限字符串 * @return 用户是否具备某权限 */ - public boolean hasPermi(String permission) - { - if (StringUtils.isEmpty(permission)) - { + public boolean hasPermi(String permission) { + if (StringUtils.isEmpty(permission)) { return false; } LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest()); - if (StringUtils.isNull(loginUser) || CollectionUtils.isEmpty(loginUser.getPermissions())) - { + if (StringUtils.isNull(loginUser) || CollectionUtils.isEmpty(loginUser.getPermissions())) { return false; } return hasPermissions(loginUser.getPermissions(), permission); @@ -56,8 +57,7 @@ public class PermissionService * @param permission 权限字符串 * @return 用户是否不具备某权限 */ - public boolean lacksPermi(String permission) - { + public boolean lacksPermi(String permission) { return hasPermi(permission) != true; } @@ -67,22 +67,17 @@ public class PermissionService * @param permissions 以 PERMISSION_NAMES_DELIMETER 为分隔符的权限列表 * @return 用户是否具有以下任意一个权限 */ - public boolean hasAnyPermi(String permissions) - { - if (StringUtils.isEmpty(permissions)) - { + public boolean hasAnyPermi(String permissions) { + if (StringUtils.isEmpty(permissions)) { return false; } LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest()); - if (StringUtils.isNull(loginUser) || CollectionUtils.isEmpty(loginUser.getPermissions())) - { + if (StringUtils.isNull(loginUser) || CollectionUtils.isEmpty(loginUser.getPermissions())) { return false; } Set authorities = loginUser.getPermissions(); - for (String permission : permissions.split(PERMISSION_DELIMETER)) - { - if (permission != null && hasPermissions(authorities, permission)) - { + for (String permission : permissions.split(PERMISSION_DELIMETER)) { + if (permission != null && hasPermissions(authorities, permission)) { return true; } } @@ -91,26 +86,21 @@ public class PermissionService /** * 判断用户是否拥有某个角色 - * + * * @param role 角色字符串 * @return 用户是否具备某角色 */ - public boolean hasRole(String role) - { - if (StringUtils.isEmpty(role)) - { + public boolean hasRole(String role) { + if (StringUtils.isEmpty(role)) { return false; } LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest()); - if (StringUtils.isNull(loginUser) || CollectionUtils.isEmpty(loginUser.getUser().getRoles())) - { + if (StringUtils.isNull(loginUser) || CollectionUtils.isEmpty(loginUser.getUser().getRoles())) { return false; } - for (SysRole sysRole : loginUser.getUser().getRoles()) - { + for (SysRole sysRole : loginUser.getUser().getRoles()) { String roleKey = sysRole.getRoleKey(); - if (SUPER_ADMIN.contains(roleKey) || roleKey.contains(StringUtils.trim(role))) - { + if (SUPER_ADMIN.contains(roleKey) || roleKey.contains(StringUtils.trim(role))) { return true; } } @@ -123,8 +113,7 @@ public class PermissionService * @param role 角色名称 * @return 用户是否不具备某角色 */ - public boolean lacksRole(String role) - { + public boolean lacksRole(String role) { return hasRole(role) != true; } @@ -134,21 +123,16 @@ public class PermissionService * @param roles 以 ROLE_NAMES_DELIMETER 为分隔符的角色列表 * @return 用户是否具有以下任意一个角色 */ - public boolean hasAnyRoles(String roles) - { - if (StringUtils.isEmpty(roles)) - { + public boolean hasAnyRoles(String roles) { + if (StringUtils.isEmpty(roles)) { return false; } LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest()); - if (StringUtils.isNull(loginUser) || CollectionUtils.isEmpty(loginUser.getUser().getRoles())) - { + if (StringUtils.isNull(loginUser) || CollectionUtils.isEmpty(loginUser.getUser().getRoles())) { return false; } - for (String role : roles.split(ROLE_DELIMETER)) - { - if (hasRole(role)) - { + for (String role : roles.split(ROLE_DELIMETER)) { + if (hasRole(role)) { return true; } } @@ -157,13 +141,12 @@ public class PermissionService /** * 判断是否包含权限 - * + * * @param permissions 权限列表 - * @param permission 权限字符串 + * @param permission 权限字符串 * @return 用户是否具备某权限 */ - private boolean hasPermissions(Set permissions, String permission) - { + private boolean hasPermissions(Set permissions, String permission) { return permissions.contains(ALL_PERMISSION) || permissions.contains(StringUtils.trim(permission)); } } diff --git a/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/web/service/SysPermissionService.java b/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/web/service/SysPermissionService.java index fe8b5cc..427c968 100644 --- a/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/web/service/SysPermissionService.java +++ b/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/web/service/SysPermissionService.java @@ -2,6 +2,7 @@ package com.hchyun.framework.web.service; import java.util.HashSet; import java.util.Set; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import com.hchyun.common.core.entity.entity.SysUser; @@ -10,12 +11,11 @@ import com.hchyun.system.service.ISysRoleService; /** * 用户权限处理 - * + * * @author hchyun */ @Component -public class SysPermissionService -{ +public class SysPermissionService { @Autowired private ISysRoleService roleService; @@ -24,20 +24,16 @@ public class SysPermissionService /** * 获取角色数据权限 - * + * * @param user 用户信息 * @return 角色权限信息 */ - public Set getRolePermission(SysUser user) - { + public Set getRolePermission(SysUser user) { Set roles = new HashSet(); // 管理员拥有所有权限 - if (user.isAdmin()) - { + if (user.isAdmin()) { roles.add("admin"); - } - else - { + } else { roles.addAll(roleService.selectRolePermissionByUserId(user.getUserId())); } return roles; @@ -45,20 +41,16 @@ public class SysPermissionService /** * 获取菜单数据权限 - * + * * @param user 用户信息 * @return 菜单权限信息 */ - public Set getMenuPermission(SysUser user) - { + public Set getMenuPermission(SysUser user) { Set perms = new HashSet(); // 管理员拥有所有权限 - if (user.isAdmin()) - { + if (user.isAdmin()) { perms.add("*:*:*"); - } - else - { + } else { perms.addAll(menuService.selectMenuPermsByUserId(user.getUserId())); } return perms; diff --git a/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/web/service/UserDetailsServiceImpl.java b/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/web/service/UserDetailsServiceImpl.java index befdc9a..1063bc8 100644 --- a/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/web/service/UserDetailsServiceImpl.java +++ b/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/web/service/UserDetailsServiceImpl.java @@ -20,8 +20,7 @@ import com.hchyun.system.service.ISysUserService; * @author hchyun */ @Service -public class UserDetailsServiceImpl implements UserDetailsService -{ +public class UserDetailsServiceImpl implements UserDetailsService { private static final Logger log = LoggerFactory.getLogger(UserDetailsServiceImpl.class); @Autowired @@ -31,21 +30,15 @@ public class UserDetailsServiceImpl implements UserDetailsService private SysPermissionService permissionService; @Override - public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException - { + public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { SysUser user = userService.selectUserByUserName(username); - if (StringUtils.isNull(user)) - { + if (StringUtils.isNull(user)) { log.info("登录用户:{} 不存在.", username); throw new UsernameNotFoundException("登录用户:" + username + " 不存在"); - } - else if (UserStatus.DELETED.getCode().equals(user.getDelFlag())) - { + } else if (UserStatus.DELETED.getCode().equals(user.getDelFlag())) { log.info("登录用户:{} 已被删除.", username); throw new BaseException("对不起,您的账号:" + username + " 已被删除"); - } - else if (UserStatus.DISABLE.getCode().equals(user.getStatus())) - { + } else if (UserStatus.DISABLE.getCode().equals(user.getStatus())) { log.info("登录用户:{} 已被停用.", username); throw new BaseException("对不起,您的账号:" + username + " 已停用"); } @@ -53,8 +46,7 @@ public class UserDetailsServiceImpl implements UserDetailsService return createLoginUser(user); } - public UserDetails createLoginUser(SysUser user) - { + public UserDetails createLoginUser(SysUser user) { return new LoginUser(user, permissionService.getMenuPermission(user)); } } diff --git a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/config/GenConfig.java b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/config/GenConfig.java index 53d02f1..0b00960 100644 --- a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/config/GenConfig.java +++ b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/config/GenConfig.java @@ -7,67 +7,66 @@ import org.springframework.stereotype.Component; /** * 读取代码生成相关配置 - * + * * @author hchyun */ @Component @ConfigurationProperties(prefix = "gen") -@PropertySource(value = { "classpath:generator.yml" }) -public class GenConfig -{ - /** 作者 */ +@PropertySource(value = {"classpath:generator.yml"}) +public class GenConfig { + /** + * 作者 + */ public static String author; - /** 生成包路径 */ + /** + * 生成包路径 + */ public static String packageName; - /** 自动去除表前缀,默认是false */ + /** + * 自动去除表前缀,默认是false + */ public static boolean autoRemovePre; - /** 表前缀(类名不会包含表前缀) */ + /** + * 表前缀(类名不会包含表前缀) + */ public static String tablePrefix; - public static String getAuthor() - { + public static String getAuthor() { return author; } @Value("${author}") - public void setAuthor(String author) - { + public void setAuthor(String author) { GenConfig.author = author; } - public static String getPackageName() - { + public static String getPackageName() { return packageName; } @Value("${packageName}") - public void setPackageName(String packageName) - { + public void setPackageName(String packageName) { GenConfig.packageName = packageName; } - public static boolean getAutoRemovePre() - { + public static boolean getAutoRemovePre() { return autoRemovePre; } @Value("${autoRemovePre}") - public void setAutoRemovePre(boolean autoRemovePre) - { + public void setAutoRemovePre(boolean autoRemovePre) { GenConfig.autoRemovePre = autoRemovePre; } - public static String getTablePrefix() - { + public static String getTablePrefix() { return tablePrefix; } @Value("${tablePrefix}") - public void setTablePrefix(String tablePrefix) - { + public void setTablePrefix(String tablePrefix) { GenConfig.tablePrefix = tablePrefix; } } diff --git a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/controller/ApiclassController.java b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/controller/ApiclassController.java index d276d2f..04ea16c 100644 --- a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/controller/ApiclassController.java +++ b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/controller/ApiclassController.java @@ -27,7 +27,7 @@ import com.hchyun.common.utils.poi.ExcelUtil; /** * 接口类名Controller - * + * * @author hchyun * @date 2021-01-24 */ @@ -42,19 +42,20 @@ public class ApiclassController extends HcyBaseController { /** * 获取到api类的select选项 + * * @return */ @PreAuthorize("@ss.hasAnyPermi('tool:apiclass:querylist')") @GetMapping("querylist") - public AjaxResult queryList(){ + public AjaxResult queryList() { try { ServerResult> serverResult = apiclassService.selectApiclassList(new Apiclass()); - if (serverResult.isStart()){ + if (serverResult.isStart()) { return AjaxResult.success(serverResult.getData()); - }else { + } else { return AjaxResult.error(serverResult.getMsg()); } - }catch (RuntimeException e){ + } catch (RuntimeException e) { logger.error(e.getMessage()); return AjaxResult.error(ReturnConstants.SYS_ERROR); } @@ -89,7 +90,7 @@ public class ApiclassController extends HcyBaseController { public AjaxResult export(Apiclass apiclass) { try { ServerResult> serverResult = apiclassService.selectApiclassList(apiclass); - ExcelUtil util = new ExcelUtil(Apiclass. class); + ExcelUtil util = new ExcelUtil(Apiclass.class); if (serverResult.isStart()) { return util.exportExcel(serverResult.getData(), "apiclass"); } else { @@ -127,7 +128,7 @@ public class ApiclassController extends HcyBaseController { @Log(title = "接口类名", businessType = BusinessType.INSERT) @PostMapping public AjaxResult add(@RequestBody Apiclass apiclass) { - if (apiclass.getmId() == null || apiclass.getmId()<0) { + if (apiclass.getmId() == null || apiclass.getmId() < 0) { return AjaxResult.error("模块id不能为空!"); } if (apiclass.getcName() == null || apiclass.getcName().equals("")) { @@ -158,7 +159,7 @@ public class ApiclassController extends HcyBaseController { public AjaxResult edit(@RequestBody Apiclass apiclass) { try { - if (apiclass.getmId() == null || apiclass.getmId()<0) { + if (apiclass.getmId() == null || apiclass.getmId() < 0) { return AjaxResult.error("模块id不能为空!"); } if (apiclass.getcName() == null || apiclass.getcName().equals("")) { @@ -184,10 +185,10 @@ public class ApiclassController extends HcyBaseController { */ @PreAuthorize("@ss.hasPermi('tool:apiclass:remove')") @Log(title = "接口类名", businessType = BusinessType.DELETE) - @DeleteMapping("/{ids}") + @DeleteMapping("/{ids}") public AjaxResult remove(@PathVariable Long[] ids) { try { - if (ids.length<0){ + if (ids.length < 0) { return AjaxResult.error("id不能为空!"); } ServerResult serverResult = apiclassService.deleteApiclassByIds(ids); @@ -196,7 +197,7 @@ public class ApiclassController extends HcyBaseController { } else { return AjaxResult.error(serverResult.getMsg()); } - }catch (RuntimeException e){ + } catch (RuntimeException e) { logger.error(e.getMessage()); return AjaxResult.error(ReturnConstants.SYS_ERROR); } diff --git a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/controller/AssociatedController.java b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/controller/AssociatedController.java index 3727711..4230619 100644 --- a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/controller/AssociatedController.java +++ b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/controller/AssociatedController.java @@ -20,6 +20,7 @@ import java.util.Map; /** * todo + * * @Author 18209 * @Date 2021/2/5 17:38 * @Version 1.0 @@ -35,15 +36,15 @@ public class AssociatedController { @ApiOperation("tableid") @GetMapping("/{tableId}") - private AjaxResult assColumnsByTable(@PathVariable("tableId")Long tableId){ + private AjaxResult assColumnsByTable(@PathVariable("tableId") Long tableId) { try { ServerResult> serverResult = associatedService.assColumnsByTable(tableId); - if (serverResult.isStart()){ + if (serverResult.isStart()) { return AjaxResult.success(serverResult.getData()); - }else { + } else { return AjaxResult.error(serverResult.getMsg()); } - }catch (RuntimeException e){ + } catch (RuntimeException e) { logger.error(e.getMessage()); return AjaxResult.error(); } @@ -51,30 +52,31 @@ public class AssociatedController { @ApiOperation("获取表信息") @GetMapping("/tableinfos") - public AjaxResult tableInfos(){ + public AjaxResult tableInfos() { try { - ServerResult>> serverResult = associatedService.tableInfos(); - if (serverResult.isStart()){ + ServerResult>> serverResult = associatedService.tableInfos(); + if (serverResult.isStart()) { return AjaxResult.success(serverResult.getData()); - }else { + } else { return AjaxResult.error(serverResult.getMsg()); } - }catch (RuntimeException e){ + } catch (RuntimeException e) { logger.error(e.getMessage()); return AjaxResult.error(ReturnConstants.SYS_ERROR); } } + @ApiOperation("关联表字段") @GetMapping("/{tableName}/{tableId}") - public AjaxResult assColumns(@PathVariable("tableName")String tableName,@PathVariable("tableId") Long tableId){ + public AjaxResult assColumns(@PathVariable("tableName") String tableName, @PathVariable("tableId") Long tableId) { try { ServerResult> serverResult = associatedService.assColumns(tableName, tableId); - if (serverResult.isStart()){ + if (serverResult.isStart()) { return AjaxResult.success(serverResult.getData()); - }else { + } else { return AjaxResult.error(serverResult.getMsg()); } - }catch (RuntimeException e){ + } catch (RuntimeException e) { logger.error(e.getMessage()); return AjaxResult.error(ReturnConstants.SYS_ERROR); } diff --git a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/controller/GenController.java b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/controller/GenController.java index 7be6284..d063540 100644 --- a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/controller/GenController.java +++ b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/controller/GenController.java @@ -66,9 +66,9 @@ public class GenController extends BaseController { List tables = genTableService.selectGenTableAll(); List list = genTableColumnService.selectGenTableColumnListByTableId(talbleId); Map map = new HashMap(); - map.put("info" , table); - map.put("rows" , list); - map.put("tables" , tables); + map.put("info", table); + map.put("rows", list); + map.put("tables", tables); return AjaxResult.success(map); } @@ -100,7 +100,7 @@ public class GenController extends BaseController { * 导入表结构(保存) */ @PreAuthorize("@ss.hasPermi('tool:gen:list')") - @Log(title = "代码生成" , businessType = BusinessType.IMPORT) + @Log(title = "代码生成", businessType = BusinessType.IMPORT) @PostMapping("/importTable") public AjaxResult importTableSave(String tables) { String[] tableNames = Convert.toStrArray(tables); @@ -115,7 +115,7 @@ public class GenController extends BaseController { * 修改保存代码生成业务 */ @PreAuthorize("@ss.hasPermi('tool:gen:edit')") - @Log(title = "代码生成" , businessType = BusinessType.UPDATE) + @Log(title = "代码生成", businessType = BusinessType.UPDATE) @PutMapping public AjaxResult editSave(@Validated @RequestBody GenTable genTable) { genTableService.validateEdit(genTable); @@ -127,17 +127,17 @@ public class GenController extends BaseController { * 删除代码生成 */ @PreAuthorize("@ss.hasPermi('tool:gen:remove')") - @Log(title = "代码生成" , businessType = BusinessType.DELETE) + @Log(title = "代码生成", businessType = BusinessType.DELETE) @DeleteMapping("/{tableIds}") public AjaxResult remove(@PathVariable Long[] tableIds) { try { ServerResult serverResult = genTableService.deleteGenTableByIds(tableIds); - if (serverResult.isStart()){ + if (serverResult.isStart()) { return AjaxResult.success(); - }else { + } else { return AjaxResult.error(serverResult.getMsg()); } - }catch (RuntimeException e){ + } catch (RuntimeException e) { logger.error(e.getMessage()); return AjaxResult.error(ReturnConstants.SYS_ERROR); } @@ -157,7 +157,7 @@ public class GenController extends BaseController { * 生成代码(下载方式) */ @PreAuthorize("@ss.hasPermi('tool:gen:code')") - @Log(title = "代码生成" , businessType = BusinessType.GENCODE) + @Log(title = "代码生成", businessType = BusinessType.GENCODE) @GetMapping("/download/{tableName}") public void download(HttpServletResponse response, @PathVariable("tableName") String tableName) throws IOException { byte[] data = genTableService.downloadCode(tableName); @@ -168,7 +168,7 @@ public class GenController extends BaseController { * 生成代码(自定义路径) */ @PreAuthorize("@ss.hasPermi('tool:gen:code')") - @Log(title = "代码生成" , businessType = BusinessType.GENCODE) + @Log(title = "代码生成", businessType = BusinessType.GENCODE) @GetMapping("/genCode/{tableName}") public AjaxResult genCode(@PathVariable("tableName") String tableName) { boolean start = genTableService.generatorCode(tableName); @@ -183,7 +183,7 @@ public class GenController extends BaseController { * 同步数据库 */ @PreAuthorize("@ss.hasPermi('tool:gen:edit')") - @Log(title = "代码生成" , businessType = BusinessType.UPDATE) + @Log(title = "代码生成", businessType = BusinessType.UPDATE) @GetMapping("/synchDb/{tableName}") public AjaxResult synchDb(@PathVariable("tableName") String tableName) { genTableService.synchDb(tableName); @@ -194,7 +194,7 @@ public class GenController extends BaseController { * 批量生成代码 */ @PreAuthorize("@ss.hasPermi('tool:gen:code')") - @Log(title = "代码生成" , businessType = BusinessType.GENCODE) + @Log(title = "代码生成", businessType = BusinessType.GENCODE) @GetMapping("/batchGenCode") public void batchGenCode(HttpServletResponse response, String tables) throws IOException { String[] tableNames = Convert.toStrArray(tables); @@ -207,10 +207,10 @@ public class GenController extends BaseController { */ private void genCode(HttpServletResponse response, byte[] data) throws IOException { response.reset(); - response.addHeader("Access-Control-Allow-Origin" , "*"); - response.addHeader("Access-Control-Expose-Headers" , "Content-Disposition"); - response.setHeader("Content-Disposition" , "attachment; filename=\"hchyun.zip\""); - response.addHeader("Content-Length" , "" + data.length); + response.addHeader("Access-Control-Allow-Origin", "*"); + response.addHeader("Access-Control-Expose-Headers", "Content-Disposition"); + response.setHeader("Content-Disposition", "attachment; filename=\"hchyun.zip\""); + response.addHeader("Content-Length", "" + data.length); response.setContentType("application/octet-stream; charset=UTF-8"); IOUtils.write(data, response.getOutputStream()); } diff --git a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/controller/InterTableController.java b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/controller/InterTableController.java index 2c979da..8ffde23 100644 --- a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/controller/InterTableController.java +++ b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/controller/InterTableController.java @@ -146,6 +146,7 @@ public class InterTableController extends HcyBaseController { /** * 生成代码(工作台) + * * @param id * @param response * @return @@ -154,7 +155,7 @@ public class InterTableController extends HcyBaseController { @PreAuthorize("@ss.hasPermi('generator:intertable:moudlegen')") @Log(title = "生成代码(工作台)", businessType = BusinessType.GENCODE) @GetMapping("/moudlegen/{id}") - public AjaxResult moudleGenerator(@PathVariable("id") Long id, HttpServletResponse response){ + public AjaxResult moudleGenerator(@PathVariable("id") Long id, HttpServletResponse response) { try { ServerResult serverResult = interTableService.generatorCodeMoudle(id); if (serverResult.isStart()) { @@ -163,14 +164,13 @@ public class InterTableController extends HcyBaseController { } else { return AjaxResult.error(serverResult.getMsg()); } - }catch (RuntimeException | IOException e){ + } catch (RuntimeException | IOException e) { logger.error(e.getMessage()); return AjaxResult.error(ReturnConstants.SYS_ERROR); } } - /** * 修改接口信息 */ diff --git a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/controller/ModuleController.java b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/controller/ModuleController.java index a50c120..966079a 100644 --- a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/controller/ModuleController.java +++ b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/controller/ModuleController.java @@ -28,7 +28,7 @@ import com.hchyun.common.utils.poi.ExcelUtil; /** * 模块管理Controller - * + * * @author hchyun * @date 2021-01-24 */ @@ -43,26 +43,26 @@ public class ModuleController extends HcyBaseController { /** * 获取到api类的select选项 + * * @return */ @PreAuthorize("@ss.hasAnyPermi('tool:module:querylist')") @GetMapping("querylist") - public AjaxResult queryList(){ + public AjaxResult queryList() { try { ServerResult> serverResult = moduleService.selectModuleList(new Module()); - if (serverResult.isStart()){ + if (serverResult.isStart()) { return AjaxResult.success(serverResult.getData()); - }else { + } else { return AjaxResult.error(serverResult.getMsg()); } - }catch (RuntimeException e){ + } catch (RuntimeException e) { logger.error(e.getMessage()); return AjaxResult.error(ReturnConstants.SYS_ERROR); } } - /** * 查询模块管理列表 */ @@ -92,7 +92,7 @@ public class ModuleController extends HcyBaseController { public AjaxResult export(Module module) { try { ServerResult> serverResult = moduleService.selectModuleList(module); - ExcelUtil util = new ExcelUtil(Module. class); + ExcelUtil util = new ExcelUtil(Module.class); if (serverResult.isStart()) { return util.exportExcel(serverResult.getData(), "module"); } else { @@ -181,10 +181,10 @@ public class ModuleController extends HcyBaseController { */ @PreAuthorize("@ss.hasPermi('tool:module:remove')") @Log(title = "模块管理", businessType = BusinessType.DELETE) - @DeleteMapping("/{ids}") + @DeleteMapping("/{ids}") public AjaxResult remove(@PathVariable Long[] ids) { try { - if (ids.length<0){ + if (ids.length < 0) { return AjaxResult.error("id不能为空!"); } ServerResult serverResult = moduleService.deleteModuleByIds(ids); @@ -193,7 +193,7 @@ public class ModuleController extends HcyBaseController { } else { return AjaxResult.error(serverResult.getMsg()); } - }catch (RuntimeException e){ + } catch (RuntimeException e) { logger.error(e.getMessage()); return AjaxResult.error(ReturnConstants.SYS_ERROR); } diff --git a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/controller/QueryController.java b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/controller/QueryController.java index e80f2de..1e83ad2 100644 --- a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/controller/QueryController.java +++ b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/controller/QueryController.java @@ -64,15 +64,15 @@ public class QueryController extends BaseController { @PreAuthorize("@ss.hasAnyPermi('query:real:export')") @PutMapping("/real/export") - public AjaxResult exportReal(@Validated @RequestBody UniQuery uniQuery){ + public AjaxResult exportReal(@Validated @RequestBody UniQuery uniQuery) { try { - ServerResult>> serverResult = queryService.RealData(uniQuery,1); - if (serverResult.isStart()){ - return new MapExcelUtil().exportExcel(serverResult.getData(),serverResult.getSheetName()); - }else { + ServerResult>> serverResult = queryService.RealData(uniQuery, 1); + if (serverResult.isStart()) { + return new MapExcelUtil().exportExcel(serverResult.getData(), serverResult.getSheetName()); + } else { return AjaxResult.error(serverResult.getMsg()); } - }catch (RuntimeException e){ + } catch (RuntimeException e) { logger.error(e.getMessage()); return AjaxResult.error(ReturnConstants.SYS_ERROR); } @@ -83,7 +83,7 @@ public class QueryController extends BaseController { @PutMapping("/real") public Serializable RealData(@Validated @RequestBody UniQuery uniQuery) { try { - ServerResult>> serverResult = queryService.RealData(uniQuery,2); + ServerResult>> serverResult = queryService.RealData(uniQuery, 2); if (serverResult.isStart()) { return getDataTable(serverResult.getData()); } else { @@ -138,13 +138,13 @@ public class QueryController extends BaseController { @PutMapping("export") public AjaxResult export(@Validated @RequestBody UniQuery uniQuery) { try { - ServerResult>> serverResult = queryService.previewQuery(uniQuery); - if (serverResult.isStart()){ - return new MapExcelUtil().exportExcel(serverResult.getData(),uniQuery.getUqName()); - }else { + ServerResult>> serverResult = queryService.previewQuery(uniQuery); + if (serverResult.isStart()) { + return new MapExcelUtil().exportExcel(serverResult.getData(), uniQuery.getUqName()); + } else { return AjaxResult.error(serverResult.getMsg()); } - }catch (RuntimeException e){ + } catch (RuntimeException e) { logger.error(e.getMessage()); return AjaxResult.error(ReturnConstants.SYS_ERROR); } @@ -175,9 +175,9 @@ public class QueryController extends BaseController { } else { if (uniQuery.getIsRelease() == 1 || uniQuery.getIsRelease() == 2) { ServerResult serverResult = queryService.Release(uniQuery); - if (serverResult.isStart()){ + if (serverResult.isStart()) { return AjaxResult.success(); - }else { + } else { return AjaxResult.error(serverResult.getMsg()); } } else { diff --git a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/controller/UniQueryController.java b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/controller/UniQueryController.java index 6ae277b..b9440e0 100644 --- a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/controller/UniQueryController.java +++ b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/controller/UniQueryController.java @@ -44,7 +44,7 @@ import com.hchyun.common.enums.BusinessType; * @author hchyun * @date 2021-01-30 */ -@Api(value = "万能查询管理",tags = "万能查询管理") +@Api(value = "万能查询管理", tags = "万能查询管理") @RestController @RequestMapping("/tool/query") public class UniQueryController extends BaseController { @@ -84,7 +84,7 @@ public class UniQueryController extends BaseController { public AjaxResult export(UniQuery uniQuery) { try { ServerResult> serverResult = uniQueryService.selectUniQueryList(uniQuery); - ExcelUtil util = new ExcelUtil(UniQuery. class); + ExcelUtil util = new ExcelUtil(UniQuery.class); if (serverResult.isStart()) { return util.exportExcel(serverResult.getData(), "query"); } else { @@ -100,7 +100,7 @@ public class UniQueryController extends BaseController { * 获取万能查询详细信息 */ @ApiOperation("获取万能查询详细信息") - @ApiImplicitParam(name = "id" , value = "万能查询id" , required = true, dataType = "Long" , paramType = "path") + @ApiImplicitParam(name = "id", value = "万能查询id", required = true, dataType = "Long", paramType = "path") @PreAuthorize("@ss.hasPermi('tool:query:query')") @GetMapping(value = "/{id}") public AjaxResult getInfo(@PathVariable("id") Long id) { @@ -121,7 +121,7 @@ public class UniQueryController extends BaseController { * 新增万能查询 */ @ApiOperation("新增万能查询") - @ApiImplicitParam(name = "uniQuery" , value = "新增万能查询信息" , dataType = "UniQuery") + @ApiImplicitParam(name = "uniQuery", value = "新增万能查询信息", dataType = "UniQuery") @PreAuthorize("@ss.hasPermi('tool:query:add')") @Log(title = "万能查询", businessType = BusinessType.INSERT) @PostMapping @@ -149,7 +149,7 @@ public class UniQueryController extends BaseController { * 修改万能查询 */ @ApiOperation("修改万能查询") - @ApiImplicitParam(name = "uniQuery" , value = "修改万能查询信息" , dataType = "UniQuery") + @ApiImplicitParam(name = "uniQuery", value = "修改万能查询信息", dataType = "UniQuery") @PreAuthorize("@ss.hasPermi('tool:query:edit')") @Log(title = "万能查询", businessType = BusinessType.UPDATE) @PutMapping @@ -178,13 +178,13 @@ public class UniQueryController extends BaseController { * 删除万能查询 */ @ApiOperation("删除万能查询") - @ApiImplicitParam(name = "ids" , value = "万能查询ids" , required = true, dataType = "Long" , paramType = "path") + @ApiImplicitParam(name = "ids", value = "万能查询ids", required = true, dataType = "Long", paramType = "path") @PreAuthorize("@ss.hasPermi('tool:query:remove')") @Log(title = "万能查询", businessType = BusinessType.DELETE) @DeleteMapping("/{ids}") public AjaxResult remove(@PathVariable Long[] ids) { try { - if (ids.length<0){ + if (ids.length < 0) { return AjaxResult.error("id不能为空!"); } ServerResult serverResult = uniQueryService.deleteUniQueryByIds(ids); @@ -193,7 +193,7 @@ public class UniQueryController extends BaseController { } else { return AjaxResult.error(serverResult.getMsg()); } - }catch (RuntimeException e){ + } catch (RuntimeException e) { logger.error(e.getMessage()); return AjaxResult.error(ReturnConstants.SYS_ERROR); } diff --git a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/dao/AssociatedDao.java b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/dao/AssociatedDao.java index fa85d78..d03efdf 100644 --- a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/dao/AssociatedDao.java +++ b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/dao/AssociatedDao.java @@ -14,12 +14,14 @@ public interface AssociatedDao { /** * 获取表信息 + * * @return */ - List> tableInfos(); + List> tableInfos(); /** * 获取表字段信息 + * * @param tableName * @return */ @@ -27,6 +29,7 @@ public interface AssociatedDao { /** * 通过tableId删除字段信息 + * * @param tableId * @return */ @@ -34,6 +37,7 @@ public interface AssociatedDao { /** * 批量增加字段信息 + * * @param assColumns * @return */ @@ -41,6 +45,7 @@ public interface AssociatedDao { /** * 通过tableId获取字段信息 + * * @param tableId * @return */ diff --git a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/dao/GenTableColumnDao.java b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/dao/GenTableColumnDao.java index a995024..c40c8d2 100644 --- a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/dao/GenTableColumnDao.java +++ b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/dao/GenTableColumnDao.java @@ -1,18 +1,18 @@ package com.hchyun.generator.dao; import java.util.List; + import com.hchyun.generator.entity.GenTableColumn; /** * 业务字段 数据层 - * + * * @author hchyun */ -public interface GenTableColumnDao -{ +public interface GenTableColumnDao { /** * 根据表名称查询列信息 - * + * * @param tableName 表名称 * @return 列信息 */ @@ -20,7 +20,7 @@ public interface GenTableColumnDao /** * 查询业务字段列表 - * + * * @param tableId 业务字段编号 * @return 业务字段集合 */ @@ -28,7 +28,7 @@ public interface GenTableColumnDao /** * 新增业务字段 - * + * * @param genTableColumn 业务字段信息 * @return 结果 */ @@ -36,7 +36,7 @@ public interface GenTableColumnDao /** * 修改业务字段 - * + * * @param genTableColumns 业务字段信息 * @return 结果 */ @@ -44,7 +44,7 @@ public interface GenTableColumnDao /** * 删除业务字段 - * + * * @param genTableColumns 列数据 * @return 结果 */ @@ -52,7 +52,7 @@ public interface GenTableColumnDao /** * 批量删除业务字段 - * + * * @param ids 需要删除的数据ID * @return 结果 */ diff --git a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/dao/GenTableDao.java b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/dao/GenTableDao.java index 8bec8b4..bb1d56f 100644 --- a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/dao/GenTableDao.java +++ b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/dao/GenTableDao.java @@ -1,19 +1,19 @@ package com.hchyun.generator.dao; import java.util.List; + import com.hchyun.generator.entity.GenTable; import org.apache.ibatis.annotations.Param; /** * 业务 数据层 - * + * * @author hchyun */ -public interface GenTableDao -{ +public interface GenTableDao { /** * 查询业务列表 - * + * * @param genTable 业务信息 * @return 业务集合 */ @@ -21,7 +21,7 @@ public interface GenTableDao /** * 查询据库列表 - * + * * @param genTable 业务信息 * @return 数据库表集合 */ @@ -29,7 +29,7 @@ public interface GenTableDao /** * 查询据库列表 - * + * * @param tableNames 表名称组 * @return 数据库表集合 */ @@ -37,14 +37,14 @@ public interface GenTableDao /** * 查询所有表信息 - * + * * @return 表信息集合 */ public List selectGenTableAll(); /** * 查询表ID业务信息 - * + * * @param id 业务ID * @return 业务信息 */ @@ -52,7 +52,7 @@ public interface GenTableDao /** * 查询表名称业务信息 - * + * * @param tableName 表名称 * @return 业务信息 */ @@ -60,7 +60,7 @@ public interface GenTableDao /** * 新增业务 - * + * * @param genTable 业务信息 * @return 结果 */ @@ -68,7 +68,7 @@ public interface GenTableDao /** * 修改业务 - * + * * @param genTable 业务信息 * @return 结果 */ @@ -76,7 +76,7 @@ public interface GenTableDao /** * 批量删除业务 - * + * * @param ids 需要删除的数据ID * @return 结果 */ diff --git a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/dao/InterTableDao.java b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/dao/InterTableDao.java index eb5eb53..ac5401c 100644 --- a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/dao/InterTableDao.java +++ b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/dao/InterTableDao.java @@ -11,8 +11,7 @@ import com.hchyun.generator.entity.InterTable; * @author hchyun * @date 2021-01-25 */ -public interface InterTableDao -{ +public interface InterTableDao { /** * 查询接口信息 * @@ -47,6 +46,7 @@ public interface InterTableDao /** * 通过类id删除接口 + * * @param cId * @return */ @@ -54,6 +54,7 @@ public interface InterTableDao /** * 通过模块id删除接口 + * * @param mId * @return */ @@ -68,7 +69,6 @@ public interface InterTableDao int updateInterTable(InterTable interTable); - /** * 删除接口信息 * diff --git a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/dao/ModuleDao.java b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/dao/ModuleDao.java index 5689c2e..0857bc7 100644 --- a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/dao/ModuleDao.java +++ b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/dao/ModuleDao.java @@ -6,15 +6,14 @@ import java.util.List; /** * 模块管理Mapper接口 - * + * * @author hchyun * @date 2021-01-24 */ -public interface ModuleDao -{ +public interface ModuleDao { /** * 查询模块管理 - * + * * @param id 模块管理ID * @return 模块管理 */ @@ -22,7 +21,7 @@ public interface ModuleDao /** * 查询模块管理列表 - * + * * @param module 模块管理 * @return 模块管理集合 */ @@ -30,7 +29,7 @@ public interface ModuleDao /** * 新增模块管理 - * + * * @param module 模块管理 * @return 结果 */ @@ -38,7 +37,7 @@ public interface ModuleDao /** * 修改模块管理 - * + * * @param module 模块管理 * @return 结果 */ @@ -46,7 +45,7 @@ public interface ModuleDao /** * 删除模块管理 - * + * * @param id 模块管理ID * @return 结果 */ @@ -54,7 +53,7 @@ public interface ModuleDao /** * 批量删除模块管理 - * + * * @param ids 需要删除的数据ID * @return 结果 */ diff --git a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/dao/QueryDao.java b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/dao/QueryDao.java index cc68a78..6027dda 100644 --- a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/dao/QueryDao.java +++ b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/dao/QueryDao.java @@ -22,7 +22,7 @@ public interface QueryDao { Integer insertUniCon(List uniCons); - List> UniQuery(String paramSQL); + List> UniQuery(String paramSQL); List queryRealInfo(Long id); diff --git a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/dao/UniQueryDao.java b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/dao/UniQueryDao.java index 9642984..429a880 100644 --- a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/dao/UniQueryDao.java +++ b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/dao/UniQueryDao.java @@ -7,15 +7,14 @@ import java.util.List; /** * 万能查询Mapper接口 - * + * * @author hchyun * @date 2021-01-30 */ -public interface UniQueryDao -{ +public interface UniQueryDao { /** * 查询万能查询 - * + * * @param id 万能查询ID * @return 万能查询 */ @@ -23,7 +22,7 @@ public interface UniQueryDao /** * 查询万能查询列表 - * + * * @param uniQuery 万能查询 * @return 万能查询集合 */ @@ -31,7 +30,7 @@ public interface UniQueryDao /** * 新增万能查询 - * + * * @param uniQuery 万能查询 * @return 结果 */ @@ -39,7 +38,7 @@ public interface UniQueryDao /** * 修改万能查询 - * + * * @param uniQuery 万能查询 * @return 结果 */ @@ -47,7 +46,7 @@ public interface UniQueryDao /** * 删除万能查询 - * + * * @param id 万能查询ID * @return 结果 */ @@ -55,14 +54,11 @@ public interface UniQueryDao /** * 批量删除万能查询 - * + * * @param ids 需要删除的数据ID * @return 结果 */ public int deleteUniQueryByIds(Long[] ids); - - - } diff --git a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/entity/Apiclass.java b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/entity/Apiclass.java index 01cbd6e..bb4a2e3 100644 --- a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/entity/Apiclass.java +++ b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/entity/Apiclass.java @@ -43,7 +43,7 @@ public class Apiclass extends BaseEntity { private String cDescribe; /** - * 包名 + * 包名 */ @Excel(name = "包名") private String packageName; @@ -77,7 +77,7 @@ public class Apiclass extends BaseEntity { } public void setInterTables(List interTables) { - if (interTables == null){ + if (interTables == null) { interTables = new ArrayList(); } this.interTables = interTables; diff --git a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/entity/AssColumn.java b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/entity/AssColumn.java index 5696203..4291045 100644 --- a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/entity/AssColumn.java +++ b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/entity/AssColumn.java @@ -3,153 +3,153 @@ package com.hchyun.generator.entity; public class AssColumn { - private long id; - private long tableId; - private String columnName; - private String columnComment; - private String columnType; - private String javaType; - private String javaField; - private String isList; - private String isQuery; - private String queryType; - private String htmlType; - private String dictType; - private Integer sort; - private long createBy; - private long updateBy; + private long id; + private long tableId; + private String columnName; + private String columnComment; + private String columnType; + private String javaType; + private String javaField; + private String isList; + private String isQuery; + private String queryType; + private String htmlType; + private String dictType; + private Integer sort; + private long createBy; + private long updateBy; - public long getId() { - return id; - } + public long getId() { + return id; + } - public void setId(long id) { - this.id = id; - } + public void setId(long id) { + this.id = id; + } - public long getTableId() { - return tableId; - } + public long getTableId() { + return tableId; + } - public void setTableId(long tableId) { - this.tableId = tableId; - } + public void setTableId(long tableId) { + this.tableId = tableId; + } - public String getColumnName() { - return columnName; - } + public String getColumnName() { + return columnName; + } - public void setColumnName(String columnName) { - this.columnName = columnName; - } + public void setColumnName(String columnName) { + this.columnName = columnName; + } - public String getColumnComment() { - return columnComment; - } + public String getColumnComment() { + return columnComment; + } - public void setColumnComment(String columnComment) { - this.columnComment = columnComment; - } + public void setColumnComment(String columnComment) { + this.columnComment = columnComment; + } - public String getColumnType() { - return columnType; - } + public String getColumnType() { + return columnType; + } - public void setColumnType(String columnType) { - this.columnType = columnType; - } + public void setColumnType(String columnType) { + this.columnType = columnType; + } - public String getJavaType() { - return javaType; - } + public String getJavaType() { + return javaType; + } - public void setJavaType(String javaType) { - this.javaType = javaType; - } + public void setJavaType(String javaType) { + this.javaType = javaType; + } - public String getJavaField() { - return javaField; - } + public String getJavaField() { + return javaField; + } - public void setJavaField(String javaField) { - this.javaField = javaField; - } + public void setJavaField(String javaField) { + this.javaField = javaField; + } - public String getIsList() { - return isList; - } + public String getIsList() { + return isList; + } - public void setIsList(String isList) { - this.isList = isList; - } + public void setIsList(String isList) { + this.isList = isList; + } - public String getIsQuery() { - return isQuery; - } + public String getIsQuery() { + return isQuery; + } - public void setIsQuery(String isQuery) { - this.isQuery = isQuery; - } + public void setIsQuery(String isQuery) { + this.isQuery = isQuery; + } - public String getQueryType() { - return queryType; - } + public String getQueryType() { + return queryType; + } - public void setQueryType(String queryType) { - this.queryType = queryType; - } + public void setQueryType(String queryType) { + this.queryType = queryType; + } - public String getHtmlType() { - return htmlType; - } + public String getHtmlType() { + return htmlType; + } - public void setHtmlType(String htmlType) { - this.htmlType = htmlType; - } + public void setHtmlType(String htmlType) { + this.htmlType = htmlType; + } - public String getDictType() { - return dictType; - } + public String getDictType() { + return dictType; + } - public void setDictType(String dictType) { - this.dictType = dictType; - } + public void setDictType(String dictType) { + this.dictType = dictType; + } - public Integer getSort() { - return sort; - } + public Integer getSort() { + return sort; + } - public void setSort(Integer sort) { - this.sort = sort; - } + public void setSort(Integer sort) { + this.sort = sort; + } - public long getCreateBy() { - return createBy; - } + public long getCreateBy() { + return createBy; + } - public void setCreateBy(long createBy) { - this.createBy = createBy; - } + public void setCreateBy(long createBy) { + this.createBy = createBy; + } - public long getUpdateBy() { - return updateBy; - } + public long getUpdateBy() { + return updateBy; + } - public void setUpdateBy(long updateBy) { - this.updateBy = updateBy; - } + public void setUpdateBy(long updateBy) { + this.updateBy = updateBy; + } } diff --git a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/entity/GenTable.java b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/entity/GenTable.java index 48a1d2d..6f866b5 100644 --- a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/entity/GenTable.java +++ b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/entity/GenTable.java @@ -3,6 +3,7 @@ package com.hchyun.generator.entity; import java.util.List; import javax.validation.Valid; import javax.validation.constraints.NotBlank; + import org.apache.commons.lang3.ArrayUtils; import com.hchyun.common.constant.GenConstants; import com.hchyun.common.core.entity.BaseEntity; @@ -10,104 +11,157 @@ import com.hchyun.common.utils.StringUtils; /** * 业务表 gen_table - * + * * @author hchyun */ -public class GenTable extends BaseEntity -{ +public class GenTable extends BaseEntity { - /** 编号 */ + /** + * 编号 + */ private Long tableId; - /** 表名称 */ + /** + * 表名称 + */ @NotBlank(message = "表名称不能为空") private String tableName; - /** 表描述 */ + /** + * 表描述 + */ @NotBlank(message = "表描述不能为空") private String tableComment; - /** 关联父表的表名 */ + /** + * 关联父表的表名 + */ private String subTableName; - /** 本表关联父表的外键名 */ + /** + * 本表关联父表的外键名 + */ private String subTableFkName; - /** 实体类名称(首字母大写) */ + /** + * 实体类名称(首字母大写) + */ @NotBlank(message = "实体类名称不能为空") private String className; - /** 使用的模板(crud单表操作 tree树表操作 sub主子表操作 ass关联表操作) */ + /** + * 使用的模板(crud单表操作 tree树表操作 sub主子表操作 ass关联表操作) + */ private String tplCategory; - /** 生成包路径 */ + /** + * 生成包路径 + */ @NotBlank(message = "生成包路径不能为空") private String packageName; - /** 生成模块名 */ + /** + * 生成模块名 + */ @NotBlank(message = "生成模块名不能为空") private String moduleName; - /** 生成业务名 */ + /** + * 生成业务名 + */ @NotBlank(message = "生成业务名不能为空") private String businessName; - /** 生成功能名 */ + /** + * 生成功能名 + */ @NotBlank(message = "生成功能名不能为空") private String functionName; - /** 生成作者 */ + /** + * 生成作者 + */ @NotBlank(message = "作者不能为空") private String functionAuthor; - /** 生成代码方式(0zip压缩包 1自定义路径) */ + /** + * 生成代码方式(0zip压缩包 1自定义路径) + */ private String genType; - /** 生成路径(不填默认项目路径) */ + /** + * 生成路径(不填默认项目路径) + */ private String genPath; - /** 主键信息 */ + /** + * 主键信息 + */ private GenTableColumn pkColumn; - /** 子表信息 */ + /** + * 子表信息 + */ private GenTable subTable; - /** 表列信息 */ + /** + * 表列信息 + */ @Valid private List columns; private List assColumns; - /** 其它生成选项 */ + /** + * 其它生成选项 + */ private String options; - /** 树编码字段 */ + /** + * 树编码字段 + */ private String treeCode; - /** 树父编码字段 */ + /** + * 树父编码字段 + */ private String treeParentCode; - /** 树名称字段 */ + /** + * 树名称字段 + */ private String treeName; - /** 上级菜单ID字段 */ + /** + * 上级菜单ID字段 + */ private String parentMenuId; - /** 上级菜单名称字段 */ + /** + * 上级菜单名称字段 + */ private String parentMenuName; - /** 关联表名 */ + /** + * 关联表名 + */ private String assTableName; - /** 主表字段 */ + /** + * 主表字段 + */ private String assTableColumn; - /** 关联表key */ + /** + * 关联表key + */ private String assTableFkColumn; - /** 关联查询方式 */ + /** + * 关联查询方式 + */ private String assQueryType; public String getAssQueryType() { @@ -150,275 +204,220 @@ public class GenTable extends BaseEntity this.assTableFkColumn = assTableFkColumn; } - public Long getTableId() - { + public Long getTableId() { return tableId; } - public void setTableId(Long tableId) - { + public void setTableId(Long tableId) { this.tableId = tableId; } - public String getTableName() - { + public String getTableName() { return tableName; } - public void setTableName(String tableName) - { + public void setTableName(String tableName) { this.tableName = tableName; } - public String getTableComment() - { + public String getTableComment() { return tableComment; } - public void setTableComment(String tableComment) - { + public void setTableComment(String tableComment) { this.tableComment = tableComment; } - public String getSubTableName() - { + public String getSubTableName() { return subTableName; } - public void setSubTableName(String subTableName) - { + public void setSubTableName(String subTableName) { this.subTableName = subTableName; } - public String getSubTableFkName() - { + public String getSubTableFkName() { return subTableFkName; } - public void setSubTableFkName(String subTableFkName) - { + public void setSubTableFkName(String subTableFkName) { this.subTableFkName = subTableFkName; } - public String getClassName() - { + public String getClassName() { return className; } - public void setClassName(String className) - { + public void setClassName(String className) { this.className = className; } - public String getTplCategory() - { + public String getTplCategory() { return tplCategory; } - public void setTplCategory(String tplCategory) - { + public void setTplCategory(String tplCategory) { this.tplCategory = tplCategory; } - public String getPackageName() - { + public String getPackageName() { return packageName; } - public void setPackageName(String packageName) - { + public void setPackageName(String packageName) { this.packageName = packageName; } - public String getModuleName() - { + public String getModuleName() { return moduleName; } - public void setModuleName(String moduleName) - { + public void setModuleName(String moduleName) { this.moduleName = moduleName; } - public String getBusinessName() - { + public String getBusinessName() { return businessName; } - public void setBusinessName(String businessName) - { + public void setBusinessName(String businessName) { this.businessName = businessName; } - public String getFunctionName() - { + public String getFunctionName() { return functionName; } - public void setFunctionName(String functionName) - { + public void setFunctionName(String functionName) { this.functionName = functionName; } - public String getFunctionAuthor() - { + public String getFunctionAuthor() { return functionAuthor; } - public void setFunctionAuthor(String functionAuthor) - { + public void setFunctionAuthor(String functionAuthor) { this.functionAuthor = functionAuthor; } - public String getGenType() - { + public String getGenType() { return genType; } - public void setGenType(String genType) - { + public void setGenType(String genType) { this.genType = genType; } - public String getGenPath() - { + public String getGenPath() { return genPath; } - public void setGenPath(String genPath) - { + public void setGenPath(String genPath) { this.genPath = genPath; } - public GenTableColumn getPkColumn() - { + public GenTableColumn getPkColumn() { return pkColumn; } - public void setPkColumn(GenTableColumn pkColumn) - { + public void setPkColumn(GenTableColumn pkColumn) { this.pkColumn = pkColumn; } - public GenTable getSubTable() - { + public GenTable getSubTable() { return subTable; } - public void setSubTable(GenTable subTable) - { + public void setSubTable(GenTable subTable) { this.subTable = subTable; } - public List getColumns() - { + public List getColumns() { return columns; } - public void setColumns(List columns) - { + public void setColumns(List columns) { this.columns = columns; } - public String getOptions() - { + public String getOptions() { return options; } - public void setOptions(String options) - { + public void setOptions(String options) { this.options = options; } - public String getTreeCode() - { + public String getTreeCode() { return treeCode; } - public void setTreeCode(String treeCode) - { + public void setTreeCode(String treeCode) { this.treeCode = treeCode; } - public String getTreeParentCode() - { + public String getTreeParentCode() { return treeParentCode; } - public void setTreeParentCode(String treeParentCode) - { + public void setTreeParentCode(String treeParentCode) { this.treeParentCode = treeParentCode; } - public String getTreeName() - { + public String getTreeName() { return treeName; } - public void setTreeName(String treeName) - { + public void setTreeName(String treeName) { this.treeName = treeName; } - public String getParentMenuId() - { + public String getParentMenuId() { return parentMenuId; } - public void setParentMenuId(String parentMenuId) - { + public void setParentMenuId(String parentMenuId) { this.parentMenuId = parentMenuId; } - public String getParentMenuName() - { + public String getParentMenuName() { return parentMenuName; } - public void setParentMenuName(String parentMenuName) - { + public void setParentMenuName(String parentMenuName) { this.parentMenuName = parentMenuName; } - public boolean isSub() - { + public boolean isSub() { return isSub(this.tplCategory); } - public static boolean isSub(String tplCategory) - { + public static boolean isSub(String tplCategory) { return tplCategory != null && StringUtils.equals(GenConstants.TPL_SUB, tplCategory); } - public boolean isTree() - { + public boolean isTree() { return isTree(this.tplCategory); } - public static boolean isTree(String tplCategory) - { + public static boolean isTree(String tplCategory) { return tplCategory != null && StringUtils.equals(GenConstants.TPL_TREE, tplCategory); } - public boolean isCrud() - { + public boolean isCrud() { return isCrud(this.tplCategory); } - public static boolean isCrud(String tplCategory) - { + public static boolean isCrud(String tplCategory) { return tplCategory != null && StringUtils.equals(GenConstants.TPL_CRUD, tplCategory); } - public boolean isSuperColumn(String javaField) - { + public boolean isSuperColumn(String javaField) { return isSuperColumn(this.tplCategory, javaField); } - public static boolean isSuperColumn(String tplCategory, String javaField) - { - if (isTree(tplCategory)) - { + public static boolean isSuperColumn(String tplCategory, String javaField) { + if (isTree(tplCategory)) { return StringUtils.equalsAnyIgnoreCase(javaField, ArrayUtils.addAll(GenConstants.TREE_ENTITY, GenConstants.BASE_ENTITY)); } diff --git a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/entity/UniCon.java b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/entity/UniCon.java index 0563605..278458f 100644 --- a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/entity/UniCon.java +++ b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/entity/UniCon.java @@ -53,10 +53,14 @@ public class UniCon { */ private String ucDescribe; - /** 输入类型 */ + /** + * 输入类型 + */ private String ucType; - /** 显示类型 */ + /** + * 显示类型 + */ private Integer type; public String getUcType() { diff --git a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/entity/UniQuery.java b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/entity/UniQuery.java index 5bea36a..f476acd 100644 --- a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/entity/UniQuery.java +++ b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/entity/UniQuery.java @@ -72,15 +72,15 @@ public class UniQuery extends BaseEntity { } public List getUniCons() { - if (uniCons == null){ + if (uniCons == null) { return uniCons = new ArrayList(); - }else { + } else { return uniCons; } } public void setUniCons(List uniCons) { - this.uniCons = uniCons; + this.uniCons = uniCons; } public void setId(Long id) { diff --git a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/service/ApiclassService.java b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/service/ApiclassService.java index cc50923..8251d0b 100644 --- a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/service/ApiclassService.java +++ b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/service/ApiclassService.java @@ -7,15 +7,14 @@ import com.hchyun.generator.entity.Apiclass; /** * 接口类名Service接口 - * + * * @author hchyun * @date 2021-01-24 */ -public interface ApiclassService -{ +public interface ApiclassService { /** * 查询接口类名 - * + * * @param id 接口类名ID * @return 接口类名 */ @@ -23,7 +22,7 @@ public interface ApiclassService /** * 查询接口类名列表 - * + * * @param apiclass 接口类名 * @return 接口类名集合 */ @@ -31,7 +30,7 @@ public interface ApiclassService /** * 新增接口类名 - * + * * @param apiclass 接口类名 * @return 结果 */ @@ -39,7 +38,7 @@ public interface ApiclassService /** * 修改接口类名 - * + * * @param apiclass 接口类名 * @return 结果 */ @@ -47,7 +46,7 @@ public interface ApiclassService /** * 批量删除接口类名 - * + * * @param ids 需要删除的接口类名ID * @return 结果 */ @@ -55,7 +54,7 @@ public interface ApiclassService /** * 删除接口类名信息 - * + * * @param id 接口类名ID * @return 结果 */ diff --git a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/service/AssociatedService.java b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/service/AssociatedService.java index 1ee4770..681c71a 100644 --- a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/service/AssociatedService.java +++ b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/service/AssociatedService.java @@ -14,25 +14,27 @@ import java.util.Map; public interface AssociatedService { /** * 获取到数据库表信息 + * * @return */ - ServerResult>> tableInfos(); + ServerResult>> tableInfos(); /** * 获取到关联边字段信息 - * @param tableName 关联表表名 - * @param tableId 关联关系id + * + * @param tableName 关联表表名 + * @param tableId 关联关系id * @return */ - ServerResult> assColumns(String tableName,Long tableId); + ServerResult> assColumns(String tableName, Long tableId); /** * 通过table获取到关联信息 + * * @param tableId * @return */ ServerResult> assColumnsByTable(Long tableId); - } diff --git a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/service/IGenTableColumnService.java b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/service/IGenTableColumnService.java index c8de225..4b93a9a 100644 --- a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/service/IGenTableColumnService.java +++ b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/service/IGenTableColumnService.java @@ -1,18 +1,18 @@ package com.hchyun.generator.service; import java.util.List; + import com.hchyun.generator.entity.GenTableColumn; /** * 业务字段 服务层 - * + * * @author hchyun */ -public interface IGenTableColumnService -{ +public interface IGenTableColumnService { /** * 查询业务字段列表 - * + * * @param tableId 业务字段编号 * @return 业务字段集合 */ @@ -20,7 +20,7 @@ public interface IGenTableColumnService /** * 新增业务字段 - * + * * @param genTableColumn 业务字段信息 * @return 结果 */ @@ -28,7 +28,7 @@ public interface IGenTableColumnService /** * 修改业务字段 - * + * * @param genTableColumn 业务字段信息 * @return 结果 */ @@ -36,7 +36,7 @@ public interface IGenTableColumnService /** * 删除业务字段信息 - * + * * @param ids 需要删除的数据ID * @return 结果 */ diff --git a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/service/IGenTableService.java b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/service/IGenTableService.java index 4b6ce79..eec9483 100644 --- a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/service/IGenTableService.java +++ b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/service/IGenTableService.java @@ -8,14 +8,13 @@ import com.hchyun.generator.entity.GenTable; /** * 业务 服务层 - * + * * @author hchyun */ -public interface IGenTableService -{ +public interface IGenTableService { /** * 查询业务列表 - * + * * @param genTable 业务信息 * @return 业务集合 */ @@ -23,7 +22,7 @@ public interface IGenTableService /** * 查询据库列表 - * + * * @param genTable 业务信息 * @return 数据库表集合 */ @@ -31,7 +30,7 @@ public interface IGenTableService /** * 查询据库列表 - * + * * @param tableNames 表名称组 * @return 数据库表集合 */ @@ -39,14 +38,14 @@ public interface IGenTableService /** * 查询所有表信息 - * + * * @return 表信息集合 */ public List selectGenTableAll(); /** * 查询业务信息 - * + * * @param id 业务ID * @return 业务信息 */ @@ -54,7 +53,7 @@ public interface IGenTableService /** * 修改业务 - * + * * @param genTable 业务信息 * @return 结果 */ @@ -62,7 +61,7 @@ public interface IGenTableService /** * 删除业务信息 - * + * * @param tableIds 需要删除的表数据ID * @return 结果 */ @@ -70,14 +69,14 @@ public interface IGenTableService /** * 导入表结构 - * + * * @param tableList 导入表列表 */ public void importGenTable(List tableList); /** * 预览代码 - * + * * @param tableId 表编号 * @return 预览数据列表 */ @@ -85,7 +84,7 @@ public interface IGenTableService /** * 生成代码(下载方式) - * + * * @param tableName 表名称 * @return 数据 */ @@ -93,7 +92,7 @@ public interface IGenTableService /** * 生成代码(自定义路径) - * + * * @param tableName 表名称 * @return 数据 */ @@ -101,14 +100,14 @@ public interface IGenTableService /** * 同步数据库 - * + * * @param tableName 表名称 */ public void synchDb(String tableName); /** * 批量生成代码(下载方式) - * + * * @param tableNames 表数组 * @return 数据 */ @@ -116,7 +115,7 @@ public interface IGenTableService /** * 修改保存参数校验 - * + * * @param genTable 业务信息 */ public void validateEdit(GenTable genTable); diff --git a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/service/InterTableService.java b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/service/InterTableService.java index f64ef22..4ebe80f 100644 --- a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/service/InterTableService.java +++ b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/service/InterTableService.java @@ -13,8 +13,7 @@ import com.hchyun.generator.entity.InterTable; * @author hchyun * @date 2021-01-25 */ -public interface InterTableService -{ +public interface InterTableService { /** * 查询接口信息 * @@ -29,7 +28,7 @@ public interface InterTableService * @param interTable 接口信息 * @return 接口信息集合 */ - ServerResult> selectInterTableList(InterTable interTable); + ServerResult> selectInterTableList(InterTable interTable); /** * 新增接口信息 @@ -69,17 +68,19 @@ public interface InterTableService * @param cid * @return */ - ServerResult> previewCodeCalss(Long cid); + ServerResult> previewCodeCalss(Long cid); /** * 预览代码()工作台 + * * @param mid * @return */ - ServerResult> previewCodeMoudle(Long mid); + ServerResult> previewCodeMoudle(Long mid); /** * 生成代码(工作流) + * * @param cid * @return */ @@ -87,6 +88,7 @@ public interface InterTableService /** * 生成代码(工作台) + * * @param mid * @return */ diff --git a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/service/ModuleService.java b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/service/ModuleService.java index 4b87996..bc352f2 100644 --- a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/service/ModuleService.java +++ b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/service/ModuleService.java @@ -8,15 +8,14 @@ import java.util.List; /** * 模块管理Service接口 - * + * * @author hchyun * @date 2021-01-24 */ -public interface ModuleService -{ +public interface ModuleService { /** * 查询模块管理 - * + * * @param id 模块管理ID * @return 模块管理 */ @@ -24,7 +23,7 @@ public interface ModuleService /** * 查询模块管理列表 - * + * * @param module 模块管理 * @return 模块管理集合 */ @@ -32,7 +31,7 @@ public interface ModuleService /** * 新增模块管理 - * + * * @param module 模块管理 * @return 结果 */ @@ -40,7 +39,7 @@ public interface ModuleService /** * 修改模块管理 - * + * * @param module 模块管理 * @return 结果 */ @@ -48,7 +47,7 @@ public interface ModuleService /** * 批量删除模块管理 - * + * * @param ids 需要删除的模块管理ID * @return 结果 */ @@ -56,7 +55,7 @@ public interface ModuleService /** * 删除模块管理信息 - * + * * @param id 模块管理ID * @return 结果 */ diff --git a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/service/UniQueryService.java b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/service/UniQueryService.java index c888c2b..eb206b3 100644 --- a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/service/UniQueryService.java +++ b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/service/UniQueryService.java @@ -7,15 +7,14 @@ import com.hchyun.generator.entity.UniQuery; /** * 万能查询Service接口 - * + * * @author hchyun * @date 2021-01-30 */ -public interface UniQueryService -{ +public interface UniQueryService { /** * 查询万能查询 - * + * * @param id 万能查询ID * @return 万能查询 */ @@ -23,7 +22,7 @@ public interface UniQueryService /** * 查询万能查询列表 - * + * * @param uniQuery 万能查询 * @return 万能查询集合 */ @@ -31,7 +30,7 @@ public interface UniQueryService /** * 新增万能查询 - * + * * @param uniQuery 万能查询 * @return 结果 */ @@ -39,7 +38,7 @@ public interface UniQueryService /** * 修改万能查询 - * + * * @param uniQuery 万能查询 * @return 结果 */ @@ -47,7 +46,7 @@ public interface UniQueryService /** * 批量删除万能查询 - * + * * @param ids 需要删除的万能查询ID * @return 结果 */ @@ -55,7 +54,7 @@ public interface UniQueryService /** * 删除万能查询信息 - * + * * @param id 万能查询ID * @return 结果 */ diff --git a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/service/impl/ApiclassServiceImpl.java b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/service/impl/ApiclassServiceImpl.java index 2f85a38..809147f 100644 --- a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/service/impl/ApiclassServiceImpl.java +++ b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/service/impl/ApiclassServiceImpl.java @@ -15,7 +15,7 @@ import org.springframework.stereotype.Service; /** * 接口类名Service业务层处理 - * + * * @author hchyun * @date 2021-01-24 */ @@ -28,7 +28,7 @@ public class ApiclassServiceImpl implements ApiclassService { /** * 查询接口类名 - * + * * @param id 接口类名ID * @return 接口类名 */ @@ -36,20 +36,20 @@ public class ApiclassServiceImpl implements ApiclassService { public ServerResult selectApiclassById(Long id) { try { Apiclass apiclass = apiclassDao.selectApiclassById(id); - if (apiclass != null){ - return new ServerResult(true,apiclass); - }else { + if (apiclass != null) { + return new ServerResult(true, apiclass); + } else { return new ServerResult(false, ReturnConstants.RESULT_EMPTY); } - }catch (RuntimeException e){ + } catch (RuntimeException e) { logger.error(e.getMessage()); - return new ServerResult(false,ReturnConstants.DB_EX); + return new ServerResult(false, ReturnConstants.DB_EX); } } /** * 查询接口类名列表 - * + * * @param apiclass 接口类名 * @return 接口类名 */ @@ -57,20 +57,20 @@ public class ApiclassServiceImpl implements ApiclassService { public ServerResult> selectApiclassList(Apiclass apiclass) { try { List apiclassList = apiclassDao.selectApiclassList(apiclass); - if (apiclassList.size()>0){ - return new ServerResult>(true,apiclassList); - }else { - return new ServerResult>(false,ReturnConstants.RESULT_EMPTY); + if (apiclassList.size() > 0) { + return new ServerResult>(true, apiclassList); + } else { + return new ServerResult>(false, ReturnConstants.RESULT_EMPTY); } - }catch (RuntimeException e){ + } catch (RuntimeException e) { logger.error(e.getMessage()); - return new ServerResult>(false,ReturnConstants.DB_EX); + return new ServerResult>(false, ReturnConstants.DB_EX); } } /** * 新增接口类名 - * + * * @param apiclass 接口类名 * @return 结果 */ @@ -79,20 +79,20 @@ public class ApiclassServiceImpl implements ApiclassService { try { apiclass.setCreateBy(SecurityUtils.getUserId()); Integer renewal = apiclassDao.insertApiclass(apiclass); - if (renewal >0){ - return new ServerResult(true,renewal); - }else { - return new ServerResult(false,ReturnConstants.SYS_FAILL); + if (renewal > 0) { + return new ServerResult(true, renewal); + } else { + return new ServerResult(false, ReturnConstants.SYS_FAILL); } - }catch (RuntimeException e){ + } catch (RuntimeException e) { logger.error(e.getMessage()); - return new ServerResult(false,ReturnConstants.DB_EX); + return new ServerResult(false, ReturnConstants.DB_EX); } } /** * 修改接口类名 - * + * * @param apiclass 接口类名 * @return 结果 */ @@ -101,20 +101,20 @@ public class ApiclassServiceImpl implements ApiclassService { try { apiclass.setUpdateBy(SecurityUtils.getUserId()); Integer renewal = apiclassDao.updateApiclass(apiclass); - if (renewal >0){ - return new ServerResult(true,renewal); - }else { - return new ServerResult(false,ReturnConstants.SYS_FAILL); + if (renewal > 0) { + return new ServerResult(true, renewal); + } else { + return new ServerResult(false, ReturnConstants.SYS_FAILL); } - }catch (RuntimeException e){ + } catch (RuntimeException e) { logger.error(e.getMessage()); - return new ServerResult(false,ReturnConstants.DB_EX); + return new ServerResult(false, ReturnConstants.DB_EX); } } /** * 批量删除接口类名 - * + * * @param ids 需要删除的接口类名ID * @return 结果 */ @@ -122,20 +122,20 @@ public class ApiclassServiceImpl implements ApiclassService { public ServerResult deleteApiclassByIds(Long[] ids) { try { Integer renewal = apiclassDao.deleteApiclassByIds(ids); - if (renewal >0){ - return new ServerResult(true,renewal); - }else { - return new ServerResult(false,ReturnConstants.SYS_FAILL); + if (renewal > 0) { + return new ServerResult(true, renewal); + } else { + return new ServerResult(false, ReturnConstants.SYS_FAILL); } - }catch (RuntimeException e){ + } catch (RuntimeException e) { logger.error(e.getMessage()); - return new ServerResult(false,ReturnConstants.DB_EX); + return new ServerResult(false, ReturnConstants.DB_EX); } } /** * 删除接口类名信息 - * + * * @param id 接口类名ID * @return 结果 */ @@ -143,14 +143,14 @@ public class ApiclassServiceImpl implements ApiclassService { public ServerResult deleteApiclassById(Long id) { try { Integer renewal = apiclassDao.deleteApiclassById(id); - if (renewal >0){ - return new ServerResult(true,renewal); - }else { - return new ServerResult(false,ReturnConstants.SYS_FAILL); + if (renewal > 0) { + return new ServerResult(true, renewal); + } else { + return new ServerResult(false, ReturnConstants.SYS_FAILL); } - }catch (RuntimeException e){ + } catch (RuntimeException e) { logger.error(e.getMessage()); - return new ServerResult(false,ReturnConstants.DB_EX); + return new ServerResult(false, ReturnConstants.DB_EX); } } } diff --git a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/service/impl/AssociatedServiceImpl.java b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/service/impl/AssociatedServiceImpl.java index 6ddd549..a6cfbda 100644 --- a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/service/impl/AssociatedServiceImpl.java +++ b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/service/impl/AssociatedServiceImpl.java @@ -30,10 +30,10 @@ public class AssociatedServiceImpl implements AssociatedService { public ServerResult> assColumnsByTable(Long tableId) { try { List assColumns = associatedDao.selectTableColumnByTableId(tableId); - return new ServerResult<>(true,assColumns); - }catch (RuntimeException e){ + return new ServerResult<>(true, assColumns); + } catch (RuntimeException e) { logger.error(e.getMessage()); - return new ServerResult<>(false,ReturnConstants.DB_EX); + return new ServerResult<>(false, ReturnConstants.DB_EX); } } diff --git a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/service/impl/GenTableColumnServiceImpl.java b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/service/impl/GenTableColumnServiceImpl.java index c682ae8..d484deb 100644 --- a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/service/impl/GenTableColumnServiceImpl.java +++ b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/service/impl/GenTableColumnServiceImpl.java @@ -12,62 +12,57 @@ import com.hchyun.generator.dao.GenTableColumnDao; /** * 业务字段 服务层实现 - * + * * @author hchyun */ @Service -public class GenTableColumnServiceImpl implements IGenTableColumnService -{ - @Autowired - private GenTableColumnDao genTableColumnDao; +public class GenTableColumnServiceImpl implements IGenTableColumnService { + @Autowired + private GenTableColumnDao genTableColumnDao; - /** + /** * 查询业务字段列表 - * + * * @param tableId 业务字段编号 * @return 业务字段集合 */ - @Override - public List selectGenTableColumnListByTableId(Long tableId) - { - return genTableColumnDao.selectGenTableColumnListByTableId(tableId); - } - + @Override + public List selectGenTableColumnListByTableId(Long tableId) { + return genTableColumnDao.selectGenTableColumnListByTableId(tableId); + } + /** * 新增业务字段 - * + * * @param genTableColumn 业务字段信息 * @return 结果 */ - @Override - public int insertGenTableColumn(GenTableColumn genTableColumn) - { - return genTableColumnDao.insertGenTableColumn(genTableColumn); - } - - /** - * 修改业务字段 - * - * @param genTableColumn 业务字段信息 - * @return 结果 - */ - @Override - public int updateGenTableColumn(GenTableColumn genTableColumn) - { - List genTableColumns = new ArrayList(); - genTableColumns.add(genTableColumn); - return genTableColumnDao.updateGenTableColumn(genTableColumns); - } + @Override + public int insertGenTableColumn(GenTableColumn genTableColumn) { + return genTableColumnDao.insertGenTableColumn(genTableColumn); + } - /** + /** + * 修改业务字段 + * + * @param genTableColumn 业务字段信息 + * @return 结果 + */ + @Override + public int updateGenTableColumn(GenTableColumn genTableColumn) { + List genTableColumns = new ArrayList(); + genTableColumns.add(genTableColumn); + return genTableColumnDao.updateGenTableColumn(genTableColumns); + } + + /** * 删除业务字段对象 - * + * * @param ids 需要删除的数据ID * @return 结果 */ - @Override - public int deleteGenTableColumnByIds(String ids) - { - return genTableColumnDao.deleteGenTableColumnByIds(Convert.toLongArray(ids)); - } + @Override + public int deleteGenTableColumnByIds(String ids) { + return genTableColumnDao.deleteGenTableColumnByIds(Convert.toLongArray(ids)); + } } diff --git a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/service/impl/GenTableServiceImpl.java b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/service/impl/GenTableServiceImpl.java index 7c803d9..95811fa 100644 --- a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/service/impl/GenTableServiceImpl.java +++ b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/service/impl/GenTableServiceImpl.java @@ -158,10 +158,10 @@ public class GenTableServiceImpl implements IGenTableService { genTableDao.deleteGenTableByIds(tableIds); genTableColumnDao.deleteGenTableColumnByIds(tableIds); return new ServerResult<>(true); - }catch (RuntimeException e){ + } catch (RuntimeException e) { TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); log.error(e.getMessage()); - return new ServerResult<>(false,ReturnConstants.DB_EX); + return new ServerResult<>(false, ReturnConstants.DB_EX); } } @@ -266,7 +266,7 @@ public class GenTableServiceImpl implements IGenTableService { // 获取模板列表 List templates = VelocityUtils.getTemplateList(table.getTplCategory()); for (String template : templates) { - if (!StringUtils.containsAny(template, "table.sql.vm" , "api.js.vm" , "index.vue.vm" , "index-tree.vue.vm")) { + if (!StringUtils.containsAny(template, "table.sql.vm", "api.js.vm", "index.vue.vm", "index-tree.vue.vm")) { // 渲染模板 StringWriter sw = new StringWriter(); Template tpl = Velocity.getTemplate(template, Constants.UTF8); @@ -369,7 +369,7 @@ public class GenTableServiceImpl implements IGenTableService { setSubTable(table); // 设置主键列信息 setPkColumn(table); - if (table.getTplCategory().equals(GenConstants.TPL_ASS)){ + if (table.getTplCategory().equals(GenConstants.TPL_ASS)) { table.setAssColumns(associatedDao.selectTableColumnByTableId(table.getTableId())); } diff --git a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/service/impl/ModuleServiceImpl.java b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/service/impl/ModuleServiceImpl.java index efb5936..22a81da 100644 --- a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/service/impl/ModuleServiceImpl.java +++ b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/service/impl/ModuleServiceImpl.java @@ -15,7 +15,7 @@ import org.springframework.stereotype.Service; /** * 模块管理Service业务层处理 - * + * * @author hchyun * @date 2021-01-24 */ @@ -28,7 +28,7 @@ public class ModuleServiceImpl implements ModuleService { /** * 查询模块管理 - * + * * @param id 模块管理ID * @return 模块管理 */ @@ -36,20 +36,20 @@ public class ModuleServiceImpl implements ModuleService { public ServerResult selectModuleById(Long id) { try { Module module = moduleDao.selectModuleById(id); - if (module != null){ - return new ServerResult(true,module); - }else { + if (module != null) { + return new ServerResult(true, module); + } else { return new ServerResult(false, ReturnConstants.RESULT_EMPTY); } - }catch (RuntimeException e){ + } catch (RuntimeException e) { logger.error(e.getMessage()); - return new ServerResult(false,ReturnConstants.DB_EX); + return new ServerResult(false, ReturnConstants.DB_EX); } } /** * 查询模块管理列表 - * + * * @param module 模块管理 * @return 模块管理 */ @@ -57,20 +57,20 @@ public class ModuleServiceImpl implements ModuleService { public ServerResult> selectModuleList(Module module) { try { List moduleList = moduleDao.selectModuleList(module); - if (moduleList.size()>0){ - return new ServerResult>(true,moduleList); - }else { - return new ServerResult>(false,ReturnConstants.RESULT_EMPTY); + if (moduleList.size() > 0) { + return new ServerResult>(true, moduleList); + } else { + return new ServerResult>(false, ReturnConstants.RESULT_EMPTY); } - }catch (RuntimeException e){ + } catch (RuntimeException e) { logger.error(e.getMessage()); - return new ServerResult>(false,ReturnConstants.DB_EX); + return new ServerResult>(false, ReturnConstants.DB_EX); } } /** * 新增模块管理 - * + * * @param module 模块管理 * @return 结果 */ @@ -79,20 +79,20 @@ public class ModuleServiceImpl implements ModuleService { try { module.setCreateBy(SecurityUtils.getUserId()); Integer renewal = moduleDao.insertModule(module); - if (renewal >0){ - return new ServerResult(true,renewal); - }else { - return new ServerResult(false,ReturnConstants.SYS_FAILL); + if (renewal > 0) { + return new ServerResult(true, renewal); + } else { + return new ServerResult(false, ReturnConstants.SYS_FAILL); } - }catch (RuntimeException e){ + } catch (RuntimeException e) { logger.error(e.getMessage()); - return new ServerResult(false,ReturnConstants.DB_EX); + return new ServerResult(false, ReturnConstants.DB_EX); } } /** * 修改模块管理 - * + * * @param module 模块管理 * @return 结果 */ @@ -101,20 +101,20 @@ public class ModuleServiceImpl implements ModuleService { try { module.setUpdateBy(SecurityUtils.getUserId()); Integer renewal = moduleDao.updateModule(module); - if (renewal >0){ - return new ServerResult(true,renewal); - }else { - return new ServerResult(false,ReturnConstants.SYS_FAILL); + if (renewal > 0) { + return new ServerResult(true, renewal); + } else { + return new ServerResult(false, ReturnConstants.SYS_FAILL); } - }catch (RuntimeException e){ + } catch (RuntimeException e) { logger.error(e.getMessage()); - return new ServerResult(false,ReturnConstants.DB_EX); + return new ServerResult(false, ReturnConstants.DB_EX); } } /** * 批量删除模块管理 - * + * * @param ids 需要删除的模块管理ID * @return 结果 */ @@ -122,20 +122,20 @@ public class ModuleServiceImpl implements ModuleService { public ServerResult deleteModuleByIds(Long[] ids) { try { Integer renewal = moduleDao.deleteModuleByIds(ids); - if (renewal >0){ - return new ServerResult(true,renewal); - }else { - return new ServerResult(false,ReturnConstants.SYS_FAILL); + if (renewal > 0) { + return new ServerResult(true, renewal); + } else { + return new ServerResult(false, ReturnConstants.SYS_FAILL); } - }catch (RuntimeException e){ + } catch (RuntimeException e) { logger.error(e.getMessage()); - return new ServerResult(false,ReturnConstants.DB_EX); + return new ServerResult(false, ReturnConstants.DB_EX); } } /** * 删除模块管理信息 - * + * * @param id 模块管理ID * @return 结果 */ @@ -143,14 +143,14 @@ public class ModuleServiceImpl implements ModuleService { public ServerResult deleteModuleById(Long id) { try { Integer renewal = moduleDao.deleteModuleById(id); - if (renewal >0){ - return new ServerResult(true,renewal); - }else { - return new ServerResult(false,ReturnConstants.SYS_FAILL); + if (renewal > 0) { + return new ServerResult(true, renewal); + } else { + return new ServerResult(false, ReturnConstants.SYS_FAILL); } - }catch (RuntimeException e){ + } catch (RuntimeException e) { logger.error(e.getMessage()); - return new ServerResult(false,ReturnConstants.DB_EX); + return new ServerResult(false, ReturnConstants.DB_EX); } } } diff --git a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/service/impl/QueryServiceImpl.java b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/service/impl/QueryServiceImpl.java index f5169c8..c6976bb 100644 --- a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/service/impl/QueryServiceImpl.java +++ b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/service/impl/QueryServiceImpl.java @@ -98,7 +98,7 @@ public class QueryServiceImpl implements QueryService { public ServerResult>> RealData(UniQuery uniQuery, Integer type) { try { List uniCons = uniQuery.getUniCons(); - Integer pageNum = null,pageSize = null; + Integer pageNum = null, pageSize = null; if (type == 2) { pageNum = uniQuery.getPageNum(); pageSize = uniQuery.getPageSize(); @@ -118,7 +118,7 @@ public class QueryServiceImpl implements QueryService { PageHelper.startPage(pageNum, pageSize, ""); } List> dataMap = queryDao.UniQuery(sql.toString()); - return new ServerResult<>(true, dataMap,uniQuery.getUqName()); + return new ServerResult<>(true, dataMap, uniQuery.getUqName()); } } catch (RuntimeException e) { logger.error(e.getMessage()); diff --git a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/service/impl/UniQueryServiceImpl.java b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/service/impl/UniQueryServiceImpl.java index 9274325..7835156 100644 --- a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/service/impl/UniQueryServiceImpl.java +++ b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/service/impl/UniQueryServiceImpl.java @@ -36,14 +36,14 @@ public class UniQueryServiceImpl implements UniQueryService { public ServerResult selectUniQueryById(Long id) { try { UniQuery uniQuery = uniQueryDao.selectUniQueryById(id); - if (uniQuery != null){ - return new ServerResult(true,uniQuery); - }else { + if (uniQuery != null) { + return new ServerResult(true, uniQuery); + } else { return new ServerResult(false, ReturnConstants.RESULT_EMPTY); } - }catch (RuntimeException e){ + } catch (RuntimeException e) { logger.error(e.getMessage()); - return new ServerResult(false,ReturnConstants.DB_EX); + return new ServerResult(false, ReturnConstants.DB_EX); } } @@ -57,14 +57,14 @@ public class UniQueryServiceImpl implements UniQueryService { public ServerResult> selectUniQueryList(UniQuery uniQuery) { try { List uniQueryList = uniQueryDao.selectUniQueryList(uniQuery); - if (uniQueryList.size()>0){ - return new ServerResult>(true,uniQueryList); - }else { - return new ServerResult>(false,ReturnConstants.RESULT_EMPTY); + if (uniQueryList.size() > 0) { + return new ServerResult>(true, uniQueryList); + } else { + return new ServerResult>(false, ReturnConstants.RESULT_EMPTY); } - }catch (RuntimeException e){ + } catch (RuntimeException e) { logger.error(e.getMessage()); - return new ServerResult>(false,ReturnConstants.DB_EX); + return new ServerResult>(false, ReturnConstants.DB_EX); } } @@ -79,14 +79,14 @@ public class UniQueryServiceImpl implements UniQueryService { try { uniQuery.setCreateBy(SecurityUtils.getUserId()); Integer renewal = uniQueryDao.insertUniQuery(uniQuery); - if (renewal >0){ - return new ServerResult(true,renewal); - }else { - return new ServerResult(false,ReturnConstants.SYS_FAILL); + if (renewal > 0) { + return new ServerResult(true, renewal); + } else { + return new ServerResult(false, ReturnConstants.SYS_FAILL); } - }catch (RuntimeException e){ + } catch (RuntimeException e) { logger.error(e.getMessage()); - return new ServerResult(false,ReturnConstants.DB_EX); + return new ServerResult(false, ReturnConstants.DB_EX); } } @@ -101,14 +101,14 @@ public class UniQueryServiceImpl implements UniQueryService { try { uniQuery.setUpdateBy(SecurityUtils.getUserId()); Integer renewal = uniQueryDao.updateUniQuery(uniQuery); - if (renewal >0){ - return new ServerResult(true,renewal); - }else { - return new ServerResult(false,ReturnConstants.SYS_FAILL); + if (renewal > 0) { + return new ServerResult(true, renewal); + } else { + return new ServerResult(false, ReturnConstants.SYS_FAILL); } - }catch (RuntimeException e){ + } catch (RuntimeException e) { logger.error(e.getMessage()); - return new ServerResult(false,ReturnConstants.DB_EX); + return new ServerResult(false, ReturnConstants.DB_EX); } } @@ -122,14 +122,14 @@ public class UniQueryServiceImpl implements UniQueryService { public ServerResult deleteUniQueryByIds(Long[] ids) { try { Integer renewal = uniQueryDao.deleteUniQueryByIds(ids); - if (renewal >0){ - return new ServerResult(true,renewal); - }else { - return new ServerResult(false,ReturnConstants.SYS_FAILL); + if (renewal > 0) { + return new ServerResult(true, renewal); + } else { + return new ServerResult(false, ReturnConstants.SYS_FAILL); } - }catch (RuntimeException e){ + } catch (RuntimeException e) { logger.error(e.getMessage()); - return new ServerResult(false,ReturnConstants.DB_EX); + return new ServerResult(false, ReturnConstants.DB_EX); } } @@ -143,14 +143,14 @@ public class UniQueryServiceImpl implements UniQueryService { public ServerResult deleteUniQueryById(Long id) { try { Integer renewal = uniQueryDao.deleteUniQueryById(id); - if (renewal >0){ - return new ServerResult(true,renewal); - }else { - return new ServerResult(false,ReturnConstants.SYS_FAILL); + if (renewal > 0) { + return new ServerResult(true, renewal); + } else { + return new ServerResult(false, ReturnConstants.SYS_FAILL); } - }catch (RuntimeException e){ + } catch (RuntimeException e) { logger.error(e.getMessage()); - return new ServerResult(false,ReturnConstants.DB_EX); + return new ServerResult(false, ReturnConstants.DB_EX); } } } \ No newline at end of file diff --git a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/util/InterTableUtils.java b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/util/InterTableUtils.java index f1b6766..3da084b 100644 --- a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/util/InterTableUtils.java +++ b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/util/InterTableUtils.java @@ -48,7 +48,7 @@ public class InterTableUtils { } } List contextList = new ArrayList(); - for (int i = 0; i < apiclassList.size(); i++){ + for (int i = 0; i < apiclassList.size(); i++) { Apiclass apiclass = apiclassList.get(i); VelocityContext velocityContext = new VelocityContext(); String module = apiclass.getInterTables().get(0).getmName(); @@ -61,19 +61,19 @@ public class InterTableUtils { } velocityContext.put("createBy", SecurityUtils.getUserId()); velocityContext.put("Permission", permission); - velocityContext.put("packageName", "com.huhyun."+module); - velocityContext.put("prefix",module+":"+getLowerCase(className)); - velocityContext.put("ClassName",getUpperCase(className)); + velocityContext.put("packageName", "com.huhyun." + module); + velocityContext.put("prefix", module + ":" + getLowerCase(className)); + velocityContext.put("ClassName", getUpperCase(className)); velocityContext.put("columns", apiclass.getInterTables()); - velocityContext.put("reqMapping","/"+module+"/"+getLowerCase(className)); - velocityContext.put("functionName",apiclass.getcDescribe()); + velocityContext.put("reqMapping", "/" + module + "/" + getLowerCase(className)); + velocityContext.put("functionName", apiclass.getcDescribe()); velocityContext.put("author", apiclass.getAuthor()); velocityContext.put("emali", apiclass.getEmail()); velocityContext.put("time", DateUtils.getTime()); contextList.add(velocityContext); } - return contextList; + return contextList; } public static VelocityContext prepareClassContext(Apiclass apiclass) { @@ -102,10 +102,10 @@ public class InterTableUtils { return "/" + getLowerCase(mname) + "/" + getLowerCase(cname); } - public static Map getTemplateList(Integer type) { - Map templates = new HashMap(); - templates.put("java","vm/java/class.java.vm"); - templates.put("sql","vm/sql/class.sql.vm"); + public static Map getTemplateList(Integer type) { + Map templates = new HashMap(); + templates.put("java", "vm/java/class.java.vm"); + templates.put("sql", "vm/sql/class.sql.vm"); return templates; } diff --git a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/util/MapExcelUtil.java b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/util/MapExcelUtil.java index 5ec8679..f7ce424 100644 --- a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/util/MapExcelUtil.java +++ b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/util/MapExcelUtil.java @@ -184,7 +184,7 @@ public class MapExcelUtil { int k = 0; for (String key : herders) { // 填充单元格的值 - this.addCell(row, key, i,k++); + this.addCell(row, key, i, k++); } } } @@ -192,7 +192,7 @@ public class MapExcelUtil { /** * 添加单元格 */ - public Cell addCell(Row row, String key, int column,Integer k) { + public Cell addCell(Row row, String key, int column, Integer k) { Cell cell = null; try { // 设置行高 diff --git a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/util/VelocityInitializer.java b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/util/VelocityInitializer.java index 1ea6c76..5fd7ce0 100644 --- a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/util/VelocityInitializer.java +++ b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/util/VelocityInitializer.java @@ -1,24 +1,22 @@ package com.hchyun.generator.util; import java.util.Properties; + import org.apache.velocity.app.Velocity; import com.hchyun.common.constant.Constants; /** * VelocityEngine工厂 - * + * * @author hchyun */ -public class VelocityInitializer -{ +public class VelocityInitializer { /** * 初始化vm方法 */ - public static void initVelocity() - { + public static void initVelocity() { Properties p = new Properties(); - try - { + try { // 加载classpath目录下的vm文件 p.setProperty("file.resource.loader.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader"); // 定义字符集 @@ -26,9 +24,7 @@ public class VelocityInitializer p.setProperty(Velocity.OUTPUT_ENCODING, Constants.UTF8); // 初始化Velocity引擎,指定配置Properties Velocity.init(p); - } - catch (Exception e) - { + } catch (Exception e) { throw new RuntimeException(e); } } diff --git a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/util/VelocityUtils.java b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/util/VelocityUtils.java index 8d9f830..f5b91ae 100644 --- a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/util/VelocityUtils.java +++ b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/util/VelocityUtils.java @@ -47,24 +47,24 @@ public class VelocityUtils { String functionName = genTable.getFunctionName(); VelocityContext velocityContext = new VelocityContext(); - velocityContext.put("tplCategory" , genTable.getTplCategory()); - velocityContext.put("tableName" , genTable.getTableName()); - velocityContext.put("functionName" , StringUtils.isNotEmpty(functionName) ? functionName : "【请填写功能名称】"); - velocityContext.put("ClassName" , genTable.getClassName()); - velocityContext.put("className" , StringUtils.uncapitalize(genTable.getClassName())); - velocityContext.put("moduleName" , genTable.getModuleName()); - velocityContext.put("BusinessName" , StringUtils.capitalize(genTable.getBusinessName())); - velocityContext.put("businessName" , genTable.getBusinessName()); - velocityContext.put("basePackage" , getPackagePrefix(packageName)); - velocityContext.put("packageName" , packageName); - velocityContext.put("author" , genTable.getFunctionAuthor()); - velocityContext.put("datetime" , DateUtils.getDate()); - velocityContext.put("createBy" , SecurityUtils.getUserId()); - velocityContext.put("pkColumn" , genTable.getPkColumn()); - velocityContext.put("importList" , getImportList(genTable)); - velocityContext.put("permissionPrefix" , getPermissionPrefix(moduleName, businessName)); - velocityContext.put("columns" , genTable.getColumns()); - velocityContext.put("table" , genTable); + velocityContext.put("tplCategory", genTable.getTplCategory()); + velocityContext.put("tableName", genTable.getTableName()); + velocityContext.put("functionName", StringUtils.isNotEmpty(functionName) ? functionName : "【请填写功能名称】"); + velocityContext.put("ClassName", genTable.getClassName()); + velocityContext.put("className", StringUtils.uncapitalize(genTable.getClassName())); + velocityContext.put("moduleName", genTable.getModuleName()); + velocityContext.put("BusinessName", StringUtils.capitalize(genTable.getBusinessName())); + velocityContext.put("businessName", genTable.getBusinessName()); + velocityContext.put("basePackage", getPackagePrefix(packageName)); + velocityContext.put("packageName", packageName); + velocityContext.put("author", genTable.getFunctionAuthor()); + velocityContext.put("datetime", DateUtils.getDate()); + velocityContext.put("createBy", SecurityUtils.getUserId()); + velocityContext.put("pkColumn", genTable.getPkColumn()); + velocityContext.put("importList", getImportList(genTable)); + velocityContext.put("permissionPrefix", getPermissionPrefix(moduleName, businessName)); + velocityContext.put("columns", genTable.getColumns()); + velocityContext.put("table", genTable); setMenuVelocityContext(velocityContext, genTable); if (GenConstants.TPL_TREE.equals(tplCategory)) { setTreeVelocityContext(velocityContext, genTable); @@ -80,17 +80,17 @@ public class VelocityUtils { public static void setAssVelocityContext(VelocityContext context, GenTable genTable) { String assClassName = GenUtils.convertClassName(genTable.getAssTableName()); - context.put("assClassName" , assClassName); - context.put("assclassName" , StringUtils.uncapitalize(assClassName)); - context.put("tableMapping" , StringUtils.sqlFormat(genTable.getTableName())); - context.put("assMapping" , StringUtils.sqlFormat(genTable.getAssTableName())); + context.put("assClassName", assClassName); + context.put("assclassName", StringUtils.uncapitalize(assClassName)); + context.put("tableMapping", StringUtils.sqlFormat(genTable.getTableName())); + context.put("assMapping", StringUtils.sqlFormat(genTable.getAssTableName())); } public static void setMenuVelocityContext(VelocityContext context, GenTable genTable) { String options = genTable.getOptions(); JSONObject paramsObj = JSONObject.parseObject(options); String parentMenuId = getParentMenuId(paramsObj); - context.put("parentMenuId" , parentMenuId); + context.put("parentMenuId", parentMenuId); } public static void setTreeVelocityContext(VelocityContext context, GenTable genTable) { @@ -100,15 +100,15 @@ public class VelocityUtils { String treeParentCode = getTreeParentCode(paramsObj); String treeName = getTreeName(paramsObj); - context.put("treeCode" , treeCode); - context.put("treeParentCode" , treeParentCode); - context.put("treeName" , treeName); - context.put("expandColumn" , getExpandColumn(genTable)); + context.put("treeCode", treeCode); + context.put("treeParentCode", treeParentCode); + context.put("treeName", treeName); + context.put("expandColumn", getExpandColumn(genTable)); if (paramsObj.containsKey(GenConstants.TREE_PARENT_CODE)) { - context.put("tree_parent_code" , paramsObj.getString(GenConstants.TREE_PARENT_CODE)); + context.put("tree_parent_code", paramsObj.getString(GenConstants.TREE_PARENT_CODE)); } if (paramsObj.containsKey(GenConstants.TREE_NAME)) { - context.put("tree_name" , paramsObj.getString(GenConstants.TREE_NAME)); + context.put("tree_name", paramsObj.getString(GenConstants.TREE_NAME)); } } @@ -119,16 +119,16 @@ public class VelocityUtils { String subClassName = genTable.getSubTable().getClassName(); String subTableFkClassName = StringUtils.convertToCamelCase(subTableFkName); - context.put("tableMapping" , StringUtils.sqlFormat(genTable.getTableName())); - context.put("subMapping" , StringUtils.sqlFormat(subTable.getTableName())); - context.put("subTable" , subTable); - context.put("subTableName" , subTableName); - context.put("subTableFkName" , subTableFkName); - context.put("subTableFkClassName" , subTableFkClassName); - context.put("subTableFkclassName" , StringUtils.uncapitalize(subTableFkClassName)); - context.put("subClassName" , subClassName); - context.put("subclassName" , StringUtils.uncapitalize(subClassName)); - context.put("subImportList" , getImportList(genTable.getSubTable())); + context.put("tableMapping", StringUtils.sqlFormat(genTable.getTableName())); + context.put("subMapping", StringUtils.sqlFormat(subTable.getTableName())); + context.put("subTable", subTable); + context.put("subTableName", subTableName); + context.put("subTableFkName", subTableFkName); + context.put("subTableFkClassName", subTableFkClassName); + context.put("subTableFkclassName", StringUtils.uncapitalize(subTableFkClassName)); + context.put("subClassName", subClassName); + context.put("subclassName", StringUtils.uncapitalize(subClassName)); + context.put("subImportList", getImportList(genTable.getSubTable())); } /** @@ -175,35 +175,35 @@ public class VelocityUtils { // 业务名称 String businessName = genTable.getBusinessName(); - String javaPath = PROJECT_PATH + "/" + StringUtils.replace(packageName, "." , "/"); + String javaPath = PROJECT_PATH + "/" + StringUtils.replace(packageName, ".", "/"); String mybatisPath = MYBATIS_PATH + "/" + moduleName; String vuePath = "vue"; if (template.contains("entity.java.vm")) { - fileName = StringUtils.format("{}/entity/{}.java" , javaPath, className); + fileName = StringUtils.format("{}/entity/{}.java", javaPath, className); } if (template.contains("sub-entity.java.vm") && StringUtils.equals(GenConstants.TPL_SUB, genTable.getTplCategory())) { - fileName = StringUtils.format("{}/entity/{}.java" , javaPath, genTable.getSubTable().getClassName()); + fileName = StringUtils.format("{}/entity/{}.java", javaPath, genTable.getSubTable().getClassName()); } else if (template.contains("ass-entity.java.vm")) { - fileName = StringUtils.format("{}/entity/{}.java" , javaPath, GenUtils.convertClassName(genTable.getAssTableName())); + fileName = StringUtils.format("{}/entity/{}.java", javaPath, GenUtils.convertClassName(genTable.getAssTableName())); } else if (template.contains("dao.java.vm")) { - fileName = StringUtils.format("{}/dao/{}Dao.java" , javaPath, className); + fileName = StringUtils.format("{}/dao/{}Dao.java", javaPath, className); } else if (template.contains("service.java.vm")) { - fileName = StringUtils.format("{}/service/{}Service.java" , javaPath, className); + fileName = StringUtils.format("{}/service/{}Service.java", javaPath, className); } else if (template.contains("serviceImpl.java.vm")) { - fileName = StringUtils.format("{}/service/impl/{}ServiceImpl.java" , javaPath, className); + fileName = StringUtils.format("{}/service/impl/{}ServiceImpl.java", javaPath, className); } else if (template.contains("controller.java.vm")) { - fileName = StringUtils.format("{}/controller/{}Controller.java" , javaPath, className); + fileName = StringUtils.format("{}/controller/{}Controller.java", javaPath, className); } else if (template.contains("mapper.xml.vm")) { - fileName = StringUtils.format("{}/{}Mapper.xml" , mybatisPath, className); + fileName = StringUtils.format("{}/{}Mapper.xml", mybatisPath, className); } else if (template.contains("table.sql.vm")) { fileName = businessName + "Menu.sql"; } else if (template.contains("api.js.vm")) { - fileName = StringUtils.format("{}/api/{}/{}.js" , vuePath, moduleName, businessName); + fileName = StringUtils.format("{}/api/{}/{}.js", vuePath, moduleName, businessName); } else if (template.contains("index.vue.vm")) { - fileName = StringUtils.format("{}/views/{}/{}/index.vue" , vuePath, moduleName, businessName); + fileName = StringUtils.format("{}/views/{}/{}/index.vue", vuePath, moduleName, businessName); } else if (template.contains("index-tree.vue.vm")) { - fileName = StringUtils.format("{}/views/{}/{}/index.vue" , vuePath, moduleName, businessName); + fileName = StringUtils.format("{}/views/{}/{}/index.vue", vuePath, moduleName, businessName); } return fileName; } @@ -252,7 +252,7 @@ public class VelocityUtils { * @return 返回权限前缀 */ public static String getPermissionPrefix(String moduleName, String businessName) { - return StringUtils.format("{}:{}" , moduleName, businessName); + return StringUtils.format("{}:{}", moduleName, businessName); } /** diff --git a/hchyun/hchyun-quartz/src/main/java/com/hchyun/quartz/config/ScheduleConfig.java b/hchyun/hchyun-quartz/src/main/java/com/hchyun/quartz/config/ScheduleConfig.java index 00c6976..859ec9d 100644 --- a/hchyun/hchyun-quartz/src/main/java/com/hchyun/quartz/config/ScheduleConfig.java +++ b/hchyun/hchyun-quartz/src/main/java/com/hchyun/quartz/config/ScheduleConfig.java @@ -22,24 +22,24 @@ public class ScheduleConfig { // quartz参数 Properties prop = new Properties(); // todo - prop.put("org.quartz.scheduler.instanceName" , "HchyunScheduler"); - prop.put("org.quartz.scheduler.instanceId" , "AUTO"); + prop.put("org.quartz.scheduler.instanceName", "HchyunScheduler"); + prop.put("org.quartz.scheduler.instanceId", "AUTO"); // 线程池配置 - prop.put("org.quartz.threadPool.class" , "org.quartz.simpl.SimpleThreadPool"); - prop.put("org.quartz.threadPool.threadCount" , "20"); - prop.put("org.quartz.threadPool.threadPriority" , "5"); + prop.put("org.quartz.threadPool.class", "org.quartz.simpl.SimpleThreadPool"); + prop.put("org.quartz.threadPool.threadCount", "20"); + prop.put("org.quartz.threadPool.threadPriority", "5"); // JobStore配置 - prop.put("org.quartz.jobStore.class" , "org.quartz.impl.jdbcjobstore.JobStoreTX"); + prop.put("org.quartz.jobStore.class", "org.quartz.impl.jdbcjobstore.JobStoreTX"); // 集群配置 - prop.put("org.quartz.jobStore.isClustered" , "true"); - prop.put("org.quartz.jobStore.clusterCheckinInterval" , "15000"); - prop.put("org.quartz.jobStore.maxMisfiresToHandleAtATime" , "1"); - prop.put("org.quartz.jobStore.txIsolationLevelSerializable" , "true"); + prop.put("org.quartz.jobStore.isClustered", "true"); + prop.put("org.quartz.jobStore.clusterCheckinInterval", "15000"); + prop.put("org.quartz.jobStore.maxMisfiresToHandleAtATime", "1"); + prop.put("org.quartz.jobStore.txIsolationLevelSerializable", "true"); // sqlserver 启用 // prop.put("org.quartz.jobStore.selectWithLockSQL", "SELECT * FROM {0}LOCKS UPDLOCK WHERE LOCK_NAME = ?"); - prop.put("org.quartz.jobStore.misfireThreshold" , "12000"); - prop.put("org.quartz.jobStore.tablePrefix" , "QRTZ_"); + prop.put("org.quartz.jobStore.misfireThreshold", "12000"); + prop.put("org.quartz.jobStore.tablePrefix", "QRTZ_"); factory.setQuartzProperties(prop); factory.setSchedulerName("HchyunScheduler"); diff --git a/hchyun/hchyun-quartz/src/main/java/com/hchyun/quartz/controller/SysJobController.java b/hchyun/hchyun-quartz/src/main/java/com/hchyun/quartz/controller/SysJobController.java index f1181fe..16f1404 100644 --- a/hchyun/hchyun-quartz/src/main/java/com/hchyun/quartz/controller/SysJobController.java +++ b/hchyun/hchyun-quartz/src/main/java/com/hchyun/quartz/controller/SysJobController.java @@ -1,6 +1,7 @@ package com.hchyun.quartz.controller; import java.util.List; + import org.quartz.SchedulerException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.access.prepost.PreAuthorize; @@ -26,13 +27,12 @@ import com.hchyun.quartz.util.CronUtils; /** * 调度任务信息操作处理 - * + * * @author hchyun */ @RestController @RequestMapping("/monitor/job") -public class SysJobController extends BaseController -{ +public class SysJobController extends BaseController { @Autowired private ISysJobService jobService; @@ -41,8 +41,7 @@ public class SysJobController extends BaseController */ @PreAuthorize("@ss.hasPermi('monitor:job:list')") @GetMapping("/list") - public TableDataInfo list(SysJob sysJob) - { + public TableDataInfo list(SysJob sysJob) { startPage(); List list = jobService.selectJobList(sysJob); return getDataTable(list); @@ -54,8 +53,7 @@ public class SysJobController extends BaseController @PreAuthorize("@ss.hasPermi('monitor:job:export')") @Log(title = "定时任务", businessType = BusinessType.EXPORT) @GetMapping("/export") - public AjaxResult export(SysJob sysJob) - { + public AjaxResult export(SysJob sysJob) { List list = jobService.selectJobList(sysJob); ExcelUtil util = new ExcelUtil(SysJob.class); return util.exportExcel(list, "定时任务"); @@ -66,8 +64,7 @@ public class SysJobController extends BaseController */ @PreAuthorize("@ss.hasPermi('monitor:job:query')") @GetMapping(value = "/{jobId}") - public AjaxResult getInfo(@PathVariable("jobId") Long jobId) - { + public AjaxResult getInfo(@PathVariable("jobId") Long jobId) { return AjaxResult.success(jobService.selectJobById(jobId)); } @@ -77,10 +74,8 @@ public class SysJobController extends BaseController @PreAuthorize("@ss.hasPermi('monitor:job:add')") @Log(title = "定时任务", businessType = BusinessType.INSERT) @PostMapping - public AjaxResult add(@RequestBody SysJob sysJob) throws SchedulerException, TaskException - { - if (!CronUtils.isValid(sysJob.getCronExpression())) - { + public AjaxResult add(@RequestBody SysJob sysJob) throws SchedulerException, TaskException { + if (!CronUtils.isValid(sysJob.getCronExpression())) { return AjaxResult.error("cron表达式不正确"); } sysJob.setCreateBy(SecurityUtils.getUserId()); @@ -93,10 +88,8 @@ public class SysJobController extends BaseController @PreAuthorize("@ss.hasPermi('monitor:job:edit')") @Log(title = "定时任务", businessType = BusinessType.UPDATE) @PutMapping - public AjaxResult edit(@RequestBody SysJob sysJob) throws SchedulerException, TaskException - { - if (!CronUtils.isValid(sysJob.getCronExpression())) - { + public AjaxResult edit(@RequestBody SysJob sysJob) throws SchedulerException, TaskException { + if (!CronUtils.isValid(sysJob.getCronExpression())) { return AjaxResult.error("cron表达式不正确"); } sysJob.setUpdateBy(SecurityUtils.getUserId()); @@ -109,8 +102,7 @@ public class SysJobController extends BaseController @PreAuthorize("@ss.hasPermi('monitor:job:changeStatus')") @Log(title = "定时任务", businessType = BusinessType.UPDATE) @PutMapping("/changeStatus") - public AjaxResult changeStatus(@RequestBody SysJob job) throws SchedulerException - { + public AjaxResult changeStatus(@RequestBody SysJob job) throws SchedulerException { SysJob newJob = jobService.selectJobById(job.getJobId()); newJob.setStatus(job.getStatus()); return toAjax(jobService.changeStatus(newJob)); @@ -122,8 +114,7 @@ public class SysJobController extends BaseController @PreAuthorize("@ss.hasPermi('monitor:job:changeStatus')") @Log(title = "定时任务", businessType = BusinessType.UPDATE) @PutMapping("/run") - public AjaxResult run(@RequestBody SysJob job) throws SchedulerException - { + public AjaxResult run(@RequestBody SysJob job) throws SchedulerException { jobService.run(job); return AjaxResult.success(); } @@ -134,8 +125,7 @@ public class SysJobController extends BaseController @PreAuthorize("@ss.hasPermi('monitor:job:remove')") @Log(title = "定时任务", businessType = BusinessType.DELETE) @DeleteMapping("/{jobIds}") - public AjaxResult remove(@PathVariable Long[] jobIds) throws SchedulerException, TaskException - { + public AjaxResult remove(@PathVariable Long[] jobIds) throws SchedulerException, TaskException { jobService.deleteJobByIds(jobIds); return AjaxResult.success(); } diff --git a/hchyun/hchyun-quartz/src/main/java/com/hchyun/quartz/controller/SysJobLogController.java b/hchyun/hchyun-quartz/src/main/java/com/hchyun/quartz/controller/SysJobLogController.java index 25432d4..0cccc10 100644 --- a/hchyun/hchyun-quartz/src/main/java/com/hchyun/quartz/controller/SysJobLogController.java +++ b/hchyun/hchyun-quartz/src/main/java/com/hchyun/quartz/controller/SysJobLogController.java @@ -1,6 +1,7 @@ package com.hchyun.quartz.controller; import java.util.List; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.DeleteMapping; @@ -19,13 +20,12 @@ import com.hchyun.quartz.service.ISysJobLogService; /** * 调度日志操作处理 - * + * * @author hchyun */ @RestController @RequestMapping("/monitor/jobLog") -public class SysJobLogController extends BaseController -{ +public class SysJobLogController extends BaseController { @Autowired private ISysJobLogService jobLogService; @@ -34,8 +34,7 @@ public class SysJobLogController extends BaseController */ @PreAuthorize("@ss.hasPermi('monitor:job:list')") @GetMapping("/list") - public TableDataInfo list(SysJobLog sysJobLog) - { + public TableDataInfo list(SysJobLog sysJobLog) { startPage(); List list = jobLogService.selectJobLogList(sysJobLog); return getDataTable(list); @@ -47,20 +46,18 @@ public class SysJobLogController extends BaseController @PreAuthorize("@ss.hasPermi('monitor:job:export')") @Log(title = "任务调度日志", businessType = BusinessType.EXPORT) @GetMapping("/export") - public AjaxResult export(SysJobLog sysJobLog) - { + public AjaxResult export(SysJobLog sysJobLog) { List list = jobLogService.selectJobLogList(sysJobLog); ExcelUtil util = new ExcelUtil(SysJobLog.class); return util.exportExcel(list, "调度日志"); } - + /** * 根据调度编号获取详细信息 */ @PreAuthorize("@ss.hasPermi('monitor:job:query')") @GetMapping(value = "/{configId}") - public AjaxResult getInfo(@PathVariable Long jobLogId) - { + public AjaxResult getInfo(@PathVariable Long jobLogId) { return AjaxResult.success(jobLogService.selectJobLogById(jobLogId)); } @@ -71,8 +68,7 @@ public class SysJobLogController extends BaseController @PreAuthorize("@ss.hasPermi('monitor:job:remove')") @Log(title = "定时任务调度日志", businessType = BusinessType.DELETE) @DeleteMapping("/{jobLogIds}") - public AjaxResult remove(@PathVariable Long[] jobLogIds) - { + public AjaxResult remove(@PathVariable Long[] jobLogIds) { return toAjax(jobLogService.deleteJobLogByIds(jobLogIds)); } @@ -82,8 +78,7 @@ public class SysJobLogController extends BaseController @PreAuthorize("@ss.hasPermi('monitor:job:remove')") @Log(title = "调度日志", businessType = BusinessType.CLEAN) @DeleteMapping("/clean") - public AjaxResult clean() - { + public AjaxResult clean() { jobLogService.cleanJobLog(); return AjaxResult.success(); } diff --git a/hchyun/hchyun-quartz/src/main/java/com/hchyun/quartz/dao/SysJobDao.java b/hchyun/hchyun-quartz/src/main/java/com/hchyun/quartz/dao/SysJobDao.java index 418b815..27f6266 100644 --- a/hchyun/hchyun-quartz/src/main/java/com/hchyun/quartz/dao/SysJobDao.java +++ b/hchyun/hchyun-quartz/src/main/java/com/hchyun/quartz/dao/SysJobDao.java @@ -1,18 +1,18 @@ package com.hchyun.quartz.dao; import java.util.List; + import com.hchyun.quartz.entity.SysJob; /** * 调度任务信息 数据层 - * + * * @author hchyun */ -public interface SysJobDao -{ +public interface SysJobDao { /** * 查询调度任务日志集合 - * + * * @param job 调度信息 * @return 操作日志集合 */ @@ -20,14 +20,14 @@ public interface SysJobDao /** * 查询所有调度任务 - * + * * @return 调度任务列表 */ public List selectJobAll(); /** * 通过调度ID查询调度任务信息 - * + * * @param jobId 调度ID * @return 角色对象信息 */ @@ -35,7 +35,7 @@ public interface SysJobDao /** * 通过调度ID删除调度任务信息 - * + * * @param jobId 调度ID * @return 结果 */ @@ -43,7 +43,7 @@ public interface SysJobDao /** * 批量删除调度任务信息 - * + * * @param ids 需要删除的数据ID * @return 结果 */ @@ -51,7 +51,7 @@ public interface SysJobDao /** * 修改调度任务信息 - * + * * @param job 调度任务信息 * @return 结果 */ @@ -59,7 +59,7 @@ public interface SysJobDao /** * 新增调度任务信息 - * + * * @param job 调度任务信息 * @return 结果 */ diff --git a/hchyun/hchyun-quartz/src/main/java/com/hchyun/quartz/dao/SysJobLogDao.java b/hchyun/hchyun-quartz/src/main/java/com/hchyun/quartz/dao/SysJobLogDao.java index a171625..fa162f6 100644 --- a/hchyun/hchyun-quartz/src/main/java/com/hchyun/quartz/dao/SysJobLogDao.java +++ b/hchyun/hchyun-quartz/src/main/java/com/hchyun/quartz/dao/SysJobLogDao.java @@ -1,18 +1,18 @@ package com.hchyun.quartz.dao; import java.util.List; + import com.hchyun.quartz.entity.SysJobLog; /** * 调度任务日志信息 数据层 - * + * * @author hchyun */ -public interface SysJobLogDao -{ +public interface SysJobLogDao { /** * 获取quartz调度器日志的计划任务 - * + * * @param jobLog 调度日志信息 * @return 调度任务日志集合 */ @@ -27,7 +27,7 @@ public interface SysJobLogDao /** * 通过调度任务日志ID查询调度信息 - * + * * @param jobLogId 调度任务日志ID * @return 调度任务日志对象信息 */ @@ -35,7 +35,7 @@ public interface SysJobLogDao /** * 新增任务日志 - * + * * @param jobLog 调度日志信息 * @return 结果 */ @@ -43,7 +43,7 @@ public interface SysJobLogDao /** * 批量删除调度日志信息 - * + * * @param logIds 需要删除的数据ID * @return 结果 */ @@ -51,7 +51,7 @@ public interface SysJobLogDao /** * 删除任务日志 - * + * * @param jobId 调度日志ID * @return 结果 */ diff --git a/hchyun/hchyun-quartz/src/main/java/com/hchyun/quartz/entity/SysJob.java b/hchyun/hchyun-quartz/src/main/java/com/hchyun/quartz/entity/SysJob.java index b53d88d..42cc9f1 100644 --- a/hchyun/hchyun-quartz/src/main/java/com/hchyun/quartz/entity/SysJob.java +++ b/hchyun/hchyun-quartz/src/main/java/com/hchyun/quartz/entity/SysJob.java @@ -4,6 +4,7 @@ import java.io.Serializable; import java.util.Date; import javax.validation.constraints.NotBlank; import javax.validation.constraints.Size; + import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; import com.fasterxml.jackson.annotation.JsonFormat; @@ -16,157 +17,154 @@ import com.hchyun.quartz.util.CronUtils; /** * 定时任务调度表 sys_job - * + * * @author hchyun */ -public class SysJob extends BaseEntity implements Serializable -{ +public class SysJob extends BaseEntity implements Serializable { - /** 任务ID */ + /** + * 任务ID + */ @Excel(name = "任务序号", cellType = ColumnType.NUMERIC) private Long jobId; - /** 任务名称 */ + /** + * 任务名称 + */ @Excel(name = "任务名称") private String jobName; - /** 任务组名 */ + /** + * 任务组名 + */ @Excel(name = "任务组名") private String jobGroup; - /** 调用目标字符串 */ + /** + * 调用目标字符串 + */ @Excel(name = "调用目标字符串") private String invokeTarget; - /** cron执行表达式 */ + /** + * cron执行表达式 + */ @Excel(name = "执行表达式 ") private String cronExpression; - /** cron计划策略 */ + /** + * cron计划策略 + */ @Excel(name = "计划策略 ", readConverterExp = "0=默认,1=立即触发执行,2=触发一次执行,3=不触发立即执行") private String misfirePolicy = ScheduleConstants.MISFIRE_DEFAULT; - /** 是否并发执行(0允许 1禁止) */ + /** + * 是否并发执行(0允许 1禁止) + */ @Excel(name = "并发执行", readConverterExp = "0=允许,1=禁止") private String concurrent; - /** 任务状态(0正常 1暂停) */ + /** + * 任务状态(0正常 1暂停) + */ @Excel(name = "任务状态", readConverterExp = "0=正常,1=暂停") private String status; - public Long getJobId() - { + public Long getJobId() { return jobId; } - public void setJobId(Long jobId) - { + public void setJobId(Long jobId) { this.jobId = jobId; } @NotBlank(message = "任务名称不能为空") @Size(min = 0, max = 64, message = "任务名称不能超过64个字符") - public String getJobName() - { + public String getJobName() { return jobName; } - public void setJobName(String jobName) - { + public void setJobName(String jobName) { this.jobName = jobName; } - public String getJobGroup() - { + public String getJobGroup() { return jobGroup; } - public void setJobGroup(String jobGroup) - { + public void setJobGroup(String jobGroup) { this.jobGroup = jobGroup; } @NotBlank(message = "调用目标字符串不能为空") @Size(min = 0, max = 500, message = "调用目标字符串长度不能超过500个字符") - public String getInvokeTarget() - { + public String getInvokeTarget() { return invokeTarget; } - public void setInvokeTarget(String invokeTarget) - { + public void setInvokeTarget(String invokeTarget) { this.invokeTarget = invokeTarget; } @NotBlank(message = "Cron执行表达式不能为空") @Size(min = 0, max = 255, message = "Cron执行表达式不能超过255个字符") - public String getCronExpression() - { + public String getCronExpression() { return cronExpression; } - public void setCronExpression(String cronExpression) - { + public void setCronExpression(String cronExpression) { this.cronExpression = cronExpression; } @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - public Date getNextValidTime() - { - if (StringUtils.isNotEmpty(cronExpression)) - { + public Date getNextValidTime() { + if (StringUtils.isNotEmpty(cronExpression)) { return CronUtils.getNextExecution(cronExpression); } return null; } - public String getMisfirePolicy() - { + public String getMisfirePolicy() { return misfirePolicy; } - public void setMisfirePolicy(String misfirePolicy) - { + public void setMisfirePolicy(String misfirePolicy) { this.misfirePolicy = misfirePolicy; } - public String getConcurrent() - { + public String getConcurrent() { return concurrent; } - public void setConcurrent(String concurrent) - { + public void setConcurrent(String concurrent) { this.concurrent = concurrent; } - public String getStatus() - { + public String getStatus() { return status; } - public void setStatus(String status) - { + public void setStatus(String status) { this.status = status; } @Override public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("jobId", getJobId()) - .append("jobName", getJobName()) - .append("jobGroup", getJobGroup()) - .append("cronExpression", getCronExpression()) - .append("nextValidTime", getNextValidTime()) - .append("misfirePolicy", getMisfirePolicy()) - .append("concurrent", getConcurrent()) - .append("status", getStatus()) - .append("createBy", getCreateBy()) - .append("createTime", getCreateTime()) - .append("updateBy", getUpdateBy()) - .append("updateTime", getUpdateTime()) - .append("remark", getRemark()) - .toString(); + return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) + .append("jobId", getJobId()) + .append("jobName", getJobName()) + .append("jobGroup", getJobGroup()) + .append("cronExpression", getCronExpression()) + .append("nextValidTime", getNextValidTime()) + .append("misfirePolicy", getMisfirePolicy()) + .append("concurrent", getConcurrent()) + .append("status", getStatus()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("remark", getRemark()) + .toString(); } } diff --git a/hchyun/hchyun-quartz/src/main/java/com/hchyun/quartz/entity/SysJobLog.java b/hchyun/hchyun-quartz/src/main/java/com/hchyun/quartz/entity/SysJobLog.java index 1941524..8cdc13e 100644 --- a/hchyun/hchyun-quartz/src/main/java/com/hchyun/quartz/entity/SysJobLog.java +++ b/hchyun/hchyun-quartz/src/main/java/com/hchyun/quartz/entity/SysJobLog.java @@ -1,6 +1,7 @@ package com.hchyun.quartz.entity; import java.util.Date; + import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; import com.hchyun.common.annotation.Excel; @@ -8,148 +9,147 @@ import com.hchyun.common.core.entity.BaseEntity; /** * 定时任务调度日志表 sys_job_log - * + * * @author hchyun */ -public class SysJobLog extends BaseEntity -{ +public class SysJobLog extends BaseEntity { - /** ID */ + /** + * ID + */ @Excel(name = "日志序号") private Long jobLogId; - /** 任务名称 */ + /** + * 任务名称 + */ @Excel(name = "任务名称") private String jobName; - /** 任务组名 */ + /** + * 任务组名 + */ @Excel(name = "任务组名") private String jobGroup; - /** 调用目标字符串 */ + /** + * 调用目标字符串 + */ @Excel(name = "调用目标字符串") private String invokeTarget; - /** 日志信息 */ + /** + * 日志信息 + */ @Excel(name = "日志信息") private String jobMessage; - /** 执行状态(0正常 1失败) */ + /** + * 执行状态(0正常 1失败) + */ @Excel(name = "执行状态", readConverterExp = "0=正常,1=失败") private String status; - /** 异常信息 */ + /** + * 异常信息 + */ @Excel(name = "异常信息") private String exceptionInfo; - /** 开始时间 */ + /** + * 开始时间 + */ private Date startTime; - /** 停止时间 */ + /** + * 停止时间 + */ private Date stopTime; - public Long getJobLogId() - { + public Long getJobLogId() { return jobLogId; } - public void setJobLogId(Long jobLogId) - { + public void setJobLogId(Long jobLogId) { this.jobLogId = jobLogId; } - public String getJobName() - { + public String getJobName() { return jobName; } - public void setJobName(String jobName) - { + public void setJobName(String jobName) { this.jobName = jobName; } - public String getJobGroup() - { + public String getJobGroup() { return jobGroup; } - public void setJobGroup(String jobGroup) - { + public void setJobGroup(String jobGroup) { this.jobGroup = jobGroup; } - public String getInvokeTarget() - { + public String getInvokeTarget() { return invokeTarget; } - public void setInvokeTarget(String invokeTarget) - { + public void setInvokeTarget(String invokeTarget) { this.invokeTarget = invokeTarget; } - public String getJobMessage() - { + public String getJobMessage() { return jobMessage; } - public void setJobMessage(String jobMessage) - { + public void setJobMessage(String jobMessage) { this.jobMessage = jobMessage; } - public String getStatus() - { + public String getStatus() { return status; } - public void setStatus(String status) - { + public void setStatus(String status) { this.status = status; } - public String getExceptionInfo() - { + public String getExceptionInfo() { return exceptionInfo; } - public void setExceptionInfo(String exceptionInfo) - { + public void setExceptionInfo(String exceptionInfo) { this.exceptionInfo = exceptionInfo; } - public Date getStartTime() - { + public Date getStartTime() { return startTime; } - public void setStartTime(Date startTime) - { + public void setStartTime(Date startTime) { this.startTime = startTime; } - - public Date getStopTime() - { + + public Date getStopTime() { return stopTime; } - public void setStopTime(Date stopTime) - { + public void setStopTime(Date stopTime) { this.stopTime = stopTime; } @Override public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("jobLogId", getJobLogId()) - .append("jobName", getJobName()) - .append("jobGroup", getJobGroup()) - .append("jobMessage", getJobMessage()) - .append("status", getStatus()) - .append("exceptionInfo", getExceptionInfo()) - .append("startTime", getStartTime()) - .append("stopTime", getStopTime()) - .toString(); + return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) + .append("jobLogId", getJobLogId()) + .append("jobName", getJobName()) + .append("jobGroup", getJobGroup()) + .append("jobMessage", getJobMessage()) + .append("status", getStatus()) + .append("exceptionInfo", getExceptionInfo()) + .append("startTime", getStartTime()) + .append("stopTime", getStopTime()) + .toString(); } } diff --git a/hchyun/hchyun-quartz/src/main/java/com/hchyun/quartz/service/ISysJobLogService.java b/hchyun/hchyun-quartz/src/main/java/com/hchyun/quartz/service/ISysJobLogService.java index 34f68cb..8622a37 100644 --- a/hchyun/hchyun-quartz/src/main/java/com/hchyun/quartz/service/ISysJobLogService.java +++ b/hchyun/hchyun-quartz/src/main/java/com/hchyun/quartz/service/ISysJobLogService.java @@ -1,18 +1,18 @@ package com.hchyun.quartz.service; import java.util.List; + import com.hchyun.quartz.entity.SysJobLog; /** * 定时任务调度日志信息信息 服务层 - * + * * @author hchyun */ -public interface ISysJobLogService -{ +public interface ISysJobLogService { /** * 获取quartz调度器日志的计划任务 - * + * * @param jobLog 调度日志信息 * @return 调度任务日志集合 */ @@ -20,7 +20,7 @@ public interface ISysJobLogService /** * 通过调度任务日志ID查询调度信息 - * + * * @param jobLogId 调度任务日志ID * @return 调度任务日志对象信息 */ @@ -28,14 +28,14 @@ public interface ISysJobLogService /** * 新增任务日志 - * + * * @param jobLog 调度日志信息 */ public void addJobLog(SysJobLog jobLog); /** * 批量删除调度日志信息 - * + * * @param logIds 需要删除的日志ID * @return 结果 */ @@ -43,7 +43,7 @@ public interface ISysJobLogService /** * 删除任务日志 - * + * * @param jobId 调度日志ID * @return 结果 */ diff --git a/hchyun/hchyun-quartz/src/main/java/com/hchyun/quartz/service/ISysJobService.java b/hchyun/hchyun-quartz/src/main/java/com/hchyun/quartz/service/ISysJobService.java index f37caba..0a9e05c 100644 --- a/hchyun/hchyun-quartz/src/main/java/com/hchyun/quartz/service/ISysJobService.java +++ b/hchyun/hchyun-quartz/src/main/java/com/hchyun/quartz/service/ISysJobService.java @@ -1,20 +1,20 @@ package com.hchyun.quartz.service; import java.util.List; + import org.quartz.SchedulerException; import com.hchyun.common.exception.job.TaskException; import com.hchyun.quartz.entity.SysJob; /** * 定时任务调度信息信息 服务层 - * + * * @author hchyun */ -public interface ISysJobService -{ +public interface ISysJobService { /** * 获取quartz调度器的计划任务 - * + * * @param job 调度信息 * @return 调度任务集合 */ @@ -22,7 +22,7 @@ public interface ISysJobService /** * 通过调度任务ID查询调度信息 - * + * * @param jobId 调度任务ID * @return 调度任务对象信息 */ @@ -30,7 +30,7 @@ public interface ISysJobService /** * 暂停任务 - * + * * @param job 调度信息 * @return 结果 */ @@ -38,7 +38,7 @@ public interface ISysJobService /** * 恢复任务 - * + * * @param job 调度信息 * @return 结果 */ @@ -46,7 +46,7 @@ public interface ISysJobService /** * 删除任务后,所对应的trigger也将被删除 - * + * * @param job 调度信息 * @return 结果 */ @@ -54,7 +54,7 @@ public interface ISysJobService /** * 批量删除调度信息 - * + * * @param jobIds 需要删除的任务ID * @return 结果 */ @@ -62,7 +62,7 @@ public interface ISysJobService /** * 任务调度状态修改 - * + * * @param job 调度信息 * @return 结果 */ @@ -70,7 +70,7 @@ public interface ISysJobService /** * 立即运行任务 - * + * * @param job 调度信息 * @return 结果 */ @@ -78,7 +78,7 @@ public interface ISysJobService /** * 新增任务 - * + * * @param job 调度信息 * @return 结果 */ @@ -86,7 +86,7 @@ public interface ISysJobService /** * 更新任务 - * + * * @param job 调度信息 * @return 结果 */ @@ -94,7 +94,7 @@ public interface ISysJobService /** * 校验cron表达式是否有效 - * + * * @param cronExpression 表达式 * @return 结果 */ diff --git a/hchyun/hchyun-quartz/src/main/java/com/hchyun/quartz/service/impl/SysJobLogServiceImpl.java b/hchyun/hchyun-quartz/src/main/java/com/hchyun/quartz/service/impl/SysJobLogServiceImpl.java index 2dc5549..7a6565e 100644 --- a/hchyun/hchyun-quartz/src/main/java/com/hchyun/quartz/service/impl/SysJobLogServiceImpl.java +++ b/hchyun/hchyun-quartz/src/main/java/com/hchyun/quartz/service/impl/SysJobLogServiceImpl.java @@ -1,6 +1,7 @@ package com.hchyun.quartz.service.impl; import java.util.List; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.hchyun.quartz.entity.SysJobLog; @@ -9,70 +10,64 @@ import com.hchyun.quartz.service.ISysJobLogService; /** * 定时任务调度日志信息 服务层 - * + * * @author hchyun */ @Service -public class SysJobLogServiceImpl implements ISysJobLogService -{ +public class SysJobLogServiceImpl implements ISysJobLogService { @Autowired private SysJobLogDao jobLogMapper; /** * 获取quartz调度器日志的计划任务 - * + * * @param jobLog 调度日志信息 * @return 调度任务日志集合 */ @Override - public List selectJobLogList(SysJobLog jobLog) - { + public List selectJobLogList(SysJobLog jobLog) { return jobLogMapper.selectJobLogList(jobLog); } /** * 通过调度任务日志ID查询调度信息 - * + * * @param jobLogId 调度任务日志ID * @return 调度任务日志对象信息 */ @Override - public SysJobLog selectJobLogById(Long jobLogId) - { + public SysJobLog selectJobLogById(Long jobLogId) { return jobLogMapper.selectJobLogById(jobLogId); } /** * 新增任务日志 - * + * * @param jobLog 调度日志信息 */ @Override - public void addJobLog(SysJobLog jobLog) - { + public void addJobLog(SysJobLog jobLog) { jobLogMapper.insertJobLog(jobLog); } /** * 批量删除调度日志信息 - * + * * @param logIds 需要删除的数据ID * @return 结果 */ @Override - public int deleteJobLogByIds(Long[] logIds) - { + public int deleteJobLogByIds(Long[] logIds) { return jobLogMapper.deleteJobLogByIds(logIds); } /** * 删除任务日志 - * + * * @param jobId 调度日志ID */ @Override - public int deleteJobLogById(Long jobId) - { + public int deleteJobLogById(Long jobId) { return jobLogMapper.deleteJobLogById(jobId); } @@ -80,8 +75,7 @@ public class SysJobLogServiceImpl implements ISysJobLogService * 清空任务日志 */ @Override - public void cleanJobLog() - { + public void cleanJobLog() { jobLogMapper.cleanJobLog(); } } diff --git a/hchyun/hchyun-quartz/src/main/java/com/hchyun/quartz/service/impl/SysJobServiceImpl.java b/hchyun/hchyun-quartz/src/main/java/com/hchyun/quartz/service/impl/SysJobServiceImpl.java index 8657585..ede20df 100644 --- a/hchyun/hchyun-quartz/src/main/java/com/hchyun/quartz/service/impl/SysJobServiceImpl.java +++ b/hchyun/hchyun-quartz/src/main/java/com/hchyun/quartz/service/impl/SysJobServiceImpl.java @@ -2,6 +2,7 @@ package com.hchyun.quartz.service.impl; import java.util.List; import javax.annotation.PostConstruct; + import org.quartz.JobDataMap; import org.quartz.JobKey; import org.quartz.Scheduler; @@ -19,12 +20,11 @@ import com.hchyun.quartz.util.ScheduleUtils; /** * 定时任务调度信息 服务层 - * + * * @author hchyun */ @Service -public class SysJobServiceImpl implements ISysJobService -{ +public class SysJobServiceImpl implements ISysJobService { @Autowired private Scheduler scheduler; @@ -35,55 +35,49 @@ public class SysJobServiceImpl implements ISysJobService * 项目启动时,初始化定时器 主要是防止手动修改数据库导致未同步到定时任务处理(注:不能手动修改数据库ID和任务组名,否则会导致脏数据) */ @PostConstruct - public void init() throws SchedulerException, TaskException - { + public void init() throws SchedulerException, TaskException { scheduler.clear(); List jobList = jobMapper.selectJobAll(); - for (SysJob job : jobList) - { + for (SysJob job : jobList) { ScheduleUtils.createScheduleJob(scheduler, job); } } /** * 获取quartz调度器的计划任务列表 - * + * * @param job 调度信息 * @return */ @Override - public List selectJobList(SysJob job) - { + public List selectJobList(SysJob job) { return jobMapper.selectJobList(job); } /** * 通过调度任务ID查询调度信息 - * + * * @param jobId 调度任务ID * @return 调度任务对象信息 */ @Override - public SysJob selectJobById(Long jobId) - { + public SysJob selectJobById(Long jobId) { return jobMapper.selectJobById(jobId); } /** * 暂停任务 - * + * * @param job 调度信息 */ @Override @Transactional - public int pauseJob(SysJob job) throws SchedulerException - { + public int pauseJob(SysJob job) throws SchedulerException { Long jobId = job.getJobId(); String jobGroup = job.getJobGroup(); job.setStatus(ScheduleConstants.Status.PAUSE.getValue()); int rows = jobMapper.updateJob(job); - if (rows > 0) - { + if (rows > 0) { scheduler.pauseJob(ScheduleUtils.getJobKey(jobId, jobGroup)); } return rows; @@ -91,19 +85,17 @@ public class SysJobServiceImpl implements ISysJobService /** * 恢复任务 - * + * * @param job 调度信息 */ @Override @Transactional - public int resumeJob(SysJob job) throws SchedulerException - { + public int resumeJob(SysJob job) throws SchedulerException { Long jobId = job.getJobId(); String jobGroup = job.getJobGroup(); job.setStatus(ScheduleConstants.Status.NORMAL.getValue()); int rows = jobMapper.updateJob(job); - if (rows > 0) - { + if (rows > 0) { scheduler.resumeJob(ScheduleUtils.getJobKey(jobId, jobGroup)); } return rows; @@ -111,18 +103,16 @@ public class SysJobServiceImpl implements ISysJobService /** * 删除任务后,所对应的trigger也将被删除 - * + * * @param job 调度信息 */ @Override @Transactional - public int deleteJob(SysJob job) throws SchedulerException - { + public int deleteJob(SysJob job) throws SchedulerException { Long jobId = job.getJobId(); String jobGroup = job.getJobGroup(); int rows = jobMapper.deleteJobById(jobId); - if (rows > 0) - { + if (rows > 0) { scheduler.deleteJob(ScheduleUtils.getJobKey(jobId, jobGroup)); } return rows; @@ -130,16 +120,14 @@ public class SysJobServiceImpl implements ISysJobService /** * 批量删除调度信息 - * + * * @param jobIds 需要删除的任务ID * @return 结果 */ @Override @Transactional - public void deleteJobByIds(Long[] jobIds) throws SchedulerException - { - for (Long jobId : jobIds) - { + public void deleteJobByIds(Long[] jobIds) throws SchedulerException { + for (Long jobId : jobIds) { SysJob job = jobMapper.selectJobById(jobId); deleteJob(job); } @@ -147,21 +135,17 @@ public class SysJobServiceImpl implements ISysJobService /** * 任务调度状态修改 - * + * * @param job 调度信息 */ @Override @Transactional - public int changeStatus(SysJob job) throws SchedulerException - { + public int changeStatus(SysJob job) throws SchedulerException { int rows = 0; String status = job.getStatus(); - if (ScheduleConstants.Status.NORMAL.getValue().equals(status)) - { + if (ScheduleConstants.Status.NORMAL.getValue().equals(status)) { rows = resumeJob(job); - } - else if (ScheduleConstants.Status.PAUSE.getValue().equals(status)) - { + } else if (ScheduleConstants.Status.PAUSE.getValue().equals(status)) { rows = pauseJob(job); } return rows; @@ -169,13 +153,12 @@ public class SysJobServiceImpl implements ISysJobService /** * 立即运行任务 - * + * * @param job 调度信息 */ @Override @Transactional - public void run(SysJob job) throws SchedulerException - { + public void run(SysJob job) throws SchedulerException { Long jobId = job.getJobId(); String jobGroup = job.getJobGroup(); SysJob properties = selectJobById(job.getJobId()); @@ -187,17 +170,15 @@ public class SysJobServiceImpl implements ISysJobService /** * 新增任务 - * + * * @param job 调度信息 调度信息 */ @Override @Transactional - public int insertJob(SysJob job) throws SchedulerException, TaskException - { + public int insertJob(SysJob job) throws SchedulerException, TaskException { job.setStatus(ScheduleConstants.Status.PAUSE.getValue()); int rows = jobMapper.insertJob(job); - if (rows > 0) - { + if (rows > 0) { ScheduleUtils.createScheduleJob(scheduler, job); } return rows; @@ -205,17 +186,15 @@ public class SysJobServiceImpl implements ISysJobService /** * 更新任务的时间表达式 - * + * * @param job 调度信息 */ @Override @Transactional - public int updateJob(SysJob job) throws SchedulerException, TaskException - { + public int updateJob(SysJob job) throws SchedulerException, TaskException { SysJob properties = selectJobById(job.getJobId()); int rows = jobMapper.updateJob(job); - if (rows > 0) - { + if (rows > 0) { updateSchedulerJob(job, properties.getJobGroup()); } return rows; @@ -223,17 +202,15 @@ public class SysJobServiceImpl implements ISysJobService /** * 更新任务 - * - * @param job 任务对象 + * + * @param job 任务对象 * @param jobGroup 任务组名 */ - public void updateSchedulerJob(SysJob job, String jobGroup) throws SchedulerException, TaskException - { + public void updateSchedulerJob(SysJob job, String jobGroup) throws SchedulerException, TaskException { Long jobId = job.getJobId(); // 判断是否存在 JobKey jobKey = ScheduleUtils.getJobKey(jobId, jobGroup); - if (scheduler.checkExists(jobKey)) - { + if (scheduler.checkExists(jobKey)) { // 防止创建时存在数据问题 先移除,然后在执行创建操作 scheduler.deleteJob(jobKey); } @@ -242,13 +219,12 @@ public class SysJobServiceImpl implements ISysJobService /** * 校验cron表达式是否有效 - * + * * @param cronExpression 表达式 * @return 结果 */ @Override - public boolean checkCronExpressionIsValid(String cronExpression) - { + public boolean checkCronExpressionIsValid(String cronExpression) { return CronUtils.isValid(cronExpression); } } diff --git a/hchyun/hchyun-quartz/src/main/java/com/hchyun/quartz/task/RyTask.java b/hchyun/hchyun-quartz/src/main/java/com/hchyun/quartz/task/RyTask.java index 56d48a0..e264043 100644 --- a/hchyun/hchyun-quartz/src/main/java/com/hchyun/quartz/task/RyTask.java +++ b/hchyun/hchyun-quartz/src/main/java/com/hchyun/quartz/task/RyTask.java @@ -5,24 +5,20 @@ import com.hchyun.common.utils.StringUtils; /** * 定时任务调度测试 - * + * * @author hchyun */ @Component("ryTask") -public class RyTask -{ - public void ryMultipleParams(String s, Boolean b, Long l, Double d, Integer i) - { +public class RyTask { + public void ryMultipleParams(String s, Boolean b, Long l, Double d, Integer i) { System.out.println(StringUtils.format("执行多参方法: 字符串类型{},布尔类型{},长整型{},浮点型{},整形{}", s, b, l, d, i)); } - public void ryParams(String params) - { + public void ryParams(String params) { System.out.println("执行有参方法:" + params); } - public void ryNoParams() - { + public void ryNoParams() { System.out.println("执行无参方法"); } } diff --git a/hchyun/hchyun-quartz/src/main/java/com/hchyun/quartz/util/AbstractQuartzJob.java b/hchyun/hchyun-quartz/src/main/java/com/hchyun/quartz/util/AbstractQuartzJob.java index 783618b..2656621 100644 --- a/hchyun/hchyun-quartz/src/main/java/com/hchyun/quartz/util/AbstractQuartzJob.java +++ b/hchyun/hchyun-quartz/src/main/java/com/hchyun/quartz/util/AbstractQuartzJob.java @@ -1,6 +1,7 @@ package com.hchyun.quartz.util; import java.util.Date; + import org.quartz.Job; import org.quartz.JobExecutionContext; import org.quartz.JobExecutionException; @@ -21,8 +22,7 @@ import com.hchyun.quartz.service.ISysJobLogService; * * @author hchyun */ -public abstract class AbstractQuartzJob implements Job -{ +public abstract class AbstractQuartzJob implements Job { private static final Logger log = LoggerFactory.getLogger(AbstractQuartzJob.class); /** @@ -31,21 +31,16 @@ public abstract class AbstractQuartzJob implements Job private static ThreadLocal threadLocal = new ThreadLocal<>(); @Override - public void execute(JobExecutionContext context) throws JobExecutionException - { + public void execute(JobExecutionContext context) throws JobExecutionException { SysJob sysJob = new SysJob(); BeanUtils.copyBeanProp(sysJob, context.getMergedJobDataMap().get(ScheduleConstants.TASK_PROPERTIES)); - try - { + try { before(context, sysJob); - if (sysJob != null) - { + if (sysJob != null) { doExecute(context, sysJob); } after(context, sysJob, null); - } - catch (Exception e) - { + } catch (Exception e) { log.error("任务执行异常 - :", e); after(context, sysJob, e); } @@ -55,10 +50,9 @@ public abstract class AbstractQuartzJob implements Job * 执行前 * * @param context 工作执行上下文对象 - * @param sysJob 系统计划任务 + * @param sysJob 系统计划任务 */ - protected void before(JobExecutionContext context, SysJob sysJob) - { + protected void before(JobExecutionContext context, SysJob sysJob) { threadLocal.set(new Date()); } @@ -66,10 +60,9 @@ public abstract class AbstractQuartzJob implements Job * 执行后 * * @param context 工作执行上下文对象 - * @param sysJob 系统计划任务 + * @param sysJob 系统计划任务 */ - protected void after(JobExecutionContext context, SysJob sysJob, Exception e) - { + protected void after(JobExecutionContext context, SysJob sysJob, Exception e) { Date startTime = threadLocal.get(); threadLocal.remove(); @@ -81,14 +74,11 @@ public abstract class AbstractQuartzJob implements Job sysJobLog.setStopTime(new Date()); long runMs = sysJobLog.getStopTime().getTime() - sysJobLog.getStartTime().getTime(); sysJobLog.setJobMessage(sysJobLog.getJobName() + " 总共耗时:" + runMs + "毫秒"); - if (e != null) - { + if (e != null) { sysJobLog.setStatus(Constants.FAIL); String errorMsg = StringUtils.substring(ExceptionUtil.getExceptionMessage(e), 0, 2000); sysJobLog.setExceptionInfo(errorMsg); - } - else - { + } else { sysJobLog.setStatus(Constants.SUCCESS); } @@ -100,7 +90,7 @@ public abstract class AbstractQuartzJob implements Job * 执行方法,由子类重载 * * @param context 工作执行上下文对象 - * @param sysJob 系统计划任务 + * @param sysJob 系统计划任务 * @throws Exception 执行过程中的异常 */ protected abstract void doExecute(JobExecutionContext context, SysJob sysJob) throws Exception; diff --git a/hchyun/hchyun-quartz/src/main/java/com/hchyun/quartz/util/CronUtils.java b/hchyun/hchyun-quartz/src/main/java/com/hchyun/quartz/util/CronUtils.java index 98bc32f..5cf408f 100644 --- a/hchyun/hchyun-quartz/src/main/java/com/hchyun/quartz/util/CronUtils.java +++ b/hchyun/hchyun-quartz/src/main/java/com/hchyun/quartz/util/CronUtils.java @@ -2,24 +2,22 @@ package com.hchyun.quartz.util; import java.text.ParseException; import java.util.Date; + import org.quartz.CronExpression; /** * cron表达式工具类 - * - * @author hchyun * + * @author hchyun */ -public class CronUtils -{ +public class CronUtils { /** * 返回一个布尔值代表一个给定的Cron表达式的有效性 * * @param cronExpression Cron表达式 * @return boolean 表达式是否有效 */ - public static boolean isValid(String cronExpression) - { + public static boolean isValid(String cronExpression) { return CronExpression.isValidExpression(cronExpression); } @@ -29,15 +27,11 @@ public class CronUtils * @param cronExpression Cron表达式 * @return String 无效时返回表达式错误描述,如果有效返回null */ - public static String getInvalidMessage(String cronExpression) - { - try - { + public static String getInvalidMessage(String cronExpression) { + try { new CronExpression(cronExpression); return null; - } - catch (ParseException pe) - { + } catch (ParseException pe) { return pe.getMessage(); } } @@ -48,15 +42,11 @@ public class CronUtils * @param cronExpression Cron表达式 * @return Date 下次Cron表达式执行时间 */ - public static Date getNextExecution(String cronExpression) - { - try - { + public static Date getNextExecution(String cronExpression) { + try { CronExpression cron = new CronExpression(cronExpression); return cron.getNextValidTimeAfter(new Date(System.currentTimeMillis())); - } - catch (ParseException e) - { + } catch (ParseException e) { throw new IllegalArgumentException(e.getMessage()); } } diff --git a/hchyun/hchyun-quartz/src/main/java/com/hchyun/quartz/util/JobInvokeUtil.java b/hchyun/hchyun-quartz/src/main/java/com/hchyun/quartz/util/JobInvokeUtil.java index 3083a23..e5ed638 100644 --- a/hchyun/hchyun-quartz/src/main/java/com/hchyun/quartz/util/JobInvokeUtil.java +++ b/hchyun/hchyun-quartz/src/main/java/com/hchyun/quartz/util/JobInvokeUtil.java @@ -4,6 +4,7 @@ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.LinkedList; import java.util.List; + import com.hchyun.common.utils.StringUtils; import com.hchyun.common.utils.spring.SpringUtils; import com.hchyun.quartz.entity.SysJob; @@ -13,27 +14,22 @@ import com.hchyun.quartz.entity.SysJob; * * @author hchyun */ -public class JobInvokeUtil -{ +public class JobInvokeUtil { /** * 执行方法 * * @param sysJob 系统任务 */ - public static void invokeMethod(SysJob sysJob) throws Exception - { + public static void invokeMethod(SysJob sysJob) throws Exception { String invokeTarget = sysJob.getInvokeTarget(); String beanName = getBeanName(invokeTarget); String methodName = getMethodName(invokeTarget); List methodParams = getMethodParams(invokeTarget); - if (!isValidClassName(beanName)) - { + if (!isValidClassName(beanName)) { Object bean = SpringUtils.getBean(beanName); invokeMethod(bean, methodName, methodParams); - } - else - { + } else { Object bean = Class.forName(beanName).newInstance(); invokeMethod(bean, methodName, methodParams); } @@ -42,21 +38,17 @@ public class JobInvokeUtil /** * 调用任务方法 * - * @param bean 目标对象 - * @param methodName 方法名称 + * @param bean 目标对象 + * @param methodName 方法名称 * @param methodParams 方法参数 */ private static void invokeMethod(Object bean, String methodName, List methodParams) throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, - InvocationTargetException - { - if (StringUtils.isNotNull(methodParams) && methodParams.size() > 0) - { + InvocationTargetException { + if (StringUtils.isNotNull(methodParams) && methodParams.size() > 0) { Method method = bean.getClass().getDeclaredMethod(methodName, getMethodParamsType(methodParams)); method.invoke(bean, getMethodParamsValue(methodParams)); - } - else - { + } else { Method method = bean.getClass().getDeclaredMethod(methodName); method.invoke(bean); } @@ -64,81 +56,70 @@ public class JobInvokeUtil /** * 校验是否为为class包名 - * + * * @param str 名称 * @return true是 false否 */ - public static boolean isValidClassName(String invokeTarget) - { + public static boolean isValidClassName(String invokeTarget) { return StringUtils.countMatches(invokeTarget, ".") > 1; } /** * 获取bean名称 - * + * * @param invokeTarget 目标字符串 * @return bean名称 */ - public static String getBeanName(String invokeTarget) - { + public static String getBeanName(String invokeTarget) { String beanName = StringUtils.substringBefore(invokeTarget, "("); return StringUtils.substringBeforeLast(beanName, "."); } /** * 获取bean方法 - * + * * @param invokeTarget 目标字符串 * @return method方法 */ - public static String getMethodName(String invokeTarget) - { + public static String getMethodName(String invokeTarget) { String methodName = StringUtils.substringBefore(invokeTarget, "("); return StringUtils.substringAfterLast(methodName, "."); } /** * 获取method方法参数相关列表 - * + * * @param invokeTarget 目标字符串 * @return method方法相关参数列表 */ - public static List getMethodParams(String invokeTarget) - { + public static List getMethodParams(String invokeTarget) { String methodStr = StringUtils.substringBetween(invokeTarget, "(", ")"); - if (StringUtils.isEmpty(methodStr)) - { + if (StringUtils.isEmpty(methodStr)) { return null; } String[] methodParams = methodStr.split(","); List classs = new LinkedList<>(); - for (int i = 0; i < methodParams.length; i++) - { + for (int i = 0; i < methodParams.length; i++) { String str = StringUtils.trimToEmpty(methodParams[i]); // String字符串类型,包含' - if (StringUtils.contains(str, "'")) - { - classs.add(new Object[] { StringUtils.replace(str, "'", ""), String.class }); + if (StringUtils.contains(str, "'")) { + classs.add(new Object[]{StringUtils.replace(str, "'", ""), String.class}); } // boolean布尔类型,等于true或者false - else if (StringUtils.equals(str, "true") || StringUtils.equalsIgnoreCase(str, "false")) - { - classs.add(new Object[] { Boolean.valueOf(str), Boolean.class }); + else if (StringUtils.equals(str, "true") || StringUtils.equalsIgnoreCase(str, "false")) { + classs.add(new Object[]{Boolean.valueOf(str), Boolean.class}); } // long长整形,包含L - else if (StringUtils.containsIgnoreCase(str, "L")) - { - classs.add(new Object[] { Long.valueOf(StringUtils.replaceIgnoreCase(str, "L", "")), Long.class }); + else if (StringUtils.containsIgnoreCase(str, "L")) { + classs.add(new Object[]{Long.valueOf(StringUtils.replaceIgnoreCase(str, "L", "")), Long.class}); } // double浮点类型,包含D - else if (StringUtils.containsIgnoreCase(str, "D")) - { - classs.add(new Object[] { Double.valueOf(StringUtils.replaceIgnoreCase(str, "D", "")), Double.class }); + else if (StringUtils.containsIgnoreCase(str, "D")) { + classs.add(new Object[]{Double.valueOf(StringUtils.replaceIgnoreCase(str, "D", "")), Double.class}); } // 其他类型归类为整形 - else - { - classs.add(new Object[] { Integer.valueOf(str), Integer.class }); + else { + classs.add(new Object[]{Integer.valueOf(str), Integer.class}); } } return classs; @@ -146,16 +127,14 @@ public class JobInvokeUtil /** * 获取参数类型 - * + * * @param methodParams 参数相关列表 * @return 参数类型列表 */ - public static Class[] getMethodParamsType(List methodParams) - { + public static Class[] getMethodParamsType(List methodParams) { Class[] classs = new Class[methodParams.size()]; int index = 0; - for (Object[] os : methodParams) - { + for (Object[] os : methodParams) { classs[index] = (Class) os[1]; index++; } @@ -164,16 +143,14 @@ public class JobInvokeUtil /** * 获取参数值 - * + * * @param methodParams 参数相关列表 * @return 参数值列表 */ - public static Object[] getMethodParamsValue(List methodParams) - { + public static Object[] getMethodParamsValue(List methodParams) { Object[] classs = new Object[methodParams.size()]; int index = 0; - for (Object[] os : methodParams) - { + for (Object[] os : methodParams) { classs[index] = (Object) os[0]; index++; } diff --git a/hchyun/hchyun-quartz/src/main/java/com/hchyun/quartz/util/QuartzDisallowConcurrentExecution.java b/hchyun/hchyun-quartz/src/main/java/com/hchyun/quartz/util/QuartzDisallowConcurrentExecution.java index e9210d1..b1d3142 100644 --- a/hchyun/hchyun-quartz/src/main/java/com/hchyun/quartz/util/QuartzDisallowConcurrentExecution.java +++ b/hchyun/hchyun-quartz/src/main/java/com/hchyun/quartz/util/QuartzDisallowConcurrentExecution.java @@ -6,16 +6,13 @@ import com.hchyun.quartz.entity.SysJob; /** * 定时任务处理(禁止并发执行) - * - * @author hchyun * + * @author hchyun */ @DisallowConcurrentExecution -public class QuartzDisallowConcurrentExecution extends AbstractQuartzJob -{ +public class QuartzDisallowConcurrentExecution extends AbstractQuartzJob { @Override - protected void doExecute(JobExecutionContext context, SysJob sysJob) throws Exception - { + protected void doExecute(JobExecutionContext context, SysJob sysJob) throws Exception { JobInvokeUtil.invokeMethod(sysJob); } } diff --git a/hchyun/hchyun-quartz/src/main/java/com/hchyun/quartz/util/QuartzJobExecution.java b/hchyun/hchyun-quartz/src/main/java/com/hchyun/quartz/util/QuartzJobExecution.java index 9836245..8eb72fa 100644 --- a/hchyun/hchyun-quartz/src/main/java/com/hchyun/quartz/util/QuartzJobExecution.java +++ b/hchyun/hchyun-quartz/src/main/java/com/hchyun/quartz/util/QuartzJobExecution.java @@ -5,15 +5,12 @@ import com.hchyun.quartz.entity.SysJob; /** * 定时任务处理(允许并发执行) - * - * @author hchyun * + * @author hchyun */ -public class QuartzJobExecution extends AbstractQuartzJob -{ +public class QuartzJobExecution extends AbstractQuartzJob { @Override - protected void doExecute(JobExecutionContext context, SysJob sysJob) throws Exception - { + protected void doExecute(JobExecutionContext context, SysJob sysJob) throws Exception { JobInvokeUtil.invokeMethod(sysJob); } } diff --git a/hchyun/hchyun-quartz/src/main/java/com/hchyun/quartz/util/ScheduleUtils.java b/hchyun/hchyun-quartz/src/main/java/com/hchyun/quartz/util/ScheduleUtils.java index 96a1224..7abc33b 100644 --- a/hchyun/hchyun-quartz/src/main/java/com/hchyun/quartz/util/ScheduleUtils.java +++ b/hchyun/hchyun-quartz/src/main/java/com/hchyun/quartz/util/ScheduleUtils.java @@ -17,20 +17,17 @@ import com.hchyun.quartz.entity.SysJob; /** * 定时任务工具类 - * - * @author hchyun * + * @author hchyun */ -public class ScheduleUtils -{ +public class ScheduleUtils { /** * 得到quartz任务类 * * @param sysJob 执行计划 * @return 具体执行任务类 */ - private static Class getQuartzJobClass(SysJob sysJob) - { + private static Class getQuartzJobClass(SysJob sysJob) { boolean isConcurrent = "0".equals(sysJob.getConcurrent()); return isConcurrent ? QuartzJobExecution.class : QuartzDisallowConcurrentExecution.class; } @@ -38,24 +35,21 @@ public class ScheduleUtils /** * 构建任务触发对象 */ - public static TriggerKey getTriggerKey(Long jobId, String jobGroup) - { + public static TriggerKey getTriggerKey(Long jobId, String jobGroup) { return TriggerKey.triggerKey(ScheduleConstants.TASK_CLASS_NAME + jobId, jobGroup); } /** * 构建任务键对象 */ - public static JobKey getJobKey(Long jobId, String jobGroup) - { + public static JobKey getJobKey(Long jobId, String jobGroup) { return JobKey.jobKey(ScheduleConstants.TASK_CLASS_NAME + jobId, jobGroup); } /** * 创建定时任务 */ - public static void createScheduleJob(Scheduler scheduler, SysJob job) throws SchedulerException, TaskException - { + public static void createScheduleJob(Scheduler scheduler, SysJob job) throws SchedulerException, TaskException { Class jobClass = getQuartzJobClass(job); // 构建job信息 Long jobId = job.getJobId(); @@ -74,8 +68,7 @@ public class ScheduleUtils jobDetail.getJobDataMap().put(ScheduleConstants.TASK_PROPERTIES, job); // 判断是否存在 - if (scheduler.checkExists(getJobKey(jobId, jobGroup))) - { + if (scheduler.checkExists(getJobKey(jobId, jobGroup))) { // 防止创建时存在数据问题 先移除,然后在执行创建操作 scheduler.deleteJob(getJobKey(jobId, jobGroup)); } @@ -83,8 +76,7 @@ public class ScheduleUtils scheduler.scheduleJob(jobDetail, trigger); // 暂停任务 - if (job.getStatus().equals(ScheduleConstants.Status.PAUSE.getValue())) - { + if (job.getStatus().equals(ScheduleConstants.Status.PAUSE.getValue())) { scheduler.pauseJob(ScheduleUtils.getJobKey(jobId, jobGroup)); } } @@ -93,10 +85,8 @@ public class ScheduleUtils * 设置定时任务策略 */ public static CronScheduleBuilder handleCronScheduleMisfirePolicy(SysJob job, CronScheduleBuilder cb) - throws TaskException - { - switch (job.getMisfirePolicy()) - { + throws TaskException { + switch (job.getMisfirePolicy()) { case ScheduleConstants.MISFIRE_DEFAULT: return cb; case ScheduleConstants.MISFIRE_IGNORE_MISFIRES: diff --git a/hchyun/hchyun-system/pom.xml b/hchyun/hchyun-system/pom.xml index 560ad58..974bfca 100644 --- a/hchyun/hchyun-system/pom.xml +++ b/hchyun/hchyun-system/pom.xml @@ -22,6 +22,11 @@ com.hchyun hchyun-common + + commons-net + commons-net + 3.7 + diff --git a/hchyun/hchyun-system/src/main/java/com/hchyun/system/dao/RegularDao.java b/hchyun/hchyun-system/src/main/java/com/hchyun/system/dao/RegularDao.java index 41dac1b..06a0285 100644 --- a/hchyun/hchyun-system/src/main/java/com/hchyun/system/dao/RegularDao.java +++ b/hchyun/hchyun-system/src/main/java/com/hchyun/system/dao/RegularDao.java @@ -1,19 +1,19 @@ package com.hchyun.system.dao; import java.util.List; + import com.hchyun.system.entity.Regular; /** * 校验规则Dao接口 - * + * * @author hchyun * @date 2021-01-18 */ -public interface RegularDao -{ +public interface RegularDao { /** * 查询校验规则 - * + * * @param id 校验规则ID * @return 校验规则 */ @@ -21,7 +21,7 @@ public interface RegularDao /** * 查询校验规则列表 - * + * * @param regular 校验规则 * @return 校验规则集合 */ @@ -29,7 +29,7 @@ public interface RegularDao /** * 新增校验规则 - * + * * @param regular 校验规则 * @return 结果 */ @@ -37,7 +37,7 @@ public interface RegularDao /** * 修改校验规则 - * + * * @param regular 校验规则 * @return 结果 */ @@ -45,7 +45,7 @@ public interface RegularDao /** * 删除校验规则 - * + * * @param id 校验规则ID * @return 结果 */ @@ -53,7 +53,7 @@ public interface RegularDao /** * 批量删除校验规则 - * + * * @param ids 需要删除的数据ID * @return 结果 */ diff --git a/hchyun/hchyun-system/src/main/java/com/hchyun/system/dao/SysConfigDao.java b/hchyun/hchyun-system/src/main/java/com/hchyun/system/dao/SysConfigDao.java index 2da8573..c6e7b72 100644 --- a/hchyun/hchyun-system/src/main/java/com/hchyun/system/dao/SysConfigDao.java +++ b/hchyun/hchyun-system/src/main/java/com/hchyun/system/dao/SysConfigDao.java @@ -1,18 +1,18 @@ package com.hchyun.system.dao; import java.util.List; + import com.hchyun.system.entity.SysConfig; /** * 参数配置 数据层 - * + * * @author hchyun */ -public interface SysConfigDao -{ +public interface SysConfigDao { /** * 查询参数配置信息 - * + * * @param config 参数配置信息 * @return 参数配置信息 */ @@ -20,7 +20,7 @@ public interface SysConfigDao /** * 查询参数配置列表 - * + * * @param config 参数配置信息 * @return 参数配置集合 */ @@ -28,7 +28,7 @@ public interface SysConfigDao /** * 根据键名查询参数配置信息 - * + * * @param configKey 参数键名 * @return 参数配置信息 */ @@ -36,7 +36,7 @@ public interface SysConfigDao /** * 新增参数配置 - * + * * @param config 参数配置信息 * @return 结果 */ @@ -44,7 +44,7 @@ public interface SysConfigDao /** * 修改参数配置 - * + * * @param config 参数配置信息 * @return 结果 */ @@ -52,7 +52,7 @@ public interface SysConfigDao /** * 删除参数配置 - * + * * @param configId 参数ID * @return 结果 */ @@ -60,7 +60,7 @@ public interface SysConfigDao /** * 批量删除参数信息 - * + * * @param configIds 需要删除的参数ID * @return 结果 */ diff --git a/hchyun/hchyun-system/src/main/java/com/hchyun/system/dao/SysDeptDao.java b/hchyun/hchyun-system/src/main/java/com/hchyun/system/dao/SysDeptDao.java index 908785f..62349ad 100644 --- a/hchyun/hchyun-system/src/main/java/com/hchyun/system/dao/SysDeptDao.java +++ b/hchyun/hchyun-system/src/main/java/com/hchyun/system/dao/SysDeptDao.java @@ -1,19 +1,19 @@ package com.hchyun.system.dao; import java.util.List; + import org.apache.ibatis.annotations.Param; import com.hchyun.common.core.entity.entity.SysDept; /** * 部门管理 数据层 - * + * * @author hchyun */ -public interface SysDeptDao -{ +public interface SysDeptDao { /** * 查询部门管理数据 - * + * * @param dept 部门信息 * @return 部门信息集合 */ @@ -21,8 +21,8 @@ public interface SysDeptDao /** * 根据角色ID查询部门树信息 - * - * @param roleId 角色ID + * + * @param roleId 角色ID * @param deptCheckStrictly 部门树选择项是否关联显示 * @return 选中部门列表 */ @@ -30,7 +30,7 @@ public interface SysDeptDao /** * 根据部门ID查询信息 - * + * * @param deptId 部门ID * @return 部门信息 */ @@ -38,7 +38,7 @@ public interface SysDeptDao /** * 根据ID查询所有子部门 - * + * * @param deptId 部门ID * @return 部门列表 */ @@ -46,7 +46,7 @@ public interface SysDeptDao /** * 根据ID查询所有子部门(正常状态) - * + * * @param deptId 部门ID * @return 子部门数 */ @@ -54,7 +54,7 @@ public interface SysDeptDao /** * 是否存在子节点 - * + * * @param deptId 部门ID * @return 结果 */ @@ -62,7 +62,7 @@ public interface SysDeptDao /** * 查询部门是否存在用户 - * + * * @param deptId 部门ID * @return 结果 */ @@ -70,7 +70,7 @@ public interface SysDeptDao /** * 校验部门名称是否唯一 - * + * * @param deptName 部门名称 * @param parentId 父部门ID * @return 结果 @@ -79,7 +79,7 @@ public interface SysDeptDao /** * 新增部门信息 - * + * * @param dept 部门信息 * @return 结果 */ @@ -87,7 +87,7 @@ public interface SysDeptDao /** * 修改部门信息 - * + * * @param dept 部门信息 * @return 结果 */ @@ -95,14 +95,14 @@ public interface SysDeptDao /** * 修改所在部门的父级部门状态 - * + * * @param dept 部门 */ public void updateDeptStatus(SysDept dept); /** * 修改子元素关系 - * + * * @param depts 子元素 * @return 结果 */ @@ -110,7 +110,7 @@ public interface SysDeptDao /** * 删除部门管理信息 - * + * * @param deptId 部门ID * @return 结果 */ diff --git a/hchyun/hchyun-system/src/main/java/com/hchyun/system/dao/SysDictDataDao.java b/hchyun/hchyun-system/src/main/java/com/hchyun/system/dao/SysDictDataDao.java index b5687e5..1bf29d4 100644 --- a/hchyun/hchyun-system/src/main/java/com/hchyun/system/dao/SysDictDataDao.java +++ b/hchyun/hchyun-system/src/main/java/com/hchyun/system/dao/SysDictDataDao.java @@ -1,19 +1,19 @@ package com.hchyun.system.dao; import java.util.List; + import org.apache.ibatis.annotations.Param; import com.hchyun.common.core.entity.entity.SysDictData; /** * 字典表 数据层 - * + * * @author hchyun */ -public interface SysDictDataDao -{ +public interface SysDictDataDao { /** * 根据条件分页查询字典数据 - * + * * @param dictData 字典数据信息 * @return 字典数据集合信息 */ @@ -21,7 +21,7 @@ public interface SysDictDataDao /** * 根据字典类型查询字典数据 - * + * * @param dictType 字典类型 * @return 字典数据集合信息 */ @@ -29,8 +29,8 @@ public interface SysDictDataDao /** * 根据字典类型和字典键值查询字典数据信息 - * - * @param dictType 字典类型 + * + * @param dictType 字典类型 * @param dictValue 字典键值 * @return 字典标签 */ @@ -38,7 +38,7 @@ public interface SysDictDataDao /** * 根据字典数据ID查询信息 - * + * * @param dictCode 字典数据ID * @return 字典数据 */ @@ -46,7 +46,7 @@ public interface SysDictDataDao /** * 查询字典数据 - * + * * @param dictType 字典类型 * @return 字典数据 */ @@ -54,7 +54,7 @@ public interface SysDictDataDao /** * 通过字典ID删除字典数据信息 - * + * * @param dictCode 字典数据ID * @return 结果 */ @@ -62,7 +62,7 @@ public interface SysDictDataDao /** * 批量删除字典数据信息 - * + * * @param dictCodes 需要删除的字典数据ID * @return 结果 */ @@ -70,7 +70,7 @@ public interface SysDictDataDao /** * 新增字典数据信息 - * + * * @param dictData 字典数据信息 * @return 结果 */ @@ -78,7 +78,7 @@ public interface SysDictDataDao /** * 修改字典数据信息 - * + * * @param dictData 字典数据信息 * @return 结果 */ @@ -86,7 +86,7 @@ public interface SysDictDataDao /** * 同步修改字典类型 - * + * * @param oldDictType 旧字典类型 * @param newDictType 新旧字典类型 * @return 结果 diff --git a/hchyun/hchyun-system/src/main/java/com/hchyun/system/dao/SysDictTypeDao.java b/hchyun/hchyun-system/src/main/java/com/hchyun/system/dao/SysDictTypeDao.java index dbcd2a8..edb1fe8 100644 --- a/hchyun/hchyun-system/src/main/java/com/hchyun/system/dao/SysDictTypeDao.java +++ b/hchyun/hchyun-system/src/main/java/com/hchyun/system/dao/SysDictTypeDao.java @@ -1,20 +1,20 @@ package com.hchyun.system.dao; import java.util.List; + import org.apache.ibatis.annotations.Mapper; import com.hchyun.common.core.entity.entity.SysDictType; /** * 字典表 数据层 - * + * * @author hchyun */ @Mapper -public interface SysDictTypeDao -{ +public interface SysDictTypeDao { /** * 根据条件分页查询字典类型 - * + * * @param dictType 字典类型信息 * @return 字典类型集合信息 */ @@ -22,14 +22,14 @@ public interface SysDictTypeDao /** * 根据所有字典类型 - * + * * @return 字典类型集合信息 */ public List selectDictTypeAll(); /** * 根据字典类型ID查询信息 - * + * * @param dictId 字典类型ID * @return 字典类型 */ @@ -37,7 +37,7 @@ public interface SysDictTypeDao /** * 根据字典类型查询信息 - * + * * @param dictType 字典类型 * @return 字典类型 */ @@ -45,7 +45,7 @@ public interface SysDictTypeDao /** * 通过字典ID删除字典信息 - * + * * @param dictId 字典ID * @return 结果 */ @@ -53,7 +53,7 @@ public interface SysDictTypeDao /** * 批量删除字典类型信息 - * + * * @param dictIds 需要删除的字典ID * @return 结果 */ @@ -61,7 +61,7 @@ public interface SysDictTypeDao /** * 新增字典类型信息 - * + * * @param dictType 字典类型信息 * @return 结果 */ @@ -69,7 +69,7 @@ public interface SysDictTypeDao /** * 修改字典类型信息 - * + * * @param dictType 字典类型信息 * @return 结果 */ @@ -77,7 +77,7 @@ public interface SysDictTypeDao /** * 校验字典类型称是否唯一 - * + * * @param dictType 字典类型 * @return 结果 */ diff --git a/hchyun/hchyun-system/src/main/java/com/hchyun/system/dao/SysLogininforDao.java b/hchyun/hchyun-system/src/main/java/com/hchyun/system/dao/SysLogininforDao.java index 2ea8c43..04a9c66 100644 --- a/hchyun/hchyun-system/src/main/java/com/hchyun/system/dao/SysLogininforDao.java +++ b/hchyun/hchyun-system/src/main/java/com/hchyun/system/dao/SysLogininforDao.java @@ -1,25 +1,25 @@ package com.hchyun.system.dao; import java.util.List; + import com.hchyun.system.entity.SysLogininfor; /** * 系统访问日志情况信息 数据层 - * + * * @author hchyun */ -public interface SysLogininforDao -{ +public interface SysLogininforDao { /** * 新增系统登录日志 - * + * * @param logininfor 访问日志对象 */ public void insertLogininfor(SysLogininfor logininfor); /** * 查询系统登录日志集合 - * + * * @param logininfor 访问日志对象 * @return 登录记录集合 */ @@ -27,7 +27,7 @@ public interface SysLogininforDao /** * 批量删除系统登录日志 - * + * * @param infoIds 需要删除的登录日志ID * @return 结果 */ @@ -35,7 +35,7 @@ public interface SysLogininforDao /** * 清空系统登录日志 - * + * * @return 结果 */ public int cleanLogininfor(); diff --git a/hchyun/hchyun-system/src/main/java/com/hchyun/system/dao/SysMenuDao.java b/hchyun/hchyun-system/src/main/java/com/hchyun/system/dao/SysMenuDao.java index 9d57dc9..145251c 100644 --- a/hchyun/hchyun-system/src/main/java/com/hchyun/system/dao/SysMenuDao.java +++ b/hchyun/hchyun-system/src/main/java/com/hchyun/system/dao/SysMenuDao.java @@ -1,6 +1,7 @@ package com.hchyun.system.dao; import java.util.List; + import org.apache.ibatis.annotations.Param; import com.hchyun.common.core.entity.entity.SysMenu; @@ -9,8 +10,7 @@ import com.hchyun.common.core.entity.entity.SysMenu; * * @author hchyun */ -public interface SysMenuDao -{ +public interface SysMenuDao { /** * 查询系统菜单列表 * @@ -59,8 +59,8 @@ public interface SysMenuDao /** * 根据角色ID查询菜单树信息 - * - * @param roleId 角色ID + * + * @param roleId 角色ID * @param menuCheckStrictly 菜单树选择项是否关联显示 * @return 选中菜单列表 */ diff --git a/hchyun/hchyun-system/src/main/java/com/hchyun/system/dao/SysNoticeDao.java b/hchyun/hchyun-system/src/main/java/com/hchyun/system/dao/SysNoticeDao.java index f5055ad..3df78c3 100644 --- a/hchyun/hchyun-system/src/main/java/com/hchyun/system/dao/SysNoticeDao.java +++ b/hchyun/hchyun-system/src/main/java/com/hchyun/system/dao/SysNoticeDao.java @@ -1,18 +1,18 @@ package com.hchyun.system.dao; import java.util.List; + import com.hchyun.system.entity.SysNotice; /** * 通知公告表 数据层 - * + * * @author hchyun */ -public interface SysNoticeDao -{ +public interface SysNoticeDao { /** * 查询公告信息 - * + * * @param noticeId 公告ID * @return 公告信息 */ @@ -20,7 +20,7 @@ public interface SysNoticeDao /** * 查询公告列表 - * + * * @param notice 公告信息 * @return 公告集合 */ @@ -28,7 +28,7 @@ public interface SysNoticeDao /** * 新增公告 - * + * * @param notice 公告信息 * @return 结果 */ @@ -36,7 +36,7 @@ public interface SysNoticeDao /** * 修改公告 - * + * * @param notice 公告信息 * @return 结果 */ @@ -44,7 +44,7 @@ public interface SysNoticeDao /** * 批量删除公告 - * + * * @param noticeId 公告ID * @return 结果 */ @@ -52,7 +52,7 @@ public interface SysNoticeDao /** * 批量删除公告信息 - * + * * @param noticeIds 需要删除的公告ID * @return 结果 */ diff --git a/hchyun/hchyun-system/src/main/java/com/hchyun/system/dao/SysOperLogDao.java b/hchyun/hchyun-system/src/main/java/com/hchyun/system/dao/SysOperLogDao.java index 34fc8b3..b4fda99 100644 --- a/hchyun/hchyun-system/src/main/java/com/hchyun/system/dao/SysOperLogDao.java +++ b/hchyun/hchyun-system/src/main/java/com/hchyun/system/dao/SysOperLogDao.java @@ -1,25 +1,25 @@ package com.hchyun.system.dao; import java.util.List; + import com.hchyun.system.entity.SysOperLog; /** * 操作日志 数据层 - * + * * @author hchyun */ -public interface SysOperLogDao -{ +public interface SysOperLogDao { /** * 新增操作日志 - * + * * @param operLog 操作日志对象 */ public void insertOperlog(SysOperLog operLog); /** * 查询系统操作日志集合 - * + * * @param operLog 操作日志对象 * @return 操作日志集合 */ @@ -27,7 +27,7 @@ public interface SysOperLogDao /** * 批量删除系统操作日志 - * + * * @param operIds 需要删除的操作日志ID * @return 结果 */ @@ -35,7 +35,7 @@ public interface SysOperLogDao /** * 查询操作日志详细 - * + * * @param operId 操作ID * @return 操作日志对象 */ diff --git a/hchyun/hchyun-system/src/main/java/com/hchyun/system/dao/SysPostDao.java b/hchyun/hchyun-system/src/main/java/com/hchyun/system/dao/SysPostDao.java index 034d65e..41cb096 100644 --- a/hchyun/hchyun-system/src/main/java/com/hchyun/system/dao/SysPostDao.java +++ b/hchyun/hchyun-system/src/main/java/com/hchyun/system/dao/SysPostDao.java @@ -1,18 +1,18 @@ package com.hchyun.system.dao; import java.util.List; + import com.hchyun.system.entity.SysPost; /** * 岗位信息 数据层 - * + * * @author hchyun */ -public interface SysPostDao -{ +public interface SysPostDao { /** * 查询岗位数据集合 - * + * * @param post 岗位信息 * @return 岗位数据集合 */ @@ -20,14 +20,14 @@ public interface SysPostDao /** * 查询所有岗位 - * + * * @return 岗位列表 */ public List selectPostAll(); /** * 通过岗位ID查询岗位信息 - * + * * @param postId 岗位ID * @return 角色对象信息 */ @@ -35,7 +35,7 @@ public interface SysPostDao /** * 根据用户ID获取岗位选择框列表 - * + * * @param userId 用户ID * @return 选中岗位ID列表 */ @@ -43,7 +43,7 @@ public interface SysPostDao /** * 查询用户所属岗位组 - * + * * @param userName 用户名 * @return 结果 */ @@ -51,7 +51,7 @@ public interface SysPostDao /** * 删除岗位信息 - * + * * @param postId 岗位ID * @return 结果 */ @@ -59,7 +59,7 @@ public interface SysPostDao /** * 批量删除岗位信息 - * + * * @param postIds 需要删除的岗位ID * @return 结果 */ @@ -67,7 +67,7 @@ public interface SysPostDao /** * 修改岗位信息 - * + * * @param post 岗位信息 * @return 结果 */ @@ -75,7 +75,7 @@ public interface SysPostDao /** * 新增岗位信息 - * + * * @param post 岗位信息 * @return 结果 */ @@ -83,7 +83,7 @@ public interface SysPostDao /** * 校验岗位名称 - * + * * @param postName 岗位名称 * @return 结果 */ @@ -91,7 +91,7 @@ public interface SysPostDao /** * 校验岗位编码 - * + * * @param postCode 岗位编码 * @return 结果 */ diff --git a/hchyun/hchyun-system/src/main/java/com/hchyun/system/dao/SysRoleDeptDao.java b/hchyun/hchyun-system/src/main/java/com/hchyun/system/dao/SysRoleDeptDao.java index e48f856..59cb569 100644 --- a/hchyun/hchyun-system/src/main/java/com/hchyun/system/dao/SysRoleDeptDao.java +++ b/hchyun/hchyun-system/src/main/java/com/hchyun/system/dao/SysRoleDeptDao.java @@ -1,18 +1,18 @@ package com.hchyun.system.dao; import java.util.List; + import com.hchyun.system.entity.SysRoleDept; /** * 角色与部门关联表 数据层 - * + * * @author hchyun */ -public interface SysRoleDeptDao -{ +public interface SysRoleDeptDao { /** * 通过角色ID删除角色和部门关联 - * + * * @param roleId 角色ID * @return 结果 */ @@ -20,7 +20,7 @@ public interface SysRoleDeptDao /** * 批量删除角色部门关联信息 - * + * * @param ids 需要删除的数据ID * @return 结果 */ @@ -28,7 +28,7 @@ public interface SysRoleDeptDao /** * 查询部门使用数量 - * + * * @param deptId 部门ID * @return 结果 */ @@ -36,7 +36,7 @@ public interface SysRoleDeptDao /** * 批量新增角色部门信息 - * + * * @param roleDeptList 角色部门列表 * @return 结果 */ diff --git a/hchyun/hchyun-system/src/main/java/com/hchyun/system/dao/SysRoleMenuDao.java b/hchyun/hchyun-system/src/main/java/com/hchyun/system/dao/SysRoleMenuDao.java index cc54873..913a26e 100644 --- a/hchyun/hchyun-system/src/main/java/com/hchyun/system/dao/SysRoleMenuDao.java +++ b/hchyun/hchyun-system/src/main/java/com/hchyun/system/dao/SysRoleMenuDao.java @@ -1,18 +1,18 @@ package com.hchyun.system.dao; import java.util.List; + import com.hchyun.system.entity.SysRoleMenu; /** * 角色与菜单关联表 数据层 - * + * * @author hchyun */ -public interface SysRoleMenuDao -{ +public interface SysRoleMenuDao { /** * 查询菜单使用数量 - * + * * @param menuId 菜单ID * @return 结果 */ @@ -20,7 +20,7 @@ public interface SysRoleMenuDao /** * 通过角色ID删除角色和菜单关联 - * + * * @param roleId 角色ID * @return 结果 */ @@ -28,7 +28,7 @@ public interface SysRoleMenuDao /** * 批量新增角色菜单信息 - * + * * @param roleMenuList 角色菜单列表 * @return 结果 */ diff --git a/hchyun/hchyun-system/src/main/java/com/hchyun/system/dao/SysUserDao.java b/hchyun/hchyun-system/src/main/java/com/hchyun/system/dao/SysUserDao.java index 182d710..bc2c168 100644 --- a/hchyun/hchyun-system/src/main/java/com/hchyun/system/dao/SysUserDao.java +++ b/hchyun/hchyun-system/src/main/java/com/hchyun/system/dao/SysUserDao.java @@ -1,19 +1,19 @@ package com.hchyun.system.dao; import java.util.List; + import org.apache.ibatis.annotations.Param; import com.hchyun.common.core.entity.entity.SysUser; /** * 用户表 数据层 - * + * * @author hchyun */ -public interface SysUserDao -{ +public interface SysUserDao { /** * 根据条件分页查询用户列表 - * + * * @param sysUser 用户信息 * @return 用户信息集合信息 */ @@ -21,7 +21,7 @@ public interface SysUserDao /** * 通过用户名查询用户 - * + * * @param userName 用户名 * @return 用户对象信息 */ @@ -29,7 +29,7 @@ public interface SysUserDao /** * 通过用户ID查询用户 - * + * * @param userId 用户ID * @return 用户对象信息 */ @@ -37,7 +37,7 @@ public interface SysUserDao /** * 新增用户信息 - * + * * @param user 用户信息 * @return 结果 */ @@ -45,7 +45,7 @@ public interface SysUserDao /** * 修改用户信息 - * + * * @param user 用户信息 * @return 结果 */ @@ -53,16 +53,16 @@ public interface SysUserDao /** * 修改用户头像 - * + * * @param userName 用户名 - * @param avatar 头像地址 + * @param avatar 头像地址 * @return 结果 */ public int updateUserAvatar(@Param("userName") String userName, @Param("avatar") String avatar); /** * 重置用户密码 - * + * * @param userName 用户名 * @param password 密码 * @return 结果 @@ -71,7 +71,7 @@ public interface SysUserDao /** * 通过用户ID删除用户 - * + * * @param userId 用户ID * @return 结果 */ @@ -79,7 +79,7 @@ public interface SysUserDao /** * 批量删除用户信息 - * + * * @param userIds 需要删除的用户ID * @return 结果 */ @@ -87,7 +87,7 @@ public interface SysUserDao /** * 校验用户名称是否唯一 - * + * * @param userName 用户名称 * @return 结果 */ diff --git a/hchyun/hchyun-system/src/main/java/com/hchyun/system/dao/SysUserPostDao.java b/hchyun/hchyun-system/src/main/java/com/hchyun/system/dao/SysUserPostDao.java index d000b72..960a98b 100644 --- a/hchyun/hchyun-system/src/main/java/com/hchyun/system/dao/SysUserPostDao.java +++ b/hchyun/hchyun-system/src/main/java/com/hchyun/system/dao/SysUserPostDao.java @@ -1,18 +1,18 @@ package com.hchyun.system.dao; import java.util.List; + import com.hchyun.system.entity.SysUserPost; /** * 用户与岗位关联表 数据层 - * + * * @author hchyun */ -public interface SysUserPostDao -{ +public interface SysUserPostDao { /** * 通过用户ID删除用户和岗位关联 - * + * * @param userId 用户ID * @return 结果 */ @@ -20,7 +20,7 @@ public interface SysUserPostDao /** * 通过岗位ID查询岗位使用数量 - * + * * @param postId 岗位ID * @return 结果 */ @@ -28,7 +28,7 @@ public interface SysUserPostDao /** * 批量删除用户和岗位关联 - * + * * @param ids 需要删除的数据ID * @return 结果 */ @@ -36,7 +36,7 @@ public interface SysUserPostDao /** * 批量新增用户岗位信息 - * + * * @param userPostList 用户角色列表 * @return 结果 */ diff --git a/hchyun/hchyun-system/src/main/java/com/hchyun/system/dao/SysUserRoleDao.java b/hchyun/hchyun-system/src/main/java/com/hchyun/system/dao/SysUserRoleDao.java index d35b206..4f3e7e8 100644 --- a/hchyun/hchyun-system/src/main/java/com/hchyun/system/dao/SysUserRoleDao.java +++ b/hchyun/hchyun-system/src/main/java/com/hchyun/system/dao/SysUserRoleDao.java @@ -1,19 +1,19 @@ package com.hchyun.system.dao; import java.util.List; + import org.apache.ibatis.annotations.Param; import com.hchyun.system.entity.SysUserRole; /** * 用户与角色关联表 数据层 - * + * * @author hchyun */ -public interface SysUserRoleDao -{ +public interface SysUserRoleDao { /** * 通过用户ID删除用户和角色关联 - * + * * @param userId 用户ID * @return 结果 */ @@ -21,7 +21,7 @@ public interface SysUserRoleDao /** * 批量删除用户和角色关联 - * + * * @param ids 需要删除的数据ID * @return 结果 */ @@ -29,7 +29,7 @@ public interface SysUserRoleDao /** * 通过角色ID查询角色使用数量 - * + * * @param roleId 角色ID * @return 结果 */ @@ -37,7 +37,7 @@ public interface SysUserRoleDao /** * 批量新增用户角色信息 - * + * * @param userRoleList 用户角色列表 * @return 结果 */ @@ -45,7 +45,7 @@ public interface SysUserRoleDao /** * 删除用户和角色关联信息 - * + * * @param userRole 用户和角色关联信息 * @return 结果 */ @@ -53,8 +53,8 @@ public interface SysUserRoleDao /** * 批量取消授权用户角色 - * - * @param roleId 角色ID + * + * @param roleId 角色ID * @param userIds 需要删除的用户数据ID * @return 结果 */ diff --git a/hchyun/hchyun-system/src/main/java/com/hchyun/system/entity/Regular.java b/hchyun/hchyun-system/src/main/java/com/hchyun/system/entity/Regular.java index 96ee3e8..e84bc47 100644 --- a/hchyun/hchyun-system/src/main/java/com/hchyun/system/entity/Regular.java +++ b/hchyun/hchyun-system/src/main/java/com/hchyun/system/entity/Regular.java @@ -11,90 +11,91 @@ import org.apache.commons.lang3.builder.ToStringStyle; * @author hchyun * @date 2021-01-18 */ -public class Regular extends BaseEntity -{ +public class Regular extends BaseEntity { - /** id */ + /** + * id + */ private Long id; - /** 正则名称 */ + /** + * 正则名称 + */ @Excel(name = "正则名称") private String name; - /** 正则内容 */ + /** + * 正则内容 + */ @Excel(name = "正则内容") private String regular; - /** 验证内容 */ + /** + * 验证内容 + */ @Excel(name = "验证内容") private String validation; - /** 是否启用 1:启动 2:关闭 */ + /** + * 是否启用 1:启动 2:关闭 + */ @Excel(name = "是否启用 1:启动 2:关闭") private Integer enable; - - - public void setId(Long id) - { + public void setId(Long id) { this.id = id; } - public Long getId() - { + public Long getId() { return id; } - public void setName(String name) - { + + public void setName(String name) { this.name = name; } - public String getName() - { + public String getName() { return name; } - public void setRegular(String regular) - { + + public void setRegular(String regular) { this.regular = regular; } - public String getRegular() - { + public String getRegular() { return regular; } - public void setValidation(String validation) - { + + public void setValidation(String validation) { this.validation = validation; } - public String getValidation() - { + public String getValidation() { return validation; } - public void setEnable(Integer enable) - { + + public void setEnable(Integer enable) { this.enable = enable; } - public Integer getEnable() - { + public Integer getEnable() { return enable; } @Override public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("id", getId()) - .append("name", getName()) - .append("regular", getRegular()) - .append("validation", getValidation()) - .append("enable", getEnable()) - .append("createBy", getCreateBy()) - .append("createTime", getCreateTime()) - .append("updateBy", getUpdateBy()) - .append("updateTime", getUpdateTime()) - .toString(); + return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("name", getName()) + .append("regular", getRegular()) + .append("validation", getValidation()) + .append("enable", getEnable()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .toString(); } } diff --git a/hchyun/hchyun-system/src/main/java/com/hchyun/system/entity/SysConfig.java b/hchyun/hchyun-system/src/main/java/com/hchyun/system/entity/SysConfig.java index 6e211c8..f73205b 100644 --- a/hchyun/hchyun-system/src/main/java/com/hchyun/system/entity/SysConfig.java +++ b/hchyun/hchyun-system/src/main/java/com/hchyun/system/entity/SysConfig.java @@ -2,6 +2,7 @@ package com.hchyun.system.entity; import javax.validation.constraints.NotBlank; import javax.validation.constraints.Size; + import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; import com.hchyun.common.annotation.Excel; @@ -10,102 +11,101 @@ import com.hchyun.common.core.entity.BaseEntity; /** * 参数配置表 sys_config - * + * * @author hchyun */ -public class SysConfig extends BaseEntity -{ +public class SysConfig extends BaseEntity { - /** 参数主键 */ + /** + * 参数主键 + */ @Excel(name = "参数主键", cellType = ColumnType.NUMERIC) private Long configId; - /** 参数名称 */ + /** + * 参数名称 + */ @Excel(name = "参数名称") private String configName; - /** 参数键名 */ + /** + * 参数键名 + */ @Excel(name = "参数键名") private String configKey; - /** 参数键值 */ + /** + * 参数键值 + */ @Excel(name = "参数键值") private String configValue; - /** 系统内置(Y是 N否) */ + /** + * 系统内置(Y是 N否) + */ @Excel(name = "系统内置", readConverterExp = "Y=是,N=否") private String configType; - public Long getConfigId() - { + public Long getConfigId() { return configId; } - public void setConfigId(Long configId) - { + public void setConfigId(Long configId) { this.configId = configId; } @NotBlank(message = "参数名称不能为空") @Size(min = 0, max = 100, message = "参数名称不能超过100个字符") - public String getConfigName() - { + public String getConfigName() { return configName; } - public void setConfigName(String configName) - { + public void setConfigName(String configName) { this.configName = configName; } @NotBlank(message = "参数键名长度不能为空") @Size(min = 0, max = 100, message = "参数键名长度不能超过100个字符") - public String getConfigKey() - { + public String getConfigKey() { return configKey; } - public void setConfigKey(String configKey) - { + public void setConfigKey(String configKey) { this.configKey = configKey; } @NotBlank(message = "参数键值不能为空") @Size(min = 0, max = 500, message = "参数键值长度不能超过500个字符") - public String getConfigValue() - { + public String getConfigValue() { return configValue; } - public void setConfigValue(String configValue) - { + public void setConfigValue(String configValue) { this.configValue = configValue; } - public String getConfigType() - { + public String getConfigType() { return configType; } - public void setConfigType(String configType) - { + public void setConfigType(String configType) { this.configType = configType; } - + @Override public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("configId", getConfigId()) - .append("configName", getConfigName()) - .append("configKey", getConfigKey()) - .append("configValue", getConfigValue()) - .append("configType", getConfigType()) - .append("createBy", getCreateBy()) - .append("createTime", getCreateTime()) - .append("updateBy", getUpdateBy()) - .append("updateTime", getUpdateTime()) - .append("remark", getRemark()) - .toString(); + return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) + .append("configId", getConfigId()) + .append("configName", getConfigName()) + .append("configKey", getConfigKey()) + .append("configValue", getConfigValue()) + .append("configType", getConfigType()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("remark", getRemark()) + .toString(); } } diff --git a/hchyun/hchyun-system/src/main/java/com/hchyun/system/entity/SysFile.java b/hchyun/hchyun-system/src/main/java/com/hchyun/system/entity/SysFile.java index 8936041..4da42a9 100644 --- a/hchyun/hchyun-system/src/main/java/com/hchyun/system/entity/SysFile.java +++ b/hchyun/hchyun-system/src/main/java/com/hchyun/system/entity/SysFile.java @@ -68,7 +68,6 @@ public class SysFile extends BaseEntity { private String isPublic; - public void setFileId(Long fileId) { this.fileId = fileId; } @@ -144,19 +143,19 @@ public class SysFile extends BaseEntity { @Override public String toString() { return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) - .append("fileId" , getFileId()) - .append("pId" , getpId()) - .append("roleIds" , getRoleIds()) - .append("fileName" , getFileName()) - .append("mapping" , getMapping()) - .append("fileAddr" , getFileAddr()) - .append("fileType" , getFileType()) - .append("fileSize" , getFileSize()) - .append("isPublic" , getIsPublic()) - .append("createBy" , getCreateBy()) - .append("createTime" , getCreateTime()) - .append("updateBy" , getUpdateBy()) - .append("updateTime" , getUpdateTime()) + .append("fileId", getFileId()) + .append("pId", getpId()) + .append("roleIds", getRoleIds()) + .append("fileName", getFileName()) + .append("mapping", getMapping()) + .append("fileAddr", getFileAddr()) + .append("fileType", getFileType()) + .append("fileSize", getFileSize()) + .append("isPublic", getIsPublic()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) .toString(); } } diff --git a/hchyun/hchyun-system/src/main/java/com/hchyun/system/entity/SysLogininfor.java b/hchyun/hchyun-system/src/main/java/com/hchyun/system/entity/SysLogininfor.java index af6ff1f..3231fba 100644 --- a/hchyun/hchyun-system/src/main/java/com/hchyun/system/entity/SysLogininfor.java +++ b/hchyun/hchyun-system/src/main/java/com/hchyun/system/entity/SysLogininfor.java @@ -1,6 +1,7 @@ package com.hchyun.system.entity; import java.util.Date; + import com.fasterxml.jackson.annotation.JsonFormat; import com.hchyun.common.annotation.Excel; import com.hchyun.common.annotation.Excel.ColumnType; @@ -8,137 +9,136 @@ import com.hchyun.common.core.entity.BaseEntity; /** * 系统访问记录表 sys_logininfor - * + * * @author hchyun */ -public class SysLogininfor extends BaseEntity -{ +public class SysLogininfor extends BaseEntity { - /** ID */ + /** + * ID + */ @Excel(name = "序号", cellType = ColumnType.NUMERIC) private Long infoId; - /** 用户账号 */ + /** + * 用户账号 + */ @Excel(name = "用户账号") private String userName; - /** 登录状态 0成功 1失败 */ + /** + * 登录状态 0成功 1失败 + */ @Excel(name = "登录状态", readConverterExp = "0=成功,1=失败") private String status; - /** 登录IP地址 */ + /** + * 登录IP地址 + */ @Excel(name = "登录地址") private String ipaddr; - /** 登录地点 */ + /** + * 登录地点 + */ @Excel(name = "登录地点") private String loginLocation; - /** 浏览器类型 */ + /** + * 浏览器类型 + */ @Excel(name = "浏览器") private String browser; - /** 操作系统 */ + /** + * 操作系统 + */ @Excel(name = "操作系统") private String os; - /** 提示消息 */ + /** + * 提示消息 + */ @Excel(name = "提示消息") private String msg; - /** 访问时间 */ + /** + * 访问时间 + */ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @Excel(name = "访问时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") private Date loginTime; - public Long getInfoId() - { + public Long getInfoId() { return infoId; } - public void setInfoId(Long infoId) - { + public void setInfoId(Long infoId) { this.infoId = infoId; } - public String getUserName() - { + public String getUserName() { return userName; } - public void setUserName(String userName) - { + public void setUserName(String userName) { this.userName = userName; } - public String getStatus() - { + public String getStatus() { return status; } - public void setStatus(String status) - { + public void setStatus(String status) { this.status = status; } - public String getIpaddr() - { + public String getIpaddr() { return ipaddr; } - public void setIpaddr(String ipaddr) - { + public void setIpaddr(String ipaddr) { this.ipaddr = ipaddr; } - public String getLoginLocation() - { + public String getLoginLocation() { return loginLocation; } - public void setLoginLocation(String loginLocation) - { + public void setLoginLocation(String loginLocation) { this.loginLocation = loginLocation; } - public String getBrowser() - { + public String getBrowser() { return browser; } - public void setBrowser(String browser) - { + public void setBrowser(String browser) { this.browser = browser; } - public String getOs() - { + public String getOs() { return os; } - public void setOs(String os) - { + public void setOs(String os) { this.os = os; } - public String getMsg() - { + public String getMsg() { return msg; } - public void setMsg(String msg) - { + public void setMsg(String msg) { this.msg = msg; } - public Date getLoginTime() - { + public Date getLoginTime() { return loginTime; } - public void setLoginTime(Date loginTime) - { + public void setLoginTime(Date loginTime) { this.loginTime = loginTime; } } diff --git a/hchyun/hchyun-system/src/main/java/com/hchyun/system/entity/SysNotice.java b/hchyun/hchyun-system/src/main/java/com/hchyun/system/entity/SysNotice.java index 738cc79..2fda2f0 100644 --- a/hchyun/hchyun-system/src/main/java/com/hchyun/system/entity/SysNotice.java +++ b/hchyun/hchyun-system/src/main/java/com/hchyun/system/entity/SysNotice.java @@ -2,99 +2,99 @@ package com.hchyun.system.entity; import javax.validation.constraints.NotBlank; import javax.validation.constraints.Size; + import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; import com.hchyun.common.core.entity.BaseEntity; /** * 通知公告表 sys_notice - * + * * @author hchyun */ -public class SysNotice extends BaseEntity -{ +public class SysNotice extends BaseEntity { - /** 公告ID */ + /** + * 公告ID + */ private Long noticeId; - /** 公告标题 */ + /** + * 公告标题 + */ private String noticeTitle; - /** 公告类型(1通知 2公告) */ + /** + * 公告类型(1通知 2公告) + */ private String noticeType; - /** 公告内容 */ + /** + * 公告内容 + */ private String noticeContent; - /** 公告状态(0正常 1关闭) */ + /** + * 公告状态(0正常 1关闭) + */ private String status; - public Long getNoticeId() - { + public Long getNoticeId() { return noticeId; } - public void setNoticeId(Long noticeId) - { + public void setNoticeId(Long noticeId) { this.noticeId = noticeId; } - public void setNoticeTitle(String noticeTitle) - { + public void setNoticeTitle(String noticeTitle) { this.noticeTitle = noticeTitle; } @NotBlank(message = "公告标题不能为空") @Size(min = 0, max = 50, message = "公告标题不能超过50个字符") - public String getNoticeTitle() - { + public String getNoticeTitle() { return noticeTitle; } - public void setNoticeType(String noticeType) - { + public void setNoticeType(String noticeType) { this.noticeType = noticeType; } - public String getNoticeType() - { + public String getNoticeType() { return noticeType; } - public void setNoticeContent(String noticeContent) - { + public void setNoticeContent(String noticeContent) { this.noticeContent = noticeContent; } - public String getNoticeContent() - { + public String getNoticeContent() { return noticeContent; } - public void setStatus(String status) - { + public void setStatus(String status) { this.status = status; } - public String getStatus() - { + public String getStatus() { return status; } @Override public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("noticeId", getNoticeId()) - .append("noticeTitle", getNoticeTitle()) - .append("noticeType", getNoticeType()) - .append("noticeContent", getNoticeContent()) - .append("status", getStatus()) - .append("createBy", getCreateBy()) - .append("createTime", getCreateTime()) - .append("updateBy", getUpdateBy()) - .append("updateTime", getUpdateTime()) - .append("remark", getRemark()) - .toString(); + return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) + .append("noticeId", getNoticeId()) + .append("noticeTitle", getNoticeTitle()) + .append("noticeType", getNoticeType()) + .append("noticeContent", getNoticeContent()) + .append("status", getStatus()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("remark", getRemark()) + .toString(); } } diff --git a/hchyun/hchyun-system/src/main/java/com/hchyun/system/entity/SysOperLog.java b/hchyun/hchyun-system/src/main/java/com/hchyun/system/entity/SysOperLog.java index b8c3dfc..48b62b3 100644 --- a/hchyun/hchyun-system/src/main/java/com/hchyun/system/entity/SysOperLog.java +++ b/hchyun/hchyun-system/src/main/java/com/hchyun/system/entity/SysOperLog.java @@ -1,6 +1,7 @@ package com.hchyun.system.entity; import java.util.Date; + import com.fasterxml.jackson.annotation.JsonFormat; import com.hchyun.common.annotation.Excel; import com.hchyun.common.annotation.Excel.ColumnType; @@ -8,248 +9,247 @@ import com.hchyun.common.core.entity.BaseEntity; /** * 操作日志记录表 oper_log - * + * * @author hchyun */ -public class SysOperLog extends BaseEntity -{ +public class SysOperLog extends BaseEntity { - /** 日志主键 */ + /** + * 日志主键 + */ @Excel(name = "操作序号", cellType = ColumnType.NUMERIC) private Long operId; - /** 操作模块 */ + /** + * 操作模块 + */ @Excel(name = "操作模块") private String title; - /** 业务类型(0其它 1新增 2修改 3删除) */ + /** + * 业务类型(0其它 1新增 2修改 3删除) + */ @Excel(name = "业务类型", readConverterExp = "0=其它,1=新增,2=修改,3=删除,4=授权,5=导出,6=导入,7=强退,8=生成代码,9=清空数据") private Integer businessType; - /** 业务类型数组 */ + /** + * 业务类型数组 + */ private Integer[] businessTypes; - /** 请求方法 */ + /** + * 请求方法 + */ @Excel(name = "请求方法") private String method; - /** 请求方式 */ + /** + * 请求方式 + */ @Excel(name = "请求方式") private String requestMethod; - /** 操作类别(0其它 1后台用户 2手机端用户) */ + /** + * 操作类别(0其它 1后台用户 2手机端用户) + */ @Excel(name = "操作类别", readConverterExp = "0=其它,1=后台用户,2=手机端用户") private Integer operatorType; - /** 操作人员 */ + /** + * 操作人员 + */ @Excel(name = "操作人员") private String operName; - /** 部门名称 */ + /** + * 部门名称 + */ @Excel(name = "部门名称") private String deptName; - /** 请求url */ + /** + * 请求url + */ @Excel(name = "请求地址") private String operUrl; - /** 操作地址 */ + /** + * 操作地址 + */ @Excel(name = "操作地址") private String operIp; - /** 操作地点 */ + /** + * 操作地点 + */ @Excel(name = "操作地点") private String operLocation; - /** 请求参数 */ + /** + * 请求参数 + */ @Excel(name = "请求参数") private String operParam; - /** 返回参数 */ + /** + * 返回参数 + */ @Excel(name = "返回参数") private String jsonResult; - /** 操作状态(0正常 1异常) */ + /** + * 操作状态(0正常 1异常) + */ @Excel(name = "状态", readConverterExp = "0=正常,1=异常") private Integer status; - /** 错误消息 */ + /** + * 错误消息 + */ @Excel(name = "错误消息") private String errorMsg; - /** 操作时间 */ + /** + * 操作时间 + */ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @Excel(name = "操作时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") private Date operTime; - public Long getOperId() - { + public Long getOperId() { return operId; } - public void setOperId(Long operId) - { + public void setOperId(Long operId) { this.operId = operId; } - public String getTitle() - { + public String getTitle() { return title; } - public void setTitle(String title) - { + public void setTitle(String title) { this.title = title; } - public Integer getBusinessType() - { + public Integer getBusinessType() { return businessType; } - public void setBusinessType(Integer businessType) - { + public void setBusinessType(Integer businessType) { this.businessType = businessType; } - public Integer[] getBusinessTypes() - { + public Integer[] getBusinessTypes() { return businessTypes; } - public void setBusinessTypes(Integer[] businessTypes) - { + public void setBusinessTypes(Integer[] businessTypes) { this.businessTypes = businessTypes; } - public String getMethod() - { + public String getMethod() { return method; } - public void setMethod(String method) - { + public void setMethod(String method) { this.method = method; } - public String getRequestMethod() - { + public String getRequestMethod() { return requestMethod; } - public void setRequestMethod(String requestMethod) - { + public void setRequestMethod(String requestMethod) { this.requestMethod = requestMethod; } - public Integer getOperatorType() - { + public Integer getOperatorType() { return operatorType; } - public void setOperatorType(Integer operatorType) - { + public void setOperatorType(Integer operatorType) { this.operatorType = operatorType; } - public String getOperName() - { + public String getOperName() { return operName; } - public void setOperName(String operName) - { + public void setOperName(String operName) { this.operName = operName; } - public String getDeptName() - { + public String getDeptName() { return deptName; } - public void setDeptName(String deptName) - { + public void setDeptName(String deptName) { this.deptName = deptName; } - public String getOperUrl() - { + public String getOperUrl() { return operUrl; } - public void setOperUrl(String operUrl) - { + public void setOperUrl(String operUrl) { this.operUrl = operUrl; } - public String getOperIp() - { + public String getOperIp() { return operIp; } - public void setOperIp(String operIp) - { + public void setOperIp(String operIp) { this.operIp = operIp; } - public String getOperLocation() - { + public String getOperLocation() { return operLocation; } - public void setOperLocation(String operLocation) - { + public void setOperLocation(String operLocation) { this.operLocation = operLocation; } - public String getOperParam() - { + public String getOperParam() { return operParam; } - public void setOperParam(String operParam) - { + public void setOperParam(String operParam) { this.operParam = operParam; } - public String getJsonResult() - { + public String getJsonResult() { return jsonResult; } - public void setJsonResult(String jsonResult) - { + public void setJsonResult(String jsonResult) { this.jsonResult = jsonResult; } - public Integer getStatus() - { + public Integer getStatus() { return status; } - public void setStatus(Integer status) - { + public void setStatus(Integer status) { this.status = status; } - public String getErrorMsg() - { + public String getErrorMsg() { return errorMsg; } - public void setErrorMsg(String errorMsg) - { + public void setErrorMsg(String errorMsg) { this.errorMsg = errorMsg; } - public Date getOperTime() - { + public Date getOperTime() { return operTime; } - public void setOperTime(Date operTime) - { + public void setOperTime(Date operTime) { this.operTime = operTime; } } diff --git a/hchyun/hchyun-system/src/main/java/com/hchyun/system/entity/SysPost.java b/hchyun/hchyun-system/src/main/java/com/hchyun/system/entity/SysPost.java index a0a6098..213eb31 100644 --- a/hchyun/hchyun-system/src/main/java/com/hchyun/system/entity/SysPost.java +++ b/hchyun/hchyun-system/src/main/java/com/hchyun/system/entity/SysPost.java @@ -2,6 +2,7 @@ package com.hchyun.system.entity; import javax.validation.constraints.NotBlank; import javax.validation.constraints.Size; + import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; import com.hchyun.common.annotation.Excel; @@ -10,114 +11,113 @@ import com.hchyun.common.core.entity.BaseEntity; /** * 岗位表 sys_post - * + * * @author hchyun */ -public class SysPost extends BaseEntity -{ +public class SysPost extends BaseEntity { - /** 岗位序号 */ + /** + * 岗位序号 + */ @Excel(name = "岗位序号", cellType = ColumnType.NUMERIC) private Long postId; - /** 岗位编码 */ + /** + * 岗位编码 + */ @Excel(name = "岗位编码") private String postCode; - /** 岗位名称 */ + /** + * 岗位名称 + */ @Excel(name = "岗位名称") private String postName; - /** 岗位排序 */ + /** + * 岗位排序 + */ @Excel(name = "岗位排序") private String postSort; - /** 状态(0正常 1停用) */ + /** + * 状态(0正常 1停用) + */ @Excel(name = "状态", readConverterExp = "0=正常,1=停用") private String status; - /** 用户是否存在此岗位标识 默认不存在 */ + /** + * 用户是否存在此岗位标识 默认不存在 + */ private boolean flag = false; - public Long getPostId() - { + public Long getPostId() { return postId; } - public void setPostId(Long postId) - { + public void setPostId(Long postId) { this.postId = postId; } @NotBlank(message = "岗位编码不能为空") @Size(min = 0, max = 64, message = "岗位编码长度不能超过64个字符") - public String getPostCode() - { + public String getPostCode() { return postCode; } - public void setPostCode(String postCode) - { + public void setPostCode(String postCode) { this.postCode = postCode; } @NotBlank(message = "岗位名称不能为空") @Size(min = 0, max = 50, message = "岗位名称长度不能超过50个字符") - public String getPostName() - { + public String getPostName() { return postName; } - public void setPostName(String postName) - { + public void setPostName(String postName) { this.postName = postName; } @NotBlank(message = "显示顺序不能为空") - public String getPostSort() - { + public String getPostSort() { return postSort; } - public void setPostSort(String postSort) - { + public void setPostSort(String postSort) { this.postSort = postSort; } - public String getStatus() - { + public String getStatus() { return status; } - public void setStatus(String status) - { + public void setStatus(String status) { this.status = status; } - public boolean isFlag() - { + public boolean isFlag() { return flag; } - public void setFlag(boolean flag) - { + public void setFlag(boolean flag) { this.flag = flag; } - + @Override public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("postId", getPostId()) - .append("postCode", getPostCode()) - .append("postName", getPostName()) - .append("postSort", getPostSort()) - .append("status", getStatus()) - .append("createBy", getCreateBy()) - .append("createTime", getCreateTime()) - .append("updateBy", getUpdateBy()) - .append("updateTime", getUpdateTime()) - .append("remark", getRemark()) - .toString(); + return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) + .append("postId", getPostId()) + .append("postCode", getPostCode()) + .append("postName", getPostName()) + .append("postSort", getPostSort()) + .append("status", getStatus()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("remark", getRemark()) + .toString(); } } diff --git a/hchyun/hchyun-system/src/main/java/com/hchyun/system/entity/SysRoleDept.java b/hchyun/hchyun-system/src/main/java/com/hchyun/system/entity/SysRoleDept.java index 852a7b6..166308c 100644 --- a/hchyun/hchyun-system/src/main/java/com/hchyun/system/entity/SysRoleDept.java +++ b/hchyun/hchyun-system/src/main/java/com/hchyun/system/entity/SysRoleDept.java @@ -5,42 +5,41 @@ import org.apache.commons.lang3.builder.ToStringStyle; /** * 角色和部门关联 sys_role_dept - * + * * @author hchyun */ -public class SysRoleDept -{ - /** 角色ID */ +public class SysRoleDept { + /** + * 角色ID + */ private Long roleId; - - /** 部门ID */ + + /** + * 部门ID + */ private Long deptId; - public Long getRoleId() - { + public Long getRoleId() { return roleId; } - public void setRoleId(Long roleId) - { + public void setRoleId(Long roleId) { this.roleId = roleId; } - public Long getDeptId() - { + public Long getDeptId() { return deptId; } - public void setDeptId(Long deptId) - { + public void setDeptId(Long deptId) { this.deptId = deptId; } @Override public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("roleId", getRoleId()) - .append("deptId", getDeptId()) - .toString(); + return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) + .append("roleId", getRoleId()) + .append("deptId", getDeptId()) + .toString(); } } diff --git a/hchyun/hchyun-system/src/main/java/com/hchyun/system/entity/SysRoleMenu.java b/hchyun/hchyun-system/src/main/java/com/hchyun/system/entity/SysRoleMenu.java index 681786a..ffa623a 100644 --- a/hchyun/hchyun-system/src/main/java/com/hchyun/system/entity/SysRoleMenu.java +++ b/hchyun/hchyun-system/src/main/java/com/hchyun/system/entity/SysRoleMenu.java @@ -5,42 +5,41 @@ import org.apache.commons.lang3.builder.ToStringStyle; /** * 角色和菜单关联 sys_role_menu - * + * * @author hchyun */ -public class SysRoleMenu -{ - /** 角色ID */ +public class SysRoleMenu { + /** + * 角色ID + */ private Long roleId; - - /** 菜单ID */ + + /** + * 菜单ID + */ private Long menuId; - public Long getRoleId() - { + public Long getRoleId() { return roleId; } - public void setRoleId(Long roleId) - { + public void setRoleId(Long roleId) { this.roleId = roleId; } - public Long getMenuId() - { + public Long getMenuId() { return menuId; } - public void setMenuId(Long menuId) - { + public void setMenuId(Long menuId) { this.menuId = menuId; } @Override public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("roleId", getRoleId()) - .append("menuId", getMenuId()) - .toString(); + return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) + .append("roleId", getRoleId()) + .append("menuId", getMenuId()) + .toString(); } } diff --git a/hchyun/hchyun-system/src/main/java/com/hchyun/system/entity/SysUserOnline.java b/hchyun/hchyun-system/src/main/java/com/hchyun/system/entity/SysUserOnline.java index 0edb64a..d9f345c 100644 --- a/hchyun/hchyun-system/src/main/java/com/hchyun/system/entity/SysUserOnline.java +++ b/hchyun/hchyun-system/src/main/java/com/hchyun/system/entity/SysUserOnline.java @@ -2,112 +2,111 @@ package com.hchyun.system.entity; /** * 当前在线会话 - * + * * @author hchyun */ -public class SysUserOnline -{ - /** 会话编号 */ +public class SysUserOnline { + /** + * 会话编号 + */ private String tokenId; - /** 部门名称 */ + /** + * 部门名称 + */ private String deptName; - /** 用户名称 */ + /** + * 用户名称 + */ private String userName; - /** 登录IP地址 */ + /** + * 登录IP地址 + */ private String ipaddr; - /** 登录地址 */ + /** + * 登录地址 + */ private String loginLocation; - /** 浏览器类型 */ + /** + * 浏览器类型 + */ private String browser; - /** 操作系统 */ + /** + * 操作系统 + */ private String os; - /** 登录时间 */ + /** + * 登录时间 + */ private Long loginTime; - public String getTokenId() - { + public String getTokenId() { return tokenId; } - public void setTokenId(String tokenId) - { + public void setTokenId(String tokenId) { this.tokenId = tokenId; } - public String getDeptName() - { + public String getDeptName() { return deptName; } - public void setDeptName(String deptName) - { + public void setDeptName(String deptName) { this.deptName = deptName; } - public String getUserName() - { + public String getUserName() { return userName; } - public void setUserName(String userName) - { + public void setUserName(String userName) { this.userName = userName; } - public String getIpaddr() - { + public String getIpaddr() { return ipaddr; } - public void setIpaddr(String ipaddr) - { + public void setIpaddr(String ipaddr) { this.ipaddr = ipaddr; } - public String getLoginLocation() - { + public String getLoginLocation() { return loginLocation; } - public void setLoginLocation(String loginLocation) - { + public void setLoginLocation(String loginLocation) { this.loginLocation = loginLocation; } - public String getBrowser() - { + public String getBrowser() { return browser; } - public void setBrowser(String browser) - { + public void setBrowser(String browser) { this.browser = browser; } - public String getOs() - { + public String getOs() { return os; } - public void setOs(String os) - { + public void setOs(String os) { this.os = os; } - public Long getLoginTime() - { + public Long getLoginTime() { return loginTime; } - public void setLoginTime(Long loginTime) - { + public void setLoginTime(Long loginTime) { this.loginTime = loginTime; } } diff --git a/hchyun/hchyun-system/src/main/java/com/hchyun/system/entity/SysUserPost.java b/hchyun/hchyun-system/src/main/java/com/hchyun/system/entity/SysUserPost.java index fd8404b..7f4b0a7 100644 --- a/hchyun/hchyun-system/src/main/java/com/hchyun/system/entity/SysUserPost.java +++ b/hchyun/hchyun-system/src/main/java/com/hchyun/system/entity/SysUserPost.java @@ -5,42 +5,41 @@ import org.apache.commons.lang3.builder.ToStringStyle; /** * 用户和岗位关联 sys_user_post - * + * * @author hchyun */ -public class SysUserPost -{ - /** 用户ID */ +public class SysUserPost { + /** + * 用户ID + */ private Long userId; - - /** 岗位ID */ + + /** + * 岗位ID + */ private Long postId; - public Long getUserId() - { + public Long getUserId() { return userId; } - public void setUserId(Long userId) - { + public void setUserId(Long userId) { this.userId = userId; } - public Long getPostId() - { + public Long getPostId() { return postId; } - public void setPostId(Long postId) - { + public void setPostId(Long postId) { this.postId = postId; } @Override public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("userId", getUserId()) - .append("postId", getPostId()) - .toString(); + return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) + .append("userId", getUserId()) + .append("postId", getPostId()) + .toString(); } } diff --git a/hchyun/hchyun-system/src/main/java/com/hchyun/system/entity/SysUserRole.java b/hchyun/hchyun-system/src/main/java/com/hchyun/system/entity/SysUserRole.java index 91ee767..ba47470 100644 --- a/hchyun/hchyun-system/src/main/java/com/hchyun/system/entity/SysUserRole.java +++ b/hchyun/hchyun-system/src/main/java/com/hchyun/system/entity/SysUserRole.java @@ -5,42 +5,41 @@ import org.apache.commons.lang3.builder.ToStringStyle; /** * 用户和角色关联 sys_user_role - * + * * @author hchyun */ -public class SysUserRole -{ - /** 用户ID */ +public class SysUserRole { + /** + * 用户ID + */ private Long userId; - - /** 角色ID */ + + /** + * 角色ID + */ private Long roleId; - public Long getUserId() - { + public Long getUserId() { return userId; } - public void setUserId(Long userId) - { + public void setUserId(Long userId) { this.userId = userId; } - public Long getRoleId() - { + public Long getRoleId() { return roleId; } - public void setRoleId(Long roleId) - { + public void setRoleId(Long roleId) { this.roleId = roleId; } @Override public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("userId", getUserId()) - .append("roleId", getRoleId()) - .toString(); + return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) + .append("userId", getUserId()) + .append("roleId", getRoleId()) + .toString(); } } diff --git a/hchyun/hchyun-system/src/main/java/com/hchyun/system/entity/vo/MetaVo.java b/hchyun/hchyun-system/src/main/java/com/hchyun/system/entity/vo/MetaVo.java index 16e12ee..ca940ab 100644 --- a/hchyun/hchyun-system/src/main/java/com/hchyun/system/entity/vo/MetaVo.java +++ b/hchyun/hchyun-system/src/main/java/com/hchyun/system/entity/vo/MetaVo.java @@ -2,11 +2,10 @@ package com.hchyun.system.entity.vo; /** * 路由显示信息 - * + * * @author hchyun */ -public class MetaVo -{ +public class MetaVo { /** * 设置该路由在侧边栏和面包屑中展示的名字 */ @@ -22,50 +21,41 @@ public class MetaVo */ private boolean noCache; - public MetaVo() - { + public MetaVo() { } - public MetaVo(String title, String icon) - { + public MetaVo(String title, String icon) { this.title = title; this.icon = icon; } - public MetaVo(String title, String icon, boolean noCache) - { + public MetaVo(String title, String icon, boolean noCache) { this.title = title; this.icon = icon; this.noCache = noCache; } - public boolean isNoCache() - { + public boolean isNoCache() { return noCache; } - public void setNoCache(boolean noCache) - { + public void setNoCache(boolean noCache) { this.noCache = noCache; } - public String getTitle() - { + public String getTitle() { return title; } - public void setTitle(String title) - { + public void setTitle(String title) { this.title = title; } - public String getIcon() - { + public String getIcon() { return icon; } - public void setIcon(String icon) - { + public void setIcon(String icon) { this.icon = icon; } } diff --git a/hchyun/hchyun-system/src/main/java/com/hchyun/system/entity/vo/RouterVo.java b/hchyun/hchyun-system/src/main/java/com/hchyun/system/entity/vo/RouterVo.java index eedddf6..455e303 100644 --- a/hchyun/hchyun-system/src/main/java/com/hchyun/system/entity/vo/RouterVo.java +++ b/hchyun/hchyun-system/src/main/java/com/hchyun/system/entity/vo/RouterVo.java @@ -1,16 +1,16 @@ package com.hchyun.system.entity.vo; import com.fasterxml.jackson.annotation.JsonInclude; + import java.util.List; /** * 路由配置信息 - * + * * @author hchyun */ @JsonInclude(JsonInclude.Include.NON_EMPTY) -public class RouterVo -{ +public class RouterVo { /** * 路由名字 */ @@ -51,83 +51,67 @@ public class RouterVo */ private List children; - public String getName() - { + public String getName() { return name; } - public void setName(String name) - { + public void setName(String name) { this.name = name; } - public String getPath() - { + public String getPath() { return path; } - public void setPath(String path) - { + public void setPath(String path) { this.path = path; } - public boolean getHidden() - { + public boolean getHidden() { return hidden; } - public void setHidden(boolean hidden) - { + public void setHidden(boolean hidden) { this.hidden = hidden; } - public String getRedirect() - { + public String getRedirect() { return redirect; } - public void setRedirect(String redirect) - { + public void setRedirect(String redirect) { this.redirect = redirect; } - public String getComponent() - { + public String getComponent() { return component; } - public void setComponent(String component) - { + public void setComponent(String component) { this.component = component; } - public Boolean getAlwaysShow() - { + public Boolean getAlwaysShow() { return alwaysShow; } - public void setAlwaysShow(Boolean alwaysShow) - { + public void setAlwaysShow(Boolean alwaysShow) { this.alwaysShow = alwaysShow; } - public MetaVo getMeta() - { + public MetaVo getMeta() { return meta; } - public void setMeta(MetaVo meta) - { + public void setMeta(MetaVo meta) { this.meta = meta; } - public List getChildren() - { + public List getChildren() { return children; } - public void setChildren(List children) - { + public void setChildren(List children) { this.children = children; } } diff --git a/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/FileService.java b/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/FileService.java index 28812ca..cb61650 100644 --- a/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/FileService.java +++ b/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/FileService.java @@ -62,6 +62,7 @@ public interface FileService { /** * 下载指定文件 + * * @param fileId * @return */ diff --git a/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/ISysConfigService.java b/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/ISysConfigService.java index 3bce8c3..c2adc9a 100644 --- a/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/ISysConfigService.java +++ b/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/ISysConfigService.java @@ -1,18 +1,18 @@ package com.hchyun.system.service; import java.util.List; + import com.hchyun.system.entity.SysConfig; /** * 参数配置 服务层 - * + * * @author hchyun */ -public interface ISysConfigService -{ +public interface ISysConfigService { /** * 查询参数配置信息 - * + * * @param configId 参数配置ID * @return 参数配置信息 */ @@ -20,7 +20,7 @@ public interface ISysConfigService /** * 根据键名查询参数配置信息 - * + * * @param configKey 参数键名 * @return 参数键值 */ @@ -28,7 +28,7 @@ public interface ISysConfigService /** * 查询参数配置列表 - * + * * @param config 参数配置信息 * @return 参数配置集合 */ @@ -36,7 +36,7 @@ public interface ISysConfigService /** * 新增参数配置 - * + * * @param config 参数配置信息 * @return 结果 */ @@ -44,7 +44,7 @@ public interface ISysConfigService /** * 修改参数配置 - * + * * @param config 参数配置信息 * @return 结果 */ @@ -52,7 +52,7 @@ public interface ISysConfigService /** * 批量删除参数信息 - * + * * @param configIds 需要删除的参数ID * @return 结果 */ @@ -65,7 +65,7 @@ public interface ISysConfigService /** * 校验参数键名是否唯一 - * + * * @param config 参数信息 * @return 结果 */ diff --git a/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/ISysDeptService.java b/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/ISysDeptService.java index 6497c17..bb5862c 100644 --- a/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/ISysDeptService.java +++ b/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/ISysDeptService.java @@ -1,19 +1,19 @@ package com.hchyun.system.service; import java.util.List; + import com.hchyun.common.core.entity.TreeSelect; import com.hchyun.common.core.entity.entity.SysDept; /** * 部门管理 服务层 - * + * * @author hchyun */ -public interface ISysDeptService -{ +public interface ISysDeptService { /** * 查询部门管理数据 - * + * * @param dept 部门信息 * @return 部门信息集合 */ @@ -21,7 +21,7 @@ public interface ISysDeptService /** * 构建前端所需要树结构 - * + * * @param depts 部门列表 * @return 树结构列表 */ @@ -29,7 +29,7 @@ public interface ISysDeptService /** * 构建前端所需要下拉树结构 - * + * * @param depts 部门列表 * @return 下拉树结构列表 */ @@ -37,7 +37,7 @@ public interface ISysDeptService /** * 根据角色ID查询部门树信息 - * + * * @param roleId 角色ID * @return 选中部门列表 */ @@ -45,7 +45,7 @@ public interface ISysDeptService /** * 根据部门ID查询信息 - * + * * @param deptId 部门ID * @return 部门信息 */ @@ -53,7 +53,7 @@ public interface ISysDeptService /** * 根据ID查询所有子部门(正常状态) - * + * * @param deptId 部门ID * @return 子部门数 */ @@ -61,7 +61,7 @@ public interface ISysDeptService /** * 是否存在部门子节点 - * + * * @param deptId 部门ID * @return 结果 */ @@ -69,7 +69,7 @@ public interface ISysDeptService /** * 查询部门是否存在用户 - * + * * @param deptId 部门ID * @return 结果 true 存在 false 不存在 */ @@ -77,7 +77,7 @@ public interface ISysDeptService /** * 校验部门名称是否唯一 - * + * * @param dept 部门信息 * @return 结果 */ @@ -85,7 +85,7 @@ public interface ISysDeptService /** * 新增保存部门信息 - * + * * @param dept 部门信息 * @return 结果 */ @@ -93,7 +93,7 @@ public interface ISysDeptService /** * 修改保存部门信息 - * + * * @param dept 部门信息 * @return 结果 */ @@ -101,7 +101,7 @@ public interface ISysDeptService /** * 删除部门管理信息 - * + * * @param deptId 部门ID * @return 结果 */ diff --git a/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/ISysDictDataService.java b/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/ISysDictDataService.java index cbb4331..d823568 100644 --- a/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/ISysDictDataService.java +++ b/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/ISysDictDataService.java @@ -1,18 +1,18 @@ package com.hchyun.system.service; import java.util.List; + import com.hchyun.common.core.entity.entity.SysDictData; /** * 字典 业务层 - * + * * @author hchyun */ -public interface ISysDictDataService -{ +public interface ISysDictDataService { /** * 根据条件分页查询字典数据 - * + * * @param dictData 字典数据信息 * @return 字典数据集合信息 */ @@ -20,8 +20,8 @@ public interface ISysDictDataService /** * 根据字典类型和字典键值查询字典数据信息 - * - * @param dictType 字典类型 + * + * @param dictType 字典类型 * @param dictValue 字典键值 * @return 字典标签 */ @@ -29,7 +29,7 @@ public interface ISysDictDataService /** * 根据字典数据ID查询信息 - * + * * @param dictCode 字典数据ID * @return 字典数据 */ @@ -37,7 +37,7 @@ public interface ISysDictDataService /** * 批量删除字典数据信息 - * + * * @param dictCodes 需要删除的字典数据ID * @return 结果 */ @@ -45,7 +45,7 @@ public interface ISysDictDataService /** * 新增保存字典数据信息 - * + * * @param dictData 字典数据信息 * @return 结果 */ @@ -53,7 +53,7 @@ public interface ISysDictDataService /** * 修改保存字典数据信息 - * + * * @param dictData 字典数据信息 * @return 结果 */ diff --git a/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/ISysDictTypeService.java b/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/ISysDictTypeService.java index 60872d4..a1cdefd 100644 --- a/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/ISysDictTypeService.java +++ b/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/ISysDictTypeService.java @@ -1,19 +1,19 @@ package com.hchyun.system.service; import java.util.List; + import com.hchyun.common.core.entity.entity.SysDictData; import com.hchyun.common.core.entity.entity.SysDictType; /** * 字典 业务层 - * + * * @author hchyun */ -public interface ISysDictTypeService -{ +public interface ISysDictTypeService { /** * 根据条件分页查询字典类型 - * + * * @param dictType 字典类型信息 * @return 字典类型集合信息 */ @@ -21,14 +21,14 @@ public interface ISysDictTypeService /** * 根据所有字典类型 - * + * * @return 字典类型集合信息 */ public List selectDictTypeAll(); /** * 根据字典类型查询字典数据 - * + * * @param dictType 字典类型 * @return 字典数据集合信息 */ @@ -36,7 +36,7 @@ public interface ISysDictTypeService /** * 根据字典类型ID查询信息 - * + * * @param dictId 字典类型ID * @return 字典类型 */ @@ -44,7 +44,7 @@ public interface ISysDictTypeService /** * 根据字典类型查询信息 - * + * * @param dictType 字典类型 * @return 字典类型 */ @@ -52,7 +52,7 @@ public interface ISysDictTypeService /** * 批量删除字典信息 - * + * * @param dictIds 需要删除的字典ID * @return 结果 */ @@ -65,7 +65,7 @@ public interface ISysDictTypeService /** * 新增保存字典类型信息 - * + * * @param dictType 字典类型信息 * @return 结果 */ @@ -73,7 +73,7 @@ public interface ISysDictTypeService /** * 修改保存字典类型信息 - * + * * @param dictType 字典类型信息 * @return 结果 */ @@ -81,7 +81,7 @@ public interface ISysDictTypeService /** * 校验字典类型称是否唯一 - * + * * @param dictType 字典类型 * @return 结果 */ diff --git a/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/ISysLogininforService.java b/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/ISysLogininforService.java index f55453c..e1e7cc7 100644 --- a/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/ISysLogininforService.java +++ b/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/ISysLogininforService.java @@ -1,25 +1,25 @@ package com.hchyun.system.service; import java.util.List; + import com.hchyun.system.entity.SysLogininfor; /** * 系统访问日志情况信息 服务层 - * + * * @author hchyun */ -public interface ISysLogininforService -{ +public interface ISysLogininforService { /** * 新增系统登录日志 - * + * * @param logininfor 访问日志对象 */ public void insertLogininfor(SysLogininfor logininfor); /** * 查询系统登录日志集合 - * + * * @param logininfor 访问日志对象 * @return 登录记录集合 */ @@ -27,7 +27,7 @@ public interface ISysLogininforService /** * 批量删除系统登录日志 - * + * * @param infoIds 需要删除的登录日志ID * @return */ diff --git a/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/ISysMenuService.java b/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/ISysMenuService.java index 1878526..8dac306 100644 --- a/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/ISysMenuService.java +++ b/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/ISysMenuService.java @@ -2,20 +2,20 @@ package com.hchyun.system.service; import java.util.List; import java.util.Set; + import com.hchyun.common.core.entity.TreeSelect; import com.hchyun.common.core.entity.entity.SysMenu; import com.hchyun.system.entity.vo.RouterVo; /** * 菜单 业务层 - * + * * @author hchyun */ -public interface ISysMenuService -{ +public interface ISysMenuService { /** * 根据用户查询系统菜单列表 - * + * * @param userId 用户ID * @return 菜单列表 */ @@ -23,8 +23,8 @@ public interface ISysMenuService /** * 根据用户查询系统菜单列表 - * - * @param menu 菜单信息 + * + * @param menu 菜单信息 * @param userId 用户ID * @return 菜单列表 */ @@ -32,7 +32,7 @@ public interface ISysMenuService /** * 根据用户ID查询权限 - * + * * @param userId 用户ID * @return 权限列表 */ @@ -40,7 +40,7 @@ public interface ISysMenuService /** * 根据用户ID查询菜单树信息 - * + * * @param userId 用户ID * @return 菜单列表 */ @@ -48,7 +48,7 @@ public interface ISysMenuService /** * 根据角色ID查询菜单树信息 - * + * * @param roleId 角色ID * @return 选中菜单列表 */ @@ -56,7 +56,7 @@ public interface ISysMenuService /** * 构建前端路由所需要的菜单 - * + * * @param menus 菜单列表 * @return 路由列表 */ @@ -64,7 +64,7 @@ public interface ISysMenuService /** * 构建前端所需要树结构 - * + * * @param menus 菜单列表 * @return 树结构列表 */ @@ -72,7 +72,7 @@ public interface ISysMenuService /** * 构建前端所需要下拉树结构 - * + * * @param menus 菜单列表 * @return 下拉树结构列表 */ @@ -80,7 +80,7 @@ public interface ISysMenuService /** * 根据菜单ID查询信息 - * + * * @param menuId 菜单ID * @return 菜单信息 */ @@ -88,7 +88,7 @@ public interface ISysMenuService /** * 是否存在菜单子节点 - * + * * @param menuId 菜单ID * @return 结果 true 存在 false 不存在 */ @@ -96,7 +96,7 @@ public interface ISysMenuService /** * 查询菜单是否存在角色 - * + * * @param menuId 菜单ID * @return 结果 true 存在 false 不存在 */ @@ -104,7 +104,7 @@ public interface ISysMenuService /** * 新增保存菜单信息 - * + * * @param menu 菜单信息 * @return 结果 */ @@ -112,7 +112,7 @@ public interface ISysMenuService /** * 修改保存菜单信息 - * + * * @param menu 菜单信息 * @return 结果 */ @@ -120,7 +120,7 @@ public interface ISysMenuService /** * 删除菜单管理信息 - * + * * @param menuId 菜单ID * @return 结果 */ @@ -128,7 +128,7 @@ public interface ISysMenuService /** * 校验菜单名称是否唯一 - * + * * @param menu 菜单信息 * @return 结果 */ diff --git a/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/ISysNoticeService.java b/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/ISysNoticeService.java index a963bdd..363a0a7 100644 --- a/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/ISysNoticeService.java +++ b/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/ISysNoticeService.java @@ -1,18 +1,18 @@ package com.hchyun.system.service; import java.util.List; + import com.hchyun.system.entity.SysNotice; /** * 公告 服务层 - * + * * @author hchyun */ -public interface ISysNoticeService -{ +public interface ISysNoticeService { /** * 查询公告信息 - * + * * @param noticeId 公告ID * @return 公告信息 */ @@ -20,7 +20,7 @@ public interface ISysNoticeService /** * 查询公告列表 - * + * * @param notice 公告信息 * @return 公告集合 */ @@ -28,7 +28,7 @@ public interface ISysNoticeService /** * 新增公告 - * + * * @param notice 公告信息 * @return 结果 */ @@ -36,7 +36,7 @@ public interface ISysNoticeService /** * 修改公告 - * + * * @param notice 公告信息 * @return 结果 */ @@ -44,15 +44,15 @@ public interface ISysNoticeService /** * 删除公告信息 - * + * * @param noticeId 公告ID * @return 结果 */ public int deleteNoticeById(Long noticeId); - + /** * 批量删除公告信息 - * + * * @param noticeIds 需要删除的公告ID * @return 结果 */ diff --git a/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/ISysOperLogService.java b/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/ISysOperLogService.java index 930edc4..fc1ad9c 100644 --- a/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/ISysOperLogService.java +++ b/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/ISysOperLogService.java @@ -1,25 +1,25 @@ package com.hchyun.system.service; import java.util.List; + import com.hchyun.system.entity.SysOperLog; /** * 操作日志 服务层 - * + * * @author hchyun */ -public interface ISysOperLogService -{ +public interface ISysOperLogService { /** * 新增操作日志 - * + * * @param operLog 操作日志对象 */ public void insertOperlog(SysOperLog operLog); /** * 查询系统操作日志集合 - * + * * @param operLog 操作日志对象 * @return 操作日志集合 */ @@ -27,7 +27,7 @@ public interface ISysOperLogService /** * 批量删除系统操作日志 - * + * * @param operIds 需要删除的操作日志ID * @return 结果 */ @@ -35,7 +35,7 @@ public interface ISysOperLogService /** * 查询操作日志详细 - * + * * @param operId 操作ID * @return 操作日志对象 */ diff --git a/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/ISysPostService.java b/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/ISysPostService.java index d797abc..1a15fdc 100644 --- a/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/ISysPostService.java +++ b/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/ISysPostService.java @@ -1,18 +1,18 @@ package com.hchyun.system.service; import java.util.List; + import com.hchyun.system.entity.SysPost; /** * 岗位信息 服务层 - * + * * @author hchyun */ -public interface ISysPostService -{ +public interface ISysPostService { /** * 查询岗位信息集合 - * + * * @param post 岗位信息 * @return 岗位列表 */ @@ -20,14 +20,14 @@ public interface ISysPostService /** * 查询所有岗位 - * + * * @return 岗位列表 */ public List selectPostAll(); /** * 通过岗位ID查询岗位信息 - * + * * @param postId 岗位ID * @return 角色对象信息 */ @@ -35,7 +35,7 @@ public interface ISysPostService /** * 根据用户ID获取岗位选择框列表 - * + * * @param userId 用户ID * @return 选中岗位ID列表 */ @@ -43,7 +43,7 @@ public interface ISysPostService /** * 校验岗位名称 - * + * * @param post 岗位信息 * @return 结果 */ @@ -51,7 +51,7 @@ public interface ISysPostService /** * 校验岗位编码 - * + * * @param post 岗位信息 * @return 结果 */ @@ -59,7 +59,7 @@ public interface ISysPostService /** * 通过岗位ID查询岗位使用数量 - * + * * @param postId 岗位ID * @return 结果 */ @@ -67,7 +67,7 @@ public interface ISysPostService /** * 删除岗位信息 - * + * * @param postId 岗位ID * @return 结果 */ @@ -75,7 +75,7 @@ public interface ISysPostService /** * 批量删除岗位信息 - * + * * @param postIds 需要删除的岗位ID * @return 结果 * @throws Exception 异常 @@ -84,7 +84,7 @@ public interface ISysPostService /** * 新增保存岗位信息 - * + * * @param post 岗位信息 * @return 结果 */ @@ -92,7 +92,7 @@ public interface ISysPostService /** * 修改保存岗位信息 - * + * * @param post 岗位信息 * @return 结果 */ diff --git a/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/ISysRoleService.java b/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/ISysRoleService.java index c0daac4..167795e 100644 --- a/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/ISysRoleService.java +++ b/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/ISysRoleService.java @@ -2,18 +2,18 @@ package com.hchyun.system.service; import java.util.List; import java.util.Set; + import com.hchyun.common.core.entity.entity.SysRole; /** * 角色业务层 - * + * * @author hchyun */ -public interface ISysRoleService -{ +public interface ISysRoleService { /** * 根据条件分页查询角色数据 - * + * * @param role 角色信息 * @return 角色数据集合信息 */ @@ -21,7 +21,7 @@ public interface ISysRoleService /** * 根据用户ID查询角色 - * + * * @param userId 用户ID * @return 权限列表 */ @@ -29,15 +29,15 @@ public interface ISysRoleService /** * 查询所有角色 - * - * @return 角色列表 + * * @param type + * @return 角色列表 */ public List selectRoleAll(Integer type); /** * 根据用户ID获取角色选择框列表 - * + * * @param userId 用户ID * @return 选中角色ID列表 */ @@ -45,7 +45,7 @@ public interface ISysRoleService /** * 通过角色ID查询角色 - * + * * @param roleId 角色ID * @return 角色对象信息 */ @@ -53,7 +53,7 @@ public interface ISysRoleService /** * 校验角色名称是否唯一 - * + * * @param role 角色信息 * @return 结果 */ @@ -61,7 +61,7 @@ public interface ISysRoleService /** * 校验角色权限是否唯一 - * + * * @param role 角色信息 * @return 结果 */ @@ -69,14 +69,14 @@ public interface ISysRoleService /** * 校验角色是否允许操作 - * + * * @param role 角色信息 */ public void checkRoleAllowed(SysRole role); /** * 通过角色ID查询角色使用数量 - * + * * @param roleId 角色ID * @return 结果 */ @@ -84,7 +84,7 @@ public interface ISysRoleService /** * 新增保存角色信息 - * + * * @param role 角色信息 * @return 结果 */ @@ -92,7 +92,7 @@ public interface ISysRoleService /** * 修改保存角色信息 - * + * * @param role 角色信息 * @return 结果 */ @@ -100,7 +100,7 @@ public interface ISysRoleService /** * 修改角色状态 - * + * * @param role 角色信息 * @return 结果 */ @@ -108,7 +108,7 @@ public interface ISysRoleService /** * 修改数据权限信息 - * + * * @param role 角色信息 * @return 结果 */ @@ -116,7 +116,7 @@ public interface ISysRoleService /** * 通过角色ID删除角色 - * + * * @param roleId 角色ID * @return 结果 */ @@ -124,7 +124,7 @@ public interface ISysRoleService /** * 批量删除角色信息 - * + * * @param roleIds 需要删除的角色ID * @return 结果 */ diff --git a/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/ISysUserOnlineService.java b/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/ISysUserOnlineService.java index e4691d9..b12c9f1 100644 --- a/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/ISysUserOnlineService.java +++ b/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/ISysUserOnlineService.java @@ -5,42 +5,41 @@ import com.hchyun.system.entity.SysUserOnline; /** * 在线用户 服务层 - * + * * @author hchyun */ -public interface ISysUserOnlineService -{ +public interface ISysUserOnlineService { /** * 通过登录地址查询信息 - * + * * @param ipaddr 登录地址 - * @param user 用户信息 + * @param user 用户信息 * @return 在线用户信息 */ public SysUserOnline selectOnlineByIpaddr(String ipaddr, LoginUser user); /** * 通过用户名称查询信息 - * + * * @param userName 用户名称 - * @param user 用户信息 + * @param user 用户信息 * @return 在线用户信息 */ public SysUserOnline selectOnlineByUserName(String userName, LoginUser user); /** * 通过登录地址/用户名称查询信息 - * - * @param ipaddr 登录地址 + * + * @param ipaddr 登录地址 * @param userName 用户名称 - * @param user 用户信息 + * @param user 用户信息 * @return 在线用户信息 */ public SysUserOnline selectOnlineByInfo(String ipaddr, String userName, LoginUser user); /** * 设置在线用户信息 - * + * * @param user 用户信息 * @return 在线用户 */ diff --git a/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/ISysUserService.java b/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/ISysUserService.java index ce10ba4..f200831 100644 --- a/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/ISysUserService.java +++ b/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/ISysUserService.java @@ -1,18 +1,18 @@ package com.hchyun.system.service; import java.util.List; + import com.hchyun.common.core.entity.entity.SysUser; /** * 用户 业务层 - * + * * @author hchyun */ -public interface ISysUserService -{ +public interface ISysUserService { /** * 根据条件分页查询用户列表 - * + * * @param user 用户信息 * @return 用户信息集合信息 */ @@ -20,7 +20,7 @@ public interface ISysUserService /** * 通过用户名查询用户 - * + * * @param userName 用户名 * @return 用户对象信息 */ @@ -28,7 +28,7 @@ public interface ISysUserService /** * 通过用户ID查询用户 - * + * * @param userId 用户ID * @return 用户对象信息 */ @@ -36,7 +36,7 @@ public interface ISysUserService /** * 根据用户ID查询用户所属角色组 - * + * * @param userName 用户名 * @return 结果 */ @@ -44,7 +44,7 @@ public interface ISysUserService /** * 根据用户ID查询用户所属岗位组 - * + * * @param userName 用户名 * @return 结果 */ @@ -52,7 +52,7 @@ public interface ISysUserService /** * 校验用户名称是否唯一 - * + * * @param userName 用户名称 * @return 结果 */ @@ -76,14 +76,14 @@ public interface ISysUserService /** * 校验用户是否允许操作 - * + * * @param user 用户信息 */ public void checkUserAllowed(SysUser user); /** * 新增用户信息 - * + * * @param user 用户信息 * @return 结果 */ @@ -91,7 +91,7 @@ public interface ISysUserService /** * 修改用户信息 - * + * * @param user 用户信息 * @return 结果 */ @@ -99,7 +99,7 @@ public interface ISysUserService /** * 修改用户状态 - * + * * @param user 用户信息 * @return 结果 */ @@ -107,7 +107,7 @@ public interface ISysUserService /** * 修改用户基本信息 - * + * * @param user 用户信息 * @return 结果 */ @@ -115,16 +115,16 @@ public interface ISysUserService /** * 修改用户头像 - * + * * @param userName 用户名 - * @param avatar 头像地址 + * @param avatar 头像地址 * @return 结果 */ public boolean updateUserAvatar(String userName, String avatar); /** * 重置用户密码 - * + * * @param user 用户信息 * @return 结果 */ @@ -132,7 +132,7 @@ public interface ISysUserService /** * 重置用户密码 - * + * * @param userName 用户名 * @param password 密码 * @return 结果 @@ -141,7 +141,7 @@ public interface ISysUserService /** * 通过用户ID删除用户 - * + * * @param userId 用户ID * @return 结果 */ @@ -149,7 +149,7 @@ public interface ISysUserService /** * 批量删除用户信息 - * + * * @param userIds 需要删除的用户ID * @return 结果 */ @@ -157,10 +157,10 @@ public interface ISysUserService /** * 导入用户数据 - * - * @param userList 用户数据列表 + * + * @param userList 用户数据列表 * @param isUpdateSupport 是否更新支持,如果已存在,则进行更新数据 - * @param operName 操作用户 + * @param operName 操作用户 * @return 结果 */ public String importUser(List userList, Boolean isUpdateSupport, Long operName); diff --git a/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/RegularService.java b/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/RegularService.java index c7eb795..26ffcaf 100644 --- a/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/RegularService.java +++ b/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/RegularService.java @@ -4,17 +4,17 @@ import com.hchyun.common.utils.ServerResult; import com.hchyun.system.entity.Regular; import java.util.List; + /** * 校验规则Service接口 - * + * * @author hchyun * @date 2021-01-18 */ -public interface RegularService -{ +public interface RegularService { /** * 查询校验规则 - * + * * @param id 校验规则ID * @return 校验规则 */ @@ -22,7 +22,7 @@ public interface RegularService /** * 查询校验规则列表 - * + * * @param regular 校验规则 * @return 校验规则集合 */ @@ -30,7 +30,7 @@ public interface RegularService /** * 新增校验规则 - * + * * @param regular 校验规则 * @return 结果 */ @@ -38,7 +38,7 @@ public interface RegularService /** * 修改校验规则 - * + * * @param regular 校验规则 * @return 结果 */ @@ -46,7 +46,7 @@ public interface RegularService /** * 批量删除校验规则 - * + * * @param ids 需要删除的校验规则ID * @return 结果 */ @@ -54,7 +54,7 @@ public interface RegularService /** * 删除校验规则信息 - * + * * @param id 校验规则ID * @return 结果 */ diff --git a/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/impl/FileServiceImpl.java b/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/impl/FileServiceImpl.java index 9ad0053..6dc56de 100644 --- a/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/impl/FileServiceImpl.java +++ b/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/impl/FileServiceImpl.java @@ -17,7 +17,7 @@ import com.hchyun.system.service.FileService; /** * 文件信息Service业务层处理 - * + * * @author hchyun * @date 2021-02-17 */ @@ -30,7 +30,7 @@ public class FileServiceImpl implements FileService { /** * 查询文件信息 - * + * * @param fileId 文件信息ID * @return 文件信息 */ @@ -38,20 +38,20 @@ public class FileServiceImpl implements FileService { public ServerResult selectFileById(Long fileId) { try { SysFile sysFile = fileDao.selectFileById(fileId); - if (sysFile != null){ + if (sysFile != null) { return new ServerResult(true, sysFile); - }else { + } else { return new ServerResult(false, ReturnConstants.RESULT_EMPTY); } - }catch (RuntimeException e){ + } catch (RuntimeException e) { logger.error(e.getMessage()); - return new ServerResult(false,ReturnConstants.DB_EX); + return new ServerResult(false, ReturnConstants.DB_EX); } } /** * 查询文件信息列表 - * + * * @param sysFile 文件信息 * @return 文件信息 */ @@ -59,20 +59,20 @@ public class FileServiceImpl implements FileService { public ServerResult> selectFileList(SysFile sysFile) { try { List sysFileList = fileDao.selectFileList(sysFile); - if (sysFileList.size()>0){ + if (sysFileList.size() > 0) { return new ServerResult>(true, sysFileList); - }else { - return new ServerResult>(false,ReturnConstants.RESULT_EMPTY); + } else { + return new ServerResult>(false, ReturnConstants.RESULT_EMPTY); } - }catch (RuntimeException e){ + } catch (RuntimeException e) { logger.error(e.getMessage()); - return new ServerResult>(false,ReturnConstants.DB_EX); + return new ServerResult>(false, ReturnConstants.DB_EX); } } /** * 新增文件信息 - * + * * @param sysFile 文件信息 * @return 结果 */ @@ -81,24 +81,24 @@ public class FileServiceImpl implements FileService { try { sysFile.setCreateBy(SecurityUtils.getUserId()); sysFile = FtpUtils.uploadFtp(sysFile); - if (sysFile == null){ - return new ServerResult<>(false,"文件上传失败!"); + if (sysFile == null) { + return new ServerResult<>(false, "文件上传失败!"); } Integer renewal = fileDao.insertFile(sysFile); - if (renewal >0){ - return new ServerResult<>(true,sysFile); - }else { - return new ServerResult<>(false,ReturnConstants.SYS_FAILL); + if (renewal > 0) { + return new ServerResult<>(true, sysFile); + } else { + return new ServerResult<>(false, ReturnConstants.SYS_FAILL); } - }catch (RuntimeException e){ + } catch (RuntimeException e) { logger.error(e.getMessage()); - return new ServerResult<>(false,ReturnConstants.DB_EX); + return new ServerResult<>(false, ReturnConstants.DB_EX); } } /** * 修改文件信息 - * + * * @param sysFile 文件信息 * @return 结果 */ @@ -107,20 +107,20 @@ public class FileServiceImpl implements FileService { try { sysFile.setUpdateBy(SecurityUtils.getUserId()); Integer renewal = fileDao.updateFile(sysFile); - if (renewal >0){ - return new ServerResult(true,renewal); - }else { - return new ServerResult(false,ReturnConstants.SYS_FAILL); + if (renewal > 0) { + return new ServerResult(true, renewal); + } else { + return new ServerResult(false, ReturnConstants.SYS_FAILL); } - }catch (RuntimeException e){ + } catch (RuntimeException e) { logger.error(e.getMessage()); - return new ServerResult(false,ReturnConstants.DB_EX); + return new ServerResult(false, ReturnConstants.DB_EX); } } /** * 批量删除文件信息 - * + * * @param fileIds 需要删除的文件信息ID * @return 结果 */ @@ -133,18 +133,18 @@ public class FileServiceImpl implements FileService { sysFile = fileDao.selectFileById(fileId); sysFiles.add(sysFile); } - if (!FtpUtils.deleteFile(sysFiles)){ - return new ServerResult<>(false,ReturnConstants.OP_ERROR); + if (!FtpUtils.deleteFile(sysFiles)) { + return new ServerResult<>(false, ReturnConstants.OP_ERROR); } Integer renewal = fileDao.deleteFileByIds(fileIds); - if (renewal >0){ - return new ServerResult(true,renewal); - }else { - return new ServerResult(false,ReturnConstants.SYS_FAILL); + if (renewal > 0) { + return new ServerResult(true, renewal); + } else { + return new ServerResult(false, ReturnConstants.SYS_FAILL); } - }catch (RuntimeException e){ + } catch (RuntimeException e) { logger.error(e.getMessage()); - return new ServerResult(false,ReturnConstants.DB_EX); + return new ServerResult(false, ReturnConstants.DB_EX); } } @@ -153,20 +153,20 @@ public class FileServiceImpl implements FileService { try { SysFile sysFile = fileDao.selectFileById(fileId); String fileName = FtpUtils.downloadFile(sysFile); - if (fileName==null){ - return new ServerResult<>(false,"文件下载失败!"); - }else { - return new ServerResult<>(true,sysFile); + if (fileName == null) { + return new ServerResult<>(false, "文件下载失败!"); + } else { + return new ServerResult<>(true, sysFile); } - }catch (RuntimeException e){ + } catch (RuntimeException e) { logger.error(e.getMessage()); - return new ServerResult<>(false,ReturnConstants.DB_EX); + return new ServerResult<>(false, ReturnConstants.DB_EX); } } /** * 删除文件信息信息 - * + * * @param fileId 文件信息ID * @return 结果 */ @@ -174,14 +174,14 @@ public class FileServiceImpl implements FileService { public ServerResult deleteFileById(Long fileId) { try { Integer renewal = fileDao.deleteFileById(fileId); - if (renewal >0){ - return new ServerResult(true,renewal); - }else { - return new ServerResult(false,ReturnConstants.SYS_FAILL); + if (renewal > 0) { + return new ServerResult(true, renewal); + } else { + return new ServerResult(false, ReturnConstants.SYS_FAILL); } - }catch (RuntimeException e){ + } catch (RuntimeException e) { logger.error(e.getMessage()); - return new ServerResult(false,ReturnConstants.DB_EX); + return new ServerResult(false, ReturnConstants.DB_EX); } } diff --git a/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/impl/SysDeptServiceImpl.java b/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/impl/SysDeptServiceImpl.java index bfbeb42..61c6c68 100644 --- a/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/impl/SysDeptServiceImpl.java +++ b/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/impl/SysDeptServiceImpl.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.stream.Collectors; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.hchyun.common.annotation.DataScope; @@ -19,12 +20,11 @@ import com.hchyun.system.service.ISysDeptService; /** * 部门管理 服务实现 - * + * * @author hchyun */ @Service -public class SysDeptServiceImpl implements ISysDeptService -{ +public class SysDeptServiceImpl implements ISysDeptService { @Autowired private SysDeptDao deptMapper; @@ -33,44 +33,38 @@ public class SysDeptServiceImpl implements ISysDeptService /** * 查询部门管理数据 - * + * * @param dept 部门信息 * @return 部门信息集合 */ @Override @DataScope(deptAlias = "d") - public List selectDeptList(SysDept dept) - { + public List selectDeptList(SysDept dept) { return deptMapper.selectDeptList(dept); } /** * 构建前端所需要树结构 - * + * * @param depts 部门列表 * @return 树结构列表 */ @Override - public List buildDeptTree(List depts) - { + public List buildDeptTree(List depts) { List returnList = new ArrayList(); List tempList = new ArrayList(); - for (SysDept dept : depts) - { + for (SysDept dept : depts) { tempList.add(dept.getDeptId()); } - for (Iterator iterator = depts.iterator(); iterator.hasNext();) - { + for (Iterator iterator = depts.iterator(); iterator.hasNext(); ) { SysDept dept = (SysDept) iterator.next(); // 如果是顶级节点, 遍历该父节点的所有子节点 - if (!tempList.contains(dept.getParentId())) - { + if (!tempList.contains(dept.getParentId())) { recursionFn(depts, dept); returnList.add(dept); } } - if (returnList.isEmpty()) - { + if (returnList.isEmpty()) { returnList = depts; } return returnList; @@ -78,93 +72,85 @@ public class SysDeptServiceImpl implements ISysDeptService /** * 构建前端所需要下拉树结构 - * + * * @param depts 部门列表 * @return 下拉树结构列表 */ @Override - public List buildDeptTreeSelect(List depts) - { + public List buildDeptTreeSelect(List depts) { List deptTrees = buildDeptTree(depts); return deptTrees.stream().map(TreeSelect::new).collect(Collectors.toList()); } /** * 根据角色ID查询部门树信息 - * + * * @param roleId 角色ID * @return 选中部门列表 */ @Override - public List selectDeptListByRoleId(Long roleId) - { + public List selectDeptListByRoleId(Long roleId) { SysRole role = roleMapper.selectRoleById(roleId); return deptMapper.selectDeptListByRoleId(roleId, role.isDeptCheckStrictly()); } /** * 根据部门ID查询信息 - * + * * @param deptId 部门ID * @return 部门信息 */ @Override - public SysDept selectDeptById(Long deptId) - { + public SysDept selectDeptById(Long deptId) { return deptMapper.selectDeptById(deptId); } /** * 根据ID查询所有子部门(正常状态) - * + * * @param deptId 部门ID * @return 子部门数 */ @Override - public int selectNormalChildrenDeptById(Long deptId) - { + public int selectNormalChildrenDeptById(Long deptId) { return deptMapper.selectNormalChildrenDeptById(deptId); } /** * 是否存在子节点 - * + * * @param deptId 部门ID * @return 结果 */ @Override - public boolean hasChildByDeptId(Long deptId) - { + public boolean hasChildByDeptId(Long deptId) { int result = deptMapper.hasChildByDeptId(deptId); return result > 0 ? true : false; } /** * 查询部门是否存在用户 - * + * * @param deptId 部门ID * @return 结果 true 存在 false 不存在 */ @Override - public boolean checkDeptExistUser(Long deptId) - { + public boolean checkDeptExistUser(Long deptId) { int result = deptMapper.checkDeptExistUser(deptId); return result > 0 ? true : false; } /** * 校验部门名称是否唯一 - * + * * @param dept 部门信息 * @return 结果 */ @Override - public String checkDeptNameUnique(SysDept dept) - { + public String checkDeptNameUnique(SysDept dept) { Long deptId = StringUtils.isNull(dept.getDeptId()) ? -1L : dept.getDeptId(); SysDept info = deptMapper.checkDeptNameUnique(dept.getDeptName(), dept.getParentId()); - if (StringUtils.isNotNull(info) && info.getDeptId().longValue() != deptId.longValue()) - { + if (StringUtils.isNotNull(info) && info.getDeptId().longValue() != deptId.longValue()) { return UserConstants.NOT_UNIQUE; } return UserConstants.UNIQUE; @@ -172,17 +158,15 @@ public class SysDeptServiceImpl implements ISysDeptService /** * 新增保存部门信息 - * + * * @param dept 部门信息 * @return 结果 */ @Override - public int insertDept(SysDept dept) - { + public int insertDept(SysDept dept) { SysDept info = deptMapper.selectDeptById(dept.getParentId()); // 如果父节点不为正常状态,则不允许新增子节点 - if (!UserConstants.DEPT_NORMAL.equals(info.getStatus())) - { + if (!UserConstants.DEPT_NORMAL.equals(info.getStatus())) { throw new CustomException("部门停用,不允许新增"); } dept.setAncestors(info.getAncestors() + "," + dept.getParentId()); @@ -191,25 +175,22 @@ public class SysDeptServiceImpl implements ISysDeptService /** * 修改保存部门信息 - * + * * @param dept 部门信息 * @return 结果 */ @Override - public int updateDept(SysDept dept) - { + public int updateDept(SysDept dept) { SysDept newParentDept = deptMapper.selectDeptById(dept.getParentId()); SysDept oldDept = deptMapper.selectDeptById(dept.getDeptId()); - if (StringUtils.isNotNull(newParentDept) && StringUtils.isNotNull(oldDept)) - { + if (StringUtils.isNotNull(newParentDept) && StringUtils.isNotNull(oldDept)) { String newAncestors = newParentDept.getAncestors() + "," + newParentDept.getDeptId(); String oldAncestors = oldDept.getAncestors(); dept.setAncestors(newAncestors); updateDeptChildren(dept.getDeptId(), newAncestors, oldAncestors); } int result = deptMapper.updateDept(dept); - if (UserConstants.DEPT_NORMAL.equals(dept.getStatus())) - { + if (UserConstants.DEPT_NORMAL.equals(dept.getStatus())) { // 如果该部门是启用状态,则启用该部门的所有上级部门 updateParentDeptStatus(dept); } @@ -218,11 +199,10 @@ public class SysDeptServiceImpl implements ISysDeptService /** * 修改该部门的父级部门状态 - * + * * @param dept 当前部门 */ - private void updateParentDeptStatus(SysDept dept) - { + private void updateParentDeptStatus(SysDept dept) { Long updateBy = dept.getUpdateBy(); dept = deptMapper.selectDeptById(dept.getDeptId()); dept.setUpdateBy(updateBy); @@ -231,48 +211,41 @@ public class SysDeptServiceImpl implements ISysDeptService /** * 修改子元素关系 - * - * @param deptId 被修改的部门ID + * + * @param deptId 被修改的部门ID * @param newAncestors 新的父ID集合 * @param oldAncestors 旧的父ID集合 */ - public void updateDeptChildren(Long deptId, String newAncestors, String oldAncestors) - { + public void updateDeptChildren(Long deptId, String newAncestors, String oldAncestors) { List children = deptMapper.selectChildrenDeptById(deptId); - for (SysDept child : children) - { + for (SysDept child : children) { child.setAncestors(child.getAncestors().replace(oldAncestors, newAncestors)); } - if (children.size() > 0) - { + if (children.size() > 0) { deptMapper.updateDeptChildren(children); } } /** * 删除部门管理信息 - * + * * @param deptId 部门ID * @return 结果 */ @Override - public int deleteDeptById(Long deptId) - { + public int deleteDeptById(Long deptId) { return deptMapper.deleteDeptById(deptId); } /** * 递归列表 */ - private void recursionFn(List list, SysDept t) - { + private void recursionFn(List list, SysDept t) { // 得到子节点列表 List childList = getChildList(list, t); t.setChildren(childList); - for (SysDept tChild : childList) - { - if (hasChild(list, tChild)) - { + for (SysDept tChild : childList) { + if (hasChild(list, tChild)) { recursionFn(list, tChild); } } @@ -281,15 +254,12 @@ public class SysDeptServiceImpl implements ISysDeptService /** * 得到子节点列表 */ - private List getChildList(List list, SysDept t) - { + private List getChildList(List list, SysDept t) { List tlist = new ArrayList(); Iterator it = list.iterator(); - while (it.hasNext()) - { + while (it.hasNext()) { SysDept n = (SysDept) it.next(); - if (StringUtils.isNotNull(n.getParentId()) && n.getParentId().longValue() == t.getDeptId().longValue()) - { + if (StringUtils.isNotNull(n.getParentId()) && n.getParentId().longValue() == t.getDeptId().longValue()) { tlist.add(n); } } @@ -299,8 +269,7 @@ public class SysDeptServiceImpl implements ISysDeptService /** * 判断是否有子节点 */ - private boolean hasChild(List list, SysDept t) - { + private boolean hasChild(List list, SysDept t) { return getChildList(list, t).size() > 0 ? true : false; } } diff --git a/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/impl/SysDictDataServiceImpl.java b/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/impl/SysDictDataServiceImpl.java index c06611a..4e66733 100644 --- a/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/impl/SysDictDataServiceImpl.java +++ b/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/impl/SysDictDataServiceImpl.java @@ -1,6 +1,7 @@ package com.hchyun.system.service.impl; import java.util.List; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.hchyun.common.core.entity.entity.SysDictData; @@ -10,64 +11,58 @@ import com.hchyun.system.service.ISysDictDataService; /** * 字典 业务层处理 - * + * * @author hchyun */ @Service -public class SysDictDataServiceImpl implements ISysDictDataService -{ +public class SysDictDataServiceImpl implements ISysDictDataService { @Autowired private SysDictDataDao dictDataMapper; /** * 根据条件分页查询字典数据 - * + * * @param dictData 字典数据信息 * @return 字典数据集合信息 */ @Override - public List selectDictDataList(SysDictData dictData) - { + public List selectDictDataList(SysDictData dictData) { return dictDataMapper.selectDictDataList(dictData); } /** * 根据字典类型和字典键值查询字典数据信息 - * - * @param dictType 字典类型 + * + * @param dictType 字典类型 * @param dictValue 字典键值 * @return 字典标签 */ @Override - public String selectDictLabel(String dictType, String dictValue) - { + public String selectDictLabel(String dictType, String dictValue) { return dictDataMapper.selectDictLabel(dictType, dictValue); } /** * 根据字典数据ID查询信息 - * + * * @param dictCode 字典数据ID * @return 字典数据 */ @Override - public SysDictData selectDictDataById(Long dictCode) - { + public SysDictData selectDictDataById(Long dictCode) { return dictDataMapper.selectDictDataById(dictCode); } /** * 批量删除字典数据信息 - * + * * @param dictCodes 需要删除的字典数据ID * @return 结果 */ @Override - public int deleteDictDataByIds(Long[] dictCodes) - { + public int deleteDictDataByIds(Long[] dictCodes) { int row = dictDataMapper.deleteDictDataByIds(dictCodes); - if (row > 0) - { + if (row > 0) { DictUtils.clearDictCache(); } return row; @@ -75,16 +70,14 @@ public class SysDictDataServiceImpl implements ISysDictDataService /** * 新增保存字典数据信息 - * + * * @param dictData 字典数据信息 * @return 结果 */ @Override - public int insertDictData(SysDictData dictData) - { + public int insertDictData(SysDictData dictData) { int row = dictDataMapper.insertDictData(dictData); - if (row > 0) - { + if (row > 0) { DictUtils.clearDictCache(); } return row; @@ -92,16 +85,14 @@ public class SysDictDataServiceImpl implements ISysDictDataService /** * 修改保存字典数据信息 - * + * * @param dictData 字典数据信息 * @return 结果 */ @Override - public int updateDictData(SysDictData dictData) - { + public int updateDictData(SysDictData dictData) { int row = dictDataMapper.updateDictData(dictData); - if (row > 0) - { + if (row > 0) { DictUtils.clearDictCache(); } return row; diff --git a/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/impl/SysDictTypeServiceImpl.java b/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/impl/SysDictTypeServiceImpl.java index 1bfd86b..cecb791 100644 --- a/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/impl/SysDictTypeServiceImpl.java +++ b/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/impl/SysDictTypeServiceImpl.java @@ -2,6 +2,7 @@ package com.hchyun.system.service.impl; import java.util.List; import javax.annotation.PostConstruct; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -17,12 +18,11 @@ import com.hchyun.system.service.ISysDictTypeService; /** * 字典 业务层处理 - * + * * @author hchyun */ @Service -public class SysDictTypeServiceImpl implements ISysDictTypeService -{ +public class SysDictTypeServiceImpl implements ISysDictTypeService { @Autowired private SysDictTypeDao dictTypeMapper; @@ -33,11 +33,9 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService * 项目启动时,初始化字典到缓存 */ @PostConstruct - public void init() - { + public void init() { List dictTypeList = dictTypeMapper.selectDictTypeAll(); - for (SysDictType dictType : dictTypeList) - { + for (SysDictType dictType : dictTypeList) { List dictDatas = dictDataMapper.selectDictDataByType(dictType.getDictType()); DictUtils.setDictCache(dictType.getDictType(), dictDatas); } @@ -45,44 +43,39 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService /** * 根据条件分页查询字典类型 - * + * * @param dictType 字典类型信息 * @return 字典类型集合信息 */ @Override - public List selectDictTypeList(SysDictType dictType) - { + public List selectDictTypeList(SysDictType dictType) { return dictTypeMapper.selectDictTypeList(dictType); } /** * 根据所有字典类型 - * + * * @return 字典类型集合信息 */ @Override - public List selectDictTypeAll() - { + public List selectDictTypeAll() { return dictTypeMapper.selectDictTypeAll(); } /** * 根据字典类型查询字典数据 - * + * * @param dictType 字典类型 * @return 字典数据集合信息 */ @Override - public List selectDictDataByType(String dictType) - { + public List selectDictDataByType(String dictType) { List dictDatas = DictUtils.getDictCache(dictType); - if (StringUtils.isNotEmpty(dictDatas)) - { + if (StringUtils.isNotEmpty(dictDatas)) { return dictDatas; } dictDatas = dictDataMapper.selectDictDataByType(dictType); - if (StringUtils.isNotEmpty(dictDatas)) - { + if (StringUtils.isNotEmpty(dictDatas)) { DictUtils.setDictCache(dictType, dictDatas); return dictDatas; } @@ -91,48 +84,42 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService /** * 根据字典类型ID查询信息 - * + * * @param dictId 字典类型ID * @return 字典类型 */ @Override - public SysDictType selectDictTypeById(Long dictId) - { + public SysDictType selectDictTypeById(Long dictId) { return dictTypeMapper.selectDictTypeById(dictId); } /** * 根据字典类型查询信息 - * + * * @param dictType 字典类型 * @return 字典类型 */ @Override - public SysDictType selectDictTypeByType(String dictType) - { + public SysDictType selectDictTypeByType(String dictType) { return dictTypeMapper.selectDictTypeByType(dictType); } /** * 批量删除字典类型信息 - * + * * @param dictIds 需要删除的字典ID * @return 结果 */ @Override - public int deleteDictTypeByIds(Long[] dictIds) - { - for (Long dictId : dictIds) - { + public int deleteDictTypeByIds(Long[] dictIds) { + for (Long dictId : dictIds) { SysDictType dictType = selectDictTypeById(dictId); - if (dictDataMapper.countDictDataByType(dictType.getDictType()) > 0) - { + if (dictDataMapper.countDictDataByType(dictType.getDictType()) > 0) { throw new CustomException(String.format("%1$s已分配,不能删除", dictType.getDictName())); } } int count = dictTypeMapper.deleteDictTypeByIds(dictIds); - if (count > 0) - { + if (count > 0) { DictUtils.clearDictCache(); } return count; @@ -142,23 +129,20 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService * 清空缓存数据 */ @Override - public void clearCache() - { + public void clearCache() { DictUtils.clearDictCache(); } /** * 新增保存字典类型信息 - * + * * @param dictType 字典类型信息 * @return 结果 */ @Override - public int insertDictType(SysDictType dictType) - { + public int insertDictType(SysDictType dictType) { int row = dictTypeMapper.insertDictType(dictType); - if (row > 0) - { + if (row > 0) { DictUtils.clearDictCache(); } return row; @@ -166,19 +150,17 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService /** * 修改保存字典类型信息 - * + * * @param dictType 字典类型信息 * @return 结果 */ @Override @Transactional - public int updateDictType(SysDictType dictType) - { + public int updateDictType(SysDictType dictType) { SysDictType oldDict = dictTypeMapper.selectDictTypeById(dictType.getDictId()); dictDataMapper.updateDictDataType(oldDict.getDictType(), dictType.getDictType()); int row = dictTypeMapper.updateDictType(dictType); - if (row > 0) - { + if (row > 0) { DictUtils.clearDictCache(); } return row; @@ -186,17 +168,15 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService /** * 校验字典类型称是否唯一 - * + * * @param dict 字典类型 * @return 结果 */ @Override - public String checkDictTypeUnique(SysDictType dict) - { + public String checkDictTypeUnique(SysDictType dict) { Long dictId = StringUtils.isNull(dict.getDictId()) ? -1L : dict.getDictId(); SysDictType dictType = dictTypeMapper.checkDictTypeUnique(dict.getDictType()); - if (StringUtils.isNotNull(dictType) && dictType.getDictId().longValue() != dictId.longValue()) - { + if (StringUtils.isNotNull(dictType) && dictType.getDictId().longValue() != dictId.longValue()) { return UserConstants.NOT_UNIQUE; } return UserConstants.UNIQUE; diff --git a/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/impl/SysLogininforServiceImpl.java b/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/impl/SysLogininforServiceImpl.java index edf04b0..f3de315 100644 --- a/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/impl/SysLogininforServiceImpl.java +++ b/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/impl/SysLogininforServiceImpl.java @@ -1,6 +1,7 @@ package com.hchyun.system.service.impl; import java.util.List; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.hchyun.system.entity.SysLogininfor; @@ -9,48 +10,44 @@ import com.hchyun.system.service.ISysLogininforService; /** * 系统访问日志情况信息 服务层处理 - * + * * @author hchyun */ @Service -public class SysLogininforServiceImpl implements ISysLogininforService -{ +public class SysLogininforServiceImpl implements ISysLogininforService { @Autowired private SysLogininforDao logininforMapper; /** * 新增系统登录日志 - * + * * @param logininfor 访问日志对象 */ @Override - public void insertLogininfor(SysLogininfor logininfor) - { + public void insertLogininfor(SysLogininfor logininfor) { logininforMapper.insertLogininfor(logininfor); } /** * 查询系统登录日志集合 - * + * * @param logininfor 访问日志对象 * @return 登录记录集合 */ @Override - public List selectLogininforList(SysLogininfor logininfor) - { + public List selectLogininforList(SysLogininfor logininfor) { return logininforMapper.selectLogininforList(logininfor); } /** * 批量删除系统登录日志 - * + * * @param infoIds 需要删除的登录日志ID * @return */ @Override - public int deleteLogininforByIds(Long[] infoIds) - { + public int deleteLogininforByIds(Long[] infoIds) { return logininforMapper.deleteLogininforByIds(infoIds); } @@ -58,8 +55,7 @@ public class SysLogininforServiceImpl implements ISysLogininforService * 清空系统登录日志 */ @Override - public void cleanLogininfor() - { + public void cleanLogininfor() { logininforMapper.cleanLogininfor(); } } diff --git a/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/impl/SysMenuServiceImpl.java b/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/impl/SysMenuServiceImpl.java index 8a12848..b021c25 100644 --- a/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/impl/SysMenuServiceImpl.java +++ b/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/impl/SysMenuServiceImpl.java @@ -8,6 +8,7 @@ import java.util.LinkedList; import java.util.List; import java.util.Set; import java.util.stream.Collectors; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.hchyun.common.constant.UserConstants; @@ -26,12 +27,11 @@ import com.hchyun.system.service.ISysMenuService; /** * 菜单 业务层处理 - * + * * @author hchyun */ @Service -public class SysMenuServiceImpl implements ISysMenuService -{ +public class SysMenuServiceImpl implements ISysMenuService { public static final String PREMISSION_STRING = "perms[\"{0}\"]"; @Autowired @@ -45,33 +45,28 @@ public class SysMenuServiceImpl implements ISysMenuService /** * 根据用户查询系统菜单列表 - * + * * @param userId 用户ID * @return 菜单列表 */ @Override - public List selectMenuList(Long userId) - { + public List selectMenuList(Long userId) { return selectMenuList(new SysMenu(), userId); } /** * 查询系统菜单列表 - * + * * @param menu 菜单信息 * @return 菜单列表 */ @Override - public List selectMenuList(SysMenu menu, Long userId) - { + public List selectMenuList(SysMenu menu, Long userId) { List menuList = null; // 管理员显示所有菜单信息 - if (SysUser.isAdmin(userId)) - { + if (SysUser.isAdmin(userId)) { menuList = menuMapper.selectMenuList(menu); - } - else - { + } else { menu.getParams().put("userId", userId); menuList = menuMapper.selectMenuListByUserId(menu); } @@ -80,19 +75,16 @@ public class SysMenuServiceImpl implements ISysMenuService /** * 根据用户ID查询权限 - * + * * @param userId 用户ID * @return 权限列表 */ @Override - public Set selectMenuPermsByUserId(Long userId) - { + public Set selectMenuPermsByUserId(Long userId) { List perms = menuMapper.selectMenuPermsByUserId(userId); Set permsSet = new HashSet<>(); - for (String perm : perms) - { - if (StringUtils.isNotEmpty(perm)) - { + for (String perm : perms) { + if (StringUtils.isNotEmpty(perm)) { permsSet.addAll(Arrays.asList(perm.trim().split(","))); } } @@ -101,20 +93,16 @@ public class SysMenuServiceImpl implements ISysMenuService /** * 根据用户ID查询菜单 - * + * * @param userId 用户名称 * @return 菜单列表 */ @Override - public List selectMenuTreeByUserId(Long userId) - { + public List selectMenuTreeByUserId(Long userId) { List menus = null; - if (SecurityUtils.isAdmin(userId)) - { + if (SecurityUtils.isAdmin(userId)) { menus = menuMapper.selectMenuTreeAll(); - } - else - { + } else { menus = menuMapper.selectMenuTreeByUserId(userId); } return getChildPerms(menus, 0); @@ -122,29 +110,26 @@ public class SysMenuServiceImpl implements ISysMenuService /** * 根据角色ID查询菜单树信息 - * + * * @param roleId 角色ID * @return 选中菜单列表 */ @Override - public List selectMenuListByRoleId(Long roleId) - { + public List selectMenuListByRoleId(Long roleId) { SysRole role = roleMapper.selectRoleById(roleId); return menuMapper.selectMenuListByRoleId(roleId, role.isMenuCheckStrictly()); } /** * 构建前端路由所需要的菜单 - * + * * @param menus 菜单列表 * @return 路由列表 */ @Override - public List buildMenus(List menus) - { + public List buildMenus(List menus) { List routers = new LinkedList(); - for (SysMenu menu : menus) - { + for (SysMenu menu : menus) { RouterVo router = new RouterVo(); router.setHidden("1".equals(menu.getVisible())); router.setName(getRouteName(menu)); @@ -152,14 +137,11 @@ public class SysMenuServiceImpl implements ISysMenuService router.setComponent(getComponent(menu)); router.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon(), StringUtils.equals("1", menu.getIsCache()))); List cMenus = menu.getChildren(); - if (!cMenus.isEmpty() && cMenus.size() > 0 && UserConstants.TYPE_DIR.equals(menu.getMenuType())) - { + if (!cMenus.isEmpty() && cMenus.size() > 0 && UserConstants.TYPE_DIR.equals(menu.getMenuType())) { router.setAlwaysShow(true); router.setRedirect("noRedirect"); router.setChildren(buildMenus(cMenus)); - } - else if (isMeunFrame(menu)) - { + } else if (isMeunFrame(menu)) { List childrenList = new ArrayList(); RouterVo children = new RouterVo(); children.setPath(menu.getPath()); @@ -176,31 +158,26 @@ public class SysMenuServiceImpl implements ISysMenuService /** * 构建前端所需要树结构 - * + * * @param menus 菜单列表 * @return 树结构列表 */ @Override - public List buildMenuTree(List menus) - { + public List buildMenuTree(List menus) { List returnList = new ArrayList(); List tempList = new ArrayList(); - for (SysMenu dept : menus) - { + for (SysMenu dept : menus) { tempList.add(dept.getMenuId()); } - for (Iterator iterator = menus.iterator(); iterator.hasNext();) - { + for (Iterator iterator = menus.iterator(); iterator.hasNext(); ) { SysMenu menu = (SysMenu) iterator.next(); // 如果是顶级节点, 遍历该父节点的所有子节点 - if (!tempList.contains(menu.getParentId())) - { + if (!tempList.contains(menu.getParentId())) { recursionFn(menus, menu); returnList.add(menu); } } - if (returnList.isEmpty()) - { + if (returnList.isEmpty()) { returnList = menus; } return returnList; @@ -208,104 +185,95 @@ public class SysMenuServiceImpl implements ISysMenuService /** * 构建前端所需要下拉树结构 - * + * * @param menus 菜单列表 * @return 下拉树结构列表 */ @Override - public List buildMenuTreeSelect(List menus) - { + public List buildMenuTreeSelect(List menus) { List menuTrees = buildMenuTree(menus); return menuTrees.stream().map(TreeSelect::new).collect(Collectors.toList()); } /** * 根据菜单ID查询信息 - * + * * @param menuId 菜单ID * @return 菜单信息 */ @Override - public SysMenu selectMenuById(Long menuId) - { + public SysMenu selectMenuById(Long menuId) { return menuMapper.selectMenuById(menuId); } /** * 是否存在菜单子节点 - * + * * @param menuId 菜单ID * @return 结果 */ @Override - public boolean hasChildByMenuId(Long menuId) - { + public boolean hasChildByMenuId(Long menuId) { int result = menuMapper.hasChildByMenuId(menuId); return result > 0 ? true : false; } /** * 查询菜单使用数量 - * + * * @param menuId 菜单ID * @return 结果 */ @Override - public boolean checkMenuExistRole(Long menuId) - { + public boolean checkMenuExistRole(Long menuId) { int result = roleMenuMapper.checkMenuExistRole(menuId); return result > 0 ? true : false; } /** * 新增保存菜单信息 - * + * * @param menu 菜单信息 * @return 结果 */ @Override - public int insertMenu(SysMenu menu) - { + public int insertMenu(SysMenu menu) { return menuMapper.insertMenu(menu); } /** * 修改保存菜单信息 - * + * * @param menu 菜单信息 * @return 结果 */ @Override - public int updateMenu(SysMenu menu) - { + public int updateMenu(SysMenu menu) { return menuMapper.updateMenu(menu); } /** * 删除菜单管理信息 - * + * * @param menuId 菜单ID * @return 结果 */ @Override - public int deleteMenuById(Long menuId) - { + public int deleteMenuById(Long menuId) { return menuMapper.deleteMenuById(menuId); } /** * 校验菜单名称是否唯一 - * + * * @param menu 菜单信息 * @return 结果 */ @Override - public String checkMenuNameUnique(SysMenu menu) - { + public String checkMenuNameUnique(SysMenu menu) { Long menuId = StringUtils.isNull(menu.getMenuId()) ? -1L : menu.getMenuId(); SysMenu info = menuMapper.checkMenuNameUnique(menu.getMenuName(), menu.getParentId()); - if (StringUtils.isNotNull(info) && info.getMenuId().longValue() != menuId.longValue()) - { + if (StringUtils.isNotNull(info) && info.getMenuId().longValue() != menuId.longValue()) { return UserConstants.NOT_UNIQUE; } return UserConstants.UNIQUE; @@ -313,16 +281,14 @@ public class SysMenuServiceImpl implements ISysMenuService /** * 获取路由名称 - * + * * @param menu 菜单信息 * @return 路由名称 */ - public String getRouteName(SysMenu menu) - { + public String getRouteName(SysMenu menu) { String routerName = StringUtils.capitalize(menu.getPath()); // 非外链并且是一级目录(类型为目录) - if (isMeunFrame(menu)) - { + if (isMeunFrame(menu)) { routerName = StringUtils.EMPTY; } return routerName; @@ -330,22 +296,19 @@ public class SysMenuServiceImpl implements ISysMenuService /** * 获取路由地址 - * + * * @param menu 菜单信息 * @return 路由地址 */ - public String getRouterPath(SysMenu menu) - { + public String getRouterPath(SysMenu menu) { String routerPath = menu.getPath(); // 非外链并且是一级目录(类型为目录) if (0 == menu.getParentId().intValue() && UserConstants.TYPE_DIR.equals(menu.getMenuType()) - && UserConstants.NO_FRAME.equals(menu.getIsFrame())) - { + && UserConstants.NO_FRAME.equals(menu.getIsFrame())) { routerPath = "/" + menu.getPath(); } // 非外链并且是一级目录(类型为菜单) - else if (isMeunFrame(menu)) - { + else if (isMeunFrame(menu)) { routerPath = "/"; } return routerPath; @@ -353,15 +316,13 @@ public class SysMenuServiceImpl implements ISysMenuService /** * 获取组件信息 - * + * * @param menu 菜单信息 * @return 组件信息 */ - public String getComponent(SysMenu menu) - { + public String getComponent(SysMenu menu) { String component = UserConstants.LAYOUT; - if (StringUtils.isNotEmpty(menu.getComponent()) && !isMeunFrame(menu)) - { + if (StringUtils.isNotEmpty(menu.getComponent()) && !isMeunFrame(menu)) { component = menu.getComponent(); } return component; @@ -369,32 +330,28 @@ public class SysMenuServiceImpl implements ISysMenuService /** * 是否为菜单内部跳转 - * + * * @param menu 菜单信息 * @return 结果 */ - public boolean isMeunFrame(SysMenu menu) - { + public boolean isMeunFrame(SysMenu menu) { return menu.getParentId().intValue() == 0 && UserConstants.TYPE_MENU.equals(menu.getMenuType()) && menu.getIsFrame().equals(UserConstants.NO_FRAME); } /** * 根据父节点的ID获取所有子节点 - * - * @param list 分类表 + * + * @param list 分类表 * @param parentId 传入的父节点ID * @return String */ - public List getChildPerms(List list, int parentId) - { + public List getChildPerms(List list, int parentId) { List returnList = new ArrayList(); - for (Iterator iterator = list.iterator(); iterator.hasNext();) - { + for (Iterator iterator = list.iterator(); iterator.hasNext(); ) { SysMenu t = (SysMenu) iterator.next(); // 一、根据传入的某个父节点ID,遍历该父节点的所有子节点 - if (t.getParentId() == parentId) - { + if (t.getParentId() == parentId) { recursionFn(list, t); returnList.add(t); } @@ -404,19 +361,16 @@ public class SysMenuServiceImpl implements ISysMenuService /** * 递归列表 - * + * * @param list * @param t */ - private void recursionFn(List list, SysMenu t) - { + private void recursionFn(List list, SysMenu t) { // 得到子节点列表 List childList = getChildList(list, t); t.setChildren(childList); - for (SysMenu tChild : childList) - { - if (hasChild(list, tChild)) - { + for (SysMenu tChild : childList) { + if (hasChild(list, tChild)) { recursionFn(list, tChild); } } @@ -425,15 +379,12 @@ public class SysMenuServiceImpl implements ISysMenuService /** * 得到子节点列表 */ - private List getChildList(List list, SysMenu t) - { + private List getChildList(List list, SysMenu t) { List tlist = new ArrayList(); Iterator it = list.iterator(); - while (it.hasNext()) - { + while (it.hasNext()) { SysMenu n = (SysMenu) it.next(); - if (n.getParentId().longValue() == t.getMenuId().longValue()) - { + if (n.getParentId().longValue() == t.getMenuId().longValue()) { tlist.add(n); } } @@ -443,8 +394,7 @@ public class SysMenuServiceImpl implements ISysMenuService /** * 判断是否有子节点 */ - private boolean hasChild(List list, SysMenu t) - { + private boolean hasChild(List list, SysMenu t) { return getChildList(list, t).size() > 0 ? true : false; } } diff --git a/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/impl/SysNoticeServiceImpl.java b/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/impl/SysNoticeServiceImpl.java index 234e7b1..4a61230 100644 --- a/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/impl/SysNoticeServiceImpl.java +++ b/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/impl/SysNoticeServiceImpl.java @@ -1,6 +1,7 @@ package com.hchyun.system.service.impl; import java.util.List; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.hchyun.system.entity.SysNotice; @@ -9,84 +10,77 @@ import com.hchyun.system.service.ISysNoticeService; /** * 公告 服务层实现 - * + * * @author hchyun */ @Service -public class SysNoticeServiceImpl implements ISysNoticeService -{ +public class SysNoticeServiceImpl implements ISysNoticeService { @Autowired private SysNoticeDao noticeMapper; /** * 查询公告信息 - * + * * @param noticeId 公告ID * @return 公告信息 */ @Override - public SysNotice selectNoticeById(Long noticeId) - { + public SysNotice selectNoticeById(Long noticeId) { return noticeMapper.selectNoticeById(noticeId); } /** * 查询公告列表 - * + * * @param notice 公告信息 * @return 公告集合 */ @Override - public List selectNoticeList(SysNotice notice) - { + public List selectNoticeList(SysNotice notice) { return noticeMapper.selectNoticeList(notice); } /** * 新增公告 - * + * * @param notice 公告信息 * @return 结果 */ @Override - public int insertNotice(SysNotice notice) - { + public int insertNotice(SysNotice notice) { return noticeMapper.insertNotice(notice); } /** * 修改公告 - * + * * @param notice 公告信息 * @return 结果 */ @Override - public int updateNotice(SysNotice notice) - { + public int updateNotice(SysNotice notice) { return noticeMapper.updateNotice(notice); } /** * 删除公告对象 - * + * * @param noticeId 公告ID * @return 结果 */ @Override - public int deleteNoticeById(Long noticeId) - { + public int deleteNoticeById(Long noticeId) { return noticeMapper.deleteNoticeById(noticeId); } /** * 批量删除公告信息 - * + * * @param noticeIds 需要删除的公告ID * @return 结果 */ @Override - public int deleteNoticeByIds(Long[] noticeIds) - { + public int deleteNoticeByIds(Long[] noticeIds) { return noticeMapper.deleteNoticeByIds(noticeIds); } } diff --git a/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/impl/SysOperLogServiceImpl.java b/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/impl/SysOperLogServiceImpl.java index 1f33c5a..904458f 100644 --- a/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/impl/SysOperLogServiceImpl.java +++ b/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/impl/SysOperLogServiceImpl.java @@ -1,6 +1,7 @@ package com.hchyun.system.service.impl; import java.util.List; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.hchyun.system.entity.SysOperLog; @@ -9,59 +10,54 @@ import com.hchyun.system.service.ISysOperLogService; /** * 操作日志 服务层处理 - * + * * @author hchyun */ @Service -public class SysOperLogServiceImpl implements ISysOperLogService -{ +public class SysOperLogServiceImpl implements ISysOperLogService { @Autowired private SysOperLogDao operLogMapper; /** * 新增操作日志 - * + * * @param operLog 操作日志对象 */ @Override - public void insertOperlog(SysOperLog operLog) - { + public void insertOperlog(SysOperLog operLog) { operLogMapper.insertOperlog(operLog); } /** * 查询系统操作日志集合 - * + * * @param operLog 操作日志对象 * @return 操作日志集合 */ @Override - public List selectOperLogList(SysOperLog operLog) - { + public List selectOperLogList(SysOperLog operLog) { return operLogMapper.selectOperLogList(operLog); } /** * 批量删除系统操作日志 - * + * * @param operIds 需要删除的操作日志ID * @return 结果 */ @Override - public int deleteOperLogByIds(Long[] operIds) - { + public int deleteOperLogByIds(Long[] operIds) { return operLogMapper.deleteOperLogByIds(operIds); } /** * 查询操作日志详细 - * + * * @param operId 操作ID * @return 操作日志对象 */ @Override - public SysOperLog selectOperLogById(Long operId) - { + public SysOperLog selectOperLogById(Long operId) { return operLogMapper.selectOperLogById(operId); } @@ -69,8 +65,7 @@ public class SysOperLogServiceImpl implements ISysOperLogService * 清空操作日志 */ @Override - public void cleanOperLog() - { + public void cleanOperLog() { operLogMapper.cleanOperLog(); } } diff --git a/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/impl/SysPostServiceImpl.java b/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/impl/SysPostServiceImpl.java index 50fdd43..e4ca43c 100644 --- a/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/impl/SysPostServiceImpl.java +++ b/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/impl/SysPostServiceImpl.java @@ -1,6 +1,7 @@ package com.hchyun.system.service.impl; import java.util.List; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.hchyun.common.constant.UserConstants; @@ -13,12 +14,11 @@ import com.hchyun.system.service.ISysPostService; /** * 岗位信息 服务层处理 - * + * * @author hchyun */ @Service -public class SysPostServiceImpl implements ISysPostService -{ +public class SysPostServiceImpl implements ISysPostService { @Autowired private SysPostDao postMapper; @@ -27,64 +27,58 @@ public class SysPostServiceImpl implements ISysPostService /** * 查询岗位信息集合 - * + * * @param post 岗位信息 * @return 岗位信息集合 */ @Override - public List selectPostList(SysPost post) - { + public List selectPostList(SysPost post) { return postMapper.selectPostList(post); } /** * 查询所有岗位 - * + * * @return 岗位列表 */ @Override - public List selectPostAll() - { + public List selectPostAll() { return postMapper.selectPostAll(); } /** * 通过岗位ID查询岗位信息 - * + * * @param postId 岗位ID * @return 角色对象信息 */ @Override - public SysPost selectPostById(Long postId) - { + public SysPost selectPostById(Long postId) { return postMapper.selectPostById(postId); } /** * 根据用户ID获取岗位选择框列表 - * + * * @param userId 用户ID * @return 选中岗位ID列表 */ @Override - public List selectPostListByUserId(Long userId) - { + public List selectPostListByUserId(Long userId) { return postMapper.selectPostListByUserId(userId); } /** * 校验岗位名称是否唯一 - * + * * @param post 岗位信息 * @return 结果 */ @Override - public String checkPostNameUnique(SysPost post) - { + public String checkPostNameUnique(SysPost post) { Long postId = StringUtils.isNull(post.getPostId()) ? -1L : post.getPostId(); SysPost info = postMapper.checkPostNameUnique(post.getPostName()); - if (StringUtils.isNotNull(info) && info.getPostId().longValue() != postId.longValue()) - { + if (StringUtils.isNotNull(info) && info.getPostId().longValue() != postId.longValue()) { return UserConstants.NOT_UNIQUE; } return UserConstants.UNIQUE; @@ -92,17 +86,15 @@ public class SysPostServiceImpl implements ISysPostService /** * 校验岗位编码是否唯一 - * + * * @param post 岗位信息 * @return 结果 */ @Override - public String checkPostCodeUnique(SysPost post) - { + public String checkPostCodeUnique(SysPost post) { Long postId = StringUtils.isNull(post.getPostId()) ? -1L : post.getPostId(); SysPost info = postMapper.checkPostCodeUnique(post.getPostCode()); - if (StringUtils.isNotNull(info) && info.getPostId().longValue() != postId.longValue()) - { + if (StringUtils.isNotNull(info) && info.getPostId().longValue() != postId.longValue()) { return UserConstants.NOT_UNIQUE; } return UserConstants.UNIQUE; @@ -110,43 +102,38 @@ public class SysPostServiceImpl implements ISysPostService /** * 通过岗位ID查询岗位使用数量 - * + * * @param postId 岗位ID * @return 结果 */ @Override - public int countUserPostById(Long postId) - { + public int countUserPostById(Long postId) { return userPostMapper.countUserPostById(postId); } /** * 删除岗位信息 - * + * * @param postId 岗位ID * @return 结果 */ @Override - public int deletePostById(Long postId) - { + public int deletePostById(Long postId) { return postMapper.deletePostById(postId); } /** * 批量删除岗位信息 - * + * * @param postIds 需要删除的岗位ID * @return 结果 * @throws Exception 异常 */ @Override - public int deletePostByIds(Long[] postIds) - { - for (Long postId : postIds) - { + public int deletePostByIds(Long[] postIds) { + for (Long postId : postIds) { SysPost post = selectPostById(postId); - if (countUserPostById(postId) > 0) - { + if (countUserPostById(postId) > 0) { throw new CustomException(String.format("%1$s已分配,不能删除", post.getPostName())); } } @@ -155,25 +142,23 @@ public class SysPostServiceImpl implements ISysPostService /** * 新增保存岗位信息 - * + * * @param post 岗位信息 * @return 结果 */ @Override - public int insertPost(SysPost post) - { + public int insertPost(SysPost post) { return postMapper.insertPost(post); } /** * 修改保存岗位信息 - * + * * @param post 岗位信息 * @return 结果 */ @Override - public int updatePost(SysPost post) - { + public int updatePost(SysPost post) { return postMapper.updatePost(post); } } diff --git a/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/impl/SysRoleServiceImpl.java b/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/impl/SysRoleServiceImpl.java index 8363abb..261ecc2 100644 --- a/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/impl/SysRoleServiceImpl.java +++ b/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/impl/SysRoleServiceImpl.java @@ -5,6 +5,7 @@ import java.util.Arrays; import java.util.HashSet; import java.util.List; import java.util.Set; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -24,12 +25,11 @@ import com.hchyun.system.service.ISysRoleService; /** * 角色 业务层处理 - * + * * @author hchyun */ @Service -public class SysRoleServiceImpl implements ISysRoleService -{ +public class SysRoleServiceImpl implements ISysRoleService { @Autowired private SysRoleDao roleMapper; @@ -44,32 +44,28 @@ public class SysRoleServiceImpl implements ISysRoleService /** * 根据条件分页查询角色数据 - * + * * @param role 角色信息 * @return 角色数据集合信息 */ @Override @DataScope(deptAlias = "d") - public List selectRoleList(SysRole role) - { + public List selectRoleList(SysRole role) { return roleMapper.selectRoleList(role); } /** * 根据用户ID查询权限 - * + * * @param userId 用户ID * @return 权限列表 */ @Override - public Set selectRolePermissionByUserId(Long userId) - { + public Set selectRolePermissionByUserId(Long userId) { List perms = roleMapper.selectRolePermissionByUserId(userId); Set permsSet = new HashSet<>(); - for (SysRole perm : perms) - { - if (StringUtils.isNotNull(perm)) - { + for (SysRole perm : perms) { + if (StringUtils.isNotNull(perm)) { permsSet.addAll(Arrays.asList(perm.getRoleKey().trim().split(","))); } } @@ -78,53 +74,48 @@ public class SysRoleServiceImpl implements ISysRoleService /** * 查询所有角色 - * - * @return 角色列表 + * * @param type + * @return 角色列表 */ @Override - public List selectRoleAll(Integer type) - { + public List selectRoleAll(Integer type) { return SpringUtils.getAopProxy(this).selectRoleList(new SysRole(type)); } /** * 根据用户ID获取角色选择框列表 - * + * * @param userId 用户ID * @return 选中角色ID列表 */ @Override - public List selectRoleListByUserId(Long userId) - { + public List selectRoleListByUserId(Long userId) { return roleMapper.selectRoleListByUserId(userId); } /** * 通过角色ID查询角色 - * + * * @param roleId 角色ID * @return 角色对象信息 */ @Override - public SysRole selectRoleById(Long roleId) - { + public SysRole selectRoleById(Long roleId) { return roleMapper.selectRoleById(roleId); } /** * 校验角色名称是否唯一 - * + * * @param role 角色信息 * @return 结果 */ @Override - public String checkRoleNameUnique(SysRole role) - { + public String checkRoleNameUnique(SysRole role) { Long roleId = StringUtils.isNull(role.getRoleId()) ? -1L : role.getRoleId(); SysRole info = roleMapper.checkRoleNameUnique(role.getRoleName()); - if (StringUtils.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue()) - { + if (StringUtils.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue()) { return UserConstants.NOT_UNIQUE; } return UserConstants.UNIQUE; @@ -132,17 +123,15 @@ public class SysRoleServiceImpl implements ISysRoleService /** * 校验角色权限是否唯一 - * + * * @param role 角色信息 * @return 结果 */ @Override - public String checkRoleKeyUnique(SysRole role) - { + public String checkRoleKeyUnique(SysRole role) { Long roleId = StringUtils.isNull(role.getRoleId()) ? -1L : role.getRoleId(); SysRole info = roleMapper.checkRoleKeyUnique(role.getRoleKey()); - if (StringUtils.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue()) - { + if (StringUtils.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue()) { return UserConstants.NOT_UNIQUE; } return UserConstants.UNIQUE; @@ -150,40 +139,36 @@ public class SysRoleServiceImpl implements ISysRoleService /** * 校验角色是否允许操作 - * + * * @param role 角色信息 */ @Override - public void checkRoleAllowed(SysRole role) - { - if (StringUtils.isNotNull(role.getRoleId()) && role.isAdmin()) - { + public void checkRoleAllowed(SysRole role) { + if (StringUtils.isNotNull(role.getRoleId()) && role.isAdmin()) { throw new CustomException("不允许操作超级管理员角色"); } } /** * 通过角色ID查询角色使用数量 - * + * * @param roleId 角色ID * @return 结果 */ @Override - public int countUserRoleByRoleId(Long roleId) - { + public int countUserRoleByRoleId(Long roleId) { return userRoleMapper.countUserRoleByRoleId(roleId); } /** * 新增保存角色信息 - * + * * @param role 角色信息 * @return 结果 */ @Override @Transactional - public int insertRole(SysRole role) - { + public int insertRole(SysRole role) { // 新增角色信息 roleMapper.insertRole(role); return insertRoleMenu(role); @@ -191,14 +176,13 @@ public class SysRoleServiceImpl implements ISysRoleService /** * 修改保存角色信息 - * + * * @param role 角色信息 * @return 结果 */ @Override @Transactional - public int updateRole(SysRole role) - { + public int updateRole(SysRole role) { // 修改角色信息 roleMapper.updateRole(role); // 删除角色与菜单关联 @@ -208,26 +192,24 @@ public class SysRoleServiceImpl implements ISysRoleService /** * 修改角色状态 - * + * * @param role 角色信息 * @return 结果 */ @Override - public int updateRoleStatus(SysRole role) - { + public int updateRoleStatus(SysRole role) { return roleMapper.updateRole(role); } /** * 修改数据权限信息 - * + * * @param role 角色信息 * @return 结果 */ @Override @Transactional - public int authDataScope(SysRole role) - { + public int authDataScope(SysRole role) { // 修改角色信息 roleMapper.updateRole(role); // 删除角色与部门关联 @@ -238,23 +220,20 @@ public class SysRoleServiceImpl implements ISysRoleService /** * 新增角色菜单信息 - * + * * @param role 角色对象 */ - public int insertRoleMenu(SysRole role) - { + public int insertRoleMenu(SysRole role) { int rows = 1; // 新增用户与角色管理 List list = new ArrayList(); - for (Long menuId : role.getMenuIds()) - { + for (Long menuId : role.getMenuIds()) { SysRoleMenu rm = new SysRoleMenu(); rm.setRoleId(role.getRoleId()); rm.setMenuId(menuId); list.add(rm); } - if (list.size() > 0) - { + if (list.size() > 0) { rows = roleMenuMapper.batchRoleMenu(list); } return rows; @@ -265,20 +244,17 @@ public class SysRoleServiceImpl implements ISysRoleService * * @param role 角色对象 */ - public int insertRoleDept(SysRole role) - { + public int insertRoleDept(SysRole role) { int rows = 1; // 新增角色与部门(数据权限)管理 List list = new ArrayList(); - for (Long deptId : role.getDeptIds()) - { + for (Long deptId : role.getDeptIds()) { SysRoleDept rd = new SysRoleDept(); rd.setRoleId(role.getRoleId()); rd.setDeptId(deptId); list.add(rd); } - if (list.size() > 0) - { + if (list.size() > 0) { rows = roleDeptMapper.batchRoleDept(list); } return rows; @@ -286,31 +262,27 @@ public class SysRoleServiceImpl implements ISysRoleService /** * 通过角色ID删除角色 - * + * * @param roleId 角色ID * @return 结果 */ @Override - public int deleteRoleById(Long roleId) - { + public int deleteRoleById(Long roleId) { return roleMapper.deleteRoleById(roleId); } /** * 批量删除角色信息 - * + * * @param roleIds 需要删除的角色ID * @return 结果 */ @Override - public int deleteRoleByIds(Long[] roleIds) - { - for (Long roleId : roleIds) - { + public int deleteRoleByIds(Long[] roleIds) { + for (Long roleId : roleIds) { checkRoleAllowed(new SysRole(roleId)); SysRole role = selectRoleById(roleId); - if (countUserRoleByRoleId(roleId) > 0) - { + if (countUserRoleByRoleId(roleId) > 0) { throw new CustomException(String.format("%1$s已分配,不能删除", role.getRoleName())); } } diff --git a/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/impl/SysUserOnlineServiceImpl.java b/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/impl/SysUserOnlineServiceImpl.java index 3444ba9..e8e9f59 100644 --- a/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/impl/SysUserOnlineServiceImpl.java +++ b/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/impl/SysUserOnlineServiceImpl.java @@ -8,24 +8,21 @@ import com.hchyun.system.service.ISysUserOnlineService; /** * 在线用户 服务层处理 - * + * * @author hchyun */ @Service -public class SysUserOnlineServiceImpl implements ISysUserOnlineService -{ +public class SysUserOnlineServiceImpl implements ISysUserOnlineService { /** * 通过登录地址查询信息 - * + * * @param ipaddr 登录地址 - * @param user 用户信息 + * @param user 用户信息 * @return 在线用户信息 */ @Override - public SysUserOnline selectOnlineByIpaddr(String ipaddr, LoginUser user) - { - if (StringUtils.equals(ipaddr, user.getIpaddr())) - { + public SysUserOnline selectOnlineByIpaddr(String ipaddr, LoginUser user) { + if (StringUtils.equals(ipaddr, user.getIpaddr())) { return loginUserToUserOnline(user); } return null; @@ -33,16 +30,14 @@ public class SysUserOnlineServiceImpl implements ISysUserOnlineService /** * 通过用户名称查询信息 - * + * * @param userName 用户名称 - * @param user 用户信息 + * @param user 用户信息 * @return 在线用户信息 */ @Override - public SysUserOnline selectOnlineByUserName(String userName, LoginUser user) - { - if (StringUtils.equals(userName, user.getUsername())) - { + public SysUserOnline selectOnlineByUserName(String userName, LoginUser user) { + if (StringUtils.equals(userName, user.getUsername())) { return loginUserToUserOnline(user); } return null; @@ -50,17 +45,15 @@ public class SysUserOnlineServiceImpl implements ISysUserOnlineService /** * 通过登录地址/用户名称查询信息 - * - * @param ipaddr 登录地址 + * + * @param ipaddr 登录地址 * @param userName 用户名称 - * @param user 用户信息 + * @param user 用户信息 * @return 在线用户信息 */ @Override - public SysUserOnline selectOnlineByInfo(String ipaddr, String userName, LoginUser user) - { - if (StringUtils.equals(ipaddr, user.getIpaddr()) && StringUtils.equals(userName, user.getUsername())) - { + public SysUserOnline selectOnlineByInfo(String ipaddr, String userName, LoginUser user) { + if (StringUtils.equals(ipaddr, user.getIpaddr()) && StringUtils.equals(userName, user.getUsername())) { return loginUserToUserOnline(user); } return null; @@ -68,15 +61,13 @@ public class SysUserOnlineServiceImpl implements ISysUserOnlineService /** * 设置在线用户信息 - * + * * @param user 用户信息 * @return 在线用户 */ @Override - public SysUserOnline loginUserToUserOnline(LoginUser user) - { - if (StringUtils.isNull(user) || StringUtils.isNull(user.getUser())) - { + public SysUserOnline loginUserToUserOnline(LoginUser user) { + if (StringUtils.isNull(user) || StringUtils.isNull(user.getUser())) { return null; } SysUserOnline sysUserOnline = new SysUserOnline(); @@ -87,8 +78,7 @@ public class SysUserOnlineServiceImpl implements ISysUserOnlineService sysUserOnline.setBrowser(user.getBrowser()); sysUserOnline.setOs(user.getOs()); sysUserOnline.setLoginTime(user.getLoginTime()); - if (StringUtils.isNotNull(user.getUser().getDept())) - { + if (StringUtils.isNotNull(user.getUser().getDept())) { sysUserOnline.setDeptName(user.getUser().getDept().getDeptName()); } return sysUserOnline; diff --git a/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/impl/SysUserServiceImpl.java b/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/impl/SysUserServiceImpl.java index 45ea1f0..cb6471a 100644 --- a/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/impl/SysUserServiceImpl.java +++ b/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/impl/SysUserServiceImpl.java @@ -2,6 +2,7 @@ package com.hchyun.system.service.impl; import java.util.ArrayList; import java.util.List; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -27,12 +28,11 @@ import com.hchyun.system.service.ISysUserService; /** * 用户 业务层处理 - * + * * @author hchyun */ @Service -public class SysUserServiceImpl implements ISysUserService -{ +public class SysUserServiceImpl implements ISysUserService { private static final Logger log = LoggerFactory.getLogger(SysUserServiceImpl.class); @Autowired @@ -55,58 +55,52 @@ public class SysUserServiceImpl implements ISysUserService /** * 根据条件分页查询用户列表 - * + * * @param user 用户信息 * @return 用户信息集合信息 */ @Override @DataScope(deptAlias = "d", userAlias = "u") - public List selectUserList(SysUser user) - { + public List selectUserList(SysUser user) { return userMapper.selectUserList(user); } /** * 通过用户名查询用户 - * + * * @param userName 用户名 * @return 用户对象信息 */ @Override - public SysUser selectUserByUserName(String userName) - { + public SysUser selectUserByUserName(String userName) { return userMapper.selectUserByUserName(userName); } /** * 通过用户ID查询用户 - * + * * @param userId 用户ID * @return 用户对象信息 */ @Override - public SysUser selectUserById(Long userId) - { + public SysUser selectUserById(Long userId) { return userMapper.selectUserById(userId); } /** * 查询用户所属角色组 - * + * * @param userName 用户名 * @return 结果 */ @Override - public String selectUserRoleGroup(String userName) - { + public String selectUserRoleGroup(String userName) { List list = roleMapper.selectRolesByUserName(userName); StringBuffer idsStr = new StringBuffer(); - for (SysRole role : list) - { + for (SysRole role : list) { idsStr.append(role.getRoleName()).append(","); } - if (StringUtils.isNotEmpty(idsStr.toString())) - { + if (StringUtils.isNotEmpty(idsStr.toString())) { return idsStr.substring(0, idsStr.length() - 1); } return idsStr.toString(); @@ -114,21 +108,18 @@ public class SysUserServiceImpl implements ISysUserService /** * 查询用户所属岗位组 - * + * * @param userName 用户名 * @return 结果 */ @Override - public String selectUserPostGroup(String userName) - { + public String selectUserPostGroup(String userName) { List list = postMapper.selectPostsByUserName(userName); StringBuffer idsStr = new StringBuffer(); - for (SysPost post : list) - { + for (SysPost post : list) { idsStr.append(post.getPostName()).append(","); } - if (StringUtils.isNotEmpty(idsStr.toString())) - { + if (StringUtils.isNotEmpty(idsStr.toString())) { return idsStr.substring(0, idsStr.length() - 1); } return idsStr.toString(); @@ -136,16 +127,14 @@ public class SysUserServiceImpl implements ISysUserService /** * 校验用户名称是否唯一 - * + * * @param userName 用户名称 * @return 结果 */ @Override - public String checkUserNameUnique(String userName) - { + public String checkUserNameUnique(String userName) { int count = userMapper.checkUserNameUnique(userName); - if (count > 0) - { + if (count > 0) { return UserConstants.NOT_UNIQUE; } return UserConstants.UNIQUE; @@ -158,12 +147,10 @@ public class SysUserServiceImpl implements ISysUserService * @return */ @Override - public String checkPhoneUnique(SysUser user) - { + public String checkPhoneUnique(SysUser user) { Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId(); SysUser info = userMapper.checkPhoneUnique(user.getPhonenumber()); - if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue()) - { + if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue()) { return UserConstants.NOT_UNIQUE; } return UserConstants.UNIQUE; @@ -176,12 +163,10 @@ public class SysUserServiceImpl implements ISysUserService * @return */ @Override - public String checkEmailUnique(SysUser user) - { + public String checkEmailUnique(SysUser user) { Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId(); SysUser info = userMapper.checkEmailUnique(user.getEmail()); - if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue()) - { + if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue()) { return UserConstants.NOT_UNIQUE; } return UserConstants.UNIQUE; @@ -189,28 +174,25 @@ public class SysUserServiceImpl implements ISysUserService /** * 校验用户是否允许操作 - * + * * @param user 用户信息 */ @Override - public void checkUserAllowed(SysUser user) - { - if (StringUtils.isNotNull(user.getUserId()) && user.isAdmin()) - { + public void checkUserAllowed(SysUser user) { + if (StringUtils.isNotNull(user.getUserId()) && user.isAdmin()) { throw new CustomException("不允许操作超级管理员用户"); } } /** * 新增保存用户信息 - * + * * @param user 用户信息 * @return 结果 */ @Override @Transactional - public int insertUser(SysUser user) - { + public int insertUser(SysUser user) { // 新增用户信息 int rows = userMapper.insertUser(user); // 新增用户岗位关联 @@ -222,14 +204,13 @@ public class SysUserServiceImpl implements ISysUserService /** * 修改保存用户信息 - * + * * @param user 用户信息 * @return 结果 */ @Override @Transactional - public int updateUser(SysUser user) - { + public int updateUser(SysUser user) { Long userId = user.getUserId(); // 删除用户与角色关联 userRoleMapper.deleteUserRoleByUserId(userId); @@ -244,87 +225,78 @@ public class SysUserServiceImpl implements ISysUserService /** * 修改用户状态 - * + * * @param user 用户信息 * @return 结果 */ @Override - public int updateUserStatus(SysUser user) - { + public int updateUserStatus(SysUser user) { return userMapper.updateUser(user); } /** * 修改用户基本信息 - * + * * @param user 用户信息 * @return 结果 */ @Override - public int updateUserProfile(SysUser user) - { + public int updateUserProfile(SysUser user) { return userMapper.updateUser(user); } /** * 修改用户头像 - * + * * @param userName 用户名 - * @param avatar 头像地址 + * @param avatar 头像地址 * @return 结果 */ @Override - public boolean updateUserAvatar(String userName, String avatar) - { + public boolean updateUserAvatar(String userName, String avatar) { return userMapper.updateUserAvatar(userName, avatar) > 0; } /** * 重置用户密码 - * + * * @param user 用户信息 * @return 结果 */ @Override - public int resetPwd(SysUser user) - { + public int resetPwd(SysUser user) { return userMapper.updateUser(user); } /** * 重置用户密码 - * + * * @param userName 用户名 * @param password 密码 * @return 结果 */ @Override - public int resetUserPwd(String userName, String password) - { + public int resetUserPwd(String userName, String password) { return userMapper.resetUserPwd(userName, password); } /** * 新增用户角色信息 - * + * * @param user 用户对象 */ - public void insertUserRole(SysUser user) - { + public void insertUserRole(SysUser user) { Long[] roles = user.getRoleIds(); - if (StringUtils.isNotNull(roles)) - { + if (StringUtils.isNotNull(roles)) { // 新增用户与角色管理 List list = new ArrayList(); - for (Long roleId : roles) - { + for (Long roleId : roles) { SysUserRole ur = new SysUserRole(); ur.setUserId(user.getUserId()); ur.setRoleId(roleId); list.add(ur); } - if (list.size() > 0) - { + if (list.size() > 0) { userRoleMapper.batchUserRole(list); } } @@ -332,25 +304,21 @@ public class SysUserServiceImpl implements ISysUserService /** * 新增用户岗位信息 - * + * * @param user 用户对象 */ - public void insertUserPost(SysUser user) - { + public void insertUserPost(SysUser user) { Long[] posts = user.getPostIds(); - if (StringUtils.isNotNull(posts)) - { + if (StringUtils.isNotNull(posts)) { // 新增用户与岗位管理 List list = new ArrayList(); - for (Long postId : posts) - { + for (Long postId : posts) { SysUserPost up = new SysUserPost(); up.setUserId(user.getUserId()); up.setPostId(postId); list.add(up); } - if (list.size() > 0) - { + if (list.size() > 0) { userPostMapper.batchUserPost(list); } } @@ -358,13 +326,12 @@ public class SysUserServiceImpl implements ISysUserService /** * 通过用户ID删除用户 - * + * * @param userId 用户ID * @return 结果 */ @Override - public int deleteUserById(Long userId) - { + public int deleteUserById(Long userId) { // 删除用户与角色关联 userRoleMapper.deleteUserRoleByUserId(userId); // 删除用户与岗位表 @@ -374,15 +341,13 @@ public class SysUserServiceImpl implements ISysUserService /** * 批量删除用户信息 - * + * * @param userIds 需要删除的用户ID * @return 结果 */ @Override - public int deleteUserByIds(Long[] userIds) - { - for (Long userId : userIds) - { + public int deleteUserByIds(Long[] userIds) { + for (Long userId : userIds) { checkUserAllowed(new SysUser(userId)); } return userMapper.deleteUserByIds(userIds); @@ -390,17 +355,15 @@ public class SysUserServiceImpl implements ISysUserService /** * 导入用户数据 - * - * @param userList 用户数据列表 + * + * @param userList 用户数据列表 * @param isUpdateSupport 是否更新支持,如果已存在,则进行更新数据 - * @param operName 操作用户 + * @param operName 操作用户 * @return 结果 */ @Override - public String importUser(List userList, Boolean isUpdateSupport, Long operName) - { - if (StringUtils.isNull(userList) || userList.size() == 0) - { + public String importUser(List userList, Boolean isUpdateSupport, Long operName) { + if (StringUtils.isNull(userList) || userList.size() == 0) { throw new CustomException("导入用户数据不能为空!"); } int successNum = 0; @@ -408,48 +371,36 @@ public class SysUserServiceImpl implements ISysUserService StringBuilder successMsg = new StringBuilder(); StringBuilder failureMsg = new StringBuilder(); String password = configService.selectConfigByKey("sys.user.initPassword"); - for (SysUser user : userList) - { - try - { + for (SysUser user : userList) { + try { // 验证是否存在这个用户 SysUser u = userMapper.selectUserByUserName(user.getUserName()); - if (StringUtils.isNull(u)) - { + if (StringUtils.isNull(u)) { user.setPassword(SecurityUtils.encryptPassword(password)); user.setCreateBy(operName); this.insertUser(user); successNum++; successMsg.append("
" + successNum + "、账号 " + user.getUserName() + " 导入成功"); - } - else if (isUpdateSupport) - { + } else if (isUpdateSupport) { user.setUpdateBy(operName); this.updateUser(user); successNum++; successMsg.append("
" + successNum + "、账号 " + user.getUserName() + " 更新成功"); - } - else - { + } else { failureNum++; failureMsg.append("
" + failureNum + "、账号 " + user.getUserName() + " 已存在"); } - } - catch (Exception e) - { + } catch (Exception e) { failureNum++; String msg = "
" + failureNum + "、账号 " + user.getUserName() + " 导入失败:"; failureMsg.append(msg + e.getMessage()); log.error(msg, e); } } - if (failureNum > 0) - { + if (failureNum > 0) { failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:"); throw new CustomException(failureMsg.toString()); - } - else - { + } else { successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:"); } return successMsg.toString(); diff --git a/hchyun/hchyun-system/src/main/java/com/hchyun/system/utils/FtpUtils.java b/hchyun/hchyun-system/src/main/java/com/hchyun/system/utils/FtpUtils.java index 14e87d7..13c786b 100644 --- a/hchyun/hchyun-system/src/main/java/com/hchyun/system/utils/FtpUtils.java +++ b/hchyun/hchyun-system/src/main/java/com/hchyun/system/utils/FtpUtils.java @@ -5,7 +5,6 @@ import com.hchyun.common.config.HchYunConfig; import com.hchyun.common.utils.DateUtils; import com.hchyun.common.utils.file.FileUtils; import com.hchyun.common.utils.uuid.IdUtils; -import com.hchyun.system.dto.FileDownload; import com.hchyun.system.entity.SysFile; import org.apache.commons.io.FilenameUtils; import org.apache.commons.net.ftp.FTPClient; @@ -61,7 +60,7 @@ public class FtpUtils { } public void setPrifiles(String prifiles) { - FtpUtils.prifiles = prifiles +"/"; + FtpUtils.prifiles = prifiles + "/"; } public static String getResources() { @@ -94,6 +93,7 @@ public class FtpUtils { /** * 上传文件 + * * @param sysFile * @return */ @@ -105,11 +105,11 @@ public class FtpUtils { } else { ftpdir += prifiles; } - ftpdir +=DateUtils.datePath(); + ftpdir += DateUtils.datePath(); File file = new File(dir); sysFile.setFileName(file.getName()); sysFile.setFileSize(file.length() / 1024 / 1024); - sysFile.setMapping(IdUtils.fastUUID() +"."+ getExtension(file.getName())); + sysFile.setMapping(IdUtils.fastUUID() + "." + getExtension(file.getName())); sysFile.setFileAddr(ftpdir); sysFile.setFileType(getExtension(file.getName())); InputStream inputStream = null; @@ -139,7 +139,7 @@ public class FtpUtils { e.printStackTrace(); } - if (!FileUtils.deleteFile(dir)){ + if (!FileUtils.deleteFile(dir)) { return null; } return sysFile; @@ -161,7 +161,7 @@ public class FtpUtils { } ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE);//设置文件类型 //设置linux ftp服务器 - FTPClientConfig conf = new FTPClientConfig( FTPClientConfig.SYST_UNIX); + FTPClientConfig conf = new FTPClientConfig(FTPClientConfig.SYST_UNIX); ftpClient.configure(conf); //设置访问被动模式 ftpClient.setRemoteVerificationEnabled(false); @@ -177,10 +177,10 @@ public class FtpUtils { // logger.error("远程文件是文件夹"); // return null; // } - String fileDir = HchYunConfig.getDownloadPath()+sysFile.getFileName(); + String fileDir = HchYunConfig.getDownloadPath() + sysFile.getFileName(); OutputStream os = new FileOutputStream(fileDir); ftpClient.retrieveFile(sysFile.getMapping(), os); - return fileDir; + return fileDir; } catch (IOException e) { e.printStackTrace(); } finally { @@ -198,6 +198,7 @@ public class FtpUtils { /** * ftp删除文件 + * * @param sysFileList * @return */ @@ -216,7 +217,7 @@ public class FtpUtils { ftpClient.changeWorkingDirectory(basePathList[i]);//改变目录 } start = ftpClient.deleteFile(sysFile.getMapping()); - if (!start){ + if (!start) { return false; } } diff --git a/hchyun/hchyun-test/src/main/java/com/hchyun/test/MapExcelUtil.java b/hchyun/hchyun-test/src/main/java/com/hchyun/test/MapExcelUtil.java index a003041..b05aece 100644 --- a/hchyun/hchyun-test/src/main/java/com/hchyun/test/MapExcelUtil.java +++ b/hchyun/hchyun-test/src/main/java/com/hchyun/test/MapExcelUtil.java @@ -184,7 +184,7 @@ public class MapExcelUtil { int k = 0; for (String key : herders) { // 填充单元格的值 - this.addCell(row, key, i,k++); + this.addCell(row, key, i, k++); } } } @@ -192,7 +192,7 @@ public class MapExcelUtil { /** * 添加单元格 */ - public Cell addCell(Row row, String key, int column,Integer k) { + public Cell addCell(Row row, String key, int column, Integer k) { Cell cell = null; try { // 设置行高 diff --git a/hchyun/hchyun-test/src/main/java/com/hchyun/test/controller/AssFatherController.java b/hchyun/hchyun-test/src/main/java/com/hchyun/test/controller/AssFatherController.java index c4fae8c..c18c9f1 100644 --- a/hchyun/hchyun-test/src/main/java/com/hchyun/test/controller/AssFatherController.java +++ b/hchyun/hchyun-test/src/main/java/com/hchyun/test/controller/AssFatherController.java @@ -33,12 +33,12 @@ import org.springframework.validation.annotation.Validated; /** * 关联查询父Controller - * + * * @author hchyun * @date 2021-02-10 */ -@Api(value = "关联查询父管理",tags = "关联查询父管理") +@Api(value = "关联查询父管理", tags = "关联查询父管理") @RestController @RequestMapping("/test/father") public class AssFatherController extends HcyBaseController { @@ -78,7 +78,7 @@ public class AssFatherController extends HcyBaseController { public AjaxResult export(@Validated @RequestBody AssFather assFather) { try { ServerResult> serverResult = assFatherService.selectAssFatherList(assFather); - ExcelUtil util = new ExcelUtil(AssFather. class); + ExcelUtil util = new ExcelUtil(AssFather.class); if (serverResult.isStart()) { return util.exportExcel(serverResult.getData(), "father"); } else { @@ -94,7 +94,7 @@ public class AssFatherController extends HcyBaseController { * 获取关联查询父详细信息 */ @ApiOperation("获取关联查询父详细信息") - @ApiImplicitParam(name = "id" , value = "关联查询父id" , required = true, dataType = "Long" , paramType = "path") + @ApiImplicitParam(name = "id", value = "关联查询父id", required = true, dataType = "Long", paramType = "path") @PreAuthorize("@ss.hasPermi('test:father:query')") @GetMapping(value = "/{id}") public AjaxResult getInfo(@PathVariable("id") Long id) { @@ -115,7 +115,7 @@ public class AssFatherController extends HcyBaseController { * 新增关联查询父 */ @ApiOperation("新增关联查询父") - @ApiImplicitParam(name = "assFather" , value = "新增关联查询父信息" , dataType = "AssFather") + @ApiImplicitParam(name = "assFather", value = "新增关联查询父信息", dataType = "AssFather") @PreAuthorize("@ss.hasPermi('test:father:add')") @Log(title = "关联查询父", businessType = BusinessType.INSERT) @PostMapping @@ -143,7 +143,7 @@ public class AssFatherController extends HcyBaseController { * 修改关联查询父 */ @ApiOperation("修改关联查询父") - @ApiImplicitParam(name = "assFather" , value = "修改关联查询父信息" , dataType = "AssFather") + @ApiImplicitParam(name = "assFather", value = "修改关联查询父信息", dataType = "AssFather") @PreAuthorize("@ss.hasPermi('test:father:edit')") @Log(title = "关联查询父", businessType = BusinessType.UPDATE) @PutMapping @@ -172,13 +172,13 @@ public class AssFatherController extends HcyBaseController { * 删除关联查询父 */ @ApiOperation("删除关联查询父") - @ApiImplicitParam(name = "ids" , value = "关联查询父ids" , required = true, dataType = "Long" , paramType = "path") + @ApiImplicitParam(name = "ids", value = "关联查询父ids", required = true, dataType = "Long", paramType = "path") @PreAuthorize("@ss.hasPermi('test:father:remove')") @Log(title = "关联查询父", businessType = BusinessType.DELETE) - @DeleteMapping("/{ids}") + @DeleteMapping("/{ids}") public AjaxResult remove(@PathVariable Long[] ids) { try { - if (ids.length<0){ + if (ids.length < 0) { return AjaxResult.error("id不能为空!"); } ServerResult serverResult = assFatherService.deleteAssFatherByIds(ids); @@ -187,7 +187,7 @@ public class AssFatherController extends HcyBaseController { } else { return AjaxResult.error(serverResult.getMsg()); } - }catch (RuntimeException e){ + } catch (RuntimeException e) { logger.error(e.getMessage()); return AjaxResult.error(ReturnConstants.SYS_ERROR); } diff --git a/hchyun/hchyun-test/src/main/java/com/hchyun/test/controller/ResultsController.java b/hchyun/hchyun-test/src/main/java/com/hchyun/test/controller/ResultsController.java index aa0aeef..aa6c666 100644 --- a/hchyun/hchyun-test/src/main/java/com/hchyun/test/controller/ResultsController.java +++ b/hchyun/hchyun-test/src/main/java/com/hchyun/test/controller/ResultsController.java @@ -31,11 +31,11 @@ import com.hchyun.common.utils.poi.ExcelUtil; /** * 成绩Controller - * + * * @author hchyun * @date 2021-01-24 */ -@Api(value = "成绩管理",tags = "成绩管理") +@Api(value = "成绩管理", tags = "成绩管理") @RestController @RequestMapping("/test/results") public class ResultsController extends HcyBaseController { @@ -75,7 +75,7 @@ public class ResultsController extends HcyBaseController { public AjaxResult export(Results results) { try { ServerResult> serverResult = resultsService.selectResultsList(results); - ExcelUtil util = new ExcelUtil(Results. class); + ExcelUtil util = new ExcelUtil(Results.class); if (serverResult.isStart()) { return util.exportExcel(serverResult.getData(), "results"); } else { @@ -92,7 +92,7 @@ public class ResultsController extends HcyBaseController { * 获取成绩详细信息 */ @ApiOperation("获取成绩详细信息") - @ApiImplicitParam(name = "id" , value = "成绩id" , required = true, dataType = "Long" , paramType = "path") + @ApiImplicitParam(name = "id", value = "成绩id", required = true, dataType = "Long", paramType = "path") @PreAuthorize("@ss.hasPermi('test:results:query')") @GetMapping(value = "/{id}") public AjaxResult getInfo(@PathVariable("id") Long id) { @@ -113,12 +113,12 @@ public class ResultsController extends HcyBaseController { * 新增成绩 */ @ApiOperation("新增成绩") - @ApiImplicitParam(name = "results" , value = "新增成绩信息" , dataType = "Results") + @ApiImplicitParam(name = "results", value = "新增成绩信息", dataType = "Results") @PreAuthorize("@ss.hasPermi('test:results:add')") @Log(title = "成绩", businessType = BusinessType.INSERT) @PostMapping public AjaxResult add(@RequestBody Results results) { - if (results.getJava() == null || results.getJava()<0) { + if (results.getJava() == null || results.getJava() < 0) { return AjaxResult.error("java成绩不能为空!"); } if (results.getImages() == null || results.getImages().equals("")) { @@ -144,7 +144,7 @@ public class ResultsController extends HcyBaseController { * 修改成绩 */ @ApiOperation("修改成绩") - @ApiImplicitParam(name = "results" , value = "修改成绩信息" , dataType = "Results") + @ApiImplicitParam(name = "results", value = "修改成绩信息", dataType = "Results") @PreAuthorize("@ss.hasPermi('test:results:edit')") @Log(title = "成绩", businessType = BusinessType.UPDATE) @PutMapping @@ -152,7 +152,7 @@ public class ResultsController extends HcyBaseController { // public AjaxResult edit(@RequestBody Map map) { try { - if (results.getJava() == null || results.getJava()<0) { + if (results.getJava() == null || results.getJava() < 0) { return AjaxResult.error("java成绩不能为空!"); } if (results.getImages() == null || results.getImages().equals("")) { @@ -177,13 +177,13 @@ public class ResultsController extends HcyBaseController { * 删除成绩 */ @ApiOperation("删除成绩") - @ApiImplicitParam(name = "ids" , value = "成绩ids" , required = true, dataType = "Long" , paramType = "path") + @ApiImplicitParam(name = "ids", value = "成绩ids", required = true, dataType = "Long", paramType = "path") @PreAuthorize("@ss.hasPermi('test:results:remove')") @Log(title = "成绩", businessType = BusinessType.DELETE) - @DeleteMapping("/{ids}") + @DeleteMapping("/{ids}") public AjaxResult remove(@PathVariable Long[] ids) { try { - if (ids.length<0){ + if (ids.length < 0) { return AjaxResult.error("id不能为空!"); } ServerResult serverResult = resultsService.deleteResultsByIds(ids); @@ -192,7 +192,7 @@ public class ResultsController extends HcyBaseController { } else { return AjaxResult.error(serverResult.getMsg()); } - }catch (RuntimeException e){ + } catch (RuntimeException e) { logger.error(e.getMessage()); return AjaxResult.error(ReturnConstants.SYS_ERROR); } diff --git a/hchyun/hchyun-test/src/main/java/com/hchyun/test/controller/StuController.java b/hchyun/hchyun-test/src/main/java/com/hchyun/test/controller/StuController.java index 558264d..b5122a5 100644 --- a/hchyun/hchyun-test/src/main/java/com/hchyun/test/controller/StuController.java +++ b/hchyun/hchyun-test/src/main/java/com/hchyun/test/controller/StuController.java @@ -30,7 +30,7 @@ import com.hchyun.common.core.page.TableDataInfo; /** * 学生Controller - * + * * @author hchyun * @date 2021-01-23 */ @@ -71,7 +71,7 @@ public class StuController extends HcyBaseController { public AjaxResult export(Stu stu) { try { ServerResult> serverResult = stuService.selectStuList(stu); - ExcelUtil util = new ExcelUtil(Stu. class); + ExcelUtil util = new ExcelUtil(Stu.class); if (serverResult.isStart()) { return util.exportExcel(serverResult.getData(), "stu"); } else { @@ -112,16 +112,16 @@ public class StuController extends HcyBaseController { if (stu.getName() == null || stu.getName().equals("")) { return AjaxResult.error("学生姓名不能为空!"); } - if (stu.getTel() == null || stu.getTel()<0) { + if (stu.getTel() == null || stu.getTel() < 0) { return AjaxResult.error("电话不能为空!"); } - if (!Pattern.matches("^1[0-9]{10}$",String.valueOf(stu.getTel()))){ + if (!Pattern.matches("^1[0-9]{10}$", String.valueOf(stu.getTel()))) { return AjaxResult.error("电话格式错误!"); } if (stu.getEmail() == null || stu.getEmail().equals("")) { return AjaxResult.error("电子邮件不能为空!"); } - if (!Pattern.matches("^[A-Za-z0-9\u4e00-\u9fa5]+@[a-zA-Z0-9_-]+(\\.[a-zA-Z0-9_-]+)+$",stu.getEmail())){ + if (!Pattern.matches("^[A-Za-z0-9\u4e00-\u9fa5]+@[a-zA-Z0-9_-]+(\\.[a-zA-Z0-9_-]+)+$", stu.getEmail())) { return AjaxResult.error("电子邮件格式错误!"); } try { @@ -149,16 +149,16 @@ public class StuController extends HcyBaseController { if (stu.getName() == null || stu.getName().equals("")) { return AjaxResult.error("学生姓名不能为空!"); } - if (stu.getTel() == null || stu.getTel()<0) { + if (stu.getTel() == null || stu.getTel() < 0) { return AjaxResult.error("电话不能为空!"); } - if (!Pattern.matches("^1[0-9]{10}$",String.valueOf(stu.getTel()))){ + if (!Pattern.matches("^1[0-9]{10}$", String.valueOf(stu.getTel()))) { return AjaxResult.error("电话格式错误!"); } if (stu.getEmail() == null || stu.getEmail().equals("")) { return AjaxResult.error("电子邮件不能为空!"); } - if (!Pattern.matches("^[A-Za-z0-9\u4e00-\u9fa5]+@[a-zA-Z0-9_-]+(\\.[a-zA-Z0-9_-]+)+$",stu.getEmail())){ + if (!Pattern.matches("^[A-Za-z0-9\u4e00-\u9fa5]+@[a-zA-Z0-9_-]+(\\.[a-zA-Z0-9_-]+)+$", stu.getEmail())) { return AjaxResult.error("电子邮件格式错误!"); } ServerResult serverResult = stuService.updateStu(stu); @@ -178,10 +178,10 @@ public class StuController extends HcyBaseController { */ @PreAuthorize("@ss.hasPermi('test:stu:remove')") @Log(title = "学生", businessType = BusinessType.DELETE) - @DeleteMapping("/{ids}") + @DeleteMapping("/{ids}") public AjaxResult remove(@PathVariable Long[] ids) { try { - if (ids.length<0){ + if (ids.length < 0) { return AjaxResult.error("id不能为空!"); } ServerResult serverResult = stuService.deleteStuByIds(ids); @@ -190,7 +190,7 @@ public class StuController extends HcyBaseController { } else { return AjaxResult.error(serverResult.getMsg()); } - }catch (RuntimeException e){ + } catch (RuntimeException e) { logger.error(e.getMessage()); return AjaxResult.error(ReturnConstants.SYS_ERROR); } diff --git a/hchyun/hchyun-test/src/main/java/com/hchyun/test/controller/Test.java b/hchyun/hchyun-test/src/main/java/com/hchyun/test/controller/Test.java index 0d2b4c6..e89a70d 100644 --- a/hchyun/hchyun-test/src/main/java/com/hchyun/test/controller/Test.java +++ b/hchyun/hchyun-test/src/main/java/com/hchyun/test/controller/Test.java @@ -23,8 +23,8 @@ public class Test { private ResultsDao resultsDao; @GetMapping("/map") - public AjaxResult mapTest(){ + public AjaxResult mapTest() { MapExcelUtil util = new MapExcelUtil(); - return util.exportExcel(resultsDao.testMap(),"test"); + return util.exportExcel(resultsDao.testMap(), "test"); } } diff --git a/hchyun/hchyun-test/src/main/java/com/hchyun/test/controller/TestTreeController.java b/hchyun/hchyun-test/src/main/java/com/hchyun/test/controller/TestTreeController.java index 7cad1b9..fe2c72c 100644 --- a/hchyun/hchyun-test/src/main/java/com/hchyun/test/controller/TestTreeController.java +++ b/hchyun/hchyun-test/src/main/java/com/hchyun/test/controller/TestTreeController.java @@ -29,7 +29,7 @@ import com.hchyun.common.utils.poi.ExcelUtil; /** * 树测试Controller - * + * * @author hchyun * @date 2021-01-23 */ @@ -46,8 +46,7 @@ public class TestTreeController extends HcyBaseController { */ @PreAuthorize("@ss.hasPermi('test:tree:list')") @GetMapping("/list") - public AjaxResult list(TestTree testTree) - { + public AjaxResult list(TestTree testTree) { ServerResult> serverResult = testTreeService.selectTestTreeList(testTree); return AjaxResult.success(serverResult.getData()); } @@ -61,7 +60,7 @@ public class TestTreeController extends HcyBaseController { public AjaxResult export(TestTree testTree) { try { ServerResult> serverResult = testTreeService.selectTestTreeList(testTree); - ExcelUtil util = new ExcelUtil(TestTree. class); + ExcelUtil util = new ExcelUtil(TestTree.class); if (serverResult.isStart()) { return util.exportExcel(serverResult.getData(), "tree"); } else { @@ -144,10 +143,10 @@ public class TestTreeController extends HcyBaseController { */ @PreAuthorize("@ss.hasPermi('test:tree:remove')") @Log(title = "树测试", businessType = BusinessType.DELETE) - @DeleteMapping("/{ids}") + @DeleteMapping("/{ids}") public AjaxResult remove(@PathVariable Long[] ids) { try { - if (ids.length<0){ + if (ids.length < 0) { return AjaxResult.error("id不能为空!"); } ServerResult serverResult = testTreeService.deleteTestTreeByIds(ids); @@ -156,7 +155,7 @@ public class TestTreeController extends HcyBaseController { } else { return AjaxResult.error(serverResult.getMsg()); } - }catch (RuntimeException e){ + } catch (RuntimeException e) { logger.error(e.getMessage()); return AjaxResult.error(ReturnConstants.SYS_ERROR); } diff --git a/hchyun/hchyun-test/src/main/java/com/hchyun/test/dao/AssFatherDao.java b/hchyun/hchyun-test/src/main/java/com/hchyun/test/dao/AssFatherDao.java index 0102c52..d258dfa 100644 --- a/hchyun/hchyun-test/src/main/java/com/hchyun/test/dao/AssFatherDao.java +++ b/hchyun/hchyun-test/src/main/java/com/hchyun/test/dao/AssFatherDao.java @@ -1,18 +1,19 @@ package com.hchyun.test.dao; import java.util.List; + import com.hchyun.test.entity.AssFather; /** * 关联查询父Mapper接口 - * + * * @author hchyun * @date 2021-02-10 */ public interface AssFatherDao { /** * 查询关联查询父 - * + * * @param id 关联查询父ID * @return 关联查询父 */ @@ -20,7 +21,7 @@ public interface AssFatherDao { /** * 查询关联查询父列表 - * + * * @param assFather 关联查询父 * @return 关联查询父集合 */ @@ -28,7 +29,7 @@ public interface AssFatherDao { /** * 新增关联查询父 - * + * * @param assFather 关联查询父 * @return 结果 */ @@ -36,7 +37,7 @@ public interface AssFatherDao { /** * 修改关联查询父 - * + * * @param assFather 关联查询父 * @return 结果 */ @@ -44,7 +45,7 @@ public interface AssFatherDao { /** * 删除关联查询父 - * + * * @param id 关联查询父ID * @return 结果 */ @@ -52,7 +53,7 @@ public interface AssFatherDao { /** * 批量删除关联查询父 - * + * * @param ids 需要删除的数据ID * @return 结果 */ diff --git a/hchyun/hchyun-test/src/main/java/com/hchyun/test/dao/ResultsDao.java b/hchyun/hchyun-test/src/main/java/com/hchyun/test/dao/ResultsDao.java index 4276556..99c47fe 100644 --- a/hchyun/hchyun-test/src/main/java/com/hchyun/test/dao/ResultsDao.java +++ b/hchyun/hchyun-test/src/main/java/com/hchyun/test/dao/ResultsDao.java @@ -60,5 +60,5 @@ public interface ResultsDao { */ public int deleteResultsByIds(Long[] ids); - List> testMap(); + List> testMap(); } diff --git a/hchyun/hchyun-test/src/main/java/com/hchyun/test/dao/StuDao.java b/hchyun/hchyun-test/src/main/java/com/hchyun/test/dao/StuDao.java index a822be0..93bd789 100644 --- a/hchyun/hchyun-test/src/main/java/com/hchyun/test/dao/StuDao.java +++ b/hchyun/hchyun-test/src/main/java/com/hchyun/test/dao/StuDao.java @@ -1,20 +1,20 @@ package com.hchyun.test.dao; import java.util.List; + import com.hchyun.test.entity.Stu; import com.hchyun.test.entity.Results; /** * 学生Mapper接口 - * + * * @author hchyun * @date 2021-01-23 */ -public interface StuDao -{ +public interface StuDao { /** * 查询学生 - * + * * @param id 学生ID * @return 学生 */ @@ -22,7 +22,7 @@ public interface StuDao /** * 查询学生列表 - * + * * @param stu 学生 * @return 学生集合 */ @@ -30,7 +30,7 @@ public interface StuDao /** * 新增学生 - * + * * @param stu 学生 * @return 结果 */ @@ -38,7 +38,7 @@ public interface StuDao /** * 修改学生 - * + * * @param stu 学生 * @return 结果 */ @@ -46,7 +46,7 @@ public interface StuDao /** * 删除学生 - * + * * @param id 学生ID * @return 结果 */ @@ -54,7 +54,7 @@ public interface StuDao /** * 批量删除学生 - * + * * @param ids 需要删除的数据ID * @return 结果 */ @@ -62,24 +62,24 @@ public interface StuDao /** * 批量删除成绩 - * + * * @param customerIds 需要删除的数据ID * @return 结果 */ int deleteResultsBySIds(Long[] ids); - + /** * 批量新增成绩 - * + * * @param resultsList 成绩列表 * @return 结果 */ int batchResults(List resultsList); - + /** * 通过学生ID删除成绩信息 - * + * * @param roleId 角色ID * @return 结果 */ diff --git a/hchyun/hchyun-test/src/main/java/com/hchyun/test/dao/TestTreeDao.java b/hchyun/hchyun-test/src/main/java/com/hchyun/test/dao/TestTreeDao.java index 72a312c..6c3069c 100644 --- a/hchyun/hchyun-test/src/main/java/com/hchyun/test/dao/TestTreeDao.java +++ b/hchyun/hchyun-test/src/main/java/com/hchyun/test/dao/TestTreeDao.java @@ -1,19 +1,19 @@ package com.hchyun.test.dao; import java.util.List; + import com.hchyun.test.entity.TestTree; /** * 树测试Mapper接口 - * + * * @author hchyun * @date 2021-01-23 */ -public interface TestTreeDao -{ +public interface TestTreeDao { /** * 查询树测试 - * + * * @param id 树测试ID * @return 树测试 */ @@ -21,7 +21,7 @@ public interface TestTreeDao /** * 查询树测试列表 - * + * * @param testTree 树测试 * @return 树测试集合 */ @@ -29,7 +29,7 @@ public interface TestTreeDao /** * 新增树测试 - * + * * @param testTree 树测试 * @return 结果 */ @@ -37,7 +37,7 @@ public interface TestTreeDao /** * 修改树测试 - * + * * @param testTree 树测试 * @return 结果 */ @@ -45,7 +45,7 @@ public interface TestTreeDao /** * 删除树测试 - * + * * @param id 树测试ID * @return 结果 */ @@ -53,7 +53,7 @@ public interface TestTreeDao /** * 批量删除树测试 - * + * * @param ids 需要删除的数据ID * @return 结果 */ diff --git a/hchyun/hchyun-test/src/main/java/com/hchyun/test/entity/AssFather.java b/hchyun/hchyun-test/src/main/java/com/hchyun/test/entity/AssFather.java index 31d1af6..33968b8 100644 --- a/hchyun/hchyun-test/src/main/java/com/hchyun/test/entity/AssFather.java +++ b/hchyun/hchyun-test/src/main/java/com/hchyun/test/entity/AssFather.java @@ -10,69 +10,76 @@ import org.apache.commons.lang3.builder.ToStringStyle; /** * 关联查询父对象 test_ass_father - * + * * @author hchyun * @date 2021-02-10 */ @ApiModel("关联查询父") -public class AssFather extends BaseEntity -{ +public class AssFather extends BaseEntity { private static final long serialVersionUID = 1L; - /** 主键 */ + /** + * 主键 + */ @ApiModelProperty("主键") private Long id; - /** 名称 */ + /** + * 名称 + */ @Excel(name = "名称") @ApiModelProperty("名称") private String name; - /** 信息 */ + /** + * 信息 + */ @Excel(name = "信息") @ApiModelProperty("信息") private String info; - @Excels({@Excel(name = "子表名称",targetAttr = "sname"),@Excel(name = "父id",targetAttr = "fId")}) + @Excels({@Excel(name = "子表名称", targetAttr = "sname"), @Excel(name = "父id", targetAttr = "fId")}) private AssSun assSun; - public void setId(Long id){ + public void setId(Long id) { this.id = id; } - public Long getId(){ + public Long getId() { return id; } - public void setName(String name){ + + public void setName(String name) { this.name = name; } - public String getName(){ + public String getName() { return name; } - public void setInfo(String info){ + + public void setInfo(String info) { this.info = info; } - public String getInfo(){ + public String getInfo() { return info; } - public AssSun getAssSun(){ + public AssSun getAssSun() { return assSun; } - public void setAssSun(AssSun assSun){ + public void setAssSun(AssSun assSun) { this.assSun = assSun; } @Override public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("id", getId()) - .append("name", getName()) - .append("info", getInfo()) - .append("createTime", getCreateTime()) - .toString(); + return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("name", getName()) + .append("info", getInfo()) + .append("createTime", getCreateTime()) + .toString(); } } diff --git a/hchyun/hchyun-test/src/main/java/com/hchyun/test/entity/AssSun.java b/hchyun/hchyun-test/src/main/java/com/hchyun/test/entity/AssSun.java index 8e2ffe6..328f424 100644 --- a/hchyun/hchyun-test/src/main/java/com/hchyun/test/entity/AssSun.java +++ b/hchyun/hchyun-test/src/main/java/com/hchyun/test/entity/AssSun.java @@ -4,45 +4,52 @@ import com.hchyun.common.annotation.Excel; import com.hchyun.common.core.entity.BaseEntity; /** - * * @author hchyun * @date 2021-02-10 */ -public class AssSun extends BaseEntity{ +public class AssSun extends BaseEntity { - /** 主键 */ + /** + * 主键 + */ @Excel(name = "主键") private Long id; - /** 父id */ + /** + * 父id + */ @Excel(name = "父id") private Long fId; - /** 名称 */ + /** + * 名称 + */ @Excel(name = "名称") private String sname; - public void setId(Long id){ + public void setId(Long id) { this.id = id; } - public Long getId(){ + public Long getId() { return id; } - public void setfId(Long fId){ + + public void setfId(Long fId) { this.fId = fId; } - public Long getfId(){ + public Long getfId() { return fId; } - public void setSname(String sname){ + + public void setSname(String sname) { this.sname = sname; } - public String getSname(){ + public String getSname() { return sname; } } \ No newline at end of file diff --git a/hchyun/hchyun-test/src/main/java/com/hchyun/test/entity/Results.java b/hchyun/hchyun-test/src/main/java/com/hchyun/test/entity/Results.java index 753fe37..50e6c78 100644 --- a/hchyun/hchyun-test/src/main/java/com/hchyun/test/entity/Results.java +++ b/hchyun/hchyun-test/src/main/java/com/hchyun/test/entity/Results.java @@ -9,93 +9,96 @@ import org.apache.commons.lang3.builder.ToStringStyle; /** * 成绩对象 sys_results - * + * * @author hchyun * @date 2021-01-24 */ @ApiModel("成绩") -public class Results extends BaseEntity -{ +public class Results extends BaseEntity { - /** id */ + /** + * id + */ @ApiModelProperty("id") private Long id; - /** 学生id */ + /** + * 学生id + */ @Excel(name = "学生id") @ApiModelProperty("学生id") private Long sId; - /** java成绩 */ + /** + * java成绩 + */ @Excel(name = "java成绩") @ApiModelProperty("java成绩") private Long java; - /** 图片路径 */ + /** + * 图片路径 + */ @Excel(name = "图片路径") @ApiModelProperty("图片路径") private String images; - /** 文件路径 */ + /** + * 文件路径 + */ @Excel(name = "文件路径") @ApiModelProperty("文件路径") private String file; - public void setId(Long id) - { + public void setId(Long id) { this.id = id; } - public Long getId() - { + public Long getId() { return id; } - public void setsId(Long sId) - { + + public void setsId(Long sId) { this.sId = sId; } - public Long getsId() - { + public Long getsId() { return sId; } - public void setJava(Long java) - { + + public void setJava(Long java) { this.java = java; } - public Long getJava() - { + public Long getJava() { return java; } - public void setImages(String images) - { + + public void setImages(String images) { this.images = images; } - public String getImages() - { + public String getImages() { return images; } - public void setFile(String file) - { + + public void setFile(String file) { this.file = file; } - public String getFile() - { + public String getFile() { return file; } @Override public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("id", getId()) - .append("sId", getsId()) - .append("java", getJava()) - .append("images", getImages()) - .append("file", getFile()) - .toString(); + return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("sId", getsId()) + .append("java", getJava()) + .append("images", getImages()) + .append("file", getFile()) + .toString(); } } diff --git a/hchyun/hchyun-test/src/main/java/com/hchyun/test/entity/Stu.java b/hchyun/hchyun-test/src/main/java/com/hchyun/test/entity/Stu.java index ab5b546..a6a541d 100644 --- a/hchyun/hchyun-test/src/main/java/com/hchyun/test/entity/Stu.java +++ b/hchyun/hchyun-test/src/main/java/com/hchyun/test/entity/Stu.java @@ -1,6 +1,7 @@ package com.hchyun.test.entity; import java.util.List; + import com.hchyun.common.annotation.Excel; import com.hchyun.common.core.entity.BaseEntity; import org.apache.commons.lang3.builder.ToStringBuilder; @@ -8,91 +9,93 @@ import org.apache.commons.lang3.builder.ToStringStyle; /** * 学生对象 sys_stu - * + * * @author hchyun * @date 2021-01-23 */ -public class Stu extends BaseEntity -{ +public class Stu extends BaseEntity { - /** id */ + /** + * id + */ private Long id; - /** 学生姓名 */ + /** + * 学生姓名 + */ @Excel(name = "学生姓名") private String name; - /** 电话 */ + /** + * 电话 + */ @Excel(name = "电话") private Long tel; - /** 电子邮件 */ + /** + * 电子邮件 + */ @Excel(name = "电子邮件") private String email; - /** 成绩信息 */ + /** + * 成绩信息 + */ private List resultsList; - public void setId(Long id) - { + public void setId(Long id) { this.id = id; } - public Long getId() - { + public Long getId() { return id; } - public void setName(String name) - { + + public void setName(String name) { this.name = name; } - public String getName() - { + public String getName() { return name; } - public void setTel(Long tel) - { + + public void setTel(Long tel) { this.tel = tel; } - public Long getTel() - { + public Long getTel() { return tel; } - public void setEmail(String email) - { + + public void setEmail(String email) { this.email = email; } - public String getEmail() - { + public String getEmail() { return email; } - public List getResultsList() - { + public List getResultsList() { return resultsList; } - public void setResultsList(List resultsList) - { + public void setResultsList(List resultsList) { this.resultsList = resultsList; } @Override public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("id", getId()) - .append("name", getName()) - .append("tel", getTel()) - .append("email", getEmail()) - .append("createTime", getCreateTime()) - .append("createBy", getCreateBy()) - .append("updateTime", getUpdateTime()) - .append("updateBy", getUpdateBy()) - .append("resultsList", getResultsList()) - .toString(); + return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("name", getName()) + .append("tel", getTel()) + .append("email", getEmail()) + .append("createTime", getCreateTime()) + .append("createBy", getCreateBy()) + .append("updateTime", getUpdateTime()) + .append("updateBy", getUpdateBy()) + .append("resultsList", getResultsList()) + .toString(); } } diff --git a/hchyun/hchyun-test/src/main/java/com/hchyun/test/entity/TestTree.java b/hchyun/hchyun-test/src/main/java/com/hchyun/test/entity/TestTree.java index aa95585..e256ae6 100644 --- a/hchyun/hchyun-test/src/main/java/com/hchyun/test/entity/TestTree.java +++ b/hchyun/hchyun-test/src/main/java/com/hchyun/test/entity/TestTree.java @@ -7,58 +7,59 @@ import org.apache.commons.lang3.builder.ToStringStyle; /** * 树测试对象 test_tree - * + * * @author hchyun * @date 2021-01-23 */ -public class TestTree extends TreeEntity -{ +public class TestTree extends TreeEntity { - /** 主键id */ + /** + * 主键id + */ private Long id; - /** 父id */ + /** + * 父id + */ private Long pId; - /** 内容 */ + /** + * 内容 + */ @Excel(name = "内容") private String content; - public void setId(Long id) - { + public void setId(Long id) { this.id = id; } - public Long getId() - { + public Long getId() { return id; } - public void setpId(Long pId) - { + + public void setpId(Long pId) { this.pId = pId; } - public Long getpId() - { + public Long getpId() { return pId; } - public void setContent(String content) - { + + public void setContent(String content) { this.content = content; } - public String getContent() - { + public String getContent() { return content; } @Override public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("id", getId()) - .append("pId", getpId()) - .append("content", getContent()) - .toString(); + return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("pId", getpId()) + .append("content", getContent()) + .toString(); } } diff --git a/hchyun/hchyun-test/src/main/java/com/hchyun/test/service/AssFatherService.java b/hchyun/hchyun-test/src/main/java/com/hchyun/test/service/AssFatherService.java index ba4c9b5..f2b2f92 100644 --- a/hchyun/hchyun-test/src/main/java/com/hchyun/test/service/AssFatherService.java +++ b/hchyun/hchyun-test/src/main/java/com/hchyun/test/service/AssFatherService.java @@ -7,15 +7,14 @@ import com.hchyun.test.entity.AssFather; /** * 关联查询父Service接口 - * + * * @author hchyun * @date 2021-02-10 */ -public interface AssFatherService -{ +public interface AssFatherService { /** * 查询关联查询父 - * + * * @param id 关联查询父ID * @return 关联查询父 */ @@ -23,7 +22,7 @@ public interface AssFatherService /** * 查询关联查询父列表 - * + * * @param assFather 关联查询父 * @return 关联查询父集合 */ @@ -31,7 +30,7 @@ public interface AssFatherService /** * 新增关联查询父 - * + * * @param assFather 关联查询父 * @return 结果 */ @@ -39,7 +38,7 @@ public interface AssFatherService /** * 修改关联查询父 - * + * * @param assFather 关联查询父 * @return 结果 */ @@ -47,7 +46,7 @@ public interface AssFatherService /** * 批量删除关联查询父 - * + * * @param ids 需要删除的关联查询父ID * @return 结果 */ @@ -55,7 +54,7 @@ public interface AssFatherService /** * 删除关联查询父信息 - * + * * @param id 关联查询父ID * @return 结果 */ diff --git a/hchyun/hchyun-test/src/main/java/com/hchyun/test/service/ResultsService.java b/hchyun/hchyun-test/src/main/java/com/hchyun/test/service/ResultsService.java index 19faa87..6b3ca30 100644 --- a/hchyun/hchyun-test/src/main/java/com/hchyun/test/service/ResultsService.java +++ b/hchyun/hchyun-test/src/main/java/com/hchyun/test/service/ResultsService.java @@ -7,15 +7,14 @@ import com.hchyun.test.entity.Results; /** * 成绩Service接口 - * + * * @author hchyun * @date 2021-01-24 */ -public interface ResultsService -{ +public interface ResultsService { /** * 查询成绩 - * + * * @param id 成绩ID * @return 成绩 */ @@ -23,7 +22,7 @@ public interface ResultsService /** * 查询成绩列表 - * + * * @param results 成绩 * @return 成绩集合 */ @@ -31,7 +30,7 @@ public interface ResultsService /** * 新增成绩 - * + * * @param results 成绩 * @return 结果 */ @@ -39,7 +38,7 @@ public interface ResultsService /** * 修改成绩 - * + * * @param results 成绩 * @return 结果 */ @@ -47,7 +46,7 @@ public interface ResultsService /** * 批量删除成绩 - * + * * @param ids 需要删除的成绩ID * @return 结果 */ @@ -55,7 +54,7 @@ public interface ResultsService /** * 删除成绩信息 - * + * * @param id 成绩ID * @return 结果 */ diff --git a/hchyun/hchyun-test/src/main/java/com/hchyun/test/service/StuService.java b/hchyun/hchyun-test/src/main/java/com/hchyun/test/service/StuService.java index 6814929..7075d64 100644 --- a/hchyun/hchyun-test/src/main/java/com/hchyun/test/service/StuService.java +++ b/hchyun/hchyun-test/src/main/java/com/hchyun/test/service/StuService.java @@ -7,15 +7,14 @@ import com.hchyun.test.entity.Stu; /** * 学生Service接口 - * + * * @author hchyun * @date 2021-01-23 */ -public interface StuService -{ +public interface StuService { /** * 查询学生 - * + * * @param id 学生ID * @return 学生 */ @@ -23,7 +22,7 @@ public interface StuService /** * 查询学生列表 - * + * * @param stu 学生 * @return 学生集合 */ @@ -31,7 +30,7 @@ public interface StuService /** * 新增学生 - * + * * @param stu 学生 * @return 结果 */ @@ -39,7 +38,7 @@ public interface StuService /** * 修改学生 - * + * * @param stu 学生 * @return 结果 */ @@ -47,7 +46,7 @@ public interface StuService /** * 批量删除学生 - * + * * @param ids 需要删除的学生ID * @return 结果 */ @@ -55,7 +54,7 @@ public interface StuService /** * 删除学生信息 - * + * * @param id 学生ID * @return 结果 */ diff --git a/hchyun/hchyun-test/src/main/java/com/hchyun/test/service/TestTreeService.java b/hchyun/hchyun-test/src/main/java/com/hchyun/test/service/TestTreeService.java index df2b9e7..82416cf 100644 --- a/hchyun/hchyun-test/src/main/java/com/hchyun/test/service/TestTreeService.java +++ b/hchyun/hchyun-test/src/main/java/com/hchyun/test/service/TestTreeService.java @@ -7,15 +7,14 @@ import com.hchyun.test.entity.TestTree; /** * 树测试Service接口 - * + * * @author hchyun * @date 2021-01-23 */ -public interface TestTreeService -{ +public interface TestTreeService { /** * 查询树测试 - * + * * @param id 树测试ID * @return 树测试 */ @@ -23,7 +22,7 @@ public interface TestTreeService /** * 查询树测试列表 - * + * * @param testTree 树测试 * @return 树测试集合 */ @@ -31,7 +30,7 @@ public interface TestTreeService /** * 新增树测试 - * + * * @param testTree 树测试 * @return 结果 */ @@ -39,7 +38,7 @@ public interface TestTreeService /** * 修改树测试 - * + * * @param testTree 树测试 * @return 结果 */ @@ -47,7 +46,7 @@ public interface TestTreeService /** * 批量删除树测试 - * + * * @param ids 需要删除的树测试ID * @return 结果 */ @@ -55,7 +54,7 @@ public interface TestTreeService /** * 删除树测试信息 - * + * * @param id 树测试ID * @return 结果 */ diff --git a/hchyun/hchyun-test/src/main/java/com/hchyun/test/service/impl/AssFatherServiceImpl.java b/hchyun/hchyun-test/src/main/java/com/hchyun/test/service/impl/AssFatherServiceImpl.java index d87410e..7617fc9 100644 --- a/hchyun/hchyun-test/src/main/java/com/hchyun/test/service/impl/AssFatherServiceImpl.java +++ b/hchyun/hchyun-test/src/main/java/com/hchyun/test/service/impl/AssFatherServiceImpl.java @@ -15,7 +15,7 @@ import com.hchyun.test.service.AssFatherService; /** * 关联查询父Service业务层处理 - * + * * @author hchyun * @date 2021-02-10 */ @@ -28,7 +28,7 @@ public class AssFatherServiceImpl implements AssFatherService { /** * 查询关联查询父 - * + * * @param id 关联查询父ID * @return 关联查询父 */ @@ -36,20 +36,20 @@ public class AssFatherServiceImpl implements AssFatherService { public ServerResult selectAssFatherById(Long id) { try { AssFather assFather = assFatherDao.selectAssFatherById(id); - if (assFather != null){ - return new ServerResult(true,assFather); - }else { + if (assFather != null) { + return new ServerResult(true, assFather); + } else { return new ServerResult(false, ReturnConstants.RESULT_EMPTY); } - }catch (RuntimeException e){ + } catch (RuntimeException e) { logger.error(e.getMessage()); - return new ServerResult(false,ReturnConstants.DB_EX); + return new ServerResult(false, ReturnConstants.DB_EX); } } /** * 查询关联查询父列表 - * + * * @param assFather 关联查询父 * @return 关联查询父 */ @@ -57,20 +57,20 @@ public class AssFatherServiceImpl implements AssFatherService { public ServerResult> selectAssFatherList(AssFather assFather) { try { List assFatherList = assFatherDao.selectAssFatherList(assFather); - if (assFatherList.size()>0){ - return new ServerResult>(true,assFatherList); - }else { - return new ServerResult>(false,ReturnConstants.RESULT_EMPTY); + if (assFatherList.size() > 0) { + return new ServerResult>(true, assFatherList); + } else { + return new ServerResult>(false, ReturnConstants.RESULT_EMPTY); } - }catch (RuntimeException e){ + } catch (RuntimeException e) { logger.error(e.getMessage()); - return new ServerResult>(false,ReturnConstants.DB_EX); + return new ServerResult>(false, ReturnConstants.DB_EX); } } /** * 新增关联查询父 - * + * * @param assFather 关联查询父 * @return 结果 */ @@ -78,20 +78,20 @@ public class AssFatherServiceImpl implements AssFatherService { public ServerResult insertAssFather(AssFather assFather) { try { Integer renewal = assFatherDao.insertAssFather(assFather); - if (renewal >0){ - return new ServerResult(true,renewal); - }else { - return new ServerResult(false,ReturnConstants.SYS_FAILL); + if (renewal > 0) { + return new ServerResult(true, renewal); + } else { + return new ServerResult(false, ReturnConstants.SYS_FAILL); } - }catch (RuntimeException e){ + } catch (RuntimeException e) { logger.error(e.getMessage()); - return new ServerResult(false,ReturnConstants.DB_EX); + return new ServerResult(false, ReturnConstants.DB_EX); } } /** * 修改关联查询父 - * + * * @param assFather 关联查询父 * @return 结果 */ @@ -99,20 +99,20 @@ public class AssFatherServiceImpl implements AssFatherService { public ServerResult updateAssFather(AssFather assFather) { try { Integer renewal = assFatherDao.updateAssFather(assFather); - if (renewal >0){ - return new ServerResult(true,renewal); - }else { - return new ServerResult(false,ReturnConstants.SYS_FAILL); + if (renewal > 0) { + return new ServerResult(true, renewal); + } else { + return new ServerResult(false, ReturnConstants.SYS_FAILL); } - }catch (RuntimeException e){ + } catch (RuntimeException e) { logger.error(e.getMessage()); - return new ServerResult(false,ReturnConstants.DB_EX); + return new ServerResult(false, ReturnConstants.DB_EX); } } /** * 批量删除关联查询父 - * + * * @param ids 需要删除的关联查询父ID * @return 结果 */ @@ -120,20 +120,20 @@ public class AssFatherServiceImpl implements AssFatherService { public ServerResult deleteAssFatherByIds(Long[] ids) { try { Integer renewal = assFatherDao.deleteAssFatherByIds(ids); - if (renewal >0){ - return new ServerResult(true,renewal); - }else { - return new ServerResult(false,ReturnConstants.SYS_FAILL); + if (renewal > 0) { + return new ServerResult(true, renewal); + } else { + return new ServerResult(false, ReturnConstants.SYS_FAILL); } - }catch (RuntimeException e){ + } catch (RuntimeException e) { logger.error(e.getMessage()); - return new ServerResult(false,ReturnConstants.DB_EX); + return new ServerResult(false, ReturnConstants.DB_EX); } } /** * 删除关联查询父信息 - * + * * @param id 关联查询父ID * @return 结果 */ @@ -141,14 +141,14 @@ public class AssFatherServiceImpl implements AssFatherService { public ServerResult deleteAssFatherById(Long id) { try { Integer renewal = assFatherDao.deleteAssFatherById(id); - if (renewal >0){ - return new ServerResult(true,renewal); - }else { - return new ServerResult(false,ReturnConstants.SYS_FAILL); + if (renewal > 0) { + return new ServerResult(true, renewal); + } else { + return new ServerResult(false, ReturnConstants.SYS_FAILL); } - }catch (RuntimeException e){ + } catch (RuntimeException e) { logger.error(e.getMessage()); - return new ServerResult(false,ReturnConstants.DB_EX); + return new ServerResult(false, ReturnConstants.DB_EX); } } } diff --git a/hchyun/hchyun-test/src/main/java/com/hchyun/test/service/impl/ResultsServiceImpl.java b/hchyun/hchyun-test/src/main/java/com/hchyun/test/service/impl/ResultsServiceImpl.java index 68deaf3..1f6b4fa 100644 --- a/hchyun/hchyun-test/src/main/java/com/hchyun/test/service/impl/ResultsServiceImpl.java +++ b/hchyun/hchyun-test/src/main/java/com/hchyun/test/service/impl/ResultsServiceImpl.java @@ -14,7 +14,7 @@ import com.hchyun.test.service.ResultsService; /** * 成绩Service业务层处理 - * + * * @author hchyun * @date 2021-01-24 */ @@ -27,7 +27,7 @@ public class ResultsServiceImpl implements ResultsService { /** * 查询成绩 - * + * * @param id 成绩ID * @return 成绩 */ @@ -35,20 +35,20 @@ public class ResultsServiceImpl implements ResultsService { public ServerResult selectResultsById(Long id) { try { Results results = resultsDao.selectResultsById(id); - if (results != null){ - return new ServerResult(true,results); - }else { + if (results != null) { + return new ServerResult(true, results); + } else { return new ServerResult(false, ReturnConstants.RESULT_EMPTY); } - }catch (RuntimeException e){ + } catch (RuntimeException e) { logger.error(e.getMessage()); - return new ServerResult(false,ReturnConstants.DB_EX); + return new ServerResult(false, ReturnConstants.DB_EX); } } /** * 查询成绩列表 - * + * * @param results 成绩 * @return 成绩 */ @@ -56,20 +56,20 @@ public class ResultsServiceImpl implements ResultsService { public ServerResult> selectResultsList(Results results) { try { List resultsList = resultsDao.selectResultsList(results); - if (resultsList.size()>0){ - return new ServerResult>(true,resultsList); - }else { - return new ServerResult>(false,ReturnConstants.RESULT_EMPTY); + if (resultsList.size() > 0) { + return new ServerResult>(true, resultsList); + } else { + return new ServerResult>(false, ReturnConstants.RESULT_EMPTY); } - }catch (RuntimeException e){ + } catch (RuntimeException e) { logger.error(e.getMessage()); - return new ServerResult>(false,ReturnConstants.DB_EX); + return new ServerResult>(false, ReturnConstants.DB_EX); } } /** * 新增成绩 - * + * * @param results 成绩 * @return 结果 */ @@ -77,20 +77,20 @@ public class ResultsServiceImpl implements ResultsService { public ServerResult insertResults(Results results) { try { Integer renewal = resultsDao.insertResults(results); - if (renewal >0){ - return new ServerResult(true,renewal); - }else { - return new ServerResult(false,ReturnConstants.SYS_FAILL); + if (renewal > 0) { + return new ServerResult(true, renewal); + } else { + return new ServerResult(false, ReturnConstants.SYS_FAILL); } - }catch (RuntimeException e){ + } catch (RuntimeException e) { logger.error(e.getMessage()); - return new ServerResult(false,ReturnConstants.DB_EX); + return new ServerResult(false, ReturnConstants.DB_EX); } } /** * 修改成绩 - * + * * @param results 成绩 * @return 结果 */ @@ -98,20 +98,20 @@ public class ResultsServiceImpl implements ResultsService { public ServerResult updateResults(Results results) { try { Integer renewal = resultsDao.updateResults(results); - if (renewal >0){ - return new ServerResult(true,renewal); - }else { - return new ServerResult(false,ReturnConstants.SYS_FAILL); + if (renewal > 0) { + return new ServerResult(true, renewal); + } else { + return new ServerResult(false, ReturnConstants.SYS_FAILL); } - }catch (RuntimeException e){ + } catch (RuntimeException e) { logger.error(e.getMessage()); - return new ServerResult(false,ReturnConstants.DB_EX); + return new ServerResult(false, ReturnConstants.DB_EX); } } /** * 批量删除成绩 - * + * * @param ids 需要删除的成绩ID * @return 结果 */ @@ -119,20 +119,20 @@ public class ResultsServiceImpl implements ResultsService { public ServerResult deleteResultsByIds(Long[] ids) { try { Integer renewal = resultsDao.deleteResultsByIds(ids); - if (renewal >0){ - return new ServerResult(true,renewal); - }else { - return new ServerResult(false,ReturnConstants.SYS_FAILL); + if (renewal > 0) { + return new ServerResult(true, renewal); + } else { + return new ServerResult(false, ReturnConstants.SYS_FAILL); } - }catch (RuntimeException e){ + } catch (RuntimeException e) { logger.error(e.getMessage()); - return new ServerResult(false,ReturnConstants.DB_EX); + return new ServerResult(false, ReturnConstants.DB_EX); } } /** * 删除成绩信息 - * + * * @param id 成绩ID * @return 结果 */ @@ -140,14 +140,14 @@ public class ResultsServiceImpl implements ResultsService { public ServerResult deleteResultsById(Long id) { try { Integer renewal = resultsDao.deleteResultsById(id); - if (renewal >0){ - return new ServerResult(true,renewal); - }else { - return new ServerResult(false,ReturnConstants.SYS_FAILL); + if (renewal > 0) { + return new ServerResult(true, renewal); + } else { + return new ServerResult(false, ReturnConstants.SYS_FAILL); } - }catch (RuntimeException e){ + } catch (RuntimeException e) { logger.error(e.getMessage()); - return new ServerResult(false,ReturnConstants.DB_EX); + return new ServerResult(false, ReturnConstants.DB_EX); } } } diff --git a/hchyun/hchyun-test/src/main/java/com/hchyun/test/service/impl/StuServiceImpl.java b/hchyun/hchyun-test/src/main/java/com/hchyun/test/service/impl/StuServiceImpl.java index 62155ae..97944e0 100644 --- a/hchyun/hchyun-test/src/main/java/com/hchyun/test/service/impl/StuServiceImpl.java +++ b/hchyun/hchyun-test/src/main/java/com/hchyun/test/service/impl/StuServiceImpl.java @@ -10,7 +10,9 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; + import java.util.ArrayList; + import com.hchyun.common.utils.StringUtils; import org.springframework.transaction.annotation.Transactional; import com.hchyun.test.entity.Results; @@ -21,7 +23,7 @@ import org.springframework.transaction.interceptor.TransactionAspectSupport; /** * 学生Service业务层处理 - * + * * @author hchyun * @date 2021-01-23 */ @@ -34,7 +36,7 @@ public class StuServiceImpl implements StuService { /** * 查询学生 - * + * * @param id 学生ID * @return 学生 */ @@ -42,20 +44,20 @@ public class StuServiceImpl implements StuService { public ServerResult selectStuById(Long id) { try { Stu stu = stuDao.selectStuById(id); - if (stu != null){ - return new ServerResult(true,stu); - }else { + if (stu != null) { + return new ServerResult(true, stu); + } else { return new ServerResult(false, ReturnConstants.RESULT_EMPTY); } - }catch (RuntimeException e){ + } catch (RuntimeException e) { logger.error(e.getMessage()); - return new ServerResult(false,ReturnConstants.DB_EX); + return new ServerResult(false, ReturnConstants.DB_EX); } } /** * 查询学生列表 - * + * * @param stu 学生 * @return 学生 */ @@ -63,20 +65,20 @@ public class StuServiceImpl implements StuService { public ServerResult> selectStuList(Stu stu) { try { List stuList = stuDao.selectStuList(stu); - if (stuList.size()>0){ - return new ServerResult>(true,stuList); - }else { - return new ServerResult>(false,ReturnConstants.RESULT_EMPTY); + if (stuList.size() > 0) { + return new ServerResult>(true, stuList); + } else { + return new ServerResult>(false, ReturnConstants.RESULT_EMPTY); } - }catch (RuntimeException e){ + } catch (RuntimeException e) { logger.error(e.getMessage()); - return new ServerResult>(false,ReturnConstants.DB_EX); + return new ServerResult>(false, ReturnConstants.DB_EX); } } /** * 新增学生 - * + * * @param stu 学生 * @return 结果 */ @@ -87,24 +89,24 @@ public class StuServiceImpl implements StuService { stu.setCreateTime(DateUtils.getNowDate()); stu.setCreateBy(SecurityUtils.getUserId()); int renewal = stuDao.insertStu(stu); - if (insertResults(stu)){ - return new ServerResult(false,ReturnConstants.DB_EX); + if (insertResults(stu)) { + return new ServerResult(false, ReturnConstants.DB_EX); } - if (renewal >0){ - return new ServerResult(true,renewal); - }else { - return new ServerResult(false,ReturnConstants.SYS_FAILL); + if (renewal > 0) { + return new ServerResult(true, renewal); + } else { + return new ServerResult(false, ReturnConstants.SYS_FAILL); } - }catch (RuntimeException e){ + } catch (RuntimeException e) { logger.error(e.getMessage()); TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); - return new ServerResult(false,ReturnConstants.DB_EX); + return new ServerResult(false, ReturnConstants.DB_EX); } } /** * 修改学生 - * + * * @param stu 学生 * @return 结果 */ @@ -115,25 +117,25 @@ public class StuServiceImpl implements StuService { stu.setUpdateTime(DateUtils.getNowDate()); stu.setUpdateBy(SecurityUtils.getUserId()); stuDao.deleteResultsBySId(stu.getId()); - if (insertResults(stu)){ - return new ServerResult(false,ReturnConstants.DB_EX); + if (insertResults(stu)) { + return new ServerResult(false, ReturnConstants.DB_EX); } Integer renewal = stuDao.updateStu(stu); - if (renewal >0){ - return new ServerResult(true,renewal); - }else { - return new ServerResult(false,ReturnConstants.SYS_FAILL); + if (renewal > 0) { + return new ServerResult(true, renewal); + } else { + return new ServerResult(false, ReturnConstants.SYS_FAILL); } - }catch (RuntimeException e){ + } catch (RuntimeException e) { logger.error(e.getMessage()); TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); - return new ServerResult(false,ReturnConstants.DB_EX); + return new ServerResult(false, ReturnConstants.DB_EX); } } /** * 批量删除学生 - * + * * @param ids 需要删除的学生ID * @return 结果 */ @@ -144,43 +146,43 @@ public class StuServiceImpl implements StuService { //批量删除子表数据 stuDao.deleteResultsBySIds(ids); Integer renewal = stuDao.deleteStuByIds(ids); - if (renewal >0){ - return new ServerResult(true,renewal); - }else { - return new ServerResult(false,ReturnConstants.SYS_FAILL); + if (renewal > 0) { + return new ServerResult(true, renewal); + } else { + return new ServerResult(false, ReturnConstants.SYS_FAILL); } - }catch (RuntimeException e){ + } catch (RuntimeException e) { logger.error(e.getMessage()); - return new ServerResult(false,ReturnConstants.DB_EX); + return new ServerResult(false, ReturnConstants.DB_EX); } } /** * 删除学生信息 - * + * * @param id 学生ID * @return 结果 */ @Override public ServerResult deleteStuById(Long id) { try { - //删除子表数据 - stuDao.deleteResultsBySId(id); + //删除子表数据 + stuDao.deleteResultsBySId(id); Integer renewal = stuDao.deleteStuById(id); - if (renewal >0){ - return new ServerResult(true,renewal); - }else { - return new ServerResult(false,ReturnConstants.SYS_FAILL); + if (renewal > 0) { + return new ServerResult(true, renewal); + } else { + return new ServerResult(false, ReturnConstants.SYS_FAILL); } - }catch (RuntimeException e){ + } catch (RuntimeException e) { logger.error(e.getMessage()); - return new ServerResult(false,ReturnConstants.DB_EX); + return new ServerResult(false, ReturnConstants.DB_EX); } } /** * 新增成绩信息 - * + * * @param stu 学生对象 */ public boolean insertResults(Stu stu) { @@ -188,13 +190,13 @@ public class StuServiceImpl implements StuService { Long id = stu.getId(); if (StringUtils.isNotNull(resultsList)) { List list = new ArrayList(); - for (Results results : resultsList){ + for (Results results : resultsList) { results.setsId(id); list.add(results); } if (list.size() > 0) { Integer renewal = stuDao.batchResults(list); - if (renewal>0){ + if (renewal > 0) { return false; } } diff --git a/hchyun/hchyun-test/src/main/java/com/hchyun/test/service/impl/TestTreeServiceImpl.java b/hchyun/hchyun-test/src/main/java/com/hchyun/test/service/impl/TestTreeServiceImpl.java index 0843633..f5e65bf 100644 --- a/hchyun/hchyun-test/src/main/java/com/hchyun/test/service/impl/TestTreeServiceImpl.java +++ b/hchyun/hchyun-test/src/main/java/com/hchyun/test/service/impl/TestTreeServiceImpl.java @@ -14,7 +14,7 @@ import com.hchyun.test.service.TestTreeService; /** * 树测试Service业务层处理 - * + * * @author hchyun * @date 2021-01-23 */ @@ -27,7 +27,7 @@ public class TestTreeServiceImpl implements TestTreeService { /** * 查询树测试 - * + * * @param id 树测试ID * @return 树测试 */ @@ -35,20 +35,20 @@ public class TestTreeServiceImpl implements TestTreeService { public ServerResult selectTestTreeById(Long id) { try { TestTree testTree = testTreeDao.selectTestTreeById(id); - if (testTree != null){ - return new ServerResult(true,testTree); - }else { + if (testTree != null) { + return new ServerResult(true, testTree); + } else { return new ServerResult(false, ReturnConstants.RESULT_EMPTY); } - }catch (RuntimeException e){ + } catch (RuntimeException e) { logger.error(e.getMessage()); - return new ServerResult(false,ReturnConstants.DB_EX); + return new ServerResult(false, ReturnConstants.DB_EX); } } /** * 查询树测试列表 - * + * * @param testTree 树测试 * @return 树测试 */ @@ -56,20 +56,20 @@ public class TestTreeServiceImpl implements TestTreeService { public ServerResult> selectTestTreeList(TestTree testTree) { try { List testTreeList = testTreeDao.selectTestTreeList(testTree); - if (testTreeList.size()>0){ - return new ServerResult>(true,testTreeList); - }else { - return new ServerResult>(false,ReturnConstants.RESULT_EMPTY); + if (testTreeList.size() > 0) { + return new ServerResult>(true, testTreeList); + } else { + return new ServerResult>(false, ReturnConstants.RESULT_EMPTY); } - }catch (RuntimeException e){ + } catch (RuntimeException e) { logger.error(e.getMessage()); - return new ServerResult>(false,ReturnConstants.DB_EX); + return new ServerResult>(false, ReturnConstants.DB_EX); } } /** * 新增树测试 - * + * * @param testTree 树测试 * @return 结果 */ @@ -77,20 +77,20 @@ public class TestTreeServiceImpl implements TestTreeService { public ServerResult insertTestTree(TestTree testTree) { try { Integer renewal = testTreeDao.insertTestTree(testTree); - if (renewal >0){ - return new ServerResult(true,renewal); - }else { - return new ServerResult(false,ReturnConstants.SYS_FAILL); + if (renewal > 0) { + return new ServerResult(true, renewal); + } else { + return new ServerResult(false, ReturnConstants.SYS_FAILL); } - }catch (RuntimeException e){ + } catch (RuntimeException e) { logger.error(e.getMessage()); - return new ServerResult(false,ReturnConstants.DB_EX); + return new ServerResult(false, ReturnConstants.DB_EX); } } /** * 修改树测试 - * + * * @param testTree 树测试 * @return 结果 */ @@ -98,20 +98,20 @@ public class TestTreeServiceImpl implements TestTreeService { public ServerResult updateTestTree(TestTree testTree) { try { Integer renewal = testTreeDao.updateTestTree(testTree); - if (renewal >0){ - return new ServerResult(true,renewal); - }else { - return new ServerResult(false,ReturnConstants.SYS_FAILL); + if (renewal > 0) { + return new ServerResult(true, renewal); + } else { + return new ServerResult(false, ReturnConstants.SYS_FAILL); } - }catch (RuntimeException e){ + } catch (RuntimeException e) { logger.error(e.getMessage()); - return new ServerResult(false,ReturnConstants.DB_EX); + return new ServerResult(false, ReturnConstants.DB_EX); } } /** * 批量删除树测试 - * + * * @param ids 需要删除的树测试ID * @return 结果 */ @@ -119,20 +119,20 @@ public class TestTreeServiceImpl implements TestTreeService { public ServerResult deleteTestTreeByIds(Long[] ids) { try { Integer renewal = testTreeDao.deleteTestTreeByIds(ids); - if (renewal >0){ - return new ServerResult(true,renewal); - }else { - return new ServerResult(false,ReturnConstants.SYS_FAILL); + if (renewal > 0) { + return new ServerResult(true, renewal); + } else { + return new ServerResult(false, ReturnConstants.SYS_FAILL); } - }catch (RuntimeException e){ + } catch (RuntimeException e) { logger.error(e.getMessage()); - return new ServerResult(false,ReturnConstants.DB_EX); + return new ServerResult(false, ReturnConstants.DB_EX); } } /** * 删除树测试信息 - * + * * @param id 树测试ID * @return 结果 */ @@ -140,14 +140,14 @@ public class TestTreeServiceImpl implements TestTreeService { public ServerResult deleteTestTreeById(Long id) { try { Integer renewal = testTreeDao.deleteTestTreeById(id); - if (renewal >0){ - return new ServerResult(true,renewal); - }else { - return new ServerResult(false,ReturnConstants.SYS_FAILL); + if (renewal > 0) { + return new ServerResult(true, renewal); + } else { + return new ServerResult(false, ReturnConstants.SYS_FAILL); } - }catch (RuntimeException e){ + } catch (RuntimeException e) { logger.error(e.getMessage()); - return new ServerResult(false,ReturnConstants.DB_EX); + return new ServerResult(false, ReturnConstants.DB_EX); } } } diff --git a/hchyun/hchyun-test/src/main/java/com/hchyun/test/test/Maptest.java b/hchyun/hchyun-test/src/main/java/com/hchyun/test/test/Maptest.java index dfc2ee0..f842258 100644 --- a/hchyun/hchyun-test/src/main/java/com/hchyun/test/test/Maptest.java +++ b/hchyun/hchyun-test/src/main/java/com/hchyun/test/test/Maptest.java @@ -17,34 +17,34 @@ import java.util.Map; * @Version 1.0 */ public class Maptest { - public static void setObject(T t, Map map){ + public static void setObject(T t, Map map) { Class cl = t.getClass(); - map.forEach((k,v)->{ + map.forEach((k, v) -> { try { - String name = k.toString().substring(0,1).toUpperCase() + k.toString().substring(1); - Method mo = cl.getMethod("get"+name); + String name = k.toString().substring(0, 1).toUpperCase() + k.toString().substring(1); + Method mo = cl.getMethod("get" + name); //类型判断可扩展 - if(mo.getReturnType().getName().equals(Integer.class.getName())){ - mo = cl.getMethod("set"+name,Integer.class); - mo.invoke(t,v); - }else if(mo.getReturnType().getName().equals(String.class.getName())){ - mo = cl.getMethod("set"+name,String.class); - mo.invoke(t,v); - }else if(mo.getReturnType().getName().equals(Long.class.getName())){ - mo = cl.getMethod("set"+name,Long.class); - mo.invoke(t,v); - }else if(mo.getReturnType().getName().equals(Double.class.getName())){ - mo = cl.getMethod("set"+name,Double.class); - mo.invoke(t,v); - }else if(mo.getReturnType().getName().equals(Date.class.getName())){ - mo = cl.getMethod("set"+name, Date.class); - mo.invoke(t,v); - }else if(mo.getReturnType().getName().equals(Float.class.getName())){ - mo = cl.getMethod("set"+name,Float.class); - mo.invoke(t,v); + if (mo.getReturnType().getName().equals(Integer.class.getName())) { + mo = cl.getMethod("set" + name, Integer.class); + mo.invoke(t, v); + } else if (mo.getReturnType().getName().equals(String.class.getName())) { + mo = cl.getMethod("set" + name, String.class); + mo.invoke(t, v); + } else if (mo.getReturnType().getName().equals(Long.class.getName())) { + mo = cl.getMethod("set" + name, Long.class); + mo.invoke(t, v); + } else if (mo.getReturnType().getName().equals(Double.class.getName())) { + mo = cl.getMethod("set" + name, Double.class); + mo.invoke(t, v); + } else if (mo.getReturnType().getName().equals(Date.class.getName())) { + mo = cl.getMethod("set" + name, Date.class); + mo.invoke(t, v); + } else if (mo.getReturnType().getName().equals(Float.class.getName())) { + mo = cl.getMethod("set" + name, Float.class); + mo.invoke(t, v); } } catch (NoSuchMethodException e) { - System.out.println("当前字段属性:"+k+",不在类中"); + System.out.println("当前字段属性:" + k + ",不在类中"); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { @@ -67,7 +67,8 @@ public class Maptest { } return obj; } - private static void populate1(Map map, T t) throws Exception { + + private static void populate1(Map map, T t) throws Exception { //拿到 BeanInfo BeanInfo beanInfo = Introspector.getBeanInfo(t.getClass()); @@ -81,31 +82,32 @@ public class Maptest { String name = pd.getName(); //判断是否有这个属性 - if (map.containsKey(name)){ + if (map.containsKey(name)) { //获取属性的 写的方法 Method wMethod = pd.getWriteMethod(); - if (pd.getPropertyType() == int.class){ - wMethod.invoke(t,Integer.valueOf(map.get(name))); - }else if (pd.getPropertyType() == double.class){ - wMethod.invoke(t,Double.valueOf(map.get(name))); - }else { - wMethod.invoke(t,map.get(name)); + if (pd.getPropertyType() == int.class) { + wMethod.invoke(t, Integer.valueOf(map.get(name))); + } else if (pd.getPropertyType() == double.class) { + wMethod.invoke(t, Double.valueOf(map.get(name))); + } else { + wMethod.invoke(t, map.get(name)); } } } } + public static void main(String[] age) throws Exception { IneniudBuid buid = new IneniudBuid(); Map map = new HashMap(); - map.put("id",123); - map.put("name","十大法d师"); - map.put("begnd","ssdfa"); - map.put("age",3.32); - map.put("addess","为东风qw股份"); - map.put("begnddd","ssdfa"); + map.put("id", 123); + map.put("name", "十大法d师"); + map.put("begnd", "ssdfa"); + map.put("age", 3.32); + map.put("addess", "为东风qw股份"); + map.put("begnddd", "ssdfa"); // setObject(buid,map); - populate1(map,buid); + populate1(map, buid); System.out.println(buid.toString()); } }