From 9a689bf07b51f9ad9210d37131bd56a53797a8ad Mon Sep 17 00:00:00 2001 From: zy_Java <654600784@qq.com> Date: Tue, 11 Jan 2022 10:58:52 +0800 Subject: [PATCH] =?UTF-8?q?20220111=E6=96=B0=E5=BB=BA=E9=A1=B9=E7=9B=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 43 + cloudutil/pom.xml | 54 + .../ccsens/cloudutil/annotation/CacheMd5.java | 13 + .../ccsens/cloudutil/annotation/Login.java | 14 + .../cloudutil/annotation/MustLogin.java | 24 + .../cloudutil/aspect/CacheMd5Aspect.java | 96 ++ .../ccsens/cloudutil/aspect/LogAspect.java | 149 ++ .../cloudutil/aspect/MustLoginAspect.java | 150 ++ .../com/ccsens/cloudutil/bean/QueryParam.java | 14 + .../cloudutil/bean/tall/dto/HolidaysDto.java | 15 + .../cloudutil/bean/tall/dto/LogDto.java | 31 + .../bean/tall/dto/MemberRoleDto.java | 169 ++ .../cloudutil/bean/tall/dto/ProjectDto.java | 56 + .../cloudutil/bean/tall/dto/TallTaskDto.java | 137 ++ .../cloudutil/bean/tall/dto/TaskDto.java | 42 + .../cloudutil/bean/tall/dto/UserDto.java | 28 + .../cloudutil/bean/tall/dto/WpsDto.java | 62 + .../cloudutil/bean/tall/vo/HolidaysVo.java | 18 + .../cloudutil/bean/tall/vo/MemberVo.java | 57 + .../cloudutil/bean/tall/vo/PluginVo.java | 28 + .../cloudutil/bean/tall/vo/ProjectVo.java | 46 + .../ccsens/cloudutil/bean/tall/vo/TaskVo.java | 124 ++ .../ccsens/cloudutil/bean/tall/vo/UserVo.java | 20 + .../ccsens/cloudutil/bean/tall/vo/WpsVo.java | 15 + .../ccsens/cloudutil/config/FeignConfig.java | 55 + .../cloudutil/config/FeignTokenConfig.java | 45 + .../cloudutil/feign/HealthFeignClient.java | 41 + .../ccsens/cloudutil/feign/MtFeignClient.java | 68 + .../cloudutil/feign/Tall3FeignClient.java | 113 ++ .../cloudutil/feign/TallFeignClient.java | 477 ++++++ .../cloudutil/interceptor/LogInterceptor.java | 31 + .../cloudutil/ribbon/RibbonClientConfig.java | 15 + .../cloudutil/ribbon/RibbonConfiguration.java | 43 + .../cloudutil/ribbon/WpsBalanceRule.java | 28 + .../main/resources/application-util-dev.yml | 72 + .../main/resources/application-util-green.yml | 143 ++ .../application-util-greenvalley.yml | 66 + .../main/resources/application-util-pre.yml | 145 ++ .../main/resources/application-util-prod.yml | 145 ++ .../resources/application-util-prodsd.yml | 82 + .../main/resources/application-util-test.yml | 146 ++ dh_diplomatist/.gitignore | 33 + dh_diplomatist/mvnw | 322 ++++ dh_diplomatist/mvnw.cmd | 182 +++ dh_diplomatist/pom.xml | 90 ++ .../DhDiplomatistApplication.java | 33 + .../dh_diplomatist/api/DebugController.java | 32 + .../dh_diplomatist/api/DomainController.java | 58 + .../api/HeartbeatController.java | 38 + .../dh_diplomatist/api/UserController.java | 35 + .../dh_diplomatist/bean/dto/HeartbeatDto.java | 37 + .../dh_diplomatist/bean/dto/UserDto.java | 37 + .../dh_diplomatist/bean/po/IdcBusiness.java | 117 ++ .../bean/po/IdcBusinessExample.java | 771 +++++++++ .../dh_diplomatist/bean/po/IdcDomain.java | 227 +++ .../bean/po/IdcDomainBusiness.java | 128 ++ .../bean/po/IdcDomainBusinessExample.java | 831 ++++++++++ .../bean/po/IdcDomainExample.java | 1411 +++++++++++++++++ .../dh_diplomatist/bean/po/IdcUser.java | 95 ++ .../dh_diplomatist/bean/po/IdcUserDomain.java | 172 ++ .../bean/po/IdcUserDomainExample.java | 1091 +++++++++++++ .../bean/po/IdcUserExample.java | 641 ++++++++ .../dh_diplomatist/bean/vo/DomainVo.java | 46 + .../dh_diplomatist/config/BeanConfig.java | 22 + .../dh_diplomatist/config/SpringConfig.java | 128 ++ .../config/SwaggerConfigure.java | 56 + .../intercept/MybatisInterceptor.java | 159 ++ .../persist/dao/IdcDomainDao.java | 44 + .../persist/mapper/IdcBusinessMapper.java | 30 + .../mapper/IdcDomainBusinessMapper.java | 30 + .../persist/mapper/IdcDomainMapper.java | 30 + .../persist/mapper/IdcUserDomainMapper.java | 30 + .../persist/mapper/IdcUserMapper.java | 30 + .../dh_diplomatist/service/DomainService.java | 185 +++ .../service/HeartbeatService.java | 134 ++ .../service/IDomainService.java | 19 + .../service/IHeartbeatService.java | 16 + .../util/DiplomatistCodeError.java | 13 + .../util/DiplomatistConstant.java | 50 + .../src/main/resources/application-common.yml | 30 + .../src/main/resources/application-dev.yml | 51 + .../src/main/resources/application-prod.yml | 40 + .../src/main/resources/application-test.yml | 48 + .../src/main/resources/application.yml | 4 + .../src/main/resources/druid-dev.yml | 34 + .../src/main/resources/druid-prod.yml | 35 + .../src/main/resources/druid-test.yml | 34 + .../src/main/resources/logback-spring.xml | 196 +++ .../main/resources/mapper_dao/SPluginDao.xml | 47 + .../mapper_raw/IdcBusinessMapper.xml | 275 ++++ .../mapper_raw/IdcDomainBusinessMapper.xml | 291 ++++ .../resources/mapper_raw/IdcDomainMapper.xml | 432 +++++ .../mapper_raw/IdcUserDomainMapper.xml | 353 +++++ .../resources/mapper_raw/IdcUserMapper.xml | 243 +++ .../main/resources/mybatis/mybatis-config.xml | 62 + dh_ht/.gitignore | 33 + dh_ht/mvnw | 322 ++++ dh_ht/mvnw.cmd | 182 +++ dh_ht/pom.xml | 84 + .../com/ccsens/dh_ht/DhHtApplication.java | 31 + .../com/ccsens/dh_ht/api/DebugController.java | 32 + .../ccsens/dh_ht/api/ProjectController.java | 41 + .../com/ccsens/dh_ht/api/UserController.java | 18 + .../com/ccsens/dh_ht/bean/dto/ProjectDto.java | 22 + .../com/ccsens/dh_ht/bean/vo/ProjectVo.java | 86 + .../com/ccsens/dh_ht/config/BeanConfig.java | 22 + .../com/ccsens/dh_ht/config/SpringConfig.java | 128 ++ .../ccsens/dh_ht/config/SwaggerConfigure.java | 56 + .../dh_ht/intercept/MybatisInterceptor.java | 159 ++ .../ccsens/dh_ht/service/IProjectService.java | 19 + .../ccsens/dh_ht/service/ProjectService.java | 25 + .../com/ccsens/dh_ht/util/PtOsCodeError.java | 12 + .../com/ccsens/dh_ht/util/PtOsConstant.java | 50 + .../src/main/resources/application-common.yml | 30 + dh_ht/src/main/resources/application-dev.yml | 50 + dh_ht/src/main/resources/application-prod.yml | 40 + dh_ht/src/main/resources/application-test.yml | 48 + dh_ht/src/main/resources/application.yml | 4 + dh_ht/src/main/resources/druid-dev.yml | 34 + dh_ht/src/main/resources/druid-prod.yml | 35 + dh_ht/src/main/resources/druid-test.yml | 34 + dh_ht/src/main/resources/logback-spring.xml | 196 +++ .../main/resources/mybatis/mybatis-config.xml | 62 + dh_ptos/.gitignore | 33 + dh_ptos/mvnw | 322 ++++ dh_ptos/mvnw.cmd | 182 +++ dh_ptos/pom.xml | 84 + .../com/ccsens/dh_ptos/DhPtosApplication.java | 31 + .../ccsens/dh_ptos/api/DebugController.java | 32 + .../ccsens/dh_ptos/api/ProjectController.java | 41 + .../ccsens/dh_ptos/api/UserController.java | 18 + .../ccsens/dh_ptos/bean/dto/ProjectDto.java | 22 + .../com/ccsens/dh_ptos/bean/vo/ProjectVo.java | 86 + .../com/ccsens/dh_ptos/config/BeanConfig.java | 22 + .../ccsens/dh_ptos/config/SpringConfig.java | 128 ++ .../dh_ptos/config/SwaggerConfigure.java | 56 + .../dh_ptos/intercept/MybatisInterceptor.java | 159 ++ .../dh_ptos/service/IProjectService.java | 19 + .../dh_ptos/service/ProjectService.java | 25 + .../ccsens/dh_ptos/util/PtOsCodeError.java | 12 + .../com/ccsens/dh_ptos/util/PtOsConstant.java | 50 + .../src/main/resources/application-common.yml | 30 + .../src/main/resources/application-dev.yml | 50 + .../src/main/resources/application-prod.yml | 40 + .../src/main/resources/application-test.yml | 48 + dh_ptos/src/main/resources/application.yml | 4 + dh_ptos/src/main/resources/druid-dev.yml | 34 + dh_ptos/src/main/resources/druid-prod.yml | 35 + dh_ptos/src/main/resources/druid-test.yml | 34 + dh_ptos/src/main/resources/logback-spring.xml | 196 +++ .../main/resources/mybatis/mybatis-config.xml | 62 + origin) | 0 pom.xml | 260 +++ util/pom.xml | 57 + .../java/com/ccsens/util/Base64FileUtil.java | 46 + .../java/com/ccsens/util/BeanWrapperUtil.java | 50 + .../main/java/com/ccsens/util/CRCUtil.java | 52 + .../main/java/com/ccsens/util/CodeEnum.java | 318 ++++ .../main/java/com/ccsens/util/CodeError.java | 54 + .../main/java/com/ccsens/util/DateUtil.java | 180 +++ .../com/ccsens/util/DesensitizedUtils.java | 118 ++ .../java/com/ccsens/util/DistanceUtil.java | 48 + .../main/java/com/ccsens/util/ExcelUtil.java | 105 ++ .../java/com/ccsens/util/GenericsUtils.java | 287 ++++ .../java/com/ccsens/util/HttpServletUtil.java | 59 + .../main/java/com/ccsens/util/HttpsUtil.java | 327 ++++ .../ccsens/util/ImageCodeGeneratorUtil.java | 140 ++ .../main/java/com/ccsens/util/ImgUtil.java | 13 + .../java/com/ccsens/util/JacksonUtil.java | 312 ++++ .../java/com/ccsens/util/JsonResponse.java | 191 +++ .../java/com/ccsens/util/JsonResponse1.java | 298 ++++ .../java/com/ccsens/util/JsonResponse2.java | 151 ++ .../main/java/com/ccsens/util/JwtUtil.java | 125 ++ .../com/ccsens/util/KCPlayerSignature.java | 106 ++ .../main/java/com/ccsens/util/Md5Util.java | 105 ++ .../ccsens/util/MyJacksonObjectMapper.java | 15 + .../util/NotSupportedFileTypeException.java | 22 + .../ccsens/util/PasswordEncryptionUtil.java | 113 ++ .../main/java/com/ccsens/util/PdfUtil.java | 210 +++ .../main/java/com/ccsens/util/PoiUtil.java | 738 +++++++++ .../main/java/com/ccsens/util/PropUtil.java | 135 ++ .../main/java/com/ccsens/util/QrCodeUtil.java | 118 ++ .../java/com/ccsens/util/RedisKeyManager.java | 24 + .../main/java/com/ccsens/util/RedisUtil.java | 769 +++++++++ .../com/ccsens/util/RestTemplateUtil.java | 207 +++ .../main/java/com/ccsens/util/SQLUtil.java | 74 + .../main/java/com/ccsens/util/Sha1Util.java | 55 + .../main/java/com/ccsens/util/ShiroKit.java | 73 + .../main/java/com/ccsens/util/SmsUtil.java | 58 + .../com/ccsens/util/SpringContextUtils.java | 69 + .../main/java/com/ccsens/util/StringUtil.java | 264 +++ .../main/java/com/ccsens/util/ToolUtil.java | 41 + .../java/com/ccsens/util/TransactionUtil.java | 21 + .../ccsens/util/UploadFileUtil_Servlet3.java | 143 ++ .../java/com/ccsens/util/WebConstant.java | 1087 +++++++++++++ .../main/java/com/ccsens/util/WechatUtil.java | 431 +++++ .../java/com/ccsens/util/WordToJpgUtil.java | 104 ++ .../java/com/ccsens/util/WpsSignature.java | 85 + .../com/ccsens/util/ali/AliInstanceUtil.java | 27 + .../util/ali/Demolyocr_general_advanced.java | 168 ++ .../HttpApiClientlyocr_general_advanced.java | 34 + .../HttpsApiClientlyocr_general_advanced.java | 50 + .../ccsens/util/annotation/OperateType.java | 16 + .../java/com/ccsens/util/baidu/BaiDuDto.java | 20 + .../java/com/ccsens/util/baidu/BaiDuUtil.java | 124 ++ .../java/com/ccsens/util/baidu/BaiDuVo.java | 33 + .../com/ccsens/util/bean/dto/QueryDto.java | 29 + .../util/bean/message/client/AckMessage.java | 31 + .../util/bean/message/client/AuthMessage.java | 37 + .../client/ClientAuthTimeOutMessage.java | 17 + .../client/ClientIdleClosedMessage.java | 17 + .../bean/message/client/GetStatusMessage.java | 17 + .../bean/message/client/HasReadMessage.java | 37 + .../util/bean/message/client/PingMessage.java | 32 + .../client/SetDeletedStatusMessage.java | 32 + .../client/SetRevertedStatusMessage.java | 32 + .../client/SetSuccessStatusMessage.java | 32 + .../client/UnExceptedErrorMessage.java | 32 + .../util/bean/message/common/InMessage.java | 141 ++ .../util/bean/message/common/Message.java | 134 ++ .../bean/message/common/MessageConstant.java | 320 ++++ .../util/bean/message/common/MessageRule.java | 80 + .../util/bean/message/common/OutMessage.java | 71 + .../bean/message/common/OutMessageSet.java | 43 + .../bean/message/common/ServerMessage.java | 11 + .../message/server/ChannelStatusMessage.java | 37 + .../bean/message/server/InvertedMessage.java | 29 + .../util/bean/message/server/PongMessage.java | 15 + .../message/server/QueueStatusMessage.java | 31 + .../bean/message/server/ServerAckMessage.java | 50 + .../ccsens/util/bean/wx/dto/WxGzhAction.java | 151 ++ .../ccsens/util/bean/wx/po/WxAccessToken.java | 18 + .../ccsens/util/bean/wx/po/WxBaseEntity.java | 12 + .../ccsens/util/bean/wx/po/WxGzhAuthType.java | 23 + .../com/ccsens/util/bean/wx/po/WxGzhMenu.java | 97 ++ .../ccsens/util/bean/wx/po/WxGzhMsgEvent.java | 53 + .../ccsens/util/bean/wx/po/WxGzhMsgType.java | 34 + .../util/bean/wx/po/WxOauth2AccessToken.java | 26 + .../util/bean/wx/po/WxOauth2UserInfo.java | 42 + .../ccsens/util/bean/wx/po/WxOperation.java | 21 + .../com/ccsens/util/config/CommonConfig.java | 53 + .../config/ControllerExceptionHandler.java | 109 ++ .../com/ccsens/util/config/DruidProps.java | 383 +++++ .../util/config/H5WebSocketInterceptor.java | 34 + .../util/config/MyPropertySourceFactory.java | 24 + .../ccsens/util/config/RabbitMQConfig.java | 130 ++ .../com/ccsens/util/config/RedisConfig.java | 137 ++ .../com/ccsens/util/config/ServletConfig.java | 122 ++ .../ccsens/util/config/SwaggerConfigure.java | 56 + .../com/ccsens/util/cron/CronConstant.java | 484 ++++++ .../com/ccsens/util/cron/NatureConstant.java | 66 + .../com/ccsens/util/cron/NatureLanguage.java | 119 ++ .../com/ccsens/util/cron/NatureToDate.java | 456 ++++++ .../util/enterprisewx/AesException.java | 59 + .../ccsens/util/enterprisewx/ByteGroup.java | 26 + .../util/enterprisewx/PKCS7Encoder.java | 67 + .../com/ccsens/util/enterprisewx/SHA1.java | 66 + .../util/enterprisewx/WXBizMsgCrypt.java | 291 ++++ .../util/enterprisewx/WeiXinConstant.java | 175 ++ .../ccsens/util/enterprisewx/XMLParse.java | 106 ++ .../util/enterprisewx/dto/MessageDto.java | 50 + .../ccsens/util/enterprisewx/vo/WeiXinVo.java | 66 + .../ccsens/util/exception/BaseException.java | 39 + .../util/exception/BusinessException.java | 16 + .../ccsens/util/exception/WxException.java | 19 + .../ccsens/util/message/BaseMessageDto.java | 66 + .../util/message/RecoveryWithStartRecipe.java | 36 + .../util/message/SwitchoverProjectUtil.java | 55 + .../com/ccsens/util/mq/DelayConsumer.java | 33 + .../com/ccsens/util/mq/DelayProducer.java | 54 + .../util/mybatis/MybatisRedisCache.java | 95 ++ .../com/ccsens/util/notice/MailSendUtil.java | 139 ++ .../ccsens/util/notice/NoticePropUtil.java | 81 + .../com/ccsens/util/notice/SmsSendUtil.java | 62 + .../com/ccsens/util/notice/dto/MailDto.java | 73 + .../com/ccsens/util/notice/dto/SmsDto.java | 37 + .../util/redis/AbstractRedisService.java | 150 ++ .../java/com/ccsens/util/wx/WxGzhUtil.java | 395 +++++ .../java/com/ccsens/util/wx/WxRobotUtil.java | 121 ++ .../com/ccsens/util/wx/WxTemplateMessage.java | 70 + .../java/com/ccsens/util/wx/WxXcxUtil.java | 556 +++++++ .../test/java/com/ccsens/util/Base64Test.java | 185 +++ .../test/java/com/ccsens/util/DateTest.java | 202 +++ .../test/java/com/ccsens/util/FileTest.java | 40 + .../test/java/com/ccsens/util/KeyTest.java | 45 + .../test/java/com/ccsens/util/ListSort.java | 33 + .../test/java/com/ccsens/util/OtherTest.java | 493 ++++++ .../test/java/com/ccsens/util/PDFTest.java | 101 ++ .../java/com/ccsens/util/PdfUtilTest.java | 145 ++ util/src/test/java/com/ccsens/util/StuVO.java | 41 + .../test/java/com/ccsens/util/TallTest.java | 17 + .../test/java/com/ccsens/util/TestQrCord.java | 114 ++ .../com/ccsens/util/TestWpsSignature.java | 27 + .../test/java/com/ccsens/util/VideoTest.java | 121 ++ .../test/java/com/ccsens/util/ZipTest.java | 44 + wechatutil/.gitignore | 33 + wechatutil/mvnw | 322 ++++ wechatutil/mvnw.cmd | 182 +++ wechatutil/pom.xml | 76 + .../wechatutil/WechatutilApplication.java | 31 + .../wechatutil/api/DebugController.java | 68 + .../ccsens/wechatutil/api/WxController.java | 80 + .../wechatutil/bean/dto/WechatCode.java | 67 + .../wechatutil/bean/dto/WxMessageDto.java | 115 ++ .../bean/dto/WxTemplateMessage.java | 71 + .../wechatutil/bean/dto/wxmini/NoticeDto.java | 75 + .../wechatutil/bean/po/MiniProgramUser.java | 14 + .../wechatutil/bean/po/WxAccessToken.java | 18 + .../wechatutil/bean/po/WxBaseEntity.java | 12 + .../bean/po/WxOauth2AccessToken.java | 27 + .../wechatutil/bean/po/WxOauth2UserInfo.java | 34 + .../bean/po/WxPhoneDecryptInfo.java | 27 + .../bean/po/wxfiotexplorer/FiotSignin.java | 84 + .../po/wxfiotexplorer/FiotSigninResponse.java | 20 + .../bean/po/wxfiotexplorer/ResponseInfo.java | 32 + .../wechatutil/bean/vo/wxmini/Custom.java | 76 + .../ccsens/wechatutil/config/BeanConfig.java | 31 + .../wechatutil/config/SpringConfig.java | 171 ++ .../wechatutil/config/SwaggerConfigure.java | 56 + .../wechatutil/exception/PayException.java | 14 + .../intercept/MybatisInterceptor.java | 159 ++ .../ccsens/wechatutil/payutil/AesUtil.java | 67 + .../ccsens/wechatutil/payutil/HttpsUtil.java | 132 ++ .../wechatutil/payutil/JacksonUtil.java | 163 ++ .../wechatutil/payutil/WxMessageUtil.java | 155 ++ .../wechatutil/payutil/WxPayDirectUtils.java | 322 ++++ .../payutil/WxPayProviderUtils.java | 687 ++++++++ .../wechatutil/payutil/WxTokenUtil.java | 64 + .../com/ccsens/wechatutil/util/TC3Util.java | 178 +++ .../ccsens/wechatutil/util/WxCodeError.java | 15 + .../ccsens/wechatutil/util/WxConstant.java | 109 ++ .../wechatutil/wxcommon/WxCommonUtil.java | 68 + .../wxenterprise/EnterpriseRobotUtil.java | 83 + .../FiotExplorerSigninUtil.java | 85 + .../ccsens/wechatutil/wxh5/H5SigninUtil.java | 105 ++ .../wechatutil/wxmini/MiniCodeUtil.java | 159 ++ .../wechatutil/wxmini/MiniCustomSendUtil.java | 72 + .../MiniEncryptionAndDecryptionUtil.java | 100 ++ .../wechatutil/wxmini/MiniMessageUtil.java | 91 ++ .../wechatutil/wxmini/MiniSigninUtil.java | 81 + .../OfficialAccountMessageUtil.java | 122 ++ .../wxofficial/OfficialAccountSigninUtil.java | 105 ++ .../src/main/resources/application-common.yml | 28 + .../src/main/resources/application-dev.yml | 70 + .../src/main/resources/application-prod.yml | 50 + .../src/main/resources/application-test.yml | 50 + wechatutil/src/main/resources/application.yml | 5 + wechatutil/src/main/resources/business.yml | 9 + wechatutil/src/main/resources/druid-dev.yml | 34 + wechatutil/src/main/resources/druid-prod.yml | 34 + wechatutil/src/main/resources/druid-test.yml | 35 + .../src/main/resources/logback-spring.xml | 196 +++ .../main/resources/mybatis/mybatis-config.xml | 62 + .../WechatutilApplicationTests.java | 13 + 354 files changed, 39150 insertions(+) create mode 100644 .gitignore create mode 100644 cloudutil/pom.xml create mode 100644 cloudutil/src/main/java/com/ccsens/cloudutil/annotation/CacheMd5.java create mode 100644 cloudutil/src/main/java/com/ccsens/cloudutil/annotation/Login.java create mode 100644 cloudutil/src/main/java/com/ccsens/cloudutil/annotation/MustLogin.java create mode 100644 cloudutil/src/main/java/com/ccsens/cloudutil/aspect/CacheMd5Aspect.java create mode 100644 cloudutil/src/main/java/com/ccsens/cloudutil/aspect/LogAspect.java create mode 100644 cloudutil/src/main/java/com/ccsens/cloudutil/aspect/MustLoginAspect.java create mode 100644 cloudutil/src/main/java/com/ccsens/cloudutil/bean/QueryParam.java create mode 100644 cloudutil/src/main/java/com/ccsens/cloudutil/bean/tall/dto/HolidaysDto.java create mode 100644 cloudutil/src/main/java/com/ccsens/cloudutil/bean/tall/dto/LogDto.java create mode 100644 cloudutil/src/main/java/com/ccsens/cloudutil/bean/tall/dto/MemberRoleDto.java create mode 100644 cloudutil/src/main/java/com/ccsens/cloudutil/bean/tall/dto/ProjectDto.java create mode 100644 cloudutil/src/main/java/com/ccsens/cloudutil/bean/tall/dto/TallTaskDto.java create mode 100644 cloudutil/src/main/java/com/ccsens/cloudutil/bean/tall/dto/TaskDto.java create mode 100644 cloudutil/src/main/java/com/ccsens/cloudutil/bean/tall/dto/UserDto.java create mode 100644 cloudutil/src/main/java/com/ccsens/cloudutil/bean/tall/dto/WpsDto.java create mode 100644 cloudutil/src/main/java/com/ccsens/cloudutil/bean/tall/vo/HolidaysVo.java create mode 100644 cloudutil/src/main/java/com/ccsens/cloudutil/bean/tall/vo/MemberVo.java create mode 100644 cloudutil/src/main/java/com/ccsens/cloudutil/bean/tall/vo/PluginVo.java create mode 100644 cloudutil/src/main/java/com/ccsens/cloudutil/bean/tall/vo/ProjectVo.java create mode 100644 cloudutil/src/main/java/com/ccsens/cloudutil/bean/tall/vo/TaskVo.java create mode 100644 cloudutil/src/main/java/com/ccsens/cloudutil/bean/tall/vo/UserVo.java create mode 100644 cloudutil/src/main/java/com/ccsens/cloudutil/bean/tall/vo/WpsVo.java create mode 100644 cloudutil/src/main/java/com/ccsens/cloudutil/config/FeignConfig.java create mode 100644 cloudutil/src/main/java/com/ccsens/cloudutil/config/FeignTokenConfig.java create mode 100644 cloudutil/src/main/java/com/ccsens/cloudutil/feign/HealthFeignClient.java create mode 100644 cloudutil/src/main/java/com/ccsens/cloudutil/feign/MtFeignClient.java create mode 100644 cloudutil/src/main/java/com/ccsens/cloudutil/feign/Tall3FeignClient.java create mode 100644 cloudutil/src/main/java/com/ccsens/cloudutil/feign/TallFeignClient.java create mode 100644 cloudutil/src/main/java/com/ccsens/cloudutil/interceptor/LogInterceptor.java create mode 100644 cloudutil/src/main/java/com/ccsens/cloudutil/ribbon/RibbonClientConfig.java create mode 100644 cloudutil/src/main/java/com/ccsens/cloudutil/ribbon/RibbonConfiguration.java create mode 100644 cloudutil/src/main/java/com/ccsens/cloudutil/ribbon/WpsBalanceRule.java create mode 100644 cloudutil/src/main/resources/application-util-dev.yml create mode 100644 cloudutil/src/main/resources/application-util-green.yml create mode 100644 cloudutil/src/main/resources/application-util-greenvalley.yml create mode 100644 cloudutil/src/main/resources/application-util-pre.yml create mode 100644 cloudutil/src/main/resources/application-util-prod.yml create mode 100644 cloudutil/src/main/resources/application-util-prodsd.yml create mode 100644 cloudutil/src/main/resources/application-util-test.yml create mode 100644 dh_diplomatist/.gitignore create mode 100644 dh_diplomatist/mvnw create mode 100644 dh_diplomatist/mvnw.cmd create mode 100644 dh_diplomatist/pom.xml create mode 100644 dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/DhDiplomatistApplication.java create mode 100644 dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/api/DebugController.java create mode 100644 dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/api/DomainController.java create mode 100644 dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/api/HeartbeatController.java create mode 100644 dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/api/UserController.java create mode 100644 dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/bean/dto/HeartbeatDto.java create mode 100644 dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/bean/dto/UserDto.java create mode 100644 dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/bean/po/IdcBusiness.java create mode 100644 dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/bean/po/IdcBusinessExample.java create mode 100644 dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/bean/po/IdcDomain.java create mode 100644 dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/bean/po/IdcDomainBusiness.java create mode 100644 dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/bean/po/IdcDomainBusinessExample.java create mode 100644 dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/bean/po/IdcDomainExample.java create mode 100644 dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/bean/po/IdcUser.java create mode 100644 dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/bean/po/IdcUserDomain.java create mode 100644 dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/bean/po/IdcUserDomainExample.java create mode 100644 dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/bean/po/IdcUserExample.java create mode 100644 dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/bean/vo/DomainVo.java create mode 100644 dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/config/BeanConfig.java create mode 100644 dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/config/SpringConfig.java create mode 100644 dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/config/SwaggerConfigure.java create mode 100644 dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/intercept/MybatisInterceptor.java create mode 100644 dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/persist/dao/IdcDomainDao.java create mode 100644 dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/persist/mapper/IdcBusinessMapper.java create mode 100644 dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/persist/mapper/IdcDomainBusinessMapper.java create mode 100644 dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/persist/mapper/IdcDomainMapper.java create mode 100644 dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/persist/mapper/IdcUserDomainMapper.java create mode 100644 dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/persist/mapper/IdcUserMapper.java create mode 100644 dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/service/DomainService.java create mode 100644 dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/service/HeartbeatService.java create mode 100644 dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/service/IDomainService.java create mode 100644 dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/service/IHeartbeatService.java create mode 100644 dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/util/DiplomatistCodeError.java create mode 100644 dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/util/DiplomatistConstant.java create mode 100644 dh_diplomatist/src/main/resources/application-common.yml create mode 100644 dh_diplomatist/src/main/resources/application-dev.yml create mode 100644 dh_diplomatist/src/main/resources/application-prod.yml create mode 100644 dh_diplomatist/src/main/resources/application-test.yml create mode 100644 dh_diplomatist/src/main/resources/application.yml create mode 100644 dh_diplomatist/src/main/resources/druid-dev.yml create mode 100644 dh_diplomatist/src/main/resources/druid-prod.yml create mode 100644 dh_diplomatist/src/main/resources/druid-test.yml create mode 100644 dh_diplomatist/src/main/resources/logback-spring.xml create mode 100644 dh_diplomatist/src/main/resources/mapper_dao/SPluginDao.xml create mode 100644 dh_diplomatist/src/main/resources/mapper_raw/IdcBusinessMapper.xml create mode 100644 dh_diplomatist/src/main/resources/mapper_raw/IdcDomainBusinessMapper.xml create mode 100644 dh_diplomatist/src/main/resources/mapper_raw/IdcDomainMapper.xml create mode 100644 dh_diplomatist/src/main/resources/mapper_raw/IdcUserDomainMapper.xml create mode 100644 dh_diplomatist/src/main/resources/mapper_raw/IdcUserMapper.xml create mode 100644 dh_diplomatist/src/main/resources/mybatis/mybatis-config.xml create mode 100644 dh_ht/.gitignore create mode 100644 dh_ht/mvnw create mode 100644 dh_ht/mvnw.cmd create mode 100644 dh_ht/pom.xml create mode 100644 dh_ht/src/main/java/com/ccsens/dh_ht/DhHtApplication.java create mode 100644 dh_ht/src/main/java/com/ccsens/dh_ht/api/DebugController.java create mode 100644 dh_ht/src/main/java/com/ccsens/dh_ht/api/ProjectController.java create mode 100644 dh_ht/src/main/java/com/ccsens/dh_ht/api/UserController.java create mode 100644 dh_ht/src/main/java/com/ccsens/dh_ht/bean/dto/ProjectDto.java create mode 100644 dh_ht/src/main/java/com/ccsens/dh_ht/bean/vo/ProjectVo.java create mode 100644 dh_ht/src/main/java/com/ccsens/dh_ht/config/BeanConfig.java create mode 100644 dh_ht/src/main/java/com/ccsens/dh_ht/config/SpringConfig.java create mode 100644 dh_ht/src/main/java/com/ccsens/dh_ht/config/SwaggerConfigure.java create mode 100644 dh_ht/src/main/java/com/ccsens/dh_ht/intercept/MybatisInterceptor.java create mode 100644 dh_ht/src/main/java/com/ccsens/dh_ht/service/IProjectService.java create mode 100644 dh_ht/src/main/java/com/ccsens/dh_ht/service/ProjectService.java create mode 100644 dh_ht/src/main/java/com/ccsens/dh_ht/util/PtOsCodeError.java create mode 100644 dh_ht/src/main/java/com/ccsens/dh_ht/util/PtOsConstant.java create mode 100644 dh_ht/src/main/resources/application-common.yml create mode 100644 dh_ht/src/main/resources/application-dev.yml create mode 100644 dh_ht/src/main/resources/application-prod.yml create mode 100644 dh_ht/src/main/resources/application-test.yml create mode 100644 dh_ht/src/main/resources/application.yml create mode 100644 dh_ht/src/main/resources/druid-dev.yml create mode 100644 dh_ht/src/main/resources/druid-prod.yml create mode 100644 dh_ht/src/main/resources/druid-test.yml create mode 100644 dh_ht/src/main/resources/logback-spring.xml create mode 100644 dh_ht/src/main/resources/mybatis/mybatis-config.xml create mode 100644 dh_ptos/.gitignore create mode 100644 dh_ptos/mvnw create mode 100644 dh_ptos/mvnw.cmd create mode 100644 dh_ptos/pom.xml create mode 100644 dh_ptos/src/main/java/com/ccsens/dh_ptos/DhPtosApplication.java create mode 100644 dh_ptos/src/main/java/com/ccsens/dh_ptos/api/DebugController.java create mode 100644 dh_ptos/src/main/java/com/ccsens/dh_ptos/api/ProjectController.java create mode 100644 dh_ptos/src/main/java/com/ccsens/dh_ptos/api/UserController.java create mode 100644 dh_ptos/src/main/java/com/ccsens/dh_ptos/bean/dto/ProjectDto.java create mode 100644 dh_ptos/src/main/java/com/ccsens/dh_ptos/bean/vo/ProjectVo.java create mode 100644 dh_ptos/src/main/java/com/ccsens/dh_ptos/config/BeanConfig.java create mode 100644 dh_ptos/src/main/java/com/ccsens/dh_ptos/config/SpringConfig.java create mode 100644 dh_ptos/src/main/java/com/ccsens/dh_ptos/config/SwaggerConfigure.java create mode 100644 dh_ptos/src/main/java/com/ccsens/dh_ptos/intercept/MybatisInterceptor.java create mode 100644 dh_ptos/src/main/java/com/ccsens/dh_ptos/service/IProjectService.java create mode 100644 dh_ptos/src/main/java/com/ccsens/dh_ptos/service/ProjectService.java create mode 100644 dh_ptos/src/main/java/com/ccsens/dh_ptos/util/PtOsCodeError.java create mode 100644 dh_ptos/src/main/java/com/ccsens/dh_ptos/util/PtOsConstant.java create mode 100644 dh_ptos/src/main/resources/application-common.yml create mode 100644 dh_ptos/src/main/resources/application-dev.yml create mode 100644 dh_ptos/src/main/resources/application-prod.yml create mode 100644 dh_ptos/src/main/resources/application-test.yml create mode 100644 dh_ptos/src/main/resources/application.yml create mode 100644 dh_ptos/src/main/resources/druid-dev.yml create mode 100644 dh_ptos/src/main/resources/druid-prod.yml create mode 100644 dh_ptos/src/main/resources/druid-test.yml create mode 100644 dh_ptos/src/main/resources/logback-spring.xml create mode 100644 dh_ptos/src/main/resources/mybatis/mybatis-config.xml create mode 100644 origin) create mode 100644 pom.xml create mode 100644 util/pom.xml create mode 100644 util/src/main/java/com/ccsens/util/Base64FileUtil.java create mode 100644 util/src/main/java/com/ccsens/util/BeanWrapperUtil.java create mode 100644 util/src/main/java/com/ccsens/util/CRCUtil.java create mode 100644 util/src/main/java/com/ccsens/util/CodeEnum.java create mode 100644 util/src/main/java/com/ccsens/util/CodeError.java create mode 100644 util/src/main/java/com/ccsens/util/DateUtil.java create mode 100644 util/src/main/java/com/ccsens/util/DesensitizedUtils.java create mode 100644 util/src/main/java/com/ccsens/util/DistanceUtil.java create mode 100644 util/src/main/java/com/ccsens/util/ExcelUtil.java create mode 100644 util/src/main/java/com/ccsens/util/GenericsUtils.java create mode 100644 util/src/main/java/com/ccsens/util/HttpServletUtil.java create mode 100644 util/src/main/java/com/ccsens/util/HttpsUtil.java create mode 100644 util/src/main/java/com/ccsens/util/ImageCodeGeneratorUtil.java create mode 100644 util/src/main/java/com/ccsens/util/ImgUtil.java create mode 100644 util/src/main/java/com/ccsens/util/JacksonUtil.java create mode 100644 util/src/main/java/com/ccsens/util/JsonResponse.java create mode 100644 util/src/main/java/com/ccsens/util/JsonResponse1.java create mode 100644 util/src/main/java/com/ccsens/util/JsonResponse2.java create mode 100644 util/src/main/java/com/ccsens/util/JwtUtil.java create mode 100644 util/src/main/java/com/ccsens/util/KCPlayerSignature.java create mode 100644 util/src/main/java/com/ccsens/util/Md5Util.java create mode 100644 util/src/main/java/com/ccsens/util/MyJacksonObjectMapper.java create mode 100644 util/src/main/java/com/ccsens/util/NotSupportedFileTypeException.java create mode 100644 util/src/main/java/com/ccsens/util/PasswordEncryptionUtil.java create mode 100644 util/src/main/java/com/ccsens/util/PdfUtil.java create mode 100644 util/src/main/java/com/ccsens/util/PoiUtil.java create mode 100644 util/src/main/java/com/ccsens/util/PropUtil.java create mode 100644 util/src/main/java/com/ccsens/util/QrCodeUtil.java create mode 100644 util/src/main/java/com/ccsens/util/RedisKeyManager.java create mode 100644 util/src/main/java/com/ccsens/util/RedisUtil.java create mode 100644 util/src/main/java/com/ccsens/util/RestTemplateUtil.java create mode 100644 util/src/main/java/com/ccsens/util/SQLUtil.java create mode 100644 util/src/main/java/com/ccsens/util/Sha1Util.java create mode 100644 util/src/main/java/com/ccsens/util/ShiroKit.java create mode 100644 util/src/main/java/com/ccsens/util/SmsUtil.java create mode 100644 util/src/main/java/com/ccsens/util/SpringContextUtils.java create mode 100644 util/src/main/java/com/ccsens/util/StringUtil.java create mode 100644 util/src/main/java/com/ccsens/util/ToolUtil.java create mode 100644 util/src/main/java/com/ccsens/util/TransactionUtil.java create mode 100644 util/src/main/java/com/ccsens/util/UploadFileUtil_Servlet3.java create mode 100644 util/src/main/java/com/ccsens/util/WebConstant.java create mode 100644 util/src/main/java/com/ccsens/util/WechatUtil.java create mode 100644 util/src/main/java/com/ccsens/util/WordToJpgUtil.java create mode 100644 util/src/main/java/com/ccsens/util/WpsSignature.java create mode 100644 util/src/main/java/com/ccsens/util/ali/AliInstanceUtil.java create mode 100644 util/src/main/java/com/ccsens/util/ali/Demolyocr_general_advanced.java create mode 100644 util/src/main/java/com/ccsens/util/ali/HttpApiClientlyocr_general_advanced.java create mode 100644 util/src/main/java/com/ccsens/util/ali/HttpsApiClientlyocr_general_advanced.java create mode 100644 util/src/main/java/com/ccsens/util/annotation/OperateType.java create mode 100644 util/src/main/java/com/ccsens/util/baidu/BaiDuDto.java create mode 100644 util/src/main/java/com/ccsens/util/baidu/BaiDuUtil.java create mode 100644 util/src/main/java/com/ccsens/util/baidu/BaiDuVo.java create mode 100644 util/src/main/java/com/ccsens/util/bean/dto/QueryDto.java create mode 100644 util/src/main/java/com/ccsens/util/bean/message/client/AckMessage.java create mode 100644 util/src/main/java/com/ccsens/util/bean/message/client/AuthMessage.java create mode 100644 util/src/main/java/com/ccsens/util/bean/message/client/ClientAuthTimeOutMessage.java create mode 100644 util/src/main/java/com/ccsens/util/bean/message/client/ClientIdleClosedMessage.java create mode 100644 util/src/main/java/com/ccsens/util/bean/message/client/GetStatusMessage.java create mode 100644 util/src/main/java/com/ccsens/util/bean/message/client/HasReadMessage.java create mode 100644 util/src/main/java/com/ccsens/util/bean/message/client/PingMessage.java create mode 100644 util/src/main/java/com/ccsens/util/bean/message/client/SetDeletedStatusMessage.java create mode 100644 util/src/main/java/com/ccsens/util/bean/message/client/SetRevertedStatusMessage.java create mode 100644 util/src/main/java/com/ccsens/util/bean/message/client/SetSuccessStatusMessage.java create mode 100644 util/src/main/java/com/ccsens/util/bean/message/client/UnExceptedErrorMessage.java create mode 100644 util/src/main/java/com/ccsens/util/bean/message/common/InMessage.java create mode 100644 util/src/main/java/com/ccsens/util/bean/message/common/Message.java create mode 100644 util/src/main/java/com/ccsens/util/bean/message/common/MessageConstant.java create mode 100644 util/src/main/java/com/ccsens/util/bean/message/common/MessageRule.java create mode 100644 util/src/main/java/com/ccsens/util/bean/message/common/OutMessage.java create mode 100644 util/src/main/java/com/ccsens/util/bean/message/common/OutMessageSet.java create mode 100644 util/src/main/java/com/ccsens/util/bean/message/common/ServerMessage.java create mode 100644 util/src/main/java/com/ccsens/util/bean/message/server/ChannelStatusMessage.java create mode 100644 util/src/main/java/com/ccsens/util/bean/message/server/InvertedMessage.java create mode 100644 util/src/main/java/com/ccsens/util/bean/message/server/PongMessage.java create mode 100644 util/src/main/java/com/ccsens/util/bean/message/server/QueueStatusMessage.java create mode 100644 util/src/main/java/com/ccsens/util/bean/message/server/ServerAckMessage.java create mode 100644 util/src/main/java/com/ccsens/util/bean/wx/dto/WxGzhAction.java create mode 100644 util/src/main/java/com/ccsens/util/bean/wx/po/WxAccessToken.java create mode 100644 util/src/main/java/com/ccsens/util/bean/wx/po/WxBaseEntity.java create mode 100644 util/src/main/java/com/ccsens/util/bean/wx/po/WxGzhAuthType.java create mode 100644 util/src/main/java/com/ccsens/util/bean/wx/po/WxGzhMenu.java create mode 100644 util/src/main/java/com/ccsens/util/bean/wx/po/WxGzhMsgEvent.java create mode 100644 util/src/main/java/com/ccsens/util/bean/wx/po/WxGzhMsgType.java create mode 100644 util/src/main/java/com/ccsens/util/bean/wx/po/WxOauth2AccessToken.java create mode 100644 util/src/main/java/com/ccsens/util/bean/wx/po/WxOauth2UserInfo.java create mode 100644 util/src/main/java/com/ccsens/util/bean/wx/po/WxOperation.java create mode 100644 util/src/main/java/com/ccsens/util/config/CommonConfig.java create mode 100644 util/src/main/java/com/ccsens/util/config/ControllerExceptionHandler.java create mode 100644 util/src/main/java/com/ccsens/util/config/DruidProps.java create mode 100644 util/src/main/java/com/ccsens/util/config/H5WebSocketInterceptor.java create mode 100644 util/src/main/java/com/ccsens/util/config/MyPropertySourceFactory.java create mode 100644 util/src/main/java/com/ccsens/util/config/RabbitMQConfig.java create mode 100644 util/src/main/java/com/ccsens/util/config/RedisConfig.java create mode 100644 util/src/main/java/com/ccsens/util/config/ServletConfig.java create mode 100644 util/src/main/java/com/ccsens/util/config/SwaggerConfigure.java create mode 100644 util/src/main/java/com/ccsens/util/cron/CronConstant.java create mode 100644 util/src/main/java/com/ccsens/util/cron/NatureConstant.java create mode 100644 util/src/main/java/com/ccsens/util/cron/NatureLanguage.java create mode 100644 util/src/main/java/com/ccsens/util/cron/NatureToDate.java create mode 100644 util/src/main/java/com/ccsens/util/enterprisewx/AesException.java create mode 100644 util/src/main/java/com/ccsens/util/enterprisewx/ByteGroup.java create mode 100644 util/src/main/java/com/ccsens/util/enterprisewx/PKCS7Encoder.java create mode 100644 util/src/main/java/com/ccsens/util/enterprisewx/SHA1.java create mode 100644 util/src/main/java/com/ccsens/util/enterprisewx/WXBizMsgCrypt.java create mode 100644 util/src/main/java/com/ccsens/util/enterprisewx/WeiXinConstant.java create mode 100644 util/src/main/java/com/ccsens/util/enterprisewx/XMLParse.java create mode 100644 util/src/main/java/com/ccsens/util/enterprisewx/dto/MessageDto.java create mode 100644 util/src/main/java/com/ccsens/util/enterprisewx/vo/WeiXinVo.java create mode 100644 util/src/main/java/com/ccsens/util/exception/BaseException.java create mode 100644 util/src/main/java/com/ccsens/util/exception/BusinessException.java create mode 100644 util/src/main/java/com/ccsens/util/exception/WxException.java create mode 100644 util/src/main/java/com/ccsens/util/message/BaseMessageDto.java create mode 100644 util/src/main/java/com/ccsens/util/message/RecoveryWithStartRecipe.java create mode 100644 util/src/main/java/com/ccsens/util/message/SwitchoverProjectUtil.java create mode 100644 util/src/main/java/com/ccsens/util/mq/DelayConsumer.java create mode 100644 util/src/main/java/com/ccsens/util/mq/DelayProducer.java create mode 100644 util/src/main/java/com/ccsens/util/mybatis/MybatisRedisCache.java create mode 100644 util/src/main/java/com/ccsens/util/notice/MailSendUtil.java create mode 100644 util/src/main/java/com/ccsens/util/notice/NoticePropUtil.java create mode 100644 util/src/main/java/com/ccsens/util/notice/SmsSendUtil.java create mode 100644 util/src/main/java/com/ccsens/util/notice/dto/MailDto.java create mode 100644 util/src/main/java/com/ccsens/util/notice/dto/SmsDto.java create mode 100644 util/src/main/java/com/ccsens/util/redis/AbstractRedisService.java create mode 100644 util/src/main/java/com/ccsens/util/wx/WxGzhUtil.java create mode 100644 util/src/main/java/com/ccsens/util/wx/WxRobotUtil.java create mode 100644 util/src/main/java/com/ccsens/util/wx/WxTemplateMessage.java create mode 100644 util/src/main/java/com/ccsens/util/wx/WxXcxUtil.java create mode 100644 util/src/test/java/com/ccsens/util/Base64Test.java create mode 100644 util/src/test/java/com/ccsens/util/DateTest.java create mode 100644 util/src/test/java/com/ccsens/util/FileTest.java create mode 100644 util/src/test/java/com/ccsens/util/KeyTest.java create mode 100644 util/src/test/java/com/ccsens/util/ListSort.java create mode 100644 util/src/test/java/com/ccsens/util/OtherTest.java create mode 100644 util/src/test/java/com/ccsens/util/PDFTest.java create mode 100644 util/src/test/java/com/ccsens/util/PdfUtilTest.java create mode 100644 util/src/test/java/com/ccsens/util/StuVO.java create mode 100644 util/src/test/java/com/ccsens/util/TallTest.java create mode 100644 util/src/test/java/com/ccsens/util/TestQrCord.java create mode 100644 util/src/test/java/com/ccsens/util/TestWpsSignature.java create mode 100644 util/src/test/java/com/ccsens/util/VideoTest.java create mode 100644 util/src/test/java/com/ccsens/util/ZipTest.java create mode 100644 wechatutil/.gitignore create mode 100644 wechatutil/mvnw create mode 100644 wechatutil/mvnw.cmd create mode 100644 wechatutil/pom.xml create mode 100644 wechatutil/src/main/java/com/ccsens/wechatutil/WechatutilApplication.java create mode 100644 wechatutil/src/main/java/com/ccsens/wechatutil/api/DebugController.java create mode 100644 wechatutil/src/main/java/com/ccsens/wechatutil/api/WxController.java create mode 100644 wechatutil/src/main/java/com/ccsens/wechatutil/bean/dto/WechatCode.java create mode 100644 wechatutil/src/main/java/com/ccsens/wechatutil/bean/dto/WxMessageDto.java create mode 100644 wechatutil/src/main/java/com/ccsens/wechatutil/bean/dto/WxTemplateMessage.java create mode 100644 wechatutil/src/main/java/com/ccsens/wechatutil/bean/dto/wxmini/NoticeDto.java create mode 100644 wechatutil/src/main/java/com/ccsens/wechatutil/bean/po/MiniProgramUser.java create mode 100644 wechatutil/src/main/java/com/ccsens/wechatutil/bean/po/WxAccessToken.java create mode 100644 wechatutil/src/main/java/com/ccsens/wechatutil/bean/po/WxBaseEntity.java create mode 100644 wechatutil/src/main/java/com/ccsens/wechatutil/bean/po/WxOauth2AccessToken.java create mode 100644 wechatutil/src/main/java/com/ccsens/wechatutil/bean/po/WxOauth2UserInfo.java create mode 100644 wechatutil/src/main/java/com/ccsens/wechatutil/bean/po/WxPhoneDecryptInfo.java create mode 100644 wechatutil/src/main/java/com/ccsens/wechatutil/bean/po/wxfiotexplorer/FiotSignin.java create mode 100644 wechatutil/src/main/java/com/ccsens/wechatutil/bean/po/wxfiotexplorer/FiotSigninResponse.java create mode 100644 wechatutil/src/main/java/com/ccsens/wechatutil/bean/po/wxfiotexplorer/ResponseInfo.java create mode 100644 wechatutil/src/main/java/com/ccsens/wechatutil/bean/vo/wxmini/Custom.java create mode 100644 wechatutil/src/main/java/com/ccsens/wechatutil/config/BeanConfig.java create mode 100644 wechatutil/src/main/java/com/ccsens/wechatutil/config/SpringConfig.java create mode 100644 wechatutil/src/main/java/com/ccsens/wechatutil/config/SwaggerConfigure.java create mode 100644 wechatutil/src/main/java/com/ccsens/wechatutil/exception/PayException.java create mode 100644 wechatutil/src/main/java/com/ccsens/wechatutil/intercept/MybatisInterceptor.java create mode 100644 wechatutil/src/main/java/com/ccsens/wechatutil/payutil/AesUtil.java create mode 100644 wechatutil/src/main/java/com/ccsens/wechatutil/payutil/HttpsUtil.java create mode 100644 wechatutil/src/main/java/com/ccsens/wechatutil/payutil/JacksonUtil.java create mode 100644 wechatutil/src/main/java/com/ccsens/wechatutil/payutil/WxMessageUtil.java create mode 100644 wechatutil/src/main/java/com/ccsens/wechatutil/payutil/WxPayDirectUtils.java create mode 100644 wechatutil/src/main/java/com/ccsens/wechatutil/payutil/WxPayProviderUtils.java create mode 100644 wechatutil/src/main/java/com/ccsens/wechatutil/payutil/WxTokenUtil.java create mode 100644 wechatutil/src/main/java/com/ccsens/wechatutil/util/TC3Util.java create mode 100644 wechatutil/src/main/java/com/ccsens/wechatutil/util/WxCodeError.java create mode 100644 wechatutil/src/main/java/com/ccsens/wechatutil/util/WxConstant.java create mode 100644 wechatutil/src/main/java/com/ccsens/wechatutil/wxcommon/WxCommonUtil.java create mode 100644 wechatutil/src/main/java/com/ccsens/wechatutil/wxenterprise/EnterpriseRobotUtil.java create mode 100644 wechatutil/src/main/java/com/ccsens/wechatutil/wxfiotexplorer/FiotExplorerSigninUtil.java create mode 100644 wechatutil/src/main/java/com/ccsens/wechatutil/wxh5/H5SigninUtil.java create mode 100644 wechatutil/src/main/java/com/ccsens/wechatutil/wxmini/MiniCodeUtil.java create mode 100644 wechatutil/src/main/java/com/ccsens/wechatutil/wxmini/MiniCustomSendUtil.java create mode 100644 wechatutil/src/main/java/com/ccsens/wechatutil/wxmini/MiniEncryptionAndDecryptionUtil.java create mode 100644 wechatutil/src/main/java/com/ccsens/wechatutil/wxmini/MiniMessageUtil.java create mode 100644 wechatutil/src/main/java/com/ccsens/wechatutil/wxmini/MiniSigninUtil.java create mode 100644 wechatutil/src/main/java/com/ccsens/wechatutil/wxofficial/OfficialAccountMessageUtil.java create mode 100644 wechatutil/src/main/java/com/ccsens/wechatutil/wxofficial/OfficialAccountSigninUtil.java create mode 100644 wechatutil/src/main/resources/application-common.yml create mode 100644 wechatutil/src/main/resources/application-dev.yml create mode 100644 wechatutil/src/main/resources/application-prod.yml create mode 100644 wechatutil/src/main/resources/application-test.yml create mode 100644 wechatutil/src/main/resources/application.yml create mode 100644 wechatutil/src/main/resources/business.yml create mode 100644 wechatutil/src/main/resources/druid-dev.yml create mode 100644 wechatutil/src/main/resources/druid-prod.yml create mode 100644 wechatutil/src/main/resources/druid-test.yml create mode 100644 wechatutil/src/main/resources/logback-spring.xml create mode 100644 wechatutil/src/main/resources/mybatis/mybatis-config.xml create mode 100644 wechatutil/src/test/java/com/ccsens/wechatutil/WechatutilApplicationTests.java diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..073a042 --- /dev/null +++ b/.gitignore @@ -0,0 +1,43 @@ +# Created by .ignore support plugin (hsz.mobi) +### Example user template template +### Example user template +target +target/ +target/* +# IntelliJ project files +.idea +.idea/ +.idea/* +*.iml +.mvn +.mvn/ +.mvn/* +out +gen +### Java template +# Compiled class file +*.class + +# Log file +*.log + +# BlueJ files +*.ctxt + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.jar +*.war +*.nar +*.ear +*.zip +*.tar.gz +*.rar + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* +mbg.xml +resources/mbg.xml +resources/application.yml diff --git a/cloudutil/pom.xml b/cloudutil/pom.xml new file mode 100644 index 0000000..1694667 --- /dev/null +++ b/cloudutil/pom.xml @@ -0,0 +1,54 @@ + + + + ccsens_dh + com.ccsens + 1.0-SNAPSHOT + + 4.0.0 + + cloudutil + + + + + + util + com.ccsens + 1.0-SNAPSHOT + + + + org.springframework.cloud + spring-cloud-starter-netflix-eureka-client + + + + org.springframework.cloud + spring-cloud-starter-openfeign + + + + org.springframework.cloud + spring-cloud-starter-netflix-hystrix + + + + org.springframework.cloud + spring-cloud-starter-sleuth + + + + org.springframework.cloud + spring-cloud-sleuth-zipkin + + + com.alibaba + fastjson + 1.2.62 + + + + \ No newline at end of file diff --git a/cloudutil/src/main/java/com/ccsens/cloudutil/annotation/CacheMd5.java b/cloudutil/src/main/java/com/ccsens/cloudutil/annotation/CacheMd5.java new file mode 100644 index 0000000..db1905c --- /dev/null +++ b/cloudutil/src/main/java/com/ccsens/cloudutil/annotation/CacheMd5.java @@ -0,0 +1,13 @@ +package com.ccsens.cloudutil.annotation; + +import java.lang.annotation.*; + + +/** + * @author 逗 + */ +@Documented +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.METHOD) +public @interface CacheMd5 { +} diff --git a/cloudutil/src/main/java/com/ccsens/cloudutil/annotation/Login.java b/cloudutil/src/main/java/com/ccsens/cloudutil/annotation/Login.java new file mode 100644 index 0000000..41f2813 --- /dev/null +++ b/cloudutil/src/main/java/com/ccsens/cloudutil/annotation/Login.java @@ -0,0 +1,14 @@ +package com.ccsens.cloudutil.annotation; + +import java.lang.annotation.*; + +/** + * 有token,则根据token获取userId, 无则不获取 + * @author: wuHuiJuan + * @create: 2019/12/26 16:39 + */ +@Documented +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.METHOD) +public @interface Login { +} diff --git a/cloudutil/src/main/java/com/ccsens/cloudutil/annotation/MustLogin.java b/cloudutil/src/main/java/com/ccsens/cloudutil/annotation/MustLogin.java new file mode 100644 index 0000000..00bb399 --- /dev/null +++ b/cloudutil/src/main/java/com/ccsens/cloudutil/annotation/MustLogin.java @@ -0,0 +1,24 @@ +package com.ccsens.cloudutil.annotation; + +import java.lang.annotation.*; + +/** + * @description: 用于标识方法需要登录,获取userId + * 如果未登录,直接返回用户未登录 + * @author: wuHuiJuan + * @create: 2019/12/09 09:48 + */ +@Documented +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.METHOD) +public @interface MustLogin { + /** + * -1 不处理 + * 0: 数组 + * 1:List + * 2:Set + * 3: Map + * */ + byte type() default -1; + +} diff --git a/cloudutil/src/main/java/com/ccsens/cloudutil/aspect/CacheMd5Aspect.java b/cloudutil/src/main/java/com/ccsens/cloudutil/aspect/CacheMd5Aspect.java new file mode 100644 index 0000000..7daf555 --- /dev/null +++ b/cloudutil/src/main/java/com/ccsens/cloudutil/aspect/CacheMd5Aspect.java @@ -0,0 +1,96 @@ +package com.ccsens.cloudutil.aspect; + +import com.alibaba.fastjson.JSONObject; +import com.ccsens.util.JsonResponse; +import com.ccsens.util.Md5Util; +import com.ccsens.util.WebConstant; +import lombok.extern.slf4j.Slf4j; +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.annotation.*; +import org.springframework.stereotype.Component; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; + +import javax.servlet.http.HttpServletRequest; + + +@Slf4j +@Aspect +@Component +public class CacheMd5Aspect { + + @Pointcut("@annotation(com.ccsens.cloudutil.annotation.CacheMd5)") + public void cacheMd5(){ + + } + + @Around("cacheMd5()") + public Object cacheMd5TestAspect1(ProceedingJoinPoint joinPoint) throws Throwable { + long s = System.currentTimeMillis(); + //拿到入参 + Object[] args = joinPoint.getArgs(); + + HttpServletRequest request = ((ServletRequestAttributes) + RequestContextHolder.getRequestAttributes()).getRequest(); + //获取入参的md5值 + final String inMd5 = request.getHeader(WebConstant.HEADER_KEY_MD5); + //获取返回值 + JsonResponse proceed = (JsonResponse) joinPoint.proceed(args); + //入参没有md5直接返回 + if(inMd5 == null){ + log.info("cache---入参md5为空"); + long e = System.currentTimeMillis(); + log.info("切面时间:{}",e-s); + return proceed; + } + //异常直接返回 + if(proceed.getCode() != 200){ + log.info("cache---接口异常"); + long e = System.currentTimeMillis(); + log.info("切面时间:{}",e-s); + return proceed; + } + //获取返回数据 + if(proceed.getData() == null){ + log.info("cache---返回数据为空"); + long e = System.currentTimeMillis(); + log.info("切面时间:{}",e-s); + return proceed; + } + //将date转成json并加密 + String data; + // 判断是否基本类型或字符串 + String type = "TYPE"; + if (proceed.getData() instanceof String ) { + data = (String)proceed.getData(); + } else if (proceed.getData() instanceof StringBuilder || proceed.getData() instanceof StringBuffer) { + data = proceed.getData().toString(); + } else if (proceed.getData().getClass().getField(type) != null && + ((Class)proceed.getData().getClass().getField(type).get(null)).isPrimitive()) { + // 基本类型 + data = String.valueOf(proceed.getData()); + } else { + try { + data = JSONObject.toJSONString(proceed.getData()); + } catch (Exception e) { + log.error("md5转换json异常:{}", e); + data = proceed.getData().toString(); + } + } + + + String outMd5 = Md5Util.stringTo(data); + log.info("md5:{}",outMd5); + if(inMd5.equalsIgnoreCase(outMd5)){ + log.info("md5相同则返回空"); + proceed.setMd5Status(JsonResponse.MD5Status.CHECK_SAME_YES); + proceed.setData(null); + } else { + proceed.setMd5Status(JsonResponse.MD5Status.CHECK_SAME_NO); + } + long e = System.currentTimeMillis(); + log.info("切面时间:{}",e-s); + return proceed; + } + +} diff --git a/cloudutil/src/main/java/com/ccsens/cloudutil/aspect/LogAspect.java b/cloudutil/src/main/java/com/ccsens/cloudutil/aspect/LogAspect.java new file mode 100644 index 0000000..efaf510 --- /dev/null +++ b/cloudutil/src/main/java/com/ccsens/cloudutil/aspect/LogAspect.java @@ -0,0 +1,149 @@ +package com.ccsens.cloudutil.aspect; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.ccsens.cloudutil.bean.tall.dto.LogDto; +import com.ccsens.cloudutil.feign.TallFeignClient; +import com.ccsens.util.UploadFileUtil_Servlet3; +import com.ccsens.util.WebConstant; +import io.jsonwebtoken.Claims; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.annotation.Around; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Pointcut; +import org.aspectj.lang.reflect.MethodSignature; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.annotation.Order; +import org.springframework.stereotype.Component; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; + +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.Part; +import java.lang.reflect.Method; +import java.util.HashSet; +import java.util.Set; + +/** + * @description: + * @author: wuHuiJuan + * @create: 2019/12/10 10:06 + */ +@Order(1) +@Slf4j +@Aspect +@Component +public class LogAspect { + + @Autowired + private TallFeignClient tallFeignClient; + + /**不记录日志的接口*/ + private Set ignoreUrlSet = new HashSet<>(); + { + ignoreUrlSet.add("/log/operation"); + ignoreUrlSet.add("/users/token"); + ignoreUrlSet.add("/users/claims"); + } + + + @Pointcut("execution(* com.ccsens.tall.web..*(..)) || execution(* com.ccsens.ht.api..*(..))" + + " || execution(* com.ccsens.mt.api..*(..)) || execution(* com.ccsens.game.api..*(..))" + + " || execution(* com.ccsens.health.api..*(..)) || execution(* com.ccsens.pims.api..*(..))") + public void logAdvice(){ + + } + + @Around("logAdvice()") + public Object around(ProceedingJoinPoint pjp) throws Throwable { + LogDto logDto = initLog(pjp); + + + Object result; + try { + result = pjp.proceed(); + } catch (Throwable throwable) { + log.error("方法运行异常", throwable); + if (logDto != null) { + String message = throwable.toString(); + logDto.setResult(message.length() > 1000 ? message.substring(0,1000) : message); + tallFeignClient.log(logDto); + } + throw throwable; + } + if (logDto != null) { + if("/users/signin".equals(logDto.getUrl()) && result != null){ + JSONObject json = JSONObject.parseObject(JSON.toJSONString(result)); + if(json.getIntValue("code") == 200 && json.get("data") != null){ + long userId = json.getJSONObject("data").getLongValue("id"); + logDto.setUserId(userId); + } + } + String message = result == null ? null : result.toString().length() > 1000 ? result.toString().substring(0, 1000) : result.toString(); + logDto.setResult(message); + tallFeignClient.log(logDto); + } + + return result; + } + + /** + * 获取方法路径、描述、参数 + * @param pjp + * @return + */ + private LogDto initLog(ProceedingJoinPoint pjp) { + + //路径 + HttpServletRequest request = ((ServletRequestAttributes) + RequestContextHolder.getRequestAttributes()).getRequest(); + String url = request.getServletPath(); + + if (ignoreUrlSet.contains(url)){ + log.info("保存日志,不进行记录"); + return null; + } + LogDto dto = new LogDto(); + dto.setUrl(url); + dto.setFacility(request.getHeader("fingerprint")); + //参数 + Object[] args = pjp.getArgs(); + StringBuilder param = new StringBuilder(); + for (int i = 0; i < args.length; i++) { + if (args[i] == null) { + continue; + }else if (args[i] instanceof ServletResponse) { + continue; + } else if (args[i] instanceof ServletRequest) { + Object claims = request.getAttribute(WebConstant.REQUEST_KEY_CLAIMS); + String userId = claims == null ? null : ((Claims) claims).getSubject(); + if (userId != null) { + param.append("userId:").append(userId).append("--"); + dto.setUserId(Long.parseLong(userId)); + } + + } else if (args[i] instanceof Part) { + param.append("file:").append(UploadFileUtil_Servlet3.getFileNameByPart((Part)args[i])).append("--"); + }else { + param.append(args[i]).append("--"); + } + + } + dto.setParams(param.length() > 1000 ? param.substring(0, 1000) : param.toString()); + try { + MethodSignature methodSignature = (MethodSignature) pjp.getSignature(); + Method method = pjp.getTarget().getClass().getMethod(methodSignature.getName(), methodSignature.getParameterTypes()); + ApiOperation annotation = method.getAnnotation(ApiOperation.class); + dto.setMethodDesc(annotation == null ? "" : annotation.value()); + } catch (Exception e) { + log.error("获取方法时异常",e); + } + + return dto; + } + +} diff --git a/cloudutil/src/main/java/com/ccsens/cloudutil/aspect/MustLoginAspect.java b/cloudutil/src/main/java/com/ccsens/cloudutil/aspect/MustLoginAspect.java new file mode 100644 index 0000000..a4eb057 --- /dev/null +++ b/cloudutil/src/main/java/com/ccsens/cloudutil/aspect/MustLoginAspect.java @@ -0,0 +1,150 @@ +package com.ccsens.cloudutil.aspect; + +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.ccsens.cloudutil.annotation.MustLogin; +import com.ccsens.cloudutil.feign.Tall3FeignClient; +import com.ccsens.util.CodeEnum; +import com.ccsens.util.JsonResponse; +import com.ccsens.util.WebConstant; +import com.ccsens.util.bean.dto.QueryDto; +import lombok.extern.slf4j.Slf4j; +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.Signature; +import org.aspectj.lang.annotation.Around; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Pointcut; +import org.aspectj.lang.reflect.MethodSignature; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.annotation.Order; +import org.springframework.stereotype.Component; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; + +import javax.servlet.http.HttpServletRequest; +import java.lang.reflect.*; +import java.util.ArrayList; +import java.util.List; + +/** + * @description: + * @author: wuHuiJuan + * @create: 2019/12/09 09:54 + */ +@Order(0) +@Slf4j +@Aspect +@Component +public class MustLoginAspect { + @Autowired + private Tall3FeignClient tall3FeignClient; + + @Pointcut("@annotation(com.ccsens.cloudutil.annotation.MustLogin) || @annotation(com.ccsens.cloudutil.annotation.Login) ") + public void loginAdvice(){} + + @Around("loginAdvice()") + public Object around(ProceedingJoinPoint pjp) throws Throwable { + + HttpServletRequest request = ((ServletRequestAttributes) + RequestContextHolder.getRequestAttributes()).getRequest(); + + final String authHeader = request.getHeader(WebConstant.HEADER_KEY_TOKEN); +// if(StrUtil.isEmpty(authHeader)){ +// return JsonResponse.newInstance().ok(CodeEnum.NOT_LOGIN); +// } + Object[] args = pjp.getArgs(); + QueryDto dto = args == null || args.length < 1 ? null : (QueryDto) args[0]; + + //获取userId + JsonResponse response = null; + if(StrUtil.isNotEmpty(authHeader)){ + log.info("MustLogin————token:{}", authHeader); + response = tall3FeignClient.getUserIdByToken(authHeader); + } + log.info("{}获取userId:{}", authHeader, response); + + Signature signature = pjp.getSignature(); + MethodSignature methodSignature = (MethodSignature) signature; + Method targetMethod = methodSignature.getMethod(); + + MustLogin mustLoginAnnotation = targetMethod.getAnnotation(MustLogin.class); + fillSpecial(dto, mustLoginAnnotation); + if (mustLoginAnnotation == null) { + log.info("不是必须登录,有token,则添加userId,没有则不添加"); + if (response != null && response.getCode().intValue() == CodeEnum.SUCCESS.getCode().intValue() && response.getData() != null) { + JSONObject json = JSONObject.parseObject(JSON.toJSONString(response.getData())); + Long userId = json.getLong("id"); + String userName = json.getString("userName"); + String avatarUrl = json.getString("avatarUrl"); + String phone = json.getString("phone"); + if (dto != null) { + dto.setUserId(userId); + dto.setUserName(userName); + dto.setAvatarUrl(avatarUrl); + dto.setPhone(phone); + } + } + Object result = pjp.proceed(); + return result; + } + //必须登录,未登录直接返回未登录相关信息 + //必须登录,未登录直接返回未登录相关信息 + if (response == null) { + return JsonResponse.newInstance().ok(CodeEnum.NOT_LOGIN); + } + if (response.getCode().intValue() != CodeEnum.SUCCESS.getCode().intValue()) { + return response; + } + if (response.getData() == null) { + return JsonResponse.newInstance().ok(CodeEnum.NOT_LOGIN); + } + JSONObject json = JSONObject.parseObject(JSON.toJSONString(response.getData())); + Long userId = json.getLong("id"); + String userName = json.getString("userName"); + String avatarUrl = json.getString("avatarUrl"); + String phone = json.getString("phone"); + if (userId == null || userId == 0) { + return JsonResponse.newInstance().ok(CodeEnum.NOT_LOGIN); + } + + if (dto != null) { + dto.setUserId(userId); + dto.setUserName(userName); + dto.setAvatarUrl(avatarUrl); + dto.setPhone(phone); + } + + Object result = pjp.proceed(); + return result; + } + + private void fillSpecial(QueryDto dto, MustLogin mustLoginAnnotation) { + if (mustLoginAnnotation == null) { + return; + } + if (dto != null && mustLoginAnnotation.type() > -1) { + switch (mustLoginAnnotation.type()) { + case 0: + Object obj = dto.getParam(); + if (obj!= null && !obj.getClass().isArray()) { + Class aClass = dto.getParam().getClass(); + Object o = Array.newInstance(aClass, 1); + Array.set(o, 0, dto.getParam()); + dto.setParam(o); + } + break; + case 1: + Object obj1 = dto.getParam(); + if (obj1!= null && !(obj1 instanceof List)) { + ArrayList arrayList = new ArrayList(); + arrayList.add(dto.getParam()); + dto.setParam(arrayList); + } + break; + } + + } + } + +} diff --git a/cloudutil/src/main/java/com/ccsens/cloudutil/bean/QueryParam.java b/cloudutil/src/main/java/com/ccsens/cloudutil/bean/QueryParam.java new file mode 100644 index 0000000..99d17bc --- /dev/null +++ b/cloudutil/src/main/java/com/ccsens/cloudutil/bean/QueryParam.java @@ -0,0 +1,14 @@ +package com.ccsens.cloudutil.bean; + +import lombok.Data; + +/** + * @description: + * @author: wuHuiJuan + * @create: 2019/11/27 10:06 + */ +@Data +public class QueryParam { + private T t; + private Long userId; +} diff --git a/cloudutil/src/main/java/com/ccsens/cloudutil/bean/tall/dto/HolidaysDto.java b/cloudutil/src/main/java/com/ccsens/cloudutil/bean/tall/dto/HolidaysDto.java new file mode 100644 index 0000000..00807ba --- /dev/null +++ b/cloudutil/src/main/java/com/ccsens/cloudutil/bean/tall/dto/HolidaysDto.java @@ -0,0 +1,15 @@ +package com.ccsens.cloudutil.bean.tall.dto; + +import lombok.Data; + +/** + * @author 逗 + */ +@Data +public class HolidaysDto { + @Data + public static class GetHolidays{ + private Long startTime; + private Long endTime; + } +} diff --git a/cloudutil/src/main/java/com/ccsens/cloudutil/bean/tall/dto/LogDto.java b/cloudutil/src/main/java/com/ccsens/cloudutil/bean/tall/dto/LogDto.java new file mode 100644 index 0000000..b6bef73 --- /dev/null +++ b/cloudutil/src/main/java/com/ccsens/cloudutil/bean/tall/dto/LogDto.java @@ -0,0 +1,31 @@ +package com.ccsens.cloudutil.bean.tall.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotNull; + +/** + * @description: + * @author: wuHuiJuan + * @create: 2019/12/09 18:01 + */ +@Data +@ApiModel +public class LogDto { + + private Long id; + @ApiModelProperty("接口地址") + private String url; + @ApiModelProperty("接口参数") + private String params; + @ApiModelProperty("接口描述") + private String methodDesc; + @ApiModelProperty("接口返回值(或异常)") + private String result; + @ApiModelProperty("设备信息") + private String facility; + @ApiModelProperty("设备信息") + private Long userId; +} diff --git a/cloudutil/src/main/java/com/ccsens/cloudutil/bean/tall/dto/MemberRoleDto.java b/cloudutil/src/main/java/com/ccsens/cloudutil/bean/tall/dto/MemberRoleDto.java new file mode 100644 index 0000000..2c3fc40 --- /dev/null +++ b/cloudutil/src/main/java/com/ccsens/cloudutil/bean/tall/dto/MemberRoleDto.java @@ -0,0 +1,169 @@ +package com.ccsens.cloudutil.bean.tall.dto; + +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.util.StrUtil; +import com.ccsens.util.CodeEnum; +import com.ccsens.util.PropUtil; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import org.springframework.beans.BeanUtils; + +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.NotNull; +import java.util.List; + +/** + * @description: + * @author: wuHuiJuan + * @create: 2019/12/05 10:37 + */ +public class MemberRoleDto { + @ApiModel("MemberRoleDtoAssign") + @Data + public static class Assign{ + @ApiModelProperty("项目ID") + private Long projectId; + @ApiModelProperty("项目名称") + private String projectName = PropUtil.projectName; + @ApiModelProperty("角色") + private List roleNames; + @ApiModelProperty("用户ID") + @NotNull + private Long userId; + @ApiModelProperty("用户名") + @NotNull + private String name; + @ApiModelProperty("操作人ID") + @NotNull + private Long createBy; + + + public CodeEnum check(){ + //至少有一个条件 + boolean noProject = (projectId == null || projectId == 0 ) && StrUtil.isBlank(projectName); + if (noProject) { + return CodeEnum.PARAM_ERROR; + } + return CodeEnum.SUCCESS; + } + } + + @ApiModel("MemberRoleDtoDelete") + @Data + public static class Delete{ + @ApiModelProperty("项目ID") + private Long projectId; + @ApiModelProperty("项目名称") + private String projectName = PropUtil.projectName; + @ApiModelProperty("角色") + private List roleNames; + @ApiModelProperty("用户ID") + @NotNull + private Long userId; + + public CodeEnum check(){ + //至少有一个条件 + boolean hasProject = (projectId == null || projectId == 0 ) && StrUtil.isBlank(projectName); + if (!hasProject) { + return CodeEnum.PARAM_ERROR; + } + return CodeEnum.SUCCESS; + } + + public Assign toAssign(){ + Assign assign = new Assign(); + BeanUtils.copyProperties(this, assign); + return assign; + } + } + + @Data + @ApiModel("添加成员") + public static class SaveMember{ + @NotNull + @ApiModelProperty("项目id") + private Long projectId; + @ApiModelProperty("成员名") + private String memberName; + @NotEmpty + @ApiModelProperty("成员手机号") + private String phone; + @ApiModelProperty("所属角色的id") + private List roleId; + @ApiModelProperty("奖惩干系人手机号") + private String stakeholderPhone; + @ApiModelProperty("奖惩干系人姓名") + private String stakeholderName; + @ApiModelProperty("token") + private String token; + } + + @Data + @ApiModel("添加角色") + public static class SaveRole{ + @NotNull(message = "项目不能为空") + @ApiModelProperty("项目id") + private Long projectId; + @NotEmpty(message = "角色名不能为空") + @ApiModelProperty("角色名") + private String roleName; + @ApiModelProperty("token") + private String token; + } + + @Data + @ApiModel + public static class GetMemberByPhone{ + @ApiModelProperty("项目id") + private Long projectId; + @ApiModelProperty("手机号") + private String phone; + @ApiModelProperty("token") + private String token; + } + + + @Data + @ApiModel("给角色添加成员") + public static class SaveMemberInRole{ + @NotNull(message = "角色Id不能为空") + @ApiModelProperty("角色id") + private Long roleId; + @ApiModelProperty("成员Id") + private Long memberId; + @ApiModelProperty("token") + private String token; + } + + @Data + @ApiModel("给角色添加成员") + public static class DeleteRole{ + @ApiModelProperty("角色id") + private Long roleId; + @ApiModelProperty("token") + private String token; + } + + @Data + @ApiModel("给模板项目添加成员") + public static class SaveMemberForTemplate { + @NotNull(message = "项目id不能为空") + @ApiModelProperty("项目id") + private Long projectId; + @ApiModelProperty("成员列表") + private List memberForTemplate; + } + @Data + @ApiModel("模板项目成员信息") + public static class MemberForTemplate { + @ApiModelProperty("用户id(医生)") + private Long userId; + @ApiModelProperty("成员名") + private String memberName; + @ApiModelProperty("成员手机号") + private String phone; + @ApiModelProperty("所属角色的名称") + private List roleName; + } +} diff --git a/cloudutil/src/main/java/com/ccsens/cloudutil/bean/tall/dto/ProjectDto.java b/cloudutil/src/main/java/com/ccsens/cloudutil/bean/tall/dto/ProjectDto.java new file mode 100644 index 0000000..26da572 --- /dev/null +++ b/cloudutil/src/main/java/com/ccsens/cloudutil/bean/tall/dto/ProjectDto.java @@ -0,0 +1,56 @@ +package com.ccsens.cloudutil.bean.tall.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.NotNull; +import java.util.List; +import java.util.Set; + +/** + * @author AUSU + */ +@Data +public class ProjectDto { + @Data + @ApiModel("根据模板复制项目") + public static class CopyProject{ + @NotNull(message = "请选择要复制得项目") + @ApiModelProperty("项目id") + private Long projectId; + @ApiModelProperty("新项目名字") + private String projectName; + } + + @Data + @ApiModel("添加项目信息") + public static class SaveProjectDto{ + @ApiModelProperty("id") + private Long id; + @ApiModelProperty("父项目id") + private Long parentId; + @ApiModelProperty("项目名称") + private String name; + @ApiModelProperty("开始时间") + private Long startTime; + @ApiModelProperty("结束时间") + private Long endTime; + @ApiModelProperty("接口访问地址") + private String url; + @ApiModelProperty("模板code") + private String code; + @ApiModelProperty("用户列表") + private Set userIdList; + } + + @Data + @ApiModel("保存用户项目列表") + public static class SaveUserProject{ + @ApiModelProperty("项目id") + private List projectId; + @ApiModelProperty("用户id") + private List userId; + } +} diff --git a/cloudutil/src/main/java/com/ccsens/cloudutil/bean/tall/dto/TallTaskDto.java b/cloudutil/src/main/java/com/ccsens/cloudutil/bean/tall/dto/TallTaskDto.java new file mode 100644 index 0000000..392673b --- /dev/null +++ b/cloudutil/src/main/java/com/ccsens/cloudutil/bean/tall/dto/TallTaskDto.java @@ -0,0 +1,137 @@ +package com.ccsens.cloudutil.bean.tall.dto; + +import cn.hutool.core.util.ObjectUtil; +import com.ccsens.util.exception.BaseException; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.NonNull; + +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.NotNull; +import java.util.List; + +@Data +@ApiModel +public class TallTaskDto { + + @ApiModel + @Data + public static class AddTask { + @ApiModelProperty("关联项目Id") + private Long projectId; + @ApiModelProperty("关联的任务id(detailId)") + private Long parentTaskId; + @ApiModelProperty("任务名称") + @NotEmpty(message = "任务名不能为空") + private String taskName; + @ApiModelProperty("任务描述") + private String description; + @ApiModelProperty("负责人id") + @NotNull(message = "请选择负责人") + private Long executorId; + @ApiModelProperty("开始时间") + private Long beginTime; + @ApiModelProperty("结束时间") + private Long endTime; + @ApiModelProperty("重复周期") + private String cycle; + @ApiModelProperty("交付物") + private String taskDeliver; + @ApiModelProperty("插件") + private List pluginList; + @ApiModelProperty("优先级 3,紧急重要 2,紧急不重要 1,重要不紧急 0,不重要不紧急 默认0") + private Byte priority; + @ApiModelProperty("任务提醒消息") + private TaskRemindByAdd taskRemind; + @ApiModelProperty("token") + private String token; + } + + @Data + @ApiModel("添加时设置任务提醒") + public static class TaskRemindByAdd{ + @ApiModelProperty("提醒时机 0不提醒 1开始前,2开始时,3开始后,4结束前,5结束时,6结束后,7自定义时间") + private Byte remindTiming; + @ApiModelProperty("时长 提醒时机是“开始时”或“结束时”可以为空") + private Long duration = 0L; + @ApiModelProperty("时间单位 0分钟 1小时 2天") + private Byte unit; + + public Long getDuration(){ + if(ObjectUtil.isNull(unit)) { + throw new BaseException("时间单位不能为空"); + } + if(remindTiming == 7){ + return duration; + } + switch (unit) { + case 0: + return duration * 60 * 1000L; + case 1: + return duration * 60 * 60 * 1000L; + case 2: + return duration * 24 * 60 * 60 * 1000L; + default: + return duration; + } + } + } + + @Data + @ApiModel("修改任务详细信息") + public static class UpdateTaskInfo{ + @ApiModelProperty("任务id") + private Long id; + @ApiModelProperty("任务名") + private String name; + @ApiModelProperty("任务详情") + private String description; + @ApiModelProperty("负责人") + private Long executorRole; + @ApiModelProperty("任务开始时间") + private Long beginTime; + @ApiModelProperty("任务结束时间") + private Long endTime; + @ApiModelProperty("重复频率") + private String cycle; + @ApiModelProperty("任务奖惩") + private Long money; + @ApiModelProperty("任务切换模式,0时间到立刻切换 1延迟delay_time切换 2手动切换") + private int delay; + @ApiModelProperty("延迟切换时间") + private Long delayTime; + @ApiModelProperty("优先级 3,紧急重要 2,紧急不重要 1,重要不紧急 0,不重要不紧急 默认0") + private Byte priority; + @ApiModelProperty("是否是里程碑 0否 1是") + private Byte milestone; + @ApiModelProperty("需要修改的插件Id") + private List plugins; + @ApiModelProperty("token") + private String token; + } + + @Data + @ApiModel("修改插件配置") + public static class UpdatePluginConfig { + @NonNull + @ApiModelProperty("任务id") + private Long taskId; + @ApiModelProperty("任务插件id") + private Long taskPluginId; + @ApiModelProperty("页面接口路径") + private String webPath; + @ApiModelProperty("入参") + private String importParam; + @ApiModelProperty("放置位置 默认0 ,0任务名 1详情页 2任务下") + private Byte placeLocation; + @ApiModelProperty("程序位置 0:tall内部,1外部") + private Byte routineLocation; + @ApiModelProperty("token") + private String token; + + public UpdatePluginConfig() { + } + } + +} diff --git a/cloudutil/src/main/java/com/ccsens/cloudutil/bean/tall/dto/TaskDto.java b/cloudutil/src/main/java/com/ccsens/cloudutil/bean/tall/dto/TaskDto.java new file mode 100644 index 0000000..a14a036 --- /dev/null +++ b/cloudutil/src/main/java/com/ccsens/cloudutil/bean/tall/dto/TaskDto.java @@ -0,0 +1,42 @@ +package com.ccsens.cloudutil.bean.tall.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotNull; + +/** + * @description: + * @author: whj + * @time: 2021/6/3 10:10 + */ +public class TaskDto { + @ApiModel + @Data + public static class StartTask { + @ApiModelProperty("项目Id") + @NotNull(message = "projectId is required.") + private Long projectId; + @ApiModelProperty("角色Id") + @NotNull(message = "roleId is required.") + private Long roleId; + @ApiModelProperty("任务在当前时间的subTimeId") + @NotNull(message = "taskId is required.") + private Long taskId; + @ApiModelProperty("开始任务的时间 如果为空则为当前时间") + private Long startTime; + @ApiModelProperty("是否修改后续任务的时间(0否,1是)") + private Byte isUpdateTime = 0; + } + + @ApiModel + @Data + public static class TaskSubTimeId { + @ApiModelProperty("任务id") + private Long id; + @ApiModelProperty("任务完成状态0未完成 1进行中 2已完成") + private Integer completedStatus; + } + +} diff --git a/cloudutil/src/main/java/com/ccsens/cloudutil/bean/tall/dto/UserDto.java b/cloudutil/src/main/java/com/ccsens/cloudutil/bean/tall/dto/UserDto.java new file mode 100644 index 0000000..923f53e --- /dev/null +++ b/cloudutil/src/main/java/com/ccsens/cloudutil/bean/tall/dto/UserDto.java @@ -0,0 +1,28 @@ +package com.ccsens.cloudutil.bean.tall.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotEmpty; + +/** + * @description: + * @author: wuHuiJuan + * @create: 2019/12/05 10:22 + */ +public class UserDto { + //默认注册 + @Data + @ApiModel("UserDtoDefaultUserSingup") + public static class DefaultUserSingup{ + @ApiModelProperty("手机号") + @NotEmpty(message = "手机号不能为空") + private String phone; + @ApiModelProperty("账号") + @NotEmpty(message = "账号不能为空.") + private String account; + @ApiModelProperty("来源") + private byte source; + } +} diff --git a/cloudutil/src/main/java/com/ccsens/cloudutil/bean/tall/dto/WpsDto.java b/cloudutil/src/main/java/com/ccsens/cloudutil/bean/tall/dto/WpsDto.java new file mode 100644 index 0000000..c534640 --- /dev/null +++ b/cloudutil/src/main/java/com/ccsens/cloudutil/bean/tall/dto/WpsDto.java @@ -0,0 +1,62 @@ +package com.ccsens.cloudutil.bean.tall.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotNull; +import java.util.Map; + +@Data +public class WpsDto { + @Data + @ApiModel("业务和WPS") + public static class Business{ + @ApiModelProperty("业务ID") + private Long businessId; + @ApiModelProperty("wps文件ID") + private Long wpsFileId; + @ApiModelProperty("业务类型 0项目WBS 1交付物 2会议记录。后面是pims内的表:3产品依据表,4产品收入表,5成本表,6损益表,7现金流表") + private Byte businessType; + @ApiModelProperty("用户ID") + private Long userId; + @ApiModelProperty("文件名") + private String fileName; + @ApiModelProperty("文件路径,默认在WebConstant.UPLOAD_PATH_BASE下") + private String filePath; + @ApiModelProperty("文件实际存储路径") + private String realFilePath; + @ApiModelProperty("文件大小") + private Long fileSize; + @ApiModelProperty("操作类型 值:WebConstant Wps USER_OPERATION... ") + private byte operation; + @ApiModelProperty("操作权限 WebConstant Wps PROJECT_PRIVILEGE...") + private byte privilege; + @ApiModelProperty("操作权限查询路径") + private String privilegeQueryUrl; + } + + @Data + @ApiModel("查找wps文件路径") + public static class VisitWpsUrl{ + @NotNull + @ApiModelProperty("业务ID") + private Long businessId; + @NotNull + @ApiModelProperty("业务类型") + private byte businessType; + @NotNull + @ApiModelProperty("userId") + private Long userId; + @ApiModelProperty("访问路径") + private Map params; + } + + @Data + @ApiModel("异步通知") + public static class Async{ + @ApiModelProperty("文件ID") + private Long fileId; + } + +} diff --git a/cloudutil/src/main/java/com/ccsens/cloudutil/bean/tall/vo/HolidaysVo.java b/cloudutil/src/main/java/com/ccsens/cloudutil/bean/tall/vo/HolidaysVo.java new file mode 100644 index 0000000..71d78bc --- /dev/null +++ b/cloudutil/src/main/java/com/ccsens/cloudutil/bean/tall/vo/HolidaysVo.java @@ -0,0 +1,18 @@ +package com.ccsens.cloudutil.bean.tall.vo; + +import lombok.Data; + +import java.util.List; + +/** + * @author 逗 + */ +@Data +public class HolidaysVo { + + @Data + public static class Holidays{ + private List workday; + private List nonWorkday; + } +} diff --git a/cloudutil/src/main/java/com/ccsens/cloudutil/bean/tall/vo/MemberVo.java b/cloudutil/src/main/java/com/ccsens/cloudutil/bean/tall/vo/MemberVo.java new file mode 100644 index 0000000..96713c8 --- /dev/null +++ b/cloudutil/src/main/java/com/ccsens/cloudutil/bean/tall/vo/MemberVo.java @@ -0,0 +1,57 @@ +package com.ccsens.cloudutil.bean.tall.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +@Data +public class MemberVo { + + @Data + public static class MemberInfo{ + private Long id; + private Long userId; + private Long projectId; + private String nickname; + private String avatarUrl; + private Integer no; + private String phone; + private String description; + private Long joinTime; + private Long stakeholderId; + } + + @Data + @ApiModel("角色信息") + public static class RoleInfo{ + @ApiModelProperty("角色id") + private Long roleId; + @ApiModelProperty("角色名") + private String roleName; + } + + @Data + @ApiModel("添加时返回成员信息") + public static class Member{ + @ApiModelProperty("成员id") + private Long memberId; + @ApiModelProperty("成员名") + private String memberName; + @ApiModelProperty("手机号") + private String phone; + @ApiModelProperty("userId") + private Long userId; + } + + + @Data + @ApiModel("查找项目内所有的成员") + public static class MemberList{ + @ApiModelProperty("成员id") + private Long memberId; + @ApiModelProperty("成员名") + private String memberName; + @ApiModelProperty("userId") + private Long userId; + } +} diff --git a/cloudutil/src/main/java/com/ccsens/cloudutil/bean/tall/vo/PluginVo.java b/cloudutil/src/main/java/com/ccsens/cloudutil/bean/tall/vo/PluginVo.java new file mode 100644 index 0000000..cbca119 --- /dev/null +++ b/cloudutil/src/main/java/com/ccsens/cloudutil/bean/tall/vo/PluginVo.java @@ -0,0 +1,28 @@ +package com.ccsens.cloudutil.bean.tall.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +@Data +public class PluginVo { + + @ApiModel + @Data + public static class PluginSignField{ + @ApiModelProperty("变量名") + private String name; + @ApiModelProperty("展示名") + private String description; + @ApiModelProperty("类型 0文本 1文本框 2单选 3多选") + private int type; + @ApiModelProperty("类型值(文本,单选,多选,展示的内容 例:{\"1\":\"男\",\"2\":\"女\"},)") + private String fieldValue; + @ApiModelProperty("正则表达式") + private String format; + @ApiModelProperty("是否必填") + private int isRequired; + @ApiModelProperty("是否支持模糊查询") + private int isFuzzy; + } +} diff --git a/cloudutil/src/main/java/com/ccsens/cloudutil/bean/tall/vo/ProjectVo.java b/cloudutil/src/main/java/com/ccsens/cloudutil/bean/tall/vo/ProjectVo.java new file mode 100644 index 0000000..60c67f8 --- /dev/null +++ b/cloudutil/src/main/java/com/ccsens/cloudutil/bean/tall/vo/ProjectVo.java @@ -0,0 +1,46 @@ +package com.ccsens.cloudutil.bean.tall.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +/** + * @author AUSU + */ +@Data +public class ProjectVo { + + @Data + @ApiModel("复制的项目信息") + public static class ProjectInfo{ + @ApiModelProperty("项目id") + private Long id; + @ApiModelProperty("任务详情") + private List taskDetails; + } + @Data + @ApiModel("任务详情") + public static class TaskDetail{ + @ApiModelProperty("任务详情id") + private Long taskDetailId; + @ApiModelProperty("任务详情名称") + private String taskDetailName; + @ApiModelProperty("任务等级") + private Byte taskDetailLevel; + @ApiModelProperty("任务详情下的分解任务") + private List taskSubList; + } + @Data + @ApiModel("分解任务") + public static class TaskSub{ + @ApiModelProperty("分解任务id") + private Long taskSubId; + @ApiModelProperty("分解任务开始时间") + private Long startTime; + @ApiModelProperty("分解任务结束时间") + private Long endTime; + } + +} diff --git a/cloudutil/src/main/java/com/ccsens/cloudutil/bean/tall/vo/TaskVo.java b/cloudutil/src/main/java/com/ccsens/cloudutil/bean/tall/vo/TaskVo.java new file mode 100644 index 0000000..b90bc85 --- /dev/null +++ b/cloudutil/src/main/java/com/ccsens/cloudutil/bean/tall/vo/TaskVo.java @@ -0,0 +1,124 @@ +package com.ccsens.cloudutil.bean.tall.vo; + +import cn.hutool.core.util.ObjectUtil; +import com.fasterxml.jackson.annotation.JsonIgnore; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; +import java.util.List; + +@Data +public class TaskVo { + @Data + public static class TaskInfoWithFeign{ + private Long id; + private String name; + private Long projectId; + private String projectName; + } + + @ApiModel + @Data + public static class NormalTask{ + @ApiModelProperty("任务详细信息id") + private Long detailId; + @ApiModelProperty("当前任务的时间段id") + private Long id; + @ApiModelProperty("名称") + private String name; + @ApiModelProperty("详细描述") + private String description; + @ApiModelProperty("父任务名称") + private String parentName; + @ApiModelProperty("所属项目id") + private Long projectId; + @ApiModelProperty("所属项目名称") + private String projectName; + @ApiModelProperty("负责人Id") + private Long executorRole; + @ApiModelProperty("负责人名称") + private String executorRoleName; + @ApiModelProperty("开始时间") + private Long beginTime; + @ApiModelProperty("结束时间") + private Long endTime; + @ApiModelProperty("时长") + private Long duration; + @ApiModelProperty("循环周期") + private String cycle; + @ApiModelProperty("跳转模式 0自动,1延迟,2手动") + private int delay; + @ApiModelProperty("实际开始时间") + private Long realBeginTime; + @ApiModelProperty("实际结束时间") + private Long realEndTime; + @ApiModelProperty("跳转结束时间") + private Long loopEndTime; + @ApiModelProperty("跳转的任务id") + private Long loopTo; + @ApiModelProperty("执行时间") + private Long execTimes; + @ApiModelProperty("奖惩") + private BigDecimal money; + @ApiModelProperty("状态:0-未开始,1-进行中,2-已完成") + private int process; + @ApiModelProperty("子项目id") + private Long subProjectId; + @ApiModelProperty("子项目名字") + private String subProjectName; + @ApiModelProperty("服务器时间") + private Long serverTime; + @ApiModelProperty("任务类型 0普通任务 1虚拟任务") + private int virtual; + @ApiModelProperty("有无分组") + private int hasGroup; + @ApiModelProperty("分数") + private BigDecimal score; + @ApiModelProperty("插件") + private List plugins; + @ApiModelProperty("二级任务") + private List secondTasks; + @ApiModelProperty("时间状态 0:正常 1:任务开始 2:任务结束") + private Byte timeStatus = 0; + @ApiModelProperty("当前周期内任务的序号") + private int sequence; + @ApiModelProperty("页面/接口路径") + private String webPath; + @ApiModelProperty("程序位置 0:tall内部,1外部") + private Byte routineLocation; + @ApiModelProperty("入参") + private String importParam; + public Long getDuration(){ + if(ObjectUtil.isNotNull(beginTime) && ObjectUtil.isNotNull(endTime)) { + return endTime - beginTime; + } + return null; + } + + public Long getServerTime(){ + return System.currentTimeMillis(); + } + + } + + @ApiModel + @Data + public static class PluginVo{ + @ApiModelProperty("插件id") + private String id; + @ApiModelProperty("插件名") + private String name; + @ApiModelProperty("插件描述") + private String description; + @ApiModelProperty("显示分类") + private String showType; + @ApiModelProperty("页面/接口路径") + private String webPath; + @ApiModelProperty("程序位置 0:tall内部,1外部") + private Byte routineLocation; + @ApiModelProperty("入参") + private String importParam; + } +} diff --git a/cloudutil/src/main/java/com/ccsens/cloudutil/bean/tall/vo/UserVo.java b/cloudutil/src/main/java/com/ccsens/cloudutil/bean/tall/vo/UserVo.java new file mode 100644 index 0000000..f3a154f --- /dev/null +++ b/cloudutil/src/main/java/com/ccsens/cloudutil/bean/tall/vo/UserVo.java @@ -0,0 +1,20 @@ +package com.ccsens.cloudutil.bean.tall.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @description: + * @author: wuHuiJuan + * @create: 2019/12/05 10:22 + */ +public class UserVo { + //默认注册 + @Data + @ApiModel("UserVoDefaultUserSingup") + public static class DefaultUserSingup{ + @ApiModelProperty("用户ID") + private Long id; + } +} diff --git a/cloudutil/src/main/java/com/ccsens/cloudutil/bean/tall/vo/WpsVo.java b/cloudutil/src/main/java/com/ccsens/cloudutil/bean/tall/vo/WpsVo.java new file mode 100644 index 0000000..297387e --- /dev/null +++ b/cloudutil/src/main/java/com/ccsens/cloudutil/bean/tall/vo/WpsVo.java @@ -0,0 +1,15 @@ +package com.ccsens.cloudutil.bean.tall.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +@Data +public class WpsVo { + @Data + public static class BusinessFileIdAndPath{ + @ApiModelProperty("业务id") + private Long businessId; + @ApiModelProperty("文件路径") + private String filePath; + } +} diff --git a/cloudutil/src/main/java/com/ccsens/cloudutil/config/FeignConfig.java b/cloudutil/src/main/java/com/ccsens/cloudutil/config/FeignConfig.java new file mode 100644 index 0000000..0ac387f --- /dev/null +++ b/cloudutil/src/main/java/com/ccsens/cloudutil/config/FeignConfig.java @@ -0,0 +1,55 @@ +//package com.ccsens.cloudutil.config; +// +//import com.fasterxml.jackson.databind.DeserializationFeature; +//import com.fasterxml.jackson.databind.ObjectMapper; +//import com.fasterxml.jackson.databind.module.SimpleModule; +//import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +//import feign.codec.Decoder; +//import feign.codec.Encoder; +//import feign.form.spring.SpringFormEncoder; +//import org.springframework.beans.factory.ObjectFactory; +//import org.springframework.beans.factory.annotation.Autowired; +//import org.springframework.boot.autoconfigure.http.HttpMessageConverters; +//import org.springframework.cloud.openfeign.support.ResponseEntityDecoder; +//import org.springframework.cloud.openfeign.support.SpringDecoder; +//import org.springframework.cloud.openfeign.support.SpringEncoder; +//import org.springframework.context.annotation.Bean; +//import org.springframework.context.annotation.Configuration; +//import org.springframework.http.MediaType; +//import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; +// +//import java.util.ArrayList; +//import java.util.List; +// +///** +// * @description: +// * @author: wuHuiJuan +// * @create: 2019/12/09 15:27 +// */ +//@Configuration +//public class FeignConfig { +// +// @Autowired +// private ObjectFactory messageConverters; +// +// @Bean +// public Encoder feignFormEncoder() { +// return new SpringFormEncoder(new SpringEncoder(messageConverters)); +// } +// +// @Bean +// public Decoder feignDecoder() { +// return new ResponseEntityDecoder(new SpringDecoder(() -> { +// MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter(); +// List mediaTypeList = new ArrayList<>(); +// mediaTypeList.add(MediaType.TEXT_HTML); +// mediaTypeList.add(MediaType.APPLICATION_JSON_UTF8); +// converter.setSupportedMediaTypes(mediaTypeList); +// +// ObjectMapper objectMapper = new ObjectMapper(); +// objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); +// converter.setObjectMapper(objectMapper); return new HttpMessageConverters(converter); +// })); +// } +// +//} diff --git a/cloudutil/src/main/java/com/ccsens/cloudutil/config/FeignTokenConfig.java b/cloudutil/src/main/java/com/ccsens/cloudutil/config/FeignTokenConfig.java new file mode 100644 index 0000000..6590f50 --- /dev/null +++ b/cloudutil/src/main/java/com/ccsens/cloudutil/config/FeignTokenConfig.java @@ -0,0 +1,45 @@ +package com.ccsens.cloudutil.config; + +import cn.hutool.json.JSONObject; +import cn.hutool.json.JSONUtil; +import feign.RequestInterceptor; +import feign.RequestTemplate; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.HttpHeaders; +import org.springframework.stereotype.Component; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; + +import javax.servlet.http.HttpServletRequest; + + +/** + * @author 逗 + */ +@Configuration +public class FeignTokenConfig implements RequestInterceptor { + @Override + public void apply(RequestTemplate template) { + ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); + System.out.println("attributes:"+attributes); + if (attributes != null) { + HttpServletRequest request = attributes.getRequest(); + System.out.println("token:" + request.getHeader(HttpHeaders.AUTHORIZATION)); + //添加token + template.header(HttpHeaders.AUTHORIZATION, request.getHeader(HttpHeaders.AUTHORIZATION)); + return; + } + + byte[] body = template.body(); + if (body == null) { + return; + } + String json = new String(body); + JSONObject jsonObject = JSONUtil.parseObj(json); + + //添加token + template.header("Authorization", jsonObject.getStr("token")); + + + } +} diff --git a/cloudutil/src/main/java/com/ccsens/cloudutil/feign/HealthFeignClient.java b/cloudutil/src/main/java/com/ccsens/cloudutil/feign/HealthFeignClient.java new file mode 100644 index 0000000..f9dc106 --- /dev/null +++ b/cloudutil/src/main/java/com/ccsens/cloudutil/feign/HealthFeignClient.java @@ -0,0 +1,41 @@ +package com.ccsens.cloudutil.feign; + +import feign.hystrix.FallbackFactory; +import lombok.extern.slf4j.Slf4j; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.stereotype.Component; +import org.springframework.util.StringUtils; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestParam; + +@FeignClient(name = "health", path = "", fallbackFactory = HealthFeignClientFallBack.class) +public interface HealthFeignClient { + /** + * 获取suiteAccessToken + * @param suiteId + * @return + */ + @GetMapping("getSuiteAccessToken") + String getSuiteAccessToken(@RequestParam(name = "suiteId") String suiteId); + + +} + + +@Slf4j +@Component +class HealthFeignClientFallBack implements FallbackFactory { + @Override + public HealthFeignClient create(Throwable throwable) { + String msg = throwable == null ? "" : throwable.getMessage(); + if (!StringUtils.isEmpty(msg)) { + log.error(msg); + } + return new HealthFeignClient() { + @Override + public String getSuiteAccessToken(String suiteId) { + return null; + } + }; + } +} diff --git a/cloudutil/src/main/java/com/ccsens/cloudutil/feign/MtFeignClient.java b/cloudutil/src/main/java/com/ccsens/cloudutil/feign/MtFeignClient.java new file mode 100644 index 0000000..bec8128 --- /dev/null +++ b/cloudutil/src/main/java/com/ccsens/cloudutil/feign/MtFeignClient.java @@ -0,0 +1,68 @@ +package com.ccsens.cloudutil.feign; + +import com.ccsens.cloudutil.bean.QueryParam; +import com.ccsens.cloudutil.bean.tall.dto.LogDto; +import com.ccsens.cloudutil.bean.tall.dto.MemberRoleDto; +import com.ccsens.cloudutil.bean.tall.dto.UserDto; +import com.ccsens.cloudutil.bean.tall.vo.MemberVo; +import com.ccsens.cloudutil.bean.tall.vo.PluginVo; +import com.ccsens.cloudutil.bean.tall.vo.TaskVo; +import com.ccsens.util.JsonResponse; +import feign.hystrix.FallbackFactory; +import lombok.extern.slf4j.Slf4j; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.stereotype.Component; +import org.springframework.util.StringUtils; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestParam; + +import java.math.BigDecimal; +import java.util.List; + +@FeignClient(name = "mt", path = "", fallbackFactory = MtFeignClientFallBack.class) +public interface MtFeignClient { + /** + * 普通成员获取自己对任务的评分 + * @param taskId + * @param userId + * @return + */ + @GetMapping("plugins/memberScore") + BigDecimal getMemberScore(@RequestParam(name = "taskId")Long taskId, @RequestParam(name = "userId")Long userId); + + /** + * 项目经理获取任务的平均分 + * @param projectId + * @param taskId + * @return + */ + @GetMapping("plugins/adminScore") + BigDecimal getAdminScore(@RequestParam(name = "projectId")Long projectId, @RequestParam(name = "taskId")Long taskId); + +} + + +@Slf4j +@Component +class MtFeignClientFallBack implements FallbackFactory { + @Override + public MtFeignClient create(Throwable throwable) { + String msg = throwable == null ? "" : throwable.getMessage(); + if (!StringUtils.isEmpty(msg)) { + log.error(msg); + } + return new MtFeignClient() { + @Override + public BigDecimal getMemberScore(Long taskId,Long userId) { + return null; + } + + @Override + public BigDecimal getAdminScore(Long projectId,Long taskId) { + return null; + } + + }; + } +} diff --git a/cloudutil/src/main/java/com/ccsens/cloudutil/feign/Tall3FeignClient.java b/cloudutil/src/main/java/com/ccsens/cloudutil/feign/Tall3FeignClient.java new file mode 100644 index 0000000..5920234 --- /dev/null +++ b/cloudutil/src/main/java/com/ccsens/cloudutil/feign/Tall3FeignClient.java @@ -0,0 +1,113 @@ +package com.ccsens.cloudutil.feign; + +import com.ccsens.cloudutil.bean.tall.dto.HolidaysDto; +import com.ccsens.cloudutil.bean.tall.dto.LogDto; +import com.ccsens.cloudutil.bean.tall.dto.ProjectDto; +import com.ccsens.cloudutil.bean.tall.vo.HolidaysVo; +import com.ccsens.cloudutil.config.FeignTokenConfig; +import com.ccsens.util.JsonResponse; +import feign.hystrix.FallbackFactory; +import lombok.extern.slf4j.Slf4j; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.stereotype.Component; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; + +/** + * @author 逗 + */ +@FeignClient(name = "tall3", path = "v3.0",fallbackFactory = Tall3FeignClientFallBack.class,configuration = FeignTokenConfig.class) +public interface Tall3FeignClient { + /** + * 根据token获取userId + * + * @param token + * @return + */ + @GetMapping("users/token") + JsonResponse getUserIdByToken(@RequestParam(required = true, name = "token") String token); + + /** + * 记录操作日志 + * + * @param logDto + * @return + */ + @RequestMapping("/log/operation") + JsonResponse log(LogDto logDto); + + /** + * 在tall3内保存项目信息 + */ + @RequestMapping("project/save") + JsonResponse saveProjectList(ProjectDto.SaveProjectDto projectDto); + + /** + * tall3内保存用户项目列表 + */ + @RequestMapping("project/saveUserProject") + JsonResponse saveUserProject(ProjectDto.SaveUserProject projectDto); + + /** + * tall3内保存用户项目列表 + */ + @RequestMapping("holidays") + JsonResponse getHolidays(HolidaysDto.GetHolidays getHolidays); + + /** + * 根据手机号查找userId + */ + @GetMapping("/project/businessDeleteProject") + JsonResponse businessDeleteProject(@RequestParam(name = "projectId")Long projectId); + + /** + * 根据手机号查找userId + */ + @GetMapping("/users/userIdByPhone") + JsonResponse getUserIdByPhone(@RequestParam(name = "phone")String phone); +} + +@Slf4j +@Component +class Tall3FeignClientFallBack implements FallbackFactory { + + @Override + public Tall3FeignClient create(Throwable cause) { + log.error("访问tall3异常", cause); + return new Tall3FeignClient() { + @Override + public JsonResponse getUserIdByToken(String token) { + return null; + } + @Override + public JsonResponse log(LogDto logDto) { + return null; + } + + @Override + public JsonResponse saveProjectList(ProjectDto.SaveProjectDto projectDto) { + return null; + } + + @Override + public JsonResponse saveUserProject(ProjectDto.SaveUserProject projectDto) { + return null; + } + + @Override + public JsonResponse getHolidays(HolidaysDto.GetHolidays getHolidays) { + return JsonResponse.newInstance().fail(); + } + @Override + public JsonResponse businessDeleteProject(Long projectId) { + return JsonResponse.newInstance().fail(); + } + @Override + public JsonResponse getUserIdByPhone(String phone) { + return JsonResponse.newInstance().fail(); + } + + }; + } +} \ No newline at end of file diff --git a/cloudutil/src/main/java/com/ccsens/cloudutil/feign/TallFeignClient.java b/cloudutil/src/main/java/com/ccsens/cloudutil/feign/TallFeignClient.java new file mode 100644 index 0000000..edc38ca --- /dev/null +++ b/cloudutil/src/main/java/com/ccsens/cloudutil/feign/TallFeignClient.java @@ -0,0 +1,477 @@ +package com.ccsens.cloudutil.feign; + +import com.ccsens.cloudutil.bean.QueryParam; +import com.ccsens.cloudutil.bean.tall.dto.*; +import com.ccsens.cloudutil.bean.tall.vo.*; +import com.ccsens.cloudutil.config.FeignTokenConfig; +import com.ccsens.util.JsonResponse; +import com.ccsens.util.bean.dto.QueryDto; +import feign.hystrix.FallbackFactory; +import lombok.extern.slf4j.Slf4j; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.stereotype.Component; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * @description: + * @author: wuHuiJuan + * @create: 2019/11/27 10:03 + */ + +@FeignClient(name = "tall", path = "v1.0",fallbackFactory = TallFeignClientFallBack.class,configuration = FeignTokenConfig.class) +public interface TallFeignClient { + + /** + * 输入两个userid将两个账号合并(保留企业用户的id) + * @param userId 需要保存的userid + * @param uselessId 不需要保存的userid + * @return + */ + @GetMapping("/users/mergeUserId") + JsonResponse mergeUserId(@RequestParam(required = true, name = "userId") Long userId,@RequestParam(required = true, name = "uselessId") Long uselessId); + + /** + * 获取 + * + * @param map + * @return + */ + @PostMapping("/getPort") + String get(QueryParam map); + + /** + * 注册用户 + * + * @param signup + * @return + */ + @PostMapping("/defaultRegister") + JsonResponse defaultRegister(UserDto.DefaultUserSingup signup); + + /** + * 为用户分配角色 + * + * @param assign + * @return + */ + @RequestMapping("assignRoles") + JsonResponse assignRoles(MemberRoleDto.Assign assign); + + /** + * 为用户删除角色 + * + * @param deleteDto + * @return + */ + @RequestMapping("deleteRoles") + JsonResponse deleteRoles(MemberRoleDto.Delete deleteDto); + + /** + * 根据token获取userId + * + * @param token + * @return + */ + @GetMapping("users/token") + JsonResponse getUserIdByToken(@RequestParam(required = true, name = "token") String token); + + /** + * 记录操作日志 + * + * @param logDto + * @return + */ + @RequestMapping("/log/operation") + JsonResponse log(LogDto logDto); + + /** + * 通过任务id获得任务信息 + * + * @param taskId + * @return + */ + @GetMapping("/tasks/projectId") + TaskVo.TaskInfoWithFeign getProjectId(@RequestParam(name = "taskId") Long taskId); + + /** + * 查询该用户在项目中的member信息 + * + * @return + */ + @GetMapping("/users/member") + JsonResponse getMemberByUserId(@RequestParam(name = "userId") Long userId, @RequestParam(name = "projectId") Long projectId); + + /** + * 当用户不在项目中时查询该用户信息 + * + * @return + */ + @GetMapping("/users/getUserInfo") + JsonResponse getUserByUserId(@RequestParam(name = "userId") Long userId); + + + /** + * 获取项目下的所有成员id + * + * @param projectId + * @return + */ + @GetMapping("/users/allMemberAll") + List getMemberIdListByProject(@RequestParam(name = "projectId") Long projectId); + + /** + * 通过token获得userId(消息系统用) + * + * @param token + * @return + */ + @GetMapping("/users/claims") + String getUserId(@RequestParam(name = "token") String token); + + /** + * 通过插件id获取签到字段和详细信息 + */ + @GetMapping("/plugins/sign") + List getSignFieldByTaskPluginId(@RequestParam(name = "taskPluginId") Long taskPluginId); + + /** + * 模糊查询 + */ + @GetMapping("/plugins/fuzzy") + List getSignFuzzy(@RequestParam(name = "taskPluginId") Long taskPluginId, @RequestParam(name = "signinName") String signinName, @RequestParam(name = "key") String key); + + /** + * 通过插件id获取签到字段和详细信息 + */ + @GetMapping("/plugins/task") + Long getTaskIdByTaskPluginId(@RequestParam(name = "taskPluginId") Long taskPluginId); + + /** + * 保存WPS业务和文件记录 + */ + @RequestMapping("/wps/saveWps") + JsonResponse saveWpsFile(WpsDto.Business business); + + /** + * 查询WPS业务和文件记录 + */ + @RequestMapping("/wps/visitUrls") + List queryVisitUrls(WpsDto.VisitWpsUrl visitWpsUrl); + + /** + * 根据wpsId查询wps文件路径 + */ + @GetMapping("/wps/wpsId") + JsonResponse getPathByWpsId(@RequestParam(name = "wpsId")Long wpsId); + /** + * 根据手机号查找userId + */ + @GetMapping("/users/userIdByPhone") + JsonResponse getUserIdByPhone(@RequestParam(name = "phone")String phone); + /** + * 查找wps文件路径 + */ + @GetMapping("/v1/3rd/getFilePath") + String getWpsFilePath(@RequestParam(name = "businessId") Long businessId,@RequestParam(name = "businessType") byte businessType); + + /** + * 通过userId呵taskId查找用户信息 + */ + @GetMapping("/users/memberByTask") + JsonResponse getMemberInfoByUserIdAndTaskId(@RequestParam(name = "userId") Long userId,@RequestParam(name = "taskId") Long taskId); + + + /** + * 添加任务 + */ + @RequestMapping("/tasks") + JsonResponse saveTask(TallTaskDto.AddTask addTask); + + /** + * 修改任务 + */ + @RequestMapping("/tasks/change") + JsonResponse updataTask(TallTaskDto.UpdateTaskInfo updateTaskInfo); + + /** + * 完成任务 + */ + @RequestMapping("/tasks/finish") + JsonResponse finishTask(TaskDto.TaskSubTimeId task); + /** + * 删除任务 + */ + @DeleteMapping("/tasks") + JsonResponse deleteTask(@RequestParam(name = "taskId") Long taskId); + + /** + * 修改任务插件配置 + */ + @RequestMapping("/plugins/config") + JsonResponse updatePluginConfig(TallTaskDto.UpdatePluginConfig updatePluginConfig); + + /** + * 添加角色 + */ + @RequestMapping("/roles/save") + JsonResponse saveRole(MemberRoleDto.SaveRole saveRole); + + /** + * 添加成员 + */ + @RequestMapping("/members/save") + JsonResponse saveMember(MemberRoleDto.SaveMember saveMember); + + /** + * 将成员添加至角色内 + */ + @RequestMapping("/roles/saveMember") + JsonResponse saveMemberInRole(MemberRoleDto.SaveMemberInRole saveMember); + /** + * 将成员从角色内删除 + */ + @RequestMapping("/roles/deleteMember") + JsonResponse deleteMemberInRole(MemberRoleDto.SaveMemberInRole saveMember); + + + /** + * 通过手机号和项目id查询成员信息 + */ + @RequestMapping("/members/query/memberByPhone") + JsonResponse queryMemberByPhone(MemberRoleDto.GetMemberByPhone getMemberByPhone); + + /** + * 删除角色 + */ + @RequestMapping("/roles/delete") + JsonResponse deleteRole(MemberRoleDto.DeleteRole deleteRole); + + /** + * 根据项目模板复制项目 + * @param copyProject 项目id + * @return 项目 + */ + @RequestMapping(value = "/projects/copyProject",method = RequestMethod.POST,produces = {"application/json;charset=UTF-8"}) + JsonResponse copyProjectNew(QueryDto copyProject); + + /** + * 给复制后的模板项目添加成员 + * @param memberForTemplate 项目id和成员 + * @return 成功/失败 + */ + @RequestMapping(value = "/members/addMemberForTemplate",method = RequestMethod.POST,produces = {"application/json;charset=UTF-8"}) + JsonResponse addMemberForTemplate(QueryDto memberForTemplate); + + /** + * 开始节点 + * @param param 时间 + * @return 结果 + * @throws Exception + */ + @RequestMapping(value = "/tasks/start", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) + JsonResponse startNode(TaskDto.StartTask param) throws Exception; + + + /** + * 在tall3内保存项目信息 + */ + @RequestMapping("/project/save") + JsonResponse saveProjectList(ProjectDto.SaveProjectDto projectDto); +} + +@Slf4j +@Component +class TallFeignClientFallBack implements FallbackFactory { + + @Override + public TallFeignClient create(Throwable throwable) { + log.error("yichang", throwable); + return new TallFeignClient() { + @Override + public JsonResponse mergeUserId(Long userId, Long uselessId) { + return JsonResponse.newInstance().fail(); + } + + @Override + public String get(QueryParam map) { + return "hello world"; + } + + @Override + public JsonResponse defaultRegister(UserDto.DefaultUserSingup signup) { + return JsonResponse.newInstance().fail(); + } + + @Override + public JsonResponse assignRoles(MemberRoleDto.Assign assign) { + return JsonResponse.newInstance().fail(); + } + + @Override + public JsonResponse deleteRoles(MemberRoleDto.Delete deleteDto) { + return JsonResponse.newInstance().fail(); + } + + @Override + public JsonResponse getUserIdByToken(String token) { + return JsonResponse.newInstance().fail(); + } + + @Override + public JsonResponse log(LogDto logDto) { + return JsonResponse.newInstance().fail(); + } + + @Override + public TaskVo.TaskInfoWithFeign getProjectId(Long taskId) { + return null; + } + + @Override + public JsonResponse getMemberByUserId(Long userId, Long projectId) { + return JsonResponse.newInstance().fail(); + } + + @Override + public JsonResponse getUserByUserId(Long userId) { + return JsonResponse.newInstance().fail(); + } + + @Override + public List getMemberIdListByProject(Long projectId) { + return null; + } + + @Override + public String getUserId(String token) { + return null; + } + + @Override + public List getSignFieldByTaskPluginId(Long taskPluginId) { + return null; + } + + @Override + public List getSignFuzzy(Long taskPluginId, String signinName, String key) { + return null; + } + + @Override + public Long getTaskIdByTaskPluginId(Long taskPluginId) { + return null; + } + + @Override + public JsonResponse saveWpsFile(WpsDto.Business business) { + return JsonResponse.newInstance().fail(); + } + + @Override + public List queryVisitUrls(WpsDto.VisitWpsUrl visitWpsUrl) { + return null; + } + + @Override + public JsonResponse getPathByWpsId(Long async) { + return JsonResponse.newInstance().fail(); + } + + @Override + public JsonResponse getUserIdByPhone(String phone) { + return JsonResponse.newInstance().fail(); + } + + @Override + public String getWpsFilePath(Long businessId, byte businessType) { + return null; + } + + @Override + public JsonResponse getMemberInfoByUserIdAndTaskId(Long userId, Long taskId) { + return JsonResponse.newInstance().fail(); + } + + @Override + public JsonResponse saveTask(TallTaskDto.AddTask addTask) { + return JsonResponse.newInstance().fail(); + } + + @Override + public JsonResponse updataTask(TallTaskDto.UpdateTaskInfo updateTaskInfo) { + return JsonResponse.newInstance().fail(); + } + + @Override + public JsonResponse finishTask(TaskDto.TaskSubTimeId task) { + return JsonResponse.newInstance().fail(); + } + + @Override + public JsonResponse deleteTask(Long taskId) { + return JsonResponse.newInstance().fail(); + } + + @Override + public JsonResponse updatePluginConfig(TallTaskDto.UpdatePluginConfig updatePluginConfig) { + return JsonResponse.newInstance().fail(); + } + + @Override + public JsonResponse saveRole(MemberRoleDto.SaveRole saveRole) { + return JsonResponse.newInstance().fail(); + } + + @Override + public JsonResponse saveMember(MemberRoleDto.SaveMember saveMember) { + return JsonResponse.newInstance().fail(); + } + + @Override + public JsonResponse saveMemberInRole(MemberRoleDto.SaveMemberInRole saveMember) { + return JsonResponse.newInstance().fail(); + } + + @Override + public JsonResponse deleteMemberInRole(MemberRoleDto.SaveMemberInRole saveMember) { + return JsonResponse.newInstance().fail(); + } + + @Override + public JsonResponse queryMemberByPhone(MemberRoleDto.GetMemberByPhone getMemberByPhone) { + return JsonResponse.newInstance().fail(); + } + + @Override + public JsonResponse deleteRole(MemberRoleDto.DeleteRole deleteRole) { + return JsonResponse.newInstance().fail(); + } + + @Override + public JsonResponse copyProjectNew(QueryDto copyProject) { + return JsonResponse.newInstance().fail(); + } + + + + + @Override + public JsonResponse addMemberForTemplate(QueryDto memberForTemplate) { + return JsonResponse.newInstance().fail(); + } + + @Override + public JsonResponse startNode(TaskDto.StartTask param) throws Exception { + return JsonResponse.newInstance().fail(); + } + + @Override + public JsonResponse saveProjectList(ProjectDto.SaveProjectDto projectDto) { + return JsonResponse.newInstance().fail(); + } + }; + } + +} diff --git a/cloudutil/src/main/java/com/ccsens/cloudutil/interceptor/LogInterceptor.java b/cloudutil/src/main/java/com/ccsens/cloudutil/interceptor/LogInterceptor.java new file mode 100644 index 0000000..248468c --- /dev/null +++ b/cloudutil/src/main/java/com/ccsens/cloudutil/interceptor/LogInterceptor.java @@ -0,0 +1,31 @@ +package com.ccsens.cloudutil.interceptor; + +import org.springframework.web.servlet.HandlerInterceptor; +import org.springframework.web.servlet.ModelAndView; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +/** + * @description: + * @author: wuHuiJuan + * @create: 2019/12/09 18:24 + */ +public class LogInterceptor implements HandlerInterceptor { + @Override + public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { + //路径 + String path = request.getContextPath(); + return false; + } + + @Override + public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception { + + } + + @Override + public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception { + + } +} diff --git a/cloudutil/src/main/java/com/ccsens/cloudutil/ribbon/RibbonClientConfig.java b/cloudutil/src/main/java/com/ccsens/cloudutil/ribbon/RibbonClientConfig.java new file mode 100644 index 0000000..9fa61f1 --- /dev/null +++ b/cloudutil/src/main/java/com/ccsens/cloudutil/ribbon/RibbonClientConfig.java @@ -0,0 +1,15 @@ +package com.ccsens.cloudutil.ribbon; + +import org.springframework.cloud.netflix.ribbon.RibbonClient; +import org.springframework.cloud.netflix.ribbon.RibbonClients; +import org.springframework.context.annotation.Configuration; + +/** + * @description: + * @author: wuHuiJuan + * @create: 2019/11/26 12:11 + */ +@Configuration +@RibbonClient(name="${spring.application.name}", configuration = RibbonConfiguration.class) +public class RibbonClientConfig { +} diff --git a/cloudutil/src/main/java/com/ccsens/cloudutil/ribbon/RibbonConfiguration.java b/cloudutil/src/main/java/com/ccsens/cloudutil/ribbon/RibbonConfiguration.java new file mode 100644 index 0000000..0de727d --- /dev/null +++ b/cloudutil/src/main/java/com/ccsens/cloudutil/ribbon/RibbonConfiguration.java @@ -0,0 +1,43 @@ +package com.ccsens.cloudutil.ribbon; + +import com.netflix.loadbalancer.IRule; +import com.netflix.loadbalancer.RoundRobinRule; +import com.netflix.loadbalancer.WeightedResponseTimeRule; +import org.springframework.cloud.netflix.ribbon.RibbonClient; +import org.springframework.cloud.netflix.ribbon.RibbonClients; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * @description: 负载均衡 + * @author: wuHuiJuan + * @create: 2019/11/26 12:04 + */ +@Configuration +public class RibbonConfiguration { + /**根据响应时间加权,响应时间越长,权重越小,被选中的可能性越低*/ +// @Bean +// public IRule weightedResponseTimeRule() { +// return new WeightedResponseTimeRule(); +// } + + /**轮询*/ + @Bean + public IRule roundRobinRule(){ + return new RoundRobinRule(); + } + + + /* + 负载均衡机制 ,也可以自定义 + AvailabilityFilteringRule:过滤掉一直连接失败的被标记为circuit tripped的后端Server,并过滤掉那些高并发的后端Server或者使用一个AvailabilityPredicate来包含过滤server的逻辑,其实就就是检查status里记录的各个Server的运行状态; + BestAvailableRule:选择一个最小的并发请求的Server,逐个考察Server,如果Server被tripped了,则跳过。 + RandomRule:随机选择一个Server; + ResponseTimeWeightedRule:作用同WeightedResponseTimeRule,二者作用一样; + RetryRule:对选定的负载均衡策略机上重试机制,在一个配置时间段内当选择Server不成功,则一直尝试使用subRule的方式选择一个可用的server; + RoundRobinRule:轮询选择, 轮询index,选择index对应位置的Server; + WeightedResponseTimeRule:根据响应时间加权,响应时间越长,权重越小,被选中的可能性越低; + ZoneAvoidanceRule:复合判断Server所在区域的性能和Server的可用性选择Server; + */ + +} diff --git a/cloudutil/src/main/java/com/ccsens/cloudutil/ribbon/WpsBalanceRule.java b/cloudutil/src/main/java/com/ccsens/cloudutil/ribbon/WpsBalanceRule.java new file mode 100644 index 0000000..569c13b --- /dev/null +++ b/cloudutil/src/main/java/com/ccsens/cloudutil/ribbon/WpsBalanceRule.java @@ -0,0 +1,28 @@ +//package com.ccsens.cloudutil.ribbon; +// +//import com.netflix.client.config.IClientConfig; +//import com.netflix.loadbalancer.AbstractLoadBalancerRule; +//import com.netflix.loadbalancer.ILoadBalancer; +//import com.netflix.loadbalancer.Server; +//import org.springframework.context.annotation.Primary; +// +////@Primary +//public class WpsBalanceRule extends AbstractLoadBalancerRule { +// +// @Override +// public void initWithNiwsConfig(IClientConfig clientConfig) { +// +// } +// +// @Override +// public Server choose(Object key) { +// return choose(getLoadBalancer(), key); +// } +// +// private Server choose(ILoadBalancer loadBalancer, Object key) { +// System.out.println(key); +// return null; +// } +// +// +//} diff --git a/cloudutil/src/main/resources/application-util-dev.yml b/cloudutil/src/main/resources/application-util-dev.yml new file mode 100644 index 0000000..384f2ec --- /dev/null +++ b/cloudutil/src/main/resources/application-util-dev.yml @@ -0,0 +1,72 @@ +#服务端点暴露 +management: + endpoints: + web: + exposure: + # 暴露xxx端点,如需暴露多个,用,分隔;如需暴露所有端点,用'*' + include: auditevents,caches,conditions,flyway,health,heapdump,httptrace,info,integrationgraph,jolokia,logfile,loggers,liquibase,metrics,mappings,prometheus,scheduledtasks,sessions,shutdown,threaddump,hystrix.stream +# # 不暴露哪些端点 +# exclude: env,beans,configprops + endpoint: + health: + # 是否展示健康检查详情 + show-details: always + health: + redis: + enabled: false +#eureka注册 +eureka: + client: + service-url: + # 指定eureka server通信地址,注意/eureka/小尾巴不能少 + #defaultZone: http://admin:admin@peer1:8761/eureka/,http://admin:admin@peer2:8762/eureka/ + defaultZone: http://admin:admin@127.0.0.1:7010/eureka/ + instance: + # 是否注册IP到eureka server,如不指定或设为false,那就回注册主机名到eureka server + prefer-ip-address: true + metadata-map: + management: + context-path: ${server.servlet.context-path}/actuator + home-page-url-path: ${server.servlet.context-path}/ + status-page-url-path: ${server.servlet.context-path}/actuator/info + health-check-url-path: ${server.servlet.context-path}/actuator/health +ribbon: + ConnectTimeout: 60000 + ReadTimeout: 60000 + eureka: + enable: true +feign: + client: + config: + default: + connectTime: 50000 + readTimeout: 50000 + # NONE【性能最佳,适用于生产】:不记录任何日志(默认值)。 + # BASIC【适用于生产环境追踪问题】:仅记录请求方法、URL、响应状态代码以及执行时间。 + # HEADERS:记录BASIC级别的基础上,记录请求和响应的header。 + # FULL【比较适用于开发及测试环境定位问题】:记录请求和响应的header、body和元数据 + loggerLevel: basic + hystrix: + enabled: true +hystrix: + command: + default: + execution: + timeout: + enabled: true + isolation: + strategy: SEMAPHORE + thread: + timeoutInMilliseconds: 60000 +# sleuth +logging: + level: + root: info + org.springframework.cloud.sleuth: DEBUG +spring: +# zipkin: +# base-url: http://anyring.cc:9411 +# sleuth: +# sampler: +# # 采样率,模式0.1,也就是10%,为了便于观察效果,改为1.0,也就是100%。生产环境建议保持默认。 +# probability: 1.0 diff --git a/cloudutil/src/main/resources/application-util-green.yml b/cloudutil/src/main/resources/application-util-green.yml new file mode 100644 index 0000000..b087e99 --- /dev/null +++ b/cloudutil/src/main/resources/application-util-green.yml @@ -0,0 +1,143 @@ +#<<<<<<< HEAD +##服务端点暴露 +#management: +# endpoints: +# web: +# exposure: +# # 暴露xxx端点,如需暴露多个,用,分隔;如需暴露所有端点,用'*' +# include: auditevents,caches,conditions,flyway,health,heapdump,httptrace,info,integrationgraph,jolokia,logfile,loggers,liquibase,metrics,mappings,prometheus,scheduledtasks,sessions,shutdown,threaddump,hystrix.stream +## # 不暴露哪些端点 +## exclude: env,beans,configprops +# endpoint: +# health: +# # 是否展示健康检查详情 +# show-details: always +# health: +# redis: +# enabled: false +##eureka注册 +#eureka: +# client: +# service-url: +# # 指定eureka server通信地址,注意/eureka/小尾巴不能少 +# #defaultZone: http://admin:admin@peer1:8761/eureka/,http://admin:admin@peer2:8762/eureka/ +## defaultZone: http://admin:admin@49.233.89.188:7010/eureka/ +# defaultZone: http://admin:admin@192.168.0.99:7010/eureka/ +# instance: +# # 是否注册IP到eureka server,如不指定或设为false,那就回注册主机名到eureka server +# prefer-ip-address: true +# metadata-map: +# management: +# context-path: ${server.servlet.context-path:}/actuator +# home-page-url-path: ${server.servlet.context-path:}/ +# status-page-url-path: ${server.servlet.context-path:}/actuator/info +# health-check-url-path: ${server.servlet.context-path:}/actuator/health +#feign: +# client: +# config: +# default: +# connectTime: 5000 +# readTimeout: 5000 +# # NONE【性能最佳,适用于生产】:不记录任何日志(默认值)。 +# # BASIC【适用于生产环境追踪问题】:仅记录请求方法、URL、响应状态代码以及执行时间。 +# # HEADERS:记录BASIC级别的基础上,记录请求和响应的header。 +# # FULL【比较适用于开发及测试环境定位问题】:记录请求和响应的header、body和元数据 +# loggerLevel: basic +# hystrix: +# enabled: true +## sleuth +#logging: +# level: +# root: info +# org.springframework.cloud.sleuth: DEBUG +#spring: +## zipkin: +## base-url: http://49.233.89.188:9411 +## sleuth: +## sampler: +## # 采样率,模式0.1,也就是10%,为了便于观察效果,改为1.0,也就是100%。生产环境建议保持默认。 +## probability: 1.0 +# cloud: +# inetutils: +#======= +#服务端点暴露 +management: + endpoints: + web: + exposure: + # 暴露xxx端点,如需暴露多个,用,分隔;如需暴露所有端点,用'*' + include: auditevents,caches,conditions,flyway,health,heapdump,httptrace,info,integrationgraph,jolokia,logfile,loggers,liquibase,metrics,mappings,prometheus,scheduledtasks,sessions,shutdown,threaddump,hystrix.stream +# # 不暴露哪些端点 +# exclude: env,beans,configprops + endpoint: + health: + # 是否展示健康检查详情 + show-details: always + health: + redis: + enabled: false +#eureka注册 +eureka: + client: + service-url: + # 指定eureka server通信地址,注意/eureka/小尾巴不能少 + #defaultZone: http://admin:admin@peer1:8761/eureka/,http://admin:admin@peer2:8762/eureka/ + defaultZone: http://admin:admin@49.232.6.143:7010/eureka/ +# defaultZone: http://admin:admin@192.168.0.99:7010/eureka/ +# defaultZone: http://admin:admin@test.tall.wiki:7010/eureka/ + instance: + # 是否注册IP到eureka server,如不指定或设为false,那就回注册主机名到eureka server + prefer-ip-address: true + metadata-map: + management: + context-path: ${server.servlet.context-path:}/actuator + home-page-url-path: ${server.servlet.context-path:}/ + status-page-url-path: ${server.servlet.context-path:}/actuator/info + health-check-url-path: ${server.servlet.context-path:}/actuator/health +feign: + client: + config: + default: + connectTime: 5000 + readTimeout: 5000 + # NONE【性能最佳,适用于生产】:不记录任何日志(默认值)。 + # BASIC【适用于生产环境追踪问题】:仅记录请求方法、URL、响应状态代码以及执行时间。 + # HEADERS:记录BASIC级别的基础上,记录请求和响应的header。 + # FULL【比较适用于开发及测试环境定位问题】:记录请求和响应的header、body和元数据 + loggerLevel: basic + hystrix: + enabled: true +hystrix: + threadpool: + default: + coreSize: 200 #并发执行的最大线程数,默认10 + maxQueueSize: 1000 #BlockingQueue的最大队列数,默认值-1 + queueSizeRejectionThreshold: 800 #即使maxQueueSize没有达到,达到queueSizeRejectionThreshold该值后,请求也会被拒绝,默认值5 + command: + default: + execution: + timeout: + enabled: true + isolation: + strategy: SEMAPHORE + thread: + timeoutInMilliseconds: 60000 +#ribbon的超时时间 +ribbon: + ReadTimeout: 60000 + ConnectTimeout: 60000 +# sleuth +logging: + level: + root: info + org.springframework.cloud.sleuth: DEBUG +spring: +# zipkin: +# base-url: http://49.233.89.188:9411 +# sleuth: +# sampler: +# # 采样率,模式0.1,也就是10%,为了便于观察效果,改为1.0,也就是100%。生产环境建议保持默认。 +# probability: 1.0 + cloud: + inetutils: + ignored-interfaces: ['VMware.*'] \ No newline at end of file diff --git a/cloudutil/src/main/resources/application-util-greenvalley.yml b/cloudutil/src/main/resources/application-util-greenvalley.yml new file mode 100644 index 0000000..0551b88 --- /dev/null +++ b/cloudutil/src/main/resources/application-util-greenvalley.yml @@ -0,0 +1,66 @@ +#服务端点暴露 +management: + endpoints: + web: + exposure: + # 暴露xxx端点,如需暴露多个,用,分隔;如需暴露所有端点,用'*' + include: auditevents,caches,conditions,flyway,health,heapdump,httptrace,info,integrationgraph,jolokia,logfile,loggers,liquibase,metrics,mappings,prometheus,scheduledtasks,sessions,shutdown,threaddump,hystrix.stream +# # 不暴露哪些端点 +# exclude: env,beans,configprops + endpoint: + health: + # 是否展示健康检查详情 + show-details: always + health: + redis: + enabled: false +#eureka注册 +eureka: + client: + service-url: + # 指定eureka server通信地址,注意/eureka/小尾巴不能少 + defaultZone: http://admin:admin@82.157.24.76:7010/eureka/ +# defaultZone: http://admin:admin@49.232.6.143:7010/eureka/ + instance: + # 是否注册IP到eureka server,如不指定或设为false,那就回注册主机名到eureka server + prefer-ip-address: true + metadata-map: + management: + context-path: ${server.servlet.context-path:}/actuator + home-page-url-path: ${server.servlet.context-path:}/ + status-page-url-path: ${server.servlet.context-path:}/actuator/info + health-check-url-path: ${server.servlet.context-path:}/actuator/health +feign: + client: + config: + default: + connectTime: 5000 + readTimeout: 5000 + # NONE【性能最佳,适用于生产】:不记录任何日志(默认值)。 + # BASIC【适用于生产环境追踪问题】:仅记录请求方法、URL、响应状态代码以及执行时间。 + # HEADERS:记录BASIC级别的基础上,记录请求和响应的header。 + # FULL【比较适用于开发及测试环境定位问题】:记录请求和响应的header、body和元数据 + loggerLevel: basic + hystrix: + enabled: true +hystrix: + command: + default: + execution: + isolation: + strategy: SEMAPHORE + thread: + timeoutInMilliseconds: 60000 +#ribbon的超时时间 +ribbon: + ReadTimeout: 60000 + ConnectTimeout: 60000 +# sleuth +logging: + level: + root: info + org.springframework.cloud.sleuth: DEBUG +spring: + cloud: + inetutils: + ignored-interfaces: ['VMware.*'] \ No newline at end of file diff --git a/cloudutil/src/main/resources/application-util-pre.yml b/cloudutil/src/main/resources/application-util-pre.yml new file mode 100644 index 0000000..38b45b5 --- /dev/null +++ b/cloudutil/src/main/resources/application-util-pre.yml @@ -0,0 +1,145 @@ +#<<<<<<< HEAD +##服务端点暴露 +#management: +# endpoints: +# web: +# exposure: +# # 暴露xxx端点,如需暴露多个,用,分隔;如需暴露所有端点,用'*' +# include: auditevents,caches,conditions,flyway,health,heapdump,httptrace,info,integrationgraph,jolokia,logfile,loggers,liquibase,metrics,mappings,prometheus,scheduledtasks,sessions,shutdown,threaddump,hystrix.stream +## # 不暴露哪些端点 +## exclude: env,beans,configprops +# endpoint: +# health: +# # 是否展示健康检查详情 +# show-details: always +# health: +# redis: +# enabled: false +##eureka注册 +#eureka: +# client: +# service-url: +# # 指定eureka server通信地址,注意/eureka/小尾巴不能少 +# #defaultZone: http://admin:admin@peer1:8761/eureka/,http://admin:admin@peer2:8762/eureka/ +## defaultZone: http://admin:admin@49.233.89.188:7010/eureka/ +# defaultZone: http://admin:admin@192.168.0.99:7010/eureka/ +# instance: +# # 是否注册IP到eureka server,如不指定或设为false,那就回注册主机名到eureka server +# prefer-ip-address: true +# metadata-map: +# management: +# context-path: ${server.servlet.context-path:}/actuator +# home-page-url-path: ${server.servlet.context-path:}/ +# status-page-url-path: ${server.servlet.context-path:}/actuator/info +# health-check-url-path: ${server.servlet.context-path:}/actuator/health +#feign: +# client: +# config: +# default: +# connectTime: 5000 +# readTimeout: 5000 +# # NONE【性能最佳,适用于生产】:不记录任何日志(默认值)。 +# # BASIC【适用于生产环境追踪问题】:仅记录请求方法、URL、响应状态代码以及执行时间。 +# # HEADERS:记录BASIC级别的基础上,记录请求和响应的header。 +# # FULL【比较适用于开发及测试环境定位问题】:记录请求和响应的header、body和元数据 +# loggerLevel: basic +# hystrix: +# enabled: true +## sleuth +#logging: +# level: +# root: info +# org.springframework.cloud.sleuth: DEBUG +#spring: +## zipkin: +## base-url: http://49.233.89.188:9411 +## sleuth: +## sampler: +## # 采样率,模式0.1,也就是10%,为了便于观察效果,改为1.0,也就是100%。生产环境建议保持默认。 +## probability: 1.0 +# cloud: +# inetutils: +#======= +#服务端点暴露 +management: + endpoints: + web: + exposure: + # 暴露xxx端点,如需暴露多个,用,分隔;如需暴露所有端点,用'*' + include: auditevents,caches,conditions,flyway,health,heapdump,httptrace,info,integrationgraph,jolokia,logfile,loggers,liquibase,metrics,mappings,prometheus,scheduledtasks,sessions,shutdown,threaddump,hystrix.stream + # # 不暴露哪些端点 + # exclude: env,beans,configprops + endpoint: + health: + # 是否展示健康检查详情 + show-details: always + health: + redis: + enabled: false +#eureka注册 +eureka: + client: + service-url: + # 指定eureka server通信地址,注意/eureka/小尾巴不能少 + #defaultZone: http://admin:admin@peer1:8761/eureka/,http://admin:admin@peer2:8762/eureka/ + +# defaultZone: http://admin:admin@101.201.226.21:7010/eureka/ +# defaultZone: http://admin:admin@121.36.3.207:7010/eureka/ + defaultZone: http://admin:admin@127.0.0.1:7010/eureka/ + # defaultZone: http://admin:admin@test.tall.wiki:7010/eureka/ + instance: + # 是否注册IP到eureka server,如不指定或设为false,那就回注册主机名到eureka server + prefer-ip-address: true + metadata-map: + management: + context-path: ${server.servlet.context-path:}/actuator + home-page-url-path: ${server.servlet.context-path:}/ + status-page-url-path: ${server.servlet.context-path:}/actuator/info + health-check-url-path: ${server.servlet.context-path:}/actuator/health +feign: + client: + config: + default: + connectTime: 60000 + readTimeout: 60000 + # NONE【性能最佳,适用于生产】:不记录任何日志(默认值)。 + # BASIC【适用于生产环境追踪问题】:仅记录请求方法、URL、响应状态代码以及执行时间。 + # HEADERS:记录BASIC级别的基础上,记录请求和响应的header。 + # FULL【比较适用于开发及测试环境定位问题】:记录请求和响应的header、body和元数据 + loggerLevel: basic + hystrix: + enabled: true +hystrix: + command: + default: + execution: + timeout: + enabled: true + isolation: + strategy: THREAD + thread: + timeoutInMilliseconds: 60000 + threadpool: + default: + coreSize: 200 #并发执行的最大线程数,默认10 + maxQueueSize: 1000 #BlockingQueue的最大队列数,默认值-1 + queueSizeRejectionThreshold: 800 #即使maxQueueSize没有达到,达到queueSizeRejectionThreshold该值后,请求也会被拒绝,默认值5 +#ribbon的超时时间 +ribbon: + ReadTimeout: 60000 + ConnectTimeout: 60000 +# sleuth +logging: + level: + root: info + org.springframework.cloud.sleuth: DEBUG +spring: + # zipkin: + # base-url: http://49.233.89.188:9411 + # sleuth: + # sampler: + # # 采样率,模式0.1,也就是10%,为了便于观察效果,改为1.0,也就是100%。生产环境建议保持默认。 + # probability: 1.0 + cloud: + inetutils: + ignored-interfaces: ['VMware.*'] \ No newline at end of file diff --git a/cloudutil/src/main/resources/application-util-prod.yml b/cloudutil/src/main/resources/application-util-prod.yml new file mode 100644 index 0000000..d3a1176 --- /dev/null +++ b/cloudutil/src/main/resources/application-util-prod.yml @@ -0,0 +1,145 @@ +#<<<<<<< HEAD +##服务端点暴露 +#management: +# endpoints: +# web: +# exposure: +# # 暴露xxx端点,如需暴露多个,用,分隔;如需暴露所有端点,用'*' +# include: auditevents,caches,conditions,flyway,health,heapdump,httptrace,info,integrationgraph,jolokia,logfile,loggers,liquibase,metrics,mappings,prometheus,scheduledtasks,sessions,shutdown,threaddump,hystrix.stream +## # 不暴露哪些端点 +## exclude: env,beans,configprops +# endpoint: +# health: +# # 是否展示健康检查详情 +# show-details: always +# health: +# redis: +# enabled: false +##eureka注册 +#eureka: +# client: +# service-url: +# # 指定eureka server通信地址,注意/eureka/小尾巴不能少 +# #defaultZone: http://admin:admin@peer1:8761/eureka/,http://admin:admin@peer2:8762/eureka/ +## defaultZone: http://admin:admin@49.233.89.188:7010/eureka/ +# defaultZone: http://admin:admin@192.168.0.99:7010/eureka/ +# instance: +# # 是否注册IP到eureka server,如不指定或设为false,那就回注册主机名到eureka server +# prefer-ip-address: true +# metadata-map: +# management: +# context-path: ${server.servlet.context-path:}/actuator +# home-page-url-path: ${server.servlet.context-path:}/ +# status-page-url-path: ${server.servlet.context-path:}/actuator/info +# health-check-url-path: ${server.servlet.context-path:}/actuator/health +#feign: +# client: +# config: +# default: +# connectTime: 5000 +# readTimeout: 5000 +# # NONE【性能最佳,适用于生产】:不记录任何日志(默认值)。 +# # BASIC【适用于生产环境追踪问题】:仅记录请求方法、URL、响应状态代码以及执行时间。 +# # HEADERS:记录BASIC级别的基础上,记录请求和响应的header。 +# # FULL【比较适用于开发及测试环境定位问题】:记录请求和响应的header、body和元数据 +# loggerLevel: basic +# hystrix: +# enabled: true +## sleuth +#logging: +# level: +# root: info +# org.springframework.cloud.sleuth: DEBUG +#spring: +## zipkin: +## base-url: http://49.233.89.188:9411 +## sleuth: +## sampler: +## # 采样率,模式0.1,也就是10%,为了便于观察效果,改为1.0,也就是100%。生产环境建议保持默认。 +## probability: 1.0 +# cloud: +# inetutils: +#======= +#服务端点暴露 +management: + endpoints: + web: + exposure: + # 暴露xxx端点,如需暴露多个,用,分隔;如需暴露所有端点,用'*' + include: auditevents,caches,conditions,flyway,health,heapdump,httptrace,info,integrationgraph,jolokia,logfile,loggers,liquibase,metrics,mappings,prometheus,scheduledtasks,sessions,shutdown,threaddump,hystrix.stream + # # 不暴露哪些端点 + # exclude: env,beans,configprops + endpoint: + health: + # 是否展示健康检查详情 + show-details: always + health: + redis: + enabled: false +#eureka注册 +eureka: + client: + service-url: + # 指定eureka server通信地址,注意/eureka/小尾巴不能少 + #defaultZone: http://admin:admin@peer1:8761/eureka/,http://admin:admin@peer2:8762/eureka/ + +# defaultZone: http://admin:admin@101.201.226.21:7010/eureka/ + defaultZone: http://admin:admin@121.36.3.207:7010/eureka/ +# defaultZone: http://admin:admin@127.0.0.1:7010/eureka/ + # defaultZone: http://admin:admin@test.tall.wiki:7010/eureka/ + instance: + # 是否注册IP到eureka server,如不指定或设为false,那就回注册主机名到eureka server + prefer-ip-address: true + metadata-map: + management: + context-path: ${server.servlet.context-path:}/actuator + home-page-url-path: ${server.servlet.context-path:}/ + status-page-url-path: ${server.servlet.context-path:}/actuator/info + health-check-url-path: ${server.servlet.context-path:}/actuator/health +feign: + client: + config: + default: + connectTime: 60000 + readTimeout: 60000 + # NONE【性能最佳,适用于生产】:不记录任何日志(默认值)。 + # BASIC【适用于生产环境追踪问题】:仅记录请求方法、URL、响应状态代码以及执行时间。 + # HEADERS:记录BASIC级别的基础上,记录请求和响应的header。 + # FULL【比较适用于开发及测试环境定位问题】:记录请求和响应的header、body和元数据 + loggerLevel: basic + hystrix: + enabled: true +hystrix: + command: + default: + execution: + timeout: + enabled: true + isolation: + strategy: THREAD + thread: + timeoutInMilliseconds: 60000 + threadpool: + default: + coreSize: 200 #并发执行的最大线程数,默认10 + maxQueueSize: 1000 #BlockingQueue的最大队列数,默认值-1 + queueSizeRejectionThreshold: 800 #即使maxQueueSize没有达到,达到queueSizeRejectionThreshold该值后,请求也会被拒绝,默认值5 +#ribbon的超时时间 +ribbon: + ReadTimeout: 60000 + ConnectTimeout: 60000 +# sleuth +logging: + level: + root: info + org.springframework.cloud.sleuth: DEBUG +spring: + # zipkin: + # base-url: http://49.233.89.188:9411 + # sleuth: + # sampler: + # # 采样率,模式0.1,也就是10%,为了便于观察效果,改为1.0,也就是100%。生产环境建议保持默认。 + # probability: 1.0 + cloud: + inetutils: + ignored-interfaces: ['VMware.*'] \ No newline at end of file diff --git a/cloudutil/src/main/resources/application-util-prodsd.yml b/cloudutil/src/main/resources/application-util-prodsd.yml new file mode 100644 index 0000000..7e21903 --- /dev/null +++ b/cloudutil/src/main/resources/application-util-prodsd.yml @@ -0,0 +1,82 @@ +#服务端点暴露 +management: + endpoints: + web: + exposure: + # 暴露xxx端点,如需暴露多个,用,分隔;如需暴露所有端点,用'*' + include: auditevents,caches,conditions,flyway,health,heapdump,httptrace,info,integrationgraph,jolokia,logfile,loggers,liquibase,metrics,mappings,prometheus,scheduledtasks,sessions,shutdown,threaddump,hystrix.stream +# # 不暴露哪些端点 + exclude: env,beans,configprops + endpoint: + health: + # 是否展示健康检查详情 + show-details: always + health: + redis: + enabled: false +#eureka注册 +eureka: + client: + service-url: + # 指定eureka server通信地址,注意/eureka/小尾巴不能少 + #defaultZone: http://admin:admin@peer1:8761/eureka/,http://admin:admin@peer2:8762/eureka/ + +# defaultZone: http://admin:admin@81.70.54.64:7010/eureka/ + defaultZone: http://admin:admin@121.36.3.207:7010/eureka/ + + instance: + # 是否注册IP到eureka server,如不指定或设为false,那就回注册主机名到eureka server + prefer-ip-address: true + metadata-map: + management: + context-path: ${server.servlet.context-path:}/actuator + home-page-url-path: ${server.servlet.context-path:}/ + status-page-url-path: ${server.servlet.context-path:}/actuator/info + health-check-url-path: ${server.servlet.context-path:}/actuator/health +feign: + client: + config: + default: + connectTime: 5000 + readTimeout: 5000 + # NONE【性能最佳,适用于生产】:不记录任何日志(默认值)。 + # BASIC【适用于生产环境追踪问题】:仅记录请求方法、URL、响应状态代码以及执行时间。 + # HEADERS:记录BASIC级别的基础上,记录请求和响应的header。 + # FULL【比较适用于开发及测试环境定位问题】:记录请求和响应的header、body和元数据 + loggerLevel: basic + hystrix: + enabled: true +hystrix: + threadpool: + default: + coreSize: 200 #并发执行的最大线程数,默认10 + maxQueueSize: 1000 #BlockingQueue的最大队列数,默认值-1 + queueSizeRejectionThreshold: 800 #即使maxQueueSize没有达到,达到queueSizeRejectionThreshold该值后,请求也会被拒绝,默认值5 + command: + default: + execution: + timeout: + enabled: true + isolation: + strategy: SEMAPHORE + thread: + timeoutInMilliseconds: 60000 +#ribbon的超时时间 +ribbon: + ReadTimeout: 60000 + ConnectTimeout: 60000 +# sleuth +logging: + level: + root: info + org.springframework.cloud.sleuth: DEBUG +spring: +# zipkin: +# base-url: http://140.143.228.3:9411 +# sleuth: +# sampler: +# # 采样率,模式0.1,也就是10%,为了便于观察效果,改为1.0,也就是100%。生产环境建议保持默认。 +# probability: 0.1 + cloud: + inetutils: + ignored-interfaces: ['VMware.*'] \ No newline at end of file diff --git a/cloudutil/src/main/resources/application-util-test.yml b/cloudutil/src/main/resources/application-util-test.yml new file mode 100644 index 0000000..e2790f9 --- /dev/null +++ b/cloudutil/src/main/resources/application-util-test.yml @@ -0,0 +1,146 @@ +#<<<<<<< HEAD +##服务端点暴露 +#management: +# endpoints: +# web: +# exposure: +# # 暴露xxx端点,如需暴露多个,用,分隔;如需暴露所有端点,用'*' +# include: auditevents,caches,conditions,flyway,health,heapdump,httptrace,info,integrationgraph,jolokia,logfile,loggers,liquibase,metrics,mappings,prometheus,scheduledtasks,sessions,shutdown,threaddump,hystrix.stream +## # 不暴露哪些端点 +## exclude: env,beans,configprops +# endpoint: +# health: +# # 是否展示健康检查详情 +# show-details: always +# health: +# redis: +# enabled: false +##eureka注册 +#eureka: +# client: +# service-url: +# # 指定eureka server通信地址,注意/eureka/小尾巴不能少 +# #defaultZone: http://admin:admin@peer1:8761/eureka/,http://admin:admin@peer2:8762/eureka/ +## defaultZone: http://admin:admin@49.233.89.188:7010/eureka/ +# defaultZone: http://admin:admin@192.168.0.99:7010/eureka/ +# instance: +# # 是否注册IP到eureka server,如不指定或设为false,那就回注册主机名到eureka server +# prefer-ip-address: true +# metadata-map: +# management: +# context-path: ${server.servlet.context-path:}/actuator +# home-page-url-path: ${server.servlet.context-path:}/ +# status-page-url-path: ${server.servlet.context-path:}/actuator/info +# health-check-url-path: ${server.servlet.context-path:}/actuator/health +#feign: +# client: +# config: +# default: +# connectTime: 5000 +# readTimeout: 5000 +# # NONE【性能最佳,适用于生产】:不记录任何日志(默认值)。 +# # BASIC【适用于生产环境追踪问题】:仅记录请求方法、URL、响应状态代码以及执行时间。 +# # HEADERS:记录BASIC级别的基础上,记录请求和响应的header。 +# # FULL【比较适用于开发及测试环境定位问题】:记录请求和响应的header、body和元数据 +# loggerLevel: basic +# hystrix: +# enabled: true +## sleuth +#logging: +# level: +# root: info +# org.springframework.cloud.sleuth: DEBUG +#spring: +## zipkin: +## base-url: http://49.233.89.188:9411 +## sleuth: +## sampler: +## # 采样率,模式0.1,也就是10%,为了便于观察效果,改为1.0,也就是100%。生产环境建议保持默认。 +## probability: 1.0 +# cloud: +# inetutils: +#======= +#服务端点暴露 +management: + endpoints: + web: + exposure: + # 暴露xxx端点,如需暴露多个,用,分隔;如需暴露所有端点,用'*' + include: auditevents,caches,conditions,flyway,health,heapdump,httptrace,info,integrationgraph,jolokia,logfile,loggers,liquibase,metrics,mappings,prometheus,scheduledtasks,sessions,shutdown,threaddump,hystrix.stream +# # 不暴露哪些端点 +# exclude: env,beans,configprops + endpoint: + health: + # 是否展示健康检查详情 + show-details: always + health: + redis: + enabled: false +#eureka注册 +eureka: + client: + service-url: + # 指定eureka server通信地址,注意/eureka/小尾巴不能少 + #defaultZone: http://admin:admin@peer1:8761/eureka/,http://admin:admin@peer2:8762/eureka/ +# defaultZone: http://admin:admin@49.232.6.143:7010/eureka/ +# defaultZone: http://admin:admin@192.168.0.99:7010/eureka/ + + defaultZone: http://admin:admin@192.168.0.99:7010/eureka/ +# defaultZone: http://admin:admin@192.168.31.13:7010/eureka/ +# defaultZone: http://admin:admin@test.tall.wiki:7010/eureka/ + instance: + # 是否注册IP到eureka server,如不指定或设为false,那就回注册主机名到eureka server + prefer-ip-address: true + metadata-map: + management: + context-path: ${server.servlet.context-path:}/actuator + home-page-url-path: ${server.servlet.context-path:}/ + status-page-url-path: ${server.servlet.context-path:}/actuator/info + health-check-url-path: ${server.servlet.context-path:}/actuator/health +feign: + client: + config: + default: + connectTime: 60000 + readTimeout: 60000 + # NONE【性能最佳,适用于生产】:不记录任何日志(默认值)。 + # BASIC【适用于生产环境追踪问题】:仅记录请求方法、URL、响应状态代码以及执行时间。 + # HEADERS:记录BASIC级别的基础上,记录请求和响应的header。 + # FULL【比较适用于开发及测试环境定位问题】:记录请求和响应的header、body和元数据 + loggerLevel: basic + hystrix: + enabled: true +hystrix: + command: + default: + execution: + timeout: + enabled: true + isolation: + strategy: THREAD + thread: + timeoutInMilliseconds: 60000 + threadpool: + default: + coreSize: 200 #并发执行的最大线程数,默认10 + maxQueueSize: 1000 #BlockingQueue的最大队列数,默认值-1 + queueSizeRejectionThreshold: 800 #即使maxQueueSize没有达到,达到queueSizeRejectionThreshold该值后,请求也会被拒绝,默认值5 +#ribbon的超时时间 +ribbon: + ReadTimeout: 60000 + ConnectTimeout: 60000 +# sleuth +logging: + level: + root: info + org.springframework.cloud.sleuth: DEBUG +spring: +# zipkin: +# base-url: http://49.233.89.188:9411 +# sleuth: +# sampler: +# # 采样率,模式0.1,也就是10%,为了便于观察效果,改为1.0,也就是100%。生产环境建议保持默认。 +# probability: 1.0 + cloud: + inetutils: + ignored-interfaces: ['VMware.*'] \ No newline at end of file diff --git a/dh_diplomatist/.gitignore b/dh_diplomatist/.gitignore new file mode 100644 index 0000000..549e00a --- /dev/null +++ b/dh_diplomatist/.gitignore @@ -0,0 +1,33 @@ +HELP.md +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ diff --git a/dh_diplomatist/mvnw b/dh_diplomatist/mvnw new file mode 100644 index 0000000..3c8a553 --- /dev/null +++ b/dh_diplomatist/mvnw @@ -0,0 +1,322 @@ +#!/bin/sh +# ---------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# ---------------------------------------------------------------------------- + +# ---------------------------------------------------------------------------- +# Maven Start Up Batch script +# +# Required ENV vars: +# ------------------ +# JAVA_HOME - location of a JDK home dir +# +# Optional ENV vars +# ----------------- +# M2_HOME - location of maven2's installed home dir +# MAVEN_OPTS - parameters passed to the Java VM when running Maven +# e.g. to debug Maven itself, use +# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +# MAVEN_SKIP_RC - flag to disable loading of mavenrc files +# ---------------------------------------------------------------------------- + +if [ -z "$MAVEN_SKIP_RC" ]; then + + if [ -f /etc/mavenrc ]; then + . /etc/mavenrc + fi + + if [ -f "$HOME/.mavenrc" ]; then + . "$HOME/.mavenrc" + fi + +fi + +# OS specific support. $var _must_ be set to either true or false. +cygwin=false +darwin=false +mingw=false +case "$(uname)" in +CYGWIN*) cygwin=true ;; +MINGW*) mingw=true ;; +Darwin*) + darwin=true + # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home + # See https://developer.apple.com/library/mac/qa/qa1170/_index.html + if [ -z "$JAVA_HOME" ]; then + if [ -x "/usr/libexec/java_home" ]; then + export JAVA_HOME="$(/usr/libexec/java_home)" + else + export JAVA_HOME="/Library/Java/Home" + fi + fi + ;; +esac + +if [ -z "$JAVA_HOME" ]; then + if [ -r /etc/gentoo-release ]; then + JAVA_HOME=$(java-config --jre-home) + fi +fi + +if [ -z "$M2_HOME" ]; then + ## resolve links - $0 may be a link to maven's home + PRG="$0" + + # need this for relative symlinks + while [ -h "$PRG" ]; do + ls=$(ls -ld "$PRG") + link=$(expr "$ls" : '.*-> \(.*\)$') + if expr "$link" : '/.*' >/dev/null; then + PRG="$link" + else + PRG="$(dirname "$PRG")/$link" + fi + done + + saveddir=$(pwd) + + M2_HOME=$(dirname "$PRG")/.. + + # make it fully qualified + M2_HOME=$(cd "$M2_HOME" && pwd) + + cd "$saveddir" + # echo Using m2 at $M2_HOME +fi + +# For Cygwin, ensure paths are in UNIX format before anything is touched +if $cygwin; then + [ -n "$M2_HOME" ] && + M2_HOME=$(cygpath --unix "$M2_HOME") + [ -n "$JAVA_HOME" ] && + JAVA_HOME=$(cygpath --unix "$JAVA_HOME") + [ -n "$CLASSPATH" ] && + CLASSPATH=$(cygpath --path --unix "$CLASSPATH") +fi + +# For Mingw, ensure paths are in UNIX format before anything is touched +if $mingw; then + [ -n "$M2_HOME" ] && + M2_HOME="$( ( + cd "$M2_HOME" + pwd + ))" + [ -n "$JAVA_HOME" ] && + JAVA_HOME="$( ( + cd "$JAVA_HOME" + pwd + ))" +fi + +if [ -z "$JAVA_HOME" ]; then + javaExecutable="$(which javac)" + if [ -n "$javaExecutable" ] && ! [ "$(expr \"$javaExecutable\" : '\([^ ]*\)')" = "no" ]; then + # readlink(1) is not available as standard on Solaris 10. + readLink=$(which readlink) + if [ ! $(expr "$readLink" : '\([^ ]*\)') = "no" ]; then + if $darwin; then + javaHome="$(dirname \"$javaExecutable\")" + javaExecutable="$(cd \"$javaHome\" && pwd -P)/javac" + else + javaExecutable="$(readlink -f \"$javaExecutable\")" + fi + javaHome="$(dirname \"$javaExecutable\")" + javaHome=$(expr "$javaHome" : '\(.*\)/bin') + JAVA_HOME="$javaHome" + export JAVA_HOME + fi + fi +fi + +if [ -z "$JAVACMD" ]; then + if [ -n "$JAVA_HOME" ]; then + if [ -x "$JAVA_HOME/jre/sh/java" ]; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + else + JAVACMD="$(which java)" + fi +fi + +if [ ! -x "$JAVACMD" ]; then + echo "Error: JAVA_HOME is not defined correctly." >&2 + echo " We cannot execute $JAVACMD" >&2 + exit 1 +fi + +if [ -z "$JAVA_HOME" ]; then + echo "Warning: JAVA_HOME environment variable is not set." +fi + +CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher + +# traverses directory structure from process work directory to filesystem root +# first directory with .mvn subdirectory is considered project base directory +find_maven_basedir() { + + if [ -z "$1" ]; then + echo "Path not specified to find_maven_basedir" + return 1 + fi + + basedir="$1" + wdir="$1" + while [ "$wdir" != '/' ]; do + if [ -d "$wdir"/.mvn ]; then + basedir=$wdir + break + fi + # workaround for JBEAP-8937 (on Solaris 10/Sparc) + if [ -d "${wdir}" ]; then + wdir=$( + cd "$wdir/.." + pwd + ) + fi + # end of workaround + done + echo "${basedir}" +} + +# concatenates all lines of a file +concat_lines() { + if [ -f "$1" ]; then + echo "$(tr -s '\n' ' ' <"$1")" + fi +} + +BASE_DIR=$(find_maven_basedir "$(pwd)") +if [ -z "$BASE_DIR" ]; then + exit 1 +fi + +########################################################################################## +# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +# This allows using the maven wrapper in projects that prohibit checking in binary data. +########################################################################################## +if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found .mvn/wrapper/maven-wrapper.jar" + fi +else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." + fi + if [ -n "$MVNW_REPOURL" ]; then + jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + else + jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + fi + while IFS="=" read key value; do + case "$key" in wrapperUrl) + jarUrl="$value" + break + ;; + esac + done <"$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" + if [ "$MVNW_VERBOSE" = true ]; then + echo "Downloading from: $jarUrl" + fi + wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" + if $cygwin; then + wrapperJarPath=$(cygpath --path --windows "$wrapperJarPath") + fi + + if command -v wget >/dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found wget ... using wget" + fi + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + wget "$jarUrl" -O "$wrapperJarPath" + else + wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" + fi + elif command -v curl >/dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found curl ... using curl" + fi + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + curl -o "$wrapperJarPath" "$jarUrl" -f + else + curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f + fi + + else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Falling back to using Java to download" + fi + javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" + # For Cygwin, switch paths to Windows format before running javac + if $cygwin; then + javaClass=$(cygpath --path --windows "$javaClass") + fi + if [ -e "$javaClass" ]; then + if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Compiling MavenWrapperDownloader.java ..." + fi + # Compiling the Java class + ("$JAVA_HOME/bin/javac" "$javaClass") + fi + if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + # Running the downloader + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Running MavenWrapperDownloader.java ..." + fi + ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") + fi + fi + fi +fi +########################################################################################## +# End of extension +########################################################################################## + +export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} +if [ "$MVNW_VERBOSE" = true ]; then + echo $MAVEN_PROJECTBASEDIR +fi +MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" + +# For Cygwin, switch paths to Windows format before running java +if $cygwin; then + [ -n "$M2_HOME" ] && + M2_HOME=$(cygpath --path --windows "$M2_HOME") + [ -n "$JAVA_HOME" ] && + JAVA_HOME=$(cygpath --path --windows "$JAVA_HOME") + [ -n "$CLASSPATH" ] && + CLASSPATH=$(cygpath --path --windows "$CLASSPATH") + [ -n "$MAVEN_PROJECTBASEDIR" ] && + MAVEN_PROJECTBASEDIR=$(cygpath --path --windows "$MAVEN_PROJECTBASEDIR") +fi + +# Provide a "standardized" way to retrieve the CLI args that will +# work with both Windows and non-Windows executions. +MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" +export MAVEN_CMD_LINE_ARGS + +WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +exec "$JAVACMD" \ + $MAVEN_OPTS \ + -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ + "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ + ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/dh_diplomatist/mvnw.cmd b/dh_diplomatist/mvnw.cmd new file mode 100644 index 0000000..c8d4337 --- /dev/null +++ b/dh_diplomatist/mvnw.cmd @@ -0,0 +1,182 @@ +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM https://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Maven Start Up Batch script +@REM +@REM Required ENV vars: +@REM JAVA_HOME - location of a JDK home dir +@REM +@REM Optional ENV vars +@REM M2_HOME - location of maven2's installed home dir +@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending +@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven +@REM e.g. to debug Maven itself, use +@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM ---------------------------------------------------------------------------- + +@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' +@echo off +@REM set title of command window +title %0 +@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' +@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% + +@REM set %HOME% to equivalent of $HOME +if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") + +@REM Execute a user defined script before this one +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre +@REM check for pre script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" +if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" +:skipRcPre + +@setlocal + +set ERROR_CODE=0 + +@REM To isolate internal variables from possible post scripts, we use another setlocal +@setlocal + +@REM ==== START VALIDATION ==== +if not "%JAVA_HOME%" == "" goto OkJHome + +echo. +echo Error: JAVA_HOME not found in your environment. >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +:OkJHome +if exist "%JAVA_HOME%\bin\java.exe" goto init + +echo. +echo Error: JAVA_HOME is set to an invalid directory. >&2 +echo JAVA_HOME = "%JAVA_HOME%" >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +@REM ==== END VALIDATION ==== + +:init + +@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". +@REM Fallback to current working directory if not found. + +set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% +IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir + +set EXEC_DIR=%CD% +set WDIR=%EXEC_DIR% +:findBaseDir +IF EXIST "%WDIR%"\.mvn goto baseDirFound +cd .. +IF "%WDIR%"=="%CD%" goto baseDirNotFound +set WDIR=%CD% +goto findBaseDir + +:baseDirFound +set MAVEN_PROJECTBASEDIR=%WDIR% +cd "%EXEC_DIR%" +goto endDetectBaseDir + +:baseDirNotFound +set MAVEN_PROJECTBASEDIR=%EXEC_DIR% +cd "%EXEC_DIR%" + +:endDetectBaseDir + +IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig + +@setlocal EnableExtensions EnableDelayedExpansion +for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a +@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% + +:endReadAdditionalConfig + +SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" +set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" +set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + +FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( + IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B +) + +@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +@REM This allows using the maven wrapper in projects that prohibit checking in binary data. +if exist %WRAPPER_JAR% ( + if "%MVNW_VERBOSE%" == "true" ( + echo Found %WRAPPER_JAR% + ) +) else ( + if not "%MVNW_REPOURL%" == "" ( + SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + ) + if "%MVNW_VERBOSE%" == "true" ( + echo Couldn't find %WRAPPER_JAR%, downloading it ... + echo Downloading from: %DOWNLOAD_URL% + ) + + powershell -Command "&{"^ + "$webclient = new-object System.Net.WebClient;"^ + "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ + "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ + "}"^ + "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ + "}" + if "%MVNW_VERBOSE%" == "true" ( + echo Finished downloading %WRAPPER_JAR% + ) +) +@REM End of extension + +@REM Provide a "standardized" way to retrieve the CLI args that will +@REM work with both Windows and non-Windows executions. +set MAVEN_CMD_LINE_ARGS=%* + +%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* +if ERRORLEVEL 1 goto error +goto end + +:error +set ERROR_CODE=1 + +:end +@endlocal & set ERROR_CODE=%ERROR_CODE% + +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost +@REM check for post script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" +if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" +:skipRcPost + +@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' +if "%MAVEN_BATCH_PAUSE%" == "on" pause + +if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% + +exit /B %ERROR_CODE% diff --git a/dh_diplomatist/pom.xml b/dh_diplomatist/pom.xml new file mode 100644 index 0000000..ec2b595 --- /dev/null +++ b/dh_diplomatist/pom.xml @@ -0,0 +1,90 @@ + + + 4.0.0 + + ccsens_dh + com.ccsens + 1.0-SNAPSHOT + + + dh_diplomatist + + 0.0.1-SNAPSHOT + + dh_diplomatist + + Demo project for Spring Boot + + 1.8 + + + + + + cloudutil + com.ccsens + 1.0-SNAPSHOT + + + + + + + + + + com.ccsens + util + 1.0-SNAPSHOT + compile + + + + wechatutil + com.ccsens + 1.0-SNAPSHOT + + + + + + + + + org.mybatis.generator + mybatis-generator-maven-plugin + 1.3.7 + + ${basedir}/src/main/resources/mbg.xml + true + + + + mysql + mysql-connector-java + 5.1.34 + + + + + org.springframework.boot + spring-boot-maven-plugin + + com.ccsens.dh_diplomatist.DhDiplomatistApplication + + + + + + repackage + + + + + + + + + + diff --git a/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/DhDiplomatistApplication.java b/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/DhDiplomatistApplication.java new file mode 100644 index 0000000..010a507 --- /dev/null +++ b/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/DhDiplomatistApplication.java @@ -0,0 +1,33 @@ +package com.ccsens.dh_diplomatist; + +import com.ccsens.cloudutil.ribbon.RibbonConfiguration; +import org.mybatis.spring.annotation.MapperScan; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.web.servlet.ServletComponentScan; +import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker; +import org.springframework.cloud.openfeign.EnableFeignClients; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.FilterType; +import org.springframework.scheduling.annotation.EnableAsync; +import org.springframework.scheduling.annotation.EnableScheduling; + +/** + * @author 逗 + */ +@MapperScan(basePackages = {"com.ccsens.dh_diplomatist.persist.*","com.ccsens.common.persist.*"}) +@ServletComponentScan +@EnableAsync +@EnableScheduling +//开启断路器功能 +@EnableCircuitBreaker +@EnableFeignClients(basePackages = "com.ccsens.cloudutil.feign") +@SpringBootApplication +@ComponentScan(basePackages = "com.ccsens", excludeFilters = { @ComponentScan.Filter(type= FilterType.ASSIGNABLE_TYPE, value = RibbonConfiguration.class)}) +public class DhDiplomatistApplication { + + public static void main(String[] args) { + SpringApplication.run(DhDiplomatistApplication.class, args); + } + +} diff --git a/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/api/DebugController.java b/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/api/DebugController.java new file mode 100644 index 0000000..033b7c5 --- /dev/null +++ b/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/api/DebugController.java @@ -0,0 +1,32 @@ +package com.ccsens.dh_diplomatist.api; + +import com.ccsens.util.JsonResponse; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +import javax.servlet.http.HttpServletRequest; + +/** + * @author 逗 + */ +@Api(tags = "DEBUG" , description = "DebugController | ") +@RestController +@RequestMapping("/debug") +@Slf4j +public class DebugController { + + @ApiOperation(value = "/测试",notes = "") + @ApiImplicitParams({ + }) + @RequestMapping(value="",method = RequestMethod.GET,produces = {"application/json;charset=UTF-8"}) + public JsonResponse debug(HttpServletRequest request) throws Exception { + + return JsonResponse.newInstance().ok("测试"); + } + +} diff --git a/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/api/DomainController.java b/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/api/DomainController.java new file mode 100644 index 0000000..653111c --- /dev/null +++ b/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/api/DomainController.java @@ -0,0 +1,58 @@ +package com.ccsens.dh_diplomatist.api; + +import cn.hutool.extra.servlet.ServletUtil; +import com.ccsens.dh_diplomatist.bean.dto.HeartbeatDto; +import com.ccsens.dh_diplomatist.bean.dto.UserDto; +import com.ccsens.dh_diplomatist.bean.vo.DomainVo; +import com.ccsens.dh_diplomatist.service.IDomainService; +import com.ccsens.util.JsonResponse; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import lombok.extern.slf4j.Slf4j; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import java.util.List; + +/** + * @author 逗 + */ +@Api(tags = "domain" , description = "域信息相关接口") +@RestController +@RequestMapping("/domain") +@Slf4j +public class DomainController { + @Resource + private IDomainService domainService; + + @ApiOperation(value = "查询用户关联的域列表(PT--传达室)", notes = "") + @RequestMapping(value = "/query", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) + public JsonResponse> queryDomainByPt(@ApiParam @Validated @RequestBody UserDto.PhoneAndIdCard params) throws Exception{ + log.info("PT查询用户关联的域列表:{}",params); + + log.info("PT查询用户关联的域列表返回:{}",params); + return JsonResponse.newInstance().ok(); + } + + @ApiOperation(value = "根据用户信息查询用户的访问权限(传达室--传达室)", notes = "") + @RequestMapping(value = "/queryByIdc", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) + public JsonResponse queryDomainByIdc(@ApiParam @Validated @RequestBody UserDto.PhoneAndIdCard params) throws Exception{ + log.info("根据用户信息查询用户的访问权限:{}",params); + + log.info("根据用户信息查询用户的访问权限返回:{}",params); + return JsonResponse.newInstance().ok(); + } + + @ApiOperation(value = "接收私域的请求返回域列表", notes = "") + @RequestMapping(value = "list", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) + public JsonResponse> heartbeatQueryList(HttpServletRequest request, + @ApiParam @Validated @RequestBody HeartbeatDto.SendDomain param) throws Exception{ + log.info("接收私域的查询域列表请求"); + List domainInfos = domainService.heartbeatQueryList(param, ServletUtil.getClientIP(request)); + log.info("返回域列表信息给私域:{}",domainInfos); + return JsonResponse.newInstance().ok(domainInfos); + } +} diff --git a/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/api/HeartbeatController.java b/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/api/HeartbeatController.java new file mode 100644 index 0000000..abb5be6 --- /dev/null +++ b/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/api/HeartbeatController.java @@ -0,0 +1,38 @@ +package com.ccsens.dh_diplomatist.api; + +import cn.hutool.extra.servlet.ServletUtil; +import com.ccsens.dh_diplomatist.bean.dto.HeartbeatDto; +import com.ccsens.dh_diplomatist.service.IHeartbeatService; +import com.ccsens.util.JsonResponse; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import lombok.extern.slf4j.Slf4j; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; + +/** + * @author 逗 + */ +@Api(tags = "heartbeat" , description = "域信息相关接口") +@RestController +@RequestMapping("/heartbeat") +@Slf4j +public class HeartbeatController { + @Resource + private IHeartbeatService heartbeatService; + + @ApiOperation(value = "接收私域的心跳", notes = "") + @RequestMapping(value = "", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) + public JsonResponse receiveHeartbeat(HttpServletRequest request, @ApiParam @Validated @RequestBody HeartbeatDto.SendDomain param) throws Exception{ + log.info("接收私域的心跳"); + heartbeatService.inHeartbeat(param,ServletUtil.getClientIP(request)); + log.info("接受心跳后正确返回"); + return JsonResponse.newInstance().ok(); + } + + +} diff --git a/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/api/UserController.java b/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/api/UserController.java new file mode 100644 index 0000000..c9c0ee9 --- /dev/null +++ b/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/api/UserController.java @@ -0,0 +1,35 @@ +package com.ccsens.dh_diplomatist.api; + +import io.swagger.annotations.Api; +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * @author 逗 + */ +@Api(tags = "user" , description = "用户信息相关接口") +@RestController +@RequestMapping("/user") +@Slf4j +public class UserController { + + +// @ApiOperation(value = "tall调用数据中心添加用户", notes = "") +// @RequestMapping(value = "/saveUserByTall", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) +// public JsonResponse saveUserByTall(@ApiParam @Validated @RequestBody UserDto.DomainUser params) throws Exception{ +// log.info("tall调用数据中心添加用户:{}",params); +// +// log.info("tall调用数据中心添加用户成功"); +// return JsonResponse.newInstance().ok(); +// } +// +// @ApiOperation(value = "私域调用公域数据中心添加用户", notes = "") +// @RequestMapping(value = "/saveUserByIdc", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) +// public JsonResponse saveUserByIdc(@ApiParam @Validated @RequestBody UserDto.DomainUser params) throws Exception{ +// log.info("私域调用公域数据中心添加用户:{}",params); +// +// log.info("私域调用公域数据中心添加用户成功"); +// return JsonResponse.newInstance().ok(); +// } +} diff --git a/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/bean/dto/HeartbeatDto.java b/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/bean/dto/HeartbeatDto.java new file mode 100644 index 0000000..9f528e0 --- /dev/null +++ b/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/bean/dto/HeartbeatDto.java @@ -0,0 +1,37 @@ +package com.ccsens.dh_diplomatist.bean.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author 逗 + */ +public class HeartbeatDto { + + @Data + @ApiModel("域之间传递的信息") + public static class SendDomain { + @ApiModelProperty("域code") + private String code; + @ApiModelProperty("发送时的时间戳") + private Long timestamp; + @ApiModelProperty("随机码") + private String noncestr; + @ApiModelProperty("签名后信息") + private byte[] data; + } + + @Data + @ApiModel("心跳里的域信息") + public static class MessageDomainInfo { + @ApiModelProperty("域id") + private Long id; + @ApiModelProperty("域名称") + private String name; + @ApiModelProperty("域code") + private String code; + @ApiModelProperty("ip") + private String host; + } +} diff --git a/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/bean/dto/UserDto.java b/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/bean/dto/UserDto.java new file mode 100644 index 0000000..c5aa079 --- /dev/null +++ b/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/bean/dto/UserDto.java @@ -0,0 +1,37 @@ +package com.ccsens.dh_diplomatist.bean.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +/** + * @author 逗 + */ +@Data +public class UserDto { + + @Data + @ApiModel("用户身份证和手机号") + public static class PhoneAndIdCard{ + @ApiModelProperty("手机号") + private String phone; + @ApiModelProperty("身份证号") + private String idCard; + } + + @Data + @ApiModel("域内用户信息") + public static class DomainUser{ + @ApiModelProperty("手机号") + private String name; + @ApiModelProperty("身份证号") + private String code; + @ApiModelProperty("身份证号") + private String domainName; + @ApiModelProperty("身份证号") + private List userList; + } + +} diff --git a/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/bean/po/IdcBusiness.java b/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/bean/po/IdcBusiness.java new file mode 100644 index 0000000..fde211e --- /dev/null +++ b/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/bean/po/IdcBusiness.java @@ -0,0 +1,117 @@ +package com.ccsens.dh_diplomatist.bean.po; + +import java.io.Serializable; +import java.util.Date; + +public class IdcBusiness implements Serializable { + private Long id; + + private String name; + + private String code; + + private String description; + + private Long creatorId; + + private Long operator; + + private Date createdAt; + + private Date updatedAt; + + private Byte recStatus; + + private static final long serialVersionUID = 1L; + + 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 == null ? null : name.trim(); + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code == null ? null : code.trim(); + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description == null ? null : description.trim(); + } + + public Long getCreatorId() { + return creatorId; + } + + public void setCreatorId(Long creatorId) { + this.creatorId = creatorId; + } + + public Long getOperator() { + return operator; + } + + public void setOperator(Long operator) { + this.operator = operator; + } + + public Date getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(Date createdAt) { + this.createdAt = createdAt; + } + + public Date getUpdatedAt() { + return updatedAt; + } + + public void setUpdatedAt(Date updatedAt) { + this.updatedAt = updatedAt; + } + + public Byte getRecStatus() { + return recStatus; + } + + public void setRecStatus(Byte recStatus) { + this.recStatus = recStatus; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append(getClass().getSimpleName()); + sb.append(" ["); + sb.append("Hash = ").append(hashCode()); + sb.append(", id=").append(id); + sb.append(", name=").append(name); + sb.append(", code=").append(code); + sb.append(", description=").append(description); + sb.append(", creatorId=").append(creatorId); + sb.append(", operator=").append(operator); + sb.append(", createdAt=").append(createdAt); + sb.append(", updatedAt=").append(updatedAt); + sb.append(", recStatus=").append(recStatus); + sb.append("]"); + return sb.toString(); + } +} \ No newline at end of file diff --git a/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/bean/po/IdcBusinessExample.java b/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/bean/po/IdcBusinessExample.java new file mode 100644 index 0000000..82a95be --- /dev/null +++ b/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/bean/po/IdcBusinessExample.java @@ -0,0 +1,771 @@ +package com.ccsens.dh_diplomatist.bean.po; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +public class IdcBusinessExample { + protected String orderByClause; + + protected boolean distinct; + + protected List oredCriteria; + + public IdcBusinessExample() { + oredCriteria = new ArrayList(); + } + + public void setOrderByClause(String orderByClause) { + this.orderByClause = orderByClause; + } + + public String getOrderByClause() { + return orderByClause; + } + + public void setDistinct(boolean distinct) { + this.distinct = distinct; + } + + public boolean isDistinct() { + return distinct; + } + + public List getOredCriteria() { + return oredCriteria; + } + + public void or(Criteria criteria) { + oredCriteria.add(criteria); + } + + public Criteria or() { + Criteria criteria = createCriteriaInternal(); + oredCriteria.add(criteria); + return criteria; + } + + public Criteria createCriteria() { + Criteria criteria = createCriteriaInternal(); + if (oredCriteria.size() == 0) { + oredCriteria.add(criteria); + } + return criteria; + } + + protected Criteria createCriteriaInternal() { + Criteria criteria = new Criteria(); + return criteria; + } + + public void clear() { + oredCriteria.clear(); + orderByClause = null; + distinct = false; + } + + protected abstract static class GeneratedCriteria { + protected List criteria; + + protected GeneratedCriteria() { + super(); + criteria = new ArrayList(); + } + + public boolean isValid() { + return criteria.size() > 0; + } + + public List getAllCriteria() { + return criteria; + } + + public List getCriteria() { + return criteria; + } + + protected void addCriterion(String condition) { + if (condition == null) { + throw new RuntimeException("Value for condition cannot be null"); + } + criteria.add(new Criterion(condition)); + } + + protected void addCriterion(String condition, Object value, String property) { + if (value == null) { + throw new RuntimeException("Value for " + property + " cannot be null"); + } + criteria.add(new Criterion(condition, value)); + } + + protected void addCriterion(String condition, Object value1, Object value2, String property) { + if (value1 == null || value2 == null) { + throw new RuntimeException("Between values for " + property + " cannot be null"); + } + criteria.add(new Criterion(condition, value1, value2)); + } + + public Criteria andIdIsNull() { + addCriterion("id is null"); + return (Criteria) this; + } + + public Criteria andIdIsNotNull() { + addCriterion("id is not null"); + return (Criteria) this; + } + + public Criteria andIdEqualTo(Long value) { + addCriterion("id =", value, "id"); + return (Criteria) this; + } + + public Criteria andIdNotEqualTo(Long value) { + addCriterion("id <>", value, "id"); + return (Criteria) this; + } + + public Criteria andIdGreaterThan(Long value) { + addCriterion("id >", value, "id"); + return (Criteria) this; + } + + public Criteria andIdGreaterThanOrEqualTo(Long value) { + addCriterion("id >=", value, "id"); + return (Criteria) this; + } + + public Criteria andIdLessThan(Long value) { + addCriterion("id <", value, "id"); + return (Criteria) this; + } + + public Criteria andIdLessThanOrEqualTo(Long value) { + addCriterion("id <=", value, "id"); + return (Criteria) this; + } + + public Criteria andIdIn(List values) { + addCriterion("id in", values, "id"); + return (Criteria) this; + } + + public Criteria andIdNotIn(List values) { + addCriterion("id not in", values, "id"); + return (Criteria) this; + } + + public Criteria andIdBetween(Long value1, Long value2) { + addCriterion("id between", value1, value2, "id"); + return (Criteria) this; + } + + public Criteria andIdNotBetween(Long value1, Long value2) { + addCriterion("id not between", value1, value2, "id"); + return (Criteria) this; + } + + public Criteria andNameIsNull() { + addCriterion("name is null"); + return (Criteria) this; + } + + public Criteria andNameIsNotNull() { + addCriterion("name is not null"); + return (Criteria) this; + } + + public Criteria andNameEqualTo(String value) { + addCriterion("name =", value, "name"); + return (Criteria) this; + } + + public Criteria andNameNotEqualTo(String value) { + addCriterion("name <>", value, "name"); + return (Criteria) this; + } + + public Criteria andNameGreaterThan(String value) { + addCriterion("name >", value, "name"); + return (Criteria) this; + } + + public Criteria andNameGreaterThanOrEqualTo(String value) { + addCriterion("name >=", value, "name"); + return (Criteria) this; + } + + public Criteria andNameLessThan(String value) { + addCriterion("name <", value, "name"); + return (Criteria) this; + } + + public Criteria andNameLessThanOrEqualTo(String value) { + addCriterion("name <=", value, "name"); + return (Criteria) this; + } + + public Criteria andNameLike(String value) { + addCriterion("name like", value, "name"); + return (Criteria) this; + } + + public Criteria andNameNotLike(String value) { + addCriterion("name not like", value, "name"); + return (Criteria) this; + } + + public Criteria andNameIn(List values) { + addCriterion("name in", values, "name"); + return (Criteria) this; + } + + public Criteria andNameNotIn(List values) { + addCriterion("name not in", values, "name"); + return (Criteria) this; + } + + public Criteria andNameBetween(String value1, String value2) { + addCriterion("name between", value1, value2, "name"); + return (Criteria) this; + } + + public Criteria andNameNotBetween(String value1, String value2) { + addCriterion("name not between", value1, value2, "name"); + return (Criteria) this; + } + + public Criteria andCodeIsNull() { + addCriterion("code is null"); + return (Criteria) this; + } + + public Criteria andCodeIsNotNull() { + addCriterion("code is not null"); + return (Criteria) this; + } + + public Criteria andCodeEqualTo(String value) { + addCriterion("code =", value, "code"); + return (Criteria) this; + } + + public Criteria andCodeNotEqualTo(String value) { + addCriterion("code <>", value, "code"); + return (Criteria) this; + } + + public Criteria andCodeGreaterThan(String value) { + addCriterion("code >", value, "code"); + return (Criteria) this; + } + + public Criteria andCodeGreaterThanOrEqualTo(String value) { + addCriterion("code >=", value, "code"); + return (Criteria) this; + } + + public Criteria andCodeLessThan(String value) { + addCriterion("code <", value, "code"); + return (Criteria) this; + } + + public Criteria andCodeLessThanOrEqualTo(String value) { + addCriterion("code <=", value, "code"); + return (Criteria) this; + } + + public Criteria andCodeLike(String value) { + addCriterion("code like", value, "code"); + return (Criteria) this; + } + + public Criteria andCodeNotLike(String value) { + addCriterion("code not like", value, "code"); + return (Criteria) this; + } + + public Criteria andCodeIn(List values) { + addCriterion("code in", values, "code"); + return (Criteria) this; + } + + public Criteria andCodeNotIn(List values) { + addCriterion("code not in", values, "code"); + return (Criteria) this; + } + + public Criteria andCodeBetween(String value1, String value2) { + addCriterion("code between", value1, value2, "code"); + return (Criteria) this; + } + + public Criteria andCodeNotBetween(String value1, String value2) { + addCriterion("code not between", value1, value2, "code"); + return (Criteria) this; + } + + public Criteria andDescriptionIsNull() { + addCriterion("description is null"); + return (Criteria) this; + } + + public Criteria andDescriptionIsNotNull() { + addCriterion("description is not null"); + return (Criteria) this; + } + + public Criteria andDescriptionEqualTo(String value) { + addCriterion("description =", value, "description"); + return (Criteria) this; + } + + public Criteria andDescriptionNotEqualTo(String value) { + addCriterion("description <>", value, "description"); + return (Criteria) this; + } + + public Criteria andDescriptionGreaterThan(String value) { + addCriterion("description >", value, "description"); + return (Criteria) this; + } + + public Criteria andDescriptionGreaterThanOrEqualTo(String value) { + addCriterion("description >=", value, "description"); + return (Criteria) this; + } + + public Criteria andDescriptionLessThan(String value) { + addCriterion("description <", value, "description"); + return (Criteria) this; + } + + public Criteria andDescriptionLessThanOrEqualTo(String value) { + addCriterion("description <=", value, "description"); + return (Criteria) this; + } + + public Criteria andDescriptionLike(String value) { + addCriterion("description like", value, "description"); + return (Criteria) this; + } + + public Criteria andDescriptionNotLike(String value) { + addCriterion("description not like", value, "description"); + return (Criteria) this; + } + + public Criteria andDescriptionIn(List values) { + addCriterion("description in", values, "description"); + return (Criteria) this; + } + + public Criteria andDescriptionNotIn(List values) { + addCriterion("description not in", values, "description"); + return (Criteria) this; + } + + public Criteria andDescriptionBetween(String value1, String value2) { + addCriterion("description between", value1, value2, "description"); + return (Criteria) this; + } + + public Criteria andDescriptionNotBetween(String value1, String value2) { + addCriterion("description not between", value1, value2, "description"); + return (Criteria) this; + } + + public Criteria andCreatorIdIsNull() { + addCriterion("creator_id is null"); + return (Criteria) this; + } + + public Criteria andCreatorIdIsNotNull() { + addCriterion("creator_id is not null"); + return (Criteria) this; + } + + public Criteria andCreatorIdEqualTo(Long value) { + addCriterion("creator_id =", value, "creatorId"); + return (Criteria) this; + } + + public Criteria andCreatorIdNotEqualTo(Long value) { + addCriterion("creator_id <>", value, "creatorId"); + return (Criteria) this; + } + + public Criteria andCreatorIdGreaterThan(Long value) { + addCriterion("creator_id >", value, "creatorId"); + return (Criteria) this; + } + + public Criteria andCreatorIdGreaterThanOrEqualTo(Long value) { + addCriterion("creator_id >=", value, "creatorId"); + return (Criteria) this; + } + + public Criteria andCreatorIdLessThan(Long value) { + addCriterion("creator_id <", value, "creatorId"); + return (Criteria) this; + } + + public Criteria andCreatorIdLessThanOrEqualTo(Long value) { + addCriterion("creator_id <=", value, "creatorId"); + return (Criteria) this; + } + + public Criteria andCreatorIdIn(List values) { + addCriterion("creator_id in", values, "creatorId"); + return (Criteria) this; + } + + public Criteria andCreatorIdNotIn(List values) { + addCriterion("creator_id not in", values, "creatorId"); + return (Criteria) this; + } + + public Criteria andCreatorIdBetween(Long value1, Long value2) { + addCriterion("creator_id between", value1, value2, "creatorId"); + return (Criteria) this; + } + + public Criteria andCreatorIdNotBetween(Long value1, Long value2) { + addCriterion("creator_id not between", value1, value2, "creatorId"); + return (Criteria) this; + } + + public Criteria andOperatorIsNull() { + addCriterion("operator is null"); + return (Criteria) this; + } + + public Criteria andOperatorIsNotNull() { + addCriterion("operator is not null"); + return (Criteria) this; + } + + public Criteria andOperatorEqualTo(Long value) { + addCriterion("operator =", value, "operator"); + return (Criteria) this; + } + + public Criteria andOperatorNotEqualTo(Long value) { + addCriterion("operator <>", value, "operator"); + return (Criteria) this; + } + + public Criteria andOperatorGreaterThan(Long value) { + addCriterion("operator >", value, "operator"); + return (Criteria) this; + } + + public Criteria andOperatorGreaterThanOrEqualTo(Long value) { + addCriterion("operator >=", value, "operator"); + return (Criteria) this; + } + + public Criteria andOperatorLessThan(Long value) { + addCriterion("operator <", value, "operator"); + return (Criteria) this; + } + + public Criteria andOperatorLessThanOrEqualTo(Long value) { + addCriterion("operator <=", value, "operator"); + return (Criteria) this; + } + + public Criteria andOperatorIn(List values) { + addCriterion("operator in", values, "operator"); + return (Criteria) this; + } + + public Criteria andOperatorNotIn(List values) { + addCriterion("operator not in", values, "operator"); + return (Criteria) this; + } + + public Criteria andOperatorBetween(Long value1, Long value2) { + addCriterion("operator between", value1, value2, "operator"); + return (Criteria) this; + } + + public Criteria andOperatorNotBetween(Long value1, Long value2) { + addCriterion("operator not between", value1, value2, "operator"); + return (Criteria) this; + } + + public Criteria andCreatedAtIsNull() { + addCriterion("created_at is null"); + return (Criteria) this; + } + + public Criteria andCreatedAtIsNotNull() { + addCriterion("created_at is not null"); + return (Criteria) this; + } + + public Criteria andCreatedAtEqualTo(Date value) { + addCriterion("created_at =", value, "createdAt"); + return (Criteria) this; + } + + public Criteria andCreatedAtNotEqualTo(Date value) { + addCriterion("created_at <>", value, "createdAt"); + return (Criteria) this; + } + + public Criteria andCreatedAtGreaterThan(Date value) { + addCriterion("created_at >", value, "createdAt"); + return (Criteria) this; + } + + public Criteria andCreatedAtGreaterThanOrEqualTo(Date value) { + addCriterion("created_at >=", value, "createdAt"); + return (Criteria) this; + } + + public Criteria andCreatedAtLessThan(Date value) { + addCriterion("created_at <", value, "createdAt"); + return (Criteria) this; + } + + public Criteria andCreatedAtLessThanOrEqualTo(Date value) { + addCriterion("created_at <=", value, "createdAt"); + return (Criteria) this; + } + + public Criteria andCreatedAtIn(List values) { + addCriterion("created_at in", values, "createdAt"); + return (Criteria) this; + } + + public Criteria andCreatedAtNotIn(List values) { + addCriterion("created_at not in", values, "createdAt"); + return (Criteria) this; + } + + public Criteria andCreatedAtBetween(Date value1, Date value2) { + addCriterion("created_at between", value1, value2, "createdAt"); + return (Criteria) this; + } + + public Criteria andCreatedAtNotBetween(Date value1, Date value2) { + addCriterion("created_at not between", value1, value2, "createdAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtIsNull() { + addCriterion("updated_at is null"); + return (Criteria) this; + } + + public Criteria andUpdatedAtIsNotNull() { + addCriterion("updated_at is not null"); + return (Criteria) this; + } + + public Criteria andUpdatedAtEqualTo(Date value) { + addCriterion("updated_at =", value, "updatedAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtNotEqualTo(Date value) { + addCriterion("updated_at <>", value, "updatedAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtGreaterThan(Date value) { + addCriterion("updated_at >", value, "updatedAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtGreaterThanOrEqualTo(Date value) { + addCriterion("updated_at >=", value, "updatedAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtLessThan(Date value) { + addCriterion("updated_at <", value, "updatedAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtLessThanOrEqualTo(Date value) { + addCriterion("updated_at <=", value, "updatedAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtIn(List values) { + addCriterion("updated_at in", values, "updatedAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtNotIn(List values) { + addCriterion("updated_at not in", values, "updatedAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtBetween(Date value1, Date value2) { + addCriterion("updated_at between", value1, value2, "updatedAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtNotBetween(Date value1, Date value2) { + addCriterion("updated_at not between", value1, value2, "updatedAt"); + return (Criteria) this; + } + + public Criteria andRecStatusIsNull() { + addCriterion("rec_status is null"); + return (Criteria) this; + } + + public Criteria andRecStatusIsNotNull() { + addCriterion("rec_status is not null"); + return (Criteria) this; + } + + public Criteria andRecStatusEqualTo(Byte value) { + addCriterion("rec_status =", value, "recStatus"); + return (Criteria) this; + } + + public Criteria andRecStatusNotEqualTo(Byte value) { + addCriterion("rec_status <>", value, "recStatus"); + return (Criteria) this; + } + + public Criteria andRecStatusGreaterThan(Byte value) { + addCriterion("rec_status >", value, "recStatus"); + return (Criteria) this; + } + + public Criteria andRecStatusGreaterThanOrEqualTo(Byte value) { + addCriterion("rec_status >=", value, "recStatus"); + return (Criteria) this; + } + + public Criteria andRecStatusLessThan(Byte value) { + addCriterion("rec_status <", value, "recStatus"); + return (Criteria) this; + } + + public Criteria andRecStatusLessThanOrEqualTo(Byte value) { + addCriterion("rec_status <=", value, "recStatus"); + return (Criteria) this; + } + + public Criteria andRecStatusIn(List values) { + addCriterion("rec_status in", values, "recStatus"); + return (Criteria) this; + } + + public Criteria andRecStatusNotIn(List values) { + addCriterion("rec_status not in", values, "recStatus"); + return (Criteria) this; + } + + public Criteria andRecStatusBetween(Byte value1, Byte value2) { + addCriterion("rec_status between", value1, value2, "recStatus"); + return (Criteria) this; + } + + public Criteria andRecStatusNotBetween(Byte value1, Byte value2) { + addCriterion("rec_status not between", value1, value2, "recStatus"); + return (Criteria) this; + } + } + + public static class Criteria extends GeneratedCriteria { + + protected Criteria() { + super(); + } + } + + public static class Criterion { + private String condition; + + private Object value; + + private Object secondValue; + + private boolean noValue; + + private boolean singleValue; + + private boolean betweenValue; + + private boolean listValue; + + private String typeHandler; + + public String getCondition() { + return condition; + } + + public Object getValue() { + return value; + } + + public Object getSecondValue() { + return secondValue; + } + + public boolean isNoValue() { + return noValue; + } + + public boolean isSingleValue() { + return singleValue; + } + + public boolean isBetweenValue() { + return betweenValue; + } + + public boolean isListValue() { + return listValue; + } + + public String getTypeHandler() { + return typeHandler; + } + + protected Criterion(String condition) { + super(); + this.condition = condition; + this.typeHandler = null; + this.noValue = true; + } + + protected Criterion(String condition, Object value, String typeHandler) { + super(); + this.condition = condition; + this.value = value; + this.typeHandler = typeHandler; + if (value instanceof List) { + this.listValue = true; + } else { + this.singleValue = true; + } + } + + protected Criterion(String condition, Object value) { + this(condition, value, null); + } + + protected Criterion(String condition, Object value, Object secondValue, String typeHandler) { + super(); + this.condition = condition; + this.value = value; + this.secondValue = secondValue; + this.typeHandler = typeHandler; + this.betweenValue = true; + } + + protected Criterion(String condition, Object value, Object secondValue) { + this(condition, value, secondValue, null); + } + } +} \ No newline at end of file diff --git a/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/bean/po/IdcDomain.java b/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/bean/po/IdcDomain.java new file mode 100644 index 0000000..1b8351e --- /dev/null +++ b/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/bean/po/IdcDomain.java @@ -0,0 +1,227 @@ +package com.ccsens.dh_diplomatist.bean.po; + +import java.io.Serializable; +import java.util.Date; + +public class IdcDomain implements Serializable { + private Long id; + + private String name; + + private String code; + + private String intro; + + private String url; + + private String host; + + private Byte self; + + private Byte pub; + + private Byte polling; + + private Byte answer; + + private Long lastUpdateTime; + + private Long lastAskTime; + + private Long lastAnswerTime; + + private String publicKey; + + private String privateKey; + + private Long operator; + + private Date createdAt; + + private Date updatedAt; + + private Byte recStatus; + + private static final long serialVersionUID = 1L; + + 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 == null ? null : name.trim(); + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code == null ? null : code.trim(); + } + + public String getIntro() { + return intro; + } + + public void setIntro(String intro) { + this.intro = intro == null ? null : intro.trim(); + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url == null ? null : url.trim(); + } + + public String getHost() { + return host; + } + + public void setHost(String host) { + this.host = host == null ? null : host.trim(); + } + + public Byte getSelf() { + return self; + } + + public void setSelf(Byte self) { + this.self = self; + } + + public Byte getPub() { + return pub; + } + + public void setPub(Byte pub) { + this.pub = pub; + } + + public Byte getPolling() { + return polling; + } + + public void setPolling(Byte polling) { + this.polling = polling; + } + + public Byte getAnswer() { + return answer; + } + + public void setAnswer(Byte answer) { + this.answer = answer; + } + + public Long getLastUpdateTime() { + return lastUpdateTime; + } + + public void setLastUpdateTime(Long lastUpdateTime) { + this.lastUpdateTime = lastUpdateTime; + } + + public Long getLastAskTime() { + return lastAskTime; + } + + public void setLastAskTime(Long lastAskTime) { + this.lastAskTime = lastAskTime; + } + + public Long getLastAnswerTime() { + return lastAnswerTime; + } + + public void setLastAnswerTime(Long lastAnswerTime) { + this.lastAnswerTime = lastAnswerTime; + } + + public String getPublicKey() { + return publicKey; + } + + public void setPublicKey(String publicKey) { + this.publicKey = publicKey == null ? null : publicKey.trim(); + } + + public String getPrivateKey() { + return privateKey; + } + + public void setPrivateKey(String privateKey) { + this.privateKey = privateKey == null ? null : privateKey.trim(); + } + + public Long getOperator() { + return operator; + } + + public void setOperator(Long operator) { + this.operator = operator; + } + + public Date getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(Date createdAt) { + this.createdAt = createdAt; + } + + public Date getUpdatedAt() { + return updatedAt; + } + + public void setUpdatedAt(Date updatedAt) { + this.updatedAt = updatedAt; + } + + public Byte getRecStatus() { + return recStatus; + } + + public void setRecStatus(Byte recStatus) { + this.recStatus = recStatus; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append(getClass().getSimpleName()); + sb.append(" ["); + sb.append("Hash = ").append(hashCode()); + sb.append(", id=").append(id); + sb.append(", name=").append(name); + sb.append(", code=").append(code); + sb.append(", intro=").append(intro); + sb.append(", url=").append(url); + sb.append(", host=").append(host); + sb.append(", self=").append(self); + sb.append(", pub=").append(pub); + sb.append(", polling=").append(polling); + sb.append(", answer=").append(answer); + sb.append(", lastUpdateTime=").append(lastUpdateTime); + sb.append(", lastAskTime=").append(lastAskTime); + sb.append(", lastAnswerTime=").append(lastAnswerTime); + sb.append(", publicKey=").append(publicKey); + sb.append(", privateKey=").append(privateKey); + sb.append(", operator=").append(operator); + sb.append(", createdAt=").append(createdAt); + sb.append(", updatedAt=").append(updatedAt); + sb.append(", recStatus=").append(recStatus); + sb.append("]"); + return sb.toString(); + } +} \ No newline at end of file diff --git a/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/bean/po/IdcDomainBusiness.java b/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/bean/po/IdcDomainBusiness.java new file mode 100644 index 0000000..73f0792 --- /dev/null +++ b/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/bean/po/IdcDomainBusiness.java @@ -0,0 +1,128 @@ +package com.ccsens.dh_diplomatist.bean.po; + +import java.io.Serializable; +import java.util.Date; + +public class IdcDomainBusiness implements Serializable { + private Long id; + + private Long domainId; + + private Long businessId; + + private String url; + + private String appId; + + private String secret; + + private Long operator; + + private Date createdAt; + + private Date updatedAt; + + private Byte recStatus; + + private static final long serialVersionUID = 1L; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Long getDomainId() { + return domainId; + } + + public void setDomainId(Long domainId) { + this.domainId = domainId; + } + + public Long getBusinessId() { + return businessId; + } + + public void setBusinessId(Long businessId) { + this.businessId = businessId; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url == null ? null : url.trim(); + } + + public String getAppId() { + return appId; + } + + public void setAppId(String appId) { + this.appId = appId == null ? null : appId.trim(); + } + + public String getSecret() { + return secret; + } + + public void setSecret(String secret) { + this.secret = secret == null ? null : secret.trim(); + } + + public Long getOperator() { + return operator; + } + + public void setOperator(Long operator) { + this.operator = operator; + } + + public Date getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(Date createdAt) { + this.createdAt = createdAt; + } + + public Date getUpdatedAt() { + return updatedAt; + } + + public void setUpdatedAt(Date updatedAt) { + this.updatedAt = updatedAt; + } + + public Byte getRecStatus() { + return recStatus; + } + + public void setRecStatus(Byte recStatus) { + this.recStatus = recStatus; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append(getClass().getSimpleName()); + sb.append(" ["); + sb.append("Hash = ").append(hashCode()); + sb.append(", id=").append(id); + sb.append(", domainId=").append(domainId); + sb.append(", businessId=").append(businessId); + sb.append(", url=").append(url); + sb.append(", appId=").append(appId); + sb.append(", secret=").append(secret); + sb.append(", operator=").append(operator); + sb.append(", createdAt=").append(createdAt); + sb.append(", updatedAt=").append(updatedAt); + sb.append(", recStatus=").append(recStatus); + sb.append("]"); + return sb.toString(); + } +} \ No newline at end of file diff --git a/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/bean/po/IdcDomainBusinessExample.java b/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/bean/po/IdcDomainBusinessExample.java new file mode 100644 index 0000000..ffd4e74 --- /dev/null +++ b/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/bean/po/IdcDomainBusinessExample.java @@ -0,0 +1,831 @@ +package com.ccsens.dh_diplomatist.bean.po; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +public class IdcDomainBusinessExample { + protected String orderByClause; + + protected boolean distinct; + + protected List oredCriteria; + + public IdcDomainBusinessExample() { + oredCriteria = new ArrayList(); + } + + public void setOrderByClause(String orderByClause) { + this.orderByClause = orderByClause; + } + + public String getOrderByClause() { + return orderByClause; + } + + public void setDistinct(boolean distinct) { + this.distinct = distinct; + } + + public boolean isDistinct() { + return distinct; + } + + public List getOredCriteria() { + return oredCriteria; + } + + public void or(Criteria criteria) { + oredCriteria.add(criteria); + } + + public Criteria or() { + Criteria criteria = createCriteriaInternal(); + oredCriteria.add(criteria); + return criteria; + } + + public Criteria createCriteria() { + Criteria criteria = createCriteriaInternal(); + if (oredCriteria.size() == 0) { + oredCriteria.add(criteria); + } + return criteria; + } + + protected Criteria createCriteriaInternal() { + Criteria criteria = new Criteria(); + return criteria; + } + + public void clear() { + oredCriteria.clear(); + orderByClause = null; + distinct = false; + } + + protected abstract static class GeneratedCriteria { + protected List criteria; + + protected GeneratedCriteria() { + super(); + criteria = new ArrayList(); + } + + public boolean isValid() { + return criteria.size() > 0; + } + + public List getAllCriteria() { + return criteria; + } + + public List getCriteria() { + return criteria; + } + + protected void addCriterion(String condition) { + if (condition == null) { + throw new RuntimeException("Value for condition cannot be null"); + } + criteria.add(new Criterion(condition)); + } + + protected void addCriterion(String condition, Object value, String property) { + if (value == null) { + throw new RuntimeException("Value for " + property + " cannot be null"); + } + criteria.add(new Criterion(condition, value)); + } + + protected void addCriterion(String condition, Object value1, Object value2, String property) { + if (value1 == null || value2 == null) { + throw new RuntimeException("Between values for " + property + " cannot be null"); + } + criteria.add(new Criterion(condition, value1, value2)); + } + + public Criteria andIdIsNull() { + addCriterion("id is null"); + return (Criteria) this; + } + + public Criteria andIdIsNotNull() { + addCriterion("id is not null"); + return (Criteria) this; + } + + public Criteria andIdEqualTo(Long value) { + addCriterion("id =", value, "id"); + return (Criteria) this; + } + + public Criteria andIdNotEqualTo(Long value) { + addCriterion("id <>", value, "id"); + return (Criteria) this; + } + + public Criteria andIdGreaterThan(Long value) { + addCriterion("id >", value, "id"); + return (Criteria) this; + } + + public Criteria andIdGreaterThanOrEqualTo(Long value) { + addCriterion("id >=", value, "id"); + return (Criteria) this; + } + + public Criteria andIdLessThan(Long value) { + addCriterion("id <", value, "id"); + return (Criteria) this; + } + + public Criteria andIdLessThanOrEqualTo(Long value) { + addCriterion("id <=", value, "id"); + return (Criteria) this; + } + + public Criteria andIdIn(List values) { + addCriterion("id in", values, "id"); + return (Criteria) this; + } + + public Criteria andIdNotIn(List values) { + addCriterion("id not in", values, "id"); + return (Criteria) this; + } + + public Criteria andIdBetween(Long value1, Long value2) { + addCriterion("id between", value1, value2, "id"); + return (Criteria) this; + } + + public Criteria andIdNotBetween(Long value1, Long value2) { + addCriterion("id not between", value1, value2, "id"); + return (Criteria) this; + } + + public Criteria andDomainIdIsNull() { + addCriterion("domain_id is null"); + return (Criteria) this; + } + + public Criteria andDomainIdIsNotNull() { + addCriterion("domain_id is not null"); + return (Criteria) this; + } + + public Criteria andDomainIdEqualTo(Long value) { + addCriterion("domain_id =", value, "domainId"); + return (Criteria) this; + } + + public Criteria andDomainIdNotEqualTo(Long value) { + addCriterion("domain_id <>", value, "domainId"); + return (Criteria) this; + } + + public Criteria andDomainIdGreaterThan(Long value) { + addCriterion("domain_id >", value, "domainId"); + return (Criteria) this; + } + + public Criteria andDomainIdGreaterThanOrEqualTo(Long value) { + addCriterion("domain_id >=", value, "domainId"); + return (Criteria) this; + } + + public Criteria andDomainIdLessThan(Long value) { + addCriterion("domain_id <", value, "domainId"); + return (Criteria) this; + } + + public Criteria andDomainIdLessThanOrEqualTo(Long value) { + addCriterion("domain_id <=", value, "domainId"); + return (Criteria) this; + } + + public Criteria andDomainIdIn(List values) { + addCriterion("domain_id in", values, "domainId"); + return (Criteria) this; + } + + public Criteria andDomainIdNotIn(List values) { + addCriterion("domain_id not in", values, "domainId"); + return (Criteria) this; + } + + public Criteria andDomainIdBetween(Long value1, Long value2) { + addCriterion("domain_id between", value1, value2, "domainId"); + return (Criteria) this; + } + + public Criteria andDomainIdNotBetween(Long value1, Long value2) { + addCriterion("domain_id not between", value1, value2, "domainId"); + return (Criteria) this; + } + + public Criteria andBusinessIdIsNull() { + addCriterion("business_id is null"); + return (Criteria) this; + } + + public Criteria andBusinessIdIsNotNull() { + addCriterion("business_id is not null"); + return (Criteria) this; + } + + public Criteria andBusinessIdEqualTo(Long value) { + addCriterion("business_id =", value, "businessId"); + return (Criteria) this; + } + + public Criteria andBusinessIdNotEqualTo(Long value) { + addCriterion("business_id <>", value, "businessId"); + return (Criteria) this; + } + + public Criteria andBusinessIdGreaterThan(Long value) { + addCriterion("business_id >", value, "businessId"); + return (Criteria) this; + } + + public Criteria andBusinessIdGreaterThanOrEqualTo(Long value) { + addCriterion("business_id >=", value, "businessId"); + return (Criteria) this; + } + + public Criteria andBusinessIdLessThan(Long value) { + addCriterion("business_id <", value, "businessId"); + return (Criteria) this; + } + + public Criteria andBusinessIdLessThanOrEqualTo(Long value) { + addCriterion("business_id <=", value, "businessId"); + return (Criteria) this; + } + + public Criteria andBusinessIdIn(List values) { + addCriterion("business_id in", values, "businessId"); + return (Criteria) this; + } + + public Criteria andBusinessIdNotIn(List values) { + addCriterion("business_id not in", values, "businessId"); + return (Criteria) this; + } + + public Criteria andBusinessIdBetween(Long value1, Long value2) { + addCriterion("business_id between", value1, value2, "businessId"); + return (Criteria) this; + } + + public Criteria andBusinessIdNotBetween(Long value1, Long value2) { + addCriterion("business_id not between", value1, value2, "businessId"); + return (Criteria) this; + } + + public Criteria andUrlIsNull() { + addCriterion("url is null"); + return (Criteria) this; + } + + public Criteria andUrlIsNotNull() { + addCriterion("url is not null"); + return (Criteria) this; + } + + public Criteria andUrlEqualTo(String value) { + addCriterion("url =", value, "url"); + return (Criteria) this; + } + + public Criteria andUrlNotEqualTo(String value) { + addCriterion("url <>", value, "url"); + return (Criteria) this; + } + + public Criteria andUrlGreaterThan(String value) { + addCriterion("url >", value, "url"); + return (Criteria) this; + } + + public Criteria andUrlGreaterThanOrEqualTo(String value) { + addCriterion("url >=", value, "url"); + return (Criteria) this; + } + + public Criteria andUrlLessThan(String value) { + addCriterion("url <", value, "url"); + return (Criteria) this; + } + + public Criteria andUrlLessThanOrEqualTo(String value) { + addCriterion("url <=", value, "url"); + return (Criteria) this; + } + + public Criteria andUrlLike(String value) { + addCriterion("url like", value, "url"); + return (Criteria) this; + } + + public Criteria andUrlNotLike(String value) { + addCriterion("url not like", value, "url"); + return (Criteria) this; + } + + public Criteria andUrlIn(List values) { + addCriterion("url in", values, "url"); + return (Criteria) this; + } + + public Criteria andUrlNotIn(List values) { + addCriterion("url not in", values, "url"); + return (Criteria) this; + } + + public Criteria andUrlBetween(String value1, String value2) { + addCriterion("url between", value1, value2, "url"); + return (Criteria) this; + } + + public Criteria andUrlNotBetween(String value1, String value2) { + addCriterion("url not between", value1, value2, "url"); + return (Criteria) this; + } + + public Criteria andAppIdIsNull() { + addCriterion("app_id is null"); + return (Criteria) this; + } + + public Criteria andAppIdIsNotNull() { + addCriterion("app_id is not null"); + return (Criteria) this; + } + + public Criteria andAppIdEqualTo(String value) { + addCriterion("app_id =", value, "appId"); + return (Criteria) this; + } + + public Criteria andAppIdNotEqualTo(String value) { + addCriterion("app_id <>", value, "appId"); + return (Criteria) this; + } + + public Criteria andAppIdGreaterThan(String value) { + addCriterion("app_id >", value, "appId"); + return (Criteria) this; + } + + public Criteria andAppIdGreaterThanOrEqualTo(String value) { + addCriterion("app_id >=", value, "appId"); + return (Criteria) this; + } + + public Criteria andAppIdLessThan(String value) { + addCriterion("app_id <", value, "appId"); + return (Criteria) this; + } + + public Criteria andAppIdLessThanOrEqualTo(String value) { + addCriterion("app_id <=", value, "appId"); + return (Criteria) this; + } + + public Criteria andAppIdLike(String value) { + addCriterion("app_id like", value, "appId"); + return (Criteria) this; + } + + public Criteria andAppIdNotLike(String value) { + addCriterion("app_id not like", value, "appId"); + return (Criteria) this; + } + + public Criteria andAppIdIn(List values) { + addCriterion("app_id in", values, "appId"); + return (Criteria) this; + } + + public Criteria andAppIdNotIn(List values) { + addCriterion("app_id not in", values, "appId"); + return (Criteria) this; + } + + public Criteria andAppIdBetween(String value1, String value2) { + addCriterion("app_id between", value1, value2, "appId"); + return (Criteria) this; + } + + public Criteria andAppIdNotBetween(String value1, String value2) { + addCriterion("app_id not between", value1, value2, "appId"); + return (Criteria) this; + } + + public Criteria andSecretIsNull() { + addCriterion("secret is null"); + return (Criteria) this; + } + + public Criteria andSecretIsNotNull() { + addCriterion("secret is not null"); + return (Criteria) this; + } + + public Criteria andSecretEqualTo(String value) { + addCriterion("secret =", value, "secret"); + return (Criteria) this; + } + + public Criteria andSecretNotEqualTo(String value) { + addCriterion("secret <>", value, "secret"); + return (Criteria) this; + } + + public Criteria andSecretGreaterThan(String value) { + addCriterion("secret >", value, "secret"); + return (Criteria) this; + } + + public Criteria andSecretGreaterThanOrEqualTo(String value) { + addCriterion("secret >=", value, "secret"); + return (Criteria) this; + } + + public Criteria andSecretLessThan(String value) { + addCriterion("secret <", value, "secret"); + return (Criteria) this; + } + + public Criteria andSecretLessThanOrEqualTo(String value) { + addCriterion("secret <=", value, "secret"); + return (Criteria) this; + } + + public Criteria andSecretLike(String value) { + addCriterion("secret like", value, "secret"); + return (Criteria) this; + } + + public Criteria andSecretNotLike(String value) { + addCriterion("secret not like", value, "secret"); + return (Criteria) this; + } + + public Criteria andSecretIn(List values) { + addCriterion("secret in", values, "secret"); + return (Criteria) this; + } + + public Criteria andSecretNotIn(List values) { + addCriterion("secret not in", values, "secret"); + return (Criteria) this; + } + + public Criteria andSecretBetween(String value1, String value2) { + addCriterion("secret between", value1, value2, "secret"); + return (Criteria) this; + } + + public Criteria andSecretNotBetween(String value1, String value2) { + addCriterion("secret not between", value1, value2, "secret"); + return (Criteria) this; + } + + public Criteria andOperatorIsNull() { + addCriterion("operator is null"); + return (Criteria) this; + } + + public Criteria andOperatorIsNotNull() { + addCriterion("operator is not null"); + return (Criteria) this; + } + + public Criteria andOperatorEqualTo(Long value) { + addCriterion("operator =", value, "operator"); + return (Criteria) this; + } + + public Criteria andOperatorNotEqualTo(Long value) { + addCriterion("operator <>", value, "operator"); + return (Criteria) this; + } + + public Criteria andOperatorGreaterThan(Long value) { + addCriterion("operator >", value, "operator"); + return (Criteria) this; + } + + public Criteria andOperatorGreaterThanOrEqualTo(Long value) { + addCriterion("operator >=", value, "operator"); + return (Criteria) this; + } + + public Criteria andOperatorLessThan(Long value) { + addCriterion("operator <", value, "operator"); + return (Criteria) this; + } + + public Criteria andOperatorLessThanOrEqualTo(Long value) { + addCriterion("operator <=", value, "operator"); + return (Criteria) this; + } + + public Criteria andOperatorIn(List values) { + addCriterion("operator in", values, "operator"); + return (Criteria) this; + } + + public Criteria andOperatorNotIn(List values) { + addCriterion("operator not in", values, "operator"); + return (Criteria) this; + } + + public Criteria andOperatorBetween(Long value1, Long value2) { + addCriterion("operator between", value1, value2, "operator"); + return (Criteria) this; + } + + public Criteria andOperatorNotBetween(Long value1, Long value2) { + addCriterion("operator not between", value1, value2, "operator"); + return (Criteria) this; + } + + public Criteria andCreatedAtIsNull() { + addCriterion("created_at is null"); + return (Criteria) this; + } + + public Criteria andCreatedAtIsNotNull() { + addCriterion("created_at is not null"); + return (Criteria) this; + } + + public Criteria andCreatedAtEqualTo(Date value) { + addCriterion("created_at =", value, "createdAt"); + return (Criteria) this; + } + + public Criteria andCreatedAtNotEqualTo(Date value) { + addCriterion("created_at <>", value, "createdAt"); + return (Criteria) this; + } + + public Criteria andCreatedAtGreaterThan(Date value) { + addCriterion("created_at >", value, "createdAt"); + return (Criteria) this; + } + + public Criteria andCreatedAtGreaterThanOrEqualTo(Date value) { + addCriterion("created_at >=", value, "createdAt"); + return (Criteria) this; + } + + public Criteria andCreatedAtLessThan(Date value) { + addCriterion("created_at <", value, "createdAt"); + return (Criteria) this; + } + + public Criteria andCreatedAtLessThanOrEqualTo(Date value) { + addCriterion("created_at <=", value, "createdAt"); + return (Criteria) this; + } + + public Criteria andCreatedAtIn(List values) { + addCriterion("created_at in", values, "createdAt"); + return (Criteria) this; + } + + public Criteria andCreatedAtNotIn(List values) { + addCriterion("created_at not in", values, "createdAt"); + return (Criteria) this; + } + + public Criteria andCreatedAtBetween(Date value1, Date value2) { + addCriterion("created_at between", value1, value2, "createdAt"); + return (Criteria) this; + } + + public Criteria andCreatedAtNotBetween(Date value1, Date value2) { + addCriterion("created_at not between", value1, value2, "createdAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtIsNull() { + addCriterion("updated_at is null"); + return (Criteria) this; + } + + public Criteria andUpdatedAtIsNotNull() { + addCriterion("updated_at is not null"); + return (Criteria) this; + } + + public Criteria andUpdatedAtEqualTo(Date value) { + addCriterion("updated_at =", value, "updatedAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtNotEqualTo(Date value) { + addCriterion("updated_at <>", value, "updatedAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtGreaterThan(Date value) { + addCriterion("updated_at >", value, "updatedAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtGreaterThanOrEqualTo(Date value) { + addCriterion("updated_at >=", value, "updatedAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtLessThan(Date value) { + addCriterion("updated_at <", value, "updatedAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtLessThanOrEqualTo(Date value) { + addCriterion("updated_at <=", value, "updatedAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtIn(List values) { + addCriterion("updated_at in", values, "updatedAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtNotIn(List values) { + addCriterion("updated_at not in", values, "updatedAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtBetween(Date value1, Date value2) { + addCriterion("updated_at between", value1, value2, "updatedAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtNotBetween(Date value1, Date value2) { + addCriterion("updated_at not between", value1, value2, "updatedAt"); + return (Criteria) this; + } + + public Criteria andRecStatusIsNull() { + addCriterion("rec_status is null"); + return (Criteria) this; + } + + public Criteria andRecStatusIsNotNull() { + addCriterion("rec_status is not null"); + return (Criteria) this; + } + + public Criteria andRecStatusEqualTo(Byte value) { + addCriterion("rec_status =", value, "recStatus"); + return (Criteria) this; + } + + public Criteria andRecStatusNotEqualTo(Byte value) { + addCriterion("rec_status <>", value, "recStatus"); + return (Criteria) this; + } + + public Criteria andRecStatusGreaterThan(Byte value) { + addCriterion("rec_status >", value, "recStatus"); + return (Criteria) this; + } + + public Criteria andRecStatusGreaterThanOrEqualTo(Byte value) { + addCriterion("rec_status >=", value, "recStatus"); + return (Criteria) this; + } + + public Criteria andRecStatusLessThan(Byte value) { + addCriterion("rec_status <", value, "recStatus"); + return (Criteria) this; + } + + public Criteria andRecStatusLessThanOrEqualTo(Byte value) { + addCriterion("rec_status <=", value, "recStatus"); + return (Criteria) this; + } + + public Criteria andRecStatusIn(List values) { + addCriterion("rec_status in", values, "recStatus"); + return (Criteria) this; + } + + public Criteria andRecStatusNotIn(List values) { + addCriterion("rec_status not in", values, "recStatus"); + return (Criteria) this; + } + + public Criteria andRecStatusBetween(Byte value1, Byte value2) { + addCriterion("rec_status between", value1, value2, "recStatus"); + return (Criteria) this; + } + + public Criteria andRecStatusNotBetween(Byte value1, Byte value2) { + addCriterion("rec_status not between", value1, value2, "recStatus"); + return (Criteria) this; + } + } + + public static class Criteria extends GeneratedCriteria { + + protected Criteria() { + super(); + } + } + + public static class Criterion { + private String condition; + + private Object value; + + private Object secondValue; + + private boolean noValue; + + private boolean singleValue; + + private boolean betweenValue; + + private boolean listValue; + + private String typeHandler; + + public String getCondition() { + return condition; + } + + public Object getValue() { + return value; + } + + public Object getSecondValue() { + return secondValue; + } + + public boolean isNoValue() { + return noValue; + } + + public boolean isSingleValue() { + return singleValue; + } + + public boolean isBetweenValue() { + return betweenValue; + } + + public boolean isListValue() { + return listValue; + } + + public String getTypeHandler() { + return typeHandler; + } + + protected Criterion(String condition) { + super(); + this.condition = condition; + this.typeHandler = null; + this.noValue = true; + } + + protected Criterion(String condition, Object value, String typeHandler) { + super(); + this.condition = condition; + this.value = value; + this.typeHandler = typeHandler; + if (value instanceof List) { + this.listValue = true; + } else { + this.singleValue = true; + } + } + + protected Criterion(String condition, Object value) { + this(condition, value, null); + } + + protected Criterion(String condition, Object value, Object secondValue, String typeHandler) { + super(); + this.condition = condition; + this.value = value; + this.secondValue = secondValue; + this.typeHandler = typeHandler; + this.betweenValue = true; + } + + protected Criterion(String condition, Object value, Object secondValue) { + this(condition, value, secondValue, null); + } + } +} \ No newline at end of file diff --git a/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/bean/po/IdcDomainExample.java b/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/bean/po/IdcDomainExample.java new file mode 100644 index 0000000..d3e13fa --- /dev/null +++ b/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/bean/po/IdcDomainExample.java @@ -0,0 +1,1411 @@ +package com.ccsens.dh_diplomatist.bean.po; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +public class IdcDomainExample { + protected String orderByClause; + + protected boolean distinct; + + protected List oredCriteria; + + public IdcDomainExample() { + oredCriteria = new ArrayList(); + } + + public void setOrderByClause(String orderByClause) { + this.orderByClause = orderByClause; + } + + public String getOrderByClause() { + return orderByClause; + } + + public void setDistinct(boolean distinct) { + this.distinct = distinct; + } + + public boolean isDistinct() { + return distinct; + } + + public List getOredCriteria() { + return oredCriteria; + } + + public void or(Criteria criteria) { + oredCriteria.add(criteria); + } + + public Criteria or() { + Criteria criteria = createCriteriaInternal(); + oredCriteria.add(criteria); + return criteria; + } + + public Criteria createCriteria() { + Criteria criteria = createCriteriaInternal(); + if (oredCriteria.size() == 0) { + oredCriteria.add(criteria); + } + return criteria; + } + + protected Criteria createCriteriaInternal() { + Criteria criteria = new Criteria(); + return criteria; + } + + public void clear() { + oredCriteria.clear(); + orderByClause = null; + distinct = false; + } + + protected abstract static class GeneratedCriteria { + protected List criteria; + + protected GeneratedCriteria() { + super(); + criteria = new ArrayList(); + } + + public boolean isValid() { + return criteria.size() > 0; + } + + public List getAllCriteria() { + return criteria; + } + + public List getCriteria() { + return criteria; + } + + protected void addCriterion(String condition) { + if (condition == null) { + throw new RuntimeException("Value for condition cannot be null"); + } + criteria.add(new Criterion(condition)); + } + + protected void addCriterion(String condition, Object value, String property) { + if (value == null) { + throw new RuntimeException("Value for " + property + " cannot be null"); + } + criteria.add(new Criterion(condition, value)); + } + + protected void addCriterion(String condition, Object value1, Object value2, String property) { + if (value1 == null || value2 == null) { + throw new RuntimeException("Between values for " + property + " cannot be null"); + } + criteria.add(new Criterion(condition, value1, value2)); + } + + public Criteria andIdIsNull() { + addCriterion("id is null"); + return (Criteria) this; + } + + public Criteria andIdIsNotNull() { + addCriterion("id is not null"); + return (Criteria) this; + } + + public Criteria andIdEqualTo(Long value) { + addCriterion("id =", value, "id"); + return (Criteria) this; + } + + public Criteria andIdNotEqualTo(Long value) { + addCriterion("id <>", value, "id"); + return (Criteria) this; + } + + public Criteria andIdGreaterThan(Long value) { + addCriterion("id >", value, "id"); + return (Criteria) this; + } + + public Criteria andIdGreaterThanOrEqualTo(Long value) { + addCriterion("id >=", value, "id"); + return (Criteria) this; + } + + public Criteria andIdLessThan(Long value) { + addCriterion("id <", value, "id"); + return (Criteria) this; + } + + public Criteria andIdLessThanOrEqualTo(Long value) { + addCriterion("id <=", value, "id"); + return (Criteria) this; + } + + public Criteria andIdIn(List values) { + addCriterion("id in", values, "id"); + return (Criteria) this; + } + + public Criteria andIdNotIn(List values) { + addCriterion("id not in", values, "id"); + return (Criteria) this; + } + + public Criteria andIdBetween(Long value1, Long value2) { + addCriterion("id between", value1, value2, "id"); + return (Criteria) this; + } + + public Criteria andIdNotBetween(Long value1, Long value2) { + addCriterion("id not between", value1, value2, "id"); + return (Criteria) this; + } + + public Criteria andNameIsNull() { + addCriterion("name is null"); + return (Criteria) this; + } + + public Criteria andNameIsNotNull() { + addCriterion("name is not null"); + return (Criteria) this; + } + + public Criteria andNameEqualTo(String value) { + addCriterion("name =", value, "name"); + return (Criteria) this; + } + + public Criteria andNameNotEqualTo(String value) { + addCriterion("name <>", value, "name"); + return (Criteria) this; + } + + public Criteria andNameGreaterThan(String value) { + addCriterion("name >", value, "name"); + return (Criteria) this; + } + + public Criteria andNameGreaterThanOrEqualTo(String value) { + addCriterion("name >=", value, "name"); + return (Criteria) this; + } + + public Criteria andNameLessThan(String value) { + addCriterion("name <", value, "name"); + return (Criteria) this; + } + + public Criteria andNameLessThanOrEqualTo(String value) { + addCriterion("name <=", value, "name"); + return (Criteria) this; + } + + public Criteria andNameLike(String value) { + addCriterion("name like", value, "name"); + return (Criteria) this; + } + + public Criteria andNameNotLike(String value) { + addCriterion("name not like", value, "name"); + return (Criteria) this; + } + + public Criteria andNameIn(List values) { + addCriterion("name in", values, "name"); + return (Criteria) this; + } + + public Criteria andNameNotIn(List values) { + addCriterion("name not in", values, "name"); + return (Criteria) this; + } + + public Criteria andNameBetween(String value1, String value2) { + addCriterion("name between", value1, value2, "name"); + return (Criteria) this; + } + + public Criteria andNameNotBetween(String value1, String value2) { + addCriterion("name not between", value1, value2, "name"); + return (Criteria) this; + } + + public Criteria andCodeIsNull() { + addCriterion("code is null"); + return (Criteria) this; + } + + public Criteria andCodeIsNotNull() { + addCriterion("code is not null"); + return (Criteria) this; + } + + public Criteria andCodeEqualTo(String value) { + addCriterion("code =", value, "code"); + return (Criteria) this; + } + + public Criteria andCodeNotEqualTo(String value) { + addCriterion("code <>", value, "code"); + return (Criteria) this; + } + + public Criteria andCodeGreaterThan(String value) { + addCriterion("code >", value, "code"); + return (Criteria) this; + } + + public Criteria andCodeGreaterThanOrEqualTo(String value) { + addCriterion("code >=", value, "code"); + return (Criteria) this; + } + + public Criteria andCodeLessThan(String value) { + addCriterion("code <", value, "code"); + return (Criteria) this; + } + + public Criteria andCodeLessThanOrEqualTo(String value) { + addCriterion("code <=", value, "code"); + return (Criteria) this; + } + + public Criteria andCodeLike(String value) { + addCriterion("code like", value, "code"); + return (Criteria) this; + } + + public Criteria andCodeNotLike(String value) { + addCriterion("code not like", value, "code"); + return (Criteria) this; + } + + public Criteria andCodeIn(List values) { + addCriterion("code in", values, "code"); + return (Criteria) this; + } + + public Criteria andCodeNotIn(List values) { + addCriterion("code not in", values, "code"); + return (Criteria) this; + } + + public Criteria andCodeBetween(String value1, String value2) { + addCriterion("code between", value1, value2, "code"); + return (Criteria) this; + } + + public Criteria andCodeNotBetween(String value1, String value2) { + addCriterion("code not between", value1, value2, "code"); + return (Criteria) this; + } + + public Criteria andIntroIsNull() { + addCriterion("intro is null"); + return (Criteria) this; + } + + public Criteria andIntroIsNotNull() { + addCriterion("intro is not null"); + return (Criteria) this; + } + + public Criteria andIntroEqualTo(String value) { + addCriterion("intro =", value, "intro"); + return (Criteria) this; + } + + public Criteria andIntroNotEqualTo(String value) { + addCriterion("intro <>", value, "intro"); + return (Criteria) this; + } + + public Criteria andIntroGreaterThan(String value) { + addCriterion("intro >", value, "intro"); + return (Criteria) this; + } + + public Criteria andIntroGreaterThanOrEqualTo(String value) { + addCriterion("intro >=", value, "intro"); + return (Criteria) this; + } + + public Criteria andIntroLessThan(String value) { + addCriterion("intro <", value, "intro"); + return (Criteria) this; + } + + public Criteria andIntroLessThanOrEqualTo(String value) { + addCriterion("intro <=", value, "intro"); + return (Criteria) this; + } + + public Criteria andIntroLike(String value) { + addCriterion("intro like", value, "intro"); + return (Criteria) this; + } + + public Criteria andIntroNotLike(String value) { + addCriterion("intro not like", value, "intro"); + return (Criteria) this; + } + + public Criteria andIntroIn(List values) { + addCriterion("intro in", values, "intro"); + return (Criteria) this; + } + + public Criteria andIntroNotIn(List values) { + addCriterion("intro not in", values, "intro"); + return (Criteria) this; + } + + public Criteria andIntroBetween(String value1, String value2) { + addCriterion("intro between", value1, value2, "intro"); + return (Criteria) this; + } + + public Criteria andIntroNotBetween(String value1, String value2) { + addCriterion("intro not between", value1, value2, "intro"); + return (Criteria) this; + } + + public Criteria andUrlIsNull() { + addCriterion("url is null"); + return (Criteria) this; + } + + public Criteria andUrlIsNotNull() { + addCriterion("url is not null"); + return (Criteria) this; + } + + public Criteria andUrlEqualTo(String value) { + addCriterion("url =", value, "url"); + return (Criteria) this; + } + + public Criteria andUrlNotEqualTo(String value) { + addCriterion("url <>", value, "url"); + return (Criteria) this; + } + + public Criteria andUrlGreaterThan(String value) { + addCriterion("url >", value, "url"); + return (Criteria) this; + } + + public Criteria andUrlGreaterThanOrEqualTo(String value) { + addCriterion("url >=", value, "url"); + return (Criteria) this; + } + + public Criteria andUrlLessThan(String value) { + addCriterion("url <", value, "url"); + return (Criteria) this; + } + + public Criteria andUrlLessThanOrEqualTo(String value) { + addCriterion("url <=", value, "url"); + return (Criteria) this; + } + + public Criteria andUrlLike(String value) { + addCriterion("url like", value, "url"); + return (Criteria) this; + } + + public Criteria andUrlNotLike(String value) { + addCriterion("url not like", value, "url"); + return (Criteria) this; + } + + public Criteria andUrlIn(List values) { + addCriterion("url in", values, "url"); + return (Criteria) this; + } + + public Criteria andUrlNotIn(List values) { + addCriterion("url not in", values, "url"); + return (Criteria) this; + } + + public Criteria andUrlBetween(String value1, String value2) { + addCriterion("url between", value1, value2, "url"); + return (Criteria) this; + } + + public Criteria andUrlNotBetween(String value1, String value2) { + addCriterion("url not between", value1, value2, "url"); + return (Criteria) this; + } + + public Criteria andHostIsNull() { + addCriterion("host is null"); + return (Criteria) this; + } + + public Criteria andHostIsNotNull() { + addCriterion("host is not null"); + return (Criteria) this; + } + + public Criteria andHostEqualTo(String value) { + addCriterion("host =", value, "host"); + return (Criteria) this; + } + + public Criteria andHostNotEqualTo(String value) { + addCriterion("host <>", value, "host"); + return (Criteria) this; + } + + public Criteria andHostGreaterThan(String value) { + addCriterion("host >", value, "host"); + return (Criteria) this; + } + + public Criteria andHostGreaterThanOrEqualTo(String value) { + addCriterion("host >=", value, "host"); + return (Criteria) this; + } + + public Criteria andHostLessThan(String value) { + addCriterion("host <", value, "host"); + return (Criteria) this; + } + + public Criteria andHostLessThanOrEqualTo(String value) { + addCriterion("host <=", value, "host"); + return (Criteria) this; + } + + public Criteria andHostLike(String value) { + addCriterion("host like", value, "host"); + return (Criteria) this; + } + + public Criteria andHostNotLike(String value) { + addCriterion("host not like", value, "host"); + return (Criteria) this; + } + + public Criteria andHostIn(List values) { + addCriterion("host in", values, "host"); + return (Criteria) this; + } + + public Criteria andHostNotIn(List values) { + addCriterion("host not in", values, "host"); + return (Criteria) this; + } + + public Criteria andHostBetween(String value1, String value2) { + addCriterion("host between", value1, value2, "host"); + return (Criteria) this; + } + + public Criteria andHostNotBetween(String value1, String value2) { + addCriterion("host not between", value1, value2, "host"); + return (Criteria) this; + } + + public Criteria andSelfIsNull() { + addCriterion("self is null"); + return (Criteria) this; + } + + public Criteria andSelfIsNotNull() { + addCriterion("self is not null"); + return (Criteria) this; + } + + public Criteria andSelfEqualTo(Byte value) { + addCriterion("self =", value, "self"); + return (Criteria) this; + } + + public Criteria andSelfNotEqualTo(Byte value) { + addCriterion("self <>", value, "self"); + return (Criteria) this; + } + + public Criteria andSelfGreaterThan(Byte value) { + addCriterion("self >", value, "self"); + return (Criteria) this; + } + + public Criteria andSelfGreaterThanOrEqualTo(Byte value) { + addCriterion("self >=", value, "self"); + return (Criteria) this; + } + + public Criteria andSelfLessThan(Byte value) { + addCriterion("self <", value, "self"); + return (Criteria) this; + } + + public Criteria andSelfLessThanOrEqualTo(Byte value) { + addCriterion("self <=", value, "self"); + return (Criteria) this; + } + + public Criteria andSelfIn(List values) { + addCriterion("self in", values, "self"); + return (Criteria) this; + } + + public Criteria andSelfNotIn(List values) { + addCriterion("self not in", values, "self"); + return (Criteria) this; + } + + public Criteria andSelfBetween(Byte value1, Byte value2) { + addCriterion("self between", value1, value2, "self"); + return (Criteria) this; + } + + public Criteria andSelfNotBetween(Byte value1, Byte value2) { + addCriterion("self not between", value1, value2, "self"); + return (Criteria) this; + } + + public Criteria andPubIsNull() { + addCriterion("pub is null"); + return (Criteria) this; + } + + public Criteria andPubIsNotNull() { + addCriterion("pub is not null"); + return (Criteria) this; + } + + public Criteria andPubEqualTo(Byte value) { + addCriterion("pub =", value, "pub"); + return (Criteria) this; + } + + public Criteria andPubNotEqualTo(Byte value) { + addCriterion("pub <>", value, "pub"); + return (Criteria) this; + } + + public Criteria andPubGreaterThan(Byte value) { + addCriterion("pub >", value, "pub"); + return (Criteria) this; + } + + public Criteria andPubGreaterThanOrEqualTo(Byte value) { + addCriterion("pub >=", value, "pub"); + return (Criteria) this; + } + + public Criteria andPubLessThan(Byte value) { + addCriterion("pub <", value, "pub"); + return (Criteria) this; + } + + public Criteria andPubLessThanOrEqualTo(Byte value) { + addCriterion("pub <=", value, "pub"); + return (Criteria) this; + } + + public Criteria andPubIn(List values) { + addCriterion("pub in", values, "pub"); + return (Criteria) this; + } + + public Criteria andPubNotIn(List values) { + addCriterion("pub not in", values, "pub"); + return (Criteria) this; + } + + public Criteria andPubBetween(Byte value1, Byte value2) { + addCriterion("pub between", value1, value2, "pub"); + return (Criteria) this; + } + + public Criteria andPubNotBetween(Byte value1, Byte value2) { + addCriterion("pub not between", value1, value2, "pub"); + return (Criteria) this; + } + + public Criteria andPollingIsNull() { + addCriterion("polling is null"); + return (Criteria) this; + } + + public Criteria andPollingIsNotNull() { + addCriterion("polling is not null"); + return (Criteria) this; + } + + public Criteria andPollingEqualTo(Byte value) { + addCriterion("polling =", value, "polling"); + return (Criteria) this; + } + + public Criteria andPollingNotEqualTo(Byte value) { + addCriterion("polling <>", value, "polling"); + return (Criteria) this; + } + + public Criteria andPollingGreaterThan(Byte value) { + addCriterion("polling >", value, "polling"); + return (Criteria) this; + } + + public Criteria andPollingGreaterThanOrEqualTo(Byte value) { + addCriterion("polling >=", value, "polling"); + return (Criteria) this; + } + + public Criteria andPollingLessThan(Byte value) { + addCriterion("polling <", value, "polling"); + return (Criteria) this; + } + + public Criteria andPollingLessThanOrEqualTo(Byte value) { + addCriterion("polling <=", value, "polling"); + return (Criteria) this; + } + + public Criteria andPollingIn(List values) { + addCriterion("polling in", values, "polling"); + return (Criteria) this; + } + + public Criteria andPollingNotIn(List values) { + addCriterion("polling not in", values, "polling"); + return (Criteria) this; + } + + public Criteria andPollingBetween(Byte value1, Byte value2) { + addCriterion("polling between", value1, value2, "polling"); + return (Criteria) this; + } + + public Criteria andPollingNotBetween(Byte value1, Byte value2) { + addCriterion("polling not between", value1, value2, "polling"); + return (Criteria) this; + } + + public Criteria andAnswerIsNull() { + addCriterion("answer is null"); + return (Criteria) this; + } + + public Criteria andAnswerIsNotNull() { + addCriterion("answer is not null"); + return (Criteria) this; + } + + public Criteria andAnswerEqualTo(Byte value) { + addCriterion("answer =", value, "answer"); + return (Criteria) this; + } + + public Criteria andAnswerNotEqualTo(Byte value) { + addCriterion("answer <>", value, "answer"); + return (Criteria) this; + } + + public Criteria andAnswerGreaterThan(Byte value) { + addCriterion("answer >", value, "answer"); + return (Criteria) this; + } + + public Criteria andAnswerGreaterThanOrEqualTo(Byte value) { + addCriterion("answer >=", value, "answer"); + return (Criteria) this; + } + + public Criteria andAnswerLessThan(Byte value) { + addCriterion("answer <", value, "answer"); + return (Criteria) this; + } + + public Criteria andAnswerLessThanOrEqualTo(Byte value) { + addCriterion("answer <=", value, "answer"); + return (Criteria) this; + } + + public Criteria andAnswerIn(List values) { + addCriterion("answer in", values, "answer"); + return (Criteria) this; + } + + public Criteria andAnswerNotIn(List values) { + addCriterion("answer not in", values, "answer"); + return (Criteria) this; + } + + public Criteria andAnswerBetween(Byte value1, Byte value2) { + addCriterion("answer between", value1, value2, "answer"); + return (Criteria) this; + } + + public Criteria andAnswerNotBetween(Byte value1, Byte value2) { + addCriterion("answer not between", value1, value2, "answer"); + return (Criteria) this; + } + + public Criteria andLastUpdateTimeIsNull() { + addCriterion("last_update_time is null"); + return (Criteria) this; + } + + public Criteria andLastUpdateTimeIsNotNull() { + addCriterion("last_update_time is not null"); + return (Criteria) this; + } + + public Criteria andLastUpdateTimeEqualTo(Long value) { + addCriterion("last_update_time =", value, "lastUpdateTime"); + return (Criteria) this; + } + + public Criteria andLastUpdateTimeNotEqualTo(Long value) { + addCriterion("last_update_time <>", value, "lastUpdateTime"); + return (Criteria) this; + } + + public Criteria andLastUpdateTimeGreaterThan(Long value) { + addCriterion("last_update_time >", value, "lastUpdateTime"); + return (Criteria) this; + } + + public Criteria andLastUpdateTimeGreaterThanOrEqualTo(Long value) { + addCriterion("last_update_time >=", value, "lastUpdateTime"); + return (Criteria) this; + } + + public Criteria andLastUpdateTimeLessThan(Long value) { + addCriterion("last_update_time <", value, "lastUpdateTime"); + return (Criteria) this; + } + + public Criteria andLastUpdateTimeLessThanOrEqualTo(Long value) { + addCriterion("last_update_time <=", value, "lastUpdateTime"); + return (Criteria) this; + } + + public Criteria andLastUpdateTimeIn(List values) { + addCriterion("last_update_time in", values, "lastUpdateTime"); + return (Criteria) this; + } + + public Criteria andLastUpdateTimeNotIn(List values) { + addCriterion("last_update_time not in", values, "lastUpdateTime"); + return (Criteria) this; + } + + public Criteria andLastUpdateTimeBetween(Long value1, Long value2) { + addCriterion("last_update_time between", value1, value2, "lastUpdateTime"); + return (Criteria) this; + } + + public Criteria andLastUpdateTimeNotBetween(Long value1, Long value2) { + addCriterion("last_update_time not between", value1, value2, "lastUpdateTime"); + return (Criteria) this; + } + + public Criteria andLastAskTimeIsNull() { + addCriterion("last_ask_time is null"); + return (Criteria) this; + } + + public Criteria andLastAskTimeIsNotNull() { + addCriterion("last_ask_time is not null"); + return (Criteria) this; + } + + public Criteria andLastAskTimeEqualTo(Long value) { + addCriterion("last_ask_time =", value, "lastAskTime"); + return (Criteria) this; + } + + public Criteria andLastAskTimeNotEqualTo(Long value) { + addCriterion("last_ask_time <>", value, "lastAskTime"); + return (Criteria) this; + } + + public Criteria andLastAskTimeGreaterThan(Long value) { + addCriterion("last_ask_time >", value, "lastAskTime"); + return (Criteria) this; + } + + public Criteria andLastAskTimeGreaterThanOrEqualTo(Long value) { + addCriterion("last_ask_time >=", value, "lastAskTime"); + return (Criteria) this; + } + + public Criteria andLastAskTimeLessThan(Long value) { + addCriterion("last_ask_time <", value, "lastAskTime"); + return (Criteria) this; + } + + public Criteria andLastAskTimeLessThanOrEqualTo(Long value) { + addCriterion("last_ask_time <=", value, "lastAskTime"); + return (Criteria) this; + } + + public Criteria andLastAskTimeIn(List values) { + addCriterion("last_ask_time in", values, "lastAskTime"); + return (Criteria) this; + } + + public Criteria andLastAskTimeNotIn(List values) { + addCriterion("last_ask_time not in", values, "lastAskTime"); + return (Criteria) this; + } + + public Criteria andLastAskTimeBetween(Long value1, Long value2) { + addCriterion("last_ask_time between", value1, value2, "lastAskTime"); + return (Criteria) this; + } + + public Criteria andLastAskTimeNotBetween(Long value1, Long value2) { + addCriterion("last_ask_time not between", value1, value2, "lastAskTime"); + return (Criteria) this; + } + + public Criteria andLastAnswerTimeIsNull() { + addCriterion("last_answer_time is null"); + return (Criteria) this; + } + + public Criteria andLastAnswerTimeIsNotNull() { + addCriterion("last_answer_time is not null"); + return (Criteria) this; + } + + public Criteria andLastAnswerTimeEqualTo(Long value) { + addCriterion("last_answer_time =", value, "lastAnswerTime"); + return (Criteria) this; + } + + public Criteria andLastAnswerTimeNotEqualTo(Long value) { + addCriterion("last_answer_time <>", value, "lastAnswerTime"); + return (Criteria) this; + } + + public Criteria andLastAnswerTimeGreaterThan(Long value) { + addCriterion("last_answer_time >", value, "lastAnswerTime"); + return (Criteria) this; + } + + public Criteria andLastAnswerTimeGreaterThanOrEqualTo(Long value) { + addCriterion("last_answer_time >=", value, "lastAnswerTime"); + return (Criteria) this; + } + + public Criteria andLastAnswerTimeLessThan(Long value) { + addCriterion("last_answer_time <", value, "lastAnswerTime"); + return (Criteria) this; + } + + public Criteria andLastAnswerTimeLessThanOrEqualTo(Long value) { + addCriterion("last_answer_time <=", value, "lastAnswerTime"); + return (Criteria) this; + } + + public Criteria andLastAnswerTimeIn(List values) { + addCriterion("last_answer_time in", values, "lastAnswerTime"); + return (Criteria) this; + } + + public Criteria andLastAnswerTimeNotIn(List values) { + addCriterion("last_answer_time not in", values, "lastAnswerTime"); + return (Criteria) this; + } + + public Criteria andLastAnswerTimeBetween(Long value1, Long value2) { + addCriterion("last_answer_time between", value1, value2, "lastAnswerTime"); + return (Criteria) this; + } + + public Criteria andLastAnswerTimeNotBetween(Long value1, Long value2) { + addCriterion("last_answer_time not between", value1, value2, "lastAnswerTime"); + return (Criteria) this; + } + + public Criteria andPublicKeyIsNull() { + addCriterion("public_key is null"); + return (Criteria) this; + } + + public Criteria andPublicKeyIsNotNull() { + addCriterion("public_key is not null"); + return (Criteria) this; + } + + public Criteria andPublicKeyEqualTo(String value) { + addCriterion("public_key =", value, "publicKey"); + return (Criteria) this; + } + + public Criteria andPublicKeyNotEqualTo(String value) { + addCriterion("public_key <>", value, "publicKey"); + return (Criteria) this; + } + + public Criteria andPublicKeyGreaterThan(String value) { + addCriterion("public_key >", value, "publicKey"); + return (Criteria) this; + } + + public Criteria andPublicKeyGreaterThanOrEqualTo(String value) { + addCriterion("public_key >=", value, "publicKey"); + return (Criteria) this; + } + + public Criteria andPublicKeyLessThan(String value) { + addCriterion("public_key <", value, "publicKey"); + return (Criteria) this; + } + + public Criteria andPublicKeyLessThanOrEqualTo(String value) { + addCriterion("public_key <=", value, "publicKey"); + return (Criteria) this; + } + + public Criteria andPublicKeyLike(String value) { + addCriterion("public_key like", value, "publicKey"); + return (Criteria) this; + } + + public Criteria andPublicKeyNotLike(String value) { + addCriterion("public_key not like", value, "publicKey"); + return (Criteria) this; + } + + public Criteria andPublicKeyIn(List values) { + addCriterion("public_key in", values, "publicKey"); + return (Criteria) this; + } + + public Criteria andPublicKeyNotIn(List values) { + addCriterion("public_key not in", values, "publicKey"); + return (Criteria) this; + } + + public Criteria andPublicKeyBetween(String value1, String value2) { + addCriterion("public_key between", value1, value2, "publicKey"); + return (Criteria) this; + } + + public Criteria andPublicKeyNotBetween(String value1, String value2) { + addCriterion("public_key not between", value1, value2, "publicKey"); + return (Criteria) this; + } + + public Criteria andPrivateKeyIsNull() { + addCriterion("private_key is null"); + return (Criteria) this; + } + + public Criteria andPrivateKeyIsNotNull() { + addCriterion("private_key is not null"); + return (Criteria) this; + } + + public Criteria andPrivateKeyEqualTo(String value) { + addCriterion("private_key =", value, "privateKey"); + return (Criteria) this; + } + + public Criteria andPrivateKeyNotEqualTo(String value) { + addCriterion("private_key <>", value, "privateKey"); + return (Criteria) this; + } + + public Criteria andPrivateKeyGreaterThan(String value) { + addCriterion("private_key >", value, "privateKey"); + return (Criteria) this; + } + + public Criteria andPrivateKeyGreaterThanOrEqualTo(String value) { + addCriterion("private_key >=", value, "privateKey"); + return (Criteria) this; + } + + public Criteria andPrivateKeyLessThan(String value) { + addCriterion("private_key <", value, "privateKey"); + return (Criteria) this; + } + + public Criteria andPrivateKeyLessThanOrEqualTo(String value) { + addCriterion("private_key <=", value, "privateKey"); + return (Criteria) this; + } + + public Criteria andPrivateKeyLike(String value) { + addCriterion("private_key like", value, "privateKey"); + return (Criteria) this; + } + + public Criteria andPrivateKeyNotLike(String value) { + addCriterion("private_key not like", value, "privateKey"); + return (Criteria) this; + } + + public Criteria andPrivateKeyIn(List values) { + addCriterion("private_key in", values, "privateKey"); + return (Criteria) this; + } + + public Criteria andPrivateKeyNotIn(List values) { + addCriterion("private_key not in", values, "privateKey"); + return (Criteria) this; + } + + public Criteria andPrivateKeyBetween(String value1, String value2) { + addCriterion("private_key between", value1, value2, "privateKey"); + return (Criteria) this; + } + + public Criteria andPrivateKeyNotBetween(String value1, String value2) { + addCriterion("private_key not between", value1, value2, "privateKey"); + return (Criteria) this; + } + + public Criteria andOperatorIsNull() { + addCriterion("operator is null"); + return (Criteria) this; + } + + public Criteria andOperatorIsNotNull() { + addCriterion("operator is not null"); + return (Criteria) this; + } + + public Criteria andOperatorEqualTo(Long value) { + addCriterion("operator =", value, "operator"); + return (Criteria) this; + } + + public Criteria andOperatorNotEqualTo(Long value) { + addCriterion("operator <>", value, "operator"); + return (Criteria) this; + } + + public Criteria andOperatorGreaterThan(Long value) { + addCriterion("operator >", value, "operator"); + return (Criteria) this; + } + + public Criteria andOperatorGreaterThanOrEqualTo(Long value) { + addCriterion("operator >=", value, "operator"); + return (Criteria) this; + } + + public Criteria andOperatorLessThan(Long value) { + addCriterion("operator <", value, "operator"); + return (Criteria) this; + } + + public Criteria andOperatorLessThanOrEqualTo(Long value) { + addCriterion("operator <=", value, "operator"); + return (Criteria) this; + } + + public Criteria andOperatorIn(List values) { + addCriterion("operator in", values, "operator"); + return (Criteria) this; + } + + public Criteria andOperatorNotIn(List values) { + addCriterion("operator not in", values, "operator"); + return (Criteria) this; + } + + public Criteria andOperatorBetween(Long value1, Long value2) { + addCriterion("operator between", value1, value2, "operator"); + return (Criteria) this; + } + + public Criteria andOperatorNotBetween(Long value1, Long value2) { + addCriterion("operator not between", value1, value2, "operator"); + return (Criteria) this; + } + + public Criteria andCreatedAtIsNull() { + addCriterion("created_at is null"); + return (Criteria) this; + } + + public Criteria andCreatedAtIsNotNull() { + addCriterion("created_at is not null"); + return (Criteria) this; + } + + public Criteria andCreatedAtEqualTo(Date value) { + addCriterion("created_at =", value, "createdAt"); + return (Criteria) this; + } + + public Criteria andCreatedAtNotEqualTo(Date value) { + addCriterion("created_at <>", value, "createdAt"); + return (Criteria) this; + } + + public Criteria andCreatedAtGreaterThan(Date value) { + addCriterion("created_at >", value, "createdAt"); + return (Criteria) this; + } + + public Criteria andCreatedAtGreaterThanOrEqualTo(Date value) { + addCriterion("created_at >=", value, "createdAt"); + return (Criteria) this; + } + + public Criteria andCreatedAtLessThan(Date value) { + addCriterion("created_at <", value, "createdAt"); + return (Criteria) this; + } + + public Criteria andCreatedAtLessThanOrEqualTo(Date value) { + addCriterion("created_at <=", value, "createdAt"); + return (Criteria) this; + } + + public Criteria andCreatedAtIn(List values) { + addCriterion("created_at in", values, "createdAt"); + return (Criteria) this; + } + + public Criteria andCreatedAtNotIn(List values) { + addCriterion("created_at not in", values, "createdAt"); + return (Criteria) this; + } + + public Criteria andCreatedAtBetween(Date value1, Date value2) { + addCriterion("created_at between", value1, value2, "createdAt"); + return (Criteria) this; + } + + public Criteria andCreatedAtNotBetween(Date value1, Date value2) { + addCriterion("created_at not between", value1, value2, "createdAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtIsNull() { + addCriterion("updated_at is null"); + return (Criteria) this; + } + + public Criteria andUpdatedAtIsNotNull() { + addCriterion("updated_at is not null"); + return (Criteria) this; + } + + public Criteria andUpdatedAtEqualTo(Date value) { + addCriterion("updated_at =", value, "updatedAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtNotEqualTo(Date value) { + addCriterion("updated_at <>", value, "updatedAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtGreaterThan(Date value) { + addCriterion("updated_at >", value, "updatedAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtGreaterThanOrEqualTo(Date value) { + addCriterion("updated_at >=", value, "updatedAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtLessThan(Date value) { + addCriterion("updated_at <", value, "updatedAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtLessThanOrEqualTo(Date value) { + addCriterion("updated_at <=", value, "updatedAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtIn(List values) { + addCriterion("updated_at in", values, "updatedAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtNotIn(List values) { + addCriterion("updated_at not in", values, "updatedAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtBetween(Date value1, Date value2) { + addCriterion("updated_at between", value1, value2, "updatedAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtNotBetween(Date value1, Date value2) { + addCriterion("updated_at not between", value1, value2, "updatedAt"); + return (Criteria) this; + } + + public Criteria andRecStatusIsNull() { + addCriterion("rec_status is null"); + return (Criteria) this; + } + + public Criteria andRecStatusIsNotNull() { + addCriterion("rec_status is not null"); + return (Criteria) this; + } + + public Criteria andRecStatusEqualTo(Byte value) { + addCriterion("rec_status =", value, "recStatus"); + return (Criteria) this; + } + + public Criteria andRecStatusNotEqualTo(Byte value) { + addCriterion("rec_status <>", value, "recStatus"); + return (Criteria) this; + } + + public Criteria andRecStatusGreaterThan(Byte value) { + addCriterion("rec_status >", value, "recStatus"); + return (Criteria) this; + } + + public Criteria andRecStatusGreaterThanOrEqualTo(Byte value) { + addCriterion("rec_status >=", value, "recStatus"); + return (Criteria) this; + } + + public Criteria andRecStatusLessThan(Byte value) { + addCriterion("rec_status <", value, "recStatus"); + return (Criteria) this; + } + + public Criteria andRecStatusLessThanOrEqualTo(Byte value) { + addCriterion("rec_status <=", value, "recStatus"); + return (Criteria) this; + } + + public Criteria andRecStatusIn(List values) { + addCriterion("rec_status in", values, "recStatus"); + return (Criteria) this; + } + + public Criteria andRecStatusNotIn(List values) { + addCriterion("rec_status not in", values, "recStatus"); + return (Criteria) this; + } + + public Criteria andRecStatusBetween(Byte value1, Byte value2) { + addCriterion("rec_status between", value1, value2, "recStatus"); + return (Criteria) this; + } + + public Criteria andRecStatusNotBetween(Byte value1, Byte value2) { + addCriterion("rec_status not between", value1, value2, "recStatus"); + return (Criteria) this; + } + } + + public static class Criteria extends GeneratedCriteria { + + protected Criteria() { + super(); + } + } + + public static class Criterion { + private String condition; + + private Object value; + + private Object secondValue; + + private boolean noValue; + + private boolean singleValue; + + private boolean betweenValue; + + private boolean listValue; + + private String typeHandler; + + public String getCondition() { + return condition; + } + + public Object getValue() { + return value; + } + + public Object getSecondValue() { + return secondValue; + } + + public boolean isNoValue() { + return noValue; + } + + public boolean isSingleValue() { + return singleValue; + } + + public boolean isBetweenValue() { + return betweenValue; + } + + public boolean isListValue() { + return listValue; + } + + public String getTypeHandler() { + return typeHandler; + } + + protected Criterion(String condition) { + super(); + this.condition = condition; + this.typeHandler = null; + this.noValue = true; + } + + protected Criterion(String condition, Object value, String typeHandler) { + super(); + this.condition = condition; + this.value = value; + this.typeHandler = typeHandler; + if (value instanceof List) { + this.listValue = true; + } else { + this.singleValue = true; + } + } + + protected Criterion(String condition, Object value) { + this(condition, value, null); + } + + protected Criterion(String condition, Object value, Object secondValue, String typeHandler) { + super(); + this.condition = condition; + this.value = value; + this.secondValue = secondValue; + this.typeHandler = typeHandler; + this.betweenValue = true; + } + + protected Criterion(String condition, Object value, Object secondValue) { + this(condition, value, secondValue, null); + } + } +} \ No newline at end of file diff --git a/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/bean/po/IdcUser.java b/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/bean/po/IdcUser.java new file mode 100644 index 0000000..9e6e3f8 --- /dev/null +++ b/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/bean/po/IdcUser.java @@ -0,0 +1,95 @@ +package com.ccsens.dh_diplomatist.bean.po; + +import java.io.Serializable; +import java.util.Date; + +public class IdcUser implements Serializable { + private Long id; + + private String idCard; + + private String phone; + + private Long operator; + + private Date createdAt; + + private Date updatedAt; + + private Byte recStatus; + + private static final long serialVersionUID = 1L; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getIdCard() { + return idCard; + } + + public void setIdCard(String idCard) { + this.idCard = idCard == null ? null : idCard.trim(); + } + + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone == null ? null : phone.trim(); + } + + public Long getOperator() { + return operator; + } + + public void setOperator(Long operator) { + this.operator = operator; + } + + public Date getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(Date createdAt) { + this.createdAt = createdAt; + } + + public Date getUpdatedAt() { + return updatedAt; + } + + public void setUpdatedAt(Date updatedAt) { + this.updatedAt = updatedAt; + } + + public Byte getRecStatus() { + return recStatus; + } + + public void setRecStatus(Byte recStatus) { + this.recStatus = recStatus; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append(getClass().getSimpleName()); + sb.append(" ["); + sb.append("Hash = ").append(hashCode()); + sb.append(", id=").append(id); + sb.append(", idCard=").append(idCard); + sb.append(", phone=").append(phone); + sb.append(", operator=").append(operator); + sb.append(", createdAt=").append(createdAt); + sb.append(", updatedAt=").append(updatedAt); + sb.append(", recStatus=").append(recStatus); + sb.append("]"); + return sb.toString(); + } +} \ No newline at end of file diff --git a/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/bean/po/IdcUserDomain.java b/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/bean/po/IdcUserDomain.java new file mode 100644 index 0000000..7360ba4 --- /dev/null +++ b/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/bean/po/IdcUserDomain.java @@ -0,0 +1,172 @@ +package com.ccsens.dh_diplomatist.bean.po; + +import java.io.Serializable; +import java.util.Date; + +public class IdcUserDomain implements Serializable { + private Long id; + + private Long userId; + + private Long domainId; + + private Long domainUserId; + + private String name; + + private Byte gender; + + private String avatarUrl; + + private String country; + + private String province; + + private String city; + + private Long operator; + + private Date createdAt; + + private Date updatedAt; + + private Byte recStatus; + + private static final long serialVersionUID = 1L; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Long getUserId() { + return userId; + } + + public void setUserId(Long userId) { + this.userId = userId; + } + + public Long getDomainId() { + return domainId; + } + + public void setDomainId(Long domainId) { + this.domainId = domainId; + } + + public Long getDomainUserId() { + return domainUserId; + } + + public void setDomainUserId(Long domainUserId) { + this.domainUserId = domainUserId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name == null ? null : name.trim(); + } + + public Byte getGender() { + return gender; + } + + public void setGender(Byte gender) { + this.gender = gender; + } + + public String getAvatarUrl() { + return avatarUrl; + } + + public void setAvatarUrl(String avatarUrl) { + this.avatarUrl = avatarUrl == null ? null : avatarUrl.trim(); + } + + public String getCountry() { + return country; + } + + public void setCountry(String country) { + this.country = country == null ? null : country.trim(); + } + + public String getProvince() { + return province; + } + + public void setProvince(String province) { + this.province = province == null ? null : province.trim(); + } + + public String getCity() { + return city; + } + + public void setCity(String city) { + this.city = city == null ? null : city.trim(); + } + + public Long getOperator() { + return operator; + } + + public void setOperator(Long operator) { + this.operator = operator; + } + + public Date getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(Date createdAt) { + this.createdAt = createdAt; + } + + public Date getUpdatedAt() { + return updatedAt; + } + + public void setUpdatedAt(Date updatedAt) { + this.updatedAt = updatedAt; + } + + public Byte getRecStatus() { + return recStatus; + } + + public void setRecStatus(Byte recStatus) { + this.recStatus = recStatus; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append(getClass().getSimpleName()); + sb.append(" ["); + sb.append("Hash = ").append(hashCode()); + sb.append(", id=").append(id); + sb.append(", userId=").append(userId); + sb.append(", domainId=").append(domainId); + sb.append(", domainUserId=").append(domainUserId); + sb.append(", name=").append(name); + sb.append(", gender=").append(gender); + sb.append(", avatarUrl=").append(avatarUrl); + sb.append(", country=").append(country); + sb.append(", province=").append(province); + sb.append(", city=").append(city); + sb.append(", operator=").append(operator); + sb.append(", createdAt=").append(createdAt); + sb.append(", updatedAt=").append(updatedAt); + sb.append(", recStatus=").append(recStatus); + sb.append("]"); + return sb.toString(); + } +} \ No newline at end of file diff --git a/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/bean/po/IdcUserDomainExample.java b/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/bean/po/IdcUserDomainExample.java new file mode 100644 index 0000000..4515a3d --- /dev/null +++ b/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/bean/po/IdcUserDomainExample.java @@ -0,0 +1,1091 @@ +package com.ccsens.dh_diplomatist.bean.po; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +public class IdcUserDomainExample { + protected String orderByClause; + + protected boolean distinct; + + protected List oredCriteria; + + public IdcUserDomainExample() { + oredCriteria = new ArrayList(); + } + + public void setOrderByClause(String orderByClause) { + this.orderByClause = orderByClause; + } + + public String getOrderByClause() { + return orderByClause; + } + + public void setDistinct(boolean distinct) { + this.distinct = distinct; + } + + public boolean isDistinct() { + return distinct; + } + + public List getOredCriteria() { + return oredCriteria; + } + + public void or(Criteria criteria) { + oredCriteria.add(criteria); + } + + public Criteria or() { + Criteria criteria = createCriteriaInternal(); + oredCriteria.add(criteria); + return criteria; + } + + public Criteria createCriteria() { + Criteria criteria = createCriteriaInternal(); + if (oredCriteria.size() == 0) { + oredCriteria.add(criteria); + } + return criteria; + } + + protected Criteria createCriteriaInternal() { + Criteria criteria = new Criteria(); + return criteria; + } + + public void clear() { + oredCriteria.clear(); + orderByClause = null; + distinct = false; + } + + protected abstract static class GeneratedCriteria { + protected List criteria; + + protected GeneratedCriteria() { + super(); + criteria = new ArrayList(); + } + + public boolean isValid() { + return criteria.size() > 0; + } + + public List getAllCriteria() { + return criteria; + } + + public List getCriteria() { + return criteria; + } + + protected void addCriterion(String condition) { + if (condition == null) { + throw new RuntimeException("Value for condition cannot be null"); + } + criteria.add(new Criterion(condition)); + } + + protected void addCriterion(String condition, Object value, String property) { + if (value == null) { + throw new RuntimeException("Value for " + property + " cannot be null"); + } + criteria.add(new Criterion(condition, value)); + } + + protected void addCriterion(String condition, Object value1, Object value2, String property) { + if (value1 == null || value2 == null) { + throw new RuntimeException("Between values for " + property + " cannot be null"); + } + criteria.add(new Criterion(condition, value1, value2)); + } + + public Criteria andIdIsNull() { + addCriterion("id is null"); + return (Criteria) this; + } + + public Criteria andIdIsNotNull() { + addCriterion("id is not null"); + return (Criteria) this; + } + + public Criteria andIdEqualTo(Long value) { + addCriterion("id =", value, "id"); + return (Criteria) this; + } + + public Criteria andIdNotEqualTo(Long value) { + addCriterion("id <>", value, "id"); + return (Criteria) this; + } + + public Criteria andIdGreaterThan(Long value) { + addCriterion("id >", value, "id"); + return (Criteria) this; + } + + public Criteria andIdGreaterThanOrEqualTo(Long value) { + addCriterion("id >=", value, "id"); + return (Criteria) this; + } + + public Criteria andIdLessThan(Long value) { + addCriterion("id <", value, "id"); + return (Criteria) this; + } + + public Criteria andIdLessThanOrEqualTo(Long value) { + addCriterion("id <=", value, "id"); + return (Criteria) this; + } + + public Criteria andIdIn(List values) { + addCriterion("id in", values, "id"); + return (Criteria) this; + } + + public Criteria andIdNotIn(List values) { + addCriterion("id not in", values, "id"); + return (Criteria) this; + } + + public Criteria andIdBetween(Long value1, Long value2) { + addCriterion("id between", value1, value2, "id"); + return (Criteria) this; + } + + public Criteria andIdNotBetween(Long value1, Long value2) { + addCriterion("id not between", value1, value2, "id"); + return (Criteria) this; + } + + public Criteria andUserIdIsNull() { + addCriterion("user_id is null"); + return (Criteria) this; + } + + public Criteria andUserIdIsNotNull() { + addCriterion("user_id is not null"); + return (Criteria) this; + } + + public Criteria andUserIdEqualTo(Long value) { + addCriterion("user_id =", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdNotEqualTo(Long value) { + addCriterion("user_id <>", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdGreaterThan(Long value) { + addCriterion("user_id >", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdGreaterThanOrEqualTo(Long value) { + addCriterion("user_id >=", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdLessThan(Long value) { + addCriterion("user_id <", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdLessThanOrEqualTo(Long value) { + addCriterion("user_id <=", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdIn(List values) { + addCriterion("user_id in", values, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdNotIn(List values) { + addCriterion("user_id not in", values, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdBetween(Long value1, Long value2) { + addCriterion("user_id between", value1, value2, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdNotBetween(Long value1, Long value2) { + addCriterion("user_id not between", value1, value2, "userId"); + return (Criteria) this; + } + + public Criteria andDomainIdIsNull() { + addCriterion("domain_id is null"); + return (Criteria) this; + } + + public Criteria andDomainIdIsNotNull() { + addCriterion("domain_id is not null"); + return (Criteria) this; + } + + public Criteria andDomainIdEqualTo(Long value) { + addCriterion("domain_id =", value, "domainId"); + return (Criteria) this; + } + + public Criteria andDomainIdNotEqualTo(Long value) { + addCriterion("domain_id <>", value, "domainId"); + return (Criteria) this; + } + + public Criteria andDomainIdGreaterThan(Long value) { + addCriterion("domain_id >", value, "domainId"); + return (Criteria) this; + } + + public Criteria andDomainIdGreaterThanOrEqualTo(Long value) { + addCriterion("domain_id >=", value, "domainId"); + return (Criteria) this; + } + + public Criteria andDomainIdLessThan(Long value) { + addCriterion("domain_id <", value, "domainId"); + return (Criteria) this; + } + + public Criteria andDomainIdLessThanOrEqualTo(Long value) { + addCriterion("domain_id <=", value, "domainId"); + return (Criteria) this; + } + + public Criteria andDomainIdIn(List values) { + addCriterion("domain_id in", values, "domainId"); + return (Criteria) this; + } + + public Criteria andDomainIdNotIn(List values) { + addCriterion("domain_id not in", values, "domainId"); + return (Criteria) this; + } + + public Criteria andDomainIdBetween(Long value1, Long value2) { + addCriterion("domain_id between", value1, value2, "domainId"); + return (Criteria) this; + } + + public Criteria andDomainIdNotBetween(Long value1, Long value2) { + addCriterion("domain_id not between", value1, value2, "domainId"); + return (Criteria) this; + } + + public Criteria andDomainUserIdIsNull() { + addCriterion("domain_user_id is null"); + return (Criteria) this; + } + + public Criteria andDomainUserIdIsNotNull() { + addCriterion("domain_user_id is not null"); + return (Criteria) this; + } + + public Criteria andDomainUserIdEqualTo(Long value) { + addCriterion("domain_user_id =", value, "domainUserId"); + return (Criteria) this; + } + + public Criteria andDomainUserIdNotEqualTo(Long value) { + addCriterion("domain_user_id <>", value, "domainUserId"); + return (Criteria) this; + } + + public Criteria andDomainUserIdGreaterThan(Long value) { + addCriterion("domain_user_id >", value, "domainUserId"); + return (Criteria) this; + } + + public Criteria andDomainUserIdGreaterThanOrEqualTo(Long value) { + addCriterion("domain_user_id >=", value, "domainUserId"); + return (Criteria) this; + } + + public Criteria andDomainUserIdLessThan(Long value) { + addCriterion("domain_user_id <", value, "domainUserId"); + return (Criteria) this; + } + + public Criteria andDomainUserIdLessThanOrEqualTo(Long value) { + addCriterion("domain_user_id <=", value, "domainUserId"); + return (Criteria) this; + } + + public Criteria andDomainUserIdIn(List values) { + addCriterion("domain_user_id in", values, "domainUserId"); + return (Criteria) this; + } + + public Criteria andDomainUserIdNotIn(List values) { + addCriterion("domain_user_id not in", values, "domainUserId"); + return (Criteria) this; + } + + public Criteria andDomainUserIdBetween(Long value1, Long value2) { + addCriterion("domain_user_id between", value1, value2, "domainUserId"); + return (Criteria) this; + } + + public Criteria andDomainUserIdNotBetween(Long value1, Long value2) { + addCriterion("domain_user_id not between", value1, value2, "domainUserId"); + return (Criteria) this; + } + + public Criteria andNameIsNull() { + addCriterion("name is null"); + return (Criteria) this; + } + + public Criteria andNameIsNotNull() { + addCriterion("name is not null"); + return (Criteria) this; + } + + public Criteria andNameEqualTo(String value) { + addCriterion("name =", value, "name"); + return (Criteria) this; + } + + public Criteria andNameNotEqualTo(String value) { + addCriterion("name <>", value, "name"); + return (Criteria) this; + } + + public Criteria andNameGreaterThan(String value) { + addCriterion("name >", value, "name"); + return (Criteria) this; + } + + public Criteria andNameGreaterThanOrEqualTo(String value) { + addCriterion("name >=", value, "name"); + return (Criteria) this; + } + + public Criteria andNameLessThan(String value) { + addCriterion("name <", value, "name"); + return (Criteria) this; + } + + public Criteria andNameLessThanOrEqualTo(String value) { + addCriterion("name <=", value, "name"); + return (Criteria) this; + } + + public Criteria andNameLike(String value) { + addCriterion("name like", value, "name"); + return (Criteria) this; + } + + public Criteria andNameNotLike(String value) { + addCriterion("name not like", value, "name"); + return (Criteria) this; + } + + public Criteria andNameIn(List values) { + addCriterion("name in", values, "name"); + return (Criteria) this; + } + + public Criteria andNameNotIn(List values) { + addCriterion("name not in", values, "name"); + return (Criteria) this; + } + + public Criteria andNameBetween(String value1, String value2) { + addCriterion("name between", value1, value2, "name"); + return (Criteria) this; + } + + public Criteria andNameNotBetween(String value1, String value2) { + addCriterion("name not between", value1, value2, "name"); + return (Criteria) this; + } + + public Criteria andGenderIsNull() { + addCriterion("gender is null"); + return (Criteria) this; + } + + public Criteria andGenderIsNotNull() { + addCriterion("gender is not null"); + return (Criteria) this; + } + + public Criteria andGenderEqualTo(Byte value) { + addCriterion("gender =", value, "gender"); + return (Criteria) this; + } + + public Criteria andGenderNotEqualTo(Byte value) { + addCriterion("gender <>", value, "gender"); + return (Criteria) this; + } + + public Criteria andGenderGreaterThan(Byte value) { + addCriterion("gender >", value, "gender"); + return (Criteria) this; + } + + public Criteria andGenderGreaterThanOrEqualTo(Byte value) { + addCriterion("gender >=", value, "gender"); + return (Criteria) this; + } + + public Criteria andGenderLessThan(Byte value) { + addCriterion("gender <", value, "gender"); + return (Criteria) this; + } + + public Criteria andGenderLessThanOrEqualTo(Byte value) { + addCriterion("gender <=", value, "gender"); + return (Criteria) this; + } + + public Criteria andGenderIn(List values) { + addCriterion("gender in", values, "gender"); + return (Criteria) this; + } + + public Criteria andGenderNotIn(List values) { + addCriterion("gender not in", values, "gender"); + return (Criteria) this; + } + + public Criteria andGenderBetween(Byte value1, Byte value2) { + addCriterion("gender between", value1, value2, "gender"); + return (Criteria) this; + } + + public Criteria andGenderNotBetween(Byte value1, Byte value2) { + addCriterion("gender not between", value1, value2, "gender"); + return (Criteria) this; + } + + public Criteria andAvatarUrlIsNull() { + addCriterion("avatar_url is null"); + return (Criteria) this; + } + + public Criteria andAvatarUrlIsNotNull() { + addCriterion("avatar_url is not null"); + return (Criteria) this; + } + + public Criteria andAvatarUrlEqualTo(String value) { + addCriterion("avatar_url =", value, "avatarUrl"); + return (Criteria) this; + } + + public Criteria andAvatarUrlNotEqualTo(String value) { + addCriterion("avatar_url <>", value, "avatarUrl"); + return (Criteria) this; + } + + public Criteria andAvatarUrlGreaterThan(String value) { + addCriterion("avatar_url >", value, "avatarUrl"); + return (Criteria) this; + } + + public Criteria andAvatarUrlGreaterThanOrEqualTo(String value) { + addCriterion("avatar_url >=", value, "avatarUrl"); + return (Criteria) this; + } + + public Criteria andAvatarUrlLessThan(String value) { + addCriterion("avatar_url <", value, "avatarUrl"); + return (Criteria) this; + } + + public Criteria andAvatarUrlLessThanOrEqualTo(String value) { + addCriterion("avatar_url <=", value, "avatarUrl"); + return (Criteria) this; + } + + public Criteria andAvatarUrlLike(String value) { + addCriterion("avatar_url like", value, "avatarUrl"); + return (Criteria) this; + } + + public Criteria andAvatarUrlNotLike(String value) { + addCriterion("avatar_url not like", value, "avatarUrl"); + return (Criteria) this; + } + + public Criteria andAvatarUrlIn(List values) { + addCriterion("avatar_url in", values, "avatarUrl"); + return (Criteria) this; + } + + public Criteria andAvatarUrlNotIn(List values) { + addCriterion("avatar_url not in", values, "avatarUrl"); + return (Criteria) this; + } + + public Criteria andAvatarUrlBetween(String value1, String value2) { + addCriterion("avatar_url between", value1, value2, "avatarUrl"); + return (Criteria) this; + } + + public Criteria andAvatarUrlNotBetween(String value1, String value2) { + addCriterion("avatar_url not between", value1, value2, "avatarUrl"); + return (Criteria) this; + } + + public Criteria andCountryIsNull() { + addCriterion("country is null"); + return (Criteria) this; + } + + public Criteria andCountryIsNotNull() { + addCriterion("country is not null"); + return (Criteria) this; + } + + public Criteria andCountryEqualTo(String value) { + addCriterion("country =", value, "country"); + return (Criteria) this; + } + + public Criteria andCountryNotEqualTo(String value) { + addCriterion("country <>", value, "country"); + return (Criteria) this; + } + + public Criteria andCountryGreaterThan(String value) { + addCriterion("country >", value, "country"); + return (Criteria) this; + } + + public Criteria andCountryGreaterThanOrEqualTo(String value) { + addCriterion("country >=", value, "country"); + return (Criteria) this; + } + + public Criteria andCountryLessThan(String value) { + addCriterion("country <", value, "country"); + return (Criteria) this; + } + + public Criteria andCountryLessThanOrEqualTo(String value) { + addCriterion("country <=", value, "country"); + return (Criteria) this; + } + + public Criteria andCountryLike(String value) { + addCriterion("country like", value, "country"); + return (Criteria) this; + } + + public Criteria andCountryNotLike(String value) { + addCriterion("country not like", value, "country"); + return (Criteria) this; + } + + public Criteria andCountryIn(List values) { + addCriterion("country in", values, "country"); + return (Criteria) this; + } + + public Criteria andCountryNotIn(List values) { + addCriterion("country not in", values, "country"); + return (Criteria) this; + } + + public Criteria andCountryBetween(String value1, String value2) { + addCriterion("country between", value1, value2, "country"); + return (Criteria) this; + } + + public Criteria andCountryNotBetween(String value1, String value2) { + addCriterion("country not between", value1, value2, "country"); + return (Criteria) this; + } + + public Criteria andProvinceIsNull() { + addCriterion("province is null"); + return (Criteria) this; + } + + public Criteria andProvinceIsNotNull() { + addCriterion("province is not null"); + return (Criteria) this; + } + + public Criteria andProvinceEqualTo(String value) { + addCriterion("province =", value, "province"); + return (Criteria) this; + } + + public Criteria andProvinceNotEqualTo(String value) { + addCriterion("province <>", value, "province"); + return (Criteria) this; + } + + public Criteria andProvinceGreaterThan(String value) { + addCriterion("province >", value, "province"); + return (Criteria) this; + } + + public Criteria andProvinceGreaterThanOrEqualTo(String value) { + addCriterion("province >=", value, "province"); + return (Criteria) this; + } + + public Criteria andProvinceLessThan(String value) { + addCriterion("province <", value, "province"); + return (Criteria) this; + } + + public Criteria andProvinceLessThanOrEqualTo(String value) { + addCriterion("province <=", value, "province"); + return (Criteria) this; + } + + public Criteria andProvinceLike(String value) { + addCriterion("province like", value, "province"); + return (Criteria) this; + } + + public Criteria andProvinceNotLike(String value) { + addCriterion("province not like", value, "province"); + return (Criteria) this; + } + + public Criteria andProvinceIn(List values) { + addCriterion("province in", values, "province"); + return (Criteria) this; + } + + public Criteria andProvinceNotIn(List values) { + addCriterion("province not in", values, "province"); + return (Criteria) this; + } + + public Criteria andProvinceBetween(String value1, String value2) { + addCriterion("province between", value1, value2, "province"); + return (Criteria) this; + } + + public Criteria andProvinceNotBetween(String value1, String value2) { + addCriterion("province not between", value1, value2, "province"); + return (Criteria) this; + } + + public Criteria andCityIsNull() { + addCriterion("city is null"); + return (Criteria) this; + } + + public Criteria andCityIsNotNull() { + addCriterion("city is not null"); + return (Criteria) this; + } + + public Criteria andCityEqualTo(String value) { + addCriterion("city =", value, "city"); + return (Criteria) this; + } + + public Criteria andCityNotEqualTo(String value) { + addCriterion("city <>", value, "city"); + return (Criteria) this; + } + + public Criteria andCityGreaterThan(String value) { + addCriterion("city >", value, "city"); + return (Criteria) this; + } + + public Criteria andCityGreaterThanOrEqualTo(String value) { + addCriterion("city >=", value, "city"); + return (Criteria) this; + } + + public Criteria andCityLessThan(String value) { + addCriterion("city <", value, "city"); + return (Criteria) this; + } + + public Criteria andCityLessThanOrEqualTo(String value) { + addCriterion("city <=", value, "city"); + return (Criteria) this; + } + + public Criteria andCityLike(String value) { + addCriterion("city like", value, "city"); + return (Criteria) this; + } + + public Criteria andCityNotLike(String value) { + addCriterion("city not like", value, "city"); + return (Criteria) this; + } + + public Criteria andCityIn(List values) { + addCriterion("city in", values, "city"); + return (Criteria) this; + } + + public Criteria andCityNotIn(List values) { + addCriterion("city not in", values, "city"); + return (Criteria) this; + } + + public Criteria andCityBetween(String value1, String value2) { + addCriterion("city between", value1, value2, "city"); + return (Criteria) this; + } + + public Criteria andCityNotBetween(String value1, String value2) { + addCriterion("city not between", value1, value2, "city"); + return (Criteria) this; + } + + public Criteria andOperatorIsNull() { + addCriterion("operator is null"); + return (Criteria) this; + } + + public Criteria andOperatorIsNotNull() { + addCriterion("operator is not null"); + return (Criteria) this; + } + + public Criteria andOperatorEqualTo(Long value) { + addCriterion("operator =", value, "operator"); + return (Criteria) this; + } + + public Criteria andOperatorNotEqualTo(Long value) { + addCriterion("operator <>", value, "operator"); + return (Criteria) this; + } + + public Criteria andOperatorGreaterThan(Long value) { + addCriterion("operator >", value, "operator"); + return (Criteria) this; + } + + public Criteria andOperatorGreaterThanOrEqualTo(Long value) { + addCriterion("operator >=", value, "operator"); + return (Criteria) this; + } + + public Criteria andOperatorLessThan(Long value) { + addCriterion("operator <", value, "operator"); + return (Criteria) this; + } + + public Criteria andOperatorLessThanOrEqualTo(Long value) { + addCriterion("operator <=", value, "operator"); + return (Criteria) this; + } + + public Criteria andOperatorIn(List values) { + addCriterion("operator in", values, "operator"); + return (Criteria) this; + } + + public Criteria andOperatorNotIn(List values) { + addCriterion("operator not in", values, "operator"); + return (Criteria) this; + } + + public Criteria andOperatorBetween(Long value1, Long value2) { + addCriterion("operator between", value1, value2, "operator"); + return (Criteria) this; + } + + public Criteria andOperatorNotBetween(Long value1, Long value2) { + addCriterion("operator not between", value1, value2, "operator"); + return (Criteria) this; + } + + public Criteria andCreatedAtIsNull() { + addCriterion("created_at is null"); + return (Criteria) this; + } + + public Criteria andCreatedAtIsNotNull() { + addCriterion("created_at is not null"); + return (Criteria) this; + } + + public Criteria andCreatedAtEqualTo(Date value) { + addCriterion("created_at =", value, "createdAt"); + return (Criteria) this; + } + + public Criteria andCreatedAtNotEqualTo(Date value) { + addCriterion("created_at <>", value, "createdAt"); + return (Criteria) this; + } + + public Criteria andCreatedAtGreaterThan(Date value) { + addCriterion("created_at >", value, "createdAt"); + return (Criteria) this; + } + + public Criteria andCreatedAtGreaterThanOrEqualTo(Date value) { + addCriterion("created_at >=", value, "createdAt"); + return (Criteria) this; + } + + public Criteria andCreatedAtLessThan(Date value) { + addCriterion("created_at <", value, "createdAt"); + return (Criteria) this; + } + + public Criteria andCreatedAtLessThanOrEqualTo(Date value) { + addCriterion("created_at <=", value, "createdAt"); + return (Criteria) this; + } + + public Criteria andCreatedAtIn(List values) { + addCriterion("created_at in", values, "createdAt"); + return (Criteria) this; + } + + public Criteria andCreatedAtNotIn(List values) { + addCriterion("created_at not in", values, "createdAt"); + return (Criteria) this; + } + + public Criteria andCreatedAtBetween(Date value1, Date value2) { + addCriterion("created_at between", value1, value2, "createdAt"); + return (Criteria) this; + } + + public Criteria andCreatedAtNotBetween(Date value1, Date value2) { + addCriterion("created_at not between", value1, value2, "createdAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtIsNull() { + addCriterion("updated_at is null"); + return (Criteria) this; + } + + public Criteria andUpdatedAtIsNotNull() { + addCriterion("updated_at is not null"); + return (Criteria) this; + } + + public Criteria andUpdatedAtEqualTo(Date value) { + addCriterion("updated_at =", value, "updatedAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtNotEqualTo(Date value) { + addCriterion("updated_at <>", value, "updatedAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtGreaterThan(Date value) { + addCriterion("updated_at >", value, "updatedAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtGreaterThanOrEqualTo(Date value) { + addCriterion("updated_at >=", value, "updatedAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtLessThan(Date value) { + addCriterion("updated_at <", value, "updatedAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtLessThanOrEqualTo(Date value) { + addCriterion("updated_at <=", value, "updatedAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtIn(List values) { + addCriterion("updated_at in", values, "updatedAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtNotIn(List values) { + addCriterion("updated_at not in", values, "updatedAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtBetween(Date value1, Date value2) { + addCriterion("updated_at between", value1, value2, "updatedAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtNotBetween(Date value1, Date value2) { + addCriterion("updated_at not between", value1, value2, "updatedAt"); + return (Criteria) this; + } + + public Criteria andRecStatusIsNull() { + addCriterion("rec_status is null"); + return (Criteria) this; + } + + public Criteria andRecStatusIsNotNull() { + addCriterion("rec_status is not null"); + return (Criteria) this; + } + + public Criteria andRecStatusEqualTo(Byte value) { + addCriterion("rec_status =", value, "recStatus"); + return (Criteria) this; + } + + public Criteria andRecStatusNotEqualTo(Byte value) { + addCriterion("rec_status <>", value, "recStatus"); + return (Criteria) this; + } + + public Criteria andRecStatusGreaterThan(Byte value) { + addCriterion("rec_status >", value, "recStatus"); + return (Criteria) this; + } + + public Criteria andRecStatusGreaterThanOrEqualTo(Byte value) { + addCriterion("rec_status >=", value, "recStatus"); + return (Criteria) this; + } + + public Criteria andRecStatusLessThan(Byte value) { + addCriterion("rec_status <", value, "recStatus"); + return (Criteria) this; + } + + public Criteria andRecStatusLessThanOrEqualTo(Byte value) { + addCriterion("rec_status <=", value, "recStatus"); + return (Criteria) this; + } + + public Criteria andRecStatusIn(List values) { + addCriterion("rec_status in", values, "recStatus"); + return (Criteria) this; + } + + public Criteria andRecStatusNotIn(List values) { + addCriterion("rec_status not in", values, "recStatus"); + return (Criteria) this; + } + + public Criteria andRecStatusBetween(Byte value1, Byte value2) { + addCriterion("rec_status between", value1, value2, "recStatus"); + return (Criteria) this; + } + + public Criteria andRecStatusNotBetween(Byte value1, Byte value2) { + addCriterion("rec_status not between", value1, value2, "recStatus"); + return (Criteria) this; + } + } + + public static class Criteria extends GeneratedCriteria { + + protected Criteria() { + super(); + } + } + + public static class Criterion { + private String condition; + + private Object value; + + private Object secondValue; + + private boolean noValue; + + private boolean singleValue; + + private boolean betweenValue; + + private boolean listValue; + + private String typeHandler; + + public String getCondition() { + return condition; + } + + public Object getValue() { + return value; + } + + public Object getSecondValue() { + return secondValue; + } + + public boolean isNoValue() { + return noValue; + } + + public boolean isSingleValue() { + return singleValue; + } + + public boolean isBetweenValue() { + return betweenValue; + } + + public boolean isListValue() { + return listValue; + } + + public String getTypeHandler() { + return typeHandler; + } + + protected Criterion(String condition) { + super(); + this.condition = condition; + this.typeHandler = null; + this.noValue = true; + } + + protected Criterion(String condition, Object value, String typeHandler) { + super(); + this.condition = condition; + this.value = value; + this.typeHandler = typeHandler; + if (value instanceof List) { + this.listValue = true; + } else { + this.singleValue = true; + } + } + + protected Criterion(String condition, Object value) { + this(condition, value, null); + } + + protected Criterion(String condition, Object value, Object secondValue, String typeHandler) { + super(); + this.condition = condition; + this.value = value; + this.secondValue = secondValue; + this.typeHandler = typeHandler; + this.betweenValue = true; + } + + protected Criterion(String condition, Object value, Object secondValue) { + this(condition, value, secondValue, null); + } + } +} \ No newline at end of file diff --git a/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/bean/po/IdcUserExample.java b/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/bean/po/IdcUserExample.java new file mode 100644 index 0000000..6011d93 --- /dev/null +++ b/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/bean/po/IdcUserExample.java @@ -0,0 +1,641 @@ +package com.ccsens.dh_diplomatist.bean.po; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +public class IdcUserExample { + protected String orderByClause; + + protected boolean distinct; + + protected List oredCriteria; + + public IdcUserExample() { + oredCriteria = new ArrayList(); + } + + public void setOrderByClause(String orderByClause) { + this.orderByClause = orderByClause; + } + + public String getOrderByClause() { + return orderByClause; + } + + public void setDistinct(boolean distinct) { + this.distinct = distinct; + } + + public boolean isDistinct() { + return distinct; + } + + public List getOredCriteria() { + return oredCriteria; + } + + public void or(Criteria criteria) { + oredCriteria.add(criteria); + } + + public Criteria or() { + Criteria criteria = createCriteriaInternal(); + oredCriteria.add(criteria); + return criteria; + } + + public Criteria createCriteria() { + Criteria criteria = createCriteriaInternal(); + if (oredCriteria.size() == 0) { + oredCriteria.add(criteria); + } + return criteria; + } + + protected Criteria createCriteriaInternal() { + Criteria criteria = new Criteria(); + return criteria; + } + + public void clear() { + oredCriteria.clear(); + orderByClause = null; + distinct = false; + } + + protected abstract static class GeneratedCriteria { + protected List criteria; + + protected GeneratedCriteria() { + super(); + criteria = new ArrayList(); + } + + public boolean isValid() { + return criteria.size() > 0; + } + + public List getAllCriteria() { + return criteria; + } + + public List getCriteria() { + return criteria; + } + + protected void addCriterion(String condition) { + if (condition == null) { + throw new RuntimeException("Value for condition cannot be null"); + } + criteria.add(new Criterion(condition)); + } + + protected void addCriterion(String condition, Object value, String property) { + if (value == null) { + throw new RuntimeException("Value for " + property + " cannot be null"); + } + criteria.add(new Criterion(condition, value)); + } + + protected void addCriterion(String condition, Object value1, Object value2, String property) { + if (value1 == null || value2 == null) { + throw new RuntimeException("Between values for " + property + " cannot be null"); + } + criteria.add(new Criterion(condition, value1, value2)); + } + + public Criteria andIdIsNull() { + addCriterion("id is null"); + return (Criteria) this; + } + + public Criteria andIdIsNotNull() { + addCriterion("id is not null"); + return (Criteria) this; + } + + public Criteria andIdEqualTo(Long value) { + addCriterion("id =", value, "id"); + return (Criteria) this; + } + + public Criteria andIdNotEqualTo(Long value) { + addCriterion("id <>", value, "id"); + return (Criteria) this; + } + + public Criteria andIdGreaterThan(Long value) { + addCriterion("id >", value, "id"); + return (Criteria) this; + } + + public Criteria andIdGreaterThanOrEqualTo(Long value) { + addCriterion("id >=", value, "id"); + return (Criteria) this; + } + + public Criteria andIdLessThan(Long value) { + addCriterion("id <", value, "id"); + return (Criteria) this; + } + + public Criteria andIdLessThanOrEqualTo(Long value) { + addCriterion("id <=", value, "id"); + return (Criteria) this; + } + + public Criteria andIdIn(List values) { + addCriterion("id in", values, "id"); + return (Criteria) this; + } + + public Criteria andIdNotIn(List values) { + addCriterion("id not in", values, "id"); + return (Criteria) this; + } + + public Criteria andIdBetween(Long value1, Long value2) { + addCriterion("id between", value1, value2, "id"); + return (Criteria) this; + } + + public Criteria andIdNotBetween(Long value1, Long value2) { + addCriterion("id not between", value1, value2, "id"); + return (Criteria) this; + } + + public Criteria andIdCardIsNull() { + addCriterion("id_card is null"); + return (Criteria) this; + } + + public Criteria andIdCardIsNotNull() { + addCriterion("id_card is not null"); + return (Criteria) this; + } + + public Criteria andIdCardEqualTo(String value) { + addCriterion("id_card =", value, "idCard"); + return (Criteria) this; + } + + public Criteria andIdCardNotEqualTo(String value) { + addCriterion("id_card <>", value, "idCard"); + return (Criteria) this; + } + + public Criteria andIdCardGreaterThan(String value) { + addCriterion("id_card >", value, "idCard"); + return (Criteria) this; + } + + public Criteria andIdCardGreaterThanOrEqualTo(String value) { + addCriterion("id_card >=", value, "idCard"); + return (Criteria) this; + } + + public Criteria andIdCardLessThan(String value) { + addCriterion("id_card <", value, "idCard"); + return (Criteria) this; + } + + public Criteria andIdCardLessThanOrEqualTo(String value) { + addCriterion("id_card <=", value, "idCard"); + return (Criteria) this; + } + + public Criteria andIdCardLike(String value) { + addCriterion("id_card like", value, "idCard"); + return (Criteria) this; + } + + public Criteria andIdCardNotLike(String value) { + addCriterion("id_card not like", value, "idCard"); + return (Criteria) this; + } + + public Criteria andIdCardIn(List values) { + addCriterion("id_card in", values, "idCard"); + return (Criteria) this; + } + + public Criteria andIdCardNotIn(List values) { + addCriterion("id_card not in", values, "idCard"); + return (Criteria) this; + } + + public Criteria andIdCardBetween(String value1, String value2) { + addCriterion("id_card between", value1, value2, "idCard"); + return (Criteria) this; + } + + public Criteria andIdCardNotBetween(String value1, String value2) { + addCriterion("id_card not between", value1, value2, "idCard"); + return (Criteria) this; + } + + public Criteria andPhoneIsNull() { + addCriterion("phone is null"); + return (Criteria) this; + } + + public Criteria andPhoneIsNotNull() { + addCriterion("phone is not null"); + return (Criteria) this; + } + + public Criteria andPhoneEqualTo(String value) { + addCriterion("phone =", value, "phone"); + return (Criteria) this; + } + + public Criteria andPhoneNotEqualTo(String value) { + addCriterion("phone <>", value, "phone"); + return (Criteria) this; + } + + public Criteria andPhoneGreaterThan(String value) { + addCriterion("phone >", value, "phone"); + return (Criteria) this; + } + + public Criteria andPhoneGreaterThanOrEqualTo(String value) { + addCriterion("phone >=", value, "phone"); + return (Criteria) this; + } + + public Criteria andPhoneLessThan(String value) { + addCriterion("phone <", value, "phone"); + return (Criteria) this; + } + + public Criteria andPhoneLessThanOrEqualTo(String value) { + addCriterion("phone <=", value, "phone"); + return (Criteria) this; + } + + public Criteria andPhoneLike(String value) { + addCriterion("phone like", value, "phone"); + return (Criteria) this; + } + + public Criteria andPhoneNotLike(String value) { + addCriterion("phone not like", value, "phone"); + return (Criteria) this; + } + + public Criteria andPhoneIn(List values) { + addCriterion("phone in", values, "phone"); + return (Criteria) this; + } + + public Criteria andPhoneNotIn(List values) { + addCriterion("phone not in", values, "phone"); + return (Criteria) this; + } + + public Criteria andPhoneBetween(String value1, String value2) { + addCriterion("phone between", value1, value2, "phone"); + return (Criteria) this; + } + + public Criteria andPhoneNotBetween(String value1, String value2) { + addCriterion("phone not between", value1, value2, "phone"); + return (Criteria) this; + } + + public Criteria andOperatorIsNull() { + addCriterion("operator is null"); + return (Criteria) this; + } + + public Criteria andOperatorIsNotNull() { + addCriterion("operator is not null"); + return (Criteria) this; + } + + public Criteria andOperatorEqualTo(Long value) { + addCriterion("operator =", value, "operator"); + return (Criteria) this; + } + + public Criteria andOperatorNotEqualTo(Long value) { + addCriterion("operator <>", value, "operator"); + return (Criteria) this; + } + + public Criteria andOperatorGreaterThan(Long value) { + addCriterion("operator >", value, "operator"); + return (Criteria) this; + } + + public Criteria andOperatorGreaterThanOrEqualTo(Long value) { + addCriterion("operator >=", value, "operator"); + return (Criteria) this; + } + + public Criteria andOperatorLessThan(Long value) { + addCriterion("operator <", value, "operator"); + return (Criteria) this; + } + + public Criteria andOperatorLessThanOrEqualTo(Long value) { + addCriterion("operator <=", value, "operator"); + return (Criteria) this; + } + + public Criteria andOperatorIn(List values) { + addCriterion("operator in", values, "operator"); + return (Criteria) this; + } + + public Criteria andOperatorNotIn(List values) { + addCriterion("operator not in", values, "operator"); + return (Criteria) this; + } + + public Criteria andOperatorBetween(Long value1, Long value2) { + addCriterion("operator between", value1, value2, "operator"); + return (Criteria) this; + } + + public Criteria andOperatorNotBetween(Long value1, Long value2) { + addCriterion("operator not between", value1, value2, "operator"); + return (Criteria) this; + } + + public Criteria andCreatedAtIsNull() { + addCriterion("created_at is null"); + return (Criteria) this; + } + + public Criteria andCreatedAtIsNotNull() { + addCriterion("created_at is not null"); + return (Criteria) this; + } + + public Criteria andCreatedAtEqualTo(Date value) { + addCriterion("created_at =", value, "createdAt"); + return (Criteria) this; + } + + public Criteria andCreatedAtNotEqualTo(Date value) { + addCriterion("created_at <>", value, "createdAt"); + return (Criteria) this; + } + + public Criteria andCreatedAtGreaterThan(Date value) { + addCriterion("created_at >", value, "createdAt"); + return (Criteria) this; + } + + public Criteria andCreatedAtGreaterThanOrEqualTo(Date value) { + addCriterion("created_at >=", value, "createdAt"); + return (Criteria) this; + } + + public Criteria andCreatedAtLessThan(Date value) { + addCriterion("created_at <", value, "createdAt"); + return (Criteria) this; + } + + public Criteria andCreatedAtLessThanOrEqualTo(Date value) { + addCriterion("created_at <=", value, "createdAt"); + return (Criteria) this; + } + + public Criteria andCreatedAtIn(List values) { + addCriterion("created_at in", values, "createdAt"); + return (Criteria) this; + } + + public Criteria andCreatedAtNotIn(List values) { + addCriterion("created_at not in", values, "createdAt"); + return (Criteria) this; + } + + public Criteria andCreatedAtBetween(Date value1, Date value2) { + addCriterion("created_at between", value1, value2, "createdAt"); + return (Criteria) this; + } + + public Criteria andCreatedAtNotBetween(Date value1, Date value2) { + addCriterion("created_at not between", value1, value2, "createdAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtIsNull() { + addCriterion("updated_at is null"); + return (Criteria) this; + } + + public Criteria andUpdatedAtIsNotNull() { + addCriterion("updated_at is not null"); + return (Criteria) this; + } + + public Criteria andUpdatedAtEqualTo(Date value) { + addCriterion("updated_at =", value, "updatedAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtNotEqualTo(Date value) { + addCriterion("updated_at <>", value, "updatedAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtGreaterThan(Date value) { + addCriterion("updated_at >", value, "updatedAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtGreaterThanOrEqualTo(Date value) { + addCriterion("updated_at >=", value, "updatedAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtLessThan(Date value) { + addCriterion("updated_at <", value, "updatedAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtLessThanOrEqualTo(Date value) { + addCriterion("updated_at <=", value, "updatedAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtIn(List values) { + addCriterion("updated_at in", values, "updatedAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtNotIn(List values) { + addCriterion("updated_at not in", values, "updatedAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtBetween(Date value1, Date value2) { + addCriterion("updated_at between", value1, value2, "updatedAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtNotBetween(Date value1, Date value2) { + addCriterion("updated_at not between", value1, value2, "updatedAt"); + return (Criteria) this; + } + + public Criteria andRecStatusIsNull() { + addCriterion("rec_status is null"); + return (Criteria) this; + } + + public Criteria andRecStatusIsNotNull() { + addCriterion("rec_status is not null"); + return (Criteria) this; + } + + public Criteria andRecStatusEqualTo(Byte value) { + addCriterion("rec_status =", value, "recStatus"); + return (Criteria) this; + } + + public Criteria andRecStatusNotEqualTo(Byte value) { + addCriterion("rec_status <>", value, "recStatus"); + return (Criteria) this; + } + + public Criteria andRecStatusGreaterThan(Byte value) { + addCriterion("rec_status >", value, "recStatus"); + return (Criteria) this; + } + + public Criteria andRecStatusGreaterThanOrEqualTo(Byte value) { + addCriterion("rec_status >=", value, "recStatus"); + return (Criteria) this; + } + + public Criteria andRecStatusLessThan(Byte value) { + addCriterion("rec_status <", value, "recStatus"); + return (Criteria) this; + } + + public Criteria andRecStatusLessThanOrEqualTo(Byte value) { + addCriterion("rec_status <=", value, "recStatus"); + return (Criteria) this; + } + + public Criteria andRecStatusIn(List values) { + addCriterion("rec_status in", values, "recStatus"); + return (Criteria) this; + } + + public Criteria andRecStatusNotIn(List values) { + addCriterion("rec_status not in", values, "recStatus"); + return (Criteria) this; + } + + public Criteria andRecStatusBetween(Byte value1, Byte value2) { + addCriterion("rec_status between", value1, value2, "recStatus"); + return (Criteria) this; + } + + public Criteria andRecStatusNotBetween(Byte value1, Byte value2) { + addCriterion("rec_status not between", value1, value2, "recStatus"); + return (Criteria) this; + } + } + + public static class Criteria extends GeneratedCriteria { + + protected Criteria() { + super(); + } + } + + public static class Criterion { + private String condition; + + private Object value; + + private Object secondValue; + + private boolean noValue; + + private boolean singleValue; + + private boolean betweenValue; + + private boolean listValue; + + private String typeHandler; + + public String getCondition() { + return condition; + } + + public Object getValue() { + return value; + } + + public Object getSecondValue() { + return secondValue; + } + + public boolean isNoValue() { + return noValue; + } + + public boolean isSingleValue() { + return singleValue; + } + + public boolean isBetweenValue() { + return betweenValue; + } + + public boolean isListValue() { + return listValue; + } + + public String getTypeHandler() { + return typeHandler; + } + + protected Criterion(String condition) { + super(); + this.condition = condition; + this.typeHandler = null; + this.noValue = true; + } + + protected Criterion(String condition, Object value, String typeHandler) { + super(); + this.condition = condition; + this.value = value; + this.typeHandler = typeHandler; + if (value instanceof List) { + this.listValue = true; + } else { + this.singleValue = true; + } + } + + protected Criterion(String condition, Object value) { + this(condition, value, null); + } + + protected Criterion(String condition, Object value, Object secondValue, String typeHandler) { + super(); + this.condition = condition; + this.value = value; + this.secondValue = secondValue; + this.typeHandler = typeHandler; + this.betweenValue = true; + } + + protected Criterion(String condition, Object value, Object secondValue) { + this(condition, value, secondValue, null); + } + } +} \ No newline at end of file diff --git a/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/bean/vo/DomainVo.java b/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/bean/vo/DomainVo.java new file mode 100644 index 0000000..6b3772e --- /dev/null +++ b/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/bean/vo/DomainVo.java @@ -0,0 +1,46 @@ +package com.ccsens.dh_diplomatist.bean.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author 逗 + */ +@Data +public class DomainVo { + + @Data + @ApiModel("域信息") + public static class DomainInfo{ + @ApiModelProperty("域id") + private Long id; + @ApiModelProperty("域名称") + private String name; + @ApiModelProperty("域code") + private String code; + @ApiModelProperty("简介") + private String intro; + @ApiModelProperty("访问前缀") + private String url; + @ApiModelProperty("ip/域名") + private String host; + @ApiModelProperty("是否是自身 0否 1是") + private Byte self; + @ApiModelProperty("是否是当前域的公域 0否 1是") + private Byte pub; + @ApiModelProperty("是否轮询 0否 1是") + private Byte polling; + @ApiModelProperty("是否接受该域的请求 0否 1是") + private Byte answer; + @ApiModelProperty("最后更新时间") + private Long lastUpdateTime; + @ApiModelProperty("最后请求时间") + private Long lastAskTime; + @ApiModelProperty("最后应答时间") + private Long lastAnswerTime; + @ApiModelProperty("公钥") + private String publicKey; + } + +} diff --git a/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/config/BeanConfig.java b/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/config/BeanConfig.java new file mode 100644 index 0000000..73f9e04 --- /dev/null +++ b/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/config/BeanConfig.java @@ -0,0 +1,22 @@ +package com.ccsens.dh_diplomatist.config; + +import com.ccsens.dh_diplomatist.intercept.MybatisInterceptor; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * @description: + * @author: wuHuiJuan + * @create: 2019/12/03 18:01 + */ +@Configuration +public class BeanConfig { + /** + * 注册拦截器 + */ + @Bean + public MybatisInterceptor mybatisInterceptor() { + MybatisInterceptor interceptor = new MybatisInterceptor(); + return interceptor; + } +} diff --git a/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/config/SpringConfig.java b/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/config/SpringConfig.java new file mode 100644 index 0000000..5e22e30 --- /dev/null +++ b/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/config/SpringConfig.java @@ -0,0 +1,128 @@ +package com.ccsens.dh_diplomatist.config; + + +import cn.hutool.core.lang.Snowflake; +import cn.hutool.core.util.IdUtil; +import com.ccsens.util.config.DruidProps; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.module.SimpleModule; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.MediaType; +import org.springframework.http.converter.HttpMessageConverter; +import org.springframework.http.converter.StringHttpMessageConverter; +import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; +import org.springframework.web.servlet.config.annotation.*; + +import javax.annotation.Resource; +import javax.sql.DataSource; +import java.nio.charset.Charset; +import java.util.ArrayList; +import java.util.List; +import java.util.TimeZone; + +@Configuration +public class SpringConfig implements WebMvcConfigurer { + @Resource + private DruidProps druidPropsUtil; + @Value("${spring.snowflake.workerId}") + private String workerId; + @Value("${spring.snowflake.datacenterId}") + private String datacenterId; + + /** + * 配置Converter + * @return + */ + @Bean + public HttpMessageConverter responseStringConverter() { + StringHttpMessageConverter converter = new StringHttpMessageConverter( + Charset.forName("UTF-8")); + return converter; + } + + @Bean + public HttpMessageConverter responseJsonConverter(){ + MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter(); + List mediaTypeList = new ArrayList<>(); + mediaTypeList.add(MediaType.TEXT_HTML); + mediaTypeList.add(MediaType.APPLICATION_JSON_UTF8); + converter.setSupportedMediaTypes(mediaTypeList); + + ObjectMapper objectMapper = new ObjectMapper(); + SimpleModule simpleModule = new SimpleModule(); + simpleModule.addSerializer(Long.class, ToStringSerializer.instance); + simpleModule.addSerializer(Long.TYPE, ToStringSerializer.instance); + objectMapper.registerModule(simpleModule); + objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + objectMapper.setTimeZone(TimeZone.getTimeZone("GMT+8")); + converter.setObjectMapper(objectMapper); + + return converter; + } + + @Override + public void configureMessageConverters(List> converters) { + converters.add(responseStringConverter()); + converters.add(responseJsonConverter()); + } + + @Override + public void configureContentNegotiation(ContentNegotiationConfigurer configurer) { + configurer.favorPathExtension(false); + } + + @Override + public void addCorsMappings(CorsRegistry registry) { + registry.addMapping("/**").allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS") +// .allowedMethods("*") // 允许提交请求的方法,*表示全部允许 + .allowedOrigins("*") // #允许向该服务器提交请求的URI,*表示全部允许 + .allowCredentials(true) // 允许cookies跨域 + .allowedHeaders("*") // #允许访问的头信息,*表示全部 + .maxAge(18000L); // 预检请求的缓存时间(秒),即在这个时间段里,对于相同的跨域请求不会再预检了 + + } + + + + + /** + * 配置静态资源 + */ + @Override + public void addResourceHandlers(ResourceHandlerRegistry registry) { + registry.addResourceHandler("swagger-ui.html") + .addResourceLocations("classpath:/META-INF/resources/"); + registry.addResourceHandler("/webjars/**") + .addResourceLocations("classpath:/META-INF/resources/webjars/"); + + registry.addResourceHandler("/uploads/**") + .addResourceLocations("file:///home/diplomatist/service/uploads/"); + } + + /** + * 配置拦截器 + * @param registry + */ + @Override + public void addInterceptors(InterceptorRegistry registry) { + + } + + + /** + * 配置数据源(单数据源) + */ + @Bean + public DataSource dataSource(){ + return druidPropsUtil.createDruidDataSource(); + } + + @Bean + public Snowflake snowflake(){ + return IdUtil.createSnowflake(Long.valueOf(workerId), Long.valueOf(datacenterId)); + } +} \ No newline at end of file diff --git a/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/config/SwaggerConfigure.java b/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/config/SwaggerConfigure.java new file mode 100644 index 0000000..37ea18c --- /dev/null +++ b/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/config/SwaggerConfigure.java @@ -0,0 +1,56 @@ +package com.ccsens.dh_diplomatist.config; + +import com.ccsens.util.WebConstant; +import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import springfox.documentation.builders.ParameterBuilder; +import springfox.documentation.builders.RequestHandlerSelectors; +import springfox.documentation.schema.ModelRef; +import springfox.documentation.service.ApiInfo; +import springfox.documentation.service.Parameter; +import springfox.documentation.spi.DocumentationType; +import springfox.documentation.spring.web.plugins.Docket; +import springfox.documentation.swagger2.annotations.EnableSwagger2; + +import java.util.ArrayList; +import java.util.List; + +@Configuration +@EnableSwagger2 +@ConditionalOnExpression("${swagger.enable}") +//public class SwaggerConfigure extends WebMvcConfigurationSupport { +public class SwaggerConfigure /*implements WebMvcConfigurer*/ { + @Bean + public Docket customDocket() { + // + return new Docket(DocumentationType.SWAGGER_2) + .apiInfo(apiInfo()) + .select() + .apis(RequestHandlerSelectors + .basePackage("com.ccsens.dh_diplomatist.api")) + .build() + .globalOperationParameters(setHeaderToken()); + } + + private ApiInfo apiInfo() { + return new ApiInfo("Swagger Tall-game",//大标题 title + "This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.",//小标题 + "1.0.0",//版本 + "http://swagger.io/terms/",//termsOfServiceUrl + "zhangsan",//作者 + "Apache 2.0",//链接显示文字 + "http://www.apache.org/licenses/LICENSE-2.0.html"//网站链接 + ); + } + + private List setHeaderToken() { + ParameterBuilder tokenPar = new ParameterBuilder(); + List pars = new ArrayList<>(); + tokenPar.name(WebConstant.HEADER_KEY_TOKEN).description("token") + .defaultValue(WebConstant.HEADER_KEY_TOKEN_PREFIX) + .modelRef(new ModelRef("string")).parameterType("header").required(false).build(); + pars.add(tokenPar.build()); + return pars; + } +} diff --git a/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/intercept/MybatisInterceptor.java b/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/intercept/MybatisInterceptor.java new file mode 100644 index 0000000..8472180 --- /dev/null +++ b/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/intercept/MybatisInterceptor.java @@ -0,0 +1,159 @@ +package com.ccsens.dh_diplomatist.intercept; + +import cn.hutool.core.collection.CollectionUtil; +import com.ccsens.util.WebConstant; +import org.apache.ibatis.executor.Executor; +import org.apache.ibatis.mapping.BoundSql; +import org.apache.ibatis.mapping.MappedStatement; +import org.apache.ibatis.mapping.ResultMap; +import org.apache.ibatis.mapping.SqlSource; +import org.apache.ibatis.plugin.*; +import org.apache.ibatis.reflection.DefaultReflectorFactory; +import org.apache.ibatis.reflection.MetaObject; +import org.apache.ibatis.reflection.factory.DefaultObjectFactory; +import org.apache.ibatis.reflection.wrapper.DefaultObjectWrapperFactory; +import org.apache.ibatis.session.ResultHandler; +import org.apache.ibatis.session.RowBounds; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.List; +import java.util.Map; +import java.util.Properties; + +/** + * @description: + * @author: wuHuiJuan + * @create: 2019/12/11 10:58 + */ +@Intercepts({ + @Signature( + type = Executor.class, + method = "query", + args = {MappedStatement.class, Object.class, RowBounds.class, ResultHandler.class} + ) +}) +public class MybatisInterceptor implements Interceptor { + @Override + public Object intercept(Invocation invocation) throws Throwable { + + + String selectByExample = "selectByExample"; + String countByExample = "countByExample"; + String countByExample2 = "selectByExample_COUNT"; + String selectByPrimaryKey = "selectByPrimaryKey"; + + Object[] args = invocation.getArgs(); + MappedStatement statement = (MappedStatement) args[0]; + if (statement.getId().endsWith(selectByExample) + || statement.getId().endsWith(countByExample) + || statement.getId().endsWith(countByExample2)) { + //XXXExample + Object example = args[1]; + + addCondition(statement, example); + + + + + } else if (statement.getId().endsWith(selectByPrimaryKey)) { + BoundSql boundSql = statement.getBoundSql(args[1]); + String sql = boundSql.getSql() + " and rec_status = 0"; + MappedStatement newStatement = newMappedStatement(statement, new BoundSqlSqlSource(boundSql)); + MetaObject msObject = MetaObject.forObject(newStatement, new DefaultObjectFactory(), new DefaultObjectWrapperFactory(),new DefaultReflectorFactory()); + msObject.setValue("sqlSource.boundSql.sql", sql); + args[0] = newStatement; + } + + return invocation.proceed(); + } + + private void addCondition(MappedStatement statement, Object example) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException, ClassNotFoundException { + if (example instanceof Map) { + example = ((Map) example).get("_ORIGINAL_PARAMETER_OBJECT"); + } + + + Method method = example.getClass().getMethod("getOredCriteria", null); + //获取到条件数组,第一个是Criteria + List list = (List) method.invoke(example); + if (CollectionUtil.isEmpty(list)) { + Class clazz = ((ResultMap) statement.getResultMaps().get(0)).getType(); + String exampleName = clazz.getName() + "Example"; + Object paramExample = Class.forName(exampleName).newInstance(); + Method createCriteria = paramExample.getClass().getMethod("createCriteria"); + Object criteria = createCriteria.invoke(paramExample); + Method andIsDelEqualTo = criteria.getClass().getMethod("andRecStatusEqualTo", Byte.class); + andIsDelEqualTo.invoke(criteria, WebConstant.REC_STATUS.Normal.value); + list.add(criteria); + } else { + Object criteria = list.get(0); + Method getCriteria = criteria.getClass().getMethod("getCriteria"); + List params = (List) getCriteria.invoke(criteria); + boolean hasDel = false; + for (Object param : params) { + Method getCondition = param.getClass().getMethod("getCondition"); + Object condition = getCondition.invoke(param); + if ("rec_status =".equals(condition)) { + hasDel = true; + } + } + if (!hasDel) { + Method andIsDelEqualTo = criteria.getClass().getMethod("andRecStatusEqualTo", Byte.class); + andIsDelEqualTo.invoke(criteria, WebConstant.REC_STATUS.Normal.value); + } + + } + + } + + @Override + public Object plugin(Object target) { + return Plugin.wrap(target, this); + } + + @Override + public void setProperties(Properties properties) { + + } + + private MappedStatement newMappedStatement(MappedStatement ms, SqlSource newSqlSource) { + MappedStatement.Builder builder = + new MappedStatement.Builder(ms.getConfiguration(), ms.getId(), newSqlSource, ms.getSqlCommandType()); + builder.resource(ms.getResource()); + builder.fetchSize(ms.getFetchSize()); + builder.statementType(ms.getStatementType()); + builder.keyGenerator(ms.getKeyGenerator()); + if (ms.getKeyProperties() != null && ms.getKeyProperties().length != 0) { + StringBuilder keyProperties = new StringBuilder(); + for (String keyProperty : ms.getKeyProperties()) { + keyProperties.append(keyProperty).append(","); + } + keyProperties.delete(keyProperties.length() - 1, keyProperties.length()); + builder.keyProperty(keyProperties.toString()); + } + builder.timeout(ms.getTimeout()); + builder.parameterMap(ms.getParameterMap()); + builder.resultMaps(ms.getResultMaps()); + builder.resultSetType(ms.getResultSetType()); + builder.cache(ms.getCache()); + builder.flushCacheRequired(ms.isFlushCacheRequired()); + builder.useCache(ms.isUseCache()); + + return builder.build(); + } + + + // 定义一个内部辅助类,作用是包装sq + class BoundSqlSqlSource implements SqlSource { + private BoundSql boundSql; + public BoundSqlSqlSource(BoundSql boundSql) { + this.boundSql = boundSql; + } + @Override + public BoundSql getBoundSql(Object parameterObject) { + return boundSql; + } + } + +} diff --git a/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/persist/dao/IdcDomainDao.java b/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/persist/dao/IdcDomainDao.java new file mode 100644 index 0000000..47d5baa --- /dev/null +++ b/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/persist/dao/IdcDomainDao.java @@ -0,0 +1,44 @@ +package com.ccsens.dh_diplomatist.persist.dao; + +import com.ccsens.dh_diplomatist.bean.po.IdcDomain; +import com.ccsens.dh_diplomatist.bean.vo.DomainVo; +import com.ccsens.dh_diplomatist.persist.mapper.IdcDomainMapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * @author 逗 + */ +public interface IdcDomainDao extends IdcDomainMapper { + /** + * 根据code查询域信息 + * @param code 域code + * @return 返回域信息 + */ + IdcDomain getByCode(@Param("code") String code); + + /** + * 查找自己的域信息 + * @return 返回域信息 + */ + IdcDomain getOneself(); + + /** + * 查询所有需要轮询的域 + * @return 返回域列表 + */ + List getPolling(); + + /** + * 查询所有域排除自身和请求的域信息 + * @return 返回所有域信息 + */ + List queryAllDomain(); + + /** + * 查询公域信息 + * @return 返回公域信息 + */ + IdcDomain getPubDomain(); +} diff --git a/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/persist/mapper/IdcBusinessMapper.java b/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/persist/mapper/IdcBusinessMapper.java new file mode 100644 index 0000000..ff3ca74 --- /dev/null +++ b/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/persist/mapper/IdcBusinessMapper.java @@ -0,0 +1,30 @@ +package com.ccsens.dh_diplomatist.persist.mapper; + +import com.ccsens.dh_diplomatist.bean.po.IdcBusiness; +import com.ccsens.dh_diplomatist.bean.po.IdcBusinessExample; +import java.util.List; +import org.apache.ibatis.annotations.Param; + +public interface IdcBusinessMapper { + long countByExample(IdcBusinessExample example); + + int deleteByExample(IdcBusinessExample example); + + int deleteByPrimaryKey(Long id); + + int insert(IdcBusiness record); + + int insertSelective(IdcBusiness record); + + List selectByExample(IdcBusinessExample example); + + IdcBusiness selectByPrimaryKey(Long id); + + int updateByExampleSelective(@Param("record") IdcBusiness record, @Param("example") IdcBusinessExample example); + + int updateByExample(@Param("record") IdcBusiness record, @Param("example") IdcBusinessExample example); + + int updateByPrimaryKeySelective(IdcBusiness record); + + int updateByPrimaryKey(IdcBusiness record); +} \ No newline at end of file diff --git a/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/persist/mapper/IdcDomainBusinessMapper.java b/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/persist/mapper/IdcDomainBusinessMapper.java new file mode 100644 index 0000000..65a6a8d --- /dev/null +++ b/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/persist/mapper/IdcDomainBusinessMapper.java @@ -0,0 +1,30 @@ +package com.ccsens.dh_diplomatist.persist.mapper; + +import com.ccsens.dh_diplomatist.bean.po.IdcDomainBusiness; +import com.ccsens.dh_diplomatist.bean.po.IdcDomainBusinessExample; +import java.util.List; +import org.apache.ibatis.annotations.Param; + +public interface IdcDomainBusinessMapper { + long countByExample(IdcDomainBusinessExample example); + + int deleteByExample(IdcDomainBusinessExample example); + + int deleteByPrimaryKey(Long id); + + int insert(IdcDomainBusiness record); + + int insertSelective(IdcDomainBusiness record); + + List selectByExample(IdcDomainBusinessExample example); + + IdcDomainBusiness selectByPrimaryKey(Long id); + + int updateByExampleSelective(@Param("record") IdcDomainBusiness record, @Param("example") IdcDomainBusinessExample example); + + int updateByExample(@Param("record") IdcDomainBusiness record, @Param("example") IdcDomainBusinessExample example); + + int updateByPrimaryKeySelective(IdcDomainBusiness record); + + int updateByPrimaryKey(IdcDomainBusiness record); +} \ No newline at end of file diff --git a/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/persist/mapper/IdcDomainMapper.java b/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/persist/mapper/IdcDomainMapper.java new file mode 100644 index 0000000..2499a1a --- /dev/null +++ b/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/persist/mapper/IdcDomainMapper.java @@ -0,0 +1,30 @@ +package com.ccsens.dh_diplomatist.persist.mapper; + +import com.ccsens.dh_diplomatist.bean.po.IdcDomain; +import com.ccsens.dh_diplomatist.bean.po.IdcDomainExample; +import java.util.List; +import org.apache.ibatis.annotations.Param; + +public interface IdcDomainMapper { + long countByExample(IdcDomainExample example); + + int deleteByExample(IdcDomainExample example); + + int deleteByPrimaryKey(Long id); + + int insert(IdcDomain record); + + int insertSelective(IdcDomain record); + + List selectByExample(IdcDomainExample example); + + IdcDomain selectByPrimaryKey(Long id); + + int updateByExampleSelective(@Param("record") IdcDomain record, @Param("example") IdcDomainExample example); + + int updateByExample(@Param("record") IdcDomain record, @Param("example") IdcDomainExample example); + + int updateByPrimaryKeySelective(IdcDomain record); + + int updateByPrimaryKey(IdcDomain record); +} \ No newline at end of file diff --git a/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/persist/mapper/IdcUserDomainMapper.java b/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/persist/mapper/IdcUserDomainMapper.java new file mode 100644 index 0000000..370e3b0 --- /dev/null +++ b/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/persist/mapper/IdcUserDomainMapper.java @@ -0,0 +1,30 @@ +package com.ccsens.dh_diplomatist.persist.mapper; + +import com.ccsens.dh_diplomatist.bean.po.IdcUserDomain; +import com.ccsens.dh_diplomatist.bean.po.IdcUserDomainExample; +import java.util.List; +import org.apache.ibatis.annotations.Param; + +public interface IdcUserDomainMapper { + long countByExample(IdcUserDomainExample example); + + int deleteByExample(IdcUserDomainExample example); + + int deleteByPrimaryKey(Long id); + + int insert(IdcUserDomain record); + + int insertSelective(IdcUserDomain record); + + List selectByExample(IdcUserDomainExample example); + + IdcUserDomain selectByPrimaryKey(Long id); + + int updateByExampleSelective(@Param("record") IdcUserDomain record, @Param("example") IdcUserDomainExample example); + + int updateByExample(@Param("record") IdcUserDomain record, @Param("example") IdcUserDomainExample example); + + int updateByPrimaryKeySelective(IdcUserDomain record); + + int updateByPrimaryKey(IdcUserDomain record); +} \ No newline at end of file diff --git a/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/persist/mapper/IdcUserMapper.java b/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/persist/mapper/IdcUserMapper.java new file mode 100644 index 0000000..7fd6d98 --- /dev/null +++ b/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/persist/mapper/IdcUserMapper.java @@ -0,0 +1,30 @@ +package com.ccsens.dh_diplomatist.persist.mapper; + +import com.ccsens.dh_diplomatist.bean.po.IdcUser; +import com.ccsens.dh_diplomatist.bean.po.IdcUserExample; +import java.util.List; +import org.apache.ibatis.annotations.Param; + +public interface IdcUserMapper { + long countByExample(IdcUserExample example); + + int deleteByExample(IdcUserExample example); + + int deleteByPrimaryKey(Long id); + + int insert(IdcUser record); + + int insertSelective(IdcUser record); + + List selectByExample(IdcUserExample example); + + IdcUser selectByPrimaryKey(Long id); + + int updateByExampleSelective(@Param("record") IdcUser record, @Param("example") IdcUserExample example); + + int updateByExample(@Param("record") IdcUser record, @Param("example") IdcUserExample example); + + int updateByPrimaryKeySelective(IdcUser record); + + int updateByPrimaryKey(IdcUser record); +} \ No newline at end of file diff --git a/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/service/DomainService.java b/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/service/DomainService.java new file mode 100644 index 0000000..d5e0b6d --- /dev/null +++ b/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/service/DomainService.java @@ -0,0 +1,185 @@ +package com.ccsens.dh_diplomatist.service; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.lang.Snowflake; +import cn.hutool.core.util.CharsetUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import cn.hutool.crypto.asymmetric.KeyType; +import cn.hutool.crypto.asymmetric.RSA; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.ccsens.dh_diplomatist.bean.dto.HeartbeatDto; +import com.ccsens.dh_diplomatist.bean.po.IdcDomain; +import com.ccsens.dh_diplomatist.bean.vo.DomainVo; +import com.ccsens.dh_diplomatist.persist.dao.IdcDomainDao; +import com.ccsens.dh_diplomatist.util.DiplomatistCodeError; +import com.ccsens.util.RestTemplateUtil; +import com.ccsens.util.exception.BaseException; +import lombok.extern.slf4j.Slf4j; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +import javax.annotation.Resource; +import java.util.List; + +/** + * @author 逗 + */ +@Slf4j +@Service +@Transactional(propagation = Propagation.REQUIRED,rollbackFor = Exception.class) +public class DomainService implements IDomainService { + @Resource + private IdcDomainDao domainDao; + @Resource + private Snowflake snowflake; + + @Override + public List heartbeatQueryList(HeartbeatDto.SendDomain param, String clientIp) { + //TODO 验证通讯时间 + //根据code查找发送方域信息 + IdcDomain idcDomains = domainDao.getByCode(param.getCode()); + if(ObjectUtil.isNull(idcDomains)){ + //返回心跳异常 + log.info("未找到code对应的域"); + throw new BaseException(DiplomatistCodeError.GET_DOMAIN_ERROR); + } + //是否接受对方的请求 + if(idcDomains.getAnswer() == 0){ + //返回心跳异常 + log.info("不接受对方的请求"); + throw new BaseException(DiplomatistCodeError.GET_DOMAIN_ERROR); + } + //根据发送方公钥验证签名 + byte[] decrypt; + try { + RSA pub = new RSA(null, idcDomains.getPublicKey()); + decrypt = pub.decrypt(param.getData(), KeyType.PublicKey); + }catch (Exception e){ + log.info("验证签名失败:{}",e); + throw new BaseException(DiplomatistCodeError.GET_DOMAIN_ERROR); + } + //查询自身域信息 + IdcDomain selfDomains = domainDao.getOneself(); + HeartbeatDto.MessageDomainInfo domainInfo; + try { + //根据自身私钥解密 + RSA pri = new RSA(selfDomains.getPrivateKey(),null); + byte[] decrypt2 = pri.decrypt(decrypt, KeyType.PrivateKey); + log.info("解密未报错"); + //转换成对象 + domainInfo = JSON.parseObject(StrUtil.str(decrypt2, CharsetUtil.CHARSET_UTF_8), HeartbeatDto.MessageDomainInfo.class); + }catch (Exception e){ + log.info("解密失败:{}",e); + throw new BaseException(DiplomatistCodeError.GET_DOMAIN_ERROR); + } + //验证ip白名单是否匹配 + if(domainInfo == null || !domainInfo.getHost().equals(clientIp)){ + log.info("白名单不匹配:{}---实际请求{}",domainInfo,clientIp); +// throw new BaseException(dh_diplomatistCodeError.GET_DOMAIN_ERROR); + } + //查询除了自身的所有域信息并返回 + return domainDao.queryAllDomain(); + } + + + /** + * 定时请求公域更新自身域列表信息 + */ + @Scheduled(cron="0/30 * * * * ?") + public void sendHeartbeat(){ + log.info("请求公域更新自身域列表信息"); + //查询自身域信息 + IdcDomain selfDomains = domainDao.getOneself(); + HeartbeatDto.MessageDomainInfo msgDomainInfo = new HeartbeatDto.MessageDomainInfo(); + //发送的信息 + msgDomainInfo.setId(selfDomains.getId()); + msgDomainInfo.setName(selfDomains.getName()); + msgDomainInfo.setCode(selfDomains.getCode()); + msgDomainInfo.setHost(selfDomains.getHost()); + //查询自身的公域 + IdcDomain pubDomain = domainDao.getPubDomain(); + if(ObjectUtil.isNull(pubDomain)){ + return; + } + //使用对方的公钥加密 + RSA pub = new RSA(null, pubDomain.getPublicKey()); + byte[] encrypt = pub.encrypt(StrUtil.bytes(JSON.toJSONString(msgDomainInfo), CharsetUtil.CHARSET_UTF_8), KeyType.PublicKey); + //使用自己的私钥签名 + RSA pri = new RSA(selfDomains.getPrivateKey(),null); + byte[] encrypt2 = pri.encrypt(encrypt, KeyType.PrivateKey); + + //生成发送的对象 + HeartbeatDto.SendDomain sendDomain = new HeartbeatDto.SendDomain(); + sendDomain.setCode(selfDomains.getCode()); + sendDomain.setTimestamp(System.currentTimeMillis()); + //TODO 随机码 + sendDomain.setData(encrypt2); + //发送请求 + String url = pubDomain.getUrl() + "/domain/list"; +// String url = "http://localhost:7280/domain/list"; + log.info("调用接口:{}--{}", url, sendDomain); + String postBody = RestTemplateUtil.postBody(url, sendDomain); + System.out.println(postBody); + JSONObject jsonObject = JSONObject.parseObject(postBody); + log.info("接口返回:{}", jsonObject); + //请求正确返回则修改域列表信息,否则无操作 + Integer code = jsonObject.getInteger("code"); + if (code == null || code != 200) { + return; + } + JSONArray data = jsonObject.getJSONArray("data"); + if(CollectionUtil.isNotEmpty(data)){ + for (Object object : data) { + DomainVo.DomainInfo domainInfo; + try { + JSONObject object1 = (JSONObject) object; + domainInfo = object1.toJavaObject(DomainVo.DomainInfo.class); + }catch (Exception e){ + log.info(""+e); + continue; + } + IdcDomain idcDomain = domainDao.getByCode(domainInfo.getCode()); + + if(ObjectUtil.isNotNull(idcDomain)){ + //修改 + if(StrUtil.isNotBlank(domainInfo.getName()) && !domainInfo.getName().equals(idcDomain.getName())){ + idcDomain.setName(domainInfo.getName()); + idcDomain.setLastUpdateTime(System.currentTimeMillis()); + } + if(StrUtil.isNotBlank(domainInfo.getUrl()) && !domainInfo.getUrl().equals(idcDomain.getUrl())){ + idcDomain.setUrl(domainInfo.getUrl()); + idcDomain.setLastUpdateTime(System.currentTimeMillis()); + } + if(StrUtil.isNotBlank(domainInfo.getIntro()) && !domainInfo.getIntro().equals(idcDomain.getIntro())){ + idcDomain.setIntro(domainInfo.getIntro()); + idcDomain.setLastUpdateTime(System.currentTimeMillis()); + } + if(StrUtil.isNotBlank(domainInfo.getHost()) && !domainInfo.getHost().equals(idcDomain.getHost())){ + idcDomain.setHost(domainInfo.getHost()); + idcDomain.setLastUpdateTime(System.currentTimeMillis()); + } + if(StrUtil.isNotBlank(domainInfo.getPublicKey()) && !domainInfo.getPublicKey().equals(idcDomain.getPublicKey())){ + idcDomain.setPublicKey(domainInfo.getPublicKey()); + idcDomain.setLastUpdateTime(System.currentTimeMillis()); + } + domainDao.updateByPrimaryKeySelective(idcDomain); + }else { + //添加新域信息 + idcDomain = new IdcDomain(); + BeanUtil.copyProperties(domainInfo,idcDomain); + idcDomain.setId(snowflake.nextId()); + idcDomain.setLastAnswerTime(System.currentTimeMillis()); + idcDomain.setLastAskTime(System.currentTimeMillis()); + idcDomain.setLastUpdateTime(System.currentTimeMillis()); + domainDao.insertSelective(idcDomain); + } + } + } + } +} diff --git a/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/service/HeartbeatService.java b/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/service/HeartbeatService.java new file mode 100644 index 0000000..5339eca --- /dev/null +++ b/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/service/HeartbeatService.java @@ -0,0 +1,134 @@ +package com.ccsens.dh_diplomatist.service; + +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.util.CharsetUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import cn.hutool.crypto.asymmetric.KeyType; +import cn.hutool.crypto.asymmetric.RSA; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.ccsens.dh_diplomatist.bean.dto.HeartbeatDto; +import com.ccsens.dh_diplomatist.bean.po.IdcDomain; +import com.ccsens.dh_diplomatist.persist.dao.IdcDomainDao; +import com.ccsens.dh_diplomatist.util.DiplomatistCodeError; +import com.ccsens.util.RestTemplateUtil; +import com.ccsens.util.exception.BaseException; +import lombok.extern.slf4j.Slf4j; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +import javax.annotation.Resource; +import java.util.List; + +/** + * @author 逗 + */ +@Slf4j +@Service +@Transactional(propagation = Propagation.REQUIRED,rollbackFor = Exception.class) +public class HeartbeatService implements IHeartbeatService { + + @Resource + private IdcDomainDao domainDao; + + @Override + public void inHeartbeat(HeartbeatDto.SendDomain param, String clientIp) { + + //TODO 验证通讯时间 + //根据code查找发送方域信息 + IdcDomain idcDomains = domainDao.getByCode(param.getCode()); + if(ObjectUtil.isNull(idcDomains)){ + //返回心跳异常 + log.info("未找到code对应的域"); + throw new BaseException(DiplomatistCodeError.HEARTBEAT_ERROR); + } + //是否接受对方的请求 + if(idcDomains.getAnswer() == 0){ + //返回心跳异常 + log.info("不接受对方的请求"); + throw new BaseException(DiplomatistCodeError.HEARTBEAT_ERROR); + } + //根据发送方公钥验证签名 + byte[] decrypt; + try { + RSA pub = new RSA(null, idcDomains.getPublicKey()); + decrypt = pub.decrypt(param.getData(), KeyType.PublicKey); + }catch (Exception e){ + log.info("验证签名失败:{}",e); + throw new BaseException(DiplomatistCodeError.HEARTBEAT_ERROR); + } + //查询自身域信息 + IdcDomain selfDomains = domainDao.getOneself(); + HeartbeatDto.MessageDomainInfo domainInfo; + try { + //根据自身私钥解密 + RSA pri = new RSA(selfDomains.getPrivateKey(),null); + byte[] decrypt2 = pri.decrypt(decrypt, KeyType.PrivateKey); + //转换成对象 + domainInfo = JSON.parseObject(StrUtil.str(decrypt2, CharsetUtil.CHARSET_UTF_8), HeartbeatDto.MessageDomainInfo.class); + }catch (Exception e){ + log.info("解密失败:{}",e); + throw new BaseException(DiplomatistCodeError.HEARTBEAT_ERROR); + } + //验证ip白名单是否匹配 + if(domainInfo == null || !domainInfo.getHost().equals(clientIp)){ + log.info("白名单不匹配:{}---实际请求{}",domainInfo,clientIp); +// throw new BaseException(dh_diplomatistCodeError.HEARTBEAT_ERROR); + } + } + + + /** + * 定时发送心跳信息 + */ + @Scheduled(cron="0/30 * * * * ?") + public void sendHeartbeat(){ + log.info("发送心跳信息"); + //查询自身域信息 + IdcDomain selfDomains = domainDao.getOneself(); + HeartbeatDto.MessageDomainInfo domainInfo = new HeartbeatDto.MessageDomainInfo(); + //发送的信息 + domainInfo.setId(selfDomains.getId()); + domainInfo.setName(selfDomains.getName()); + domainInfo.setCode(selfDomains.getCode()); + domainInfo.setHost(selfDomains.getHost()); + + //查找需要轮询的域 + List idcDomains = domainDao.getPolling(); + if(CollectionUtil.isNotEmpty(idcDomains)){ + idcDomains.forEach(idcDomain -> { + //修改最后请求时间 + idcDomain.setLastAskTime(System.currentTimeMillis()); + domainDao.updateByPrimaryKeySelective(idcDomain); + //使用对方的公钥加密 + RSA pub = new RSA(null, idcDomain.getPublicKey()); + byte[] encrypt = pub.encrypt(StrUtil.bytes(JSON.toJSONString(domainInfo), CharsetUtil.CHARSET_UTF_8), KeyType.PublicKey); + //使用自己的私钥签名 + RSA pri = new RSA(selfDomains.getPrivateKey(),null); + byte[] encrypt2 = pri.encrypt(encrypt, KeyType.PrivateKey); + //生成发送的对象 + HeartbeatDto.SendDomain sendDomain = new HeartbeatDto.SendDomain(); + sendDomain.setCode(selfDomains.getCode()); + sendDomain.setTimestamp(System.currentTimeMillis()); + //TODO 随机码 + sendDomain.setData(encrypt2); + //发送心跳 + String url = idcDomain.getUrl() + "/heartbeat"; + log.info("调用接口:{}--{}", url, sendDomain); + String postBody = RestTemplateUtil.postBody(url, sendDomain); + System.out.println(postBody); + JSONObject jsonObject = JSONObject.parseObject(postBody); + log.info("接口返回:{}", jsonObject); + //请求正确返回则修改最后应答时间,否则无操作 + Integer code = jsonObject.getInteger("code"); + if (code != null && code == 200) { + idcDomain.setLastAnswerTime(System.currentTimeMillis()); + domainDao.updateByPrimaryKeySelective(idcDomain); + } + }); + } + } +} diff --git a/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/service/IDomainService.java b/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/service/IDomainService.java new file mode 100644 index 0000000..7758288 --- /dev/null +++ b/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/service/IDomainService.java @@ -0,0 +1,19 @@ +package com.ccsens.dh_diplomatist.service; + +import com.ccsens.dh_diplomatist.bean.dto.HeartbeatDto; +import com.ccsens.dh_diplomatist.bean.vo.DomainVo; + +import java.util.List; + +/** + * @author 逗 + */ +public interface IDomainService { + /** + * 接受私域发送的消息,返回域列表信息 + * @param param 发送放信息 + * @param clientIp 发送方ip + * @return 返回域列表 + */ + List heartbeatQueryList(HeartbeatDto.SendDomain param, String clientIp); +} diff --git a/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/service/IHeartbeatService.java b/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/service/IHeartbeatService.java new file mode 100644 index 0000000..a13d2ee --- /dev/null +++ b/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/service/IHeartbeatService.java @@ -0,0 +1,16 @@ +package com.ccsens.dh_diplomatist.service; + +import com.ccsens.dh_diplomatist.bean.dto.HeartbeatDto; + +/** + * @author 逗 + */ +public interface IHeartbeatService { + + /** + * 接受心跳并返回自身域列表 + * @param param 发送心跳的域的code和信息 + * @param clientIp 请求方的ip地址 + */ + void inHeartbeat(HeartbeatDto.SendDomain param, String clientIp); +} diff --git a/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/util/DiplomatistCodeError.java b/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/util/DiplomatistCodeError.java new file mode 100644 index 0000000..e371f4d --- /dev/null +++ b/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/util/DiplomatistCodeError.java @@ -0,0 +1,13 @@ +package com.ccsens.dh_diplomatist.util; + +import com.ccsens.util.CodeError; + +/** + * @author 逗 + */ +public class DiplomatistCodeError extends CodeError { + + public static final Code HEARTBEAT_ERROR = new Code(501,"心跳异常",true); + public static final Code GET_DOMAIN_ERROR = new Code(502,"查询域列表失败",true); + +} diff --git a/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/util/DiplomatistConstant.java b/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/util/DiplomatistConstant.java new file mode 100644 index 0000000..e201953 --- /dev/null +++ b/dh_diplomatist/src/main/java/com/ccsens/dh_diplomatist/util/DiplomatistConstant.java @@ -0,0 +1,50 @@ +package com.ccsens.dh_diplomatist.util; + +import java.util.HashMap; +import java.util.Map; + +/** + * @author 逗 + */ +public class DiplomatistConstant { + + /**图片类型*/ + public static final String FILE_TYPE_IMG = "bmp,jpg,jpeg,png,tif,gif,pcx,tga,exif,fpx,svg,psd,cdr,pcd,dxf,ufo,eps,ai,raw,WMF,webp"; + /**文档类型*/ + public static final String FILE_TYPE_DOCUMENT = "doc, dot, wps, wpt, docx, dotx, docm, dotm, xls, xlt, et, xlsx, xltx, csv, xlsm, xltm, ppt,pptx,pptm,ppsx,ppsm,pps,potx,potm,dpt,dps, pdf"; + + + /**验证手机正则*/ + public static final String PHONE_REGEX = "^[1]([3-9])[0-9]{9}$"; + /**字符串分隔符*/ + public static final String STRING_REGEX = ",|,|;|;|、|/"; + /**wbs相关*/ + public static final class WbsExcel { + /**wbsSheet*/ + public static final String WBS_SHEET = "WBS"; + /**项目成员Sheet*/ + public static final String MEMBER_SHEET = "项目成员表"; + /**项目信息头*/ + public static final String PROJECT_INFO_TITLE = "项目信息"; + /**任务信息头*/ + public static final String TASK_INFO_TITLE = "项目任务分解"; + /**excel文件格式验证*/ + public static final String WBS_FILE_FORMAT = "xls,xlsx"; + /**插件配置表*/ + public static final String WBS_PLUGIN_CONFIG = "插件配置表"; + } + + /**wbs表时长对应关系表*/ + public static final Map WBS_DURATION = new HashMap<>(); + static { + WBS_DURATION.put("s",1000L); + WBS_DURATION.put("min",60 * 1000L); + WBS_DURATION.put("h",60 * 60 * 1000L); + WBS_DURATION.put("d",24 * 60 * 60 * 1000L); + WBS_DURATION.put("w",7 * 24 * 60 * 60 * 1000L); + WBS_DURATION.put("m",30 * 24 * 60 * 60 * 1000L); + WBS_DURATION.put("y",365 * 24 * 60 * 60 * 1000L); + } + + +} diff --git a/dh_diplomatist/src/main/resources/application-common.yml b/dh_diplomatist/src/main/resources/application-common.yml new file mode 100644 index 0000000..7e1c8d3 --- /dev/null +++ b/dh_diplomatist/src/main/resources/application-common.yml @@ -0,0 +1,30 @@ +logging: + level: + com: + favorites: DEBUG + org: + hibernate: ERROR + springframework: + web: DEBUG +mybatis: + config-location: classpath:mybatis/mybatis-config.xml + mapper-locations: classpath*:mapper_*/*.xml +# type-aliases-package: com.ccsens.mtpro.bean +#server: +# tomcat: +# uri-encoding: UTF-8 +spring: + http: + encoding: + charset: UTF-8 + enabled: true + force: true + log-request-details: true + servlet: + multipart: + max-file-size: 10MB + max-request-size: 100MB + snowflake: + datacenterId: 9 + workerId: 1 + diff --git a/dh_diplomatist/src/main/resources/application-dev.yml b/dh_diplomatist/src/main/resources/application-dev.yml new file mode 100644 index 0000000..8fb42be --- /dev/null +++ b/dh_diplomatist/src/main/resources/application-dev.yml @@ -0,0 +1,51 @@ +server: + port: 7280 + servlet: + context-path: +spring: + application: + name: dh_diplomatist + datasource: + type: com.alibaba.druid.pool.DruidDataSource + rabbitmq: +# listener: +# direct: +# auto-startup: false +# simple: +# auto-startup: false + host: dd.tall.wiki + password: 111111 + port: 5672 + username: admin + redis: + database: 0 + host: 127.0.0.1 + jedis: + pool: + max-active: 200 + max-idle: 10 + max-wait: -1ms + min-idle: 0 + password: '' + port: 6379 + timeout: 1000ms +swagger: + enable: true +mybatisCache: + database: 1 + host: 127.0.0.1 + jedis: + pool: + max-active: 200 + max-idle: 10 + max-wait: -1 + min-idle: 0 + password: '' + port: 6379 + timeout: 1000 + + +file: + path: /home/diplomatist/service/uploads/ + domain: https://test.tall.wiki/gateway/dh_diplomatist + imgDomain: https://test.tall.wiki/gateway/dh_diplomatist/uploads/ diff --git a/dh_diplomatist/src/main/resources/application-prod.yml b/dh_diplomatist/src/main/resources/application-prod.yml new file mode 100644 index 0000000..bc7a262 --- /dev/null +++ b/dh_diplomatist/src/main/resources/application-prod.yml @@ -0,0 +1,40 @@ +server: + port: 7280 + servlet: + context-path: +spring: + application: + name: dh_diplomatist + datasource: + type: com.alibaba.druid.pool.DruidDataSource + rabbitmq: + host: 121.36.3.207 + password: 111111 + port: 5672 + username: admin + redis: + database: 0 + host: 127.0.0.1 + jedis: + pool: + max-active: 200 + max-idle: 10 + max-wait: -1ms + min-idle: 0 + password: '' +# password: 'areowqr!@43ef' + port: 6379 + timeout: 1000ms +swagger: + enable: true +eureka: + instance: + ip-address: 101.201.226.21 + +gatewayUrl: https://www.tall.wiki/gateway/ +notGatewayUrl: https://www.tall.wiki/ +apiUrl: https://www.tall.wiki/ +file: + path: /home/diplomatist/service/uploads/ + domain: https://www.tall.wiki/gateway/dh_diplomatist + imgDomain: https://www.tall.wiki/gateway/dh_diplomatist/uploads/ diff --git a/dh_diplomatist/src/main/resources/application-test.yml b/dh_diplomatist/src/main/resources/application-test.yml new file mode 100644 index 0000000..a5a8982 --- /dev/null +++ b/dh_diplomatist/src/main/resources/application-test.yml @@ -0,0 +1,48 @@ +server: + port: 7280 + servlet: + context-path: +spring: + application: + name: dh_diplomatist + datasource: + type: com.alibaba.druid.pool.DruidDataSource +# rabbitmq: +# host: dd.tall.wiki +# password: 111111 +# port: 5672 +# username: admin + redis: + database: 0 + host: 127.0.0.1 + jedis: + pool: + max-active: 200 + max-idle: 10 + max-wait: -1ms + min-idle: 0 + password: '' + port: 6379 + timeout: 1000ms +swagger: + enable: true +mybatisCache: + database: 1 + host: 127.0.0.1 + jedis: + pool: + max-active: 200 + max-idle: 10 + max-wait: -1 + min-idle: 0 + password: '' + port: 6379 + timeout: 1000 +eureka: + instance: + ip-address: 127.0.0.1 + +file: + path: /home/diplomatist/service/uploads/ + domain: https://test.tall.wiki/gateway/dh_diplomatist + imgDomain: https://test.tall.wiki/gateway/dh_diplomatist/uploads/ diff --git a/dh_diplomatist/src/main/resources/application.yml b/dh_diplomatist/src/main/resources/application.yml new file mode 100644 index 0000000..2fb38e5 --- /dev/null +++ b/dh_diplomatist/src/main/resources/application.yml @@ -0,0 +1,4 @@ +spring: + profiles: + active: dev + include: common, util-dev diff --git a/dh_diplomatist/src/main/resources/druid-dev.yml b/dh_diplomatist/src/main/resources/druid-dev.yml new file mode 100644 index 0000000..c761e18 --- /dev/null +++ b/dh_diplomatist/src/main/resources/druid-dev.yml @@ -0,0 +1,34 @@ +spring: + datasource: + druid: + connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000 + driverClassName: com.mysql.cj.jdbc.Driver + dynamicUrl: jdbc:mysql://localhost:3306/${schema} + filterExclusions: '*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*' + filterName: druidFilter + filterProfileEnable: true + filterUrlPattern: /* + filters: stat,wall + initialSize: 5 + maxActive: 20 + maxPoolPreparedStatementPerConnectionSize: 20 + maxWait: 60000 + minEvictableIdleTimeMillis: 300000 + minIdle: 5 +# password: + password: 68073a279b399baa1fa12cf39bfbb65bfc1480ffee7b659ccc81cf19be8c4473 + poolPreparedStatements: true + servletLogSlowSql: true + servletLoginPassword: 111111 + servletLoginUsername: druid + servletName: druidServlet + servletResetEnable: true + servletUrlMapping: /druid/* + testOnBorrow: false + testOnReturn: false + testWhileIdle: true + timeBetweenEvictionRunsMillis: 60000 + url: jdbc:mysql://101.201.226.163:3306/tall_dh?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&autoReconnect=true + username: root + validationQuery: SELECT 1 FROM DUAL + env: CCSENS_TALL \ No newline at end of file diff --git a/dh_diplomatist/src/main/resources/druid-prod.yml b/dh_diplomatist/src/main/resources/druid-prod.yml new file mode 100644 index 0000000..8e3c3c9 --- /dev/null +++ b/dh_diplomatist/src/main/resources/druid-prod.yml @@ -0,0 +1,35 @@ +spring: + datasource: + druid: + connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000 + driverClassName: com.mysql.cj.jdbc.Driver + dynamicUrl: jdbc:mysql://localhost:3306/${schema} + filterExclusions: '*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*' + filterName: druidFilter + filterProfileEnable: true + filterUrlPattern: /* + filters: stat,wall + initialSize: 5 + maxActive: 20 + maxPoolPreparedStatementPerConnectionSize: 20 + maxWait: 60000 + minEvictableIdleTimeMillis: 300000 + minIdle: 5 +# password: + password: 68073a279b399baa1fa12cf39bfbb65bfc1480ffee7b659ccc81cf19be8c4473 + poolPreparedStatements: true + servletLogSlowSql: true + servletLoginPassword: 111111 + servletLoginUsername: druid + servletName: druidServlet + servletResetEnable: true + servletUrlMapping: /druid/* + testOnBorrow: false + testOnReturn: false + testWhileIdle: true + timeBetweenEvictionRunsMillis: 60000 +# url: jdbc:mysql://127.0.0.1/defaultwbs?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&autoReconnect=true + url: jdbc:mysql://101.201.226.163:3306/tall_dm?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&autoReconnect=true + username: root + validationQuery: SELECT 1 FROM DUAL + env: CCSENS_TALL \ No newline at end of file diff --git a/dh_diplomatist/src/main/resources/druid-test.yml b/dh_diplomatist/src/main/resources/druid-test.yml new file mode 100644 index 0000000..e3c10f6 --- /dev/null +++ b/dh_diplomatist/src/main/resources/druid-test.yml @@ -0,0 +1,34 @@ +spring: + datasource: + druid: + connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000 + driverClassName: com.mysql.cj.jdbc.Driver + dynamicUrl: jdbc:mysql://localhost:3306/${schema} + filterExclusions: '*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*' + filterName: druidFilter + filterProfileEnable: true + filterUrlPattern: /* + filters: stat,wall + initialSize: 5 + maxActive: 20 + maxPoolPreparedStatementPerConnectionSize: 20 + maxWait: 60000 + minEvictableIdleTimeMillis: 300000 + minIdle: 5 +# password: 68073a279b399baa1fa12cf39bfbb65bfc1480ffee7b659ccc81cf19be8c4473 + password: + poolPreparedStatements: true + servletLogSlowSql: true + servletLoginPassword: 111111 + servletLoginUsername: druid + servletName: druidServlet + servletResetEnable: true + servletUrlMapping: /druid/* + testOnBorrow: false + testOnReturn: false + testWhileIdle: true + timeBetweenEvictionRunsMillis: 60000 + url: jdbc:mysql://101.201.226.163:3306/tall_dh?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&autoReconnect=true + username: root + validationQuery: SELECT 1 FROM DUAL + env: CCSENS_TALL \ No newline at end of file diff --git a/dh_diplomatist/src/main/resources/logback-spring.xml b/dh_diplomatist/src/main/resources/logback-spring.xml new file mode 100644 index 0000000..2a2bedc --- /dev/null +++ b/dh_diplomatist/src/main/resources/logback-spring.xml @@ -0,0 +1,196 @@ + + + + + + + + + + logback + + + + + + + + + + + + + + + + + info + + + ${CONSOLE_LOG_PATTERN} + + UTF-8 + + + + + + + + + + ${log.path}/log_debug.log + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n + UTF-8 + + + + + ${log.path}/debug/log-debug-%d{yyyy-MM-dd}.%i.log + + 100MB + + + 15 + + + + debug + ACCEPT + DENY + + + + + + + ${log.path}/log_info.log + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n + UTF-8 + + + + + ${log.path}/info/log-info-%d{yyyy-MM-dd}.%i.log + + 100MB + + + 15 + + + + info + ACCEPT + DENY + + + + + + + ${log.path}/log_warn.log + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n + UTF-8 + + + + ${log.path}/warn/log-warn-%d{yyyy-MM-dd}.%i.log + + 100MB + + + 15 + + + + warn + ACCEPT + DENY + + + + + + + + ${log.path}/log_error.log + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n + UTF-8 + + + + ${log.path}/error/log-error-%d{yyyy-MM-dd}.%i.log + + 100MB + + + 15 + + + + ERROR + ACCEPT + DENY + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/dh_diplomatist/src/main/resources/mapper_dao/SPluginDao.xml b/dh_diplomatist/src/main/resources/mapper_dao/SPluginDao.xml new file mode 100644 index 0000000..e6633d9 --- /dev/null +++ b/dh_diplomatist/src/main/resources/mapper_dao/SPluginDao.xml @@ -0,0 +1,47 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/dh_diplomatist/src/main/resources/mapper_raw/IdcBusinessMapper.xml b/dh_diplomatist/src/main/resources/mapper_raw/IdcBusinessMapper.xml new file mode 100644 index 0000000..acafc93 --- /dev/null +++ b/dh_diplomatist/src/main/resources/mapper_raw/IdcBusinessMapper.xml @@ -0,0 +1,275 @@ + + + + + + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + id, name, code, description, creator_id, operator, created_at, updated_at, rec_status + + + + + delete from t_idc_business + where id = #{id,jdbcType=BIGINT} + + + delete from t_idc_business + + + + + + insert into t_idc_business (id, name, code, + description, creator_id, operator, + created_at, updated_at, rec_status + ) + values (#{id,jdbcType=BIGINT}, #{name,jdbcType=VARCHAR}, #{code,jdbcType=VARCHAR}, + #{description,jdbcType=VARCHAR}, #{creatorId,jdbcType=BIGINT}, #{operator,jdbcType=BIGINT}, + #{createdAt,jdbcType=TIMESTAMP}, #{updatedAt,jdbcType=TIMESTAMP}, #{recStatus,jdbcType=TINYINT} + ) + + + insert into t_idc_business + + + id, + + + name, + + + code, + + + description, + + + creator_id, + + + operator, + + + created_at, + + + updated_at, + + + rec_status, + + + + + #{id,jdbcType=BIGINT}, + + + #{name,jdbcType=VARCHAR}, + + + #{code,jdbcType=VARCHAR}, + + + #{description,jdbcType=VARCHAR}, + + + #{creatorId,jdbcType=BIGINT}, + + + #{operator,jdbcType=BIGINT}, + + + #{createdAt,jdbcType=TIMESTAMP}, + + + #{updatedAt,jdbcType=TIMESTAMP}, + + + #{recStatus,jdbcType=TINYINT}, + + + + + + update t_idc_business + + + id = #{record.id,jdbcType=BIGINT}, + + + name = #{record.name,jdbcType=VARCHAR}, + + + code = #{record.code,jdbcType=VARCHAR}, + + + description = #{record.description,jdbcType=VARCHAR}, + + + creator_id = #{record.creatorId,jdbcType=BIGINT}, + + + operator = #{record.operator,jdbcType=BIGINT}, + + + created_at = #{record.createdAt,jdbcType=TIMESTAMP}, + + + updated_at = #{record.updatedAt,jdbcType=TIMESTAMP}, + + + rec_status = #{record.recStatus,jdbcType=TINYINT}, + + + + + + + + update t_idc_business + set id = #{record.id,jdbcType=BIGINT}, + name = #{record.name,jdbcType=VARCHAR}, + code = #{record.code,jdbcType=VARCHAR}, + description = #{record.description,jdbcType=VARCHAR}, + creator_id = #{record.creatorId,jdbcType=BIGINT}, + operator = #{record.operator,jdbcType=BIGINT}, + created_at = #{record.createdAt,jdbcType=TIMESTAMP}, + updated_at = #{record.updatedAt,jdbcType=TIMESTAMP}, + rec_status = #{record.recStatus,jdbcType=TINYINT} + + + + + + update t_idc_business + + + name = #{name,jdbcType=VARCHAR}, + + + code = #{code,jdbcType=VARCHAR}, + + + description = #{description,jdbcType=VARCHAR}, + + + creator_id = #{creatorId,jdbcType=BIGINT}, + + + operator = #{operator,jdbcType=BIGINT}, + + + created_at = #{createdAt,jdbcType=TIMESTAMP}, + + + updated_at = #{updatedAt,jdbcType=TIMESTAMP}, + + + rec_status = #{recStatus,jdbcType=TINYINT}, + + + where id = #{id,jdbcType=BIGINT} + + + update t_idc_business + set name = #{name,jdbcType=VARCHAR}, + code = #{code,jdbcType=VARCHAR}, + description = #{description,jdbcType=VARCHAR}, + creator_id = #{creatorId,jdbcType=BIGINT}, + operator = #{operator,jdbcType=BIGINT}, + created_at = #{createdAt,jdbcType=TIMESTAMP}, + updated_at = #{updatedAt,jdbcType=TIMESTAMP}, + rec_status = #{recStatus,jdbcType=TINYINT} + where id = #{id,jdbcType=BIGINT} + + \ No newline at end of file diff --git a/dh_diplomatist/src/main/resources/mapper_raw/IdcDomainBusinessMapper.xml b/dh_diplomatist/src/main/resources/mapper_raw/IdcDomainBusinessMapper.xml new file mode 100644 index 0000000..4521291 --- /dev/null +++ b/dh_diplomatist/src/main/resources/mapper_raw/IdcDomainBusinessMapper.xml @@ -0,0 +1,291 @@ + + + + + + + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + id, domain_id, business_id, url, app_id, secret, operator, created_at, updated_at, + rec_status + + + + + delete from t_idc_domain_business + where id = #{id,jdbcType=BIGINT} + + + delete from t_idc_domain_business + + + + + + insert into t_idc_domain_business (id, domain_id, business_id, + url, app_id, secret, + operator, created_at, updated_at, + rec_status) + values (#{id,jdbcType=BIGINT}, #{domainId,jdbcType=BIGINT}, #{businessId,jdbcType=BIGINT}, + #{url,jdbcType=VARCHAR}, #{appId,jdbcType=VARCHAR}, #{secret,jdbcType=VARCHAR}, + #{operator,jdbcType=BIGINT}, #{createdAt,jdbcType=TIMESTAMP}, #{updatedAt,jdbcType=TIMESTAMP}, + #{recStatus,jdbcType=TINYINT}) + + + insert into t_idc_domain_business + + + id, + + + domain_id, + + + business_id, + + + url, + + + app_id, + + + secret, + + + operator, + + + created_at, + + + updated_at, + + + rec_status, + + + + + #{id,jdbcType=BIGINT}, + + + #{domainId,jdbcType=BIGINT}, + + + #{businessId,jdbcType=BIGINT}, + + + #{url,jdbcType=VARCHAR}, + + + #{appId,jdbcType=VARCHAR}, + + + #{secret,jdbcType=VARCHAR}, + + + #{operator,jdbcType=BIGINT}, + + + #{createdAt,jdbcType=TIMESTAMP}, + + + #{updatedAt,jdbcType=TIMESTAMP}, + + + #{recStatus,jdbcType=TINYINT}, + + + + + + update t_idc_domain_business + + + id = #{record.id,jdbcType=BIGINT}, + + + domain_id = #{record.domainId,jdbcType=BIGINT}, + + + business_id = #{record.businessId,jdbcType=BIGINT}, + + + url = #{record.url,jdbcType=VARCHAR}, + + + app_id = #{record.appId,jdbcType=VARCHAR}, + + + secret = #{record.secret,jdbcType=VARCHAR}, + + + operator = #{record.operator,jdbcType=BIGINT}, + + + created_at = #{record.createdAt,jdbcType=TIMESTAMP}, + + + updated_at = #{record.updatedAt,jdbcType=TIMESTAMP}, + + + rec_status = #{record.recStatus,jdbcType=TINYINT}, + + + + + + + + update t_idc_domain_business + set id = #{record.id,jdbcType=BIGINT}, + domain_id = #{record.domainId,jdbcType=BIGINT}, + business_id = #{record.businessId,jdbcType=BIGINT}, + url = #{record.url,jdbcType=VARCHAR}, + app_id = #{record.appId,jdbcType=VARCHAR}, + secret = #{record.secret,jdbcType=VARCHAR}, + operator = #{record.operator,jdbcType=BIGINT}, + created_at = #{record.createdAt,jdbcType=TIMESTAMP}, + updated_at = #{record.updatedAt,jdbcType=TIMESTAMP}, + rec_status = #{record.recStatus,jdbcType=TINYINT} + + + + + + update t_idc_domain_business + + + domain_id = #{domainId,jdbcType=BIGINT}, + + + business_id = #{businessId,jdbcType=BIGINT}, + + + url = #{url,jdbcType=VARCHAR}, + + + app_id = #{appId,jdbcType=VARCHAR}, + + + secret = #{secret,jdbcType=VARCHAR}, + + + operator = #{operator,jdbcType=BIGINT}, + + + created_at = #{createdAt,jdbcType=TIMESTAMP}, + + + updated_at = #{updatedAt,jdbcType=TIMESTAMP}, + + + rec_status = #{recStatus,jdbcType=TINYINT}, + + + where id = #{id,jdbcType=BIGINT} + + + update t_idc_domain_business + set domain_id = #{domainId,jdbcType=BIGINT}, + business_id = #{businessId,jdbcType=BIGINT}, + url = #{url,jdbcType=VARCHAR}, + app_id = #{appId,jdbcType=VARCHAR}, + secret = #{secret,jdbcType=VARCHAR}, + operator = #{operator,jdbcType=BIGINT}, + created_at = #{createdAt,jdbcType=TIMESTAMP}, + updated_at = #{updatedAt,jdbcType=TIMESTAMP}, + rec_status = #{recStatus,jdbcType=TINYINT} + where id = #{id,jdbcType=BIGINT} + + \ No newline at end of file diff --git a/dh_diplomatist/src/main/resources/mapper_raw/IdcDomainMapper.xml b/dh_diplomatist/src/main/resources/mapper_raw/IdcDomainMapper.xml new file mode 100644 index 0000000..1d2a9c7 --- /dev/null +++ b/dh_diplomatist/src/main/resources/mapper_raw/IdcDomainMapper.xml @@ -0,0 +1,432 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + id, name, code, intro, url, host, self, pub, polling, answer, last_update_time, last_ask_time, + last_answer_time, public_key, private_key, operator, created_at, updated_at, rec_status + + + + + delete from t_idc_domain + where id = #{id,jdbcType=BIGINT} + + + delete from t_idc_domain + + + + + + insert into t_idc_domain (id, name, code, + intro, url, host, self, + pub, polling, answer, + last_update_time, last_ask_time, last_answer_time, + public_key, private_key, operator, + created_at, updated_at, rec_status + ) + values (#{id,jdbcType=BIGINT}, #{name,jdbcType=VARCHAR}, #{code,jdbcType=VARCHAR}, + #{intro,jdbcType=VARCHAR}, #{url,jdbcType=VARCHAR}, #{host,jdbcType=VARCHAR}, #{self,jdbcType=TINYINT}, + #{pub,jdbcType=TINYINT}, #{polling,jdbcType=TINYINT}, #{answer,jdbcType=TINYINT}, + #{lastUpdateTime,jdbcType=BIGINT}, #{lastAskTime,jdbcType=BIGINT}, #{lastAnswerTime,jdbcType=BIGINT}, + #{publicKey,jdbcType=VARCHAR}, #{privateKey,jdbcType=VARCHAR}, #{operator,jdbcType=BIGINT}, + #{createdAt,jdbcType=TIMESTAMP}, #{updatedAt,jdbcType=TIMESTAMP}, #{recStatus,jdbcType=TINYINT} + ) + + + insert into t_idc_domain + + + id, + + + name, + + + code, + + + intro, + + + url, + + + host, + + + self, + + + pub, + + + polling, + + + answer, + + + last_update_time, + + + last_ask_time, + + + last_answer_time, + + + public_key, + + + private_key, + + + operator, + + + created_at, + + + updated_at, + + + rec_status, + + + + + #{id,jdbcType=BIGINT}, + + + #{name,jdbcType=VARCHAR}, + + + #{code,jdbcType=VARCHAR}, + + + #{intro,jdbcType=VARCHAR}, + + + #{url,jdbcType=VARCHAR}, + + + #{host,jdbcType=VARCHAR}, + + + #{self,jdbcType=TINYINT}, + + + #{pub,jdbcType=TINYINT}, + + + #{polling,jdbcType=TINYINT}, + + + #{answer,jdbcType=TINYINT}, + + + #{lastUpdateTime,jdbcType=BIGINT}, + + + #{lastAskTime,jdbcType=BIGINT}, + + + #{lastAnswerTime,jdbcType=BIGINT}, + + + #{publicKey,jdbcType=VARCHAR}, + + + #{privateKey,jdbcType=VARCHAR}, + + + #{operator,jdbcType=BIGINT}, + + + #{createdAt,jdbcType=TIMESTAMP}, + + + #{updatedAt,jdbcType=TIMESTAMP}, + + + #{recStatus,jdbcType=TINYINT}, + + + + + + update t_idc_domain + + + id = #{record.id,jdbcType=BIGINT}, + + + name = #{record.name,jdbcType=VARCHAR}, + + + code = #{record.code,jdbcType=VARCHAR}, + + + intro = #{record.intro,jdbcType=VARCHAR}, + + + url = #{record.url,jdbcType=VARCHAR}, + + + host = #{record.host,jdbcType=VARCHAR}, + + + self = #{record.self,jdbcType=TINYINT}, + + + pub = #{record.pub,jdbcType=TINYINT}, + + + polling = #{record.polling,jdbcType=TINYINT}, + + + answer = #{record.answer,jdbcType=TINYINT}, + + + last_update_time = #{record.lastUpdateTime,jdbcType=BIGINT}, + + + last_ask_time = #{record.lastAskTime,jdbcType=BIGINT}, + + + last_answer_time = #{record.lastAnswerTime,jdbcType=BIGINT}, + + + public_key = #{record.publicKey,jdbcType=VARCHAR}, + + + private_key = #{record.privateKey,jdbcType=VARCHAR}, + + + operator = #{record.operator,jdbcType=BIGINT}, + + + created_at = #{record.createdAt,jdbcType=TIMESTAMP}, + + + updated_at = #{record.updatedAt,jdbcType=TIMESTAMP}, + + + rec_status = #{record.recStatus,jdbcType=TINYINT}, + + + + + + + + update t_idc_domain + set id = #{record.id,jdbcType=BIGINT}, + name = #{record.name,jdbcType=VARCHAR}, + code = #{record.code,jdbcType=VARCHAR}, + intro = #{record.intro,jdbcType=VARCHAR}, + url = #{record.url,jdbcType=VARCHAR}, + host = #{record.host,jdbcType=VARCHAR}, + self = #{record.self,jdbcType=TINYINT}, + pub = #{record.pub,jdbcType=TINYINT}, + polling = #{record.polling,jdbcType=TINYINT}, + answer = #{record.answer,jdbcType=TINYINT}, + last_update_time = #{record.lastUpdateTime,jdbcType=BIGINT}, + last_ask_time = #{record.lastAskTime,jdbcType=BIGINT}, + last_answer_time = #{record.lastAnswerTime,jdbcType=BIGINT}, + public_key = #{record.publicKey,jdbcType=VARCHAR}, + private_key = #{record.privateKey,jdbcType=VARCHAR}, + operator = #{record.operator,jdbcType=BIGINT}, + created_at = #{record.createdAt,jdbcType=TIMESTAMP}, + updated_at = #{record.updatedAt,jdbcType=TIMESTAMP}, + rec_status = #{record.recStatus,jdbcType=TINYINT} + + + + + + update t_idc_domain + + + name = #{name,jdbcType=VARCHAR}, + + + code = #{code,jdbcType=VARCHAR}, + + + intro = #{intro,jdbcType=VARCHAR}, + + + url = #{url,jdbcType=VARCHAR}, + + + host = #{host,jdbcType=VARCHAR}, + + + self = #{self,jdbcType=TINYINT}, + + + pub = #{pub,jdbcType=TINYINT}, + + + polling = #{polling,jdbcType=TINYINT}, + + + answer = #{answer,jdbcType=TINYINT}, + + + last_update_time = #{lastUpdateTime,jdbcType=BIGINT}, + + + last_ask_time = #{lastAskTime,jdbcType=BIGINT}, + + + last_answer_time = #{lastAnswerTime,jdbcType=BIGINT}, + + + public_key = #{publicKey,jdbcType=VARCHAR}, + + + private_key = #{privateKey,jdbcType=VARCHAR}, + + + operator = #{operator,jdbcType=BIGINT}, + + + created_at = #{createdAt,jdbcType=TIMESTAMP}, + + + updated_at = #{updatedAt,jdbcType=TIMESTAMP}, + + + rec_status = #{recStatus,jdbcType=TINYINT}, + + + where id = #{id,jdbcType=BIGINT} + + + update t_idc_domain + set name = #{name,jdbcType=VARCHAR}, + code = #{code,jdbcType=VARCHAR}, + intro = #{intro,jdbcType=VARCHAR}, + url = #{url,jdbcType=VARCHAR}, + host = #{host,jdbcType=VARCHAR}, + self = #{self,jdbcType=TINYINT}, + pub = #{pub,jdbcType=TINYINT}, + polling = #{polling,jdbcType=TINYINT}, + answer = #{answer,jdbcType=TINYINT}, + last_update_time = #{lastUpdateTime,jdbcType=BIGINT}, + last_ask_time = #{lastAskTime,jdbcType=BIGINT}, + last_answer_time = #{lastAnswerTime,jdbcType=BIGINT}, + public_key = #{publicKey,jdbcType=VARCHAR}, + private_key = #{privateKey,jdbcType=VARCHAR}, + operator = #{operator,jdbcType=BIGINT}, + created_at = #{createdAt,jdbcType=TIMESTAMP}, + updated_at = #{updatedAt,jdbcType=TIMESTAMP}, + rec_status = #{recStatus,jdbcType=TINYINT} + where id = #{id,jdbcType=BIGINT} + + \ No newline at end of file diff --git a/dh_diplomatist/src/main/resources/mapper_raw/IdcUserDomainMapper.xml b/dh_diplomatist/src/main/resources/mapper_raw/IdcUserDomainMapper.xml new file mode 100644 index 0000000..7d0d83d --- /dev/null +++ b/dh_diplomatist/src/main/resources/mapper_raw/IdcUserDomainMapper.xml @@ -0,0 +1,353 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + id, user_id, domain_id, domain_user_id, name, gender, avatar_url, country, province, + city, operator, created_at, updated_at, rec_status + + + + + delete from t_idc_user_domain + where id = #{id,jdbcType=BIGINT} + + + delete from t_idc_user_domain + + + + + + insert into t_idc_user_domain (id, user_id, domain_id, + domain_user_id, name, gender, + avatar_url, country, province, + city, operator, created_at, + updated_at, rec_status) + values (#{id,jdbcType=BIGINT}, #{userId,jdbcType=BIGINT}, #{domainId,jdbcType=BIGINT}, + #{domainUserId,jdbcType=BIGINT}, #{name,jdbcType=VARCHAR}, #{gender,jdbcType=TINYINT}, + #{avatarUrl,jdbcType=VARCHAR}, #{country,jdbcType=VARCHAR}, #{province,jdbcType=VARCHAR}, + #{city,jdbcType=VARCHAR}, #{operator,jdbcType=BIGINT}, #{createdAt,jdbcType=TIMESTAMP}, + #{updatedAt,jdbcType=TIMESTAMP}, #{recStatus,jdbcType=TINYINT}) + + + insert into t_idc_user_domain + + + id, + + + user_id, + + + domain_id, + + + domain_user_id, + + + name, + + + gender, + + + avatar_url, + + + country, + + + province, + + + city, + + + operator, + + + created_at, + + + updated_at, + + + rec_status, + + + + + #{id,jdbcType=BIGINT}, + + + #{userId,jdbcType=BIGINT}, + + + #{domainId,jdbcType=BIGINT}, + + + #{domainUserId,jdbcType=BIGINT}, + + + #{name,jdbcType=VARCHAR}, + + + #{gender,jdbcType=TINYINT}, + + + #{avatarUrl,jdbcType=VARCHAR}, + + + #{country,jdbcType=VARCHAR}, + + + #{province,jdbcType=VARCHAR}, + + + #{city,jdbcType=VARCHAR}, + + + #{operator,jdbcType=BIGINT}, + + + #{createdAt,jdbcType=TIMESTAMP}, + + + #{updatedAt,jdbcType=TIMESTAMP}, + + + #{recStatus,jdbcType=TINYINT}, + + + + + + update t_idc_user_domain + + + id = #{record.id,jdbcType=BIGINT}, + + + user_id = #{record.userId,jdbcType=BIGINT}, + + + domain_id = #{record.domainId,jdbcType=BIGINT}, + + + domain_user_id = #{record.domainUserId,jdbcType=BIGINT}, + + + name = #{record.name,jdbcType=VARCHAR}, + + + gender = #{record.gender,jdbcType=TINYINT}, + + + avatar_url = #{record.avatarUrl,jdbcType=VARCHAR}, + + + country = #{record.country,jdbcType=VARCHAR}, + + + province = #{record.province,jdbcType=VARCHAR}, + + + city = #{record.city,jdbcType=VARCHAR}, + + + operator = #{record.operator,jdbcType=BIGINT}, + + + created_at = #{record.createdAt,jdbcType=TIMESTAMP}, + + + updated_at = #{record.updatedAt,jdbcType=TIMESTAMP}, + + + rec_status = #{record.recStatus,jdbcType=TINYINT}, + + + + + + + + update t_idc_user_domain + set id = #{record.id,jdbcType=BIGINT}, + user_id = #{record.userId,jdbcType=BIGINT}, + domain_id = #{record.domainId,jdbcType=BIGINT}, + domain_user_id = #{record.domainUserId,jdbcType=BIGINT}, + name = #{record.name,jdbcType=VARCHAR}, + gender = #{record.gender,jdbcType=TINYINT}, + avatar_url = #{record.avatarUrl,jdbcType=VARCHAR}, + country = #{record.country,jdbcType=VARCHAR}, + province = #{record.province,jdbcType=VARCHAR}, + city = #{record.city,jdbcType=VARCHAR}, + operator = #{record.operator,jdbcType=BIGINT}, + created_at = #{record.createdAt,jdbcType=TIMESTAMP}, + updated_at = #{record.updatedAt,jdbcType=TIMESTAMP}, + rec_status = #{record.recStatus,jdbcType=TINYINT} + + + + + + update t_idc_user_domain + + + user_id = #{userId,jdbcType=BIGINT}, + + + domain_id = #{domainId,jdbcType=BIGINT}, + + + domain_user_id = #{domainUserId,jdbcType=BIGINT}, + + + name = #{name,jdbcType=VARCHAR}, + + + gender = #{gender,jdbcType=TINYINT}, + + + avatar_url = #{avatarUrl,jdbcType=VARCHAR}, + + + country = #{country,jdbcType=VARCHAR}, + + + province = #{province,jdbcType=VARCHAR}, + + + city = #{city,jdbcType=VARCHAR}, + + + operator = #{operator,jdbcType=BIGINT}, + + + created_at = #{createdAt,jdbcType=TIMESTAMP}, + + + updated_at = #{updatedAt,jdbcType=TIMESTAMP}, + + + rec_status = #{recStatus,jdbcType=TINYINT}, + + + where id = #{id,jdbcType=BIGINT} + + + update t_idc_user_domain + set user_id = #{userId,jdbcType=BIGINT}, + domain_id = #{domainId,jdbcType=BIGINT}, + domain_user_id = #{domainUserId,jdbcType=BIGINT}, + name = #{name,jdbcType=VARCHAR}, + gender = #{gender,jdbcType=TINYINT}, + avatar_url = #{avatarUrl,jdbcType=VARCHAR}, + country = #{country,jdbcType=VARCHAR}, + province = #{province,jdbcType=VARCHAR}, + city = #{city,jdbcType=VARCHAR}, + operator = #{operator,jdbcType=BIGINT}, + created_at = #{createdAt,jdbcType=TIMESTAMP}, + updated_at = #{updatedAt,jdbcType=TIMESTAMP}, + rec_status = #{recStatus,jdbcType=TINYINT} + where id = #{id,jdbcType=BIGINT} + + \ No newline at end of file diff --git a/dh_diplomatist/src/main/resources/mapper_raw/IdcUserMapper.xml b/dh_diplomatist/src/main/resources/mapper_raw/IdcUserMapper.xml new file mode 100644 index 0000000..3dfa506 --- /dev/null +++ b/dh_diplomatist/src/main/resources/mapper_raw/IdcUserMapper.xml @@ -0,0 +1,243 @@ + + + + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + id, id_card, phone, operator, created_at, updated_at, rec_status + + + + + delete from t_idc_user + where id = #{id,jdbcType=BIGINT} + + + delete from t_idc_user + + + + + + insert into t_idc_user (id, id_card, phone, + operator, created_at, updated_at, + rec_status) + values (#{id,jdbcType=BIGINT}, #{idCard,jdbcType=VARCHAR}, #{phone,jdbcType=VARCHAR}, + #{operator,jdbcType=BIGINT}, #{createdAt,jdbcType=TIMESTAMP}, #{updatedAt,jdbcType=TIMESTAMP}, + #{recStatus,jdbcType=TINYINT}) + + + insert into t_idc_user + + + id, + + + id_card, + + + phone, + + + operator, + + + created_at, + + + updated_at, + + + rec_status, + + + + + #{id,jdbcType=BIGINT}, + + + #{idCard,jdbcType=VARCHAR}, + + + #{phone,jdbcType=VARCHAR}, + + + #{operator,jdbcType=BIGINT}, + + + #{createdAt,jdbcType=TIMESTAMP}, + + + #{updatedAt,jdbcType=TIMESTAMP}, + + + #{recStatus,jdbcType=TINYINT}, + + + + + + update t_idc_user + + + id = #{record.id,jdbcType=BIGINT}, + + + id_card = #{record.idCard,jdbcType=VARCHAR}, + + + phone = #{record.phone,jdbcType=VARCHAR}, + + + operator = #{record.operator,jdbcType=BIGINT}, + + + created_at = #{record.createdAt,jdbcType=TIMESTAMP}, + + + updated_at = #{record.updatedAt,jdbcType=TIMESTAMP}, + + + rec_status = #{record.recStatus,jdbcType=TINYINT}, + + + + + + + + update t_idc_user + set id = #{record.id,jdbcType=BIGINT}, + id_card = #{record.idCard,jdbcType=VARCHAR}, + phone = #{record.phone,jdbcType=VARCHAR}, + operator = #{record.operator,jdbcType=BIGINT}, + created_at = #{record.createdAt,jdbcType=TIMESTAMP}, + updated_at = #{record.updatedAt,jdbcType=TIMESTAMP}, + rec_status = #{record.recStatus,jdbcType=TINYINT} + + + + + + update t_idc_user + + + id_card = #{idCard,jdbcType=VARCHAR}, + + + phone = #{phone,jdbcType=VARCHAR}, + + + operator = #{operator,jdbcType=BIGINT}, + + + created_at = #{createdAt,jdbcType=TIMESTAMP}, + + + updated_at = #{updatedAt,jdbcType=TIMESTAMP}, + + + rec_status = #{recStatus,jdbcType=TINYINT}, + + + where id = #{id,jdbcType=BIGINT} + + + update t_idc_user + set id_card = #{idCard,jdbcType=VARCHAR}, + phone = #{phone,jdbcType=VARCHAR}, + operator = #{operator,jdbcType=BIGINT}, + created_at = #{createdAt,jdbcType=TIMESTAMP}, + updated_at = #{updatedAt,jdbcType=TIMESTAMP}, + rec_status = #{recStatus,jdbcType=TINYINT} + where id = #{id,jdbcType=BIGINT} + + \ No newline at end of file diff --git a/dh_diplomatist/src/main/resources/mybatis/mybatis-config.xml b/dh_diplomatist/src/main/resources/mybatis/mybatis-config.xml new file mode 100644 index 0000000..e5a218d --- /dev/null +++ b/dh_diplomatist/src/main/resources/mybatis/mybatis-config.xml @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/dh_ht/.gitignore b/dh_ht/.gitignore new file mode 100644 index 0000000..549e00a --- /dev/null +++ b/dh_ht/.gitignore @@ -0,0 +1,33 @@ +HELP.md +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ diff --git a/dh_ht/mvnw b/dh_ht/mvnw new file mode 100644 index 0000000..3c8a553 --- /dev/null +++ b/dh_ht/mvnw @@ -0,0 +1,322 @@ +#!/bin/sh +# ---------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# ---------------------------------------------------------------------------- + +# ---------------------------------------------------------------------------- +# Maven Start Up Batch script +# +# Required ENV vars: +# ------------------ +# JAVA_HOME - location of a JDK home dir +# +# Optional ENV vars +# ----------------- +# M2_HOME - location of maven2's installed home dir +# MAVEN_OPTS - parameters passed to the Java VM when running Maven +# e.g. to debug Maven itself, use +# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +# MAVEN_SKIP_RC - flag to disable loading of mavenrc files +# ---------------------------------------------------------------------------- + +if [ -z "$MAVEN_SKIP_RC" ]; then + + if [ -f /etc/mavenrc ]; then + . /etc/mavenrc + fi + + if [ -f "$HOME/.mavenrc" ]; then + . "$HOME/.mavenrc" + fi + +fi + +# OS specific support. $var _must_ be set to either true or false. +cygwin=false +darwin=false +mingw=false +case "$(uname)" in +CYGWIN*) cygwin=true ;; +MINGW*) mingw=true ;; +Darwin*) + darwin=true + # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home + # See https://developer.apple.com/library/mac/qa/qa1170/_index.html + if [ -z "$JAVA_HOME" ]; then + if [ -x "/usr/libexec/java_home" ]; then + export JAVA_HOME="$(/usr/libexec/java_home)" + else + export JAVA_HOME="/Library/Java/Home" + fi + fi + ;; +esac + +if [ -z "$JAVA_HOME" ]; then + if [ -r /etc/gentoo-release ]; then + JAVA_HOME=$(java-config --jre-home) + fi +fi + +if [ -z "$M2_HOME" ]; then + ## resolve links - $0 may be a link to maven's home + PRG="$0" + + # need this for relative symlinks + while [ -h "$PRG" ]; do + ls=$(ls -ld "$PRG") + link=$(expr "$ls" : '.*-> \(.*\)$') + if expr "$link" : '/.*' >/dev/null; then + PRG="$link" + else + PRG="$(dirname "$PRG")/$link" + fi + done + + saveddir=$(pwd) + + M2_HOME=$(dirname "$PRG")/.. + + # make it fully qualified + M2_HOME=$(cd "$M2_HOME" && pwd) + + cd "$saveddir" + # echo Using m2 at $M2_HOME +fi + +# For Cygwin, ensure paths are in UNIX format before anything is touched +if $cygwin; then + [ -n "$M2_HOME" ] && + M2_HOME=$(cygpath --unix "$M2_HOME") + [ -n "$JAVA_HOME" ] && + JAVA_HOME=$(cygpath --unix "$JAVA_HOME") + [ -n "$CLASSPATH" ] && + CLASSPATH=$(cygpath --path --unix "$CLASSPATH") +fi + +# For Mingw, ensure paths are in UNIX format before anything is touched +if $mingw; then + [ -n "$M2_HOME" ] && + M2_HOME="$( ( + cd "$M2_HOME" + pwd + ))" + [ -n "$JAVA_HOME" ] && + JAVA_HOME="$( ( + cd "$JAVA_HOME" + pwd + ))" +fi + +if [ -z "$JAVA_HOME" ]; then + javaExecutable="$(which javac)" + if [ -n "$javaExecutable" ] && ! [ "$(expr \"$javaExecutable\" : '\([^ ]*\)')" = "no" ]; then + # readlink(1) is not available as standard on Solaris 10. + readLink=$(which readlink) + if [ ! $(expr "$readLink" : '\([^ ]*\)') = "no" ]; then + if $darwin; then + javaHome="$(dirname \"$javaExecutable\")" + javaExecutable="$(cd \"$javaHome\" && pwd -P)/javac" + else + javaExecutable="$(readlink -f \"$javaExecutable\")" + fi + javaHome="$(dirname \"$javaExecutable\")" + javaHome=$(expr "$javaHome" : '\(.*\)/bin') + JAVA_HOME="$javaHome" + export JAVA_HOME + fi + fi +fi + +if [ -z "$JAVACMD" ]; then + if [ -n "$JAVA_HOME" ]; then + if [ -x "$JAVA_HOME/jre/sh/java" ]; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + else + JAVACMD="$(which java)" + fi +fi + +if [ ! -x "$JAVACMD" ]; then + echo "Error: JAVA_HOME is not defined correctly." >&2 + echo " We cannot execute $JAVACMD" >&2 + exit 1 +fi + +if [ -z "$JAVA_HOME" ]; then + echo "Warning: JAVA_HOME environment variable is not set." +fi + +CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher + +# traverses directory structure from process work directory to filesystem root +# first directory with .mvn subdirectory is considered project base directory +find_maven_basedir() { + + if [ -z "$1" ]; then + echo "Path not specified to find_maven_basedir" + return 1 + fi + + basedir="$1" + wdir="$1" + while [ "$wdir" != '/' ]; do + if [ -d "$wdir"/.mvn ]; then + basedir=$wdir + break + fi + # workaround for JBEAP-8937 (on Solaris 10/Sparc) + if [ -d "${wdir}" ]; then + wdir=$( + cd "$wdir/.." + pwd + ) + fi + # end of workaround + done + echo "${basedir}" +} + +# concatenates all lines of a file +concat_lines() { + if [ -f "$1" ]; then + echo "$(tr -s '\n' ' ' <"$1")" + fi +} + +BASE_DIR=$(find_maven_basedir "$(pwd)") +if [ -z "$BASE_DIR" ]; then + exit 1 +fi + +########################################################################################## +# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +# This allows using the maven wrapper in projects that prohibit checking in binary data. +########################################################################################## +if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found .mvn/wrapper/maven-wrapper.jar" + fi +else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." + fi + if [ -n "$MVNW_REPOURL" ]; then + jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + else + jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + fi + while IFS="=" read key value; do + case "$key" in wrapperUrl) + jarUrl="$value" + break + ;; + esac + done <"$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" + if [ "$MVNW_VERBOSE" = true ]; then + echo "Downloading from: $jarUrl" + fi + wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" + if $cygwin; then + wrapperJarPath=$(cygpath --path --windows "$wrapperJarPath") + fi + + if command -v wget >/dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found wget ... using wget" + fi + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + wget "$jarUrl" -O "$wrapperJarPath" + else + wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" + fi + elif command -v curl >/dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found curl ... using curl" + fi + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + curl -o "$wrapperJarPath" "$jarUrl" -f + else + curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f + fi + + else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Falling back to using Java to download" + fi + javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" + # For Cygwin, switch paths to Windows format before running javac + if $cygwin; then + javaClass=$(cygpath --path --windows "$javaClass") + fi + if [ -e "$javaClass" ]; then + if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Compiling MavenWrapperDownloader.java ..." + fi + # Compiling the Java class + ("$JAVA_HOME/bin/javac" "$javaClass") + fi + if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + # Running the downloader + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Running MavenWrapperDownloader.java ..." + fi + ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") + fi + fi + fi +fi +########################################################################################## +# End of extension +########################################################################################## + +export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} +if [ "$MVNW_VERBOSE" = true ]; then + echo $MAVEN_PROJECTBASEDIR +fi +MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" + +# For Cygwin, switch paths to Windows format before running java +if $cygwin; then + [ -n "$M2_HOME" ] && + M2_HOME=$(cygpath --path --windows "$M2_HOME") + [ -n "$JAVA_HOME" ] && + JAVA_HOME=$(cygpath --path --windows "$JAVA_HOME") + [ -n "$CLASSPATH" ] && + CLASSPATH=$(cygpath --path --windows "$CLASSPATH") + [ -n "$MAVEN_PROJECTBASEDIR" ] && + MAVEN_PROJECTBASEDIR=$(cygpath --path --windows "$MAVEN_PROJECTBASEDIR") +fi + +# Provide a "standardized" way to retrieve the CLI args that will +# work with both Windows and non-Windows executions. +MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" +export MAVEN_CMD_LINE_ARGS + +WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +exec "$JAVACMD" \ + $MAVEN_OPTS \ + -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ + "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ + ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/dh_ht/mvnw.cmd b/dh_ht/mvnw.cmd new file mode 100644 index 0000000..c8d4337 --- /dev/null +++ b/dh_ht/mvnw.cmd @@ -0,0 +1,182 @@ +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM https://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Maven Start Up Batch script +@REM +@REM Required ENV vars: +@REM JAVA_HOME - location of a JDK home dir +@REM +@REM Optional ENV vars +@REM M2_HOME - location of maven2's installed home dir +@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending +@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven +@REM e.g. to debug Maven itself, use +@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM ---------------------------------------------------------------------------- + +@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' +@echo off +@REM set title of command window +title %0 +@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' +@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% + +@REM set %HOME% to equivalent of $HOME +if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") + +@REM Execute a user defined script before this one +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre +@REM check for pre script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" +if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" +:skipRcPre + +@setlocal + +set ERROR_CODE=0 + +@REM To isolate internal variables from possible post scripts, we use another setlocal +@setlocal + +@REM ==== START VALIDATION ==== +if not "%JAVA_HOME%" == "" goto OkJHome + +echo. +echo Error: JAVA_HOME not found in your environment. >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +:OkJHome +if exist "%JAVA_HOME%\bin\java.exe" goto init + +echo. +echo Error: JAVA_HOME is set to an invalid directory. >&2 +echo JAVA_HOME = "%JAVA_HOME%" >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +@REM ==== END VALIDATION ==== + +:init + +@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". +@REM Fallback to current working directory if not found. + +set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% +IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir + +set EXEC_DIR=%CD% +set WDIR=%EXEC_DIR% +:findBaseDir +IF EXIST "%WDIR%"\.mvn goto baseDirFound +cd .. +IF "%WDIR%"=="%CD%" goto baseDirNotFound +set WDIR=%CD% +goto findBaseDir + +:baseDirFound +set MAVEN_PROJECTBASEDIR=%WDIR% +cd "%EXEC_DIR%" +goto endDetectBaseDir + +:baseDirNotFound +set MAVEN_PROJECTBASEDIR=%EXEC_DIR% +cd "%EXEC_DIR%" + +:endDetectBaseDir + +IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig + +@setlocal EnableExtensions EnableDelayedExpansion +for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a +@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% + +:endReadAdditionalConfig + +SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" +set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" +set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + +FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( + IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B +) + +@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +@REM This allows using the maven wrapper in projects that prohibit checking in binary data. +if exist %WRAPPER_JAR% ( + if "%MVNW_VERBOSE%" == "true" ( + echo Found %WRAPPER_JAR% + ) +) else ( + if not "%MVNW_REPOURL%" == "" ( + SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + ) + if "%MVNW_VERBOSE%" == "true" ( + echo Couldn't find %WRAPPER_JAR%, downloading it ... + echo Downloading from: %DOWNLOAD_URL% + ) + + powershell -Command "&{"^ + "$webclient = new-object System.Net.WebClient;"^ + "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ + "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ + "}"^ + "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ + "}" + if "%MVNW_VERBOSE%" == "true" ( + echo Finished downloading %WRAPPER_JAR% + ) +) +@REM End of extension + +@REM Provide a "standardized" way to retrieve the CLI args that will +@REM work with both Windows and non-Windows executions. +set MAVEN_CMD_LINE_ARGS=%* + +%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* +if ERRORLEVEL 1 goto error +goto end + +:error +set ERROR_CODE=1 + +:end +@endlocal & set ERROR_CODE=%ERROR_CODE% + +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost +@REM check for post script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" +if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" +:skipRcPost + +@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' +if "%MAVEN_BATCH_PAUSE%" == "on" pause + +if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% + +exit /B %ERROR_CODE% diff --git a/dh_ht/pom.xml b/dh_ht/pom.xml new file mode 100644 index 0000000..81078d4 --- /dev/null +++ b/dh_ht/pom.xml @@ -0,0 +1,84 @@ + + + 4.0.0 + + ccsens_dh + com.ccsens + 1.0-SNAPSHOT + + + dh_ht + + 0.0.1-SNAPSHOT + + dh_ht + + Demo project for Spring Boot + + 1.8 + + + + + + cloudutil + com.ccsens + 1.0-SNAPSHOT + + + + com.ccsens + util + 1.0-SNAPSHOT + compile + + + + wechatutil + com.ccsens + 1.0-SNAPSHOT + + + + + + + + + org.mybatis.generator + mybatis-generator-maven-plugin + 1.3.7 + + ${basedir}/src/main/resources/mbg.xml + true + + + + mysql + mysql-connector-java + 5.1.34 + + + + + org.springframework.boot + spring-boot-maven-plugin + + com.ccsens.dh_ht.DhHtApplication + + + + + + repackage + + + + + + + + + + diff --git a/dh_ht/src/main/java/com/ccsens/dh_ht/DhHtApplication.java b/dh_ht/src/main/java/com/ccsens/dh_ht/DhHtApplication.java new file mode 100644 index 0000000..1d0b9b5 --- /dev/null +++ b/dh_ht/src/main/java/com/ccsens/dh_ht/DhHtApplication.java @@ -0,0 +1,31 @@ +package com.ccsens.dh_ht; + +import com.ccsens.cloudutil.ribbon.RibbonConfiguration; +import org.mybatis.spring.annotation.MapperScan; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.web.servlet.ServletComponentScan; +import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker; +import org.springframework.cloud.openfeign.EnableFeignClients; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.FilterType; +import org.springframework.scheduling.annotation.EnableAsync; + +/** + * @author 逗 + */ +@MapperScan(basePackages = {"com.ccsens.dh_ht.persist.*","com.ccsens.common.persist.*"}) +@ServletComponentScan +@EnableAsync +//开启断路器功能 +@EnableCircuitBreaker +@EnableFeignClients(basePackages = "com.ccsens.cloudutil.feign") +@SpringBootApplication +@ComponentScan(basePackages = "com.ccsens", excludeFilters = { @ComponentScan.Filter(type= FilterType.ASSIGNABLE_TYPE, value = RibbonConfiguration.class)}) +public class DhHtApplication { + + public static void main(String[] args) { + SpringApplication.run(DhHtApplication.class, args); + } + +} diff --git a/dh_ht/src/main/java/com/ccsens/dh_ht/api/DebugController.java b/dh_ht/src/main/java/com/ccsens/dh_ht/api/DebugController.java new file mode 100644 index 0000000..1e4419b --- /dev/null +++ b/dh_ht/src/main/java/com/ccsens/dh_ht/api/DebugController.java @@ -0,0 +1,32 @@ +package com.ccsens.dh_ht.api; + +import com.ccsens.util.JsonResponse; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +import javax.servlet.http.HttpServletRequest; + +/** + * @author 逗 + */ +@Api(tags = "DEBUG" , description = "DebugController | ") +@RestController +@RequestMapping("/debug") +@Slf4j +public class DebugController { + + @ApiOperation(value = "/测试",notes = "") + @ApiImplicitParams({ + }) + @RequestMapping(value="",method = RequestMethod.GET,produces = {"application/json;charset=UTF-8"}) + public JsonResponse debug(HttpServletRequest request) throws Exception { + + return JsonResponse.newInstance().ok("测试"); + } + +} diff --git a/dh_ht/src/main/java/com/ccsens/dh_ht/api/ProjectController.java b/dh_ht/src/main/java/com/ccsens/dh_ht/api/ProjectController.java new file mode 100644 index 0000000..2771355 --- /dev/null +++ b/dh_ht/src/main/java/com/ccsens/dh_ht/api/ProjectController.java @@ -0,0 +1,41 @@ +package com.ccsens.dh_ht.api; + +import com.ccsens.dh_ht.bean.dto.ProjectDto; +import com.ccsens.dh_ht.bean.vo.ProjectVo; +import com.ccsens.dh_ht.service.IProjectService; +import com.ccsens.util.JsonResponse; +import com.ccsens.util.bean.dto.QueryDto; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import lombok.extern.slf4j.Slf4j; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; +import java.util.List; + +/** + * @author 逗 + */ +@Api(tags = "project" , description = "项目相关接口") +@RestController +@RequestMapping("/project") +@Slf4j +public class ProjectController { + + @Resource + private IProjectService projectService; + + @ApiOperation(value = "查询用户所有域下所有业务内的所有项目", notes = "") + @RequestMapping(value = "/query", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) + public JsonResponse> queryDomainByUser(@ApiParam @Validated @RequestBody QueryDto params) throws Exception{ + log.info("查询用户所有域下所有业务内的所有项目:{}",params); + List domainInfoList = projectService.queryDomainByUser(params.getParam(),params.getUserId()); + log.info("查询用户所有域下所有业务内的所有项目"); + return JsonResponse.newInstance().ok(domainInfoList); + } +} diff --git a/dh_ht/src/main/java/com/ccsens/dh_ht/api/UserController.java b/dh_ht/src/main/java/com/ccsens/dh_ht/api/UserController.java new file mode 100644 index 0000000..61d1fbd --- /dev/null +++ b/dh_ht/src/main/java/com/ccsens/dh_ht/api/UserController.java @@ -0,0 +1,18 @@ +package com.ccsens.dh_ht.api; + +import io.swagger.annotations.Api; +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * @author 逗 + */ +@Api(tags = "user" , description = "用户信息相关接口") +@RestController +@RequestMapping("/user") +@Slf4j +public class UserController { + + +} diff --git a/dh_ht/src/main/java/com/ccsens/dh_ht/bean/dto/ProjectDto.java b/dh_ht/src/main/java/com/ccsens/dh_ht/bean/dto/ProjectDto.java new file mode 100644 index 0000000..ef0d86d --- /dev/null +++ b/dh_ht/src/main/java/com/ccsens/dh_ht/bean/dto/ProjectDto.java @@ -0,0 +1,22 @@ +package com.ccsens.dh_ht.bean.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author 逗 + */ +@Data +public class ProjectDto { + + @Data + @ApiModel("用户查询可见的项目") + public static class QueryProjectDto{ + @ApiModelProperty("开始时间") + private Long startTime; + @ApiModelProperty("结束时间") + private Long endTime; + } + +} diff --git a/dh_ht/src/main/java/com/ccsens/dh_ht/bean/vo/ProjectVo.java b/dh_ht/src/main/java/com/ccsens/dh_ht/bean/vo/ProjectVo.java new file mode 100644 index 0000000..9ced019 --- /dev/null +++ b/dh_ht/src/main/java/com/ccsens/dh_ht/bean/vo/ProjectVo.java @@ -0,0 +1,86 @@ +package com.ccsens.dh_ht.bean.vo; + +import cn.hutool.core.util.ObjectUtil; +import com.ccsens.util.WebConstant; +import com.fasterxml.jackson.annotation.JsonIgnore; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +/** + * @author 逗 + */ +@Data +public class ProjectVo { + + @Data + @ApiModel("域信息") + public static class DomainInfo{ + @ApiModelProperty("id") + private Long id; + @ApiModelProperty("域名") + private String name; + @ApiModelProperty("域code") + private String code; + @ApiModelProperty("域访问前缀") + private String url; + @ApiModelProperty("是否是自身 0否 1是") + private byte self; + @ApiModelProperty("业务列表") + private List businessList; + } + @Data + @ApiModel("业务信息") + public static class BusinessInfo{ + @ApiModelProperty("业务id") + private Long businessId; + @ApiModelProperty("业务名") + private String businessName; + @ApiModelProperty("业务code") + private String businessCode; + @ApiModelProperty("业务访问前缀") + private String url; + @ApiModelProperty("项目列表") + private List projectList; + } + + @Data + @ApiModel("日历下项目列表信息") + public static class ProjectInfo{ + @ApiModelProperty("id") + private Long id; + @ApiModelProperty("项目名") + private String name; + @ApiModelProperty("开始时间") + private Long startTime; + @ApiModelProperty("结束时间") + private Long endTime; + @ApiModelProperty("项目完成状态(0-未开始,1-进行中,2-暂停,3-已完成)") + private byte status; + @ApiModelProperty("访问路径)") + private String url; + @ApiModelProperty("子项目") + private List sonProjectList; + @JsonIgnore + @ApiModelProperty("父级id") + private Long parentId; + + public Byte getStatus() { + long current = System.currentTimeMillis(); + if(ObjectUtil.isNull(getStartTime()) || ObjectUtil.isNull(getEndTime())) { + return null; + } + if(getStartTime() > current){ + this.status = (byte) WebConstant.EVENT_PROCESS.Pending.value; + }else if(getEndTime() < current){ + this.status = (byte) WebConstant.EVENT_PROCESS.Expired.value; + }else{ + this.status = (byte) WebConstant.EVENT_PROCESS.Processing.value; + } + return this.status; + } + } + +} diff --git a/dh_ht/src/main/java/com/ccsens/dh_ht/config/BeanConfig.java b/dh_ht/src/main/java/com/ccsens/dh_ht/config/BeanConfig.java new file mode 100644 index 0000000..37336e4 --- /dev/null +++ b/dh_ht/src/main/java/com/ccsens/dh_ht/config/BeanConfig.java @@ -0,0 +1,22 @@ +package com.ccsens.dh_ht.config; + +import com.ccsens.dh_ht.intercept.MybatisInterceptor; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * @description: + * @author: wuHuiJuan + * @create: 2019/12/03 18:01 + */ +@Configuration +public class BeanConfig { + /** + * 注册拦截器 + */ + @Bean + public MybatisInterceptor mybatisInterceptor() { + MybatisInterceptor interceptor = new MybatisInterceptor(); + return interceptor; + } +} diff --git a/dh_ht/src/main/java/com/ccsens/dh_ht/config/SpringConfig.java b/dh_ht/src/main/java/com/ccsens/dh_ht/config/SpringConfig.java new file mode 100644 index 0000000..53eaf75 --- /dev/null +++ b/dh_ht/src/main/java/com/ccsens/dh_ht/config/SpringConfig.java @@ -0,0 +1,128 @@ +package com.ccsens.dh_ht.config; + + +import cn.hutool.core.lang.Snowflake; +import cn.hutool.core.util.IdUtil; +import com.ccsens.util.config.DruidProps; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.module.SimpleModule; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.MediaType; +import org.springframework.http.converter.HttpMessageConverter; +import org.springframework.http.converter.StringHttpMessageConverter; +import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; +import org.springframework.web.servlet.config.annotation.*; + +import javax.annotation.Resource; +import javax.sql.DataSource; +import java.nio.charset.Charset; +import java.util.ArrayList; +import java.util.List; +import java.util.TimeZone; + +@Configuration +public class SpringConfig implements WebMvcConfigurer { + @Resource + private DruidProps druidPropsUtil; + @Value("${spring.snowflake.workerId}") + private String workerId; + @Value("${spring.snowflake.datacenterId}") + private String datacenterId; + + /** + * 配置Converter + * @return + */ + @Bean + public HttpMessageConverter responseStringConverter() { + StringHttpMessageConverter converter = new StringHttpMessageConverter( + Charset.forName("UTF-8")); + return converter; + } + + @Bean + public HttpMessageConverter responseJsonConverter(){ + MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter(); + List mediaTypeList = new ArrayList<>(); + mediaTypeList.add(MediaType.TEXT_HTML); + mediaTypeList.add(MediaType.APPLICATION_JSON_UTF8); + converter.setSupportedMediaTypes(mediaTypeList); + + ObjectMapper objectMapper = new ObjectMapper(); + SimpleModule simpleModule = new SimpleModule(); + simpleModule.addSerializer(Long.class, ToStringSerializer.instance); + simpleModule.addSerializer(Long.TYPE, ToStringSerializer.instance); + objectMapper.registerModule(simpleModule); + objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + objectMapper.setTimeZone(TimeZone.getTimeZone("GMT+8")); + converter.setObjectMapper(objectMapper); + + return converter; + } + + @Override + public void configureMessageConverters(List> converters) { + converters.add(responseStringConverter()); + converters.add(responseJsonConverter()); + } + + @Override + public void configureContentNegotiation(ContentNegotiationConfigurer configurer) { + configurer.favorPathExtension(false); + } + + @Override + public void addCorsMappings(CorsRegistry registry) { + registry.addMapping("/**").allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS") +// .allowedMethods("*") // 允许提交请求的方法,*表示全部允许 + .allowedOrigins("*") // #允许向该服务器提交请求的URI,*表示全部允许 + .allowCredentials(true) // 允许cookies跨域 + .allowedHeaders("*") // #允许访问的头信息,*表示全部 + .maxAge(18000L); // 预检请求的缓存时间(秒),即在这个时间段里,对于相同的跨域请求不会再预检了 + + } + + + + + /** + * 配置静态资源 + */ + @Override + public void addResourceHandlers(ResourceHandlerRegistry registry) { + registry.addResourceHandler("swagger-ui.html") + .addResourceLocations("classpath:/META-INF/resources/"); + registry.addResourceHandler("/webjars/**") + .addResourceLocations("classpath:/META-INF/resources/webjars/"); + + registry.addResourceHandler("/uploads/**") + .addResourceLocations("file:///home/ht/service/uploads/"); + } + + /** + * 配置拦截器 + * @param registry + */ + @Override + public void addInterceptors(InterceptorRegistry registry) { + + } + + + /** + * 配置数据源(单数据源) + */ + @Bean + public DataSource dataSource(){ + return druidPropsUtil.createDruidDataSource(); + } + + @Bean + public Snowflake snowflake(){ + return IdUtil.createSnowflake(Long.valueOf(workerId), Long.valueOf(datacenterId)); + } +} \ No newline at end of file diff --git a/dh_ht/src/main/java/com/ccsens/dh_ht/config/SwaggerConfigure.java b/dh_ht/src/main/java/com/ccsens/dh_ht/config/SwaggerConfigure.java new file mode 100644 index 0000000..7e38128 --- /dev/null +++ b/dh_ht/src/main/java/com/ccsens/dh_ht/config/SwaggerConfigure.java @@ -0,0 +1,56 @@ +package com.ccsens.dh_ht.config; + +import com.ccsens.util.WebConstant; +import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import springfox.documentation.builders.ParameterBuilder; +import springfox.documentation.builders.RequestHandlerSelectors; +import springfox.documentation.schema.ModelRef; +import springfox.documentation.service.ApiInfo; +import springfox.documentation.service.Parameter; +import springfox.documentation.spi.DocumentationType; +import springfox.documentation.spring.web.plugins.Docket; +import springfox.documentation.swagger2.annotations.EnableSwagger2; + +import java.util.ArrayList; +import java.util.List; + +@Configuration +@EnableSwagger2 +@ConditionalOnExpression("${swagger.enable}") +//public class SwaggerConfigure extends WebMvcConfigurationSupport { +public class SwaggerConfigure /*implements WebMvcConfigurer*/ { + @Bean + public Docket customDocket() { + // + return new Docket(DocumentationType.SWAGGER_2) + .apiInfo(apiInfo()) + .select() + .apis(RequestHandlerSelectors + .basePackage("com.ccsens.dh_ht.api")) + .build() + .globalOperationParameters(setHeaderToken()); + } + + private ApiInfo apiInfo() { + return new ApiInfo("Swagger Tall-game",//大标题 title + "This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.",//小标题 + "1.0.0",//版本 + "http://swagger.io/terms/",//termsOfServiceUrl + "zhangsan",//作者 + "Apache 2.0",//链接显示文字 + "http://www.apache.org/licenses/LICENSE-2.0.html"//网站链接 + ); + } + + private List setHeaderToken() { + ParameterBuilder tokenPar = new ParameterBuilder(); + List pars = new ArrayList<>(); + tokenPar.name(WebConstant.HEADER_KEY_TOKEN).description("token") + .defaultValue(WebConstant.HEADER_KEY_TOKEN_PREFIX) + .modelRef(new ModelRef("string")).parameterType("header").required(false).build(); + pars.add(tokenPar.build()); + return pars; + } +} diff --git a/dh_ht/src/main/java/com/ccsens/dh_ht/intercept/MybatisInterceptor.java b/dh_ht/src/main/java/com/ccsens/dh_ht/intercept/MybatisInterceptor.java new file mode 100644 index 0000000..eae54e1 --- /dev/null +++ b/dh_ht/src/main/java/com/ccsens/dh_ht/intercept/MybatisInterceptor.java @@ -0,0 +1,159 @@ +package com.ccsens.dh_ht.intercept; + +import cn.hutool.core.collection.CollectionUtil; +import com.ccsens.util.WebConstant; +import org.apache.ibatis.executor.Executor; +import org.apache.ibatis.mapping.BoundSql; +import org.apache.ibatis.mapping.MappedStatement; +import org.apache.ibatis.mapping.ResultMap; +import org.apache.ibatis.mapping.SqlSource; +import org.apache.ibatis.plugin.*; +import org.apache.ibatis.reflection.DefaultReflectorFactory; +import org.apache.ibatis.reflection.MetaObject; +import org.apache.ibatis.reflection.factory.DefaultObjectFactory; +import org.apache.ibatis.reflection.wrapper.DefaultObjectWrapperFactory; +import org.apache.ibatis.session.ResultHandler; +import org.apache.ibatis.session.RowBounds; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.List; +import java.util.Map; +import java.util.Properties; + +/** + * @description: + * @author: wuHuiJuan + * @create: 2019/12/11 10:58 + */ +@Intercepts({ + @Signature( + type = Executor.class, + method = "query", + args = {MappedStatement.class, Object.class, RowBounds.class, ResultHandler.class} + ) +}) +public class MybatisInterceptor implements Interceptor { + @Override + public Object intercept(Invocation invocation) throws Throwable { + + + String selectByExample = "selectByExample"; + String countByExample = "countByExample"; + String countByExample2 = "selectByExample_COUNT"; + String selectByPrimaryKey = "selectByPrimaryKey"; + + Object[] args = invocation.getArgs(); + MappedStatement statement = (MappedStatement) args[0]; + if (statement.getId().endsWith(selectByExample) + || statement.getId().endsWith(countByExample) + || statement.getId().endsWith(countByExample2)) { + //XXXExample + Object example = args[1]; + + addCondition(statement, example); + + + + + } else if (statement.getId().endsWith(selectByPrimaryKey)) { + BoundSql boundSql = statement.getBoundSql(args[1]); + String sql = boundSql.getSql() + " and rec_status = 0"; + MappedStatement newStatement = newMappedStatement(statement, new BoundSqlSqlSource(boundSql)); + MetaObject msObject = MetaObject.forObject(newStatement, new DefaultObjectFactory(), new DefaultObjectWrapperFactory(),new DefaultReflectorFactory()); + msObject.setValue("sqlSource.boundSql.sql", sql); + args[0] = newStatement; + } + + return invocation.proceed(); + } + + private void addCondition(MappedStatement statement, Object example) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException, ClassNotFoundException { + if (example instanceof Map) { + example = ((Map) example).get("_ORIGINAL_PARAMETER_OBJECT"); + } + + + Method method = example.getClass().getMethod("getOredCriteria", null); + //获取到条件数组,第一个是Criteria + List list = (List) method.invoke(example); + if (CollectionUtil.isEmpty(list)) { + Class clazz = ((ResultMap) statement.getResultMaps().get(0)).getType(); + String exampleName = clazz.getName() + "Example"; + Object paramExample = Class.forName(exampleName).newInstance(); + Method createCriteria = paramExample.getClass().getMethod("createCriteria"); + Object criteria = createCriteria.invoke(paramExample); + Method andIsDelEqualTo = criteria.getClass().getMethod("andRecStatusEqualTo", Byte.class); + andIsDelEqualTo.invoke(criteria, WebConstant.REC_STATUS.Normal.value); + list.add(criteria); + } else { + Object criteria = list.get(0); + Method getCriteria = criteria.getClass().getMethod("getCriteria"); + List params = (List) getCriteria.invoke(criteria); + boolean hasDel = false; + for (Object param : params) { + Method getCondition = param.getClass().getMethod("getCondition"); + Object condition = getCondition.invoke(param); + if ("rec_status =".equals(condition)) { + hasDel = true; + } + } + if (!hasDel) { + Method andIsDelEqualTo = criteria.getClass().getMethod("andRecStatusEqualTo", Byte.class); + andIsDelEqualTo.invoke(criteria, WebConstant.REC_STATUS.Normal.value); + } + + } + + } + + @Override + public Object plugin(Object target) { + return Plugin.wrap(target, this); + } + + @Override + public void setProperties(Properties properties) { + + } + + private MappedStatement newMappedStatement(MappedStatement ms, SqlSource newSqlSource) { + MappedStatement.Builder builder = + new MappedStatement.Builder(ms.getConfiguration(), ms.getId(), newSqlSource, ms.getSqlCommandType()); + builder.resource(ms.getResource()); + builder.fetchSize(ms.getFetchSize()); + builder.statementType(ms.getStatementType()); + builder.keyGenerator(ms.getKeyGenerator()); + if (ms.getKeyProperties() != null && ms.getKeyProperties().length != 0) { + StringBuilder keyProperties = new StringBuilder(); + for (String keyProperty : ms.getKeyProperties()) { + keyProperties.append(keyProperty).append(","); + } + keyProperties.delete(keyProperties.length() - 1, keyProperties.length()); + builder.keyProperty(keyProperties.toString()); + } + builder.timeout(ms.getTimeout()); + builder.parameterMap(ms.getParameterMap()); + builder.resultMaps(ms.getResultMaps()); + builder.resultSetType(ms.getResultSetType()); + builder.cache(ms.getCache()); + builder.flushCacheRequired(ms.isFlushCacheRequired()); + builder.useCache(ms.isUseCache()); + + return builder.build(); + } + + + // 定义一个内部辅助类,作用是包装sq + class BoundSqlSqlSource implements SqlSource { + private BoundSql boundSql; + public BoundSqlSqlSource(BoundSql boundSql) { + this.boundSql = boundSql; + } + @Override + public BoundSql getBoundSql(Object parameterObject) { + return boundSql; + } + } + +} diff --git a/dh_ht/src/main/java/com/ccsens/dh_ht/service/IProjectService.java b/dh_ht/src/main/java/com/ccsens/dh_ht/service/IProjectService.java new file mode 100644 index 0000000..348b0c5 --- /dev/null +++ b/dh_ht/src/main/java/com/ccsens/dh_ht/service/IProjectService.java @@ -0,0 +1,19 @@ +package com.ccsens.dh_ht.service; + +import com.ccsens.dh_ht.bean.dto.ProjectDto; +import com.ccsens.dh_ht.bean.vo.ProjectVo; + +import java.util.List; + +/** + * @author 逗 + */ +public interface IProjectService { + /** + * 查询用户在所有域所有业务下的所有项目 + * @param param 开始结束时间 + * @param userId userId + * @return 返回项目列表 + */ + List queryDomainByUser(ProjectDto.QueryProjectDto param, Long userId); +} diff --git a/dh_ht/src/main/java/com/ccsens/dh_ht/service/ProjectService.java b/dh_ht/src/main/java/com/ccsens/dh_ht/service/ProjectService.java new file mode 100644 index 0000000..3ad3429 --- /dev/null +++ b/dh_ht/src/main/java/com/ccsens/dh_ht/service/ProjectService.java @@ -0,0 +1,25 @@ +package com.ccsens.dh_ht.service; + +import com.ccsens.dh_ht.bean.dto.ProjectDto; +import com.ccsens.dh_ht.bean.vo.ProjectVo; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; +/** + * @author 逗 + */ +@Slf4j +@Service +@Transactional(propagation = Propagation.REQUIRED,rollbackFor = Exception.class) +public class ProjectService implements IProjectService { + + + @Override + public List queryDomainByUser(ProjectDto.QueryProjectDto param, Long userId) { + + return null; + } +} diff --git a/dh_ht/src/main/java/com/ccsens/dh_ht/util/PtOsCodeError.java b/dh_ht/src/main/java/com/ccsens/dh_ht/util/PtOsCodeError.java new file mode 100644 index 0000000..2817687 --- /dev/null +++ b/dh_ht/src/main/java/com/ccsens/dh_ht/util/PtOsCodeError.java @@ -0,0 +1,12 @@ +package com.ccsens.dh_ht.util; + +import com.ccsens.util.CodeError; + +/** + * @author 逗 + */ +public class PtOsCodeError extends CodeError { + + public static final Code NOT_WBS_SHEET = new Code(501,"找不到wbs表",true); + +} diff --git a/dh_ht/src/main/java/com/ccsens/dh_ht/util/PtOsConstant.java b/dh_ht/src/main/java/com/ccsens/dh_ht/util/PtOsConstant.java new file mode 100644 index 0000000..ac26704 --- /dev/null +++ b/dh_ht/src/main/java/com/ccsens/dh_ht/util/PtOsConstant.java @@ -0,0 +1,50 @@ +package com.ccsens.dh_ht.util; + +import java.util.HashMap; +import java.util.Map; + +/** + * @author 逗 + */ +public class PtOsConstant { + + /**图片类型*/ + public static final String FILE_TYPE_IMG = "bmp,jpg,jpeg,png,tif,gif,pcx,tga,exif,fpx,svg,psd,cdr,pcd,dxf,ufo,eps,ai,raw,WMF,webp"; + /**文档类型*/ + public static final String FILE_TYPE_DOCUMENT = "doc, dot, wps, wpt, docx, dotx, docm, dotm, xls, xlt, et, xlsx, xltx, csv, xlsm, xltm, ppt,pptx,pptm,ppsx,ppsm,pps,potx,potm,dpt,dps, pdf"; + + + /**验证手机正则*/ + public static final String PHONE_REGEX = "^[1]([3-9])[0-9]{9}$"; + /**字符串分隔符*/ + public static final String STRING_REGEX = ",|,|;|;|、|/"; + /**wbs相关*/ + public static final class WbsExcel { + /**wbsSheet*/ + public static final String WBS_SHEET = "WBS"; + /**项目成员Sheet*/ + public static final String MEMBER_SHEET = "项目成员表"; + /**项目信息头*/ + public static final String PROJECT_INFO_TITLE = "项目信息"; + /**任务信息头*/ + public static final String TASK_INFO_TITLE = "项目任务分解"; + /**excel文件格式验证*/ + public static final String WBS_FILE_FORMAT = "xls,xlsx"; + /**插件配置表*/ + public static final String WBS_PLUGIN_CONFIG = "插件配置表"; + } + + /**wbs表时长对应关系表*/ + public static final Map WBS_DURATION = new HashMap<>(); + static { + WBS_DURATION.put("s",1000L); + WBS_DURATION.put("min",60 * 1000L); + WBS_DURATION.put("h",60 * 60 * 1000L); + WBS_DURATION.put("d",24 * 60 * 60 * 1000L); + WBS_DURATION.put("w",7 * 24 * 60 * 60 * 1000L); + WBS_DURATION.put("m",30 * 24 * 60 * 60 * 1000L); + WBS_DURATION.put("y",365 * 24 * 60 * 60 * 1000L); + } + + +} diff --git a/dh_ht/src/main/resources/application-common.yml b/dh_ht/src/main/resources/application-common.yml new file mode 100644 index 0000000..a9fafd1 --- /dev/null +++ b/dh_ht/src/main/resources/application-common.yml @@ -0,0 +1,30 @@ +logging: + level: + com: + favorites: DEBUG + org: + hibernate: ERROR + springframework: + web: DEBUG +mybatis: + config-location: classpath:mybatis/mybatis-config.xml + mapper-locations: classpath*:mapper_*/*.xml +# type-aliases-package: com.ccsens.mtpro.bean +#server: +# tomcat: +# uri-encoding: UTF-8 +spring: + http: + encoding: + charset: UTF-8 + enabled: true + force: true + log-request-details: true + servlet: + multipart: + max-file-size: 10MB + max-request-size: 100MB + snowflake: + datacenterId: 10 + workerId: 1 + diff --git a/dh_ht/src/main/resources/application-dev.yml b/dh_ht/src/main/resources/application-dev.yml new file mode 100644 index 0000000..504a92c --- /dev/null +++ b/dh_ht/src/main/resources/application-dev.yml @@ -0,0 +1,50 @@ +server: + port: 7310 + servlet: + context-path: +spring: + application: + name: dh_ht + datasource: + type: com.alibaba.druid.pool.DruidDataSource +# rabbitmq: +# host: 192.168.0.99 +# password: 111111 +# port: 5672 +# username: admin + rabbitmq: + host: 127.0.0.1 + password: guest + port: 5672 + username: guest + redis: + database: 0 + host: 127.0.0.1 + jedis: + pool: + max-active: 200 + max-idle: 10 + max-wait: -1ms + min-idle: 0 + password: '' + port: 6379 + timeout: 1000ms +swagger: + enable: true +mybatisCache: + database: 1 + host: 127.0.0.1 + jedis: + pool: + max-active: 200 + max-idle: 10 + max-wait: -1 + min-idle: 0 + password: '' + port: 6379 + timeout: 1000 + +file: + path: /home/ht/service/uploads/ + domain: https://test.tall.wiki/gateway/dh_ht + imgDomain: https://test.tall.wiki/gateway/dh_ht/uploads/ diff --git a/dh_ht/src/main/resources/application-prod.yml b/dh_ht/src/main/resources/application-prod.yml new file mode 100644 index 0000000..0aa5e27 --- /dev/null +++ b/dh_ht/src/main/resources/application-prod.yml @@ -0,0 +1,40 @@ +server: + port: 7310 + servlet: + context-path: +spring: + application: + name: dh_ht + datasource: + type: com.alibaba.druid.pool.DruidDataSource + rabbitmq: + host: 121.36.3.207 + password: 111111 + port: 5672 + username: admin + redis: + database: 0 + host: 127.0.0.1 + jedis: + pool: + max-active: 200 + max-idle: 10 + max-wait: -1ms + min-idle: 0 + password: '' +# password: 'areowqr!@43ef' + port: 6379 + timeout: 1000ms +swagger: + enable: true +eureka: + instance: + ip-address: 121.36.106.168 + +gatewayUrl: https://www.tall.wiki/gateway/ +notGatewayUrl: https://www.tall.wiki/ +apiUrl: https://www.tall.wiki/ +file: + path: /home/ht/service/uploads/ + domain: https://www.tall.wiki/gateway/dh_ht + imgDomain: https://www.tall.wiki/gateway/dh_ht/uploads/ diff --git a/dh_ht/src/main/resources/application-test.yml b/dh_ht/src/main/resources/application-test.yml new file mode 100644 index 0000000..1d13837 --- /dev/null +++ b/dh_ht/src/main/resources/application-test.yml @@ -0,0 +1,48 @@ +server: + port: 7310 + servlet: + context-path: +spring: + application: + name: dh_ht + datasource: + type: com.alibaba.druid.pool.DruidDataSource + rabbitmq: + host: dd.tall.wiki + password: 111111 + port: 5672 + username: admin + redis: + database: 0 + host: 127.0.0.1 + jedis: + pool: + max-active: 200 + max-idle: 10 + max-wait: -1ms + min-idle: 0 + password: '' + port: 6379 + timeout: 1000ms +swagger: + enable: true +mybatisCache: + database: 1 + host: 127.0.0.1 + jedis: + pool: + max-active: 200 + max-idle: 10 + max-wait: -1 + min-idle: 0 + password: '' + port: 6379 + timeout: 1000 +eureka: + instance: + ip-address: 127.0.0.1 + +file: + path: /home/ht/service/uploads/ + domain: https://test.tall.wiki/gateway/dh_ht + imgDomain: https://test.tall.wiki/gateway/dh_ht/uploads/ diff --git a/dh_ht/src/main/resources/application.yml b/dh_ht/src/main/resources/application.yml new file mode 100644 index 0000000..2fb38e5 --- /dev/null +++ b/dh_ht/src/main/resources/application.yml @@ -0,0 +1,4 @@ +spring: + profiles: + active: dev + include: common, util-dev diff --git a/dh_ht/src/main/resources/druid-dev.yml b/dh_ht/src/main/resources/druid-dev.yml new file mode 100644 index 0000000..1de2452 --- /dev/null +++ b/dh_ht/src/main/resources/druid-dev.yml @@ -0,0 +1,34 @@ +spring: + datasource: + druid: + connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000 + driverClassName: com.mysql.cj.jdbc.Driver + dynamicUrl: jdbc:mysql://localhost:3306/${schema} + filterExclusions: '*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*' + filterName: druidFilter + filterProfileEnable: true + filterUrlPattern: /* + filters: stat,wall + initialSize: 5 + maxActive: 20 + maxPoolPreparedStatementPerConnectionSize: 20 + maxWait: 60000 + minEvictableIdleTimeMillis: 300000 + minIdle: 5 +# password: 37080c1f223685592316b02dad8816c019290a476e54ebb638f9aa3ba8b6bdb9 + password: 68073a279b399baa1fa12cf39bfbb65bfc1480ffee7b659ccc81cf19be8c4473 + poolPreparedStatements: true + servletLogSlowSql: true + servletLoginPassword: 111111 + servletLoginUsername: druid + servletName: druidServlet + servletResetEnable: true + servletUrlMapping: /druid/* + testOnBorrow: false + testOnReturn: false + testWhileIdle: true + timeBetweenEvictionRunsMillis: 60000 + url: jdbc:mysql://101.201.226.163:3306/tall_dh?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&autoReconnect=true + username: root + validationQuery: SELECT 1 FROM DUAL + env: CCSENS_TALL \ No newline at end of file diff --git a/dh_ht/src/main/resources/druid-prod.yml b/dh_ht/src/main/resources/druid-prod.yml new file mode 100644 index 0000000..986eb39 --- /dev/null +++ b/dh_ht/src/main/resources/druid-prod.yml @@ -0,0 +1,35 @@ +spring: + datasource: + druid: + connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000 + driverClassName: com.mysql.cj.jdbc.Driver + dynamicUrl: jdbc:mysql://localhost:3306/${schema} + filterExclusions: '*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*' + filterName: druidFilter + filterProfileEnable: true + filterUrlPattern: /* + filters: stat,wall + initialSize: 5 + maxActive: 20 + maxPoolPreparedStatementPerConnectionSize: 20 + maxWait: 60000 + minEvictableIdleTimeMillis: 300000 + minIdle: 5 +# password: + password: 68073a279b399baa1fa12cf39bfbb65bfc1480ffee7b659ccc81cf19be8c4473 + poolPreparedStatements: true + servletLogSlowSql: true + servletLoginPassword: 111111 + servletLoginUsername: druid + servletName: druidServlet + servletResetEnable: true + servletUrlMapping: /druid/* + testOnBorrow: false + testOnReturn: false + testWhileIdle: true + timeBetweenEvictionRunsMillis: 60000 +# url: jdbc:mysql://127.0.0.1/defaultwbs?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&autoReconnect=true + url: jdbc:mysql://www.tall.wiki/data_centre?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&autoReconnect=true + username: root + validationQuery: SELECT 1 FROM DUAL + env: CCSENS_TALL \ No newline at end of file diff --git a/dh_ht/src/main/resources/druid-test.yml b/dh_ht/src/main/resources/druid-test.yml new file mode 100644 index 0000000..32e18fd --- /dev/null +++ b/dh_ht/src/main/resources/druid-test.yml @@ -0,0 +1,34 @@ +spring: + datasource: + druid: + connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000 + driverClassName: com.mysql.cj.jdbc.Driver + dynamicUrl: jdbc:mysql://localhost:3306/${schema} + filterExclusions: '*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*' + filterName: druidFilter + filterProfileEnable: true + filterUrlPattern: /* + filters: stat,wall + initialSize: 5 + maxActive: 20 + maxPoolPreparedStatementPerConnectionSize: 20 + maxWait: 60000 + minEvictableIdleTimeMillis: 300000 + minIdle: 5 +# password: 68073a279b399baa1fa12cf39bfbb65bfc1480ffee7b659ccc81cf19be8c4473 + password: + poolPreparedStatements: true + servletLogSlowSql: true + servletLoginPassword: 111111 + servletLoginUsername: druid + servletName: druidServlet + servletResetEnable: true + servletUrlMapping: /druid/* + testOnBorrow: false + testOnReturn: false + testWhileIdle: true + timeBetweenEvictionRunsMillis: 60000 + url: jdbc:mysql://101.201.226.163:3306/tall_dm?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&autoReconnect=true + username: root + validationQuery: SELECT 1 FROM DUAL + env: CCSENS_TALL \ No newline at end of file diff --git a/dh_ht/src/main/resources/logback-spring.xml b/dh_ht/src/main/resources/logback-spring.xml new file mode 100644 index 0000000..5845aad --- /dev/null +++ b/dh_ht/src/main/resources/logback-spring.xml @@ -0,0 +1,196 @@ + + + + + + + + + + logback + + + + + + + + + + + + + + + + + info + + + ${CONSOLE_LOG_PATTERN} + + UTF-8 + + + + + + + + + + ${log.path}/log_debug.log + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n + UTF-8 + + + + + ${log.path}/debug/log-debug-%d{yyyy-MM-dd}.%i.log + + 100MB + + + 15 + + + + debug + ACCEPT + DENY + + + + + + + ${log.path}/log_info.log + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n + UTF-8 + + + + + ${log.path}/info/log-info-%d{yyyy-MM-dd}.%i.log + + 100MB + + + 15 + + + + info + ACCEPT + DENY + + + + + + + ${log.path}/log_warn.log + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n + UTF-8 + + + + ${log.path}/warn/log-warn-%d{yyyy-MM-dd}.%i.log + + 100MB + + + 15 + + + + warn + ACCEPT + DENY + + + + + + + + ${log.path}/log_error.log + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n + UTF-8 + + + + ${log.path}/error/log-error-%d{yyyy-MM-dd}.%i.log + + 100MB + + + 15 + + + + ERROR + ACCEPT + DENY + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/dh_ht/src/main/resources/mybatis/mybatis-config.xml b/dh_ht/src/main/resources/mybatis/mybatis-config.xml new file mode 100644 index 0000000..e5a218d --- /dev/null +++ b/dh_ht/src/main/resources/mybatis/mybatis-config.xml @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/dh_ptos/.gitignore b/dh_ptos/.gitignore new file mode 100644 index 0000000..549e00a --- /dev/null +++ b/dh_ptos/.gitignore @@ -0,0 +1,33 @@ +HELP.md +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ diff --git a/dh_ptos/mvnw b/dh_ptos/mvnw new file mode 100644 index 0000000..3c8a553 --- /dev/null +++ b/dh_ptos/mvnw @@ -0,0 +1,322 @@ +#!/bin/sh +# ---------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# ---------------------------------------------------------------------------- + +# ---------------------------------------------------------------------------- +# Maven Start Up Batch script +# +# Required ENV vars: +# ------------------ +# JAVA_HOME - location of a JDK home dir +# +# Optional ENV vars +# ----------------- +# M2_HOME - location of maven2's installed home dir +# MAVEN_OPTS - parameters passed to the Java VM when running Maven +# e.g. to debug Maven itself, use +# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +# MAVEN_SKIP_RC - flag to disable loading of mavenrc files +# ---------------------------------------------------------------------------- + +if [ -z "$MAVEN_SKIP_RC" ]; then + + if [ -f /etc/mavenrc ]; then + . /etc/mavenrc + fi + + if [ -f "$HOME/.mavenrc" ]; then + . "$HOME/.mavenrc" + fi + +fi + +# OS specific support. $var _must_ be set to either true or false. +cygwin=false +darwin=false +mingw=false +case "$(uname)" in +CYGWIN*) cygwin=true ;; +MINGW*) mingw=true ;; +Darwin*) + darwin=true + # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home + # See https://developer.apple.com/library/mac/qa/qa1170/_index.html + if [ -z "$JAVA_HOME" ]; then + if [ -x "/usr/libexec/java_home" ]; then + export JAVA_HOME="$(/usr/libexec/java_home)" + else + export JAVA_HOME="/Library/Java/Home" + fi + fi + ;; +esac + +if [ -z "$JAVA_HOME" ]; then + if [ -r /etc/gentoo-release ]; then + JAVA_HOME=$(java-config --jre-home) + fi +fi + +if [ -z "$M2_HOME" ]; then + ## resolve links - $0 may be a link to maven's home + PRG="$0" + + # need this for relative symlinks + while [ -h "$PRG" ]; do + ls=$(ls -ld "$PRG") + link=$(expr "$ls" : '.*-> \(.*\)$') + if expr "$link" : '/.*' >/dev/null; then + PRG="$link" + else + PRG="$(dirname "$PRG")/$link" + fi + done + + saveddir=$(pwd) + + M2_HOME=$(dirname "$PRG")/.. + + # make it fully qualified + M2_HOME=$(cd "$M2_HOME" && pwd) + + cd "$saveddir" + # echo Using m2 at $M2_HOME +fi + +# For Cygwin, ensure paths are in UNIX format before anything is touched +if $cygwin; then + [ -n "$M2_HOME" ] && + M2_HOME=$(cygpath --unix "$M2_HOME") + [ -n "$JAVA_HOME" ] && + JAVA_HOME=$(cygpath --unix "$JAVA_HOME") + [ -n "$CLASSPATH" ] && + CLASSPATH=$(cygpath --path --unix "$CLASSPATH") +fi + +# For Mingw, ensure paths are in UNIX format before anything is touched +if $mingw; then + [ -n "$M2_HOME" ] && + M2_HOME="$( ( + cd "$M2_HOME" + pwd + ))" + [ -n "$JAVA_HOME" ] && + JAVA_HOME="$( ( + cd "$JAVA_HOME" + pwd + ))" +fi + +if [ -z "$JAVA_HOME" ]; then + javaExecutable="$(which javac)" + if [ -n "$javaExecutable" ] && ! [ "$(expr \"$javaExecutable\" : '\([^ ]*\)')" = "no" ]; then + # readlink(1) is not available as standard on Solaris 10. + readLink=$(which readlink) + if [ ! $(expr "$readLink" : '\([^ ]*\)') = "no" ]; then + if $darwin; then + javaHome="$(dirname \"$javaExecutable\")" + javaExecutable="$(cd \"$javaHome\" && pwd -P)/javac" + else + javaExecutable="$(readlink -f \"$javaExecutable\")" + fi + javaHome="$(dirname \"$javaExecutable\")" + javaHome=$(expr "$javaHome" : '\(.*\)/bin') + JAVA_HOME="$javaHome" + export JAVA_HOME + fi + fi +fi + +if [ -z "$JAVACMD" ]; then + if [ -n "$JAVA_HOME" ]; then + if [ -x "$JAVA_HOME/jre/sh/java" ]; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + else + JAVACMD="$(which java)" + fi +fi + +if [ ! -x "$JAVACMD" ]; then + echo "Error: JAVA_HOME is not defined correctly." >&2 + echo " We cannot execute $JAVACMD" >&2 + exit 1 +fi + +if [ -z "$JAVA_HOME" ]; then + echo "Warning: JAVA_HOME environment variable is not set." +fi + +CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher + +# traverses directory structure from process work directory to filesystem root +# first directory with .mvn subdirectory is considered project base directory +find_maven_basedir() { + + if [ -z "$1" ]; then + echo "Path not specified to find_maven_basedir" + return 1 + fi + + basedir="$1" + wdir="$1" + while [ "$wdir" != '/' ]; do + if [ -d "$wdir"/.mvn ]; then + basedir=$wdir + break + fi + # workaround for JBEAP-8937 (on Solaris 10/Sparc) + if [ -d "${wdir}" ]; then + wdir=$( + cd "$wdir/.." + pwd + ) + fi + # end of workaround + done + echo "${basedir}" +} + +# concatenates all lines of a file +concat_lines() { + if [ -f "$1" ]; then + echo "$(tr -s '\n' ' ' <"$1")" + fi +} + +BASE_DIR=$(find_maven_basedir "$(pwd)") +if [ -z "$BASE_DIR" ]; then + exit 1 +fi + +########################################################################################## +# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +# This allows using the maven wrapper in projects that prohibit checking in binary data. +########################################################################################## +if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found .mvn/wrapper/maven-wrapper.jar" + fi +else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." + fi + if [ -n "$MVNW_REPOURL" ]; then + jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + else + jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + fi + while IFS="=" read key value; do + case "$key" in wrapperUrl) + jarUrl="$value" + break + ;; + esac + done <"$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" + if [ "$MVNW_VERBOSE" = true ]; then + echo "Downloading from: $jarUrl" + fi + wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" + if $cygwin; then + wrapperJarPath=$(cygpath --path --windows "$wrapperJarPath") + fi + + if command -v wget >/dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found wget ... using wget" + fi + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + wget "$jarUrl" -O "$wrapperJarPath" + else + wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" + fi + elif command -v curl >/dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found curl ... using curl" + fi + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + curl -o "$wrapperJarPath" "$jarUrl" -f + else + curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f + fi + + else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Falling back to using Java to download" + fi + javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" + # For Cygwin, switch paths to Windows format before running javac + if $cygwin; then + javaClass=$(cygpath --path --windows "$javaClass") + fi + if [ -e "$javaClass" ]; then + if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Compiling MavenWrapperDownloader.java ..." + fi + # Compiling the Java class + ("$JAVA_HOME/bin/javac" "$javaClass") + fi + if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + # Running the downloader + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Running MavenWrapperDownloader.java ..." + fi + ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") + fi + fi + fi +fi +########################################################################################## +# End of extension +########################################################################################## + +export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} +if [ "$MVNW_VERBOSE" = true ]; then + echo $MAVEN_PROJECTBASEDIR +fi +MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" + +# For Cygwin, switch paths to Windows format before running java +if $cygwin; then + [ -n "$M2_HOME" ] && + M2_HOME=$(cygpath --path --windows "$M2_HOME") + [ -n "$JAVA_HOME" ] && + JAVA_HOME=$(cygpath --path --windows "$JAVA_HOME") + [ -n "$CLASSPATH" ] && + CLASSPATH=$(cygpath --path --windows "$CLASSPATH") + [ -n "$MAVEN_PROJECTBASEDIR" ] && + MAVEN_PROJECTBASEDIR=$(cygpath --path --windows "$MAVEN_PROJECTBASEDIR") +fi + +# Provide a "standardized" way to retrieve the CLI args that will +# work with both Windows and non-Windows executions. +MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" +export MAVEN_CMD_LINE_ARGS + +WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +exec "$JAVACMD" \ + $MAVEN_OPTS \ + -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ + "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ + ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/dh_ptos/mvnw.cmd b/dh_ptos/mvnw.cmd new file mode 100644 index 0000000..c8d4337 --- /dev/null +++ b/dh_ptos/mvnw.cmd @@ -0,0 +1,182 @@ +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM https://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Maven Start Up Batch script +@REM +@REM Required ENV vars: +@REM JAVA_HOME - location of a JDK home dir +@REM +@REM Optional ENV vars +@REM M2_HOME - location of maven2's installed home dir +@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending +@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven +@REM e.g. to debug Maven itself, use +@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM ---------------------------------------------------------------------------- + +@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' +@echo off +@REM set title of command window +title %0 +@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' +@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% + +@REM set %HOME% to equivalent of $HOME +if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") + +@REM Execute a user defined script before this one +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre +@REM check for pre script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" +if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" +:skipRcPre + +@setlocal + +set ERROR_CODE=0 + +@REM To isolate internal variables from possible post scripts, we use another setlocal +@setlocal + +@REM ==== START VALIDATION ==== +if not "%JAVA_HOME%" == "" goto OkJHome + +echo. +echo Error: JAVA_HOME not found in your environment. >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +:OkJHome +if exist "%JAVA_HOME%\bin\java.exe" goto init + +echo. +echo Error: JAVA_HOME is set to an invalid directory. >&2 +echo JAVA_HOME = "%JAVA_HOME%" >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +@REM ==== END VALIDATION ==== + +:init + +@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". +@REM Fallback to current working directory if not found. + +set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% +IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir + +set EXEC_DIR=%CD% +set WDIR=%EXEC_DIR% +:findBaseDir +IF EXIST "%WDIR%"\.mvn goto baseDirFound +cd .. +IF "%WDIR%"=="%CD%" goto baseDirNotFound +set WDIR=%CD% +goto findBaseDir + +:baseDirFound +set MAVEN_PROJECTBASEDIR=%WDIR% +cd "%EXEC_DIR%" +goto endDetectBaseDir + +:baseDirNotFound +set MAVEN_PROJECTBASEDIR=%EXEC_DIR% +cd "%EXEC_DIR%" + +:endDetectBaseDir + +IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig + +@setlocal EnableExtensions EnableDelayedExpansion +for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a +@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% + +:endReadAdditionalConfig + +SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" +set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" +set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + +FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( + IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B +) + +@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +@REM This allows using the maven wrapper in projects that prohibit checking in binary data. +if exist %WRAPPER_JAR% ( + if "%MVNW_VERBOSE%" == "true" ( + echo Found %WRAPPER_JAR% + ) +) else ( + if not "%MVNW_REPOURL%" == "" ( + SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + ) + if "%MVNW_VERBOSE%" == "true" ( + echo Couldn't find %WRAPPER_JAR%, downloading it ... + echo Downloading from: %DOWNLOAD_URL% + ) + + powershell -Command "&{"^ + "$webclient = new-object System.Net.WebClient;"^ + "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ + "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ + "}"^ + "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ + "}" + if "%MVNW_VERBOSE%" == "true" ( + echo Finished downloading %WRAPPER_JAR% + ) +) +@REM End of extension + +@REM Provide a "standardized" way to retrieve the CLI args that will +@REM work with both Windows and non-Windows executions. +set MAVEN_CMD_LINE_ARGS=%* + +%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* +if ERRORLEVEL 1 goto error +goto end + +:error +set ERROR_CODE=1 + +:end +@endlocal & set ERROR_CODE=%ERROR_CODE% + +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost +@REM check for post script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" +if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" +:skipRcPost + +@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' +if "%MAVEN_BATCH_PAUSE%" == "on" pause + +if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% + +exit /B %ERROR_CODE% diff --git a/dh_ptos/pom.xml b/dh_ptos/pom.xml new file mode 100644 index 0000000..6bdf59d --- /dev/null +++ b/dh_ptos/pom.xml @@ -0,0 +1,84 @@ + + + 4.0.0 + + ccsens_dh + com.ccsens + 1.0-SNAPSHOT + + + dh_ptos + + 0.0.1-SNAPSHOT + + dh_ptos + + Demo project for Spring Boot + + 1.8 + + + + + + cloudutil + com.ccsens + 1.0-SNAPSHOT + + + + com.ccsens + util + 1.0-SNAPSHOT + compile + + + + wechatutil + com.ccsens + 1.0-SNAPSHOT + + + + + + + + + org.mybatis.generator + mybatis-generator-maven-plugin + 1.3.7 + + ${basedir}/src/main/resources/mbg.xml + true + + + + mysql + mysql-connector-java + 5.1.34 + + + + + org.springframework.boot + spring-boot-maven-plugin + + com.ccsens.dh_ptos.DhPtosApplication + + + + + + repackage + + + + + + + + + + diff --git a/dh_ptos/src/main/java/com/ccsens/dh_ptos/DhPtosApplication.java b/dh_ptos/src/main/java/com/ccsens/dh_ptos/DhPtosApplication.java new file mode 100644 index 0000000..2243e41 --- /dev/null +++ b/dh_ptos/src/main/java/com/ccsens/dh_ptos/DhPtosApplication.java @@ -0,0 +1,31 @@ +package com.ccsens.dh_ptos; + +import com.ccsens.cloudutil.ribbon.RibbonConfiguration; +import org.mybatis.spring.annotation.MapperScan; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.web.servlet.ServletComponentScan; +import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker; +import org.springframework.cloud.openfeign.EnableFeignClients; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.FilterType; +import org.springframework.scheduling.annotation.EnableAsync; + +/** + * @author 逗 + */ +@MapperScan(basePackages = {"com.ccsens.dh_ptos.persist.*","com.ccsens.common.persist.*"}) +@ServletComponentScan +@EnableAsync +//开启断路器功能 +@EnableCircuitBreaker +@EnableFeignClients(basePackages = "com.ccsens.cloudutil.feign") +@SpringBootApplication +@ComponentScan(basePackages = "com.ccsens", excludeFilters = { @ComponentScan.Filter(type= FilterType.ASSIGNABLE_TYPE, value = RibbonConfiguration.class)}) +public class DhPtosApplication { + + public static void main(String[] args) { + SpringApplication.run(DhPtosApplication.class, args); + } + +} diff --git a/dh_ptos/src/main/java/com/ccsens/dh_ptos/api/DebugController.java b/dh_ptos/src/main/java/com/ccsens/dh_ptos/api/DebugController.java new file mode 100644 index 0000000..58d0a35 --- /dev/null +++ b/dh_ptos/src/main/java/com/ccsens/dh_ptos/api/DebugController.java @@ -0,0 +1,32 @@ +package com.ccsens.dh_ptos.api; + +import com.ccsens.util.JsonResponse; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +import javax.servlet.http.HttpServletRequest; + +/** + * @author 逗 + */ +@Api(tags = "DEBUG" , description = "DebugController | ") +@RestController +@RequestMapping("/debug") +@Slf4j +public class DebugController { + + @ApiOperation(value = "/测试",notes = "") + @ApiImplicitParams({ + }) + @RequestMapping(value="",method = RequestMethod.GET,produces = {"application/json;charset=UTF-8"}) + public JsonResponse debug(HttpServletRequest request) throws Exception { + + return JsonResponse.newInstance().ok("测试"); + } + +} diff --git a/dh_ptos/src/main/java/com/ccsens/dh_ptos/api/ProjectController.java b/dh_ptos/src/main/java/com/ccsens/dh_ptos/api/ProjectController.java new file mode 100644 index 0000000..f9fbec9 --- /dev/null +++ b/dh_ptos/src/main/java/com/ccsens/dh_ptos/api/ProjectController.java @@ -0,0 +1,41 @@ +package com.ccsens.dh_ptos.api; + +import com.ccsens.dh_ptos.bean.dto.ProjectDto; +import com.ccsens.dh_ptos.bean.vo.ProjectVo; +import com.ccsens.dh_ptos.service.IProjectService; +import com.ccsens.util.JsonResponse; +import com.ccsens.util.bean.dto.QueryDto; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import lombok.extern.slf4j.Slf4j; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; +import java.util.List; + +/** + * @author 逗 + */ +@Api(tags = "project" , description = "项目相关接口") +@RestController +@RequestMapping("/project") +@Slf4j +public class ProjectController { + + @Resource + private IProjectService projectService; + + @ApiOperation(value = "查询用户所有域下所有业务内的所有项目", notes = "") + @RequestMapping(value = "/query", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) + public JsonResponse> queryDomainByUser(@ApiParam @Validated @RequestBody QueryDto params) throws Exception{ + log.info("查询用户所有域下所有业务内的所有项目:{}",params); + List domainInfoList = projectService.queryDomainByUser(params.getParam(),params.getUserId()); + log.info("查询用户所有域下所有业务内的所有项目"); + return JsonResponse.newInstance().ok(domainInfoList); + } +} diff --git a/dh_ptos/src/main/java/com/ccsens/dh_ptos/api/UserController.java b/dh_ptos/src/main/java/com/ccsens/dh_ptos/api/UserController.java new file mode 100644 index 0000000..f96fbda --- /dev/null +++ b/dh_ptos/src/main/java/com/ccsens/dh_ptos/api/UserController.java @@ -0,0 +1,18 @@ +package com.ccsens.dh_ptos.api; + +import io.swagger.annotations.Api; +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * @author 逗 + */ +@Api(tags = "user" , description = "用户信息相关接口") +@RestController +@RequestMapping("/user") +@Slf4j +public class UserController { + + +} diff --git a/dh_ptos/src/main/java/com/ccsens/dh_ptos/bean/dto/ProjectDto.java b/dh_ptos/src/main/java/com/ccsens/dh_ptos/bean/dto/ProjectDto.java new file mode 100644 index 0000000..6a1aa5d --- /dev/null +++ b/dh_ptos/src/main/java/com/ccsens/dh_ptos/bean/dto/ProjectDto.java @@ -0,0 +1,22 @@ +package com.ccsens.dh_ptos.bean.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author 逗 + */ +@Data +public class ProjectDto { + + @Data + @ApiModel("用户查询可见的项目") + public static class QueryProjectDto{ + @ApiModelProperty("开始时间") + private Long startTime; + @ApiModelProperty("结束时间") + private Long endTime; + } + +} diff --git a/dh_ptos/src/main/java/com/ccsens/dh_ptos/bean/vo/ProjectVo.java b/dh_ptos/src/main/java/com/ccsens/dh_ptos/bean/vo/ProjectVo.java new file mode 100644 index 0000000..464e600 --- /dev/null +++ b/dh_ptos/src/main/java/com/ccsens/dh_ptos/bean/vo/ProjectVo.java @@ -0,0 +1,86 @@ +package com.ccsens.dh_ptos.bean.vo; + +import cn.hutool.core.util.ObjectUtil; +import com.ccsens.util.WebConstant; +import com.fasterxml.jackson.annotation.JsonIgnore; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +/** + * @author 逗 + */ +@Data +public class ProjectVo { + + @Data + @ApiModel("域信息") + public static class DomainInfo{ + @ApiModelProperty("id") + private Long id; + @ApiModelProperty("域名") + private String name; + @ApiModelProperty("域code") + private String code; + @ApiModelProperty("域访问前缀") + private String url; + @ApiModelProperty("是否是自身 0否 1是") + private byte self; + @ApiModelProperty("业务列表") + private List businessList; + } + @Data + @ApiModel("业务信息") + public static class BusinessInfo{ + @ApiModelProperty("业务id") + private Long businessId; + @ApiModelProperty("业务名") + private String businessName; + @ApiModelProperty("业务code") + private String businessCode; + @ApiModelProperty("业务访问前缀") + private String url; + @ApiModelProperty("项目列表") + private List projectList; + } + + @Data + @ApiModel("日历下项目列表信息") + public static class ProjectInfo{ + @ApiModelProperty("id") + private Long id; + @ApiModelProperty("项目名") + private String name; + @ApiModelProperty("开始时间") + private Long startTime; + @ApiModelProperty("结束时间") + private Long endTime; + @ApiModelProperty("项目完成状态(0-未开始,1-进行中,2-暂停,3-已完成)") + private byte status; + @ApiModelProperty("访问路径)") + private String url; + @ApiModelProperty("子项目") + private List sonProjectList; + @JsonIgnore + @ApiModelProperty("父级id") + private Long parentId; + + public Byte getStatus() { + long current = System.currentTimeMillis(); + if(ObjectUtil.isNull(getStartTime()) || ObjectUtil.isNull(getEndTime())) { + return null; + } + if(getStartTime() > current){ + this.status = (byte) WebConstant.EVENT_PROCESS.Pending.value; + }else if(getEndTime() < current){ + this.status = (byte) WebConstant.EVENT_PROCESS.Expired.value; + }else{ + this.status = (byte) WebConstant.EVENT_PROCESS.Processing.value; + } + return this.status; + } + } + +} diff --git a/dh_ptos/src/main/java/com/ccsens/dh_ptos/config/BeanConfig.java b/dh_ptos/src/main/java/com/ccsens/dh_ptos/config/BeanConfig.java new file mode 100644 index 0000000..07fb159 --- /dev/null +++ b/dh_ptos/src/main/java/com/ccsens/dh_ptos/config/BeanConfig.java @@ -0,0 +1,22 @@ +package com.ccsens.dh_ptos.config; + +import com.ccsens.dh_ptos.intercept.MybatisInterceptor; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * @description: + * @author: wuHuiJuan + * @create: 2019/12/03 18:01 + */ +@Configuration +public class BeanConfig { + /** + * 注册拦截器 + */ + @Bean + public MybatisInterceptor mybatisInterceptor() { + MybatisInterceptor interceptor = new MybatisInterceptor(); + return interceptor; + } +} diff --git a/dh_ptos/src/main/java/com/ccsens/dh_ptos/config/SpringConfig.java b/dh_ptos/src/main/java/com/ccsens/dh_ptos/config/SpringConfig.java new file mode 100644 index 0000000..1e6b4c4 --- /dev/null +++ b/dh_ptos/src/main/java/com/ccsens/dh_ptos/config/SpringConfig.java @@ -0,0 +1,128 @@ +package com.ccsens.dh_ptos.config; + + +import cn.hutool.core.lang.Snowflake; +import cn.hutool.core.util.IdUtil; +import com.ccsens.util.config.DruidProps; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.module.SimpleModule; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.MediaType; +import org.springframework.http.converter.HttpMessageConverter; +import org.springframework.http.converter.StringHttpMessageConverter; +import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; +import org.springframework.web.servlet.config.annotation.*; + +import javax.annotation.Resource; +import javax.sql.DataSource; +import java.nio.charset.Charset; +import java.util.ArrayList; +import java.util.List; +import java.util.TimeZone; + +@Configuration +public class SpringConfig implements WebMvcConfigurer { + @Resource + private DruidProps druidPropsUtil; + @Value("${spring.snowflake.workerId}") + private String workerId; + @Value("${spring.snowflake.datacenterId}") + private String datacenterId; + + /** + * 配置Converter + * @return + */ + @Bean + public HttpMessageConverter responseStringConverter() { + StringHttpMessageConverter converter = new StringHttpMessageConverter( + Charset.forName("UTF-8")); + return converter; + } + + @Bean + public HttpMessageConverter responseJsonConverter(){ + MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter(); + List mediaTypeList = new ArrayList<>(); + mediaTypeList.add(MediaType.TEXT_HTML); + mediaTypeList.add(MediaType.APPLICATION_JSON_UTF8); + converter.setSupportedMediaTypes(mediaTypeList); + + ObjectMapper objectMapper = new ObjectMapper(); + SimpleModule simpleModule = new SimpleModule(); + simpleModule.addSerializer(Long.class, ToStringSerializer.instance); + simpleModule.addSerializer(Long.TYPE, ToStringSerializer.instance); + objectMapper.registerModule(simpleModule); + objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + objectMapper.setTimeZone(TimeZone.getTimeZone("GMT+8")); + converter.setObjectMapper(objectMapper); + + return converter; + } + + @Override + public void configureMessageConverters(List> converters) { + converters.add(responseStringConverter()); + converters.add(responseJsonConverter()); + } + + @Override + public void configureContentNegotiation(ContentNegotiationConfigurer configurer) { + configurer.favorPathExtension(false); + } + + @Override + public void addCorsMappings(CorsRegistry registry) { + registry.addMapping("/**").allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS") +// .allowedMethods("*") // 允许提交请求的方法,*表示全部允许 + .allowedOrigins("*") // #允许向该服务器提交请求的URI,*表示全部允许 + .allowCredentials(true) // 允许cookies跨域 + .allowedHeaders("*") // #允许访问的头信息,*表示全部 + .maxAge(18000L); // 预检请求的缓存时间(秒),即在这个时间段里,对于相同的跨域请求不会再预检了 + + } + + + + + /** + * 配置静态资源 + */ + @Override + public void addResourceHandlers(ResourceHandlerRegistry registry) { + registry.addResourceHandler("swagger-ui.html") + .addResourceLocations("classpath:/META-INF/resources/"); + registry.addResourceHandler("/webjars/**") + .addResourceLocations("classpath:/META-INF/resources/webjars/"); + + registry.addResourceHandler("/uploads/**") + .addResourceLocations("file:///home/ptos/service/uploads/"); + } + + /** + * 配置拦截器 + * @param registry + */ + @Override + public void addInterceptors(InterceptorRegistry registry) { + + } + + + /** + * 配置数据源(单数据源) + */ + @Bean + public DataSource dataSource(){ + return druidPropsUtil.createDruidDataSource(); + } + + @Bean + public Snowflake snowflake(){ + return IdUtil.createSnowflake(Long.valueOf(workerId), Long.valueOf(datacenterId)); + } +} \ No newline at end of file diff --git a/dh_ptos/src/main/java/com/ccsens/dh_ptos/config/SwaggerConfigure.java b/dh_ptos/src/main/java/com/ccsens/dh_ptos/config/SwaggerConfigure.java new file mode 100644 index 0000000..857cbdb --- /dev/null +++ b/dh_ptos/src/main/java/com/ccsens/dh_ptos/config/SwaggerConfigure.java @@ -0,0 +1,56 @@ +package com.ccsens.dh_ptos.config; + +import com.ccsens.util.WebConstant; +import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import springfox.documentation.builders.ParameterBuilder; +import springfox.documentation.builders.RequestHandlerSelectors; +import springfox.documentation.schema.ModelRef; +import springfox.documentation.service.ApiInfo; +import springfox.documentation.service.Parameter; +import springfox.documentation.spi.DocumentationType; +import springfox.documentation.spring.web.plugins.Docket; +import springfox.documentation.swagger2.annotations.EnableSwagger2; + +import java.util.ArrayList; +import java.util.List; + +@Configuration +@EnableSwagger2 +@ConditionalOnExpression("${swagger.enable}") +//public class SwaggerConfigure extends WebMvcConfigurationSupport { +public class SwaggerConfigure /*implements WebMvcConfigurer*/ { + @Bean + public Docket customDocket() { + // + return new Docket(DocumentationType.SWAGGER_2) + .apiInfo(apiInfo()) + .select() + .apis(RequestHandlerSelectors + .basePackage("com.ccsens.dh_ptos.api")) + .build() + .globalOperationParameters(setHeaderToken()); + } + + private ApiInfo apiInfo() { + return new ApiInfo("Swagger Tall-game",//大标题 title + "This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.",//小标题 + "1.0.0",//版本 + "http://swagger.io/terms/",//termsOfServiceUrl + "zhangsan",//作者 + "Apache 2.0",//链接显示文字 + "http://www.apache.org/licenses/LICENSE-2.0.html"//网站链接 + ); + } + + private List setHeaderToken() { + ParameterBuilder tokenPar = new ParameterBuilder(); + List pars = new ArrayList<>(); + tokenPar.name(WebConstant.HEADER_KEY_TOKEN).description("token") + .defaultValue(WebConstant.HEADER_KEY_TOKEN_PREFIX) + .modelRef(new ModelRef("string")).parameterType("header").required(false).build(); + pars.add(tokenPar.build()); + return pars; + } +} diff --git a/dh_ptos/src/main/java/com/ccsens/dh_ptos/intercept/MybatisInterceptor.java b/dh_ptos/src/main/java/com/ccsens/dh_ptos/intercept/MybatisInterceptor.java new file mode 100644 index 0000000..335fe90 --- /dev/null +++ b/dh_ptos/src/main/java/com/ccsens/dh_ptos/intercept/MybatisInterceptor.java @@ -0,0 +1,159 @@ +package com.ccsens.dh_ptos.intercept; + +import cn.hutool.core.collection.CollectionUtil; +import com.ccsens.util.WebConstant; +import org.apache.ibatis.executor.Executor; +import org.apache.ibatis.mapping.BoundSql; +import org.apache.ibatis.mapping.MappedStatement; +import org.apache.ibatis.mapping.ResultMap; +import org.apache.ibatis.mapping.SqlSource; +import org.apache.ibatis.plugin.*; +import org.apache.ibatis.reflection.DefaultReflectorFactory; +import org.apache.ibatis.reflection.MetaObject; +import org.apache.ibatis.reflection.factory.DefaultObjectFactory; +import org.apache.ibatis.reflection.wrapper.DefaultObjectWrapperFactory; +import org.apache.ibatis.session.ResultHandler; +import org.apache.ibatis.session.RowBounds; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.List; +import java.util.Map; +import java.util.Properties; + +/** + * @description: + * @author: wuHuiJuan + * @create: 2019/12/11 10:58 + */ +@Intercepts({ + @Signature( + type = Executor.class, + method = "query", + args = {MappedStatement.class, Object.class, RowBounds.class, ResultHandler.class} + ) +}) +public class MybatisInterceptor implements Interceptor { + @Override + public Object intercept(Invocation invocation) throws Throwable { + + + String selectByExample = "selectByExample"; + String countByExample = "countByExample"; + String countByExample2 = "selectByExample_COUNT"; + String selectByPrimaryKey = "selectByPrimaryKey"; + + Object[] args = invocation.getArgs(); + MappedStatement statement = (MappedStatement) args[0]; + if (statement.getId().endsWith(selectByExample) + || statement.getId().endsWith(countByExample) + || statement.getId().endsWith(countByExample2)) { + //XXXExample + Object example = args[1]; + + addCondition(statement, example); + + + + + } else if (statement.getId().endsWith(selectByPrimaryKey)) { + BoundSql boundSql = statement.getBoundSql(args[1]); + String sql = boundSql.getSql() + " and rec_status = 0"; + MappedStatement newStatement = newMappedStatement(statement, new BoundSqlSqlSource(boundSql)); + MetaObject msObject = MetaObject.forObject(newStatement, new DefaultObjectFactory(), new DefaultObjectWrapperFactory(),new DefaultReflectorFactory()); + msObject.setValue("sqlSource.boundSql.sql", sql); + args[0] = newStatement; + } + + return invocation.proceed(); + } + + private void addCondition(MappedStatement statement, Object example) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException, ClassNotFoundException { + if (example instanceof Map) { + example = ((Map) example).get("_ORIGINAL_PARAMETER_OBJECT"); + } + + + Method method = example.getClass().getMethod("getOredCriteria", null); + //获取到条件数组,第一个是Criteria + List list = (List) method.invoke(example); + if (CollectionUtil.isEmpty(list)) { + Class clazz = ((ResultMap) statement.getResultMaps().get(0)).getType(); + String exampleName = clazz.getName() + "Example"; + Object paramExample = Class.forName(exampleName).newInstance(); + Method createCriteria = paramExample.getClass().getMethod("createCriteria"); + Object criteria = createCriteria.invoke(paramExample); + Method andIsDelEqualTo = criteria.getClass().getMethod("andRecStatusEqualTo", Byte.class); + andIsDelEqualTo.invoke(criteria, WebConstant.REC_STATUS.Normal.value); + list.add(criteria); + } else { + Object criteria = list.get(0); + Method getCriteria = criteria.getClass().getMethod("getCriteria"); + List params = (List) getCriteria.invoke(criteria); + boolean hasDel = false; + for (Object param : params) { + Method getCondition = param.getClass().getMethod("getCondition"); + Object condition = getCondition.invoke(param); + if ("rec_status =".equals(condition)) { + hasDel = true; + } + } + if (!hasDel) { + Method andIsDelEqualTo = criteria.getClass().getMethod("andRecStatusEqualTo", Byte.class); + andIsDelEqualTo.invoke(criteria, WebConstant.REC_STATUS.Normal.value); + } + + } + + } + + @Override + public Object plugin(Object target) { + return Plugin.wrap(target, this); + } + + @Override + public void setProperties(Properties properties) { + + } + + private MappedStatement newMappedStatement(MappedStatement ms, SqlSource newSqlSource) { + MappedStatement.Builder builder = + new MappedStatement.Builder(ms.getConfiguration(), ms.getId(), newSqlSource, ms.getSqlCommandType()); + builder.resource(ms.getResource()); + builder.fetchSize(ms.getFetchSize()); + builder.statementType(ms.getStatementType()); + builder.keyGenerator(ms.getKeyGenerator()); + if (ms.getKeyProperties() != null && ms.getKeyProperties().length != 0) { + StringBuilder keyProperties = new StringBuilder(); + for (String keyProperty : ms.getKeyProperties()) { + keyProperties.append(keyProperty).append(","); + } + keyProperties.delete(keyProperties.length() - 1, keyProperties.length()); + builder.keyProperty(keyProperties.toString()); + } + builder.timeout(ms.getTimeout()); + builder.parameterMap(ms.getParameterMap()); + builder.resultMaps(ms.getResultMaps()); + builder.resultSetType(ms.getResultSetType()); + builder.cache(ms.getCache()); + builder.flushCacheRequired(ms.isFlushCacheRequired()); + builder.useCache(ms.isUseCache()); + + return builder.build(); + } + + + // 定义一个内部辅助类,作用是包装sq + class BoundSqlSqlSource implements SqlSource { + private BoundSql boundSql; + public BoundSqlSqlSource(BoundSql boundSql) { + this.boundSql = boundSql; + } + @Override + public BoundSql getBoundSql(Object parameterObject) { + return boundSql; + } + } + +} diff --git a/dh_ptos/src/main/java/com/ccsens/dh_ptos/service/IProjectService.java b/dh_ptos/src/main/java/com/ccsens/dh_ptos/service/IProjectService.java new file mode 100644 index 0000000..34648d6 --- /dev/null +++ b/dh_ptos/src/main/java/com/ccsens/dh_ptos/service/IProjectService.java @@ -0,0 +1,19 @@ +package com.ccsens.dh_ptos.service; + +import com.ccsens.dh_ptos.bean.dto.ProjectDto; +import com.ccsens.dh_ptos.bean.vo.ProjectVo; + +import java.util.List; + +/** + * @author 逗 + */ +public interface IProjectService { + /** + * 查询用户在所有域所有业务下的所有项目 + * @param param 开始结束时间 + * @param userId userId + * @return 返回项目列表 + */ + List queryDomainByUser(ProjectDto.QueryProjectDto param, Long userId); +} diff --git a/dh_ptos/src/main/java/com/ccsens/dh_ptos/service/ProjectService.java b/dh_ptos/src/main/java/com/ccsens/dh_ptos/service/ProjectService.java new file mode 100644 index 0000000..cd67c16 --- /dev/null +++ b/dh_ptos/src/main/java/com/ccsens/dh_ptos/service/ProjectService.java @@ -0,0 +1,25 @@ +package com.ccsens.dh_ptos.service; + +import com.ccsens.dh_ptos.bean.dto.ProjectDto; +import com.ccsens.dh_ptos.bean.vo.ProjectVo; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; +/** + * @author 逗 + */ +@Slf4j +@Service +@Transactional(propagation = Propagation.REQUIRED,rollbackFor = Exception.class) +public class ProjectService implements IProjectService { + + + @Override + public List queryDomainByUser(ProjectDto.QueryProjectDto param, Long userId) { + + return null; + } +} diff --git a/dh_ptos/src/main/java/com/ccsens/dh_ptos/util/PtOsCodeError.java b/dh_ptos/src/main/java/com/ccsens/dh_ptos/util/PtOsCodeError.java new file mode 100644 index 0000000..cc9a967 --- /dev/null +++ b/dh_ptos/src/main/java/com/ccsens/dh_ptos/util/PtOsCodeError.java @@ -0,0 +1,12 @@ +package com.ccsens.dh_ptos.util; + +import com.ccsens.util.CodeError; + +/** + * @author 逗 + */ +public class PtOsCodeError extends CodeError { + + public static final Code NOT_WBS_SHEET = new Code(501,"找不到wbs表",true); + +} diff --git a/dh_ptos/src/main/java/com/ccsens/dh_ptos/util/PtOsConstant.java b/dh_ptos/src/main/java/com/ccsens/dh_ptos/util/PtOsConstant.java new file mode 100644 index 0000000..1d861e8 --- /dev/null +++ b/dh_ptos/src/main/java/com/ccsens/dh_ptos/util/PtOsConstant.java @@ -0,0 +1,50 @@ +package com.ccsens.dh_ptos.util; + +import java.util.HashMap; +import java.util.Map; + +/** + * @author 逗 + */ +public class PtOsConstant { + + /**图片类型*/ + public static final String FILE_TYPE_IMG = "bmp,jpg,jpeg,png,tif,gif,pcx,tga,exif,fpx,svg,psd,cdr,pcd,dxf,ufo,eps,ai,raw,WMF,webp"; + /**文档类型*/ + public static final String FILE_TYPE_DOCUMENT = "doc, dot, wps, wpt, docx, dotx, docm, dotm, xls, xlt, et, xlsx, xltx, csv, xlsm, xltm, ppt,pptx,pptm,ppsx,ppsm,pps,potx,potm,dpt,dps, pdf"; + + + /**验证手机正则*/ + public static final String PHONE_REGEX = "^[1]([3-9])[0-9]{9}$"; + /**字符串分隔符*/ + public static final String STRING_REGEX = ",|,|;|;|、|/"; + /**wbs相关*/ + public static final class WbsExcel { + /**wbsSheet*/ + public static final String WBS_SHEET = "WBS"; + /**项目成员Sheet*/ + public static final String MEMBER_SHEET = "项目成员表"; + /**项目信息头*/ + public static final String PROJECT_INFO_TITLE = "项目信息"; + /**任务信息头*/ + public static final String TASK_INFO_TITLE = "项目任务分解"; + /**excel文件格式验证*/ + public static final String WBS_FILE_FORMAT = "xls,xlsx"; + /**插件配置表*/ + public static final String WBS_PLUGIN_CONFIG = "插件配置表"; + } + + /**wbs表时长对应关系表*/ + public static final Map WBS_DURATION = new HashMap<>(); + static { + WBS_DURATION.put("s",1000L); + WBS_DURATION.put("min",60 * 1000L); + WBS_DURATION.put("h",60 * 60 * 1000L); + WBS_DURATION.put("d",24 * 60 * 60 * 1000L); + WBS_DURATION.put("w",7 * 24 * 60 * 60 * 1000L); + WBS_DURATION.put("m",30 * 24 * 60 * 60 * 1000L); + WBS_DURATION.put("y",365 * 24 * 60 * 60 * 1000L); + } + + +} diff --git a/dh_ptos/src/main/resources/application-common.yml b/dh_ptos/src/main/resources/application-common.yml new file mode 100644 index 0000000..a9fafd1 --- /dev/null +++ b/dh_ptos/src/main/resources/application-common.yml @@ -0,0 +1,30 @@ +logging: + level: + com: + favorites: DEBUG + org: + hibernate: ERROR + springframework: + web: DEBUG +mybatis: + config-location: classpath:mybatis/mybatis-config.xml + mapper-locations: classpath*:mapper_*/*.xml +# type-aliases-package: com.ccsens.mtpro.bean +#server: +# tomcat: +# uri-encoding: UTF-8 +spring: + http: + encoding: + charset: UTF-8 + enabled: true + force: true + log-request-details: true + servlet: + multipart: + max-file-size: 10MB + max-request-size: 100MB + snowflake: + datacenterId: 10 + workerId: 1 + diff --git a/dh_ptos/src/main/resources/application-dev.yml b/dh_ptos/src/main/resources/application-dev.yml new file mode 100644 index 0000000..3444f22 --- /dev/null +++ b/dh_ptos/src/main/resources/application-dev.yml @@ -0,0 +1,50 @@ +server: + port: 7290 + servlet: + context-path: +spring: + application: + name: dh_ptos + datasource: + type: com.alibaba.druid.pool.DruidDataSource +# rabbitmq: +# host: 192.168.0.99 +# password: 111111 +# port: 5672 +# username: admin + rabbitmq: + host: 127.0.0.1 + password: guest + port: 5672 + username: guest + redis: + database: 0 + host: 127.0.0.1 + jedis: + pool: + max-active: 200 + max-idle: 10 + max-wait: -1ms + min-idle: 0 + password: '' + port: 6379 + timeout: 1000ms +swagger: + enable: true +mybatisCache: + database: 1 + host: 127.0.0.1 + jedis: + pool: + max-active: 200 + max-idle: 10 + max-wait: -1 + min-idle: 0 + password: '' + port: 6379 + timeout: 1000 + +file: + path: /home/ptos/service/uploads/ + domain: https://test.tall.wiki/gateway/dh_ptos + imgDomain: https://test.tall.wiki/gateway/dh_ptos/uploads/ diff --git a/dh_ptos/src/main/resources/application-prod.yml b/dh_ptos/src/main/resources/application-prod.yml new file mode 100644 index 0000000..af7bd73 --- /dev/null +++ b/dh_ptos/src/main/resources/application-prod.yml @@ -0,0 +1,40 @@ +server: + port: 7290 + servlet: + context-path: +spring: + application: + name: dh_ptos + datasource: + type: com.alibaba.druid.pool.DruidDataSource + rabbitmq: + host: 121.36.3.207 + password: 111111 + port: 5672 + username: admin + redis: + database: 0 + host: 127.0.0.1 + jedis: + pool: + max-active: 200 + max-idle: 10 + max-wait: -1ms + min-idle: 0 + password: '' +# password: 'areowqr!@43ef' + port: 6379 + timeout: 1000ms +swagger: + enable: true +eureka: + instance: + ip-address: 121.36.106.168 + +gatewayUrl: https://www.tall.wiki/gateway/ +notGatewayUrl: https://www.tall.wiki/ +apiUrl: https://www.tall.wiki/ +file: + path: /home/ptos/service/uploads/ + domain: https://www.tall.wiki/gateway/dh_ptos + imgDomain: https://www.tall.wiki/gateway/dh_ptos/uploads/ diff --git a/dh_ptos/src/main/resources/application-test.yml b/dh_ptos/src/main/resources/application-test.yml new file mode 100644 index 0000000..3542416 --- /dev/null +++ b/dh_ptos/src/main/resources/application-test.yml @@ -0,0 +1,48 @@ +server: + port: 7290 + servlet: + context-path: +spring: + application: + name: dh_ptos + datasource: + type: com.alibaba.druid.pool.DruidDataSource + rabbitmq: + host: dd.tall.wiki + password: 111111 + port: 5672 + username: admin + redis: + database: 0 + host: 127.0.0.1 + jedis: + pool: + max-active: 200 + max-idle: 10 + max-wait: -1ms + min-idle: 0 + password: '' + port: 6379 + timeout: 1000ms +swagger: + enable: true +mybatisCache: + database: 1 + host: 127.0.0.1 + jedis: + pool: + max-active: 200 + max-idle: 10 + max-wait: -1 + min-idle: 0 + password: '' + port: 6379 + timeout: 1000 +eureka: + instance: + ip-address: 127.0.0.1 + +file: + path: /home/ptos/service/uploads/ + domain: https://test.tall.wiki/gateway/dh_ptos + imgDomain: https://test.tall.wiki/gateway/dh_ptos/uploads/ diff --git a/dh_ptos/src/main/resources/application.yml b/dh_ptos/src/main/resources/application.yml new file mode 100644 index 0000000..2fb38e5 --- /dev/null +++ b/dh_ptos/src/main/resources/application.yml @@ -0,0 +1,4 @@ +spring: + profiles: + active: dev + include: common, util-dev diff --git a/dh_ptos/src/main/resources/druid-dev.yml b/dh_ptos/src/main/resources/druid-dev.yml new file mode 100644 index 0000000..f7298f6 --- /dev/null +++ b/dh_ptos/src/main/resources/druid-dev.yml @@ -0,0 +1,34 @@ +spring: + datasource: + druid: + connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000 + driverClassName: com.mysql.cj.jdbc.Driver + dynamicUrl: jdbc:mysql://localhost:3306/${schema} + filterExclusions: '*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*' + filterName: druidFilter + filterProfileEnable: true + filterUrlPattern: /* + filters: stat,wall + initialSize: 5 + maxActive: 20 + maxPoolPreparedStatementPerConnectionSize: 20 + maxWait: 60000 + minEvictableIdleTimeMillis: 300000 + minIdle: 5 +# password: 37080c1f223685592316b02dad8816c019290a476e54ebb638f9aa3ba8b6bdb9 + password: 68073a279b399baa1fa12cf39bfbb65bfc1480ffee7b659ccc81cf19be8c4473 + poolPreparedStatements: true + servletLogSlowSql: true + servletLoginPassword: 111111 + servletLoginUsername: druid + servletName: druidServlet + servletResetEnable: true + servletUrlMapping: /druid/* + testOnBorrow: false + testOnReturn: false + testWhileIdle: true + timeBetweenEvictionRunsMillis: 60000 + url: jdbc:mysql://101.201.226.163:3306/dh_ht?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&autoReconnect=true + username: root + validationQuery: SELECT 1 FROM DUAL + env: CCSENS_TALL \ No newline at end of file diff --git a/dh_ptos/src/main/resources/druid-prod.yml b/dh_ptos/src/main/resources/druid-prod.yml new file mode 100644 index 0000000..986eb39 --- /dev/null +++ b/dh_ptos/src/main/resources/druid-prod.yml @@ -0,0 +1,35 @@ +spring: + datasource: + druid: + connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000 + driverClassName: com.mysql.cj.jdbc.Driver + dynamicUrl: jdbc:mysql://localhost:3306/${schema} + filterExclusions: '*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*' + filterName: druidFilter + filterProfileEnable: true + filterUrlPattern: /* + filters: stat,wall + initialSize: 5 + maxActive: 20 + maxPoolPreparedStatementPerConnectionSize: 20 + maxWait: 60000 + minEvictableIdleTimeMillis: 300000 + minIdle: 5 +# password: + password: 68073a279b399baa1fa12cf39bfbb65bfc1480ffee7b659ccc81cf19be8c4473 + poolPreparedStatements: true + servletLogSlowSql: true + servletLoginPassword: 111111 + servletLoginUsername: druid + servletName: druidServlet + servletResetEnable: true + servletUrlMapping: /druid/* + testOnBorrow: false + testOnReturn: false + testWhileIdle: true + timeBetweenEvictionRunsMillis: 60000 +# url: jdbc:mysql://127.0.0.1/defaultwbs?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&autoReconnect=true + url: jdbc:mysql://www.tall.wiki/data_centre?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&autoReconnect=true + username: root + validationQuery: SELECT 1 FROM DUAL + env: CCSENS_TALL \ No newline at end of file diff --git a/dh_ptos/src/main/resources/druid-test.yml b/dh_ptos/src/main/resources/druid-test.yml new file mode 100644 index 0000000..32e18fd --- /dev/null +++ b/dh_ptos/src/main/resources/druid-test.yml @@ -0,0 +1,34 @@ +spring: + datasource: + druid: + connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000 + driverClassName: com.mysql.cj.jdbc.Driver + dynamicUrl: jdbc:mysql://localhost:3306/${schema} + filterExclusions: '*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*' + filterName: druidFilter + filterProfileEnable: true + filterUrlPattern: /* + filters: stat,wall + initialSize: 5 + maxActive: 20 + maxPoolPreparedStatementPerConnectionSize: 20 + maxWait: 60000 + minEvictableIdleTimeMillis: 300000 + minIdle: 5 +# password: 68073a279b399baa1fa12cf39bfbb65bfc1480ffee7b659ccc81cf19be8c4473 + password: + poolPreparedStatements: true + servletLogSlowSql: true + servletLoginPassword: 111111 + servletLoginUsername: druid + servletName: druidServlet + servletResetEnable: true + servletUrlMapping: /druid/* + testOnBorrow: false + testOnReturn: false + testWhileIdle: true + timeBetweenEvictionRunsMillis: 60000 + url: jdbc:mysql://101.201.226.163:3306/tall_dm?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&autoReconnect=true + username: root + validationQuery: SELECT 1 FROM DUAL + env: CCSENS_TALL \ No newline at end of file diff --git a/dh_ptos/src/main/resources/logback-spring.xml b/dh_ptos/src/main/resources/logback-spring.xml new file mode 100644 index 0000000..3d37c64 --- /dev/null +++ b/dh_ptos/src/main/resources/logback-spring.xml @@ -0,0 +1,196 @@ + + + + + + + + + + logback + + + + + + + + + + + + + + + + + info + + + ${CONSOLE_LOG_PATTERN} + + UTF-8 + + + + + + + + + + ${log.path}/log_debug.log + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n + UTF-8 + + + + + ${log.path}/debug/log-debug-%d{yyyy-MM-dd}.%i.log + + 100MB + + + 15 + + + + debug + ACCEPT + DENY + + + + + + + ${log.path}/log_info.log + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n + UTF-8 + + + + + ${log.path}/info/log-info-%d{yyyy-MM-dd}.%i.log + + 100MB + + + 15 + + + + info + ACCEPT + DENY + + + + + + + ${log.path}/log_warn.log + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n + UTF-8 + + + + ${log.path}/warn/log-warn-%d{yyyy-MM-dd}.%i.log + + 100MB + + + 15 + + + + warn + ACCEPT + DENY + + + + + + + + ${log.path}/log_error.log + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n + UTF-8 + + + + ${log.path}/error/log-error-%d{yyyy-MM-dd}.%i.log + + 100MB + + + 15 + + + + ERROR + ACCEPT + DENY + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/dh_ptos/src/main/resources/mybatis/mybatis-config.xml b/dh_ptos/src/main/resources/mybatis/mybatis-config.xml new file mode 100644 index 0000000..e5a218d --- /dev/null +++ b/dh_ptos/src/main/resources/mybatis/mybatis-config.xml @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/origin) b/origin) new file mode 100644 index 0000000..e69de29 diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..fd68636 --- /dev/null +++ b/pom.xml @@ -0,0 +1,260 @@ + + + 4.0.0 + + pom + + cloudutil + util + wechatutil + dh_ptos + dh_diplomatist + dh_ht + + + + com.ccsens + ccsens_dh + 1.0-SNAPSHOT + + + + org.springframework.boot + spring-boot-starter-parent + 2.1.8.RELEASE + + + + + UTF-8 + 1.8 + true + + + + + + io.netty + netty-all + 4.1.32.Final + + + + org.springframework.boot + spring-boot-starter-data-redis + + + + org.springframework.boot + spring-boot-starter-cache + + + + redis.clients + jedis + + + org.springframework.boot + spring-boot-starter-jdbc + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-tomcat + + + + + org.springframework.boot + spring-boot-starter-jetty + + + + + org.springframework.boot + spring-boot-configuration-processor + true + + + org.projectlombok + lombok + true + + + org.springframework.boot + spring-boot-starter-test + + + com.vaadin.external.google + android-json + + + test + + + org.springframework.boot + spring-boot-starter-actuator + + + + + cn.hutool + hutool-all + 4.1.21 + + + + + org.apache.poi + poi + 3.17 + + + org.apache.poi + poi-ooxml + 3.17 + + + + org.springframework.boot + spring-boot-starter-websocket + + + + org.springframework.boot + spring-boot-starter-amqp + + + + org.mybatis.spring.boot + mybatis-spring-boot-starter + 1.1.1 + + + + com.github.pagehelper + pagehelper + 4.1.4 + + + + mysql + mysql-connector-java + + + + com.alibaba + druid + 1.1.10 + + + + io.jsonwebtoken + jjwt + 0.7.0 + + + + + + com.fasterxml.jackson.dataformat + jackson-dataformat-xml + 2.9.0 + + + + + org.apache.shiro + shiro-spring + 1.4.0 + + + + net.sourceforge.htmlcleaner + htmlcleaner + 2.22 + + + + org.apache.commons + commons-lang3 + 3.8.1 + + + + + + io.springfox + springfox-swagger2 + 2.9.2 + + + + io.springfox + springfox-swagger-ui + 2.9.2 + + + + org.mybatis.generator + mybatis-generator-core + 1.3.7 + + + + + org.beanshell + bsh + 2.0b5 + + + + org.apache.httpcomponents + httpclient + 4.5.1 + + + + org.apache.httpcomponents + httpcore + 4.4.3 + + + + com.github.qcloudsms + qcloudsms + 1.0.5 + + + com.alibaba + fastjson + 1.2.62 + + + + + + + + org.springframework.cloud + spring-cloud-dependencies + Finchley.SR2 + pom + import + + + + + + + \ No newline at end of file diff --git a/util/pom.xml b/util/pom.xml new file mode 100644 index 0000000..b805426 --- /dev/null +++ b/util/pom.xml @@ -0,0 +1,57 @@ + + + + ccsens_dh + com.ccsens + 1.0-SNAPSHOT + + 4.0.0 + + util + + + org.aspectj + aspectjrt + + + + + org.xhtmlrenderer + flying-saucer-pdf + 9.1.19 + + + com.itextpdf + itextpdf + 5.5.13.1 + + + com.itextpdf + itext-asian + 5.2.0 + + + + net.glxn.qrgen + javase + 2.0 + + + + com.aliyun.api.gateway + sdk-core-java + 1.1.6 + + + + javax.mail + mail + 1.5.0-b01 + + + + + + \ No newline at end of file diff --git a/util/src/main/java/com/ccsens/util/Base64FileUtil.java b/util/src/main/java/com/ccsens/util/Base64FileUtil.java new file mode 100644 index 0000000..cf06e56 --- /dev/null +++ b/util/src/main/java/com/ccsens/util/Base64FileUtil.java @@ -0,0 +1,46 @@ +package com.ccsens.util; + +import cn.hutool.core.codec.Base64; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.util.Random; + +/** + * @description: + * @author: wuHuiJuan + * @create: 2019/12/17 17:48 + */ +public class Base64FileUtil { + + /** + * 将base64字符串转换成文件 + * @param base64 + * @param path + * @param visitPath 访问路径(无文件名) + * @return 返回文件访问路径(无域名) + * @throws Exception + */ + public static String base64ToFile(String base64, String path, String visitPath) throws Exception { + //获取后缀 data:image/png;base64,xxxxxx + String suffix = base64.substring(base64.indexOf("/")+1, base64.indexOf(";")); + Random random = new Random(); + String randomStr = String.valueOf(System.currentTimeMillis()) + random.nextInt(100) + "." + suffix; + String fileName = visitPath + randomStr; + File file = new File(path + fileName); + if (!file.getParentFile().exists()) { + file.getParentFile().mkdirs(); + } + // 截取base64,后面的字符串 + String base64flag = "base64,"; + int index = base64.indexOf(base64flag); + String str = index < 0 ? base64 : base64.substring(index + base64flag.length()); + byte[] decode = Base64.decode(str); + FileOutputStream out = new FileOutputStream(file); + out.write(decode); + out.close(); + return fileName; + } + +} diff --git a/util/src/main/java/com/ccsens/util/BeanWrapperUtil.java b/util/src/main/java/com/ccsens/util/BeanWrapperUtil.java new file mode 100644 index 0000000..4a96eac --- /dev/null +++ b/util/src/main/java/com/ccsens/util/BeanWrapperUtil.java @@ -0,0 +1,50 @@ +package com.ccsens.util; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.collection.CollectionUtil; + +import java.util.ArrayList; +import java.util.List; + +public class BeanWrapperUtil { + + public static T warpVoToObj(V userVo,Class tClazz){ + if(userVo == null) + return null; + T user = null; + try { + user = tClazz.newInstance(); + BeanUtil.copyProperties(userVo,user); + } catch (InstantiationException e) { + e.printStackTrace(); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } + return user; + } + + public static V warpObjToVo(T user,Class vClass){ + if(user == null) + return null; + V userVo = null; + try { + userVo = vClass.newInstance(); + } catch (InstantiationException e) { + e.printStackTrace(); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } + BeanUtil.copyProperties(user,userVo); + return userVo; + } + + public static List warpObjToVo(List userList,Class vClass){ + if(CollectionUtil.isEmpty(userList)) + return null; + List userVoList = new ArrayList<>(); + for(T user: userList) { + userVoList.add(warpObjToVo(user,vClass)); + } + return userVoList; + } +} diff --git a/util/src/main/java/com/ccsens/util/CRCUtil.java b/util/src/main/java/com/ccsens/util/CRCUtil.java new file mode 100644 index 0000000..94a41ba --- /dev/null +++ b/util/src/main/java/com/ccsens/util/CRCUtil.java @@ -0,0 +1,52 @@ +package com.ccsens.util; + +import lombok.extern.slf4j.Slf4j; + +@Slf4j +public class CRCUtil { + public static void crc16(byte crc[], byte data[], int index, int len) { + for (int i = 0; i < len; i++) { + log.info("发送数据:{}",Integer.toHexString(data[i] & 0xFF)); + } + // 预置16位crc寄存器,初值全部为1 + int wcrc = 0xFFFF; + // 定义中间变量 + int temp; + // 定义计数 + int i = 0, j = 0, k = index; + // 循环计算每个数据 + for (i = 0; i < len; i++) + { + // 将八位数据与crc寄存器亦或 + temp = (data[k] & 0xFF); + // 指针地址增加,指向下个数据 + k++; + // 将数据存入crc寄存器 + wcrc ^= temp; + // 循环计算数据的 + for (j = 0; j < 8; j++) + { + // 判断右移出的是不是1,如果是1则与多项式进行异或。 + if ((wcrc & 0x0001) == 1) + { + // 先将数据右移一位 + wcrc >>= 1; + // 与上面的多项式进行异或 + wcrc ^= 0XA001; + } else// 如果不是1,则直接移出 + { + // 直接移出 + wcrc >>= 1; + } + } + } + // crc的值 + temp = wcrc; + // crc的低八位 + crc[0] = (byte)(wcrc & 0xFF); + // crc的高八位 + crc[1] = (byte)((wcrc >> 8) & 0xFF); + } + + +} diff --git a/util/src/main/java/com/ccsens/util/CodeEnum.java b/util/src/main/java/com/ccsens/util/CodeEnum.java new file mode 100644 index 0000000..09ed0e7 --- /dev/null +++ b/util/src/main/java/com/ccsens/util/CodeEnum.java @@ -0,0 +1,318 @@ +package com.ccsens.util; + +import lombok.Getter; + +@Getter +public enum CodeEnum { + /** + * 异常 + */ + SUCCESS(200, "ok", true), + SYS_ERROR(500, "网络繁忙,请您稍后重试", false), + THIRD_ERROR(-1, "调用第三方刚接口异常", false), + + FILE_FORMAT_ERROR(1, "文件格式错误", true), + AUDITED(2, "已经审核通过,不重复提交。", true), + POSITION_NO_FOUND(3, "未找到对应职务,请重新选择职务。", true), + TITLE_NO_FOUND(4, "未找到对应职称,请重新选择职称。", true), + ADMIN_DEAL(5,"由于您的资格太高,请联系管理员进行审核。", true), + PARAM_NULL(6, "请检查您的参数是否填写完整。", true), + ROLE_NOT_FOUND(7, "未找到相关角色,请确认项目和角色信息。", true), + AUDIT_NOT_PASS (8, "对不起,您尚未审核通过,暂时没有操作权限。", true), + PARAM_ERROR(9,"请求参数错误,请确认操作是否正确。", true), + ID_CARD_ERROR(10,"身份证格式错误,请检查身份证填写是否正确。", true), + QUESTION_NOT_FOUND(11,"试题未找到。", true), + + WSB_NOT_PROJECT_HEADER(12,"没有项目信息的表头",true), + WSB_NOT_MEMBER_HEADER(13,"没有项目成员的表头",true), + WSB_NOT_TASK_HEADER(14,"没有项目任务分解的表头",true), + WBS_PROJECT_TIME_ERROR(15,"时间格式异常",true), + WBS_NOT_PROJECT_TIME(16,"项目时间不能为空",true), + WBS_NOT_PROJECT_NAME(17,"项目名称不能为空",true), + WBS_NOT_PROJECT(17,"找不到项目信息",true), + WBS_NOT_MEMBER_SHEET(18,"未找到项目成员表",true), + WBS_NOT_PHONE(19,"手机号为空",true), + WBS_PHONE_ERROR(19,"手机号格式错误",true), + WBS_STAKEHOLDER_PHONE(20,"奖惩干系人和手机号不匹配",true), + WBS_STAKEHOLDER_PHONE_NOT_FOUND(20,"请填写奖惩干系人手机号",true), + WBS_REPEAT_MEMBER_PHONE(21,"成员名或手机号与其他人重复",true), + WBS_NOT_FIRST_ROLE(22,"系统角色名称错误",true), + WBS_REPEAT_ROLE_NAME(23,"角色名称重复",true), + WSB_NOT_MEMBER(24,"未找到对应成员", true), + WBS_NOT_FIND_ROLE(25,"未找到对应的角色,请检查对谁不可见一列的名字与格式",true), + WBS_NOT_TASK_NAME(26,"任务名不能为空",true), + WBS_NOT_FIND_EXECUTOR_ROLE(27,"找不到负责人,请检查负责人的名称",true), + WBS_NOT_FIND_CHECKER_ROLE(28,"找不到检查人,请检查检查人的名称",true), + WBS_DELAY_ERROR(29,"任务切换模式填写错误",true), + WBS_SUB_TASK_ANALYSIS(30,"无法解析此子日程表",true), + WBS_NOT_SUB_TASK(31,"找不到对应的子表,请检查子表的名字是否正确",true), + WBS_NOT_PLUGIN_SHEET(32,"未找到插件表",true), + WBS_NOT_PLUGIN(33,"未找到对应的插件,请确认是否填写正确",true), + PROJECT_DATE_FORMAT_ERROR(34,"输入的日期格式错误,有效日期格式 例:2019-01-01或2019-01",true), + TASK_NOT_UPLOAD_DELIVER(35,"交付物未上传,无法完成任务",true), + NOT_PROJECT(36,"对不起,找不到该项目",true), + NOT_ROLE(37,"对不起,找不到该角色",true), + NOT_DELIVER(38,"对不起,找不到对应的交付物",true), + NOT_TASK(39,"找不到对应的任务",true), + NOT_DELIVER_FILE(40,"文件信息错误,请重试",true), + IS_NOT_EXECUTOR(41,"对不起,您不是该任务负责人",true), + NOT_CHECKER(42,"请选择检查人",true), + SUB_TASK_IS_NOT_FINISH(43,"分组内任务未全部完成,无法完成任务",true), + IS_NOT_CHECKER(44,"您不是该交付物的检查人",true), + NOT_POWER(45,"对不起,您的权限不足,无法进行此操作",true), + SMS_CODE_CORRECT(46,"请输入正确验证码",true), + + QUESTION_RULE_NOT_FOUND(47,"该评测规则未知,请联系开发人员。", true), + REPORT_DOCTOR_ERROR(48, "对不起,您没有修改报告单结果的权限。", true), + NOT_LOGIN(49, "对不起,您尚未登录或登录已失效,请重新登录。", true), + POSITION_NOT_3(50, "对不起,您尚未选择职务,请重新选择。", true), + + REPEAT_PROJECT_NAME(51,"项目名不能重复,请修改后重试",true), + TIME_ERROR_BEGIN(52,"时间异常,开始时间不能大于结束时间",true), + TIME_ERROR_PROJECT(53,"时间异常,任务的时间不能超出项目的时间",true), + HAS_GROUP_TIME_CHANGE(54,"分组任务不能直接修改时间,请修改其子任务时间",true), + DOCTOR_NOT_SUBMIT(55,"尚未进行资格认证",true), + REPORT_NOT_FOUND(56,"对不起,没有找到您查询的报告单,请确认报告单是否存在。",true), + PATIENT_NOT_CHOICE(57,"没有选择病人,不进行保存答案。", true), + + NOT_GAME_TYPE(58,"对不起,未找到对应的游戏",true), + SIGNIN_REPEAT(59,"请勿重复签到",true), + SCORE_REPEAT(60,"您已经评分,请勿重复提交",true), + NOT_MEMBER(61,"对不起,找不到对应的成员信息",true), + NOT_GAME_RECORD(62,"对不起,找不到对应的游戏场次",true), + NOT_JOIN_GAME(63,"您还未加入游戏,请参加游戏后再试",true), + + GAME_NO_END(64,"您的上一场游戏尚未结束,请勿重复开启",true), + GAME_NOT_TIMES(65,"游戏可玩次数不足,请充值后重试",true), + + GAME_PENDING(66, "游戏尚未开始,请等待主持人开始", true), + GAME_PREPARATION(67, "游戏已经开始倒计时了", true), + GAME_PROCESSING (68, "游戏已经在火热进行啦", true), + GAME_COMPLETED(69, "抱歉,您来晚了,游戏已结束", true), + NOT_REGISTER(70,"该手机号尚未注册账号",true), + PHONE_ERR(71,"请输入正确的手机号",true), + NOT_SELECT_WX(72,"未查到对应的微信信息",true), + ALREADY_EXIST_PHONE(73,"手机号已存在",true), + ALREADY_BINDING_PHONE(74,"您已绑定过手机号,请勿重复绑定",true), + MERGE_WX_PHONE(75,"该手机号已经注册过账号,是否将账号合并",true), + ALREADY_EXIST_ACCOUNT(76,"该账号已存在",true), + NOT_SIGN_FIELD(77,"签到的字段不可用",true), + ALREADY_SIGN(78,"您已经签到过了,请勿重复签到",true), + ALREADY_ATTENTION(79,"您已经关注了这个项目",true), + NOT_EMPLOYEE(80,"未找到成员信息",true), + NOT_SITE(81,"未找到该场所",true), + ALREADY_REAL_AUTH(82,"您已经完成认证",true), + LACK_CONFIG(83,"缺少配置",true), + ANIMAL_HEAT_ERROR(84,"体温异常,请选择正确的健康状态",true), + NOT_BUSINESS(85,"未找到商户信息",true), + SITE_EXCEED(86,"您所添加的场所数量已超出上限,请联系客服提高场所上限",true), + SITE_NAME_REPETITION(86,"场所名重复",true), + LOCATION_LONG(87,"对不起,您的距离太远了,请靠近目的地或打开定位后重试。",true), + NO_IMPORT_DATA(88,"没有有效的数据,请检查您的导入文件。",true), + FILL_ERROR(89,"您的信息填写有误,请检查您的信息。",true), + ACCOUNT_BIND(90,"您的帐号已经绑定了,请重新进入小程序。",true), + RECORDER_NOT(91, "对不起,您不是该信息的录入者,不能修改信息。", true), + REPORT_HAD_COMPLETED(92, "报告单已经完成,不能再修改答题记录。", true), + NOT_REAL_AUTH(93,"您尚未填写基本信息,请补全信息后再试。",true), + HEALTH_TYPE_ERROR(94,"您的健康状态异常,打卡失败。",true), + NOT_HEALTH_RECORD(95,"您今天还未上报健康信息,请上报后再试。",true), + SELECT_TIME_ERROR(96,"请输入正确的查询时间",true), + + TASK_PREPARATION(97,"任务已经开始了,请勿重复操作",true), + NOT_COMMENT(98,"该评论不存在",true), + NOT_MESSAGE_TYPE(99,"找不到消息类型,请检查名称是否正确",true), + + NOT_LABEL(100,"标签不存在,请检查后操作",true), + REPEAT_LABEL(101,"标签已存在,请勿重复添加",true), + + NICKNAME_REPEAT(102,"该名字已经存在,请换一个再试",true), + NEW_PASSWORD_REPEAT_OLD(103,"新密码不能和旧密码相同",true), + PASSWORD_ERROR(104,"用户名或密码错误",true), + NOT_ACCOUNT(105,"未找到该账号",true), + + FILE_NOT_FOUND(106,"未找到对应的文件,请检查后操作",true), + SIGNATURE_FAIL(107,"签名验证失败",true), + + NOT_UNIT(108,"时间单位不能为空",true), + NOT_USER(109,"用户不存在",true), + VERIFICATION_CODE_PAST(110,"验证码失效,请刷新重试",true), + VERIFICATION_CODE_PAST_IMG(110,"图形验证码失效,请刷新重试",true), + VERIFICATION_CODE_ERROR(111,"验证码错误",true), + VERIFICATION_CODE_ERROR_IMG(111,"图形验证码错误",true), + NOT_ROW(112,"该行不存在",true), + VOTED(113,"对不起,您已经支持过看好的队伍了",true), + + NOT_TOPIC(114,"找不到该题目",true), + NOT_GROUP(115,"找不到该组信息",true), + VOTE_COMPLETED(116,"投票已结束",true), + VOTE_NOT_START(117,"投票未开始",true), + NOT_CONFIG_OR_ERR(118,"缺少配置信息,或配置信息异常",true), + GROUP_MEMBER_LIMIT(119,"当前组内人员已满,请选择其他组",true), + GROUP_NOT_CHOICE(120,"请选择要加入的队伍",true), + JOINED_TEAM(121,"您已经加入队伍,无需重复加入",true), + TEAM_MEMBER_MORE(122,"加入队伍的人数已经达到上限,请选择其他队伍",true), + TEAM_COMPANY_NOT_SAME(123,"对不起,您和团队其他人不是同一个单位的", true), + TEAM_GROUP_NOT_SAME(124,"对不起,您和团队其他人不是同一个组别的", true), + BASE_INFO_LACK(125,"请先填写您的基本信息", true), + JOINED_MORE(126,"该类型比赛您参赛的数目已达上限", true), + JOINED_SAME(127,"您已经参加同类型的比赛了,不能再重复参加参赛", true), + PLAYER_INFO_ALREADY(127,"您已经有了报名信息,请不要重复提交", true), + + GAME_TIME_DUE(128,"您的游戏已到期,请重新购买", true), + TEAM_MEMBER_ERROR(129,"参赛人数不符合,请重新填写", true), + SIGN_UP_TIME_NOT_START(130,"报名未开始", true), + SIGN_UP_TIME_FINISHED(131,"报名已结束", true), + + PROJECT_IMITATION_NO(132,"该项目未开启变身系统", true), + PROJECT_IMITATION_CODE_ERROR(131,"秘钥错误", true), + + DINGDING_EXCEPTION(132,"钉钉接口调用异常。",true), + URL_ERROR(133, "请求路径转换异常", true), + + JOIN_PROJECT_NUM_FULL(134, "可参赛次数已满", true), + PHOTO_FILE_EXCEED_2M(135, "图片大小不能超过2M", true), + COACH_NUM_FULL(136,"教练人数已达上限",true), + LEADER_NUM_FULL(137,"领队人数已达上限",true), + AUTHORIZATION_AGREE(138,"请阅读并同意安全责任书",true), + NAME_EMPTY(139,"单位名称不能为空",true), + PHOTO_IS_EMPTY(140,"请上传证件照",true), + ID_CARD_ALREADY(141,"此身份证已注册",true), + NOT_COMPANY(142,"请先填写基础信息",true), + MT_NOT_GROUP(143,"请选择正确的组别信息",true), + CONTACTS_NAME_EMPTY(144,"联系人名称不能为空",true), + MEMBER_NUM_ERROR(145,"参赛人数不满足比赛人数要求",true), + GENDER_ERROR(146,"请选择正确的性别",true), + JOIN_AUTH_GROUP(147,"已参加了其他组别,无法再次报名",true), + ALREADY_JOIN_PROJECT(148,"该选手已经参加了比赛,不可修改身份证组别等信息",true), + ALREADY_JOIN_PROJECT_DEL(149,"取消报名后可删除",true), + ALREADY_UPLOAD_VIDEO(150,"您已经上传了视频,请勿重复提交",true), + ALREADY_UPLOAD_FORM(151,"请勿重复提交信息",true), + MESSAGEISNULL(152,"数据为空",true), + QUANTITYERROR(153,"住院号不正确",true), + NOT_HOSPITAL(154,"未找到医院信息",true), + ZHUYUANIDCHONGFU(155,"患者研究编号重复",true), + MEIYOUGAIYISHENG(156,"该医生信息查询不正确",true), + QINGTIJIAOSHITI(157,"未做出修改答案,修改后再提交",true), + DOC_REPEAT(158,"输入文档已存在",true), + DOC_NONE(161,"输入文档不存在",true), + NOTNAME(159,"未找到该列",true), + CHONGFU(160,"该成员在项目下有多个成员角色",true), + CHAOGUOSHI(161,"角色展示不能超过10个",true), + BAOHANJINLI(162,"不能删除包含经理得角色",true), + CHONGFUTIJIAO(163,"不要重复提交",true), + ZUISHAOCHUANLIANGE(164,"排序最少需要传入两个",true), + HOSPITAL_NOT_FOUND(165,"没有找到医院",true), + NOT_FOUND_PM(166,"系统角色缺少项目经理",true), + NOT_FOUND_MEMBER(167,"系统角色缺少项目成员",true), + NOT_SUPPORT_CYCLE(168,"重复规则文本格式暂不支持",true), + WBS_TASK_START_TIME_ERROR(168,"任务开始时间格式错误,请检查后操作",true), + WBS_TASK_END_TIME_ERROR(169,"任务结束时间格式错误,请检查后操作",true), + CANNOT_DELETE_PM(170,"无法删除项目经理",true), + LABEL_TOO_LONG(171,"标签长度过长,请不要超过六个字",true), + WBS_PROJECT_NAME_REPEAT(172,"项目名称不能重复",true), + DELIVER_REPEAT(173,"交付物已存在",true), + PARENT_PROJECT_NOT_MATCHING(174,"父任务与项目不匹配",true), + PM_NOT_MEMBER(175,"项目经理下必须有一个成员",true), + WisdomCar_NOT_Found(176,"没有找到绑定的平车信息",true), + WISDOM_CAR_RUNNED(177,"这段时间内平车正在运行,请结束平车运行或重新选择平车",true), + WISDOM_CAR_IS_EXIST(178,"平车不存在,请检查后操作",true), + TASK_IS_EXIST(179,"任务不存在,请检查后操作",true), + PATIENT_PROJECT_REPEAT(180,"已创建该患者的病例,请不要重复操作",true), + //TALL3 + PROJECT_REGION_NO_SAME(181,"项目域不同无法进行操作",true), + NO_POWER(182,"权限不足",true), + DATA_DECRYPTION(183,"解密失败,数据可能遭受到破坏,操作取消。",true), + NOT_TEMPLATE(183,"找不到对应的模板信息",true), + DELETE_PROJECT_ERROR(184,"删除项目失败",true), + ; + + + public CodeEnum mtMsgPhoto(String msg){ + this.msg = "请上传"+msg; + return this; + } + public static String mtJoinAuthGroup(String msg){ + msg = msg+"已参加了其他组别,无法再次报名"; + return msg; + } + public static String mtCertificate(String msg){ + msg = msg+"未同时报名“30秒单摇跳”和“3分钟单摇跳”"; + return msg; + } + public static String mtCertificateJoin(String msg){ + msg = msg+"已报名“速度通级赛”无法取消当前项目"; + return msg; + } + public CodeEnum mtProjectMsg(String msg){ + this.msg = msg+"项目参赛次数已满"; + return this; + } + public CodeEnum mtProjectMsg1(String msg){ + this.msg = msg+"报名人数已满"; + return this; + } + + + public CodeEnum addMsg(String msg){ + if(this.msg.contains("错误:")){ + this.msg = this.msg.substring(this.msg.indexOf("错误:") + 3); + } + this.msg = msg+"--错误:"+this.msg; + return this; + } + + + public CodeEnum addMsg(String sheetName,Integer rowNum){ + if(this.msg.contains("错误:")){ + this.msg = this.msg.substring(this.msg.indexOf("错误:") + 3); + } + this.msg = sheetName+"第"+rowNum+"行--错误:"+this.msg; + return this; + } + public CodeEnum addMsg(String sheetName,Integer rowNum,String value){ + if(this.msg.contains("错误:")){ + this.msg = this.msg.substring(this.msg.indexOf("错误:") + 3); + } + this.msg = sheetName+"第"+rowNum+"行["+value+"]--错误:"+this.msg; + return this; + } + + + + public CodeEnum addMsgAndMemberName(String msg,String memberName){ + this.msg = msg+"行:成员["+memberName+"]"+this.msg; + return this; + } + public CodeEnum addMsgAndNoLookName(String msg,String noLookName){ + this.msg = msg+"行:对谁不可见成员["+noLookName+"]"+this.msg; + return this; + } + + + public CodeEnum addMsgLwb(String msg) { + this.msg = "未找到名为“"+msg+"”的列,请检查列名称是否正确"; + return this; + } + public static CodeEnum getByCode(int code) { + for (CodeEnum codeEnum: CodeEnum.values()) { + if (codeEnum.getCode() == code) { + return codeEnum; + } + } + return null; + } + + private CodeEnum(Integer code, String msg, boolean success) { + this.code = code; + this.msg = msg; + this.success = success; + } + private Integer code; + private String msg; + private boolean success; + + public void setMsg(String msg) { + this.msg = msg; + } +} + diff --git a/util/src/main/java/com/ccsens/util/CodeError.java b/util/src/main/java/com/ccsens/util/CodeError.java new file mode 100644 index 0000000..903c10b --- /dev/null +++ b/util/src/main/java/com/ccsens/util/CodeError.java @@ -0,0 +1,54 @@ +package com.ccsens.util; + +import lombok.Getter; + +/** + * @author 逗 + */ +public class CodeError { + + public static final Code SUCCESS = new Code(200, "ok", true); + public static final Code SYS_ERROR = new Code(500, "网络繁忙,请您稍后重试", false); + public static final Code THIRD_ERROR = new Code(-1, "调用第三方刚接口异常", false); + public static final Code PARAM_ERROR = new Code(1, "参数异常", false); + public static final Code PARAM_LOCK = new Code(2, "必填参数为空", false); + + @Getter + public static class Code{ + private Integer code; + private String msg; + private boolean success; + + public Code(Integer code, String msg, boolean success) { + this.code = code; + this.msg = msg; + this.success = success; + } + + + public Code addMsg(String msg){ + if(this.msg.contains("错误:")){ + this.msg = this.msg.substring(this.msg.indexOf("错误:") + 3); + } + this.msg = msg+"--错误:"+this.msg; + return this; + } + + public Code addMsg(String sheetName,Integer rowNum){ + if(this.msg.contains("错误:")){ + this.msg = this.msg.substring(this.msg.indexOf("错误:") + 3); + } + this.msg = sheetName+"第"+rowNum+"行--错误:"+this.msg; + return this; + } + + public Code addMsg(String sheetName,Integer rowNum,String value){ + if(this.msg.contains("错误:")){ + this.msg = this.msg.substring(this.msg.indexOf("错误:") + 3); + } + this.msg = sheetName+"第"+rowNum+"行["+value+"]--错误:"+this.msg; + return this; + } + } + +} diff --git a/util/src/main/java/com/ccsens/util/DateUtil.java b/util/src/main/java/com/ccsens/util/DateUtil.java new file mode 100644 index 0000000..0e6fbd9 --- /dev/null +++ b/util/src/main/java/com/ccsens/util/DateUtil.java @@ -0,0 +1,180 @@ +package com.ccsens.util; + +import cn.hutool.core.util.StrUtil; +import com.ccsens.util.exception.BaseException; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.*; + +public class DateUtil extends cn.hutool.core.date.DateUtil { + /**年月日时分秒*/ + public static final String yyyyMMddHHmmss="yyyyMMddHHmmss"; + /**年月日*/ + public static final String yyyyMMdd="yyyyMMdd"; + + /** + * 时间格式转换 + * @param date date + * @param format 格式 + * @return 时间字符串 + */ + public static String format(Date date, String format) { + SimpleDateFormat sdf = new SimpleDateFormat(format); + return sdf.format(date); + } + + public static Long dateBeginSeconds(Long seconds){ + if(seconds == null) { + seconds = currentSeconds(); + } + return (seconds - (seconds + TimeZone.getDefault().getRawOffset()/1000 )% (3600*24)); + } + + public static Date getYMD(Date date) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + Date ymd = null; + try { + ymd = sdf.parse(sdf.format(date)); + } catch (ParseException e) { + e.printStackTrace(); + } + return ymd; + } + + public static Long dateEndSeconds(Long seconds){ + return dateBeginSeconds(seconds) + (3600 * 24 - 1); + } + + public static Long str2MillSeconds(String str){ + long num = 0; + if(StrUtil.isNotEmpty(str)){ + for(int i=0;i= '0' && str.charAt(i)<='9'){ + num = num * 10 + str.charAt(i) - '0'; + } + } + } + + if(str.contains("年")){ + num = num * 3600 * 24 * 30 * 12; + }else if(str.contains("月")){ + num = num * 3600 * 24 * 30; + }else if(str.contains("日") || str.contains("天")){ + num = num * 3600 * 24; + }else if(str.contains("时")){ + num = num * 3600; + }else if(str.contains("分")){ + num = num * 60; + }else if(str.contains("秒")){ + num = num * 1; + } + + num *= 1000; + + return num; + } + + public static Map projectFormatDateTime(String date) throws Exception { + Map timeMap = new HashMap<>(); + //获取日期的开始结束时间 + Long startMillisTime = null, endMillisTime = null; + String[] dateFormattedPart = null; + String formattedDate = projectFormatDate(date); + if (formattedDate != null) { + dateFormattedPart = formattedDate.split(","); + } else { + throw new BaseException(CodeEnum.PROJECT_DATE_FORMAT_ERROR); + } + if (dateFormattedPart != null) { + String beginDate = dateFormattedPart[0]; + String endDate = dateFormattedPart[1]; + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss SSS"); + Date startDate = sdf.parse(beginDate); + Date finishDate = sdf.parse(endDate); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(startDate); + startMillisTime = calendar.getTimeInMillis(); + calendar.setTime(finishDate); + endMillisTime = calendar.getTimeInMillis(); + } + timeMap.put("startMillisTime",startMillisTime); + timeMap.put("endMillisTime",endMillisTime); + return timeMap; + } + public static String projectFormatDate(String date) { + String[] daysOfMonthInCommonYear = {"31", "28", "31", "30", "31", "30", "31", "31", "30", "31", "30", "31"}; + String[] daysOfMonthInLeapYear = {"31", "29", "31", "30", "31", "30", "31", "31", "30", "31", "30", "31"}; + + int dateLength = date.length(); + String beginTime = " 00:00:00 000"; + String endTime = " 23:59:59 999"; + String beginDateTime = null; + String endDateTime = null; + if (!isDateValid(date)) { + return null; + } else { + if (dateLength == 4) { + beginDateTime = date + "-01-01" + beginTime; + endDateTime = date + "-12-31" + endTime; + } else if (dateLength > 4 && dateLength <= 7) { + beginDateTime = date + "-01" + beginTime; + String yearStr = date.substring(0, 4); + String montStr = date.substring(5, dateLength); + int year = Integer.parseInt(yearStr); + int month = Integer.parseInt(montStr); + if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0) { + endDateTime = date + "-" + daysOfMonthInLeapYear[month - 1] + endTime; + } else { + endDateTime = date + "-" + daysOfMonthInCommonYear[month - 1] + endTime; + } + } else if (dateLength > 7 && dateLength <= 10) { + beginDateTime = date + beginTime; + endDateTime = date + endTime; + } + } + return beginDateTime + "," + endDateTime; + } + private static boolean isDateValid(String date) { + int dateLength = date.length(); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + if (dateLength < 4) { + return false; + } + else if (dateLength == 4) { + date = date + "-01-01"; + } else if (dateLength > 4 && dateLength <= 7) { + date = date + "-01"; + } else if (dateLength > 10) { + return false; + } + try { + Date realDate = sdf.parse(date); + } catch (ParseException e) { + e.printStackTrace(); + return false; + } + return true; + } + + /** + * 获取某天零点的时间戳 + */ + public static Long getZeroTime(Date date) throws Exception{ + Calendar calendar = Calendar.getInstance(); + calendar.setTime(new Date()); + calendar.set(Calendar.HOUR_OF_DAY, 0); + calendar.set(Calendar.MINUTE, 0); + calendar.set(Calendar.SECOND, 0); + calendar.set(Calendar.MILLISECOND, 0); + return calendar.getTime().getTime(); + } + +// public static void main(String[] args) throws Exception { +// DateTime endTime = cn.hutool.core.date.DateUtil.endOfDay(new Date()); +// DateTime beginTime = cn.hutool.core.date.DateUtil.beginOfDay(new Date()); +// System.out.println(endTime); +// System.out.println(beginTime); +// } + +} diff --git a/util/src/main/java/com/ccsens/util/DesensitizedUtils.java b/util/src/main/java/com/ccsens/util/DesensitizedUtils.java new file mode 100644 index 0000000..01999f9 --- /dev/null +++ b/util/src/main/java/com/ccsens/util/DesensitizedUtils.java @@ -0,0 +1,118 @@ +package com.ccsens.util; + +import org.apache.commons.lang3.StringUtils; +/** + * 数据脱敏工具类 + * + * @author ma + * @date 2017/10/25 + */ +public class DesensitizedUtils { + /** + * 【中文姓名】只显示第一个汉字,其他隐藏为2个星号,比如:李** + * + * @param fullName + * @return + */ + public static String chineseName(String fullName) { + if (StringUtils.isBlank(fullName)) { + return ""; + } + String name = StringUtils.left(fullName, 1); + return StringUtils.rightPad(name, StringUtils.length(fullName), "*"); + } + /** + * 【身份证号】显示最后四位,其他隐藏。共计18位或者15位,比如:*************1234 + * + * @param id + * @return + */ + public static String idCardNum(String id) { + if (StringUtils.isBlank(id)) { + return ""; + } + String num = StringUtils.right(id, 4); + return StringUtils.leftPad(num, StringUtils.length(id), "*"); + } + /** + * 【固定电话】 显示后四位,其他隐藏,比如:*******3241 + * + * @param num + * @return + */ + public static String fixedPhone(String num) { + if (StringUtils.isBlank(num)) { + return ""; + } + return StringUtils.leftPad(StringUtils.right(num, 4), StringUtils.length(num), "*"); + } + /** + * 【手机号码】前三位,后四位,其他隐藏,比如:135****6810 + * + * @param num + * @return + */ + public static String mobilePhone(String num) { + if (StringUtils.isBlank(num)) { + return ""; + } + return StringUtils.left(num, 3).concat(StringUtils.removeStart(StringUtils.leftPad(StringUtils.right(num, 4), StringUtils.length(num), "*"), "***")); + } + /** + * 【地址】只显示到地区,不显示详细地址,比如:上海徐汇区漕河泾开发区*** + * + * @param address + * @param sensitiveSize 敏感信息长度 + * @return + */ + public static String address(String address, int sensitiveSize) { + if (StringUtils.isBlank(address)) { + return ""; + } + int length = StringUtils.length(address); + return StringUtils.rightPad(StringUtils.left(address, length - sensitiveSize), length, "*"); + } + /** + * 【电子邮箱】 邮箱前缀仅显示第一个字母,前缀其他隐藏,用星号代替,@及后面的地址显示,比如:d**@126.com + * + * @param email + * @return + */ + public static String email(String email) { + if (StringUtils.isBlank(email)) { + return ""; + } + int index = StringUtils.indexOf(email, "@"); + if (index <= 1) { + return email; + } else { + return StringUtils.rightPad(StringUtils.left(email, 1), index, "*").concat(StringUtils.mid(email, index, StringUtils.length(email))); + } + } + /** + * 【银行卡号】前六位,后四位,其他用星号隐藏每位1个星号,比如:6222600**********1234 + * + * @param cardNum + * @return + */ + public static String bankCard(String cardNum) { + if (StringUtils.isBlank(cardNum)) { + return ""; + } + return StringUtils.left(cardNum, 6).concat(StringUtils.removeStart(StringUtils.leftPad(StringUtils.right(cardNum, 4), StringUtils.length(cardNum), "*"), "******")); + } + /** + * 【密码】密码的全部字符都用*代替,比如:****** + * + * @param password + * @return + */ + public static String password(String password) { + if (StringUtils.isBlank(password)) { + return ""; + } + String pwd = StringUtils.left(password, 0); + return StringUtils.rightPad(pwd, StringUtils.length(password), "*"); + } + +} diff --git a/util/src/main/java/com/ccsens/util/DistanceUtil.java b/util/src/main/java/com/ccsens/util/DistanceUtil.java new file mode 100644 index 0000000..beaf3da --- /dev/null +++ b/util/src/main/java/com/ccsens/util/DistanceUtil.java @@ -0,0 +1,48 @@ +package com.ccsens.util; + +import lombok.extern.slf4j.Slf4j; + +import java.math.BigDecimal; + +@Slf4j +public class DistanceUtil { + + private static double EARTH_RADIUS = 6378.137; + + private static BigDecimal rad(BigDecimal d) { + return d.multiply(new BigDecimal(Math.PI)).divide(new BigDecimal(180.0),15, BigDecimal.ROUND_DOWN); + } + + /** + * 通过经纬度获取距离(单位:米) + * + * @param lat1 + * @param lng1 + * @param lat2 + * @param lng2 + * @return + */ + public static double getDistance(BigDecimal lat1, BigDecimal lng1, BigDecimal lat2, + BigDecimal lng2) { + log.info("坐标:{},{},{},{}", lat1, lng1, lat2, lng2); + BigDecimal radLat1 = rad(lat1); + BigDecimal radLat2 = rad(lat2); + BigDecimal a = radLat1.subtract(radLat2); + BigDecimal b = rad(lng1).subtract(rad(lng2)); + double s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a.divide(new BigDecimal(2)).doubleValue()), 2) + + Math.cos(radLat1.doubleValue()) * Math.cos(radLat2.doubleValue()) * Math.pow(Math.sin(b.divide(new BigDecimal(2)).doubleValue()), 2))); + s = s * EARTH_RADIUS; + s = Math.round(s * 10000d) / 10000d; + log.info("距离:{}", s); + return s; + } + + /** + * 判断一个点是否在圆形区域内 + */ + public static boolean isInCircle(BigDecimal lng1, BigDecimal lat1, BigDecimal lng2, BigDecimal lat2, String radius) { + log.info("判断距离参数:{},{},{},{},{}", lat1, lng1, lat2, lng2,radius); + return getDistance(lat1, lng1, lat2, lng2) <= Double.parseDouble(radius); + } + +} diff --git a/util/src/main/java/com/ccsens/util/ExcelUtil.java b/util/src/main/java/com/ccsens/util/ExcelUtil.java new file mode 100644 index 0000000..e66f2c1 --- /dev/null +++ b/util/src/main/java/com/ccsens/util/ExcelUtil.java @@ -0,0 +1,105 @@ +package com.ccsens.util; + +import cn.hutool.core.date.DateException; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import org.apache.poi.ss.usermodel.*; +import org.apache.poi.ss.util.NumberToTextConverter; + +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; + +public class ExcelUtil { + //读取每个单元格的信息 +// public static String getCellValue(Cell cell) { +// String ret; +// if(ObjectUtil.isNull(cell)){ +// return ""; +// } +// +// switch (cell.getCellType()) { +// case Cell.CELL_TYPE_BLANK: +// ret = ""; +// break; +// case Cell.CELL_TYPE_BOOLEAN: +// ret = String.valueOf(cell.getBooleanCellValue()); +// break; +// case Cell.CELL_TYPE_ERROR: +// ret = null; +// break; +// case Cell.CELL_TYPE_FORMULA: +// Workbook wb = cell.getSheet().getWorkbook(); +// CreationHelper crateHelper = wb.getCreationHelper(); +// FormulaEvaluator evaluator = crateHelper.createFormulaEvaluator(); +// ret = getCellValue(evaluator.evaluateInCell(cell)); +// break; +// case Cell.CELL_TYPE_NUMERIC: +// if (org.apache.poi.ss.usermodel.DateUtil.isCellDateFormatted(cell)) { +// Date theDate = cell.getDateCellValue(); +// ret = String.valueOf(theDate.getTime()); +// } else { +// ret = NumberToTextConverter.toText(cell.getNumericCellValue()); +// } +// break; +// case Cell.CELL_TYPE_STRING: +// ret = cell.getRichStringCellValue().getString(); +// break; +// default: +// ret = null; +// } +// +// return ret; +// } + + public static String getCellValue(Cell cell) { + String ret; + if(ObjectUtil.isNull(cell)){ + return ""; + } + + switch (cell.getCellTypeEnum()) { + case BLANK: + ret = ""; + break; + case BOOLEAN: + ret = String.valueOf(cell.getBooleanCellValue()); + break; + case ERROR: + ret = null; + break; + case FORMULA: + Workbook wb = cell.getSheet().getWorkbook(); + CreationHelper crateHelper = wb.getCreationHelper(); + FormulaEvaluator evaluator = crateHelper.createFormulaEvaluator(); + ret = getCellValue(evaluator.evaluateInCell(cell)); + break; + case NUMERIC: + if (org.apache.poi.ss.usermodel.DateUtil.isCellDateFormatted(cell)) { + Date theDate = cell.getDateCellValue(); + ret = String.valueOf(theDate.getTime()); + } else { + ret = NumberToTextConverter.toText(cell.getNumericCellValue()); + } + break; + case STRING: + if(StrUtil.isEmpty(cell.getStringCellValue())){ + ret = cell.getStringCellValue(); + break; + } + try { + ret = String.valueOf(cn.hutool.core.date.DateUtil.parse(cell.getStringCellValue()).getTime()); + }catch (DateException e){ + ret = cell.getRichStringCellValue().getString(); + } + break; + default: + ret = null; + } + + return ret; + } + +} diff --git a/util/src/main/java/com/ccsens/util/GenericsUtils.java b/util/src/main/java/com/ccsens/util/GenericsUtils.java new file mode 100644 index 0000000..6b8b90f --- /dev/null +++ b/util/src/main/java/com/ccsens/util/GenericsUtils.java @@ -0,0 +1,287 @@ +package com.ccsens.util; + +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; + +import javax.servlet.http.HttpSession; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.lang.reflect.ParameterizedType; +import java.lang.reflect.Type; +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +/** + * 泛型工具类 + * + * @author ShunLi + * @notes Created on 2010-1-21
+ * Revision of last commit:$Revision: 1.1 $
+ * Author of last commit:$Author: ghp $
+ * Date of last commit:$Date: 2010-01-25 16:48:17 +0800 (周一, 25 一月 2010) + * $
+ *

+ */ +public class GenericsUtils { + /** + * 通过反射,获得指定类的父类的泛型参数的实际类型. 如BuyerServiceBean extends DaoSupport + * + * @param clazz + * clazz 需要反射的类,该类必须继承范型父类 + * @param index + * 泛型参数所在索引,从0开始. + * @return 范型参数的实际类型, 如果没有实现ParameterizedType接口,即不支持泛型,所以直接返回 + * Object.class + */ + public static Class getSuperClassGenricType(Class clazz, int index) { + Type genType = clazz.getGenericSuperclass();// 得到泛型父类 + // 如果没有实现ParameterizedType接口,即不支持泛型,直接返回Object.class + if (!(genType instanceof ParameterizedType)) { + Type genTypeArray[] = clazz.getGenericInterfaces(); + boolean isParameterizedType = false; + for(Type tmpGenType : genTypeArray){ + if(tmpGenType instanceof ParameterizedType) { + genType = tmpGenType; + isParameterizedType = true; + break; + } + } + if(isParameterizedType == false) { + return Object.class; + } + } + // 返回表示此类型实际类型参数的Type对象的数组,数组里放的都是对应类型的Class, 如BuyerServiceBean extends + // DaoSupport就返回Buyer和Contact类型 + Type[] params = ((ParameterizedType) genType).getActualTypeArguments(); + if (index >= params.length || index < 0) { + throw new RuntimeException("你输入的索引" + (index < 0 ? "不能小于0" : "超出了参数的总数")); + } + if (!(params[index] instanceof Class)) { + return Object.class; + } + return (Class) params[index]; + } + + /** + * 通过反射,获得指定类的父类的第一个泛型参数的实际类型. 如BuyerServiceBean extends DaoSupport + * + * @param clazz + * clazz 需要反射的类,该类必须继承泛型父类 + * @return 泛型参数的实际类型, 如果没有实现ParameterizedType接口,即不支持泛型,所以直接返回 + * Object.class + */ + @SuppressWarnings("unchecked") + public static Class getSuperClassGenricType(Class clazz) { + return getSuperClassGenricType(clazz, 0); + } + + /** + * 通过反射,获得方法返回值泛型参数的实际类型. 如: public Map getNames(){} + * + * @param method 方法 + * @param index 泛型参数所在索引,从0开始. + * @return 泛型参数的实际类型, 如果没有实现ParameterizedType接口,即不支持泛型,所以直接返回 + * Object.class + */ + @SuppressWarnings("unchecked") + public static Class getMethodGenericReturnType(Method method, int index) { + Type returnType = method.getGenericReturnType(); + if (returnType instanceof ParameterizedType) { + ParameterizedType type = (ParameterizedType) returnType; + Type[] typeArguments = type.getActualTypeArguments(); + if (index >= typeArguments.length || index < 0) { + throw new RuntimeException("你输入的索引" + (index < 0 ? "不能小于0" : "超出了参数的总数")); + } + return (Class) typeArguments[index]; + } + return Object.class; + } + + /** + * 通过反射,获得方法返回值第一个泛型参数的实际类型. 如: public Map getNames(){} + * + * @param method 方法 + * @return 泛型参数的实际类型, 如果没有实现ParameterizedType接口,即不支持泛型,所以直接返回 + * Object.class + */ + @SuppressWarnings("unchecked") + public static Class getMethodGenericReturnType(Method method) { + return getMethodGenericReturnType(method, 0); + } + + /** + * 通过反射,获得方法输入参数第index个输入参数的所有泛型参数的实际类型. 如: public void add(Map maps, List names){} + * + * @param method 方法 + * @param index 第几个输入参数 + * @return 输入参数的泛型参数的实际类型集合, 如果没有实现ParameterizedType接口,即不支持泛型,所以直接返回空集合 + */ + @SuppressWarnings("unchecked") + public static List getMethodGenericParameterTypes(Method method, int index) { + List results = new ArrayList(); + Type[] genericParameterTypes = method.getGenericParameterTypes(); + if (index >= genericParameterTypes.length || index < 0) { + throw new RuntimeException("你输入的索引" + (index < 0 ? "不能小于0" : "超出了参数的总数")); + } + Type genericParameterType = genericParameterTypes[index]; + if (genericParameterType instanceof ParameterizedType) { + ParameterizedType aType = (ParameterizedType) genericParameterType; + Type[] parameterArgTypes = aType.getActualTypeArguments(); + for (Type parameterArgType : parameterArgTypes) { + Class parameterArgClass = (Class) parameterArgType; + results.add(parameterArgClass); + } + return results; + } + return results; + } + + /** + * 通过反射,获得方法输入参数第一个输入参数的所有泛型参数的实际类型. 如: public void add(Map + * maps, List names){} + * + * @param method 方法 + * @return 输入参数的泛型参数的实际类型集合, 如果没有实现ParameterizedType接口,即不支持泛型,所以直接返回空集合 + */ + @SuppressWarnings("unchecked") + public static List getMethodGenericParameterTypes(Method method) { + return getMethodGenericParameterTypes(method, 0); + } + + /** + * 通过反射,获得Field泛型参数的实际类型. 如: public Map names; + * + * @param field 字段 + * @param index 泛型参数所在索引,从0开始. + * @return 泛型参数的实际类型, 如果没有实现ParameterizedType接口,即不支持泛型,所以直接返回 + * Object.class + */ + @SuppressWarnings("unchecked") + public static Class getFieldGenericType(Field field, int index) { + Type genericFieldType = field.getGenericType(); + + if (genericFieldType instanceof ParameterizedType) { + ParameterizedType aType = (ParameterizedType) genericFieldType; + Type[] fieldArgTypes = aType.getActualTypeArguments(); + if (index >= fieldArgTypes.length || index < 0) { + throw new RuntimeException("你输入的索引" + (index < 0 ? "不能小于0" : "超出了参数的总数")); + } + return (Class) fieldArgTypes[index]; + } + return Object.class; + } + + /** + * 通过反射,获得Field泛型参数的实际类型. 如: public Map names; + * + * @param field 字段 + * @return 泛型参数的实际类型, 如果没有实现ParameterizedType接口,即不支持泛型,所以直接返回 + * Object.class + */ + @SuppressWarnings("unchecked") + public static Class getFieldGenericType(Field field) { + return getFieldGenericType(field, 0); + } + /** + * 根据实体得到实体的所有属性 + * @param objClass + * @return + * @throws ClassNotFoundException + */ + public static String[] getColumnNames(String objClass) throws ClassNotFoundException { + String[] wageStrArray = null; + if (objClass != null) { + Class class1 = Class.forName(objClass); + Field[] field = class1.getDeclaredFields();// 这里便是获得实体Bean中所有属性的方法 + StringBuffer sb = new StringBuffer(); + for (int i = 0; i < field.length; i++) {// 这里不多说了 + + sb.append(field[i].getName()); + + // 这是分割符 是为了去掉最后那个逗号 + + // 比如 如果不去最后那个逗号 最后打印出来的结果是 "id,name," + + // 去了以后打印出来的是 "id,name" + if (i < field.length - 1) { + sb.append(","); + + } + } + + // split(",");这是根据逗号来切割字符串使字符串变成一个数组 + + wageStrArray = sb.toString().split(","); + return wageStrArray; + } else { + return wageStrArray; + } + } + public static Object[] field2Value(Field[] f, Object o) throws Exception { + Object[] value = new Object[f.length]; + for (int i = 0; i < f.length; i++) { + value[i] = f[i].get(o); + } + return value; + } + /** + * returns the current http session object + * + * @return session + */ + public HttpSession getSession() { + HttpSession session=null; + ServletRequestAttributes attr = (ServletRequestAttributes) RequestContextHolder.currentRequestAttributes(); + HttpSession contextSess = attr == null ? session : attr.getRequest().getSession(true); + + return contextSess; + } + /** + * 得到实体类 + * @param objClass 实体类包含包名 + * @return + */ + public static Class getEntityClass(String objClass){ + Class entityClass = null; + try { + entityClass = Class.forName(objClass); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + } + return entityClass; + } + + /** + * 定义字符集 + * @param + * @return + */ + private static char[] chars = { '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', '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'}; //72个字符集 + + /** + * + * @param passLength + * 随机密码长度 + * @return 随机密码数组 + */ + public static String getPasswords(int passLength) { + String passwords = "";// 新建一个长度为指定需要密码个数的字符串数组 + Random random = new Random(); + StringBuilder password = new StringBuilder("");// 保存生成密码的变量 + for (int m = 1; m <= passLength; m++) {// 内循环 从1开始到密码长度 正式开始生成密码 + password.append(chars[random.nextInt(62)]);// 为密码变量随机增加上面字符中的一个 + } + passwords = password.toString();// 将生成出来的密码赋值给密码数组 + return passwords; + } + + +} \ No newline at end of file diff --git a/util/src/main/java/com/ccsens/util/HttpServletUtil.java b/util/src/main/java/com/ccsens/util/HttpServletUtil.java new file mode 100644 index 0000000..c04adef --- /dev/null +++ b/util/src/main/java/com/ccsens/util/HttpServletUtil.java @@ -0,0 +1,59 @@ +package com.ccsens.util; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.io.PrintWriter; + +public class HttpServletUtil { + public static void responseJson(HttpServletResponse response, String json) throws IOException { + response.setCharacterEncoding("UTF-8"); + response.setContentType("application/json;charset=utf-8"); + PrintWriter out = response.getWriter(); + out.append(json); + out.close(); + } + + /** + * 获取用户真实IP地址,不使用request.getRemoteAddr();的原因是有可能用户使用了代理软件方式避免真实IP地址, + * + * 可是,如果通过了多级反向代理的话,X-Forwarded-For的值并不止一个,而是一串IP值,究竟哪个才是真正的用户端的真实IP呢? + * 答案是取X-Forwarded-For中第一个非unknown的有效IP字符串。 + * + * 如:X-Forwarded-For:192.168.1.110, 192.168.1.120, 192.168.1.130, + * 192.168.1.100 + * + * 用户真实IP为: 192.168.1.110 + * + * @param request + * @return + */ + public static String getIpAddress(HttpServletRequest request) { + String ip = request.getHeader("x-forwarded-for"); + if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { + ip = request.getHeader("Proxy-Client-IP"); + } + if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { + ip = request.getHeader("WL-Proxy-Client-IP"); + } + if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { + ip = request.getHeader("HTTP_CLIENT_IP"); + } + if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { + ip = request.getHeader("HTTP_X_FORWARDED_FOR"); + } + if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { + ip = request.getRemoteAddr(); + } + return ip; + } + + public static String getSiteBasePath(HttpServletRequest request){ + return request.getScheme() + "://" + + request.getServerName() + ":" + request.getServerPort(); + } + + public static String getSiteContextPath(HttpServletRequest request){ + return getSiteBasePath(request) + "/" + request.getContextPath(); + } +} diff --git a/util/src/main/java/com/ccsens/util/HttpsUtil.java b/util/src/main/java/com/ccsens/util/HttpsUtil.java new file mode 100644 index 0000000..cbfdb74 --- /dev/null +++ b/util/src/main/java/com/ccsens/util/HttpsUtil.java @@ -0,0 +1,327 @@ +package com.ccsens.util; + +import lombok.extern.slf4j.Slf4j; +import org.apache.http.HttpEntity; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.conn.ssl.SSLConnectionSocketFactory; +import org.apache.http.conn.ssl.SSLContexts; +import org.apache.http.conn.ssl.TrustSelfSignedStrategy; +import org.apache.http.entity.StringEntity; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.util.EntityUtils; + +import javax.net.ssl.*; +import java.io.*; +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLConnection; +import java.security.KeyStore; +import java.security.cert.CertificateException; +import java.security.cert.X509Certificate; +import java.util.ArrayList; +import java.util.List; + +/** + * 类名: MyX509TrustManager
+ * 描述:信任管理器
+ * 开发人员: souvc
+ * 创建时间: 2015-11-27
+ * 发布版本:V1.0
+ */ + +class MyX509TrustManager implements X509TrustManager { + + // 检查客户端证书 + public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException { + } + + // 检查服务器端证书 + public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException { + } + + // 返回受信任的X509证书数组 + public X509Certificate[] getAcceptedIssuers() { + return null; + } +} +@Slf4j +public class HttpsUtil { + /** + * 发送https请求 + * + * @param requestUrl 请求地址 + * @param requestMethod 请求方式(GET、POST) + * @param postStr 提交的数据 + * @return String(Json) + */ + public static String httpsRequest(String requestUrl, String requestMethod, String postStr) throws Exception { + StringBuffer buffer = null; + // 创建SSLContext对象,并使用我们指定的信任管理器初始化 + TrustManager[] tm = {new MyX509TrustManager()}; + SSLContext sslContext = SSLContext.getInstance("SSL", "SunJSSE"); + sslContext.init(null, tm, new java.security.SecureRandom()); + // 从上述SSLContext对象中得到SSLSocketFactory对象 + SSLSocketFactory ssf = sslContext.getSocketFactory(); + + URL url = new URL(requestUrl); + HttpsURLConnection conn = (HttpsURLConnection) url.openConnection(); + conn.setSSLSocketFactory(ssf); + + conn.setDoOutput(true); + conn.setDoInput(true); + conn.setUseCaches(false); + // 设置请求方式(GET/POST) + conn.setRequestMethod(requestMethod); + + // 当outputStr不为null时向输出流写数据 + if (null != postStr) { + OutputStream outputStream = conn.getOutputStream(); + // 注意编码格式 + outputStream.write(postStr.getBytes("UTF-8")); + outputStream.close(); + } + + // 从输入流读取返回内容 + InputStream inputStream = conn.getInputStream(); + InputStreamReader inputStreamReader = new InputStreamReader(inputStream, "utf-8"); + BufferedReader bufferedReader = new BufferedReader(inputStreamReader); + String str = null; + buffer = new StringBuffer(); + while ((str = bufferedReader.readLine()) != null) { + buffer.append(str); + } + + // 释放资源 + bufferedReader.close(); + inputStreamReader.close(); + inputStream.close(); + inputStream = null; + conn.disconnect(); + return buffer == null ? null : buffer.toString(); + } + + + /** + * 发送https请求 + * + * @param requestUrl 请求地址 + * @param requestMethod 请求方式(GET、POST) + * @param postStr 提交的数据 + * @return String(Json) + */ + public static byte[] httpsRequestByte(String requestUrl, String requestMethod, String postStr) throws Exception { + // 创建SSLContext对象,并使用我们指定的信任管理器初始化 + TrustManager[] tm = {new MyX509TrustManager()}; + SSLContext sslContext = SSLContext.getInstance("SSL", "SunJSSE"); + sslContext.init(null, tm, new java.security.SecureRandom()); + // 从上述SSLContext对象中得到SSLSocketFactory对象 + SSLSocketFactory ssf = sslContext.getSocketFactory(); + + URL url = new URL(requestUrl); + HttpsURLConnection conn = (HttpsURLConnection) url.openConnection(); + conn.setSSLSocketFactory(ssf); + + conn.setDoOutput(true); + conn.setDoInput(true); + conn.setUseCaches(false); + // 设置请求方式(GET/POST) + conn.setRequestMethod(requestMethod); + + // 当outputStr不为null时向输出流写数据 + if (null != postStr) { + OutputStream outputStream = conn.getOutputStream(); + // 注意编码格式 + outputStream.write(postStr.getBytes("UTF-8")); + outputStream.close(); + } + + // 从输入流读取返回内容 + InputStream inputStream = conn.getInputStream(); +// InputStreamReader inputStreamReader = new InputStreamReader(inputStream, "utf-8"); +// BufferedReader bufferedReader = new BufferedReader(inputStreamReader); + int length = 1024; + List buffer = new ArrayList<>(); + byte[] temp = new byte[length]; + int i = 0; + while ((length = inputStream.read(temp)) > 0) { + i += length; + byte[] temp2 = new byte[length]; + System.arraycopy(temp,0,temp2,0,length); + buffer.add(temp2); + } + + // 释放资源 + inputStream.close(); + conn.disconnect(); + + byte[] t = new byte[i]; + int j = 0; + for (byte[] b : buffer){ + System.arraycopy(b,0,t,j,b.length); + j += b.length; + } + return t; + } + /** + * 发送https请求 + * + * @param requestUrl 请求地址 + * @param requestMethod 请求方式(GET、POST) + * @param postStr 提交的数据 + * @param path 将结果以二进制方式写入文件 + * @return void + */ + public static void httpsRequest(String requestUrl, String requestMethod, String postStr,String path)throws Exception { + log.info("发送POST请求的路径:{}",requestUrl); + log.info("请求提交的数据:{}",postStr); + + StringBuffer buffer = null; + // 创建SSLContext对象,并使用我们指定的信任管理器初始化 + TrustManager[] tm = {new MyX509TrustManager()}; + SSLContext sslContext = SSLContext.getInstance("SSL", "SunJSSE"); + sslContext.init(null, tm, new java.security.SecureRandom()); + // 从上述SSLContext对象中得到SSLSocketFactory对象 + SSLSocketFactory ssf = sslContext.getSocketFactory(); + + URL url = new URL(requestUrl); + HttpsURLConnection conn = (HttpsURLConnection) url.openConnection(); + conn.setSSLSocketFactory(ssf); + + conn.setDoOutput(true); + conn.setDoInput(true); + conn.setUseCaches(false); + // 设置请求方式(GET/POST) + conn.setRequestMethod(requestMethod); + + // 当outputStr不为null时向输出流写数据 + if (null != postStr) { + OutputStream outputStream = conn.getOutputStream(); + // 注意编码格式 + outputStream.write(postStr.getBytes("UTF-8")); + outputStream.close(); + } + + // 从输入流读取返回内容 + File file = new File(path); + if (!file.getParentFile().exists()) { + file.getParentFile().mkdirs(); + } + InputStream inputStream = conn.getInputStream(); + BufferedInputStream bis = new BufferedInputStream(inputStream); + OutputStream os = new FileOutputStream(file); + int len; + byte[] arr = new byte[1024]; + while ((len = bis.read(arr)) != -1) + { + os.write(arr, 0, len); + os.flush(); + } + os.close(); + } + + /** + * 发送https请求 使用PKCS12类型证书 + * + * @param requestUrl 请求地址 + * @param requestMethod 请求方式(GET、POST) + * @param postStr 提交的数据 + * @return String(Json) + */ + public static String httpsRequest(String requestUrl, String requestMethod, String postStr,String pKCS12Path,String pKCS12Pwd) throws Exception { + SSLContext sc = null; + FileInputStream instream = null; + KeyStore keyStore = null; + + keyStore = KeyStore.getInstance("PKCS12"); + instream = new FileInputStream(new File(pKCS12Path)); + keyStore.load(instream,pKCS12Pwd.toCharArray()); + instream.close(); + + SSLContext sslcontext = SSLContexts.custom().loadKeyMaterial( + keyStore, pKCS12Pwd.toCharArray()).build(); + SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory( + sslcontext, + new String[] { "TLSv1" }, + null, + SSLConnectionSocketFactory.BROWSER_COMPATIBLE_HOSTNAME_VERIFIER + ); + CloseableHttpClient httpclient = HttpClients.custom().setSSLSocketFactory(sslsf) .build(); + HttpPost httpost = new HttpPost(requestUrl); + httpost.addHeader("Connection", "keep-alive"); + httpost.addHeader("Accept", "*/*"); + httpost.addHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8"); + httpost.addHeader("Host", "api.mch.weixin.qq.com"); + httpost.addHeader("X-Requested-With", "XMLHttpRequest"); + httpost.addHeader("Cache-Control", "max-age=0"); + httpost.addHeader("User-Agent", + "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0) "); + httpost.setEntity(new StringEntity(postStr, "UTF-8")); + CloseableHttpResponse response = httpclient.execute(httpost); + HttpEntity entity = response.getEntity(); + String jsonStr = EntityUtils.toString(response.getEntity(), "UTF-8"); + EntityUtils.consume(entity); + + return jsonStr; + } + + /** + * 设置信任自签名证书 + * + * @param keyStorePath 密钥库路径 + * @param keyStorepass 密钥库密码 + * @return + */ + public static SSLContext custom(String keyStorePath, String keyStorepass) { + SSLContext sc = null; + FileInputStream instream = null; + KeyStore trustStore = null; + try { + trustStore = KeyStore.getInstance(KeyStore.getDefaultType()); + instream = new FileInputStream(new File(keyStorePath)); + trustStore.load(instream, keyStorepass.toCharArray()); + // 相信自己的CA和所有自签名的证书 + sc = SSLContexts.custom().loadTrustMaterial(trustStore, new TrustSelfSignedStrategy()).build(); + // 构造 javax.net.ssl.TrustManager 对象 + TrustManagerFactory tmf = + TrustManagerFactory.getInstance("SunX509", "SunJSSE"); + tmf.init(trustStore); + TrustManager tms [] = tmf.getTrustManagers(); + // 使用构造好的 TrustManager 访问相应的 https 站点 + SSLContext sslContext = SSLContext.getInstance("SSL", "SunJSSE"); + sslContext.init(null, tms, new java.security.SecureRandom()); + } catch (Exception e) { + e.printStackTrace(); + } finally { + try { + instream.close(); + } catch (IOException e) { + } + } + return sc; + } + + public static String sendGet(String url, String charset, int timeout) { + String result = ""; + try { + URL u = new URL(url); + try { + URLConnection conn = u.openConnection(); + conn.connect(); + conn.setConnectTimeout(timeout); + BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream(), charset)); + String line = ""; + while ((line = in.readLine()) != null) { + result = result + line; + } + in.close(); + } catch (IOException e) { + return result; + } + } catch (MalformedURLException e) { + return result; + } + return result; + } +} diff --git a/util/src/main/java/com/ccsens/util/ImageCodeGeneratorUtil.java b/util/src/main/java/com/ccsens/util/ImageCodeGeneratorUtil.java new file mode 100644 index 0000000..65c106a --- /dev/null +++ b/util/src/main/java/com/ccsens/util/ImageCodeGeneratorUtil.java @@ -0,0 +1,140 @@ +package com.ccsens.util; + + +import cn.hutool.core.codec.Base64; +import lombok.extern.slf4j.Slf4j; + +import java.awt.*; +import java.awt.image.BufferedImage; +import java.io.*; +import java.util.HashMap; +import java.util.Map; +import java.util.Random; + +import javax.imageio.ImageIO; + +/** + * @author 逗 + */ +@Slf4j +public class ImageCodeGeneratorUtil { + + + + /** + * 验证码字符的范围 + */ + public static final String VERTIFICATION_CODE ="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; + + + /** + * + * @param size 字符长度 + * @param sourceCode 字符范围 + * @return 返回随机生成的字符 + */ + public static String generateCode(int size,String sourceCode) { + Random random = new Random(System.currentTimeMillis()); + char[] codes= new char[size]; + for(int i=0;i generateCountCode() { + //生成两个随机数 + Random random = new Random(); + int i1 = random.nextInt(50); + int i2 = random.nextInt(50); + //计算两个数的和,并生成验证码的内容 + int sum = i1 + i2; + String imageCode = i1 + "+" + i2 + "=" + "?"; + + //返回 + Map codeMap = new HashMap<>(); + codeMap.put("imageCode",imageCode); + codeMap.put("sum",sum); + return codeMap; + } + + + public static String generateCodeImage(OutputStream os,String vertifyCode,int width,int height) { + int verifySize = vertifyCode.length(); + BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); + // 获取图形上下文 + Graphics g = image.getGraphics(); + // 生成随机类 + Random random = new Random(); + // 设定背景色 + g.setColor(getRandColor(230, 255)); + g.fillRect(0, 0, width, height); + // 设定字体 + g.setFont(new Font("Arial", Font.CENTER_BASELINE | Font.ITALIC, 28)); + // 产生0条干扰线, + g.drawLine(0, 0, 0, 0); + // 取随机产生的认证码(4位数字) + for (int i = 0; i < verifySize; i++) { + + // 将认证码显示到图象中 + // 调用函数出来的颜色相同,可能是因为种子太接近,所以只能直接生成 + g.setColor(getRandColor(100, 150)); + g.drawString(String.valueOf(vertifyCode.charAt(i)), i * (width/verifySize) +5, 50); + } + //画干扰线 + for(int i=0;i<(random.nextInt(20)+5);i++){ + g.setColor(new Color(random.nextInt(255)+1,random.nextInt(255)+1,random.nextInt(255)+1)); + g.drawLine(random.nextInt(width),random.nextInt(height),random.nextInt(width)+5,random.nextInt(height)+5); + } + // 图象生效 + g.dispose(); + // 输出图象到页面 + try { +// ImageIO.write(image, "jpg", os); + + ByteArrayOutputStream outputStream = new ByteArrayOutputStream (); + ImageIO.write(image, "png", outputStream); + ByteArrayInputStream input = new ByteArrayInputStream(outputStream.toByteArray()); + return Base64.encode(input); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + log.error("生成图片验证码异常",e); + return null; + } + } + + public static void main(String[] args) { +// System.out.println(generateCode(6, VERTIFICATION_CODE)); +// int iRandom = (int)(1+Math.random()*50); +// Double a = Math.random(); +// System.out.println(a); +// System.out.println(a*50); +// System.out.println(1+a*50); +// System.out.println(new Random().nextInt(9)+1); + String c = new String("aaa"); + String a = "helloword"; + String b = "ewor"; + a.indexOf(b); + + } + + private static Color getRandColor(int fc, int bc) { + Random random = new Random(); + if (fc > 255) { + fc = 255; + } + if (bc > 255) { + bc = 255; + } + int r = fc + random.nextInt(bc - fc); + int g = fc + random.nextInt(bc - fc); + int b = fc + random.nextInt(bc - fc); + return new Color(r, g, b); + } + +} diff --git a/util/src/main/java/com/ccsens/util/ImgUtil.java b/util/src/main/java/com/ccsens/util/ImgUtil.java new file mode 100644 index 0000000..53affa2 --- /dev/null +++ b/util/src/main/java/com/ccsens/util/ImgUtil.java @@ -0,0 +1,13 @@ +//package com.ccsens.util; +// +//import sun.font.FontDesignMetrics; +// +//import java.awt.*; +// +//public class ImgUtil { +// public static int getStringWidth(String text,Font f){ +// FontMetrics fm = FontDesignMetrics.getMetrics(f); +// int w = fm.stringWidth(text); +// return w; +// } +//} diff --git a/util/src/main/java/com/ccsens/util/JacksonUtil.java b/util/src/main/java/com/ccsens/util/JacksonUtil.java new file mode 100644 index 0000000..6134cda --- /dev/null +++ b/util/src/main/java/com/ccsens/util/JacksonUtil.java @@ -0,0 +1,312 @@ +package com.ccsens.util; + +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.util.StrUtil; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.*; +import com.fasterxml.jackson.databind.module.SimpleModule; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import com.fasterxml.jackson.dataformat.xml.XmlMapper; + +import java.io.IOException; +import java.io.InputStream; +import java.util.List; +import java.util.Map; + +/** + * @author wei + * @date 2019.11.25 + */ +public class JacksonUtil { + private static ObjectMapper objectMapper = new ObjectMapper(); + private static XmlMapper xmlMapper = new XmlMapper(); + static { + objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + objectMapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY); + objectMapper.configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true); + SimpleModule simpleModule = new SimpleModule(); + simpleModule.addSerializer(Long.class, ToStringSerializer.instance); + simpleModule.addSerializer(Long.TYPE, ToStringSerializer.instance); + objectMapper.registerModule(simpleModule); + + xmlMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + xmlMapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY); + } + + /** + * 获取泛型的Collection Type + * eg: collectionClass==List.class elementClasses == MessageBean.class 则返回 List对应的java类型 + * @param collectionClass 泛型的Collection + * @param elementClasses 元素类 + * @return JavaType Java类型 + * @since 1.0 + */ + private static JavaType getCollectionType(ObjectMapper mapper, Class collectionClass, Class... elementClasses) { + return mapper.getTypeFactory().constructParametricType(collectionClass, elementClasses); + } + + /** + * Json And Bean Converter + * @param json 要转换的json + * @param clazz 目标类型类对象 + * @param isSet 是否集合类型 + * @param 目标类型 + * @return 集合(如果,只有1个对象,则添加到集合中返回) + * @throws IOException IO异常 + */ + public static List jsonToBean(String json, Class clazz, boolean isSet) throws IOException { + if (!isSet) { + return CollectionUtil.newArrayList(objectMapper.readValue(json, clazz)); + } + else { + JavaType javaType = getCollectionType(objectMapper,List.class,clazz); + return objectMapper.readValue(json, javaType); + } + } + + public static T jsonToBean(String json, Class clazz) throws IOException { + return objectMapper.readValue(json, clazz); + } + + public static String beanToJson(T bean, boolean pretty) throws JsonProcessingException { + if (!pretty) { + return objectMapper.writeValueAsString(bean); + } + else { + return objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(bean); + } + } + + public static String beanToJson(T bean) throws JsonProcessingException { + return beanToJson(bean,false); + } + + + /** + * Json And Map Converter + * + * @param json 要转换的json + * eg: {"time":"1574602523","from":{"id":"1","name":"zs"},"to":[{"id":"1","name":"ls","avatar":"xx.jpg"}],"rule":{"offlineDiscard":1}} + * @return Map 如果value还是一个json对象,则也会被转化为map + * eg: entry1: "time"->String entry2: "from"--> Map entry3: "to"->List entry4: "rule"-->Map + * @throws IOException + */ + public static Map jsonToMap(String json) throws IOException { + JavaType javaType = getCollectionType(objectMapper,Map.class,String.class,Object.class); + return objectMapper.readValue(json,javaType); + } + + public static String mapToJson(Map map,boolean pretty) throws JsonProcessingException { + if(!pretty){ + return objectMapper.writeValueAsString(map); + }else{ + return objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(map); + } + } + + public static String mapToJson(Map map) throws JsonProcessingException { + return mapToJson(map,false); + } + + /** + * Map And Bean Converter + * @param map 要转换的集合 + * @param clazz 目标类型类对象 + * @param 目标类型 + * @return JavaBean + * @throws IOException IO异常 + */ + public static T mapToBean(Map map,Class clazz) throws IOException { + return jsonToBean(mapToJson(map),clazz); + } + + public static Map beanToMap(T bean) throws IOException { + return jsonToMap(beanToJson(bean)); + } + + + /** + * Xml And Bean Converter + * Javabean可以使用Jackson xml标注: @JacksonXmlRootElement(localName = "Class") 指定root元素名称 + * 其他标注:@JacksonXmlElementWrapper(localName = "Students")指定List类型包装元素名称比如:学生列表 @JacksonXmlProperty(localName = "Stu") 指定字段元素名称比如:学生 + * @param bean 要转换的JavaBean + * @param root xml root元素名称,建议使用@JacksonXmlElementWrapper表示 + * @param pretty 是否启用pretty模式 + * @param Javabean类型 + * @return xml字符串 + * @throws JsonProcessingException Json处理异常 + */ + public static String beanToXml(T bean,String root,boolean pretty) throws JsonProcessingException { + if(!pretty) { + if(StrUtil.isEmpty(root)) { + return xmlMapper.writeValueAsString(bean); + }else{ + return xmlMapper.writer().with(SerializationFeature.WRAP_ROOT_VALUE).withRootName(root).writeValueAsString(bean); + } + }else{ + if(StrUtil.isEmpty(root)) { + return xmlMapper.writerWithDefaultPrettyPrinter().writeValueAsString(bean); + }else{ + return xmlMapper.writer().with(SerializationFeature.WRAP_ROOT_VALUE).withRootName(root).withDefaultPrettyPrinter().writeValueAsString(bean); + } + } + } + + public static String beanToXml(T bean,String root) throws JsonProcessingException { + return beanToXml(bean,root,false); + } + + public static String beanToXml(T bean,boolean pretty) throws JsonProcessingException { + return beanToXml(bean,null,pretty); + } + + public static String beanToXml(T bean) throws JsonProcessingException { + return beanToXml(bean,null,false); + } + + public static T xmlToBean(String xml, Class clazz) throws IOException { + return xmlMapper.readValue(xml, clazz); + } + + public static T xmlToBean(InputStream xmlInStream, Class clazz) throws IOException { + return xmlMapper.readValue(xmlInStream, clazz); + } + + /** + * Xml And Map Converter + * 注意:存在一直问题: xml转map时,对于相同属性,比如123234不会自动转化为list,而还是map,由于map不能重复,因此导致第二个to丢失 + * 暂未找到解决办法 + * 暂时解决办法:xml转map时,先转成bean,bean再转map + * @param xml 要转换的xml字符串 + * @return Map + * @throws IOException IO异常 + */ + public static Map xmlToMap(String xml) throws IOException { + JavaType javaType = getCollectionType(objectMapper,Map.class,String.class,Object.class); + return xmlMapper.readValue(xml, javaType); + } + + public static Map xmlToMap(InputStream xmlInStream) throws IOException { + JavaType javaType = getCollectionType(objectMapper,Map.class,String.class,Object.class); + return xmlMapper.readValue(xmlInStream, javaType); + } + + public static String mapToXml(Map map,String root,boolean pretty) throws JsonProcessingException { + if(!pretty) { + if(StrUtil.isEmpty(root)) { + return xmlMapper.writeValueAsString(map); + }else{ + return xmlMapper.writer().with(SerializationFeature.WRAP_ROOT_VALUE).withRootName(root).writeValueAsString(map); + } + }else{ + if(StrUtil.isEmpty(root)) { + return xmlMapper.writerWithDefaultPrettyPrinter().writeValueAsString(map); + }else{ + return xmlMapper.writer().with(SerializationFeature.WRAP_ROOT_VALUE).withRootName(root).withDefaultPrettyPrinter().writeValueAsString(map); + } + } + } + + public static String mapToXml(Map map,String root) throws JsonProcessingException { + return mapToXml(map,root,false); + } + + public static String mapToXml(Map map,boolean pretty) throws JsonProcessingException { + return mapToXml(map,null,pretty); + } + + public static String mapToXml(Map map) throws JsonProcessingException { + return mapToXml(map,null,false); + } + + /** + * Json And Xml Converter + * @param json 要转换的json字符串 + * @return xml + * @throws IOException IO异常 + */ + public static String jsonToXml(String json) throws IOException { + return mapToXml(jsonToMap(json)); + } + + public static String jsonToXml(String json,String root) throws IOException { + return mapToXml(jsonToMap(json),root); + } + + public static String jsonToXml(String json,boolean pretty) throws IOException { + return mapToXml(jsonToMap(json),pretty); + } + + public static String jsonToXml(String json,String root,boolean pretty) throws IOException { + return mapToXml(jsonToMap(json),root,pretty); + } + + public static String xmlToJson(String xml) throws IOException { + return mapToJson(xmlToMap(xml)); + } + + public static String xmlToJson(String xml,boolean pretty) throws IOException { + return mapToJson(xmlToMap(xml),pretty); + } + + /** + * 获取单个字段值 + * @param json + * @param property + * @return + * @throws IOException + * + * JsonNode tmpNode, node = objectMapper.readTree(json); + * System.out.println("voName:" + node.get("voName").textValue()); + * System.out.println("pers: " + node.get("pers").toString()); + * System.out.println("age: " + node.get("age").toString()); + * JsonNode persNode = node.get("pers"); + * if (persNode.isArray()) { + * for (int i = 0; i < persNode.size(); i++) { + * tmpNode = persNode.get(i); + * System.out.println(tmpNode.get("name")); + * JsonNode childNode = tmpNode.get("childs"); + * if(!childNode.isNull() && childNode.isArray()){ + * for(int j=0;j T getJsonPropertyValueByPath(String json,String path,T t) throws IOException{ + //TODO + return null; + } + +} diff --git a/util/src/main/java/com/ccsens/util/JsonResponse.java b/util/src/main/java/com/ccsens/util/JsonResponse.java new file mode 100644 index 0000000..3116f7e --- /dev/null +++ b/util/src/main/java/com/ccsens/util/JsonResponse.java @@ -0,0 +1,191 @@ +package com.ccsens.util; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +@Data +@ApiModel +public class JsonResponse { + + /** + * Common Error Constant + */ + public static class RegularError { + public static final int ERRCODE_SUCCESS = 200; + public static final String ERRCODE_SUCCESS_PHASE = "ok"; + public static final int ERRCODE_FAIL = -1; + public static final String ERRCODE_FAIL_PHASE = "error"; + } + + /** + * Jwt Error Constant + */ + public static class TokenError{ + public static final int TOKEN_ERRCODE_OK = JwtUtil.JwtError.TOKEN_ERRCODE_OK; + public static final String TOKEN_ERRCODE_OK_PHASE = JwtUtil.JwtError.TOKEN_ERRCODE_OK_PHASE; + public static final int TOKEN_ERRCODE_NOTFOUND = JwtUtil.JwtError.TOKEN_ERRCODE_NOTFOUND; + public static final String TOKEN_ERRCODE_NOTFOUND_PHASE = JwtUtil.JwtError.TOKEN_ERRCODE_NOTFOUND_PHASE; + public static final int TOKEN_ERRCODE_SIGNATURE_INVALIDATE = JwtUtil.JwtError.TOKEN_ERRCODE_SIGNATURE_INVALIDATE; + public static final String TOKEN_ERRCODE_SIGNATURE_INVALIDATE_PHASE = JwtUtil.JwtError.TOKEN_ERRCODE_SIGNATURE_INVALIDATE_PHASE; + public static final int TOKEN_ERRCODE_EXPIRE = JwtUtil.JwtError.TOKEN_ERRCODE_EXPIRE; + public static final String TOKEN_ERRCODE_EXPIRE_PHASE = JwtUtil.JwtError.TOKEN_ERRCODE_EXPIRE_PHASE; + public static final int TOKEN_ERRCODE_STUB_NOT_FOUND = JwtUtil.JwtError.TOKEN_ERRCODE_STUB_NOT_FOUND; + public static final String TOKEN_ERRCODE_STUB_NOT_FOUND_PHASE = JwtUtil.JwtError.TOKEN_ERRCODE_STUB_NOT_FOUND_PHASE; + public static final int TOKEN_ERRCODE_USER_DISABLED = JwtUtil.JwtError.TOKEN_ERRCODE_USER_DISABLED; + public static final String TOKEN_ERRCODE_USER_DISABLED_PHASE = JwtUtil.JwtError.TOKEN_ERRCODE_USER_DISABLED_PHASE; + public static final int TOKEN_ERRCODE_FAILED = JwtUtil.JwtError.TOKEN_ERRCODE_FAILED; + public static final String TOKEN_ERRCODE_FAILED_PHASE = JwtUtil.JwtError.TOKEN_ERRCODE_FAILED_PHASE; + } + + @ApiModelProperty(value="状态码") + private Integer code; + @ApiModelProperty(value="数据") + private T data; + @ApiModelProperty(value="消息") + private String msg; + @ApiModelProperty(value="成功与否") + private boolean success; + @ApiModelProperty(value = "md5校验状态 0:未校验 1:校验一致 2:校验不一致") + private byte md5Status = 0; + + public static class MD5Status{ + public final static byte UNCHECK = 0; + public final static byte CHECK_SAME_YES = 1; + public final static byte CHECK_SAME_NO = 2; + } + + private JsonResponse() { + } + + public static JsonResponse newInstance(){ + return new JsonResponse(); + } +// public static JsonResponse newInstance(Class T){ +// return new JsonResponse(); +// } + + public JsonResponse ok(){ + this.code = CodeEnum.SUCCESS.getCode(); + this.msg = CodeEnum.SUCCESS.getMsg(); + this.success = CodeEnum.SUCCESS.isSuccess(); + return this; + } + + public JsonResponse ok(T data){ + ok(); + this.data = data; + return this; + } + + public JsonResponse ok(CodeEnum codeEnum){ + this.code = codeEnum.getCode(); + this.msg = codeEnum.getMsg(); + this.success = codeEnum.isSuccess(); + return this; + } + + public JsonResponse ok(CodeEnum codeEnum, T data){ + this.code = codeEnum.getCode(); + this.msg = codeEnum.getMsg(); + this.success = codeEnum.isSuccess(); + this.data = data; + return this; + } + + public JsonResponse ok(CodeError.Code code){ + this.code = code.getCode(); + this.msg = code.getMsg(); + this.success = code.isSuccess(); + return this; + } + + public JsonResponse fail(){ + this.code = RegularError.ERRCODE_FAIL; + this.msg = RegularError.ERRCODE_FAIL_PHASE; + this.success = false; + return this; + } + + public JsonResponse fail(String error){ + fail(); + this.msg = error; + return this; + } + + public JsonResponse fail(int code){ + fail(); + this.code = code; + return this; + } + + public JsonResponse fail(int code, String error){ + fail(); + this.code = code; + this.msg = error; + return this; + } + + public JsonResponse fail(int code, String error, T obj){ + fail(); + this.code = code; + this.msg = error; + this.data = obj; + return this; + } + + //Token null + public JsonResponse tokenNotFound(){ + fail(TokenError.TOKEN_ERRCODE_NOTFOUND, TokenError.TOKEN_ERRCODE_NOTFOUND_PHASE); + return this; + } + + //Token expire + public JsonResponse tokenExpire(){ + fail(TokenError.TOKEN_ERRCODE_EXPIRE, TokenError.TOKEN_ERRCODE_EXPIRE_PHASE); + return this; + } + public JsonResponse tokenExpire(String phase){ + fail(TokenError.TOKEN_ERRCODE_EXPIRE,phase); + return this; + } + + public JsonResponse tokenSignatureFail(){ + fail(TokenError.TOKEN_ERRCODE_SIGNATURE_INVALIDATE, TokenError.TOKEN_ERRCODE_SIGNATURE_INVALIDATE_PHASE); + return this; + } + public JsonResponse tokenSignatureFail(String phase){ + fail(TokenError.TOKEN_ERRCODE_SIGNATURE_INVALIDATE,phase); + return this; + } + + //Token Stub Not Found + public JsonResponse tokenStubNotFound(){ + fail(TokenError.TOKEN_ERRCODE_STUB_NOT_FOUND, TokenError.TOKEN_ERRCODE_STUB_NOT_FOUND_PHASE); + return this; + } + public JsonResponse tokenDisabled(String phase){ + fail(TokenError.TOKEN_ERRCODE_STUB_NOT_FOUND,phase); + return this; + } + + //User Disabled + public JsonResponse userDisabled(){ + fail(TokenError.TOKEN_ERRCODE_USER_DISABLED, TokenError.TOKEN_ERRCODE_USER_DISABLED_PHASE); + return this; + } + public JsonResponse userDisabled(String phase){ + fail(TokenError.TOKEN_ERRCODE_USER_DISABLED,phase); + return this; + } + + //Token Failed + public JsonResponse tokenFailed(){ + fail(TokenError.TOKEN_ERRCODE_FAILED, TokenError.TOKEN_ERRCODE_FAILED_PHASE); + return this; + } + public JsonResponse tokenFailed(String phase){ + fail(TokenError.TOKEN_ERRCODE_FAILED,phase); + return this; + } +} diff --git a/util/src/main/java/com/ccsens/util/JsonResponse1.java b/util/src/main/java/com/ccsens/util/JsonResponse1.java new file mode 100644 index 0000000..eb63573 --- /dev/null +++ b/util/src/main/java/com/ccsens/util/JsonResponse1.java @@ -0,0 +1,298 @@ +package com.ccsens.util; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +public class JsonResponse1 { + + /** + * Hypermedia API + */ + private static class Link{ + private String rel; //API与当前调用API的关系 + private String href; //API url + private String title; //API title + private String type; //API 返回类型 + public Link() { + } + + public Link(String title,String rel, String href) { + this.title = title; + this.rel = rel; + this.href = href; + } + + public Link(String title,String rel, String href,String type) { + this.title = title; + this.rel = rel; + this.href = href; + this.type = type; + } + + public String getRel() { + return rel; + } + + public void setRel(String rel) { + this.rel = rel; + } + + public String getHref() { + return href; + } + + public void setHref(String href) { + this.href = href; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + } + + /** + * Meta data + */ + public static class Meta{ + /** + * Common Error Constant + */ + public static class RegularError { + public static final int ERRCODE_SUCCESS = 0; + public static final String ERRCODE_SUCCESS_PHASE = "ok"; + public static final int ERRCODE_FAIL = -1; + public static final String ERRCODE_FAIL_PHASE = "error"; + } + + /** + * Jwt Error Constant + */ + public static class TokenError{ + public static final int TOKEN_ERRCODE_OK = JwtUtil.JwtError.TOKEN_ERRCODE_OK; + public static final String TOKEN_ERRCODE_OK_PHASE = JwtUtil.JwtError.TOKEN_ERRCODE_OK_PHASE; + public static final int TOKEN_ERRCODE_NOTFOUND = JwtUtil.JwtError.TOKEN_ERRCODE_NOTFOUND; + public static final String TOKEN_ERRCODE_NOTFOUND_PHASE = JwtUtil.JwtError.TOKEN_ERRCODE_NOTFOUND_PHASE; + public static final int TOKEN_ERRCODE_SIGNATURE_INVALIDATE = JwtUtil.JwtError.TOKEN_ERRCODE_SIGNATURE_INVALIDATE; + public static final String TOKEN_ERRCODE_SIGNATURE_INVALIDATE_PHASE = JwtUtil.JwtError.TOKEN_ERRCODE_SIGNATURE_INVALIDATE_PHASE; + public static final int TOKEN_ERRCODE_EXPIRE = JwtUtil.JwtError.TOKEN_ERRCODE_EXPIRE; + public static final String TOKEN_ERRCODE_EXPIRE_PHASE = JwtUtil.JwtError.TOKEN_ERRCODE_EXPIRE_PHASE; + public static final int TOKEN_ERRCODE_STUB_NOT_FOUND = JwtUtil.JwtError.TOKEN_ERRCODE_STUB_NOT_FOUND; + public static final String TOKEN_ERRCODE_STUB_NOT_FOUND_PHASE = JwtUtil.JwtError.TOKEN_ERRCODE_STUB_NOT_FOUND_PHASE; + public static final int TOKEN_ERRCODE_USER_DISABLED = JwtUtil.JwtError.TOKEN_ERRCODE_USER_DISABLED; + public static final String TOKEN_ERRCODE_USER_DISABLED_PHASE = JwtUtil.JwtError.TOKEN_ERRCODE_USER_DISABLED_PHASE; + public static final int TOKEN_ERRCODE_FAILED = JwtUtil.JwtError.TOKEN_ERRCODE_FAILED; + public static final String TOKEN_ERRCODE_FAILED_PHASE = JwtUtil.JwtError.TOKEN_ERRCODE_FAILED_PHASE; + } + + private int code; + private String error; + + public Meta() { + } + + public Meta(int code) { + this.code = code; + } + + public Meta(int code,String error) { + this.code = code; + this.error = error; + } + + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public String getError() { + return error; + } + + public void setError(String error) { + this.error = error; + } + } + + /** + * Page Data + */ + public class Data{ + private long total; + private int size; + private Collection list; + + public Data(){} + + public Data(long total,Collection list){ + if(list != null && list.size() == 1){ //处理Arrays.asList(null)的情况 + if(list.toArray()[0] == null) + list = null; + } + this.total = total; + this.size = list == null ? 0 : list.size(); + this.list = list; + } + + public long getTotal() { + return total; + } + + public void setTotal(long total) { + this.total = total; + } + + public int getSize() { + return size; + } + + public void setSize(int size) { + this.size = size; + } + + public Collection getList() { + return list; + } + + public void setList(Collection list) { + this.list = list; + } + } + + private Meta meta; + private Data data; + private List links; + + public static JsonResponse1 newInstance(){ + return new JsonResponse1(); + } + + public JsonResponse1 addLink(String title, String rel, String url){ + if(links==null) + links = new ArrayList(); + links.add(new Link(title,rel,url)); + return this; + } + + public JsonResponse1 ok(){ + this.meta = new Meta(Meta.RegularError.ERRCODE_SUCCESS, Meta.RegularError.ERRCODE_SUCCESS_PHASE); + return this; + } + + public JsonResponse1 ok(Collection list){ + ok(); + this.data = new Data(-1,list); + return this; + } + + public JsonResponse1 ok(long total, Collection list){ + ok(); + this.data = new Data(total,list); + return this; + } + + public JsonResponse1 fail(){ + this.meta = new Meta(Meta.RegularError.ERRCODE_FAIL, Meta.RegularError.ERRCODE_FAIL_PHASE); + return this; + } + + public JsonResponse1 fail(String error){ + this.meta = new Meta(Meta.RegularError.ERRCODE_FAIL,error); + return this; + } + + public JsonResponse1 fail(int code){ + this.meta = new Meta(code, Meta.RegularError.ERRCODE_FAIL_PHASE); + return this; + } + + public JsonResponse1 fail(int code, String error){ + this.meta = new Meta(code,error); + return this; + } + + //Token null + public JsonResponse1 tokenNotFound(){ + this.meta = new Meta(Meta.TokenError.TOKEN_ERRCODE_NOTFOUND, Meta.TokenError.TOKEN_ERRCODE_NOTFOUND_PHASE); + return this; + } + + //Token expire + public JsonResponse1 tokenExpire(){ + this.meta = new Meta(Meta.TokenError.TOKEN_ERRCODE_EXPIRE, Meta.TokenError.TOKEN_ERRCODE_EXPIRE_PHASE); + return this; + } + public JsonResponse1 tokenExpire(String phase){ + this.meta = new Meta(Meta.TokenError.TOKEN_ERRCODE_EXPIRE,phase); + return this; + } + + //Token Signature failed + public JsonResponse1 tokenSignatureFail(){ + this.meta = new Meta(Meta.TokenError.TOKEN_ERRCODE_SIGNATURE_INVALIDATE, Meta.TokenError.TOKEN_ERRCODE_SIGNATURE_INVALIDATE_PHASE); + return this; + } + public JsonResponse1 tokenSignatureFail(String phase){ + this.meta = new Meta(Meta.TokenError.TOKEN_ERRCODE_SIGNATURE_INVALIDATE,phase); + return this; + } + + //Token Stub Not Found + public JsonResponse1 tokenStubNotFound(){ + this.meta = new Meta(Meta.TokenError.TOKEN_ERRCODE_STUB_NOT_FOUND, Meta.TokenError.TOKEN_ERRCODE_STUB_NOT_FOUND_PHASE); + return this; + }public JsonResponse1 tokenDisabled(String phase){ + this.meta = new Meta(Meta.TokenError.TOKEN_ERRCODE_STUB_NOT_FOUND,phase); + return this; + } + + //User Disabled + public JsonResponse1 userDisabled(){ + this.meta = new Meta(Meta.TokenError.TOKEN_ERRCODE_USER_DISABLED, Meta.TokenError.TOKEN_ERRCODE_USER_DISABLED_PHASE); + return this; + }public JsonResponse1 userDisabled(String phase){ + this.meta = new Meta(Meta.TokenError.TOKEN_ERRCODE_USER_DISABLED,phase); + return this; + } + + //Token Failed + public JsonResponse1 tokenFailed(){ + this.meta = new Meta(Meta.TokenError.TOKEN_ERRCODE_FAILED, Meta.TokenError.TOKEN_ERRCODE_FAILED_PHASE); + return this; + } + public JsonResponse1 tokenFailed(String phase){ + this.meta = new Meta(Meta.TokenError.TOKEN_ERRCODE_FAILED, phase); + return this; + } + + public JsonResponse1() { + } + + public Meta getMeta() { + return meta; + } + + public Object getData() { + return data; + } + + public Object setData(Data data) { + this.data = data; + return this; + } + + public List getLinks() { + return links; + } + + public void setLinks(List links) { + this.links = links; + } +} diff --git a/util/src/main/java/com/ccsens/util/JsonResponse2.java b/util/src/main/java/com/ccsens/util/JsonResponse2.java new file mode 100644 index 0000000..0173d22 --- /dev/null +++ b/util/src/main/java/com/ccsens/util/JsonResponse2.java @@ -0,0 +1,151 @@ +package com.ccsens.util; + +import lombok.Data; + +@Data +public class JsonResponse2 { + + /** + * Common Error Constant + */ + public static class RegularError { + public static final int ERRCODE_SUCCESS = 200; + public static final String ERRCODE_SUCCESS_PHASE = "ok"; + public static final int ERRCODE_FAIL = -1; + public static final String ERRCODE_FAIL_PHASE = "error"; + } + + /** + * Jwt Error Constant + */ + public static class TokenError{ + public static final int TOKEN_ERRCODE_OK = JwtUtil.JwtError.TOKEN_ERRCODE_OK; + public static final String TOKEN_ERRCODE_OK_PHASE = JwtUtil.JwtError.TOKEN_ERRCODE_OK_PHASE; + public static final int TOKEN_ERRCODE_NOTFOUND = JwtUtil.JwtError.TOKEN_ERRCODE_NOTFOUND; + public static final String TOKEN_ERRCODE_NOTFOUND_PHASE = JwtUtil.JwtError.TOKEN_ERRCODE_NOTFOUND_PHASE; + public static final int TOKEN_ERRCODE_SIGNATURE_INVALIDATE = JwtUtil.JwtError.TOKEN_ERRCODE_SIGNATURE_INVALIDATE; + public static final String TOKEN_ERRCODE_SIGNATURE_INVALIDATE_PHASE = JwtUtil.JwtError.TOKEN_ERRCODE_SIGNATURE_INVALIDATE_PHASE; + public static final int TOKEN_ERRCODE_EXPIRE = JwtUtil.JwtError.TOKEN_ERRCODE_EXPIRE; + public static final String TOKEN_ERRCODE_EXPIRE_PHASE = JwtUtil.JwtError.TOKEN_ERRCODE_EXPIRE_PHASE; + public static final int TOKEN_ERRCODE_STUB_NOT_FOUND = JwtUtil.JwtError.TOKEN_ERRCODE_STUB_NOT_FOUND; + public static final String TOKEN_ERRCODE_STUB_NOT_FOUND_PHASE = JwtUtil.JwtError.TOKEN_ERRCODE_STUB_NOT_FOUND_PHASE; + public static final int TOKEN_ERRCODE_USER_DISABLED = JwtUtil.JwtError.TOKEN_ERRCODE_USER_DISABLED; + public static final String TOKEN_ERRCODE_USER_DISABLED_PHASE = JwtUtil.JwtError.TOKEN_ERRCODE_USER_DISABLED_PHASE; + public static final int TOKEN_ERRCODE_FAILED = JwtUtil.JwtError.TOKEN_ERRCODE_FAILED; + public static final String TOKEN_ERRCODE_FAILED_PHASE = JwtUtil.JwtError.TOKEN_ERRCODE_FAILED_PHASE; + } + + private Integer code; + private Object data; + private String msg; + private boolean success; + + private JsonResponse2() { + } + + public static JsonResponse2 newInstance(){ + return new JsonResponse2(); + } + + public JsonResponse2 ok(){ + this.code = RegularError.ERRCODE_SUCCESS; + this.msg = RegularError.ERRCODE_SUCCESS_PHASE; + this.success = true; + return this; + } + + public JsonResponse2 ok(Object data){ + ok(); + this.data = data; + return this; + } + + public JsonResponse2 fail(){ + this.code = RegularError.ERRCODE_FAIL; + this.msg = RegularError.ERRCODE_FAIL_PHASE; + this.success = false; + return this; + } + + public JsonResponse2 fail(String error){ + fail(); + this.msg = error; + return this; + } + + public JsonResponse2 fail(int code){ + fail(); + this.code = code; + return this; + } + + public JsonResponse2 fail(int code, String error){ + fail(); + this.code = code; + this.msg = error; + return this; + } + + public JsonResponse2 fail(int code, String error, Object obj){ + fail(); + this.code = code; + this.msg = error; + this.data = obj; + return this; + } + + //Token null + public JsonResponse2 tokenNotFound(){ + fail(TokenError.TOKEN_ERRCODE_NOTFOUND, TokenError.TOKEN_ERRCODE_NOTFOUND_PHASE); + return this; + } + + //Token expire + public JsonResponse2 tokenExpire(){ + fail(TokenError.TOKEN_ERRCODE_EXPIRE, TokenError.TOKEN_ERRCODE_EXPIRE_PHASE); + return this; + } + public JsonResponse2 tokenExpire(String phase){ + fail(TokenError.TOKEN_ERRCODE_EXPIRE,phase); + return this; + } + + public JsonResponse2 tokenSignatureFail(){ + fail(TokenError.TOKEN_ERRCODE_SIGNATURE_INVALIDATE, TokenError.TOKEN_ERRCODE_SIGNATURE_INVALIDATE_PHASE); + return this; + } + public JsonResponse2 tokenSignatureFail(String phase){ + fail(TokenError.TOKEN_ERRCODE_SIGNATURE_INVALIDATE,phase); + return this; + } + + //Token Stub Not Found + public JsonResponse2 tokenStubNotFound(){ + fail(TokenError.TOKEN_ERRCODE_STUB_NOT_FOUND, TokenError.TOKEN_ERRCODE_STUB_NOT_FOUND_PHASE); + return this; + } + public JsonResponse2 tokenDisabled(String phase){ + fail(TokenError.TOKEN_ERRCODE_STUB_NOT_FOUND,phase); + return this; + } + + //User Disabled + public JsonResponse2 userDisabled(){ + fail(TokenError.TOKEN_ERRCODE_USER_DISABLED, TokenError.TOKEN_ERRCODE_USER_DISABLED_PHASE); + return this; + } + public JsonResponse2 userDisabled(String phase){ + fail(TokenError.TOKEN_ERRCODE_USER_DISABLED,phase); + return this; + } + + //Token Failed + public JsonResponse2 tokenFailed(){ + fail(TokenError.TOKEN_ERRCODE_FAILED, TokenError.TOKEN_ERRCODE_FAILED_PHASE); + return this; + } + public JsonResponse2 tokenFailed(String phase){ + fail(TokenError.TOKEN_ERRCODE_FAILED,phase); + return this; + } +} diff --git a/util/src/main/java/com/ccsens/util/JwtUtil.java b/util/src/main/java/com/ccsens/util/JwtUtil.java new file mode 100644 index 0000000..f758daf --- /dev/null +++ b/util/src/main/java/com/ccsens/util/JwtUtil.java @@ -0,0 +1,125 @@ +package com.ccsens.util; + +import cn.hutool.core.codec.Base64; +import cn.hutool.core.util.StrUtil; +import io.jsonwebtoken.*; +import lombok.extern.slf4j.Slf4j; + +import javax.crypto.SecretKey; +import javax.crypto.spec.SecretKeySpec; +import java.security.SignatureException; +import java.util.Date; +import java.util.Map; +import java.util.Set; + +/** + * @Author: __zHangSan + * @Description: + * @Date: Created in 17:40 2018/2/1 + */ +@Slf4j +public class JwtUtil { + /** + * Jwt Error Constant + */ + public static class JwtError{ + public static final int TOKEN_ERRCODE_OK = 200; + public static final String TOKEN_ERRCODE_OK_PHASE = "Token ok."; + public static final int TOKEN_ERRCODE_NOTFOUND = 401; + public static final String TOKEN_ERRCODE_NOTFOUND_PHASE = "Missing or invalid Authorization header."; + public static final int TOKEN_ERRCODE_SIGNATURE_INVALIDATE = 400; + public static final String TOKEN_ERRCODE_SIGNATURE_INVALIDATE_PHASE = "Token signature encoding error."; + public static final int TOKEN_ERRCODE_EXPIRE = 402; + public static final String TOKEN_ERRCODE_EXPIRE_PHASE = "Token Expire."; + public static final int TOKEN_ERRCODE_STUB_NOT_FOUND = 403; + public static final String TOKEN_ERRCODE_STUB_NOT_FOUND_PHASE = "Token stub not found."; + public static final int TOKEN_ERRCODE_USER_DISABLED = 405; + public static final String TOKEN_ERRCODE_USER_DISABLED_PHASE = "User disabled,Please concact the System Administrator."; + public static final int TOKEN_ERRCODE_FAILED = 406; + public static final String TOKEN_ERRCODE_FAILED_PHASE = "Token failed."; + } + + public static SecretKey generalKey(String secret) { + byte[] encodedKey = Base64.decode(secret); + SecretKey key = new SecretKeySpec(encodedKey, 0, encodedKey.length, "AES"); + return key; + } + + /** + * 签发JWT + * + * @param subject + * @param ttlMillis + * @return + * @throws Exception + */ + public static String createJWT(String subject, Map extraClaimMap, long ttlMillis,String secret) { + SignatureAlgorithm signatureAlgorithm = SignatureAlgorithm.HS256; + long nowMillis = System.currentTimeMillis(); + Date now = new Date(nowMillis); + SecretKey secretKey = generalKey(secret); + JwtBuilder builder = Jwts.builder() + .setIssuedAt(now) + .signWith(signatureAlgorithm, secretKey); + if(!StrUtil.isEmpty(subject)) { + builder.setSubject(subject); + } + if(extraClaimMap != null){ + Set> entrys = extraClaimMap.entrySet(); + for(Map.Entry entry:entrys){ + builder.claim(entry.getKey(),entry.getValue()); + } + } + if (ttlMillis >= 0) { + long expMillis = nowMillis + ttlMillis; + Date expDate = new Date(expMillis); + builder.setExpiration(expDate); + } + return builder.compact(); + } + + /** + * 签发JWT + * + * @param ttlMillis + * @return + * @throws Exception + */ + public static String createJWT(Claims claims, long ttlMillis, String secret) { + SignatureAlgorithm signatureAlgorithm = SignatureAlgorithm.HS256; + long nowMillis = System.currentTimeMillis(); + Date now = new Date(nowMillis); + SecretKey secretKey = generalKey(secret); + JwtBuilder builder = Jwts.builder() + .setClaims(claims) + .setIssuedAt(now) + .signWith(signatureAlgorithm, secretKey); + if (ttlMillis >= 0) { + long expMillis = nowMillis + ttlMillis; + Date expDate = new Date(expMillis); + builder.setExpiration(expDate); + } + return builder.compact(); + } + + /** + * 解析JWT字符串 + * + * @param jwt + * @return + * @throws Exception + */ + public static Claims parseJWT(String jwt, String secret)throws ExpiredJwtException,SignatureException,Exception{ + SecretKey secretKey = generalKey(secret); + log.info("JWT解析token:{},,,{}",jwt,secretKey); + return Jwts.parser() + .setSigningKey(secretKey) + .parseClaimsJws(jwt) + .getBody(); + } + + public static void main(String[] args) throws Exception { + String a = "eyJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE2MDczMDY4ODYsInN1YiI6IjEyMTc2NTEzNTQ5MTk2MzY5OTIiLCJhdXRoSWQiOiIxMTc3Mzk0MTQ5NzIxMjQ3NzQ0IiwiZXhwIjoxNjA3MzkzMjg2fQ.HSwJca28I2sddgyYf2dzNtn5M-mrPcVmbzvjn9dGZvE"; + parseJWT(a,WebConstant.JWT_ACCESS_TOKEN_SECERT); + } +} diff --git a/util/src/main/java/com/ccsens/util/KCPlayerSignature.java b/util/src/main/java/com/ccsens/util/KCPlayerSignature.java new file mode 100644 index 0000000..f6bf029 --- /dev/null +++ b/util/src/main/java/com/ccsens/util/KCPlayerSignature.java @@ -0,0 +1,106 @@ +package com.ccsens.util; + + +import java.util.Base64; +import java.util.Random; +import javax.crypto.Mac; +import javax.crypto.spec.SecretKeySpec; + + +/** + * 签名工具类 + * @author 逗 + */ +public class KCPlayerSignature{ + private String secretId = "AKIDTr6B7uA2qCRWRDRXyeUAZpkfR2tupVFu"; + private String secretKey = "wVtKAuXEjXFpxQmz9PM6hWallNEyZ0Na"; + private long currentTime; + private int random; + private int signValidDuration; + //签名算法 + private static final String HMAC_ALGORITHM = "HmacSHA1"; + private static final String CONTENT_CHARSET = "UTF-8"; + + public static byte[] byteMerger(byte[] byte1, byte[] byte2) { + byte[] byte3 = new byte[byte1.length + byte2.length]; + System.arraycopy(byte1, 0, byte3, 0, byte1.length); + System.arraycopy(byte2, 0, byte3, byte1.length, byte2.length); + return byte3; + } + + // 获取签名 + public String getUploadSignature(Long id) throws Exception { + String strSign = ""; + String contextStr = ""; + + // 生成原始参数字符串 + long endTime = (currentTime + signValidDuration); + contextStr += "secretId=" + java.net.URLEncoder.encode(secretId, "utf8"); + contextStr += "¤tTimeStamp=" + currentTime; + contextStr += "&expireTime=" + endTime; + contextStr += "&random=" + random; + contextStr += "&procedure=videoEncode"; + contextStr += "&sourceContext=" + id; + System.out.println("------------------contextStr:" + contextStr); + + + try { + Mac mac = Mac.getInstance(HMAC_ALGORITHM); + SecretKeySpec secretKey = new SecretKeySpec(this.secretKey.getBytes(CONTENT_CHARSET), mac.getAlgorithm()); + mac.init(secretKey); + + byte[] hash = mac.doFinal(contextStr.getBytes(CONTENT_CHARSET)); + byte[] sigBuf = byteMerger(hash, contextStr.getBytes("utf8")); + strSign = base64Encode(sigBuf); + strSign = strSign.replace(" ", "").replace("\n", "").replace("\r", ""); + } catch (Exception e) { + throw e; + } + return strSign; + } + + public static String base64Encode(byte[] buffer) { + Base64.Encoder encoder = Base64.getEncoder(); + return encoder.encodeToString(buffer); + } + + + public void setSecretId(String secretId) { + this.secretId = secretId; + } + + public void setSecretKey(String secretKey) { + this.secretKey = secretKey; + } + + public void setCurrentTime(long currentTime) { + this.currentTime = currentTime; + } + + public void setRandom(int random) { + this.random = random; + } + + public void setSignValidDuration(int signValidDuration) { + this.signValidDuration = signValidDuration; + } + + static void main(String[] args) { +// KCPlayerSignature sign = new KCPlayerSignature(); +// // 设置 App 的云 API 密钥 +// sign.setSecretId("个人 API 密钥中的 Secret Id"); +// sign.setSecretKey("个人 API 密钥中的 Secret Key"); +// sign.setCurrentTime(System.currentTimeMillis() / 1000); +// sign.setRandom(new Random().nextInt(java.lang.Integer.MAX_VALUE)); +// // 签名有效期:2天 +// sign.setSignValidDuration(3600 * 24 * 2); +// +// try { +// String signature = sign.getUploadSignature(id); +// System.out.println("signature : " + signature); +// } catch (Exception e) { +// System.out.print("获取签名失败"); +// e.printStackTrace(); +// } + } +} \ No newline at end of file diff --git a/util/src/main/java/com/ccsens/util/Md5Util.java b/util/src/main/java/com/ccsens/util/Md5Util.java new file mode 100644 index 0000000..c0b1e4d --- /dev/null +++ b/util/src/main/java/com/ccsens/util/Md5Util.java @@ -0,0 +1,105 @@ +package com.ccsens.util; + + +import lombok.extern.slf4j.Slf4j; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.math.BigInteger; +import java.security.MessageDigest; +@Slf4j +public class Md5Util { +// +// //获取文件MD5 +// public static String getMd5File(String path) { +// String md5 = null; +// try { +// FileInputStream fis = new FileInputStream(path); +// md5 = DigestUtils.md5Hex(IOUtils.toByteArray(fis)); +// IOUtils.closeQuietly(fis); +// } catch (IOException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// return md5; +// } + + public static String getFileMD5(File file) { + String str = null; + FileInputStream in = null; + try { + in = new FileInputStream(file); + MessageDigest digest = MessageDigest.getInstance("MD5"); + byte[] buffer = new byte[1024 * 1024 * 10]; + + int len = 0; + while ((len = in.read(buffer)) > 0) { + digest.update(buffer, 0, len); + } + String md5 = new BigInteger(1, digest.digest()).toString(16); + int length = 32 - md5.length(); + if (length > 0) { + for (int i = 0; i < length; i++) { + md5 = "0" + md5; + } + } + str = md5; + } catch (Exception e) { + log.info(String.valueOf(e)); + } finally { + try { + if (in != null) { + in.close(); + } + } catch (IOException e) { + log.info(String.valueOf(e)); + } + } + return str; + } + + public static String stringTo(String plainText) { + try { + //生成实现指定摘要算法的 MessageDigest 对象。 + MessageDigest md = MessageDigest.getInstance("MD5"); + //使用指定的字节数组更新摘要。 + md.update(plainText.getBytes()); + //通过执行诸如填充之类的最终操作完成哈希计算。 + byte b[] = md.digest(); + //生成具体的md5密码到buf数组 + int i; + StringBuffer buf = new StringBuffer(""); + for (int offset = 0; offset < b.length; offset++) { + i = b[offset]; + if (i < 0) { + i += 256; + } + if (i < 16) { + buf.append("0"); + } + buf.append(Integer.toHexString(i)); + } + return buf.toString(); +// System.out.println("32位: " + buf.toString());// 32位的加密 +// System.out.println("16位: " + buf.toString().substring(8, 24));// 16位的加密,其实就是32位加密后的截取 + } + catch (Exception e) { + e.printStackTrace(); + } + return ""; + } + +// public static void main(String args[]) { +// String path = "D:\\home\\btpro\\uploads\\delivers\\20190509\\fc3d9e330c75414d96ebadaac0294fdc.pdf"; +// String path1 = "C:\\Users\\逗\\Desktop\\测试.pdf"; +// File file = new File(path); +// File file1 = new File(path1); +// +// System.out.println(getMd5File(path)); +// System.out.println(getMd5File(path1)); +// } + + + +} diff --git a/util/src/main/java/com/ccsens/util/MyJacksonObjectMapper.java b/util/src/main/java/com/ccsens/util/MyJacksonObjectMapper.java new file mode 100644 index 0000000..12f4cd5 --- /dev/null +++ b/util/src/main/java/com/ccsens/util/MyJacksonObjectMapper.java @@ -0,0 +1,15 @@ +package com.ccsens.util; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; + +public class MyJacksonObjectMapper extends ObjectMapper { + public MyJacksonObjectMapper(){ + //目标类中找不到json字符串中属性时直接忽略 + this.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + this.setSerializationInclusion(JsonInclude.Include.NON_EMPTY); + this.configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true); + } +} diff --git a/util/src/main/java/com/ccsens/util/NotSupportedFileTypeException.java b/util/src/main/java/com/ccsens/util/NotSupportedFileTypeException.java new file mode 100644 index 0000000..c0a175a --- /dev/null +++ b/util/src/main/java/com/ccsens/util/NotSupportedFileTypeException.java @@ -0,0 +1,22 @@ +package com.ccsens.util; + +public class NotSupportedFileTypeException extends Exception { + public NotSupportedFileTypeException() { + } + + public NotSupportedFileTypeException(String message) { + super(message); + } + + public NotSupportedFileTypeException(String message, Throwable cause) { + super(message, cause); + } + + public NotSupportedFileTypeException(Throwable cause) { + super(cause); + } + + public NotSupportedFileTypeException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { + super(message, cause, enableSuppression, writableStackTrace); + } +} diff --git a/util/src/main/java/com/ccsens/util/PasswordEncryptionUtil.java b/util/src/main/java/com/ccsens/util/PasswordEncryptionUtil.java new file mode 100644 index 0000000..9d305e5 --- /dev/null +++ b/util/src/main/java/com/ccsens/util/PasswordEncryptionUtil.java @@ -0,0 +1,113 @@ +package com.ccsens.util; + +import javax.crypto.SecretKeyFactory; +import javax.crypto.spec.PBEKeySpec; +import java.math.BigInteger; +import java.security.NoSuchAlgorithmException; +import java.security.SecureRandom; +import java.security.spec.InvalidKeySpecException; +import java.security.spec.KeySpec; + +public class PasswordEncryptionUtil { + + public static final String PBKDF2_ALGORITHM = "PBKDF2WithHmacSHA1"; + + /** + * 盐的长度 + */ + public static final int SALT_BYTE_SIZE = 32 / 2; + + /** + * 生成密文的长度 + */ + public static final int HASH_BIT_SIZE = 128 * 4; + + /** + * 迭代次数 + */ + public static final int PBKDF2_ITERATIONS = 1000; + + /** + * 对输入的密码进行验证 + * + * @param attemptedPassword + * 待验证的密码 + * @param encryptedPassword + * 密文 + * @param salt + * 盐值 + * @return 是否验证成功 + * @throws NoSuchAlgorithmException + * @throws InvalidKeySpecException + */ + public static boolean authenticate(String attemptedPassword, String encryptedPassword, String salt) + throws NoSuchAlgorithmException, InvalidKeySpecException { + // 用相同的盐值对用户输入的密码进行加密 + String encryptedAttemptedPassword = getEncryptedPassword(attemptedPassword, salt); + // 把加密后的密文和原密文进行比较,相同则验证成功,否则失败 + return encryptedAttemptedPassword.equals(encryptedPassword); + } + + /** + * 生成密文 + * + * @param password + * 明文密码 + * @param salt + * 盐值 + * @return + * @throws NoSuchAlgorithmException + * @throws InvalidKeySpecException + */ + public static String getEncryptedPassword(String password, String salt) throws NoSuchAlgorithmException, + InvalidKeySpecException { + + KeySpec spec = new PBEKeySpec(password.toCharArray(), fromHex(salt), PBKDF2_ITERATIONS, HASH_BIT_SIZE); + SecretKeyFactory f = SecretKeyFactory.getInstance(PBKDF2_ALGORITHM); + return toHex(f.generateSecret(spec).getEncoded()); + } + + /** + * 通过提供加密的强随机数生成器 生成盐 + * + * @return + * @throws NoSuchAlgorithmException + */ + public static String generateSalt() throws NoSuchAlgorithmException { + SecureRandom random = SecureRandom.getInstance("SHA1PRNG"); + byte[] salt = new byte[SALT_BYTE_SIZE]; + random.nextBytes(salt); + + return toHex(salt); + } + + /** + * 十六进制字符串转二进制字符串 + * + * @param   hex         the hex string + * @return              the hex string decoded into a byte array       + */ + private static byte[] fromHex(String hex) { + byte[] binary = new byte[hex.length() / 2]; + for (int i = 0; i < binary.length; i++) { + binary[i] = (byte) Integer.parseInt(hex.substring(2 * i, 2 * i + 2), 16); + } + return binary; + } + + /** + * 二进制字符串转十六进制字符串 + * + * @param   array       the byte array to convert + * @return              a length*2 character string encoding the byte array       + */ + private static String toHex(byte[] array) { + BigInteger bi = new BigInteger(1, array); + String hex = bi.toString(16); + int paddingLength = (array.length * 2) - hex.length(); + if (paddingLength > 0) + return String.format("%0" + paddingLength + "d", 0) + hex; + else + return hex; + } +} \ No newline at end of file diff --git a/util/src/main/java/com/ccsens/util/PdfUtil.java b/util/src/main/java/com/ccsens/util/PdfUtil.java new file mode 100644 index 0000000..0116bb9 --- /dev/null +++ b/util/src/main/java/com/ccsens/util/PdfUtil.java @@ -0,0 +1,210 @@ +package com.ccsens.util; + +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.StrUtil; +import com.itextpdf.text.*; +import com.itextpdf.text.pdf.BaseFont; +import com.itextpdf.text.pdf.PdfPCell; +import com.itextpdf.text.pdf.PdfPTable; +import com.itextpdf.text.pdf.PdfWriter; +import lombok.Data; +import lombok.extern.slf4j.Slf4j; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +/** + * @description: + * @author: wuHuiJuan + * @create: 2019/12/20 09:34 + */ +@Slf4j +public class PdfUtil { + + /** + * 生成pdf + * @param parentPath + * @param title + * @param subhead 副标题 + * @param intros + * @param content + * @return + */ + public static String credatePdf(String parentPath, String title, String subhead, List intros, List content, Margin margin) { + String fileName = "pdf/" + DateUtil.today() + "/" + System.currentTimeMillis() + ".pdf"; + log.info("pdf文件名:{}", fileName ); + File file = new File(parentPath, fileName); + if (!file.getParentFile().exists()) { + file.getParentFile().mkdirs(); + } + //新建文件 + Document document = new Document(); + try { + document.setMargins(margin.left, margin.right, margin.top, margin.bottom); + PdfWriter.getInstance(document, new FileOutputStream(file)); + document.open(); + // 中文字体 + BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); + // 标题字体 + Font titleChinese = new Font(bfChinese, 24, Font.BOLD); + //设置标题 + Paragraph par = new Paragraph(title, titleChinese); + par.setAlignment(Element.ALIGN_CENTER); + document.add(par); + + if (StrUtil.isNotBlank(subhead)) { + // 标题字体 + Font subheadChinese = new Font(bfChinese, 22, Font.NORMAL); + //设置标题 + Paragraph subheadPar = new Paragraph(subhead, subheadChinese); + subheadPar.setAlignment(Element.ALIGN_CENTER); + document.add(subheadPar); + } + // 每行加空白 + fillBlankRow(document, titleChinese); + //设置介绍内容 + if (CollectionUtil.isNotEmpty(intros)) { + fillRow(intros, document); + } + if (CollectionUtil.isNotEmpty(content)) { + fillRow(content, document); + } + + } catch (DocumentException e) { + e.printStackTrace(); + log.error("导出pdf异常", e); + return null; + } catch (FileNotFoundException e) { + e.printStackTrace(); + log.error("导出pdf异常", e); + return null; + } catch (IOException e) { + e.printStackTrace(); + log.error("导出pdf异常", e); + return null; + } finally { + document.close(); + } + + return fileName; + } + + /** + * 添加空白行 + * @param document + * @param titleChinese + * @throws DocumentException + */ + private static void fillBlankRow(Document document, Font titleChinese) throws DocumentException { + Paragraph par; + par = new Paragraph(" ", titleChinese); + par.setAlignment(Element.ALIGN_LEFT); + document.add(par); + } + + /** + * 添加内容 + * @param rows + * @param document + */ + private static void fillRow(List rows, Document document) throws IOException, DocumentException { + BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); + int size = 0; + for (Cell cell :rows.get(0).getCells()) { + size += cell.getColSpan(); + } + + PdfPTable table = new PdfPTable(size); + table.setSpacingBefore(0); + table.setWidthPercentage(90); + for (int j = 0; j < rows.size(); j++) { + Row row = rows.get(j); + table.setHorizontalAlignment(row.align); + Font font = new Font(bfChinese, row.fontSize, row.fontStyle); + for (int i = 0; i < row.cells.size(); i++) { + Cell cell = row.cells.get(i); + PdfPCell pdfpCell = new PdfPCell(new Phrase(cell.content,font)); + pdfpCell.setBorderWidthTop(cell.borderTop == null ? 0 : cell.borderTop); + pdfpCell.setBorderWidthLeft(cell.borderLeft == null ? 0 : cell.borderLeft); + pdfpCell.setBorderWidthRight(cell.borderRight == null ? 0 : cell.borderRight); + pdfpCell.setBorderWidthBottom(cell.borderBottom == null ? 0 : cell.borderBottom); + pdfpCell.setColspan(cell.colSpan); + pdfpCell.setRowspan(cell.rowSpan); + if (cell.isCenter) { + //水平居中 + pdfpCell.setHorizontalAlignment(Element.ALIGN_CENTER); + } + + //垂直居中 + pdfpCell.setVerticalAlignment(Element.ALIGN_MIDDLE); + pdfpCell.setMinimumHeight(cell.height); + table.addCell(pdfpCell); + } + } + try { + + document.add(table); + } catch (DocumentException e) { + e.printStackTrace(); + } + } + + /** + * pdf每行的内容 + */ + @Data + public static class Row{ + //表格内容 + private List cells = new ArrayList<>(); + //文字位置(居左) + private int align = Element.ALIGN_LEFT; + private int fontSize = 12; + private int fontStyle = Font.NORMAL; + private int height = 80; + + public void addCell(Cell cell) { + cells.add(cell); + } + } + @Data + public static class Cell{ + public final static int defaultHeight = 24; + //内容 + private String content; + //边框宽度 + private int border = 1; + // 上边框宽度 + private Integer borderTop = null; + // 下边框宽度 + private Integer borderBottom = 1; + // 左边框宽度 + private Integer borderLeft = 1; + // 右边框宽度 + private Integer borderRight = null; + //横向合并数 + private int colSpan = 1; + //纵向合并数 + private int rowSpan = 1; + //单元格高度 + private int height = defaultHeight; + // 单元格是否居中 + private boolean isCenter = true; + + } + + /** + * pdf位置 + */ + @Data + public static class Margin{ + private float left = 72; + private float right = 0; + private float top = 32; + private float bottom = 32; + } +} diff --git a/util/src/main/java/com/ccsens/util/PoiUtil.java b/util/src/main/java/com/ccsens/util/PoiUtil.java new file mode 100644 index 0000000..8a5edee --- /dev/null +++ b/util/src/main/java/com/ccsens/util/PoiUtil.java @@ -0,0 +1,738 @@ +package com.ccsens.util; + +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import com.ccsens.util.exception.BaseException; +import lombok.Data; +import lombok.extern.slf4j.Slf4j; +import org.apache.poi.POIXMLDocumentPart; +import org.apache.poi.common.usermodel.HyperlinkType; +import org.apache.poi.hssf.usermodel.*; +import org.apache.poi.ss.usermodel.DateUtil; +import org.apache.poi.ss.usermodel.*; +import org.apache.poi.ss.util.CellRangeAddress; +import org.apache.poi.util.IOUtils; +import org.apache.poi.xssf.usermodel.*; +import org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTMarker; +import org.springframework.stereotype.Component; + +import java.io.*; +import java.text.DecimalFormat; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 导入导出excel + * @author wu + */ +@Slf4j +@Component +public class PoiUtil { + + @Data + public static class PoiUtilCell { + /** + * 单元格内容 + */ + private String value = ""; + /** + * 跨列 + */ + private int colspan = 1; + /** + * 跨行 + */ + private int rowspan = 1; + /** + * 水平居中 + */ + private HorizontalAlignment style = HorizontalAlignment.CENTER; + /** + * 垂直居中 + */ + private VerticalAlignment verticalAlignment = VerticalAlignment.CENTER; + /** + * 行高 + */ + private Integer height; + /** + * 列宽 + */ + private Integer wight; + + /** + * 跳转的路径 + */ + private String path; + /** + * 函数 + */ + private String function; + + /** + * 是否是数字格式 0否 1是 + */ + private byte num = 0; + + public PoiUtilCell() { + + } + + public PoiUtilCell(String value) { + this.value = value; + } + + public PoiUtilCell(String value,String function) { + this.value = value; + this.function = function; + } + + + public PoiUtilCell(String value, int colspan, int rowspan) { + this.value = value; + this.colspan = colspan; + this.rowspan = rowspan; + } + + public PoiUtilCell(String value, Integer height, Integer wight) { + this.value = value; + this.height = height; + this.wight = wight; + } + + public PoiUtilCell(String value, int colspan, int rowspan, Integer height, Integer wight) { + this.value = value; + this.colspan = colspan; + this.rowspan = rowspan; + this.height = height; + this.wight = wight; + } + + } + + + /** + * 导出Excel + * + * @param sheetName sheet名称 + * @param rows 行 + * @param wb XSSFWorkbook对象 无则创建 + * @return 返回生成的excel数据 + */ + public static Workbook exportWB(String sheetName, List> rows, Workbook wb) { + return exportWB(sheetName, 0, rows, wb); + } + public static Workbook exportWB(String sheetName, int rowIndex, List> rows, Workbook wb) { + + // 第一步,创建一个XSSFWorkbook,对应一个Excel文件 + if (wb == null) { + wb = new XSSFWorkbook(); + } + if (rows == null) { + return wb; + } + // 第二步,在workbook中添加一个sheet,对应Excel文件中的sheet + Sheet sheet = wb.getSheet(sheetName); + if (ObjectUtil.isNull(sheet)) { + sheet = wb.createSheet(sheetName); + } + +// // 第三步,在sheet中添加表头第0行,注意老版本poi对Excel的行数列数有限制 +// HSSFRow row = sheet.createRow(0); + + // 第四步,创建单元格,并设置值表头 设置表头居中 + for (int i = 0; i < rows.size(); i++) { + List cells = rows.get(i); + for (int j = 0; j < cells.size(); j++) { + PoiUtilCell cell = cells.get(j); + //设置列宽 + if (ObjectUtil.isNotNull(cell.wight)) { + sheet.setColumnWidth(j, cell.wight * 256); + } + mergedRegion(sheet, i, j, cells.get(j)); + } + } + + //创建内容 + for (int i = 0; i < rows.size(); i++) { + Row row = sheet.getRow(i+rowIndex); + if (ObjectUtil.isNull(row)) { + row = sheet.createRow(i + rowIndex); + } + List cells = rows.get(i); + for (int j = 0; j < cells.size(); j++) { + PoiUtilCell cell = cells.get(j); + if(ObjectUtil.isNull(cell)){ + continue; + } + //查找当前单元格 + Cell newCell = row.getCell(j); + if(ObjectUtil.isNull(newCell)){ + newCell = row.createCell(j); + } + //查找当前单元格的样式 + CellStyle style = newCell.getCellStyle(); + if(ObjectUtil.isNull(style)){ + style = wb.createCellStyle(); + } +// CellStyle style = wb.createCellStyle(); + //设置内容 + if (!WebConstant.CELL_NULL.equals(cell.value)){ +// if(cell.num == 1){ +// newCell.setCellValue(Integer.parseInt(cell.value)); +// }else { +// newCell.setCellValue(cell.value); +// } + if(ObjectUtil.isNull(cell.value)) { +// log.info("单元格内容为空:{}", cell.value); + }else { + if (cell.value.length() <= 14 && cell.value.matches("\\d+")) { + newCell.setCellValue(Long.parseLong(cell.value)); + } else { + newCell.setCellValue(cell.value); + } + } + } + //设置行高 + if (ObjectUtil.isNotNull(cell.height)) { + if (j == 0) { + row.setHeight(cell.height.shortValue()); + } + } + //设置水平居中和垂直居中 + style.setAlignment(cell.style); + style.setVerticalAlignment(cell.verticalAlignment); + //设置跳转路径 + if (StrUtil.isNotEmpty(cell.path)) { + XSSFCreationHelper createHelper = (XSSFCreationHelper) wb.getCreationHelper(); + XSSFHyperlink link = createHelper.createHyperlink(HyperlinkType.URL); + link.setAddress(cell.path); + newCell.setHyperlink(link); + //设置字体颜色 + Font font = wb.createFont(); + font.setColor(Font.COLOR_RED); + style.setFont(font); + } + //添加函数 + if(StrUtil.isNotEmpty(cell.getFunction())) { + newCell.setCellFormula(cell.getFunction()); + } + //设置自动换行 + style.setWrapText(true); + //将样式添加至单元格 + newCell.setCellStyle(style); + +// CellStyle style = wb.createCellStyle(); +// 将内容按顺序赋给对应的列对象 +// 如果value是cell_null代表次单元格不需要赋值 +// if (cell.value.equals(WebConstant.CELL_NULL)){ +// continue; +// } +// Cell newCell = row.createCell(j); +// //设置行高 +// if (ObjectUtil.isNotNull(cell.height)) { +// if (j == 0) { +// row.setHeight(cell.height.shortValue()); +// } +// } +// +// if(cell.num == 1){ +// newCell.setCellValue(Integer.parseInt(cell.value)); +// }else { +// newCell.setCellValue(cell.value); +// } +// style.setAlignment(cell.style); +// style.setVerticalAlignment(cell.verticalAlignment); + +// //设置跳转路径 +// if (StrUtil.isNotEmpty(cell.path)) { +// XSSFCreationHelper createHelper = (XSSFCreationHelper) wb.getCreationHelper(); +// XSSFHyperlink link = createHelper.createHyperlink(HyperlinkType.URL); +// link.setAddress(cell.path); +// newCell.setHyperlink(link); +// //设置字体颜色 +// Font font = wb.createFont(); +// font.setColor(Font.COLOR_RED); +// style.setFont(font); +// } +// //添加函数 +// if(StrUtil.isNotEmpty(cell.getFunction())) { +// newCell.setCellFormula(cell.getFunction()); +// } +// //设置自动换行 +// style.setWrapText(true); +// newCell.setCellStyle(style); + } + } + return wb; + } + + /** + * 合并单元格 + * + * @param sheet 当前sheet + * @param rows 行数 + * @param cols 列数 + * @param cell 单元格信息 + */ + private static void mergedRegion(Sheet sheet, int rows, int cols, PoiUtilCell cell) { +// +// int rowspan = cell.rowspan; +// if (rowspan > 1) { +// sheet.addMergedRegion(new CellRangeAddress(rows, rows + rowspan - 1, cols, cols)); +// } +// int colspan = cell.colspan; +// +// if (colspan > 1) { +// sheet.addMergedRegion(new CellRangeAddress(rows, rows, cols, cols + colspan - 1)); +// } + + int rowspan = cell.rowspan; + int colspan = cell.colspan; + if(rowspan > 1 || colspan > 1){ + sheet.addMergedRegion(new CellRangeAddress(rows, rows + rowspan - 1, cols, cols + colspan - 1)); + } + + } + + + /** + * @param file + * @param sheetIndex + * @param dataIndex 数据从第几行开始(0) + * @return + */ + public static List readExce(File file, int sheetIndex, String sheetName, int dataIndex, boolean hasImg) throws Exception { + if (!file.getPath().endsWith(".xls") && !file.getPath().endsWith(".xlsx")) { + log.info("文件不是excel类型:{}", file.getName()); + throw new BaseException(CodeEnum.FILE_FORMAT_ERROR); + } + + + log.info("导入解析开始,fileName:{}", file.getPath()); + List list = new ArrayList<>(); + + Sheet sheet = createSheet(file, sheetIndex, sheetName); + if(ObjectUtil.isNull(sheet)){ + return list; + } + //读取放在首列的图片 + Map imgMap = null; + if (hasImg) { + imgMap = getImg(file, sheet); + } + //获取sheet的行数 + int rows = sheet.getPhysicalNumberOfRows(); + + //读取数据 + for (int i = 0; i < rows; i++) { + + Row row = getRow(sheet, i, dataIndex); + if (row == null || row.getLastCellNum() <= 0) { + continue; + } + System.out.println(row); + System.out.println(row.getLastCellNum()); + Object[] objects = new Object[row.getLastCellNum()]; + if (hasImg && imgMap != null) { + for (String key : imgMap.keySet()) { + if (key.startsWith(i + "-")) { + int index = Integer.parseInt(key.split("-")[1]); + objects[index] = imgMap.get(key); + } + } + } + for (int j = 0; j < row.getLastCellNum(); j++) { + Cell cell = row.getCell(j); + if (cell == null) { + continue; + } + if (objects[j] == null) { + objects[j] = getCallValue(cell); + } + + } + list.add(objects); + } + log.info("导入文件解析成功!"); + return list; + + } + + + public static String getCallValue(Cell cell) { + String cellValue = null; + // 判断excel单元格内容的格式,并对其进行转换,以便插入数据库 + switch (cell.getCellType()) { + case 0://number类型 + //时间类型也被认为是number类型,所以在读取数据时需进行判断 + if (DateUtil.isCellDateFormatted(cell)) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S"); + cellValue = sdf.format(cell.getDateCellValue()); + } else { + cellValue = new DecimalFormat("0").format(cell.getNumericCellValue()); + } + break; + case 1: + cellValue = cell.getStringCellValue(); + break; + case 2: + if (DateUtil.isCellDateFormatted(cell)) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S"); + cellValue = sdf.format(cell.getDateCellValue()); + } else { + cellValue = String.valueOf(cell.getNumericCellValue()); + } + break; + case 3: + cellValue = ""; + break; + case 4: + cellValue = String.valueOf(cell.getBooleanCellValue()); + break; + case 5: + cellValue = String.valueOf(cell.getErrorCellValue()); + break; + } + return cellValue; + } + + + private PoiUtil() { + super(); + } + + /** + * 获取图片和位置 (xls) + * + * @param sheet + * @return + * @throws IOException + */ + public static Map getXlsPictures(HSSFSheet sheet) { + Map map = new HashMap<>(); + List list = sheet.getDrawingPatriarch().getChildren(); + for (HSSFShape shape : list) { + if (shape instanceof HSSFPicture) { + HSSFPicture picture = (HSSFPicture) shape; + HSSFClientAnchor cAnchor = picture.getClientAnchor(); + + // 行号-列号 + String key = cAnchor.getRow1() + "-" + cAnchor.getCol1(); + + HSSFPictureData pictureData = picture.getPictureData(); + + map.put(key, createImgPath(pictureData)); + } + } + return map; + } + + /** + * 将流转储为图片 + * + * @param pictureData + * @return + */ + private static String createImgPath(PictureData pictureData) { + //后缀 + String suffix = pictureData.suggestFileExtension(); + //图片 + byte[] data = pictureData.getData(); + String fileName = "/poi/img/" + cn.hutool.core.date.DateUtil.today() + "/" + System.currentTimeMillis() + "." + suffix; + String path = PropUtil.path + fileName; + + FileOutputStream out = null; + try { + File file = new File(path); + if (!file.getParentFile().exists()) { + file.getParentFile().mkdirs(); + } + out = new FileOutputStream(path); + out.write(data); + return fileName; + } catch (IOException e) { + log.error("文件解析发生异常", e); + if (out != null) { + try { + out.close(); + } catch (IOException e1) { + e1.printStackTrace(); + } + } + return null; + } + + } + + /** + * 获取图片和位置 (xlsx) + * + * @param sheet + * @return + * @throws IOException + */ + public static Map getXlsxPictures(XSSFSheet sheet) { + Map map = new HashMap<>(); + List list = sheet.getRelations(); + for (POIXMLDocumentPart part : list) { + if (part instanceof XSSFDrawing) { + XSSFDrawing drawing = (XSSFDrawing) part; + List shapes = drawing.getShapes(); + for (XSSFShape shape : shapes) { + XSSFPicture picture = (XSSFPicture) shape; + XSSFClientAnchor anchor = picture.getPreferredSize(); + CTMarker marker = anchor.getFrom(); + String key = marker.getRow() + "-" + marker.getCol(); + map.put(key, createImgPath(picture.getPictureData())); + } + } + } + return map; + } + + + /** + * 获取当前行 + */ + private static Row getRow(Sheet sheet, int i, int dataIndex) { + //过滤表头行 + if (i < dataIndex) { + return null; + } + //获取当前行的数据 + Row row = sheet.getRow(i); + return row; + } + + private static Map getImg(File file, Sheet sheet) { + Map imgMap; + if (file.getPath().endsWith(".xls")) { + imgMap = getXlsPictures((HSSFSheet) sheet); + } else { + imgMap = getXlsxPictures((XSSFSheet) sheet); + } + return imgMap; + + } + + /** + * 生成sheet + * @param file + * @param index + * @return + * @throws Exception + */ + private static Sheet createSheet(File file, int index, String sheetName) throws Exception { + InputStream inputStream = new FileInputStream(file); + Workbook workbook; + if (file.getPath().endsWith(".xls")) { + workbook = new XSSFWorkbook(inputStream); + } else { + workbook = new XSSFWorkbook(inputStream); + } + if (index < 0) { + return workbook.getSheet(sheetName); + } + return workbook.getSheetAt(index); + } + + /** + * 插入图片 + * @param row1:起始行 + * @param row2:终止行 + * @param col1:起始列 + * @param col2:终止列 + * @throws IOException + */ + public static Workbook setImg(Workbook wb,String sheetName,String imgPath,int row1,int row2,int col1,int col2) throws IOException { + // 第一步,创建一个XSSFWorkbook,对应一个Excel文件 + if (wb == null) { + wb = new XSSFWorkbook(); + } + // 第二步,在workbook中添加一个sheet,对应Excel文件中的sheet + Sheet sheet = wb.getSheet(sheetName); + if (ObjectUtil.isNull(sheet)) { + sheet = wb.createSheet(sheetName); + } + // 插入 PNG 图片至 Excel + InputStream is = new FileInputStream(imgPath); + if(ObjectUtil.isNull(is)){ + return wb; + } + byte[] bytes = IOUtils.toByteArray(is); + int pictureIdx = wb.addPicture(bytes, Workbook.PICTURE_TYPE_PNG); + + CreationHelper helper = wb.getCreationHelper(); + Drawing drawing = sheet.createDrawingPatriarch(); + ClientAnchor anchor = helper.createClientAnchor(); + + // 图片插入坐标 + anchor.setDx1(0); + anchor.setDy1(0); + anchor.setDx2(0); + anchor.setDy2(0); + anchor.setRow1(row1); + anchor.setRow2(row2); + anchor.setCol1(col1); + anchor.setCol2(col2); + // 插入图片 + Picture pict = drawing.createPicture(anchor, pictureIdx); + return wb; + } + + + + /** + * 获取excel的列号 + * @param num 第几列(从1开始) + * @return 返回列号 + */ + public static String toRadix(Integer num) throws Exception{ + String[] array = {"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"}; + int count = 26; + String out = ""; + if(num > count){ + if(num % count == 0){ + out = array[(num / count) - 1 - 1] + array[count - 1]; + }else { + out = array[(num / count) - 1] + array[(num % count) - 1]; + } + }else{ + out = array[num - 1]; + } + return out; + } + + + public static void main(String[] args) throws Exception { + String s = toRadix(3); + System.out.println(s); + + +// File file = new File("F:\\wenjian\\3.xlsx"); +// file.createNewFile(); +// InputStream inputStream = new FileInputStream(file); + Workbook workbook = new XSSFWorkbook(); +// XSSFSheet sheet = (XSSFSheet) workbook.getSheetAt(0); +// XSSFRow row = sheet.getRow(6); +// XSSFCell newCell = row.createCell(2); +// XSSFCell newCell1 = row.createCell(3); +// //添加公式 +// newCell.setCellFormula("A7+B7"); +// newCell1.setCellFormula("A8/B8"); +// //设置打印区域 +// workbook.setPrintArea( +// 0, //工作薄 下标0开始 +// 0, //起始列 下标0开始 +// 20, //终止列 下标0开始 +// 0, //起始行 下标0开始 +// 20 //终止行 下标0开始 +// ); +//// CellStyle style = workbook.createCellStyle(); +//// style.setFillBackgroundColor(); +// +// OutputStream stream = new FileOutputStream(new File("D:\\1.xlsx")); +// workbook.write(stream); +// stream.close(); + + //第一行 + PoiUtilCell blank = new PoiUtilCell(); + PoiUtilCell poiUtilCell = new PoiUtilCell(); + poiUtilCell.setValue("空白"); + poiUtilCell.setColspan(1); + poiUtilCell.setRowspan(2); + PoiUtilCell poiUtilCell1 = new PoiUtilCell(); + poiUtilCell1.setValue("2021.8.31"); + poiUtilCell1.setColspan(2); + poiUtilCell1.setRowspan(1); + PoiUtilCell poiUtilCell3 = new PoiUtilCell(); + poiUtilCell3.setValue("2021.9.1"); + poiUtilCell3.setColspan(2); + poiUtilCell3.setRowspan(1); + //第二行 + PoiUtilCell poiUtilCellTwo1 = new PoiUtilCell(); + poiUtilCellTwo1.setValue(""); + poiUtilCellTwo1.setValue(""); + PoiUtilCell poiUtilCellTwo2 = new PoiUtilCell(); + poiUtilCellTwo2.setValue("早"); + PoiUtilCell poiUtilCellTwo3 = new PoiUtilCell(); + poiUtilCellTwo3.setValue("晚"); + PoiUtilCell poiUtilCellTwo4 = new PoiUtilCell(); + poiUtilCellTwo2.setValue("早"); + PoiUtilCell poiUtilCellTwo5 = new PoiUtilCell(); + poiUtilCellTwo3.setValue("晚"); + //poiUtilCell2.setFunction("SUM(A1:C1)"); + //第三行 + PoiUtilCell poiUtilCellThree1 = new PoiUtilCell(); + poiUtilCellThree1.setValue("张三"); + PoiUtilCell poiUtilCellThree2 = new PoiUtilCell(); + poiUtilCellThree2.setValue("10:43"); + PoiUtilCell poiUtilCellThree3 = new PoiUtilCell(); + poiUtilCellThree3.setValue("20:00"); + + + List cells = new ArrayList<>(); + cells.add(poiUtilCell); + cells.add(poiUtilCell1); + cells.add(blank); + cells.add(poiUtilCell3); + cells.add(blank); + + List cells2 = new ArrayList<>(); + cells2.add(poiUtilCellTwo1); + cells2.add(poiUtilCellTwo2); + cells2.add(poiUtilCellTwo3); + cells2.add(poiUtilCellTwo4); + cells2.add(poiUtilCellTwo5); + + List cells3 = new ArrayList<>(); + cells3.add(poiUtilCellThree1); + cells3.add(poiUtilCellThree2); + cells3.add(poiUtilCellThree3); + + List> list = new ArrayList<>(); + list.add(cells); + list.add(cells2); + list.add(cells3); + + + +// list.add(cells); +// +// List cells1 = new ArrayList<>(); +// cells1.add(new PoiUtilCell("两列一行", 2, 1)); +// list.add(cells1); +// +// List cells2 = new ArrayList<>(); +// cells2.add(new PoiUtilCell("一列两行", 1, 2)); +// list.add(cells2); +// List cells3 = new ArrayList<>(); +// cells3.add(new PoiUtilCell("5")); +// cells3.add(new PoiUtilCell("6")); +// list.add(cells3); +// List cells4 = new ArrayList<>(); +// list.add(cells4); +// List cells5 = new ArrayList<>(); +// cells5.add(new PoiUtilCell("9", 2, 2)); +// cells5.add(new PoiUtilCell("9")); +// list.add(cells5); + String fileName = "zzz/" + cn.hutool.core.date.DateUtil.today() + "/" + System.currentTimeMillis() + ".xlsx"; + String path = WebConstant.UPLOAD_PATH_BASE + fileName; + File tmpFile = new File(path); + if (!tmpFile.getParentFile().exists()) { + tmpFile.getParentFile().mkdirs(); + } + + Workbook wbs = exportWB("Sheet1", list, workbook); + OutputStream stream = new FileOutputStream(tmpFile); + wbs.write(stream); + stream.close(); + + + } + +} diff --git a/util/src/main/java/com/ccsens/util/PropUtil.java b/util/src/main/java/com/ccsens/util/PropUtil.java new file mode 100644 index 0000000..6acbb89 --- /dev/null +++ b/util/src/main/java/com/ccsens/util/PropUtil.java @@ -0,0 +1,135 @@ +package com.ccsens.util; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +/** + * @program: ptpro + * @description: + * @author: wu huijuan + * @create: 2019/10/21 10:37 + */ +@Component +public class PropUtil { + public static String application; + public static String path; + public static String domain; + public static String imgDomain; + public static String projectName; + public static String contextPath; + public static String gatewayUrl; + public static String notGatewayUrl; + public static String qrCode; + public static String wxPrefix; + public static String smsCode; + public static String openWx; + public static String signUpUrl; + public static String gameMqName; + public static String saveWpsFile; + public static String queryVisitUrls; + public static String getWpsFilePath; + public static String accessPath; + public static String filedeal; + public static String wxH5; + /**redis是否需要更新*/ + public static String redisUpdate; + public static String redisUpdateUrl; + public static final String REDIS_UPDATE_YES = "1"; + + public static String queryPowerAddress; + + @Value("${spring.application.name:}") + public void setApplication(String application) { + PropUtil.application = application; + } + @Value("${saveWpsFile:}") + public void setSaveWpsFile(String saveWpsFile) { + PropUtil.saveWpsFile = saveWpsFile; + } + @Value("${queryVisitUrls:}") + public void setQueryVisitUrls(String queryVisitUrls) { + PropUtil.queryVisitUrls = queryVisitUrls; + } + @Value("${getWpsFilePath:}") + public void setGetWpsFilePath(String getWpsFilePath) { + PropUtil.getWpsFilePath = getWpsFilePath; + } + @Value("${gameMqName:}") + public void setGameMqName(String gameMqName) { + PropUtil.gameMqName = gameMqName; + } + @Value("${gatewayUrl:}") + public void setGatewayUrl(String gatewayUrl) { + PropUtil.gatewayUrl = gatewayUrl; + } + @Value("${notGatewayUrl:}") + public void setNotGatewayUrl(String notGatewayUrl) { + PropUtil.notGatewayUrl = notGatewayUrl; + } + @Value("${file.path:}") + public void setPath(String path) { + PropUtil.path = path; + } + @Value("${file.domain:}") + public void setDomain(String domain) { + PropUtil.domain = domain; + } + @Value("${file.imgDomain:}") + public void setImgDomain(String imgDomain) { + PropUtil.imgDomain = imgDomain; + } + @Value("${file.qrCode:}") + public void setQrCode(String qrCode) { + PropUtil.qrCode = qrCode; + } + @Value("${ht.project.name:}") + public void setProjectName(String projectName) { + PropUtil.projectName = projectName; + } + + @Value("${server.servlet.context-path:}") + public void setContextPath(String contextPath) { + PropUtil.contextPath = contextPath; + } + @Value("${wx.prefixUrl:}") + public void setWxPrefix(String wxPrefix) { + PropUtil.wxPrefix = wxPrefix; + } + @Value("${smsCode:}") + public void setSmsCode(String smsCode) { + PropUtil.smsCode = smsCode; + } + @Value("${file.openWX:}") + public void setOpenWx(String openWx) { + PropUtil.openWx = openWx; + } + @Value("${file.signUpUrl:}") + public void setSignUpUrl(String signUpUrl) { + PropUtil.signUpUrl = signUpUrl; + } + + @Value("${accessPath:}") + public void setAccessPath(String accessPath) { + PropUtil.accessPath = accessPath; + } + @Value("${project.filedeal:}") + public void setFiledeal(String filedeal) { + PropUtil.filedeal = filedeal; + } + @Value("${project.redisUpdate:}") + public void setRedisUpdate(String redisUpdate) { + PropUtil.redisUpdate = redisUpdate; + } + @Value("${project.redisUpdateUrl:}") + public void setRedisUpdateUrl(String redisUpdateUrl) { + PropUtil.redisUpdateUrl = redisUpdateUrl; + } + @Value("${project.wx_h5:}") + public static void setWxH5(String wxH5) { + PropUtil.wxH5 = wxH5; + } + @Value("${file.queryPowerAddress:}") + public void setQueryPowerAddress(String queryPowerAddress) { + PropUtil.queryPowerAddress = queryPowerAddress; + } +} diff --git a/util/src/main/java/com/ccsens/util/QrCodeUtil.java b/util/src/main/java/com/ccsens/util/QrCodeUtil.java new file mode 100644 index 0000000..80a67e7 --- /dev/null +++ b/util/src/main/java/com/ccsens/util/QrCodeUtil.java @@ -0,0 +1,118 @@ +package com.ccsens.util; + +import cn.hutool.core.date.DateUtil; +import com.google.zxing.BarcodeFormat; +import com.google.zxing.EncodeHintType; +import com.google.zxing.client.j2se.MatrixToImageWriter; +import com.google.zxing.common.BitMatrix; +import com.google.zxing.qrcode.QRCodeWriter; +import net.glxn.qrgen.core.image.ImageType; +import net.glxn.qrgen.javase.QRCode; + +import java.io.*; +import java.nio.file.FileSystems; +import java.nio.file.Path; +import java.util.HashMap; + +/** + * 二维码工具类 + * @author: wuHuiJuan + * @create: 2019/12/25 10:36 + */ +public class QrCodeUtil { + + + + /** + * 根据文件路径生成二维码 + * @param url + * @param parentPath + * @return + * @throws IOException + */ + public static String urlToQRCode(String url, String parentPath) throws IOException { + String fileName = "qrCode/" + DateUtil.today() + "/" + System.currentTimeMillis() + ".png"; + ByteArrayOutputStream stream = QRCode.from(url).to(ImageType.BMP).withSize(500,500).stream(); + byte[] codeByte = stream.toByteArray(); + File file = new File(parentPath, fileName); + if (!file.getParentFile().exists()) { + file.getParentFile().mkdirs(); + } + OutputStream out = null; + try { + out = new FileOutputStream(file); + out.write(codeByte); + out.flush(); + } finally { + if ( out!= null) { + out.close(); + } + } + return fileName; + } + + + /** + * 根据文件路径生成二维码(可以调整大小) + * @param url + * @param parentPath + * @param type 图片类型。0缩略图 1打印图 + * @return + * @throws IOException + */ + public static String urlToQRCodeWithSize(String url, String parentPath,int type) throws IOException { + String name = System.currentTimeMillis()+""; + int size = 200; + if(type == 0){ + name = "缩略图"; + size = 200; + }else if(type == 1){ + name = "打印图"; + size = 1000; + } + String fileName = name + ".png"; + ByteArrayOutputStream stream = QRCode.from(url).to(ImageType.BMP).withSize(size,size).stream(); + byte[] codeByte = stream.toByteArray(); + File file = new File(parentPath, fileName); + if (!file.getParentFile().exists()) { + file.getParentFile().mkdirs(); + } + OutputStream out = null; + try { + out = new FileOutputStream(file); + out.write(codeByte); + out.flush(); + } finally { + if ( out!= null) { + out.close(); + } + } + return fileName; + } + + + /** + * 生成二位吗(utf-8) + * @return 返回文件位置(不带前缀) + */ + public static String getQrCodeWithUtf8(String value, String filePath) throws Exception { + + //文件地址 + String fileName = "qrCode/" + DateUtil.today() + "/" + System.currentTimeMillis() + ".png"; + + QRCodeWriter qrCodeWriter = new QRCodeWriter(); + HashMap hints = new HashMap<>(); + hints.put(EncodeHintType.CHARACTER_SET, "utf-8"); + BitMatrix bitMatrix =qrCodeWriter.encode(value, BarcodeFormat.QR_CODE, 1000, 1000,hints); + File file = new File(filePath, fileName); + if (!file.getParentFile().exists()) { + file.getParentFile().mkdirs(); + } + Path path = FileSystems.getDefault().getPath(filePath + fileName); + + MatrixToImageWriter.writeToPath(bitMatrix, "PNG", path); + + return fileName; + } + +} diff --git a/util/src/main/java/com/ccsens/util/RedisKeyManager.java b/util/src/main/java/com/ccsens/util/RedisKeyManager.java new file mode 100644 index 0000000..33cabfb --- /dev/null +++ b/util/src/main/java/com/ccsens/util/RedisKeyManager.java @@ -0,0 +1,24 @@ +package com.ccsens.util; + +public class RedisKeyManager { + public static String getTokenCachedKey(Object key){ + return key + "_t"; + } + + public static String getRefreshTokenCachedKey(Object key){ + return key + "_r"; + } + public static String getSmsKey(Long authId){ + return "sms_" + authId; + } + public static String getSmsExistKey(Long authId){ + return "sms_exist_" + authId; + } + + public static String getSigninSmsKey(String phone){ + return "sms_signin_" + phone; + } + public static String getSigninSmsExistKey(String phone){ + return "sms_signin_exist_" + phone; + } +} diff --git a/util/src/main/java/com/ccsens/util/RedisUtil.java b/util/src/main/java/com/ccsens/util/RedisUtil.java new file mode 100644 index 0000000..8c3709b --- /dev/null +++ b/util/src/main/java/com/ccsens/util/RedisUtil.java @@ -0,0 +1,769 @@ +package com.ccsens.util; + +import cn.hutool.core.util.ObjectUtil; +import lombok.extern.slf4j.Slf4j; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.data.redis.core.ZSetOperations; +import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; + +import javax.annotation.Resource; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.TimeUnit; +@Slf4j +@Component +public class RedisUtil { + @Resource + private RedisTemplate redisTemplate; + + /** + * 指定缓存失效时间 + * + * @param key 键 + * @param time 时间(秒) + * @return + */ + public boolean expire(String key, long time) { + try { + if (time > 0) { + redisTemplate.expire(key, time, TimeUnit.SECONDS); + } + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * 普通缓存放入 + * + * @param key 键 + * @param value 值 + * @return true成功 false失败 + */ + public boolean setNx(String key, Object value) { + try { + return redisTemplate.opsForValue().setIfAbsent(key, value); + } catch (Exception e) { + e.printStackTrace(); + return false; + } + + } + /** + * 普通缓存放入并设置时间 + * + * @param key 键 + * @param value 值 + * @param seconds 时间(秒) time要大于0 如果time小于等于0 将设置无限期 + * @return true成功 false 失败 + */ + public boolean setNx(String key, Object value, long seconds) { + try { + if (seconds > 0) { + return redisTemplate.opsForValue().setIfAbsent(key, value, seconds, TimeUnit.SECONDS); + } else { + return setNx(key, value); + } + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * 根据key 获取过期时间 + * + * @param key 键 不能为null + * @return 时间(秒) 返回0代表为永久有效 + */ + public long getExpire(String key) { + return redisTemplate.getExpire(key, TimeUnit.SECONDS); + } + + /** + * 判断key是否存在 + * + * @param key 键 + * @return true 存在 false不存在 + */ + public boolean hasKey(String key) { + try { + return redisTemplate.hasKey(key); + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * 删除缓存 + * + * @param key 可以传一个值 或多个 + */ + @SuppressWarnings("unchecked") + public void del(String... key) { + if (key != null && key.length > 0) { + if (key.length == 1) { + redisTemplate.delete(key[0]); + } else { + redisTemplate.delete(CollectionUtils.arrayToList(key)); + } + } + } + + //============================String============================= + + /** + * 普通缓存获取 + * + * @param key 键 + * @return 值 + */ + public Object get(String key) { + return key == null ? null : redisTemplate.opsForValue().get(key); + } + + /** + * 普通缓存放入 + * + * @param key 键 + * @param value 值 + * @return true成功 false失败 + */ + public boolean set(String key, Object value) { + try { + redisTemplate.opsForValue().set(key, value); + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + + } + + /** + * 普通缓存放入并设置时间 + * + * @param key 键 + * @param value 值 + * @param seconds 时间(秒) time要大于0 如果time小于等于0 将设置无限期 + * @return true成功 false 失败 + */ + public boolean set(String key, Object value, long seconds) { + try { + if (seconds > 0) { + redisTemplate.opsForValue().set(key, value, seconds, TimeUnit.SECONDS); + } else { + set(key, value); + } + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * 递增 + * + * @param key 键 + * @param delta 要增加几(大于0) + * @return + */ + public long incr(String key, long delta) { + if (delta < 0) { + throw new RuntimeException("递增因子必须大于0"); + } + return redisTemplate.opsForValue().increment(key, delta); + } + + /** + * 递减 + * + * @param key 键 + * @param delta 要减少几(小于0) + * @return + */ + public long decr(String key, long delta) { + if (delta < 0) { + throw new RuntimeException("递减因子必须大于0"); + } + return redisTemplate.opsForValue().increment(key, -delta); + } + + //================================Map================================= + + /** + * HashGet + * + * @param key 键 不能为null + * @param item 项 不能为null + * @return 值 + */ + public Object hget(String key, String item) { + return redisTemplate.opsForHash().get(key, item); + } + + /** + * 获取hashKey对应的所有键值 + * + * @param key 键 + * @return 对应的多个键值 + */ + public Map hmget(String key) { + return redisTemplate.opsForHash().entries(key); + } + + /** + * HashSet + * + * @param key 键 + * @param map 对应多个键值 + * @return true 成功 false 失败 + */ + public boolean hmset(String key, Map map) { + try { + redisTemplate.opsForHash().putAll(key, map); + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * HashSet 并设置时间 + * + * @param key 键 + * @param map 对应多个键值 + * @param time 时间(秒) + * @return true成功 false失败 + */ + public boolean hmset(String key, Map map, long time) { + try { + redisTemplate.opsForHash().putAll(key, map); + if (time > 0) { + expire(key, time); + } + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * 向一张hash表中放入数据,如果不存在将创建 + * + * @param key 键 + * @param item 项 + * @param value 值 + * @return true 成功 false失败 + */ + public boolean hset(String key, String item, Object value) { + try { + redisTemplate.opsForHash().put(key, item, value); + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * 向一张hash表中放入数据,如果不存在将创建 + * + * @param key 键 + * @param item 项 + * @param value 值 + * @param time 时间(秒) 注意:如果已存在的hash表有时间,这里将会替换原有的时间 + * @return true 成功 false失败 + */ + public boolean hset(String key, Object item, Object value, long time) { + log.info("存hash:{}:{}:{}:{}",key,item,value,time); + try { + redisTemplate.opsForHash().put(key, item, value); + if (time > 0) { + expire(key, time); + } + log.info("存hash成功:{}:{}:{}:{}",key,item,value,time); + return true; + } catch (Exception e) { + log.error("存hash异常",e); + e.printStackTrace(); + return false; + } + } + + /** + * 删除hash表中的值 + * + * @param key 键 不能为null + * @param item 项 可以使多个 不能为null + */ + public void hdel(String key, Object... item) { + redisTemplate.opsForHash().delete(key, item); + } + + /** + * 判断hash表中是否有该项的值 + * + * @param key 键 不能为null + * @param item 项 不能为null + * @return true 存在 false不存在 + */ + public boolean hHasKey(String key, String item) { + return redisTemplate.opsForHash().hasKey(key, item); + } + + /** + * hash递增 如果不存在,就会创建一个 并把新增后的值返回 + * + * @param key 键 + * @param item 项 + * @param by 要增加几(大于0) + * @return + */ + public double hincr(String key, String item, double by) { + return redisTemplate.opsForHash().increment(key, item, by); + } + + /** + * hash递减 + * + * @param key 键 + * @param item 项 + * @param by 要减少记(小于0) + * @return + */ + public double hdecr(String key, String item, double by) { + return redisTemplate.opsForHash().increment(key, item, -by); + } + + //============================set============================= + + /** + * 根据key获取Set中的所有值 + * + * @param key 键 + * @return + */ + public Set sGet(String key) { + try { + return redisTemplate.opsForSet().members(key); + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + + /** + * 根据value从一个set中查询,是否存在 + * + * @param key 键 + * @param value 值 + * @return true 存在 false不存在 + */ + public boolean sHasKey(String key, Object value) { + try { + return redisTemplate.opsForSet().isMember(key, value); + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * 将数据放入set缓存 + * + * @param key 键 + * @param values 值 可以是多个 + * @return 成功个数 + */ + public long sSet(String key, Object... values) { + try { + return redisTemplate.opsForSet().add(key, values); + } catch (Exception e) { + e.printStackTrace(); + return 0; + } + } + + /** + * 将set数据放入缓存 + * + * @param key 键 + * @param time 时间(秒) + * @param values 值 可以是多个 + * @return 成功个数 + */ + public long sSetAndTime(String key, long time, Object... values) { + try { + Long count = redisTemplate.opsForSet().add(key, values); + if (time > 0) expire(key, time); + return count; + } catch (Exception e) { + e.printStackTrace(); + return 0; + } + } + + /** + * 获取set缓存的长度 + * + * @param key 键 + * @return + */ + public long sGetSetSize(String key) { + try { + return redisTemplate.opsForSet().size(key); + } catch (Exception e) { + e.printStackTrace(); + return 0; + } + } + + /** + * 移除值为value的 + * + * @param key 键 + * @param values 值 可以是多个 + * @return 移除的个数 + */ + public long setRemove(String key, Object... values) { + try { + Long count = redisTemplate.opsForSet().remove(key, values); + return count; + } catch (Exception e) { + e.printStackTrace(); + return 0; + } + } + //===============================list================================= + + /** + * 获取list缓存的内容 + * + * @param key 键 + * @param start 开始 + * @param end 结束 0 到 -1代表所有值 + * @return + */ + public List lGet(String key, long start, long end) { + try { + return redisTemplate.opsForList().range(key, start, end); + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + + /** + * 获取list缓存的长度 + * + * @param key 键 + * @return + */ + public long lGetListSize(String key) { + try { + return redisTemplate.opsForList().size(key); + } catch (Exception e) { + e.printStackTrace(); + return 0; + } + } + + /** + * 通过索引 获取list中的值 + * + * @param key 键 + * @param index 索引 index>=0时, 0 表头,1 第二个元素,依次类推;index<0时,-1,表尾,-2倒数第二个元素,依次类推 + * @return + */ + public Object lGetIndex(String key, long index) { + try { + return redisTemplate.opsForList().index(key, index); + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + + /** + * 将list放入缓存 + * + * @param key 键 + * @param value 值 + * @return + */ + public boolean lSet(String key, Object value) { + try { + redisTemplate.opsForList().rightPush(key, value); + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * 将list放入缓存 + * + * @param key 键 + * @param value 值 + * @param time 时间(秒) + * @return + */ + public boolean lSet(String key, Object value, long time) { + try { + redisTemplate.opsForList().rightPush(key, value); + if (time > 0) { + expire(key, time); + } + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * 将list放入缓存 + * + * @param key 键 + * @param value 值 + * @return + */ + public boolean lSet(String key, List value) { + try { + redisTemplate.opsForList().rightPushAll(key, value); + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * 将list放入缓存 + * + * @param key 键 + * @param value 值 + * @param time 时间(秒) + * @return + */ + public boolean lSet(String key, List value, long time) { + try { + redisTemplate.opsForList().rightPushAll(key, value); + if (time > 0) { + expire(key, time); + } + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * 根据索引修改list中的某条数据 + * + * @param key 键 + * @param index 索引 + * @param value 值 + * @return + */ + public boolean lUpdateIndex(String key, long index, Object value) { + try { + redisTemplate.opsForList().set(key, index, value); + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * 移除N个值为value + * + * @param key 键 + * @param count 移除多少个 + * @param value 值 + * @return 移除的个数 + */ + public long lRemove(String key, long count, Object value) { + try { + Long remove = redisTemplate.opsForList().remove(key, count, value); + return remove; + } catch (Exception e) { + e.printStackTrace(); + return 0; + } + } + + /** + * 移除列表的最后一个值 + * @param key 键 + */ + public Object lRemoveLast(String key) { + try { + Object o = redisTemplate.opsForList().leftPop(key); + return o; + } catch (Exception e) { + e.printStackTrace(); + return 0; + } + } + + //===============================zset================================= + /** + * 获取sort set缓存的内容 + * @author whj + * @date 2019/8/1 + * @param key + * @param small 起始分数 + * @param max 结束分数 + * @return java.util.Set + */ + public Set zsGetByScore(String key, double small, double max) { + return redisTemplate.opsForZSet().rangeByScore(key, small, max); + } + + /** + * 获取sort set缓存的内容 + * @author whj + * @date 2019/8/1 + * @param key + * @param start 开始 0:第一个元素 + * @param end 结束 -1:代表所有 + * @return java.util.Set + */ + public Set zsGet(String key, long start, long end) { + return redisTemplate.opsForZSet().range(key, start, end); + } + + /** + * 获取sort set缓存的内容(包含分数) + * @author whj + * @date 2019/8/1 + * @param key + * @param start 开始 0:第一个元素 + * @param end 结束 -1:代表所有 + * @return java.util.Set> + */ + public Set> zsGetWithScore(String key, long start, long end) { + return redisTemplate.opsForZSet().rangeWithScores(key, start, end); + } + + /** + * 分数由高到低 获取sort set缓存的内容 + * @author whj + * @date 2019/8/1 + * @param key + * @param start 开始 0:第一个元素 + * @param end 结束 -1:代表所有 + * @return java.util.Set + */ + public Set zsRevGet(String key, long start, long end) { + return redisTemplate.opsForZSet().reverseRange(key, start, end); + } + + /** + * 分数由高到低 获取sort set缓存的内容(包含分数) + * @author whj + * @date 2019/8/1 + * @param key + * @param start 开始 0:第一个元素 + * @param end 结束 -1:代表所有 + * @return java.util.Set> + */ + public Set> zsRevGetWithScore(String key, long start, long end) { + return redisTemplate.opsForZSet().reverseRangeWithScores(key, start, end); + } + + /** + * 添加zset + * @author whj + * @date 2019/8/1 + * @param key + * @param value + * @param score + * @return boolean + */ + public boolean zsSet(String key, Object value, double score) { + return redisTemplate.opsForZSet().add(key, value, score); + } + + /** + * 添加zset + * @author whj + * @date 2019/8/1 + * @param key + * @param value + * @param score + * @return boolean + */ + public boolean zsSet(String key, Object value, double score, long time) { + redisTemplate.opsForZSet().add(key, value, score); + if (time > 0) { + expire(key, time); + } + return true; + } + + /** + * 获取zset长度 + * @author whj + * @date 2019/8/1 + * @param key + * @return + */ + public Long zsGetSize(String key) { + return redisTemplate.opsForZSet().size(key); + } + + /** + * 删除元素 + * @param key + * @param values + * @return + */ + public Long zsDel(String key, Object... values) { + return redisTemplate.opsForZSet().remove(key, values); + } + + /** + * 获取对应分数 + * @param key + * @param value + * @return + */ + public Object zsGetScore(String key, Object value) { + return redisTemplate.opsForZSet().score(key, value); + } + + /** + * 查询排第几 + * @param key + * @param value + * @return + */ + public Long zsRank(String key, Object value) { + return redisTemplate.opsForZSet().rank(key, value); + } + + /** + * 查询倒叙排第几 + * @param key + * @param value + * @return + */ + public Long zsReverseRank(String key, Object value) { + return redisTemplate.opsForZSet().reverseRank(key, value); + } + +} diff --git a/util/src/main/java/com/ccsens/util/RestTemplateUtil.java b/util/src/main/java/com/ccsens/util/RestTemplateUtil.java new file mode 100644 index 0000000..c976625 --- /dev/null +++ b/util/src/main/java/com/ccsens/util/RestTemplateUtil.java @@ -0,0 +1,207 @@ +package com.ccsens.util; + +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.ccsens.util.exception.BaseException; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.annotation.Order; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Component; +import org.springframework.util.LinkedMultiValueMap; +import org.springframework.util.MultiValueMap; +import org.springframework.web.client.RestTemplate; + +import javax.annotation.PostConstruct; +import javax.annotation.Resource; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.List; +import java.util.Map; + +@Slf4j +@Component +public class RestTemplateUtil { + + @Resource + private RestTemplate restTemplate; + + private static RestTemplateUtil util; + + @PostConstruct + public void init(){ + util = this; + util.restTemplate = this.restTemplate; + if (PropUtil.REDIS_UPDATE_YES.equals(PropUtil.redisUpdate)) { + String result = postUrlEncode(PropUtil.redisUpdateUrl + PropUtil.application, null); + log.info("更新缓存结果:{}", result); + } + } + + public static Object getForEntity(String url, Map params, Class returnClass) { + + if (params != null && !params.isEmpty()) { + if (!url.contains("?")) { + url += "?"; + } + for (String key : params.keySet()) { + if (url.endsWith("?")) { + url += key + "="+params.get(key)+""; + } else { + url += "&" + key + "="+params.get(key)+""; + } + } + } + log.info("url:{}, params:{}", url, params); + ResponseEntity entity = util.restTemplate.getForEntity(url, String.class); + log.info("entity:{}",entity); +// return entity; + return JSONObject.parseObject(entity.getBody(), returnClass); + } + + public static String postBody(String url, Object params) { + log.info("路径:{}, 参数:{}", url, params); + HttpHeaders httpHeaders = new HttpHeaders(); + MediaType type=MediaType.parseMediaType("application/json;charset=UTF-8"); + httpHeaders.setContentType(type); + +// MultiValueMap map=new LinkedMultiValueMap<>(); + + JSONObject json = JSON.parseObject(JSON.toJSONString(params)); + HttpEntity> objectHttpEntity = new HttpEntity<>(json,httpHeaders); + URI uri = null; + try { + uri = new URI(url); + }catch (URISyntaxException e) { + log.error("转换路径异常:{}", e); + throw new BaseException(CodeEnum.URL_ERROR); + } + + ResponseEntity response = util.restTemplate.postForEntity(uri, objectHttpEntity, String.class); + log.info("返回:{}", response); + return response.getBody(); + } + + public static String postBodySpecialHeader(String url, Object params, Map headMap) { + log.info("路径:{}, 参数:{}", url, params); + HttpHeaders httpHeaders = new HttpHeaders(); + MediaType type=MediaType.parseMediaType("application/json;charset=UTF-8"); + httpHeaders.setContentType(type); + if (CollectionUtil.isNotEmpty(headMap)) { + for (Map.Entry entry: headMap.entrySet()) { + httpHeaders.set(entry.getKey(), entry.getValue()); + } + } + +// MultiValueMap map=new LinkedMultiValueMap<>(); + + JSONObject json = JSON.parseObject(JSON.toJSONString(params)); + HttpEntity> objectHttpEntity = new HttpEntity<>(json,httpHeaders); + URI uri = null; + try { + uri = new URI(url); + }catch (URISyntaxException e) { + log.error("转换路径异常:{}", e); + throw new BaseException(CodeEnum.URL_ERROR); + } + log.info("uri:{}",uri); + log.info("json:{}",json); + log.info("objectHttpEntity:{}",objectHttpEntity); + + ResponseEntity response = util.restTemplate.postForEntity(uri, objectHttpEntity, String.class); + log.info("返回:{}", response); + return response.getBody(); + } + + public static String postBody1(String url, List params) { + log.info("路径:{}, 参数:{}", url, params); + HttpHeaders httpHeaders = new HttpHeaders(); + MediaType type=MediaType.parseMediaType("application/json;charset=UTF-8"); + httpHeaders.setContentType(type); + +// MultiValueMap map=new LinkedMultiValueMap<>(); + +// JSONObject json = JSON.parseObject(JSON.toJSONString(params)); + + + HttpEntity> objectHttpEntity = new HttpEntity<>(params,httpHeaders); + URI uri = null; + try { + uri = new URI(url); + }catch (URISyntaxException e) { + log.error("转换路径异常:{}", e); + throw new BaseException(CodeEnum.URL_ERROR); + } + + ResponseEntity response = util.restTemplate.postForEntity(uri, objectHttpEntity, String.class); + log.info("返回:{}", response); + return response.getBody(); + } + public static String postUrlEncode(String url, Object params) { + log.info("请求路径:{},请求参数:{}", url, params); + MultiValueMap paramMap; + if (params == null) { + paramMap = new LinkedMultiValueMap<>(); + } else { + JSONObject json = JSON.parseObject(JSON.toJSONString(params)); + paramMap = transMultiValueMap(json); + } + + HttpHeaders headers = new HttpHeaders(); + headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); + HttpEntity formEntity = new HttpEntity<>(paramMap, headers); + ResponseEntity result = util.restTemplate.postForEntity(url, formEntity, String.class); + log.info("接口返回结果:{}", result); + return result.getBody(); + } + + /** + * 发送multipart/form-data + * @author whj + * @date 2019/8/20 + * @param url + * @param params + * @return com.alibaba.fastjson.JSONObject + */ + public static JSONObject postImg(String url, JSONObject params) { + log.info("请求路径:{},请求参数:{}", url, params); + HttpHeaders headers = new HttpHeaders(); + headers.add("Accept", MediaType.APPLICATION_JSON.toString()); + headers.setContentType(MediaType.MULTIPART_FORM_DATA); + MultiValueMap paramMap = transMultiValueMap(params); + HttpEntity formEntity = new HttpEntity<>(paramMap, headers); + JSONObject result = util.restTemplate.postForObject(url, formEntity, JSONObject.class); + log.info("接口返回结果:{}", result); + return result; + } + + /** + * 将参数封装成MultiValueMap对象 + * @author whj + * @date 2019/8/20 + * @param params + * @return org.springframework.util.MultiValueMap + */ + private static MultiValueMap transMultiValueMap(JSONObject params) { + MultiValueMap paramMap = new LinkedMultiValueMap<>(); + for (String key: params.keySet()) { + paramMap.add(key, params.get(key)); + } + return paramMap; + } + + public static boolean pageResult(String result) { + if (StrUtil.isBlank(result) || result.contains(" parseSQL(InputStream inputStream){ + return getSql(getText(inputStream)); + } + + /* + * getText方法吧path路径里面的文件按行读数来放入一个大的String里面去 + * 并在换行的时候加入\r\n + */ + private static String getText(InputStream inputStream){ + StringBuilder sb = new StringBuilder(); + try{ + InputStreamReader isr = new InputStreamReader(inputStream,"UTF-8"); + BufferedReader br = new BufferedReader(isr); + String temp = null; + temp = br.readLine(); + while(temp!=null){ + if(temp.length()>=2){ + String str1 = temp.substring(0, 1); + String str2 = temp.substring(0, 2); + if(str1.equals("#")||str2.equals("--")||str2.equals("/*")||str2.equals("//")){ + temp = br.readLine(); + continue; + } + sb.append(temp+"\r\n"); + } + + temp = br.readLine(); + } + br.close(); + + }catch(Exception e){ + e.printStackTrace(); + } + return sb.toString(); + } + /* + * getSqlArray方法 + * 从文件的sql字符串中分析出能够独立执行的sql语句并返回 + */ + private static List getSql(String sql){ + String s = sql; + s = s.replaceAll("\r\n", "\r"); + s = s.replaceAll("\r", "\n"); + List ret = new ArrayList(); + String[] sqlarry = s.split(";"); //用;把所有的语句都分开成一个个单独的句子 + sqlarry = filter(sqlarry); + ret = Arrays.asList(sqlarry); + return ret; + } + + private static String[] filter(String[] ss){ + List strs = new ArrayList(); + for(String s : ss){ + if(s!=null&&!s.trim().equals("")){ + strs.add(s); + } + } + String[] result = new String[strs.size()]; + for(int i=0; i 0) { + digest.update(buffer, 0, len); + } + String sha1 = new BigInteger(1, digest.digest()).toString(16); + int length = 40 - sha1.length(); + if (length > 0) { + for (int i = 0; i < length; i++) { + sha1 = "0" + sha1; + } + } + str = sha1; + } catch (Exception e) { + System.out.println(e); + } finally { + try { + if (in != null) { + in.close(); + } + } catch (Exception e) { + System.out.println(e); + } + } + return str; + } + +// public static void main(String args[]) { +// String path = "D:\\home\\btpro\\uploads\\delivers\\20190509\\fc3d9e330c75414d96ebadaac0294fdc.pdf"; +// String path1 = "C:\\Users\\逗\\Desktop\\测试.pdf"; +// File file = new File(path); +// File file1 = new File(path1); +// +// System.out.println(getFileSha1(file)); +// System.out.println(getFileSha1(file1)); +// } +} diff --git a/util/src/main/java/com/ccsens/util/ShiroKit.java b/util/src/main/java/com/ccsens/util/ShiroKit.java new file mode 100644 index 0000000..75cea6d --- /dev/null +++ b/util/src/main/java/com/ccsens/util/ShiroKit.java @@ -0,0 +1,73 @@ +/** + * Copyright (c) 2015-2017, Chill Zhuang 庄骞 (smallchill@163.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.ccsens.util; + +import org.apache.shiro.crypto.hash.Md5Hash; +import org.apache.shiro.crypto.hash.SimpleHash; +import org.apache.shiro.util.ByteSource; + +import java.security.NoSuchAlgorithmException; +import java.security.spec.InvalidKeySpecException; + + +/** + * shiro工具类 + * + * @author dafei, Chill Zhuang + */ +public class ShiroKit { + + private static final String NAMES_DELIMETER = ","; + + /** + * 加盐参数 + */ + public final static String hashAlgorithmName = "MD5"; + + /** + * 循环次数 + */ + public final static int hashIterations = 1024; + + /** + * shiro密码加密工具类 + * + * @param credentials 密码 + * @param saltSource 密码盐 + * @return + */ + public static String md5(String credentials, String saltSource) { + ByteSource salt = new Md5Hash(saltSource); + return new SimpleHash(hashAlgorithmName, credentials, salt, hashIterations).toString(); + } + + /** + * 获取随机盐值 + * @param length + * @return + */ + public static String getRandomSalt(int length) { + return ToolUtil.getRandomString(length); + } + + public static boolean authenticate(String attemptedPassword, String encryptedPassword, String salt) + throws NoSuchAlgorithmException, InvalidKeySpecException { + // 用相同的盐值对用户输入的密码进行加密 + String encryptedAttemptedPassword = md5(attemptedPassword, salt); + // 把加密后的密文和原密文进行比较,相同则验证成功,否则失败 + return encryptedAttemptedPassword.equals(encryptedPassword); + } +} diff --git a/util/src/main/java/com/ccsens/util/SmsUtil.java b/util/src/main/java/com/ccsens/util/SmsUtil.java new file mode 100644 index 0000000..ef6c4ca --- /dev/null +++ b/util/src/main/java/com/ccsens/util/SmsUtil.java @@ -0,0 +1,58 @@ +package com.ccsens.util; + +import cn.hutool.core.util.RandomUtil; +import cn.hutool.json.JSONException; +import com.github.qcloudsms.SmsSingleSender; +import com.github.qcloudsms.SmsSingleSenderResult; +import com.github.qcloudsms.httpclient.HTTPException; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +import java.io.IOException; +@Slf4j +@Component +public class SmsUtil { + // 1400开头 + private static final int appid = 1400188778; + private static final String appkey = "c86ca104521ab2e28e1d4b558fdd665e"; + /** + * {1} 验证码{1}, 您正在通过{2}登录传控科技“时物链条”会议管理系统,请与{3}分钟内填写,如非本人操作,请忽略本短信。\ + */ + private static final int templateId = 286731; + /** + * {1} 您正在通过{2}登录传控科技“时物链条”会议管理系统,请与{2}分钟内填写,如非本人操作,请忽略本短信。 + */ + private static final int templateId1 = 286682; + /**验证码{1},{2}分钟内有效,如非本人操作请忽略 + * + */ + private static final int templateId2 = 686476; + private static final String smsSign = "传控科技"; + + public static void sendSms(String phone,String code,String appName,Integer seconds){ + String phoneNumbers[] = {phone}; + Integer minutes = (seconds - 1) / 60 + 1; + try { + //数组具体的元素个数和模板中变量个数必须一致,例如事例中templateId:5678对应一个变量,参数数组中元素个数也必须是一个 + String[] params = {code,String.valueOf(minutes)}; + SmsSingleSender ssender = new SmsSingleSender(appid, appkey); + // 签名参数未提供或者为空时,会使用默认签名发送短信 + SmsSingleSenderResult result = ssender.sendWithParam("86", phoneNumbers[0], + templateId2, params, smsSign, "", ""); + log.info(String.valueOf(result)); + } catch (HTTPException e) { + // HTTP响应码错误 + e.printStackTrace(); + } catch (JSONException e) { + // json解析错误 + e.printStackTrace(); + } catch (IOException e) { + // 网络IO错误 + e.printStackTrace(); + } + } + + public static String generateRandomSmsCode(int length){ + return RandomUtil.randomNumbers(4); + } +} diff --git a/util/src/main/java/com/ccsens/util/SpringContextUtils.java b/util/src/main/java/com/ccsens/util/SpringContextUtils.java new file mode 100644 index 0000000..3fc8362 --- /dev/null +++ b/util/src/main/java/com/ccsens/util/SpringContextUtils.java @@ -0,0 +1,69 @@ +package com.ccsens.util; + +import org.springframework.beans.BeansException; +import org.springframework.context.ApplicationContext; +import org.springframework.context.ApplicationContextAware; +import org.springframework.stereotype.Component; + +/** + * Author:__zHangSan + * Date:2017/11/8 10:00 + * Description: + * Get Bean which is mananered by spring container + */ +@Component +public class SpringContextUtils implements ApplicationContextAware { + + /** + * 上下文对象实例 + */ + private static ApplicationContext applicationContext; + + @Override + public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { + this.applicationContext = applicationContext; + } + + /** + * 获取applicationContext + * + * @return + */ + public static ApplicationContext getApplicationContext() { + return applicationContext; + } + + /** + * 通过name获取 Bean. + * + * @param name + * @return + */ + public static Object getBean(String name) { + return getApplicationContext().getBean(name); + } + + /** + * 通过class获取Bean. + * + * @param clazz + * @param + * @return + */ + public static T getBean(Class clazz) { + return getApplicationContext().getBean(clazz); + } + + /** + * 通过name,以及Clazz返回指定的Bean + * + * @param name + * @param clazz + * @param + * @return + */ + public static T getBean(String name, Class clazz) { + return getApplicationContext().getBean(name, clazz); + } +} + diff --git a/util/src/main/java/com/ccsens/util/StringUtil.java b/util/src/main/java/com/ccsens/util/StringUtil.java new file mode 100644 index 0000000..c2d39a9 --- /dev/null +++ b/util/src/main/java/com/ccsens/util/StringUtil.java @@ -0,0 +1,264 @@ +package com.ccsens.util; + +import cn.hutool.core.util.StrUtil; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class StringUtil { + + public final static String SPLIT_RANGE = "[到\\-至]"; + public final static String SPLIT = "-"; + public final static String WEEK_DAY = "(每?隔\\d周)|(每?隔\\d星期)|(每?周[0-7]+)|(每?星期[0-7]+)|(每?周一)|(每?周二)|(每?周三)|(每?周四)|(每?周五)|(每?周六)|(每?周日)|(每?周天)"; + public final static String WEEK_DAY_CIRCLE = WEEK_DAY+SPLIT_RANGE+WEEK_DAY; + public final static String DAY = "(每\\d+天)|(每\\d+日)|(每?隔\\d+天)|(每?隔\\d+日)|(\\d+号)|(\\d+日)|(\\d+\\-\\d+号)|(\\d+\\-\\d+日)|(\\d+到\\d+号)|(\\d+到\\d+日)"; + + + public final static String CONTINUE_RANGE = ".*(到|\\-|至).*"; + public final static String EVERY = "每(天|日|小时|时|分钟|分|秒)"; + public final static String EVERY_WEEK = "每(周|星期)"; + + public final static String EVERY_MONTH = "每月"; + public final static String EVERY_NUM = "\\D*(\\d+)\\D*"; + public final static String CHINESE_NUM = "([零一二三四五六七八九十百千万亿]+)"; + + public final static String SECOND_REGEXP = "(每\\d*秒钟)|(\\d*秒)|(\\d+\\-\\d+秒钟?)"; + public final static String MINUTE_REGEXP = "(每\\d*分钟)|(\\d*分)|(\\d+\\-\\d+分钟?)"; + public final static String HOUR_REGEXP = "(每隔?\\d*小?时)|(\\d+\\-\\d+小?时)|(\\d*点)|(\\d*时)"; + public final static String DAY_REGEXP = "(每天)|(每日)|" + DAY; + public final static String MONTH_REGEXP = EVERY_MONTH +"|(每隔\\d+月)|(\\d+月)|(每隔[零一二三四五六七八九十百千万亿]+月)|([零一二三四五六七八九十百千万亿]+月)"; + + public final static String WEEK_REGEXP = "(每?周[0-7]"+SPLIT_RANGE+"每?周[0-7])|" + WEEK_DAY + "|(每周)|(每星期)"; + public final static String WEEK_FLAG_REGEXP = "(每?周)|(每?星期)"; + + public final static String NO_REPEAT = "不重复"; + + + + + public final static String NUMBER = "\\d+"; + + private static final String NUMBER_FORMAT = "^[-\\+]?\\d+$"; + public static final String NUMBER_DOUBLE = "([1-9]+[0-9]*|0)(\\.[\\d]+)?"; + private static final String SEX_FORMAT = "^[01]$"; + + /** + *@Description:判断文本是否为数字格式 + * @param str 待判断文本 + * @param allowBlank 是否允许为空 true:允许 false:不允许 + *@return: boolean + *@Author: wuhuijuan + *@date: 2019/10/23 11:07 + */ + public static boolean checkNum(String str, boolean allowBlank) { + if (StringUtil.isEmpty(str)) { + return allowBlank ; + } + Pattern pattern = Pattern.compile(NUMBER_FORMAT); + Matcher matcher = pattern.matcher(str); + return matcher.matches(); + } + +// public static void main(String[] args) { +//// matchSingle("每天5分", MINUTE_REGEXP); +//// +//// String[] split = "a至b".split("[到\\-至]"); +//// for (String s: split) { +//// System.out.println("split:" + s); +//// } +//// System.out.println(isMatch("3到5",CONTINUE_RANGE)); +//// System.out.println("------------------------------------------------" + (null + "hello wold")); +//// match("3-5小时", "(每隔?\\d*小?时)|(\\d+\\-\\d+小?时)|(\\d*点)|(\\d*时)"); +// +//// System.out.println(isMatch("每周一5点", EVERY_WEEK_MORE)); +//// System.out.println(isMatch("每周5点", EVERY_WEEK_MORE)); +// System.out.println(matchSingle("第一百零三个", CHINESE_NUM)); +// } + + + + + + + public static int transNum(String str) { + String numStr = str; + + return Integer.parseInt(numStr); + } + + + + + public static String matchSingle(String source, String regexp) { + Pattern pattern = Pattern.compile(regexp); + Matcher matcher = pattern.matcher(source); + while (matcher.find()) { + return matcher.group(1); + } + return null; + + } + + + public static boolean isMatch(String source, String regexp) { + Pattern pattern = Pattern.compile(regexp); + Matcher matcher = pattern.matcher(source); + return matcher.matches(); + + } + public static List match(String source, String regexp) { + Pattern pattern = Pattern.compile(regexp); + Matcher matcher = pattern.matcher(source); + List list = new ArrayList<>(); + while (matcher.find()) { + + for (int index = 1; index <= matcher.groupCount(); index++) { + list.add(matcher.group(index)); + } + } + return list; + + } + public static boolean isEmpty(Object str) { + return str == null || "".equals(str); + } + + /** + * 去除String内的不可见字符 + */ + public static String replaceStr(String str) { + //可以在中括号内加上任何想要替换的字符 + String regEx = "[\n`~!@#$%^&*()+=|{}':;',\\[\\]<>/?~!@#¥%……&*()——+|{}【】‘;:”“’。, 、?]"; + + Pattern p = Pattern.compile(regEx); + Matcher m = p.matcher(str);//原字符串 + String aa = "";//这里是将特殊字符换为aa字符串,""代表直接去掉 + + String newString = m.replaceAll(aa).trim();//替换过的新String +// System.out.println(newString); + return newString; + } + + /** + * 去除String中的空格 + */ + public static String replaceStrSpace(String str) { + //可以在中括号内加上任何想要替换的字符 + String regEx = "[ ]"; + + Pattern p = Pattern.compile(regEx); + Matcher m = p.matcher(str);//原字符串 + String aa = "";//这里是将特殊字符换为aa字符串,""代表直接去掉 + + String newString = m.replaceAll(aa).trim();//替换过的新String +// System.out.println(newString); + return newString; + } + /** + * 将中文的,()替换成英文 + * + * @param str + * @return + */ + public static String replaceComma(String str) { + //可以在中括号内加上任何想要替换的字符 + String regEx = "[,,、]"; + String lBracket = "[(]"; + String rBracket = "[)]"; + + Pattern p = Pattern.compile(regEx); + Matcher m = p.matcher(str);//原字符串 + String aa = ",";//这里是将特殊字符换为aa字符串,""代表直接去掉 + String newString = m.replaceAll(aa).trim();//替换过的新String + + Pattern p1 = Pattern.compile(lBracket); + Matcher m1 = p1.matcher(newString);//原字符串 + String aa1 = "(";//这里是将特殊字符换为aa字符串,""代表直接去掉 + String newString1 = m1.replaceAll(aa1).trim();//替换过的新String + + Pattern p2 = Pattern.compile(rBracket); + Matcher m2 = p2.matcher(newString1);//原字符串 + String aa2 = ")";//这里是将特殊字符换为aa字符串,""代表直接去掉 + String newString2 = m2.replaceAll(aa2).trim();//替换过的新String + + return newString2; + } + + /** + * 提取括号中内容,忽略括号中的括号 + * + * @param msg + * @return + */ + public static List extractMessage(String msg) { + List list = new ArrayList(); + if(StrUtil.isNotEmpty(msg)) { + if(msg.indexOf("(")==-1){ + list.add(msg); + }else { + int start = 0; + int startFlag = 0; + int endFlag = 0; + for (int i = 0; i < msg.length(); i++) { + if (msg.charAt(i) == '(') { + startFlag++; + if (startFlag == endFlag + 1) { + start = i; + } + } else if (msg.charAt(i) == ')') { + endFlag++; + if (endFlag == startFlag) { + list.add(msg.substring(start + 1, i)); + } + } + } + } + } + return list; + } + + /** + * 分解字符串“第x天” + */ + public static Long severalDay(String severalDay) { + Map map = new HashMap<>(); + map.put("零", 0); + map.put("一", 1); + map.put("二", 2); + map.put("三", 3); + map.put("四", 4); + map.put("五", 5); + map.put("六", 6); + map.put("七", 7); + map.put("八", 8); + map.put("九", 9); + map.put("十", 10); + + Long day = null; + if(StrUtil.isNotEmpty(severalDay)&&severalDay.length()>2) { + String s = severalDay.substring(1, severalDay.length() - 1); +// for (int i = 0; i < s.length(); i++) { + day = Long.valueOf(map.get(s)*24*3600*1000); +// } + } + return day; + + + + + + } + +// public static void main(String[] args) { +// String a = "员工成长(112333)"; +// +// List list = extractMessage(a); +// for(String s : list){ +// System.out.println(s); +// } +// } +} diff --git a/util/src/main/java/com/ccsens/util/ToolUtil.java b/util/src/main/java/com/ccsens/util/ToolUtil.java new file mode 100644 index 0000000..188b1ec --- /dev/null +++ b/util/src/main/java/com/ccsens/util/ToolUtil.java @@ -0,0 +1,41 @@ +/** + * Copyright (c) 2015-2016, Chill Zhuang 庄骞 (smallchill@163.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.ccsens.util; + +import java.util.Random; + +/** + * 高频方法集合类 + */ +public class ToolUtil { + + /** + * 获取随机位数的字符串 + * + * @author fengshuonan + * @Date 2017/8/24 14:09 + */ + public static String getRandomString(int length) { + String base = "abcdefghijklmnopqrstuvwxyz0123456789"; + Random random = new Random(); + StringBuffer sb = new StringBuffer(); + for (int i = 0; i < length; i++) { + int number = random.nextInt(base.length()); + sb.append(base.charAt(number)); + } + return sb.toString(); + } +} \ No newline at end of file diff --git a/util/src/main/java/com/ccsens/util/TransactionUtil.java b/util/src/main/java/com/ccsens/util/TransactionUtil.java new file mode 100644 index 0000000..08334c4 --- /dev/null +++ b/util/src/main/java/com/ccsens/util/TransactionUtil.java @@ -0,0 +1,21 @@ +package com.ccsens.util; + +import org.springframework.transaction.PlatformTransactionManager; +import org.springframework.transaction.TransactionDefinition; +import org.springframework.transaction.TransactionStatus; +import org.springframework.transaction.support.DefaultTransactionDefinition; + +public class TransactionUtil { + /** + * 手动开启事务,获取事务状态 + * @return + */ + public static TransactionStatus getTransactionStatus(PlatformTransactionManager transactionManager) { + //开启手动事务 + DefaultTransactionDefinition def = new DefaultTransactionDefinition(); + // 事务隔离级别,开启新事务 + def.setPropagationBehavior( TransactionDefinition.PROPAGATION_REQUIRES_NEW ); + // 获取事务状态,并开启事务,相当于 transaction begin; + return transactionManager.getTransaction( def ); + } +} diff --git a/util/src/main/java/com/ccsens/util/UploadFileUtil_Servlet3.java b/util/src/main/java/com/ccsens/util/UploadFileUtil_Servlet3.java new file mode 100644 index 0000000..4d55ff5 --- /dev/null +++ b/util/src/main/java/com/ccsens/util/UploadFileUtil_Servlet3.java @@ -0,0 +1,143 @@ +package com.ccsens.util; + +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.io.FileUtil; +import cn.hutool.core.util.CharsetUtil; +import cn.hutool.core.util.IdUtil; +import cn.hutool.core.util.StrUtil; +import lombok.extern.slf4j.Slf4j; + +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.Part; +import java.io.*; +import java.net.URLEncoder; +import java.util.Date; + +@Slf4j +public class UploadFileUtil_Servlet3 { + /** + * Servlet3.0文件上传 (生成uuid.txt文件) + * @param part Servlet3.0 API ---> Part + * @param allowedExts 允许的后缀名 + * @param dir 目录 + * @return 文件名 + * @throws IOException + * @throws NotSupportedFileTypeException + */ + public static String uploadFile(Part part, String allowedExts, String dir) + throws IOException, NotSupportedFileTypeException { + String extraPath = DateUtil.format(new Date(), "yyyyMMdd"); + + //1.判断是否为空 + if (part == null) { + return null; + } + + //2.生成文件名 [uuid.ext] + String original = getFileNameByPart(part); + String ext = FileUtil.extName(original); + if (StrUtil.isEmpty(ext) || !allowedExts.contains(ext)){ + throw new NotSupportedFileTypeException("不支持的格式类型: " + ext); + } + String path = extraPath + File.separator + IdUtil.simpleUUID() + "." + ext; + //3.创建必要的目录 + File tmpFile = new File(dir); + if (!tmpFile.exists()) { + tmpFile.mkdirs(); + } + + //4.写入磁盘 + String fullPath = dir + File.separator + path; + //part.write(path); //需要配置临时路径 + //saveFileFromInputStream(part.getInputStream(),dir,name); + FileUtil.writeFromStream(part.getInputStream(),fullPath); + + return path; + } + + public static byte[] uploadFile(Part part) + throws IOException, NotSupportedFileTypeException { + //1.判断是否为空 + if (part == null) { + return null; + } + + //2.读取文件 + InputStream is = part.getInputStream(); + byte[] bytes = new byte[is.available()]; + is.read(bytes); + + return bytes; + } + + /** + * 根据请求头解析出文件名 + * 请求头的格式:火狐和google浏览器下:form-data; name="file"; filename="snmp4j--api.zip" + * IE浏览器下:form-data; name="file"; filename="E:\snmp4j--api.zip" + * @param part 包含请求头 + * @return 文件名 + */ + public static String getFileNameByPart(Part part) { + String header = part.getHeader("content-disposition"); + /** + * String[] tempArr1 = header.split(";");代码执行完之后,在不同的浏览器下,tempArr1数组里面的内容稍有区别 + * 火狐或者google浏览器下:tempArr1={form-data,name="file",filename="snmp4j--api.zip"} + * IE浏览器下:tempArr1={form-data,name="file",filename="E:\snmp4j--api.zip"} + */ + String[] tempArr1 = header.split(";"); + /** + *火狐或者google浏览器下:tempArr2={filename,"snmp4j--api.zip"} + *IE浏览器下:tempArr2={filename,"E:\snmp4j--api.zip"} + */ + String[] tempArr2 = tempArr1[2].split("="); + //获取文件名,兼容各种浏览器的写法 + String fileName = tempArr2[1].substring(tempArr2[1].lastIndexOf("\\")+1).replaceAll("\"", ""); + return fileName; + } + + public static void download(HttpServletResponse response, String path, String fileName) throws Exception{ + File file = new File(path); + // 如果文件存在,则进行下载 + if (!file.exists()) { + log.info("该路径不存在:{}",path); + return; + } + // 配置文件下载 + response.setHeader("content-type", "application/octet-stream"); + response.setContentType("application/octet-stream"); + // 下载文件能正常显示中文 + response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName, CharsetUtil.UTF_8)); + // 实现文件下载 + byte[] buffer = new byte[1024]; + FileInputStream fis = null; + BufferedInputStream bis = null; + try { + fis = new FileInputStream(file); + bis = new BufferedInputStream(fis); + OutputStream os = response.getOutputStream(); + int i = bis.read(buffer); + while (i != -1) { + os.write(buffer, 0, i); + i = bis.read(buffer); + } + + } finally { + if (bis != null) { + try { + bis.close(); + } catch (IOException e) { + log.error("关闭流异常", e); + } + } + if (fis != null) { + try { + fis.close(); + } catch (IOException e) { + log.error("关闭流异常", e); + } + } + } + + + } +} diff --git a/util/src/main/java/com/ccsens/util/WebConstant.java b/util/src/main/java/com/ccsens/util/WebConstant.java new file mode 100644 index 0000000..3f01b31 --- /dev/null +++ b/util/src/main/java/com/ccsens/util/WebConstant.java @@ -0,0 +1,1087 @@ +package com.ccsens.util; + +import cn.hutool.core.codec.Base64; +import cn.hutool.core.util.URLUtil; +import lombok.Getter; +import lombok.Setter; + +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.Pattern; +import java.io.File; + +public class WebConstant { + + /**cell内容不赋值*/ + public static final String CELL_NULL = "cell_null"; + /**数据存在*/ + public static final byte STATUS_EXIT = 0; + /**数据已删除*/ + public static final byte STATUS_DELETE = 1; + public static final String IMG_TYPE = "bmp,jpg,png,tif,gif,pcx,tga,exif,fpx,svg,psd,cdr,pcd,dxf,ufo,eps,ai,raw,WMF,webp,jpeg"; + /**手机号正则*/ +// public static final String REGEX_PHONE = "^((13[0-9])|(14[5|7])|(15([0-3]|[5-9]))|(17[013678])|(18[0,1-9]))\\d{8}$"; + public static final String REGEX_PHONE = "^[1]([3-9])[0-9]{9}$"; + + /* 导入WBS ,规定标签长度 */ + public static final Integer LABEL_LENGTH = 6; + + public static class Time { + public static final long DAY = 24 * 3600 * 1000; + } + + /**属性名*/ + public static class Field{ + public static final String CODE = "code"; + + } + + + public static class Wx{ + public static final String ACCESS_TOKEN = "tall_wx_access_token_"; + public static final long EXPIRE_TIME = 1 * 60 * 60; + public static final String DOMAIN = PropUtil.wxPrefix; + public static final String TEMPLATE_SEND = DOMAIN + "template/send"; + + public static final String GZH_AUTH_URL + = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=%1$s&redirect_uri=%2$s&response_type=code&scope=%3$s&state=STATE#wechat_redirect"; + public static final String ACCOUNT_WX_APPID = "account_wx_appId"; + + public static String getAuthedUrl(String url, WxGzhAuthType wxGzhAuthType,String appId){ + return String.format(GZH_AUTH_URL,appId, URLUtil.encode(url),wxGzhAuthType.getText()); + } + + public static final String SESSION_KEY = "{}_{}_session_key"; + public static final String OPEN_KEY = "{}_{}_openid_key"; + + } + + public enum WxGzhAuthType { + //基本授权类型,静默,只能获取openId + SNSAPI_BASE("snsapi_base"), + //信息授权类型,弹出提示框,可以获取openId,unionId,nickanme,city等用户信息 + SNSAPI_USERINFO("snsapi_userinfo"); + + @Getter + @Setter + private String text; + + private WxGzhAuthType(String text){ + this.text = text; + } + } + + public static enum TemplateParam { + + Operator("{{operator}}", "操作者"), + ProjectName("{{projectName}}", "项目名"), + TaskName("{{taskName}}", "任务名"), + Deliverable("{{deliverable}}", "交付物"), + Operate("{{operate}}", "操作"), + Principal("{{principal}}", "负责人"), + RoleName("{{roleName}}", "角色名"), + MemberName("{{memberName}}", "成员名"), + ; + + public String value; + public String phase; + + private TemplateParam(String value, String phase) { + this.value = value; + this.phase = phase; + } + } + + public static final class Wps{ +// public static final String APPID = "09d77d2eb919438e8ae4f2a9ec6ec8dd"; +// public static final String APPKEY = "1b52d9ef8b1c4019be49f211b84c4f90"; + public static final String APPID = "wps_tall_appId"; + public static final String APPKEY = "wps_tall_appKey"; + public static final String PERMISSION_READ = "read"; + public static final String PERMISSION_WRITE = "write"; + public static final String FILE_TYPE_ALL = "doc, dot, wps, wpt, docx, dotx, docm, dotm, xls, xlt, et, xlsx, xltx, csv, xlsm, xltm, ppt,pptx,pptm,ppsx,ppsm,pps,potx,potm,dpt,dps, pdf"; + public static final String FILE_TYPE_WORD = "doc, dot, wps, wpt, docx, dotx, docm, dotm"; + public static final String FILE_TYPE_TABLE = "xls, xlt, et, xlsx, xltx, csv, xlsm, xltm"; + public static final String FILE_TYPE_DEMO = " ppt,pptx,pptm,ppsx,ppsm,pps,potx,potm,dpt,dps"; + public static final String FILE_TYPE_PDF = "pdf"; + public static final String _W_URL = "_w_url"; + + + /**新建*/ + public static final byte USER_OPERATION_NEW = 0; + /**读权限*/ + public static final byte USER_OPERATION_READ = 1; + /**写权限*/ + public static final byte USER_OPERATION_WRITE = 2; + /**编辑保存*/ + public static final byte USER_OPERATION_SAVE = 3; + /**打开旧版本号*/ + public static final byte USER_OPERATION_OLD = 4; + /**重命名*/ + public static final byte USER_OPERATION_RENAME = 5; + + /**业务权限:只读*/ + public static final byte PROJECT_PRIVILEGE_READ = 0; + /**业务权限:可写*/ + public static final byte PROJECT_PRIVILEGE_WRITE = 1; + /**业务权限:查询接口决定*/ + public static final byte PROJECT_PRIVILEGE_QUERY = 2; + + /** + * 获取文件类型 + * @param suffix + * @return + */ + public static String getFileType(String suffix) { + if (FILE_TYPE_WORD.contains(suffix)) { + return "w"; + }else if (FILE_TYPE_TABLE.contains(suffix)) { + return "s"; + } else if (FILE_TYPE_DEMO.contains(suffix)) { + return "p"; + } else if (FILE_TYPE_PDF.contains(suffix)) { + return "f"; + } + return null; + } + + } + + public static final class Message{ + public static final byte TYPE_TEXT = 0; + public static final byte TYPE_LINK = 1; + public static final byte SEND_WS = 0; + public static final byte SEND_WX_OFFICIAL = 1; + public static final byte SEND_SUCCESS = 1; + public static final byte SEND_FAIL = 0; + } + + public static final class Project{ + public static final String PROJECT_ID = "projectId"; + public static final byte TASK_COMPLETE_YES = 2; + + + public static final String getTaskCompleteStatus(byte completedStatus) { + return completedStatus == WebConstant.Project.TASK_COMPLETE_YES ? "完成" : "取消完成"; + } + } + + + /**注册来源*/ + public static final class Regist { + public final static byte SOURCE = 0; + public final static byte SOURCE_HT = 1; + public final static String PASSWORD = "123456"; + } + + public enum APP_SCENE { + BTPRO(0,"btpro"), MTPRO(1,"mtpro"),PTPRO(2,"ptpro"); + + public int value; + public String phase; + APP_SCENE(int value,String thePhase){ + this.value =value; + this.phase = thePhase; + } + } + public static final APP_SCENE CURRENT_APP_SCENE = APP_SCENE.BTPRO; + public static final String DYNAMIC_DATASOURCE_SCHEMA_KEY = "${schema}"; + public static final String JWT_ACCESS_TOKEN_SECERT = Base64.encode("v%R5jNdmouCN?"); + public static final String JWT_REFRESH_TOKEN_SECRET = Base64.encode("GPYTu,tHA\"|/~"); + + public static final String PARAMETER_KEY_TOKEN = "token"; + public static final String HEADER_KEY_TOKEN = "Authorization"; + public static final String HEADER_KEY_MD5 = "md5"; + public static final String HEADER_KEY_TOKEN_PREFIX = "Bearer "; + public static final String REQUEST_KEY_CLAIMS = "claims"; + public static final String REQUEST_KEY_TOKEN_USERS = "Token_User"; + public static final String RANDOM_STR = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; + public static final String IMAGE_CODE = "image_code_"; + + + public static final long JWT_ACCESS_TOKEN_EXPIRED_TLLMILLS = 3600 * 24 * 365 * 1000; //20 hours + public static final long JWT_REFRESH_TOKEN_EXPIRED_TLLMILLS = 3600 * 17 * 30 * 1000; //17 days + public static final long JWT_ACCESS_TOKEN_EXPIRED_TLLMILLS_TEST = 3600 * 24 * 365 * 1000; //2 hours + + public static final String IMG_PATH_PREFIX = "/home/ptpro/images"; + public static final String IMG_PATH_PREFIX_AVATAR = IMG_PATH_PREFIX + File.separator + "avatar"; + public static final String IMG_PATH_PREFIX_SHARE_QR = IMG_PATH_PREFIX + File.separator + "qrcode"; + public static final String IMG_PATH_PREFIX_SHARE_IMG = IMG_PATH_PREFIX + File.separator + "shareimg"; + public static final String IMG_PATH_SHARE_IMG = "/shareimg"; + + + public static final String PATH_WX_CRET = "/home/packet/1513955071_20181128_cert.p12"; + //public static final String WX_CRET_PWD = xxx; + + public static final String DEFAULT_NICKNAME = "普通用户"; + public static final String DEFAULT_DESCRIPTION = "这个人很懒,什么都没有留下"; + public static final String DEFAULT_AVATAR = ""; + + public static final String KEY_WEBSOCKET_GROUPID = "WebScoket_groupId"; + public static final String PREFIX_WEBSOCKET_GROUPID = "groupId="; + + public static final String UPLOAD_PATH_BASE = "/home/cloud/tall/uploads"; + public static final String UPLOAD_PATH_BASE_HEALTH = "/home/cloud/health/uploads"; + public static final String UPLOAD_PATH_BASE_PIMS = "/home/cloud/pims/uploads"; + public static final String UPLOAD_PATH_BASE_MT_JUDGE = "mt"; + public static final String UPLOAD_PATH_BASE_WBS = "wbs"; + public static final String HOME_STATICREC = "/home/staticrec/"; + + public static final String UPLOAD_PATH_DELIVER = UPLOAD_PATH_BASE + File.separator + "delivers"; + public static final String UPLOAD_PATH_DELIVER1 ="delivers"; + public static final String UPLOAD_PATH_PROJECT ="project"; + + public static final String UPLOAD_PATH_WPS ="wps"; + public static final String UPLOAD_PATH_AVATAR_URL ="avatarUrl"; + public static final String UPLOAD_PATH_REMARK ="remarks"; + public static final String UPLOAD_PROJECT_WBS = UPLOAD_PATH_BASE + File.separator + "project"; + public static final String UPLOAD_AVATAR_URL = UPLOAD_PATH_BASE + File.separator + "avatarUrl/"; +// public static final String URL_BASE = "https://api.ccsens.com/ptpro/uploads/"; + + public static final String TEST_URL = "https://test.tall.wiki/"; + public static final String TEST_URL_GAME_SQ = "game-dev/"; + public static final String TEST_URL_GAME_SP = "game-sp/"; + public static final String TEST_URL_GAME_BH = "game-bh/"; + public static final String TALL_UPLOADS = "tall/v1.0/uploads/"; + public static final String TEST_URL_BASE = TEST_URL + "gateway/" + TALL_UPLOADS; + + public static final String TEST_URL_BASE_MT = TEST_URL + "gateway/mt/uploads/"; + public static final String TEST_URL_BASE_HEALTH = TEST_URL + "gateway/health/uploads/"; + public static final String TEST_URL_BASE_CT = TEST_URL + "gateway/ct/uploads/"; + + public static final String QRCODE_HEALTH = "pages/user-code/user-code"; + public static final String QRCODE_SITE = "pages/sign/sign"; + public static final String QRCODE_GAME = "pages/index/index"; + + public static final Integer Expired_Verify_Code_In_Seconds = 120; + public static final Integer Exist_Verify_Code_In_Seconds = 60; + + public static final String NOTUPLOAD = "未上传"; + public static final String UPLOAD = "已上传"; + + public enum ROLE_NAME { + God("God","上帝"),ManageRepresent("ManageRepresent","管代"),Stakeholder("Stakeholder","干系人"), + PM("PM","项目经理"),Member("Member","项目成员"),MVP("MVP","MVP") + ,Attention("Attention","关注者"),Creator("Creator","创建者") + ,MoneyStakeholder("MoneyStakeholder","奖惩干系人"),AllMember("AllMember","全体成员") + ,ProjectVirtualRole("ProjectVirtualRole","角色项目"); + + public String value; + public String phase; + ROLE_NAME(String value,String thePhase){ + this.value =value; + this.phase = thePhase; + } + } + public enum ROLE_POWER { + NOT_POWER((byte) 0,"只能查看"), LOOK_POWER((byte) 1,"只能查看"), + OPERATION_POWER((byte) 2,"操作权限"),ADMIN_POWER((byte)3,"管理权限"),MAX_POWER((byte)4,"最高权限"); + + public byte value; + public String phase; + ROLE_POWER(byte value,String thePhase){ + this.value =value; + this.phase = thePhase; + } + } + + public enum TASK_VIRTUAL { + Normal(0,"普通任务"), Virtual(1,"虚拟任务"); + public int value; + public String phase; + TASK_VIRTUAL(int value,String thePhase){ + this.value =value; + this.phase = thePhase; + } + } + public enum TASK_DELAY { + SelfMotion(0,"立即切换"),DelayManual(1,"延迟自动切换"), Manual(2,"手动切换"); + public int value; + public String phase; + TASK_DELAY(int value,String thePhase){ + this.value =value; + this.phase = thePhase; + } + public static TASK_DELAY valueOf(int value) { + switch (value) { + case 0: return SelfMotion; + case 1: return DelayManual; + case 2: return Manual; + default: return null; + } + } + + } + public enum TASK_LEVEL { + Virtual(0,"虚拟任务"),FirstTask(1,"一级任务"),SecondTask(2,"二级任务"), SubTask(3,"子任务"); + public int value; + public String phase; + TASK_LEVEL(int value,String thePhase){ + this.value =value; + this.phase = thePhase; + } + } + public enum REC_STATUS { + Normal((byte) 0,"正常"), Disabled((byte) 1,"已禁用"),Deleted((byte) 2,"已删除"); + + public byte value; + public String phase; + REC_STATUS(byte value,String thePhase){ + this.value =value; + this.phase = thePhase; + } + } + + + public enum CLIENT_TYPE { + Wxmp(0,"微信小程序"), H5(1,"网页"),Android(2 + ,"安卓客户端"),IOS(3,"苹果客户端"), + WxEnterprise(4, "企业微信"); + + public int value; + public String phase; + CLIENT_TYPE(int value,String thePhase){ + this.value =value; + this.phase = thePhase; + } + + public static CLIENT_TYPE valueOf(int value) { + switch (value) { + case 0: return Wxmp; + case 1: return H5; + case 2: return Android; + case 3: return IOS; + case 4: return WxEnterprise; + default: return null; + } + } + } + + public enum IDENTIFY_TYPE { + Wxmp(0,"微信小程序"), Phone(1,"电话") + , Email(2,"Email"), Account(3,"账号") + ,OAUTH2_Wx(4,"微信公众号网页授权登录"),Wx_H5(5,"网页微信登陆") + ,OAUTH2_WeiBo(6,"微博"),WxEnterprise(7, "企业微信"), + OFFICIAL_ACCOUNT_WX(9,"微信公众号登录"),Wx_H5_TEST(10,"网页微信登陆测试"); + // 钉钉是11 + + public int value; + public String phase; + IDENTIFY_TYPE(int value,String thePhase){ + this.value =value; + this.phase = thePhase; + } + + public static IDENTIFY_TYPE valueOf(int value) { // 手写的从int到enum的转换函数 + switch (value) { + case 0: return Wxmp; + case 1: return Phone; + case 2: return Email; + case 3: return Account; + case 4: return OAUTH2_Wx; + case 5: return Wx_H5; + case 6: return OAUTH2_WeiBo; + case 7: return WxEnterprise; + default: return null; + } + } + } + + + public enum EVENT_PROCESS { + Pending(0,"未开始"), Processing(1,"进行中"), Expired(2,"已完成"); + + public int value; + public String phase; + EVENT_PROCESS(int value,String thePhase){ + this.value =value; + this.phase = thePhase; + } + + public static EVENT_PROCESS valueOf(int value) { // 手写的从int到enum的转换函数 + switch (value) { + case 0: return Pending; + case 1: return Processing; + case 2: return Expired; + default: return null; + } + } + } + public enum NODE_USER_ROLE_TYPE { + Add(0,"添加"),Delete(1,"删除"); + + public int value; + public String phase; + NODE_USER_ROLE_TYPE(int value,String thePhase){ + this.value =value; + this.phase = thePhase; + } + + public static NODE_USER_ROLE_TYPE valueOf(int value) { // 手写的从int到enum的转换函数 + switch (value) { + case 0: return Add; + case 1: return Delete; + default: return null; + } + } + } + + public enum Role { + Tourist(-1,"游客"),Creator(0,"创建者"), Judger(1,"评委"), Player(2,"选手"),Host(3,"主持人"),Audience(4,"观众"); + + public int value; + public String phase; + Role(int value,String thePhase){ + this.value =value; + this.phase = thePhase; + } + } + + public enum PARTI_DEVICE_TYPE { + Wxmp(0,"微信小程序"), H5(1,"H5"), App(2,"App"); + + public int value; + public String phase; + PARTI_DEVICE_TYPE(int value,String thePhase){ + this.value =value; + this.phase = thePhase; + } + public static PARTI_DEVICE_TYPE valueOf(int value) { // 手写的从int到enum的转换函数 + switch (value) { + case 0: return Wxmp; + case 1: return H5; + case 2: return App; + default: return null; + } + } + } + + public enum PARTI_LOGIN_STATUS { + SUCCESS(0,"登陆成功"), ToStep2(1,"进入下一步"); + + public int value; + public String phase; + PARTI_LOGIN_STATUS(int value,String thePhase){ + this.value =value; + this.phase = thePhase; + } + } + + public enum Gender{ + Unknown(0,"未知"),Male(1,"男"),Female(2,"女"); + + public int value; + public String phase; + Gender(int value,String thePhase){ + this.value =value; + this.phase = thePhase; + } + } + + public enum Parti_Verify_Type{ + Phone(0,"手机"),Email(1,"邮件"),Account(2,"账号"); + public int value; + public String phase; + Parti_Verify_Type(int value,String thePhase){ + this.value = value; + this.phase = thePhase; + } + public static Parti_Verify_Type valueOf(int value) { // 手写的从int到enum的转换函数 + switch (value) { + case 0: return Phone; + case 1: return Email; + case 2: return Account; + default: return null; + } + } + } + + public enum PartiVerify{ + None(0,"无验证"),Verify(1,"验证"); + public int value; + public String phase; + PartiVerify(int value,String thePhase){ + this.value = value; + this.phase = thePhase; + } + } + + public enum TASK_Execute_Type { + Start(0,"开始"),Complete(1,"完成"); + + public int value; + public String phase; + TASK_Execute_Type(int value,String thePhase){ + this.value = value; + this.phase = thePhase; + } + } + +// public enum Message_Type{ +// Ack(0,"Ack"),Sync(1,"Sync"),Node(2,"Node"),User(3,"User"),Heart(4,"Heart"),Auth(5,"Auth"),Channel(6,"Channel") +// ,Error(0x99,"Error") +// ,MasterStatus(0x10,"MasterStatus") +// ,BatchSetting(0x11,"BatchSetting"); +// public int value; +// public String phase; +// Message_Type(int value,String thePhase){ +// this.value = value; +// this.phase = thePhase; +// } +// public static Message_Type valueOf(int value) { // 手写的从int到enum的转换函数 +// switch (value) { +// case 0: return Ack; +// case 1: return Sync; +// case 2: return Node; +// case 3: return User; +// case 4: return Heart; +// case 5: return Auth; +// case 6: return Channel; +// default: return null; +// } +// } +// +// public static Message_Type phaseOf(String phase) { // 手写的从String到enum的转换函数 +// if(phase.equalsIgnoreCase("Sync")) +// return Sync; +// if(phase.equalsIgnoreCase("Ack")) +// return Ack; +// if(phase.equalsIgnoreCase("Node")) +// return Node; +// if(phase.equalsIgnoreCase("User")) +// return User; +// if(phase.equalsIgnoreCase("Heart")) +// return Heart; +// if(phase.equalsIgnoreCase("Auth")) +// return Auth; +// if(phase.equalsIgnoreCase("Channel")) +// return Channel; +// else +// return null; +// } +// } + + public enum Message_Type{ + Heart(0x00,"Heart"),Ack(0x01,"Ack"),Auth(0x02,"Auth"),Channel(0x03,"Channel") + ,Sync(0x04,"Sync") + ,Node(0x05,"Node"),User(0x06,"User"), Timer(0x07,"Timer") + ,Error(0x99,"Error") + ,MasterStatus(0x10,"MasterStatus") + ,BatchSetting(0x11,"BatchSetting") + ,Admin(0x12,"Admin") + ,Ring(0x13,"Ring") + ,Deliver(0x14,"Deliver") + ,Game(0x15,"Game") + ,Chrome(0x15,"Chrome") + ,PPTCtl(0x15,"PPTCtl") + ,Count(0x16,"Count") + ,ChangeStatus(0x17,"ChangeStatus") + ,PROJECT_MESSAGE(0x18, "ProjectMessage") + ,CAR_RECORD(0x19, "CarRecord"); + public int value; + public String phase; + Message_Type(int value,String thePhase){ + this.value = value; + this.phase = thePhase; + } + public static Message_Type valueOf(int value) { // 手写的从int到enum的转换函数 + switch (value) { + case 0x00: return Heart; + case 0x01: return Ack; + case 0x02: return Auth; + case 0x03: return Channel; + case 0x04: return Sync; + case 0x05: return Node; + case 0x06: return User; + case 0x07: return Timer; + case 0x10: return MasterStatus; + case 0x11: return BatchSetting; + case 0x12: return Admin; + case 0x13: return Ring; + case 0x14: return Deliver; + case 0x15: return Game; + case 0x16: return Count; + case 0x17: return ChangeStatus; + case 0x19: return CAR_RECORD; + default: return null; + } + } + + public static Message_Type phaseOf(String phase) { // 手写的从String到enum的转换函数 + if("Sync".equalsIgnoreCase(phase)) { + return Sync; + } + if("Ack".equalsIgnoreCase(phase)) { + return Ack; + } + if("Node".equalsIgnoreCase(phase)) { + return Node; + } + if("User".equalsIgnoreCase(phase)) { + return User; + } + if("Heart".equalsIgnoreCase(phase)) { + return Heart; + } + if("Auth".equalsIgnoreCase(phase)) { + return Auth; + } + if("Channel".equalsIgnoreCase(phase)) { + return Channel; + } + if("Timer".equalsIgnoreCase(phase)) { + return Timer; + } + if("MasterStatus".equalsIgnoreCase(phase)) { + return MasterStatus; + } + if("BatchSetting".equalsIgnoreCase(phase)) { + return BatchSetting; + } + if("Admin".equalsIgnoreCase(phase)) { + return Admin; + } + if("Ring".equalsIgnoreCase(phase)) { + return Ring; + } + if("Deliver".equalsIgnoreCase(phase)) { + return Deliver; + } + if("Game".equalsIgnoreCase(phase)) { + return Game; + } + if("Count".equalsIgnoreCase(phase)) { + return Count; + } + if("ChangeStatus".equalsIgnoreCase(phase)) { + return ChangeStatus; + } + if("CarRecord".equalsIgnoreCase(phase)) { + return CAR_RECORD; + } + return null; + + } + } + public enum Message_Ack_Event{ + Ack(0,"Ack"); + public int value; + public String phase; + Message_Ack_Event(int value,String thePhase){ + this.value = value; + this.phase = thePhase; + } + public static Message_Ack_Event valueOf(int value) { // 手写的从int到enum的转换函数 + switch (value) { + case 0: return Ack; + default: return null; + } + } + public static Message_Ack_Event phaseOf(String phase) { // 手写的从String到enum的转换函数 + if("Ack".equalsIgnoreCase(phase)) { + return Ack; + } else { + return null; + } + } + } + + public enum Message_Sync_Event{ + ChangeDuration(0,"ChangeDuration"),Move(1,"Move"), + Remove(2,"Remove"),Add(3,"Add"),Start(4,"Start"),ChangeBeginTime(5,"ChangeBeginTime"),Show(6,"Show"); + public int value; + public String phase; + Message_Sync_Event(int value,String thePhase){ + this.value = value; + this.phase = thePhase; + } + public static Message_Sync_Event valueOf(int value) { // 手写的从int到enum的转换函数 + switch (value) { + case 0: return ChangeDuration; + case 1: return Move; + case 2: return Remove; + case 3: return Add; + case 4: return Start; + case 5: return ChangeBeginTime; + case 6: return Show; + default: return null; + } + } + public static Message_Sync_Event phaseOf(String phase) { // 手写的从String到enum的转换函数 + if(phase.equalsIgnoreCase("Start")) { + return Start; + } + if(phase.equalsIgnoreCase("ChangeDuration")) { + return ChangeDuration; + } + if(phase.equalsIgnoreCase("Move")) { + return Move; + } + if(phase.equalsIgnoreCase("Remove")) { + return Remove; + } + if(phase.equalsIgnoreCase("Add")) { + return Add; + } + if(phase.equalsIgnoreCase("ChangeBeginTime")) { + return ChangeBeginTime; + } + if(phase.equalsIgnoreCase("Show")) { + return Show; + } else { + return null; + } + } + } + + public enum Message_Node_Event{ + ChangeStatus(0,"ChangeStatus"),PostComment(1,"PostComment"),UploadDeliver(2,"UploadDeliver"); + public int value; + public String phase; + Message_Node_Event(int value,String thePhase){ + this.value = value; + this.phase = thePhase; + } + public static Message_Node_Event valueOf(int value) { // 手写的从int到enum的转换函数 + switch (value) { + case 0: return ChangeStatus; + case 1: return PostComment; + case 2: return UploadDeliver; + default: return null; + } + } + public static Message_Node_Event phaseOf(String phase) { // 手写的从String到enum的转换函数 + if(phase.equalsIgnoreCase("ChangeStatus")) { + return ChangeStatus; + } + if(phase.equalsIgnoreCase("PostComment")) { + return PostComment; + } + if(phase.equalsIgnoreCase("UploadDeliver")) { + return UploadDeliver; + } else { + return null; + } + } + } + + public enum Message_User_Event{ + HasRead(0,"HasRead"),User(1,"User"); + public int value; + public String phase; + Message_User_Event(int value,String thePhase){ + this.value = value; + this.phase = thePhase; + } + public static Message_User_Event valueOf(int value) { // 手写的从int到enum的转换函数 + switch (value) { + case 0: return HasRead; + case 1: return User; + default: return null; + } + } + public static Message_User_Event phaseOf(String phase) { // 手写的从String到enum的转换函数 + if(phase.equalsIgnoreCase("HasRead")) { + return HasRead; + } + if(phase.equalsIgnoreCase("User")) { + return User; + } else { + return null; + } + } + } + + public enum Message_Heart_Event{ + Heart(0,"Heart"); + public int value; + public String phase; + Message_Heart_Event(int value,String thePhase){ + this.value = value; + this.phase = thePhase; + } + public static Message_Heart_Event valueOf(int value) { // 手写的从int到enum的转换函数 + switch (value) { + case 0: return Heart; + default: return null; + } + } + public static Message_Heart_Event phaseOf(String phase) { // 手写的从String到enum的转换函数 + if(phase.equalsIgnoreCase("Heart")) { + return Heart; + } else { + return null; + } + } + } + + public enum Message_Auth_Event{ + Auth(0,"Auth"), + Answer(1,"Answer"); + public int value; + public String phase; + Message_Auth_Event(int value,String thePhase){ + this.value = value; + this.phase = thePhase; + } + public static Message_Auth_Event valueOf(int value) { // 手写的从int到enum的转换函数 + switch (value) { + case 0: return Auth; + case 1: return Answer; + default: return null; + } + } + public static Message_Auth_Event phaseOf(String phase) { // 手写的从String到enum的转换函数 + if(phase.equalsIgnoreCase("Auth")) { + return Auth; + } + if(phase.equalsIgnoreCase("Answer")) { + return Answer; + }else { + return null; + } + } + } + + public enum Message_Channel_Event{ + Channel(0,"Channel"); + public int value; + public String phase; + Message_Channel_Event(int value,String thePhase){ + this.value = value; + this.phase = thePhase; + } + public static Message_Channel_Event valueOf(int value) { // 手写的从int到enum的转换函数 + switch (value) { + case 0: return Channel; + default: return null; + } + } + public static Message_Channel_Event phaseOf(String phase) { // 手写的从String到enum的转换函数 + if(phase.equalsIgnoreCase("Channel")) { + return Channel; + } else { + return null; + } + } + } + + public enum Message_MasterStatus_Event{ + Report(0,"Report"),Query(1,"Query"),Answer(2,"Answer"); + public int value; + public String phase; + Message_MasterStatus_Event(int value,String thePhase){ + this.value = value; + this.phase = thePhase; + } + public static Message_MasterStatus_Event valueOf(int value) { // 手写的从int到enum的转换函数 + switch (value) { + case 0: return Report; + case 1: return Query; + case 2: return Answer; + default: return null; + } + } + public static Message_MasterStatus_Event phaseOf(String phase) { // 手写的从String到enum的转换函数 + if(phase.equalsIgnoreCase("Report")) { + return Report; + } + if(phase.equalsIgnoreCase("Query")) { + return Query; + } + if(phase.equalsIgnoreCase("Answer")) { + return Answer; + } else { + return null; + } + } + } + + @SuppressWarnings("all") + public enum Task_Check_Status{ + PENDING(0,"未审核"),FAILURE(1,"审核未通过"),SUCCESS(2,"审核已通过"); + public int value; + public String phase; + Task_Check_Status(int value,String thePhase){ + this.value = value; + this.phase = thePhase; + } + public static Task_Check_Status valueOf(int value) { // 手写的从int到enum的转换函数 + switch (value) { + case 0: return PENDING; + case 1: return FAILURE; + case 2: return SUCCESS; + default: return null; + } + } + public static Task_Check_Status phaseOf(String phase) { // 手写的从String到enum的转换函数 + if(phase.equalsIgnoreCase("PENDING")) { + return PENDING; + }else if(phase.equalsIgnoreCase("FAILURE")) { + return FAILURE; + } else if(phase.equalsIgnoreCase("SUCCESS")) { + return SUCCESS; + } else { + return null; + } + } + } + + + public enum Message_BatchSetting_Event{ + Apply(0,"Apply"),Answer(1,"Answer"); + public int value; + public String phase; + Message_BatchSetting_Event(int value,String thePhase){ + this.value = value; + this.phase = thePhase; + } + public static Message_BatchSetting_Event valueOf(int value) { // 手写的从int到enum的转换函数 + switch (value) { + case 0: return Apply; + case 1: return Answer; + default: return null; + } + } + public static Message_BatchSetting_Event phaseOf(String phase) { // 手写的从String到enum的转换函数 + if(phase.equalsIgnoreCase("Apply")) { + return Apply; + } + if(phase.equalsIgnoreCase("Answer")) { + return Answer; + } + return null; + } + } + + public enum Message_Admin_Event{ + FindAll(0,"FindAll"); + public int value; + public String phase; + Message_Admin_Event(int value,String thePhase){ + this.value = value; + this.phase = thePhase; + } + public static Message_Admin_Event valueOf(int value) { // 手写的从int到enum的转换函数 + switch (value) { + case 0: return FindAll; + default: return null; + } + } + public static Message_Admin_Event phaseOf(String phase) { // 手写的从String到enum的转换函数 + if(phase.equalsIgnoreCase("FindAll")) { + return FindAll; + } else { + return null; + } + } + } + + public enum Message_Ring_Event{ + Send(0,"Send") + ,Read(1,"Read"); + public int value; + public String phase; + Message_Ring_Event(int value,String thePhase){ + this.value = value; + this.phase = thePhase; + } + public static Message_Ring_Event valueOf(int value) { // 手写的从int到enum的转换函数 + switch (value) { + case 0: return Send; + case 1: return Read; + default: return null; + } + } + public static Message_Ring_Event phaseOf(String phase) { // 手写的从String到enum的转换函数 + if(phase.equalsIgnoreCase("Send")) { + return Send; + } + if(phase.equalsIgnoreCase("Read")) { + return Read; + } else { + return null; + } + } + } + public enum Message_Deliver_Event{ + Upload(0,"Upload") + ,Checker(1,"Checker") + ,Delete(2,"Delete"); + public int value; + public String phase; + Message_Deliver_Event(int value,String thePhase){ + this.value = value; + this.phase = thePhase; + } + public static Message_Deliver_Event valueOf(int value) { // 手写的从int到enum的转换函数 + switch (value) { + case 0: return Upload; + case 1: return Checker; + case 2: return Delete; + default: return null; + } + } + public static Message_Deliver_Event phaseOf(String phase) { // 手写的从String到enum的转换函数 + if(phase.equalsIgnoreCase("Upload")) { + return Upload; + } + if(phase.equalsIgnoreCase("Checker")) { + return Checker; + } + if(phase.equalsIgnoreCase("Delete")) { + return Delete; + } else { + return null; + } + } + } + + public enum Message_Url_Event{ + Url(0,"Url"); + public int value; + public String phase; + Message_Url_Event(int value,String thePhase){ + this.value = value; + this.phase = thePhase; + } + public static Message_Url_Event valueOf(int value) { // 手写的从int到enum的转换函数 + switch (value) { + case 0: return Url; + default: return null; + } + } + public static Message_Url_Event phaseOf(String phase) { // 手写的从String到enum的转换函数 + if(phase.equalsIgnoreCase("Url")) { + return Url; + } + return null; + } + } + //wbs表时间类型==================================================================/ + + /** + * redis类型 + */ + public enum RedisType{ + /**redis类型**/ + STRING(0,"字符串类型"), + LIST_INDEX(1,"列表-某一个"), + LIST_RANGE(2,"列表-范围"), + SET(3,"集合"), + SORT_SET_RANGE(4,"有序集合-index"), + SORT_SET_SCORE(5,"有序集合-分数"), + HASH_ITEM(6, "哈希-某一项"), + HASH(7, "哈希-全部"), + ; + /**类型code*/ + public int type; + /**类型*/ + public String message; + RedisType(int type, String message) { + this.type = type; + this.message = message; + } + } + + +} diff --git a/util/src/main/java/com/ccsens/util/WechatUtil.java b/util/src/main/java/com/ccsens/util/WechatUtil.java new file mode 100644 index 0000000..5781f2b --- /dev/null +++ b/util/src/main/java/com/ccsens/util/WechatUtil.java @@ -0,0 +1,431 @@ +package com.ccsens.util; + +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import lombok.Data; +import org.apache.commons.codec.digest.DigestUtils; + +import java.io.ByteArrayInputStream; +import java.io.UnsupportedEncodingException; +import java.net.ConnectException; +import java.util.*; + +@Data +class GetUserInfoException extends RuntimeException{ + private int code; + public GetUserInfoException(int code,String message){ + super(message); + this.code = code; + } +} + +@Data +class PayException extends RuntimeException{ + private int code; + public PayException(int code,String message){ + super(message); + this.code = code; + } + + public PayException(String message){ + super(message); + this.code = -1; + } +} + +public class WechatUtil { + + /** + * 被Jasckson使用的内部类 必须是static的 + */ + public static class WechatUser { + public String openid; + public String session_key; + public String unionid; + public String errcode; + public String errmsg; + } + + /** + * Access_Token + */ + public static class WechatToken{ + public String access_token; + public Long expires_in; + public String errcode; + public String errmsg; + public Date create_at; + } + + /** + * Get wx code + */ + public static class WechatCode{ + public String scene; + public String page; + public Integer width; + public Boolean auto_color; + public Boolean line_color; + public Boolean is_hyaline; + } + + /** + * Prepare pay + */ + public static class PreparePayBean{ + public String appid;//小程序ID + public String mch_id;//商户号 + public String device_info;//设备号 + public String nonce_str;//随机字符串 + public String sign;//签名 + public String sign_type; //签名类型 + public String body;//商品描述 + public String detail;//商品详情 + public String attach;//附加数据 + public String out_trade_no;//商户订单号 + public String fee_type;//货币类型 + public Integer total_fee; //金额(分) + public String spbill_create_ip;//终端IP + public String time_start;//交易起始时间 + public String time_expire;//交易结束时间 + public String goods_tag;//商品标记 + public String notify_url;//通知地址 + public String trade_type;//交易类型 + public String product_id;//商品id + public String limit_pay;//指定支付方式 + public String openid;//用户标识 + } + + /** + * Prepare pay result + */ + public static class PreparePayResultBean{ + public String return_code; + public String return_msg; + public String result_code; + public String prepay_id; + public String err_code; + public String err_code_des; + } + + /** + * Prepare pay resign + */ + public static class PreparePayReSignBean{ + public String nonceStr; + public String _package; + public long timeStamp; + public String paySign; + public String signType; + } + + private static final String URL_LOGIN + = "https://api.weixin.qq.com/sns/jscode2session?appid=%1$s&secret=%2$s&js_code=%3$s&grant_type=%4$s"; + private static final String URL_GET_ACCESS_TOKEN + = "https://api.weixin.qq.com/cgi-bin/token?grant_type=%1$s&appid=%2$s&secret=%3$s"; + private static final String URL_GET_WX_CODE_A + = "https://api.weixin.qq.com/wxa/getwxacode?access_token=%1$s"; + private static final String URL_GET_WX_CODE_B + = "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=%1$s"; + private static final String URL_GET_WX_CODE_C + = "https://api.weixin.qq.com/cgi-bin/wxaapp/createwxaqrcode?access_token=%1$s"; + private static final String URL_PREPARE_PAY + = "https://api.mch.weixin.qq.com/pay/unifiedorder"; + private static final String URL_PAY_TO_USR_WX + = "https://api.mch.weixin.qq.com/mmpaymkttransfers/promotion/transfers"; + private static final String URL_PAY_TO_USR_BANK + = "https://api.mch.weixin.qq.com/mmpaysptrans/pay_bank"; + + /**Anyring appid*/ + public static final String appid = "wx356e01c7eb01d55d"; + private static final String secret = "83149f3e151d9532f1d2eb76ca10722b"; + private static final String mchid = "1513955071"; + private static final String key = "5a689a2d6b8c4ff499c23d998fde0941"; //商户平台key + public static final String PROJECT_URL = "pages/project/project?projectId=%1$s&scene=2001"; + /** + * 小程序登陆,根据code获取用户信息(openid,sessionKey,) + * @param code + * @return + * @throws ConnectException + * @throws Exception + */ + public static WechatUser getUserInfo(String code) throws Exception { + String response = null; + WechatUser wechatUser = null; + String url_login = String.format(URL_LOGIN, appid, secret, code, "authorization_code"); + + try { + response = HttpsUtil.httpsRequest(url_login, "GET", null); + wechatUser = JacksonUtil.jsonToBean(response, WechatUser.class); + }catch (Exception e){ + throw new GetUserInfoException(-1,e.getMessage()); + } + + if(wechatUser == null) { + throw new GetUserInfoException(-1, "Get UserInfoByCode failed."); + } + if(!StrUtil.isEmpty(wechatUser.errcode)) { + throw new GetUserInfoException(Integer.valueOf(wechatUser.errcode), wechatUser.errmsg); + } + + return wechatUser; + } + + /** + * 获取Access_token + * @return + * @throws Exception + */ + public static WechatToken getAccessToken() throws Exception { + String response = null; + WechatToken wechatToken = null; + String url = String.format(URL_GET_ACCESS_TOKEN,"client_credential",appid,secret); + + response = HttpsUtil.httpsRequest(url,"GET",null); + if(StrUtil.isEmpty(response)) { + return null; + } + wechatToken = JacksonUtil.jsonToBean(response,WechatToken.class); + wechatToken.create_at = new Date(); + return wechatToken; + } + + /** + * 获取小程序二维码/小程序码 + * @return + * @throws Exception + */ + public static void getWxCode(String page,String scene,String path) throws Exception { + WechatToken wechatToken = getAccessToken(); + String url = String.format(URL_GET_WX_CODE_B,wechatToken.access_token); + + WechatCode wechatCode = new WechatCode(); + wechatCode.page = page; + wechatCode.scene = scene; + + String postStr = JacksonUtil.beanToJson(wechatCode); + System.out.println(postStr); + + HttpsUtil.httpsRequest(url,"POST",postStr,path); + } + + /** + * 统一下单 + */ + public static PreparePayReSignBean preparePay(String openid,String out_trade_no,String body,int total_fee,String spbill_create_ip, + String notify_url) throws Exception { + PreparePayBean preparePayBean = new PreparePayBean(); + preparePayBean.appid = appid; + preparePayBean.mch_id = mchid; + preparePayBean.openid = openid; + preparePayBean.total_fee = total_fee; + preparePayBean.out_trade_no = out_trade_no; + preparePayBean.body = new String(body.getBytes("ISO-8859-1"),"UTF-8");//以utf-8编码放入paymentPo,微信支付要求字符编码统一采用UTF-8字符编码 + //preparePayBean.body = new String("聊天密码小程序-充值"); + preparePayBean.spbill_create_ip = spbill_create_ip; + preparePayBean.notify_url = notify_url; + preparePayBean.trade_type = "JSAPI"; + preparePayBean.nonce_str = createNonceStr(); + + // 把请求参数打包成数组 + Map sParaTemp = new HashMap(); + sParaTemp.put("appid", preparePayBean.appid); + sParaTemp.put("mch_id", preparePayBean.mch_id); + sParaTemp.put("openid", preparePayBean.openid); + sParaTemp.put("total_fee",preparePayBean.total_fee + ""); + sParaTemp.put("out_trade_no", preparePayBean.out_trade_no); + sParaTemp.put("body", preparePayBean.body); + sParaTemp.put("spbill_create_ip", preparePayBean.spbill_create_ip); + sParaTemp.put("notify_url",preparePayBean.notify_url); + sParaTemp.put("trade_type", preparePayBean.trade_type); + sParaTemp.put("nonce_str", preparePayBean.nonce_str); + + preparePayBean.sign = createSign(sParaTemp); + + String reqrXml = JacksonUtil.beanToXml(preparePayBean,"xml"); + String respXml = HttpsUtil.httpsRequest(URL_PREPARE_PAY,"POST",reqrXml); + + System.out.println("---------------PreparePay Request Xml-----------------"); + System.out.println(reqrXml); + System.out.println("---------------PreparePay Response Xml-----------------"); + System.out.println(respXml); + System.out.println("---------------PreparePay end-----------------"); + + PreparePayResultBean resultBean = null; + PreparePayReSignBean reSignBean = new PreparePayReSignBean(); + resultBean = JacksonUtil.xmlToBean(new ByteArrayInputStream(respXml.getBytes()),PreparePayResultBean.class); + + if(ObjectUtil.isNull(resultBean)) { + throw new PayException("PreparePay 返回的resultBean为空"); + } + + if(!StrUtil.isEmpty(resultBean.return_code) + && !StrUtil.isEmpty(resultBean.result_code)){ + if(resultBean.result_code.equals("SUCCESS") && resultBean.return_code.equals(resultBean.result_code)){ + reSignBean.nonceStr = createNonceStr(); + reSignBean._package = "prepay_id="+resultBean.prepay_id; + reSignBean.timeStamp = System.currentTimeMillis() / 1000; + reSignBean.signType = "MD5"; + + // 把请求参数打包成数组 + sParaTemp = new HashMap(); + sParaTemp.put("appId", appid); + sParaTemp.put("package", reSignBean._package); + sParaTemp.put("nonceStr", reSignBean.nonceStr); + sParaTemp.put("signType", reSignBean.signType); + sParaTemp.put("timeStamp",reSignBean.timeStamp + ""); + + reSignBean.paySign = createSign(sParaTemp); + + return reSignBean; + }else{ + throw new PayException("[" + resultBean.err_code + "]" + + resultBean.err_code_des); + } + }else { + throw new PayException(resultBean.return_msg); + } + //return null; + } + + /** + * Create Sign + * @param sParaTemp + * @return + */ + public static String createSign(Map sParaTemp){ + // 除去数组中的空值和签名参数 + Map sPara = paraFilter(sParaTemp); + String prestr = createLinkString(sPara); // 把数组所有元素,按照“参数=参数值”的模式用“&”字符拼接成字符串 + //MD5运算生成签名 + String sign = sign(prestr, key, "utf-8").toUpperCase(); + return sign; + } + + /** + * 除去数组中的空值和签名参数 + * @param sArray 签名参数组 + * @return 去掉空值与签名参数后的新签名参数组 + */ + private static Map paraFilter(Map sArray) { + Map result = new HashMap(); + if (sArray == null || sArray.size() <= 0) { + return result; + } + for (String key : sArray.keySet()) { + String value = "" + sArray.get(key); + if (StrUtil.isEmpty(value) || key.equalsIgnoreCase("sign") || key.equalsIgnoreCase("sign_type")) { + continue; + } + result.put(key, value); + } + return result; + } + + /** + * 把数组所有元素排序,并按照“参数=参数值”的模式用“&”字符拼接成字符串 + * @param params 需要排序并参与字符拼接的参数组 + * @return 拼接后字符串 + */ + private static String createLinkString(Map params) { + List keys = new ArrayList(params.keySet()); + Collections.sort(keys); + String prestr = ""; + for (int i = 0; i < keys.size(); i++) { + String key = keys.get(i); + String value = params.get(key); + if (i == keys.size() - 1) {// 拼接时,不包括最后一个&字符 + prestr = prestr + key + "=" + value; + } else { + prestr = prestr + key + "=" + value + "&"; + } + } + return prestr; + } + + /** + * 签名字符串 + * @param text 需要签名的字符串 + * @param key 密钥 + * @param input_charset 编码格式 + * @return 签名结果 + */ + private static String sign(String text, String key, String input_charset) { + text = text + "&key=" + key; + return DigestUtils.md5Hex(getContentBytes(text, input_charset)); + } + + /** + * @param content + * @param charset + * @return + * @throws + * @throws UnsupportedEncodingException + */ + private static byte[] getContentBytes(String content, String charset) { + if (charset == null || "".equals(charset)) { + return content.getBytes(); + } + try { + return content.getBytes(charset); + } catch (UnsupportedEncodingException e) { + throw new RuntimeException("MD5签名过程中出现错误,指定的编码集不对,您目前指定的编码集是:" + charset); + } + } + + private static String createNonceStr(){ + return UUID.randomUUID().toString().replace("-",""); + } + + public static Map payToUsrWx( + String partner_trade_no,String openid,int total_fee,String desc,String spbill_create_ip) + throws Exception{ + //1.构造请求字符串 + Map reqMap = new HashMap(); + reqMap.put("mch_appid",appid); + reqMap.put("mchid",mchid); + //reqMap.put("device_info",null); //不能添加空字段,Jackson会生成闭包xml 导致签名失败 + reqMap.put("nonce_str",createNonceStr()); + reqMap.put("partner_trade_no",partner_trade_no); + reqMap.put("openid",openid); + reqMap.put("check_name","NO_CHECK"); + //reqMap.put("re_user_name",null); + reqMap.put("amount",total_fee + ""); + reqMap.put("desc",desc); + reqMap.put("spbill_create_ip",spbill_create_ip); + reqMap.put("sign",createSign(reqMap)); + + //2.发送付款请求 + String reqrXml = JacksonUtil.mapToXml(reqMap,"xml"); + String respXml = HttpsUtil.httpsRequest(URL_PAY_TO_USR_WX,"POST",reqrXml, + WebConstant.PATH_WX_CRET,mchid); + System.out.println("---------------PayToUsrWx Request Xml-----------------"); + System.out.println(reqrXml); + System.out.println("---------------PayToUsrWx Response Xml-----------------"); + System.out.println(respXml); + System.out.println("---------------PayToUsrWx end-----------------"); + + //3.判断成功失败 + Map respMap = JacksonUtil.xmlToMap(new ByteArrayInputStream(respXml.getBytes())); + String return_code,result_code; + return_code = (String) respMap.get("return_code"); + result_code = (String) respMap.get("result_code"); + + if(!StrUtil.isEmpty(return_code) && !StrUtil.isEmpty(result_code)){ + if(return_code.equals("SUCCESS") && return_code.equals(result_code)){ + return respMap; + }else{ + throw new PayException("[" + respMap.get("err_code") + "]" + + respMap.get("err_code_des")); + } + }else { + throw new PayException((String) respMap.get("return_msg")); + } + //return null; + } + + public static Map payToUsrBank(){ + //Fix Me + return null; + } +} diff --git a/util/src/main/java/com/ccsens/util/WordToJpgUtil.java b/util/src/main/java/com/ccsens/util/WordToJpgUtil.java new file mode 100644 index 0000000..c1e7821 --- /dev/null +++ b/util/src/main/java/com/ccsens/util/WordToJpgUtil.java @@ -0,0 +1,104 @@ +//package com.ccsens.util;//package com.ccsens.ptpro.util; +// +//import com.artofsolving.jodconverter.DocumentConverter; +//import com.artofsolving.jodconverter.openoffice.connection.OpenOfficeConnection; +//import com.artofsolving.jodconverter.openoffice.connection.SocketOpenOfficeConnection; +//import com.artofsolving.jodconverter.openoffice.converter.OpenOfficeDocumentConverter; +// +// +//import org.apache.pdfbox.pdmodel.PDDocument; +//import org.apache.pdfbox.rendering.ImageType; +//import org.apache.pdfbox.rendering.PDFRenderer; +//import org.apache.pdfbox.tools.imageio.ImageIOUtil; +// +// +// +//import java.awt.image.BufferedImage; +//import java.io.*; +// +// +//public class WordToJpgUtil { +// /** +// * 预览word +// * word转换pdf +// * pdf转换jpg图片 +// * 返回图片地址 +// */ +// +// //word转换pdf +// public void wordToPDF(String wordPath, String pdfPath) throws IOException { +// System.out.println("//////////////////"+wordPath); +// System.out.println("//////////////////"+pdfPath); +// // 源文件目录 +// File inputFile = new File(wordPath); +// if (!inputFile.exists()) { +// System.out.println("源文件不存在!"); +// return; +// } +// // 输出文件目录 +// File outputFile = new File(pdfPath); +// if (!outputFile.getParentFile().exists()) { +// outputFile.getParentFile().exists(); +// } +// System.out.println(outputFile); +// // window 使用 调用openoffice服务线程 本机C盘!!! +//// String command = "c:\\Program Files (x86)\\OpenOffice 4\\program\\soffice -headless -accept=\"socket,host=127.0.0.1,port=8100;urp; -nofirststartwizard\""; +// //Linux使用 +// String command = "/opt/openoffice4/program/soffice -headless -accept=\"socket,host=127.0.0.1,port=8100;urp; -nofirststartwizard\""; +// Process p = Runtime.getRuntime().exec(command); +// System.out.println("*/*/*/*/*/*/*/*/*/*/*/*/准备连接!*/*/*/*/*/*/*/*/*/*"); +// // 连接openoffice服务 +// OpenOfficeConnection connection = new SocketOpenOfficeConnection( +// "127.0.0.1", 8100); +// connection.connect(); +// System.out.println("*/*/*/*/*/*/*/*/*/*/*/*/连接成功!*/*/*/*/*/*/*/*/*/*"); +// // 转换word到pdf +// DocumentConverter converter = new OpenOfficeDocumentConverter( +// connection); +// converter.convert(inputFile, outputFile); +// +// // 关闭连接 +// connection.disconnect(); +// +//// 关闭进程 +// p.destroy(); +// System.out.println("*/*/*/*/*/*/*/*/*/*/*/*/转换完成!*/*/*/*/*/*/*/*/*/*"); +// } +// +// //pdf转换jpg +// public static void pdfToJpg(String inputFile, String outputFolder) throws IOException { +// PDDocument doc = PDDocument.load(new File(inputFile)); +// int pageCount = doc.getNumberOfPages(); +// PDFRenderer pdfRenderer = new PDFRenderer(doc); +// for (int pageIndex = 0; pageIndex < pageCount; pageIndex++) { +// BufferedImage image = pdfRenderer.renderImageWithDPI(pageIndex, 105, ImageType.RGB); +// ImageIOUtil.writeImage(image, outputFolder, 105); +// } +// doc.close(); +// } +// +// +//// public static void main(String args[]) throws Exception { +//// String wordPath = "C:\\Users\\逗\\Desktop\\新建文件夹\\MMSE量表.doc"; +//// String pdfPath = "C:\\Users\\逗\\Desktop\\MMSE量表.pdf"; +//// String imgPath = "C:\\Users\\逗\\Desktop\\ADL.jpg"; +//// WordToJpgUtil j = new WordToJpgUtil(); +////// System.out.println(j.wordToJpg(wordPath,pdfPath,imgPath)); +//// j.wordToPDF(wordPath,pdfPath); +////// j.pdfToJpg(pdfPath,imgPath); +//// } +// +// public static String wordToJpg(String wordPath, String pdfPath, String imgPath) throws IOException { +// String dir = Constant.UPLOAD_PATH_BASE + File.separator + Constant.UPLOAD_PATH_PREVIEW; +// String pdf = dir + File.separator + pdfPath;//pdf地址 +// String img = dir + File.separator + imgPath;//img地址 +// WordToJpgUtil w = new WordToJpgUtil(); +// w.wordToPDF(wordPath, pdf); +// System.out.println("########已经是pdf############"); +// w.pdfToJpg(pdf, img); +// System.out.println("**********完成,已经是图片***********"); +// String returnImgPath = Constant.URL_BASE + Constant.UPLOAD_PATH_PREVIEW + File.separator + imgPath; +// return returnImgPath; +// } +// +//} diff --git a/util/src/main/java/com/ccsens/util/WpsSignature.java b/util/src/main/java/com/ccsens/util/WpsSignature.java new file mode 100644 index 0000000..3fcf180 --- /dev/null +++ b/util/src/main/java/com/ccsens/util/WpsSignature.java @@ -0,0 +1,85 @@ +package com.ccsens.util; + +import cn.hutool.core.codec.Base64; + +import javax.crypto.Mac; +import javax.crypto.spec.SecretKeySpec; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.security.InvalidKeyException; +import java.security.NoSuchAlgorithmException; +import java.util.*; + + +/** + * @description: + * @author: whj + * @time: 2020/6/17 9:59 + */ +public class WpsSignature { + + + + public static String getUrlParam(Map params) throws UnsupportedEncodingException { + StringBuilder builder = new StringBuilder(); + for (Map.Entry entry : params.entrySet()) { + if (builder.length() > 0) { + builder.append('&'); + } + builder.append(URLEncoder.encode(entry.getKey(), "utf-8")).append('=').append(URLEncoder.encode(entry.getValue(), "utf-8")); + } + return builder.toString(); + } + + public static String getSignature(Map params, String appSecret) { + List keys=new ArrayList(); + for (Map.Entry entry : params.entrySet()) { + keys.add(entry.getKey()); + } + + // 将所有参数按key的升序排序 + Collections.sort(keys, new Comparator() { + @Override + public int compare(String o1, String o2) { + return o1.compareTo(o2); + } + }); + + // 构造签名的源字符串 + StringBuilder contents=new StringBuilder(""); + for (String key : keys) { + if ("_w_signature".equals(key)){ + continue; + } + contents.append(key).append("=").append(params.get(key)); + } + contents.append("_w_secretkey=").append(appSecret); + + // 进行hmac sha1 签名 + byte[] bytes= hmacSha1(appSecret.getBytes(),contents.toString().getBytes()); + //字符串经过Base64编码 + String sign= Base64.encode(bytes); + try { + sign = URLEncoder.encode( sign, "UTF-8"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + System.out.println(sign); + return sign; + } + + public static byte[] hmacSha1(byte[] key, byte[] data) { + try { + SecretKeySpec signingKey = new SecretKeySpec(key, "HmacSHA1"); + Mac mac = Mac.getInstance(signingKey.getAlgorithm()); + mac.init(signingKey); + return mac.doFinal(data); + } + catch (NoSuchAlgorithmException e) { + e.printStackTrace(); + } catch (InvalidKeyException e) { + e.printStackTrace(); + } + return null; + } +} diff --git a/util/src/main/java/com/ccsens/util/ali/AliInstanceUtil.java b/util/src/main/java/com/ccsens/util/ali/AliInstanceUtil.java new file mode 100644 index 0000000..c1839d4 --- /dev/null +++ b/util/src/main/java/com/ccsens/util/ali/AliInstanceUtil.java @@ -0,0 +1,27 @@ +package com.ccsens.util.ali; + +import com.alibaba.cloudapi.sdk.model.HttpClientBuilderParams; + +/** + * @description: + * @author: whj + * @time: 2021/4/25 16:53 + */ +public class AliInstanceUtil { + + private static String appKey = "203933478"; + private static String appSecret = "KrDev8GlVu6DyMOhjGSudngDZ8RsslYE"; + + /** + * + * @return + */ + public static HttpsApiClientlyocr_general_advanced getGeneralAdvancedHttps(){ + HttpClientBuilderParams httpsParam = new HttpClientBuilderParams(); + httpsParam.setAppKey(appKey); + httpsParam.setAppSecret(appSecret); + HttpsApiClientlyocr_general_advanced instance = HttpsApiClientlyocr_general_advanced.getInstance(); + instance.init(httpsParam); + return instance; + } +} diff --git a/util/src/main/java/com/ccsens/util/ali/Demolyocr_general_advanced.java b/util/src/main/java/com/ccsens/util/ali/Demolyocr_general_advanced.java new file mode 100644 index 0000000..98d141e --- /dev/null +++ b/util/src/main/java/com/ccsens/util/ali/Demolyocr_general_advanced.java @@ -0,0 +1,168 @@ +// +// Created by fred on 2016/10/26. +// Copyright © 2016年 Alibaba. All rights reserved. +// + +package com.ccsens.util.ali; + +import com.alibaba.cloudapi.sdk.constant.SdkConstant; +import com.alibaba.cloudapi.sdk.model.ApiCallback; +import com.alibaba.cloudapi.sdk.model.ApiRequest; +import com.alibaba.cloudapi.sdk.model.ApiResponse; +import com.alibaba.cloudapi.sdk.model.HttpClientBuilderParams; +import java.io.IOException; + + + +import org.apache.http.config.Registry; +import org.apache.http.config.RegistryBuilder; +import org.apache.http.conn.socket.ConnectionSocketFactory; +import org.apache.http.conn.socket.PlainConnectionSocketFactory; +import org.apache.http.conn.ssl.SSLConnectionSocketFactory; +import org.apache.http.ssl.SSLContextBuilder; +import org.apache.http.ssl.TrustStrategy; +import javax.net.ssl.*; +import java.security.KeyStore; +import java.security.cert.CertificateException; +import java.security.cert.X509Certificate; + +public class Demolyocr_general_advanced { + + + static{ + //HTTP Client init + HttpClientBuilderParams httpParam = new HttpClientBuilderParams(); + httpParam.setAppKey("203933478"); + httpParam.setAppSecret("KrDev8GlVu6DyMOhjGSudngDZ8RsslYE"); + HttpApiClientlyocr_general_advanced.getInstance().init(httpParam); + + + //HTTPS Client init + HttpClientBuilderParams httpsParam = new HttpClientBuilderParams(); + httpsParam.setAppKey("203933478"); + httpsParam.setAppSecret("KrDev8GlVu6DyMOhjGSudngDZ8RsslYE"); + + /** + * HTTPS request use DO_NOT_VERIFY mode only for demo + * Suggest verify for security + */ + //httpsParam.setRegistry(getNoVerifyRegistry()); + + HttpsApiClientlyocr_general_advanced.getInstance().init(httpsParam); + + + } + + + public static void ocrAdvancedHttpsTest(){ + HttpsApiClientlyocr_general_advanced.getInstance().ocrAdvanced("default".getBytes(SdkConstant.CLOUDAPI_ENCODING) , new ApiCallback() { + @Override + public void onFailure(ApiRequest request, Exception e) { + e.printStackTrace(); + } + + @Override + public void onResponse(ApiRequest request, ApiResponse response) { + try { + System.out.println(getResultString(response)); + }catch (Exception ex){ + ex.printStackTrace(); + } + } + }); + } + + public static void ocrAdvancedHttpsSyncTest(){ + ApiResponse response = HttpsApiClientlyocr_general_advanced.getInstance().ocrAdvancedSyncMode("default".getBytes(SdkConstant.CLOUDAPI_ENCODING)); + try { + System.out.println(getResultString(response)); + }catch (Exception ex){ + ex.printStackTrace(); + } + } + + + + private static String getResultString(ApiResponse response) throws IOException { + StringBuilder result = new StringBuilder(); + result.append("Response from backend server").append(SdkConstant.CLOUDAPI_LF).append(SdkConstant.CLOUDAPI_LF); + result.append("ResultCode:").append(SdkConstant.CLOUDAPI_LF).append(response.getCode()).append(SdkConstant.CLOUDAPI_LF).append(SdkConstant.CLOUDAPI_LF); + if(response.getCode() != 200){ + result.append("Error description:").append(response.getHeaders().get("X-Ca-Error-Message")).append(SdkConstant.CLOUDAPI_LF).append(SdkConstant.CLOUDAPI_LF); + } + + result.append("ResultBody:").append(SdkConstant.CLOUDAPI_LF).append(new String(response.getBody() , SdkConstant.CLOUDAPI_ENCODING)); + + return result.toString(); + } + + private static Registry getNoVerifyRegistry() { + RegistryBuilder registryBuilder = RegistryBuilder.create(); + try { + registryBuilder.register("http", PlainConnectionSocketFactory.INSTANCE).build(); + registryBuilder.register( + "https", + new SSLConnectionSocketFactory(new SSLContextBuilder().loadTrustMaterial( + KeyStore.getInstance(KeyStore.getDefaultType()), new TrustStrategy() { + @Override + public boolean isTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException { + return true; + } + }).build(), + new HostnameVerifier() { + @Override + public boolean verify(String paramString, SSLSession paramSSLSession) { + return true; + } + })); + + } catch (Exception e) { + throw new RuntimeException("HttpClientUtil init failure !", e); + } + return registryBuilder.build(); + } + + + private static void trustAllHttpsCertificates() throws Exception { + javax.net.ssl.TrustManager[] trustAllCerts = new javax.net.ssl.TrustManager[1]; + javax.net.ssl.TrustManager tm = new miTM(); + trustAllCerts[0] = tm; + javax.net.ssl.SSLContext sc = javax.net.ssl.SSLContext + .getInstance("SSL"); + sc.init(null, trustAllCerts, null); + javax.net.ssl.HttpsURLConnection.setDefaultSSLSocketFactory(sc + .getSocketFactory()); + } + + static class miTM implements javax.net.ssl.TrustManager, + javax.net.ssl.X509TrustManager { + @Override + public java.security.cert.X509Certificate[] getAcceptedIssuers() { + return null; + } + + public boolean isServerTrusted( + java.security.cert.X509Certificate[] certs) { + return true; + } + + public boolean isClientTrusted( + java.security.cert.X509Certificate[] certs) { + return true; + } + + @Override + public void checkServerTrusted( + java.security.cert.X509Certificate[] certs, String authType) + throws java.security.cert.CertificateException { + return; + } + + @Override + public void checkClientTrusted( + java.security.cert.X509Certificate[] certs, String authType) + throws java.security.cert.CertificateException { + return; + } + } +} diff --git a/util/src/main/java/com/ccsens/util/ali/HttpApiClientlyocr_general_advanced.java b/util/src/main/java/com/ccsens/util/ali/HttpApiClientlyocr_general_advanced.java new file mode 100644 index 0000000..99c5d95 --- /dev/null +++ b/util/src/main/java/com/ccsens/util/ali/HttpApiClientlyocr_general_advanced.java @@ -0,0 +1,34 @@ +// +// Created by fred on 2017/1/12. +// Copyright © 2016年 Alibaba. All rights reserved. +// + +package com.ccsens.util.ali; +import com.alibaba.cloudapi.sdk.client.ApacheHttpClient; +import com.alibaba.cloudapi.sdk.enums.Scheme; +import com.alibaba.cloudapi.sdk.enums.HttpMethod; +import com.alibaba.cloudapi.sdk.model.ApiRequest; +import com.alibaba.cloudapi.sdk.model.ApiResponse; +import com.alibaba.cloudapi.sdk.model.ApiCallback; +import com.alibaba.cloudapi.sdk.model.HttpClientBuilderParams; +import com.alibaba.cloudapi.sdk.enums.ParamPosition; +import com.alibaba.cloudapi.sdk.enums.WebSocketApiType; +import com.alibaba.fastjson.JSONObject; + + +public class HttpApiClientlyocr_general_advanced extends ApacheHttpClient{ + public final static String HOST = "ocrapi-advanced.taobao.com"; + static HttpApiClientlyocr_general_advanced instance = new HttpApiClientlyocr_general_advanced(); + public static HttpApiClientlyocr_general_advanced getInstance(){return instance;} + + public void init(HttpClientBuilderParams httpClientBuilderParams){ + httpClientBuilderParams.setScheme(Scheme.HTTP); + httpClientBuilderParams.setHost(HOST); + super.init(httpClientBuilderParams); + } + + + + + +} \ No newline at end of file diff --git a/util/src/main/java/com/ccsens/util/ali/HttpsApiClientlyocr_general_advanced.java b/util/src/main/java/com/ccsens/util/ali/HttpsApiClientlyocr_general_advanced.java new file mode 100644 index 0000000..fa99dcb --- /dev/null +++ b/util/src/main/java/com/ccsens/util/ali/HttpsApiClientlyocr_general_advanced.java @@ -0,0 +1,50 @@ +// +// Created by fred on 2017/1/12. +// Copyright © 2016年 Alibaba. All rights reserved. +// + +package com.ccsens.util.ali; + +import com.alibaba.cloudapi.sdk.client.ApacheHttpClient; +import com.alibaba.cloudapi.sdk.enums.HttpMethod; +import com.alibaba.cloudapi.sdk.enums.ParamPosition; +import com.alibaba.cloudapi.sdk.enums.Scheme; +import com.alibaba.cloudapi.sdk.model.ApiCallback; +import com.alibaba.cloudapi.sdk.model.ApiRequest; +import com.alibaba.cloudapi.sdk.model.ApiResponse; +import com.alibaba.cloudapi.sdk.model.HttpClientBuilderParams; +import com.alibaba.cloudapi.sdk.enums.WebSocketApiType; +import com.alibaba.fastjson.JSONObject; + +public class HttpsApiClientlyocr_general_advanced extends ApacheHttpClient{ + public final static String HOST = "ocrapi-advanced.taobao.com"; + static HttpsApiClientlyocr_general_advanced instance = new HttpsApiClientlyocr_general_advanced(); + public static HttpsApiClientlyocr_general_advanced getInstance(){return instance;} + + public void init(HttpClientBuilderParams httpClientBuilderParams){ + httpClientBuilderParams.setScheme(Scheme.HTTPS); + httpClientBuilderParams.setHost(HOST); + super.init(httpClientBuilderParams); + } + + + + public void ocrAdvanced(byte[] body , ApiCallback callback) { + String path = "/ocrservice/advanced"; + ApiRequest request = new ApiRequest(HttpMethod.POST_BODY , path, body); + + + + sendAsyncRequest(request , callback); + } + + public ApiResponse ocrAdvancedSyncMode(byte[] body) { + String path = "/ocrservice/advanced"; + ApiRequest request = new ApiRequest(HttpMethod.POST_BODY , path, body); + + + + return sendSyncRequest(request); + } + +} \ No newline at end of file diff --git a/util/src/main/java/com/ccsens/util/annotation/OperateType.java b/util/src/main/java/com/ccsens/util/annotation/OperateType.java new file mode 100644 index 0000000..3b417b3 --- /dev/null +++ b/util/src/main/java/com/ccsens/util/annotation/OperateType.java @@ -0,0 +1,16 @@ +package com.ccsens.util.annotation; + +import java.lang.annotation.*; +import java.util.List; + +/** + * @author 逗 + */ +@Documented +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.METHOD) +public @interface OperateType { + public int value(); + + +} diff --git a/util/src/main/java/com/ccsens/util/baidu/BaiDuDto.java b/util/src/main/java/com/ccsens/util/baidu/BaiDuDto.java new file mode 100644 index 0000000..1a5e781 --- /dev/null +++ b/util/src/main/java/com/ccsens/util/baidu/BaiDuDto.java @@ -0,0 +1,20 @@ +package com.ccsens.util.baidu; + +import io.swagger.annotations.ApiModel; +import lombok.Data; + +/** + * @description: + * @author: whj + * @time: 2021/3/31 16:39 + */ +public class BaiDuDto { + + @ApiModel("通用文字识别(标准版)-请求参数") + @Data + public static class GeneralBasic{ + private String image; + private String url; + private String detect_direction = "true"; + } +} diff --git a/util/src/main/java/com/ccsens/util/baidu/BaiDuUtil.java b/util/src/main/java/com/ccsens/util/baidu/BaiDuUtil.java new file mode 100644 index 0000000..3ba89e9 --- /dev/null +++ b/util/src/main/java/com/ccsens/util/baidu/BaiDuUtil.java @@ -0,0 +1,124 @@ +package com.ccsens.util.baidu; + +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSONObject; +import com.ccsens.util.CodeEnum; +import com.ccsens.util.RedisUtil; +import com.ccsens.util.RestTemplateUtil; +import com.ccsens.util.exception.BaseException; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +import javax.annotation.PostConstruct; +import javax.annotation.Resource; + +/** + * @description: 百度API + * @author: whj + * @time: 2021/3/31 15:30 + */ +@Component +@Slf4j +public class BaiDuUtil { + + @Resource + private RedisUtil redisUtil; + private static BaiDuUtil util; + /**token_appKey*/ + private static final String TOKEN_KEY = "baidu_token_"; + + private static final String AUTH_URL = "https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&client_id={}&client_secret={}"; + private static final String GENERAL_BASIC_URL = "https://aip.baidubce.com/rest/2.0/ocr/v1/general_basic?access_token={}"; + /**通用文字识别(高精度版)*/ + private static final String ACCURATE_BASIC_URL = "https://aip.baidubce.com/rest/2.0/ocr/v1/accurate_basic?access_token={}"; + + @PostConstruct + public void init(){ + util = this; + util.redisUtil = this.redisUtil; + } + + /** + * 获取token + * @param appKey appKey + * @param secretKey secretKey + * @return token + */ + public static String getToken(String appKey, String secretKey){ + log.info("获取百度认证:{},{}", appKey, secretKey); + String key = TOKEN_KEY + appKey; + String token = (String) util.redisUtil.get(key); + log.info("缓存token:{}", token); + if (StrUtil.isNotEmpty(token)) { + return token; + } + String url = StrUtil.format(AUTH_URL, appKey, secretKey); + String result = RestTemplateUtil.postUrlEncode(url, null); + log.info("获取百度认证:{}", result); + JSONObject json = JSONObject.parseObject(result); + if (json.containsKey(Code.ERROR)) { + log.info("获取token失败"); + CodeEnum thirdError = CodeEnum.THIRD_ERROR; + thirdError.setMsg(result); + throw new BaseException(thirdError); + } + token = json.getString(Code.ACCESS_TOKEN); + // 有效期,减10分钟 + int expiresTime = json.getIntValue(Code.EXPIRES_TIME) - 10*60; + util.redisUtil.set(key, token, expiresTime); + return token; + } + + /** + * 调用百度通用文字识别(高精度版) + * @param appKey appKey + * @param secretKey secretKey + * @param basic 图像 + * @return 识别结果 + */ + public static BaiDuVo.GeneralBasic accurateBasic(String appKey, String secretKey, BaiDuDto.GeneralBasic basic) { + return getGeneralBasic(appKey, secretKey, basic, ACCURATE_BASIC_URL); + } + + /** + * 调用百度通用文字识别 + * @param appKey appKey + * @param secretKey secretKey + * @param basic 图像 + * @param accurateBasicUrl 路径 + * @return 识别结果 + */ + private static BaiDuVo.GeneralBasic getGeneralBasic(String appKey, String secretKey, BaiDuDto.GeneralBasic basic, String accurateBasicUrl) { + String token = getToken(appKey, secretKey); + String url = StrUtil.format(accurateBasicUrl, token); + String result = RestTemplateUtil.postUrlEncode(url, basic); + log.info("百度orc调用{}的结果是:{}", url, result); + if (result.contains(Code.GENERAL_BASIC_ERROR)) { + CodeEnum thirdError = CodeEnum.THIRD_ERROR; + thirdError.setMsg(result); + throw new BaseException(thirdError); + } + return JSONObject.parseObject(result, BaiDuVo.GeneralBasic.class); + } + + /** + * 调用百度通用文字识别(标准版) + * @param appKey appKey + * @param secretKey secretKey + * @param basic 图像 + * @return 识别结果 + */ + public static BaiDuVo.GeneralBasic generalBasic(String appKey, String secretKey, BaiDuDto.GeneralBasic basic) { + return getGeneralBasic(appKey, secretKey, basic, GENERAL_BASIC_URL); + } + + private static class Code{ + private final static String ERROR = "error"; + private final static String GENERAL_BASIC_ERROR = "error_code"; + private final static String ERROR_DESC = "error_description"; + private final static String ACCESS_TOKEN = "access_token"; + private final static String EXPIRES_TIME = "expires_in"; + + } + +} diff --git a/util/src/main/java/com/ccsens/util/baidu/BaiDuVo.java b/util/src/main/java/com/ccsens/util/baidu/BaiDuVo.java new file mode 100644 index 0000000..4c722df --- /dev/null +++ b/util/src/main/java/com/ccsens/util/baidu/BaiDuVo.java @@ -0,0 +1,33 @@ +package com.ccsens.util.baidu; + +import com.alibaba.fastjson.annotation.JSONField; +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModel; +import lombok.Data; + +import java.util.List; + +/** + * @description: + * @author: whj + * @time: 2021/3/31 16:11 + */ +public class BaiDuVo { + + @ApiModel("通用文字识别(标准版)") + @Data + public static class GeneralBasic{ + @JSONField(name="log_id") + private String logId; + @JSONField(name="words_result") + private List wordsResult; + @JSONField(name="words_result_num") + private int wordsResultNum; + } + + @Data + @ApiModel("文字识别-文字") + public static class GeneralWord{ + private String words; + } +} diff --git a/util/src/main/java/com/ccsens/util/bean/dto/QueryDto.java b/util/src/main/java/com/ccsens/util/bean/dto/QueryDto.java new file mode 100644 index 0000000..2ffffde --- /dev/null +++ b/util/src/main/java/com/ccsens/util/bean/dto/QueryDto.java @@ -0,0 +1,29 @@ +package com.ccsens.util.bean.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.Valid; + +/** + * @program: ptpro + * @description: 编辑病人信息 + * @author: wu huijuan + * @create: 2019/10/30 14:33 + */ +@ApiModel +@Data +public class QueryDto { + @ApiModelProperty("真正的请求参数") + @Valid + private T param; + @ApiModelProperty("登录用户ID 前端不为userId赋值") + private Long userId; + @ApiModelProperty("用户名") + private String userName; + @ApiModelProperty("头像") + private String avatarUrl; + @ApiModelProperty("手机号") + private String phone; +} diff --git a/util/src/main/java/com/ccsens/util/bean/message/client/AckMessage.java b/util/src/main/java/com/ccsens/util/bean/message/client/AckMessage.java new file mode 100644 index 0000000..567a222 --- /dev/null +++ b/util/src/main/java/com/ccsens/util/bean/message/client/AckMessage.java @@ -0,0 +1,31 @@ +package com.ccsens.util.bean.message.client; + +import com.ccsens.util.bean.message.common.MessageConstant; +import com.ccsens.util.bean.message.common.ServerMessage; +import lombok.Data; +import lombok.Getter; +import lombok.Setter; + +/** + * @author wei + */ +@Data +public class AckMessage extends ServerMessage { + @Setter + @Getter + public static class Data { + String ackId; + } + + private Data data; + + public AckMessage(){ + setType(MessageConstant.ClientMessageType.Ack.name()); + } + + public AckMessage(String ackId){ + this(); + data = new Data(); + data.setAckId(ackId); + } +} diff --git a/util/src/main/java/com/ccsens/util/bean/message/client/AuthMessage.java b/util/src/main/java/com/ccsens/util/bean/message/client/AuthMessage.java new file mode 100644 index 0000000..6c2df5c --- /dev/null +++ b/util/src/main/java/com/ccsens/util/bean/message/client/AuthMessage.java @@ -0,0 +1,37 @@ +package com.ccsens.util.bean.message.client; + + +import com.ccsens.util.bean.message.common.MessageConstant; +import com.ccsens.util.bean.message.common.ServerMessage; +import lombok.Data; +import lombok.Getter; +import lombok.Setter; + +/** + * @author wei + * 客户端认证 (user) + */ +@Data +public class AuthMessage extends ServerMessage { + @Setter + @Getter + public static class Data{ + private String token; + private int major; + private int minor; + } + + private Data data; + + public AuthMessage(){ + setType(MessageConstant.ClientMessageType.Auth.name()); + } + + public AuthMessage(String token,int major,int minor){ + this(); + data = new Data(); + data.setToken(token); + data.setMajor(major); + data.setMinor(minor); + } +} diff --git a/util/src/main/java/com/ccsens/util/bean/message/client/ClientAuthTimeOutMessage.java b/util/src/main/java/com/ccsens/util/bean/message/client/ClientAuthTimeOutMessage.java new file mode 100644 index 0000000..3524395 --- /dev/null +++ b/util/src/main/java/com/ccsens/util/bean/message/client/ClientAuthTimeOutMessage.java @@ -0,0 +1,17 @@ +package com.ccsens.util.bean.message.client; + + +import com.ccsens.util.bean.message.common.MessageConstant; +import com.ccsens.util.bean.message.common.ServerMessage; +import lombok.Data; + +/** + * @author wei + * 客户端向服务器请求当前连接状态 + */ +@Data +public class ClientAuthTimeOutMessage extends ServerMessage { + public ClientAuthTimeOutMessage(){ + setType(MessageConstant.ClientMessageType.ClientAuthTimeOut.name()); + } +} diff --git a/util/src/main/java/com/ccsens/util/bean/message/client/ClientIdleClosedMessage.java b/util/src/main/java/com/ccsens/util/bean/message/client/ClientIdleClosedMessage.java new file mode 100644 index 0000000..c83b6ae --- /dev/null +++ b/util/src/main/java/com/ccsens/util/bean/message/client/ClientIdleClosedMessage.java @@ -0,0 +1,17 @@ +package com.ccsens.util.bean.message.client; + + +import com.ccsens.util.bean.message.common.MessageConstant; +import com.ccsens.util.bean.message.common.ServerMessage; +import lombok.Data; + +/** + * @author wei + * 客户端向服务器请求当前连接状态 + */ +@Data +public class ClientIdleClosedMessage extends ServerMessage { + public ClientIdleClosedMessage(){ + setType(MessageConstant.ClientMessageType.ClientIdleClosed.name()); + } +} diff --git a/util/src/main/java/com/ccsens/util/bean/message/client/GetStatusMessage.java b/util/src/main/java/com/ccsens/util/bean/message/client/GetStatusMessage.java new file mode 100644 index 0000000..598794f --- /dev/null +++ b/util/src/main/java/com/ccsens/util/bean/message/client/GetStatusMessage.java @@ -0,0 +1,17 @@ +package com.ccsens.util.bean.message.client; + + +import com.ccsens.util.bean.message.common.MessageConstant; +import com.ccsens.util.bean.message.common.ServerMessage; +import lombok.Data; + +/** + * @author wei + * 客户端向服务器请求当前连接状态 + */ +@Data +public class GetStatusMessage extends ServerMessage { + public GetStatusMessage(){ + setType(MessageConstant.ClientMessageType.GetChannelStatus.name()); + } +} diff --git a/util/src/main/java/com/ccsens/util/bean/message/client/HasReadMessage.java b/util/src/main/java/com/ccsens/util/bean/message/client/HasReadMessage.java new file mode 100644 index 0000000..2575b85 --- /dev/null +++ b/util/src/main/java/com/ccsens/util/bean/message/client/HasReadMessage.java @@ -0,0 +1,37 @@ +package com.ccsens.util.bean.message.client; + + +import com.ccsens.util.bean.message.common.MessageConstant; +import com.ccsens.util.bean.message.common.ServerMessage; +import lombok.Data; +import lombok.Getter; +import lombok.Setter; + +/** + * @author wei + */ +@Data +public class HasReadMessage extends ServerMessage { + /** + * fromDomain域的fromUserId用户 给我发送的所有 时间 tos; + /** + * 消息的标示符(通常是由用户传过来的消息ID,该消息在用户系统中的ID) + */ + private String unikey; + /** + * 发送规则 + * DeSerialize but not serialize @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) + */ + private MessageRule rule; + /** + * 发送内容 + * 如果toDomain是Server: 代表消息是发给当前服务器的,必须是MessageSysData的子类型 + * 其他:(格式不限,由用户指定) + */ + private String data; + + + public InMessage(){ + this.time = DateUtil.currentSeconds(); + } + public static InMessage newToServerMessage(MessageConstant.DomainType fromDomain,ServerMessage serverMessage) throws JsonProcessingException { + InMessage inMessage = new InMessage(); + inMessage.setFromDomain(fromDomain); + inMessage.setToDomain(MessageConstant.DomainType.Server); + inMessage.setData(JacksonUtil.beanToJson(serverMessage)); + return inMessage; + } + + public static InMessage newToQueueMessage(String from, Set tos, String unikey, MessageRule rule, String data) throws JsonProcessingException { + InMessage inMessage = new InMessage(); + inMessage.setToDomain(MessageConstant.DomainType.Queue); + inMessage.setFrom(from); + inMessage.setTos(tos); + inMessage.setUnikey(unikey); + inMessage.setRule(rule); + inMessage.setData(data); + return inMessage; + } + public static InMessage newToUserMessage(String from, Set tos, String unikey, MessageRule rule, String data) throws JsonProcessingException { + InMessage inMessage = new InMessage(); + inMessage.setToDomain(MessageConstant.DomainType.User); + inMessage.setFrom(from); + inMessage.setTos(tos); + inMessage.setUnikey(unikey); + inMessage.setRule(rule); + inMessage.setData(data); + return inMessage; + } + + + //TODO + //添加方便链式调用的构造方法,类似builder + + @Data + @ApiModel("接收消息者") + public static class To{ + private Long id; + + public To() { + } + public To(Long id) { + this.id = id; + } + + } + + /** + * 将userids列表转成tos格式 + * @param userIds + * @return + */ + public static Set transTos(List userIds) { + + Set sets = new HashSet<>(); + if (CollectionUtil.isEmpty(userIds)) { + return sets; + } + userIds.forEach(userId -> { + To to = new To(userId); + sets.add(JSONObject.toJSONString(to)); + }); + return sets; + } +} diff --git a/util/src/main/java/com/ccsens/util/bean/message/common/Message.java b/util/src/main/java/com/ccsens/util/bean/message/common/Message.java new file mode 100644 index 0000000..cc06b18 --- /dev/null +++ b/util/src/main/java/com/ccsens/util/bean/message/common/Message.java @@ -0,0 +1,134 @@ +package com.ccsens.util.bean.message.common; + +import cn.hutool.core.date.DateUtil; +import lombok.Data; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author wei + */ +@Data +public class Message { + /** + * 消息ID (Message's ID) + */ + private String id; + + /** + * 原始消息ID (InMessage's ID) + */ + private String rawId; + + /** + * 发送时间(s) + * Notice: 指的是服务器收到发送请求的时间,不是服务器发出消息的时间 + */ + private Long time; + /** + * 消息来自于那个域 + */ + private MessageConstant.DomainType fromDomain; + /** + * 发送者信息 + */ + private String from; + /** + * 消息要发送到哪个域 + */ + private MessageConstant.DomainType toDomain; + /** + * 接受者信息(列表) + */ + private String to; + /** + * 发送规则 + * DeSerialize but not serialize @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) + */ + private MessageRule rule; + /** + * 发送内容 + * 如果toDomain是Server: 代表消息是发给当前服务器的,必须是MessageSysData的子类型 + * 其他:(格式不限,由用户指定) + */ + private String data; + + /** + * 是否收到用户的ack消息 + */ + private byte acked; + /** + * 是否收到用户的已读消息 + */ + private byte hasRead; + /** + * 消息状态 + * 发送成功标志:根据配置由三种情况 + * 1. 配置不需要客户端ack, + * 发送完毕自动设置 ack = true; + * rule -> ackIsSuccess = true 发送即代表成功 + * rule -> ackIsSuccess = false 等待用户手动设置成功标志 + * 2. 配置需要ack,则发送并受到ack代表成功 + * rule -> ackIsSuccess = true 发送并收到ack即代表成功 + * rule -> ackIsSuccess = false 等待用户手动设置成功标志 + */ + private MessageConstant.Status status; + + /** + * 发送次数 + */ + private int sendTimes; + /** + * 发送时间 + */ + private List sendTimeInSecondList; + + public Message(){ + } + + public Message(MessageConstant.DomainType fromDomain,String from,MessageConstant.DomainType toDomain,String to,String data,MessageRule rule){ + this.time = DateUtil.currentSeconds(); + this.fromDomain = fromDomain; + this.from = from; + this.toDomain = toDomain; + this.to = to; + this.data = data; + this.rule = rule; + } + + public Message(InMessage inEntity, String to){ + this.rawId = inEntity.getId(); + this.time = inEntity.getTime(); + this.fromDomain = inEntity.getFromDomain(); + this.from = inEntity.getFrom(); + this.toDomain = inEntity.getToDomain(); + this.to = to; + this.rule = inEntity.getRule(); + this.data = inEntity.getData(); + + this.acked = 0; + this.hasRead = 0; + this.status = MessageConstant.Status.Pending; + this.sendTimes = 0; + } + + public void incrementSendTimes() { + this.sendTimes++; + if(this.sendTimeInSecondList == null){ + this.sendTimeInSecondList = new ArrayList<>(); + } + this.sendTimeInSecondList.add(DateUtil.currentSeconds()); + } + + public boolean isSendTimesUpLimit() { + if((rule.getNoAckRetryTimes() > 0) && (sendTimes >= rule.getNoAckRetryTimes())){ + return true; + } + return false; + } + + public boolean isExpired() { + return DateUtil.currentSeconds() >= rule.getExpireAt(); + } +} diff --git a/util/src/main/java/com/ccsens/util/bean/message/common/MessageConstant.java b/util/src/main/java/com/ccsens/util/bean/message/common/MessageConstant.java new file mode 100644 index 0000000..b9586b1 --- /dev/null +++ b/util/src/main/java/com/ccsens/util/bean/message/common/MessageConstant.java @@ -0,0 +1,320 @@ +package com.ccsens.util.bean.message.common; + +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; + +/** + * @author wei + * 消息相关常量 + */ +public class MessageConstant { + + /** + * redis参数 + */ + public static class Redis{ + /**mq集合key*/ + public static final String KEY_MQ_COLLECTION = "mqCollection"; + } + + + /** + * 寄存器地址 + */ + public enum Register{ + /**授权*/ + Auth((byte) 0x00, (byte) 0x01), + /**心跳*/ + Ping((byte) 0x00, (byte) 0x02), + ; + + public byte first; + public byte second; + + Register(byte first, byte second){ + this.first = first; + this.second = second; + + } + + public long getAddr(){ + long addr = ((long)first << 8 | second) & 0xFFFF; + return addr; + } + + public static Register valueOf(byte first, byte second) { + for(Register register : Register.values()){ + if (register.first == first && register.second == second) { + return register; + } + } + return null; + } + } + + public enum ClientMessageType{ + //客户端心跳 + Ping(0x00), + //客户端认证 + Auth(0x01), + feedback(0x01), + + + //客户端收到消息ACK + Ack(0x02), + //客户端收到消息ACK + HasRead(0x03), + //客户端请求连接状态 + GetChannelStatus(0x04), + ModBus(0x05), + //不可预期的错误 + UnExceptedError(0x21), + ClientIdleClosed(0x22), + ClientAuthTimeOut(0x23), + + //设置消息状态消息(disable撤销消息,适用于,消息撤回),针对消息本身(eg:消息撤回) + SetMsgSuccess(0x52), + SetMsgReverted(0x53), + SetMsgDeleted(0x54); + + public int value; + + ClientMessageType(int value){ + this.value = value; + } + + /** + * 从int到enum的转换函数 + * @param value 枚举int值 + * @return 对应的枚举,找不到则返回null + */ + public static ClientMessageType valueOf(int value) { + for(ClientMessageType type : values()){ + if(type.value == value){ + return type; + } + } + return null; + } + } + + public enum ServerMessageType{ + //客户端心跳 + Pong(0x00), + //客户端收到消息ACK + Ack(0x02), + //客户端请求连接状态 + ChannelStatus(0x03), + // 未认证 + UnAuth(0x04); + //撤销某个消息 + //DelMessage(0x04), + //客户端请求连接状态 + //QueueStatus(0x05); + + public int value; + + ServerMessageType(int value){ + this.value = value; + } + + /** + * 从int到enum的转换函数 + * @param value 枚举int值 + * @return 对应的枚举,找不到则返回null + */ + public static ServerMessageType valueOf(int value) { + for(ServerMessageType type : values()){ + if(type.value == value){ + return type; + } + } + return null; + } + } + + /** + * JsonFormat是Json Serialize相关配置 + */ + @JsonFormat(shape = JsonFormat.Shape.OBJECT) + public enum Error{ + //Ok + Ok(200,"Ok"), + + /** + * 通用消息错误 + */ + //消息无接收者错误 + MessageNoReceiversError(1001,"[用户]消息至少应该有一个接收者"), + //消息无数据错误 + MessageNoDataError(1002,"不允许消息内容为空"), + + /** + * server消息错误 + */ + //server消息无type错误 + MessageNoTypeError(1003,"发送至Server域的消息必须有type字段"), + //Ack参数错误,没有找到对应的msgId + AckParameterError(1103,"Ack参数错误,没有找到对应的msgId"), + //SetSuccess参数错误,没有找到对应的msgId + SetSuccessParameterError(1104,"SetSuccess参数错误,没有找到对应的msgId"), + //SetStatusParameterError + SetStatusParameterError(1105,"SetStatus参数错误,没有找到对应的msgId"), + //HasRead参数错误,没有找到对应的msgId + HasReadParameterError(1106,"HasRead参数错误,没有找到对应的msgId"), + + /** + * 身份认证错误 + */ + //无权限 + UnAuthed(1021, "未认证的用户"), + + /** + * 业务错误 + */ + //认证失败 + AuthFailed(1301,"认证失败"), + //空闲断开连接(连续Ns没有收到数据) + ChannelIdle(1302,"连接断开:连续N秒没有从收到客户端收到任何数据"), + //认证超时断开连接 + ChannelAuthTimeOut(1303,"连接断开:认证超时"), + //不可预期错误 + UnExpectedError(1304,"不可预期异常"), + QUEUE_NEW_FAIL(1305, "队列创建失败"), + QUEUE_NAME_EMPTY(1306, "不予许消息队列名称为空"), + QUEUE_NOT_EXISTED(1307, "不予许消息队列名称为空"); + + public int code; + public String text; + public String extra; + + Error(int code,String text) { + this.code = code; + this.text = text; + } + Error(int code,String text,String extra) { + this.code = code; + this.text = text; + this.extra = extra; + } + public Error joinExtra(String extra){ + this.extra = extra; + return this; + } + } + + + /** + * 域(User、Queue、Rest、Server) + */ + public enum DomainType{ + //Netty Client + User(1), + //Queue Client + Queue(2), + //Rest Client + Rest(3), + //系统 + Server(4); + + public int value; + + DomainType(int value){ + this.value = value; + } + + public static DomainType valueOf(int value) { + for(DomainType domainType : values()){ + if(domainType.value == value){ + return domainType; + } + } + return null; + } + } + + /** + * 被调用者信息 + */ + @Data + public static class InvokerMessage{ + /**地址,ws不必设置,mq为Queue name, rest为url*/ + private String address; + /**发送方式,get请求...,主要用于rest类型*/ + private SendMethod method; + } + + public enum SendMethod{ + GET, POST, POST_JSON; + } + + public enum Status{ + //未决状态(未完成) + Pending(0), + //发送成功(投递成功) + Succeed(1), + //发送失败(投递失败) + Failed(2), + //消息过期 + Expired(3), + //消息被撤回 + Reverted(4), + //消息被删除 + Deleted(5), + //消息达到重试次数上限 + SendTimesUpLimit(6), + + //临时完成状态,当ackIsSuccess==0时,一旦ack设置消息为此状态 + TempSucceed(10); + + public int value; + + Status(int value){ + this.value = value; + } + + public static Status valueOf(int value){ + for(Status status : values()){ + if(status.value == value){ + return status; + } + } + return null; + } + } + + public enum GameClientMessageType{ + //客户端心跳 + Heart(0x00), + //客户端认证 + Auth(0x01), + //客户端收到消息ACK + Ack(0x02), + //滑动 + Count(0x03), + //状态改变 + ChangeStatus(0x04) + ; + + public int value; + + GameClientMessageType(int value){ + this.value = value; + } + + /** + * 从int到enum的转换函数 + * @param value 枚举int值 + * @return 对应的枚举,找不到则返回null + */ + public static GameClientMessageType valueOf(int value) { + for(GameClientMessageType type : values()){ + if(type.value == value){ + return type; + } + } + return null; + } + } + +} diff --git a/util/src/main/java/com/ccsens/util/bean/message/common/MessageRule.java b/util/src/main/java/com/ccsens/util/bean/message/common/MessageRule.java new file mode 100644 index 0000000..98b97eb --- /dev/null +++ b/util/src/main/java/com/ccsens/util/bean/message/common/MessageRule.java @@ -0,0 +1,80 @@ +package com.ccsens.util.bean.message.common; + +import lombok.Data; + +/** + * 发送规则实体类 + * @author wei + */ +@Data +public class MessageRule { + public enum AckRule{ + //不需要ack + NONE, + //产生错误时回复ack + ERROR, + //总是回复ack + ALWAYS + } + /** + * 离线丢弃标志 + */ + private byte offlineDiscard; + /** + * 消息是否需要ack,如果不需要ack,则发送完毕,即代表成功 + */ + private AckRule ackRule; + /** + * 没有收到ack重试次数 + */ + private Integer noAckRetryTimes; + /** + * 收到ack代表发送成功,不再发送 + * 如果该标志为0,则代表每次上线都发送,直到用户手动设置成功。 + */ + private byte ackIsSuccess; + /** + * 消息过期时间(s) + */ + private Long expireAt; + + public MessageRule(){ + + } + + public MessageRule(byte offlineDiscard,AckRule ackRule,Integer noAckRetryTimes,byte ackIsSuccess){ + this.offlineDiscard = offlineDiscard; + this.ackRule = ackRule; + this.noAckRetryTimes = noAckRetryTimes; + this.ackIsSuccess = ackIsSuccess; + } + + public MessageRule(byte offlineDiscard,AckRule ackRule,Integer noAckRetryTimes,byte ackIsSuccess,Long expireAt){ + this.offlineDiscard = offlineDiscard; + this.ackRule = ackRule; + this.noAckRetryTimes = noAckRetryTimes; + this.ackIsSuccess = ackIsSuccess; + this.expireAt = expireAt; + } + + public static MessageRule defaultRule(MessageConstant.DomainType fromDomain) { + MessageRule messageRule = null; + switch(fromDomain) { + case User: + messageRule = new MessageRule((byte) 0, AckRule.ALWAYS, 10, (byte) 1,0L); + break; + case Queue: + messageRule = new MessageRule((byte) 1, AckRule.ALWAYS, 10, (byte) 1,0L); + break; + case Rest: + messageRule = new MessageRule((byte) 1, AckRule.ALWAYS, 10, (byte) 1,0L); + break; + case Server: + messageRule = new MessageRule((byte) 1, AckRule.ALWAYS, 10, (byte) 1,0L); + break; + default: + break; + } + return messageRule; + } +} diff --git a/util/src/main/java/com/ccsens/util/bean/message/common/OutMessage.java b/util/src/main/java/com/ccsens/util/bean/message/common/OutMessage.java new file mode 100644 index 0000000..8e30d2a --- /dev/null +++ b/util/src/main/java/com/ccsens/util/bean/message/common/OutMessage.java @@ -0,0 +1,71 @@ +package com.ccsens.util.bean.message.common; + +import cn.hutool.core.date.DateUtil; +import lombok.Data; + +/** + * @author wei + */ +@Data +public class OutMessage { + /** + * 消息ID + */ + private String id; + /** + * sender发送消息时间(s) + * Notice: 指的是服务器收到发送请求的时间,不是服务器发出消息的时间,服务器发出消息的时间客户端很好确定(就是当前时间) + */ + private Long time; + /** + * 消息来自于那个域,通常不需要知道toDomain + */ + private MessageConstant.DomainType fromDomain; + /** + * 发送者信息 + */ + private String from; + /** + * 如果toDomain是Server: 代表消息是发给当前服务器的,必须是MessageSysData的子类型 + * 其他:(格式不限,由用户指定,消息系统会将data字段原封不动投递到接收方,由接收方进行解析) + */ + private String data; + + public OutMessage(){ + } + + public OutMessage(String id, Long time, String from, String data){ + this.id = id; + this.time = time; + this.from = from; + this.data = data; + } + + public OutMessage(InMessage messageEntity){ + this.id = messageEntity.getId(); + this.time = messageEntity.getTime(); + this.fromDomain = messageEntity.getFromDomain(); + this.from = messageEntity.getFrom(); + this.data = messageEntity.getData(); + } + + public OutMessage(String data){ + this.time = DateUtil.currentSeconds(); + this.fromDomain = MessageConstant.DomainType.Server; + this.data = data; + } + + public OutMessage(MessageConstant.DomainType fromDomain, String data) { + this.time = DateUtil.currentSeconds(); + this.fromDomain = fromDomain; + this.data = data; + } + + public OutMessage(Message message){ + this.id = message.getId(); + this.time = message.getTime(); + this.fromDomain = message.getFromDomain(); + this.from = message.getFrom(); + this.data = message.getData(); + } +} diff --git a/util/src/main/java/com/ccsens/util/bean/message/common/OutMessageSet.java b/util/src/main/java/com/ccsens/util/bean/message/common/OutMessageSet.java new file mode 100644 index 0000000..1b0c076 --- /dev/null +++ b/util/src/main/java/com/ccsens/util/bean/message/common/OutMessageSet.java @@ -0,0 +1,43 @@ +package com.ccsens.util.bean.message.common; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; + +/** + * @author __zHangSan + */ +@Getter @Setter @ToString +public class OutMessageSet { + private String ackId; + private Set messageSet; + + public OutMessageSet ackId(String ackId){ + this.ackId = ackId; + return this; + } + + public static OutMessageSet newInstance(){ + return new OutMessageSet(); + } + + public OutMessageSet add(OutMessage messageOutEntity){ + if(messageSet == null){ + messageSet = new HashSet<>(); + } + messageSet.add(messageOutEntity); + return this; + } + + public OutMessageSet addAll(Collection theMessageSet){ + if(messageSet == null){ + messageSet = new HashSet<>(); + } + messageSet.addAll(theMessageSet); + return this; + } +} diff --git a/util/src/main/java/com/ccsens/util/bean/message/common/ServerMessage.java b/util/src/main/java/com/ccsens/util/bean/message/common/ServerMessage.java new file mode 100644 index 0000000..8e37f1b --- /dev/null +++ b/util/src/main/java/com/ccsens/util/bean/message/common/ServerMessage.java @@ -0,0 +1,11 @@ +package com.ccsens.util.bean.message.common; + +import lombok.Data; + +/** + * @author wei + */ +@Data +public class ServerMessage { + private String type; +} diff --git a/util/src/main/java/com/ccsens/util/bean/message/server/ChannelStatusMessage.java b/util/src/main/java/com/ccsens/util/bean/message/server/ChannelStatusMessage.java new file mode 100644 index 0000000..d1605ff --- /dev/null +++ b/util/src/main/java/com/ccsens/util/bean/message/server/ChannelStatusMessage.java @@ -0,0 +1,37 @@ +package com.ccsens.util.bean.message.server; + +import com.ccsens.util.bean.message.common.MessageConstant; +import com.ccsens.util.bean.message.common.ServerMessage; +import lombok.Data; +import lombok.Getter; +import lombok.Setter; + +/** + * @author zhangsan + */ +@Data +public class ChannelStatusMessage extends ServerMessage { + @Setter + @Getter + public static class Data{ + //认证状态 + private Boolean authed; + //已认证时长(s) + private Long onlineSeconds; + //错误信息 + private MessageConstant.Error error; + } + private Data data; + + public ChannelStatusMessage(){ + setType(MessageConstant.ServerMessageType.ChannelStatus.name()); + } + + public ChannelStatusMessage(Boolean authed,Long onlineSeconds,MessageConstant.Error error){ + this(); + data = new Data(); + data.authed = authed; + data.onlineSeconds = onlineSeconds; + data.error = error; + } +} diff --git a/util/src/main/java/com/ccsens/util/bean/message/server/InvertedMessage.java b/util/src/main/java/com/ccsens/util/bean/message/server/InvertedMessage.java new file mode 100644 index 0000000..a31c9ff --- /dev/null +++ b/util/src/main/java/com/ccsens/util/bean/message/server/InvertedMessage.java @@ -0,0 +1,29 @@ +package com.ccsens.util.bean.message.server; + + +import com.ccsens.util.bean.message.common.MessageConstant; +import com.ccsens.util.bean.message.common.ServerMessage; +import lombok.Getter; +import lombok.Setter; + +/** + * @author __zHangSan + */ +public class InvertedMessage extends ServerMessage { + @Setter + @Getter + public static class Data{ + private String msgId; + } + private Data data; + + public InvertedMessage(){ + setType(MessageConstant.ServerMessageType.Pong.name()); + } + + public InvertedMessage(String msgId){ + this(); + data = new Data(); + data.setMsgId(msgId); + } +} diff --git a/util/src/main/java/com/ccsens/util/bean/message/server/PongMessage.java b/util/src/main/java/com/ccsens/util/bean/message/server/PongMessage.java new file mode 100644 index 0000000..f9b5c0b --- /dev/null +++ b/util/src/main/java/com/ccsens/util/bean/message/server/PongMessage.java @@ -0,0 +1,15 @@ +package com.ccsens.util.bean.message.server; + +import com.ccsens.util.bean.message.common.MessageConstant; +import com.ccsens.util.bean.message.common.ServerMessage; +import lombok.Data; + +/** + * @author zhangsan + */ +@Data +public class PongMessage extends ServerMessage { + public PongMessage(){ + setType(MessageConstant.ServerMessageType.Pong.name()); + } +} diff --git a/util/src/main/java/com/ccsens/util/bean/message/server/QueueStatusMessage.java b/util/src/main/java/com/ccsens/util/bean/message/server/QueueStatusMessage.java new file mode 100644 index 0000000..948fdc5 --- /dev/null +++ b/util/src/main/java/com/ccsens/util/bean/message/server/QueueStatusMessage.java @@ -0,0 +1,31 @@ +package com.ccsens.util.bean.message.server; + + +import com.ccsens.util.bean.message.common.MessageConstant; +import com.ccsens.util.bean.message.common.ServerMessage; +import lombok.Data; +import lombok.Getter; +import lombok.Setter; + +/** + * @author zhangsan + */ +@Data +public class QueueStatusMessage extends ServerMessage { + @Setter + @Getter + public static class Data{ + private MessageConstant.Error error; + } + private Data data; + + public QueueStatusMessage(){ + setType(MessageConstant.ServerMessageType.ChannelStatus.name()); + } + + public QueueStatusMessage(MessageConstant.Error error){ + this(); + data = new Data(); + data.error = error; + } +} diff --git a/util/src/main/java/com/ccsens/util/bean/message/server/ServerAckMessage.java b/util/src/main/java/com/ccsens/util/bean/message/server/ServerAckMessage.java new file mode 100644 index 0000000..69645f4 --- /dev/null +++ b/util/src/main/java/com/ccsens/util/bean/message/server/ServerAckMessage.java @@ -0,0 +1,50 @@ +package com.ccsens.util.bean.message.server; + + +import com.ccsens.util.bean.message.common.MessageConstant; +import com.ccsens.util.bean.message.common.ServerMessage; +import lombok.Data; + +/** + * @author zhangsan + */ +@Data +public class ServerAckMessage extends ServerMessage { + @lombok.Data + public static class Data{ + /** + * 消息ID + */ + private String msgId; + /** + * 发送者指定的unikey,如果发送者未指定,则为null + */ + private String unikey; + /** + * 消息状态 + */ + private MessageConstant.Error error; + + public Data(String msgId,String unikey,MessageConstant.Error error){ + this.msgId = msgId; + this.unikey = unikey; + this.error = error; + } + } + + private Data data; + + public ServerAckMessage(){ + setType(MessageConstant.ServerMessageType.Ack.name()); + } + + public ServerAckMessage(MessageConstant.Error status){ + this(); + this.data = new Data(null,null,status); + } + + public ServerAckMessage(String msgId,String unikey,MessageConstant.Error status){ + this(); + this.data = new Data(msgId,unikey,status); + } +} diff --git a/util/src/main/java/com/ccsens/util/bean/wx/dto/WxGzhAction.java b/util/src/main/java/com/ccsens/util/bean/wx/dto/WxGzhAction.java new file mode 100644 index 0000000..7c8aa61 --- /dev/null +++ b/util/src/main/java/com/ccsens/util/bean/wx/dto/WxGzhAction.java @@ -0,0 +1,151 @@ +package com.ccsens.util.bean.wx.dto; + +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; +import lombok.Data; + +import java.util.List; + +/** + * @author __zHangSan + */ +@Data +@JacksonXmlRootElement(localName = "xml") +public class WxGzhAction { + @Data + private static class ScanCodeInfo{ + @JacksonXmlProperty(localName = "ScanType") + private String scanType; + @JacksonXmlProperty(localName = "ScanResult") + private String scanResult; + }; + + @Data + private static class SendPicsInfo{ + @Data + private static class Item{ + @JacksonXmlProperty(localName = "PicMd5Sum") + private String picMd5Sum; + } + @JacksonXmlProperty(localName = "Count") + private Integer count; + @JacksonXmlProperty(localName = "PicList") + private List picList; + } + + @Data + private static class SendLocationInfo{ + @JacksonXmlProperty(localName = "Location_X") + private String x; + @JacksonXmlProperty(localName = "Location_Y") + private String y; + @JacksonXmlProperty(localName = "Scale") + private String scale; + @JacksonXmlProperty(localName = "Label") + private String label; + @JacksonXmlProperty(localName = "Poiname") + private String poiname; + } + + @JacksonXmlProperty(localName = "FromUserName") + private String openId; + @JacksonXmlProperty(localName = "ToUserName") + private String gzhId; + @JacksonXmlProperty(localName = "CreateTime") + private Long createTime; + @JacksonXmlProperty(localName = "MsgType") + private String msgType; + + /** + * MsgType: Text (Content,MsgId) + */ + @JacksonXmlProperty(localName = "Content") + private String content; + @JacksonXmlProperty(localName = "MsgId") + private String msgId; + /** + * MsgType: image (PicUrl,MediaId,MsgId) + */ + @JacksonXmlProperty(localName = "PicUrl") + private String picUrl; + @JacksonXmlProperty(localName = "MediaId") + private String mediaId; + /** + * MsgType: voice (MediaId,Format,MsgId) + * Recognition: 开通语音识别后生效 + */ + @JacksonXmlProperty(localName = "Format") + private String format; + @JacksonXmlProperty(localName = "Recognition") + private String recognition; + + /** + * MsgType: video/shortvideo(MediaId,ThumbMediaId,MsgId) + */ + @JacksonXmlProperty(localName = "ThumbMediaId") + private String thumbMediaId; + /** + * MsgType: location(Location_x,Location_y,Scale,Label,MsgId) + */ + @JacksonXmlProperty(localName = "Location_X") + private String x; + @JacksonXmlProperty(localName = "Location_Y") + private String y; + @JacksonXmlProperty(localName = "Scale") + private String scale; + @JacksonXmlProperty(localName = "Label") + private String label; + /** + * MsgType: link(Title,Description,Url,MsgId) + */ + @JacksonXmlProperty(localName = "Title") + private String title; + @JacksonXmlProperty(localName = "Description") + private String description; + @JacksonXmlProperty(localName = "Url") + private String url; + + /** + * MsgType: event + */ + @JacksonXmlProperty(localName = "Event") + private String event; + @JacksonXmlProperty(localName = "EventKey") + private String eventKey; + + /** + * Event: subscribe/SCAN + */ + @JacksonXmlProperty(localName = "Ticket") + private String ticket; + /** + * Event: Location + */ + @JacksonXmlProperty(localName = "Latitude") + private String latitude; + @JacksonXmlProperty(localName = "Longitude") + private String longitude; + @JacksonXmlProperty(localName = "Precision") + private String precision; + + /** + * Event: VIEW/view_miniprogram + */ + @JacksonXmlProperty(localName = "MenuId") + private String menuId; + /** + * Event: scancode_push/scancode_waitmsg + */ + @JacksonXmlProperty(localName = "ScanCodeInfo") + private ScanCodeInfo scanCodeInfo; + /** + * Event: pic_sysphoto/pic_photo_or_album/pic_weixin + */ + @JacksonXmlProperty(localName = "SendPicsInfo") + private SendPicsInfo sendPicsInfo; + /** + * Event: location_select + */ + @JacksonXmlProperty(localName = "SendLocationInfo") + private SendLocationInfo sendLocationInfo; +} \ No newline at end of file diff --git a/util/src/main/java/com/ccsens/util/bean/wx/po/WxAccessToken.java b/util/src/main/java/com/ccsens/util/bean/wx/po/WxAccessToken.java new file mode 100644 index 0000000..018b866 --- /dev/null +++ b/util/src/main/java/com/ccsens/util/bean/wx/po/WxAccessToken.java @@ -0,0 +1,18 @@ +package com.ccsens.util.bean.wx.po; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; + +/** + * @author __zHangSan + */ +@Data +public class WxAccessToken extends WxBaseEntity{ + @JsonProperty("access_token") + private String accessToken; + @JsonProperty("expires_in") + private Long expiresIn; + @JsonIgnore + private Long createdAt; +} diff --git a/util/src/main/java/com/ccsens/util/bean/wx/po/WxBaseEntity.java b/util/src/main/java/com/ccsens/util/bean/wx/po/WxBaseEntity.java new file mode 100644 index 0000000..7007df1 --- /dev/null +++ b/util/src/main/java/com/ccsens/util/bean/wx/po/WxBaseEntity.java @@ -0,0 +1,12 @@ +package com.ccsens.util.bean.wx.po; + +import lombok.Data; + +/** + * @author __zHangSan + */ +@Data +public class WxBaseEntity { + private Integer errcode; + private String errmsg; +} diff --git a/util/src/main/java/com/ccsens/util/bean/wx/po/WxGzhAuthType.java b/util/src/main/java/com/ccsens/util/bean/wx/po/WxGzhAuthType.java new file mode 100644 index 0000000..dfe42dc --- /dev/null +++ b/util/src/main/java/com/ccsens/util/bean/wx/po/WxGzhAuthType.java @@ -0,0 +1,23 @@ +package com.ccsens.util.bean.wx.po; + +import lombok.Getter; +import lombok.Setter; + +/** + * @author __zHangSan + */ + +public enum WxGzhAuthType { + //基本授权类型,静默,只能获取openId + SNSAPI_BASE("snsapi_base"), + //信息授权类型,弹出提示框,可以获取openId,unionId,nickanme,city等用户信息 + SNSAPI_USERINFO("snsapi_userinfo"); + + @Getter + @Setter + private String text; + + private WxGzhAuthType(String text){ + this.text = text; + } +} diff --git a/util/src/main/java/com/ccsens/util/bean/wx/po/WxGzhMenu.java b/util/src/main/java/com/ccsens/util/bean/wx/po/WxGzhMenu.java new file mode 100644 index 0000000..5c79cf7 --- /dev/null +++ b/util/src/main/java/com/ccsens/util/bean/wx/po/WxGzhMenu.java @@ -0,0 +1,97 @@ +package com.ccsens.util.bean.wx.po; + +import cn.hutool.core.collection.CollectionUtil; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonValue; +import lombok.Builder; +import lombok.Data; +import lombok.Getter; + +import java.util.List; + +/** + * @author __zHangSan + */ +@Data +public class WxGzhMenu { + public enum ButtonType{ + //点击推事件 + CLICK("click"), + //跳转URL + VIEW("view"), + //小程序 + MINIPROGRAM("miniprogram"), + //扫码推事件 + SCANCODE_PUSH("scancode_push"), + //扫码推事件且弹出“消息接收中”提示框 + SCANCODE_WAITMSG("scancode_waitmsg"), + //弹出系统拍照发图 + PIC_SYSPHOTO("pic_sysphoto"), + //弹出拍照或者相册发图 + PIC_PHOTO_OR_ALBUM("pic_photo_or_album"), + //弹出微信相册发图器 + PIC_WEIXIN("pic_weixin"), + //弹出地理位置选择器 + LOCATION_SELECT("location_select"), + //下发消息(除文本消息) + MEDIA_ID("media_id"), + //跳转图文消息URL + VIEW_LIMITED("view_limited"); + + @JsonValue + private String text; + + ButtonType(String text){ + this.text = text; + } + } + @Builder(toBuilder = true) + @Getter + public static class Button{ + /** + * 必须 + */ + private ButtonType type; + /** + * 必须 + */ + private String name; + /** + * click等点击类型必须 + */ + private String key; + /** + * view、miniprogram类型必须 + */ + private String url; + /** + * media_id类型和view_limited类型必须 + */ + @JsonProperty("media_id") + private String mediaId; + /** + * miniprogram类型必须 + */ + private String appid; + private String pagepath; + /** + * optional + */ + @JsonProperty("sub_button") + private List