From 98dfc421beb8f86830deb1ff4b8841d8737bab7a Mon Sep 17 00:00:00 2001 From: liulin <lin.liu@88.com> Date: 星期四, 19 六月 2025 11:36:06 +0800 Subject: [PATCH] 初始化项目 --- src/main/java/com/fengdu/gas/service/AdminPermissionService.java | 118 src/main/java/com/fengdu/gas/entity/request/sysdictdata/ReqModifySysDictData.java | 54 src/main/java/com/fengdu/gas/common/config/TokenConfig.java | 36 src/main/java/com/fengdu/gas/entity/response/admin/ResAdminPermission.java | 28 src/main/java/com/fengdu/gas/repository/vo/TestInfoVO.java | 25 src/main/java/com/fengdu/gas/service/convert/AdminMenuConvert.java | 51 src/test/java/com/lunhan/xxx/po/UserPO.java | 2 src/main/java/com/fengdu/gas/common/serializer/CQTimestampSerializer.java | 24 src/main/java/com/fengdu/gas/common/model/ResFileUpload.java | 96 src/main/java/com/fengdu/gas/common/util/LocalDateTimeUtil.java | 564 + src/main/java/com/fengdu/gas/entity/response/admin/ResAdminMenuTreeAndPermission.java | 13 src/main/java/com/fengdu/gas/common/util/SM2Util.java | 162 src/test/java/com/lunhan/xxx/GenCodeMysql.java | 6 src/main/java/com/fengdu/gas/entity/search/SearchQuartzTaskError.java | 23 src/main/resources/application-dev.yml | 2 src/main/java/com/fengdu/gas/entity/request/ReqNeedCode.java | 19 src/main/java/com/fengdu/gas/repository/po/QuartzTaskErrorPO.java | 74 src/main/java/com/fengdu/gas/common/util/OrderUtil.java | 13 src/main/java/com/fengdu/gas/repository/impl/SysDictTypeMapperImpl.java | 150 src/main/java/com/fengdu/gas/entity/dto/PagerBasicDTO.java | 47 src/main/java/com/fengdu/gas/host/api/ApiRequestLogDTO.java | 113 src/main/java/com/fengdu/gas/host/controller/base/FileController.java | 188 src/main/java/com/fengdu/gas/common/validator/EParameterValidateType.java | 139 src/main/java/com/fengdu/gas/entity/request/test/ReqModifyTestInfo.java | 114 src/main/java/com/fengdu/gas/service/AdminService.java | 494 + src/main/java/com/fengdu/gas/entity/request/quartztaskerror/ReqCreateQuartzTaskError.java | 46 src/main/java/com/fengdu/gas/common/ExecutedResult.java | 151 src/main/java/com/fengdu/gas/host/controller/admin/AdminMenuController.java | 273 src/main/java/com/fengdu/gas/entity/search/SearchAdminUser.java | 25 src/main/java/com/fengdu/gas/entity/search/SearchNotice.java | 14 src/main/java/com/fengdu/gas/repository/vo/AdminUserVO.java | 62 src/main/java/com/fengdu/gas/entity/request/adminrolerelation/ReqCreateAdminRoleRelation.java | 42 src/main/java/com/fengdu/gas/service/quartz/QuartzExecutor.java | 72 src/main/java/com/fengdu/gas/entity/enums/ESex.java | 66 src/main/java/com/fengdu/gas/common/PagerResultMore.java | 26 src/main/java/com/fengdu/gas/repository/impl/QuartzTaskInfoMapperImpl.java | 120 src/main/java/com/fengdu/gas/entity/request/adminmenu/ReqCreateAdminMenu.java | 64 src/main/java/com/fengdu/gas/entity/response/admin/ResAdminPower.java | 18 src/main/java/com/fengdu/gas/service/convert/AdminUserConvert.java | 53 src/main/java/com/fengdu/gas/repository/mapper/AdminMenuMapper.java | 11 src/main/java/com/fengdu/gas/service/convert/QuartzTaskInfoConvert.java | 48 pom.xml | 6 src/main/java/com/fengdu/gas/entity/request/adminpermission/ReqCreateAdminPermission.java | 58 src/main/java/com/fengdu/gas/common/config/SysConfig.java | 45 src/main/java/com/fengdu/gas/service/convert/AdminPermissionConvert.java | 52 src/main/java/com/fengdu/gas/service/convert/QuartzTaskErrorConvert.java | 48 src/main/java/com/fengdu/gas/common/ToBigDecimalFunction.java | 8 src/main/java/com/fengdu/gas/repository/vo/AdminRoleMenuRelationVO.java | 55 src/main/java/com/fengdu/gas/repository/po/NoticePO.java | 109 src/main/java/com/fengdu/gas/service/AdminMenuService.java | 49 src/test/java/com/lunhan/xxx/JenkinsTest.java | 2 src/main/java/com/fengdu/gas/entity/request/adminrolepermissionrelation/ReqCreateAdminRolePermissionRelation.java | 42 src/main/java/com/fengdu/gas/entity/request/adminuser/ReqModifyAdminUser.java | 62 src/main/java/com/fengdu/gas/repository/impl/NoticeMapperImpl.java | 122 src/main/java/com/fengdu/gas/entity/search/SearchAdminMenus.java | 14 src/main/java/com/fengdu/gas/entity/request/adminrolerelation/ReqModifyAdminRoleRelation.java | 46 src/main/java/com/fengdu/gas/common/enums/EHorizontalLocation.java | 64 src/main/java/com/fengdu/gas/service/convert/SysDictDataConvert.java | 48 src/main/java/com/fengdu/gas/common/enums/EYesOrNo.java | 58 src/main/java/com/fengdu/gas/common/model/ExcelDiscernRow.java | 24 src/main/java/com/fengdu/gas/common/util/SM4Util.java | 93 src/main/java/com/fengdu/gas/entity/enums/EOrderBy.java | 63 src/main/java/com/fengdu/gas/repository/po/AdminRoleMenuRelationPO.java | 69 src/main/java/com/fengdu/gas/common/exceptions/BusinessException.java | 40 src/main/java/com/fengdu/gas/host/api/WebMvcConfig.java | 14 src/main/java/com/fengdu/gas/host/controller/base/NoticeController.java | 180 run-doc.sh | 4 src/main/java/com/fengdu/gas/entity/request/AdminSendMail.java | 23 src/main/java/com/fengdu/gas/common/util/SpringUtil.java | 44 src/main/java/com/fengdu/gas/entity/dto/KeyValueDTO.java | 28 src/main/java/com/fengdu/gas/entity/request/adminuser/ReqAdminLogin.java | 17 src/main/java/com/fengdu/gas/repository/BasicMapper.java | 126 src/main/java/com/fengdu/gas/repository/vo/AdminMenusVO.java | 54 src/main/java/com/fengdu/gas/host/api/CorsFilterConfig.java | 31 src/main/resources/application.yml | 4 src/main/java/com/fengdu/gas/repository/mapper/QuartzTaskRecordMapper.java | 12 src/main/java/com/fengdu/gas/repository/mapper/AdminUserMapper.java | 11 src/main/java/com/fengdu/gas/service/SysDictTypeService.java | 323 src/main/java/com/fengdu/gas/host/controller/base/SysDictTypeController.java | 143 src/test/java/com/lunhan/xxx/SpringConfig.java | 2 src/main/java/com/fengdu/gas/common/serializer/CQLocalDateSerializer.java | 20 src/main/java/com/fengdu/gas/common/cache/CacheManagerConfig.java | 59 src/main/java/com/fengdu/gas/common/util/EncryptionUtil.java | 46 src/main/java/com/fengdu/gas/common/util/SnowFlakeUtil.java | 115 src/main/java/com/fengdu/gas/common/util/SerializeUtil.java | 282 src/main/java/com/fengdu/gas/service/convert/QuartzTaskRecordConvert.java | 48 src/main/java/com/fengdu/gas/common/config/JdbcSetConfig.java | 18 src/main/java/com/fengdu/gas/common/serializer/CQLocalDateTimeSerializer.java | 21 src/main/java/com/fengdu/gas/entity/request/adminuser/ReqSetListRole4Admin.java | 19 src/main/java/com/fengdu/gas/repository/vo/AdminRoleRelationVO.java | 55 src/main/java/com/fengdu/gas/entity/request/adminrole/ReqCreateAdminRole.java | 46 src/main/java/com/fengdu/gas/common/util/CopierUtil.java | 70 src/main/java/com/fengdu/gas/entity/enums/EUserType.java | 61 src/main/java/com/fengdu/gas/repository/po/SysDictTypePO.java | 79 src/main/java/com/fengdu/gas/repository/po/AdminMenuPO.java | 104 src/main/java/com/fengdu/gas/repository/vo/QuartzTaskRecordVO.java | 62 src/main/java/com/fengdu/gas/repository/mapper/QuartzTaskInfoMapper.java | 12 src/main/java/com/fengdu/gas/common/util/ExceptionUtil.java | 69 src/main/java/com/fengdu/gas/common/enums/EVerticalLocation.java | 64 src/main/java/com/fengdu/gas/entity/search/SearchSysDictType.java | 14 src/main/java/com/fengdu/gas/common/enums/ELogger.java | 32 src/main/java/com/fengdu/gas/common/util/PinYinUtil.java | 88 src/main/java/com/fengdu/gas/common/security/Des3Util.java | 146 src/main/java/com/fengdu/gas/host/api/HttpRequestLogPool.java | 16 src/main/java/com/fengdu/gas/repository/po/SysDictDataPO.java | 84 src/main/java/com/fengdu/gas/repository/impl/AdminRoleRelationMapperImpl.java | 144 src/main/java/com/fengdu/gas/common/util/NumericUtil.java | 240 src/main/java/com/fengdu/gas/entity/search/SearchAdminRole.java | 25 src/main/java/com/fengdu/gas/common/config/RedisConfig.java | 18 src/main/java/com/fengdu/gas/repository/impl/AdminUserMapperImpl.java | 134 src/test/java/com/lunhan/xxx/DemoTest.java | 2 src/main/java/com/fengdu/gas/service/AdminPowerService.java | 867 + src/main/java/com/fengdu/gas/host/controller/base/QuartzController.java | 141 src/main/java/com/fengdu/gas/common/jwt/JWTUtil.java | 85 src/main/java/com/fengdu/gas/entity/request/notice/ReqModifyNotice.java | 61 src/main/java/com/fengdu/gas/repository/vo/SysDictDataVO.java | 60 src/main/java/com/fengdu/gas/service/convert/TestInfoConvert.java | 48 src/main/java/com/fengdu/gas/entity/request/adminrolemenurelation/ReqSetListMenu4Role.java | 24 src/main/java/com/fengdu/gas/entity/request/adminuser/ReqCreateAdminUser.java | 62 src/main/java/com/fengdu/gas/entity/request/testinfo/ReqModifyTestInfo.java | 74 src/main/java/com/fengdu/gas/entity/request/sysdicttype/ReqCreateSysDictType.java | 46 src/main/java/com/fengdu/gas/service/SysDictDataService.java | 390 src/main/java/com/fengdu/gas/service/convert/NoticeConvert.java | 48 src/main/java/com/fengdu/gas/entity/request/adminmenu/ReqModifyAdminMenu.java | 73 src/main/java/com/fengdu/gas/common/util/FileUtil.java | 436 src/main/java/com/fengdu/gas/entity/dto/UserInfoDto.java | 178 src/main/java/com/fengdu/gas/entity/enums/ESortOrderBy.java | 67 src/main/java/com/fengdu/gas/entity/enums/EMenuType.java | 66 src/main/java/com/fengdu/gas/common/serializer/CQCalendarSerializer.java | 24 src/main/java/com/fengdu/gas/host/api/MyBatisPlusConfig.java | 16 src/main/java/com/fengdu/gas/common/extend/CollectorsPlus.java | 1498 +++ src/main/resources/smart-doc.json | 16 src/main/java/com/fengdu/gas/repository/vo/BasicVO.java | 13 src/main/java/com/fengdu/gas/service/convert/AdminRoleConvert.java | 48 src/test/java/com/lunhan/xxx/GaussExportTest.java | 4 src/main/java/com/fengdu/gas/common/PagerResult.java | 119 src/main/java/com/fengdu/gas/host/api/TokenFilter.java | 116 src/main/java/com/fengdu/gas/service/TestInfoService.java | 250 src/main/java/com/fengdu/gas/host/api/MvcTokenInterceptors.java | 42 src/main/java/com/fengdu/gas/host/controller/admin/AdminUserController.java | 265 src/main/java/com/fengdu/gas/entity/search/SearchAdminMenu.java | 14 src/main/java/com/fengdu/gas/entity/dto/RequestDTO.java | 114 src/main/java/com/fengdu/gas/entity/search/SearchTestInfo.java | 40 src/main/java/com/fengdu/gas/common/util/MailUtils.java | 81 src/main/java/com/fengdu/gas/entity/request/quartztaskinfo/ReqRunTaskRightNow.java | 15 src/main/java/com/fengdu/gas/service/convert/AdminRolePermissionRelationConvert.java | 48 src/main/java/com/fengdu/gas/repository/impl/QuartzTaskRecordMapperImpl.java | 114 src/main/java/com/fengdu/gas/entity/request/ReqOperate.java | 30 src/main/java/com/fengdu/gas/entity/request/adminrolemenurelation/ReqSetListRole4Admin.java | 19 src/main/java/com/fengdu/gas/service/convert/SysDictTypeConvert.java | 48 src/main/java/com/fengdu/gas/repository/vo/SysDictTypeVO.java | 55 src/main/java/com/fengdu/gas/host/controller/base/SysDictDataController.java | 145 src/main/resources/application-prod.yml | 2 src/test/java/com/lunhan/xxx/Gauss2Gauss.java | 6 src/main/java/com/fengdu/gas/entity/search/SearchQuartzTaskInfo.java | 30 src/main/java/com/fengdu/gas/repository/impl/AdminMenusMapperImpl.java | 138 src/main/java/com/fengdu/gas/host/BasicController.java | 62 src/main/java/com/fengdu/gas/repository/po/AdminRolePO.java | 79 src/main/java/com/fengdu/gas/entity/request/adminrolemenurelation/ReqCreateAdminRoleMenuRelation.java | 42 src/main/java/com/fengdu/gas/common/util/CalendarUtil.java | 378 src/main/java/com/fengdu/gas/service/quartz/QuartzService.java | 420 src/test/resources/application.yml | 2 src/main/java/com/fengdu/gas/entity/request/sysdicttype/ReqModifySysDictType.java | 50 src/main/java/com/fengdu/gas/service/convert/AdminMenusConvert.java | 48 src/test/java/com/lunhan/xxx/Mysql2Gauss.java | 4 src/main/java/com/fengdu/gas/entity/enums/EHandleStatus.java | 69 src/main/java/com/fengdu/gas/repository/vo/QuartzTaskErrorVO.java | 55 src/main/resources/application-test.yml | 4 src/main/java/com/fengdu/gas/common/model/Tuple.java | 35 src/main/java/com/fengdu/gas/host/api/MustAdmin.java | 15 src/main/java/com/fengdu/gas/repository/impl/QuartzTaskErrorMapperImpl.java | 115 src/main/java/com/fengdu/gas/entity/enums/EState.java | 69 src/main/java/com/fengdu/gas/entity/request/ReqListSetSort.java | 22 src/main/java/com/fengdu/gas/entity/request/adminpermission/ReqModifyAdminPermission.java | 66 src/test/java/com/lunhan/xxx/StringUtilTest.java | 4 src/main/java/com/fengdu/gas/common/enums/ERequestTokenFrom.java | 60 src/main/java/com/fengdu/gas/host/controller/admin/AdminPermissionController.java | 120 src/main/java/com/fengdu/gas/service/BaseService.java | 16 src/main/java/com/fengdu/gas/entity/search/SearchQuartzTaskRecord.java | 48 src/main/java/com/fengdu/gas/common/enums/EResultCode.java | 71 src/main/java/com/fengdu/gas/repository/mapper/AdminRolePermissionRelationMapper.java | 11 src/main/java/com/fengdu/gas/entity/request/notice/ReqCreateNotice.java | 53 src/main/java/com/fengdu/gas/common/jackson/BigNumberSerializer.java | 40 src/main/java/com/fengdu/gas/repository/mapper/SysDictDataMapper.java | 11 src/main/java/com/fengdu/gas/entity/search/SearchAdminPermission.java | 25 src/main/java/com/fengdu/gas/host/api/WebLogAspect.java | 209 src/main/java/com/fengdu/gas/repository/mapper/AdminRoleMenuRelationMapper.java | 11 src/main/java/com/fengdu/gas/common/security/MD5Util.java | 70 src/main/java/com/fengdu/gas/common/util/SnowFlake.java | 198 src/main/java/com/fengdu/gas/common/util/HttpUtil.java | 484 + src/main/java/com/fengdu/gas/entity/enums/EExecuteType.java | 63 src/main/java/com/fengdu/gas/entity/request/ReqListStatus.java | 18 src/test/java/com/lunhan/xxx/repository/mapper/UserMapper.java | 6 run-doc.bat | 4 src/main/java/com/fengdu/gas/common/util/LoggerUtil.java | 15 src/main/java/com/fengdu/gas/entity/search/SearchSysDictData.java | 14 src/main/java/com/fengdu/gas/common/util/ThreadPoolUtil.java | 27 src/main/java/com/fengdu/gas/entity/request/quartztaskinfo/ReqModifyQuartzTaskInfo.java | 66 src/main/java/com/fengdu/gas/common/serializer/deserializer/CQTimestampDeSerializer.java | 35 src/main/java/com/fengdu/gas/entity/dto/UploadResultVo.java | 88 src/main/java/com/fengdu/gas/entity/request/adminmenus/ReqModifyAdminMenus.java | 69 src/main/java/com/fengdu/gas/common/ConstantFactory.java | 329 src/main/java/com/fengdu/gas/host/ApplicationStarter.java | 31 src/main/java/com/fengdu/gas/common/cache/RedisKeySerializer.java | 30 src/main/java/com/fengdu/gas/common/util/StringUtil.java | 847 + src/main/java/com/fengdu/gas/entity/request/quartztaskerror/ReqModifyQuartzTaskError.java | 50 src/main/java/com/fengdu/gas/repository/mapper/AdminRoleRelationMapper.java | 11 src/main/java/com/fengdu/gas/common/enums/EHttpContentType.java | 68 src/main/java/com/fengdu/gas/repository/po/AdminMenusPO.java | 99 src/main/java/com/fengdu/gas/host/api/GlobalExceptionHandler.java | 92 src/main/java/com/fengdu/gas/common/serializer/deserializer/CQLocalDateTimeDeSerializer.java | 35 src/main/java/com/fengdu/gas/repository/mapper/TestInfoMapper.java | 36 src/main/java/com/fengdu/gas/entity/dto/SearchBasicDTO.java | 137 src/main/java/com/fengdu/gas/service/dto/NoticeDetail.java | 12 src/main/java/com/fengdu/gas/entity/dto/OrderByDTO.java | 29 src/main/java/com/fengdu/gas/entity/response/ResNameValue.java | 28 src/main/java/com/fengdu/gas/entity/response/admin/ResAdminMenuTree.java | 50 src/main/java/com/fengdu/gas/repository/po/AdminRoleRelationPO.java | 69 src/main/java/com/fengdu/gas/common/config/JWTConfig.java | 45 src/main/java/com/fengdu/gas/repository/po/AdminPermissionPO.java | 94 src/main/java/com/fengdu/gas/repository/vo/AdminPermissionVO.java | 55 src/main/java/com/fengdu/gas/common/enums/EContentType.java | 204 src/main/java/com/fengdu/gas/common/serializer/deserializer/CQDateDeSerializer.java | 33 src/main/java/com/fengdu/gas/common/enums/EnumBasic.java | 12 src/main/java/com/fengdu/gas/entity/dto/NameSortIdDTO.java | 37 src/main/java/com/fengdu/gas/entity/search/SearchAdminRolePermissionRelation.java | 25 src/main/java/com/fengdu/gas/repository/impl/AdminRoleMenuRelationMapperImpl.java | 144 src/test/java/com/lunhan/xxx/GenCodeGauss.java | 64 src/main/java/com/fengdu/gas/common/validator/ParameterValidator.java | 555 + src/test/resources/application-dev.yml | 2 src/main/java/com/fengdu/gas/common/security/Base64Util.java | 119 src/main/java/com/fengdu/gas/entity/dto/NameSortDTO.java | 28 src/main/java/com/fengdu/gas/service/convert/AdminRoleMenuRelationConvert.java | 48 src/main/java/com/fengdu/gas/repository/mapper/SysDictTypeMapper.java | 11 src/main/java/com/fengdu/gas/common/enums/IErrorCode.java | 18 src/main/java/com/fengdu/gas/entity/search/SearchAdminRoleRelation.java | 25 src/main/java/com/fengdu/gas/repository/po/TestInfoPO.java | 105 src/main/java/com/fengdu/gas/repository/mapper/AdminPermissionMapper.java | 11 src/main/java/com/fengdu/gas/common/util/ParameterUtil.java | 69 src/main/java/com/fengdu/gas/entity/search/SearchAdminRoleMenuRelation.java | 25 src/main/java/com/fengdu/gas/entity/enums/EOperation.java | 98 src/main/java/com/fengdu/gas/repository/impl/TestInfoMapperImpl.java | 133 src/main/java/com/fengdu/gas/repository/mapper/QuartzTaskErrorMapper.java | 12 src/main/java/com/fengdu/gas/repository/vo/NoticeVO.java | 55 src/main/java/com/fengdu/gas/repository/impl/SysDictDataMapperImpl.java | 187 src/main/java/com/fengdu/gas/entity/request/adminrole/ReqModifyAdminRole.java | 54 src/main/java/com/fengdu/gas/repository/mapper/NoticeMapper.java | 11 src/main/java/com/fengdu/gas/common/jackson/JacksonConfig.java | 40 src/main/java/com/fengdu/gas/common/jwt/LoginUserDTO.java | 114 src/main/java/com/fengdu/gas/repository/impl/AdminRoleMapperImpl.java | 117 src/main/java/com/fengdu/gas/common/serializer/deserializer/CQLocalDateDeSerializer.java | 28 src/main/java/com/fengdu/gas/common/validator/ParameterValidateResult.java | 38 src/main/java/com/fengdu/gas/common/model/ExcelDiscernCell.java | 31 src/main/java/com/fengdu/gas/repository/mapper/AdminRoleMapper.java | 11 src/main/java/com/fengdu/gas/host/controller/base/BaseController.java | 49 src/main/java/com/fengdu/gas/service/quartz/QuartzMainJobFactory.java | 99 src/main/java/com/fengdu/gas/entity/enums/ELockValue.java | 8 src/main/java/com/fengdu/gas/repository/po/QuartzTaskInfoPO.java | 129 src/main/java/com/fengdu/gas/entity/request/adminrolemenurelation/ReqModifyAdminRoleMenuRelation.java | 46 src/main/java/com/fengdu/gas/service/NoticeService.java | 168 src/test/java/com/lunhan/xxx/MySqlExportTest.java | 4 src/main/java/com/fengdu/gas/repository/po/AdminRolePermissionRelationPO.java | 69 src/test/java/com/lunhan/xxx/repository/test123.java | 2 src/main/java/com/fengdu/gas/repository/bo/NoticeBO.java | 66 src/main/java/com/fengdu/gas/repository/vo/AdminMenuVO.java | 55 src/main/java/com/fengdu/gas/repository/BasicMapperImpl.java | 699 + src/main/java/com/fengdu/gas/common/util/MoneyUtil.java | 129 src/main/java/com/fengdu/gas/host/controller/TestInfoServiceController.java | 257 src/main/java/com/fengdu/gas/entity/dto/NameValueDTO.java | 39 src/main/java/com/fengdu/gas/common/util/ListUtil.java | 200 src/main/java/com/fengdu/gas/entity/request/ReqListId.java | 19 src/main/java/com/fengdu/gas/host/api/NonLogin.java | 15 src/main/java/com/fengdu/gas/repository/vo/AdminRolePermissionRelationVO.java | 55 src/main/java/com/fengdu/gas/repository/impl/AdminRolePermissionRelationMapperImpl.java | 144 src/main/java/com/fengdu/gas/service/convert/AdminRoleRelationConvert.java | 48 src/main/java/com/fengdu/gas/repository/mapper/AdminMenusMapper.java | 11 src/main/java/com/fengdu/gas/common/util/IPUtils.java | 71 src/main/java/com/fengdu/gas/common/validator/ParameterValidateItem.java | 124 src/test/java/com/lunhan/xxx/DateTimeTest.java | 4 src/main/java/com/fengdu/gas/entity/request/quartztaskrecord/ReqModifyQuartzTaskRecord.java | 62 src/main/java/com/fengdu/gas/host/controller/admin/AdminRoleController.java | 319 src/main/java/com/fengdu/gas/common/serializer/CQDateSerializer.java | 26 src/main/java/com/fengdu/gas/entity/request/quartztaskrecord/ReqCreateQuartzTaskRecord.java | 58 src/main/java/com/fengdu/gas/common/util/RandVerifyCode.java | 106 src/main/java/com/fengdu/gas/entity/request/testinfo/ReqCreateTestInfo.java | 66 src/main/java/com/fengdu/gas/repository/impl/AdminMenuMapperImpl.java | 135 src/main/java/com/fengdu/gas/repository/po/QuartzTaskRecordPO.java | 99 src/main/java/com/fengdu/gas/repository/vo/QuartzTaskInfoVO.java | 55 src/main/java/com/fengdu/gas/common/config/FileConfig.java | 36 src/main/java/com/fengdu/gas/entity/request/ReqSetSort.java | 30 src/main/java/com/fengdu/gas/entity/enums/EParameterType.java | 56 src/main/java/com/fengdu/gas/entity/request/sysdictdata/ReqCreateSysDictData.java | 50 src/main/java/com/fengdu/gas/entity/request/test/ReqCreateTestInfo.java | 102 src/main/java/com/fengdu/gas/entity/response/admin/ResAdminLogin.java | 35 src/main/java/com/fengdu/gas/service/dto/ResAdminDetail.java | 15 src/test/java/com/lunhan/xxx/BasicServiceApplicationTests.java | 6 src/main/java/com/fengdu/gas/entity/request/adminrolepermissionrelation/ReqModifyAdminRolePermissionRelation.java | 46 src/main/java/com/fengdu/gas/repository/impl/AdminPermissionMapperImpl.java | 141 src/main/java/com/fengdu/gas/entity/request/ReqUserLogin.java | 30 /dev/null | 420 src/main/java/com/fengdu/gas/entity/request/ReqChangePassword.java | 30 src/main/java/com/fengdu/gas/entity/request/adminmenus/ReqCreateAdminMenus.java | 61 src/main/java/com/fengdu/gas/common/serializer/deserializer/CQCalendarDeSerializer.java | 44 src/main/java/com/fengdu/gas/repository/po/AdminUserPO.java | 104 src/main/java/com/fengdu/gas/entity/enums/EDataChangeType.java | 73 src/main/java/com/fengdu/gas/common/validator/ParameterRunnable.java | 13 src/main/java/com/fengdu/gas/entity/request/ReqNeedId.java | 17 src/main/java/com/fengdu/gas/repository/vo/AdminRoleVO.java | 55 src/main/java/com/fengdu/gas/entity/request/quartztaskinfo/ReqCreateQuartzTaskInfo.java | 58 src/main/java/com/fengdu/gas/repository/bo/AdminUserBO.java | 29 310 files changed, 26,435 insertions(+), 502 deletions(-) diff --git a/pom.xml b/pom.xml index 287fa5e..d902c49 100644 --- a/pom.xml +++ b/pom.xml @@ -9,10 +9,10 @@ <relativePath/> </parent> - <groupId>com.lunhan.xxx</groupId> - <artifactId>xxx-yyy</artifactId> + <groupId>com.fengdu.gas</groupId> + <artifactId>fengdu_gases</artifactId> <version>0.0.1-SNAPSHOT</version> - <name>xxx-yyy-service</name> + <name>fengdu_gases-service</name> <description>The service which yyy of xxx project</description> <properties> diff --git a/run-doc.bat b/run-doc.bat index 640912c..723b3dc 100644 --- a/run-doc.bat +++ b/run-doc.bat @@ -10,7 +10,7 @@ cd %currPath% -mvn smart-doc:html -Dfile.encoding=UTF-8 -pl :xxx-yyy -am -mvn smart-doc:openapi -Dfile.encoding=UTF-8 -pl :xxx-yyy -am +mvn smart-doc:html -Dfile.encoding=UTF-8 -pl :fengdu_gases -am +mvn smart-doc:openapi -Dfile.encoding=UTF-8 -pl :fengdu_gases -am pause>nul \ No newline at end of file diff --git a/run-doc.sh b/run-doc.sh index 136e9e3..43acbf5 100644 --- a/run-doc.sh +++ b/run-doc.sh @@ -8,8 +8,8 @@ echo $project_name -mvn smart-doc:html -Dfile.encoding=UTF-8 -pl :xxx-yyy -am -mvn smart-doc:openapi -Dfile.encoding=UTF-8 -pl :xxx-yyy -am +mvn smart-doc:html -Dfile.encoding=UTF-8 -pl :fengdu_gases -am +mvn smart-doc:openapi -Dfile.encoding=UTF-8 -pl :fengdu_gases -am #echo 按任意键退出 #read -n 1 diff --git a/src/main/java/com/fengdu/gas/common/ConstantFactory.java b/src/main/java/com/fengdu/gas/common/ConstantFactory.java new file mode 100644 index 0000000..75231f7 --- /dev/null +++ b/src/main/java/com/fengdu/gas/common/ConstantFactory.java @@ -0,0 +1,329 @@ +package com.fengdu.gas.common; + +import java.math.BigDecimal; + +public final class ConstantFactory { + private ConstantFactory() { + throw new IllegalStateException("Utility class"); + } + + //********************************** msgCode ********************************** + /** + * msgCode - token错误 + */ + public static final String MCODE_TOKENERROR = "SYS000003"; + //********************************** msgCode ********************************** + + + + + + //********************************** 字符串 ********************************** + /** + * 获取字符串换行符 + */ + public static final String STR_NEWLINE = "\r\n"; + /** + * 获取html换行符 + */ + public static final String STR_HTMLBR = "<br />"; + /** + * 1个空格字符串 + */ + public static final String STR_SPACE = " "; + /** + * 正则中的1个空格字符串 + */ + public static final String STR_REGEX_SPACE = "\\s"; + /** + * ~ + */ + public static final String STR_TIME_RANGE = " ~ "; + /** + * ; + */ + public static final String STR_SEMICOLON = ";"; + //********************************** 字符串 ********************************** + + + + + + //********************************** 时间日期 相关 ********************************** + /** + * 日期格式“yyyy-MM-dd” + */ + public static final String STR_DATE = "yyyy-MM-dd"; + /** + * 时间格式“yyyy-MM-dd HH:mm:ss” + */ + public static final String STR_DATE_FULL = "yyyy-MM-dd HH:mm:ss"; + /** + * 时间格式“yyyy-MM-dd HH:mm:ss.SSS” + */ + public static final String STR_DATE_FULLMS = "yyyy-MM-dd HH:mm:ss.SSS"; + /** + * “ 00:00:00” + */ + public static final String STR_DATE_DAYSTART = " 00:00:00"; + /** + * “ 23:59:59” + */ + public static final String STR_DATE_DAYEND = " 23:59:59"; + /** + * “1970-01-01” + */ + public static final String STR_DATE_DEFAULT_DATE = "1970-01-01"; + /** + * “1970-01-01 00:00:00” + */ + public static final String STR_DATE_DEFAULT = "1970-01-01 00:00:00"; + /** + * “1970-01-01 08:00:01” + */ + public static final String STR_DATE_DEFAULT_UTC8 = "1970-01-01 08:00:01"; + /** + * “1970-01-01 00:00:00” + */ + public static final String STR_DATE_DEFAULT_FULL = "1970-01-01 00:00:00.000"; + //********************************** 时间日期 相关 ********************************** + + + + + + //********************************** SQL关键字 相关 ********************************** + /** + * 等于“ = ?” + */ + public static final String SQL_EQUAL = " = ?"; + /** + * 不等于 + */ + public static final String SQL_NOTEQUAL = " <> ?"; + /** + * 大于 + */ + public static final String SQL_GREATER = " > ?"; + /** + * 大于等于 + */ + public static final String SQL_GREATERTHAN = " >= ?"; + /** + * 小于 + */ + public static final String SQL_LESS = " < ?"; + /** + * 小于等于 + */ + public static final String SQL_LESSTHAN = " <= ?"; + /** + * 模糊等于“ like ?” + */ + public static final String SQL_LIKE = " like ?"; + /** + * 模糊不等于“ not like ?” + */ + public static final String SQL_NOTLIKE = " not like ?"; + /** + * “ IN” + */ + public static final String SQL_IN = " IN"; + //public static final String SQL_IN = " FIND_IN_SET(%s, ?) > 0";//由于“FIND_IN_SET”无法使用索引 2020-06-17 改为“in”语法 lin.liu + /** + * “ NOT IN” + */ + public static final String SQL_NOTIN = " NOT IN"; + //public static final String SQL_NOTIN = " FIND_IN_SET(%s, ?) = 0";//由于“FIND_IN_SET”无法使用索引 2020-06-17 改为“not in”语法 lin.liu + + + /** + * 并且“AND” + */ + public static final String SQL_AND = " AND"; + /** + * 或者“OR” + */ + public static final String SQL_OR = " OR"; + + /** + * 逗号“,” + */ + public static final String SQL_STR_COMMA = " ,"; + /** + * “ ASC” + */ + public static final String SQL_ASC = " ASC"; + /** + * “ DESC” + */ + public static final String SQL_DESC = " DESC"; + public static final String TB_A = "a."; + public static final String TB_B = "b."; + //********************************** SQL关键字 相关 ********************************** + + + + + + + //********************************** redis 相关 ********************************** + /** + * 分布式锁前缀 + */ + public static final String REDIS_LOCKPREFIX = "lock_"; + /** + * 分布式锁超时时间10秒 + */ + public static final Long REDIS_LOCKTIMEOUT = 10 * 1000L; + /** + * token哈希key + */ + public static final String REDIS_HASH_TOKEN = "HASH_TOKEN"; + /** + * 分布式锁超时时间24小时 + */ + public static final Long REDIS_EXPIRE_DEFAULT = 24 * 60 * 60L; + //********************************** redis 相关 ********************************** + + + + + + + //********************************** request请求 相关 ********************************** + /** + * token存在于headers的键值 + */ + public static final String REQUEST_TOKENKEY = "tokencode"; + /** + * token过期时间 + */ + public static final Long TOKEN_EXPIRE_DEFAULT = 2 * 60 * 60L; + /** + * 刷新token过期时间 + */ + public static final Long LONG_TOKEN_EXPIRE_DEFAULT = 7 * 24 * 60 * 60L; + //********************************** request请求 相关 ********************************** + + + + + + + //********************************** 正则表达式相关 ********************************** + /** + * 字符串格式为日期“yyyy-MM-dd”的正则 + */ + public static final String REGEX_DATE = "^[0-9]{4}\\-((0[1-9])|(1[0-2]))\\-((0[1-9])|(1[0-9])|(2[0-9])|(3[0-1]))$"; + /** + * 字符串格式为时间“yyyy-MM-dd HH:mm:ss”的正则 + */ + public static final String REGEX_DATETIME = "^[0-9]{4}\\-((0[1-9])|(1[0-2]))\\-((0[1-9])|([12][0-9])|(3[0-1]))\\s((0[0-9])|(1[0-9])|(2[0-3]))(\\:((0[0-9])|([1-5][0-9]))){2}$"; + /** + * 字符串格式为完整时间“yyyy-MM-dd HH:mm:ss.SSS”的正则 + */ + public static final String REGEX_DATETIME_FULL = "^[0-9]{4}\\-((0[1-9])|(1[0-2]))\\-((0[1-9])|([12][0-9])|(3[0-1]))\\s((0[0-9])|(1[0-9])|(2[0-3]))(\\:((0[0-9])|([1-5][0-9]))){2}\\.([0-9]){3}$"; + /** + * 字符串格式为时间“/Date(1585790902913+0800)/”的正则 + */ + public static final String REGEX_DATETIME_JAVA = "^/Date\\((?<timestamp>[0-9]{13})\\+([^\\)]+)\\)/$"; + + //********************************** 正则表达式相关 ********************************** + /** + * 缴费成功微信模版 + */ + public static final String PAY_THE_FEES_SUCCEED="D_m6GtEG-JQspqFuAvjcvzWCQDCtJAKxtq4pqFzgF54"; + /** + * 欠费催缴通知 + */ + public static final String ARREARAGE_INFORM="suK97dUCdCqQzwgQ90_DRfzI3TFExmEL1n9DAK3oTDE"; + /** + * 水费账单提醒 + */ + public static final String WATER_RATE_BILL="qqGUVvz3_rcqpDwJ6LywFOsbZhIHV-0oA6sLbHl1pQ4"; + /** + * 用水号绑定成功通知 + */ + public static final String ACCOUNT_BINDING_SUCCEED="l1wUD1hkSN16sQxsJ6dcm04BnmiO5-cRGgpsjuoSbLY"; + /** + * 预付费充值成功提醒 + */ + public static final String TOP_UP_SUCCEED="P29GhSpqsvVdIvEvCabpSD47lNjS5J_jw0tYm5GSKpw"; + + + + //********************************** 正则表达式相关 ********************************** + + + + + + + + + + + + + + public static final BigDecimal FEE_MAX = new BigDecimal("99999999999999999999.99"); + public static final BigDecimal FEE_PRICE_MAX = new BigDecimal("999.99"); + public static final BigDecimal FEE_AMOUNT_MAX = new BigDecimal("999999.99"); + public static final BigDecimal FEE_PERCENTAGE_MAX = new BigDecimal("100"); + public static final Integer NUM0 = 0; + public static final Integer NUM1 = 1; + public static final Integer NUM2 = 2; + public static final Integer NUM3 = 3; + public static final Integer NUM4 = 4; + public static final Integer NUM5 = 5; + public static final Integer NUM10 = 10; + public static final Integer NUM15 = 15; + public static final Integer NUM20 = 20; + public static final Integer NUM30 = 30; + public static final Integer NUM50 = 50; + public static final Integer NUM100 = 100; + public static final Integer NUM200 = 200; + public static final Integer NUM500 = 500; + public static final Integer NUM1000 = 1000; + public static final Integer NUM2000 = 2000; + public static final Integer NUM5000 = 5000; + public static final Integer NUM10000 = 10000; + public static final Integer LENGTH_MAX10000 = 10000; + public static final Integer LENGTH_MAX7000 = 7000; + public static final Integer LENGTH_MAX5000 = 5000; + public static final Integer LENGTH_MAX2000 = 2000; + public static final Integer LENGTH_MAX1000 = 1000; + public static final Integer LENGTH_MAX500 = 500; + public static final Integer LENGTH_MAX200 = 200; + public static final Integer LENGTH_MAX100 = 100; + public static final Integer LENGTH_MAX50 = 50; + public static final Integer LENGTH_MAX20 = 20; + public static final Integer LENGTH_MAX11 = 11; + public static final Integer MONEY_MAX_LENGTH = 2; + public static final Integer MAX_PAGE_SIZE = 999999; + public static final Integer PAGE_SIZE_DEFAULT = 20; + public static final Integer DEFAULT_NUM_PRECISION = 2; + public static final Integer FILE_UNIT = 1024; + public static final Integer FILE_SIZE_1M = 1024; + public static final Integer FILE_SIZE_2M = 2 * 1024; + public static final Integer FILE_SIZE_5M = 5 * 1024; + public static final Integer FILE_SIZE_10M = 10 * 1024; + public static final Integer FILE_SIZE_20M = 20 * 1024; + public static final Integer FILE_SIZE_50M = 50 * 1024; + public static final Integer FILE_SIZE_100M = 100 * 1024; + public static final Integer FILE_SIZE_200M = 200 * 1024; + public static final Integer TIME_LEN_1S = 1000; + public static final Integer TIME_LEN_10S = 10 * 1000; + public static final Integer TIME_LEN_1MIN = 60 * 1000; + public static final Integer TIME_LEN_5MIN = 5 * 60 * 1000; + public static final Integer TIME_LEN_10MIN = 10 * 60 * 1000; + public static final Integer TIME_LEN_20MIN = 20 * 60 * 1000; + public static final Integer TIME_LEN_50MIN = 50 * 60 * 1000; + public static final Integer TIME_LEN_100MIN = 100 * 60 * 1000; + public static final Integer TIME_LEN_1H = 60 * 60 * 1000; + public static final Integer TIME_LEN_2H = 2 * 60 * 60 * 1000; + public static final Integer TIME_LEN_12H = 12 * 60 * 60 * 1000; + public static final Integer TIME_LEN_24H = 24 * 60 * 60 * 1000; + public static final String KEY_PASSWORD = "lunhan_wcI32U+F5cSF1AL2321UoelnZNYQWxCd_hard_ware"; +} \ No newline at end of file diff --git a/src/main/java/com/fengdu/gas/common/ExecutedResult.java b/src/main/java/com/fengdu/gas/common/ExecutedResult.java new file mode 100644 index 0000000..5274fd3 --- /dev/null +++ b/src/main/java/com/fengdu/gas/common/ExecutedResult.java @@ -0,0 +1,151 @@ +package com.fengdu.gas.common; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fengdu.gas.common.enums.EResultCode; +import com.fengdu.gas.common.util.StringUtil; + +import java.util.Objects; + +/** + * 执行结果实体 + * @author lin.liu + * @date 2019-01-08 + * @param <T> 数据包类型 + */ +public class ExecutedResult<T> { + private static final String STR_SUCCESS = "success."; + private static final String STR_FAILED = "failed."; + + /** + * 请求响应状态码 EResultCode + */ + private Integer code = EResultCode.FAILED.getCode(); + /** + * 错误消息 + */ + private String msg = STR_FAILED; + /** + * 数据包 + */ + private T data = null; + /** + * 错误码 + * @ignore + */ + @JsonIgnore + private String msgCode = ""; + + public Integer getCode() { + return code; + } + public void setCode(Integer code) { + this.code = code; + } + + public String getMsg() { + return msg; + } + public void setMsg(String msg) { + this.msg = msg; + } + + public T getData() { + return data; + } + public void setData(T data) { + this.data = data; + } + + public String getMsgCode() { + return msgCode; + } + public void setMsgCode(String msgCode) { + this.msgCode = msgCode; + } + + public ExecutedResult(){} + + public ExecutedResult(EResultCode code, T data){ + this.code = code.getCode(); + this.data = data; + } + + public ExecutedResult(EResultCode code, T data, String msg){ + this.code = code.getCode(); + this.data = data; + this.msg = msg; + } + + public ExecutedResult(EResultCode code, T data, String msg, String msgCode){ + this.code = code.getCode(); + this.data = data; + this.msg = msg; + this.msgCode = msgCode; + } + + @JsonIgnore + public Boolean isSuccess(){ + return Objects.equals(this.code, EResultCode.SUCCESS.getCode()); + } + + @JsonIgnore + public Boolean isFailed(){ + return !this.isSuccess(); + } + + public static <T> ExecutedResult<T> success(){ + return new ExecutedResult<>(EResultCode.SUCCESS, null, STR_SUCCESS); + } + + public static <T> ExecutedResult<T> success(T data){ + return new ExecutedResult<>(EResultCode.SUCCESS, data, STR_SUCCESS); + } + + public static <T> ExecutedResult<T> success(T data, String msg){ + if(StringUtil.isNullOrEmpty(msg)){ + msg = STR_SUCCESS; + } + return new ExecutedResult<>(EResultCode.SUCCESS, data, msg); + } + + public static <T> ExecutedResult<T> failed(){ + return ExecutedResult.failed(""); + } + + public static <T> ExecutedResult<T> failed(String msg){ + return ExecutedResult.failed(msg, ""); + } + + public static <T> ExecutedResult<T> failed(String msg, String msgCode){ + return ExecutedResult.failed(null, msg, msgCode); + } + + public static <T> ExecutedResult<T> failed(T data, String msg, String msgCode){ + if(StringUtil.isNullOrEmpty(msg)){ + msg = STR_FAILED; + } + return new ExecutedResult<>(EResultCode.FAILED, data, msg, msgCode); + } + + /** + * 参数验证失败返回结果 + * @param message 提示信息 + */ + public static <T> ExecutedResult<T> validateFailed(String message) { + return new ExecutedResult<>(EResultCode.VALIDATE_FAILED, null, message); + } + + /** + * 未登录返回结果 + */ + public static <T> ExecutedResult<T> unauthorized(T data) { + return new ExecutedResult<>(EResultCode.UNAUTHORIZED, data, EResultCode.UNAUTHORIZED.getMessage()); + } + + /** + * 未授权返回结果 + */ + public static <T> ExecutedResult<T> forbidden() { + return new ExecutedResult<>(EResultCode.FORBIDDEN, null, EResultCode.FORBIDDEN.getMessage()); + } +} \ No newline at end of file diff --git a/src/main/java/com/fengdu/gas/common/PagerResult.java b/src/main/java/com/fengdu/gas/common/PagerResult.java new file mode 100644 index 0000000..b31cb2f --- /dev/null +++ b/src/main/java/com/fengdu/gas/common/PagerResult.java @@ -0,0 +1,119 @@ +package com.fengdu.gas.common; + +import java.util.ArrayList; +import java.util.List; + +/** + * 分页结果 + * @author linliu + * @date 2018-12-24 + * @param <T> 数据包数据类型 + */ +public class PagerResult<T> { + /** + * 页大小(每页返回的记录条数) + **/ + private Number limit = 10; + /** + * 页号(第几页, 从1开始) + **/ + private Number page = 1; + /** + * 记录总条数 + **/ + private Number total = 0L; + /** + * 上一次请求最后一条数据的id + * + **/ + private Long lastId = 0L; + /** + * 数据包 + **/ + private List<T> list = new ArrayList<>(); + + /** + * 构造方法 + */ + public PagerResult() { + + } + + /** + * 构造方法 + * @param limit 页大小(每页显示记录数) + * @param page 页号(第几页, 从1开始) + * @param total 记录总条数 + * @param list 数据包 + */ + public PagerResult(Number limit, Number page, Number total, List<T> list) { + this.limit = limit; + this.page = page; + this.total = total; + this.list = list; + } + + public Number getLimit() { + return limit; + } + public void setLimit(Number limit) { + this.limit = limit; + } + + public Number getPage() { + return page; + } + + public void setPage(Number page) { + this.page = page; + } + + public Long getTotal() { + return total.longValue(); + } + + public void setTotal(Number total) { + this.total = total; + } + + public List<T> getList() { + return list; + } + + public void setList(List<T> list) { + this.list = list; + } + + public Long getLastId() { + return lastId; + } + + public void setLastId(Long lastId) { + this.lastId = lastId; + } + + /** + * 总页数 + */ + public Long getTotalPage() { + Long page = this.total.longValue() / this.limit.longValue(); + if(this.total.longValue() % this.limit.longValue() != 0){ + page++; + } + return page; + } + + /** + * 是否还有上一页 + */ + public boolean getIsHasPrePage() { + return this.getPage().longValue() > 1L; + } + + /** + * 是否还有下一页 + */ + public boolean getIsHasNextPage() { + return this.getPage().longValue() < this.getTotalPage(); + } +} \ No newline at end of file diff --git a/src/main/java/com/fengdu/gas/common/PagerResultMore.java b/src/main/java/com/fengdu/gas/common/PagerResultMore.java new file mode 100644 index 0000000..a5be74d --- /dev/null +++ b/src/main/java/com/fengdu/gas/common/PagerResultMore.java @@ -0,0 +1,26 @@ +package com.fengdu.gas.common; + +import java.util.List; + +public class PagerResultMore<T, M> extends PagerResult<T> { + /** + * 其他信息 + */ + private M other; + + public M getOther() { + return other; + } + + public void setOther(M other) { + this.other = other; + } + + public PagerResultMore() { + } + + public PagerResultMore(Integer limit, Integer page, Number total, List<T> list, M other) { + super(limit, page, total, list); + this.other = other; + } +} diff --git a/src/main/java/com/fengdu/gas/common/ToBigDecimalFunction.java b/src/main/java/com/fengdu/gas/common/ToBigDecimalFunction.java new file mode 100644 index 0000000..d124fb3 --- /dev/null +++ b/src/main/java/com/fengdu/gas/common/ToBigDecimalFunction.java @@ -0,0 +1,8 @@ +package com.fengdu.gas.common; + +import java.math.BigDecimal; + +@FunctionalInterface +public interface ToBigDecimalFunction<T> { + BigDecimal applyAsBigDecimal(T value); +} diff --git a/src/main/java/com/fengdu/gas/common/cache/CacheManagerConfig.java b/src/main/java/com/fengdu/gas/common/cache/CacheManagerConfig.java new file mode 100644 index 0000000..45b700f --- /dev/null +++ b/src/main/java/com/fengdu/gas/common/cache/CacheManagerConfig.java @@ -0,0 +1,59 @@ +package com.fengdu.gas.common.cache; + +import com.fengdu.gas.common.ConstantFactory; +import org.springframework.cache.CacheManager; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Primary; +import org.springframework.data.redis.cache.RedisCacheConfiguration; +import org.springframework.data.redis.cache.RedisCacheManager; +import org.springframework.data.redis.connection.RedisConnectionFactory; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.data.redis.core.StringRedisTemplate; +import org.springframework.data.redis.serializer.*; + +import java.time.Duration; + +@Configuration +public class CacheManagerConfig { + @Bean + @Primary + public CacheManager json4RedisCacheManager(RedisConnectionFactory redisConnectionFactory) { + RedisCacheConfiguration config = RedisCacheConfiguration.defaultCacheConfig() + //设置24小时过期 + .entryTtl(Duration.ofMillis(ConstantFactory.TIME_LEN_24H)) + //设置key的序列化方式 + .serializeKeysWith(RedisSerializationContext.SerializationPair.fromSerializer(new RedisKeySerializer())) + //设置值的序列化方式 + .serializeValuesWith(RedisSerializationContext.SerializationPair.fromSerializer(new GenericJackson2JsonRedisSerializer())); + + + RedisCacheManager.RedisCacheManagerBuilder builder = + RedisCacheManager.RedisCacheManagerBuilder.fromConnectionFactory(redisConnectionFactory); + + //返回构造的cacheManager + return builder.transactionAware().cacheDefaults(config).build(); + } + + @Bean + public StringRedisTemplate stringRedisTemplate(RedisConnectionFactory redisConnectionFactory) { + StringRedisTemplate stringRedisTemplate = new StringRedisTemplate(redisConnectionFactory); + stringRedisTemplate.setKeySerializer(new RedisKeySerializer()); + return stringRedisTemplate; + } + + @Bean + public RedisTemplate<String, Object> objectRedisTemplate(RedisConnectionFactory redisConnectionFactory) { + RedisSerializer<String> serializer = new StringRedisSerializer(); + Jackson2JsonRedisSerializer<Object> jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer<>(Object.class); + RedisTemplate<String, Object> template = new RedisTemplate<>(); + template.setConnectionFactory(redisConnectionFactory); + template.setKeySerializer(new RedisKeySerializer()); + template.setValueSerializer(jackson2JsonRedisSerializer); + template.setHashKeySerializer(serializer); + template.setHashValueSerializer(jackson2JsonRedisSerializer); + template.afterPropertiesSet(); + + return template; + } +} diff --git a/src/main/java/com/fengdu/gas/common/cache/RedisKeySerializer.java b/src/main/java/com/fengdu/gas/common/cache/RedisKeySerializer.java new file mode 100644 index 0000000..a9f1a91 --- /dev/null +++ b/src/main/java/com/fengdu/gas/common/cache/RedisKeySerializer.java @@ -0,0 +1,30 @@ +package com.fengdu.gas.common.cache; + +import com.fengdu.gas.common.config.SysConfig; +import org.springframework.data.redis.serializer.RedisSerializer; +import org.springframework.lang.Nullable; + +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; + +public class RedisKeySerializer implements RedisSerializer<String> { + private static final Charset charset = StandardCharsets.UTF_8; + + /* + * (non-Javadoc) + * @see org.springframework.data.redis.serializer.RedisSerializer#deserialize(byte[]) + */ + @Override + public String deserialize(@Nullable byte[] bytes) { + return (bytes == null ? null : new String(bytes, charset).replaceFirst(SysConfig.redis.getKeyPrefix(), "")); + } + + /* + * (non-Javadoc) + * @see org.springframework.data.redis.serializer.RedisSerializer#serialize(java.lang.Object) + */ + @Override + public byte[] serialize(@Nullable String string) { + return (string == null ? null : (SysConfig.redis.getKeyPrefix() + string).getBytes(charset)); + } +} diff --git a/src/main/java/com/fengdu/gas/common/config/FileConfig.java b/src/main/java/com/fengdu/gas/common/config/FileConfig.java new file mode 100644 index 0000000..5cdc848 --- /dev/null +++ b/src/main/java/com/fengdu/gas/common/config/FileConfig.java @@ -0,0 +1,36 @@ +package com.fengdu.gas.common.config; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + +@Component +@ConfigurationProperties(prefix = "file") +public class FileConfig { + private String uploadBasicPath; + private String fileBasicUrl; + private String disturbStr; + + public String getUploadBasicPath() { + return uploadBasicPath; + } + + public void setUploadBasicPath(String uploadBasicPath) { + this.uploadBasicPath = uploadBasicPath; + } + + public String getFileBasicUrl() { + return fileBasicUrl; + } + + public void setFileBasicUrl(String fileBasicUrl) { + this.fileBasicUrl = fileBasicUrl; + } + + public String getDisturbStr() { + return disturbStr; + } + + public void setDisturbStr(String disturbStr) { + this.disturbStr = disturbStr; + } +} diff --git a/src/main/java/com/fengdu/gas/common/config/JWTConfig.java b/src/main/java/com/fengdu/gas/common/config/JWTConfig.java new file mode 100644 index 0000000..21ddad5 --- /dev/null +++ b/src/main/java/com/fengdu/gas/common/config/JWTConfig.java @@ -0,0 +1,45 @@ +package com.fengdu.gas.common.config; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + +@Component +@ConfigurationProperties(prefix = "jwt") +public class JWTConfig { + private String head; + private String tokenHeader; + private String secret; + private Long expiration; + + public String getHead() { + return head; + } + + public void setHead(String head) { + this.head = head; + } + + public String getTokenHeader() { + return tokenHeader; + } + + public void setTokenHeader(String tokenHeader) { + this.tokenHeader = tokenHeader; + } + + public String getSecret() { + return secret; + } + + public void setSecret(String secret) { + this.secret = secret; + } + + public Long getExpiration() { + return expiration; + } + + public void setExpiration(Long expiration) { + this.expiration = expiration; + } +} diff --git a/src/main/java/com/fengdu/gas/common/config/JdbcSetConfig.java b/src/main/java/com/fengdu/gas/common/config/JdbcSetConfig.java new file mode 100644 index 0000000..3250da5 --- /dev/null +++ b/src/main/java/com/fengdu/gas/common/config/JdbcSetConfig.java @@ -0,0 +1,18 @@ +package com.fengdu.gas.common.config; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + +@Component +@ConfigurationProperties(prefix = "jdbc-set") +public class JdbcSetConfig { + private String sqlLog; + + public String getSqlLog() { + return sqlLog; + } + + public void setSqlLog(String sqlLog) { + this.sqlLog = sqlLog; + } +} diff --git a/src/main/java/com/fengdu/gas/common/config/RedisConfig.java b/src/main/java/com/fengdu/gas/common/config/RedisConfig.java new file mode 100644 index 0000000..d2c2507 --- /dev/null +++ b/src/main/java/com/fengdu/gas/common/config/RedisConfig.java @@ -0,0 +1,18 @@ +package com.fengdu.gas.common.config; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + +@Component +@ConfigurationProperties(prefix = "spring.redis") +public class RedisConfig { + private String keyPrefix; + + public String getKeyPrefix() { + return keyPrefix; + } + + public void setKeyPrefix(String keyPrefix) { + this.keyPrefix = keyPrefix; + } +} diff --git a/src/main/java/com/fengdu/gas/common/config/SysConfig.java b/src/main/java/com/fengdu/gas/common/config/SysConfig.java new file mode 100644 index 0000000..66c721e --- /dev/null +++ b/src/main/java/com/fengdu/gas/common/config/SysConfig.java @@ -0,0 +1,45 @@ +package com.fengdu.gas.common.config; + +import com.fengdu.gas.common.util.SpringUtil; + +/** + * 获取系统配置 读取“config.properties” + */ +public final class SysConfig { + public static JWTConfig jwt = SpringUtil.getBean(JWTConfig.class); + public static JdbcSetConfig jdbc = SpringUtil.getBean(JdbcSetConfig.class); + public static FileConfig file = SpringUtil.getBean(FileConfig.class); + public static RedisConfig redis = SpringUtil.getBean(RedisConfig.class); + + public static String getTokenHeader() { + return jwt.getTokenHeader(); + //return properties.getProperty("jwt.tokenHeader", ""); + } + + public static String getJwtHead() { + return jwt.getHead(); + //return properties.getProperty("jwt.tokenHead", ""); + } + + public static String getTJwtHeader() { + return jwt.getTokenHeader(); + //return properties.getProperty("jwt.tokenHeader", ""); + } + + public static boolean isSqlLog() { + return "true".equalsIgnoreCase(jdbc.getSqlLog()); + //return properties.getProperty("mail.sendEmail", ""); + } + + public static String fileUploadBasic() { + return file.getUploadBasicPath(); + } + + public static String fileViewBasic() { + return file.getFileBasicUrl(); + } + + public static String fileDisturbStr() { + return file.getDisturbStr(); + } +} \ No newline at end of file diff --git a/src/main/java/com/fengdu/gas/common/config/TokenConfig.java b/src/main/java/com/fengdu/gas/common/config/TokenConfig.java new file mode 100644 index 0000000..6cc672b --- /dev/null +++ b/src/main/java/com/fengdu/gas/common/config/TokenConfig.java @@ -0,0 +1,36 @@ +package com.fengdu.gas.common.config; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + +@Component +@ConfigurationProperties(prefix = "token") +public class TokenConfig { + private String tokenHeader; + private String expiredTime; + private String longExpiredTime; + + public String getTokenHeader() { + return tokenHeader; + } + + public void setTokenHeader(String tokenHeader) { + this.tokenHeader = tokenHeader; + } + + public String getExpiredTime() { + return expiredTime; + } + + public void setExpiredTime(String expiredTime) { + this.expiredTime = expiredTime; + } + + public String getLongExpiredTime() { + return longExpiredTime; + } + + public void setLongExpiredTime(String longExpiredTime) { + this.longExpiredTime = longExpiredTime; + } +} diff --git a/src/main/java/com/fengdu/gas/common/enums/EContentType.java b/src/main/java/com/fengdu/gas/common/enums/EContentType.java new file mode 100644 index 0000000..f7866ab --- /dev/null +++ b/src/main/java/com/fengdu/gas/common/enums/EContentType.java @@ -0,0 +1,204 @@ +package com.fengdu.gas.common.enums; + +import java.util.Arrays; + +/** + * ContentType 枚举 + */ +public enum EContentType { + /** + * application/json + */ + JSON("application/json", "application/json"), + /** + * application/x-www-form-urlencoded + */ + FORM("application/x-www-form-urlencoded", "application/x-www-form-urlencoded"), + /** + * multipart/form-data + */ + FORMDATA("multipart/form-data", "multipart/form-data"), + /** + * application/xml + */ + XML("application/xml", "application/xml"), + /** + * text/plain + */ + TEXT("text/plain", "text/plain"), + + + + + + /** + * application/vnd.ms-excel + */ + EXCEL("application/vnd.ms-excel", "application/vnd.ms-excel"), + /** + * application/vnd.openxmlformats-officedocument.spreadsheetml.sheet + */ + EXCELX("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"), + /** + * application/msword + */ + WORD("application/msword", "application/msword"), + /** + * application/vnd.openxmlformats-officedocument.wordprocessingml.document + */ + WORDX("application/vnd.openxmlformats-officedocument.wordprocessingml.document", "application/vnd.openxmlformats-officedocument.wordprocessingml.document"), + /** + * application/vnd.ms-powerpoint + */ + PPT("application/vnd.ms-powerpoint", "application/vnd.ms-powerpoint"), + /** + * application/vnd.openxmlformats-officedocument.presentationml.presentation + */ + PPTX("application/vnd.openxmlformats-officedocument.presentationml.presentation", "application/vnd.openxmlformats-officedocument.presentationml.presentation"), + + + + + + + + + + + /** + * image/jpeg + */ + JPEG("image/jpeg", "image/jpeg"), + /** + * image/jpg + */ + JPG("image/jpg", "image/jpg"), + /** + * image/gif + */ + GIF("image/gif", "image/gif"), + /** + * image/png + */ + PNG("image/png", "image/png"), + /** + * image/bmp + */ + BMP("image/bmp", "image/bmp"), + + + + + + + + + + + /** + * application/zip + */ + ZIP("application/zip", "application/zip"), + /** + * application/x-rar + */ + RAR("application/x-rar", "application/x-rar"), + /** + * application/x-7z-compressed + */ + X7Z("application/x-7z-compressed", "application/x-7z-compressed"), + /** + * application/x-gzip + */ + GZ("application/x-gzip", "application/x-gzip"), + + + + + + + + + + + /** + * video/mpeg + */ + MP2("video/mpeg", "video/mpeg"), + /** + * audio/mpeg + */ + MP3("audio/mpeg", "audio/mpeg"), + /** + * aaudio/x-flac + */ + FLAC("audio/x-flac", "audio/x-flac"), + /** + * video/x-flv + */ + FLV("video/x-flv", "video/x-flv"), + /** + * video/3gpp + */ + X3GP("video/3gpp", "video/3gpp"), + /** + * video/mp4 + */ + MP4("video/mp4", "video/mp4"), + + + + + + + + + + + /** + * application/pdf + */ + PDF("application/pdf", "application/pdf") + ; + + private String desc;//枚举描述 + private String value;//枚举值 + + public String getValue() { + return value; + } + public String getDesc() { + return desc; + } + + /** + * 构造方法 + * @param desc 枚举描述 + * @param value 枚举值 + */ + EContentType(String desc, String value) { + this.desc = desc; + this.value = value; + } + + /** + * 根据值获取枚举 + * + * @param value 枚举值 + * @return + */ + public static EContentType getByValue(String value) { + return Arrays.stream(EContentType.values()) + .filter(e -> e.getValue().equals(value)) + .findFirst() + .orElse(null); + } + + @Override + public String toString() { + return "EContentType{" + + "desc='" + desc + '\'' + + ", value=" + value + + '}'; + } +} \ No newline at end of file diff --git a/src/main/java/com/fengdu/gas/common/enums/EHorizontalLocation.java b/src/main/java/com/fengdu/gas/common/enums/EHorizontalLocation.java new file mode 100644 index 0000000..3dd6a1f --- /dev/null +++ b/src/main/java/com/fengdu/gas/common/enums/EHorizontalLocation.java @@ -0,0 +1,64 @@ +package com.fengdu.gas.common.enums; + +import java.util.Arrays; + +/** + * 水平位置 枚举 + */ +public enum EHorizontalLocation { + /** + * 靠左 + */ + LEFT("LEFT", 1), + + /** + * 居中 + */ + CENTRE("CENTRE", 2), + + /** + * 靠右 + */ + RIGHT("RIGHT", 3); + + private String desc;//枚举描述 + private int value;//枚举值 + + public int getValue() { + return value; + } + public String getDesc() { + return desc; + } + + /** + * 构造方法 + * @param desc 枚举描述 + * @param value 枚举值 + */ + EHorizontalLocation(String desc, int value) { + this.desc = desc; + this.value = value; + } + + /** + * 根据值获取枚举 + * + * @param value 枚举值 + * @return + */ + public static EHorizontalLocation getByValue(int value) { + return Arrays.stream(EHorizontalLocation.values()) + .filter(e -> e.getValue() == value) + .findFirst() + .orElse(null); + } + + @Override + public String toString() { + return "EHorizontalLocation{" + + "desc='" + desc + '\'' + + ", value=" + value + + '}'; + } +} \ No newline at end of file diff --git a/src/main/java/com/fengdu/gas/common/enums/EHttpContentType.java b/src/main/java/com/fengdu/gas/common/enums/EHttpContentType.java new file mode 100644 index 0000000..2c169c9 --- /dev/null +++ b/src/main/java/com/fengdu/gas/common/enums/EHttpContentType.java @@ -0,0 +1,68 @@ +package com.fengdu.gas.common.enums; + +import java.util.Arrays; + +/** + * http请求类型 枚举 + * @author linliu + * @date 2019-01-08 + */ +public enum EHttpContentType { + /** + * application/json + */ + JSON("application/json", "application/json"), + /** + * application/x-www-form-urlencoded + */ + FORM("application/x-www-form-urlencoded", "application/x-www-form-urlencoded"), + /** + * multipart/form-data + */ + FORMDATA("multipart/form-data", "multipart/form-data"), + /** + * application/xml + */ + XML("application/xml", "application/xml"); + + private String desc;//枚举描述 + private String value;//枚举值 + + public String getValue() { + return value; + } + public String getDesc() { + return desc; + } + + /** + * 构造方法 + * @param desc 枚举描述 + * @param value 枚举值 + */ + EHttpContentType(String desc, String value) { + this.desc = desc; + this.value = value; + } + + /** + * 根据值获取枚举 + * + * @param value 枚举值 + * @return + */ + public static EHttpContentType getByValue(String value) { + return Arrays.stream(EHttpContentType.values()) + .filter(e -> e.getValue().equals(value)) + .findFirst() + .orElse(null); + } + + @Override + public String toString() { + return "EHttpContentType{" + + "desc='" + desc + '\'' + + ", value=" + value + + '}'; + } +} \ No newline at end of file diff --git a/src/main/java/com/fengdu/gas/common/enums/ELogger.java b/src/main/java/com/fengdu/gas/common/enums/ELogger.java new file mode 100644 index 0000000..f79a172 --- /dev/null +++ b/src/main/java/com/fengdu/gas/common/enums/ELogger.java @@ -0,0 +1,32 @@ +package com.fengdu.gas.common.enums; + +import java.util.Arrays; +import java.util.Objects; + +public enum ELogger { + DEBUG("debug"), + INFO("info"), + API_REQUEST("apiRequest"), + + SQL_LOG("sqlLog"), + SYS_ERROR("sysError"), + PAY_SERVICE("payService") + ; + + private String logFileName; + + ELogger(String logFileName) { + this.logFileName = logFileName; + } + + public String getLogFileName() { + return this.logFileName; + } + + public static ELogger getByLoggerName(String loggerName) { + ELogger[] arr = values(); + return Arrays.stream(arr) + .filter(c -> Objects.equals(c.getLogFileName(), loggerName)) + .findAny().orElse(null); + } +} diff --git a/src/main/java/com/fengdu/gas/common/enums/ERequestTokenFrom.java b/src/main/java/com/fengdu/gas/common/enums/ERequestTokenFrom.java new file mode 100644 index 0000000..5f22ae0 --- /dev/null +++ b/src/main/java/com/fengdu/gas/common/enums/ERequestTokenFrom.java @@ -0,0 +1,60 @@ +package com.fengdu.gas.common.enums; + +import java.util.Arrays; + +/** + * token存放地方 枚举 + * @author linliu + * @date 2019-06-04 + */ +public enum ERequestTokenFrom { + /** + * token从 headers 传输 + */ + HEADERS("headers", 1), + /** + * token从 urls 传输 + */ + URLS("urls", 2); + + private String desc;//枚举描述 + private int value;//枚举值 + + public int getValue() { + return value; + } + public String getDesc() { + return desc; + } + + /** + * 构造方法 + * @param desc 枚举描述 + * @param value 枚举值 + */ + ERequestTokenFrom(String desc, int value) { + this.desc = desc; + this.value = value; + } + + /** + * 根据值获取枚举 + * + * @param value 枚举值 + * @return + */ + public static ERequestTokenFrom getByValue(int value) { + return Arrays.stream(ERequestTokenFrom.values()) + .filter(e -> e.getValue() == value) + .findFirst() + .orElse(null); + } + + @Override + public String toString() { + return "ERequestTokenFrom{" + + "desc='" + desc + '\'' + + ", value=" + value + + '}'; + } +} \ No newline at end of file diff --git a/src/main/java/com/fengdu/gas/common/enums/EResultCode.java b/src/main/java/com/fengdu/gas/common/enums/EResultCode.java new file mode 100644 index 0000000..5f05ab4 --- /dev/null +++ b/src/main/java/com/fengdu/gas/common/enums/EResultCode.java @@ -0,0 +1,71 @@ +package com.fengdu.gas.common.enums; + +/** + * 执行结果 枚举 + * @author linliu + * @date 2019-01-08 + */ +public enum EResultCode implements IErrorCode { + /** + * 操作成功=200, + **/ + SUCCESS(200, "操作成功"), + /** + * 部分成功=210 + */ + PARTIAL_SUCCESS(210, "部分成功"), + /** + * 操作失败=300, + **/ + FAILED(300, "操作失败"), + /** + * 参数检验失败=301, + **/ + VALIDATE_FAILED(301, "参数检验失败"), + /** + * 相关需要支付:未付费 + */ + UNPAID(302,"未付费"), + /** + * 积分不足,充值提示 + */ + INTEGRAL(303,"积分不足,请充值。"), + /** + * 未登录或token已经过期=401, + **/ + UNAUTHORIZED(401, "未登录或token已经过期"), + /** + * 没有相关权限=403, + **/ + FORBIDDEN(403, "没有相关权限"), + /** + * 找不到相关资源=404, + **/ + NOT_FOUND(404, "找不到相关资源"), + /** + * 签名验证失败=407, + */ + SIGN_NOT_PASS(407, "签名验证失败"), + /** + * 系统繁忙=500, + **/ + ERROR(500, "系统繁忙"); + + private Integer code; + private String message; + + EResultCode(Integer code, String message) { + this.code = code; + this.message = message; + } + + @Override + public Integer getCode() { + return code; + } + + @Override + public String getMessage() { + return message; + } +} \ No newline at end of file diff --git a/src/main/java/com/fengdu/gas/common/enums/EVerticalLocation.java b/src/main/java/com/fengdu/gas/common/enums/EVerticalLocation.java new file mode 100644 index 0000000..989f841 --- /dev/null +++ b/src/main/java/com/fengdu/gas/common/enums/EVerticalLocation.java @@ -0,0 +1,64 @@ +package com.fengdu.gas.common.enums; + +import java.util.Arrays; + +/** + * 垂直位置 枚举 + */ +public enum EVerticalLocation { + /** + * 靠顶端 + */ + TOP("TOP", 1), + + /** + * 居中 + */ + MIDDLE("MIDDLE", 2), + + /** + * 靠底部 + */ + BOTTOM("BOTTOM", 3); + + private String desc;//枚举描述 + private int value;//枚举值 + + public int getValue() { + return value; + } + public String getDesc() { + return desc; + } + + /** + * 构造方法 + * @param desc 枚举描述 + * @param value 枚举值 + */ + EVerticalLocation(String desc, int value) { + this.desc = desc; + this.value = value; + } + + /** + * 根据值获取枚举 + * + * @param value 枚举值 + * @return + */ + public static EVerticalLocation getByValue(int value) { + return Arrays.stream(EVerticalLocation.values()) + .filter(e -> e.getValue() == value) + .findFirst() + .orElse(null); + } + + @Override + public String toString() { + return "EVerticalLocation{" + + "desc='" + desc + '\'' + + ", value=" + value + + '}'; + } +} \ No newline at end of file diff --git a/src/main/java/com/fengdu/gas/common/enums/EYesOrNo.java b/src/main/java/com/fengdu/gas/common/enums/EYesOrNo.java new file mode 100644 index 0000000..c9ecc2b --- /dev/null +++ b/src/main/java/com/fengdu/gas/common/enums/EYesOrNo.java @@ -0,0 +1,58 @@ +package com.fengdu.gas.common.enums; + +import java.util.Arrays; +import java.util.Objects; + +public enum EYesOrNo { + /** + * 否 + */ + NO("否", 0), + + /** + * 是=1 + */ + YES("是", 1) + ; + + private String desc;//枚举描述 + private Integer value;//枚举值 + + public Integer getValue() { + return value; + } + public String getDesc() { + return desc; + } + + /** + * 构造方法 + * @param desc 枚举描述 + * @param value 枚举值 + */ + EYesOrNo(String desc, Integer value) { + this.desc = desc; + this.value = value; + } + + /** + * 根据值获取枚举 + * + * @param value 枚举值 + * @return + */ + public static EYesOrNo getByValue(Integer value) { + return Arrays.stream(EYesOrNo.values()) + .filter(e -> Objects.equals(e.getValue(), value)) + .findFirst() + .orElse(null); + } + + @Override + public String toString() { + return "EYesOrNo{" + + "desc='" + desc + '\'' + + ", value=" + value + + '}'; + } +} diff --git a/src/main/java/com/fengdu/gas/common/enums/EnumBasic.java b/src/main/java/com/fengdu/gas/common/enums/EnumBasic.java new file mode 100644 index 0000000..aa716b5 --- /dev/null +++ b/src/main/java/com/fengdu/gas/common/enums/EnumBasic.java @@ -0,0 +1,12 @@ +package com.fengdu.gas.common.enums; + +/** + * 枚举基类 + * @author linliu + * @date 2019-01-08 + */ +public interface EnumBasic { + int getValue(); + String getColumnName(); + String getTableName(); +} \ No newline at end of file diff --git a/src/main/java/com/fengdu/gas/common/enums/IErrorCode.java b/src/main/java/com/fengdu/gas/common/enums/IErrorCode.java new file mode 100644 index 0000000..7860f29 --- /dev/null +++ b/src/main/java/com/fengdu/gas/common/enums/IErrorCode.java @@ -0,0 +1,18 @@ +package com.fengdu.gas.common.enums; + +/** + * @Author lin.liu + * @Description 错误编码 接口 + * @Date 2021/4/16 + **/ +public interface IErrorCode { + /** + * 错误编码 + **/ + Integer getCode(); + + /** + * 错误信息 + **/ + String getMessage(); +} diff --git a/src/main/java/com/fengdu/gas/common/exceptions/BusinessException.java b/src/main/java/com/fengdu/gas/common/exceptions/BusinessException.java new file mode 100644 index 0000000..29f6232 --- /dev/null +++ b/src/main/java/com/fengdu/gas/common/exceptions/BusinessException.java @@ -0,0 +1,40 @@ +package com.fengdu.gas.common.exceptions; + +import com.fengdu.gas.common.enums.EResultCode; + +/** + * 自定义业务异常 + */ +public class BusinessException extends RuntimeException { + private EResultCode code; + + public EResultCode getCode() { + return code; + } + + public void setCode(EResultCode code) { + this.code = code; + } + + public BusinessException() { + super(); + } + + public BusinessException(String message) { + super(message); + this.code = EResultCode.ERROR; + } + + public BusinessException(EResultCode code, String message) { + super(message); + this.code = code; + } + + public BusinessException(String message, Throwable cause) { + super(message, cause); + } + + public BusinessException(Throwable cause) { + super(cause); + } +} \ No newline at end of file diff --git a/src/main/java/com/fengdu/gas/common/extend/CollectorsPlus.java b/src/main/java/com/fengdu/gas/common/extend/CollectorsPlus.java new file mode 100644 index 0000000..e1880dd --- /dev/null +++ b/src/main/java/com/fengdu/gas/common/extend/CollectorsPlus.java @@ -0,0 +1,1498 @@ +package com.fengdu.gas.common.extend; + +import com.fengdu.gas.common.ToBigDecimalFunction; + +import java.math.BigDecimal; +import java.util.*; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; +import java.util.function.*; +import java.util.stream.Collector; +import java.util.stream.Stream; + +public class CollectorsPlus { + static final Set<Collector.Characteristics> CH_CONCURRENT_ID + = Collections.unmodifiableSet(EnumSet.of(Collector.Characteristics.CONCURRENT, + Collector.Characteristics.UNORDERED, + Collector.Characteristics.IDENTITY_FINISH)); + static final Set<Collector.Characteristics> CH_CONCURRENT_NOID + = Collections.unmodifiableSet(EnumSet.of(Collector.Characteristics.CONCURRENT, + Collector.Characteristics.UNORDERED)); + static final Set<Collector.Characteristics> CH_ID + = Collections.unmodifiableSet(EnumSet.of(Collector.Characteristics.IDENTITY_FINISH)); + static final Set<Collector.Characteristics> CH_UNORDERED_ID + = Collections.unmodifiableSet(EnumSet.of(Collector.Characteristics.UNORDERED, + Collector.Characteristics.IDENTITY_FINISH)); + static final Set<Collector.Characteristics> CH_NOID = Collections.emptySet(); + + private CollectorsPlus() { } + + /** + * Returns a merge function, suitable for use in + * {@link Map#merge(Object, Object, BiFunction) Map.merge()} or + * {@link #toMap(Function, Function, BinaryOperator) toMap()}, which always + * throws {@code IllegalStateException}. This can be used to enforce the + * assumption that the elements being collected are distinct. + * + * @param <T> the type of input arguments to the merge function + * @return a merge function which always throw {@code IllegalStateException} + */ + private static <T> BinaryOperator<T> throwingMerger() { + return (u,v) -> { throw new IllegalStateException(String.format("Duplicate key %s", u)); }; + } + + @SuppressWarnings("unchecked") + private static <I, R> Function<I, R> castingIdentity() { + return i -> (R) i; + } + + /** + * Simple implementation class for {@code Collector}. + * + * @param <T> the type of elements to be collected + * @param <R> the type of the result + */ + static class CollectorImpl<T, A, R> implements Collector<T, A, R> { + private final Supplier<A> supplier; + private final BiConsumer<A, T> accumulator; + private final BinaryOperator<A> combiner; + private final Function<A, R> finisher; + private final Set<Characteristics> characteristics; + + CollectorImpl(Supplier<A> supplier, + BiConsumer<A, T> accumulator, + BinaryOperator<A> combiner, + Function<A,R> finisher, + Set<Characteristics> characteristics) { + this.supplier = supplier; + this.accumulator = accumulator; + this.combiner = combiner; + this.finisher = finisher; + this.characteristics = characteristics; + } + + CollectorImpl(Supplier<A> supplier, + BiConsumer<A, T> accumulator, + BinaryOperator<A> combiner, + Set<Characteristics> characteristics) { + this(supplier, accumulator, combiner, castingIdentity(), characteristics); + } + + @Override + public BiConsumer<A, T> accumulator() { + return accumulator; + } + + @Override + public Supplier<A> supplier() { + return supplier; + } + + @Override + public BinaryOperator<A> combiner() { + return combiner; + } + + @Override + public Function<A, R> finisher() { + return finisher; + } + + @Override + public Set<Characteristics> characteristics() { + return characteristics; + } + } + + /** + * Returns a {@code Collector} that accumulates the input elements into a + * new {@code Collection}, in encounter order. The {@code Collection} is + * created by the provided factory. + * + * @param <T> the type of the input elements + * @param <C> the type of the resulting {@code Collection} + * @param collectionFactory a {@code Supplier} which returns a new, empty + * {@code Collection} of the appropriate type + * @return a {@code Collector} which collects all the input elements into a + * {@code Collection}, in encounter order + */ + public static <T, C extends Collection<T>> + Collector<T, ?, C> toCollection(Supplier<C> collectionFactory) { + return new CollectorImpl<>(collectionFactory, Collection<T>::add, + (r1, r2) -> { r1.addAll(r2); return r1; }, + CH_ID); + } + + /** + * Returns a {@code Collector} that accumulates the input elements into a + * new {@code List}. There are no guarantees on the type, mutability, + * serializability, or thread-safety of the {@code List} returned; if more + * control over the returned {@code List} is required, use {@link #toCollection(Supplier)}. + * + * @param <T> the type of the input elements + * @return a {@code Collector} which collects all the input elements into a + * {@code List}, in encounter order + */ + public static <T> + Collector<T, ?, List<T>> toList() { + return new CollectorImpl<>((Supplier<List<T>>) ArrayList::new, List::add, + (left, right) -> { left.addAll(right); return left; }, + CH_ID); + } + + /** + * Returns a {@code Collector} that accumulates the input elements into a + * new {@code Set}. There are no guarantees on the type, mutability, + * serializability, or thread-safety of the {@code Set} returned; if more + * control over the returned {@code Set} is required, use + * {@link #toCollection(Supplier)}. + * + * <p>This is an {@link Collector.Characteristics#UNORDERED unordered} + * Collector. + * + * @param <T> the type of the input elements + * @return a {@code Collector} which collects all the input elements into a + * {@code Set} + */ + public static <T> + Collector<T, ?, Set<T>> toSet() { + return new CollectorImpl<>((Supplier<Set<T>>) HashSet::new, Set::add, + (left, right) -> { left.addAll(right); return left; }, + CH_UNORDERED_ID); + } + + /** + * Returns a {@code Collector} that concatenates the input elements into a + * {@code String}, in encounter order. + * + * @return a {@code Collector} that concatenates the input elements into a + * {@code String}, in encounter order + */ + public static Collector<CharSequence, ?, String> joining() { + return new CollectorImpl<CharSequence, StringBuilder, String>( + StringBuilder::new, StringBuilder::append, + (r1, r2) -> { r1.append(r2); return r1; }, + StringBuilder::toString, CH_NOID); + } + + /** + * Returns a {@code Collector} that concatenates the input elements, + * separated by the specified delimiter, in encounter order. + * + * @param delimiter the delimiter to be used between each element + * @return A {@code Collector} which concatenates CharSequence elements, + * separated by the specified delimiter, in encounter order + */ + public static Collector<CharSequence, ?, String> joining(CharSequence delimiter) { + return joining(delimiter, "", ""); + } + + /** + * Returns a {@code Collector} that concatenates the input elements, + * separated by the specified delimiter, with the specified prefix and + * suffix, in encounter order. + * + * @param delimiter the delimiter to be used between each element + * @param prefix the sequence of characters to be used at the beginning + * of the joined result + * @param suffix the sequence of characters to be used at the end + * of the joined result + * @return A {@code Collector} which concatenates CharSequence elements, + * separated by the specified delimiter, in encounter order + */ + public static Collector<CharSequence, ?, String> joining(CharSequence delimiter, + CharSequence prefix, + CharSequence suffix) { + return new CollectorImpl<>( + () -> new StringJoiner(delimiter, prefix, suffix), + StringJoiner::add, StringJoiner::merge, + StringJoiner::toString, CH_NOID); + } + + /** + * {@code BinaryOperator<Map>} that merges the contents of its right + * argument into its left argument, using the provided merge function to + * handle duplicate keys. + * + * @param <K> type of the map keys + * @param <V> type of the map values + * @param <M> type of the map + * @param mergeFunction A merge function suitable for + * {@link Map#merge(Object, Object, BiFunction) Map.merge()} + * @return a merge function for two maps + */ + private static <K, V, M extends Map<K,V>> + BinaryOperator<M> mapMerger(BinaryOperator<V> mergeFunction) { + return (m1, m2) -> { + for (Map.Entry<K,V> e : m2.entrySet()) { + m1.merge(e.getKey(), e.getValue(), mergeFunction); + } + return m1; + }; + } + + /** + * Adapts a {@code Collector} accepting elements of type {@code U} to one + * accepting elements of type {@code T} by applying a mapping function to + * each input element before accumulation. + * + * @apiNote + * The {@code mapping()} collectors are most useful when used in a + * multi-level reduction, such as downstream of a {@code groupingBy} or + * {@code partitioningBy}. For example, given a stream of + * {@code Person}, to accumulate the set of last names in each city: + * <pre>{@code + * Map<City, Set<String>> lastNamesByCity + * = people.stream().collect(groupingBy(Person::getCity, + * mapping(Person::getLastName, toSet()))); + * }</pre> + * + * @param <T> the type of the input elements + * @param <U> type of elements accepted by downstream collector + * @param <A> intermediate accumulation type of the downstream collector + * @param <R> result type of collector + * @param mapper a function to be applied to the input elements + * @param downstream a collector which will accept mapped values + * @return a collector which applies the mapping function to the input + * elements and provides the mapped results to the downstream collector + */ + public static <T, U, A, R> + Collector<T, ?, R> mapping(Function<? super T, ? extends U> mapper, + Collector<? super U, A, R> downstream) { + BiConsumer<A, ? super U> downstreamAccumulator = downstream.accumulator(); + return new CollectorImpl<>(downstream.supplier(), + (r, t) -> downstreamAccumulator.accept(r, mapper.apply(t)), + downstream.combiner(), downstream.finisher(), + downstream.characteristics()); + } + + /** + * Adapts a {@code Collector} to perform an additional finishing + * transformation. For example, one could adapt the {@link #toList()} + * collector to always produce an immutable list with: + * <pre>{@code + * List<String> people + * = people.stream().collect(collectingAndThen(toList(), Collections::unmodifiableList)); + * }</pre> + * + * @param <T> the type of the input elements + * @param <A> intermediate accumulation type of the downstream collector + * @param <R> result type of the downstream collector + * @param <RR> result type of the resulting collector + * @param downstream a collector + * @param finisher a function to be applied to the final result of the downstream collector + * @return a collector which performs the action of the downstream collector, + * followed by an additional finishing step + */ + public static<T,A,R,RR> Collector<T,A,RR> collectingAndThen(Collector<T,A,R> downstream, + Function<R,RR> finisher) { + Set<Collector.Characteristics> characteristics = downstream.characteristics(); + if (characteristics.contains(Collector.Characteristics.IDENTITY_FINISH)) { + if (characteristics.size() == 1) + characteristics = CollectorsPlus.CH_NOID; + else { + characteristics = EnumSet.copyOf(characteristics); + characteristics.remove(Collector.Characteristics.IDENTITY_FINISH); + characteristics = Collections.unmodifiableSet(characteristics); + } + } + return new CollectorImpl<>(downstream.supplier(), + downstream.accumulator(), + downstream.combiner(), + downstream.finisher().andThen(finisher), + characteristics); + } + + /** + * Returns a {@code Collector} accepting elements of type {@code T} that + * counts the number of input elements. If no elements are present, the + * result is 0. + * + * @implSpec + * This produces a result equivalent to: + * <pre>{@code + * reducing(0L, e -> 1L, Long::sum) + * }</pre> + * + * @param <T> the type of the input elements + * @return a {@code Collector} that counts the input elements + */ + public static <T> Collector<T, ?, Long> + counting() { + return reducing(0L, e -> 1L, Long::sum); + } + + /** + * Returns a {@code Collector} that produces the minimal element according + * to a given {@code Comparator}, described as an {@code Optional<T>}. + * + * @implSpec + * This produces a result equivalent to: + * <pre>{@code + * reducing(BinaryOperator.minBy(comparator)) + * }</pre> + * + * @param <T> the type of the input elements + * @param comparator a {@code Comparator} for comparing elements + * @return a {@code Collector} that produces the minimal value + */ + public static <T> Collector<T, ?, Optional<T>> + minBy(Comparator<? super T> comparator) { + return reducing(BinaryOperator.minBy(comparator)); + } + + /** + * Returns a {@code Collector} that produces the maximal element according + * to a given {@code Comparator}, described as an {@code Optional<T>}. + * + * @implSpec + * This produces a result equivalent to: + * <pre>{@code + * reducing(BinaryOperator.maxBy(comparator)) + * }</pre> + * + * @param <T> the type of the input elements + * @param comparator a {@code Comparator} for comparing elements + * @return a {@code Collector} that produces the maximal value + */ + public static <T> Collector<T, ?, Optional<T>> + maxBy(Comparator<? super T> comparator) { + return reducing(BinaryOperator.maxBy(comparator)); + } + + /** + * Returns a {@code Collector} that produces the sum of a integer-valued + * function applied to the input elements. If no elements are present, + * the result is 0. + * + * @param <T> the type of the input elements + * @param mapper a function extracting the property to be summed + * @return a {@code Collector} that produces the sum of a derived property + */ + public static <T> Collector<T, ?, Integer> + summingInt(ToIntFunction<? super T> mapper) { + return new CollectorImpl<>( + () -> new int[1], + (a, t) -> { a[0] += mapper.applyAsInt(t); }, + (a, b) -> { a[0] += b[0]; return a; }, + a -> a[0], CH_NOID); + } + + /** + * Returns a {@code Collector} that produces the sum of a long-valued + * function applied to the input elements. If no elements are present, + * the result is 0. + * + * @param <T> the type of the input elements + * @param mapper a function extracting the property to be summed + * @return a {@code Collector} that produces the sum of a derived property + */ + public static <T> Collector<T, ?, Long> + summingLong(ToLongFunction<? super T> mapper) { + return new CollectorImpl<>( + () -> new long[1], + (a, t) -> { a[0] += mapper.applyAsLong(t); }, + (a, b) -> { a[0] += b[0]; return a; }, + a -> a[0], CH_NOID); + } + + /** + * Returns a {@code Collector} that produces the sum of a double-valued + * function applied to the input elements. If no elements are present, + * the result is 0. + * + * <p>The sum returned can vary depending upon the order in which + * values are recorded, due to accumulated rounding error in + * addition of values of differing magnitudes. Values sorted by increasing + * absolute magnitude tend to yield more accurate results. If any recorded + * value is a {@code NaN} or the sum is at any point a {@code NaN} then the + * sum will be {@code NaN}. + * + * @param <T> the type of the input elements + * @param mapper a function extracting the property to be summed + * @return a {@code Collector} that produces the sum of a derived property + */ + public static <T> Collector<T, ?, Double> + summingDouble(ToDoubleFunction<? super T> mapper) { + /* + * In the arrays allocated for the collect operation, index 0 + * holds the high-order bits of the running sum, index 1 holds + * the low-order bits of the sum computed via compensated + * summation, and index 2 holds the simple sum used to compute + * the proper result if the stream contains infinite values of + * the same sign. + */ + return new CollectorImpl<>( + () -> new double[3], + (a, t) -> { sumWithCompensation(a, mapper.applyAsDouble(t)); + a[2] += mapper.applyAsDouble(t);}, + (a, b) -> { sumWithCompensation(a, b[0]); + a[2] += b[2]; + return sumWithCompensation(a, b[1]); }, + a -> computeFinalSum(a), + CH_NOID); + } + + /** + * Incorporate a new double value using Kahan summation / + * compensation summation. + * + * High-order bits of the sum are in intermediateSum[0], low-order + * bits of the sum are in intermediateSum[1], any additional + * elements are application-specific. + * + * @param intermediateSum the high-order and low-order words of the intermediate sum + * @param value the name value to be included in the running sum + */ + static double[] sumWithCompensation(double[] intermediateSum, double value) { + double tmp = value - intermediateSum[1]; + double sum = intermediateSum[0]; + double velvel = sum + tmp; // Little wolf of rounding error + intermediateSum[1] = (velvel - sum) - tmp; + intermediateSum[0] = velvel; + return intermediateSum; + } + + /** + * If the compensated sum is spuriously NaN from accumulating one + * or more same-signed infinite values, return the + * correctly-signed infinity stored in the simple sum. + */ + static double computeFinalSum(double[] summands) { + // Better error bounds to add both terms as the final sum + double tmp = summands[0] + summands[1]; + double simpleSum = summands[summands.length - 1]; + if (Double.isNaN(tmp) && Double.isInfinite(simpleSum)) { + return simpleSum; + } else { + return tmp; + } + } + + /** + * Returns a {@code Collector} that produces the arithmetic mean of an integer-valued + * function applied to the input elements. If no elements are present, + * the result is 0. + * + * @param <T> the type of the input elements + * @param mapper a function extracting the property to be summed + * @return a {@code Collector} that produces the sum of a derived property + */ + public static <T> Collector<T, ?, Double> + averagingInt(ToIntFunction<? super T> mapper) { + return new CollectorImpl<>( + () -> new long[2], + (a, t) -> { a[0] += mapper.applyAsInt(t); a[1]++; }, + (a, b) -> { a[0] += b[0]; a[1] += b[1]; return a; }, + a -> (a[1] == 0) ? 0.0d : (double) a[0] / a[1], CH_NOID); + } + + /** + * Returns a {@code Collector} that produces the arithmetic mean of a long-valued + * function applied to the input elements. If no elements are present, + * the result is 0. + * + * @param <T> the type of the input elements + * @param mapper a function extracting the property to be summed + * @return a {@code Collector} that produces the sum of a derived property + */ + public static <T> Collector<T, ?, Double> + averagingLong(ToLongFunction<? super T> mapper) { + return new CollectorImpl<>( + () -> new long[2], + (a, t) -> { a[0] += mapper.applyAsLong(t); a[1]++; }, + (a, b) -> { a[0] += b[0]; a[1] += b[1]; return a; }, + a -> (a[1] == 0) ? 0.0d : (double) a[0] / a[1], CH_NOID); + } + + /** + * Returns a {@code Collector} that produces the arithmetic mean of a double-valued + * function applied to the input elements. If no elements are present, + * the result is 0. + * + * <p>The average returned can vary depending upon the order in which + * values are recorded, due to accumulated rounding error in + * addition of values of differing magnitudes. Values sorted by increasing + * absolute magnitude tend to yield more accurate results. If any recorded + * value is a {@code NaN} or the sum is at any point a {@code NaN} then the + * average will be {@code NaN}. + * + * @implNote The {@code double} format can represent all + * consecutive integers in the range -2<sup>53</sup> to + * 2<sup>53</sup>. If the pipeline has more than 2<sup>53</sup> + * values, the divisor in the average computation will saturate at + * 2<sup>53</sup>, leading to additional numerical errors. + * + * @param <T> the type of the input elements + * @param mapper a function extracting the property to be summed + * @return a {@code Collector} that produces the sum of a derived property + */ + public static <T> Collector<T, ?, Double> + averagingDouble(ToDoubleFunction<? super T> mapper) { + /* + * In the arrays allocated for the collect operation, index 0 + * holds the high-order bits of the running sum, index 1 holds + * the low-order bits of the sum computed via compensated + * summation, and index 2 holds the number of values seen. + */ + return new CollectorImpl<>( + () -> new double[4], + (a, t) -> { sumWithCompensation(a, mapper.applyAsDouble(t)); a[2]++; a[3]+= mapper.applyAsDouble(t);}, + (a, b) -> { sumWithCompensation(a, b[0]); sumWithCompensation(a, b[1]); a[2] += b[2]; a[3] += b[3]; return a; }, + a -> (a[2] == 0) ? 0.0d : (computeFinalSum(a) / a[2]), + CH_NOID); + } + + /** + * Returns a {@code Collector} which performs a reduction of its + * input elements under a specified {@code BinaryOperator} using the + * provided identity. + * + * @apiNote + * The {@code reducing()} collectors are most useful when used in a + * multi-level reduction, downstream of {@code groupingBy} or + * {@code partitioningBy}. To perform a simple reduction on a stream, + * use {@link Stream#reduce(Object, BinaryOperator)}} instead. + * + * @param <T> element type for the input and output of the reduction + * @param identity the identity value for the reduction (also, the value + * that is returned when there are no input elements) + * @param op a {@code BinaryOperator<T>} used to reduce the input elements + * @return a {@code Collector} which implements the reduction operation + * + * @see #reducing(BinaryOperator) + * @see #reducing(Object, Function, BinaryOperator) + */ + public static <T> Collector<T, ?, T> + reducing(T identity, BinaryOperator<T> op) { + return new CollectorImpl<>( + boxSupplier(identity), + (a, t) -> { a[0] = op.apply(a[0], t); }, + (a, b) -> { a[0] = op.apply(a[0], b[0]); return a; }, + a -> a[0], + CH_NOID); + } + + @SuppressWarnings("unchecked") + private static <T> Supplier<T[]> boxSupplier(T identity) { + return () -> (T[]) new Object[] { identity }; + } + + /** + * Returns a {@code Collector} which performs a reduction of its + * input elements under a specified {@code BinaryOperator}. The result + * is described as an {@code Optional<T>}. + * + * @apiNote + * The {@code reducing()} collectors are most useful when used in a + * multi-level reduction, downstream of {@code groupingBy} or + * {@code partitioningBy}. To perform a simple reduction on a stream, + * use {@link Stream#reduce(BinaryOperator)} instead. + * + * <p>For example, given a stream of {@code Person}, to calculate tallest + * person in each city: + * <pre>{@code + * Comparator<Person> byHeight = Comparator.comparing(Person::getHeight); + * Map<City, Person> tallestByCity + * = people.stream().collect(groupingBy(Person::getCity, reducing(BinaryOperator.maxBy(byHeight)))); + * }</pre> + * + * @param <T> element type for the input and output of the reduction + * @param op a {@code BinaryOperator<T>} used to reduce the input elements + * @return a {@code Collector} which implements the reduction operation + * + * @see #reducing(Object, BinaryOperator) + * @see #reducing(Object, Function, BinaryOperator) + */ + public static <T> Collector<T, ?, Optional<T>> + reducing(BinaryOperator<T> op) { + class OptionalBox implements Consumer<T> { + T value = null; + boolean present = false; + + @Override + public void accept(T t) { + if (present) { + value = op.apply(value, t); + } + else { + value = t; + present = true; + } + } + } + + return new CollectorImpl<T, OptionalBox, Optional<T>>( + OptionalBox::new, OptionalBox::accept, + (a, b) -> { if (b.present) a.accept(b.value); return a; }, + a -> Optional.ofNullable(a.value), CH_NOID); + } + + /** + * Returns a {@code Collector} which performs a reduction of its + * input elements under a specified mapping function and + * {@code BinaryOperator}. This is a generalization of + * {@link #reducing(Object, BinaryOperator)} which allows a transformation + * of the elements before reduction. + * + * @apiNote + * The {@code reducing()} collectors are most useful when used in a + * multi-level reduction, downstream of {@code groupingBy} or + * {@code partitioningBy}. To perform a simple map-reduce on a stream, + * use {@link Stream#map(Function)} and {@link Stream#reduce(Object, BinaryOperator)} + * instead. + * + * <p>For example, given a stream of {@code Person}, to calculate the longest + * last name of residents in each city: + * <pre>{@code + * Comparator<String> byLength = Comparator.comparing(String::length); + * Map<City, String> longestLastNameByCity + * = people.stream().collect(groupingBy(Person::getCity, + * reducing(Person::getLastName, BinaryOperator.maxBy(byLength)))); + * }</pre> + * + * @param <T> the type of the input elements + * @param <U> the type of the mapped values + * @param identity the identity value for the reduction (also, the value + * that is returned when there are no input elements) + * @param mapper a mapping function to apply to each input value + * @param op a {@code BinaryOperator<U>} used to reduce the mapped values + * @return a {@code Collector} implementing the map-reduce operation + * + * @see #reducing(Object, BinaryOperator) + * @see #reducing(BinaryOperator) + */ + public static <T, U> + Collector<T, ?, U> reducing(U identity, + Function<? super T, ? extends U> mapper, + BinaryOperator<U> op) { + return new CollectorImpl<>( + boxSupplier(identity), + (a, t) -> { a[0] = op.apply(a[0], mapper.apply(t)); }, + (a, b) -> { a[0] = op.apply(a[0], b[0]); return a; }, + a -> a[0], CH_NOID); + } + + /** + * Returns a {@code Collector} implementing a "group by" operation on + * input elements of type {@code T}, grouping elements according to a + * classification function, and returning the results in a {@code Map}. + * + * <p>The classification function maps elements to some key type {@code K}. + * The collector produces a {@code Map<K, List<T>>} whose keys are the + * values resulting from applying the classification function to the input + * elements, and whose corresponding values are {@code List}s containing the + * input elements which map to the associated key under the classification + * function. + * + * <p>There are no guarantees on the type, mutability, serializability, or + * thread-safety of the {@code Map} or {@code List} objects returned. + * @implSpec + * This produces a result similar to: + * <pre>{@code + * groupingBy(classifier, toList()); + * }</pre> + * + * @implNote + * The returned {@code Collector} is not concurrent. For parallel stream + * pipelines, the {@code combiner} function operates by merging the keys + * from one map into another, which can be an expensive operation. If + * preservation of the order in which elements appear in the resulting {@code Map} + * collector is not required, using {@link #groupingByConcurrent(Function)} + * may offer better parallel performance. + * + * @param <T> the type of the input elements + * @param <K> the type of the keys + * @param classifier the classifier function mapping input elements to keys + * @return a {@code Collector} implementing the group-by operation + * + * @see #groupingBy(Function, Collector) + * @see #groupingBy(Function, Supplier, Collector) + * @see #groupingByConcurrent(Function) + */ + public static <T, K> Collector<T, ?, Map<K, List<T>>> + groupingBy(Function<? super T, ? extends K> classifier) { + return groupingBy(classifier, toList()); + } + + /** + * Returns a {@code Collector} implementing a cascaded "group by" operation + * on input elements of type {@code T}, grouping elements according to a + * classification function, and then performing a reduction operation on + * the values associated with a given key using the specified downstream + * {@code Collector}. + * + * <p>The classification function maps elements to some key type {@code K}. + * The downstream collector operates on elements of type {@code T} and + * produces a result of type {@code D}. The resulting collector produces a + * {@code Map<K, D>}. + * + * <p>There are no guarantees on the type, mutability, + * serializability, or thread-safety of the {@code Map} returned. + * + * <p>For example, to compute the set of last names of people in each city: + * <pre>{@code + * Map<City, Set<String>> namesByCity + * = people.stream().collect(groupingBy(Person::getCity, + * mapping(Person::getLastName, toSet()))); + * }</pre> + * + * @implNote + * The returned {@code Collector} is not concurrent. For parallel stream + * pipelines, the {@code combiner} function operates by merging the keys + * from one map into another, which can be an expensive operation. If + * preservation of the order in which elements are presented to the downstream + * collector is not required, using {@link #groupingByConcurrent(Function, Collector)} + * may offer better parallel performance. + * + * @param <T> the type of the input elements + * @param <K> the type of the keys + * @param <A> the intermediate accumulation type of the downstream collector + * @param <D> the result type of the downstream reduction + * @param classifier a classifier function mapping input elements to keys + * @param downstream a {@code Collector} implementing the downstream reduction + * @return a {@code Collector} implementing the cascaded group-by operation + * @see #groupingBy(Function) + * + * @see #groupingBy(Function, Supplier, Collector) + * @see #groupingByConcurrent(Function, Collector) + */ + public static <T, K, A, D> + Collector<T, ?, Map<K, D>> groupingBy(Function<? super T, ? extends K> classifier, + Collector<? super T, A, D> downstream) { + return groupingBy(classifier, HashMap::new, downstream); + } + + /** + * Returns a {@code Collector} implementing a cascaded "group by" operation + * on input elements of type {@code T}, grouping elements according to a + * classification function, and then performing a reduction operation on + * the values associated with a given key using the specified downstream + * {@code Collector}. The {@code Map} produced by the Collector is created + * with the supplied factory function. + * + * <p>The classification function maps elements to some key type {@code K}. + * The downstream collector operates on elements of type {@code T} and + * produces a result of type {@code D}. The resulting collector produces a + * {@code Map<K, D>}. + * + * <p>For example, to compute the set of last names of people in each city, + * where the city names are sorted: + * <pre>{@code + * Map<City, Set<String>> namesByCity + * = people.stream().collect(groupingBy(Person::getCity, TreeMap::new, + * mapping(Person::getLastName, toSet()))); + * }</pre> + * + * @implNote + * The returned {@code Collector} is not concurrent. For parallel stream + * pipelines, the {@code combiner} function operates by merging the keys + * from one map into another, which can be an expensive operation. If + * preservation of the order in which elements are presented to the downstream + * collector is not required, using {@link #groupingByConcurrent(Function, Supplier, Collector)} + * may offer better parallel performance. + * + * @param <T> the type of the input elements + * @param <K> the type of the keys + * @param <A> the intermediate accumulation type of the downstream collector + * @param <D> the result type of the downstream reduction + * @param <M> the type of the resulting {@code Map} + * @param classifier a classifier function mapping input elements to keys + * @param downstream a {@code Collector} implementing the downstream reduction + * @param mapFactory a function which, when called, produces a new empty + * {@code Map} of the desired type + * @return a {@code Collector} implementing the cascaded group-by operation + * + * @see #groupingBy(Function, Collector) + * @see #groupingBy(Function) + * @see #groupingByConcurrent(Function, Supplier, Collector) + */ + public static <T, K, D, A, M extends Map<K, D>> + Collector<T, ?, M> groupingBy(Function<? super T, ? extends K> classifier, + Supplier<M> mapFactory, + Collector<? super T, A, D> downstream) { + Supplier<A> downstreamSupplier = downstream.supplier(); + BiConsumer<A, ? super T> downstreamAccumulator = downstream.accumulator(); + BiConsumer<Map<K, A>, T> accumulator = (m, t) -> { + K key = Objects.requireNonNull(classifier.apply(t), "element cannot be mapped to a null key"); + A container = m.computeIfAbsent(key, k -> downstreamSupplier.get()); + downstreamAccumulator.accept(container, t); + }; + BinaryOperator<Map<K, A>> merger = CollectorsPlus.<K, A, Map<K, A>>mapMerger(downstream.combiner()); + @SuppressWarnings("unchecked") + Supplier<Map<K, A>> mangledFactory = (Supplier<Map<K, A>>) mapFactory; + + if (downstream.characteristics().contains(Collector.Characteristics.IDENTITY_FINISH)) { + return new CollectorImpl<>(mangledFactory, accumulator, merger, CH_ID); + } + else { + @SuppressWarnings("unchecked") + Function<A, A> downstreamFinisher = (Function<A, A>) downstream.finisher(); + Function<Map<K, A>, M> finisher = intermediate -> { + intermediate.replaceAll((k, v) -> downstreamFinisher.apply(v)); + @SuppressWarnings("unchecked") + M castResult = (M) intermediate; + return castResult; + }; + return new CollectorImpl<>(mangledFactory, accumulator, merger, finisher, CH_NOID); + } + } + + /** + * Returns a concurrent {@code Collector} implementing a "group by" + * operation on input elements of type {@code T}, grouping elements + * according to a classification function. + * + * <p>This is a {@link Collector.Characteristics#CONCURRENT concurrent} and + * {@link Collector.Characteristics#UNORDERED unordered} Collector. + * + * <p>The classification function maps elements to some key type {@code K}. + * The collector produces a {@code ConcurrentMap<K, List<T>>} whose keys are the + * values resulting from applying the classification function to the input + * elements, and whose corresponding values are {@code List}s containing the + * input elements which map to the associated key under the classification + * function. + * + * <p>There are no guarantees on the type, mutability, or serializability + * of the {@code Map} or {@code List} objects returned, or of the + * thread-safety of the {@code List} objects returned. + * @implSpec + * This produces a result similar to: + * <pre>{@code + * groupingByConcurrent(classifier, toList()); + * }</pre> + * + * @param <T> the type of the input elements + * @param <K> the type of the keys + * @param classifier a classifier function mapping input elements to keys + * @return a concurrent, unordered {@code Collector} implementing the group-by operation + * + * @see #groupingBy(Function) + * @see #groupingByConcurrent(Function, Collector) + * @see #groupingByConcurrent(Function, Supplier, Collector) + */ + public static <T, K> + Collector<T, ?, ConcurrentMap<K, List<T>>> + groupingByConcurrent(Function<? super T, ? extends K> classifier) { + return groupingByConcurrent(classifier, ConcurrentHashMap::new, toList()); + } + + /** + * Returns a concurrent {@code Collector} implementing a cascaded "group by" + * operation on input elements of type {@code T}, grouping elements + * according to a classification function, and then performing a reduction + * operation on the values associated with a given key using the specified + * downstream {@code Collector}. + * + * <p>This is a {@link Collector.Characteristics#CONCURRENT concurrent} and + * {@link Collector.Characteristics#UNORDERED unordered} Collector. + * + * <p>The classification function maps elements to some key type {@code K}. + * The downstream collector operates on elements of type {@code T} and + * produces a result of type {@code D}. The resulting collector produces a + * {@code Map<K, D>}. + * + * <p>For example, to compute the set of last names of people in each city, + * where the city names are sorted: + * <pre>{@code + * ConcurrentMap<City, Set<String>> namesByCity + * = people.stream().collect(groupingByConcurrent(Person::getCity, + * mapping(Person::getLastName, toSet()))); + * }</pre> + * + * @param <T> the type of the input elements + * @param <K> the type of the keys + * @param <A> the intermediate accumulation type of the downstream collector + * @param <D> the result type of the downstream reduction + * @param classifier a classifier function mapping input elements to keys + * @param downstream a {@code Collector} implementing the downstream reduction + * @return a concurrent, unordered {@code Collector} implementing the cascaded group-by operation + * + * @see #groupingBy(Function, Collector) + * @see #groupingByConcurrent(Function) + * @see #groupingByConcurrent(Function, Supplier, Collector) + */ + public static <T, K, A, D> + Collector<T, ?, ConcurrentMap<K, D>> groupingByConcurrent(Function<? super T, ? extends K> classifier, + Collector<? super T, A, D> downstream) { + return groupingByConcurrent(classifier, ConcurrentHashMap::new, downstream); + } + + /** + * Returns a concurrent {@code Collector} implementing a cascaded "group by" + * operation on input elements of type {@code T}, grouping elements + * according to a classification function, and then performing a reduction + * operation on the values associated with a given key using the specified + * downstream {@code Collector}. The {@code ConcurrentMap} produced by the + * Collector is created with the supplied factory function. + * + * <p>This is a {@link Collector.Characteristics#CONCURRENT concurrent} and + * {@link Collector.Characteristics#UNORDERED unordered} Collector. + * + * <p>The classification function maps elements to some key type {@code K}. + * The downstream collector operates on elements of type {@code T} and + * produces a result of type {@code D}. The resulting collector produces a + * {@code Map<K, D>}. + * + * <p>For example, to compute the set of last names of people in each city, + * where the city names are sorted: + * <pre>{@code + * ConcurrentMap<City, Set<String>> namesByCity + * = people.stream().collect(groupingBy(Person::getCity, ConcurrentSkipListMap::new, + * mapping(Person::getLastName, toSet()))); + * }</pre> + * + * + * @param <T> the type of the input elements + * @param <K> the type of the keys + * @param <A> the intermediate accumulation type of the downstream collector + * @param <D> the result type of the downstream reduction + * @param <M> the type of the resulting {@code ConcurrentMap} + * @param classifier a classifier function mapping input elements to keys + * @param downstream a {@code Collector} implementing the downstream reduction + * @param mapFactory a function which, when called, produces a new empty + * {@code ConcurrentMap} of the desired type + * @return a concurrent, unordered {@code Collector} implementing the cascaded group-by operation + * + * @see #groupingByConcurrent(Function) + * @see #groupingByConcurrent(Function, Collector) + * @see #groupingBy(Function, Supplier, Collector) + */ + public static <T, K, A, D, M extends ConcurrentMap<K, D>> + Collector<T, ?, M> groupingByConcurrent(Function<? super T, ? extends K> classifier, + Supplier<M> mapFactory, + Collector<? super T, A, D> downstream) { + Supplier<A> downstreamSupplier = downstream.supplier(); + BiConsumer<A, ? super T> downstreamAccumulator = downstream.accumulator(); + BinaryOperator<ConcurrentMap<K, A>> merger = CollectorsPlus.<K, A, ConcurrentMap<K, A>>mapMerger(downstream.combiner()); + @SuppressWarnings("unchecked") + Supplier<ConcurrentMap<K, A>> mangledFactory = (Supplier<ConcurrentMap<K, A>>) mapFactory; + BiConsumer<ConcurrentMap<K, A>, T> accumulator; + if (downstream.characteristics().contains(Collector.Characteristics.CONCURRENT)) { + accumulator = (m, t) -> { + K key = Objects.requireNonNull(classifier.apply(t), "element cannot be mapped to a null key"); + A resultContainer = m.computeIfAbsent(key, k -> downstreamSupplier.get()); + downstreamAccumulator.accept(resultContainer, t); + }; + } + else { + accumulator = (m, t) -> { + K key = Objects.requireNonNull(classifier.apply(t), "element cannot be mapped to a null key"); + A resultContainer = m.computeIfAbsent(key, k -> downstreamSupplier.get()); + synchronized (resultContainer) { + downstreamAccumulator.accept(resultContainer, t); + } + }; + } + + if (downstream.characteristics().contains(Collector.Characteristics.IDENTITY_FINISH)) { + return new CollectorImpl<>(mangledFactory, accumulator, merger, CH_CONCURRENT_ID); + } + else { + @SuppressWarnings("unchecked") + Function<A, A> downstreamFinisher = (Function<A, A>) downstream.finisher(); + Function<ConcurrentMap<K, A>, M> finisher = intermediate -> { + intermediate.replaceAll((k, v) -> downstreamFinisher.apply(v)); + @SuppressWarnings("unchecked") + M castResult = (M) intermediate; + return castResult; + }; + return new CollectorImpl<>(mangledFactory, accumulator, merger, finisher, CH_CONCURRENT_NOID); + } + } + + /** + * Returns a {@code Collector} which partitions the input elements according + * to a {@code Predicate}, and organizes them into a + * {@code Map<Boolean, List<T>>}. + * + * There are no guarantees on the type, mutability, + * serializability, or thread-safety of the {@code Map} returned. + * + * @param <T> the type of the input elements + * @param predicate a predicate used for classifying input elements + * @return a {@code Collector} implementing the partitioning operation + * + * @see #partitioningBy(Predicate, Collector) + */ + public static <T> + Collector<T, ?, Map<Boolean, List<T>>> partitioningBy(Predicate<? super T> predicate) { + return partitioningBy(predicate, toList()); + } + + /** + * Returns a {@code Collector} which partitions the input elements according + * to a {@code Predicate}, reduces the values in each partition according to + * another {@code Collector}, and organizes them into a + * {@code Map<Boolean, D>} whose values are the result of the downstream + * reduction. + * + * <p>There are no guarantees on the type, mutability, + * serializability, or thread-safety of the {@code Map} returned. + * + * @param <T> the type of the input elements + * @param <A> the intermediate accumulation type of the downstream collector + * @param <D> the result type of the downstream reduction + * @param predicate a predicate used for classifying input elements + * @param downstream a {@code Collector} implementing the downstream + * reduction + * @return a {@code Collector} implementing the cascaded partitioning + * operation + * + * @see #partitioningBy(Predicate) + */ + public static <T, D, A> + Collector<T, ?, Map<Boolean, D>> partitioningBy(Predicate<? super T> predicate, + Collector<? super T, A, D> downstream) { + BiConsumer<A, ? super T> downstreamAccumulator = downstream.accumulator(); + BiConsumer<Partition<A>, T> accumulator = (result, t) -> + downstreamAccumulator.accept(predicate.test(t) ? result.forTrue : result.forFalse, t); + BinaryOperator<A> op = downstream.combiner(); + BinaryOperator<Partition<A>> merger = (left, right) -> + new Partition<>(op.apply(left.forTrue, right.forTrue), + op.apply(left.forFalse, right.forFalse)); + Supplier<Partition<A>> supplier = () -> + new Partition<>(downstream.supplier().get(), + downstream.supplier().get()); + if (downstream.characteristics().contains(Collector.Characteristics.IDENTITY_FINISH)) { + return new CollectorImpl<>(supplier, accumulator, merger, CH_ID); + } + else { + Function<Partition<A>, Map<Boolean, D>> finisher = par -> + new Partition<>(downstream.finisher().apply(par.forTrue), + downstream.finisher().apply(par.forFalse)); + return new CollectorImpl<>(supplier, accumulator, merger, finisher, CH_NOID); + } + } + + /** + * Returns a {@code Collector} that accumulates elements into a + * {@code Map} whose keys and values are the result of applying the provided + * mapping functions to the input elements. + * + * <p>If the mapped keys contains duplicates (according to + * {@link Object#equals(Object)}), an {@code IllegalStateException} is + * thrown when the collection operation is performed. If the mapped keys + * may have duplicates, use {@link #toMap(Function, Function, BinaryOperator)} + * instead. + * + * @apiNote + * It is common for either the key or the value to be the input elements. + * In this case, the utility method + * {@link Function#identity()} may be helpful. + * For example, the following produces a {@code Map} mapping + * students to their grade point average: + * <pre>{@code + * Map<Student, Double> studentToGPA + * students.stream().collect(toMap(Functions.identity(), + * student -> computeGPA(student))); + * }</pre> + * And the following produces a {@code Map} mapping a unique identifier to + * students: + * <pre>{@code + * Map<String, Student> studentIdToStudent + * students.stream().collect(toMap(Student::getId, + * Functions.identity()); + * }</pre> + * + * @implNote + * The returned {@code Collector} is not concurrent. For parallel stream + * pipelines, the {@code combiner} function operates by merging the keys + * from one map into another, which can be an expensive operation. If it is + * not required that results are inserted into the {@code Map} in encounter + * order, using {@link #toConcurrentMap(Function, Function)} + * may offer better parallel performance. + * + * @param <T> the type of the input elements + * @param <K> the output type of the key mapping function + * @param <U> the output type of the value mapping function + * @param keyMapper a mapping function to produce keys + * @param valueMapper a mapping function to produce values + * @return a {@code Collector} which collects elements into a {@code Map} + * whose keys and values are the result of applying mapping functions to + * the input elements + * + * @see #toMap(Function, Function, BinaryOperator) + * @see #toMap(Function, Function, BinaryOperator, Supplier) + * @see #toConcurrentMap(Function, Function) + */ + public static <T, K, U> + Collector<T, ?, Map<K,U>> toMap(Function<? super T, ? extends K> keyMapper, + Function<? super T, ? extends U> valueMapper) { + return toMap(keyMapper, valueMapper, throwingMerger(), HashMap::new); + } + + /** + * Returns a {@code Collector} that accumulates elements into a + * {@code Map} whose keys and values are the result of applying the provided + * mapping functions to the input elements. + * + * <p>If the mapped + * keys contains duplicates (according to {@link Object#equals(Object)}), + * the value mapping function is applied to each equal element, and the + * results are merged using the provided merging function. + * + * @apiNote + * There are multiple ways to deal with collisions between multiple elements + * mapping to the same key. The other forms of {@code toMap} simply use + * a merge function that throws unconditionally, but you can easily write + * more flexible merge policies. For example, if you have a stream + * of {@code Person}, and you want to produce a "phone book" mapping name to + * address, but it is possible that two persons have the same name, you can + * do as follows to gracefully deals with these collisions, and produce a + * {@code Map} mapping names to a concatenated list of addresses: + * <pre>{@code + * Map<String, String> phoneBook + * people.stream().collect(toMap(Person::getName, + * Person::getAddress, + * (s, a) -> s + ", " + a)); + * }</pre> + * + * @implNote + * The returned {@code Collector} is not concurrent. For parallel stream + * pipelines, the {@code combiner} function operates by merging the keys + * from one map into another, which can be an expensive operation. If it is + * not required that results are merged into the {@code Map} in encounter + * order, using {@link #toConcurrentMap(Function, Function, BinaryOperator)} + * may offer better parallel performance. + * + * @param <T> the type of the input elements + * @param <K> the output type of the key mapping function + * @param <U> the output type of the value mapping function + * @param keyMapper a mapping function to produce keys + * @param valueMapper a mapping function to produce values + * @param mergeFunction a merge function, used to resolve collisions between + * values associated with the same key, as supplied + * to {@link Map#merge(Object, Object, BiFunction)} + * @return a {@code Collector} which collects elements into a {@code Map} + * whose keys are the result of applying a key mapping function to the input + * elements, and whose values are the result of applying a value mapping + * function to all input elements equal to the key and combining them + * using the merge function + * + * @see #toMap(Function, Function) + * @see #toMap(Function, Function, BinaryOperator, Supplier) + * @see #toConcurrentMap(Function, Function, BinaryOperator) + */ + public static <T, K, U> + Collector<T, ?, Map<K,U>> toMap(Function<? super T, ? extends K> keyMapper, + Function<? super T, ? extends U> valueMapper, + BinaryOperator<U> mergeFunction) { + return toMap(keyMapper, valueMapper, mergeFunction, HashMap::new); + } + + /** + * Returns a {@code Collector} that accumulates elements into a + * {@code Map} whose keys and values are the result of applying the provided + * mapping functions to the input elements. + * + * <p>If the mapped + * keys contains duplicates (according to {@link Object#equals(Object)}), + * the value mapping function is applied to each equal element, and the + * results are merged using the provided merging function. The {@code Map} + * is created by a provided supplier function. + * + * @implNote + * The returned {@code Collector} is not concurrent. For parallel stream + * pipelines, the {@code combiner} function operates by merging the keys + * from one map into another, which can be an expensive operation. If it is + * not required that results are merged into the {@code Map} in encounter + * order, using {@link #toConcurrentMap(Function, Function, BinaryOperator, Supplier)} + * may offer better parallel performance. + * + * @param <T> the type of the input elements + * @param <K> the output type of the key mapping function + * @param <U> the output type of the value mapping function + * @param <M> the type of the resulting {@code Map} + * @param keyMapper a mapping function to produce keys + * @param valueMapper a mapping function to produce values + * @param mergeFunction a merge function, used to resolve collisions between + * values associated with the same key, as supplied + * to {@link Map#merge(Object, Object, BiFunction)} + * @param mapSupplier a function which returns a new, empty {@code Map} into + * which the results will be inserted + * @return a {@code Collector} which collects elements into a {@code Map} + * whose keys are the result of applying a key mapping function to the input + * elements, and whose values are the result of applying a value mapping + * function to all input elements equal to the key and combining them + * using the merge function + * + * @see #toMap(Function, Function) + * @see #toMap(Function, Function, BinaryOperator) + * @see #toConcurrentMap(Function, Function, BinaryOperator, Supplier) + */ + public static <T, K, U, M extends Map<K, U>> + Collector<T, ?, M> toMap(Function<? super T, ? extends K> keyMapper, + Function<? super T, ? extends U> valueMapper, + BinaryOperator<U> mergeFunction, + Supplier<M> mapSupplier) { + BiConsumer<M, T> accumulator + = (map, element) -> map.merge(keyMapper.apply(element), + valueMapper.apply(element), mergeFunction); + return new CollectorImpl<>(mapSupplier, accumulator, mapMerger(mergeFunction), CH_ID); + } + + /** + * Returns a concurrent {@code Collector} that accumulates elements into a + * {@code ConcurrentMap} whose keys and values are the result of applying + * the provided mapping functions to the input elements. + * + * <p>If the mapped keys contains duplicates (according to + * {@link Object#equals(Object)}), an {@code IllegalStateException} is + * thrown when the collection operation is performed. If the mapped keys + * may have duplicates, use + * {@link #toConcurrentMap(Function, Function, BinaryOperator)} instead. + * + * @apiNote + * It is common for either the key or the value to be the input elements. + * In this case, the utility method + * {@link Function#identity()} may be helpful. + * For example, the following produces a {@code Map} mapping + * students to their grade point average: + * <pre>{@code + * Map<Student, Double> studentToGPA + * students.stream().collect(toMap(Functions.identity(), + * student -> computeGPA(student))); + * }</pre> + * And the following produces a {@code Map} mapping a unique identifier to + * students: + * <pre>{@code + * Map<String, Student> studentIdToStudent + * students.stream().collect(toConcurrentMap(Student::getId, + * Functions.identity()); + * }</pre> + * + * <p>This is a {@link Collector.Characteristics#CONCURRENT concurrent} and + * {@link Collector.Characteristics#UNORDERED unordered} Collector. + * + * @param <T> the type of the input elements + * @param <K> the output type of the key mapping function + * @param <U> the output type of the value mapping function + * @param keyMapper the mapping function to produce keys + * @param valueMapper the mapping function to produce values + * @return a concurrent, unordered {@code Collector} which collects elements into a + * {@code ConcurrentMap} whose keys are the result of applying a key mapping + * function to the input elements, and whose values are the result of + * applying a value mapping function to the input elements + * + * @see #toMap(Function, Function) + * @see #toConcurrentMap(Function, Function, BinaryOperator) + * @see #toConcurrentMap(Function, Function, BinaryOperator, Supplier) + */ + public static <T, K, U> + Collector<T, ?, ConcurrentMap<K,U>> toConcurrentMap(Function<? super T, ? extends K> keyMapper, + Function<? super T, ? extends U> valueMapper) { + return toConcurrentMap(keyMapper, valueMapper, throwingMerger(), ConcurrentHashMap::new); + } + + /** + * Returns a concurrent {@code Collector} that accumulates elements into a + * {@code ConcurrentMap} whose keys and values are the result of applying + * the provided mapping functions to the input elements. + * + * <p>If the mapped keys contains duplicates (according to {@link Object#equals(Object)}), + * the value mapping function is applied to each equal element, and the + * results are merged using the provided merging function. + * + * @apiNote + * There are multiple ways to deal with collisions between multiple elements + * mapping to the same key. The other forms of {@code toConcurrentMap} simply use + * a merge function that throws unconditionally, but you can easily write + * more flexible merge policies. For example, if you have a stream + * of {@code Person}, and you want to produce a "phone book" mapping name to + * address, but it is possible that two persons have the same name, you can + * do as follows to gracefully deals with these collisions, and produce a + * {@code Map} mapping names to a concatenated list of addresses: + * <pre>{@code + * Map<String, String> phoneBook + * people.stream().collect(toConcurrentMap(Person::getName, + * Person::getAddress, + * (s, a) -> s + ", " + a)); + * }</pre> + * + * <p>This is a {@link Collector.Characteristics#CONCURRENT concurrent} and + * {@link Collector.Characteristics#UNORDERED unordered} Collector. + * + * @param <T> the type of the input elements + * @param <K> the output type of the key mapping function + * @param <U> the output type of the value mapping function + * @param keyMapper a mapping function to produce keys + * @param valueMapper a mapping function to produce values + * @param mergeFunction a merge function, used to resolve collisions between + * values associated with the same key, as supplied + * to {@link Map#merge(Object, Object, BiFunction)} + * @return a concurrent, unordered {@code Collector} which collects elements into a + * {@code ConcurrentMap} whose keys are the result of applying a key mapping + * function to the input elements, and whose values are the result of + * applying a value mapping function to all input elements equal to the key + * and combining them using the merge function + * + * @see #toConcurrentMap(Function, Function) + * @see #toConcurrentMap(Function, Function, BinaryOperator, Supplier) + * @see #toMap(Function, Function, BinaryOperator) + */ + public static <T, K, U> + Collector<T, ?, ConcurrentMap<K,U>> + toConcurrentMap(Function<? super T, ? extends K> keyMapper, + Function<? super T, ? extends U> valueMapper, + BinaryOperator<U> mergeFunction) { + return toConcurrentMap(keyMapper, valueMapper, mergeFunction, ConcurrentHashMap::new); + } + + /** + * Returns a concurrent {@code Collector} that accumulates elements into a + * {@code ConcurrentMap} whose keys and values are the result of applying + * the provided mapping functions to the input elements. + * + * <p>If the mapped keys contains duplicates (according to {@link Object#equals(Object)}), + * the value mapping function is applied to each equal element, and the + * results are merged using the provided merging function. The + * {@code ConcurrentMap} is created by a provided supplier function. + * + * <p>This is a {@link Collector.Characteristics#CONCURRENT concurrent} and + * {@link Collector.Characteristics#UNORDERED unordered} Collector. + * + * @param <T> the type of the input elements + * @param <K> the output type of the key mapping function + * @param <U> the output type of the value mapping function + * @param <M> the type of the resulting {@code ConcurrentMap} + * @param keyMapper a mapping function to produce keys + * @param valueMapper a mapping function to produce values + * @param mergeFunction a merge function, used to resolve collisions between + * values associated with the same key, as supplied + * to {@link Map#merge(Object, Object, BiFunction)} + * @param mapSupplier a function which returns a new, empty {@code Map} into + * which the results will be inserted + * @return a concurrent, unordered {@code Collector} which collects elements into a + * {@code ConcurrentMap} whose keys are the result of applying a key mapping + * function to the input elements, and whose values are the result of + * applying a value mapping function to all input elements equal to the key + * and combining them using the merge function + * + * @see #toConcurrentMap(Function, Function) + * @see #toConcurrentMap(Function, Function, BinaryOperator) + * @see #toMap(Function, Function, BinaryOperator, Supplier) + */ + public static <T, K, U, M extends ConcurrentMap<K, U>> + Collector<T, ?, M> toConcurrentMap(Function<? super T, ? extends K> keyMapper, + Function<? super T, ? extends U> valueMapper, + BinaryOperator<U> mergeFunction, + Supplier<M> mapSupplier) { + BiConsumer<M, T> accumulator + = (map, element) -> map.merge(keyMapper.apply(element), + valueMapper.apply(element), mergeFunction); + return new CollectorImpl<>(mapSupplier, accumulator, mapMerger(mergeFunction), CH_CONCURRENT_ID); + } + + /** + * Returns a {@code Collector} which applies an {@code int}-producing + * mapping function to each input element, and returns summary statistics + * for the resulting values. + * + * @param <T> the type of the input elements + * @param mapper a mapping function to apply to each element + * @return a {@code Collector} implementing the summary-statistics reduction + * + * @see #summarizingDouble(ToDoubleFunction) + * @see #summarizingLong(ToLongFunction) + */ + public static <T> + Collector<T, ?, IntSummaryStatistics> summarizingInt(ToIntFunction<? super T> mapper) { + return new CollectorImpl<T, IntSummaryStatistics, IntSummaryStatistics>( + IntSummaryStatistics::new, + (r, t) -> r.accept(mapper.applyAsInt(t)), + (l, r) -> { l.combine(r); return l; }, CH_ID); + } + + /** + * Returns a {@code Collector} which applies an {@code long}-producing + * mapping function to each input element, and returns summary statistics + * for the resulting values. + * + * @param <T> the type of the input elements + * @param mapper the mapping function to apply to each element + * @return a {@code Collector} implementing the summary-statistics reduction + * + * @see #summarizingDouble(ToDoubleFunction) + * @see #summarizingInt(ToIntFunction) + */ + public static <T> + Collector<T, ?, LongSummaryStatistics> summarizingLong(ToLongFunction<? super T> mapper) { + return new CollectorImpl<T, LongSummaryStatistics, LongSummaryStatistics>( + LongSummaryStatistics::new, + (r, t) -> r.accept(mapper.applyAsLong(t)), + (l, r) -> { l.combine(r); return l; }, CH_ID); + } + + /** + * Returns a {@code Collector} which applies an {@code double}-producing + * mapping function to each input element, and returns summary statistics + * for the resulting values. + * + * @param <T> the type of the input elements + * @param mapper a mapping function to apply to each element + * @return a {@code Collector} implementing the summary-statistics reduction + * + * @see #summarizingLong(ToLongFunction) + * @see #summarizingInt(ToIntFunction) + */ + public static <T> + Collector<T, ?, DoubleSummaryStatistics> summarizingDouble(ToDoubleFunction<? super T> mapper) { + return new CollectorImpl<T, DoubleSummaryStatistics, DoubleSummaryStatistics>( + DoubleSummaryStatistics::new, + (r, t) -> r.accept(mapper.applyAsDouble(t)), + (l, r) -> { l.combine(r); return l; }, CH_ID); + } + + /** + * BigDecimal求和 + * @Author lin.liu + * @Description BigDecimal求和 + * @Date 2021/8/26 + * @Param [mapper] + * @return java.util.stream.Collector<T,?,java.math.BigDecimal> + **/ + public static <T> Collector<T, ?, BigDecimal> summingBigDecimal(ToBigDecimalFunction<? super T> mapper) { + return new CollectorImpl<>(() -> new BigDecimal[1], (a, t) -> { + if (a[0] == null) { + a[0] = BigDecimal.ZERO; + } + a[0] = a[0].add(mapper.applyAsBigDecimal(t)); + }, (a, b) -> { + a[0] = a[0].add(b[0]); + return a; + }, a -> a[0], CH_NOID); + } + + /** + * Implementation class used by partitioningBy. + */ + private static final class Partition<T> + extends AbstractMap<Boolean, T> + implements Map<Boolean, T> { + final T forTrue; + final T forFalse; + + Partition(T forTrue, T forFalse) { + this.forTrue = forTrue; + this.forFalse = forFalse; + } + + @Override + public Set<Entry<Boolean, T>> entrySet() { + return new AbstractSet<Entry<Boolean, T>>() { + @Override + public Iterator<Entry<Boolean, T>> iterator() { + Entry<Boolean, T> falseEntry = new SimpleImmutableEntry<>(false, forFalse); + Entry<Boolean, T> trueEntry = new SimpleImmutableEntry<>(true, forTrue); + return Arrays.asList(falseEntry, trueEntry).iterator(); + } + + @Override + public int size() { + return 2; + } + }; + } + } +} diff --git a/src/main/java/com/fengdu/gas/common/jackson/BigNumberSerializer.java b/src/main/java/com/fengdu/gas/common/jackson/BigNumberSerializer.java new file mode 100644 index 0000000..de5442b --- /dev/null +++ b/src/main/java/com/fengdu/gas/common/jackson/BigNumberSerializer.java @@ -0,0 +1,40 @@ +package com.fengdu.gas.common.jackson; + +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.annotation.JacksonStdImpl; +import com.fasterxml.jackson.databind.ser.std.NumberSerializer; + +import java.io.IOException; + +@JacksonStdImpl +public class BigNumberSerializer extends NumberSerializer { + /** + * 根据JS NUmber.MAX SAFE INTEGER与NUmber.MIN SAFE INTEGER 得来 + */ + private static final long MAX_SAFE_INTEGER = 9007199254740991L; + private static final long MIN_SAFE_INTEGER = -9007199254740991L; + + /** + * 提供实例 + */ + public static final BigNumberSerializer INSTANCE = new BigNumberSerializer(Number.class); + + public BigNumberSerializer(Class<? extends Number> rawType) { + super(rawType); + } + + + @Override + + public void serialize(Number value, JsonGenerator gen, SerializerProvider provider) throws IOException { +//超出范围 序列化位字符串 + if (value.longValue() > MIN_SAFE_INTEGER && value.longValue() < MAX_SAFE_INTEGER){ + super.serialize(value, gen, provider); + } else{ + gen.writeString(value.toString()); + } + } +} + + diff --git a/src/main/java/com/fengdu/gas/common/jackson/JacksonConfig.java b/src/main/java/com/fengdu/gas/common/jackson/JacksonConfig.java new file mode 100644 index 0000000..1ddbf85 --- /dev/null +++ b/src/main/java/com/fengdu/gas/common/jackson/JacksonConfig.java @@ -0,0 +1,40 @@ +package com.fengdu.gas.common.jackson; + +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; +import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer; +import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer; +import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import java.math.BigDecimal; +import java.math.BigInteger; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.TimeZone; + +@Configuration +public class JacksonConfig { + /** + * jackson 配置 + * @return + */ + @Bean + public Jackson2ObjectMapperBuilderCustomizer customizer() { + return builder -> { + //全局配置序列化返回 JSON 处理 + JavaTimeModule javaTimeModule = new JavaTimeModule(); + javaTimeModule.addSerializer(Long.class, BigNumberSerializer.INSTANCE); + javaTimeModule.addSerializer(Long.TYPE, BigNumberSerializer.INSTANCE); + javaTimeModule.addSerializer(BigInteger.class, BigNumberSerializer.INSTANCE); + javaTimeModule.addSerializer(BigDecimal.class, ToStringSerializer.instance); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH : mm: ss"); + javaTimeModule.addSerializer(LocalDateTime.class, new LocalDateTimeSerializer(formatter)); + javaTimeModule.addDeserializer(LocalDateTime.class, new LocalDateTimeDeserializer(formatter)); + builder.modules(javaTimeModule); + builder.timeZone(TimeZone.getDefault()); + System.out.println("初始化 jackson 配置"); + }; + } +} diff --git a/src/main/java/com/fengdu/gas/common/jwt/JWTUtil.java b/src/main/java/com/fengdu/gas/common/jwt/JWTUtil.java new file mode 100644 index 0000000..6a3ee3e --- /dev/null +++ b/src/main/java/com/fengdu/gas/common/jwt/JWTUtil.java @@ -0,0 +1,85 @@ +package com.fengdu.gas.common.jwt; + +import com.auth0.jwt.JWT; +import com.auth0.jwt.JWTCreator; +import com.auth0.jwt.JWTVerifier; +import com.auth0.jwt.algorithms.Algorithm; +import com.auth0.jwt.exceptions.TokenExpiredException; +import com.auth0.jwt.interfaces.DecodedJWT; +import com.fengdu.gas.common.config.SysConfig; +import com.fengdu.gas.common.enums.EResultCode; +import com.fengdu.gas.common.exceptions.BusinessException; +import com.fengdu.gas.common.util.LocalDateTimeUtil; +import com.fengdu.gas.common.util.NumericUtil; +import com.fengdu.gas.common.util.StringUtil; +import com.fengdu.gas.common.ConstantFactory; + +import java.time.LocalDateTime; +import java.util.Date; + +public class JWTUtil { + /** + * @return token中包含的用户名 + */ + public static LoginUserDTO getUser(String token) { + if (StringUtil.isNullOrEmpty(token)) { + throw new BusinessException(EResultCode.UNAUTHORIZED, "尚未登录"); + } + JWTVerifier verifier = JWT.require(Algorithm.HMAC256(SysConfig.jwt.getSecret())) + .build(); + DecodedJWT jwt = null; + try { + + jwt = verifier.verify(token); + } catch (TokenExpiredException e) { + throw new BusinessException(EResultCode.UNAUTHORIZED, "token已过期"); + } catch (Exception e) { + throw new BusinessException(EResultCode.UNAUTHORIZED, "token格式不正确." + token); + } + if (null == jwt) { + throw new BusinessException(EResultCode.UNAUTHORIZED, "token已过期"); + } + Date expiresAt = jwt.getExpiresAt(); + + LocalDateTime dtExpires = LocalDateTimeUtil.getDateTime(expiresAt.getTime()); + if (dtExpires.isBefore(LocalDateTimeUtil.nowDateTime())) { + throw new BusinessException(EResultCode.UNAUTHORIZED, "token已过期"); + } + LoginUserDTO loginUser = new LoginUserDTO(); + loginUser.setUserId(jwt.getClaim("userId").asString()); + loginUser.setUserType(NumericUtil.tryParseInt(jwt.getClaim("userType").asString(), 0)); + loginUser.setPhone(jwt.getClaim("phone").asString()); + loginUser.setPhone(jwt.getClaim("phone").asString()); + loginUser.setNickName(jwt.getClaim("nickName").asString()); + loginUser.setHeadImg(jwt.getClaim("headImg").asString()); + loginUser.setListRole(StringUtil.splitLongList(jwt.getClaim("listRole").asString())); + loginUser.setListRoleName(StringUtil.splitList(jwt.getClaim("listRoleName").asString())); + + return loginUser; + } + + /** + * 生成token,并保存到jwt + * + * @param loginUser 登录用户信息 + * @return 加密的token + */ + public static String getToken(LoginUserDTO loginUser) { + JWTCreator.Builder builder = JWT.create() + //设置jwt生成时间 + .withIssuedAt(new Date(LocalDateTimeUtil.nowTimeStamp())) + //设置token有效期 + .withExpiresAt(new Date(LocalDateTimeUtil.nowTimeStamp() + SysConfig.jwt.getExpiration() * ConstantFactory.TIME_LEN_1S)); + builder.withClaim("userId", loginUser.getUserId()); + builder.withClaim("userType", loginUser.getUserType().toString()); + builder.withClaim("phone", loginUser.getPhone()); + builder.withClaim("nickName", loginUser.getNickName()); + builder.withClaim("headImg", loginUser.getHeadImg()); + builder.withClaim("listRole", StringUtil.joinLong(loginUser.getListRole())); + builder.withClaim("listRoleName", StringUtil.join(loginUser.getListRoleName())); + return builder + //生成token字符串 + .sign(Algorithm.HMAC256(SysConfig.jwt.getSecret())) + ; + } +} \ No newline at end of file diff --git a/src/main/java/com/fengdu/gas/common/jwt/LoginUserDTO.java b/src/main/java/com/fengdu/gas/common/jwt/LoginUserDTO.java new file mode 100644 index 0000000..516fee5 --- /dev/null +++ b/src/main/java/com/fengdu/gas/common/jwt/LoginUserDTO.java @@ -0,0 +1,114 @@ +package com.fengdu.gas.common.jwt; + +import java.util.List; + +public class LoginUserDTO { + /** + * 身份令牌 + */ + private String token; + /** + * 用户唯一标识 + */ + private String userId; + /** + * 用户类型 EUserType + */ + private Integer userType; + /** + * 用户名称 + */ + private String userName; + /** + * 手机号 + */ + private String phone; + /** + * 昵称 + */ + private String nickName; + /** + * 头像 + */ + private String headImg; + /** + * 拥有角色列表 + */ + private List<Long> listRole; + /** + * 拥有角色-名称列表 + */ + private List<String> listRoleName; + + public String getToken() { + return token; + } + + public void setToken(String token) { + this.token = token; + } + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public Integer getUserType() { + return userType; + } + + public void setUserType(Integer userType) { + this.userType = userType; + } + + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + + public String getNickName() { + return nickName; + } + + public void setNickName(String nickName) { + this.nickName = nickName; + } + + public String getHeadImg() { + return headImg; + } + + public void setHeadImg(String headImg) { + this.headImg = headImg; + } + + public List<Long> getListRole() { + return listRole; + } + + public void setListRole(List<Long> listRole) { + this.listRole = listRole; + } + + public List<String> getListRoleName() { + return listRoleName; + } + + public void setListRoleName(List<String> listRoleName) { + this.listRoleName = listRoleName; + } +} diff --git a/src/main/java/com/fengdu/gas/common/model/ExcelDiscernCell.java b/src/main/java/com/fengdu/gas/common/model/ExcelDiscernCell.java new file mode 100644 index 0000000..290df39 --- /dev/null +++ b/src/main/java/com/fengdu/gas/common/model/ExcelDiscernCell.java @@ -0,0 +1,31 @@ +package com.fengdu.gas.common.model; + +public class ExcelDiscernCell { + private int cellIndex; + private String name; + private String value; + + public int getCellIndex() { + return cellIndex; + } + + public void setCellIndex(int cellIndex) { + this.cellIndex = cellIndex; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } +} \ No newline at end of file diff --git a/src/main/java/com/fengdu/gas/common/model/ExcelDiscernRow.java b/src/main/java/com/fengdu/gas/common/model/ExcelDiscernRow.java new file mode 100644 index 0000000..672ece3 --- /dev/null +++ b/src/main/java/com/fengdu/gas/common/model/ExcelDiscernRow.java @@ -0,0 +1,24 @@ +package com.fengdu.gas.common.model; + +import java.util.List; + +public class ExcelDiscernRow { + private int rowIndx; + List<ExcelDiscernCell> listCell; + + public int getRowIndx() { + return rowIndx; + } + + public void setRowIndx(int rowIndx) { + this.rowIndx = rowIndx; + } + + public List<ExcelDiscernCell> getListCell() { + return listCell; + } + + public void setListCell(List<ExcelDiscernCell> listCell) { + this.listCell = listCell; + } +} \ No newline at end of file diff --git a/src/main/java/com/fengdu/gas/common/model/ResFileUpload.java b/src/main/java/com/fengdu/gas/common/model/ResFileUpload.java new file mode 100644 index 0000000..0bdc75e --- /dev/null +++ b/src/main/java/com/fengdu/gas/common/model/ResFileUpload.java @@ -0,0 +1,96 @@ +package com.fengdu.gas.common.model; + +/** + * 文件上传 响应dto + */ +public class ResFileUpload { + /** + * 文件名 + */ + public String fileId; + + /** + * 文件名 + */ + public String fileName; + + /** + * 是否上传成功 + */ + public Boolean isSuccess; + + /** + * 上传错误消息 + */ + public String errorMsg; + + /** + * 保存文件地址(数据库保存) + */ + public String newFilePath; + + /** + * 文件下载/预览地址 + */ + public String newFullPath; + + public String getFileId() { + return fileId; + } + + public void setFileId(String fileId) { + this.fileId = fileId; + } + + public String getFileName() { + return fileName; + } + + public void setFileName(String fileName) { + this.fileName = fileName; + } + + public Boolean getIsSuccess() { + return isSuccess; + } + + public void setIsSuccess(Boolean isSuccess) { + this.isSuccess = isSuccess; + } + + public String getErrorMsg() { + return errorMsg; + } + + public void setErrorMsg(String errorMsg) { + this.errorMsg = errorMsg; + } + + public String getNewFilePath() { + return newFilePath; + } + + public void setNewFilePath(String newFilePath) { + this.newFilePath = newFilePath; + } + + public String getNewFullPath() { + return newFullPath; + } + + public void setNewFullPath(String newFullPath) { + this.newFullPath = newFullPath; + } + + @Override + public String toString() { + return "ResFileUpload{" + + "fileId='" + fileId + '\'' + + ", fileName='" + fileName + '\'' + + ", isSuccess=" + isSuccess + + ", errorMsg='" + errorMsg + '\'' + + ", newFilePath='" + newFilePath + '\'' + + ", newFullPath='" + newFullPath + '\'' + + '}'; + } +} \ No newline at end of file diff --git a/src/main/java/com/fengdu/gas/common/model/Tuple.java b/src/main/java/com/fengdu/gas/common/model/Tuple.java new file mode 100644 index 0000000..1bfd6f6 --- /dev/null +++ b/src/main/java/com/fengdu/gas/common/model/Tuple.java @@ -0,0 +1,35 @@ +package com.fengdu.gas.common.model; + +/** + * 2个泛型参数返回结果 + * @param <T1> 参数1的类型 + * @param <T2> 参数2的类型 + */ +public class Tuple<T1, T2> { + private T1 item1; + private T2 item2; + + public Tuple() { + } + + public Tuple(T1 item1, T2 item2) { + this.item1 = item1; + this.item2 = item2; + } + + public T1 getItem1() { + return this.item1; + } + + public void setItem1(T1 item1) { + this.item1 = item1; + } + + public T2 getItem2() { + return this.item2; + } + + public void setItem2(T2 item2) { + this.item2 = item2; + } +} \ No newline at end of file diff --git a/src/main/java/com/fengdu/gas/common/security/Base64Util.java b/src/main/java/com/fengdu/gas/common/security/Base64Util.java new file mode 100644 index 0000000..4535b9d --- /dev/null +++ b/src/main/java/com/fengdu/gas/common/security/Base64Util.java @@ -0,0 +1,119 @@ +package com.fengdu.gas.common.security; + +import com.fengdu.gas.common.util.StringUtil; + +import java.nio.charset.Charset; +import java.util.Base64; + +/** + * Base64工具类 + * @author linliu + * @date 2019-06-14 + */ +public final class Base64Util { + private Base64Util() { + throw new IllegalStateException("Utility class"); + } + private static final String DEFAULT = "utf-8"; + + /** + * base64解码(utf-8编码) + * @author linliu + * @date 2019-06-14 + * @param str 密文字符串 + * @return 解码后的明文 + */ + public static String encode(String str) { + return encode(str, DEFAULT); + } + /** + * base64解码 + * @author linliu + * @date 2019-06-14 + * @param str 密文字符串 + * @param encoding 编码格式[默认utf-8] + * @return 解码后的明文 + */ + public static String encode(String str, String encoding) { + if(StringUtil.isNullOrEmpty(str)) { + return ""; + } + if(StringUtil.isNullOrEmpty(encoding)) { + encoding = DEFAULT; + } + byte[] bytes = str.getBytes(Charset.forName(encoding)); + return Base64.getEncoder().encodeToString(bytes); + } + /** + * base64解码(utf-8编码) + * @author linliu + * @date 2019-06-14 + * @param str 密文字符串 + * @return 解码后的明文 + */ + public static String decode(String str) { + return decode(str, DEFAULT); + } + /** + * base64解码 + * @author linliu + * @date 2019-06-14 + * @param str 密文字符串 + * @param encoding 编码格式[默认utf-8] + * @return 解码后的明文 + */ + public static String decode(String str, String encoding) { + if(StringUtil.isNullOrEmpty(str)) { + return ""; + } + if(StringUtil.isNullOrEmpty(encoding)) { + encoding = DEFAULT; + } + byte[] bytes = Base64.getDecoder().decode(str); + return new String(bytes, Charset.forName(encoding)); + } + + /** + * 二进制流转成base64字符串 + * @param buffer 二进制数组 + * @return 编码后的base64字符串 + */ + public static String encodeStream(final byte[] buffer) { + return Base64.getEncoder().encodeToString(buffer); + } + + /** + * 二进制流转成base64流 + * @param buffer 二进制数组 + * @return 编码后的base64流 + */ + public static byte[] encodeToStream(final byte[] buffer) { + return Base64.getEncoder().encode(buffer); + } + + /** + * base64字符串转成二进制流 + * @param str 密文字符串 + * @return 解码后的文件流 + */ + public static byte[] decodeToStream(String str) { + try { + return Base64.getDecoder().decode(str); + } catch (Exception e) { + return new byte[0]; + } + } + + /** + * base64字符串转成二进制流 + * @param buffer 密文流 + * @return 解码后的文件流 + */ + public static byte[] decodeToStream(final byte[] buffer) { + try { + return Base64.getDecoder().decode(buffer); + } catch (Exception e) { + return new byte[0]; + } + } +} \ No newline at end of file diff --git a/src/main/java/com/fengdu/gas/common/security/Des3Util.java b/src/main/java/com/fengdu/gas/common/security/Des3Util.java new file mode 100644 index 0000000..1e0eedb --- /dev/null +++ b/src/main/java/com/fengdu/gas/common/security/Des3Util.java @@ -0,0 +1,146 @@ +package com.fengdu.gas.common.security; + +import com.fengdu.gas.common.enums.ELogger; +import com.fengdu.gas.common.util.LoggerUtil; +import org.slf4j.Logger; + +import javax.crypto.Cipher; +import javax.crypto.KeyGenerator; +import javax.crypto.SecretKey; +import javax.crypto.SecretKeyFactory; +import javax.crypto.spec.DESedeKeySpec; +import javax.crypto.spec.IvParameterSpec; +import java.nio.charset.Charset; +import java.security.InvalidKeyException; +import java.security.Key; +import java.security.NoSuchAlgorithmException; +import java.security.SecureRandom; +import java.security.spec.InvalidKeySpecException; +import java.util.UUID; + + +public final class Des3Util { + private Des3Util() { + throw new IllegalStateException("Utility class"); + } + + private static final Logger sysLogger = LoggerUtil.get(ELogger.SYS_ERROR); + + private static final String TITLE = "Des3加密工具"; + + //默认加密偏移量 + private static byte[] DEFAULT_IV = { 0x23, (byte)0xf2, (byte)0xa3, (byte)0xc6, 0x3e, 0x2b, (byte)0xe7, 0x28 }; + //加密算法 + private static final String ALGORITHM = "DESede"; + // 加解密统一使用的编码方式 + private static final String DEFAULT_ENCODING = "utf-8"; + //密钥 + public static final String DEFAULT_KEY = "com.ctrip.tour.cq.soa.v1"; + + /** + * 生成加密偏移量 + * @param iv 偏移量 + */ + private static IvParameterSpec IvGenerator(byte[] iv) throws Exception { + IvParameterSpec result = new IvParameterSpec(iv); + return result; + } + + /** + * 随机生成一个key + */ + public static String genKey() throws NoSuchAlgorithmException { + byte[] keyBytes = UUID.randomUUID().toString().getBytes(); + KeyGenerator generator = KeyGenerator.getInstance(ALGORITHM); + generator.init(new SecureRandom( keyBytes ) ); + SecretKey key = generator.generateKey(); + return Base64Util.encodeStream(key.getEncoded()); + } + /** + * 根据明文字符串生成key(key长度必须 大于等于 24) + */ + public static Key genKey(String key) throws InvalidKeyException, NoSuchAlgorithmException, InvalidKeySpecException { + DESedeKeySpec spec = new DESedeKeySpec(key.getBytes()); + SecretKeyFactory keyfactory = SecretKeyFactory.getInstance(ALGORITHM); + return keyfactory.generateSecret(spec); + } + + /** + * 加密以byte[]明文输入,byte[]密文输出 + * @param buffer 待加密的字节码 + * @param key 密钥(key长度必须 大于等于 24) + * @return 加密后的字节码 + */ + private static byte[] encrypt(byte[] buffer, String key) { + byte[] result = null; + try { + Cipher cipher = Cipher.getInstance(ALGORITHM +"/CBC/PKCS5Padding"); + IvParameterSpec IVSpec = IvGenerator(DEFAULT_IV); + cipher.init(Cipher.ENCRYPT_MODE, genKey(key), IVSpec); + byte[] temp = cipher.doFinal(buffer); + result = Base64Util.encodeToStream(temp); + } catch (Exception e) { + sysLogger.error("Des3Util.encrypt", e); + } + return result; + } + /** + * 解密以byte[]密文输入,以byte[]明文输出 + * @param buffer 待解密的字节码 + * @param key 密钥(key长度必须是8的倍数) + * @return 解密后的字节码 + */ + private static byte[] decrypt(byte[] buffer, String key) { + byte[] result = null; + try { + IvParameterSpec IVSpec = IvGenerator(DEFAULT_IV); + Cipher cipher = Cipher.getInstance(ALGORITHM +"/CBC/PKCS5Padding"); + cipher.init(Cipher.DECRYPT_MODE, genKey(key), IVSpec); + byte[] temp = Base64Util.decodeToStream(buffer); + result = cipher.doFinal(temp); + } catch (Exception e) { + sysLogger.error("Des3Util.decrypt", e); + } + return result; + } + + /** + * 加密String 明文输入密文输出 + * @param str 待加密的明文 + * @param key 密钥(key长度必须 大于等于 24) + * @return 加密后的字符串 + */ + public static String encrypt(String str, String key) throws Exception { + byte[] buffer = str.getBytes(Charset.forName(DEFAULT_ENCODING)); + byte[] result = encrypt(buffer, key); + return new String(result); + } + /** + * 解密String 以密文输入明文输出 + * @param str 需要解密的字符串 + * @param key 密钥(key长度必须 大于等于 24) + * @return 解密后的字符串 + */ + public static String decrypt(String str, String key) { + byte[] buffer = str.getBytes(Charset.forName(DEFAULT_ENCODING)); + byte[] result = decrypt(buffer, key); + return new String(result).trim(); + } + + /** + * 加密String 明文输入密文输出 + * @param str 待加密的明文 + * @return 加密后的字符串 + */ + public static String encrypt(String str) throws Exception { + return encrypt(str, DEFAULT_KEY); + } + /** + * 解密String 以密文输入明文输出 + * @param str 需要解密的字符串 + * @return 解密后的字符串 + */ + public static String decrypt(String str) { + return decrypt(str, DEFAULT_KEY); + } +} \ No newline at end of file diff --git a/src/main/java/com/fengdu/gas/common/security/MD5Util.java b/src/main/java/com/fengdu/gas/common/security/MD5Util.java new file mode 100644 index 0000000..edb993a --- /dev/null +++ b/src/main/java/com/fengdu/gas/common/security/MD5Util.java @@ -0,0 +1,70 @@ +package com.fengdu.gas.common.security; + +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; + +public class MD5Util { + private MD5Util() { + throw new IllegalStateException("Utility class"); + } + + /** + * 生成32位md5码 + * @param content 待加密明文字符串 + * @return 加密串 + */ + public static String encrypt(String content) { + //region 加盐方式 + try { + // 得到一个信息摘要器 + MessageDigest digest = MessageDigest.getInstance("md5"); + byte[] result = digest.digest(content.getBytes()); + StringBuilder sb = new StringBuilder(); + // 把每一个byte 做一个与运算 0xff; + for (byte b : result) { + // 与运算 + int number = b & 0xff;// 加盐 + String str = Integer.toHexString(number); + if (str.length() == 1) { + sb.append("0"); + } + sb.append(str); + } + // 标准的md5加密后的结果 + return sb.toString(); + } catch (NoSuchAlgorithmException e) { + e.printStackTrace(); + return ""; + } + //endregion + + //region 普通方式 + + /*char hexDigits[] = { + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' + }; + try { + byte[] btInput = content.getBytes(); + // 获得MD5摘要算法的 MessageDigest 对象 + MessageDigest mdInst = MessageDigest.getInstance("MD5"); + // 使用指定的字节更新摘要 + mdInst.update(btInput); + // 获得密文 + byte[] md = mdInst.digest(); + // 把密文转换成十六进制的字符串形式 + int j = md.length; + char str[] = new char[j * 2]; + int k = 0; + for (int i = 0; i < j; i++) { + byte byte0 = md[i]; + str[k++] = hexDigits[byte0 >>> 4 & 0xf]; + str[k++] = hexDigits[byte0 & 0xf]; + } + return new String(str); + } catch (Exception e) { + return ""; + }*/ + + //endregion + } +} \ No newline at end of file diff --git a/src/main/java/com/fengdu/gas/common/serializer/CQCalendarSerializer.java b/src/main/java/com/fengdu/gas/common/serializer/CQCalendarSerializer.java new file mode 100644 index 0000000..939b13f --- /dev/null +++ b/src/main/java/com/fengdu/gas/common/serializer/CQCalendarSerializer.java @@ -0,0 +1,24 @@ +package com.fengdu.gas.common.serializer; + +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.databind.JsonSerializer; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fengdu.gas.common.util.CalendarUtil; + +import java.io.IOException; +import java.util.Calendar; + +/** + * 自定义json序列化 Calendar 属性 + * @author linliu + * @date 2020-05-12 + */ +public class CQCalendarSerializer extends JsonSerializer<Calendar> { + @Override + public void serialize(Calendar value, JsonGenerator g, SerializerProvider provider) throws IOException { + if(null==value) { + return; + } + g.writeString(CalendarUtil.toDateTimeStr(value)); + } +} \ No newline at end of file diff --git a/src/main/java/com/fengdu/gas/common/serializer/CQDateSerializer.java b/src/main/java/com/fengdu/gas/common/serializer/CQDateSerializer.java new file mode 100644 index 0000000..c747924 --- /dev/null +++ b/src/main/java/com/fengdu/gas/common/serializer/CQDateSerializer.java @@ -0,0 +1,26 @@ +package com.fengdu.gas.common.serializer; + +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.databind.JsonSerializer; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fengdu.gas.common.ConstantFactory; + +import java.io.IOException; +import java.text.SimpleDateFormat; +import java.util.Date; + +/** + * 自定义json序列化 Date 属性 + * @author linliu + * @date 2020-05-12 + */ +public class CQDateSerializer extends JsonSerializer<Date> { + @Override + public void serialize(Date value, JsonGenerator g, SerializerProvider provider) throws IOException { + if(null==value) { + return; + } + SimpleDateFormat sdf = new SimpleDateFormat(ConstantFactory.STR_DATE); + g.writeString(sdf.format(value)); + } +} \ No newline at end of file diff --git a/src/main/java/com/fengdu/gas/common/serializer/CQLocalDateSerializer.java b/src/main/java/com/fengdu/gas/common/serializer/CQLocalDateSerializer.java new file mode 100644 index 0000000..776d5d1 --- /dev/null +++ b/src/main/java/com/fengdu/gas/common/serializer/CQLocalDateSerializer.java @@ -0,0 +1,20 @@ +package com.fengdu.gas.common.serializer; + +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.databind.JsonSerializer; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fengdu.gas.common.util.LocalDateTimeUtil; + +import java.io.IOException; +import java.time.LocalDate; + +/** + * 自定义json序列化 LocalDate 属性 + * @author linliu + * @date 2020-05-12 + */ +public class CQLocalDateSerializer extends JsonSerializer<LocalDate> { + public void serialize(LocalDate value, JsonGenerator g, SerializerProvider provider) throws IOException { + g.writeString(LocalDateTimeUtil.toFormatString(value)); + } +} \ No newline at end of file diff --git a/src/main/java/com/fengdu/gas/common/serializer/CQLocalDateTimeSerializer.java b/src/main/java/com/fengdu/gas/common/serializer/CQLocalDateTimeSerializer.java new file mode 100644 index 0000000..c0b6535 --- /dev/null +++ b/src/main/java/com/fengdu/gas/common/serializer/CQLocalDateTimeSerializer.java @@ -0,0 +1,21 @@ +package com.fengdu.gas.common.serializer; + +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.databind.JsonSerializer; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fengdu.gas.common.util.LocalDateTimeUtil; + +import java.io.IOException; +import java.time.LocalDateTime; + +/** + * 自定义json序列化 LocalDateTime 属性 + * @author linliu + * @date 2020-05-12 + */ +public class CQLocalDateTimeSerializer extends JsonSerializer<LocalDateTime> { + @Override + public void serialize(LocalDateTime value, JsonGenerator g, SerializerProvider provider) throws IOException { + g.writeString(LocalDateTimeUtil.toFormatFullString(value)); + } +} \ No newline at end of file diff --git a/src/main/java/com/fengdu/gas/common/serializer/CQTimestampSerializer.java b/src/main/java/com/fengdu/gas/common/serializer/CQTimestampSerializer.java new file mode 100644 index 0000000..041910a --- /dev/null +++ b/src/main/java/com/fengdu/gas/common/serializer/CQTimestampSerializer.java @@ -0,0 +1,24 @@ +package com.fengdu.gas.common.serializer; + +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.databind.JsonSerializer; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fengdu.gas.common.util.LocalDateTimeUtil; + +import java.io.IOException; +import java.sql.Timestamp; + +/** + * 自定义json序列化 Timestamp 属性 + * @author linliu + * @date 2020-05-12 + */ +public class CQTimestampSerializer extends JsonSerializer<Timestamp> { + @Override + public void serialize(Timestamp value, JsonGenerator g, SerializerProvider provider) throws IOException { + if(null==value) { + return; + } + g.writeString(LocalDateTimeUtil.toFormatFullString(value)); + } +} \ No newline at end of file diff --git a/src/main/java/com/fengdu/gas/common/serializer/deserializer/CQCalendarDeSerializer.java b/src/main/java/com/fengdu/gas/common/serializer/deserializer/CQCalendarDeSerializer.java new file mode 100644 index 0000000..fe62dea --- /dev/null +++ b/src/main/java/com/fengdu/gas/common/serializer/deserializer/CQCalendarDeSerializer.java @@ -0,0 +1,44 @@ +package com.fengdu.gas.common.serializer.deserializer; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonDeserializer; +import com.fengdu.gas.common.ConstantFactory; +import com.fengdu.gas.common.util.CalendarUtil; +import com.fengdu.gas.common.util.NumericUtil; +import com.fengdu.gas.common.util.StringUtil; + +import java.io.IOException; +import java.util.Calendar; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * 自定义json反序列化 Calendar 属性 + * @author linliu + * @date 2020-05-12 + */ +public class CQCalendarDeSerializer extends JsonDeserializer<Calendar> { + @Override + public Calendar deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + String value = p.getText(); + + if(StringUtil.isMatch(value, ConstantFactory.REGEX_DATE)) { + return CalendarUtil.fromDateStr(value); + } else if(StringUtil.isMatch(value, ConstantFactory.REGEX_DATETIME)) { + return CalendarUtil.fromDateTimeStr(value); + } else if(StringUtil.isMatch(value, ConstantFactory.REGEX_DATETIME_FULL)) { + return CalendarUtil.fromDateTimeMSStr(value); + } else if(StringUtil.isMatch(value, ConstantFactory.REGEX_DATETIME_JAVA)) { + Pattern pattern = Pattern.compile(ConstantFactory.REGEX_DATETIME_JAVA); + Matcher matcher = pattern.matcher(value); + if(matcher.find()) { + String timestamp = matcher.group("timestamp"); + return CalendarUtil.fromMillis(NumericUtil.tryParseLong(timestamp)); + } + } else if(StringUtil.isMatch(value, "^[0-9]{13}$")) { + return CalendarUtil.fromMillis(NumericUtil.tryParseLong(value)); + } + throw new IOException("can't be deserialize as type “Calendar”, " + value); + } +} \ No newline at end of file diff --git a/src/main/java/com/fengdu/gas/common/serializer/deserializer/CQDateDeSerializer.java b/src/main/java/com/fengdu/gas/common/serializer/deserializer/CQDateDeSerializer.java new file mode 100644 index 0000000..d5ded5c --- /dev/null +++ b/src/main/java/com/fengdu/gas/common/serializer/deserializer/CQDateDeSerializer.java @@ -0,0 +1,33 @@ +package com.fengdu.gas.common.serializer.deserializer; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonDeserializer; +import com.fengdu.gas.common.ConstantFactory; +import com.fengdu.gas.common.util.LocalDateTimeUtil; +import com.fengdu.gas.common.util.StringUtil; + +import java.io.IOException; +import java.time.Instant; +import java.time.LocalDateTime; +import java.time.ZoneOffset; +import java.util.Date; + +/** + * 自定义json反序列化 Date 属性 + * @author linliu + * @date 2020-05-12 + */ +public class CQDateDeSerializer extends JsonDeserializer<Date> { + @Override + public Date deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + String value = p.getText(); + if(StringUtil.isMatch(value, ConstantFactory.REGEX_DATE)) { + LocalDateTime date = LocalDateTimeUtil.getDateTime(value, ConstantFactory.STR_DATE); + Instant instant = date.toInstant(ZoneOffset.UTC); + return Date.from(instant); + } else { + throw new IOException("can't be deserialize as type “Date”, " + value); + } + } +} \ No newline at end of file diff --git a/src/main/java/com/fengdu/gas/common/serializer/deserializer/CQLocalDateDeSerializer.java b/src/main/java/com/fengdu/gas/common/serializer/deserializer/CQLocalDateDeSerializer.java new file mode 100644 index 0000000..407a674 --- /dev/null +++ b/src/main/java/com/fengdu/gas/common/serializer/deserializer/CQLocalDateDeSerializer.java @@ -0,0 +1,28 @@ +package com.fengdu.gas.common.serializer.deserializer; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonDeserializer; +import com.fengdu.gas.common.ConstantFactory; +import com.fengdu.gas.common.util.LocalDateTimeUtil; +import com.fengdu.gas.common.util.StringUtil; + +import java.io.IOException; +import java.time.LocalDate; + +/** + * 自定义json反序列化 LocalDate 属性 + * @author linliu + * @date 2020-05-12 + */ +public class CQLocalDateDeSerializer extends JsonDeserializer<LocalDate> { + @Override + public LocalDate deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + String value = p.getText(); + if(StringUtil.isMatch(value, ConstantFactory.REGEX_DATE)) { + return LocalDateTimeUtil.getDate(value); + } else { + throw new IOException("can't be deserialize as type “LocalDate”, " + value); + } + } +} \ No newline at end of file diff --git a/src/main/java/com/fengdu/gas/common/serializer/deserializer/CQLocalDateTimeDeSerializer.java b/src/main/java/com/fengdu/gas/common/serializer/deserializer/CQLocalDateTimeDeSerializer.java new file mode 100644 index 0000000..68083c1 --- /dev/null +++ b/src/main/java/com/fengdu/gas/common/serializer/deserializer/CQLocalDateTimeDeSerializer.java @@ -0,0 +1,35 @@ +package com.fengdu.gas.common.serializer.deserializer; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonDeserializer; +import com.fengdu.gas.common.ConstantFactory; +import com.fengdu.gas.common.util.LocalDateTimeUtil; +import com.fengdu.gas.common.util.NumericUtil; +import com.fengdu.gas.common.util.StringUtil; + +import java.io.IOException; +import java.time.LocalDateTime; + +/** + * 自定义json反序列化 LocalDateTime 属性 + * @author linliu + * @date 2020-05-12 + */ +public class CQLocalDateTimeDeSerializer extends JsonDeserializer<LocalDateTime> { + @Override + public LocalDateTime deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + String value = p.getText(); + if(StringUtil.isMatch(value, ConstantFactory.REGEX_DATE)) { + return LocalDateTimeUtil.getDateTime(value, ConstantFactory.STR_DATE); + } else if(StringUtil.isMatch(value, ConstantFactory.REGEX_DATETIME)) { + return LocalDateTimeUtil.getDateTime(value); + } else if(StringUtil.isMatch(value, ConstantFactory.REGEX_DATETIME_FULL)) { + return LocalDateTimeUtil.getDateTime(value, ConstantFactory.STR_DATE_FULLMS); + } else if(StringUtil.isMatch(value, "^[0-9]{13}$")) { + return LocalDateTimeUtil.getDateTime(NumericUtil.tryParseLong(value)); + } else { + throw new IOException("can't be deserialize as type “LocalDateTime”, " + value); + } + } +} \ No newline at end of file diff --git a/src/main/java/com/fengdu/gas/common/serializer/deserializer/CQTimestampDeSerializer.java b/src/main/java/com/fengdu/gas/common/serializer/deserializer/CQTimestampDeSerializer.java new file mode 100644 index 0000000..e8290bf --- /dev/null +++ b/src/main/java/com/fengdu/gas/common/serializer/deserializer/CQTimestampDeSerializer.java @@ -0,0 +1,35 @@ +package com.fengdu.gas.common.serializer.deserializer; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonDeserializer; +import com.fengdu.gas.common.ConstantFactory; +import com.fengdu.gas.common.util.LocalDateTimeUtil; +import com.fengdu.gas.common.util.NumericUtil; +import com.fengdu.gas.common.util.StringUtil; + +import java.io.IOException; +import java.sql.Timestamp; + +/** + * 自定义json反序列化 LocalDateTime 属性 + * @author linliu + * @date 2020-07-03 + */ +public class CQTimestampDeSerializer extends JsonDeserializer<Timestamp> { + @Override + public Timestamp deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + String value = p.getText(); + if(StringUtil.isMatch(value, ConstantFactory.REGEX_DATE)) { + return LocalDateTimeUtil.getTimeStamp(value, ConstantFactory.STR_DATE); + } else if(StringUtil.isMatch(value, ConstantFactory.REGEX_DATETIME)) { + return LocalDateTimeUtil.getTimeStamp(value); + } else if(StringUtil.isMatch(value, ConstantFactory.REGEX_DATETIME_FULL)) { + return LocalDateTimeUtil.getTimeStamp(value, ConstantFactory.STR_DATE_FULLMS); + } else if(StringUtil.isMatch(value, "^[0-9]{13}$")) { + return LocalDateTimeUtil.getTimeStamp(NumericUtil.tryParseLong(value)); + } else { + throw new IOException("can't be deserialize as type “Timestamp”, " + value); + } + } +} \ No newline at end of file diff --git a/src/main/java/com/fengdu/gas/common/util/CalendarUtil.java b/src/main/java/com/fengdu/gas/common/util/CalendarUtil.java new file mode 100644 index 0000000..2453b8b --- /dev/null +++ b/src/main/java/com/fengdu/gas/common/util/CalendarUtil.java @@ -0,0 +1,378 @@ +package com.fengdu.gas.common.util; + +import com.fengdu.gas.common.ConstantFactory; + +import java.sql.Timestamp; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.time.Instant; +import java.util.*; + +/** + * 日期处理类 + * @author xiangyuanzhang + * @date 2018-12-25 + */ +public final class CalendarUtil { + static final Long ONE_DAYMS = 86400000L; + private static final int ONE_SECONDS = 1000; + + private CalendarUtil() { + throw new IllegalStateException("Utility class"); + } + + /** + * 获取当前时区时间 + * @param origin + */ + public static Calendar toLocal(Calendar origin) { + if(origin == null) { + return null; + } else if(origin.getTimeZone().equals(TimeZone.getDefault())) { + return origin; + } else { + Calendar calendar = Calendar.getInstance(); + calendar.setTimeInMillis(origin.getTimeInMillis()); + return calendar; + } + } + + public static int daysBetween(Calendar timeStart, Calendar timeEnd) { + long time1 = timeStart.getTimeInMillis(); + long time2 = timeEnd.getTimeInMillis(); + long betweenDays = (time2 - time1) / ONE_DAYMS; + return Integer.parseInt(String.valueOf(betweenDays)); + } + + /** + * 获取当前时间 + */ + public static Calendar getNow() { + Calendar calendar = Calendar.getInstance(); + calendar.setTime(new Date()); + return calendar; + } + + public static Calendar getNow(int days) { + Calendar calendar = getNow(); + calendar.add(Calendar.DAY_OF_MONTH, days); + return calendar; + } + + public static Calendar fromCalendarInDate(Calendar time) { + Calendar calendar = null; + if(time != null) { + try { + String ex = toDateStr(time); + calendar = fromDateStr(ex); + } catch (Exception e) { + //TODO log + } + } + + return calendar; + } + + public static Calendar fromMillisInDate(Long ms) { + Calendar calendar = fromMillis(ms); + return CalendarUtil.fromCalendarInDate(calendar); + } + + public static Calendar fromMillis(Long ms) { + Calendar calendar = Calendar.getInstance(); + calendar.setTimeInMillis(ms); + return calendar; + } + + public static Calendar fromTimestamp(Timestamp ts) { + Calendar calendar = null; + if(ts != null) { + calendar = Calendar.getInstance(); + long time = ts.getTime(); + calendar.setTimeInMillis(time); + } + return calendar; + } + + /** + * 通过yyyy-MM-dd获取日期 + * @param dateStr 日期字符串 + */ + public static Calendar fromDateStr(String dateStr) { + return CalendarUtil.fromStr(dateStr, ConstantFactory.STR_DATE); + } + + /** + * 通过yyyy-MM-dd HH:mm:ss.SSS获取日期 + * @param dateTimeMSStr 带毫秒的时间字符串 + */ + public static Calendar fromDateTimeMSStr(String dateTimeMSStr) { + Calendar calendar = null; + if(StringUtil.isNotNullOrEmpty(dateTimeMSStr) && !"null".equals(dateTimeMSStr)) { + calendar = CalendarUtil.fromStr(dateTimeMSStr, ConstantFactory.STR_DATE_FULLMS); + } + return calendar; + } + + /** + * 通过yyyy-MM-dd HH:mm:ss获取日期 + * @param dateTimeStr 时间字符串 + */ + public static Calendar fromDateTimeStr(String dateTimeStr) { + return CalendarUtil.fromStr(dateTimeStr, ConstantFactory.STR_DATE_FULL); + } + + /** + * 通过指定时间格式,获取Calendar对象 + * @param dateStr 时间字符串 + * @param format 时间格式 + */ + public static Calendar fromStr(String dateStr, String format) { + Calendar calendar; + try { + SimpleDateFormat sdf = new SimpleDateFormat(format); + Date date = sdf.parse(dateStr); + calendar = Calendar.getInstance(); + calendar.setTime(date); + return calendar; + } catch (ParseException var5) { + //TODO log + return null; + } + } + + public static String toNowDateStr() { + return CalendarUtil.toDateStr(getNow()); + } + + public static String toNowDateTimeStr() { + return CalendarUtil.toDateTimeStr(getNow()); + } + + public static String toNowDateTimeMSStr() { + return CalendarUtil.toDateTimeMSStr(getNow()); + } + + public static String toDateStr(Calendar calendar) { + return CalendarUtil.toDateTimeStr(calendar, ConstantFactory.STR_DATE); + } + + public static String toDateTimeStr(Calendar calendar) { + return CalendarUtil.toDateTimeStr(calendar, ConstantFactory.STR_DATE_FULL); + } + + public static String toDateTimeMSStr(Calendar calendar) { + return CalendarUtil.toDateTimeStr(calendar, ConstantFactory.STR_DATE_FULLMS); + } + + public static String toDateTimeStr(Calendar calendar, String format) { + if(null == calendar) { + calendar = CalendarUtil.fromDateTimeStr(ConstantFactory.STR_DATE_DEFAULT); + } + SimpleDateFormat formatter = new SimpleDateFormat(format); + return formatter.format(calendar.getTime()); + } + + public static String toStringByTimestamp(Timestamp ts) { + Calendar calendar = CalendarUtil.fromTimestamp(ts); + return CalendarUtil.toDateTimeStr(calendar, ConstantFactory.STR_DATE_FULLMS); + } + + /** + * 获取当前时间戳 + * @return 当前时间戳 + */ + public static Timestamp getNowTimestamp() { + return new Timestamp(CalendarUtil.nowTimestamp()); + } + + /** + * 获取当前时间戳 + */ + public static Long nowTimestamp() { + return Instant.now().toEpochMilli(); + } + + /** + * 获取当前时间戳 + */ + public static String nowTimestampStr() { + return Long.toString(CalendarUtil.nowTimestamp()); + } + + public static Calendar get1970() { + Calendar result; + try { + result = fromStr("1970-01-01 08:00:01", ConstantFactory.STR_DATE_FULL); + } catch (Exception e) { + result = null; + } + return result; + } + + public static Integer getAge(Calendar birthDay) { + if(birthDay==null) { + return 0; + } + Calendar now = getNow(); + + int nowYear = now.get(Calendar.YEAR); + int nowMonth = now.get(Calendar.MONTH); + int nowDay = now.get(Calendar.DAY_OF_MONTH); + + int birthDayYear= birthDay.get(Calendar.YEAR); + int birthDayMonth = birthDay.get(Calendar.MONTH); + int birthDayDay = birthDay.get(Calendar.DAY_OF_MONTH); + + int age = nowYear - birthDayYear; + if(nowMonth < birthDayMonth) { + age--; + } else if(nowMonth == birthDayMonth && nowDay < birthDayDay) { + age--; + } else { + age = 0; + } + return age; + } + + public static Integer getAge(String birthDay) { + Calendar cBirthDay = CalendarUtil.fromStr(birthDay, ConstantFactory.STR_DATE); + return getAge(cBirthDay); + } + + /** + * 方法为获取时间段内的所有日期 + * @param dateFrom 时间起 + * @param dateEnd 时间至 + * @return List<Long> 返回该时间段内的所有日期的时间戳队列。 + * @throws ParseException + */ + public static List<String> getDates(String dateFrom, String dateEnd) throws ParseException { + return CalendarUtil.getDates(dateFrom, dateEnd, "-1"); + } + + /** + * 方法为指定时间段内获取指定周几的所有日期 + * @param dateFrom 时间起 + * @param dateEnd 时间至 + * @param weekDays 需要在时间段中指定查询的周数,建议使用“,”隔开(不隔开也没问题),需要获取时间段内所有日期时参数为"-1"。星期日=0,星期一=1,星期二=2,星期三=3,星期四=4,星期五=5,星期六=6。 + * @return List<Long> 返回符合条件日期的时间戳队列。 + * @throws ParseException + */ + public static List<String> getDates(String dateFrom, String dateEnd, String weekDays) throws ParseException { + boolean isAll = weekDays.contains("-1"); + long time; + List<String> dateList = new ArrayList<>(); + SimpleDateFormat simpleDateFormat = new SimpleDateFormat(ConstantFactory.STR_DATE); + dateFrom = simpleDateFormat.format(simpleDateFormat.parse(dateFrom).getTime() - ONE_DAYMS); + while (true) { + time = simpleDateFormat.parse(dateFrom).getTime(); + time = time + ONE_DAYMS; + Date date = new Date(time); + dateFrom = simpleDateFormat.format(date); + if (dateFrom.compareTo(dateEnd) <= 0) { + if (isAll) { + dateList.add(dateFrom); + } else { + Integer weekDay = dayForWeek(date); + if (weekDays.contains(weekDay.toString())) { + dateList.add(dateFrom); + } + } + } else { + break; + } + } + return dateList; + } + + private static Integer dayForWeek(Date date) { + Calendar calendar = Calendar.getInstance(); + calendar.setTime(date); + return calendar.get(Calendar.DAY_OF_WEEK) - 1; + } + + public static Timestamp get1970Timestamp() { + Timestamp result; + try { + Calendar date = get1970(); + if(null!=date) { + result = new Timestamp(date.getTimeInMillis()); + } else { + result = null; + } + } catch (Exception e) { + result = null; + } + return result; + } + + /** + * 从指定格式时间字符串,获取时间戳 + */ + public static Timestamp getTimestamp(String dateStr, String format) { + Long timspamp = Long.parseLong("1000"); + Calendar date = CalendarUtil.fromStr(dateStr, format); + if(null!=date) { + timspamp = date.getTimeInMillis(); + } + return new Timestamp(timspamp); + } + + /** + * 获取今日 00:00:00 + */ + public static Calendar getToday() { + Calendar calendar = Calendar.getInstance(); + calendar.setTime(new Date()); + String today = CalendarUtil.toDateTimeStr(calendar, ConstantFactory.STR_DATE); + return CalendarUtil.fromStr(today, ConstantFactory.STR_DATE); + } + + /** + * 获取本月第一天零时 xxxx-xx-01 00:00:00 + */ + public static Calendar getCurrentMonthFirstDay() { + Calendar calendar = Calendar.getInstance(); + calendar.setTime(new Date()); + String toMonth = CalendarUtil.toDateTimeStr(calendar, "yyyy-MM")+"-01"; + return CalendarUtil.fromStr(toMonth, ConstantFactory.STR_DATE); + } + + /** + * 从指定Calendar获取时间戳 + */ + public static Timestamp getTimestamp(Calendar date) { + Long timspamp = Long.parseLong("1000"); + if(null!=date) { + timspamp = date.getTimeInMillis(); + } + return new Timestamp(timspamp); + } + + public static boolean isValid(Calendar calendar) { + if(null==calendar|| calendar.compareTo(CalendarUtil.get1970())<0) { + return false; + } + return true; + } + public static boolean isValid(Timestamp timestamp) { + if(null==timestamp || timestamp.compareTo(CalendarUtil.get1970Timestamp())<0) { + return false; + } + return true; + } + public static boolean isValid(String dateStr, String format) { + Calendar calendar = CalendarUtil.fromStr(dateStr, format); + if(null==calendar || calendar.compareTo(CalendarUtil.get1970())<0) { + return false; + } + return true; + } + + public static Integer getTimestampSeconds(Calendar time) { + long mils = time.getTimeInMillis(); + String timestamp = String.valueOf(mils / ONE_SECONDS); + return Integer.valueOf(timestamp); + } +} \ No newline at end of file diff --git a/src/main/java/com/fengdu/gas/common/util/CopierUtil.java b/src/main/java/com/fengdu/gas/common/util/CopierUtil.java new file mode 100644 index 0000000..7bd684a --- /dev/null +++ b/src/main/java/com/fengdu/gas/common/util/CopierUtil.java @@ -0,0 +1,70 @@ +package com.fengdu.gas.common.util; + +import org.springframework.cglib.beans.BeanCopier; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.Optional; +import java.util.stream.Collectors; + +public final class CopierUtil { + private CopierUtil() { + throw new IllegalStateException("Utility class"); + } + + /** + * 单个对象属性拷贝 + * @param source 源对象 + * @param clazz 目标对象Class + * @param <T> 目标对象类型 + * @param <M> 源对象类型 + * @return 目标对象 + */ + public static <T, M> T mapTo(M source, Class<T> clazz) { + if (Objects.isNull(source) || Objects.isNull(clazz)) + throw new IllegalArgumentException(); + return mapTo(source, clazz, null); + } + + /** + * 列表对象拷贝 + * @param sources 源列表 + * @param clazz 源列表对象Class + * @param <T> 目标列表对象类型 + * @param <M> 源列表对象类型 + * @return 目标列表 + */ + public static <T, M> List<T> mapTo(List<M> sources, Class<T> clazz) { + if (Objects.isNull(sources) || Objects.isNull(clazz) || sources.isEmpty()) + throw new IllegalArgumentException(); + BeanCopier copier = BeanCopier.create(sources.get(0).getClass(), clazz, false); + return Optional.of(sources) + .orElse(new ArrayList<>()) + .stream().map(m -> mapTo(m, clazz, copier)) + .collect(Collectors.toList()); + } + + /** + * 单个对象属性拷贝 + * @param source 源对象 + * @param clazz 目标对象Class + * @param copier copier + * @param <T> 目标对象类型 + * @param <M> 源对象类型 + * @return 目标对象 + */ + private static <T, M> T mapTo(M source, Class<T> clazz, BeanCopier copier) { + if (null == copier){ + copier = BeanCopier.create(source.getClass(), clazz, false); + } + T t = null; + try { + t = clazz.newInstance(); + copier.copy(source, t, null); + } catch (InstantiationException | IllegalAccessException e) { + // TODO log + } + return t; + } +} \ No newline at end of file diff --git a/src/main/java/com/fengdu/gas/common/util/EncryptionUtil.java b/src/main/java/com/fengdu/gas/common/util/EncryptionUtil.java new file mode 100644 index 0000000..8ca176b --- /dev/null +++ b/src/main/java/com/fengdu/gas/common/util/EncryptionUtil.java @@ -0,0 +1,46 @@ +package com.fengdu.gas.common.util; +import java.nio.charset.StandardCharsets; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; + +public class EncryptionUtil { + public static String encryptString(String input) { + try { + // 将传入的字符串转换为字节数组 + byte[] inputBytes = input.getBytes(StandardCharsets.UTF_8); + + // 使用SHA-256进行加密 + MessageDigest digest = MessageDigest.getInstance("SHA-256"); + byte[] hashBytes = digest.digest(inputBytes); + + // 转换为十六进制字符串 + StringBuilder sb = new StringBuilder(); + for (byte b : hashBytes) { + sb.append(String.format("%02x", b)); + } + String hashedString = sb.toString(); + + // 按照指定规则截取和重新组合字符串 + StringBuilder result = new StringBuilder(); + for (int i = 0; i < 4; i++) { + String subString = hashedString.substring(i * 16, (i + 1) * 16); + for (int j = 0; j < 4; j++) { + result.append(subString.charAt(j * 4 + j)); + } + } + return result.toString(); + + } catch (NoSuchAlgorithmException e) { + e.printStackTrace(); + return null; + } + } + +// public static void main(String[] args) { +// String input = "#beiaisi#_000001"; // 传入的字符串 +// +// // 调用加密方法 +// String encryptedString = encryptString(input); +// System.out.println(encryptedString); +// } +} \ No newline at end of file diff --git a/src/main/java/com/fengdu/gas/common/util/ExceptionUtil.java b/src/main/java/com/fengdu/gas/common/util/ExceptionUtil.java new file mode 100644 index 0000000..52ecaaa --- /dev/null +++ b/src/main/java/com/fengdu/gas/common/util/ExceptionUtil.java @@ -0,0 +1,69 @@ +package com.fengdu.gas.common.util; + +import java.io.ByteArrayOutputStream; +import java.io.PrintStream; + +/** + * 异常工具类 + * @author linliu + * @date 2018-12-28 + */ +public final class ExceptionUtil { + private ExceptionUtil() { + throw new IllegalStateException("Utility class"); + } + + public static String getMsg(Throwable e) { + ByteArrayOutputStream out = new ByteArrayOutputStream(); + PrintStream pout = new PrintStream(out); + e.printStackTrace(pout); + String ret = new String(out.toByteArray()); + pout.close(); + return ret; + } + + public static String getDetails(Throwable ex) { + return getMessage(ex, true); + } + + + private static String getMessage(Throwable ex, boolean includeDetail) { + if (ex != null) { + StringBuilder builder = new StringBuilder(); + Throwable current = ex; + + do { + builder.append(ex.getClass().getName()); + if (!StringUtil.isNullOrEmpty(current.getMessage())) { + builder.append(String.format(" : %s%n", current.getMessage())); + } + + if (includeDetail) { + builder.append(getStackTraceInfo(current)); + } + + current = current.getCause(); + } while(current != null); + + return builder.toString(); + } else { + return ""; + } + } + + private static String getStackTraceInfo(Throwable ex) { + StringBuilder sb = new StringBuilder(); + if (ex != null) { + StackTraceElement[] trace = ex.getStackTrace(); + StackTraceElement[] var6 = trace; + int var5 = trace.length; + + for(int var4 = 0; var4 < var5; ++var4) { + StackTraceElement s = var6[var4]; + sb.append(String.format("\tat %s%n", s)); + } + } + + return sb.toString(); + } +} \ No newline at end of file diff --git a/src/main/java/com/fengdu/gas/common/util/FileUtil.java b/src/main/java/com/fengdu/gas/common/util/FileUtil.java new file mode 100644 index 0000000..8acf67a --- /dev/null +++ b/src/main/java/com/fengdu/gas/common/util/FileUtil.java @@ -0,0 +1,436 @@ +package com.fengdu.gas.common.util; + +import java.io.*; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; + +/** + * 文件工具类 + * @author linliu + * @date 2019-03-20 + */ +public final class FileUtil { + private FileUtil() { + throw new IllegalStateException("Utility class"); + } + + static final String TITLE = "FileUtil"; + static final Integer EXCEL_SHEET_MAXROW = 65536; + static final String STR_FAILD = "generate excel is faild!"; + static final String STR_UPLOADEXCEL = "list to excel and upload file service"; + static final String STR_DEFAULT_SHEETNAME = "Sheet1"; + + /** + * 根据文件contentType生成一个文件名 + * @param fileContentType contentType + */ + public static String getNewFileNameByType(String fileContentType) { + String timeStamp = Long.toString(System.currentTimeMillis()); + return timeStamp + FileUtil.getFileExtByType(fileContentType); + } + + /** + * 根据文件contentType生成一个文件名 + * @param fileContentType contentType + */ + public static String getFileExtByType(String fileContentType) { + String result = checkImage(fileContentType); + if (StringUtil.isNotNullOrEmpty(result)) { + return result; + } + + result = checkRar(fileContentType); + if (StringUtil.isNotNullOrEmpty(result)) { + return result; + } + + result = checkMedia(fileContentType); + if (StringUtil.isNotNullOrEmpty(result)) { + return result; + } + + result = checkXml(fileContentType); + if (StringUtil.isNotNullOrEmpty(result)) { + return result; + } + + result = checkOffice(fileContentType); + if (StringUtil.isNotNullOrEmpty(result)) { + return result; + } + return ".txt"; + } + + /** + * 验证文件contentType是否是图片 + * @param fileContentType contentType + */ + private static String checkImage(String fileContentType) { + String result; + switch (fileContentType) { + case "image/jpeg": + case "application/x-jpg": + result = ".jpg"; + break; + case "image/gif": + result = ".gif"; + break; + case "image/png": + result = ".png"; + break; + case "image/bmp": + result = ".bmp"; + break; + default: + result = ""; + break; + } + return result; + } + + /** + * 验证文件contentType是否是压缩包 + * @param fileContentType contentType + */ + private static String checkRar(String fileContentType) { + String result; + switch (fileContentType) { + case "application/zip": + result = ".zip"; + break; + case "application/x-rar": + result = ".rar"; + break; + case "application/x-7z-compressed": + result = ".7z"; + break; + case "application/x-gzip": + result = ".gz"; + break; + default: + result = ""; + break; + } + return result; + } + + /** + * 验证文件contentType是否是媒体文件 + * @param fileContentType contentType + */ + private static String checkMedia(String fileContentType) { + String result; + switch (fileContentType) { + case "video/mpeg": + result = ".mp2"; + break; + case "video/mp4": + result = ".mp4"; + break; + case "video/3gpp": + result = ".3gp"; + break; + case "video/x-flv": + result = ".flv"; + break; + + case "audio/mpeg": + result = ".mp3"; + break; + case "audio/x-flac": + result = ".flac"; + break; + default: + result = ""; + break; + } + return result; + } + + /** + * 验证文件contentType是否是xml + * @param fileContentType contentType + */ + private static String checkXml(String fileContentType) { + String result; + switch (fileContentType) { + case "application/xml": + case "text/html": + result = ".xml"; + break; + default: + result = ""; + break; + } + return result; + } + + /** + * 验证文件contentType是否是office + * @param fileContentType contentType + */ + private static String checkOffice(String fileContentType) { + String result; + switch (fileContentType) { + case "application/vnd.ms-excel": + result = ".xls"; + break; + case "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": + result = ".xlsx"; + break; + case "application/msword": + result = ".doc"; + break; + case "application/vnd.openxmlformats-officedocument.wordprocessingml.document": + result = ".docx"; + break; + case "application/vnd.ms-powerpoint": + result = ".ppt"; + break; + case "application/vnd.openxmlformats-officedocument.presentationml.presentation": + result = ".pptx"; + break; + default: + result = ""; + break; + } + return result; + } + + /** + * 根据文件名识别文件 mediaType + * @author linliu + * @date 2019-06-26 + * @param fileName 文件名 + */ + public static String getMediaTypeByFileName(String fileName) { + if (StringUtil.isNullOrEmpty(fileName)) { + return ""; + } + String[] arrayPath = StringUtil.split(fileName, "/"); + String realFileName = arrayPath[arrayPath.length - 1]; + String[] array = StringUtil.split(realFileName, "\\."); + String fileSuffix = "." + array[array.length - 1]; + return getOfficeMediaTypeByFileName(fileSuffix); + } + + /** + * 根据文件拓展名识别 office文件 + * @param fileSuffix 拓展名 + */ + private static String getOfficeMediaTypeByFileName(String fileSuffix) { + String result; + switch (fileSuffix) { + case ".xls": + result = "application/vnd.ms-excel"; + break; + case ".xlsx": + result = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; + break; + case ".doc": + result = "application/msword"; + break; + case ".docx": + result = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; + break; + case ".ppt": + result = "application/vnd.ms-powerpoint"; + break; + case ".pptx": + result = "application/vnd.openxmlformats-officedocument.presentationml.presentation"; + break; + default: + result = getImageMediaTypeByFileName(fileSuffix); + break; + } + return result; + } + + /** + * 根据文件拓展名识别 图片文件 + * @param fileSuffix 拓展名 + */ + private static String getImageMediaTypeByFileName(String fileSuffix) { + String result; + switch (fileSuffix) { + case ".jpeg": + result = "image/jpeg"; + break; + case ".jpg": + result = "application/x-jpg"; + break; + case ".gif": + result = "image/gif"; + break; + case ".png": + result = "image/png"; + break; + case ".bmp": + result = "image/bmp"; + break; + default: + result = getRarMediaTypeByFileName(fileSuffix); + break; + } + return result; + } + + /** + * 根据文件拓展名识别 压缩文件 + * @param fileSuffix 拓展名 + */ + private static String getRarMediaTypeByFileName(String fileSuffix) { + String result; + switch (fileSuffix) { + case ".zip": + result = "application/zip"; + break; + case ".rar": + result = "application/x-rar"; + break; + case ".7z": + result = "application/x-7z-compressed"; + break; + case ".gz": + result = "application/x-gzip"; + break; + default: + result = getOtherMediaTypeByFileName(fileSuffix); + break; + } + return result; + } + + /** + * 根据文件拓展名识别 其他文件 + * @param fileSuffix 拓展名 + */ + private static String getOtherMediaTypeByFileName(String fileSuffix) { + String result; + switch (fileSuffix) { + case ".pdf": + result = "application/pdf"; + break; + case ".txt": + result = "text/plain"; + break; + default: + result = ""; + break; + } + return result; + } + + /** + * 读取本地文件内容 + * @param filePath 文件路径 + */ + public static String readFileContent(String filePath) { + return readFileContent(filePath, null); + } + + /** + * 读取本地文件内容 + * @param filePath 文件路径 + * @param charset 编码格式 + */ + public static String readFileContent(String filePath, Charset charset) { + if(null==charset) { + charset = Charset.forName("utf-8"); + } + File file = new File(filePath.replaceAll("\\\\", "/")); + StringBuilder localStrBulider = new StringBuilder(); + if(file.isFile() && file.exists()) { + String lineStr; + try (InputStreamReader inputStreamReader=new InputStreamReader(new FileInputStream(file), charset)){ + BufferedReader bufferReader = new BufferedReader(inputStreamReader); + while((lineStr = bufferReader.readLine()) != null) { + localStrBulider.append(lineStr); + } + bufferReader.close(); + } catch (IOException e) { + //TODO log + } + } else { + //TODO log + return null; + } + return localStrBulider.toString(); + } + + /** + * 读取本地文件内容 + * @param filePath 文件路径 + */ + public static byte[] readFile(String filePath) throws IOException { + File f = new File(filePath); + if (!f.exists()) { + throw new FileNotFoundException(filePath); + } + + ByteArrayOutputStream bos = new ByteArrayOutputStream((int) f.length()); + BufferedInputStream in = null; + try { + in = new BufferedInputStream(new FileInputStream(f)); + int bufSize = 1024; + byte[] buffer = new byte[bufSize]; + int len; + while (-1 != (len = in.read(buffer, 0, bufSize))) { + bos.write(buffer, 0, len); + } + return bos.toByteArray(); + } catch (IOException e) { + e.printStackTrace(); + throw e; + } finally { + try { + in.close(); + } catch (IOException e) { + e.printStackTrace(); + } + bos.close(); + } + } + + /** + * 删除文件 + * @param path + */ + public static void deleteFile(String path){ + File file=new File(path); + if(file.exists()){ + file.delete(); + } + } + + /** + * 读取流内容 + * @param inputStream 流 + */ + public static String readFileContent(InputStream inputStream) { + return FileUtil.readFileContent(inputStream, null); + } + + /** + * 读取流内容 + * @param inputStream 流 + * @param charset 编码格式 + */ + public static String readFileContent(InputStream inputStream, Charset charset) { + if(null==charset) { + charset = StandardCharsets.UTF_8; + } + StringBuilder localStrBulider = new StringBuilder(); + try (InputStreamReader inputStreamReader=new InputStreamReader(inputStream, charset)){ + BufferedReader bufferReader = new BufferedReader(inputStreamReader); + String lineStr; + while((lineStr = bufferReader.readLine()) != null) { + localStrBulider.append(lineStr); + } + bufferReader.close(); + } catch (IOException e) { + //TODO log + } + return localStrBulider.toString(); + } +} \ No newline at end of file diff --git a/src/main/java/com/fengdu/gas/common/util/HttpUtil.java b/src/main/java/com/fengdu/gas/common/util/HttpUtil.java new file mode 100644 index 0000000..459944a --- /dev/null +++ b/src/main/java/com/fengdu/gas/common/util/HttpUtil.java @@ -0,0 +1,484 @@ +package com.fengdu.gas.common.util; + +import com.fengdu.gas.common.enums.EHttpContentType; +import org.apache.http.HttpEntity; +import org.apache.http.HttpHost; +import org.apache.http.HttpStatus; +import org.apache.http.StatusLine; +import org.apache.http.client.config.RequestConfig; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.entity.ByteArrayEntity; +import org.apache.http.entity.ContentType; +import org.apache.http.entity.StringEntity; +import org.apache.http.entity.mime.MultipartEntityBuilder; +import org.apache.http.entity.mime.content.ByteArrayBody; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.util.EntityUtils; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.UnsupportedEncodingException; +import java.math.BigDecimal; +import java.util.HashMap; +import java.util.Map; + +/** + * Http请求工具类 + * @author xiangyuanzhang + * @date 2018-12-25 + */ +public final class HttpUtil { + //region 常量 + + static final String STR_LOGTITLE = "SendHttpRequest"; + static final String STR_UTF8 = "utf-8"; + + private static final int CONNECTTIMEOUT=20000; + + //endregion + + private HttpUtil() { + throw new IllegalStateException("Utility class"); + } + + static Boolean isLogRequestContent(EHttpContentType contentType) { + Boolean isLog; + switch (contentType) { + case JSON: + case XML: + case FORM: + isLog = Boolean.TRUE; + break; + default: + isLog = Boolean.FALSE; + break; + } + return isLog; + } + + /** + * 获取HttpPost对象 + * @param url 请求url + * @param contentType 请求类型(EHttpContentType),默认application/x-www-Form-urlencoded + * @param headers 自定义请求头 + * @param proxy http代理(例: http://ntproxy.qa.nt.ctripcorp.com:8080) + * @return + */ + private static HttpPost getHttpPost(String url, String contentType, Map<String, String> headers, String proxy) { + if(StringUtil.isNullOrEmpty(contentType)) { + contentType = EHttpContentType.FORM.getDesc(); + } + + HttpHost httpProxy = null; + if(StringUtil.isNotNullOrEmpty(proxy)) { + proxy = proxy.replace("https://", "").replace("http://", ""); + String[] arrProxy = StringUtil.split(proxy, ":"); + httpProxy = new HttpHost(arrProxy[0], Integer.valueOf(arrProxy[1])); + } + + //创建httpPost + HttpPost httpPost = new HttpPost(url); + if(!EHttpContentType.FORMDATA.getDesc().equals(contentType)) { + httpPost.setHeader("Content-Type", contentType); + } + + RequestConfig config = RequestConfig.custom() + //连接超时 + .setConnectionRequestTimeout(Integer.parseInt("60000"))//60 * 1000 + //请求超时 + .setConnectTimeout(Integer.parseInt("300000"))//5 * 60 * 1000 + //读取超时 + .setSocketTimeout(Integer.parseInt("10000"))//10 * 1000 + .setProxy(httpProxy) + .build(); + + httpPost.setConfig(config); + if(headers!=null && !headers.isEmpty()) { + for (Map.Entry<String, String> item : headers.entrySet()) { + httpPost.setHeader(item.getKey(), item.getValue()); + } + } + + return httpPost; + } + + /** + * 发起post请求 + * @param url 请求url + * @param postData 数据包 + * @param contentType 请求类型 + * @param headers 自定义header + * @param proxy http代理(例: http://ntproxy.qa.nt.ctripcorp.com:8080) + */ + public static String doPost(String url, HttpEntity postData, EHttpContentType contentType, Map<String, String> headers, String proxy) throws IOException { + String responseContent; + + CloseableHttpClient httpclient = HttpClients.custom() + .build(); + HttpPost httpPost = HttpUtil.getHttpPost(url, contentType.getDesc(), headers, proxy); + httpPost.setEntity(postData); + CloseableHttpResponse response = null; + + Map<String, String> logTags = new HashMap<>(); + logTags.put("url", url.toLowerCase()); + StringBuilder sbLog = new StringBuilder(HttpUtil.createLog(url, httpPost, contentType, postData)); + + try { + response = httpclient.execute(httpPost); + sbLog.append(String.format("ResponseTime:%s%n", CalendarUtil.toNowDateTimeMSStr())); + + StatusLine status = response.getStatusLine(); + int state = status.getStatusCode(); + if (state == HttpStatus.SC_OK) { + HttpEntity responseEntity = response.getEntity(); + responseContent = EntityUtils.toString(responseEntity); + + sbLog.append(String.format("ResponseData:%s%n", responseContent)); + sbLog.append(String.format("ResponseDataReadedTime:%s%n", CalendarUtil.toNowDateTimeMSStr())); + } + else{ + throw new RuntimeException(url+", the response “HttpStatus” of remote is :"+ state); + } + } + catch (Exception e) { + sbLog.append(String.format("the time at exception happend:%s%n", LocalDateTimeUtil.nowTimeStampStr())); + //TODO log + throw e; + } + finally { + if (response != null) { + try { + response.close(); + } catch (IOException e) { + //TODO log + } + } + try { + httpclient.close(); + } catch (IOException e) { + //TODO log + } + } + //TODO log + return responseContent; + } + + static String createLog(String url, HttpPost httpPost, EHttpContentType contentType, HttpEntity postData) { + StringBuilder sbLog = new StringBuilder(); + + sbLog.append(String.format("url:%s%n", url)); + sbLog.append(String.format("Request time:%s%n", CalendarUtil.toNowDateTimeMSStr())); + sbLog.append(String.format("Request method:%s%n", httpPost.getMethod())); + sbLog.append(String.format("ContentType:%s%n", httpPost.getEntity().getContentType())); + HttpHost hProxy = httpPost.getConfig().getProxy(); + if(hProxy!=null && StringUtil.isNotNullOrEmpty(hProxy.getHostName())) { + sbLog.append(String.format("used http proxy:%s://%s:%s%n", hProxy.getSchemeName(), hProxy.getHostName(), hProxy.getPort())); + } + if(null!= httpPost.getAllHeaders() && httpPost.getAllHeaders().length>0) { + sbLog.append(String.format("headers:%s%n", SerializeUtil.toJson(httpPost.getAllHeaders()))); + } + + if(isLogRequestContent(contentType)) { + try { + sbLog.append(String.format("Request body:%s%n", EntityUtils.toString(postData, STR_UTF8))); + } catch (Exception e) { + // + } + } else { + BigDecimal sizeKB = new BigDecimal(postData.getContentLength()).divide(new BigDecimal("1024")); + sbLog.append(String.format("Request body:%s kb.%n", sizeKB.setScale(Integer.parseInt("2"), BigDecimal.ROUND_HALF_UP))); + } + sbLog.append(String.format("Request data readed time:%s%n", CalendarUtil.toNowDateTimeMSStr())); + + return sbLog.toString(); + } + + /** + * 发起post请求 + * @param url 请求url + * @param postData 数据包 + * @param contentType 请求类型 + */ + public static String doPost(String url, byte[] postData, EHttpContentType contentType) throws IOException { + return HttpUtil.doPost(url, postData, contentType, null, null); + } + + /** + * 发起post请求 + * @param url 请求url + * @param postData 数据包 + * @param contentType 请求类型 + * @param headers 自定义header + * @param proxy http代理(例: http://ntproxy.qa.nt.ctripcorp.com:8080) + */ + public static String doPost(String url, byte[] postData, EHttpContentType contentType, Map<String, String> headers, String proxy) throws IOException { + HttpEntity entity = new ByteArrayEntity(postData, ContentType.create(contentType.getDesc())); + return HttpUtil.doPost(url, entity, contentType, headers, proxy); + } + + /** + * 发起文件上传请求 + * @param url 请求url + * @param postData 数据包 + * @param fileName 文件名 + * @param fileContentType 文件类型 + */ + public static String postFile(String url, byte[] postData, String fileName, String fileContentType) throws IOException { + return HttpUtil.postFile(url, postData, fileName, fileContentType, null, null); + } + /** + * 发起文件上传请求 + * @param url 请求url + * @param postData 数据包 + * @param fileName 文件名 + * @param fileContentType 文件类型 + * @param headers 自定义header + * @param proxy http代理(例: http://ntproxy.qa.nt.ctripcorp.com:8080) + */ + public static String postFile(String url, byte[] postData, String fileName, String fileContentType, Map<String, String> headers, String proxy) throws IOException { + MultipartEntityBuilder entity = MultipartEntityBuilder.create(); + entity.addPart("file", new ByteArrayBody(postData, ContentType.create(fileContentType), fileName)); + return HttpUtil.doPost(url, entity.build(), EHttpContentType.FORMDATA, headers, proxy); + } + + /** + * 发起post请求 + * @param url 请求url + * @param postData 数据包 + * @param contentType 请求类型 + */ + public static String doPost(String url, String postData, EHttpContentType contentType, Map<String, String> headers) throws IOException { + HttpEntity entity = new StringEntity(postData, STR_UTF8); + return HttpUtil.doPost(url, entity, contentType, headers, null); + } + + /** + * 发起post请求 + * @param url 请求url + * @param postData 数据包 + * @param contentType 请求类型 + * @param proxy http代理(例: http://ntproxy.qa.nt.ctripcorp.com:8080) + */ + public static String doPost(String url, String postData, EHttpContentType contentType, Map<String, String> headers, String proxy) throws IOException { + HttpEntity entity = new StringEntity(postData, STR_UTF8); + return HttpUtil.doPost(url, entity, contentType, headers, proxy); + } + + /** + * 发起post请求 + * @param url 请求url + * @param postData 数据包 + * @param contentType 请求类型 + */ + public static String doPost(String url, String postData, EHttpContentType contentType) throws IOException { + return HttpUtil.doPost(url, postData, contentType, null); + } + + /** + * 以“application/json”方式发起post请求 + * @param url 请求url + * @param postData 数据包 + * @param headers 自定义header + */ + public static String postJson(String url, Object postData, Map<String, String> headers) throws IOException { + String json = SerializeUtil.toJson(postData); + HttpEntity entity = new StringEntity(json, STR_UTF8); + return HttpUtil.doPost(url, entity, EHttpContentType.JSON, headers, null); + } + + /** + * 以“application/json”方式发起post请求 + * @param url 请求url + * @param postData 数据包 + * @param type 反序列化类型 + * @param headers 自定义header + * @param <T> 反序列化对象泛型 + */ + public static <T> T postJson(String url, Object postData, Class<T> type, Map<String, String> headers) throws IOException { + return HttpUtil.postJson(url, postData, type, headers, null); + } + + /** + * 以“application/json”方式发起post请求 + * @param url 请求url + * @param postData 数据包 + * @param type 反序列化类型 + * @param headers 自定义header + * @param proxy http代理(例: http://ntproxy.qa.nt.ctripcorp.com:8080) + * @param <T> 反序列化对象泛型 + */ + public static <T> T postJson(String url, Object postData, Class<T> type, Map<String, String> headers, String proxy) throws IOException { + String json = SerializeUtil.toJson(postData); + HttpEntity entity = new StringEntity(json, STR_UTF8); + String response = doPost(url, entity, EHttpContentType.JSON, headers, proxy); + + T result; + try { + result = SerializeUtil.toObject(response, type); + } catch (Exception e) { + result = null; + } + return result; + } + + /** + * 从url获取响应流 + * @param url 请求url + */ + public static byte[] getStreamByUrl(String url) { + CloseableHttpClient httpclient = HttpClients.custom().setConnectionManagerShared(true).build(); + HttpGet httpGet = new HttpGet(url); + RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(CONNECTTIMEOUT).setConnectTimeout(CONNECTTIMEOUT).build();//设置请求和传输超时时间 + httpGet.setConfig(requestConfig); + CloseableHttpResponse response = null; + try { + response = httpclient.execute(httpGet); + int statuscode = response.getStatusLine().getStatusCode(); + if (statuscode == HttpStatus.SC_OK) { + HttpEntity entity = response.getEntity(); + InputStream isStream = entity.getContent(); + return HttpUtil.getBytesFromInputStream(isStream); + } + } catch (Exception e) { + //TODO log + } finally { + if (response != null) { + //TODO log + } + + try { + httpclient.close(); + } catch (IOException e) { + //TODO log + } + } + return new byte[0]; + } + + /** + * 从输入流返回字节数组 + * @param input 输入流 + */ + public static byte[] getBytesFromInputStream(InputStream input) { + ByteArrayOutputStream output = new ByteArrayOutputStream(); + try { + byte[] buffer = new byte[1024]; + int n = 0; + while (-1 != (n = input.read(buffer))) { + output.write(buffer, 0, n); + } + return output.toByteArray(); + } catch (IOException e) { + //TODO log + return new byte[0]; + } finally { + try { + output.close(); + input.close(); + } catch (IOException e) { + //TODO log + } + } + } + + /** + * 发起get请求,读取返回流为字符串 + * @param url 请求url + * @param charset 读取返回流的字符集 + */ + public static String doGet(String url, String charset) throws UnsupportedEncodingException { + byte[] result = HttpUtil.getStreamByUrl(url); + try { + return new String(result, charset); + } catch (UnsupportedEncodingException e) { + try { + return new String(result, STR_UTF8); + } catch (Exception ex) { + throw e; + } + } + } + + /** + * 发起get请求,以“utf-8”字符集,读取返回流为字符串 + * @param url 请求url + */ + public static String doGet(String url) { + try { + return HttpUtil.doGet(url, STR_UTF8); + } catch (UnsupportedEncodingException e) { + throw new RuntimeException(e.getMessage()); + } + } + + /** + * 从url获取响应流 + * @param url 请求url + * @param headers 自定义header + * @param proxy 代理地址([http:// | https://]www.baidu.com:8080) + */ + public static byte[] getStream(String url, Map<String, String> headers, String proxy) { + String action = "getStreamByUrl"; + Map<String, String> logTags = new HashMap<>(); + logTags.put("action", action); + logTags.put("url", url); + + HttpHost httpProxy = null; + if(StringUtil.isNotNullOrEmpty(proxy)) { + proxy = proxy.replace("https://", "").replace("http://", ""); + String[] arrProxy = StringUtil.split(proxy, ":"); + httpProxy = new HttpHost(arrProxy[0], Integer.parseInt(arrProxy[1])); + } + + CloseableHttpClient httpclient = HttpClients.custom() + .setConnectionManagerShared(true) + .build(); + HttpGet httpGet = new HttpGet(url); + if(null!=headers) { + for (Map.Entry<String, String> entry : headers.entrySet()) { + httpGet.setHeader(entry.getKey(), entry.getValue()); + } + } + //设置请求和传输超时时间 + RequestConfig requestConfig = RequestConfig.custom() + .setSocketTimeout(CONNECTTIMEOUT) + .setConnectTimeout(CONNECTTIMEOUT) + .setProxy(httpProxy) + .build(); + httpGet.setConfig(requestConfig); + CloseableHttpResponse response = null; + try { + response = httpclient.execute(httpGet); + int statusCode = response.getStatusLine().getStatusCode(); + if (statusCode == HttpStatus.SC_OK) { + HttpEntity entity = response.getEntity(); + InputStream isStream = entity.getContent(); + return HttpUtil.getBytesFromInputStream(isStream); + } + } catch (Exception e) { + //TODO log + } finally { + if (response != null) { + try { + response.close(); + } catch (IOException e) { + //TODO log + } + } + try { + httpclient.close(); + } catch (IOException e) { + //TODO log + } + } + return new byte[0]; + } + + public static byte[] getStream(String url, Map<String, String> headers) { + return HttpUtil.getStream(url, headers, null); + } +} \ No newline at end of file diff --git a/src/main/java/com/fengdu/gas/common/util/IPUtils.java b/src/main/java/com/fengdu/gas/common/util/IPUtils.java new file mode 100644 index 0000000..390eb8a --- /dev/null +++ b/src/main/java/com/fengdu/gas/common/util/IPUtils.java @@ -0,0 +1,71 @@ +package com.fengdu.gas.common.util; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.servlet.http.HttpServletRequest; +import java.net.InetAddress; +import java.net.UnknownHostException; + +public class IPUtils { + private static Logger logger = LoggerFactory.getLogger(IPUtils.class); + private static final String IP_UTILS_FLAG = ","; + private static final String UNKNOWN = "unknown"; + private static final String LOCALHOST_IP = "0:0:0:0:0:0:0:1"; + private static final String LOCALHOST_IP1 = "127.0.0.1"; + + /** + * 获取IP地址 + * <p> + * 使用Nginx等反向代理软件, 则不能通过request.getRemoteAddr()获取IP地址 + * 如果使用了多级反向代理的话,X-Forwarded-For的值并不止一个,而是一串IP地址,X-Forwarded-For中第一个非unknown的有效IP字符串,则为真实IP地址 + */ + public static String getIpAddress(HttpServletRequest request) { + String ip = null; + try { + //以下两个获取在k8s中,将真实的客户端IP,放到了x-Original-Forwarded-For。而将WAF的回源地址放到了 x-Forwarded-For了。 + ip = request.getHeader("X-Original-Forwarded-For"); + if (StringUtil.isNullOrEmpty(ip) || UNKNOWN.equalsIgnoreCase(ip)) { + ip = request.getHeader("X-Forwarded-For"); + } + //获取nginx等代理的ip + if (StringUtil.isNullOrEmpty(ip) || UNKNOWN.equalsIgnoreCase(ip)) { + ip = request.getHeader("x-forwarded-for"); + } + if (StringUtil.isNullOrEmpty(ip) || UNKNOWN.equalsIgnoreCase(ip)) { + ip = request.getHeader("Proxy-Client-IP"); + } + if (StringUtil.isNullOrEmpty(ip) || ip.length() == 0 || UNKNOWN.equalsIgnoreCase(ip)) { + ip = request.getHeader("WL-Proxy-Client-IP"); + } + if (StringUtil.isNullOrEmpty(ip) || UNKNOWN.equalsIgnoreCase(ip)) { + ip = request.getHeader("HTTP_CLIENT_IP"); + } + if (StringUtil.isNullOrEmpty(ip) || UNKNOWN.equalsIgnoreCase(ip)) { + ip = request.getHeader("HTTP_X_FORWARDED_FOR"); + } + //兼容k8s集群获取ip + if (StringUtil.isNullOrEmpty(ip) || UNKNOWN.equalsIgnoreCase(ip)) { + ip = request.getRemoteAddr(); + if (LOCALHOST_IP1.equalsIgnoreCase(ip) || LOCALHOST_IP.equalsIgnoreCase(ip)) { + //根据网卡取本机配置的IP + InetAddress iNet = null; + try { + iNet = InetAddress.getLocalHost(); + } catch (UnknownHostException e) { + logger.error("getClientIp error: {}", e); + } + ip = iNet.getHostAddress(); + } + } + } catch (Exception e) { + logger.error("IPUtils ERROR ", e); + } + //使用代理,则获取第一个IP地址 + if (!StringUtil.isNullOrEmpty(ip) && ip.indexOf(IP_UTILS_FLAG) > 0) { + ip = ip.substring(0, ip.indexOf(IP_UTILS_FLAG)); + } + + return ip; + } +} diff --git a/src/main/java/com/fengdu/gas/common/util/ListUtil.java b/src/main/java/com/fengdu/gas/common/util/ListUtil.java new file mode 100644 index 0000000..57704e4 --- /dev/null +++ b/src/main/java/com/fengdu/gas/common/util/ListUtil.java @@ -0,0 +1,200 @@ +package com.fengdu.gas.common.util; + +import java.math.BigDecimal; +import java.util.*; +import java.util.function.Consumer; +import java.util.function.Function; +import java.util.stream.Collectors; + +/** + * List工具类 + * @author linliu + * @date 2018-12-28 + */ +public final class ListUtil { + private ListUtil() { + throw new IllegalStateException("Utility class"); + } + + /** + * array转list + * @param array 数组 + * @param <T> 实体类型 + */ + public static <T> List<T> toList(T... array) { + if(array==null || array.length==0) { + return new ArrayList<>(); + } + return Arrays.stream(array).collect(Collectors.toList()); + } + + /** + * Long类型 list转array + * @param list 集合 + */ + public static Long[] toLongArray(List<Long> list) { + if(ListUtil.isNullOrEmpty(list)) { + return new Long[0]; + } + Long[] array = new Long[list.size()]; + return list.toArray(array); + } + /** + * Integer类型 list转array + * @param list 集合 + */ + public static Integer[] toIntArray(List<Integer> list) { + if(ListUtil.isNullOrEmpty(list)) { + return new Integer[0]; + } + Integer[] array = new Integer[list.size()]; + return list.toArray(array); + } + /** + * BigDecimal类型 list转array + * @param list 集合 + */ + public static BigDecimal[] toDecimalArray(List<BigDecimal> list) { + if(ListUtil.isNullOrEmpty(list)) { + return new BigDecimal[0]; + } + BigDecimal[] array = new BigDecimal[list.size()]; + return list.toArray(array); + } + /** + * Double类型 list转array + * @param list 集合 + */ + public static Double[] toDoubleArray(List<Double> list) { + if(ListUtil.isNullOrEmpty(list)) { + return new Double[0]; + } + Double[] array = new Double[list.size()]; + return list.toArray(array); + } + /** + * String类型 list转array + * @param list 集合 + */ + public static String[] toArray(List<String> list) { + if(ListUtil.isNullOrEmpty(list)) { + return new String[0]; + } + String[] array = new String[list.size()]; + return list.toArray(array); + } + + /** + * 判断集合【为】null或empty + * @param list 集合 + * @param <T> 集合实体类型 + */ + public static <T> boolean isNullOrEmpty(Collection<T> list){ + return list==null || list.isEmpty(); + } + + /** + * 判断集合【不为】null或empty + * @param list 集合 + * @param <T> 集合实体类型 + */ + public static <T> boolean isNotNullOrEmpty(Collection<T> list){ + return !ListUtil.isNullOrEmpty(list); + } + + /** + * String类型集合转Integer类型集合 + * @param list 集合 + */ + public static List<Integer> toIntList(List<String> list) { + if(ListUtil.isNullOrEmpty(list)) { + return new ArrayList<>(); + } + return list.stream().map(Integer::parseInt).collect(Collectors.toList()); + } + + /** + * String类型集合转Long类型集合 + * @param list 集合 + */ + public static List<Long> toLongList(List<String> list) { + if(ListUtil.isNullOrEmpty(list)) { + return new ArrayList<>(); + } + return list.stream().map(Long::parseLong).collect(Collectors.toList()); + } + + /** + * Integer类型集合转String类型集合 + * @param list 集合 + */ + public static List<String> toStringList(List<Integer> list) { + if(ListUtil.isNullOrEmpty(list)) { + return new ArrayList<>(); + } + return list.stream().map(String::valueOf).collect(Collectors.toList()); + } + + /** + * BigDecimal类型集合求和 + * @param list 集合 + */ + public static BigDecimal sum(Collection<BigDecimal> list) { + BigDecimal result = BigDecimal.ZERO; + if(ListUtil.isNotNullOrEmpty(list)) { + result = list.stream().reduce(BigDecimal.ZERO, BigDecimal::add); + } + return result; + } + + /** + * 判断集合非空后,执行委托 + * @param list 集合 + * @param predicate 循环集合的委托代码 + * @param <T> 集合实体类型 + * @param <R> 函数(集合委托)返回值,委托里最后一句写死“return null;” + */ + public static <T, R> void notNullForeach(Collection<T> list, Function<T, R> predicate) { + if(ListUtil.isNotNullOrEmpty(list)) { + for (T item : list) { + predicate.apply(item); + } + } + } + + /** + * 集合去重 + * @param list 集合 + * @param <T> 集合实体类型 + */ + public static <T> void repeat(Collection<T> list) { + HashSet<T> hash = new HashSet<T>(list); + list.clear(); + list.addAll(hash); + } + + /** + * 判断集合是否存在重复元素 + * @param list 集合 + * @param <T> 集合实体类型 + */ + public static <T> Boolean hasRepeat(Collection<T> list) { + int oldSize = list.size(); + repeat(list); + return list.size()!=oldSize; + } + + /** + * 集合非空,则执行委托 + * @param list 集合 + * @param predicate 循环集合的委托代码 + * @param <T> 集合实体类型 + */ + public static <T> void notNullForeach(Collection<T> list, Consumer<T> predicate) { + if(ListUtil.isNotNullOrEmpty(list)) { + for (T item : list) { + predicate.accept(item); + } + } + } +} \ No newline at end of file diff --git a/src/main/java/com/fengdu/gas/common/util/LocalDateTimeUtil.java b/src/main/java/com/fengdu/gas/common/util/LocalDateTimeUtil.java new file mode 100644 index 0000000..a102e43 --- /dev/null +++ b/src/main/java/com/fengdu/gas/common/util/LocalDateTimeUtil.java @@ -0,0 +1,564 @@ +package com.fengdu.gas.common.util; + +import cn.hutool.core.date.DateTime; +import com.fengdu.gas.common.exceptions.BusinessException; +import com.fengdu.gas.common.ConstantFactory; + +import java.sql.Timestamp; +import java.text.SimpleDateFormat; +import java.time.Instant; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.ZoneId; +import java.time.format.DateTimeFormatter; +import java.time.temporal.ChronoUnit; +import java.time.temporal.TemporalAdjusters; +import java.util.Date; + +/** + * jdk8时间日期处理 工具类 + */ +public final class LocalDateTimeUtil { + private LocalDateTimeUtil() { + throw new IllegalStateException("Utility class"); + } + + /** + * 默认时间格式化对象 + */ + private static final DateTimeFormatter DEFAULT_FORMATTER = DateTimeFormatter.ofPattern(ConstantFactory.STR_DATE_FULL); + /** + * 默认时间格式化对象 + */ + private static final DateTimeFormatter DEFAULT_FORMATTER_DATE = DateTimeFormatter.ofPattern(ConstantFactory.STR_DATE); + /** + * 默认时间(1970-01-01 00:00:00) + */ + public static final LocalDateTime DEFAULT_DATETIME = LocalDateTime.parse(ConstantFactory.STR_DATE_DEFAULT, DEFAULT_FORMATTER); + /** + * 默认时间(1970-01-01) + */ + public static final LocalDate DEFAULT_DATE = LocalDate.parse(ConstantFactory.STR_DATE_DEFAULT_DATE, DEFAULT_FORMATTER_DATE); + + //************************************** 【LocalDateTime】 ************************************** + /** + * 获取当前LocalDateTime + */ + public static LocalDateTime nowDateTime() { + return LocalDateTime.now(); + } + /** + * 获取当前时间字符串(yyyy-MM-dd HH:mm:ss) + */ + public static String nowDateTimeStr() { + return LocalDateTimeUtil.toFormatString(LocalDateTime.now()); + } + /** + * 获取当前时间字符串(yyyy-MM-dd HH:mm:ss.SSS) + */ + public static String nowDateTimeFullStr() { + return LocalDateTimeUtil.toFormatFullString(LocalDateTime.now()); + } + /** + * 通过时间戳构建LocalDateTime + * @param timestamp 时间戳 + */ + public static LocalDateTime getDateTime(Long timestamp) { + if(NumericUtil.tryParseLong(timestamp).compareTo(0L)<1) { + return LocalDateTimeUtil.DEFAULT_DATETIME; + } + return LocalDateTime.ofInstant(Instant.ofEpochMilli(timestamp), ZoneId.systemDefault()); + } + /** + * 通过时间戳构建LocalDateTime + * @param timestamp 时间戳 + */ + public static LocalDateTime getDateTime(Timestamp timestamp) { + if(null==timestamp) { + return LocalDateTimeUtil.DEFAULT_DATETIME; + } + return LocalDateTimeUtil.getDateTime(timestamp.getTime()); + } + /** + * 通过时间字符串和指定时间格式(例:yyyy-MM-dd HH:mm:ss), 构建LocalDateTime + * @param dateTime 时间字符串 + * @param format 指定时间格式(例:yyyy-MM-dd HH:mm:ss) + */ + public static LocalDateTime getDateTime(String dateTime, String format) { + if(StringUtil.isNullOrEmpty(dateTime)) { + return LocalDateTimeUtil.DEFAULT_DATETIME; + } + if(StringUtil.isNullOrEmpty(format)) { + format = ConstantFactory.STR_DATE_FULL; + } + DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(format); + if(ConstantFactory.STR_DATE.equals(format)) { + LocalDate localDate = getDate(dateTime); + return localDate.atStartOfDay(); + } + return LocalDateTime.parse(dateTime, dateTimeFormatter); + } + /** + * 通过时间字符串和固定时间格式(yyyy-MM-dd HH:mm:ss), 构建LocalDateTime + * @param dateTime 时间字符串 + */ + public static LocalDateTime getDateTime(String dateTime) { + return LocalDateTimeUtil.getDateTime(dateTime, ConstantFactory.STR_DATE_FULL); + } + /** + * 将LocalDateTime格式化成时间字符串 + * @param dateTime LocalDateTime对象 + * @param format 指定时间格式(例:yyyy-MM-dd HH:mm:ss) + */ + public static String toFormatString(LocalDateTime dateTime, String format) { + if(null==dateTime) { + return ConstantFactory.STR_DATE_DEFAULT; + } + if(StringUtil.isNullOrEmpty(format)) { + format = ConstantFactory.STR_DATE_FULL; + } + DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(format); + return dateTimeFormatter.format(dateTime); + } + /** + * 将LocalDateTime按“yyyy-MM-dd HH:mm:ss.SSS”格式化成时间字符串 + * @param dateTime LocalDateTime对象 + */ + public static String toFormatFullString(LocalDateTime dateTime) { + if(null==dateTime) { + return ConstantFactory.STR_DATE_DEFAULT_FULL; + } + return LocalDateTimeUtil.toFormatString(dateTime, ConstantFactory.STR_DATE_FULLMS); + } + /** + * 将LocalDateTime按“yyyy-MM-dd HH:mm:ss”格式化成时间字符串 + * @param dateTime LocalDateTime对象 + */ + public static String toFormatString(LocalDateTime dateTime) { + if(null==dateTime) { + return ConstantFactory.STR_DATE_DEFAULT; + } + return LocalDateTimeUtil.toFormatString(dateTime, ConstantFactory.STR_DATE_FULL); + } + /** + * 将LocalDateTime按“yyyy-MM-dd”格式化成时间字符串 + * @param dateTime LocalDateTime对象 + */ + public static String toDateString(LocalDateTime dateTime) { + if(null==dateTime) { + return ConstantFactory.STR_DATE_DEFAULT_DATE; + } + return LocalDateTimeUtil.toFormatString(dateTime, ConstantFactory.STR_DATE); + } + /** + * 将dateTime格式化成时间字符串 + * @param date LocalDate对象 + * @param format 指定时间格式(例:yyyy-MM-dd) + */ + public static String toFormatString(LocalDate date, String format) { + if(null==date) { + return ConstantFactory.STR_DATE_DEFAULT_DATE; + } + if(StringUtil.isNullOrEmpty(format)) { + format = ConstantFactory.STR_DATE; + } + DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(format); + return dateTimeFormatter.format(date); + } + /** + * 将LocalDate按“yyyy-MM-dd”格式化成时间字符串 + * @param date LocalDate对象 + */ + public static String toFormatString(LocalDate date) { + return LocalDateTimeUtil.toFormatString(date, ConstantFactory.STR_DATE); + } + /** + * LocalDateTime偏移指定月数 + * @param dateTime LocalDateTime对象 + * @param addMonth 偏移月数(可以为负数) + */ + public static LocalDateTime dateTimeAddMonth(LocalDateTime dateTime, Long addMonth) { + if(null==dateTime) { + return LocalDateTimeUtil.DEFAULT_DATETIME; + } + return dateTime.plusMonths(addMonth); + } + /** + * LocalDateTime偏移指定天数 + * @param dateTime LocalDateTime对象 + * @param addDay 偏移天数(可以为负数) + */ + public static LocalDateTime dateTimeAddDay(LocalDateTime dateTime, Long addDay) { + if(null==dateTime) { + return LocalDateTimeUtil.DEFAULT_DATETIME; + } + return dateTime.plusDays(addDay); + } + /** + * LocalDateTime偏移指定小时数 + * @param dateTime LocalDateTime对象 + * @param addHour 偏移小时数(可以为负数) + */ + public static LocalDateTime dateTimeAddHour(LocalDateTime dateTime, Long addHour) { + if(null==dateTime) { + return LocalDateTimeUtil.DEFAULT_DATETIME; + } + return dateTime.plusHours(addHour); + } + /** + * LocalDateTime偏移指定分钟数 + * @param dateTime LocalDateTime对象 + * @param addMin 偏移分钟数(可以为负数) + */ + public static LocalDateTime dateTimeAddMin(LocalDateTime dateTime, Long addMin) { + if(null==dateTime) { + return LocalDateTimeUtil.DEFAULT_DATETIME; + } + return dateTime.plusMinutes(addMin); + } + /** + * 获取两个日期相差的天数 + * + * @param dateString1 开始日期的字符串 + * @param dateString2 结束日期的字符串 + * @return 相差天数,如果解析失败则返回-1 + **/ + public static long subDaysByDate2(String dateString1 , String dateString2 ) { + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + LocalDate date1 = LocalDate.parse(dateString1, formatter); + LocalDate date2 = LocalDate.parse(dateString2, formatter); + long daysBetween = java.time.Duration.between(date1.atStartOfDay(), date2.atStartOfDay()).toDays(); + return daysBetween; + } + /** + * LocalDateTime偏移指定秒数 + * @param dateTime LocalDateTime对象 + * @param addSec 偏移秒数(可以为负数) + */ + public static LocalDateTime dateTimeAddSec(LocalDateTime dateTime, Long addSec) { + if(null==dateTime) { + return LocalDateTimeUtil.DEFAULT_DATETIME; + } + return dateTime.plusSeconds(addSec); + } + /** + * LocalDateTime指定时间部分,偏移指定值 + * @param dateTime LocalDateTime对象 + * @param addPart 偏移时间部分 + * @param value 偏移值 + */ + public static LocalDateTime dateTimeAdd(LocalDateTime dateTime, ChronoUnit addPart, Long value) { + if(null==dateTime) { + return LocalDateTimeUtil.DEFAULT_DATETIME; + } + return dateTime.plus(value, addPart); + } + /** + * 获取当前月份第一天LocalDateTime“00:00:00” + */ + public static LocalDateTime monthFirstDateTime() { + + LocalDateTime now = LocalDateTime.now(); + return LocalDateTime.of(now.getYear(), now.getMonthValue(), 1, 0, 0); + } + /** + * 获取年月字符串第一天“00:00:00”时间戳 + */ + public static Long getYearMonthFirstTime(String yearMonth){ + //String month = "2023-05"; + LocalDateTime time = DateTime.of(yearMonth, "yyyy-MM").toTimestamp().toLocalDateTime(); + LocalDateTime first = time.with(TemporalAdjusters.firstDayOfMonth()).withHour(0) + .withMinute(0).withSecond(0); + return getTimeStamp(first).getTime(); + } + /** + * 获取年月字符串最后一天“00:00:00”时间戳 + */ + public static Long getYearMonthLatestTime(String yearMonth){ + //String month = "2023-05"; + LocalDateTime time = DateTime.of(yearMonth, "yyyy-MM").toTimestamp().toLocalDateTime(); + LocalDateTime end = time.with(TemporalAdjusters.lastDayOfMonth()).withHour(23) + .withMinute(59).withSecond(59); + return getTimeStamp(end).getTime(); + } + /** + * 获取当前月份最后一天LocalDateTime“23:59:59” + */ + public static LocalDateTime monthLatestDateTime() { + //当前月第一天“00:00:00” + LocalDateTime monthFirst = monthFirstDateTime(); + //下个月第一天“00:00:00” + LocalDateTime nextMonthFirst = dateTimeAddMonth(monthFirst, 1L); + //当前月最后一天“23:59:59” + return LocalDateTimeUtil.dateTimeAddSec(nextMonthFirst, -1L); + } + /** + * 获取今天LocalDateTime“00:00:00” + */ + public static LocalDateTime todayFirst() { + LocalDateTime now = LocalDateTimeUtil.nowDateTime(); + return LocalDateTime.of(now.getYear(), now.getMonthValue(), now.getDayOfMonth(), 0, 0); + } + /** + * 获取今天LocalDateTime“23:59:59” + */ + public static LocalDateTime todayLatest() { + //今天“00:00:00” + LocalDateTime now = LocalDateTimeUtil.nowDateTime(); + //明天“00:00:00” + LocalDateTime nextDayFirst = LocalDateTimeUtil.dateTimeAddDay(now, 1L); + //今天“23:59:59” + return LocalDateTimeUtil.dateTimeAddSec(nextDayFirst, -1L); + } + //************************************** 【LocalDateTime】 ************************************** + + + + + + //************************************** 【LocalDate】 ************************************** + /** + * 获取当前LocalDate + */ + public static LocalDate nowDate() { + return LocalDate.now(); + } + /** + * 获取当前日期字符串(yyyy-MM-dd) + */ + public static String todayStr() { + return LocalDateTimeUtil.toFormatString(LocalDateTime.now(), ConstantFactory.STR_DATE); + } + /** + * 根据日期字符串获取LocalDate(必须是yyyy-MM-dd格式) + * @param date 日期字符串 + */ + public static LocalDate getDate(String date) { + if(StringUtil.isNullOrEmpty(date)) { + return LocalDateTimeUtil.DEFAULT_DATE; + } + return LocalDate.parse(date); + } + /** + * 获取LocalDate + * @param year 年份 + * @param month 月份 + * @param day 天 + */ + public static LocalDate getDate(Integer year, Integer month, Integer day) { + return LocalDate.of(year, month, day); + } + /** + * LocalDate偏移指定天数 + * @param date LocalDate对象 + * @param addDay 偏移天数(可以为负数) + */ + public static LocalDate dateAddDay(LocalDate date, Long addDay) { + if(null==date) { + return LocalDateTimeUtil.DEFAULT_DATE; + } + return date.plusDays(addDay); + } + /** + * LocalDate偏移指定月数 + * @param date LocalDate对象 + * @param addMonth 偏移月数(可以为负数) + */ + public static LocalDate dateAddMonth(LocalDate date, Long addMonth) { + if(null==date) { + return LocalDateTimeUtil.DEFAULT_DATE; + } + return date.plusMonths(addMonth); + } + /** + * 获取当前月份第一天LocalDate + */ + public static LocalDate monthFirstDate() { + LocalDate toDay = nowDate(); + return LocalDate.of(toDay.getYear(), toDay.getMonthValue(), 1); + } + /** + * 获取当前月份最后一天LocalDate + */ + public static LocalDate monthLatestDate() { + //当前月第一天 + LocalDate monthFirst = monthFirstDate(); + //下个月第一天 + LocalDate nextMonthDay = dateAddMonth(monthFirst, 1L); + return LocalDateTimeUtil.dateAddDay(nextMonthDay, -1L); + } + //************************************** 【LocalDate】 ************************************** + + + + + + //************************************** 【时间戳处理】 ************************************** + /** + * 获取当前时间戳 + */ + public static Long nowTimeStamp() { + return Instant.now().toEpochMilli(); + } + /** + * 获取当前时间戳(字符串) + */ + public static String nowTimeStampStr() { + return String.valueOf(nowTimeStamp()); + } + /** + * 通过LocalDateTime对象获取时间戳 + * @param dateTime LocalDateTime对象 + */ + public static Timestamp getTimeStamp(LocalDateTime dateTime) { + if(null==dateTime) { + return Timestamp.valueOf(LocalDateTimeUtil.DEFAULT_DATETIME); + } + return Timestamp.valueOf(dateTime); + } + /** + * 通过时间字符串按指定格式获取时间戳 + * @param dateTime 时间字符串 + * @param format 时间格式 + */ + public static Timestamp getTimeStamp(String dateTime, String format) { + LocalDateTime localDateTime = LocalDateTimeUtil.getDateTime(dateTime, format); + return Timestamp.valueOf(localDateTime); + } + /** + * 通过时间字符串按“yyyy-MM-dd HH:mm:ss”格式获取时间戳 + * @param dateTime 时间字符串 + */ + public static Timestamp getTimeStamp(String dateTime) { + return LocalDateTimeUtil.getTimeStamp(dateTime, ConstantFactory.STR_DATE_FULL); + } + + + /** + * 通过Unix时间戳获取Timestamp + * @param timeStamp Unix时间戳 + */ + public static Timestamp getTimeStamp(Long timeStamp) { + return new Timestamp(timeStamp); + } + /** + * 通过时间戳,按指定格式,转成时间字符串 + * @param timeStamp 时间戳值 + * @param format 时间格式 + */ + public static String toFormatString(Long timeStamp, String format) { + LocalDateTime dateTime = LocalDateTimeUtil.getDateTime(timeStamp); + return LocalDateTimeUtil.toFormatString(dateTime, format); + } + /** + * 通过时间戳,按“yyyy-MM-dd HH:mm:ss”转成时间字符串 + * @param timeStamp 时间戳值 + */ + public static String toFormatString(Long timeStamp) { + return LocalDateTimeUtil.toFormatString(timeStamp, ConstantFactory.STR_DATE_FULL); + } + /** + * 通过时间戳,按“yyyy-MM-dd”转成时间字符串 + * @param timeStamp 时间戳值 + */ + public static String toDateString(Long timeStamp) { + return LocalDateTimeUtil.toFormatString(timeStamp, ConstantFactory.STR_DATE); + } + /** + * 通过时间戳,按“yyyy-MM-dd HH:mm:ss.SSS”转成时间字符串 + * @param timeStamp 时间戳值 + */ + public static String toFormatFullString(Long timeStamp) { + return LocalDateTimeUtil.toFormatString(timeStamp, ConstantFactory.STR_DATE_FULLMS); + } + /** + * 通过时间戳,按指定格式,转成时间字符串 + * @param timeStamp 时间戳值 + * @param format 时间格式 + */ + public static String toFormatString(Timestamp timeStamp, String format) { + LocalDateTime dateTime = LocalDateTimeUtil.getDateTime(timeStamp); + return LocalDateTimeUtil.toFormatString(dateTime, format); + } + /** + * 通过时间戳,按“yyyy-MM-dd HH:mm:ss”转成时间字符串 + * @param timeStamp 时间戳值 + */ + public static String toFormatString(Timestamp timeStamp) { + return LocalDateTimeUtil.toFormatString(timeStamp, ConstantFactory.STR_DATE_FULL); + } + /** + * 通过时间戳,按“yyyy-MM-dd”转成时间字符串 + * @param timeStamp 时间戳值 + */ + public static String toDateString(Timestamp timeStamp) { + return LocalDateTimeUtil.toFormatString(timeStamp, ConstantFactory.STR_DATE); + } + /** + * 通过时间戳,按“yyyy-MM-dd HH:mm:ss.SSS”转成时间字符串 + * @param timeStamp 时间戳值 + */ + public static String toFormatFullString(Timestamp timeStamp) { + return LocalDateTimeUtil.toFormatString(timeStamp, ConstantFactory.STR_DATE_FULLMS); + } + //************************************** 【时间戳处理】 ************************************** + + + public static String convertToDateFormat(String inputString) { + try { + // 将输入字符串解析为日期对象 + SimpleDateFormat inputFormat = new SimpleDateFormat("yyMMddHHmmss"); + Date date = inputFormat.parse(inputString); + + // 将日期对象格式化为目标日期字符串 + SimpleDateFormat outputFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + return outputFormat.format(date); + } catch (Exception e) { + return "Invalid Date"; + } + } + + public static String nowTimeBCD(String timeFormat) { + return LocalDateTimeUtil.time2BCD(LocalDateTimeUtil.nowDateTime(), timeFormat); + } + public static String nowTimeBCD() { + return LocalDateTimeUtil.time2BCD(LocalDateTimeUtil.nowDateTime()); + } + + public static String time2BCD(LocalDateTime nowDateTime) { + String timeStr = LocalDateTimeUtil.toFormatString(nowDateTime, ConstantFactory.STR_DATE_FULL); + return LocalDateTimeUtil.number2BCD(timeStr); + } + + public static String time2BCD(LocalDateTime nowDateTime, String timeFormat) { + String timeStr = LocalDateTimeUtil.toFormatString(nowDateTime, timeFormat); + return LocalDateTimeUtil.number2BCD(timeStr); + } + + public static String number2BCD(String numberStr) { + // 因为可能修改字符串的内容,所以构造StringBuffer + StringBuffer sb = new StringBuffer(numberStr); + // 一个字节包含两个4位的BCD码,byte数组中要包含偶数个BCD码 + // 一个十进制字符对应4位BCD码,所以如果十进制字符串的长度是奇数,要在前面补一个0使长度成为偶数 + if ((sb.length() % 2) != 0) { + sb.insert(0, '0'); + } + + // 两个十进制数字转换为BCD码后占用一个字节,所以存放BCD码的字节数等于十进制字符串长度的一半 + byte[] bcd = new byte[sb.length() / 2]; + for (int i = 0; i < sb.length();) { + if (!Character.isDigit(sb.charAt(i)) || !Character.isDigit(sb.charAt(i + 1))) { + throw new BusinessException("传入的十进制字符串包含非数字字符!"); + } + // 每个字节的构成:用两位十进制数字运算的和填充,高位十进制数字左移4位+低位十进制数字 + bcd[i/2] = (byte)((Character.digit(sb.charAt(i), 10) << 4) + Character.digit(sb.charAt(i + 1), 10)); + // 字符串的每两个字符取出来一起处理,所以此处i的自增长要加2,而不是加1 + i += 2; + } + StringBuffer sbResult = new StringBuffer(); + for (int i = 0; i < bcd.length; i++) { + sbResult.append(Integer.toBinaryString(bcd[i])); + } + return sbResult.toString(); + } +} \ No newline at end of file diff --git a/src/main/java/com/fengdu/gas/common/util/LoggerUtil.java b/src/main/java/com/fengdu/gas/common/util/LoggerUtil.java new file mode 100644 index 0000000..b736e55 --- /dev/null +++ b/src/main/java/com/fengdu/gas/common/util/LoggerUtil.java @@ -0,0 +1,15 @@ +package com.fengdu.gas.common.util; + +import com.fengdu.gas.common.enums.ELogger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class LoggerUtil { + public static <T> Logger get(Class<T> clazz) { + return LoggerFactory.getLogger(clazz); + } + + public static Logger get(ELogger logger) { + return LoggerFactory.getLogger(logger.getLogFileName()); + } +} diff --git a/src/main/java/com/fengdu/gas/common/util/MailUtils.java b/src/main/java/com/fengdu/gas/common/util/MailUtils.java new file mode 100644 index 0000000..db01e11 --- /dev/null +++ b/src/main/java/com/fengdu/gas/common/util/MailUtils.java @@ -0,0 +1,81 @@ +package com.fengdu.gas.common.util; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +import javax.mail.*; +import javax.mail.internet.InternetAddress; +import javax.mail.internet.MimeMessage; +import java.util.Properties; + +/** + * 发邮件工具类 + */ +@Component +public final class MailUtils { + @Value("${spring:mail:username}") + private String USER; // 发件人邮箱地址 + @Value("${spring:mail:password}") + private String PASSWORD; // 如果是qq邮箱可以使户端授权码 + + /** + * 发送邮件 + * @param to 收件人邮箱 + * @param text 邮件正文 + * @param title 标题 + * mail: + * password: ennnntqxzijsdjdh + * username: 2413500195@qq.com + * host: smtp.qq.com + * default-encoding: UTF-8 + */ + public boolean sendMail(String to, String text, String title){ + try { + final Properties props = new Properties(); + props.put("mail.smtp.auth", "true"); + props.put("mail.smtp.host", "smtp.qq.com"); + + // 发件人的账号 + props.put("spring:mail:username", USER); + //发件人的密码 + props.put("spring:mail:password", PASSWORD); + + // 构建授权信息,用于进行SMTP进行身份验证 + Authenticator authenticator = new Authenticator() { + @Override + protected PasswordAuthentication getPasswordAuthentication() { + // 用户名、密码 + String userName = props.getProperty("spring:mail:username"); + String password = props.getProperty("spring:mail:password"); + return new PasswordAuthentication(userName, password); + } + }; + // 使用环境属性和授权信息,创建邮件会话 + Session mailSession = Session.getInstance(props, authenticator); + // 创建邮件消息 + MimeMessage message = new MimeMessage(mailSession); + // 设置发件人 + String username = props.getProperty("spring:mail:username"); + InternetAddress form = new InternetAddress(username); + message.setFrom(form); + + // 设置收件人 + InternetAddress toAddress = new InternetAddress(to); + message.setRecipient(Message.RecipientType.TO, toAddress); + + // 设置邮件标题 + message.setSubject(title); + + // 设置邮件的内容体 + message.setContent(text, "text/html;charset=UTF-8"); + // 发送邮件 + Transport.send(message); + return true; + }catch (Exception e){ + e.printStackTrace(); + } + return false; + } + +} + diff --git a/src/main/java/com/fengdu/gas/common/util/MoneyUtil.java b/src/main/java/com/fengdu/gas/common/util/MoneyUtil.java new file mode 100644 index 0000000..97c0c75 --- /dev/null +++ b/src/main/java/com/fengdu/gas/common/util/MoneyUtil.java @@ -0,0 +1,129 @@ +package com.fengdu.gas.common.util; + +import java.math.BigDecimal; + +/** + * 金钱计算工具类 + */ + +public class MoneyUtil { + /** + * 加法 + * @param v1 + * @param v2 + * @return + */ + public static BigDecimal add(BigDecimal v1,BigDecimal v2){ + if(v1 == null || "".equals(v1)){ + v1 = new BigDecimal(0); + }else if(v2 == null || "".equals(v2)){ + v2 = new BigDecimal(0); + } + return v1.add(v2).setScale(2, BigDecimal.ROUND_DOWN); + + } + + /** + * 减法 + * @param v1 + * @param v2 + * @return + */ + public static BigDecimal subtract(BigDecimal v1,BigDecimal v2){ + if(v1 == null || "".equals(v1)){ + v1 = new BigDecimal(0); + }else if(v2 == null || "".equals(v2)){ + v2 = new BigDecimal(0); + } + return v1.subtract(v2).setScale(2, BigDecimal.ROUND_DOWN); + } + + /** + * 除法 + * @param v1 + * @param v2 + * @return + */ + public static BigDecimal divide(BigDecimal v1,BigDecimal v2){ + if(v1 == null || "".equals(v1)){ + v1 = new BigDecimal(0); + }else if(v2 == null || "".equals(v2)){ + v2 = new BigDecimal(0); + } + // 暂时不算负数的情况 + int i = v2.compareTo(new BigDecimal(0)); + if(i == 0){ + return new BigDecimal(0); + } + return v1.divide(v2,2, BigDecimal.ROUND_DOWN); + } + + /** + * 乘法 + * @param v1 + * @param v2 + * @return + */ + + public static BigDecimal multiply(BigDecimal v1,BigDecimal v2){ + if(v1 == null || "".equals(v1)){ + v1 = new BigDecimal(0); + }else if(v2 == null || "".equals(v2)){ + v2 = new BigDecimal(0); + } + return v1.multiply(v2).setScale(2, BigDecimal.ROUND_DOWN); + } + + // 小于 + public static boolean lt(BigDecimal v1,BigDecimal v2) { + return v1.compareTo(v2) == -1; + } + + // 等于 + public static boolean eq(BigDecimal v1,BigDecimal v2) { + return v1.compareTo(v2) == 0; + } + + // 大于 + public static boolean gt(BigDecimal v1,BigDecimal v2) { + return v1.compareTo(v2) == 1; + } + + // 大于等于 + public static boolean ge(BigDecimal v1,BigDecimal v2) { + return v1.compareTo(v2) > -1; + } + + // 小于等于 + public static boolean le(BigDecimal v1,BigDecimal v2) { + return v1.compareTo(v2) < 1; + } + + /** + * 换算积分 + * @param money + * @return + */ + public static Integer integral(BigDecimal money){ + Integer integer=money.intValue()/10; + return integer; + } + +// public static void main(String [] args){ +// //加法 +// BigDecimal jia=add(BigDecimal.valueOf(5.66),BigDecimal.valueOf(3.347)); +// System.out.println("加法:"+jia); +// //减法 +// BigDecimal jian=subtract(BigDecimal.valueOf(5.66),BigDecimal.valueOf(3.347)); +// System.out.println("减法:"+jian); +// //乘法 +// BigDecimal chen=multiply(BigDecimal.valueOf(5.66),BigDecimal.valueOf(3.347)); +// System.out.println("乘法:"+chen); +// //除法 +// BigDecimal chu=divide(BigDecimal.valueOf(5.66),BigDecimal.valueOf(3.347)); +// System.out.println("积分:"+integral(BigDecimal.valueOf(101.88))); +// } + + + +} diff --git a/src/main/java/com/fengdu/gas/common/util/NumericUtil.java b/src/main/java/com/fengdu/gas/common/util/NumericUtil.java new file mode 100644 index 0000000..eeac7a6 --- /dev/null +++ b/src/main/java/com/fengdu/gas/common/util/NumericUtil.java @@ -0,0 +1,240 @@ +package com.fengdu.gas.common.util; + +import java.lang.reflect.Method; +import java.math.BigDecimal; +import java.text.DecimalFormat; + +/** + * 数值处理类 + * @author linliu + * @date 2018-12-28 + */ +public final class NumericUtil { + private NumericUtil() { + throw new IllegalStateException("Utility class"); + } + + /** + * 验证数值为空 + * @param num 传入数值 + */ + public static Boolean isNullOrEmpty(Number num) { + return num==null || num.doubleValue()==0; + } + + /** + * 验证数值非空 + * @param num 传入数值 + */ + public static Boolean isNotNullOrEmpty(Number num) { + return !NumericUtil.isNullOrEmpty(num); + } + + /** + * 判断传入值,是否在传入数组中 + * @param num 比较值 + * @param array 范围数组 + */ + public static Boolean includeIn(Number num, Number... array) { + return ListUtil.toList(array).contains(num); + } + + /** + * 字符串枚举值转成枚举对象 + * @author linliu + * @date 2018-12-24 + * @param enumType 枚举类型 + * @param value 枚举值 + * @param <T> 枚举类型 + * @return 枚举对象 + */ + public static <T extends Enum<T>> T parseEnum(Class<T> enumType, Integer value) { + if(null == value) { + return null; + } + + T result = null; + try { + T[] values = enumType.getEnumConstants(); + Method getValue = enumType.getMethod("getValue"); + + for (T e : values) { + if(getValue.invoke(e).equals(value)) { + result = e; + break; + } + } + } catch (Exception e) { + //TODO log + } + return result; + } + + /** + * 判断枚举是否申明了传入枚举值 + * @author linliu + * @date 2018-12-24 + * @param enumType 枚举类型 + * @param value 枚举值 + * @param <T> 枚举类型 + * @return 是否包含 + */ + public static <T extends Enum<T>> boolean isEnum(Class<T> enumType, Integer value) { + return (null != NumericUtil.parseEnum(enumType, value)); + } + + /** + * 尝试转换为 Integer + * @param value 传入值 + */ + public static Integer tryParseInt(Object value) { + return NumericUtil.tryParseInt(value, Integer.MIN_VALUE); + } + + /** + * 尝试转换为 Long + * @param value 传入值 + */ + public static Long tryParseLong(Object value) { + return NumericUtil.tryParseLong(value, Long.MIN_VALUE); + } + + /** + * 尝试转换为 Double + * @param value 传入值 + */ + public static Double tryParseDouble(Object value) { + return NumericUtil.tryParseDouble(value, Double.valueOf(String.valueOf(Long.MIN_VALUE))); + } + + /** + * 尝试转换为 BigDecimal + * @param value 传入值 + */ + public static BigDecimal tryParseBigDecimal(Object value) { + return NumericUtil.tryParseBigDecimal(value, new BigDecimal(String.valueOf(Long.MIN_VALUE))); + } + + /** + * 输出数值补“0”,不输出小数部分(如果传入数值位数不足传入最小位数,则在数值前补“0”,否则直接输出数值的字符串) + * @param value 传入数值 + * @param minLength 最小位数 + */ + public static String toDString(Number value, Integer minLength) { + String result = toNumberString(value, 0); + StringBuilder sb = new StringBuilder(); + while (result.length()+sb.length() < minLength) { + sb.append("0"); + } + sb.append(result); + return sb.toString(); + } + + /** + * 判断传入数值大小是否在“min”和“max”之间(不包含包含端值,即包含最大最小值) + * @param num 比较的数值 + * @param min 最小值 + * @param max 最大值 + */ + public static Boolean isInRange(Number num, Number min, Number max) { + BigDecimal dnum = tryParseBigDecimal(num); + BigDecimal dmin = tryParseBigDecimal(min); + BigDecimal dmax = tryParseBigDecimal(max); + return dnum.compareTo(dmin)>0 && dnum.compareTo(dmax)<0; + } + + /** + * 判断传入数值大小是否在“min”和“max”之间(包含端值,即包含最大最小值) + * @param num 比较的数值 + * @param min 最小值 + * @param max 最大值 + */ + public static Boolean isInRangeInclude(Number num, Number min, Number max) { + BigDecimal dnum = tryParseBigDecimal(num); + BigDecimal dmin = tryParseBigDecimal(min); + BigDecimal dmax = tryParseBigDecimal(max); + return dnum.compareTo(dmin)>-1 && dnum.compareTo(dmax)<1; + } + + /** + * 格式化输出小数(最多“length”位小数,如果小数部分某位后面全是0,则不展示) + * @param num 数字 + * @param length 最多展示的小数位数 + */ + public static String toNumberString(Number num, Integer length) { + length = tryParseInt(length); + StringBuilder sbFormat = new StringBuilder("#0"); + if(length.compareTo(0) > 0) { + sbFormat.append("."); + for(int i=0; i<length; i++) { + sbFormat.append("#"); + } + } + DecimalFormat df = new DecimalFormat(sbFormat.toString()); + return df.format(num); + } + + /** + * 尝试转换为 Integer + * @param value 传入值 + * @param defaultValue 传入值为空,或者转换失败时,返回的默认值 + */ + public static Integer tryParseInt(Object value, Integer defaultValue) { + if(null==value) { + return defaultValue; + } + try { + return Integer.parseInt(String.valueOf(value)); + } catch (Exception e) { + return defaultValue; + } + } + + /** + * 尝试转换为 Long + * @param value 传入值 + * @param defaultValue 传入值为空,或者转换失败时,返回的默认值 + */ + public static Long tryParseLong(Object value, Long defaultValue) { + if(null==value) { + return defaultValue; + } + try { + return Long.parseLong(String.valueOf(value)); + } catch (Exception e) { + return defaultValue; + } + } + + /** + * 尝试转换为 Double + * @param value 传入值 + * @param defaultValue 传入值为空,或者转换失败时,返回的默认值 + */ + public static Double tryParseDouble(Object value, Double defaultValue) { + if(null==value) { + return defaultValue; + } + try { + return Double.parseDouble(String.valueOf(value)); + } catch (Exception e) { + return defaultValue; + } + } + + /** + * 尝试转换为 BigDecimal + * @param value 传入值 + * @param defaultValue 传入值为空,或者转换失败时,返回的默认值 + */ + public static BigDecimal tryParseBigDecimal(Object value, BigDecimal defaultValue) { + if(null==value) { + return defaultValue; + } + try { + return new BigDecimal(String.valueOf(value)); + } catch (Exception e) { + return defaultValue; + } + } +} \ No newline at end of file diff --git a/src/main/java/com/fengdu/gas/common/util/OrderUtil.java b/src/main/java/com/fengdu/gas/common/util/OrderUtil.java new file mode 100644 index 0000000..236375f --- /dev/null +++ b/src/main/java/com/fengdu/gas/common/util/OrderUtil.java @@ -0,0 +1,13 @@ +package com.fengdu.gas.common.util; + +public class OrderUtil { + + public static String getOrderNo(String prefix) { + SnowFlake idWorker = new SnowFlake(7, 7); + long id = idWorker.nextId(); + String rechargeOrder = prefix + id; + return rechargeOrder; + } + + +} diff --git a/src/main/java/com/fengdu/gas/common/util/ParameterUtil.java b/src/main/java/com/fengdu/gas/common/util/ParameterUtil.java new file mode 100644 index 0000000..cfb6ef0 --- /dev/null +++ b/src/main/java/com/fengdu/gas/common/util/ParameterUtil.java @@ -0,0 +1,69 @@ +package com.fengdu.gas.common.util; + +import com.fengdu.gas.common.model.Tuple; +import com.fengdu.gas.common.ConstantFactory; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +public class ParameterUtil { + public static String named(String name) { + return "参数“" + name + "”"; + } + + public static String sqlASC(String name) { + return name + ConstantFactory.SQL_ASC; + } + + public static String sqlDESC(String name) { + return name + ConstantFactory.SQL_DESC; + } + + public static String sqlLikeValue(String value) { + return "%" + value + "%"; + } + + public static String dealNull(String parameter) { + if(StringUtil.isNullOrEmpty(parameter)) { + return ""; + } + return parameter.trim().replaceAll("\\t", "").replaceAll("\\r", "").replaceAll("\\n", ""); + } + + public static String dealNullStr(Object parameter, String defaultValue) { + if(Objects.isNull(parameter) || StringUtil.isNullOrEmpty(parameter.toString())) { + return defaultValue; + } + return parameter.toString(); + } + + public static String dealNullStr(Object parameter) { + return ParameterUtil.dealNullStr(parameter, ""); + } + + public static <T> List<T> dealNull(List<T> list) { + if(null == list) { + return new ArrayList<>(); + } + return list; + } + + public static String dealNotStr(String parameter) { + if(null == parameter) { + return parameter; + } + return parameter.trim().replaceAll("\\t", "").replaceAll("\\r", "").replaceAll("\\n", ""); + } + + public static Tuple<String, String> getTimeRange(String timeRange) { + if (StringUtil.isNullOrEmpty(timeRange)) { + return new Tuple<>("", ""); + } + String[] list = StringUtil.split(timeRange, ConstantFactory.STR_TIME_RANGE); + if (list.length != 2) { + return new Tuple<>("", ""); + } + return new Tuple<>(list[0], list[1]); + } +} diff --git a/src/main/java/com/fengdu/gas/common/util/PinYinUtil.java b/src/main/java/com/fengdu/gas/common/util/PinYinUtil.java new file mode 100644 index 0000000..8590adc --- /dev/null +++ b/src/main/java/com/fengdu/gas/common/util/PinYinUtil.java @@ -0,0 +1,88 @@ +package com.fengdu.gas.common.util; + +import net.sourceforge.pinyin4j.PinyinHelper; +import net.sourceforge.pinyin4j.format.HanyuPinyinCaseType; +import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat; +import net.sourceforge.pinyin4j.format.HanyuPinyinToneType; +import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination; + +public final class PinYinUtil { + private PinYinUtil() { + throw new IllegalStateException("Utility class"); + } + + /** + * 获取中文全拼 + * + * @param name 需要转换的中文 + * @return 全拼结果 + **/ + public static String getFullPinyin(String name) { + // 创建格式化对象 + HanyuPinyinOutputFormat outputFormat = new HanyuPinyinOutputFormat(); + //设置大小写格式 + outputFormat.setCaseType(HanyuPinyinCaseType.LOWERCASE); + //设置声调格式 + outputFormat.setToneType(HanyuPinyinToneType.WITHOUT_TONE); + // 放置输入结果 + StringBuilder result = new StringBuilder(); + // 字符数组 + char[] charArray = name.toCharArray(); + // 遍历字符 + for (char c : charArray) { + // 中文会被变成全拼,非中文会被直接拼接在结果字符串中 + if (Character.toString(c).matches("[\\u4E00-\\u9FA5]+")) { + String[] pinyinArray = new String[0]; + try { + pinyinArray = PinyinHelper.toHanyuPinyinStringArray(c, outputFormat); + } catch (BadHanyuPinyinOutputFormatCombination badHanyuPinyinOutputFormatCombination) { + badHanyuPinyinOutputFormatCombination.printStackTrace(); + } + if (pinyinArray != null) { + result.append(pinyinArray[0]); + } + } else { + result.append(c); + } + } + return result.toString(); + } + + /** + * 获取中文首字母 + * + * @param name 需要转换的中文 + * @return 首字母结果 + **/ + public static String getPinyinInitial(String name) { + // 创建格式化对象 + HanyuPinyinOutputFormat outputFormat = new HanyuPinyinOutputFormat(); + //设置大小写格式 + outputFormat.setCaseType(HanyuPinyinCaseType.UPPERCASE); + //设置声调格式 + outputFormat.setToneType(HanyuPinyinToneType.WITHOUT_TONE); + // 放置输入结果 + StringBuilder result = new StringBuilder(); + // 字符数组 + char[] charArray = name.toCharArray(); + // 遍历字符 + for (char c : charArray) { + // 中文会被变成拼音首字母,非中文会被直接拼接在结果字符串中 + if (Character.toString(c).matches("[\\u4E00-\\u9FA5]+")) { + String[] pinyinArray = new String[0]; + try { + pinyinArray = PinyinHelper.toHanyuPinyinStringArray(c, outputFormat); + } catch (BadHanyuPinyinOutputFormatCombination badHanyuPinyinOutputFormatCombination) { + badHanyuPinyinOutputFormatCombination.printStackTrace(); + } + if (pinyinArray != null) { + result.append(pinyinArray[0].charAt(0)); + } + } else { + result.append(c); + } + } + return result.toString(); + } + +} diff --git a/src/main/java/com/fengdu/gas/common/util/RandVerifyCode.java b/src/main/java/com/fengdu/gas/common/util/RandVerifyCode.java new file mode 100644 index 0000000..cfa2558 --- /dev/null +++ b/src/main/java/com/fengdu/gas/common/util/RandVerifyCode.java @@ -0,0 +1,106 @@ +package com.fengdu.gas.common.util; + +import java.util.Random; + +/** + * 随机验证码 工具类 + */ +public final class RandVerifyCode { + public static final Integer USE_ZERO = 1; + public static final Integer USE_O = 2; + public static final Integer USE_ONE = 1; + public static final Integer USE_I = 2; + + static char[] arrayCharCode = new char[] { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' }; + static char[] arrayComplexCode = new char[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' }; + + private RandVerifyCode() { + throw new IllegalStateException("Utility class"); + } + + /** + * 生成随机数字 + * @param length 生成长度 + */ + public static String numberCode(int length) { + try { + Thread.sleep(Long.valueOf("1")); + } catch (Exception e) { + e.getStackTrace(); + } + Random random = new Random(CalendarUtil.nowTimestamp()); + + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < length; i++) { + try { + Thread.sleep(Long.valueOf("1")); + } catch (Exception e) {} + sb.append(random.nextInt(Integer.valueOf("10"))); + } + return sb.toString(); + } + + /** + * 生成随机字母与数字 + * @param length 生成长度 + */ + public static String complexCode(int length) { + return complexCode(length, 2, 2); + } + + /** + * 生成随机字母与数字 + * @param length 生成长度 + * @param zeroOrO 为避免视觉歧义,数字零“0”和字母欧“O”如何取舍。取数字零=1,取字母欧=2 + * @param oneOrI 为避免视觉歧义,数字一“1”和字母艾“I”如何取舍。取数字一=1,取字母艾=2 + */ + public static String complexCode(int length, Integer zeroOrO, Integer oneOrI) { + int n = arrayComplexCode.length; + try { + Thread.sleep(Long.valueOf("1")); + } catch (Exception e) { + e.getStackTrace(); + } + Random random = new Random(CalendarUtil.nowTimestamp()); + + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < length; i++) { + int rnd = random.nextInt(n); + char code = arrayComplexCode[rnd]; + if('O'==code && USE_ZERO.equals(zeroOrO)) { + code = '0'; + } else if('0'==code && USE_O.equals(zeroOrO)) { + code = 'O'; + } + + if('I'==code && USE_ONE.equals(oneOrI)) { + code = '1'; + } else if('1'==code && USE_I.equals(oneOrI)) { + code = 'I'; + } + sb.append(code); + } + return sb.toString(); + } + + /** + * 生成随机纯字母随机数 + * @param length 生成长度 + */ + public static String charCode(int length) { + int n = arrayCharCode.length; + try { + Thread.sleep(Long.valueOf("1")); + } catch (Exception e) { + e.getStackTrace(); + } + Random random = new Random(CalendarUtil.nowTimestamp()); + + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < length; i++) { + int rnd = random.nextInt(n); + sb.append(arrayCharCode[rnd]); + } + return sb.toString(); + } +} \ No newline at end of file diff --git a/src/main/java/com/fengdu/gas/common/util/SM2Util.java b/src/main/java/com/fengdu/gas/common/util/SM2Util.java new file mode 100644 index 0000000..353d136 --- /dev/null +++ b/src/main/java/com/fengdu/gas/common/util/SM2Util.java @@ -0,0 +1,162 @@ +package com.fengdu.gas.common.util; + +import org.bouncycastle.crypto.CipherParameters; +import org.bouncycastle.crypto.params.ECPrivateKeyParameters; +import org.bouncycastle.crypto.params.ECPublicKeyParameters; +import org.bouncycastle.crypto.params.ParametersWithRandom; +import org.bouncycastle.crypto.signers.SM2Signer; +import org.bouncycastle.jcajce.provider.asymmetric.util.ECUtil; +import org.bouncycastle.jce.provider.BouncyCastleProvider; +import org.springframework.util.Base64Utils; + +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.security.*; +import java.security.spec.*; + +public class SM2Util { + /** + * 要生成的EC域参数的标准名称 + */ + private static final String STANDARD_NAME = "sm2p256v1"; + /** + * 算法 + */ + private static final String ALGORITHM = "EC"; + /** + * 字符编码 + */ + private static final Charset CHARSET = StandardCharsets.UTF_8; + + /** + * 生成密钥对 + * + * @return 密钥对 + */ + private static KeyPair generateSm2KeyPair() throws NoSuchAlgorithmException, InvalidAlgorithmParameterException { + //使用标准名称创建EC参数生成的参数规范 + final ECGenParameterSpec sm2Spec = new ECGenParameterSpec(STANDARD_NAME); + + // 获取一个椭圆曲线类型的密钥对生成器 + final KeyPairGenerator kpg = KeyPairGenerator.getInstance(ALGORITHM, new BouncyCastleProvider()); + + kpg.initialize(sm2Spec, new SecureRandom()); + // 通过密钥生成器生成密钥对 + return kpg.generateKeyPair(); + } + + /** + * 生成密钥对 + * + * @return 密钥对 + */ + public static String[] genKeyPair() throws InvalidAlgorithmParameterException, NoSuchAlgorithmException { + KeyPair keyPair = generateSm2KeyPair(); + PrivateKey privateKey = keyPair.getPrivate(); + PublicKey publicKey = keyPair.getPublic(); + return new String[]{ + Base64Utils.encodeToString(privateKey.getEncoded()), + Base64Utils.encodeToString(publicKey.getEncoded()) + }; + } + + /** + * 私钥转换为 {@link ECPrivateKeyParameters} + * + * @param key 私钥 + * @return 私钥{@link ECPrivateKeyParameters} + */ + private static ECPrivateKeyParameters privateKeyToParams(byte[] key) throws InvalidKeyException, InvalidKeySpecException, NoSuchAlgorithmException { + KeySpec keySpec = new PKCS8EncodedKeySpec(key); + PrivateKey privateKey = getKeyFactory().generatePrivate(keySpec); + ; + return (ECPrivateKeyParameters) ECUtil.generatePrivateKeyParameter(privateKey); + } + + /** + * 公钥转换为 {@link ECPublicKeyParameters} + * + * @param key 公钥 + * @return 公钥{@link ECPublicKeyParameters} + */ + private static ECPublicKeyParameters publicKeyToParams(byte[] key) throws InvalidKeyException, InvalidKeySpecException, NoSuchAlgorithmException { + KeySpec keySpec = new X509EncodedKeySpec(key); + PublicKey publicKey = getKeyFactory().generatePublic(keySpec); + return (ECPublicKeyParameters) ECUtil.generatePublicKeyParameter(publicKey); + } + + /** + * 获取{@link KeyFactory} + * + * @return {@link KeyFactory} + */ + private static KeyFactory getKeyFactory() throws NoSuchAlgorithmException { + final Provider provider = new BouncyCastleProvider(); + return KeyFactory.getInstance(ALGORITHM, provider); + } + + /** + * 签名 + * + * @param content 原始串 + * @param priKey 私钥 + * @return 签名 + */ + public static String sign(String content, String priKey) throws Exception { + byte[] data = content.getBytes(CHARSET); + byte[] privateKey = Base64Utils.decode(priKey.getBytes(CHARSET)); + + SM2Signer signer = new SM2Signer(); + CipherParameters param = new ParametersWithRandom(privateKeyToParams(privateKey)); + signer.init(true, param); + signer.update(data, 0, data.length); + + byte[] buffer = signer.generateSignature(); + + return Base64Utils.encodeToString(buffer); + } + + /** + * 用公钥检验数字签名的合法性 + * + * @param content 原始串 + * @param sign 待验证签名 + * @param publicKey 私钥 + * @return 是否验证通过 + */ + public static boolean verify(String content, String sign, String publicKey) throws Exception { + byte[] data = content.getBytes(CHARSET); + byte[] signBuffer = Base64Utils.decodeFromString(sign); + byte[] keyBuffer = Base64Utils.decodeFromString(publicKey); + + SM2Signer signer = new SM2Signer(); + CipherParameters param = publicKeyToParams(keyBuffer); + signer.init(false, param); + signer.update(data, 0, data.length); + return signer.verifySignature(signBuffer); + } + + + +// public static void main(String[] args) { +// Security.addProvider(new BouncyCastleProvider()); +// +// try { +// // 生成密钥对 +// String[] keyPair = SM2Util.genKeyPair(); +// String privateKey = keyPair[0]; +// String publicKey = keyPair[1]; +// +// // 对消息进行签名 +// String message = "你好,世界!"; +// String signature = SM2Util.sign(message, privateKey); +// System.out.println("生成的签名: " + signature); +// +// // 验证签名 +// boolean isValid = SM2Util.verify(message, signature, publicKey); +// System.out.println("签名验证结果: " + isValid); +// } catch (Exception e) { +// e.printStackTrace(); +// } +// } +} diff --git a/src/main/java/com/fengdu/gas/common/util/SM4Util.java b/src/main/java/com/fengdu/gas/common/util/SM4Util.java new file mode 100644 index 0000000..0584d60 --- /dev/null +++ b/src/main/java/com/fengdu/gas/common/util/SM4Util.java @@ -0,0 +1,93 @@ +package com.fengdu.gas.common.util; + + +import org.springframework.util.Base64Utils; + +import javax.crypto.Cipher; +import javax.crypto.spec.IvParameterSpec; +import javax.crypto.spec.SecretKeySpec; +import java.nio.charset.StandardCharsets; +import java.util.Random; + +public class SM4Util { + /** + * 算法名字 + */ + private static final String NAME = "SM4"; + /** + * 加密模式以及短快填充方式 + */ + private static final String ALGORITHM = "SM4/CBC/PKCS5Padding"; + /** + * 加密使用的初始向量 + */ + private static final String IV = "0000000000000000"; + /** + * 密钥长度(128-32位16进制;256-64位16进制) + */ + private static final int KEY_SIZE = 16; + + private static final String ALL_STR = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; + + public static String generateKey() { + Random random = new Random(); + StringBuffer sb = new StringBuffer(); + for (int i = 0; i < KEY_SIZE; i++) { + int number = random.nextInt(ALL_STR.length()); + sb.append(ALL_STR.charAt(number)); + } + return sb.toString(); + } + + /** + * 使用指定的加密算法和密钥对给定的字节数组进行加密 + * + * @param content 待加密的原始字符串 + * @param key 密钥(注意必须是128bits,即16个字节) + * @return 加密后的字符串 + * @throws Exception 如果加密时发生错误,则抛出异常 + */ + public static String encode(String content, String key) throws Exception { + try { + byte[] inputByte = content.getBytes(StandardCharsets.UTF_8); + byte[] keyBuffer = key.getBytes(StandardCharsets.UTF_8); + + // 获取加密实例 + Cipher c = Cipher.getInstance(ALGORITHM); + // 根据密钥的字节数组创建 SecretKeySpec + SecretKeySpec secretKeySpec = new SecretKeySpec(keyBuffer, NAME); + // 创建 IvParameterSpec 对象,使用默认向量和字符集 + IvParameterSpec ivParameterSpec = new IvParameterSpec(IV.getBytes(StandardCharsets.UTF_8)); + // 初始化加密实例 + c.init(Cipher.ENCRYPT_MODE, secretKeySpec, ivParameterSpec); + // 返回加密后的字节数组 + byte[] buffer = c.doFinal(inputByte); + return Base64Utils.encodeToString(buffer); + } catch (Exception e) { + throw new Exception("加密失败: " + e, e); + } + } + + /** + * 解密 + * + * @param content 待解密字符串 + * @param key 密钥(注意必须是128bits,即16个字节) + * @return 解密后的原始字符串 + * @throws Exception 如果解密时发生错误,则抛出异常 + */ + public static String decode(String content, String key) throws Exception { + try { + byte[] inputBytes = Base64Utils.decode(content.getBytes(StandardCharsets.UTF_8)); + byte[] keyBuffer = key.getBytes(StandardCharsets.UTF_8); + Cipher cipher = Cipher.getInstance(ALGORITHM); + SecretKeySpec secretKeySpec = new SecretKeySpec(keyBuffer, NAME); + IvParameterSpec ivParameterSpec = new IvParameterSpec(IV.getBytes(StandardCharsets.UTF_8)); + cipher.init(Cipher.DECRYPT_MODE, secretKeySpec, ivParameterSpec); + byte[] buffer = cipher.doFinal(inputBytes); + return new String(buffer, StandardCharsets.UTF_8); + } catch (Exception e) { + throw new Exception("解密失败: " + e, e); + } + } +} diff --git a/src/main/java/com/fengdu/gas/common/util/SerializeUtil.java b/src/main/java/com/fengdu/gas/common/util/SerializeUtil.java new file mode 100644 index 0000000..7f21bad --- /dev/null +++ b/src/main/java/com/fengdu/gas/common/util/SerializeUtil.java @@ -0,0 +1,282 @@ +package com.fengdu.gas.common.util; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.databind.*; +import com.fasterxml.jackson.databind.module.SimpleModule; +import com.fasterxml.jackson.dataformat.xml.PackageVersion; +import com.fasterxml.jackson.dataformat.xml.XmlMapper; +import com.google.gson.Gson; +import com.google.gson.JsonArray; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import com.fengdu.gas.common.serializer.*; +import com.fengdu.gas.common.serializer.deserializer.*; + +import java.io.IOException; +import java.sql.Timestamp; +import java.text.SimpleDateFormat; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.util.*; + +/** + * json/XML处理类 + * @author linliu + * @date 2018-12-28 + */ +public final class SerializeUtil { + private SerializeUtil() { + throw new IllegalStateException("Utility class"); + } + + //region 字符串常量 + private static final String TITLE = "SerializeUtil"; + //endregion + + private static final ObjectMapper JSON_MAPPER = new ObjectMapper(); + private static final XmlMapper XML_MAPPER = new XmlMapper(); + + static { + //忽略字段大小写 + XML_MAPPER.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES, true); + //忽略字段数量不一致 + XML_MAPPER.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + + //默认json序列化设置 + SerializeUtil.initSerializationConfigure(JSON_MAPPER); + } + /** + * 默认json序列化设置 + * @param JSON_MAPPER mapper实例 + */ + private static void initSerializationConfigure(ObjectMapper JSON_MAPPER) { + //忽略字段大小写 + JSON_MAPPER.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES, true); + + //此配置反序列化的时候如果多了属性, 不抛出异常。不设置这个json字符串只能少属性,不能多属性,否者会抛异常 + JSON_MAPPER.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + + //如果是空对象的时候,不抛异常 + JSON_MAPPER.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false); + + //******************************* 处理日期类型序列化和反序列化 ******************************* + + //取消时间的转化格式,默认是时间戳,可以取消,同时需要设置要表现的时间格式 + JSON_MAPPER.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); + + SimpleModule serializerModule = new SimpleModule("CQDateTimeSerializer", PackageVersion.VERSION); + + serializerModule.addSerializer(Date.class, new CQDateSerializer()); + serializerModule.addDeserializer(Date.class, new CQDateDeSerializer()); + + serializerModule.addSerializer(Calendar.class, new CQCalendarSerializer()); + serializerModule.addDeserializer(Calendar.class, new CQCalendarDeSerializer()); + + serializerModule.addSerializer(LocalDate.class, new CQLocalDateSerializer()); + serializerModule.addDeserializer(LocalDate.class, new CQLocalDateDeSerializer()); + + serializerModule.addSerializer(LocalDateTime.class, new CQLocalDateTimeSerializer()); + serializerModule.addDeserializer(LocalDateTime.class, new CQLocalDateTimeDeSerializer()); + + serializerModule.addSerializer(Timestamp.class, new CQTimestampSerializer()); + serializerModule.addDeserializer(Timestamp.class, new CQTimestampDeSerializer()); + + JSON_MAPPER.registerModule(serializerModule); + //******************************* 处理日期类型序列化和反序列化 ******************************* + + /* + + //序列化的时候序列对象的所有属性 + JSON_MAPPER.setSerializationInclusion(JsonInclude.Include.ALWAYS); + + */ + } + + /** + * json字符串转 T 类型实体 + * @param json json字符串 + * @param clazz 实体类型 + * @param <T> 实体类型 + */ + public static <T> T toObject(String json, Class<T> clazz) { + if(StringUtil.isNullOrEmpty(json)){ + return null; + } + try { + if(Objects.equals(clazz, JsonObject.class)) { + JsonParser jsonParser = new JsonParser(); + return (T)jsonParser.parse(json).getAsJsonObject(); + } + return JSON_MAPPER.readValue(json, clazz); + } catch (IOException e) { + //TODO log + throw new RuntimeException(e); + } + } + + /** + * json字符串转 List→T 类型集合 + * @param json json字符串 + * @param clazz 实体类型 + * @param <T> 实体类型 + */ + public static <T> List<T> toListObject(String json, Class<T> clazz){ + if(StringUtil.isNullOrEmpty(json)){ + return new ArrayList<>(); + } + try{ + //这种返回的是List<LinkedMap> + //return JSON_MAPPER.readValue(json, new TypeReference<List<T>>() {}); + return SerializeUtil.toObject(json, List.class, clazz); + } catch (Exception e) { + //TODO log + throw new RuntimeException(e); + } + } + + /** + * json字符串转 T 类型实体 + * @param json json字符串 + * @param genericClass 实体类型 + * @param clazz 实体类型 + * @param <T> 实体类型 + */ + public static <T> T toObject(String json, Class<?> genericClass, Class<?> clazz) { + if(StringUtil.isNullOrEmpty(json)){ + return null; + } + try { + JavaType type = JSON_MAPPER.getTypeFactory().constructParametricType(genericClass, clazz); + return JSON_MAPPER.readValue(json, type); + } catch (IOException e) { + //TODO log + throw new RuntimeException(e); + } + } + + public static String toJson(Object obj) { + if(obj==null){ + return null; + } + try { + if(obj instanceof JsonObject || obj instanceof JsonArray) { + return obj.toString(); + } else { + return JSON_MAPPER.writeValueAsString(obj); + } + } catch (Exception e) { + //TODO log + throw new RuntimeException(e); + } + } + public static String toJsonWithoutNull(Object obj) { + if(obj==null){ + return null; + } + try { + if (obj instanceof JsonObject || obj instanceof JsonArray) { + return obj.toString(); + } else { + ObjectMapper mapper = new ObjectMapper(); + //默认json序列化设置 + SerializeUtil.initSerializationConfigure(mapper); + mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); + return mapper.writeValueAsString(obj); + } + } catch (Exception e) { + //TODO log + throw new RuntimeException(e); + } + } + + public static String toCSharpJson(Object obj) { + if(obj==null){ + return null; + } + try { + if (obj instanceof JsonObject || obj instanceof JsonArray) { + return obj.toString(); + } else { + ObjectMapper mapper = new ObjectMapper(); + //默认json序列化设置 + SerializeUtil.initSerializationConfigure(mapper); + // deprecated mapper.setPropertyNamingStrategy(PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES); + mapper.setPropertyNamingStrategy(PropertyNamingStrategy.UPPER_CAMEL_CASE); + return mapper.writeValueAsString(obj); + } + } catch (Exception e) { + //TODO log + throw new RuntimeException(e); + } + } + + public static String toJson(Object obj, String dateFormat) { + if(obj==null){ + return null; + } + try { + if (obj instanceof JsonObject || obj instanceof JsonArray) { + return obj.toString(); + } else { + ObjectMapper mapper = new ObjectMapper(); + //默认json序列化设置 + SerializeUtil.initSerializationConfigure(mapper); + mapper.setDateFormat(new SimpleDateFormat(dateFormat)); + return mapper.writeValueAsString(obj); + } + } catch (Exception e) { + //TODO log + throw new RuntimeException(e); + } + } + + public static <T> T fromXml(String xml, Class<T> clazz) { + if(StringUtil.isNullOrEmpty(xml)){ + return null; + } + try { + return XML_MAPPER.readValue(xml, clazz); + } catch (Exception e) { + //TODO log + throw new RuntimeException(e); + } + } + + public static <T> T fromXml(String xml, Class<?> genericClass, Class<?> clazz) { + if(StringUtil.isNullOrEmpty(xml)){ + return null; + } + try { + JavaType type = XML_MAPPER.getTypeFactory().constructParametricType(genericClass, clazz); + return XML_MAPPER.readValue(xml, type); + } catch (Exception e) { + //TODO log + throw new RuntimeException(e); + } + } + + public static String toXml(Object obj) { + if(obj == null){ + return ""; + } + try{ + return XML_MAPPER.writeValueAsString(obj); + } catch (Exception e) { + //TODO log + throw new RuntimeException(e); + } + } + + public static JsonObject toJSONObject(Object obj) { + if(null==obj) { + return null; + } + try { + String json = new Gson().toJson(obj); + return new JsonParser().parse(json).getAsJsonObject(); + } catch (Exception e) { + //TODO log + throw new RuntimeException(e); + } + } +} \ No newline at end of file diff --git a/src/main/java/com/fengdu/gas/common/util/SnowFlake.java b/src/main/java/com/fengdu/gas/common/util/SnowFlake.java new file mode 100644 index 0000000..1d4d5a8 --- /dev/null +++ b/src/main/java/com/fengdu/gas/common/util/SnowFlake.java @@ -0,0 +1,198 @@ +package com.fengdu.gas.common.util; + + +/** + * + * + * 生成唯一id + * + * + * Twitter_Snowflake<br> + * SnowFlake的结构如下(每部分用-分开):<br> + * 0 - 0000000000 0000000000 0000000000 0000000000 0 - 00000 - 00000 - 000000000000 <br> + * 1位标识,由于long基本类型在Java中是带符号的,最高位是符号位,正数是0,负数是1,所以id一般是正数,最高位是0<br> + * 41位时间截(毫秒级),注意,41位时间截不是存储当前时间的时间截,而是存储时间截的差值(当前时间截 - 开始时间截) + * 得到的值),这里的的开始时间截,一般是我们的id生成器开始使用的时间,由我们程序来指定的(如下下面程序IdWorker类的startTime属性)。41位的时间截,可以使用69年,年T = (1L << 41) / (1000L * 60 * 60 * 24 * 365) = 69<br> + * 10位的数据机器位,可以部署在1024个节点,包括5位datacenterId和5位workerId<br> + * 12位序列,毫秒内的计数,12位的计数顺序号支持每个节点每毫秒(同一机器,同一时间截)产生4096个ID序号<br> + * 加起来刚好64位,为一个Long型。<br> + * SnowFlake的优点是,整体上按照时间自增排序,并且整个分布式系统内不会产生ID碰撞(由数据中心ID和机器ID作区分),并且效率较高,经测试,SnowFlake每秒能够产生26万ID左右。 + * + * @author Lucifer + */ +public class SnowFlake { + + // ==============================Fields=========================================== + /** + * 开始时间截 (2018-07-03) + */ + + private final long twepoch = 1530607760000L; + + /** + * 机器id所占的位数 + */ + private final long workerIdBits = 5L; + + /** + * 数据标识id所占的位数 + */ + private final long datacenterIdBits = 5L; + + /** + * 支持的最大机器id,结果是31 (这个移位算法可以很快的计算出几位二进制数所能表示的最大十进制数) + */ + private final long maxWorkerId = -1L ^ (-1L << workerIdBits); + + /** + * 支持的最大数据标识id,结果是31 + */ + private final long maxDatacenterId = -1L ^ (-1L << datacenterIdBits); + + /** + * 序列在id中占的位数 + */ + private final long sequenceBits = 12L; + + /** + * 机器ID向左移12位 + */ + private final long workerIdShift = sequenceBits; + + /** + * 数据标识id向左移17位(12+5) + */ + private final long datacenterIdShift = sequenceBits + workerIdBits; + + /** + * 时间截向左移22位(5+5+12) + */ + private final long timestampLeftShift = sequenceBits + workerIdBits + datacenterIdBits; + + /** + * 生成序列的掩码,这里为4095 (0b111111111111=0xfff=4095) + */ + private final long sequenceMask = -1L ^ (-1L << sequenceBits); + + /** + * 工作机器ID(0~31) + */ + private long workerId; + + /** + * 数据中心ID(0~31) + */ + private long datacenterId; + + /** + * 毫秒内序列(0~4095) + */ + private long sequence = 0L; + + /** + * 上次生成ID的时间截 + */ + private long lastTimestamp = -1L; + + //==============================Constructors===================================== + + /** + * 构造函数 + * + * @param workerId 工作ID (0~31) + * @param datacenterId 数据中心ID (0~31) + */ + public SnowFlake(long workerId, long datacenterId) { + if (workerId > maxWorkerId || workerId < 0) { + throw new IllegalArgumentException(String.format("worker Id can't be greater than %d or less than 0", maxWorkerId)); + } + if (datacenterId > maxDatacenterId || datacenterId < 0) { + throw new IllegalArgumentException(String.format("datacenter Id can't be greater than %d or less than 0", maxDatacenterId)); + } + this.workerId = workerId; + this.datacenterId = datacenterId; + } + + // ==============================Methods========================================== + + /** + * 获得下一个ID (该方法是线程安全的) + * + * @return SnowflakeId + */ + public synchronized long nextId() { + long timestamp = timeGen(); + + //如果当前时间小于上一次ID生成的时间戳,说明系统时钟回退过这个时候应当抛出异常 + if (timestamp < lastTimestamp) { + throw new RuntimeException( + String.format("Clock moved backwards. Refusing to generate id for %d milliseconds", lastTimestamp - timestamp)); + } + + //如果是同一时间生成的,则进行毫秒内序列 + if (lastTimestamp == timestamp) { + sequence = (sequence + 1) & sequenceMask; + //毫秒内序列溢出 + if (sequence == 0) { + //阻塞到下一个毫秒,获得新的时间戳 + timestamp = tilNextMillis(lastTimestamp); + } + } + //时间戳改变,毫秒内序列重置 + else { + sequence = 0L; + } + + //上次生成ID的时间截 + lastTimestamp = timestamp; + + //移位并通过或运算拼到一起组成64位的ID + return (((timestamp - twepoch) << timestampLeftShift) + | (datacenterId << datacenterIdShift) + | (workerId << workerIdShift) + | sequence); + } + + /** + * 阻塞到下一个毫秒,直到获得新的时间戳 + * + * @param lastTimestamp 上次生成ID的时间截 + * @return 当前时间戳 + */ + protected long tilNextMillis(long lastTimestamp) { + long timestamp = timeGen(); + while (timestamp <= lastTimestamp) { + timestamp = timeGen(); + } + return timestamp; + } + + /** + * 返回以毫秒为单位的当前时间 + * + * @return 当前时间(毫秒) + */ + protected long timeGen() { + return System.currentTimeMillis(); + } + + //==============================Test============================================= + + /** + * 测试 + */ + +// public static void main(String[] args) { +// long startTime = System.currentTimeMillis(); +// SnowFlake idWorker = new SnowFlake(30, 30); +// Set set = new HashSet(); +// for (int i = 0; i < 10; i++) { +// long id = idWorker.nextId(); +// set.add(id); +// System.out.println("id----"+i+":"+id); +// } +// long endTime = System.currentTimeMillis(); +// System.out.println("set.size():" + set.size()); +// System.out.println("endTime-startTime:" + (endTime - startTime)); +// } +} \ No newline at end of file diff --git a/src/main/java/com/fengdu/gas/common/util/SnowFlakeUtil.java b/src/main/java/com/fengdu/gas/common/util/SnowFlakeUtil.java new file mode 100644 index 0000000..809f626 --- /dev/null +++ b/src/main/java/com/fengdu/gas/common/util/SnowFlakeUtil.java @@ -0,0 +1,115 @@ +package com.fengdu.gas.common.util; + +public class SnowFlakeUtil { + + /** + * 起始的时间戳(2020-05-27 00:00:00) + */ + private final static long START_STAMP = 1590508800000L; + + /** + * 每一部分占用的位数 + */ + //序列号占用的位数 + private final static long SEQUENCE_BIT = 12; + //机器标识占用的位数 + private final static long MACHINE_BIT = 5; + //数据中心占用的位数 + private final static long DATA_CENTER_BIT = 5; + + /** + * 每一部分的最大值 + */ + private final static long MAX_DATA_CENTER_NUM = -1L ^ (-1L << DATA_CENTER_BIT); + private final static long MAX_MACHINE_NUM = -1L ^ (-1L << MACHINE_BIT); + private final static long MAX_SEQUENCE = -1L ^ (-1L << SEQUENCE_BIT); + + /** + * 每一部分向左的位移 + */ + private final static long MACHINE_LEFT = SEQUENCE_BIT; + private final static long DATA_CENTER_LEFT = SEQUENCE_BIT + MACHINE_BIT; + private final static long TIMESTAMP_LEFT = DATA_CENTER_LEFT + DATA_CENTER_BIT; + + /** + * 单例模式 + */ + private static SnowFlakeUtil snowFlake; + + static { + snowFlake = new SnowFlakeUtil(1L, 2L); + } + + public static long getId() { + return snowFlake.nextId(); + } + + public static long getId(long machineId) { + return SnowFlakeUtil.getId(1L, machineId); + } + + public static long getId(long dataCenterId, long machineId) { + return new SnowFlakeUtil(dataCenterId, machineId).nextId(); + } + + //数据中心 + private long dataCenterId; + //机器标识 + private long machineId; + //序列号 + private long sequence = 0L; + //上一次时间戳 + private long lastStamp = -1L; + + private SnowFlakeUtil(long dataCenterId, long machineId) { + if (dataCenterId > MAX_DATA_CENTER_NUM || dataCenterId < 0) { + throw new IllegalArgumentException("dataCenterId can't be greater than MAX_DATA_CENTER_NUM or less than 0"); + } + if (machineId > MAX_MACHINE_NUM || machineId < 0) { + throw new IllegalArgumentException("machineId can't be greater than MAX_MACHINE_NUM or less than 0"); + } + this.dataCenterId = dataCenterId; + this.machineId = machineId; + } + + /** + * 产生下一个ID + */ + public synchronized long nextId() { + long currStamp = getNewStamp(); + if (currStamp < lastStamp) { + throw new RuntimeException("Clock moved backwards. Refusing to generate id"); + } + + if (currStamp == lastStamp) { + //相同毫秒内,序列号自增 + sequence = (sequence + 1) & MAX_SEQUENCE; + //同一毫秒的序列数已经达到最大 + if (sequence == 0L) { + currStamp = getNextMill(); + } + } else { + //不同毫秒内,序列号置为0 + sequence = 0L; + } + + lastStamp = currStamp; + + return (currStamp - START_STAMP) << TIMESTAMP_LEFT //时间戳部分 + | dataCenterId << DATA_CENTER_LEFT //数据中心部分 + | machineId << MACHINE_LEFT //机器标识部分 + | sequence; //序列号部分 + } + + private long getNextMill() { + long mill = getNewStamp(); + while (mill <= lastStamp) { + mill = getNewStamp(); + } + return mill; + } + + private long getNewStamp() { + return LocalDateTimeUtil.nowTimeStamp(); + } +} diff --git a/src/main/java/com/fengdu/gas/common/util/SpringUtil.java b/src/main/java/com/fengdu/gas/common/util/SpringUtil.java new file mode 100644 index 0000000..d6886eb --- /dev/null +++ b/src/main/java/com/fengdu/gas/common/util/SpringUtil.java @@ -0,0 +1,44 @@ +package com.fengdu.gas.common.util; + +import org.springframework.beans.BeansException; +import org.springframework.context.ApplicationContext; +import org.springframework.context.ApplicationContextAware; +import org.springframework.stereotype.Component; + +/** + * Spring工具类 + * Created by macro on 2020/3/3. + */ +@Component +public class SpringUtil implements ApplicationContextAware { + + private static ApplicationContext applicationContext; + + // 获取applicationContext + public static ApplicationContext getApplicationContext() { + return applicationContext; + } + + @Override + public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { + if (SpringUtil.applicationContext == null) { + SpringUtil.applicationContext = applicationContext; + } + } + + // 通过name获取Bean + public static Object getBean(String name) { + return getApplicationContext().getBean(name); + } + + // 通过class获取Bean + public static <T> T getBean(Class<T> clazz) { + return getApplicationContext().getBean(clazz); + } + + // 通过name,以及Clazz返回指定的Bean + public static <T> T getBean(String name, Class<T> clazz) { + return getApplicationContext().getBean(name, clazz); + } + +} diff --git a/src/main/java/com/fengdu/gas/common/util/StringUtil.java b/src/main/java/com/fengdu/gas/common/util/StringUtil.java new file mode 100644 index 0000000..cc9a4da --- /dev/null +++ b/src/main/java/com/fengdu/gas/common/util/StringUtil.java @@ -0,0 +1,847 @@ +package com.fengdu.gas.common.util; + +import com.fengdu.gas.common.security.MD5Util; +import com.fengdu.gas.common.ConstantFactory; +import org.apache.commons.lang3.EnumUtils; +import org.apache.commons.lang3.StringUtils; + +import java.lang.reflect.Method; +import java.math.BigDecimal; +import java.nio.charset.Charset; +import java.util.*; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import java.util.stream.Collectors; + +/** + * 字符串处理类 + * @author linliu + * @date 2018-12-28 + */ +public final class StringUtil { + //region 常量 + private static final String REGX_MOBILEPHONE = "^((\\+86)|(\\(\\+86\\))-)?[0-9]{11}$"; + + private static final String REGX_TELEPHONE = "^((\\+86)|(\\(\\+86\\))-)?(((0[1,2]{1}\\d{1})?-?\\d{8})|((0[3-9]{1}\\d{2})?-?\\d{7,8}))$"; + + private static final String REGX_IDCARD = "^([0-9]{17}[0-9X]{1})|([0-9]{15})$"; + + private static final String REGX_WEBURL = "^(((file|gopher|news|nntp|telnet|http|ftp|https|ftps|sftp)://)|(www\\.))+(([a-zA-Z0-9\\._-]+\\.[a-zA-Z]{2,6})|([0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}))(/[a-zA-Z0-9\\&%_\\./-~-]*)?$"; + + private static final String REGX_EMAIL = "^\\w+([-+.']\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$"; + + private static final String REGX_MONEY = "^\\d{1,12}(?:\\.\\d{1,4})?$"; + + private static final String DEFAULT = "utf-8"; + //endregion + + private StringUtil() { + throw new IllegalStateException("Utility class"); + } + + /** + * 从当前对象移除头尾指定字符 + * @author xiangyuanzhang + * @date 2018-12-25 + * @param source 原始字符串 + * @param trimChar 移除字符串 + */ + public String trim(String source, String trimChar) { + if(source==null){ + return ""; + } + source = source.trim(); + if(source.isEmpty()){ + return ""; + } + String beginChar = source.substring(0, 1); + if (beginChar.equalsIgnoreCase(trimChar)) { + source = source.substring(1, source.length()); + } + String endChar = source.substring(source.length() - 1, source.length()); + if (endChar.equalsIgnoreCase(trimChar)) { + source = source.substring(0, source.length() - 1); + } + return source; + } + + /** + * 从当前对象移除头部指定字符 + * @author xiangyuanzhang + * @date 2018-12-25 + * @param source 原始字符串 + * @param trimChar 移除字符串 + */ + public String trimStart(String source, String trimChar) { + if(source==null){ + return ""; + } + source = source.trim(); + if(source.isEmpty()){ + return ""; + } + String beginChar = source.substring(0, 1); + if (beginChar.equalsIgnoreCase(trimChar)) { + source = source.substring(1, source.length()); + } + return source; + } + + /** + * 从当前对象移除尾部指定字符 + * @author xiangyuanzhang + * @date 2018-12-25 + * @param source 原始字符串 + * @param trimChar 移除字符串 + */ + public String trimEnd(String source, String trimChar) { + if(source==null){ + return ""; + } + source = source.trim(); + if(source.isEmpty()){ + return ""; + } + String endChar = source.substring(source.length() - 1, source.length()); + if (endChar.equalsIgnoreCase(trimChar)) { + source = source.substring(0, source.length() - 1); + } + return source; + } + + /** + * 字符串枚举值转成枚举对象 + * @author linliu + * @date 2018-12-24 + * @param enumType 枚举类型 + * @param value 枚举值 + * @param <T> 枚举类型 + * @return 枚举对象 + */ + public static <T extends Enum<T>> T parseEnum(Class<T> enumType, String value) { + if(isNullOrEmpty(value)) { + return null; + } + + T result = null; + try { + T[] values = enumType.getEnumConstants(); + Method getValue = enumType.getMethod("getValue"); + + for (T e : values) { + if(getValue.invoke(e).toString().equals(value)) { + result = e; + break; + } + } + } catch (Exception e) { + //TODO log + } + return result; + } + + /** + * 字符串枚举值转成枚举对象 + * @author linliu + * @date 2018-12-24 + * @param enumType 枚举类型 + * @param name 枚举名称 + * @param <T> 枚举类型 + * @return 枚举对象 + */ + public static <T extends Enum<T>> T parseEnumByName(Class<T> enumType, String name) { + if(isNullOrEmpty(name)) { + return null; + } + + T result = null; + try { + result = EnumUtils.getEnum(enumType, name); + } catch (Exception e) { + //TODO log + } + return result; + } + + /** + * 判断枚举是否申明了传入枚举值 + * @author linliu + * @date 2018-12-24 + * @param enumType 枚举类型 + * @param value 枚举值 + * @param <T> 枚举类型 + * @return 是否包含 + */ + public static <T extends Enum<T>> boolean isEnum(Class<T> enumType, String value) { + return (null != parseEnum(enumType, value)); + } + + /** + * 判断枚举是否申明了传入枚举值 + * @author linliu + * @date 2018-12-24 + * @param enumType 枚举类型 + * @param name 枚举名称 + * @param <T> 枚举类型 + * @return 是否包含 + */ + public static <T extends Enum<T>> boolean isEnumName(Class<T> enumType, String name) { + return EnumUtils.isValidEnum(enumType, name); + } + + /** + * 字符串是否为空 + * @author linliu + * @date 2018-12-25 + * @param str 字符串 + * @return 是否为空 + */ + public static boolean isNullOrEmpty(String str){ + return (str==null || str.equals("") || str.replace(" ","").length() == 0); + } + + /** + * 字符串非空 + * @author linliu + * @date 2018-12-25 + * @param str 字符串 + * @return 是否非空 + */ + public static boolean isNotNullOrEmpty(String str){ + return !isNullOrEmpty(str); + } + + /** + * 集合,使用英文逗号“,”拼接成一个字符串 + * @param list 集合 + */ + public static String join(Collection<String> list){ + return StringUtil.join(list, ","); + } + /** + * 集合,使用指定的字符,拼接成一个字符串 + * @param list 集合 + * @param separator 拼接字符 + */ + public static String join(Collection<String> list, String separator){ + if(ListUtil.isNullOrEmpty(list)){ + return ""; + } + return StringUtils.join(list.toArray(), separator); + } + /** + * 数组,使用英文逗号“,”拼接成一个字符串 + * @param array 数组 + */ + public static String join(String[] array){ + return StringUtil.join(array, ","); + } + /** + * 数组,使用指定的字符,拼接成一个字符串 + * @param array 数组 + * @param separator 拼接字符 + */ + public static String join(String[] array, String separator){ + if(array == null){ + return ""; + } + return StringUtils.join(array, separator); + } + + /** + * 集合,使用英文逗号“,”拼接成一个字符串 + * @param list 集合 + */ + public static String joinNumber(Collection<Number> list){ + return StringUtil.joinNumber(list, ","); + } + /** + * 集合,使用指定的字符,拼接成一个字符串 + * @param list 集合 + * @param separator 拼接字符 + */ + public static String joinNumber(Collection<Number> list, String separator){ + if(ListUtil.isNullOrEmpty(list)){ + return ""; + } + return StringUtils.join(list.toArray(), separator); + } + /** + * 数组,使用英文逗号“,”拼接成一个字符串 + * @param array 数组 + */ + public static String joinNumber(Number[] array){ + return joinNumber(array, ","); + } + /** + * 数组,使用指定的字符,拼接成一个字符串 + * @param array 数组 + * @param separator 拼接字符 + */ + public static String joinNumber(Number[] array, String separator){ + if(array == null){ + return ""; + } + return StringUtils.join(array, separator); + } + + /** + * base64解码(utf-8编码) + * @author linliu + * @date 2019-06-14 + * @param str 密文字符串 + * @return 解码后的明文 + */ + public static String base64Encode(String str) { + return base64Encode(str, DEFAULT); + } + /** + * base64解码 + * @author linliu + * @date 2019-06-14 + * @param str 密文字符串 + * @param encoding 编码格式[默认utf-8] + * @return 解码后的明文 + */ + public static String base64Encode(String str, String encoding) { + if(isNullOrEmpty(str)) { + return ""; + } + if(isNullOrEmpty(encoding)) { + encoding = DEFAULT; + } + byte[] bytes = str.getBytes(Charset.forName(encoding)); + return Base64.getEncoder().encodeToString(bytes); + } + + /** + * base64解码(utf-8编码) + * @author linliu + * @date 2019-06-14 + * @param str 密文字符串 + * @return 解码后的明文 + */ + public static String base64Decode(String str) { + return base64Decode(str, DEFAULT); + } + /** + * base64解码 + * @author linliu + * @date 2019-06-14 + * @param str 密文字符串 + * @param encoding 编码格式[默认utf-8] + * @return 解码后的明文 + */ + public static String base64Decode(String str, String encoding) { + if(isNullOrEmpty(str)) { + return ""; + } + if(isNullOrEmpty(encoding)) { + encoding = DEFAULT; + } + byte[] bytes = Base64.getDecoder().decode(str); + return new String(bytes, Charset.forName(encoding)); + } + + /** + * 传入字符串是否是有效的手机号码 + * @param str 字符串 + */ + public static boolean isMobilePhone(String str) { + return Pattern.matches(REGX_MOBILEPHONE, str); + } + + /** + * 传入字符串是否是有效的座机号码 + * @param str 字符串 + */ + public static boolean isTelPhone(String str) { + return Pattern.matches(REGX_TELEPHONE, str); + } + + /** + * 传入字符串是否是有效的身份证号码 + * @param str 字符串 + */ + public static boolean isIdCard(String str) { + return Pattern.matches(REGX_IDCARD, str); + } + + /** + * 传入字符串是否是有效的网址 + * @param str 字符串 + */ + public static boolean isWebUrl(String str) { + return Pattern.matches(REGX_WEBURL, str); + } + + /** + * 传入字符串是否是有效的电子邮件邮箱地址 + * @param str 字符串 + */ + public static boolean isEmail(String str) { + return Pattern.matches(REGX_EMAIL, str); + } + + /** + * 传入字符串是否是有效的金额 + * @param str 字符串 + */ + public static boolean isMoney(String str) { + return Pattern.matches(REGX_MONEY, str); + } + + /** + * 是否满足正则表达式规则 + * @author linliu + * @date 2019-01-04 + * @param str 字符串 + * @param regex 正则表达式 + * @return 是否匹配 + */ + public static Boolean isMatch(String str,String regex) { + if(StringUtil.isNullOrEmpty(str)) { + return Boolean.FALSE; + } + return Pattern.matches(regex, str); + } + + /** + * 正则获取Xml中的内容 + * @author xiangyuanzhang + * @date 2019-01-09 + * @param xml 传入的xml字符串 + * @param label 指定的标签中的内容 + */ + public static String regexXml(String xml, String label) { + String context = ""; + String rgex = "<" + label + ">(.*?)</" + label + ">"; + Pattern pattern = Pattern.compile(rgex,Pattern.CASE_INSENSITIVE); + Matcher m = pattern.matcher(xml); + List<String> list = new ArrayList<>(); + int i = 1; + while (m.find()) { + list.add(m.group(i)); + i++; + } + if (!list.isEmpty()) { + context = list.get(0); + } + return context; + } + + /** + * 获取<![CDATA 中内容 + * @author xiangyuanzhang + * @date 2019-01-14 + * @param str + * @return + */ + public static String getCDATAContent(String str) { + Pattern p = Pattern.compile(".*<!\\[CDATA\\[(.*)\\]\\]>.*"); + Matcher m = p.matcher(str); + if(m.matches()) { + return m.group(1); + } + return str; + } + + /** + * 将传入字符串转成 Integer 类型 + * @param str 字符串 + */ + public static int parseInt(String str) { + return Integer.parseInt(str); + } + + /** + * 将传入字符串转成 Long 类型 + * @param str 字符串 + */ + public static long parseLong(String str) { + return Long.parseLong(str); + } + + /** + * 将传入字符串转成精度为2位小数的 BigDecimal 类型 + * @param str 字符串 + */ + public static BigDecimal parseBigDecimal(String str) { + return parseBigDecimal(str, Integer.parseInt("2")); + } + + /** + * 将传入字符串转成指定精度的 BigDecimal 类型 + * @param str 字符串 + */ + public static BigDecimal parseBigDecimal(String str, Integer length) { + BigDecimal bd = new BigDecimal(str); + return bd.setScale(length, BigDecimal.ROUND_HALF_UP); + } + + /** + * 传入字符串是否是有效的 BigDecimal + * @param str 字符串 + */ + public static boolean isBigDecimal(String str) { + try{ + if(isNullOrEmpty(str)) { + return false; + } + new BigDecimal(str); + return true; + }catch (NumberFormatException e){ + return false; + } + } + + /** + * 将传入指定格式的字符串转成 Calendar 类型(默认“yyyy-MM-dd HH:mm:ss”) + * @param str 时间字符串 + * @param format 时间格式 + */ + public static Calendar parseDate(String str, String... format) { + String f = ConstantFactory.STR_DATE_FULL; + if(format.length>0) { + f = format[0]; + } + return CalendarUtil.fromStr(str, f); + } + + /** + * md5加密 + * @param content 待加密明文字符串 + */ + public static String md5(String content) { + return MD5Util.encrypt(content); + } + + /** + * 集合,使用英文逗号“,”拼接成一个字符串 + * @param list 集合 + */ + public static String joinInt(List<Integer> list){ + return joinInt(list, ","); + } + /** + * 集合,使用指定的字符,拼接成一个字符串 + * @param list 集合 + * @param separator 拼接字符 + */ + public static String joinInt(List<Integer> list, String separator){ + if(ListUtil.isNullOrEmpty(list)){ + return ""; + } + return StringUtils.join(list.toArray(), separator); + } + + /** + * 数组,使用英文逗号“,”拼接成一个字符串 + * @param array 数组 + */ + public static String joinInt(Integer[] array){ + return joinInt(array, ","); + } + /** + * 数组,使用指定的字符,拼接成一个字符串 + * @param array 数组 + * @param separator 拼接字符 + */ + public static String joinInt(Integer[] array, String separator){ + if(array == null){ + return ""; + } + return StringUtils.join(array, separator); + } + + /** + * 将传入字符串按指定分隔符,拆分成数组 + * @param str 字符串 + * @param splitChar 分隔符 + */ + public static String[] split(String str, String splitChar) { + if(StringUtil.isNullOrEmpty(str)) { + return new String[0]; + } + return str.split(splitChar); + } + /** + * 将传入字符串按英文逗号“,”分隔,拆分成数组 + * @param str 字符串 + */ + public static String[] split(String str) { + if(StringUtil.isNullOrEmpty(str)) { + return new String[0]; + } + return str.split("\\,"); + } + + /** + * 将传入字符串按指定分隔符,拆分成集合 + * @param str 字符串 + * @param splitChar 分隔符 + */ + public static List<String> splitList(String str, String splitChar) { + if(StringUtil.isNullOrEmpty(str)) { + return new ArrayList<>(); + } + return ListUtil.toList(split(str, splitChar)); + } + /** + * 将传入字符串按英文逗号“,”分隔,拆分成集合 + * @param str 字符串 + */ + public static List<String> splitList(String str) { + if(StringUtil.isNullOrEmpty(str)) { + return new ArrayList<>(); + } + return splitList(str, ","); + } + + /** + * 将传入字符串按指定分隔符,拆分成集合 + * @param str 字符串 + * @param splitChar 分隔符 + */ + public static List<Integer> splitIntList(String str, String splitChar) { + if(StringUtil.isNullOrEmpty(str)) { + return new ArrayList<>(); + } + return ListUtil.toIntList(splitList(str, splitChar)); + } + /** + * 将传入字符串按英文逗号“,”分隔,拆分成集合 + * @param str 字符串 + */ + public static List<Integer> splitIntList(String str) { + if(StringUtil.isNullOrEmpty(str)) { + return new ArrayList<>(); + } + return splitIntList(str, ","); + } + + /** + * 将传入字符串按指定分隔符,拆分成集合 + * @param str 字符串 + * @param splitChar 分隔符 + */ + public static List<Long> splitLongList(String str, String splitChar) { + if(StringUtil.isNullOrEmpty(str)) { + return new ArrayList<>(); + } + return ListUtil.toLongList(splitList(str, splitChar)); + } + /** + * 将传入字符串按英文逗号“,”分隔,拆分成集合 + * @param str 字符串 + */ + public static List<Long> splitLongList(String str) { + if(StringUtil.isNullOrEmpty(str)) { + return new ArrayList<>(); + } + return splitLongList(str, ","); + } + + /** + * 集合,使用英文逗号“,”拼接成一个字符串 + * @param list 集合 + */ + public static String joinLong(Collection<Long> list) { + return StringUtil.joinLong(list, ","); + } + /** + * 集合,使用指定的字符,拼接成一个字符串 + * @param list 集合 + * @param separator 拼接字符 + */ + public static String joinLong(Collection<Long> list, String separator) { + if(ListUtil.isNullOrEmpty(list)){ + return ""; + } + return StringUtils.join(list.toArray(), separator); + } + + /** + * 数组,使用英文逗号“,”拼接成一个字符串 + * @param array 数组 + */ + public static String joinLong(Long[] array) { + return joinLong(array, ","); + } + /** + * 数组,使用指定的字符,拼接成一个字符串 + * @param array 数组 + * @param separator 拼接字符 + */ + public static String joinLong(Long[] array, String separator){ + if(array == null){ + return ""; + } + return StringUtils.join(array, separator); + } + + /** + * 将字符串按英文逗号“,”分割,拆分成日期集合 + * @param str + * @param dateFormat + * @return + */ + public static List<Date> splitListDate(String str, String dateFormat) { + return splitListDate(str, dateFormat, ","); + } + /** + * 将字符串按指定分隔符,拆分成日期集合 + * @param str 字符串 + * @param dateFormat 日期格式 + * @return + */ + public static List<Date> splitListDate(String str, String dateFormat, String separator) { + if(StringUtil.isNullOrEmpty(str)) { + return new ArrayList<>(); + } + List<String> lstDate = splitList(str, separator); + return lstDate.stream().map(d -> { + try { + return CalendarUtil.fromStr(d, dateFormat).getTime(); + } catch (Exception e) { + return null; + } + }).collect(Collectors.toList()); + } + + /** + * 按指定字符串分割字符串 + * @author linliu + * @date 2019-06-19 + * @param str 字符串 + * @param onceQuantity 拆分后单个字符串的字符数 + */ + public static String[] split(String str, Integer onceQuantity) { + if(StringUtil.isNullOrEmpty(str)) { + return new String[]{}; + } + if(Integer.valueOf(0).compareTo(onceQuantity)>-1) { + onceQuantity = str.length(); + } + int size = str.length() / onceQuantity; + String[] result = new String[size]; + if(size==1) { + result[0] = str; + return result; + } + for (int idx=0; idx<size; idx++) { + result[idx] = substring(str, onceQuantity*idx, onceQuantity*(idx+1)); + } + return result; + } + + /** + * 按指定字符串分割字符串 + * @author linliu + * @date 2019-06-19 + * @param str 字符串 + * @param onceQuantity 拆分后单个字符串的字符数 + */ + public static List<String> splitList(String str, Integer onceQuantity) { + if(StringUtil.isNullOrEmpty(str)) { + return new ArrayList<>(); + } + if(Integer.valueOf(0).compareTo(onceQuantity)>-1) { + onceQuantity = str.length(); + } + int size = str.length() / onceQuantity; + List<String> result = new ArrayList<>(); + if(size==1) { + result.add(str); + return result; + } + if(str.length()%onceQuantity != 0) { + size += 1; + } + for (int idx=0; idx<size; idx++) { + result.add(substring(str, onceQuantity*idx, onceQuantity*(idx+1))); + } + return result; + } + + /** + * 分割字符串,如果开始位置大于字符串长度,返回空 + * @author linliu + * @date 2019-06-19 + * @param str 原始字符串 + * @param start 开始位置 + * @param end 结束位置 + */ + public static String substring(String str, Integer start, Integer end) { + if (StringUtil.isNullOrEmpty(str) || start > str.length()) { + return ""; + } + if (end > str.length()) { + return str.substring(start, str.length()); + } else { + return str.substring(start, end); + } + } + + /** + * 截取字符串长度 + * @param content 字符串 + * @param length 截取长度 + */ + public static String cutStr(String content, Integer length) { + return StringUtil.substring(content, 0, length); + } + + /** + * 判断是否为空,如果为空返回空字符串 + * @param str 字符串 + */ + public static String getStringDefault(String str) { + if (StringUtil.isNullOrEmpty(str)) { + return ""; + } + return str; + } + + /** + * 将小驼峰字符串转为_连接的 + * @param input 字符串 + */ + public static String camelCaseToUnderscore(String input) { + if (input == null) { + return null; + } + + StringBuilder result = new StringBuilder(); + boolean prevIsLowerCase = false; + + for (char c : input.toCharArray()) { + if (Character.isUpperCase(c)) { + if (prevIsLowerCase) { + result.append('_'); + } + result.append(Character.toLowerCase(c)); + prevIsLowerCase = false; + } else { + result.append(c); + prevIsLowerCase = true; + } + } + + return result.toString(); + } + + /** + * 字符串转16进制字符 + * @param input 字符串 + */ + public static String toHexString(String input) { + StringBuilder str = new StringBuilder(); + for (int i = 0; i < input.length(); i++) { + int ch = input.charAt(i); + String s4 = Integer.toHexString(ch); + str.append(s4); + } + return str.toString(); + } +} \ No newline at end of file diff --git a/src/main/java/com/fengdu/gas/common/util/ThreadPoolUtil.java b/src/main/java/com/fengdu/gas/common/util/ThreadPoolUtil.java new file mode 100644 index 0000000..fcd1f51 --- /dev/null +++ b/src/main/java/com/fengdu/gas/common/util/ThreadPoolUtil.java @@ -0,0 +1,27 @@ +package com.fengdu.gas.common.util; + +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +/** + * 线程池管理类 + */ +public final class ThreadPoolUtil { + /** + * 多线程允许最大并发线程数的默认大小 + */ + private static final Integer THREAD_DEFAULT_MAXQUANTITY = 50; + + /** + * 创建一个定长线程池,可控制线程最大并发数,超出的线程会在队列中等待。 + */ + private static ExecutorService THREADPOOL_DEFAULT = Executors.newFixedThreadPool(THREAD_DEFAULT_MAXQUANTITY); + + /** + * 获取默认线程池 + * @return + */ + public static ExecutorService getDefaultPool() { + return THREADPOOL_DEFAULT; + } +} diff --git a/src/main/java/com/fengdu/gas/common/validator/EParameterValidateType.java b/src/main/java/com/fengdu/gas/common/validator/EParameterValidateType.java new file mode 100644 index 0000000..0819d81 --- /dev/null +++ b/src/main/java/com/fengdu/gas/common/validator/EParameterValidateType.java @@ -0,0 +1,139 @@ +package com.fengdu.gas.common.validator; + +import java.util.Arrays; +import java.util.Objects; + +/** + * 参数验证类型 枚举 + * @author linliu + * @date 2019-04-19 + */ +public enum EParameterValidateType { + /** + * 不能为空 + */ + NOT_NULLOREMPTY(", 不能为空 ", 1), + + + + /** + * 必须大于 + */ + MUST_GREATER(", 必须大于 ", 2), + /** + * 必须大于等于 + */ + MUST_GREATER_THAN(", 必须大于等于 ", 3), + + + + /** + * 必须小于 + */ + MUST_LESS(", 必须小于 ", 4), + /** + * 必须小于等于 + */ + MUST_LESS_THAN(", 必须小于等于 ", 5), + + + + /** + * 必须是枚举 + */ + MUST_ENUM(", 必须是合法的枚举值", 6), + + + + /** + * 必须是有效的日期(yyyy-MM-dd) + */ + MUST_DATE(", 必须是有效的日期格式(yyyy-MM-dd)", 7), + /** + * 必须是有效的时间(yyyy-MM-dd HH:mm:ss) + */ + MUST_DATE_TIME(", 必须是有效的日期格式(yyyy-MM-dd HH:mm:ss)", 8), + + + + /** + * 必须是有效电话号码 + */ + MUST_PHONE_NUMBER(", 必须是有效的联系方式", 9), + /** + * 必须是有效座机号码 + */ + MUST_TELEPHONE_NUMBER(", 必须是有效的座机号码", 10), + /** + * 必须是有效手机号码 + */ + MUST_MOBILE_NUMBER(", 必须是有效的手机号码", 11), + + + + /** + * 必须是有效电子邮箱地址 + */ + MUST_EMAIL(", 必须是有效的电子邮箱", 12), + + /** + * 不能超出取值范围 + */ + MUST_IN_RANGE(", 取值超出允许范围 ", 13), + + /** + * 长度不能小于 + */ + MUST_LENGTH_MIN(", 字符长度不能少于 ", 14), + /** + * 长度不能大于 + */ + MUST_LENGTH_MAX(", 字符长度不能超过 ", 15), + + /** + * 必须满足正则表达式规则 + */ + MUST_PASS_REGEX(", 必须满足正则表达式规则 ", 16) + ; + + private String desc;//枚举描述 + private Integer value;//枚举值 + + public Integer getValue() { + return value; + } + public String getDesc() { + return desc; + } + + /** + * 构造方法 + * @param desc 枚举描述 + * @param value 枚举值 + */ + private EParameterValidateType(String desc, Integer value) { + this.desc = desc; + this.value = value; + } + + /** + * 根据值获取枚举 + * + * @param value 枚举值 + * @return + */ + public static EParameterValidateType getByValue(Integer value) { + return Arrays.stream(EParameterValidateType.values()) + .filter(e -> Objects.equals(e.getValue(), value)) + .findFirst() + .orElse(null); + } + + @Override + public String toString() { + return "EParameterValidateType{" + + "desc='" + desc + '\'' + + ", value=" + value + + '}'; + } +} \ No newline at end of file diff --git a/src/main/java/com/fengdu/gas/common/validator/ParameterRunnable.java b/src/main/java/com/fengdu/gas/common/validator/ParameterRunnable.java new file mode 100644 index 0000000..09905ce --- /dev/null +++ b/src/main/java/com/fengdu/gas/common/validator/ParameterRunnable.java @@ -0,0 +1,13 @@ +package com.fengdu.gas.common.validator; + +public class ParameterRunnable<T> implements Runnable { + T param; + public ParameterRunnable(T param) { + this.param = param; + } + + @Override + public void run() { + new ParameterRunnable(param); + } +} diff --git a/src/main/java/com/fengdu/gas/common/validator/ParameterValidateItem.java b/src/main/java/com/fengdu/gas/common/validator/ParameterValidateItem.java new file mode 100644 index 0000000..6caab0c --- /dev/null +++ b/src/main/java/com/fengdu/gas/common/validator/ParameterValidateItem.java @@ -0,0 +1,124 @@ +package com.fengdu.gas.common.validator; + +import java.util.function.Function; + +/** + * 参数验证 对象 + * @author linliu + * @date 2019-04-19 + * @param <T> 枚举类型 + */ +public class ParameterValidateItem<T extends Enum> { + private String fieldName; + private EParameterValidateType type; + private Object value; + private Object rangeMin; + private Object rangeMax; + private Class<T> enumType; + private Function<Object, Boolean> validateFunc = null; + private String regex; + + public ParameterValidateItem() {} + public ParameterValidateItem(String fieldName, EParameterValidateType type, Object value) { + this.fieldName = fieldName; + this.type = type; + this.value = value; + } + public ParameterValidateItem(String fieldName, EParameterValidateType type, Object value, Function<Object, Boolean> validateFunc) { + this.fieldName = fieldName; + this.type = type; + this.value = value; + this.validateFunc = validateFunc; + } + public ParameterValidateItem(String fieldName, EParameterValidateType type, Object value, Object rangeMin, Object rangeMax) { + this.fieldName = fieldName; + this.type = type; + this.value = value; + this.rangeMin = rangeMin; + this.rangeMax = rangeMax; + } + public ParameterValidateItem(String fieldName, EParameterValidateType type, Object value, Object rangeMin, Object rangeMax, Class<T> enumType) { + this.fieldName = fieldName; + this.type = type; + this.value = value; + this.rangeMin = rangeMin; + this.rangeMax = rangeMax; + this.enumType = enumType; + } + public ParameterValidateItem(String fieldName, Object value, Object rangeMin, Object rangeMax) { + this.fieldName = fieldName; + this.type = EParameterValidateType.MUST_IN_RANGE; + this.value = value; + this.rangeMin = rangeMin; + this.rangeMax = rangeMax; + } + public ParameterValidateItem(String fieldName, Object value , Class<T> enumType) { + this.fieldName = fieldName; + this.type = EParameterValidateType.MUST_ENUM; + this.value = value; + this.enumType = enumType; + } + public ParameterValidateItem(String fieldName, Object value , String regex) { + this.fieldName = fieldName; + this.type = EParameterValidateType.MUST_PASS_REGEX; + this.value = value; + this.regex = regex; + } + + public String getFieldName() { + return fieldName; + } + public void setFieldName(String fieldName) { + this.fieldName = fieldName; + } + + public EParameterValidateType getType() { + return type; + } + public void setType(EParameterValidateType type) { + this.type = type; + } + + public Object getValue() { + return value; + } + public void setValue(Object value) { + this.value = value; + } + + public Object getRangeMin() { + return rangeMin; + } + public void setRangeMin(Object rangeMin) { + this.rangeMin = rangeMin; + } + + public Object getRangeMax() { + return rangeMax; + } + public void setRangeMax(Object rangeMax) { + this.rangeMax = rangeMax; + } + + public Class<T> getEnumType() { + return enumType; + } + public void setEnumType(Class<T> enumType) { + this.enumType = enumType; + } + + public Function<Object, Boolean> getValidateFunc() { + return validateFunc; + } + public void setValidateFunc(Function<Object, Boolean> validateFunc) { + this.validateFunc = validateFunc; + } + + public String getRegex() { + return regex; + } + + public void setRegex(String regex) { + this.regex = regex; + } +} \ No newline at end of file diff --git a/src/main/java/com/fengdu/gas/common/validator/ParameterValidateResult.java b/src/main/java/com/fengdu/gas/common/validator/ParameterValidateResult.java new file mode 100644 index 0000000..ebb93f1 --- /dev/null +++ b/src/main/java/com/fengdu/gas/common/validator/ParameterValidateResult.java @@ -0,0 +1,38 @@ +package com.fengdu.gas.common.validator; + +public class ParameterValidateResult { + private Boolean isSuccess; + private String errorMsg; + + public ParameterValidateResult() {} + public ParameterValidateResult(Boolean isSuccess, String errorMsg) { + this.isSuccess = isSuccess; + this.errorMsg = errorMsg; + } + + public Boolean getIsSuccess() { + return isSuccess; + } + public void setIsSuccess(Boolean success) { + isSuccess = success; + } + + public Boolean getIsFiled() { + return !isSuccess; + } + + public String getErrorMsg() { + return errorMsg; + } + public void setErrorMsg(String errorMsg) { + this.errorMsg = errorMsg; + } + + @Override + public String toString() { + return "ParameterValidateResult{" + + "isSuccess=" + isSuccess + + ", errorMsg='" + errorMsg + '\'' + + '}'; + } +} \ No newline at end of file diff --git a/src/main/java/com/fengdu/gas/common/validator/ParameterValidator.java b/src/main/java/com/fengdu/gas/common/validator/ParameterValidator.java new file mode 100644 index 0000000..2bfce6a --- /dev/null +++ b/src/main/java/com/fengdu/gas/common/validator/ParameterValidator.java @@ -0,0 +1,555 @@ +package com.fengdu.gas.common.validator; + +import com.fengdu.gas.common.ConstantFactory; +import com.fengdu.gas.common.util.ListUtil; +import com.fengdu.gas.common.util.LocalDateTimeUtil; +import com.fengdu.gas.common.util.NumericUtil; +import com.fengdu.gas.common.util.StringUtil; + +import java.math.BigDecimal; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Calendar; +import java.util.List; +import java.util.function.Function; + +/** + * 参数验证 + * @author linliu + * @date 2019-04-19 + */ +public class ParameterValidator { + /** + * 验证参数列表 + */ + public List<ParameterValidateItem> listParameter; + public List<ParameterValidateItem> getListParameter() { + return listParameter; + } + public void setListParameter(List<ParameterValidateItem> listParameter) { + this.listParameter = listParameter; + } + + public ParameterValidator() { + listParameter = new ArrayList<>(); + } + + /** + * 添加一个需要验证的参数 + * @param item 参数验证对象 + */ + public ParameterValidator addParameter(ParameterValidateItem... item) { + this.listParameter.addAll(Arrays.asList(item)); + return this; + } + + /** + * 添加一个需要验证的参数 + * @param fieldName 参数名称“自行构建参数描述"userName" 或者 "the parameter which named “userName”"” + * @param type 需要验证的类型 + * @param value 参数的值 + * @param validateFunc 是否通过验证的自函数 + */ + public ParameterValidator addParameter(String fieldName, EParameterValidateType type, Object value, Function<Object, Boolean> validateFunc) { + this.listParameter.add(new ParameterValidateItem(fieldName, type, value, validateFunc)); + return this; + } + + + + /** + * 添加一个“不能为空”的参数 验证 + * @param fieldName 参数名称 + * @param value 参数值 + */ + public ParameterValidator addNotNullOrEmpty(String fieldName, Object value) { + this.listParameter.add(new ParameterValidateItem(fieldName, EParameterValidateType.NOT_NULLOREMPTY, value)); + return this; + } + /** + * 添加一个“必须是一个有效日期”(yyyy-MM-dd)的参数 验证 + * @param fieldName 参数名称 + * @param value 参数值 + */ + public ParameterValidator addMustDate(String fieldName, Object value) { + this.listParameter.add(new ParameterValidateItem(fieldName, EParameterValidateType.MUST_DATE, value)); + return this; + } + /** + * 添加一个“必须是一个有效时间”(yyyy-MM-dd HH:mm:ss)的参数 验证 + * @param fieldName 参数名称 + * @param value 参数值 + */ + public ParameterValidator addMustDateTime(String fieldName, Object value) { + this.listParameter.add(new ParameterValidateItem(fieldName, EParameterValidateType.MUST_DATE_TIME, value)); + return this; + } + /** + * 添加一个“必须是指定枚举类型的有效值”的参数 验证 + * @param fieldName 参数名称 + * @param value 参数值 + * @param enumType 枚举类型 + */ + public <T extends Enum> ParameterValidator addMustEnum(String fieldName, Object value, Class<T> enumType) { + this.listParameter.add(new ParameterValidateItem(fieldName, value, enumType)); + return this; + } + /** + * 添加一个“必须是有效电子邮箱地址”的参数 验证 + * @param fieldName 参数名称 + * @param value 参数值 + */ + public ParameterValidator addMustEmail(String fieldName, Object value) { + this.listParameter.add(new ParameterValidateItem(fieldName, EParameterValidateType.MUST_EMAIL, value)); + return this; + } + /** + * 添加一个“必须是有效手机号码”的参数 验证 + * @param fieldName 参数名称 + * @param value 参数值 + */ + public ParameterValidator addMustMobile(String fieldName, Object value) { + this.listParameter.add(new ParameterValidateItem(fieldName, EParameterValidateType.MUST_MOBILE_NUMBER, value)); + return this; + } + /** + * 添加一个“必须是有效手机号码”的参数 验证 + * @param fieldName 参数名称 + * @param value 参数值 + */ + public ParameterValidator addMustPassRegex(String fieldName, Object value, String regex) { + this.listParameter.add(new ParameterValidateItem(fieldName, value, regex)); + return this; + } + + + + /** + * 添加一个“必须大于最小值”的参数 验证 + * @param fieldName 参数名称 + * @param value 参数值 + * @param minValue 校验允许的最小值 + */ + public ParameterValidator addGreater(String fieldName, Object value, Object minValue) { + this.listParameter.add(new ParameterValidateItem(fieldName, EParameterValidateType.MUST_GREATER, value, minValue, null)); + return this; + } + /** + * 添加一个“必须大于等于最小值”的参数 验证 + * @param fieldName 参数名称 + * @param value 参数值 + * @param minValue 校验允许的最小值 + */ + public ParameterValidator addGreaterThan(String fieldName, Object value, Object minValue) { + this.listParameter.add(new ParameterValidateItem(fieldName, EParameterValidateType.MUST_GREATER_THAN, value, minValue, null)); + return this; + } + + + + /** + * 添加一个“必须小于最大值”的参数 验证 + * @param fieldName 参数名称 + * @param value 参数值 + * @param maxValue 校验允许的最大值 + */ + public ParameterValidator addLess(String fieldName, Object value, Object maxValue) { + this.listParameter.add(new ParameterValidateItem(fieldName, EParameterValidateType.MUST_LESS, value, null, maxValue)); + return this; + } + /** + * 添加一个“必须小于等于最大值”的参数 验证 + * @param fieldName 参数名称 + * @param value 参数值 + * @param maxValue 校验允许的最大值 + */ + public ParameterValidator addLessThan(String fieldName, Object value, Object maxValue) { + this.listParameter.add(new ParameterValidateItem(fieldName, EParameterValidateType.MUST_LESS_THAN, value, null, maxValue)); + return this; + } + + + + /** + * 添加一个“字符串必须大于等于最小长度”的参数 验证 + * @param fieldName 参数名称 + * @param value 参数值 + * @param minLength 校验允许的最小长度 + */ + public ParameterValidator addLengthMin(String fieldName, Object value, Integer minLength) { + this.listParameter.add(new ParameterValidateItem(fieldName, EParameterValidateType.MUST_LENGTH_MIN, value, minLength, null, null)); + return this; + } + /** + * 添加一个“字符串必须小于等于最大长度”的参数 验证 + * @param fieldName 参数名称 + * @param value 参数值 + * @param maxLength 校验允许的最大长度 + */ + public ParameterValidator addLengthMax(String fieldName, Object value, Integer maxLength) { + this.listParameter.add(new ParameterValidateItem(fieldName, EParameterValidateType.MUST_LENGTH_MAX, value, null, maxLength, null)); + return this; + } + + + /** + * 执行验证参数 + * @return 验证结果 + */ + public ParameterValidateResult validate() { + if(ListUtil.isNotNullOrEmpty((this.listParameter))) { + return this.checkParameterValidate(); + } + return new ParameterValidateResult(true, ""); + } + + private ParameterValidateResult checkParameterValidate() { + for (ParameterValidateItem item : this.listParameter) { + ParameterValidateResult result = this.checkParameterValidateItem(item); + if(result.getIsFiled()) { + return result; + } + } + return new ParameterValidateResult(true, ""); + } + private ParameterValidateResult checkParameterValidateItem(ParameterValidateItem item) { + Function<Object, Boolean> func = item.getValidateFunc(); + if(null != func) { + if(func.apply(item.getValue())) { + return new ParameterValidateResult(true, ""); + } else { + return new ParameterValidateResult(false, item.getFieldName()+item.getType().getDesc()); + } + } + switch (item.getType()) { + case NOT_NULLOREMPTY: + if(!ParameterValidator.checkNotNull(item.getValue())) { + return new ParameterValidateResult(false, item.getFieldName()+item.getType().getDesc()); + } + break; + + + + case MUST_ENUM: + if(!ParameterValidator.checkIsEnum(item.getValue(), item.getEnumType())) { + return new ParameterValidateResult(false, item.getFieldName()+item.getType().getDesc()+item.getEnumType().getName().replace(item.getEnumType().getPackage().getName()+".", "")+":"+item.getValue()); + } + break; + case MUST_IN_RANGE: + if(!ParameterValidator.checkInRange(item.getValue(), item.getRangeMin(), item.getRangeMax())) { + return new ParameterValidateResult(false, item.getFieldName()+item.getType().getDesc()+item.getEnumType().getTypeName()); + } + break; + default: + return this.checkMustGreaterLess(item); + } + return new ParameterValidateResult(true, ""); + } + private ParameterValidateResult checkMustGreaterLess(ParameterValidateItem item) { + switch (item.getType()) { + case MUST_GREATER: + if(!ParameterValidator.checkGreater(item.getValue(), item.getRangeMin())) { + return new ParameterValidateResult(false, item.getFieldName()+item.getType().getDesc()+item.getRangeMin().toString()); + } + break; + case MUST_GREATER_THAN: + if(!ParameterValidator.checkGreaterThan(item.getValue(), item.getRangeMin())) { + return new ParameterValidateResult(false, item.getFieldName()+item.getType().getDesc()+item.getRangeMin().toString()); + } + break; + case MUST_LESS: + if(!ParameterValidator.checkLess(item.getValue(), item.getRangeMax())) { + return new ParameterValidateResult(false, item.getFieldName()+item.getType().getDesc()+item.getRangeMax().toString()); + } + break; + case MUST_LESS_THAN: + if(!checkLessThan(item.getValue(), item.getRangeMax())) { + return new ParameterValidateResult(false, item.getFieldName()+item.getType().getDesc()+item.getRangeMax().toString()); + } + break; + default: + return this.checkDateTime(item); + } + return new ParameterValidateResult(true, ""); + } + private ParameterValidateResult checkDateTime(ParameterValidateItem item) { + switch (item.getType()) { + case MUST_DATE: + if(!checkIsMatch(item.getValue(), item.getType()) || !LocalDateTimeUtil.getDate(item.getValue().toString()).isAfter(LocalDateTimeUtil.DEFAULT_DATE)) { + return new ParameterValidateResult(false, item.getFieldName()+item.getType().getDesc()); + } + break; + case MUST_DATE_TIME: + if(!checkIsMatch(item.getValue(), item.getType()) || !LocalDateTimeUtil.getDateTime(item.getValue().toString()).isAfter(LocalDateTimeUtil.DEFAULT_DATETIME)) { + return new ParameterValidateResult(false, item.getFieldName()+item.getType().getDesc()); + } + break; + default: + return this.checkLength(item); + } + return new ParameterValidateResult(true, ""); + } + private ParameterValidateResult checkLength(ParameterValidateItem item) { + switch (item.getType()) { + case MUST_LENGTH_MIN: + String strMin = item.getRangeMin().toString(); + int minLength = Integer.valueOf(strMin); + if(null==item.getValue() || item.getValue().toString().length()<minLength) { + return new ParameterValidateResult(false, item.getFieldName()+item.getType().getDesc()+strMin); + } + break; + case MUST_LENGTH_MAX: + String strMax = item.getRangeMax().toString(); + int maxLength = Integer.valueOf(strMax); + if(null!=item.getValue() && item.getValue().toString().length()>maxLength) { + return new ParameterValidateResult(false, item.getFieldName()+item.getType().getDesc()+strMax); + } + break; + default: + return this.checkOther(item); + } + return new ParameterValidateResult(true, ""); + } + private ParameterValidateResult checkOther(ParameterValidateItem item) { + switch (item.getType()) { + case MUST_EMAIL: + case MUST_MOBILE_NUMBER: + case MUST_TELEPHONE_NUMBER: + case MUST_PHONE_NUMBER: + if(!checkIsMatch(item.getValue(), item.getType())) { + return new ParameterValidateResult(false, item.getFieldName()+item.getType().getDesc()); + } + break; + + case MUST_PASS_REGEX: + if (!checkIsMatch(item.getRegex(), item.getValue())) { + return new ParameterValidateResult(false, item.getFieldName() + item.getType().getDesc() + item.getRegex()); + } + break; + + default: + break; + } + return new ParameterValidateResult(true, ""); + } + + /** + * 验证传入参数“不为空”(非null且非空) + * @param value 参数值 + * @return 是否“不为空” + */ + public static Boolean checkNotNull(Object value) { + if(null == value) { + return false; + } + if(value instanceof String) { + String realValue = (String) value; + return realValue.replaceAll(ConstantFactory.STR_REGEX_SPACE, "").length()>0; + } else if(value instanceof List) { + List<?> realValue = (List)value; + return ListUtil.isNotNullOrEmpty(realValue); + } + return true; + } + + /** + * 验证传入参数是否“大于”传入最小值 + * @param value 参数值 + * @param minValue 校验允许的最小值 + * @return 是否“大于”最小值 + */ + public static Boolean checkGreater(Object value, Object minValue) { + if(null == value) { + return false; + } + if(value instanceof Integer || value instanceof Long || value instanceof Double || value instanceof BigDecimal) { + BigDecimal realValue = new BigDecimal(value.toString()); + BigDecimal realMin = new BigDecimal(minValue.toString()); + return realValue.compareTo(realMin)>0; + } else if(value instanceof Calendar) { + Calendar realValue = (Calendar)value; + Calendar realMin = (Calendar)minValue; + return realValue.compareTo(realMin)>0; + } else if(value instanceof LocalDateTime) { + LocalDateTime realValue = (LocalDateTime)value; + LocalDateTime realMin = (LocalDateTime)minValue; + return realValue.compareTo(realMin)>0; + } else if(value instanceof LocalDate) { + LocalDate realValue = (LocalDate)value; + LocalDate realMin = (LocalDate)minValue; + return realValue.compareTo(realMin)>0; + } + return true; + } + + /** + * 验证传入参数是否“大于等于”传入最小值 + * @param value 参数值 + * @param minValue 校验允许的最小值 + * @return 是否“大于等于”传入最小值 + */ + public static Boolean checkGreaterThan(Object value, Object minValue) { + if(null == value) { + return false; + } + if(value instanceof Integer || value instanceof Long || value instanceof Double || value instanceof BigDecimal) { + BigDecimal realValue = new BigDecimal(value.toString()); + BigDecimal realMin = new BigDecimal(minValue.toString()); + return realValue.compareTo(realMin)>=0; + }else if(value instanceof Calendar) { + Calendar realValue = (Calendar)value; + Calendar realMin = (Calendar)minValue; + return realValue.compareTo(realMin)>=0; + } else if(value instanceof LocalDateTime) { + LocalDateTime realValue = (LocalDateTime)value; + LocalDateTime realMin = (LocalDateTime)minValue; + return realValue.compareTo(realMin)>=0; + } else if(value instanceof LocalDate) { + LocalDate realValue = (LocalDate)value; + LocalDate realMin = (LocalDate)minValue; + return realValue.compareTo(realMin)>=0; + } + return true; + } + /** + * 验证传入参数是否“小于”传入最大值 + * @param value 参数值 + * @param maxValue 校验允许的最大值 + * @return 是否“小于”最大值 + */ + public static Boolean checkLess(Object value, Object maxValue) { + if(null == value) { + return true; + } + if(value instanceof Integer || value instanceof Long || value instanceof Double || value instanceof BigDecimal) { + BigDecimal realValue = new BigDecimal(value.toString()); + BigDecimal realMax = new BigDecimal(maxValue.toString()); + return realValue.compareTo(realMax)<0; + } else if(value instanceof Calendar) { + Calendar realValue = (Calendar)value; + Calendar realMax = (Calendar)maxValue; + return realValue.compareTo(realMax)<0; + } else if(value instanceof LocalDateTime) { + LocalDateTime realValue = (LocalDateTime)value; + LocalDateTime realMax = (LocalDateTime)maxValue; + return realValue.compareTo(realMax)<0; + } else if(value instanceof LocalDate) { + LocalDate realValue = (LocalDate)value; + LocalDate realMax = (LocalDate)maxValue; + return realValue.compareTo(realMax)<0; + } + return true; + } + /** + * 验证传入参数是否“小于等于”传入最小值 + * @param value 参数值 + * @param maxValue 校验允许的最大值 + * @return 是否“小于等于”传入最小值 + */ + public static Boolean checkLessThan(Object value, Object maxValue) { + if(null == value) { + return true; + } + if(value instanceof Integer || value instanceof Long || value instanceof Double || value instanceof BigDecimal) { + BigDecimal realValue = new BigDecimal(value.toString()); + BigDecimal realMax = new BigDecimal(maxValue.toString()); + return realValue.compareTo(realMax)<=0; + } else if(value instanceof Calendar) { + Calendar realValue = (Calendar)value; + Calendar realMax = (Calendar)maxValue; + return realValue.compareTo(realMax)<=0; + } else if(value instanceof LocalDateTime) { + LocalDateTime realValue = (LocalDateTime)value; + LocalDateTime realMax = (LocalDateTime)maxValue; + return realValue.compareTo(realMax)<=0; + } else if(value instanceof LocalDate) { + LocalDate realValue = (LocalDate)value; + LocalDate realMax = (LocalDate)maxValue; + return realValue.compareTo(realMax)<=0; + } + return true; + } + /** + * 验证传入参数是否符合指定“参数校验类型”格式 + * @param value 参数值 + * @param type 参数校验类型 + * @return 是否符合指定“参数校验类型”格式 + */ + public static Boolean checkIsMatch(Object value, EParameterValidateType type) { + Boolean result = false; + String realValue = String.valueOf(value); + switch (type) { + case MUST_DATE: + result = StringUtil.isMatch(realValue, ConstantFactory.REGEX_DATE); + break; + case MUST_DATE_TIME: + result = StringUtil.isMatch(realValue, ConstantFactory.REGEX_DATETIME); + break; + case MUST_EMAIL: + result = StringUtil.isEmail(realValue); + break; + case MUST_MOBILE_NUMBER: + result = StringUtil.isMobilePhone(realValue); + break; + case MUST_TELEPHONE_NUMBER: + result = StringUtil.isTelPhone(realValue); + break; + case MUST_PHONE_NUMBER: + result = (StringUtil.isTelPhone(realValue) || StringUtil.isMobilePhone(realValue)); + break; + default: + break; + } + return result; + } + /** + * 验证传入参数是否符合指定“参数校验类型”格式 + * @param regex 正则表达式 + * @param value 参数值 + * @return 是否符合指定“参数校验类型”格式 + */ + public static Boolean checkIsMatch(String regex, Object value) { + return StringUtil.isMatch(String.valueOf(value), regex); + } + /** + * 验证传入参数是否是指定类型的“有效枚举值” + * @param value 参数值 + * @param enumType 枚举类型 + * @param <T> 枚举类型 + * @return 是否是“有效枚举值” + */ + public static <T extends Enum<T>> Boolean checkIsEnum(Object value, Class<T> enumType) { + if(value instanceof String) { + return StringUtil.isEnum(enumType, value.toString()); + } else if(value instanceof Integer) { + return NumericUtil.isEnum(enumType, ((Integer) value)); + } + return false; + } + /** + * 验证传入参数值是否在指定“最大值”和“最小值”范围内 + * @param value 参数值 + * @param minValue 校验允许的最大值 + * @param maxValue 校验允许的最小值 + * @return 是否在指定“最大值”和“最小值”范围内 + */ + public static Boolean checkInRange(Object value, Object minValue, Object maxValue) { + if(null == value) { + return false; + } + if(value instanceof Integer || value instanceof Long || value instanceof Double || value instanceof BigDecimal) { + BigDecimal realValue = new BigDecimal(value.toString()); + BigDecimal realMin = new BigDecimal(minValue.toString()); + BigDecimal realMax = new BigDecimal(maxValue.toString()); + return (realValue.compareTo(realMin)>=0 && realValue.compareTo(realMax)<=0); + } else if(value instanceof Calendar) { + Calendar realValue = (Calendar)value; + Calendar realMin = (Calendar)minValue; + Calendar realMax = (Calendar)maxValue; + return (realValue.compareTo(realMin)>=0 && realValue.compareTo(realMax)<=0); + } + return true; + } +} \ No newline at end of file diff --git a/src/main/java/com/fengdu/gas/entity/dto/KeyValueDTO.java b/src/main/java/com/fengdu/gas/entity/dto/KeyValueDTO.java new file mode 100644 index 0000000..79eda1d --- /dev/null +++ b/src/main/java/com/fengdu/gas/entity/dto/KeyValueDTO.java @@ -0,0 +1,28 @@ +package com.fengdu.gas.entity.dto; + +/** + * 键值对 dto + * @author lin.liu + * @description 键值对 dto + * @date 2021/4/7 + **/ +public class KeyValueDTO { + private String key; + private String value; + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } +} diff --git a/src/main/java/com/fengdu/gas/entity/dto/NameSortDTO.java b/src/main/java/com/fengdu/gas/entity/dto/NameSortDTO.java new file mode 100644 index 0000000..e225130 --- /dev/null +++ b/src/main/java/com/fengdu/gas/entity/dto/NameSortDTO.java @@ -0,0 +1,28 @@ +package com.fengdu.gas.entity.dto; + +public class NameSortDTO { + /** + * 名称 + */ + private String name; + /** + * 排序值 + */ + private Integer sort; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Integer getSort() { + return sort; + } + + public void setSort(Integer sort) { + this.sort = sort; + } +} diff --git a/src/main/java/com/fengdu/gas/entity/dto/NameSortIdDTO.java b/src/main/java/com/fengdu/gas/entity/dto/NameSortIdDTO.java new file mode 100644 index 0000000..b9cef18 --- /dev/null +++ b/src/main/java/com/fengdu/gas/entity/dto/NameSortIdDTO.java @@ -0,0 +1,37 @@ +package com.fengdu.gas.entity.dto; + +public class NameSortIdDTO { + private Long id; + /** + * 名称 + */ + private String name; + /** + * 排序值 + */ + private Integer sort; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Integer getSort() { + return sort; + } + + public void setSort(Integer sort) { + this.sort = sort; + } +} diff --git a/src/main/java/com/fengdu/gas/entity/dto/NameValueDTO.java b/src/main/java/com/fengdu/gas/entity/dto/NameValueDTO.java new file mode 100644 index 0000000..e7b8e4b --- /dev/null +++ b/src/main/java/com/fengdu/gas/entity/dto/NameValueDTO.java @@ -0,0 +1,39 @@ +package com.fengdu.gas.entity.dto; + +/** + * 名称-值 数据对象 + */ +public class NameValueDTO<T> { + /** + * 名称 + */ + private String name; + /** + * 值 + */ + private T value; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public T getValue() { + return value; + } + + public void setValue(T value) { + this.value = value; + } + + public NameValueDTO() { + } + + public NameValueDTO(String name, T value) { + this.name = name; + this.value = value; + } +} diff --git a/src/main/java/com/fengdu/gas/entity/dto/OrderByDTO.java b/src/main/java/com/fengdu/gas/entity/dto/OrderByDTO.java new file mode 100644 index 0000000..f85d0e2 --- /dev/null +++ b/src/main/java/com/fengdu/gas/entity/dto/OrderByDTO.java @@ -0,0 +1,29 @@ +package com.fengdu.gas.entity.dto; + +public class OrderByDTO { + /** + * 排序字段枚举(支持的枚举值请参照字段“ orderByEnum”说明中的枚举类型,无特殊说明使用通用排序枚举,“EOrderBy”) + */ + private Integer orderBy; + /** + * 是否升序排序 true=升序,不传或者其他任意值=降序(默认) + */ + private Boolean isAsc; + + public Integer getOrderBy() { + return orderBy; + } + + public void setOrderBy(Integer orderBy) { + this.orderBy = orderBy; + } + + public Boolean getIsAsc() { + return isAsc; + } + + public void setIsAsc(Boolean asc) { + isAsc = asc; + } +} + diff --git a/src/main/java/com/fengdu/gas/entity/dto/PagerBasicDTO.java b/src/main/java/com/fengdu/gas/entity/dto/PagerBasicDTO.java new file mode 100644 index 0000000..eac6b5a --- /dev/null +++ b/src/main/java/com/fengdu/gas/entity/dto/PagerBasicDTO.java @@ -0,0 +1,47 @@ +package com.fengdu.gas.entity.dto; + +/** + * 分页基本属性 dto + * @Author lin.liu + * @Description 分页基本属性 dto + * @Date 2021/4/7 + **/ +public class PagerBasicDTO { + /** + * 最后一条记录的id + * @ignore + */ + private Long lastRowNo; + /** + * 页大小(每页返回的记录条数) + */ + private Integer limit; + /** + * 页号(第几页,从1开始) + */ + private Integer page; + + public Long getLastRowNo() { + return lastRowNo; + } + + public void setLastRowNo(Long lastRowNo) { + this.lastRowNo = lastRowNo; + } + + public Integer getLimit() { + return limit; + } + + public void setLimit(Integer limit) { + this.limit = limit; + } + + public Integer getPage() { + return page; + } + + public void setPage(Integer page) { + this.page = page; + } +} \ No newline at end of file diff --git a/src/main/java/com/fengdu/gas/entity/dto/RequestDTO.java b/src/main/java/com/fengdu/gas/entity/dto/RequestDTO.java new file mode 100644 index 0000000..3a4fb77 --- /dev/null +++ b/src/main/java/com/fengdu/gas/entity/dto/RequestDTO.java @@ -0,0 +1,114 @@ +package com.fengdu.gas.entity.dto; + +import java.util.Map; + +public class RequestDTO { + private Map<String, String> requestDataMap; + private String businessCode; + private String approveCode; + private String conditionColumn; + private Long conditionValue; + private Long creator_id; + private String creator_name; + private Long listAppRover; + private Integer applyStatus; + private Long id; + private String comment; + private Integer type; + + public Integer getType() { + return type; + } + + public void setType(Integer type) { + this.type = type; + } + + public String getComment() { + return comment; + } + + public void setComment(String comment) { + this.comment = comment; + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Integer getApplyStatus() { + return applyStatus; + } + + public void setApplyStatus(Integer applyStatus) { + this.applyStatus = applyStatus; + } + + public Long getListAppRover() { + return listAppRover; + } + + public void setListAppRover(Long listAppRover) { + this.listAppRover = listAppRover; + } + + public Long getCreator_id() { + return creator_id; + } + + public void setCreator_id(Long creator_id) { + this.creator_id = creator_id; + } + + public String getCreator_name() { + return creator_name; + } + + public void setCreator_name(String creator_name) { + this.creator_name = creator_name; + } + + public String getConditionColumn() { + return conditionColumn; + } + + public void setConditionColumn(String conditionColumn) { + this.conditionColumn = conditionColumn; + } + + public Long getConditionValue() { + return conditionValue; + } + + public void setConditionValue(Long conditionValue) { + this.conditionValue = conditionValue; + } + + public String getApproveCode() { + return approveCode; + } + + public void setApproveCode(String approveCode) { + this.approveCode = approveCode; + } + + public Map<String, String> getRequestDataMap() { + return requestDataMap; + } + + public void setRequestDataMap(Map<String, String> requestDataMap) { + this.requestDataMap = requestDataMap; + } + + public String getBusinessCode() { + return businessCode; + } + + public void setBusinessCode(String businessCode) { + this.businessCode = businessCode; + } +} diff --git a/src/main/java/com/fengdu/gas/entity/dto/SearchBasicDTO.java b/src/main/java/com/fengdu/gas/entity/dto/SearchBasicDTO.java new file mode 100644 index 0000000..0821e00 --- /dev/null +++ b/src/main/java/com/fengdu/gas/entity/dto/SearchBasicDTO.java @@ -0,0 +1,137 @@ +package com.fengdu.gas.entity.dto; + +import java.util.List; + +/** + * 分页查询基础 dto + * @Author lin.liu + * @Description 分页查询基础 dto + * @Date 2021/4/7 + **/ +public class SearchBasicDTO extends PagerBasicDTO { + /** + * 关键字 + */ + private String keywords; + /** + * 自增id列表 + */ + private List<Long> listId; + /** + * 数据状态 EState + */ + private Integer status; + /** + * 数据状态列表 + */ + private List<Integer> listStatus; + /** + * 数据创建时间-范围(eg: 2021-01-01 00:00:00 ~ 2021-01-01 23:59:59)" + */ + private String createTimeRange; + /** + * 数据创建时间-起始 + * @ignore + */ + private Long createTimeStart; + /** + * 数据创建时间-截止 + * @ignore + */ + private Long createTimeEnd; + /** + * 上次请求最后一条数据的id + */ + private Long lastId; + /** + * 排序列表 + */ + private List<OrderByDTO> orderBy; + + public String getKeywords() { + return keywords; + } + + public void setKeywords(String keywords) { + this.keywords = keywords; + } + + public List<Long> getListId() { + return listId; + } + + public void setListId(List<Long> listId) { + this.listId = listId; + } + + public Integer getStatus() { + return status; + } + + public void setStatus(Integer status) { + this.status = status; + } + + public List<Integer> getListStatus() { + return listStatus; + } + + public void setListStatus(List<Integer> listStatus) { + this.listStatus = listStatus; + } + + public String getCreateTimeRange() { + return createTimeRange; + } + + public void setCreateTimeRange(String createTimeRange) { + this.createTimeRange = createTimeRange; + } + + public Long getCreateTimeStart() { + return createTimeStart; + } + + public void setCreateTimeStart(Long createTimeStart) { + this.createTimeStart = createTimeStart; + } + + public Long getCreateTimeEnd() { + return createTimeEnd; + } + + public void setCreateTimeEnd(Long createTimeEnd) { + this.createTimeEnd = createTimeEnd; + } + + public Long getLastId() { + return lastId; + } + + public void setLastId(Long lastId) { + this.lastId = lastId; + } + + public List<OrderByDTO> getOrderBy() { + return orderBy; + } + + public void setOrderBy(List<OrderByDTO> orderBy) { + this.orderBy = orderBy; + } + + @Override + public String toString() { + return "SearchBasicDTO{" + + "keywords='" + keywords + '\'' + + ", listId=" + listId + + ", status=" + status + + ", listStatus=" + listStatus + + ", createTimeRange='" + createTimeRange + '\'' + + ", createTimeStart=" + createTimeStart + + ", createTimeEnd=" + createTimeEnd + + ", lastId=" + lastId + + ", orderBy='" + orderBy + '\'' + + '}'; + } +} diff --git a/src/main/java/com/fengdu/gas/entity/dto/UploadResultVo.java b/src/main/java/com/fengdu/gas/entity/dto/UploadResultVo.java new file mode 100644 index 0000000..063e5a3 --- /dev/null +++ b/src/main/java/com/fengdu/gas/entity/dto/UploadResultVo.java @@ -0,0 +1,88 @@ +package com.fengdu.gas.entity.dto; + +public class UploadResultVo { + /** + * 文件id,传参后原样输出,前端比对文件用,无实际意义。 + */ + private String fileId; + /** + * 原始文件名称 传参后原样输出 + */ + private String name; + /** + * 新文件名称(需要保存数据库的虚拟路径) + */ + private String newFileName; + /** + * 文件预览地址 + */ + private String newFileView; + /** + * 文件类型 + */ + private String fileType; + /** + * 文件媒体类型 + */ + private String contentType; + /** + * 文件大小(kb) + */ + private Long size; + + public String getFileId() { + return fileId; + } + + public void setFileId(String fileId) { + this.fileId = fileId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getNewFileName() { + return newFileName; + } + + public void setNewFileName(String newFileName) { + this.newFileName = newFileName; + } + + public String getNewFileView() { + return newFileView; + } + + public void setNewFileView(String newFileView) { + this.newFileView = newFileView; + } + + public String getFileType() { + return fileType; + } + + public void setFileType(String fileType) { + this.fileType = fileType; + } + + public String getContentType() { + return contentType; + } + + public void setContentType(String contentType) { + this.contentType = contentType; + } + + public Long getSize() { + return size; + } + + public void setSize(Long size) { + this.size = size; + } +} \ No newline at end of file diff --git a/src/main/java/com/fengdu/gas/entity/dto/UserInfoDto.java b/src/main/java/com/fengdu/gas/entity/dto/UserInfoDto.java new file mode 100644 index 0000000..47dc767 --- /dev/null +++ b/src/main/java/com/fengdu/gas/entity/dto/UserInfoDto.java @@ -0,0 +1,178 @@ +package com.fengdu.gas.entity.dto; + +public class UserInfoDto { + /** + * 联系方式 + */ + private String contact; + /** + * 数据创建时间 + */ + private Long createTime; + private String createTimeView; + /** + * 联系邮箱 + */ + private String email; + /** + * 头像 + */ + private String headImg; + /** + * 自增id + */ + private Long id; + /** + * 昵称 + */ + private String nickName; + /** + * 密码 + */ + private String password; + /** + * 角色id + */ + private Long roleId; + /** + * 状态(EState) 正常=1,关闭=2 + */ + private Long status; + /** + * 数据最后更新时间 + */ + private String updateTime; + private String updateTimeView; + /** + * 用户名 + */ + private String userName; + /** + * 用户关联id,和“user_type”对应,如:客户id等 + */ + private Long userRelId; + /** + * 用户类型 EUserType + */ + private Long userType; + + public String getContact() { + return contact; + } + + public void setContact(String contact) { + this.contact = contact; + } + + public Long getCreateTime() { + return createTime; + } + + public void setCreateTime(Long createTime) { + this.createTime = createTime; + } + + public String getCreateTimeView() { + return createTimeView; + } + + public void setCreateTimeView(String createTimeView) { + this.createTimeView = createTimeView; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public String getHeadImg() { + return headImg; + } + + public void setHeadImg(String headImg) { + this.headImg = headImg; + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getNickName() { + return nickName; + } + + public void setNickName(String nickName) { + this.nickName = nickName; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public Long getRoleId() { + return roleId; + } + + public void setRoleId(Long roleId) { + this.roleId = roleId; + } + + public Long getStatus() { + return status; + } + + public void setStatus(Long status) { + this.status = status; + } + + public String getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(String updateTime) { + this.updateTime = updateTime; + } + + public String getUpdateTimeView() { + return updateTimeView; + } + + public void setUpdateTimeView(String updateTimeView) { + this.updateTimeView = updateTimeView; + } + + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + + public Long getUserRelId() { + return userRelId; + } + + public void setUserRelId(Long userRelId) { + this.userRelId = userRelId; + } + + public Long getUserType() { + return userType; + } + + public void setUserType(Long userType) { + this.userType = userType; + } +} diff --git a/src/main/java/com/fengdu/gas/entity/enums/EDataChangeType.java b/src/main/java/com/fengdu/gas/entity/enums/EDataChangeType.java new file mode 100644 index 0000000..c2196ba --- /dev/null +++ b/src/main/java/com/fengdu/gas/entity/enums/EDataChangeType.java @@ -0,0 +1,73 @@ +package com.fengdu.gas.entity.enums; + +import java.util.Arrays; +import java.util.Objects; + +/** + * 数据变更类型 通用枚举 + * @author linliu + * @date 2019-01-02 + */ +public enum EDataChangeType { + /** + * 新增 + */ + CREATE("新增", 1), + /** + * 修改 + */ + MODIFY("修改", 2), + /** + * 停用 + */ + DISABLED("停用", 3), + /** + * 启用 + */ + ENABLED("启用", 4), + /** + * 删除 + */ + DELETED("删除", 5); + + private String desc;//枚举描述 + private Integer value;//枚举值 + + public Integer getValue() { + return value; + } + public String getDesc() { + return desc; + } + + /** + * 构造方法 + * @param desc 枚举描述 + * @param value 枚举值 + */ + private EDataChangeType(String desc, Integer value) { + this.desc = desc; + this.value = value; + } + + /** + * 根据值获取枚举 + * + * @param value 枚举值 + * @return + */ + public static EDataChangeType getByValue(Integer value) { + return Arrays.stream(EDataChangeType.values()) + .filter(e -> Objects.equals(e.getValue(), value)) + .findAny() + .orElse(null); + } + + @Override + public String toString() { + return "EDataChangeType{" + + "desc='" + desc + '\'' + + ", value=" + value + + '}'; + } +} \ No newline at end of file diff --git a/src/main/java/com/fengdu/gas/entity/enums/EExecuteType.java b/src/main/java/com/fengdu/gas/entity/enums/EExecuteType.java new file mode 100644 index 0000000..efb77e6 --- /dev/null +++ b/src/main/java/com/fengdu/gas/entity/enums/EExecuteType.java @@ -0,0 +1,63 @@ +package com.fengdu.gas.entity.enums; + +import java.util.Arrays; +import java.util.Objects; + +public enum EExecuteType { + /** + * 待执行 + */ + NOT_EXECUTE("待执行", 1), + /** + * 执行中 + */ + IN_EXECUTE("执行中", 2), + /** + * 已执行 + */ + YES_EXECUTE("已执行", 3), + /** + * 撤销 + */ + ANNUL_EXECUTE("撤销", 4); + private String desc;//枚举描述 + private Integer value;//枚举值 + + public Integer getValue() { + return value; + } + public String getDesc() { + return desc; + } + + /** + * 构造方法 + * @param desc 枚举描述 + * @param value 枚举值 + */ + private EExecuteType(String desc, Integer value) { + this.desc = desc; + this.value = value; + } + + /** + * 根据值获取枚举 + * + * @param value 枚举值 + * @return + */ + public static EExecuteType getByValue(Integer value) { + return Arrays.stream(EExecuteType.values()) + .filter(e -> Objects.equals(e.getValue(), value)) + .findAny() + .orElse(null); + } + + @Override + public String toString() { + return "EExecuteType{" + + "desc='" + desc + '\'' + + ", value=" + value + + '}'; + } +} diff --git a/src/main/java/com/fengdu/gas/entity/enums/EHandleStatus.java b/src/main/java/com/fengdu/gas/entity/enums/EHandleStatus.java new file mode 100644 index 0000000..c30b10c --- /dev/null +++ b/src/main/java/com/fengdu/gas/entity/enums/EHandleStatus.java @@ -0,0 +1,69 @@ +package com.fengdu.gas.entity.enums; + +import java.util.Arrays; +import java.util.Objects; + +/** + * 数据处理状态 通用枚举 + * @author lin.liu + * @date 2019-01-08 + */ +public enum EHandleStatus { + /** + * 待处理 + */ + AWAITING("待处理", 100), + /** + *处理中 + */ + PROCESSING("处理中", 101), + /** + * 已处理 + */ + SUCCESS("已处理", 200), + /** + * 处理失败 + */ + FAILED("处理失败", 300); + + private String desc;//枚举描述 + private Integer value;//枚举值 + + public Integer getValue() { + return value; + } + public String getDesc() { + return desc; + } + + /** + * 构造方法 + * @param desc 枚举描述 + * @param value 枚举值 + */ + EHandleStatus(String desc, Integer value) { + this.desc = desc; + this.value = value; + } + + /** + * 根据值获取枚举 + * + * @param value 枚举值 + * @return + */ + public static EHandleStatus getByValue(Integer value) { + return Arrays.stream(EHandleStatus.values()) + .filter(e -> Objects.equals(e.getValue(), value)) + .findAny() + .orElse(null); + } + + @Override + public String toString() { + return "EHandleStatus{" + + "desc='" + desc + '\'' + + ", value=" + value + + '}'; + } +} \ No newline at end of file diff --git a/src/main/java/com/fengdu/gas/entity/enums/ELockValue.java b/src/main/java/com/fengdu/gas/entity/enums/ELockValue.java new file mode 100644 index 0000000..38313e6 --- /dev/null +++ b/src/main/java/com/fengdu/gas/entity/enums/ELockValue.java @@ -0,0 +1,8 @@ +package com.fengdu.gas.entity.enums; + +public enum ELockValue { + /** + * 管理员变更 + */ + ADMIN_CHANGE +} diff --git a/src/main/java/com/fengdu/gas/entity/enums/EMenuType.java b/src/main/java/com/fengdu/gas/entity/enums/EMenuType.java new file mode 100644 index 0000000..74ed9ae --- /dev/null +++ b/src/main/java/com/fengdu/gas/entity/enums/EMenuType.java @@ -0,0 +1,66 @@ +package com.fengdu.gas.entity.enums; + +import java.util.Arrays; +import java.util.Objects; + +/** + * 菜单类型 + */ +public enum EMenuType { + /** + * 目录=1, + */ + FOLDER("目录", 1), + /** + * 页面=2, + */ + PAGE("页面", 2), + ; + + /** + * 枚举描述 + */ + private String desc; + /** + * 枚举值 + */ + private Integer value; + + public Integer getValue() { + return value; + } + public String getDesc() { + return desc; + } + + /** + * 构造方法 + * @param desc 枚举描述 + * @param value 枚举值 + */ + EMenuType(String desc, Integer value) { + this.desc = desc; + this.value = value; + } + + /** + * 根据值获取枚举 + * + * @param value 枚举值 + * @return + */ + public static EMenuType getByValue(Integer value) { + return Arrays.stream(EMenuType.values()) + .filter(e -> Objects.equals(e.getValue(), value)) + .findAny() + .orElse(null); + } + + @Override + public String toString() { + return "EMenuType{" + + "desc='" + desc + '\'' + + ", value=" + value + + '}'; + } +} diff --git a/src/main/java/com/fengdu/gas/entity/enums/EOperation.java b/src/main/java/com/fengdu/gas/entity/enums/EOperation.java new file mode 100644 index 0000000..3b21d94 --- /dev/null +++ b/src/main/java/com/fengdu/gas/entity/enums/EOperation.java @@ -0,0 +1,98 @@ +package com.fengdu.gas.entity.enums; + +import java.util.Arrays; +import java.util.Objects; + +/** + * 操作类型 + * @author linliu + * @date 2019-01-02 + */ +public enum EOperation { + /** + * 搜索 + */ + LIST("搜索", "list"), + /** + * 保存(新增+编辑) + */ + SAVE("保存(新增+编辑)", "save"), + /** + * 新增 + */ + ADD("新增", "add"), + /** + * 详情 + */ + DETAIL("详情", "detail"), + /** + * 修改 + */ + UPDATE("修改", "update"), + /** + * 停用 + */ + DISABLED("停用", "disable"), + /** + * 启用 + */ + ENABLED("启用", "enable"), + /** + * 删除 + */ + DELETED("删除", "delete"), + /** + * 导入 + */ + IMPORT("导入", "import"), + /** + * 导出 + */ + EXPORT("导出", "export"), + /** + * 打印 + */ + PRINT("打印", "print"), + ; + + private String desc;//枚举描述 + private String value;//枚举值 + + public String getValue() { + return value; + } + public String getDesc() { + return desc; + } + + /** + * 构造方法 + * @param desc 枚举描述 + * @param value 枚举值 + */ + EOperation(String desc, String value) { + this.desc = desc; + this.value = value; + } + + /** + * 根据值获取枚举 + * + * @param value 枚举值 + * @return + */ + public static EOperation getByValue(String value) { + return Arrays.stream(EOperation.values()) + .filter(e -> Objects.equals(e.getValue(), value)) + .findAny() + .orElse(null); + } + + @Override + public String toString() { + return "EOperation{" + + "desc='" + desc + '\'' + + ", value=" + value + + '}'; + } +} \ No newline at end of file diff --git a/src/main/java/com/fengdu/gas/entity/enums/EOrderBy.java b/src/main/java/com/fengdu/gas/entity/enums/EOrderBy.java new file mode 100644 index 0000000..ecb4485 --- /dev/null +++ b/src/main/java/com/fengdu/gas/entity/enums/EOrderBy.java @@ -0,0 +1,63 @@ +package com.fengdu.gas.entity.enums; + +import java.util.Arrays; +import java.util.Objects; + +/** + * 通用排序类型 枚举 + */ +public enum EOrderBy { + /** + * 自增id=1, + */ + ID("自增id", 1), + /** + * 创建时间=2, + */ + CREATE_TIME("创建时间", 2), + /** + * 更新时间=3, + */ + UPDATE_TIME("更新时间", 3); + + private String desc;//枚举描述 + private Integer value;//枚举值 + + public Integer getValue() { + return value; + } + public String getDesc() { + return desc; + } + + /** + * 构造方法 + * @param desc 枚举描述 + * @param value 枚举值 + */ + EOrderBy(String desc, Integer value) { + this.desc = desc; + this.value = value; + } + + /** + * 根据值获取枚举 + * + * @param value 枚举值 + * @return + */ + public static EOrderBy getByValue(Integer value) { + return Arrays.stream(EOrderBy.values()) + .filter(e -> Objects.equals(e.getValue(), value)) + .findAny() + .orElse(null); + } + + @Override + public String toString() { + return "EOrderBy{" + + "desc='" + desc + '\'' + + ", value=" + value + + '}'; + } +} diff --git a/src/main/java/com/fengdu/gas/entity/enums/EParameterType.java b/src/main/java/com/fengdu/gas/entity/enums/EParameterType.java new file mode 100644 index 0000000..5418b3a --- /dev/null +++ b/src/main/java/com/fengdu/gas/entity/enums/EParameterType.java @@ -0,0 +1,56 @@ +package com.fengdu.gas.entity.enums; + +import java.util.Arrays; +import java.util.Objects; + +public enum EParameterType { + /** + * 固定值=1, + */ + CONSTANT("固定值", 1), + /** + * 范围=2, + */ + RANGE("范围", 2); + + private String desc;//枚举描述 + private Integer value;//枚举值 + + public Integer getValue() { + return value; + } + public String getDesc() { + return desc; + } + + /** + * 构造方法 + * @param desc 枚举描述 + * @param value 枚举值 + */ + EParameterType(String desc, Integer value) { + this.desc = desc; + this.value = value; + } + + /** + * 根据值获取枚举 + * + * @param value 枚举值 + * @return + */ + public static EParameterType getByValue(Integer value) { + return Arrays.stream(EParameterType.values()) + .filter(e -> Objects.equals(e.getValue(), value)) + .findAny() + .orElse(null); + } + + @Override + public String toString() { + return "EParameterType{" + + "desc='" + desc + '\'' + + ", value=" + value + + '}'; + } +} diff --git a/src/main/java/com/fengdu/gas/entity/enums/ESex.java b/src/main/java/com/fengdu/gas/entity/enums/ESex.java new file mode 100644 index 0000000..b8d90dd --- /dev/null +++ b/src/main/java/com/fengdu/gas/entity/enums/ESex.java @@ -0,0 +1,66 @@ +package com.fengdu.gas.entity.enums; + +import java.util.Arrays; +import java.util.Objects; + +public enum ESex { + /** + * 男=1, + */ + MALE("男", 1), + /** + * 女=2, + */ + FEMALE("女", 2), + /** + * 其他=3, + */ + OTHER("其他", 3); + + /** + * 枚举描述 + */ + private String desc; + /** + * 枚举值 + */ + private Integer value; + + public Integer getValue() { + return value; + } + public String getDesc() { + return desc; + } + + /** + * 构造方法 + * @param desc 枚举描述 + * @param value 枚举值 + */ + ESex(String desc, Integer value) { + this.desc = desc; + this.value = value; + } + + /** + * 根据值获取枚举 + * + * @param value 枚举值 + * @return + */ + public static ESex getByValue(Integer value) { + return Arrays.stream(ESex.values()) + .filter(e -> Objects.equals(e.getValue(), value)) + .findAny() + .orElse(null); + } + + @Override + public String toString() { + return "ESex{" + + "desc='" + desc + '\'' + + ", value=" + value + + '}'; + } +} diff --git a/src/main/java/com/fengdu/gas/entity/enums/ESortOrderBy.java b/src/main/java/com/fengdu/gas/entity/enums/ESortOrderBy.java new file mode 100644 index 0000000..db28a0f --- /dev/null +++ b/src/main/java/com/fengdu/gas/entity/enums/ESortOrderBy.java @@ -0,0 +1,67 @@ +package com.fengdu.gas.entity.enums; + +import java.util.Arrays; +import java.util.Objects; + +/** + * 带排序值的排序类型 枚举 + */ +public enum ESortOrderBy { + /** + * 自增id=1, + */ + ID("自增id", 1), + /** + * 创建时间=2, + */ + CREATE_TIME("创建时间", 2), + /** + * 更新时间=3, + */ + UPDATE_TIME("更新时间", 3), + /** + * 排序值=4, + */ + SORT("排序值", 4); + + private String desc;//枚举描述 + private Integer value;//枚举值 + + public Integer getValue() { + return value; + } + public String getDesc() { + return desc; + } + + /** + * 构造方法 + * @param desc 枚举描述 + * @param value 枚举值 + */ + ESortOrderBy(String desc, Integer value) { + this.desc = desc; + this.value = value; + } + + /** + * 根据值获取枚举 + * + * @param value 枚举值 + * @return + */ + public static ESortOrderBy getByValue(Integer value) { + return Arrays.stream(ESortOrderBy.values()) + .filter(e -> Objects.equals(e.getValue(), value)) + .findAny() + .orElse(null); + } + + @Override + public String toString() { + return "ESortOrderBy{" + + "desc='" + desc + '\'' + + ", value=" + value + + '}'; + } +} diff --git a/src/main/java/com/fengdu/gas/entity/enums/EState.java b/src/main/java/com/fengdu/gas/entity/enums/EState.java new file mode 100644 index 0000000..aefe1a5 --- /dev/null +++ b/src/main/java/com/fengdu/gas/entity/enums/EState.java @@ -0,0 +1,69 @@ +package com.fengdu.gas.entity.enums; + +import java.util.Arrays; +import java.util.Objects; + +/** + * 状态 枚举 + */ +public enum EState { + /** + * 正常=1, + */ + NORMAL("正常", 1), + /** + * 关闭/停用=2, + */ + DISABLED("关闭/停用", 2), + /** + * 删除=3, + */ + DELETED("删除", 3); + + /** + * 枚举描述 + */ + private String desc; + /** + * 枚举值 + */ + private Integer value; + + public Integer getValue() { + return value; + } + public String getDesc() { + return desc; + } + + /** + * 构造方法 + * @param desc 枚举描述 + * @param value 枚举值 + */ + EState(String desc, Integer value) { + this.desc = desc; + this.value = value; + } + + /** + * 根据值获取枚举 + * + * @param value 枚举值 + * @return + */ + public static EState getByValue(Integer value) { + return Arrays.stream(EState.values()) + .filter(e -> Objects.equals(e.getValue(), value)) + .findAny() + .orElse(null); + } + + @Override + public String toString() { + return "EState{" + + "desc='" + desc + '\'' + + ", value=" + value + + '}'; + } +} diff --git a/src/main/java/com/fengdu/gas/entity/enums/EUserType.java b/src/main/java/com/fengdu/gas/entity/enums/EUserType.java new file mode 100644 index 0000000..df6dcee --- /dev/null +++ b/src/main/java/com/fengdu/gas/entity/enums/EUserType.java @@ -0,0 +1,61 @@ +package com.fengdu.gas.entity.enums; + +import java.util.Arrays; +import java.util.Objects; + +/** + * 用户类型 枚举 + */ +public enum EUserType { + /** + * 超级管理员=1, + */ + ADMIN("超级管理员", 1), + /** + * 普通管理员=2, + */ + ADMIN_USER("普通管理员", 2), + + ; + + private String desc;//枚举描述 + private Integer value;//枚举值 + + public Integer getValue() { + return value; + } + public String getDesc() { + return desc; + } + + /** + * 构造方法 + * @param desc 枚举描述 + * @param value 枚举值 + */ + EUserType(String desc, Integer value) { + this.desc = desc; + this.value = value; + } + + /** + * 根据值获取枚举 + * + * @param value 枚举值 + * @return + */ + public static EUserType getByValue(Integer value) { + return Arrays.stream(EUserType.values()) + .filter(e -> Objects.equals(e.getValue(), value)) + .findAny() + .orElse(null); + } + + @Override + public String toString() { + return "EUserType{" + + "desc='" + desc + '\'' + + ", value=" + value + + '}'; + } +} diff --git a/src/main/java/com/fengdu/gas/entity/request/AdminSendMail.java b/src/main/java/com/fengdu/gas/entity/request/AdminSendMail.java new file mode 100644 index 0000000..e370ed6 --- /dev/null +++ b/src/main/java/com/fengdu/gas/entity/request/AdminSendMail.java @@ -0,0 +1,23 @@ +package com.fengdu.gas.entity.request; + +public class AdminSendMail { + + private String username; + private String password; + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } +} \ No newline at end of file diff --git a/src/main/java/com/fengdu/gas/entity/request/ReqChangePassword.java b/src/main/java/com/fengdu/gas/entity/request/ReqChangePassword.java new file mode 100644 index 0000000..4676bdf --- /dev/null +++ b/src/main/java/com/fengdu/gas/entity/request/ReqChangePassword.java @@ -0,0 +1,30 @@ +package com.fengdu.gas.entity.request; + +public class ReqChangePassword { + /** + * 旧密码 + * @required + */ + private String oldPassword; + /** + * 新密码 + * @required + */ + private String newPassword; + + public String getOldPassword() { + return oldPassword; + } + + public void setOldPassword(String oldPassword) { + this.oldPassword = oldPassword; + } + + public String getNewPassword() { + return newPassword; + } + + public void setNewPassword(String newPassword) { + this.newPassword = newPassword; + } +} diff --git a/src/main/java/com/fengdu/gas/entity/request/ReqListId.java b/src/main/java/com/fengdu/gas/entity/request/ReqListId.java new file mode 100644 index 0000000..647e0e2 --- /dev/null +++ b/src/main/java/com/fengdu/gas/entity/request/ReqListId.java @@ -0,0 +1,19 @@ +package com.fengdu.gas.entity.request; + +import java.util.List; + +public class ReqListId { + /** + * id列表 + * @required + */ + private List<Long> listId; + + public List<Long> getListId() { + return listId; + } + + public void setListId(List<Long> listId) { + this.listId = listId; + } +} diff --git a/src/main/java/com/fengdu/gas/entity/request/ReqListSetSort.java b/src/main/java/com/fengdu/gas/entity/request/ReqListSetSort.java new file mode 100644 index 0000000..84daf04 --- /dev/null +++ b/src/main/java/com/fengdu/gas/entity/request/ReqListSetSort.java @@ -0,0 +1,22 @@ +package com.fengdu.gas.entity.request; + +import java.util.List; + +/** + * 批量设置顺序 对象 + */ +public class ReqListSetSort { + /** + * 设置顺序列表 + * @required + */ + private List<ReqSetSort> list; + + public List<ReqSetSort> getList() { + return list; + } + + public void setList(List<ReqSetSort> list) { + this.list = list; + } +} diff --git a/src/main/java/com/fengdu/gas/entity/request/ReqListStatus.java b/src/main/java/com/fengdu/gas/entity/request/ReqListStatus.java new file mode 100644 index 0000000..92f55a2 --- /dev/null +++ b/src/main/java/com/fengdu/gas/entity/request/ReqListStatus.java @@ -0,0 +1,18 @@ +package com.fengdu.gas.entity.request; + +import java.util.List; + +public class ReqListStatus { + /** + * 状态列表 + */ + private List<Integer> listStatus; + + public List<Integer> getListStatus() { + return listStatus; + } + + public void setListStatus(List<Integer> listStatus) { + this.listStatus = listStatus; + } +} diff --git a/src/main/java/com/fengdu/gas/entity/request/ReqNeedCode.java b/src/main/java/com/fengdu/gas/entity/request/ReqNeedCode.java new file mode 100644 index 0000000..f63a45a --- /dev/null +++ b/src/main/java/com/fengdu/gas/entity/request/ReqNeedCode.java @@ -0,0 +1,19 @@ +package com.fengdu.gas.entity.request; + + + +public class ReqNeedCode { + /** + * 编号 + * @required + */ + private String code; + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } +} diff --git a/src/main/java/com/fengdu/gas/entity/request/ReqNeedId.java b/src/main/java/com/fengdu/gas/entity/request/ReqNeedId.java new file mode 100644 index 0000000..ee6244a --- /dev/null +++ b/src/main/java/com/fengdu/gas/entity/request/ReqNeedId.java @@ -0,0 +1,17 @@ +package com.fengdu.gas.entity.request; + +public class ReqNeedId { + /** + * 自增id + * @required + */ + private Long id; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } +} diff --git a/src/main/java/com/fengdu/gas/entity/request/ReqOperate.java b/src/main/java/com/fengdu/gas/entity/request/ReqOperate.java new file mode 100644 index 0000000..ffbb35f --- /dev/null +++ b/src/main/java/com/fengdu/gas/entity/request/ReqOperate.java @@ -0,0 +1,30 @@ +package com.fengdu.gas.entity.request; + +public class ReqOperate { + /** + * 业务id + * @required + */ + private Long id; + /** + * 操作备注 + * @required + */ + private String comment; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getComment() { + return comment; + } + + public void setComment(String comment) { + this.comment = comment; + } +} diff --git a/src/main/java/com/fengdu/gas/entity/request/ReqSetSort.java b/src/main/java/com/fengdu/gas/entity/request/ReqSetSort.java new file mode 100644 index 0000000..2f94445 --- /dev/null +++ b/src/main/java/com/fengdu/gas/entity/request/ReqSetSort.java @@ -0,0 +1,30 @@ +package com.fengdu.gas.entity.request; + +public class ReqSetSort { + /** + * 自增id + * @required + */ + private Long id; + /** + * 排序值 + * @required + */ + private Integer sort; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Integer getSort() { + return sort; + } + + public void setSort(Integer sort) { + this.sort = sort; + } +} diff --git a/src/main/java/com/fengdu/gas/entity/request/ReqUserLogin.java b/src/main/java/com/fengdu/gas/entity/request/ReqUserLogin.java new file mode 100644 index 0000000..8fd7ecc --- /dev/null +++ b/src/main/java/com/fengdu/gas/entity/request/ReqUserLogin.java @@ -0,0 +1,30 @@ +package com.fengdu.gas.entity.request; + +public class ReqUserLogin { + /** + * 登录账户 + * @required + */ + private String userName; + /** + * 密码 + * @required + */ + private String password; + + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } +} diff --git a/src/main/java/com/fengdu/gas/entity/request/adminmenu/ReqCreateAdminMenu.java b/src/main/java/com/fengdu/gas/entity/request/adminmenu/ReqCreateAdminMenu.java new file mode 100644 index 0000000..201af46 --- /dev/null +++ b/src/main/java/com/fengdu/gas/entity/request/adminmenu/ReqCreateAdminMenu.java @@ -0,0 +1,64 @@ +/** +# __----~~~~~~~~~~~------___ +# . . ~~//====...... __--~ ~~ +# -. \_|// |||\\ ~~~~~~::::... /~ +# ___-==_ _-~o~ \/ ||| \\ _/~~- +# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ +# _-~~ .=~ | \\-_ '-~7 /- / || \ / +# .~ .~ | \\ -_ / /- / || \ / +# / ____ / | \\ ~-_/ /|- _/ .|| \ / +# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ +# ' ~-| /| |-~\~~ __--~~ +# |-~~-_/ | | ~\_ _-~ /\ +# / \ \__ \/~ \__ +# _--~ _/ | .-~~____--~-/ ~~==. +# ((->/~ '.|||' -_| ~~-/ , . _|| +# -_ ~\ ~~---l__i__i__i--~~_/ +# _-~-__ ~) \--______________--~~ +# //.-~~~-~_--~- |-------~~~~~~~~ +# //.-~~~--\ +# 神兽保佑 +# 永无BUG! +*/ +package com.fengdu.gas.entity.request.adminmenu; + +import lombok.Data; + +/** + * 后台菜单 + * @author lin.liu + * @description 后台菜单 + */ +@Data +public class ReqCreateAdminMenu { + /** + * 类型 EMenuType + * @required + */ + private Integer type; + /** + * 父级ID + */ + private Long parentId; + /** + * 菜单名称 + * @required + */ + private String name; + /** + * 菜单标题 + */ + private String title; + /** + * 前端资源路径 + */ + private String url; + /** + * 排序值 + */ + private Integer sort; + /** + * 图标 + */ + private String icon; +} diff --git a/src/main/java/com/fengdu/gas/entity/request/adminmenu/ReqModifyAdminMenu.java b/src/main/java/com/fengdu/gas/entity/request/adminmenu/ReqModifyAdminMenu.java new file mode 100644 index 0000000..4fb468e --- /dev/null +++ b/src/main/java/com/fengdu/gas/entity/request/adminmenu/ReqModifyAdminMenu.java @@ -0,0 +1,73 @@ +/** +# __----~~~~~~~~~~~------___ +# . . ~~//====...... __--~ ~~ +# -. \_|// |||\\ ~~~~~~::::... /~ +# ___-==_ _-~o~ \/ ||| \\ _/~~- +# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ +# _-~~ .=~ | \\-_ '-~7 /- / || \ / +# .~ .~ | \\ -_ / /- / || \ / +# / ____ / | \\ ~-_/ /|- _/ .|| \ / +# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ +# ' ~-| /| |-~\~~ __--~~ +# |-~~-_/ | | ~\_ _-~ /\ +# / \ \__ \/~ \__ +# _--~ _/ | .-~~____--~-/ ~~==. +# ((->/~ '.|||' -_| ~~-/ , . _|| +# -_ ~\ ~~---l__i__i__i--~~_/ +# _-~-__ ~) \--______________--~~ +# //.-~~~-~_--~- |-------~~~~~~~~ +# //.-~~~--\ +# 神兽保佑 +# 永无BUG! +*/ +package com.fengdu.gas.entity.request.adminmenu; + +import lombok.Data; + +/** + * 后台菜单 + * @author lin.liu + * @description 后台菜单 + */ +@Data +public class ReqModifyAdminMenu { + /** + * 主键 + * @required + */ + private Long id; + /** + * 类型 EMenuType + * @required + */ + private Integer type; + /** + * 父级ID + */ + private Long parentId; + /** + * 菜单名称 + * @required + */ + private String name; + /** + * 菜单标题 + */ + private String title; + /** + * 前端资源路径 + */ + private String url; + /** + * 排序值 + */ + private Integer sort; + /** + * 图标 + */ + private String icon; + /** + * 状态 EState + */ + private Integer status; +} diff --git a/src/main/java/com/fengdu/gas/entity/request/adminmenus/ReqCreateAdminMenus.java b/src/main/java/com/fengdu/gas/entity/request/adminmenus/ReqCreateAdminMenus.java new file mode 100644 index 0000000..a6d600f --- /dev/null +++ b/src/main/java/com/fengdu/gas/entity/request/adminmenus/ReqCreateAdminMenus.java @@ -0,0 +1,61 @@ +/** +# __----~~~~~~~~~~~------___ +# . . ~~//====...... __--~ ~~ +# -. \_|// |||\\ ~~~~~~::::... /~ +# ___-==_ _-~o~ \/ ||| \\ _/~~- +# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ +# _-~~ .=~ | \\-_ '-~7 /- / || \ / +# .~ .~ | \\ -_ / /- / || \ / +# / ____ / | \\ ~-_/ /|- _/ .|| \ / +# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ +# ' ~-| /| |-~\~~ __--~~ +# |-~~-_/ | | ~\_ _-~ /\ +# / \ \__ \/~ \__ +# _--~ _/ | .-~~____--~-/ ~~==. +# ((->/~ '.|||' -_| ~~-/ , . _|| +# -_ ~\ ~~---l__i__i__i--~~_/ +# _-~-__ ~) \--______________--~~ +# //.-~~~-~_--~- |-------~~~~~~~~ +# //.-~~~--\ +# 神兽保佑 +# 永无BUG! +*/ +package com.fengdu.gas.entity.request.adminmenus; + +import lombok.Data; + +/** + * 菜单信息 + * @author lin.liu + */ +@Data +public class ReqCreateAdminMenus { + /** + * 父级id + */ + private Long parentId; + /** + * 菜单名称 + */ + private String name; + /** + * 菜单标题 + */ + private String title; + /** + * 前端资源路径 + */ + private String uri; + /** + * 菜单层级 + */ + private Integer level; + /** + * 排序值 + */ + private Integer sort; + /** + * 图标 + */ + private String icon; +} diff --git a/src/main/java/com/fengdu/gas/entity/request/adminmenus/ReqModifyAdminMenus.java b/src/main/java/com/fengdu/gas/entity/request/adminmenus/ReqModifyAdminMenus.java new file mode 100644 index 0000000..be186e3 --- /dev/null +++ b/src/main/java/com/fengdu/gas/entity/request/adminmenus/ReqModifyAdminMenus.java @@ -0,0 +1,69 @@ +/** +# __----~~~~~~~~~~~------___ +# . . ~~//====...... __--~ ~~ +# -. \_|// |||\\ ~~~~~~::::... /~ +# ___-==_ _-~o~ \/ ||| \\ _/~~- +# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ +# _-~~ .=~ | \\-_ '-~7 /- / || \ / +# .~ .~ | \\ -_ / /- / || \ / +# / ____ / | \\ ~-_/ /|- _/ .|| \ / +# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ +# ' ~-| /| |-~\~~ __--~~ +# |-~~-_/ | | ~\_ _-~ /\ +# / \ \__ \/~ \__ +# _--~ _/ | .-~~____--~-/ ~~==. +# ((->/~ '.|||' -_| ~~-/ , . _|| +# -_ ~\ ~~---l__i__i__i--~~_/ +# _-~-__ ~) \--______________--~~ +# //.-~~~-~_--~- |-------~~~~~~~~ +# //.-~~~--\ +# 神兽保佑 +# 永无BUG! +*/ +package com.fengdu.gas.entity.request.adminmenus; + +import lombok.Data; + +/** + * 菜单信息 + * @author lin.liu + */ +@Data +public class ReqModifyAdminMenus { + /** + * 主键id + */ + private Long id; + /** + * 父级id + */ + private Long parentId; + /** + * 菜单名称 + */ + private String name; + /** + * 菜单标题 + */ + private String title; + /** + * 前端资源路径 + */ + private String uri; + /** + * 菜单层级 + */ + private Integer level; + /** + * 排序值 + */ + private Integer sort; + /** + * 图标 + */ + private String icon; + /** + * 状态 EState + */ + private Integer status; +} diff --git a/src/main/java/com/fengdu/gas/entity/request/adminpermission/ReqCreateAdminPermission.java b/src/main/java/com/fengdu/gas/entity/request/adminpermission/ReqCreateAdminPermission.java new file mode 100644 index 0000000..a99bd80 --- /dev/null +++ b/src/main/java/com/fengdu/gas/entity/request/adminpermission/ReqCreateAdminPermission.java @@ -0,0 +1,58 @@ +/** +# __----~~~~~~~~~~~------___ +# . . ~~//====...... __--~ ~~ +# -. \_|// |||\\ ~~~~~~::::... /~ +# ___-==_ _-~o~ \/ ||| \\ _/~~- +# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ +# _-~~ .=~ | \\-_ '-~7 /- / || \ / +# .~ .~ | \\ -_ / /- / || \ / +# / ____ / | \\ ~-_/ /|- _/ .|| \ / +# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ +# ' ~-| /| |-~\~~ __--~~ +# |-~~-_/ | | ~\_ _-~ /\ +# / \ \__ \/~ \__ +# _--~ _/ | .-~~____--~-/ ~~==. +# ((->/~ '.|||' -_| ~~-/ , . _|| +# -_ ~\ ~~---l__i__i__i--~~_/ +# _-~-__ ~) \--______________--~~ +# //.-~~~-~_--~- |-------~~~~~~~~ +# //.-~~~--\ +# 神兽保佑 +# 永无BUG! +*/ +package com.fengdu.gas.entity.request.adminpermission; + +import lombok.Data; + +/** + * 后台用户权限表 + * @author lin.liu + * @description 后台用户权限表 + */ +@Data +public class ReqCreateAdminPermission { + /** + * 权限值 + */ + private String sn; + /** + * 菜单id + */ + private Long menuId; + /** + * 前端资源url + */ + private String menuUrl; + /** + * 名称 + */ + private String name; + /** + * 图标 + */ + private String icon; + /** + * 权限类型 EOperation + */ + private String type; +} diff --git a/src/main/java/com/fengdu/gas/entity/request/adminpermission/ReqModifyAdminPermission.java b/src/main/java/com/fengdu/gas/entity/request/adminpermission/ReqModifyAdminPermission.java new file mode 100644 index 0000000..e55e25c --- /dev/null +++ b/src/main/java/com/fengdu/gas/entity/request/adminpermission/ReqModifyAdminPermission.java @@ -0,0 +1,66 @@ +/** +# __----~~~~~~~~~~~------___ +# . . ~~//====...... __--~ ~~ +# -. \_|// |||\\ ~~~~~~::::... /~ +# ___-==_ _-~o~ \/ ||| \\ _/~~- +# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ +# _-~~ .=~ | \\-_ '-~7 /- / || \ / +# .~ .~ | \\ -_ / /- / || \ / +# / ____ / | \\ ~-_/ /|- _/ .|| \ / +# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ +# ' ~-| /| |-~\~~ __--~~ +# |-~~-_/ | | ~\_ _-~ /\ +# / \ \__ \/~ \__ +# _--~ _/ | .-~~____--~-/ ~~==. +# ((->/~ '.|||' -_| ~~-/ , . _|| +# -_ ~\ ~~---l__i__i__i--~~_/ +# _-~-__ ~) \--______________--~~ +# //.-~~~-~_--~- |-------~~~~~~~~ +# //.-~~~--\ +# 神兽保佑 +# 永无BUG! +*/ +package com.fengdu.gas.entity.request.adminpermission; + +import lombok.Data; + +/** + * 后台用户权限表 + * @author lin.liu + * @description 后台用户权限表 + */ +@Data +public class ReqModifyAdminPermission { + /** + * 主键 + */ + private Long id; + /** + * 权限值 + */ + private String sn; + /** + * 菜单id + */ + private Long menuId; + /** + * 前端资源url + */ + private String menuUrl; + /** + * 名称 + */ + private String name; + /** + * 图标 + */ + private String icon; + /** + * 权限类型 EOperation + */ + private String type; + /** + * 状态 EState + */ + private Integer status; +} diff --git a/src/main/java/com/fengdu/gas/entity/request/adminrole/ReqCreateAdminRole.java b/src/main/java/com/fengdu/gas/entity/request/adminrole/ReqCreateAdminRole.java new file mode 100644 index 0000000..bf441a4 --- /dev/null +++ b/src/main/java/com/fengdu/gas/entity/request/adminrole/ReqCreateAdminRole.java @@ -0,0 +1,46 @@ +/** +# __----~~~~~~~~~~~------___ +# . . ~~//====...... __--~ ~~ +# -. \_|// |||\\ ~~~~~~::::... /~ +# ___-==_ _-~o~ \/ ||| \\ _/~~- +# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ +# _-~~ .=~ | \\-_ '-~7 /- / || \ / +# .~ .~ | \\ -_ / /- / || \ / +# / ____ / | \\ ~-_/ /|- _/ .|| \ / +# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ +# ' ~-| /| |-~\~~ __--~~ +# |-~~-_/ | | ~\_ _-~ /\ +# / \ \__ \/~ \__ +# _--~ _/ | .-~~____--~-/ ~~==. +# ((->/~ '.|||' -_| ~~-/ , . _|| +# -_ ~\ ~~---l__i__i__i--~~_/ +# _-~-__ ~) \--______________--~~ +# //.-~~~-~_--~- |-------~~~~~~~~ +# //.-~~~--\ +# 神兽保佑 +# 永无BUG! +*/ +package com.fengdu.gas.entity.request.adminrole; + +import lombok.Data; + +/** + * 后台用户角色表 + * @author lin.liu + * @description 后台用户角色表 + */ +@Data +public class ReqCreateAdminRole { + /** + * 角色名称 + */ + private String name; + /** + * 描述 + */ + private String description; + /** + * 排序值 + */ + private Integer sort; +} diff --git a/src/main/java/com/fengdu/gas/entity/request/adminrole/ReqModifyAdminRole.java b/src/main/java/com/fengdu/gas/entity/request/adminrole/ReqModifyAdminRole.java new file mode 100644 index 0000000..b82afdd --- /dev/null +++ b/src/main/java/com/fengdu/gas/entity/request/adminrole/ReqModifyAdminRole.java @@ -0,0 +1,54 @@ +/** +# __----~~~~~~~~~~~------___ +# . . ~~//====...... __--~ ~~ +# -. \_|// |||\\ ~~~~~~::::... /~ +# ___-==_ _-~o~ \/ ||| \\ _/~~- +# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ +# _-~~ .=~ | \\-_ '-~7 /- / || \ / +# .~ .~ | \\ -_ / /- / || \ / +# / ____ / | \\ ~-_/ /|- _/ .|| \ / +# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ +# ' ~-| /| |-~\~~ __--~~ +# |-~~-_/ | | ~\_ _-~ /\ +# / \ \__ \/~ \__ +# _--~ _/ | .-~~____--~-/ ~~==. +# ((->/~ '.|||' -_| ~~-/ , . _|| +# -_ ~\ ~~---l__i__i__i--~~_/ +# _-~-__ ~) \--______________--~~ +# //.-~~~-~_--~- |-------~~~~~~~~ +# //.-~~~--\ +# 神兽保佑 +# 永无BUG! +*/ +package com.fengdu.gas.entity.request.adminrole; + +import lombok.Data; + +/** + * 后台用户角色表 + * @author lin.liu + * @description 后台用户角色表 + */ +@Data +public class ReqModifyAdminRole { + /** + * 主键 + */ + private Long id; + /** + * 角色名称 + */ + private String name; + /** + * 描述 + */ + private String description; + /** + * 状态 EState + */ + private Integer status; + /** + * 排序值 + */ + private Integer sort; +} diff --git a/src/main/java/com/fengdu/gas/entity/request/adminrolemenurelation/ReqCreateAdminRoleMenuRelation.java b/src/main/java/com/fengdu/gas/entity/request/adminrolemenurelation/ReqCreateAdminRoleMenuRelation.java new file mode 100644 index 0000000..11caa0e --- /dev/null +++ b/src/main/java/com/fengdu/gas/entity/request/adminrolemenurelation/ReqCreateAdminRoleMenuRelation.java @@ -0,0 +1,42 @@ +/** +# __----~~~~~~~~~~~------___ +# . . ~~//====...... __--~ ~~ +# -. \_|// |||\\ ~~~~~~::::... /~ +# ___-==_ _-~o~ \/ ||| \\ _/~~- +# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ +# _-~~ .=~ | \\-_ '-~7 /- / || \ / +# .~ .~ | \\ -_ / /- / || \ / +# / ____ / | \\ ~-_/ /|- _/ .|| \ / +# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ +# ' ~-| /| |-~\~~ __--~~ +# |-~~-_/ | | ~\_ _-~ /\ +# / \ \__ \/~ \__ +# _--~ _/ | .-~~____--~-/ ~~==. +# ((->/~ '.|||' -_| ~~-/ , . _|| +# -_ ~\ ~~---l__i__i__i--~~_/ +# _-~-__ ~) \--______________--~~ +# //.-~~~-~_--~- |-------~~~~~~~~ +# //.-~~~--\ +# 神兽保佑 +# 永无BUG! +*/ +package com.fengdu.gas.entity.request.adminrolemenurelation; + +import lombok.Data; + +/** + * 后台角色菜单关系表 + * @author lin.liu + * @description 后台角色菜单关系表 + */ +@Data +public class ReqCreateAdminRoleMenuRelation { + /** + * 角色id + */ + private Long roleId; + /** + * 菜单id + */ + private Long menuId; +} diff --git a/src/main/java/com/fengdu/gas/entity/request/adminrolemenurelation/ReqModifyAdminRoleMenuRelation.java b/src/main/java/com/fengdu/gas/entity/request/adminrolemenurelation/ReqModifyAdminRoleMenuRelation.java new file mode 100644 index 0000000..4fe57f2 --- /dev/null +++ b/src/main/java/com/fengdu/gas/entity/request/adminrolemenurelation/ReqModifyAdminRoleMenuRelation.java @@ -0,0 +1,46 @@ +/** +# __----~~~~~~~~~~~------___ +# . . ~~//====...... __--~ ~~ +# -. \_|// |||\\ ~~~~~~::::... /~ +# ___-==_ _-~o~ \/ ||| \\ _/~~- +# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ +# _-~~ .=~ | \\-_ '-~7 /- / || \ / +# .~ .~ | \\ -_ / /- / || \ / +# / ____ / | \\ ~-_/ /|- _/ .|| \ / +# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ +# ' ~-| /| |-~\~~ __--~~ +# |-~~-_/ | | ~\_ _-~ /\ +# / \ \__ \/~ \__ +# _--~ _/ | .-~~____--~-/ ~~==. +# ((->/~ '.|||' -_| ~~-/ , . _|| +# -_ ~\ ~~---l__i__i__i--~~_/ +# _-~-__ ~) \--______________--~~ +# //.-~~~-~_--~- |-------~~~~~~~~ +# //.-~~~--\ +# 神兽保佑 +# 永无BUG! +*/ +package com.fengdu.gas.entity.request.adminrolemenurelation; + +import lombok.Data; + +/** + * 后台角色菜单关系表 + * @author lin.liu + * @description 后台角色菜单关系表 + */ +@Data +public class ReqModifyAdminRoleMenuRelation { + /** + * 主键 + */ + private Long id; + /** + * 角色id + */ + private Long roleId; + /** + * 菜单id + */ + private Long menuId; +} diff --git a/src/main/java/com/fengdu/gas/entity/request/adminrolemenurelation/ReqSetListMenu4Role.java b/src/main/java/com/fengdu/gas/entity/request/adminrolemenurelation/ReqSetListMenu4Role.java new file mode 100644 index 0000000..1ea8614 --- /dev/null +++ b/src/main/java/com/fengdu/gas/entity/request/adminrolemenurelation/ReqSetListMenu4Role.java @@ -0,0 +1,24 @@ +package com.fengdu.gas.entity.request.adminrolemenurelation; + +import lombok.Data; + +import java.util.List; + +@Data +public class ReqSetListMenu4Role { + /** + * 角色id + * @required + */ + private Long id; + /** + * 菜单列表 + * @required + **/ + private List<Long> listMenu; + /** + * 权限列表 + * @required + **/ + private List<Long> listPermission; +} diff --git a/src/main/java/com/fengdu/gas/entity/request/adminrolemenurelation/ReqSetListRole4Admin.java b/src/main/java/com/fengdu/gas/entity/request/adminrolemenurelation/ReqSetListRole4Admin.java new file mode 100644 index 0000000..99c2588 --- /dev/null +++ b/src/main/java/com/fengdu/gas/entity/request/adminrolemenurelation/ReqSetListRole4Admin.java @@ -0,0 +1,19 @@ +package com.fengdu.gas.entity.request.adminrolemenurelation; + +import lombok.Data; + +import java.util.List; + +@Data +public class ReqSetListRole4Admin { + /** + * 管理员id + * @required + */ + private Long id; + /** + * 角色列表 + * @required + **/ + private List<Long> listRole; +} diff --git a/src/main/java/com/fengdu/gas/entity/request/adminrolepermissionrelation/ReqCreateAdminRolePermissionRelation.java b/src/main/java/com/fengdu/gas/entity/request/adminrolepermissionrelation/ReqCreateAdminRolePermissionRelation.java new file mode 100644 index 0000000..4d9f353 --- /dev/null +++ b/src/main/java/com/fengdu/gas/entity/request/adminrolepermissionrelation/ReqCreateAdminRolePermissionRelation.java @@ -0,0 +1,42 @@ +/** +# __----~~~~~~~~~~~------___ +# . . ~~//====...... __--~ ~~ +# -. \_|// |||\\ ~~~~~~::::... /~ +# ___-==_ _-~o~ \/ ||| \\ _/~~- +# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ +# _-~~ .=~ | \\-_ '-~7 /- / || \ / +# .~ .~ | \\ -_ / /- / || \ / +# / ____ / | \\ ~-_/ /|- _/ .|| \ / +# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ +# ' ~-| /| |-~\~~ __--~~ +# |-~~-_/ | | ~\_ _-~ /\ +# / \ \__ \/~ \__ +# _--~ _/ | .-~~____--~-/ ~~==. +# ((->/~ '.|||' -_| ~~-/ , . _|| +# -_ ~\ ~~---l__i__i__i--~~_/ +# _-~-__ ~) \--______________--~~ +# //.-~~~-~_--~- |-------~~~~~~~~ +# //.-~~~--\ +# 神兽保佑 +# 永无BUG! +*/ +package com.fengdu.gas.entity.request.adminrolepermissionrelation; + +import lombok.Data; + +/** + * 后台角色权限关系表 + * @author lin.liu + * @description 后台角色权限关系表 + */ +@Data +public class ReqCreateAdminRolePermissionRelation { + /** + * 角色id + */ + private Long roleId; + /** + * 权限id + */ + private Long permissionId; +} diff --git a/src/main/java/com/fengdu/gas/entity/request/adminrolepermissionrelation/ReqModifyAdminRolePermissionRelation.java b/src/main/java/com/fengdu/gas/entity/request/adminrolepermissionrelation/ReqModifyAdminRolePermissionRelation.java new file mode 100644 index 0000000..652fc83 --- /dev/null +++ b/src/main/java/com/fengdu/gas/entity/request/adminrolepermissionrelation/ReqModifyAdminRolePermissionRelation.java @@ -0,0 +1,46 @@ +/** +# __----~~~~~~~~~~~------___ +# . . ~~//====...... __--~ ~~ +# -. \_|// |||\\ ~~~~~~::::... /~ +# ___-==_ _-~o~ \/ ||| \\ _/~~- +# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ +# _-~~ .=~ | \\-_ '-~7 /- / || \ / +# .~ .~ | \\ -_ / /- / || \ / +# / ____ / | \\ ~-_/ /|- _/ .|| \ / +# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ +# ' ~-| /| |-~\~~ __--~~ +# |-~~-_/ | | ~\_ _-~ /\ +# / \ \__ \/~ \__ +# _--~ _/ | .-~~____--~-/ ~~==. +# ((->/~ '.|||' -_| ~~-/ , . _|| +# -_ ~\ ~~---l__i__i__i--~~_/ +# _-~-__ ~) \--______________--~~ +# //.-~~~-~_--~- |-------~~~~~~~~ +# //.-~~~--\ +# 神兽保佑 +# 永无BUG! +*/ +package com.fengdu.gas.entity.request.adminrolepermissionrelation; + +import lombok.Data; + +/** + * 后台角色权限关系表 + * @author lin.liu + * @description 后台角色权限关系表 + */ +@Data +public class ReqModifyAdminRolePermissionRelation { + /** + * 主键 + */ + private Long id; + /** + * 角色id + */ + private Long roleId; + /** + * 权限id + */ + private Long permissionId; +} diff --git a/src/main/java/com/fengdu/gas/entity/request/adminrolerelation/ReqCreateAdminRoleRelation.java b/src/main/java/com/fengdu/gas/entity/request/adminrolerelation/ReqCreateAdminRoleRelation.java new file mode 100644 index 0000000..254a7fc --- /dev/null +++ b/src/main/java/com/fengdu/gas/entity/request/adminrolerelation/ReqCreateAdminRoleRelation.java @@ -0,0 +1,42 @@ +/** +# __----~~~~~~~~~~~------___ +# . . ~~//====...... __--~ ~~ +# -. \_|// |||\\ ~~~~~~::::... /~ +# ___-==_ _-~o~ \/ ||| \\ _/~~- +# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ +# _-~~ .=~ | \\-_ '-~7 /- / || \ / +# .~ .~ | \\ -_ / /- / || \ / +# / ____ / | \\ ~-_/ /|- _/ .|| \ / +# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ +# ' ~-| /| |-~\~~ __--~~ +# |-~~-_/ | | ~\_ _-~ /\ +# / \ \__ \/~ \__ +# _--~ _/ | .-~~____--~-/ ~~==. +# ((->/~ '.|||' -_| ~~-/ , . _|| +# -_ ~\ ~~---l__i__i__i--~~_/ +# _-~-__ ~) \--______________--~~ +# //.-~~~-~_--~- |-------~~~~~~~~ +# //.-~~~--\ +# 神兽保佑 +# 永无BUG! +*/ +package com.fengdu.gas.entity.request.adminrolerelation; + +import lombok.Data; + +/** + * 后台用户和角色关系表 + * @author lin.liu + * @description 后台用户和角色关系表 + */ +@Data +public class ReqCreateAdminRoleRelation { + /** + * 管理员id + */ + private Long adminId; + /** + * 角色id + */ + private Long roleId; +} diff --git a/src/main/java/com/fengdu/gas/entity/request/adminrolerelation/ReqModifyAdminRoleRelation.java b/src/main/java/com/fengdu/gas/entity/request/adminrolerelation/ReqModifyAdminRoleRelation.java new file mode 100644 index 0000000..9ad543e --- /dev/null +++ b/src/main/java/com/fengdu/gas/entity/request/adminrolerelation/ReqModifyAdminRoleRelation.java @@ -0,0 +1,46 @@ +/** +# __----~~~~~~~~~~~------___ +# . . ~~//====...... __--~ ~~ +# -. \_|// |||\\ ~~~~~~::::... /~ +# ___-==_ _-~o~ \/ ||| \\ _/~~- +# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ +# _-~~ .=~ | \\-_ '-~7 /- / || \ / +# .~ .~ | \\ -_ / /- / || \ / +# / ____ / | \\ ~-_/ /|- _/ .|| \ / +# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ +# ' ~-| /| |-~\~~ __--~~ +# |-~~-_/ | | ~\_ _-~ /\ +# / \ \__ \/~ \__ +# _--~ _/ | .-~~____--~-/ ~~==. +# ((->/~ '.|||' -_| ~~-/ , . _|| +# -_ ~\ ~~---l__i__i__i--~~_/ +# _-~-__ ~) \--______________--~~ +# //.-~~~-~_--~- |-------~~~~~~~~ +# //.-~~~--\ +# 神兽保佑 +# 永无BUG! +*/ +package com.fengdu.gas.entity.request.adminrolerelation; + +import lombok.Data; + +/** + * 后台用户和角色关系表 + * @author lin.liu + * @description 后台用户和角色关系表 + */ +@Data +public class ReqModifyAdminRoleRelation { + /** + * 主键 + */ + private Long id; + /** + * 管理员id + */ + private Long adminId; + /** + * 角色id + */ + private Long roleId; +} diff --git a/src/main/java/com/fengdu/gas/entity/request/adminuser/ReqAdminLogin.java b/src/main/java/com/fengdu/gas/entity/request/adminuser/ReqAdminLogin.java new file mode 100644 index 0000000..370c23b --- /dev/null +++ b/src/main/java/com/fengdu/gas/entity/request/adminuser/ReqAdminLogin.java @@ -0,0 +1,17 @@ +package com.fengdu.gas.entity.request.adminuser; + +import lombok.Data; + +@Data +public class ReqAdminLogin { + /** + * 登录账户 + * @required + */ + private String userName; + /** + * 密码 + * @required + */ + private String password; +} diff --git a/src/main/java/com/fengdu/gas/entity/request/adminuser/ReqCreateAdminUser.java b/src/main/java/com/fengdu/gas/entity/request/adminuser/ReqCreateAdminUser.java new file mode 100644 index 0000000..bc57f2a --- /dev/null +++ b/src/main/java/com/fengdu/gas/entity/request/adminuser/ReqCreateAdminUser.java @@ -0,0 +1,62 @@ +/** +# __----~~~~~~~~~~~------___ +# . . ~~//====...... __--~ ~~ +# -. \_|// |||\\ ~~~~~~::::... /~ +# ___-==_ _-~o~ \/ ||| \\ _/~~- +# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ +# _-~~ .=~ | \\-_ '-~7 /- / || \ / +# .~ .~ | \\ -_ / /- / || \ / +# / ____ / | \\ ~-_/ /|- _/ .|| \ / +# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ +# ' ~-| /| |-~\~~ __--~~ +# |-~~-_/ | | ~\_ _-~ /\ +# / \ \__ \/~ \__ +# _--~ _/ | .-~~____--~-/ ~~==. +# ((->/~ '.|||' -_| ~~-/ , . _|| +# -_ ~\ ~~---l__i__i__i--~~_/ +# _-~-__ ~) \--______________--~~ +# //.-~~~-~_--~- |-------~~~~~~~~ +# //.-~~~--\ +# 神兽保佑 +# 永无BUG! +*/ +package com.fengdu.gas.entity.request.adminuser; + +import lombok.Data; + +/** + * 管理员帐号 + * @author lin.liu + * @description 管理员帐号 + */ +@Data +public class ReqCreateAdminUser { + /** + * 用户类型 EUserType + */ + private Integer userType; + /** + * 用户名 + */ + private String userName; + /** + * 密码 + */ + private String password; + /** + * 昵称 + */ + private String nickName; + /** + * 头像 + */ + private String headImg; + /** + * 联系方式 + */ + private String contact; + /** + * 联系邮箱 + */ + private String email; +} diff --git a/src/main/java/com/fengdu/gas/entity/request/adminuser/ReqModifyAdminUser.java b/src/main/java/com/fengdu/gas/entity/request/adminuser/ReqModifyAdminUser.java new file mode 100644 index 0000000..8d32f9c --- /dev/null +++ b/src/main/java/com/fengdu/gas/entity/request/adminuser/ReqModifyAdminUser.java @@ -0,0 +1,62 @@ +/** +# __----~~~~~~~~~~~------___ +# . . ~~//====...... __--~ ~~ +# -. \_|// |||\\ ~~~~~~::::... /~ +# ___-==_ _-~o~ \/ ||| \\ _/~~- +# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ +# _-~~ .=~ | \\-_ '-~7 /- / || \ / +# .~ .~ | \\ -_ / /- / || \ / +# / ____ / | \\ ~-_/ /|- _/ .|| \ / +# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ +# ' ~-| /| |-~\~~ __--~~ +# |-~~-_/ | | ~\_ _-~ /\ +# / \ \__ \/~ \__ +# _--~ _/ | .-~~____--~-/ ~~==. +# ((->/~ '.|||' -_| ~~-/ , . _|| +# -_ ~\ ~~---l__i__i__i--~~_/ +# _-~-__ ~) \--______________--~~ +# //.-~~~-~_--~- |-------~~~~~~~~ +# //.-~~~--\ +# 神兽保佑 +# 永无BUG! +*/ +package com.fengdu.gas.entity.request.adminuser; + +import lombok.Data; + +/** + * 管理员帐号 + * @author lin.liu + * @description 管理员帐号 + */ +@Data +public class ReqModifyAdminUser { + /** + * 主键 + */ + private Long id; + /** + * 用户类型 EUserType + */ + private Integer userType; + /** + * 昵称 + */ + private String nickName; + /** + * 头像 + */ + private String headImg; + /** + * 联系方式 + */ + private String contact; + /** + * 联系邮箱 + */ + private String email; + /** + * 状态 EState + */ + private Integer status; +} diff --git a/src/main/java/com/fengdu/gas/entity/request/adminuser/ReqSetListRole4Admin.java b/src/main/java/com/fengdu/gas/entity/request/adminuser/ReqSetListRole4Admin.java new file mode 100644 index 0000000..20bc2bd --- /dev/null +++ b/src/main/java/com/fengdu/gas/entity/request/adminuser/ReqSetListRole4Admin.java @@ -0,0 +1,19 @@ +package com.fengdu.gas.entity.request.adminuser; + +import lombok.Data; + +import java.util.List; + +@Data +public class ReqSetListRole4Admin { + /** + * 管理员id + * @required + */ + private Long id; + /** + * 角色列表 + * @required + **/ + private List<Long> listRole; +} diff --git a/src/main/java/com/fengdu/gas/entity/request/notice/ReqCreateNotice.java b/src/main/java/com/fengdu/gas/entity/request/notice/ReqCreateNotice.java new file mode 100644 index 0000000..671650d --- /dev/null +++ b/src/main/java/com/fengdu/gas/entity/request/notice/ReqCreateNotice.java @@ -0,0 +1,53 @@ +/** +# __----~~~~~~~~~~~------___ +# . . ~~//====...... __--~ ~~ +# -. \_|// |||\\ ~~~~~~::::... /~ +# ___-==_ _-~o~ \/ ||| \\ _/~~- +# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ +# _-~~ .=~ | \\-_ '-~7 /- / || \ / +# .~ .~ | \\ -_ / /- / || \ / +# / ____ / | \\ ~-_/ /|- _/ .|| \ / +# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ +# ' ~-| /| |-~\~~ __--~~ +# |-~~-_/ | | ~\_ _-~ /\ +# / \ \__ \/~ \__ +# _--~ _/ | .-~~____--~-/ ~~==. +# ((->/~ '.|||' -_| ~~-/ , . _|| +# -_ ~\ ~~---l__i__i__i--~~_/ +# _-~-__ ~) \--______________--~~ +# //.-~~~-~_--~- |-------~~~~~~~~ +# //.-~~~--\ +# 神兽保佑 +# 永无BUG! +*/ +package com.fengdu.gas.entity.request.notice; + +import lombok.Data; + +/** + * 公告 + * @author lin.liu + */ +@Data +public class ReqCreateNotice { + /** + * 发布人 + */ + private String publishUser; + /** + * 标题 + */ + private String title; + /** + * 摘要 + */ + private String summary; + /** + * 内容 + */ + private String content; + /** + * 排序 + */ + private Integer sort; +} diff --git a/src/main/java/com/fengdu/gas/entity/request/notice/ReqModifyNotice.java b/src/main/java/com/fengdu/gas/entity/request/notice/ReqModifyNotice.java new file mode 100644 index 0000000..0d7cb32 --- /dev/null +++ b/src/main/java/com/fengdu/gas/entity/request/notice/ReqModifyNotice.java @@ -0,0 +1,61 @@ +/** +# __----~~~~~~~~~~~------___ +# . . ~~//====...... __--~ ~~ +# -. \_|// |||\\ ~~~~~~::::... /~ +# ___-==_ _-~o~ \/ ||| \\ _/~~- +# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ +# _-~~ .=~ | \\-_ '-~7 /- / || \ / +# .~ .~ | \\ -_ / /- / || \ / +# / ____ / | \\ ~-_/ /|- _/ .|| \ / +# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ +# ' ~-| /| |-~\~~ __--~~ +# |-~~-_/ | | ~\_ _-~ /\ +# / \ \__ \/~ \__ +# _--~ _/ | .-~~____--~-/ ~~==. +# ((->/~ '.|||' -_| ~~-/ , . _|| +# -_ ~\ ~~---l__i__i__i--~~_/ +# _-~-__ ~) \--______________--~~ +# //.-~~~-~_--~- |-------~~~~~~~~ +# //.-~~~--\ +# 神兽保佑 +# 永无BUG! +*/ +package com.fengdu.gas.entity.request.notice; + +import lombok.Data; + +/** + * 公告 + * @author lin.liu + */ +@Data +public class ReqModifyNotice { + /** + * 主键 + */ + private Long id; + /** + * 发布人 + */ + private String publishUser; + /** + * 标题 + */ + private String title; + /** + * 摘要 + */ + private String summary; + /** + * 内容 + */ + private String content; + /** + * 排序 + */ + private Integer sort; + /** + * 状态(EState) + */ + private Integer status; +} diff --git a/src/main/java/com/fengdu/gas/entity/request/quartztaskerror/ReqCreateQuartzTaskError.java b/src/main/java/com/fengdu/gas/entity/request/quartztaskerror/ReqCreateQuartzTaskError.java new file mode 100644 index 0000000..e875fc3 --- /dev/null +++ b/src/main/java/com/fengdu/gas/entity/request/quartztaskerror/ReqCreateQuartzTaskError.java @@ -0,0 +1,46 @@ +/** +# __----~~~~~~~~~~~------___ +# . . ~~//====...... __--~ ~~ +# -. \_|// |||\\ ~~~~~~::::... /~ +# ___-==_ _-~o~ \/ ||| \\ _/~~- +# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ +# _-~~ .=~ | \\-_ '-~7 /- / || \ / +# .~ .~ | \\ -_ / /- / || \ / +# / ____ / | \\ ~-_/ /|- _/ .|| \ / +# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ +# ' ~-| /| |-~\~~ __--~~ +# |-~~-_/ | | ~\_ _-~ /\ +# / \ \__ \/~ \__ +# _--~ _/ | .-~~____--~-/ ~~==. +# ((->/~ '.|||' -_| ~~-/ , . _|| +# -_ ~\ ~~---l__i__i__i--~~_/ +# _-~-__ ~) \--______________--~~ +# //.-~~~-~_--~- |-------~~~~~~~~ +# //.-~~~--\ +# 神兽保佑 +# 永无BUG! +*/ +package com.fengdu.gas.entity.request.quartztaskerror; + +import lombok.Data; + +/** + * 定时任务错误信息表 + * @author lin.liu + * @description 定时任务错误信息表 + */ +@Data +public class ReqCreateQuartzTaskError { + /** + * 任务执行记录Id + */ + private String taskExecuteRecordId; + /** + * 任务执行记录Id + */ + private String errorKey; + /** + * 任务执行记录Id + */ + private String errorValue; +} diff --git a/src/main/java/com/fengdu/gas/entity/request/quartztaskerror/ReqModifyQuartzTaskError.java b/src/main/java/com/fengdu/gas/entity/request/quartztaskerror/ReqModifyQuartzTaskError.java new file mode 100644 index 0000000..2ce9bd9 --- /dev/null +++ b/src/main/java/com/fengdu/gas/entity/request/quartztaskerror/ReqModifyQuartzTaskError.java @@ -0,0 +1,50 @@ +/** +# __----~~~~~~~~~~~------___ +# . . ~~//====...... __--~ ~~ +# -. \_|// |||\\ ~~~~~~::::... /~ +# ___-==_ _-~o~ \/ ||| \\ _/~~- +# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ +# _-~~ .=~ | \\-_ '-~7 /- / || \ / +# .~ .~ | \\ -_ / /- / || \ / +# / ____ / | \\ ~-_/ /|- _/ .|| \ / +# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ +# ' ~-| /| |-~\~~ __--~~ +# |-~~-_/ | | ~\_ _-~ /\ +# / \ \__ \/~ \__ +# _--~ _/ | .-~~____--~-/ ~~==. +# ((->/~ '.|||' -_| ~~-/ , . _|| +# -_ ~\ ~~---l__i__i__i--~~_/ +# _-~-__ ~) \--______________--~~ +# //.-~~~-~_--~- |-------~~~~~~~~ +# //.-~~~--\ +# 神兽保佑 +# 永无BUG! +*/ +package com.fengdu.gas.entity.request.quartztaskerror; + +import lombok.Data; + +/** + * 定时任务错误信息表 + * @author lin.liu + * @description 定时任务错误信息表 + */ +@Data +public class ReqModifyQuartzTaskError { + /** + * 主键 + */ + private Long id; + /** + * 任务执行记录Id + */ + private String taskExecuteRecordId; + /** + * 任务执行记录Id + */ + private String errorKey; + /** + * 任务执行记录Id + */ + private String errorValue; +} diff --git a/src/main/java/com/fengdu/gas/entity/request/quartztaskinfo/ReqCreateQuartzTaskInfo.java b/src/main/java/com/fengdu/gas/entity/request/quartztaskinfo/ReqCreateQuartzTaskInfo.java new file mode 100644 index 0000000..4d8a305 --- /dev/null +++ b/src/main/java/com/fengdu/gas/entity/request/quartztaskinfo/ReqCreateQuartzTaskInfo.java @@ -0,0 +1,58 @@ +/** +# __----~~~~~~~~~~~------___ +# . . ~~//====...... __--~ ~~ +# -. \_|// |||\\ ~~~~~~::::... /~ +# ___-==_ _-~o~ \/ ||| \\ _/~~- +# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ +# _-~~ .=~ | \\-_ '-~7 /- / || \ / +# .~ .~ | \\ -_ / /- / || \ / +# / ____ / | \\ ~-_/ /|- _/ .|| \ / +# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ +# ' ~-| /| |-~\~~ __--~~ +# |-~~-_/ | | ~\_ _-~ /\ +# / \ \__ \/~ \__ +# _--~ _/ | .-~~____--~-/ ~~==. +# ((->/~ '.|||' -_| ~~-/ , . _|| +# -_ ~\ ~~---l__i__i__i--~~_/ +# _-~-__ ~) \--______________--~~ +# //.-~~~-~_--~- |-------~~~~~~~~ +# //.-~~~--\ +# 神兽保佑 +# 永无BUG! +*/ +package com.fengdu.gas.entity.request.quartztaskinfo; + +import lombok.Data; + +/** + * 定时任务信息表 + * @author lin.liu + * @description 定时任务信息表 + */ +@Data +public class ReqCreateQuartzTaskInfo { + /** + * 任务名称 + */ + private String taskName; + /** + * 定时规则表达式 + */ + private String schedulerRule; + /** + * 执行方 + */ + private String executor; + /** + * 执行参数 + */ + private String executeParameter; + /** + * 执行结果发送方式 + */ + private String sendType; + /** + * 执行结果发送请求地址 + */ + private String url; +} diff --git a/src/main/java/com/fengdu/gas/entity/request/quartztaskinfo/ReqModifyQuartzTaskInfo.java b/src/main/java/com/fengdu/gas/entity/request/quartztaskinfo/ReqModifyQuartzTaskInfo.java new file mode 100644 index 0000000..ed83eca --- /dev/null +++ b/src/main/java/com/fengdu/gas/entity/request/quartztaskinfo/ReqModifyQuartzTaskInfo.java @@ -0,0 +1,66 @@ +/** +# __----~~~~~~~~~~~------___ +# . . ~~//====...... __--~ ~~ +# -. \_|// |||\\ ~~~~~~::::... /~ +# ___-==_ _-~o~ \/ ||| \\ _/~~- +# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ +# _-~~ .=~ | \\-_ '-~7 /- / || \ / +# .~ .~ | \\ -_ / /- / || \ / +# / ____ / | \\ ~-_/ /|- _/ .|| \ / +# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ +# ' ~-| /| |-~\~~ __--~~ +# |-~~-_/ | | ~\_ _-~ /\ +# / \ \__ \/~ \__ +# _--~ _/ | .-~~____--~-/ ~~==. +# ((->/~ '.|||' -_| ~~-/ , . _|| +# -_ ~\ ~~---l__i__i__i--~~_/ +# _-~-__ ~) \--______________--~~ +# //.-~~~-~_--~- |-------~~~~~~~~ +# //.-~~~--\ +# 神兽保佑 +# 永无BUG! +*/ +package com.fengdu.gas.entity.request.quartztaskinfo; + +import lombok.Data; + +/** + * 定时任务信息表 + * @author lin.liu + * @description 定时任务信息表 + */ +@Data +public class ReqModifyQuartzTaskInfo { + /** + * 主键 + */ + private Long id; + /** + * 任务名称 + */ + private String taskName; + /** + * 定时规则表达式 + */ + private String schedulerRule; + /** + * 执行方 + */ + private String executor; + /** + * 执行参数 + */ + private String executeParameter; + /** + * 任务状态 EState + */ + private Integer status; + /** + * 执行结果发送方式 + */ + private String sendType; + /** + * 执行结果发送请求地址 + */ + private String url; +} diff --git a/src/main/java/com/fengdu/gas/entity/request/quartztaskinfo/ReqRunTaskRightNow.java b/src/main/java/com/fengdu/gas/entity/request/quartztaskinfo/ReqRunTaskRightNow.java new file mode 100644 index 0000000..d01b325 --- /dev/null +++ b/src/main/java/com/fengdu/gas/entity/request/quartztaskinfo/ReqRunTaskRightNow.java @@ -0,0 +1,15 @@ +package com.fengdu.gas.entity.request.quartztaskinfo; + +import lombok.Data; + +@Data +public class ReqRunTaskRightNow { + /** + * 任务id + */ + private Long id; + /** + * 执行参数 + */ + private String executeParameter; +} diff --git a/src/main/java/com/fengdu/gas/entity/request/quartztaskrecord/ReqCreateQuartzTaskRecord.java b/src/main/java/com/fengdu/gas/entity/request/quartztaskrecord/ReqCreateQuartzTaskRecord.java new file mode 100644 index 0000000..1dab0ad --- /dev/null +++ b/src/main/java/com/fengdu/gas/entity/request/quartztaskrecord/ReqCreateQuartzTaskRecord.java @@ -0,0 +1,58 @@ +/** +# __----~~~~~~~~~~~------___ +# . . ~~//====...... __--~ ~~ +# -. \_|// |||\\ ~~~~~~::::... /~ +# ___-==_ _-~o~ \/ ||| \\ _/~~- +# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ +# _-~~ .=~ | \\-_ '-~7 /- / || \ / +# .~ .~ | \\ -_ / /- / || \ / +# / ____ / | \\ ~-_/ /|- _/ .|| \ / +# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ +# ' ~-| /| |-~\~~ __--~~ +# |-~~-_/ | | ~\_ _-~ /\ +# / \ \__ \/~ \__ +# _--~ _/ | .-~~____--~-/ ~~==. +# ((->/~ '.|||' -_| ~~-/ , . _|| +# -_ ~\ ~~---l__i__i__i--~~_/ +# _-~-__ ~) \--______________--~~ +# //.-~~~-~_--~- |-------~~~~~~~~ +# //.-~~~--\ +# 神兽保佑 +# 永无BUG! +*/ +package com.fengdu.gas.entity.request.quartztaskrecord; + +import lombok.Data; + +/** + * 定时任务执行情况记录表 + * @author lin.liu + * @description 定时任务执行情况记录表 + */ +@Data +public class ReqCreateQuartzTaskRecord { + /** + * 任务编号 + */ + private String taskNo; + /** + * 执行时间格式值 + */ + private String timeKeyValue; + /** + * 执行时间 + */ + private Long executeTime; + /** + * 任务状态 + */ + private String taskStatus; + /** + * 失败统计数 + */ + private Long failCount; + /** + * 失败错误描述 + */ + private String failReason; +} diff --git a/src/main/java/com/fengdu/gas/entity/request/quartztaskrecord/ReqModifyQuartzTaskRecord.java b/src/main/java/com/fengdu/gas/entity/request/quartztaskrecord/ReqModifyQuartzTaskRecord.java new file mode 100644 index 0000000..c19ca51 --- /dev/null +++ b/src/main/java/com/fengdu/gas/entity/request/quartztaskrecord/ReqModifyQuartzTaskRecord.java @@ -0,0 +1,62 @@ +/** +# __----~~~~~~~~~~~------___ +# . . ~~//====...... __--~ ~~ +# -. \_|// |||\\ ~~~~~~::::... /~ +# ___-==_ _-~o~ \/ ||| \\ _/~~- +# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ +# _-~~ .=~ | \\-_ '-~7 /- / || \ / +# .~ .~ | \\ -_ / /- / || \ / +# / ____ / | \\ ~-_/ /|- _/ .|| \ / +# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ +# ' ~-| /| |-~\~~ __--~~ +# |-~~-_/ | | ~\_ _-~ /\ +# / \ \__ \/~ \__ +# _--~ _/ | .-~~____--~-/ ~~==. +# ((->/~ '.|||' -_| ~~-/ , . _|| +# -_ ~\ ~~---l__i__i__i--~~_/ +# _-~-__ ~) \--______________--~~ +# //.-~~~-~_--~- |-------~~~~~~~~ +# //.-~~~--\ +# 神兽保佑 +# 永无BUG! +*/ +package com.fengdu.gas.entity.request.quartztaskrecord; + +import lombok.Data; + +/** + * 定时任务执行情况记录表 + * @author lin.liu + * @description 定时任务执行情况记录表 + */ +@Data +public class ReqModifyQuartzTaskRecord { + /** + * 主键 + */ + private Long id; + /** + * 任务编号 + */ + private String taskNo; + /** + * 执行时间格式值 + */ + private String timeKeyValue; + /** + * 执行时间 + */ + private Long executeTime; + /** + * 任务状态 + */ + private String taskStatus; + /** + * 失败统计数 + */ + private Long failCount; + /** + * 失败错误描述 + */ + private String failReason; +} diff --git a/src/main/java/com/fengdu/gas/entity/request/sysdictdata/ReqCreateSysDictData.java b/src/main/java/com/fengdu/gas/entity/request/sysdictdata/ReqCreateSysDictData.java new file mode 100644 index 0000000..ec16f86 --- /dev/null +++ b/src/main/java/com/fengdu/gas/entity/request/sysdictdata/ReqCreateSysDictData.java @@ -0,0 +1,50 @@ +/** +# __----~~~~~~~~~~~------___ +# . . ~~//====...... __--~ ~~ +# -. \_|// |||\\ ~~~~~~::::... /~ +# ___-==_ _-~o~ \/ ||| \\ _/~~- +# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ +# _-~~ .=~ | \\-_ '-~7 /- / || \ / +# .~ .~ | \\ -_ / /- / || \ / +# / ____ / | \\ ~-_/ /|- _/ .|| \ / +# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ +# ' ~-| /| |-~\~~ __--~~ +# |-~~-_/ | | ~\_ _-~ /\ +# / \ \__ \/~ \__ +# _--~ _/ | .-~~____--~-/ ~~==. +# ((->/~ '.|||' -_| ~~-/ , . _|| +# -_ ~\ ~~---l__i__i__i--~~_/ +# _-~-__ ~) \--______________--~~ +# //.-~~~-~_--~- |-------~~~~~~~~ +# //.-~~~--\ +# 神兽保佑 +# 永无BUG! +*/ +package com.fengdu.gas.entity.request.sysdictdata; + +import lombok.Data; + +/** + * 字典数据表 + * @author lin.liu + * @description 字典数据表 + */ +@Data +public class ReqCreateSysDictData { + /** + * 字典类型 + */ + private String dictType; + /** + * 字典标题 + */ + private String dictLabel; + /** + * 字典键值 + */ + private String dictValue; + /** + * 备注 + */ + private String remark; +} diff --git a/src/main/java/com/fengdu/gas/entity/request/sysdictdata/ReqModifySysDictData.java b/src/main/java/com/fengdu/gas/entity/request/sysdictdata/ReqModifySysDictData.java new file mode 100644 index 0000000..67ad964 --- /dev/null +++ b/src/main/java/com/fengdu/gas/entity/request/sysdictdata/ReqModifySysDictData.java @@ -0,0 +1,54 @@ +/** +# __----~~~~~~~~~~~------___ +# . . ~~//====...... __--~ ~~ +# -. \_|// |||\\ ~~~~~~::::... /~ +# ___-==_ _-~o~ \/ ||| \\ _/~~- +# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ +# _-~~ .=~ | \\-_ '-~7 /- / || \ / +# .~ .~ | \\ -_ / /- / || \ / +# / ____ / | \\ ~-_/ /|- _/ .|| \ / +# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ +# ' ~-| /| |-~\~~ __--~~ +# |-~~-_/ | | ~\_ _-~ /\ +# / \ \__ \/~ \__ +# _--~ _/ | .-~~____--~-/ ~~==. +# ((->/~ '.|||' -_| ~~-/ , . _|| +# -_ ~\ ~~---l__i__i__i--~~_/ +# _-~-__ ~) \--______________--~~ +# //.-~~~-~_--~- |-------~~~~~~~~ +# //.-~~~--\ +# 神兽保佑 +# 永无BUG! +*/ +package com.fengdu.gas.entity.request.sysdictdata; + +import lombok.Data; + +/** + * 字典数据表 + * @author lin.liu + * @description 字典数据表 + */ +@Data +public class ReqModifySysDictData { + /** + * 主键 + */ + private Long id; + /** + * 字典标题 + */ + private String dictLabel; + /** + * 字典键值 + */ + private String dictValue; + /** + * 状态 + */ + private Integer status; + /** + * 备注 + */ + private String remark; +} diff --git a/src/main/java/com/fengdu/gas/entity/request/sysdicttype/ReqCreateSysDictType.java b/src/main/java/com/fengdu/gas/entity/request/sysdicttype/ReqCreateSysDictType.java new file mode 100644 index 0000000..b5c6018 --- /dev/null +++ b/src/main/java/com/fengdu/gas/entity/request/sysdicttype/ReqCreateSysDictType.java @@ -0,0 +1,46 @@ +/** +# __----~~~~~~~~~~~------___ +# . . ~~//====...... __--~ ~~ +# -. \_|// |||\\ ~~~~~~::::... /~ +# ___-==_ _-~o~ \/ ||| \\ _/~~- +# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ +# _-~~ .=~ | \\-_ '-~7 /- / || \ / +# .~ .~ | \\ -_ / /- / || \ / +# / ____ / | \\ ~-_/ /|- _/ .|| \ / +# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ +# ' ~-| /| |-~\~~ __--~~ +# |-~~-_/ | | ~\_ _-~ /\ +# / \ \__ \/~ \__ +# _--~ _/ | .-~~____--~-/ ~~==. +# ((->/~ '.|||' -_| ~~-/ , . _|| +# -_ ~\ ~~---l__i__i__i--~~_/ +# _-~-__ ~) \--______________--~~ +# //.-~~~-~_--~- |-------~~~~~~~~ +# //.-~~~--\ +# 神兽保佑 +# 永无BUG! +*/ +package com.fengdu.gas.entity.request.sysdicttype; + +import lombok.Data; + +/** + * 字典类型表 + * @author lin.liu + * @description 字典类型表 + */ +@Data +public class ReqCreateSysDictType { + /** + * 字典类型 + */ + private String dictType; + /** + * 字典名称 + */ + private String dictName; + /** + * 备注 + */ + private String remark; +} diff --git a/src/main/java/com/fengdu/gas/entity/request/sysdicttype/ReqModifySysDictType.java b/src/main/java/com/fengdu/gas/entity/request/sysdicttype/ReqModifySysDictType.java new file mode 100644 index 0000000..ed3069d --- /dev/null +++ b/src/main/java/com/fengdu/gas/entity/request/sysdicttype/ReqModifySysDictType.java @@ -0,0 +1,50 @@ +/** +# __----~~~~~~~~~~~------___ +# . . ~~//====...... __--~ ~~ +# -. \_|// |||\\ ~~~~~~::::... /~ +# ___-==_ _-~o~ \/ ||| \\ _/~~- +# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ +# _-~~ .=~ | \\-_ '-~7 /- / || \ / +# .~ .~ | \\ -_ / /- / || \ / +# / ____ / | \\ ~-_/ /|- _/ .|| \ / +# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ +# ' ~-| /| |-~\~~ __--~~ +# |-~~-_/ | | ~\_ _-~ /\ +# / \ \__ \/~ \__ +# _--~ _/ | .-~~____--~-/ ~~==. +# ((->/~ '.|||' -_| ~~-/ , . _|| +# -_ ~\ ~~---l__i__i__i--~~_/ +# _-~-__ ~) \--______________--~~ +# //.-~~~-~_--~- |-------~~~~~~~~ +# //.-~~~--\ +# 神兽保佑 +# 永无BUG! +*/ +package com.fengdu.gas.entity.request.sysdicttype; + +import lombok.Data; + +/** + * 字典类型表 + * @author lin.liu + * @description 字典类型表 + */ +@Data +public class ReqModifySysDictType { + /** + * 主键 + */ + private Long id; + /** + * 字典名称 + */ + private String dictName; + /** + * 状态 EState + */ + private Integer status; + /** + * 备注 + */ + private String remark; +} diff --git a/src/main/java/com/fengdu/gas/entity/request/test/ReqCreateTestInfo.java b/src/main/java/com/fengdu/gas/entity/request/test/ReqCreateTestInfo.java new file mode 100644 index 0000000..c8cf372 --- /dev/null +++ b/src/main/java/com/fengdu/gas/entity/request/test/ReqCreateTestInfo.java @@ -0,0 +1,102 @@ +package com.fengdu.gas.entity.request.test; + +import java.math.BigDecimal; + +public class ReqCreateTestInfo { + /** + * 名称 + */ + private String name; + /** + * 用户id + */ + private Long userId; + /** + * 电话 + */ + private String phone; + /** + * 余额 + */ + private BigDecimal balance; + /** + * 性别 ESex + */ + private Integer sex; + /** + * 生日 + */ + private String birthday; + /** + * 排序值 + */ + private Integer sort; + /** + * 备注 + */ + private String comment; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Long getUserId() { + return userId; + } + + public void setUserId(Long userId) { + this.userId = userId; + } + + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + + public BigDecimal getBalance() { + return balance; + } + + public void setBalance(BigDecimal balance) { + this.balance = balance; + } + + public Integer getSex() { + return sex; + } + + public void setSex(Integer sex) { + this.sex = sex; + } + + public String getBirthday() { + return birthday; + } + + public void setBirthday(String birthday) { + this.birthday = birthday; + } + + public Integer getSort() { + return sort; + } + + public void setSort(Integer sort) { + this.sort = sort; + } + + public String getComment() { + return comment; + } + + public void setComment(String comment) { + this.comment = comment; + } +} diff --git a/src/main/java/com/fengdu/gas/entity/request/test/ReqModifyTestInfo.java b/src/main/java/com/fengdu/gas/entity/request/test/ReqModifyTestInfo.java new file mode 100644 index 0000000..b217140 --- /dev/null +++ b/src/main/java/com/fengdu/gas/entity/request/test/ReqModifyTestInfo.java @@ -0,0 +1,114 @@ +package com.fengdu.gas.entity.request.test; + +import java.math.BigDecimal; + +public class ReqModifyTestInfo { + /** + * 自增id + */ + private Long id; + /** + * 名称 + */ + private String name; + /** + * 用户id + */ + private Long userId; + /** + * 电话 + */ + private String phone; + /** + * 余额 + */ + private BigDecimal balance; + /** + * 性别 ESex + */ + private Integer sex; + /** + * 生日 + */ + private String birthday; + /** + * 排序值 + */ + private Integer sort; + /** + * 备注 + */ + private String comment; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Long getUserId() { + return userId; + } + + public void setUserId(Long userId) { + this.userId = userId; + } + + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + + public BigDecimal getBalance() { + return balance; + } + + public void setBalance(BigDecimal balance) { + this.balance = balance; + } + + public Integer getSex() { + return sex; + } + + public void setSex(Integer sex) { + this.sex = sex; + } + + public String getBirthday() { + return birthday; + } + + public void setBirthday(String birthday) { + this.birthday = birthday; + } + + public Integer getSort() { + return sort; + } + + public void setSort(Integer sort) { + this.sort = sort; + } + + public String getComment() { + return comment; + } + + public void setComment(String comment) { + this.comment = comment; + } +} diff --git a/src/main/java/com/fengdu/gas/entity/request/testinfo/ReqCreateTestInfo.java b/src/main/java/com/fengdu/gas/entity/request/testinfo/ReqCreateTestInfo.java new file mode 100644 index 0000000..fc412db --- /dev/null +++ b/src/main/java/com/fengdu/gas/entity/request/testinfo/ReqCreateTestInfo.java @@ -0,0 +1,66 @@ +/** +# __----~~~~~~~~~~~------___ +# . . ~~//====...... __--~ ~~ +# -. \_|// |||\\ ~~~~~~::::... /~ +# ___-==_ _-~o~ \/ ||| \\ _/~~- +# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ +# _-~~ .=~ | \\-_ '-~7 /- / || \ / +# .~ .~ | \\ -_ / /- / || \ / +# / ____ / | \\ ~-_/ /|- _/ .|| \ / +# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ +# ' ~-| /| |-~\~~ __--~~ +# |-~~-_/ | | ~\_ _-~ /\ +# / \ \__ \/~ \__ +# _--~ _/ | .-~~____--~-/ ~~==. +# ((->/~ '.|||' -_| ~~-/ , . _|| +# -_ ~\ ~~---l__i__i__i--~~_/ +# _-~-__ ~) \--______________--~~ +# //.-~~~-~_--~- |-------~~~~~~~~ +# //.-~~~--\ +# 神兽保佑 +# 永无BUG! +*/ +package com.fengdu.gas.entity.request.testinfo; + +import lombok.Data; +import java.math.BigDecimal; + +/** + * 测试信息表 + * @author lin.liu + */ +@Data +public class ReqCreateTestInfo { + /** + * 名称 + */ + private String name; + /** + * 用户id + */ + private Long userId; + /** + * 电话 + */ + private String phone; + /** + * balance余额 + */ + private BigDecimal balance; + /** + * 性别 男=1,女=2,其他=3 + */ + private Integer sex; + /** + * 生日 + */ + private String birthday; + /** + * 排序值 + */ + private Integer sort; + /** + * 备注 + */ + private String comment; +} diff --git a/src/main/java/com/fengdu/gas/entity/request/testinfo/ReqModifyTestInfo.java b/src/main/java/com/fengdu/gas/entity/request/testinfo/ReqModifyTestInfo.java new file mode 100644 index 0000000..c89f3a2 --- /dev/null +++ b/src/main/java/com/fengdu/gas/entity/request/testinfo/ReqModifyTestInfo.java @@ -0,0 +1,74 @@ +/** +# __----~~~~~~~~~~~------___ +# . . ~~//====...... __--~ ~~ +# -. \_|// |||\\ ~~~~~~::::... /~ +# ___-==_ _-~o~ \/ ||| \\ _/~~- +# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ +# _-~~ .=~ | \\-_ '-~7 /- / || \ / +# .~ .~ | \\ -_ / /- / || \ / +# / ____ / | \\ ~-_/ /|- _/ .|| \ / +# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ +# ' ~-| /| |-~\~~ __--~~ +# |-~~-_/ | | ~\_ _-~ /\ +# / \ \__ \/~ \__ +# _--~ _/ | .-~~____--~-/ ~~==. +# ((->/~ '.|||' -_| ~~-/ , . _|| +# -_ ~\ ~~---l__i__i__i--~~_/ +# _-~-__ ~) \--______________--~~ +# //.-~~~-~_--~- |-------~~~~~~~~ +# //.-~~~--\ +# 神兽保佑 +# 永无BUG! +*/ +package com.fengdu.gas.entity.request.testinfo; + +import lombok.Data; +import java.math.BigDecimal; + +/** + * 测试信息表 + * @author lin.liu + */ +@Data +public class ReqModifyTestInfo { + /** + * 主键 + */ + private Long id; + /** + * 名称 + */ + private String name; + /** + * 用户id + */ + private Long userId; + /** + * 电话 + */ + private String phone; + /** + * balance余额 + */ + private BigDecimal balance; + /** + * 性别 男=1,女=2,其他=3 + */ + private Integer sex; + /** + * 生日 + */ + private String birthday; + /** + * 排序值 + */ + private Integer sort; + /** + * 状态 EState + */ + private Integer status; + /** + * 备注 + */ + private String comment; +} diff --git a/src/main/java/com/fengdu/gas/entity/response/ResNameValue.java b/src/main/java/com/fengdu/gas/entity/response/ResNameValue.java new file mode 100644 index 0000000..465c846 --- /dev/null +++ b/src/main/java/com/fengdu/gas/entity/response/ResNameValue.java @@ -0,0 +1,28 @@ +package com.fengdu.gas.entity.response; + +public class ResNameValue { + /** + * 名称 + **/ + private String name; + /** + * 值 + **/ + private String value; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } +} diff --git a/src/main/java/com/fengdu/gas/entity/response/admin/ResAdminLogin.java b/src/main/java/com/fengdu/gas/entity/response/admin/ResAdminLogin.java new file mode 100644 index 0000000..150a7cd --- /dev/null +++ b/src/main/java/com/fengdu/gas/entity/response/admin/ResAdminLogin.java @@ -0,0 +1,35 @@ +package com.fengdu.gas.entity.response.admin; + +import lombok.Data; + +import java.util.List; + +@Data +public class ResAdminLogin { + /** + * 管理员id + */ + private Long id; + /** + * 用户类型 EUserType + */ + private Integer userType; + + /** + * 管理员名称 + */ + private String name; + + /** + * 请求令牌 + */ + private String token; + /** + * 菜单列表 + */ + private List<ResAdminMenuTree> menus; + /** + * 权限列表 + */ + private List<String> listPermission; +} diff --git a/src/main/java/com/fengdu/gas/entity/response/admin/ResAdminMenuTree.java b/src/main/java/com/fengdu/gas/entity/response/admin/ResAdminMenuTree.java new file mode 100644 index 0000000..1d8fae0 --- /dev/null +++ b/src/main/java/com/fengdu/gas/entity/response/admin/ResAdminMenuTree.java @@ -0,0 +1,50 @@ +package com.fengdu.gas.entity.response.admin; + +import lombok.Data; + +import java.util.List; + +@Data +public class ResAdminMenuTree { + /** + * 菜单id + */ + private Long id; + /** + * 类型 EMenuType + * @required + */ + private Integer type; + /** + * 父级ID + */ + private Long parentId; + /** + * 菜单名称 + */ + private String name; + /** + * 菜单标题 + */ + private String title; + /** + * 前端资源路径 + */ + private String url; + /** + * 菜单层级 + */ + private Integer level; + /** + * 排序 越大越靠前 + */ + private Integer sort; + /** + * 图标 + */ + private String icon; + /** + * 子级菜单列表 + */ + private List<ResAdminMenuTreeAndPermission> children; +} diff --git a/src/main/java/com/fengdu/gas/entity/response/admin/ResAdminMenuTreeAndPermission.java b/src/main/java/com/fengdu/gas/entity/response/admin/ResAdminMenuTreeAndPermission.java new file mode 100644 index 0000000..c195845 --- /dev/null +++ b/src/main/java/com/fengdu/gas/entity/response/admin/ResAdminMenuTreeAndPermission.java @@ -0,0 +1,13 @@ +package com.fengdu.gas.entity.response.admin; + +import lombok.Data; + +import java.util.List; + +@Data +public class ResAdminMenuTreeAndPermission extends ResAdminMenuTree { + /** + * 权限列表 + */ + private List<ResAdminPermission> permissions; +} diff --git a/src/main/java/com/fengdu/gas/entity/response/admin/ResAdminPermission.java b/src/main/java/com/fengdu/gas/entity/response/admin/ResAdminPermission.java new file mode 100644 index 0000000..b5b0f39 --- /dev/null +++ b/src/main/java/com/fengdu/gas/entity/response/admin/ResAdminPermission.java @@ -0,0 +1,28 @@ +package com.fengdu.gas.entity.response.admin; + +import lombok.Data; + +@Data +public class ResAdminPermission { + /** + * 权限id + */ + private Long id; + /** + * 权限值 + */ + private String sn; + /** + * 菜单id + */ + private Long menuId; + + /** + * 名称 + */ + private String name; + /** + * 状态 EState + */ + private Integer status; +} diff --git a/src/main/java/com/fengdu/gas/entity/response/admin/ResAdminPower.java b/src/main/java/com/fengdu/gas/entity/response/admin/ResAdminPower.java new file mode 100644 index 0000000..1f79076 --- /dev/null +++ b/src/main/java/com/fengdu/gas/entity/response/admin/ResAdminPower.java @@ -0,0 +1,18 @@ +package com.fengdu.gas.entity.response.admin; + +import com.fengdu.gas.repository.vo.AdminMenuVO; +import lombok.Data; + +import java.util.List; + +@Data +public class ResAdminPower { + /** + * 菜单列表 + */ + private List<AdminMenuVO> menus; + /** + * 权限列表 + */ + private List<ResAdminPermission> permissions; +} diff --git a/src/main/java/com/fengdu/gas/entity/search/SearchAdminMenu.java b/src/main/java/com/fengdu/gas/entity/search/SearchAdminMenu.java new file mode 100644 index 0000000..45ced83 --- /dev/null +++ b/src/main/java/com/fengdu/gas/entity/search/SearchAdminMenu.java @@ -0,0 +1,14 @@ +package com.fengdu.gas.entity.search; + +import com.fengdu.gas.entity.dto.SearchBasicDTO; +import lombok.Data; + +/** + * 后台菜单 + * @author lin.liu + * @description 后台菜单 + */ +@Data +public class SearchAdminMenu extends SearchBasicDTO { + +} diff --git a/src/main/java/com/fengdu/gas/entity/search/SearchAdminMenus.java b/src/main/java/com/fengdu/gas/entity/search/SearchAdminMenus.java new file mode 100644 index 0000000..efabb15 --- /dev/null +++ b/src/main/java/com/fengdu/gas/entity/search/SearchAdminMenus.java @@ -0,0 +1,14 @@ +package com.fengdu.gas.entity.search; + +import lombok.Data; + +import com.fengdu.gas.entity.dto.SearchBasicDTO; + +/** + * 菜单信息 + * @author lin.liu + */ +@Data +public class SearchAdminMenus extends SearchBasicDTO { + +} diff --git a/src/main/java/com/fengdu/gas/entity/search/SearchAdminPermission.java b/src/main/java/com/fengdu/gas/entity/search/SearchAdminPermission.java new file mode 100644 index 0000000..48e2bf3 --- /dev/null +++ b/src/main/java/com/fengdu/gas/entity/search/SearchAdminPermission.java @@ -0,0 +1,25 @@ +package com.fengdu.gas.entity.search; + +import com.fengdu.gas.entity.dto.SearchBasicDTO; + +/** + * 后台用户权限表 + * @author lin.liu + * @description 后台用户权限表 + */ +public class SearchAdminPermission extends SearchBasicDTO { + @Override + public String toString() { + return "SearchAdminPermission{" + "'" + + "keywords='" + getKeywords() + + ", listId =" + getListId() + + ", status =" + getStatus() + + ", listStatus =" + getListStatus() + + ", createTimeRange='" + getCreateTimeRange() + "'" + + ", createTimeStart =" + getCreateTimeEnd() + + ", createTimeEnd =" + getCreateTimeEnd() + + ", lastId =" + getListId() + + ", orderBy='" + getOrderBy() + "'" + + '}'; + } +} diff --git a/src/main/java/com/fengdu/gas/entity/search/SearchAdminRole.java b/src/main/java/com/fengdu/gas/entity/search/SearchAdminRole.java new file mode 100644 index 0000000..4c5fa64 --- /dev/null +++ b/src/main/java/com/fengdu/gas/entity/search/SearchAdminRole.java @@ -0,0 +1,25 @@ +package com.fengdu.gas.entity.search; + +import com.fengdu.gas.entity.dto.SearchBasicDTO; + +/** + * 后台用户角色表 + * @author lin.liu + * @description 后台用户角色表 + */ +public class SearchAdminRole extends SearchBasicDTO { + @Override + public String toString() { + return "SearchAdminRole{" + "'" + + "keywords='" + getKeywords() + + ", listId =" + getListId() + + ", status =" + getStatus() + + ", listStatus =" + getListStatus() + + ", createTimeRange='" + getCreateTimeRange() + "'" + + ", createTimeStart =" + getCreateTimeEnd() + + ", createTimeEnd =" + getCreateTimeEnd() + + ", lastId =" + getListId() + + ", orderBy='" + getOrderBy() + "'" + + '}'; + } +} diff --git a/src/main/java/com/fengdu/gas/entity/search/SearchAdminRoleMenuRelation.java b/src/main/java/com/fengdu/gas/entity/search/SearchAdminRoleMenuRelation.java new file mode 100644 index 0000000..406c4ae --- /dev/null +++ b/src/main/java/com/fengdu/gas/entity/search/SearchAdminRoleMenuRelation.java @@ -0,0 +1,25 @@ +package com.fengdu.gas.entity.search; + +import com.fengdu.gas.entity.dto.SearchBasicDTO; + +/** + * 后台角色菜单关系表 + * @author lin.liu + * @description 后台角色菜单关系表 + */ +public class SearchAdminRoleMenuRelation extends SearchBasicDTO { + @Override + public String toString() { + return "SearchAdminRoleMenuRelation{" + "'" + + "keywords='" + getKeywords() + + ", listId =" + getListId() + + ", status =" + getStatus() + + ", listStatus =" + getListStatus() + + ", createTimeRange='" + getCreateTimeRange() + "'" + + ", createTimeStart =" + getCreateTimeEnd() + + ", createTimeEnd =" + getCreateTimeEnd() + + ", lastId =" + getListId() + + ", orderBy='" + getOrderBy() + "'" + + '}'; + } +} diff --git a/src/main/java/com/fengdu/gas/entity/search/SearchAdminRolePermissionRelation.java b/src/main/java/com/fengdu/gas/entity/search/SearchAdminRolePermissionRelation.java new file mode 100644 index 0000000..cbdaffe --- /dev/null +++ b/src/main/java/com/fengdu/gas/entity/search/SearchAdminRolePermissionRelation.java @@ -0,0 +1,25 @@ +package com.fengdu.gas.entity.search; + +import com.fengdu.gas.entity.dto.SearchBasicDTO; + +/** + * 后台角色权限关系表 + * @author lin.liu + * @description 后台角色权限关系表 + */ +public class SearchAdminRolePermissionRelation extends SearchBasicDTO { + @Override + public String toString() { + return "SearchAdminRolePermissionRelation{" + "'" + + "keywords='" + getKeywords() + + ", listId =" + getListId() + + ", status =" + getStatus() + + ", listStatus =" + getListStatus() + + ", createTimeRange='" + getCreateTimeRange() + "'" + + ", createTimeStart =" + getCreateTimeEnd() + + ", createTimeEnd =" + getCreateTimeEnd() + + ", lastId =" + getListId() + + ", orderBy='" + getOrderBy() + "'" + + '}'; + } +} diff --git a/src/main/java/com/fengdu/gas/entity/search/SearchAdminRoleRelation.java b/src/main/java/com/fengdu/gas/entity/search/SearchAdminRoleRelation.java new file mode 100644 index 0000000..a3d0300 --- /dev/null +++ b/src/main/java/com/fengdu/gas/entity/search/SearchAdminRoleRelation.java @@ -0,0 +1,25 @@ +package com.fengdu.gas.entity.search; + +import com.fengdu.gas.entity.dto.SearchBasicDTO; + +/** + * 后台用户和角色关系表 + * @author lin.liu + * @description 后台用户和角色关系表 + */ +public class SearchAdminRoleRelation extends SearchBasicDTO { + @Override + public String toString() { + return "SearchAdminRoleRelation{" + "'" + + "keywords='" + getKeywords() + + ", listId =" + getListId() + + ", status =" + getStatus() + + ", listStatus =" + getListStatus() + + ", createTimeRange='" + getCreateTimeRange() + "'" + + ", createTimeStart =" + getCreateTimeEnd() + + ", createTimeEnd =" + getCreateTimeEnd() + + ", lastId =" + getListId() + + ", orderBy='" + getOrderBy() + "'" + + '}'; + } +} diff --git a/src/main/java/com/fengdu/gas/entity/search/SearchAdminUser.java b/src/main/java/com/fengdu/gas/entity/search/SearchAdminUser.java new file mode 100644 index 0000000..d4295ee --- /dev/null +++ b/src/main/java/com/fengdu/gas/entity/search/SearchAdminUser.java @@ -0,0 +1,25 @@ +package com.fengdu.gas.entity.search; + +import com.fengdu.gas.entity.dto.SearchBasicDTO; + +/** + * 管理员帐号 + * @author lin.liu + * @description 管理员帐号 + */ +public class SearchAdminUser extends SearchBasicDTO { + @Override + public String toString() { + return "SearchAdminUser{" + "'" + + "keywords='" + getKeywords() + + ", listId =" + getListId() + + ", status =" + getStatus() + + ", listStatus =" + getListStatus() + + ", createTimeRange='" + getCreateTimeRange() + "'" + + ", createTimeStart =" + getCreateTimeEnd() + + ", createTimeEnd =" + getCreateTimeEnd() + + ", lastId =" + getListId() + + ", orderBy='" + getOrderBy() + "'" + + '}'; + } +} diff --git a/src/main/java/com/fengdu/gas/entity/search/SearchNotice.java b/src/main/java/com/fengdu/gas/entity/search/SearchNotice.java new file mode 100644 index 0000000..ef2a223 --- /dev/null +++ b/src/main/java/com/fengdu/gas/entity/search/SearchNotice.java @@ -0,0 +1,14 @@ +package com.fengdu.gas.entity.search; + +import lombok.Data; + +import com.fengdu.gas.entity.dto.SearchBasicDTO; + +/** + * 公告 + * @author lin.liu + */ +@Data +public class SearchNotice extends SearchBasicDTO { + +} diff --git a/src/main/java/com/fengdu/gas/entity/search/SearchQuartzTaskError.java b/src/main/java/com/fengdu/gas/entity/search/SearchQuartzTaskError.java new file mode 100644 index 0000000..322e465 --- /dev/null +++ b/src/main/java/com/fengdu/gas/entity/search/SearchQuartzTaskError.java @@ -0,0 +1,23 @@ +package com.fengdu.gas.entity.search; + +import com.fengdu.gas.entity.dto.SearchBasicDTO; + +/** + * 定时任务错误信息表 + * @author lin.liu + * @description 定时任务错误信息表 + */ +public class SearchQuartzTaskError extends SearchBasicDTO { + @Override + public String toString() { + return "SearchQuartzTaskError{" + "'" + + "keywords='" + getKeywords() + + ", status =" + getStatus() + + ", listStatus =" + getListStatus() + + ", createTimeRange='" + getCreateTimeRange() + "'" + + ", createTimeStart =" + getCreateTimeEnd() + + ", createTimeEnd =" + getCreateTimeEnd() + + ", orderBy='" + getOrderBy() + "'" + + '}'; + } +} diff --git a/src/main/java/com/fengdu/gas/entity/search/SearchQuartzTaskInfo.java b/src/main/java/com/fengdu/gas/entity/search/SearchQuartzTaskInfo.java new file mode 100644 index 0000000..af0e86b --- /dev/null +++ b/src/main/java/com/fengdu/gas/entity/search/SearchQuartzTaskInfo.java @@ -0,0 +1,30 @@ +package com.fengdu.gas.entity.search; + +import com.fengdu.gas.entity.dto.SearchBasicDTO; +import lombok.Data; + +/** + * 定时任务信息表 + * @author lin.liu + * @description 定时任务信息表 + */ +@Data +public class SearchQuartzTaskInfo extends SearchBasicDTO { + /** + * 任务编号 + */ + private String taskNo; + + @Override + public String toString() { + return "SearchQuartzTaskInfo{" + "'" + + "keywords='" + getKeywords() + + ", status =" + getStatus() + + ", listStatus =" + getListStatus() + + ", createTimeRange='" + getCreateTimeRange() + "'" + + ", createTimeStart =" + getCreateTimeEnd() + + ", createTimeEnd =" + getCreateTimeEnd() + + ", orderBy='" + getOrderBy() + "'" + + '}'; + } +} diff --git a/src/main/java/com/fengdu/gas/entity/search/SearchQuartzTaskRecord.java b/src/main/java/com/fengdu/gas/entity/search/SearchQuartzTaskRecord.java new file mode 100644 index 0000000..bb186d0 --- /dev/null +++ b/src/main/java/com/fengdu/gas/entity/search/SearchQuartzTaskRecord.java @@ -0,0 +1,48 @@ +package com.fengdu.gas.entity.search; + +import com.fengdu.gas.entity.dto.SearchBasicDTO; +import lombok.Data; + +/** + * 定时任务执行情况记录表 + * @author lin.liu + * @description 定时任务执行情况记录表 + */ +@Data +public class SearchQuartzTaskRecord extends SearchBasicDTO { + /** + * 任务编号 + */ + private String taskNo; + /** + * 执行时间-范围(eg: 2021-01-01 00:00:00 ~ 2021-01-01 23:59:59)" + */ + private String executeTimeRange; + /** + * 执行时间-起始 + * @ignore + */ + private Long executeTimeStart; + /** + * 执行时间-截止 + * @ignore + */ + private Long executeTimeEnd; + + @Override + public String toString() { + return "SearchQuartzTaskRecord{" + "'" + + "keywords='" + getKeywords() + + ", status =" + getStatus() + + ", listStatus =" + getListStatus() + + ", createTimeRange='" + getCreateTimeRange() + "'" + + ", createTimeStart =" + getCreateTimeEnd() + + ", createTimeEnd =" + getCreateTimeEnd() + + ", orderBy='" + getOrderBy() + "'" + + ", taskNo='" + taskNo + "'" + + ", executeTimeRange='" + executeTimeRange + "'" + + ", executeTimeStart =" + executeTimeStart + + ", executeTimeEnd =" + executeTimeEnd + + '}'; + } +} diff --git a/src/main/java/com/fengdu/gas/entity/search/SearchSysDictData.java b/src/main/java/com/fengdu/gas/entity/search/SearchSysDictData.java new file mode 100644 index 0000000..ead5868 --- /dev/null +++ b/src/main/java/com/fengdu/gas/entity/search/SearchSysDictData.java @@ -0,0 +1,14 @@ +package com.fengdu.gas.entity.search; + +import com.fengdu.gas.entity.dto.SearchBasicDTO; +import lombok.Data; + +/** + * 字典数据表 + * @author lin.liu + * @description 字典数据表 + */ +@Data +public class SearchSysDictData extends SearchBasicDTO { + +} diff --git a/src/main/java/com/fengdu/gas/entity/search/SearchSysDictType.java b/src/main/java/com/fengdu/gas/entity/search/SearchSysDictType.java new file mode 100644 index 0000000..011ef06 --- /dev/null +++ b/src/main/java/com/fengdu/gas/entity/search/SearchSysDictType.java @@ -0,0 +1,14 @@ +package com.fengdu.gas.entity.search; + +import com.fengdu.gas.entity.dto.SearchBasicDTO; +import lombok.Data; + +/** + * 字典类型表 + * @author lin.liu + * @description 字典类型表 + */ +@Data +public class SearchSysDictType extends SearchBasicDTO { + +} diff --git a/src/main/java/com/fengdu/gas/entity/search/SearchTestInfo.java b/src/main/java/com/fengdu/gas/entity/search/SearchTestInfo.java new file mode 100644 index 0000000..8929388 --- /dev/null +++ b/src/main/java/com/fengdu/gas/entity/search/SearchTestInfo.java @@ -0,0 +1,40 @@ +package com.fengdu.gas.entity.search; + +import com.fengdu.gas.entity.dto.SearchBasicDTO; + +/** + * 测试信息 查询条件dto + * @author lin.liu + * @description 测试信息 查询条件dto + * @date 2021/11/23 + */ +public class SearchTestInfo extends SearchBasicDTO { + /** + * EOrderBy-此字段仅为“orderBy”说明枚举类型,无需传参 + */ + private String orderByEnum; + + public String getOrderByEnum() { + return orderByEnum; + } + + public void setOrderByEnum(String orderByEnum) { + this.orderByEnum = orderByEnum; + } + + @Override + public String toString() { + return "SearchTestInfo{" + "'" + + "keywords='" + getKeywords() + + ", listId =" + getListId() + + ", status =" + getStatus() + + ", listStatus =" + getListStatus() + + ", createTimeRange='" + getCreateTimeRange() + "'" + + ", createTimeStart =" + getCreateTimeEnd() + + ", createTimeEnd =" + getCreateTimeEnd() + + ", lastId =" + getListId() + + ", orderByEnum='" + getOrderByEnum() + '\'' + + ", orderBy='" + getOrderBy() + '\'' + + '}'; + } +} diff --git a/src/main/java/com/fengdu/gas/host/ApplicationStarter.java b/src/main/java/com/fengdu/gas/host/ApplicationStarter.java new file mode 100644 index 0000000..3a057bc --- /dev/null +++ b/src/main/java/com/fengdu/gas/host/ApplicationStarter.java @@ -0,0 +1,31 @@ +package com.fengdu.gas.host; + +import com.yomahub.tlog.core.enhance.AspectLogEnhance; +import org.mybatis.spring.annotation.MapperScan; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.builder.SpringApplicationBuilder; +import org.springframework.boot.web.servlet.ServletComponentScan; +import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; +import org.springframework.cache.annotation.EnableCaching; + +@SpringBootApplication(scanBasePackages = { "com.lunhan" }) +@ServletComponentScan +@MapperScan("com.fengdu.gas.repository.mapper") +// 开启缓存 +@EnableCaching +public class ApplicationStarter extends SpringBootServletInitializer { + static { + // 进行日志增强,自动判断日志框架。自动给每条日志加上一个全局唯一的traceId + AspectLogEnhance.enhance(); + } + + public static void main(String[] args) { + SpringApplication.run(ApplicationStarter.class, args); + } + + @Override + protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { + return application.sources(ApplicationStarter.class); + } +} diff --git a/src/main/java/com/fengdu/gas/host/BasicController.java b/src/main/java/com/fengdu/gas/host/BasicController.java new file mode 100644 index 0000000..70ebdb6 --- /dev/null +++ b/src/main/java/com/fengdu/gas/host/BasicController.java @@ -0,0 +1,62 @@ +package com.fengdu.gas.host; + +import com.fengdu.gas.common.ExecutedResult; +import com.fengdu.gas.common.config.SysConfig; +import com.fengdu.gas.common.jwt.JWTUtil; +import com.fengdu.gas.common.jwt.LoginUserDTO; +import org.springframework.web.context.request.RequestAttributes; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +/** + * 基础controller + */ +public class BasicController { + + /** + * 获取当前请求上下文的“HttpServletRequest”对象 + */ + protected HttpServletRequest ServletRequest() { + RequestAttributes reqAttributes = RequestContextHolder.currentRequestAttributes(); + if (null == reqAttributes) { + return null; + } + ServletRequestAttributes servletReqAttributes = (ServletRequestAttributes)reqAttributes; + return servletReqAttributes.getRequest(); + } + + /** + * 获取当前请求上下文的“HttpServletResponse”对象 + */ + protected HttpServletResponse ServletResponse() { + RequestAttributes reqAttributes = RequestContextHolder.currentRequestAttributes(); + if (null == reqAttributes) { + return null; + } + ServletRequestAttributes servletReqAttributes = (ServletRequestAttributes)reqAttributes; + return servletReqAttributes.getResponse(); + } + + protected String getToken() { + return this.ServletRequest().getHeader(SysConfig.getTokenHeader()); + } + + protected String getHeader(String key) { + return this.ServletRequest().getHeader(key); + } + + protected LoginUserDTO getTokenUser() { + return JWTUtil.getUser(this.getToken()); + } + + protected <T> ExecutedResult<T> success(T data) { + return ExecutedResult.success(data); + } + + protected <T> ExecutedResult<T> failed(String msg) { + return ExecutedResult.failed(msg); + } +} \ No newline at end of file diff --git a/src/main/java/com/fengdu/gas/host/api/ApiRequestLogDTO.java b/src/main/java/com/fengdu/gas/host/api/ApiRequestLogDTO.java new file mode 100644 index 0000000..462f74d --- /dev/null +++ b/src/main/java/com/fengdu/gas/host/api/ApiRequestLogDTO.java @@ -0,0 +1,113 @@ +package com.fengdu.gas.host.api; + +public class ApiRequestLogDTO { + private String requestId; + private String requestIP; + private String path; + private String desc; + private String method; + private Long requestTime; + private String requestData; + private String requestToken; + private String requestHeaders; + private Long responseTime; + private Long spendTime; + private String responseData; + + + public String getRequestId() { + return requestId; + } + + public void setRequestId(String requestId) { + this.requestId = requestId; + } + + public String getRequestIP() { + return requestIP; + } + + public void setRequestIP(String requestIP) { + this.requestIP = requestIP; + } + + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + public String getDesc() { + return desc; + } + + public void setDesc(String desc) { + this.desc = desc; + } + + public String getMethod() { + return method; + } + + public void setMethod(String method) { + this.method = method; + } + + public Long getRequestTime() { + return requestTime; + } + + public void setRequestTime(Long requestTime) { + this.requestTime = requestTime; + } + + public String getRequestData() { + return requestData; + } + + public void setRequestData(String requestData) { + this.requestData = requestData; + } + + public String getRequestToken() { + return requestToken; + } + + public void setRequestToken(String requestToken) { + this.requestToken = requestToken; + } + + public String getRequestHeaders() { + return requestHeaders; + } + + public void setRequestHeaders(String requestHeaders) { + this.requestHeaders = requestHeaders; + } + + public Long getResponseTime() { + return responseTime; + } + + public void setResponseTime(Long responseTime) { + this.responseTime = responseTime; + } + + public Long getSpendTime() { + return spendTime; + } + + public void setSpendTime(Long spendTime) { + this.spendTime = spendTime; + } + + public String getResponseData() { + return responseData; + } + + public void setResponseData(String responseData) { + this.responseData = responseData; + } +} diff --git a/src/main/java/com/fengdu/gas/host/api/CorsFilterConfig.java b/src/main/java/com/fengdu/gas/host/api/CorsFilterConfig.java new file mode 100644 index 0000000..c143e72 --- /dev/null +++ b/src/main/java/com/fengdu/gas/host/api/CorsFilterConfig.java @@ -0,0 +1,31 @@ +package com.fengdu.gas.host.api; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.cors.CorsConfiguration; +import org.springframework.web.cors.UrlBasedCorsConfigurationSource; +import org.springframework.web.filter.CorsFilter; + +// 一定不能忽略此注解 +@Configuration +public class CorsFilterConfig { + /** + * 跨域过滤器 TODO 如果通过ngix或者其他方式配置了跨域,请注释掉 @Bean 注解 + * @return CorsFilter 跨域过滤器对象 + */ + + @Bean + public CorsFilter corsFilter() { + UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); + source.registerCorsConfiguration("/**", buildConfig()); + return new CorsFilter(source); + } + + private CorsConfiguration buildConfig() { + CorsConfiguration corsConfiguration = new CorsConfiguration(); + corsConfiguration.addAllowedOrigin("*"); + corsConfiguration.addAllowedHeader("*"); + corsConfiguration.addAllowedMethod("*"); + return corsConfiguration; + } +} diff --git a/src/main/java/com/fengdu/gas/host/api/GlobalExceptionHandler.java b/src/main/java/com/fengdu/gas/host/api/GlobalExceptionHandler.java new file mode 100644 index 0000000..007080d --- /dev/null +++ b/src/main/java/com/fengdu/gas/host/api/GlobalExceptionHandler.java @@ -0,0 +1,92 @@ +package com.fengdu.gas.host.api; + +import com.fengdu.gas.common.ExecutedResult; +import com.fengdu.gas.common.enums.ELogger; +import com.fengdu.gas.common.enums.EResultCode; +import com.fengdu.gas.common.exceptions.BusinessException; +import com.google.common.base.Charsets; +import com.fengdu.gas.common.util.*; +import org.slf4j.Logger; +import org.springframework.web.bind.annotation.ControllerAdvice; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; + +import javax.servlet.http.HttpServletRequest; + +/** + * 全局异常处理 + */ +@ControllerAdvice +public class GlobalExceptionHandler { + private static final Logger sysLogger = LoggerUtil.get(ELogger.SYS_ERROR); + private static final Logger logger = LoggerUtil.get(ELogger.API_REQUEST); + @ResponseBody + @ExceptionHandler(value = Exception.class) + public ExecutedResult<String> handle(Exception e) { + ExecutedResult<String> result = new ExecutedResult<>(EResultCode.ERROR, "", e.getMessage()); + + // 记录请求日志 + this.writeLog(result); + + sysLogger.error("SysError", e); + return result; + } + + + @ResponseBody + @ExceptionHandler(value = BusinessException.class) + public ExecutedResult<String> handle(BusinessException e) { + ExecutedResult<String> result = new ExecutedResult<>(e.getCode(), "", e.getMessage()); + + // 记录请求日志 + this.writeLog(result); + + return result; + } + + private void writeLog(ExecutedResult<String> result) { + //获取当前请求对象 + ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); + if (null == attributes) { + return; + } + HttpServletRequest request = attributes.getRequest(); + String data; + try { + byte[] buffer = HttpUtil.getBytesFromInputStream(request.getInputStream()); + data = new String(buffer, Charsets.UTF_8); + } catch (Exception e) { + data = ""; + } + ApiRequestLogDTO webLog = HttpRequestLogPool.getRequestInfo(); + if (null == webLog) { + return; + } + String log = String.format("[%s]" + + "%nrequestPath: %s[%s]" + + "%nreponseData: %s" + + "%nrequestTime: %s" + + "%nresponseTime: %s" + + "%nspendTime: %s" + + "%nmethod: %s" + + "%nrequestIp: %s" + + "%ntokenCode: %s" + + "%nrequestData: %s", + + "", + webLog.getPath(), + "", + SerializeUtil.toJson(result), + LocalDateTimeUtil.toFormatFullString(webLog.getRequestTime()), + LocalDateTimeUtil.nowDateTimeFullStr(), + LocalDateTimeUtil.nowTimeStamp() - webLog.getRequestTime(), + webLog.getMethod(), + webLog.getRequestIP(), + webLog.getRequestToken(), + data + ); + logger.info(log); + } +} diff --git a/src/main/java/com/fengdu/gas/host/api/HttpRequestLogPool.java b/src/main/java/com/fengdu/gas/host/api/HttpRequestLogPool.java new file mode 100644 index 0000000..fba5a74 --- /dev/null +++ b/src/main/java/com/fengdu/gas/host/api/HttpRequestLogPool.java @@ -0,0 +1,16 @@ +package com.fengdu.gas.host.api; + +class HttpRequestLogPool { + private static ThreadLocal<ApiRequestLogDTO> requestThreadLocal = new ThreadLocal<>(); + + public static void setRequestInfo(ApiRequestLogDTO requestInfo) { + requestThreadLocal.set(requestInfo); + } + + public static ApiRequestLogDTO getRequestInfo() { + ApiRequestLogDTO result = requestThreadLocal.get(); + requestThreadLocal.remove(); + return result; + } + +} diff --git a/src/main/java/com/fengdu/gas/host/api/MustAdmin.java b/src/main/java/com/fengdu/gas/host/api/MustAdmin.java new file mode 100644 index 0000000..0e02cb2 --- /dev/null +++ b/src/main/java/com/fengdu/gas/host/api/MustAdmin.java @@ -0,0 +1,15 @@ +package com.fengdu.gas.host.api; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * 标记必须是管理员(作用整个controller类,或者某个接口方法) + */ + +@Target(value = { ElementType.TYPE, ElementType.METHOD }) +@Retention(RetentionPolicy.RUNTIME) +public @interface MustAdmin { +} diff --git a/src/main/java/com/fengdu/gas/host/api/MvcTokenInterceptors.java b/src/main/java/com/fengdu/gas/host/api/MvcTokenInterceptors.java new file mode 100644 index 0000000..58b840c --- /dev/null +++ b/src/main/java/com/fengdu/gas/host/api/MvcTokenInterceptors.java @@ -0,0 +1,42 @@ +package com.fengdu.gas.host.api; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.InterceptorRegistration; +import org.springframework.web.servlet.config.annotation.InterceptorRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +@Configuration +public class MvcTokenInterceptors implements WebMvcConfigurer { + @Autowired + private TokenFilter tokenFilter; + + + @Override + public void addInterceptors(InterceptorRegistry registry) { + //添加处理拦截器,拦截所有请求 + InterceptorRegistration interceptorRegistration = registry.addInterceptor(tokenFilter); + //配置拦截策略 所有路径都被拦截 + interceptorRegistration.addPathPatterns("/**"); + //排除配置 这里接口的跳过不使用此方式排除,通过注解“NonLogin”跳过拦截 + interceptorRegistration.excludePathPatterns( + "/**/*.html", + "/**/*.vue" + , "/**/*.css" + , "/**/*.js" + , "/**/*.js.map" + , "/*.ico" + , "/**/*.jpg" + , "/**/*.png" + , "/**/*.woff" + , "/**/*.ttf" + ,"/**/*.json" + , "/doc/*" + , "/swagger/*" + , "/swagger\\-ui/*" + , "/swagger3/*" +// , "/login/*" +// , "/user/login" + ); + } +} diff --git a/src/main/java/com/fengdu/gas/host/api/MyBatisPlusConfig.java b/src/main/java/com/fengdu/gas/host/api/MyBatisPlusConfig.java new file mode 100644 index 0000000..0c98d0b --- /dev/null +++ b/src/main/java/com/fengdu/gas/host/api/MyBatisPlusConfig.java @@ -0,0 +1,16 @@ +package com.fengdu.gas.host.api; + +import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; +import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class MyBatisPlusConfig { + @Bean + public MybatisPlusInterceptor paginationInterceptor() { + MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); + interceptor.addInnerInterceptor(new PaginationInnerInterceptor()); + return interceptor; + } +} diff --git a/src/main/java/com/fengdu/gas/host/api/NonLogin.java b/src/main/java/com/fengdu/gas/host/api/NonLogin.java new file mode 100644 index 0000000..dc26ee2 --- /dev/null +++ b/src/main/java/com/fengdu/gas/host/api/NonLogin.java @@ -0,0 +1,15 @@ +package com.fengdu.gas.host.api; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * 不需要登陆注解(作用整个controller类,或者某个接口方法) + */ + +@Target(value = { ElementType.TYPE, ElementType.METHOD }) +@Retention(RetentionPolicy.RUNTIME) +public @interface NonLogin { +} diff --git a/src/main/java/com/fengdu/gas/host/api/TokenFilter.java b/src/main/java/com/fengdu/gas/host/api/TokenFilter.java new file mode 100644 index 0000000..03b3fd0 --- /dev/null +++ b/src/main/java/com/fengdu/gas/host/api/TokenFilter.java @@ -0,0 +1,116 @@ +package com.fengdu.gas.host.api; + +import com.fengdu.gas.common.config.SysConfig; +import com.fengdu.gas.common.enums.EResultCode; +import com.fengdu.gas.common.exceptions.BusinessException; +import com.fengdu.gas.common.jwt.JWTUtil; +import com.fengdu.gas.common.jwt.LoginUserDTO; +import com.fengdu.gas.common.util.IPUtils; +import com.fengdu.gas.common.util.LocalDateTimeUtil; +import com.fengdu.gas.common.util.RandVerifyCode; +import com.fengdu.gas.common.util.StringUtil; +import com.fengdu.gas.entity.enums.EUserType; +import org.apache.commons.lang3.BooleanUtils; +import org.springframework.core.annotation.AnnotationUtils; +import org.springframework.stereotype.Component; +import org.springframework.web.method.HandlerMethod; +import org.springframework.web.servlet.HandlerInterceptor; +import org.springframework.web.servlet.ModelAndView; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + + +@Component +public class TokenFilter implements HandlerInterceptor { + @Override + public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) { + String method = request.getMethod(); + if ("options".equalsIgnoreCase(method)) { + + return true; + } + Long now = LocalDateTimeUtil.nowTimeStamp(); + String reqId = now + RandVerifyCode.complexCode(6); + ApiRequestLogDTO req = new ApiRequestLogDTO(); + req.setRequestTime(now); + req.setRequestId(reqId); + req.setRequestIP(IPUtils.getIpAddress(request)); + String urlParams = request.getQueryString(); + if (StringUtil.isNotNullOrEmpty(urlParams)) { + urlParams = "?" + urlParams; + } + req.setPath(request.getRequestURI() + urlParams); + req.setMethod(method); + req.setRequestData(""); +// Map<String, String> mapHeaders = new HashMap<>(); +// Enumeration<String> headerNames = request.getHeaderNames(); +// String key = headerNames.nextElement(); +// while (StringUtil.isNotNullOrEmpty(key)) { +// mapHeaders.put(key, request.getHeader(key)); +// key = headerNames.nextElement(); +// } + req.setRequestHeaders(""); + String token = request.getHeader(SysConfig.getTokenHeader()); + req.setRequestToken(token); + HttpRequestLogPool.setRequestInfo(req); + + List<Class<?>> listHas = new ArrayList<>(); + if (handler instanceof HandlerMethod) { + HandlerMethod methodHandle = (HandlerMethod) handler; + Class<?> clazz = ((HandlerMethod) handler).getBeanType(); + + NonLogin nonLogin = methodHandle.getMethodAnnotation(NonLogin.class); + // 如果方法拥有跳过登陆验权的注解,则返回成功 + if (Objects.nonNull(nonLogin)) { + return true; + } + nonLogin = AnnotationUtils.findAnnotation(clazz, NonLogin.class); + // 如果此方法所属类拥有跳过登陆验权的注解,则返回成功 + if (Objects.nonNull(nonLogin)) { + return true; + } + + MustAdmin mustAdmin = methodHandle.getMethodAnnotation(MustAdmin.class); + if (Objects.nonNull(mustAdmin)) { + listHas.add(MustAdmin.class); + } + mustAdmin = AnnotationUtils.findAnnotation(clazz, MustAdmin.class); + if (Objects.nonNull(mustAdmin)) { + listHas.add(MustAdmin.class); + } + } + if (Objects.isNull(token)) { + throw new BusinessException(EResultCode.UNAUTHORIZED, "token未传入"); + } + + // 验证token + LoginUserDTO user = JWTUtil.getUser(token); + // 超级管理员拥有所有权限 + if (Objects.equals(user.getUserType(), EUserType.ADMIN.getValue())) { + return true; + } + if ( + listHas.contains(MustAdmin.class) && ( + BooleanUtils.isFalse(Objects.equals(user.getUserType(), EUserType.ADMIN.getValue())) && + BooleanUtils.isFalse(Objects.equals(user.getUserType(), EUserType.ADMIN_USER.getValue())) + ) + ) { + throw new BusinessException(EResultCode.FORBIDDEN, "没有权限"); + } + return true; + } + + @Override + public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) { + + } + + @Override + public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) { + + } +} diff --git a/src/main/java/com/fengdu/gas/host/api/WebLogAspect.java b/src/main/java/com/fengdu/gas/host/api/WebLogAspect.java new file mode 100644 index 0000000..db4ba74 --- /dev/null +++ b/src/main/java/com/fengdu/gas/host/api/WebLogAspect.java @@ -0,0 +1,209 @@ +package com.fengdu.gas.host.api; + +import java.lang.reflect.Method; +import java.lang.reflect.Parameter; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import javax.servlet.http.HttpServletRequest; + +import com.fengdu.gas.common.enums.ELogger; +import com.fengdu.gas.common.util.*; +import org.aspectj.lang.JoinPoint; +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.Signature; +import org.aspectj.lang.annotation.AfterReturning; +import org.aspectj.lang.annotation.Around; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Before; +import org.aspectj.lang.annotation.Pointcut; +import org.aspectj.lang.reflect.MethodSignature; +import org.slf4j.Logger; +import org.springframework.core.annotation.Order; +import org.springframework.stereotype.Component; +import org.springframework.util.StringUtils; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; + +/** + * 统一日志处理切面 + * Created by macro on 2018/4/26. + */ +@Aspect +@Component +@Order(1) +public class WebLogAspect { + private static final Logger logger = LoggerUtil.get(ELogger.API_REQUEST); + private static final Logger sysLogger = LoggerUtil.get(ELogger.SYS_ERROR); + /** + * 100毫秒 + */ + private static final long MS_100 = 100; + /** + * 2秒 + */ + private static final long SEC_1 = 1000; + /** + * 2秒 + */ + private static final long SEC_2 = 2 * 1000; + /** + * 10秒 + */ + private static final long SEC_10 = 10 * 1000; + /** + * 1分钟 + */ + private static final long MINS_1 = 60 * 1000; + /** + * 5分钟 + */ + private static final long MINS_5 = 5 * 60 * 1000; + + @Pointcut( + "execution(public * com.lunhan.*.host.controller.*.*(..))" + + "||execution(public * com.lunhan.*.host.admin.*.*(..))" + + "||execution(public * com.lunhan.*.host.customer.*.*(..))" + ) + public void webLog() { + } + + @Before("webLog()") + public void doBefore(JoinPoint joinPoint) { + } + + @AfterReturning(value = "webLog()", returning = "ret") + public void doAfterReturning(Object ret) { + } + + + @Around("webLog()") + public Object doAround(ProceedingJoinPoint joinPoint) throws Throwable { + long startTime = System.currentTimeMillis(); + //获取当前请求对象 + ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); + HttpServletRequest request = attributes.getRequest(); + //记录请求信息(通过Logstash传入Elasticsearch) + ApiRequestLogDTO webLog = HttpRequestLogPool.getRequestInfo(); + Object result = joinPoint.proceed(); + Signature signature = joinPoint.getSignature(); + MethodSignature methodSignature = (MethodSignature) signature; + Method method = methodSignature.getMethod(); +// if (method.isAnnotationPresent(ApiOperation.class)) { +// ApiOperation log = method.getAnnotation(ApiOperation.class); +// webLog.setDescription(log.value()); +// } + String desc; + switch (webLog.getMethod()) { + case "POST": + desc = method.getAnnotation(PostMapping.class).name(); + break; + case "GET": + desc = method.getAnnotation(GetMapping.class).name(); + break; + case "PUT": + desc = method.getAnnotation(PutMapping.class).name(); + break; + case "Delete": + desc = method.getAnnotation(DeleteMapping.class).name(); + break; + default: + desc = ""; + break; + } + webLog.setDesc(desc); + + Long endTime = LocalDateTimeUtil.nowTimeStamp(); + webLog.setResponseTime(endTime); + webLog.setRequestData(SerializeUtil.toJson(getParameter(method, joinPoint.getArgs()))); + webLog.setResponseData(SerializeUtil.toJson(result)); + webLog.setSpendTime((endTime - startTime)); + + String usedTimesLevel; + if (webLog.getSpendTime() > MINS_5) {//大于5分钟 + usedTimesLevel = "F"; + } else if (webLog.getSpendTime() > MINS_1) {//1 - 5分钟 + usedTimesLevel = "E"; + } else if (webLog.getSpendTime() > SEC_10) {//10秒 - 1分钟 + usedTimesLevel = "D"; + } else if (webLog.getSpendTime() > SEC_2) {//2秒 - 10秒 + usedTimesLevel = "C"; + } else if (webLog.getSpendTime() > SEC_1) {//1秒 - 2秒 + usedTimesLevel = "B"; + } else if (webLog.getSpendTime() > MS_100) {//100毫秒 - 1秒 + usedTimesLevel = "A"; + } else {//100毫秒以内 + usedTimesLevel = "SSS"; + } + + List<String> listTag = new ArrayList<>(); + listTag.add("url=" + webLog.getPath()); + listTag.add("method=" + webLog.getMethod()); + listTag.add("spendTime=" + webLog.getSpendTime()); + listTag.add("description=" + webLog.getDesc()); + listTag.add("tokenCode=" + webLog.getRequestToken()); + listTag.add("usedTimesLevel=" + usedTimesLevel); + + String log = String.format("[%s]" + + "%nrequestPath: %s[%s]" + + "%nreponseData: %s" + + "%nrequestTime: %s" + + "%nresponseTime: %s" + + "%nspendTime: %s" + + "%nmethod: %s" + + "%nrequestIp: %s" + + "%ntokenCode: %s" + + "%nrequestData: %s", + + StringUtil.join(listTag, "],["), + webLog.getPath(), + webLog.getDesc(), + webLog.getResponseData(), + LocalDateTimeUtil.toFormatFullString(webLog.getRequestTime()), + LocalDateTimeUtil.toFormatFullString(webLog.getResponseTime()), + webLog.getSpendTime(), + webLog.getMethod(), + webLog.getRequestIP(), + webLog.getRequestToken(), + webLog.getRequestData() + ); + + logger.info(log); + return result; + } + + /** + * 根据方法和传入的参数获取请求参数 + */ + private Object getParameter(Method method, Object[] args) { + List<Object> argList = new ArrayList<>(); + Parameter[] parameters = method.getParameters(); + for (int i = 0; i < parameters.length; i++) { + //将RequestBody注解修饰的参数作为请求参数 + RequestBody requestBody = parameters[i].getAnnotation(RequestBody.class); + if (requestBody != null) { + argList.add(args[i]); + } + //将RequestParam注解修饰的参数作为请求参数 + RequestParam requestParam = parameters[i].getAnnotation(RequestParam.class); + if (requestParam != null) { + Map<String, Object> map = new HashMap<>(); + String key = parameters[i].getName(); + if (!StringUtils.isEmpty(requestParam.value())) { + key = requestParam.value(); + } + map.put(key, args[i]); + argList.add(map); + } + } + if (argList.size() == 0) { + return null; + } else if (argList.size() == 1) { + return argList.get(0); + } else { + return argList; + } + } +} diff --git a/src/main/java/com/fengdu/gas/host/api/WebMvcConfig.java b/src/main/java/com/fengdu/gas/host/api/WebMvcConfig.java new file mode 100644 index 0000000..282c3a2 --- /dev/null +++ b/src/main/java/com/fengdu/gas/host/api/WebMvcConfig.java @@ -0,0 +1,14 @@ +package com.fengdu.gas.host.api; + +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +@Configuration +public class WebMvcConfig implements WebMvcConfigurer { + @Override + public void addResourceHandlers(ResourceHandlerRegistry registry) { + // 添加一个静态资源映射 将/logs/upload/xxx 映射到文件上传目录 + registry.addResourceHandler("/upload/**").addResourceLocations("file:" + System.getProperty("user.dir") + "/logs/upload/"); + } +} diff --git a/src/main/java/com/fengdu/gas/host/controller/TestInfoServiceController.java b/src/main/java/com/fengdu/gas/host/controller/TestInfoServiceController.java new file mode 100644 index 0000000..a35b2d7 --- /dev/null +++ b/src/main/java/com/fengdu/gas/host/controller/TestInfoServiceController.java @@ -0,0 +1,257 @@ +package com.fengdu.gas.host.controller; + +import com.fengdu.gas.common.ConstantFactory; +import com.fengdu.gas.common.ExecutedResult; +import com.fengdu.gas.common.PagerResult; +import com.fengdu.gas.common.util.ParameterUtil; +import com.fengdu.gas.common.validator.ParameterValidateResult; +import com.fengdu.gas.common.validator.ParameterValidator; +import com.fengdu.gas.entity.enums.ESex; +import com.fengdu.gas.entity.request.ReqListId; +import com.fengdu.gas.entity.request.ReqListSetSort; +import com.fengdu.gas.entity.request.ReqSetSort; +import com.fengdu.gas.entity.request.test.ReqCreateTestInfo; +import com.fengdu.gas.entity.request.test.ReqModifyTestInfo; +import com.fengdu.gas.entity.search.SearchTestInfo; +import com.fengdu.gas.service.TestInfoService; +import com.fengdu.gas.host.BasicController; +import com.fengdu.gas.host.api.NonLogin; +import com.fengdu.gas.repository.vo.TestInfoVO; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.math.BigDecimal; +import java.util.List; + +/** + * 99999.测试信息相关接口 + * + * @author lin.liu + * @date 2021/11/23 + * @order 99999 + */ +@NonLogin +@RestController +@RequestMapping(value = "testInfo") +public class TestInfoServiceController extends BasicController { + @Autowired + private TestInfoService service; + /** + * 创建[测试信息] + * + * @author lin.liu + * @date 2021/11/23 + */ + @PostMapping(value = "create") + public ExecutedResult<Long> create(@RequestBody ReqCreateTestInfo request) { + //#region 参数验证 + ParameterValidator validator = new ParameterValidator() + // 非空 + .addNotNullOrEmpty(ParameterUtil.named("名称"), request.getName()) + // 限制最大长度 + .addLengthMax(ParameterUtil.named("名称"), request.getName(), ConstantFactory.LENGTH_MAX50) + // 必须大于0 + .addGreater(ParameterUtil.named("用户id"), request.getUserId(), 0L) + // 必须是手机号码(正则) + .addMustMobile(ParameterUtil.named("电话"), request.getPhone()) + // 金额大于0 + .addGreaterThan(ParameterUtil.named("余额"), request.getBalance(), BigDecimal.ZERO) + // 必须是枚举值 + .addMustEnum(ParameterUtil.named("性别"), request.getSex(), ESex.class) + // 必须是日期字符串(yyyy-MM-dd) + .addMustDate(ParameterUtil.named("生日"), request.getBirthday()) + // 必须大于0 + .addGreater(ParameterUtil.named("排序值"), request.getSort(), 0) + // 限制最大长度 + .addLengthMax(ParameterUtil.named("备注"), request.getComment(), ConstantFactory.LENGTH_MAX500); + ParameterValidateResult result = validator.validate(); + if (result.getIsFiled()) { + return failed(result.getErrorMsg()); + } + //#endregion + return this.service.create(request); + } + + /** + * 编辑[测试信息] + * + * @author lin.liu + * @date 2021/11/23 + */ + @PostMapping(value = "modify") + public ExecutedResult<String> modify(@RequestBody ReqModifyTestInfo request) { + //#region 参数验证 + ParameterValidator validator = new ParameterValidator() + // 必须大于0 + .addGreater(ParameterUtil.named("[测试信息]id"), request.getId(), 0L) + // 非空 + .addNotNullOrEmpty(ParameterUtil.named("名称"), request.getName()) + // 限制最大长度 + .addLengthMax(ParameterUtil.named("名称"), request.getName(), ConstantFactory.LENGTH_MAX50) + // 必须大于0 + .addGreater(ParameterUtil.named("用户id"), request.getUserId(), 0L) + // 必须是手机号码(正则) + .addMustMobile(ParameterUtil.named("电话"), request.getPhone()) + // 金额大于0 + .addGreaterThan(ParameterUtil.named("余额"), request.getBalance(), BigDecimal.ZERO) + // 必须是枚举值 + .addMustEnum(ParameterUtil.named("性别"), request.getSex(), ESex.class) + // 必须是日期字符串(yyyy-MM-dd) + .addMustDate(ParameterUtil.named("生日"), request.getBirthday()) + // 必须大于0 + .addGreater(ParameterUtil.named("排序值"), request.getSort(), 0) + // 限制最大长度 + .addLengthMax(ParameterUtil.named("备注"), request.getComment(), ConstantFactory.LENGTH_MAX500); + ParameterValidateResult result = validator.validate(); + if (result.getIsFiled()) { + return failed(result.getErrorMsg()); + } + //#endregion + return this.service.modify(request); + } + + /** + * 获取[测试信息] + * + * @author lin.liu + * @date 2021/11/23 + */ + @GetMapping(value = "get/{id}") + public ExecutedResult<TestInfoVO> get(@PathVariable Long id) { + return this.service.get(id); + } + + /** + * 根据id批量获取[测试信息] + * + * @author lin.liu + * @date 2021/11/23 + */ + @PostMapping(value = "getList") + public ExecutedResult<List<TestInfoVO>> getList(@RequestBody ReqListId request) { + //#region 参数验证 + ParameterValidator validator = new ParameterValidator() + // 不能为空 + .addNotNullOrEmpty(ParameterUtil.named("[测试信息]id列表"), request.getListId()) + ; + ParameterValidateResult result = validator.validate(); + if (result.getIsFiled()) { + return failed(result.getErrorMsg()); + } + //#endregion + return this.service.getList(request.getListId()); + } + + /** + * [测试信息]设置排序值 + * + * @author lin.liu + * @date 2021/11/23 + */ + @PostMapping(value = "setSort") + public ExecutedResult<String> setSort(@RequestBody ReqSetSort request) { + //#region 参数验证 + ParameterValidator validator = new ParameterValidator() + // 必须大于0 + .addGreater(ParameterUtil.named("[测试信息]id"), request.getId(), 0L) + // 必须大于0 + .addGreaterThan(ParameterUtil.named("排序值"), request.getSort(), 0) + ; + ParameterValidateResult result = validator.validate(); + if (result.getIsFiled()) { + return failed(result.getErrorMsg()); + } + //#endregion + return this.service.setSort(request); + } + + /** + * [测试信息]批量设置排序值 + * + * @author lin.liu + * @date 2021/11/23 + */ + @PostMapping(value = "listSetSort") + ExecutedResult<String> listSetSort(ReqListSetSort request) { + //#region 参数验证 + ParameterValidator validator = new ParameterValidator() + // 不能为空 + .addNotNullOrEmpty(ParameterUtil.named("[测试信息]排序设置列表"), request.getList()) + ; + ParameterValidateResult result = validator.validate(); + if (result.getIsFiled()) { + return failed(result.getErrorMsg()); + } + //#endregion + return this.service.listSetSort(request); + } + + /** + * 停用[测试信息] + * + * @param id [测试]id + * @author lin.liu + * @date 2021/11/23 + */ + @PostMapping(value = "stop/{id}") + public ExecutedResult<String> stop(@PathVariable Long id) { + return this.service.stop(id); + } + + /** + * 启用[测试信息] + * + * @param id [测试]id + * @author lin.liu + * @date 2021/11/23 + */ + @PostMapping(value = "enable/{id}") + public ExecutedResult<String> enable(@PathVariable Long id) { + return this.service.enable(id); + } + + /** + * 删除[测试信息] + * + * @param id [测试]id + * @author lin.liu + * @date 2021/11/23 + */ + @PostMapping(value = "remove/{id}") + public ExecutedResult<String> remove(@PathVariable Long id) { + return this.service.remove(id); + } + + /** + * 批量删除[测试信息] + * + * @author lin.liu + * @date 2021/11/23 + */ + @PostMapping(value = "removeList") + public ExecutedResult<String> removeList(@RequestBody ReqListId request) { + //#region 参数验证 + ParameterValidator validator = new ParameterValidator() + // 不能为空 + .addNotNullOrEmpty(ParameterUtil.named("[测试信息]id列表"), request.getListId()) + ; + ParameterValidateResult result = validator.validate(); + if (result.getIsFiled()) { + return failed(result.getErrorMsg()); + } + //#endregion + return this.service.removeList(request.getListId()); + } + + /** + * 查询[测试信息] + * + * @author lin.liu + * @date 2021/11/23 + */ + @NonLogin + @PostMapping(value = "search") + public ExecutedResult<PagerResult<TestInfoVO>> search(@RequestBody SearchTestInfo request) { + return this.service.search(request); + } +} diff --git a/src/main/java/com/fengdu/gas/host/controller/admin/AdminMenuController.java b/src/main/java/com/fengdu/gas/host/controller/admin/AdminMenuController.java new file mode 100644 index 0000000..2db8b38 --- /dev/null +++ b/src/main/java/com/fengdu/gas/host/controller/admin/AdminMenuController.java @@ -0,0 +1,273 @@ +package com.fengdu.gas.host.controller.admin; + +import com.fengdu.gas.common.ConstantFactory; +import com.fengdu.gas.common.ExecutedResult; +import com.fengdu.gas.common.PagerResult; +import com.fengdu.gas.common.util.ParameterUtil; +import com.fengdu.gas.common.validator.ParameterValidateResult; +import com.fengdu.gas.common.validator.ParameterValidator; +import com.fengdu.gas.entity.enums.EMenuType; +import com.fengdu.gas.entity.enums.EState; +import com.fengdu.gas.entity.request.ReqListId; +import com.fengdu.gas.entity.request.ReqListSetSort; +import com.fengdu.gas.entity.request.ReqSetSort; +import com.fengdu.gas.entity.request.adminmenu.ReqCreateAdminMenu; +import com.fengdu.gas.entity.request.adminmenu.ReqModifyAdminMenu; +import com.fengdu.gas.entity.response.admin.ResAdminMenuTreeAndPermission; +import com.fengdu.gas.entity.search.SearchAdminMenu; +import com.fengdu.gas.service.AdminPowerService; +import com.fengdu.gas.host.BasicController; +import com.fengdu.gas.host.api.MustAdmin; +import com.fengdu.gas.repository.vo.AdminMenuVO; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 10.菜单相关接口 + * + * @author lin.liu + * @date 2023/02/17 + * @order 10 + */ +@RestController +@RequestMapping(value = "admin/menu") +public class AdminMenuController extends BasicController { + @Autowired + private AdminPowerService service; + + /** + * 创建菜单 + * + * @author lin.liu + * @date 2023/02/17 + */ + @MustAdmin + @PostMapping(value = "create") + public ExecutedResult<Long> create(@RequestBody ReqCreateAdminMenu request) { + //#region 参数验证 + ParameterValidator validator = new ParameterValidator() + // 必须是枚举值 + .addMustEnum(ParameterUtil.named("类型"), request.getType(), EMenuType.class) + // 非空 + .addNotNullOrEmpty(ParameterUtil.named("菜单名称"), request.getName()) + // 限制长度 + .addLengthMax(ParameterUtil.named("菜单名称"), request.getName(), ConstantFactory.LENGTH_MAX20) + // 限制长度 + .addLengthMax(ParameterUtil.named("菜单标题"), request.getTitle(), ConstantFactory.LENGTH_MAX100) + // 限制长度 + .addLengthMax(ParameterUtil.named("前端资源路径"), request.getUrl(), ConstantFactory.LENGTH_MAX200) + // 限制长度 + .addLengthMax(ParameterUtil.named("图标"), request.getIcon(), ConstantFactory.LENGTH_MAX200) + ; + ParameterValidateResult result = validator.validate(); + if (result.getIsFiled()) { + return ExecutedResult.failed(result.getErrorMsg()); + } + //#endregion + return this.service.createMenu(request); + } + + /** + * 编辑菜单 + * + * @author lin.liu + * @date 2023/02/17 + */ + @MustAdmin + @PostMapping(value = "modify") + public ExecutedResult<String> modify(@RequestBody ReqModifyAdminMenu request) { + //#region 参数验证 + ParameterValidator validator = new ParameterValidator() + // 必须是枚举值 + .addMustEnum(ParameterUtil.named("类型"), request.getType(), EMenuType.class) + // 非空 + .addNotNullOrEmpty(ParameterUtil.named("菜单名称"), request.getName()) + // 限制长度 + .addLengthMax(ParameterUtil.named("菜单名称"), request.getName(), ConstantFactory.LENGTH_MAX20) + // 限制长度 + .addLengthMax(ParameterUtil.named("菜单标题"), request.getTitle(), ConstantFactory.LENGTH_MAX100) + // 限制长度 + .addLengthMax(ParameterUtil.named("前端资源路径"), request.getUrl(), ConstantFactory.LENGTH_MAX200) + // 限制长度 + .addLengthMax(ParameterUtil.named("图标"), request.getIcon(), ConstantFactory.LENGTH_MAX200) + ; + ParameterValidateResult result = validator.validate(); + if (result.getIsFiled()) { + return ExecutedResult.failed(result.getErrorMsg()); + } + //#endregion + return this.service.modifyMenu(request); + } + + /** + * 停用菜单 + * + * @param menuId 菜单id + * @author lin.liu + * @date 2023/02/17 + */ + @MustAdmin + @PostMapping(value = "stop/{menuId}") + public ExecutedResult<String> stop(@PathVariable Long menuId) { + //#region 参数验证 + ParameterValidator validator = new ParameterValidator() + .addGreater(ParameterUtil.named("菜单id"), menuId, 0L); + ParameterValidateResult result = validator.validate(); + if (result.getIsFiled()) { + return ExecutedResult.failed(result.getErrorMsg()); + } + //#endregion + return this.service.changeMenuStatus(menuId, EState.DISABLED); + } + + /** + * 启用菜单 + * + * @param menuId 菜单id + * @author lin.liu + * @date 2023/02/17 + */ + @MustAdmin + @PostMapping(value = "enable/menuId") + public ExecutedResult<String> enable(@PathVariable Long menuId) { + //#region 参数验证 + ParameterValidator validator = new ParameterValidator() + .addGreater(ParameterUtil.named("菜单id"), menuId, 0L); + ParameterValidateResult result = validator.validate(); + if (result.getIsFiled()) { + return ExecutedResult.failed(result.getErrorMsg()); + } + //#endregion + return this.service.changeMenuStatus(menuId, EState.NORMAL); + } + + /** + * [菜单]设置排序值 + * + * @author lin.liu + * @date 2021/11/23 + */ + @PostMapping(value = "setSort") + public ExecutedResult<String> setSort(@RequestBody ReqSetSort request) { + //#region 参数验证 + ParameterValidator validator = new ParameterValidator() + // 必须大于0 + .addGreater(ParameterUtil.named("菜单id"), request.getId(), 0L) + // 必须大于0 + .addGreaterThan(ParameterUtil.named("排序值"), request.getSort(), 0) + ; + ParameterValidateResult result = validator.validate(); + if (result.getIsFiled()) { + return failed(result.getErrorMsg()); + } + //#endregion + return this.service.setMenuSort(request); + } + + /** + * [菜单]批量设置排序值 + * + * @author lin.liu + * @date 2021/11/23 + */ + @PostMapping(value = "listSetSort") + ExecutedResult<String> listSetSort(ReqListSetSort request) { + //#region 参数验证 + ParameterValidator validator = new ParameterValidator() + // 不能为空 + .addNotNullOrEmpty(ParameterUtil.named("菜单排序设置列表"), request.getList()) + ; + ParameterValidateResult result = validator.validate(); + if (result.getIsFiled()) { + return failed(result.getErrorMsg()); + } + //#endregion + return this.service.listSetMenuSort(request); + } + + /** + * 删除菜单 + * + * @param menuId 菜单id + * @author lin.liu + * @date 2023/02/17 + */ + @MustAdmin + @PostMapping(value = "remove/{menuId}") + public ExecutedResult<String> remove(@PathVariable Long menuId) { + //#region 参数验证 + ParameterValidator validator = new ParameterValidator() + .addGreater(ParameterUtil.named("菜单id"), menuId, 0L); + ParameterValidateResult result = validator.validate(); + if (result.getIsFiled()) { + return ExecutedResult.failed(result.getErrorMsg()); + } + //#endregion + return this.service.removeMenu(menuId); + } + + /** + * 批量删除[删除菜单] + * + * @author lin.liu + * @date 2021/11/23 + */ + @PostMapping(value = "removeList") + public ExecutedResult<String> removeList(@RequestBody ReqListId request) { + //#region 参数验证 + ParameterValidator validator = new ParameterValidator() + // 不能为空 + .addNotNullOrEmpty(ParameterUtil.named("[测试信息]id列表"), request.getListId()) + ; + ParameterValidateResult result = validator.validate(); + if (result.getIsFiled()) { + return failed(result.getErrorMsg()); + } + //#endregion + return this.service.removeMenuList(request.getListId()); + } + + /** + * 获取所有层级菜单(只返回状态正常的数据) + * + * @author lin.liu + * @date 2023/02/17 + */ + @GetMapping(value = "getListTree") + public ExecutedResult<List<ResAdminMenuTreeAndPermission>> getListTree() { + return this.service.getListTreeMenu(); + } + + /** + * 获取指定菜单的子级菜单 + * + * @param menuId 菜单id + * @author lin.liu + * @date 2023/02/17 + */ + @GetMapping(value = "getListChild/{menuId}") + public ExecutedResult<List<AdminMenuVO>> getListChild(@PathVariable Long menuId) { + //#region 参数验证 + ParameterValidator validator = new ParameterValidator() + .addGreater(ParameterUtil.named("菜单id"), menuId, 0L); + ParameterValidateResult result = validator.validate(); + if (result.getIsFiled()) { + return ExecutedResult.failed(result.getErrorMsg()); + } + //#endregion + return this.service.getListChildMenu(menuId); + } + + /** + * 分页查询菜单 + * + * @author lin.liu + * @date 2023/02/17 + */ + @PostMapping(value = "search") + public ExecutedResult<PagerResult<AdminMenuVO>> search(@RequestBody SearchAdminMenu request) { + return this.service.searchMenu(request); + } +} diff --git a/src/main/java/com/fengdu/gas/host/controller/admin/AdminPermissionController.java b/src/main/java/com/fengdu/gas/host/controller/admin/AdminPermissionController.java new file mode 100644 index 0000000..b64aa0c --- /dev/null +++ b/src/main/java/com/fengdu/gas/host/controller/admin/AdminPermissionController.java @@ -0,0 +1,120 @@ +package com.fengdu.gas.host.controller.admin; + +import com.fengdu.gas.common.ConstantFactory; +import com.fengdu.gas.common.ExecutedResult; +import com.fengdu.gas.common.PagerResult; +import com.fengdu.gas.common.util.ParameterUtil; +import com.fengdu.gas.common.validator.ParameterValidateResult; +import com.fengdu.gas.common.validator.ParameterValidator; +import com.fengdu.gas.entity.enums.EState; +import com.fengdu.gas.entity.request.adminpermission.ReqCreateAdminPermission; +import com.fengdu.gas.entity.request.adminpermission.ReqModifyAdminPermission; +import com.fengdu.gas.entity.response.admin.ResAdminPermission; +import com.fengdu.gas.entity.search.SearchAdminPermission; +import com.fengdu.gas.service.AdminPowerService; +import com.fengdu.gas.host.api.MustAdmin; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +/** + * 20.权限相关接口 + * + * @author lin.liu + * @date 2023/02/17 + * @order 20 + */ +@MustAdmin +@RestController +@RequestMapping(value = "admin/permission") +public class AdminPermissionController { + @Autowired + private AdminPowerService service; + + + /** + * 创建权限 + * + * @author lin.liu + * @date 2023/02/17 + */ + @PostMapping(value = "create") + public ExecutedResult<Long> create(@RequestBody ReqCreateAdminPermission request) { + //#region 参数验证 + ParameterValidator validator = new ParameterValidator() + .addNotNullOrEmpty(ParameterUtil.named("权限值"), request.getSn()) + .addLengthMax(ParameterUtil.named("权限值"), request.getSn(), ConstantFactory.LENGTH_MAX50) + .addGreater(ParameterUtil.named("菜单id"), request.getMenuId(), 0) + .addLengthMax(ParameterUtil.named("前端资源url"), request.getMenuUrl(), ConstantFactory.LENGTH_MAX200) + .addNotNullOrEmpty(ParameterUtil.named("权限名称"), request.getName()) + .addLengthMax(ParameterUtil.named("权限名称"), request.getName(), ConstantFactory.LENGTH_MAX50) + .addLengthMax(ParameterUtil.named("图标"), request.getIcon(), ConstantFactory.LENGTH_MAX200) + .addLengthMax(ParameterUtil.named("类型"), request.getType(), ConstantFactory.LENGTH_MAX50) + ; + ParameterValidateResult result = validator.validate(); + if (result.getIsFiled()) { + return ExecutedResult.failed(result.getErrorMsg()); + } + //#endregion + return this.service.createPermission(request); + } + + /** + * 编辑权限 + * + * @author lin.liu + * @date 2023/02/17 + */ + @PostMapping(value = "modify") + public ExecutedResult<String> modify(@RequestBody ReqModifyAdminPermission request) { + //#region 参数验证 + ParameterValidator validator = new ParameterValidator() + .addNotNullOrEmpty(ParameterUtil.named("权限值"), request.getSn()) + .addLengthMax(ParameterUtil.named("权限值"), request.getSn(), ConstantFactory.LENGTH_MAX50) + .addGreater(ParameterUtil.named("菜单id"), request.getMenuId(), 0) + .addLengthMax(ParameterUtil.named("前端资源url"), request.getMenuUrl(), ConstantFactory.LENGTH_MAX200) + .addNotNullOrEmpty(ParameterUtil.named("权限名称"), request.getName()) + .addLengthMax(ParameterUtil.named("权限名称"), request.getName(), ConstantFactory.LENGTH_MAX50) + .addLengthMax(ParameterUtil.named("图标"), request.getIcon(), ConstantFactory.LENGTH_MAX200) + .addLengthMax(ParameterUtil.named("类型"), request.getType(), ConstantFactory.LENGTH_MAX50) + // 必须是枚举 + .addMustEnum(ParameterUtil.named("状态"), request.getStatus(), EState.class) + ; + ParameterValidateResult result = validator.validate(); + if (result.getIsFiled()) { + return ExecutedResult.failed(result.getErrorMsg()); + } + //#endregion + return this.service.modifyPermission(request); + } + + /** + * 删除权限 + * + * @param powerId 权限id + * @author lin.liu + * @date 2023/02/17 + */ + @GetMapping(value = "remove/{powerId}") + public ExecutedResult<String> remove(@PathVariable Long powerId) { + //#region 参数验证 + ParameterValidator validator = new ParameterValidator() + .addGreater(ParameterUtil.named("权限id"), powerId, 0L); + ParameterValidateResult result = validator.validate(); + if (result.getIsFiled()) { + return ExecutedResult.failed(result.getErrorMsg()); + } + //#endregion + return this.service.removePermission(powerId); + } + + /** + * 分页查询权限 + * + * @author lin.liu + * @date 2023/02/17 + */ + @PostMapping(value = "search") + public ExecutedResult<PagerResult<ResAdminPermission>> search(@RequestBody SearchAdminPermission request) { + return this.service.searchPermission(request); + } +} diff --git a/src/main/java/com/fengdu/gas/host/controller/admin/AdminRoleController.java b/src/main/java/com/fengdu/gas/host/controller/admin/AdminRoleController.java new file mode 100644 index 0000000..60778d1 --- /dev/null +++ b/src/main/java/com/fengdu/gas/host/controller/admin/AdminRoleController.java @@ -0,0 +1,319 @@ +package com.fengdu.gas.host.controller.admin; + +import com.fengdu.gas.common.ExecutedResult; +import com.fengdu.gas.common.util.ParameterUtil; +import com.fengdu.gas.common.validator.ParameterValidateResult; +import com.fengdu.gas.common.validator.ParameterValidator; +import com.fengdu.gas.entity.enums.EState; +import com.fengdu.gas.entity.request.ReqListId; +import com.fengdu.gas.entity.request.ReqListSetSort; +import com.fengdu.gas.entity.request.ReqSetSort; +import com.fengdu.gas.entity.request.adminrole.ReqCreateAdminRole; +import com.fengdu.gas.entity.request.adminrole.ReqModifyAdminRole; +import com.fengdu.gas.entity.request.adminrolemenurelation.ReqSetListMenu4Role; +import com.fengdu.gas.entity.request.adminuser.ReqSetListRole4Admin; +import com.fengdu.gas.entity.response.admin.ResAdminPower; +import com.fengdu.gas.entity.search.SearchAdminRole; +import com.fengdu.gas.service.AdminPowerService; +import com.fengdu.gas.service.AdminService; +import com.fengdu.gas.host.BasicController; +import com.fengdu.gas.host.api.MustAdmin; +import com.fengdu.gas.common.ConstantFactory; +import com.fengdu.gas.common.PagerResult; +import com.fengdu.gas.repository.vo.AdminRoleVO; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 30.角色相关接口 + * + * @author lin.liu + * @date 2023/02/17 + * @order 30 + */ + +@RestController +@RequestMapping(value = "admin/role") +public class AdminRoleController extends BasicController { + @Autowired + private AdminPowerService service; + @Autowired + private AdminService adminService; + + /** + * 创建角色 + * + * @author lin.liu + * @date 2023/02/17 + */ + @MustAdmin + @PostMapping(value = "create") + public ExecutedResult<Long> create(@RequestBody ReqCreateAdminRole request) { + //#region 参数验证 + ParameterValidator validator = new ParameterValidator() + // 非空 + .addNotNullOrEmpty(ParameterUtil.named("角色名称"), request.getName()) + // 限制长度 + .addLengthMax(ParameterUtil.named("角色名称"), request.getName(), ConstantFactory.LENGTH_MAX20) + // 限制长度 + .addLengthMax(ParameterUtil.named("描述"), request.getDescription(), ConstantFactory.LENGTH_MAX100) + ; + ParameterValidateResult result = validator.validate(); + if (result.getIsFiled()) { + return ExecutedResult.failed(result.getErrorMsg()); + } + //#endregion + return service.createRole(request); + } + + /** + * 编辑角色 + * + * @author lin.liu + * @date 2023/02/17 + */ + @MustAdmin + @PostMapping(value = "modify") + public ExecutedResult<String> modify(@RequestBody ReqModifyAdminRole request) { + //#region 参数验证 + ParameterValidator validator = new ParameterValidator() + // 必须大于0 + .addGreater(ParameterUtil.named("角色id"), request.getId(), 0L) + // 非空 + .addNotNullOrEmpty(ParameterUtil.named("角色名称"), request.getName()) + // 限制长度 + .addLengthMax(ParameterUtil.named("角色名称"), request.getName(), ConstantFactory.LENGTH_MAX100) + // 限制长度 + .addLengthMax(ParameterUtil.named("描述"), request.getDescription(), ConstantFactory.LENGTH_MAX200) + // 必须是枚举值 + .addMustEnum(ParameterUtil.named("状态"), request.getStatus(), EState.class) + ; + ParameterValidateResult result = validator.validate(); + if (result.getIsFiled()) { + return ExecutedResult.failed(result.getErrorMsg()); + } + //#endregion + return service.modifyRole(request); + } + + /** + * 停用角色 + * + * @param roleId 角色id + * @author lin.liu + * @date 2023/02/17 + */ + @MustAdmin + @PostMapping(value = "stop/{roleId}") + public ExecutedResult<String> stop(@PathVariable Long roleId) { + //#region 参数验证 + ParameterValidator validator = new ParameterValidator() + .addGreater(ParameterUtil.named("角色id"), roleId, 0L); + ParameterValidateResult result = validator.validate(); + if (result.getIsFiled()) { + return ExecutedResult.failed(result.getErrorMsg()); + } + //#endregion + return service.changeRoleStatus(roleId, EState.DISABLED); + } + + /** + * 启用角色 + * + * @param roleId 角色id + * @author lin.liu + * @date 2023/02/17 + */ + @MustAdmin + @PostMapping(value = "enable/{roleId}") + public ExecutedResult<String> enable(@PathVariable Long roleId) { + //#region 参数验证 + ParameterValidator validator = new ParameterValidator() + .addGreater(ParameterUtil.named("角色id"), roleId, 0L); + ParameterValidateResult result = validator.validate(); + if (result.getIsFiled()) { + return ExecutedResult.failed(result.getErrorMsg()); + } + //#endregion + return service.changeRoleStatus(roleId, EState.NORMAL); + } + + /** + * [角色]设置排序值 + * + * @author lin.liu + * @date 2021/11/23 + */ + @PostMapping(value = "setSort") + public ExecutedResult<String> setSort(@RequestBody ReqSetSort request) { + //#region 参数验证 + ParameterValidator validator = new ParameterValidator() + // 必须大于0 + .addGreater(ParameterUtil.named("角色id"), request.getId(), 0L) + // 必须大于0 + .addGreaterThan(ParameterUtil.named("排序值"), request.getSort(), 0) + ; + ParameterValidateResult result = validator.validate(); + if (result.getIsFiled()) { + return failed(result.getErrorMsg()); + } + //#endregion + return this.service.setRoleSort(request); + } + + /** + * [角色]批量设置排序值 + * + * @author lin.liu + * @date 2021/11/23 + */ + @PostMapping(value = "listSetSort") + ExecutedResult<String> listSetSort(ReqListSetSort request) { + //#region 参数验证 + ParameterValidator validator = new ParameterValidator() + // 不能为空 + .addNotNullOrEmpty(ParameterUtil.named("角色排序设置列表"), request.getList()) + ; + ParameterValidateResult result = validator.validate(); + if (result.getIsFiled()) { + return failed(result.getErrorMsg()); + } + //#endregion + return this.service.listSetRoleSort(request); + } + + /** + * 删除角色 + * + * @param roleId 角色id + * @author lin.liu + * @date 2023/02/17 + */ + @MustAdmin + @PostMapping(value = "remove/{roleId}") + public ExecutedResult<String> remove(@PathVariable Long roleId) { + //#region 参数验证 + ParameterValidator validator = new ParameterValidator() + .addGreater(ParameterUtil.named("角色id"), roleId, 0L); + ParameterValidateResult result = validator.validate(); + if (result.getIsFiled()) { + return ExecutedResult.failed(result.getErrorMsg()); + } + //#endregion + return service.removeRole(roleId); + } + + /** + * 批量删除角色 + * @param request 请求参数 + * @author lin.liu + * @date 2021/11/23 + */ + @PostMapping(value = "removeList") + public ExecutedResult<String> removeList(@RequestBody ReqListId request) { + //#region 参数验证 + ParameterValidator validator = new ParameterValidator() + // 不能为空 + .addNotNullOrEmpty(ParameterUtil.named("角色id列表"), request.getListId()) + ; + ParameterValidateResult result = validator.validate(); + if (result.getIsFiled()) { + return failed(result.getErrorMsg()); + } + //#endregion + return this.service.removeRoleList(request.getListId()); + } + + /** + * 分页查询角色 + * + * @author lin.liu + * @date 2023/02/17 + */ + @PostMapping(value = "search") + public ExecutedResult<PagerResult<AdminRoleVO>> search(@RequestBody SearchAdminRole request) { + return this.service.searchRole(request); + } + + /** + * 设置角色菜单权限列表 + * + * @author lin.liu + * @date 2023/02/17 + */ + @MustAdmin + @PostMapping(value = "setListMenuAndPermission") + public ExecutedResult<String> setListMenuAndPermission(@RequestBody ReqSetListMenu4Role request) { + //#region 参数验证 + ParameterValidator validator = new ParameterValidator() + .addGreater(ParameterUtil.named("角色id"), request.getId(), 0); + ParameterValidateResult result = validator.validate(); + if (result.getIsFiled()) { + return ExecutedResult.failed(result.getErrorMsg()); + } + //#endregion + return service.setListMenu4Role(request); + } + + /** + * 获取角色菜单权限列表 + * + * @param roleId 角色id + * @author lin.liu + * @date 2023/02/17 + */ + @GetMapping(value = "getListMenuAndPermission/{roleId}") + public ExecutedResult<ResAdminPower> getListMenuAndPermission(@PathVariable Long roleId) { + //#region 参数验证 + ParameterValidator validator = new ParameterValidator() + .addGreater(ParameterUtil.named("角色id"), roleId, 0); + ParameterValidateResult result = validator.validate(); + if (result.getIsFiled()) { + return ExecutedResult.failed(result.getErrorMsg()); + } + //#endregion + return service.getListMenu4Role(roleId); + } + + /** + * 设置管理员的角色列表 + * + * @author lin.liu + * @date 2023/02/17 + */ + @MustAdmin + @PostMapping(value = "setListRole4Admin") + public ExecutedResult<String> setListRole4Admin(@RequestBody ReqSetListRole4Admin request) { + //#region 参数验证 + ParameterValidator validator = new ParameterValidator() + .addGreater(ParameterUtil.named("管理员id"), request.getId(), 0); + ParameterValidateResult result = validator.validate(); + if (result.getIsFiled()) { + return ExecutedResult.failed(result.getErrorMsg()); + } + //#endregion + return adminService.setListRole4Admin(request); + } + + /** + * 获取管理员的角色列表 + * + * @param adminId 管理员id + * @author lin.liu + * @date 2023/02/17 + */ + @GetMapping(value = "getListRole4Admin") + public ExecutedResult<List<AdminRoleVO>> getListRole4Admin(@RequestParam Long adminId) { + //#region 参数验证 + ParameterValidator validator = new ParameterValidator() + .addGreater(ParameterUtil.named("管理员id"), adminId, 0); + ParameterValidateResult result = validator.validate(); + if (result.getIsFiled()) { + return ExecutedResult.failed(result.getErrorMsg()); + } + //#endregion + return adminService.getListRole4Admin(adminId); + } +} diff --git a/src/main/java/com/fengdu/gas/host/controller/admin/AdminUserController.java b/src/main/java/com/fengdu/gas/host/controller/admin/AdminUserController.java new file mode 100644 index 0000000..679d07d --- /dev/null +++ b/src/main/java/com/fengdu/gas/host/controller/admin/AdminUserController.java @@ -0,0 +1,265 @@ +package com.fengdu.gas.host.controller.admin; + +import com.fengdu.gas.common.ConstantFactory; +import com.fengdu.gas.common.ExecutedResult; +import com.fengdu.gas.common.PagerResult; +import com.fengdu.gas.common.jwt.LoginUserDTO; +import com.fengdu.gas.common.util.ParameterUtil; +import com.fengdu.gas.common.validator.ParameterValidateResult; +import com.fengdu.gas.common.validator.ParameterValidator; +import com.fengdu.gas.entity.enums.EState; +import com.fengdu.gas.entity.enums.EUserType; +import com.fengdu.gas.entity.request.ReqChangePassword; +import com.fengdu.gas.entity.request.adminuser.ReqAdminLogin; +import com.fengdu.gas.entity.request.adminuser.ReqCreateAdminUser; +import com.fengdu.gas.entity.request.adminuser.ReqModifyAdminUser; +import com.fengdu.gas.entity.response.admin.ResAdminLogin; +import com.fengdu.gas.entity.response.admin.ResAdminPower; +import com.fengdu.gas.entity.search.SearchAdminUser; +import com.fengdu.gas.service.AdminPowerService; +import com.fengdu.gas.service.AdminService; +import com.fengdu.gas.service.dto.ResAdminDetail; +import com.fengdu.gas.host.BasicController; +import com.fengdu.gas.host.api.MustAdmin; +import com.fengdu.gas.host.api.NonLogin; +import com.fengdu.gas.repository.vo.AdminUserVO; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +/** + * 40.管理员用户相关接口 + * + * @author lin.liu + * @date 2023/02/17 + * @order 40 + */ +@RestController +@RequestMapping("admin/user") +public class AdminUserController extends BasicController { + @Autowired + private AdminService service; + @Autowired + private AdminPowerService adminPowerService; + + /** + * 添加后台管理员 + * + * @param request 请求参数 + * @author lin.liu + * @date 2023/02/17 + */ + @MustAdmin + @PostMapping("add") + public ExecutedResult<Long> add(@RequestBody ReqCreateAdminUser request) { + //#region 参数验证 + ParameterValidator validator = new ParameterValidator() + .addMustEnum(ParameterUtil.named("用户类型"), request.getUserType(), EUserType.class) + .addNotNullOrEmpty(ParameterUtil.named("用户名"), request.getUserName()) + .addLengthMax(ParameterUtil.named("用户名"), request.getUserName(), ConstantFactory.LENGTH_MAX100) + .addNotNullOrEmpty(ParameterUtil.named("密码"), request.getPassword()) + .addLengthMax(ParameterUtil.named("密码"), request.getPassword(), ConstantFactory.LENGTH_MAX50) + .addLengthMax(ParameterUtil.named("昵称"), request.getNickName(), ConstantFactory.LENGTH_MAX50) + .addLengthMax(ParameterUtil.named("头像"), request.getHeadImg(), ConstantFactory.LENGTH_MAX500) + .addLengthMax(ParameterUtil.named("联系方式"), request.getContact(), ConstantFactory.LENGTH_MAX50) + .addLengthMax(ParameterUtil.named("联系邮箱"), request.getEmail(), ConstantFactory.LENGTH_MAX50); + ParameterValidateResult result = validator.validate(); + if (result.getIsFiled()) { + return ExecutedResult.failed(result.getErrorMsg()); + } + //#endregion + return service.createAdmin(request); + } + + /** + * 修改后台管理员 + * + * @param request 请求参数 + * @author lin.liu + * @date 2023/02/17 + */ + @MustAdmin + @PostMapping("modify") + public ExecutedResult<String> modify(@RequestBody ReqModifyAdminUser request) { + //#region 参数验证 + ParameterValidator validator = new ParameterValidator() + .addGreater(ParameterUtil.named("用户id"), request.getId(), 0L) + .addMustEnum(ParameterUtil.named("用户类型"), request.getUserType(), EUserType.class) + .addMustEnum(ParameterUtil.named("状态"), request.getStatus(), EState.class) + .addLengthMax(ParameterUtil.named("昵称"), request.getNickName(), ConstantFactory.LENGTH_MAX50) + .addLengthMax(ParameterUtil.named("头像"), request.getHeadImg(), ConstantFactory.LENGTH_MAX500) + .addLengthMax(ParameterUtil.named("联系方式"), request.getContact(), ConstantFactory.LENGTH_MAX50) + .addLengthMax(ParameterUtil.named("联系邮箱"), request.getEmail(), ConstantFactory.LENGTH_MAX50); + ParameterValidateResult result = validator.validate(); + if (result.getIsFiled()) { + return ExecutedResult.failed(result.getErrorMsg()); + } + //#endregion + return service.modify(request); + } + + /** + * 获取指定管理员详情 + * + * @param userId 用户id + * @author lin.liu + * @date 2023/02/17 + */ + @GetMapping("detail/{userId}") + public ExecutedResult<ResAdminDetail> detail(@PathVariable Long userId) { + //#region 参数验证 + ParameterValidator validator = new ParameterValidator() + .addGreater(ParameterUtil.named("用户id"), userId, 0L); + ParameterValidateResult result = validator.validate(); + if (result.getIsFiled()) { + return ExecutedResult.failed(result.getErrorMsg()); + } + //#endregion + return service.detail(userId); + } + + /** + * 分页查询所有管理员 + * + * @param request 查询参数 + * @author lin.liu + * @date 2023/02/17 + */ + @MustAdmin + @PostMapping("search") + public ExecutedResult<PagerResult<AdminUserVO>> search(@RequestBody SearchAdminUser request) { + //#region 参数验证 + ParameterValidator validator = new ParameterValidator(); + ParameterValidateResult result = validator.validate(); + if (result.getIsFiled()) { + return ExecutedResult.failed(result.getErrorMsg()); + } + //#endregion + return service.search(request); + } + + /** + * 管理员登录 + * + * @param request 请求参数 + * @author lin.liu + * @date 2023/02/17 + */ + @PostMapping("login") + @NonLogin + public ExecutedResult<ResAdminLogin> adminLogin(@RequestBody ReqAdminLogin request) { + //#region 参数验证 + ParameterValidator validator = new ParameterValidator() + .addNotNullOrEmpty(ParameterUtil.named("用户名"), request.getUserName()) + .addNotNullOrEmpty(ParameterUtil.named("密码"), request.getPassword()); + ParameterValidateResult result = validator.validate(); + if (result.getIsFiled()) { + return ExecutedResult.failed(result.getErrorMsg()); + } + //#endregion + return service.adminLogin(request); + } + + + /** + * 获取管理员权限列表 + * + * @param userId 用户id + * @author lin.liu + * @date 2023/02/17 + */ + @GetMapping("getPower/{userId}") + public ExecutedResult<ResAdminPower> getPower(@PathVariable Long userId) { + return service.getPower(userId); + } + + /** + * 修改密码 + * + * @param request 请求参数 + * @author lin.liu + * @date 2023/02/17 + */ + @PostMapping("changePassword") + public ExecutedResult<String> changePassword(@RequestBody ReqChangePassword request) { + //#region 参数验证 + ParameterValidator validator = new ParameterValidator() + .addNotNullOrEmpty(ParameterUtil.named("旧密码"), request.getOldPassword()) + .addNotNullOrEmpty(ParameterUtil.named("新密码"), request.getNewPassword()) + .addLengthMax(ParameterUtil.named("新密码"), request.getNewPassword(), ConstantFactory.LENGTH_MAX50); + ParameterValidateResult result = validator.validate(); + if (result.getIsFiled()) { + return ExecutedResult.failed(result.getErrorMsg()); + } + //#endregion + LoginUserDTO user = super.getTokenUser(); + return service.changePassword(user, request); + } + + /** + * 重置管理员密码 + * + * @param userId 用户id + * @author lin.liu + * @date 2023/02/17 + */ + @MustAdmin + @PostMapping("resetPassword/{userId}") + public ExecutedResult<String> resetPassword(@PathVariable Long userId) { + //#region 参数验证 + ParameterValidator validator = new ParameterValidator() + .addGreater(ParameterUtil.named("用户id"), userId, 0L); + ParameterValidateResult result = validator.validate(); + if (result.getIsFiled()) { + return ExecutedResult.failed(result.getErrorMsg()); + } + //#endregion + return service.resetPassword(userId); + } + + /** + * 停用管理员帐号 + * + * @param userId 用户id + * @author lin.liu + * @date 2023/02/17 + */ + @MustAdmin + @PostMapping(value = "stop/{userId}") + public ExecutedResult<String> stop(@PathVariable Long userId) { + return this.service.stop(userId); + } + + /** + * 启用管理员帐号 + * + * @param userId 用户id + * @author lin.liu + * @date 2023/02/17 + */ + @MustAdmin + @PostMapping(value = "enable/{userId}") + public ExecutedResult<String> enable(@PathVariable Long userId) { + return this.service.enable(userId); + } + + /** + * 删除管理员 + * + * @param userId 用户id + * @author lin.liu + * @date 2023/02/17 + */ + @MustAdmin + @PostMapping("remove/{userId}") + public ExecutedResult<String> remove(@PathVariable Long userId) { + //#region 参数验证 + ParameterValidator validator = new ParameterValidator() + .addGreater(ParameterUtil.named("用户id"), userId, 0L); + ParameterValidateResult result = validator.validate(); + if (result.getIsFiled()) { + return ExecutedResult.failed(result.getErrorMsg()); + } + //#endregion + return service.remove(userId); + } +} diff --git a/src/main/java/com/fengdu/gas/host/controller/base/BaseController.java b/src/main/java/com/fengdu/gas/host/controller/base/BaseController.java new file mode 100644 index 0000000..47458e2 --- /dev/null +++ b/src/main/java/com/fengdu/gas/host/controller/base/BaseController.java @@ -0,0 +1,49 @@ +package com.fengdu.gas.host.controller.base; + +import com.fengdu.gas.common.ExecutedResult; +import com.fengdu.gas.entity.dto.NameValueDTO; +import com.fengdu.gas.host.api.NonLogin; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.List; + +/** + * 00.基础接口 + * @order 00 + */ +@NonLogin +@RestController +@RequestMapping("base") +public class BaseController { + /** + * 获取指定枚举类型的所有值 + * @param enumName 枚举类型名称 + */ + @GetMapping("listEnumValue/{enumName}") + public ExecutedResult<List<NameValueDTO>> listEnumValue(@PathVariable String enumName) { + try { + Class<?> enumClass = Class.forName("com.fengdu.gas.entity.enums." + enumName); + Method valuesMethod = enumClass.getMethod("values"); + Method getValueMethod = enumClass.getMethod("getValue"); + Method getDescMethod = enumClass.getMethod("getDesc"); + + Object valuesObj = valuesMethod.invoke(enumClass); + Object[] values = (Object[]) valuesObj; + + List<NameValueDTO> result = new ArrayList<>(); + for(Object c : values) { + String value = getValueMethod.invoke(c).toString(); + String desc = getDescMethod.invoke(c).toString(); + result.add(new NameValueDTO(desc, value)); + } + return ExecutedResult.success(result); + } catch (Exception e) { + return ExecutedResult.failed("获取枚举类型失败(" + enumName + "): " + e.getMessage()); + } + } +} diff --git a/src/main/java/com/fengdu/gas/host/controller/base/FileController.java b/src/main/java/com/fengdu/gas/host/controller/base/FileController.java new file mode 100644 index 0000000..1b28480 --- /dev/null +++ b/src/main/java/com/fengdu/gas/host/controller/base/FileController.java @@ -0,0 +1,188 @@ +package com.fengdu.gas.host.controller.base; + +import com.fengdu.gas.common.ConstantFactory; +import com.fengdu.gas.common.ExecutedResult; +import com.fengdu.gas.common.config.SysConfig; +import com.fengdu.gas.common.enums.EContentType; +import com.fengdu.gas.common.util.FileUtil; +import com.fengdu.gas.common.util.LocalDateTimeUtil; +import com.fengdu.gas.common.util.ParameterUtil; +import com.fengdu.gas.common.util.StringUtil; +import com.fengdu.gas.common.validator.EParameterValidateType; +import com.fengdu.gas.entity.dto.NameValueDTO; +import com.fengdu.gas.entity.dto.UploadResultVo; +import com.google.gson.Gson; +import com.fengdu.gas.host.api.NonLogin; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.io.ResourceLoader; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.multipart.MultipartHttpServletRequest; + +import javax.servlet.http.HttpServletRequest; +import java.io.File; +import java.io.FileOutputStream; +import java.io.InputStream; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.stream.Collectors; + +/** + * 01.文件上传 + * @author lin.liu + * @date 2021/11/26 + * @order 01 + */ +@NonLogin +@RestController +@RequestMapping("/file") +public class FileController { + @Autowired + private ResourceLoader resourceLoader; + + /** + * 上传文件 + * + * @param requestMultipart 复杂请求对象 + */ + @PostMapping(value = "upload") + @NonLogin + public ExecutedResult<UploadResultVo> upload(MultipartHttpServletRequest requestMultipart, HttpServletRequest request) throws Exception { + UploadResultVo result = this.defaultResult(); + + Map<String, MultipartFile> mapFile = requestMultipart.getFileMap(); + if (mapFile.isEmpty()) { + return ExecutedResult.failed("请求中没有找到文件。"); + } + if (mapFile.size() > 1) { + return ExecutedResult.failed("仅支持单个文件上传。"); + } + String fileId = requestMultipart.getParameter("fileId"); + String toPath = requestMultipart.getParameter("path"); + if (StringUtil.isNullOrEmpty(toPath)) { + return ExecutedResult.failed(ParameterUtil.named("path") + EParameterValidateType.NOT_NULLOREMPTY.getDesc()); + } + Iterator<Map.Entry<String, MultipartFile>> iterator = mapFile.entrySet().iterator(); + Map.Entry<String, MultipartFile> fileEntry = iterator.next(); + + MultipartFile file = fileEntry.getValue(); + String contentType = file.getContentType(); + + InputStream fConfig = resourceLoader.getResource("classpath:upload_allow.json").getInputStream(); + String allowStr = FileUtil.readFileContent(fConfig); + Map<String, String> map = new Gson().fromJson(allowStr, Map.class); + List<NameValueDTO<String>> listConfig = map.entrySet().stream().map(c -> new NameValueDTO<>(c.getKey(), c.getValue())) + .collect(Collectors.toList()); + NameValueDTO<String> findConfig = listConfig.stream().filter(c -> c.getName().equals(contentType)) + .findAny().orElse(null); + if (Objects.isNull(findConfig)) { + return ExecutedResult.failed(file.getOriginalFilename() + ", 不支持的文件类型。" + file.getContentType()); + } + if (null != file.getOriginalFilename() && !file.getOriginalFilename().contains(findConfig.getValue())) { + return ExecutedResult.failed(file.getOriginalFilename() + ", 不支持的文件类型。" + file.getContentType()); + } + + EContentType type = EContentType.getByValue(file.getContentType()); + String filePath = "/" + toPath + "/files/"; + boolean isMultimedia = false; + long size = file.getSize() / ConstantFactory.FILE_UNIT; + if (null != type) { + switch (type) { + case GIF: + case JPG: + case PNG: + case JPEG: + filePath = "/" + toPath + "/images/"; + if (size > ConstantFactory.FILE_SIZE_20M) { + return ExecutedResult.failed("图片不能超过20M!"); + } + break; + case GZ: + case RAR: + case X7Z: + case ZIP: + if (size > ConstantFactory.FILE_SIZE_20M) { + return ExecutedResult.failed("压缩文件不能超过20M!"); + } + break; + + case MP3: + isMultimedia = true; + if (size > ConstantFactory.FILE_SIZE_20M) { + return ExecutedResult.failed("音频文件不能超过20M!"); + } + break; + case MP4: + isMultimedia = true; + if (size > ConstantFactory.FILE_SIZE_20M) { + return ExecutedResult.failed("视频文件不能超过20M!"); + } + break; + default: + break; + } + } + filePath += LocalDateTimeUtil.toFormatString(LocalDateTimeUtil.todayFirst(), "yyyyMMdd") + "/"; + InputStream fsIn = file.getInputStream(); + + String fileSuffix = "." + findConfig.getValue(); + File directory = new File(SysConfig.fileUploadBasic() + filePath); + //如果路径不存在,新建 + if (!directory.exists() && !directory.isDirectory()) { + directory.mkdirs(); + } + + String newFileName = filePath + StringUtil.md5(file.getOriginalFilename() + LocalDateTimeUtil.nowDateTimeFullStr() + SysConfig.fileDisturbStr()) + fileSuffix; + File newFile = new File(SysConfig.fileUploadBasic() + newFileName); + if (!newFile.exists()) { + //每次写入1MB + byte[] buffer = new byte[ConstantFactory.FILE_UNIT * ConstantFactory.FILE_SIZE_1M]; + int len; + FileOutputStream fsOut = null; + try { + fsOut = new FileOutputStream(newFile); + while ((len = fsIn.read(buffer)) != -1) { + fsOut.write(buffer, 0, len); + fsOut.flush(); + } + } finally { + if (Objects.nonNull(fsOut)) { + fsOut.close(); + } + } + } + if (Objects.nonNull(fsIn)) { + fsIn.close(); + } + + result.setFileId(fileId); + result.setName(file.getOriginalFilename()); + result.setNewFileName(newFileName); + result.setSize(size); + result.setFileType(findConfig.getValue()); + result.setContentType(findConfig.getName()); + result.setNewFileView(SysConfig.fileViewBasic() + newFileName); + + file = null; + newFile = null; + + return ExecutedResult.success(result); + } + + + private UploadResultVo defaultResult() { + UploadResultVo result = new UploadResultVo(); + result.setFileId(""); + result.setName(""); + result.setNewFileName(""); + result.setNewFileView(""); + result.setFileType(""); + result.setContentType(""); + result.setSize(0L); + return result; + } +} diff --git a/src/main/java/com/fengdu/gas/host/controller/base/NoticeController.java b/src/main/java/com/fengdu/gas/host/controller/base/NoticeController.java new file mode 100644 index 0000000..78a7c2d --- /dev/null +++ b/src/main/java/com/fengdu/gas/host/controller/base/NoticeController.java @@ -0,0 +1,180 @@ +package com.fengdu.gas.host.controller.base; + +import com.fengdu.gas.common.ConstantFactory; +import com.fengdu.gas.common.ExecutedResult; +import com.fengdu.gas.common.PagerResult; +import com.fengdu.gas.common.jwt.LoginUserDTO; +import com.fengdu.gas.common.util.ParameterUtil; +import com.fengdu.gas.common.validator.ParameterValidateResult; +import com.fengdu.gas.common.validator.ParameterValidator; +import com.fengdu.gas.entity.enums.EState; +import com.fengdu.gas.entity.request.ReqListId; +import com.fengdu.gas.entity.request.ReqSetSort; +import com.fengdu.gas.entity.request.notice.ReqCreateNotice; +import com.fengdu.gas.entity.request.notice.ReqModifyNotice; +import com.fengdu.gas.entity.search.SearchNotice; +import com.fengdu.gas.service.NoticeService; +import com.fengdu.gas.service.dto.NoticeDetail; +import com.fengdu.gas.host.BasicController; +import com.fengdu.gas.host.api.NonLogin; +import com.fengdu.gas.repository.vo.NoticeVO; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 02.公告相关接口 + * @author lin.liu + * @order 02 + */ +@RestController +@RequestMapping(value = "notice") +public class NoticeController extends BasicController { + @Autowired + private NoticeService service; + /** + * 创建公告 + * + * @author lin.liu + * @date 2023/02/26 + */ + @PostMapping(value = "create") + public ExecutedResult<Long> create(@RequestBody ReqCreateNotice request) { + //#region 参数验证 + ParameterValidator validator = new ParameterValidator() + // 非空 + .addNotNullOrEmpty(ParameterUtil.named("标题"), request.getTitle()) + // 限制最大长度 + .addLengthMax(ParameterUtil.named("标题"), request.getTitle(), ConstantFactory.LENGTH_MAX50) + // 非空 + .addNotNullOrEmpty(ParameterUtil.named("内容"), request.getContent()) + ; + ParameterValidateResult result = validator.validate(); + if (result.getIsFiled()) { + return failed(result.getErrorMsg()); + } + //#endregion + LoginUserDTO user = super.getTokenUser(); + return this.service.create(request, user); + } + + /** + * 编辑公告 + * + * @author lin.liu + * @date 2023/02/26 + */ + @PostMapping(value = "modify") + public ExecutedResult<String> modify(@RequestBody ReqModifyNotice request) { + //#region 参数验证 + ParameterValidator validator = new ParameterValidator() + // 必须大于0 + .addGreater(ParameterUtil.named("公告id"), request.getId(), 0L) + // 非空 + .addNotNullOrEmpty(ParameterUtil.named("标题"), request.getTitle()) + // 限制最大长度 + .addLengthMax(ParameterUtil.named("标题"), request.getTitle(), ConstantFactory.LENGTH_MAX50) + // 非空 + .addNotNullOrEmpty(ParameterUtil.named("内容"), request.getContent()) + // 必须是枚举值 + .addMustEnum(ParameterUtil.named("状态"), request.getStatus(), EState.class) + ; + ParameterValidateResult result = validator.validate(); + if (result.getIsFiled()) { + return failed(result.getErrorMsg()); + } + //#endregion + return this.service.modify(request); + } + + /** + * 获取公告 + * + * @author lin.liu + * @date 2023/02/26 + */ + @GetMapping(value = "get/{id}") + public ExecutedResult<NoticeDetail> get(@PathVariable Long id) { + return this.service.get(id); + } + + /** + * 根据id批量获取公告 + * + * @author lin.liu + * @date 2023/02/26 + */ + @PostMapping(value = "getList") + public ExecutedResult<List<NoticeVO>> getList(@RequestBody ReqListId request) { + return this.service.getList(request.getListId()); + } + + /** + * 公告设置排序值 + * + * @author lin.liu + * @date 2023/02/26 + */ + @PostMapping(value = "setSort") + public ExecutedResult<String> setSort(@RequestBody ReqSetSort request) { + //#region 参数验证 + ParameterValidator validator = new ParameterValidator() + .addGreater(ParameterUtil.named("公告id"), request.getId(), 0L) + .addGreaterThan(ParameterUtil.named("排序值"), request.getSort(), 0); + ParameterValidateResult result = validator.validate(); + if (result.getIsFiled()) { + return failed(result.getErrorMsg()); + } + //#endregion + return this.service.setSort(request); + } + + /** + * 停用公告 + * + * @param id 项目id + * @author lin.liu + * @date 2023/02/26 + */ + @PostMapping(value = "stop") + public ExecutedResult<String> stop(@RequestParam Long id) { + return this.service.changeStatus(id, EState.DISABLED); + } + + /** + * 启用公告 + * + * @param id 项目id + * @author lin.liu + * @date 2023/02/26 + */ + @PostMapping(value = "enable") + public ExecutedResult<String> enable(@RequestParam Long id) { + return this.service.changeStatus(id, EState.NORMAL); + } + + /** + * 删除公告 + * + * @param id 项目id + * @author lin.liu + * @date 2023/02/26 + */ + @PostMapping(value = "remove") + public ExecutedResult<String> remove(@RequestParam Long id) { + return this.service.changeStatus(id, EState.DELETED); + } + + /** + * 查询公告 + * + * @author lin.liu + * @date 2023/02/26 + */ + @NonLogin + @PostMapping(value = "search") + public ExecutedResult<PagerResult<NoticeVO>> search(@RequestBody SearchNotice request) { + return this.service.search(request); + } +} diff --git a/src/main/java/com/fengdu/gas/host/controller/base/QuartzController.java b/src/main/java/com/fengdu/gas/host/controller/base/QuartzController.java new file mode 100644 index 0000000..9475525 --- /dev/null +++ b/src/main/java/com/fengdu/gas/host/controller/base/QuartzController.java @@ -0,0 +1,141 @@ +package com.fengdu.gas.host.controller.base; + +import com.fengdu.gas.common.ExecutedResult; +import com.fengdu.gas.common.PagerResult; +import com.fengdu.gas.entity.request.quartztaskinfo.ReqCreateQuartzTaskInfo; +import com.fengdu.gas.entity.request.quartztaskinfo.ReqModifyQuartzTaskInfo; +import com.fengdu.gas.entity.request.quartztaskinfo.ReqRunTaskRightNow; +import com.fengdu.gas.entity.search.SearchQuartzTaskInfo; +import com.fengdu.gas.entity.search.SearchQuartzTaskRecord; +import com.fengdu.gas.service.quartz.QuartzService; +import com.fengdu.gas.host.api.NonLogin; +import com.fengdu.gas.repository.vo.QuartzTaskErrorVO; +import com.fengdu.gas.repository.vo.QuartzTaskInfoVO; +import com.fengdu.gas.repository.vo.QuartzTaskRecordVO; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.*; + +/** + * 05.任务调度 + * @author lin.liu + * @order 05 + */ +@NonLogin +@Controller +@RequestMapping("quartz") +public class QuartzController { + private static final Logger logger = LoggerFactory.getLogger(QuartzController.class); + + @Autowired + private QuartzService quartzService; + + /** + * 任务列表 + * @param request 请求参数 + */ + @ResponseBody + @PostMapping("listTask") + public ExecutedResult<PagerResult<QuartzTaskInfoVO>> listTask(@RequestBody SearchQuartzTaskInfo request) { + try { + return quartzService.listTask(request); + } catch (Exception e) { + logger.error("listTask", e); + return ExecutedResult.failed(e.getMessage()); + } + } + + /** + * 添加任务 + * @param request 请求参数 + */ + @ResponseBody + @PostMapping("addTask") + public ExecutedResult<String> addTask(@RequestBody ReqCreateQuartzTaskInfo request) { + try { + return quartzService.addTask(request); + } catch (Exception e) { + logger.error("addTask", e); + return ExecutedResult.failed(e.getMessage()); + } + } + + /** + * 修改任务 + * @param request 请求参数 + */ + @ResponseBody + @PostMapping("editTask") + public ExecutedResult<String> editTask(@RequestBody ReqModifyQuartzTaskInfo request) { + try { + return quartzService.updateTask(request); + } catch (Exception e) { + logger.error("editTask", e); + return ExecutedResult.failed(e.getMessage()); + } + } + + /** + * 启动 或者 暂定定时任务 + * @param taskId 任务id + */ + @ResponseBody + @PostMapping("optionJob/{taskId}") + public ExecutedResult<String> optionJob(@PathVariable Long taskId) { + try { + return quartzService.optionJob(taskId); + } catch (Exception e) { + logger.error("optionJob", e); + return ExecutedResult.failed(e.getMessage()); + } + } + + /** + * 立即运行一次定时任务 + * @param request 请求参数 + */ + @ResponseBody + @PostMapping("runTaskRightNow") + public ExecutedResult<String> runTaskRightNow(@RequestBody ReqRunTaskRightNow request) { + try { + return quartzService.runTaskRightNow(request); + } catch (Exception e) { + logger.error("/runTaskRightNow", e); + return ExecutedResult.failed(e.getMessage()); + } + } + + /** + * 定时任务执行情况 + * + * @param search 请求参数 + */ + @ResponseBody + @PostMapping("taskRecords") + public ExecutedResult<PagerResult<QuartzTaskRecordVO>> taskRecords(@RequestBody SearchQuartzTaskRecord search) { + try { + return quartzService.taskRecords(search); + } catch (Exception e) { + logger.error("/taskRecords", e); + return ExecutedResult.failed(e.getMessage()); + } + } + + /** + * 定时任务错误详情 + * + * @param recordId 执行记录id + */ + @ResponseBody + @GetMapping("taskErrors/{recordId}") + public ExecutedResult<QuartzTaskErrorVO> detailTaskErrors(@PathVariable String recordId) { + try { + return quartzService.detailTaskErrors(recordId); + } catch (Exception e) { + logger.error("/taskErrors", e); + return ExecutedResult.failed(e.getMessage()); + } + } +} diff --git a/src/main/java/com/fengdu/gas/host/controller/base/SysDictDataController.java b/src/main/java/com/fengdu/gas/host/controller/base/SysDictDataController.java new file mode 100644 index 0000000..602a5f3 --- /dev/null +++ b/src/main/java/com/fengdu/gas/host/controller/base/SysDictDataController.java @@ -0,0 +1,145 @@ +/** +# __----~~~~~~~~~~~------___ +# . . ~~//====...... __--~ ~~ +# -. \_|// |||\\ ~~~~~~::::... /~ +# ___-==_ _-~o~ \/ ||| \\ _/~~- +# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ +# _-~~ .=~ | \\-_ '-~7 /- / || \ / +# .~ .~ | \\ -_ / /- / || \ / +# / ____ / | \\ ~-_/ /|- _/ .|| \ / +# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ +# ' ~-| /| |-~\~~ __--~~ +# |-~~-_/ | | ~\_ _-~ /\ +# / \ \__ \/~ \__ +# _--~ _/ | .-~~____--~-/ ~~==. +# ((->/~ '.|||' -_| ~~-/ , . _|| +# -_ ~\ ~~---l__i__i__i--~~_/ +# _-~-__ ~) \--______________--~~ +# //.-~~~-~_--~- |-------~~~~~~~~ +# //.-~~~--\ +# 神兽保佑 +# 永无BUG! +*/ +package com.fengdu.gas.host.controller.base; + +import com.fengdu.gas.common.ExecutedResult; +import com.fengdu.gas.common.PagerResult; +import com.fengdu.gas.common.util.ParameterUtil; +import com.fengdu.gas.common.validator.ParameterValidateResult; +import com.fengdu.gas.common.validator.ParameterValidator; +import com.fengdu.gas.entity.request.ReqListId; +import com.fengdu.gas.entity.request.sysdictdata.ReqCreateSysDictData; +import com.fengdu.gas.entity.request.sysdictdata.ReqModifySysDictData; +import com.fengdu.gas.entity.search.SearchSysDictData; +import com.fengdu.gas.service.SysDictDataService; +import com.fengdu.gas.host.BasicController; +import com.fengdu.gas.repository.vo.SysDictDataVO; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 04.字典数据 + * @author lin.liu + * @description 字典数据 + * @order 04 + */ +@RestController +@RequestMapping(value = "sysDictData") +public class SysDictDataController extends BasicController { + @Autowired + private SysDictDataService service; + + /** + * 创建[字典数据表] + * @author lin.liu + * @description 创建[字典数据表] + */ + @PostMapping(value = "create") + public ExecutedResult<Long> create(@RequestBody ReqCreateSysDictData request) { + //#region 参数验证 + ParameterValidator validator = new ParameterValidator() + // 非空 + //.addNotNullOrEmpty(ParameterUtil.named("名称"), request.getName()) + // 限制最大长度 + //.addLengthMax(ParameterUtil.named("名称"), request.getName(), ConstantFactory.LENGTH_MAX50) + ; + ParameterValidateResult result = validator.validate(); + if (result.getIsFiled()) { + return failed(result.getErrorMsg()); + } + //#endregion + return this.service.create(request, super.getTokenUser()); + } + + /** + * 编辑[字典数据表] + * @author lin.liu + * @description 编辑[字典数据表] + */ + @PostMapping(value = "modify") + public ExecutedResult<String> modify(@RequestBody ReqModifySysDictData request) { + //#region 参数验证 + ParameterValidator validator = new ParameterValidator() + // 必须大于0 + .addGreater(ParameterUtil.named("[字典数据表]id"), request.getId(), 0L) + // 非空 + //.addNotNullOrEmpty(ParameterUtil.named("名称"), request.getName()) + // 限制最大长度 + //.addLengthMax(ParameterUtil.named("名称"), request.getName(), ConstantFactory.LENGTH_MAX50) + ; + ParameterValidateResult result = validator.validate(); + if (result.getIsFiled()) { + return failed(result.getErrorMsg()); + } + //#endregion + return this.service.modify(request, super.getTokenUser()); + } + + /** + * 获取[字典数据表] + * @author lin.liu + */ + @GetMapping(value = "get/{id}") + public ExecutedResult<SysDictDataVO> get(@PathVariable Long id) { + return this.service.get(id); + } + + /** + * 根据id删除[字典数据表] + * @author zr + * @description 根据id删除[字典数据表] + */ + @PostMapping(value = "remove/{id}") + public ExecutedResult<String> remove(@PathVariable Long id){ + return this.service.remove(id); + } + + /** + * 根据id批量删除字典数据 + * @author zr + */ + @PostMapping(value = "removeList") + public ExecutedResult<String> removeList(@RequestBody ReqListId reqListId){ + return this.service.removeList(reqListId.getListId()); + } + + /** + * 根据类型获取[字典数据表] + * @author zr + */ + @GetMapping(value = "getListByType/{type}") + public ExecutedResult<List<SysDictDataVO>> getListByType(@PathVariable String type) { + return this.service.getListByType(type); + } + + /** + * 查询[字典数据表] + * @author lin.liu + */ + @PostMapping(value = "search") + public ExecutedResult<PagerResult<SysDictDataVO>> search(@RequestBody SearchSysDictData request) { + return this.service.search(request); + } +} diff --git a/src/main/java/com/fengdu/gas/host/controller/base/SysDictTypeController.java b/src/main/java/com/fengdu/gas/host/controller/base/SysDictTypeController.java new file mode 100644 index 0000000..f450f00 --- /dev/null +++ b/src/main/java/com/fengdu/gas/host/controller/base/SysDictTypeController.java @@ -0,0 +1,143 @@ +/** +# __----~~~~~~~~~~~------___ +# . . ~~//====...... __--~ ~~ +# -. \_|// |||\\ ~~~~~~::::... /~ +# ___-==_ _-~o~ \/ ||| \\ _/~~- +# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ +# _-~~ .=~ | \\-_ '-~7 /- / || \ / +# .~ .~ | \\ -_ / /- / || \ / +# / ____ / | \\ ~-_/ /|- _/ .|| \ / +# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ +# ' ~-| /| |-~\~~ __--~~ +# |-~~-_/ | | ~\_ _-~ /\ +# / \ \__ \/~ \__ +# _--~ _/ | .-~~____--~-/ ~~==. +# ((->/~ '.|||' -_| ~~-/ , . _|| +# -_ ~\ ~~---l__i__i__i--~~_/ +# _-~-__ ~) \--______________--~~ +# //.-~~~-~_--~- |-------~~~~~~~~ +# //.-~~~--\ +# 神兽保佑 +# 永无BUG! +*/ +package com.fengdu.gas.host.controller.base; + +import com.fengdu.gas.common.ExecutedResult; +import com.fengdu.gas.common.PagerResult; +import com.fengdu.gas.common.util.ParameterUtil; +import com.fengdu.gas.common.validator.ParameterValidateResult; +import com.fengdu.gas.common.validator.ParameterValidator; +import com.fengdu.gas.entity.request.ReqListId; +import com.fengdu.gas.entity.request.sysdicttype.ReqCreateSysDictType; +import com.fengdu.gas.entity.request.sysdicttype.ReqModifySysDictType; +import com.fengdu.gas.entity.search.SearchSysDictType; +import com.fengdu.gas.service.SysDictTypeService; +import com.fengdu.gas.host.BasicController; +import com.fengdu.gas.repository.vo.SysDictTypeVO; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 03.字典类型 + * @author lin.liu + * @order 03 + */ +@RestController +@RequestMapping(value = "sysDictType") +public class SysDictTypeController extends BasicController { + @Autowired + private SysDictTypeService service; + + /** + * 创建[字典类型表] + * @author lin.liu + */ + @PostMapping(value = "create") + public ExecutedResult<Long> create(@RequestBody ReqCreateSysDictType request) { + //#region 参数验证 + ParameterValidator validator = new ParameterValidator() + // 非空 + //.addNotNullOrEmpty(ParameterUtil.named("名称"), request.getName()) + // 限制最大长度 + //.addLengthMax(ParameterUtil.named("名称"), request.getName(), ConstantFactory.LENGTH_MAX50) + ; + ParameterValidateResult result = validator.validate(); + if (result.getIsFiled()) { + return failed(result.getErrorMsg()); + } + //#endregion + return this.service.create(request); + } + + /** + * 编辑[字典类型表] + * @author lin.liu + */ + @PostMapping(value = "modify") + public ExecutedResult<String> modify(@RequestBody ReqModifySysDictType request) { + //#region 参数验证 + ParameterValidator validator = new ParameterValidator() + // 必须大于0 + .addGreater(ParameterUtil.named("[字典类型表]id"), request.getId(), 0L) + // 非空 + //.addNotNullOrEmpty(ParameterUtil.named("名称"), request.getName()) + // 限制最大长度 + //.addLengthMax(ParameterUtil.named("名称"), request.getName(), ConstantFactory.LENGTH_MAX50) + ; + ParameterValidateResult result = validator.validate(); + if (result.getIsFiled()) { + return failed(result.getErrorMsg()); + } + //#endregion + return this.service.modify(request); + } + + /** + * 获取[字典类型表] + * @author lin.liu + */ + @GetMapping(value = "get/{id}") + public ExecutedResult<SysDictTypeVO> get(@PathVariable Long id) { + return this.service.get(id); + } + + /** + * 根据id删除[字典类型表] + * @author zr + * @description 根据id删除[字典类型表] + */ + @PostMapping(value = "remove/{id}") + ExecutedResult<String> remove(@PathVariable Long id){ + return this.service.remove(id); + } + + /** + * 根据id批量删除字典类型 + */ + @PostMapping(value = "removeList") + public ExecutedResult<String> removeList(@RequestBody ReqListId request) { + return service.removeList(request.getListId()); + } + + /** + * 根据id批量获取[字典类型表] + * @author zr + * @description 根据id批量获取[字典类型表] + */ + @PostMapping(value = "getList") + public ExecutedResult<List<SysDictTypeVO>> getList(@RequestBody ReqListId request) { + return this.service.getList(request.getListId()); + } + + /** + * 查询[字典类型表] + * @author lin.liu + * @description 查询[字典类型表] + */ + @PostMapping(value = "search") + public ExecutedResult<PagerResult<SysDictTypeVO>> search(@RequestBody SearchSysDictType request) { + return this.service.search(request); + } +} diff --git a/src/main/java/com/fengdu/gas/repository/BasicMapper.java b/src/main/java/com/fengdu/gas/repository/BasicMapper.java new file mode 100644 index 0000000..4019b0c --- /dev/null +++ b/src/main/java/com/fengdu/gas/repository/BasicMapper.java @@ -0,0 +1,126 @@ +package com.fengdu.gas.repository; + +import com.baomidou.mybatisplus.core.conditions.Wrapper; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.fengdu.gas.common.PagerResult; +import com.fengdu.gas.entity.dto.SearchBasicDTO; +import org.apache.ibatis.session.ResultHandler; + +import java.io.Serializable; +import java.util.List; +import java.util.Map; + +public interface BasicMapper<T> extends BaseMapper<T> { + /** + * 批量新增 + * @param list 数据实体列表 + */ + Boolean addList(List<T> list); + + /** + * 批量更新 + * @param list 数据实体列表 + */ + Boolean modifyList(List<T> list); + + /** + * 批量查询其他实体列表 + * @param queryWrapper 查询条件 + * @param <E> 实体类型 + */ + <E> List<E> selectListObject(Wrapper<T> queryWrapper); + + /** + * 批量查询其他实体列表 + * @param queryWrapper 查询条件 + * @param resultHandler 查询结果处理器 + * @param <E> 实体类型 + */ + <E> void selectListObject(Wrapper<T> queryWrapper, ResultHandler<E> resultHandler); + + /** + * 根据主键查询单个数据实体 + * + * @param id 主键值 + */ + T get(Serializable id); + + /** + * 条件查询单个数据实体 + * + * @param queryWrapper 查询条件 + */ + T get(Wrapper<T> queryWrapper); + + /** + * 根据主键批量获取 + * @param listId 主键列表 + */ + <E extends Serializable> List<T> getList(List<E> listId); + + + /** + * 获取全量数据(慎重) + */ + List<T> getList(); + + /** + * 根据传入sql查询数据 + * + * @param queryWrapper 查询条件 + */ + List<Map<String, Object>> getMap(Wrapper<T> queryWrapper); + + /** + * 查询记录条数 + * + * @param queryWrapper 查询条件 + */ + Long getCount(Wrapper<T> queryWrapper); + + /** + * 根据主键id删除数据 + * + * @param id 主键id + * @return 是否成功 + */ + Boolean remove(Serializable id); + + /** + * 根据主键id删除数据 + * + * @param listId id列表 + * @return 是否成功 + */ + <E extends Serializable> Boolean remove(List<E> listId); + + /** + * 根据条件删除数据 + * + * @param queryWrapper 查询条件 + */ + Boolean remove(Wrapper<T> queryWrapper); + + /** + * 根据主键id逻辑删除数据(逻辑删除) + * + * @param id 主键id + * @return 是否成功 + */ + Boolean deleteLogic(Serializable id); + + /** + * 根据逐渐删除数据(逻辑删除) + * + * @param listId id列表 + * @return 是否成功 + */ + <E extends Serializable> Boolean deleteLogic(List<E> listId); + + /** + * 分页查询 + * + * @param search 查询参数 + */ + PagerResult<T> search(SearchBasicDTO search); +} diff --git a/src/main/java/com/fengdu/gas/repository/BasicMapperImpl.java b/src/main/java/com/fengdu/gas/repository/BasicMapperImpl.java new file mode 100644 index 0000000..afd2100 --- /dev/null +++ b/src/main/java/com/fengdu/gas/repository/BasicMapperImpl.java @@ -0,0 +1,699 @@ +package com.fengdu.gas.repository; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.core.batch.BatchSqlSession; +import com.baomidou.mybatisplus.core.conditions.Wrapper; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; +import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.Constants; +import com.baomidou.mybatisplus.core.toolkit.StringUtils; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.fengdu.gas.common.PagerResult; +import com.fengdu.gas.common.enums.ELogger; +import com.fengdu.gas.common.enums.EResultCode; +import com.fengdu.gas.common.enums.EYesOrNo; +import com.fengdu.gas.common.exceptions.BusinessException; +import com.fengdu.gas.common.util.LoggerUtil; +import com.fengdu.gas.entity.dto.SearchBasicDTO; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.executor.BatchResult; +import org.apache.ibatis.session.ResultHandler; +import org.slf4j.Logger; +import org.springframework.dao.EmptyResultDataAccessException; + +import java.io.Serializable; +import java.lang.reflect.ParameterizedType; +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.function.BiPredicate; + +/** + * 数据访问 实现类 + * + * @param <T> 数据实体 + */ +public abstract class BasicMapperImpl<T, M extends BasicMapper<T>> implements BasicMapper<T> { + protected M DB; + protected Class<T> clazz; + protected String tableName; + + protected static final Logger logger = LoggerUtil.get(ELogger.SQL_LOG); + + /** + * 构造方法 + */ + public BasicMapperImpl(M db) { + this.clazz = (Class<T>) ( + (ParameterizedType) getClass().getGenericSuperclass() + ).getActualTypeArguments()[0]; + this.DB = db; + TableName annotation = clazz.getAnnotation(TableName.class); + if (null == annotation) { + this.tableName = StringUtils.camelToUnderline(clazz.getSimpleName().replace("PO", "")); + return; + } + this.tableName = annotation.value(); + } + + public LambdaQueryWrapper<T> query() { + return Wrappers.lambdaQuery(); + } + + public UpdateWrapper<T> update() { + return Wrappers.update(); + } + + /** + * 插入一条记录 + * + * @param entity 实体对象 + */ + public int insert(T entity) { + return DB.insert(entity); + } + + /** + * 根据 ID 删除 + * + * @param id 主键 + */ + public int deleteById(Serializable id) { + return DB.deleteById(id); + } + + /** + * 根据 ID 删除 + * + * @param useFill 是否填充 + * @param obj 主键或实体 + * @since 3.5.7 + */ + public int deleteById(Object obj, boolean useFill) { + return DB.deleteById(obj, useFill); + } + + /** + * 根据实体(ID)删除 + * + * @param entity 实体对象 + * @since 3.4.4 + */ + public int deleteById(T entity) { + return DB.deleteById(entity); + } + + /** + * 根据 columnMap 条件,删除记录 + * + * @param columnMap 表字段 map 对象 + */ + public int deleteByMap(Map<String, Object> columnMap) { + return DB.deleteByMap(columnMap); + } + + /** + * 根据 entity 条件,删除记录 + * + * @param queryWrapper 实体对象封装操作类(可以为 null,里面的 entity 用于生成 where 语句) + */ + public int delete(@Param(Constants.WRAPPER) Wrapper<T> queryWrapper) { + return DB.delete(queryWrapper); + } + + + /** + * 删除(根据ID或实体 批量删除) + * + * @param idList 主键列表或实体列表(不能为 null 以及 empty) + * @deprecated 3.5.7 {@link #deleteByIds(Collection)} + */ + @Deprecated + public int deleteBatchIds(@Param(Constants.COLL) Collection<?> idList) { + return DB.deleteBatchIds(idList); + } + + + /** + * 删除(根据ID或实体 批量删除) + * + * @param idList 主键列表或实体列表(不能为 null 以及 empty) + * @since 3.5.7 + */ + public int deleteByIds(@Param(Constants.COLL) Collection<?> idList) { + return DB.deleteByIds(idList); + } + + /** + * 删除(根据ID或实体 批量删除) + * <p> + * 普通删除: DELETE FROM h2user WHERE id IN ( ? , ? ) + * </p> + * <p> + * 逻辑删除: UPDATE h2user SET deleted=1 WHERE id IN ( ? , ? ) AND deleted=0 + * </p> + * <p> + * 逻辑删除(填充): UPDATE h2user SET delete_user = 'xxx', deleted=1 WHERE id IN ( ? , ? ) AND deleted=0 + * <ul>注意:无论参数为id还是实体,填充参数只会以方法追加的et参数为准.<ul/> + * </p> + * + * @param collections 主键列表或实体列表(不能为 null 以及 empty) + * @param useFill 逻辑删除下是否填充 + * @since 3.5.7 + */ + public int deleteByIds(@Param(Constants.COLL) Collection<?> collections, boolean useFill) { + return DB.deleteByIds(collections, useFill); + } + + /** + * 根据 ID 修改 + * + * @param entity 实体对象 + */ + public int updateById(@Param(Constants.ENTITY) T entity) { + return DB.updateById(entity); + } + + /** + * 根据 whereEntity 条件,更新记录 + * + * @param entity 实体对象 (set 条件值,可以为 null,当entity为null时,无法进行自动填充) + * @param updateWrapper 实体对象封装操作类(可以为 null,里面的 entity 用于生成 where 语句) + */ + public int update(@Param(Constants.ENTITY) T entity, @Param(Constants.WRAPPER) Wrapper<T> updateWrapper) { + return DB.update(entity, updateWrapper); + } + + /** + * 根据 Wrapper 更新记录 + * <p>此方法无法进行自动填充,如需自动填充请使用{@link #update(Object, Wrapper)}</p> + * + * @param updateWrapper {@link UpdateWrapper} or {@link LambdaUpdateWrapper} + * @since 3.5.4 + */ + public int update(@Param(Constants.WRAPPER) Wrapper<T> updateWrapper) { + return DB.update(updateWrapper); + } + + /** + * 根据 ID 查询 + * + * @param id 主键 + */ + public T selectById(Serializable id) { + return DB.selectById(id); + } + + /** + * 查询(根据ID 批量查询) + * + * @param idList 主键列表(不能为 null 以及 empty) + */ + public List<T> selectBatchIds(@Param(Constants.COLL) Collection<? extends Serializable> idList) { + return DB.selectBatchIds(idList); + } + + /** + * 查询(根据ID 批量查询) + * + * @param idList idList 主键列表(不能为 null 以及 empty) + * @param resultHandler resultHandler 结果处理器 {@link ResultHandler} + * @since 3.5.4 + */ + public void selectBatchIds(@Param(Constants.COLL) Collection<? extends Serializable> idList, ResultHandler<T> resultHandler) { + DB.selectBatchIds(idList, resultHandler); + } + + /** + * 查询(根据 columnMap 条件) + * + * @param columnMap 表字段 map 对象 + */ + public List<T> selectByMap(Map<String, Object> columnMap) { + return DB.selectByMap(columnMap); + } + + /** + * 查询(根据 columnMap 条件) + * + * @param columnMap 表字段 map 对象 + * @param resultHandler resultHandler 结果处理器 {@link ResultHandler} + * @since 3.5.4 + */ + public void selectByMap(Map<String, Object> columnMap, ResultHandler<T> resultHandler) { + DB.selectByMap(columnMap, resultHandler); + } + + /** + * 根据 entity 条件,查询一条记录 + * <p>查询一条记录,例如 qw.last("limit 1") 限制取一条记录, 注意:多条数据会报异常</p> + * + * @param queryWrapper 实体对象封装操作类(可以为 null) + */ + public T selectOne(@Param(Constants.WRAPPER) Wrapper<T> queryWrapper) { + return DB.selectOne(queryWrapper); + } + + /** + * 根据 entity 条件,查询一条记录,现在会根据{@code throwEx}参数判断是否抛出异常,如果为false就直接返回一条数据 + * <p>查询一条记录,例如 qw.last("limit 1") 限制取一条记录, 注意:多条数据会报异常</p> + * + * @param queryWrapper 实体对象封装操作类(可以为 null) + * @param throwEx boolean 参数,为true如果存在多个结果直接抛出异常 + */ + public T selectOne(@Param(Constants.WRAPPER) Wrapper<T> queryWrapper, boolean throwEx) { + return DB.selectOne(queryWrapper, throwEx); + } + + /** + * 根据 Wrapper 条件,判断是否存在记录 + * + * @param queryWrapper 实体对象封装操作类 + * @return 是否存在记录 + */ + public boolean exists(Wrapper<T> queryWrapper) { + return DB.exists(queryWrapper); + } + + /** + * 根据 Wrapper 条件,查询总记录数 + * + * @param queryWrapper 实体对象封装操作类(可以为 null) + */ + public Long selectCount(@Param(Constants.WRAPPER) Wrapper<T> queryWrapper) { + return DB.selectCount(queryWrapper); + } + + /** + * 根据 entity 条件,查询全部记录 + * + * @param queryWrapper 实体对象封装操作类(可以为 null) + */ + public List<T> selectList(@Param(Constants.WRAPPER) Wrapper<T> queryWrapper) { + return DB.selectList(queryWrapper); + } + + /** + * 根据 entity 条件,查询全部记录 + * + * @param queryWrapper 实体对象封装操作类(可以为 null) + * @param resultHandler 结果处理器 {@link ResultHandler} + * @since 3.5.4 + */ + public void selectList(@Param(Constants.WRAPPER) Wrapper<T> queryWrapper, ResultHandler<T> resultHandler) { + DB.selectList(queryWrapper, resultHandler); + } + + /** + * 根据 entity 条件,查询全部记录(并翻页) + * + * @param page 分页查询条件 + * @param queryWrapper 实体对象封装操作类(可以为 null) + * @since 3.5.3.2 + */ + public List<T> selectList(IPage<T> page, @Param(Constants.WRAPPER) Wrapper<T> queryWrapper) { + return DB.selectList(page, queryWrapper); + } + + /** + * 根据 entity 条件,查询全部记录(并翻页) + * + * @param page 分页查询条件 + * @param queryWrapper 实体对象封装操作类(可以为 null) + * @param resultHandler 结果处理器 {@link ResultHandler} + * @since 3.5.4 + */ + public void selectList(IPage<T> page, @Param(Constants.WRAPPER) Wrapper<T> queryWrapper, ResultHandler<T> resultHandler) { + DB.selectList(page, queryWrapper, resultHandler); + } + + + /** + * 根据 Wrapper 条件,查询全部记录 + * + * @param queryWrapper 实体对象封装操作类 + */ + public List<Map<String, Object>> selectMaps(@Param(Constants.WRAPPER) Wrapper<T> queryWrapper) { + return DB.selectMaps(queryWrapper); + } + + /** + * 根据 Wrapper 条件,查询全部记录 + * + * @param queryWrapper 实体对象封装操作类 + * @param resultHandler 结果处理器 {@link ResultHandler} + * @since 3.5.4 + */ + public void selectMaps(@Param(Constants.WRAPPER) Wrapper<T> queryWrapper, ResultHandler<Map<String, Object>> resultHandler) { + DB.selectMaps(queryWrapper, resultHandler); + } + + /** + * 根据 Wrapper 条件,查询全部记录(并翻页) + * + * @param page 分页查询条件 + * @param queryWrapper 实体对象封装操作类 + * @since 3.5.3.2 + */ + public List<Map<String, Object>> selectMaps(IPage<? extends Map<String, Object>> page, @Param(Constants.WRAPPER) Wrapper<T> queryWrapper) { + return DB.selectMaps(page, queryWrapper); + } + + /** + * 根据 Wrapper 条件,查询全部记录(并翻页) + * + * @param page 分页查询条件 + * @param queryWrapper 实体对象封装操作类 + * @param resultHandler 结果处理器 {@link ResultHandler} + * @since 3.5.4 + */ + public void selectMaps(IPage<? extends Map<String, Object>> page, @Param(Constants.WRAPPER) Wrapper<T> queryWrapper, ResultHandler<Map<String, Object>> resultHandler) { + DB.selectMaps(page, queryWrapper, resultHandler); + } + + /** + * 根据 Wrapper 条件,查询全部记录 + * <p>注意: 只返回第一个字段的值</p> + * + * @param queryWrapper 实体对象封装操作类(可以为 null) + */ + public <E> List<E> selectObjs(@Param(Constants.WRAPPER) Wrapper<T> queryWrapper) { + return DB.selectObjs(queryWrapper); + } + + /** + * 根据 Wrapper 条件,查询全部记录 + * <p>注意: 只返回第一个字段的值</p> + * + * @param queryWrapper 实体对象封装操作类(可以为 null) + * @param resultHandler 结果处理器 {@link ResultHandler} + * @since 3.5.4 + */ + public <E> void selectObjs(@Param(Constants.WRAPPER) Wrapper<T> queryWrapper, ResultHandler<E> resultHandler) { + DB.selectObjs(queryWrapper, resultHandler); + } + + /** + * 根据 entity 条件,查询全部记录(并翻页) + * + * @param page 分页查询条件 + * @param queryWrapper 实体对象封装操作类(可以为 null) + */ + public <P extends IPage<T>> P selectPage(P page, @Param(Constants.WRAPPER) Wrapper<T> queryWrapper) { + return DB.selectPage(page, queryWrapper); + } + + /** + * 根据 Wrapper 条件,查询全部记录(并翻页) + * + * @param page 分页查询条件 + * @param queryWrapper 实体对象封装操作类 + */ + public <P extends IPage<Map<String, Object>>> P selectMapsPage(P page, @Param(Constants.WRAPPER) Wrapper<T> queryWrapper) { + return DB.selectMapsPage(page, queryWrapper); + } + + /** + * 主键存在更新记录,否插入一条记录 + * + * @param entity 实体对象 (不能为空) + * @since 3.5.7 + */ + public boolean insertOrUpdate(T entity) { + return DB.insertOrUpdate(entity); + } + + + /** + * 插入(批量) + * + * @param entityList 实体对象集合 + * @since 3.5.7 + */ + public List<BatchResult> insert(Collection<T> entityList) { + return DB.insert(entityList); + } + + /** + * 插入(批量) + * + * @param entityList 实体对象集合 + * @param batchSize 插入批次数量 + * @since 3.5.7 + */ + public List<BatchResult> insert(Collection<T> entityList, int batchSize) { + return DB.insert(entityList, batchSize); + } + + /** + * 根据ID 批量更新 + * + * @param entityList 实体对象集合 + * @since 3.5.7 + */ + public List<BatchResult> updateById(Collection<T> entityList) { + return DB.updateById(entityList); + } + + /** + * 根据ID 批量更新 + * + * @param entityList 实体对象集合 + * @param batchSize 插入批次数量 + * @since 3.5.7 + */ + public List<BatchResult> updateById(Collection<T> entityList, int batchSize) { + return DB.updateById(entityList, batchSize); + } + + /** + * 批量修改或插入 + * + * @param entityList 实体对象集合 + * @since 3.5.7 + */ + public List<BatchResult> insertOrUpdate(Collection<T> entityList) { + return DB.insertOrUpdate(entityList); + } + + /** + * 批量修改或插入 + * + * @param entityList 实体对象集合 + * @param batchSize 插入批次数量 + * @since 3.5.7 + */ + public List<BatchResult> insertOrUpdate(Collection<T> entityList, int batchSize) { + return DB.insertOrUpdate(entityList, batchSize); + } + + /** + * 批量修改或插入 + * + * @param entityList 实体对象集合 + * @since 3.5.7 + */ + public List<BatchResult> insertOrUpdate(Collection<T> entityList, BiPredicate<BatchSqlSession, T> insertPredicate) { + return DB.insertOrUpdate(entityList, insertPredicate); + } + + /** + * 批量修改或插入 + * + * @param entityList 实体对象集合 + * @param batchSize 插入批次数量 + * @since 3.5.7 + */ + public List<BatchResult> insertOrUpdate(Collection<T> entityList, BiPredicate<BatchSqlSession, T> insertPredicate, int batchSize) { + return DB.insertOrUpdate(entityList, insertPredicate, batchSize); + } + + + /** + * 批量新增 + * + * @param list 数据实体列表 + */ + public Boolean addList(List<T> list) { + List<BatchResult> batchResult = DB.insert(list); + // TODO 判断成功 + return Boolean.TRUE; + } + + /** + * 批量更新 + * + * @param list 数据实体列表 + */ + public Boolean modifyList(List<T> list) { + List<BatchResult> batchResult = DB.updateById(list); + // TODO 判断成功 + return Boolean.TRUE; + } + + /** + * 批量查询其他实体列表 + * + * @param queryWrapper 查询条件 + */ + public <E> List<E> selectListObject(Wrapper<T> queryWrapper) { + return DB.selectObjs(queryWrapper); + } + + /** + * 批量查询其他实体列表 + * + * @param queryWrapper 查询条件 + * @param resultHandler 查询结果处理器 + */ + public <E> void selectListObject(Wrapper<T> queryWrapper, ResultHandler<E> resultHandler) { + DB.selectObjs(queryWrapper, resultHandler); + } + + /** + * 根据主键查询单个数据实体 + * + * @param id 主键值 + */ + public T get(Serializable id) { + return DB.selectById(id); + } + + /** + * 条件查询单个数据实体 + * + * @param queryWrapper 查询条件 + */ + public T get(Wrapper<T> queryWrapper) { + String method = "BasicDao.Wrapper<T> queryWrapper"; + try { + return DB.selectOne(queryWrapper); + } catch (EmptyResultDataAccessException e) { + logger.error(method, e); + return null; + } catch (Exception e) { + logger.error(method + ", 发生异常", e); + throw new BusinessException(EResultCode.ERROR, "BasicDao.get(SqlBuilder builder)发生异常." + e.getMessage()); + } + } + + /** + * 根据主键批量获取 + * + * @param listId 主键列表 + */ + public <E extends Serializable> List<T> getList(List<E> listId) { + return DB.selectBatchIds(listId); + } + + /** + * 获取全量数据(慎重) + */ + public List<T> getList() { + return DB.selectList(null); + } + + /** + * 根据传入sql查询数据 + * + * @param queryWrapper 查询条件 + */ + public List<Map<String, Object>> getMap(Wrapper<T> queryWrapper) { + return DB.selectMaps(queryWrapper); + } + + /** + * 查询记录条数 + * + * @param queryWrapper 查询条件 + */ + public Long getCount(Wrapper<T> queryWrapper) { + return DB.selectCount(queryWrapper); + } + + /** + * 根据主键删除数据 + * + * @param id 主键 + * @return 是否成功 + */ + public Boolean remove(Serializable id) { + int rowCount = DB.deleteById(id); + if (rowCount > 0) { + return Boolean.TRUE; + } + return Boolean.FALSE; + } + + /** + * 根据主键删除数据 + * + * @param listId id列表 + * @return 是否成功 + */ + public <E extends Serializable> Boolean remove(List<E> listId) { + int rowCount = DB.deleteByIds(listId); + if (rowCount > 0) { + return Boolean.TRUE; + } + return Boolean.FALSE; + + } + + /** + * 根据条件删除数据 + * + * @param queryWrapper 查询条件 + */ + public Boolean remove(Wrapper<T> queryWrapper) { + int rowCount = DB.delete(queryWrapper); + if (rowCount > 0) { + return Boolean.TRUE; + } + return Boolean.FALSE; + } + + /** + * 根据主键逻辑删除数据(逻辑删除) + * + * @param id 主键 + * @return 是否成功 + */ + public Boolean deleteLogic(Serializable id) { + UpdateWrapper<T> where = Wrappers.update(); + where.set("is_delete", EYesOrNo.YES.getValue()); + where.eq("id", id); + int rowCount = DB.update(where); + if (rowCount > 0) { + return Boolean.TRUE; + } + return Boolean.FALSE; + } + + /** + * 根据逐渐删除数据(逻辑删除) + * + * @param listId id列表 + * @return 是否成功 + */ + public <E extends Serializable> Boolean deleteLogic(List<E> listId) { + UpdateWrapper<T> where = Wrappers.update(); + where.set("is_delete", EYesOrNo.YES.getValue()); + where.in("id", listId); + int rowCount = DB.update(where); + if (rowCount > 0) { + return Boolean.TRUE; + } + return Boolean.FALSE; + } + + /** + * 分页查询 + * + * @param search 查询参数 + */ + @Override + public abstract PagerResult<T> search(SearchBasicDTO search); +} diff --git a/src/main/java/com/fengdu/gas/repository/bo/AdminUserBO.java b/src/main/java/com/fengdu/gas/repository/bo/AdminUserBO.java new file mode 100644 index 0000000..638a1c0 --- /dev/null +++ b/src/main/java/com/fengdu/gas/repository/bo/AdminUserBO.java @@ -0,0 +1,29 @@ +package com.fengdu.gas.repository.bo; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; + +@Data +@TableName("admin_user") +public class AdminUserBO implements Serializable { + /** + * 主键 + */ + @TableId + @TableField("id") + private Long id; + /** + * 用户名 + */ + @TableField("user_name") + private String userName; + /** + * 昵称 + */ + @TableField("nick_name") + private String nickName; +} diff --git a/src/main/java/com/fengdu/gas/repository/bo/NoticeBO.java b/src/main/java/com/fengdu/gas/repository/bo/NoticeBO.java new file mode 100644 index 0000000..fc9dda2 --- /dev/null +++ b/src/main/java/com/fengdu/gas/repository/bo/NoticeBO.java @@ -0,0 +1,66 @@ +package com.fengdu.gas.repository.bo; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; +import java.sql.Timestamp; + +/** + * 公告-不返回内容 + * @author lin.liu + * @description 公告 + * @date 2023/02/26 + */ +@Data +@TableName("notice") +public class NoticeBO implements Serializable { + /** + * 主键 + */ + @TableId + @TableField("id") + private Long id; + /** + * 发布人 + */ + @TableField("user_id") + private Long userId; + /** + * 发布人昵称 + */ + @TableField("user_nick_name") + private String userNickName; + /** + * 标题 + */ + @TableField("title") + private String title; + /** + * 摘要 + */ + @TableField("summary") + private String summary; + /** + * 排序 越大越靠后 + */ + @TableField("sort") + private Integer sort; + /** + * 状态(EState) 正常=1,关闭=2,删除=3 + */ + @TableField("status") + private Integer status; + /** + * 创建时间 + */ + @TableField("create_time") + private Long createTime; + /** + * 数据最后更新时间 + */ + @TableField("update_time") + private Timestamp updateTime; +} diff --git a/src/main/java/com/fengdu/gas/repository/impl/AdminMenuMapperImpl.java b/src/main/java/com/fengdu/gas/repository/impl/AdminMenuMapperImpl.java new file mode 100644 index 0000000..417bd73 --- /dev/null +++ b/src/main/java/com/fengdu/gas/repository/impl/AdminMenuMapperImpl.java @@ -0,0 +1,135 @@ +/** +# __----~~~~~~~~~~~------___ +# . . ~~//====...... __--~ ~~ +# -. \_|// |||\\ ~~~~~~::::... /~ +# ___-==_ _-~o~ \/ ||| \\ _/~~- +# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ +# _-~~ .=~ | \\-_ '-~7 /- / || \ / +# .~ .~ | \\ -_ / /- / || \ / +# / ____ / | \\ ~-_/ /|- _/ .|| \ / +# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ +# ' ~-| /| |-~\~~ __--~~ +# |-~~-_/ | | ~\_ _-~ /\ +# / \ \__ \/~ \__ +# _--~ _/ | .-~~____--~-/ ~~==. +# ((->/~ '.|||' -_| ~~-/ , . _|| +# -_ ~\ ~~---l__i__i__i--~~_/ +# _-~-__ ~) \--______________--~~ +# //.-~~~-~_--~- |-------~~~~~~~~ +# //.-~~~--\ +# 神兽保佑 +# 永无BUG! +*/ +package com.fengdu.gas.repository.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.fengdu.gas.common.PagerResult; +import com.fengdu.gas.common.enums.EYesOrNo; +import com.fengdu.gas.common.util.ListUtil; +import com.fengdu.gas.common.util.NumericUtil; +import com.fengdu.gas.common.util.StringUtil; +import com.fengdu.gas.entity.dto.OrderByDTO; +import com.fengdu.gas.entity.dto.SearchBasicDTO; +import com.fengdu.gas.entity.enums.EOrderBy; +import com.fengdu.gas.entity.search.SearchAdminMenu; +import com.fengdu.gas.repository.BasicMapperImpl; +import com.fengdu.gas.repository.mapper.AdminMenuMapper; +import com.fengdu.gas.repository.po.AdminMenuPO; +import org.springframework.stereotype.Repository; + +import java.util.List; + +/** + * 后台菜单 + * @author lin.liu + * @description 后台菜单 + */ +@Repository +public class AdminMenuMapperImpl extends BasicMapperImpl<AdminMenuPO, AdminMenuMapper> { + public AdminMenuMapper mapper; + AdminMenuMapperImpl(AdminMenuMapper mapper) { + super(mapper); + } + + @Override + public PagerResult<AdminMenuPO> search(SearchBasicDTO request) { + // 还原查询条件真实类型 + SearchAdminMenu search = (SearchAdminMenu)request; + // 查询条件 + LambdaQueryWrapper<AdminMenuPO> queryWrapper = this.query(); + // 非逻辑删除 + queryWrapper.eq(AdminMenuPO::getIsDelete, EYesOrNo.NO.getValue()); + // 状态 + //queryWrapper.eq(NumericUtil.tryParseInt(search.getStatus()).compareTo(0) > 0, AdminMenuPO::getStatus, search.getStatus()); + // 状态列表 + //queryWrapper.in(ListUtil.isNotNullOrEmpty(search.getListStatus()), AdminMenuPO::getStatus, search.getListStatus()); + + // 数据创建时间-起始 + queryWrapper.ge(NumericUtil.tryParseLong(search.getCreateTimeStart()).compareTo(0L) > 0, AdminMenuPO::getCreateTime, search.getCreateTimeStart()); + // 数据创建时间-截止 + queryWrapper.le(NumericUtil.tryParseLong(search.getCreateTimeEnd()).compareTo(0L) > 0, AdminMenuPO::getCreateTime, search.getCreateTimeEnd()); + // 关键字 + if (StringUtil.isNotNullOrEmpty(search.getKeywords())) { + queryWrapper.and(q -> + q.like(AdminMenuPO::getName, search.getKeywords()) + .or().like(AdminMenuPO::getTitle, search.getKeywords()) + ); + } + + // 排序处理 + if (ListUtil.isNotNullOrEmpty(search.getOrderBy())) { + for (OrderByDTO item : search.getOrderBy()) { + EOrderBy orderBy = EOrderBy.getByValue(item.getOrderBy()); + // 顺序排序 + if (item.getIsAsc()) { + switch (orderBy) { + // 主键 + case ID: + queryWrapper.orderByAsc(AdminMenuPO::getId); + break; + // 数据创建时间 + case CREATE_TIME: + queryWrapper.orderByAsc(AdminMenuPO::getCreateTime); + break; + // 最后更新时间 + case UPDATE_TIME: + queryWrapper.orderByAsc(AdminMenuPO::getUpdateTime); + break; + } + } else { + // 倒叙排序 + switch (orderBy) { + // 主键 + case ID: + queryWrapper.orderByDesc(AdminMenuPO::getId); + break; + // 数据创建时间 + case CREATE_TIME: + queryWrapper.orderByDesc(AdminMenuPO::getCreateTime); + break; + // 最后更新时间 + case UPDATE_TIME: + queryWrapper.orderByDesc(AdminMenuPO::getUpdateTime); + break; + } + } + } + } else { + queryWrapper.orderByDesc(AdminMenuPO::getId); + } + Page<AdminMenuPO> pageResult = DB.selectPage(new Page<>(search.getPage(), search.getLimit()), queryWrapper); + return new PagerResult<>(pageResult.getSize(), pageResult.getCurrent(), pageResult.getTotal(), pageResult.getRecords()); + } + + /** + * 根据父级菜单获取子菜单列表 + * @param parentId 父级菜单id + */ + public List<AdminMenuPO> list4Parent(Long parentId) { + // 查询条件 + LambdaQueryWrapper<AdminMenuPO> queryWrapper = this.query(); + queryWrapper.eq(AdminMenuPO::getParentId, parentId); + return DB.selectList(queryWrapper); + } +} diff --git a/src/main/java/com/fengdu/gas/repository/impl/AdminMenusMapperImpl.java b/src/main/java/com/fengdu/gas/repository/impl/AdminMenusMapperImpl.java new file mode 100644 index 0000000..ddc507a --- /dev/null +++ b/src/main/java/com/fengdu/gas/repository/impl/AdminMenusMapperImpl.java @@ -0,0 +1,138 @@ +/** +# __----~~~~~~~~~~~------___ +# . . ~~//====...... __--~ ~~ +# -. \_|// |||\\ ~~~~~~::::... /~ +# ___-==_ _-~o~ \/ ||| \\ _/~~- +# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ +# _-~~ .=~ | \\-_ '-~7 /- / || \ / +# .~ .~ | \\ -_ / /- / || \ / +# / ____ / | \\ ~-_/ /|- _/ .|| \ / +# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ +# ' ~-| /| |-~\~~ __--~~ +# |-~~-_/ | | ~\_ _-~ /\ +# / \ \__ \/~ \__ +# _--~ _/ | .-~~____--~-/ ~~==. +# ((->/~ '.|||' -_| ~~-/ , . _|| +# -_ ~\ ~~---l__i__i__i--~~_/ +# _-~-__ ~) \--______________--~~ +# //.-~~~-~_--~- |-------~~~~~~~~ +# //.-~~~--\ +# 神兽保佑 +# 永无BUG! +*/ +package com.fengdu.gas.repository.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.fengdu.gas.common.PagerResult; +import com.fengdu.gas.common.enums.EYesOrNo; +import com.fengdu.gas.entity.search.SearchAdminMenus; +import com.fengdu.gas.repository.BasicMapperImpl; +import com.fengdu.gas.repository.mapper.AdminMenusMapper; +import com.fengdu.gas.common.util.*; +import com.fengdu.gas.entity.dto.*; +import com.fengdu.gas.entity.enums.*; +import org.springframework.stereotype.Repository; + +import java.util.List; + +import com.fengdu.gas.repository.po.AdminMenusPO; + +/** + * 菜单信息 + * @author lin.liu + */ +@Repository +public class AdminMenusMapperImpl extends BasicMapperImpl<AdminMenusPO, AdminMenusMapper> { + AdminMenusMapperImpl(AdminMenusMapper mapper) { + super(mapper); + } + + @Override + public PagerResult<AdminMenusPO> search(SearchBasicDTO request) { + // 还原查询条件真实类型 + SearchAdminMenus search = (SearchAdminMenus)request; + // 查询条件 + LambdaQueryWrapper<AdminMenusPO> queryWrapper = this.query(); + // 非逻辑删除 + queryWrapper.eq(AdminMenusPO::getIsDelete, EYesOrNo.NO.getValue()); + // 状态 + //queryWrapper.eq(NumericUtil.tryParseInt(search.getStatus()).compareTo(0) > 0, AdminMenusPO::getStatus, search.getStatus()); + // 状态列表 + //queryWrapper.in(ListUtil.isNotNullOrEmpty(search.getListStatus()), AdminMenusPO::getStatus, search.getListStatus()); + + // 数据创建时间-起始 + queryWrapper.ge(NumericUtil.tryParseLong(search.getCreateTimeStart()).compareTo(0L) > 0, AdminMenusPO::getCreateTime, search.getCreateTimeStart()); + // 数据创建时间-截止 + queryWrapper.le(NumericUtil.tryParseLong(search.getCreateTimeEnd()).compareTo(0L) > 0, AdminMenusPO::getCreateTime, search.getCreateTimeEnd()); + // 关键字 + //if (StringUtil.isNotNullOrEmpty(search.getKeywords())) { + // queryWrapper.and(q -> + // q.like(AdminMenusPO::getName, search.getKeywords()) + // .or().like(AdminMenusPO::getPhone, search.getKeywords()) + // ); + //} + + // 排序处理 + if (ListUtil.isNotNullOrEmpty(search.getOrderBy())) { + for (OrderByDTO item : search.getOrderBy()) { + EOrderBy orderBy = EOrderBy.getByValue(item.getOrderBy()); + // 顺序排序 + if (item.getIsAsc()) { + switch (orderBy) { + // 主键 + case ID: + queryWrapper.orderByAsc(AdminMenusPO::getId); + break; + // 数据创建时间 + case CREATE_TIME: + queryWrapper.orderByAsc(AdminMenusPO::getCreateTime); + break; + // 最后更新时间 + case UPDATE_TIME: + queryWrapper.orderByAsc(AdminMenusPO::getUpdateTime); + break; + } + } else { + // 倒叙排序 + switch (orderBy) { + // 主键 + case ID: + queryWrapper.orderByDesc(AdminMenusPO::getId); + break; + // 数据创建时间 + case CREATE_TIME: + queryWrapper.orderByDesc(AdminMenusPO::getCreateTime); + break; + // 最后更新时间 + case UPDATE_TIME: + queryWrapper.orderByDesc(AdminMenusPO::getUpdateTime); + break; + } + } + } + } else { + queryWrapper.orderByDesc(AdminMenusPO::getId); + } + Page<AdminMenusPO> pageResult = super.selectPage(new Page<>(search.getPage(), search.getLimit()), queryWrapper); + return new PagerResult<>(pageResult.getSize(), pageResult.getCurrent(), pageResult.getTotal(), pageResult.getRecords()); + } + + public Boolean add(AdminMenusPO item) { + int rowCount = super.insert(item); + return rowCount == 1; + } + + public Boolean addNotIncrement(AdminMenusPO item) { + int rowCount = super.insert(item); + return rowCount == 1; + } + + public AdminMenusPO getById(Long id) { + return super.get(id); + } + + public List<AdminMenusPO> getListById(List<Long> listId) { + return super.getList(listId); + } +} diff --git a/src/main/java/com/fengdu/gas/repository/impl/AdminPermissionMapperImpl.java b/src/main/java/com/fengdu/gas/repository/impl/AdminPermissionMapperImpl.java new file mode 100644 index 0000000..a4f8efe --- /dev/null +++ b/src/main/java/com/fengdu/gas/repository/impl/AdminPermissionMapperImpl.java @@ -0,0 +1,141 @@ +/** +# __----~~~~~~~~~~~------___ +# . . ~~//====...... __--~ ~~ +# -. \_|// |||\\ ~~~~~~::::... /~ +# ___-==_ _-~o~ \/ ||| \\ _/~~- +# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ +# _-~~ .=~ | \\-_ '-~7 /- / || \ / +# .~ .~ | \\ -_ / /- / || \ / +# / ____ / | \\ ~-_/ /|- _/ .|| \ / +# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ +# ' ~-| /| |-~\~~ __--~~ +# |-~~-_/ | | ~\_ _-~ /\ +# / \ \__ \/~ \__ +# _--~ _/ | .-~~____--~-/ ~~==. +# ((->/~ '.|||' -_| ~~-/ , . _|| +# -_ ~\ ~~---l__i__i__i--~~_/ +# _-~-__ ~) \--______________--~~ +# //.-~~~-~_--~- |-------~~~~~~~~ +# //.-~~~--\ +# 神兽保佑 +# 永无BUG! +*/ +package com.fengdu.gas.repository.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.fengdu.gas.common.PagerResult; +import com.fengdu.gas.common.enums.EYesOrNo; +import com.fengdu.gas.common.util.ListUtil; +import com.fengdu.gas.common.util.NumericUtil; +import com.fengdu.gas.common.util.StringUtil; +import com.fengdu.gas.entity.dto.OrderByDTO; +import com.fengdu.gas.entity.dto.SearchBasicDTO; +import com.fengdu.gas.entity.enums.EOrderBy; +import com.fengdu.gas.entity.search.SearchAdminPermission; +import com.fengdu.gas.repository.BasicMapperImpl; +import com.fengdu.gas.repository.mapper.AdminPermissionMapper; +import com.fengdu.gas.repository.po.AdminPermissionPO; +import org.springframework.stereotype.Repository; + +import java.util.List; + +/** + * 后台用户权限表 + * @author lin.liu + * @description 后台用户权限表 + */ +@Repository +public class AdminPermissionMapperImpl extends BasicMapperImpl<AdminPermissionPO, AdminPermissionMapper> { + AdminPermissionMapperImpl(AdminPermissionMapper mapper) { + super(mapper); + } + + @Override + public PagerResult<AdminPermissionPO> search(SearchBasicDTO request) { + // 还原查询条件真实类型 + SearchAdminPermission search = (SearchAdminPermission)request; + // 查询条件 + LambdaQueryWrapper<AdminPermissionPO> queryWrapper = this.query(); + // 非逻辑删除 + queryWrapper.eq(AdminPermissionPO::getIsDelete, EYesOrNo.NO.getValue()); + // 状态 + //queryWrapper.eq(NumericUtil.tryParseInt(search.getStatus()).compareTo(0) > 0, AdminPermissionPO::getStatus, search.getStatus()); + // 状态列表 + //queryWrapper.in(ListUtil.isNotNullOrEmpty(search.getListStatus()), AdminPermissionPO::getStatus, search.getListStatus()); + + // 数据创建时间-起始 + queryWrapper.ge(NumericUtil.tryParseLong(search.getCreateTimeStart()).compareTo(0L) > 0, AdminPermissionPO::getCreateTime, search.getCreateTimeStart()); + // 数据创建时间-截止 + queryWrapper.le(NumericUtil.tryParseLong(search.getCreateTimeEnd()).compareTo(0L) > 0, AdminPermissionPO::getCreateTime, search.getCreateTimeEnd()); + // 关键字 + if (StringUtil.isNotNullOrEmpty(search.getKeywords())) { + queryWrapper.and(q -> + q.like(AdminPermissionPO::getName, search.getKeywords()) + .or().like(AdminPermissionPO::getMenuUrl, search.getKeywords()) + ); + } + + // 排序处理 + if (ListUtil.isNotNullOrEmpty(search.getOrderBy())) { + for (OrderByDTO item : search.getOrderBy()) { + EOrderBy orderBy = EOrderBy.getByValue(item.getOrderBy()); + // 顺序排序 + if (item.getIsAsc()) { + switch (orderBy) { + // 主键 + case ID: + queryWrapper.orderByAsc(AdminPermissionPO::getId); + break; + // 数据创建时间 + case CREATE_TIME: + queryWrapper.orderByAsc(AdminPermissionPO::getCreateTime); + break; + // 最后更新时间 + case UPDATE_TIME: + queryWrapper.orderByAsc(AdminPermissionPO::getUpdateTime); + break; + } + } else { + // 倒叙排序 + switch (orderBy) { + // 主键 + case ID: + queryWrapper.orderByDesc(AdminPermissionPO::getId); + break; + // 数据创建时间 + case CREATE_TIME: + queryWrapper.orderByDesc(AdminPermissionPO::getCreateTime); + break; + // 最后更新时间 + case UPDATE_TIME: + queryWrapper.orderByDesc(AdminPermissionPO::getUpdateTime); + break; + } + } + } + } else { + queryWrapper.orderByDesc(AdminPermissionPO::getId); + } + Page<AdminPermissionPO> pageResult = DB.selectPage(new Page<>(search.getPage(), search.getLimit()), queryWrapper); + return new PagerResult<>(pageResult.getSize(), pageResult.getCurrent(), pageResult.getTotal(), pageResult.getRecords()); + } + + /** + * 根据菜单id获取权限列表 + * @param listMenuId 菜单id + */ + public List<AdminPermissionPO> list4MenuId(List<Long> listMenuId) { + // 查询条件 + LambdaQueryWrapper<AdminPermissionPO> queryWrapper = this.query(); + queryWrapper.in(AdminPermissionPO::getMenuId, listMenuId); + return DB.selectList(queryWrapper); + } + + public AdminPermissionPO get4Sn(String sn) { + // 查询条件 + LambdaQueryWrapper<AdminPermissionPO> queryWrapper = this.query(); + queryWrapper.eq(AdminPermissionPO::getSn, sn); + return DB.selectOne(queryWrapper); + } +} diff --git a/src/main/java/com/fengdu/gas/repository/impl/AdminRoleMapperImpl.java b/src/main/java/com/fengdu/gas/repository/impl/AdminRoleMapperImpl.java new file mode 100644 index 0000000..fb4d062 --- /dev/null +++ b/src/main/java/com/fengdu/gas/repository/impl/AdminRoleMapperImpl.java @@ -0,0 +1,117 @@ +/** +# __----~~~~~~~~~~~------___ +# . . ~~//====...... __--~ ~~ +# -. \_|// |||\\ ~~~~~~::::... /~ +# ___-==_ _-~o~ \/ ||| \\ _/~~- +# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ +# _-~~ .=~ | \\-_ '-~7 /- / || \ / +# .~ .~ | \\ -_ / /- / || \ / +# / ____ / | \\ ~-_/ /|- _/ .|| \ / +# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ +# ' ~-| /| |-~\~~ __--~~ +# |-~~-_/ | | ~\_ _-~ /\ +# / \ \__ \/~ \__ +# _--~ _/ | .-~~____--~-/ ~~==. +# ((->/~ '.|||' -_| ~~-/ , . _|| +# -_ ~\ ~~---l__i__i__i--~~_/ +# _-~-__ ~) \--______________--~~ +# //.-~~~-~_--~- |-------~~~~~~~~ +# //.-~~~--\ +# 神兽保佑 +# 永无BUG! +*/ +package com.fengdu.gas.repository.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.fengdu.gas.common.PagerResult; +import com.fengdu.gas.common.enums.EYesOrNo; +import com.fengdu.gas.entity.search.SearchAdminRole; +import com.fengdu.gas.repository.BasicMapperImpl; +import com.fengdu.gas.repository.mapper.AdminRoleMapper; +import com.fengdu.gas.repository.po.AdminRolePO; +import com.fengdu.gas.common.util.*; +import com.fengdu.gas.entity.dto.*; +import com.fengdu.gas.entity.enums.*; +import org.springframework.stereotype.Repository; + +/** + * 后台用户角色表 + * @author lin.liu + * @description 后台用户角色表 + */ +@Repository +public class AdminRoleMapperImpl extends BasicMapperImpl<AdminRolePO, AdminRoleMapper> { + AdminRoleMapperImpl(AdminRoleMapper mapper) { + super(mapper); + } + + @Override + public PagerResult<AdminRolePO> search(SearchBasicDTO request) { + // 还原查询条件真实类型 + SearchAdminRole search = (SearchAdminRole)request; + // 查询条件 + LambdaQueryWrapper<AdminRolePO> queryWrapper = this.query(); + // 非逻辑删除 + queryWrapper.eq(AdminRolePO::getIsDelete, EYesOrNo.NO.getValue()); + // 状态 + //queryWrapper.eq(NumericUtil.tryParseInt(search.getStatus()).compareTo(0) > 0, AdminRolePO::getStatus, search.getStatus()); + // 状态列表 + //queryWrapper.in(ListUtil.isNotNullOrEmpty(search.getListStatus()), AdminRolePO::getStatus, search.getListStatus()); + + // 数据创建时间-起始 + queryWrapper.ge(NumericUtil.tryParseLong(search.getCreateTimeStart()).compareTo(0L) > 0, AdminRolePO::getCreateTime, search.getCreateTimeStart()); + // 数据创建时间-截止 + queryWrapper.le(NumericUtil.tryParseLong(search.getCreateTimeEnd()).compareTo(0L) > 0, AdminRolePO::getCreateTime, search.getCreateTimeEnd()); + // 关键字 + if (StringUtil.isNotNullOrEmpty(search.getKeywords())) { + queryWrapper.and(q -> + q.like(AdminRolePO::getName, search.getKeywords()) + .or().like(AdminRolePO::getDescription, search.getKeywords()) + ); + } + + // 排序处理 + if (ListUtil.isNotNullOrEmpty(search.getOrderBy())) { + for (OrderByDTO item : search.getOrderBy()) { + EOrderBy orderBy = EOrderBy.getByValue(item.getOrderBy()); + // 顺序排序 + if (item.getIsAsc()) { + switch (orderBy) { + // 主键 + case ID: + queryWrapper.orderByAsc(AdminRolePO::getId); + break; + // 数据创建时间 + case CREATE_TIME: + queryWrapper.orderByAsc(AdminRolePO::getCreateTime); + break; + // 最后更新时间 + case UPDATE_TIME: + queryWrapper.orderByAsc(AdminRolePO::getUpdateTime); + break; + } + } else { + // 倒叙排序 + switch (orderBy) { + // 主键 + case ID: + queryWrapper.orderByDesc(AdminRolePO::getId); + break; + // 数据创建时间 + case CREATE_TIME: + queryWrapper.orderByDesc(AdminRolePO::getCreateTime); + break; + // 最后更新时间 + case UPDATE_TIME: + queryWrapper.orderByDesc(AdminRolePO::getUpdateTime); + break; + } + } + } + } else { + queryWrapper.orderByDesc(AdminRolePO::getId); + } + Page<AdminRolePO> pageResult = DB.selectPage(new Page<>(search.getPage(), search.getLimit()), queryWrapper); + return new PagerResult<>(pageResult.getSize(), pageResult.getCurrent(), pageResult.getTotal(), pageResult.getRecords()); + }} diff --git a/src/main/java/com/fengdu/gas/repository/impl/AdminRoleMenuRelationMapperImpl.java b/src/main/java/com/fengdu/gas/repository/impl/AdminRoleMenuRelationMapperImpl.java new file mode 100644 index 0000000..c80e70e --- /dev/null +++ b/src/main/java/com/fengdu/gas/repository/impl/AdminRoleMenuRelationMapperImpl.java @@ -0,0 +1,144 @@ +/** +# __----~~~~~~~~~~~------___ +# . . ~~//====...... __--~ ~~ +# -. \_|// |||\\ ~~~~~~::::... /~ +# ___-==_ _-~o~ \/ ||| \\ _/~~- +# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ +# _-~~ .=~ | \\-_ '-~7 /- / || \ / +# .~ .~ | \\ -_ / /- / || \ / +# / ____ / | \\ ~-_/ /|- _/ .|| \ / +# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ +# ' ~-| /| |-~\~~ __--~~ +# |-~~-_/ | | ~\_ _-~ /\ +# / \ \__ \/~ \__ +# _--~ _/ | .-~~____--~-/ ~~==. +# ((->/~ '.|||' -_| ~~-/ , . _|| +# -_ ~\ ~~---l__i__i__i--~~_/ +# _-~-__ ~) \--______________--~~ +# //.-~~~-~_--~- |-------~~~~~~~~ +# //.-~~~--\ +# 神兽保佑 +# 永无BUG! +*/ +package com.fengdu.gas.repository.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.fengdu.gas.common.PagerResult; +import com.fengdu.gas.common.enums.EYesOrNo; +import com.fengdu.gas.common.util.ListUtil; +import com.fengdu.gas.common.util.NumericUtil; +import com.fengdu.gas.entity.dto.OrderByDTO; +import com.fengdu.gas.entity.dto.SearchBasicDTO; +import com.fengdu.gas.entity.enums.EOrderBy; +import com.fengdu.gas.entity.search.SearchAdminRoleMenuRelation; +import com.fengdu.gas.repository.BasicMapperImpl; +import com.fengdu.gas.repository.mapper.AdminRoleMenuRelationMapper; +import com.fengdu.gas.repository.po.AdminRoleMenuRelationPO; +import org.springframework.stereotype.Repository; + +import java.util.List; + +/** + * 后台角色菜单关系表 + * @author lin.liu + * @description 后台角色菜单关系表 + */ +@Repository +public class AdminRoleMenuRelationMapperImpl extends BasicMapperImpl<AdminRoleMenuRelationPO, AdminRoleMenuRelationMapper> { + AdminRoleMenuRelationMapperImpl(AdminRoleMenuRelationMapper mapper) { + super(mapper); + } + + @Override + public PagerResult<AdminRoleMenuRelationPO> search(SearchBasicDTO request) { + // 还原查询条件真实类型 + SearchAdminRoleMenuRelation search = (SearchAdminRoleMenuRelation)request; + // 查询条件 + LambdaQueryWrapper<AdminRoleMenuRelationPO> queryWrapper = this.query(); + // 非逻辑删除 + queryWrapper.eq(AdminRoleMenuRelationPO::getIsDelete, EYesOrNo.NO.getValue()); + // 状态 + //queryWrapper.eq(NumericUtil.tryParseInt(search.getStatus()).compareTo(0) > 0, AdminRoleMenuRelationPO::getStatus, search.getStatus()); + // 状态列表 + //queryWrapper.in(ListUtil.isNotNullOrEmpty(search.getListStatus()), AdminRoleMenuRelationPO::getStatus, search.getListStatus()); + + // 数据创建时间-起始 + queryWrapper.ge(NumericUtil.tryParseLong(search.getCreateTimeStart()).compareTo(0L) > 0, AdminRoleMenuRelationPO::getCreateTime, search.getCreateTimeStart()); + // 数据创建时间-截止 + queryWrapper.le(NumericUtil.tryParseLong(search.getCreateTimeEnd()).compareTo(0L) > 0, AdminRoleMenuRelationPO::getCreateTime, search.getCreateTimeEnd()); + // 关键字 + //if (StringUtil.isNotNullOrEmpty(search.getKeywords())) { + // queryWrapper.and(q -> + // q.like(AdminRoleMenuRelationPO::getName, search.getKeywords()) + // .or().like(AdminRoleMenuRelationPO::getPhone, search.getKeywords()) + // ); + //} + + // 排序处理 + if (ListUtil.isNotNullOrEmpty(search.getOrderBy())) { + for (OrderByDTO item : search.getOrderBy()) { + EOrderBy orderBy = EOrderBy.getByValue(item.getOrderBy()); + // 顺序排序 + if (item.getIsAsc()) { + switch (orderBy) { + // 主键 + case ID: + queryWrapper.orderByAsc(AdminRoleMenuRelationPO::getId); + break; + // 数据创建时间 + case CREATE_TIME: + queryWrapper.orderByAsc(AdminRoleMenuRelationPO::getCreateTime); + break; + // 最后更新时间 + case UPDATE_TIME: + queryWrapper.orderByAsc(AdminRoleMenuRelationPO::getUpdateTime); + break; + } + } else { + // 倒叙排序 + switch (orderBy) { + // 主键 + case ID: + queryWrapper.orderByDesc(AdminRoleMenuRelationPO::getId); + break; + // 数据创建时间 + case CREATE_TIME: + queryWrapper.orderByDesc(AdminRoleMenuRelationPO::getCreateTime); + break; + // 最后更新时间 + case UPDATE_TIME: + queryWrapper.orderByDesc(AdminRoleMenuRelationPO::getUpdateTime); + break; + } + } + } + } else { + queryWrapper.orderByDesc(AdminRoleMenuRelationPO::getId); + } + Page<AdminRoleMenuRelationPO> pageResult = DB.selectPage(new Page<>(search.getPage(), search.getLimit()), queryWrapper); + return new PagerResult<>(pageResult.getSize(), pageResult.getCurrent(), pageResult.getTotal(), pageResult.getRecords()); + } + + /** + * 根据角色id获取角色拥有的菜单列表 + * @param roleId 角色id + */ + public List<AdminRoleMenuRelationPO> list4Role(Long roleId) { + // 查询条件 + LambdaQueryWrapper<AdminRoleMenuRelationPO> queryWrapper = this.query(); + queryWrapper.eq(AdminRoleMenuRelationPO::getRoleId, roleId); + return DB.selectList(queryWrapper); + } + + /** + * 根据角色id获取角色拥有的菜单列表 + * @param listRoleId 角色id列表 + */ + public List<AdminRoleMenuRelationPO> list4Role(List<Long> listRoleId) { + // 查询条件 + LambdaQueryWrapper<AdminRoleMenuRelationPO> queryWrapper = this.query(); + queryWrapper.in(AdminRoleMenuRelationPO::getRoleId, listRoleId); + return DB.selectList(queryWrapper); + } +} diff --git a/src/main/java/com/fengdu/gas/repository/impl/AdminRolePermissionRelationMapperImpl.java b/src/main/java/com/fengdu/gas/repository/impl/AdminRolePermissionRelationMapperImpl.java new file mode 100644 index 0000000..7b07e64 --- /dev/null +++ b/src/main/java/com/fengdu/gas/repository/impl/AdminRolePermissionRelationMapperImpl.java @@ -0,0 +1,144 @@ +/** +# __----~~~~~~~~~~~------___ +# . . ~~//====...... __--~ ~~ +# -. \_|// |||\\ ~~~~~~::::... /~ +# ___-==_ _-~o~ \/ ||| \\ _/~~- +# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ +# _-~~ .=~ | \\-_ '-~7 /- / || \ / +# .~ .~ | \\ -_ / /- / || \ / +# / ____ / | \\ ~-_/ /|- _/ .|| \ / +# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ +# ' ~-| /| |-~\~~ __--~~ +# |-~~-_/ | | ~\_ _-~ /\ +# / \ \__ \/~ \__ +# _--~ _/ | .-~~____--~-/ ~~==. +# ((->/~ '.|||' -_| ~~-/ , . _|| +# -_ ~\ ~~---l__i__i__i--~~_/ +# _-~-__ ~) \--______________--~~ +# //.-~~~-~_--~- |-------~~~~~~~~ +# //.-~~~--\ +# 神兽保佑 +# 永无BUG! +*/ +package com.fengdu.gas.repository.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.fengdu.gas.common.PagerResult; +import com.fengdu.gas.common.enums.EYesOrNo; +import com.fengdu.gas.common.util.ListUtil; +import com.fengdu.gas.common.util.NumericUtil; +import com.fengdu.gas.entity.dto.OrderByDTO; +import com.fengdu.gas.entity.dto.SearchBasicDTO; +import com.fengdu.gas.entity.enums.EOrderBy; +import com.fengdu.gas.entity.search.SearchAdminRolePermissionRelation; +import com.fengdu.gas.repository.BasicMapperImpl; +import com.fengdu.gas.repository.mapper.AdminRolePermissionRelationMapper; +import com.fengdu.gas.repository.po.AdminRolePermissionRelationPO; +import org.springframework.stereotype.Repository; + +import java.util.List; + +/** + * 后台角色权限关系表 + * @author lin.liu + * @description 后台角色权限关系表 + */ +@Repository +public class AdminRolePermissionRelationMapperImpl extends BasicMapperImpl<AdminRolePermissionRelationPO, AdminRolePermissionRelationMapper> { + AdminRolePermissionRelationMapperImpl(AdminRolePermissionRelationMapper mapper) { + super(mapper); + } + + @Override + public PagerResult<AdminRolePermissionRelationPO> search(SearchBasicDTO request) { + // 还原查询条件真实类型 + SearchAdminRolePermissionRelation search = (SearchAdminRolePermissionRelation)request; + // 查询条件 + LambdaQueryWrapper<AdminRolePermissionRelationPO> queryWrapper = this.query(); + // 非逻辑删除 + queryWrapper.eq(AdminRolePermissionRelationPO::getIsDelete, EYesOrNo.NO.getValue()); + // 状态 + //queryWrapper.eq(NumericUtil.tryParseInt(search.getStatus()).compareTo(0) > 0, AdminRolePermissionRelationPO::getStatus, search.getStatus()); + // 状态列表 + //queryWrapper.in(ListUtil.isNotNullOrEmpty(search.getListStatus()), AdminRolePermissionRelationPO::getStatus, search.getListStatus()); + + // 数据创建时间-起始 + queryWrapper.ge(NumericUtil.tryParseLong(search.getCreateTimeStart()).compareTo(0L) > 0, AdminRolePermissionRelationPO::getCreateTime, search.getCreateTimeStart()); + // 数据创建时间-截止 + queryWrapper.le(NumericUtil.tryParseLong(search.getCreateTimeEnd()).compareTo(0L) > 0, AdminRolePermissionRelationPO::getCreateTime, search.getCreateTimeEnd()); + // 关键字 + //if (StringUtil.isNotNullOrEmpty(search.getKeywords())) { + // queryWrapper.and(q -> + // q.like(AdminRolePermissionRelationPO::getName, search.getKeywords()) + // .or().like(AdminRolePermissionRelationPO::getPhone, search.getKeywords()) + // ); + //} + + // 排序处理 + if (ListUtil.isNotNullOrEmpty(search.getOrderBy())) { + for (OrderByDTO item : search.getOrderBy()) { + EOrderBy orderBy = EOrderBy.getByValue(item.getOrderBy()); + // 顺序排序 + if (item.getIsAsc()) { + switch (orderBy) { + // 主键 + case ID: + queryWrapper.orderByAsc(AdminRolePermissionRelationPO::getId); + break; + // 数据创建时间 + case CREATE_TIME: + queryWrapper.orderByAsc(AdminRolePermissionRelationPO::getCreateTime); + break; + // 最后更新时间 + case UPDATE_TIME: + queryWrapper.orderByAsc(AdminRolePermissionRelationPO::getUpdateTime); + break; + } + } else { + // 倒叙排序 + switch (orderBy) { + // 主键 + case ID: + queryWrapper.orderByDesc(AdminRolePermissionRelationPO::getId); + break; + // 数据创建时间 + case CREATE_TIME: + queryWrapper.orderByDesc(AdminRolePermissionRelationPO::getCreateTime); + break; + // 最后更新时间 + case UPDATE_TIME: + queryWrapper.orderByDesc(AdminRolePermissionRelationPO::getUpdateTime); + break; + } + } + } + } else { + queryWrapper.orderByDesc(AdminRolePermissionRelationPO::getId); + } + Page<AdminRolePermissionRelationPO> pageResult = DB.selectPage(new Page<>(search.getPage(), search.getLimit()), queryWrapper); + return new PagerResult<>(pageResult.getSize(), pageResult.getCurrent(), pageResult.getTotal(), pageResult.getRecords()); + } + + /** + * 根据角色获取拥有的权限列表 + * @param roleId 角色id + */ + public List<AdminRolePermissionRelationPO> list4Role(Long roleId) { + // 查询条件 + LambdaQueryWrapper<AdminRolePermissionRelationPO> queryWrapper = this.query(); + queryWrapper.eq(AdminRolePermissionRelationPO::getRoleId, roleId); + return DB.selectList(queryWrapper); + } + + /** + * 根据角色获取拥有的权限列表 + * @param listRoleId 角色id列表 + */ + public List<AdminRolePermissionRelationPO> list4Role(List<Long> listRoleId) { + // 查询条件 + LambdaQueryWrapper<AdminRolePermissionRelationPO> queryWrapper = this.query(); + queryWrapper.in(AdminRolePermissionRelationPO::getRoleId, listRoleId); + return DB.selectList(queryWrapper); + } +} diff --git a/src/main/java/com/fengdu/gas/repository/impl/AdminRoleRelationMapperImpl.java b/src/main/java/com/fengdu/gas/repository/impl/AdminRoleRelationMapperImpl.java new file mode 100644 index 0000000..94876a6 --- /dev/null +++ b/src/main/java/com/fengdu/gas/repository/impl/AdminRoleRelationMapperImpl.java @@ -0,0 +1,144 @@ +/** +# __----~~~~~~~~~~~------___ +# . . ~~//====...... __--~ ~~ +# -. \_|// |||\\ ~~~~~~::::... /~ +# ___-==_ _-~o~ \/ ||| \\ _/~~- +# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ +# _-~~ .=~ | \\-_ '-~7 /- / || \ / +# .~ .~ | \\ -_ / /- / || \ / +# / ____ / | \\ ~-_/ /|- _/ .|| \ / +# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ +# ' ~-| /| |-~\~~ __--~~ +# |-~~-_/ | | ~\_ _-~ /\ +# / \ \__ \/~ \__ +# _--~ _/ | .-~~____--~-/ ~~==. +# ((->/~ '.|||' -_| ~~-/ , . _|| +# -_ ~\ ~~---l__i__i__i--~~_/ +# _-~-__ ~) \--______________--~~ +# //.-~~~-~_--~- |-------~~~~~~~~ +# //.-~~~--\ +# 神兽保佑 +# 永无BUG! +*/ +package com.fengdu.gas.repository.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.fengdu.gas.common.PagerResult; +import com.fengdu.gas.common.enums.EYesOrNo; +import com.fengdu.gas.common.util.ListUtil; +import com.fengdu.gas.common.util.NumericUtil; +import com.fengdu.gas.entity.dto.OrderByDTO; +import com.fengdu.gas.entity.dto.SearchBasicDTO; +import com.fengdu.gas.entity.enums.EOrderBy; +import com.fengdu.gas.entity.search.SearchAdminRoleRelation; +import com.fengdu.gas.repository.BasicMapperImpl; +import com.fengdu.gas.repository.mapper.AdminRoleRelationMapper; +import com.fengdu.gas.repository.po.AdminRoleRelationPO; +import org.springframework.stereotype.Repository; + +import java.util.List; + +/** + * 后台用户和角色关系表 + * @author lin.liu + * @description 后台用户和角色关系表 + */ +@Repository +public class AdminRoleRelationMapperImpl extends BasicMapperImpl<AdminRoleRelationPO, AdminRoleRelationMapper> { + AdminRoleRelationMapperImpl(AdminRoleRelationMapper mapper) { + super(mapper); + } + + @Override + public PagerResult<AdminRoleRelationPO> search(SearchBasicDTO request) { + // 还原查询条件真实类型 + SearchAdminRoleRelation search = (SearchAdminRoleRelation)request; + // 查询条件 + LambdaQueryWrapper<AdminRoleRelationPO> queryWrapper = this.query(); + // 非逻辑删除 + queryWrapper.eq(AdminRoleRelationPO::getIsDelete, EYesOrNo.NO.getValue()); + // 状态 + //queryWrapper.eq(NumericUtil.tryParseInt(search.getStatus()).compareTo(0) > 0, AdminRoleRelationPO::getStatus, search.getStatus()); + // 状态列表 + //queryWrapper.in(ListUtil.isNotNullOrEmpty(search.getListStatus()), AdminRoleRelationPO::getStatus, search.getListStatus()); + + // 数据创建时间-起始 + queryWrapper.ge(NumericUtil.tryParseLong(search.getCreateTimeStart()).compareTo(0L) > 0, AdminRoleRelationPO::getCreateTime, search.getCreateTimeStart()); + // 数据创建时间-截止 + queryWrapper.le(NumericUtil.tryParseLong(search.getCreateTimeEnd()).compareTo(0L) > 0, AdminRoleRelationPO::getCreateTime, search.getCreateTimeEnd()); + // 关键字 + //if (StringUtil.isNotNullOrEmpty(search.getKeywords())) { + // queryWrapper.and(q -> + // q.like(AdminRoleRelationPO::getName, search.getKeywords()) + // .or().like(AdminRoleRelationPO::getPhone, search.getKeywords()) + // ); + //} + + // 排序处理 + if (ListUtil.isNotNullOrEmpty(search.getOrderBy())) { + for (OrderByDTO item : search.getOrderBy()) { + EOrderBy orderBy = EOrderBy.getByValue(item.getOrderBy()); + // 顺序排序 + if (item.getIsAsc()) { + switch (orderBy) { + // 主键 + case ID: + queryWrapper.orderByAsc(AdminRoleRelationPO::getId); + break; + // 数据创建时间 + case CREATE_TIME: + queryWrapper.orderByAsc(AdminRoleRelationPO::getCreateTime); + break; + // 最后更新时间 + case UPDATE_TIME: + queryWrapper.orderByAsc(AdminRoleRelationPO::getUpdateTime); + break; + } + } else { + // 倒叙排序 + switch (orderBy) { + // 主键 + case ID: + queryWrapper.orderByDesc(AdminRoleRelationPO::getId); + break; + // 数据创建时间 + case CREATE_TIME: + queryWrapper.orderByDesc(AdminRoleRelationPO::getCreateTime); + break; + // 最后更新时间 + case UPDATE_TIME: + queryWrapper.orderByDesc(AdminRoleRelationPO::getUpdateTime); + break; + } + } + } + } else { + queryWrapper.orderByDesc(AdminRoleRelationPO::getId); + } + Page<AdminRoleRelationPO> pageResult = DB.selectPage(new Page<>(search.getPage(), search.getLimit()), queryWrapper); + return new PagerResult<>(pageResult.getSize(), pageResult.getCurrent(), pageResult.getTotal(), pageResult.getRecords()); + } + + /** + * 根据管理员获取拥有的角色列表 + * @param adminId 管理员id + */ + public List<AdminRoleRelationPO> list4Admin(Long adminId) { + // 查询条件 + LambdaQueryWrapper<AdminRoleRelationPO> queryWrapper = this.query(); + queryWrapper.eq(AdminRoleRelationPO::getAdminId, adminId); + return DB.selectList(queryWrapper); + } + + /** + * 根据管理员获取拥有的角色列表 + * @param listAdminId 管理员id列表 + */ + public List<AdminRoleRelationPO> list4Admin(List<Long> listAdminId) { + // 查询条件 + LambdaQueryWrapper<AdminRoleRelationPO> queryWrapper = this.query(); + queryWrapper.in(AdminRoleRelationPO::getAdminId, listAdminId); + return DB.selectList(queryWrapper); + } +} diff --git a/src/main/java/com/fengdu/gas/repository/impl/AdminUserMapperImpl.java b/src/main/java/com/fengdu/gas/repository/impl/AdminUserMapperImpl.java new file mode 100644 index 0000000..41f6195 --- /dev/null +++ b/src/main/java/com/fengdu/gas/repository/impl/AdminUserMapperImpl.java @@ -0,0 +1,134 @@ +/** + * # __----~~~~~~~~~~~------___ + * # . . ~~//====...... __--~ ~~ + * # -. \_|// |||\\ ~~~~~~::::... /~ + * # ___-==_ _-~o~ \/ ||| \\ _/~~- + * # __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ + * # _-~~ .=~ | \\-_ '-~7 /- / || \ / + * # .~ .~ | \\ -_ / /- / || \ / + * # / ____ / | \\ ~-_/ /|- _/ .|| \ / + * # |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ + * # ' ~-| /| |-~\~~ __--~~ + * # |-~~-_/ | | ~\_ _-~ /\ + * # / \ \__ \/~ \__ + * # _--~ _/ | .-~~____--~-/ ~~==. + * # ((->/~ '.|||' -_| ~~-/ , . _|| + * # -_ ~\ ~~---l__i__i__i--~~_/ + * # _-~-__ ~) \--______________--~~ + * # //.-~~~-~_--~- |-------~~~~~~~~ + * # //.-~~~--\ + * # 神兽保佑 + * # 永无BUG! + */ +package com.fengdu.gas.repository.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.fengdu.gas.common.PagerResult; +import com.fengdu.gas.common.enums.EYesOrNo; +import com.fengdu.gas.common.util.ListUtil; +import com.fengdu.gas.common.util.NumericUtil; +import com.fengdu.gas.common.util.StringUtil; +import com.fengdu.gas.entity.dto.OrderByDTO; +import com.fengdu.gas.entity.dto.SearchBasicDTO; +import com.fengdu.gas.entity.enums.EOrderBy; +import com.fengdu.gas.entity.search.SearchAdminUser; +import com.fengdu.gas.repository.BasicMapperImpl; +import com.fengdu.gas.repository.mapper.AdminUserMapper; +import com.fengdu.gas.repository.po.AdminUserPO; +import org.springframework.stereotype.Repository; + +/** + * 管理员帐号 + * @author lin.liu + * @description 管理员帐号 + */ +@Repository +public class AdminUserMapperImpl extends BasicMapperImpl<AdminUserPO, AdminUserMapper> { + AdminUserMapperImpl(AdminUserMapper mapper) { + super(mapper); + } + + @Override + public PagerResult<AdminUserPO> search(SearchBasicDTO request) { + // 还原查询条件真实类型 + SearchAdminUser search = (SearchAdminUser) request; + // 查询条件 + LambdaQueryWrapper<AdminUserPO> queryWrapper = this.query(); + // 非逻辑删除 + queryWrapper.eq(AdminUserPO::getIsDelete, EYesOrNo.NO.getValue()); + // 状态 + //queryWrapper.eq(NumericUtil.tryParseInt(search.getStatus()).compareTo(0) > 0, AdminUserPO::getStatus, search.getStatus()); + // 状态列表 + //queryWrapper.in(ListUtil.isNotNullOrEmpty(search.getListStatus()), AdminUserPO::getStatus, search.getListStatus()); + + // 数据创建时间-起始 + queryWrapper.ge(NumericUtil.tryParseLong(search.getCreateTimeStart()).compareTo(0L) > 0, AdminUserPO::getCreateTime, search.getCreateTimeStart()); + // 数据创建时间-截止 + queryWrapper.le(NumericUtil.tryParseLong(search.getCreateTimeEnd()).compareTo(0L) > 0, AdminUserPO::getCreateTime, search.getCreateTimeEnd()); + // 关键字 + if (StringUtil.isNotNullOrEmpty(search.getKeywords())) { + queryWrapper.and(q -> + q.like(AdminUserPO::getUserName, search.getKeywords()) + .or().like(AdminUserPO::getNickName, search.getKeywords()) + .or().like(AdminUserPO::getContact, search.getKeywords()) + .or().like(AdminUserPO::getEmail, search.getKeywords()) + ); + } + + // 排序处理 + if (ListUtil.isNotNullOrEmpty(search.getOrderBy())) { + for (OrderByDTO item : search.getOrderBy()) { + EOrderBy orderBy = EOrderBy.getByValue(item.getOrderBy()); + // 顺序排序 + if (item.getIsAsc()) { + switch (orderBy) { + // 主键 + case ID: + queryWrapper.orderByAsc(AdminUserPO::getId); + break; + // 数据创建时间 + case CREATE_TIME: + queryWrapper.orderByAsc(AdminUserPO::getCreateTime); + break; + // 最后更新时间 + case UPDATE_TIME: + queryWrapper.orderByAsc(AdminUserPO::getUpdateTime); + break; + } + } else { + // 倒叙排序 + switch (orderBy) { + // 主键 + case ID: + queryWrapper.orderByDesc(AdminUserPO::getId); + break; + // 数据创建时间 + case CREATE_TIME: + queryWrapper.orderByDesc(AdminUserPO::getCreateTime); + break; + // 最后更新时间 + case UPDATE_TIME: + queryWrapper.orderByDesc(AdminUserPO::getUpdateTime); + break; + } + } + } + } else { + queryWrapper.orderByDesc(AdminUserPO::getId); + } + Page<AdminUserPO> pageResult = DB.selectPage(new Page<>(search.getPage(), search.getLimit()), queryWrapper); + return new PagerResult<>(pageResult.getSize(), pageResult.getCurrent(), pageResult.getTotal(), pageResult.getRecords()); + } + + /** + * 根据用户名获取管理端用户 + * @param userName 用户名 + */ + public AdminUserPO get4Name(String userName) { + // 查询条件 + LambdaQueryWrapper<AdminUserPO> queryWrapper = this.query(); + queryWrapper.eq(AdminUserPO::getUserName, userName); + return DB.selectOne(queryWrapper); + } +} diff --git a/src/main/java/com/fengdu/gas/repository/impl/NoticeMapperImpl.java b/src/main/java/com/fengdu/gas/repository/impl/NoticeMapperImpl.java new file mode 100644 index 0000000..ffdd7b0 --- /dev/null +++ b/src/main/java/com/fengdu/gas/repository/impl/NoticeMapperImpl.java @@ -0,0 +1,122 @@ +/** +# __----~~~~~~~~~~~------___ +# . . ~~//====...... __--~ ~~ +# -. \_|// |||\\ ~~~~~~::::... /~ +# ___-==_ _-~o~ \/ ||| \\ _/~~- +# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ +# _-~~ .=~ | \\-_ '-~7 /- / || \ / +# .~ .~ | \\ -_ / /- / || \ / +# / ____ / | \\ ~-_/ /|- _/ .|| \ / +# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ +# ' ~-| /| |-~\~~ __--~~ +# |-~~-_/ | | ~\_ _-~ /\ +# / \ \__ \/~ \__ +# _--~ _/ | .-~~____--~-/ ~~==. +# ((->/~ '.|||' -_| ~~-/ , . _|| +# -_ ~\ ~~---l__i__i__i--~~_/ +# _-~-__ ~) \--______________--~~ +# //.-~~~-~_--~- |-------~~~~~~~~ +# //.-~~~--\ +# 神兽保佑 +# 永无BUG! +*/ +package com.fengdu.gas.repository.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.fengdu.gas.common.PagerResult; +import com.fengdu.gas.common.enums.EYesOrNo; +import com.fengdu.gas.common.util.ListUtil; +import com.fengdu.gas.common.util.NumericUtil; +import com.fengdu.gas.entity.dto.OrderByDTO; +import com.fengdu.gas.entity.dto.SearchBasicDTO; +import com.fengdu.gas.entity.enums.EOrderBy; +import com.fengdu.gas.entity.search.SearchNotice; +import com.fengdu.gas.repository.BasicMapperImpl; +import com.fengdu.gas.repository.mapper.NoticeMapper; +import com.fengdu.gas.repository.po.NoticePO; +import org.springframework.stereotype.Repository; + +import java.util.ArrayList; + +/** + * 公告 + * @author lin.liu + * @description 公告 + */ +@Repository +public class NoticeMapperImpl extends BasicMapperImpl<NoticePO, NoticeMapper> { + NoticeMapperImpl(NoticeMapper mapper) { + super(mapper); + } + + @Override + public PagerResult<NoticePO> search(SearchBasicDTO request) { + // 还原查询条件真实类型 + SearchNotice search = (SearchNotice)request; + // 查询条件 + LambdaQueryWrapper<NoticePO> queryWrapper = this.query(); + // 非逻辑删除 + queryWrapper.eq(NoticePO::getIsDelete, EYesOrNo.NO.getValue()); + // 状态 + //queryWrapper.eq(NumericUtil.tryParseInt(search.getStatus()).compareTo(0) > 0, NoticePO::getStatus, search.getStatus()); + // 状态列表 + //queryWrapper.in(ListUtil.isNotNullOrEmpty(search.getListStatus()), NoticePO::getStatus, search.getListStatus()); + + // 数据创建时间-起始 + queryWrapper.ge(NumericUtil.tryParseLong(search.getCreateTimeStart()).compareTo(0L) > 0, NoticePO::getCreateTime, search.getCreateTimeStart()); + // 数据创建时间-截止 + queryWrapper.le(NumericUtil.tryParseLong(search.getCreateTimeEnd()).compareTo(0L) > 0, NoticePO::getCreateTime, search.getCreateTimeEnd()); + // 关键字 + //if (StringUtil.isNotNullOrEmpty(search.getKeywords())) { + // queryWrapper.and(q -> + // q.like(NoticePO::getName, search.getKeywords()) + // .or().like(NoticePO::getPhone, search.getKeywords()) + // ); + //} + + // 排序处理 + if (ListUtil.isNotNullOrEmpty(search.getOrderBy())) { + for (OrderByDTO item : search.getOrderBy()) { + EOrderBy orderBy = EOrderBy.getByValue(item.getOrderBy()); + // 顺序排序 + if (item.getIsAsc()) { + switch (orderBy) { + // 主键 + case ID: + queryWrapper.orderByAsc(NoticePO::getId); + break; + // 数据创建时间 + case CREATE_TIME: + queryWrapper.orderByAsc(NoticePO::getCreateTime); + break; + // 最后更新时间 + case UPDATE_TIME: + queryWrapper.orderByAsc(NoticePO::getUpdateTime); + break; + } + } else { + // 倒叙排序 + switch (orderBy) { + // 主键 + case ID: + queryWrapper.orderByDesc(NoticePO::getId); + break; + // 数据创建时间 + case CREATE_TIME: + queryWrapper.orderByDesc(NoticePO::getCreateTime); + break; + // 最后更新时间 + case UPDATE_TIME: + queryWrapper.orderByDesc(NoticePO::getUpdateTime); + break; + } + } + } + } else { + queryWrapper.orderByDesc(NoticePO::getId); + } + return new PagerResult<>(search.getLimit(), search.getPage(), 0L, new ArrayList<>()); +// DB.selectCount() +// Page<NoticeBO> pageResult = DB.selectObjs(new Page<>(search.getPage(), search.getLimit()), queryWrapper); +// return new PagerResult<>(pageResult.getSize(), pageResult.getCurrent(), pageResult.getTotal(), pageResult.getRecords()); + }} diff --git a/src/main/java/com/fengdu/gas/repository/impl/QuartzTaskErrorMapperImpl.java b/src/main/java/com/fengdu/gas/repository/impl/QuartzTaskErrorMapperImpl.java new file mode 100644 index 0000000..b0d2eb7 --- /dev/null +++ b/src/main/java/com/fengdu/gas/repository/impl/QuartzTaskErrorMapperImpl.java @@ -0,0 +1,115 @@ +package com.fengdu.gas.repository.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.fengdu.gas.common.PagerResult; +import com.fengdu.gas.common.enums.EYesOrNo; +import com.fengdu.gas.common.util.ListUtil; +import com.fengdu.gas.common.util.NumericUtil; +import com.fengdu.gas.entity.dto.OrderByDTO; +import com.fengdu.gas.entity.dto.SearchBasicDTO; +import com.fengdu.gas.entity.enums.EOrderBy; +import com.fengdu.gas.entity.search.SearchQuartzTaskError; +import com.fengdu.gas.repository.BasicMapperImpl; +import com.fengdu.gas.repository.mapper.QuartzTaskErrorMapper; +import com.fengdu.gas.repository.po.QuartzTaskErrorPO; +import org.springframework.stereotype.Repository; + +/** + * 定时任务错误信息表 + * @author lin.liu + * @description 定时任务错误信息表 + */ +@Repository +public class QuartzTaskErrorMapperImpl extends BasicMapperImpl<QuartzTaskErrorPO, QuartzTaskErrorMapper> { + public QuartzTaskErrorMapperImpl(QuartzTaskErrorMapper mapper) { + super(mapper); + } + + /** + * 分页查询 + * + * @param request 请求参数 + */ + @Override + public PagerResult<QuartzTaskErrorPO> search(SearchBasicDTO request) { + // 查询条件类型还原 + SearchQuartzTaskError search = (SearchQuartzTaskError)request; + + LambdaQueryWrapper<QuartzTaskErrorPO> queryWrapper = this.query(); + // 状态非逻辑删除 + queryWrapper.eq(QuartzTaskErrorPO::getIsDelete, EYesOrNo.NO.getValue()); + // 状态 + //queryWrapper.eq(NumericUtil.tryParseInt(search.getStatus()).compareTo(0) > 0, QuartzTaskErrorPO::getState, search.getStatus()); + // 状态列表 + //queryWrapper.in(ListUtil.isNotNullOrEmpty(search.getListStatus()), QuartzTaskErrorPO::getState, search.getListStatus()); + // 数据创建时间-起始 + queryWrapper.ge(NumericUtil.tryParseLong(search.getCreateTimeStart()).compareTo(0L) > 0, QuartzTaskErrorPO::getCreateTime, search.getCreateTimeStart()); + // 数据创建时间-截止 + queryWrapper.le(NumericUtil.tryParseLong(search.getCreateTimeEnd()).compareTo(0L) > 0, QuartzTaskErrorPO::getCreateTime, search.getCreateTimeEnd()); + // 关键字 + //if (StringUtil.isNotNullOrEmpty(search.getKeywords())) { + // queryWrapper.and(q -> + // q.like(QuartzTaskErrorPO::getRealName, search.getKeywords()) + // .or().like(QuartzTaskErrorPO::getContactPhone, search.getKeywords()) + // ); + //} + // 排序处理 + if (ListUtil.isNotNullOrEmpty(search.getOrderBy())) { + for (OrderByDTO item : search.getOrderBy()) { + EOrderBy orderBy = EOrderBy.getByValue(item.getOrderBy()); + // 顺序排序 + if (item.getIsAsc()) { + switch (orderBy) { + // 主键 + case ID: + queryWrapper.orderByAsc(QuartzTaskErrorPO::getId); + break; + // 数据创建时间 + case CREATE_TIME: + queryWrapper.orderByAsc(QuartzTaskErrorPO::getCreateTime); + break; + // 最后更新时间 + case UPDATE_TIME: + queryWrapper.orderByAsc(QuartzTaskErrorPO::getUpdateTime); + break; + } + } else { + // 倒叙排序 + switch (orderBy) { + // 主键 + case ID: + queryWrapper.orderByAsc(QuartzTaskErrorPO::getId); + break; + // 数据创建时间 + case CREATE_TIME: + queryWrapper.orderByAsc(QuartzTaskErrorPO::getCreateTime); + break; + // 最后更新时间 + case UPDATE_TIME: + queryWrapper.orderByAsc(QuartzTaskErrorPO::getUpdateTime); + break; + } + } + } + } else { + queryWrapper.orderByDesc(QuartzTaskErrorPO::getId); + } + Page<QuartzTaskErrorPO> pageResult = DB.selectPage(new Page<>(search.getPage(), search.getLimit()), queryWrapper); + return new PagerResult<>(pageResult.getSize(), pageResult.getCurrent(), pageResult.getTotal(), pageResult.getRecords()); + } + + public QuartzTaskErrorPO get4RecordId(String recordId) { + LambdaQueryWrapper<QuartzTaskErrorPO> queryWrapper = this.query(); + // 执行记录编号 + queryWrapper.eq(QuartzTaskErrorPO::getTaskExecuteRecordId, recordId); + return DB.selectOne(queryWrapper); + } + + public int clear4DateTime(long time) { + LambdaQueryWrapper<QuartzTaskErrorPO> query = this.query(); + query.lt(QuartzTaskErrorPO::getCreateTime, time); + return DB.delete(query); + + } +} diff --git a/src/main/java/com/fengdu/gas/repository/impl/QuartzTaskInfoMapperImpl.java b/src/main/java/com/fengdu/gas/repository/impl/QuartzTaskInfoMapperImpl.java new file mode 100644 index 0000000..95b2ee4 --- /dev/null +++ b/src/main/java/com/fengdu/gas/repository/impl/QuartzTaskInfoMapperImpl.java @@ -0,0 +1,120 @@ +package com.fengdu.gas.repository.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.fengdu.gas.common.PagerResult; +import com.fengdu.gas.common.enums.EYesOrNo; +import com.fengdu.gas.common.util.ListUtil; +import com.fengdu.gas.common.util.NumericUtil; +import com.fengdu.gas.common.util.StringUtil; +import com.fengdu.gas.entity.dto.OrderByDTO; +import com.fengdu.gas.entity.dto.SearchBasicDTO; +import com.fengdu.gas.entity.enums.EOrderBy; +import com.fengdu.gas.entity.search.SearchQuartzTaskInfo; +import com.fengdu.gas.repository.BasicMapperImpl; +import com.fengdu.gas.repository.mapper.QuartzTaskInfoMapper; +import com.fengdu.gas.repository.po.QuartzTaskInfoPO; +import org.springframework.stereotype.Repository; + +import java.util.List; + +/** + * 定时任务信息表 + * + * @author lin.liu + * @description 定时任务信息表 + */ +@Repository +public class QuartzTaskInfoMapperImpl extends BasicMapperImpl<QuartzTaskInfoPO, QuartzTaskInfoMapper> { + public QuartzTaskInfoMapperImpl(QuartzTaskInfoMapper mapper) { + super(mapper); + } + + /** + * 分页查询 + * + * @param request 请求参数 + */ + @Override + public PagerResult<QuartzTaskInfoPO> search(SearchBasicDTO request) { + // 查询条件类型还原 + SearchQuartzTaskInfo search = (SearchQuartzTaskInfo) request; + + LambdaQueryWrapper<QuartzTaskInfoPO> queryWrapper = this.query(); + // 状态非逻辑删除 + queryWrapper.eq(QuartzTaskInfoPO::getIsDelete, EYesOrNo.NO.getValue()); + // 状态 + queryWrapper.eq(NumericUtil.tryParseInt(search.getStatus()).compareTo(0) > 0, QuartzTaskInfoPO::getStatus, search.getStatus()); + // 状态列表 + queryWrapper.in(ListUtil.isNotNullOrEmpty(search.getListStatus()), QuartzTaskInfoPO::getStatus, search.getListStatus()); + // 任务编号 + queryWrapper.eq(StringUtil.isNotNullOrEmpty(search.getTaskNo()), QuartzTaskInfoPO::getTaskNo, search.getTaskNo()); + // 数据创建时间-起始 + queryWrapper.ge(NumericUtil.tryParseLong(search.getCreateTimeStart()).compareTo(0L) > 0, QuartzTaskInfoPO::getCreateTime, search.getCreateTimeStart()); + // 数据创建时间-截止 + queryWrapper.le(NumericUtil.tryParseLong(search.getCreateTimeEnd()).compareTo(0L) > 0, QuartzTaskInfoPO::getCreateTime, search.getCreateTimeEnd()); + // 关键字 + if (StringUtil.isNotNullOrEmpty(search.getKeywords())) { + queryWrapper.like(QuartzTaskInfoPO::getTaskName, search.getKeywords()); + } + // 排序处理 + if (ListUtil.isNotNullOrEmpty(search.getOrderBy())) { + for (OrderByDTO item : search.getOrderBy()) { + EOrderBy orderBy = EOrderBy.getByValue(item.getOrderBy()); + // 顺序排序 + if (item.getIsAsc()) { + switch (orderBy) { + // 主键 + case ID: + queryWrapper.orderByAsc(QuartzTaskInfoPO::getId); + break; + // 数据创建时间 + case CREATE_TIME: + queryWrapper.orderByAsc(QuartzTaskInfoPO::getCreateTime); + break; + // 最后更新时间 + case UPDATE_TIME: + queryWrapper.orderByAsc(QuartzTaskInfoPO::getUpdateTime); + break; + } + } else { + // 倒叙排序 + switch (orderBy) { + // 主键 + case ID: + queryWrapper.orderByAsc(QuartzTaskInfoPO::getId); + break; + // 数据创建时间 + case CREATE_TIME: + queryWrapper.orderByAsc(QuartzTaskInfoPO::getCreateTime); + break; + // 最后更新时间 + case UPDATE_TIME: + queryWrapper.orderByAsc(QuartzTaskInfoPO::getUpdateTime); + break; + } + } + } + } else { + queryWrapper.orderByDesc(QuartzTaskInfoPO::getId); + } + Page<QuartzTaskInfoPO> pageResult = DB.selectPage(new Page<>(search.getPage(), search.getLimit()), queryWrapper); + return new PagerResult<>(pageResult.getSize(), pageResult.getCurrent(), pageResult.getTotal(), pageResult.getRecords()); + } + + public List<QuartzTaskInfoPO> list4Status(Integer status) { + LambdaQueryWrapper<QuartzTaskInfoPO> queryWrapper = this.query(); + // 非逻辑删除 + queryWrapper.eq(QuartzTaskInfoPO::getIsDelete, EYesOrNo.NO.getValue()); + // 状态 + queryWrapper.eq(QuartzTaskInfoPO::getStatus, status); + return DB.selectList(queryWrapper); + } + + public QuartzTaskInfoPO get4No(String taskNo) { + LambdaQueryWrapper<QuartzTaskInfoPO> queryWrapper = this.query(); + // 任务编号 + queryWrapper.eq(QuartzTaskInfoPO::getTaskNo, taskNo); + return DB.selectOne(queryWrapper); + } +} diff --git a/src/main/java/com/fengdu/gas/repository/impl/QuartzTaskRecordMapperImpl.java b/src/main/java/com/fengdu/gas/repository/impl/QuartzTaskRecordMapperImpl.java new file mode 100644 index 0000000..3ddbd1d --- /dev/null +++ b/src/main/java/com/fengdu/gas/repository/impl/QuartzTaskRecordMapperImpl.java @@ -0,0 +1,114 @@ +package com.fengdu.gas.repository.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.fengdu.gas.common.PagerResult; +import com.fengdu.gas.common.enums.EYesOrNo; +import com.fengdu.gas.common.util.ListUtil; +import com.fengdu.gas.common.util.NumericUtil; +import com.fengdu.gas.common.util.StringUtil; +import com.fengdu.gas.entity.dto.OrderByDTO; +import com.fengdu.gas.entity.dto.SearchBasicDTO; +import com.fengdu.gas.entity.enums.EOrderBy; +import com.fengdu.gas.entity.search.SearchQuartzTaskRecord; +import com.fengdu.gas.repository.BasicMapperImpl; +import com.fengdu.gas.repository.mapper.QuartzTaskRecordMapper; +import com.fengdu.gas.repository.po.QuartzTaskRecordPO; +import org.springframework.stereotype.Repository; + +/** + * 定时任务执行情况记录表 + * @author lin.liu + * @description 定时任务执行情况记录表 + */ +@Repository +public class QuartzTaskRecordMapperImpl extends BasicMapperImpl<QuartzTaskRecordPO, QuartzTaskRecordMapper> { + public QuartzTaskRecordMapperImpl(QuartzTaskRecordMapper mapper) { + super(mapper); + } + + /** + * 分页查询 + * + * @param request 请求参数 + */ + @Override + public PagerResult<QuartzTaskRecordPO> search(SearchBasicDTO request) { + // 查询条件类型还原 + SearchQuartzTaskRecord search = (SearchQuartzTaskRecord)request; + + LambdaQueryWrapper<QuartzTaskRecordPO> queryWrapper = this.query(); + // 状态非逻辑删除 + queryWrapper.eq(QuartzTaskRecordPO::getIsDelete, EYesOrNo.NO.getValue()); + // 状态 + queryWrapper.eq(NumericUtil.tryParseInt(search.getStatus()).compareTo(0) > 0, QuartzTaskRecordPO::getTaskStatus, search.getStatus()); + // 状态列表 + queryWrapper.in(ListUtil.isNotNullOrEmpty(search.getListStatus()), QuartzTaskRecordPO::getTaskStatus, search.getListStatus()); + // 数据创建时间-起始 + queryWrapper.ge(NumericUtil.tryParseLong(search.getCreateTimeStart()).compareTo(0L) > 0, QuartzTaskRecordPO::getCreateTime, search.getCreateTimeStart()); + // 数据创建时间-截止 + queryWrapper.le(NumericUtil.tryParseLong(search.getCreateTimeEnd()).compareTo(0L) > 0, QuartzTaskRecordPO::getCreateTime, search.getCreateTimeEnd()); + // 任务编号 + queryWrapper.eq(StringUtil.isNotNullOrEmpty(search.getTaskNo()), QuartzTaskRecordPO::getTaskNo, search.getTaskNo()); + // 执行时间-起始 + queryWrapper.ge(NumericUtil.tryParseLong(search.getExecuteTimeStart()).compareTo(0L) > 0, QuartzTaskRecordPO::getStartTime, search.getExecuteTimeStart()); + // 执行时间-截止 + queryWrapper.le(NumericUtil.tryParseLong(search.getExecuteTimeEnd()).compareTo(0L) > 0, QuartzTaskRecordPO::getStartTime, search.getExecuteTimeEnd()); + // 关键字 + //if (StringUtil.isNotNullOrEmpty(search.getKeywords())) { + // queryWrapper.and(q -> + // q.like(QuartzTaskRecordPO::getRealName, search.getKeywords()) + // .or().like(QuartzTaskRecordPO::getContactPhone, search.getKeywords()) + // ); + //} + // 排序处理 + if (ListUtil.isNotNullOrEmpty(search.getOrderBy())) { + for (OrderByDTO item : search.getOrderBy()) { + EOrderBy orderBy = EOrderBy.getByValue(item.getOrderBy()); + // 顺序排序 + if (item.getIsAsc()) { + switch (orderBy) { + // 主键 + case ID: + queryWrapper.orderByAsc(QuartzTaskRecordPO::getId); + break; + // 数据创建时间 + case CREATE_TIME: + queryWrapper.orderByAsc(QuartzTaskRecordPO::getCreateTime); + break; + // 最后更新时间 + case UPDATE_TIME: + queryWrapper.orderByAsc(QuartzTaskRecordPO::getUpdateTime); + break; + } + } else { + // 倒叙排序 + switch (orderBy) { + // 主键 + case ID: + queryWrapper.orderByAsc(QuartzTaskRecordPO::getId); + break; + // 数据创建时间 + case CREATE_TIME: + queryWrapper.orderByAsc(QuartzTaskRecordPO::getCreateTime); + break; + // 最后更新时间 + case UPDATE_TIME: + queryWrapper.orderByAsc(QuartzTaskRecordPO::getUpdateTime); + break; + } + } + } + } else { + queryWrapper.orderByDesc(QuartzTaskRecordPO::getId); + } + Page<QuartzTaskRecordPO> pageResult = DB.selectPage(new Page<>(search.getPage(), search.getLimit()), queryWrapper); + return new PagerResult<>(pageResult.getSize(), pageResult.getCurrent(), pageResult.getTotal(), pageResult.getRecords()); + } + + public int clear4DateTime(long time) { + LambdaQueryWrapper<QuartzTaskRecordPO> query = this.query(); + query.lt(QuartzTaskRecordPO::getCreateTime, time); + return DB.delete(query); + } +} diff --git a/src/main/java/com/fengdu/gas/repository/impl/SysDictDataMapperImpl.java b/src/main/java/com/fengdu/gas/repository/impl/SysDictDataMapperImpl.java new file mode 100644 index 0000000..3a2cd16 --- /dev/null +++ b/src/main/java/com/fengdu/gas/repository/impl/SysDictDataMapperImpl.java @@ -0,0 +1,187 @@ +/** +# __----~~~~~~~~~~~------___ +# . . ~~//====...... __--~ ~~ +# -. \_|// |||\\ ~~~~~~::::... /~ +# ___-==_ _-~o~ \/ ||| \\ _/~~- +# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ +# _-~~ .=~ | \\-_ '-~7 /- / || \ / +# .~ .~ | \\ -_ / /- / || \ / +# / ____ / | \\ ~-_/ /|- _/ .|| \ / +# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ +# ' ~-| /| |-~\~~ __--~~ +# |-~~-_/ | | ~\_ _-~ /\ +# / \ \__ \/~ \__ +# _--~ _/ | .-~~____--~-/ ~~==. +# ((->/~ '.|||' -_| ~~-/ , . _|| +# -_ ~\ ~~---l__i__i__i--~~_/ +# _-~-__ ~) \--______________--~~ +# //.-~~~-~_--~- |-------~~~~~~~~ +# //.-~~~--\ +# 神兽保佑 +# 永无BUG! +*/ +package com.fengdu.gas.repository.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.fengdu.gas.common.PagerResult; +import com.fengdu.gas.common.util.ListUtil; +import com.fengdu.gas.common.util.NumericUtil; +import com.fengdu.gas.common.util.StringUtil; +import com.fengdu.gas.entity.dto.OrderByDTO; +import com.fengdu.gas.entity.dto.SearchBasicDTO; +import com.fengdu.gas.entity.enums.EOrderBy; +import com.fengdu.gas.entity.search.SearchSysDictData; +import com.fengdu.gas.repository.BasicMapperImpl; +import com.fengdu.gas.repository.mapper.SysDictDataMapper; +import com.fengdu.gas.repository.po.SysDictDataPO; +import org.springframework.stereotype.Repository; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * 字典数据表 + * @author lin.liu + * @description 字典数据表 + */ +@Repository +public class SysDictDataMapperImpl extends BasicMapperImpl<SysDictDataPO, SysDictDataMapper> { + SysDictDataMapperImpl(SysDictDataMapper mapper) { + super(mapper); + } + + @Override + public PagerResult<SysDictDataPO> search(SearchBasicDTO request) { + // 还原查询条件真实类型 + SearchSysDictData search = (SearchSysDictData)request; + // 查询条件 + LambdaQueryWrapper<SysDictDataPO> queryWrapper = this.query(); + // 状态 + queryWrapper.eq(NumericUtil.tryParseInt(search.getStatus()).compareTo(0) > 0, SysDictDataPO::getStatus, search.getStatus()); + // 状态列表 + queryWrapper.in(ListUtil.isNotNullOrEmpty(search.getListStatus()), SysDictDataPO::getStatus, search.getListStatus()); + + // 数据创建时间-起始 + queryWrapper.ge(NumericUtil.tryParseLong(search.getCreateTimeStart()).compareTo(0L) > 0, SysDictDataPO::getCreateTime, search.getCreateTimeStart()); + // 数据创建时间-截止 + queryWrapper.le(NumericUtil.tryParseLong(search.getCreateTimeEnd()).compareTo(0L) > 0, SysDictDataPO::getCreateTime, search.getCreateTimeEnd()); + // 关键字 + if (StringUtil.isNotNullOrEmpty(search.getKeywords())) { + queryWrapper.like(SysDictDataPO::getDictLabel, search.getKeywords()); + } + + // 排序处理 + if (ListUtil.isNotNullOrEmpty(search.getOrderBy())) { + for (OrderByDTO item : search.getOrderBy()) { + EOrderBy orderBy = EOrderBy.getByValue(item.getOrderBy()); + // 顺序排序 + if (item.getIsAsc()) { + switch (orderBy) { + // 主键 + case ID: + queryWrapper.orderByAsc(SysDictDataPO::getId); + break; + // 数据创建时间 + case CREATE_TIME: + queryWrapper.orderByAsc(SysDictDataPO::getCreateTime); + break; + // 最后更新时间 + case UPDATE_TIME: + queryWrapper.orderByAsc(SysDictDataPO::getUpdateTime); + break; + } + } else { + // 倒叙排序 + switch (orderBy) { + // 主键 + case ID: + queryWrapper.orderByDesc(SysDictDataPO::getId); + break; + // 数据创建时间 + case CREATE_TIME: + queryWrapper.orderByDesc(SysDictDataPO::getCreateTime); + break; + // 最后更新时间 + case UPDATE_TIME: + queryWrapper.orderByDesc(SysDictDataPO::getUpdateTime); + break; + } + } + } + } else { + queryWrapper.orderByDesc(SysDictDataPO::getId); + } + Page<SysDictDataPO> pageResult = super.selectPage(new Page<>(search.getPage(), search.getLimit()), queryWrapper); + return new PagerResult<>(pageResult.getSize(), pageResult.getCurrent(), pageResult.getTotal(), pageResult.getRecords()); + } + + public Boolean add(SysDictDataPO item) { + int rowCount = super.insert(item); + return rowCount == 1; + } + /** + * 根据type获取数据列表 + * @param type 类型 + */ + public List<SysDictDataPO> getListByType(String type) { + LambdaQueryWrapper<SysDictDataPO> queryWrapper = this.query(); + queryWrapper.eq(SysDictDataPO::getDictType, type); + return DB.selectList(queryWrapper); + } + public Long count4Type(String type) { + LambdaQueryWrapper<SysDictDataPO> queryWrapper = this.query(); + queryWrapper.eq(SysDictDataPO::getDictType, type); + return DB.getCount(queryWrapper); + } + public List<String> findExists4Type(List<String> listType) { + LambdaQueryWrapper<SysDictDataPO> queryWrapper = this.query(); + queryWrapper.select(SysDictDataPO.class, c -> c.getColumn().equals("dict_type")); + queryWrapper.in(SysDictDataPO::getDictType, listType); + List<Map<String, Object>> result = DB.selectMaps(queryWrapper); + return result.stream().map(c -> c.get("dict_type").toString()).distinct().collect(Collectors.toList()); + } + + public Boolean addNotIncrement(SysDictDataPO item) { + int rowCount = super.insert(item); + return rowCount == 1; + } + + public SysDictDataPO getById(Long id) { + return super.get(id); + } + + public List<SysDictDataPO> getListById(List<Long> listId) { + return super.getList(listId); + } + + public List<SysDictDataPO> listByType(List<String> listType) { + LambdaQueryWrapper<SysDictDataPO> queryWrapper = this.query(); + queryWrapper.in(SysDictDataPO::getDictType, listType); + return DB.selectList(queryWrapper); + } + + public Map<String, Map<String, String>> map4Type(List<String> listType) { + Map<String, Map<String, String>> result = new HashMap<>(); + + List<SysDictDataPO> listDictData = this.listByType(listType); + Map<String, List<SysDictDataPO>> map4Type = listDictData.stream().collect(Collectors.groupingBy(SysDictDataPO::getDictType)); + for (Map.Entry<String, List<SysDictDataPO>> entry : map4Type.entrySet()) { + Map<String, String> mapData = entry.getValue().stream().collect( + Collectors.toMap(SysDictDataPO::getDictValue, SysDictDataPO::getDictLabel) + ); + result.put(entry.getKey(), mapData); + } + return result; + } + + public Map<String, SysDictDataPO> map4Type(String type) { + List<SysDictDataPO> listDictData = this.getListByType(type); + if (ListUtil.isNullOrEmpty(listDictData)) { + return new HashMap<>(); + } + return listDictData.stream().collect(Collectors.toMap(SysDictDataPO::getDictValue, c -> c)); + } +} diff --git a/src/main/java/com/fengdu/gas/repository/impl/SysDictTypeMapperImpl.java b/src/main/java/com/fengdu/gas/repository/impl/SysDictTypeMapperImpl.java new file mode 100644 index 0000000..1372ccb --- /dev/null +++ b/src/main/java/com/fengdu/gas/repository/impl/SysDictTypeMapperImpl.java @@ -0,0 +1,150 @@ +/** +# __----~~~~~~~~~~~------___ +# . . ~~//====...... __--~ ~~ +# -. \_|// |||\\ ~~~~~~::::... /~ +# ___-==_ _-~o~ \/ ||| \\ _/~~- +# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ +# _-~~ .=~ | \\-_ '-~7 /- / || \ / +# .~ .~ | \\ -_ / /- / || \ / +# / ____ / | \\ ~-_/ /|- _/ .|| \ / +# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ +# ' ~-| /| |-~\~~ __--~~ +# |-~~-_/ | | ~\_ _-~ /\ +# / \ \__ \/~ \__ +# _--~ _/ | .-~~____--~-/ ~~==. +# ((->/~ '.|||' -_| ~~-/ , . _|| +# -_ ~\ ~~---l__i__i__i--~~_/ +# _-~-__ ~) \--______________--~~ +# //.-~~~-~_--~- |-------~~~~~~~~ +# //.-~~~--\ +# 神兽保佑 +# 永无BUG! +*/ +package com.fengdu.gas.repository.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.fengdu.gas.common.PagerResult; +import com.fengdu.gas.common.util.ListUtil; +import com.fengdu.gas.common.util.NumericUtil; +import com.fengdu.gas.common.util.StringUtil; +import com.fengdu.gas.entity.dto.OrderByDTO; +import com.fengdu.gas.entity.dto.SearchBasicDTO; +import com.fengdu.gas.entity.enums.EOrderBy; +import com.fengdu.gas.entity.search.SearchSysDictType; +import com.fengdu.gas.repository.BasicMapperImpl; +import com.fengdu.gas.repository.mapper.SysDictTypeMapper; +import com.fengdu.gas.repository.po.SysDictTypePO; +import org.springframework.stereotype.Repository; + +import java.util.List; + +/** + * 字典类型表 + * @author lin.liu + * @description 字典类型表 + */ +@Repository +public class SysDictTypeMapperImpl extends BasicMapperImpl<SysDictTypePO, SysDictTypeMapper> { + SysDictTypeMapperImpl(SysDictTypeMapper mapper) { + super(mapper); + } + + @Override + public PagerResult<SysDictTypePO> search(SearchBasicDTO request) { + // 还原查询条件真实类型 + SearchSysDictType search = (SearchSysDictType)request; + // 查询条件 + LambdaQueryWrapper<SysDictTypePO> queryWrapper = this.query(); + // 状态 + queryWrapper.eq(NumericUtil.tryParseInt(search.getStatus()).compareTo(0) > 0, SysDictTypePO::getStatus, search.getStatus()); + // 状态列表 + queryWrapper.in(ListUtil.isNotNullOrEmpty(search.getListStatus()), SysDictTypePO::getStatus, search.getListStatus()); + + // 数据创建时间-起始 + queryWrapper.ge(NumericUtil.tryParseLong(search.getCreateTimeStart()).compareTo(0L) > 0, SysDictTypePO::getCreateTime, search.getCreateTimeStart()); + // 数据创建时间-截止 + queryWrapper.le(NumericUtil.tryParseLong(search.getCreateTimeEnd()).compareTo(0L) > 0, SysDictTypePO::getCreateTime, search.getCreateTimeEnd()); + // 关键字 + if (StringUtil.isNotNullOrEmpty(search.getKeywords())) { + queryWrapper.and(q -> + q.like(SysDictTypePO::getDictType, search.getKeywords()) + .or().like(SysDictTypePO::getDictName, search.getKeywords()) + ); + } + + // 排序处理 + if (ListUtil.isNotNullOrEmpty(search.getOrderBy())) { + for (OrderByDTO item : search.getOrderBy()) { + EOrderBy orderBy = EOrderBy.getByValue(item.getOrderBy()); + // 顺序排序 + if (item.getIsAsc()) { + switch (orderBy) { + // 主键 + case ID: + queryWrapper.orderByAsc(SysDictTypePO::getId); + break; + // 数据创建时间 + case CREATE_TIME: + queryWrapper.orderByAsc(SysDictTypePO::getCreateTime); + break; + // 最后更新时间 + case UPDATE_TIME: + queryWrapper.orderByAsc(SysDictTypePO::getUpdateTime); + break; + } + } else { + // 倒叙排序 + switch (orderBy) { + // 主键 + case ID: + queryWrapper.orderByDesc(SysDictTypePO::getId); + break; + // 数据创建时间 + case CREATE_TIME: + queryWrapper.orderByDesc(SysDictTypePO::getCreateTime); + break; + // 最后更新时间 + case UPDATE_TIME: + queryWrapper.orderByDesc(SysDictTypePO::getUpdateTime); + break; + } + } + } + } else { + queryWrapper.orderByDesc(SysDictTypePO::getId); + } + Page<SysDictTypePO> pageResult = super.selectPage(new Page<>(search.getPage(), search.getLimit()), queryWrapper); + return new PagerResult<>(pageResult.getSize(), pageResult.getCurrent(), pageResult.getTotal(), pageResult.getRecords()); + } + + public Boolean add(SysDictTypePO item) { + int rowCount = super.insert(item); + return rowCount == 1; + } + + public Boolean addNotIncrement(SysDictTypePO item) { + int rowCount = super.insert(item); + return rowCount == 1; + } + + public SysDictTypePO getById(Long id) { + return super.get(id); + } + + public List<SysDictTypePO> getListById(List<Long> listId) { + return super.getList(listId); + } + + public SysDictTypePO get4Type(String type) { + LambdaQueryWrapper<SysDictTypePO> queryWrapper = this.query(); + queryWrapper.eq(SysDictTypePO::getDictType, type); + return DB.selectOne(queryWrapper); + } + + public List<SysDictTypePO> get4Type(List<String> listType) { + LambdaQueryWrapper<SysDictTypePO> queryWrapper = this.query(); + queryWrapper.in(SysDictTypePO::getDictType, listType); + return DB.selectList(queryWrapper); + } +} diff --git a/src/main/java/com/fengdu/gas/repository/impl/TestInfoMapperImpl.java b/src/main/java/com/fengdu/gas/repository/impl/TestInfoMapperImpl.java new file mode 100644 index 0000000..487bdbf --- /dev/null +++ b/src/main/java/com/fengdu/gas/repository/impl/TestInfoMapperImpl.java @@ -0,0 +1,133 @@ +/** +# __----~~~~~~~~~~~------___ +# . . ~~//====...... __--~ ~~ +# -. \_|// |||\\ ~~~~~~::::... /~ +# ___-==_ _-~o~ \/ ||| \\ _/~~- +# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ +# _-~~ .=~ | \\-_ '-~7 /- / || \ / +# .~ .~ | \\ -_ / /- / || \ / +# / ____ / | \\ ~-_/ /|- _/ .|| \ / +# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ +# ' ~-| /| |-~\~~ __--~~ +# |-~~-_/ | | ~\_ _-~ /\ +# / \ \__ \/~ \__ +# _--~ _/ | .-~~____--~-/ ~~==. +# ((->/~ '.|||' -_| ~~-/ , . _|| +# -_ ~\ ~~---l__i__i__i--~~_/ +# _-~-__ ~) \--______________--~~ +# //.-~~~-~_--~- |-------~~~~~~~~ +# //.-~~~--\ +# 神兽保佑 +# 永无BUG! +*/ +package com.fengdu.gas.repository.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.fengdu.gas.common.PagerResult; +import com.fengdu.gas.common.enums.EYesOrNo; +import com.fengdu.gas.common.util.ListUtil; +import com.fengdu.gas.common.util.NumericUtil; +import com.fengdu.gas.common.util.StringUtil; +import com.fengdu.gas.entity.dto.OrderByDTO; +import com.fengdu.gas.entity.dto.SearchBasicDTO; +import com.fengdu.gas.entity.enums.EOrderBy; +import com.fengdu.gas.entity.search.SearchTestInfo; +import com.fengdu.gas.repository.BasicMapperImpl; +import com.fengdu.gas.repository.mapper.TestInfoMapper; +import com.fengdu.gas.repository.po.TestInfoPO; +import org.springframework.stereotype.Repository; + +import java.util.List; + +/** + * 测试信息 数据访问类 + * @author lin.liu + * @description 测试信息 数据访问类 + * @date 2021/11/23 + */ +@Repository +public class TestInfoMapperImpl extends BasicMapperImpl<TestInfoPO, TestInfoMapper> { + public TestInfoMapperImpl(TestInfoMapper mapper) { + super(mapper); + } + + @Override + public PagerResult<TestInfoPO> search(SearchBasicDTO request) { + // 还原查询条件真实类型 + SearchTestInfo search = (SearchTestInfo)request; + + //==================== 自定义sql查询方法 调用示例 - begin ==================== + TestInfoPO model1 = DB.testGet(553261510198173696L); + TestInfoPO model2 = DB.testGet2("verona.stroman"); + + List<TestInfoPO> list1 = DB.testList1(search); + List<TestInfoPO> list2 = DB.testList2(search); + //==================== 自定义sql查询方法 调用示例 - end ==================== + + // 查询条件 + LambdaQueryWrapper<TestInfoPO> queryWrapper = this.query(); + // 非逻辑删除 + queryWrapper.eq(TestInfoPO::getIsDelete, EYesOrNo.NO.getValue()); + // 状态 + queryWrapper.eq(NumericUtil.tryParseInt(search.getStatus()).compareTo(0) > 0, TestInfoPO::getStatus, search.getStatus()); + // 状态列表 + queryWrapper.in(ListUtil.isNotNullOrEmpty(search.getListStatus()), TestInfoPO::getStatus, search.getListStatus()); + + // 数据创建时间-起始 + queryWrapper.ge(NumericUtil.tryParseLong(search.getCreateTimeStart()).compareTo(0L) > 0, TestInfoPO::getCreateTime, search.getCreateTimeStart()); + // 数据创建时间-截止 + queryWrapper.le(NumericUtil.tryParseLong(search.getCreateTimeEnd()).compareTo(0L) > 0, TestInfoPO::getCreateTime, search.getCreateTimeEnd()); + // 关键字 + if (StringUtil.isNotNullOrEmpty(search.getKeywords())) { + queryWrapper.and(q -> + q.like(TestInfoPO::getName, search.getKeywords()) + .or().like(TestInfoPO::getPhone, search.getKeywords()) + ); + } + + // 排序处理 + if (ListUtil.isNotNullOrEmpty(search.getOrderBy())) { + for (OrderByDTO item : search.getOrderBy()) { + EOrderBy orderBy = EOrderBy.getByValue(item.getOrderBy()); + // 顺序排序 + if (item.getIsAsc()) { + switch (orderBy) { + // 主键 + case ID: + queryWrapper.orderByAsc(TestInfoPO::getId); + break; + // 数据创建时间 + case CREATE_TIME: + queryWrapper.orderByAsc(TestInfoPO::getCreateTime); + break; + // 最后更新时间 + case UPDATE_TIME: + queryWrapper.orderByAsc(TestInfoPO::getUpdateTime); + break; + } + } else { + // 倒叙排序 + switch (orderBy) { + // 主键 + case ID: + queryWrapper.orderByDesc(TestInfoPO::getId); + break; + // 数据创建时间 + case CREATE_TIME: + queryWrapper.orderByDesc(TestInfoPO::getCreateTime); + break; + // 最后更新时间 + case UPDATE_TIME: + queryWrapper.orderByDesc(TestInfoPO::getUpdateTime); + break; + } + } + } + } else { + queryWrapper.orderByDesc(TestInfoPO::getId); + } + Page<TestInfoPO> pageResult = DB.selectPage(new Page<>(search.getPage(), search.getLimit()), queryWrapper); + return new PagerResult<>(pageResult.getSize(), pageResult.getPages(), pageResult.getTotal(), pageResult.getRecords()); + } +} diff --git a/src/main/java/com/fengdu/gas/repository/mapper/AdminMenuMapper.java b/src/main/java/com/fengdu/gas/repository/mapper/AdminMenuMapper.java new file mode 100644 index 0000000..3aeb960 --- /dev/null +++ b/src/main/java/com/fengdu/gas/repository/mapper/AdminMenuMapper.java @@ -0,0 +1,11 @@ +package com.fengdu.gas.repository.mapper; + +import com.fengdu.gas.repository.BasicMapper; +import com.fengdu.gas.repository.po.AdminMenuPO; + +/** + * 菜单 mapper + * @author lin.liu + */ +public interface AdminMenuMapper extends BasicMapper<AdminMenuPO> { +} diff --git a/src/main/java/com/fengdu/gas/repository/mapper/AdminMenusMapper.java b/src/main/java/com/fengdu/gas/repository/mapper/AdminMenusMapper.java new file mode 100644 index 0000000..417b9ed --- /dev/null +++ b/src/main/java/com/fengdu/gas/repository/mapper/AdminMenusMapper.java @@ -0,0 +1,11 @@ +package com.fengdu.gas.repository.mapper; + +import com.fengdu.gas.repository.BasicMapper; +import com.fengdu.gas.repository.po.AdminMenusPO; + +/** + * 菜单信息 mapper + * @author lin.liu + */ +public interface AdminMenusMapper extends BasicMapper<AdminMenusPO> { +} diff --git a/src/main/java/com/fengdu/gas/repository/mapper/AdminPermissionMapper.java b/src/main/java/com/fengdu/gas/repository/mapper/AdminPermissionMapper.java new file mode 100644 index 0000000..cadf145 --- /dev/null +++ b/src/main/java/com/fengdu/gas/repository/mapper/AdminPermissionMapper.java @@ -0,0 +1,11 @@ +package com.fengdu.gas.repository.mapper; + +import com.fengdu.gas.repository.BasicMapper; +import com.fengdu.gas.repository.po.AdminPermissionPO; + +/** + * 权限 mapper + * @author lin.liu + */ +public interface AdminPermissionMapper extends BasicMapper<AdminPermissionPO> { +} diff --git a/src/main/java/com/fengdu/gas/repository/mapper/AdminRoleMapper.java b/src/main/java/com/fengdu/gas/repository/mapper/AdminRoleMapper.java new file mode 100644 index 0000000..8af2d46 --- /dev/null +++ b/src/main/java/com/fengdu/gas/repository/mapper/AdminRoleMapper.java @@ -0,0 +1,11 @@ +package com.fengdu.gas.repository.mapper; + +import com.fengdu.gas.repository.BasicMapper; +import com.fengdu.gas.repository.po.AdminRolePO; + +/** + * 角色 mapper + * @author lin.liu + */ +public interface AdminRoleMapper extends BasicMapper<AdminRolePO> { +} diff --git a/src/main/java/com/fengdu/gas/repository/mapper/AdminRoleMenuRelationMapper.java b/src/main/java/com/fengdu/gas/repository/mapper/AdminRoleMenuRelationMapper.java new file mode 100644 index 0000000..f716259 --- /dev/null +++ b/src/main/java/com/fengdu/gas/repository/mapper/AdminRoleMenuRelationMapper.java @@ -0,0 +1,11 @@ +package com.fengdu.gas.repository.mapper; + +import com.fengdu.gas.repository.BasicMapper; +import com.fengdu.gas.repository.po.AdminRoleMenuRelationPO; + +/** + * 角色菜单关联关系 mapper + * @author lin.liu + */ +public interface AdminRoleMenuRelationMapper extends BasicMapper<AdminRoleMenuRelationPO> { +} diff --git a/src/main/java/com/fengdu/gas/repository/mapper/AdminRolePermissionRelationMapper.java b/src/main/java/com/fengdu/gas/repository/mapper/AdminRolePermissionRelationMapper.java new file mode 100644 index 0000000..bc8feb2 --- /dev/null +++ b/src/main/java/com/fengdu/gas/repository/mapper/AdminRolePermissionRelationMapper.java @@ -0,0 +1,11 @@ +package com.fengdu.gas.repository.mapper; + +import com.fengdu.gas.repository.BasicMapper; +import com.fengdu.gas.repository.po.AdminRolePermissionRelationPO; + +/** + * 角色权限关联关系 mapper + * @author lin.liu + */ +public interface AdminRolePermissionRelationMapper extends BasicMapper<AdminRolePermissionRelationPO> { +} diff --git a/src/main/java/com/fengdu/gas/repository/mapper/AdminRoleRelationMapper.java b/src/main/java/com/fengdu/gas/repository/mapper/AdminRoleRelationMapper.java new file mode 100644 index 0000000..cde25fe --- /dev/null +++ b/src/main/java/com/fengdu/gas/repository/mapper/AdminRoleRelationMapper.java @@ -0,0 +1,11 @@ +package com.fengdu.gas.repository.mapper; + +import com.fengdu.gas.repository.BasicMapper; +import com.fengdu.gas.repository.po.AdminRoleRelationPO; + +/** + * 用户和角色关联关系 mapper + * @author lin.liu + */ +public interface AdminRoleRelationMapper extends BasicMapper<AdminRoleRelationPO> { +} diff --git a/src/main/java/com/fengdu/gas/repository/mapper/AdminUserMapper.java b/src/main/java/com/fengdu/gas/repository/mapper/AdminUserMapper.java new file mode 100644 index 0000000..abf6d89 --- /dev/null +++ b/src/main/java/com/fengdu/gas/repository/mapper/AdminUserMapper.java @@ -0,0 +1,11 @@ +package com.fengdu.gas.repository.mapper; + +import com.fengdu.gas.repository.BasicMapper; +import com.fengdu.gas.repository.po.AdminUserPO; + +/** + * 管理员帐号 mapper + * @author lin.liu + */ +public interface AdminUserMapper extends BasicMapper<AdminUserPO> { +} diff --git a/src/main/java/com/fengdu/gas/repository/mapper/NoticeMapper.java b/src/main/java/com/fengdu/gas/repository/mapper/NoticeMapper.java new file mode 100644 index 0000000..476816e --- /dev/null +++ b/src/main/java/com/fengdu/gas/repository/mapper/NoticeMapper.java @@ -0,0 +1,11 @@ +package com.fengdu.gas.repository.mapper; + +import com.fengdu.gas.repository.BasicMapper; +import com.fengdu.gas.repository.po.NoticePO; + +/** + * 公告 mapper + * @author lin.liu + */ +public interface NoticeMapper extends BasicMapper<NoticePO> { +} diff --git a/src/main/java/com/fengdu/gas/repository/mapper/QuartzTaskErrorMapper.java b/src/main/java/com/fengdu/gas/repository/mapper/QuartzTaskErrorMapper.java new file mode 100644 index 0000000..d50ef35 --- /dev/null +++ b/src/main/java/com/fengdu/gas/repository/mapper/QuartzTaskErrorMapper.java @@ -0,0 +1,12 @@ +package com.fengdu.gas.repository.mapper; + +import com.fengdu.gas.repository.BasicMapper; +import com.fengdu.gas.repository.po.QuartzTaskErrorPO; + +/** + * 定时任务错误信息 mapper + * @author lin.liu + * @description 定时任务错误信息 mapper + */ +public interface QuartzTaskErrorMapper extends BasicMapper<QuartzTaskErrorPO> { +} diff --git a/src/main/java/com/fengdu/gas/repository/mapper/QuartzTaskInfoMapper.java b/src/main/java/com/fengdu/gas/repository/mapper/QuartzTaskInfoMapper.java new file mode 100644 index 0000000..42f78b3 --- /dev/null +++ b/src/main/java/com/fengdu/gas/repository/mapper/QuartzTaskInfoMapper.java @@ -0,0 +1,12 @@ +package com.fengdu.gas.repository.mapper; + +import com.fengdu.gas.repository.BasicMapper; +import com.fengdu.gas.repository.po.QuartzTaskInfoPO; + +/** + * 定时任务信息 mapper + * @author lin.liu + * @description 定时任务信息 mapper + */ +public interface QuartzTaskInfoMapper extends BasicMapper<QuartzTaskInfoPO> { +} diff --git a/src/main/java/com/fengdu/gas/repository/mapper/QuartzTaskRecordMapper.java b/src/main/java/com/fengdu/gas/repository/mapper/QuartzTaskRecordMapper.java new file mode 100644 index 0000000..ef06d22 --- /dev/null +++ b/src/main/java/com/fengdu/gas/repository/mapper/QuartzTaskRecordMapper.java @@ -0,0 +1,12 @@ +package com.fengdu.gas.repository.mapper; + +import com.fengdu.gas.repository.BasicMapper; +import com.fengdu.gas.repository.po.QuartzTaskRecordPO; + +/** + * 定时任务执行记录 mapper + * @author lin.liu + * @description 定时任务执行记录 mapper + */ +public interface QuartzTaskRecordMapper extends BasicMapper<QuartzTaskRecordPO> { +} diff --git a/src/main/java/com/fengdu/gas/repository/mapper/SysDictDataMapper.java b/src/main/java/com/fengdu/gas/repository/mapper/SysDictDataMapper.java new file mode 100644 index 0000000..d432393 --- /dev/null +++ b/src/main/java/com/fengdu/gas/repository/mapper/SysDictDataMapper.java @@ -0,0 +1,11 @@ +package com.fengdu.gas.repository.mapper; + +import com.fengdu.gas.repository.BasicMapper; +import com.fengdu.gas.repository.po.SysDictDataPO; + +/** + * 字典数据 mapper + * @author lin.liu + */ +public interface SysDictDataMapper extends BasicMapper<SysDictDataPO> { +} diff --git a/src/main/java/com/fengdu/gas/repository/mapper/SysDictTypeMapper.java b/src/main/java/com/fengdu/gas/repository/mapper/SysDictTypeMapper.java new file mode 100644 index 0000000..ff57c90 --- /dev/null +++ b/src/main/java/com/fengdu/gas/repository/mapper/SysDictTypeMapper.java @@ -0,0 +1,11 @@ +package com.fengdu.gas.repository.mapper; + +import com.fengdu.gas.repository.BasicMapper; +import com.fengdu.gas.repository.po.SysDictTypePO; + +/** + * 字典类型 mapper + * @author lin.liu + */ +public interface SysDictTypeMapper extends BasicMapper<SysDictTypePO> { +} diff --git a/src/main/java/com/fengdu/gas/repository/mapper/TestInfoMapper.java b/src/main/java/com/fengdu/gas/repository/mapper/TestInfoMapper.java new file mode 100644 index 0000000..6876456 --- /dev/null +++ b/src/main/java/com/fengdu/gas/repository/mapper/TestInfoMapper.java @@ -0,0 +1,36 @@ +package com.fengdu.gas.repository.mapper; + +import com.baomidou.mybatisplus.core.toolkit.Constants; +import com.fengdu.gas.entity.search.SearchTestInfo; +import com.fengdu.gas.repository.BasicMapper; +import com.fengdu.gas.repository.po.TestInfoPO; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; + +import java.util.List; + +@Mapper +public interface TestInfoMapper extends BasicMapper<TestInfoPO> { + //==================== 自定义sql查询方法 声明示例 - begin ==================== + // #{param}:会进行预编译,而且进行类型匹配,最后进行变量替换,括号中可以添加映射类型如 +// @Select( +// "<script>" + +// "select * from student where id= #{param,javaType=int,jdbcType=NUMERIC}" + +// "</script> " +// ) + // ${param}:$只是只是简单的字符串拼接,要特别小心sql注入问题,对应非变量部分,只能用$。$方式一般用于传入数据库对象,比如这种group by 字段 ,order by 字段,表名,字段名等没法使用占位符的就需要使用${param} + + @Select("select * from test_info where id = #{id}") + TestInfoPO testGet(Long id); + + @Select("select * from test_info where name = #{name}") + TestInfoPO testGet2(String userName); + + @Select("select * from test_info where status = #{ew.status}") + List<TestInfoPO> testList1(@Param(Constants.WRAPPER) SearchTestInfo search); + + @Select("select * from test_info where status = #{search.status}") + List<TestInfoPO> testList2(@Param("search") SearchTestInfo search); + //==================== 自定义sql查询方法 声明示例 - end ==================== +} diff --git a/src/main/java/com/fengdu/gas/repository/po/AdminMenuPO.java b/src/main/java/com/fengdu/gas/repository/po/AdminMenuPO.java new file mode 100644 index 0000000..ffecdd8 --- /dev/null +++ b/src/main/java/com/fengdu/gas/repository/po/AdminMenuPO.java @@ -0,0 +1,104 @@ +/** +# __----~~~~~~~~~~~------___ +# . . ~~//====...... __--~ ~~ +# -. \_|// |||\\ ~~~~~~::::... /~ +# ___-==_ _-~o~ \/ ||| \\ _/~~- +# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ +# _-~~ .=~ | \\-_ '-~7 /- / || \ / +# .~ .~ | \\ -_ / /- / || \ / +# / ____ / | \\ ~-_/ /|- _/ .|| \ / +# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ +# ' ~-| /| |-~\~~ __--~~ +# |-~~-_/ | | ~\_ _-~ /\ +# / \ \__ \/~ \__ +# _--~ _/ | .-~~____--~-/ ~~==. +# ((->/~ '.|||' -_| ~~-/ , . _|| +# -_ ~\ ~~---l__i__i__i--~~_/ +# _-~-__ ~) \--______________--~~ +# //.-~~~-~_--~- |-------~~~~~~~~ +# //.-~~~--\ +# 神兽保佑 +# 永无BUG! +*/ +package com.fengdu.gas.repository.po; + +import lombok.Data; + +import com.baomidou.mybatisplus.annotation.*; + +import java.io.Serializable; +import java.sql.Timestamp; + +/** + * 菜单 + * @author lin.liu + */ +@Data +@TableName("admin_menu") +public class AdminMenuPO implements Serializable { + /** + * 主键 + */ + private Long id; + /** + * 父级ID + */ + @TableField(value = "parent_id") + private Long parentId; + /** + * 类型 EMenuType + */ + @TableField(value = "type") + private Integer type; + /** + * 菜单名称 + */ + @TableField(value = "name") + private String name; + /** + * 菜单标题 + */ + @TableField(value = "title") + private String title; + /** + * 前端资源路径 + */ + @TableField(value = "url") + private String url; + /** + * 菜单层级 + */ + @TableField(value = "level") + private Integer level; + /** + * 排序值 + */ + @TableField(value = "sort") + private Integer sort; + /** + * 图标 + */ + @TableField(value = "icon") + private String icon; + /** + * 状态 EState + */ + @TableField(value = "status") + private Integer status; + /** + * 数据创建时间 + */ + @TableField(value = "create_time") + private Long createTime; + /** + * 最后更新时间 + */ + @TableField(value = "update_time") + private Timestamp updateTime; + /** + * 是否删除(逻辑删除) + */ + @TableLogic + @TableField(value = "is_delete") + private Integer isDelete; +} diff --git a/src/main/java/com/fengdu/gas/repository/po/AdminMenusPO.java b/src/main/java/com/fengdu/gas/repository/po/AdminMenusPO.java new file mode 100644 index 0000000..5135ba6 --- /dev/null +++ b/src/main/java/com/fengdu/gas/repository/po/AdminMenusPO.java @@ -0,0 +1,99 @@ +/** +# __----~~~~~~~~~~~------___ +# . . ~~//====...... __--~ ~~ +# -. \_|// |||\\ ~~~~~~::::... /~ +# ___-==_ _-~o~ \/ ||| \\ _/~~- +# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ +# _-~~ .=~ | \\-_ '-~7 /- / || \ / +# .~ .~ | \\ -_ / /- / || \ / +# / ____ / | \\ ~-_/ /|- _/ .|| \ / +# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ +# ' ~-| /| |-~\~~ __--~~ +# |-~~-_/ | | ~\_ _-~ /\ +# / \ \__ \/~ \__ +# _--~ _/ | .-~~____--~-/ ~~==. +# ((->/~ '.|||' -_| ~~-/ , . _|| +# -_ ~\ ~~---l__i__i__i--~~_/ +# _-~-__ ~) \--______________--~~ +# //.-~~~-~_--~- |-------~~~~~~~~ +# //.-~~~--\ +# 神兽保佑 +# 永无BUG! +*/ +package com.fengdu.gas.repository.po; + +import lombok.Data; + +import com.baomidou.mybatisplus.annotation.*; + +import java.io.Serializable; +import java.sql.Timestamp; + +/** + * 菜单信息 + * @author lin.liu + */ +@Data +@TableName("admin_menus") +public class AdminMenusPO implements Serializable { + /** + * 主键id + */ + private Long id; + /** + * 父级id + */ + @TableField(value = "parent_id") + private Long parentId; + /** + * 菜单名称 + */ + @TableField(value = "name") + private String name; + /** + * 菜单标题 + */ + @TableField(value = "title") + private String title; + /** + * 前端资源路径 + */ + @TableField(value = "uri") + private String uri; + /** + * 菜单层级 + */ + @TableField(value = "level") + private Integer level; + /** + * 排序值 + */ + @TableField(value = "sort") + private Integer sort; + /** + * 图标 + */ + @TableField(value = "icon") + private String icon; + /** + * 状态 EState + */ + @TableField(value = "status") + private Integer status; + /** + * 数据创建时间 + */ + @TableField(value = "create_time") + private Long createTime; + /** + * 最后更新时间 + */ + @TableField(value = "update_time") + private Timestamp updateTime; + /** + * 是否删除(逻辑删除) + */ + @TableLogic + @TableField(value = "is_delete") + private Integer isDelete; +} diff --git a/src/main/java/com/fengdu/gas/repository/po/AdminPermissionPO.java b/src/main/java/com/fengdu/gas/repository/po/AdminPermissionPO.java new file mode 100644 index 0000000..b609174 --- /dev/null +++ b/src/main/java/com/fengdu/gas/repository/po/AdminPermissionPO.java @@ -0,0 +1,94 @@ +/** +# __----~~~~~~~~~~~------___ +# . . ~~//====...... __--~ ~~ +# -. \_|// |||\\ ~~~~~~::::... /~ +# ___-==_ _-~o~ \/ ||| \\ _/~~- +# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ +# _-~~ .=~ | \\-_ '-~7 /- / || \ / +# .~ .~ | \\ -_ / /- / || \ / +# / ____ / | \\ ~-_/ /|- _/ .|| \ / +# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ +# ' ~-| /| |-~\~~ __--~~ +# |-~~-_/ | | ~\_ _-~ /\ +# / \ \__ \/~ \__ +# _--~ _/ | .-~~____--~-/ ~~==. +# ((->/~ '.|||' -_| ~~-/ , . _|| +# -_ ~\ ~~---l__i__i__i--~~_/ +# _-~-__ ~) \--______________--~~ +# //.-~~~-~_--~- |-------~~~~~~~~ +# //.-~~~--\ +# 神兽保佑 +# 永无BUG! +*/ +package com.fengdu.gas.repository.po; + +import lombok.Data; + +import com.baomidou.mybatisplus.annotation.*; + +import java.io.Serializable; +import java.sql.Timestamp; + +/** + * 权限 + * @author lin.liu + */ +@Data +@TableName("admin_permission") +public class AdminPermissionPO implements Serializable { + /** + * 主键 + */ + private Long id; + /** + * 权限值 + */ + @TableField(value = "sn") + private String sn; + /** + * 菜单id + */ + @TableField(value = "menu_id") + private Long menuId; + /** + * 前端资源url + */ + @TableField(value = "menu_url") + private String menuUrl; + /** + * 名称 + */ + @TableField(value = "name") + private String name; + /** + * 图标 + */ + @TableField(value = "icon") + private String icon; + /** + * 权限类型 EOperation + */ + @TableField(value = "type") + private String type; + /** + * 状态 EStatus + */ + @TableField(value = "status") + private Integer status; + /** + * 数据创建时间 + */ + @TableField(value = "create_time") + private Long createTime; + /** + * 最后更新时间 + */ + @TableField(value = "update_time") + private Timestamp updateTime; + /** + * 是否删除(逻辑删除) + */ + @TableLogic + @TableField(value = "is_delete") + private Integer isDelete; +} diff --git a/src/main/java/com/fengdu/gas/repository/po/AdminRoleMenuRelationPO.java b/src/main/java/com/fengdu/gas/repository/po/AdminRoleMenuRelationPO.java new file mode 100644 index 0000000..5b2255f --- /dev/null +++ b/src/main/java/com/fengdu/gas/repository/po/AdminRoleMenuRelationPO.java @@ -0,0 +1,69 @@ +/** +# __----~~~~~~~~~~~------___ +# . . ~~//====...... __--~ ~~ +# -. \_|// |||\\ ~~~~~~::::... /~ +# ___-==_ _-~o~ \/ ||| \\ _/~~- +# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ +# _-~~ .=~ | \\-_ '-~7 /- / || \ / +# .~ .~ | \\ -_ / /- / || \ / +# / ____ / | \\ ~-_/ /|- _/ .|| \ / +# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ +# ' ~-| /| |-~\~~ __--~~ +# |-~~-_/ | | ~\_ _-~ /\ +# / \ \__ \/~ \__ +# _--~ _/ | .-~~____--~-/ ~~==. +# ((->/~ '.|||' -_| ~~-/ , . _|| +# -_ ~\ ~~---l__i__i__i--~~_/ +# _-~-__ ~) \--______________--~~ +# //.-~~~-~_--~- |-------~~~~~~~~ +# //.-~~~--\ +# 神兽保佑 +# 永无BUG! +*/ +package com.fengdu.gas.repository.po; + +import lombok.Data; + +import com.baomidou.mybatisplus.annotation.*; + +import java.io.Serializable; +import java.sql.Timestamp; + +/** + * 角色菜单关联关系 + * @author lin.liu + */ +@Data +@TableName("admin_role_menu_relation") +public class AdminRoleMenuRelationPO implements Serializable { + /** + * 主键 + */ + private Long id; + /** + * 角色id + */ + @TableField(value = "role_id") + private Long roleId; + /** + * 菜单id + */ + @TableField(value = "menu_id") + private Long menuId; + /** + * 数据创建时间 + */ + @TableField(value = "create_time") + private Long createTime; + /** + * 最后更新时间 + */ + @TableField(value = "update_time") + private Timestamp updateTime; + /** + * 是否删除(逻辑删除) + */ + @TableLogic + @TableField(value = "is_delete") + private Integer isDelete; +} diff --git a/src/main/java/com/fengdu/gas/repository/po/AdminRolePO.java b/src/main/java/com/fengdu/gas/repository/po/AdminRolePO.java new file mode 100644 index 0000000..32eccd8 --- /dev/null +++ b/src/main/java/com/fengdu/gas/repository/po/AdminRolePO.java @@ -0,0 +1,79 @@ +/** +# __----~~~~~~~~~~~------___ +# . . ~~//====...... __--~ ~~ +# -. \_|// |||\\ ~~~~~~::::... /~ +# ___-==_ _-~o~ \/ ||| \\ _/~~- +# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ +# _-~~ .=~ | \\-_ '-~7 /- / || \ / +# .~ .~ | \\ -_ / /- / || \ / +# / ____ / | \\ ~-_/ /|- _/ .|| \ / +# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ +# ' ~-| /| |-~\~~ __--~~ +# |-~~-_/ | | ~\_ _-~ /\ +# / \ \__ \/~ \__ +# _--~ _/ | .-~~____--~-/ ~~==. +# ((->/~ '.|||' -_| ~~-/ , . _|| +# -_ ~\ ~~---l__i__i__i--~~_/ +# _-~-__ ~) \--______________--~~ +# //.-~~~-~_--~- |-------~~~~~~~~ +# //.-~~~--\ +# 神兽保佑 +# 永无BUG! +*/ +package com.fengdu.gas.repository.po; + +import lombok.Data; + +import com.baomidou.mybatisplus.annotation.*; + +import java.io.Serializable; +import java.sql.Timestamp; + +/** + * 角色 + * @author lin.liu + */ +@Data +@TableName("admin_role") +public class AdminRolePO implements Serializable { + /** + * 主键 + */ + private Long id; + /** + * 角色名称 + */ + @TableField(value = "name") + private String name; + /** + * 描述 + */ + @TableField(value = "description") + private String description; + /** + * 状态 EState + */ + @TableField(value = "status") + private Integer status; + /** + * 排序值 + */ + @TableField(value = "sort") + private Integer sort; + /** + * 数据创建时间 + */ + @TableField(value = "create_time") + private Long createTime; + /** + * 最后更新时间 + */ + @TableField(value = "update_time") + private Timestamp updateTime; + /** + * 是否删除(逻辑删除) + */ + @TableLogic + @TableField(value = "is_delete") + private Integer isDelete; +} diff --git a/src/main/java/com/fengdu/gas/repository/po/AdminRolePermissionRelationPO.java b/src/main/java/com/fengdu/gas/repository/po/AdminRolePermissionRelationPO.java new file mode 100644 index 0000000..471839f --- /dev/null +++ b/src/main/java/com/fengdu/gas/repository/po/AdminRolePermissionRelationPO.java @@ -0,0 +1,69 @@ +/** +# __----~~~~~~~~~~~------___ +# . . ~~//====...... __--~ ~~ +# -. \_|// |||\\ ~~~~~~::::... /~ +# ___-==_ _-~o~ \/ ||| \\ _/~~- +# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ +# _-~~ .=~ | \\-_ '-~7 /- / || \ / +# .~ .~ | \\ -_ / /- / || \ / +# / ____ / | \\ ~-_/ /|- _/ .|| \ / +# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ +# ' ~-| /| |-~\~~ __--~~ +# |-~~-_/ | | ~\_ _-~ /\ +# / \ \__ \/~ \__ +# _--~ _/ | .-~~____--~-/ ~~==. +# ((->/~ '.|||' -_| ~~-/ , . _|| +# -_ ~\ ~~---l__i__i__i--~~_/ +# _-~-__ ~) \--______________--~~ +# //.-~~~-~_--~- |-------~~~~~~~~ +# //.-~~~--\ +# 神兽保佑 +# 永无BUG! +*/ +package com.fengdu.gas.repository.po; + +import lombok.Data; + +import com.baomidou.mybatisplus.annotation.*; + +import java.io.Serializable; +import java.sql.Timestamp; + +/** + * 角色权限关联关系 + * @author lin.liu + */ +@Data +@TableName("admin_role_permission_relation") +public class AdminRolePermissionRelationPO implements Serializable { + /** + * 主键 + */ + private Long id; + /** + * 角色id + */ + @TableField(value = "role_id") + private Long roleId; + /** + * 权限id + */ + @TableField(value = "permission_id") + private Long permissionId; + /** + * 数据创建时间 + */ + @TableField(value = "create_time") + private Long createTime; + /** + * 最后更新时间 + */ + @TableField(value = "update_time") + private Timestamp updateTime; + /** + * 是否删除(逻辑删除) + */ + @TableLogic + @TableField(value = "is_delete") + private Integer isDelete; +} diff --git a/src/main/java/com/fengdu/gas/repository/po/AdminRoleRelationPO.java b/src/main/java/com/fengdu/gas/repository/po/AdminRoleRelationPO.java new file mode 100644 index 0000000..ced15c9 --- /dev/null +++ b/src/main/java/com/fengdu/gas/repository/po/AdminRoleRelationPO.java @@ -0,0 +1,69 @@ +/** +# __----~~~~~~~~~~~------___ +# . . ~~//====...... __--~ ~~ +# -. \_|// |||\\ ~~~~~~::::... /~ +# ___-==_ _-~o~ \/ ||| \\ _/~~- +# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ +# _-~~ .=~ | \\-_ '-~7 /- / || \ / +# .~ .~ | \\ -_ / /- / || \ / +# / ____ / | \\ ~-_/ /|- _/ .|| \ / +# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ +# ' ~-| /| |-~\~~ __--~~ +# |-~~-_/ | | ~\_ _-~ /\ +# / \ \__ \/~ \__ +# _--~ _/ | .-~~____--~-/ ~~==. +# ((->/~ '.|||' -_| ~~-/ , . _|| +# -_ ~\ ~~---l__i__i__i--~~_/ +# _-~-__ ~) \--______________--~~ +# //.-~~~-~_--~- |-------~~~~~~~~ +# //.-~~~--\ +# 神兽保佑 +# 永无BUG! +*/ +package com.fengdu.gas.repository.po; + +import lombok.Data; + +import com.baomidou.mybatisplus.annotation.*; + +import java.io.Serializable; +import java.sql.Timestamp; + +/** + * 用户和角色关联关系 + * @author lin.liu + */ +@Data +@TableName("admin_role_relation") +public class AdminRoleRelationPO implements Serializable { + /** + * 主键 + */ + private Long id; + /** + * 管理员id + */ + @TableField(value = "admin_id") + private Long adminId; + /** + * 角色id + */ + @TableField(value = "role_id") + private Long roleId; + /** + * 数据创建时间 + */ + @TableField(value = "create_time") + private Long createTime; + /** + * 最后更新时间 + */ + @TableField(value = "update_time") + private Timestamp updateTime; + /** + * 是否删除(逻辑删除) + */ + @TableLogic + @TableField(value = "is_delete") + private Integer isDelete; +} diff --git a/src/main/java/com/fengdu/gas/repository/po/AdminUserPO.java b/src/main/java/com/fengdu/gas/repository/po/AdminUserPO.java new file mode 100644 index 0000000..fad12f2 --- /dev/null +++ b/src/main/java/com/fengdu/gas/repository/po/AdminUserPO.java @@ -0,0 +1,104 @@ +/** +# __----~~~~~~~~~~~------___ +# . . ~~//====...... __--~ ~~ +# -. \_|// |||\\ ~~~~~~::::... /~ +# ___-==_ _-~o~ \/ ||| \\ _/~~- +# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ +# _-~~ .=~ | \\-_ '-~7 /- / || \ / +# .~ .~ | \\ -_ / /- / || \ / +# / ____ / | \\ ~-_/ /|- _/ .|| \ / +# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ +# ' ~-| /| |-~\~~ __--~~ +# |-~~-_/ | | ~\_ _-~ /\ +# / \ \__ \/~ \__ +# _--~ _/ | .-~~____--~-/ ~~==. +# ((->/~ '.|||' -_| ~~-/ , . _|| +# -_ ~\ ~~---l__i__i__i--~~_/ +# _-~-__ ~) \--______________--~~ +# //.-~~~-~_--~- |-------~~~~~~~~ +# //.-~~~--\ +# 神兽保佑 +# 永无BUG! +*/ +package com.fengdu.gas.repository.po; + +import lombok.Data; + +import com.baomidou.mybatisplus.annotation.*; + +import java.io.Serializable; +import java.sql.Timestamp; + +/** + * 管理员帐号 + * @author lin.liu + */ +@Data +@TableName("admin_user") +public class AdminUserPO implements Serializable { + /** + * 主键 + */ + private Long id; + /** + * 用户类型 EUserType + */ + @TableField(value = "user_type") + private Integer userType; + /** + * 用户关联id,和“user_type”对应,如:客户id等 + */ + @TableField(value = "user_rel_id") + private Long userRelId; + /** + * 用户名 + */ + @TableField(value = "user_name") + private String userName; + /** + * 密码 + */ + @TableField(value = "password") + private String password; + /** + * 昵称 + */ + @TableField(value = "nick_name") + private String nickName; + /** + * 头像 + */ + @TableField(value = "head_img") + private String headImg; + /** + * 联系方式 + */ + @TableField(value = "contact") + private String contact; + /** + * 联系邮箱 + */ + @TableField(value = "email") + private String email; + /** + * 状态 EState + */ + @TableField(value = "status") + private Integer status; + /** + * 数据创建时间 + */ + @TableField(value = "create_time") + private Long createTime; + /** + * 最后更新时间 + */ + @TableField(value = "update_time") + private Timestamp updateTime; + /** + * 是否删除(逻辑删除) + */ + @TableLogic + @TableField(value = "is_delete") + private Integer isDelete; +} diff --git a/src/main/java/com/fengdu/gas/repository/po/NoticePO.java b/src/main/java/com/fengdu/gas/repository/po/NoticePO.java new file mode 100644 index 0000000..2b613eb --- /dev/null +++ b/src/main/java/com/fengdu/gas/repository/po/NoticePO.java @@ -0,0 +1,109 @@ +/** +# __----~~~~~~~~~~~------___ +# . . ~~//====...... __--~ ~~ +# -. \_|// |||\\ ~~~~~~::::... /~ +# ___-==_ _-~o~ \/ ||| \\ _/~~- +# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ +# _-~~ .=~ | \\-_ '-~7 /- / || \ / +# .~ .~ | \\ -_ / /- / || \ / +# / ____ / | \\ ~-_/ /|- _/ .|| \ / +# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ +# ' ~-| /| |-~\~~ __--~~ +# |-~~-_/ | | ~\_ _-~ /\ +# / \ \__ \/~ \__ +# _--~ _/ | .-~~____--~-/ ~~==. +# ((->/~ '.|||' -_| ~~-/ , . _|| +# -_ ~\ ~~---l__i__i__i--~~_/ +# _-~-__ ~) \--______________--~~ +# //.-~~~-~_--~- |-------~~~~~~~~ +# //.-~~~--\ +# 神兽保佑 +# 永无BUG! +*/ +package com.fengdu.gas.repository.po; + +import lombok.Data; + +import com.baomidou.mybatisplus.annotation.*; + +import java.io.Serializable; +import java.sql.Timestamp; + +/** + * 公告 + * @author lin.liu + */ +@Data +@TableName("notice") +public class NoticePO implements Serializable { + /** + * 主键 + */ + private Long id; + /** + * 发布人 + */ + @TableField(value = "publish_user") + private String publishUser; + /** + * 标题 + */ + @TableField(value = "title") + private String title; + /** + * 摘要 + */ + @TableField(value = "summary") + private String summary; + /** + * 内容 + */ + @TableField(value = "content") + private String content; + /** + * 排序 + */ + @TableField(value = "sort") + private Integer sort; + /** + * 状态(EState) + */ + @TableField(value = "status") + private Integer status; + /** + * 数据创建时间 + */ + @TableField(value = "create_time") + private Long createTime; + /** + * 最后更新时间 + */ + @TableField(value = "update_time") + private Timestamp updateTime; + /** + * 数据创建人 + */ + @TableField(value = "create_user") + private String createUser; + /** + * 数据创建人名称 + */ + @TableField(value = "create_user_name") + private String createUserName; + /** + * 最后更新人 + */ + @TableField(value = "update_user") + private String updateUser; + /** + * 最后更新人名称 + */ + @TableField(value = "update_user_name") + private String updateUserName; + /** + * 是否删除(逻辑删除) + */ + @TableLogic + @TableField(value = "is_delete") + private Integer isDelete; +} diff --git a/src/main/java/com/fengdu/gas/repository/po/QuartzTaskErrorPO.java b/src/main/java/com/fengdu/gas/repository/po/QuartzTaskErrorPO.java new file mode 100644 index 0000000..49206aa --- /dev/null +++ b/src/main/java/com/fengdu/gas/repository/po/QuartzTaskErrorPO.java @@ -0,0 +1,74 @@ +/** +# __----~~~~~~~~~~~------___ +# . . ~~//====...... __--~ ~~ +# -. \_|// |||\\ ~~~~~~::::... /~ +# ___-==_ _-~o~ \/ ||| \\ _/~~- +# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ +# _-~~ .=~ | \\-_ '-~7 /- / || \ / +# .~ .~ | \\ -_ / /- / || \ / +# / ____ / | \\ ~-_/ /|- _/ .|| \ / +# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ +# ' ~-| /| |-~\~~ __--~~ +# |-~~-_/ | | ~\_ _-~ /\ +# / \ \__ \/~ \__ +# _--~ _/ | .-~~____--~-/ ~~==. +# ((->/~ '.|||' -_| ~~-/ , . _|| +# -_ ~\ ~~---l__i__i__i--~~_/ +# _-~-__ ~) \--______________--~~ +# //.-~~~-~_--~- |-------~~~~~~~~ +# //.-~~~--\ +# 神兽保佑 +# 永无BUG! +*/ +package com.fengdu.gas.repository.po; + +import lombok.Data; + +import com.baomidou.mybatisplus.annotation.*; + +import java.io.Serializable; +import java.sql.Timestamp; + +/** + * 定时任务错误信息 + * @author lin.liu + */ +@Data +@TableName("quartz_task_error") +public class QuartzTaskErrorPO implements Serializable { + /** + * 主键 + */ + private Long id; + /** + * 任务执行记录id + */ + @TableField(value = "task_execute_record_id") + private String taskExecuteRecordId; + /** + * 关键字 + */ + @TableField(value = "error_key") + private String errorKey; + /** + * 详细信息 + */ + @TableField(value = "error_value") + private String errorValue; + /** + * 数据创建时间 + */ + @TableField(value = "create_time") + private Long createTime; + /** + * 最后更新时间 + */ + @TableField(value = "update_time") + private Timestamp updateTime; + /** + * 是否删除(逻辑删除) + */ + @TableLogic + @TableField(value = "is_delete") + private Integer isDelete; +} diff --git a/src/main/java/com/fengdu/gas/repository/po/QuartzTaskInfoPO.java b/src/main/java/com/fengdu/gas/repository/po/QuartzTaskInfoPO.java new file mode 100644 index 0000000..a7c2a78 --- /dev/null +++ b/src/main/java/com/fengdu/gas/repository/po/QuartzTaskInfoPO.java @@ -0,0 +1,129 @@ +/** +# __----~~~~~~~~~~~------___ +# . . ~~//====...... __--~ ~~ +# -. \_|// |||\\ ~~~~~~::::... /~ +# ___-==_ _-~o~ \/ ||| \\ _/~~- +# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ +# _-~~ .=~ | \\-_ '-~7 /- / || \ / +# .~ .~ | \\ -_ / /- / || \ / +# / ____ / | \\ ~-_/ /|- _/ .|| \ / +# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ +# ' ~-| /| |-~\~~ __--~~ +# |-~~-_/ | | ~\_ _-~ /\ +# / \ \__ \/~ \__ +# _--~ _/ | .-~~____--~-/ ~~==. +# ((->/~ '.|||' -_| ~~-/ , . _|| +# -_ ~\ ~~---l__i__i__i--~~_/ +# _-~-__ ~) \--______________--~~ +# //.-~~~-~_--~- |-------~~~~~~~~ +# //.-~~~--\ +# 神兽保佑 +# 永无BUG! +*/ +package com.fengdu.gas.repository.po; + +import lombok.Data; + +import com.baomidou.mybatisplus.annotation.*; + +import java.io.Serializable; +import java.sql.Timestamp; + +/** + * 定时任务信息 + * @author lin.liu + */ +@Data +@TableName("quartz_task_info") +public class QuartzTaskInfoPO implements Serializable { + /** + * 主键 + */ + private Long id; + /** + * 版本号:需要乐观锁控制 + */ + @TableField(value = "version") + private Long version; + /** + * 任务编号 + */ + @TableField(value = "task_no") + private String taskNo; + /** + * 任务名称 + */ + @TableField(value = "task_name") + private String taskName; + /** + * 定时规则表达式 + */ + @TableField(value = "scheduler_rule") + private String schedulerRule; + /** + * 冻结状态 + */ + @TableField(value = "status") + private Integer status; + /** + * 执行者(job方法名) + */ + @TableField(value = "executor") + private String executor; + /** + * 冻结时间 + */ + @TableField(value = "frozen_time") + private Long frozenTime; + /** + * 解冻时间 + */ + @TableField(value = "unfrozen_time") + private Long unfrozenTime; + /** + * 发送方式 + */ + @TableField(value = "send_type") + private String sendType; + /** + * 请求地址 + */ + @TableField(value = "url") + private String url; + /** + * 执行参数 + */ + @TableField(value = "execute_parameter") + private String executeParameter; + /** + * 上次执行时间 + */ + @TableField(value = "last_time") + private String lastTime; + /** + * 上次执行参数 + */ + @TableField(value = "last_parameter") + private String lastParameter; + /** + * 上次执行结果 + */ + @TableField(value = "last_status") + private Integer lastStatus; + /** + * 数据创建时间 + */ + @TableField(value = "create_time") + private Long createTime; + /** + * 最后更新时间 + */ + @TableField(value = "update_time") + private Timestamp updateTime; + /** + * 是否删除(逻辑删除) + */ + @TableLogic + @TableField(value = "is_delete") + private Integer isDelete; +} diff --git a/src/main/java/com/fengdu/gas/repository/po/QuartzTaskRecordPO.java b/src/main/java/com/fengdu/gas/repository/po/QuartzTaskRecordPO.java new file mode 100644 index 0000000..c596222 --- /dev/null +++ b/src/main/java/com/fengdu/gas/repository/po/QuartzTaskRecordPO.java @@ -0,0 +1,99 @@ +/** +# __----~~~~~~~~~~~------___ +# . . ~~//====...... __--~ ~~ +# -. \_|// |||\\ ~~~~~~::::... /~ +# ___-==_ _-~o~ \/ ||| \\ _/~~- +# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ +# _-~~ .=~ | \\-_ '-~7 /- / || \ / +# .~ .~ | \\ -_ / /- / || \ / +# / ____ / | \\ ~-_/ /|- _/ .|| \ / +# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ +# ' ~-| /| |-~\~~ __--~~ +# |-~~-_/ | | ~\_ _-~ /\ +# / \ \__ \/~ \__ +# _--~ _/ | .-~~____--~-/ ~~==. +# ((->/~ '.|||' -_| ~~-/ , . _|| +# -_ ~\ ~~---l__i__i__i--~~_/ +# _-~-__ ~) \--______________--~~ +# //.-~~~-~_--~- |-------~~~~~~~~ +# //.-~~~--\ +# 神兽保佑 +# 永无BUG! +*/ +package com.fengdu.gas.repository.po; + +import lombok.Data; + +import com.baomidou.mybatisplus.annotation.*; + +import java.io.Serializable; +import java.sql.Timestamp; + +/** + * 定时任务执行记录 + * @author lin.liu + */ +@Data +@TableName("quartz_task_record") +public class QuartzTaskRecordPO implements Serializable { + /** + * 主键 + */ + private Long id; + /** + * 任务编号 + */ + @TableField(value = "task_no") + private String taskNo; + /** + * 任务名称 + */ + @TableField(value = "task_name") + private String taskName; + /** + * 执行参数 + */ + @TableField(value = "execute_parameter") + private String executeParameter; + /** + * 开始执行时间 + */ + @TableField(value = "start_time") + private Long startTime; + /** + * 执行结束时间 + */ + @TableField(value = "end_time") + private Long endTime; + /** + * 执行耗时(ms) + */ + @TableField(value = "execute_times") + private Long executeTimes; + /** + * 任务状态 + */ + @TableField(value = "task_status") + private Integer taskStatus; + /** + * 失败错误描述 + */ + @TableField(value = "fail_reason") + private String failReason; + /** + * 数据创建时间 + */ + @TableField(value = "create_time") + private Long createTime; + /** + * 最后更新时间 + */ + @TableField(value = "update_time") + private Timestamp updateTime; + /** + * 是否删除(逻辑删除) + */ + @TableLogic + @TableField(value = "is_delete") + private Integer isDelete; +} diff --git a/src/main/java/com/fengdu/gas/repository/po/SysDictDataPO.java b/src/main/java/com/fengdu/gas/repository/po/SysDictDataPO.java new file mode 100644 index 0000000..0eb8316 --- /dev/null +++ b/src/main/java/com/fengdu/gas/repository/po/SysDictDataPO.java @@ -0,0 +1,84 @@ +/** +# __----~~~~~~~~~~~------___ +# . . ~~//====...... __--~ ~~ +# -. \_|// |||\\ ~~~~~~::::... /~ +# ___-==_ _-~o~ \/ ||| \\ _/~~- +# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ +# _-~~ .=~ | \\-_ '-~7 /- / || \ / +# .~ .~ | \\ -_ / /- / || \ / +# / ____ / | \\ ~-_/ /|- _/ .|| \ / +# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ +# ' ~-| /| |-~\~~ __--~~ +# |-~~-_/ | | ~\_ _-~ /\ +# / \ \__ \/~ \__ +# _--~ _/ | .-~~____--~-/ ~~==. +# ((->/~ '.|||' -_| ~~-/ , . _|| +# -_ ~\ ~~---l__i__i__i--~~_/ +# _-~-__ ~) \--______________--~~ +# //.-~~~-~_--~- |-------~~~~~~~~ +# //.-~~~--\ +# 神兽保佑 +# 永无BUG! +*/ +package com.fengdu.gas.repository.po; + +import lombok.Data; + +import com.baomidou.mybatisplus.annotation.*; + +import java.io.Serializable; +import java.sql.Timestamp; + +/** + * 字典数据 + * @author lin.liu + */ +@Data +@TableName("sys_dict_data") +public class SysDictDataPO implements Serializable { + /** + * 主键 + */ + private Long id; + /** + * 字典标题 + */ + @TableField(value = "dict_label") + private String dictLabel; + /** + * 字典键值 + */ + @TableField(value = "dict_value") + private String dictValue; + /** + * 字典类型 + */ + @TableField(value = "dict_type") + private String dictType; + /** + * 状态 + */ + @TableField(value = "status") + private Integer status; + /** + * 备注 + */ + @TableField(value = "remark") + private String remark; + /** + * 数据创建时间 + */ + @TableField(value = "create_time") + private Long createTime; + /** + * 最后更新时间 + */ + @TableField(value = "update_time") + private Timestamp updateTime; + /** + * 是否删除(逻辑删除) + */ + @TableLogic + @TableField(value = "is_delete") + private Integer isDelete; +} diff --git a/src/main/java/com/fengdu/gas/repository/po/SysDictTypePO.java b/src/main/java/com/fengdu/gas/repository/po/SysDictTypePO.java new file mode 100644 index 0000000..4f4490c --- /dev/null +++ b/src/main/java/com/fengdu/gas/repository/po/SysDictTypePO.java @@ -0,0 +1,79 @@ +/** +# __----~~~~~~~~~~~------___ +# . . ~~//====...... __--~ ~~ +# -. \_|// |||\\ ~~~~~~::::... /~ +# ___-==_ _-~o~ \/ ||| \\ _/~~- +# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ +# _-~~ .=~ | \\-_ '-~7 /- / || \ / +# .~ .~ | \\ -_ / /- / || \ / +# / ____ / | \\ ~-_/ /|- _/ .|| \ / +# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ +# ' ~-| /| |-~\~~ __--~~ +# |-~~-_/ | | ~\_ _-~ /\ +# / \ \__ \/~ \__ +# _--~ _/ | .-~~____--~-/ ~~==. +# ((->/~ '.|||' -_| ~~-/ , . _|| +# -_ ~\ ~~---l__i__i__i--~~_/ +# _-~-__ ~) \--______________--~~ +# //.-~~~-~_--~- |-------~~~~~~~~ +# //.-~~~--\ +# 神兽保佑 +# 永无BUG! +*/ +package com.fengdu.gas.repository.po; + +import lombok.Data; + +import com.baomidou.mybatisplus.annotation.*; + +import java.io.Serializable; +import java.sql.Timestamp; + +/** + * 字典类型 + * @author lin.liu + */ +@Data +@TableName("sys_dict_type") +public class SysDictTypePO implements Serializable { + /** + * 主键 + */ + private Long id; + /** + * 字典名称 + */ + @TableField(value = "dict_name") + private String dictName; + /** + * 字典类型 + */ + @TableField(value = "dict_type") + private String dictType; + /** + * 状态 + */ + @TableField(value = "status") + private Integer status; + /** + * 备注 + */ + @TableField(value = "remark") + private String remark; + /** + * 数据创建时间 + */ + @TableField(value = "create_time") + private Long createTime; + /** + * 最后更新时间 + */ + @TableField(value = "update_time") + private Timestamp updateTime; + /** + * 是否删除(逻辑删除) + */ + @TableLogic + @TableField(value = "is_delete") + private Integer isDelete; +} diff --git a/src/main/java/com/fengdu/gas/repository/po/TestInfoPO.java b/src/main/java/com/fengdu/gas/repository/po/TestInfoPO.java new file mode 100644 index 0000000..aed2e9d --- /dev/null +++ b/src/main/java/com/fengdu/gas/repository/po/TestInfoPO.java @@ -0,0 +1,105 @@ +/** +# __----~~~~~~~~~~~------___ +# . . ~~//====...... __--~ ~~ +# -. \_|// |||\\ ~~~~~~::::... /~ +# ___-==_ _-~o~ \/ ||| \\ _/~~- +# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ +# _-~~ .=~ | \\-_ '-~7 /- / || \ / +# .~ .~ | \\ -_ / /- / || \ / +# / ____ / | \\ ~-_/ /|- _/ .|| \ / +# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ +# ' ~-| /| |-~\~~ __--~~ +# |-~~-_/ | | ~\_ _-~ /\ +# / \ \__ \/~ \__ +# _--~ _/ | .-~~____--~-/ ~~==. +# ((->/~ '.|||' -_| ~~-/ , . _|| +# -_ ~\ ~~---l__i__i__i--~~_/ +# _-~-__ ~) \--______________--~~ +# //.-~~~-~_--~- |-------~~~~~~~~ +# //.-~~~--\ +# 神兽保佑 +# 永无BUG! +*/ +package com.fengdu.gas.repository.po; + +import lombok.Data; + +import com.baomidou.mybatisplus.annotation.*; + +import java.io.Serializable; +import java.sql.Timestamp; +import java.math.BigDecimal; + +/** + * 测试信息表 + * @author lin.liu + */ +@Data +@TableName("test_info") +public class TestInfoPO implements Serializable { + /** + * 主键 + */ + private Long id; + /** + * 名称 + */ + @TableField(value = "name") + private String name; + /** + * 用户id + */ + @TableField(value = "user_id") + private Long userId; + /** + * 电话 + */ + @TableField(value = "phone") + private String phone; + /** + * balance余额 + */ + @TableField(value = "balance") + private BigDecimal balance; + /** + * 性别 男=1,女=2,其他=3 + */ + @TableField(value = "sex") + private Integer sex; + /** + * 生日 + */ + @TableField(value = "birthday") + private String birthday; + /** + * 排序值 + */ + @TableField(value = "sort") + private Integer sort; + /** + * 状态 EState + */ + @TableField(value = "status") + private Integer status; + /** + * 备注 + */ + @TableField(value = "comment") + private String comment; + /** + * 数据创建时间 + */ + @TableField(value = "create_time") + private Long createTime; + /** + * 最后更新时间 + */ + @TableField(value = "update_time") + private Timestamp updateTime; + /** + * 是否删除(逻辑删除) + */ + @TableLogic + @TableField(value = "is_delete") + private Integer isDelete; +} diff --git a/src/main/java/com/fengdu/gas/repository/vo/AdminMenuVO.java b/src/main/java/com/fengdu/gas/repository/vo/AdminMenuVO.java new file mode 100644 index 0000000..ee983df --- /dev/null +++ b/src/main/java/com/fengdu/gas/repository/vo/AdminMenuVO.java @@ -0,0 +1,55 @@ +/** +# __----~~~~~~~~~~~------___ +# . . ~~//====...... __--~ ~~ +# -. \_|// |||\\ ~~~~~~::::... /~ +# ___-==_ _-~o~ \/ ||| \\ _/~~- +# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ +# _-~~ .=~ | \\-_ '-~7 /- / || \ / +# .~ .~ | \\ -_ / /- / || \ / +# / ____ / | \\ ~-_/ /|- _/ .|| \ / +# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ +# ' ~-| /| |-~\~~ __--~~ +# |-~~-_/ | | ~\_ _-~ /\ +# / \ \__ \/~ \__ +# _--~ _/ | .-~~____--~-/ ~~==. +# ((->/~ '.|||' -_| ~~-/ , . _|| +# -_ ~\ ~~---l__i__i__i--~~_/ +# _-~-__ ~) \--______________--~~ +# //.-~~~-~_--~- |-------~~~~~~~~ +# //.-~~~--\ +# 神兽保佑 +# 永无BUG! +*/ +package com.fengdu.gas.repository.vo; + +import com.fengdu.gas.common.util.LocalDateTimeUtil; +import com.fengdu.gas.common.util.NumericUtil; +import com.fengdu.gas.repository.po.AdminMenuPO; +import lombok.Data; + +import java.util.Objects; + +/** + * 后台菜单 + * @author lin.liu + * @description 后台菜单 + */ +@Data +public class AdminMenuVO extends AdminMenuPO implements BasicVO { + + @Override + public String getCreateTimeView() { + if (NumericUtil.tryParseLong(this.getCreateTime()).compareTo(0L) > 0) { + return LocalDateTimeUtil.toFormatString(this.getCreateTime()); + } + return ""; + } + + @Override + public String getUpdateTimeView() { + if (Objects.isNull(this.getUpdateTime())) { + return ""; + } + return LocalDateTimeUtil.toFormatFullString(this.getUpdateTime()); + } +} diff --git a/src/main/java/com/fengdu/gas/repository/vo/AdminMenusVO.java b/src/main/java/com/fengdu/gas/repository/vo/AdminMenusVO.java new file mode 100644 index 0000000..7d5abfe --- /dev/null +++ b/src/main/java/com/fengdu/gas/repository/vo/AdminMenusVO.java @@ -0,0 +1,54 @@ +/** +# __----~~~~~~~~~~~------___ +# . . ~~//====...... __--~ ~~ +# -. \_|// |||\\ ~~~~~~::::... /~ +# ___-==_ _-~o~ \/ ||| \\ _/~~- +# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ +# _-~~ .=~ | \\-_ '-~7 /- / || \ / +# .~ .~ | \\ -_ / /- / || \ / +# / ____ / | \\ ~-_/ /|- _/ .|| \ / +# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ +# ' ~-| /| |-~\~~ __--~~ +# |-~~-_/ | | ~\_ _-~ /\ +# / \ \__ \/~ \__ +# _--~ _/ | .-~~____--~-/ ~~==. +# ((->/~ '.|||' -_| ~~-/ , . _|| +# -_ ~\ ~~---l__i__i__i--~~_/ +# _-~-__ ~) \--______________--~~ +# //.-~~~-~_--~- |-------~~~~~~~~ +# //.-~~~--\ +# 神兽保佑 +# 永无BUG! +*/ +package com.fengdu.gas.repository.vo; + +import com.fengdu.gas.common.util.LocalDateTimeUtil; +import com.fengdu.gas.common.util.NumericUtil; +import lombok.Data; + +import java.util.Objects; +import com.fengdu.gas.repository.po.AdminMenusPO; + +/** + * 菜单信息 + * @author lin.liu + */ +@Data +public class AdminMenusVO extends AdminMenusPO implements BasicVO { + + @Override + public String getCreateTimeView() { + if (NumericUtil.tryParseLong(this.getCreateTime()).compareTo(0L) > 0) { + return LocalDateTimeUtil.toFormatString(this.getCreateTime()); + } + return ""; + } + + @Override + public String getUpdateTimeView() { + if (Objects.isNull(this.getUpdateTime())) { + return ""; + } + return LocalDateTimeUtil.toFormatFullString(this.getUpdateTime()); + } +} diff --git a/src/main/java/com/fengdu/gas/repository/vo/AdminPermissionVO.java b/src/main/java/com/fengdu/gas/repository/vo/AdminPermissionVO.java new file mode 100644 index 0000000..de7320f --- /dev/null +++ b/src/main/java/com/fengdu/gas/repository/vo/AdminPermissionVO.java @@ -0,0 +1,55 @@ +/** +# __----~~~~~~~~~~~------___ +# . . ~~//====...... __--~ ~~ +# -. \_|// |||\\ ~~~~~~::::... /~ +# ___-==_ _-~o~ \/ ||| \\ _/~~- +# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ +# _-~~ .=~ | \\-_ '-~7 /- / || \ / +# .~ .~ | \\ -_ / /- / || \ / +# / ____ / | \\ ~-_/ /|- _/ .|| \ / +# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ +# ' ~-| /| |-~\~~ __--~~ +# |-~~-_/ | | ~\_ _-~ /\ +# / \ \__ \/~ \__ +# _--~ _/ | .-~~____--~-/ ~~==. +# ((->/~ '.|||' -_| ~~-/ , . _|| +# -_ ~\ ~~---l__i__i__i--~~_/ +# _-~-__ ~) \--______________--~~ +# //.-~~~-~_--~- |-------~~~~~~~~ +# //.-~~~--\ +# 神兽保佑 +# 永无BUG! +*/ +package com.fengdu.gas.repository.vo; + +import com.fengdu.gas.common.util.LocalDateTimeUtil; +import com.fengdu.gas.common.util.NumericUtil; +import com.fengdu.gas.repository.po.AdminPermissionPO; +import lombok.Data; + +import java.util.Objects; + +/** + * 后台用户权限表 + * @author lin.liu + * @description 后台用户权限表 + */ +@Data +public class AdminPermissionVO extends AdminPermissionPO implements BasicVO { + + @Override + public String getCreateTimeView() { + if (NumericUtil.tryParseLong(this.getCreateTime()).compareTo(0L) > 0) { + return LocalDateTimeUtil.toFormatString(this.getCreateTime()); + } + return ""; + } + + @Override + public String getUpdateTimeView() { + if (Objects.isNull(this.getUpdateTime())) { + return ""; + } + return LocalDateTimeUtil.toFormatFullString(this.getUpdateTime()); + } +} diff --git a/src/main/java/com/fengdu/gas/repository/vo/AdminRoleMenuRelationVO.java b/src/main/java/com/fengdu/gas/repository/vo/AdminRoleMenuRelationVO.java new file mode 100644 index 0000000..915c556 --- /dev/null +++ b/src/main/java/com/fengdu/gas/repository/vo/AdminRoleMenuRelationVO.java @@ -0,0 +1,55 @@ +/** +# __----~~~~~~~~~~~------___ +# . . ~~//====...... __--~ ~~ +# -. \_|// |||\\ ~~~~~~::::... /~ +# ___-==_ _-~o~ \/ ||| \\ _/~~- +# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ +# _-~~ .=~ | \\-_ '-~7 /- / || \ / +# .~ .~ | \\ -_ / /- / || \ / +# / ____ / | \\ ~-_/ /|- _/ .|| \ / +# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ +# ' ~-| /| |-~\~~ __--~~ +# |-~~-_/ | | ~\_ _-~ /\ +# / \ \__ \/~ \__ +# _--~ _/ | .-~~____--~-/ ~~==. +# ((->/~ '.|||' -_| ~~-/ , . _|| +# -_ ~\ ~~---l__i__i__i--~~_/ +# _-~-__ ~) \--______________--~~ +# //.-~~~-~_--~- |-------~~~~~~~~ +# //.-~~~--\ +# 神兽保佑 +# 永无BUG! +*/ +package com.fengdu.gas.repository.vo; + +import com.fengdu.gas.common.util.LocalDateTimeUtil; +import com.fengdu.gas.common.util.NumericUtil; +import com.fengdu.gas.repository.po.AdminRoleMenuRelationPO; +import lombok.Data; + +import java.util.Objects; + +/** + * 后台角色菜单关系表 + * @author lin.liu + * @description 后台角色菜单关系表 + */ +@Data +public class AdminRoleMenuRelationVO extends AdminRoleMenuRelationPO implements BasicVO { + + @Override + public String getCreateTimeView() { + if (NumericUtil.tryParseLong(this.getCreateTime()).compareTo(0L) > 0) { + return LocalDateTimeUtil.toFormatString(this.getCreateTime()); + } + return ""; + } + + @Override + public String getUpdateTimeView() { + if (Objects.isNull(this.getUpdateTime())) { + return ""; + } + return LocalDateTimeUtil.toFormatFullString(this.getUpdateTime()); + } +} diff --git a/src/main/java/com/fengdu/gas/repository/vo/AdminRolePermissionRelationVO.java b/src/main/java/com/fengdu/gas/repository/vo/AdminRolePermissionRelationVO.java new file mode 100644 index 0000000..e0af40c --- /dev/null +++ b/src/main/java/com/fengdu/gas/repository/vo/AdminRolePermissionRelationVO.java @@ -0,0 +1,55 @@ +/** +# __----~~~~~~~~~~~------___ +# . . ~~//====...... __--~ ~~ +# -. \_|// |||\\ ~~~~~~::::... /~ +# ___-==_ _-~o~ \/ ||| \\ _/~~- +# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ +# _-~~ .=~ | \\-_ '-~7 /- / || \ / +# .~ .~ | \\ -_ / /- / || \ / +# / ____ / | \\ ~-_/ /|- _/ .|| \ / +# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ +# ' ~-| /| |-~\~~ __--~~ +# |-~~-_/ | | ~\_ _-~ /\ +# / \ \__ \/~ \__ +# _--~ _/ | .-~~____--~-/ ~~==. +# ((->/~ '.|||' -_| ~~-/ , . _|| +# -_ ~\ ~~---l__i__i__i--~~_/ +# _-~-__ ~) \--______________--~~ +# //.-~~~-~_--~- |-------~~~~~~~~ +# //.-~~~--\ +# 神兽保佑 +# 永无BUG! +*/ +package com.fengdu.gas.repository.vo; + +import com.fengdu.gas.common.util.LocalDateTimeUtil; +import com.fengdu.gas.common.util.NumericUtil; +import com.fengdu.gas.repository.po.AdminRolePermissionRelationPO; +import lombok.Data; + +import java.util.Objects; + +/** + * 后台角色权限关系表 + * @author lin.liu + * @description 后台角色权限关系表 + */ +@Data +public class AdminRolePermissionRelationVO extends AdminRolePermissionRelationPO implements BasicVO { + + @Override + public String getCreateTimeView() { + if (NumericUtil.tryParseLong(this.getCreateTime()).compareTo(0L) > 0) { + return LocalDateTimeUtil.toFormatString(this.getCreateTime()); + } + return ""; + } + + @Override + public String getUpdateTimeView() { + if (Objects.isNull(this.getUpdateTime())) { + return ""; + } + return LocalDateTimeUtil.toFormatFullString(this.getUpdateTime()); + } +} diff --git a/src/main/java/com/fengdu/gas/repository/vo/AdminRoleRelationVO.java b/src/main/java/com/fengdu/gas/repository/vo/AdminRoleRelationVO.java new file mode 100644 index 0000000..8143656 --- /dev/null +++ b/src/main/java/com/fengdu/gas/repository/vo/AdminRoleRelationVO.java @@ -0,0 +1,55 @@ +/** +# __----~~~~~~~~~~~------___ +# . . ~~//====...... __--~ ~~ +# -. \_|// |||\\ ~~~~~~::::... /~ +# ___-==_ _-~o~ \/ ||| \\ _/~~- +# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ +# _-~~ .=~ | \\-_ '-~7 /- / || \ / +# .~ .~ | \\ -_ / /- / || \ / +# / ____ / | \\ ~-_/ /|- _/ .|| \ / +# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ +# ' ~-| /| |-~\~~ __--~~ +# |-~~-_/ | | ~\_ _-~ /\ +# / \ \__ \/~ \__ +# _--~ _/ | .-~~____--~-/ ~~==. +# ((->/~ '.|||' -_| ~~-/ , . _|| +# -_ ~\ ~~---l__i__i__i--~~_/ +# _-~-__ ~) \--______________--~~ +# //.-~~~-~_--~- |-------~~~~~~~~ +# //.-~~~--\ +# 神兽保佑 +# 永无BUG! +*/ +package com.fengdu.gas.repository.vo; + +import com.fengdu.gas.common.util.LocalDateTimeUtil; +import com.fengdu.gas.common.util.NumericUtil; +import com.fengdu.gas.repository.po.AdminRoleRelationPO; +import lombok.Data; + +import java.util.Objects; + +/** + * 后台用户和角色关系表 + * @author lin.liu + * @description 后台用户和角色关系表 + */ +@Data +public class AdminRoleRelationVO extends AdminRoleRelationPO implements BasicVO { + + @Override + public String getCreateTimeView() { + if (NumericUtil.tryParseLong(this.getCreateTime()).compareTo(0L) > 0) { + return LocalDateTimeUtil.toFormatString(this.getCreateTime()); + } + return ""; + } + + @Override + public String getUpdateTimeView() { + if (Objects.isNull(this.getUpdateTime())) { + return ""; + } + return LocalDateTimeUtil.toFormatFullString(this.getUpdateTime()); + } +} diff --git a/src/main/java/com/fengdu/gas/repository/vo/AdminRoleVO.java b/src/main/java/com/fengdu/gas/repository/vo/AdminRoleVO.java new file mode 100644 index 0000000..6bbbbe0 --- /dev/null +++ b/src/main/java/com/fengdu/gas/repository/vo/AdminRoleVO.java @@ -0,0 +1,55 @@ +/** +# __----~~~~~~~~~~~------___ +# . . ~~//====...... __--~ ~~ +# -. \_|// |||\\ ~~~~~~::::... /~ +# ___-==_ _-~o~ \/ ||| \\ _/~~- +# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ +# _-~~ .=~ | \\-_ '-~7 /- / || \ / +# .~ .~ | \\ -_ / /- / || \ / +# / ____ / | \\ ~-_/ /|- _/ .|| \ / +# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ +# ' ~-| /| |-~\~~ __--~~ +# |-~~-_/ | | ~\_ _-~ /\ +# / \ \__ \/~ \__ +# _--~ _/ | .-~~____--~-/ ~~==. +# ((->/~ '.|||' -_| ~~-/ , . _|| +# -_ ~\ ~~---l__i__i__i--~~_/ +# _-~-__ ~) \--______________--~~ +# //.-~~~-~_--~- |-------~~~~~~~~ +# //.-~~~--\ +# 神兽保佑 +# 永无BUG! +*/ +package com.fengdu.gas.repository.vo; + +import com.fengdu.gas.common.util.LocalDateTimeUtil; +import com.fengdu.gas.common.util.NumericUtil; +import com.fengdu.gas.repository.po.AdminRolePO; +import lombok.Data; + +import java.util.Objects; + +/** + * 后台用户角色表 + * @author lin.liu + * @description 后台用户角色表 + */ +@Data +public class AdminRoleVO extends AdminRolePO implements BasicVO { + + @Override + public String getCreateTimeView() { + if (NumericUtil.tryParseLong(this.getCreateTime()).compareTo(0L) > 0) { + return LocalDateTimeUtil.toFormatString(this.getCreateTime()); + } + return ""; + } + + @Override + public String getUpdateTimeView() { + if (Objects.isNull(this.getUpdateTime())) { + return ""; + } + return LocalDateTimeUtil.toFormatFullString(this.getUpdateTime()); + } +} diff --git a/src/main/java/com/fengdu/gas/repository/vo/AdminUserVO.java b/src/main/java/com/fengdu/gas/repository/vo/AdminUserVO.java new file mode 100644 index 0000000..f7c4f3a --- /dev/null +++ b/src/main/java/com/fengdu/gas/repository/vo/AdminUserVO.java @@ -0,0 +1,62 @@ +/** +# __----~~~~~~~~~~~------___ +# . . ~~//====...... __--~ ~~ +# -. \_|// |||\\ ~~~~~~::::... /~ +# ___-==_ _-~o~ \/ ||| \\ _/~~- +# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ +# _-~~ .=~ | \\-_ '-~7 /- / || \ / +# .~ .~ | \\ -_ / /- / || \ / +# / ____ / | \\ ~-_/ /|- _/ .|| \ / +# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ +# ' ~-| /| |-~\~~ __--~~ +# |-~~-_/ | | ~\_ _-~ /\ +# / \ \__ \/~ \__ +# _--~ _/ | .-~~____--~-/ ~~==. +# ((->/~ '.|||' -_| ~~-/ , . _|| +# -_ ~\ ~~---l__i__i__i--~~_/ +# _-~-__ ~) \--______________--~~ +# //.-~~~-~_--~- |-------~~~~~~~~ +# //.-~~~--\ +# 神兽保佑 +# 永无BUG! +*/ +package com.fengdu.gas.repository.vo; + +import com.fengdu.gas.common.util.LocalDateTimeUtil; +import com.fengdu.gas.common.util.NumericUtil; +import com.fengdu.gas.entity.enums.EUserType; +import com.fengdu.gas.repository.po.AdminUserPO; +import lombok.Data; + +import java.util.Objects; + +/** + * 管理员帐号 + * @author lin.liu + * @description 管理员帐号 + */ +@Data +public class AdminUserVO extends AdminUserPO implements BasicVO { + + @Override + public String getCreateTimeView() { + if (NumericUtil.tryParseLong(this.getCreateTime()).compareTo(0L) > 0) { + return LocalDateTimeUtil.toFormatString(this.getCreateTime()); + } + return ""; + } + + @Override + public String getUpdateTimeView() { + if (Objects.isNull(this.getUpdateTime())) { + return ""; + } + return LocalDateTimeUtil.toFormatFullString(this.getUpdateTime()); + } + public String getUserTypeView() { + if (Objects.isNull(this.getUserType())) { + return ""; + } + return EUserType.getByValue(this.getUserType()).getDesc(); + } +} diff --git a/src/main/java/com/fengdu/gas/repository/vo/BasicVO.java b/src/main/java/com/fengdu/gas/repository/vo/BasicVO.java new file mode 100644 index 0000000..a865b41 --- /dev/null +++ b/src/main/java/com/fengdu/gas/repository/vo/BasicVO.java @@ -0,0 +1,13 @@ +package com.fengdu.gas.repository.vo; + + +public interface BasicVO { + /** + * 创建时间展示 + */ + String getCreateTimeView(); + /** + * 数据最后更新时间展示 + */ + String getUpdateTimeView(); +} diff --git a/src/main/java/com/fengdu/gas/repository/vo/NoticeVO.java b/src/main/java/com/fengdu/gas/repository/vo/NoticeVO.java new file mode 100644 index 0000000..9561f85 --- /dev/null +++ b/src/main/java/com/fengdu/gas/repository/vo/NoticeVO.java @@ -0,0 +1,55 @@ +/** +# __----~~~~~~~~~~~------___ +# . . ~~//====...... __--~ ~~ +# -. \_|// |||\\ ~~~~~~::::... /~ +# ___-==_ _-~o~ \/ ||| \\ _/~~- +# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ +# _-~~ .=~ | \\-_ '-~7 /- / || \ / +# .~ .~ | \\ -_ / /- / || \ / +# / ____ / | \\ ~-_/ /|- _/ .|| \ / +# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ +# ' ~-| /| |-~\~~ __--~~ +# |-~~-_/ | | ~\_ _-~ /\ +# / \ \__ \/~ \__ +# _--~ _/ | .-~~____--~-/ ~~==. +# ((->/~ '.|||' -_| ~~-/ , . _|| +# -_ ~\ ~~---l__i__i__i--~~_/ +# _-~-__ ~) \--______________--~~ +# //.-~~~-~_--~- |-------~~~~~~~~ +# //.-~~~--\ +# 神兽保佑 +# 永无BUG! +*/ +package com.fengdu.gas.repository.vo; + +import com.fengdu.gas.common.util.LocalDateTimeUtil; +import com.fengdu.gas.common.util.NumericUtil; +import com.fengdu.gas.repository.bo.NoticeBO; +import lombok.Data; + +import java.util.Objects; + +/** + * 公告 + * @author lin.liu + * @description 公告 + */ +@Data +public class NoticeVO extends NoticeBO implements BasicVO { + + @Override + public String getCreateTimeView() { + if (NumericUtil.tryParseLong(this.getCreateTime()).compareTo(0L) > 0) { + return LocalDateTimeUtil.toFormatString(this.getCreateTime()); + } + return ""; + } + + @Override + public String getUpdateTimeView() { + if (Objects.isNull(this.getUpdateTime())) { + return ""; + } + return LocalDateTimeUtil.toFormatFullString(this.getUpdateTime()); + } +} diff --git a/src/main/java/com/fengdu/gas/repository/vo/QuartzTaskErrorVO.java b/src/main/java/com/fengdu/gas/repository/vo/QuartzTaskErrorVO.java new file mode 100644 index 0000000..5c647b6 --- /dev/null +++ b/src/main/java/com/fengdu/gas/repository/vo/QuartzTaskErrorVO.java @@ -0,0 +1,55 @@ +/** +# __----~~~~~~~~~~~------___ +# . . ~~//====...... __--~ ~~ +# -. \_|// |||\\ ~~~~~~::::... /~ +# ___-==_ _-~o~ \/ ||| \\ _/~~- +# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ +# _-~~ .=~ | \\-_ '-~7 /- / || \ / +# .~ .~ | \\ -_ / /- / || \ / +# / ____ / | \\ ~-_/ /|- _/ .|| \ / +# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ +# ' ~-| /| |-~\~~ __--~~ +# |-~~-_/ | | ~\_ _-~ /\ +# / \ \__ \/~ \__ +# _--~ _/ | .-~~____--~-/ ~~==. +# ((->/~ '.|||' -_| ~~-/ , . _|| +# -_ ~\ ~~---l__i__i__i--~~_/ +# _-~-__ ~) \--______________--~~ +# //.-~~~-~_--~- |-------~~~~~~~~ +# //.-~~~--\ +# 神兽保佑 +# 永无BUG! +*/ +package com.fengdu.gas.repository.vo; + +import com.fengdu.gas.common.util.LocalDateTimeUtil; +import com.fengdu.gas.common.util.NumericUtil; +import com.fengdu.gas.repository.po.QuartzTaskErrorPO; +import lombok.Data; + +import java.util.Objects; + +/** + * 定时任务错误信息 + * @author lin.liu + * @description 定时任务错误信息 + */ +@Data +public class QuartzTaskErrorVO extends QuartzTaskErrorPO implements BasicVO { + + @Override + public String getCreateTimeView() { + if (NumericUtil.tryParseLong(this.getCreateTime()).compareTo(0L) > 0) { + return LocalDateTimeUtil.toFormatString(this.getCreateTime()); + } + return ""; + } + + @Override + public String getUpdateTimeView() { + if (Objects.isNull(this.getUpdateTime())) { + return ""; + } + return LocalDateTimeUtil.toFormatFullString(this.getUpdateTime()); + } +} diff --git a/src/main/java/com/fengdu/gas/repository/vo/QuartzTaskInfoVO.java b/src/main/java/com/fengdu/gas/repository/vo/QuartzTaskInfoVO.java new file mode 100644 index 0000000..7aa719b --- /dev/null +++ b/src/main/java/com/fengdu/gas/repository/vo/QuartzTaskInfoVO.java @@ -0,0 +1,55 @@ +/** +# __----~~~~~~~~~~~------___ +# . . ~~//====...... __--~ ~~ +# -. \_|// |||\\ ~~~~~~::::... /~ +# ___-==_ _-~o~ \/ ||| \\ _/~~- +# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ +# _-~~ .=~ | \\-_ '-~7 /- / || \ / +# .~ .~ | \\ -_ / /- / || \ / +# / ____ / | \\ ~-_/ /|- _/ .|| \ / +# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ +# ' ~-| /| |-~\~~ __--~~ +# |-~~-_/ | | ~\_ _-~ /\ +# / \ \__ \/~ \__ +# _--~ _/ | .-~~____--~-/ ~~==. +# ((->/~ '.|||' -_| ~~-/ , . _|| +# -_ ~\ ~~---l__i__i__i--~~_/ +# _-~-__ ~) \--______________--~~ +# //.-~~~-~_--~- |-------~~~~~~~~ +# //.-~~~--\ +# 神兽保佑 +# 永无BUG! +*/ +package com.fengdu.gas.repository.vo; + +import com.fengdu.gas.common.util.LocalDateTimeUtil; +import com.fengdu.gas.common.util.NumericUtil; +import com.fengdu.gas.repository.po.QuartzTaskInfoPO; +import lombok.Data; + +import java.util.Objects; + +/** + * 定时任务信息 + * @author lin.liu + * @description 定时任务信息 + */ +@Data +public class QuartzTaskInfoVO extends QuartzTaskInfoPO implements BasicVO { + + @Override + public String getCreateTimeView() { + if (NumericUtil.tryParseLong(this.getCreateTime()).compareTo(0L) > 0) { + return LocalDateTimeUtil.toFormatString(this.getCreateTime()); + } + return ""; + } + + @Override + public String getUpdateTimeView() { + if (Objects.isNull(this.getUpdateTime())) { + return ""; + } + return LocalDateTimeUtil.toFormatFullString(this.getUpdateTime()); + } +} diff --git a/src/main/java/com/fengdu/gas/repository/vo/QuartzTaskRecordVO.java b/src/main/java/com/fengdu/gas/repository/vo/QuartzTaskRecordVO.java new file mode 100644 index 0000000..9a9907b --- /dev/null +++ b/src/main/java/com/fengdu/gas/repository/vo/QuartzTaskRecordVO.java @@ -0,0 +1,62 @@ +/** +# __----~~~~~~~~~~~------___ +# . . ~~//====...... __--~ ~~ +# -. \_|// |||\\ ~~~~~~::::... /~ +# ___-==_ _-~o~ \/ ||| \\ _/~~- +# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ +# _-~~ .=~ | \\-_ '-~7 /- / || \ / +# .~ .~ | \\ -_ / /- / || \ / +# / ____ / | \\ ~-_/ /|- _/ .|| \ / +# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ +# ' ~-| /| |-~\~~ __--~~ +# |-~~-_/ | | ~\_ _-~ /\ +# / \ \__ \/~ \__ +# _--~ _/ | .-~~____--~-/ ~~==. +# ((->/~ '.|||' -_| ~~-/ , . _|| +# -_ ~\ ~~---l__i__i__i--~~_/ +# _-~-__ ~) \--______________--~~ +# //.-~~~-~_--~- |-------~~~~~~~~ +# //.-~~~--\ +# 神兽保佑 +# 永无BUG! +*/ +package com.fengdu.gas.repository.vo; + +import com.fengdu.gas.common.util.LocalDateTimeUtil; +import com.fengdu.gas.common.util.NumericUtil; +import com.fengdu.gas.repository.po.QuartzTaskRecordPO; +import lombok.Data; + +import java.util.Objects; + +/** + * 定时任务执行记录 + * @author lin.liu + * @description 定时任务执行记录 + */ +@Data +public class QuartzTaskRecordVO extends QuartzTaskRecordPO implements BasicVO { + + @Override + public String getCreateTimeView() { + if (NumericUtil.tryParseLong(this.getCreateTime()).compareTo(0L) > 0) { + return LocalDateTimeUtil.toFormatString(this.getCreateTime()); + } + return ""; + } + + @Override + public String getUpdateTimeView() { + if (Objects.isNull(this.getUpdateTime())) { + return ""; + } + return LocalDateTimeUtil.toFormatFullString(this.getUpdateTime()); + } + + public String getStartTimeView() { + if (NumericUtil.tryParseLong(this.getStartTime()).compareTo(0L) > 0) { + return LocalDateTimeUtil.toFormatString(this.getStartTime()); + } + return ""; + } +} diff --git a/src/main/java/com/fengdu/gas/repository/vo/SysDictDataVO.java b/src/main/java/com/fengdu/gas/repository/vo/SysDictDataVO.java new file mode 100644 index 0000000..4b589d4 --- /dev/null +++ b/src/main/java/com/fengdu/gas/repository/vo/SysDictDataVO.java @@ -0,0 +1,60 @@ +/** +# __----~~~~~~~~~~~------___ +# . . ~~//====...... __--~ ~~ +# -. \_|// |||\\ ~~~~~~::::... /~ +# ___-==_ _-~o~ \/ ||| \\ _/~~- +# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ +# _-~~ .=~ | \\-_ '-~7 /- / || \ / +# .~ .~ | \\ -_ / /- / || \ / +# / ____ / | \\ ~-_/ /|- _/ .|| \ / +# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ +# ' ~-| /| |-~\~~ __--~~ +# |-~~-_/ | | ~\_ _-~ /\ +# / \ \__ \/~ \__ +# _--~ _/ | .-~~____--~-/ ~~==. +# ((->/~ '.|||' -_| ~~-/ , . _|| +# -_ ~\ ~~---l__i__i__i--~~_/ +# _-~-__ ~) \--______________--~~ +# //.-~~~-~_--~- |-------~~~~~~~~ +# //.-~~~--\ +# 神兽保佑 +# 永无BUG! +*/ +package com.fengdu.gas.repository.vo; + +import com.fengdu.gas.common.util.LocalDateTimeUtil; +import com.fengdu.gas.common.util.NumericUtil; +import com.fengdu.gas.repository.po.SysDictDataPO; +import lombok.Data; + +import java.util.Objects; + +/** + * 字典数据表 + * @author lin.liu + * @description 字典数据表 + */ +@Data +public class SysDictDataVO extends SysDictDataPO implements BasicVO { + + @Override + public String getCreateTimeView() { + if (NumericUtil.tryParseLong(this.getCreateTime()).compareTo(0L) > 0) { + return LocalDateTimeUtil.toFormatString(this.getCreateTime()); + } + return ""; + } + + @Override + public String getUpdateTimeView() { + if (Objects.isNull(this.getUpdateTime())) { + return ""; + } + return LocalDateTimeUtil.toFormatFullString(this.getUpdateTime()); + } + + /** + * 字典类型名称 + */ + public String dictTypeTxt; +} diff --git a/src/main/java/com/fengdu/gas/repository/vo/SysDictTypeVO.java b/src/main/java/com/fengdu/gas/repository/vo/SysDictTypeVO.java new file mode 100644 index 0000000..d7bfcb8 --- /dev/null +++ b/src/main/java/com/fengdu/gas/repository/vo/SysDictTypeVO.java @@ -0,0 +1,55 @@ +/** +# __----~~~~~~~~~~~------___ +# . . ~~//====...... __--~ ~~ +# -. \_|// |||\\ ~~~~~~::::... /~ +# ___-==_ _-~o~ \/ ||| \\ _/~~- +# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ +# _-~~ .=~ | \\-_ '-~7 /- / || \ / +# .~ .~ | \\ -_ / /- / || \ / +# / ____ / | \\ ~-_/ /|- _/ .|| \ / +# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ +# ' ~-| /| |-~\~~ __--~~ +# |-~~-_/ | | ~\_ _-~ /\ +# / \ \__ \/~ \__ +# _--~ _/ | .-~~____--~-/ ~~==. +# ((->/~ '.|||' -_| ~~-/ , . _|| +# -_ ~\ ~~---l__i__i__i--~~_/ +# _-~-__ ~) \--______________--~~ +# //.-~~~-~_--~- |-------~~~~~~~~ +# //.-~~~--\ +# 神兽保佑 +# 永无BUG! +*/ +package com.fengdu.gas.repository.vo; + +import com.fengdu.gas.common.util.LocalDateTimeUtil; +import com.fengdu.gas.common.util.NumericUtil; +import com.fengdu.gas.repository.po.SysDictTypePO; +import lombok.Data; + +import java.util.Objects; + +/** + * 字典类型表 + * @author lin.liu + * @description 字典类型表 + */ +@Data +public class SysDictTypeVO extends SysDictTypePO implements BasicVO { + + @Override + public String getCreateTimeView() { + if (NumericUtil.tryParseLong(this.getCreateTime()).compareTo(0L) > 0) { + return LocalDateTimeUtil.toFormatString(this.getCreateTime()); + } + return ""; + } + + @Override + public String getUpdateTimeView() { + if (Objects.isNull(this.getUpdateTime())) { + return ""; + } + return LocalDateTimeUtil.toFormatFullString(this.getUpdateTime()); + } +} diff --git a/src/main/java/com/fengdu/gas/repository/vo/TestInfoVO.java b/src/main/java/com/fengdu/gas/repository/vo/TestInfoVO.java new file mode 100644 index 0000000..928ec35 --- /dev/null +++ b/src/main/java/com/fengdu/gas/repository/vo/TestInfoVO.java @@ -0,0 +1,25 @@ +package com.fengdu.gas.repository.vo; + +import com.fengdu.gas.common.util.LocalDateTimeUtil; +import com.fengdu.gas.common.util.NumericUtil; +import com.fengdu.gas.repository.po.TestInfoPO; + +import java.util.Objects; + +public class TestInfoVO extends TestInfoPO implements BasicVO { + @Override + public String getCreateTimeView() { + if (NumericUtil.tryParseLong(this.getCreateTime()).compareTo(0L) > 0) { + return LocalDateTimeUtil.toFormatString(this.getCreateTime()); + } + return ""; + } + + @Override + public String getUpdateTimeView() { + if (Objects.isNull(this.getUpdateTime())) { + return ""; + } + return LocalDateTimeUtil.toFormatFullString(this.getUpdateTime()); + } +} diff --git a/src/main/java/com/fengdu/gas/service/AdminMenuService.java b/src/main/java/com/fengdu/gas/service/AdminMenuService.java new file mode 100644 index 0000000..1c805b1 --- /dev/null +++ b/src/main/java/com/fengdu/gas/service/AdminMenuService.java @@ -0,0 +1,49 @@ +package com.fengdu.gas.service; + +import com.fengdu.gas.repository.po.AdminMenuPO; +import com.fengdu.gas.repository.impl.AdminMenuMapperImpl; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cache.annotation.CacheEvict; +import org.springframework.cache.annotation.Cacheable; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.function.Function; + +@Service +public class AdminMenuService { + @Autowired + private AdminMenuMapperImpl dao; + + /** + * 获取所有菜单(缓存) + */ + //@Cacheable(cacheManager = "json4RedisCacheManager",value = "userCache", key = "#id") + //@Cacheable(cacheManager = "json4RedisCacheManager",value = "userCache", key = "#user.id") + @Cacheable(cacheManager = "json4RedisCacheManager", value = "adminMenusCache") + public List<AdminMenuPO> listAllWithCache() { + return dao.getList(); + } + + // 删除菜单缓存 + @CacheEvict(cacheNames = "adminMenusCache", allEntries = true) + public void removeListAllCache() { + } + + + /** + * 获取用户拥有的菜单(缓存) + */ + @Cacheable(cacheManager = "json4RedisCacheManager", value = "userMenusCache", key = "#id") + public List<AdminMenuPO> listUserAllWithCache(Long id, List<Long> listRoleId, Function<List<Long>, List<AdminMenuPO>> funcGetUserMenu) { + return funcGetUserMenu.apply(listRoleId); + } + // 删除指定用户拥有的菜单缓存 + @CacheEvict(cacheNames = "userMenusCache", key = "#id") + public void removeUserMenuCache(Long id) { + } + // 删除所有用户拥有的菜单缓存 + @CacheEvict(cacheNames = "userMenusCache", allEntries = true) + public void removeAllUserMenuCache() { + } +} diff --git a/src/main/java/com/fengdu/gas/service/AdminPermissionService.java b/src/main/java/com/fengdu/gas/service/AdminPermissionService.java new file mode 100644 index 0000000..a124725 --- /dev/null +++ b/src/main/java/com/fengdu/gas/service/AdminPermissionService.java @@ -0,0 +1,118 @@ +package com.fengdu.gas.service; + +import com.fengdu.gas.repository.po.AdminMenuPO; +import com.fengdu.gas.repository.po.AdminPermissionPO; +import com.fengdu.gas.common.enums.EYesOrNo; +import com.fengdu.gas.common.util.LocalDateTimeUtil; +import com.fengdu.gas.entity.enums.EMenuType; +import com.fengdu.gas.entity.enums.EOperation; +import com.fengdu.gas.entity.enums.EState; +import com.fengdu.gas.repository.impl.AdminPermissionMapperImpl; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cache.annotation.CacheEvict; +import org.springframework.cache.annotation.Cacheable; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.function.Function; + +@Service +public class AdminPermissionService { + @Autowired + private AdminPermissionMapperImpl dao; + + /** + * 获取所有权限(缓存) + */ + //@Cacheable(cacheManager = "json4RedisCacheManager",value = "userCache", key = "#id") + //@Cacheable(cacheManager = "json4RedisCacheManager",value = "userCache", key = "#user.id") + @Cacheable(cacheManager = "json4RedisCacheManager", value = "adminPermissionCache") + public List<AdminPermissionPO> listAllWithCache() { + return dao.getList(); + } + + // 删除权限缓存 + @CacheEvict(cacheNames = "adminPermissionCache", allEntries = true) + public void removeListAllCache() { + } + + /** + * 获取用户拥有的权限(缓存) + */ + @Cacheable(cacheManager = "json4RedisCacheManager", value = "userPermissionCache", key = "#id") + public List<AdminPermissionPO> listUserAllWithCache(Long id, List<Long> listRoleId, Function<List<Long>, List<AdminPermissionPO>> funcGetUserPermission) { + return funcGetUserPermission.apply(listRoleId); + } + // 删除指定用户拥有的权限缓存 + @CacheEvict(cacheNames = "userPermissionCache", key = "#id") + public void removeUserCache(Long id) { + } + // 删除所有用户拥有的权限缓存 + @CacheEvict(cacheNames = "userPermissionCache", allEntries = true) + public void removeAllUserCache() { + } + + /** + * 给菜单添加默认权限 + * @param menu 菜单信息 + */ + public void createDefaultPermission(AdminMenuPO menu) { + if (!Objects.equals(menu.getType(), EMenuType.PAGE.getValue())) { + return; + } + Long now = LocalDateTimeUtil.nowTimeStamp(); + List<AdminPermissionPO> list = new ArrayList<>(); + + AdminPermissionPO item1 = new AdminPermissionPO(); + item1.setSn(menu.getUrl().replaceAll("/", "") + "." + EOperation.LIST.getValue()); + item1.setMenuId(menu.getId()); + item1.setMenuUrl(menu.getUrl()); + item1.setName(menu.getName() + "." + EOperation.LIST.getDesc()); + item1.setIcon(""); + item1.setType(EOperation.LIST.getValue()); + item1.setStatus(EState.NORMAL.getValue()); + item1.setCreateTime(now); + item1.setIsDelete(EYesOrNo.NO.getValue()); + list.add(item1); + + AdminPermissionPO item2 = new AdminPermissionPO(); + item2.setSn(menu.getUrl().replaceAll("/", "") + "." + EOperation.ADD.getValue()); + item2.setMenuId(menu.getId()); + item2.setMenuUrl(menu.getUrl()); + item2.setName(menu.getName() + "." + EOperation.ADD.getDesc()); + item2.setIcon(""); + item2.setType(EOperation.ADD.getValue()); + item2.setStatus(EState.NORMAL.getValue()); + item2.setCreateTime(now); + item2.setIsDelete(EYesOrNo.NO.getValue()); + list.add(item2); + + AdminPermissionPO item3 = new AdminPermissionPO(); + item3.setSn(menu.getUrl().replaceAll("/", "") + "." + EOperation.UPDATE.getValue()); + item3.setMenuId(menu.getId()); + item3.setMenuUrl(menu.getUrl()); + item3.setName(menu.getName() + "." + EOperation.UPDATE.getDesc()); + item3.setIcon(""); + item3.setType(EOperation.UPDATE.getValue()); + item3.setStatus(EState.NORMAL.getValue()); + item3.setCreateTime(now); + item3.setIsDelete(EYesOrNo.NO.getValue()); + list.add(item3); + + AdminPermissionPO item4 = new AdminPermissionPO(); + item4.setSn(menu.getUrl().replaceAll("/", "") + "." + EOperation.DETAIL.getValue()); + item4.setMenuId(menu.getId()); + item4.setMenuUrl(menu.getUrl()); + item4.setName(menu.getName() + "." + EOperation.DETAIL.getDesc()); + item4.setIcon(""); + item4.setType(EOperation.DETAIL.getValue()); + item4.setStatus(EState.NORMAL.getValue()); + item4.setCreateTime(now); + item4.setIsDelete(EYesOrNo.NO.getValue()); + list.add(item4); + + dao.insert(list); + } +} diff --git a/src/main/java/com/fengdu/gas/service/AdminPowerService.java b/src/main/java/com/fengdu/gas/service/AdminPowerService.java new file mode 100644 index 0000000..e43235e --- /dev/null +++ b/src/main/java/com/fengdu/gas/service/AdminPowerService.java @@ -0,0 +1,867 @@ +package com.fengdu.gas.service; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.fengdu.gas.service.convert.AdminMenuConvert; +import com.fengdu.gas.service.convert.AdminPermissionConvert; +import com.fengdu.gas.service.convert.AdminRoleConvert; +import com.fengdu.gas.common.ExecutedResult; +import com.fengdu.gas.common.PagerResult; +import com.fengdu.gas.common.model.Tuple; +import com.fengdu.gas.common.util.*; +import com.fengdu.gas.entity.enums.EState; +import com.fengdu.gas.entity.request.ReqListSetSort; +import com.fengdu.gas.entity.request.ReqSetSort; +import com.fengdu.gas.entity.request.adminmenu.ReqCreateAdminMenu; +import com.fengdu.gas.entity.request.adminmenu.ReqModifyAdminMenu; +import com.fengdu.gas.entity.request.adminpermission.ReqCreateAdminPermission; +import com.fengdu.gas.entity.request.adminpermission.ReqModifyAdminPermission; +import com.fengdu.gas.entity.request.adminrole.ReqCreateAdminRole; +import com.fengdu.gas.entity.request.adminrole.ReqModifyAdminRole; +import com.fengdu.gas.entity.request.adminrolemenurelation.ReqSetListMenu4Role; +import com.fengdu.gas.entity.response.admin.ResAdminMenuTreeAndPermission; +import com.fengdu.gas.entity.response.admin.ResAdminPermission; +import com.fengdu.gas.entity.response.admin.ResAdminPower; +import com.fengdu.gas.entity.search.SearchAdminMenu; +import com.fengdu.gas.entity.search.SearchAdminPermission; +import com.fengdu.gas.entity.search.SearchAdminRole; +import com.fengdu.gas.repository.impl.*; +import com.fengdu.gas.repository.po.*; +import com.fengdu.gas.repository.vo.AdminMenuVO; +import com.fengdu.gas.repository.vo.AdminRoleVO; +import org.apache.commons.lang3.BooleanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.*; +import java.util.stream.Collectors; + +@Service +public class AdminPowerService extends BaseService { + @Autowired + private AdminMenuMapperImpl menusDao; + @Autowired + private AdminPermissionMapperImpl permissionDao; + @Autowired + private AdminRoleMapperImpl roleDao; + @Autowired + private AdminRoleMenuRelationMapperImpl roleMenuRelationDao; + @Autowired + private AdminRolePermissionRelationMapperImpl rolePermissionRelationDao; + @Autowired + private AdminRoleRelationMapperImpl adminRoleRelationDao; + + @Autowired + private AdminMenuService menusService; + @Autowired + private AdminPermissionService permissionService; + + + + // 创建菜单 + public ExecutedResult<Long> createMenu(ReqCreateAdminMenu request) { + AdminMenuPO item = AdminMenuConvert.INSTANCE.toCreate(request); + item.setParentId(NumericUtil.tryParseLong(request.getParentId(), 0L)); + item.setTitle(ParameterUtil.dealNullStr(request.getTitle())); + item.setLevel(1); + item.setSort(NumericUtil.tryParseInt(request.getSort(), 0)); + item.setStatus(EState.NORMAL.getValue()); + item.setCreateTime(LocalDateTimeUtil.nowTimeStamp()); + if (item.getParentId().compareTo(0L) > 0) { + ExecutedResult<AdminMenuPO> check = this.checkMenuId(request.getParentId()); + if (check.isFailed()) { + return ExecutedResult.failed("父级菜单不存在: " + request.getParentId()); + } + item.setLevel(check.getData().getLevel() + 1); + } + int rowCount = menusDao.insert(item); + if (rowCount == 1) { + // 删除菜单缓存 + menusService.removeListAllCache(); + // 删除所有权限缓存 + permissionService.removeListAllCache(); + // 删除所有用户的菜单和权限缓存 + this.removePowerAllUser(); + + // 给新增的菜单添加默认权限 + permissionService.createDefaultPermission(item); + return ExecutedResult.success(item.getId()); + } + return ExecutedResult.failed("创建[菜单]失败。"); + } + private ExecutedResult<AdminMenuPO> checkMenuId(Long id) { + AdminMenuPO item = menusDao.get(id); + if (Objects.isNull(item)) { + return ExecutedResult.failed("[菜单]不存在: " + id); + } + return ExecutedResult.success(item); + } + protected ExecutedResult<List<AdminMenuPO>> checkMenuId(List<Long> listId) { + // 从数据库查找测试信息 + List<AdminMenuPO> list = menusDao.getList(listId); + if (ListUtil.isNullOrEmpty(list)) { + return ExecutedResult.failed("[菜单]不存在." + listId); + } + // 数据库找到的id列表 + List<Long> listIdFind = list.stream().map(AdminMenuPO::getId).collect(Collectors.toList()); + // 数量不一致 + if (listId.size() != listIdFind.size()) { + // 筛选数据库不存在的测试信息 + List<Long> listIdNotFound = listId.stream().filter(c -> !listIdFind.contains(c)).collect(Collectors.toList()); + if (ListUtil.isNullOrEmpty(list)) { + return ExecutedResult.failed("[菜单]不存在." + listIdNotFound); + } + } + return ExecutedResult.success(list); + } + + // 编辑菜单 + public ExecutedResult<String> modifyMenu(ReqModifyAdminMenu request) { + ExecutedResult<AdminMenuPO> checkExists = this.checkMenuId(request.getId()); + if (checkExists.isFailed()) { + return ExecutedResult.failed(checkExists.getMsg()); + } + AdminMenuPO item = AdminMenuConvert.INSTANCE.toModify(request); + item.setTitle(ParameterUtil.dealNullStr(request.getTitle())); + item.setParentId(NumericUtil.tryParseLong(request.getParentId(), 0L)); + item.setLevel(1); + item.setSort(NumericUtil.tryParseInt(request.getSort(), 0)); + if (item.getParentId().compareTo(0L) > 0) { + ExecutedResult<AdminMenuPO> check = this.checkMenuId(request.getParentId()); + if (check.isFailed()) { + return ExecutedResult.failed("父级菜单不存在: " + request.getParentId()); + } + item.setLevel(check.getData().getLevel() + 1); + } + int rowCount = menusDao.updateById(item); + if (rowCount == 1) { + // 删除菜单缓存 + menusService.removeListAllCache(); + // 删除所有权限缓存 + permissionService.removeListAllCache(); + // 删除所有用户的菜单和权限缓存 + this.removePowerAllUser(); + return ExecutedResult.success(); + } + return ExecutedResult.failed("编辑[菜单]失败。"); + } + + public ExecutedResult<String> removeMenu(Long id) { + // 验证记录是否存在 + ExecutedResult<AdminMenuPO> checkExists = this.checkMenuId(id); + if (checkExists.isFailed()) { + return ExecutedResult.failed(checkExists.getMsg()); + } + + Boolean result = menusDao.deleteLogic(id); + if (result) { + // 删除菜单缓存 + menusService.removeListAllCache(); + // 删除所有权限缓存 + permissionService.removeListAllCache(); + // 删除所有用户的菜单和权限缓存 + this.removePowerAllUser(); + return ExecutedResult.success(); + } + return ExecutedResult.failed("删除[菜单]失败。"); + } + + public ExecutedResult<String> removeMenuList(List<Long> listId) { + // 验证记录是否存在 + ExecutedResult<List<AdminMenuPO>> checkExists = this.checkMenuId(listId); + if (checkExists.isFailed()) { + return ExecutedResult.failed(checkExists.getMsg()); + } + + Boolean result = menusDao.deleteLogic(listId); + if (result) { + // 删除菜单缓存 + menusService.removeListAllCache(); + // 删除所有权限缓存 + permissionService.removeListAllCache(); + // 删除所有用户的菜单和权限缓存 + this.removePowerAllUser(); + return ExecutedResult.success(); + } + return ExecutedResult.failed("删除[菜单]失败。"); + } + + // 变更菜单状态 + public ExecutedResult<String> changeMenuStatus(Long id, EState status) { + ExecutedResult<AdminMenuPO> checkExists = this.checkMenuId(id); + if (checkExists.isFailed()) { + return ExecutedResult.failed(checkExists.getMsg()); + } + AdminMenuPO upd = new AdminMenuPO(); + upd.setId(id); + upd.setStatus(status.getValue()); + int rowCount = menusDao.updateById(upd); + if (rowCount == 1) { + // 删除菜单缓存 + menusService.removeListAllCache(); + // 删除所有权限缓存 + permissionService.removeListAllCache(); + // 删除所有用户的菜单和权限缓存 + this.removePowerAllUser(); + return ExecutedResult.success(); + } + return ExecutedResult.failed("修改[菜单]状态失败。"); + } + + // 获取所有层级菜单 + public ExecutedResult<List<ResAdminMenuTreeAndPermission>> getListTreeMenu() { + List<ResAdminMenuTreeAndPermission> result = new ArrayList<>(); + LambdaQueryWrapper<AdminMenuPO> where = menusDao.query(); + where.in(AdminMenuPO::getStatus, Arrays.asList( + EState.NORMAL.getValue() + )); + List<AdminMenuPO> list = menusDao.selectList(where); + + if (ListUtil.isNullOrEmpty(list)) { + return ExecutedResult.success(result); + } + List<AdminMenuPO> listRoot = list.stream().filter(c -> Objects.equals(c.getLevel(), 1)).collect(Collectors.toList()); + listRoot = listRoot.stream() + .sorted(Comparator.comparing(AdminMenuPO::getSort)) + .collect(Collectors.toList()); + if (ListUtil.isNullOrEmpty(listRoot)) { + return ExecutedResult.success(result); + } + + List<Long> listMenuId = list.stream() + .map(AdminMenuPO::getId) + .collect(Collectors.toList()); + List<AdminPermissionPO> listPermission = permissionDao.list4MenuId(listMenuId); + Map<Long, List<AdminPermissionPO>> mapPermission = listPermission.stream() + .collect(Collectors.groupingBy(AdminPermissionPO::getMenuId)); + + for (AdminMenuPO item : listRoot) { + ResAdminMenuTreeAndPermission view = AdminMenuConvert.INSTANCE.toTreeVo(item); + this.fillChildMenu(view, list, mapPermission); + this.fillPermission4Menu(view, mapPermission); + result.add(view); + } + return ExecutedResult.success(result); + } + public void fillPermission4Menu(ResAdminMenuTreeAndPermission view, Map<Long, List<AdminPermissionPO>> mapPermission) { + view.setPermissions(new ArrayList<>()); + if (BooleanUtils.isFalse(mapPermission.containsKey(view.getId()))) { + return; + } + List<AdminPermissionPO> list = mapPermission.get(view.getId()); + view.setPermissions(AdminPermissionConvert.INSTANCE.toDetail(list)); + } + public void fillChildMenu(ResAdminMenuTreeAndPermission view, List<AdminMenuPO> list, Map<Long, List<AdminPermissionPO>> mapPermission) { + List<AdminMenuPO> listChild = list.stream() + .filter(c -> c.getParentId().equals(view.getId())) + .collect(Collectors.toList()); + view.setChildren(new ArrayList<>()); + if (ListUtil.isNullOrEmpty(listChild)) { + return; + } + listChild = listChild.stream() + .sorted(Comparator.comparing(AdminMenuPO::getSort)) + .collect(Collectors.toList()); + for (AdminMenuPO child : listChild) { + ResAdminMenuTreeAndPermission viewChild = AdminMenuConvert.INSTANCE.toTreeVo(child); + this.fillChildMenu(viewChild, list, mapPermission); + this.fillPermission4Menu(viewChild, mapPermission); + view.getChildren().add(viewChild); + } + } + + // 获取指定菜单的子级菜单 + public ExecutedResult<List<AdminMenuVO>> getListChildMenu(Long parentId) { + List<AdminMenuPO> list = menusDao.list4Parent(parentId); + if (ListUtil.isNullOrEmpty(list)) { + return ExecutedResult.success(new ArrayList<>()); + } + return ExecutedResult.success(AdminMenuConvert.INSTANCE.toVo(list)); + } + + // 分页查询菜单 + public ExecutedResult<PagerResult<AdminMenuVO>> searchMenu(SearchAdminMenu request) { + List<AdminMenuVO> result = new ArrayList<>(); + + super.dealPager(request); + request.setLastRowNo((request.getPage() - 1) * NumericUtil.tryParseLong(request.getLimit())); + // 处理时间范围 + Tuple<String, String> createTimeRange = ParameterUtil.getTimeRange(request.getCreateTimeRange()); + if (StringUtil.isNotNullOrEmpty(createTimeRange.getItem1())) { + request.setCreateTimeStart(LocalDateTimeUtil.getTimeStamp(createTimeRange.getItem1()).getTime()); + } + if (StringUtil.isNotNullOrEmpty(createTimeRange.getItem2())) { + request.setCreateTimeEnd(LocalDateTimeUtil.getTimeStamp(createTimeRange.getItem2()).getTime()); + } + if (NumericUtil.tryParseInt(request.getStatus(), 0).compareTo(0) < 1 && ListUtil.isNullOrEmpty(request.getListStatus())) { + request.setListStatus(Arrays.asList(EState.NORMAL.getValue(), EState.DISABLED.getValue())); + } + + PagerResult<AdminMenuPO> pagerResult = menusDao.search(request); + + if (NumericUtil.tryParseLong(pagerResult.getTotal()).compareTo(0L) < 1) { + return ExecutedResult.success( + new PagerResult<>(request.getLimit(), request.getPage(), 0L, new ArrayList<>()) + ); + } + List<AdminMenuPO> list = pagerResult.getList(); + Long lastId = 0L; + if (ListUtil.isNotNullOrEmpty(list)) { + lastId = list.stream().map(AdminMenuPO::getId).min(Comparator.comparing(c -> c)).get(); + result = AdminMenuConvert.INSTANCE.toVo(list); + } + PagerResult<AdminMenuVO> view = new PagerResult<>(request.getLimit(), request.getPage(), pagerResult.getTotal(), result); + view.setLastId(lastId); + return ExecutedResult.success(view); + } + + // 创建权限 + public ExecutedResult<Long> createPermission(ReqCreateAdminPermission request) { + String sn = request.getSn(); + AdminPermissionPO find = permissionDao.get4Sn(sn); + if (Objects.nonNull(find) && find.getId().compareTo(0L) > 0) { + return ExecutedResult.failed("权限编码已存在。" + sn); + } + ExecutedResult<AdminMenuPO> checkExists = this.checkMenuId(request.getMenuId()); + if (checkExists.isFailed()) { + return ExecutedResult.failed(checkExists.getMsg()); + } + + AdminPermissionPO item = new AdminPermissionPO(); + item.setName(request.getName()); + item.setSn(request.getSn()); + item.setMenuId(request.getMenuId()); + item.setMenuId(request.getMenuId()); + item.setStatus(EState.NORMAL.getValue()); + item.setMenuUrl(ParameterUtil.dealNullStr(request.getMenuUrl())); + item.setIcon(ParameterUtil.dealNullStr(request.getIcon())); + item.setType(ParameterUtil.dealNullStr(request.getType())); + item.setCreateTime(LocalDateTimeUtil.nowTimeStamp()); + int rowCount = permissionDao.insert(item); + if (rowCount == 1) { + // 删除权限缓存 + permissionService.removeListAllCache(); + return ExecutedResult.success(item.getId()); + } + return ExecutedResult.failed("创建[权限]失败。"); + } + + // 编辑权限 + public ExecutedResult<String> modifyPermission(ReqModifyAdminPermission request) { + Long id = request.getId(); + String sn = request.getSn(); + ExecutedResult<AdminPermissionPO> checkExists = this.checkPermissionId(id); + if (checkExists.isFailed()) { + return ExecutedResult.failed(checkExists.getMsg()); + } + AdminPermissionPO findBySn = permissionDao.get4Sn(sn); + if (Objects.nonNull(findBySn) && !Objects.equals(id, findBySn.getId())) { + return ExecutedResult.failed("权限编码已存在。" + sn); + } + ExecutedResult<AdminMenuPO> check = this.checkMenuId(request.getMenuId()); + if (check.isFailed()) { + return ExecutedResult.failed(check.getMsg()); + } + + AdminPermissionPO item = new AdminPermissionPO(); + item.setId(id); + item.setSn(request.getSn()); + item.setMenuId(request.getMenuId()); + item.setName(request.getName()); + int rowCount = permissionDao.updateById(item); + if (rowCount == 1) { + // 删除权限缓存 + permissionService.removeListAllCache(); + return ExecutedResult.success(); + } + return ExecutedResult.failed("编辑[权限]失败。"); + } + private ExecutedResult<AdminPermissionPO> checkPermissionId(Long id) { + AdminPermissionPO item = permissionDao.get(id); + if (Objects.isNull(item)) { + return ExecutedResult.failed("[权限]不存在: " + id); + } + return ExecutedResult.success(item); + } + + // 删除权限 + public ExecutedResult<String> removePermission(Long id) { + AdminPermissionPO find = permissionDao.get(id); + if (null == find) { + return ExecutedResult.failed("[权限]记录未找到。" + id); + } + Boolean remove = permissionDao.remove(id); + if (remove) { + // 删除权限缓存 + permissionService.removeListAllCache(); + return ExecutedResult.success(); + } + return ExecutedResult.failed("删除[权限]失败"); + } + + // 分页查询权限 + public ExecutedResult<PagerResult<ResAdminPermission>> searchPermission(SearchAdminPermission request) { + List<ResAdminPermission> result = new ArrayList<>(); + + super.dealPager(request); + request.setLastRowNo((request.getPage() - 1) * NumericUtil.tryParseLong(request.getLimit())); + // 处理时间范围 + Tuple<String, String> createTimeRange = ParameterUtil.getTimeRange(request.getCreateTimeRange()); + if (StringUtil.isNotNullOrEmpty(createTimeRange.getItem1())) { + request.setCreateTimeStart(LocalDateTimeUtil.getTimeStamp(createTimeRange.getItem1()).getTime()); + } + if (StringUtil.isNotNullOrEmpty(createTimeRange.getItem2())) { + request.setCreateTimeEnd(LocalDateTimeUtil.getTimeStamp(createTimeRange.getItem2()).getTime()); + } + if (NumericUtil.tryParseInt(request.getStatus(), 0).compareTo(0) < 1 && ListUtil.isNullOrEmpty(request.getListStatus())) { + request.setListStatus(Arrays.asList(EState.NORMAL.getValue(), EState.DISABLED.getValue())); + } + PagerResult<AdminPermissionPO> pagerResult = permissionDao.search(request); + + if (NumericUtil.tryParseLong(pagerResult.getTotal()).compareTo(0L) < 1) { + return ExecutedResult.success( + new PagerResult<>(request.getLimit(), request.getPage(), 0L, new ArrayList<>()) + ); + } + List<AdminPermissionPO> list = pagerResult.getList(); + Long lastId = 0L; + if (ListUtil.isNotNullOrEmpty(list)) { + lastId = list.stream().map(AdminPermissionPO::getId).min(Comparator.comparing(c -> c)).get(); + result = AdminPermissionConvert.INSTANCE.toDetail(list); + } + PagerResult<ResAdminPermission> view = new PagerResult<>(request.getLimit(), request.getPage(), pagerResult.getTotal(), result); + view.setLastId(lastId); + return ExecutedResult.success(view); + } + + // 创建角色 + public ExecutedResult<Long> createRole(ReqCreateAdminRole request) { + AdminRolePO item = AdminRoleConvert.INSTANCE.toCreate(request); + item.setDescription(ParameterUtil.dealNullStr(request.getDescription())); + item.setStatus(EState.NORMAL.getValue()); + item.setSort(NumericUtil.tryParseInt(request.getSort(), 0)); + item.setCreateTime(LocalDateTimeUtil.nowTimeStamp()); + int rowCount = roleDao.insert(item); + if (rowCount == 1) { + return ExecutedResult.success(item.getId()); + } + return ExecutedResult.failed("创建[角色]失败。"); + } + + // 编辑角色 + public ExecutedResult<String> modifyRole(ReqModifyAdminRole request) { + ExecutedResult<AdminRolePO> checkExists = this.checkRoleId(request.getId()); + if (checkExists.isFailed()) { + return ExecutedResult.failed(checkExists.getMsg()); + } + AdminRolePO item = AdminRoleConvert.INSTANCE.toModify(request); + item.setSort(NumericUtil.tryParseInt(request.getSort(), 0)); + item.setDescription(ParameterUtil.dealNullStr(request.getDescription())); + int rowCount = roleDao.updateById(item); + if (rowCount == 1) { + return ExecutedResult.success(); + } + return ExecutedResult.failed("编辑[角色]失败。"); + } + + // 修改角色状态 + public ExecutedResult<String> changeRoleStatus(Long id, EState status) { + ExecutedResult<AdminRolePO> checkExists = this.checkRoleId(id); + if (checkExists.isFailed()) { + return ExecutedResult.failed(checkExists.getMsg()); + } + AdminRolePO upd = new AdminRolePO(); + upd.setId(id); + upd.setStatus(status.getValue()); + int rowCount = roleDao.updateById(upd); + if (rowCount == 1) { + return ExecutedResult.success(); + } + return ExecutedResult.failed("修改[角色]状态失败。"); + } + private ExecutedResult<AdminRolePO> checkRoleId(Long id) { + AdminRolePO item = roleDao.get(id); + if (Objects.isNull(item)) { + return ExecutedResult.failed("[角色]不存在: " + id); + } + return ExecutedResult.success(item); + } + private ExecutedResult<List<AdminRolePO>> checkRoleId(List<Long> listId) { + // 从数据库查找测试信息 + List<AdminRolePO> list = roleDao.getList(listId); + if (ListUtil.isNullOrEmpty(list)) { + return ExecutedResult.failed("[角色]不存在." + listId); + } + // 数据库找到的id列表 + List<Long> listIdFind = list.stream().map(AdminRolePO::getId).collect(Collectors.toList()); + // 数量不一致 + if (listId.size() != listIdFind.size()) { + // 筛选数据库不存在的测试信息 + List<Long> listIdNotFound = listId.stream().filter(c -> !listIdFind.contains(c)).collect(Collectors.toList()); + if (ListUtil.isNullOrEmpty(list)) { + return ExecutedResult.failed("[角色]不存在." + listIdNotFound); + } + } + return ExecutedResult.success(list); + } + + public ExecutedResult<String> removeRole(Long id) { + // 验证记录是否存在 + ExecutedResult<AdminRolePO> checkExists = this.checkRoleId(id); + if (checkExists.isFailed()) { + return ExecutedResult.failed(checkExists.getMsg()); + } + + Boolean result = roleDao.deleteLogic(id); + if (BooleanUtils.isFalse(result)) { + return ExecutedResult.failed("删除[角色]失败。"); + } + return ExecutedResult.success(); + } + + public ExecutedResult<String> removeRoleList(List<Long> listId) { + // 验证记录是否存在 + ExecutedResult<List<AdminRolePO>> checkExists = this.checkRoleId(listId); + if (checkExists.isFailed()) { + return ExecutedResult.failed(checkExists.getMsg()); + } + + Boolean result = roleDao.deleteLogic(listId); + if (BooleanUtils.isFalse(result)) { + return ExecutedResult.failed("删除[角色]失败。"); + } + return ExecutedResult.success(); + } + + // 分页查询角色 + public ExecutedResult<PagerResult<AdminRoleVO>> searchRole(SearchAdminRole request) { + List<AdminRoleVO> result = new ArrayList<>(); + + super.dealPager(request); + request.setLastRowNo((request.getPage() - 1) * NumericUtil.tryParseLong(request.getLimit())); + // 处理时间范围 + Tuple<String, String> createTimeRange = ParameterUtil.getTimeRange(request.getCreateTimeRange()); + if (StringUtil.isNotNullOrEmpty(createTimeRange.getItem1())) { + request.setCreateTimeStart(LocalDateTimeUtil.getTimeStamp(createTimeRange.getItem1()).getTime()); + } + if (StringUtil.isNotNullOrEmpty(createTimeRange.getItem2())) { + request.setCreateTimeEnd(LocalDateTimeUtil.getTimeStamp(createTimeRange.getItem2()).getTime()); + } + if (NumericUtil.tryParseInt(request.getStatus(), 0).compareTo(0) < 1 && ListUtil.isNullOrEmpty(request.getListStatus())) { + request.setListStatus(Arrays.asList(EState.NORMAL.getValue(), EState.DISABLED.getValue())); + } + + PagerResult<AdminRolePO> pagerResult = roleDao.search(request); + + if (NumericUtil.tryParseLong(pagerResult.getTotal()).compareTo(0L) < 1) { + return ExecutedResult.success( + new PagerResult<>(request.getLimit(), request.getPage(), 0L, new ArrayList<>()) + ); + } + List<AdminRolePO> list = pagerResult.getList(); + Long lastId = 0L; + if (ListUtil.isNotNullOrEmpty(list)) { + lastId = list.stream().map(AdminRolePO::getId).min(Comparator.comparing(c -> c)).get(); + result = AdminRoleConvert.INSTANCE.toVo(list); + } + PagerResult<AdminRoleVO> view = new PagerResult<>(request.getLimit(), request.getPage(), pagerResult.getTotal(), result); + view.setLastId(lastId); + return ExecutedResult.success(view); + } + + // 设置角色菜单权限列表 + public ExecutedResult<String> setListMenu4Role(ReqSetListMenu4Role request) { + Long roleId = request.getId(); + ExecutedResult<AdminRolePO> checkExists = this.checkRoleId(roleId); + if (checkExists.isFailed()) { + return ExecutedResult.failed(checkExists.getMsg()); + } + AdminRolePO find = checkExists.getData(); + Long now = LocalDateTimeUtil.nowTimeStamp(); + + //找到角色已有的菜单列表 + List<AdminRoleMenuRelationPO> listOld = roleMenuRelationDao.list4Role(roleId); + listOld = ParameterUtil.dealNull(listOld); + List<Long> listOldMenuId = listOld.stream() + .map(AdminRoleMenuRelationPO::getMenuId) + .collect(Collectors.toList()); + + //现在设置的菜单id列表 + List<Long> listMenuId = ParameterUtil.dealNull(request.getListMenu()); + + //找到所有菜单 + List<Long> listAllId = new ArrayList<>(listOldMenuId); + listAllId.addAll(listMenuId); + ListUtil.repeat(listAllId); + List<AdminMenuPO> listMenu = menusDao.getList(listAllId); + Map<Long, AdminMenuPO> mapMenu = listMenu.stream() + .collect(Collectors.toMap(AdminMenuPO::getId, c -> c)); + + //找到新增菜单列表(新菜单列表的元素,不存在于已有的菜单列表中) + List<Long> listNew = listMenuId.stream() + .filter(c -> !listOldMenuId.contains(c)) + .collect(Collectors.toList()); + //找到删除菜单列表(已有菜单列表的元素,不存在于新菜单列表) + List<Long> listRemove = listOldMenuId.stream() + .filter(c -> !listMenuId.contains(c)) + .collect(Collectors.toList()); + + //批量新增 + if(BooleanUtils.isFalse(listNew.isEmpty())) { + List<AdminRoleMenuRelationPO> list = listNew.stream() + .map(c -> { + AdminRoleMenuRelationPO item = new AdminRoleMenuRelationPO(); + item.setRoleId(roleId); + item.setMenuId(c); + item.setCreateTime(now); + return item; + }).collect(Collectors.toList()); + Boolean addList = roleMenuRelationDao.addList(list); + if(BooleanUtils.isFalse(addList)) { + return ExecutedResult.failed("给角色“" + roleId + "”新增菜单失败。" + listNew); + } + } + //批量删除 + if(BooleanUtils.isFalse(listRemove.isEmpty())) { + List<Long> listId = listOld.stream() + .filter(c -> listRemove.contains(c.getMenuId())) + .map(AdminRoleMenuRelationPO::getId).collect(Collectors.toList()); + Boolean removeList = roleMenuRelationDao.remove(listId); + if(BooleanUtils.isFalse(removeList)) { + return ExecutedResult.failed("删除角色“" + roleId + "”已有菜单失败。" + listRemove); + } + } + + + + //找到角色已有的权限列表 + List<AdminRolePermissionRelationPO> listOldPermission = rolePermissionRelationDao.list4Role(roleId); + listOldPermission = ParameterUtil.dealNull(listOldPermission); + List<Long> listOldPermissionId = listOldPermission.stream() + .map(AdminRolePermissionRelationPO::getPermissionId) + .collect(Collectors.toList()); + + //现在设置的权限id列表 + List<Long> listPermissionId = ParameterUtil.dealNull(request.getListPermission()); + + //找到所有权限 + List<Long> listAllPermissionId = new ArrayList<>(listOldPermissionId); + listAllPermissionId.addAll(listPermissionId); + ListUtil.repeat(listAllPermissionId); + List<AdminPermissionPO> listPermission = permissionDao.getList(listAllPermissionId); + Map<Long, AdminPermissionPO> mapPermission = listPermission.stream() + .collect(Collectors.toMap(AdminPermissionPO::getId, c -> c)); + + //找到新增权限列表(新权限列表的元素,不存在于已有的菜单列表中) + List<Long> listNewPermission = listPermissionId.stream() + .filter(c -> !listOldPermissionId.contains(c)) + .collect(Collectors.toList()); + //找到删除权限列表(已有权限列表的元素,不存在于新菜单列表) + List<Long> listRemovePermission = listOldPermissionId.stream() + .filter(c -> !listPermissionId.contains(c)) + .collect(Collectors.toList()); + + //批量新增 + if(BooleanUtils.isFalse(listNewPermission.isEmpty())) { + List<AdminRolePermissionRelationPO> list = listNewPermission.stream() + .map(c -> { + AdminRolePermissionRelationPO item = new AdminRolePermissionRelationPO(); + item.setRoleId(roleId); + item.setPermissionId(c); + item.setCreateTime(now); + return item; + }).collect(Collectors.toList()); + Boolean addList = rolePermissionRelationDao.addList(list); + if(BooleanUtils.isFalse(addList)) { + return ExecutedResult.failed("给角色“" + roleId + "”新增权限失败。" + listNewPermission); + } + } + //批量删除 + if(BooleanUtils.isFalse(listRemovePermission.isEmpty())) { + List<Long> listId = listOldPermission.stream() + .filter(c -> listRemovePermission.contains(c.getPermissionId())) + .map(AdminRolePermissionRelationPO::getId).collect(Collectors.toList()); + Boolean removeList = rolePermissionRelationDao.remove(listId); + if(BooleanUtils.isFalse(removeList)) { + return ExecutedResult.failed("删除角色“" + roleId + "”已有权限失败。" + listRemovePermission); + } + } + return ExecutedResult.success(); + } + + // 获取角色菜单权限列表 + public ExecutedResult<ResAdminPower> getListMenu4Role(Long roleId) { + ResAdminPower result = new ResAdminPower(); + result.setMenus(new ArrayList<>()); + result.setPermissions(new ArrayList<>()); + + ExecutedResult<AdminRolePO> checkExists = this.checkRoleId(roleId); + if (checkExists.isFailed()) { + return ExecutedResult.failed(checkExists.getMsg()); + } + AdminRolePO find = checkExists.getData(); + //找到角色已有的菜单列表 + List<AdminRoleMenuRelationPO> listMenu4Role = roleMenuRelationDao.list4Role(roleId); + if (ListUtil.isNotNullOrEmpty(listMenu4Role)) { + List<Long> listOldMenuId = listMenu4Role.stream() + .map(AdminRoleMenuRelationPO::getMenuId) + .collect(Collectors.toList()); + List<AdminMenuPO> listMenu = menusDao.getList(listOldMenuId); + if (ListUtil.isNotNullOrEmpty(listMenu)) { + result.setMenus(AdminMenuConvert.INSTANCE.toVo(listMenu)); + } + } + //找到角色已有的权限列表 + List<AdminRolePermissionRelationPO> listPermission4Role = rolePermissionRelationDao.list4Role(roleId); + if (ListUtil.isNotNullOrEmpty(listPermission4Role)) { + List<Long> listPermissionId = listPermission4Role.stream() + .map(AdminRolePermissionRelationPO::getPermissionId) + .collect(Collectors.toList()); + List<AdminPermissionPO> listPermission = permissionDao.getList(listPermissionId); + if (ListUtil.isNotNullOrEmpty(listPermission)) { + result.setPermissions(AdminPermissionConvert.INSTANCE.toDetail(listPermission)); + } + } + return ExecutedResult.success(result); + } + + protected List<AdminPermissionPO> getListPermission4Role(List<Long> listRoleId) { + List<AdminRolePermissionRelationPO> listPermissionRel = rolePermissionRelationDao.list4Role(listRoleId); + if (ListUtil.isNullOrEmpty(listPermissionRel)) { + return new ArrayList<>(); + } + List<AdminPermissionPO> listPermission = permissionService.listAllWithCache(); + if (ListUtil.isNullOrEmpty(listPermission)) { + return new ArrayList<>(); + } + // 筛选状态 + listPermission = listPermission.stream() + .filter(c -> Objects.equals(c.getStatus(), EState.NORMAL.getValue())) + .collect(Collectors.toList()); + List<Long> listPermissionId = listPermissionRel.stream() + .map(AdminRolePermissionRelationPO::getPermissionId) + .collect(Collectors.toList()); + return listPermission.stream() + .filter(c -> listPermissionId.contains(c.getId())) + .collect(Collectors.toList()); + } + + protected List<AdminMenuPO> getListMenu4Role(List<Long> listRoleId) { + List<AdminRoleMenuRelationPO> listRoleMenu = roleMenuRelationDao.list4Role(listRoleId); + if (ListUtil.isNullOrEmpty(listRoleMenu)) { + return new ArrayList<>(); + } + List<AdminMenuPO> listMenu = menusService.listAllWithCache(); + if (ListUtil.isNullOrEmpty(listMenu)) { + return new ArrayList<>(); + } + // 筛选状态 + listMenu = listMenu.stream() + .filter(c -> Objects.equals(c.getStatus(), EState.NORMAL.getValue())) + .collect(Collectors.toList()); + List<Long> listMenuId = listRoleMenu.stream().map(AdminRoleMenuRelationPO::getMenuId) + .collect(Collectors.toList()); + return listMenu.stream() + .filter(c -> listMenuId.contains(c.getId())) + .collect(Collectors.toList()); + } + + /** + * 删除指定用户的菜单和权限缓存 + * @param userId 用户id + */ + protected void removePower4User(Long userId) { + menusService.removeUserMenuCache(userId); + permissionService.removeUserCache(userId); + } + /** + * 删除所有用户的菜单和权限缓存 + */ + protected void removePowerAllUser() { + menusService.removeAllUserMenuCache(); + permissionService.removeAllUserCache(); + } + + public ExecutedResult<String> setMenuSort(ReqSetSort request) { + // 验证记录是否存在 + ExecutedResult<AdminMenuPO> checkExists = this.checkMenuId(request.getId()); + if (checkExists.isFailed()) { + return ExecutedResult.failed(checkExists.getMsg()); + } + + AdminMenuPO item = new AdminMenuPO(); + item.setId(request.getId()); + item.setSort(request.getSort()); + + int rowCount = menusDao.updateById(item); + if (rowCount != 1) { + return ExecutedResult.failed("[测试信息]设置排序值失败。"); + } + return ExecutedResult.success(); + } + + public ExecutedResult<String> listSetMenuSort(ReqListSetSort request) { + // id列表 + List<Long> listId = request.getList().stream().map(ReqSetSort::getId).collect(Collectors.toList()); + // 验证记录是否存在 + ExecutedResult<List<AdminMenuPO>> checkExists = this.checkMenuId(listId); + if (checkExists.isFailed()) { + return ExecutedResult.failed(checkExists.getMsg()); + } + + List<AdminMenuPO> listUpdate = request.getList().stream() + .map(c -> { + AdminMenuPO item = new AdminMenuPO(); + item.setId(c.getId()); + item.setSort(c.getSort()); + return item; + }) + .collect(Collectors.toList()); + Boolean result = menusDao.modifyList(listUpdate); + if (result) { + return ExecutedResult.success(); + } + return ExecutedResult.failed("[测试信息]设置排序值失败"); + } + + public ExecutedResult<String> setRoleSort(ReqSetSort request) { + // 验证记录是否存在 + ExecutedResult<AdminRolePO> checkExists = this.checkRoleId(request.getId()); + if (checkExists.isFailed()) { + return ExecutedResult.failed(checkExists.getMsg()); + } + + AdminRolePO item = new AdminRolePO(); + item.setId(request.getId()); + item.setSort(request.getSort()); + + int rowCount = roleDao.updateById(item); + if (rowCount != 1) { + return ExecutedResult.failed("[角色]设置排序值失败。"); + } + return ExecutedResult.success(); + } + + public ExecutedResult<String> listSetRoleSort(ReqListSetSort request) { + // id列表 + List<Long> listId = request.getList().stream().map(ReqSetSort::getId).collect(Collectors.toList()); + // 验证记录是否存在 + ExecutedResult<List<AdminRolePO>> checkExists = this.checkRoleId(listId); + if (checkExists.isFailed()) { + return ExecutedResult.failed(checkExists.getMsg()); + } + + List<AdminRolePO> listUpdate = request.getList().stream() + .map(c -> { + AdminRolePO item = new AdminRolePO(); + item.setId(c.getId()); + item.setSort(c.getSort()); + return item; + }) + .collect(Collectors.toList()); + Boolean result = roleDao.modifyList(listUpdate); + if (result) { + return ExecutedResult.success(); + } + return ExecutedResult.failed("[角色]设置排序值失败"); + } +} diff --git a/src/main/java/com/fengdu/gas/service/AdminService.java b/src/main/java/com/fengdu/gas/service/AdminService.java new file mode 100644 index 0000000..9ed5b1a --- /dev/null +++ b/src/main/java/com/fengdu/gas/service/AdminService.java @@ -0,0 +1,494 @@ +package com.fengdu.gas.service; + +import com.fengdu.gas.entity.response.admin.ResAdminLogin; +import com.fengdu.gas.service.convert.AdminMenuConvert; +import com.fengdu.gas.service.convert.AdminPermissionConvert; +import com.fengdu.gas.service.convert.AdminRoleConvert; +import com.fengdu.gas.service.convert.AdminUserConvert; +import com.fengdu.gas.service.dto.ResAdminDetail; +import com.fengdu.gas.common.ConstantFactory; +import com.fengdu.gas.common.ExecutedResult; +import com.fengdu.gas.common.PagerResult; +import com.fengdu.gas.common.jwt.JWTUtil; +import com.fengdu.gas.common.jwt.LoginUserDTO; +import com.fengdu.gas.common.model.Tuple; +import com.fengdu.gas.common.security.MD5Util; +import com.fengdu.gas.common.util.*; +import com.fengdu.gas.entity.enums.EState; +import com.fengdu.gas.entity.enums.EUserType; +import com.fengdu.gas.entity.request.ReqChangePassword; +import com.fengdu.gas.entity.request.adminuser.ReqAdminLogin; +import com.fengdu.gas.entity.request.adminuser.ReqCreateAdminUser; +import com.fengdu.gas.entity.request.adminuser.ReqModifyAdminUser; +import com.fengdu.gas.entity.request.adminuser.ReqSetListRole4Admin; +import com.fengdu.gas.entity.response.admin.ResAdminMenuTreeAndPermission; +import com.fengdu.gas.entity.response.admin.ResAdminPower; +import com.fengdu.gas.entity.search.SearchAdminUser; +import com.fengdu.gas.repository.impl.*; +import com.fengdu.gas.repository.po.*; +import com.fengdu.gas.repository.vo.AdminRoleVO; +import com.fengdu.gas.repository.vo.AdminUserVO; +import org.apache.commons.lang3.BooleanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.*; +import java.util.stream.Collectors; + +@Service +public class AdminService extends BaseService { + private static final List<Integer> LIST_ADMIN_TYPE = Arrays.asList( + EUserType.ADMIN.getValue(), + EUserType.ADMIN_USER.getValue() + ); + + @Autowired + private AdminUserMapperImpl dao; + @Autowired + private AdminMenuMapperImpl menusDao; + @Autowired + private AdminPermissionMapperImpl permissionDao; + @Autowired + private AdminRoleMapperImpl roleDao; + @Autowired + private AdminRoleMenuRelationMapperImpl roleMenuRelationDao; + @Autowired + private AdminRolePermissionRelationMapperImpl rolePermissionRelationDao; + @Autowired + private AdminRoleRelationMapperImpl adminRoleRelationDao; + + @Autowired + private AdminMenuService menusService; + @Autowired + private AdminPermissionService permissionService; + @Autowired + private AdminPowerService adminPowerService; + + + + // 添加后台管理员 + public ExecutedResult<Long> createAdmin(ReqCreateAdminUser request) { + AdminUserPO find = dao.get4Name(request.getUserName()); + if(Objects.nonNull(find)){ + return ExecutedResult.failed("管理员帐号已存在。" + request.getUserName()); + } + AdminUserPO item = AdminUserConvert.INSTANCE.toCreate(request); + item.setUserRelId(0L); + item.setNickName(ParameterUtil.dealNullStr(request.getNickName())); + item.setHeadImg(ParameterUtil.dealNullStr(request.getHeadImg())); + item.setEmail(ParameterUtil.dealNullStr(request.getEmail())); + item.setContact(ParameterUtil.dealNullStr(request.getContact())); + // 密码加密 + item.setPassword(MD5Util.encrypt(request.getPassword() + ConstantFactory.KEY_PASSWORD)); + item.setStatus(EState.NORMAL.getValue()); + item.setCreateTime(LocalDateTimeUtil.nowTimeStamp()); + int rowCount = dao.insert(item); + if (rowCount == 1) { + return ExecutedResult.success(item.getId()); + } + return ExecutedResult.failed("添加[管理员]失败。"); + } + + // 修改后台管理员 + public ExecutedResult<String> modify(ReqModifyAdminUser request) { + ExecutedResult<AdminUserPO> check = this.check4Id(request.getId()); + if (check.isFailed()) { + return ExecutedResult.failed(check.getMsg(), check.getMsgCode()); + } + + AdminUserPO item = new AdminUserPO(); + item.setId(request.getId()); + item.setNickName(ParameterUtil.dealNullStr(request.getNickName())); + item.setHeadImg(ParameterUtil.dealNullStr(request.getHeadImg())); + item.setContact(ParameterUtil.dealNullStr(request.getContact())); + item.setEmail(ParameterUtil.dealNullStr(request.getEmail())); + item.setStatus(request.getStatus()); + int rowCount = dao.updateById(item); + if (rowCount == 1) { + return ExecutedResult.success(); + } + return ExecutedResult.failed("编辑[管理员]失败。"); + } + + // 获取指定管理员详情 + public ExecutedResult<ResAdminDetail> detail(Long adminId) { + ExecutedResult<AdminUserPO> check = this.check4Id(adminId); + if (check.isFailed()) { + return ExecutedResult.failed(check.getMsg(), check.getMsgCode()); + } + ResAdminDetail result = AdminUserConvert.INSTANCE.toDetail(check.getData()); + + result.setListRole(new ArrayList<>()); + //找到角色已有的菜单列表 + List<AdminRoleRelationPO> listRoleRel = adminRoleRelationDao.list4Admin(adminId); + if (ListUtil.isNotNullOrEmpty(listRoleRel)) { + List<Long> listRoleId = listRoleRel.stream() + .map(AdminRoleRelationPO::getRoleId) + .collect(Collectors.toList()); + List<AdminRolePO> listRole = roleDao.getList(listRoleId); + result.setListRole(AdminRoleConvert.INSTANCE.toVo(listRole)); + } + return ExecutedResult.success(result); + } + + // 管理员登录 + public ExecutedResult<ResAdminLogin> adminLogin(ReqAdminLogin request) { + AdminUserPO user = dao.get4Name(request.getUserName()); + if(Objects.isNull(user)){ + return ExecutedResult.failed("用户名或密码错误。"); + } + if(BooleanUtils.isFalse(Objects.equals(user.getStatus(), EState.NORMAL.getValue()))) { + return ExecutedResult.failed("账号已锁定,请联系管理员。"); + } + if(BooleanUtils.isFalse(MD5Util.encrypt(request.getPassword() + ConstantFactory.KEY_PASSWORD).equals(user.getPassword()))) { + return ExecutedResult.failed("用户名或密码错误。"); + } + // 构建登录用户 + LoginUserDTO loginUser = new LoginUserDTO(); + loginUser.setUserId(user.getId().toString()); + loginUser.setUserType(user.getUserType()); + loginUser.setNickName(user.getNickName()); + loginUser.setPhone(user.getContact()); + + // 保存用户信息到jwt + String token = JWTUtil.getToken(loginUser); + + ResAdminLogin result = this.getListPower4Admin(user); + result.setName(user.getNickName()); + result.setToken(token); + + return ExecutedResult.success(result); + } + + // 获取管理员权限列表 + public ExecutedResult<ResAdminPower> getPower(Long adminId) { + ResAdminPower result = new ResAdminPower(); + result.setMenus(new ArrayList<>()); + + ExecutedResult<AdminUserPO> check = this.check4Id(adminId); + if (check.isFailed()) { + return ExecutedResult.success(result); + } + AdminUserPO user = check.getData(); + + List<AdminMenuPO> listMenu; + List<AdminPermissionPO> listPermission = null; + // 超级管理员有所有权限 + if (Objects.equals(user.getUserType(), EUserType.ADMIN.getValue())) { + listMenu = menusService.listAllWithCache(); + listPermission = permissionService.listAllWithCache(); + } else { + //找到角色已有的菜单列表 + List<AdminRoleRelationPO> listRole = adminRoleRelationDao.list4Admin(adminId); + if (ListUtil.isNullOrEmpty(listRole)) { + return ExecutedResult.success(result); + } + List<Long> listRoleId = listRole.stream() + .map(AdminRoleRelationPO::getRoleId) + .collect(Collectors.toList()); + + listMenu = menusService.listUserAllWithCache(adminId, listRoleId, adminPowerService::getListMenu4Role); + listPermission = permissionService.listUserAllWithCache(adminId, listRoleId, adminPowerService::getListPermission4Role); + } + if (ListUtil.isNotNullOrEmpty(listMenu)) { + // 筛选状态 + listMenu = listMenu.stream() + .filter(c -> Objects.equals(c.getStatus(), EState.NORMAL.getValue())) + .collect(Collectors.toList()); + result.setMenus(AdminMenuConvert.INSTANCE.toVo(listMenu)); + } + if (ListUtil.isNotNullOrEmpty(listPermission)) { + // 筛选状态 + listPermission = listPermission.stream() + .filter(c -> Objects.equals(c.getStatus(), EState.NORMAL.getValue())) + .collect(Collectors.toList()); + result.setPermissions(AdminPermissionConvert.INSTANCE.toDetail(listPermission)); + } + return ExecutedResult.success(result); + } + + // 修改密码 + public ExecutedResult<String> changePassword(LoginUserDTO user, ReqChangePassword request) { + Long adminId = NumericUtil.tryParseLong(user.getUserId(), 0L); + ExecutedResult<AdminUserPO> check = this.check4Id(adminId); + if (check.isFailed()) { + return ExecutedResult.failed(check.getMsg(), check.getMsgCode()); + } + String oldPass = MD5Util.encrypt(request.getOldPassword() + ConstantFactory.KEY_PASSWORD); + if (BooleanUtils.isFalse(oldPass.equals(check.getData().getPassword()))) { + return ExecutedResult.failed("密码校验失败。"); + } + return this.changePasswordDo(adminId, request.getNewPassword()); + } + private ExecutedResult<String> changePasswordDo(Long adminId, String password) { + AdminUserPO item = new AdminUserPO(); + item.setId(adminId); + // 密码加密 + item.setPassword(MD5Util.encrypt(password + ConstantFactory.KEY_PASSWORD)); + int rowCount = dao.updateById(item); + if (rowCount == 1) { + return ExecutedResult.success(); + } + return ExecutedResult.failed("密码修改失败。"); + } + + // 重置密码 + public ExecutedResult<String> resetPassword(Long adminId) { + ExecutedResult<AdminUserPO> check = this.check4Id(adminId); + if (check.isFailed()) { + return ExecutedResult.failed(check.getMsg(), check.getMsgCode()); + } + String pass = RandVerifyCode.complexCode(8); + ExecutedResult<String> changePasswordDo = this.changePasswordDo(adminId, pass); + if (changePasswordDo.isFailed()) { + return changePasswordDo; + } + return ExecutedResult.success(pass); + } + + // 分页查询所有管理员 + public ExecutedResult<PagerResult<AdminUserVO>> search(SearchAdminUser request) { + List<AdminUserVO> result = new ArrayList<>(); + + super.dealPager(request); + request.setLastRowNo((request.getPage() - 1) * NumericUtil.tryParseLong(request.getLimit())); + // 处理时间范围 + Tuple<String, String> createTimeRange = ParameterUtil.getTimeRange(request.getCreateTimeRange()); + if (StringUtil.isNotNullOrEmpty(createTimeRange.getItem1())) { + request.setCreateTimeStart(LocalDateTimeUtil.getTimeStamp(createTimeRange.getItem1()).getTime()); + } + if (StringUtil.isNotNullOrEmpty(createTimeRange.getItem2())) { + request.setCreateTimeEnd(LocalDateTimeUtil.getTimeStamp(createTimeRange.getItem2()).getTime()); + } + + PagerResult<AdminUserPO> pagerResult = dao.search(request); + + if (NumericUtil.tryParseLong(pagerResult.getTotal()).compareTo(0L) < 1) { + return ExecutedResult.success( + new PagerResult<>(request.getLimit(), request.getPage(), 0L, new ArrayList<>()) + ); + } + List<AdminUserPO> list = pagerResult.getList(); + Long lastId = 0L; + if (ListUtil.isNotNullOrEmpty(list)) { + lastId = list.stream().map(AdminUserPO::getId).min(Comparator.comparing(c -> c)).get(); + + list.forEach(item -> { + AdminUserVO vo = AdminUserConvert.INSTANCE.toVo(item); + result.add(vo); + }); + } + PagerResult<AdminUserVO> view = new PagerResult<>(request.getLimit(), request.getPage(), pagerResult.getTotal(), result); + view.setLastId(lastId); + return ExecutedResult.success(view); + } + + public ExecutedResult<String> stop(Long id) { + // 验证记录是否存在 + ExecutedResult<AdminUserPO> checkExists = this.check4Id(id); + if (checkExists.isFailed()) { + return ExecutedResult.failed(checkExists.getMsg()); + } + AdminUserPO item = new AdminUserPO(); + item.setId(id); + item.setStatus(EState.DISABLED.getValue()); + + int rowCount = this.dao.updateById(item); + if (rowCount == 1) { + return ExecutedResult.success(); + } + return ExecutedResult.failed("停用[管理员]失败。"); + } + + public ExecutedResult<String> enable(Long id) { + // 验证记录是否存在 + ExecutedResult<AdminUserPO> checkExists = this.check4Id(id); + if (checkExists.isFailed()) { + return ExecutedResult.failed(checkExists.getMsg()); + } + AdminUserPO item = new AdminUserPO(); + item.setId(id); + item.setStatus(EState.NORMAL.getValue()); + + int rowCount = this.dao.updateById(item); + if (rowCount == 1) { + return ExecutedResult.success(); + } + return ExecutedResult.failed("启用[管理员]失败。"); + } + + public ExecutedResult<String> remove(Long adminId) { + ExecutedResult<AdminUserPO> check = this.check4Id(adminId); + if (check.isFailed()) { + return ExecutedResult.failed(check.getMsg(), check.getMsgCode()); + } + Boolean remove = dao.remove(adminId); + if (remove) { + return ExecutedResult.success(); + } + return ExecutedResult.failed("删除[管理员]失败"); + } + + public ExecutedResult<AdminUserPO> check4Id(Long id) { + AdminUserPO item = dao.get(id); + if (Objects.isNull(item)) { + return ExecutedResult.failed("[管理员]不存在: " + id); + } + return ExecutedResult.success(item); + } + + // 设置管理员的角色列表 + public ExecutedResult<String> setListRole4Admin(ReqSetListRole4Admin request) { + Long adminId = request.getId(); + ExecutedResult<AdminUserPO> checkExists = this.check4Id(adminId); + if (checkExists.isFailed()) { + return ExecutedResult.failed(checkExists.getMsg()); + } + AdminUserPO find = checkExists.getData(); + //找到管理员已有的角色列表 + List<AdminRoleRelationPO> listOld = adminRoleRelationDao.list4Admin(adminId); + listOld = ParameterUtil.dealNull(listOld); + + //现在设置的角色id列表 + List<Long> listRoleId = ParameterUtil.dealNull(request.getListRole()); + + //批量新增 + if(BooleanUtils.isFalse(listRoleId.isEmpty())) { + List<AdminRoleRelationPO> list = listRoleId.stream() + .map(c -> { + AdminRoleRelationPO item = new AdminRoleRelationPO(); + item.setAdminId(adminId); + item.setRoleId(c); + item.setCreateTime(LocalDateTimeUtil.nowTimeStamp()); + return item; + }).collect(Collectors.toList()); + Boolean addList = adminRoleRelationDao.addList(list); + if(BooleanUtils.isFalse(addList)) { + return ExecutedResult.failed("给管理员“" + adminId + "”新增角色失败。" + listRoleId); + } + } + //批量删除 + if(BooleanUtils.isFalse(listOld.isEmpty())) { + List<Long> listId = listOld.stream() + .map(AdminRoleRelationPO::getId).collect(Collectors.toList()); + Boolean removeList = adminRoleRelationDao.remove(listId); + if(BooleanUtils.isFalse(removeList)) { + return ExecutedResult.failed("删除管理员“" + adminId + "”已有角色失败。" + listId); + } + } + // 删除指定用户的菜单和权限缓存 + adminPowerService.removePower4User(adminId); + return ExecutedResult.success(); + } + + // 获取管理员的角色列表 + public ExecutedResult<List<AdminRoleVO>> getListRole4Admin(Long id) { + List<AdminRoleVO> result = new ArrayList<>(); + + ExecutedResult<AdminUserPO> checkExists = this.check4Id(id); + if (checkExists.isFailed()) { + return ExecutedResult.failed(checkExists.getMsg()); + } + AdminUserPO find = checkExists.getData(); + List<AdminRolePO> list; + if (Objects.equals(find.getUserType(), EUserType.ADMIN.getValue())) { + list = roleDao.getList(); + } else { + //找到角色已有的菜单列表 + List<AdminRoleRelationPO> listRole = adminRoleRelationDao.list4Admin(id); + listRole = ParameterUtil.dealNull(listRole); + if (ListUtil.isNullOrEmpty(listRole)) { + return ExecutedResult.success(result); + } + List<Long> listRoleId = listRole.stream() + .map(AdminRoleRelationPO::getRoleId) + .collect(Collectors.toList()); + list = roleDao.getList(listRoleId); + } + if (ListUtil.isNotNullOrEmpty(list)) { + // 筛选状态 + list = list.stream() + .filter(c -> Objects.equals(c.getStatus(),EState.NORMAL.getValue())) + .collect(Collectors.toList()); + result = AdminRoleConvert.INSTANCE.toVo(list); + } + return ExecutedResult.success(result); + } + + /** + * 获取指定用户的菜单和权限 + * @param user 用户 + */ + public ResAdminLogin getListPower4Admin(AdminUserPO user) { + Long adminId = user.getId(); + + ResAdminLogin result = new ResAdminLogin(); + result.setId(user.getId()); + result.setUserType(user.getUserType()); + result.setMenus(new ArrayList<>()); + + List<AdminMenuPO> listMenu; + List<AdminPermissionPO> listPermission = null; + + // 管理员从缓存中取有所有权限(普通管理员剔除系统管理部分菜单) + if (LIST_ADMIN_TYPE.contains(user.getUserType())) { + listMenu = menusService.listAllWithCache(); + + if (Objects.equals(EUserType.ADMIN_USER.getValue(), user.getUserType())) { + List<Long> listNot = Arrays.asList(10101L, 10102L, 10103L); + listMenu = listMenu.stream().filter(c -> !listNot.contains(c.getId())).collect(Collectors.toList()); + } + + listPermission = permissionService.listAllWithCache(); + } else { + //找到角色已有的菜单列表 + List<AdminRoleRelationPO> listRole = adminRoleRelationDao.list4Admin(adminId); + if (ListUtil.isNullOrEmpty(listRole)) { + return result; + } + List<Long> listRoleId = listRole.stream() + .map(AdminRoleRelationPO::getRoleId) + .collect(Collectors.toList()); + + listMenu = menusService.listUserAllWithCache(user.getId(), listRoleId, adminPowerService::getListMenu4Role); + listPermission = permissionService.listUserAllWithCache(user.getId(), listRoleId, adminPowerService::getListPermission4Role); + } + if (ListUtil.isNotNullOrEmpty(listMenu)) { + // 筛选状态 + listMenu = listMenu.stream() + .filter(c -> Objects.equals(c.getStatus(), EState.NORMAL.getValue())) + .collect(Collectors.toList()); + Map<Long, List<AdminPermissionPO>> mapPermission = new HashMap<>(); + // 筛选权限状态 + if (ListUtil.isNotNullOrEmpty(listPermission)) { + // 筛选状态 + mapPermission = listPermission.stream() + .filter(c -> Objects.equals(c.getStatus(), EState.NORMAL.getValue())) + .collect(Collectors.groupingBy(AdminPermissionPO::getMenuId)); + } + + List<AdminMenuPO> listRoot = listMenu.stream().filter(c -> Objects.equals(c.getLevel(), 1)).collect(Collectors.toList()); + listRoot = listRoot.stream() + .sorted(Comparator.comparing(AdminMenuPO::getSort)) + .collect(Collectors.toList()); + if (ListUtil.isNotNullOrEmpty(listRoot)) { + for (AdminMenuPO item : listRoot) { + ResAdminMenuTreeAndPermission view = AdminMenuConvert.INSTANCE.toTreeVo(item); + adminPowerService.fillChildMenu(view, listMenu, mapPermission); + adminPowerService.fillPermission4Menu(view, mapPermission); + result.getMenus().add(view); + } + } + } + if (ListUtil.isNotNullOrEmpty(listPermission)) { + // 筛选状态 + List<String> listPermissionSn = listPermission.stream() + .filter(c -> Objects.equals(c.getStatus(), EState.NORMAL.getValue())) + .sorted(Comparator.comparing(AdminPermissionPO::getMenuId)) + .map(AdminPermissionPO::getSn) + .collect(Collectors.toList()); + result.setListPermission(listPermissionSn); + } + return result; + } +} diff --git a/src/main/java/com/fengdu/gas/service/BaseService.java b/src/main/java/com/fengdu/gas/service/BaseService.java new file mode 100644 index 0000000..7182c74 --- /dev/null +++ b/src/main/java/com/fengdu/gas/service/BaseService.java @@ -0,0 +1,16 @@ +package com.fengdu.gas.service; + +import com.fengdu.gas.common.ConstantFactory; +import com.fengdu.gas.common.util.NumericUtil; +import com.fengdu.gas.entity.dto.SearchBasicDTO; + +public class BaseService { + public void dealPager(SearchBasicDTO search) { + if(NumericUtil.tryParseInt(search.getLimit()).compareTo(0) < 1) { + search.setLimit(ConstantFactory.PAGE_SIZE_DEFAULT); + } + if(NumericUtil.tryParseInt(search.getPage()).compareTo(0) < 1) { + search.setPage(1); + } + } +} diff --git a/src/main/java/com/fengdu/gas/service/NoticeService.java b/src/main/java/com/fengdu/gas/service/NoticeService.java new file mode 100644 index 0000000..02bf0ae --- /dev/null +++ b/src/main/java/com/fengdu/gas/service/NoticeService.java @@ -0,0 +1,168 @@ +package com.fengdu.gas.service; + +import com.fengdu.gas.service.dto.NoticeDetail; +import com.fengdu.gas.common.ExecutedResult; +import com.fengdu.gas.common.PagerResult; +import com.fengdu.gas.common.jwt.LoginUserDTO; +import com.fengdu.gas.common.model.Tuple; +import com.fengdu.gas.common.util.*; +import com.fengdu.gas.entity.enums.EState; +import com.fengdu.gas.entity.request.ReqSetSort; +import com.fengdu.gas.entity.request.notice.ReqCreateNotice; +import com.fengdu.gas.entity.request.notice.ReqModifyNotice; +import com.fengdu.gas.entity.search.SearchNotice; +import com.fengdu.gas.repository.impl.AdminUserMapperImpl; +import com.fengdu.gas.repository.impl.NoticeMapperImpl; +import com.fengdu.gas.repository.po.NoticePO; +import com.fengdu.gas.repository.vo.NoticeVO; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** + * 公告相关服务 + * + * @author lin.liu + * @date 2023/02/26 + */ +@Service +public class NoticeService extends BaseService { + @Autowired + private NoticeMapperImpl dao; + @Autowired + private AdminUserMapperImpl adminUserDao; + + public ExecutedResult<Long> create(ReqCreateNotice request, LoginUserDTO user) { + Long now = LocalDateTimeUtil.nowTimeStamp(); + + // 转换po + NoticePO item = CopierUtil.mapTo(request, NoticePO.class); + // 设置发布人 + item.setPublishUser(user.getNickName()); + // 截取摘要 + item.setSummary(request.getContent().substring(0, 80)); + // 设置记录创建时间 + item.setCreateTime(now); + item.setStatus(EState.NORMAL.getValue()); + item.setSort(NumericUtil.tryParseInt(request.getSort(), 0)); + + int rowCount = dao.insert(item); + if (rowCount == 1) { + return ExecutedResult.success(item.getId()); + } + return ExecutedResult.failed("创建[公告]失败"); + } + + public ExecutedResult<String> modify(ReqModifyNotice request) { + // 验证记录是否存在 + ExecutedResult<NoticePO> checkExists = this.check4Id(request.getId()); + if (checkExists.isFailed()) { + return ExecutedResult.failed(checkExists.getMsg()); + } + + // 转换po + NoticePO item = CopierUtil.mapTo(request, NoticePO.class); + // 截取摘要 + item.setSummary(request.getContent().substring(0, 80)); + item.setStatus(NumericUtil.tryParseInt(request.getStatus(), EState.NORMAL.getValue())); + item.setSort(NumericUtil.tryParseInt(request.getSort(), 0)); + + int rowCount = this.dao.updateById(item); + if (rowCount == 1) { + return ExecutedResult.failed("编辑[公告]失败。"); + } + return ExecutedResult.success(); + } + + public ExecutedResult<NoticeDetail> get(Long id) { + NoticeDetail result = new NoticeDetail(); + + NoticePO find = dao.get(id); + if (null != find) { + result = CopierUtil.mapTo(find, NoticeDetail.class); + } + return ExecutedResult.success(result); + } + + public ExecutedResult<String> changeStatus(Long id, EState state) { + // 验证记录是否存在 + ExecutedResult<NoticePO> checkExists = this.check4Id(id); + if (checkExists.isFailed()) { + return ExecutedResult.failed(checkExists.getMsg()); + } + NoticePO item = new NoticePO(); + item.setId(id); + item.setStatus(state.getValue()); + + int rowCount = this.dao.updateById(item); + if (rowCount == 1) { + return ExecutedResult.failed("[公告]状态修改失败。"); + } + return ExecutedResult.success(); + } + + public ExecutedResult<String> setSort(ReqSetSort request) { + // 验证记录是否存在 + ExecutedResult<NoticePO> checkExists = this.check4Id(request.getId()); + if (checkExists.isFailed()) { + return ExecutedResult.failed(checkExists.getMsg()); + } + NoticePO item = new NoticePO(); + item.setId(request.getId()); + item.setSort(request.getSort()); + + int rowCount = this.dao.updateById(item); + if (rowCount == 1) { + return ExecutedResult.failed("[公告]排序值设置失败。"); + } + return ExecutedResult.success(); + } + + public ExecutedResult<List<NoticeVO>> getList(List<Long> listId) { + List<NoticeVO> result = new ArrayList<>(); + + List<NoticePO> list = this.dao.getList(listId); + if (ListUtil.isNotNullOrEmpty(list)) { + result = CopierUtil.mapTo(list, NoticeVO.class); + } + return ExecutedResult.success(result); + } + + public ExecutedResult<PagerResult<NoticeVO>> search(SearchNotice search) { + // 处理创建时间范围-查询参数 + Tuple<String, String> createTimeRange = ParameterUtil.getTimeRange(search.getCreateTimeRange()); + if (StringUtil.isNotNullOrEmpty(createTimeRange.getItem1())) { + search.setCreateTimeStart(LocalDateTimeUtil.getTimeStamp(createTimeRange.getItem1()).getTime()); + } + if (StringUtil.isNotNullOrEmpty(createTimeRange.getItem2())) { + search.setCreateTimeEnd(LocalDateTimeUtil.getTimeStamp(createTimeRange.getItem2()).getTime()); + } + if (NumericUtil.tryParseInt(search.getStatus(), 0).compareTo(0) < 1 && ListUtil.isNullOrEmpty(search.getListStatus())) { + search.setStatus(EState.NORMAL.getValue()); + } + + + PagerResult<NoticePO> pageList = dao.search(search); + List<NoticeVO> listVo = new ArrayList<>(); + List<NoticePO> list = pageList.getList(); + if (ListUtil.isNotNullOrEmpty(list)) { + pageList.setLastId(list.get(list.size() - 1).getId()); + // 转换vo + listVo = CopierUtil.mapTo(list, NoticeVO.class); + } + PagerResult<NoticeVO> result = new PagerResult<>(pageList.getLimit(), pageList.getPage(), pageList.getTotal(), listVo); + result.setLastId(pageList.getLastId()); + return ExecutedResult.success(result); + } + + protected ExecutedResult<NoticePO> check4Id(Long id) { + NoticePO exists = dao.get(id); + if (Objects.isNull(exists)) { + return ExecutedResult.failed("[公告]不存在:" + id); + } + return ExecutedResult.success(exists); + } +} diff --git a/src/main/java/com/fengdu/gas/service/SysDictDataService.java b/src/main/java/com/fengdu/gas/service/SysDictDataService.java new file mode 100644 index 0000000..bf5c885 --- /dev/null +++ b/src/main/java/com/fengdu/gas/service/SysDictDataService.java @@ -0,0 +1,390 @@ +/** +# __----~~~~~~~~~~~------___ +# . . ~~//====...... __--~ ~~ +# -. \_|// |||\\ ~~~~~~::::... /~ +# ___-==_ _-~o~ \/ ||| \\ _/~~- +# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ +# _-~~ .=~ | \\-_ '-~7 /- / || \ / +# .~ .~ | \\ -_ / /- / || \ / +# / ____ / | \\ ~-_/ /|- _/ .|| \ / +# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ +# ' ~-| /| |-~\~~ __--~~ +# |-~~-_/ | | ~\_ _-~ /\ +# / \ \__ \/~ \__ +# _--~ _/ | .-~~____--~-/ ~~==. +# ((->/~ '.|||' -_| ~~-/ , . _|| +# -_ ~\ ~~---l__i__i__i--~~_/ +# _-~-__ ~) \--______________--~~ +# //.-~~~-~_--~- |-------~~~~~~~~ +# //.-~~~--\ +# 神兽保佑 +# 永无BUG! +*/ +package com.fengdu.gas.service; + +import com.fengdu.gas.repository.po.SysDictDataPO; +import com.fengdu.gas.repository.po.SysDictTypePO; +import com.fengdu.gas.service.convert.SysDictDataConvert; +import com.fengdu.gas.common.ExecutedResult; +import com.fengdu.gas.common.PagerResult; +import com.fengdu.gas.common.enums.EYesOrNo; +import com.fengdu.gas.common.jwt.LoginUserDTO; +import com.fengdu.gas.common.model.Tuple; +import com.fengdu.gas.common.util.ListUtil; +import com.fengdu.gas.common.util.LocalDateTimeUtil; +import com.fengdu.gas.common.util.ParameterUtil; +import com.fengdu.gas.common.util.StringUtil; +import com.fengdu.gas.entity.enums.EState; +import com.fengdu.gas.entity.request.sysdictdata.ReqCreateSysDictData; +import com.fengdu.gas.entity.request.sysdictdata.ReqModifySysDictData; +import com.fengdu.gas.entity.search.SearchSysDictData; +import com.fengdu.gas.repository.impl.SysDictDataMapperImpl; +import com.fengdu.gas.repository.impl.SysDictTypeMapperImpl; +import com.fengdu.gas.repository.vo.SysDictDataVO; +import org.apache.commons.lang3.BooleanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cache.annotation.CacheEvict; +import org.springframework.cache.annotation.Cacheable; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.function.Function; +import java.util.stream.Collectors; + +/** + * 字典数据表 + * @author lin.liu + * @description 字典数据表 + */ +@Service +public class SysDictDataService extends BaseService { + @Autowired + private SysDictDataMapperImpl mapper; + @Autowired + private SysDictTypeMapperImpl dictTypeMapper; + + @Autowired + private SysDictTypeService dictTypeService; + + + public ExecutedResult<Long> create(ReqCreateSysDictData request, LoginUserDTO loginUser) { + // 校验类型 + dictTypeService.check4TypeExc(request.getDictType()); + + // 转换po + SysDictDataPO item = SysDictDataConvert.INSTANCE.toCreate(request); + // 设置状态 + item.setStatus(EState.NORMAL.getValue()); + // 设置记录创建时间 + item.setCreateTime(LocalDateTimeUtil.nowTimeStamp()); + // 是否删除(逻辑删除)初始值 + item.setIsDelete(EYesOrNo.NO.getValue()); + + int rowCount = mapper.insert(item); + if (rowCount != 1) { + return ExecutedResult.failed("创建[字典数据表]失败。"); + } + // 删除所有缓存 + this.removeAllTypeCache(); + return ExecutedResult.success(item.getId()); + } + + public ExecutedResult<String> modify(ReqModifySysDictData request, LoginUserDTO loginUser) { + // 验证记录是否存在 + ExecutedResult<SysDictDataPO> checkExists = this.check4Id(request.getId()); + if (checkExists.isFailed()) { + return ExecutedResult.failed(checkExists.getMsg()); + } + // 转换po + SysDictDataPO item = SysDictDataConvert.INSTANCE.toModify(request); + + int rowCount = mapper.updateById(item); + if (rowCount != 1) { + return ExecutedResult.failed("编辑[字典数据表]失败。"); + } + // 删除所有缓存 + this.removeAllTypeCache(); + return ExecutedResult.success(); + } + + public ExecutedResult<SysDictDataVO> get(Long id) { + SysDictDataVO result = new SysDictDataVO(); + + SysDictDataPO find = mapper.get(id); + if (null != find) { + // 转换po + result = SysDictDataConvert.INSTANCE.toVo(find); + // 赋值类型名称 + result.setDictTypeTxt(""); + + SysDictTypePO type = dictTypeMapper.get4Type(find.getDictType()); + if (Objects.nonNull(type)) { + result.setDictTypeTxt(type.getDictName()); + } + } + return ExecutedResult.success(result); + } + + // public ExecutedResult<String> stop(Long id) { +// // 验证记录是否存在 +// ExecutedResult<SysDictDataPO> checkExists = this.check4Id(id); +// if (checkExists.isFailed()) { +// return ExecutedResult.failed(checkExists.getMsg()); +// } +// SysDictDataPO item = new SysDictDataPO(); +// item.setId(id); +// item.setStatus(EState.DISABLED.getValue()); +// +// int rowCount = mapper.updateById(item); +// if (rowCount != 1) { +// return ExecutedResult.failed("停用[字典数据表]失败。"); +// } +// return ExecutedResult.success(); +// } +// +// public ExecutedResult<String> enable(Long id) { +// // 验证记录是否存在 +// ExecutedResult<SysDictDataPO> checkExists = this.check4Id(id); +// if (checkExists.isFailed()) { +// return ExecutedResult.failed(checkExists.getMsg()); +// } +// SysDictDataPO item = new SysDictDataPO(); +// item.setId(id); +// item.setStatus(EState.NORMAL.getValue()); +// +// int rowCount = mapper.updateById(item);\n" + +// if (rowCount != 1) { +// return ExecutedResult.failed("启用[字典数据表]失败。"); +// } +// return ExecutedResult.success(); +// } +// +// public ExecutedResult<String> setSort(ReqSetSort request) { +// // 验证记录是否存在 +// ExecutedResult<SysDictDataPO> checkExists = this.check4Id(request.getId()); +// if (checkExists.isFailed()) { +// return ExecutedResult.failed(checkExists.getMsg()); +// } +// SysDictDataPO item = new SysDictDataPO(); +// item.setId(request.getId()); +// item.setSort(request.getSort()); +// +// int rowCount = mapper.updateById(item);\n" + +// if (rowCount != 1) { +// return ExecutedResult.failed("设置[字典数据表]排序值失败。"); +// } +// return ExecutedResult.success(); +// } +// +// public ExecutedResult<String> listSetSort(ReqListSetSort request) { +// // id列表 +// List<Long> listId = request.getList().stream().map(ReqSetSort::getId).collect(Collectors.toList()); +// // 验证记录是否存在 +// ExecutedResult<List<SysDictDataPO>> checkExists = this.check4Id(listId); +// if (checkExists.isFailed()) { +// return ExecutedResult.failed(checkExists.getMsg()); +// } +// +// List<SysDictDataPO> listUpdate = request.getList().stream() +// .map(c -> { +// SysDictDataPO item = new SysDictDataPO(); +// item.setId(c.getId()); +// item.setSort(c.getSort()); +// return item; +// }) +// .collect(Collectors.toList()); +// Boolean result = mapper.modifyList(listUpdate); +// if (result) { +// return ExecutedResult.success(); +// } +// return ExecutedResult.failed("[字典数据表]设置排序值失败"); +// } +// + public ExecutedResult<String> remove(Long id) { + Boolean result = mapper.remove(id); + if (BooleanUtils.isFalse(result)) { + return ExecutedResult.failed("删除[字典数据表]失败。"); + } + // 删除所有缓存 + this.removeAllTypeCache(); + return ExecutedResult.success(); + } + + public ExecutedResult<String> removeList(List<Long> ids) { + Boolean result = mapper.remove(ids); + if (BooleanUtils.isFalse(result)) { + return ExecutedResult.failed("删除[字典数据表]失败。"); + } + // 删除所有缓存 + this.removeAllTypeCache(); + return ExecutedResult.success(); + } + + /** + * 根据类型查询数据 + * @param type 字典类型 + */ + public ExecutedResult<List<SysDictDataVO>> getListByType(String type) { + List<SysDictDataVO> result = new ArrayList<>(); + + List<SysDictDataPO> list = this.mapper.getListByType(type); + if (ListUtil.isNotNullOrEmpty(list)) { + List<SysDictTypePO> listType = dictTypeMapper.get4Type( + list.stream() + .map(SysDictDataPO::getDictType) + .distinct() + .collect(Collectors.toList()) + ); + Map<Object, SysDictTypePO> map4Type = listType.stream().collect(Collectors.toMap(SysDictTypePO::getId, c -> c)); + + for (SysDictDataPO item : list) { + // 转化vo + SysDictDataVO vo = SysDictDataConvert.INSTANCE.toVo(item); + // 赋值类型名称 + vo.setDictTypeTxt(""); + + if (map4Type.containsKey(item.getDictType())) { + vo.setDictTypeTxt(map4Type.get(item.getDictType()).getDictName()); + } + + result.add(vo); + } + } + return ExecutedResult.success(result); + } + + /** + * 根据类型查询数据 + * @param listId 字典数据id列表 + */ + public ExecutedResult<List<SysDictDataVO>> getList(List<Long> listId) { + List<SysDictDataVO> result = new ArrayList<>(); + + List<SysDictDataPO> list = mapper.getList(listId); + if (ListUtil.isNotNullOrEmpty(list)) { + List<SysDictTypePO> listType = dictTypeMapper.get4Type( + list.stream() + .map(SysDictDataPO::getDictType) + .distinct() + .collect(Collectors.toList()) + ); + Map<Object, SysDictTypePO> map4Type = listType.stream().collect(Collectors.toMap(SysDictTypePO::getId, c -> c)); + + for (SysDictDataPO item : list) { + // 转化vo + SysDictDataVO vo = SysDictDataConvert.INSTANCE.toVo(item); + // 赋值类型名称 + vo.setDictTypeTxt(""); + + if (map4Type.containsKey(item.getDictType())) { + vo.setDictTypeTxt(map4Type.get(item.getDictType()).getDictName()); + } + + result.add(vo); + } + } + return ExecutedResult.success(result); + } + + public ExecutedResult<PagerResult<SysDictDataVO>> search(SearchSysDictData search) { + // 处理创建时间范围-查询参数 + Tuple<String, String> createTimeRange = ParameterUtil.getTimeRange(search.getCreateTimeRange()); + if (StringUtil.isNotNullOrEmpty(createTimeRange.getItem1())) { + search.setCreateTimeStart(LocalDateTimeUtil.getTimeStamp(createTimeRange.getItem1()).getTime()); + } + if (StringUtil.isNotNullOrEmpty(createTimeRange.getItem2())) { + search.setCreateTimeEnd(LocalDateTimeUtil.getTimeStamp(createTimeRange.getItem2()).getTime()); + } + + PagerResult<SysDictDataPO> pageList = mapper.search(search); + List<SysDictDataVO> listVo = new ArrayList<>(); + List<SysDictDataPO> list = pageList.getList(); + if (ListUtil.isNotNullOrEmpty(list)) { + pageList.setLastId(list.get(list.size() - 1).getId()); + List<SysDictTypePO> listType = dictTypeMapper.get4Type( + list.stream() + .map(SysDictDataPO::getDictType) + .distinct() + .collect(Collectors.toList()) + ); + Map<Object, SysDictTypePO> map4Type = listType.stream().collect(Collectors.toMap(SysDictTypePO::getId, c -> c)); + + for (SysDictDataPO item : list) { + // 转化vo + SysDictDataVO vo = SysDictDataConvert.INSTANCE.toVo(item); + // 赋值类型名称 + vo.setDictTypeTxt(""); + + if (map4Type.containsKey(item.getDictType())) { + vo.setDictTypeTxt(map4Type.get(item.getDictType()).getDictName()); + } + + listVo.add(vo); + } + } + PagerResult<SysDictDataVO> result = new PagerResult<>(pageList.getLimit(), pageList.getPage(), pageList.getTotal(), listVo); + result.setLastId(pageList.getLastId()); + return ExecutedResult.success(result); + } + + protected ExecutedResult<SysDictDataPO> check4Id(Long id) { + SysDictDataPO exists = mapper.get(id); + if (Objects.isNull(exists)) { + return ExecutedResult.failed("[字典数据表]不存在:" + id); + } + return ExecutedResult.success(exists); + } + + protected ExecutedResult<List<SysDictDataPO>> check4Id(List<Long> listId) { + // 从数据库查找字典数据表 + List<SysDictDataPO> list = mapper.getList(listId); + if (ListUtil.isNullOrEmpty(list)) { + return ExecutedResult.failed("[字典数据表]不存在." + listId); + } + // 数据库找到的id列表 + List<Long> listIdFind = list.stream().map(SysDictDataPO::getId).collect(Collectors.toList()); + // 数量不一致 + if (listId.size() != listIdFind.size()) { + // 筛选数据库不存在的字典数据表 + List<Long> listIdNotFound = listId.stream().filter(c -> !listIdFind.contains(c)).collect(Collectors.toList()); + if (ListUtil.isNullOrEmpty(list)) { + return ExecutedResult.failed("[字典数据表]不存在." + listIdNotFound); + } + } + return ExecutedResult.success(list); + } + + + /** + * 获取指定类型下的字典列表(缓存) + */ + @Cacheable(cacheManager = "json4RedisCacheManager", value = "dictDataCache4Type", key = "#type") + private List<SysDictDataVO> list4TypeWithCache(String type, Function<String, List<SysDictDataVO>> funcList4Type) { + return funcList4Type.apply(type); + } + // 根据类型删除字典列表缓存 + @CacheEvict(cacheNames = "dictDataCache4Type", key = "#type") + private void removeList4TypeCache(String type) { + } + // 删除所有用户拥有的菜单缓存 + @CacheEvict(cacheNames = "dictDataCache4Type", allEntries = true) + public void removeAllTypeCache() { + } + + public List<SysDictDataVO> list4TypeWithCache(String type) { + return this.list4TypeWithCache(type, (t) -> this.getListByType(t).getData()); + } + + public Map<String, SysDictDataVO> map4TypeWithCache(String type) { + List<SysDictDataVO> list = this.list4TypeWithCache(type); + return list.stream().collect(Collectors.toMap(SysDictDataVO::getDictValue, c -> c)); + } + + public Map<String, SysDictDataVO> mapLabel4TypeWithCache(String type) { + List<SysDictDataVO> list = this.list4TypeWithCache(type); + return list.stream().collect(Collectors.toMap(SysDictDataVO::getDictLabel, c -> c)); + } +} diff --git a/src/main/java/com/fengdu/gas/service/SysDictTypeService.java b/src/main/java/com/fengdu/gas/service/SysDictTypeService.java new file mode 100644 index 0000000..aeb0ae1 --- /dev/null +++ b/src/main/java/com/fengdu/gas/service/SysDictTypeService.java @@ -0,0 +1,323 @@ +/** +# __----~~~~~~~~~~~------___ +# . . ~~//====...... __--~ ~~ +# -. \_|// |||\\ ~~~~~~::::... /~ +# ___-==_ _-~o~ \/ ||| \\ _/~~- +# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ +# _-~~ .=~ | \\-_ '-~7 /- / || \ / +# .~ .~ | \\ -_ / /- / || \ / +# / ____ / | \\ ~-_/ /|- _/ .|| \ / +# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ +# ' ~-| /| |-~\~~ __--~~ +# |-~~-_/ | | ~\_ _-~ /\ +# / \ \__ \/~ \__ +# _--~ _/ | .-~~____--~-/ ~~==. +# ((->/~ '.|||' -_| ~~-/ , . _|| +# -_ ~\ ~~---l__i__i__i--~~_/ +# _-~-__ ~) \--______________--~~ +# //.-~~~-~_--~- |-------~~~~~~~~ +# //.-~~~--\ +# 神兽保佑 +# 永无BUG! +*/ +package com.fengdu.gas.service; + +import com.fengdu.gas.repository.po.SysDictTypePO; +import com.fengdu.gas.common.ExecutedResult; +import com.fengdu.gas.common.PagerResult; +import com.fengdu.gas.common.enums.EResultCode; +import com.fengdu.gas.common.enums.EYesOrNo; +import com.fengdu.gas.common.exceptions.BusinessException; +import com.fengdu.gas.common.model.Tuple; +import com.fengdu.gas.common.util.*; +import com.fengdu.gas.entity.enums.EState; +import com.fengdu.gas.entity.request.sysdicttype.ReqCreateSysDictType; +import com.fengdu.gas.entity.request.sysdicttype.ReqModifySysDictType; +import com.fengdu.gas.entity.search.SearchSysDictType; +import com.fengdu.gas.repository.impl.SysDictDataMapperImpl; +import com.fengdu.gas.repository.impl.SysDictTypeMapperImpl; +import com.fengdu.gas.repository.vo.SysDictTypeVO; +import org.apache.commons.lang3.BooleanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; + +/** + * 字典类型表 + * @author lin.liu + * @description 字典类型表 + */ +@Service +public class SysDictTypeService extends BaseService { + @Autowired + private SysDictTypeMapperImpl mapper; + @Autowired + private SysDictDataMapperImpl sysDictDataMapper; + + public ExecutedResult<Long> create(ReqCreateSysDictType request) { + // 转换po + SysDictTypePO item = CopierUtil.mapTo(request, SysDictTypePO.class); + // 设置状态 + item.setStatus(EState.NORMAL.getValue()); + // 设置记录创建时间 + item.setCreateTime(LocalDateTimeUtil.nowTimeStamp()); + // 是否删除(逻辑删除)初始值 + item.setIsDelete(EYesOrNo.NO.getValue()); + + int rowCount = mapper.insert(item); + if (rowCount != 1) { + return ExecutedResult.failed("创建[字典类型表]失败。"); + } + return ExecutedResult.success(item.getId()); + } + + public ExecutedResult<String> modify(ReqModifySysDictType request) { + // 验证记录是否存在 + ExecutedResult<SysDictTypePO> checkExists = this.check4Id(request.getId()); + if (checkExists.isFailed()) { + return ExecutedResult.failed(checkExists.getMsg()); + } + // 转换po + SysDictTypePO item = CopierUtil.mapTo(request, SysDictTypePO.class); + + int rowCount = mapper.updateById(item); + if (rowCount != 1) { + return ExecutedResult.failed("编辑[字典类型表]失败。"); + } + return ExecutedResult.success(); + } + + public ExecutedResult<SysDictTypeVO> get(Long id) { + SysDictTypeVO result = new SysDictTypeVO(); + + SysDictTypePO find = mapper.get(id); + if (null != find) { + result = CopierUtil.mapTo(find, SysDictTypeVO.class); + } + return ExecutedResult.success(result); + } + public ExecutedResult<String> remove(Long id) { + // 验证记录是否存在 + ExecutedResult<SysDictTypePO> checkExists = this.check4Id(id); + if (checkExists.isFailed()) { + return ExecutedResult.failed(checkExists.getMsg()); + } + + Long exitCount = sysDictDataMapper.count4Type(checkExists.getData().getDictType()); + if(exitCount.compareTo(0L) > 0){ + return ExecutedResult.failed("此类型有关联的字典数据,不能删除"); + } + Boolean result = this.mapper.remove(id); + + if (BooleanUtils.isFalse(result)) { + return ExecutedResult.failed("删除[字典类型表]失败。"); + } + return ExecutedResult.success(); + } + + public ExecutedResult<String> removeList(List<Long> ids) { + // 验证记录是否存在 + ExecutedResult<List<SysDictTypePO>> checkExists = this.check4Id(ids); + if (checkExists.isFailed()) { + return ExecutedResult.failed(checkExists.getMsg()); + } + + List<String> listExitDataType = sysDictDataMapper.findExists4Type( + checkExists.getData().stream() + .map(SysDictTypePO::getDictType) + .collect(Collectors.toList()) + ); + if (ListUtil.isNotNullOrEmpty(listExitDataType)) { + return ExecutedResult.failed("以下类型有关联的字典数据,不能删除." + listExitDataType); + } + + Boolean result = mapper.remove(ids); + if (BooleanUtils.isFalse(result)) { + return ExecutedResult.failed("删除[字典类型表]失败。"); + } + return ExecutedResult.success(); + } + +// public ExecutedResult<String> stop(Long id) { +// // 验证记录是否存在 +// ExecutedResult<SysDictTypePO> checkExists = this.check4Id(id); +// if (checkExists.isFailed()) { +// return ExecutedResult.failed(checkExists.getMsg()); +// } +// SysDictTypePO item = new SysDictTypePO(); +// item.setId(id); +// item.setStatus(EState.DISABLED.getValue()); +// +// int rowCount = mapper.updateById(item); +// if (rowCount != 1) { +// return ExecutedResult.failed("停用[字典类型表]失败。"); +// } +// return ExecutedResult.success(); +// } +// +// public ExecutedResult<String> enable(Long id) { +// // 验证记录是否存在 +// ExecutedResult<SysDictTypePO> checkExists = this.check4Id(id); +// if (checkExists.isFailed()) { +// return ExecutedResult.failed(checkExists.getMsg()); +// } +// SysDictTypePO item = new SysDictTypePO(); +// item.setId(id); +// item.setStatus(EState.NORMAL.getValue()); +// +// int rowCount = mapper.updateById(item);\n" + +// if (rowCount != 1) { +// return ExecutedResult.failed("启用[字典类型表]失败。"); +// } +// return ExecutedResult.success(); +// } +// +// public ExecutedResult<String> setSort(ReqSetSort request) { +// // 验证记录是否存在 +// ExecutedResult<SysDictTypePO> checkExists = this.check4Id(request.getId()); +// if (checkExists.isFailed()) { +// return ExecutedResult.failed(checkExists.getMsg()); +// } +// SysDictTypePO item = new SysDictTypePO(); +// item.setId(request.getId()); +// item.setSort(request.getSort()); +// +// int rowCount = mapper.updateById(item);\n" + +// if (rowCount != 1) { +// return ExecutedResult.failed("设置[字典类型表]排序值失败。"); +// } +// return ExecutedResult.success(); +// } +// +// public ExecutedResult<String> listSetSort(ReqListSetSort request) { +// // id列表 +// List<Long> listId = request.getList().stream().map(ReqSetSort::getId).collect(Collectors.toList()); +// // 验证记录是否存在 +// ExecutedResult<List<SysDictTypePO>> checkExists = this.check4Id(listId); +// if (checkExists.isFailed()) { +// return ExecutedResult.failed(checkExists.getMsg()); +// } +// +// List<SysDictTypePO> listUpdate = request.getList().stream() +// .map(c -> { +// SysDictTypePO item = new SysDictTypePO(); +// item.setId(c.getId()); +// item.setSort(c.getSort()); +// return item; +// }) +// .collect(Collectors.toList()); +// Boolean result = mapper.modifyList(listUpdate); +// if (result) { +// return ExecutedResult.success(); +// } +// return ExecutedResult.failed("[字典类型表]设置排序值失败"); +// } +// +// public ExecutedResult<String> remove(Long id) { +// Boolean result = mapper.deleteLogic(id); +// if (BooleanUtils.isFalse(result)) { +// return ExecutedResult.failed("删除[字典类型表]失败。"); +// } +// return ExecutedResult.success(); +// } +// +// public ExecutedResult<String> removeList(List<Long> ids) { +// Boolean result = mapper.deleteLogic(ids); +// if (BooleanUtils.isFalse(result)) { +// return ExecutedResult.failed("删除[字典类型表]失败。"); +// } +// return ExecutedResult.success(); +// } + + public ExecutedResult<List<SysDictTypeVO>> getList(List<Long> listId) { + List<SysDictTypeVO> result = new ArrayList<>(); + + List<SysDictTypePO> list = mapper.getList(listId); + if (ListUtil.isNotNullOrEmpty(list)) { + result = CopierUtil.mapTo(list, SysDictTypeVO.class); + } + return ExecutedResult.success(result); + } + + public ExecutedResult<PagerResult<SysDictTypeVO>> search(SearchSysDictType search) { + // 处理创建时间范围-查询参数 + Tuple<String, String> createTimeRange = ParameterUtil.getTimeRange(search.getCreateTimeRange()); + if (StringUtil.isNotNullOrEmpty(createTimeRange.getItem1())) { + search.setCreateTimeStart(LocalDateTimeUtil.getTimeStamp(createTimeRange.getItem1()).getTime()); + } + if (StringUtil.isNotNullOrEmpty(createTimeRange.getItem2())) { + search.setCreateTimeEnd(LocalDateTimeUtil.getTimeStamp(createTimeRange.getItem2()).getTime()); + } + + PagerResult<SysDictTypePO> pageList = mapper.search(search); + List<SysDictTypeVO> listVo = new ArrayList<>(); + List<SysDictTypePO> list = pageList.getList(); + if (ListUtil.isNotNullOrEmpty(list)) { + pageList.setLastId(list.get(list.size() - 1).getId()); + // 转换vo + listVo = CopierUtil.mapTo(list, SysDictTypeVO.class); + } + PagerResult<SysDictTypeVO> result = new PagerResult<>(pageList.getLimit(), pageList.getPage(), pageList.getTotal(), listVo); + result.setLastId(pageList.getLastId()); + return ExecutedResult.success(result); + } + + protected ExecutedResult<SysDictTypePO> check4Id(Long id) { + SysDictTypePO exists = mapper.get(id); + if (Objects.isNull(exists)) { + return ExecutedResult.failed("[字典类型]不存在:" + id); + } + return ExecutedResult.success(exists); + } + protected SysDictTypePO check4IdExc(Long id) { + ExecutedResult<SysDictTypePO> check = this.check4Id(id); + if (check.isFailed()) { + throw new BusinessException(EResultCode.NOT_FOUND, check.getMsg()); + } + return check.getData(); + } + protected ExecutedResult<List<SysDictTypePO>> check4Id(List<Long> listId) { + // 从数据库查找字典类型表 + List<SysDictTypePO> list = mapper.getList(listId); + if (ListUtil.isNullOrEmpty(list)) { + return ExecutedResult.failed("[字典类型]不存在." + listId); + } + // 数据库找到的id列表 + List<Long> listIdFind = list.stream().map(SysDictTypePO::getId).collect(Collectors.toList()); + // 数量不一致 + if (listId.size() != listIdFind.size()) { + // 筛选数据库不存在的字典类型表 + List<Long> listIdNotFound = listId.stream().filter(c -> !listIdFind.contains(c)).collect(Collectors.toList()); + if (ListUtil.isNullOrEmpty(list)) { + return ExecutedResult.failed("[字典类型]不存在." + listIdNotFound); + } + } + return ExecutedResult.success(list); + } + protected List<SysDictTypePO> check4IdExc(List<Long> listId) { + ExecutedResult<List<SysDictTypePO>> check = this.check4Id(listId); + if (check.isFailed()) { + throw new BusinessException(EResultCode.NOT_FOUND, check.getMsg()); + } + return check.getData(); + } + + protected ExecutedResult<SysDictTypePO> check4Type(String type) { + SysDictTypePO exists = mapper.get4Type(type); + if (Objects.isNull(exists)) { + return ExecutedResult.failed("[字典类型]不存在:" + type); + } + return ExecutedResult.success(exists); + } + protected SysDictTypePO check4TypeExc(String type) { + ExecutedResult<SysDictTypePO> check = this.check4Type(type); + if (check.isFailed()) { + throw new BusinessException(EResultCode.NOT_FOUND, check.getMsg()); + } + return check.getData(); + } +} diff --git a/src/main/java/com/fengdu/gas/service/TestInfoService.java b/src/main/java/com/fengdu/gas/service/TestInfoService.java new file mode 100644 index 0000000..efb660d --- /dev/null +++ b/src/main/java/com/fengdu/gas/service/TestInfoService.java @@ -0,0 +1,250 @@ +package com.fengdu.gas.service; + +import com.fengdu.gas.repository.po.TestInfoPO; +import com.fengdu.gas.service.convert.TestInfoConvert; +import com.fengdu.gas.common.ExecutedResult; +import com.fengdu.gas.common.PagerResult; +import com.fengdu.gas.common.enums.EYesOrNo; +import com.fengdu.gas.common.model.Tuple; +import com.fengdu.gas.common.util.*; +import com.fengdu.gas.entity.enums.EState; +import com.fengdu.gas.entity.request.ReqListSetSort; +import com.fengdu.gas.entity.request.ReqSetSort; +import com.fengdu.gas.entity.request.test.ReqCreateTestInfo; +import com.fengdu.gas.entity.request.test.ReqModifyTestInfo; +import com.fengdu.gas.entity.search.SearchTestInfo; +import com.fengdu.gas.repository.impl.TestInfoMapperImpl; +import com.fengdu.gas.repository.vo.TestInfoVO; +import org.apache.commons.lang3.BooleanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * 测试信息 相关服务 + */ +@Service +public class TestInfoService extends BaseService { + @Autowired + private TestInfoMapperImpl mapper; + + public ExecutedResult<Long> create(ReqCreateTestInfo request) { + // 转换po + TestInfoPO item = TestInfoConvert.INSTANCE.toCreate(request); + // 设置状态 + item.setStatus(EState.NORMAL.getValue()); + // 设置记录创建时间 + item.setCreateTime(LocalDateTimeUtil.nowTimeStamp()); + // 非逻辑删除 + item.setIsDelete(EYesOrNo.NO.getValue()); + + int rowCount = mapper.insert(item); + if (rowCount != 1) { + return ExecutedResult.failed("创建[测试信息]失败。"); + } + return ExecutedResult.success(item.getId()); + } + + public ExecutedResult<String> modify(ReqModifyTestInfo request) { + // 验证记录是否存在 + ExecutedResult<TestInfoPO> checkExists = this.check4Id(request.getId()); + if (checkExists.isFailed()) { + return ExecutedResult.failed(checkExists.getMsg()); + } + + // 转换po + TestInfoPO item = TestInfoConvert.INSTANCE.toModify(request); + + int rowCount = mapper.updateById(item); + if (rowCount != 1) { + return ExecutedResult.failed("编辑[测试信息]失败。"); + } + return ExecutedResult.success(); + } + + public ExecutedResult<TestInfoVO> get(Long id) { + TestInfoVO result = new TestInfoVO(); + + TestInfoPO find = mapper.selectById(id); + if (null != find) { + result = TestInfoConvert.INSTANCE.toVo(find); + } + return ExecutedResult.success(result); + } + + public ExecutedResult<String> stop(Long id) { + // 验证记录是否存在 + ExecutedResult<TestInfoPO> checkExists = this.check4Id(id); + if (checkExists.isFailed()) { + return ExecutedResult.failed(checkExists.getMsg()); + } + + TestInfoPO item = new TestInfoPO(); + item.setId(id); + item.setStatus(EState.DISABLED.getValue()); + + int rowCount = mapper.updateById(item); + if (rowCount != 1) { + return ExecutedResult.failed("停用[测试信息]失败。"); + } + return ExecutedResult.success(); + } + + public ExecutedResult<String> enable(Long id) { + // 验证记录是否存在 + ExecutedResult<TestInfoPO> checkExists = this.check4Id(id); + if (checkExists.isFailed()) { + return ExecutedResult.failed(checkExists.getMsg()); + } + + TestInfoPO item = new TestInfoPO(); + item.setId(id); + item.setStatus(EState.NORMAL.getValue()); + + int rowCount = mapper.updateById(item); + if (rowCount != 1) { + return ExecutedResult.failed("启用[测试信息]失败。"); + } + return ExecutedResult.success(); + } + + public ExecutedResult<String> setSort(ReqSetSort request) { + // 验证记录是否存在 + ExecutedResult<TestInfoPO> checkExists = this.check4Id(request.getId()); + if (checkExists.isFailed()) { + return ExecutedResult.failed(checkExists.getMsg()); + } + + TestInfoPO item = new TestInfoPO(); + item.setId(request.getId()); + item.setSort(request.getSort()); + + int rowCount = mapper.updateById(item); + if (rowCount != 1) { + return ExecutedResult.failed("[测试信息]设置排序值失败。"); + } + return ExecutedResult.success(); + } + + public ExecutedResult<String> listSetSort(ReqListSetSort request) { + // id列表 + List<Long> listId = request.getList().stream().map(ReqSetSort::getId).collect(Collectors.toList()); + // 验证记录是否存在 + ExecutedResult<List<TestInfoPO>> checkExists = this.check4Id(listId); + if (checkExists.isFailed()) { + return ExecutedResult.failed(checkExists.getMsg()); + } + + List<TestInfoPO> listUpdate = request.getList().stream() + .map(c -> { + TestInfoPO item = new TestInfoPO(); + item.setId(c.getId()); + item.setSort(c.getSort()); + return item; + }) + .collect(Collectors.toList()); + Boolean result = mapper.modifyList(listUpdate); + if (result) { + return ExecutedResult.success(); + } + return ExecutedResult.failed("[测试信息]设置排序值失败"); + } + + public ExecutedResult<String> remove(Long id) { + // 验证记录是否存在 + ExecutedResult<TestInfoPO> checkExists = this.check4Id(id); + if (checkExists.isFailed()) { + return ExecutedResult.failed(checkExists.getMsg()); + } + + Boolean result = mapper.deleteLogic(id); + if (BooleanUtils.isFalse(result)) { + return ExecutedResult.failed("删除[测试信息]失败。"); + } + return ExecutedResult.success(); + } + + public ExecutedResult<String> removeList(List<Long> listId) { + // 验证记录是否存在 + ExecutedResult<List<TestInfoPO>> checkExists = this.check4Id(listId); + if (checkExists.isFailed()) { + return ExecutedResult.failed(checkExists.getMsg()); + } + + Boolean result = mapper.deleteLogic(listId); + if (BooleanUtils.isFalse(result)) { + return ExecutedResult.failed("删除[测试信息]失败。"); + } + return ExecutedResult.success(); + } + + public ExecutedResult<List<TestInfoVO>> getList(List<Long> listId) { + List<TestInfoVO> result = new ArrayList<>(); + + List<TestInfoPO> list = mapper.getList(listId); + if (ListUtil.isNotNullOrEmpty(list)) { + result = CopierUtil.mapTo(list, TestInfoVO.class); + } + return ExecutedResult.success(result); + } + + public ExecutedResult<PagerResult<TestInfoVO>> search(SearchTestInfo search) { + // 处理创建时间范围-查询参数 + Tuple<String, String> createTimeRange = ParameterUtil.getTimeRange(search.getCreateTimeRange()); + if (StringUtil.isNotNullOrEmpty(createTimeRange.getItem1())) { + search.setCreateTimeStart(LocalDateTimeUtil.getTimeStamp(createTimeRange.getItem1()).getTime()); + } + if (StringUtil.isNotNullOrEmpty(createTimeRange.getItem2())) { + search.setCreateTimeEnd(LocalDateTimeUtil.getTimeStamp(createTimeRange.getItem2()).getTime()); + } + + PagerResult<TestInfoPO> pageList = mapper.search(search); + List<TestInfoVO> listVo = new ArrayList<>(); + List<TestInfoPO> list = pageList.getList(); + if (ListUtil.isNotNullOrEmpty(list)) { + pageList.setLastId(list.get(list.size() - 1).getId()); + // 转换vo + listVo = TestInfoConvert.INSTANCE.toVo(list); + } + PagerResult<TestInfoVO> result = new PagerResult<>(pageList.getLimit(), pageList.getPage(), pageList.getTotal(), listVo); + result.setLastId(pageList.getLastId()); + return ExecutedResult.success(result); + } + + protected ExecutedResult<TestInfoPO> check4Id(Long id) { + TestInfoPO exists = mapper.get(id); + if (Objects.isNull(exists)) { + return ExecutedResult.failed("[测试信息]不存在:" + id); + } + return ExecutedResult.success(exists); + } + protected ExecutedResult<List<TestInfoPO>> check4Id(List<Long> listId) { + // 从数据库查找测试信息 + List<TestInfoPO> list = mapper.getList(listId); + if (ListUtil.isNullOrEmpty(list)) { + return ExecutedResult.failed("[测试信息]不存在." + listId); + } + // 数据库找到的id列表 + List<Long> listIdFind = list.stream().map(TestInfoPO::getId).collect(Collectors.toList()); + // 数量不一致 + if (listId.size() != listIdFind.size()) { + // 筛选数据库不存在的测试信息 + List<Long> listIdNotFound = listId.stream().filter(c -> !listIdFind.contains(c)).collect(Collectors.toList()); + if (ListUtil.isNullOrEmpty(list)) { + return ExecutedResult.failed("[测试信息]不存在." + listIdNotFound); + } + } + return ExecutedResult.success(list); + } + + protected Map<Long, TestInfoPO> getMap4Id(List<Long> listId) { + List<TestInfoPO> list = mapper.getList(listId); + if (ListUtil.isNullOrEmpty(list)) { + return new HashMap<>(0); + } + return list.stream().collect(Collectors.toMap(TestInfoPO::getId, c -> c)); + } + +} diff --git a/src/main/java/com/fengdu/gas/service/convert/AdminMenuConvert.java b/src/main/java/com/fengdu/gas/service/convert/AdminMenuConvert.java new file mode 100644 index 0000000..f6e052c --- /dev/null +++ b/src/main/java/com/fengdu/gas/service/convert/AdminMenuConvert.java @@ -0,0 +1,51 @@ +/** +# __----~~~~~~~~~~~------___ +# . . ~~//====...... __--~ ~~ +# -. \_|// |||\\ ~~~~~~::::... /~ +# ___-==_ _-~o~ \/ ||| \\ _/~~- +# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ +# _-~~ .=~ | \\-_ '-~7 /- / || \ / +# .~ .~ | \\ -_ / /- / || \ / +# / ____ / | \\ ~-_/ /|- _/ .|| \ / +# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ +# ' ~-| /| |-~\~~ __--~~ +# |-~~-_/ | | ~\_ _-~ /\ +# / \ \__ \/~ \__ +# _--~ _/ | .-~~____--~-/ ~~==. +# ((->/~ '.|||' -_| ~~-/ , . _|| +# -_ ~\ ~~---l__i__i__i--~~_/ +# _-~-__ ~) \--______________--~~ +# //.-~~~-~_--~- |-------~~~~~~~~ +# //.-~~~--\ +# 神兽保佑 +# 永无BUG! +*/ +package com.fengdu.gas.service.convert; + +import com.fengdu.gas.repository.po.AdminMenuPO; +import com.fengdu.gas.entity.request.adminmenu.ReqCreateAdminMenu; +import com.fengdu.gas.entity.request.adminmenu.ReqModifyAdminMenu; +import com.fengdu.gas.entity.response.admin.ResAdminMenuTreeAndPermission; +import com.fengdu.gas.repository.vo.AdminMenuVO; +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + +import java.util.List; + +/** + * 后台菜单 + * @author {#=author} + * @description 后台菜单 + */ +@Mapper +public interface AdminMenuConvert { + AdminMenuConvert INSTANCE = Mappers.getMapper(AdminMenuConvert.class); + + AdminMenuPO toCreate(ReqCreateAdminMenu request); + AdminMenuPO toModify(ReqModifyAdminMenu request); + + AdminMenuVO toVo(AdminMenuPO item); + List<AdminMenuVO> toVo(List<AdminMenuPO> list); + + ResAdminMenuTreeAndPermission toTreeVo(AdminMenuPO item); +} diff --git a/src/main/java/com/fengdu/gas/service/convert/AdminMenusConvert.java b/src/main/java/com/fengdu/gas/service/convert/AdminMenusConvert.java new file mode 100644 index 0000000..a84ee1e --- /dev/null +++ b/src/main/java/com/fengdu/gas/service/convert/AdminMenusConvert.java @@ -0,0 +1,48 @@ +/** +# __----~~~~~~~~~~~------___ +# . . ~~//====...... __--~ ~~ +# -. \_|// |||\\ ~~~~~~::::... /~ +# ___-==_ _-~o~ \/ ||| \\ _/~~- +# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ +# _-~~ .=~ | \\-_ '-~7 /- / || \ / +# .~ .~ | \\ -_ / /- / || \ / +# / ____ / | \\ ~-_/ /|- _/ .|| \ / +# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ +# ' ~-| /| |-~\~~ __--~~ +# |-~~-_/ | | ~\_ _-~ /\ +# / \ \__ \/~ \__ +# _--~ _/ | .-~~____--~-/ ~~==. +# ((->/~ '.|||' -_| ~~-/ , . _|| +# -_ ~\ ~~---l__i__i__i--~~_/ +# _-~-__ ~) \--______________--~~ +# //.-~~~-~_--~- |-------~~~~~~~~ +# //.-~~~--\ +# 神兽保佑 +# 永无BUG! +*/ +package com.fengdu.gas.service.convert; + +import com.fengdu.gas.entity.request.adminmenus.ReqCreateAdminMenus; +import com.fengdu.gas.entity.request.adminmenus.ReqModifyAdminMenus; +import com.fengdu.gas.repository.po.AdminMenusPO; +import com.fengdu.gas.repository.vo.AdminMenusVO; + +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + +import java.util.List; + +/** + * 菜单信息 + * @author {#=author} + */ +@Mapper +public interface AdminMenusConvert { + AdminMenusConvert INSTANCE = Mappers.getMapper(AdminMenusConvert.class); + + AdminMenusPO toCreate(ReqCreateAdminMenus request); + AdminMenusPO toModify(ReqModifyAdminMenus request); + + AdminMenusVO toVo(AdminMenusPO item); + List<AdminMenusVO> toVo(List<AdminMenusPO> list); +} diff --git a/src/main/java/com/fengdu/gas/service/convert/AdminPermissionConvert.java b/src/main/java/com/fengdu/gas/service/convert/AdminPermissionConvert.java new file mode 100644 index 0000000..c0f36bf --- /dev/null +++ b/src/main/java/com/fengdu/gas/service/convert/AdminPermissionConvert.java @@ -0,0 +1,52 @@ +/** +# __----~~~~~~~~~~~------___ +# . . ~~//====...... __--~ ~~ +# -. \_|// |||\\ ~~~~~~::::... /~ +# ___-==_ _-~o~ \/ ||| \\ _/~~- +# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ +# _-~~ .=~ | \\-_ '-~7 /- / || \ / +# .~ .~ | \\ -_ / /- / || \ / +# / ____ / | \\ ~-_/ /|- _/ .|| \ / +# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ +# ' ~-| /| |-~\~~ __--~~ +# |-~~-_/ | | ~\_ _-~ /\ +# / \ \__ \/~ \__ +# _--~ _/ | .-~~____--~-/ ~~==. +# ((->/~ '.|||' -_| ~~-/ , . _|| +# -_ ~\ ~~---l__i__i__i--~~_/ +# _-~-__ ~) \--______________--~~ +# //.-~~~-~_--~- |-------~~~~~~~~ +# //.-~~~--\ +# 神兽保佑 +# 永无BUG! +*/ +package com.fengdu.gas.service.convert; + +import com.fengdu.gas.repository.po.AdminPermissionPO; +import com.fengdu.gas.entity.request.adminpermission.ReqCreateAdminPermission; +import com.fengdu.gas.entity.request.adminpermission.ReqModifyAdminPermission; +import com.fengdu.gas.entity.response.admin.ResAdminPermission; +import com.fengdu.gas.repository.vo.AdminPermissionVO; +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + +import java.util.List; + +/** + * 后台用户权限表 + * @author {#=author} + * @description 后台用户权限表 + */ +@Mapper +public interface AdminPermissionConvert { + AdminPermissionConvert INSTANCE = Mappers.getMapper(AdminPermissionConvert.class); + + AdminPermissionPO toCreate(ReqCreateAdminPermission request); + AdminPermissionPO toModify(ReqModifyAdminPermission request); + + AdminPermissionVO toVo(AdminPermissionPO item); + List<AdminPermissionVO> toVo(List<AdminPermissionPO> list); + + ResAdminPermission toDetail(AdminPermissionPO item); + List<ResAdminPermission> toDetail(List<AdminPermissionPO> list); +} diff --git a/src/main/java/com/fengdu/gas/service/convert/AdminRoleConvert.java b/src/main/java/com/fengdu/gas/service/convert/AdminRoleConvert.java new file mode 100644 index 0000000..ab0a0ed --- /dev/null +++ b/src/main/java/com/fengdu/gas/service/convert/AdminRoleConvert.java @@ -0,0 +1,48 @@ +/** +# __----~~~~~~~~~~~------___ +# . . ~~//====...... __--~ ~~ +# -. \_|// |||\\ ~~~~~~::::... /~ +# ___-==_ _-~o~ \/ ||| \\ _/~~- +# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ +# _-~~ .=~ | \\-_ '-~7 /- / || \ / +# .~ .~ | \\ -_ / /- / || \ / +# / ____ / | \\ ~-_/ /|- _/ .|| \ / +# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ +# ' ~-| /| |-~\~~ __--~~ +# |-~~-_/ | | ~\_ _-~ /\ +# / \ \__ \/~ \__ +# _--~ _/ | .-~~____--~-/ ~~==. +# ((->/~ '.|||' -_| ~~-/ , . _|| +# -_ ~\ ~~---l__i__i__i--~~_/ +# _-~-__ ~) \--______________--~~ +# //.-~~~-~_--~- |-------~~~~~~~~ +# //.-~~~--\ +# 神兽保佑 +# 永无BUG! +*/ +package com.fengdu.gas.service.convert; + +import com.fengdu.gas.repository.po.AdminRolePO; +import com.fengdu.gas.entity.request.adminrole.ReqCreateAdminRole; +import com.fengdu.gas.entity.request.adminrole.ReqModifyAdminRole; +import com.fengdu.gas.repository.vo.AdminRoleVO; +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + +import java.util.List; + +/** + * 后台用户角色表 + * @author {#=author} + * @description 后台用户角色表 + */ +@Mapper +public interface AdminRoleConvert { + AdminRoleConvert INSTANCE = Mappers.getMapper(AdminRoleConvert.class); + + AdminRolePO toCreate(ReqCreateAdminRole request); + AdminRolePO toModify(ReqModifyAdminRole request); + + AdminRoleVO toVo(AdminRolePO item); + List<AdminRoleVO> toVo(List<AdminRolePO> list); +} diff --git a/src/main/java/com/fengdu/gas/service/convert/AdminRoleMenuRelationConvert.java b/src/main/java/com/fengdu/gas/service/convert/AdminRoleMenuRelationConvert.java new file mode 100644 index 0000000..9283aed --- /dev/null +++ b/src/main/java/com/fengdu/gas/service/convert/AdminRoleMenuRelationConvert.java @@ -0,0 +1,48 @@ +/** +# __----~~~~~~~~~~~------___ +# . . ~~//====...... __--~ ~~ +# -. \_|// |||\\ ~~~~~~::::... /~ +# ___-==_ _-~o~ \/ ||| \\ _/~~- +# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ +# _-~~ .=~ | \\-_ '-~7 /- / || \ / +# .~ .~ | \\ -_ / /- / || \ / +# / ____ / | \\ ~-_/ /|- _/ .|| \ / +# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ +# ' ~-| /| |-~\~~ __--~~ +# |-~~-_/ | | ~\_ _-~ /\ +# / \ \__ \/~ \__ +# _--~ _/ | .-~~____--~-/ ~~==. +# ((->/~ '.|||' -_| ~~-/ , . _|| +# -_ ~\ ~~---l__i__i__i--~~_/ +# _-~-__ ~) \--______________--~~ +# //.-~~~-~_--~- |-------~~~~~~~~ +# //.-~~~--\ +# 神兽保佑 +# 永无BUG! +*/ +package com.fengdu.gas.service.convert; + +import com.fengdu.gas.repository.po.AdminRoleMenuRelationPO; +import com.fengdu.gas.entity.request.adminrolemenurelation.ReqCreateAdminRoleMenuRelation; +import com.fengdu.gas.entity.request.adminrolemenurelation.ReqModifyAdminRoleMenuRelation; +import com.fengdu.gas.repository.vo.AdminRoleMenuRelationVO; +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + +import java.util.List; + +/** + * 后台角色菜单关系表 + * @author {#=author} + * @description 后台角色菜单关系表 + */ +@Mapper +public interface AdminRoleMenuRelationConvert { + AdminRoleMenuRelationConvert INSTANCE = Mappers.getMapper(AdminRoleMenuRelationConvert.class); + + AdminRoleMenuRelationPO toCreate(ReqCreateAdminRoleMenuRelation request); + AdminRoleMenuRelationPO toModify(ReqModifyAdminRoleMenuRelation request); + + AdminRoleMenuRelationVO toVo(AdminRoleMenuRelationPO item); + List<AdminRoleMenuRelationVO> toVo(List<AdminRoleMenuRelationPO> list); +} diff --git a/src/main/java/com/fengdu/gas/service/convert/AdminRolePermissionRelationConvert.java b/src/main/java/com/fengdu/gas/service/convert/AdminRolePermissionRelationConvert.java new file mode 100644 index 0000000..da571c9 --- /dev/null +++ b/src/main/java/com/fengdu/gas/service/convert/AdminRolePermissionRelationConvert.java @@ -0,0 +1,48 @@ +/** +# __----~~~~~~~~~~~------___ +# . . ~~//====...... __--~ ~~ +# -. \_|// |||\\ ~~~~~~::::... /~ +# ___-==_ _-~o~ \/ ||| \\ _/~~- +# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ +# _-~~ .=~ | \\-_ '-~7 /- / || \ / +# .~ .~ | \\ -_ / /- / || \ / +# / ____ / | \\ ~-_/ /|- _/ .|| \ / +# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ +# ' ~-| /| |-~\~~ __--~~ +# |-~~-_/ | | ~\_ _-~ /\ +# / \ \__ \/~ \__ +# _--~ _/ | .-~~____--~-/ ~~==. +# ((->/~ '.|||' -_| ~~-/ , . _|| +# -_ ~\ ~~---l__i__i__i--~~_/ +# _-~-__ ~) \--______________--~~ +# //.-~~~-~_--~- |-------~~~~~~~~ +# //.-~~~--\ +# 神兽保佑 +# 永无BUG! +*/ +package com.fengdu.gas.service.convert; + +import com.fengdu.gas.repository.po.AdminRolePermissionRelationPO; +import com.fengdu.gas.entity.request.adminrolepermissionrelation.ReqCreateAdminRolePermissionRelation; +import com.fengdu.gas.entity.request.adminrolepermissionrelation.ReqModifyAdminRolePermissionRelation; +import com.fengdu.gas.repository.vo.AdminRolePermissionRelationVO; +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + +import java.util.List; + +/** + * 后台角色权限关系表 + * @author {#=author} + * @description 后台角色权限关系表 + */ +@Mapper +public interface AdminRolePermissionRelationConvert { + AdminRolePermissionRelationConvert INSTANCE = Mappers.getMapper(AdminRolePermissionRelationConvert.class); + + AdminRolePermissionRelationPO toCreate(ReqCreateAdminRolePermissionRelation request); + AdminRolePermissionRelationPO toModify(ReqModifyAdminRolePermissionRelation request); + + AdminRolePermissionRelationVO toVo(AdminRolePermissionRelationPO item); + List<AdminRolePermissionRelationVO> toVo(List<AdminRolePermissionRelationPO> list); +} diff --git a/src/main/java/com/fengdu/gas/service/convert/AdminRoleRelationConvert.java b/src/main/java/com/fengdu/gas/service/convert/AdminRoleRelationConvert.java new file mode 100644 index 0000000..10eeb02 --- /dev/null +++ b/src/main/java/com/fengdu/gas/service/convert/AdminRoleRelationConvert.java @@ -0,0 +1,48 @@ +/** +# __----~~~~~~~~~~~------___ +# . . ~~//====...... __--~ ~~ +# -. \_|// |||\\ ~~~~~~::::... /~ +# ___-==_ _-~o~ \/ ||| \\ _/~~- +# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ +# _-~~ .=~ | \\-_ '-~7 /- / || \ / +# .~ .~ | \\ -_ / /- / || \ / +# / ____ / | \\ ~-_/ /|- _/ .|| \ / +# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ +# ' ~-| /| |-~\~~ __--~~ +# |-~~-_/ | | ~\_ _-~ /\ +# / \ \__ \/~ \__ +# _--~ _/ | .-~~____--~-/ ~~==. +# ((->/~ '.|||' -_| ~~-/ , . _|| +# -_ ~\ ~~---l__i__i__i--~~_/ +# _-~-__ ~) \--______________--~~ +# //.-~~~-~_--~- |-------~~~~~~~~ +# //.-~~~--\ +# 神兽保佑 +# 永无BUG! +*/ +package com.fengdu.gas.service.convert; + +import com.fengdu.gas.repository.po.AdminRoleRelationPO; +import com.fengdu.gas.entity.request.adminrolerelation.ReqCreateAdminRoleRelation; +import com.fengdu.gas.entity.request.adminrolerelation.ReqModifyAdminRoleRelation; +import com.fengdu.gas.repository.vo.AdminRoleRelationVO; +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + +import java.util.List; + +/** + * 后台用户和角色关系表 + * @author {#=author} + * @description 后台用户和角色关系表 + */ +@Mapper +public interface AdminRoleRelationConvert { + AdminRoleRelationConvert INSTANCE = Mappers.getMapper(AdminRoleRelationConvert.class); + + AdminRoleRelationPO toCreate(ReqCreateAdminRoleRelation request); + AdminRoleRelationPO toModify(ReqModifyAdminRoleRelation request); + + AdminRoleRelationVO toVo(AdminRoleRelationPO item); + List<AdminRoleRelationVO> toVo(List<AdminRoleRelationPO> list); +} diff --git a/src/main/java/com/fengdu/gas/service/convert/AdminUserConvert.java b/src/main/java/com/fengdu/gas/service/convert/AdminUserConvert.java new file mode 100644 index 0000000..26e78bc --- /dev/null +++ b/src/main/java/com/fengdu/gas/service/convert/AdminUserConvert.java @@ -0,0 +1,53 @@ +/** +# __----~~~~~~~~~~~------___ +# . . ~~//====...... __--~ ~~ +# -. \_|// |||\\ ~~~~~~::::... /~ +# ___-==_ _-~o~ \/ ||| \\ _/~~- +# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ +# _-~~ .=~ | \\-_ '-~7 /- / || \ / +# .~ .~ | \\ -_ / /- / || \ / +# / ____ / | \\ ~-_/ /|- _/ .|| \ / +# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ +# ' ~-| /| |-~\~~ __--~~ +# |-~~-_/ | | ~\_ _-~ /\ +# / \ \__ \/~ \__ +# _--~ _/ | .-~~____--~-/ ~~==. +# ((->/~ '.|||' -_| ~~-/ , . _|| +# -_ ~\ ~~---l__i__i__i--~~_/ +# _-~-__ ~) \--______________--~~ +# //.-~~~-~_--~- |-------~~~~~~~~ +# //.-~~~--\ +# 神兽保佑 +# 永无BUG! +*/ +package com.fengdu.gas.service.convert; + +import com.fengdu.gas.repository.po.AdminUserPO; +import com.fengdu.gas.entity.request.adminuser.ReqCreateAdminUser; +import com.fengdu.gas.entity.request.adminuser.ReqModifyAdminUser; +import com.fengdu.gas.repository.vo.AdminUserVO; +import com.fengdu.gas.service.dto.ResAdminDetail; +import org.mapstruct.Mapper; +import org.mapstruct.Named; +import org.mapstruct.factory.Mappers; + +import java.util.List; + +/** + * 管理员帐号 + * @author {#=author} + * @description 管理员帐号 + */ +@Mapper +public interface AdminUserConvert { + AdminUserConvert INSTANCE = Mappers.getMapper(AdminUserConvert.class); + + AdminUserPO toCreate(ReqCreateAdminUser request); + AdminUserPO toModify(ReqModifyAdminUser request); + + AdminUserVO toVo(AdminUserPO item); + List<AdminUserVO> toVo(List<AdminUserPO> list); + + @Named("toDetail") + ResAdminDetail toDetail(AdminUserPO data); +} diff --git a/src/main/java/com/fengdu/gas/service/convert/NoticeConvert.java b/src/main/java/com/fengdu/gas/service/convert/NoticeConvert.java new file mode 100644 index 0000000..77d8568 --- /dev/null +++ b/src/main/java/com/fengdu/gas/service/convert/NoticeConvert.java @@ -0,0 +1,48 @@ +/** +# __----~~~~~~~~~~~------___ +# . . ~~//====...... __--~ ~~ +# -. \_|// |||\\ ~~~~~~::::... /~ +# ___-==_ _-~o~ \/ ||| \\ _/~~- +# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ +# _-~~ .=~ | \\-_ '-~7 /- / || \ / +# .~ .~ | \\ -_ / /- / || \ / +# / ____ / | \\ ~-_/ /|- _/ .|| \ / +# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ +# ' ~-| /| |-~\~~ __--~~ +# |-~~-_/ | | ~\_ _-~ /\ +# / \ \__ \/~ \__ +# _--~ _/ | .-~~____--~-/ ~~==. +# ((->/~ '.|||' -_| ~~-/ , . _|| +# -_ ~\ ~~---l__i__i__i--~~_/ +# _-~-__ ~) \--______________--~~ +# //.-~~~-~_--~- |-------~~~~~~~~ +# //.-~~~--\ +# 神兽保佑 +# 永无BUG! +*/ +package com.fengdu.gas.service.convert; + +import com.fengdu.gas.entity.request.notice.ReqCreateNotice; +import com.fengdu.gas.entity.request.notice.ReqModifyNotice; +import com.fengdu.gas.repository.po.NoticePO; +import com.fengdu.gas.repository.vo.NoticeVO; +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + +import java.util.List; + +/** + * 公告 + * @author {#=author} + * @description 公告 + */ +@Mapper +public interface NoticeConvert { + NoticeConvert INSTANCE = Mappers.getMapper(NoticeConvert.class); + + NoticePO toCreate(ReqCreateNotice request); + NoticePO toModify(ReqModifyNotice request); + + NoticeVO toVo(NoticePO item); + List<NoticeVO> toVo(List<NoticePO> list); +} diff --git a/src/main/java/com/fengdu/gas/service/convert/QuartzTaskErrorConvert.java b/src/main/java/com/fengdu/gas/service/convert/QuartzTaskErrorConvert.java new file mode 100644 index 0000000..2736476 --- /dev/null +++ b/src/main/java/com/fengdu/gas/service/convert/QuartzTaskErrorConvert.java @@ -0,0 +1,48 @@ +/** +# __----~~~~~~~~~~~------___ +# . . ~~//====...... __--~ ~~ +# -. \_|// |||\\ ~~~~~~::::... /~ +# ___-==_ _-~o~ \/ ||| \\ _/~~- +# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ +# _-~~ .=~ | \\-_ '-~7 /- / || \ / +# .~ .~ | \\ -_ / /- / || \ / +# / ____ / | \\ ~-_/ /|- _/ .|| \ / +# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ +# ' ~-| /| |-~\~~ __--~~ +# |-~~-_/ | | ~\_ _-~ /\ +# / \ \__ \/~ \__ +# _--~ _/ | .-~~____--~-/ ~~==. +# ((->/~ '.|||' -_| ~~-/ , . _|| +# -_ ~\ ~~---l__i__i__i--~~_/ +# _-~-__ ~) \--______________--~~ +# //.-~~~-~_--~- |-------~~~~~~~~ +# //.-~~~--\ +# 神兽保佑 +# 永无BUG! +*/ +package com.fengdu.gas.service.convert; + +import com.fengdu.gas.repository.po.QuartzTaskErrorPO; +import com.fengdu.gas.entity.request.quartztaskerror.ReqCreateQuartzTaskError; +import com.fengdu.gas.entity.request.quartztaskerror.ReqModifyQuartzTaskError; +import com.fengdu.gas.repository.vo.QuartzTaskErrorVO; +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + +import java.util.List; + +/** + * 定时任务错误信息 + * @author {#=author} + * @description 定时任务错误信息 + */ +@Mapper +public interface QuartzTaskErrorConvert { + QuartzTaskErrorConvert INSTANCE = Mappers.getMapper(QuartzTaskErrorConvert.class); + + QuartzTaskErrorPO toCreate(ReqCreateQuartzTaskError request); + QuartzTaskErrorPO toModify(ReqModifyQuartzTaskError request); + + QuartzTaskErrorVO toVo(QuartzTaskErrorPO item); + List<QuartzTaskErrorVO> toVo(List<QuartzTaskErrorPO> list); +} diff --git a/src/main/java/com/fengdu/gas/service/convert/QuartzTaskInfoConvert.java b/src/main/java/com/fengdu/gas/service/convert/QuartzTaskInfoConvert.java new file mode 100644 index 0000000..95aef52 --- /dev/null +++ b/src/main/java/com/fengdu/gas/service/convert/QuartzTaskInfoConvert.java @@ -0,0 +1,48 @@ +/** +# __----~~~~~~~~~~~------___ +# . . ~~//====...... __--~ ~~ +# -. \_|// |||\\ ~~~~~~::::... /~ +# ___-==_ _-~o~ \/ ||| \\ _/~~- +# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ +# _-~~ .=~ | \\-_ '-~7 /- / || \ / +# .~ .~ | \\ -_ / /- / || \ / +# / ____ / | \\ ~-_/ /|- _/ .|| \ / +# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ +# ' ~-| /| |-~\~~ __--~~ +# |-~~-_/ | | ~\_ _-~ /\ +# / \ \__ \/~ \__ +# _--~ _/ | .-~~____--~-/ ~~==. +# ((->/~ '.|||' -_| ~~-/ , . _|| +# -_ ~\ ~~---l__i__i__i--~~_/ +# _-~-__ ~) \--______________--~~ +# //.-~~~-~_--~- |-------~~~~~~~~ +# //.-~~~--\ +# 神兽保佑 +# 永无BUG! +*/ +package com.fengdu.gas.service.convert; + +import com.fengdu.gas.repository.po.QuartzTaskInfoPO; +import com.fengdu.gas.entity.request.quartztaskinfo.ReqCreateQuartzTaskInfo; +import com.fengdu.gas.entity.request.quartztaskinfo.ReqModifyQuartzTaskInfo; +import com.fengdu.gas.repository.vo.QuartzTaskInfoVO; +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + +import java.util.List; + +/** + * 定时任务信息 + * @author {#=author} + * @description 定时任务信息 + */ +@Mapper +public interface QuartzTaskInfoConvert { + QuartzTaskInfoConvert INSTANCE = Mappers.getMapper(QuartzTaskInfoConvert.class); + + QuartzTaskInfoPO toCreate(ReqCreateQuartzTaskInfo request); + QuartzTaskInfoPO toModify(ReqModifyQuartzTaskInfo request); + + QuartzTaskInfoVO toVo(QuartzTaskInfoPO item); + List<QuartzTaskInfoVO> toVo(List<QuartzTaskInfoPO> list); +} diff --git a/src/main/java/com/fengdu/gas/service/convert/QuartzTaskRecordConvert.java b/src/main/java/com/fengdu/gas/service/convert/QuartzTaskRecordConvert.java new file mode 100644 index 0000000..c384120 --- /dev/null +++ b/src/main/java/com/fengdu/gas/service/convert/QuartzTaskRecordConvert.java @@ -0,0 +1,48 @@ +/** +# __----~~~~~~~~~~~------___ +# . . ~~//====...... __--~ ~~ +# -. \_|// |||\\ ~~~~~~::::... /~ +# ___-==_ _-~o~ \/ ||| \\ _/~~- +# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ +# _-~~ .=~ | \\-_ '-~7 /- / || \ / +# .~ .~ | \\ -_ / /- / || \ / +# / ____ / | \\ ~-_/ /|- _/ .|| \ / +# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ +# ' ~-| /| |-~\~~ __--~~ +# |-~~-_/ | | ~\_ _-~ /\ +# / \ \__ \/~ \__ +# _--~ _/ | .-~~____--~-/ ~~==. +# ((->/~ '.|||' -_| ~~-/ , . _|| +# -_ ~\ ~~---l__i__i__i--~~_/ +# _-~-__ ~) \--______________--~~ +# //.-~~~-~_--~- |-------~~~~~~~~ +# //.-~~~--\ +# 神兽保佑 +# 永无BUG! +*/ +package com.fengdu.gas.service.convert; + +import com.fengdu.gas.repository.po.QuartzTaskRecordPO; +import com.fengdu.gas.entity.request.quartztaskrecord.ReqCreateQuartzTaskRecord; +import com.fengdu.gas.entity.request.quartztaskrecord.ReqModifyQuartzTaskRecord; +import com.fengdu.gas.repository.vo.QuartzTaskRecordVO; +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + +import java.util.List; + +/** + * 定时任务执行记录 + * @author {#=author} + * @description 定时任务执行记录 + */ +@Mapper +public interface QuartzTaskRecordConvert { + QuartzTaskRecordConvert INSTANCE = Mappers.getMapper(QuartzTaskRecordConvert.class); + + QuartzTaskRecordPO toCreate(ReqCreateQuartzTaskRecord request); + QuartzTaskRecordPO toModify(ReqModifyQuartzTaskRecord request); + + QuartzTaskRecordVO toVo(QuartzTaskRecordPO item); + List<QuartzTaskRecordVO> toVo(List<QuartzTaskRecordPO> list); +} diff --git a/src/main/java/com/fengdu/gas/service/convert/SysDictDataConvert.java b/src/main/java/com/fengdu/gas/service/convert/SysDictDataConvert.java new file mode 100644 index 0000000..5d54ab5 --- /dev/null +++ b/src/main/java/com/fengdu/gas/service/convert/SysDictDataConvert.java @@ -0,0 +1,48 @@ +/** +# __----~~~~~~~~~~~------___ +# . . ~~//====...... __--~ ~~ +# -. \_|// |||\\ ~~~~~~::::... /~ +# ___-==_ _-~o~ \/ ||| \\ _/~~- +# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ +# _-~~ .=~ | \\-_ '-~7 /- / || \ / +# .~ .~ | \\ -_ / /- / || \ / +# / ____ / | \\ ~-_/ /|- _/ .|| \ / +# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ +# ' ~-| /| |-~\~~ __--~~ +# |-~~-_/ | | ~\_ _-~ /\ +# / \ \__ \/~ \__ +# _--~ _/ | .-~~____--~-/ ~~==. +# ((->/~ '.|||' -_| ~~-/ , . _|| +# -_ ~\ ~~---l__i__i__i--~~_/ +# _-~-__ ~) \--______________--~~ +# //.-~~~-~_--~- |-------~~~~~~~~ +# //.-~~~--\ +# 神兽保佑 +# 永无BUG! +*/ +package com.fengdu.gas.service.convert; + +import com.fengdu.gas.repository.po.SysDictDataPO; +import com.fengdu.gas.entity.request.sysdictdata.ReqCreateSysDictData; +import com.fengdu.gas.entity.request.sysdictdata.ReqModifySysDictData; +import com.fengdu.gas.repository.vo.SysDictDataVO; +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + +import java.util.List; + +/** + * 字典数据表 + * @author {#=author} + * @description 字典数据表 + */ +@Mapper +public interface SysDictDataConvert { + SysDictDataConvert INSTANCE = Mappers.getMapper(SysDictDataConvert.class); + + SysDictDataPO toCreate(ReqCreateSysDictData request); + SysDictDataPO toModify(ReqModifySysDictData request); + + SysDictDataVO toVo(SysDictDataPO item); + List<SysDictDataVO> toVo(List<SysDictDataPO> list); +} diff --git a/src/main/java/com/fengdu/gas/service/convert/SysDictTypeConvert.java b/src/main/java/com/fengdu/gas/service/convert/SysDictTypeConvert.java new file mode 100644 index 0000000..664e6ad --- /dev/null +++ b/src/main/java/com/fengdu/gas/service/convert/SysDictTypeConvert.java @@ -0,0 +1,48 @@ +/** +# __----~~~~~~~~~~~------___ +# . . ~~//====...... __--~ ~~ +# -. \_|// |||\\ ~~~~~~::::... /~ +# ___-==_ _-~o~ \/ ||| \\ _/~~- +# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ +# _-~~ .=~ | \\-_ '-~7 /- / || \ / +# .~ .~ | \\ -_ / /- / || \ / +# / ____ / | \\ ~-_/ /|- _/ .|| \ / +# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ +# ' ~-| /| |-~\~~ __--~~ +# |-~~-_/ | | ~\_ _-~ /\ +# / \ \__ \/~ \__ +# _--~ _/ | .-~~____--~-/ ~~==. +# ((->/~ '.|||' -_| ~~-/ , . _|| +# -_ ~\ ~~---l__i__i__i--~~_/ +# _-~-__ ~) \--______________--~~ +# //.-~~~-~_--~- |-------~~~~~~~~ +# //.-~~~--\ +# 神兽保佑 +# 永无BUG! +*/ +package com.fengdu.gas.service.convert; + +import com.fengdu.gas.repository.po.SysDictTypePO; +import com.fengdu.gas.entity.request.sysdicttype.ReqCreateSysDictType; +import com.fengdu.gas.entity.request.sysdicttype.ReqModifySysDictType; +import com.fengdu.gas.repository.vo.SysDictTypeVO; +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + +import java.util.List; + +/** + * 字典类型表 + * @author {#=author} + * @description 字典类型表 + */ +@Mapper +public interface SysDictTypeConvert { + SysDictTypeConvert INSTANCE = Mappers.getMapper(SysDictTypeConvert.class); + + SysDictTypePO toCreate(ReqCreateSysDictType request); + SysDictTypePO toModify(ReqModifySysDictType request); + + SysDictTypeVO toVo(SysDictTypePO item); + List<SysDictTypeVO> toVo(List<SysDictTypePO> list); +} diff --git a/src/main/java/com/fengdu/gas/service/convert/TestInfoConvert.java b/src/main/java/com/fengdu/gas/service/convert/TestInfoConvert.java new file mode 100644 index 0000000..ee2eb5a --- /dev/null +++ b/src/main/java/com/fengdu/gas/service/convert/TestInfoConvert.java @@ -0,0 +1,48 @@ +/** +# __----~~~~~~~~~~~------___ +# . . ~~//====...... __--~ ~~ +# -. \_|// |||\\ ~~~~~~::::... /~ +# ___-==_ _-~o~ \/ ||| \\ _/~~- +# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ +# _-~~ .=~ | \\-_ '-~7 /- / || \ / +# .~ .~ | \\ -_ / /- / || \ / +# / ____ / | \\ ~-_/ /|- _/ .|| \ / +# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ +# ' ~-| /| |-~\~~ __--~~ +# |-~~-_/ | | ~\_ _-~ /\ +# / \ \__ \/~ \__ +# _--~ _/ | .-~~____--~-/ ~~==. +# ((->/~ '.|||' -_| ~~-/ , . _|| +# -_ ~\ ~~---l__i__i__i--~~_/ +# _-~-__ ~) \--______________--~~ +# //.-~~~-~_--~- |-------~~~~~~~~ +# //.-~~~--\ +# 神兽保佑 +# 永无BUG! +*/ +package com.fengdu.gas.service.convert; + +import com.fengdu.gas.repository.po.TestInfoPO; +import com.fengdu.gas.entity.request.test.ReqCreateTestInfo; +import com.fengdu.gas.entity.request.test.ReqModifyTestInfo; +import com.fengdu.gas.repository.vo.TestInfoVO; +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + +import java.util.List; + +/** + * 水表账户停用启用申请表 + * @author {#=author} + * @description 水表账户停用启用申请表 + */ +@Mapper +public interface TestInfoConvert { + TestInfoConvert INSTANCE = Mappers.getMapper(TestInfoConvert.class); + + TestInfoPO toCreate(ReqCreateTestInfo request); + TestInfoPO toModify(ReqModifyTestInfo request); + + TestInfoVO toVo(TestInfoPO item); + List<TestInfoVO> toVo(List<TestInfoPO> list); +} diff --git a/src/main/java/com/fengdu/gas/service/dto/NoticeDetail.java b/src/main/java/com/fengdu/gas/service/dto/NoticeDetail.java new file mode 100644 index 0000000..c45dcba --- /dev/null +++ b/src/main/java/com/fengdu/gas/service/dto/NoticeDetail.java @@ -0,0 +1,12 @@ +package com.fengdu.gas.service.dto; + +import com.fengdu.gas.repository.vo.NoticeVO; +import lombok.Data; + +@Data +public class NoticeDetail extends NoticeVO { + /** + * 内容 + */ + private String content; +} diff --git a/src/main/java/com/fengdu/gas/service/dto/ResAdminDetail.java b/src/main/java/com/fengdu/gas/service/dto/ResAdminDetail.java new file mode 100644 index 0000000..65dceb4 --- /dev/null +++ b/src/main/java/com/fengdu/gas/service/dto/ResAdminDetail.java @@ -0,0 +1,15 @@ +package com.fengdu.gas.service.dto; + +import com.fengdu.gas.repository.vo.AdminRoleVO; +import com.fengdu.gas.repository.vo.AdminUserVO; +import lombok.Data; + +import java.util.List; + +@Data +public class ResAdminDetail extends AdminUserVO { + /** + * 角色列表 + */ + private List<AdminRoleVO> listRole; +} diff --git a/src/main/java/com/fengdu/gas/service/quartz/QuartzExecutor.java b/src/main/java/com/fengdu/gas/service/quartz/QuartzExecutor.java new file mode 100644 index 0000000..a4e190d --- /dev/null +++ b/src/main/java/com/fengdu/gas/service/quartz/QuartzExecutor.java @@ -0,0 +1,72 @@ +package com.fengdu.gas.service.quartz; + +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import com.fengdu.gas.common.ConstantFactory; +import com.fengdu.gas.common.ExecutedResult; +import com.fengdu.gas.common.util.LocalDateTimeUtil; +import com.fengdu.gas.common.util.NumericUtil; +import com.fengdu.gas.common.util.StringUtil; +import com.fengdu.gas.repository.impl.QuartzTaskErrorMapperImpl; +import com.fengdu.gas.repository.impl.QuartzTaskRecordMapperImpl; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.lang.reflect.Method; +import java.time.LocalDateTime; +import java.util.Objects; + +@Service +public class QuartzExecutor { + private static Logger logger = LoggerFactory.getLogger(QuartzExecutor.class); + + @Autowired + private QuartzTaskRecordMapperImpl taskRecordsDao; + @Autowired + private QuartzTaskErrorMapperImpl taskErrorsDao; + + /** + * 执行job + * @param executorName 执行器名称(方法名) + * @param jobParameter 执行参数 + */ + public ExecutedResult<String> execute(String executorName, String jobParameter) { + try { + // 根据执行器key,查找执行器的方法(入参:String jobParameter,返参:ExecutedResult<String>) + Method method = QuartzExecutor.class.getMethod(executorName, String.class); + return (ExecutedResult<String>)method.invoke(this, jobParameter); + } catch (Exception e) { + return ExecutedResult.failed(e.toString()); + } + } + + /*** + * job执行器-清理任务调度日志 + * @param jobParameter 执行参数 + */ + public ExecutedResult<String> clearQuartzLog(String jobParameter) { + try { + int keepDays = ConstantFactory.NUM15; + if (StringUtil.isNotNullOrEmpty(jobParameter)) { + JsonElement element = new JsonParser().parse(jobParameter); + if (Objects.nonNull(element) && !element.isJsonNull()) { + JsonObject data = element.getAsJsonObject(); + if (data.has("keepDays") && !data.get("keepDays").isJsonNull()) { + keepDays = NumericUtil.tryParseInt(data.get("keepDays").getAsString(), ConstantFactory.NUM15); + } + } + } + LocalDateTime today = LocalDateTimeUtil.todayFirst(); + LocalDateTime limitDate = LocalDateTimeUtil.dateTimeAddDay(today, -1L * keepDays); + + taskRecordsDao.clear4DateTime(LocalDateTimeUtil.getTimeStamp(limitDate).getTime()); + taskErrorsDao.clear4DateTime(LocalDateTimeUtil.getTimeStamp(limitDate).getTime()); + return ExecutedResult.success(); + } catch (Exception e) { + return ExecutedResult.failed(e.toString()); + } + } +} diff --git a/src/main/java/com/fengdu/gas/service/quartz/QuartzMainJobFactory.java b/src/main/java/com/fengdu/gas/service/quartz/QuartzMainJobFactory.java new file mode 100644 index 0000000..c26fae8 --- /dev/null +++ b/src/main/java/com/fengdu/gas/service/quartz/QuartzMainJobFactory.java @@ -0,0 +1,99 @@ +package com.fengdu.gas.service.quartz; + +import com.fengdu.gas.repository.po.QuartzTaskInfoPO; +import com.fengdu.gas.repository.po.QuartzTaskRecordPO; +import com.fengdu.gas.common.ExecutedResult; +import com.fengdu.gas.common.util.ExceptionUtil; +import com.fengdu.gas.common.util.SerializeUtil; +import com.fengdu.gas.entity.enums.EHandleStatus; +import com.fengdu.gas.entity.enums.EState; +import org.quartz.DisallowConcurrentExecution; +import org.quartz.Job; +import org.quartz.JobDataMap; +import org.quartz.JobExecutionContext; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.Objects; + +@DisallowConcurrentExecution +public class QuartzMainJobFactory implements Job { + private static Logger logger = LoggerFactory.getLogger(QuartzMainJobFactory.class); + + @Autowired + private QuartzExecutor executor; + @Autowired + private QuartzService quartzService; + + @Override + public void execute(JobExecutionContext jobExecutionContext) { + JobDataMap jobDataMap = jobExecutionContext.getMergedJobDataMap(); + String id = jobDataMap.getString("id"); + String taskNo = jobDataMap.getString("taskNo"); + String executorName = jobDataMap.getString("executor"); + String sendType = jobDataMap.getString("sendType"); + String url = jobDataMap.getString("url"); + String executeParameter = jobDataMap.getString("executeParameter"); + logger.info("定时任务被执行:taskNo={},executor={},sendType={},url={},executeParameter={}", taskNo, executor, sendType, url, executeParameter); + //QuartzService quartzService = SpringUtil.getBean(QuartzService.class); + QuartzTaskRecordPO records = null; + ExecutedResult<String> result = ExecutedResult.failed("未知错误"); + try { + ExecutedResult<QuartzTaskInfoPO> checkTask4Code = quartzService.checkTask4Code(taskNo); + if (checkTask4Code.isFailed()) { + logger.info("taskNo={}执行任务失败.找不到任务信息", taskNo); + return; + } + QuartzTaskInfoPO task = checkTask4Code.getData(); + //保存定时任务的执行记录 + records = quartzService.addTaskRecords(task, executeParameter); + if (null == records || !Objects.equals(EHandleStatus.AWAITING.getValue(), records.getTaskStatus())) { + logger.info("taskNo={}执行定时任务失败: 保存执行记录失败", taskNo); + return; + } + if (!Objects.equals(task.getStatus(), EState.NORMAL.getValue())) { + logger.info("taskNo={}执行定时任务失败: 任务状态异常{}", taskNo, task.getStatus()); + result = ExecutedResult.failed("定时任务状态异常." + task.getStatus()); + return; + } + + result = executor.execute(executorName, executeParameter); + logger.info("{}-{}执行结果: {}", taskNo, task.getTaskName(), SerializeUtil.toJson(result)); + + // 发送执行任务的消息 +// if (ResultEnum.HTTP.getMessage().equals(sendType)) { +// try { +// String result = HttpClientUtil.doPost(url, "text/json", executeParameter); +// logger.info("taskNo={},sendType={}执行结果result{}", taskNo, sendType, result); +// if (StringUtils.isEmpty(result)) { +// throw new RuntimeException("taskNo=" + taskNo + "http方式返回null"); +// } +// } catch (Exception ex) { +// logger.error(""); +// throw ex; +// } +// } else if (ResultEnum.KAFKA.getMessage().equals(sendType)) { +// try { +// String message = new StringBuffer(taskNo).append(":").append(id).append(":").append(executeParameter).toString(); +// quartzService.sendMessage(message); +// logger.info("taskNo={},sendType={}推送至kafka成功", taskNo, sendType); +// } catch (Exception ex) { +// logger.error(""); +// throw ex; +// } +// } + } catch (Exception ex) { + logger.error("任务调度QuartzMainJobFactory.execute", ex); + if (Objects.nonNull(records)) { + quartzService.addTaskErrorRecord(records.getId(), taskNo + ":" + ex.getMessage(), ExceptionUtil.getDetails(ex)); + } + result = ExecutedResult.failed(ExceptionUtil.getDetails(ex)); + } finally { + if (Objects.nonNull(records)) { + // 更改record表的执行状态 + quartzService.doneRecordById(records.getId(), result); + } + } + } +} diff --git a/src/main/java/com/fengdu/gas/service/quartz/QuartzService.java b/src/main/java/com/fengdu/gas/service/quartz/QuartzService.java new file mode 100644 index 0000000..c06ec28 --- /dev/null +++ b/src/main/java/com/fengdu/gas/service/quartz/QuartzService.java @@ -0,0 +1,420 @@ +package com.fengdu.gas.service.quartz; + +import com.fengdu.gas.repository.po.QuartzTaskErrorPO; +import com.fengdu.gas.repository.po.QuartzTaskInfoPO; +import com.fengdu.gas.repository.po.QuartzTaskRecordPO; +import com.fengdu.gas.common.ExecutedResult; +import com.fengdu.gas.common.PagerResult; +import com.fengdu.gas.common.enums.EYesOrNo; +import com.fengdu.gas.common.model.Tuple; +import com.fengdu.gas.common.util.*; +import com.fengdu.gas.entity.enums.EHandleStatus; +import com.fengdu.gas.entity.enums.EState; +import com.fengdu.gas.entity.request.quartztaskinfo.ReqCreateQuartzTaskInfo; +import com.fengdu.gas.entity.request.quartztaskinfo.ReqModifyQuartzTaskInfo; +import com.fengdu.gas.entity.request.quartztaskinfo.ReqRunTaskRightNow; +import com.fengdu.gas.entity.search.SearchQuartzTaskInfo; +import com.fengdu.gas.entity.search.SearchQuartzTaskRecord; +import com.fengdu.gas.repository.impl.QuartzTaskErrorMapperImpl; +import com.fengdu.gas.repository.impl.QuartzTaskInfoMapperImpl; +import com.fengdu.gas.repository.impl.QuartzTaskRecordMapperImpl; +import com.fengdu.gas.repository.vo.QuartzTaskErrorVO; +import com.fengdu.gas.repository.vo.QuartzTaskInfoVO; +import com.fengdu.gas.repository.vo.QuartzTaskRecordVO; +import com.fengdu.gas.service.convert.QuartzTaskInfoConvert; +import org.quartz.*; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.InitializingBean; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.scheduling.quartz.SchedulerFactoryBean; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +@Service +public class QuartzService implements InitializingBean { + private static final Logger logger = LoggerFactory.getLogger(QuartzService.class); + + @Value("${quartz.enable}") + private Boolean isQuartzEnable; + + @Autowired + private QuartzTaskInfoMapperImpl taskDao; + @Autowired + private QuartzTaskRecordMapperImpl taskRecordsDao; + @Autowired + private QuartzTaskErrorMapperImpl taskErrorsDao; + + @Autowired + private SchedulerFactoryBean schedulerBean; + @Autowired + private QuartzExecutor executor; + + public ExecutedResult<PagerResult<QuartzTaskInfoVO>> listTask(SearchQuartzTaskInfo search) { + // 预处理 mybatis plus 空指针 + search.setCreateTimeStart(0L); + search.setCreateTimeEnd(0L); + // 处理创建时间范围-查询参数 + Tuple<String, String> createTimeRange = ParameterUtil.getTimeRange(search.getCreateTimeRange()); + if (StringUtil.isNotNullOrEmpty(createTimeRange.getItem1())) { + search.setCreateTimeStart(LocalDateTimeUtil.getTimeStamp(createTimeRange.getItem1()).getTime()); + } + if (StringUtil.isNotNullOrEmpty(createTimeRange.getItem2())) { + search.setCreateTimeEnd(LocalDateTimeUtil.getTimeStamp(createTimeRange.getItem2()).getTime()); + } + + PagerResult<QuartzTaskInfoPO> pageList = taskDao.search(search); + List<QuartzTaskInfoVO> listVo = new ArrayList<>(); + List<QuartzTaskInfoPO> list = pageList.getList(); + if (ListUtil.isNotNullOrEmpty(list)) { + // 转换vo + listVo = QuartzTaskInfoConvert.INSTANCE.toVo(list); + } + PagerResult<QuartzTaskInfoVO> result = new PagerResult<>(pageList.getLimit(), pageList.getPage(), pageList.getTotal(), listVo); + return ExecutedResult.success(result); + } + + public ExecutedResult<String> addTask(ReqCreateQuartzTaskInfo request) { + Long now = LocalDateTimeUtil.nowTimeStamp(); + // 转换po + QuartzTaskInfoPO item = QuartzTaskInfoConvert.INSTANCE.toCreate(request); + // 任务编号 + item.setTaskNo("T" + SnowFlakeUtil.getId()); + // 设置状态 + item.setStatus(EState.NORMAL.getValue()); + // 设置记录创建时间 + item.setCreateTime(now); + // 版本号 + item.setVersion(now); + item.setLastTime(""); + item.setLastStatus(0); + item.setLastParameter(""); + // 是否删除(逻辑删除)初始值 + item.setIsDelete(EYesOrNo.NO.getValue()); + + int result = this.taskDao.insert(item); + if (result != 1) { + return ExecutedResult.failed("创建任务失败。"); + } + Scheduler scheduler = schedulerBean.getScheduler(); + try { + this.schedule(item, scheduler); + } catch (SchedulerException e) { + logger.error("addTask", e); + } + return ExecutedResult.success(item.getTaskNo()); + } + + @Transactional + public ExecutedResult<String> updateTask(ReqModifyQuartzTaskInfo request) throws SchedulerException { + // 验证记录是否存在 + ExecutedResult<QuartzTaskInfoPO> checkExists = this.checkTask4Id(request.getId()); + if (checkExists.isFailed()) { + return ExecutedResult.failed(checkExists.getMsg()); + } + QuartzTaskInfoPO find = checkExists.getData(); + + // 转换po + QuartzTaskInfoPO item = CopierUtil.mapTo(request, QuartzTaskInfoPO.class); + + int result = taskDao.updateById(item); + if (result != 1) { + return ExecutedResult.failed("编辑任务失败。"); + } + Scheduler scheduler = schedulerBean.getScheduler(); + scheduler.deleteJob(new JobKey(find.getTaskNo())); + if (Objects.equals(item.getStatus(),EState.NORMAL.getValue())) { + this.schedule(find, scheduler); + } + return ExecutedResult.success(); + } + + public ExecutedResult<QuartzTaskInfoPO> checkTask4Id(Long id) { + QuartzTaskInfoPO exists = taskDao.selectById(id); + if (Objects.isNull(exists)) { + return ExecutedResult.failed("任务不存在:" + id); + } + return ExecutedResult.success(exists); + } + + public ExecutedResult<QuartzTaskInfoPO> checkTask4Code(String taskNo) { + QuartzTaskInfoPO exists = taskDao.get4No(taskNo); + if (Objects.isNull(exists)) { + return ExecutedResult.failed("任务不存在:" + taskNo); + } + return ExecutedResult.success(exists); + } + + // 启动 或者 暂定定时任务 + @Transactional + public ExecutedResult<String> optionJob(Long taskId) throws SchedulerException { + // 验证记录是否存在 + ExecutedResult<QuartzTaskInfoPO> checkExists = this.checkTask4Id(taskId); + if (checkExists.isFailed()) { + return ExecutedResult.failed(checkExists.getMsg()); + } + Long now = LocalDateTimeUtil.nowTimeStamp(); + + QuartzTaskInfoPO task = checkExists.getData(); + Integer status = task.getStatus(); + String taskNo = task.getTaskNo(); + + Scheduler scheduler = schedulerBean.getScheduler(); + QuartzTaskInfoPO item = new QuartzTaskInfoPO(); + item.setId(task.getId()); + item.setVersion(task.getVersion()); + //说明要暂停 + if (Objects.equals(status, EState.NORMAL.getValue())) { + scheduler.deleteJob(new JobKey(taskNo)); + item.setFrozenTime(now); + item.setStatus(EState.DISABLED.getValue()); + } + //说明要启动 + else if (Objects.equals(status, EState.DISABLED.getValue())) { + scheduler.deleteJob(new JobKey(taskNo)); + this.schedule(task, scheduler); + item.setUnfrozenTime(now); + item.setStatus(EState.NORMAL.getValue()); + } + taskDao.updateById(item); + logger.info("taskNo={},taskName={},scheduleRule={},任务{}成功", task.getTaskNo(), task.getTaskName(), task.getSchedulerRule(), Objects.equals(status, EState.NORMAL.getValue()) ? "启动" : "暂停"); + return ExecutedResult.success(); + } + + /** + * 立即执行一次任务 + * @param request 请求参数 + */ + public ExecutedResult<String> runTaskRightNow(ReqRunTaskRightNow request) { + // 验证记录是否存在 + ExecutedResult<QuartzTaskInfoPO> checkExists = this.checkTask4Id(request.getId()); + if (checkExists.isFailed()) { + return ExecutedResult.failed(checkExists.getMsg()); + } + QuartzTaskInfoPO task = checkExists.getData(); + String taskNo = task.getTaskNo(); + + String sendType = task.getSendType(); + String executorName = task.getExecutor(); + String url = task.getUrl(); + String executeParameter = request.getExecuteParameter(); + logger.info("定时任务被执行:taskNo={},executor={},sendType={},url={},executeParameter={}", taskNo, executor, sendType, url, executeParameter); + QuartzTaskRecordPO records = null; + try { + //保存定时任务的执行记录 + records = this.addTaskRecords(task, executeParameter); + if (Objects.isNull(records) || !Objects.equals(EHandleStatus.AWAITING.getValue(), records.getTaskStatus())) { + logger.info("taskNo={}执行定时任务失败--->>保存执行记录失败", taskNo); + return ExecutedResult.failed("单次执行任务失败"); + } + Long recordId = records.getId(); + String taskName = task.getTaskName(); + ThreadPoolUtil.getDefaultPool().execute(() -> { + ExecutedResult<String> executeResult = SpringUtil.getBean(QuartzExecutor.class).execute(executorName, executeParameter); + logger.info("{}-{}执行结果: {}", taskNo, taskName, SerializeUtil.toJson(executeResult)); + // 更改record表的执行状态 + this.doneRecordById(recordId, executeResult); + }); + + + // 发送执行任务的消息 +// if (ResultEnum.HTTP.getMessage().equals(sendType)) { +// try { +// HttpClientUtil.doPost(url, "text/json", executeParameter); +// logger.info(""); +// } catch (Exception ex) { +// logger.error(""); +// atomicInteger.incrementAndGet(); +// throw ex; +// } +// } else if (ResultEnum.KAFKA.getMessage().equals(sendType)) { +// try { +// String message = new StringBuffer(taskNo).append(":").append(executeParameter).toString(); +// this.sendMessage(message); +// } catch (Exception ex) { +// logger.error(""); +// atomicInteger.incrementAndGet(); +// throw ex; +// } +// } + return ExecutedResult.success(); + } catch (Exception ex) { + logger.error("单次执行任务 runTaskRightNow", ex); + if (Objects.nonNull(records)) { + this.addTaskErrorRecord(records.getId(), taskNo + ":" + ex.getMessage(), ExceptionUtil.getDetails(ex)); + } + ExecutedResult<String> result = ExecutedResult.failed("单次执行任务失败." + ex.getMessage()); + if (Objects.nonNull(records)) { + // 更改record表的执行状态 + this.doneRecordById(records.getId(), result); + } + return result; + } + } + + // 定时任务执行记录 + public ExecutedResult<PagerResult<QuartzTaskRecordVO>> taskRecords(SearchQuartzTaskRecord search) { + // 预处理 mybatis plus 空指针 + search.setCreateTimeStart(0L); + search.setCreateTimeEnd(0L); + search.setExecuteTimeStart(0L); + search.setExecuteTimeEnd(0L); + // 处理创建时间范围-查询参数 + Tuple<String, String> createTimeRange = ParameterUtil.getTimeRange(search.getCreateTimeRange()); + if (StringUtil.isNotNullOrEmpty(createTimeRange.getItem1())) { + search.setCreateTimeStart(LocalDateTimeUtil.getTimeStamp(createTimeRange.getItem1()).getTime()); + } + if (StringUtil.isNotNullOrEmpty(createTimeRange.getItem2())) { + search.setCreateTimeEnd(LocalDateTimeUtil.getTimeStamp(createTimeRange.getItem2()).getTime()); + } + // 处理执行时间范围-查询参数 + Tuple<String, String> executeTimeRange = ParameterUtil.getTimeRange(search.getExecuteTimeRange()); + if (StringUtil.isNotNullOrEmpty(executeTimeRange.getItem1())) { + search.setExecuteTimeStart(LocalDateTimeUtil.getTimeStamp(executeTimeRange.getItem1()).getTime()); + } + if (StringUtil.isNotNullOrEmpty(executeTimeRange.getItem2())) { + search.setExecuteTimeEnd(LocalDateTimeUtil.getTimeStamp(executeTimeRange.getItem2()).getTime()); + } + + PagerResult<QuartzTaskRecordPO> pageList = taskRecordsDao.search(search); + List<QuartzTaskRecordVO> listVo = new ArrayList<>(); + List<QuartzTaskRecordPO> list = pageList.getList(); + if (ListUtil.isNotNullOrEmpty(list)) { + // 转换vo + listVo = CopierUtil.mapTo(list, QuartzTaskRecordVO.class); + } + PagerResult<QuartzTaskRecordVO> result = new PagerResult<>(pageList.getLimit(), pageList.getPage(), pageList.getTotal(), listVo); + return ExecutedResult.success(result); + } + + // 定时任务错误详情 + public ExecutedResult<QuartzTaskErrorVO> detailTaskErrors(String recordId) { + QuartzTaskErrorPO error = taskErrorsDao.get4RecordId(recordId); + if (Objects.isNull(error)) { + return ExecutedResult.success(null); + } + return ExecutedResult.success(CopierUtil.mapTo(error, QuartzTaskErrorVO.class)); + } + + /** + * Invoked by the containing {@code BeanFactory} after it has set all bean properties + * and satisfied {link BeanFactory Aware}, {@code ApplicationContextAware} etc. + * <p>This method allows the bean instance to perform validation of its overall + * configuration and final initialization when all bean properties have been set. + */ + @Override + public void afterPropertiesSet() { + if (!this.isQuartzEnable) { + return; + } + this.initLoadOnlineTasks(); + } + + /** + * 初始化加载定时任务 + * + * @throws Exception + */ + public void initLoadOnlineTasks() { + List<QuartzTaskInfoPO> list = taskDao.list4Status(EState.NORMAL.getValue()); + if (ListUtil.isNullOrEmpty(list)) { + logger.info("没有需要初始化加载的定时任务"); + return; + } + Scheduler scheduler = schedulerBean.getScheduler(); + for (QuartzTaskInfoPO task : list) { + try { + this.schedule(task, scheduler); + } catch (Exception e) { + logger.error("系统初始化加载定时任务:taskno={},taskname={}失败原因exception={}", task.getTaskNo(), task.getTaskName(), e); + } + } + } + + private void schedule(QuartzTaskInfoPO task, Scheduler scheduler) throws SchedulerException { + TriggerKey triggerKey = TriggerKey.triggerKey(task.getTaskNo(), Scheduler.DEFAULT_GROUP); + JobDetail jobDetail = JobBuilder.newJob(QuartzMainJobFactory.class).withDescription(task.getTaskName()).withIdentity(task.getTaskNo(), Scheduler.DEFAULT_GROUP).build(); + JobDataMap jobDataMap = jobDetail.getJobDataMap(); + jobDataMap.put("id", task.getId().toString()); + jobDataMap.put("taskNo", task.getTaskNo()); + jobDataMap.put("executor", task.getExecutor()); + jobDataMap.put("sendType", task.getSendType()); + jobDataMap.put("url", task.getUrl()); + jobDataMap.put("executeParameter", task.getExecuteParameter()); + CronScheduleBuilder cronScheduleBuilder = CronScheduleBuilder.cronSchedule(task.getSchedulerRule()); + CronTrigger cronTrigger = TriggerBuilder.newTrigger().withDescription(task.getTaskName()).withIdentity(triggerKey).withSchedule(cronScheduleBuilder).build(); + scheduler.scheduleJob(jobDetail, cronTrigger); + logger.info("taskNo={},taskName={},scheduleRule={} load to quartz success!", task.getTaskNo(), task.getTaskName(), task.getSchedulerRule()); + } + + public QuartzTaskRecordPO addTaskRecords(QuartzTaskInfoPO task, String executeParameter) { + Long now = LocalDateTimeUtil.nowTimeStamp(); + QuartzTaskRecordPO quartzTaskRecords = null; + try { + quartzTaskRecords = new QuartzTaskRecordPO(); + quartzTaskRecords.setTaskNo(task.getTaskNo()); + quartzTaskRecords.setTaskName(task.getTaskName()); + quartzTaskRecords.setExecuteParameter(executeParameter); + quartzTaskRecords.setStartTime(now); + quartzTaskRecords.setEndTime(0L); + quartzTaskRecords.setExecuteTimes(0L); + quartzTaskRecords.setTaskStatus(EHandleStatus.AWAITING.getValue()); + quartzTaskRecords.setFailReason(""); + quartzTaskRecords.setIsDelete(EYesOrNo.NO.getValue()); + quartzTaskRecords.setCreateTime(now); + taskRecordsDao.insert(quartzTaskRecords); + logger.info("taskNo={},taskName={}添加执行记录表成功", task.getTaskNo(), task.getTaskName()); + return quartzTaskRecords; + } catch (Exception ex) { + logger.error("添加执行记录异常 addTaskRecords", ex); + return null; + } + } + + public Integer addTaskErrorRecord(Long id, String errorKey, String errorValue) { + QuartzTaskErrorPO taskErrors = new QuartzTaskErrorPO(); + taskErrors.setTaskExecuteRecordId(String.valueOf(id)); + taskErrors.setErrorKey(errorKey); + taskErrors.setErrorValue(errorValue); + taskErrors.setIsDelete(EYesOrNo.NO.getValue()); + taskErrors.setCreateTime(LocalDateTimeUtil.nowTimeStamp()); + return taskErrorsDao.insert(taskErrors); + } + + /** + * 完成执行记录 + * @param id 执行记录id + * @param result 执行结果 + */ + public Integer doneRecordById(Long id, ExecutedResult<String> result) { + QuartzTaskRecordPO find = taskRecordsDao.selectById(id); + + QuartzTaskRecordPO records = new QuartzTaskRecordPO(); + records.setId(id); + records.setEndTime(LocalDateTimeUtil.nowTimeStamp()); + records.setExecuteTimes(records.getEndTime() - find.getStartTime()); + records.setFailReason("SUCCESS"); + if (result.isSuccess()) { + records.setTaskStatus(EHandleStatus.SUCCESS.getValue()); + } else { + records.setTaskStatus(EHandleStatus.FAILED.getValue()); + records.setFailReason(result.getMsg()); + } + + QuartzTaskInfoPO task = taskDao.get4No(find.getTaskNo()); + // 更新任务的上次执行结果 + QuartzTaskInfoPO item = new QuartzTaskInfoPO(); + item.setId(task.getId()); + item.setLastTime(LocalDateTimeUtil.nowDateTimeFullStr()); + item.setLastStatus(records.getTaskStatus()); + item.setLastParameter(find.getExecuteParameter()); + taskDao.updateById(item); + + return taskRecordsDao.updateById(records); + } +} diff --git a/src/main/java/com/lunhan/xxx/common/ConstantFactory.java b/src/main/java/com/lunhan/xxx/common/ConstantFactory.java deleted file mode 100644 index 7a7a7c1..0000000 --- a/src/main/java/com/lunhan/xxx/common/ConstantFactory.java +++ /dev/null @@ -1,329 +0,0 @@ -package com.lunhan.xxx.common; - -import java.math.BigDecimal; - -public final class ConstantFactory { - private ConstantFactory() { - throw new IllegalStateException("Utility class"); - } - - //********************************** msgCode ********************************** - /** - * msgCode - token错误 - */ - public static final String MCODE_TOKENERROR = "SYS000003"; - //********************************** msgCode ********************************** - - - - - - //********************************** 字符串 ********************************** - /** - * 获取字符串换行符 - */ - public static final String STR_NEWLINE = "\r\n"; - /** - * 获取html换行符 - */ - public static final String STR_HTMLBR = "<br />"; - /** - * 1个空格字符串 - */ - public static final String STR_SPACE = " "; - /** - * 正则中的1个空格字符串 - */ - public static final String STR_REGEX_SPACE = "\\s"; - /** - * ~ - */ - public static final String STR_TIME_RANGE = " ~ "; - /** - * ; - */ - public static final String STR_SEMICOLON = ";"; - //********************************** 字符串 ********************************** - - - - - - //********************************** 时间日期 相关 ********************************** - /** - * 日期格式“yyyy-MM-dd” - */ - public static final String STR_DATE = "yyyy-MM-dd"; - /** - * 时间格式“yyyy-MM-dd HH:mm:ss” - */ - public static final String STR_DATE_FULL = "yyyy-MM-dd HH:mm:ss"; - /** - * 时间格式“yyyy-MM-dd HH:mm:ss.SSS” - */ - public static final String STR_DATE_FULLMS = "yyyy-MM-dd HH:mm:ss.SSS"; - /** - * “ 00:00:00” - */ - public static final String STR_DATE_DAYSTART = " 00:00:00"; - /** - * “ 23:59:59” - */ - public static final String STR_DATE_DAYEND = " 23:59:59"; - /** - * “1970-01-01” - */ - public static final String STR_DATE_DEFAULT_DATE = "1970-01-01"; - /** - * “1970-01-01 00:00:00” - */ - public static final String STR_DATE_DEFAULT = "1970-01-01 00:00:00"; - /** - * “1970-01-01 08:00:01” - */ - public static final String STR_DATE_DEFAULT_UTC8 = "1970-01-01 08:00:01"; - /** - * “1970-01-01 00:00:00” - */ - public static final String STR_DATE_DEFAULT_FULL = "1970-01-01 00:00:00.000"; - //********************************** 时间日期 相关 ********************************** - - - - - - //********************************** SQL关键字 相关 ********************************** - /** - * 等于“ = ?” - */ - public static final String SQL_EQUAL = " = ?"; - /** - * 不等于 - */ - public static final String SQL_NOTEQUAL = " <> ?"; - /** - * 大于 - */ - public static final String SQL_GREATER = " > ?"; - /** - * 大于等于 - */ - public static final String SQL_GREATERTHAN = " >= ?"; - /** - * 小于 - */ - public static final String SQL_LESS = " < ?"; - /** - * 小于等于 - */ - public static final String SQL_LESSTHAN = " <= ?"; - /** - * 模糊等于“ like ?” - */ - public static final String SQL_LIKE = " like ?"; - /** - * 模糊不等于“ not like ?” - */ - public static final String SQL_NOTLIKE = " not like ?"; - /** - * “ IN” - */ - public static final String SQL_IN = " IN"; - //public static final String SQL_IN = " FIND_IN_SET(%s, ?) > 0";//由于“FIND_IN_SET”无法使用索引 2020-06-17 改为“in”语法 lin.liu - /** - * “ NOT IN” - */ - public static final String SQL_NOTIN = " NOT IN"; - //public static final String SQL_NOTIN = " FIND_IN_SET(%s, ?) = 0";//由于“FIND_IN_SET”无法使用索引 2020-06-17 改为“not in”语法 lin.liu - - - /** - * 并且“AND” - */ - public static final String SQL_AND = " AND"; - /** - * 或者“OR” - */ - public static final String SQL_OR = " OR"; - - /** - * 逗号“,” - */ - public static final String SQL_STR_COMMA = " ,"; - /** - * “ ASC” - */ - public static final String SQL_ASC = " ASC"; - /** - * “ DESC” - */ - public static final String SQL_DESC = " DESC"; - public static final String TB_A = "a."; - public static final String TB_B = "b."; - //********************************** SQL关键字 相关 ********************************** - - - - - - - //********************************** redis 相关 ********************************** - /** - * 分布式锁前缀 - */ - public static final String REDIS_LOCKPREFIX = "lock_"; - /** - * 分布式锁超时时间10秒 - */ - public static final Long REDIS_LOCKTIMEOUT = 10 * 1000L; - /** - * token哈希key - */ - public static final String REDIS_HASH_TOKEN = "HASH_TOKEN"; - /** - * 分布式锁超时时间24小时 - */ - public static final Long REDIS_EXPIRE_DEFAULT = 24 * 60 * 60L; - //********************************** redis 相关 ********************************** - - - - - - - //********************************** request请求 相关 ********************************** - /** - * token存在于headers的键值 - */ - public static final String REQUEST_TOKENKEY = "tokencode"; - /** - * token过期时间 - */ - public static final Long TOKEN_EXPIRE_DEFAULT = 2 * 60 * 60L; - /** - * 刷新token过期时间 - */ - public static final Long LONG_TOKEN_EXPIRE_DEFAULT = 7 * 24 * 60 * 60L; - //********************************** request请求 相关 ********************************** - - - - - - - //********************************** 正则表达式相关 ********************************** - /** - * 字符串格式为日期“yyyy-MM-dd”的正则 - */ - public static final String REGEX_DATE = "^[0-9]{4}\\-((0[1-9])|(1[0-2]))\\-((0[1-9])|(1[0-9])|(2[0-9])|(3[0-1]))$"; - /** - * 字符串格式为时间“yyyy-MM-dd HH:mm:ss”的正则 - */ - public static final String REGEX_DATETIME = "^[0-9]{4}\\-((0[1-9])|(1[0-2]))\\-((0[1-9])|([12][0-9])|(3[0-1]))\\s((0[0-9])|(1[0-9])|(2[0-3]))(\\:((0[0-9])|([1-5][0-9]))){2}$"; - /** - * 字符串格式为完整时间“yyyy-MM-dd HH:mm:ss.SSS”的正则 - */ - public static final String REGEX_DATETIME_FULL = "^[0-9]{4}\\-((0[1-9])|(1[0-2]))\\-((0[1-9])|([12][0-9])|(3[0-1]))\\s((0[0-9])|(1[0-9])|(2[0-3]))(\\:((0[0-9])|([1-5][0-9]))){2}\\.([0-9]){3}$"; - /** - * 字符串格式为时间“/Date(1585790902913+0800)/”的正则 - */ - public static final String REGEX_DATETIME_JAVA = "^/Date\\((?<timestamp>[0-9]{13})\\+([^\\)]+)\\)/$"; - - //********************************** 正则表达式相关 ********************************** - /** - * 缴费成功微信模版 - */ - public static final String PAY_THE_FEES_SUCCEED="D_m6GtEG-JQspqFuAvjcvzWCQDCtJAKxtq4pqFzgF54"; - /** - * 欠费催缴通知 - */ - public static final String ARREARAGE_INFORM="suK97dUCdCqQzwgQ90_DRfzI3TFExmEL1n9DAK3oTDE"; - /** - * 水费账单提醒 - */ - public static final String WATER_RATE_BILL="qqGUVvz3_rcqpDwJ6LywFOsbZhIHV-0oA6sLbHl1pQ4"; - /** - * 用水号绑定成功通知 - */ - public static final String ACCOUNT_BINDING_SUCCEED="l1wUD1hkSN16sQxsJ6dcm04BnmiO5-cRGgpsjuoSbLY"; - /** - * 预付费充值成功提醒 - */ - public static final String TOP_UP_SUCCEED="P29GhSpqsvVdIvEvCabpSD47lNjS5J_jw0tYm5GSKpw"; - - - - //********************************** 正则表达式相关 ********************************** - - - - - - - - - - - - - - public static final BigDecimal FEE_MAX = new BigDecimal("99999999999999999999.99"); - public static final BigDecimal FEE_PRICE_MAX = new BigDecimal("999.99"); - public static final BigDecimal FEE_AMOUNT_MAX = new BigDecimal("999999.99"); - public static final BigDecimal FEE_PERCENTAGE_MAX = new BigDecimal("100"); - public static final Integer NUM0 = 0; - public static final Integer NUM1 = 1; - public static final Integer NUM2 = 2; - public static final Integer NUM3 = 3; - public static final Integer NUM4 = 4; - public static final Integer NUM5 = 5; - public static final Integer NUM10 = 10; - public static final Integer NUM15 = 15; - public static final Integer NUM20 = 20; - public static final Integer NUM30 = 30; - public static final Integer NUM50 = 50; - public static final Integer NUM100 = 100; - public static final Integer NUM200 = 200; - public static final Integer NUM500 = 500; - public static final Integer NUM1000 = 1000; - public static final Integer NUM2000 = 2000; - public static final Integer NUM5000 = 5000; - public static final Integer NUM10000 = 10000; - public static final Integer LENGTH_MAX10000 = 10000; - public static final Integer LENGTH_MAX7000 = 7000; - public static final Integer LENGTH_MAX5000 = 5000; - public static final Integer LENGTH_MAX2000 = 2000; - public static final Integer LENGTH_MAX1000 = 1000; - public static final Integer LENGTH_MAX500 = 500; - public static final Integer LENGTH_MAX200 = 200; - public static final Integer LENGTH_MAX100 = 100; - public static final Integer LENGTH_MAX50 = 50; - public static final Integer LENGTH_MAX20 = 20; - public static final Integer LENGTH_MAX11 = 11; - public static final Integer MONEY_MAX_LENGTH = 2; - public static final Integer MAX_PAGE_SIZE = 999999; - public static final Integer PAGE_SIZE_DEFAULT = 20; - public static final Integer DEFAULT_NUM_PRECISION = 2; - public static final Integer FILE_UNIT = 1024; - public static final Integer FILE_SIZE_1M = 1024; - public static final Integer FILE_SIZE_2M = 2 * 1024; - public static final Integer FILE_SIZE_5M = 5 * 1024; - public static final Integer FILE_SIZE_10M = 10 * 1024; - public static final Integer FILE_SIZE_20M = 20 * 1024; - public static final Integer FILE_SIZE_50M = 50 * 1024; - public static final Integer FILE_SIZE_100M = 100 * 1024; - public static final Integer FILE_SIZE_200M = 200 * 1024; - public static final Integer TIME_LEN_1S = 1000; - public static final Integer TIME_LEN_10S = 10 * 1000; - public static final Integer TIME_LEN_1MIN = 60 * 1000; - public static final Integer TIME_LEN_5MIN = 5 * 60 * 1000; - public static final Integer TIME_LEN_10MIN = 10 * 60 * 1000; - public static final Integer TIME_LEN_20MIN = 20 * 60 * 1000; - public static final Integer TIME_LEN_50MIN = 50 * 60 * 1000; - public static final Integer TIME_LEN_100MIN = 100 * 60 * 1000; - public static final Integer TIME_LEN_1H = 60 * 60 * 1000; - public static final Integer TIME_LEN_2H = 2 * 60 * 60 * 1000; - public static final Integer TIME_LEN_12H = 12 * 60 * 60 * 1000; - public static final Integer TIME_LEN_24H = 24 * 60 * 60 * 1000; - public static final String KEY_PASSWORD = "lunhan_wcI32U+F5cSF1AL2321UoelnZNYQWxCd_hard_ware"; -} \ No newline at end of file diff --git a/src/main/java/com/lunhan/xxx/common/ExecutedResult.java b/src/main/java/com/lunhan/xxx/common/ExecutedResult.java deleted file mode 100644 index 98ae39e..0000000 --- a/src/main/java/com/lunhan/xxx/common/ExecutedResult.java +++ /dev/null @@ -1,151 +0,0 @@ -package com.lunhan.xxx.common; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.lunhan.xxx.common.enums.EResultCode; -import com.lunhan.xxx.common.util.StringUtil; - -import java.util.Objects; - -/** - * 执行结果实体 - * @author lin.liu - * @date 2019-01-08 - * @param <T> 数据包类型 - */ -public class ExecutedResult<T> { - private static final String STR_SUCCESS = "success."; - private static final String STR_FAILED = "failed."; - - /** - * 请求响应状态码 EResultCode - */ - private Integer code = EResultCode.FAILED.getCode(); - /** - * 错误消息 - */ - private String msg = STR_FAILED; - /** - * 数据包 - */ - private T data = null; - /** - * 错误码 - * @ignore - */ - @JsonIgnore - private String msgCode = ""; - - public Integer getCode() { - return code; - } - public void setCode(Integer code) { - this.code = code; - } - - public String getMsg() { - return msg; - } - public void setMsg(String msg) { - this.msg = msg; - } - - public T getData() { - return data; - } - public void setData(T data) { - this.data = data; - } - - public String getMsgCode() { - return msgCode; - } - public void setMsgCode(String msgCode) { - this.msgCode = msgCode; - } - - public ExecutedResult(){} - - public ExecutedResult(EResultCode code, T data){ - this.code = code.getCode(); - this.data = data; - } - - public ExecutedResult(EResultCode code, T data, String msg){ - this.code = code.getCode(); - this.data = data; - this.msg = msg; - } - - public ExecutedResult(EResultCode code, T data, String msg, String msgCode){ - this.code = code.getCode(); - this.data = data; - this.msg = msg; - this.msgCode = msgCode; - } - - @JsonIgnore - public Boolean isSuccess(){ - return Objects.equals(this.code, EResultCode.SUCCESS.getCode()); - } - - @JsonIgnore - public Boolean isFailed(){ - return !this.isSuccess(); - } - - public static <T> ExecutedResult<T> success(){ - return new ExecutedResult<>(EResultCode.SUCCESS, null, STR_SUCCESS); - } - - public static <T> ExecutedResult<T> success(T data){ - return new ExecutedResult<>(EResultCode.SUCCESS, data, STR_SUCCESS); - } - - public static <T> ExecutedResult<T> success(T data, String msg){ - if(StringUtil.isNullOrEmpty(msg)){ - msg = STR_SUCCESS; - } - return new ExecutedResult<>(EResultCode.SUCCESS, data, msg); - } - - public static <T> ExecutedResult<T> failed(){ - return ExecutedResult.failed(""); - } - - public static <T> ExecutedResult<T> failed(String msg){ - return ExecutedResult.failed(msg, ""); - } - - public static <T> ExecutedResult<T> failed(String msg, String msgCode){ - return ExecutedResult.failed(null, msg, msgCode); - } - - public static <T> ExecutedResult<T> failed(T data, String msg, String msgCode){ - if(StringUtil.isNullOrEmpty(msg)){ - msg = STR_FAILED; - } - return new ExecutedResult<>(EResultCode.FAILED, data, msg, msgCode); - } - - /** - * 参数验证失败返回结果 - * @param message 提示信息 - */ - public static <T> ExecutedResult<T> validateFailed(String message) { - return new ExecutedResult<>(EResultCode.VALIDATE_FAILED, null, message); - } - - /** - * 未登录返回结果 - */ - public static <T> ExecutedResult<T> unauthorized(T data) { - return new ExecutedResult<>(EResultCode.UNAUTHORIZED, data, EResultCode.UNAUTHORIZED.getMessage()); - } - - /** - * 未授权返回结果 - */ - public static <T> ExecutedResult<T> forbidden() { - return new ExecutedResult<>(EResultCode.FORBIDDEN, null, EResultCode.FORBIDDEN.getMessage()); - } -} \ No newline at end of file diff --git a/src/main/java/com/lunhan/xxx/common/PagerResult.java b/src/main/java/com/lunhan/xxx/common/PagerResult.java deleted file mode 100644 index a85c492..0000000 --- a/src/main/java/com/lunhan/xxx/common/PagerResult.java +++ /dev/null @@ -1,119 +0,0 @@ -package com.lunhan.xxx.common; - -import java.util.ArrayList; -import java.util.List; - -/** - * 分页结果 - * @author linliu - * @date 2018-12-24 - * @param <T> 数据包数据类型 - */ -public class PagerResult<T> { - /** - * 页大小(每页返回的记录条数) - **/ - private Number limit = 10; - /** - * 页号(第几页, 从1开始) - **/ - private Number page = 1; - /** - * 记录总条数 - **/ - private Number total = 0L; - /** - * 上一次请求最后一条数据的id - * - **/ - private Long lastId = 0L; - /** - * 数据包 - **/ - private List<T> list = new ArrayList<>(); - - /** - * 构造方法 - */ - public PagerResult() { - - } - - /** - * 构造方法 - * @param limit 页大小(每页显示记录数) - * @param page 页号(第几页, 从1开始) - * @param total 记录总条数 - * @param list 数据包 - */ - public PagerResult(Number limit, Number page, Number total, List<T> list) { - this.limit = limit; - this.page = page; - this.total = total; - this.list = list; - } - - public Number getLimit() { - return limit; - } - public void setLimit(Number limit) { - this.limit = limit; - } - - public Number getPage() { - return page; - } - - public void setPage(Number page) { - this.page = page; - } - - public Long getTotal() { - return total.longValue(); - } - - public void setTotal(Number total) { - this.total = total; - } - - public List<T> getList() { - return list; - } - - public void setList(List<T> list) { - this.list = list; - } - - public Long getLastId() { - return lastId; - } - - public void setLastId(Long lastId) { - this.lastId = lastId; - } - - /** - * 总页数 - */ - public Long getTotalPage() { - Long page = this.total.longValue() / this.limit.longValue(); - if(this.total.longValue() % this.limit.longValue() != 0){ - page++; - } - return page; - } - - /** - * 是否还有上一页 - */ - public boolean getIsHasPrePage() { - return this.getPage().longValue() > 1L; - } - - /** - * 是否还有下一页 - */ - public boolean getIsHasNextPage() { - return this.getPage().longValue() < this.getTotalPage(); - } -} \ No newline at end of file diff --git a/src/main/java/com/lunhan/xxx/common/PagerResultMore.java b/src/main/java/com/lunhan/xxx/common/PagerResultMore.java deleted file mode 100644 index 1b46f76..0000000 --- a/src/main/java/com/lunhan/xxx/common/PagerResultMore.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.lunhan.xxx.common; - -import java.util.List; - -public class PagerResultMore<T, M> extends PagerResult<T> { - /** - * 其他信息 - */ - private M other; - - public M getOther() { - return other; - } - - public void setOther(M other) { - this.other = other; - } - - public PagerResultMore() { - } - - public PagerResultMore(Integer limit, Integer page, Number total, List<T> list, M other) { - super(limit, page, total, list); - this.other = other; - } -} diff --git a/src/main/java/com/lunhan/xxx/common/ToBigDecimalFunction.java b/src/main/java/com/lunhan/xxx/common/ToBigDecimalFunction.java deleted file mode 100644 index 15a0c55..0000000 --- a/src/main/java/com/lunhan/xxx/common/ToBigDecimalFunction.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.lunhan.xxx.common; - -import java.math.BigDecimal; - -@FunctionalInterface -public interface ToBigDecimalFunction<T> { - BigDecimal applyAsBigDecimal(T value); -} diff --git a/src/main/java/com/lunhan/xxx/common/cache/CacheManagerConfig.java b/src/main/java/com/lunhan/xxx/common/cache/CacheManagerConfig.java deleted file mode 100644 index 815af08..0000000 --- a/src/main/java/com/lunhan/xxx/common/cache/CacheManagerConfig.java +++ /dev/null @@ -1,59 +0,0 @@ -package com.lunhan.xxx.common.cache; - -import com.lunhan.xxx.common.ConstantFactory; -import org.springframework.cache.CacheManager; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Primary; -import org.springframework.data.redis.cache.RedisCacheConfiguration; -import org.springframework.data.redis.cache.RedisCacheManager; -import org.springframework.data.redis.connection.RedisConnectionFactory; -import org.springframework.data.redis.core.RedisTemplate; -import org.springframework.data.redis.core.StringRedisTemplate; -import org.springframework.data.redis.serializer.*; - -import java.time.Duration; - -@Configuration -public class CacheManagerConfig { - @Bean - @Primary - public CacheManager json4RedisCacheManager(RedisConnectionFactory redisConnectionFactory) { - RedisCacheConfiguration config = RedisCacheConfiguration.defaultCacheConfig() - //设置24小时过期 - .entryTtl(Duration.ofMillis(ConstantFactory.TIME_LEN_24H)) - //设置key的序列化方式 - .serializeKeysWith(RedisSerializationContext.SerializationPair.fromSerializer(new RedisKeySerializer())) - //设置值的序列化方式 - .serializeValuesWith(RedisSerializationContext.SerializationPair.fromSerializer(new GenericJackson2JsonRedisSerializer())); - - - RedisCacheManager.RedisCacheManagerBuilder builder = - RedisCacheManager.RedisCacheManagerBuilder.fromConnectionFactory(redisConnectionFactory); - - //返回构造的cacheManager - return builder.transactionAware().cacheDefaults(config).build(); - } - - @Bean - public StringRedisTemplate stringRedisTemplate(RedisConnectionFactory redisConnectionFactory) { - StringRedisTemplate stringRedisTemplate = new StringRedisTemplate(redisConnectionFactory); - stringRedisTemplate.setKeySerializer(new RedisKeySerializer()); - return stringRedisTemplate; - } - - @Bean - public RedisTemplate<String, Object> objectRedisTemplate(RedisConnectionFactory redisConnectionFactory) { - RedisSerializer<String> serializer = new StringRedisSerializer(); - Jackson2JsonRedisSerializer<Object> jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer<>(Object.class); - RedisTemplate<String, Object> template = new RedisTemplate<>(); - template.setConnectionFactory(redisConnectionFactory); - template.setKeySerializer(new RedisKeySerializer()); - template.setValueSerializer(jackson2JsonRedisSerializer); - template.setHashKeySerializer(serializer); - template.setHashValueSerializer(jackson2JsonRedisSerializer); - template.afterPropertiesSet(); - - return template; - } -} diff --git a/src/main/java/com/lunhan/xxx/common/cache/RedisKeySerializer.java b/src/main/java/com/lunhan/xxx/common/cache/RedisKeySerializer.java deleted file mode 100644 index a1d4655..0000000 --- a/src/main/java/com/lunhan/xxx/common/cache/RedisKeySerializer.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.lunhan.xxx.common.cache; - -import com.lunhan.xxx.common.config.SysConfig; -import org.springframework.data.redis.serializer.RedisSerializer; -import org.springframework.lang.Nullable; - -import java.nio.charset.Charset; -import java.nio.charset.StandardCharsets; - -public class RedisKeySerializer implements RedisSerializer<String> { - private static final Charset charset = StandardCharsets.UTF_8; - - /* - * (non-Javadoc) - * @see org.springframework.data.redis.serializer.RedisSerializer#deserialize(byte[]) - */ - @Override - public String deserialize(@Nullable byte[] bytes) { - return (bytes == null ? null : new String(bytes, charset).replaceFirst(SysConfig.redis.getKeyPrefix(), "")); - } - - /* - * (non-Javadoc) - * @see org.springframework.data.redis.serializer.RedisSerializer#serialize(java.lang.Object) - */ - @Override - public byte[] serialize(@Nullable String string) { - return (string == null ? null : (SysConfig.redis.getKeyPrefix() + string).getBytes(charset)); - } -} diff --git a/src/main/java/com/lunhan/xxx/common/config/FileConfig.java b/src/main/java/com/lunhan/xxx/common/config/FileConfig.java deleted file mode 100644 index 5a0b4f1..0000000 --- a/src/main/java/com/lunhan/xxx/common/config/FileConfig.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.lunhan.xxx.common.config; - -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.stereotype.Component; - -@Component -@ConfigurationProperties(prefix = "file") -public class FileConfig { - private String uploadBasicPath; - private String fileBasicUrl; - private String disturbStr; - - public String getUploadBasicPath() { - return uploadBasicPath; - } - - public void setUploadBasicPath(String uploadBasicPath) { - this.uploadBasicPath = uploadBasicPath; - } - - public String getFileBasicUrl() { - return fileBasicUrl; - } - - public void setFileBasicUrl(String fileBasicUrl) { - this.fileBasicUrl = fileBasicUrl; - } - - public String getDisturbStr() { - return disturbStr; - } - - public void setDisturbStr(String disturbStr) { - this.disturbStr = disturbStr; - } -} diff --git a/src/main/java/com/lunhan/xxx/common/config/JWTConfig.java b/src/main/java/com/lunhan/xxx/common/config/JWTConfig.java deleted file mode 100644 index 67162ec..0000000 --- a/src/main/java/com/lunhan/xxx/common/config/JWTConfig.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.lunhan.xxx.common.config; - -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.stereotype.Component; - -@Component -@ConfigurationProperties(prefix = "jwt") -public class JWTConfig { - private String head; - private String tokenHeader; - private String secret; - private Long expiration; - - public String getHead() { - return head; - } - - public void setHead(String head) { - this.head = head; - } - - public String getTokenHeader() { - return tokenHeader; - } - - public void setTokenHeader(String tokenHeader) { - this.tokenHeader = tokenHeader; - } - - public String getSecret() { - return secret; - } - - public void setSecret(String secret) { - this.secret = secret; - } - - public Long getExpiration() { - return expiration; - } - - public void setExpiration(Long expiration) { - this.expiration = expiration; - } -} diff --git a/src/main/java/com/lunhan/xxx/common/config/JdbcSetConfig.java b/src/main/java/com/lunhan/xxx/common/config/JdbcSetConfig.java deleted file mode 100644 index 1120a95..0000000 --- a/src/main/java/com/lunhan/xxx/common/config/JdbcSetConfig.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.lunhan.xxx.common.config; - -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.stereotype.Component; - -@Component -@ConfigurationProperties(prefix = "jdbc-set") -public class JdbcSetConfig { - private String sqlLog; - - public String getSqlLog() { - return sqlLog; - } - - public void setSqlLog(String sqlLog) { - this.sqlLog = sqlLog; - } -} diff --git a/src/main/java/com/lunhan/xxx/common/config/RedisConfig.java b/src/main/java/com/lunhan/xxx/common/config/RedisConfig.java deleted file mode 100644 index 0530571..0000000 --- a/src/main/java/com/lunhan/xxx/common/config/RedisConfig.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.lunhan.xxx.common.config; - -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.stereotype.Component; - -@Component -@ConfigurationProperties(prefix = "spring.redis") -public class RedisConfig { - private String keyPrefix; - - public String getKeyPrefix() { - return keyPrefix; - } - - public void setKeyPrefix(String keyPrefix) { - this.keyPrefix = keyPrefix; - } -} diff --git a/src/main/java/com/lunhan/xxx/common/config/SysConfig.java b/src/main/java/com/lunhan/xxx/common/config/SysConfig.java deleted file mode 100644 index 6a8d4ad..0000000 --- a/src/main/java/com/lunhan/xxx/common/config/SysConfig.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.lunhan.xxx.common.config; - -import com.lunhan.xxx.common.util.SpringUtil; - -/** - * 获取系统配置 读取“config.properties” - */ -public final class SysConfig { - public static JWTConfig jwt = SpringUtil.getBean(JWTConfig.class); - public static JdbcSetConfig jdbc = SpringUtil.getBean(JdbcSetConfig.class); - public static FileConfig file = SpringUtil.getBean(FileConfig.class); - public static RedisConfig redis = SpringUtil.getBean(RedisConfig.class); - - public static String getTokenHeader() { - return jwt.getTokenHeader(); - //return properties.getProperty("jwt.tokenHeader", ""); - } - - public static String getJwtHead() { - return jwt.getHead(); - //return properties.getProperty("jwt.tokenHead", ""); - } - - public static String getTJwtHeader() { - return jwt.getTokenHeader(); - //return properties.getProperty("jwt.tokenHeader", ""); - } - - public static boolean isSqlLog() { - return "true".equalsIgnoreCase(jdbc.getSqlLog()); - //return properties.getProperty("mail.sendEmail", ""); - } - - public static String fileUploadBasic() { - return file.getUploadBasicPath(); - } - - public static String fileViewBasic() { - return file.getFileBasicUrl(); - } - - public static String fileDisturbStr() { - return file.getDisturbStr(); - } -} \ No newline at end of file diff --git a/src/main/java/com/lunhan/xxx/common/config/TokenConfig.java b/src/main/java/com/lunhan/xxx/common/config/TokenConfig.java deleted file mode 100644 index 2f2f7d7..0000000 --- a/src/main/java/com/lunhan/xxx/common/config/TokenConfig.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.lunhan.xxx.common.config; - -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.stereotype.Component; - -@Component -@ConfigurationProperties(prefix = "token") -public class TokenConfig { - private String tokenHeader; - private String expiredTime; - private String longExpiredTime; - - public String getTokenHeader() { - return tokenHeader; - } - - public void setTokenHeader(String tokenHeader) { - this.tokenHeader = tokenHeader; - } - - public String getExpiredTime() { - return expiredTime; - } - - public void setExpiredTime(String expiredTime) { - this.expiredTime = expiredTime; - } - - public String getLongExpiredTime() { - return longExpiredTime; - } - - public void setLongExpiredTime(String longExpiredTime) { - this.longExpiredTime = longExpiredTime; - } -} diff --git a/src/main/java/com/lunhan/xxx/common/enums/EContentType.java b/src/main/java/com/lunhan/xxx/common/enums/EContentType.java deleted file mode 100644 index 47ad591..0000000 --- a/src/main/java/com/lunhan/xxx/common/enums/EContentType.java +++ /dev/null @@ -1,204 +0,0 @@ -package com.lunhan.xxx.common.enums; - -import java.util.Arrays; - -/** - * ContentType 枚举 - */ -public enum EContentType { - /** - * application/json - */ - JSON("application/json", "application/json"), - /** - * application/x-www-form-urlencoded - */ - FORM("application/x-www-form-urlencoded", "application/x-www-form-urlencoded"), - /** - * multipart/form-data - */ - FORMDATA("multipart/form-data", "multipart/form-data"), - /** - * application/xml - */ - XML("application/xml", "application/xml"), - /** - * text/plain - */ - TEXT("text/plain", "text/plain"), - - - - - - /** - * application/vnd.ms-excel - */ - EXCEL("application/vnd.ms-excel", "application/vnd.ms-excel"), - /** - * application/vnd.openxmlformats-officedocument.spreadsheetml.sheet - */ - EXCELX("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"), - /** - * application/msword - */ - WORD("application/msword", "application/msword"), - /** - * application/vnd.openxmlformats-officedocument.wordprocessingml.document - */ - WORDX("application/vnd.openxmlformats-officedocument.wordprocessingml.document", "application/vnd.openxmlformats-officedocument.wordprocessingml.document"), - /** - * application/vnd.ms-powerpoint - */ - PPT("application/vnd.ms-powerpoint", "application/vnd.ms-powerpoint"), - /** - * application/vnd.openxmlformats-officedocument.presentationml.presentation - */ - PPTX("application/vnd.openxmlformats-officedocument.presentationml.presentation", "application/vnd.openxmlformats-officedocument.presentationml.presentation"), - - - - - - - - - - - /** - * image/jpeg - */ - JPEG("image/jpeg", "image/jpeg"), - /** - * image/jpg - */ - JPG("image/jpg", "image/jpg"), - /** - * image/gif - */ - GIF("image/gif", "image/gif"), - /** - * image/png - */ - PNG("image/png", "image/png"), - /** - * image/bmp - */ - BMP("image/bmp", "image/bmp"), - - - - - - - - - - - /** - * application/zip - */ - ZIP("application/zip", "application/zip"), - /** - * application/x-rar - */ - RAR("application/x-rar", "application/x-rar"), - /** - * application/x-7z-compressed - */ - X7Z("application/x-7z-compressed", "application/x-7z-compressed"), - /** - * application/x-gzip - */ - GZ("application/x-gzip", "application/x-gzip"), - - - - - - - - - - - /** - * video/mpeg - */ - MP2("video/mpeg", "video/mpeg"), - /** - * audio/mpeg - */ - MP3("audio/mpeg", "audio/mpeg"), - /** - * aaudio/x-flac - */ - FLAC("audio/x-flac", "audio/x-flac"), - /** - * video/x-flv - */ - FLV("video/x-flv", "video/x-flv"), - /** - * video/3gpp - */ - X3GP("video/3gpp", "video/3gpp"), - /** - * video/mp4 - */ - MP4("video/mp4", "video/mp4"), - - - - - - - - - - - /** - * application/pdf - */ - PDF("application/pdf", "application/pdf") - ; - - private String desc;//枚举描述 - private String value;//枚举值 - - public String getValue() { - return value; - } - public String getDesc() { - return desc; - } - - /** - * 构造方法 - * @param desc 枚举描述 - * @param value 枚举值 - */ - EContentType(String desc, String value) { - this.desc = desc; - this.value = value; - } - - /** - * 根据值获取枚举 - * - * @param value 枚举值 - * @return - */ - public static EContentType getByValue(String value) { - return Arrays.stream(EContentType.values()) - .filter(e -> e.getValue().equals(value)) - .findFirst() - .orElse(null); - } - - @Override - public String toString() { - return "EContentType{" + - "desc='" + desc + '\'' + - ", value=" + value + - '}'; - } -} \ No newline at end of file diff --git a/src/main/java/com/lunhan/xxx/common/enums/EHorizontalLocation.java b/src/main/java/com/lunhan/xxx/common/enums/EHorizontalLocation.java deleted file mode 100644 index 05690d5..0000000 --- a/src/main/java/com/lunhan/xxx/common/enums/EHorizontalLocation.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.lunhan.xxx.common.enums; - -import java.util.Arrays; - -/** - * 水平位置 枚举 - */ -public enum EHorizontalLocation { - /** - * 靠左 - */ - LEFT("LEFT", 1), - - /** - * 居中 - */ - CENTRE("CENTRE", 2), - - /** - * 靠右 - */ - RIGHT("RIGHT", 3); - - private String desc;//枚举描述 - private int value;//枚举值 - - public int getValue() { - return value; - } - public String getDesc() { - return desc; - } - - /** - * 构造方法 - * @param desc 枚举描述 - * @param value 枚举值 - */ - EHorizontalLocation(String desc, int value) { - this.desc = desc; - this.value = value; - } - - /** - * 根据值获取枚举 - * - * @param value 枚举值 - * @return - */ - public static EHorizontalLocation getByValue(int value) { - return Arrays.stream(EHorizontalLocation.values()) - .filter(e -> e.getValue() == value) - .findFirst() - .orElse(null); - } - - @Override - public String toString() { - return "EHorizontalLocation{" + - "desc='" + desc + '\'' + - ", value=" + value + - '}'; - } -} \ No newline at end of file diff --git a/src/main/java/com/lunhan/xxx/common/enums/EHttpContentType.java b/src/main/java/com/lunhan/xxx/common/enums/EHttpContentType.java deleted file mode 100644 index 6cd648c..0000000 --- a/src/main/java/com/lunhan/xxx/common/enums/EHttpContentType.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.lunhan.xxx.common.enums; - -import java.util.Arrays; - -/** - * http请求类型 枚举 - * @author linliu - * @date 2019-01-08 - */ -public enum EHttpContentType { - /** - * application/json - */ - JSON("application/json", "application/json"), - /** - * application/x-www-form-urlencoded - */ - FORM("application/x-www-form-urlencoded", "application/x-www-form-urlencoded"), - /** - * multipart/form-data - */ - FORMDATA("multipart/form-data", "multipart/form-data"), - /** - * application/xml - */ - XML("application/xml", "application/xml"); - - private String desc;//枚举描述 - private String value;//枚举值 - - public String getValue() { - return value; - } - public String getDesc() { - return desc; - } - - /** - * 构造方法 - * @param desc 枚举描述 - * @param value 枚举值 - */ - EHttpContentType(String desc, String value) { - this.desc = desc; - this.value = value; - } - - /** - * 根据值获取枚举 - * - * @param value 枚举值 - * @return - */ - public static EHttpContentType getByValue(String value) { - return Arrays.stream(EHttpContentType.values()) - .filter(e -> e.getValue().equals(value)) - .findFirst() - .orElse(null); - } - - @Override - public String toString() { - return "EHttpContentType{" + - "desc='" + desc + '\'' + - ", value=" + value + - '}'; - } -} \ No newline at end of file diff --git a/src/main/java/com/lunhan/xxx/common/enums/ELogger.java b/src/main/java/com/lunhan/xxx/common/enums/ELogger.java deleted file mode 100644 index f312110..0000000 --- a/src/main/java/com/lunhan/xxx/common/enums/ELogger.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.lunhan.xxx.common.enums; - -import java.util.Arrays; -import java.util.Objects; - -public enum ELogger { - DEBUG("debug"), - INFO("info"), - API_REQUEST("apiRequest"), - - SQL_LOG("sqlLog"), - SYS_ERROR("sysError"), - PAY_SERVICE("payService") - ; - - private String logFileName; - - ELogger(String logFileName) { - this.logFileName = logFileName; - } - - public String getLogFileName() { - return this.logFileName; - } - - public static ELogger getByLoggerName(String loggerName) { - ELogger[] arr = values(); - return Arrays.stream(arr) - .filter(c -> Objects.equals(c.getLogFileName(), loggerName)) - .findAny().orElse(null); - } -} diff --git a/src/main/java/com/lunhan/xxx/common/enums/ERequestTokenFrom.java b/src/main/java/com/lunhan/xxx/common/enums/ERequestTokenFrom.java deleted file mode 100644 index 9609230..0000000 --- a/src/main/java/com/lunhan/xxx/common/enums/ERequestTokenFrom.java +++ /dev/null @@ -1,60 +0,0 @@ -package com.lunhan.xxx.common.enums; - -import java.util.Arrays; - -/** - * token存放地方 枚举 - * @author linliu - * @date 2019-06-04 - */ -public enum ERequestTokenFrom { - /** - * token从 headers 传输 - */ - HEADERS("headers", 1), - /** - * token从 urls 传输 - */ - URLS("urls", 2); - - private String desc;//枚举描述 - private int value;//枚举值 - - public int getValue() { - return value; - } - public String getDesc() { - return desc; - } - - /** - * 构造方法 - * @param desc 枚举描述 - * @param value 枚举值 - */ - ERequestTokenFrom(String desc, int value) { - this.desc = desc; - this.value = value; - } - - /** - * 根据值获取枚举 - * - * @param value 枚举值 - * @return - */ - public static ERequestTokenFrom getByValue(int value) { - return Arrays.stream(ERequestTokenFrom.values()) - .filter(e -> e.getValue() == value) - .findFirst() - .orElse(null); - } - - @Override - public String toString() { - return "ERequestTokenFrom{" + - "desc='" + desc + '\'' + - ", value=" + value + - '}'; - } -} \ No newline at end of file diff --git a/src/main/java/com/lunhan/xxx/common/enums/EResultCode.java b/src/main/java/com/lunhan/xxx/common/enums/EResultCode.java deleted file mode 100644 index 68fc714..0000000 --- a/src/main/java/com/lunhan/xxx/common/enums/EResultCode.java +++ /dev/null @@ -1,71 +0,0 @@ -package com.lunhan.xxx.common.enums; - -/** - * 执行结果 枚举 - * @author linliu - * @date 2019-01-08 - */ -public enum EResultCode implements IErrorCode { - /** - * 操作成功=200, - **/ - SUCCESS(200, "操作成功"), - /** - * 部分成功=210 - */ - PARTIAL_SUCCESS(210, "部分成功"), - /** - * 操作失败=300, - **/ - FAILED(300, "操作失败"), - /** - * 参数检验失败=301, - **/ - VALIDATE_FAILED(301, "参数检验失败"), - /** - * 相关需要支付:未付费 - */ - UNPAID(302,"未付费"), - /** - * 积分不足,充值提示 - */ - INTEGRAL(303,"积分不足,请充值。"), - /** - * 未登录或token已经过期=401, - **/ - UNAUTHORIZED(401, "未登录或token已经过期"), - /** - * 没有相关权限=403, - **/ - FORBIDDEN(403, "没有相关权限"), - /** - * 找不到相关资源=404, - **/ - NOT_FOUND(404, "找不到相关资源"), - /** - * 签名验证失败=407, - */ - SIGN_NOT_PASS(407, "签名验证失败"), - /** - * 系统繁忙=500, - **/ - ERROR(500, "系统繁忙"); - - private Integer code; - private String message; - - EResultCode(Integer code, String message) { - this.code = code; - this.message = message; - } - - @Override - public Integer getCode() { - return code; - } - - @Override - public String getMessage() { - return message; - } -} \ No newline at end of file diff --git a/src/main/java/com/lunhan/xxx/common/enums/EVerticalLocation.java b/src/main/java/com/lunhan/xxx/common/enums/EVerticalLocation.java deleted file mode 100644 index dfdcc61..0000000 --- a/src/main/java/com/lunhan/xxx/common/enums/EVerticalLocation.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.lunhan.xxx.common.enums; - -import java.util.Arrays; - -/** - * 垂直位置 枚举 - */ -public enum EVerticalLocation { - /** - * 靠顶端 - */ - TOP("TOP", 1), - - /** - * 居中 - */ - MIDDLE("MIDDLE", 2), - - /** - * 靠底部 - */ - BOTTOM("BOTTOM", 3); - - private String desc;//枚举描述 - private int value;//枚举值 - - public int getValue() { - return value; - } - public String getDesc() { - return desc; - } - - /** - * 构造方法 - * @param desc 枚举描述 - * @param value 枚举值 - */ - EVerticalLocation(String desc, int value) { - this.desc = desc; - this.value = value; - } - - /** - * 根据值获取枚举 - * - * @param value 枚举值 - * @return - */ - public static EVerticalLocation getByValue(int value) { - return Arrays.stream(EVerticalLocation.values()) - .filter(e -> e.getValue() == value) - .findFirst() - .orElse(null); - } - - @Override - public String toString() { - return "EVerticalLocation{" + - "desc='" + desc + '\'' + - ", value=" + value + - '}'; - } -} \ No newline at end of file diff --git a/src/main/java/com/lunhan/xxx/common/enums/EYesOrNo.java b/src/main/java/com/lunhan/xxx/common/enums/EYesOrNo.java deleted file mode 100644 index ee02c2e..0000000 --- a/src/main/java/com/lunhan/xxx/common/enums/EYesOrNo.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.lunhan.xxx.common.enums; - -import java.util.Arrays; -import java.util.Objects; - -public enum EYesOrNo { - /** - * 否 - */ - NO("否", 0), - - /** - * 是=1 - */ - YES("是", 1) - ; - - private String desc;//枚举描述 - private Integer value;//枚举值 - - public Integer getValue() { - return value; - } - public String getDesc() { - return desc; - } - - /** - * 构造方法 - * @param desc 枚举描述 - * @param value 枚举值 - */ - EYesOrNo(String desc, Integer value) { - this.desc = desc; - this.value = value; - } - - /** - * 根据值获取枚举 - * - * @param value 枚举值 - * @return - */ - public static EYesOrNo getByValue(Integer value) { - return Arrays.stream(EYesOrNo.values()) - .filter(e -> Objects.equals(e.getValue(), value)) - .findFirst() - .orElse(null); - } - - @Override - public String toString() { - return "EYesOrNo{" + - "desc='" + desc + '\'' + - ", value=" + value + - '}'; - } -} diff --git a/src/main/java/com/lunhan/xxx/common/enums/EnumBasic.java b/src/main/java/com/lunhan/xxx/common/enums/EnumBasic.java deleted file mode 100644 index 4516e54..0000000 --- a/src/main/java/com/lunhan/xxx/common/enums/EnumBasic.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.lunhan.xxx.common.enums; - -/** - * 枚举基类 - * @author linliu - * @date 2019-01-08 - */ -public interface EnumBasic { - int getValue(); - String getColumnName(); - String getTableName(); -} \ No newline at end of file diff --git a/src/main/java/com/lunhan/xxx/common/enums/IErrorCode.java b/src/main/java/com/lunhan/xxx/common/enums/IErrorCode.java deleted file mode 100644 index fef538c..0000000 --- a/src/main/java/com/lunhan/xxx/common/enums/IErrorCode.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.lunhan.xxx.common.enums; - -/** - * @Author lin.liu - * @Description 错误编码 接口 - * @Date 2021/4/16 - **/ -public interface IErrorCode { - /** - * 错误编码 - **/ - Integer getCode(); - - /** - * 错误信息 - **/ - String getMessage(); -} diff --git a/src/main/java/com/lunhan/xxx/common/exceptions/BusinessException.java b/src/main/java/com/lunhan/xxx/common/exceptions/BusinessException.java deleted file mode 100644 index cbf2aaa..0000000 --- a/src/main/java/com/lunhan/xxx/common/exceptions/BusinessException.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.lunhan.xxx.common.exceptions; - -import com.lunhan.xxx.common.enums.EResultCode; - -/** - * 自定义业务异常 - */ -public class BusinessException extends RuntimeException { - private EResultCode code; - - public EResultCode getCode() { - return code; - } - - public void setCode(EResultCode code) { - this.code = code; - } - - public BusinessException() { - super(); - } - - public BusinessException(String message) { - super(message); - this.code = EResultCode.ERROR; - } - - public BusinessException(EResultCode code, String message) { - super(message); - this.code = code; - } - - public BusinessException(String message, Throwable cause) { - super(message, cause); - } - - public BusinessException(Throwable cause) { - super(cause); - } -} \ No newline at end of file diff --git a/src/main/java/com/lunhan/xxx/common/extend/CollectorsPlus.java b/src/main/java/com/lunhan/xxx/common/extend/CollectorsPlus.java deleted file mode 100644 index cc8e14a..0000000 --- a/src/main/java/com/lunhan/xxx/common/extend/CollectorsPlus.java +++ /dev/null @@ -1,1498 +0,0 @@ -package com.lunhan.xxx.common.extend; - -import com.lunhan.xxx.common.ToBigDecimalFunction; - -import java.math.BigDecimal; -import java.util.*; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; -import java.util.function.*; -import java.util.stream.Collector; -import java.util.stream.Stream; - -public class CollectorsPlus { - static final Set<Collector.Characteristics> CH_CONCURRENT_ID - = Collections.unmodifiableSet(EnumSet.of(Collector.Characteristics.CONCURRENT, - Collector.Characteristics.UNORDERED, - Collector.Characteristics.IDENTITY_FINISH)); - static final Set<Collector.Characteristics> CH_CONCURRENT_NOID - = Collections.unmodifiableSet(EnumSet.of(Collector.Characteristics.CONCURRENT, - Collector.Characteristics.UNORDERED)); - static final Set<Collector.Characteristics> CH_ID - = Collections.unmodifiableSet(EnumSet.of(Collector.Characteristics.IDENTITY_FINISH)); - static final Set<Collector.Characteristics> CH_UNORDERED_ID - = Collections.unmodifiableSet(EnumSet.of(Collector.Characteristics.UNORDERED, - Collector.Characteristics.IDENTITY_FINISH)); - static final Set<Collector.Characteristics> CH_NOID = Collections.emptySet(); - - private CollectorsPlus() { } - - /** - * Returns a merge function, suitable for use in - * {@link Map#merge(Object, Object, BiFunction) Map.merge()} or - * {@link #toMap(Function, Function, BinaryOperator) toMap()}, which always - * throws {@code IllegalStateException}. This can be used to enforce the - * assumption that the elements being collected are distinct. - * - * @param <T> the type of input arguments to the merge function - * @return a merge function which always throw {@code IllegalStateException} - */ - private static <T> BinaryOperator<T> throwingMerger() { - return (u,v) -> { throw new IllegalStateException(String.format("Duplicate key %s", u)); }; - } - - @SuppressWarnings("unchecked") - private static <I, R> Function<I, R> castingIdentity() { - return i -> (R) i; - } - - /** - * Simple implementation class for {@code Collector}. - * - * @param <T> the type of elements to be collected - * @param <R> the type of the result - */ - static class CollectorImpl<T, A, R> implements Collector<T, A, R> { - private final Supplier<A> supplier; - private final BiConsumer<A, T> accumulator; - private final BinaryOperator<A> combiner; - private final Function<A, R> finisher; - private final Set<Characteristics> characteristics; - - CollectorImpl(Supplier<A> supplier, - BiConsumer<A, T> accumulator, - BinaryOperator<A> combiner, - Function<A,R> finisher, - Set<Characteristics> characteristics) { - this.supplier = supplier; - this.accumulator = accumulator; - this.combiner = combiner; - this.finisher = finisher; - this.characteristics = characteristics; - } - - CollectorImpl(Supplier<A> supplier, - BiConsumer<A, T> accumulator, - BinaryOperator<A> combiner, - Set<Characteristics> characteristics) { - this(supplier, accumulator, combiner, castingIdentity(), characteristics); - } - - @Override - public BiConsumer<A, T> accumulator() { - return accumulator; - } - - @Override - public Supplier<A> supplier() { - return supplier; - } - - @Override - public BinaryOperator<A> combiner() { - return combiner; - } - - @Override - public Function<A, R> finisher() { - return finisher; - } - - @Override - public Set<Characteristics> characteristics() { - return characteristics; - } - } - - /** - * Returns a {@code Collector} that accumulates the input elements into a - * new {@code Collection}, in encounter order. The {@code Collection} is - * created by the provided factory. - * - * @param <T> the type of the input elements - * @param <C> the type of the resulting {@code Collection} - * @param collectionFactory a {@code Supplier} which returns a new, empty - * {@code Collection} of the appropriate type - * @return a {@code Collector} which collects all the input elements into a - * {@code Collection}, in encounter order - */ - public static <T, C extends Collection<T>> - Collector<T, ?, C> toCollection(Supplier<C> collectionFactory) { - return new CollectorImpl<>(collectionFactory, Collection<T>::add, - (r1, r2) -> { r1.addAll(r2); return r1; }, - CH_ID); - } - - /** - * Returns a {@code Collector} that accumulates the input elements into a - * new {@code List}. There are no guarantees on the type, mutability, - * serializability, or thread-safety of the {@code List} returned; if more - * control over the returned {@code List} is required, use {@link #toCollection(Supplier)}. - * - * @param <T> the type of the input elements - * @return a {@code Collector} which collects all the input elements into a - * {@code List}, in encounter order - */ - public static <T> - Collector<T, ?, List<T>> toList() { - return new CollectorImpl<>((Supplier<List<T>>) ArrayList::new, List::add, - (left, right) -> { left.addAll(right); return left; }, - CH_ID); - } - - /** - * Returns a {@code Collector} that accumulates the input elements into a - * new {@code Set}. There are no guarantees on the type, mutability, - * serializability, or thread-safety of the {@code Set} returned; if more - * control over the returned {@code Set} is required, use - * {@link #toCollection(Supplier)}. - * - * <p>This is an {@link Collector.Characteristics#UNORDERED unordered} - * Collector. - * - * @param <T> the type of the input elements - * @return a {@code Collector} which collects all the input elements into a - * {@code Set} - */ - public static <T> - Collector<T, ?, Set<T>> toSet() { - return new CollectorImpl<>((Supplier<Set<T>>) HashSet::new, Set::add, - (left, right) -> { left.addAll(right); return left; }, - CH_UNORDERED_ID); - } - - /** - * Returns a {@code Collector} that concatenates the input elements into a - * {@code String}, in encounter order. - * - * @return a {@code Collector} that concatenates the input elements into a - * {@code String}, in encounter order - */ - public static Collector<CharSequence, ?, String> joining() { - return new CollectorImpl<CharSequence, StringBuilder, String>( - StringBuilder::new, StringBuilder::append, - (r1, r2) -> { r1.append(r2); return r1; }, - StringBuilder::toString, CH_NOID); - } - - /** - * Returns a {@code Collector} that concatenates the input elements, - * separated by the specified delimiter, in encounter order. - * - * @param delimiter the delimiter to be used between each element - * @return A {@code Collector} which concatenates CharSequence elements, - * separated by the specified delimiter, in encounter order - */ - public static Collector<CharSequence, ?, String> joining(CharSequence delimiter) { - return joining(delimiter, "", ""); - } - - /** - * Returns a {@code Collector} that concatenates the input elements, - * separated by the specified delimiter, with the specified prefix and - * suffix, in encounter order. - * - * @param delimiter the delimiter to be used between each element - * @param prefix the sequence of characters to be used at the beginning - * of the joined result - * @param suffix the sequence of characters to be used at the end - * of the joined result - * @return A {@code Collector} which concatenates CharSequence elements, - * separated by the specified delimiter, in encounter order - */ - public static Collector<CharSequence, ?, String> joining(CharSequence delimiter, - CharSequence prefix, - CharSequence suffix) { - return new CollectorImpl<>( - () -> new StringJoiner(delimiter, prefix, suffix), - StringJoiner::add, StringJoiner::merge, - StringJoiner::toString, CH_NOID); - } - - /** - * {@code BinaryOperator<Map>} that merges the contents of its right - * argument into its left argument, using the provided merge function to - * handle duplicate keys. - * - * @param <K> type of the map keys - * @param <V> type of the map values - * @param <M> type of the map - * @param mergeFunction A merge function suitable for - * {@link Map#merge(Object, Object, BiFunction) Map.merge()} - * @return a merge function for two maps - */ - private static <K, V, M extends Map<K,V>> - BinaryOperator<M> mapMerger(BinaryOperator<V> mergeFunction) { - return (m1, m2) -> { - for (Map.Entry<K,V> e : m2.entrySet()) { - m1.merge(e.getKey(), e.getValue(), mergeFunction); - } - return m1; - }; - } - - /** - * Adapts a {@code Collector} accepting elements of type {@code U} to one - * accepting elements of type {@code T} by applying a mapping function to - * each input element before accumulation. - * - * @apiNote - * The {@code mapping()} collectors are most useful when used in a - * multi-level reduction, such as downstream of a {@code groupingBy} or - * {@code partitioningBy}. For example, given a stream of - * {@code Person}, to accumulate the set of last names in each city: - * <pre>{@code - * Map<City, Set<String>> lastNamesByCity - * = people.stream().collect(groupingBy(Person::getCity, - * mapping(Person::getLastName, toSet()))); - * }</pre> - * - * @param <T> the type of the input elements - * @param <U> type of elements accepted by downstream collector - * @param <A> intermediate accumulation type of the downstream collector - * @param <R> result type of collector - * @param mapper a function to be applied to the input elements - * @param downstream a collector which will accept mapped values - * @return a collector which applies the mapping function to the input - * elements and provides the mapped results to the downstream collector - */ - public static <T, U, A, R> - Collector<T, ?, R> mapping(Function<? super T, ? extends U> mapper, - Collector<? super U, A, R> downstream) { - BiConsumer<A, ? super U> downstreamAccumulator = downstream.accumulator(); - return new CollectorImpl<>(downstream.supplier(), - (r, t) -> downstreamAccumulator.accept(r, mapper.apply(t)), - downstream.combiner(), downstream.finisher(), - downstream.characteristics()); - } - - /** - * Adapts a {@code Collector} to perform an additional finishing - * transformation. For example, one could adapt the {@link #toList()} - * collector to always produce an immutable list with: - * <pre>{@code - * List<String> people - * = people.stream().collect(collectingAndThen(toList(), Collections::unmodifiableList)); - * }</pre> - * - * @param <T> the type of the input elements - * @param <A> intermediate accumulation type of the downstream collector - * @param <R> result type of the downstream collector - * @param <RR> result type of the resulting collector - * @param downstream a collector - * @param finisher a function to be applied to the final result of the downstream collector - * @return a collector which performs the action of the downstream collector, - * followed by an additional finishing step - */ - public static<T,A,R,RR> Collector<T,A,RR> collectingAndThen(Collector<T,A,R> downstream, - Function<R,RR> finisher) { - Set<Collector.Characteristics> characteristics = downstream.characteristics(); - if (characteristics.contains(Collector.Characteristics.IDENTITY_FINISH)) { - if (characteristics.size() == 1) - characteristics = CollectorsPlus.CH_NOID; - else { - characteristics = EnumSet.copyOf(characteristics); - characteristics.remove(Collector.Characteristics.IDENTITY_FINISH); - characteristics = Collections.unmodifiableSet(characteristics); - } - } - return new CollectorImpl<>(downstream.supplier(), - downstream.accumulator(), - downstream.combiner(), - downstream.finisher().andThen(finisher), - characteristics); - } - - /** - * Returns a {@code Collector} accepting elements of type {@code T} that - * counts the number of input elements. If no elements are present, the - * result is 0. - * - * @implSpec - * This produces a result equivalent to: - * <pre>{@code - * reducing(0L, e -> 1L, Long::sum) - * }</pre> - * - * @param <T> the type of the input elements - * @return a {@code Collector} that counts the input elements - */ - public static <T> Collector<T, ?, Long> - counting() { - return reducing(0L, e -> 1L, Long::sum); - } - - /** - * Returns a {@code Collector} that produces the minimal element according - * to a given {@code Comparator}, described as an {@code Optional<T>}. - * - * @implSpec - * This produces a result equivalent to: - * <pre>{@code - * reducing(BinaryOperator.minBy(comparator)) - * }</pre> - * - * @param <T> the type of the input elements - * @param comparator a {@code Comparator} for comparing elements - * @return a {@code Collector} that produces the minimal value - */ - public static <T> Collector<T, ?, Optional<T>> - minBy(Comparator<? super T> comparator) { - return reducing(BinaryOperator.minBy(comparator)); - } - - /** - * Returns a {@code Collector} that produces the maximal element according - * to a given {@code Comparator}, described as an {@code Optional<T>}. - * - * @implSpec - * This produces a result equivalent to: - * <pre>{@code - * reducing(BinaryOperator.maxBy(comparator)) - * }</pre> - * - * @param <T> the type of the input elements - * @param comparator a {@code Comparator} for comparing elements - * @return a {@code Collector} that produces the maximal value - */ - public static <T> Collector<T, ?, Optional<T>> - maxBy(Comparator<? super T> comparator) { - return reducing(BinaryOperator.maxBy(comparator)); - } - - /** - * Returns a {@code Collector} that produces the sum of a integer-valued - * function applied to the input elements. If no elements are present, - * the result is 0. - * - * @param <T> the type of the input elements - * @param mapper a function extracting the property to be summed - * @return a {@code Collector} that produces the sum of a derived property - */ - public static <T> Collector<T, ?, Integer> - summingInt(ToIntFunction<? super T> mapper) { - return new CollectorImpl<>( - () -> new int[1], - (a, t) -> { a[0] += mapper.applyAsInt(t); }, - (a, b) -> { a[0] += b[0]; return a; }, - a -> a[0], CH_NOID); - } - - /** - * Returns a {@code Collector} that produces the sum of a long-valued - * function applied to the input elements. If no elements are present, - * the result is 0. - * - * @param <T> the type of the input elements - * @param mapper a function extracting the property to be summed - * @return a {@code Collector} that produces the sum of a derived property - */ - public static <T> Collector<T, ?, Long> - summingLong(ToLongFunction<? super T> mapper) { - return new CollectorImpl<>( - () -> new long[1], - (a, t) -> { a[0] += mapper.applyAsLong(t); }, - (a, b) -> { a[0] += b[0]; return a; }, - a -> a[0], CH_NOID); - } - - /** - * Returns a {@code Collector} that produces the sum of a double-valued - * function applied to the input elements. If no elements are present, - * the result is 0. - * - * <p>The sum returned can vary depending upon the order in which - * values are recorded, due to accumulated rounding error in - * addition of values of differing magnitudes. Values sorted by increasing - * absolute magnitude tend to yield more accurate results. If any recorded - * value is a {@code NaN} or the sum is at any point a {@code NaN} then the - * sum will be {@code NaN}. - * - * @param <T> the type of the input elements - * @param mapper a function extracting the property to be summed - * @return a {@code Collector} that produces the sum of a derived property - */ - public static <T> Collector<T, ?, Double> - summingDouble(ToDoubleFunction<? super T> mapper) { - /* - * In the arrays allocated for the collect operation, index 0 - * holds the high-order bits of the running sum, index 1 holds - * the low-order bits of the sum computed via compensated - * summation, and index 2 holds the simple sum used to compute - * the proper result if the stream contains infinite values of - * the same sign. - */ - return new CollectorImpl<>( - () -> new double[3], - (a, t) -> { sumWithCompensation(a, mapper.applyAsDouble(t)); - a[2] += mapper.applyAsDouble(t);}, - (a, b) -> { sumWithCompensation(a, b[0]); - a[2] += b[2]; - return sumWithCompensation(a, b[1]); }, - a -> computeFinalSum(a), - CH_NOID); - } - - /** - * Incorporate a new double value using Kahan summation / - * compensation summation. - * - * High-order bits of the sum are in intermediateSum[0], low-order - * bits of the sum are in intermediateSum[1], any additional - * elements are application-specific. - * - * @param intermediateSum the high-order and low-order words of the intermediate sum - * @param value the name value to be included in the running sum - */ - static double[] sumWithCompensation(double[] intermediateSum, double value) { - double tmp = value - intermediateSum[1]; - double sum = intermediateSum[0]; - double velvel = sum + tmp; // Little wolf of rounding error - intermediateSum[1] = (velvel - sum) - tmp; - intermediateSum[0] = velvel; - return intermediateSum; - } - - /** - * If the compensated sum is spuriously NaN from accumulating one - * or more same-signed infinite values, return the - * correctly-signed infinity stored in the simple sum. - */ - static double computeFinalSum(double[] summands) { - // Better error bounds to add both terms as the final sum - double tmp = summands[0] + summands[1]; - double simpleSum = summands[summands.length - 1]; - if (Double.isNaN(tmp) && Double.isInfinite(simpleSum)) { - return simpleSum; - } else { - return tmp; - } - } - - /** - * Returns a {@code Collector} that produces the arithmetic mean of an integer-valued - * function applied to the input elements. If no elements are present, - * the result is 0. - * - * @param <T> the type of the input elements - * @param mapper a function extracting the property to be summed - * @return a {@code Collector} that produces the sum of a derived property - */ - public static <T> Collector<T, ?, Double> - averagingInt(ToIntFunction<? super T> mapper) { - return new CollectorImpl<>( - () -> new long[2], - (a, t) -> { a[0] += mapper.applyAsInt(t); a[1]++; }, - (a, b) -> { a[0] += b[0]; a[1] += b[1]; return a; }, - a -> (a[1] == 0) ? 0.0d : (double) a[0] / a[1], CH_NOID); - } - - /** - * Returns a {@code Collector} that produces the arithmetic mean of a long-valued - * function applied to the input elements. If no elements are present, - * the result is 0. - * - * @param <T> the type of the input elements - * @param mapper a function extracting the property to be summed - * @return a {@code Collector} that produces the sum of a derived property - */ - public static <T> Collector<T, ?, Double> - averagingLong(ToLongFunction<? super T> mapper) { - return new CollectorImpl<>( - () -> new long[2], - (a, t) -> { a[0] += mapper.applyAsLong(t); a[1]++; }, - (a, b) -> { a[0] += b[0]; a[1] += b[1]; return a; }, - a -> (a[1] == 0) ? 0.0d : (double) a[0] / a[1], CH_NOID); - } - - /** - * Returns a {@code Collector} that produces the arithmetic mean of a double-valued - * function applied to the input elements. If no elements are present, - * the result is 0. - * - * <p>The average returned can vary depending upon the order in which - * values are recorded, due to accumulated rounding error in - * addition of values of differing magnitudes. Values sorted by increasing - * absolute magnitude tend to yield more accurate results. If any recorded - * value is a {@code NaN} or the sum is at any point a {@code NaN} then the - * average will be {@code NaN}. - * - * @implNote The {@code double} format can represent all - * consecutive integers in the range -2<sup>53</sup> to - * 2<sup>53</sup>. If the pipeline has more than 2<sup>53</sup> - * values, the divisor in the average computation will saturate at - * 2<sup>53</sup>, leading to additional numerical errors. - * - * @param <T> the type of the input elements - * @param mapper a function extracting the property to be summed - * @return a {@code Collector} that produces the sum of a derived property - */ - public static <T> Collector<T, ?, Double> - averagingDouble(ToDoubleFunction<? super T> mapper) { - /* - * In the arrays allocated for the collect operation, index 0 - * holds the high-order bits of the running sum, index 1 holds - * the low-order bits of the sum computed via compensated - * summation, and index 2 holds the number of values seen. - */ - return new CollectorImpl<>( - () -> new double[4], - (a, t) -> { sumWithCompensation(a, mapper.applyAsDouble(t)); a[2]++; a[3]+= mapper.applyAsDouble(t);}, - (a, b) -> { sumWithCompensation(a, b[0]); sumWithCompensation(a, b[1]); a[2] += b[2]; a[3] += b[3]; return a; }, - a -> (a[2] == 0) ? 0.0d : (computeFinalSum(a) / a[2]), - CH_NOID); - } - - /** - * Returns a {@code Collector} which performs a reduction of its - * input elements under a specified {@code BinaryOperator} using the - * provided identity. - * - * @apiNote - * The {@code reducing()} collectors are most useful when used in a - * multi-level reduction, downstream of {@code groupingBy} or - * {@code partitioningBy}. To perform a simple reduction on a stream, - * use {@link Stream#reduce(Object, BinaryOperator)}} instead. - * - * @param <T> element type for the input and output of the reduction - * @param identity the identity value for the reduction (also, the value - * that is returned when there are no input elements) - * @param op a {@code BinaryOperator<T>} used to reduce the input elements - * @return a {@code Collector} which implements the reduction operation - * - * @see #reducing(BinaryOperator) - * @see #reducing(Object, Function, BinaryOperator) - */ - public static <T> Collector<T, ?, T> - reducing(T identity, BinaryOperator<T> op) { - return new CollectorImpl<>( - boxSupplier(identity), - (a, t) -> { a[0] = op.apply(a[0], t); }, - (a, b) -> { a[0] = op.apply(a[0], b[0]); return a; }, - a -> a[0], - CH_NOID); - } - - @SuppressWarnings("unchecked") - private static <T> Supplier<T[]> boxSupplier(T identity) { - return () -> (T[]) new Object[] { identity }; - } - - /** - * Returns a {@code Collector} which performs a reduction of its - * input elements under a specified {@code BinaryOperator}. The result - * is described as an {@code Optional<T>}. - * - * @apiNote - * The {@code reducing()} collectors are most useful when used in a - * multi-level reduction, downstream of {@code groupingBy} or - * {@code partitioningBy}. To perform a simple reduction on a stream, - * use {@link Stream#reduce(BinaryOperator)} instead. - * - * <p>For example, given a stream of {@code Person}, to calculate tallest - * person in each city: - * <pre>{@code - * Comparator<Person> byHeight = Comparator.comparing(Person::getHeight); - * Map<City, Person> tallestByCity - * = people.stream().collect(groupingBy(Person::getCity, reducing(BinaryOperator.maxBy(byHeight)))); - * }</pre> - * - * @param <T> element type for the input and output of the reduction - * @param op a {@code BinaryOperator<T>} used to reduce the input elements - * @return a {@code Collector} which implements the reduction operation - * - * @see #reducing(Object, BinaryOperator) - * @see #reducing(Object, Function, BinaryOperator) - */ - public static <T> Collector<T, ?, Optional<T>> - reducing(BinaryOperator<T> op) { - class OptionalBox implements Consumer<T> { - T value = null; - boolean present = false; - - @Override - public void accept(T t) { - if (present) { - value = op.apply(value, t); - } - else { - value = t; - present = true; - } - } - } - - return new CollectorImpl<T, OptionalBox, Optional<T>>( - OptionalBox::new, OptionalBox::accept, - (a, b) -> { if (b.present) a.accept(b.value); return a; }, - a -> Optional.ofNullable(a.value), CH_NOID); - } - - /** - * Returns a {@code Collector} which performs a reduction of its - * input elements under a specified mapping function and - * {@code BinaryOperator}. This is a generalization of - * {@link #reducing(Object, BinaryOperator)} which allows a transformation - * of the elements before reduction. - * - * @apiNote - * The {@code reducing()} collectors are most useful when used in a - * multi-level reduction, downstream of {@code groupingBy} or - * {@code partitioningBy}. To perform a simple map-reduce on a stream, - * use {@link Stream#map(Function)} and {@link Stream#reduce(Object, BinaryOperator)} - * instead. - * - * <p>For example, given a stream of {@code Person}, to calculate the longest - * last name of residents in each city: - * <pre>{@code - * Comparator<String> byLength = Comparator.comparing(String::length); - * Map<City, String> longestLastNameByCity - * = people.stream().collect(groupingBy(Person::getCity, - * reducing(Person::getLastName, BinaryOperator.maxBy(byLength)))); - * }</pre> - * - * @param <T> the type of the input elements - * @param <U> the type of the mapped values - * @param identity the identity value for the reduction (also, the value - * that is returned when there are no input elements) - * @param mapper a mapping function to apply to each input value - * @param op a {@code BinaryOperator<U>} used to reduce the mapped values - * @return a {@code Collector} implementing the map-reduce operation - * - * @see #reducing(Object, BinaryOperator) - * @see #reducing(BinaryOperator) - */ - public static <T, U> - Collector<T, ?, U> reducing(U identity, - Function<? super T, ? extends U> mapper, - BinaryOperator<U> op) { - return new CollectorImpl<>( - boxSupplier(identity), - (a, t) -> { a[0] = op.apply(a[0], mapper.apply(t)); }, - (a, b) -> { a[0] = op.apply(a[0], b[0]); return a; }, - a -> a[0], CH_NOID); - } - - /** - * Returns a {@code Collector} implementing a "group by" operation on - * input elements of type {@code T}, grouping elements according to a - * classification function, and returning the results in a {@code Map}. - * - * <p>The classification function maps elements to some key type {@code K}. - * The collector produces a {@code Map<K, List<T>>} whose keys are the - * values resulting from applying the classification function to the input - * elements, and whose corresponding values are {@code List}s containing the - * input elements which map to the associated key under the classification - * function. - * - * <p>There are no guarantees on the type, mutability, serializability, or - * thread-safety of the {@code Map} or {@code List} objects returned. - * @implSpec - * This produces a result similar to: - * <pre>{@code - * groupingBy(classifier, toList()); - * }</pre> - * - * @implNote - * The returned {@code Collector} is not concurrent. For parallel stream - * pipelines, the {@code combiner} function operates by merging the keys - * from one map into another, which can be an expensive operation. If - * preservation of the order in which elements appear in the resulting {@code Map} - * collector is not required, using {@link #groupingByConcurrent(Function)} - * may offer better parallel performance. - * - * @param <T> the type of the input elements - * @param <K> the type of the keys - * @param classifier the classifier function mapping input elements to keys - * @return a {@code Collector} implementing the group-by operation - * - * @see #groupingBy(Function, Collector) - * @see #groupingBy(Function, Supplier, Collector) - * @see #groupingByConcurrent(Function) - */ - public static <T, K> Collector<T, ?, Map<K, List<T>>> - groupingBy(Function<? super T, ? extends K> classifier) { - return groupingBy(classifier, toList()); - } - - /** - * Returns a {@code Collector} implementing a cascaded "group by" operation - * on input elements of type {@code T}, grouping elements according to a - * classification function, and then performing a reduction operation on - * the values associated with a given key using the specified downstream - * {@code Collector}. - * - * <p>The classification function maps elements to some key type {@code K}. - * The downstream collector operates on elements of type {@code T} and - * produces a result of type {@code D}. The resulting collector produces a - * {@code Map<K, D>}. - * - * <p>There are no guarantees on the type, mutability, - * serializability, or thread-safety of the {@code Map} returned. - * - * <p>For example, to compute the set of last names of people in each city: - * <pre>{@code - * Map<City, Set<String>> namesByCity - * = people.stream().collect(groupingBy(Person::getCity, - * mapping(Person::getLastName, toSet()))); - * }</pre> - * - * @implNote - * The returned {@code Collector} is not concurrent. For parallel stream - * pipelines, the {@code combiner} function operates by merging the keys - * from one map into another, which can be an expensive operation. If - * preservation of the order in which elements are presented to the downstream - * collector is not required, using {@link #groupingByConcurrent(Function, Collector)} - * may offer better parallel performance. - * - * @param <T> the type of the input elements - * @param <K> the type of the keys - * @param <A> the intermediate accumulation type of the downstream collector - * @param <D> the result type of the downstream reduction - * @param classifier a classifier function mapping input elements to keys - * @param downstream a {@code Collector} implementing the downstream reduction - * @return a {@code Collector} implementing the cascaded group-by operation - * @see #groupingBy(Function) - * - * @see #groupingBy(Function, Supplier, Collector) - * @see #groupingByConcurrent(Function, Collector) - */ - public static <T, K, A, D> - Collector<T, ?, Map<K, D>> groupingBy(Function<? super T, ? extends K> classifier, - Collector<? super T, A, D> downstream) { - return groupingBy(classifier, HashMap::new, downstream); - } - - /** - * Returns a {@code Collector} implementing a cascaded "group by" operation - * on input elements of type {@code T}, grouping elements according to a - * classification function, and then performing a reduction operation on - * the values associated with a given key using the specified downstream - * {@code Collector}. The {@code Map} produced by the Collector is created - * with the supplied factory function. - * - * <p>The classification function maps elements to some key type {@code K}. - * The downstream collector operates on elements of type {@code T} and - * produces a result of type {@code D}. The resulting collector produces a - * {@code Map<K, D>}. - * - * <p>For example, to compute the set of last names of people in each city, - * where the city names are sorted: - * <pre>{@code - * Map<City, Set<String>> namesByCity - * = people.stream().collect(groupingBy(Person::getCity, TreeMap::new, - * mapping(Person::getLastName, toSet()))); - * }</pre> - * - * @implNote - * The returned {@code Collector} is not concurrent. For parallel stream - * pipelines, the {@code combiner} function operates by merging the keys - * from one map into another, which can be an expensive operation. If - * preservation of the order in which elements are presented to the downstream - * collector is not required, using {@link #groupingByConcurrent(Function, Supplier, Collector)} - * may offer better parallel performance. - * - * @param <T> the type of the input elements - * @param <K> the type of the keys - * @param <A> the intermediate accumulation type of the downstream collector - * @param <D> the result type of the downstream reduction - * @param <M> the type of the resulting {@code Map} - * @param classifier a classifier function mapping input elements to keys - * @param downstream a {@code Collector} implementing the downstream reduction - * @param mapFactory a function which, when called, produces a new empty - * {@code Map} of the desired type - * @return a {@code Collector} implementing the cascaded group-by operation - * - * @see #groupingBy(Function, Collector) - * @see #groupingBy(Function) - * @see #groupingByConcurrent(Function, Supplier, Collector) - */ - public static <T, K, D, A, M extends Map<K, D>> - Collector<T, ?, M> groupingBy(Function<? super T, ? extends K> classifier, - Supplier<M> mapFactory, - Collector<? super T, A, D> downstream) { - Supplier<A> downstreamSupplier = downstream.supplier(); - BiConsumer<A, ? super T> downstreamAccumulator = downstream.accumulator(); - BiConsumer<Map<K, A>, T> accumulator = (m, t) -> { - K key = Objects.requireNonNull(classifier.apply(t), "element cannot be mapped to a null key"); - A container = m.computeIfAbsent(key, k -> downstreamSupplier.get()); - downstreamAccumulator.accept(container, t); - }; - BinaryOperator<Map<K, A>> merger = CollectorsPlus.<K, A, Map<K, A>>mapMerger(downstream.combiner()); - @SuppressWarnings("unchecked") - Supplier<Map<K, A>> mangledFactory = (Supplier<Map<K, A>>) mapFactory; - - if (downstream.characteristics().contains(Collector.Characteristics.IDENTITY_FINISH)) { - return new CollectorImpl<>(mangledFactory, accumulator, merger, CH_ID); - } - else { - @SuppressWarnings("unchecked") - Function<A, A> downstreamFinisher = (Function<A, A>) downstream.finisher(); - Function<Map<K, A>, M> finisher = intermediate -> { - intermediate.replaceAll((k, v) -> downstreamFinisher.apply(v)); - @SuppressWarnings("unchecked") - M castResult = (M) intermediate; - return castResult; - }; - return new CollectorImpl<>(mangledFactory, accumulator, merger, finisher, CH_NOID); - } - } - - /** - * Returns a concurrent {@code Collector} implementing a "group by" - * operation on input elements of type {@code T}, grouping elements - * according to a classification function. - * - * <p>This is a {@link Collector.Characteristics#CONCURRENT concurrent} and - * {@link Collector.Characteristics#UNORDERED unordered} Collector. - * - * <p>The classification function maps elements to some key type {@code K}. - * The collector produces a {@code ConcurrentMap<K, List<T>>} whose keys are the - * values resulting from applying the classification function to the input - * elements, and whose corresponding values are {@code List}s containing the - * input elements which map to the associated key under the classification - * function. - * - * <p>There are no guarantees on the type, mutability, or serializability - * of the {@code Map} or {@code List} objects returned, or of the - * thread-safety of the {@code List} objects returned. - * @implSpec - * This produces a result similar to: - * <pre>{@code - * groupingByConcurrent(classifier, toList()); - * }</pre> - * - * @param <T> the type of the input elements - * @param <K> the type of the keys - * @param classifier a classifier function mapping input elements to keys - * @return a concurrent, unordered {@code Collector} implementing the group-by operation - * - * @see #groupingBy(Function) - * @see #groupingByConcurrent(Function, Collector) - * @see #groupingByConcurrent(Function, Supplier, Collector) - */ - public static <T, K> - Collector<T, ?, ConcurrentMap<K, List<T>>> - groupingByConcurrent(Function<? super T, ? extends K> classifier) { - return groupingByConcurrent(classifier, ConcurrentHashMap::new, toList()); - } - - /** - * Returns a concurrent {@code Collector} implementing a cascaded "group by" - * operation on input elements of type {@code T}, grouping elements - * according to a classification function, and then performing a reduction - * operation on the values associated with a given key using the specified - * downstream {@code Collector}. - * - * <p>This is a {@link Collector.Characteristics#CONCURRENT concurrent} and - * {@link Collector.Characteristics#UNORDERED unordered} Collector. - * - * <p>The classification function maps elements to some key type {@code K}. - * The downstream collector operates on elements of type {@code T} and - * produces a result of type {@code D}. The resulting collector produces a - * {@code Map<K, D>}. - * - * <p>For example, to compute the set of last names of people in each city, - * where the city names are sorted: - * <pre>{@code - * ConcurrentMap<City, Set<String>> namesByCity - * = people.stream().collect(groupingByConcurrent(Person::getCity, - * mapping(Person::getLastName, toSet()))); - * }</pre> - * - * @param <T> the type of the input elements - * @param <K> the type of the keys - * @param <A> the intermediate accumulation type of the downstream collector - * @param <D> the result type of the downstream reduction - * @param classifier a classifier function mapping input elements to keys - * @param downstream a {@code Collector} implementing the downstream reduction - * @return a concurrent, unordered {@code Collector} implementing the cascaded group-by operation - * - * @see #groupingBy(Function, Collector) - * @see #groupingByConcurrent(Function) - * @see #groupingByConcurrent(Function, Supplier, Collector) - */ - public static <T, K, A, D> - Collector<T, ?, ConcurrentMap<K, D>> groupingByConcurrent(Function<? super T, ? extends K> classifier, - Collector<? super T, A, D> downstream) { - return groupingByConcurrent(classifier, ConcurrentHashMap::new, downstream); - } - - /** - * Returns a concurrent {@code Collector} implementing a cascaded "group by" - * operation on input elements of type {@code T}, grouping elements - * according to a classification function, and then performing a reduction - * operation on the values associated with a given key using the specified - * downstream {@code Collector}. The {@code ConcurrentMap} produced by the - * Collector is created with the supplied factory function. - * - * <p>This is a {@link Collector.Characteristics#CONCURRENT concurrent} and - * {@link Collector.Characteristics#UNORDERED unordered} Collector. - * - * <p>The classification function maps elements to some key type {@code K}. - * The downstream collector operates on elements of type {@code T} and - * produces a result of type {@code D}. The resulting collector produces a - * {@code Map<K, D>}. - * - * <p>For example, to compute the set of last names of people in each city, - * where the city names are sorted: - * <pre>{@code - * ConcurrentMap<City, Set<String>> namesByCity - * = people.stream().collect(groupingBy(Person::getCity, ConcurrentSkipListMap::new, - * mapping(Person::getLastName, toSet()))); - * }</pre> - * - * - * @param <T> the type of the input elements - * @param <K> the type of the keys - * @param <A> the intermediate accumulation type of the downstream collector - * @param <D> the result type of the downstream reduction - * @param <M> the type of the resulting {@code ConcurrentMap} - * @param classifier a classifier function mapping input elements to keys - * @param downstream a {@code Collector} implementing the downstream reduction - * @param mapFactory a function which, when called, produces a new empty - * {@code ConcurrentMap} of the desired type - * @return a concurrent, unordered {@code Collector} implementing the cascaded group-by operation - * - * @see #groupingByConcurrent(Function) - * @see #groupingByConcurrent(Function, Collector) - * @see #groupingBy(Function, Supplier, Collector) - */ - public static <T, K, A, D, M extends ConcurrentMap<K, D>> - Collector<T, ?, M> groupingByConcurrent(Function<? super T, ? extends K> classifier, - Supplier<M> mapFactory, - Collector<? super T, A, D> downstream) { - Supplier<A> downstreamSupplier = downstream.supplier(); - BiConsumer<A, ? super T> downstreamAccumulator = downstream.accumulator(); - BinaryOperator<ConcurrentMap<K, A>> merger = CollectorsPlus.<K, A, ConcurrentMap<K, A>>mapMerger(downstream.combiner()); - @SuppressWarnings("unchecked") - Supplier<ConcurrentMap<K, A>> mangledFactory = (Supplier<ConcurrentMap<K, A>>) mapFactory; - BiConsumer<ConcurrentMap<K, A>, T> accumulator; - if (downstream.characteristics().contains(Collector.Characteristics.CONCURRENT)) { - accumulator = (m, t) -> { - K key = Objects.requireNonNull(classifier.apply(t), "element cannot be mapped to a null key"); - A resultContainer = m.computeIfAbsent(key, k -> downstreamSupplier.get()); - downstreamAccumulator.accept(resultContainer, t); - }; - } - else { - accumulator = (m, t) -> { - K key = Objects.requireNonNull(classifier.apply(t), "element cannot be mapped to a null key"); - A resultContainer = m.computeIfAbsent(key, k -> downstreamSupplier.get()); - synchronized (resultContainer) { - downstreamAccumulator.accept(resultContainer, t); - } - }; - } - - if (downstream.characteristics().contains(Collector.Characteristics.IDENTITY_FINISH)) { - return new CollectorImpl<>(mangledFactory, accumulator, merger, CH_CONCURRENT_ID); - } - else { - @SuppressWarnings("unchecked") - Function<A, A> downstreamFinisher = (Function<A, A>) downstream.finisher(); - Function<ConcurrentMap<K, A>, M> finisher = intermediate -> { - intermediate.replaceAll((k, v) -> downstreamFinisher.apply(v)); - @SuppressWarnings("unchecked") - M castResult = (M) intermediate; - return castResult; - }; - return new CollectorImpl<>(mangledFactory, accumulator, merger, finisher, CH_CONCURRENT_NOID); - } - } - - /** - * Returns a {@code Collector} which partitions the input elements according - * to a {@code Predicate}, and organizes them into a - * {@code Map<Boolean, List<T>>}. - * - * There are no guarantees on the type, mutability, - * serializability, or thread-safety of the {@code Map} returned. - * - * @param <T> the type of the input elements - * @param predicate a predicate used for classifying input elements - * @return a {@code Collector} implementing the partitioning operation - * - * @see #partitioningBy(Predicate, Collector) - */ - public static <T> - Collector<T, ?, Map<Boolean, List<T>>> partitioningBy(Predicate<? super T> predicate) { - return partitioningBy(predicate, toList()); - } - - /** - * Returns a {@code Collector} which partitions the input elements according - * to a {@code Predicate}, reduces the values in each partition according to - * another {@code Collector}, and organizes them into a - * {@code Map<Boolean, D>} whose values are the result of the downstream - * reduction. - * - * <p>There are no guarantees on the type, mutability, - * serializability, or thread-safety of the {@code Map} returned. - * - * @param <T> the type of the input elements - * @param <A> the intermediate accumulation type of the downstream collector - * @param <D> the result type of the downstream reduction - * @param predicate a predicate used for classifying input elements - * @param downstream a {@code Collector} implementing the downstream - * reduction - * @return a {@code Collector} implementing the cascaded partitioning - * operation - * - * @see #partitioningBy(Predicate) - */ - public static <T, D, A> - Collector<T, ?, Map<Boolean, D>> partitioningBy(Predicate<? super T> predicate, - Collector<? super T, A, D> downstream) { - BiConsumer<A, ? super T> downstreamAccumulator = downstream.accumulator(); - BiConsumer<Partition<A>, T> accumulator = (result, t) -> - downstreamAccumulator.accept(predicate.test(t) ? result.forTrue : result.forFalse, t); - BinaryOperator<A> op = downstream.combiner(); - BinaryOperator<Partition<A>> merger = (left, right) -> - new Partition<>(op.apply(left.forTrue, right.forTrue), - op.apply(left.forFalse, right.forFalse)); - Supplier<Partition<A>> supplier = () -> - new Partition<>(downstream.supplier().get(), - downstream.supplier().get()); - if (downstream.characteristics().contains(Collector.Characteristics.IDENTITY_FINISH)) { - return new CollectorImpl<>(supplier, accumulator, merger, CH_ID); - } - else { - Function<Partition<A>, Map<Boolean, D>> finisher = par -> - new Partition<>(downstream.finisher().apply(par.forTrue), - downstream.finisher().apply(par.forFalse)); - return new CollectorImpl<>(supplier, accumulator, merger, finisher, CH_NOID); - } - } - - /** - * Returns a {@code Collector} that accumulates elements into a - * {@code Map} whose keys and values are the result of applying the provided - * mapping functions to the input elements. - * - * <p>If the mapped keys contains duplicates (according to - * {@link Object#equals(Object)}), an {@code IllegalStateException} is - * thrown when the collection operation is performed. If the mapped keys - * may have duplicates, use {@link #toMap(Function, Function, BinaryOperator)} - * instead. - * - * @apiNote - * It is common for either the key or the value to be the input elements. - * In this case, the utility method - * {@link Function#identity()} may be helpful. - * For example, the following produces a {@code Map} mapping - * students to their grade point average: - * <pre>{@code - * Map<Student, Double> studentToGPA - * students.stream().collect(toMap(Functions.identity(), - * student -> computeGPA(student))); - * }</pre> - * And the following produces a {@code Map} mapping a unique identifier to - * students: - * <pre>{@code - * Map<String, Student> studentIdToStudent - * students.stream().collect(toMap(Student::getId, - * Functions.identity()); - * }</pre> - * - * @implNote - * The returned {@code Collector} is not concurrent. For parallel stream - * pipelines, the {@code combiner} function operates by merging the keys - * from one map into another, which can be an expensive operation. If it is - * not required that results are inserted into the {@code Map} in encounter - * order, using {@link #toConcurrentMap(Function, Function)} - * may offer better parallel performance. - * - * @param <T> the type of the input elements - * @param <K> the output type of the key mapping function - * @param <U> the output type of the value mapping function - * @param keyMapper a mapping function to produce keys - * @param valueMapper a mapping function to produce values - * @return a {@code Collector} which collects elements into a {@code Map} - * whose keys and values are the result of applying mapping functions to - * the input elements - * - * @see #toMap(Function, Function, BinaryOperator) - * @see #toMap(Function, Function, BinaryOperator, Supplier) - * @see #toConcurrentMap(Function, Function) - */ - public static <T, K, U> - Collector<T, ?, Map<K,U>> toMap(Function<? super T, ? extends K> keyMapper, - Function<? super T, ? extends U> valueMapper) { - return toMap(keyMapper, valueMapper, throwingMerger(), HashMap::new); - } - - /** - * Returns a {@code Collector} that accumulates elements into a - * {@code Map} whose keys and values are the result of applying the provided - * mapping functions to the input elements. - * - * <p>If the mapped - * keys contains duplicates (according to {@link Object#equals(Object)}), - * the value mapping function is applied to each equal element, and the - * results are merged using the provided merging function. - * - * @apiNote - * There are multiple ways to deal with collisions between multiple elements - * mapping to the same key. The other forms of {@code toMap} simply use - * a merge function that throws unconditionally, but you can easily write - * more flexible merge policies. For example, if you have a stream - * of {@code Person}, and you want to produce a "phone book" mapping name to - * address, but it is possible that two persons have the same name, you can - * do as follows to gracefully deals with these collisions, and produce a - * {@code Map} mapping names to a concatenated list of addresses: - * <pre>{@code - * Map<String, String> phoneBook - * people.stream().collect(toMap(Person::getName, - * Person::getAddress, - * (s, a) -> s + ", " + a)); - * }</pre> - * - * @implNote - * The returned {@code Collector} is not concurrent. For parallel stream - * pipelines, the {@code combiner} function operates by merging the keys - * from one map into another, which can be an expensive operation. If it is - * not required that results are merged into the {@code Map} in encounter - * order, using {@link #toConcurrentMap(Function, Function, BinaryOperator)} - * may offer better parallel performance. - * - * @param <T> the type of the input elements - * @param <K> the output type of the key mapping function - * @param <U> the output type of the value mapping function - * @param keyMapper a mapping function to produce keys - * @param valueMapper a mapping function to produce values - * @param mergeFunction a merge function, used to resolve collisions between - * values associated with the same key, as supplied - * to {@link Map#merge(Object, Object, BiFunction)} - * @return a {@code Collector} which collects elements into a {@code Map} - * whose keys are the result of applying a key mapping function to the input - * elements, and whose values are the result of applying a value mapping - * function to all input elements equal to the key and combining them - * using the merge function - * - * @see #toMap(Function, Function) - * @see #toMap(Function, Function, BinaryOperator, Supplier) - * @see #toConcurrentMap(Function, Function, BinaryOperator) - */ - public static <T, K, U> - Collector<T, ?, Map<K,U>> toMap(Function<? super T, ? extends K> keyMapper, - Function<? super T, ? extends U> valueMapper, - BinaryOperator<U> mergeFunction) { - return toMap(keyMapper, valueMapper, mergeFunction, HashMap::new); - } - - /** - * Returns a {@code Collector} that accumulates elements into a - * {@code Map} whose keys and values are the result of applying the provided - * mapping functions to the input elements. - * - * <p>If the mapped - * keys contains duplicates (according to {@link Object#equals(Object)}), - * the value mapping function is applied to each equal element, and the - * results are merged using the provided merging function. The {@code Map} - * is created by a provided supplier function. - * - * @implNote - * The returned {@code Collector} is not concurrent. For parallel stream - * pipelines, the {@code combiner} function operates by merging the keys - * from one map into another, which can be an expensive operation. If it is - * not required that results are merged into the {@code Map} in encounter - * order, using {@link #toConcurrentMap(Function, Function, BinaryOperator, Supplier)} - * may offer better parallel performance. - * - * @param <T> the type of the input elements - * @param <K> the output type of the key mapping function - * @param <U> the output type of the value mapping function - * @param <M> the type of the resulting {@code Map} - * @param keyMapper a mapping function to produce keys - * @param valueMapper a mapping function to produce values - * @param mergeFunction a merge function, used to resolve collisions between - * values associated with the same key, as supplied - * to {@link Map#merge(Object, Object, BiFunction)} - * @param mapSupplier a function which returns a new, empty {@code Map} into - * which the results will be inserted - * @return a {@code Collector} which collects elements into a {@code Map} - * whose keys are the result of applying a key mapping function to the input - * elements, and whose values are the result of applying a value mapping - * function to all input elements equal to the key and combining them - * using the merge function - * - * @see #toMap(Function, Function) - * @see #toMap(Function, Function, BinaryOperator) - * @see #toConcurrentMap(Function, Function, BinaryOperator, Supplier) - */ - public static <T, K, U, M extends Map<K, U>> - Collector<T, ?, M> toMap(Function<? super T, ? extends K> keyMapper, - Function<? super T, ? extends U> valueMapper, - BinaryOperator<U> mergeFunction, - Supplier<M> mapSupplier) { - BiConsumer<M, T> accumulator - = (map, element) -> map.merge(keyMapper.apply(element), - valueMapper.apply(element), mergeFunction); - return new CollectorImpl<>(mapSupplier, accumulator, mapMerger(mergeFunction), CH_ID); - } - - /** - * Returns a concurrent {@code Collector} that accumulates elements into a - * {@code ConcurrentMap} whose keys and values are the result of applying - * the provided mapping functions to the input elements. - * - * <p>If the mapped keys contains duplicates (according to - * {@link Object#equals(Object)}), an {@code IllegalStateException} is - * thrown when the collection operation is performed. If the mapped keys - * may have duplicates, use - * {@link #toConcurrentMap(Function, Function, BinaryOperator)} instead. - * - * @apiNote - * It is common for either the key or the value to be the input elements. - * In this case, the utility method - * {@link Function#identity()} may be helpful. - * For example, the following produces a {@code Map} mapping - * students to their grade point average: - * <pre>{@code - * Map<Student, Double> studentToGPA - * students.stream().collect(toMap(Functions.identity(), - * student -> computeGPA(student))); - * }</pre> - * And the following produces a {@code Map} mapping a unique identifier to - * students: - * <pre>{@code - * Map<String, Student> studentIdToStudent - * students.stream().collect(toConcurrentMap(Student::getId, - * Functions.identity()); - * }</pre> - * - * <p>This is a {@link Collector.Characteristics#CONCURRENT concurrent} and - * {@link Collector.Characteristics#UNORDERED unordered} Collector. - * - * @param <T> the type of the input elements - * @param <K> the output type of the key mapping function - * @param <U> the output type of the value mapping function - * @param keyMapper the mapping function to produce keys - * @param valueMapper the mapping function to produce values - * @return a concurrent, unordered {@code Collector} which collects elements into a - * {@code ConcurrentMap} whose keys are the result of applying a key mapping - * function to the input elements, and whose values are the result of - * applying a value mapping function to the input elements - * - * @see #toMap(Function, Function) - * @see #toConcurrentMap(Function, Function, BinaryOperator) - * @see #toConcurrentMap(Function, Function, BinaryOperator, Supplier) - */ - public static <T, K, U> - Collector<T, ?, ConcurrentMap<K,U>> toConcurrentMap(Function<? super T, ? extends K> keyMapper, - Function<? super T, ? extends U> valueMapper) { - return toConcurrentMap(keyMapper, valueMapper, throwingMerger(), ConcurrentHashMap::new); - } - - /** - * Returns a concurrent {@code Collector} that accumulates elements into a - * {@code ConcurrentMap} whose keys and values are the result of applying - * the provided mapping functions to the input elements. - * - * <p>If the mapped keys contains duplicates (according to {@link Object#equals(Object)}), - * the value mapping function is applied to each equal element, and the - * results are merged using the provided merging function. - * - * @apiNote - * There are multiple ways to deal with collisions between multiple elements - * mapping to the same key. The other forms of {@code toConcurrentMap} simply use - * a merge function that throws unconditionally, but you can easily write - * more flexible merge policies. For example, if you have a stream - * of {@code Person}, and you want to produce a "phone book" mapping name to - * address, but it is possible that two persons have the same name, you can - * do as follows to gracefully deals with these collisions, and produce a - * {@code Map} mapping names to a concatenated list of addresses: - * <pre>{@code - * Map<String, String> phoneBook - * people.stream().collect(toConcurrentMap(Person::getName, - * Person::getAddress, - * (s, a) -> s + ", " + a)); - * }</pre> - * - * <p>This is a {@link Collector.Characteristics#CONCURRENT concurrent} and - * {@link Collector.Characteristics#UNORDERED unordered} Collector. - * - * @param <T> the type of the input elements - * @param <K> the output type of the key mapping function - * @param <U> the output type of the value mapping function - * @param keyMapper a mapping function to produce keys - * @param valueMapper a mapping function to produce values - * @param mergeFunction a merge function, used to resolve collisions between - * values associated with the same key, as supplied - * to {@link Map#merge(Object, Object, BiFunction)} - * @return a concurrent, unordered {@code Collector} which collects elements into a - * {@code ConcurrentMap} whose keys are the result of applying a key mapping - * function to the input elements, and whose values are the result of - * applying a value mapping function to all input elements equal to the key - * and combining them using the merge function - * - * @see #toConcurrentMap(Function, Function) - * @see #toConcurrentMap(Function, Function, BinaryOperator, Supplier) - * @see #toMap(Function, Function, BinaryOperator) - */ - public static <T, K, U> - Collector<T, ?, ConcurrentMap<K,U>> - toConcurrentMap(Function<? super T, ? extends K> keyMapper, - Function<? super T, ? extends U> valueMapper, - BinaryOperator<U> mergeFunction) { - return toConcurrentMap(keyMapper, valueMapper, mergeFunction, ConcurrentHashMap::new); - } - - /** - * Returns a concurrent {@code Collector} that accumulates elements into a - * {@code ConcurrentMap} whose keys and values are the result of applying - * the provided mapping functions to the input elements. - * - * <p>If the mapped keys contains duplicates (according to {@link Object#equals(Object)}), - * the value mapping function is applied to each equal element, and the - * results are merged using the provided merging function. The - * {@code ConcurrentMap} is created by a provided supplier function. - * - * <p>This is a {@link Collector.Characteristics#CONCURRENT concurrent} and - * {@link Collector.Characteristics#UNORDERED unordered} Collector. - * - * @param <T> the type of the input elements - * @param <K> the output type of the key mapping function - * @param <U> the output type of the value mapping function - * @param <M> the type of the resulting {@code ConcurrentMap} - * @param keyMapper a mapping function to produce keys - * @param valueMapper a mapping function to produce values - * @param mergeFunction a merge function, used to resolve collisions between - * values associated with the same key, as supplied - * to {@link Map#merge(Object, Object, BiFunction)} - * @param mapSupplier a function which returns a new, empty {@code Map} into - * which the results will be inserted - * @return a concurrent, unordered {@code Collector} which collects elements into a - * {@code ConcurrentMap} whose keys are the result of applying a key mapping - * function to the input elements, and whose values are the result of - * applying a value mapping function to all input elements equal to the key - * and combining them using the merge function - * - * @see #toConcurrentMap(Function, Function) - * @see #toConcurrentMap(Function, Function, BinaryOperator) - * @see #toMap(Function, Function, BinaryOperator, Supplier) - */ - public static <T, K, U, M extends ConcurrentMap<K, U>> - Collector<T, ?, M> toConcurrentMap(Function<? super T, ? extends K> keyMapper, - Function<? super T, ? extends U> valueMapper, - BinaryOperator<U> mergeFunction, - Supplier<M> mapSupplier) { - BiConsumer<M, T> accumulator - = (map, element) -> map.merge(keyMapper.apply(element), - valueMapper.apply(element), mergeFunction); - return new CollectorImpl<>(mapSupplier, accumulator, mapMerger(mergeFunction), CH_CONCURRENT_ID); - } - - /** - * Returns a {@code Collector} which applies an {@code int}-producing - * mapping function to each input element, and returns summary statistics - * for the resulting values. - * - * @param <T> the type of the input elements - * @param mapper a mapping function to apply to each element - * @return a {@code Collector} implementing the summary-statistics reduction - * - * @see #summarizingDouble(ToDoubleFunction) - * @see #summarizingLong(ToLongFunction) - */ - public static <T> - Collector<T, ?, IntSummaryStatistics> summarizingInt(ToIntFunction<? super T> mapper) { - return new CollectorImpl<T, IntSummaryStatistics, IntSummaryStatistics>( - IntSummaryStatistics::new, - (r, t) -> r.accept(mapper.applyAsInt(t)), - (l, r) -> { l.combine(r); return l; }, CH_ID); - } - - /** - * Returns a {@code Collector} which applies an {@code long}-producing - * mapping function to each input element, and returns summary statistics - * for the resulting values. - * - * @param <T> the type of the input elements - * @param mapper the mapping function to apply to each element - * @return a {@code Collector} implementing the summary-statistics reduction - * - * @see #summarizingDouble(ToDoubleFunction) - * @see #summarizingInt(ToIntFunction) - */ - public static <T> - Collector<T, ?, LongSummaryStatistics> summarizingLong(ToLongFunction<? super T> mapper) { - return new CollectorImpl<T, LongSummaryStatistics, LongSummaryStatistics>( - LongSummaryStatistics::new, - (r, t) -> r.accept(mapper.applyAsLong(t)), - (l, r) -> { l.combine(r); return l; }, CH_ID); - } - - /** - * Returns a {@code Collector} which applies an {@code double}-producing - * mapping function to each input element, and returns summary statistics - * for the resulting values. - * - * @param <T> the type of the input elements - * @param mapper a mapping function to apply to each element - * @return a {@code Collector} implementing the summary-statistics reduction - * - * @see #summarizingLong(ToLongFunction) - * @see #summarizingInt(ToIntFunction) - */ - public static <T> - Collector<T, ?, DoubleSummaryStatistics> summarizingDouble(ToDoubleFunction<? super T> mapper) { - return new CollectorImpl<T, DoubleSummaryStatistics, DoubleSummaryStatistics>( - DoubleSummaryStatistics::new, - (r, t) -> r.accept(mapper.applyAsDouble(t)), - (l, r) -> { l.combine(r); return l; }, CH_ID); - } - - /** - * BigDecimal求和 - * @Author lin.liu - * @Description BigDecimal求和 - * @Date 2021/8/26 - * @Param [mapper] - * @return java.util.stream.Collector<T,?,java.math.BigDecimal> - **/ - public static <T> Collector<T, ?, BigDecimal> summingBigDecimal(ToBigDecimalFunction<? super T> mapper) { - return new CollectorImpl<>(() -> new BigDecimal[1], (a, t) -> { - if (a[0] == null) { - a[0] = BigDecimal.ZERO; - } - a[0] = a[0].add(mapper.applyAsBigDecimal(t)); - }, (a, b) -> { - a[0] = a[0].add(b[0]); - return a; - }, a -> a[0], CH_NOID); - } - - /** - * Implementation class used by partitioningBy. - */ - private static final class Partition<T> - extends AbstractMap<Boolean, T> - implements Map<Boolean, T> { - final T forTrue; - final T forFalse; - - Partition(T forTrue, T forFalse) { - this.forTrue = forTrue; - this.forFalse = forFalse; - } - - @Override - public Set<Entry<Boolean, T>> entrySet() { - return new AbstractSet<Entry<Boolean, T>>() { - @Override - public Iterator<Entry<Boolean, T>> iterator() { - Entry<Boolean, T> falseEntry = new SimpleImmutableEntry<>(false, forFalse); - Entry<Boolean, T> trueEntry = new SimpleImmutableEntry<>(true, forTrue); - return Arrays.asList(falseEntry, trueEntry).iterator(); - } - - @Override - public int size() { - return 2; - } - }; - } - } -} diff --git a/src/main/java/com/lunhan/xxx/common/jackson/BigNumberSerializer.java b/src/main/java/com/lunhan/xxx/common/jackson/BigNumberSerializer.java deleted file mode 100644 index 619d0c1..0000000 --- a/src/main/java/com/lunhan/xxx/common/jackson/BigNumberSerializer.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.lunhan.xxx.common.jackson; - -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JacksonStdImpl; -import com.fasterxml.jackson.databind.ser.std.NumberSerializer; - -import java.io.IOException; - -@JacksonStdImpl -public class BigNumberSerializer extends NumberSerializer { - /** - * 根据JS NUmber.MAX SAFE INTEGER与NUmber.MIN SAFE INTEGER 得来 - */ - private static final long MAX_SAFE_INTEGER = 9007199254740991L; - private static final long MIN_SAFE_INTEGER = -9007199254740991L; - - /** - * 提供实例 - */ - public static final BigNumberSerializer INSTANCE = new BigNumberSerializer(Number.class); - - public BigNumberSerializer(Class<? extends Number> rawType) { - super(rawType); - } - - - @Override - - public void serialize(Number value, JsonGenerator gen, SerializerProvider provider) throws IOException { -//超出范围 序列化位字符串 - if (value.longValue() > MIN_SAFE_INTEGER && value.longValue() < MAX_SAFE_INTEGER){ - super.serialize(value, gen, provider); - } else{ - gen.writeString(value.toString()); - } - } -} - - diff --git a/src/main/java/com/lunhan/xxx/common/jackson/JacksonConfig.java b/src/main/java/com/lunhan/xxx/common/jackson/JacksonConfig.java deleted file mode 100644 index 9c9b565..0000000 --- a/src/main/java/com/lunhan/xxx/common/jackson/JacksonConfig.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.lunhan.xxx.common.jackson; - -import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; -import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; -import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer; -import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer; -import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -import java.math.BigDecimal; -import java.math.BigInteger; -import java.time.LocalDateTime; -import java.time.format.DateTimeFormatter; -import java.util.TimeZone; - -@Configuration -public class JacksonConfig { - /** - * jackson 配置 - * @return - */ - @Bean - public Jackson2ObjectMapperBuilderCustomizer customizer() { - return builder -> { - //全局配置序列化返回 JSON 处理 - JavaTimeModule javaTimeModule = new JavaTimeModule(); - javaTimeModule.addSerializer(Long.class, BigNumberSerializer.INSTANCE); - javaTimeModule.addSerializer(Long.TYPE, BigNumberSerializer.INSTANCE); - javaTimeModule.addSerializer(BigInteger.class, BigNumberSerializer.INSTANCE); - javaTimeModule.addSerializer(BigDecimal.class, ToStringSerializer.instance); - DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH : mm: ss"); - javaTimeModule.addSerializer(LocalDateTime.class, new LocalDateTimeSerializer(formatter)); - javaTimeModule.addDeserializer(LocalDateTime.class, new LocalDateTimeDeserializer(formatter)); - builder.modules(javaTimeModule); - builder.timeZone(TimeZone.getDefault()); - System.out.println("初始化 jackson 配置"); - }; - } -} diff --git a/src/main/java/com/lunhan/xxx/common/jwt/JWTUtil.java b/src/main/java/com/lunhan/xxx/common/jwt/JWTUtil.java deleted file mode 100644 index dbe9370..0000000 --- a/src/main/java/com/lunhan/xxx/common/jwt/JWTUtil.java +++ /dev/null @@ -1,85 +0,0 @@ -package com.lunhan.xxx.common.jwt; - -import com.auth0.jwt.JWT; -import com.auth0.jwt.JWTCreator; -import com.auth0.jwt.JWTVerifier; -import com.auth0.jwt.algorithms.Algorithm; -import com.auth0.jwt.exceptions.TokenExpiredException; -import com.auth0.jwt.interfaces.DecodedJWT; -import com.lunhan.xxx.common.ConstantFactory; -import com.lunhan.xxx.common.config.SysConfig; -import com.lunhan.xxx.common.enums.EResultCode; -import com.lunhan.xxx.common.exceptions.BusinessException; -import com.lunhan.xxx.common.util.LocalDateTimeUtil; -import com.lunhan.xxx.common.util.NumericUtil; -import com.lunhan.xxx.common.util.StringUtil; - -import java.time.LocalDateTime; -import java.util.Date; - -public class JWTUtil { - /** - * @return token中包含的用户名 - */ - public static LoginUserDTO getUser(String token) { - if (StringUtil.isNullOrEmpty(token)) { - throw new BusinessException(EResultCode.UNAUTHORIZED, "尚未登录"); - } - JWTVerifier verifier = JWT.require(Algorithm.HMAC256(SysConfig.jwt.getSecret())) - .build(); - DecodedJWT jwt = null; - try { - - jwt = verifier.verify(token); - } catch (TokenExpiredException e) { - throw new BusinessException(EResultCode.UNAUTHORIZED, "token已过期"); - } catch (Exception e) { - throw new BusinessException(EResultCode.UNAUTHORIZED, "token格式不正确." + token); - } - if (null == jwt) { - throw new BusinessException(EResultCode.UNAUTHORIZED, "token已过期"); - } - Date expiresAt = jwt.getExpiresAt(); - - LocalDateTime dtExpires = LocalDateTimeUtil.getDateTime(expiresAt.getTime()); - if (dtExpires.isBefore(LocalDateTimeUtil.nowDateTime())) { - throw new BusinessException(EResultCode.UNAUTHORIZED, "token已过期"); - } - LoginUserDTO loginUser = new LoginUserDTO(); - loginUser.setUserId(jwt.getClaim("userId").asString()); - loginUser.setUserType(NumericUtil.tryParseInt(jwt.getClaim("userType").asString(), 0)); - loginUser.setPhone(jwt.getClaim("phone").asString()); - loginUser.setPhone(jwt.getClaim("phone").asString()); - loginUser.setNickName(jwt.getClaim("nickName").asString()); - loginUser.setHeadImg(jwt.getClaim("headImg").asString()); - loginUser.setListRole(StringUtil.splitLongList(jwt.getClaim("listRole").asString())); - loginUser.setListRoleName(StringUtil.splitList(jwt.getClaim("listRoleName").asString())); - - return loginUser; - } - - /** - * 生成token,并保存到jwt - * - * @param loginUser 登录用户信息 - * @return 加密的token - */ - public static String getToken(LoginUserDTO loginUser) { - JWTCreator.Builder builder = JWT.create() - //设置jwt生成时间 - .withIssuedAt(new Date(LocalDateTimeUtil.nowTimeStamp())) - //设置token有效期 - .withExpiresAt(new Date(LocalDateTimeUtil.nowTimeStamp() + SysConfig.jwt.getExpiration() * ConstantFactory.TIME_LEN_1S)); - builder.withClaim("userId", loginUser.getUserId()); - builder.withClaim("userType", loginUser.getUserType().toString()); - builder.withClaim("phone", loginUser.getPhone()); - builder.withClaim("nickName", loginUser.getNickName()); - builder.withClaim("headImg", loginUser.getHeadImg()); - builder.withClaim("listRole", StringUtil.joinLong(loginUser.getListRole())); - builder.withClaim("listRoleName", StringUtil.join(loginUser.getListRoleName())); - return builder - //生成token字符串 - .sign(Algorithm.HMAC256(SysConfig.jwt.getSecret())) - ; - } -} \ No newline at end of file diff --git a/src/main/java/com/lunhan/xxx/common/jwt/LoginUserDTO.java b/src/main/java/com/lunhan/xxx/common/jwt/LoginUserDTO.java deleted file mode 100644 index b8ca96c..0000000 --- a/src/main/java/com/lunhan/xxx/common/jwt/LoginUserDTO.java +++ /dev/null @@ -1,114 +0,0 @@ -package com.lunhan.xxx.common.jwt; - -import java.util.List; - -public class LoginUserDTO { - /** - * 身份令牌 - */ - private String token; - /** - * 用户唯一标识 - */ - private String userId; - /** - * 用户类型 EUserType - */ - private Integer userType; - /** - * 用户名称 - */ - private String userName; - /** - * 手机号 - */ - private String phone; - /** - * 昵称 - */ - private String nickName; - /** - * 头像 - */ - private String headImg; - /** - * 拥有角色列表 - */ - private List<Long> listRole; - /** - * 拥有角色-名称列表 - */ - private List<String> listRoleName; - - public String getToken() { - return token; - } - - public void setToken(String token) { - this.token = token; - } - - public String getUserId() { - return userId; - } - - public void setUserId(String userId) { - this.userId = userId; - } - - public Integer getUserType() { - return userType; - } - - public void setUserType(Integer userType) { - this.userType = userType; - } - - public String getUserName() { - return userName; - } - - public void setUserName(String userName) { - this.userName = userName; - } - - public String getPhone() { - return phone; - } - - public void setPhone(String phone) { - this.phone = phone; - } - - public String getNickName() { - return nickName; - } - - public void setNickName(String nickName) { - this.nickName = nickName; - } - - public String getHeadImg() { - return headImg; - } - - public void setHeadImg(String headImg) { - this.headImg = headImg; - } - - public List<Long> getListRole() { - return listRole; - } - - public void setListRole(List<Long> listRole) { - this.listRole = listRole; - } - - public List<String> getListRoleName() { - return listRoleName; - } - - public void setListRoleName(List<String> listRoleName) { - this.listRoleName = listRoleName; - } -} diff --git a/src/main/java/com/lunhan/xxx/common/model/ExcelDiscernCell.java b/src/main/java/com/lunhan/xxx/common/model/ExcelDiscernCell.java deleted file mode 100644 index a9ce8bf..0000000 --- a/src/main/java/com/lunhan/xxx/common/model/ExcelDiscernCell.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.lunhan.xxx.common.model; - -public class ExcelDiscernCell { - private int cellIndex; - private String name; - private String value; - - public int getCellIndex() { - return cellIndex; - } - - public void setCellIndex(int cellIndex) { - this.cellIndex = cellIndex; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getValue() { - return value; - } - - public void setValue(String value) { - this.value = value; - } -} \ No newline at end of file diff --git a/src/main/java/com/lunhan/xxx/common/model/ExcelDiscernRow.java b/src/main/java/com/lunhan/xxx/common/model/ExcelDiscernRow.java deleted file mode 100644 index ed12949..0000000 --- a/src/main/java/com/lunhan/xxx/common/model/ExcelDiscernRow.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.lunhan.xxx.common.model; - -import java.util.List; - -public class ExcelDiscernRow { - private int rowIndx; - List<ExcelDiscernCell> listCell; - - public int getRowIndx() { - return rowIndx; - } - - public void setRowIndx(int rowIndx) { - this.rowIndx = rowIndx; - } - - public List<ExcelDiscernCell> getListCell() { - return listCell; - } - - public void setListCell(List<ExcelDiscernCell> listCell) { - this.listCell = listCell; - } -} \ No newline at end of file diff --git a/src/main/java/com/lunhan/xxx/common/model/ResFileUpload.java b/src/main/java/com/lunhan/xxx/common/model/ResFileUpload.java deleted file mode 100644 index 05c9dc1..0000000 --- a/src/main/java/com/lunhan/xxx/common/model/ResFileUpload.java +++ /dev/null @@ -1,96 +0,0 @@ -package com.lunhan.xxx.common.model; - -/** - * 文件上传 响应dto - */ -public class ResFileUpload { - /** - * 文件名 - */ - public String fileId; - - /** - * 文件名 - */ - public String fileName; - - /** - * 是否上传成功 - */ - public Boolean isSuccess; - - /** - * 上传错误消息 - */ - public String errorMsg; - - /** - * 保存文件地址(数据库保存) - */ - public String newFilePath; - - /** - * 文件下载/预览地址 - */ - public String newFullPath; - - public String getFileId() { - return fileId; - } - - public void setFileId(String fileId) { - this.fileId = fileId; - } - - public String getFileName() { - return fileName; - } - - public void setFileName(String fileName) { - this.fileName = fileName; - } - - public Boolean getIsSuccess() { - return isSuccess; - } - - public void setIsSuccess(Boolean isSuccess) { - this.isSuccess = isSuccess; - } - - public String getErrorMsg() { - return errorMsg; - } - - public void setErrorMsg(String errorMsg) { - this.errorMsg = errorMsg; - } - - public String getNewFilePath() { - return newFilePath; - } - - public void setNewFilePath(String newFilePath) { - this.newFilePath = newFilePath; - } - - public String getNewFullPath() { - return newFullPath; - } - - public void setNewFullPath(String newFullPath) { - this.newFullPath = newFullPath; - } - - @Override - public String toString() { - return "ResFileUpload{" + - "fileId='" + fileId + '\'' + - ", fileName='" + fileName + '\'' + - ", isSuccess=" + isSuccess + - ", errorMsg='" + errorMsg + '\'' + - ", newFilePath='" + newFilePath + '\'' + - ", newFullPath='" + newFullPath + '\'' + - '}'; - } -} \ No newline at end of file diff --git a/src/main/java/com/lunhan/xxx/common/model/Tuple.java b/src/main/java/com/lunhan/xxx/common/model/Tuple.java deleted file mode 100644 index c9a5a97..0000000 --- a/src/main/java/com/lunhan/xxx/common/model/Tuple.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.lunhan.xxx.common.model; - -/** - * 2个泛型参数返回结果 - * @param <T1> 参数1的类型 - * @param <T2> 参数2的类型 - */ -public class Tuple<T1, T2> { - private T1 item1; - private T2 item2; - - public Tuple() { - } - - public Tuple(T1 item1, T2 item2) { - this.item1 = item1; - this.item2 = item2; - } - - public T1 getItem1() { - return this.item1; - } - - public void setItem1(T1 item1) { - this.item1 = item1; - } - - public T2 getItem2() { - return this.item2; - } - - public void setItem2(T2 item2) { - this.item2 = item2; - } -} \ No newline at end of file diff --git a/src/main/java/com/lunhan/xxx/common/security/Base64Util.java b/src/main/java/com/lunhan/xxx/common/security/Base64Util.java deleted file mode 100644 index 792b3f4..0000000 --- a/src/main/java/com/lunhan/xxx/common/security/Base64Util.java +++ /dev/null @@ -1,119 +0,0 @@ -package com.lunhan.xxx.common.security; - -import com.lunhan.xxx.common.util.StringUtil; - -import java.nio.charset.Charset; -import java.util.Base64; - -/** - * Base64工具类 - * @author linliu - * @date 2019-06-14 - */ -public final class Base64Util { - private Base64Util() { - throw new IllegalStateException("Utility class"); - } - private static final String DEFAULT = "utf-8"; - - /** - * base64解码(utf-8编码) - * @author linliu - * @date 2019-06-14 - * @param str 密文字符串 - * @return 解码后的明文 - */ - public static String encode(String str) { - return encode(str, DEFAULT); - } - /** - * base64解码 - * @author linliu - * @date 2019-06-14 - * @param str 密文字符串 - * @param encoding 编码格式[默认utf-8] - * @return 解码后的明文 - */ - public static String encode(String str, String encoding) { - if(StringUtil.isNullOrEmpty(str)) { - return ""; - } - if(StringUtil.isNullOrEmpty(encoding)) { - encoding = DEFAULT; - } - byte[] bytes = str.getBytes(Charset.forName(encoding)); - return Base64.getEncoder().encodeToString(bytes); - } - /** - * base64解码(utf-8编码) - * @author linliu - * @date 2019-06-14 - * @param str 密文字符串 - * @return 解码后的明文 - */ - public static String decode(String str) { - return decode(str, DEFAULT); - } - /** - * base64解码 - * @author linliu - * @date 2019-06-14 - * @param str 密文字符串 - * @param encoding 编码格式[默认utf-8] - * @return 解码后的明文 - */ - public static String decode(String str, String encoding) { - if(StringUtil.isNullOrEmpty(str)) { - return ""; - } - if(StringUtil.isNullOrEmpty(encoding)) { - encoding = DEFAULT; - } - byte[] bytes = Base64.getDecoder().decode(str); - return new String(bytes, Charset.forName(encoding)); - } - - /** - * 二进制流转成base64字符串 - * @param buffer 二进制数组 - * @return 编码后的base64字符串 - */ - public static String encodeStream(final byte[] buffer) { - return Base64.getEncoder().encodeToString(buffer); - } - - /** - * 二进制流转成base64流 - * @param buffer 二进制数组 - * @return 编码后的base64流 - */ - public static byte[] encodeToStream(final byte[] buffer) { - return Base64.getEncoder().encode(buffer); - } - - /** - * base64字符串转成二进制流 - * @param str 密文字符串 - * @return 解码后的文件流 - */ - public static byte[] decodeToStream(String str) { - try { - return Base64.getDecoder().decode(str); - } catch (Exception e) { - return new byte[0]; - } - } - - /** - * base64字符串转成二进制流 - * @param buffer 密文流 - * @return 解码后的文件流 - */ - public static byte[] decodeToStream(final byte[] buffer) { - try { - return Base64.getDecoder().decode(buffer); - } catch (Exception e) { - return new byte[0]; - } - } -} \ No newline at end of file diff --git a/src/main/java/com/lunhan/xxx/common/security/Des3Util.java b/src/main/java/com/lunhan/xxx/common/security/Des3Util.java deleted file mode 100644 index e8c95e5..0000000 --- a/src/main/java/com/lunhan/xxx/common/security/Des3Util.java +++ /dev/null @@ -1,146 +0,0 @@ -package com.lunhan.xxx.common.security; - -import com.lunhan.xxx.common.enums.ELogger; -import com.lunhan.xxx.common.util.LoggerUtil; -import org.slf4j.Logger; - -import javax.crypto.Cipher; -import javax.crypto.KeyGenerator; -import javax.crypto.SecretKey; -import javax.crypto.SecretKeyFactory; -import javax.crypto.spec.DESedeKeySpec; -import javax.crypto.spec.IvParameterSpec; -import java.nio.charset.Charset; -import java.security.InvalidKeyException; -import java.security.Key; -import java.security.NoSuchAlgorithmException; -import java.security.SecureRandom; -import java.security.spec.InvalidKeySpecException; -import java.util.UUID; - - -public final class Des3Util { - private Des3Util() { - throw new IllegalStateException("Utility class"); - } - - private static final Logger sysLogger = LoggerUtil.get(ELogger.SYS_ERROR); - - private static final String TITLE = "Des3加密工具"; - - //默认加密偏移量 - private static byte[] DEFAULT_IV = { 0x23, (byte)0xf2, (byte)0xa3, (byte)0xc6, 0x3e, 0x2b, (byte)0xe7, 0x28 }; - //加密算法 - private static final String ALGORITHM = "DESede"; - // 加解密统一使用的编码方式 - private static final String DEFAULT_ENCODING = "utf-8"; - //密钥 - public static final String DEFAULT_KEY = "com.ctrip.tour.cq.soa.v1"; - - /** - * 生成加密偏移量 - * @param iv 偏移量 - */ - private static IvParameterSpec IvGenerator(byte[] iv) throws Exception { - IvParameterSpec result = new IvParameterSpec(iv); - return result; - } - - /** - * 随机生成一个key - */ - public static String genKey() throws NoSuchAlgorithmException { - byte[] keyBytes = UUID.randomUUID().toString().getBytes(); - KeyGenerator generator = KeyGenerator.getInstance(ALGORITHM); - generator.init(new SecureRandom( keyBytes ) ); - SecretKey key = generator.generateKey(); - return Base64Util.encodeStream(key.getEncoded()); - } - /** - * 根据明文字符串生成key(key长度必须 大于等于 24) - */ - public static Key genKey(String key) throws InvalidKeyException, NoSuchAlgorithmException, InvalidKeySpecException { - DESedeKeySpec spec = new DESedeKeySpec(key.getBytes()); - SecretKeyFactory keyfactory = SecretKeyFactory.getInstance(ALGORITHM); - return keyfactory.generateSecret(spec); - } - - /** - * 加密以byte[]明文输入,byte[]密文输出 - * @param buffer 待加密的字节码 - * @param key 密钥(key长度必须 大于等于 24) - * @return 加密后的字节码 - */ - private static byte[] encrypt(byte[] buffer, String key) { - byte[] result = null; - try { - Cipher cipher = Cipher.getInstance(ALGORITHM +"/CBC/PKCS5Padding"); - IvParameterSpec IVSpec = IvGenerator(DEFAULT_IV); - cipher.init(Cipher.ENCRYPT_MODE, genKey(key), IVSpec); - byte[] temp = cipher.doFinal(buffer); - result = Base64Util.encodeToStream(temp); - } catch (Exception e) { - sysLogger.error("Des3Util.encrypt", e); - } - return result; - } - /** - * 解密以byte[]密文输入,以byte[]明文输出 - * @param buffer 待解密的字节码 - * @param key 密钥(key长度必须是8的倍数) - * @return 解密后的字节码 - */ - private static byte[] decrypt(byte[] buffer, String key) { - byte[] result = null; - try { - IvParameterSpec IVSpec = IvGenerator(DEFAULT_IV); - Cipher cipher = Cipher.getInstance(ALGORITHM +"/CBC/PKCS5Padding"); - cipher.init(Cipher.DECRYPT_MODE, genKey(key), IVSpec); - byte[] temp = Base64Util.decodeToStream(buffer); - result = cipher.doFinal(temp); - } catch (Exception e) { - sysLogger.error("Des3Util.decrypt", e); - } - return result; - } - - /** - * 加密String 明文输入密文输出 - * @param str 待加密的明文 - * @param key 密钥(key长度必须 大于等于 24) - * @return 加密后的字符串 - */ - public static String encrypt(String str, String key) throws Exception { - byte[] buffer = str.getBytes(Charset.forName(DEFAULT_ENCODING)); - byte[] result = encrypt(buffer, key); - return new String(result); - } - /** - * 解密String 以密文输入明文输出 - * @param str 需要解密的字符串 - * @param key 密钥(key长度必须 大于等于 24) - * @return 解密后的字符串 - */ - public static String decrypt(String str, String key) { - byte[] buffer = str.getBytes(Charset.forName(DEFAULT_ENCODING)); - byte[] result = decrypt(buffer, key); - return new String(result).trim(); - } - - /** - * 加密String 明文输入密文输出 - * @param str 待加密的明文 - * @return 加密后的字符串 - */ - public static String encrypt(String str) throws Exception { - return encrypt(str, DEFAULT_KEY); - } - /** - * 解密String 以密文输入明文输出 - * @param str 需要解密的字符串 - * @return 解密后的字符串 - */ - public static String decrypt(String str) { - return decrypt(str, DEFAULT_KEY); - } -} \ No newline at end of file diff --git a/src/main/java/com/lunhan/xxx/common/security/MD5Util.java b/src/main/java/com/lunhan/xxx/common/security/MD5Util.java deleted file mode 100644 index 2ce463a..0000000 --- a/src/main/java/com/lunhan/xxx/common/security/MD5Util.java +++ /dev/null @@ -1,70 +0,0 @@ -package com.lunhan.xxx.common.security; - -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; - -public class MD5Util { - private MD5Util() { - throw new IllegalStateException("Utility class"); - } - - /** - * 生成32位md5码 - * @param content 待加密明文字符串 - * @return 加密串 - */ - public static String encrypt(String content) { - //region 加盐方式 - try { - // 得到一个信息摘要器 - MessageDigest digest = MessageDigest.getInstance("md5"); - byte[] result = digest.digest(content.getBytes()); - StringBuilder sb = new StringBuilder(); - // 把每一个byte 做一个与运算 0xff; - for (byte b : result) { - // 与运算 - int number = b & 0xff;// 加盐 - String str = Integer.toHexString(number); - if (str.length() == 1) { - sb.append("0"); - } - sb.append(str); - } - // 标准的md5加密后的结果 - return sb.toString(); - } catch (NoSuchAlgorithmException e) { - e.printStackTrace(); - return ""; - } - //endregion - - //region 普通方式 - - /*char hexDigits[] = { - '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' - }; - try { - byte[] btInput = content.getBytes(); - // 获得MD5摘要算法的 MessageDigest 对象 - MessageDigest mdInst = MessageDigest.getInstance("MD5"); - // 使用指定的字节更新摘要 - mdInst.update(btInput); - // 获得密文 - byte[] md = mdInst.digest(); - // 把密文转换成十六进制的字符串形式 - int j = md.length; - char str[] = new char[j * 2]; - int k = 0; - for (int i = 0; i < j; i++) { - byte byte0 = md[i]; - str[k++] = hexDigits[byte0 >>> 4 & 0xf]; - str[k++] = hexDigits[byte0 & 0xf]; - } - return new String(str); - } catch (Exception e) { - return ""; - }*/ - - //endregion - } -} \ No newline at end of file diff --git a/src/main/java/com/lunhan/xxx/common/serializer/CQCalendarSerializer.java b/src/main/java/com/lunhan/xxx/common/serializer/CQCalendarSerializer.java deleted file mode 100644 index 47cb9b1..0000000 --- a/src/main/java/com/lunhan/xxx/common/serializer/CQCalendarSerializer.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.lunhan.xxx.common.serializer; - -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.lunhan.xxx.common.util.CalendarUtil; - -import java.io.IOException; -import java.util.Calendar; - -/** - * 自定义json序列化 Calendar 属性 - * @author linliu - * @date 2020-05-12 - */ -public class CQCalendarSerializer extends JsonSerializer<Calendar> { - @Override - public void serialize(Calendar value, JsonGenerator g, SerializerProvider provider) throws IOException { - if(null==value) { - return; - } - g.writeString(CalendarUtil.toDateTimeStr(value)); - } -} \ No newline at end of file diff --git a/src/main/java/com/lunhan/xxx/common/serializer/CQDateSerializer.java b/src/main/java/com/lunhan/xxx/common/serializer/CQDateSerializer.java deleted file mode 100644 index b9cd09e..0000000 --- a/src/main/java/com/lunhan/xxx/common/serializer/CQDateSerializer.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.lunhan.xxx.common.serializer; - -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.lunhan.xxx.common.ConstantFactory; - -import java.io.IOException; -import java.text.SimpleDateFormat; -import java.util.Date; - -/** - * 自定义json序列化 Date 属性 - * @author linliu - * @date 2020-05-12 - */ -public class CQDateSerializer extends JsonSerializer<Date> { - @Override - public void serialize(Date value, JsonGenerator g, SerializerProvider provider) throws IOException { - if(null==value) { - return; - } - SimpleDateFormat sdf = new SimpleDateFormat(ConstantFactory.STR_DATE); - g.writeString(sdf.format(value)); - } -} \ No newline at end of file diff --git a/src/main/java/com/lunhan/xxx/common/serializer/CQLocalDateSerializer.java b/src/main/java/com/lunhan/xxx/common/serializer/CQLocalDateSerializer.java deleted file mode 100644 index 0ef0341..0000000 --- a/src/main/java/com/lunhan/xxx/common/serializer/CQLocalDateSerializer.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.lunhan.xxx.common.serializer; - -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.lunhan.xxx.common.util.LocalDateTimeUtil; - -import java.io.IOException; -import java.time.LocalDate; - -/** - * 自定义json序列化 LocalDate 属性 - * @author linliu - * @date 2020-05-12 - */ -public class CQLocalDateSerializer extends JsonSerializer<LocalDate> { - public void serialize(LocalDate value, JsonGenerator g, SerializerProvider provider) throws IOException { - g.writeString(LocalDateTimeUtil.toFormatString(value)); - } -} \ No newline at end of file diff --git a/src/main/java/com/lunhan/xxx/common/serializer/CQLocalDateTimeSerializer.java b/src/main/java/com/lunhan/xxx/common/serializer/CQLocalDateTimeSerializer.java deleted file mode 100644 index bf49940..0000000 --- a/src/main/java/com/lunhan/xxx/common/serializer/CQLocalDateTimeSerializer.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.lunhan.xxx.common.serializer; - -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.lunhan.xxx.common.util.LocalDateTimeUtil; - -import java.io.IOException; -import java.time.LocalDateTime; - -/** - * 自定义json序列化 LocalDateTime 属性 - * @author linliu - * @date 2020-05-12 - */ -public class CQLocalDateTimeSerializer extends JsonSerializer<LocalDateTime> { - @Override - public void serialize(LocalDateTime value, JsonGenerator g, SerializerProvider provider) throws IOException { - g.writeString(LocalDateTimeUtil.toFormatFullString(value)); - } -} \ No newline at end of file diff --git a/src/main/java/com/lunhan/xxx/common/serializer/CQTimestampSerializer.java b/src/main/java/com/lunhan/xxx/common/serializer/CQTimestampSerializer.java deleted file mode 100644 index c58e91e..0000000 --- a/src/main/java/com/lunhan/xxx/common/serializer/CQTimestampSerializer.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.lunhan.xxx.common.serializer; - -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.lunhan.xxx.common.util.LocalDateTimeUtil; - -import java.io.IOException; -import java.sql.Timestamp; - -/** - * 自定义json序列化 Timestamp 属性 - * @author linliu - * @date 2020-05-12 - */ -public class CQTimestampSerializer extends JsonSerializer<Timestamp> { - @Override - public void serialize(Timestamp value, JsonGenerator g, SerializerProvider provider) throws IOException { - if(null==value) { - return; - } - g.writeString(LocalDateTimeUtil.toFormatFullString(value)); - } -} \ No newline at end of file diff --git a/src/main/java/com/lunhan/xxx/common/serializer/deserializer/CQCalendarDeSerializer.java b/src/main/java/com/lunhan/xxx/common/serializer/deserializer/CQCalendarDeSerializer.java deleted file mode 100644 index a1d3c63..0000000 --- a/src/main/java/com/lunhan/xxx/common/serializer/deserializer/CQCalendarDeSerializer.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.lunhan.xxx.common.serializer.deserializer; - -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.lunhan.xxx.common.ConstantFactory; -import com.lunhan.xxx.common.util.CalendarUtil; -import com.lunhan.xxx.common.util.NumericUtil; -import com.lunhan.xxx.common.util.StringUtil; - -import java.io.IOException; -import java.util.Calendar; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * 自定义json反序列化 Calendar 属性 - * @author linliu - * @date 2020-05-12 - */ -public class CQCalendarDeSerializer extends JsonDeserializer<Calendar> { - @Override - public Calendar deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - String value = p.getText(); - - if(StringUtil.isMatch(value, ConstantFactory.REGEX_DATE)) { - return CalendarUtil.fromDateStr(value); - } else if(StringUtil.isMatch(value, ConstantFactory.REGEX_DATETIME)) { - return CalendarUtil.fromDateTimeStr(value); - } else if(StringUtil.isMatch(value, ConstantFactory.REGEX_DATETIME_FULL)) { - return CalendarUtil.fromDateTimeMSStr(value); - } else if(StringUtil.isMatch(value, ConstantFactory.REGEX_DATETIME_JAVA)) { - Pattern pattern = Pattern.compile(ConstantFactory.REGEX_DATETIME_JAVA); - Matcher matcher = pattern.matcher(value); - if(matcher.find()) { - String timestamp = matcher.group("timestamp"); - return CalendarUtil.fromMillis(NumericUtil.tryParseLong(timestamp)); - } - } else if(StringUtil.isMatch(value, "^[0-9]{13}$")) { - return CalendarUtil.fromMillis(NumericUtil.tryParseLong(value)); - } - throw new IOException("can't be deserialize as type “Calendar”, " + value); - } -} \ No newline at end of file diff --git a/src/main/java/com/lunhan/xxx/common/serializer/deserializer/CQDateDeSerializer.java b/src/main/java/com/lunhan/xxx/common/serializer/deserializer/CQDateDeSerializer.java deleted file mode 100644 index 0130f52..0000000 --- a/src/main/java/com/lunhan/xxx/common/serializer/deserializer/CQDateDeSerializer.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.lunhan.xxx.common.serializer.deserializer; - -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.lunhan.xxx.common.ConstantFactory; -import com.lunhan.xxx.common.util.LocalDateTimeUtil; -import com.lunhan.xxx.common.util.StringUtil; - -import java.io.IOException; -import java.time.Instant; -import java.time.LocalDateTime; -import java.time.ZoneOffset; -import java.util.Date; - -/** - * 自定义json反序列化 Date 属性 - * @author linliu - * @date 2020-05-12 - */ -public class CQDateDeSerializer extends JsonDeserializer<Date> { - @Override - public Date deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - String value = p.getText(); - if(StringUtil.isMatch(value, ConstantFactory.REGEX_DATE)) { - LocalDateTime date = LocalDateTimeUtil.getDateTime(value, ConstantFactory.STR_DATE); - Instant instant = date.toInstant(ZoneOffset.UTC); - return Date.from(instant); - } else { - throw new IOException("can't be deserialize as type “Date”, " + value); - } - } -} \ No newline at end of file diff --git a/src/main/java/com/lunhan/xxx/common/serializer/deserializer/CQLocalDateDeSerializer.java b/src/main/java/com/lunhan/xxx/common/serializer/deserializer/CQLocalDateDeSerializer.java deleted file mode 100644 index 089b27b..0000000 --- a/src/main/java/com/lunhan/xxx/common/serializer/deserializer/CQLocalDateDeSerializer.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.lunhan.xxx.common.serializer.deserializer; - -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.lunhan.xxx.common.ConstantFactory; -import com.lunhan.xxx.common.util.LocalDateTimeUtil; -import com.lunhan.xxx.common.util.StringUtil; - -import java.io.IOException; -import java.time.LocalDate; - -/** - * 自定义json反序列化 LocalDate 属性 - * @author linliu - * @date 2020-05-12 - */ -public class CQLocalDateDeSerializer extends JsonDeserializer<LocalDate> { - @Override - public LocalDate deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - String value = p.getText(); - if(StringUtil.isMatch(value, ConstantFactory.REGEX_DATE)) { - return LocalDateTimeUtil.getDate(value); - } else { - throw new IOException("can't be deserialize as type “LocalDate”, " + value); - } - } -} \ No newline at end of file diff --git a/src/main/java/com/lunhan/xxx/common/serializer/deserializer/CQLocalDateTimeDeSerializer.java b/src/main/java/com/lunhan/xxx/common/serializer/deserializer/CQLocalDateTimeDeSerializer.java deleted file mode 100644 index 780633c..0000000 --- a/src/main/java/com/lunhan/xxx/common/serializer/deserializer/CQLocalDateTimeDeSerializer.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.lunhan.xxx.common.serializer.deserializer; - -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.lunhan.xxx.common.ConstantFactory; -import com.lunhan.xxx.common.util.LocalDateTimeUtil; -import com.lunhan.xxx.common.util.NumericUtil; -import com.lunhan.xxx.common.util.StringUtil; - -import java.io.IOException; -import java.time.LocalDateTime; - -/** - * 自定义json反序列化 LocalDateTime 属性 - * @author linliu - * @date 2020-05-12 - */ -public class CQLocalDateTimeDeSerializer extends JsonDeserializer<LocalDateTime> { - @Override - public LocalDateTime deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - String value = p.getText(); - if(StringUtil.isMatch(value, ConstantFactory.REGEX_DATE)) { - return LocalDateTimeUtil.getDateTime(value, ConstantFactory.STR_DATE); - } else if(StringUtil.isMatch(value, ConstantFactory.REGEX_DATETIME)) { - return LocalDateTimeUtil.getDateTime(value); - } else if(StringUtil.isMatch(value, ConstantFactory.REGEX_DATETIME_FULL)) { - return LocalDateTimeUtil.getDateTime(value, ConstantFactory.STR_DATE_FULLMS); - } else if(StringUtil.isMatch(value, "^[0-9]{13}$")) { - return LocalDateTimeUtil.getDateTime(NumericUtil.tryParseLong(value)); - } else { - throw new IOException("can't be deserialize as type “LocalDateTime”, " + value); - } - } -} \ No newline at end of file diff --git a/src/main/java/com/lunhan/xxx/common/serializer/deserializer/CQTimestampDeSerializer.java b/src/main/java/com/lunhan/xxx/common/serializer/deserializer/CQTimestampDeSerializer.java deleted file mode 100644 index abc6cad..0000000 --- a/src/main/java/com/lunhan/xxx/common/serializer/deserializer/CQTimestampDeSerializer.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.lunhan.xxx.common.serializer.deserializer; - -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.lunhan.xxx.common.ConstantFactory; -import com.lunhan.xxx.common.util.LocalDateTimeUtil; -import com.lunhan.xxx.common.util.NumericUtil; -import com.lunhan.xxx.common.util.StringUtil; - -import java.io.IOException; -import java.sql.Timestamp; - -/** - * 自定义json反序列化 LocalDateTime 属性 - * @author linliu - * @date 2020-07-03 - */ -public class CQTimestampDeSerializer extends JsonDeserializer<Timestamp> { - @Override - public Timestamp deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - String value = p.getText(); - if(StringUtil.isMatch(value, ConstantFactory.REGEX_DATE)) { - return LocalDateTimeUtil.getTimeStamp(value, ConstantFactory.STR_DATE); - } else if(StringUtil.isMatch(value, ConstantFactory.REGEX_DATETIME)) { - return LocalDateTimeUtil.getTimeStamp(value); - } else if(StringUtil.isMatch(value, ConstantFactory.REGEX_DATETIME_FULL)) { - return LocalDateTimeUtil.getTimeStamp(value, ConstantFactory.STR_DATE_FULLMS); - } else if(StringUtil.isMatch(value, "^[0-9]{13}$")) { - return LocalDateTimeUtil.getTimeStamp(NumericUtil.tryParseLong(value)); - } else { - throw new IOException("can't be deserialize as type “Timestamp”, " + value); - } - } -} \ No newline at end of file diff --git a/src/main/java/com/lunhan/xxx/common/util/CalendarUtil.java b/src/main/java/com/lunhan/xxx/common/util/CalendarUtil.java deleted file mode 100644 index 0b0d24f..0000000 --- a/src/main/java/com/lunhan/xxx/common/util/CalendarUtil.java +++ /dev/null @@ -1,378 +0,0 @@ -package com.lunhan.xxx.common.util; - -import com.lunhan.xxx.common.ConstantFactory; - -import java.sql.Timestamp; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.time.Instant; -import java.util.*; - -/** - * 日期处理类 - * @author xiangyuanzhang - * @date 2018-12-25 - */ -public final class CalendarUtil { - static final Long ONE_DAYMS = 86400000L; - private static final int ONE_SECONDS = 1000; - - private CalendarUtil() { - throw new IllegalStateException("Utility class"); - } - - /** - * 获取当前时区时间 - * @param origin - */ - public static Calendar toLocal(Calendar origin) { - if(origin == null) { - return null; - } else if(origin.getTimeZone().equals(TimeZone.getDefault())) { - return origin; - } else { - Calendar calendar = Calendar.getInstance(); - calendar.setTimeInMillis(origin.getTimeInMillis()); - return calendar; - } - } - - public static int daysBetween(Calendar timeStart, Calendar timeEnd) { - long time1 = timeStart.getTimeInMillis(); - long time2 = timeEnd.getTimeInMillis(); - long betweenDays = (time2 - time1) / ONE_DAYMS; - return Integer.parseInt(String.valueOf(betweenDays)); - } - - /** - * 获取当前时间 - */ - public static Calendar getNow() { - Calendar calendar = Calendar.getInstance(); - calendar.setTime(new Date()); - return calendar; - } - - public static Calendar getNow(int days) { - Calendar calendar = getNow(); - calendar.add(Calendar.DAY_OF_MONTH, days); - return calendar; - } - - public static Calendar fromCalendarInDate(Calendar time) { - Calendar calendar = null; - if(time != null) { - try { - String ex = toDateStr(time); - calendar = fromDateStr(ex); - } catch (Exception e) { - //TODO log - } - } - - return calendar; - } - - public static Calendar fromMillisInDate(Long ms) { - Calendar calendar = fromMillis(ms); - return CalendarUtil.fromCalendarInDate(calendar); - } - - public static Calendar fromMillis(Long ms) { - Calendar calendar = Calendar.getInstance(); - calendar.setTimeInMillis(ms); - return calendar; - } - - public static Calendar fromTimestamp(Timestamp ts) { - Calendar calendar = null; - if(ts != null) { - calendar = Calendar.getInstance(); - long time = ts.getTime(); - calendar.setTimeInMillis(time); - } - return calendar; - } - - /** - * 通过yyyy-MM-dd获取日期 - * @param dateStr 日期字符串 - */ - public static Calendar fromDateStr(String dateStr) { - return CalendarUtil.fromStr(dateStr, ConstantFactory.STR_DATE); - } - - /** - * 通过yyyy-MM-dd HH:mm:ss.SSS获取日期 - * @param dateTimeMSStr 带毫秒的时间字符串 - */ - public static Calendar fromDateTimeMSStr(String dateTimeMSStr) { - Calendar calendar = null; - if(StringUtil.isNotNullOrEmpty(dateTimeMSStr) && !"null".equals(dateTimeMSStr)) { - calendar = CalendarUtil.fromStr(dateTimeMSStr, ConstantFactory.STR_DATE_FULLMS); - } - return calendar; - } - - /** - * 通过yyyy-MM-dd HH:mm:ss获取日期 - * @param dateTimeStr 时间字符串 - */ - public static Calendar fromDateTimeStr(String dateTimeStr) { - return CalendarUtil.fromStr(dateTimeStr, ConstantFactory.STR_DATE_FULL); - } - - /** - * 通过指定时间格式,获取Calendar对象 - * @param dateStr 时间字符串 - * @param format 时间格式 - */ - public static Calendar fromStr(String dateStr, String format) { - Calendar calendar; - try { - SimpleDateFormat sdf = new SimpleDateFormat(format); - Date date = sdf.parse(dateStr); - calendar = Calendar.getInstance(); - calendar.setTime(date); - return calendar; - } catch (ParseException var5) { - //TODO log - return null; - } - } - - public static String toNowDateStr() { - return CalendarUtil.toDateStr(getNow()); - } - - public static String toNowDateTimeStr() { - return CalendarUtil.toDateTimeStr(getNow()); - } - - public static String toNowDateTimeMSStr() { - return CalendarUtil.toDateTimeMSStr(getNow()); - } - - public static String toDateStr(Calendar calendar) { - return CalendarUtil.toDateTimeStr(calendar, ConstantFactory.STR_DATE); - } - - public static String toDateTimeStr(Calendar calendar) { - return CalendarUtil.toDateTimeStr(calendar, ConstantFactory.STR_DATE_FULL); - } - - public static String toDateTimeMSStr(Calendar calendar) { - return CalendarUtil.toDateTimeStr(calendar, ConstantFactory.STR_DATE_FULLMS); - } - - public static String toDateTimeStr(Calendar calendar, String format) { - if(null == calendar) { - calendar = CalendarUtil.fromDateTimeStr(ConstantFactory.STR_DATE_DEFAULT); - } - SimpleDateFormat formatter = new SimpleDateFormat(format); - return formatter.format(calendar.getTime()); - } - - public static String toStringByTimestamp(Timestamp ts) { - Calendar calendar = CalendarUtil.fromTimestamp(ts); - return CalendarUtil.toDateTimeStr(calendar, ConstantFactory.STR_DATE_FULLMS); - } - - /** - * 获取当前时间戳 - * @return 当前时间戳 - */ - public static Timestamp getNowTimestamp() { - return new Timestamp(CalendarUtil.nowTimestamp()); - } - - /** - * 获取当前时间戳 - */ - public static Long nowTimestamp() { - return Instant.now().toEpochMilli(); - } - - /** - * 获取当前时间戳 - */ - public static String nowTimestampStr() { - return Long.toString(CalendarUtil.nowTimestamp()); - } - - public static Calendar get1970() { - Calendar result; - try { - result = fromStr("1970-01-01 08:00:01", ConstantFactory.STR_DATE_FULL); - } catch (Exception e) { - result = null; - } - return result; - } - - public static Integer getAge(Calendar birthDay) { - if(birthDay==null) { - return 0; - } - Calendar now = getNow(); - - int nowYear = now.get(Calendar.YEAR); - int nowMonth = now.get(Calendar.MONTH); - int nowDay = now.get(Calendar.DAY_OF_MONTH); - - int birthDayYear= birthDay.get(Calendar.YEAR); - int birthDayMonth = birthDay.get(Calendar.MONTH); - int birthDayDay = birthDay.get(Calendar.DAY_OF_MONTH); - - int age = nowYear - birthDayYear; - if(nowMonth < birthDayMonth) { - age--; - } else if(nowMonth == birthDayMonth && nowDay < birthDayDay) { - age--; - } else { - age = 0; - } - return age; - } - - public static Integer getAge(String birthDay) { - Calendar cBirthDay = CalendarUtil.fromStr(birthDay, ConstantFactory.STR_DATE); - return getAge(cBirthDay); - } - - /** - * 方法为获取时间段内的所有日期 - * @param dateFrom 时间起 - * @param dateEnd 时间至 - * @return List<Long> 返回该时间段内的所有日期的时间戳队列。 - * @throws ParseException - */ - public static List<String> getDates(String dateFrom, String dateEnd) throws ParseException { - return CalendarUtil.getDates(dateFrom, dateEnd, "-1"); - } - - /** - * 方法为指定时间段内获取指定周几的所有日期 - * @param dateFrom 时间起 - * @param dateEnd 时间至 - * @param weekDays 需要在时间段中指定查询的周数,建议使用“,”隔开(不隔开也没问题),需要获取时间段内所有日期时参数为"-1"。星期日=0,星期一=1,星期二=2,星期三=3,星期四=4,星期五=5,星期六=6。 - * @return List<Long> 返回符合条件日期的时间戳队列。 - * @throws ParseException - */ - public static List<String> getDates(String dateFrom, String dateEnd, String weekDays) throws ParseException { - boolean isAll = weekDays.contains("-1"); - long time; - List<String> dateList = new ArrayList<>(); - SimpleDateFormat simpleDateFormat = new SimpleDateFormat(ConstantFactory.STR_DATE); - dateFrom = simpleDateFormat.format(simpleDateFormat.parse(dateFrom).getTime() - ONE_DAYMS); - while (true) { - time = simpleDateFormat.parse(dateFrom).getTime(); - time = time + ONE_DAYMS; - Date date = new Date(time); - dateFrom = simpleDateFormat.format(date); - if (dateFrom.compareTo(dateEnd) <= 0) { - if (isAll) { - dateList.add(dateFrom); - } else { - Integer weekDay = dayForWeek(date); - if (weekDays.contains(weekDay.toString())) { - dateList.add(dateFrom); - } - } - } else { - break; - } - } - return dateList; - } - - private static Integer dayForWeek(Date date) { - Calendar calendar = Calendar.getInstance(); - calendar.setTime(date); - return calendar.get(Calendar.DAY_OF_WEEK) - 1; - } - - public static Timestamp get1970Timestamp() { - Timestamp result; - try { - Calendar date = get1970(); - if(null!=date) { - result = new Timestamp(date.getTimeInMillis()); - } else { - result = null; - } - } catch (Exception e) { - result = null; - } - return result; - } - - /** - * 从指定格式时间字符串,获取时间戳 - */ - public static Timestamp getTimestamp(String dateStr, String format) { - Long timspamp = Long.parseLong("1000"); - Calendar date = CalendarUtil.fromStr(dateStr, format); - if(null!=date) { - timspamp = date.getTimeInMillis(); - } - return new Timestamp(timspamp); - } - - /** - * 获取今日 00:00:00 - */ - public static Calendar getToday() { - Calendar calendar = Calendar.getInstance(); - calendar.setTime(new Date()); - String today = CalendarUtil.toDateTimeStr(calendar, ConstantFactory.STR_DATE); - return CalendarUtil.fromStr(today, ConstantFactory.STR_DATE); - } - - /** - * 获取本月第一天零时 xxxx-xx-01 00:00:00 - */ - public static Calendar getCurrentMonthFirstDay() { - Calendar calendar = Calendar.getInstance(); - calendar.setTime(new Date()); - String toMonth = CalendarUtil.toDateTimeStr(calendar, "yyyy-MM")+"-01"; - return CalendarUtil.fromStr(toMonth, ConstantFactory.STR_DATE); - } - - /** - * 从指定Calendar获取时间戳 - */ - public static Timestamp getTimestamp(Calendar date) { - Long timspamp = Long.parseLong("1000"); - if(null!=date) { - timspamp = date.getTimeInMillis(); - } - return new Timestamp(timspamp); - } - - public static boolean isValid(Calendar calendar) { - if(null==calendar|| calendar.compareTo(CalendarUtil.get1970())<0) { - return false; - } - return true; - } - public static boolean isValid(Timestamp timestamp) { - if(null==timestamp || timestamp.compareTo(CalendarUtil.get1970Timestamp())<0) { - return false; - } - return true; - } - public static boolean isValid(String dateStr, String format) { - Calendar calendar = CalendarUtil.fromStr(dateStr, format); - if(null==calendar || calendar.compareTo(CalendarUtil.get1970())<0) { - return false; - } - return true; - } - - public static Integer getTimestampSeconds(Calendar time) { - long mils = time.getTimeInMillis(); - String timestamp = String.valueOf(mils / ONE_SECONDS); - return Integer.valueOf(timestamp); - } -} \ No newline at end of file diff --git a/src/main/java/com/lunhan/xxx/common/util/CopierUtil.java b/src/main/java/com/lunhan/xxx/common/util/CopierUtil.java deleted file mode 100644 index 1365a88..0000000 --- a/src/main/java/com/lunhan/xxx/common/util/CopierUtil.java +++ /dev/null @@ -1,70 +0,0 @@ -package com.lunhan.xxx.common.util; - -import org.springframework.cglib.beans.BeanCopier; - -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; -import java.util.Optional; -import java.util.stream.Collectors; - -public final class CopierUtil { - private CopierUtil() { - throw new IllegalStateException("Utility class"); - } - - /** - * 单个对象属性拷贝 - * @param source 源对象 - * @param clazz 目标对象Class - * @param <T> 目标对象类型 - * @param <M> 源对象类型 - * @return 目标对象 - */ - public static <T, M> T mapTo(M source, Class<T> clazz) { - if (Objects.isNull(source) || Objects.isNull(clazz)) - throw new IllegalArgumentException(); - return mapTo(source, clazz, null); - } - - /** - * 列表对象拷贝 - * @param sources 源列表 - * @param clazz 源列表对象Class - * @param <T> 目标列表对象类型 - * @param <M> 源列表对象类型 - * @return 目标列表 - */ - public static <T, M> List<T> mapTo(List<M> sources, Class<T> clazz) { - if (Objects.isNull(sources) || Objects.isNull(clazz) || sources.isEmpty()) - throw new IllegalArgumentException(); - BeanCopier copier = BeanCopier.create(sources.get(0).getClass(), clazz, false); - return Optional.of(sources) - .orElse(new ArrayList<>()) - .stream().map(m -> mapTo(m, clazz, copier)) - .collect(Collectors.toList()); - } - - /** - * 单个对象属性拷贝 - * @param source 源对象 - * @param clazz 目标对象Class - * @param copier copier - * @param <T> 目标对象类型 - * @param <M> 源对象类型 - * @return 目标对象 - */ - private static <T, M> T mapTo(M source, Class<T> clazz, BeanCopier copier) { - if (null == copier){ - copier = BeanCopier.create(source.getClass(), clazz, false); - } - T t = null; - try { - t = clazz.newInstance(); - copier.copy(source, t, null); - } catch (InstantiationException | IllegalAccessException e) { - // TODO log - } - return t; - } -} \ No newline at end of file diff --git a/src/main/java/com/lunhan/xxx/common/util/EncryptionUtil.java b/src/main/java/com/lunhan/xxx/common/util/EncryptionUtil.java deleted file mode 100644 index 7c5cf4f..0000000 --- a/src/main/java/com/lunhan/xxx/common/util/EncryptionUtil.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.lunhan.xxx.common.util; -import java.nio.charset.StandardCharsets; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; - -public class EncryptionUtil { - public static String encryptString(String input) { - try { - // 将传入的字符串转换为字节数组 - byte[] inputBytes = input.getBytes(StandardCharsets.UTF_8); - - // 使用SHA-256进行加密 - MessageDigest digest = MessageDigest.getInstance("SHA-256"); - byte[] hashBytes = digest.digest(inputBytes); - - // 转换为十六进制字符串 - StringBuilder sb = new StringBuilder(); - for (byte b : hashBytes) { - sb.append(String.format("%02x", b)); - } - String hashedString = sb.toString(); - - // 按照指定规则截取和重新组合字符串 - StringBuilder result = new StringBuilder(); - for (int i = 0; i < 4; i++) { - String subString = hashedString.substring(i * 16, (i + 1) * 16); - for (int j = 0; j < 4; j++) { - result.append(subString.charAt(j * 4 + j)); - } - } - return result.toString(); - - } catch (NoSuchAlgorithmException e) { - e.printStackTrace(); - return null; - } - } - -// public static void main(String[] args) { -// String input = "#beiaisi#_000001"; // 传入的字符串 -// -// // 调用加密方法 -// String encryptedString = encryptString(input); -// System.out.println(encryptedString); -// } -} \ No newline at end of file diff --git a/src/main/java/com/lunhan/xxx/common/util/ExceptionUtil.java b/src/main/java/com/lunhan/xxx/common/util/ExceptionUtil.java deleted file mode 100644 index d763a37..0000000 --- a/src/main/java/com/lunhan/xxx/common/util/ExceptionUtil.java +++ /dev/null @@ -1,69 +0,0 @@ -package com.lunhan.xxx.common.util; - -import java.io.ByteArrayOutputStream; -import java.io.PrintStream; - -/** - * 异常工具类 - * @author linliu - * @date 2018-12-28 - */ -public final class ExceptionUtil { - private ExceptionUtil() { - throw new IllegalStateException("Utility class"); - } - - public static String getMsg(Throwable e) { - ByteArrayOutputStream out = new ByteArrayOutputStream(); - PrintStream pout = new PrintStream(out); - e.printStackTrace(pout); - String ret = new String(out.toByteArray()); - pout.close(); - return ret; - } - - public static String getDetails(Throwable ex) { - return getMessage(ex, true); - } - - - private static String getMessage(Throwable ex, boolean includeDetail) { - if (ex != null) { - StringBuilder builder = new StringBuilder(); - Throwable current = ex; - - do { - builder.append(ex.getClass().getName()); - if (!StringUtil.isNullOrEmpty(current.getMessage())) { - builder.append(String.format(" : %s%n", current.getMessage())); - } - - if (includeDetail) { - builder.append(getStackTraceInfo(current)); - } - - current = current.getCause(); - } while(current != null); - - return builder.toString(); - } else { - return ""; - } - } - - private static String getStackTraceInfo(Throwable ex) { - StringBuilder sb = new StringBuilder(); - if (ex != null) { - StackTraceElement[] trace = ex.getStackTrace(); - StackTraceElement[] var6 = trace; - int var5 = trace.length; - - for(int var4 = 0; var4 < var5; ++var4) { - StackTraceElement s = var6[var4]; - sb.append(String.format("\tat %s%n", s)); - } - } - - return sb.toString(); - } -} \ No newline at end of file diff --git a/src/main/java/com/lunhan/xxx/common/util/FileUtil.java b/src/main/java/com/lunhan/xxx/common/util/FileUtil.java deleted file mode 100644 index 82574e4..0000000 --- a/src/main/java/com/lunhan/xxx/common/util/FileUtil.java +++ /dev/null @@ -1,436 +0,0 @@ -package com.lunhan.xxx.common.util; - -import java.io.*; -import java.nio.charset.Charset; -import java.nio.charset.StandardCharsets; - -/** - * 文件工具类 - * @author linliu - * @date 2019-03-20 - */ -public final class FileUtil { - private FileUtil() { - throw new IllegalStateException("Utility class"); - } - - static final String TITLE = "FileUtil"; - static final Integer EXCEL_SHEET_MAXROW = 65536; - static final String STR_FAILD = "generate excel is faild!"; - static final String STR_UPLOADEXCEL = "list to excel and upload file service"; - static final String STR_DEFAULT_SHEETNAME = "Sheet1"; - - /** - * 根据文件contentType生成一个文件名 - * @param fileContentType contentType - */ - public static String getNewFileNameByType(String fileContentType) { - String timeStamp = Long.toString(System.currentTimeMillis()); - return timeStamp + FileUtil.getFileExtByType(fileContentType); - } - - /** - * 根据文件contentType生成一个文件名 - * @param fileContentType contentType - */ - public static String getFileExtByType(String fileContentType) { - String result = checkImage(fileContentType); - if (StringUtil.isNotNullOrEmpty(result)) { - return result; - } - - result = checkRar(fileContentType); - if (StringUtil.isNotNullOrEmpty(result)) { - return result; - } - - result = checkMedia(fileContentType); - if (StringUtil.isNotNullOrEmpty(result)) { - return result; - } - - result = checkXml(fileContentType); - if (StringUtil.isNotNullOrEmpty(result)) { - return result; - } - - result = checkOffice(fileContentType); - if (StringUtil.isNotNullOrEmpty(result)) { - return result; - } - return ".txt"; - } - - /** - * 验证文件contentType是否是图片 - * @param fileContentType contentType - */ - private static String checkImage(String fileContentType) { - String result; - switch (fileContentType) { - case "image/jpeg": - case "application/x-jpg": - result = ".jpg"; - break; - case "image/gif": - result = ".gif"; - break; - case "image/png": - result = ".png"; - break; - case "image/bmp": - result = ".bmp"; - break; - default: - result = ""; - break; - } - return result; - } - - /** - * 验证文件contentType是否是压缩包 - * @param fileContentType contentType - */ - private static String checkRar(String fileContentType) { - String result; - switch (fileContentType) { - case "application/zip": - result = ".zip"; - break; - case "application/x-rar": - result = ".rar"; - break; - case "application/x-7z-compressed": - result = ".7z"; - break; - case "application/x-gzip": - result = ".gz"; - break; - default: - result = ""; - break; - } - return result; - } - - /** - * 验证文件contentType是否是媒体文件 - * @param fileContentType contentType - */ - private static String checkMedia(String fileContentType) { - String result; - switch (fileContentType) { - case "video/mpeg": - result = ".mp2"; - break; - case "video/mp4": - result = ".mp4"; - break; - case "video/3gpp": - result = ".3gp"; - break; - case "video/x-flv": - result = ".flv"; - break; - - case "audio/mpeg": - result = ".mp3"; - break; - case "audio/x-flac": - result = ".flac"; - break; - default: - result = ""; - break; - } - return result; - } - - /** - * 验证文件contentType是否是xml - * @param fileContentType contentType - */ - private static String checkXml(String fileContentType) { - String result; - switch (fileContentType) { - case "application/xml": - case "text/html": - result = ".xml"; - break; - default: - result = ""; - break; - } - return result; - } - - /** - * 验证文件contentType是否是office - * @param fileContentType contentType - */ - private static String checkOffice(String fileContentType) { - String result; - switch (fileContentType) { - case "application/vnd.ms-excel": - result = ".xls"; - break; - case "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": - result = ".xlsx"; - break; - case "application/msword": - result = ".doc"; - break; - case "application/vnd.openxmlformats-officedocument.wordprocessingml.document": - result = ".docx"; - break; - case "application/vnd.ms-powerpoint": - result = ".ppt"; - break; - case "application/vnd.openxmlformats-officedocument.presentationml.presentation": - result = ".pptx"; - break; - default: - result = ""; - break; - } - return result; - } - - /** - * 根据文件名识别文件 mediaType - * @author linliu - * @date 2019-06-26 - * @param fileName 文件名 - */ - public static String getMediaTypeByFileName(String fileName) { - if (StringUtil.isNullOrEmpty(fileName)) { - return ""; - } - String[] arrayPath = StringUtil.split(fileName, "/"); - String realFileName = arrayPath[arrayPath.length - 1]; - String[] array = StringUtil.split(realFileName, "\\."); - String fileSuffix = "." + array[array.length - 1]; - return getOfficeMediaTypeByFileName(fileSuffix); - } - - /** - * 根据文件拓展名识别 office文件 - * @param fileSuffix 拓展名 - */ - private static String getOfficeMediaTypeByFileName(String fileSuffix) { - String result; - switch (fileSuffix) { - case ".xls": - result = "application/vnd.ms-excel"; - break; - case ".xlsx": - result = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; - break; - case ".doc": - result = "application/msword"; - break; - case ".docx": - result = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; - break; - case ".ppt": - result = "application/vnd.ms-powerpoint"; - break; - case ".pptx": - result = "application/vnd.openxmlformats-officedocument.presentationml.presentation"; - break; - default: - result = getImageMediaTypeByFileName(fileSuffix); - break; - } - return result; - } - - /** - * 根据文件拓展名识别 图片文件 - * @param fileSuffix 拓展名 - */ - private static String getImageMediaTypeByFileName(String fileSuffix) { - String result; - switch (fileSuffix) { - case ".jpeg": - result = "image/jpeg"; - break; - case ".jpg": - result = "application/x-jpg"; - break; - case ".gif": - result = "image/gif"; - break; - case ".png": - result = "image/png"; - break; - case ".bmp": - result = "image/bmp"; - break; - default: - result = getRarMediaTypeByFileName(fileSuffix); - break; - } - return result; - } - - /** - * 根据文件拓展名识别 压缩文件 - * @param fileSuffix 拓展名 - */ - private static String getRarMediaTypeByFileName(String fileSuffix) { - String result; - switch (fileSuffix) { - case ".zip": - result = "application/zip"; - break; - case ".rar": - result = "application/x-rar"; - break; - case ".7z": - result = "application/x-7z-compressed"; - break; - case ".gz": - result = "application/x-gzip"; - break; - default: - result = getOtherMediaTypeByFileName(fileSuffix); - break; - } - return result; - } - - /** - * 根据文件拓展名识别 其他文件 - * @param fileSuffix 拓展名 - */ - private static String getOtherMediaTypeByFileName(String fileSuffix) { - String result; - switch (fileSuffix) { - case ".pdf": - result = "application/pdf"; - break; - case ".txt": - result = "text/plain"; - break; - default: - result = ""; - break; - } - return result; - } - - /** - * 读取本地文件内容 - * @param filePath 文件路径 - */ - public static String readFileContent(String filePath) { - return readFileContent(filePath, null); - } - - /** - * 读取本地文件内容 - * @param filePath 文件路径 - * @param charset 编码格式 - */ - public static String readFileContent(String filePath, Charset charset) { - if(null==charset) { - charset = Charset.forName("utf-8"); - } - File file = new File(filePath.replaceAll("\\\\", "/")); - StringBuilder localStrBulider = new StringBuilder(); - if(file.isFile() && file.exists()) { - String lineStr; - try (InputStreamReader inputStreamReader=new InputStreamReader(new FileInputStream(file), charset)){ - BufferedReader bufferReader = new BufferedReader(inputStreamReader); - while((lineStr = bufferReader.readLine()) != null) { - localStrBulider.append(lineStr); - } - bufferReader.close(); - } catch (IOException e) { - //TODO log - } - } else { - //TODO log - return null; - } - return localStrBulider.toString(); - } - - /** - * 读取本地文件内容 - * @param filePath 文件路径 - */ - public static byte[] readFile(String filePath) throws IOException { - File f = new File(filePath); - if (!f.exists()) { - throw new FileNotFoundException(filePath); - } - - ByteArrayOutputStream bos = new ByteArrayOutputStream((int) f.length()); - BufferedInputStream in = null; - try { - in = new BufferedInputStream(new FileInputStream(f)); - int bufSize = 1024; - byte[] buffer = new byte[bufSize]; - int len; - while (-1 != (len = in.read(buffer, 0, bufSize))) { - bos.write(buffer, 0, len); - } - return bos.toByteArray(); - } catch (IOException e) { - e.printStackTrace(); - throw e; - } finally { - try { - in.close(); - } catch (IOException e) { - e.printStackTrace(); - } - bos.close(); - } - } - - /** - * 删除文件 - * @param path - */ - public static void deleteFile(String path){ - File file=new File(path); - if(file.exists()){ - file.delete(); - } - } - - /** - * 读取流内容 - * @param inputStream 流 - */ - public static String readFileContent(InputStream inputStream) { - return FileUtil.readFileContent(inputStream, null); - } - - /** - * 读取流内容 - * @param inputStream 流 - * @param charset 编码格式 - */ - public static String readFileContent(InputStream inputStream, Charset charset) { - if(null==charset) { - charset = StandardCharsets.UTF_8; - } - StringBuilder localStrBulider = new StringBuilder(); - try (InputStreamReader inputStreamReader=new InputStreamReader(inputStream, charset)){ - BufferedReader bufferReader = new BufferedReader(inputStreamReader); - String lineStr; - while((lineStr = bufferReader.readLine()) != null) { - localStrBulider.append(lineStr); - } - bufferReader.close(); - } catch (IOException e) { - //TODO log - } - return localStrBulider.toString(); - } -} \ No newline at end of file diff --git a/src/main/java/com/lunhan/xxx/common/util/HttpUtil.java b/src/main/java/com/lunhan/xxx/common/util/HttpUtil.java deleted file mode 100644 index cfd9058..0000000 --- a/src/main/java/com/lunhan/xxx/common/util/HttpUtil.java +++ /dev/null @@ -1,484 +0,0 @@ -package com.lunhan.xxx.common.util; - -import com.lunhan.xxx.common.enums.EHttpContentType; -import org.apache.http.HttpEntity; -import org.apache.http.HttpHost; -import org.apache.http.HttpStatus; -import org.apache.http.StatusLine; -import org.apache.http.client.config.RequestConfig; -import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.entity.ByteArrayEntity; -import org.apache.http.entity.ContentType; -import org.apache.http.entity.StringEntity; -import org.apache.http.entity.mime.MultipartEntityBuilder; -import org.apache.http.entity.mime.content.ByteArrayBody; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.impl.client.HttpClients; -import org.apache.http.util.EntityUtils; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.UnsupportedEncodingException; -import java.math.BigDecimal; -import java.util.HashMap; -import java.util.Map; - -/** - * Http请求工具类 - * @author xiangyuanzhang - * @date 2018-12-25 - */ -public final class HttpUtil { - //region 常量 - - static final String STR_LOGTITLE = "SendHttpRequest"; - static final String STR_UTF8 = "utf-8"; - - private static final int CONNECTTIMEOUT=20000; - - //endregion - - private HttpUtil() { - throw new IllegalStateException("Utility class"); - } - - static Boolean isLogRequestContent(EHttpContentType contentType) { - Boolean isLog; - switch (contentType) { - case JSON: - case XML: - case FORM: - isLog = Boolean.TRUE; - break; - default: - isLog = Boolean.FALSE; - break; - } - return isLog; - } - - /** - * 获取HttpPost对象 - * @param url 请求url - * @param contentType 请求类型(EHttpContentType),默认application/x-www-Form-urlencoded - * @param headers 自定义请求头 - * @param proxy http代理(例: http://ntproxy.qa.nt.ctripcorp.com:8080) - * @return - */ - private static HttpPost getHttpPost(String url, String contentType, Map<String, String> headers, String proxy) { - if(StringUtil.isNullOrEmpty(contentType)) { - contentType = EHttpContentType.FORM.getDesc(); - } - - HttpHost httpProxy = null; - if(StringUtil.isNotNullOrEmpty(proxy)) { - proxy = proxy.replace("https://", "").replace("http://", ""); - String[] arrProxy = StringUtil.split(proxy, ":"); - httpProxy = new HttpHost(arrProxy[0], Integer.valueOf(arrProxy[1])); - } - - //创建httpPost - HttpPost httpPost = new HttpPost(url); - if(!EHttpContentType.FORMDATA.getDesc().equals(contentType)) { - httpPost.setHeader("Content-Type", contentType); - } - - RequestConfig config = RequestConfig.custom() - //连接超时 - .setConnectionRequestTimeout(Integer.parseInt("60000"))//60 * 1000 - //请求超时 - .setConnectTimeout(Integer.parseInt("300000"))//5 * 60 * 1000 - //读取超时 - .setSocketTimeout(Integer.parseInt("10000"))//10 * 1000 - .setProxy(httpProxy) - .build(); - - httpPost.setConfig(config); - if(headers!=null && !headers.isEmpty()) { - for (Map.Entry<String, String> item : headers.entrySet()) { - httpPost.setHeader(item.getKey(), item.getValue()); - } - } - - return httpPost; - } - - /** - * 发起post请求 - * @param url 请求url - * @param postData 数据包 - * @param contentType 请求类型 - * @param headers 自定义header - * @param proxy http代理(例: http://ntproxy.qa.nt.ctripcorp.com:8080) - */ - public static String doPost(String url, HttpEntity postData, EHttpContentType contentType, Map<String, String> headers, String proxy) throws IOException { - String responseContent; - - CloseableHttpClient httpclient = HttpClients.custom() - .build(); - HttpPost httpPost = HttpUtil.getHttpPost(url, contentType.getDesc(), headers, proxy); - httpPost.setEntity(postData); - CloseableHttpResponse response = null; - - Map<String, String> logTags = new HashMap<>(); - logTags.put("url", url.toLowerCase()); - StringBuilder sbLog = new StringBuilder(HttpUtil.createLog(url, httpPost, contentType, postData)); - - try { - response = httpclient.execute(httpPost); - sbLog.append(String.format("ResponseTime:%s%n", CalendarUtil.toNowDateTimeMSStr())); - - StatusLine status = response.getStatusLine(); - int state = status.getStatusCode(); - if (state == HttpStatus.SC_OK) { - HttpEntity responseEntity = response.getEntity(); - responseContent = EntityUtils.toString(responseEntity); - - sbLog.append(String.format("ResponseData:%s%n", responseContent)); - sbLog.append(String.format("ResponseDataReadedTime:%s%n", CalendarUtil.toNowDateTimeMSStr())); - } - else{ - throw new RuntimeException(url+", the response “HttpStatus” of remote is :"+ state); - } - } - catch (Exception e) { - sbLog.append(String.format("the time at exception happend:%s%n", LocalDateTimeUtil.nowTimeStampStr())); - //TODO log - throw e; - } - finally { - if (response != null) { - try { - response.close(); - } catch (IOException e) { - //TODO log - } - } - try { - httpclient.close(); - } catch (IOException e) { - //TODO log - } - } - //TODO log - return responseContent; - } - - static String createLog(String url, HttpPost httpPost, EHttpContentType contentType, HttpEntity postData) { - StringBuilder sbLog = new StringBuilder(); - - sbLog.append(String.format("url:%s%n", url)); - sbLog.append(String.format("Request time:%s%n", CalendarUtil.toNowDateTimeMSStr())); - sbLog.append(String.format("Request method:%s%n", httpPost.getMethod())); - sbLog.append(String.format("ContentType:%s%n", httpPost.getEntity().getContentType())); - HttpHost hProxy = httpPost.getConfig().getProxy(); - if(hProxy!=null && StringUtil.isNotNullOrEmpty(hProxy.getHostName())) { - sbLog.append(String.format("used http proxy:%s://%s:%s%n", hProxy.getSchemeName(), hProxy.getHostName(), hProxy.getPort())); - } - if(null!= httpPost.getAllHeaders() && httpPost.getAllHeaders().length>0) { - sbLog.append(String.format("headers:%s%n", SerializeUtil.toJson(httpPost.getAllHeaders()))); - } - - if(isLogRequestContent(contentType)) { - try { - sbLog.append(String.format("Request body:%s%n", EntityUtils.toString(postData, STR_UTF8))); - } catch (Exception e) { - // - } - } else { - BigDecimal sizeKB = new BigDecimal(postData.getContentLength()).divide(new BigDecimal("1024")); - sbLog.append(String.format("Request body:%s kb.%n", sizeKB.setScale(Integer.parseInt("2"), BigDecimal.ROUND_HALF_UP))); - } - sbLog.append(String.format("Request data readed time:%s%n", CalendarUtil.toNowDateTimeMSStr())); - - return sbLog.toString(); - } - - /** - * 发起post请求 - * @param url 请求url - * @param postData 数据包 - * @param contentType 请求类型 - */ - public static String doPost(String url, byte[] postData, EHttpContentType contentType) throws IOException { - return HttpUtil.doPost(url, postData, contentType, null, null); - } - - /** - * 发起post请求 - * @param url 请求url - * @param postData 数据包 - * @param contentType 请求类型 - * @param headers 自定义header - * @param proxy http代理(例: http://ntproxy.qa.nt.ctripcorp.com:8080) - */ - public static String doPost(String url, byte[] postData, EHttpContentType contentType, Map<String, String> headers, String proxy) throws IOException { - HttpEntity entity = new ByteArrayEntity(postData, ContentType.create(contentType.getDesc())); - return HttpUtil.doPost(url, entity, contentType, headers, proxy); - } - - /** - * 发起文件上传请求 - * @param url 请求url - * @param postData 数据包 - * @param fileName 文件名 - * @param fileContentType 文件类型 - */ - public static String postFile(String url, byte[] postData, String fileName, String fileContentType) throws IOException { - return HttpUtil.postFile(url, postData, fileName, fileContentType, null, null); - } - /** - * 发起文件上传请求 - * @param url 请求url - * @param postData 数据包 - * @param fileName 文件名 - * @param fileContentType 文件类型 - * @param headers 自定义header - * @param proxy http代理(例: http://ntproxy.qa.nt.ctripcorp.com:8080) - */ - public static String postFile(String url, byte[] postData, String fileName, String fileContentType, Map<String, String> headers, String proxy) throws IOException { - MultipartEntityBuilder entity = MultipartEntityBuilder.create(); - entity.addPart("file", new ByteArrayBody(postData, ContentType.create(fileContentType), fileName)); - return HttpUtil.doPost(url, entity.build(), EHttpContentType.FORMDATA, headers, proxy); - } - - /** - * 发起post请求 - * @param url 请求url - * @param postData 数据包 - * @param contentType 请求类型 - */ - public static String doPost(String url, String postData, EHttpContentType contentType, Map<String, String> headers) throws IOException { - HttpEntity entity = new StringEntity(postData, STR_UTF8); - return HttpUtil.doPost(url, entity, contentType, headers, null); - } - - /** - * 发起post请求 - * @param url 请求url - * @param postData 数据包 - * @param contentType 请求类型 - * @param proxy http代理(例: http://ntproxy.qa.nt.ctripcorp.com:8080) - */ - public static String doPost(String url, String postData, EHttpContentType contentType, Map<String, String> headers, String proxy) throws IOException { - HttpEntity entity = new StringEntity(postData, STR_UTF8); - return HttpUtil.doPost(url, entity, contentType, headers, proxy); - } - - /** - * 发起post请求 - * @param url 请求url - * @param postData 数据包 - * @param contentType 请求类型 - */ - public static String doPost(String url, String postData, EHttpContentType contentType) throws IOException { - return HttpUtil.doPost(url, postData, contentType, null); - } - - /** - * 以“application/json”方式发起post请求 - * @param url 请求url - * @param postData 数据包 - * @param headers 自定义header - */ - public static String postJson(String url, Object postData, Map<String, String> headers) throws IOException { - String json = SerializeUtil.toJson(postData); - HttpEntity entity = new StringEntity(json, STR_UTF8); - return HttpUtil.doPost(url, entity, EHttpContentType.JSON, headers, null); - } - - /** - * 以“application/json”方式发起post请求 - * @param url 请求url - * @param postData 数据包 - * @param type 反序列化类型 - * @param headers 自定义header - * @param <T> 反序列化对象泛型 - */ - public static <T> T postJson(String url, Object postData, Class<T> type, Map<String, String> headers) throws IOException { - return HttpUtil.postJson(url, postData, type, headers, null); - } - - /** - * 以“application/json”方式发起post请求 - * @param url 请求url - * @param postData 数据包 - * @param type 反序列化类型 - * @param headers 自定义header - * @param proxy http代理(例: http://ntproxy.qa.nt.ctripcorp.com:8080) - * @param <T> 反序列化对象泛型 - */ - public static <T> T postJson(String url, Object postData, Class<T> type, Map<String, String> headers, String proxy) throws IOException { - String json = SerializeUtil.toJson(postData); - HttpEntity entity = new StringEntity(json, STR_UTF8); - String response = doPost(url, entity, EHttpContentType.JSON, headers, proxy); - - T result; - try { - result = SerializeUtil.toObject(response, type); - } catch (Exception e) { - result = null; - } - return result; - } - - /** - * 从url获取响应流 - * @param url 请求url - */ - public static byte[] getStreamByUrl(String url) { - CloseableHttpClient httpclient = HttpClients.custom().setConnectionManagerShared(true).build(); - HttpGet httpGet = new HttpGet(url); - RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(CONNECTTIMEOUT).setConnectTimeout(CONNECTTIMEOUT).build();//设置请求和传输超时时间 - httpGet.setConfig(requestConfig); - CloseableHttpResponse response = null; - try { - response = httpclient.execute(httpGet); - int statuscode = response.getStatusLine().getStatusCode(); - if (statuscode == HttpStatus.SC_OK) { - HttpEntity entity = response.getEntity(); - InputStream isStream = entity.getContent(); - return HttpUtil.getBytesFromInputStream(isStream); - } - } catch (Exception e) { - //TODO log - } finally { - if (response != null) { - //TODO log - } - - try { - httpclient.close(); - } catch (IOException e) { - //TODO log - } - } - return new byte[0]; - } - - /** - * 从输入流返回字节数组 - * @param input 输入流 - */ - public static byte[] getBytesFromInputStream(InputStream input) { - ByteArrayOutputStream output = new ByteArrayOutputStream(); - try { - byte[] buffer = new byte[1024]; - int n = 0; - while (-1 != (n = input.read(buffer))) { - output.write(buffer, 0, n); - } - return output.toByteArray(); - } catch (IOException e) { - //TODO log - return new byte[0]; - } finally { - try { - output.close(); - input.close(); - } catch (IOException e) { - //TODO log - } - } - } - - /** - * 发起get请求,读取返回流为字符串 - * @param url 请求url - * @param charset 读取返回流的字符集 - */ - public static String doGet(String url, String charset) throws UnsupportedEncodingException { - byte[] result = HttpUtil.getStreamByUrl(url); - try { - return new String(result, charset); - } catch (UnsupportedEncodingException e) { - try { - return new String(result, STR_UTF8); - } catch (Exception ex) { - throw e; - } - } - } - - /** - * 发起get请求,以“utf-8”字符集,读取返回流为字符串 - * @param url 请求url - */ - public static String doGet(String url) { - try { - return HttpUtil.doGet(url, STR_UTF8); - } catch (UnsupportedEncodingException e) { - throw new RuntimeException(e.getMessage()); - } - } - - /** - * 从url获取响应流 - * @param url 请求url - * @param headers 自定义header - * @param proxy 代理地址([http:// | https://]www.baidu.com:8080) - */ - public static byte[] getStream(String url, Map<String, String> headers, String proxy) { - String action = "getStreamByUrl"; - Map<String, String> logTags = new HashMap<>(); - logTags.put("action", action); - logTags.put("url", url); - - HttpHost httpProxy = null; - if(StringUtil.isNotNullOrEmpty(proxy)) { - proxy = proxy.replace("https://", "").replace("http://", ""); - String[] arrProxy = StringUtil.split(proxy, ":"); - httpProxy = new HttpHost(arrProxy[0], Integer.parseInt(arrProxy[1])); - } - - CloseableHttpClient httpclient = HttpClients.custom() - .setConnectionManagerShared(true) - .build(); - HttpGet httpGet = new HttpGet(url); - if(null!=headers) { - for (Map.Entry<String, String> entry : headers.entrySet()) { - httpGet.setHeader(entry.getKey(), entry.getValue()); - } - } - //设置请求和传输超时时间 - RequestConfig requestConfig = RequestConfig.custom() - .setSocketTimeout(CONNECTTIMEOUT) - .setConnectTimeout(CONNECTTIMEOUT) - .setProxy(httpProxy) - .build(); - httpGet.setConfig(requestConfig); - CloseableHttpResponse response = null; - try { - response = httpclient.execute(httpGet); - int statusCode = response.getStatusLine().getStatusCode(); - if (statusCode == HttpStatus.SC_OK) { - HttpEntity entity = response.getEntity(); - InputStream isStream = entity.getContent(); - return HttpUtil.getBytesFromInputStream(isStream); - } - } catch (Exception e) { - //TODO log - } finally { - if (response != null) { - try { - response.close(); - } catch (IOException e) { - //TODO log - } - } - try { - httpclient.close(); - } catch (IOException e) { - //TODO log - } - } - return new byte[0]; - } - - public static byte[] getStream(String url, Map<String, String> headers) { - return HttpUtil.getStream(url, headers, null); - } -} \ No newline at end of file diff --git a/src/main/java/com/lunhan/xxx/common/util/IPUtils.java b/src/main/java/com/lunhan/xxx/common/util/IPUtils.java deleted file mode 100644 index 29e9eb3..0000000 --- a/src/main/java/com/lunhan/xxx/common/util/IPUtils.java +++ /dev/null @@ -1,71 +0,0 @@ -package com.lunhan.xxx.common.util; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import javax.servlet.http.HttpServletRequest; -import java.net.InetAddress; -import java.net.UnknownHostException; - -public class IPUtils { - private static Logger logger = LoggerFactory.getLogger(IPUtils.class); - private static final String IP_UTILS_FLAG = ","; - private static final String UNKNOWN = "unknown"; - private static final String LOCALHOST_IP = "0:0:0:0:0:0:0:1"; - private static final String LOCALHOST_IP1 = "127.0.0.1"; - - /** - * 获取IP地址 - * <p> - * 使用Nginx等反向代理软件, 则不能通过request.getRemoteAddr()获取IP地址 - * 如果使用了多级反向代理的话,X-Forwarded-For的值并不止一个,而是一串IP地址,X-Forwarded-For中第一个非unknown的有效IP字符串,则为真实IP地址 - */ - public static String getIpAddress(HttpServletRequest request) { - String ip = null; - try { - //以下两个获取在k8s中,将真实的客户端IP,放到了x-Original-Forwarded-For。而将WAF的回源地址放到了 x-Forwarded-For了。 - ip = request.getHeader("X-Original-Forwarded-For"); - if (StringUtil.isNullOrEmpty(ip) || UNKNOWN.equalsIgnoreCase(ip)) { - ip = request.getHeader("X-Forwarded-For"); - } - //获取nginx等代理的ip - if (StringUtil.isNullOrEmpty(ip) || UNKNOWN.equalsIgnoreCase(ip)) { - ip = request.getHeader("x-forwarded-for"); - } - if (StringUtil.isNullOrEmpty(ip) || UNKNOWN.equalsIgnoreCase(ip)) { - ip = request.getHeader("Proxy-Client-IP"); - } - if (StringUtil.isNullOrEmpty(ip) || ip.length() == 0 || UNKNOWN.equalsIgnoreCase(ip)) { - ip = request.getHeader("WL-Proxy-Client-IP"); - } - if (StringUtil.isNullOrEmpty(ip) || UNKNOWN.equalsIgnoreCase(ip)) { - ip = request.getHeader("HTTP_CLIENT_IP"); - } - if (StringUtil.isNullOrEmpty(ip) || UNKNOWN.equalsIgnoreCase(ip)) { - ip = request.getHeader("HTTP_X_FORWARDED_FOR"); - } - //兼容k8s集群获取ip - if (StringUtil.isNullOrEmpty(ip) || UNKNOWN.equalsIgnoreCase(ip)) { - ip = request.getRemoteAddr(); - if (LOCALHOST_IP1.equalsIgnoreCase(ip) || LOCALHOST_IP.equalsIgnoreCase(ip)) { - //根据网卡取本机配置的IP - InetAddress iNet = null; - try { - iNet = InetAddress.getLocalHost(); - } catch (UnknownHostException e) { - logger.error("getClientIp error: {}", e); - } - ip = iNet.getHostAddress(); - } - } - } catch (Exception e) { - logger.error("IPUtils ERROR ", e); - } - //使用代理,则获取第一个IP地址 - if (!StringUtil.isNullOrEmpty(ip) && ip.indexOf(IP_UTILS_FLAG) > 0) { - ip = ip.substring(0, ip.indexOf(IP_UTILS_FLAG)); - } - - return ip; - } -} diff --git a/src/main/java/com/lunhan/xxx/common/util/ListUtil.java b/src/main/java/com/lunhan/xxx/common/util/ListUtil.java deleted file mode 100644 index 91ab5cb..0000000 --- a/src/main/java/com/lunhan/xxx/common/util/ListUtil.java +++ /dev/null @@ -1,200 +0,0 @@ -package com.lunhan.xxx.common.util; - -import java.math.BigDecimal; -import java.util.*; -import java.util.function.Consumer; -import java.util.function.Function; -import java.util.stream.Collectors; - -/** - * List工具类 - * @author linliu - * @date 2018-12-28 - */ -public final class ListUtil { - private ListUtil() { - throw new IllegalStateException("Utility class"); - } - - /** - * array转list - * @param array 数组 - * @param <T> 实体类型 - */ - public static <T> List<T> toList(T... array) { - if(array==null || array.length==0) { - return new ArrayList<>(); - } - return Arrays.stream(array).collect(Collectors.toList()); - } - - /** - * Long类型 list转array - * @param list 集合 - */ - public static Long[] toLongArray(List<Long> list) { - if(ListUtil.isNullOrEmpty(list)) { - return new Long[0]; - } - Long[] array = new Long[list.size()]; - return list.toArray(array); - } - /** - * Integer类型 list转array - * @param list 集合 - */ - public static Integer[] toIntArray(List<Integer> list) { - if(ListUtil.isNullOrEmpty(list)) { - return new Integer[0]; - } - Integer[] array = new Integer[list.size()]; - return list.toArray(array); - } - /** - * BigDecimal类型 list转array - * @param list 集合 - */ - public static BigDecimal[] toDecimalArray(List<BigDecimal> list) { - if(ListUtil.isNullOrEmpty(list)) { - return new BigDecimal[0]; - } - BigDecimal[] array = new BigDecimal[list.size()]; - return list.toArray(array); - } - /** - * Double类型 list转array - * @param list 集合 - */ - public static Double[] toDoubleArray(List<Double> list) { - if(ListUtil.isNullOrEmpty(list)) { - return new Double[0]; - } - Double[] array = new Double[list.size()]; - return list.toArray(array); - } - /** - * String类型 list转array - * @param list 集合 - */ - public static String[] toArray(List<String> list) { - if(ListUtil.isNullOrEmpty(list)) { - return new String[0]; - } - String[] array = new String[list.size()]; - return list.toArray(array); - } - - /** - * 判断集合【为】null或empty - * @param list 集合 - * @param <T> 集合实体类型 - */ - public static <T> boolean isNullOrEmpty(Collection<T> list){ - return list==null || list.isEmpty(); - } - - /** - * 判断集合【不为】null或empty - * @param list 集合 - * @param <T> 集合实体类型 - */ - public static <T> boolean isNotNullOrEmpty(Collection<T> list){ - return !ListUtil.isNullOrEmpty(list); - } - - /** - * String类型集合转Integer类型集合 - * @param list 集合 - */ - public static List<Integer> toIntList(List<String> list) { - if(ListUtil.isNullOrEmpty(list)) { - return new ArrayList<>(); - } - return list.stream().map(Integer::parseInt).collect(Collectors.toList()); - } - - /** - * String类型集合转Long类型集合 - * @param list 集合 - */ - public static List<Long> toLongList(List<String> list) { - if(ListUtil.isNullOrEmpty(list)) { - return new ArrayList<>(); - } - return list.stream().map(Long::parseLong).collect(Collectors.toList()); - } - - /** - * Integer类型集合转String类型集合 - * @param list 集合 - */ - public static List<String> toStringList(List<Integer> list) { - if(ListUtil.isNullOrEmpty(list)) { - return new ArrayList<>(); - } - return list.stream().map(String::valueOf).collect(Collectors.toList()); - } - - /** - * BigDecimal类型集合求和 - * @param list 集合 - */ - public static BigDecimal sum(Collection<BigDecimal> list) { - BigDecimal result = BigDecimal.ZERO; - if(ListUtil.isNotNullOrEmpty(list)) { - result = list.stream().reduce(BigDecimal.ZERO, BigDecimal::add); - } - return result; - } - - /** - * 判断集合非空后,执行委托 - * @param list 集合 - * @param predicate 循环集合的委托代码 - * @param <T> 集合实体类型 - * @param <R> 函数(集合委托)返回值,委托里最后一句写死“return null;” - */ - public static <T, R> void notNullForeach(Collection<T> list, Function<T, R> predicate) { - if(ListUtil.isNotNullOrEmpty(list)) { - for (T item : list) { - predicate.apply(item); - } - } - } - - /** - * 集合去重 - * @param list 集合 - * @param <T> 集合实体类型 - */ - public static <T> void repeat(Collection<T> list) { - HashSet<T> hash = new HashSet<T>(list); - list.clear(); - list.addAll(hash); - } - - /** - * 判断集合是否存在重复元素 - * @param list 集合 - * @param <T> 集合实体类型 - */ - public static <T> Boolean hasRepeat(Collection<T> list) { - int oldSize = list.size(); - repeat(list); - return list.size()!=oldSize; - } - - /** - * 集合非空,则执行委托 - * @param list 集合 - * @param predicate 循环集合的委托代码 - * @param <T> 集合实体类型 - */ - public static <T> void notNullForeach(Collection<T> list, Consumer<T> predicate) { - if(ListUtil.isNotNullOrEmpty(list)) { - for (T item : list) { - predicate.accept(item); - } - } - } -} \ No newline at end of file diff --git a/src/main/java/com/lunhan/xxx/common/util/LocalDateTimeUtil.java b/src/main/java/com/lunhan/xxx/common/util/LocalDateTimeUtil.java deleted file mode 100644 index 05d1405..0000000 --- a/src/main/java/com/lunhan/xxx/common/util/LocalDateTimeUtil.java +++ /dev/null @@ -1,565 +0,0 @@ -package com.lunhan.xxx.common.util; - -import cn.hutool.core.date.DateTime; -import com.lunhan.xxx.common.ConstantFactory; -import com.lunhan.xxx.common.exceptions.BusinessException; - -import java.sql.Timestamp; -import java.text.SimpleDateFormat; -import java.time.Instant; -import java.time.LocalDate; -import java.time.LocalDateTime; -import java.time.ZoneId; -import java.time.format.DateTimeFormatter; -import java.time.format.DateTimeParseException; -import java.time.temporal.ChronoUnit; -import java.time.temporal.TemporalAdjusters; -import java.util.Date; - -/** - * jdk8时间日期处理 工具类 - */ -public final class LocalDateTimeUtil { - private LocalDateTimeUtil() { - throw new IllegalStateException("Utility class"); - } - - /** - * 默认时间格式化对象 - */ - private static final DateTimeFormatter DEFAULT_FORMATTER = DateTimeFormatter.ofPattern(ConstantFactory.STR_DATE_FULL); - /** - * 默认时间格式化对象 - */ - private static final DateTimeFormatter DEFAULT_FORMATTER_DATE = DateTimeFormatter.ofPattern(ConstantFactory.STR_DATE); - /** - * 默认时间(1970-01-01 00:00:00) - */ - public static final LocalDateTime DEFAULT_DATETIME = LocalDateTime.parse(ConstantFactory.STR_DATE_DEFAULT, DEFAULT_FORMATTER); - /** - * 默认时间(1970-01-01) - */ - public static final LocalDate DEFAULT_DATE = LocalDate.parse(ConstantFactory.STR_DATE_DEFAULT_DATE, DEFAULT_FORMATTER_DATE); - - //************************************** 【LocalDateTime】 ************************************** - /** - * 获取当前LocalDateTime - */ - public static LocalDateTime nowDateTime() { - return LocalDateTime.now(); - } - /** - * 获取当前时间字符串(yyyy-MM-dd HH:mm:ss) - */ - public static String nowDateTimeStr() { - return LocalDateTimeUtil.toFormatString(LocalDateTime.now()); - } - /** - * 获取当前时间字符串(yyyy-MM-dd HH:mm:ss.SSS) - */ - public static String nowDateTimeFullStr() { - return LocalDateTimeUtil.toFormatFullString(LocalDateTime.now()); - } - /** - * 通过时间戳构建LocalDateTime - * @param timestamp 时间戳 - */ - public static LocalDateTime getDateTime(Long timestamp) { - if(NumericUtil.tryParseLong(timestamp).compareTo(0L)<1) { - return LocalDateTimeUtil.DEFAULT_DATETIME; - } - return LocalDateTime.ofInstant(Instant.ofEpochMilli(timestamp), ZoneId.systemDefault()); - } - /** - * 通过时间戳构建LocalDateTime - * @param timestamp 时间戳 - */ - public static LocalDateTime getDateTime(Timestamp timestamp) { - if(null==timestamp) { - return LocalDateTimeUtil.DEFAULT_DATETIME; - } - return LocalDateTimeUtil.getDateTime(timestamp.getTime()); - } - /** - * 通过时间字符串和指定时间格式(例:yyyy-MM-dd HH:mm:ss), 构建LocalDateTime - * @param dateTime 时间字符串 - * @param format 指定时间格式(例:yyyy-MM-dd HH:mm:ss) - */ - public static LocalDateTime getDateTime(String dateTime, String format) { - if(StringUtil.isNullOrEmpty(dateTime)) { - return LocalDateTimeUtil.DEFAULT_DATETIME; - } - if(StringUtil.isNullOrEmpty(format)) { - format = ConstantFactory.STR_DATE_FULL; - } - DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(format); - if(ConstantFactory.STR_DATE.equals(format)) { - LocalDate localDate = getDate(dateTime); - return localDate.atStartOfDay(); - } - return LocalDateTime.parse(dateTime, dateTimeFormatter); - } - /** - * 通过时间字符串和固定时间格式(yyyy-MM-dd HH:mm:ss), 构建LocalDateTime - * @param dateTime 时间字符串 - */ - public static LocalDateTime getDateTime(String dateTime) { - return LocalDateTimeUtil.getDateTime(dateTime, ConstantFactory.STR_DATE_FULL); - } - /** - * 将LocalDateTime格式化成时间字符串 - * @param dateTime LocalDateTime对象 - * @param format 指定时间格式(例:yyyy-MM-dd HH:mm:ss) - */ - public static String toFormatString(LocalDateTime dateTime, String format) { - if(null==dateTime) { - return ConstantFactory.STR_DATE_DEFAULT; - } - if(StringUtil.isNullOrEmpty(format)) { - format = ConstantFactory.STR_DATE_FULL; - } - DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(format); - return dateTimeFormatter.format(dateTime); - } - /** - * 将LocalDateTime按“yyyy-MM-dd HH:mm:ss.SSS”格式化成时间字符串 - * @param dateTime LocalDateTime对象 - */ - public static String toFormatFullString(LocalDateTime dateTime) { - if(null==dateTime) { - return ConstantFactory.STR_DATE_DEFAULT_FULL; - } - return LocalDateTimeUtil.toFormatString(dateTime, ConstantFactory.STR_DATE_FULLMS); - } - /** - * 将LocalDateTime按“yyyy-MM-dd HH:mm:ss”格式化成时间字符串 - * @param dateTime LocalDateTime对象 - */ - public static String toFormatString(LocalDateTime dateTime) { - if(null==dateTime) { - return ConstantFactory.STR_DATE_DEFAULT; - } - return LocalDateTimeUtil.toFormatString(dateTime, ConstantFactory.STR_DATE_FULL); - } - /** - * 将LocalDateTime按“yyyy-MM-dd”格式化成时间字符串 - * @param dateTime LocalDateTime对象 - */ - public static String toDateString(LocalDateTime dateTime) { - if(null==dateTime) { - return ConstantFactory.STR_DATE_DEFAULT_DATE; - } - return LocalDateTimeUtil.toFormatString(dateTime, ConstantFactory.STR_DATE); - } - /** - * 将dateTime格式化成时间字符串 - * @param date LocalDate对象 - * @param format 指定时间格式(例:yyyy-MM-dd) - */ - public static String toFormatString(LocalDate date, String format) { - if(null==date) { - return ConstantFactory.STR_DATE_DEFAULT_DATE; - } - if(StringUtil.isNullOrEmpty(format)) { - format = ConstantFactory.STR_DATE; - } - DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(format); - return dateTimeFormatter.format(date); - } - /** - * 将LocalDate按“yyyy-MM-dd”格式化成时间字符串 - * @param date LocalDate对象 - */ - public static String toFormatString(LocalDate date) { - return LocalDateTimeUtil.toFormatString(date, ConstantFactory.STR_DATE); - } - /** - * LocalDateTime偏移指定月数 - * @param dateTime LocalDateTime对象 - * @param addMonth 偏移月数(可以为负数) - */ - public static LocalDateTime dateTimeAddMonth(LocalDateTime dateTime, Long addMonth) { - if(null==dateTime) { - return LocalDateTimeUtil.DEFAULT_DATETIME; - } - return dateTime.plusMonths(addMonth); - } - /** - * LocalDateTime偏移指定天数 - * @param dateTime LocalDateTime对象 - * @param addDay 偏移天数(可以为负数) - */ - public static LocalDateTime dateTimeAddDay(LocalDateTime dateTime, Long addDay) { - if(null==dateTime) { - return LocalDateTimeUtil.DEFAULT_DATETIME; - } - return dateTime.plusDays(addDay); - } - /** - * LocalDateTime偏移指定小时数 - * @param dateTime LocalDateTime对象 - * @param addHour 偏移小时数(可以为负数) - */ - public static LocalDateTime dateTimeAddHour(LocalDateTime dateTime, Long addHour) { - if(null==dateTime) { - return LocalDateTimeUtil.DEFAULT_DATETIME; - } - return dateTime.plusHours(addHour); - } - /** - * LocalDateTime偏移指定分钟数 - * @param dateTime LocalDateTime对象 - * @param addMin 偏移分钟数(可以为负数) - */ - public static LocalDateTime dateTimeAddMin(LocalDateTime dateTime, Long addMin) { - if(null==dateTime) { - return LocalDateTimeUtil.DEFAULT_DATETIME; - } - return dateTime.plusMinutes(addMin); - } - /** - * 获取两个日期相差的天数 - * - * @param dateString1 开始日期的字符串 - * @param dateString2 结束日期的字符串 - * @return 相差天数,如果解析失败则返回-1 - **/ - public static long subDaysByDate2(String dateString1 , String dateString2 ) { - DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); - LocalDate date1 = LocalDate.parse(dateString1, formatter); - LocalDate date2 = LocalDate.parse(dateString2, formatter); - long daysBetween = java.time.Duration.between(date1.atStartOfDay(), date2.atStartOfDay()).toDays(); - return daysBetween; - } - /** - * LocalDateTime偏移指定秒数 - * @param dateTime LocalDateTime对象 - * @param addSec 偏移秒数(可以为负数) - */ - public static LocalDateTime dateTimeAddSec(LocalDateTime dateTime, Long addSec) { - if(null==dateTime) { - return LocalDateTimeUtil.DEFAULT_DATETIME; - } - return dateTime.plusSeconds(addSec); - } - /** - * LocalDateTime指定时间部分,偏移指定值 - * @param dateTime LocalDateTime对象 - * @param addPart 偏移时间部分 - * @param value 偏移值 - */ - public static LocalDateTime dateTimeAdd(LocalDateTime dateTime, ChronoUnit addPart, Long value) { - if(null==dateTime) { - return LocalDateTimeUtil.DEFAULT_DATETIME; - } - return dateTime.plus(value, addPart); - } - /** - * 获取当前月份第一天LocalDateTime“00:00:00” - */ - public static LocalDateTime monthFirstDateTime() { - - LocalDateTime now = LocalDateTime.now(); - return LocalDateTime.of(now.getYear(), now.getMonthValue(), 1, 0, 0); - } - /** - * 获取年月字符串第一天“00:00:00”时间戳 - */ - public static Long getYearMonthFirstTime(String yearMonth){ - //String month = "2023-05"; - LocalDateTime time = DateTime.of(yearMonth, "yyyy-MM").toTimestamp().toLocalDateTime(); - LocalDateTime first = time.with(TemporalAdjusters.firstDayOfMonth()).withHour(0) - .withMinute(0).withSecond(0); - return getTimeStamp(first).getTime(); - } - /** - * 获取年月字符串最后一天“00:00:00”时间戳 - */ - public static Long getYearMonthLatestTime(String yearMonth){ - //String month = "2023-05"; - LocalDateTime time = DateTime.of(yearMonth, "yyyy-MM").toTimestamp().toLocalDateTime(); - LocalDateTime end = time.with(TemporalAdjusters.lastDayOfMonth()).withHour(23) - .withMinute(59).withSecond(59); - return getTimeStamp(end).getTime(); - } - /** - * 获取当前月份最后一天LocalDateTime“23:59:59” - */ - public static LocalDateTime monthLatestDateTime() { - //当前月第一天“00:00:00” - LocalDateTime monthFirst = monthFirstDateTime(); - //下个月第一天“00:00:00” - LocalDateTime nextMonthFirst = dateTimeAddMonth(monthFirst, 1L); - //当前月最后一天“23:59:59” - return LocalDateTimeUtil.dateTimeAddSec(nextMonthFirst, -1L); - } - /** - * 获取今天LocalDateTime“00:00:00” - */ - public static LocalDateTime todayFirst() { - LocalDateTime now = LocalDateTimeUtil.nowDateTime(); - return LocalDateTime.of(now.getYear(), now.getMonthValue(), now.getDayOfMonth(), 0, 0); - } - /** - * 获取今天LocalDateTime“23:59:59” - */ - public static LocalDateTime todayLatest() { - //今天“00:00:00” - LocalDateTime now = LocalDateTimeUtil.nowDateTime(); - //明天“00:00:00” - LocalDateTime nextDayFirst = LocalDateTimeUtil.dateTimeAddDay(now, 1L); - //今天“23:59:59” - return LocalDateTimeUtil.dateTimeAddSec(nextDayFirst, -1L); - } - //************************************** 【LocalDateTime】 ************************************** - - - - - - //************************************** 【LocalDate】 ************************************** - /** - * 获取当前LocalDate - */ - public static LocalDate nowDate() { - return LocalDate.now(); - } - /** - * 获取当前日期字符串(yyyy-MM-dd) - */ - public static String todayStr() { - return LocalDateTimeUtil.toFormatString(LocalDateTime.now(), ConstantFactory.STR_DATE); - } - /** - * 根据日期字符串获取LocalDate(必须是yyyy-MM-dd格式) - * @param date 日期字符串 - */ - public static LocalDate getDate(String date) { - if(StringUtil.isNullOrEmpty(date)) { - return LocalDateTimeUtil.DEFAULT_DATE; - } - return LocalDate.parse(date); - } - /** - * 获取LocalDate - * @param year 年份 - * @param month 月份 - * @param day 天 - */ - public static LocalDate getDate(Integer year, Integer month, Integer day) { - return LocalDate.of(year, month, day); - } - /** - * LocalDate偏移指定天数 - * @param date LocalDate对象 - * @param addDay 偏移天数(可以为负数) - */ - public static LocalDate dateAddDay(LocalDate date, Long addDay) { - if(null==date) { - return LocalDateTimeUtil.DEFAULT_DATE; - } - return date.plusDays(addDay); - } - /** - * LocalDate偏移指定月数 - * @param date LocalDate对象 - * @param addMonth 偏移月数(可以为负数) - */ - public static LocalDate dateAddMonth(LocalDate date, Long addMonth) { - if(null==date) { - return LocalDateTimeUtil.DEFAULT_DATE; - } - return date.plusMonths(addMonth); - } - /** - * 获取当前月份第一天LocalDate - */ - public static LocalDate monthFirstDate() { - LocalDate toDay = nowDate(); - return LocalDate.of(toDay.getYear(), toDay.getMonthValue(), 1); - } - /** - * 获取当前月份最后一天LocalDate - */ - public static LocalDate monthLatestDate() { - //当前月第一天 - LocalDate monthFirst = monthFirstDate(); - //下个月第一天 - LocalDate nextMonthDay = dateAddMonth(monthFirst, 1L); - return LocalDateTimeUtil.dateAddDay(nextMonthDay, -1L); - } - //************************************** 【LocalDate】 ************************************** - - - - - - //************************************** 【时间戳处理】 ************************************** - /** - * 获取当前时间戳 - */ - public static Long nowTimeStamp() { - return Instant.now().toEpochMilli(); - } - /** - * 获取当前时间戳(字符串) - */ - public static String nowTimeStampStr() { - return String.valueOf(nowTimeStamp()); - } - /** - * 通过LocalDateTime对象获取时间戳 - * @param dateTime LocalDateTime对象 - */ - public static Timestamp getTimeStamp(LocalDateTime dateTime) { - if(null==dateTime) { - return Timestamp.valueOf(LocalDateTimeUtil.DEFAULT_DATETIME); - } - return Timestamp.valueOf(dateTime); - } - /** - * 通过时间字符串按指定格式获取时间戳 - * @param dateTime 时间字符串 - * @param format 时间格式 - */ - public static Timestamp getTimeStamp(String dateTime, String format) { - LocalDateTime localDateTime = LocalDateTimeUtil.getDateTime(dateTime, format); - return Timestamp.valueOf(localDateTime); - } - /** - * 通过时间字符串按“yyyy-MM-dd HH:mm:ss”格式获取时间戳 - * @param dateTime 时间字符串 - */ - public static Timestamp getTimeStamp(String dateTime) { - return LocalDateTimeUtil.getTimeStamp(dateTime, ConstantFactory.STR_DATE_FULL); - } - - - /** - * 通过Unix时间戳获取Timestamp - * @param timeStamp Unix时间戳 - */ - public static Timestamp getTimeStamp(Long timeStamp) { - return new Timestamp(timeStamp); - } - /** - * 通过时间戳,按指定格式,转成时间字符串 - * @param timeStamp 时间戳值 - * @param format 时间格式 - */ - public static String toFormatString(Long timeStamp, String format) { - LocalDateTime dateTime = LocalDateTimeUtil.getDateTime(timeStamp); - return LocalDateTimeUtil.toFormatString(dateTime, format); - } - /** - * 通过时间戳,按“yyyy-MM-dd HH:mm:ss”转成时间字符串 - * @param timeStamp 时间戳值 - */ - public static String toFormatString(Long timeStamp) { - return LocalDateTimeUtil.toFormatString(timeStamp, ConstantFactory.STR_DATE_FULL); - } - /** - * 通过时间戳,按“yyyy-MM-dd”转成时间字符串 - * @param timeStamp 时间戳值 - */ - public static String toDateString(Long timeStamp) { - return LocalDateTimeUtil.toFormatString(timeStamp, ConstantFactory.STR_DATE); - } - /** - * 通过时间戳,按“yyyy-MM-dd HH:mm:ss.SSS”转成时间字符串 - * @param timeStamp 时间戳值 - */ - public static String toFormatFullString(Long timeStamp) { - return LocalDateTimeUtil.toFormatString(timeStamp, ConstantFactory.STR_DATE_FULLMS); - } - /** - * 通过时间戳,按指定格式,转成时间字符串 - * @param timeStamp 时间戳值 - * @param format 时间格式 - */ - public static String toFormatString(Timestamp timeStamp, String format) { - LocalDateTime dateTime = LocalDateTimeUtil.getDateTime(timeStamp); - return LocalDateTimeUtil.toFormatString(dateTime, format); - } - /** - * 通过时间戳,按“yyyy-MM-dd HH:mm:ss”转成时间字符串 - * @param timeStamp 时间戳值 - */ - public static String toFormatString(Timestamp timeStamp) { - return LocalDateTimeUtil.toFormatString(timeStamp, ConstantFactory.STR_DATE_FULL); - } - /** - * 通过时间戳,按“yyyy-MM-dd”转成时间字符串 - * @param timeStamp 时间戳值 - */ - public static String toDateString(Timestamp timeStamp) { - return LocalDateTimeUtil.toFormatString(timeStamp, ConstantFactory.STR_DATE); - } - /** - * 通过时间戳,按“yyyy-MM-dd HH:mm:ss.SSS”转成时间字符串 - * @param timeStamp 时间戳值 - */ - public static String toFormatFullString(Timestamp timeStamp) { - return LocalDateTimeUtil.toFormatString(timeStamp, ConstantFactory.STR_DATE_FULLMS); - } - //************************************** 【时间戳处理】 ************************************** - - - public static String convertToDateFormat(String inputString) { - try { - // 将输入字符串解析为日期对象 - SimpleDateFormat inputFormat = new SimpleDateFormat("yyMMddHHmmss"); - Date date = inputFormat.parse(inputString); - - // 将日期对象格式化为目标日期字符串 - SimpleDateFormat outputFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - return outputFormat.format(date); - } catch (Exception e) { - return "Invalid Date"; - } - } - - public static String nowTimeBCD(String timeFormat) { - return LocalDateTimeUtil.time2BCD(LocalDateTimeUtil.nowDateTime(), timeFormat); - } - public static String nowTimeBCD() { - return LocalDateTimeUtil.time2BCD(LocalDateTimeUtil.nowDateTime()); - } - - public static String time2BCD(LocalDateTime nowDateTime) { - String timeStr = LocalDateTimeUtil.toFormatString(nowDateTime, ConstantFactory.STR_DATE_FULL); - return LocalDateTimeUtil.number2BCD(timeStr); - } - - public static String time2BCD(LocalDateTime nowDateTime, String timeFormat) { - String timeStr = LocalDateTimeUtil.toFormatString(nowDateTime, timeFormat); - return LocalDateTimeUtil.number2BCD(timeStr); - } - - public static String number2BCD(String numberStr) { - // 因为可能修改字符串的内容,所以构造StringBuffer - StringBuffer sb = new StringBuffer(numberStr); - // 一个字节包含两个4位的BCD码,byte数组中要包含偶数个BCD码 - // 一个十进制字符对应4位BCD码,所以如果十进制字符串的长度是奇数,要在前面补一个0使长度成为偶数 - if ((sb.length() % 2) != 0) { - sb.insert(0, '0'); - } - - // 两个十进制数字转换为BCD码后占用一个字节,所以存放BCD码的字节数等于十进制字符串长度的一半 - byte[] bcd = new byte[sb.length() / 2]; - for (int i = 0; i < sb.length();) { - if (!Character.isDigit(sb.charAt(i)) || !Character.isDigit(sb.charAt(i + 1))) { - throw new BusinessException("传入的十进制字符串包含非数字字符!"); - } - // 每个字节的构成:用两位十进制数字运算的和填充,高位十进制数字左移4位+低位十进制数字 - bcd[i/2] = (byte)((Character.digit(sb.charAt(i), 10) << 4) + Character.digit(sb.charAt(i + 1), 10)); - // 字符串的每两个字符取出来一起处理,所以此处i的自增长要加2,而不是加1 - i += 2; - } - StringBuffer sbResult = new StringBuffer(); - for (int i = 0; i < bcd.length; i++) { - sbResult.append(Integer.toBinaryString(bcd[i])); - } - return sbResult.toString(); - } -} \ No newline at end of file diff --git a/src/main/java/com/lunhan/xxx/common/util/LoggerUtil.java b/src/main/java/com/lunhan/xxx/common/util/LoggerUtil.java deleted file mode 100644 index 72e7a70..0000000 --- a/src/main/java/com/lunhan/xxx/common/util/LoggerUtil.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.lunhan.xxx.common.util; - -import com.lunhan.xxx.common.enums.ELogger; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class LoggerUtil { - public static <T> Logger get(Class<T> clazz) { - return LoggerFactory.getLogger(clazz); - } - - public static Logger get(ELogger logger) { - return LoggerFactory.getLogger(logger.getLogFileName()); - } -} diff --git a/src/main/java/com/lunhan/xxx/common/util/MailUtils.java b/src/main/java/com/lunhan/xxx/common/util/MailUtils.java deleted file mode 100644 index c2e65dc..0000000 --- a/src/main/java/com/lunhan/xxx/common/util/MailUtils.java +++ /dev/null @@ -1,81 +0,0 @@ -package com.lunhan.xxx.common.util; - -import org.springframework.beans.factory.annotation.Value; -import org.springframework.stereotype.Component; - -import javax.mail.*; -import javax.mail.internet.InternetAddress; -import javax.mail.internet.MimeMessage; -import java.util.Properties; - -/** - * 发邮件工具类 - */ -@Component -public final class MailUtils { - @Value("${spring:mail:username}") - private String USER; // 发件人邮箱地址 - @Value("${spring:mail:password}") - private String PASSWORD; // 如果是qq邮箱可以使户端授权码 - - /** - * 发送邮件 - * @param to 收件人邮箱 - * @param text 邮件正文 - * @param title 标题 - * mail: - * password: ennnntqxzijsdjdh - * username: 2413500195@qq.com - * host: smtp.qq.com - * default-encoding: UTF-8 - */ - public boolean sendMail(String to, String text, String title){ - try { - final Properties props = new Properties(); - props.put("mail.smtp.auth", "true"); - props.put("mail.smtp.host", "smtp.qq.com"); - - // 发件人的账号 - props.put("spring:mail:username", USER); - //发件人的密码 - props.put("spring:mail:password", PASSWORD); - - // 构建授权信息,用于进行SMTP进行身份验证 - Authenticator authenticator = new Authenticator() { - @Override - protected PasswordAuthentication getPasswordAuthentication() { - // 用户名、密码 - String userName = props.getProperty("spring:mail:username"); - String password = props.getProperty("spring:mail:password"); - return new PasswordAuthentication(userName, password); - } - }; - // 使用环境属性和授权信息,创建邮件会话 - Session mailSession = Session.getInstance(props, authenticator); - // 创建邮件消息 - MimeMessage message = new MimeMessage(mailSession); - // 设置发件人 - String username = props.getProperty("spring:mail:username"); - InternetAddress form = new InternetAddress(username); - message.setFrom(form); - - // 设置收件人 - InternetAddress toAddress = new InternetAddress(to); - message.setRecipient(Message.RecipientType.TO, toAddress); - - // 设置邮件标题 - message.setSubject(title); - - // 设置邮件的内容体 - message.setContent(text, "text/html;charset=UTF-8"); - // 发送邮件 - Transport.send(message); - return true; - }catch (Exception e){ - e.printStackTrace(); - } - return false; - } - -} - diff --git a/src/main/java/com/lunhan/xxx/common/util/MoneyUtil.java b/src/main/java/com/lunhan/xxx/common/util/MoneyUtil.java deleted file mode 100644 index 56b37fa..0000000 --- a/src/main/java/com/lunhan/xxx/common/util/MoneyUtil.java +++ /dev/null @@ -1,129 +0,0 @@ -package com.lunhan.xxx.common.util; - -import java.math.BigDecimal; - -/** - * 金钱计算工具类 - */ - -public class MoneyUtil { - /** - * 加法 - * @param v1 - * @param v2 - * @return - */ - public static BigDecimal add(BigDecimal v1,BigDecimal v2){ - if(v1 == null || "".equals(v1)){ - v1 = new BigDecimal(0); - }else if(v2 == null || "".equals(v2)){ - v2 = new BigDecimal(0); - } - return v1.add(v2).setScale(2, BigDecimal.ROUND_DOWN); - - } - - /** - * 减法 - * @param v1 - * @param v2 - * @return - */ - public static BigDecimal subtract(BigDecimal v1,BigDecimal v2){ - if(v1 == null || "".equals(v1)){ - v1 = new BigDecimal(0); - }else if(v2 == null || "".equals(v2)){ - v2 = new BigDecimal(0); - } - return v1.subtract(v2).setScale(2, BigDecimal.ROUND_DOWN); - } - - /** - * 除法 - * @param v1 - * @param v2 - * @return - */ - public static BigDecimal divide(BigDecimal v1,BigDecimal v2){ - if(v1 == null || "".equals(v1)){ - v1 = new BigDecimal(0); - }else if(v2 == null || "".equals(v2)){ - v2 = new BigDecimal(0); - } - // 暂时不算负数的情况 - int i = v2.compareTo(new BigDecimal(0)); - if(i == 0){ - return new BigDecimal(0); - } - return v1.divide(v2,2, BigDecimal.ROUND_DOWN); - } - - /** - * 乘法 - * @param v1 - * @param v2 - * @return - */ - - public static BigDecimal multiply(BigDecimal v1,BigDecimal v2){ - if(v1 == null || "".equals(v1)){ - v1 = new BigDecimal(0); - }else if(v2 == null || "".equals(v2)){ - v2 = new BigDecimal(0); - } - return v1.multiply(v2).setScale(2, BigDecimal.ROUND_DOWN); - } - - // 小于 - public static boolean lt(BigDecimal v1,BigDecimal v2) { - return v1.compareTo(v2) == -1; - } - - // 等于 - public static boolean eq(BigDecimal v1,BigDecimal v2) { - return v1.compareTo(v2) == 0; - } - - // 大于 - public static boolean gt(BigDecimal v1,BigDecimal v2) { - return v1.compareTo(v2) == 1; - } - - // 大于等于 - public static boolean ge(BigDecimal v1,BigDecimal v2) { - return v1.compareTo(v2) > -1; - } - - // 小于等于 - public static boolean le(BigDecimal v1,BigDecimal v2) { - return v1.compareTo(v2) < 1; - } - - /** - * 换算积分 - * @param money - * @return - */ - public static Integer integral(BigDecimal money){ - Integer integer=money.intValue()/10; - return integer; - } - -// public static void main(String [] args){ -// //加法 -// BigDecimal jia=add(BigDecimal.valueOf(5.66),BigDecimal.valueOf(3.347)); -// System.out.println("加法:"+jia); -// //减法 -// BigDecimal jian=subtract(BigDecimal.valueOf(5.66),BigDecimal.valueOf(3.347)); -// System.out.println("减法:"+jian); -// //乘法 -// BigDecimal chen=multiply(BigDecimal.valueOf(5.66),BigDecimal.valueOf(3.347)); -// System.out.println("乘法:"+chen); -// //除法 -// BigDecimal chu=divide(BigDecimal.valueOf(5.66),BigDecimal.valueOf(3.347)); -// System.out.println("积分:"+integral(BigDecimal.valueOf(101.88))); -// } - - - -} diff --git a/src/main/java/com/lunhan/xxx/common/util/NumericUtil.java b/src/main/java/com/lunhan/xxx/common/util/NumericUtil.java deleted file mode 100644 index c745cf5..0000000 --- a/src/main/java/com/lunhan/xxx/common/util/NumericUtil.java +++ /dev/null @@ -1,240 +0,0 @@ -package com.lunhan.xxx.common.util; - -import java.lang.reflect.Method; -import java.math.BigDecimal; -import java.text.DecimalFormat; - -/** - * 数值处理类 - * @author linliu - * @date 2018-12-28 - */ -public final class NumericUtil { - private NumericUtil() { - throw new IllegalStateException("Utility class"); - } - - /** - * 验证数值为空 - * @param num 传入数值 - */ - public static Boolean isNullOrEmpty(Number num) { - return num==null || num.doubleValue()==0; - } - - /** - * 验证数值非空 - * @param num 传入数值 - */ - public static Boolean isNotNullOrEmpty(Number num) { - return !NumericUtil.isNullOrEmpty(num); - } - - /** - * 判断传入值,是否在传入数组中 - * @param num 比较值 - * @param array 范围数组 - */ - public static Boolean includeIn(Number num, Number... array) { - return ListUtil.toList(array).contains(num); - } - - /** - * 字符串枚举值转成枚举对象 - * @author linliu - * @date 2018-12-24 - * @param enumType 枚举类型 - * @param value 枚举值 - * @param <T> 枚举类型 - * @return 枚举对象 - */ - public static <T extends Enum<T>> T parseEnum(Class<T> enumType, Integer value) { - if(null == value) { - return null; - } - - T result = null; - try { - T[] values = enumType.getEnumConstants(); - Method getValue = enumType.getMethod("getValue"); - - for (T e : values) { - if(getValue.invoke(e).equals(value)) { - result = e; - break; - } - } - } catch (Exception e) { - //TODO log - } - return result; - } - - /** - * 判断枚举是否申明了传入枚举值 - * @author linliu - * @date 2018-12-24 - * @param enumType 枚举类型 - * @param value 枚举值 - * @param <T> 枚举类型 - * @return 是否包含 - */ - public static <T extends Enum<T>> boolean isEnum(Class<T> enumType, Integer value) { - return (null != NumericUtil.parseEnum(enumType, value)); - } - - /** - * 尝试转换为 Integer - * @param value 传入值 - */ - public static Integer tryParseInt(Object value) { - return NumericUtil.tryParseInt(value, Integer.MIN_VALUE); - } - - /** - * 尝试转换为 Long - * @param value 传入值 - */ - public static Long tryParseLong(Object value) { - return NumericUtil.tryParseLong(value, Long.MIN_VALUE); - } - - /** - * 尝试转换为 Double - * @param value 传入值 - */ - public static Double tryParseDouble(Object value) { - return NumericUtil.tryParseDouble(value, Double.valueOf(String.valueOf(Long.MIN_VALUE))); - } - - /** - * 尝试转换为 BigDecimal - * @param value 传入值 - */ - public static BigDecimal tryParseBigDecimal(Object value) { - return NumericUtil.tryParseBigDecimal(value, new BigDecimal(String.valueOf(Long.MIN_VALUE))); - } - - /** - * 输出数值补“0”,不输出小数部分(如果传入数值位数不足传入最小位数,则在数值前补“0”,否则直接输出数值的字符串) - * @param value 传入数值 - * @param minLength 最小位数 - */ - public static String toDString(Number value, Integer minLength) { - String result = toNumberString(value, 0); - StringBuilder sb = new StringBuilder(); - while (result.length()+sb.length() < minLength) { - sb.append("0"); - } - sb.append(result); - return sb.toString(); - } - - /** - * 判断传入数值大小是否在“min”和“max”之间(不包含包含端值,即包含最大最小值) - * @param num 比较的数值 - * @param min 最小值 - * @param max 最大值 - */ - public static Boolean isInRange(Number num, Number min, Number max) { - BigDecimal dnum = tryParseBigDecimal(num); - BigDecimal dmin = tryParseBigDecimal(min); - BigDecimal dmax = tryParseBigDecimal(max); - return dnum.compareTo(dmin)>0 && dnum.compareTo(dmax)<0; - } - - /** - * 判断传入数值大小是否在“min”和“max”之间(包含端值,即包含最大最小值) - * @param num 比较的数值 - * @param min 最小值 - * @param max 最大值 - */ - public static Boolean isInRangeInclude(Number num, Number min, Number max) { - BigDecimal dnum = tryParseBigDecimal(num); - BigDecimal dmin = tryParseBigDecimal(min); - BigDecimal dmax = tryParseBigDecimal(max); - return dnum.compareTo(dmin)>-1 && dnum.compareTo(dmax)<1; - } - - /** - * 格式化输出小数(最多“length”位小数,如果小数部分某位后面全是0,则不展示) - * @param num 数字 - * @param length 最多展示的小数位数 - */ - public static String toNumberString(Number num, Integer length) { - length = tryParseInt(length); - StringBuilder sbFormat = new StringBuilder("#0"); - if(length.compareTo(0) > 0) { - sbFormat.append("."); - for(int i=0; i<length; i++) { - sbFormat.append("#"); - } - } - DecimalFormat df = new DecimalFormat(sbFormat.toString()); - return df.format(num); - } - - /** - * 尝试转换为 Integer - * @param value 传入值 - * @param defaultValue 传入值为空,或者转换失败时,返回的默认值 - */ - public static Integer tryParseInt(Object value, Integer defaultValue) { - if(null==value) { - return defaultValue; - } - try { - return Integer.parseInt(String.valueOf(value)); - } catch (Exception e) { - return defaultValue; - } - } - - /** - * 尝试转换为 Long - * @param value 传入值 - * @param defaultValue 传入值为空,或者转换失败时,返回的默认值 - */ - public static Long tryParseLong(Object value, Long defaultValue) { - if(null==value) { - return defaultValue; - } - try { - return Long.parseLong(String.valueOf(value)); - } catch (Exception e) { - return defaultValue; - } - } - - /** - * 尝试转换为 Double - * @param value 传入值 - * @param defaultValue 传入值为空,或者转换失败时,返回的默认值 - */ - public static Double tryParseDouble(Object value, Double defaultValue) { - if(null==value) { - return defaultValue; - } - try { - return Double.parseDouble(String.valueOf(value)); - } catch (Exception e) { - return defaultValue; - } - } - - /** - * 尝试转换为 BigDecimal - * @param value 传入值 - * @param defaultValue 传入值为空,或者转换失败时,返回的默认值 - */ - public static BigDecimal tryParseBigDecimal(Object value, BigDecimal defaultValue) { - if(null==value) { - return defaultValue; - } - try { - return new BigDecimal(String.valueOf(value)); - } catch (Exception e) { - return defaultValue; - } - } -} \ No newline at end of file diff --git a/src/main/java/com/lunhan/xxx/common/util/OrderUtil.java b/src/main/java/com/lunhan/xxx/common/util/OrderUtil.java deleted file mode 100644 index 080d163..0000000 --- a/src/main/java/com/lunhan/xxx/common/util/OrderUtil.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.lunhan.xxx.common.util; - -public class OrderUtil { - - public static String getOrderNo(String prefix) { - SnowFlake idWorker = new SnowFlake(7, 7); - long id = idWorker.nextId(); - String rechargeOrder = prefix + id; - return rechargeOrder; - } - - -} diff --git a/src/main/java/com/lunhan/xxx/common/util/ParameterUtil.java b/src/main/java/com/lunhan/xxx/common/util/ParameterUtil.java deleted file mode 100644 index 6305256..0000000 --- a/src/main/java/com/lunhan/xxx/common/util/ParameterUtil.java +++ /dev/null @@ -1,69 +0,0 @@ -package com.lunhan.xxx.common.util; - -import com.lunhan.xxx.common.ConstantFactory; -import com.lunhan.xxx.common.model.Tuple; - -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; - -public class ParameterUtil { - public static String named(String name) { - return "参数“" + name + "”"; - } - - public static String sqlASC(String name) { - return name + ConstantFactory.SQL_ASC; - } - - public static String sqlDESC(String name) { - return name + ConstantFactory.SQL_DESC; - } - - public static String sqlLikeValue(String value) { - return "%" + value + "%"; - } - - public static String dealNull(String parameter) { - if(StringUtil.isNullOrEmpty(parameter)) { - return ""; - } - return parameter.trim().replaceAll("\\t", "").replaceAll("\\r", "").replaceAll("\\n", ""); - } - - public static String dealNullStr(Object parameter, String defaultValue) { - if(Objects.isNull(parameter) || StringUtil.isNullOrEmpty(parameter.toString())) { - return defaultValue; - } - return parameter.toString(); - } - - public static String dealNullStr(Object parameter) { - return ParameterUtil.dealNullStr(parameter, ""); - } - - public static <T> List<T> dealNull(List<T> list) { - if(null == list) { - return new ArrayList<>(); - } - return list; - } - - public static String dealNotStr(String parameter) { - if(null == parameter) { - return parameter; - } - return parameter.trim().replaceAll("\\t", "").replaceAll("\\r", "").replaceAll("\\n", ""); - } - - public static Tuple<String, String> getTimeRange(String timeRange) { - if (StringUtil.isNullOrEmpty(timeRange)) { - return new Tuple<>("", ""); - } - String[] list = StringUtil.split(timeRange, ConstantFactory.STR_TIME_RANGE); - if (list.length != 2) { - return new Tuple<>("", ""); - } - return new Tuple<>(list[0], list[1]); - } -} diff --git a/src/main/java/com/lunhan/xxx/common/util/PinYinUtil.java b/src/main/java/com/lunhan/xxx/common/util/PinYinUtil.java deleted file mode 100644 index a5a6f4b..0000000 --- a/src/main/java/com/lunhan/xxx/common/util/PinYinUtil.java +++ /dev/null @@ -1,88 +0,0 @@ -package com.lunhan.xxx.common.util; - -import net.sourceforge.pinyin4j.PinyinHelper; -import net.sourceforge.pinyin4j.format.HanyuPinyinCaseType; -import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat; -import net.sourceforge.pinyin4j.format.HanyuPinyinToneType; -import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination; - -public final class PinYinUtil { - private PinYinUtil() { - throw new IllegalStateException("Utility class"); - } - - /** - * 获取中文全拼 - * - * @param name 需要转换的中文 - * @return 全拼结果 - **/ - public static String getFullPinyin(String name) { - // 创建格式化对象 - HanyuPinyinOutputFormat outputFormat = new HanyuPinyinOutputFormat(); - //设置大小写格式 - outputFormat.setCaseType(HanyuPinyinCaseType.LOWERCASE); - //设置声调格式 - outputFormat.setToneType(HanyuPinyinToneType.WITHOUT_TONE); - // 放置输入结果 - StringBuilder result = new StringBuilder(); - // 字符数组 - char[] charArray = name.toCharArray(); - // 遍历字符 - for (char c : charArray) { - // 中文会被变成全拼,非中文会被直接拼接在结果字符串中 - if (Character.toString(c).matches("[\\u4E00-\\u9FA5]+")) { - String[] pinyinArray = new String[0]; - try { - pinyinArray = PinyinHelper.toHanyuPinyinStringArray(c, outputFormat); - } catch (BadHanyuPinyinOutputFormatCombination badHanyuPinyinOutputFormatCombination) { - badHanyuPinyinOutputFormatCombination.printStackTrace(); - } - if (pinyinArray != null) { - result.append(pinyinArray[0]); - } - } else { - result.append(c); - } - } - return result.toString(); - } - - /** - * 获取中文首字母 - * - * @param name 需要转换的中文 - * @return 首字母结果 - **/ - public static String getPinyinInitial(String name) { - // 创建格式化对象 - HanyuPinyinOutputFormat outputFormat = new HanyuPinyinOutputFormat(); - //设置大小写格式 - outputFormat.setCaseType(HanyuPinyinCaseType.UPPERCASE); - //设置声调格式 - outputFormat.setToneType(HanyuPinyinToneType.WITHOUT_TONE); - // 放置输入结果 - StringBuilder result = new StringBuilder(); - // 字符数组 - char[] charArray = name.toCharArray(); - // 遍历字符 - for (char c : charArray) { - // 中文会被变成拼音首字母,非中文会被直接拼接在结果字符串中 - if (Character.toString(c).matches("[\\u4E00-\\u9FA5]+")) { - String[] pinyinArray = new String[0]; - try { - pinyinArray = PinyinHelper.toHanyuPinyinStringArray(c, outputFormat); - } catch (BadHanyuPinyinOutputFormatCombination badHanyuPinyinOutputFormatCombination) { - badHanyuPinyinOutputFormatCombination.printStackTrace(); - } - if (pinyinArray != null) { - result.append(pinyinArray[0].charAt(0)); - } - } else { - result.append(c); - } - } - return result.toString(); - } - -} diff --git a/src/main/java/com/lunhan/xxx/common/util/RandVerifyCode.java b/src/main/java/com/lunhan/xxx/common/util/RandVerifyCode.java deleted file mode 100644 index 431c933..0000000 --- a/src/main/java/com/lunhan/xxx/common/util/RandVerifyCode.java +++ /dev/null @@ -1,106 +0,0 @@ -package com.lunhan.xxx.common.util; - -import java.util.Random; - -/** - * 随机验证码 工具类 - */ -public final class RandVerifyCode { - public static final Integer USE_ZERO = 1; - public static final Integer USE_O = 2; - public static final Integer USE_ONE = 1; - public static final Integer USE_I = 2; - - static char[] arrayCharCode = new char[] { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' }; - static char[] arrayComplexCode = new char[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' }; - - private RandVerifyCode() { - throw new IllegalStateException("Utility class"); - } - - /** - * 生成随机数字 - * @param length 生成长度 - */ - public static String numberCode(int length) { - try { - Thread.sleep(Long.valueOf("1")); - } catch (Exception e) { - e.getStackTrace(); - } - Random random = new Random(CalendarUtil.nowTimestamp()); - - StringBuilder sb = new StringBuilder(); - for (int i = 0; i < length; i++) { - try { - Thread.sleep(Long.valueOf("1")); - } catch (Exception e) {} - sb.append(random.nextInt(Integer.valueOf("10"))); - } - return sb.toString(); - } - - /** - * 生成随机字母与数字 - * @param length 生成长度 - */ - public static String complexCode(int length) { - return complexCode(length, 2, 2); - } - - /** - * 生成随机字母与数字 - * @param length 生成长度 - * @param zeroOrO 为避免视觉歧义,数字零“0”和字母欧“O”如何取舍。取数字零=1,取字母欧=2 - * @param oneOrI 为避免视觉歧义,数字一“1”和字母艾“I”如何取舍。取数字一=1,取字母艾=2 - */ - public static String complexCode(int length, Integer zeroOrO, Integer oneOrI) { - int n = arrayComplexCode.length; - try { - Thread.sleep(Long.valueOf("1")); - } catch (Exception e) { - e.getStackTrace(); - } - Random random = new Random(CalendarUtil.nowTimestamp()); - - StringBuilder sb = new StringBuilder(); - for (int i = 0; i < length; i++) { - int rnd = random.nextInt(n); - char code = arrayComplexCode[rnd]; - if('O'==code && USE_ZERO.equals(zeroOrO)) { - code = '0'; - } else if('0'==code && USE_O.equals(zeroOrO)) { - code = 'O'; - } - - if('I'==code && USE_ONE.equals(oneOrI)) { - code = '1'; - } else if('1'==code && USE_I.equals(oneOrI)) { - code = 'I'; - } - sb.append(code); - } - return sb.toString(); - } - - /** - * 生成随机纯字母随机数 - * @param length 生成长度 - */ - public static String charCode(int length) { - int n = arrayCharCode.length; - try { - Thread.sleep(Long.valueOf("1")); - } catch (Exception e) { - e.getStackTrace(); - } - Random random = new Random(CalendarUtil.nowTimestamp()); - - StringBuilder sb = new StringBuilder(); - for (int i = 0; i < length; i++) { - int rnd = random.nextInt(n); - sb.append(arrayCharCode[rnd]); - } - return sb.toString(); - } -} \ No newline at end of file diff --git a/src/main/java/com/lunhan/xxx/common/util/SM2Util.java b/src/main/java/com/lunhan/xxx/common/util/SM2Util.java deleted file mode 100644 index 59d3472..0000000 --- a/src/main/java/com/lunhan/xxx/common/util/SM2Util.java +++ /dev/null @@ -1,162 +0,0 @@ -package com.lunhan.xxx.common.util; - -import org.bouncycastle.crypto.CipherParameters; -import org.bouncycastle.crypto.params.ECPrivateKeyParameters; -import org.bouncycastle.crypto.params.ECPublicKeyParameters; -import org.bouncycastle.crypto.params.ParametersWithRandom; -import org.bouncycastle.crypto.signers.SM2Signer; -import org.bouncycastle.jcajce.provider.asymmetric.util.ECUtil; -import org.bouncycastle.jce.provider.BouncyCastleProvider; -import org.springframework.util.Base64Utils; - -import java.nio.charset.Charset; -import java.nio.charset.StandardCharsets; -import java.security.*; -import java.security.spec.*; - -public class SM2Util { - /** - * 要生成的EC域参数的标准名称 - */ - private static final String STANDARD_NAME = "sm2p256v1"; - /** - * 算法 - */ - private static final String ALGORITHM = "EC"; - /** - * 字符编码 - */ - private static final Charset CHARSET = StandardCharsets.UTF_8; - - /** - * 生成密钥对 - * - * @return 密钥对 - */ - private static KeyPair generateSm2KeyPair() throws NoSuchAlgorithmException, InvalidAlgorithmParameterException { - //使用标准名称创建EC参数生成的参数规范 - final ECGenParameterSpec sm2Spec = new ECGenParameterSpec(STANDARD_NAME); - - // 获取一个椭圆曲线类型的密钥对生成器 - final KeyPairGenerator kpg = KeyPairGenerator.getInstance(ALGORITHM, new BouncyCastleProvider()); - - kpg.initialize(sm2Spec, new SecureRandom()); - // 通过密钥生成器生成密钥对 - return kpg.generateKeyPair(); - } - - /** - * 生成密钥对 - * - * @return 密钥对 - */ - public static String[] genKeyPair() throws InvalidAlgorithmParameterException, NoSuchAlgorithmException { - KeyPair keyPair = generateSm2KeyPair(); - PrivateKey privateKey = keyPair.getPrivate(); - PublicKey publicKey = keyPair.getPublic(); - return new String[]{ - Base64Utils.encodeToString(privateKey.getEncoded()), - Base64Utils.encodeToString(publicKey.getEncoded()) - }; - } - - /** - * 私钥转换为 {@link ECPrivateKeyParameters} - * - * @param key 私钥 - * @return 私钥{@link ECPrivateKeyParameters} - */ - private static ECPrivateKeyParameters privateKeyToParams(byte[] key) throws InvalidKeyException, InvalidKeySpecException, NoSuchAlgorithmException { - KeySpec keySpec = new PKCS8EncodedKeySpec(key); - PrivateKey privateKey = getKeyFactory().generatePrivate(keySpec); - ; - return (ECPrivateKeyParameters) ECUtil.generatePrivateKeyParameter(privateKey); - } - - /** - * 公钥转换为 {@link ECPublicKeyParameters} - * - * @param key 公钥 - * @return 公钥{@link ECPublicKeyParameters} - */ - private static ECPublicKeyParameters publicKeyToParams(byte[] key) throws InvalidKeyException, InvalidKeySpecException, NoSuchAlgorithmException { - KeySpec keySpec = new X509EncodedKeySpec(key); - PublicKey publicKey = getKeyFactory().generatePublic(keySpec); - return (ECPublicKeyParameters) ECUtil.generatePublicKeyParameter(publicKey); - } - - /** - * 获取{@link KeyFactory} - * - * @return {@link KeyFactory} - */ - private static KeyFactory getKeyFactory() throws NoSuchAlgorithmException { - final Provider provider = new BouncyCastleProvider(); - return KeyFactory.getInstance(ALGORITHM, provider); - } - - /** - * 签名 - * - * @param content 原始串 - * @param priKey 私钥 - * @return 签名 - */ - public static String sign(String content, String priKey) throws Exception { - byte[] data = content.getBytes(CHARSET); - byte[] privateKey = Base64Utils.decode(priKey.getBytes(CHARSET)); - - SM2Signer signer = new SM2Signer(); - CipherParameters param = new ParametersWithRandom(privateKeyToParams(privateKey)); - signer.init(true, param); - signer.update(data, 0, data.length); - - byte[] buffer = signer.generateSignature(); - - return Base64Utils.encodeToString(buffer); - } - - /** - * 用公钥检验数字签名的合法性 - * - * @param content 原始串 - * @param sign 待验证签名 - * @param publicKey 私钥 - * @return 是否验证通过 - */ - public static boolean verify(String content, String sign, String publicKey) throws Exception { - byte[] data = content.getBytes(CHARSET); - byte[] signBuffer = Base64Utils.decodeFromString(sign); - byte[] keyBuffer = Base64Utils.decodeFromString(publicKey); - - SM2Signer signer = new SM2Signer(); - CipherParameters param = publicKeyToParams(keyBuffer); - signer.init(false, param); - signer.update(data, 0, data.length); - return signer.verifySignature(signBuffer); - } - - - -// public static void main(String[] args) { -// Security.addProvider(new BouncyCastleProvider()); -// -// try { -// // 生成密钥对 -// String[] keyPair = SM2Util.genKeyPair(); -// String privateKey = keyPair[0]; -// String publicKey = keyPair[1]; -// -// // 对消息进行签名 -// String message = "你好,世界!"; -// String signature = SM2Util.sign(message, privateKey); -// System.out.println("生成的签名: " + signature); -// -// // 验证签名 -// boolean isValid = SM2Util.verify(message, signature, publicKey); -// System.out.println("签名验证结果: " + isValid); -// } catch (Exception e) { -// e.printStackTrace(); -// } -// } -} diff --git a/src/main/java/com/lunhan/xxx/common/util/SM4Util.java b/src/main/java/com/lunhan/xxx/common/util/SM4Util.java deleted file mode 100644 index f30265d..0000000 --- a/src/main/java/com/lunhan/xxx/common/util/SM4Util.java +++ /dev/null @@ -1,93 +0,0 @@ -package com.lunhan.xxx.common.util; - - -import org.springframework.util.Base64Utils; - -import javax.crypto.Cipher; -import javax.crypto.spec.IvParameterSpec; -import javax.crypto.spec.SecretKeySpec; -import java.nio.charset.StandardCharsets; -import java.util.Random; - -public class SM4Util { - /** - * 算法名字 - */ - private static final String NAME = "SM4"; - /** - * 加密模式以及短快填充方式 - */ - private static final String ALGORITHM = "SM4/CBC/PKCS5Padding"; - /** - * 加密使用的初始向量 - */ - private static final String IV = "0000000000000000"; - /** - * 密钥长度(128-32位16进制;256-64位16进制) - */ - private static final int KEY_SIZE = 16; - - private static final String ALL_STR = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; - - public static String generateKey() { - Random random = new Random(); - StringBuffer sb = new StringBuffer(); - for (int i = 0; i < KEY_SIZE; i++) { - int number = random.nextInt(ALL_STR.length()); - sb.append(ALL_STR.charAt(number)); - } - return sb.toString(); - } - - /** - * 使用指定的加密算法和密钥对给定的字节数组进行加密 - * - * @param content 待加密的原始字符串 - * @param key 密钥(注意必须是128bits,即16个字节) - * @return 加密后的字符串 - * @throws Exception 如果加密时发生错误,则抛出异常 - */ - public static String encode(String content, String key) throws Exception { - try { - byte[] inputByte = content.getBytes(StandardCharsets.UTF_8); - byte[] keyBuffer = key.getBytes(StandardCharsets.UTF_8); - - // 获取加密实例 - Cipher c = Cipher.getInstance(ALGORITHM); - // 根据密钥的字节数组创建 SecretKeySpec - SecretKeySpec secretKeySpec = new SecretKeySpec(keyBuffer, NAME); - // 创建 IvParameterSpec 对象,使用默认向量和字符集 - IvParameterSpec ivParameterSpec = new IvParameterSpec(IV.getBytes(StandardCharsets.UTF_8)); - // 初始化加密实例 - c.init(Cipher.ENCRYPT_MODE, secretKeySpec, ivParameterSpec); - // 返回加密后的字节数组 - byte[] buffer = c.doFinal(inputByte); - return Base64Utils.encodeToString(buffer); - } catch (Exception e) { - throw new Exception("加密失败: " + e, e); - } - } - - /** - * 解密 - * - * @param content 待解密字符串 - * @param key 密钥(注意必须是128bits,即16个字节) - * @return 解密后的原始字符串 - * @throws Exception 如果解密时发生错误,则抛出异常 - */ - public static String decode(String content, String key) throws Exception { - try { - byte[] inputBytes = Base64Utils.decode(content.getBytes(StandardCharsets.UTF_8)); - byte[] keyBuffer = key.getBytes(StandardCharsets.UTF_8); - Cipher cipher = Cipher.getInstance(ALGORITHM); - SecretKeySpec secretKeySpec = new SecretKeySpec(keyBuffer, NAME); - IvParameterSpec ivParameterSpec = new IvParameterSpec(IV.getBytes(StandardCharsets.UTF_8)); - cipher.init(Cipher.DECRYPT_MODE, secretKeySpec, ivParameterSpec); - byte[] buffer = cipher.doFinal(inputBytes); - return new String(buffer, StandardCharsets.UTF_8); - } catch (Exception e) { - throw new Exception("解密失败: " + e, e); - } - } -} diff --git a/src/main/java/com/lunhan/xxx/common/util/SerializeUtil.java b/src/main/java/com/lunhan/xxx/common/util/SerializeUtil.java deleted file mode 100644 index 3a40038..0000000 --- a/src/main/java/com/lunhan/xxx/common/util/SerializeUtil.java +++ /dev/null @@ -1,282 +0,0 @@ -package com.lunhan.xxx.common.util; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.databind.*; -import com.fasterxml.jackson.databind.module.SimpleModule; -import com.fasterxml.jackson.dataformat.xml.PackageVersion; -import com.fasterxml.jackson.dataformat.xml.XmlMapper; -import com.google.gson.Gson; -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; -import com.lunhan.xxx.common.serializer.*; -import com.lunhan.xxx.common.serializer.deserializer.*; - -import java.io.IOException; -import java.sql.Timestamp; -import java.text.SimpleDateFormat; -import java.time.LocalDate; -import java.time.LocalDateTime; -import java.util.*; - -/** - * json/XML处理类 - * @author linliu - * @date 2018-12-28 - */ -public final class SerializeUtil { - private SerializeUtil() { - throw new IllegalStateException("Utility class"); - } - - //region 字符串常量 - private static final String TITLE = "SerializeUtil"; - //endregion - - private static final ObjectMapper JSON_MAPPER = new ObjectMapper(); - private static final XmlMapper XML_MAPPER = new XmlMapper(); - - static { - //忽略字段大小写 - XML_MAPPER.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES, true); - //忽略字段数量不一致 - XML_MAPPER.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - - //默认json序列化设置 - SerializeUtil.initSerializationConfigure(JSON_MAPPER); - } - /** - * 默认json序列化设置 - * @param JSON_MAPPER mapper实例 - */ - private static void initSerializationConfigure(ObjectMapper JSON_MAPPER) { - //忽略字段大小写 - JSON_MAPPER.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES, true); - - //此配置反序列化的时候如果多了属性, 不抛出异常。不设置这个json字符串只能少属性,不能多属性,否者会抛异常 - JSON_MAPPER.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - - //如果是空对象的时候,不抛异常 - JSON_MAPPER.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false); - - //******************************* 处理日期类型序列化和反序列化 ******************************* - - //取消时间的转化格式,默认是时间戳,可以取消,同时需要设置要表现的时间格式 - JSON_MAPPER.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); - - SimpleModule serializerModule = new SimpleModule("CQDateTimeSerializer", PackageVersion.VERSION); - - serializerModule.addSerializer(Date.class, new CQDateSerializer()); - serializerModule.addDeserializer(Date.class, new CQDateDeSerializer()); - - serializerModule.addSerializer(Calendar.class, new CQCalendarSerializer()); - serializerModule.addDeserializer(Calendar.class, new CQCalendarDeSerializer()); - - serializerModule.addSerializer(LocalDate.class, new CQLocalDateSerializer()); - serializerModule.addDeserializer(LocalDate.class, new CQLocalDateDeSerializer()); - - serializerModule.addSerializer(LocalDateTime.class, new CQLocalDateTimeSerializer()); - serializerModule.addDeserializer(LocalDateTime.class, new CQLocalDateTimeDeSerializer()); - - serializerModule.addSerializer(Timestamp.class, new CQTimestampSerializer()); - serializerModule.addDeserializer(Timestamp.class, new CQTimestampDeSerializer()); - - JSON_MAPPER.registerModule(serializerModule); - //******************************* 处理日期类型序列化和反序列化 ******************************* - - /* - - //序列化的时候序列对象的所有属性 - JSON_MAPPER.setSerializationInclusion(JsonInclude.Include.ALWAYS); - - */ - } - - /** - * json字符串转 T 类型实体 - * @param json json字符串 - * @param clazz 实体类型 - * @param <T> 实体类型 - */ - public static <T> T toObject(String json, Class<T> clazz) { - if(StringUtil.isNullOrEmpty(json)){ - return null; - } - try { - if(Objects.equals(clazz, JsonObject.class)) { - JsonParser jsonParser = new JsonParser(); - return (T)jsonParser.parse(json).getAsJsonObject(); - } - return JSON_MAPPER.readValue(json, clazz); - } catch (IOException e) { - //TODO log - throw new RuntimeException(e); - } - } - - /** - * json字符串转 List→T 类型集合 - * @param json json字符串 - * @param clazz 实体类型 - * @param <T> 实体类型 - */ - public static <T> List<T> toListObject(String json, Class<T> clazz){ - if(StringUtil.isNullOrEmpty(json)){ - return new ArrayList<>(); - } - try{ - //这种返回的是List<LinkedMap> - //return JSON_MAPPER.readValue(json, new TypeReference<List<T>>() {}); - return SerializeUtil.toObject(json, List.class, clazz); - } catch (Exception e) { - //TODO log - throw new RuntimeException(e); - } - } - - /** - * json字符串转 T 类型实体 - * @param json json字符串 - * @param genericClass 实体类型 - * @param clazz 实体类型 - * @param <T> 实体类型 - */ - public static <T> T toObject(String json, Class<?> genericClass, Class<?> clazz) { - if(StringUtil.isNullOrEmpty(json)){ - return null; - } - try { - JavaType type = JSON_MAPPER.getTypeFactory().constructParametricType(genericClass, clazz); - return JSON_MAPPER.readValue(json, type); - } catch (IOException e) { - //TODO log - throw new RuntimeException(e); - } - } - - public static String toJson(Object obj) { - if(obj==null){ - return null; - } - try { - if(obj instanceof JsonObject || obj instanceof JsonArray) { - return obj.toString(); - } else { - return JSON_MAPPER.writeValueAsString(obj); - } - } catch (Exception e) { - //TODO log - throw new RuntimeException(e); - } - } - public static String toJsonWithoutNull(Object obj) { - if(obj==null){ - return null; - } - try { - if (obj instanceof JsonObject || obj instanceof JsonArray) { - return obj.toString(); - } else { - ObjectMapper mapper = new ObjectMapper(); - //默认json序列化设置 - SerializeUtil.initSerializationConfigure(mapper); - mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); - return mapper.writeValueAsString(obj); - } - } catch (Exception e) { - //TODO log - throw new RuntimeException(e); - } - } - - public static String toCSharpJson(Object obj) { - if(obj==null){ - return null; - } - try { - if (obj instanceof JsonObject || obj instanceof JsonArray) { - return obj.toString(); - } else { - ObjectMapper mapper = new ObjectMapper(); - //默认json序列化设置 - SerializeUtil.initSerializationConfigure(mapper); - // deprecated mapper.setPropertyNamingStrategy(PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES); - mapper.setPropertyNamingStrategy(PropertyNamingStrategy.UPPER_CAMEL_CASE); - return mapper.writeValueAsString(obj); - } - } catch (Exception e) { - //TODO log - throw new RuntimeException(e); - } - } - - public static String toJson(Object obj, String dateFormat) { - if(obj==null){ - return null; - } - try { - if (obj instanceof JsonObject || obj instanceof JsonArray) { - return obj.toString(); - } else { - ObjectMapper mapper = new ObjectMapper(); - //默认json序列化设置 - SerializeUtil.initSerializationConfigure(mapper); - mapper.setDateFormat(new SimpleDateFormat(dateFormat)); - return mapper.writeValueAsString(obj); - } - } catch (Exception e) { - //TODO log - throw new RuntimeException(e); - } - } - - public static <T> T fromXml(String xml, Class<T> clazz) { - if(StringUtil.isNullOrEmpty(xml)){ - return null; - } - try { - return XML_MAPPER.readValue(xml, clazz); - } catch (Exception e) { - //TODO log - throw new RuntimeException(e); - } - } - - public static <T> T fromXml(String xml, Class<?> genericClass, Class<?> clazz) { - if(StringUtil.isNullOrEmpty(xml)){ - return null; - } - try { - JavaType type = XML_MAPPER.getTypeFactory().constructParametricType(genericClass, clazz); - return XML_MAPPER.readValue(xml, type); - } catch (Exception e) { - //TODO log - throw new RuntimeException(e); - } - } - - public static String toXml(Object obj) { - if(obj == null){ - return ""; - } - try{ - return XML_MAPPER.writeValueAsString(obj); - } catch (Exception e) { - //TODO log - throw new RuntimeException(e); - } - } - - public static JsonObject toJSONObject(Object obj) { - if(null==obj) { - return null; - } - try { - String json = new Gson().toJson(obj); - return new JsonParser().parse(json).getAsJsonObject(); - } catch (Exception e) { - //TODO log - throw new RuntimeException(e); - } - } -} \ No newline at end of file diff --git a/src/main/java/com/lunhan/xxx/common/util/SnowFlake.java b/src/main/java/com/lunhan/xxx/common/util/SnowFlake.java deleted file mode 100644 index 4649623..0000000 --- a/src/main/java/com/lunhan/xxx/common/util/SnowFlake.java +++ /dev/null @@ -1,198 +0,0 @@ -package com.lunhan.xxx.common.util; - - -/** - * - * - * 生成唯一id - * - * - * Twitter_Snowflake<br> - * SnowFlake的结构如下(每部分用-分开):<br> - * 0 - 0000000000 0000000000 0000000000 0000000000 0 - 00000 - 00000 - 000000000000 <br> - * 1位标识,由于long基本类型在Java中是带符号的,最高位是符号位,正数是0,负数是1,所以id一般是正数,最高位是0<br> - * 41位时间截(毫秒级),注意,41位时间截不是存储当前时间的时间截,而是存储时间截的差值(当前时间截 - 开始时间截) - * 得到的值),这里的的开始时间截,一般是我们的id生成器开始使用的时间,由我们程序来指定的(如下下面程序IdWorker类的startTime属性)。41位的时间截,可以使用69年,年T = (1L << 41) / (1000L * 60 * 60 * 24 * 365) = 69<br> - * 10位的数据机器位,可以部署在1024个节点,包括5位datacenterId和5位workerId<br> - * 12位序列,毫秒内的计数,12位的计数顺序号支持每个节点每毫秒(同一机器,同一时间截)产生4096个ID序号<br> - * 加起来刚好64位,为一个Long型。<br> - * SnowFlake的优点是,整体上按照时间自增排序,并且整个分布式系统内不会产生ID碰撞(由数据中心ID和机器ID作区分),并且效率较高,经测试,SnowFlake每秒能够产生26万ID左右。 - * - * @author Lucifer - */ -public class SnowFlake { - - // ==============================Fields=========================================== - /** - * 开始时间截 (2018-07-03) - */ - - private final long twepoch = 1530607760000L; - - /** - * 机器id所占的位数 - */ - private final long workerIdBits = 5L; - - /** - * 数据标识id所占的位数 - */ - private final long datacenterIdBits = 5L; - - /** - * 支持的最大机器id,结果是31 (这个移位算法可以很快的计算出几位二进制数所能表示的最大十进制数) - */ - private final long maxWorkerId = -1L ^ (-1L << workerIdBits); - - /** - * 支持的最大数据标识id,结果是31 - */ - private final long maxDatacenterId = -1L ^ (-1L << datacenterIdBits); - - /** - * 序列在id中占的位数 - */ - private final long sequenceBits = 12L; - - /** - * 机器ID向左移12位 - */ - private final long workerIdShift = sequenceBits; - - /** - * 数据标识id向左移17位(12+5) - */ - private final long datacenterIdShift = sequenceBits + workerIdBits; - - /** - * 时间截向左移22位(5+5+12) - */ - private final long timestampLeftShift = sequenceBits + workerIdBits + datacenterIdBits; - - /** - * 生成序列的掩码,这里为4095 (0b111111111111=0xfff=4095) - */ - private final long sequenceMask = -1L ^ (-1L << sequenceBits); - - /** - * 工作机器ID(0~31) - */ - private long workerId; - - /** - * 数据中心ID(0~31) - */ - private long datacenterId; - - /** - * 毫秒内序列(0~4095) - */ - private long sequence = 0L; - - /** - * 上次生成ID的时间截 - */ - private long lastTimestamp = -1L; - - //==============================Constructors===================================== - - /** - * 构造函数 - * - * @param workerId 工作ID (0~31) - * @param datacenterId 数据中心ID (0~31) - */ - public SnowFlake(long workerId, long datacenterId) { - if (workerId > maxWorkerId || workerId < 0) { - throw new IllegalArgumentException(String.format("worker Id can't be greater than %d or less than 0", maxWorkerId)); - } - if (datacenterId > maxDatacenterId || datacenterId < 0) { - throw new IllegalArgumentException(String.format("datacenter Id can't be greater than %d or less than 0", maxDatacenterId)); - } - this.workerId = workerId; - this.datacenterId = datacenterId; - } - - // ==============================Methods========================================== - - /** - * 获得下一个ID (该方法是线程安全的) - * - * @return SnowflakeId - */ - public synchronized long nextId() { - long timestamp = timeGen(); - - //如果当前时间小于上一次ID生成的时间戳,说明系统时钟回退过这个时候应当抛出异常 - if (timestamp < lastTimestamp) { - throw new RuntimeException( - String.format("Clock moved backwards. Refusing to generate id for %d milliseconds", lastTimestamp - timestamp)); - } - - //如果是同一时间生成的,则进行毫秒内序列 - if (lastTimestamp == timestamp) { - sequence = (sequence + 1) & sequenceMask; - //毫秒内序列溢出 - if (sequence == 0) { - //阻塞到下一个毫秒,获得新的时间戳 - timestamp = tilNextMillis(lastTimestamp); - } - } - //时间戳改变,毫秒内序列重置 - else { - sequence = 0L; - } - - //上次生成ID的时间截 - lastTimestamp = timestamp; - - //移位并通过或运算拼到一起组成64位的ID - return (((timestamp - twepoch) << timestampLeftShift) - | (datacenterId << datacenterIdShift) - | (workerId << workerIdShift) - | sequence); - } - - /** - * 阻塞到下一个毫秒,直到获得新的时间戳 - * - * @param lastTimestamp 上次生成ID的时间截 - * @return 当前时间戳 - */ - protected long tilNextMillis(long lastTimestamp) { - long timestamp = timeGen(); - while (timestamp <= lastTimestamp) { - timestamp = timeGen(); - } - return timestamp; - } - - /** - * 返回以毫秒为单位的当前时间 - * - * @return 当前时间(毫秒) - */ - protected long timeGen() { - return System.currentTimeMillis(); - } - - //==============================Test============================================= - - /** - * 测试 - */ - -// public static void main(String[] args) { -// long startTime = System.currentTimeMillis(); -// SnowFlake idWorker = new SnowFlake(30, 30); -// Set set = new HashSet(); -// for (int i = 0; i < 10; i++) { -// long id = idWorker.nextId(); -// set.add(id); -// System.out.println("id----"+i+":"+id); -// } -// long endTime = System.currentTimeMillis(); -// System.out.println("set.size():" + set.size()); -// System.out.println("endTime-startTime:" + (endTime - startTime)); -// } -} \ No newline at end of file diff --git a/src/main/java/com/lunhan/xxx/common/util/SnowFlakeUtil.java b/src/main/java/com/lunhan/xxx/common/util/SnowFlakeUtil.java deleted file mode 100644 index a384201..0000000 --- a/src/main/java/com/lunhan/xxx/common/util/SnowFlakeUtil.java +++ /dev/null @@ -1,115 +0,0 @@ -package com.lunhan.xxx.common.util; - -public class SnowFlakeUtil { - - /** - * 起始的时间戳(2020-05-27 00:00:00) - */ - private final static long START_STAMP = 1590508800000L; - - /** - * 每一部分占用的位数 - */ - //序列号占用的位数 - private final static long SEQUENCE_BIT = 12; - //机器标识占用的位数 - private final static long MACHINE_BIT = 5; - //数据中心占用的位数 - private final static long DATA_CENTER_BIT = 5; - - /** - * 每一部分的最大值 - */ - private final static long MAX_DATA_CENTER_NUM = -1L ^ (-1L << DATA_CENTER_BIT); - private final static long MAX_MACHINE_NUM = -1L ^ (-1L << MACHINE_BIT); - private final static long MAX_SEQUENCE = -1L ^ (-1L << SEQUENCE_BIT); - - /** - * 每一部分向左的位移 - */ - private final static long MACHINE_LEFT = SEQUENCE_BIT; - private final static long DATA_CENTER_LEFT = SEQUENCE_BIT + MACHINE_BIT; - private final static long TIMESTAMP_LEFT = DATA_CENTER_LEFT + DATA_CENTER_BIT; - - /** - * 单例模式 - */ - private static SnowFlakeUtil snowFlake; - - static { - snowFlake = new SnowFlakeUtil(1L, 2L); - } - - public static long getId() { - return snowFlake.nextId(); - } - - public static long getId(long machineId) { - return SnowFlakeUtil.getId(1L, machineId); - } - - public static long getId(long dataCenterId, long machineId) { - return new SnowFlakeUtil(dataCenterId, machineId).nextId(); - } - - //数据中心 - private long dataCenterId; - //机器标识 - private long machineId; - //序列号 - private long sequence = 0L; - //上一次时间戳 - private long lastStamp = -1L; - - private SnowFlakeUtil(long dataCenterId, long machineId) { - if (dataCenterId > MAX_DATA_CENTER_NUM || dataCenterId < 0) { - throw new IllegalArgumentException("dataCenterId can't be greater than MAX_DATA_CENTER_NUM or less than 0"); - } - if (machineId > MAX_MACHINE_NUM || machineId < 0) { - throw new IllegalArgumentException("machineId can't be greater than MAX_MACHINE_NUM or less than 0"); - } - this.dataCenterId = dataCenterId; - this.machineId = machineId; - } - - /** - * 产生下一个ID - */ - public synchronized long nextId() { - long currStamp = getNewStamp(); - if (currStamp < lastStamp) { - throw new RuntimeException("Clock moved backwards. Refusing to generate id"); - } - - if (currStamp == lastStamp) { - //相同毫秒内,序列号自增 - sequence = (sequence + 1) & MAX_SEQUENCE; - //同一毫秒的序列数已经达到最大 - if (sequence == 0L) { - currStamp = getNextMill(); - } - } else { - //不同毫秒内,序列号置为0 - sequence = 0L; - } - - lastStamp = currStamp; - - return (currStamp - START_STAMP) << TIMESTAMP_LEFT //时间戳部分 - | dataCenterId << DATA_CENTER_LEFT //数据中心部分 - | machineId << MACHINE_LEFT //机器标识部分 - | sequence; //序列号部分 - } - - private long getNextMill() { - long mill = getNewStamp(); - while (mill <= lastStamp) { - mill = getNewStamp(); - } - return mill; - } - - private long getNewStamp() { - return LocalDateTimeUtil.nowTimeStamp(); - } -} diff --git a/src/main/java/com/lunhan/xxx/common/util/SpringUtil.java b/src/main/java/com/lunhan/xxx/common/util/SpringUtil.java deleted file mode 100644 index c810efa..0000000 --- a/src/main/java/com/lunhan/xxx/common/util/SpringUtil.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.lunhan.xxx.common.util; - -import org.springframework.beans.BeansException; -import org.springframework.context.ApplicationContext; -import org.springframework.context.ApplicationContextAware; -import org.springframework.stereotype.Component; - -/** - * Spring工具类 - * Created by macro on 2020/3/3. - */ -@Component -public class SpringUtil implements ApplicationContextAware { - - private static ApplicationContext applicationContext; - - // 获取applicationContext - public static ApplicationContext getApplicationContext() { - return applicationContext; - } - - @Override - public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { - if (SpringUtil.applicationContext == null) { - SpringUtil.applicationContext = applicationContext; - } - } - - // 通过name获取Bean - public static Object getBean(String name) { - return getApplicationContext().getBean(name); - } - - // 通过class获取Bean - public static <T> T getBean(Class<T> clazz) { - return getApplicationContext().getBean(clazz); - } - - // 通过name,以及Clazz返回指定的Bean - public static <T> T getBean(String name, Class<T> clazz) { - return getApplicationContext().getBean(name, clazz); - } - -} diff --git a/src/main/java/com/lunhan/xxx/common/util/StringUtil.java b/src/main/java/com/lunhan/xxx/common/util/StringUtil.java deleted file mode 100644 index 40bd4bf..0000000 --- a/src/main/java/com/lunhan/xxx/common/util/StringUtil.java +++ /dev/null @@ -1,847 +0,0 @@ -package com.lunhan.xxx.common.util; - -import com.lunhan.xxx.common.ConstantFactory; -import com.lunhan.xxx.common.security.MD5Util; -import org.apache.commons.lang3.EnumUtils; -import org.apache.commons.lang3.StringUtils; - -import java.lang.reflect.Method; -import java.math.BigDecimal; -import java.nio.charset.Charset; -import java.util.*; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import java.util.stream.Collectors; - -/** - * 字符串处理类 - * @author linliu - * @date 2018-12-28 - */ -public final class StringUtil { - //region 常量 - private static final String REGX_MOBILEPHONE = "^((\\+86)|(\\(\\+86\\))-)?[0-9]{11}$"; - - private static final String REGX_TELEPHONE = "^((\\+86)|(\\(\\+86\\))-)?(((0[1,2]{1}\\d{1})?-?\\d{8})|((0[3-9]{1}\\d{2})?-?\\d{7,8}))$"; - - private static final String REGX_IDCARD = "^([0-9]{17}[0-9X]{1})|([0-9]{15})$"; - - private static final String REGX_WEBURL = "^(((file|gopher|news|nntp|telnet|http|ftp|https|ftps|sftp)://)|(www\\.))+(([a-zA-Z0-9\\._-]+\\.[a-zA-Z]{2,6})|([0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}))(/[a-zA-Z0-9\\&%_\\./-~-]*)?$"; - - private static final String REGX_EMAIL = "^\\w+([-+.']\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$"; - - private static final String REGX_MONEY = "^\\d{1,12}(?:\\.\\d{1,4})?$"; - - private static final String DEFAULT = "utf-8"; - //endregion - - private StringUtil() { - throw new IllegalStateException("Utility class"); - } - - /** - * 从当前对象移除头尾指定字符 - * @author xiangyuanzhang - * @date 2018-12-25 - * @param source 原始字符串 - * @param trimChar 移除字符串 - */ - public String trim(String source, String trimChar) { - if(source==null){ - return ""; - } - source = source.trim(); - if(source.isEmpty()){ - return ""; - } - String beginChar = source.substring(0, 1); - if (beginChar.equalsIgnoreCase(trimChar)) { - source = source.substring(1, source.length()); - } - String endChar = source.substring(source.length() - 1, source.length()); - if (endChar.equalsIgnoreCase(trimChar)) { - source = source.substring(0, source.length() - 1); - } - return source; - } - - /** - * 从当前对象移除头部指定字符 - * @author xiangyuanzhang - * @date 2018-12-25 - * @param source 原始字符串 - * @param trimChar 移除字符串 - */ - public String trimStart(String source, String trimChar) { - if(source==null){ - return ""; - } - source = source.trim(); - if(source.isEmpty()){ - return ""; - } - String beginChar = source.substring(0, 1); - if (beginChar.equalsIgnoreCase(trimChar)) { - source = source.substring(1, source.length()); - } - return source; - } - - /** - * 从当前对象移除尾部指定字符 - * @author xiangyuanzhang - * @date 2018-12-25 - * @param source 原始字符串 - * @param trimChar 移除字符串 - */ - public String trimEnd(String source, String trimChar) { - if(source==null){ - return ""; - } - source = source.trim(); - if(source.isEmpty()){ - return ""; - } - String endChar = source.substring(source.length() - 1, source.length()); - if (endChar.equalsIgnoreCase(trimChar)) { - source = source.substring(0, source.length() - 1); - } - return source; - } - - /** - * 字符串枚举值转成枚举对象 - * @author linliu - * @date 2018-12-24 - * @param enumType 枚举类型 - * @param value 枚举值 - * @param <T> 枚举类型 - * @return 枚举对象 - */ - public static <T extends Enum<T>> T parseEnum(Class<T> enumType, String value) { - if(isNullOrEmpty(value)) { - return null; - } - - T result = null; - try { - T[] values = enumType.getEnumConstants(); - Method getValue = enumType.getMethod("getValue"); - - for (T e : values) { - if(getValue.invoke(e).toString().equals(value)) { - result = e; - break; - } - } - } catch (Exception e) { - //TODO log - } - return result; - } - - /** - * 字符串枚举值转成枚举对象 - * @author linliu - * @date 2018-12-24 - * @param enumType 枚举类型 - * @param name 枚举名称 - * @param <T> 枚举类型 - * @return 枚举对象 - */ - public static <T extends Enum<T>> T parseEnumByName(Class<T> enumType, String name) { - if(isNullOrEmpty(name)) { - return null; - } - - T result = null; - try { - result = EnumUtils.getEnum(enumType, name); - } catch (Exception e) { - //TODO log - } - return result; - } - - /** - * 判断枚举是否申明了传入枚举值 - * @author linliu - * @date 2018-12-24 - * @param enumType 枚举类型 - * @param value 枚举值 - * @param <T> 枚举类型 - * @return 是否包含 - */ - public static <T extends Enum<T>> boolean isEnum(Class<T> enumType, String value) { - return (null != parseEnum(enumType, value)); - } - - /** - * 判断枚举是否申明了传入枚举值 - * @author linliu - * @date 2018-12-24 - * @param enumType 枚举类型 - * @param name 枚举名称 - * @param <T> 枚举类型 - * @return 是否包含 - */ - public static <T extends Enum<T>> boolean isEnumName(Class<T> enumType, String name) { - return EnumUtils.isValidEnum(enumType, name); - } - - /** - * 字符串是否为空 - * @author linliu - * @date 2018-12-25 - * @param str 字符串 - * @return 是否为空 - */ - public static boolean isNullOrEmpty(String str){ - return (str==null || str.equals("") || str.replace(" ","").length() == 0); - } - - /** - * 字符串非空 - * @author linliu - * @date 2018-12-25 - * @param str 字符串 - * @return 是否非空 - */ - public static boolean isNotNullOrEmpty(String str){ - return !isNullOrEmpty(str); - } - - /** - * 集合,使用英文逗号“,”拼接成一个字符串 - * @param list 集合 - */ - public static String join(Collection<String> list){ - return StringUtil.join(list, ","); - } - /** - * 集合,使用指定的字符,拼接成一个字符串 - * @param list 集合 - * @param separator 拼接字符 - */ - public static String join(Collection<String> list, String separator){ - if(ListUtil.isNullOrEmpty(list)){ - return ""; - } - return StringUtils.join(list.toArray(), separator); - } - /** - * 数组,使用英文逗号“,”拼接成一个字符串 - * @param array 数组 - */ - public static String join(String[] array){ - return StringUtil.join(array, ","); - } - /** - * 数组,使用指定的字符,拼接成一个字符串 - * @param array 数组 - * @param separator 拼接字符 - */ - public static String join(String[] array, String separator){ - if(array == null){ - return ""; - } - return StringUtils.join(array, separator); - } - - /** - * 集合,使用英文逗号“,”拼接成一个字符串 - * @param list 集合 - */ - public static String joinNumber(Collection<Number> list){ - return StringUtil.joinNumber(list, ","); - } - /** - * 集合,使用指定的字符,拼接成一个字符串 - * @param list 集合 - * @param separator 拼接字符 - */ - public static String joinNumber(Collection<Number> list, String separator){ - if(ListUtil.isNullOrEmpty(list)){ - return ""; - } - return StringUtils.join(list.toArray(), separator); - } - /** - * 数组,使用英文逗号“,”拼接成一个字符串 - * @param array 数组 - */ - public static String joinNumber(Number[] array){ - return joinNumber(array, ","); - } - /** - * 数组,使用指定的字符,拼接成一个字符串 - * @param array 数组 - * @param separator 拼接字符 - */ - public static String joinNumber(Number[] array, String separator){ - if(array == null){ - return ""; - } - return StringUtils.join(array, separator); - } - - /** - * base64解码(utf-8编码) - * @author linliu - * @date 2019-06-14 - * @param str 密文字符串 - * @return 解码后的明文 - */ - public static String base64Encode(String str) { - return base64Encode(str, DEFAULT); - } - /** - * base64解码 - * @author linliu - * @date 2019-06-14 - * @param str 密文字符串 - * @param encoding 编码格式[默认utf-8] - * @return 解码后的明文 - */ - public static String base64Encode(String str, String encoding) { - if(isNullOrEmpty(str)) { - return ""; - } - if(isNullOrEmpty(encoding)) { - encoding = DEFAULT; - } - byte[] bytes = str.getBytes(Charset.forName(encoding)); - return Base64.getEncoder().encodeToString(bytes); - } - - /** - * base64解码(utf-8编码) - * @author linliu - * @date 2019-06-14 - * @param str 密文字符串 - * @return 解码后的明文 - */ - public static String base64Decode(String str) { - return base64Decode(str, DEFAULT); - } - /** - * base64解码 - * @author linliu - * @date 2019-06-14 - * @param str 密文字符串 - * @param encoding 编码格式[默认utf-8] - * @return 解码后的明文 - */ - public static String base64Decode(String str, String encoding) { - if(isNullOrEmpty(str)) { - return ""; - } - if(isNullOrEmpty(encoding)) { - encoding = DEFAULT; - } - byte[] bytes = Base64.getDecoder().decode(str); - return new String(bytes, Charset.forName(encoding)); - } - - /** - * 传入字符串是否是有效的手机号码 - * @param str 字符串 - */ - public static boolean isMobilePhone(String str) { - return Pattern.matches(REGX_MOBILEPHONE, str); - } - - /** - * 传入字符串是否是有效的座机号码 - * @param str 字符串 - */ - public static boolean isTelPhone(String str) { - return Pattern.matches(REGX_TELEPHONE, str); - } - - /** - * 传入字符串是否是有效的身份证号码 - * @param str 字符串 - */ - public static boolean isIdCard(String str) { - return Pattern.matches(REGX_IDCARD, str); - } - - /** - * 传入字符串是否是有效的网址 - * @param str 字符串 - */ - public static boolean isWebUrl(String str) { - return Pattern.matches(REGX_WEBURL, str); - } - - /** - * 传入字符串是否是有效的电子邮件邮箱地址 - * @param str 字符串 - */ - public static boolean isEmail(String str) { - return Pattern.matches(REGX_EMAIL, str); - } - - /** - * 传入字符串是否是有效的金额 - * @param str 字符串 - */ - public static boolean isMoney(String str) { - return Pattern.matches(REGX_MONEY, str); - } - - /** - * 是否满足正则表达式规则 - * @author linliu - * @date 2019-01-04 - * @param str 字符串 - * @param regex 正则表达式 - * @return 是否匹配 - */ - public static Boolean isMatch(String str,String regex) { - if(StringUtil.isNullOrEmpty(str)) { - return Boolean.FALSE; - } - return Pattern.matches(regex, str); - } - - /** - * 正则获取Xml中的内容 - * @author xiangyuanzhang - * @date 2019-01-09 - * @param xml 传入的xml字符串 - * @param label 指定的标签中的内容 - */ - public static String regexXml(String xml, String label) { - String context = ""; - String rgex = "<" + label + ">(.*?)</" + label + ">"; - Pattern pattern = Pattern.compile(rgex,Pattern.CASE_INSENSITIVE); - Matcher m = pattern.matcher(xml); - List<String> list = new ArrayList<>(); - int i = 1; - while (m.find()) { - list.add(m.group(i)); - i++; - } - if (!list.isEmpty()) { - context = list.get(0); - } - return context; - } - - /** - * 获取<![CDATA 中内容 - * @author xiangyuanzhang - * @date 2019-01-14 - * @param str - * @return - */ - public static String getCDATAContent(String str) { - Pattern p = Pattern.compile(".*<!\\[CDATA\\[(.*)\\]\\]>.*"); - Matcher m = p.matcher(str); - if(m.matches()) { - return m.group(1); - } - return str; - } - - /** - * 将传入字符串转成 Integer 类型 - * @param str 字符串 - */ - public static int parseInt(String str) { - return Integer.parseInt(str); - } - - /** - * 将传入字符串转成 Long 类型 - * @param str 字符串 - */ - public static long parseLong(String str) { - return Long.parseLong(str); - } - - /** - * 将传入字符串转成精度为2位小数的 BigDecimal 类型 - * @param str 字符串 - */ - public static BigDecimal parseBigDecimal(String str) { - return parseBigDecimal(str, Integer.parseInt("2")); - } - - /** - * 将传入字符串转成指定精度的 BigDecimal 类型 - * @param str 字符串 - */ - public static BigDecimal parseBigDecimal(String str, Integer length) { - BigDecimal bd = new BigDecimal(str); - return bd.setScale(length, BigDecimal.ROUND_HALF_UP); - } - - /** - * 传入字符串是否是有效的 BigDecimal - * @param str 字符串 - */ - public static boolean isBigDecimal(String str) { - try{ - if(isNullOrEmpty(str)) { - return false; - } - new BigDecimal(str); - return true; - }catch (NumberFormatException e){ - return false; - } - } - - /** - * 将传入指定格式的字符串转成 Calendar 类型(默认“yyyy-MM-dd HH:mm:ss”) - * @param str 时间字符串 - * @param format 时间格式 - */ - public static Calendar parseDate(String str, String... format) { - String f = ConstantFactory.STR_DATE_FULL; - if(format.length>0) { - f = format[0]; - } - return CalendarUtil.fromStr(str, f); - } - - /** - * md5加密 - * @param content 待加密明文字符串 - */ - public static String md5(String content) { - return MD5Util.encrypt(content); - } - - /** - * 集合,使用英文逗号“,”拼接成一个字符串 - * @param list 集合 - */ - public static String joinInt(List<Integer> list){ - return joinInt(list, ","); - } - /** - * 集合,使用指定的字符,拼接成一个字符串 - * @param list 集合 - * @param separator 拼接字符 - */ - public static String joinInt(List<Integer> list, String separator){ - if(ListUtil.isNullOrEmpty(list)){ - return ""; - } - return StringUtils.join(list.toArray(), separator); - } - - /** - * 数组,使用英文逗号“,”拼接成一个字符串 - * @param array 数组 - */ - public static String joinInt(Integer[] array){ - return joinInt(array, ","); - } - /** - * 数组,使用指定的字符,拼接成一个字符串 - * @param array 数组 - * @param separator 拼接字符 - */ - public static String joinInt(Integer[] array, String separator){ - if(array == null){ - return ""; - } - return StringUtils.join(array, separator); - } - - /** - * 将传入字符串按指定分隔符,拆分成数组 - * @param str 字符串 - * @param splitChar 分隔符 - */ - public static String[] split(String str, String splitChar) { - if(StringUtil.isNullOrEmpty(str)) { - return new String[0]; - } - return str.split(splitChar); - } - /** - * 将传入字符串按英文逗号“,”分隔,拆分成数组 - * @param str 字符串 - */ - public static String[] split(String str) { - if(StringUtil.isNullOrEmpty(str)) { - return new String[0]; - } - return str.split("\\,"); - } - - /** - * 将传入字符串按指定分隔符,拆分成集合 - * @param str 字符串 - * @param splitChar 分隔符 - */ - public static List<String> splitList(String str, String splitChar) { - if(StringUtil.isNullOrEmpty(str)) { - return new ArrayList<>(); - } - return ListUtil.toList(split(str, splitChar)); - } - /** - * 将传入字符串按英文逗号“,”分隔,拆分成集合 - * @param str 字符串 - */ - public static List<String> splitList(String str) { - if(StringUtil.isNullOrEmpty(str)) { - return new ArrayList<>(); - } - return splitList(str, ","); - } - - /** - * 将传入字符串按指定分隔符,拆分成集合 - * @param str 字符串 - * @param splitChar 分隔符 - */ - public static List<Integer> splitIntList(String str, String splitChar) { - if(StringUtil.isNullOrEmpty(str)) { - return new ArrayList<>(); - } - return ListUtil.toIntList(splitList(str, splitChar)); - } - /** - * 将传入字符串按英文逗号“,”分隔,拆分成集合 - * @param str 字符串 - */ - public static List<Integer> splitIntList(String str) { - if(StringUtil.isNullOrEmpty(str)) { - return new ArrayList<>(); - } - return splitIntList(str, ","); - } - - /** - * 将传入字符串按指定分隔符,拆分成集合 - * @param str 字符串 - * @param splitChar 分隔符 - */ - public static List<Long> splitLongList(String str, String splitChar) { - if(StringUtil.isNullOrEmpty(str)) { - return new ArrayList<>(); - } - return ListUtil.toLongList(splitList(str, splitChar)); - } - /** - * 将传入字符串按英文逗号“,”分隔,拆分成集合 - * @param str 字符串 - */ - public static List<Long> splitLongList(String str) { - if(StringUtil.isNullOrEmpty(str)) { - return new ArrayList<>(); - } - return splitLongList(str, ","); - } - - /** - * 集合,使用英文逗号“,”拼接成一个字符串 - * @param list 集合 - */ - public static String joinLong(Collection<Long> list) { - return StringUtil.joinLong(list, ","); - } - /** - * 集合,使用指定的字符,拼接成一个字符串 - * @param list 集合 - * @param separator 拼接字符 - */ - public static String joinLong(Collection<Long> list, String separator) { - if(ListUtil.isNullOrEmpty(list)){ - return ""; - } - return StringUtils.join(list.toArray(), separator); - } - - /** - * 数组,使用英文逗号“,”拼接成一个字符串 - * @param array 数组 - */ - public static String joinLong(Long[] array) { - return joinLong(array, ","); - } - /** - * 数组,使用指定的字符,拼接成一个字符串 - * @param array 数组 - * @param separator 拼接字符 - */ - public static String joinLong(Long[] array, String separator){ - if(array == null){ - return ""; - } - return StringUtils.join(array, separator); - } - - /** - * 将字符串按英文逗号“,”分割,拆分成日期集合 - * @param str - * @param dateFormat - * @return - */ - public static List<Date> splitListDate(String str, String dateFormat) { - return splitListDate(str, dateFormat, ","); - } - /** - * 将字符串按指定分隔符,拆分成日期集合 - * @param str 字符串 - * @param dateFormat 日期格式 - * @return - */ - public static List<Date> splitListDate(String str, String dateFormat, String separator) { - if(StringUtil.isNullOrEmpty(str)) { - return new ArrayList<>(); - } - List<String> lstDate = splitList(str, separator); - return lstDate.stream().map(d -> { - try { - return CalendarUtil.fromStr(d, dateFormat).getTime(); - } catch (Exception e) { - return null; - } - }).collect(Collectors.toList()); - } - - /** - * 按指定字符串分割字符串 - * @author linliu - * @date 2019-06-19 - * @param str 字符串 - * @param onceQuantity 拆分后单个字符串的字符数 - */ - public static String[] split(String str, Integer onceQuantity) { - if(StringUtil.isNullOrEmpty(str)) { - return new String[]{}; - } - if(Integer.valueOf(0).compareTo(onceQuantity)>-1) { - onceQuantity = str.length(); - } - int size = str.length() / onceQuantity; - String[] result = new String[size]; - if(size==1) { - result[0] = str; - return result; - } - for (int idx=0; idx<size; idx++) { - result[idx] = substring(str, onceQuantity*idx, onceQuantity*(idx+1)); - } - return result; - } - - /** - * 按指定字符串分割字符串 - * @author linliu - * @date 2019-06-19 - * @param str 字符串 - * @param onceQuantity 拆分后单个字符串的字符数 - */ - public static List<String> splitList(String str, Integer onceQuantity) { - if(StringUtil.isNullOrEmpty(str)) { - return new ArrayList<>(); - } - if(Integer.valueOf(0).compareTo(onceQuantity)>-1) { - onceQuantity = str.length(); - } - int size = str.length() / onceQuantity; - List<String> result = new ArrayList<>(); - if(size==1) { - result.add(str); - return result; - } - if(str.length()%onceQuantity != 0) { - size += 1; - } - for (int idx=0; idx<size; idx++) { - result.add(substring(str, onceQuantity*idx, onceQuantity*(idx+1))); - } - return result; - } - - /** - * 分割字符串,如果开始位置大于字符串长度,返回空 - * @author linliu - * @date 2019-06-19 - * @param str 原始字符串 - * @param start 开始位置 - * @param end 结束位置 - */ - public static String substring(String str, Integer start, Integer end) { - if (StringUtil.isNullOrEmpty(str) || start > str.length()) { - return ""; - } - if (end > str.length()) { - return str.substring(start, str.length()); - } else { - return str.substring(start, end); - } - } - - /** - * 截取字符串长度 - * @param content 字符串 - * @param length 截取长度 - */ - public static String cutStr(String content, Integer length) { - return StringUtil.substring(content, 0, length); - } - - /** - * 判断是否为空,如果为空返回空字符串 - * @param str 字符串 - */ - public static String getStringDefault(String str) { - if (StringUtil.isNullOrEmpty(str)) { - return ""; - } - return str; - } - - /** - * 将小驼峰字符串转为_连接的 - * @param input 字符串 - */ - public static String camelCaseToUnderscore(String input) { - if (input == null) { - return null; - } - - StringBuilder result = new StringBuilder(); - boolean prevIsLowerCase = false; - - for (char c : input.toCharArray()) { - if (Character.isUpperCase(c)) { - if (prevIsLowerCase) { - result.append('_'); - } - result.append(Character.toLowerCase(c)); - prevIsLowerCase = false; - } else { - result.append(c); - prevIsLowerCase = true; - } - } - - return result.toString(); - } - - /** - * 字符串转16进制字符 - * @param input 字符串 - */ - public static String toHexString(String input) { - StringBuilder str = new StringBuilder(); - for (int i = 0; i < input.length(); i++) { - int ch = input.charAt(i); - String s4 = Integer.toHexString(ch); - str.append(s4); - } - return str.toString(); - } -} \ No newline at end of file diff --git a/src/main/java/com/lunhan/xxx/common/util/ThreadPoolUtil.java b/src/main/java/com/lunhan/xxx/common/util/ThreadPoolUtil.java deleted file mode 100644 index f7fe230..0000000 --- a/src/main/java/com/lunhan/xxx/common/util/ThreadPoolUtil.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.lunhan.xxx.common.util; - -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; - -/** - * 线程池管理类 - */ -public final class ThreadPoolUtil { - /** - * 多线程允许最大并发线程数的默认大小 - */ - private static final Integer THREAD_DEFAULT_MAXQUANTITY = 50; - - /** - * 创建一个定长线程池,可控制线程最大并发数,超出的线程会在队列中等待。 - */ - private static ExecutorService THREADPOOL_DEFAULT = Executors.newFixedThreadPool(THREAD_DEFAULT_MAXQUANTITY); - - /** - * 获取默认线程池 - * @return - */ - public static ExecutorService getDefaultPool() { - return THREADPOOL_DEFAULT; - } -} diff --git a/src/main/java/com/lunhan/xxx/common/validator/EParameterValidateType.java b/src/main/java/com/lunhan/xxx/common/validator/EParameterValidateType.java deleted file mode 100644 index a84b4f2..0000000 --- a/src/main/java/com/lunhan/xxx/common/validator/EParameterValidateType.java +++ /dev/null @@ -1,139 +0,0 @@ -package com.lunhan.xxx.common.validator; - -import java.util.Arrays; -import java.util.Objects; - -/** - * 参数验证类型 枚举 - * @author linliu - * @date 2019-04-19 - */ -public enum EParameterValidateType { - /** - * 不能为空 - */ - NOT_NULLOREMPTY(", 不能为空 ", 1), - - - - /** - * 必须大于 - */ - MUST_GREATER(", 必须大于 ", 2), - /** - * 必须大于等于 - */ - MUST_GREATER_THAN(", 必须大于等于 ", 3), - - - - /** - * 必须小于 - */ - MUST_LESS(", 必须小于 ", 4), - /** - * 必须小于等于 - */ - MUST_LESS_THAN(", 必须小于等于 ", 5), - - - - /** - * 必须是枚举 - */ - MUST_ENUM(", 必须是合法的枚举值", 6), - - - - /** - * 必须是有效的日期(yyyy-MM-dd) - */ - MUST_DATE(", 必须是有效的日期格式(yyyy-MM-dd)", 7), - /** - * 必须是有效的时间(yyyy-MM-dd HH:mm:ss) - */ - MUST_DATE_TIME(", 必须是有效的日期格式(yyyy-MM-dd HH:mm:ss)", 8), - - - - /** - * 必须是有效电话号码 - */ - MUST_PHONE_NUMBER(", 必须是有效的联系方式", 9), - /** - * 必须是有效座机号码 - */ - MUST_TELEPHONE_NUMBER(", 必须是有效的座机号码", 10), - /** - * 必须是有效手机号码 - */ - MUST_MOBILE_NUMBER(", 必须是有效的手机号码", 11), - - - - /** - * 必须是有效电子邮箱地址 - */ - MUST_EMAIL(", 必须是有效的电子邮箱", 12), - - /** - * 不能超出取值范围 - */ - MUST_IN_RANGE(", 取值超出允许范围 ", 13), - - /** - * 长度不能小于 - */ - MUST_LENGTH_MIN(", 字符长度不能少于 ", 14), - /** - * 长度不能大于 - */ - MUST_LENGTH_MAX(", 字符长度不能超过 ", 15), - - /** - * 必须满足正则表达式规则 - */ - MUST_PASS_REGEX(", 必须满足正则表达式规则 ", 16) - ; - - private String desc;//枚举描述 - private Integer value;//枚举值 - - public Integer getValue() { - return value; - } - public String getDesc() { - return desc; - } - - /** - * 构造方法 - * @param desc 枚举描述 - * @param value 枚举值 - */ - private EParameterValidateType(String desc, Integer value) { - this.desc = desc; - this.value = value; - } - - /** - * 根据值获取枚举 - * - * @param value 枚举值 - * @return - */ - public static EParameterValidateType getByValue(Integer value) { - return Arrays.stream(EParameterValidateType.values()) - .filter(e -> Objects.equals(e.getValue(), value)) - .findFirst() - .orElse(null); - } - - @Override - public String toString() { - return "EParameterValidateType{" + - "desc='" + desc + '\'' + - ", value=" + value + - '}'; - } -} \ No newline at end of file diff --git a/src/main/java/com/lunhan/xxx/common/validator/ParameterRunnable.java b/src/main/java/com/lunhan/xxx/common/validator/ParameterRunnable.java deleted file mode 100644 index c527603..0000000 --- a/src/main/java/com/lunhan/xxx/common/validator/ParameterRunnable.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.lunhan.xxx.common.validator; - -public class ParameterRunnable<T> implements Runnable { - T param; - public ParameterRunnable(T param) { - this.param = param; - } - - @Override - public void run() { - new ParameterRunnable(param); - } -} diff --git a/src/main/java/com/lunhan/xxx/common/validator/ParameterValidateItem.java b/src/main/java/com/lunhan/xxx/common/validator/ParameterValidateItem.java deleted file mode 100644 index a23b761..0000000 --- a/src/main/java/com/lunhan/xxx/common/validator/ParameterValidateItem.java +++ /dev/null @@ -1,124 +0,0 @@ -package com.lunhan.xxx.common.validator; - -import java.util.function.Function; - -/** - * 参数验证 对象 - * @author linliu - * @date 2019-04-19 - * @param <T> 枚举类型 - */ -public class ParameterValidateItem<T extends Enum> { - private String fieldName; - private EParameterValidateType type; - private Object value; - private Object rangeMin; - private Object rangeMax; - private Class<T> enumType; - private Function<Object, Boolean> validateFunc = null; - private String regex; - - public ParameterValidateItem() {} - public ParameterValidateItem(String fieldName, EParameterValidateType type, Object value) { - this.fieldName = fieldName; - this.type = type; - this.value = value; - } - public ParameterValidateItem(String fieldName, EParameterValidateType type, Object value, Function<Object, Boolean> validateFunc) { - this.fieldName = fieldName; - this.type = type; - this.value = value; - this.validateFunc = validateFunc; - } - public ParameterValidateItem(String fieldName, EParameterValidateType type, Object value, Object rangeMin, Object rangeMax) { - this.fieldName = fieldName; - this.type = type; - this.value = value; - this.rangeMin = rangeMin; - this.rangeMax = rangeMax; - } - public ParameterValidateItem(String fieldName, EParameterValidateType type, Object value, Object rangeMin, Object rangeMax, Class<T> enumType) { - this.fieldName = fieldName; - this.type = type; - this.value = value; - this.rangeMin = rangeMin; - this.rangeMax = rangeMax; - this.enumType = enumType; - } - public ParameterValidateItem(String fieldName, Object value, Object rangeMin, Object rangeMax) { - this.fieldName = fieldName; - this.type = EParameterValidateType.MUST_IN_RANGE; - this.value = value; - this.rangeMin = rangeMin; - this.rangeMax = rangeMax; - } - public ParameterValidateItem(String fieldName, Object value , Class<T> enumType) { - this.fieldName = fieldName; - this.type = EParameterValidateType.MUST_ENUM; - this.value = value; - this.enumType = enumType; - } - public ParameterValidateItem(String fieldName, Object value , String regex) { - this.fieldName = fieldName; - this.type = EParameterValidateType.MUST_PASS_REGEX; - this.value = value; - this.regex = regex; - } - - public String getFieldName() { - return fieldName; - } - public void setFieldName(String fieldName) { - this.fieldName = fieldName; - } - - public EParameterValidateType getType() { - return type; - } - public void setType(EParameterValidateType type) { - this.type = type; - } - - public Object getValue() { - return value; - } - public void setValue(Object value) { - this.value = value; - } - - public Object getRangeMin() { - return rangeMin; - } - public void setRangeMin(Object rangeMin) { - this.rangeMin = rangeMin; - } - - public Object getRangeMax() { - return rangeMax; - } - public void setRangeMax(Object rangeMax) { - this.rangeMax = rangeMax; - } - - public Class<T> getEnumType() { - return enumType; - } - public void setEnumType(Class<T> enumType) { - this.enumType = enumType; - } - - public Function<Object, Boolean> getValidateFunc() { - return validateFunc; - } - public void setValidateFunc(Function<Object, Boolean> validateFunc) { - this.validateFunc = validateFunc; - } - - public String getRegex() { - return regex; - } - - public void setRegex(String regex) { - this.regex = regex; - } -} \ No newline at end of file diff --git a/src/main/java/com/lunhan/xxx/common/validator/ParameterValidateResult.java b/src/main/java/com/lunhan/xxx/common/validator/ParameterValidateResult.java deleted file mode 100644 index 4b46d15..0000000 --- a/src/main/java/com/lunhan/xxx/common/validator/ParameterValidateResult.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.lunhan.xxx.common.validator; - -public class ParameterValidateResult { - private Boolean isSuccess; - private String errorMsg; - - public ParameterValidateResult() {} - public ParameterValidateResult(Boolean isSuccess, String errorMsg) { - this.isSuccess = isSuccess; - this.errorMsg = errorMsg; - } - - public Boolean getIsSuccess() { - return isSuccess; - } - public void setIsSuccess(Boolean success) { - isSuccess = success; - } - - public Boolean getIsFiled() { - return !isSuccess; - } - - public String getErrorMsg() { - return errorMsg; - } - public void setErrorMsg(String errorMsg) { - this.errorMsg = errorMsg; - } - - @Override - public String toString() { - return "ParameterValidateResult{" + - "isSuccess=" + isSuccess + - ", errorMsg='" + errorMsg + '\'' + - '}'; - } -} \ No newline at end of file diff --git a/src/main/java/com/lunhan/xxx/common/validator/ParameterValidator.java b/src/main/java/com/lunhan/xxx/common/validator/ParameterValidator.java deleted file mode 100644 index 654acd3..0000000 --- a/src/main/java/com/lunhan/xxx/common/validator/ParameterValidator.java +++ /dev/null @@ -1,555 +0,0 @@ -package com.lunhan.xxx.common.validator; - -import com.lunhan.xxx.common.ConstantFactory; -import com.lunhan.xxx.common.util.ListUtil; -import com.lunhan.xxx.common.util.LocalDateTimeUtil; -import com.lunhan.xxx.common.util.NumericUtil; -import com.lunhan.xxx.common.util.StringUtil; - -import java.math.BigDecimal; -import java.time.LocalDate; -import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Calendar; -import java.util.List; -import java.util.function.Function; - -/** - * 参数验证 - * @author linliu - * @date 2019-04-19 - */ -public class ParameterValidator { - /** - * 验证参数列表 - */ - public List<ParameterValidateItem> listParameter; - public List<ParameterValidateItem> getListParameter() { - return listParameter; - } - public void setListParameter(List<ParameterValidateItem> listParameter) { - this.listParameter = listParameter; - } - - public ParameterValidator() { - listParameter = new ArrayList<>(); - } - - /** - * 添加一个需要验证的参数 - * @param item 参数验证对象 - */ - public ParameterValidator addParameter(ParameterValidateItem... item) { - this.listParameter.addAll(Arrays.asList(item)); - return this; - } - - /** - * 添加一个需要验证的参数 - * @param fieldName 参数名称“自行构建参数描述"userName" 或者 "the parameter which named “userName”"” - * @param type 需要验证的类型 - * @param value 参数的值 - * @param validateFunc 是否通过验证的自函数 - */ - public ParameterValidator addParameter(String fieldName, EParameterValidateType type, Object value, Function<Object, Boolean> validateFunc) { - this.listParameter.add(new ParameterValidateItem(fieldName, type, value, validateFunc)); - return this; - } - - - - /** - * 添加一个“不能为空”的参数 验证 - * @param fieldName 参数名称 - * @param value 参数值 - */ - public ParameterValidator addNotNullOrEmpty(String fieldName, Object value) { - this.listParameter.add(new ParameterValidateItem(fieldName, EParameterValidateType.NOT_NULLOREMPTY, value)); - return this; - } - /** - * 添加一个“必须是一个有效日期”(yyyy-MM-dd)的参数 验证 - * @param fieldName 参数名称 - * @param value 参数值 - */ - public ParameterValidator addMustDate(String fieldName, Object value) { - this.listParameter.add(new ParameterValidateItem(fieldName, EParameterValidateType.MUST_DATE, value)); - return this; - } - /** - * 添加一个“必须是一个有效时间”(yyyy-MM-dd HH:mm:ss)的参数 验证 - * @param fieldName 参数名称 - * @param value 参数值 - */ - public ParameterValidator addMustDateTime(String fieldName, Object value) { - this.listParameter.add(new ParameterValidateItem(fieldName, EParameterValidateType.MUST_DATE_TIME, value)); - return this; - } - /** - * 添加一个“必须是指定枚举类型的有效值”的参数 验证 - * @param fieldName 参数名称 - * @param value 参数值 - * @param enumType 枚举类型 - */ - public <T extends Enum> ParameterValidator addMustEnum(String fieldName, Object value, Class<T> enumType) { - this.listParameter.add(new ParameterValidateItem(fieldName, value, enumType)); - return this; - } - /** - * 添加一个“必须是有效电子邮箱地址”的参数 验证 - * @param fieldName 参数名称 - * @param value 参数值 - */ - public ParameterValidator addMustEmail(String fieldName, Object value) { - this.listParameter.add(new ParameterValidateItem(fieldName, EParameterValidateType.MUST_EMAIL, value)); - return this; - } - /** - * 添加一个“必须是有效手机号码”的参数 验证 - * @param fieldName 参数名称 - * @param value 参数值 - */ - public ParameterValidator addMustMobile(String fieldName, Object value) { - this.listParameter.add(new ParameterValidateItem(fieldName, EParameterValidateType.MUST_MOBILE_NUMBER, value)); - return this; - } - /** - * 添加一个“必须是有效手机号码”的参数 验证 - * @param fieldName 参数名称 - * @param value 参数值 - */ - public ParameterValidator addMustPassRegex(String fieldName, Object value, String regex) { - this.listParameter.add(new ParameterValidateItem(fieldName, value, regex)); - return this; - } - - - - /** - * 添加一个“必须大于最小值”的参数 验证 - * @param fieldName 参数名称 - * @param value 参数值 - * @param minValue 校验允许的最小值 - */ - public ParameterValidator addGreater(String fieldName, Object value, Object minValue) { - this.listParameter.add(new ParameterValidateItem(fieldName, EParameterValidateType.MUST_GREATER, value, minValue, null)); - return this; - } - /** - * 添加一个“必须大于等于最小值”的参数 验证 - * @param fieldName 参数名称 - * @param value 参数值 - * @param minValue 校验允许的最小值 - */ - public ParameterValidator addGreaterThan(String fieldName, Object value, Object minValue) { - this.listParameter.add(new ParameterValidateItem(fieldName, EParameterValidateType.MUST_GREATER_THAN, value, minValue, null)); - return this; - } - - - - /** - * 添加一个“必须小于最大值”的参数 验证 - * @param fieldName 参数名称 - * @param value 参数值 - * @param maxValue 校验允许的最大值 - */ - public ParameterValidator addLess(String fieldName, Object value, Object maxValue) { - this.listParameter.add(new ParameterValidateItem(fieldName, EParameterValidateType.MUST_LESS, value, null, maxValue)); - return this; - } - /** - * 添加一个“必须小于等于最大值”的参数 验证 - * @param fieldName 参数名称 - * @param value 参数值 - * @param maxValue 校验允许的最大值 - */ - public ParameterValidator addLessThan(String fieldName, Object value, Object maxValue) { - this.listParameter.add(new ParameterValidateItem(fieldName, EParameterValidateType.MUST_LESS_THAN, value, null, maxValue)); - return this; - } - - - - /** - * 添加一个“字符串必须大于等于最小长度”的参数 验证 - * @param fieldName 参数名称 - * @param value 参数值 - * @param minLength 校验允许的最小长度 - */ - public ParameterValidator addLengthMin(String fieldName, Object value, Integer minLength) { - this.listParameter.add(new ParameterValidateItem(fieldName, EParameterValidateType.MUST_LENGTH_MIN, value, minLength, null, null)); - return this; - } - /** - * 添加一个“字符串必须小于等于最大长度”的参数 验证 - * @param fieldName 参数名称 - * @param value 参数值 - * @param maxLength 校验允许的最大长度 - */ - public ParameterValidator addLengthMax(String fieldName, Object value, Integer maxLength) { - this.listParameter.add(new ParameterValidateItem(fieldName, EParameterValidateType.MUST_LENGTH_MAX, value, null, maxLength, null)); - return this; - } - - - /** - * 执行验证参数 - * @return 验证结果 - */ - public ParameterValidateResult validate() { - if(ListUtil.isNotNullOrEmpty((this.listParameter))) { - return this.checkParameterValidate(); - } - return new ParameterValidateResult(true, ""); - } - - private ParameterValidateResult checkParameterValidate() { - for (ParameterValidateItem item : this.listParameter) { - ParameterValidateResult result = this.checkParameterValidateItem(item); - if(result.getIsFiled()) { - return result; - } - } - return new ParameterValidateResult(true, ""); - } - private ParameterValidateResult checkParameterValidateItem(ParameterValidateItem item) { - Function<Object, Boolean> func = item.getValidateFunc(); - if(null != func) { - if(func.apply(item.getValue())) { - return new ParameterValidateResult(true, ""); - } else { - return new ParameterValidateResult(false, item.getFieldName()+item.getType().getDesc()); - } - } - switch (item.getType()) { - case NOT_NULLOREMPTY: - if(!ParameterValidator.checkNotNull(item.getValue())) { - return new ParameterValidateResult(false, item.getFieldName()+item.getType().getDesc()); - } - break; - - - - case MUST_ENUM: - if(!ParameterValidator.checkIsEnum(item.getValue(), item.getEnumType())) { - return new ParameterValidateResult(false, item.getFieldName()+item.getType().getDesc()+item.getEnumType().getName().replace(item.getEnumType().getPackage().getName()+".", "")+":"+item.getValue()); - } - break; - case MUST_IN_RANGE: - if(!ParameterValidator.checkInRange(item.getValue(), item.getRangeMin(), item.getRangeMax())) { - return new ParameterValidateResult(false, item.getFieldName()+item.getType().getDesc()+item.getEnumType().getTypeName()); - } - break; - default: - return this.checkMustGreaterLess(item); - } - return new ParameterValidateResult(true, ""); - } - private ParameterValidateResult checkMustGreaterLess(ParameterValidateItem item) { - switch (item.getType()) { - case MUST_GREATER: - if(!ParameterValidator.checkGreater(item.getValue(), item.getRangeMin())) { - return new ParameterValidateResult(false, item.getFieldName()+item.getType().getDesc()+item.getRangeMin().toString()); - } - break; - case MUST_GREATER_THAN: - if(!ParameterValidator.checkGreaterThan(item.getValue(), item.getRangeMin())) { - return new ParameterValidateResult(false, item.getFieldName()+item.getType().getDesc()+item.getRangeMin().toString()); - } - break; - case MUST_LESS: - if(!ParameterValidator.checkLess(item.getValue(), item.getRangeMax())) { - return new ParameterValidateResult(false, item.getFieldName()+item.getType().getDesc()+item.getRangeMax().toString()); - } - break; - case MUST_LESS_THAN: - if(!checkLessThan(item.getValue(), item.getRangeMax())) { - return new ParameterValidateResult(false, item.getFieldName()+item.getType().getDesc()+item.getRangeMax().toString()); - } - break; - default: - return this.checkDateTime(item); - } - return new ParameterValidateResult(true, ""); - } - private ParameterValidateResult checkDateTime(ParameterValidateItem item) { - switch (item.getType()) { - case MUST_DATE: - if(!ParameterValidator.checkIsMatch(item.getValue(), item.getType()) || !LocalDateTimeUtil.getDate(item.getValue().toString()).isAfter(LocalDateTimeUtil.DEFAULT_DATE)) { - return new ParameterValidateResult(false, item.getFieldName()+item.getType().getDesc()); - } - break; - case MUST_DATE_TIME: - if(!ParameterValidator.checkIsMatch(item.getValue(), item.getType()) || !LocalDateTimeUtil.getDateTime(item.getValue().toString()).isAfter(LocalDateTimeUtil.DEFAULT_DATETIME)) { - return new ParameterValidateResult(false, item.getFieldName()+item.getType().getDesc()); - } - break; - default: - return this.checkLength(item); - } - return new ParameterValidateResult(true, ""); - } - private ParameterValidateResult checkLength(ParameterValidateItem item) { - switch (item.getType()) { - case MUST_LENGTH_MIN: - String strMin = item.getRangeMin().toString(); - int minLength = Integer.valueOf(strMin); - if(null==item.getValue() || item.getValue().toString().length()<minLength) { - return new ParameterValidateResult(false, item.getFieldName()+item.getType().getDesc()+strMin); - } - break; - case MUST_LENGTH_MAX: - String strMax = item.getRangeMax().toString(); - int maxLength = Integer.valueOf(strMax); - if(null!=item.getValue() && item.getValue().toString().length()>maxLength) { - return new ParameterValidateResult(false, item.getFieldName()+item.getType().getDesc()+strMax); - } - break; - default: - return this.checkOther(item); - } - return new ParameterValidateResult(true, ""); - } - private ParameterValidateResult checkOther(ParameterValidateItem item) { - switch (item.getType()) { - case MUST_EMAIL: - case MUST_MOBILE_NUMBER: - case MUST_TELEPHONE_NUMBER: - case MUST_PHONE_NUMBER: - if(!ParameterValidator.checkIsMatch(item.getValue(), item.getType())) { - return new ParameterValidateResult(false, item.getFieldName()+item.getType().getDesc()); - } - break; - - case MUST_PASS_REGEX: - if (!checkIsMatch(item.getRegex(), item.getValue())) { - return new ParameterValidateResult(false, item.getFieldName() + item.getType().getDesc() + item.getRegex()); - } - break; - - default: - break; - } - return new ParameterValidateResult(true, ""); - } - - /** - * 验证传入参数“不为空”(非null且非空) - * @param value 参数值 - * @return 是否“不为空” - */ - public static Boolean checkNotNull(Object value) { - if(null == value) { - return false; - } - if(value instanceof String) { - String realValue = (String) value; - return realValue.replaceAll(ConstantFactory.STR_REGEX_SPACE, "").length()>0; - } else if(value instanceof List) { - List<?> realValue = (List)value; - return ListUtil.isNotNullOrEmpty(realValue); - } - return true; - } - - /** - * 验证传入参数是否“大于”传入最小值 - * @param value 参数值 - * @param minValue 校验允许的最小值 - * @return 是否“大于”最小值 - */ - public static Boolean checkGreater(Object value, Object minValue) { - if(null == value) { - return false; - } - if(value instanceof Integer || value instanceof Long || value instanceof Double || value instanceof BigDecimal) { - BigDecimal realValue = new BigDecimal(value.toString()); - BigDecimal realMin = new BigDecimal(minValue.toString()); - return realValue.compareTo(realMin)>0; - } else if(value instanceof Calendar) { - Calendar realValue = (Calendar)value; - Calendar realMin = (Calendar)minValue; - return realValue.compareTo(realMin)>0; - } else if(value instanceof LocalDateTime) { - LocalDateTime realValue = (LocalDateTime)value; - LocalDateTime realMin = (LocalDateTime)minValue; - return realValue.compareTo(realMin)>0; - } else if(value instanceof LocalDate) { - LocalDate realValue = (LocalDate)value; - LocalDate realMin = (LocalDate)minValue; - return realValue.compareTo(realMin)>0; - } - return true; - } - - /** - * 验证传入参数是否“大于等于”传入最小值 - * @param value 参数值 - * @param minValue 校验允许的最小值 - * @return 是否“大于等于”传入最小值 - */ - public static Boolean checkGreaterThan(Object value, Object minValue) { - if(null == value) { - return false; - } - if(value instanceof Integer || value instanceof Long || value instanceof Double || value instanceof BigDecimal) { - BigDecimal realValue = new BigDecimal(value.toString()); - BigDecimal realMin = new BigDecimal(minValue.toString()); - return realValue.compareTo(realMin)>=0; - }else if(value instanceof Calendar) { - Calendar realValue = (Calendar)value; - Calendar realMin = (Calendar)minValue; - return realValue.compareTo(realMin)>=0; - } else if(value instanceof LocalDateTime) { - LocalDateTime realValue = (LocalDateTime)value; - LocalDateTime realMin = (LocalDateTime)minValue; - return realValue.compareTo(realMin)>=0; - } else if(value instanceof LocalDate) { - LocalDate realValue = (LocalDate)value; - LocalDate realMin = (LocalDate)minValue; - return realValue.compareTo(realMin)>=0; - } - return true; - } - /** - * 验证传入参数是否“小于”传入最大值 - * @param value 参数值 - * @param maxValue 校验允许的最大值 - * @return 是否“小于”最大值 - */ - public static Boolean checkLess(Object value, Object maxValue) { - if(null == value) { - return true; - } - if(value instanceof Integer || value instanceof Long || value instanceof Double || value instanceof BigDecimal) { - BigDecimal realValue = new BigDecimal(value.toString()); - BigDecimal realMax = new BigDecimal(maxValue.toString()); - return realValue.compareTo(realMax)<0; - } else if(value instanceof Calendar) { - Calendar realValue = (Calendar)value; - Calendar realMax = (Calendar)maxValue; - return realValue.compareTo(realMax)<0; - } else if(value instanceof LocalDateTime) { - LocalDateTime realValue = (LocalDateTime)value; - LocalDateTime realMax = (LocalDateTime)maxValue; - return realValue.compareTo(realMax)<0; - } else if(value instanceof LocalDate) { - LocalDate realValue = (LocalDate)value; - LocalDate realMax = (LocalDate)maxValue; - return realValue.compareTo(realMax)<0; - } - return true; - } - /** - * 验证传入参数是否“小于等于”传入最小值 - * @param value 参数值 - * @param maxValue 校验允许的最大值 - * @return 是否“小于等于”传入最小值 - */ - public static Boolean checkLessThan(Object value, Object maxValue) { - if(null == value) { - return true; - } - if(value instanceof Integer || value instanceof Long || value instanceof Double || value instanceof BigDecimal) { - BigDecimal realValue = new BigDecimal(value.toString()); - BigDecimal realMax = new BigDecimal(maxValue.toString()); - return realValue.compareTo(realMax)<=0; - } else if(value instanceof Calendar) { - Calendar realValue = (Calendar)value; - Calendar realMax = (Calendar)maxValue; - return realValue.compareTo(realMax)<=0; - } else if(value instanceof LocalDateTime) { - LocalDateTime realValue = (LocalDateTime)value; - LocalDateTime realMax = (LocalDateTime)maxValue; - return realValue.compareTo(realMax)<=0; - } else if(value instanceof LocalDate) { - LocalDate realValue = (LocalDate)value; - LocalDate realMax = (LocalDate)maxValue; - return realValue.compareTo(realMax)<=0; - } - return true; - } - /** - * 验证传入参数是否符合指定“参数校验类型”格式 - * @param value 参数值 - * @param type 参数校验类型 - * @return 是否符合指定“参数校验类型”格式 - */ - public static Boolean checkIsMatch(Object value, EParameterValidateType type) { - Boolean result = false; - String realValue = String.valueOf(value); - switch (type) { - case MUST_DATE: - result = StringUtil.isMatch(realValue, ConstantFactory.REGEX_DATE); - break; - case MUST_DATE_TIME: - result = StringUtil.isMatch(realValue, ConstantFactory.REGEX_DATETIME); - break; - case MUST_EMAIL: - result = StringUtil.isEmail(realValue); - break; - case MUST_MOBILE_NUMBER: - result = StringUtil.isMobilePhone(realValue); - break; - case MUST_TELEPHONE_NUMBER: - result = StringUtil.isTelPhone(realValue); - break; - case MUST_PHONE_NUMBER: - result = (StringUtil.isTelPhone(realValue) || StringUtil.isMobilePhone(realValue)); - break; - default: - break; - } - return result; - } - /** - * 验证传入参数是否符合指定“参数校验类型”格式 - * @param regex 正则表达式 - * @param value 参数值 - * @return 是否符合指定“参数校验类型”格式 - */ - public static Boolean checkIsMatch(String regex, Object value) { - return StringUtil.isMatch(String.valueOf(value), regex); - } - /** - * 验证传入参数是否是指定类型的“有效枚举值” - * @param value 参数值 - * @param enumType 枚举类型 - * @param <T> 枚举类型 - * @return 是否是“有效枚举值” - */ - public static <T extends Enum<T>> Boolean checkIsEnum(Object value, Class<T> enumType) { - if(value instanceof String) { - return StringUtil.isEnum(enumType, value.toString()); - } else if(value instanceof Integer) { - return NumericUtil.isEnum(enumType, ((Integer) value)); - } - return false; - } - /** - * 验证传入参数值是否在指定“最大值”和“最小值”范围内 - * @param value 参数值 - * @param minValue 校验允许的最大值 - * @param maxValue 校验允许的最小值 - * @return 是否在指定“最大值”和“最小值”范围内 - */ - public static Boolean checkInRange(Object value, Object minValue, Object maxValue) { - if(null == value) { - return false; - } - if(value instanceof Integer || value instanceof Long || value instanceof Double || value instanceof BigDecimal) { - BigDecimal realValue = new BigDecimal(value.toString()); - BigDecimal realMin = new BigDecimal(minValue.toString()); - BigDecimal realMax = new BigDecimal(maxValue.toString()); - return (realValue.compareTo(realMin)>=0 && realValue.compareTo(realMax)<=0); - } else if(value instanceof Calendar) { - Calendar realValue = (Calendar)value; - Calendar realMin = (Calendar)minValue; - Calendar realMax = (Calendar)maxValue; - return (realValue.compareTo(realMin)>=0 && realValue.compareTo(realMax)<=0); - } - return true; - } -} \ No newline at end of file diff --git a/src/main/java/com/lunhan/xxx/entity/dto/KeyValueDTO.java b/src/main/java/com/lunhan/xxx/entity/dto/KeyValueDTO.java deleted file mode 100644 index 586081f..0000000 --- a/src/main/java/com/lunhan/xxx/entity/dto/KeyValueDTO.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.lunhan.xxx.entity.dto; - -/** - * 键值对 dto - * @author lin.liu - * @description 键值对 dto - * @date 2021/4/7 - **/ -public class KeyValueDTO { - private String key; - private String value; - - public String getKey() { - return key; - } - - public void setKey(String key) { - this.key = key; - } - - public String getValue() { - return value; - } - - public void setValue(String value) { - this.value = value; - } -} diff --git a/src/main/java/com/lunhan/xxx/entity/dto/NameSortDTO.java b/src/main/java/com/lunhan/xxx/entity/dto/NameSortDTO.java deleted file mode 100644 index 5bb29e9..0000000 --- a/src/main/java/com/lunhan/xxx/entity/dto/NameSortDTO.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.lunhan.xxx.entity.dto; - -public class NameSortDTO { - /** - * 名称 - */ - private String name; - /** - * 排序值 - */ - private Integer sort; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public Integer getSort() { - return sort; - } - - public void setSort(Integer sort) { - this.sort = sort; - } -} diff --git a/src/main/java/com/lunhan/xxx/entity/dto/NameSortIdDTO.java b/src/main/java/com/lunhan/xxx/entity/dto/NameSortIdDTO.java deleted file mode 100644 index 6747392..0000000 --- a/src/main/java/com/lunhan/xxx/entity/dto/NameSortIdDTO.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.lunhan.xxx.entity.dto; - -public class NameSortIdDTO { - private Long id; - /** - * 名称 - */ - private String name; - /** - * 排序值 - */ - private Integer sort; - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public Integer getSort() { - return sort; - } - - public void setSort(Integer sort) { - this.sort = sort; - } -} diff --git a/src/main/java/com/lunhan/xxx/entity/dto/NameValueDTO.java b/src/main/java/com/lunhan/xxx/entity/dto/NameValueDTO.java deleted file mode 100644 index 6272591..0000000 --- a/src/main/java/com/lunhan/xxx/entity/dto/NameValueDTO.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.lunhan.xxx.entity.dto; - -/** - * 名称-值 数据对象 - */ -public class NameValueDTO<T> { - /** - * 名称 - */ - private String name; - /** - * 值 - */ - private T value; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public T getValue() { - return value; - } - - public void setValue(T value) { - this.value = value; - } - - public NameValueDTO() { - } - - public NameValueDTO(String name, T value) { - this.name = name; - this.value = value; - } -} diff --git a/src/main/java/com/lunhan/xxx/entity/dto/OrderByDTO.java b/src/main/java/com/lunhan/xxx/entity/dto/OrderByDTO.java deleted file mode 100644 index 9539ee7..0000000 --- a/src/main/java/com/lunhan/xxx/entity/dto/OrderByDTO.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.lunhan.xxx.entity.dto; - -public class OrderByDTO { - /** - * 排序字段枚举(支持的枚举值请参照字段“ orderByEnum”说明中的枚举类型,无特殊说明使用通用排序枚举,“EOrderBy”) - */ - private Integer orderBy; - /** - * 是否升序排序 true=升序,不传或者其他任意值=降序(默认) - */ - private Boolean isAsc; - - public Integer getOrderBy() { - return orderBy; - } - - public void setOrderBy(Integer orderBy) { - this.orderBy = orderBy; - } - - public Boolean getIsAsc() { - return isAsc; - } - - public void setIsAsc(Boolean asc) { - isAsc = asc; - } -} - diff --git a/src/main/java/com/lunhan/xxx/entity/dto/PagerBasicDTO.java b/src/main/java/com/lunhan/xxx/entity/dto/PagerBasicDTO.java deleted file mode 100644 index 6165936..0000000 --- a/src/main/java/com/lunhan/xxx/entity/dto/PagerBasicDTO.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.lunhan.xxx.entity.dto; - -/** - * 分页基本属性 dto - * @Author lin.liu - * @Description 分页基本属性 dto - * @Date 2021/4/7 - **/ -public class PagerBasicDTO { - /** - * 最后一条记录的id - * @ignore - */ - private Long lastRowNo; - /** - * 页大小(每页返回的记录条数) - */ - private Integer limit; - /** - * 页号(第几页,从1开始) - */ - private Integer page; - - public Long getLastRowNo() { - return lastRowNo; - } - - public void setLastRowNo(Long lastRowNo) { - this.lastRowNo = lastRowNo; - } - - public Integer getLimit() { - return limit; - } - - public void setLimit(Integer limit) { - this.limit = limit; - } - - public Integer getPage() { - return page; - } - - public void setPage(Integer page) { - this.page = page; - } -} \ No newline at end of file diff --git a/src/main/java/com/lunhan/xxx/entity/dto/RequestDTO.java b/src/main/java/com/lunhan/xxx/entity/dto/RequestDTO.java deleted file mode 100644 index 7d4a200..0000000 --- a/src/main/java/com/lunhan/xxx/entity/dto/RequestDTO.java +++ /dev/null @@ -1,114 +0,0 @@ -package com.lunhan.xxx.entity.dto; - -import java.util.Map; - -public class RequestDTO { - private Map<String, String> requestDataMap; - private String businessCode; - private String approveCode; - private String conditionColumn; - private Long conditionValue; - private Long creator_id; - private String creator_name; - private Long listAppRover; - private Integer applyStatus; - private Long id; - private String comment; - private Integer type; - - public Integer getType() { - return type; - } - - public void setType(Integer type) { - this.type = type; - } - - public String getComment() { - return comment; - } - - public void setComment(String comment) { - this.comment = comment; - } - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public Integer getApplyStatus() { - return applyStatus; - } - - public void setApplyStatus(Integer applyStatus) { - this.applyStatus = applyStatus; - } - - public Long getListAppRover() { - return listAppRover; - } - - public void setListAppRover(Long listAppRover) { - this.listAppRover = listAppRover; - } - - public Long getCreator_id() { - return creator_id; - } - - public void setCreator_id(Long creator_id) { - this.creator_id = creator_id; - } - - public String getCreator_name() { - return creator_name; - } - - public void setCreator_name(String creator_name) { - this.creator_name = creator_name; - } - - public String getConditionColumn() { - return conditionColumn; - } - - public void setConditionColumn(String conditionColumn) { - this.conditionColumn = conditionColumn; - } - - public Long getConditionValue() { - return conditionValue; - } - - public void setConditionValue(Long conditionValue) { - this.conditionValue = conditionValue; - } - - public String getApproveCode() { - return approveCode; - } - - public void setApproveCode(String approveCode) { - this.approveCode = approveCode; - } - - public Map<String, String> getRequestDataMap() { - return requestDataMap; - } - - public void setRequestDataMap(Map<String, String> requestDataMap) { - this.requestDataMap = requestDataMap; - } - - public String getBusinessCode() { - return businessCode; - } - - public void setBusinessCode(String businessCode) { - this.businessCode = businessCode; - } -} diff --git a/src/main/java/com/lunhan/xxx/entity/dto/SearchBasicDTO.java b/src/main/java/com/lunhan/xxx/entity/dto/SearchBasicDTO.java deleted file mode 100644 index 66f23de..0000000 --- a/src/main/java/com/lunhan/xxx/entity/dto/SearchBasicDTO.java +++ /dev/null @@ -1,137 +0,0 @@ -package com.lunhan.xxx.entity.dto; - -import java.util.List; - -/** - * 分页查询基础 dto - * @Author lin.liu - * @Description 分页查询基础 dto - * @Date 2021/4/7 - **/ -public class SearchBasicDTO extends PagerBasicDTO { - /** - * 关键字 - */ - private String keywords; - /** - * 自增id列表 - */ - private List<Long> listId; - /** - * 数据状态 EState - */ - private Integer status; - /** - * 数据状态列表 - */ - private List<Integer> listStatus; - /** - * 数据创建时间-范围(eg: 2021-01-01 00:00:00 ~ 2021-01-01 23:59:59)" - */ - private String createTimeRange; - /** - * 数据创建时间-起始 - * @ignore - */ - private Long createTimeStart; - /** - * 数据创建时间-截止 - * @ignore - */ - private Long createTimeEnd; - /** - * 上次请求最后一条数据的id - */ - private Long lastId; - /** - * 排序列表 - */ - private List<OrderByDTO> orderBy; - - public String getKeywords() { - return keywords; - } - - public void setKeywords(String keywords) { - this.keywords = keywords; - } - - public List<Long> getListId() { - return listId; - } - - public void setListId(List<Long> listId) { - this.listId = listId; - } - - public Integer getStatus() { - return status; - } - - public void setStatus(Integer status) { - this.status = status; - } - - public List<Integer> getListStatus() { - return listStatus; - } - - public void setListStatus(List<Integer> listStatus) { - this.listStatus = listStatus; - } - - public String getCreateTimeRange() { - return createTimeRange; - } - - public void setCreateTimeRange(String createTimeRange) { - this.createTimeRange = createTimeRange; - } - - public Long getCreateTimeStart() { - return createTimeStart; - } - - public void setCreateTimeStart(Long createTimeStart) { - this.createTimeStart = createTimeStart; - } - - public Long getCreateTimeEnd() { - return createTimeEnd; - } - - public void setCreateTimeEnd(Long createTimeEnd) { - this.createTimeEnd = createTimeEnd; - } - - public Long getLastId() { - return lastId; - } - - public void setLastId(Long lastId) { - this.lastId = lastId; - } - - public List<OrderByDTO> getOrderBy() { - return orderBy; - } - - public void setOrderBy(List<OrderByDTO> orderBy) { - this.orderBy = orderBy; - } - - @Override - public String toString() { - return "SearchBasicDTO{" + - "keywords='" + keywords + '\'' + - ", listId=" + listId + - ", status=" + status + - ", listStatus=" + listStatus + - ", createTimeRange='" + createTimeRange + '\'' + - ", createTimeStart=" + createTimeStart + - ", createTimeEnd=" + createTimeEnd + - ", lastId=" + lastId + - ", orderBy='" + orderBy + '\'' + - '}'; - } -} diff --git a/src/main/java/com/lunhan/xxx/entity/dto/UploadResultVo.java b/src/main/java/com/lunhan/xxx/entity/dto/UploadResultVo.java deleted file mode 100644 index 80aeda9..0000000 --- a/src/main/java/com/lunhan/xxx/entity/dto/UploadResultVo.java +++ /dev/null @@ -1,88 +0,0 @@ -package com.lunhan.xxx.entity.dto; - -public class UploadResultVo { - /** - * 文件id,传参后原样输出,前端比对文件用,无实际意义。 - */ - private String fileId; - /** - * 原始文件名称 传参后原样输出 - */ - private String name; - /** - * 新文件名称(需要保存数据库的虚拟路径) - */ - private String newFileName; - /** - * 文件预览地址 - */ - private String newFileView; - /** - * 文件类型 - */ - private String fileType; - /** - * 文件媒体类型 - */ - private String contentType; - /** - * 文件大小(kb) - */ - private Long size; - - public String getFileId() { - return fileId; - } - - public void setFileId(String fileId) { - this.fileId = fileId; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getNewFileName() { - return newFileName; - } - - public void setNewFileName(String newFileName) { - this.newFileName = newFileName; - } - - public String getNewFileView() { - return newFileView; - } - - public void setNewFileView(String newFileView) { - this.newFileView = newFileView; - } - - public String getFileType() { - return fileType; - } - - public void setFileType(String fileType) { - this.fileType = fileType; - } - - public String getContentType() { - return contentType; - } - - public void setContentType(String contentType) { - this.contentType = contentType; - } - - public Long getSize() { - return size; - } - - public void setSize(Long size) { - this.size = size; - } -} \ No newline at end of file diff --git a/src/main/java/com/lunhan/xxx/entity/dto/UserInfoDto.java b/src/main/java/com/lunhan/xxx/entity/dto/UserInfoDto.java deleted file mode 100644 index ebd6e8b..0000000 --- a/src/main/java/com/lunhan/xxx/entity/dto/UserInfoDto.java +++ /dev/null @@ -1,178 +0,0 @@ -package com.lunhan.xxx.entity.dto; - -public class UserInfoDto { - /** - * 联系方式 - */ - private String contact; - /** - * 数据创建时间 - */ - private Long createTime; - private String createTimeView; - /** - * 联系邮箱 - */ - private String email; - /** - * 头像 - */ - private String headImg; - /** - * 自增id - */ - private Long id; - /** - * 昵称 - */ - private String nickName; - /** - * 密码 - */ - private String password; - /** - * 角色id - */ - private Long roleId; - /** - * 状态(EState) 正常=1,关闭=2 - */ - private Long status; - /** - * 数据最后更新时间 - */ - private String updateTime; - private String updateTimeView; - /** - * 用户名 - */ - private String userName; - /** - * 用户关联id,和“user_type”对应,如:客户id等 - */ - private Long userRelId; - /** - * 用户类型 EUserType - */ - private Long userType; - - public String getContact() { - return contact; - } - - public void setContact(String contact) { - this.contact = contact; - } - - public Long getCreateTime() { - return createTime; - } - - public void setCreateTime(Long createTime) { - this.createTime = createTime; - } - - public String getCreateTimeView() { - return createTimeView; - } - - public void setCreateTimeView(String createTimeView) { - this.createTimeView = createTimeView; - } - - public String getEmail() { - return email; - } - - public void setEmail(String email) { - this.email = email; - } - - public String getHeadImg() { - return headImg; - } - - public void setHeadImg(String headImg) { - this.headImg = headImg; - } - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getNickName() { - return nickName; - } - - public void setNickName(String nickName) { - this.nickName = nickName; - } - - public String getPassword() { - return password; - } - - public void setPassword(String password) { - this.password = password; - } - - public Long getRoleId() { - return roleId; - } - - public void setRoleId(Long roleId) { - this.roleId = roleId; - } - - public Long getStatus() { - return status; - } - - public void setStatus(Long status) { - this.status = status; - } - - public String getUpdateTime() { - return updateTime; - } - - public void setUpdateTime(String updateTime) { - this.updateTime = updateTime; - } - - public String getUpdateTimeView() { - return updateTimeView; - } - - public void setUpdateTimeView(String updateTimeView) { - this.updateTimeView = updateTimeView; - } - - public String getUserName() { - return userName; - } - - public void setUserName(String userName) { - this.userName = userName; - } - - public Long getUserRelId() { - return userRelId; - } - - public void setUserRelId(Long userRelId) { - this.userRelId = userRelId; - } - - public Long getUserType() { - return userType; - } - - public void setUserType(Long userType) { - this.userType = userType; - } -} diff --git a/src/main/java/com/lunhan/xxx/entity/enums/EDataChangeType.java b/src/main/java/com/lunhan/xxx/entity/enums/EDataChangeType.java deleted file mode 100644 index d8dc718..0000000 --- a/src/main/java/com/lunhan/xxx/entity/enums/EDataChangeType.java +++ /dev/null @@ -1,73 +0,0 @@ -package com.lunhan.xxx.entity.enums; - -import java.util.Arrays; -import java.util.Objects; - -/** - * 数据变更类型 通用枚举 - * @author linliu - * @date 2019-01-02 - */ -public enum EDataChangeType { - /** - * 新增 - */ - CREATE("新增", 1), - /** - * 修改 - */ - MODIFY("修改", 2), - /** - * 停用 - */ - DISABLED("停用", 3), - /** - * 启用 - */ - ENABLED("启用", 4), - /** - * 删除 - */ - DELETED("删除", 5); - - private String desc;//枚举描述 - private Integer value;//枚举值 - - public Integer getValue() { - return value; - } - public String getDesc() { - return desc; - } - - /** - * 构造方法 - * @param desc 枚举描述 - * @param value 枚举值 - */ - private EDataChangeType(String desc, Integer value) { - this.desc = desc; - this.value = value; - } - - /** - * 根据值获取枚举 - * - * @param value 枚举值 - * @return - */ - public static EDataChangeType getByValue(Integer value) { - return Arrays.stream(EDataChangeType.values()) - .filter(e -> Objects.equals(e.getValue(), value)) - .findAny() - .orElse(null); - } - - @Override - public String toString() { - return "EDataChangeType{" + - "desc='" + desc + '\'' + - ", value=" + value + - '}'; - } -} \ No newline at end of file diff --git a/src/main/java/com/lunhan/xxx/entity/enums/EExecuteType.java b/src/main/java/com/lunhan/xxx/entity/enums/EExecuteType.java deleted file mode 100644 index bc8cbc3..0000000 --- a/src/main/java/com/lunhan/xxx/entity/enums/EExecuteType.java +++ /dev/null @@ -1,63 +0,0 @@ -package com.lunhan.xxx.entity.enums; - -import java.util.Arrays; -import java.util.Objects; - -public enum EExecuteType { - /** - * 待执行 - */ - NOT_EXECUTE("待执行", 1), - /** - * 执行中 - */ - IN_EXECUTE("执行中", 2), - /** - * 已执行 - */ - YES_EXECUTE("已执行", 3), - /** - * 撤销 - */ - ANNUL_EXECUTE("撤销", 4); - private String desc;//枚举描述 - private Integer value;//枚举值 - - public Integer getValue() { - return value; - } - public String getDesc() { - return desc; - } - - /** - * 构造方法 - * @param desc 枚举描述 - * @param value 枚举值 - */ - private EExecuteType(String desc, Integer value) { - this.desc = desc; - this.value = value; - } - - /** - * 根据值获取枚举 - * - * @param value 枚举值 - * @return - */ - public static EExecuteType getByValue(Integer value) { - return Arrays.stream(EExecuteType.values()) - .filter(e -> Objects.equals(e.getValue(), value)) - .findAny() - .orElse(null); - } - - @Override - public String toString() { - return "EExecuteType{" + - "desc='" + desc + '\'' + - ", value=" + value + - '}'; - } -} diff --git a/src/main/java/com/lunhan/xxx/entity/enums/EHandleStatus.java b/src/main/java/com/lunhan/xxx/entity/enums/EHandleStatus.java deleted file mode 100644 index a377782..0000000 --- a/src/main/java/com/lunhan/xxx/entity/enums/EHandleStatus.java +++ /dev/null @@ -1,69 +0,0 @@ -package com.lunhan.xxx.entity.enums; - -import java.util.Arrays; -import java.util.Objects; - -/** - * 数据处理状态 通用枚举 - * @author lin.liu - * @date 2019-01-08 - */ -public enum EHandleStatus { - /** - * 待处理 - */ - AWAITING("待处理", 100), - /** - *处理中 - */ - PROCESSING("处理中", 101), - /** - * 已处理 - */ - SUCCESS("已处理", 200), - /** - * 处理失败 - */ - FAILED("处理失败", 300); - - private String desc;//枚举描述 - private Integer value;//枚举值 - - public Integer getValue() { - return value; - } - public String getDesc() { - return desc; - } - - /** - * 构造方法 - * @param desc 枚举描述 - * @param value 枚举值 - */ - EHandleStatus(String desc, Integer value) { - this.desc = desc; - this.value = value; - } - - /** - * 根据值获取枚举 - * - * @param value 枚举值 - * @return - */ - public static EHandleStatus getByValue(Integer value) { - return Arrays.stream(EHandleStatus.values()) - .filter(e -> Objects.equals(e.getValue(), value)) - .findAny() - .orElse(null); - } - - @Override - public String toString() { - return "EHandleStatus{" + - "desc='" + desc + '\'' + - ", value=" + value + - '}'; - } -} \ No newline at end of file diff --git a/src/main/java/com/lunhan/xxx/entity/enums/ELockValue.java b/src/main/java/com/lunhan/xxx/entity/enums/ELockValue.java deleted file mode 100644 index 469ed4f..0000000 --- a/src/main/java/com/lunhan/xxx/entity/enums/ELockValue.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.lunhan.xxx.entity.enums; - -public enum ELockValue { - /** - * 管理员变更 - */ - ADMIN_CHANGE -} diff --git a/src/main/java/com/lunhan/xxx/entity/enums/EMenuType.java b/src/main/java/com/lunhan/xxx/entity/enums/EMenuType.java deleted file mode 100644 index 00d7d9b..0000000 --- a/src/main/java/com/lunhan/xxx/entity/enums/EMenuType.java +++ /dev/null @@ -1,66 +0,0 @@ -package com.lunhan.xxx.entity.enums; - -import java.util.Arrays; -import java.util.Objects; - -/** - * 菜单类型 - */ -public enum EMenuType { - /** - * 目录=1, - */ - FOLDER("目录", 1), - /** - * 页面=2, - */ - PAGE("页面", 2), - ; - - /** - * 枚举描述 - */ - private String desc; - /** - * 枚举值 - */ - private Integer value; - - public Integer getValue() { - return value; - } - public String getDesc() { - return desc; - } - - /** - * 构造方法 - * @param desc 枚举描述 - * @param value 枚举值 - */ - EMenuType(String desc, Integer value) { - this.desc = desc; - this.value = value; - } - - /** - * 根据值获取枚举 - * - * @param value 枚举值 - * @return - */ - public static EMenuType getByValue(Integer value) { - return Arrays.stream(EMenuType.values()) - .filter(e -> Objects.equals(e.getValue(), value)) - .findAny() - .orElse(null); - } - - @Override - public String toString() { - return "EMenuType{" + - "desc='" + desc + '\'' + - ", value=" + value + - '}'; - } -} diff --git a/src/main/java/com/lunhan/xxx/entity/enums/EOperation.java b/src/main/java/com/lunhan/xxx/entity/enums/EOperation.java deleted file mode 100644 index 996b06d..0000000 --- a/src/main/java/com/lunhan/xxx/entity/enums/EOperation.java +++ /dev/null @@ -1,98 +0,0 @@ -package com.lunhan.xxx.entity.enums; - -import java.util.Arrays; -import java.util.Objects; - -/** - * 操作类型 - * @author linliu - * @date 2019-01-02 - */ -public enum EOperation { - /** - * 搜索 - */ - LIST("搜索", "list"), - /** - * 保存(新增+编辑) - */ - SAVE("保存(新增+编辑)", "save"), - /** - * 新增 - */ - ADD("新增", "add"), - /** - * 详情 - */ - DETAIL("详情", "detail"), - /** - * 修改 - */ - UPDATE("修改", "update"), - /** - * 停用 - */ - DISABLED("停用", "disable"), - /** - * 启用 - */ - ENABLED("启用", "enable"), - /** - * 删除 - */ - DELETED("删除", "delete"), - /** - * 导入 - */ - IMPORT("导入", "import"), - /** - * 导出 - */ - EXPORT("导出", "export"), - /** - * 打印 - */ - PRINT("打印", "print"), - ; - - private String desc;//枚举描述 - private String value;//枚举值 - - public String getValue() { - return value; - } - public String getDesc() { - return desc; - } - - /** - * 构造方法 - * @param desc 枚举描述 - * @param value 枚举值 - */ - EOperation(String desc, String value) { - this.desc = desc; - this.value = value; - } - - /** - * 根据值获取枚举 - * - * @param value 枚举值 - * @return - */ - public static EOperation getByValue(String value) { - return Arrays.stream(EOperation.values()) - .filter(e -> Objects.equals(e.getValue(), value)) - .findAny() - .orElse(null); - } - - @Override - public String toString() { - return "EOperation{" + - "desc='" + desc + '\'' + - ", value=" + value + - '}'; - } -} \ No newline at end of file diff --git a/src/main/java/com/lunhan/xxx/entity/enums/EOrderBy.java b/src/main/java/com/lunhan/xxx/entity/enums/EOrderBy.java deleted file mode 100644 index d163c22..0000000 --- a/src/main/java/com/lunhan/xxx/entity/enums/EOrderBy.java +++ /dev/null @@ -1,63 +0,0 @@ -package com.lunhan.xxx.entity.enums; - -import java.util.Arrays; -import java.util.Objects; - -/** - * 通用排序类型 枚举 - */ -public enum EOrderBy { - /** - * 自增id=1, - */ - ID("自增id", 1), - /** - * 创建时间=2, - */ - CREATE_TIME("创建时间", 2), - /** - * 更新时间=3, - */ - UPDATE_TIME("更新时间", 3); - - private String desc;//枚举描述 - private Integer value;//枚举值 - - public Integer getValue() { - return value; - } - public String getDesc() { - return desc; - } - - /** - * 构造方法 - * @param desc 枚举描述 - * @param value 枚举值 - */ - EOrderBy(String desc, Integer value) { - this.desc = desc; - this.value = value; - } - - /** - * 根据值获取枚举 - * - * @param value 枚举值 - * @return - */ - public static EOrderBy getByValue(Integer value) { - return Arrays.stream(EOrderBy.values()) - .filter(e -> Objects.equals(e.getValue(), value)) - .findAny() - .orElse(null); - } - - @Override - public String toString() { - return "EOrderBy{" + - "desc='" + desc + '\'' + - ", value=" + value + - '}'; - } -} diff --git a/src/main/java/com/lunhan/xxx/entity/enums/EParameterType.java b/src/main/java/com/lunhan/xxx/entity/enums/EParameterType.java deleted file mode 100644 index e7576f0..0000000 --- a/src/main/java/com/lunhan/xxx/entity/enums/EParameterType.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.lunhan.xxx.entity.enums; - -import java.util.Arrays; -import java.util.Objects; - -public enum EParameterType { - /** - * 固定值=1, - */ - CONSTANT("固定值", 1), - /** - * 范围=2, - */ - RANGE("范围", 2); - - private String desc;//枚举描述 - private Integer value;//枚举值 - - public Integer getValue() { - return value; - } - public String getDesc() { - return desc; - } - - /** - * 构造方法 - * @param desc 枚举描述 - * @param value 枚举值 - */ - EParameterType(String desc, Integer value) { - this.desc = desc; - this.value = value; - } - - /** - * 根据值获取枚举 - * - * @param value 枚举值 - * @return - */ - public static EParameterType getByValue(Integer value) { - return Arrays.stream(EParameterType.values()) - .filter(e -> Objects.equals(e.getValue(), value)) - .findAny() - .orElse(null); - } - - @Override - public String toString() { - return "EParameterType{" + - "desc='" + desc + '\'' + - ", value=" + value + - '}'; - } -} diff --git a/src/main/java/com/lunhan/xxx/entity/enums/ESex.java b/src/main/java/com/lunhan/xxx/entity/enums/ESex.java deleted file mode 100644 index beec2ef..0000000 --- a/src/main/java/com/lunhan/xxx/entity/enums/ESex.java +++ /dev/null @@ -1,66 +0,0 @@ -package com.lunhan.xxx.entity.enums; - -import java.util.Arrays; -import java.util.Objects; - -public enum ESex { - /** - * 男=1, - */ - MALE("男", 1), - /** - * 女=2, - */ - FEMALE("女", 2), - /** - * 其他=3, - */ - OTHER("其他", 3); - - /** - * 枚举描述 - */ - private String desc; - /** - * 枚举值 - */ - private Integer value; - - public Integer getValue() { - return value; - } - public String getDesc() { - return desc; - } - - /** - * 构造方法 - * @param desc 枚举描述 - * @param value 枚举值 - */ - ESex(String desc, Integer value) { - this.desc = desc; - this.value = value; - } - - /** - * 根据值获取枚举 - * - * @param value 枚举值 - * @return - */ - public static ESex getByValue(Integer value) { - return Arrays.stream(ESex.values()) - .filter(e -> Objects.equals(e.getValue(), value)) - .findAny() - .orElse(null); - } - - @Override - public String toString() { - return "ESex{" + - "desc='" + desc + '\'' + - ", value=" + value + - '}'; - } -} diff --git a/src/main/java/com/lunhan/xxx/entity/enums/ESortOrderBy.java b/src/main/java/com/lunhan/xxx/entity/enums/ESortOrderBy.java deleted file mode 100644 index 3da2aca..0000000 --- a/src/main/java/com/lunhan/xxx/entity/enums/ESortOrderBy.java +++ /dev/null @@ -1,67 +0,0 @@ -package com.lunhan.xxx.entity.enums; - -import java.util.Arrays; -import java.util.Objects; - -/** - * 带排序值的排序类型 枚举 - */ -public enum ESortOrderBy { - /** - * 自增id=1, - */ - ID("自增id", 1), - /** - * 创建时间=2, - */ - CREATE_TIME("创建时间", 2), - /** - * 更新时间=3, - */ - UPDATE_TIME("更新时间", 3), - /** - * 排序值=4, - */ - SORT("排序值", 4); - - private String desc;//枚举描述 - private Integer value;//枚举值 - - public Integer getValue() { - return value; - } - public String getDesc() { - return desc; - } - - /** - * 构造方法 - * @param desc 枚举描述 - * @param value 枚举值 - */ - ESortOrderBy(String desc, Integer value) { - this.desc = desc; - this.value = value; - } - - /** - * 根据值获取枚举 - * - * @param value 枚举值 - * @return - */ - public static ESortOrderBy getByValue(Integer value) { - return Arrays.stream(ESortOrderBy.values()) - .filter(e -> Objects.equals(e.getValue(), value)) - .findAny() - .orElse(null); - } - - @Override - public String toString() { - return "ESortOrderBy{" + - "desc='" + desc + '\'' + - ", value=" + value + - '}'; - } -} diff --git a/src/main/java/com/lunhan/xxx/entity/enums/EState.java b/src/main/java/com/lunhan/xxx/entity/enums/EState.java deleted file mode 100644 index 8126274..0000000 --- a/src/main/java/com/lunhan/xxx/entity/enums/EState.java +++ /dev/null @@ -1,69 +0,0 @@ -package com.lunhan.xxx.entity.enums; - -import java.util.Arrays; -import java.util.Objects; - -/** - * 状态 枚举 - */ -public enum EState { - /** - * 正常=1, - */ - NORMAL("正常", 1), - /** - * 关闭/停用=2, - */ - DISABLED("关闭/停用", 2), - /** - * 删除=3, - */ - DELETED("删除", 3); - - /** - * 枚举描述 - */ - private String desc; - /** - * 枚举值 - */ - private Integer value; - - public Integer getValue() { - return value; - } - public String getDesc() { - return desc; - } - - /** - * 构造方法 - * @param desc 枚举描述 - * @param value 枚举值 - */ - EState(String desc, Integer value) { - this.desc = desc; - this.value = value; - } - - /** - * 根据值获取枚举 - * - * @param value 枚举值 - * @return - */ - public static EState getByValue(Integer value) { - return Arrays.stream(EState.values()) - .filter(e -> Objects.equals(e.getValue(), value)) - .findAny() - .orElse(null); - } - - @Override - public String toString() { - return "EState{" + - "desc='" + desc + '\'' + - ", value=" + value + - '}'; - } -} diff --git a/src/main/java/com/lunhan/xxx/entity/enums/EUserType.java b/src/main/java/com/lunhan/xxx/entity/enums/EUserType.java deleted file mode 100644 index 0e8a087..0000000 --- a/src/main/java/com/lunhan/xxx/entity/enums/EUserType.java +++ /dev/null @@ -1,61 +0,0 @@ -package com.lunhan.xxx.entity.enums; - -import java.util.Arrays; -import java.util.Objects; - -/** - * 用户类型 枚举 - */ -public enum EUserType { - /** - * 超级管理员=1, - */ - ADMIN("超级管理员", 1), - /** - * 普通管理员=2, - */ - ADMIN_USER("普通管理员", 2), - - ; - - private String desc;//枚举描述 - private Integer value;//枚举值 - - public Integer getValue() { - return value; - } - public String getDesc() { - return desc; - } - - /** - * 构造方法 - * @param desc 枚举描述 - * @param value 枚举值 - */ - EUserType(String desc, Integer value) { - this.desc = desc; - this.value = value; - } - - /** - * 根据值获取枚举 - * - * @param value 枚举值 - * @return - */ - public static EUserType getByValue(Integer value) { - return Arrays.stream(EUserType.values()) - .filter(e -> Objects.equals(e.getValue(), value)) - .findAny() - .orElse(null); - } - - @Override - public String toString() { - return "EUserType{" + - "desc='" + desc + '\'' + - ", value=" + value + - '}'; - } -} diff --git a/src/main/java/com/lunhan/xxx/entity/request/AdminSendMail.java b/src/main/java/com/lunhan/xxx/entity/request/AdminSendMail.java deleted file mode 100644 index b2b12d8..0000000 --- a/src/main/java/com/lunhan/xxx/entity/request/AdminSendMail.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.lunhan.xxx.entity.request; - -public class AdminSendMail { - - private String username; - private String password; - - public String getUsername() { - return username; - } - - public void setUsername(String username) { - this.username = username; - } - - public String getPassword() { - return password; - } - - public void setPassword(String password) { - this.password = password; - } -} \ No newline at end of file diff --git a/src/main/java/com/lunhan/xxx/entity/request/ReqChangePassword.java b/src/main/java/com/lunhan/xxx/entity/request/ReqChangePassword.java deleted file mode 100644 index 7ee7ffe..0000000 --- a/src/main/java/com/lunhan/xxx/entity/request/ReqChangePassword.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.lunhan.xxx.entity.request; - -public class ReqChangePassword { - /** - * 旧密码 - * @required - */ - private String oldPassword; - /** - * 新密码 - * @required - */ - private String newPassword; - - public String getOldPassword() { - return oldPassword; - } - - public void setOldPassword(String oldPassword) { - this.oldPassword = oldPassword; - } - - public String getNewPassword() { - return newPassword; - } - - public void setNewPassword(String newPassword) { - this.newPassword = newPassword; - } -} diff --git a/src/main/java/com/lunhan/xxx/entity/request/ReqListId.java b/src/main/java/com/lunhan/xxx/entity/request/ReqListId.java deleted file mode 100644 index 7d801a0..0000000 --- a/src/main/java/com/lunhan/xxx/entity/request/ReqListId.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.lunhan.xxx.entity.request; - -import java.util.List; - -public class ReqListId { - /** - * id列表 - * @required - */ - private List<Long> listId; - - public List<Long> getListId() { - return listId; - } - - public void setListId(List<Long> listId) { - this.listId = listId; - } -} diff --git a/src/main/java/com/lunhan/xxx/entity/request/ReqListSetSort.java b/src/main/java/com/lunhan/xxx/entity/request/ReqListSetSort.java deleted file mode 100644 index 13b1360..0000000 --- a/src/main/java/com/lunhan/xxx/entity/request/ReqListSetSort.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.lunhan.xxx.entity.request; - -import java.util.List; - -/** - * 批量设置顺序 对象 - */ -public class ReqListSetSort { - /** - * 设置顺序列表 - * @required - */ - private List<ReqSetSort> list; - - public List<ReqSetSort> getList() { - return list; - } - - public void setList(List<ReqSetSort> list) { - this.list = list; - } -} diff --git a/src/main/java/com/lunhan/xxx/entity/request/ReqListStatus.java b/src/main/java/com/lunhan/xxx/entity/request/ReqListStatus.java deleted file mode 100644 index 4757014..0000000 --- a/src/main/java/com/lunhan/xxx/entity/request/ReqListStatus.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.lunhan.xxx.entity.request; - -import java.util.List; - -public class ReqListStatus { - /** - * 状态列表 - */ - private List<Integer> listStatus; - - public List<Integer> getListStatus() { - return listStatus; - } - - public void setListStatus(List<Integer> listStatus) { - this.listStatus = listStatus; - } -} diff --git a/src/main/java/com/lunhan/xxx/entity/request/ReqNeedCode.java b/src/main/java/com/lunhan/xxx/entity/request/ReqNeedCode.java deleted file mode 100644 index 2b74cc9..0000000 --- a/src/main/java/com/lunhan/xxx/entity/request/ReqNeedCode.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.lunhan.xxx.entity.request; - - - -public class ReqNeedCode { - /** - * 编号 - * @required - */ - private String code; - - public String getCode() { - return code; - } - - public void setCode(String code) { - this.code = code; - } -} diff --git a/src/main/java/com/lunhan/xxx/entity/request/ReqNeedId.java b/src/main/java/com/lunhan/xxx/entity/request/ReqNeedId.java deleted file mode 100644 index de70a98..0000000 --- a/src/main/java/com/lunhan/xxx/entity/request/ReqNeedId.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.lunhan.xxx.entity.request; - -public class ReqNeedId { - /** - * 自增id - * @required - */ - private Long id; - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } -} diff --git a/src/main/java/com/lunhan/xxx/entity/request/ReqOperate.java b/src/main/java/com/lunhan/xxx/entity/request/ReqOperate.java deleted file mode 100644 index 24780fc..0000000 --- a/src/main/java/com/lunhan/xxx/entity/request/ReqOperate.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.lunhan.xxx.entity.request; - -public class ReqOperate { - /** - * 业务id - * @required - */ - private Long id; - /** - * 操作备注 - * @required - */ - private String comment; - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getComment() { - return comment; - } - - public void setComment(String comment) { - this.comment = comment; - } -} diff --git a/src/main/java/com/lunhan/xxx/entity/request/ReqSetSort.java b/src/main/java/com/lunhan/xxx/entity/request/ReqSetSort.java deleted file mode 100644 index f6a7256..0000000 --- a/src/main/java/com/lunhan/xxx/entity/request/ReqSetSort.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.lunhan.xxx.entity.request; - -public class ReqSetSort { - /** - * 自增id - * @required - */ - private Long id; - /** - * 排序值 - * @required - */ - private Integer sort; - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public Integer getSort() { - return sort; - } - - public void setSort(Integer sort) { - this.sort = sort; - } -} diff --git a/src/main/java/com/lunhan/xxx/entity/request/ReqUserLogin.java b/src/main/java/com/lunhan/xxx/entity/request/ReqUserLogin.java deleted file mode 100644 index 4544241..0000000 --- a/src/main/java/com/lunhan/xxx/entity/request/ReqUserLogin.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.lunhan.xxx.entity.request; - -public class ReqUserLogin { - /** - * 登录账户 - * @required - */ - private String userName; - /** - * 密码 - * @required - */ - private String password; - - public String getUserName() { - return userName; - } - - public void setUserName(String userName) { - this.userName = userName; - } - - public String getPassword() { - return password; - } - - public void setPassword(String password) { - this.password = password; - } -} diff --git a/src/main/java/com/lunhan/xxx/entity/request/adminmenu/ReqCreateAdminMenu.java b/src/main/java/com/lunhan/xxx/entity/request/adminmenu/ReqCreateAdminMenu.java deleted file mode 100644 index 3c859a2..0000000 --- a/src/main/java/com/lunhan/xxx/entity/request/adminmenu/ReqCreateAdminMenu.java +++ /dev/null @@ -1,64 +0,0 @@ -/** -# __----~~~~~~~~~~~------___ -# . . ~~//====...... __--~ ~~ -# -. \_|// |||\\ ~~~~~~::::... /~ -# ___-==_ _-~o~ \/ ||| \\ _/~~- -# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ -# _-~~ .=~ | \\-_ '-~7 /- / || \ / -# .~ .~ | \\ -_ / /- / || \ / -# / ____ / | \\ ~-_/ /|- _/ .|| \ / -# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ -# ' ~-| /| |-~\~~ __--~~ -# |-~~-_/ | | ~\_ _-~ /\ -# / \ \__ \/~ \__ -# _--~ _/ | .-~~____--~-/ ~~==. -# ((->/~ '.|||' -_| ~~-/ , . _|| -# -_ ~\ ~~---l__i__i__i--~~_/ -# _-~-__ ~) \--______________--~~ -# //.-~~~-~_--~- |-------~~~~~~~~ -# //.-~~~--\ -# 神兽保佑 -# 永无BUG! -*/ -package com.lunhan.xxx.entity.request.adminmenu; - -import lombok.Data; - -/** - * 后台菜单 - * @author lin.liu - * @description 后台菜单 - */ -@Data -public class ReqCreateAdminMenu { - /** - * 类型 EMenuType - * @required - */ - private Integer type; - /** - * 父级ID - */ - private Long parentId; - /** - * 菜单名称 - * @required - */ - private String name; - /** - * 菜单标题 - */ - private String title; - /** - * 前端资源路径 - */ - private String url; - /** - * 排序值 - */ - private Integer sort; - /** - * 图标 - */ - private String icon; -} diff --git a/src/main/java/com/lunhan/xxx/entity/request/adminmenu/ReqModifyAdminMenu.java b/src/main/java/com/lunhan/xxx/entity/request/adminmenu/ReqModifyAdminMenu.java deleted file mode 100644 index ad635bb..0000000 --- a/src/main/java/com/lunhan/xxx/entity/request/adminmenu/ReqModifyAdminMenu.java +++ /dev/null @@ -1,73 +0,0 @@ -/** -# __----~~~~~~~~~~~------___ -# . . ~~//====...... __--~ ~~ -# -. \_|// |||\\ ~~~~~~::::... /~ -# ___-==_ _-~o~ \/ ||| \\ _/~~- -# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ -# _-~~ .=~ | \\-_ '-~7 /- / || \ / -# .~ .~ | \\ -_ / /- / || \ / -# / ____ / | \\ ~-_/ /|- _/ .|| \ / -# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ -# ' ~-| /| |-~\~~ __--~~ -# |-~~-_/ | | ~\_ _-~ /\ -# / \ \__ \/~ \__ -# _--~ _/ | .-~~____--~-/ ~~==. -# ((->/~ '.|||' -_| ~~-/ , . _|| -# -_ ~\ ~~---l__i__i__i--~~_/ -# _-~-__ ~) \--______________--~~ -# //.-~~~-~_--~- |-------~~~~~~~~ -# //.-~~~--\ -# 神兽保佑 -# 永无BUG! -*/ -package com.lunhan.xxx.entity.request.adminmenu; - -import lombok.Data; - -/** - * 后台菜单 - * @author lin.liu - * @description 后台菜单 - */ -@Data -public class ReqModifyAdminMenu { - /** - * 主键 - * @required - */ - private Long id; - /** - * 类型 EMenuType - * @required - */ - private Integer type; - /** - * 父级ID - */ - private Long parentId; - /** - * 菜单名称 - * @required - */ - private String name; - /** - * 菜单标题 - */ - private String title; - /** - * 前端资源路径 - */ - private String url; - /** - * 排序值 - */ - private Integer sort; - /** - * 图标 - */ - private String icon; - /** - * 状态 EState - */ - private Integer status; -} diff --git a/src/main/java/com/lunhan/xxx/entity/request/adminmenus/ReqCreateAdminMenus.java b/src/main/java/com/lunhan/xxx/entity/request/adminmenus/ReqCreateAdminMenus.java deleted file mode 100644 index 6e94fd8..0000000 --- a/src/main/java/com/lunhan/xxx/entity/request/adminmenus/ReqCreateAdminMenus.java +++ /dev/null @@ -1,61 +0,0 @@ -/** -# __----~~~~~~~~~~~------___ -# . . ~~//====...... __--~ ~~ -# -. \_|// |||\\ ~~~~~~::::... /~ -# ___-==_ _-~o~ \/ ||| \\ _/~~- -# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ -# _-~~ .=~ | \\-_ '-~7 /- / || \ / -# .~ .~ | \\ -_ / /- / || \ / -# / ____ / | \\ ~-_/ /|- _/ .|| \ / -# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ -# ' ~-| /| |-~\~~ __--~~ -# |-~~-_/ | | ~\_ _-~ /\ -# / \ \__ \/~ \__ -# _--~ _/ | .-~~____--~-/ ~~==. -# ((->/~ '.|||' -_| ~~-/ , . _|| -# -_ ~\ ~~---l__i__i__i--~~_/ -# _-~-__ ~) \--______________--~~ -# //.-~~~-~_--~- |-------~~~~~~~~ -# //.-~~~--\ -# 神兽保佑 -# 永无BUG! -*/ -package com.lunhan.xxx.entity.request.adminmenus; - -import lombok.Data; - -/** - * 菜单信息 - * @author lin.liu - */ -@Data -public class ReqCreateAdminMenus { - /** - * 父级id - */ - private Long parentId; - /** - * 菜单名称 - */ - private String name; - /** - * 菜单标题 - */ - private String title; - /** - * 前端资源路径 - */ - private String uri; - /** - * 菜单层级 - */ - private Integer level; - /** - * 排序值 - */ - private Integer sort; - /** - * 图标 - */ - private String icon; -} diff --git a/src/main/java/com/lunhan/xxx/entity/request/adminmenus/ReqModifyAdminMenus.java b/src/main/java/com/lunhan/xxx/entity/request/adminmenus/ReqModifyAdminMenus.java deleted file mode 100644 index b80e172..0000000 --- a/src/main/java/com/lunhan/xxx/entity/request/adminmenus/ReqModifyAdminMenus.java +++ /dev/null @@ -1,69 +0,0 @@ -/** -# __----~~~~~~~~~~~------___ -# . . ~~//====...... __--~ ~~ -# -. \_|// |||\\ ~~~~~~::::... /~ -# ___-==_ _-~o~ \/ ||| \\ _/~~- -# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ -# _-~~ .=~ | \\-_ '-~7 /- / || \ / -# .~ .~ | \\ -_ / /- / || \ / -# / ____ / | \\ ~-_/ /|- _/ .|| \ / -# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ -# ' ~-| /| |-~\~~ __--~~ -# |-~~-_/ | | ~\_ _-~ /\ -# / \ \__ \/~ \__ -# _--~ _/ | .-~~____--~-/ ~~==. -# ((->/~ '.|||' -_| ~~-/ , . _|| -# -_ ~\ ~~---l__i__i__i--~~_/ -# _-~-__ ~) \--______________--~~ -# //.-~~~-~_--~- |-------~~~~~~~~ -# //.-~~~--\ -# 神兽保佑 -# 永无BUG! -*/ -package com.lunhan.xxx.entity.request.adminmenus; - -import lombok.Data; - -/** - * 菜单信息 - * @author lin.liu - */ -@Data -public class ReqModifyAdminMenus { - /** - * 主键id - */ - private Long id; - /** - * 父级id - */ - private Long parentId; - /** - * 菜单名称 - */ - private String name; - /** - * 菜单标题 - */ - private String title; - /** - * 前端资源路径 - */ - private String uri; - /** - * 菜单层级 - */ - private Integer level; - /** - * 排序值 - */ - private Integer sort; - /** - * 图标 - */ - private String icon; - /** - * 状态 EState - */ - private Integer status; -} diff --git a/src/main/java/com/lunhan/xxx/entity/request/adminpermission/ReqCreateAdminPermission.java b/src/main/java/com/lunhan/xxx/entity/request/adminpermission/ReqCreateAdminPermission.java deleted file mode 100644 index 7a84831..0000000 --- a/src/main/java/com/lunhan/xxx/entity/request/adminpermission/ReqCreateAdminPermission.java +++ /dev/null @@ -1,58 +0,0 @@ -/** -# __----~~~~~~~~~~~------___ -# . . ~~//====...... __--~ ~~ -# -. \_|// |||\\ ~~~~~~::::... /~ -# ___-==_ _-~o~ \/ ||| \\ _/~~- -# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ -# _-~~ .=~ | \\-_ '-~7 /- / || \ / -# .~ .~ | \\ -_ / /- / || \ / -# / ____ / | \\ ~-_/ /|- _/ .|| \ / -# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ -# ' ~-| /| |-~\~~ __--~~ -# |-~~-_/ | | ~\_ _-~ /\ -# / \ \__ \/~ \__ -# _--~ _/ | .-~~____--~-/ ~~==. -# ((->/~ '.|||' -_| ~~-/ , . _|| -# -_ ~\ ~~---l__i__i__i--~~_/ -# _-~-__ ~) \--______________--~~ -# //.-~~~-~_--~- |-------~~~~~~~~ -# //.-~~~--\ -# 神兽保佑 -# 永无BUG! -*/ -package com.lunhan.xxx.entity.request.adminpermission; - -import lombok.Data; - -/** - * 后台用户权限表 - * @author lin.liu - * @description 后台用户权限表 - */ -@Data -public class ReqCreateAdminPermission { - /** - * 权限值 - */ - private String sn; - /** - * 菜单id - */ - private Long menuId; - /** - * 前端资源url - */ - private String menuUrl; - /** - * 名称 - */ - private String name; - /** - * 图标 - */ - private String icon; - /** - * 权限类型 EOperation - */ - private String type; -} diff --git a/src/main/java/com/lunhan/xxx/entity/request/adminpermission/ReqModifyAdminPermission.java b/src/main/java/com/lunhan/xxx/entity/request/adminpermission/ReqModifyAdminPermission.java deleted file mode 100644 index 3d62265..0000000 --- a/src/main/java/com/lunhan/xxx/entity/request/adminpermission/ReqModifyAdminPermission.java +++ /dev/null @@ -1,66 +0,0 @@ -/** -# __----~~~~~~~~~~~------___ -# . . ~~//====...... __--~ ~~ -# -. \_|// |||\\ ~~~~~~::::... /~ -# ___-==_ _-~o~ \/ ||| \\ _/~~- -# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ -# _-~~ .=~ | \\-_ '-~7 /- / || \ / -# .~ .~ | \\ -_ / /- / || \ / -# / ____ / | \\ ~-_/ /|- _/ .|| \ / -# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ -# ' ~-| /| |-~\~~ __--~~ -# |-~~-_/ | | ~\_ _-~ /\ -# / \ \__ \/~ \__ -# _--~ _/ | .-~~____--~-/ ~~==. -# ((->/~ '.|||' -_| ~~-/ , . _|| -# -_ ~\ ~~---l__i__i__i--~~_/ -# _-~-__ ~) \--______________--~~ -# //.-~~~-~_--~- |-------~~~~~~~~ -# //.-~~~--\ -# 神兽保佑 -# 永无BUG! -*/ -package com.lunhan.xxx.entity.request.adminpermission; - -import lombok.Data; - -/** - * 后台用户权限表 - * @author lin.liu - * @description 后台用户权限表 - */ -@Data -public class ReqModifyAdminPermission { - /** - * 主键 - */ - private Long id; - /** - * 权限值 - */ - private String sn; - /** - * 菜单id - */ - private Long menuId; - /** - * 前端资源url - */ - private String menuUrl; - /** - * 名称 - */ - private String name; - /** - * 图标 - */ - private String icon; - /** - * 权限类型 EOperation - */ - private String type; - /** - * 状态 EState - */ - private Integer status; -} diff --git a/src/main/java/com/lunhan/xxx/entity/request/adminrole/ReqCreateAdminRole.java b/src/main/java/com/lunhan/xxx/entity/request/adminrole/ReqCreateAdminRole.java deleted file mode 100644 index 16b39b8..0000000 --- a/src/main/java/com/lunhan/xxx/entity/request/adminrole/ReqCreateAdminRole.java +++ /dev/null @@ -1,46 +0,0 @@ -/** -# __----~~~~~~~~~~~------___ -# . . ~~//====...... __--~ ~~ -# -. \_|// |||\\ ~~~~~~::::... /~ -# ___-==_ _-~o~ \/ ||| \\ _/~~- -# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ -# _-~~ .=~ | \\-_ '-~7 /- / || \ / -# .~ .~ | \\ -_ / /- / || \ / -# / ____ / | \\ ~-_/ /|- _/ .|| \ / -# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ -# ' ~-| /| |-~\~~ __--~~ -# |-~~-_/ | | ~\_ _-~ /\ -# / \ \__ \/~ \__ -# _--~ _/ | .-~~____--~-/ ~~==. -# ((->/~ '.|||' -_| ~~-/ , . _|| -# -_ ~\ ~~---l__i__i__i--~~_/ -# _-~-__ ~) \--______________--~~ -# //.-~~~-~_--~- |-------~~~~~~~~ -# //.-~~~--\ -# 神兽保佑 -# 永无BUG! -*/ -package com.lunhan.xxx.entity.request.adminrole; - -import lombok.Data; - -/** - * 后台用户角色表 - * @author lin.liu - * @description 后台用户角色表 - */ -@Data -public class ReqCreateAdminRole { - /** - * 角色名称 - */ - private String name; - /** - * 描述 - */ - private String description; - /** - * 排序值 - */ - private Integer sort; -} diff --git a/src/main/java/com/lunhan/xxx/entity/request/adminrole/ReqModifyAdminRole.java b/src/main/java/com/lunhan/xxx/entity/request/adminrole/ReqModifyAdminRole.java deleted file mode 100644 index 7e524e3..0000000 --- a/src/main/java/com/lunhan/xxx/entity/request/adminrole/ReqModifyAdminRole.java +++ /dev/null @@ -1,54 +0,0 @@ -/** -# __----~~~~~~~~~~~------___ -# . . ~~//====...... __--~ ~~ -# -. \_|// |||\\ ~~~~~~::::... /~ -# ___-==_ _-~o~ \/ ||| \\ _/~~- -# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ -# _-~~ .=~ | \\-_ '-~7 /- / || \ / -# .~ .~ | \\ -_ / /- / || \ / -# / ____ / | \\ ~-_/ /|- _/ .|| \ / -# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ -# ' ~-| /| |-~\~~ __--~~ -# |-~~-_/ | | ~\_ _-~ /\ -# / \ \__ \/~ \__ -# _--~ _/ | .-~~____--~-/ ~~==. -# ((->/~ '.|||' -_| ~~-/ , . _|| -# -_ ~\ ~~---l__i__i__i--~~_/ -# _-~-__ ~) \--______________--~~ -# //.-~~~-~_--~- |-------~~~~~~~~ -# //.-~~~--\ -# 神兽保佑 -# 永无BUG! -*/ -package com.lunhan.xxx.entity.request.adminrole; - -import lombok.Data; - -/** - * 后台用户角色表 - * @author lin.liu - * @description 后台用户角色表 - */ -@Data -public class ReqModifyAdminRole { - /** - * 主键 - */ - private Long id; - /** - * 角色名称 - */ - private String name; - /** - * 描述 - */ - private String description; - /** - * 状态 EState - */ - private Integer status; - /** - * 排序值 - */ - private Integer sort; -} diff --git a/src/main/java/com/lunhan/xxx/entity/request/adminrolemenurelation/ReqCreateAdminRoleMenuRelation.java b/src/main/java/com/lunhan/xxx/entity/request/adminrolemenurelation/ReqCreateAdminRoleMenuRelation.java deleted file mode 100644 index b2f2766..0000000 --- a/src/main/java/com/lunhan/xxx/entity/request/adminrolemenurelation/ReqCreateAdminRoleMenuRelation.java +++ /dev/null @@ -1,42 +0,0 @@ -/** -# __----~~~~~~~~~~~------___ -# . . ~~//====...... __--~ ~~ -# -. \_|// |||\\ ~~~~~~::::... /~ -# ___-==_ _-~o~ \/ ||| \\ _/~~- -# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ -# _-~~ .=~ | \\-_ '-~7 /- / || \ / -# .~ .~ | \\ -_ / /- / || \ / -# / ____ / | \\ ~-_/ /|- _/ .|| \ / -# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ -# ' ~-| /| |-~\~~ __--~~ -# |-~~-_/ | | ~\_ _-~ /\ -# / \ \__ \/~ \__ -# _--~ _/ | .-~~____--~-/ ~~==. -# ((->/~ '.|||' -_| ~~-/ , . _|| -# -_ ~\ ~~---l__i__i__i--~~_/ -# _-~-__ ~) \--______________--~~ -# //.-~~~-~_--~- |-------~~~~~~~~ -# //.-~~~--\ -# 神兽保佑 -# 永无BUG! -*/ -package com.lunhan.xxx.entity.request.adminrolemenurelation; - -import lombok.Data; - -/** - * 后台角色菜单关系表 - * @author lin.liu - * @description 后台角色菜单关系表 - */ -@Data -public class ReqCreateAdminRoleMenuRelation { - /** - * 角色id - */ - private Long roleId; - /** - * 菜单id - */ - private Long menuId; -} diff --git a/src/main/java/com/lunhan/xxx/entity/request/adminrolemenurelation/ReqModifyAdminRoleMenuRelation.java b/src/main/java/com/lunhan/xxx/entity/request/adminrolemenurelation/ReqModifyAdminRoleMenuRelation.java deleted file mode 100644 index 95be2a7..0000000 --- a/src/main/java/com/lunhan/xxx/entity/request/adminrolemenurelation/ReqModifyAdminRoleMenuRelation.java +++ /dev/null @@ -1,46 +0,0 @@ -/** -# __----~~~~~~~~~~~------___ -# . . ~~//====...... __--~ ~~ -# -. \_|// |||\\ ~~~~~~::::... /~ -# ___-==_ _-~o~ \/ ||| \\ _/~~- -# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ -# _-~~ .=~ | \\-_ '-~7 /- / || \ / -# .~ .~ | \\ -_ / /- / || \ / -# / ____ / | \\ ~-_/ /|- _/ .|| \ / -# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ -# ' ~-| /| |-~\~~ __--~~ -# |-~~-_/ | | ~\_ _-~ /\ -# / \ \__ \/~ \__ -# _--~ _/ | .-~~____--~-/ ~~==. -# ((->/~ '.|||' -_| ~~-/ , . _|| -# -_ ~\ ~~---l__i__i__i--~~_/ -# _-~-__ ~) \--______________--~~ -# //.-~~~-~_--~- |-------~~~~~~~~ -# //.-~~~--\ -# 神兽保佑 -# 永无BUG! -*/ -package com.lunhan.xxx.entity.request.adminrolemenurelation; - -import lombok.Data; - -/** - * 后台角色菜单关系表 - * @author lin.liu - * @description 后台角色菜单关系表 - */ -@Data -public class ReqModifyAdminRoleMenuRelation { - /** - * 主键 - */ - private Long id; - /** - * 角色id - */ - private Long roleId; - /** - * 菜单id - */ - private Long menuId; -} diff --git a/src/main/java/com/lunhan/xxx/entity/request/adminrolemenurelation/ReqSetListMenu4Role.java b/src/main/java/com/lunhan/xxx/entity/request/adminrolemenurelation/ReqSetListMenu4Role.java deleted file mode 100644 index 3aba0b8..0000000 --- a/src/main/java/com/lunhan/xxx/entity/request/adminrolemenurelation/ReqSetListMenu4Role.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.lunhan.xxx.entity.request.adminrolemenurelation; - -import lombok.Data; - -import java.util.List; - -@Data -public class ReqSetListMenu4Role { - /** - * 角色id - * @required - */ - private Long id; - /** - * 菜单列表 - * @required - **/ - private List<Long> listMenu; - /** - * 权限列表 - * @required - **/ - private List<Long> listPermission; -} diff --git a/src/main/java/com/lunhan/xxx/entity/request/adminrolemenurelation/ReqSetListRole4Admin.java b/src/main/java/com/lunhan/xxx/entity/request/adminrolemenurelation/ReqSetListRole4Admin.java deleted file mode 100644 index 2f1188d..0000000 --- a/src/main/java/com/lunhan/xxx/entity/request/adminrolemenurelation/ReqSetListRole4Admin.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.lunhan.xxx.entity.request.adminrolemenurelation; - -import lombok.Data; - -import java.util.List; - -@Data -public class ReqSetListRole4Admin { - /** - * 管理员id - * @required - */ - private Long id; - /** - * 角色列表 - * @required - **/ - private List<Long> listRole; -} diff --git a/src/main/java/com/lunhan/xxx/entity/request/adminrolepermissionrelation/ReqCreateAdminRolePermissionRelation.java b/src/main/java/com/lunhan/xxx/entity/request/adminrolepermissionrelation/ReqCreateAdminRolePermissionRelation.java deleted file mode 100644 index 17c25c2..0000000 --- a/src/main/java/com/lunhan/xxx/entity/request/adminrolepermissionrelation/ReqCreateAdminRolePermissionRelation.java +++ /dev/null @@ -1,42 +0,0 @@ -/** -# __----~~~~~~~~~~~------___ -# . . ~~//====...... __--~ ~~ -# -. \_|// |||\\ ~~~~~~::::... /~ -# ___-==_ _-~o~ \/ ||| \\ _/~~- -# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ -# _-~~ .=~ | \\-_ '-~7 /- / || \ / -# .~ .~ | \\ -_ / /- / || \ / -# / ____ / | \\ ~-_/ /|- _/ .|| \ / -# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ -# ' ~-| /| |-~\~~ __--~~ -# |-~~-_/ | | ~\_ _-~ /\ -# / \ \__ \/~ \__ -# _--~ _/ | .-~~____--~-/ ~~==. -# ((->/~ '.|||' -_| ~~-/ , . _|| -# -_ ~\ ~~---l__i__i__i--~~_/ -# _-~-__ ~) \--______________--~~ -# //.-~~~-~_--~- |-------~~~~~~~~ -# //.-~~~--\ -# 神兽保佑 -# 永无BUG! -*/ -package com.lunhan.xxx.entity.request.adminrolepermissionrelation; - -import lombok.Data; - -/** - * 后台角色权限关系表 - * @author lin.liu - * @description 后台角色权限关系表 - */ -@Data -public class ReqCreateAdminRolePermissionRelation { - /** - * 角色id - */ - private Long roleId; - /** - * 权限id - */ - private Long permissionId; -} diff --git a/src/main/java/com/lunhan/xxx/entity/request/adminrolepermissionrelation/ReqModifyAdminRolePermissionRelation.java b/src/main/java/com/lunhan/xxx/entity/request/adminrolepermissionrelation/ReqModifyAdminRolePermissionRelation.java deleted file mode 100644 index 0a1a95e..0000000 --- a/src/main/java/com/lunhan/xxx/entity/request/adminrolepermissionrelation/ReqModifyAdminRolePermissionRelation.java +++ /dev/null @@ -1,46 +0,0 @@ -/** -# __----~~~~~~~~~~~------___ -# . . ~~//====...... __--~ ~~ -# -. \_|// |||\\ ~~~~~~::::... /~ -# ___-==_ _-~o~ \/ ||| \\ _/~~- -# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ -# _-~~ .=~ | \\-_ '-~7 /- / || \ / -# .~ .~ | \\ -_ / /- / || \ / -# / ____ / | \\ ~-_/ /|- _/ .|| \ / -# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ -# ' ~-| /| |-~\~~ __--~~ -# |-~~-_/ | | ~\_ _-~ /\ -# / \ \__ \/~ \__ -# _--~ _/ | .-~~____--~-/ ~~==. -# ((->/~ '.|||' -_| ~~-/ , . _|| -# -_ ~\ ~~---l__i__i__i--~~_/ -# _-~-__ ~) \--______________--~~ -# //.-~~~-~_--~- |-------~~~~~~~~ -# //.-~~~--\ -# 神兽保佑 -# 永无BUG! -*/ -package com.lunhan.xxx.entity.request.adminrolepermissionrelation; - -import lombok.Data; - -/** - * 后台角色权限关系表 - * @author lin.liu - * @description 后台角色权限关系表 - */ -@Data -public class ReqModifyAdminRolePermissionRelation { - /** - * 主键 - */ - private Long id; - /** - * 角色id - */ - private Long roleId; - /** - * 权限id - */ - private Long permissionId; -} diff --git a/src/main/java/com/lunhan/xxx/entity/request/adminrolerelation/ReqCreateAdminRoleRelation.java b/src/main/java/com/lunhan/xxx/entity/request/adminrolerelation/ReqCreateAdminRoleRelation.java deleted file mode 100644 index 22c0778..0000000 --- a/src/main/java/com/lunhan/xxx/entity/request/adminrolerelation/ReqCreateAdminRoleRelation.java +++ /dev/null @@ -1,42 +0,0 @@ -/** -# __----~~~~~~~~~~~------___ -# . . ~~//====...... __--~ ~~ -# -. \_|// |||\\ ~~~~~~::::... /~ -# ___-==_ _-~o~ \/ ||| \\ _/~~- -# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ -# _-~~ .=~ | \\-_ '-~7 /- / || \ / -# .~ .~ | \\ -_ / /- / || \ / -# / ____ / | \\ ~-_/ /|- _/ .|| \ / -# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ -# ' ~-| /| |-~\~~ __--~~ -# |-~~-_/ | | ~\_ _-~ /\ -# / \ \__ \/~ \__ -# _--~ _/ | .-~~____--~-/ ~~==. -# ((->/~ '.|||' -_| ~~-/ , . _|| -# -_ ~\ ~~---l__i__i__i--~~_/ -# _-~-__ ~) \--______________--~~ -# //.-~~~-~_--~- |-------~~~~~~~~ -# //.-~~~--\ -# 神兽保佑 -# 永无BUG! -*/ -package com.lunhan.xxx.entity.request.adminrolerelation; - -import lombok.Data; - -/** - * 后台用户和角色关系表 - * @author lin.liu - * @description 后台用户和角色关系表 - */ -@Data -public class ReqCreateAdminRoleRelation { - /** - * 管理员id - */ - private Long adminId; - /** - * 角色id - */ - private Long roleId; -} diff --git a/src/main/java/com/lunhan/xxx/entity/request/adminrolerelation/ReqModifyAdminRoleRelation.java b/src/main/java/com/lunhan/xxx/entity/request/adminrolerelation/ReqModifyAdminRoleRelation.java deleted file mode 100644 index 7a9ad3f..0000000 --- a/src/main/java/com/lunhan/xxx/entity/request/adminrolerelation/ReqModifyAdminRoleRelation.java +++ /dev/null @@ -1,46 +0,0 @@ -/** -# __----~~~~~~~~~~~------___ -# . . ~~//====...... __--~ ~~ -# -. \_|// |||\\ ~~~~~~::::... /~ -# ___-==_ _-~o~ \/ ||| \\ _/~~- -# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ -# _-~~ .=~ | \\-_ '-~7 /- / || \ / -# .~ .~ | \\ -_ / /- / || \ / -# / ____ / | \\ ~-_/ /|- _/ .|| \ / -# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ -# ' ~-| /| |-~\~~ __--~~ -# |-~~-_/ | | ~\_ _-~ /\ -# / \ \__ \/~ \__ -# _--~ _/ | .-~~____--~-/ ~~==. -# ((->/~ '.|||' -_| ~~-/ , . _|| -# -_ ~\ ~~---l__i__i__i--~~_/ -# _-~-__ ~) \--______________--~~ -# //.-~~~-~_--~- |-------~~~~~~~~ -# //.-~~~--\ -# 神兽保佑 -# 永无BUG! -*/ -package com.lunhan.xxx.entity.request.adminrolerelation; - -import lombok.Data; - -/** - * 后台用户和角色关系表 - * @author lin.liu - * @description 后台用户和角色关系表 - */ -@Data -public class ReqModifyAdminRoleRelation { - /** - * 主键 - */ - private Long id; - /** - * 管理员id - */ - private Long adminId; - /** - * 角色id - */ - private Long roleId; -} diff --git a/src/main/java/com/lunhan/xxx/entity/request/adminuser/ReqAdminLogin.java b/src/main/java/com/lunhan/xxx/entity/request/adminuser/ReqAdminLogin.java deleted file mode 100644 index 35cd367..0000000 --- a/src/main/java/com/lunhan/xxx/entity/request/adminuser/ReqAdminLogin.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.lunhan.xxx.entity.request.adminuser; - -import lombok.Data; - -@Data -public class ReqAdminLogin { - /** - * 登录账户 - * @required - */ - private String userName; - /** - * 密码 - * @required - */ - private String password; -} diff --git a/src/main/java/com/lunhan/xxx/entity/request/adminuser/ReqCreateAdminUser.java b/src/main/java/com/lunhan/xxx/entity/request/adminuser/ReqCreateAdminUser.java deleted file mode 100644 index eba3d3b..0000000 --- a/src/main/java/com/lunhan/xxx/entity/request/adminuser/ReqCreateAdminUser.java +++ /dev/null @@ -1,62 +0,0 @@ -/** -# __----~~~~~~~~~~~------___ -# . . ~~//====...... __--~ ~~ -# -. \_|// |||\\ ~~~~~~::::... /~ -# ___-==_ _-~o~ \/ ||| \\ _/~~- -# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ -# _-~~ .=~ | \\-_ '-~7 /- / || \ / -# .~ .~ | \\ -_ / /- / || \ / -# / ____ / | \\ ~-_/ /|- _/ .|| \ / -# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ -# ' ~-| /| |-~\~~ __--~~ -# |-~~-_/ | | ~\_ _-~ /\ -# / \ \__ \/~ \__ -# _--~ _/ | .-~~____--~-/ ~~==. -# ((->/~ '.|||' -_| ~~-/ , . _|| -# -_ ~\ ~~---l__i__i__i--~~_/ -# _-~-__ ~) \--______________--~~ -# //.-~~~-~_--~- |-------~~~~~~~~ -# //.-~~~--\ -# 神兽保佑 -# 永无BUG! -*/ -package com.lunhan.xxx.entity.request.adminuser; - -import lombok.Data; - -/** - * 管理员帐号 - * @author lin.liu - * @description 管理员帐号 - */ -@Data -public class ReqCreateAdminUser { - /** - * 用户类型 EUserType - */ - private Integer userType; - /** - * 用户名 - */ - private String userName; - /** - * 密码 - */ - private String password; - /** - * 昵称 - */ - private String nickName; - /** - * 头像 - */ - private String headImg; - /** - * 联系方式 - */ - private String contact; - /** - * 联系邮箱 - */ - private String email; -} diff --git a/src/main/java/com/lunhan/xxx/entity/request/adminuser/ReqModifyAdminUser.java b/src/main/java/com/lunhan/xxx/entity/request/adminuser/ReqModifyAdminUser.java deleted file mode 100644 index 50a9df6..0000000 --- a/src/main/java/com/lunhan/xxx/entity/request/adminuser/ReqModifyAdminUser.java +++ /dev/null @@ -1,62 +0,0 @@ -/** -# __----~~~~~~~~~~~------___ -# . . ~~//====...... __--~ ~~ -# -. \_|// |||\\ ~~~~~~::::... /~ -# ___-==_ _-~o~ \/ ||| \\ _/~~- -# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ -# _-~~ .=~ | \\-_ '-~7 /- / || \ / -# .~ .~ | \\ -_ / /- / || \ / -# / ____ / | \\ ~-_/ /|- _/ .|| \ / -# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ -# ' ~-| /| |-~\~~ __--~~ -# |-~~-_/ | | ~\_ _-~ /\ -# / \ \__ \/~ \__ -# _--~ _/ | .-~~____--~-/ ~~==. -# ((->/~ '.|||' -_| ~~-/ , . _|| -# -_ ~\ ~~---l__i__i__i--~~_/ -# _-~-__ ~) \--______________--~~ -# //.-~~~-~_--~- |-------~~~~~~~~ -# //.-~~~--\ -# 神兽保佑 -# 永无BUG! -*/ -package com.lunhan.xxx.entity.request.adminuser; - -import lombok.Data; - -/** - * 管理员帐号 - * @author lin.liu - * @description 管理员帐号 - */ -@Data -public class ReqModifyAdminUser { - /** - * 主键 - */ - private Long id; - /** - * 用户类型 EUserType - */ - private Integer userType; - /** - * 昵称 - */ - private String nickName; - /** - * 头像 - */ - private String headImg; - /** - * 联系方式 - */ - private String contact; - /** - * 联系邮箱 - */ - private String email; - /** - * 状态 EState - */ - private Integer status; -} diff --git a/src/main/java/com/lunhan/xxx/entity/request/adminuser/ReqSetListRole4Admin.java b/src/main/java/com/lunhan/xxx/entity/request/adminuser/ReqSetListRole4Admin.java deleted file mode 100644 index 3755fa4..0000000 --- a/src/main/java/com/lunhan/xxx/entity/request/adminuser/ReqSetListRole4Admin.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.lunhan.xxx.entity.request.adminuser; - -import lombok.Data; - -import java.util.List; - -@Data -public class ReqSetListRole4Admin { - /** - * 管理员id - * @required - */ - private Long id; - /** - * 角色列表 - * @required - **/ - private List<Long> listRole; -} diff --git a/src/main/java/com/lunhan/xxx/entity/request/notice/ReqCreateNotice.java b/src/main/java/com/lunhan/xxx/entity/request/notice/ReqCreateNotice.java deleted file mode 100644 index b8027b2..0000000 --- a/src/main/java/com/lunhan/xxx/entity/request/notice/ReqCreateNotice.java +++ /dev/null @@ -1,53 +0,0 @@ -/** -# __----~~~~~~~~~~~------___ -# . . ~~//====...... __--~ ~~ -# -. \_|// |||\\ ~~~~~~::::... /~ -# ___-==_ _-~o~ \/ ||| \\ _/~~- -# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ -# _-~~ .=~ | \\-_ '-~7 /- / || \ / -# .~ .~ | \\ -_ / /- / || \ / -# / ____ / | \\ ~-_/ /|- _/ .|| \ / -# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ -# ' ~-| /| |-~\~~ __--~~ -# |-~~-_/ | | ~\_ _-~ /\ -# / \ \__ \/~ \__ -# _--~ _/ | .-~~____--~-/ ~~==. -# ((->/~ '.|||' -_| ~~-/ , . _|| -# -_ ~\ ~~---l__i__i__i--~~_/ -# _-~-__ ~) \--______________--~~ -# //.-~~~-~_--~- |-------~~~~~~~~ -# //.-~~~--\ -# 神兽保佑 -# 永无BUG! -*/ -package com.lunhan.xxx.entity.request.notice; - -import lombok.Data; - -/** - * 公告 - * @author lin.liu - */ -@Data -public class ReqCreateNotice { - /** - * 发布人 - */ - private String publishUser; - /** - * 标题 - */ - private String title; - /** - * 摘要 - */ - private String summary; - /** - * 内容 - */ - private String content; - /** - * 排序 - */ - private Integer sort; -} diff --git a/src/main/java/com/lunhan/xxx/entity/request/notice/ReqModifyNotice.java b/src/main/java/com/lunhan/xxx/entity/request/notice/ReqModifyNotice.java deleted file mode 100644 index c59df01..0000000 --- a/src/main/java/com/lunhan/xxx/entity/request/notice/ReqModifyNotice.java +++ /dev/null @@ -1,61 +0,0 @@ -/** -# __----~~~~~~~~~~~------___ -# . . ~~//====...... __--~ ~~ -# -. \_|// |||\\ ~~~~~~::::... /~ -# ___-==_ _-~o~ \/ ||| \\ _/~~- -# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ -# _-~~ .=~ | \\-_ '-~7 /- / || \ / -# .~ .~ | \\ -_ / /- / || \ / -# / ____ / | \\ ~-_/ /|- _/ .|| \ / -# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ -# ' ~-| /| |-~\~~ __--~~ -# |-~~-_/ | | ~\_ _-~ /\ -# / \ \__ \/~ \__ -# _--~ _/ | .-~~____--~-/ ~~==. -# ((->/~ '.|||' -_| ~~-/ , . _|| -# -_ ~\ ~~---l__i__i__i--~~_/ -# _-~-__ ~) \--______________--~~ -# //.-~~~-~_--~- |-------~~~~~~~~ -# //.-~~~--\ -# 神兽保佑 -# 永无BUG! -*/ -package com.lunhan.xxx.entity.request.notice; - -import lombok.Data; - -/** - * 公告 - * @author lin.liu - */ -@Data -public class ReqModifyNotice { - /** - * 主键 - */ - private Long id; - /** - * 发布人 - */ - private String publishUser; - /** - * 标题 - */ - private String title; - /** - * 摘要 - */ - private String summary; - /** - * 内容 - */ - private String content; - /** - * 排序 - */ - private Integer sort; - /** - * 状态(EState) - */ - private Integer status; -} diff --git a/src/main/java/com/lunhan/xxx/entity/request/quartztaskerror/ReqCreateQuartzTaskError.java b/src/main/java/com/lunhan/xxx/entity/request/quartztaskerror/ReqCreateQuartzTaskError.java deleted file mode 100644 index 80968e4..0000000 --- a/src/main/java/com/lunhan/xxx/entity/request/quartztaskerror/ReqCreateQuartzTaskError.java +++ /dev/null @@ -1,46 +0,0 @@ -/** -# __----~~~~~~~~~~~------___ -# . . ~~//====...... __--~ ~~ -# -. \_|// |||\\ ~~~~~~::::... /~ -# ___-==_ _-~o~ \/ ||| \\ _/~~- -# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ -# _-~~ .=~ | \\-_ '-~7 /- / || \ / -# .~ .~ | \\ -_ / /- / || \ / -# / ____ / | \\ ~-_/ /|- _/ .|| \ / -# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ -# ' ~-| /| |-~\~~ __--~~ -# |-~~-_/ | | ~\_ _-~ /\ -# / \ \__ \/~ \__ -# _--~ _/ | .-~~____--~-/ ~~==. -# ((->/~ '.|||' -_| ~~-/ , . _|| -# -_ ~\ ~~---l__i__i__i--~~_/ -# _-~-__ ~) \--______________--~~ -# //.-~~~-~_--~- |-------~~~~~~~~ -# //.-~~~--\ -# 神兽保佑 -# 永无BUG! -*/ -package com.lunhan.xxx.entity.request.quartztaskerror; - -import lombok.Data; - -/** - * 定时任务错误信息表 - * @author lin.liu - * @description 定时任务错误信息表 - */ -@Data -public class ReqCreateQuartzTaskError { - /** - * 任务执行记录Id - */ - private String taskExecuteRecordId; - /** - * 任务执行记录Id - */ - private String errorKey; - /** - * 任务执行记录Id - */ - private String errorValue; -} diff --git a/src/main/java/com/lunhan/xxx/entity/request/quartztaskerror/ReqModifyQuartzTaskError.java b/src/main/java/com/lunhan/xxx/entity/request/quartztaskerror/ReqModifyQuartzTaskError.java deleted file mode 100644 index 12c0177..0000000 --- a/src/main/java/com/lunhan/xxx/entity/request/quartztaskerror/ReqModifyQuartzTaskError.java +++ /dev/null @@ -1,50 +0,0 @@ -/** -# __----~~~~~~~~~~~------___ -# . . ~~//====...... __--~ ~~ -# -. \_|// |||\\ ~~~~~~::::... /~ -# ___-==_ _-~o~ \/ ||| \\ _/~~- -# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ -# _-~~ .=~ | \\-_ '-~7 /- / || \ / -# .~ .~ | \\ -_ / /- / || \ / -# / ____ / | \\ ~-_/ /|- _/ .|| \ / -# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ -# ' ~-| /| |-~\~~ __--~~ -# |-~~-_/ | | ~\_ _-~ /\ -# / \ \__ \/~ \__ -# _--~ _/ | .-~~____--~-/ ~~==. -# ((->/~ '.|||' -_| ~~-/ , . _|| -# -_ ~\ ~~---l__i__i__i--~~_/ -# _-~-__ ~) \--______________--~~ -# //.-~~~-~_--~- |-------~~~~~~~~ -# //.-~~~--\ -# 神兽保佑 -# 永无BUG! -*/ -package com.lunhan.xxx.entity.request.quartztaskerror; - -import lombok.Data; - -/** - * 定时任务错误信息表 - * @author lin.liu - * @description 定时任务错误信息表 - */ -@Data -public class ReqModifyQuartzTaskError { - /** - * 主键 - */ - private Long id; - /** - * 任务执行记录Id - */ - private String taskExecuteRecordId; - /** - * 任务执行记录Id - */ - private String errorKey; - /** - * 任务执行记录Id - */ - private String errorValue; -} diff --git a/src/main/java/com/lunhan/xxx/entity/request/quartztaskinfo/ReqCreateQuartzTaskInfo.java b/src/main/java/com/lunhan/xxx/entity/request/quartztaskinfo/ReqCreateQuartzTaskInfo.java deleted file mode 100644 index 5b38e58..0000000 --- a/src/main/java/com/lunhan/xxx/entity/request/quartztaskinfo/ReqCreateQuartzTaskInfo.java +++ /dev/null @@ -1,58 +0,0 @@ -/** -# __----~~~~~~~~~~~------___ -# . . ~~//====...... __--~ ~~ -# -. \_|// |||\\ ~~~~~~::::... /~ -# ___-==_ _-~o~ \/ ||| \\ _/~~- -# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ -# _-~~ .=~ | \\-_ '-~7 /- / || \ / -# .~ .~ | \\ -_ / /- / || \ / -# / ____ / | \\ ~-_/ /|- _/ .|| \ / -# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ -# ' ~-| /| |-~\~~ __--~~ -# |-~~-_/ | | ~\_ _-~ /\ -# / \ \__ \/~ \__ -# _--~ _/ | .-~~____--~-/ ~~==. -# ((->/~ '.|||' -_| ~~-/ , . _|| -# -_ ~\ ~~---l__i__i__i--~~_/ -# _-~-__ ~) \--______________--~~ -# //.-~~~-~_--~- |-------~~~~~~~~ -# //.-~~~--\ -# 神兽保佑 -# 永无BUG! -*/ -package com.lunhan.xxx.entity.request.quartztaskinfo; - -import lombok.Data; - -/** - * 定时任务信息表 - * @author lin.liu - * @description 定时任务信息表 - */ -@Data -public class ReqCreateQuartzTaskInfo { - /** - * 任务名称 - */ - private String taskName; - /** - * 定时规则表达式 - */ - private String schedulerRule; - /** - * 执行方 - */ - private String executor; - /** - * 执行参数 - */ - private String executeParameter; - /** - * 执行结果发送方式 - */ - private String sendType; - /** - * 执行结果发送请求地址 - */ - private String url; -} diff --git a/src/main/java/com/lunhan/xxx/entity/request/quartztaskinfo/ReqModifyQuartzTaskInfo.java b/src/main/java/com/lunhan/xxx/entity/request/quartztaskinfo/ReqModifyQuartzTaskInfo.java deleted file mode 100644 index 6d233f0..0000000 --- a/src/main/java/com/lunhan/xxx/entity/request/quartztaskinfo/ReqModifyQuartzTaskInfo.java +++ /dev/null @@ -1,66 +0,0 @@ -/** -# __----~~~~~~~~~~~------___ -# . . ~~//====...... __--~ ~~ -# -. \_|// |||\\ ~~~~~~::::... /~ -# ___-==_ _-~o~ \/ ||| \\ _/~~- -# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ -# _-~~ .=~ | \\-_ '-~7 /- / || \ / -# .~ .~ | \\ -_ / /- / || \ / -# / ____ / | \\ ~-_/ /|- _/ .|| \ / -# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ -# ' ~-| /| |-~\~~ __--~~ -# |-~~-_/ | | ~\_ _-~ /\ -# / \ \__ \/~ \__ -# _--~ _/ | .-~~____--~-/ ~~==. -# ((->/~ '.|||' -_| ~~-/ , . _|| -# -_ ~\ ~~---l__i__i__i--~~_/ -# _-~-__ ~) \--______________--~~ -# //.-~~~-~_--~- |-------~~~~~~~~ -# //.-~~~--\ -# 神兽保佑 -# 永无BUG! -*/ -package com.lunhan.xxx.entity.request.quartztaskinfo; - -import lombok.Data; - -/** - * 定时任务信息表 - * @author lin.liu - * @description 定时任务信息表 - */ -@Data -public class ReqModifyQuartzTaskInfo { - /** - * 主键 - */ - private Long id; - /** - * 任务名称 - */ - private String taskName; - /** - * 定时规则表达式 - */ - private String schedulerRule; - /** - * 执行方 - */ - private String executor; - /** - * 执行参数 - */ - private String executeParameter; - /** - * 任务状态 EState - */ - private Integer status; - /** - * 执行结果发送方式 - */ - private String sendType; - /** - * 执行结果发送请求地址 - */ - private String url; -} diff --git a/src/main/java/com/lunhan/xxx/entity/request/quartztaskinfo/ReqRunTaskRightNow.java b/src/main/java/com/lunhan/xxx/entity/request/quartztaskinfo/ReqRunTaskRightNow.java deleted file mode 100644 index 1235063..0000000 --- a/src/main/java/com/lunhan/xxx/entity/request/quartztaskinfo/ReqRunTaskRightNow.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.lunhan.xxx.entity.request.quartztaskinfo; - -import lombok.Data; - -@Data -public class ReqRunTaskRightNow { - /** - * 任务id - */ - private Long id; - /** - * 执行参数 - */ - private String executeParameter; -} diff --git a/src/main/java/com/lunhan/xxx/entity/request/quartztaskrecord/ReqCreateQuartzTaskRecord.java b/src/main/java/com/lunhan/xxx/entity/request/quartztaskrecord/ReqCreateQuartzTaskRecord.java deleted file mode 100644 index 8003f5a..0000000 --- a/src/main/java/com/lunhan/xxx/entity/request/quartztaskrecord/ReqCreateQuartzTaskRecord.java +++ /dev/null @@ -1,58 +0,0 @@ -/** -# __----~~~~~~~~~~~------___ -# . . ~~//====...... __--~ ~~ -# -. \_|// |||\\ ~~~~~~::::... /~ -# ___-==_ _-~o~ \/ ||| \\ _/~~- -# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ -# _-~~ .=~ | \\-_ '-~7 /- / || \ / -# .~ .~ | \\ -_ / /- / || \ / -# / ____ / | \\ ~-_/ /|- _/ .|| \ / -# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ -# ' ~-| /| |-~\~~ __--~~ -# |-~~-_/ | | ~\_ _-~ /\ -# / \ \__ \/~ \__ -# _--~ _/ | .-~~____--~-/ ~~==. -# ((->/~ '.|||' -_| ~~-/ , . _|| -# -_ ~\ ~~---l__i__i__i--~~_/ -# _-~-__ ~) \--______________--~~ -# //.-~~~-~_--~- |-------~~~~~~~~ -# //.-~~~--\ -# 神兽保佑 -# 永无BUG! -*/ -package com.lunhan.xxx.entity.request.quartztaskrecord; - -import lombok.Data; - -/** - * 定时任务执行情况记录表 - * @author lin.liu - * @description 定时任务执行情况记录表 - */ -@Data -public class ReqCreateQuartzTaskRecord { - /** - * 任务编号 - */ - private String taskNo; - /** - * 执行时间格式值 - */ - private String timeKeyValue; - /** - * 执行时间 - */ - private Long executeTime; - /** - * 任务状态 - */ - private String taskStatus; - /** - * 失败统计数 - */ - private Long failCount; - /** - * 失败错误描述 - */ - private String failReason; -} diff --git a/src/main/java/com/lunhan/xxx/entity/request/quartztaskrecord/ReqModifyQuartzTaskRecord.java b/src/main/java/com/lunhan/xxx/entity/request/quartztaskrecord/ReqModifyQuartzTaskRecord.java deleted file mode 100644 index 0b7fb38..0000000 --- a/src/main/java/com/lunhan/xxx/entity/request/quartztaskrecord/ReqModifyQuartzTaskRecord.java +++ /dev/null @@ -1,62 +0,0 @@ -/** -# __----~~~~~~~~~~~------___ -# . . ~~//====...... __--~ ~~ -# -. \_|// |||\\ ~~~~~~::::... /~ -# ___-==_ _-~o~ \/ ||| \\ _/~~- -# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ -# _-~~ .=~ | \\-_ '-~7 /- / || \ / -# .~ .~ | \\ -_ / /- / || \ / -# / ____ / | \\ ~-_/ /|- _/ .|| \ / -# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ -# ' ~-| /| |-~\~~ __--~~ -# |-~~-_/ | | ~\_ _-~ /\ -# / \ \__ \/~ \__ -# _--~ _/ | .-~~____--~-/ ~~==. -# ((->/~ '.|||' -_| ~~-/ , . _|| -# -_ ~\ ~~---l__i__i__i--~~_/ -# _-~-__ ~) \--______________--~~ -# //.-~~~-~_--~- |-------~~~~~~~~ -# //.-~~~--\ -# 神兽保佑 -# 永无BUG! -*/ -package com.lunhan.xxx.entity.request.quartztaskrecord; - -import lombok.Data; - -/** - * 定时任务执行情况记录表 - * @author lin.liu - * @description 定时任务执行情况记录表 - */ -@Data -public class ReqModifyQuartzTaskRecord { - /** - * 主键 - */ - private Long id; - /** - * 任务编号 - */ - private String taskNo; - /** - * 执行时间格式值 - */ - private String timeKeyValue; - /** - * 执行时间 - */ - private Long executeTime; - /** - * 任务状态 - */ - private String taskStatus; - /** - * 失败统计数 - */ - private Long failCount; - /** - * 失败错误描述 - */ - private String failReason; -} diff --git a/src/main/java/com/lunhan/xxx/entity/request/sysdictdata/ReqCreateSysDictData.java b/src/main/java/com/lunhan/xxx/entity/request/sysdictdata/ReqCreateSysDictData.java deleted file mode 100644 index fa4c8bd..0000000 --- a/src/main/java/com/lunhan/xxx/entity/request/sysdictdata/ReqCreateSysDictData.java +++ /dev/null @@ -1,50 +0,0 @@ -/** -# __----~~~~~~~~~~~------___ -# . . ~~//====...... __--~ ~~ -# -. \_|// |||\\ ~~~~~~::::... /~ -# ___-==_ _-~o~ \/ ||| \\ _/~~- -# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ -# _-~~ .=~ | \\-_ '-~7 /- / || \ / -# .~ .~ | \\ -_ / /- / || \ / -# / ____ / | \\ ~-_/ /|- _/ .|| \ / -# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ -# ' ~-| /| |-~\~~ __--~~ -# |-~~-_/ | | ~\_ _-~ /\ -# / \ \__ \/~ \__ -# _--~ _/ | .-~~____--~-/ ~~==. -# ((->/~ '.|||' -_| ~~-/ , . _|| -# -_ ~\ ~~---l__i__i__i--~~_/ -# _-~-__ ~) \--______________--~~ -# //.-~~~-~_--~- |-------~~~~~~~~ -# //.-~~~--\ -# 神兽保佑 -# 永无BUG! -*/ -package com.lunhan.xxx.entity.request.sysdictdata; - -import lombok.Data; - -/** - * 字典数据表 - * @author lin.liu - * @description 字典数据表 - */ -@Data -public class ReqCreateSysDictData { - /** - * 字典类型 - */ - private String dictType; - /** - * 字典标题 - */ - private String dictLabel; - /** - * 字典键值 - */ - private String dictValue; - /** - * 备注 - */ - private String remark; -} diff --git a/src/main/java/com/lunhan/xxx/entity/request/sysdictdata/ReqModifySysDictData.java b/src/main/java/com/lunhan/xxx/entity/request/sysdictdata/ReqModifySysDictData.java deleted file mode 100644 index b4a2ee5..0000000 --- a/src/main/java/com/lunhan/xxx/entity/request/sysdictdata/ReqModifySysDictData.java +++ /dev/null @@ -1,54 +0,0 @@ -/** -# __----~~~~~~~~~~~------___ -# . . ~~//====...... __--~ ~~ -# -. \_|// |||\\ ~~~~~~::::... /~ -# ___-==_ _-~o~ \/ ||| \\ _/~~- -# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ -# _-~~ .=~ | \\-_ '-~7 /- / || \ / -# .~ .~ | \\ -_ / /- / || \ / -# / ____ / | \\ ~-_/ /|- _/ .|| \ / -# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ -# ' ~-| /| |-~\~~ __--~~ -# |-~~-_/ | | ~\_ _-~ /\ -# / \ \__ \/~ \__ -# _--~ _/ | .-~~____--~-/ ~~==. -# ((->/~ '.|||' -_| ~~-/ , . _|| -# -_ ~\ ~~---l__i__i__i--~~_/ -# _-~-__ ~) \--______________--~~ -# //.-~~~-~_--~- |-------~~~~~~~~ -# //.-~~~--\ -# 神兽保佑 -# 永无BUG! -*/ -package com.lunhan.xxx.entity.request.sysdictdata; - -import lombok.Data; - -/** - * 字典数据表 - * @author lin.liu - * @description 字典数据表 - */ -@Data -public class ReqModifySysDictData { - /** - * 主键 - */ - private Long id; - /** - * 字典标题 - */ - private String dictLabel; - /** - * 字典键值 - */ - private String dictValue; - /** - * 状态 - */ - private Integer status; - /** - * 备注 - */ - private String remark; -} diff --git a/src/main/java/com/lunhan/xxx/entity/request/sysdicttype/ReqCreateSysDictType.java b/src/main/java/com/lunhan/xxx/entity/request/sysdicttype/ReqCreateSysDictType.java deleted file mode 100644 index c108336..0000000 --- a/src/main/java/com/lunhan/xxx/entity/request/sysdicttype/ReqCreateSysDictType.java +++ /dev/null @@ -1,46 +0,0 @@ -/** -# __----~~~~~~~~~~~------___ -# . . ~~//====...... __--~ ~~ -# -. \_|// |||\\ ~~~~~~::::... /~ -# ___-==_ _-~o~ \/ ||| \\ _/~~- -# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ -# _-~~ .=~ | \\-_ '-~7 /- / || \ / -# .~ .~ | \\ -_ / /- / || \ / -# / ____ / | \\ ~-_/ /|- _/ .|| \ / -# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ -# ' ~-| /| |-~\~~ __--~~ -# |-~~-_/ | | ~\_ _-~ /\ -# / \ \__ \/~ \__ -# _--~ _/ | .-~~____--~-/ ~~==. -# ((->/~ '.|||' -_| ~~-/ , . _|| -# -_ ~\ ~~---l__i__i__i--~~_/ -# _-~-__ ~) \--______________--~~ -# //.-~~~-~_--~- |-------~~~~~~~~ -# //.-~~~--\ -# 神兽保佑 -# 永无BUG! -*/ -package com.lunhan.xxx.entity.request.sysdicttype; - -import lombok.Data; - -/** - * 字典类型表 - * @author lin.liu - * @description 字典类型表 - */ -@Data -public class ReqCreateSysDictType { - /** - * 字典类型 - */ - private String dictType; - /** - * 字典名称 - */ - private String dictName; - /** - * 备注 - */ - private String remark; -} diff --git a/src/main/java/com/lunhan/xxx/entity/request/sysdicttype/ReqModifySysDictType.java b/src/main/java/com/lunhan/xxx/entity/request/sysdicttype/ReqModifySysDictType.java deleted file mode 100644 index 33825b0..0000000 --- a/src/main/java/com/lunhan/xxx/entity/request/sysdicttype/ReqModifySysDictType.java +++ /dev/null @@ -1,50 +0,0 @@ -/** -# __----~~~~~~~~~~~------___ -# . . ~~//====...... __--~ ~~ -# -. \_|// |||\\ ~~~~~~::::... /~ -# ___-==_ _-~o~ \/ ||| \\ _/~~- -# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ -# _-~~ .=~ | \\-_ '-~7 /- / || \ / -# .~ .~ | \\ -_ / /- / || \ / -# / ____ / | \\ ~-_/ /|- _/ .|| \ / -# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ -# ' ~-| /| |-~\~~ __--~~ -# |-~~-_/ | | ~\_ _-~ /\ -# / \ \__ \/~ \__ -# _--~ _/ | .-~~____--~-/ ~~==. -# ((->/~ '.|||' -_| ~~-/ , . _|| -# -_ ~\ ~~---l__i__i__i--~~_/ -# _-~-__ ~) \--______________--~~ -# //.-~~~-~_--~- |-------~~~~~~~~ -# //.-~~~--\ -# 神兽保佑 -# 永无BUG! -*/ -package com.lunhan.xxx.entity.request.sysdicttype; - -import lombok.Data; - -/** - * 字典类型表 - * @author lin.liu - * @description 字典类型表 - */ -@Data -public class ReqModifySysDictType { - /** - * 主键 - */ - private Long id; - /** - * 字典名称 - */ - private String dictName; - /** - * 状态 EState - */ - private Integer status; - /** - * 备注 - */ - private String remark; -} diff --git a/src/main/java/com/lunhan/xxx/entity/request/test/ReqCreateTestInfo.java b/src/main/java/com/lunhan/xxx/entity/request/test/ReqCreateTestInfo.java deleted file mode 100644 index 83b3fef..0000000 --- a/src/main/java/com/lunhan/xxx/entity/request/test/ReqCreateTestInfo.java +++ /dev/null @@ -1,102 +0,0 @@ -package com.lunhan.xxx.entity.request.test; - -import java.math.BigDecimal; - -public class ReqCreateTestInfo { - /** - * 名称 - */ - private String name; - /** - * 用户id - */ - private Long userId; - /** - * 电话 - */ - private String phone; - /** - * 余额 - */ - private BigDecimal balance; - /** - * 性别 ESex - */ - private Integer sex; - /** - * 生日 - */ - private String birthday; - /** - * 排序值 - */ - private Integer sort; - /** - * 备注 - */ - private String comment; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public Long getUserId() { - return userId; - } - - public void setUserId(Long userId) { - this.userId = userId; - } - - public String getPhone() { - return phone; - } - - public void setPhone(String phone) { - this.phone = phone; - } - - public BigDecimal getBalance() { - return balance; - } - - public void setBalance(BigDecimal balance) { - this.balance = balance; - } - - public Integer getSex() { - return sex; - } - - public void setSex(Integer sex) { - this.sex = sex; - } - - public String getBirthday() { - return birthday; - } - - public void setBirthday(String birthday) { - this.birthday = birthday; - } - - public Integer getSort() { - return sort; - } - - public void setSort(Integer sort) { - this.sort = sort; - } - - public String getComment() { - return comment; - } - - public void setComment(String comment) { - this.comment = comment; - } -} diff --git a/src/main/java/com/lunhan/xxx/entity/request/test/ReqModifyTestInfo.java b/src/main/java/com/lunhan/xxx/entity/request/test/ReqModifyTestInfo.java deleted file mode 100644 index 74ced95..0000000 --- a/src/main/java/com/lunhan/xxx/entity/request/test/ReqModifyTestInfo.java +++ /dev/null @@ -1,114 +0,0 @@ -package com.lunhan.xxx.entity.request.test; - -import java.math.BigDecimal; - -public class ReqModifyTestInfo { - /** - * 自增id - */ - private Long id; - /** - * 名称 - */ - private String name; - /** - * 用户id - */ - private Long userId; - /** - * 电话 - */ - private String phone; - /** - * 余额 - */ - private BigDecimal balance; - /** - * 性别 ESex - */ - private Integer sex; - /** - * 生日 - */ - private String birthday; - /** - * 排序值 - */ - private Integer sort; - /** - * 备注 - */ - private String comment; - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public Long getUserId() { - return userId; - } - - public void setUserId(Long userId) { - this.userId = userId; - } - - public String getPhone() { - return phone; - } - - public void setPhone(String phone) { - this.phone = phone; - } - - public BigDecimal getBalance() { - return balance; - } - - public void setBalance(BigDecimal balance) { - this.balance = balance; - } - - public Integer getSex() { - return sex; - } - - public void setSex(Integer sex) { - this.sex = sex; - } - - public String getBirthday() { - return birthday; - } - - public void setBirthday(String birthday) { - this.birthday = birthday; - } - - public Integer getSort() { - return sort; - } - - public void setSort(Integer sort) { - this.sort = sort; - } - - public String getComment() { - return comment; - } - - public void setComment(String comment) { - this.comment = comment; - } -} diff --git a/src/main/java/com/lunhan/xxx/entity/request/testinfo/ReqCreateTestInfo.java b/src/main/java/com/lunhan/xxx/entity/request/testinfo/ReqCreateTestInfo.java deleted file mode 100644 index 33660d9..0000000 --- a/src/main/java/com/lunhan/xxx/entity/request/testinfo/ReqCreateTestInfo.java +++ /dev/null @@ -1,66 +0,0 @@ -/** -# __----~~~~~~~~~~~------___ -# . . ~~//====...... __--~ ~~ -# -. \_|// |||\\ ~~~~~~::::... /~ -# ___-==_ _-~o~ \/ ||| \\ _/~~- -# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ -# _-~~ .=~ | \\-_ '-~7 /- / || \ / -# .~ .~ | \\ -_ / /- / || \ / -# / ____ / | \\ ~-_/ /|- _/ .|| \ / -# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ -# ' ~-| /| |-~\~~ __--~~ -# |-~~-_/ | | ~\_ _-~ /\ -# / \ \__ \/~ \__ -# _--~ _/ | .-~~____--~-/ ~~==. -# ((->/~ '.|||' -_| ~~-/ , . _|| -# -_ ~\ ~~---l__i__i__i--~~_/ -# _-~-__ ~) \--______________--~~ -# //.-~~~-~_--~- |-------~~~~~~~~ -# //.-~~~--\ -# 神兽保佑 -# 永无BUG! -*/ -package com.lunhan.xxx.entity.request.testinfo; - -import lombok.Data; -import java.math.BigDecimal; - -/** - * 测试信息表 - * @author lin.liu - */ -@Data -public class ReqCreateTestInfo { - /** - * 名称 - */ - private String name; - /** - * 用户id - */ - private Long userId; - /** - * 电话 - */ - private String phone; - /** - * balance余额 - */ - private BigDecimal balance; - /** - * 性别 男=1,女=2,其他=3 - */ - private Integer sex; - /** - * 生日 - */ - private String birthday; - /** - * 排序值 - */ - private Integer sort; - /** - * 备注 - */ - private String comment; -} diff --git a/src/main/java/com/lunhan/xxx/entity/request/testinfo/ReqModifyTestInfo.java b/src/main/java/com/lunhan/xxx/entity/request/testinfo/ReqModifyTestInfo.java deleted file mode 100644 index 528ae2b..0000000 --- a/src/main/java/com/lunhan/xxx/entity/request/testinfo/ReqModifyTestInfo.java +++ /dev/null @@ -1,74 +0,0 @@ -/** -# __----~~~~~~~~~~~------___ -# . . ~~//====...... __--~ ~~ -# -. \_|// |||\\ ~~~~~~::::... /~ -# ___-==_ _-~o~ \/ ||| \\ _/~~- -# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ -# _-~~ .=~ | \\-_ '-~7 /- / || \ / -# .~ .~ | \\ -_ / /- / || \ / -# / ____ / | \\ ~-_/ /|- _/ .|| \ / -# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ -# ' ~-| /| |-~\~~ __--~~ -# |-~~-_/ | | ~\_ _-~ /\ -# / \ \__ \/~ \__ -# _--~ _/ | .-~~____--~-/ ~~==. -# ((->/~ '.|||' -_| ~~-/ , . _|| -# -_ ~\ ~~---l__i__i__i--~~_/ -# _-~-__ ~) \--______________--~~ -# //.-~~~-~_--~- |-------~~~~~~~~ -# //.-~~~--\ -# 神兽保佑 -# 永无BUG! -*/ -package com.lunhan.xxx.entity.request.testinfo; - -import lombok.Data; -import java.math.BigDecimal; - -/** - * 测试信息表 - * @author lin.liu - */ -@Data -public class ReqModifyTestInfo { - /** - * 主键 - */ - private Long id; - /** - * 名称 - */ - private String name; - /** - * 用户id - */ - private Long userId; - /** - * 电话 - */ - private String phone; - /** - * balance余额 - */ - private BigDecimal balance; - /** - * 性别 男=1,女=2,其他=3 - */ - private Integer sex; - /** - * 生日 - */ - private String birthday; - /** - * 排序值 - */ - private Integer sort; - /** - * 状态 EState - */ - private Integer status; - /** - * 备注 - */ - private String comment; -} diff --git a/src/main/java/com/lunhan/xxx/entity/response/ResNameValue.java b/src/main/java/com/lunhan/xxx/entity/response/ResNameValue.java deleted file mode 100644 index 2561d75..0000000 --- a/src/main/java/com/lunhan/xxx/entity/response/ResNameValue.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.lunhan.xxx.entity.response; - -public class ResNameValue { - /** - * 名称 - **/ - private String name; - /** - * 值 - **/ - private String value; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getValue() { - return value; - } - - public void setValue(String value) { - this.value = value; - } -} diff --git a/src/main/java/com/lunhan/xxx/entity/response/admin/ResAdminLogin.java b/src/main/java/com/lunhan/xxx/entity/response/admin/ResAdminLogin.java deleted file mode 100644 index 14c8b14..0000000 --- a/src/main/java/com/lunhan/xxx/entity/response/admin/ResAdminLogin.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.lunhan.xxx.entity.response.admin; - -import lombok.Data; - -import java.util.List; - -@Data -public class ResAdminLogin { - /** - * 管理员id - */ - private Long id; - /** - * 用户类型 EUserType - */ - private Integer userType; - - /** - * 管理员名称 - */ - private String name; - - /** - * 请求令牌 - */ - private String token; - /** - * 菜单列表 - */ - private List<ResAdminMenuTree> menus; - /** - * 权限列表 - */ - private List<String> listPermission; -} diff --git a/src/main/java/com/lunhan/xxx/entity/response/admin/ResAdminMenuTree.java b/src/main/java/com/lunhan/xxx/entity/response/admin/ResAdminMenuTree.java deleted file mode 100644 index e20bb19..0000000 --- a/src/main/java/com/lunhan/xxx/entity/response/admin/ResAdminMenuTree.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.lunhan.xxx.entity.response.admin; - -import lombok.Data; - -import java.util.List; - -@Data -public class ResAdminMenuTree { - /** - * 菜单id - */ - private Long id; - /** - * 类型 EMenuType - * @required - */ - private Integer type; - /** - * 父级ID - */ - private Long parentId; - /** - * 菜单名称 - */ - private String name; - /** - * 菜单标题 - */ - private String title; - /** - * 前端资源路径 - */ - private String url; - /** - * 菜单层级 - */ - private Integer level; - /** - * 排序 越大越靠前 - */ - private Integer sort; - /** - * 图标 - */ - private String icon; - /** - * 子级菜单列表 - */ - private List<ResAdminMenuTreeAndPermission> children; -} diff --git a/src/main/java/com/lunhan/xxx/entity/response/admin/ResAdminMenuTreeAndPermission.java b/src/main/java/com/lunhan/xxx/entity/response/admin/ResAdminMenuTreeAndPermission.java deleted file mode 100644 index e002330..0000000 --- a/src/main/java/com/lunhan/xxx/entity/response/admin/ResAdminMenuTreeAndPermission.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.lunhan.xxx.entity.response.admin; - -import lombok.Data; - -import java.util.List; - -@Data -public class ResAdminMenuTreeAndPermission extends ResAdminMenuTree { - /** - * 权限列表 - */ - private List<ResAdminPermission> permissions; -} diff --git a/src/main/java/com/lunhan/xxx/entity/response/admin/ResAdminPermission.java b/src/main/java/com/lunhan/xxx/entity/response/admin/ResAdminPermission.java deleted file mode 100644 index 43d7547..0000000 --- a/src/main/java/com/lunhan/xxx/entity/response/admin/ResAdminPermission.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.lunhan.xxx.entity.response.admin; - -import lombok.Data; - -@Data -public class ResAdminPermission { - /** - * 权限id - */ - private Long id; - /** - * 权限值 - */ - private String sn; - /** - * 菜单id - */ - private Long menuId; - - /** - * 名称 - */ - private String name; - /** - * 状态 EState - */ - private Integer status; -} diff --git a/src/main/java/com/lunhan/xxx/entity/response/admin/ResAdminPower.java b/src/main/java/com/lunhan/xxx/entity/response/admin/ResAdminPower.java deleted file mode 100644 index 4af7eeb..0000000 --- a/src/main/java/com/lunhan/xxx/entity/response/admin/ResAdminPower.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.lunhan.xxx.entity.response.admin; - -import com.lunhan.xxx.repository.vo.AdminMenuVO; -import lombok.Data; - -import java.util.List; - -@Data -public class ResAdminPower { - /** - * 菜单列表 - */ - private List<AdminMenuVO> menus; - /** - * 权限列表 - */ - private List<ResAdminPermission> permissions; -} diff --git a/src/main/java/com/lunhan/xxx/entity/search/SearchAdminMenu.java b/src/main/java/com/lunhan/xxx/entity/search/SearchAdminMenu.java deleted file mode 100644 index d612f1d..0000000 --- a/src/main/java/com/lunhan/xxx/entity/search/SearchAdminMenu.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.lunhan.xxx.entity.search; - -import com.lunhan.xxx.entity.dto.SearchBasicDTO; -import lombok.Data; - -/** - * 后台菜单 - * @author lin.liu - * @description 后台菜单 - */ -@Data -public class SearchAdminMenu extends SearchBasicDTO { - -} diff --git a/src/main/java/com/lunhan/xxx/entity/search/SearchAdminMenus.java b/src/main/java/com/lunhan/xxx/entity/search/SearchAdminMenus.java deleted file mode 100644 index bcb5975..0000000 --- a/src/main/java/com/lunhan/xxx/entity/search/SearchAdminMenus.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.lunhan.xxx.entity.search; - -import lombok.Data; - -import com.lunhan.xxx.entity.dto.SearchBasicDTO; - -/** - * 菜单信息 - * @author lin.liu - */ -@Data -public class SearchAdminMenus extends SearchBasicDTO { - -} diff --git a/src/main/java/com/lunhan/xxx/entity/search/SearchAdminPermission.java b/src/main/java/com/lunhan/xxx/entity/search/SearchAdminPermission.java deleted file mode 100644 index b2522b2..0000000 --- a/src/main/java/com/lunhan/xxx/entity/search/SearchAdminPermission.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.lunhan.xxx.entity.search; - -import com.lunhan.xxx.entity.dto.SearchBasicDTO; - -/** - * 后台用户权限表 - * @author lin.liu - * @description 后台用户权限表 - */ -public class SearchAdminPermission extends SearchBasicDTO { - @Override - public String toString() { - return "SearchAdminPermission{" + "'" + - "keywords='" + getKeywords() + - ", listId =" + getListId() + - ", status =" + getStatus() + - ", listStatus =" + getListStatus() + - ", createTimeRange='" + getCreateTimeRange() + "'" + - ", createTimeStart =" + getCreateTimeEnd() + - ", createTimeEnd =" + getCreateTimeEnd() + - ", lastId =" + getListId() + - ", orderBy='" + getOrderBy() + "'" + - '}'; - } -} diff --git a/src/main/java/com/lunhan/xxx/entity/search/SearchAdminRole.java b/src/main/java/com/lunhan/xxx/entity/search/SearchAdminRole.java deleted file mode 100644 index 010258b..0000000 --- a/src/main/java/com/lunhan/xxx/entity/search/SearchAdminRole.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.lunhan.xxx.entity.search; - -import com.lunhan.xxx.entity.dto.SearchBasicDTO; - -/** - * 后台用户角色表 - * @author lin.liu - * @description 后台用户角色表 - */ -public class SearchAdminRole extends SearchBasicDTO { - @Override - public String toString() { - return "SearchAdminRole{" + "'" + - "keywords='" + getKeywords() + - ", listId =" + getListId() + - ", status =" + getStatus() + - ", listStatus =" + getListStatus() + - ", createTimeRange='" + getCreateTimeRange() + "'" + - ", createTimeStart =" + getCreateTimeEnd() + - ", createTimeEnd =" + getCreateTimeEnd() + - ", lastId =" + getListId() + - ", orderBy='" + getOrderBy() + "'" + - '}'; - } -} diff --git a/src/main/java/com/lunhan/xxx/entity/search/SearchAdminRoleMenuRelation.java b/src/main/java/com/lunhan/xxx/entity/search/SearchAdminRoleMenuRelation.java deleted file mode 100644 index a3cfb05..0000000 --- a/src/main/java/com/lunhan/xxx/entity/search/SearchAdminRoleMenuRelation.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.lunhan.xxx.entity.search; - -import com.lunhan.xxx.entity.dto.SearchBasicDTO; - -/** - * 后台角色菜单关系表 - * @author lin.liu - * @description 后台角色菜单关系表 - */ -public class SearchAdminRoleMenuRelation extends SearchBasicDTO { - @Override - public String toString() { - return "SearchAdminRoleMenuRelation{" + "'" + - "keywords='" + getKeywords() + - ", listId =" + getListId() + - ", status =" + getStatus() + - ", listStatus =" + getListStatus() + - ", createTimeRange='" + getCreateTimeRange() + "'" + - ", createTimeStart =" + getCreateTimeEnd() + - ", createTimeEnd =" + getCreateTimeEnd() + - ", lastId =" + getListId() + - ", orderBy='" + getOrderBy() + "'" + - '}'; - } -} diff --git a/src/main/java/com/lunhan/xxx/entity/search/SearchAdminRolePermissionRelation.java b/src/main/java/com/lunhan/xxx/entity/search/SearchAdminRolePermissionRelation.java deleted file mode 100644 index 99f2bbe..0000000 --- a/src/main/java/com/lunhan/xxx/entity/search/SearchAdminRolePermissionRelation.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.lunhan.xxx.entity.search; - -import com.lunhan.xxx.entity.dto.SearchBasicDTO; - -/** - * 后台角色权限关系表 - * @author lin.liu - * @description 后台角色权限关系表 - */ -public class SearchAdminRolePermissionRelation extends SearchBasicDTO { - @Override - public String toString() { - return "SearchAdminRolePermissionRelation{" + "'" + - "keywords='" + getKeywords() + - ", listId =" + getListId() + - ", status =" + getStatus() + - ", listStatus =" + getListStatus() + - ", createTimeRange='" + getCreateTimeRange() + "'" + - ", createTimeStart =" + getCreateTimeEnd() + - ", createTimeEnd =" + getCreateTimeEnd() + - ", lastId =" + getListId() + - ", orderBy='" + getOrderBy() + "'" + - '}'; - } -} diff --git a/src/main/java/com/lunhan/xxx/entity/search/SearchAdminRoleRelation.java b/src/main/java/com/lunhan/xxx/entity/search/SearchAdminRoleRelation.java deleted file mode 100644 index 2407c79..0000000 --- a/src/main/java/com/lunhan/xxx/entity/search/SearchAdminRoleRelation.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.lunhan.xxx.entity.search; - -import com.lunhan.xxx.entity.dto.SearchBasicDTO; - -/** - * 后台用户和角色关系表 - * @author lin.liu - * @description 后台用户和角色关系表 - */ -public class SearchAdminRoleRelation extends SearchBasicDTO { - @Override - public String toString() { - return "SearchAdminRoleRelation{" + "'" + - "keywords='" + getKeywords() + - ", listId =" + getListId() + - ", status =" + getStatus() + - ", listStatus =" + getListStatus() + - ", createTimeRange='" + getCreateTimeRange() + "'" + - ", createTimeStart =" + getCreateTimeEnd() + - ", createTimeEnd =" + getCreateTimeEnd() + - ", lastId =" + getListId() + - ", orderBy='" + getOrderBy() + "'" + - '}'; - } -} diff --git a/src/main/java/com/lunhan/xxx/entity/search/SearchAdminUser.java b/src/main/java/com/lunhan/xxx/entity/search/SearchAdminUser.java deleted file mode 100644 index 358068d..0000000 --- a/src/main/java/com/lunhan/xxx/entity/search/SearchAdminUser.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.lunhan.xxx.entity.search; - -import com.lunhan.xxx.entity.dto.SearchBasicDTO; - -/** - * 管理员帐号 - * @author lin.liu - * @description 管理员帐号 - */ -public class SearchAdminUser extends SearchBasicDTO { - @Override - public String toString() { - return "SearchAdminUser{" + "'" + - "keywords='" + getKeywords() + - ", listId =" + getListId() + - ", status =" + getStatus() + - ", listStatus =" + getListStatus() + - ", createTimeRange='" + getCreateTimeRange() + "'" + - ", createTimeStart =" + getCreateTimeEnd() + - ", createTimeEnd =" + getCreateTimeEnd() + - ", lastId =" + getListId() + - ", orderBy='" + getOrderBy() + "'" + - '}'; - } -} diff --git a/src/main/java/com/lunhan/xxx/entity/search/SearchNotice.java b/src/main/java/com/lunhan/xxx/entity/search/SearchNotice.java deleted file mode 100644 index 0ea3131..0000000 --- a/src/main/java/com/lunhan/xxx/entity/search/SearchNotice.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.lunhan.xxx.entity.search; - -import lombok.Data; - -import com.lunhan.xxx.entity.dto.SearchBasicDTO; - -/** - * 公告 - * @author lin.liu - */ -@Data -public class SearchNotice extends SearchBasicDTO { - -} diff --git a/src/main/java/com/lunhan/xxx/entity/search/SearchQuartzTaskError.java b/src/main/java/com/lunhan/xxx/entity/search/SearchQuartzTaskError.java deleted file mode 100644 index 1bfd593..0000000 --- a/src/main/java/com/lunhan/xxx/entity/search/SearchQuartzTaskError.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.lunhan.xxx.entity.search; - -import com.lunhan.xxx.entity.dto.SearchBasicDTO; - -/** - * 定时任务错误信息表 - * @author lin.liu - * @description 定时任务错误信息表 - */ -public class SearchQuartzTaskError extends SearchBasicDTO { - @Override - public String toString() { - return "SearchQuartzTaskError{" + "'" + - "keywords='" + getKeywords() + - ", status =" + getStatus() + - ", listStatus =" + getListStatus() + - ", createTimeRange='" + getCreateTimeRange() + "'" + - ", createTimeStart =" + getCreateTimeEnd() + - ", createTimeEnd =" + getCreateTimeEnd() + - ", orderBy='" + getOrderBy() + "'" + - '}'; - } -} diff --git a/src/main/java/com/lunhan/xxx/entity/search/SearchQuartzTaskInfo.java b/src/main/java/com/lunhan/xxx/entity/search/SearchQuartzTaskInfo.java deleted file mode 100644 index 36a7e18..0000000 --- a/src/main/java/com/lunhan/xxx/entity/search/SearchQuartzTaskInfo.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.lunhan.xxx.entity.search; - -import com.lunhan.xxx.entity.dto.SearchBasicDTO; -import lombok.Data; - -/** - * 定时任务信息表 - * @author lin.liu - * @description 定时任务信息表 - */ -@Data -public class SearchQuartzTaskInfo extends SearchBasicDTO { - /** - * 任务编号 - */ - private String taskNo; - - @Override - public String toString() { - return "SearchQuartzTaskInfo{" + "'" + - "keywords='" + getKeywords() + - ", status =" + getStatus() + - ", listStatus =" + getListStatus() + - ", createTimeRange='" + getCreateTimeRange() + "'" + - ", createTimeStart =" + getCreateTimeEnd() + - ", createTimeEnd =" + getCreateTimeEnd() + - ", orderBy='" + getOrderBy() + "'" + - '}'; - } -} diff --git a/src/main/java/com/lunhan/xxx/entity/search/SearchQuartzTaskRecord.java b/src/main/java/com/lunhan/xxx/entity/search/SearchQuartzTaskRecord.java deleted file mode 100644 index 837df4e..0000000 --- a/src/main/java/com/lunhan/xxx/entity/search/SearchQuartzTaskRecord.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.lunhan.xxx.entity.search; - -import com.lunhan.xxx.entity.dto.SearchBasicDTO; -import lombok.Data; - -/** - * 定时任务执行情况记录表 - * @author lin.liu - * @description 定时任务执行情况记录表 - */ -@Data -public class SearchQuartzTaskRecord extends SearchBasicDTO { - /** - * 任务编号 - */ - private String taskNo; - /** - * 执行时间-范围(eg: 2021-01-01 00:00:00 ~ 2021-01-01 23:59:59)" - */ - private String executeTimeRange; - /** - * 执行时间-起始 - * @ignore - */ - private Long executeTimeStart; - /** - * 执行时间-截止 - * @ignore - */ - private Long executeTimeEnd; - - @Override - public String toString() { - return "SearchQuartzTaskRecord{" + "'" + - "keywords='" + getKeywords() + - ", status =" + getStatus() + - ", listStatus =" + getListStatus() + - ", createTimeRange='" + getCreateTimeRange() + "'" + - ", createTimeStart =" + getCreateTimeEnd() + - ", createTimeEnd =" + getCreateTimeEnd() + - ", orderBy='" + getOrderBy() + "'" + - ", taskNo='" + taskNo + "'" + - ", executeTimeRange='" + executeTimeRange + "'" + - ", executeTimeStart =" + executeTimeStart + - ", executeTimeEnd =" + executeTimeEnd + - '}'; - } -} diff --git a/src/main/java/com/lunhan/xxx/entity/search/SearchSysDictData.java b/src/main/java/com/lunhan/xxx/entity/search/SearchSysDictData.java deleted file mode 100644 index 79c57c2..0000000 --- a/src/main/java/com/lunhan/xxx/entity/search/SearchSysDictData.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.lunhan.xxx.entity.search; - -import com.lunhan.xxx.entity.dto.SearchBasicDTO; -import lombok.Data; - -/** - * 字典数据表 - * @author lin.liu - * @description 字典数据表 - */ -@Data -public class SearchSysDictData extends SearchBasicDTO { - -} diff --git a/src/main/java/com/lunhan/xxx/entity/search/SearchSysDictType.java b/src/main/java/com/lunhan/xxx/entity/search/SearchSysDictType.java deleted file mode 100644 index c0b19a8..0000000 --- a/src/main/java/com/lunhan/xxx/entity/search/SearchSysDictType.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.lunhan.xxx.entity.search; - -import com.lunhan.xxx.entity.dto.SearchBasicDTO; -import lombok.Data; - -/** - * 字典类型表 - * @author lin.liu - * @description 字典类型表 - */ -@Data -public class SearchSysDictType extends SearchBasicDTO { - -} diff --git a/src/main/java/com/lunhan/xxx/entity/search/SearchTestInfo.java b/src/main/java/com/lunhan/xxx/entity/search/SearchTestInfo.java deleted file mode 100644 index 0945ed3..0000000 --- a/src/main/java/com/lunhan/xxx/entity/search/SearchTestInfo.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.lunhan.xxx.entity.search; - -import com.lunhan.xxx.entity.dto.SearchBasicDTO; - -/** - * 测试信息 查询条件dto - * @author lin.liu - * @description 测试信息 查询条件dto - * @date 2021/11/23 - */ -public class SearchTestInfo extends SearchBasicDTO { - /** - * EOrderBy-此字段仅为“orderBy”说明枚举类型,无需传参 - */ - private String orderByEnum; - - public String getOrderByEnum() { - return orderByEnum; - } - - public void setOrderByEnum(String orderByEnum) { - this.orderByEnum = orderByEnum; - } - - @Override - public String toString() { - return "SearchTestInfo{" + "'" + - "keywords='" + getKeywords() + - ", listId =" + getListId() + - ", status =" + getStatus() + - ", listStatus =" + getListStatus() + - ", createTimeRange='" + getCreateTimeRange() + "'" + - ", createTimeStart =" + getCreateTimeEnd() + - ", createTimeEnd =" + getCreateTimeEnd() + - ", lastId =" + getListId() + - ", orderByEnum='" + getOrderByEnum() + '\'' + - ", orderBy='" + getOrderBy() + '\'' + - '}'; - } -} diff --git a/src/main/java/com/lunhan/xxx/host/ApplicationStarter.java b/src/main/java/com/lunhan/xxx/host/ApplicationStarter.java deleted file mode 100644 index 22b2de4..0000000 --- a/src/main/java/com/lunhan/xxx/host/ApplicationStarter.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.lunhan.xxx.host; - -import com.yomahub.tlog.core.enhance.AspectLogEnhance; -import org.mybatis.spring.annotation.MapperScan; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.builder.SpringApplicationBuilder; -import org.springframework.boot.web.servlet.ServletComponentScan; -import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; -import org.springframework.cache.annotation.EnableCaching; - -@SpringBootApplication(scanBasePackages = { "com.lunhan" }) -@ServletComponentScan -@MapperScan("com.lunhan.xxx.repository.mapper") -// 开启缓存 -@EnableCaching -public class ApplicationStarter extends SpringBootServletInitializer { - static { - // 进行日志增强,自动判断日志框架。自动给每条日志加上一个全局唯一的traceId - AspectLogEnhance.enhance(); - } - - public static void main(String[] args) { - SpringApplication.run(ApplicationStarter.class, args); - } - - @Override - protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { - return application.sources(ApplicationStarter.class); - } -} diff --git a/src/main/java/com/lunhan/xxx/host/BasicController.java b/src/main/java/com/lunhan/xxx/host/BasicController.java deleted file mode 100644 index cb3bb9a..0000000 --- a/src/main/java/com/lunhan/xxx/host/BasicController.java +++ /dev/null @@ -1,62 +0,0 @@ -package com.lunhan.xxx.host; - -import com.lunhan.xxx.common.ExecutedResult; -import com.lunhan.xxx.common.config.SysConfig; -import com.lunhan.xxx.common.jwt.JWTUtil; -import com.lunhan.xxx.common.jwt.LoginUserDTO; -import org.springframework.web.context.request.RequestAttributes; -import org.springframework.web.context.request.RequestContextHolder; -import org.springframework.web.context.request.ServletRequestAttributes; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -/** - * 基础controller - */ -public class BasicController { - - /** - * 获取当前请求上下文的“HttpServletRequest”对象 - */ - protected HttpServletRequest ServletRequest() { - RequestAttributes reqAttributes = RequestContextHolder.currentRequestAttributes(); - if (null == reqAttributes) { - return null; - } - ServletRequestAttributes servletReqAttributes = (ServletRequestAttributes)reqAttributes; - return servletReqAttributes.getRequest(); - } - - /** - * 获取当前请求上下文的“HttpServletResponse”对象 - */ - protected HttpServletResponse ServletResponse() { - RequestAttributes reqAttributes = RequestContextHolder.currentRequestAttributes(); - if (null == reqAttributes) { - return null; - } - ServletRequestAttributes servletReqAttributes = (ServletRequestAttributes)reqAttributes; - return servletReqAttributes.getResponse(); - } - - protected String getToken() { - return this.ServletRequest().getHeader(SysConfig.getTokenHeader()); - } - - protected String getHeader(String key) { - return this.ServletRequest().getHeader(key); - } - - protected LoginUserDTO getTokenUser() { - return JWTUtil.getUser(this.getToken()); - } - - protected <T> ExecutedResult<T> success(T data) { - return ExecutedResult.success(data); - } - - protected <T> ExecutedResult<T> failed(String msg) { - return ExecutedResult.failed(msg); - } -} \ No newline at end of file diff --git a/src/main/java/com/lunhan/xxx/host/api/ApiRequestLogDTO.java b/src/main/java/com/lunhan/xxx/host/api/ApiRequestLogDTO.java deleted file mode 100644 index 4818c10..0000000 --- a/src/main/java/com/lunhan/xxx/host/api/ApiRequestLogDTO.java +++ /dev/null @@ -1,113 +0,0 @@ -package com.lunhan.xxx.host.api; - -public class ApiRequestLogDTO { - private String requestId; - private String requestIP; - private String path; - private String desc; - private String method; - private Long requestTime; - private String requestData; - private String requestToken; - private String requestHeaders; - private Long responseTime; - private Long spendTime; - private String responseData; - - - public String getRequestId() { - return requestId; - } - - public void setRequestId(String requestId) { - this.requestId = requestId; - } - - public String getRequestIP() { - return requestIP; - } - - public void setRequestIP(String requestIP) { - this.requestIP = requestIP; - } - - public String getPath() { - return path; - } - - public void setPath(String path) { - this.path = path; - } - - public String getDesc() { - return desc; - } - - public void setDesc(String desc) { - this.desc = desc; - } - - public String getMethod() { - return method; - } - - public void setMethod(String method) { - this.method = method; - } - - public Long getRequestTime() { - return requestTime; - } - - public void setRequestTime(Long requestTime) { - this.requestTime = requestTime; - } - - public String getRequestData() { - return requestData; - } - - public void setRequestData(String requestData) { - this.requestData = requestData; - } - - public String getRequestToken() { - return requestToken; - } - - public void setRequestToken(String requestToken) { - this.requestToken = requestToken; - } - - public String getRequestHeaders() { - return requestHeaders; - } - - public void setRequestHeaders(String requestHeaders) { - this.requestHeaders = requestHeaders; - } - - public Long getResponseTime() { - return responseTime; - } - - public void setResponseTime(Long responseTime) { - this.responseTime = responseTime; - } - - public Long getSpendTime() { - return spendTime; - } - - public void setSpendTime(Long spendTime) { - this.spendTime = spendTime; - } - - public String getResponseData() { - return responseData; - } - - public void setResponseData(String responseData) { - this.responseData = responseData; - } -} diff --git a/src/main/java/com/lunhan/xxx/host/api/CorsFilterConfig.java b/src/main/java/com/lunhan/xxx/host/api/CorsFilterConfig.java deleted file mode 100644 index e1393be..0000000 --- a/src/main/java/com/lunhan/xxx/host/api/CorsFilterConfig.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.lunhan.xxx.host.api; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.web.cors.CorsConfiguration; -import org.springframework.web.cors.UrlBasedCorsConfigurationSource; -import org.springframework.web.filter.CorsFilter; - -// 一定不能忽略此注解 -@Configuration -public class CorsFilterConfig { - /** - * 跨域过滤器 TODO 如果通过ngix或者其他方式配置了跨域,请注释掉 @Bean 注解 - * @return CorsFilter 跨域过滤器对象 - */ - - @Bean - public CorsFilter corsFilter() { - UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); - source.registerCorsConfiguration("/**", buildConfig()); - return new CorsFilter(source); - } - - private CorsConfiguration buildConfig() { - CorsConfiguration corsConfiguration = new CorsConfiguration(); - corsConfiguration.addAllowedOrigin("*"); - corsConfiguration.addAllowedHeader("*"); - corsConfiguration.addAllowedMethod("*"); - return corsConfiguration; - } -} diff --git a/src/main/java/com/lunhan/xxx/host/api/GlobalExceptionHandler.java b/src/main/java/com/lunhan/xxx/host/api/GlobalExceptionHandler.java deleted file mode 100644 index fdd47b3..0000000 --- a/src/main/java/com/lunhan/xxx/host/api/GlobalExceptionHandler.java +++ /dev/null @@ -1,92 +0,0 @@ -package com.lunhan.xxx.host.api; - -import com.google.common.base.Charsets; -import com.lunhan.xxx.common.enums.ELogger; -import com.lunhan.xxx.common.enums.EResultCode; -import com.lunhan.xxx.common.ExecutedResult; -import com.lunhan.xxx.common.exceptions.BusinessException; -import com.lunhan.xxx.common.util.*; -import org.slf4j.Logger; -import org.springframework.web.bind.annotation.ControllerAdvice; -import org.springframework.web.bind.annotation.ExceptionHandler; -import org.springframework.web.bind.annotation.ResponseBody; -import org.springframework.web.context.request.RequestContextHolder; -import org.springframework.web.context.request.ServletRequestAttributes; - -import javax.servlet.http.HttpServletRequest; - -/** - * 全局异常处理 - */ -@ControllerAdvice -public class GlobalExceptionHandler { - private static final Logger sysLogger = LoggerUtil.get(ELogger.SYS_ERROR); - private static final Logger logger = LoggerUtil.get(ELogger.API_REQUEST); - @ResponseBody - @ExceptionHandler(value = Exception.class) - public ExecutedResult<String> handle(Exception e) { - ExecutedResult<String> result = new ExecutedResult<>(EResultCode.ERROR, "", e.getMessage()); - - // 记录请求日志 - this.writeLog(result); - - sysLogger.error("SysError", e); - return result; - } - - - @ResponseBody - @ExceptionHandler(value = BusinessException.class) - public ExecutedResult<String> handle(BusinessException e) { - ExecutedResult<String> result = new ExecutedResult<>(e.getCode(), "", e.getMessage()); - - // 记录请求日志 - this.writeLog(result); - - return result; - } - - private void writeLog(ExecutedResult<String> result) { - //获取当前请求对象 - ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); - if (null == attributes) { - return; - } - HttpServletRequest request = attributes.getRequest(); - String data; - try { - byte[] buffer = HttpUtil.getBytesFromInputStream(request.getInputStream()); - data = new String(buffer, Charsets.UTF_8); - } catch (Exception e) { - data = ""; - } - ApiRequestLogDTO webLog = HttpRequestLogPool.getRequestInfo(); - if (null == webLog) { - return; - } - String log = String.format("[%s]" + - "%nrequestPath: %s[%s]" + - "%nreponseData: %s" + - "%nrequestTime: %s" + - "%nresponseTime: %s" + - "%nspendTime: %s" + - "%nmethod: %s" + - "%nrequestIp: %s" + - "%ntokenCode: %s" + - "%nrequestData: %s", - - "", - webLog.getPath(), - "", - SerializeUtil.toJson(result), - LocalDateTimeUtil.toFormatFullString(webLog.getRequestTime()), - LocalDateTimeUtil.nowDateTimeFullStr(), - LocalDateTimeUtil.nowTimeStamp() - webLog.getRequestTime(), - webLog.getMethod(), - webLog.getRequestIP(), - webLog.getRequestToken(), - data - ); - logger.info(log); - } -} diff --git a/src/main/java/com/lunhan/xxx/host/api/HttpRequestLogPool.java b/src/main/java/com/lunhan/xxx/host/api/HttpRequestLogPool.java deleted file mode 100644 index 77536ae..0000000 --- a/src/main/java/com/lunhan/xxx/host/api/HttpRequestLogPool.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.lunhan.xxx.host.api; - -class HttpRequestLogPool { - private static ThreadLocal<ApiRequestLogDTO> requestThreadLocal = new ThreadLocal<>(); - - public static void setRequestInfo(ApiRequestLogDTO requestInfo) { - requestThreadLocal.set(requestInfo); - } - - public static ApiRequestLogDTO getRequestInfo() { - ApiRequestLogDTO result = requestThreadLocal.get(); - requestThreadLocal.remove(); - return result; - } - -} diff --git a/src/main/java/com/lunhan/xxx/host/api/MustAdmin.java b/src/main/java/com/lunhan/xxx/host/api/MustAdmin.java deleted file mode 100644 index 3bb4b9b..0000000 --- a/src/main/java/com/lunhan/xxx/host/api/MustAdmin.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.lunhan.xxx.host.api; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * 标记必须是管理员(作用整个controller类,或者某个接口方法) - */ - -@Target(value = { ElementType.TYPE, ElementType.METHOD }) -@Retention(RetentionPolicy.RUNTIME) -public @interface MustAdmin { -} diff --git a/src/main/java/com/lunhan/xxx/host/api/MvcTokenInterceptors.java b/src/main/java/com/lunhan/xxx/host/api/MvcTokenInterceptors.java deleted file mode 100644 index 7301feb..0000000 --- a/src/main/java/com/lunhan/xxx/host/api/MvcTokenInterceptors.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.lunhan.xxx.host.api; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Configuration; -import org.springframework.web.servlet.config.annotation.InterceptorRegistration; -import org.springframework.web.servlet.config.annotation.InterceptorRegistry; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; - -@Configuration -public class MvcTokenInterceptors implements WebMvcConfigurer { - @Autowired - private TokenFilter tokenFilter; - - - @Override - public void addInterceptors(InterceptorRegistry registry) { - //添加处理拦截器,拦截所有请求 - InterceptorRegistration interceptorRegistration = registry.addInterceptor(tokenFilter); - //配置拦截策略 所有路径都被拦截 - interceptorRegistration.addPathPatterns("/**"); - //排除配置 这里接口的跳过不使用此方式排除,通过注解“NonLogin”跳过拦截 - interceptorRegistration.excludePathPatterns( - "/**/*.html", - "/**/*.vue" - , "/**/*.css" - , "/**/*.js" - , "/**/*.js.map" - , "/*.ico" - , "/**/*.jpg" - , "/**/*.png" - , "/**/*.woff" - , "/**/*.ttf" - ,"/**/*.json" - , "/doc/*" - , "/swagger/*" - , "/swagger\\-ui/*" - , "/swagger3/*" -// , "/login/*" -// , "/user/login" - ); - } -} diff --git a/src/main/java/com/lunhan/xxx/host/api/MyBatisPlusConfig.java b/src/main/java/com/lunhan/xxx/host/api/MyBatisPlusConfig.java deleted file mode 100644 index b1e0b3c..0000000 --- a/src/main/java/com/lunhan/xxx/host/api/MyBatisPlusConfig.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.lunhan.xxx.host.api; - -import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; -import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -@Configuration -public class MyBatisPlusConfig { - @Bean - public MybatisPlusInterceptor paginationInterceptor() { - MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); - interceptor.addInnerInterceptor(new PaginationInnerInterceptor()); - return interceptor; - } -} diff --git a/src/main/java/com/lunhan/xxx/host/api/NonLogin.java b/src/main/java/com/lunhan/xxx/host/api/NonLogin.java deleted file mode 100644 index dd31f40..0000000 --- a/src/main/java/com/lunhan/xxx/host/api/NonLogin.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.lunhan.xxx.host.api; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * 不需要登陆注解(作用整个controller类,或者某个接口方法) - */ - -@Target(value = { ElementType.TYPE, ElementType.METHOD }) -@Retention(RetentionPolicy.RUNTIME) -public @interface NonLogin { -} diff --git a/src/main/java/com/lunhan/xxx/host/api/TokenFilter.java b/src/main/java/com/lunhan/xxx/host/api/TokenFilter.java deleted file mode 100644 index 6971c21..0000000 --- a/src/main/java/com/lunhan/xxx/host/api/TokenFilter.java +++ /dev/null @@ -1,116 +0,0 @@ -package com.lunhan.xxx.host.api; - -import com.lunhan.xxx.common.config.SysConfig; -import com.lunhan.xxx.common.enums.EResultCode; -import com.lunhan.xxx.common.exceptions.BusinessException; -import com.lunhan.xxx.common.jwt.JWTUtil; -import com.lunhan.xxx.common.jwt.LoginUserDTO; -import com.lunhan.xxx.common.util.IPUtils; -import com.lunhan.xxx.common.util.LocalDateTimeUtil; -import com.lunhan.xxx.common.util.RandVerifyCode; -import com.lunhan.xxx.common.util.StringUtil; -import com.lunhan.xxx.entity.enums.EUserType; -import org.apache.commons.lang3.BooleanUtils; -import org.springframework.core.annotation.AnnotationUtils; -import org.springframework.stereotype.Component; -import org.springframework.web.method.HandlerMethod; -import org.springframework.web.servlet.HandlerInterceptor; -import org.springframework.web.servlet.ModelAndView; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; - - -@Component -public class TokenFilter implements HandlerInterceptor { - @Override - public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) { - String method = request.getMethod(); - if ("options".equalsIgnoreCase(method)) { - - return true; - } - Long now = LocalDateTimeUtil.nowTimeStamp(); - String reqId = now + RandVerifyCode.complexCode(6); - ApiRequestLogDTO req = new ApiRequestLogDTO(); - req.setRequestTime(now); - req.setRequestId(reqId); - req.setRequestIP(IPUtils.getIpAddress(request)); - String urlParams = request.getQueryString(); - if (StringUtil.isNotNullOrEmpty(urlParams)) { - urlParams = "?" + urlParams; - } - req.setPath(request.getRequestURI() + urlParams); - req.setMethod(method); - req.setRequestData(""); -// Map<String, String> mapHeaders = new HashMap<>(); -// Enumeration<String> headerNames = request.getHeaderNames(); -// String key = headerNames.nextElement(); -// while (StringUtil.isNotNullOrEmpty(key)) { -// mapHeaders.put(key, request.getHeader(key)); -// key = headerNames.nextElement(); -// } - req.setRequestHeaders(""); - String token = request.getHeader(SysConfig.getTokenHeader()); - req.setRequestToken(token); - HttpRequestLogPool.setRequestInfo(req); - - List<Class<?>> listHas = new ArrayList<>(); - if (handler instanceof HandlerMethod) { - HandlerMethod methodHandle = (HandlerMethod) handler; - Class<?> clazz = ((HandlerMethod) handler).getBeanType(); - - NonLogin nonLogin = methodHandle.getMethodAnnotation(NonLogin.class); - // 如果方法拥有跳过登陆验权的注解,则返回成功 - if (Objects.nonNull(nonLogin)) { - return true; - } - nonLogin = AnnotationUtils.findAnnotation(clazz, NonLogin.class); - // 如果此方法所属类拥有跳过登陆验权的注解,则返回成功 - if (Objects.nonNull(nonLogin)) { - return true; - } - - MustAdmin mustAdmin = methodHandle.getMethodAnnotation(MustAdmin.class); - if (Objects.nonNull(mustAdmin)) { - listHas.add(MustAdmin.class); - } - mustAdmin = AnnotationUtils.findAnnotation(clazz, MustAdmin.class); - if (Objects.nonNull(mustAdmin)) { - listHas.add(MustAdmin.class); - } - } - if (Objects.isNull(token)) { - throw new BusinessException(EResultCode.UNAUTHORIZED, "token未传入"); - } - - // 验证token - LoginUserDTO user = JWTUtil.getUser(token); - // 超级管理员拥有所有权限 - if (Objects.equals(user.getUserType(), EUserType.ADMIN.getValue())) { - return true; - } - if ( - listHas.contains(MustAdmin.class) && ( - BooleanUtils.isFalse(Objects.equals(user.getUserType(), EUserType.ADMIN.getValue())) && - BooleanUtils.isFalse(Objects.equals(user.getUserType(), EUserType.ADMIN_USER.getValue())) - ) - ) { - throw new BusinessException(EResultCode.FORBIDDEN, "没有权限"); - } - return true; - } - - @Override - public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) { - - } - - @Override - public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) { - - } -} diff --git a/src/main/java/com/lunhan/xxx/host/api/WebLogAspect.java b/src/main/java/com/lunhan/xxx/host/api/WebLogAspect.java deleted file mode 100644 index 28a8a59..0000000 --- a/src/main/java/com/lunhan/xxx/host/api/WebLogAspect.java +++ /dev/null @@ -1,209 +0,0 @@ -package com.lunhan.xxx.host.api; - -import java.lang.reflect.Method; -import java.lang.reflect.Parameter; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import javax.servlet.http.HttpServletRequest; - -import com.lunhan.xxx.common.enums.ELogger; -import com.lunhan.xxx.common.util.*; -import org.aspectj.lang.JoinPoint; -import org.aspectj.lang.ProceedingJoinPoint; -import org.aspectj.lang.Signature; -import org.aspectj.lang.annotation.AfterReturning; -import org.aspectj.lang.annotation.Around; -import org.aspectj.lang.annotation.Aspect; -import org.aspectj.lang.annotation.Before; -import org.aspectj.lang.annotation.Pointcut; -import org.aspectj.lang.reflect.MethodSignature; -import org.slf4j.Logger; -import org.springframework.core.annotation.Order; -import org.springframework.stereotype.Component; -import org.springframework.util.StringUtils; -import org.springframework.web.bind.annotation.*; -import org.springframework.web.context.request.RequestContextHolder; -import org.springframework.web.context.request.ServletRequestAttributes; - -/** - * 统一日志处理切面 - * Created by macro on 2018/4/26. - */ -@Aspect -@Component -@Order(1) -public class WebLogAspect { - private static final Logger logger = LoggerUtil.get(ELogger.API_REQUEST); - private static final Logger sysLogger = LoggerUtil.get(ELogger.SYS_ERROR); - /** - * 100毫秒 - */ - private static final long MS_100 = 100; - /** - * 2秒 - */ - private static final long SEC_1 = 1000; - /** - * 2秒 - */ - private static final long SEC_2 = 2 * 1000; - /** - * 10秒 - */ - private static final long SEC_10 = 10 * 1000; - /** - * 1分钟 - */ - private static final long MINS_1 = 60 * 1000; - /** - * 5分钟 - */ - private static final long MINS_5 = 5 * 60 * 1000; - - @Pointcut( - "execution(public * com.lunhan.*.host.controller.*.*(..))" + - "||execution(public * com.lunhan.*.host.admin.*.*(..))" + - "||execution(public * com.lunhan.*.host.customer.*.*(..))" - ) - public void webLog() { - } - - @Before("webLog()") - public void doBefore(JoinPoint joinPoint) { - } - - @AfterReturning(value = "webLog()", returning = "ret") - public void doAfterReturning(Object ret) { - } - - - @Around("webLog()") - public Object doAround(ProceedingJoinPoint joinPoint) throws Throwable { - long startTime = System.currentTimeMillis(); - //获取当前请求对象 - ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); - HttpServletRequest request = attributes.getRequest(); - //记录请求信息(通过Logstash传入Elasticsearch) - ApiRequestLogDTO webLog = HttpRequestLogPool.getRequestInfo(); - Object result = joinPoint.proceed(); - Signature signature = joinPoint.getSignature(); - MethodSignature methodSignature = (MethodSignature) signature; - Method method = methodSignature.getMethod(); -// if (method.isAnnotationPresent(ApiOperation.class)) { -// ApiOperation log = method.getAnnotation(ApiOperation.class); -// webLog.setDescription(log.value()); -// } - String desc; - switch (webLog.getMethod()) { - case "POST": - desc = method.getAnnotation(PostMapping.class).name(); - break; - case "GET": - desc = method.getAnnotation(GetMapping.class).name(); - break; - case "PUT": - desc = method.getAnnotation(PutMapping.class).name(); - break; - case "Delete": - desc = method.getAnnotation(DeleteMapping.class).name(); - break; - default: - desc = ""; - break; - } - webLog.setDesc(desc); - - Long endTime = LocalDateTimeUtil.nowTimeStamp(); - webLog.setResponseTime(endTime); - webLog.setRequestData(SerializeUtil.toJson(getParameter(method, joinPoint.getArgs()))); - webLog.setResponseData(SerializeUtil.toJson(result)); - webLog.setSpendTime((endTime - startTime)); - - String usedTimesLevel; - if (webLog.getSpendTime() > MINS_5) {//大于5分钟 - usedTimesLevel = "F"; - } else if (webLog.getSpendTime() > MINS_1) {//1 - 5分钟 - usedTimesLevel = "E"; - } else if (webLog.getSpendTime() > SEC_10) {//10秒 - 1分钟 - usedTimesLevel = "D"; - } else if (webLog.getSpendTime() > SEC_2) {//2秒 - 10秒 - usedTimesLevel = "C"; - } else if (webLog.getSpendTime() > SEC_1) {//1秒 - 2秒 - usedTimesLevel = "B"; - } else if (webLog.getSpendTime() > MS_100) {//100毫秒 - 1秒 - usedTimesLevel = "A"; - } else {//100毫秒以内 - usedTimesLevel = "SSS"; - } - - List<String> listTag = new ArrayList<>(); - listTag.add("url=" + webLog.getPath()); - listTag.add("method=" + webLog.getMethod()); - listTag.add("spendTime=" + webLog.getSpendTime()); - listTag.add("description=" + webLog.getDesc()); - listTag.add("tokenCode=" + webLog.getRequestToken()); - listTag.add("usedTimesLevel=" + usedTimesLevel); - - String log = String.format("[%s]" + - "%nrequestPath: %s[%s]" + - "%nreponseData: %s" + - "%nrequestTime: %s" + - "%nresponseTime: %s" + - "%nspendTime: %s" + - "%nmethod: %s" + - "%nrequestIp: %s" + - "%ntokenCode: %s" + - "%nrequestData: %s", - - StringUtil.join(listTag, "],["), - webLog.getPath(), - webLog.getDesc(), - webLog.getResponseData(), - LocalDateTimeUtil.toFormatFullString(webLog.getRequestTime()), - LocalDateTimeUtil.toFormatFullString(webLog.getResponseTime()), - webLog.getSpendTime(), - webLog.getMethod(), - webLog.getRequestIP(), - webLog.getRequestToken(), - webLog.getRequestData() - ); - - logger.info(log); - return result; - } - - /** - * 根据方法和传入的参数获取请求参数 - */ - private Object getParameter(Method method, Object[] args) { - List<Object> argList = new ArrayList<>(); - Parameter[] parameters = method.getParameters(); - for (int i = 0; i < parameters.length; i++) { - //将RequestBody注解修饰的参数作为请求参数 - RequestBody requestBody = parameters[i].getAnnotation(RequestBody.class); - if (requestBody != null) { - argList.add(args[i]); - } - //将RequestParam注解修饰的参数作为请求参数 - RequestParam requestParam = parameters[i].getAnnotation(RequestParam.class); - if (requestParam != null) { - Map<String, Object> map = new HashMap<>(); - String key = parameters[i].getName(); - if (!StringUtils.isEmpty(requestParam.value())) { - key = requestParam.value(); - } - map.put(key, args[i]); - argList.add(map); - } - } - if (argList.size() == 0) { - return null; - } else if (argList.size() == 1) { - return argList.get(0); - } else { - return argList; - } - } -} diff --git a/src/main/java/com/lunhan/xxx/host/api/WebMvcConfig.java b/src/main/java/com/lunhan/xxx/host/api/WebMvcConfig.java deleted file mode 100644 index 8d1a279..0000000 --- a/src/main/java/com/lunhan/xxx/host/api/WebMvcConfig.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.lunhan.xxx.host.api; - -import org.springframework.context.annotation.Configuration; -import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; - -@Configuration -public class WebMvcConfig implements WebMvcConfigurer { - @Override - public void addResourceHandlers(ResourceHandlerRegistry registry) { - // 添加一个静态资源映射 将/logs/upload/xxx 映射到文件上传目录 - registry.addResourceHandler("/upload/**").addResourceLocations("file:" + System.getProperty("user.dir") + "/logs/upload/"); - } -} diff --git a/src/main/java/com/lunhan/xxx/host/controller/TestInfoServiceController.java b/src/main/java/com/lunhan/xxx/host/controller/TestInfoServiceController.java deleted file mode 100644 index 34cdd05..0000000 --- a/src/main/java/com/lunhan/xxx/host/controller/TestInfoServiceController.java +++ /dev/null @@ -1,257 +0,0 @@ -package com.lunhan.xxx.host.controller; - -import com.lunhan.xxx.common.ConstantFactory; -import com.lunhan.xxx.common.ExecutedResult; -import com.lunhan.xxx.common.PagerResult; -import com.lunhan.xxx.common.util.ParameterUtil; -import com.lunhan.xxx.common.validator.ParameterValidateResult; -import com.lunhan.xxx.common.validator.ParameterValidator; -import com.lunhan.xxx.entity.enums.ESex; -import com.lunhan.xxx.entity.request.ReqListId; -import com.lunhan.xxx.entity.request.ReqListSetSort; -import com.lunhan.xxx.entity.request.ReqSetSort; -import com.lunhan.xxx.entity.request.test.ReqCreateTestInfo; -import com.lunhan.xxx.entity.request.test.ReqModifyTestInfo; -import com.lunhan.xxx.entity.search.SearchTestInfo; -import com.lunhan.xxx.host.BasicController; -import com.lunhan.xxx.host.api.NonLogin; -import com.lunhan.xxx.repository.vo.TestInfoVO; -import com.lunhan.xxx.service.TestInfoService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.*; - -import java.math.BigDecimal; -import java.util.List; - -/** - * 99999.测试信息相关接口 - * - * @author lin.liu - * @date 2021/11/23 - * @order 99999 - */ -@NonLogin -@RestController -@RequestMapping(value = "testInfo") -public class TestInfoServiceController extends BasicController { - @Autowired - private TestInfoService service; - /** - * 创建[测试信息] - * - * @author lin.liu - * @date 2021/11/23 - */ - @PostMapping(value = "create") - public ExecutedResult<Long> create(@RequestBody ReqCreateTestInfo request) { - //#region 参数验证 - ParameterValidator validator = new ParameterValidator() - // 非空 - .addNotNullOrEmpty(ParameterUtil.named("名称"), request.getName()) - // 限制最大长度 - .addLengthMax(ParameterUtil.named("名称"), request.getName(), ConstantFactory.LENGTH_MAX50) - // 必须大于0 - .addGreater(ParameterUtil.named("用户id"), request.getUserId(), 0L) - // 必须是手机号码(正则) - .addMustMobile(ParameterUtil.named("电话"), request.getPhone()) - // 金额大于0 - .addGreaterThan(ParameterUtil.named("余额"), request.getBalance(), BigDecimal.ZERO) - // 必须是枚举值 - .addMustEnum(ParameterUtil.named("性别"), request.getSex(), ESex.class) - // 必须是日期字符串(yyyy-MM-dd) - .addMustDate(ParameterUtil.named("生日"), request.getBirthday()) - // 必须大于0 - .addGreater(ParameterUtil.named("排序值"), request.getSort(), 0) - // 限制最大长度 - .addLengthMax(ParameterUtil.named("备注"), request.getComment(), ConstantFactory.LENGTH_MAX500); - ParameterValidateResult result = validator.validate(); - if (result.getIsFiled()) { - return failed(result.getErrorMsg()); - } - //#endregion - return this.service.create(request); - } - - /** - * 编辑[测试信息] - * - * @author lin.liu - * @date 2021/11/23 - */ - @PostMapping(value = "modify") - public ExecutedResult<String> modify(@RequestBody ReqModifyTestInfo request) { - //#region 参数验证 - ParameterValidator validator = new ParameterValidator() - // 必须大于0 - .addGreater(ParameterUtil.named("[测试信息]id"), request.getId(), 0L) - // 非空 - .addNotNullOrEmpty(ParameterUtil.named("名称"), request.getName()) - // 限制最大长度 - .addLengthMax(ParameterUtil.named("名称"), request.getName(), ConstantFactory.LENGTH_MAX50) - // 必须大于0 - .addGreater(ParameterUtil.named("用户id"), request.getUserId(), 0L) - // 必须是手机号码(正则) - .addMustMobile(ParameterUtil.named("电话"), request.getPhone()) - // 金额大于0 - .addGreaterThan(ParameterUtil.named("余额"), request.getBalance(), BigDecimal.ZERO) - // 必须是枚举值 - .addMustEnum(ParameterUtil.named("性别"), request.getSex(), ESex.class) - // 必须是日期字符串(yyyy-MM-dd) - .addMustDate(ParameterUtil.named("生日"), request.getBirthday()) - // 必须大于0 - .addGreater(ParameterUtil.named("排序值"), request.getSort(), 0) - // 限制最大长度 - .addLengthMax(ParameterUtil.named("备注"), request.getComment(), ConstantFactory.LENGTH_MAX500); - ParameterValidateResult result = validator.validate(); - if (result.getIsFiled()) { - return failed(result.getErrorMsg()); - } - //#endregion - return this.service.modify(request); - } - - /** - * 获取[测试信息] - * - * @author lin.liu - * @date 2021/11/23 - */ - @GetMapping(value = "get/{id}") - public ExecutedResult<TestInfoVO> get(@PathVariable Long id) { - return this.service.get(id); - } - - /** - * 根据id批量获取[测试信息] - * - * @author lin.liu - * @date 2021/11/23 - */ - @PostMapping(value = "getList") - public ExecutedResult<List<TestInfoVO>> getList(@RequestBody ReqListId request) { - //#region 参数验证 - ParameterValidator validator = new ParameterValidator() - // 不能为空 - .addNotNullOrEmpty(ParameterUtil.named("[测试信息]id列表"), request.getListId()) - ; - ParameterValidateResult result = validator.validate(); - if (result.getIsFiled()) { - return failed(result.getErrorMsg()); - } - //#endregion - return this.service.getList(request.getListId()); - } - - /** - * [测试信息]设置排序值 - * - * @author lin.liu - * @date 2021/11/23 - */ - @PostMapping(value = "setSort") - public ExecutedResult<String> setSort(@RequestBody ReqSetSort request) { - //#region 参数验证 - ParameterValidator validator = new ParameterValidator() - // 必须大于0 - .addGreater(ParameterUtil.named("[测试信息]id"), request.getId(), 0L) - // 必须大于0 - .addGreaterThan(ParameterUtil.named("排序值"), request.getSort(), 0) - ; - ParameterValidateResult result = validator.validate(); - if (result.getIsFiled()) { - return failed(result.getErrorMsg()); - } - //#endregion - return this.service.setSort(request); - } - - /** - * [测试信息]批量设置排序值 - * - * @author lin.liu - * @date 2021/11/23 - */ - @PostMapping(value = "listSetSort") - ExecutedResult<String> listSetSort(ReqListSetSort request) { - //#region 参数验证 - ParameterValidator validator = new ParameterValidator() - // 不能为空 - .addNotNullOrEmpty(ParameterUtil.named("[测试信息]排序设置列表"), request.getList()) - ; - ParameterValidateResult result = validator.validate(); - if (result.getIsFiled()) { - return failed(result.getErrorMsg()); - } - //#endregion - return this.service.listSetSort(request); - } - - /** - * 停用[测试信息] - * - * @param id [测试]id - * @author lin.liu - * @date 2021/11/23 - */ - @PostMapping(value = "stop/{id}") - public ExecutedResult<String> stop(@PathVariable Long id) { - return this.service.stop(id); - } - - /** - * 启用[测试信息] - * - * @param id [测试]id - * @author lin.liu - * @date 2021/11/23 - */ - @PostMapping(value = "enable/{id}") - public ExecutedResult<String> enable(@PathVariable Long id) { - return this.service.enable(id); - } - - /** - * 删除[测试信息] - * - * @param id [测试]id - * @author lin.liu - * @date 2021/11/23 - */ - @PostMapping(value = "remove/{id}") - public ExecutedResult<String> remove(@PathVariable Long id) { - return this.service.remove(id); - } - - /** - * 批量删除[测试信息] - * - * @author lin.liu - * @date 2021/11/23 - */ - @PostMapping(value = "removeList") - public ExecutedResult<String> removeList(@RequestBody ReqListId request) { - //#region 参数验证 - ParameterValidator validator = new ParameterValidator() - // 不能为空 - .addNotNullOrEmpty(ParameterUtil.named("[测试信息]id列表"), request.getListId()) - ; - ParameterValidateResult result = validator.validate(); - if (result.getIsFiled()) { - return failed(result.getErrorMsg()); - } - //#endregion - return this.service.removeList(request.getListId()); - } - - /** - * 查询[测试信息] - * - * @author lin.liu - * @date 2021/11/23 - */ - @NonLogin - @PostMapping(value = "search") - public ExecutedResult<PagerResult<TestInfoVO>> search(@RequestBody SearchTestInfo request) { - return this.service.search(request); - } -} diff --git a/src/main/java/com/lunhan/xxx/host/controller/admin/AdminMenuController.java b/src/main/java/com/lunhan/xxx/host/controller/admin/AdminMenuController.java deleted file mode 100644 index a0c13f7..0000000 --- a/src/main/java/com/lunhan/xxx/host/controller/admin/AdminMenuController.java +++ /dev/null @@ -1,273 +0,0 @@ -package com.lunhan.xxx.host.controller.admin; - -import com.lunhan.xxx.host.BasicController; -import com.lunhan.xxx.host.api.MustAdmin; -import com.lunhan.xxx.common.ConstantFactory; -import com.lunhan.xxx.common.ExecutedResult; -import com.lunhan.xxx.common.PagerResult; -import com.lunhan.xxx.common.util.ParameterUtil; -import com.lunhan.xxx.common.validator.ParameterValidateResult; -import com.lunhan.xxx.common.validator.ParameterValidator; -import com.lunhan.xxx.entity.search.SearchAdminMenu; -import com.lunhan.xxx.entity.enums.EMenuType; -import com.lunhan.xxx.entity.enums.EState; -import com.lunhan.xxx.entity.request.ReqListId; -import com.lunhan.xxx.entity.request.ReqListSetSort; -import com.lunhan.xxx.entity.request.ReqSetSort; -import com.lunhan.xxx.entity.request.adminmenu.ReqCreateAdminMenu; -import com.lunhan.xxx.entity.request.adminmenu.ReqModifyAdminMenu; -import com.lunhan.xxx.entity.response.admin.ResAdminMenuTreeAndPermission; -import com.lunhan.xxx.repository.vo.AdminMenuVO; -import com.lunhan.xxx.service.AdminPowerService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.*; - -import java.util.List; - -/** - * 10.菜单相关接口 - * - * @author lin.liu - * @date 2023/02/17 - * @order 10 - */ -@RestController -@RequestMapping(value = "admin/menu") -public class AdminMenuController extends BasicController { - @Autowired - private AdminPowerService service; - - /** - * 创建菜单 - * - * @author lin.liu - * @date 2023/02/17 - */ - @MustAdmin - @PostMapping(value = "create") - public ExecutedResult<Long> create(@RequestBody ReqCreateAdminMenu request) { - //#region 参数验证 - ParameterValidator validator = new ParameterValidator() - // 必须是枚举值 - .addMustEnum(ParameterUtil.named("类型"), request.getType(), EMenuType.class) - // 非空 - .addNotNullOrEmpty(ParameterUtil.named("菜单名称"), request.getName()) - // 限制长度 - .addLengthMax(ParameterUtil.named("菜单名称"), request.getName(), ConstantFactory.LENGTH_MAX20) - // 限制长度 - .addLengthMax(ParameterUtil.named("菜单标题"), request.getTitle(), ConstantFactory.LENGTH_MAX100) - // 限制长度 - .addLengthMax(ParameterUtil.named("前端资源路径"), request.getUrl(), ConstantFactory.LENGTH_MAX200) - // 限制长度 - .addLengthMax(ParameterUtil.named("图标"), request.getIcon(), ConstantFactory.LENGTH_MAX200) - ; - ParameterValidateResult result = validator.validate(); - if (result.getIsFiled()) { - return ExecutedResult.failed(result.getErrorMsg()); - } - //#endregion - return this.service.createMenu(request); - } - - /** - * 编辑菜单 - * - * @author lin.liu - * @date 2023/02/17 - */ - @MustAdmin - @PostMapping(value = "modify") - public ExecutedResult<String> modify(@RequestBody ReqModifyAdminMenu request) { - //#region 参数验证 - ParameterValidator validator = new ParameterValidator() - // 必须是枚举值 - .addMustEnum(ParameterUtil.named("类型"), request.getType(), EMenuType.class) - // 非空 - .addNotNullOrEmpty(ParameterUtil.named("菜单名称"), request.getName()) - // 限制长度 - .addLengthMax(ParameterUtil.named("菜单名称"), request.getName(), ConstantFactory.LENGTH_MAX20) - // 限制长度 - .addLengthMax(ParameterUtil.named("菜单标题"), request.getTitle(), ConstantFactory.LENGTH_MAX100) - // 限制长度 - .addLengthMax(ParameterUtil.named("前端资源路径"), request.getUrl(), ConstantFactory.LENGTH_MAX200) - // 限制长度 - .addLengthMax(ParameterUtil.named("图标"), request.getIcon(), ConstantFactory.LENGTH_MAX200) - ; - ParameterValidateResult result = validator.validate(); - if (result.getIsFiled()) { - return ExecutedResult.failed(result.getErrorMsg()); - } - //#endregion - return this.service.modifyMenu(request); - } - - /** - * 停用菜单 - * - * @param menuId 菜单id - * @author lin.liu - * @date 2023/02/17 - */ - @MustAdmin - @PostMapping(value = "stop/{menuId}") - public ExecutedResult<String> stop(@PathVariable Long menuId) { - //#region 参数验证 - ParameterValidator validator = new ParameterValidator() - .addGreater(ParameterUtil.named("菜单id"), menuId, 0L); - ParameterValidateResult result = validator.validate(); - if (result.getIsFiled()) { - return ExecutedResult.failed(result.getErrorMsg()); - } - //#endregion - return this.service.changeMenuStatus(menuId, EState.DISABLED); - } - - /** - * 启用菜单 - * - * @param menuId 菜单id - * @author lin.liu - * @date 2023/02/17 - */ - @MustAdmin - @PostMapping(value = "enable/menuId") - public ExecutedResult<String> enable(@PathVariable Long menuId) { - //#region 参数验证 - ParameterValidator validator = new ParameterValidator() - .addGreater(ParameterUtil.named("菜单id"), menuId, 0L); - ParameterValidateResult result = validator.validate(); - if (result.getIsFiled()) { - return ExecutedResult.failed(result.getErrorMsg()); - } - //#endregion - return this.service.changeMenuStatus(menuId, EState.NORMAL); - } - - /** - * [菜单]设置排序值 - * - * @author lin.liu - * @date 2021/11/23 - */ - @PostMapping(value = "setSort") - public ExecutedResult<String> setSort(@RequestBody ReqSetSort request) { - //#region 参数验证 - ParameterValidator validator = new ParameterValidator() - // 必须大于0 - .addGreater(ParameterUtil.named("菜单id"), request.getId(), 0L) - // 必须大于0 - .addGreaterThan(ParameterUtil.named("排序值"), request.getSort(), 0) - ; - ParameterValidateResult result = validator.validate(); - if (result.getIsFiled()) { - return failed(result.getErrorMsg()); - } - //#endregion - return this.service.setMenuSort(request); - } - - /** - * [菜单]批量设置排序值 - * - * @author lin.liu - * @date 2021/11/23 - */ - @PostMapping(value = "listSetSort") - ExecutedResult<String> listSetSort(ReqListSetSort request) { - //#region 参数验证 - ParameterValidator validator = new ParameterValidator() - // 不能为空 - .addNotNullOrEmpty(ParameterUtil.named("菜单排序设置列表"), request.getList()) - ; - ParameterValidateResult result = validator.validate(); - if (result.getIsFiled()) { - return failed(result.getErrorMsg()); - } - //#endregion - return this.service.listSetMenuSort(request); - } - - /** - * 删除菜单 - * - * @param menuId 菜单id - * @author lin.liu - * @date 2023/02/17 - */ - @MustAdmin - @PostMapping(value = "remove/{menuId}") - public ExecutedResult<String> remove(@PathVariable Long menuId) { - //#region 参数验证 - ParameterValidator validator = new ParameterValidator() - .addGreater(ParameterUtil.named("菜单id"), menuId, 0L); - ParameterValidateResult result = validator.validate(); - if (result.getIsFiled()) { - return ExecutedResult.failed(result.getErrorMsg()); - } - //#endregion - return this.service.removeMenu(menuId); - } - - /** - * 批量删除[删除菜单] - * - * @author lin.liu - * @date 2021/11/23 - */ - @PostMapping(value = "removeList") - public ExecutedResult<String> removeList(@RequestBody ReqListId request) { - //#region 参数验证 - ParameterValidator validator = new ParameterValidator() - // 不能为空 - .addNotNullOrEmpty(ParameterUtil.named("[测试信息]id列表"), request.getListId()) - ; - ParameterValidateResult result = validator.validate(); - if (result.getIsFiled()) { - return failed(result.getErrorMsg()); - } - //#endregion - return this.service.removeMenuList(request.getListId()); - } - - /** - * 获取所有层级菜单(只返回状态正常的数据) - * - * @author lin.liu - * @date 2023/02/17 - */ - @GetMapping(value = "getListTree") - public ExecutedResult<List<ResAdminMenuTreeAndPermission>> getListTree() { - return this.service.getListTreeMenu(); - } - - /** - * 获取指定菜单的子级菜单 - * - * @param menuId 菜单id - * @author lin.liu - * @date 2023/02/17 - */ - @GetMapping(value = "getListChild/{menuId}") - public ExecutedResult<List<AdminMenuVO>> getListChild(@PathVariable Long menuId) { - //#region 参数验证 - ParameterValidator validator = new ParameterValidator() - .addGreater(ParameterUtil.named("菜单id"), menuId, 0L); - ParameterValidateResult result = validator.validate(); - if (result.getIsFiled()) { - return ExecutedResult.failed(result.getErrorMsg()); - } - //#endregion - return this.service.getListChildMenu(menuId); - } - - /** - * 分页查询菜单 - * - * @author lin.liu - * @date 2023/02/17 - */ - @PostMapping(value = "search") - public ExecutedResult<PagerResult<AdminMenuVO>> search(@RequestBody SearchAdminMenu request) { - return this.service.searchMenu(request); - } -} diff --git a/src/main/java/com/lunhan/xxx/host/controller/admin/AdminPermissionController.java b/src/main/java/com/lunhan/xxx/host/controller/admin/AdminPermissionController.java deleted file mode 100644 index b1f6482..0000000 --- a/src/main/java/com/lunhan/xxx/host/controller/admin/AdminPermissionController.java +++ /dev/null @@ -1,120 +0,0 @@ -package com.lunhan.xxx.host.controller.admin; - -import com.lunhan.xxx.host.api.MustAdmin; -import com.lunhan.xxx.common.ConstantFactory; -import com.lunhan.xxx.common.ExecutedResult; -import com.lunhan.xxx.common.PagerResult; -import com.lunhan.xxx.common.util.ParameterUtil; -import com.lunhan.xxx.common.validator.ParameterValidateResult; -import com.lunhan.xxx.common.validator.ParameterValidator; -import com.lunhan.xxx.entity.search.SearchAdminPermission; -import com.lunhan.xxx.entity.enums.EState; -import com.lunhan.xxx.entity.request.adminpermission.ReqCreateAdminPermission; -import com.lunhan.xxx.entity.request.adminpermission.ReqModifyAdminPermission; -import com.lunhan.xxx.entity.response.admin.ResAdminPermission; -import com.lunhan.xxx.service.AdminPowerService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.*; - -/** - * 20.权限相关接口 - * - * @author lin.liu - * @date 2023/02/17 - * @order 20 - */ -@MustAdmin -@RestController -@RequestMapping(value = "admin/permission") -public class AdminPermissionController { - @Autowired - private AdminPowerService service; - - - /** - * 创建权限 - * - * @author lin.liu - * @date 2023/02/17 - */ - @PostMapping(value = "create") - public ExecutedResult<Long> create(@RequestBody ReqCreateAdminPermission request) { - //#region 参数验证 - ParameterValidator validator = new ParameterValidator() - .addNotNullOrEmpty(ParameterUtil.named("权限值"), request.getSn()) - .addLengthMax(ParameterUtil.named("权限值"), request.getSn(), ConstantFactory.LENGTH_MAX50) - .addGreater(ParameterUtil.named("菜单id"), request.getMenuId(), 0) - .addLengthMax(ParameterUtil.named("前端资源url"), request.getMenuUrl(), ConstantFactory.LENGTH_MAX200) - .addNotNullOrEmpty(ParameterUtil.named("权限名称"), request.getName()) - .addLengthMax(ParameterUtil.named("权限名称"), request.getName(), ConstantFactory.LENGTH_MAX50) - .addLengthMax(ParameterUtil.named("图标"), request.getIcon(), ConstantFactory.LENGTH_MAX200) - .addLengthMax(ParameterUtil.named("类型"), request.getType(), ConstantFactory.LENGTH_MAX50) - ; - ParameterValidateResult result = validator.validate(); - if (result.getIsFiled()) { - return ExecutedResult.failed(result.getErrorMsg()); - } - //#endregion - return this.service.createPermission(request); - } - - /** - * 编辑权限 - * - * @author lin.liu - * @date 2023/02/17 - */ - @PostMapping(value = "modify") - public ExecutedResult<String> modify(@RequestBody ReqModifyAdminPermission request) { - //#region 参数验证 - ParameterValidator validator = new ParameterValidator() - .addNotNullOrEmpty(ParameterUtil.named("权限值"), request.getSn()) - .addLengthMax(ParameterUtil.named("权限值"), request.getSn(), ConstantFactory.LENGTH_MAX50) - .addGreater(ParameterUtil.named("菜单id"), request.getMenuId(), 0) - .addLengthMax(ParameterUtil.named("前端资源url"), request.getMenuUrl(), ConstantFactory.LENGTH_MAX200) - .addNotNullOrEmpty(ParameterUtil.named("权限名称"), request.getName()) - .addLengthMax(ParameterUtil.named("权限名称"), request.getName(), ConstantFactory.LENGTH_MAX50) - .addLengthMax(ParameterUtil.named("图标"), request.getIcon(), ConstantFactory.LENGTH_MAX200) - .addLengthMax(ParameterUtil.named("类型"), request.getType(), ConstantFactory.LENGTH_MAX50) - // 必须是枚举 - .addMustEnum(ParameterUtil.named("状态"), request.getStatus(), EState.class) - ; - ParameterValidateResult result = validator.validate(); - if (result.getIsFiled()) { - return ExecutedResult.failed(result.getErrorMsg()); - } - //#endregion - return this.service.modifyPermission(request); - } - - /** - * 删除权限 - * - * @param powerId 权限id - * @author lin.liu - * @date 2023/02/17 - */ - @GetMapping(value = "remove/{powerId}") - public ExecutedResult<String> remove(@PathVariable Long powerId) { - //#region 参数验证 - ParameterValidator validator = new ParameterValidator() - .addGreater(ParameterUtil.named("权限id"), powerId, 0L); - ParameterValidateResult result = validator.validate(); - if (result.getIsFiled()) { - return ExecutedResult.failed(result.getErrorMsg()); - } - //#endregion - return this.service.removePermission(powerId); - } - - /** - * 分页查询权限 - * - * @author lin.liu - * @date 2023/02/17 - */ - @PostMapping(value = "search") - public ExecutedResult<PagerResult<ResAdminPermission>> search(@RequestBody SearchAdminPermission request) { - return this.service.searchPermission(request); - } -} diff --git a/src/main/java/com/lunhan/xxx/host/controller/admin/AdminRoleController.java b/src/main/java/com/lunhan/xxx/host/controller/admin/AdminRoleController.java deleted file mode 100644 index 25e3599..0000000 --- a/src/main/java/com/lunhan/xxx/host/controller/admin/AdminRoleController.java +++ /dev/null @@ -1,319 +0,0 @@ -package com.lunhan.xxx.host.controller.admin; - -import com.lunhan.xxx.host.BasicController; -import com.lunhan.xxx.host.api.MustAdmin; -import com.lunhan.xxx.common.ConstantFactory; -import com.lunhan.xxx.common.ExecutedResult; -import com.lunhan.xxx.common.PagerResult; -import com.lunhan.xxx.common.util.ParameterUtil; -import com.lunhan.xxx.common.validator.ParameterValidateResult; -import com.lunhan.xxx.common.validator.ParameterValidator; -import com.lunhan.xxx.entity.search.SearchAdminRole; -import com.lunhan.xxx.entity.enums.EState; -import com.lunhan.xxx.entity.request.ReqListId; -import com.lunhan.xxx.entity.request.ReqListSetSort; -import com.lunhan.xxx.entity.request.ReqSetSort; -import com.lunhan.xxx.entity.request.adminrole.ReqCreateAdminRole; -import com.lunhan.xxx.entity.request.adminrole.ReqModifyAdminRole; -import com.lunhan.xxx.entity.request.adminrolemenurelation.ReqSetListMenu4Role; -import com.lunhan.xxx.entity.request.adminuser.ReqSetListRole4Admin; -import com.lunhan.xxx.entity.response.admin.ResAdminPower; -import com.lunhan.xxx.repository.vo.AdminRoleVO; -import com.lunhan.xxx.service.AdminPowerService; -import com.lunhan.xxx.service.AdminService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.*; - -import java.util.List; - -/** - * 30.角色相关接口 - * - * @author lin.liu - * @date 2023/02/17 - * @order 30 - */ - -@RestController -@RequestMapping(value = "admin/role") -public class AdminRoleController extends BasicController { - @Autowired - private AdminPowerService service; - @Autowired - private AdminService adminService; - - /** - * 创建角色 - * - * @author lin.liu - * @date 2023/02/17 - */ - @MustAdmin - @PostMapping(value = "create") - public ExecutedResult<Long> create(@RequestBody ReqCreateAdminRole request) { - //#region 参数验证 - ParameterValidator validator = new ParameterValidator() - // 非空 - .addNotNullOrEmpty(ParameterUtil.named("角色名称"), request.getName()) - // 限制长度 - .addLengthMax(ParameterUtil.named("角色名称"), request.getName(), ConstantFactory.LENGTH_MAX20) - // 限制长度 - .addLengthMax(ParameterUtil.named("描述"), request.getDescription(), ConstantFactory.LENGTH_MAX100) - ; - ParameterValidateResult result = validator.validate(); - if (result.getIsFiled()) { - return ExecutedResult.failed(result.getErrorMsg()); - } - //#endregion - return service.createRole(request); - } - - /** - * 编辑角色 - * - * @author lin.liu - * @date 2023/02/17 - */ - @MustAdmin - @PostMapping(value = "modify") - public ExecutedResult<String> modify(@RequestBody ReqModifyAdminRole request) { - //#region 参数验证 - ParameterValidator validator = new ParameterValidator() - // 必须大于0 - .addGreater(ParameterUtil.named("角色id"), request.getId(), 0L) - // 非空 - .addNotNullOrEmpty(ParameterUtil.named("角色名称"), request.getName()) - // 限制长度 - .addLengthMax(ParameterUtil.named("角色名称"), request.getName(), ConstantFactory.LENGTH_MAX100) - // 限制长度 - .addLengthMax(ParameterUtil.named("描述"), request.getDescription(), ConstantFactory.LENGTH_MAX200) - // 必须是枚举值 - .addMustEnum(ParameterUtil.named("状态"), request.getStatus(), EState.class) - ; - ParameterValidateResult result = validator.validate(); - if (result.getIsFiled()) { - return ExecutedResult.failed(result.getErrorMsg()); - } - //#endregion - return service.modifyRole(request); - } - - /** - * 停用角色 - * - * @param roleId 角色id - * @author lin.liu - * @date 2023/02/17 - */ - @MustAdmin - @PostMapping(value = "stop/{roleId}") - public ExecutedResult<String> stop(@PathVariable Long roleId) { - //#region 参数验证 - ParameterValidator validator = new ParameterValidator() - .addGreater(ParameterUtil.named("角色id"), roleId, 0L); - ParameterValidateResult result = validator.validate(); - if (result.getIsFiled()) { - return ExecutedResult.failed(result.getErrorMsg()); - } - //#endregion - return service.changeRoleStatus(roleId, EState.DISABLED); - } - - /** - * 启用角色 - * - * @param roleId 角色id - * @author lin.liu - * @date 2023/02/17 - */ - @MustAdmin - @PostMapping(value = "enable/{roleId}") - public ExecutedResult<String> enable(@PathVariable Long roleId) { - //#region 参数验证 - ParameterValidator validator = new ParameterValidator() - .addGreater(ParameterUtil.named("角色id"), roleId, 0L); - ParameterValidateResult result = validator.validate(); - if (result.getIsFiled()) { - return ExecutedResult.failed(result.getErrorMsg()); - } - //#endregion - return service.changeRoleStatus(roleId, EState.NORMAL); - } - - /** - * [角色]设置排序值 - * - * @author lin.liu - * @date 2021/11/23 - */ - @PostMapping(value = "setSort") - public ExecutedResult<String> setSort(@RequestBody ReqSetSort request) { - //#region 参数验证 - ParameterValidator validator = new ParameterValidator() - // 必须大于0 - .addGreater(ParameterUtil.named("角色id"), request.getId(), 0L) - // 必须大于0 - .addGreaterThan(ParameterUtil.named("排序值"), request.getSort(), 0) - ; - ParameterValidateResult result = validator.validate(); - if (result.getIsFiled()) { - return failed(result.getErrorMsg()); - } - //#endregion - return this.service.setRoleSort(request); - } - - /** - * [角色]批量设置排序值 - * - * @author lin.liu - * @date 2021/11/23 - */ - @PostMapping(value = "listSetSort") - ExecutedResult<String> listSetSort(ReqListSetSort request) { - //#region 参数验证 - ParameterValidator validator = new ParameterValidator() - // 不能为空 - .addNotNullOrEmpty(ParameterUtil.named("角色排序设置列表"), request.getList()) - ; - ParameterValidateResult result = validator.validate(); - if (result.getIsFiled()) { - return failed(result.getErrorMsg()); - } - //#endregion - return this.service.listSetRoleSort(request); - } - - /** - * 删除角色 - * - * @param roleId 角色id - * @author lin.liu - * @date 2023/02/17 - */ - @MustAdmin - @PostMapping(value = "remove/{roleId}") - public ExecutedResult<String> remove(@PathVariable Long roleId) { - //#region 参数验证 - ParameterValidator validator = new ParameterValidator() - .addGreater(ParameterUtil.named("角色id"), roleId, 0L); - ParameterValidateResult result = validator.validate(); - if (result.getIsFiled()) { - return ExecutedResult.failed(result.getErrorMsg()); - } - //#endregion - return service.removeRole(roleId); - } - - /** - * 批量删除角色 - * @param request 请求参数 - * @author lin.liu - * @date 2021/11/23 - */ - @PostMapping(value = "removeList") - public ExecutedResult<String> removeList(@RequestBody ReqListId request) { - //#region 参数验证 - ParameterValidator validator = new ParameterValidator() - // 不能为空 - .addNotNullOrEmpty(ParameterUtil.named("角色id列表"), request.getListId()) - ; - ParameterValidateResult result = validator.validate(); - if (result.getIsFiled()) { - return failed(result.getErrorMsg()); - } - //#endregion - return this.service.removeRoleList(request.getListId()); - } - - /** - * 分页查询角色 - * - * @author lin.liu - * @date 2023/02/17 - */ - @PostMapping(value = "search") - public ExecutedResult<PagerResult<AdminRoleVO>> search(@RequestBody SearchAdminRole request) { - return this.service.searchRole(request); - } - - /** - * 设置角色菜单权限列表 - * - * @author lin.liu - * @date 2023/02/17 - */ - @MustAdmin - @PostMapping(value = "setListMenuAndPermission") - public ExecutedResult<String> setListMenuAndPermission(@RequestBody ReqSetListMenu4Role request) { - //#region 参数验证 - ParameterValidator validator = new ParameterValidator() - .addGreater(ParameterUtil.named("角色id"), request.getId(), 0); - ParameterValidateResult result = validator.validate(); - if (result.getIsFiled()) { - return ExecutedResult.failed(result.getErrorMsg()); - } - //#endregion - return service.setListMenu4Role(request); - } - - /** - * 获取角色菜单权限列表 - * - * @param roleId 角色id - * @author lin.liu - * @date 2023/02/17 - */ - @GetMapping(value = "getListMenuAndPermission/{roleId}") - public ExecutedResult<ResAdminPower> getListMenuAndPermission(@PathVariable Long roleId) { - //#region 参数验证 - ParameterValidator validator = new ParameterValidator() - .addGreater(ParameterUtil.named("角色id"), roleId, 0); - ParameterValidateResult result = validator.validate(); - if (result.getIsFiled()) { - return ExecutedResult.failed(result.getErrorMsg()); - } - //#endregion - return service.getListMenu4Role(roleId); - } - - /** - * 设置管理员的角色列表 - * - * @author lin.liu - * @date 2023/02/17 - */ - @MustAdmin - @PostMapping(value = "setListRole4Admin") - public ExecutedResult<String> setListRole4Admin(@RequestBody ReqSetListRole4Admin request) { - //#region 参数验证 - ParameterValidator validator = new ParameterValidator() - .addGreater(ParameterUtil.named("管理员id"), request.getId(), 0); - ParameterValidateResult result = validator.validate(); - if (result.getIsFiled()) { - return ExecutedResult.failed(result.getErrorMsg()); - } - //#endregion - return adminService.setListRole4Admin(request); - } - - /** - * 获取管理员的角色列表 - * - * @param adminId 管理员id - * @author lin.liu - * @date 2023/02/17 - */ - @GetMapping(value = "getListRole4Admin") - public ExecutedResult<List<AdminRoleVO>> getListRole4Admin(@RequestParam Long adminId) { - //#region 参数验证 - ParameterValidator validator = new ParameterValidator() - .addGreater(ParameterUtil.named("管理员id"), adminId, 0); - ParameterValidateResult result = validator.validate(); - if (result.getIsFiled()) { - return ExecutedResult.failed(result.getErrorMsg()); - } - //#endregion - return adminService.getListRole4Admin(adminId); - } -} diff --git a/src/main/java/com/lunhan/xxx/host/controller/admin/AdminUserController.java b/src/main/java/com/lunhan/xxx/host/controller/admin/AdminUserController.java deleted file mode 100644 index 46d551b..0000000 --- a/src/main/java/com/lunhan/xxx/host/controller/admin/AdminUserController.java +++ /dev/null @@ -1,265 +0,0 @@ -package com.lunhan.xxx.host.controller.admin; - -import com.lunhan.xxx.host.BasicController; -import com.lunhan.xxx.host.api.MustAdmin; -import com.lunhan.xxx.host.api.NonLogin; -import com.lunhan.xxx.common.ConstantFactory; -import com.lunhan.xxx.common.ExecutedResult; -import com.lunhan.xxx.common.PagerResult; -import com.lunhan.xxx.common.jwt.LoginUserDTO; -import com.lunhan.xxx.common.util.ParameterUtil; -import com.lunhan.xxx.common.validator.ParameterValidateResult; -import com.lunhan.xxx.common.validator.ParameterValidator; -import com.lunhan.xxx.entity.search.SearchAdminUser; -import com.lunhan.xxx.entity.enums.EState; -import com.lunhan.xxx.entity.enums.EUserType; -import com.lunhan.xxx.entity.request.ReqChangePassword; -import com.lunhan.xxx.entity.request.adminuser.ReqAdminLogin; -import com.lunhan.xxx.entity.request.adminuser.ReqCreateAdminUser; -import com.lunhan.xxx.entity.request.adminuser.ReqModifyAdminUser; -import com.lunhan.xxx.entity.response.admin.ResAdminLogin; -import com.lunhan.xxx.entity.response.admin.ResAdminPower; -import com.lunhan.xxx.repository.vo.AdminUserVO; -import com.lunhan.xxx.service.AdminPowerService; -import com.lunhan.xxx.service.AdminService; -import com.lunhan.xxx.service.dto.ResAdminDetail; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.*; - -/** - * 40.管理员用户相关接口 - * - * @author lin.liu - * @date 2023/02/17 - * @order 40 - */ -@RestController -@RequestMapping("admin/user") -public class AdminUserController extends BasicController { - @Autowired - private AdminService service; - @Autowired - private AdminPowerService adminPowerService; - - /** - * 添加后台管理员 - * - * @param request 请求参数 - * @author lin.liu - * @date 2023/02/17 - */ - @MustAdmin - @PostMapping("add") - public ExecutedResult<Long> add(@RequestBody ReqCreateAdminUser request) { - //#region 参数验证 - ParameterValidator validator = new ParameterValidator() - .addMustEnum(ParameterUtil.named("用户类型"), request.getUserType(), EUserType.class) - .addNotNullOrEmpty(ParameterUtil.named("用户名"), request.getUserName()) - .addLengthMax(ParameterUtil.named("用户名"), request.getUserName(), ConstantFactory.LENGTH_MAX100) - .addNotNullOrEmpty(ParameterUtil.named("密码"), request.getPassword()) - .addLengthMax(ParameterUtil.named("密码"), request.getPassword(), ConstantFactory.LENGTH_MAX50) - .addLengthMax(ParameterUtil.named("昵称"), request.getNickName(), ConstantFactory.LENGTH_MAX50) - .addLengthMax(ParameterUtil.named("头像"), request.getHeadImg(), ConstantFactory.LENGTH_MAX500) - .addLengthMax(ParameterUtil.named("联系方式"), request.getContact(), ConstantFactory.LENGTH_MAX50) - .addLengthMax(ParameterUtil.named("联系邮箱"), request.getEmail(), ConstantFactory.LENGTH_MAX50); - ParameterValidateResult result = validator.validate(); - if (result.getIsFiled()) { - return ExecutedResult.failed(result.getErrorMsg()); - } - //#endregion - return service.createAdmin(request); - } - - /** - * 修改后台管理员 - * - * @param request 请求参数 - * @author lin.liu - * @date 2023/02/17 - */ - @MustAdmin - @PostMapping("modify") - public ExecutedResult<String> modify(@RequestBody ReqModifyAdminUser request) { - //#region 参数验证 - ParameterValidator validator = new ParameterValidator() - .addGreater(ParameterUtil.named("用户id"), request.getId(), 0L) - .addMustEnum(ParameterUtil.named("用户类型"), request.getUserType(), EUserType.class) - .addMustEnum(ParameterUtil.named("状态"), request.getStatus(), EState.class) - .addLengthMax(ParameterUtil.named("昵称"), request.getNickName(), ConstantFactory.LENGTH_MAX50) - .addLengthMax(ParameterUtil.named("头像"), request.getHeadImg(), ConstantFactory.LENGTH_MAX500) - .addLengthMax(ParameterUtil.named("联系方式"), request.getContact(), ConstantFactory.LENGTH_MAX50) - .addLengthMax(ParameterUtil.named("联系邮箱"), request.getEmail(), ConstantFactory.LENGTH_MAX50); - ParameterValidateResult result = validator.validate(); - if (result.getIsFiled()) { - return ExecutedResult.failed(result.getErrorMsg()); - } - //#endregion - return service.modify(request); - } - - /** - * 获取指定管理员详情 - * - * @param userId 用户id - * @author lin.liu - * @date 2023/02/17 - */ - @GetMapping("detail/{userId}") - public ExecutedResult<ResAdminDetail> detail(@PathVariable Long userId) { - //#region 参数验证 - ParameterValidator validator = new ParameterValidator() - .addGreater(ParameterUtil.named("用户id"), userId, 0L); - ParameterValidateResult result = validator.validate(); - if (result.getIsFiled()) { - return ExecutedResult.failed(result.getErrorMsg()); - } - //#endregion - return service.detail(userId); - } - - /** - * 分页查询所有管理员 - * - * @param request 查询参数 - * @author lin.liu - * @date 2023/02/17 - */ - @MustAdmin - @PostMapping("search") - public ExecutedResult<PagerResult<AdminUserVO>> search(@RequestBody SearchAdminUser request) { - //#region 参数验证 - ParameterValidator validator = new ParameterValidator(); - ParameterValidateResult result = validator.validate(); - if (result.getIsFiled()) { - return ExecutedResult.failed(result.getErrorMsg()); - } - //#endregion - return service.search(request); - } - - /** - * 管理员登录 - * - * @param request 请求参数 - * @author lin.liu - * @date 2023/02/17 - */ - @PostMapping("login") - @NonLogin - public ExecutedResult<ResAdminLogin> adminLogin(@RequestBody ReqAdminLogin request) { - //#region 参数验证 - ParameterValidator validator = new ParameterValidator() - .addNotNullOrEmpty(ParameterUtil.named("用户名"), request.getUserName()) - .addNotNullOrEmpty(ParameterUtil.named("密码"), request.getPassword()); - ParameterValidateResult result = validator.validate(); - if (result.getIsFiled()) { - return ExecutedResult.failed(result.getErrorMsg()); - } - //#endregion - return service.adminLogin(request); - } - - - /** - * 获取管理员权限列表 - * - * @param userId 用户id - * @author lin.liu - * @date 2023/02/17 - */ - @GetMapping("getPower/{userId}") - public ExecutedResult<ResAdminPower> getPower(@PathVariable Long userId) { - return service.getPower(userId); - } - - /** - * 修改密码 - * - * @param request 请求参数 - * @author lin.liu - * @date 2023/02/17 - */ - @PostMapping("changePassword") - public ExecutedResult<String> changePassword(@RequestBody ReqChangePassword request) { - //#region 参数验证 - ParameterValidator validator = new ParameterValidator() - .addNotNullOrEmpty(ParameterUtil.named("旧密码"), request.getOldPassword()) - .addNotNullOrEmpty(ParameterUtil.named("新密码"), request.getNewPassword()) - .addLengthMax(ParameterUtil.named("新密码"), request.getNewPassword(), ConstantFactory.LENGTH_MAX50); - ParameterValidateResult result = validator.validate(); - if (result.getIsFiled()) { - return ExecutedResult.failed(result.getErrorMsg()); - } - //#endregion - LoginUserDTO user = super.getTokenUser(); - return service.changePassword(user, request); - } - - /** - * 重置管理员密码 - * - * @param userId 用户id - * @author lin.liu - * @date 2023/02/17 - */ - @MustAdmin - @PostMapping("resetPassword/{userId}") - public ExecutedResult<String> resetPassword(@PathVariable Long userId) { - //#region 参数验证 - ParameterValidator validator = new ParameterValidator() - .addGreater(ParameterUtil.named("用户id"), userId, 0L); - ParameterValidateResult result = validator.validate(); - if (result.getIsFiled()) { - return ExecutedResult.failed(result.getErrorMsg()); - } - //#endregion - return service.resetPassword(userId); - } - - /** - * 停用管理员帐号 - * - * @param userId 用户id - * @author lin.liu - * @date 2023/02/17 - */ - @MustAdmin - @PostMapping(value = "stop/{userId}") - public ExecutedResult<String> stop(@PathVariable Long userId) { - return this.service.stop(userId); - } - - /** - * 启用管理员帐号 - * - * @param userId 用户id - * @author lin.liu - * @date 2023/02/17 - */ - @MustAdmin - @PostMapping(value = "enable/{userId}") - public ExecutedResult<String> enable(@PathVariable Long userId) { - return this.service.enable(userId); - } - - /** - * 删除管理员 - * - * @param userId 用户id - * @author lin.liu - * @date 2023/02/17 - */ - @MustAdmin - @PostMapping("remove/{userId}") - public ExecutedResult<String> remove(@PathVariable Long userId) { - //#region 参数验证 - ParameterValidator validator = new ParameterValidator() - .addGreater(ParameterUtil.named("用户id"), userId, 0L); - ParameterValidateResult result = validator.validate(); - if (result.getIsFiled()) { - return ExecutedResult.failed(result.getErrorMsg()); - } - //#endregion - return service.remove(userId); - } -} diff --git a/src/main/java/com/lunhan/xxx/host/controller/base/BaseController.java b/src/main/java/com/lunhan/xxx/host/controller/base/BaseController.java deleted file mode 100644 index 7115851..0000000 --- a/src/main/java/com/lunhan/xxx/host/controller/base/BaseController.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.lunhan.xxx.host.controller.base; - -import com.lunhan.xxx.common.ExecutedResult; -import com.lunhan.xxx.entity.dto.NameValueDTO; -import com.lunhan.xxx.host.api.NonLogin; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.List; - -/** - * 00.基础接口 - * @order 00 - */ -@NonLogin -@RestController -@RequestMapping("base") -public class BaseController { - /** - * 获取指定枚举类型的所有值 - * @param enumName 枚举类型名称 - */ - @GetMapping("listEnumValue/{enumName}") - public ExecutedResult<List<NameValueDTO>> listEnumValue(@PathVariable String enumName) { - try { - Class<?> enumClass = Class.forName("com.lunhan.xxx.entity.enums." + enumName); - Method valuesMethod = enumClass.getMethod("values"); - Method getValueMethod = enumClass.getMethod("getValue"); - Method getDescMethod = enumClass.getMethod("getDesc"); - - Object valuesObj = valuesMethod.invoke(enumClass); - Object[] values = (Object[]) valuesObj; - - List<NameValueDTO> result = new ArrayList<>(); - for(Object c : values) { - String value = getValueMethod.invoke(c).toString(); - String desc = getDescMethod.invoke(c).toString(); - result.add(new NameValueDTO(desc, value)); - } - return ExecutedResult.success(result); - } catch (Exception e) { - return ExecutedResult.failed("获取枚举类型失败(" + enumName + "): " + e.getMessage()); - } - } -} diff --git a/src/main/java/com/lunhan/xxx/host/controller/base/FileController.java b/src/main/java/com/lunhan/xxx/host/controller/base/FileController.java deleted file mode 100644 index 3f7876c..0000000 --- a/src/main/java/com/lunhan/xxx/host/controller/base/FileController.java +++ /dev/null @@ -1,188 +0,0 @@ -package com.lunhan.xxx.host.controller.base; - -import com.google.gson.Gson; -import com.lunhan.xxx.common.ConstantFactory; -import com.lunhan.xxx.common.ExecutedResult; -import com.lunhan.xxx.common.config.SysConfig; -import com.lunhan.xxx.common.enums.EContentType; -import com.lunhan.xxx.common.util.FileUtil; -import com.lunhan.xxx.common.util.LocalDateTimeUtil; -import com.lunhan.xxx.common.util.ParameterUtil; -import com.lunhan.xxx.common.util.StringUtil; -import com.lunhan.xxx.common.validator.EParameterValidateType; -import com.lunhan.xxx.entity.dto.NameValueDTO; -import com.lunhan.xxx.entity.dto.UploadResultVo; -import com.lunhan.xxx.host.api.NonLogin; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.core.io.ResourceLoader; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.multipart.MultipartFile; -import org.springframework.web.multipart.MultipartHttpServletRequest; - -import javax.servlet.http.HttpServletRequest; -import java.io.File; -import java.io.FileOutputStream; -import java.io.InputStream; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.stream.Collectors; - -/** - * 01.文件上传 - * @author lin.liu - * @date 2021/11/26 - * @order 01 - */ -@NonLogin -@RestController -@RequestMapping("/file") -public class FileController { - @Autowired - private ResourceLoader resourceLoader; - - /** - * 上传文件 - * - * @param requestMultipart 复杂请求对象 - */ - @PostMapping(value = "upload") - @NonLogin - public ExecutedResult<UploadResultVo> upload(MultipartHttpServletRequest requestMultipart, HttpServletRequest request) throws Exception { - UploadResultVo result = this.defaultResult(); - - Map<String, MultipartFile> mapFile = requestMultipart.getFileMap(); - if (mapFile.isEmpty()) { - return ExecutedResult.failed("请求中没有找到文件。"); - } - if (mapFile.size() > 1) { - return ExecutedResult.failed("仅支持单个文件上传。"); - } - String fileId = requestMultipart.getParameter("fileId"); - String toPath = requestMultipart.getParameter("path"); - if (StringUtil.isNullOrEmpty(toPath)) { - return ExecutedResult.failed(ParameterUtil.named("path") + EParameterValidateType.NOT_NULLOREMPTY.getDesc()); - } - Iterator<Map.Entry<String, MultipartFile>> iterator = mapFile.entrySet().iterator(); - Map.Entry<String, MultipartFile> fileEntry = iterator.next(); - - MultipartFile file = fileEntry.getValue(); - String contentType = file.getContentType(); - - InputStream fConfig = resourceLoader.getResource("classpath:upload_allow.json").getInputStream(); - String allowStr = FileUtil.readFileContent(fConfig); - Map<String, String> map = new Gson().fromJson(allowStr, Map.class); - List<NameValueDTO<String>> listConfig = map.entrySet().stream().map(c -> new NameValueDTO<>(c.getKey(), c.getValue())) - .collect(Collectors.toList()); - NameValueDTO<String> findConfig = listConfig.stream().filter(c -> c.getName().equals(contentType)) - .findAny().orElse(null); - if (Objects.isNull(findConfig)) { - return ExecutedResult.failed(file.getOriginalFilename() + ", 不支持的文件类型。" + file.getContentType()); - } - if (null != file.getOriginalFilename() && !file.getOriginalFilename().contains(findConfig.getValue())) { - return ExecutedResult.failed(file.getOriginalFilename() + ", 不支持的文件类型。" + file.getContentType()); - } - - EContentType type = EContentType.getByValue(file.getContentType()); - String filePath = "/" + toPath + "/files/"; - boolean isMultimedia = false; - long size = file.getSize() / ConstantFactory.FILE_UNIT; - if (null != type) { - switch (type) { - case GIF: - case JPG: - case PNG: - case JPEG: - filePath = "/" + toPath + "/images/"; - if (size > ConstantFactory.FILE_SIZE_20M) { - return ExecutedResult.failed("图片不能超过20M!"); - } - break; - case GZ: - case RAR: - case X7Z: - case ZIP: - if (size > ConstantFactory.FILE_SIZE_20M) { - return ExecutedResult.failed("压缩文件不能超过20M!"); - } - break; - - case MP3: - isMultimedia = true; - if (size > ConstantFactory.FILE_SIZE_20M) { - return ExecutedResult.failed("音频文件不能超过20M!"); - } - break; - case MP4: - isMultimedia = true; - if (size > ConstantFactory.FILE_SIZE_20M) { - return ExecutedResult.failed("视频文件不能超过20M!"); - } - break; - default: - break; - } - } - filePath += LocalDateTimeUtil.toFormatString(LocalDateTimeUtil.todayFirst(), "yyyyMMdd") + "/"; - InputStream fsIn = file.getInputStream(); - - String fileSuffix = "." + findConfig.getValue(); - File directory = new File(SysConfig.fileUploadBasic() + filePath); - //如果路径不存在,新建 - if (!directory.exists() && !directory.isDirectory()) { - directory.mkdirs(); - } - - String newFileName = filePath + StringUtil.md5(file.getOriginalFilename() + LocalDateTimeUtil.nowDateTimeFullStr() + SysConfig.fileDisturbStr()) + fileSuffix; - File newFile = new File(SysConfig.fileUploadBasic() + newFileName); - if (!newFile.exists()) { - //每次写入1MB - byte[] buffer = new byte[ConstantFactory.FILE_UNIT * ConstantFactory.FILE_SIZE_1M]; - int len; - FileOutputStream fsOut = null; - try { - fsOut = new FileOutputStream(newFile); - while ((len = fsIn.read(buffer)) != -1) { - fsOut.write(buffer, 0, len); - fsOut.flush(); - } - } finally { - if (Objects.nonNull(fsOut)) { - fsOut.close(); - } - } - } - if (Objects.nonNull(fsIn)) { - fsIn.close(); - } - - result.setFileId(fileId); - result.setName(file.getOriginalFilename()); - result.setNewFileName(newFileName); - result.setSize(size); - result.setFileType(findConfig.getValue()); - result.setContentType(findConfig.getName()); - result.setNewFileView(SysConfig.fileViewBasic() + newFileName); - - file = null; - newFile = null; - - return ExecutedResult.success(result); - } - - - private UploadResultVo defaultResult() { - UploadResultVo result = new UploadResultVo(); - result.setFileId(""); - result.setName(""); - result.setNewFileName(""); - result.setNewFileView(""); - result.setFileType(""); - result.setContentType(""); - result.setSize(0L); - return result; - } -} diff --git a/src/main/java/com/lunhan/xxx/host/controller/base/NoticeController.java b/src/main/java/com/lunhan/xxx/host/controller/base/NoticeController.java deleted file mode 100644 index 1d40491..0000000 --- a/src/main/java/com/lunhan/xxx/host/controller/base/NoticeController.java +++ /dev/null @@ -1,180 +0,0 @@ -package com.lunhan.xxx.host.controller.base; - -import com.lunhan.xxx.common.ConstantFactory; -import com.lunhan.xxx.common.ExecutedResult; -import com.lunhan.xxx.common.PagerResult; -import com.lunhan.xxx.common.jwt.LoginUserDTO; -import com.lunhan.xxx.common.util.ParameterUtil; -import com.lunhan.xxx.common.validator.ParameterValidateResult; -import com.lunhan.xxx.common.validator.ParameterValidator; -import com.lunhan.xxx.entity.enums.EState; -import com.lunhan.xxx.entity.request.ReqListId; -import com.lunhan.xxx.entity.request.ReqSetSort; -import com.lunhan.xxx.entity.request.notice.ReqCreateNotice; -import com.lunhan.xxx.entity.request.notice.ReqModifyNotice; -import com.lunhan.xxx.entity.search.SearchNotice; -import com.lunhan.xxx.host.BasicController; -import com.lunhan.xxx.host.api.NonLogin; -import com.lunhan.xxx.repository.vo.NoticeVO; -import com.lunhan.xxx.service.NoticeService; -import com.lunhan.xxx.service.dto.NoticeDetail; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.*; - -import java.util.List; - -/** - * 02.公告相关接口 - * @author lin.liu - * @order 02 - */ -@RestController -@RequestMapping(value = "notice") -public class NoticeController extends BasicController { - @Autowired - private NoticeService service; - /** - * 创建公告 - * - * @author lin.liu - * @date 2023/02/26 - */ - @PostMapping(value = "create") - public ExecutedResult<Long> create(@RequestBody ReqCreateNotice request) { - //#region 参数验证 - ParameterValidator validator = new ParameterValidator() - // 非空 - .addNotNullOrEmpty(ParameterUtil.named("标题"), request.getTitle()) - // 限制最大长度 - .addLengthMax(ParameterUtil.named("标题"), request.getTitle(), ConstantFactory.LENGTH_MAX50) - // 非空 - .addNotNullOrEmpty(ParameterUtil.named("内容"), request.getContent()) - ; - ParameterValidateResult result = validator.validate(); - if (result.getIsFiled()) { - return failed(result.getErrorMsg()); - } - //#endregion - LoginUserDTO user = super.getTokenUser(); - return this.service.create(request, user); - } - - /** - * 编辑公告 - * - * @author lin.liu - * @date 2023/02/26 - */ - @PostMapping(value = "modify") - public ExecutedResult<String> modify(@RequestBody ReqModifyNotice request) { - //#region 参数验证 - ParameterValidator validator = new ParameterValidator() - // 必须大于0 - .addGreater(ParameterUtil.named("公告id"), request.getId(), 0L) - // 非空 - .addNotNullOrEmpty(ParameterUtil.named("标题"), request.getTitle()) - // 限制最大长度 - .addLengthMax(ParameterUtil.named("标题"), request.getTitle(), ConstantFactory.LENGTH_MAX50) - // 非空 - .addNotNullOrEmpty(ParameterUtil.named("内容"), request.getContent()) - // 必须是枚举值 - .addMustEnum(ParameterUtil.named("状态"), request.getStatus(), EState.class) - ; - ParameterValidateResult result = validator.validate(); - if (result.getIsFiled()) { - return failed(result.getErrorMsg()); - } - //#endregion - return this.service.modify(request); - } - - /** - * 获取公告 - * - * @author lin.liu - * @date 2023/02/26 - */ - @GetMapping(value = "get/{id}") - public ExecutedResult<NoticeDetail> get(@PathVariable Long id) { - return this.service.get(id); - } - - /** - * 根据id批量获取公告 - * - * @author lin.liu - * @date 2023/02/26 - */ - @PostMapping(value = "getList") - public ExecutedResult<List<NoticeVO>> getList(@RequestBody ReqListId request) { - return this.service.getList(request.getListId()); - } - - /** - * 公告设置排序值 - * - * @author lin.liu - * @date 2023/02/26 - */ - @PostMapping(value = "setSort") - public ExecutedResult<String> setSort(@RequestBody ReqSetSort request) { - //#region 参数验证 - ParameterValidator validator = new ParameterValidator() - .addGreater(ParameterUtil.named("公告id"), request.getId(), 0L) - .addGreaterThan(ParameterUtil.named("排序值"), request.getSort(), 0); - ParameterValidateResult result = validator.validate(); - if (result.getIsFiled()) { - return failed(result.getErrorMsg()); - } - //#endregion - return this.service.setSort(request); - } - - /** - * 停用公告 - * - * @param id 项目id - * @author lin.liu - * @date 2023/02/26 - */ - @PostMapping(value = "stop") - public ExecutedResult<String> stop(@RequestParam Long id) { - return this.service.changeStatus(id, EState.DISABLED); - } - - /** - * 启用公告 - * - * @param id 项目id - * @author lin.liu - * @date 2023/02/26 - */ - @PostMapping(value = "enable") - public ExecutedResult<String> enable(@RequestParam Long id) { - return this.service.changeStatus(id, EState.NORMAL); - } - - /** - * 删除公告 - * - * @param id 项目id - * @author lin.liu - * @date 2023/02/26 - */ - @PostMapping(value = "remove") - public ExecutedResult<String> remove(@RequestParam Long id) { - return this.service.changeStatus(id, EState.DELETED); - } - - /** - * 查询公告 - * - * @author lin.liu - * @date 2023/02/26 - */ - @NonLogin - @PostMapping(value = "search") - public ExecutedResult<PagerResult<NoticeVO>> search(@RequestBody SearchNotice request) { - return this.service.search(request); - } -} diff --git a/src/main/java/com/lunhan/xxx/host/controller/base/QuartzController.java b/src/main/java/com/lunhan/xxx/host/controller/base/QuartzController.java deleted file mode 100644 index fb5a39d..0000000 --- a/src/main/java/com/lunhan/xxx/host/controller/base/QuartzController.java +++ /dev/null @@ -1,141 +0,0 @@ -package com.lunhan.xxx.host.controller.base; - -import com.lunhan.xxx.common.ExecutedResult; -import com.lunhan.xxx.common.PagerResult; -import com.lunhan.xxx.entity.request.quartztaskinfo.ReqCreateQuartzTaskInfo; -import com.lunhan.xxx.entity.request.quartztaskinfo.ReqModifyQuartzTaskInfo; -import com.lunhan.xxx.entity.request.quartztaskinfo.ReqRunTaskRightNow; -import com.lunhan.xxx.entity.search.SearchQuartzTaskInfo; -import com.lunhan.xxx.entity.search.SearchQuartzTaskRecord; -import com.lunhan.xxx.host.api.NonLogin; -import com.lunhan.xxx.repository.vo.QuartzTaskErrorVO; -import com.lunhan.xxx.repository.vo.QuartzTaskInfoVO; -import com.lunhan.xxx.repository.vo.QuartzTaskRecordVO; -import com.lunhan.xxx.service.quartz.QuartzService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.*; - -/** - * 05.任务调度 - * @author lin.liu - * @order 05 - */ -@NonLogin -@Controller -@RequestMapping("quartz") -public class QuartzController { - private static final Logger logger = LoggerFactory.getLogger(QuartzController.class); - - @Autowired - private QuartzService quartzService; - - /** - * 任务列表 - * @param request 请求参数 - */ - @ResponseBody - @PostMapping("listTask") - public ExecutedResult<PagerResult<QuartzTaskInfoVO>> listTask(@RequestBody SearchQuartzTaskInfo request) { - try { - return quartzService.listTask(request); - } catch (Exception e) { - logger.error("listTask", e); - return ExecutedResult.failed(e.getMessage()); - } - } - - /** - * 添加任务 - * @param request 请求参数 - */ - @ResponseBody - @PostMapping("addTask") - public ExecutedResult<String> addTask(@RequestBody ReqCreateQuartzTaskInfo request) { - try { - return quartzService.addTask(request); - } catch (Exception e) { - logger.error("addTask", e); - return ExecutedResult.failed(e.getMessage()); - } - } - - /** - * 修改任务 - * @param request 请求参数 - */ - @ResponseBody - @PostMapping("editTask") - public ExecutedResult<String> editTask(@RequestBody ReqModifyQuartzTaskInfo request) { - try { - return quartzService.updateTask(request); - } catch (Exception e) { - logger.error("editTask", e); - return ExecutedResult.failed(e.getMessage()); - } - } - - /** - * 启动 或者 暂定定时任务 - * @param taskId 任务id - */ - @ResponseBody - @PostMapping("optionJob/{taskId}") - public ExecutedResult<String> optionJob(@PathVariable Long taskId) { - try { - return quartzService.optionJob(taskId); - } catch (Exception e) { - logger.error("optionJob", e); - return ExecutedResult.failed(e.getMessage()); - } - } - - /** - * 立即运行一次定时任务 - * @param request 请求参数 - */ - @ResponseBody - @PostMapping("runTaskRightNow") - public ExecutedResult<String> runTaskRightNow(@RequestBody ReqRunTaskRightNow request) { - try { - return quartzService.runTaskRightNow(request); - } catch (Exception e) { - logger.error("/runTaskRightNow", e); - return ExecutedResult.failed(e.getMessage()); - } - } - - /** - * 定时任务执行情况 - * - * @param search 请求参数 - */ - @ResponseBody - @PostMapping("taskRecords") - public ExecutedResult<PagerResult<QuartzTaskRecordVO>> taskRecords(@RequestBody SearchQuartzTaskRecord search) { - try { - return quartzService.taskRecords(search); - } catch (Exception e) { - logger.error("/taskRecords", e); - return ExecutedResult.failed(e.getMessage()); - } - } - - /** - * 定时任务错误详情 - * - * @param recordId 执行记录id - */ - @ResponseBody - @GetMapping("taskErrors/{recordId}") - public ExecutedResult<QuartzTaskErrorVO> detailTaskErrors(@PathVariable String recordId) { - try { - return quartzService.detailTaskErrors(recordId); - } catch (Exception e) { - logger.error("/taskErrors", e); - return ExecutedResult.failed(e.getMessage()); - } - } -} diff --git a/src/main/java/com/lunhan/xxx/host/controller/base/SysDictDataController.java b/src/main/java/com/lunhan/xxx/host/controller/base/SysDictDataController.java deleted file mode 100644 index c99dd83..0000000 --- a/src/main/java/com/lunhan/xxx/host/controller/base/SysDictDataController.java +++ /dev/null @@ -1,145 +0,0 @@ -/** -# __----~~~~~~~~~~~------___ -# . . ~~//====...... __--~ ~~ -# -. \_|// |||\\ ~~~~~~::::... /~ -# ___-==_ _-~o~ \/ ||| \\ _/~~- -# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ -# _-~~ .=~ | \\-_ '-~7 /- / || \ / -# .~ .~ | \\ -_ / /- / || \ / -# / ____ / | \\ ~-_/ /|- _/ .|| \ / -# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ -# ' ~-| /| |-~\~~ __--~~ -# |-~~-_/ | | ~\_ _-~ /\ -# / \ \__ \/~ \__ -# _--~ _/ | .-~~____--~-/ ~~==. -# ((->/~ '.|||' -_| ~~-/ , . _|| -# -_ ~\ ~~---l__i__i__i--~~_/ -# _-~-__ ~) \--______________--~~ -# //.-~~~-~_--~- |-------~~~~~~~~ -# //.-~~~--\ -# 神兽保佑 -# 永无BUG! -*/ -package com.lunhan.xxx.host.controller.base; - -import com.lunhan.xxx.common.ExecutedResult; -import com.lunhan.xxx.common.PagerResult; -import com.lunhan.xxx.common.util.ParameterUtil; -import com.lunhan.xxx.common.validator.ParameterValidateResult; -import com.lunhan.xxx.common.validator.ParameterValidator; -import com.lunhan.xxx.entity.request.ReqListId; -import com.lunhan.xxx.entity.request.sysdictdata.ReqCreateSysDictData; -import com.lunhan.xxx.entity.request.sysdictdata.ReqModifySysDictData; -import com.lunhan.xxx.entity.search.SearchSysDictData; -import com.lunhan.xxx.host.BasicController; -import com.lunhan.xxx.repository.vo.SysDictDataVO; -import com.lunhan.xxx.service.SysDictDataService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.*; - -import java.util.List; - -/** - * 04.字典数据 - * @author lin.liu - * @description 字典数据 - * @order 04 - */ -@RestController -@RequestMapping(value = "sysDictData") -public class SysDictDataController extends BasicController { - @Autowired - private SysDictDataService service; - - /** - * 创建[字典数据表] - * @author lin.liu - * @description 创建[字典数据表] - */ - @PostMapping(value = "create") - public ExecutedResult<Long> create(@RequestBody ReqCreateSysDictData request) { - //#region 参数验证 - ParameterValidator validator = new ParameterValidator() - // 非空 - //.addNotNullOrEmpty(ParameterUtil.named("名称"), request.getName()) - // 限制最大长度 - //.addLengthMax(ParameterUtil.named("名称"), request.getName(), ConstantFactory.LENGTH_MAX50) - ; - ParameterValidateResult result = validator.validate(); - if (result.getIsFiled()) { - return failed(result.getErrorMsg()); - } - //#endregion - return this.service.create(request, super.getTokenUser()); - } - - /** - * 编辑[字典数据表] - * @author lin.liu - * @description 编辑[字典数据表] - */ - @PostMapping(value = "modify") - public ExecutedResult<String> modify(@RequestBody ReqModifySysDictData request) { - //#region 参数验证 - ParameterValidator validator = new ParameterValidator() - // 必须大于0 - .addGreater(ParameterUtil.named("[字典数据表]id"), request.getId(), 0L) - // 非空 - //.addNotNullOrEmpty(ParameterUtil.named("名称"), request.getName()) - // 限制最大长度 - //.addLengthMax(ParameterUtil.named("名称"), request.getName(), ConstantFactory.LENGTH_MAX50) - ; - ParameterValidateResult result = validator.validate(); - if (result.getIsFiled()) { - return failed(result.getErrorMsg()); - } - //#endregion - return this.service.modify(request, super.getTokenUser()); - } - - /** - * 获取[字典数据表] - * @author lin.liu - */ - @GetMapping(value = "get/{id}") - public ExecutedResult<SysDictDataVO> get(@PathVariable Long id) { - return this.service.get(id); - } - - /** - * 根据id删除[字典数据表] - * @author zr - * @description 根据id删除[字典数据表] - */ - @PostMapping(value = "remove/{id}") - public ExecutedResult<String> remove(@PathVariable Long id){ - return this.service.remove(id); - } - - /** - * 根据id批量删除字典数据 - * @author zr - */ - @PostMapping(value = "removeList") - public ExecutedResult<String> removeList(@RequestBody ReqListId reqListId){ - return this.service.removeList(reqListId.getListId()); - } - - /** - * 根据类型获取[字典数据表] - * @author zr - */ - @GetMapping(value = "getListByType/{type}") - public ExecutedResult<List<SysDictDataVO>> getListByType(@PathVariable String type) { - return this.service.getListByType(type); - } - - /** - * 查询[字典数据表] - * @author lin.liu - */ - @PostMapping(value = "search") - public ExecutedResult<PagerResult<SysDictDataVO>> search(@RequestBody SearchSysDictData request) { - return this.service.search(request); - } -} diff --git a/src/main/java/com/lunhan/xxx/host/controller/base/SysDictTypeController.java b/src/main/java/com/lunhan/xxx/host/controller/base/SysDictTypeController.java deleted file mode 100644 index 53fda81..0000000 --- a/src/main/java/com/lunhan/xxx/host/controller/base/SysDictTypeController.java +++ /dev/null @@ -1,143 +0,0 @@ -/** -# __----~~~~~~~~~~~------___ -# . . ~~//====...... __--~ ~~ -# -. \_|// |||\\ ~~~~~~::::... /~ -# ___-==_ _-~o~ \/ ||| \\ _/~~- -# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ -# _-~~ .=~ | \\-_ '-~7 /- / || \ / -# .~ .~ | \\ -_ / /- / || \ / -# / ____ / | \\ ~-_/ /|- _/ .|| \ / -# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ -# ' ~-| /| |-~\~~ __--~~ -# |-~~-_/ | | ~\_ _-~ /\ -# / \ \__ \/~ \__ -# _--~ _/ | .-~~____--~-/ ~~==. -# ((->/~ '.|||' -_| ~~-/ , . _|| -# -_ ~\ ~~---l__i__i__i--~~_/ -# _-~-__ ~) \--______________--~~ -# //.-~~~-~_--~- |-------~~~~~~~~ -# //.-~~~--\ -# 神兽保佑 -# 永无BUG! -*/ -package com.lunhan.xxx.host.controller.base; - -import com.lunhan.xxx.common.ExecutedResult; -import com.lunhan.xxx.common.PagerResult; -import com.lunhan.xxx.common.util.ParameterUtil; -import com.lunhan.xxx.common.validator.ParameterValidateResult; -import com.lunhan.xxx.common.validator.ParameterValidator; -import com.lunhan.xxx.entity.request.ReqListId; -import com.lunhan.xxx.entity.request.sysdicttype.ReqCreateSysDictType; -import com.lunhan.xxx.entity.request.sysdicttype.ReqModifySysDictType; -import com.lunhan.xxx.entity.search.SearchSysDictType; -import com.lunhan.xxx.host.BasicController; -import com.lunhan.xxx.repository.vo.SysDictTypeVO; -import com.lunhan.xxx.service.SysDictTypeService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.*; - -import java.util.List; - -/** - * 03.字典类型 - * @author lin.liu - * @order 03 - */ -@RestController -@RequestMapping(value = "sysDictType") -public class SysDictTypeController extends BasicController { - @Autowired - private SysDictTypeService service; - - /** - * 创建[字典类型表] - * @author lin.liu - */ - @PostMapping(value = "create") - public ExecutedResult<Long> create(@RequestBody ReqCreateSysDictType request) { - //#region 参数验证 - ParameterValidator validator = new ParameterValidator() - // 非空 - //.addNotNullOrEmpty(ParameterUtil.named("名称"), request.getName()) - // 限制最大长度 - //.addLengthMax(ParameterUtil.named("名称"), request.getName(), ConstantFactory.LENGTH_MAX50) - ; - ParameterValidateResult result = validator.validate(); - if (result.getIsFiled()) { - return failed(result.getErrorMsg()); - } - //#endregion - return this.service.create(request); - } - - /** - * 编辑[字典类型表] - * @author lin.liu - */ - @PostMapping(value = "modify") - public ExecutedResult<String> modify(@RequestBody ReqModifySysDictType request) { - //#region 参数验证 - ParameterValidator validator = new ParameterValidator() - // 必须大于0 - .addGreater(ParameterUtil.named("[字典类型表]id"), request.getId(), 0L) - // 非空 - //.addNotNullOrEmpty(ParameterUtil.named("名称"), request.getName()) - // 限制最大长度 - //.addLengthMax(ParameterUtil.named("名称"), request.getName(), ConstantFactory.LENGTH_MAX50) - ; - ParameterValidateResult result = validator.validate(); - if (result.getIsFiled()) { - return failed(result.getErrorMsg()); - } - //#endregion - return this.service.modify(request); - } - - /** - * 获取[字典类型表] - * @author lin.liu - */ - @GetMapping(value = "get/{id}") - public ExecutedResult<SysDictTypeVO> get(@PathVariable Long id) { - return this.service.get(id); - } - - /** - * 根据id删除[字典类型表] - * @author zr - * @description 根据id删除[字典类型表] - */ - @PostMapping(value = "remove/{id}") - ExecutedResult<String> remove(@PathVariable Long id){ - return this.service.remove(id); - } - - /** - * 根据id批量删除字典类型 - */ - @PostMapping(value = "removeList") - public ExecutedResult<String> removeList(@RequestBody ReqListId request) { - return service.removeList(request.getListId()); - } - - /** - * 根据id批量获取[字典类型表] - * @author zr - * @description 根据id批量获取[字典类型表] - */ - @PostMapping(value = "getList") - public ExecutedResult<List<SysDictTypeVO>> getList(@RequestBody ReqListId request) { - return this.service.getList(request.getListId()); - } - - /** - * 查询[字典类型表] - * @author lin.liu - * @description 查询[字典类型表] - */ - @PostMapping(value = "search") - public ExecutedResult<PagerResult<SysDictTypeVO>> search(@RequestBody SearchSysDictType request) { - return this.service.search(request); - } -} diff --git a/src/main/java/com/lunhan/xxx/repository/BasicMapper.java b/src/main/java/com/lunhan/xxx/repository/BasicMapper.java deleted file mode 100644 index 3908aa4..0000000 --- a/src/main/java/com/lunhan/xxx/repository/BasicMapper.java +++ /dev/null @@ -1,126 +0,0 @@ -package com.lunhan.xxx.repository; - -import com.baomidou.mybatisplus.core.conditions.Wrapper; -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.lunhan.xxx.common.PagerResult; -import com.lunhan.xxx.entity.dto.SearchBasicDTO; -import org.apache.ibatis.session.ResultHandler; - -import java.io.Serializable; -import java.util.List; -import java.util.Map; - -public interface BasicMapper<T> extends BaseMapper<T> { - /** - * 批量新增 - * @param list 数据实体列表 - */ - Boolean addList(List<T> list); - - /** - * 批量更新 - * @param list 数据实体列表 - */ - Boolean modifyList(List<T> list); - - /** - * 批量查询其他实体列表 - * @param queryWrapper 查询条件 - * @param <E> 实体类型 - */ - <E> List<E> selectListObject(Wrapper<T> queryWrapper); - - /** - * 批量查询其他实体列表 - * @param queryWrapper 查询条件 - * @param resultHandler 查询结果处理器 - * @param <E> 实体类型 - */ - <E> void selectListObject(Wrapper<T> queryWrapper, ResultHandler<E> resultHandler); - - /** - * 根据主键查询单个数据实体 - * - * @param id 主键值 - */ - T get(Serializable id); - - /** - * 条件查询单个数据实体 - * - * @param queryWrapper 查询条件 - */ - T get(Wrapper<T> queryWrapper); - - /** - * 根据主键批量获取 - * @param listId 主键列表 - */ - <E extends Serializable> List<T> getList(List<E> listId); - - - /** - * 获取全量数据(慎重) - */ - List<T> getList(); - - /** - * 根据传入sql查询数据 - * - * @param queryWrapper 查询条件 - */ - List<Map<String, Object>> getMap(Wrapper<T> queryWrapper); - - /** - * 查询记录条数 - * - * @param queryWrapper 查询条件 - */ - Long getCount(Wrapper<T> queryWrapper); - - /** - * 根据主键id删除数据 - * - * @param id 主键id - * @return 是否成功 - */ - Boolean remove(Serializable id); - - /** - * 根据主键id删除数据 - * - * @param listId id列表 - * @return 是否成功 - */ - <E extends Serializable> Boolean remove(List<E> listId); - - /** - * 根据条件删除数据 - * - * @param queryWrapper 查询条件 - */ - Boolean remove(Wrapper<T> queryWrapper); - - /** - * 根据主键id逻辑删除数据(逻辑删除) - * - * @param id 主键id - * @return 是否成功 - */ - Boolean deleteLogic(Serializable id); - - /** - * 根据逐渐删除数据(逻辑删除) - * - * @param listId id列表 - * @return 是否成功 - */ - <E extends Serializable> Boolean deleteLogic(List<E> listId); - - /** - * 分页查询 - * - * @param search 查询参数 - */ - PagerResult<T> search(SearchBasicDTO search); -} diff --git a/src/main/java/com/lunhan/xxx/repository/BasicMapperImpl.java b/src/main/java/com/lunhan/xxx/repository/BasicMapperImpl.java deleted file mode 100644 index 4a33f2f..0000000 --- a/src/main/java/com/lunhan/xxx/repository/BasicMapperImpl.java +++ /dev/null @@ -1,699 +0,0 @@ -package com.lunhan.xxx.repository; - -import com.baomidou.mybatisplus.annotation.TableName; -import com.baomidou.mybatisplus.core.batch.BatchSqlSession; -import com.baomidou.mybatisplus.core.conditions.Wrapper; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.core.toolkit.Constants; -import com.baomidou.mybatisplus.core.toolkit.StringUtils; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import com.lunhan.xxx.common.PagerResult; -import com.lunhan.xxx.common.enums.ELogger; -import com.lunhan.xxx.common.enums.EResultCode; -import com.lunhan.xxx.common.enums.EYesOrNo; -import com.lunhan.xxx.common.exceptions.BusinessException; -import com.lunhan.xxx.common.util.LoggerUtil; -import com.lunhan.xxx.entity.dto.SearchBasicDTO; -import org.apache.ibatis.annotations.Param; -import org.apache.ibatis.executor.BatchResult; -import org.apache.ibatis.session.ResultHandler; -import org.slf4j.Logger; -import org.springframework.dao.EmptyResultDataAccessException; - -import java.io.Serializable; -import java.lang.reflect.ParameterizedType; -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.function.BiPredicate; - -/** - * 数据访问 实现类 - * - * @param <T> 数据实体 - */ -public abstract class BasicMapperImpl<T, M extends BasicMapper<T>> implements BasicMapper<T> { - protected M DB; - protected Class<T> clazz; - protected String tableName; - - protected static final Logger logger = LoggerUtil.get(ELogger.SQL_LOG); - - /** - * 构造方法 - */ - public BasicMapperImpl(M db) { - this.clazz = (Class<T>) ( - (ParameterizedType) getClass().getGenericSuperclass() - ).getActualTypeArguments()[0]; - this.DB = db; - TableName annotation = clazz.getAnnotation(TableName.class); - if (null == annotation) { - this.tableName = StringUtils.camelToUnderline(clazz.getSimpleName().replace("PO", "")); - return; - } - this.tableName = annotation.value(); - } - - public LambdaQueryWrapper<T> query() { - return Wrappers.lambdaQuery(); - } - - public UpdateWrapper<T> update() { - return Wrappers.update(); - } - - /** - * 插入一条记录 - * - * @param entity 实体对象 - */ - public int insert(T entity) { - return DB.insert(entity); - } - - /** - * 根据 ID 删除 - * - * @param id 主键 - */ - public int deleteById(Serializable id) { - return DB.deleteById(id); - } - - /** - * 根据 ID 删除 - * - * @param useFill 是否填充 - * @param obj 主键或实体 - * @since 3.5.7 - */ - public int deleteById(Object obj, boolean useFill) { - return DB.deleteById(obj, useFill); - } - - /** - * 根据实体(ID)删除 - * - * @param entity 实体对象 - * @since 3.4.4 - */ - public int deleteById(T entity) { - return DB.deleteById(entity); - } - - /** - * 根据 columnMap 条件,删除记录 - * - * @param columnMap 表字段 map 对象 - */ - public int deleteByMap(Map<String, Object> columnMap) { - return DB.deleteByMap(columnMap); - } - - /** - * 根据 entity 条件,删除记录 - * - * @param queryWrapper 实体对象封装操作类(可以为 null,里面的 entity 用于生成 where 语句) - */ - public int delete(@Param(Constants.WRAPPER) Wrapper<T> queryWrapper) { - return DB.delete(queryWrapper); - } - - - /** - * 删除(根据ID或实体 批量删除) - * - * @param idList 主键列表或实体列表(不能为 null 以及 empty) - * @deprecated 3.5.7 {@link #deleteByIds(Collection)} - */ - @Deprecated - public int deleteBatchIds(@Param(Constants.COLL) Collection<?> idList) { - return DB.deleteBatchIds(idList); - } - - - /** - * 删除(根据ID或实体 批量删除) - * - * @param idList 主键列表或实体列表(不能为 null 以及 empty) - * @since 3.5.7 - */ - public int deleteByIds(@Param(Constants.COLL) Collection<?> idList) { - return DB.deleteByIds(idList); - } - - /** - * 删除(根据ID或实体 批量删除) - * <p> - * 普通删除: DELETE FROM h2user WHERE id IN ( ? , ? ) - * </p> - * <p> - * 逻辑删除: UPDATE h2user SET deleted=1 WHERE id IN ( ? , ? ) AND deleted=0 - * </p> - * <p> - * 逻辑删除(填充): UPDATE h2user SET delete_user = 'xxx', deleted=1 WHERE id IN ( ? , ? ) AND deleted=0 - * <ul>注意:无论参数为id还是实体,填充参数只会以方法追加的et参数为准.<ul/> - * </p> - * - * @param collections 主键列表或实体列表(不能为 null 以及 empty) - * @param useFill 逻辑删除下是否填充 - * @since 3.5.7 - */ - public int deleteByIds(@Param(Constants.COLL) Collection<?> collections, boolean useFill) { - return DB.deleteByIds(collections, useFill); - } - - /** - * 根据 ID 修改 - * - * @param entity 实体对象 - */ - public int updateById(@Param(Constants.ENTITY) T entity) { - return DB.updateById(entity); - } - - /** - * 根据 whereEntity 条件,更新记录 - * - * @param entity 实体对象 (set 条件值,可以为 null,当entity为null时,无法进行自动填充) - * @param updateWrapper 实体对象封装操作类(可以为 null,里面的 entity 用于生成 where 语句) - */ - public int update(@Param(Constants.ENTITY) T entity, @Param(Constants.WRAPPER) Wrapper<T> updateWrapper) { - return DB.update(entity, updateWrapper); - } - - /** - * 根据 Wrapper 更新记录 - * <p>此方法无法进行自动填充,如需自动填充请使用{@link #update(Object, Wrapper)}</p> - * - * @param updateWrapper {@link UpdateWrapper} or {@link LambdaUpdateWrapper} - * @since 3.5.4 - */ - public int update(@Param(Constants.WRAPPER) Wrapper<T> updateWrapper) { - return DB.update(updateWrapper); - } - - /** - * 根据 ID 查询 - * - * @param id 主键 - */ - public T selectById(Serializable id) { - return DB.selectById(id); - } - - /** - * 查询(根据ID 批量查询) - * - * @param idList 主键列表(不能为 null 以及 empty) - */ - public List<T> selectBatchIds(@Param(Constants.COLL) Collection<? extends Serializable> idList) { - return DB.selectBatchIds(idList); - } - - /** - * 查询(根据ID 批量查询) - * - * @param idList idList 主键列表(不能为 null 以及 empty) - * @param resultHandler resultHandler 结果处理器 {@link ResultHandler} - * @since 3.5.4 - */ - public void selectBatchIds(@Param(Constants.COLL) Collection<? extends Serializable> idList, ResultHandler<T> resultHandler) { - DB.selectBatchIds(idList, resultHandler); - } - - /** - * 查询(根据 columnMap 条件) - * - * @param columnMap 表字段 map 对象 - */ - public List<T> selectByMap(Map<String, Object> columnMap) { - return DB.selectByMap(columnMap); - } - - /** - * 查询(根据 columnMap 条件) - * - * @param columnMap 表字段 map 对象 - * @param resultHandler resultHandler 结果处理器 {@link ResultHandler} - * @since 3.5.4 - */ - public void selectByMap(Map<String, Object> columnMap, ResultHandler<T> resultHandler) { - DB.selectByMap(columnMap, resultHandler); - } - - /** - * 根据 entity 条件,查询一条记录 - * <p>查询一条记录,例如 qw.last("limit 1") 限制取一条记录, 注意:多条数据会报异常</p> - * - * @param queryWrapper 实体对象封装操作类(可以为 null) - */ - public T selectOne(@Param(Constants.WRAPPER) Wrapper<T> queryWrapper) { - return DB.selectOne(queryWrapper); - } - - /** - * 根据 entity 条件,查询一条记录,现在会根据{@code throwEx}参数判断是否抛出异常,如果为false就直接返回一条数据 - * <p>查询一条记录,例如 qw.last("limit 1") 限制取一条记录, 注意:多条数据会报异常</p> - * - * @param queryWrapper 实体对象封装操作类(可以为 null) - * @param throwEx boolean 参数,为true如果存在多个结果直接抛出异常 - */ - public T selectOne(@Param(Constants.WRAPPER) Wrapper<T> queryWrapper, boolean throwEx) { - return DB.selectOne(queryWrapper, throwEx); - } - - /** - * 根据 Wrapper 条件,判断是否存在记录 - * - * @param queryWrapper 实体对象封装操作类 - * @return 是否存在记录 - */ - public boolean exists(Wrapper<T> queryWrapper) { - return DB.exists(queryWrapper); - } - - /** - * 根据 Wrapper 条件,查询总记录数 - * - * @param queryWrapper 实体对象封装操作类(可以为 null) - */ - public Long selectCount(@Param(Constants.WRAPPER) Wrapper<T> queryWrapper) { - return DB.selectCount(queryWrapper); - } - - /** - * 根据 entity 条件,查询全部记录 - * - * @param queryWrapper 实体对象封装操作类(可以为 null) - */ - public List<T> selectList(@Param(Constants.WRAPPER) Wrapper<T> queryWrapper) { - return DB.selectList(queryWrapper); - } - - /** - * 根据 entity 条件,查询全部记录 - * - * @param queryWrapper 实体对象封装操作类(可以为 null) - * @param resultHandler 结果处理器 {@link ResultHandler} - * @since 3.5.4 - */ - public void selectList(@Param(Constants.WRAPPER) Wrapper<T> queryWrapper, ResultHandler<T> resultHandler) { - DB.selectList(queryWrapper, resultHandler); - } - - /** - * 根据 entity 条件,查询全部记录(并翻页) - * - * @param page 分页查询条件 - * @param queryWrapper 实体对象封装操作类(可以为 null) - * @since 3.5.3.2 - */ - public List<T> selectList(IPage<T> page, @Param(Constants.WRAPPER) Wrapper<T> queryWrapper) { - return DB.selectList(page, queryWrapper); - } - - /** - * 根据 entity 条件,查询全部记录(并翻页) - * - * @param page 分页查询条件 - * @param queryWrapper 实体对象封装操作类(可以为 null) - * @param resultHandler 结果处理器 {@link ResultHandler} - * @since 3.5.4 - */ - public void selectList(IPage<T> page, @Param(Constants.WRAPPER) Wrapper<T> queryWrapper, ResultHandler<T> resultHandler) { - DB.selectList(page, queryWrapper, resultHandler); - } - - - /** - * 根据 Wrapper 条件,查询全部记录 - * - * @param queryWrapper 实体对象封装操作类 - */ - public List<Map<String, Object>> selectMaps(@Param(Constants.WRAPPER) Wrapper<T> queryWrapper) { - return DB.selectMaps(queryWrapper); - } - - /** - * 根据 Wrapper 条件,查询全部记录 - * - * @param queryWrapper 实体对象封装操作类 - * @param resultHandler 结果处理器 {@link ResultHandler} - * @since 3.5.4 - */ - public void selectMaps(@Param(Constants.WRAPPER) Wrapper<T> queryWrapper, ResultHandler<Map<String, Object>> resultHandler) { - DB.selectMaps(queryWrapper, resultHandler); - } - - /** - * 根据 Wrapper 条件,查询全部记录(并翻页) - * - * @param page 分页查询条件 - * @param queryWrapper 实体对象封装操作类 - * @since 3.5.3.2 - */ - public List<Map<String, Object>> selectMaps(IPage<? extends Map<String, Object>> page, @Param(Constants.WRAPPER) Wrapper<T> queryWrapper) { - return DB.selectMaps(page, queryWrapper); - } - - /** - * 根据 Wrapper 条件,查询全部记录(并翻页) - * - * @param page 分页查询条件 - * @param queryWrapper 实体对象封装操作类 - * @param resultHandler 结果处理器 {@link ResultHandler} - * @since 3.5.4 - */ - public void selectMaps(IPage<? extends Map<String, Object>> page, @Param(Constants.WRAPPER) Wrapper<T> queryWrapper, ResultHandler<Map<String, Object>> resultHandler) { - DB.selectMaps(page, queryWrapper, resultHandler); - } - - /** - * 根据 Wrapper 条件,查询全部记录 - * <p>注意: 只返回第一个字段的值</p> - * - * @param queryWrapper 实体对象封装操作类(可以为 null) - */ - public <E> List<E> selectObjs(@Param(Constants.WRAPPER) Wrapper<T> queryWrapper) { - return DB.selectObjs(queryWrapper); - } - - /** - * 根据 Wrapper 条件,查询全部记录 - * <p>注意: 只返回第一个字段的值</p> - * - * @param queryWrapper 实体对象封装操作类(可以为 null) - * @param resultHandler 结果处理器 {@link ResultHandler} - * @since 3.5.4 - */ - public <E> void selectObjs(@Param(Constants.WRAPPER) Wrapper<T> queryWrapper, ResultHandler<E> resultHandler) { - DB.selectObjs(queryWrapper, resultHandler); - } - - /** - * 根据 entity 条件,查询全部记录(并翻页) - * - * @param page 分页查询条件 - * @param queryWrapper 实体对象封装操作类(可以为 null) - */ - public <P extends IPage<T>> P selectPage(P page, @Param(Constants.WRAPPER) Wrapper<T> queryWrapper) { - return DB.selectPage(page, queryWrapper); - } - - /** - * 根据 Wrapper 条件,查询全部记录(并翻页) - * - * @param page 分页查询条件 - * @param queryWrapper 实体对象封装操作类 - */ - public <P extends IPage<Map<String, Object>>> P selectMapsPage(P page, @Param(Constants.WRAPPER) Wrapper<T> queryWrapper) { - return DB.selectMapsPage(page, queryWrapper); - } - - /** - * 主键存在更新记录,否插入一条记录 - * - * @param entity 实体对象 (不能为空) - * @since 3.5.7 - */ - public boolean insertOrUpdate(T entity) { - return DB.insertOrUpdate(entity); - } - - - /** - * 插入(批量) - * - * @param entityList 实体对象集合 - * @since 3.5.7 - */ - public List<BatchResult> insert(Collection<T> entityList) { - return DB.insert(entityList); - } - - /** - * 插入(批量) - * - * @param entityList 实体对象集合 - * @param batchSize 插入批次数量 - * @since 3.5.7 - */ - public List<BatchResult> insert(Collection<T> entityList, int batchSize) { - return DB.insert(entityList, batchSize); - } - - /** - * 根据ID 批量更新 - * - * @param entityList 实体对象集合 - * @since 3.5.7 - */ - public List<BatchResult> updateById(Collection<T> entityList) { - return DB.updateById(entityList); - } - - /** - * 根据ID 批量更新 - * - * @param entityList 实体对象集合 - * @param batchSize 插入批次数量 - * @since 3.5.7 - */ - public List<BatchResult> updateById(Collection<T> entityList, int batchSize) { - return DB.updateById(entityList, batchSize); - } - - /** - * 批量修改或插入 - * - * @param entityList 实体对象集合 - * @since 3.5.7 - */ - public List<BatchResult> insertOrUpdate(Collection<T> entityList) { - return DB.insertOrUpdate(entityList); - } - - /** - * 批量修改或插入 - * - * @param entityList 实体对象集合 - * @param batchSize 插入批次数量 - * @since 3.5.7 - */ - public List<BatchResult> insertOrUpdate(Collection<T> entityList, int batchSize) { - return DB.insertOrUpdate(entityList, batchSize); - } - - /** - * 批量修改或插入 - * - * @param entityList 实体对象集合 - * @since 3.5.7 - */ - public List<BatchResult> insertOrUpdate(Collection<T> entityList, BiPredicate<BatchSqlSession, T> insertPredicate) { - return DB.insertOrUpdate(entityList, insertPredicate); - } - - /** - * 批量修改或插入 - * - * @param entityList 实体对象集合 - * @param batchSize 插入批次数量 - * @since 3.5.7 - */ - public List<BatchResult> insertOrUpdate(Collection<T> entityList, BiPredicate<BatchSqlSession, T> insertPredicate, int batchSize) { - return DB.insertOrUpdate(entityList, insertPredicate, batchSize); - } - - - /** - * 批量新增 - * - * @param list 数据实体列表 - */ - public Boolean addList(List<T> list) { - List<BatchResult> batchResult = DB.insert(list); - // TODO 判断成功 - return Boolean.TRUE; - } - - /** - * 批量更新 - * - * @param list 数据实体列表 - */ - public Boolean modifyList(List<T> list) { - List<BatchResult> batchResult = DB.updateById(list); - // TODO 判断成功 - return Boolean.TRUE; - } - - /** - * 批量查询其他实体列表 - * - * @param queryWrapper 查询条件 - */ - public <E> List<E> selectListObject(Wrapper<T> queryWrapper) { - return DB.selectObjs(queryWrapper); - } - - /** - * 批量查询其他实体列表 - * - * @param queryWrapper 查询条件 - * @param resultHandler 查询结果处理器 - */ - public <E> void selectListObject(Wrapper<T> queryWrapper, ResultHandler<E> resultHandler) { - DB.selectObjs(queryWrapper, resultHandler); - } - - /** - * 根据主键查询单个数据实体 - * - * @param id 主键值 - */ - public T get(Serializable id) { - return DB.selectById(id); - } - - /** - * 条件查询单个数据实体 - * - * @param queryWrapper 查询条件 - */ - public T get(Wrapper<T> queryWrapper) { - String method = "BasicDao.Wrapper<T> queryWrapper"; - try { - return DB.selectOne(queryWrapper); - } catch (EmptyResultDataAccessException e) { - logger.error(method, e); - return null; - } catch (Exception e) { - logger.error(method + ", 发生异常", e); - throw new BusinessException(EResultCode.ERROR, "BasicDao.get(SqlBuilder builder)发生异常." + e.getMessage()); - } - } - - /** - * 根据主键批量获取 - * - * @param listId 主键列表 - */ - public <E extends Serializable> List<T> getList(List<E> listId) { - return DB.selectBatchIds(listId); - } - - /** - * 获取全量数据(慎重) - */ - public List<T> getList() { - return DB.selectList(null); - } - - /** - * 根据传入sql查询数据 - * - * @param queryWrapper 查询条件 - */ - public List<Map<String, Object>> getMap(Wrapper<T> queryWrapper) { - return DB.selectMaps(queryWrapper); - } - - /** - * 查询记录条数 - * - * @param queryWrapper 查询条件 - */ - public Long getCount(Wrapper<T> queryWrapper) { - return DB.selectCount(queryWrapper); - } - - /** - * 根据主键删除数据 - * - * @param id 主键 - * @return 是否成功 - */ - public Boolean remove(Serializable id) { - int rowCount = DB.deleteById(id); - if (rowCount > 0) { - return Boolean.TRUE; - } - return Boolean.FALSE; - } - - /** - * 根据主键删除数据 - * - * @param listId id列表 - * @return 是否成功 - */ - public <E extends Serializable> Boolean remove(List<E> listId) { - int rowCount = DB.deleteByIds(listId); - if (rowCount > 0) { - return Boolean.TRUE; - } - return Boolean.FALSE; - - } - - /** - * 根据条件删除数据 - * - * @param queryWrapper 查询条件 - */ - public Boolean remove(Wrapper<T> queryWrapper) { - int rowCount = DB.delete(queryWrapper); - if (rowCount > 0) { - return Boolean.TRUE; - } - return Boolean.FALSE; - } - - /** - * 根据主键逻辑删除数据(逻辑删除) - * - * @param id 主键 - * @return 是否成功 - */ - public Boolean deleteLogic(Serializable id) { - UpdateWrapper<T> where = Wrappers.update(); - where.set("is_delete", EYesOrNo.YES.getValue()); - where.eq("id", id); - int rowCount = DB.update(where); - if (rowCount > 0) { - return Boolean.TRUE; - } - return Boolean.FALSE; - } - - /** - * 根据逐渐删除数据(逻辑删除) - * - * @param listId id列表 - * @return 是否成功 - */ - public <E extends Serializable> Boolean deleteLogic(List<E> listId) { - UpdateWrapper<T> where = Wrappers.update(); - where.set("is_delete", EYesOrNo.YES.getValue()); - where.in("id", listId); - int rowCount = DB.update(where); - if (rowCount > 0) { - return Boolean.TRUE; - } - return Boolean.FALSE; - } - - /** - * 分页查询 - * - * @param search 查询参数 - */ - @Override - public abstract PagerResult<T> search(SearchBasicDTO search); -} diff --git a/src/main/java/com/lunhan/xxx/repository/bo/AdminUserBO.java b/src/main/java/com/lunhan/xxx/repository/bo/AdminUserBO.java deleted file mode 100644 index a9454e4..0000000 --- a/src/main/java/com/lunhan/xxx/repository/bo/AdminUserBO.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.lunhan.xxx.repository.bo; - -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; - -import java.io.Serializable; - -@Data -@TableName("admin_user") -public class AdminUserBO implements Serializable { - /** - * 主键 - */ - @TableId - @TableField("id") - private Long id; - /** - * 用户名 - */ - @TableField("user_name") - private String userName; - /** - * 昵称 - */ - @TableField("nick_name") - private String nickName; -} diff --git a/src/main/java/com/lunhan/xxx/repository/bo/NoticeBO.java b/src/main/java/com/lunhan/xxx/repository/bo/NoticeBO.java deleted file mode 100644 index 4dfd291..0000000 --- a/src/main/java/com/lunhan/xxx/repository/bo/NoticeBO.java +++ /dev/null @@ -1,66 +0,0 @@ -package com.lunhan.xxx.repository.bo; - -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; - -import java.io.Serializable; -import java.sql.Timestamp; - -/** - * 公告-不返回内容 - * @author lin.liu - * @description 公告 - * @date 2023/02/26 - */ -@Data -@TableName("notice") -public class NoticeBO implements Serializable { - /** - * 主键 - */ - @TableId - @TableField("id") - private Long id; - /** - * 发布人 - */ - @TableField("user_id") - private Long userId; - /** - * 发布人昵称 - */ - @TableField("user_nick_name") - private String userNickName; - /** - * 标题 - */ - @TableField("title") - private String title; - /** - * 摘要 - */ - @TableField("summary") - private String summary; - /** - * 排序 越大越靠后 - */ - @TableField("sort") - private Integer sort; - /** - * 状态(EState) 正常=1,关闭=2,删除=3 - */ - @TableField("status") - private Integer status; - /** - * 创建时间 - */ - @TableField("create_time") - private Long createTime; - /** - * 数据最后更新时间 - */ - @TableField("update_time") - private Timestamp updateTime; -} diff --git a/src/main/java/com/lunhan/xxx/repository/impl/AdminMenuMapperImpl.java b/src/main/java/com/lunhan/xxx/repository/impl/AdminMenuMapperImpl.java deleted file mode 100644 index 84b8ae4..0000000 --- a/src/main/java/com/lunhan/xxx/repository/impl/AdminMenuMapperImpl.java +++ /dev/null @@ -1,135 +0,0 @@ -/** -# __----~~~~~~~~~~~------___ -# . . ~~//====...... __--~ ~~ -# -. \_|// |||\\ ~~~~~~::::... /~ -# ___-==_ _-~o~ \/ ||| \\ _/~~- -# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ -# _-~~ .=~ | \\-_ '-~7 /- / || \ / -# .~ .~ | \\ -_ / /- / || \ / -# / ____ / | \\ ~-_/ /|- _/ .|| \ / -# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ -# ' ~-| /| |-~\~~ __--~~ -# |-~~-_/ | | ~\_ _-~ /\ -# / \ \__ \/~ \__ -# _--~ _/ | .-~~____--~-/ ~~==. -# ((->/~ '.|||' -_| ~~-/ , . _|| -# -_ ~\ ~~---l__i__i__i--~~_/ -# _-~-__ ~) \--______________--~~ -# //.-~~~-~_--~- |-------~~~~~~~~ -# //.-~~~--\ -# 神兽保佑 -# 永无BUG! -*/ -package com.lunhan.xxx.repository.impl; - -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.lunhan.xxx.common.PagerResult; -import com.lunhan.xxx.common.enums.EYesOrNo; -import com.lunhan.xxx.common.util.ListUtil; -import com.lunhan.xxx.common.util.NumericUtil; -import com.lunhan.xxx.common.util.StringUtil; -import com.lunhan.xxx.entity.dto.OrderByDTO; -import com.lunhan.xxx.entity.dto.SearchBasicDTO; -import com.lunhan.xxx.entity.enums.EOrderBy; -import com.lunhan.xxx.entity.search.SearchAdminMenu; -import com.lunhan.xxx.repository.BasicMapperImpl; -import com.lunhan.xxx.repository.mapper.AdminMenuMapper; -import com.lunhan.xxx.repository.po.AdminMenuPO; -import org.springframework.stereotype.Repository; - -import java.util.List; - -/** - * 后台菜单 - * @author lin.liu - * @description 后台菜单 - */ -@Repository -public class AdminMenuMapperImpl extends BasicMapperImpl<AdminMenuPO, AdminMenuMapper> { - public AdminMenuMapper mapper; - AdminMenuMapperImpl(AdminMenuMapper mapper) { - super(mapper); - } - - @Override - public PagerResult<AdminMenuPO> search(SearchBasicDTO request) { - // 还原查询条件真实类型 - SearchAdminMenu search = (SearchAdminMenu)request; - // 查询条件 - LambdaQueryWrapper<AdminMenuPO> queryWrapper = this.query(); - // 非逻辑删除 - queryWrapper.eq(AdminMenuPO::getIsDelete, EYesOrNo.NO.getValue()); - // 状态 - //queryWrapper.eq(NumericUtil.tryParseInt(search.getStatus()).compareTo(0) > 0, AdminMenuPO::getStatus, search.getStatus()); - // 状态列表 - //queryWrapper.in(ListUtil.isNotNullOrEmpty(search.getListStatus()), AdminMenuPO::getStatus, search.getListStatus()); - - // 数据创建时间-起始 - queryWrapper.ge(NumericUtil.tryParseLong(search.getCreateTimeStart()).compareTo(0L) > 0, AdminMenuPO::getCreateTime, search.getCreateTimeStart()); - // 数据创建时间-截止 - queryWrapper.le(NumericUtil.tryParseLong(search.getCreateTimeEnd()).compareTo(0L) > 0, AdminMenuPO::getCreateTime, search.getCreateTimeEnd()); - // 关键字 - if (StringUtil.isNotNullOrEmpty(search.getKeywords())) { - queryWrapper.and(q -> - q.like(AdminMenuPO::getName, search.getKeywords()) - .or().like(AdminMenuPO::getTitle, search.getKeywords()) - ); - } - - // 排序处理 - if (ListUtil.isNotNullOrEmpty(search.getOrderBy())) { - for (OrderByDTO item : search.getOrderBy()) { - EOrderBy orderBy = EOrderBy.getByValue(item.getOrderBy()); - // 顺序排序 - if (item.getIsAsc()) { - switch (orderBy) { - // 主键 - case ID: - queryWrapper.orderByAsc(AdminMenuPO::getId); - break; - // 数据创建时间 - case CREATE_TIME: - queryWrapper.orderByAsc(AdminMenuPO::getCreateTime); - break; - // 最后更新时间 - case UPDATE_TIME: - queryWrapper.orderByAsc(AdminMenuPO::getUpdateTime); - break; - } - } else { - // 倒叙排序 - switch (orderBy) { - // 主键 - case ID: - queryWrapper.orderByDesc(AdminMenuPO::getId); - break; - // 数据创建时间 - case CREATE_TIME: - queryWrapper.orderByDesc(AdminMenuPO::getCreateTime); - break; - // 最后更新时间 - case UPDATE_TIME: - queryWrapper.orderByDesc(AdminMenuPO::getUpdateTime); - break; - } - } - } - } else { - queryWrapper.orderByDesc(AdminMenuPO::getId); - } - Page<AdminMenuPO> pageResult = DB.selectPage(new Page<>(search.getPage(), search.getLimit()), queryWrapper); - return new PagerResult<>(pageResult.getSize(), pageResult.getCurrent(), pageResult.getTotal(), pageResult.getRecords()); - } - - /** - * 根据父级菜单获取子菜单列表 - * @param parentId 父级菜单id - */ - public List<AdminMenuPO> list4Parent(Long parentId) { - // 查询条件 - LambdaQueryWrapper<AdminMenuPO> queryWrapper = this.query(); - queryWrapper.eq(AdminMenuPO::getParentId, parentId); - return DB.selectList(queryWrapper); - } -} diff --git a/src/main/java/com/lunhan/xxx/repository/impl/AdminMenusMapperImpl.java b/src/main/java/com/lunhan/xxx/repository/impl/AdminMenusMapperImpl.java deleted file mode 100644 index 18fc834..0000000 --- a/src/main/java/com/lunhan/xxx/repository/impl/AdminMenusMapperImpl.java +++ /dev/null @@ -1,137 +0,0 @@ -/** -# __----~~~~~~~~~~~------___ -# . . ~~//====...... __--~ ~~ -# -. \_|// |||\\ ~~~~~~::::... /~ -# ___-==_ _-~o~ \/ ||| \\ _/~~- -# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ -# _-~~ .=~ | \\-_ '-~7 /- / || \ / -# .~ .~ | \\ -_ / /- / || \ / -# / ____ / | \\ ~-_/ /|- _/ .|| \ / -# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ -# ' ~-| /| |-~\~~ __--~~ -# |-~~-_/ | | ~\_ _-~ /\ -# / \ \__ \/~ \__ -# _--~ _/ | .-~~____--~-/ ~~==. -# ((->/~ '.|||' -_| ~~-/ , . _|| -# -_ ~\ ~~---l__i__i__i--~~_/ -# _-~-__ ~) \--______________--~~ -# //.-~~~-~_--~- |-------~~~~~~~~ -# //.-~~~--\ -# 神兽保佑 -# 永无BUG! -*/ -package com.lunhan.xxx.repository.impl; - -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.lunhan.xxx.common.PagerResult; -import com.lunhan.xxx.common.enums.EYesOrNo; -import com.lunhan.xxx.common.util.*; -import com.lunhan.xxx.entity.dto.*; -import com.lunhan.xxx.entity.enums.*; -import com.lunhan.xxx.repository.BasicMapperImpl; -import org.springframework.stereotype.Repository; - -import java.util.List; -import com.lunhan.xxx.entity.search.SearchAdminMenus; -import com.lunhan.xxx.repository.mapper.AdminMenusMapper; -import com.lunhan.xxx.repository.po.AdminMenusPO; - -/** - * 菜单信息 - * @author lin.liu - */ -@Repository -public class AdminMenusMapperImpl extends BasicMapperImpl<AdminMenusPO, AdminMenusMapper> { - AdminMenusMapperImpl(AdminMenusMapper mapper) { - super(mapper); - } - - @Override - public PagerResult<AdminMenusPO> search(SearchBasicDTO request) { - // 还原查询条件真实类型 - SearchAdminMenus search = (SearchAdminMenus)request; - // 查询条件 - LambdaQueryWrapper<AdminMenusPO> queryWrapper = this.query(); - // 非逻辑删除 - queryWrapper.eq(AdminMenusPO::getIsDelete, EYesOrNo.NO.getValue()); - // 状态 - //queryWrapper.eq(NumericUtil.tryParseInt(search.getStatus()).compareTo(0) > 0, AdminMenusPO::getStatus, search.getStatus()); - // 状态列表 - //queryWrapper.in(ListUtil.isNotNullOrEmpty(search.getListStatus()), AdminMenusPO::getStatus, search.getListStatus()); - - // 数据创建时间-起始 - queryWrapper.ge(NumericUtil.tryParseLong(search.getCreateTimeStart()).compareTo(0L) > 0, AdminMenusPO::getCreateTime, search.getCreateTimeStart()); - // 数据创建时间-截止 - queryWrapper.le(NumericUtil.tryParseLong(search.getCreateTimeEnd()).compareTo(0L) > 0, AdminMenusPO::getCreateTime, search.getCreateTimeEnd()); - // 关键字 - //if (StringUtil.isNotNullOrEmpty(search.getKeywords())) { - // queryWrapper.and(q -> - // q.like(AdminMenusPO::getName, search.getKeywords()) - // .or().like(AdminMenusPO::getPhone, search.getKeywords()) - // ); - //} - - // 排序处理 - if (ListUtil.isNotNullOrEmpty(search.getOrderBy())) { - for (OrderByDTO item : search.getOrderBy()) { - EOrderBy orderBy = EOrderBy.getByValue(item.getOrderBy()); - // 顺序排序 - if (item.getIsAsc()) { - switch (orderBy) { - // 主键 - case ID: - queryWrapper.orderByAsc(AdminMenusPO::getId); - break; - // 数据创建时间 - case CREATE_TIME: - queryWrapper.orderByAsc(AdminMenusPO::getCreateTime); - break; - // 最后更新时间 - case UPDATE_TIME: - queryWrapper.orderByAsc(AdminMenusPO::getUpdateTime); - break; - } - } else { - // 倒叙排序 - switch (orderBy) { - // 主键 - case ID: - queryWrapper.orderByDesc(AdminMenusPO::getId); - break; - // 数据创建时间 - case CREATE_TIME: - queryWrapper.orderByDesc(AdminMenusPO::getCreateTime); - break; - // 最后更新时间 - case UPDATE_TIME: - queryWrapper.orderByDesc(AdminMenusPO::getUpdateTime); - break; - } - } - } - } else { - queryWrapper.orderByDesc(AdminMenusPO::getId); - } - Page<AdminMenusPO> pageResult = super.selectPage(new Page<>(search.getPage(), search.getLimit()), queryWrapper); - return new PagerResult<>(pageResult.getSize(), pageResult.getCurrent(), pageResult.getTotal(), pageResult.getRecords()); - } - - public Boolean add(AdminMenusPO item) { - int rowCount = super.insert(item); - return rowCount == 1; - } - - public Boolean addNotIncrement(AdminMenusPO item) { - int rowCount = super.insert(item); - return rowCount == 1; - } - - public AdminMenusPO getById(Long id) { - return super.get(id); - } - - public List<AdminMenusPO> getListById(List<Long> listId) { - return super.getList(listId); - } -} diff --git a/src/main/java/com/lunhan/xxx/repository/impl/AdminPermissionMapperImpl.java b/src/main/java/com/lunhan/xxx/repository/impl/AdminPermissionMapperImpl.java deleted file mode 100644 index de54f5d..0000000 --- a/src/main/java/com/lunhan/xxx/repository/impl/AdminPermissionMapperImpl.java +++ /dev/null @@ -1,141 +0,0 @@ -/** -# __----~~~~~~~~~~~------___ -# . . ~~//====...... __--~ ~~ -# -. \_|// |||\\ ~~~~~~::::... /~ -# ___-==_ _-~o~ \/ ||| \\ _/~~- -# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ -# _-~~ .=~ | \\-_ '-~7 /- / || \ / -# .~ .~ | \\ -_ / /- / || \ / -# / ____ / | \\ ~-_/ /|- _/ .|| \ / -# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ -# ' ~-| /| |-~\~~ __--~~ -# |-~~-_/ | | ~\_ _-~ /\ -# / \ \__ \/~ \__ -# _--~ _/ | .-~~____--~-/ ~~==. -# ((->/~ '.|||' -_| ~~-/ , . _|| -# -_ ~\ ~~---l__i__i__i--~~_/ -# _-~-__ ~) \--______________--~~ -# //.-~~~-~_--~- |-------~~~~~~~~ -# //.-~~~--\ -# 神兽保佑 -# 永无BUG! -*/ -package com.lunhan.xxx.repository.impl; - -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.lunhan.xxx.common.PagerResult; -import com.lunhan.xxx.common.enums.EYesOrNo; -import com.lunhan.xxx.common.util.ListUtil; -import com.lunhan.xxx.common.util.NumericUtil; -import com.lunhan.xxx.common.util.StringUtil; -import com.lunhan.xxx.entity.dto.OrderByDTO; -import com.lunhan.xxx.entity.dto.SearchBasicDTO; -import com.lunhan.xxx.entity.enums.EOrderBy; -import com.lunhan.xxx.entity.search.SearchAdminPermission; -import com.lunhan.xxx.repository.BasicMapperImpl; -import com.lunhan.xxx.repository.mapper.AdminPermissionMapper; -import com.lunhan.xxx.repository.po.AdminPermissionPO; -import org.springframework.stereotype.Repository; - -import java.util.List; - -/** - * 后台用户权限表 - * @author lin.liu - * @description 后台用户权限表 - */ -@Repository -public class AdminPermissionMapperImpl extends BasicMapperImpl<AdminPermissionPO, AdminPermissionMapper> { - AdminPermissionMapperImpl(AdminPermissionMapper mapper) { - super(mapper); - } - - @Override - public PagerResult<AdminPermissionPO> search(SearchBasicDTO request) { - // 还原查询条件真实类型 - SearchAdminPermission search = (SearchAdminPermission)request; - // 查询条件 - LambdaQueryWrapper<AdminPermissionPO> queryWrapper = this.query(); - // 非逻辑删除 - queryWrapper.eq(AdminPermissionPO::getIsDelete, EYesOrNo.NO.getValue()); - // 状态 - //queryWrapper.eq(NumericUtil.tryParseInt(search.getStatus()).compareTo(0) > 0, AdminPermissionPO::getStatus, search.getStatus()); - // 状态列表 - //queryWrapper.in(ListUtil.isNotNullOrEmpty(search.getListStatus()), AdminPermissionPO::getStatus, search.getListStatus()); - - // 数据创建时间-起始 - queryWrapper.ge(NumericUtil.tryParseLong(search.getCreateTimeStart()).compareTo(0L) > 0, AdminPermissionPO::getCreateTime, search.getCreateTimeStart()); - // 数据创建时间-截止 - queryWrapper.le(NumericUtil.tryParseLong(search.getCreateTimeEnd()).compareTo(0L) > 0, AdminPermissionPO::getCreateTime, search.getCreateTimeEnd()); - // 关键字 - if (StringUtil.isNotNullOrEmpty(search.getKeywords())) { - queryWrapper.and(q -> - q.like(AdminPermissionPO::getName, search.getKeywords()) - .or().like(AdminPermissionPO::getMenuUrl, search.getKeywords()) - ); - } - - // 排序处理 - if (ListUtil.isNotNullOrEmpty(search.getOrderBy())) { - for (OrderByDTO item : search.getOrderBy()) { - EOrderBy orderBy = EOrderBy.getByValue(item.getOrderBy()); - // 顺序排序 - if (item.getIsAsc()) { - switch (orderBy) { - // 主键 - case ID: - queryWrapper.orderByAsc(AdminPermissionPO::getId); - break; - // 数据创建时间 - case CREATE_TIME: - queryWrapper.orderByAsc(AdminPermissionPO::getCreateTime); - break; - // 最后更新时间 - case UPDATE_TIME: - queryWrapper.orderByAsc(AdminPermissionPO::getUpdateTime); - break; - } - } else { - // 倒叙排序 - switch (orderBy) { - // 主键 - case ID: - queryWrapper.orderByDesc(AdminPermissionPO::getId); - break; - // 数据创建时间 - case CREATE_TIME: - queryWrapper.orderByDesc(AdminPermissionPO::getCreateTime); - break; - // 最后更新时间 - case UPDATE_TIME: - queryWrapper.orderByDesc(AdminPermissionPO::getUpdateTime); - break; - } - } - } - } else { - queryWrapper.orderByDesc(AdminPermissionPO::getId); - } - Page<AdminPermissionPO> pageResult = DB.selectPage(new Page<>(search.getPage(), search.getLimit()), queryWrapper); - return new PagerResult<>(pageResult.getSize(), pageResult.getCurrent(), pageResult.getTotal(), pageResult.getRecords()); - } - - /** - * 根据菜单id获取权限列表 - * @param listMenuId 菜单id - */ - public List<AdminPermissionPO> list4MenuId(List<Long> listMenuId) { - // 查询条件 - LambdaQueryWrapper<AdminPermissionPO> queryWrapper = this.query(); - queryWrapper.in(AdminPermissionPO::getMenuId, listMenuId); - return DB.selectList(queryWrapper); - } - - public AdminPermissionPO get4Sn(String sn) { - // 查询条件 - LambdaQueryWrapper<AdminPermissionPO> queryWrapper = this.query(); - queryWrapper.eq(AdminPermissionPO::getSn, sn); - return DB.selectOne(queryWrapper); - } -} diff --git a/src/main/java/com/lunhan/xxx/repository/impl/AdminRoleMapperImpl.java b/src/main/java/com/lunhan/xxx/repository/impl/AdminRoleMapperImpl.java deleted file mode 100644 index 7fce277..0000000 --- a/src/main/java/com/lunhan/xxx/repository/impl/AdminRoleMapperImpl.java +++ /dev/null @@ -1,117 +0,0 @@ -/** -# __----~~~~~~~~~~~------___ -# . . ~~//====...... __--~ ~~ -# -. \_|// |||\\ ~~~~~~::::... /~ -# ___-==_ _-~o~ \/ ||| \\ _/~~- -# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ -# _-~~ .=~ | \\-_ '-~7 /- / || \ / -# .~ .~ | \\ -_ / /- / || \ / -# / ____ / | \\ ~-_/ /|- _/ .|| \ / -# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ -# ' ~-| /| |-~\~~ __--~~ -# |-~~-_/ | | ~\_ _-~ /\ -# / \ \__ \/~ \__ -# _--~ _/ | .-~~____--~-/ ~~==. -# ((->/~ '.|||' -_| ~~-/ , . _|| -# -_ ~\ ~~---l__i__i__i--~~_/ -# _-~-__ ~) \--______________--~~ -# //.-~~~-~_--~- |-------~~~~~~~~ -# //.-~~~--\ -# 神兽保佑 -# 永无BUG! -*/ -package com.lunhan.xxx.repository.impl; - -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.lunhan.xxx.common.PagerResult; -import com.lunhan.xxx.common.enums.EYesOrNo; -import com.lunhan.xxx.common.util.*; -import com.lunhan.xxx.entity.dto.*; -import com.lunhan.xxx.entity.enums.*; -import com.lunhan.xxx.entity.search.SearchAdminRole; -import com.lunhan.xxx.repository.BasicMapperImpl; -import com.lunhan.xxx.repository.mapper.AdminRoleMapper; -import com.lunhan.xxx.repository.po.AdminRolePO; -import org.springframework.stereotype.Repository; - -/** - * 后台用户角色表 - * @author lin.liu - * @description 后台用户角色表 - */ -@Repository -public class AdminRoleMapperImpl extends BasicMapperImpl<AdminRolePO, AdminRoleMapper> { - AdminRoleMapperImpl(AdminRoleMapper mapper) { - super(mapper); - } - - @Override - public PagerResult<AdminRolePO> search(SearchBasicDTO request) { - // 还原查询条件真实类型 - SearchAdminRole search = (SearchAdminRole)request; - // 查询条件 - LambdaQueryWrapper<AdminRolePO> queryWrapper = this.query(); - // 非逻辑删除 - queryWrapper.eq(AdminRolePO::getIsDelete, EYesOrNo.NO.getValue()); - // 状态 - //queryWrapper.eq(NumericUtil.tryParseInt(search.getStatus()).compareTo(0) > 0, AdminRolePO::getStatus, search.getStatus()); - // 状态列表 - //queryWrapper.in(ListUtil.isNotNullOrEmpty(search.getListStatus()), AdminRolePO::getStatus, search.getListStatus()); - - // 数据创建时间-起始 - queryWrapper.ge(NumericUtil.tryParseLong(search.getCreateTimeStart()).compareTo(0L) > 0, AdminRolePO::getCreateTime, search.getCreateTimeStart()); - // 数据创建时间-截止 - queryWrapper.le(NumericUtil.tryParseLong(search.getCreateTimeEnd()).compareTo(0L) > 0, AdminRolePO::getCreateTime, search.getCreateTimeEnd()); - // 关键字 - if (StringUtil.isNotNullOrEmpty(search.getKeywords())) { - queryWrapper.and(q -> - q.like(AdminRolePO::getName, search.getKeywords()) - .or().like(AdminRolePO::getDescription, search.getKeywords()) - ); - } - - // 排序处理 - if (ListUtil.isNotNullOrEmpty(search.getOrderBy())) { - for (OrderByDTO item : search.getOrderBy()) { - EOrderBy orderBy = EOrderBy.getByValue(item.getOrderBy()); - // 顺序排序 - if (item.getIsAsc()) { - switch (orderBy) { - // 主键 - case ID: - queryWrapper.orderByAsc(AdminRolePO::getId); - break; - // 数据创建时间 - case CREATE_TIME: - queryWrapper.orderByAsc(AdminRolePO::getCreateTime); - break; - // 最后更新时间 - case UPDATE_TIME: - queryWrapper.orderByAsc(AdminRolePO::getUpdateTime); - break; - } - } else { - // 倒叙排序 - switch (orderBy) { - // 主键 - case ID: - queryWrapper.orderByDesc(AdminRolePO::getId); - break; - // 数据创建时间 - case CREATE_TIME: - queryWrapper.orderByDesc(AdminRolePO::getCreateTime); - break; - // 最后更新时间 - case UPDATE_TIME: - queryWrapper.orderByDesc(AdminRolePO::getUpdateTime); - break; - } - } - } - } else { - queryWrapper.orderByDesc(AdminRolePO::getId); - } - Page<AdminRolePO> pageResult = DB.selectPage(new Page<>(search.getPage(), search.getLimit()), queryWrapper); - return new PagerResult<>(pageResult.getSize(), pageResult.getCurrent(), pageResult.getTotal(), pageResult.getRecords()); - }} diff --git a/src/main/java/com/lunhan/xxx/repository/impl/AdminRoleMenuRelationMapperImpl.java b/src/main/java/com/lunhan/xxx/repository/impl/AdminRoleMenuRelationMapperImpl.java deleted file mode 100644 index 42cffb1..0000000 --- a/src/main/java/com/lunhan/xxx/repository/impl/AdminRoleMenuRelationMapperImpl.java +++ /dev/null @@ -1,144 +0,0 @@ -/** -# __----~~~~~~~~~~~------___ -# . . ~~//====...... __--~ ~~ -# -. \_|// |||\\ ~~~~~~::::... /~ -# ___-==_ _-~o~ \/ ||| \\ _/~~- -# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ -# _-~~ .=~ | \\-_ '-~7 /- / || \ / -# .~ .~ | \\ -_ / /- / || \ / -# / ____ / | \\ ~-_/ /|- _/ .|| \ / -# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ -# ' ~-| /| |-~\~~ __--~~ -# |-~~-_/ | | ~\_ _-~ /\ -# / \ \__ \/~ \__ -# _--~ _/ | .-~~____--~-/ ~~==. -# ((->/~ '.|||' -_| ~~-/ , . _|| -# -_ ~\ ~~---l__i__i__i--~~_/ -# _-~-__ ~) \--______________--~~ -# //.-~~~-~_--~- |-------~~~~~~~~ -# //.-~~~--\ -# 神兽保佑 -# 永无BUG! -*/ -package com.lunhan.xxx.repository.impl; - -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.lunhan.xxx.common.PagerResult; -import com.lunhan.xxx.common.enums.EYesOrNo; -import com.lunhan.xxx.common.util.ListUtil; -import com.lunhan.xxx.common.util.NumericUtil; -import com.lunhan.xxx.entity.dto.OrderByDTO; -import com.lunhan.xxx.entity.dto.SearchBasicDTO; -import com.lunhan.xxx.entity.enums.EOrderBy; -import com.lunhan.xxx.entity.search.SearchAdminRoleMenuRelation; -import com.lunhan.xxx.repository.BasicMapperImpl; -import com.lunhan.xxx.repository.mapper.AdminRoleMenuRelationMapper; -import com.lunhan.xxx.repository.po.AdminRoleMenuRelationPO; -import org.springframework.stereotype.Repository; - -import java.util.List; - -/** - * 后台角色菜单关系表 - * @author lin.liu - * @description 后台角色菜单关系表 - */ -@Repository -public class AdminRoleMenuRelationMapperImpl extends BasicMapperImpl<AdminRoleMenuRelationPO, AdminRoleMenuRelationMapper> { - AdminRoleMenuRelationMapperImpl(AdminRoleMenuRelationMapper mapper) { - super(mapper); - } - - @Override - public PagerResult<AdminRoleMenuRelationPO> search(SearchBasicDTO request) { - // 还原查询条件真实类型 - SearchAdminRoleMenuRelation search = (SearchAdminRoleMenuRelation)request; - // 查询条件 - LambdaQueryWrapper<AdminRoleMenuRelationPO> queryWrapper = this.query(); - // 非逻辑删除 - queryWrapper.eq(AdminRoleMenuRelationPO::getIsDelete, EYesOrNo.NO.getValue()); - // 状态 - //queryWrapper.eq(NumericUtil.tryParseInt(search.getStatus()).compareTo(0) > 0, AdminRoleMenuRelationPO::getStatus, search.getStatus()); - // 状态列表 - //queryWrapper.in(ListUtil.isNotNullOrEmpty(search.getListStatus()), AdminRoleMenuRelationPO::getStatus, search.getListStatus()); - - // 数据创建时间-起始 - queryWrapper.ge(NumericUtil.tryParseLong(search.getCreateTimeStart()).compareTo(0L) > 0, AdminRoleMenuRelationPO::getCreateTime, search.getCreateTimeStart()); - // 数据创建时间-截止 - queryWrapper.le(NumericUtil.tryParseLong(search.getCreateTimeEnd()).compareTo(0L) > 0, AdminRoleMenuRelationPO::getCreateTime, search.getCreateTimeEnd()); - // 关键字 - //if (StringUtil.isNotNullOrEmpty(search.getKeywords())) { - // queryWrapper.and(q -> - // q.like(AdminRoleMenuRelationPO::getName, search.getKeywords()) - // .or().like(AdminRoleMenuRelationPO::getPhone, search.getKeywords()) - // ); - //} - - // 排序处理 - if (ListUtil.isNotNullOrEmpty(search.getOrderBy())) { - for (OrderByDTO item : search.getOrderBy()) { - EOrderBy orderBy = EOrderBy.getByValue(item.getOrderBy()); - // 顺序排序 - if (item.getIsAsc()) { - switch (orderBy) { - // 主键 - case ID: - queryWrapper.orderByAsc(AdminRoleMenuRelationPO::getId); - break; - // 数据创建时间 - case CREATE_TIME: - queryWrapper.orderByAsc(AdminRoleMenuRelationPO::getCreateTime); - break; - // 最后更新时间 - case UPDATE_TIME: - queryWrapper.orderByAsc(AdminRoleMenuRelationPO::getUpdateTime); - break; - } - } else { - // 倒叙排序 - switch (orderBy) { - // 主键 - case ID: - queryWrapper.orderByDesc(AdminRoleMenuRelationPO::getId); - break; - // 数据创建时间 - case CREATE_TIME: - queryWrapper.orderByDesc(AdminRoleMenuRelationPO::getCreateTime); - break; - // 最后更新时间 - case UPDATE_TIME: - queryWrapper.orderByDesc(AdminRoleMenuRelationPO::getUpdateTime); - break; - } - } - } - } else { - queryWrapper.orderByDesc(AdminRoleMenuRelationPO::getId); - } - Page<AdminRoleMenuRelationPO> pageResult = DB.selectPage(new Page<>(search.getPage(), search.getLimit()), queryWrapper); - return new PagerResult<>(pageResult.getSize(), pageResult.getCurrent(), pageResult.getTotal(), pageResult.getRecords()); - } - - /** - * 根据角色id获取角色拥有的菜单列表 - * @param roleId 角色id - */ - public List<AdminRoleMenuRelationPO> list4Role(Long roleId) { - // 查询条件 - LambdaQueryWrapper<AdminRoleMenuRelationPO> queryWrapper = this.query(); - queryWrapper.eq(AdminRoleMenuRelationPO::getRoleId, roleId); - return DB.selectList(queryWrapper); - } - - /** - * 根据角色id获取角色拥有的菜单列表 - * @param listRoleId 角色id列表 - */ - public List<AdminRoleMenuRelationPO> list4Role(List<Long> listRoleId) { - // 查询条件 - LambdaQueryWrapper<AdminRoleMenuRelationPO> queryWrapper = this.query(); - queryWrapper.in(AdminRoleMenuRelationPO::getRoleId, listRoleId); - return DB.selectList(queryWrapper); - } -} diff --git a/src/main/java/com/lunhan/xxx/repository/impl/AdminRolePermissionRelationMapperImpl.java b/src/main/java/com/lunhan/xxx/repository/impl/AdminRolePermissionRelationMapperImpl.java deleted file mode 100644 index ede4a4f..0000000 --- a/src/main/java/com/lunhan/xxx/repository/impl/AdminRolePermissionRelationMapperImpl.java +++ /dev/null @@ -1,144 +0,0 @@ -/** -# __----~~~~~~~~~~~------___ -# . . ~~//====...... __--~ ~~ -# -. \_|// |||\\ ~~~~~~::::... /~ -# ___-==_ _-~o~ \/ ||| \\ _/~~- -# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ -# _-~~ .=~ | \\-_ '-~7 /- / || \ / -# .~ .~ | \\ -_ / /- / || \ / -# / ____ / | \\ ~-_/ /|- _/ .|| \ / -# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ -# ' ~-| /| |-~\~~ __--~~ -# |-~~-_/ | | ~\_ _-~ /\ -# / \ \__ \/~ \__ -# _--~ _/ | .-~~____--~-/ ~~==. -# ((->/~ '.|||' -_| ~~-/ , . _|| -# -_ ~\ ~~---l__i__i__i--~~_/ -# _-~-__ ~) \--______________--~~ -# //.-~~~-~_--~- |-------~~~~~~~~ -# //.-~~~--\ -# 神兽保佑 -# 永无BUG! -*/ -package com.lunhan.xxx.repository.impl; - -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.lunhan.xxx.common.PagerResult; -import com.lunhan.xxx.common.enums.EYesOrNo; -import com.lunhan.xxx.common.util.ListUtil; -import com.lunhan.xxx.common.util.NumericUtil; -import com.lunhan.xxx.entity.dto.OrderByDTO; -import com.lunhan.xxx.entity.dto.SearchBasicDTO; -import com.lunhan.xxx.entity.enums.EOrderBy; -import com.lunhan.xxx.entity.search.SearchAdminRolePermissionRelation; -import com.lunhan.xxx.repository.BasicMapperImpl; -import com.lunhan.xxx.repository.mapper.AdminRolePermissionRelationMapper; -import com.lunhan.xxx.repository.po.AdminRolePermissionRelationPO; -import org.springframework.stereotype.Repository; - -import java.util.List; - -/** - * 后台角色权限关系表 - * @author lin.liu - * @description 后台角色权限关系表 - */ -@Repository -public class AdminRolePermissionRelationMapperImpl extends BasicMapperImpl<AdminRolePermissionRelationPO, AdminRolePermissionRelationMapper> { - AdminRolePermissionRelationMapperImpl(AdminRolePermissionRelationMapper mapper) { - super(mapper); - } - - @Override - public PagerResult<AdminRolePermissionRelationPO> search(SearchBasicDTO request) { - // 还原查询条件真实类型 - SearchAdminRolePermissionRelation search = (SearchAdminRolePermissionRelation)request; - // 查询条件 - LambdaQueryWrapper<AdminRolePermissionRelationPO> queryWrapper = this.query(); - // 非逻辑删除 - queryWrapper.eq(AdminRolePermissionRelationPO::getIsDelete, EYesOrNo.NO.getValue()); - // 状态 - //queryWrapper.eq(NumericUtil.tryParseInt(search.getStatus()).compareTo(0) > 0, AdminRolePermissionRelationPO::getStatus, search.getStatus()); - // 状态列表 - //queryWrapper.in(ListUtil.isNotNullOrEmpty(search.getListStatus()), AdminRolePermissionRelationPO::getStatus, search.getListStatus()); - - // 数据创建时间-起始 - queryWrapper.ge(NumericUtil.tryParseLong(search.getCreateTimeStart()).compareTo(0L) > 0, AdminRolePermissionRelationPO::getCreateTime, search.getCreateTimeStart()); - // 数据创建时间-截止 - queryWrapper.le(NumericUtil.tryParseLong(search.getCreateTimeEnd()).compareTo(0L) > 0, AdminRolePermissionRelationPO::getCreateTime, search.getCreateTimeEnd()); - // 关键字 - //if (StringUtil.isNotNullOrEmpty(search.getKeywords())) { - // queryWrapper.and(q -> - // q.like(AdminRolePermissionRelationPO::getName, search.getKeywords()) - // .or().like(AdminRolePermissionRelationPO::getPhone, search.getKeywords()) - // ); - //} - - // 排序处理 - if (ListUtil.isNotNullOrEmpty(search.getOrderBy())) { - for (OrderByDTO item : search.getOrderBy()) { - EOrderBy orderBy = EOrderBy.getByValue(item.getOrderBy()); - // 顺序排序 - if (item.getIsAsc()) { - switch (orderBy) { - // 主键 - case ID: - queryWrapper.orderByAsc(AdminRolePermissionRelationPO::getId); - break; - // 数据创建时间 - case CREATE_TIME: - queryWrapper.orderByAsc(AdminRolePermissionRelationPO::getCreateTime); - break; - // 最后更新时间 - case UPDATE_TIME: - queryWrapper.orderByAsc(AdminRolePermissionRelationPO::getUpdateTime); - break; - } - } else { - // 倒叙排序 - switch (orderBy) { - // 主键 - case ID: - queryWrapper.orderByDesc(AdminRolePermissionRelationPO::getId); - break; - // 数据创建时间 - case CREATE_TIME: - queryWrapper.orderByDesc(AdminRolePermissionRelationPO::getCreateTime); - break; - // 最后更新时间 - case UPDATE_TIME: - queryWrapper.orderByDesc(AdminRolePermissionRelationPO::getUpdateTime); - break; - } - } - } - } else { - queryWrapper.orderByDesc(AdminRolePermissionRelationPO::getId); - } - Page<AdminRolePermissionRelationPO> pageResult = DB.selectPage(new Page<>(search.getPage(), search.getLimit()), queryWrapper); - return new PagerResult<>(pageResult.getSize(), pageResult.getCurrent(), pageResult.getTotal(), pageResult.getRecords()); - } - - /** - * 根据角色获取拥有的权限列表 - * @param roleId 角色id - */ - public List<AdminRolePermissionRelationPO> list4Role(Long roleId) { - // 查询条件 - LambdaQueryWrapper<AdminRolePermissionRelationPO> queryWrapper = this.query(); - queryWrapper.eq(AdminRolePermissionRelationPO::getRoleId, roleId); - return DB.selectList(queryWrapper); - } - - /** - * 根据角色获取拥有的权限列表 - * @param listRoleId 角色id列表 - */ - public List<AdminRolePermissionRelationPO> list4Role(List<Long> listRoleId) { - // 查询条件 - LambdaQueryWrapper<AdminRolePermissionRelationPO> queryWrapper = this.query(); - queryWrapper.in(AdminRolePermissionRelationPO::getRoleId, listRoleId); - return DB.selectList(queryWrapper); - } -} diff --git a/src/main/java/com/lunhan/xxx/repository/impl/AdminRoleRelationMapperImpl.java b/src/main/java/com/lunhan/xxx/repository/impl/AdminRoleRelationMapperImpl.java deleted file mode 100644 index da9ebc3..0000000 --- a/src/main/java/com/lunhan/xxx/repository/impl/AdminRoleRelationMapperImpl.java +++ /dev/null @@ -1,144 +0,0 @@ -/** -# __----~~~~~~~~~~~------___ -# . . ~~//====...... __--~ ~~ -# -. \_|// |||\\ ~~~~~~::::... /~ -# ___-==_ _-~o~ \/ ||| \\ _/~~- -# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ -# _-~~ .=~ | \\-_ '-~7 /- / || \ / -# .~ .~ | \\ -_ / /- / || \ / -# / ____ / | \\ ~-_/ /|- _/ .|| \ / -# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ -# ' ~-| /| |-~\~~ __--~~ -# |-~~-_/ | | ~\_ _-~ /\ -# / \ \__ \/~ \__ -# _--~ _/ | .-~~____--~-/ ~~==. -# ((->/~ '.|||' -_| ~~-/ , . _|| -# -_ ~\ ~~---l__i__i__i--~~_/ -# _-~-__ ~) \--______________--~~ -# //.-~~~-~_--~- |-------~~~~~~~~ -# //.-~~~--\ -# 神兽保佑 -# 永无BUG! -*/ -package com.lunhan.xxx.repository.impl; - -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.lunhan.xxx.common.PagerResult; -import com.lunhan.xxx.common.enums.EYesOrNo; -import com.lunhan.xxx.common.util.ListUtil; -import com.lunhan.xxx.common.util.NumericUtil; -import com.lunhan.xxx.entity.dto.OrderByDTO; -import com.lunhan.xxx.entity.dto.SearchBasicDTO; -import com.lunhan.xxx.entity.enums.EOrderBy; -import com.lunhan.xxx.entity.search.SearchAdminRoleRelation; -import com.lunhan.xxx.repository.BasicMapperImpl; -import com.lunhan.xxx.repository.mapper.AdminRoleRelationMapper; -import com.lunhan.xxx.repository.po.AdminRoleRelationPO; -import org.springframework.stereotype.Repository; - -import java.util.List; - -/** - * 后台用户和角色关系表 - * @author lin.liu - * @description 后台用户和角色关系表 - */ -@Repository -public class AdminRoleRelationMapperImpl extends BasicMapperImpl<AdminRoleRelationPO, AdminRoleRelationMapper> { - AdminRoleRelationMapperImpl(AdminRoleRelationMapper mapper) { - super(mapper); - } - - @Override - public PagerResult<AdminRoleRelationPO> search(SearchBasicDTO request) { - // 还原查询条件真实类型 - SearchAdminRoleRelation search = (SearchAdminRoleRelation)request; - // 查询条件 - LambdaQueryWrapper<AdminRoleRelationPO> queryWrapper = this.query(); - // 非逻辑删除 - queryWrapper.eq(AdminRoleRelationPO::getIsDelete, EYesOrNo.NO.getValue()); - // 状态 - //queryWrapper.eq(NumericUtil.tryParseInt(search.getStatus()).compareTo(0) > 0, AdminRoleRelationPO::getStatus, search.getStatus()); - // 状态列表 - //queryWrapper.in(ListUtil.isNotNullOrEmpty(search.getListStatus()), AdminRoleRelationPO::getStatus, search.getListStatus()); - - // 数据创建时间-起始 - queryWrapper.ge(NumericUtil.tryParseLong(search.getCreateTimeStart()).compareTo(0L) > 0, AdminRoleRelationPO::getCreateTime, search.getCreateTimeStart()); - // 数据创建时间-截止 - queryWrapper.le(NumericUtil.tryParseLong(search.getCreateTimeEnd()).compareTo(0L) > 0, AdminRoleRelationPO::getCreateTime, search.getCreateTimeEnd()); - // 关键字 - //if (StringUtil.isNotNullOrEmpty(search.getKeywords())) { - // queryWrapper.and(q -> - // q.like(AdminRoleRelationPO::getName, search.getKeywords()) - // .or().like(AdminRoleRelationPO::getPhone, search.getKeywords()) - // ); - //} - - // 排序处理 - if (ListUtil.isNotNullOrEmpty(search.getOrderBy())) { - for (OrderByDTO item : search.getOrderBy()) { - EOrderBy orderBy = EOrderBy.getByValue(item.getOrderBy()); - // 顺序排序 - if (item.getIsAsc()) { - switch (orderBy) { - // 主键 - case ID: - queryWrapper.orderByAsc(AdminRoleRelationPO::getId); - break; - // 数据创建时间 - case CREATE_TIME: - queryWrapper.orderByAsc(AdminRoleRelationPO::getCreateTime); - break; - // 最后更新时间 - case UPDATE_TIME: - queryWrapper.orderByAsc(AdminRoleRelationPO::getUpdateTime); - break; - } - } else { - // 倒叙排序 - switch (orderBy) { - // 主键 - case ID: - queryWrapper.orderByDesc(AdminRoleRelationPO::getId); - break; - // 数据创建时间 - case CREATE_TIME: - queryWrapper.orderByDesc(AdminRoleRelationPO::getCreateTime); - break; - // 最后更新时间 - case UPDATE_TIME: - queryWrapper.orderByDesc(AdminRoleRelationPO::getUpdateTime); - break; - } - } - } - } else { - queryWrapper.orderByDesc(AdminRoleRelationPO::getId); - } - Page<AdminRoleRelationPO> pageResult = DB.selectPage(new Page<>(search.getPage(), search.getLimit()), queryWrapper); - return new PagerResult<>(pageResult.getSize(), pageResult.getCurrent(), pageResult.getTotal(), pageResult.getRecords()); - } - - /** - * 根据管理员获取拥有的角色列表 - * @param adminId 管理员id - */ - public List<AdminRoleRelationPO> list4Admin(Long adminId) { - // 查询条件 - LambdaQueryWrapper<AdminRoleRelationPO> queryWrapper = this.query(); - queryWrapper.eq(AdminRoleRelationPO::getAdminId, adminId); - return DB.selectList(queryWrapper); - } - - /** - * 根据管理员获取拥有的角色列表 - * @param listAdminId 管理员id列表 - */ - public List<AdminRoleRelationPO> list4Admin(List<Long> listAdminId) { - // 查询条件 - LambdaQueryWrapper<AdminRoleRelationPO> queryWrapper = this.query(); - queryWrapper.in(AdminRoleRelationPO::getAdminId, listAdminId); - return DB.selectList(queryWrapper); - } -} diff --git a/src/main/java/com/lunhan/xxx/repository/impl/AdminUserMapperImpl.java b/src/main/java/com/lunhan/xxx/repository/impl/AdminUserMapperImpl.java deleted file mode 100644 index d1503af..0000000 --- a/src/main/java/com/lunhan/xxx/repository/impl/AdminUserMapperImpl.java +++ /dev/null @@ -1,134 +0,0 @@ -/** - * # __----~~~~~~~~~~~------___ - * # . . ~~//====...... __--~ ~~ - * # -. \_|// |||\\ ~~~~~~::::... /~ - * # ___-==_ _-~o~ \/ ||| \\ _/~~- - * # __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ - * # _-~~ .=~ | \\-_ '-~7 /- / || \ / - * # .~ .~ | \\ -_ / /- / || \ / - * # / ____ / | \\ ~-_/ /|- _/ .|| \ / - * # |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ - * # ' ~-| /| |-~\~~ __--~~ - * # |-~~-_/ | | ~\_ _-~ /\ - * # / \ \__ \/~ \__ - * # _--~ _/ | .-~~____--~-/ ~~==. - * # ((->/~ '.|||' -_| ~~-/ , . _|| - * # -_ ~\ ~~---l__i__i__i--~~_/ - * # _-~-__ ~) \--______________--~~ - * # //.-~~~-~_--~- |-------~~~~~~~~ - * # //.-~~~--\ - * # 神兽保佑 - * # 永无BUG! - */ -package com.lunhan.xxx.repository.impl; - -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.lunhan.xxx.common.PagerResult; -import com.lunhan.xxx.common.enums.EYesOrNo; -import com.lunhan.xxx.common.util.ListUtil; -import com.lunhan.xxx.common.util.NumericUtil; -import com.lunhan.xxx.common.util.StringUtil; -import com.lunhan.xxx.entity.dto.OrderByDTO; -import com.lunhan.xxx.entity.dto.SearchBasicDTO; -import com.lunhan.xxx.entity.enums.EOrderBy; -import com.lunhan.xxx.entity.search.SearchAdminUser; -import com.lunhan.xxx.repository.BasicMapperImpl; -import com.lunhan.xxx.repository.mapper.AdminUserMapper; -import com.lunhan.xxx.repository.po.AdminUserPO; -import org.springframework.stereotype.Repository; - -/** - * 管理员帐号 - * @author lin.liu - * @description 管理员帐号 - */ -@Repository -public class AdminUserMapperImpl extends BasicMapperImpl<AdminUserPO, AdminUserMapper> { - AdminUserMapperImpl(AdminUserMapper mapper) { - super(mapper); - } - - @Override - public PagerResult<AdminUserPO> search(SearchBasicDTO request) { - // 还原查询条件真实类型 - SearchAdminUser search = (SearchAdminUser) request; - // 查询条件 - LambdaQueryWrapper<AdminUserPO> queryWrapper = this.query(); - // 非逻辑删除 - queryWrapper.eq(AdminUserPO::getIsDelete, EYesOrNo.NO.getValue()); - // 状态 - //queryWrapper.eq(NumericUtil.tryParseInt(search.getStatus()).compareTo(0) > 0, AdminUserPO::getStatus, search.getStatus()); - // 状态列表 - //queryWrapper.in(ListUtil.isNotNullOrEmpty(search.getListStatus()), AdminUserPO::getStatus, search.getListStatus()); - - // 数据创建时间-起始 - queryWrapper.ge(NumericUtil.tryParseLong(search.getCreateTimeStart()).compareTo(0L) > 0, AdminUserPO::getCreateTime, search.getCreateTimeStart()); - // 数据创建时间-截止 - queryWrapper.le(NumericUtil.tryParseLong(search.getCreateTimeEnd()).compareTo(0L) > 0, AdminUserPO::getCreateTime, search.getCreateTimeEnd()); - // 关键字 - if (StringUtil.isNotNullOrEmpty(search.getKeywords())) { - queryWrapper.and(q -> - q.like(AdminUserPO::getUserName, search.getKeywords()) - .or().like(AdminUserPO::getNickName, search.getKeywords()) - .or().like(AdminUserPO::getContact, search.getKeywords()) - .or().like(AdminUserPO::getEmail, search.getKeywords()) - ); - } - - // 排序处理 - if (ListUtil.isNotNullOrEmpty(search.getOrderBy())) { - for (OrderByDTO item : search.getOrderBy()) { - EOrderBy orderBy = EOrderBy.getByValue(item.getOrderBy()); - // 顺序排序 - if (item.getIsAsc()) { - switch (orderBy) { - // 主键 - case ID: - queryWrapper.orderByAsc(AdminUserPO::getId); - break; - // 数据创建时间 - case CREATE_TIME: - queryWrapper.orderByAsc(AdminUserPO::getCreateTime); - break; - // 最后更新时间 - case UPDATE_TIME: - queryWrapper.orderByAsc(AdminUserPO::getUpdateTime); - break; - } - } else { - // 倒叙排序 - switch (orderBy) { - // 主键 - case ID: - queryWrapper.orderByDesc(AdminUserPO::getId); - break; - // 数据创建时间 - case CREATE_TIME: - queryWrapper.orderByDesc(AdminUserPO::getCreateTime); - break; - // 最后更新时间 - case UPDATE_TIME: - queryWrapper.orderByDesc(AdminUserPO::getUpdateTime); - break; - } - } - } - } else { - queryWrapper.orderByDesc(AdminUserPO::getId); - } - Page<AdminUserPO> pageResult = DB.selectPage(new Page<>(search.getPage(), search.getLimit()), queryWrapper); - return new PagerResult<>(pageResult.getSize(), pageResult.getCurrent(), pageResult.getTotal(), pageResult.getRecords()); - } - - /** - * 根据用户名获取管理端用户 - * @param userName 用户名 - */ - public AdminUserPO get4Name(String userName) { - // 查询条件 - LambdaQueryWrapper<AdminUserPO> queryWrapper = this.query(); - queryWrapper.eq(AdminUserPO::getUserName, userName); - return DB.selectOne(queryWrapper); - } -} diff --git a/src/main/java/com/lunhan/xxx/repository/impl/NoticeMapperImpl.java b/src/main/java/com/lunhan/xxx/repository/impl/NoticeMapperImpl.java deleted file mode 100644 index 02dc359..0000000 --- a/src/main/java/com/lunhan/xxx/repository/impl/NoticeMapperImpl.java +++ /dev/null @@ -1,122 +0,0 @@ -/** -# __----~~~~~~~~~~~------___ -# . . ~~//====...... __--~ ~~ -# -. \_|// |||\\ ~~~~~~::::... /~ -# ___-==_ _-~o~ \/ ||| \\ _/~~- -# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ -# _-~~ .=~ | \\-_ '-~7 /- / || \ / -# .~ .~ | \\ -_ / /- / || \ / -# / ____ / | \\ ~-_/ /|- _/ .|| \ / -# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ -# ' ~-| /| |-~\~~ __--~~ -# |-~~-_/ | | ~\_ _-~ /\ -# / \ \__ \/~ \__ -# _--~ _/ | .-~~____--~-/ ~~==. -# ((->/~ '.|||' -_| ~~-/ , . _|| -# -_ ~\ ~~---l__i__i__i--~~_/ -# _-~-__ ~) \--______________--~~ -# //.-~~~-~_--~- |-------~~~~~~~~ -# //.-~~~--\ -# 神兽保佑 -# 永无BUG! -*/ -package com.lunhan.xxx.repository.impl; - -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.lunhan.xxx.common.PagerResult; -import com.lunhan.xxx.common.enums.EYesOrNo; -import com.lunhan.xxx.common.util.ListUtil; -import com.lunhan.xxx.common.util.NumericUtil; -import com.lunhan.xxx.entity.dto.OrderByDTO; -import com.lunhan.xxx.entity.dto.SearchBasicDTO; -import com.lunhan.xxx.entity.enums.EOrderBy; -import com.lunhan.xxx.entity.search.SearchNotice; -import com.lunhan.xxx.repository.BasicMapperImpl; -import com.lunhan.xxx.repository.mapper.NoticeMapper; -import com.lunhan.xxx.repository.po.NoticePO; -import org.springframework.stereotype.Repository; - -import java.util.ArrayList; - -/** - * 公告 - * @author lin.liu - * @description 公告 - */ -@Repository -public class NoticeMapperImpl extends BasicMapperImpl<NoticePO, NoticeMapper> { - NoticeMapperImpl(NoticeMapper mapper) { - super(mapper); - } - - @Override - public PagerResult<NoticePO> search(SearchBasicDTO request) { - // 还原查询条件真实类型 - SearchNotice search = (SearchNotice)request; - // 查询条件 - LambdaQueryWrapper<NoticePO> queryWrapper = this.query(); - // 非逻辑删除 - queryWrapper.eq(NoticePO::getIsDelete, EYesOrNo.NO.getValue()); - // 状态 - //queryWrapper.eq(NumericUtil.tryParseInt(search.getStatus()).compareTo(0) > 0, NoticePO::getStatus, search.getStatus()); - // 状态列表 - //queryWrapper.in(ListUtil.isNotNullOrEmpty(search.getListStatus()), NoticePO::getStatus, search.getListStatus()); - - // 数据创建时间-起始 - queryWrapper.ge(NumericUtil.tryParseLong(search.getCreateTimeStart()).compareTo(0L) > 0, NoticePO::getCreateTime, search.getCreateTimeStart()); - // 数据创建时间-截止 - queryWrapper.le(NumericUtil.tryParseLong(search.getCreateTimeEnd()).compareTo(0L) > 0, NoticePO::getCreateTime, search.getCreateTimeEnd()); - // 关键字 - //if (StringUtil.isNotNullOrEmpty(search.getKeywords())) { - // queryWrapper.and(q -> - // q.like(NoticePO::getName, search.getKeywords()) - // .or().like(NoticePO::getPhone, search.getKeywords()) - // ); - //} - - // 排序处理 - if (ListUtil.isNotNullOrEmpty(search.getOrderBy())) { - for (OrderByDTO item : search.getOrderBy()) { - EOrderBy orderBy = EOrderBy.getByValue(item.getOrderBy()); - // 顺序排序 - if (item.getIsAsc()) { - switch (orderBy) { - // 主键 - case ID: - queryWrapper.orderByAsc(NoticePO::getId); - break; - // 数据创建时间 - case CREATE_TIME: - queryWrapper.orderByAsc(NoticePO::getCreateTime); - break; - // 最后更新时间 - case UPDATE_TIME: - queryWrapper.orderByAsc(NoticePO::getUpdateTime); - break; - } - } else { - // 倒叙排序 - switch (orderBy) { - // 主键 - case ID: - queryWrapper.orderByDesc(NoticePO::getId); - break; - // 数据创建时间 - case CREATE_TIME: - queryWrapper.orderByDesc(NoticePO::getCreateTime); - break; - // 最后更新时间 - case UPDATE_TIME: - queryWrapper.orderByDesc(NoticePO::getUpdateTime); - break; - } - } - } - } else { - queryWrapper.orderByDesc(NoticePO::getId); - } - return new PagerResult<>(search.getLimit(), search.getPage(), 0L, new ArrayList<>()); -// DB.selectCount() -// Page<NoticeBO> pageResult = DB.selectObjs(new Page<>(search.getPage(), search.getLimit()), queryWrapper); -// return new PagerResult<>(pageResult.getSize(), pageResult.getCurrent(), pageResult.getTotal(), pageResult.getRecords()); - }} diff --git a/src/main/java/com/lunhan/xxx/repository/impl/QuartzTaskErrorMapperImpl.java b/src/main/java/com/lunhan/xxx/repository/impl/QuartzTaskErrorMapperImpl.java deleted file mode 100644 index bbfd6bf..0000000 --- a/src/main/java/com/lunhan/xxx/repository/impl/QuartzTaskErrorMapperImpl.java +++ /dev/null @@ -1,115 +0,0 @@ -package com.lunhan.xxx.repository.impl; - -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.lunhan.xxx.common.PagerResult; -import com.lunhan.xxx.common.enums.EYesOrNo; -import com.lunhan.xxx.common.util.ListUtil; -import com.lunhan.xxx.common.util.NumericUtil; -import com.lunhan.xxx.entity.dto.OrderByDTO; -import com.lunhan.xxx.entity.dto.SearchBasicDTO; -import com.lunhan.xxx.entity.enums.EOrderBy; -import com.lunhan.xxx.entity.search.SearchQuartzTaskError; -import com.lunhan.xxx.repository.BasicMapperImpl; -import com.lunhan.xxx.repository.mapper.QuartzTaskErrorMapper; -import com.lunhan.xxx.repository.po.QuartzTaskErrorPO; -import org.springframework.stereotype.Repository; - -/** - * 定时任务错误信息表 - * @author lin.liu - * @description 定时任务错误信息表 - */ -@Repository -public class QuartzTaskErrorMapperImpl extends BasicMapperImpl<QuartzTaskErrorPO, QuartzTaskErrorMapper> { - public QuartzTaskErrorMapperImpl(QuartzTaskErrorMapper mapper) { - super(mapper); - } - - /** - * 分页查询 - * - * @param request 请求参数 - */ - @Override - public PagerResult<QuartzTaskErrorPO> search(SearchBasicDTO request) { - // 查询条件类型还原 - SearchQuartzTaskError search = (SearchQuartzTaskError)request; - - LambdaQueryWrapper<QuartzTaskErrorPO> queryWrapper = this.query(); - // 状态非逻辑删除 - queryWrapper.eq(QuartzTaskErrorPO::getIsDelete, EYesOrNo.NO.getValue()); - // 状态 - //queryWrapper.eq(NumericUtil.tryParseInt(search.getStatus()).compareTo(0) > 0, QuartzTaskErrorPO::getState, search.getStatus()); - // 状态列表 - //queryWrapper.in(ListUtil.isNotNullOrEmpty(search.getListStatus()), QuartzTaskErrorPO::getState, search.getListStatus()); - // 数据创建时间-起始 - queryWrapper.ge(NumericUtil.tryParseLong(search.getCreateTimeStart()).compareTo(0L) > 0, QuartzTaskErrorPO::getCreateTime, search.getCreateTimeStart()); - // 数据创建时间-截止 - queryWrapper.le(NumericUtil.tryParseLong(search.getCreateTimeEnd()).compareTo(0L) > 0, QuartzTaskErrorPO::getCreateTime, search.getCreateTimeEnd()); - // 关键字 - //if (StringUtil.isNotNullOrEmpty(search.getKeywords())) { - // queryWrapper.and(q -> - // q.like(QuartzTaskErrorPO::getRealName, search.getKeywords()) - // .or().like(QuartzTaskErrorPO::getContactPhone, search.getKeywords()) - // ); - //} - // 排序处理 - if (ListUtil.isNotNullOrEmpty(search.getOrderBy())) { - for (OrderByDTO item : search.getOrderBy()) { - EOrderBy orderBy = EOrderBy.getByValue(item.getOrderBy()); - // 顺序排序 - if (item.getIsAsc()) { - switch (orderBy) { - // 主键 - case ID: - queryWrapper.orderByAsc(QuartzTaskErrorPO::getId); - break; - // 数据创建时间 - case CREATE_TIME: - queryWrapper.orderByAsc(QuartzTaskErrorPO::getCreateTime); - break; - // 最后更新时间 - case UPDATE_TIME: - queryWrapper.orderByAsc(QuartzTaskErrorPO::getUpdateTime); - break; - } - } else { - // 倒叙排序 - switch (orderBy) { - // 主键 - case ID: - queryWrapper.orderByAsc(QuartzTaskErrorPO::getId); - break; - // 数据创建时间 - case CREATE_TIME: - queryWrapper.orderByAsc(QuartzTaskErrorPO::getCreateTime); - break; - // 最后更新时间 - case UPDATE_TIME: - queryWrapper.orderByAsc(QuartzTaskErrorPO::getUpdateTime); - break; - } - } - } - } else { - queryWrapper.orderByDesc(QuartzTaskErrorPO::getId); - } - Page<QuartzTaskErrorPO> pageResult = DB.selectPage(new Page<>(search.getPage(), search.getLimit()), queryWrapper); - return new PagerResult<>(pageResult.getSize(), pageResult.getCurrent(), pageResult.getTotal(), pageResult.getRecords()); - } - - public QuartzTaskErrorPO get4RecordId(String recordId) { - LambdaQueryWrapper<QuartzTaskErrorPO> queryWrapper = this.query(); - // 执行记录编号 - queryWrapper.eq(QuartzTaskErrorPO::getTaskExecuteRecordId, recordId); - return DB.selectOne(queryWrapper); - } - - public int clear4DateTime(long time) { - LambdaQueryWrapper<QuartzTaskErrorPO> query = this.query(); - query.lt(QuartzTaskErrorPO::getCreateTime, time); - return DB.delete(query); - - } -} diff --git a/src/main/java/com/lunhan/xxx/repository/impl/QuartzTaskInfoMapperImpl.java b/src/main/java/com/lunhan/xxx/repository/impl/QuartzTaskInfoMapperImpl.java deleted file mode 100644 index 490fc59..0000000 --- a/src/main/java/com/lunhan/xxx/repository/impl/QuartzTaskInfoMapperImpl.java +++ /dev/null @@ -1,120 +0,0 @@ -package com.lunhan.xxx.repository.impl; - -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.lunhan.xxx.common.PagerResult; -import com.lunhan.xxx.common.enums.EYesOrNo; -import com.lunhan.xxx.common.util.ListUtil; -import com.lunhan.xxx.common.util.NumericUtil; -import com.lunhan.xxx.common.util.StringUtil; -import com.lunhan.xxx.entity.dto.OrderByDTO; -import com.lunhan.xxx.entity.dto.SearchBasicDTO; -import com.lunhan.xxx.entity.enums.EOrderBy; -import com.lunhan.xxx.entity.search.SearchQuartzTaskInfo; -import com.lunhan.xxx.repository.BasicMapperImpl; -import com.lunhan.xxx.repository.mapper.QuartzTaskInfoMapper; -import com.lunhan.xxx.repository.po.QuartzTaskInfoPO; -import org.springframework.stereotype.Repository; - -import java.util.List; - -/** - * 定时任务信息表 - * - * @author lin.liu - * @description 定时任务信息表 - */ -@Repository -public class QuartzTaskInfoMapperImpl extends BasicMapperImpl<QuartzTaskInfoPO, QuartzTaskInfoMapper> { - public QuartzTaskInfoMapperImpl(QuartzTaskInfoMapper mapper) { - super(mapper); - } - - /** - * 分页查询 - * - * @param request 请求参数 - */ - @Override - public PagerResult<QuartzTaskInfoPO> search(SearchBasicDTO request) { - // 查询条件类型还原 - SearchQuartzTaskInfo search = (SearchQuartzTaskInfo) request; - - LambdaQueryWrapper<QuartzTaskInfoPO> queryWrapper = this.query(); - // 状态非逻辑删除 - queryWrapper.eq(QuartzTaskInfoPO::getIsDelete, EYesOrNo.NO.getValue()); - // 状态 - queryWrapper.eq(NumericUtil.tryParseInt(search.getStatus()).compareTo(0) > 0, QuartzTaskInfoPO::getStatus, search.getStatus()); - // 状态列表 - queryWrapper.in(ListUtil.isNotNullOrEmpty(search.getListStatus()), QuartzTaskInfoPO::getStatus, search.getListStatus()); - // 任务编号 - queryWrapper.eq(StringUtil.isNotNullOrEmpty(search.getTaskNo()), QuartzTaskInfoPO::getTaskNo, search.getTaskNo()); - // 数据创建时间-起始 - queryWrapper.ge(NumericUtil.tryParseLong(search.getCreateTimeStart()).compareTo(0L) > 0, QuartzTaskInfoPO::getCreateTime, search.getCreateTimeStart()); - // 数据创建时间-截止 - queryWrapper.le(NumericUtil.tryParseLong(search.getCreateTimeEnd()).compareTo(0L) > 0, QuartzTaskInfoPO::getCreateTime, search.getCreateTimeEnd()); - // 关键字 - if (StringUtil.isNotNullOrEmpty(search.getKeywords())) { - queryWrapper.like(QuartzTaskInfoPO::getTaskName, search.getKeywords()); - } - // 排序处理 - if (ListUtil.isNotNullOrEmpty(search.getOrderBy())) { - for (OrderByDTO item : search.getOrderBy()) { - EOrderBy orderBy = EOrderBy.getByValue(item.getOrderBy()); - // 顺序排序 - if (item.getIsAsc()) { - switch (orderBy) { - // 主键 - case ID: - queryWrapper.orderByAsc(QuartzTaskInfoPO::getId); - break; - // 数据创建时间 - case CREATE_TIME: - queryWrapper.orderByAsc(QuartzTaskInfoPO::getCreateTime); - break; - // 最后更新时间 - case UPDATE_TIME: - queryWrapper.orderByAsc(QuartzTaskInfoPO::getUpdateTime); - break; - } - } else { - // 倒叙排序 - switch (orderBy) { - // 主键 - case ID: - queryWrapper.orderByAsc(QuartzTaskInfoPO::getId); - break; - // 数据创建时间 - case CREATE_TIME: - queryWrapper.orderByAsc(QuartzTaskInfoPO::getCreateTime); - break; - // 最后更新时间 - case UPDATE_TIME: - queryWrapper.orderByAsc(QuartzTaskInfoPO::getUpdateTime); - break; - } - } - } - } else { - queryWrapper.orderByDesc(QuartzTaskInfoPO::getId); - } - Page<QuartzTaskInfoPO> pageResult = DB.selectPage(new Page<>(search.getPage(), search.getLimit()), queryWrapper); - return new PagerResult<>(pageResult.getSize(), pageResult.getCurrent(), pageResult.getTotal(), pageResult.getRecords()); - } - - public List<QuartzTaskInfoPO> list4Status(Integer status) { - LambdaQueryWrapper<QuartzTaskInfoPO> queryWrapper = this.query(); - // 非逻辑删除 - queryWrapper.eq(QuartzTaskInfoPO::getIsDelete, EYesOrNo.NO.getValue()); - // 状态 - queryWrapper.eq(QuartzTaskInfoPO::getStatus, status); - return DB.selectList(queryWrapper); - } - - public QuartzTaskInfoPO get4No(String taskNo) { - LambdaQueryWrapper<QuartzTaskInfoPO> queryWrapper = this.query(); - // 任务编号 - queryWrapper.eq(QuartzTaskInfoPO::getTaskNo, taskNo); - return DB.selectOne(queryWrapper); - } -} diff --git a/src/main/java/com/lunhan/xxx/repository/impl/QuartzTaskRecordMapperImpl.java b/src/main/java/com/lunhan/xxx/repository/impl/QuartzTaskRecordMapperImpl.java deleted file mode 100644 index 314ffa3..0000000 --- a/src/main/java/com/lunhan/xxx/repository/impl/QuartzTaskRecordMapperImpl.java +++ /dev/null @@ -1,114 +0,0 @@ -package com.lunhan.xxx.repository.impl; - -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.lunhan.xxx.common.PagerResult; -import com.lunhan.xxx.common.enums.EYesOrNo; -import com.lunhan.xxx.common.util.ListUtil; -import com.lunhan.xxx.common.util.NumericUtil; -import com.lunhan.xxx.common.util.StringUtil; -import com.lunhan.xxx.entity.dto.OrderByDTO; -import com.lunhan.xxx.entity.dto.SearchBasicDTO; -import com.lunhan.xxx.entity.enums.EOrderBy; -import com.lunhan.xxx.entity.search.SearchQuartzTaskRecord; -import com.lunhan.xxx.repository.BasicMapperImpl; -import com.lunhan.xxx.repository.mapper.QuartzTaskRecordMapper; -import com.lunhan.xxx.repository.po.QuartzTaskRecordPO; -import org.springframework.stereotype.Repository; - -/** - * 定时任务执行情况记录表 - * @author lin.liu - * @description 定时任务执行情况记录表 - */ -@Repository -public class QuartzTaskRecordMapperImpl extends BasicMapperImpl<QuartzTaskRecordPO, QuartzTaskRecordMapper> { - public QuartzTaskRecordMapperImpl(QuartzTaskRecordMapper mapper) { - super(mapper); - } - - /** - * 分页查询 - * - * @param request 请求参数 - */ - @Override - public PagerResult<QuartzTaskRecordPO> search(SearchBasicDTO request) { - // 查询条件类型还原 - SearchQuartzTaskRecord search = (SearchQuartzTaskRecord)request; - - LambdaQueryWrapper<QuartzTaskRecordPO> queryWrapper = this.query(); - // 状态非逻辑删除 - queryWrapper.eq(QuartzTaskRecordPO::getIsDelete, EYesOrNo.NO.getValue()); - // 状态 - queryWrapper.eq(NumericUtil.tryParseInt(search.getStatus()).compareTo(0) > 0, QuartzTaskRecordPO::getTaskStatus, search.getStatus()); - // 状态列表 - queryWrapper.in(ListUtil.isNotNullOrEmpty(search.getListStatus()), QuartzTaskRecordPO::getTaskStatus, search.getListStatus()); - // 数据创建时间-起始 - queryWrapper.ge(NumericUtil.tryParseLong(search.getCreateTimeStart()).compareTo(0L) > 0, QuartzTaskRecordPO::getCreateTime, search.getCreateTimeStart()); - // 数据创建时间-截止 - queryWrapper.le(NumericUtil.tryParseLong(search.getCreateTimeEnd()).compareTo(0L) > 0, QuartzTaskRecordPO::getCreateTime, search.getCreateTimeEnd()); - // 任务编号 - queryWrapper.eq(StringUtil.isNotNullOrEmpty(search.getTaskNo()), QuartzTaskRecordPO::getTaskNo, search.getTaskNo()); - // 执行时间-起始 - queryWrapper.ge(NumericUtil.tryParseLong(search.getExecuteTimeStart()).compareTo(0L) > 0, QuartzTaskRecordPO::getStartTime, search.getExecuteTimeStart()); - // 执行时间-截止 - queryWrapper.le(NumericUtil.tryParseLong(search.getExecuteTimeEnd()).compareTo(0L) > 0, QuartzTaskRecordPO::getStartTime, search.getExecuteTimeEnd()); - // 关键字 - //if (StringUtil.isNotNullOrEmpty(search.getKeywords())) { - // queryWrapper.and(q -> - // q.like(QuartzTaskRecordPO::getRealName, search.getKeywords()) - // .or().like(QuartzTaskRecordPO::getContactPhone, search.getKeywords()) - // ); - //} - // 排序处理 - if (ListUtil.isNotNullOrEmpty(search.getOrderBy())) { - for (OrderByDTO item : search.getOrderBy()) { - EOrderBy orderBy = EOrderBy.getByValue(item.getOrderBy()); - // 顺序排序 - if (item.getIsAsc()) { - switch (orderBy) { - // 主键 - case ID: - queryWrapper.orderByAsc(QuartzTaskRecordPO::getId); - break; - // 数据创建时间 - case CREATE_TIME: - queryWrapper.orderByAsc(QuartzTaskRecordPO::getCreateTime); - break; - // 最后更新时间 - case UPDATE_TIME: - queryWrapper.orderByAsc(QuartzTaskRecordPO::getUpdateTime); - break; - } - } else { - // 倒叙排序 - switch (orderBy) { - // 主键 - case ID: - queryWrapper.orderByAsc(QuartzTaskRecordPO::getId); - break; - // 数据创建时间 - case CREATE_TIME: - queryWrapper.orderByAsc(QuartzTaskRecordPO::getCreateTime); - break; - // 最后更新时间 - case UPDATE_TIME: - queryWrapper.orderByAsc(QuartzTaskRecordPO::getUpdateTime); - break; - } - } - } - } else { - queryWrapper.orderByDesc(QuartzTaskRecordPO::getId); - } - Page<QuartzTaskRecordPO> pageResult = DB.selectPage(new Page<>(search.getPage(), search.getLimit()), queryWrapper); - return new PagerResult<>(pageResult.getSize(), pageResult.getCurrent(), pageResult.getTotal(), pageResult.getRecords()); - } - - public int clear4DateTime(long time) { - LambdaQueryWrapper<QuartzTaskRecordPO> query = this.query(); - query.lt(QuartzTaskRecordPO::getCreateTime, time); - return DB.delete(query); - } -} diff --git a/src/main/java/com/lunhan/xxx/repository/impl/SysDictDataMapperImpl.java b/src/main/java/com/lunhan/xxx/repository/impl/SysDictDataMapperImpl.java deleted file mode 100644 index 43f3ef0..0000000 --- a/src/main/java/com/lunhan/xxx/repository/impl/SysDictDataMapperImpl.java +++ /dev/null @@ -1,187 +0,0 @@ -/** -# __----~~~~~~~~~~~------___ -# . . ~~//====...... __--~ ~~ -# -. \_|// |||\\ ~~~~~~::::... /~ -# ___-==_ _-~o~ \/ ||| \\ _/~~- -# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ -# _-~~ .=~ | \\-_ '-~7 /- / || \ / -# .~ .~ | \\ -_ / /- / || \ / -# / ____ / | \\ ~-_/ /|- _/ .|| \ / -# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ -# ' ~-| /| |-~\~~ __--~~ -# |-~~-_/ | | ~\_ _-~ /\ -# / \ \__ \/~ \__ -# _--~ _/ | .-~~____--~-/ ~~==. -# ((->/~ '.|||' -_| ~~-/ , . _|| -# -_ ~\ ~~---l__i__i__i--~~_/ -# _-~-__ ~) \--______________--~~ -# //.-~~~-~_--~- |-------~~~~~~~~ -# //.-~~~--\ -# 神兽保佑 -# 永无BUG! -*/ -package com.lunhan.xxx.repository.impl; - -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.lunhan.xxx.common.PagerResult; -import com.lunhan.xxx.common.util.ListUtil; -import com.lunhan.xxx.common.util.NumericUtil; -import com.lunhan.xxx.common.util.StringUtil; -import com.lunhan.xxx.entity.dto.OrderByDTO; -import com.lunhan.xxx.entity.dto.SearchBasicDTO; -import com.lunhan.xxx.entity.enums.EOrderBy; -import com.lunhan.xxx.entity.search.SearchSysDictData; -import com.lunhan.xxx.repository.BasicMapperImpl; -import com.lunhan.xxx.repository.mapper.SysDictDataMapper; -import com.lunhan.xxx.repository.po.SysDictDataPO; -import org.springframework.stereotype.Repository; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -/** - * 字典数据表 - * @author lin.liu - * @description 字典数据表 - */ -@Repository -public class SysDictDataMapperImpl extends BasicMapperImpl<SysDictDataPO, SysDictDataMapper> { - SysDictDataMapperImpl(SysDictDataMapper mapper) { - super(mapper); - } - - @Override - public PagerResult<SysDictDataPO> search(SearchBasicDTO request) { - // 还原查询条件真实类型 - SearchSysDictData search = (SearchSysDictData)request; - // 查询条件 - LambdaQueryWrapper<SysDictDataPO> queryWrapper = this.query(); - // 状态 - queryWrapper.eq(NumericUtil.tryParseInt(search.getStatus()).compareTo(0) > 0, SysDictDataPO::getStatus, search.getStatus()); - // 状态列表 - queryWrapper.in(ListUtil.isNotNullOrEmpty(search.getListStatus()), SysDictDataPO::getStatus, search.getListStatus()); - - // 数据创建时间-起始 - queryWrapper.ge(NumericUtil.tryParseLong(search.getCreateTimeStart()).compareTo(0L) > 0, SysDictDataPO::getCreateTime, search.getCreateTimeStart()); - // 数据创建时间-截止 - queryWrapper.le(NumericUtil.tryParseLong(search.getCreateTimeEnd()).compareTo(0L) > 0, SysDictDataPO::getCreateTime, search.getCreateTimeEnd()); - // 关键字 - if (StringUtil.isNotNullOrEmpty(search.getKeywords())) { - queryWrapper.like(SysDictDataPO::getDictLabel, search.getKeywords()); - } - - // 排序处理 - if (ListUtil.isNotNullOrEmpty(search.getOrderBy())) { - for (OrderByDTO item : search.getOrderBy()) { - EOrderBy orderBy = EOrderBy.getByValue(item.getOrderBy()); - // 顺序排序 - if (item.getIsAsc()) { - switch (orderBy) { - // 主键 - case ID: - queryWrapper.orderByAsc(SysDictDataPO::getId); - break; - // 数据创建时间 - case CREATE_TIME: - queryWrapper.orderByAsc(SysDictDataPO::getCreateTime); - break; - // 最后更新时间 - case UPDATE_TIME: - queryWrapper.orderByAsc(SysDictDataPO::getUpdateTime); - break; - } - } else { - // 倒叙排序 - switch (orderBy) { - // 主键 - case ID: - queryWrapper.orderByDesc(SysDictDataPO::getId); - break; - // 数据创建时间 - case CREATE_TIME: - queryWrapper.orderByDesc(SysDictDataPO::getCreateTime); - break; - // 最后更新时间 - case UPDATE_TIME: - queryWrapper.orderByDesc(SysDictDataPO::getUpdateTime); - break; - } - } - } - } else { - queryWrapper.orderByDesc(SysDictDataPO::getId); - } - Page<SysDictDataPO> pageResult = super.selectPage(new Page<>(search.getPage(), search.getLimit()), queryWrapper); - return new PagerResult<>(pageResult.getSize(), pageResult.getCurrent(), pageResult.getTotal(), pageResult.getRecords()); - } - - public Boolean add(SysDictDataPO item) { - int rowCount = super.insert(item); - return rowCount == 1; - } - /** - * 根据type获取数据列表 - * @param type 类型 - */ - public List<SysDictDataPO> getListByType(String type) { - LambdaQueryWrapper<SysDictDataPO> queryWrapper = this.query(); - queryWrapper.eq(SysDictDataPO::getDictType, type); - return DB.selectList(queryWrapper); - } - public Long count4Type(String type) { - LambdaQueryWrapper<SysDictDataPO> queryWrapper = this.query(); - queryWrapper.eq(SysDictDataPO::getDictType, type); - return DB.getCount(queryWrapper); - } - public List<String> findExists4Type(List<String> listType) { - LambdaQueryWrapper<SysDictDataPO> queryWrapper = this.query(); - queryWrapper.select(SysDictDataPO.class, c -> c.getColumn().equals("dict_type")); - queryWrapper.in(SysDictDataPO::getDictType, listType); - List<Map<String, Object>> result = DB.selectMaps(queryWrapper); - return result.stream().map(c -> c.get("dict_type").toString()).distinct().collect(Collectors.toList()); - } - - public Boolean addNotIncrement(SysDictDataPO item) { - int rowCount = super.insert(item); - return rowCount == 1; - } - - public SysDictDataPO getById(Long id) { - return super.get(id); - } - - public List<SysDictDataPO> getListById(List<Long> listId) { - return super.getList(listId); - } - - public List<SysDictDataPO> listByType(List<String> listType) { - LambdaQueryWrapper<SysDictDataPO> queryWrapper = this.query(); - queryWrapper.in(SysDictDataPO::getDictType, listType); - return DB.selectList(queryWrapper); - } - - public Map<String, Map<String, String>> map4Type(List<String> listType) { - Map<String, Map<String, String>> result = new HashMap<>(); - - List<SysDictDataPO> listDictData = this.listByType(listType); - Map<String, List<SysDictDataPO>> map4Type = listDictData.stream().collect(Collectors.groupingBy(SysDictDataPO::getDictType)); - for (Map.Entry<String, List<SysDictDataPO>> entry : map4Type.entrySet()) { - Map<String, String> mapData = entry.getValue().stream().collect( - Collectors.toMap(SysDictDataPO::getDictValue, SysDictDataPO::getDictLabel) - ); - result.put(entry.getKey(), mapData); - } - return result; - } - - public Map<String, SysDictDataPO> map4Type(String type) { - List<SysDictDataPO> listDictData = this.getListByType(type); - if (ListUtil.isNullOrEmpty(listDictData)) { - return new HashMap<>(); - } - return listDictData.stream().collect(Collectors.toMap(SysDictDataPO::getDictValue, c -> c)); - } -} diff --git a/src/main/java/com/lunhan/xxx/repository/impl/SysDictTypeMapperImpl.java b/src/main/java/com/lunhan/xxx/repository/impl/SysDictTypeMapperImpl.java deleted file mode 100644 index 82bb373..0000000 --- a/src/main/java/com/lunhan/xxx/repository/impl/SysDictTypeMapperImpl.java +++ /dev/null @@ -1,150 +0,0 @@ -/** -# __----~~~~~~~~~~~------___ -# . . ~~//====...... __--~ ~~ -# -. \_|// |||\\ ~~~~~~::::... /~ -# ___-==_ _-~o~ \/ ||| \\ _/~~- -# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ -# _-~~ .=~ | \\-_ '-~7 /- / || \ / -# .~ .~ | \\ -_ / /- / || \ / -# / ____ / | \\ ~-_/ /|- _/ .|| \ / -# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ -# ' ~-| /| |-~\~~ __--~~ -# |-~~-_/ | | ~\_ _-~ /\ -# / \ \__ \/~ \__ -# _--~ _/ | .-~~____--~-/ ~~==. -# ((->/~ '.|||' -_| ~~-/ , . _|| -# -_ ~\ ~~---l__i__i__i--~~_/ -# _-~-__ ~) \--______________--~~ -# //.-~~~-~_--~- |-------~~~~~~~~ -# //.-~~~--\ -# 神兽保佑 -# 永无BUG! -*/ -package com.lunhan.xxx.repository.impl; - -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.lunhan.xxx.common.PagerResult; -import com.lunhan.xxx.common.util.ListUtil; -import com.lunhan.xxx.common.util.NumericUtil; -import com.lunhan.xxx.common.util.StringUtil; -import com.lunhan.xxx.entity.dto.OrderByDTO; -import com.lunhan.xxx.entity.dto.SearchBasicDTO; -import com.lunhan.xxx.entity.enums.EOrderBy; -import com.lunhan.xxx.entity.search.SearchSysDictType; -import com.lunhan.xxx.repository.BasicMapperImpl; -import com.lunhan.xxx.repository.mapper.SysDictTypeMapper; -import com.lunhan.xxx.repository.po.SysDictTypePO; -import org.springframework.stereotype.Repository; - -import java.util.List; - -/** - * 字典类型表 - * @author lin.liu - * @description 字典类型表 - */ -@Repository -public class SysDictTypeMapperImpl extends BasicMapperImpl<SysDictTypePO, SysDictTypeMapper> { - SysDictTypeMapperImpl(SysDictTypeMapper mapper) { - super(mapper); - } - - @Override - public PagerResult<SysDictTypePO> search(SearchBasicDTO request) { - // 还原查询条件真实类型 - SearchSysDictType search = (SearchSysDictType)request; - // 查询条件 - LambdaQueryWrapper<SysDictTypePO> queryWrapper = this.query(); - // 状态 - queryWrapper.eq(NumericUtil.tryParseInt(search.getStatus()).compareTo(0) > 0, SysDictTypePO::getStatus, search.getStatus()); - // 状态列表 - queryWrapper.in(ListUtil.isNotNullOrEmpty(search.getListStatus()), SysDictTypePO::getStatus, search.getListStatus()); - - // 数据创建时间-起始 - queryWrapper.ge(NumericUtil.tryParseLong(search.getCreateTimeStart()).compareTo(0L) > 0, SysDictTypePO::getCreateTime, search.getCreateTimeStart()); - // 数据创建时间-截止 - queryWrapper.le(NumericUtil.tryParseLong(search.getCreateTimeEnd()).compareTo(0L) > 0, SysDictTypePO::getCreateTime, search.getCreateTimeEnd()); - // 关键字 - if (StringUtil.isNotNullOrEmpty(search.getKeywords())) { - queryWrapper.and(q -> - q.like(SysDictTypePO::getDictType, search.getKeywords()) - .or().like(SysDictTypePO::getDictName, search.getKeywords()) - ); - } - - // 排序处理 - if (ListUtil.isNotNullOrEmpty(search.getOrderBy())) { - for (OrderByDTO item : search.getOrderBy()) { - EOrderBy orderBy = EOrderBy.getByValue(item.getOrderBy()); - // 顺序排序 - if (item.getIsAsc()) { - switch (orderBy) { - // 主键 - case ID: - queryWrapper.orderByAsc(SysDictTypePO::getId); - break; - // 数据创建时间 - case CREATE_TIME: - queryWrapper.orderByAsc(SysDictTypePO::getCreateTime); - break; - // 最后更新时间 - case UPDATE_TIME: - queryWrapper.orderByAsc(SysDictTypePO::getUpdateTime); - break; - } - } else { - // 倒叙排序 - switch (orderBy) { - // 主键 - case ID: - queryWrapper.orderByDesc(SysDictTypePO::getId); - break; - // 数据创建时间 - case CREATE_TIME: - queryWrapper.orderByDesc(SysDictTypePO::getCreateTime); - break; - // 最后更新时间 - case UPDATE_TIME: - queryWrapper.orderByDesc(SysDictTypePO::getUpdateTime); - break; - } - } - } - } else { - queryWrapper.orderByDesc(SysDictTypePO::getId); - } - Page<SysDictTypePO> pageResult = super.selectPage(new Page<>(search.getPage(), search.getLimit()), queryWrapper); - return new PagerResult<>(pageResult.getSize(), pageResult.getCurrent(), pageResult.getTotal(), pageResult.getRecords()); - } - - public Boolean add(SysDictTypePO item) { - int rowCount = super.insert(item); - return rowCount == 1; - } - - public Boolean addNotIncrement(SysDictTypePO item) { - int rowCount = super.insert(item); - return rowCount == 1; - } - - public SysDictTypePO getById(Long id) { - return super.get(id); - } - - public List<SysDictTypePO> getListById(List<Long> listId) { - return super.getList(listId); - } - - public SysDictTypePO get4Type(String type) { - LambdaQueryWrapper<SysDictTypePO> queryWrapper = this.query(); - queryWrapper.eq(SysDictTypePO::getDictType, type); - return DB.selectOne(queryWrapper); - } - - public List<SysDictTypePO> get4Type(List<String> listType) { - LambdaQueryWrapper<SysDictTypePO> queryWrapper = this.query(); - queryWrapper.in(SysDictTypePO::getDictType, listType); - return DB.selectList(queryWrapper); - } -} diff --git a/src/main/java/com/lunhan/xxx/repository/impl/TestInfoMapperImpl.java b/src/main/java/com/lunhan/xxx/repository/impl/TestInfoMapperImpl.java deleted file mode 100644 index 73dd592..0000000 --- a/src/main/java/com/lunhan/xxx/repository/impl/TestInfoMapperImpl.java +++ /dev/null @@ -1,133 +0,0 @@ -/** -# __----~~~~~~~~~~~------___ -# . . ~~//====...... __--~ ~~ -# -. \_|// |||\\ ~~~~~~::::... /~ -# ___-==_ _-~o~ \/ ||| \\ _/~~- -# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ -# _-~~ .=~ | \\-_ '-~7 /- / || \ / -# .~ .~ | \\ -_ / /- / || \ / -# / ____ / | \\ ~-_/ /|- _/ .|| \ / -# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ -# ' ~-| /| |-~\~~ __--~~ -# |-~~-_/ | | ~\_ _-~ /\ -# / \ \__ \/~ \__ -# _--~ _/ | .-~~____--~-/ ~~==. -# ((->/~ '.|||' -_| ~~-/ , . _|| -# -_ ~\ ~~---l__i__i__i--~~_/ -# _-~-__ ~) \--______________--~~ -# //.-~~~-~_--~- |-------~~~~~~~~ -# //.-~~~--\ -# 神兽保佑 -# 永无BUG! -*/ -package com.lunhan.xxx.repository.impl; - -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.lunhan.xxx.common.PagerResult; -import com.lunhan.xxx.common.enums.EYesOrNo; -import com.lunhan.xxx.common.util.ListUtil; -import com.lunhan.xxx.common.util.NumericUtil; -import com.lunhan.xxx.common.util.StringUtil; -import com.lunhan.xxx.entity.dto.OrderByDTO; -import com.lunhan.xxx.entity.dto.SearchBasicDTO; -import com.lunhan.xxx.entity.enums.EOrderBy; -import com.lunhan.xxx.entity.search.SearchTestInfo; -import com.lunhan.xxx.repository.BasicMapperImpl; -import com.lunhan.xxx.repository.mapper.TestInfoMapper; -import com.lunhan.xxx.repository.po.TestInfoPO; -import org.springframework.stereotype.Repository; - -import java.util.List; - -/** - * 测试信息 数据访问类 - * @author lin.liu - * @description 测试信息 数据访问类 - * @date 2021/11/23 - */ -@Repository -public class TestInfoMapperImpl extends BasicMapperImpl<TestInfoPO, TestInfoMapper> { - public TestInfoMapperImpl(TestInfoMapper mapper) { - super(mapper); - } - - @Override - public PagerResult<TestInfoPO> search(SearchBasicDTO request) { - // 还原查询条件真实类型 - SearchTestInfo search = (SearchTestInfo)request; - - //==================== 自定义sql查询方法 调用示例 - begin ==================== - TestInfoPO model1 = DB.testGet(553261510198173696L); - TestInfoPO model2 = DB.testGet2("verona.stroman"); - - List<TestInfoPO> list1 = DB.testList1(search); - List<TestInfoPO> list2 = DB.testList2(search); - //==================== 自定义sql查询方法 调用示例 - end ==================== - - // 查询条件 - LambdaQueryWrapper<TestInfoPO> queryWrapper = this.query(); - // 非逻辑删除 - queryWrapper.eq(TestInfoPO::getIsDelete, EYesOrNo.NO.getValue()); - // 状态 - queryWrapper.eq(NumericUtil.tryParseInt(search.getStatus()).compareTo(0) > 0, TestInfoPO::getStatus, search.getStatus()); - // 状态列表 - queryWrapper.in(ListUtil.isNotNullOrEmpty(search.getListStatus()), TestInfoPO::getStatus, search.getListStatus()); - - // 数据创建时间-起始 - queryWrapper.ge(NumericUtil.tryParseLong(search.getCreateTimeStart()).compareTo(0L) > 0, TestInfoPO::getCreateTime, search.getCreateTimeStart()); - // 数据创建时间-截止 - queryWrapper.le(NumericUtil.tryParseLong(search.getCreateTimeEnd()).compareTo(0L) > 0, TestInfoPO::getCreateTime, search.getCreateTimeEnd()); - // 关键字 - if (StringUtil.isNotNullOrEmpty(search.getKeywords())) { - queryWrapper.and(q -> - q.like(TestInfoPO::getName, search.getKeywords()) - .or().like(TestInfoPO::getPhone, search.getKeywords()) - ); - } - - // 排序处理 - if (ListUtil.isNotNullOrEmpty(search.getOrderBy())) { - for (OrderByDTO item : search.getOrderBy()) { - EOrderBy orderBy = EOrderBy.getByValue(item.getOrderBy()); - // 顺序排序 - if (item.getIsAsc()) { - switch (orderBy) { - // 主键 - case ID: - queryWrapper.orderByAsc(TestInfoPO::getId); - break; - // 数据创建时间 - case CREATE_TIME: - queryWrapper.orderByAsc(TestInfoPO::getCreateTime); - break; - // 最后更新时间 - case UPDATE_TIME: - queryWrapper.orderByAsc(TestInfoPO::getUpdateTime); - break; - } - } else { - // 倒叙排序 - switch (orderBy) { - // 主键 - case ID: - queryWrapper.orderByDesc(TestInfoPO::getId); - break; - // 数据创建时间 - case CREATE_TIME: - queryWrapper.orderByDesc(TestInfoPO::getCreateTime); - break; - // 最后更新时间 - case UPDATE_TIME: - queryWrapper.orderByDesc(TestInfoPO::getUpdateTime); - break; - } - } - } - } else { - queryWrapper.orderByDesc(TestInfoPO::getId); - } - Page<TestInfoPO> pageResult = DB.selectPage(new Page<>(search.getPage(), search.getLimit()), queryWrapper); - return new PagerResult<>(pageResult.getSize(), pageResult.getPages(), pageResult.getTotal(), pageResult.getRecords()); - } -} diff --git a/src/main/java/com/lunhan/xxx/repository/mapper/AdminMenuMapper.java b/src/main/java/com/lunhan/xxx/repository/mapper/AdminMenuMapper.java deleted file mode 100644 index ceaee19..0000000 --- a/src/main/java/com/lunhan/xxx/repository/mapper/AdminMenuMapper.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.lunhan.xxx.repository.mapper; - -import com.lunhan.xxx.repository.BasicMapper;import com.lunhan.xxx.repository.po.AdminMenuPO; - -/** - * 菜单 mapper - * @author lin.liu - */ -public interface AdminMenuMapper extends BasicMapper<AdminMenuPO> { -} diff --git a/src/main/java/com/lunhan/xxx/repository/mapper/AdminMenusMapper.java b/src/main/java/com/lunhan/xxx/repository/mapper/AdminMenusMapper.java deleted file mode 100644 index 051b043..0000000 --- a/src/main/java/com/lunhan/xxx/repository/mapper/AdminMenusMapper.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.lunhan.xxx.repository.mapper; - -import com.lunhan.xxx.repository.BasicMapper;import com.lunhan.xxx.repository.po.AdminMenusPO; - -/** - * 菜单信息 mapper - * @author lin.liu - */ -public interface AdminMenusMapper extends BasicMapper<AdminMenusPO> { -} diff --git a/src/main/java/com/lunhan/xxx/repository/mapper/AdminPermissionMapper.java b/src/main/java/com/lunhan/xxx/repository/mapper/AdminPermissionMapper.java deleted file mode 100644 index 441632d..0000000 --- a/src/main/java/com/lunhan/xxx/repository/mapper/AdminPermissionMapper.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.lunhan.xxx.repository.mapper; - -import com.lunhan.xxx.repository.BasicMapper;import com.lunhan.xxx.repository.po.AdminPermissionPO; - -/** - * 权限 mapper - * @author lin.liu - */ -public interface AdminPermissionMapper extends BasicMapper<AdminPermissionPO> { -} diff --git a/src/main/java/com/lunhan/xxx/repository/mapper/AdminRoleMapper.java b/src/main/java/com/lunhan/xxx/repository/mapper/AdminRoleMapper.java deleted file mode 100644 index 7241f65..0000000 --- a/src/main/java/com/lunhan/xxx/repository/mapper/AdminRoleMapper.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.lunhan.xxx.repository.mapper; - -import com.lunhan.xxx.repository.BasicMapper;import com.lunhan.xxx.repository.po.AdminRolePO; - -/** - * 角色 mapper - * @author lin.liu - */ -public interface AdminRoleMapper extends BasicMapper<AdminRolePO> { -} diff --git a/src/main/java/com/lunhan/xxx/repository/mapper/AdminRoleMenuRelationMapper.java b/src/main/java/com/lunhan/xxx/repository/mapper/AdminRoleMenuRelationMapper.java deleted file mode 100644 index f45c717..0000000 --- a/src/main/java/com/lunhan/xxx/repository/mapper/AdminRoleMenuRelationMapper.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.lunhan.xxx.repository.mapper; - -import com.lunhan.xxx.repository.BasicMapper;import com.lunhan.xxx.repository.po.AdminRoleMenuRelationPO; - -/** - * 角色菜单关联关系 mapper - * @author lin.liu - */ -public interface AdminRoleMenuRelationMapper extends BasicMapper<AdminRoleMenuRelationPO> { -} diff --git a/src/main/java/com/lunhan/xxx/repository/mapper/AdminRolePermissionRelationMapper.java b/src/main/java/com/lunhan/xxx/repository/mapper/AdminRolePermissionRelationMapper.java deleted file mode 100644 index 494909b..0000000 --- a/src/main/java/com/lunhan/xxx/repository/mapper/AdminRolePermissionRelationMapper.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.lunhan.xxx.repository.mapper; - -import com.lunhan.xxx.repository.BasicMapper;import com.lunhan.xxx.repository.po.AdminRolePermissionRelationPO; - -/** - * 角色权限关联关系 mapper - * @author lin.liu - */ -public interface AdminRolePermissionRelationMapper extends BasicMapper<AdminRolePermissionRelationPO> { -} diff --git a/src/main/java/com/lunhan/xxx/repository/mapper/AdminRoleRelationMapper.java b/src/main/java/com/lunhan/xxx/repository/mapper/AdminRoleRelationMapper.java deleted file mode 100644 index 21e3328..0000000 --- a/src/main/java/com/lunhan/xxx/repository/mapper/AdminRoleRelationMapper.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.lunhan.xxx.repository.mapper; - -import com.lunhan.xxx.repository.BasicMapper;import com.lunhan.xxx.repository.po.AdminRoleRelationPO; - -/** - * 用户和角色关联关系 mapper - * @author lin.liu - */ -public interface AdminRoleRelationMapper extends BasicMapper<AdminRoleRelationPO> { -} diff --git a/src/main/java/com/lunhan/xxx/repository/mapper/AdminUserMapper.java b/src/main/java/com/lunhan/xxx/repository/mapper/AdminUserMapper.java deleted file mode 100644 index ec44326..0000000 --- a/src/main/java/com/lunhan/xxx/repository/mapper/AdminUserMapper.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.lunhan.xxx.repository.mapper; - -import com.lunhan.xxx.repository.BasicMapper;import com.lunhan.xxx.repository.po.AdminUserPO; - -/** - * 管理员帐号 mapper - * @author lin.liu - */ -public interface AdminUserMapper extends BasicMapper<AdminUserPO> { -} diff --git a/src/main/java/com/lunhan/xxx/repository/mapper/NoticeMapper.java b/src/main/java/com/lunhan/xxx/repository/mapper/NoticeMapper.java deleted file mode 100644 index 19cfc27..0000000 --- a/src/main/java/com/lunhan/xxx/repository/mapper/NoticeMapper.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.lunhan.xxx.repository.mapper; - -import com.lunhan.xxx.repository.BasicMapper;import com.lunhan.xxx.repository.po.NoticePO; - -/** - * 公告 mapper - * @author lin.liu - */ -public interface NoticeMapper extends BasicMapper<NoticePO> { -} diff --git a/src/main/java/com/lunhan/xxx/repository/mapper/QuartzTaskErrorMapper.java b/src/main/java/com/lunhan/xxx/repository/mapper/QuartzTaskErrorMapper.java deleted file mode 100644 index 8658cf2..0000000 --- a/src/main/java/com/lunhan/xxx/repository/mapper/QuartzTaskErrorMapper.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.lunhan.xxx.repository.mapper; - -import com.lunhan.xxx.repository.BasicMapper; -import com.lunhan.xxx.repository.po.QuartzTaskErrorPO; - -/** - * 定时任务错误信息 mapper - * @author lin.liu - * @description 定时任务错误信息 mapper - */ -public interface QuartzTaskErrorMapper extends BasicMapper<QuartzTaskErrorPO> { -} diff --git a/src/main/java/com/lunhan/xxx/repository/mapper/QuartzTaskInfoMapper.java b/src/main/java/com/lunhan/xxx/repository/mapper/QuartzTaskInfoMapper.java deleted file mode 100644 index 3bbc195..0000000 --- a/src/main/java/com/lunhan/xxx/repository/mapper/QuartzTaskInfoMapper.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.lunhan.xxx.repository.mapper; - -import com.lunhan.xxx.repository.BasicMapper; -import com.lunhan.xxx.repository.po.QuartzTaskInfoPO; - -/** - * 定时任务信息 mapper - * @author lin.liu - * @description 定时任务信息 mapper - */ -public interface QuartzTaskInfoMapper extends BasicMapper<QuartzTaskInfoPO> { -} diff --git a/src/main/java/com/lunhan/xxx/repository/mapper/QuartzTaskRecordMapper.java b/src/main/java/com/lunhan/xxx/repository/mapper/QuartzTaskRecordMapper.java deleted file mode 100644 index 8974935..0000000 --- a/src/main/java/com/lunhan/xxx/repository/mapper/QuartzTaskRecordMapper.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.lunhan.xxx.repository.mapper; - -import com.lunhan.xxx.repository.BasicMapper; -import com.lunhan.xxx.repository.po.QuartzTaskRecordPO; - -/** - * 定时任务执行记录 mapper - * @author lin.liu - * @description 定时任务执行记录 mapper - */ -public interface QuartzTaskRecordMapper extends BasicMapper<QuartzTaskRecordPO> { -} diff --git a/src/main/java/com/lunhan/xxx/repository/mapper/SysDictDataMapper.java b/src/main/java/com/lunhan/xxx/repository/mapper/SysDictDataMapper.java deleted file mode 100644 index a6875c7..0000000 --- a/src/main/java/com/lunhan/xxx/repository/mapper/SysDictDataMapper.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.lunhan.xxx.repository.mapper; - -import com.lunhan.xxx.repository.BasicMapper;import com.lunhan.xxx.repository.po.SysDictDataPO; - -/** - * 字典数据 mapper - * @author lin.liu - */ -public interface SysDictDataMapper extends BasicMapper<SysDictDataPO> { -} diff --git a/src/main/java/com/lunhan/xxx/repository/mapper/SysDictTypeMapper.java b/src/main/java/com/lunhan/xxx/repository/mapper/SysDictTypeMapper.java deleted file mode 100644 index b892dc2..0000000 --- a/src/main/java/com/lunhan/xxx/repository/mapper/SysDictTypeMapper.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.lunhan.xxx.repository.mapper; - -import com.lunhan.xxx.repository.BasicMapper;import com.lunhan.xxx.repository.po.SysDictTypePO; - -/** - * 字典类型 mapper - * @author lin.liu - */ -public interface SysDictTypeMapper extends BasicMapper<SysDictTypePO> { -} diff --git a/src/main/java/com/lunhan/xxx/repository/mapper/TestInfoMapper.java b/src/main/java/com/lunhan/xxx/repository/mapper/TestInfoMapper.java deleted file mode 100644 index be6b533..0000000 --- a/src/main/java/com/lunhan/xxx/repository/mapper/TestInfoMapper.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.lunhan.xxx.repository.mapper; - -import com.baomidou.mybatisplus.core.toolkit.Constants; -import com.lunhan.xxx.entity.search.SearchTestInfo; -import com.lunhan.xxx.repository.BasicMapper; -import com.lunhan.xxx.repository.po.TestInfoPO; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; -import org.apache.ibatis.annotations.Select; - -import java.util.List; - -@Mapper -public interface TestInfoMapper extends BasicMapper<TestInfoPO> { - //==================== 自定义sql查询方法 声明示例 - begin ==================== - // #{param}:会进行预编译,而且进行类型匹配,最后进行变量替换,括号中可以添加映射类型如 -// @Select( -// "<script>" + -// "select * from student where id= #{param,javaType=int,jdbcType=NUMERIC}" + -// "</script> " -// ) - // ${param}:$只是只是简单的字符串拼接,要特别小心sql注入问题,对应非变量部分,只能用$。$方式一般用于传入数据库对象,比如这种group by 字段 ,order by 字段,表名,字段名等没法使用占位符的就需要使用${param} - - @Select("select * from test_info where id = #{id}") - TestInfoPO testGet(Long id); - - @Select("select * from test_info where name = #{name}") - TestInfoPO testGet2(String userName); - - @Select("select * from test_info where status = #{ew.status}") - List<TestInfoPO> testList1(@Param(Constants.WRAPPER) SearchTestInfo search); - - @Select("select * from test_info where status = #{search.status}") - List<TestInfoPO> testList2(@Param("search") SearchTestInfo search); - //==================== 自定义sql查询方法 声明示例 - end ==================== -} diff --git a/src/main/java/com/lunhan/xxx/repository/po/AdminMenuPO.java b/src/main/java/com/lunhan/xxx/repository/po/AdminMenuPO.java deleted file mode 100644 index d65c8e5..0000000 --- a/src/main/java/com/lunhan/xxx/repository/po/AdminMenuPO.java +++ /dev/null @@ -1,104 +0,0 @@ -/** -# __----~~~~~~~~~~~------___ -# . . ~~//====...... __--~ ~~ -# -. \_|// |||\\ ~~~~~~::::... /~ -# ___-==_ _-~o~ \/ ||| \\ _/~~- -# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ -# _-~~ .=~ | \\-_ '-~7 /- / || \ / -# .~ .~ | \\ -_ / /- / || \ / -# / ____ / | \\ ~-_/ /|- _/ .|| \ / -# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ -# ' ~-| /| |-~\~~ __--~~ -# |-~~-_/ | | ~\_ _-~ /\ -# / \ \__ \/~ \__ -# _--~ _/ | .-~~____--~-/ ~~==. -# ((->/~ '.|||' -_| ~~-/ , . _|| -# -_ ~\ ~~---l__i__i__i--~~_/ -# _-~-__ ~) \--______________--~~ -# //.-~~~-~_--~- |-------~~~~~~~~ -# //.-~~~--\ -# 神兽保佑 -# 永无BUG! -*/ -package com.lunhan.xxx.repository.po; - -import lombok.Data; - -import com.baomidou.mybatisplus.annotation.*; - -import java.io.Serializable; -import java.sql.Timestamp; - -/** - * 菜单 - * @author lin.liu - */ -@Data -@TableName("admin_menu") -public class AdminMenuPO implements Serializable { - /** - * 主键 - */ - private Long id; - /** - * 父级ID - */ - @TableField(value = "parent_id") - private Long parentId; - /** - * 类型 EMenuType - */ - @TableField(value = "type") - private Integer type; - /** - * 菜单名称 - */ - @TableField(value = "name") - private String name; - /** - * 菜单标题 - */ - @TableField(value = "title") - private String title; - /** - * 前端资源路径 - */ - @TableField(value = "url") - private String url; - /** - * 菜单层级 - */ - @TableField(value = "level") - private Integer level; - /** - * 排序值 - */ - @TableField(value = "sort") - private Integer sort; - /** - * 图标 - */ - @TableField(value = "icon") - private String icon; - /** - * 状态 EState - */ - @TableField(value = "status") - private Integer status; - /** - * 数据创建时间 - */ - @TableField(value = "create_time") - private Long createTime; - /** - * 最后更新时间 - */ - @TableField(value = "update_time") - private Timestamp updateTime; - /** - * 是否删除(逻辑删除) - */ - @TableLogic - @TableField(value = "is_delete") - private Integer isDelete; -} diff --git a/src/main/java/com/lunhan/xxx/repository/po/AdminMenusPO.java b/src/main/java/com/lunhan/xxx/repository/po/AdminMenusPO.java deleted file mode 100644 index 9c804fe..0000000 --- a/src/main/java/com/lunhan/xxx/repository/po/AdminMenusPO.java +++ /dev/null @@ -1,99 +0,0 @@ -/** -# __----~~~~~~~~~~~------___ -# . . ~~//====...... __--~ ~~ -# -. \_|// |||\\ ~~~~~~::::... /~ -# ___-==_ _-~o~ \/ ||| \\ _/~~- -# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ -# _-~~ .=~ | \\-_ '-~7 /- / || \ / -# .~ .~ | \\ -_ / /- / || \ / -# / ____ / | \\ ~-_/ /|- _/ .|| \ / -# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ -# ' ~-| /| |-~\~~ __--~~ -# |-~~-_/ | | ~\_ _-~ /\ -# / \ \__ \/~ \__ -# _--~ _/ | .-~~____--~-/ ~~==. -# ((->/~ '.|||' -_| ~~-/ , . _|| -# -_ ~\ ~~---l__i__i__i--~~_/ -# _-~-__ ~) \--______________--~~ -# //.-~~~-~_--~- |-------~~~~~~~~ -# //.-~~~--\ -# 神兽保佑 -# 永无BUG! -*/ -package com.lunhan.xxx.repository.po; - -import lombok.Data; - -import com.baomidou.mybatisplus.annotation.*; - -import java.io.Serializable; -import java.sql.Timestamp; - -/** - * 菜单信息 - * @author lin.liu - */ -@Data -@TableName("admin_menus") -public class AdminMenusPO implements Serializable { - /** - * 主键id - */ - private Long id; - /** - * 父级id - */ - @TableField(value = "parent_id") - private Long parentId; - /** - * 菜单名称 - */ - @TableField(value = "name") - private String name; - /** - * 菜单标题 - */ - @TableField(value = "title") - private String title; - /** - * 前端资源路径 - */ - @TableField(value = "uri") - private String uri; - /** - * 菜单层级 - */ - @TableField(value = "level") - private Integer level; - /** - * 排序值 - */ - @TableField(value = "sort") - private Integer sort; - /** - * 图标 - */ - @TableField(value = "icon") - private String icon; - /** - * 状态 EState - */ - @TableField(value = "status") - private Integer status; - /** - * 数据创建时间 - */ - @TableField(value = "create_time") - private Long createTime; - /** - * 最后更新时间 - */ - @TableField(value = "update_time") - private Timestamp updateTime; - /** - * 是否删除(逻辑删除) - */ - @TableLogic - @TableField(value = "is_delete") - private Integer isDelete; -} diff --git a/src/main/java/com/lunhan/xxx/repository/po/AdminPermissionPO.java b/src/main/java/com/lunhan/xxx/repository/po/AdminPermissionPO.java deleted file mode 100644 index b617e24..0000000 --- a/src/main/java/com/lunhan/xxx/repository/po/AdminPermissionPO.java +++ /dev/null @@ -1,94 +0,0 @@ -/** -# __----~~~~~~~~~~~------___ -# . . ~~//====...... __--~ ~~ -# -. \_|// |||\\ ~~~~~~::::... /~ -# ___-==_ _-~o~ \/ ||| \\ _/~~- -# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ -# _-~~ .=~ | \\-_ '-~7 /- / || \ / -# .~ .~ | \\ -_ / /- / || \ / -# / ____ / | \\ ~-_/ /|- _/ .|| \ / -# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ -# ' ~-| /| |-~\~~ __--~~ -# |-~~-_/ | | ~\_ _-~ /\ -# / \ \__ \/~ \__ -# _--~ _/ | .-~~____--~-/ ~~==. -# ((->/~ '.|||' -_| ~~-/ , . _|| -# -_ ~\ ~~---l__i__i__i--~~_/ -# _-~-__ ~) \--______________--~~ -# //.-~~~-~_--~- |-------~~~~~~~~ -# //.-~~~--\ -# 神兽保佑 -# 永无BUG! -*/ -package com.lunhan.xxx.repository.po; - -import lombok.Data; - -import com.baomidou.mybatisplus.annotation.*; - -import java.io.Serializable; -import java.sql.Timestamp; - -/** - * 权限 - * @author lin.liu - */ -@Data -@TableName("admin_permission") -public class AdminPermissionPO implements Serializable { - /** - * 主键 - */ - private Long id; - /** - * 权限值 - */ - @TableField(value = "sn") - private String sn; - /** - * 菜单id - */ - @TableField(value = "menu_id") - private Long menuId; - /** - * 前端资源url - */ - @TableField(value = "menu_url") - private String menuUrl; - /** - * 名称 - */ - @TableField(value = "name") - private String name; - /** - * 图标 - */ - @TableField(value = "icon") - private String icon; - /** - * 权限类型 EOperation - */ - @TableField(value = "type") - private String type; - /** - * 状态 EStatus - */ - @TableField(value = "status") - private Integer status; - /** - * 数据创建时间 - */ - @TableField(value = "create_time") - private Long createTime; - /** - * 最后更新时间 - */ - @TableField(value = "update_time") - private Timestamp updateTime; - /** - * 是否删除(逻辑删除) - */ - @TableLogic - @TableField(value = "is_delete") - private Integer isDelete; -} diff --git a/src/main/java/com/lunhan/xxx/repository/po/AdminRoleMenuRelationPO.java b/src/main/java/com/lunhan/xxx/repository/po/AdminRoleMenuRelationPO.java deleted file mode 100644 index 984a01f..0000000 --- a/src/main/java/com/lunhan/xxx/repository/po/AdminRoleMenuRelationPO.java +++ /dev/null @@ -1,69 +0,0 @@ -/** -# __----~~~~~~~~~~~------___ -# . . ~~//====...... __--~ ~~ -# -. \_|// |||\\ ~~~~~~::::... /~ -# ___-==_ _-~o~ \/ ||| \\ _/~~- -# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ -# _-~~ .=~ | \\-_ '-~7 /- / || \ / -# .~ .~ | \\ -_ / /- / || \ / -# / ____ / | \\ ~-_/ /|- _/ .|| \ / -# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ -# ' ~-| /| |-~\~~ __--~~ -# |-~~-_/ | | ~\_ _-~ /\ -# / \ \__ \/~ \__ -# _--~ _/ | .-~~____--~-/ ~~==. -# ((->/~ '.|||' -_| ~~-/ , . _|| -# -_ ~\ ~~---l__i__i__i--~~_/ -# _-~-__ ~) \--______________--~~ -# //.-~~~-~_--~- |-------~~~~~~~~ -# //.-~~~--\ -# 神兽保佑 -# 永无BUG! -*/ -package com.lunhan.xxx.repository.po; - -import lombok.Data; - -import com.baomidou.mybatisplus.annotation.*; - -import java.io.Serializable; -import java.sql.Timestamp; - -/** - * 角色菜单关联关系 - * @author lin.liu - */ -@Data -@TableName("admin_role_menu_relation") -public class AdminRoleMenuRelationPO implements Serializable { - /** - * 主键 - */ - private Long id; - /** - * 角色id - */ - @TableField(value = "role_id") - private Long roleId; - /** - * 菜单id - */ - @TableField(value = "menu_id") - private Long menuId; - /** - * 数据创建时间 - */ - @TableField(value = "create_time") - private Long createTime; - /** - * 最后更新时间 - */ - @TableField(value = "update_time") - private Timestamp updateTime; - /** - * 是否删除(逻辑删除) - */ - @TableLogic - @TableField(value = "is_delete") - private Integer isDelete; -} diff --git a/src/main/java/com/lunhan/xxx/repository/po/AdminRolePO.java b/src/main/java/com/lunhan/xxx/repository/po/AdminRolePO.java deleted file mode 100644 index 00f9552..0000000 --- a/src/main/java/com/lunhan/xxx/repository/po/AdminRolePO.java +++ /dev/null @@ -1,79 +0,0 @@ -/** -# __----~~~~~~~~~~~------___ -# . . ~~//====...... __--~ ~~ -# -. \_|// |||\\ ~~~~~~::::... /~ -# ___-==_ _-~o~ \/ ||| \\ _/~~- -# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ -# _-~~ .=~ | \\-_ '-~7 /- / || \ / -# .~ .~ | \\ -_ / /- / || \ / -# / ____ / | \\ ~-_/ /|- _/ .|| \ / -# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ -# ' ~-| /| |-~\~~ __--~~ -# |-~~-_/ | | ~\_ _-~ /\ -# / \ \__ \/~ \__ -# _--~ _/ | .-~~____--~-/ ~~==. -# ((->/~ '.|||' -_| ~~-/ , . _|| -# -_ ~\ ~~---l__i__i__i--~~_/ -# _-~-__ ~) \--______________--~~ -# //.-~~~-~_--~- |-------~~~~~~~~ -# //.-~~~--\ -# 神兽保佑 -# 永无BUG! -*/ -package com.lunhan.xxx.repository.po; - -import lombok.Data; - -import com.baomidou.mybatisplus.annotation.*; - -import java.io.Serializable; -import java.sql.Timestamp; - -/** - * 角色 - * @author lin.liu - */ -@Data -@TableName("admin_role") -public class AdminRolePO implements Serializable { - /** - * 主键 - */ - private Long id; - /** - * 角色名称 - */ - @TableField(value = "name") - private String name; - /** - * 描述 - */ - @TableField(value = "description") - private String description; - /** - * 状态 EState - */ - @TableField(value = "status") - private Integer status; - /** - * 排序值 - */ - @TableField(value = "sort") - private Integer sort; - /** - * 数据创建时间 - */ - @TableField(value = "create_time") - private Long createTime; - /** - * 最后更新时间 - */ - @TableField(value = "update_time") - private Timestamp updateTime; - /** - * 是否删除(逻辑删除) - */ - @TableLogic - @TableField(value = "is_delete") - private Integer isDelete; -} diff --git a/src/main/java/com/lunhan/xxx/repository/po/AdminRolePermissionRelationPO.java b/src/main/java/com/lunhan/xxx/repository/po/AdminRolePermissionRelationPO.java deleted file mode 100644 index 4bd54be..0000000 --- a/src/main/java/com/lunhan/xxx/repository/po/AdminRolePermissionRelationPO.java +++ /dev/null @@ -1,69 +0,0 @@ -/** -# __----~~~~~~~~~~~------___ -# . . ~~//====...... __--~ ~~ -# -. \_|// |||\\ ~~~~~~::::... /~ -# ___-==_ _-~o~ \/ ||| \\ _/~~- -# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ -# _-~~ .=~ | \\-_ '-~7 /- / || \ / -# .~ .~ | \\ -_ / /- / || \ / -# / ____ / | \\ ~-_/ /|- _/ .|| \ / -# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ -# ' ~-| /| |-~\~~ __--~~ -# |-~~-_/ | | ~\_ _-~ /\ -# / \ \__ \/~ \__ -# _--~ _/ | .-~~____--~-/ ~~==. -# ((->/~ '.|||' -_| ~~-/ , . _|| -# -_ ~\ ~~---l__i__i__i--~~_/ -# _-~-__ ~) \--______________--~~ -# //.-~~~-~_--~- |-------~~~~~~~~ -# //.-~~~--\ -# 神兽保佑 -# 永无BUG! -*/ -package com.lunhan.xxx.repository.po; - -import lombok.Data; - -import com.baomidou.mybatisplus.annotation.*; - -import java.io.Serializable; -import java.sql.Timestamp; - -/** - * 角色权限关联关系 - * @author lin.liu - */ -@Data -@TableName("admin_role_permission_relation") -public class AdminRolePermissionRelationPO implements Serializable { - /** - * 主键 - */ - private Long id; - /** - * 角色id - */ - @TableField(value = "role_id") - private Long roleId; - /** - * 权限id - */ - @TableField(value = "permission_id") - private Long permissionId; - /** - * 数据创建时间 - */ - @TableField(value = "create_time") - private Long createTime; - /** - * 最后更新时间 - */ - @TableField(value = "update_time") - private Timestamp updateTime; - /** - * 是否删除(逻辑删除) - */ - @TableLogic - @TableField(value = "is_delete") - private Integer isDelete; -} diff --git a/src/main/java/com/lunhan/xxx/repository/po/AdminRoleRelationPO.java b/src/main/java/com/lunhan/xxx/repository/po/AdminRoleRelationPO.java deleted file mode 100644 index b0501dd..0000000 --- a/src/main/java/com/lunhan/xxx/repository/po/AdminRoleRelationPO.java +++ /dev/null @@ -1,69 +0,0 @@ -/** -# __----~~~~~~~~~~~------___ -# . . ~~//====...... __--~ ~~ -# -. \_|// |||\\ ~~~~~~::::... /~ -# ___-==_ _-~o~ \/ ||| \\ _/~~- -# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ -# _-~~ .=~ | \\-_ '-~7 /- / || \ / -# .~ .~ | \\ -_ / /- / || \ / -# / ____ / | \\ ~-_/ /|- _/ .|| \ / -# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ -# ' ~-| /| |-~\~~ __--~~ -# |-~~-_/ | | ~\_ _-~ /\ -# / \ \__ \/~ \__ -# _--~ _/ | .-~~____--~-/ ~~==. -# ((->/~ '.|||' -_| ~~-/ , . _|| -# -_ ~\ ~~---l__i__i__i--~~_/ -# _-~-__ ~) \--______________--~~ -# //.-~~~-~_--~- |-------~~~~~~~~ -# //.-~~~--\ -# 神兽保佑 -# 永无BUG! -*/ -package com.lunhan.xxx.repository.po; - -import lombok.Data; - -import com.baomidou.mybatisplus.annotation.*; - -import java.io.Serializable; -import java.sql.Timestamp; - -/** - * 用户和角色关联关系 - * @author lin.liu - */ -@Data -@TableName("admin_role_relation") -public class AdminRoleRelationPO implements Serializable { - /** - * 主键 - */ - private Long id; - /** - * 管理员id - */ - @TableField(value = "admin_id") - private Long adminId; - /** - * 角色id - */ - @TableField(value = "role_id") - private Long roleId; - /** - * 数据创建时间 - */ - @TableField(value = "create_time") - private Long createTime; - /** - * 最后更新时间 - */ - @TableField(value = "update_time") - private Timestamp updateTime; - /** - * 是否删除(逻辑删除) - */ - @TableLogic - @TableField(value = "is_delete") - private Integer isDelete; -} diff --git a/src/main/java/com/lunhan/xxx/repository/po/AdminUserPO.java b/src/main/java/com/lunhan/xxx/repository/po/AdminUserPO.java deleted file mode 100644 index 1fbce9d..0000000 --- a/src/main/java/com/lunhan/xxx/repository/po/AdminUserPO.java +++ /dev/null @@ -1,104 +0,0 @@ -/** -# __----~~~~~~~~~~~------___ -# . . ~~//====...... __--~ ~~ -# -. \_|// |||\\ ~~~~~~::::... /~ -# ___-==_ _-~o~ \/ ||| \\ _/~~- -# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ -# _-~~ .=~ | \\-_ '-~7 /- / || \ / -# .~ .~ | \\ -_ / /- / || \ / -# / ____ / | \\ ~-_/ /|- _/ .|| \ / -# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ -# ' ~-| /| |-~\~~ __--~~ -# |-~~-_/ | | ~\_ _-~ /\ -# / \ \__ \/~ \__ -# _--~ _/ | .-~~____--~-/ ~~==. -# ((->/~ '.|||' -_| ~~-/ , . _|| -# -_ ~\ ~~---l__i__i__i--~~_/ -# _-~-__ ~) \--______________--~~ -# //.-~~~-~_--~- |-------~~~~~~~~ -# //.-~~~--\ -# 神兽保佑 -# 永无BUG! -*/ -package com.lunhan.xxx.repository.po; - -import lombok.Data; - -import com.baomidou.mybatisplus.annotation.*; - -import java.io.Serializable; -import java.sql.Timestamp; - -/** - * 管理员帐号 - * @author lin.liu - */ -@Data -@TableName("admin_user") -public class AdminUserPO implements Serializable { - /** - * 主键 - */ - private Long id; - /** - * 用户类型 EUserType - */ - @TableField(value = "user_type") - private Integer userType; - /** - * 用户关联id,和“user_type”对应,如:客户id等 - */ - @TableField(value = "user_rel_id") - private Long userRelId; - /** - * 用户名 - */ - @TableField(value = "user_name") - private String userName; - /** - * 密码 - */ - @TableField(value = "password") - private String password; - /** - * 昵称 - */ - @TableField(value = "nick_name") - private String nickName; - /** - * 头像 - */ - @TableField(value = "head_img") - private String headImg; - /** - * 联系方式 - */ - @TableField(value = "contact") - private String contact; - /** - * 联系邮箱 - */ - @TableField(value = "email") - private String email; - /** - * 状态 EState - */ - @TableField(value = "status") - private Integer status; - /** - * 数据创建时间 - */ - @TableField(value = "create_time") - private Long createTime; - /** - * 最后更新时间 - */ - @TableField(value = "update_time") - private Timestamp updateTime; - /** - * 是否删除(逻辑删除) - */ - @TableLogic - @TableField(value = "is_delete") - private Integer isDelete; -} diff --git a/src/main/java/com/lunhan/xxx/repository/po/NoticePO.java b/src/main/java/com/lunhan/xxx/repository/po/NoticePO.java deleted file mode 100644 index 832de7a..0000000 --- a/src/main/java/com/lunhan/xxx/repository/po/NoticePO.java +++ /dev/null @@ -1,109 +0,0 @@ -/** -# __----~~~~~~~~~~~------___ -# . . ~~//====...... __--~ ~~ -# -. \_|// |||\\ ~~~~~~::::... /~ -# ___-==_ _-~o~ \/ ||| \\ _/~~- -# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ -# _-~~ .=~ | \\-_ '-~7 /- / || \ / -# .~ .~ | \\ -_ / /- / || \ / -# / ____ / | \\ ~-_/ /|- _/ .|| \ / -# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ -# ' ~-| /| |-~\~~ __--~~ -# |-~~-_/ | | ~\_ _-~ /\ -# / \ \__ \/~ \__ -# _--~ _/ | .-~~____--~-/ ~~==. -# ((->/~ '.|||' -_| ~~-/ , . _|| -# -_ ~\ ~~---l__i__i__i--~~_/ -# _-~-__ ~) \--______________--~~ -# //.-~~~-~_--~- |-------~~~~~~~~ -# //.-~~~--\ -# 神兽保佑 -# 永无BUG! -*/ -package com.lunhan.xxx.repository.po; - -import lombok.Data; - -import com.baomidou.mybatisplus.annotation.*; - -import java.io.Serializable; -import java.sql.Timestamp; - -/** - * 公告 - * @author lin.liu - */ -@Data -@TableName("notice") -public class NoticePO implements Serializable { - /** - * 主键 - */ - private Long id; - /** - * 发布人 - */ - @TableField(value = "publish_user") - private String publishUser; - /** - * 标题 - */ - @TableField(value = "title") - private String title; - /** - * 摘要 - */ - @TableField(value = "summary") - private String summary; - /** - * 内容 - */ - @TableField(value = "content") - private String content; - /** - * 排序 - */ - @TableField(value = "sort") - private Integer sort; - /** - * 状态(EState) - */ - @TableField(value = "status") - private Integer status; - /** - * 数据创建时间 - */ - @TableField(value = "create_time") - private Long createTime; - /** - * 最后更新时间 - */ - @TableField(value = "update_time") - private Timestamp updateTime; - /** - * 数据创建人 - */ - @TableField(value = "create_user") - private String createUser; - /** - * 数据创建人名称 - */ - @TableField(value = "create_user_name") - private String createUserName; - /** - * 最后更新人 - */ - @TableField(value = "update_user") - private String updateUser; - /** - * 最后更新人名称 - */ - @TableField(value = "update_user_name") - private String updateUserName; - /** - * 是否删除(逻辑删除) - */ - @TableLogic - @TableField(value = "is_delete") - private Integer isDelete; -} diff --git a/src/main/java/com/lunhan/xxx/repository/po/QuartzTaskErrorPO.java b/src/main/java/com/lunhan/xxx/repository/po/QuartzTaskErrorPO.java deleted file mode 100644 index 7ffb4bb..0000000 --- a/src/main/java/com/lunhan/xxx/repository/po/QuartzTaskErrorPO.java +++ /dev/null @@ -1,74 +0,0 @@ -/** -# __----~~~~~~~~~~~------___ -# . . ~~//====...... __--~ ~~ -# -. \_|// |||\\ ~~~~~~::::... /~ -# ___-==_ _-~o~ \/ ||| \\ _/~~- -# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ -# _-~~ .=~ | \\-_ '-~7 /- / || \ / -# .~ .~ | \\ -_ / /- / || \ / -# / ____ / | \\ ~-_/ /|- _/ .|| \ / -# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ -# ' ~-| /| |-~\~~ __--~~ -# |-~~-_/ | | ~\_ _-~ /\ -# / \ \__ \/~ \__ -# _--~ _/ | .-~~____--~-/ ~~==. -# ((->/~ '.|||' -_| ~~-/ , . _|| -# -_ ~\ ~~---l__i__i__i--~~_/ -# _-~-__ ~) \--______________--~~ -# //.-~~~-~_--~- |-------~~~~~~~~ -# //.-~~~--\ -# 神兽保佑 -# 永无BUG! -*/ -package com.lunhan.xxx.repository.po; - -import lombok.Data; - -import com.baomidou.mybatisplus.annotation.*; - -import java.io.Serializable; -import java.sql.Timestamp; - -/** - * 定时任务错误信息 - * @author lin.liu - */ -@Data -@TableName("quartz_task_error") -public class QuartzTaskErrorPO implements Serializable { - /** - * 主键 - */ - private Long id; - /** - * 任务执行记录id - */ - @TableField(value = "task_execute_record_id") - private String taskExecuteRecordId; - /** - * 关键字 - */ - @TableField(value = "error_key") - private String errorKey; - /** - * 详细信息 - */ - @TableField(value = "error_value") - private String errorValue; - /** - * 数据创建时间 - */ - @TableField(value = "create_time") - private Long createTime; - /** - * 最后更新时间 - */ - @TableField(value = "update_time") - private Timestamp updateTime; - /** - * 是否删除(逻辑删除) - */ - @TableLogic - @TableField(value = "is_delete") - private Integer isDelete; -} diff --git a/src/main/java/com/lunhan/xxx/repository/po/QuartzTaskInfoPO.java b/src/main/java/com/lunhan/xxx/repository/po/QuartzTaskInfoPO.java deleted file mode 100644 index b0835ca..0000000 --- a/src/main/java/com/lunhan/xxx/repository/po/QuartzTaskInfoPO.java +++ /dev/null @@ -1,129 +0,0 @@ -/** -# __----~~~~~~~~~~~------___ -# . . ~~//====...... __--~ ~~ -# -. \_|// |||\\ ~~~~~~::::... /~ -# ___-==_ _-~o~ \/ ||| \\ _/~~- -# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ -# _-~~ .=~ | \\-_ '-~7 /- / || \ / -# .~ .~ | \\ -_ / /- / || \ / -# / ____ / | \\ ~-_/ /|- _/ .|| \ / -# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ -# ' ~-| /| |-~\~~ __--~~ -# |-~~-_/ | | ~\_ _-~ /\ -# / \ \__ \/~ \__ -# _--~ _/ | .-~~____--~-/ ~~==. -# ((->/~ '.|||' -_| ~~-/ , . _|| -# -_ ~\ ~~---l__i__i__i--~~_/ -# _-~-__ ~) \--______________--~~ -# //.-~~~-~_--~- |-------~~~~~~~~ -# //.-~~~--\ -# 神兽保佑 -# 永无BUG! -*/ -package com.lunhan.xxx.repository.po; - -import lombok.Data; - -import com.baomidou.mybatisplus.annotation.*; - -import java.io.Serializable; -import java.sql.Timestamp; - -/** - * 定时任务信息 - * @author lin.liu - */ -@Data -@TableName("quartz_task_info") -public class QuartzTaskInfoPO implements Serializable { - /** - * 主键 - */ - private Long id; - /** - * 版本号:需要乐观锁控制 - */ - @TableField(value = "version") - private Long version; - /** - * 任务编号 - */ - @TableField(value = "task_no") - private String taskNo; - /** - * 任务名称 - */ - @TableField(value = "task_name") - private String taskName; - /** - * 定时规则表达式 - */ - @TableField(value = "scheduler_rule") - private String schedulerRule; - /** - * 冻结状态 - */ - @TableField(value = "status") - private Integer status; - /** - * 执行者(job方法名) - */ - @TableField(value = "executor") - private String executor; - /** - * 冻结时间 - */ - @TableField(value = "frozen_time") - private Long frozenTime; - /** - * 解冻时间 - */ - @TableField(value = "unfrozen_time") - private Long unfrozenTime; - /** - * 发送方式 - */ - @TableField(value = "send_type") - private String sendType; - /** - * 请求地址 - */ - @TableField(value = "url") - private String url; - /** - * 执行参数 - */ - @TableField(value = "execute_parameter") - private String executeParameter; - /** - * 上次执行时间 - */ - @TableField(value = "last_time") - private String lastTime; - /** - * 上次执行参数 - */ - @TableField(value = "last_parameter") - private String lastParameter; - /** - * 上次执行结果 - */ - @TableField(value = "last_status") - private Integer lastStatus; - /** - * 数据创建时间 - */ - @TableField(value = "create_time") - private Long createTime; - /** - * 最后更新时间 - */ - @TableField(value = "update_time") - private Timestamp updateTime; - /** - * 是否删除(逻辑删除) - */ - @TableLogic - @TableField(value = "is_delete") - private Integer isDelete; -} diff --git a/src/main/java/com/lunhan/xxx/repository/po/QuartzTaskRecordPO.java b/src/main/java/com/lunhan/xxx/repository/po/QuartzTaskRecordPO.java deleted file mode 100644 index cb59f12..0000000 --- a/src/main/java/com/lunhan/xxx/repository/po/QuartzTaskRecordPO.java +++ /dev/null @@ -1,99 +0,0 @@ -/** -# __----~~~~~~~~~~~------___ -# . . ~~//====...... __--~ ~~ -# -. \_|// |||\\ ~~~~~~::::... /~ -# ___-==_ _-~o~ \/ ||| \\ _/~~- -# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ -# _-~~ .=~ | \\-_ '-~7 /- / || \ / -# .~ .~ | \\ -_ / /- / || \ / -# / ____ / | \\ ~-_/ /|- _/ .|| \ / -# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ -# ' ~-| /| |-~\~~ __--~~ -# |-~~-_/ | | ~\_ _-~ /\ -# / \ \__ \/~ \__ -# _--~ _/ | .-~~____--~-/ ~~==. -# ((->/~ '.|||' -_| ~~-/ , . _|| -# -_ ~\ ~~---l__i__i__i--~~_/ -# _-~-__ ~) \--______________--~~ -# //.-~~~-~_--~- |-------~~~~~~~~ -# //.-~~~--\ -# 神兽保佑 -# 永无BUG! -*/ -package com.lunhan.xxx.repository.po; - -import lombok.Data; - -import com.baomidou.mybatisplus.annotation.*; - -import java.io.Serializable; -import java.sql.Timestamp; - -/** - * 定时任务执行记录 - * @author lin.liu - */ -@Data -@TableName("quartz_task_record") -public class QuartzTaskRecordPO implements Serializable { - /** - * 主键 - */ - private Long id; - /** - * 任务编号 - */ - @TableField(value = "task_no") - private String taskNo; - /** - * 任务名称 - */ - @TableField(value = "task_name") - private String taskName; - /** - * 执行参数 - */ - @TableField(value = "execute_parameter") - private String executeParameter; - /** - * 开始执行时间 - */ - @TableField(value = "start_time") - private Long startTime; - /** - * 执行结束时间 - */ - @TableField(value = "end_time") - private Long endTime; - /** - * 执行耗时(ms) - */ - @TableField(value = "execute_times") - private Long executeTimes; - /** - * 任务状态 - */ - @TableField(value = "task_status") - private Integer taskStatus; - /** - * 失败错误描述 - */ - @TableField(value = "fail_reason") - private String failReason; - /** - * 数据创建时间 - */ - @TableField(value = "create_time") - private Long createTime; - /** - * 最后更新时间 - */ - @TableField(value = "update_time") - private Timestamp updateTime; - /** - * 是否删除(逻辑删除) - */ - @TableLogic - @TableField(value = "is_delete") - private Integer isDelete; -} diff --git a/src/main/java/com/lunhan/xxx/repository/po/SysDictDataPO.java b/src/main/java/com/lunhan/xxx/repository/po/SysDictDataPO.java deleted file mode 100644 index 7db9a0d..0000000 --- a/src/main/java/com/lunhan/xxx/repository/po/SysDictDataPO.java +++ /dev/null @@ -1,84 +0,0 @@ -/** -# __----~~~~~~~~~~~------___ -# . . ~~//====...... __--~ ~~ -# -. \_|// |||\\ ~~~~~~::::... /~ -# ___-==_ _-~o~ \/ ||| \\ _/~~- -# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ -# _-~~ .=~ | \\-_ '-~7 /- / || \ / -# .~ .~ | \\ -_ / /- / || \ / -# / ____ / | \\ ~-_/ /|- _/ .|| \ / -# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ -# ' ~-| /| |-~\~~ __--~~ -# |-~~-_/ | | ~\_ _-~ /\ -# / \ \__ \/~ \__ -# _--~ _/ | .-~~____--~-/ ~~==. -# ((->/~ '.|||' -_| ~~-/ , . _|| -# -_ ~\ ~~---l__i__i__i--~~_/ -# _-~-__ ~) \--______________--~~ -# //.-~~~-~_--~- |-------~~~~~~~~ -# //.-~~~--\ -# 神兽保佑 -# 永无BUG! -*/ -package com.lunhan.xxx.repository.po; - -import lombok.Data; - -import com.baomidou.mybatisplus.annotation.*; - -import java.io.Serializable; -import java.sql.Timestamp; - -/** - * 字典数据 - * @author lin.liu - */ -@Data -@TableName("sys_dict_data") -public class SysDictDataPO implements Serializable { - /** - * 主键 - */ - private Long id; - /** - * 字典标题 - */ - @TableField(value = "dict_label") - private String dictLabel; - /** - * 字典键值 - */ - @TableField(value = "dict_value") - private String dictValue; - /** - * 字典类型 - */ - @TableField(value = "dict_type") - private String dictType; - /** - * 状态 - */ - @TableField(value = "status") - private Integer status; - /** - * 备注 - */ - @TableField(value = "remark") - private String remark; - /** - * 数据创建时间 - */ - @TableField(value = "create_time") - private Long createTime; - /** - * 最后更新时间 - */ - @TableField(value = "update_time") - private Timestamp updateTime; - /** - * 是否删除(逻辑删除) - */ - @TableLogic - @TableField(value = "is_delete") - private Integer isDelete; -} diff --git a/src/main/java/com/lunhan/xxx/repository/po/SysDictTypePO.java b/src/main/java/com/lunhan/xxx/repository/po/SysDictTypePO.java deleted file mode 100644 index 6deafb5..0000000 --- a/src/main/java/com/lunhan/xxx/repository/po/SysDictTypePO.java +++ /dev/null @@ -1,79 +0,0 @@ -/** -# __----~~~~~~~~~~~------___ -# . . ~~//====...... __--~ ~~ -# -. \_|// |||\\ ~~~~~~::::... /~ -# ___-==_ _-~o~ \/ ||| \\ _/~~- -# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ -# _-~~ .=~ | \\-_ '-~7 /- / || \ / -# .~ .~ | \\ -_ / /- / || \ / -# / ____ / | \\ ~-_/ /|- _/ .|| \ / -# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ -# ' ~-| /| |-~\~~ __--~~ -# |-~~-_/ | | ~\_ _-~ /\ -# / \ \__ \/~ \__ -# _--~ _/ | .-~~____--~-/ ~~==. -# ((->/~ '.|||' -_| ~~-/ , . _|| -# -_ ~\ ~~---l__i__i__i--~~_/ -# _-~-__ ~) \--______________--~~ -# //.-~~~-~_--~- |-------~~~~~~~~ -# //.-~~~--\ -# 神兽保佑 -# 永无BUG! -*/ -package com.lunhan.xxx.repository.po; - -import lombok.Data; - -import com.baomidou.mybatisplus.annotation.*; - -import java.io.Serializable; -import java.sql.Timestamp; - -/** - * 字典类型 - * @author lin.liu - */ -@Data -@TableName("sys_dict_type") -public class SysDictTypePO implements Serializable { - /** - * 主键 - */ - private Long id; - /** - * 字典名称 - */ - @TableField(value = "dict_name") - private String dictName; - /** - * 字典类型 - */ - @TableField(value = "dict_type") - private String dictType; - /** - * 状态 - */ - @TableField(value = "status") - private Integer status; - /** - * 备注 - */ - @TableField(value = "remark") - private String remark; - /** - * 数据创建时间 - */ - @TableField(value = "create_time") - private Long createTime; - /** - * 最后更新时间 - */ - @TableField(value = "update_time") - private Timestamp updateTime; - /** - * 是否删除(逻辑删除) - */ - @TableLogic - @TableField(value = "is_delete") - private Integer isDelete; -} diff --git a/src/main/java/com/lunhan/xxx/repository/po/TestInfoPO.java b/src/main/java/com/lunhan/xxx/repository/po/TestInfoPO.java deleted file mode 100644 index dfb62e8..0000000 --- a/src/main/java/com/lunhan/xxx/repository/po/TestInfoPO.java +++ /dev/null @@ -1,105 +0,0 @@ -/** -# __----~~~~~~~~~~~------___ -# . . ~~//====...... __--~ ~~ -# -. \_|// |||\\ ~~~~~~::::... /~ -# ___-==_ _-~o~ \/ ||| \\ _/~~- -# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ -# _-~~ .=~ | \\-_ '-~7 /- / || \ / -# .~ .~ | \\ -_ / /- / || \ / -# / ____ / | \\ ~-_/ /|- _/ .|| \ / -# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ -# ' ~-| /| |-~\~~ __--~~ -# |-~~-_/ | | ~\_ _-~ /\ -# / \ \__ \/~ \__ -# _--~ _/ | .-~~____--~-/ ~~==. -# ((->/~ '.|||' -_| ~~-/ , . _|| -# -_ ~\ ~~---l__i__i__i--~~_/ -# _-~-__ ~) \--______________--~~ -# //.-~~~-~_--~- |-------~~~~~~~~ -# //.-~~~--\ -# 神兽保佑 -# 永无BUG! -*/ -package com.lunhan.xxx.repository.po; - -import lombok.Data; - -import com.baomidou.mybatisplus.annotation.*; - -import java.io.Serializable; -import java.sql.Timestamp; -import java.math.BigDecimal; - -/** - * 测试信息表 - * @author lin.liu - */ -@Data -@TableName("test_info") -public class TestInfoPO implements Serializable { - /** - * 主键 - */ - private Long id; - /** - * 名称 - */ - @TableField(value = "name") - private String name; - /** - * 用户id - */ - @TableField(value = "user_id") - private Long userId; - /** - * 电话 - */ - @TableField(value = "phone") - private String phone; - /** - * balance余额 - */ - @TableField(value = "balance") - private BigDecimal balance; - /** - * 性别 男=1,女=2,其他=3 - */ - @TableField(value = "sex") - private Integer sex; - /** - * 生日 - */ - @TableField(value = "birthday") - private String birthday; - /** - * 排序值 - */ - @TableField(value = "sort") - private Integer sort; - /** - * 状态 EState - */ - @TableField(value = "status") - private Integer status; - /** - * 备注 - */ - @TableField(value = "comment") - private String comment; - /** - * 数据创建时间 - */ - @TableField(value = "create_time") - private Long createTime; - /** - * 最后更新时间 - */ - @TableField(value = "update_time") - private Timestamp updateTime; - /** - * 是否删除(逻辑删除) - */ - @TableLogic - @TableField(value = "is_delete") - private Integer isDelete; -} diff --git a/src/main/java/com/lunhan/xxx/repository/vo/AdminMenuVO.java b/src/main/java/com/lunhan/xxx/repository/vo/AdminMenuVO.java deleted file mode 100644 index 55ef525..0000000 --- a/src/main/java/com/lunhan/xxx/repository/vo/AdminMenuVO.java +++ /dev/null @@ -1,55 +0,0 @@ -/** -# __----~~~~~~~~~~~------___ -# . . ~~//====...... __--~ ~~ -# -. \_|// |||\\ ~~~~~~::::... /~ -# ___-==_ _-~o~ \/ ||| \\ _/~~- -# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ -# _-~~ .=~ | \\-_ '-~7 /- / || \ / -# .~ .~ | \\ -_ / /- / || \ / -# / ____ / | \\ ~-_/ /|- _/ .|| \ / -# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ -# ' ~-| /| |-~\~~ __--~~ -# |-~~-_/ | | ~\_ _-~ /\ -# / \ \__ \/~ \__ -# _--~ _/ | .-~~____--~-/ ~~==. -# ((->/~ '.|||' -_| ~~-/ , . _|| -# -_ ~\ ~~---l__i__i__i--~~_/ -# _-~-__ ~) \--______________--~~ -# //.-~~~-~_--~- |-------~~~~~~~~ -# //.-~~~--\ -# 神兽保佑 -# 永无BUG! -*/ -package com.lunhan.xxx.repository.vo; - -import com.lunhan.xxx.common.util.LocalDateTimeUtil; -import com.lunhan.xxx.common.util.NumericUtil; -import com.lunhan.xxx.repository.po.AdminMenuPO; -import lombok.Data; - -import java.util.Objects; - -/** - * 后台菜单 - * @author lin.liu - * @description 后台菜单 - */ -@Data -public class AdminMenuVO extends AdminMenuPO implements BasicVO { - - @Override - public String getCreateTimeView() { - if (NumericUtil.tryParseLong(this.getCreateTime()).compareTo(0L) > 0) { - return LocalDateTimeUtil.toFormatString(this.getCreateTime()); - } - return ""; - } - - @Override - public String getUpdateTimeView() { - if (Objects.isNull(this.getUpdateTime())) { - return ""; - } - return LocalDateTimeUtil.toFormatFullString(this.getUpdateTime()); - } -} diff --git a/src/main/java/com/lunhan/xxx/repository/vo/AdminMenusVO.java b/src/main/java/com/lunhan/xxx/repository/vo/AdminMenusVO.java deleted file mode 100644 index ac5a19d..0000000 --- a/src/main/java/com/lunhan/xxx/repository/vo/AdminMenusVO.java +++ /dev/null @@ -1,54 +0,0 @@ -/** -# __----~~~~~~~~~~~------___ -# . . ~~//====...... __--~ ~~ -# -. \_|// |||\\ ~~~~~~::::... /~ -# ___-==_ _-~o~ \/ ||| \\ _/~~- -# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ -# _-~~ .=~ | \\-_ '-~7 /- / || \ / -# .~ .~ | \\ -_ / /- / || \ / -# / ____ / | \\ ~-_/ /|- _/ .|| \ / -# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ -# ' ~-| /| |-~\~~ __--~~ -# |-~~-_/ | | ~\_ _-~ /\ -# / \ \__ \/~ \__ -# _--~ _/ | .-~~____--~-/ ~~==. -# ((->/~ '.|||' -_| ~~-/ , . _|| -# -_ ~\ ~~---l__i__i__i--~~_/ -# _-~-__ ~) \--______________--~~ -# //.-~~~-~_--~- |-------~~~~~~~~ -# //.-~~~--\ -# 神兽保佑 -# 永无BUG! -*/ -package com.lunhan.xxx.repository.vo; - -import lombok.Data; - -import com.lunhan.xxx.common.util.LocalDateTimeUtil; -import com.lunhan.xxx.common.util.NumericUtil; -import java.util.Objects; -import com.lunhan.xxx.repository.po.AdminMenusPO; - -/** - * 菜单信息 - * @author lin.liu - */ -@Data -public class AdminMenusVO extends AdminMenusPO implements BasicVO { - - @Override - public String getCreateTimeView() { - if (NumericUtil.tryParseLong(this.getCreateTime()).compareTo(0L) > 0) { - return LocalDateTimeUtil.toFormatString(this.getCreateTime()); - } - return ""; - } - - @Override - public String getUpdateTimeView() { - if (Objects.isNull(this.getUpdateTime())) { - return ""; - } - return LocalDateTimeUtil.toFormatFullString(this.getUpdateTime()); - } -} diff --git a/src/main/java/com/lunhan/xxx/repository/vo/AdminPermissionVO.java b/src/main/java/com/lunhan/xxx/repository/vo/AdminPermissionVO.java deleted file mode 100644 index 4d5be86..0000000 --- a/src/main/java/com/lunhan/xxx/repository/vo/AdminPermissionVO.java +++ /dev/null @@ -1,55 +0,0 @@ -/** -# __----~~~~~~~~~~~------___ -# . . ~~//====...... __--~ ~~ -# -. \_|// |||\\ ~~~~~~::::... /~ -# ___-==_ _-~o~ \/ ||| \\ _/~~- -# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ -# _-~~ .=~ | \\-_ '-~7 /- / || \ / -# .~ .~ | \\ -_ / /- / || \ / -# / ____ / | \\ ~-_/ /|- _/ .|| \ / -# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ -# ' ~-| /| |-~\~~ __--~~ -# |-~~-_/ | | ~\_ _-~ /\ -# / \ \__ \/~ \__ -# _--~ _/ | .-~~____--~-/ ~~==. -# ((->/~ '.|||' -_| ~~-/ , . _|| -# -_ ~\ ~~---l__i__i__i--~~_/ -# _-~-__ ~) \--______________--~~ -# //.-~~~-~_--~- |-------~~~~~~~~ -# //.-~~~--\ -# 神兽保佑 -# 永无BUG! -*/ -package com.lunhan.xxx.repository.vo; - -import com.lunhan.xxx.common.util.LocalDateTimeUtil; -import com.lunhan.xxx.common.util.NumericUtil; -import com.lunhan.xxx.repository.po.AdminPermissionPO; -import lombok.Data; - -import java.util.Objects; - -/** - * 后台用户权限表 - * @author lin.liu - * @description 后台用户权限表 - */ -@Data -public class AdminPermissionVO extends AdminPermissionPO implements BasicVO { - - @Override - public String getCreateTimeView() { - if (NumericUtil.tryParseLong(this.getCreateTime()).compareTo(0L) > 0) { - return LocalDateTimeUtil.toFormatString(this.getCreateTime()); - } - return ""; - } - - @Override - public String getUpdateTimeView() { - if (Objects.isNull(this.getUpdateTime())) { - return ""; - } - return LocalDateTimeUtil.toFormatFullString(this.getUpdateTime()); - } -} diff --git a/src/main/java/com/lunhan/xxx/repository/vo/AdminRoleMenuRelationVO.java b/src/main/java/com/lunhan/xxx/repository/vo/AdminRoleMenuRelationVO.java deleted file mode 100644 index 32ccd48..0000000 --- a/src/main/java/com/lunhan/xxx/repository/vo/AdminRoleMenuRelationVO.java +++ /dev/null @@ -1,55 +0,0 @@ -/** -# __----~~~~~~~~~~~------___ -# . . ~~//====...... __--~ ~~ -# -. \_|// |||\\ ~~~~~~::::... /~ -# ___-==_ _-~o~ \/ ||| \\ _/~~- -# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ -# _-~~ .=~ | \\-_ '-~7 /- / || \ / -# .~ .~ | \\ -_ / /- / || \ / -# / ____ / | \\ ~-_/ /|- _/ .|| \ / -# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ -# ' ~-| /| |-~\~~ __--~~ -# |-~~-_/ | | ~\_ _-~ /\ -# / \ \__ \/~ \__ -# _--~ _/ | .-~~____--~-/ ~~==. -# ((->/~ '.|||' -_| ~~-/ , . _|| -# -_ ~\ ~~---l__i__i__i--~~_/ -# _-~-__ ~) \--______________--~~ -# //.-~~~-~_--~- |-------~~~~~~~~ -# //.-~~~--\ -# 神兽保佑 -# 永无BUG! -*/ -package com.lunhan.xxx.repository.vo; - -import com.lunhan.xxx.common.util.LocalDateTimeUtil; -import com.lunhan.xxx.common.util.NumericUtil; -import com.lunhan.xxx.repository.po.AdminRoleMenuRelationPO; -import lombok.Data; - -import java.util.Objects; - -/** - * 后台角色菜单关系表 - * @author lin.liu - * @description 后台角色菜单关系表 - */ -@Data -public class AdminRoleMenuRelationVO extends AdminRoleMenuRelationPO implements BasicVO { - - @Override - public String getCreateTimeView() { - if (NumericUtil.tryParseLong(this.getCreateTime()).compareTo(0L) > 0) { - return LocalDateTimeUtil.toFormatString(this.getCreateTime()); - } - return ""; - } - - @Override - public String getUpdateTimeView() { - if (Objects.isNull(this.getUpdateTime())) { - return ""; - } - return LocalDateTimeUtil.toFormatFullString(this.getUpdateTime()); - } -} diff --git a/src/main/java/com/lunhan/xxx/repository/vo/AdminRolePermissionRelationVO.java b/src/main/java/com/lunhan/xxx/repository/vo/AdminRolePermissionRelationVO.java deleted file mode 100644 index 902ecee..0000000 --- a/src/main/java/com/lunhan/xxx/repository/vo/AdminRolePermissionRelationVO.java +++ /dev/null @@ -1,55 +0,0 @@ -/** -# __----~~~~~~~~~~~------___ -# . . ~~//====...... __--~ ~~ -# -. \_|// |||\\ ~~~~~~::::... /~ -# ___-==_ _-~o~ \/ ||| \\ _/~~- -# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ -# _-~~ .=~ | \\-_ '-~7 /- / || \ / -# .~ .~ | \\ -_ / /- / || \ / -# / ____ / | \\ ~-_/ /|- _/ .|| \ / -# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ -# ' ~-| /| |-~\~~ __--~~ -# |-~~-_/ | | ~\_ _-~ /\ -# / \ \__ \/~ \__ -# _--~ _/ | .-~~____--~-/ ~~==. -# ((->/~ '.|||' -_| ~~-/ , . _|| -# -_ ~\ ~~---l__i__i__i--~~_/ -# _-~-__ ~) \--______________--~~ -# //.-~~~-~_--~- |-------~~~~~~~~ -# //.-~~~--\ -# 神兽保佑 -# 永无BUG! -*/ -package com.lunhan.xxx.repository.vo; - -import com.lunhan.xxx.common.util.LocalDateTimeUtil; -import com.lunhan.xxx.common.util.NumericUtil; -import com.lunhan.xxx.repository.po.AdminRolePermissionRelationPO; -import lombok.Data; - -import java.util.Objects; - -/** - * 后台角色权限关系表 - * @author lin.liu - * @description 后台角色权限关系表 - */ -@Data -public class AdminRolePermissionRelationVO extends AdminRolePermissionRelationPO implements BasicVO { - - @Override - public String getCreateTimeView() { - if (NumericUtil.tryParseLong(this.getCreateTime()).compareTo(0L) > 0) { - return LocalDateTimeUtil.toFormatString(this.getCreateTime()); - } - return ""; - } - - @Override - public String getUpdateTimeView() { - if (Objects.isNull(this.getUpdateTime())) { - return ""; - } - return LocalDateTimeUtil.toFormatFullString(this.getUpdateTime()); - } -} diff --git a/src/main/java/com/lunhan/xxx/repository/vo/AdminRoleRelationVO.java b/src/main/java/com/lunhan/xxx/repository/vo/AdminRoleRelationVO.java deleted file mode 100644 index 0b5b0a6..0000000 --- a/src/main/java/com/lunhan/xxx/repository/vo/AdminRoleRelationVO.java +++ /dev/null @@ -1,55 +0,0 @@ -/** -# __----~~~~~~~~~~~------___ -# . . ~~//====...... __--~ ~~ -# -. \_|// |||\\ ~~~~~~::::... /~ -# ___-==_ _-~o~ \/ ||| \\ _/~~- -# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ -# _-~~ .=~ | \\-_ '-~7 /- / || \ / -# .~ .~ | \\ -_ / /- / || \ / -# / ____ / | \\ ~-_/ /|- _/ .|| \ / -# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ -# ' ~-| /| |-~\~~ __--~~ -# |-~~-_/ | | ~\_ _-~ /\ -# / \ \__ \/~ \__ -# _--~ _/ | .-~~____--~-/ ~~==. -# ((->/~ '.|||' -_| ~~-/ , . _|| -# -_ ~\ ~~---l__i__i__i--~~_/ -# _-~-__ ~) \--______________--~~ -# //.-~~~-~_--~- |-------~~~~~~~~ -# //.-~~~--\ -# 神兽保佑 -# 永无BUG! -*/ -package com.lunhan.xxx.repository.vo; - -import com.lunhan.xxx.common.util.LocalDateTimeUtil; -import com.lunhan.xxx.common.util.NumericUtil; -import com.lunhan.xxx.repository.po.AdminRoleRelationPO; -import lombok.Data; - -import java.util.Objects; - -/** - * 后台用户和角色关系表 - * @author lin.liu - * @description 后台用户和角色关系表 - */ -@Data -public class AdminRoleRelationVO extends AdminRoleRelationPO implements BasicVO { - - @Override - public String getCreateTimeView() { - if (NumericUtil.tryParseLong(this.getCreateTime()).compareTo(0L) > 0) { - return LocalDateTimeUtil.toFormatString(this.getCreateTime()); - } - return ""; - } - - @Override - public String getUpdateTimeView() { - if (Objects.isNull(this.getUpdateTime())) { - return ""; - } - return LocalDateTimeUtil.toFormatFullString(this.getUpdateTime()); - } -} diff --git a/src/main/java/com/lunhan/xxx/repository/vo/AdminRoleVO.java b/src/main/java/com/lunhan/xxx/repository/vo/AdminRoleVO.java deleted file mode 100644 index 8cd2807..0000000 --- a/src/main/java/com/lunhan/xxx/repository/vo/AdminRoleVO.java +++ /dev/null @@ -1,55 +0,0 @@ -/** -# __----~~~~~~~~~~~------___ -# . . ~~//====...... __--~ ~~ -# -. \_|// |||\\ ~~~~~~::::... /~ -# ___-==_ _-~o~ \/ ||| \\ _/~~- -# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ -# _-~~ .=~ | \\-_ '-~7 /- / || \ / -# .~ .~ | \\ -_ / /- / || \ / -# / ____ / | \\ ~-_/ /|- _/ .|| \ / -# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ -# ' ~-| /| |-~\~~ __--~~ -# |-~~-_/ | | ~\_ _-~ /\ -# / \ \__ \/~ \__ -# _--~ _/ | .-~~____--~-/ ~~==. -# ((->/~ '.|||' -_| ~~-/ , . _|| -# -_ ~\ ~~---l__i__i__i--~~_/ -# _-~-__ ~) \--______________--~~ -# //.-~~~-~_--~- |-------~~~~~~~~ -# //.-~~~--\ -# 神兽保佑 -# 永无BUG! -*/ -package com.lunhan.xxx.repository.vo; - -import com.lunhan.xxx.common.util.LocalDateTimeUtil; -import com.lunhan.xxx.common.util.NumericUtil; -import com.lunhan.xxx.repository.po.AdminRolePO; -import lombok.Data; - -import java.util.Objects; - -/** - * 后台用户角色表 - * @author lin.liu - * @description 后台用户角色表 - */ -@Data -public class AdminRoleVO extends AdminRolePO implements BasicVO { - - @Override - public String getCreateTimeView() { - if (NumericUtil.tryParseLong(this.getCreateTime()).compareTo(0L) > 0) { - return LocalDateTimeUtil.toFormatString(this.getCreateTime()); - } - return ""; - } - - @Override - public String getUpdateTimeView() { - if (Objects.isNull(this.getUpdateTime())) { - return ""; - } - return LocalDateTimeUtil.toFormatFullString(this.getUpdateTime()); - } -} diff --git a/src/main/java/com/lunhan/xxx/repository/vo/AdminUserVO.java b/src/main/java/com/lunhan/xxx/repository/vo/AdminUserVO.java deleted file mode 100644 index 438cbf8..0000000 --- a/src/main/java/com/lunhan/xxx/repository/vo/AdminUserVO.java +++ /dev/null @@ -1,62 +0,0 @@ -/** -# __----~~~~~~~~~~~------___ -# . . ~~//====...... __--~ ~~ -# -. \_|// |||\\ ~~~~~~::::... /~ -# ___-==_ _-~o~ \/ ||| \\ _/~~- -# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ -# _-~~ .=~ | \\-_ '-~7 /- / || \ / -# .~ .~ | \\ -_ / /- / || \ / -# / ____ / | \\ ~-_/ /|- _/ .|| \ / -# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ -# ' ~-| /| |-~\~~ __--~~ -# |-~~-_/ | | ~\_ _-~ /\ -# / \ \__ \/~ \__ -# _--~ _/ | .-~~____--~-/ ~~==. -# ((->/~ '.|||' -_| ~~-/ , . _|| -# -_ ~\ ~~---l__i__i__i--~~_/ -# _-~-__ ~) \--______________--~~ -# //.-~~~-~_--~- |-------~~~~~~~~ -# //.-~~~--\ -# 神兽保佑 -# 永无BUG! -*/ -package com.lunhan.xxx.repository.vo; - -import com.lunhan.xxx.common.util.LocalDateTimeUtil; -import com.lunhan.xxx.common.util.NumericUtil; -import com.lunhan.xxx.entity.enums.EUserType; -import com.lunhan.xxx.repository.po.AdminUserPO; -import lombok.Data; - -import java.util.Objects; - -/** - * 管理员帐号 - * @author lin.liu - * @description 管理员帐号 - */ -@Data -public class AdminUserVO extends AdminUserPO implements BasicVO { - - @Override - public String getCreateTimeView() { - if (NumericUtil.tryParseLong(this.getCreateTime()).compareTo(0L) > 0) { - return LocalDateTimeUtil.toFormatString(this.getCreateTime()); - } - return ""; - } - - @Override - public String getUpdateTimeView() { - if (Objects.isNull(this.getUpdateTime())) { - return ""; - } - return LocalDateTimeUtil.toFormatFullString(this.getUpdateTime()); - } - public String getUserTypeView() { - if (Objects.isNull(this.getUserType())) { - return ""; - } - return EUserType.getByValue(this.getUserType()).getDesc(); - } -} diff --git a/src/main/java/com/lunhan/xxx/repository/vo/BasicVO.java b/src/main/java/com/lunhan/xxx/repository/vo/BasicVO.java deleted file mode 100644 index 5a31afa..0000000 --- a/src/main/java/com/lunhan/xxx/repository/vo/BasicVO.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.lunhan.xxx.repository.vo; - - -public interface BasicVO { - /** - * 创建时间展示 - */ - String getCreateTimeView(); - /** - * 数据最后更新时间展示 - */ - String getUpdateTimeView(); -} diff --git a/src/main/java/com/lunhan/xxx/repository/vo/NoticeVO.java b/src/main/java/com/lunhan/xxx/repository/vo/NoticeVO.java deleted file mode 100644 index 59af2f7..0000000 --- a/src/main/java/com/lunhan/xxx/repository/vo/NoticeVO.java +++ /dev/null @@ -1,55 +0,0 @@ -/** -# __----~~~~~~~~~~~------___ -# . . ~~//====...... __--~ ~~ -# -. \_|// |||\\ ~~~~~~::::... /~ -# ___-==_ _-~o~ \/ ||| \\ _/~~- -# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ -# _-~~ .=~ | \\-_ '-~7 /- / || \ / -# .~ .~ | \\ -_ / /- / || \ / -# / ____ / | \\ ~-_/ /|- _/ .|| \ / -# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ -# ' ~-| /| |-~\~~ __--~~ -# |-~~-_/ | | ~\_ _-~ /\ -# / \ \__ \/~ \__ -# _--~ _/ | .-~~____--~-/ ~~==. -# ((->/~ '.|||' -_| ~~-/ , . _|| -# -_ ~\ ~~---l__i__i__i--~~_/ -# _-~-__ ~) \--______________--~~ -# //.-~~~-~_--~- |-------~~~~~~~~ -# //.-~~~--\ -# 神兽保佑 -# 永无BUG! -*/ -package com.lunhan.xxx.repository.vo; - -import com.lunhan.xxx.common.util.LocalDateTimeUtil; -import com.lunhan.xxx.common.util.NumericUtil; -import com.lunhan.xxx.repository.bo.NoticeBO; -import lombok.Data; - -import java.util.Objects; - -/** - * 公告 - * @author lin.liu - * @description 公告 - */ -@Data -public class NoticeVO extends NoticeBO implements BasicVO { - - @Override - public String getCreateTimeView() { - if (NumericUtil.tryParseLong(this.getCreateTime()).compareTo(0L) > 0) { - return LocalDateTimeUtil.toFormatString(this.getCreateTime()); - } - return ""; - } - - @Override - public String getUpdateTimeView() { - if (Objects.isNull(this.getUpdateTime())) { - return ""; - } - return LocalDateTimeUtil.toFormatFullString(this.getUpdateTime()); - } -} diff --git a/src/main/java/com/lunhan/xxx/repository/vo/QuartzTaskErrorVO.java b/src/main/java/com/lunhan/xxx/repository/vo/QuartzTaskErrorVO.java deleted file mode 100644 index 6966179..0000000 --- a/src/main/java/com/lunhan/xxx/repository/vo/QuartzTaskErrorVO.java +++ /dev/null @@ -1,55 +0,0 @@ -/** -# __----~~~~~~~~~~~------___ -# . . ~~//====...... __--~ ~~ -# -. \_|// |||\\ ~~~~~~::::... /~ -# ___-==_ _-~o~ \/ ||| \\ _/~~- -# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ -# _-~~ .=~ | \\-_ '-~7 /- / || \ / -# .~ .~ | \\ -_ / /- / || \ / -# / ____ / | \\ ~-_/ /|- _/ .|| \ / -# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ -# ' ~-| /| |-~\~~ __--~~ -# |-~~-_/ | | ~\_ _-~ /\ -# / \ \__ \/~ \__ -# _--~ _/ | .-~~____--~-/ ~~==. -# ((->/~ '.|||' -_| ~~-/ , . _|| -# -_ ~\ ~~---l__i__i__i--~~_/ -# _-~-__ ~) \--______________--~~ -# //.-~~~-~_--~- |-------~~~~~~~~ -# //.-~~~--\ -# 神兽保佑 -# 永无BUG! -*/ -package com.lunhan.xxx.repository.vo; - -import com.lunhan.xxx.common.util.LocalDateTimeUtil; -import com.lunhan.xxx.common.util.NumericUtil; -import com.lunhan.xxx.repository.po.QuartzTaskErrorPO; -import lombok.Data; - -import java.util.Objects; - -/** - * 定时任务错误信息 - * @author lin.liu - * @description 定时任务错误信息 - */ -@Data -public class QuartzTaskErrorVO extends QuartzTaskErrorPO implements BasicVO { - - @Override - public String getCreateTimeView() { - if (NumericUtil.tryParseLong(this.getCreateTime()).compareTo(0L) > 0) { - return LocalDateTimeUtil.toFormatString(this.getCreateTime()); - } - return ""; - } - - @Override - public String getUpdateTimeView() { - if (Objects.isNull(this.getUpdateTime())) { - return ""; - } - return LocalDateTimeUtil.toFormatFullString(this.getUpdateTime()); - } -} diff --git a/src/main/java/com/lunhan/xxx/repository/vo/QuartzTaskInfoVO.java b/src/main/java/com/lunhan/xxx/repository/vo/QuartzTaskInfoVO.java deleted file mode 100644 index ed24203..0000000 --- a/src/main/java/com/lunhan/xxx/repository/vo/QuartzTaskInfoVO.java +++ /dev/null @@ -1,55 +0,0 @@ -/** -# __----~~~~~~~~~~~------___ -# . . ~~//====...... __--~ ~~ -# -. \_|// |||\\ ~~~~~~::::... /~ -# ___-==_ _-~o~ \/ ||| \\ _/~~- -# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ -# _-~~ .=~ | \\-_ '-~7 /- / || \ / -# .~ .~ | \\ -_ / /- / || \ / -# / ____ / | \\ ~-_/ /|- _/ .|| \ / -# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ -# ' ~-| /| |-~\~~ __--~~ -# |-~~-_/ | | ~\_ _-~ /\ -# / \ \__ \/~ \__ -# _--~ _/ | .-~~____--~-/ ~~==. -# ((->/~ '.|||' -_| ~~-/ , . _|| -# -_ ~\ ~~---l__i__i__i--~~_/ -# _-~-__ ~) \--______________--~~ -# //.-~~~-~_--~- |-------~~~~~~~~ -# //.-~~~--\ -# 神兽保佑 -# 永无BUG! -*/ -package com.lunhan.xxx.repository.vo; - -import com.lunhan.xxx.common.util.LocalDateTimeUtil; -import com.lunhan.xxx.common.util.NumericUtil; -import com.lunhan.xxx.repository.po.QuartzTaskInfoPO; -import lombok.Data; - -import java.util.Objects; - -/** - * 定时任务信息 - * @author lin.liu - * @description 定时任务信息 - */ -@Data -public class QuartzTaskInfoVO extends QuartzTaskInfoPO implements BasicVO { - - @Override - public String getCreateTimeView() { - if (NumericUtil.tryParseLong(this.getCreateTime()).compareTo(0L) > 0) { - return LocalDateTimeUtil.toFormatString(this.getCreateTime()); - } - return ""; - } - - @Override - public String getUpdateTimeView() { - if (Objects.isNull(this.getUpdateTime())) { - return ""; - } - return LocalDateTimeUtil.toFormatFullString(this.getUpdateTime()); - } -} diff --git a/src/main/java/com/lunhan/xxx/repository/vo/QuartzTaskRecordVO.java b/src/main/java/com/lunhan/xxx/repository/vo/QuartzTaskRecordVO.java deleted file mode 100644 index 84309ed..0000000 --- a/src/main/java/com/lunhan/xxx/repository/vo/QuartzTaskRecordVO.java +++ /dev/null @@ -1,62 +0,0 @@ -/** -# __----~~~~~~~~~~~------___ -# . . ~~//====...... __--~ ~~ -# -. \_|// |||\\ ~~~~~~::::... /~ -# ___-==_ _-~o~ \/ ||| \\ _/~~- -# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ -# _-~~ .=~ | \\-_ '-~7 /- / || \ / -# .~ .~ | \\ -_ / /- / || \ / -# / ____ / | \\ ~-_/ /|- _/ .|| \ / -# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ -# ' ~-| /| |-~\~~ __--~~ -# |-~~-_/ | | ~\_ _-~ /\ -# / \ \__ \/~ \__ -# _--~ _/ | .-~~____--~-/ ~~==. -# ((->/~ '.|||' -_| ~~-/ , . _|| -# -_ ~\ ~~---l__i__i__i--~~_/ -# _-~-__ ~) \--______________--~~ -# //.-~~~-~_--~- |-------~~~~~~~~ -# //.-~~~--\ -# 神兽保佑 -# 永无BUG! -*/ -package com.lunhan.xxx.repository.vo; - -import com.lunhan.xxx.common.util.LocalDateTimeUtil; -import com.lunhan.xxx.common.util.NumericUtil; -import com.lunhan.xxx.repository.po.QuartzTaskRecordPO; -import lombok.Data; - -import java.util.Objects; - -/** - * 定时任务执行记录 - * @author lin.liu - * @description 定时任务执行记录 - */ -@Data -public class QuartzTaskRecordVO extends QuartzTaskRecordPO implements BasicVO { - - @Override - public String getCreateTimeView() { - if (NumericUtil.tryParseLong(this.getCreateTime()).compareTo(0L) > 0) { - return LocalDateTimeUtil.toFormatString(this.getCreateTime()); - } - return ""; - } - - @Override - public String getUpdateTimeView() { - if (Objects.isNull(this.getUpdateTime())) { - return ""; - } - return LocalDateTimeUtil.toFormatFullString(this.getUpdateTime()); - } - - public String getStartTimeView() { - if (NumericUtil.tryParseLong(this.getStartTime()).compareTo(0L) > 0) { - return LocalDateTimeUtil.toFormatString(this.getStartTime()); - } - return ""; - } -} diff --git a/src/main/java/com/lunhan/xxx/repository/vo/SysDictDataVO.java b/src/main/java/com/lunhan/xxx/repository/vo/SysDictDataVO.java deleted file mode 100644 index 116c7f6..0000000 --- a/src/main/java/com/lunhan/xxx/repository/vo/SysDictDataVO.java +++ /dev/null @@ -1,60 +0,0 @@ -/** -# __----~~~~~~~~~~~------___ -# . . ~~//====...... __--~ ~~ -# -. \_|// |||\\ ~~~~~~::::... /~ -# ___-==_ _-~o~ \/ ||| \\ _/~~- -# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ -# _-~~ .=~ | \\-_ '-~7 /- / || \ / -# .~ .~ | \\ -_ / /- / || \ / -# / ____ / | \\ ~-_/ /|- _/ .|| \ / -# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ -# ' ~-| /| |-~\~~ __--~~ -# |-~~-_/ | | ~\_ _-~ /\ -# / \ \__ \/~ \__ -# _--~ _/ | .-~~____--~-/ ~~==. -# ((->/~ '.|||' -_| ~~-/ , . _|| -# -_ ~\ ~~---l__i__i__i--~~_/ -# _-~-__ ~) \--______________--~~ -# //.-~~~-~_--~- |-------~~~~~~~~ -# //.-~~~--\ -# 神兽保佑 -# 永无BUG! -*/ -package com.lunhan.xxx.repository.vo; - -import com.lunhan.xxx.common.util.LocalDateTimeUtil; -import com.lunhan.xxx.common.util.NumericUtil; -import com.lunhan.xxx.repository.po.SysDictDataPO; -import lombok.Data; - -import java.util.Objects; - -/** - * 字典数据表 - * @author lin.liu - * @description 字典数据表 - */ -@Data -public class SysDictDataVO extends SysDictDataPO implements BasicVO { - - @Override - public String getCreateTimeView() { - if (NumericUtil.tryParseLong(this.getCreateTime()).compareTo(0L) > 0) { - return LocalDateTimeUtil.toFormatString(this.getCreateTime()); - } - return ""; - } - - @Override - public String getUpdateTimeView() { - if (Objects.isNull(this.getUpdateTime())) { - return ""; - } - return LocalDateTimeUtil.toFormatFullString(this.getUpdateTime()); - } - - /** - * 字典类型名称 - */ - public String dictTypeTxt; -} diff --git a/src/main/java/com/lunhan/xxx/repository/vo/SysDictTypeVO.java b/src/main/java/com/lunhan/xxx/repository/vo/SysDictTypeVO.java deleted file mode 100644 index 20db3e7..0000000 --- a/src/main/java/com/lunhan/xxx/repository/vo/SysDictTypeVO.java +++ /dev/null @@ -1,55 +0,0 @@ -/** -# __----~~~~~~~~~~~------___ -# . . ~~//====...... __--~ ~~ -# -. \_|// |||\\ ~~~~~~::::... /~ -# ___-==_ _-~o~ \/ ||| \\ _/~~- -# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ -# _-~~ .=~ | \\-_ '-~7 /- / || \ / -# .~ .~ | \\ -_ / /- / || \ / -# / ____ / | \\ ~-_/ /|- _/ .|| \ / -# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ -# ' ~-| /| |-~\~~ __--~~ -# |-~~-_/ | | ~\_ _-~ /\ -# / \ \__ \/~ \__ -# _--~ _/ | .-~~____--~-/ ~~==. -# ((->/~ '.|||' -_| ~~-/ , . _|| -# -_ ~\ ~~---l__i__i__i--~~_/ -# _-~-__ ~) \--______________--~~ -# //.-~~~-~_--~- |-------~~~~~~~~ -# //.-~~~--\ -# 神兽保佑 -# 永无BUG! -*/ -package com.lunhan.xxx.repository.vo; - -import com.lunhan.xxx.common.util.LocalDateTimeUtil; -import com.lunhan.xxx.common.util.NumericUtil; -import com.lunhan.xxx.repository.po.SysDictTypePO; -import lombok.Data; - -import java.util.Objects; - -/** - * 字典类型表 - * @author lin.liu - * @description 字典类型表 - */ -@Data -public class SysDictTypeVO extends SysDictTypePO implements BasicVO { - - @Override - public String getCreateTimeView() { - if (NumericUtil.tryParseLong(this.getCreateTime()).compareTo(0L) > 0) { - return LocalDateTimeUtil.toFormatString(this.getCreateTime()); - } - return ""; - } - - @Override - public String getUpdateTimeView() { - if (Objects.isNull(this.getUpdateTime())) { - return ""; - } - return LocalDateTimeUtil.toFormatFullString(this.getUpdateTime()); - } -} diff --git a/src/main/java/com/lunhan/xxx/repository/vo/TestInfoVO.java b/src/main/java/com/lunhan/xxx/repository/vo/TestInfoVO.java deleted file mode 100644 index fcde1c8..0000000 --- a/src/main/java/com/lunhan/xxx/repository/vo/TestInfoVO.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.lunhan.xxx.repository.vo; - -import com.lunhan.xxx.common.util.LocalDateTimeUtil; -import com.lunhan.xxx.common.util.NumericUtil; -import com.lunhan.xxx.repository.po.TestInfoPO; - -import java.util.Objects; - -public class TestInfoVO extends TestInfoPO implements BasicVO { - @Override - public String getCreateTimeView() { - if (NumericUtil.tryParseLong(this.getCreateTime()).compareTo(0L) > 0) { - return LocalDateTimeUtil.toFormatString(this.getCreateTime()); - } - return ""; - } - - @Override - public String getUpdateTimeView() { - if (Objects.isNull(this.getUpdateTime())) { - return ""; - } - return LocalDateTimeUtil.toFormatFullString(this.getUpdateTime()); - } -} diff --git a/src/main/java/com/lunhan/xxx/service/AdminMenuService.java b/src/main/java/com/lunhan/xxx/service/AdminMenuService.java deleted file mode 100644 index 1486a03..0000000 --- a/src/main/java/com/lunhan/xxx/service/AdminMenuService.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.lunhan.xxx.service; - -import com.lunhan.xxx.repository.impl.AdminMenuMapperImpl; -import com.lunhan.xxx.repository.po.AdminMenuPO; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.cache.annotation.CacheEvict; -import org.springframework.cache.annotation.Cacheable; -import org.springframework.stereotype.Service; - -import java.util.List; -import java.util.function.Function; - -@Service -public class AdminMenuService { - @Autowired - private AdminMenuMapperImpl dao; - - /** - * 获取所有菜单(缓存) - */ - //@Cacheable(cacheManager = "json4RedisCacheManager",value = "userCache", key = "#id") - //@Cacheable(cacheManager = "json4RedisCacheManager",value = "userCache", key = "#user.id") - @Cacheable(cacheManager = "json4RedisCacheManager", value = "adminMenusCache") - public List<AdminMenuPO> listAllWithCache() { - return dao.getList(); - } - - // 删除菜单缓存 - @CacheEvict(cacheNames = "adminMenusCache", allEntries = true) - public void removeListAllCache() { - } - - - /** - * 获取用户拥有的菜单(缓存) - */ - @Cacheable(cacheManager = "json4RedisCacheManager", value = "userMenusCache", key = "#id") - public List<AdminMenuPO> listUserAllWithCache(Long id, List<Long> listRoleId, Function<List<Long>, List<AdminMenuPO>> funcGetUserMenu) { - return funcGetUserMenu.apply(listRoleId); - } - // 删除指定用户拥有的菜单缓存 - @CacheEvict(cacheNames = "userMenusCache", key = "#id") - public void removeUserMenuCache(Long id) { - } - // 删除所有用户拥有的菜单缓存 - @CacheEvict(cacheNames = "userMenusCache", allEntries = true) - public void removeAllUserMenuCache() { - } -} diff --git a/src/main/java/com/lunhan/xxx/service/AdminPermissionService.java b/src/main/java/com/lunhan/xxx/service/AdminPermissionService.java deleted file mode 100644 index 5659259..0000000 --- a/src/main/java/com/lunhan/xxx/service/AdminPermissionService.java +++ /dev/null @@ -1,118 +0,0 @@ -package com.lunhan.xxx.service; - -import com.lunhan.xxx.common.enums.EYesOrNo; -import com.lunhan.xxx.common.util.LocalDateTimeUtil; -import com.lunhan.xxx.entity.enums.EMenuType; -import com.lunhan.xxx.entity.enums.EOperation; -import com.lunhan.xxx.entity.enums.EState; -import com.lunhan.xxx.repository.impl.AdminPermissionMapperImpl; -import com.lunhan.xxx.repository.po.AdminMenuPO; -import com.lunhan.xxx.repository.po.AdminPermissionPO; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.cache.annotation.CacheEvict; -import org.springframework.cache.annotation.Cacheable; -import org.springframework.stereotype.Service; - -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; -import java.util.function.Function; - -@Service -public class AdminPermissionService { - @Autowired - private AdminPermissionMapperImpl dao; - - /** - * 获取所有权限(缓存) - */ - //@Cacheable(cacheManager = "json4RedisCacheManager",value = "userCache", key = "#id") - //@Cacheable(cacheManager = "json4RedisCacheManager",value = "userCache", key = "#user.id") - @Cacheable(cacheManager = "json4RedisCacheManager", value = "adminPermissionCache") - public List<AdminPermissionPO> listAllWithCache() { - return dao.getList(); - } - - // 删除权限缓存 - @CacheEvict(cacheNames = "adminPermissionCache", allEntries = true) - public void removeListAllCache() { - } - - /** - * 获取用户拥有的权限(缓存) - */ - @Cacheable(cacheManager = "json4RedisCacheManager", value = "userPermissionCache", key = "#id") - public List<AdminPermissionPO> listUserAllWithCache(Long id, List<Long> listRoleId, Function<List<Long>, List<AdminPermissionPO>> funcGetUserPermission) { - return funcGetUserPermission.apply(listRoleId); - } - // 删除指定用户拥有的权限缓存 - @CacheEvict(cacheNames = "userPermissionCache", key = "#id") - public void removeUserCache(Long id) { - } - // 删除所有用户拥有的权限缓存 - @CacheEvict(cacheNames = "userPermissionCache", allEntries = true) - public void removeAllUserCache() { - } - - /** - * 给菜单添加默认权限 - * @param menu 菜单信息 - */ - public void createDefaultPermission(AdminMenuPO menu) { - if (!Objects.equals(menu.getType(), EMenuType.PAGE.getValue())) { - return; - } - Long now = LocalDateTimeUtil.nowTimeStamp(); - List<AdminPermissionPO> list = new ArrayList<>(); - - AdminPermissionPO item1 = new AdminPermissionPO(); - item1.setSn(menu.getUrl().replaceAll("/", "") + "." + EOperation.LIST.getValue()); - item1.setMenuId(menu.getId()); - item1.setMenuUrl(menu.getUrl()); - item1.setName(menu.getName() + "." + EOperation.LIST.getDesc()); - item1.setIcon(""); - item1.setType(EOperation.LIST.getValue()); - item1.setStatus(EState.NORMAL.getValue()); - item1.setCreateTime(now); - item1.setIsDelete(EYesOrNo.NO.getValue()); - list.add(item1); - - AdminPermissionPO item2 = new AdminPermissionPO(); - item2.setSn(menu.getUrl().replaceAll("/", "") + "." + EOperation.ADD.getValue()); - item2.setMenuId(menu.getId()); - item2.setMenuUrl(menu.getUrl()); - item2.setName(menu.getName() + "." + EOperation.ADD.getDesc()); - item2.setIcon(""); - item2.setType(EOperation.ADD.getValue()); - item2.setStatus(EState.NORMAL.getValue()); - item2.setCreateTime(now); - item2.setIsDelete(EYesOrNo.NO.getValue()); - list.add(item2); - - AdminPermissionPO item3 = new AdminPermissionPO(); - item3.setSn(menu.getUrl().replaceAll("/", "") + "." + EOperation.UPDATE.getValue()); - item3.setMenuId(menu.getId()); - item3.setMenuUrl(menu.getUrl()); - item3.setName(menu.getName() + "." + EOperation.UPDATE.getDesc()); - item3.setIcon(""); - item3.setType(EOperation.UPDATE.getValue()); - item3.setStatus(EState.NORMAL.getValue()); - item3.setCreateTime(now); - item3.setIsDelete(EYesOrNo.NO.getValue()); - list.add(item3); - - AdminPermissionPO item4 = new AdminPermissionPO(); - item4.setSn(menu.getUrl().replaceAll("/", "") + "." + EOperation.DETAIL.getValue()); - item4.setMenuId(menu.getId()); - item4.setMenuUrl(menu.getUrl()); - item4.setName(menu.getName() + "." + EOperation.DETAIL.getDesc()); - item4.setIcon(""); - item4.setType(EOperation.DETAIL.getValue()); - item4.setStatus(EState.NORMAL.getValue()); - item4.setCreateTime(now); - item4.setIsDelete(EYesOrNo.NO.getValue()); - list.add(item4); - - dao.insert(list); - } -} diff --git a/src/main/java/com/lunhan/xxx/service/AdminPowerService.java b/src/main/java/com/lunhan/xxx/service/AdminPowerService.java deleted file mode 100644 index 3cd52b5..0000000 --- a/src/main/java/com/lunhan/xxx/service/AdminPowerService.java +++ /dev/null @@ -1,867 +0,0 @@ -package com.lunhan.xxx.service; - -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.lunhan.xxx.common.ExecutedResult; -import com.lunhan.xxx.common.PagerResult; -import com.lunhan.xxx.common.model.Tuple; -import com.lunhan.xxx.common.util.*; -import com.lunhan.xxx.entity.enums.EState; -import com.lunhan.xxx.entity.request.ReqListSetSort; -import com.lunhan.xxx.entity.request.ReqSetSort; -import com.lunhan.xxx.entity.request.adminmenu.ReqCreateAdminMenu; -import com.lunhan.xxx.entity.request.adminmenu.ReqModifyAdminMenu; -import com.lunhan.xxx.entity.request.adminpermission.ReqCreateAdminPermission; -import com.lunhan.xxx.entity.request.adminpermission.ReqModifyAdminPermission; -import com.lunhan.xxx.entity.request.adminrole.ReqCreateAdminRole; -import com.lunhan.xxx.entity.request.adminrole.ReqModifyAdminRole; -import com.lunhan.xxx.entity.request.adminrolemenurelation.ReqSetListMenu4Role; -import com.lunhan.xxx.entity.response.admin.ResAdminMenuTreeAndPermission; -import com.lunhan.xxx.entity.response.admin.ResAdminPermission; -import com.lunhan.xxx.entity.response.admin.ResAdminPower; -import com.lunhan.xxx.entity.search.SearchAdminMenu; -import com.lunhan.xxx.entity.search.SearchAdminPermission; -import com.lunhan.xxx.entity.search.SearchAdminRole; -import com.lunhan.xxx.repository.impl.*; -import com.lunhan.xxx.repository.po.*; -import com.lunhan.xxx.repository.vo.AdminMenuVO; -import com.lunhan.xxx.repository.vo.AdminRoleVO; -import com.lunhan.xxx.service.convert.AdminMenuConvert; -import com.lunhan.xxx.service.convert.AdminPermissionConvert; -import com.lunhan.xxx.service.convert.AdminRoleConvert; -import org.apache.commons.lang3.BooleanUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import java.util.*; -import java.util.stream.Collectors; - -@Service -public class AdminPowerService extends BaseService { - @Autowired - private AdminMenuMapperImpl menusDao; - @Autowired - private AdminPermissionMapperImpl permissionDao; - @Autowired - private AdminRoleMapperImpl roleDao; - @Autowired - private AdminRoleMenuRelationMapperImpl roleMenuRelationDao; - @Autowired - private AdminRolePermissionRelationMapperImpl rolePermissionRelationDao; - @Autowired - private AdminRoleRelationMapperImpl adminRoleRelationDao; - - @Autowired - private AdminMenuService menusService; - @Autowired - private AdminPermissionService permissionService; - - - - // 创建菜单 - public ExecutedResult<Long> createMenu(ReqCreateAdminMenu request) { - AdminMenuPO item = AdminMenuConvert.INSTANCE.toCreate(request); - item.setParentId(NumericUtil.tryParseLong(request.getParentId(), 0L)); - item.setTitle(ParameterUtil.dealNullStr(request.getTitle())); - item.setLevel(1); - item.setSort(NumericUtil.tryParseInt(request.getSort(), 0)); - item.setStatus(EState.NORMAL.getValue()); - item.setCreateTime(LocalDateTimeUtil.nowTimeStamp()); - if (item.getParentId().compareTo(0L) > 0) { - ExecutedResult<AdminMenuPO> check = this.checkMenuId(request.getParentId()); - if (check.isFailed()) { - return ExecutedResult.failed("父级菜单不存在: " + request.getParentId()); - } - item.setLevel(check.getData().getLevel() + 1); - } - int rowCount = menusDao.insert(item); - if (rowCount == 1) { - // 删除菜单缓存 - menusService.removeListAllCache(); - // 删除所有权限缓存 - permissionService.removeListAllCache(); - // 删除所有用户的菜单和权限缓存 - this.removePowerAllUser(); - - // 给新增的菜单添加默认权限 - permissionService.createDefaultPermission(item); - return ExecutedResult.success(item.getId()); - } - return ExecutedResult.failed("创建[菜单]失败。"); - } - private ExecutedResult<AdminMenuPO> checkMenuId(Long id) { - AdminMenuPO item = menusDao.get(id); - if (Objects.isNull(item)) { - return ExecutedResult.failed("[菜单]不存在: " + id); - } - return ExecutedResult.success(item); - } - protected ExecutedResult<List<AdminMenuPO>> checkMenuId(List<Long> listId) { - // 从数据库查找测试信息 - List<AdminMenuPO> list = menusDao.getList(listId); - if (ListUtil.isNullOrEmpty(list)) { - return ExecutedResult.failed("[菜单]不存在." + listId); - } - // 数据库找到的id列表 - List<Long> listIdFind = list.stream().map(AdminMenuPO::getId).collect(Collectors.toList()); - // 数量不一致 - if (listId.size() != listIdFind.size()) { - // 筛选数据库不存在的测试信息 - List<Long> listIdNotFound = listId.stream().filter(c -> !listIdFind.contains(c)).collect(Collectors.toList()); - if (ListUtil.isNullOrEmpty(list)) { - return ExecutedResult.failed("[菜单]不存在." + listIdNotFound); - } - } - return ExecutedResult.success(list); - } - - // 编辑菜单 - public ExecutedResult<String> modifyMenu(ReqModifyAdminMenu request) { - ExecutedResult<AdminMenuPO> checkExists = this.checkMenuId(request.getId()); - if (checkExists.isFailed()) { - return ExecutedResult.failed(checkExists.getMsg()); - } - AdminMenuPO item = AdminMenuConvert.INSTANCE.toModify(request); - item.setTitle(ParameterUtil.dealNullStr(request.getTitle())); - item.setParentId(NumericUtil.tryParseLong(request.getParentId(), 0L)); - item.setLevel(1); - item.setSort(NumericUtil.tryParseInt(request.getSort(), 0)); - if (item.getParentId().compareTo(0L) > 0) { - ExecutedResult<AdminMenuPO> check = this.checkMenuId(request.getParentId()); - if (check.isFailed()) { - return ExecutedResult.failed("父级菜单不存在: " + request.getParentId()); - } - item.setLevel(check.getData().getLevel() + 1); - } - int rowCount = menusDao.updateById(item); - if (rowCount == 1) { - // 删除菜单缓存 - menusService.removeListAllCache(); - // 删除所有权限缓存 - permissionService.removeListAllCache(); - // 删除所有用户的菜单和权限缓存 - this.removePowerAllUser(); - return ExecutedResult.success(); - } - return ExecutedResult.failed("编辑[菜单]失败。"); - } - - public ExecutedResult<String> removeMenu(Long id) { - // 验证记录是否存在 - ExecutedResult<AdminMenuPO> checkExists = this.checkMenuId(id); - if (checkExists.isFailed()) { - return ExecutedResult.failed(checkExists.getMsg()); - } - - Boolean result = menusDao.deleteLogic(id); - if (result) { - // 删除菜单缓存 - menusService.removeListAllCache(); - // 删除所有权限缓存 - permissionService.removeListAllCache(); - // 删除所有用户的菜单和权限缓存 - this.removePowerAllUser(); - return ExecutedResult.success(); - } - return ExecutedResult.failed("删除[菜单]失败。"); - } - - public ExecutedResult<String> removeMenuList(List<Long> listId) { - // 验证记录是否存在 - ExecutedResult<List<AdminMenuPO>> checkExists = this.checkMenuId(listId); - if (checkExists.isFailed()) { - return ExecutedResult.failed(checkExists.getMsg()); - } - - Boolean result = menusDao.deleteLogic(listId); - if (result) { - // 删除菜单缓存 - menusService.removeListAllCache(); - // 删除所有权限缓存 - permissionService.removeListAllCache(); - // 删除所有用户的菜单和权限缓存 - this.removePowerAllUser(); - return ExecutedResult.success(); - } - return ExecutedResult.failed("删除[菜单]失败。"); - } - - // 变更菜单状态 - public ExecutedResult<String> changeMenuStatus(Long id, EState status) { - ExecutedResult<AdminMenuPO> checkExists = this.checkMenuId(id); - if (checkExists.isFailed()) { - return ExecutedResult.failed(checkExists.getMsg()); - } - AdminMenuPO upd = new AdminMenuPO(); - upd.setId(id); - upd.setStatus(status.getValue()); - int rowCount = menusDao.updateById(upd); - if (rowCount == 1) { - // 删除菜单缓存 - menusService.removeListAllCache(); - // 删除所有权限缓存 - permissionService.removeListAllCache(); - // 删除所有用户的菜单和权限缓存 - this.removePowerAllUser(); - return ExecutedResult.success(); - } - return ExecutedResult.failed("修改[菜单]状态失败。"); - } - - // 获取所有层级菜单 - public ExecutedResult<List<ResAdminMenuTreeAndPermission>> getListTreeMenu() { - List<ResAdminMenuTreeAndPermission> result = new ArrayList<>(); - LambdaQueryWrapper<AdminMenuPO> where = menusDao.query(); - where.in(AdminMenuPO::getStatus, Arrays.asList( - EState.NORMAL.getValue() - )); - List<AdminMenuPO> list = menusDao.selectList(where); - - if (ListUtil.isNullOrEmpty(list)) { - return ExecutedResult.success(result); - } - List<AdminMenuPO> listRoot = list.stream().filter(c -> Objects.equals(c.getLevel(), 1)).collect(Collectors.toList()); - listRoot = listRoot.stream() - .sorted(Comparator.comparing(AdminMenuPO::getSort)) - .collect(Collectors.toList()); - if (ListUtil.isNullOrEmpty(listRoot)) { - return ExecutedResult.success(result); - } - - List<Long> listMenuId = list.stream() - .map(AdminMenuPO::getId) - .collect(Collectors.toList()); - List<AdminPermissionPO> listPermission = permissionDao.list4MenuId(listMenuId); - Map<Long, List<AdminPermissionPO>> mapPermission = listPermission.stream() - .collect(Collectors.groupingBy(AdminPermissionPO::getMenuId)); - - for (AdminMenuPO item : listRoot) { - ResAdminMenuTreeAndPermission view = AdminMenuConvert.INSTANCE.toTreeVo(item); - this.fillChildMenu(view, list, mapPermission); - this.fillPermission4Menu(view, mapPermission); - result.add(view); - } - return ExecutedResult.success(result); - } - public void fillPermission4Menu(ResAdminMenuTreeAndPermission view, Map<Long, List<AdminPermissionPO>> mapPermission) { - view.setPermissions(new ArrayList<>()); - if (BooleanUtils.isFalse(mapPermission.containsKey(view.getId()))) { - return; - } - List<AdminPermissionPO> list = mapPermission.get(view.getId()); - view.setPermissions(AdminPermissionConvert.INSTANCE.toDetail(list)); - } - public void fillChildMenu(ResAdminMenuTreeAndPermission view, List<AdminMenuPO> list, Map<Long, List<AdminPermissionPO>> mapPermission) { - List<AdminMenuPO> listChild = list.stream() - .filter(c -> c.getParentId().equals(view.getId())) - .collect(Collectors.toList()); - view.setChildren(new ArrayList<>()); - if (ListUtil.isNullOrEmpty(listChild)) { - return; - } - listChild = listChild.stream() - .sorted(Comparator.comparing(AdminMenuPO::getSort)) - .collect(Collectors.toList()); - for (AdminMenuPO child : listChild) { - ResAdminMenuTreeAndPermission viewChild = AdminMenuConvert.INSTANCE.toTreeVo(child); - this.fillChildMenu(viewChild, list, mapPermission); - this.fillPermission4Menu(viewChild, mapPermission); - view.getChildren().add(viewChild); - } - } - - // 获取指定菜单的子级菜单 - public ExecutedResult<List<AdminMenuVO>> getListChildMenu(Long parentId) { - List<AdminMenuPO> list = menusDao.list4Parent(parentId); - if (ListUtil.isNullOrEmpty(list)) { - return ExecutedResult.success(new ArrayList<>()); - } - return ExecutedResult.success(AdminMenuConvert.INSTANCE.toVo(list)); - } - - // 分页查询菜单 - public ExecutedResult<PagerResult<AdminMenuVO>> searchMenu(SearchAdminMenu request) { - List<AdminMenuVO> result = new ArrayList<>(); - - super.dealPager(request); - request.setLastRowNo((request.getPage() - 1) * NumericUtil.tryParseLong(request.getLimit())); - // 处理时间范围 - Tuple<String, String> createTimeRange = ParameterUtil.getTimeRange(request.getCreateTimeRange()); - if (StringUtil.isNotNullOrEmpty(createTimeRange.getItem1())) { - request.setCreateTimeStart(LocalDateTimeUtil.getTimeStamp(createTimeRange.getItem1()).getTime()); - } - if (StringUtil.isNotNullOrEmpty(createTimeRange.getItem2())) { - request.setCreateTimeEnd(LocalDateTimeUtil.getTimeStamp(createTimeRange.getItem2()).getTime()); - } - if (NumericUtil.tryParseInt(request.getStatus(), 0).compareTo(0) < 1 && ListUtil.isNullOrEmpty(request.getListStatus())) { - request.setListStatus(Arrays.asList(EState.NORMAL.getValue(), EState.DISABLED.getValue())); - } - - PagerResult<AdminMenuPO> pagerResult = menusDao.search(request); - - if (NumericUtil.tryParseLong(pagerResult.getTotal()).compareTo(0L) < 1) { - return ExecutedResult.success( - new PagerResult<>(request.getLimit(), request.getPage(), 0L, new ArrayList<>()) - ); - } - List<AdminMenuPO> list = pagerResult.getList(); - Long lastId = 0L; - if (ListUtil.isNotNullOrEmpty(list)) { - lastId = list.stream().map(AdminMenuPO::getId).min(Comparator.comparing(c -> c)).get(); - result = AdminMenuConvert.INSTANCE.toVo(list); - } - PagerResult<AdminMenuVO> view = new PagerResult<>(request.getLimit(), request.getPage(), pagerResult.getTotal(), result); - view.setLastId(lastId); - return ExecutedResult.success(view); - } - - // 创建权限 - public ExecutedResult<Long> createPermission(ReqCreateAdminPermission request) { - String sn = request.getSn(); - AdminPermissionPO find = permissionDao.get4Sn(sn); - if (Objects.nonNull(find) && find.getId().compareTo(0L) > 0) { - return ExecutedResult.failed("权限编码已存在。" + sn); - } - ExecutedResult<AdminMenuPO> checkExists = this.checkMenuId(request.getMenuId()); - if (checkExists.isFailed()) { - return ExecutedResult.failed(checkExists.getMsg()); - } - - AdminPermissionPO item = new AdminPermissionPO(); - item.setName(request.getName()); - item.setSn(request.getSn()); - item.setMenuId(request.getMenuId()); - item.setMenuId(request.getMenuId()); - item.setStatus(EState.NORMAL.getValue()); - item.setMenuUrl(ParameterUtil.dealNullStr(request.getMenuUrl())); - item.setIcon(ParameterUtil.dealNullStr(request.getIcon())); - item.setType(ParameterUtil.dealNullStr(request.getType())); - item.setCreateTime(LocalDateTimeUtil.nowTimeStamp()); - int rowCount = permissionDao.insert(item); - if (rowCount == 1) { - // 删除权限缓存 - permissionService.removeListAllCache(); - return ExecutedResult.success(item.getId()); - } - return ExecutedResult.failed("创建[权限]失败。"); - } - - // 编辑权限 - public ExecutedResult<String> modifyPermission(ReqModifyAdminPermission request) { - Long id = request.getId(); - String sn = request.getSn(); - ExecutedResult<AdminPermissionPO> checkExists = this.checkPermissionId(id); - if (checkExists.isFailed()) { - return ExecutedResult.failed(checkExists.getMsg()); - } - AdminPermissionPO findBySn = permissionDao.get4Sn(sn); - if (Objects.nonNull(findBySn) && !Objects.equals(id, findBySn.getId())) { - return ExecutedResult.failed("权限编码已存在。" + sn); - } - ExecutedResult<AdminMenuPO> check = this.checkMenuId(request.getMenuId()); - if (check.isFailed()) { - return ExecutedResult.failed(check.getMsg()); - } - - AdminPermissionPO item = new AdminPermissionPO(); - item.setId(id); - item.setSn(request.getSn()); - item.setMenuId(request.getMenuId()); - item.setName(request.getName()); - int rowCount = permissionDao.updateById(item); - if (rowCount == 1) { - // 删除权限缓存 - permissionService.removeListAllCache(); - return ExecutedResult.success(); - } - return ExecutedResult.failed("编辑[权限]失败。"); - } - private ExecutedResult<AdminPermissionPO> checkPermissionId(Long id) { - AdminPermissionPO item = permissionDao.get(id); - if (Objects.isNull(item)) { - return ExecutedResult.failed("[权限]不存在: " + id); - } - return ExecutedResult.success(item); - } - - // 删除权限 - public ExecutedResult<String> removePermission(Long id) { - AdminPermissionPO find = permissionDao.get(id); - if (null == find) { - return ExecutedResult.failed("[权限]记录未找到。" + id); - } - Boolean remove = permissionDao.remove(id); - if (remove) { - // 删除权限缓存 - permissionService.removeListAllCache(); - return ExecutedResult.success(); - } - return ExecutedResult.failed("删除[权限]失败"); - } - - // 分页查询权限 - public ExecutedResult<PagerResult<ResAdminPermission>> searchPermission(SearchAdminPermission request) { - List<ResAdminPermission> result = new ArrayList<>(); - - super.dealPager(request); - request.setLastRowNo((request.getPage() - 1) * NumericUtil.tryParseLong(request.getLimit())); - // 处理时间范围 - Tuple<String, String> createTimeRange = ParameterUtil.getTimeRange(request.getCreateTimeRange()); - if (StringUtil.isNotNullOrEmpty(createTimeRange.getItem1())) { - request.setCreateTimeStart(LocalDateTimeUtil.getTimeStamp(createTimeRange.getItem1()).getTime()); - } - if (StringUtil.isNotNullOrEmpty(createTimeRange.getItem2())) { - request.setCreateTimeEnd(LocalDateTimeUtil.getTimeStamp(createTimeRange.getItem2()).getTime()); - } - if (NumericUtil.tryParseInt(request.getStatus(), 0).compareTo(0) < 1 && ListUtil.isNullOrEmpty(request.getListStatus())) { - request.setListStatus(Arrays.asList(EState.NORMAL.getValue(), EState.DISABLED.getValue())); - } - PagerResult<AdminPermissionPO> pagerResult = permissionDao.search(request); - - if (NumericUtil.tryParseLong(pagerResult.getTotal()).compareTo(0L) < 1) { - return ExecutedResult.success( - new PagerResult<>(request.getLimit(), request.getPage(), 0L, new ArrayList<>()) - ); - } - List<AdminPermissionPO> list = pagerResult.getList(); - Long lastId = 0L; - if (ListUtil.isNotNullOrEmpty(list)) { - lastId = list.stream().map(AdminPermissionPO::getId).min(Comparator.comparing(c -> c)).get(); - result = AdminPermissionConvert.INSTANCE.toDetail(list); - } - PagerResult<ResAdminPermission> view = new PagerResult<>(request.getLimit(), request.getPage(), pagerResult.getTotal(), result); - view.setLastId(lastId); - return ExecutedResult.success(view); - } - - // 创建角色 - public ExecutedResult<Long> createRole(ReqCreateAdminRole request) { - AdminRolePO item = AdminRoleConvert.INSTANCE.toCreate(request); - item.setDescription(ParameterUtil.dealNullStr(request.getDescription())); - item.setStatus(EState.NORMAL.getValue()); - item.setSort(NumericUtil.tryParseInt(request.getSort(), 0)); - item.setCreateTime(LocalDateTimeUtil.nowTimeStamp()); - int rowCount = roleDao.insert(item); - if (rowCount == 1) { - return ExecutedResult.success(item.getId()); - } - return ExecutedResult.failed("创建[角色]失败。"); - } - - // 编辑角色 - public ExecutedResult<String> modifyRole(ReqModifyAdminRole request) { - ExecutedResult<AdminRolePO> checkExists = this.checkRoleId(request.getId()); - if (checkExists.isFailed()) { - return ExecutedResult.failed(checkExists.getMsg()); - } - AdminRolePO item = AdminRoleConvert.INSTANCE.toModify(request); - item.setSort(NumericUtil.tryParseInt(request.getSort(), 0)); - item.setDescription(ParameterUtil.dealNullStr(request.getDescription())); - int rowCount = roleDao.updateById(item); - if (rowCount == 1) { - return ExecutedResult.success(); - } - return ExecutedResult.failed("编辑[角色]失败。"); - } - - // 修改角色状态 - public ExecutedResult<String> changeRoleStatus(Long id, EState status) { - ExecutedResult<AdminRolePO> checkExists = this.checkRoleId(id); - if (checkExists.isFailed()) { - return ExecutedResult.failed(checkExists.getMsg()); - } - AdminRolePO upd = new AdminRolePO(); - upd.setId(id); - upd.setStatus(status.getValue()); - int rowCount = roleDao.updateById(upd); - if (rowCount == 1) { - return ExecutedResult.success(); - } - return ExecutedResult.failed("修改[角色]状态失败。"); - } - private ExecutedResult<AdminRolePO> checkRoleId(Long id) { - AdminRolePO item = roleDao.get(id); - if (Objects.isNull(item)) { - return ExecutedResult.failed("[角色]不存在: " + id); - } - return ExecutedResult.success(item); - } - private ExecutedResult<List<AdminRolePO>> checkRoleId(List<Long> listId) { - // 从数据库查找测试信息 - List<AdminRolePO> list = roleDao.getList(listId); - if (ListUtil.isNullOrEmpty(list)) { - return ExecutedResult.failed("[角色]不存在." + listId); - } - // 数据库找到的id列表 - List<Long> listIdFind = list.stream().map(AdminRolePO::getId).collect(Collectors.toList()); - // 数量不一致 - if (listId.size() != listIdFind.size()) { - // 筛选数据库不存在的测试信息 - List<Long> listIdNotFound = listId.stream().filter(c -> !listIdFind.contains(c)).collect(Collectors.toList()); - if (ListUtil.isNullOrEmpty(list)) { - return ExecutedResult.failed("[角色]不存在." + listIdNotFound); - } - } - return ExecutedResult.success(list); - } - - public ExecutedResult<String> removeRole(Long id) { - // 验证记录是否存在 - ExecutedResult<AdminRolePO> checkExists = this.checkRoleId(id); - if (checkExists.isFailed()) { - return ExecutedResult.failed(checkExists.getMsg()); - } - - Boolean result = roleDao.deleteLogic(id); - if (BooleanUtils.isFalse(result)) { - return ExecutedResult.failed("删除[角色]失败。"); - } - return ExecutedResult.success(); - } - - public ExecutedResult<String> removeRoleList(List<Long> listId) { - // 验证记录是否存在 - ExecutedResult<List<AdminRolePO>> checkExists = this.checkRoleId(listId); - if (checkExists.isFailed()) { - return ExecutedResult.failed(checkExists.getMsg()); - } - - Boolean result = roleDao.deleteLogic(listId); - if (BooleanUtils.isFalse(result)) { - return ExecutedResult.failed("删除[角色]失败。"); - } - return ExecutedResult.success(); - } - - // 分页查询角色 - public ExecutedResult<PagerResult<AdminRoleVO>> searchRole(SearchAdminRole request) { - List<AdminRoleVO> result = new ArrayList<>(); - - super.dealPager(request); - request.setLastRowNo((request.getPage() - 1) * NumericUtil.tryParseLong(request.getLimit())); - // 处理时间范围 - Tuple<String, String> createTimeRange = ParameterUtil.getTimeRange(request.getCreateTimeRange()); - if (StringUtil.isNotNullOrEmpty(createTimeRange.getItem1())) { - request.setCreateTimeStart(LocalDateTimeUtil.getTimeStamp(createTimeRange.getItem1()).getTime()); - } - if (StringUtil.isNotNullOrEmpty(createTimeRange.getItem2())) { - request.setCreateTimeEnd(LocalDateTimeUtil.getTimeStamp(createTimeRange.getItem2()).getTime()); - } - if (NumericUtil.tryParseInt(request.getStatus(), 0).compareTo(0) < 1 && ListUtil.isNullOrEmpty(request.getListStatus())) { - request.setListStatus(Arrays.asList(EState.NORMAL.getValue(), EState.DISABLED.getValue())); - } - - PagerResult<AdminRolePO> pagerResult = roleDao.search(request); - - if (NumericUtil.tryParseLong(pagerResult.getTotal()).compareTo(0L) < 1) { - return ExecutedResult.success( - new PagerResult<>(request.getLimit(), request.getPage(), 0L, new ArrayList<>()) - ); - } - List<AdminRolePO> list = pagerResult.getList(); - Long lastId = 0L; - if (ListUtil.isNotNullOrEmpty(list)) { - lastId = list.stream().map(AdminRolePO::getId).min(Comparator.comparing(c -> c)).get(); - result = AdminRoleConvert.INSTANCE.toVo(list); - } - PagerResult<AdminRoleVO> view = new PagerResult<>(request.getLimit(), request.getPage(), pagerResult.getTotal(), result); - view.setLastId(lastId); - return ExecutedResult.success(view); - } - - // 设置角色菜单权限列表 - public ExecutedResult<String> setListMenu4Role(ReqSetListMenu4Role request) { - Long roleId = request.getId(); - ExecutedResult<AdminRolePO> checkExists = this.checkRoleId(roleId); - if (checkExists.isFailed()) { - return ExecutedResult.failed(checkExists.getMsg()); - } - AdminRolePO find = checkExists.getData(); - Long now = LocalDateTimeUtil.nowTimeStamp(); - - //找到角色已有的菜单列表 - List<AdminRoleMenuRelationPO> listOld = roleMenuRelationDao.list4Role(roleId); - listOld = ParameterUtil.dealNull(listOld); - List<Long> listOldMenuId = listOld.stream() - .map(AdminRoleMenuRelationPO::getMenuId) - .collect(Collectors.toList()); - - //现在设置的菜单id列表 - List<Long> listMenuId = ParameterUtil.dealNull(request.getListMenu()); - - //找到所有菜单 - List<Long> listAllId = new ArrayList<>(listOldMenuId); - listAllId.addAll(listMenuId); - ListUtil.repeat(listAllId); - List<AdminMenuPO> listMenu = menusDao.getList(listAllId); - Map<Long, AdminMenuPO> mapMenu = listMenu.stream() - .collect(Collectors.toMap(AdminMenuPO::getId, c -> c)); - - //找到新增菜单列表(新菜单列表的元素,不存在于已有的菜单列表中) - List<Long> listNew = listMenuId.stream() - .filter(c -> !listOldMenuId.contains(c)) - .collect(Collectors.toList()); - //找到删除菜单列表(已有菜单列表的元素,不存在于新菜单列表) - List<Long> listRemove = listOldMenuId.stream() - .filter(c -> !listMenuId.contains(c)) - .collect(Collectors.toList()); - - //批量新增 - if(BooleanUtils.isFalse(listNew.isEmpty())) { - List<AdminRoleMenuRelationPO> list = listNew.stream() - .map(c -> { - AdminRoleMenuRelationPO item = new AdminRoleMenuRelationPO(); - item.setRoleId(roleId); - item.setMenuId(c); - item.setCreateTime(now); - return item; - }).collect(Collectors.toList()); - Boolean addList = roleMenuRelationDao.addList(list); - if(BooleanUtils.isFalse(addList)) { - return ExecutedResult.failed("给角色“" + roleId + "”新增菜单失败。" + listNew); - } - } - //批量删除 - if(BooleanUtils.isFalse(listRemove.isEmpty())) { - List<Long> listId = listOld.stream() - .filter(c -> listRemove.contains(c.getMenuId())) - .map(AdminRoleMenuRelationPO::getId).collect(Collectors.toList()); - Boolean removeList = roleMenuRelationDao.remove(listId); - if(BooleanUtils.isFalse(removeList)) { - return ExecutedResult.failed("删除角色“" + roleId + "”已有菜单失败。" + listRemove); - } - } - - - - //找到角色已有的权限列表 - List<AdminRolePermissionRelationPO> listOldPermission = rolePermissionRelationDao.list4Role(roleId); - listOldPermission = ParameterUtil.dealNull(listOldPermission); - List<Long> listOldPermissionId = listOldPermission.stream() - .map(AdminRolePermissionRelationPO::getPermissionId) - .collect(Collectors.toList()); - - //现在设置的权限id列表 - List<Long> listPermissionId = ParameterUtil.dealNull(request.getListPermission()); - - //找到所有权限 - List<Long> listAllPermissionId = new ArrayList<>(listOldPermissionId); - listAllPermissionId.addAll(listPermissionId); - ListUtil.repeat(listAllPermissionId); - List<AdminPermissionPO> listPermission = permissionDao.getList(listAllPermissionId); - Map<Long, AdminPermissionPO> mapPermission = listPermission.stream() - .collect(Collectors.toMap(AdminPermissionPO::getId, c -> c)); - - //找到新增权限列表(新权限列表的元素,不存在于已有的菜单列表中) - List<Long> listNewPermission = listPermissionId.stream() - .filter(c -> !listOldPermissionId.contains(c)) - .collect(Collectors.toList()); - //找到删除权限列表(已有权限列表的元素,不存在于新菜单列表) - List<Long> listRemovePermission = listOldPermissionId.stream() - .filter(c -> !listPermissionId.contains(c)) - .collect(Collectors.toList()); - - //批量新增 - if(BooleanUtils.isFalse(listNewPermission.isEmpty())) { - List<AdminRolePermissionRelationPO> list = listNewPermission.stream() - .map(c -> { - AdminRolePermissionRelationPO item = new AdminRolePermissionRelationPO(); - item.setRoleId(roleId); - item.setPermissionId(c); - item.setCreateTime(now); - return item; - }).collect(Collectors.toList()); - Boolean addList = rolePermissionRelationDao.addList(list); - if(BooleanUtils.isFalse(addList)) { - return ExecutedResult.failed("给角色“" + roleId + "”新增权限失败。" + listNewPermission); - } - } - //批量删除 - if(BooleanUtils.isFalse(listRemovePermission.isEmpty())) { - List<Long> listId = listOldPermission.stream() - .filter(c -> listRemovePermission.contains(c.getPermissionId())) - .map(AdminRolePermissionRelationPO::getId).collect(Collectors.toList()); - Boolean removeList = rolePermissionRelationDao.remove(listId); - if(BooleanUtils.isFalse(removeList)) { - return ExecutedResult.failed("删除角色“" + roleId + "”已有权限失败。" + listRemovePermission); - } - } - return ExecutedResult.success(); - } - - // 获取角色菜单权限列表 - public ExecutedResult<ResAdminPower> getListMenu4Role(Long roleId) { - ResAdminPower result = new ResAdminPower(); - result.setMenus(new ArrayList<>()); - result.setPermissions(new ArrayList<>()); - - ExecutedResult<AdminRolePO> checkExists = this.checkRoleId(roleId); - if (checkExists.isFailed()) { - return ExecutedResult.failed(checkExists.getMsg()); - } - AdminRolePO find = checkExists.getData(); - //找到角色已有的菜单列表 - List<AdminRoleMenuRelationPO> listMenu4Role = roleMenuRelationDao.list4Role(roleId); - if (ListUtil.isNotNullOrEmpty(listMenu4Role)) { - List<Long> listOldMenuId = listMenu4Role.stream() - .map(AdminRoleMenuRelationPO::getMenuId) - .collect(Collectors.toList()); - List<AdminMenuPO> listMenu = menusDao.getList(listOldMenuId); - if (ListUtil.isNotNullOrEmpty(listMenu)) { - result.setMenus(AdminMenuConvert.INSTANCE.toVo(listMenu)); - } - } - //找到角色已有的权限列表 - List<AdminRolePermissionRelationPO> listPermission4Role = rolePermissionRelationDao.list4Role(roleId); - if (ListUtil.isNotNullOrEmpty(listPermission4Role)) { - List<Long> listPermissionId = listPermission4Role.stream() - .map(AdminRolePermissionRelationPO::getPermissionId) - .collect(Collectors.toList()); - List<AdminPermissionPO> listPermission = permissionDao.getList(listPermissionId); - if (ListUtil.isNotNullOrEmpty(listPermission)) { - result.setPermissions(AdminPermissionConvert.INSTANCE.toDetail(listPermission)); - } - } - return ExecutedResult.success(result); - } - - protected List<AdminPermissionPO> getListPermission4Role(List<Long> listRoleId) { - List<AdminRolePermissionRelationPO> listPermissionRel = rolePermissionRelationDao.list4Role(listRoleId); - if (ListUtil.isNullOrEmpty(listPermissionRel)) { - return new ArrayList<>(); - } - List<AdminPermissionPO> listPermission = permissionService.listAllWithCache(); - if (ListUtil.isNullOrEmpty(listPermission)) { - return new ArrayList<>(); - } - // 筛选状态 - listPermission = listPermission.stream() - .filter(c -> Objects.equals(c.getStatus(), EState.NORMAL.getValue())) - .collect(Collectors.toList()); - List<Long> listPermissionId = listPermissionRel.stream() - .map(AdminRolePermissionRelationPO::getPermissionId) - .collect(Collectors.toList()); - return listPermission.stream() - .filter(c -> listPermissionId.contains(c.getId())) - .collect(Collectors.toList()); - } - - protected List<AdminMenuPO> getListMenu4Role(List<Long> listRoleId) { - List<AdminRoleMenuRelationPO> listRoleMenu = roleMenuRelationDao.list4Role(listRoleId); - if (ListUtil.isNullOrEmpty(listRoleMenu)) { - return new ArrayList<>(); - } - List<AdminMenuPO> listMenu = menusService.listAllWithCache(); - if (ListUtil.isNullOrEmpty(listMenu)) { - return new ArrayList<>(); - } - // 筛选状态 - listMenu = listMenu.stream() - .filter(c -> Objects.equals(c.getStatus(), EState.NORMAL.getValue())) - .collect(Collectors.toList()); - List<Long> listMenuId = listRoleMenu.stream().map(AdminRoleMenuRelationPO::getMenuId) - .collect(Collectors.toList()); - return listMenu.stream() - .filter(c -> listMenuId.contains(c.getId())) - .collect(Collectors.toList()); - } - - /** - * 删除指定用户的菜单和权限缓存 - * @param userId 用户id - */ - protected void removePower4User(Long userId) { - menusService.removeUserMenuCache(userId); - permissionService.removeUserCache(userId); - } - /** - * 删除所有用户的菜单和权限缓存 - */ - protected void removePowerAllUser() { - menusService.removeAllUserMenuCache(); - permissionService.removeAllUserCache(); - } - - public ExecutedResult<String> setMenuSort(ReqSetSort request) { - // 验证记录是否存在 - ExecutedResult<AdminMenuPO> checkExists = this.checkMenuId(request.getId()); - if (checkExists.isFailed()) { - return ExecutedResult.failed(checkExists.getMsg()); - } - - AdminMenuPO item = new AdminMenuPO(); - item.setId(request.getId()); - item.setSort(request.getSort()); - - int rowCount = menusDao.updateById(item); - if (rowCount != 1) { - return ExecutedResult.failed("[测试信息]设置排序值失败。"); - } - return ExecutedResult.success(); - } - - public ExecutedResult<String> listSetMenuSort(ReqListSetSort request) { - // id列表 - List<Long> listId = request.getList().stream().map(ReqSetSort::getId).collect(Collectors.toList()); - // 验证记录是否存在 - ExecutedResult<List<AdminMenuPO>> checkExists = this.checkMenuId(listId); - if (checkExists.isFailed()) { - return ExecutedResult.failed(checkExists.getMsg()); - } - - List<AdminMenuPO> listUpdate = request.getList().stream() - .map(c -> { - AdminMenuPO item = new AdminMenuPO(); - item.setId(c.getId()); - item.setSort(c.getSort()); - return item; - }) - .collect(Collectors.toList()); - Boolean result = menusDao.modifyList(listUpdate); - if (result) { - return ExecutedResult.success(); - } - return ExecutedResult.failed("[测试信息]设置排序值失败"); - } - - public ExecutedResult<String> setRoleSort(ReqSetSort request) { - // 验证记录是否存在 - ExecutedResult<AdminRolePO> checkExists = this.checkRoleId(request.getId()); - if (checkExists.isFailed()) { - return ExecutedResult.failed(checkExists.getMsg()); - } - - AdminRolePO item = new AdminRolePO(); - item.setId(request.getId()); - item.setSort(request.getSort()); - - int rowCount = roleDao.updateById(item); - if (rowCount != 1) { - return ExecutedResult.failed("[角色]设置排序值失败。"); - } - return ExecutedResult.success(); - } - - public ExecutedResult<String> listSetRoleSort(ReqListSetSort request) { - // id列表 - List<Long> listId = request.getList().stream().map(ReqSetSort::getId).collect(Collectors.toList()); - // 验证记录是否存在 - ExecutedResult<List<AdminRolePO>> checkExists = this.checkRoleId(listId); - if (checkExists.isFailed()) { - return ExecutedResult.failed(checkExists.getMsg()); - } - - List<AdminRolePO> listUpdate = request.getList().stream() - .map(c -> { - AdminRolePO item = new AdminRolePO(); - item.setId(c.getId()); - item.setSort(c.getSort()); - return item; - }) - .collect(Collectors.toList()); - Boolean result = roleDao.modifyList(listUpdate); - if (result) { - return ExecutedResult.success(); - } - return ExecutedResult.failed("[角色]设置排序值失败"); - } -} diff --git a/src/main/java/com/lunhan/xxx/service/AdminService.java b/src/main/java/com/lunhan/xxx/service/AdminService.java deleted file mode 100644 index cda5365..0000000 --- a/src/main/java/com/lunhan/xxx/service/AdminService.java +++ /dev/null @@ -1,494 +0,0 @@ -package com.lunhan.xxx.service; - -import com.lunhan.xxx.common.ConstantFactory; -import com.lunhan.xxx.common.ExecutedResult; -import com.lunhan.xxx.common.PagerResult; -import com.lunhan.xxx.common.jwt.JWTUtil; -import com.lunhan.xxx.common.jwt.LoginUserDTO; -import com.lunhan.xxx.common.model.Tuple; -import com.lunhan.xxx.common.security.MD5Util; -import com.lunhan.xxx.common.util.*; -import com.lunhan.xxx.entity.enums.EState; -import com.lunhan.xxx.entity.enums.EUserType; -import com.lunhan.xxx.entity.request.ReqChangePassword; -import com.lunhan.xxx.entity.request.adminuser.ReqAdminLogin; -import com.lunhan.xxx.entity.request.adminuser.ReqCreateAdminUser; -import com.lunhan.xxx.entity.request.adminuser.ReqModifyAdminUser; -import com.lunhan.xxx.entity.request.adminuser.ReqSetListRole4Admin; -import com.lunhan.xxx.entity.response.admin.ResAdminLogin; -import com.lunhan.xxx.entity.response.admin.ResAdminMenuTreeAndPermission; -import com.lunhan.xxx.entity.response.admin.ResAdminPower; -import com.lunhan.xxx.entity.search.SearchAdminUser; -import com.lunhan.xxx.repository.impl.*; -import com.lunhan.xxx.repository.po.*; -import com.lunhan.xxx.repository.vo.AdminRoleVO; -import com.lunhan.xxx.repository.vo.AdminUserVO; -import com.lunhan.xxx.service.convert.AdminMenuConvert; -import com.lunhan.xxx.service.convert.AdminPermissionConvert; -import com.lunhan.xxx.service.convert.AdminRoleConvert; -import com.lunhan.xxx.service.convert.AdminUserConvert; -import com.lunhan.xxx.service.dto.ResAdminDetail; -import org.apache.commons.lang3.BooleanUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import java.util.*; -import java.util.stream.Collectors; - -@Service -public class AdminService extends BaseService { - private static final List<Integer> LIST_ADMIN_TYPE = Arrays.asList( - EUserType.ADMIN.getValue(), - EUserType.ADMIN_USER.getValue() - ); - - @Autowired - private AdminUserMapperImpl dao; - @Autowired - private AdminMenuMapperImpl menusDao; - @Autowired - private AdminPermissionMapperImpl permissionDao; - @Autowired - private AdminRoleMapperImpl roleDao; - @Autowired - private AdminRoleMenuRelationMapperImpl roleMenuRelationDao; - @Autowired - private AdminRolePermissionRelationMapperImpl rolePermissionRelationDao; - @Autowired - private AdminRoleRelationMapperImpl adminRoleRelationDao; - - @Autowired - private AdminMenuService menusService; - @Autowired - private AdminPermissionService permissionService; - @Autowired - private AdminPowerService adminPowerService; - - - - // 添加后台管理员 - public ExecutedResult<Long> createAdmin(ReqCreateAdminUser request) { - AdminUserPO find = dao.get4Name(request.getUserName()); - if(Objects.nonNull(find)){ - return ExecutedResult.failed("管理员帐号已存在。" + request.getUserName()); - } - AdminUserPO item = AdminUserConvert.INSTANCE.toCreate(request); - item.setUserRelId(0L); - item.setNickName(ParameterUtil.dealNullStr(request.getNickName())); - item.setHeadImg(ParameterUtil.dealNullStr(request.getHeadImg())); - item.setEmail(ParameterUtil.dealNullStr(request.getEmail())); - item.setContact(ParameterUtil.dealNullStr(request.getContact())); - // 密码加密 - item.setPassword(MD5Util.encrypt(request.getPassword() + ConstantFactory.KEY_PASSWORD)); - item.setStatus(EState.NORMAL.getValue()); - item.setCreateTime(LocalDateTimeUtil.nowTimeStamp()); - int rowCount = dao.insert(item); - if (rowCount == 1) { - return ExecutedResult.success(item.getId()); - } - return ExecutedResult.failed("添加[管理员]失败。"); - } - - // 修改后台管理员 - public ExecutedResult<String> modify(ReqModifyAdminUser request) { - ExecutedResult<AdminUserPO> check = this.check4Id(request.getId()); - if (check.isFailed()) { - return ExecutedResult.failed(check.getMsg(), check.getMsgCode()); - } - - AdminUserPO item = new AdminUserPO(); - item.setId(request.getId()); - item.setNickName(ParameterUtil.dealNullStr(request.getNickName())); - item.setHeadImg(ParameterUtil.dealNullStr(request.getHeadImg())); - item.setContact(ParameterUtil.dealNullStr(request.getContact())); - item.setEmail(ParameterUtil.dealNullStr(request.getEmail())); - item.setStatus(request.getStatus()); - int rowCount = dao.updateById(item); - if (rowCount == 1) { - return ExecutedResult.success(); - } - return ExecutedResult.failed("编辑[管理员]失败。"); - } - - // 获取指定管理员详情 - public ExecutedResult<ResAdminDetail> detail(Long adminId) { - ExecutedResult<AdminUserPO> check = this.check4Id(adminId); - if (check.isFailed()) { - return ExecutedResult.failed(check.getMsg(), check.getMsgCode()); - } - ResAdminDetail result = AdminUserConvert.INSTANCE.toDetail(check.getData()); - - result.setListRole(new ArrayList<>()); - //找到角色已有的菜单列表 - List<AdminRoleRelationPO> listRoleRel = adminRoleRelationDao.list4Admin(adminId); - if (ListUtil.isNotNullOrEmpty(listRoleRel)) { - List<Long> listRoleId = listRoleRel.stream() - .map(AdminRoleRelationPO::getRoleId) - .collect(Collectors.toList()); - List<AdminRolePO> listRole = roleDao.getList(listRoleId); - result.setListRole(AdminRoleConvert.INSTANCE.toVo(listRole)); - } - return ExecutedResult.success(result); - } - - // 管理员登录 - public ExecutedResult<ResAdminLogin> adminLogin(ReqAdminLogin request) { - AdminUserPO user = dao.get4Name(request.getUserName()); - if(Objects.isNull(user)){ - return ExecutedResult.failed("用户名或密码错误。"); - } - if(BooleanUtils.isFalse(Objects.equals(user.getStatus(), EState.NORMAL.getValue()))) { - return ExecutedResult.failed("账号已锁定,请联系管理员。"); - } - if(BooleanUtils.isFalse(MD5Util.encrypt(request.getPassword() + ConstantFactory.KEY_PASSWORD).equals(user.getPassword()))) { - return ExecutedResult.failed("用户名或密码错误。"); - } - // 构建登录用户 - LoginUserDTO loginUser = new LoginUserDTO(); - loginUser.setUserId(user.getId().toString()); - loginUser.setUserType(user.getUserType()); - loginUser.setNickName(user.getNickName()); - loginUser.setPhone(user.getContact()); - - // 保存用户信息到jwt - String token = JWTUtil.getToken(loginUser); - - ResAdminLogin result = this.getListPower4Admin(user); - result.setName(user.getNickName()); - result.setToken(token); - - return ExecutedResult.success(result); - } - - // 获取管理员权限列表 - public ExecutedResult<ResAdminPower> getPower(Long adminId) { - ResAdminPower result = new ResAdminPower(); - result.setMenus(new ArrayList<>()); - - ExecutedResult<AdminUserPO> check = this.check4Id(adminId); - if (check.isFailed()) { - return ExecutedResult.success(result); - } - AdminUserPO user = check.getData(); - - List<AdminMenuPO> listMenu; - List<AdminPermissionPO> listPermission = null; - // 超级管理员有所有权限 - if (Objects.equals(user.getUserType(), EUserType.ADMIN.getValue())) { - listMenu = menusService.listAllWithCache(); - listPermission = permissionService.listAllWithCache(); - } else { - //找到角色已有的菜单列表 - List<AdminRoleRelationPO> listRole = adminRoleRelationDao.list4Admin(adminId); - if (ListUtil.isNullOrEmpty(listRole)) { - return ExecutedResult.success(result); - } - List<Long> listRoleId = listRole.stream() - .map(AdminRoleRelationPO::getRoleId) - .collect(Collectors.toList()); - - listMenu = menusService.listUserAllWithCache(adminId, listRoleId, adminPowerService::getListMenu4Role); - listPermission = permissionService.listUserAllWithCache(adminId, listRoleId, adminPowerService::getListPermission4Role); - } - if (ListUtil.isNotNullOrEmpty(listMenu)) { - // 筛选状态 - listMenu = listMenu.stream() - .filter(c -> Objects.equals(c.getStatus(), EState.NORMAL.getValue())) - .collect(Collectors.toList()); - result.setMenus(AdminMenuConvert.INSTANCE.toVo(listMenu)); - } - if (ListUtil.isNotNullOrEmpty(listPermission)) { - // 筛选状态 - listPermission = listPermission.stream() - .filter(c -> Objects.equals(c.getStatus(), EState.NORMAL.getValue())) - .collect(Collectors.toList()); - result.setPermissions(AdminPermissionConvert.INSTANCE.toDetail(listPermission)); - } - return ExecutedResult.success(result); - } - - // 修改密码 - public ExecutedResult<String> changePassword(LoginUserDTO user, ReqChangePassword request) { - Long adminId = NumericUtil.tryParseLong(user.getUserId(), 0L); - ExecutedResult<AdminUserPO> check = this.check4Id(adminId); - if (check.isFailed()) { - return ExecutedResult.failed(check.getMsg(), check.getMsgCode()); - } - String oldPass = MD5Util.encrypt(request.getOldPassword() + ConstantFactory.KEY_PASSWORD); - if (BooleanUtils.isFalse(oldPass.equals(check.getData().getPassword()))) { - return ExecutedResult.failed("密码校验失败。"); - } - return this.changePasswordDo(adminId, request.getNewPassword()); - } - private ExecutedResult<String> changePasswordDo(Long adminId, String password) { - AdminUserPO item = new AdminUserPO(); - item.setId(adminId); - // 密码加密 - item.setPassword(MD5Util.encrypt(password + ConstantFactory.KEY_PASSWORD)); - int rowCount = dao.updateById(item); - if (rowCount == 1) { - return ExecutedResult.success(); - } - return ExecutedResult.failed("密码修改失败。"); - } - - // 重置密码 - public ExecutedResult<String> resetPassword(Long adminId) { - ExecutedResult<AdminUserPO> check = this.check4Id(adminId); - if (check.isFailed()) { - return ExecutedResult.failed(check.getMsg(), check.getMsgCode()); - } - String pass = RandVerifyCode.complexCode(8); - ExecutedResult<String> changePasswordDo = this.changePasswordDo(adminId, pass); - if (changePasswordDo.isFailed()) { - return changePasswordDo; - } - return ExecutedResult.success(pass); - } - - // 分页查询所有管理员 - public ExecutedResult<PagerResult<AdminUserVO>> search(SearchAdminUser request) { - List<AdminUserVO> result = new ArrayList<>(); - - super.dealPager(request); - request.setLastRowNo((request.getPage() - 1) * NumericUtil.tryParseLong(request.getLimit())); - // 处理时间范围 - Tuple<String, String> createTimeRange = ParameterUtil.getTimeRange(request.getCreateTimeRange()); - if (StringUtil.isNotNullOrEmpty(createTimeRange.getItem1())) { - request.setCreateTimeStart(LocalDateTimeUtil.getTimeStamp(createTimeRange.getItem1()).getTime()); - } - if (StringUtil.isNotNullOrEmpty(createTimeRange.getItem2())) { - request.setCreateTimeEnd(LocalDateTimeUtil.getTimeStamp(createTimeRange.getItem2()).getTime()); - } - - PagerResult<AdminUserPO> pagerResult = dao.search(request); - - if (NumericUtil.tryParseLong(pagerResult.getTotal()).compareTo(0L) < 1) { - return ExecutedResult.success( - new PagerResult<>(request.getLimit(), request.getPage(), 0L, new ArrayList<>()) - ); - } - List<AdminUserPO> list = pagerResult.getList(); - Long lastId = 0L; - if (ListUtil.isNotNullOrEmpty(list)) { - lastId = list.stream().map(AdminUserPO::getId).min(Comparator.comparing(c -> c)).get(); - - list.forEach(item -> { - AdminUserVO vo = AdminUserConvert.INSTANCE.toVo(item); - result.add(vo); - }); - } - PagerResult<AdminUserVO> view = new PagerResult<>(request.getLimit(), request.getPage(), pagerResult.getTotal(), result); - view.setLastId(lastId); - return ExecutedResult.success(view); - } - - public ExecutedResult<String> stop(Long id) { - // 验证记录是否存在 - ExecutedResult<AdminUserPO> checkExists = this.check4Id(id); - if (checkExists.isFailed()) { - return ExecutedResult.failed(checkExists.getMsg()); - } - AdminUserPO item = new AdminUserPO(); - item.setId(id); - item.setStatus(EState.DISABLED.getValue()); - - int rowCount = this.dao.updateById(item); - if (rowCount == 1) { - return ExecutedResult.success(); - } - return ExecutedResult.failed("停用[管理员]失败。"); - } - - public ExecutedResult<String> enable(Long id) { - // 验证记录是否存在 - ExecutedResult<AdminUserPO> checkExists = this.check4Id(id); - if (checkExists.isFailed()) { - return ExecutedResult.failed(checkExists.getMsg()); - } - AdminUserPO item = new AdminUserPO(); - item.setId(id); - item.setStatus(EState.NORMAL.getValue()); - - int rowCount = this.dao.updateById(item); - if (rowCount == 1) { - return ExecutedResult.success(); - } - return ExecutedResult.failed("启用[管理员]失败。"); - } - - public ExecutedResult<String> remove(Long adminId) { - ExecutedResult<AdminUserPO> check = this.check4Id(adminId); - if (check.isFailed()) { - return ExecutedResult.failed(check.getMsg(), check.getMsgCode()); - } - Boolean remove = dao.remove(adminId); - if (remove) { - return ExecutedResult.success(); - } - return ExecutedResult.failed("删除[管理员]失败"); - } - - public ExecutedResult<AdminUserPO> check4Id(Long id) { - AdminUserPO item = dao.get(id); - if (Objects.isNull(item)) { - return ExecutedResult.failed("[管理员]不存在: " + id); - } - return ExecutedResult.success(item); - } - - // 设置管理员的角色列表 - public ExecutedResult<String> setListRole4Admin(ReqSetListRole4Admin request) { - Long adminId = request.getId(); - ExecutedResult<AdminUserPO> checkExists = this.check4Id(adminId); - if (checkExists.isFailed()) { - return ExecutedResult.failed(checkExists.getMsg()); - } - AdminUserPO find = checkExists.getData(); - //找到管理员已有的角色列表 - List<AdminRoleRelationPO> listOld = adminRoleRelationDao.list4Admin(adminId); - listOld = ParameterUtil.dealNull(listOld); - - //现在设置的角色id列表 - List<Long> listRoleId = ParameterUtil.dealNull(request.getListRole()); - - //批量新增 - if(BooleanUtils.isFalse(listRoleId.isEmpty())) { - List<AdminRoleRelationPO> list = listRoleId.stream() - .map(c -> { - AdminRoleRelationPO item = new AdminRoleRelationPO(); - item.setAdminId(adminId); - item.setRoleId(c); - item.setCreateTime(LocalDateTimeUtil.nowTimeStamp()); - return item; - }).collect(Collectors.toList()); - Boolean addList = adminRoleRelationDao.addList(list); - if(BooleanUtils.isFalse(addList)) { - return ExecutedResult.failed("给管理员“" + adminId + "”新增角色失败。" + listRoleId); - } - } - //批量删除 - if(BooleanUtils.isFalse(listOld.isEmpty())) { - List<Long> listId = listOld.stream() - .map(AdminRoleRelationPO::getId).collect(Collectors.toList()); - Boolean removeList = adminRoleRelationDao.remove(listId); - if(BooleanUtils.isFalse(removeList)) { - return ExecutedResult.failed("删除管理员“" + adminId + "”已有角色失败。" + listId); - } - } - // 删除指定用户的菜单和权限缓存 - adminPowerService.removePower4User(adminId); - return ExecutedResult.success(); - } - - // 获取管理员的角色列表 - public ExecutedResult<List<AdminRoleVO>> getListRole4Admin(Long id) { - List<AdminRoleVO> result = new ArrayList<>(); - - ExecutedResult<AdminUserPO> checkExists = this.check4Id(id); - if (checkExists.isFailed()) { - return ExecutedResult.failed(checkExists.getMsg()); - } - AdminUserPO find = checkExists.getData(); - List<AdminRolePO> list; - if (Objects.equals(find.getUserType(), EUserType.ADMIN.getValue())) { - list = roleDao.getList(); - } else { - //找到角色已有的菜单列表 - List<AdminRoleRelationPO> listRole = adminRoleRelationDao.list4Admin(id); - listRole = ParameterUtil.dealNull(listRole); - if (ListUtil.isNullOrEmpty(listRole)) { - return ExecutedResult.success(result); - } - List<Long> listRoleId = listRole.stream() - .map(AdminRoleRelationPO::getRoleId) - .collect(Collectors.toList()); - list = roleDao.getList(listRoleId); - } - if (ListUtil.isNotNullOrEmpty(list)) { - // 筛选状态 - list = list.stream() - .filter(c -> Objects.equals(c.getStatus(),EState.NORMAL.getValue())) - .collect(Collectors.toList()); - result = AdminRoleConvert.INSTANCE.toVo(list); - } - return ExecutedResult.success(result); - } - - /** - * 获取指定用户的菜单和权限 - * @param user 用户 - */ - public ResAdminLogin getListPower4Admin(AdminUserPO user) { - Long adminId = user.getId(); - - ResAdminLogin result = new ResAdminLogin(); - result.setId(user.getId()); - result.setUserType(user.getUserType()); - result.setMenus(new ArrayList<>()); - - List<AdminMenuPO> listMenu; - List<AdminPermissionPO> listPermission = null; - - // 管理员从缓存中取有所有权限(普通管理员剔除系统管理部分菜单) - if (LIST_ADMIN_TYPE.contains(user.getUserType())) { - listMenu = menusService.listAllWithCache(); - - if (Objects.equals(EUserType.ADMIN_USER.getValue(), user.getUserType())) { - List<Long> listNot = Arrays.asList(10101L, 10102L, 10103L); - listMenu = listMenu.stream().filter(c -> !listNot.contains(c.getId())).collect(Collectors.toList()); - } - - listPermission = permissionService.listAllWithCache(); - } else { - //找到角色已有的菜单列表 - List<AdminRoleRelationPO> listRole = adminRoleRelationDao.list4Admin(adminId); - if (ListUtil.isNullOrEmpty(listRole)) { - return result; - } - List<Long> listRoleId = listRole.stream() - .map(AdminRoleRelationPO::getRoleId) - .collect(Collectors.toList()); - - listMenu = menusService.listUserAllWithCache(user.getId(), listRoleId, adminPowerService::getListMenu4Role); - listPermission = permissionService.listUserAllWithCache(user.getId(), listRoleId, adminPowerService::getListPermission4Role); - } - if (ListUtil.isNotNullOrEmpty(listMenu)) { - // 筛选状态 - listMenu = listMenu.stream() - .filter(c -> Objects.equals(c.getStatus(), EState.NORMAL.getValue())) - .collect(Collectors.toList()); - Map<Long, List<AdminPermissionPO>> mapPermission = new HashMap<>(); - // 筛选权限状态 - if (ListUtil.isNotNullOrEmpty(listPermission)) { - // 筛选状态 - mapPermission = listPermission.stream() - .filter(c -> Objects.equals(c.getStatus(), EState.NORMAL.getValue())) - .collect(Collectors.groupingBy(AdminPermissionPO::getMenuId)); - } - - List<AdminMenuPO> listRoot = listMenu.stream().filter(c -> Objects.equals(c.getLevel(), 1)).collect(Collectors.toList()); - listRoot = listRoot.stream() - .sorted(Comparator.comparing(AdminMenuPO::getSort)) - .collect(Collectors.toList()); - if (ListUtil.isNotNullOrEmpty(listRoot)) { - for (AdminMenuPO item : listRoot) { - ResAdminMenuTreeAndPermission view = AdminMenuConvert.INSTANCE.toTreeVo(item); - adminPowerService.fillChildMenu(view, listMenu, mapPermission); - adminPowerService.fillPermission4Menu(view, mapPermission); - result.getMenus().add(view); - } - } - } - if (ListUtil.isNotNullOrEmpty(listPermission)) { - // 筛选状态 - List<String> listPermissionSn = listPermission.stream() - .filter(c -> Objects.equals(c.getStatus(), EState.NORMAL.getValue())) - .sorted(Comparator.comparing(AdminPermissionPO::getMenuId)) - .map(AdminPermissionPO::getSn) - .collect(Collectors.toList()); - result.setListPermission(listPermissionSn); - } - return result; - } -} diff --git a/src/main/java/com/lunhan/xxx/service/BaseService.java b/src/main/java/com/lunhan/xxx/service/BaseService.java deleted file mode 100644 index ddb35cd..0000000 --- a/src/main/java/com/lunhan/xxx/service/BaseService.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.lunhan.xxx.service; - -import com.lunhan.xxx.common.ConstantFactory; -import com.lunhan.xxx.common.util.NumericUtil; -import com.lunhan.xxx.entity.dto.SearchBasicDTO; - -public class BaseService { - public void dealPager(SearchBasicDTO search) { - if(NumericUtil.tryParseInt(search.getLimit()).compareTo(0) < 1) { - search.setLimit(ConstantFactory.PAGE_SIZE_DEFAULT); - } - if(NumericUtil.tryParseInt(search.getPage()).compareTo(0) < 1) { - search.setPage(1); - } - } -} diff --git a/src/main/java/com/lunhan/xxx/service/NoticeService.java b/src/main/java/com/lunhan/xxx/service/NoticeService.java deleted file mode 100644 index 49d9315..0000000 --- a/src/main/java/com/lunhan/xxx/service/NoticeService.java +++ /dev/null @@ -1,168 +0,0 @@ -package com.lunhan.xxx.service; - -import com.lunhan.xxx.common.ExecutedResult; -import com.lunhan.xxx.common.PagerResult; -import com.lunhan.xxx.common.jwt.LoginUserDTO; -import com.lunhan.xxx.common.model.Tuple; -import com.lunhan.xxx.common.util.*; -import com.lunhan.xxx.entity.enums.EState; -import com.lunhan.xxx.entity.request.ReqSetSort; -import com.lunhan.xxx.entity.request.notice.ReqCreateNotice; -import com.lunhan.xxx.entity.request.notice.ReqModifyNotice; -import com.lunhan.xxx.entity.search.SearchNotice; -import com.lunhan.xxx.repository.impl.AdminUserMapperImpl; -import com.lunhan.xxx.repository.impl.NoticeMapperImpl; -import com.lunhan.xxx.repository.po.NoticePO; -import com.lunhan.xxx.repository.vo.NoticeVO; -import com.lunhan.xxx.service.dto.NoticeDetail; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; - -/** - * 公告相关服务 - * - * @author lin.liu - * @date 2023/02/26 - */ -@Service -public class NoticeService extends BaseService { - @Autowired - private NoticeMapperImpl dao; - @Autowired - private AdminUserMapperImpl adminUserDao; - - public ExecutedResult<Long> create(ReqCreateNotice request, LoginUserDTO user) { - Long now = LocalDateTimeUtil.nowTimeStamp(); - - // 转换po - NoticePO item = CopierUtil.mapTo(request, NoticePO.class); - // 设置发布人 - item.setPublishUser(user.getNickName()); - // 截取摘要 - item.setSummary(request.getContent().substring(0, 80)); - // 设置记录创建时间 - item.setCreateTime(now); - item.setStatus(EState.NORMAL.getValue()); - item.setSort(NumericUtil.tryParseInt(request.getSort(), 0)); - - int rowCount = dao.insert(item); - if (rowCount == 1) { - return ExecutedResult.success(item.getId()); - } - return ExecutedResult.failed("创建[公告]失败"); - } - - public ExecutedResult<String> modify(ReqModifyNotice request) { - // 验证记录是否存在 - ExecutedResult<NoticePO> checkExists = this.check4Id(request.getId()); - if (checkExists.isFailed()) { - return ExecutedResult.failed(checkExists.getMsg()); - } - - // 转换po - NoticePO item = CopierUtil.mapTo(request, NoticePO.class); - // 截取摘要 - item.setSummary(request.getContent().substring(0, 80)); - item.setStatus(NumericUtil.tryParseInt(request.getStatus(), EState.NORMAL.getValue())); - item.setSort(NumericUtil.tryParseInt(request.getSort(), 0)); - - int rowCount = this.dao.updateById(item); - if (rowCount == 1) { - return ExecutedResult.failed("编辑[公告]失败。"); - } - return ExecutedResult.success(); - } - - public ExecutedResult<NoticeDetail> get(Long id) { - NoticeDetail result = new NoticeDetail(); - - NoticePO find = dao.get(id); - if (null != find) { - result = CopierUtil.mapTo(find, NoticeDetail.class); - } - return ExecutedResult.success(result); - } - - public ExecutedResult<String> changeStatus(Long id, EState state) { - // 验证记录是否存在 - ExecutedResult<NoticePO> checkExists = this.check4Id(id); - if (checkExists.isFailed()) { - return ExecutedResult.failed(checkExists.getMsg()); - } - NoticePO item = new NoticePO(); - item.setId(id); - item.setStatus(state.getValue()); - - int rowCount = this.dao.updateById(item); - if (rowCount == 1) { - return ExecutedResult.failed("[公告]状态修改失败。"); - } - return ExecutedResult.success(); - } - - public ExecutedResult<String> setSort(ReqSetSort request) { - // 验证记录是否存在 - ExecutedResult<NoticePO> checkExists = this.check4Id(request.getId()); - if (checkExists.isFailed()) { - return ExecutedResult.failed(checkExists.getMsg()); - } - NoticePO item = new NoticePO(); - item.setId(request.getId()); - item.setSort(request.getSort()); - - int rowCount = this.dao.updateById(item); - if (rowCount == 1) { - return ExecutedResult.failed("[公告]排序值设置失败。"); - } - return ExecutedResult.success(); - } - - public ExecutedResult<List<NoticeVO>> getList(List<Long> listId) { - List<NoticeVO> result = new ArrayList<>(); - - List<NoticePO> list = this.dao.getList(listId); - if (ListUtil.isNotNullOrEmpty(list)) { - result = CopierUtil.mapTo(list, NoticeVO.class); - } - return ExecutedResult.success(result); - } - - public ExecutedResult<PagerResult<NoticeVO>> search(SearchNotice search) { - // 处理创建时间范围-查询参数 - Tuple<String, String> createTimeRange = ParameterUtil.getTimeRange(search.getCreateTimeRange()); - if (StringUtil.isNotNullOrEmpty(createTimeRange.getItem1())) { - search.setCreateTimeStart(LocalDateTimeUtil.getTimeStamp(createTimeRange.getItem1()).getTime()); - } - if (StringUtil.isNotNullOrEmpty(createTimeRange.getItem2())) { - search.setCreateTimeEnd(LocalDateTimeUtil.getTimeStamp(createTimeRange.getItem2()).getTime()); - } - if (NumericUtil.tryParseInt(search.getStatus(), 0).compareTo(0) < 1 && ListUtil.isNullOrEmpty(search.getListStatus())) { - search.setStatus(EState.NORMAL.getValue()); - } - - - PagerResult<NoticePO> pageList = dao.search(search); - List<NoticeVO> listVo = new ArrayList<>(); - List<NoticePO> list = pageList.getList(); - if (ListUtil.isNotNullOrEmpty(list)) { - pageList.setLastId(list.get(list.size() - 1).getId()); - // 转换vo - listVo = CopierUtil.mapTo(list, NoticeVO.class); - } - PagerResult<NoticeVO> result = new PagerResult<>(pageList.getLimit(), pageList.getPage(), pageList.getTotal(), listVo); - result.setLastId(pageList.getLastId()); - return ExecutedResult.success(result); - } - - protected ExecutedResult<NoticePO> check4Id(Long id) { - NoticePO exists = dao.get(id); - if (Objects.isNull(exists)) { - return ExecutedResult.failed("[公告]不存在:" + id); - } - return ExecutedResult.success(exists); - } -} diff --git a/src/main/java/com/lunhan/xxx/service/SysDictDataService.java b/src/main/java/com/lunhan/xxx/service/SysDictDataService.java deleted file mode 100644 index a6e6a54..0000000 --- a/src/main/java/com/lunhan/xxx/service/SysDictDataService.java +++ /dev/null @@ -1,390 +0,0 @@ -/** -# __----~~~~~~~~~~~------___ -# . . ~~//====...... __--~ ~~ -# -. \_|// |||\\ ~~~~~~::::... /~ -# ___-==_ _-~o~ \/ ||| \\ _/~~- -# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ -# _-~~ .=~ | \\-_ '-~7 /- / || \ / -# .~ .~ | \\ -_ / /- / || \ / -# / ____ / | \\ ~-_/ /|- _/ .|| \ / -# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ -# ' ~-| /| |-~\~~ __--~~ -# |-~~-_/ | | ~\_ _-~ /\ -# / \ \__ \/~ \__ -# _--~ _/ | .-~~____--~-/ ~~==. -# ((->/~ '.|||' -_| ~~-/ , . _|| -# -_ ~\ ~~---l__i__i__i--~~_/ -# _-~-__ ~) \--______________--~~ -# //.-~~~-~_--~- |-------~~~~~~~~ -# //.-~~~--\ -# 神兽保佑 -# 永无BUG! -*/ -package com.lunhan.xxx.service; - -import com.lunhan.xxx.common.ExecutedResult; -import com.lunhan.xxx.common.PagerResult; -import com.lunhan.xxx.common.enums.EYesOrNo; -import com.lunhan.xxx.common.jwt.LoginUserDTO; -import com.lunhan.xxx.common.model.Tuple; -import com.lunhan.xxx.common.util.ListUtil; -import com.lunhan.xxx.common.util.LocalDateTimeUtil; -import com.lunhan.xxx.common.util.ParameterUtil; -import com.lunhan.xxx.common.util.StringUtil; -import com.lunhan.xxx.entity.enums.EState; -import com.lunhan.xxx.entity.request.sysdictdata.ReqCreateSysDictData; -import com.lunhan.xxx.entity.request.sysdictdata.ReqModifySysDictData; -import com.lunhan.xxx.entity.search.SearchSysDictData; -import com.lunhan.xxx.repository.impl.SysDictDataMapperImpl; -import com.lunhan.xxx.repository.impl.SysDictTypeMapperImpl; -import com.lunhan.xxx.repository.po.SysDictDataPO; -import com.lunhan.xxx.repository.po.SysDictTypePO; -import com.lunhan.xxx.repository.vo.SysDictDataVO; -import com.lunhan.xxx.service.convert.SysDictDataConvert; -import org.apache.commons.lang3.BooleanUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.cache.annotation.CacheEvict; -import org.springframework.cache.annotation.Cacheable; -import org.springframework.stereotype.Service; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.function.Function; -import java.util.stream.Collectors; - -/** - * 字典数据表 - * @author lin.liu - * @description 字典数据表 - */ -@Service -public class SysDictDataService extends BaseService { - @Autowired - private SysDictDataMapperImpl mapper; - @Autowired - private SysDictTypeMapperImpl dictTypeMapper; - - @Autowired - private SysDictTypeService dictTypeService; - - - public ExecutedResult<Long> create(ReqCreateSysDictData request, LoginUserDTO loginUser) { - // 校验类型 - dictTypeService.check4TypeExc(request.getDictType()); - - // 转换po - SysDictDataPO item = SysDictDataConvert.INSTANCE.toCreate(request); - // 设置状态 - item.setStatus(EState.NORMAL.getValue()); - // 设置记录创建时间 - item.setCreateTime(LocalDateTimeUtil.nowTimeStamp()); - // 是否删除(逻辑删除)初始值 - item.setIsDelete(EYesOrNo.NO.getValue()); - - int rowCount = mapper.insert(item); - if (rowCount != 1) { - return ExecutedResult.failed("创建[字典数据表]失败。"); - } - // 删除所有缓存 - this.removeAllTypeCache(); - return ExecutedResult.success(item.getId()); - } - - public ExecutedResult<String> modify(ReqModifySysDictData request, LoginUserDTO loginUser) { - // 验证记录是否存在 - ExecutedResult<SysDictDataPO> checkExists = this.check4Id(request.getId()); - if (checkExists.isFailed()) { - return ExecutedResult.failed(checkExists.getMsg()); - } - // 转换po - SysDictDataPO item = SysDictDataConvert.INSTANCE.toModify(request); - - int rowCount = mapper.updateById(item); - if (rowCount != 1) { - return ExecutedResult.failed("编辑[字典数据表]失败。"); - } - // 删除所有缓存 - this.removeAllTypeCache(); - return ExecutedResult.success(); - } - - public ExecutedResult<SysDictDataVO> get(Long id) { - SysDictDataVO result = new SysDictDataVO(); - - SysDictDataPO find = mapper.get(id); - if (null != find) { - // 转换po - result = SysDictDataConvert.INSTANCE.toVo(find); - // 赋值类型名称 - result.setDictTypeTxt(""); - - SysDictTypePO type = dictTypeMapper.get4Type(find.getDictType()); - if (Objects.nonNull(type)) { - result.setDictTypeTxt(type.getDictName()); - } - } - return ExecutedResult.success(result); - } - - // public ExecutedResult<String> stop(Long id) { -// // 验证记录是否存在 -// ExecutedResult<SysDictDataPO> checkExists = this.check4Id(id); -// if (checkExists.isFailed()) { -// return ExecutedResult.failed(checkExists.getMsg()); -// } -// SysDictDataPO item = new SysDictDataPO(); -// item.setId(id); -// item.setStatus(EState.DISABLED.getValue()); -// -// int rowCount = mapper.updateById(item); -// if (rowCount != 1) { -// return ExecutedResult.failed("停用[字典数据表]失败。"); -// } -// return ExecutedResult.success(); -// } -// -// public ExecutedResult<String> enable(Long id) { -// // 验证记录是否存在 -// ExecutedResult<SysDictDataPO> checkExists = this.check4Id(id); -// if (checkExists.isFailed()) { -// return ExecutedResult.failed(checkExists.getMsg()); -// } -// SysDictDataPO item = new SysDictDataPO(); -// item.setId(id); -// item.setStatus(EState.NORMAL.getValue()); -// -// int rowCount = mapper.updateById(item);\n" + -// if (rowCount != 1) { -// return ExecutedResult.failed("启用[字典数据表]失败。"); -// } -// return ExecutedResult.success(); -// } -// -// public ExecutedResult<String> setSort(ReqSetSort request) { -// // 验证记录是否存在 -// ExecutedResult<SysDictDataPO> checkExists = this.check4Id(request.getId()); -// if (checkExists.isFailed()) { -// return ExecutedResult.failed(checkExists.getMsg()); -// } -// SysDictDataPO item = new SysDictDataPO(); -// item.setId(request.getId()); -// item.setSort(request.getSort()); -// -// int rowCount = mapper.updateById(item);\n" + -// if (rowCount != 1) { -// return ExecutedResult.failed("设置[字典数据表]排序值失败。"); -// } -// return ExecutedResult.success(); -// } -// -// public ExecutedResult<String> listSetSort(ReqListSetSort request) { -// // id列表 -// List<Long> listId = request.getList().stream().map(ReqSetSort::getId).collect(Collectors.toList()); -// // 验证记录是否存在 -// ExecutedResult<List<SysDictDataPO>> checkExists = this.check4Id(listId); -// if (checkExists.isFailed()) { -// return ExecutedResult.failed(checkExists.getMsg()); -// } -// -// List<SysDictDataPO> listUpdate = request.getList().stream() -// .map(c -> { -// SysDictDataPO item = new SysDictDataPO(); -// item.setId(c.getId()); -// item.setSort(c.getSort()); -// return item; -// }) -// .collect(Collectors.toList()); -// Boolean result = mapper.modifyList(listUpdate); -// if (result) { -// return ExecutedResult.success(); -// } -// return ExecutedResult.failed("[字典数据表]设置排序值失败"); -// } -// - public ExecutedResult<String> remove(Long id) { - Boolean result = mapper.remove(id); - if (BooleanUtils.isFalse(result)) { - return ExecutedResult.failed("删除[字典数据表]失败。"); - } - // 删除所有缓存 - this.removeAllTypeCache(); - return ExecutedResult.success(); - } - - public ExecutedResult<String> removeList(List<Long> ids) { - Boolean result = mapper.remove(ids); - if (BooleanUtils.isFalse(result)) { - return ExecutedResult.failed("删除[字典数据表]失败。"); - } - // 删除所有缓存 - this.removeAllTypeCache(); - return ExecutedResult.success(); - } - - /** - * 根据类型查询数据 - * @param type 字典类型 - */ - public ExecutedResult<List<SysDictDataVO>> getListByType(String type) { - List<SysDictDataVO> result = new ArrayList<>(); - - List<SysDictDataPO> list = this.mapper.getListByType(type); - if (ListUtil.isNotNullOrEmpty(list)) { - List<SysDictTypePO> listType = dictTypeMapper.get4Type( - list.stream() - .map(SysDictDataPO::getDictType) - .distinct() - .collect(Collectors.toList()) - ); - Map<Object, SysDictTypePO> map4Type = listType.stream().collect(Collectors.toMap(SysDictTypePO::getId, c -> c)); - - for (SysDictDataPO item : list) { - // 转化vo - SysDictDataVO vo = SysDictDataConvert.INSTANCE.toVo(item); - // 赋值类型名称 - vo.setDictTypeTxt(""); - - if (map4Type.containsKey(item.getDictType())) { - vo.setDictTypeTxt(map4Type.get(item.getDictType()).getDictName()); - } - - result.add(vo); - } - } - return ExecutedResult.success(result); - } - - /** - * 根据类型查询数据 - * @param listId 字典数据id列表 - */ - public ExecutedResult<List<SysDictDataVO>> getList(List<Long> listId) { - List<SysDictDataVO> result = new ArrayList<>(); - - List<SysDictDataPO> list = mapper.getList(listId); - if (ListUtil.isNotNullOrEmpty(list)) { - List<SysDictTypePO> listType = dictTypeMapper.get4Type( - list.stream() - .map(SysDictDataPO::getDictType) - .distinct() - .collect(Collectors.toList()) - ); - Map<Object, SysDictTypePO> map4Type = listType.stream().collect(Collectors.toMap(SysDictTypePO::getId, c -> c)); - - for (SysDictDataPO item : list) { - // 转化vo - SysDictDataVO vo = SysDictDataConvert.INSTANCE.toVo(item); - // 赋值类型名称 - vo.setDictTypeTxt(""); - - if (map4Type.containsKey(item.getDictType())) { - vo.setDictTypeTxt(map4Type.get(item.getDictType()).getDictName()); - } - - result.add(vo); - } - } - return ExecutedResult.success(result); - } - - public ExecutedResult<PagerResult<SysDictDataVO>> search(SearchSysDictData search) { - // 处理创建时间范围-查询参数 - Tuple<String, String> createTimeRange = ParameterUtil.getTimeRange(search.getCreateTimeRange()); - if (StringUtil.isNotNullOrEmpty(createTimeRange.getItem1())) { - search.setCreateTimeStart(LocalDateTimeUtil.getTimeStamp(createTimeRange.getItem1()).getTime()); - } - if (StringUtil.isNotNullOrEmpty(createTimeRange.getItem2())) { - search.setCreateTimeEnd(LocalDateTimeUtil.getTimeStamp(createTimeRange.getItem2()).getTime()); - } - - PagerResult<SysDictDataPO> pageList = mapper.search(search); - List<SysDictDataVO> listVo = new ArrayList<>(); - List<SysDictDataPO> list = pageList.getList(); - if (ListUtil.isNotNullOrEmpty(list)) { - pageList.setLastId(list.get(list.size() - 1).getId()); - List<SysDictTypePO> listType = dictTypeMapper.get4Type( - list.stream() - .map(SysDictDataPO::getDictType) - .distinct() - .collect(Collectors.toList()) - ); - Map<Object, SysDictTypePO> map4Type = listType.stream().collect(Collectors.toMap(SysDictTypePO::getId, c -> c)); - - for (SysDictDataPO item : list) { - // 转化vo - SysDictDataVO vo = SysDictDataConvert.INSTANCE.toVo(item); - // 赋值类型名称 - vo.setDictTypeTxt(""); - - if (map4Type.containsKey(item.getDictType())) { - vo.setDictTypeTxt(map4Type.get(item.getDictType()).getDictName()); - } - - listVo.add(vo); - } - } - PagerResult<SysDictDataVO> result = new PagerResult<>(pageList.getLimit(), pageList.getPage(), pageList.getTotal(), listVo); - result.setLastId(pageList.getLastId()); - return ExecutedResult.success(result); - } - - protected ExecutedResult<SysDictDataPO> check4Id(Long id) { - SysDictDataPO exists = mapper.get(id); - if (Objects.isNull(exists)) { - return ExecutedResult.failed("[字典数据表]不存在:" + id); - } - return ExecutedResult.success(exists); - } - - protected ExecutedResult<List<SysDictDataPO>> check4Id(List<Long> listId) { - // 从数据库查找字典数据表 - List<SysDictDataPO> list = mapper.getList(listId); - if (ListUtil.isNullOrEmpty(list)) { - return ExecutedResult.failed("[字典数据表]不存在." + listId); - } - // 数据库找到的id列表 - List<Long> listIdFind = list.stream().map(SysDictDataPO::getId).collect(Collectors.toList()); - // 数量不一致 - if (listId.size() != listIdFind.size()) { - // 筛选数据库不存在的字典数据表 - List<Long> listIdNotFound = listId.stream().filter(c -> !listIdFind.contains(c)).collect(Collectors.toList()); - if (ListUtil.isNullOrEmpty(list)) { - return ExecutedResult.failed("[字典数据表]不存在." + listIdNotFound); - } - } - return ExecutedResult.success(list); - } - - - /** - * 获取指定类型下的字典列表(缓存) - */ - @Cacheable(cacheManager = "json4RedisCacheManager", value = "dictDataCache4Type", key = "#type") - private List<SysDictDataVO> list4TypeWithCache(String type, Function<String, List<SysDictDataVO>> funcList4Type) { - return funcList4Type.apply(type); - } - // 根据类型删除字典列表缓存 - @CacheEvict(cacheNames = "dictDataCache4Type", key = "#type") - private void removeList4TypeCache(String type) { - } - // 删除所有用户拥有的菜单缓存 - @CacheEvict(cacheNames = "dictDataCache4Type", allEntries = true) - public void removeAllTypeCache() { - } - - public List<SysDictDataVO> list4TypeWithCache(String type) { - return this.list4TypeWithCache(type, (t) -> this.getListByType(t).getData()); - } - - public Map<String, SysDictDataVO> map4TypeWithCache(String type) { - List<SysDictDataVO> list = this.list4TypeWithCache(type); - return list.stream().collect(Collectors.toMap(SysDictDataVO::getDictValue, c -> c)); - } - - public Map<String, SysDictDataVO> mapLabel4TypeWithCache(String type) { - List<SysDictDataVO> list = this.list4TypeWithCache(type); - return list.stream().collect(Collectors.toMap(SysDictDataVO::getDictLabel, c -> c)); - } -} diff --git a/src/main/java/com/lunhan/xxx/service/SysDictTypeService.java b/src/main/java/com/lunhan/xxx/service/SysDictTypeService.java deleted file mode 100644 index cdc0c85..0000000 --- a/src/main/java/com/lunhan/xxx/service/SysDictTypeService.java +++ /dev/null @@ -1,323 +0,0 @@ -/** -# __----~~~~~~~~~~~------___ -# . . ~~//====...... __--~ ~~ -# -. \_|// |||\\ ~~~~~~::::... /~ -# ___-==_ _-~o~ \/ ||| \\ _/~~- -# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ -# _-~~ .=~ | \\-_ '-~7 /- / || \ / -# .~ .~ | \\ -_ / /- / || \ / -# / ____ / | \\ ~-_/ /|- _/ .|| \ / -# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ -# ' ~-| /| |-~\~~ __--~~ -# |-~~-_/ | | ~\_ _-~ /\ -# / \ \__ \/~ \__ -# _--~ _/ | .-~~____--~-/ ~~==. -# ((->/~ '.|||' -_| ~~-/ , . _|| -# -_ ~\ ~~---l__i__i__i--~~_/ -# _-~-__ ~) \--______________--~~ -# //.-~~~-~_--~- |-------~~~~~~~~ -# //.-~~~--\ -# 神兽保佑 -# 永无BUG! -*/ -package com.lunhan.xxx.service; - -import com.lunhan.xxx.common.ExecutedResult; -import com.lunhan.xxx.common.PagerResult; -import com.lunhan.xxx.common.enums.EResultCode; -import com.lunhan.xxx.common.enums.EYesOrNo; -import com.lunhan.xxx.common.exceptions.BusinessException; -import com.lunhan.xxx.common.model.Tuple; -import com.lunhan.xxx.common.util.*; -import com.lunhan.xxx.entity.enums.EState; -import com.lunhan.xxx.entity.request.sysdicttype.ReqCreateSysDictType; -import com.lunhan.xxx.entity.request.sysdicttype.ReqModifySysDictType; -import com.lunhan.xxx.entity.search.SearchSysDictType; -import com.lunhan.xxx.repository.impl.SysDictDataMapperImpl; -import com.lunhan.xxx.repository.impl.SysDictTypeMapperImpl; -import com.lunhan.xxx.repository.po.SysDictTypePO; -import com.lunhan.xxx.repository.vo.SysDictTypeVO; -import org.apache.commons.lang3.BooleanUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; -import java.util.stream.Collectors; - -/** - * 字典类型表 - * @author lin.liu - * @description 字典类型表 - */ -@Service -public class SysDictTypeService extends BaseService { - @Autowired - private SysDictTypeMapperImpl mapper; - @Autowired - private SysDictDataMapperImpl sysDictDataMapper; - - public ExecutedResult<Long> create(ReqCreateSysDictType request) { - // 转换po - SysDictTypePO item = CopierUtil.mapTo(request, SysDictTypePO.class); - // 设置状态 - item.setStatus(EState.NORMAL.getValue()); - // 设置记录创建时间 - item.setCreateTime(LocalDateTimeUtil.nowTimeStamp()); - // 是否删除(逻辑删除)初始值 - item.setIsDelete(EYesOrNo.NO.getValue()); - - int rowCount = mapper.insert(item); - if (rowCount != 1) { - return ExecutedResult.failed("创建[字典类型表]失败。"); - } - return ExecutedResult.success(item.getId()); - } - - public ExecutedResult<String> modify(ReqModifySysDictType request) { - // 验证记录是否存在 - ExecutedResult<SysDictTypePO> checkExists = this.check4Id(request.getId()); - if (checkExists.isFailed()) { - return ExecutedResult.failed(checkExists.getMsg()); - } - // 转换po - SysDictTypePO item = CopierUtil.mapTo(request, SysDictTypePO.class); - - int rowCount = mapper.updateById(item); - if (rowCount != 1) { - return ExecutedResult.failed("编辑[字典类型表]失败。"); - } - return ExecutedResult.success(); - } - - public ExecutedResult<SysDictTypeVO> get(Long id) { - SysDictTypeVO result = new SysDictTypeVO(); - - SysDictTypePO find = mapper.get(id); - if (null != find) { - result = CopierUtil.mapTo(find, SysDictTypeVO.class); - } - return ExecutedResult.success(result); - } - public ExecutedResult<String> remove(Long id) { - // 验证记录是否存在 - ExecutedResult<SysDictTypePO> checkExists = this.check4Id(id); - if (checkExists.isFailed()) { - return ExecutedResult.failed(checkExists.getMsg()); - } - - Long exitCount = sysDictDataMapper.count4Type(checkExists.getData().getDictType()); - if(exitCount.compareTo(0L) > 0){ - return ExecutedResult.failed("此类型有关联的字典数据,不能删除"); - } - Boolean result = this.mapper.remove(id); - - if (BooleanUtils.isFalse(result)) { - return ExecutedResult.failed("删除[字典类型表]失败。"); - } - return ExecutedResult.success(); - } - - public ExecutedResult<String> removeList(List<Long> ids) { - // 验证记录是否存在 - ExecutedResult<List<SysDictTypePO>> checkExists = this.check4Id(ids); - if (checkExists.isFailed()) { - return ExecutedResult.failed(checkExists.getMsg()); - } - - List<String> listExitDataType = sysDictDataMapper.findExists4Type( - checkExists.getData().stream() - .map(SysDictTypePO::getDictType) - .collect(Collectors.toList()) - ); - if (ListUtil.isNotNullOrEmpty(listExitDataType)) { - return ExecutedResult.failed("以下类型有关联的字典数据,不能删除." + listExitDataType); - } - - Boolean result = mapper.remove(ids); - if (BooleanUtils.isFalse(result)) { - return ExecutedResult.failed("删除[字典类型表]失败。"); - } - return ExecutedResult.success(); - } - -// public ExecutedResult<String> stop(Long id) { -// // 验证记录是否存在 -// ExecutedResult<SysDictTypePO> checkExists = this.check4Id(id); -// if (checkExists.isFailed()) { -// return ExecutedResult.failed(checkExists.getMsg()); -// } -// SysDictTypePO item = new SysDictTypePO(); -// item.setId(id); -// item.setStatus(EState.DISABLED.getValue()); -// -// int rowCount = mapper.updateById(item); -// if (rowCount != 1) { -// return ExecutedResult.failed("停用[字典类型表]失败。"); -// } -// return ExecutedResult.success(); -// } -// -// public ExecutedResult<String> enable(Long id) { -// // 验证记录是否存在 -// ExecutedResult<SysDictTypePO> checkExists = this.check4Id(id); -// if (checkExists.isFailed()) { -// return ExecutedResult.failed(checkExists.getMsg()); -// } -// SysDictTypePO item = new SysDictTypePO(); -// item.setId(id); -// item.setStatus(EState.NORMAL.getValue()); -// -// int rowCount = mapper.updateById(item);\n" + -// if (rowCount != 1) { -// return ExecutedResult.failed("启用[字典类型表]失败。"); -// } -// return ExecutedResult.success(); -// } -// -// public ExecutedResult<String> setSort(ReqSetSort request) { -// // 验证记录是否存在 -// ExecutedResult<SysDictTypePO> checkExists = this.check4Id(request.getId()); -// if (checkExists.isFailed()) { -// return ExecutedResult.failed(checkExists.getMsg()); -// } -// SysDictTypePO item = new SysDictTypePO(); -// item.setId(request.getId()); -// item.setSort(request.getSort()); -// -// int rowCount = mapper.updateById(item);\n" + -// if (rowCount != 1) { -// return ExecutedResult.failed("设置[字典类型表]排序值失败。"); -// } -// return ExecutedResult.success(); -// } -// -// public ExecutedResult<String> listSetSort(ReqListSetSort request) { -// // id列表 -// List<Long> listId = request.getList().stream().map(ReqSetSort::getId).collect(Collectors.toList()); -// // 验证记录是否存在 -// ExecutedResult<List<SysDictTypePO>> checkExists = this.check4Id(listId); -// if (checkExists.isFailed()) { -// return ExecutedResult.failed(checkExists.getMsg()); -// } -// -// List<SysDictTypePO> listUpdate = request.getList().stream() -// .map(c -> { -// SysDictTypePO item = new SysDictTypePO(); -// item.setId(c.getId()); -// item.setSort(c.getSort()); -// return item; -// }) -// .collect(Collectors.toList()); -// Boolean result = mapper.modifyList(listUpdate); -// if (result) { -// return ExecutedResult.success(); -// } -// return ExecutedResult.failed("[字典类型表]设置排序值失败"); -// } -// -// public ExecutedResult<String> remove(Long id) { -// Boolean result = mapper.deleteLogic(id); -// if (BooleanUtils.isFalse(result)) { -// return ExecutedResult.failed("删除[字典类型表]失败。"); -// } -// return ExecutedResult.success(); -// } -// -// public ExecutedResult<String> removeList(List<Long> ids) { -// Boolean result = mapper.deleteLogic(ids); -// if (BooleanUtils.isFalse(result)) { -// return ExecutedResult.failed("删除[字典类型表]失败。"); -// } -// return ExecutedResult.success(); -// } - - public ExecutedResult<List<SysDictTypeVO>> getList(List<Long> listId) { - List<SysDictTypeVO> result = new ArrayList<>(); - - List<SysDictTypePO> list = mapper.getList(listId); - if (ListUtil.isNotNullOrEmpty(list)) { - result = CopierUtil.mapTo(list, SysDictTypeVO.class); - } - return ExecutedResult.success(result); - } - - public ExecutedResult<PagerResult<SysDictTypeVO>> search(SearchSysDictType search) { - // 处理创建时间范围-查询参数 - Tuple<String, String> createTimeRange = ParameterUtil.getTimeRange(search.getCreateTimeRange()); - if (StringUtil.isNotNullOrEmpty(createTimeRange.getItem1())) { - search.setCreateTimeStart(LocalDateTimeUtil.getTimeStamp(createTimeRange.getItem1()).getTime()); - } - if (StringUtil.isNotNullOrEmpty(createTimeRange.getItem2())) { - search.setCreateTimeEnd(LocalDateTimeUtil.getTimeStamp(createTimeRange.getItem2()).getTime()); - } - - PagerResult<SysDictTypePO> pageList = mapper.search(search); - List<SysDictTypeVO> listVo = new ArrayList<>(); - List<SysDictTypePO> list = pageList.getList(); - if (ListUtil.isNotNullOrEmpty(list)) { - pageList.setLastId(list.get(list.size() - 1).getId()); - // 转换vo - listVo = CopierUtil.mapTo(list, SysDictTypeVO.class); - } - PagerResult<SysDictTypeVO> result = new PagerResult<>(pageList.getLimit(), pageList.getPage(), pageList.getTotal(), listVo); - result.setLastId(pageList.getLastId()); - return ExecutedResult.success(result); - } - - protected ExecutedResult<SysDictTypePO> check4Id(Long id) { - SysDictTypePO exists = mapper.get(id); - if (Objects.isNull(exists)) { - return ExecutedResult.failed("[字典类型]不存在:" + id); - } - return ExecutedResult.success(exists); - } - protected SysDictTypePO check4IdExc(Long id) { - ExecutedResult<SysDictTypePO> check = this.check4Id(id); - if (check.isFailed()) { - throw new BusinessException(EResultCode.NOT_FOUND, check.getMsg()); - } - return check.getData(); - } - protected ExecutedResult<List<SysDictTypePO>> check4Id(List<Long> listId) { - // 从数据库查找字典类型表 - List<SysDictTypePO> list = mapper.getList(listId); - if (ListUtil.isNullOrEmpty(list)) { - return ExecutedResult.failed("[字典类型]不存在." + listId); - } - // 数据库找到的id列表 - List<Long> listIdFind = list.stream().map(SysDictTypePO::getId).collect(Collectors.toList()); - // 数量不一致 - if (listId.size() != listIdFind.size()) { - // 筛选数据库不存在的字典类型表 - List<Long> listIdNotFound = listId.stream().filter(c -> !listIdFind.contains(c)).collect(Collectors.toList()); - if (ListUtil.isNullOrEmpty(list)) { - return ExecutedResult.failed("[字典类型]不存在." + listIdNotFound); - } - } - return ExecutedResult.success(list); - } - protected List<SysDictTypePO> check4IdExc(List<Long> listId) { - ExecutedResult<List<SysDictTypePO>> check = this.check4Id(listId); - if (check.isFailed()) { - throw new BusinessException(EResultCode.NOT_FOUND, check.getMsg()); - } - return check.getData(); - } - - protected ExecutedResult<SysDictTypePO> check4Type(String type) { - SysDictTypePO exists = mapper.get4Type(type); - if (Objects.isNull(exists)) { - return ExecutedResult.failed("[字典类型]不存在:" + type); - } - return ExecutedResult.success(exists); - } - protected SysDictTypePO check4TypeExc(String type) { - ExecutedResult<SysDictTypePO> check = this.check4Type(type); - if (check.isFailed()) { - throw new BusinessException(EResultCode.NOT_FOUND, check.getMsg()); - } - return check.getData(); - } -} diff --git a/src/main/java/com/lunhan/xxx/service/TestInfoService.java b/src/main/java/com/lunhan/xxx/service/TestInfoService.java deleted file mode 100644 index c070314..0000000 --- a/src/main/java/com/lunhan/xxx/service/TestInfoService.java +++ /dev/null @@ -1,250 +0,0 @@ -package com.lunhan.xxx.service; - -import com.lunhan.xxx.common.ExecutedResult; -import com.lunhan.xxx.common.PagerResult; -import com.lunhan.xxx.common.enums.EYesOrNo; -import com.lunhan.xxx.common.model.Tuple; -import com.lunhan.xxx.common.util.*; -import com.lunhan.xxx.entity.enums.EState; -import com.lunhan.xxx.entity.request.ReqListSetSort; -import com.lunhan.xxx.entity.request.ReqSetSort; -import com.lunhan.xxx.entity.request.test.ReqCreateTestInfo; -import com.lunhan.xxx.entity.request.test.ReqModifyTestInfo; -import com.lunhan.xxx.entity.search.SearchTestInfo; -import com.lunhan.xxx.repository.impl.TestInfoMapperImpl; -import com.lunhan.xxx.repository.po.TestInfoPO; -import com.lunhan.xxx.repository.vo.TestInfoVO; -import com.lunhan.xxx.service.convert.TestInfoConvert; -import org.apache.commons.lang3.BooleanUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import java.util.*; -import java.util.stream.Collectors; - -/** - * 测试信息 相关服务 - */ -@Service -public class TestInfoService extends BaseService { - @Autowired - private TestInfoMapperImpl mapper; - - public ExecutedResult<Long> create(ReqCreateTestInfo request) { - // 转换po - TestInfoPO item = TestInfoConvert.INSTANCE.toCreate(request); - // 设置状态 - item.setStatus(EState.NORMAL.getValue()); - // 设置记录创建时间 - item.setCreateTime(LocalDateTimeUtil.nowTimeStamp()); - // 非逻辑删除 - item.setIsDelete(EYesOrNo.NO.getValue()); - - int rowCount = mapper.insert(item); - if (rowCount != 1) { - return ExecutedResult.failed("创建[测试信息]失败。"); - } - return ExecutedResult.success(item.getId()); - } - - public ExecutedResult<String> modify(ReqModifyTestInfo request) { - // 验证记录是否存在 - ExecutedResult<TestInfoPO> checkExists = this.check4Id(request.getId()); - if (checkExists.isFailed()) { - return ExecutedResult.failed(checkExists.getMsg()); - } - - // 转换po - TestInfoPO item = TestInfoConvert.INSTANCE.toModify(request); - - int rowCount = mapper.updateById(item); - if (rowCount != 1) { - return ExecutedResult.failed("编辑[测试信息]失败。"); - } - return ExecutedResult.success(); - } - - public ExecutedResult<TestInfoVO> get(Long id) { - TestInfoVO result = new TestInfoVO(); - - TestInfoPO find = mapper.selectById(id); - if (null != find) { - result = TestInfoConvert.INSTANCE.toVo(find); - } - return ExecutedResult.success(result); - } - - public ExecutedResult<String> stop(Long id) { - // 验证记录是否存在 - ExecutedResult<TestInfoPO> checkExists = this.check4Id(id); - if (checkExists.isFailed()) { - return ExecutedResult.failed(checkExists.getMsg()); - } - - TestInfoPO item = new TestInfoPO(); - item.setId(id); - item.setStatus(EState.DISABLED.getValue()); - - int rowCount = mapper.updateById(item); - if (rowCount != 1) { - return ExecutedResult.failed("停用[测试信息]失败。"); - } - return ExecutedResult.success(); - } - - public ExecutedResult<String> enable(Long id) { - // 验证记录是否存在 - ExecutedResult<TestInfoPO> checkExists = this.check4Id(id); - if (checkExists.isFailed()) { - return ExecutedResult.failed(checkExists.getMsg()); - } - - TestInfoPO item = new TestInfoPO(); - item.setId(id); - item.setStatus(EState.NORMAL.getValue()); - - int rowCount = mapper.updateById(item); - if (rowCount != 1) { - return ExecutedResult.failed("启用[测试信息]失败。"); - } - return ExecutedResult.success(); - } - - public ExecutedResult<String> setSort(ReqSetSort request) { - // 验证记录是否存在 - ExecutedResult<TestInfoPO> checkExists = this.check4Id(request.getId()); - if (checkExists.isFailed()) { - return ExecutedResult.failed(checkExists.getMsg()); - } - - TestInfoPO item = new TestInfoPO(); - item.setId(request.getId()); - item.setSort(request.getSort()); - - int rowCount = mapper.updateById(item); - if (rowCount != 1) { - return ExecutedResult.failed("[测试信息]设置排序值失败。"); - } - return ExecutedResult.success(); - } - - public ExecutedResult<String> listSetSort(ReqListSetSort request) { - // id列表 - List<Long> listId = request.getList().stream().map(ReqSetSort::getId).collect(Collectors.toList()); - // 验证记录是否存在 - ExecutedResult<List<TestInfoPO>> checkExists = this.check4Id(listId); - if (checkExists.isFailed()) { - return ExecutedResult.failed(checkExists.getMsg()); - } - - List<TestInfoPO> listUpdate = request.getList().stream() - .map(c -> { - TestInfoPO item = new TestInfoPO(); - item.setId(c.getId()); - item.setSort(c.getSort()); - return item; - }) - .collect(Collectors.toList()); - Boolean result = mapper.modifyList(listUpdate); - if (result) { - return ExecutedResult.success(); - } - return ExecutedResult.failed("[测试信息]设置排序值失败"); - } - - public ExecutedResult<String> remove(Long id) { - // 验证记录是否存在 - ExecutedResult<TestInfoPO> checkExists = this.check4Id(id); - if (checkExists.isFailed()) { - return ExecutedResult.failed(checkExists.getMsg()); - } - - Boolean result = mapper.deleteLogic(id); - if (BooleanUtils.isFalse(result)) { - return ExecutedResult.failed("删除[测试信息]失败。"); - } - return ExecutedResult.success(); - } - - public ExecutedResult<String> removeList(List<Long> listId) { - // 验证记录是否存在 - ExecutedResult<List<TestInfoPO>> checkExists = this.check4Id(listId); - if (checkExists.isFailed()) { - return ExecutedResult.failed(checkExists.getMsg()); - } - - Boolean result = mapper.deleteLogic(listId); - if (BooleanUtils.isFalse(result)) { - return ExecutedResult.failed("删除[测试信息]失败。"); - } - return ExecutedResult.success(); - } - - public ExecutedResult<List<TestInfoVO>> getList(List<Long> listId) { - List<TestInfoVO> result = new ArrayList<>(); - - List<TestInfoPO> list = mapper.getList(listId); - if (ListUtil.isNotNullOrEmpty(list)) { - result = CopierUtil.mapTo(list, TestInfoVO.class); - } - return ExecutedResult.success(result); - } - - public ExecutedResult<PagerResult<TestInfoVO>> search(SearchTestInfo search) { - // 处理创建时间范围-查询参数 - Tuple<String, String> createTimeRange = ParameterUtil.getTimeRange(search.getCreateTimeRange()); - if (StringUtil.isNotNullOrEmpty(createTimeRange.getItem1())) { - search.setCreateTimeStart(LocalDateTimeUtil.getTimeStamp(createTimeRange.getItem1()).getTime()); - } - if (StringUtil.isNotNullOrEmpty(createTimeRange.getItem2())) { - search.setCreateTimeEnd(LocalDateTimeUtil.getTimeStamp(createTimeRange.getItem2()).getTime()); - } - - PagerResult<TestInfoPO> pageList = mapper.search(search); - List<TestInfoVO> listVo = new ArrayList<>(); - List<TestInfoPO> list = pageList.getList(); - if (ListUtil.isNotNullOrEmpty(list)) { - pageList.setLastId(list.get(list.size() - 1).getId()); - // 转换vo - listVo = TestInfoConvert.INSTANCE.toVo(list); - } - PagerResult<TestInfoVO> result = new PagerResult<>(pageList.getLimit(), pageList.getPage(), pageList.getTotal(), listVo); - result.setLastId(pageList.getLastId()); - return ExecutedResult.success(result); - } - - protected ExecutedResult<TestInfoPO> check4Id(Long id) { - TestInfoPO exists = mapper.get(id); - if (Objects.isNull(exists)) { - return ExecutedResult.failed("[测试信息]不存在:" + id); - } - return ExecutedResult.success(exists); - } - protected ExecutedResult<List<TestInfoPO>> check4Id(List<Long> listId) { - // 从数据库查找测试信息 - List<TestInfoPO> list = mapper.getList(listId); - if (ListUtil.isNullOrEmpty(list)) { - return ExecutedResult.failed("[测试信息]不存在." + listId); - } - // 数据库找到的id列表 - List<Long> listIdFind = list.stream().map(TestInfoPO::getId).collect(Collectors.toList()); - // 数量不一致 - if (listId.size() != listIdFind.size()) { - // 筛选数据库不存在的测试信息 - List<Long> listIdNotFound = listId.stream().filter(c -> !listIdFind.contains(c)).collect(Collectors.toList()); - if (ListUtil.isNullOrEmpty(list)) { - return ExecutedResult.failed("[测试信息]不存在." + listIdNotFound); - } - } - return ExecutedResult.success(list); - } - - protected Map<Long, TestInfoPO> getMap4Id(List<Long> listId) { - List<TestInfoPO> list = mapper.getList(listId); - if (ListUtil.isNullOrEmpty(list)) { - return new HashMap<>(0); - } - return list.stream().collect(Collectors.toMap(TestInfoPO::getId, c -> c)); - } - -} diff --git a/src/main/java/com/lunhan/xxx/service/convert/AdminMenuConvert.java b/src/main/java/com/lunhan/xxx/service/convert/AdminMenuConvert.java deleted file mode 100644 index 3c40fb1..0000000 --- a/src/main/java/com/lunhan/xxx/service/convert/AdminMenuConvert.java +++ /dev/null @@ -1,51 +0,0 @@ -/** -# __----~~~~~~~~~~~------___ -# . . ~~//====...... __--~ ~~ -# -. \_|// |||\\ ~~~~~~::::... /~ -# ___-==_ _-~o~ \/ ||| \\ _/~~- -# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ -# _-~~ .=~ | \\-_ '-~7 /- / || \ / -# .~ .~ | \\ -_ / /- / || \ / -# / ____ / | \\ ~-_/ /|- _/ .|| \ / -# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ -# ' ~-| /| |-~\~~ __--~~ -# |-~~-_/ | | ~\_ _-~ /\ -# / \ \__ \/~ \__ -# _--~ _/ | .-~~____--~-/ ~~==. -# ((->/~ '.|||' -_| ~~-/ , . _|| -# -_ ~\ ~~---l__i__i__i--~~_/ -# _-~-__ ~) \--______________--~~ -# //.-~~~-~_--~- |-------~~~~~~~~ -# //.-~~~--\ -# 神兽保佑 -# 永无BUG! -*/ -package com.lunhan.xxx.service.convert; - -import com.lunhan.xxx.entity.request.adminmenu.ReqCreateAdminMenu; -import com.lunhan.xxx.entity.request.adminmenu.ReqModifyAdminMenu; -import com.lunhan.xxx.entity.response.admin.ResAdminMenuTreeAndPermission; -import com.lunhan.xxx.repository.po.AdminMenuPO; -import com.lunhan.xxx.repository.vo.AdminMenuVO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -/** - * 后台菜单 - * @author {#=author} - * @description 后台菜单 - */ -@Mapper -public interface AdminMenuConvert { - AdminMenuConvert INSTANCE = Mappers.getMapper(AdminMenuConvert.class); - - AdminMenuPO toCreate(ReqCreateAdminMenu request); - AdminMenuPO toModify(ReqModifyAdminMenu request); - - AdminMenuVO toVo(AdminMenuPO item); - List<AdminMenuVO> toVo(List<AdminMenuPO> list); - - ResAdminMenuTreeAndPermission toTreeVo(AdminMenuPO item); -} diff --git a/src/main/java/com/lunhan/xxx/service/convert/AdminMenusConvert.java b/src/main/java/com/lunhan/xxx/service/convert/AdminMenusConvert.java deleted file mode 100644 index a8308ec..0000000 --- a/src/main/java/com/lunhan/xxx/service/convert/AdminMenusConvert.java +++ /dev/null @@ -1,48 +0,0 @@ -/** -# __----~~~~~~~~~~~------___ -# . . ~~//====...... __--~ ~~ -# -. \_|// |||\\ ~~~~~~::::... /~ -# ___-==_ _-~o~ \/ ||| \\ _/~~- -# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ -# _-~~ .=~ | \\-_ '-~7 /- / || \ / -# .~ .~ | \\ -_ / /- / || \ / -# / ____ / | \\ ~-_/ /|- _/ .|| \ / -# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ -# ' ~-| /| |-~\~~ __--~~ -# |-~~-_/ | | ~\_ _-~ /\ -# / \ \__ \/~ \__ -# _--~ _/ | .-~~____--~-/ ~~==. -# ((->/~ '.|||' -_| ~~-/ , . _|| -# -_ ~\ ~~---l__i__i__i--~~_/ -# _-~-__ ~) \--______________--~~ -# //.-~~~-~_--~- |-------~~~~~~~~ -# //.-~~~--\ -# 神兽保佑 -# 永无BUG! -*/ -package com.lunhan.xxx.service.convert; - -import com.lunhan.xxx.entity.request.adminmenus.ReqCreateAdminMenus; -import com.lunhan.xxx.entity.request.adminmenus.ReqModifyAdminMenus; -import com.lunhan.xxx.repository.po.AdminMenusPO; -import com.lunhan.xxx.repository.vo.AdminMenusVO; - -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -/** - * 菜单信息 - * @author {#=author} - */ -@Mapper -public interface AdminMenusConvert { - AdminMenusConvert INSTANCE = Mappers.getMapper(AdminMenusConvert.class); - - AdminMenusPO toCreate(ReqCreateAdminMenus request); - AdminMenusPO toModify(ReqModifyAdminMenus request); - - AdminMenusVO toVo(AdminMenusPO item); - List<AdminMenusVO> toVo(List<AdminMenusPO> list); -} diff --git a/src/main/java/com/lunhan/xxx/service/convert/AdminPermissionConvert.java b/src/main/java/com/lunhan/xxx/service/convert/AdminPermissionConvert.java deleted file mode 100644 index 0cb82d8..0000000 --- a/src/main/java/com/lunhan/xxx/service/convert/AdminPermissionConvert.java +++ /dev/null @@ -1,52 +0,0 @@ -/** -# __----~~~~~~~~~~~------___ -# . . ~~//====...... __--~ ~~ -# -. \_|// |||\\ ~~~~~~::::... /~ -# ___-==_ _-~o~ \/ ||| \\ _/~~- -# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ -# _-~~ .=~ | \\-_ '-~7 /- / || \ / -# .~ .~ | \\ -_ / /- / || \ / -# / ____ / | \\ ~-_/ /|- _/ .|| \ / -# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ -# ' ~-| /| |-~\~~ __--~~ -# |-~~-_/ | | ~\_ _-~ /\ -# / \ \__ \/~ \__ -# _--~ _/ | .-~~____--~-/ ~~==. -# ((->/~ '.|||' -_| ~~-/ , . _|| -# -_ ~\ ~~---l__i__i__i--~~_/ -# _-~-__ ~) \--______________--~~ -# //.-~~~-~_--~- |-------~~~~~~~~ -# //.-~~~--\ -# 神兽保佑 -# 永无BUG! -*/ -package com.lunhan.xxx.service.convert; - -import com.lunhan.xxx.entity.request.adminpermission.ReqCreateAdminPermission; -import com.lunhan.xxx.entity.request.adminpermission.ReqModifyAdminPermission; -import com.lunhan.xxx.entity.response.admin.ResAdminPermission; -import com.lunhan.xxx.repository.po.AdminPermissionPO; -import com.lunhan.xxx.repository.vo.AdminPermissionVO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -/** - * 后台用户权限表 - * @author {#=author} - * @description 后台用户权限表 - */ -@Mapper -public interface AdminPermissionConvert { - AdminPermissionConvert INSTANCE = Mappers.getMapper(AdminPermissionConvert.class); - - AdminPermissionPO toCreate(ReqCreateAdminPermission request); - AdminPermissionPO toModify(ReqModifyAdminPermission request); - - AdminPermissionVO toVo(AdminPermissionPO item); - List<AdminPermissionVO> toVo(List<AdminPermissionPO> list); - - ResAdminPermission toDetail(AdminPermissionPO item); - List<ResAdminPermission> toDetail(List<AdminPermissionPO> list); -} diff --git a/src/main/java/com/lunhan/xxx/service/convert/AdminRoleConvert.java b/src/main/java/com/lunhan/xxx/service/convert/AdminRoleConvert.java deleted file mode 100644 index 64d7329..0000000 --- a/src/main/java/com/lunhan/xxx/service/convert/AdminRoleConvert.java +++ /dev/null @@ -1,48 +0,0 @@ -/** -# __----~~~~~~~~~~~------___ -# . . ~~//====...... __--~ ~~ -# -. \_|// |||\\ ~~~~~~::::... /~ -# ___-==_ _-~o~ \/ ||| \\ _/~~- -# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ -# _-~~ .=~ | \\-_ '-~7 /- / || \ / -# .~ .~ | \\ -_ / /- / || \ / -# / ____ / | \\ ~-_/ /|- _/ .|| \ / -# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ -# ' ~-| /| |-~\~~ __--~~ -# |-~~-_/ | | ~\_ _-~ /\ -# / \ \__ \/~ \__ -# _--~ _/ | .-~~____--~-/ ~~==. -# ((->/~ '.|||' -_| ~~-/ , . _|| -# -_ ~\ ~~---l__i__i__i--~~_/ -# _-~-__ ~) \--______________--~~ -# //.-~~~-~_--~- |-------~~~~~~~~ -# //.-~~~--\ -# 神兽保佑 -# 永无BUG! -*/ -package com.lunhan.xxx.service.convert; - -import com.lunhan.xxx.entity.request.adminrole.ReqCreateAdminRole; -import com.lunhan.xxx.entity.request.adminrole.ReqModifyAdminRole; -import com.lunhan.xxx.repository.po.AdminRolePO; -import com.lunhan.xxx.repository.vo.AdminRoleVO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -/** - * 后台用户角色表 - * @author {#=author} - * @description 后台用户角色表 - */ -@Mapper -public interface AdminRoleConvert { - AdminRoleConvert INSTANCE = Mappers.getMapper(AdminRoleConvert.class); - - AdminRolePO toCreate(ReqCreateAdminRole request); - AdminRolePO toModify(ReqModifyAdminRole request); - - AdminRoleVO toVo(AdminRolePO item); - List<AdminRoleVO> toVo(List<AdminRolePO> list); -} diff --git a/src/main/java/com/lunhan/xxx/service/convert/AdminRoleMenuRelationConvert.java b/src/main/java/com/lunhan/xxx/service/convert/AdminRoleMenuRelationConvert.java deleted file mode 100644 index d27cd56..0000000 --- a/src/main/java/com/lunhan/xxx/service/convert/AdminRoleMenuRelationConvert.java +++ /dev/null @@ -1,48 +0,0 @@ -/** -# __----~~~~~~~~~~~------___ -# . . ~~//====...... __--~ ~~ -# -. \_|// |||\\ ~~~~~~::::... /~ -# ___-==_ _-~o~ \/ ||| \\ _/~~- -# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ -# _-~~ .=~ | \\-_ '-~7 /- / || \ / -# .~ .~ | \\ -_ / /- / || \ / -# / ____ / | \\ ~-_/ /|- _/ .|| \ / -# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ -# ' ~-| /| |-~\~~ __--~~ -# |-~~-_/ | | ~\_ _-~ /\ -# / \ \__ \/~ \__ -# _--~ _/ | .-~~____--~-/ ~~==. -# ((->/~ '.|||' -_| ~~-/ , . _|| -# -_ ~\ ~~---l__i__i__i--~~_/ -# _-~-__ ~) \--______________--~~ -# //.-~~~-~_--~- |-------~~~~~~~~ -# //.-~~~--\ -# 神兽保佑 -# 永无BUG! -*/ -package com.lunhan.xxx.service.convert; - -import com.lunhan.xxx.entity.request.adminrolemenurelation.ReqCreateAdminRoleMenuRelation; -import com.lunhan.xxx.entity.request.adminrolemenurelation.ReqModifyAdminRoleMenuRelation; -import com.lunhan.xxx.repository.po.AdminRoleMenuRelationPO; -import com.lunhan.xxx.repository.vo.AdminRoleMenuRelationVO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -/** - * 后台角色菜单关系表 - * @author {#=author} - * @description 后台角色菜单关系表 - */ -@Mapper -public interface AdminRoleMenuRelationConvert { - AdminRoleMenuRelationConvert INSTANCE = Mappers.getMapper(AdminRoleMenuRelationConvert.class); - - AdminRoleMenuRelationPO toCreate(ReqCreateAdminRoleMenuRelation request); - AdminRoleMenuRelationPO toModify(ReqModifyAdminRoleMenuRelation request); - - AdminRoleMenuRelationVO toVo(AdminRoleMenuRelationPO item); - List<AdminRoleMenuRelationVO> toVo(List<AdminRoleMenuRelationPO> list); -} diff --git a/src/main/java/com/lunhan/xxx/service/convert/AdminRolePermissionRelationConvert.java b/src/main/java/com/lunhan/xxx/service/convert/AdminRolePermissionRelationConvert.java deleted file mode 100644 index 4176108..0000000 --- a/src/main/java/com/lunhan/xxx/service/convert/AdminRolePermissionRelationConvert.java +++ /dev/null @@ -1,48 +0,0 @@ -/** -# __----~~~~~~~~~~~------___ -# . . ~~//====...... __--~ ~~ -# -. \_|// |||\\ ~~~~~~::::... /~ -# ___-==_ _-~o~ \/ ||| \\ _/~~- -# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ -# _-~~ .=~ | \\-_ '-~7 /- / || \ / -# .~ .~ | \\ -_ / /- / || \ / -# / ____ / | \\ ~-_/ /|- _/ .|| \ / -# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ -# ' ~-| /| |-~\~~ __--~~ -# |-~~-_/ | | ~\_ _-~ /\ -# / \ \__ \/~ \__ -# _--~ _/ | .-~~____--~-/ ~~==. -# ((->/~ '.|||' -_| ~~-/ , . _|| -# -_ ~\ ~~---l__i__i__i--~~_/ -# _-~-__ ~) \--______________--~~ -# //.-~~~-~_--~- |-------~~~~~~~~ -# //.-~~~--\ -# 神兽保佑 -# 永无BUG! -*/ -package com.lunhan.xxx.service.convert; - -import com.lunhan.xxx.entity.request.adminrolepermissionrelation.ReqCreateAdminRolePermissionRelation; -import com.lunhan.xxx.entity.request.adminrolepermissionrelation.ReqModifyAdminRolePermissionRelation; -import com.lunhan.xxx.repository.po.AdminRolePermissionRelationPO; -import com.lunhan.xxx.repository.vo.AdminRolePermissionRelationVO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -/** - * 后台角色权限关系表 - * @author {#=author} - * @description 后台角色权限关系表 - */ -@Mapper -public interface AdminRolePermissionRelationConvert { - AdminRolePermissionRelationConvert INSTANCE = Mappers.getMapper(AdminRolePermissionRelationConvert.class); - - AdminRolePermissionRelationPO toCreate(ReqCreateAdminRolePermissionRelation request); - AdminRolePermissionRelationPO toModify(ReqModifyAdminRolePermissionRelation request); - - AdminRolePermissionRelationVO toVo(AdminRolePermissionRelationPO item); - List<AdminRolePermissionRelationVO> toVo(List<AdminRolePermissionRelationPO> list); -} diff --git a/src/main/java/com/lunhan/xxx/service/convert/AdminRoleRelationConvert.java b/src/main/java/com/lunhan/xxx/service/convert/AdminRoleRelationConvert.java deleted file mode 100644 index 7e1c69c..0000000 --- a/src/main/java/com/lunhan/xxx/service/convert/AdminRoleRelationConvert.java +++ /dev/null @@ -1,48 +0,0 @@ -/** -# __----~~~~~~~~~~~------___ -# . . ~~//====...... __--~ ~~ -# -. \_|// |||\\ ~~~~~~::::... /~ -# ___-==_ _-~o~ \/ ||| \\ _/~~- -# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ -# _-~~ .=~ | \\-_ '-~7 /- / || \ / -# .~ .~ | \\ -_ / /- / || \ / -# / ____ / | \\ ~-_/ /|- _/ .|| \ / -# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ -# ' ~-| /| |-~\~~ __--~~ -# |-~~-_/ | | ~\_ _-~ /\ -# / \ \__ \/~ \__ -# _--~ _/ | .-~~____--~-/ ~~==. -# ((->/~ '.|||' -_| ~~-/ , . _|| -# -_ ~\ ~~---l__i__i__i--~~_/ -# _-~-__ ~) \--______________--~~ -# //.-~~~-~_--~- |-------~~~~~~~~ -# //.-~~~--\ -# 神兽保佑 -# 永无BUG! -*/ -package com.lunhan.xxx.service.convert; - -import com.lunhan.xxx.entity.request.adminrolerelation.ReqCreateAdminRoleRelation; -import com.lunhan.xxx.entity.request.adminrolerelation.ReqModifyAdminRoleRelation; -import com.lunhan.xxx.repository.po.AdminRoleRelationPO; -import com.lunhan.xxx.repository.vo.AdminRoleRelationVO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -/** - * 后台用户和角色关系表 - * @author {#=author} - * @description 后台用户和角色关系表 - */ -@Mapper -public interface AdminRoleRelationConvert { - AdminRoleRelationConvert INSTANCE = Mappers.getMapper(AdminRoleRelationConvert.class); - - AdminRoleRelationPO toCreate(ReqCreateAdminRoleRelation request); - AdminRoleRelationPO toModify(ReqModifyAdminRoleRelation request); - - AdminRoleRelationVO toVo(AdminRoleRelationPO item); - List<AdminRoleRelationVO> toVo(List<AdminRoleRelationPO> list); -} diff --git a/src/main/java/com/lunhan/xxx/service/convert/AdminUserConvert.java b/src/main/java/com/lunhan/xxx/service/convert/AdminUserConvert.java deleted file mode 100644 index 0cb6ea6..0000000 --- a/src/main/java/com/lunhan/xxx/service/convert/AdminUserConvert.java +++ /dev/null @@ -1,53 +0,0 @@ -/** -# __----~~~~~~~~~~~------___ -# . . ~~//====...... __--~ ~~ -# -. \_|// |||\\ ~~~~~~::::... /~ -# ___-==_ _-~o~ \/ ||| \\ _/~~- -# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ -# _-~~ .=~ | \\-_ '-~7 /- / || \ / -# .~ .~ | \\ -_ / /- / || \ / -# / ____ / | \\ ~-_/ /|- _/ .|| \ / -# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ -# ' ~-| /| |-~\~~ __--~~ -# |-~~-_/ | | ~\_ _-~ /\ -# / \ \__ \/~ \__ -# _--~ _/ | .-~~____--~-/ ~~==. -# ((->/~ '.|||' -_| ~~-/ , . _|| -# -_ ~\ ~~---l__i__i__i--~~_/ -# _-~-__ ~) \--______________--~~ -# //.-~~~-~_--~- |-------~~~~~~~~ -# //.-~~~--\ -# 神兽保佑 -# 永无BUG! -*/ -package com.lunhan.xxx.service.convert; - -import com.lunhan.xxx.entity.request.adminuser.ReqCreateAdminUser; -import com.lunhan.xxx.entity.request.adminuser.ReqModifyAdminUser; -import com.lunhan.xxx.repository.po.AdminUserPO; -import com.lunhan.xxx.repository.vo.AdminUserVO; -import com.lunhan.xxx.service.dto.ResAdminDetail; -import org.mapstruct.Mapper; -import org.mapstruct.Named; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -/** - * 管理员帐号 - * @author {#=author} - * @description 管理员帐号 - */ -@Mapper -public interface AdminUserConvert { - AdminUserConvert INSTANCE = Mappers.getMapper(AdminUserConvert.class); - - AdminUserPO toCreate(ReqCreateAdminUser request); - AdminUserPO toModify(ReqModifyAdminUser request); - - AdminUserVO toVo(AdminUserPO item); - List<AdminUserVO> toVo(List<AdminUserPO> list); - - @Named("toDetail") - ResAdminDetail toDetail(AdminUserPO data); -} diff --git a/src/main/java/com/lunhan/xxx/service/convert/NoticeConvert.java b/src/main/java/com/lunhan/xxx/service/convert/NoticeConvert.java deleted file mode 100644 index 886cc15..0000000 --- a/src/main/java/com/lunhan/xxx/service/convert/NoticeConvert.java +++ /dev/null @@ -1,48 +0,0 @@ -/** -# __----~~~~~~~~~~~------___ -# . . ~~//====...... __--~ ~~ -# -. \_|// |||\\ ~~~~~~::::... /~ -# ___-==_ _-~o~ \/ ||| \\ _/~~- -# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ -# _-~~ .=~ | \\-_ '-~7 /- / || \ / -# .~ .~ | \\ -_ / /- / || \ / -# / ____ / | \\ ~-_/ /|- _/ .|| \ / -# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ -# ' ~-| /| |-~\~~ __--~~ -# |-~~-_/ | | ~\_ _-~ /\ -# / \ \__ \/~ \__ -# _--~ _/ | .-~~____--~-/ ~~==. -# ((->/~ '.|||' -_| ~~-/ , . _|| -# -_ ~\ ~~---l__i__i__i--~~_/ -# _-~-__ ~) \--______________--~~ -# //.-~~~-~_--~- |-------~~~~~~~~ -# //.-~~~--\ -# 神兽保佑 -# 永无BUG! -*/ -package com.lunhan.xxx.service.convert; - -import com.lunhan.xxx.entity.request.notice.ReqCreateNotice; -import com.lunhan.xxx.entity.request.notice.ReqModifyNotice; -import com.lunhan.xxx.repository.po.NoticePO; -import com.lunhan.xxx.repository.vo.NoticeVO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -/** - * 公告 - * @author {#=author} - * @description 公告 - */ -@Mapper -public interface NoticeConvert { - NoticeConvert INSTANCE = Mappers.getMapper(NoticeConvert.class); - - NoticePO toCreate(ReqCreateNotice request); - NoticePO toModify(ReqModifyNotice request); - - NoticeVO toVo(NoticePO item); - List<NoticeVO> toVo(List<NoticePO> list); -} diff --git a/src/main/java/com/lunhan/xxx/service/convert/QuartzTaskErrorConvert.java b/src/main/java/com/lunhan/xxx/service/convert/QuartzTaskErrorConvert.java deleted file mode 100644 index 83792ca..0000000 --- a/src/main/java/com/lunhan/xxx/service/convert/QuartzTaskErrorConvert.java +++ /dev/null @@ -1,48 +0,0 @@ -/** -# __----~~~~~~~~~~~------___ -# . . ~~//====...... __--~ ~~ -# -. \_|// |||\\ ~~~~~~::::... /~ -# ___-==_ _-~o~ \/ ||| \\ _/~~- -# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ -# _-~~ .=~ | \\-_ '-~7 /- / || \ / -# .~ .~ | \\ -_ / /- / || \ / -# / ____ / | \\ ~-_/ /|- _/ .|| \ / -# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ -# ' ~-| /| |-~\~~ __--~~ -# |-~~-_/ | | ~\_ _-~ /\ -# / \ \__ \/~ \__ -# _--~ _/ | .-~~____--~-/ ~~==. -# ((->/~ '.|||' -_| ~~-/ , . _|| -# -_ ~\ ~~---l__i__i__i--~~_/ -# _-~-__ ~) \--______________--~~ -# //.-~~~-~_--~- |-------~~~~~~~~ -# //.-~~~--\ -# 神兽保佑 -# 永无BUG! -*/ -package com.lunhan.xxx.service.convert; - -import com.lunhan.xxx.entity.request.quartztaskerror.ReqCreateQuartzTaskError; -import com.lunhan.xxx.entity.request.quartztaskerror.ReqModifyQuartzTaskError; -import com.lunhan.xxx.repository.po.QuartzTaskErrorPO; -import com.lunhan.xxx.repository.vo.QuartzTaskErrorVO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -/** - * 定时任务错误信息 - * @author {#=author} - * @description 定时任务错误信息 - */ -@Mapper -public interface QuartzTaskErrorConvert { - QuartzTaskErrorConvert INSTANCE = Mappers.getMapper(QuartzTaskErrorConvert.class); - - QuartzTaskErrorPO toCreate(ReqCreateQuartzTaskError request); - QuartzTaskErrorPO toModify(ReqModifyQuartzTaskError request); - - QuartzTaskErrorVO toVo(QuartzTaskErrorPO item); - List<QuartzTaskErrorVO> toVo(List<QuartzTaskErrorPO> list); -} diff --git a/src/main/java/com/lunhan/xxx/service/convert/QuartzTaskInfoConvert.java b/src/main/java/com/lunhan/xxx/service/convert/QuartzTaskInfoConvert.java deleted file mode 100644 index 4e58b0b..0000000 --- a/src/main/java/com/lunhan/xxx/service/convert/QuartzTaskInfoConvert.java +++ /dev/null @@ -1,48 +0,0 @@ -/** -# __----~~~~~~~~~~~------___ -# . . ~~//====...... __--~ ~~ -# -. \_|// |||\\ ~~~~~~::::... /~ -# ___-==_ _-~o~ \/ ||| \\ _/~~- -# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ -# _-~~ .=~ | \\-_ '-~7 /- / || \ / -# .~ .~ | \\ -_ / /- / || \ / -# / ____ / | \\ ~-_/ /|- _/ .|| \ / -# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ -# ' ~-| /| |-~\~~ __--~~ -# |-~~-_/ | | ~\_ _-~ /\ -# / \ \__ \/~ \__ -# _--~ _/ | .-~~____--~-/ ~~==. -# ((->/~ '.|||' -_| ~~-/ , . _|| -# -_ ~\ ~~---l__i__i__i--~~_/ -# _-~-__ ~) \--______________--~~ -# //.-~~~-~_--~- |-------~~~~~~~~ -# //.-~~~--\ -# 神兽保佑 -# 永无BUG! -*/ -package com.lunhan.xxx.service.convert; - -import com.lunhan.xxx.entity.request.quartztaskinfo.ReqCreateQuartzTaskInfo; -import com.lunhan.xxx.entity.request.quartztaskinfo.ReqModifyQuartzTaskInfo; -import com.lunhan.xxx.repository.po.QuartzTaskInfoPO; -import com.lunhan.xxx.repository.vo.QuartzTaskInfoVO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -/** - * 定时任务信息 - * @author {#=author} - * @description 定时任务信息 - */ -@Mapper -public interface QuartzTaskInfoConvert { - QuartzTaskInfoConvert INSTANCE = Mappers.getMapper(QuartzTaskInfoConvert.class); - - QuartzTaskInfoPO toCreate(ReqCreateQuartzTaskInfo request); - QuartzTaskInfoPO toModify(ReqModifyQuartzTaskInfo request); - - QuartzTaskInfoVO toVo(QuartzTaskInfoPO item); - List<QuartzTaskInfoVO> toVo(List<QuartzTaskInfoPO> list); -} diff --git a/src/main/java/com/lunhan/xxx/service/convert/QuartzTaskRecordConvert.java b/src/main/java/com/lunhan/xxx/service/convert/QuartzTaskRecordConvert.java deleted file mode 100644 index 7579fad..0000000 --- a/src/main/java/com/lunhan/xxx/service/convert/QuartzTaskRecordConvert.java +++ /dev/null @@ -1,48 +0,0 @@ -/** -# __----~~~~~~~~~~~------___ -# . . ~~//====...... __--~ ~~ -# -. \_|// |||\\ ~~~~~~::::... /~ -# ___-==_ _-~o~ \/ ||| \\ _/~~- -# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ -# _-~~ .=~ | \\-_ '-~7 /- / || \ / -# .~ .~ | \\ -_ / /- / || \ / -# / ____ / | \\ ~-_/ /|- _/ .|| \ / -# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ -# ' ~-| /| |-~\~~ __--~~ -# |-~~-_/ | | ~\_ _-~ /\ -# / \ \__ \/~ \__ -# _--~ _/ | .-~~____--~-/ ~~==. -# ((->/~ '.|||' -_| ~~-/ , . _|| -# -_ ~\ ~~---l__i__i__i--~~_/ -# _-~-__ ~) \--______________--~~ -# //.-~~~-~_--~- |-------~~~~~~~~ -# //.-~~~--\ -# 神兽保佑 -# 永无BUG! -*/ -package com.lunhan.xxx.service.convert; - -import com.lunhan.xxx.entity.request.quartztaskrecord.ReqCreateQuartzTaskRecord; -import com.lunhan.xxx.entity.request.quartztaskrecord.ReqModifyQuartzTaskRecord; -import com.lunhan.xxx.repository.po.QuartzTaskRecordPO; -import com.lunhan.xxx.repository.vo.QuartzTaskRecordVO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -/** - * 定时任务执行记录 - * @author {#=author} - * @description 定时任务执行记录 - */ -@Mapper -public interface QuartzTaskRecordConvert { - QuartzTaskRecordConvert INSTANCE = Mappers.getMapper(QuartzTaskRecordConvert.class); - - QuartzTaskRecordPO toCreate(ReqCreateQuartzTaskRecord request); - QuartzTaskRecordPO toModify(ReqModifyQuartzTaskRecord request); - - QuartzTaskRecordVO toVo(QuartzTaskRecordPO item); - List<QuartzTaskRecordVO> toVo(List<QuartzTaskRecordPO> list); -} diff --git a/src/main/java/com/lunhan/xxx/service/convert/SysDictDataConvert.java b/src/main/java/com/lunhan/xxx/service/convert/SysDictDataConvert.java deleted file mode 100644 index 17cfbed..0000000 --- a/src/main/java/com/lunhan/xxx/service/convert/SysDictDataConvert.java +++ /dev/null @@ -1,48 +0,0 @@ -/** -# __----~~~~~~~~~~~------___ -# . . ~~//====...... __--~ ~~ -# -. \_|// |||\\ ~~~~~~::::... /~ -# ___-==_ _-~o~ \/ ||| \\ _/~~- -# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ -# _-~~ .=~ | \\-_ '-~7 /- / || \ / -# .~ .~ | \\ -_ / /- / || \ / -# / ____ / | \\ ~-_/ /|- _/ .|| \ / -# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ -# ' ~-| /| |-~\~~ __--~~ -# |-~~-_/ | | ~\_ _-~ /\ -# / \ \__ \/~ \__ -# _--~ _/ | .-~~____--~-/ ~~==. -# ((->/~ '.|||' -_| ~~-/ , . _|| -# -_ ~\ ~~---l__i__i__i--~~_/ -# _-~-__ ~) \--______________--~~ -# //.-~~~-~_--~- |-------~~~~~~~~ -# //.-~~~--\ -# 神兽保佑 -# 永无BUG! -*/ -package com.lunhan.xxx.service.convert; - -import com.lunhan.xxx.entity.request.sysdictdata.ReqCreateSysDictData; -import com.lunhan.xxx.entity.request.sysdictdata.ReqModifySysDictData; -import com.lunhan.xxx.repository.po.SysDictDataPO; -import com.lunhan.xxx.repository.vo.SysDictDataVO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -/** - * 字典数据表 - * @author {#=author} - * @description 字典数据表 - */ -@Mapper -public interface SysDictDataConvert { - SysDictDataConvert INSTANCE = Mappers.getMapper(SysDictDataConvert.class); - - SysDictDataPO toCreate(ReqCreateSysDictData request); - SysDictDataPO toModify(ReqModifySysDictData request); - - SysDictDataVO toVo(SysDictDataPO item); - List<SysDictDataVO> toVo(List<SysDictDataPO> list); -} diff --git a/src/main/java/com/lunhan/xxx/service/convert/SysDictTypeConvert.java b/src/main/java/com/lunhan/xxx/service/convert/SysDictTypeConvert.java deleted file mode 100644 index 450c4ad..0000000 --- a/src/main/java/com/lunhan/xxx/service/convert/SysDictTypeConvert.java +++ /dev/null @@ -1,48 +0,0 @@ -/** -# __----~~~~~~~~~~~------___ -# . . ~~//====...... __--~ ~~ -# -. \_|// |||\\ ~~~~~~::::... /~ -# ___-==_ _-~o~ \/ ||| \\ _/~~- -# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ -# _-~~ .=~ | \\-_ '-~7 /- / || \ / -# .~ .~ | \\ -_ / /- / || \ / -# / ____ / | \\ ~-_/ /|- _/ .|| \ / -# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ -# ' ~-| /| |-~\~~ __--~~ -# |-~~-_/ | | ~\_ _-~ /\ -# / \ \__ \/~ \__ -# _--~ _/ | .-~~____--~-/ ~~==. -# ((->/~ '.|||' -_| ~~-/ , . _|| -# -_ ~\ ~~---l__i__i__i--~~_/ -# _-~-__ ~) \--______________--~~ -# //.-~~~-~_--~- |-------~~~~~~~~ -# //.-~~~--\ -# 神兽保佑 -# 永无BUG! -*/ -package com.lunhan.xxx.service.convert; - -import com.lunhan.xxx.entity.request.sysdicttype.ReqCreateSysDictType; -import com.lunhan.xxx.entity.request.sysdicttype.ReqModifySysDictType; -import com.lunhan.xxx.repository.po.SysDictTypePO; -import com.lunhan.xxx.repository.vo.SysDictTypeVO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -/** - * 字典类型表 - * @author {#=author} - * @description 字典类型表 - */ -@Mapper -public interface SysDictTypeConvert { - SysDictTypeConvert INSTANCE = Mappers.getMapper(SysDictTypeConvert.class); - - SysDictTypePO toCreate(ReqCreateSysDictType request); - SysDictTypePO toModify(ReqModifySysDictType request); - - SysDictTypeVO toVo(SysDictTypePO item); - List<SysDictTypeVO> toVo(List<SysDictTypePO> list); -} diff --git a/src/main/java/com/lunhan/xxx/service/convert/TestInfoConvert.java b/src/main/java/com/lunhan/xxx/service/convert/TestInfoConvert.java deleted file mode 100644 index c0fc66e..0000000 --- a/src/main/java/com/lunhan/xxx/service/convert/TestInfoConvert.java +++ /dev/null @@ -1,48 +0,0 @@ -/** -# __----~~~~~~~~~~~------___ -# . . ~~//====...... __--~ ~~ -# -. \_|// |||\\ ~~~~~~::::... /~ -# ___-==_ _-~o~ \/ ||| \\ _/~~- -# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ -# _-~~ .=~ | \\-_ '-~7 /- / || \ / -# .~ .~ | \\ -_ / /- / || \ / -# / ____ / | \\ ~-_/ /|- _/ .|| \ / -# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ -# ' ~-| /| |-~\~~ __--~~ -# |-~~-_/ | | ~\_ _-~ /\ -# / \ \__ \/~ \__ -# _--~ _/ | .-~~____--~-/ ~~==. -# ((->/~ '.|||' -_| ~~-/ , . _|| -# -_ ~\ ~~---l__i__i__i--~~_/ -# _-~-__ ~) \--______________--~~ -# //.-~~~-~_--~- |-------~~~~~~~~ -# //.-~~~--\ -# 神兽保佑 -# 永无BUG! -*/ -package com.lunhan.xxx.service.convert; - -import com.lunhan.xxx.entity.request.test.ReqCreateTestInfo; -import com.lunhan.xxx.entity.request.test.ReqModifyTestInfo; -import com.lunhan.xxx.repository.po.TestInfoPO; -import com.lunhan.xxx.repository.vo.TestInfoVO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -/** - * 水表账户停用启用申请表 - * @author {#=author} - * @description 水表账户停用启用申请表 - */ -@Mapper -public interface TestInfoConvert { - TestInfoConvert INSTANCE = Mappers.getMapper(TestInfoConvert.class); - - TestInfoPO toCreate(ReqCreateTestInfo request); - TestInfoPO toModify(ReqModifyTestInfo request); - - TestInfoVO toVo(TestInfoPO item); - List<TestInfoVO> toVo(List<TestInfoPO> list); -} diff --git a/src/main/java/com/lunhan/xxx/service/dto/NoticeDetail.java b/src/main/java/com/lunhan/xxx/service/dto/NoticeDetail.java deleted file mode 100644 index e1cae8d..0000000 --- a/src/main/java/com/lunhan/xxx/service/dto/NoticeDetail.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.lunhan.xxx.service.dto; - -import com.lunhan.xxx.repository.vo.NoticeVO; -import lombok.Data; - -@Data -public class NoticeDetail extends NoticeVO { - /** - * 内容 - */ - private String content; -} diff --git a/src/main/java/com/lunhan/xxx/service/dto/ResAdminDetail.java b/src/main/java/com/lunhan/xxx/service/dto/ResAdminDetail.java deleted file mode 100644 index 6386807..0000000 --- a/src/main/java/com/lunhan/xxx/service/dto/ResAdminDetail.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.lunhan.xxx.service.dto; - -import com.lunhan.xxx.repository.vo.AdminRoleVO; -import com.lunhan.xxx.repository.vo.AdminUserVO; -import lombok.Data; - -import java.util.List; - -@Data -public class ResAdminDetail extends AdminUserVO { - /** - * 角色列表 - */ - private List<AdminRoleVO> listRole; -} diff --git a/src/main/java/com/lunhan/xxx/service/quartz/QuartzExecutor.java b/src/main/java/com/lunhan/xxx/service/quartz/QuartzExecutor.java deleted file mode 100644 index 5efefa2..0000000 --- a/src/main/java/com/lunhan/xxx/service/quartz/QuartzExecutor.java +++ /dev/null @@ -1,72 +0,0 @@ -package com.lunhan.xxx.service.quartz; - -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; -import com.lunhan.xxx.common.ConstantFactory; -import com.lunhan.xxx.common.ExecutedResult; -import com.lunhan.xxx.common.util.LocalDateTimeUtil; -import com.lunhan.xxx.common.util.NumericUtil; -import com.lunhan.xxx.common.util.StringUtil; -import com.lunhan.xxx.repository.impl.QuartzTaskErrorMapperImpl; -import com.lunhan.xxx.repository.impl.QuartzTaskRecordMapperImpl; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import java.lang.reflect.Method; -import java.time.LocalDateTime; -import java.util.Objects; - -@Service -public class QuartzExecutor { - private static Logger logger = LoggerFactory.getLogger(QuartzExecutor.class); - - @Autowired - private QuartzTaskRecordMapperImpl taskRecordsDao; - @Autowired - private QuartzTaskErrorMapperImpl taskErrorsDao; - - /** - * 执行job - * @param executorName 执行器名称(方法名) - * @param jobParameter 执行参数 - */ - public ExecutedResult<String> execute(String executorName, String jobParameter) { - try { - // 根据执行器key,查找执行器的方法(入参:String jobParameter,返参:ExecutedResult<String>) - Method method = QuartzExecutor.class.getMethod(executorName, String.class); - return (ExecutedResult<String>)method.invoke(this, jobParameter); - } catch (Exception e) { - return ExecutedResult.failed(e.toString()); - } - } - - /*** - * job执行器-清理任务调度日志 - * @param jobParameter 执行参数 - */ - public ExecutedResult<String> clearQuartzLog(String jobParameter) { - try { - int keepDays = ConstantFactory.NUM15; - if (StringUtil.isNotNullOrEmpty(jobParameter)) { - JsonElement element = new JsonParser().parse(jobParameter); - if (Objects.nonNull(element) && !element.isJsonNull()) { - JsonObject data = element.getAsJsonObject(); - if (data.has("keepDays") && !data.get("keepDays").isJsonNull()) { - keepDays = NumericUtil.tryParseInt(data.get("keepDays").getAsString(), ConstantFactory.NUM15); - } - } - } - LocalDateTime today = LocalDateTimeUtil.todayFirst(); - LocalDateTime limitDate = LocalDateTimeUtil.dateTimeAddDay(today, -1L * keepDays); - - taskRecordsDao.clear4DateTime(LocalDateTimeUtil.getTimeStamp(limitDate).getTime()); - taskErrorsDao.clear4DateTime(LocalDateTimeUtil.getTimeStamp(limitDate).getTime()); - return ExecutedResult.success(); - } catch (Exception e) { - return ExecutedResult.failed(e.toString()); - } - } -} diff --git a/src/main/java/com/lunhan/xxx/service/quartz/QuartzMainJobFactory.java b/src/main/java/com/lunhan/xxx/service/quartz/QuartzMainJobFactory.java deleted file mode 100644 index 078de50..0000000 --- a/src/main/java/com/lunhan/xxx/service/quartz/QuartzMainJobFactory.java +++ /dev/null @@ -1,99 +0,0 @@ -package com.lunhan.xxx.service.quartz; - -import com.lunhan.xxx.common.ExecutedResult; -import com.lunhan.xxx.common.util.ExceptionUtil; -import com.lunhan.xxx.common.util.SerializeUtil; -import com.lunhan.xxx.entity.enums.EHandleStatus; -import com.lunhan.xxx.entity.enums.EState; -import com.lunhan.xxx.repository.po.QuartzTaskInfoPO; -import com.lunhan.xxx.repository.po.QuartzTaskRecordPO; -import org.quartz.DisallowConcurrentExecution; -import org.quartz.Job; -import org.quartz.JobDataMap; -import org.quartz.JobExecutionContext; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; - -import java.util.Objects; - -@DisallowConcurrentExecution -public class QuartzMainJobFactory implements Job { - private static Logger logger = LoggerFactory.getLogger(QuartzMainJobFactory.class); - - @Autowired - private QuartzExecutor executor; - @Autowired - private QuartzService quartzService; - - @Override - public void execute(JobExecutionContext jobExecutionContext) { - JobDataMap jobDataMap = jobExecutionContext.getMergedJobDataMap(); - String id = jobDataMap.getString("id"); - String taskNo = jobDataMap.getString("taskNo"); - String executorName = jobDataMap.getString("executor"); - String sendType = jobDataMap.getString("sendType"); - String url = jobDataMap.getString("url"); - String executeParameter = jobDataMap.getString("executeParameter"); - logger.info("定时任务被执行:taskNo={},executor={},sendType={},url={},executeParameter={}", taskNo, executor, sendType, url, executeParameter); - //QuartzService quartzService = SpringUtil.getBean(QuartzService.class); - QuartzTaskRecordPO records = null; - ExecutedResult<String> result = ExecutedResult.failed("未知错误"); - try { - ExecutedResult<QuartzTaskInfoPO> checkTask4Code = quartzService.checkTask4Code(taskNo); - if (checkTask4Code.isFailed()) { - logger.info("taskNo={}执行任务失败.找不到任务信息", taskNo); - return; - } - QuartzTaskInfoPO task = checkTask4Code.getData(); - //保存定时任务的执行记录 - records = quartzService.addTaskRecords(task, executeParameter); - if (null == records || !Objects.equals(EHandleStatus.AWAITING.getValue(), records.getTaskStatus())) { - logger.info("taskNo={}执行定时任务失败: 保存执行记录失败", taskNo); - return; - } - if (!Objects.equals(task.getStatus(), EState.NORMAL.getValue())) { - logger.info("taskNo={}执行定时任务失败: 任务状态异常{}", taskNo, task.getStatus()); - result = ExecutedResult.failed("定时任务状态异常." + task.getStatus()); - return; - } - - result = executor.execute(executorName, executeParameter); - logger.info("{}-{}执行结果: {}", taskNo, task.getTaskName(), SerializeUtil.toJson(result)); - - // 发送执行任务的消息 -// if (ResultEnum.HTTP.getMessage().equals(sendType)) { -// try { -// String result = HttpClientUtil.doPost(url, "text/json", executeParameter); -// logger.info("taskNo={},sendType={}执行结果result{}", taskNo, sendType, result); -// if (StringUtils.isEmpty(result)) { -// throw new RuntimeException("taskNo=" + taskNo + "http方式返回null"); -// } -// } catch (Exception ex) { -// logger.error(""); -// throw ex; -// } -// } else if (ResultEnum.KAFKA.getMessage().equals(sendType)) { -// try { -// String message = new StringBuffer(taskNo).append(":").append(id).append(":").append(executeParameter).toString(); -// quartzService.sendMessage(message); -// logger.info("taskNo={},sendType={}推送至kafka成功", taskNo, sendType); -// } catch (Exception ex) { -// logger.error(""); -// throw ex; -// } -// } - } catch (Exception ex) { - logger.error("任务调度QuartzMainJobFactory.execute", ex); - if (Objects.nonNull(records)) { - quartzService.addTaskErrorRecord(records.getId(), taskNo + ":" + ex.getMessage(), ExceptionUtil.getDetails(ex)); - } - result = ExecutedResult.failed(ExceptionUtil.getDetails(ex)); - } finally { - if (Objects.nonNull(records)) { - // 更改record表的执行状态 - quartzService.doneRecordById(records.getId(), result); - } - } - } -} diff --git a/src/main/java/com/lunhan/xxx/service/quartz/QuartzService.java b/src/main/java/com/lunhan/xxx/service/quartz/QuartzService.java deleted file mode 100644 index b54a434..0000000 --- a/src/main/java/com/lunhan/xxx/service/quartz/QuartzService.java +++ /dev/null @@ -1,420 +0,0 @@ -package com.lunhan.xxx.service.quartz; - -import com.lunhan.xxx.common.ExecutedResult; -import com.lunhan.xxx.common.PagerResult; -import com.lunhan.xxx.common.enums.EYesOrNo; -import com.lunhan.xxx.common.model.Tuple; -import com.lunhan.xxx.common.util.*; -import com.lunhan.xxx.entity.enums.EHandleStatus; -import com.lunhan.xxx.entity.enums.EState; -import com.lunhan.xxx.entity.request.quartztaskinfo.ReqCreateQuartzTaskInfo; -import com.lunhan.xxx.entity.request.quartztaskinfo.ReqModifyQuartzTaskInfo; -import com.lunhan.xxx.entity.request.quartztaskinfo.ReqRunTaskRightNow; -import com.lunhan.xxx.entity.search.SearchQuartzTaskInfo; -import com.lunhan.xxx.entity.search.SearchQuartzTaskRecord; -import com.lunhan.xxx.repository.impl.QuartzTaskErrorMapperImpl; -import com.lunhan.xxx.repository.impl.QuartzTaskInfoMapperImpl; -import com.lunhan.xxx.repository.impl.QuartzTaskRecordMapperImpl; -import com.lunhan.xxx.repository.po.QuartzTaskErrorPO; -import com.lunhan.xxx.repository.po.QuartzTaskInfoPO; -import com.lunhan.xxx.repository.po.QuartzTaskRecordPO; -import com.lunhan.xxx.repository.vo.QuartzTaskErrorVO; -import com.lunhan.xxx.repository.vo.QuartzTaskInfoVO; -import com.lunhan.xxx.repository.vo.QuartzTaskRecordVO; -import com.lunhan.xxx.service.convert.QuartzTaskInfoConvert; -import org.quartz.*; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.InitializingBean; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.scheduling.quartz.SchedulerFactoryBean; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; - -@Service -public class QuartzService implements InitializingBean { - private static final Logger logger = LoggerFactory.getLogger(QuartzService.class); - - @Value("${quartz.enable}") - private Boolean isQuartzEnable; - - @Autowired - private QuartzTaskInfoMapperImpl taskDao; - @Autowired - private QuartzTaskRecordMapperImpl taskRecordsDao; - @Autowired - private QuartzTaskErrorMapperImpl taskErrorsDao; - - @Autowired - private SchedulerFactoryBean schedulerBean; - @Autowired - private QuartzExecutor executor; - - public ExecutedResult<PagerResult<QuartzTaskInfoVO>> listTask(SearchQuartzTaskInfo search) { - // 预处理 mybatis plus 空指针 - search.setCreateTimeStart(0L); - search.setCreateTimeEnd(0L); - // 处理创建时间范围-查询参数 - Tuple<String, String> createTimeRange = ParameterUtil.getTimeRange(search.getCreateTimeRange()); - if (StringUtil.isNotNullOrEmpty(createTimeRange.getItem1())) { - search.setCreateTimeStart(LocalDateTimeUtil.getTimeStamp(createTimeRange.getItem1()).getTime()); - } - if (StringUtil.isNotNullOrEmpty(createTimeRange.getItem2())) { - search.setCreateTimeEnd(LocalDateTimeUtil.getTimeStamp(createTimeRange.getItem2()).getTime()); - } - - PagerResult<QuartzTaskInfoPO> pageList = taskDao.search(search); - List<QuartzTaskInfoVO> listVo = new ArrayList<>(); - List<QuartzTaskInfoPO> list = pageList.getList(); - if (ListUtil.isNotNullOrEmpty(list)) { - // 转换vo - listVo = QuartzTaskInfoConvert.INSTANCE.toVo(list); - } - PagerResult<QuartzTaskInfoVO> result = new PagerResult<>(pageList.getLimit(), pageList.getPage(), pageList.getTotal(), listVo); - return ExecutedResult.success(result); - } - - public ExecutedResult<String> addTask(ReqCreateQuartzTaskInfo request) { - Long now = LocalDateTimeUtil.nowTimeStamp(); - // 转换po - QuartzTaskInfoPO item = QuartzTaskInfoConvert.INSTANCE.toCreate(request); - // 任务编号 - item.setTaskNo("T" + SnowFlakeUtil.getId()); - // 设置状态 - item.setStatus(EState.NORMAL.getValue()); - // 设置记录创建时间 - item.setCreateTime(now); - // 版本号 - item.setVersion(now); - item.setLastTime(""); - item.setLastStatus(0); - item.setLastParameter(""); - // 是否删除(逻辑删除)初始值 - item.setIsDelete(EYesOrNo.NO.getValue()); - - int result = this.taskDao.insert(item); - if (result != 1) { - return ExecutedResult.failed("创建任务失败。"); - } - Scheduler scheduler = schedulerBean.getScheduler(); - try { - this.schedule(item, scheduler); - } catch (SchedulerException e) { - logger.error("addTask", e); - } - return ExecutedResult.success(item.getTaskNo()); - } - - @Transactional - public ExecutedResult<String> updateTask(ReqModifyQuartzTaskInfo request) throws SchedulerException { - // 验证记录是否存在 - ExecutedResult<QuartzTaskInfoPO> checkExists = this.checkTask4Id(request.getId()); - if (checkExists.isFailed()) { - return ExecutedResult.failed(checkExists.getMsg()); - } - QuartzTaskInfoPO find = checkExists.getData(); - - // 转换po - QuartzTaskInfoPO item = CopierUtil.mapTo(request, QuartzTaskInfoPO.class); - - int result = taskDao.updateById(item); - if (result != 1) { - return ExecutedResult.failed("编辑任务失败。"); - } - Scheduler scheduler = schedulerBean.getScheduler(); - scheduler.deleteJob(new JobKey(find.getTaskNo())); - if (Objects.equals(item.getStatus(),EState.NORMAL.getValue())) { - this.schedule(find, scheduler); - } - return ExecutedResult.success(); - } - - public ExecutedResult<QuartzTaskInfoPO> checkTask4Id(Long id) { - QuartzTaskInfoPO exists = taskDao.selectById(id); - if (Objects.isNull(exists)) { - return ExecutedResult.failed("任务不存在:" + id); - } - return ExecutedResult.success(exists); - } - - public ExecutedResult<QuartzTaskInfoPO> checkTask4Code(String taskNo) { - QuartzTaskInfoPO exists = taskDao.get4No(taskNo); - if (Objects.isNull(exists)) { - return ExecutedResult.failed("任务不存在:" + taskNo); - } - return ExecutedResult.success(exists); - } - - // 启动 或者 暂定定时任务 - @Transactional - public ExecutedResult<String> optionJob(Long taskId) throws SchedulerException { - // 验证记录是否存在 - ExecutedResult<QuartzTaskInfoPO> checkExists = this.checkTask4Id(taskId); - if (checkExists.isFailed()) { - return ExecutedResult.failed(checkExists.getMsg()); - } - Long now = LocalDateTimeUtil.nowTimeStamp(); - - QuartzTaskInfoPO task = checkExists.getData(); - Integer status = task.getStatus(); - String taskNo = task.getTaskNo(); - - Scheduler scheduler = schedulerBean.getScheduler(); - QuartzTaskInfoPO item = new QuartzTaskInfoPO(); - item.setId(task.getId()); - item.setVersion(task.getVersion()); - //说明要暂停 - if (Objects.equals(status, EState.NORMAL.getValue())) { - scheduler.deleteJob(new JobKey(taskNo)); - item.setFrozenTime(now); - item.setStatus(EState.DISABLED.getValue()); - } - //说明要启动 - else if (Objects.equals(status, EState.DISABLED.getValue())) { - scheduler.deleteJob(new JobKey(taskNo)); - this.schedule(task, scheduler); - item.setUnfrozenTime(now); - item.setStatus(EState.NORMAL.getValue()); - } - taskDao.updateById(item); - logger.info("taskNo={},taskName={},scheduleRule={},任务{}成功", task.getTaskNo(), task.getTaskName(), task.getSchedulerRule(), Objects.equals(status, EState.NORMAL.getValue()) ? "启动" : "暂停"); - return ExecutedResult.success(); - } - - /** - * 立即执行一次任务 - * @param request 请求参数 - */ - public ExecutedResult<String> runTaskRightNow(ReqRunTaskRightNow request) { - // 验证记录是否存在 - ExecutedResult<QuartzTaskInfoPO> checkExists = this.checkTask4Id(request.getId()); - if (checkExists.isFailed()) { - return ExecutedResult.failed(checkExists.getMsg()); - } - QuartzTaskInfoPO task = checkExists.getData(); - String taskNo = task.getTaskNo(); - - String sendType = task.getSendType(); - String executorName = task.getExecutor(); - String url = task.getUrl(); - String executeParameter = request.getExecuteParameter(); - logger.info("定时任务被执行:taskNo={},executor={},sendType={},url={},executeParameter={}", taskNo, executor, sendType, url, executeParameter); - QuartzTaskRecordPO records = null; - try { - //保存定时任务的执行记录 - records = this.addTaskRecords(task, executeParameter); - if (Objects.isNull(records) || !Objects.equals(EHandleStatus.AWAITING.getValue(), records.getTaskStatus())) { - logger.info("taskNo={}执行定时任务失败--->>保存执行记录失败", taskNo); - return ExecutedResult.failed("单次执行任务失败"); - } - Long recordId = records.getId(); - String taskName = task.getTaskName(); - ThreadPoolUtil.getDefaultPool().execute(() -> { - ExecutedResult<String> executeResult = SpringUtil.getBean(QuartzExecutor.class).execute(executorName, executeParameter); - logger.info("{}-{}执行结果: {}", taskNo, taskName, SerializeUtil.toJson(executeResult)); - // 更改record表的执行状态 - this.doneRecordById(recordId, executeResult); - }); - - - // 发送执行任务的消息 -// if (ResultEnum.HTTP.getMessage().equals(sendType)) { -// try { -// HttpClientUtil.doPost(url, "text/json", executeParameter); -// logger.info(""); -// } catch (Exception ex) { -// logger.error(""); -// atomicInteger.incrementAndGet(); -// throw ex; -// } -// } else if (ResultEnum.KAFKA.getMessage().equals(sendType)) { -// try { -// String message = new StringBuffer(taskNo).append(":").append(executeParameter).toString(); -// this.sendMessage(message); -// } catch (Exception ex) { -// logger.error(""); -// atomicInteger.incrementAndGet(); -// throw ex; -// } -// } - return ExecutedResult.success(); - } catch (Exception ex) { - logger.error("单次执行任务 runTaskRightNow", ex); - if (Objects.nonNull(records)) { - this.addTaskErrorRecord(records.getId(), taskNo + ":" + ex.getMessage(), ExceptionUtil.getDetails(ex)); - } - ExecutedResult<String> result = ExecutedResult.failed("单次执行任务失败." + ex.getMessage()); - if (Objects.nonNull(records)) { - // 更改record表的执行状态 - this.doneRecordById(records.getId(), result); - } - return result; - } - } - - // 定时任务执行记录 - public ExecutedResult<PagerResult<QuartzTaskRecordVO>> taskRecords(SearchQuartzTaskRecord search) { - // 预处理 mybatis plus 空指针 - search.setCreateTimeStart(0L); - search.setCreateTimeEnd(0L); - search.setExecuteTimeStart(0L); - search.setExecuteTimeEnd(0L); - // 处理创建时间范围-查询参数 - Tuple<String, String> createTimeRange = ParameterUtil.getTimeRange(search.getCreateTimeRange()); - if (StringUtil.isNotNullOrEmpty(createTimeRange.getItem1())) { - search.setCreateTimeStart(LocalDateTimeUtil.getTimeStamp(createTimeRange.getItem1()).getTime()); - } - if (StringUtil.isNotNullOrEmpty(createTimeRange.getItem2())) { - search.setCreateTimeEnd(LocalDateTimeUtil.getTimeStamp(createTimeRange.getItem2()).getTime()); - } - // 处理执行时间范围-查询参数 - Tuple<String, String> executeTimeRange = ParameterUtil.getTimeRange(search.getExecuteTimeRange()); - if (StringUtil.isNotNullOrEmpty(executeTimeRange.getItem1())) { - search.setExecuteTimeStart(LocalDateTimeUtil.getTimeStamp(executeTimeRange.getItem1()).getTime()); - } - if (StringUtil.isNotNullOrEmpty(executeTimeRange.getItem2())) { - search.setExecuteTimeEnd(LocalDateTimeUtil.getTimeStamp(executeTimeRange.getItem2()).getTime()); - } - - PagerResult<QuartzTaskRecordPO> pageList = taskRecordsDao.search(search); - List<QuartzTaskRecordVO> listVo = new ArrayList<>(); - List<QuartzTaskRecordPO> list = pageList.getList(); - if (ListUtil.isNotNullOrEmpty(list)) { - // 转换vo - listVo = CopierUtil.mapTo(list, QuartzTaskRecordVO.class); - } - PagerResult<QuartzTaskRecordVO> result = new PagerResult<>(pageList.getLimit(), pageList.getPage(), pageList.getTotal(), listVo); - return ExecutedResult.success(result); - } - - // 定时任务错误详情 - public ExecutedResult<QuartzTaskErrorVO> detailTaskErrors(String recordId) { - QuartzTaskErrorPO error = taskErrorsDao.get4RecordId(recordId); - if (Objects.isNull(error)) { - return ExecutedResult.success(null); - } - return ExecutedResult.success(CopierUtil.mapTo(error, QuartzTaskErrorVO.class)); - } - - /** - * Invoked by the containing {@code BeanFactory} after it has set all bean properties - * and satisfied {link BeanFactory Aware}, {@code ApplicationContextAware} etc. - * <p>This method allows the bean instance to perform validation of its overall - * configuration and final initialization when all bean properties have been set. - */ - @Override - public void afterPropertiesSet() { - if (!this.isQuartzEnable) { - return; - } - this.initLoadOnlineTasks(); - } - - /** - * 初始化加载定时任务 - * - * @throws Exception - */ - public void initLoadOnlineTasks() { - List<QuartzTaskInfoPO> list = taskDao.list4Status(EState.NORMAL.getValue()); - if (ListUtil.isNullOrEmpty(list)) { - logger.info("没有需要初始化加载的定时任务"); - return; - } - Scheduler scheduler = schedulerBean.getScheduler(); - for (QuartzTaskInfoPO task : list) { - try { - this.schedule(task, scheduler); - } catch (Exception e) { - logger.error("系统初始化加载定时任务:taskno={},taskname={}失败原因exception={}", task.getTaskNo(), task.getTaskName(), e); - } - } - } - - private void schedule(QuartzTaskInfoPO task, Scheduler scheduler) throws SchedulerException { - TriggerKey triggerKey = TriggerKey.triggerKey(task.getTaskNo(), Scheduler.DEFAULT_GROUP); - JobDetail jobDetail = JobBuilder.newJob(QuartzMainJobFactory.class).withDescription(task.getTaskName()).withIdentity(task.getTaskNo(), Scheduler.DEFAULT_GROUP).build(); - JobDataMap jobDataMap = jobDetail.getJobDataMap(); - jobDataMap.put("id", task.getId().toString()); - jobDataMap.put("taskNo", task.getTaskNo()); - jobDataMap.put("executor", task.getExecutor()); - jobDataMap.put("sendType", task.getSendType()); - jobDataMap.put("url", task.getUrl()); - jobDataMap.put("executeParameter", task.getExecuteParameter()); - CronScheduleBuilder cronScheduleBuilder = CronScheduleBuilder.cronSchedule(task.getSchedulerRule()); - CronTrigger cronTrigger = TriggerBuilder.newTrigger().withDescription(task.getTaskName()).withIdentity(triggerKey).withSchedule(cronScheduleBuilder).build(); - scheduler.scheduleJob(jobDetail, cronTrigger); - logger.info("taskNo={},taskName={},scheduleRule={} load to quartz success!", task.getTaskNo(), task.getTaskName(), task.getSchedulerRule()); - } - - public QuartzTaskRecordPO addTaskRecords(QuartzTaskInfoPO task, String executeParameter) { - Long now = LocalDateTimeUtil.nowTimeStamp(); - QuartzTaskRecordPO quartzTaskRecords = null; - try { - quartzTaskRecords = new QuartzTaskRecordPO(); - quartzTaskRecords.setTaskNo(task.getTaskNo()); - quartzTaskRecords.setTaskName(task.getTaskName()); - quartzTaskRecords.setExecuteParameter(executeParameter); - quartzTaskRecords.setStartTime(now); - quartzTaskRecords.setEndTime(0L); - quartzTaskRecords.setExecuteTimes(0L); - quartzTaskRecords.setTaskStatus(EHandleStatus.AWAITING.getValue()); - quartzTaskRecords.setFailReason(""); - quartzTaskRecords.setIsDelete(EYesOrNo.NO.getValue()); - quartzTaskRecords.setCreateTime(now); - taskRecordsDao.insert(quartzTaskRecords); - logger.info("taskNo={},taskName={}添加执行记录表成功", task.getTaskNo(), task.getTaskName()); - return quartzTaskRecords; - } catch (Exception ex) { - logger.error("添加执行记录异常 addTaskRecords", ex); - return null; - } - } - - public Integer addTaskErrorRecord(Long id, String errorKey, String errorValue) { - QuartzTaskErrorPO taskErrors = new QuartzTaskErrorPO(); - taskErrors.setTaskExecuteRecordId(String.valueOf(id)); - taskErrors.setErrorKey(errorKey); - taskErrors.setErrorValue(errorValue); - taskErrors.setIsDelete(EYesOrNo.NO.getValue()); - taskErrors.setCreateTime(LocalDateTimeUtil.nowTimeStamp()); - return taskErrorsDao.insert(taskErrors); - } - - /** - * 完成执行记录 - * @param id 执行记录id - * @param result 执行结果 - */ - public Integer doneRecordById(Long id, ExecutedResult<String> result) { - QuartzTaskRecordPO find = taskRecordsDao.selectById(id); - - QuartzTaskRecordPO records = new QuartzTaskRecordPO(); - records.setId(id); - records.setEndTime(LocalDateTimeUtil.nowTimeStamp()); - records.setExecuteTimes(records.getEndTime() - find.getStartTime()); - records.setFailReason("SUCCESS"); - if (result.isSuccess()) { - records.setTaskStatus(EHandleStatus.SUCCESS.getValue()); - } else { - records.setTaskStatus(EHandleStatus.FAILED.getValue()); - records.setFailReason(result.getMsg()); - } - - QuartzTaskInfoPO task = taskDao.get4No(find.getTaskNo()); - // 更新任务的上次执行结果 - QuartzTaskInfoPO item = new QuartzTaskInfoPO(); - item.setId(task.getId()); - item.setLastTime(LocalDateTimeUtil.nowDateTimeFullStr()); - item.setLastStatus(records.getTaskStatus()); - item.setLastParameter(find.getExecuteParameter()); - taskDao.updateById(item); - - return taskRecordsDao.updateById(records); - } -} diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index f8718f9..5be01ea 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -34,7 +34,7 @@ path: ./logs level: root: info - com.lunhan.xxx: info + com.fengdu.gas: info # mybatis-plus 配置: mybatis-plus: diff --git a/src/main/resources/application-prod.yml b/src/main/resources/application-prod.yml index d1c1444..7ddc250 100644 --- a/src/main/resources/application-prod.yml +++ b/src/main/resources/application-prod.yml @@ -34,7 +34,7 @@ path: ./logs level: root: info - com.lunhan.xxx.host: debug + com.fengdu.gas.host: debug # quartz定时任务配置 quartz: diff --git a/src/main/resources/application-test.yml b/src/main/resources/application-test.yml index 9edb608..a1d2c9f 100644 --- a/src/main/resources/application-test.yml +++ b/src/main/resources/application-test.yml @@ -34,8 +34,8 @@ path: ./logs level: root: info - com.lunhan.xxx.host: DEBUG - com.lunhan.xxx.service: DEBUG + com.fengdu.gas.host: DEBUG + com.fengdu.gas.service: DEBUG # quartz定时任务配置 quartz: diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index c902c4c..ed96ee1 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -1,6 +1,6 @@ spring: application: - name: xxx-yyy + name: fengdu_gases profiles: # 通过mvn打包传递参数,指定配置文件环境 active: @package.environment@ @@ -21,7 +21,7 @@ jwt: token_header: Token #JWT存储的请求头 - secret: xxx-yyy-secret #hardware-lunhan-secret #JWT加解密密钥(所有硬件项目通用,公用一个用户中心登录,其他项目不写登录接口,直接用token) + secret: fengdu_gases-secret #hardware-lunhan-secret #JWT加解密密钥(所有硬件项目通用,公用一个用户中心登录,其他项目不写登录接口,直接用token) expiration: 15811200 #JWT的超期限时间(60*60*24*183) 单位:秒 head: 'Bearer ' #JWT负载中拿到开头 diff --git a/src/main/resources/smart-doc.json b/src/main/resources/smart-doc.json index 6101148..1eacaf0 100644 --- a/src/main/resources/smart-doc.json +++ b/src/main/resources/smart-doc.json @@ -5,7 +5,7 @@ "allInOneDocFileName":"index.html",//自定义设置输出文档名称, @since 1.9.0 "style": "vs2015", "createDebugPage": true, //@since 2.0.0 smart-doc支持创建可以测试的html页面,仅在AllInOne模式中起作用。 - "packageFilters": "com.lunhan.xxx.host.controller.*,com.lunhan.xxx.host.admin.*,com.lunhan.xxx.host.controller.pay.*",//controller包过滤,多个包用英文逗号隔开,2.2.2开始需要采用正则:com.test.controller.* + "packageFilters": "com.fengdu.gas.host.controller.*,com.fengdu.gas.host.admin.*,com.fengdu.gas.host.controller.pay.*",//controller包过滤,多个包用英文逗号隔开,2.2.2开始需要采用正则:com.test.controller.* "requestExample":"true",//是否将请求示例展示在文档中,默认true,@since 1.9.0 "responseExample":"true",//是否将响应示例展示在文档中,默认为true,@since 1.9.0 // "requestHeaders": [{ //设置请求头,没有需求可以不设置 @@ -20,27 +20,27 @@ // }], "dataDictionaries": [{ "title": "EResultCode - 请求响应状态码", - "enumClassName": "com.lunhan.xxx.common.enums.EResultCode", + "enumClassName": "com.fengdu.gas.common.enums.EResultCode", "codeField": "code", "descField": "message" },{ "title": "ESex - 性别", - "enumClassName": "com.lunhan.xxx.entity.enums.ESex", + "enumClassName": "com.fengdu.gas.entity.enums.ESex", "codeField": "value", "descField": "desc" }, { "title": "EState - 状态", - "enumClassName": "com.lunhan.xxx.entity.enums.EState", + "enumClassName": "com.fengdu.gas.entity.enums.EState", "codeField": "value", "descField": "desc" }, { "title": "EParameterType - 参数类型", - "enumClassName": "com.lunhan.xxx.entity.enums.EParameterType", + "enumClassName": "com.fengdu.gas.entity.enums.EParameterType", "codeField": "value", "descField": "desc" }, { "title": "EUserType - 用户类型", - "enumClassName": "com.lunhan.xxx.entity.enums.EUserType", + "enumClassName": "com.fengdu.gas.entity.enums.EUserType", "codeField": "value", "descField": "desc" }, @@ -50,12 +50,12 @@ // 排序的枚举,为了便于阅读请放在字典列表的最后。业务枚举放在前面 { "title": "EOrderBy - 通用查询-排序支持的字段枚举", - "enumClassName": "com.lunhan.xxx.entity.enums.EOrderBy", + "enumClassName": "com.fengdu.gas.entity.enums.EOrderBy", "codeField": "value", "descField": "desc" }, { "title": "ESortOrderBy - 排序类型带排序值字段", - "enumClassName": "com.lunhan.xxx.entity.enums.ESortOrderBy", + "enumClassName": "com.fengdu.gas.entity.enums.ESortOrderBy", "codeField": "value", "descField": "desc" } diff --git a/src/test/java/com/lunhan/xxx/BasicServiceApplicationTests.java b/src/test/java/com/lunhan/xxx/BasicServiceApplicationTests.java index 2227823..28cf6c6 100644 --- a/src/test/java/com/lunhan/xxx/BasicServiceApplicationTests.java +++ b/src/test/java/com/lunhan/xxx/BasicServiceApplicationTests.java @@ -1,8 +1,8 @@ -package com.lunhan.xxx; +package com.fengdu.gas; import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder; -import com.lunhan.xxx.po.UserPO; -import com.lunhan.xxx.repository.mapper.UserMapper; +import com.fengdu.gas.po.UserPO; +import com.fengdu.gas.repository.mapper.UserMapper; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; diff --git a/src/test/java/com/lunhan/xxx/DateTimeTest.java b/src/test/java/com/lunhan/xxx/DateTimeTest.java index aa33759..89f12de 100644 --- a/src/test/java/com/lunhan/xxx/DateTimeTest.java +++ b/src/test/java/com/lunhan/xxx/DateTimeTest.java @@ -1,6 +1,6 @@ -package com.lunhan.xxx; +package com.fengdu.gas; -import com.lunhan.xxx.common.util.LocalDateTimeUtil; +import com.fengdu.gas.common.util.LocalDateTimeUtil; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; diff --git a/src/test/java/com/lunhan/xxx/DemoTest.java b/src/test/java/com/lunhan/xxx/DemoTest.java index 7e5aa87..040719d 100644 --- a/src/test/java/com/lunhan/xxx/DemoTest.java +++ b/src/test/java/com/lunhan/xxx/DemoTest.java @@ -1,4 +1,4 @@ -package com.lunhan.xxx; +package com.fengdu.gas; import org.junit.runner.RunWith; import org.springframework.test.context.ContextConfiguration; diff --git a/src/test/java/com/lunhan/xxx/Gauss2Gauss.java b/src/test/java/com/lunhan/xxx/Gauss2Gauss.java index aa413d7..7edb726 100644 --- a/src/test/java/com/lunhan/xxx/Gauss2Gauss.java +++ b/src/test/java/com/lunhan/xxx/Gauss2Gauss.java @@ -1,7 +1,7 @@ -package com.lunhan.xxx; +package com.fengdu.gas; -import com.lunhan.xxx.common.util.ListUtil; -import com.lunhan.xxx.common.util.StringUtil; +import com.fengdu.gas.common.util.ListUtil; +import com.fengdu.gas.common.util.StringUtil; import java.sql.Connection; import java.sql.DriverManager; diff --git a/src/test/java/com/lunhan/xxx/GaussExportTest.java b/src/test/java/com/lunhan/xxx/GaussExportTest.java index de3e7d0..0f77010 100644 --- a/src/test/java/com/lunhan/xxx/GaussExportTest.java +++ b/src/test/java/com/lunhan/xxx/GaussExportTest.java @@ -1,6 +1,6 @@ -package com.lunhan.xxx; +package com.fengdu.gas; -import com.lunhan.xxx.common.util.StringUtil; +import com.fengdu.gas.common.util.StringUtil; import java.sql.Connection; import java.sql.DriverManager; diff --git a/src/test/java/com/lunhan/xxx/GenCodeGauss.java b/src/test/java/com/lunhan/xxx/GenCodeGauss.java index 399276a..618dfaf 100644 --- a/src/test/java/com/lunhan/xxx/GenCodeGauss.java +++ b/src/test/java/com/lunhan/xxx/GenCodeGauss.java @@ -1,7 +1,7 @@ -package com.lunhan.xxx; +package com.fengdu.gas; -import com.lunhan.xxx.common.ConstantFactory; -import com.lunhan.xxx.common.util.*; +import com.fengdu.gas.common.ConstantFactory; +import com.fengdu.gas.common.util.*; import org.apache.commons.lang3.BooleanUtils; import java.io.File; @@ -44,16 +44,16 @@ //region 架包路径设置 class PackageSet { - public static final String PO = "com.lunhan.xxx.repository.po"; - public static final String VO = "com.lunhan.xxx.repository.vo"; - public static final String CONVERT_MAPPER = "com.lunhan.xxx.service.convert"; - public static final String MAPPER_IMPL = "com.lunhan.xxx.repository.impl"; - public static final String MAPPER = "com.lunhan.xxx.repository.mapper"; - public static final String SERVICE = "com.lunhan.xxx.service"; - public static final String Controller = "com.lunhan.xxx.host.controller"; - public static final String SEARCH = "com.lunhan.xxx.entity.search"; - public static final String Request = "com.lunhan.xxx.entity.request"; - public static final String Response = "com.lunhan.xxx.entity.response"; + public static final String PO = "com.fengdu.gas.repository.po"; + public static final String VO = "com.fengdu.gas.repository.vo"; + public static final String CONVERT_MAPPER = "com.fengdu.gas.service.convert"; + public static final String MAPPER_IMPL = "com.fengdu.gas.repository.impl"; + public static final String MAPPER = "com.fengdu.gas.repository.mapper"; + public static final String SERVICE = "com.fengdu.gas.service"; + public static final String Controller = "com.fengdu.gas.host.controller"; + public static final String SEARCH = "com.fengdu.gas.entity.search"; + public static final String Request = "com.fengdu.gas.entity.request"; + public static final String Response = "com.fengdu.gas.entity.response"; } //endregion @@ -119,8 +119,8 @@ //region vo类 import 内容设置 private static final String[] SET_VO_IMPORT = new String[]{ - "import com.lunhan.xxx.common.util.LocalDateTimeUtil;", - "import com.lunhan.xxx.common.util.NumericUtil;", + "import com.fengdu.gas.common.util.LocalDateTimeUtil;", + "import com.fengdu.gas.common.util.NumericUtil;", "import java.util.Objects;" }; //endregion @@ -138,12 +138,12 @@ private static final String[] SET_MAPPER_IMPL_IMPORT = new String[]{ "import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;", "import com.baomidou.mybatisplus.extension.plugins.pagination.Page;", - "import com.lunhan.xxx.common.PagerResult;", - "import com.lunhan.xxx.common.enums.EYesOrNo;", - "import com.lunhan.xxx.common.util.*;", - "import com.lunhan.xxx.entity.dto.*;", - "import com.lunhan.xxx.entity.enums.*;", - "import com.lunhan.xxx.repository.BasicMapperImpl;", + "import com.fengdu.gas.common.PagerResult;", + "import com.fengdu.gas.common.enums.EYesOrNo;", + "import com.fengdu.gas.common.util.*;", + "import com.fengdu.gas.entity.dto.*;", + "import com.fengdu.gas.entity.enums.*;", + "import com.fengdu.gas.repository.BasicMapperImpl;", "import org.springframework.stereotype.Repository;", "", "import java.util.List;" @@ -152,10 +152,10 @@ //region service类 import 内容设置 private static final String[] SET_Service_IMPORT = new String[]{ - "import com.lunhan.xxx.common.*;", - "import com.lunhan.xxx.common.enums.*;", - "import com.lunhan.xxx.common.model.Tuple;", - "import com.lunhan.xxx.common.util.*;", + "import com.fengdu.gas.common.*;", + "import com.fengdu.gas.common.enums.*;", + "import com.fengdu.gas.common.model.Tuple;", + "import com.fengdu.gas.common.util.*;", "import org.apache.commons.lang3.BooleanUtils;", "import org.springframework.beans.factory.annotation.Autowired;", "import org.springframework.stereotype.Service;", @@ -166,13 +166,13 @@ //region Controller类 import 内容设置 private static final String[] SET_Controller_IMPORT = new String[]{ - "import com.lunhan.xxx.common.ExecutedResult;", - "import com.lunhan.xxx.common.PagerResult;", - "import com.lunhan.xxx.common.util.ParameterUtil;", - "import com.lunhan.xxx.common.validator.ParameterValidateResult;", - "import com.lunhan.xxx.common.validator.ParameterValidator;", - "import com.lunhan.xxx.entity.request.ReqListId;", - "import com.lunhan.xxx.host.BasicController;", + "import com.fengdu.gas.common.ExecutedResult;", + "import com.fengdu.gas.common.PagerResult;", + "import com.fengdu.gas.common.util.ParameterUtil;", + "import com.fengdu.gas.common.validator.ParameterValidateResult;", + "import com.fengdu.gas.common.validator.ParameterValidator;", + "import com.fengdu.gas.entity.request.ReqListId;", + "import com.fengdu.gas.host.BasicController;", "import org.springframework.beans.factory.annotation.Autowired;", "import org.springframework.web.bind.annotation.*;", "import java.util.List;" diff --git a/src/test/java/com/lunhan/xxx/GenCodeMysql.java b/src/test/java/com/lunhan/xxx/GenCodeMysql.java index a1db204..f14ad9a 100644 --- a/src/test/java/com/lunhan/xxx/GenCodeMysql.java +++ b/src/test/java/com/lunhan/xxx/GenCodeMysql.java @@ -1,7 +1,7 @@ -package com.lunhan.xxx; +package com.fengdu.gas; -import com.lunhan.xxx.common.ConstantFactory; -import com.lunhan.xxx.common.util.*; +import com.fengdu.gas.common.ConstantFactory; +import com.fengdu.gas.common.util.*; import org.apache.commons.lang3.BooleanUtils; import java.io.File; diff --git a/src/test/java/com/lunhan/xxx/JenkinsTest.java b/src/test/java/com/lunhan/xxx/JenkinsTest.java index 0461f64..7cba52c 100644 --- a/src/test/java/com/lunhan/xxx/JenkinsTest.java +++ b/src/test/java/com/lunhan/xxx/JenkinsTest.java @@ -1,4 +1,4 @@ -package com.lunhan.xxx; +package com.fengdu.gas; import com.cdancy.jenkins.rest.JenkinsClient; import com.cdancy.jenkins.rest.domain.job.Job; diff --git a/src/test/java/com/lunhan/xxx/MySqlExportTest.java b/src/test/java/com/lunhan/xxx/MySqlExportTest.java index 54626dc..3f866ce 100644 --- a/src/test/java/com/lunhan/xxx/MySqlExportTest.java +++ b/src/test/java/com/lunhan/xxx/MySqlExportTest.java @@ -1,6 +1,6 @@ -package com.lunhan.xxx; +package com.fengdu.gas; -import com.lunhan.xxx.common.util.StringUtil; +import com.fengdu.gas.common.util.StringUtil; import java.sql.Connection; import java.sql.DriverManager; diff --git a/src/test/java/com/lunhan/xxx/Mysql2Gauss.java b/src/test/java/com/lunhan/xxx/Mysql2Gauss.java index 1144c26..01947f0 100644 --- a/src/test/java/com/lunhan/xxx/Mysql2Gauss.java +++ b/src/test/java/com/lunhan/xxx/Mysql2Gauss.java @@ -1,6 +1,6 @@ -package com.lunhan.xxx; +package com.fengdu.gas; -import com.lunhan.xxx.common.util.ListUtil; +import com.fengdu.gas.common.util.ListUtil; import java.sql.Connection; import java.sql.DriverManager; diff --git a/src/test/java/com/lunhan/xxx/SpringConfig.java b/src/test/java/com/lunhan/xxx/SpringConfig.java index 4a4d865..e7c0bf9 100644 --- a/src/test/java/com/lunhan/xxx/SpringConfig.java +++ b/src/test/java/com/lunhan/xxx/SpringConfig.java @@ -1,4 +1,4 @@ -package com.lunhan.xxx; +package com.fengdu.gas; import org.springframework.context.annotation.ComponentScan; diff --git a/src/test/java/com/lunhan/xxx/StringUtilTest.java b/src/test/java/com/lunhan/xxx/StringUtilTest.java index b04dc64..3e42a28 100644 --- a/src/test/java/com/lunhan/xxx/StringUtilTest.java +++ b/src/test/java/com/lunhan/xxx/StringUtilTest.java @@ -1,7 +1,7 @@ -package com.lunhan.xxx; +package com.fengdu.gas; import com.baomidou.mybatisplus.core.toolkit.StringUtils; -import com.lunhan.xxx.repository.po.TestInfoPO; +import com.fengdu.gas.repository.po.TestInfoPO; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; diff --git a/src/test/java/com/lunhan/xxx/po/UserPO.java b/src/test/java/com/lunhan/xxx/po/UserPO.java index ee7b513..871d69b 100644 --- a/src/test/java/com/lunhan/xxx/po/UserPO.java +++ b/src/test/java/com/lunhan/xxx/po/UserPO.java @@ -1,4 +1,4 @@ -package com.lunhan.xxx.po; +package com.fengdu.gas.po; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableField; diff --git a/src/test/java/com/lunhan/xxx/repository/mapper/UserMapper.java b/src/test/java/com/lunhan/xxx/repository/mapper/UserMapper.java index 1fc59f0..08a23b4 100644 --- a/src/test/java/com/lunhan/xxx/repository/mapper/UserMapper.java +++ b/src/test/java/com/lunhan/xxx/repository/mapper/UserMapper.java @@ -1,7 +1,7 @@ -package com.lunhan.xxx.repository.mapper; +package com.fengdu.gas.repository.mapper; -import com.lunhan.xxx.po.UserPO; -import com.lunhan.xxx.repository.BasicMapper; +import com.fengdu.gas.po.UserPO; +import com.fengdu.gas.repository.BasicMapper; import org.apache.ibatis.annotations.Mapper; @Mapper diff --git a/src/test/java/com/lunhan/xxx/repository/test123.java b/src/test/java/com/lunhan/xxx/repository/test123.java index 92f53cd..86d408c 100644 --- a/src/test/java/com/lunhan/xxx/repository/test123.java +++ b/src/test/java/com/lunhan/xxx/repository/test123.java @@ -1,4 +1,4 @@ -package com.lunhan.xxx.repository; +package com.fengdu.gas.repository; public class test123 { } diff --git a/src/test/resources/application-dev.yml b/src/test/resources/application-dev.yml index 6105c1c..0bb36fa 100644 --- a/src/test/resources/application-dev.yml +++ b/src/test/resources/application-dev.yml @@ -46,7 +46,7 @@ path: ./logs level: root: info - com.lunhan.xxx: info + com.fengdu.gas: info # mybatis-plus 配置: mybatis-plus: diff --git a/src/test/resources/application.yml b/src/test/resources/application.yml index 16933ca..1002dda 100644 --- a/src/test/resources/application.yml +++ b/src/test/resources/application.yml @@ -1,6 +1,6 @@ spring: application: - name: xxx-yyy + name: fengdu_gases profiles: # 通过mvn打包传递参数,指定配置文件环境 active: dev -- Gitblit v1.9.3