From 36f1a9f27cbcda260475d4d29ef07e09f94865e3 Mon Sep 17 00:00:00 2001 From: kuanghua <869653722@qq.com> Date: Sun, 26 Jun 2022 19:13:11 +0800 Subject: [PATCH] update springboot and springcloud version and add generator plateform --- .gitignore | 6 +- README-zh_CN.md | 33 +- README.md | 33 +- auth-pom/pom.xml | 32 + .../authpom}/controller/TokenController.java | 128 +- .../authpom/service/TokenService.java | 50 + .../kuanghua/authpom}/utils/JwtUtilsSelf.java | 188 +- {ty-auth => auth-pom}/src/main/main12.iml | 0 auth-pom/src/main/resources/application.yml | 11 + .../src/main/resources/bootstrap.yml | 56 +- .../src/main/resources/rsa.pri | Bin .../src/main/resources/rsa.pub | Bin {ty-example => basis-func}/pom.xml | 46 +- .../basisfunc/BasisFuncApplication.java | 17 + .../kuanghua/basisfunc/config/BaseConfig.java | 17 + .../config/Knife4jConfiguration.java | 39 + .../controller/DataBaseController.java | 48 + .../controller/GeneratorController.java | 115 + .../controller/GoFastDFSController.java | 7 +- .../basisfunc/mapper/DataBaseMapper.java | 35 + .../basisfunc/service/DataBaseService.java | 40 + .../service/GeneratorCustromService.java | 315 ++ .../basisfunc/service/GeneratorService.java | 232 ++ .../basisfunc/utils/GeneratorTempUtils.java | 353 ++ .../src/main/resources/application-db.yml | 39 + basis-func/src/main/resources/application.yml | 2 + basis-func/src/main/resources/bootstrap.yml | 15 + .../resources/mapper/RepairInfoMapper.xml | 69 + .../src/main/resources/velocity-tools.xml | 13 + .../service/GeneratorServiceTest.java | 180 + common-pom/pom.xml | 78 + .../commonpom}/config/FeignConfiguration.java | 6 +- .../config/MetaObjectHandlerConfig.java | 2 +- .../commonpom}/config/MybatisPlusConfig.java | 6 +- .../commonpom/entity/CommonPageParams.java | 18 +- .../commonpom}/entity/PageResult.java | 2 +- .../kuanghua/commonpom}/entity/ResResult.java | 18 +- .../commonpom/entity/SelfCommonParams.java | 8 +- .../commonpom}/entity/StatusCode.java | 2 +- .../exception/BaseExceptionHandler.java | 11 +- .../commonpom/feign/tyauth/TokenFeign.java | 43 + .../commonpom/utils/ObjSelfUtils.java | 178 + .../commonpom/utils/SelfObjUtils.java | 80 +- .../src/main/resources/application-main.yml | 17 + .../src/main/resources/config/banner.txt | 12 +- .../src/main/resources/config/emp.properties | 2 +- .../main/resources/logs/logback-spring.xml | 0 .../src/main/resources/spy.properties | 44 +- easycode-temp/controller.mv | 140 - easycode-temp/element-form.mv | 303 -- easycode-temp/element-table.mv | 300 -- easycode-temp/entity.mv | 56 - easycode-temp/mapper.mv | 19 - easycode-temp/service.mv | 54 - {ty-auth => gateway}/pom.xml | 37 +- .../kuanghua/gateway/GatewayApplication.java | 30 +- .../kuanghua/gateway/config/BaseConfig.java | 86 +- .../config/MySwaggerResourceProvider.java | 64 + .../controller/SwaggerResourceController.java | 24 + .../gateway}/filter/AuthorizeFilterAfter.java | 268 +- .../filter/AuthorizeFilterBefore.java | 227 +- gateway/src/main/resources/application.yml | 58 + gateway/src/main/resources/bootstrap.yml | 15 + integration-front/pom.xml | 29 +- .../IntegrationFrontApplication.java | 2 - .../integrationfront/config/BaseConfig.java | 22 +- .../config/Knife4jConfiguration.java | 39 + .../config/Swagger2Config.java | 56 - .../controller/BrandController.java | 6 +- .../controller/ErrorCollectionController.java | 6 +- .../controller/PairmentController.java | 89 + .../controller/UserController.java | 10 +- .../controller/VciController.java | 13 +- .../integrationfront/entity/Brand.java | 8 +- .../entity/ErrorCollection.java | 4 +- .../integrationfront/entity/Pairment.java | 63 + .../integrationfront/entity/Repair.java | 70 + .../integrationfront/entity/Replacement.java | 46 + .../integrationfront/entity/Role.java | 1 + .../integrationfront/excel/cv/VciTimeCv.java | 4 +- .../mapper/PairmentMapper.java | 18 + .../integrationfront/mapper/RepairMapper.java | 14 + .../mapper/ReplacementMapper.java | 14 + .../service/PairmentService.java | 76 + .../integrationfront/service/UserService.java | 26 +- .../integrationfront}/utils/CodecUtils.java | 4 +- .../integrationfront/vo/PairmentVo.java | 29 + .../src/main/resources/application-db.yml | 45 + .../src/main/resources/application-rabbit.yml | 8 + .../src/main/resources/application-redis.yml | 4 + .../src/main/resources/application-seata.yml | 26 + .../src/main/resources/application.yml | 2 + .../src/main/resources/bootstrap.yml | 37 +- .../src/main/resources/mapper/AdminMapper.xml | 107 +- .../main/resources/mapper/PairmentMapper.xml | 57 + nacos_config_export_20220115133818.zip | Bin 16104 -> 0 bytes pom.xml | 84 +- springboot-cloud-mapping.json | 113 - .../kuanghua/tyauth/config/BaseConfig.java | 21 - .../tyauth/config/Swagger2Config.java | 54 - .../controller/TestGetTokenController.java | 47 - .../kuanghua/tyauth/service/TokenService.java | 70 - ty-auth/src/main/resources/application.yml | 1 - ty-common/pom.xml | 142 - .../kuanghua/controller/HstrixController.java | 26 - .../integrationfront/feign/UserFeign.java | 15 - .../feign/tyauth/feign/TestGetTokenFeign.java | 14 - .../feign/tyauth/feign/TokenFeign.java | 45 - .../khcomomon/config/TokenParseInfo.java | 26 - .../khcomomon/config/TyCommonConfig.java | 25 - .../top/kuanghua/khcomomon/entity/BCrypt.java | 792 ----- .../kuanghua/khcomomon/entity/CacheKey.java | 24 - .../khcomomon/entity/CommonParamsSelf.java | 20 - .../kuanghua/khcomomon/entity/HttpClient.java | 170 - .../kuanghua/khcomomon/entity/IdWorker.java | 172 - .../top/kuanghua/khcomomon/entity/Result.java | 69 - .../khcomomon/utils/ChineseUtils.java | 65 - .../khcomomon/utils/DateUtilSelf.java | 164 - .../kuanghua/khcomomon/utils/IdWorker.java | 163 - .../top/kuanghua/khcomomon/utils/JwtUtil.java | 104 - .../khcomomon/utils/NumberUtilsSelf.java | 73 - .../khcomomon/utils/RandomValueUtil.java | 126 - .../khcomomon/utils/RedisClientUtils.java | 577 ---- .../kuanghua/khcomomon/utils/ThreadUtils.java | 13 - .../src/main/resources/application-dev.yml | 7 - .../src/main/resources/application-prod.yml | 7 - .../src/main/resources/application-test.yml | 7 - .../tyexample/ExampleApplication.java | 19 - .../kuanghua/tyexample/config/BaseConfig.java | 27 - .../tyexample/config/RabbitDelayConfig.java | 67 - .../tyexample/config/SmsProperties.java | 25 - .../tyexample/config/Swagger2Config.java | 55 - .../controller/GetTokenFromOtherService.java | 35 - .../controller/HystrixRibbonController.java | 31 - .../controller/RabbitDelayController.java | 35 - .../controller/RedisTestController.java | 131 - .../controller/SeataTestController.java | 30 - .../controller/SendEmailController.java | 50 - .../tyexample/entity/ErrorCollection.java | 36 - .../listener/CanalDataEventListener.java | 53 - .../listener/RabbitDelayListener.java | 29 - .../tyexample/listener/SmsListener.java | 50 - .../mapper/ErrorCollectionMapper.java | 9 - .../tyexample/service/RabbitDelayService.java | 33 - .../tyexample/service/SeataTestService.java | 26 - .../tyexample/service/SendEmailService.java | 99 - .../tyexample/service/SendMsgService.java | 42 - .../tyexample/service/UploadService.java | 92 - .../tyexample/utils/SendSmsUtils.java | 54 - ty-example/src/main/resources/bootstrap.yml | 46 - .../service/CacheAvalancheServiceTest.java | 32 - ty-gateway/pom.xml | 44 - ty-gateway/ty-gateway-one/pom.xml | 39 - .../gatewaytwo/config/BaseConfig.java | 23 - .../gatewaytwo/config/JwtProperties.java | 54 - .../SpecialHystrixGatewayFilterFactory.java | 241 -- .../gatewaytwo/config/SwaggerDocConfig.java | 21 - .../gatewaytwo/config/SwaggerHandler.java | 49 - .../config/SwaggerHeaderFilter.java | 34 - .../gatewaytwo/config/SwaggerProvider.java | 62 - .../gatewaytwo/utils/ChangeObjectUtils.java | 38 - .../kuanghua/gatewaytwo/utils/JwtUtilsKh.java | 42 - .../kuanghua/gatewaytwo/utils/RsaUtils.java | 92 - .../src/main/resources/application.yml | 0 .../src/main/resources/bootstrap.yml | 38 - .../mybatis-plus-multb/controllerMul.vm | 75 + .../back-vms/mybatis-plus-multb/entity.vm | 37 + .../back-vms/mybatis-plus-multb/entityMul.vm | 29 + .../back-vms/mybatis-plus-multb/entityVo.vm | 19 + .../back-vms/mybatis-plus-multb/mapper.vm | 10 + .../back-vms/mybatis-plus-multb/mapperMul.vm | 16 + .../back-vms/mybatis-plus-multb/serviceMul.vm | 57 + .../back-vms/mybatis-plus-multb/utils.vm | 8 + .../back-vms/mybatis-plus-multb/xmlMul.vm | 60 + .../back-vms/mybatis-plus/controller.vm | 112 + .../back-vms/mybatis-plus/entity.vm | 37 + .../back-vms/mybatis-plus/mapper.vm | 10 + .../back-vms/mybatis-plus/service.vm | 42 + .../back-vms/mybatis-plus/utils.vm | 6 + .../back-vms/mybatis-plus/xml.vm | 0 .../front-vms/element-plus/CRUD.vm | 96 + .../front-vms/element-plus/CRUDForm.vm | 87 + .../front-vms/element-plus/formUtils.vm | 268 ++ .../front-vms/element-plus/queryUtils.vm | 139 + .../front-vms/element-plus/tableUtils.vm | 214 ++ .../front-vms/element-plus/utils.vm | 30 + velocity-tmp-dir/json-data/brandData.json | 135 + velocity-tmp-dir/json-data/cascadeData.json | 16 + velocity-tmp-dir/json-data/data.json | 192 + .../json-data/multiTableData.json | 3076 +++++++++++++++++ velocity-tmp-dir/json-data/tb_brand.json | 877 +++++ 191 files changed, 9202 insertions(+), 6827 deletions(-) create mode 100644 auth-pom/pom.xml rename {ty-auth/src/main/java/top/kuanghua/tyauth => auth-pom/src/main/java/top/kuanghua/authpom}/controller/TokenController.java (89%) create mode 100644 auth-pom/src/main/java/top/kuanghua/authpom/service/TokenService.java rename {ty-auth/src/main/java/top/kuanghua/tyauth => auth-pom/src/main/java/top/kuanghua/authpom}/utils/JwtUtilsSelf.java (95%) rename {ty-auth => auth-pom}/src/main/main12.iml (100%) create mode 100644 auth-pom/src/main/resources/application.yml rename {ty-auth => auth-pom}/src/main/resources/bootstrap.yml (92%) rename {ty-auth => auth-pom}/src/main/resources/rsa.pri (100%) rename {ty-auth => auth-pom}/src/main/resources/rsa.pub (100%) rename {ty-example => basis-func}/pom.xml (63%) create mode 100644 basis-func/src/main/java/top/kuanghua/basisfunc/BasisFuncApplication.java create mode 100644 basis-func/src/main/java/top/kuanghua/basisfunc/config/BaseConfig.java create mode 100644 basis-func/src/main/java/top/kuanghua/basisfunc/config/Knife4jConfiguration.java create mode 100644 basis-func/src/main/java/top/kuanghua/basisfunc/controller/DataBaseController.java create mode 100644 basis-func/src/main/java/top/kuanghua/basisfunc/controller/GeneratorController.java rename {ty-example/src/main/java/top/kuanghua/tyexample => basis-func/src/main/java/top/kuanghua/basisfunc}/controller/GoFastDFSController.java (89%) create mode 100644 basis-func/src/main/java/top/kuanghua/basisfunc/mapper/DataBaseMapper.java create mode 100644 basis-func/src/main/java/top/kuanghua/basisfunc/service/DataBaseService.java create mode 100644 basis-func/src/main/java/top/kuanghua/basisfunc/service/GeneratorCustromService.java create mode 100644 basis-func/src/main/java/top/kuanghua/basisfunc/service/GeneratorService.java create mode 100644 basis-func/src/main/java/top/kuanghua/basisfunc/utils/GeneratorTempUtils.java create mode 100644 basis-func/src/main/resources/application-db.yml create mode 100644 basis-func/src/main/resources/application.yml create mode 100644 basis-func/src/main/resources/bootstrap.yml create mode 100644 basis-func/src/main/resources/mapper/RepairInfoMapper.xml create mode 100644 basis-func/src/main/resources/velocity-tools.xml create mode 100644 basis-func/src/test/java/top/kuanghua/basisfunc/service/GeneratorServiceTest.java create mode 100644 common-pom/pom.xml rename {ty-common/src/main/java/top/kuanghua/feign => common-pom/src/main/java/top/kuanghua/commonpom}/config/FeignConfiguration.java (89%) rename {ty-common/src/main/java/top/kuanghua/khcomomon => common-pom/src/main/java/top/kuanghua/commonpom}/config/MetaObjectHandlerConfig.java (95%) rename {ty-common/src/main/java/top/kuanghua/khcomomon => common-pom/src/main/java/top/kuanghua/commonpom}/config/MybatisPlusConfig.java (97%) rename ty-common/src/main/java/top/kuanghua/khcomomon/entity/KHCommonPageParams.java => common-pom/src/main/java/top/kuanghua/commonpom/entity/CommonPageParams.java (68%) rename {ty-common/src/main/java/top/kuanghua/khcomomon => common-pom/src/main/java/top/kuanghua/commonpom}/entity/PageResult.java (93%) rename {ty-common/src/main/java/top/kuanghua/khcomomon => common-pom/src/main/java/top/kuanghua/commonpom}/entity/ResResult.java (69%) rename ty-common/src/main/java/top/kuanghua/khcomomon/entity/KHCommonParams.java => common-pom/src/main/java/top/kuanghua/commonpom/entity/SelfCommonParams.java (62%) rename {ty-common/src/main/java/top/kuanghua/khcomomon => common-pom/src/main/java/top/kuanghua/commonpom}/entity/StatusCode.java (92%) rename {ty-common/src/main/java/top/kuanghua/khcomomon => common-pom/src/main/java/top/kuanghua/commonpom}/exception/BaseExceptionHandler.java (80%) create mode 100644 common-pom/src/main/java/top/kuanghua/commonpom/feign/tyauth/TokenFeign.java create mode 100644 common-pom/src/main/java/top/kuanghua/commonpom/utils/ObjSelfUtils.java rename ty-common/src/main/java/top/kuanghua/khcomomon/utils/ObjectUtilsSelf.java => common-pom/src/main/java/top/kuanghua/commonpom/utils/SelfObjUtils.java (64%) create mode 100644 common-pom/src/main/resources/application-main.yml rename {ty-common => common-pom}/src/main/resources/config/banner.txt (98%) rename {ty-common => common-pom}/src/main/resources/config/emp.properties (91%) rename {ty-common => common-pom}/src/main/resources/logs/logback-spring.xml (100%) rename {ty-common => common-pom}/src/main/resources/spy.properties (98%) delete mode 100644 easycode-temp/controller.mv delete mode 100644 easycode-temp/element-form.mv delete mode 100644 easycode-temp/element-table.mv delete mode 100644 easycode-temp/entity.mv delete mode 100644 easycode-temp/mapper.mv delete mode 100644 easycode-temp/service.mv rename {ty-auth => gateway}/pom.xml (53%) rename ty-auth/src/main/java/top/kuanghua/tyauth/AuthApplication.java => gateway/src/main/java/top/kuanghua/gateway/GatewayApplication.java (58%) rename ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/GatewayOneApplication.java => gateway/src/main/java/top/kuanghua/gateway/config/BaseConfig.java (57%) create mode 100644 gateway/src/main/java/top/kuanghua/gateway/config/MySwaggerResourceProvider.java create mode 100644 gateway/src/main/java/top/kuanghua/gateway/controller/SwaggerResourceController.java rename {ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo => gateway/src/main/java/top/kuanghua/gateway}/filter/AuthorizeFilterAfter.java (85%) rename {ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo => gateway/src/main/java/top/kuanghua/gateway}/filter/AuthorizeFilterBefore.java (81%) create mode 100644 gateway/src/main/resources/application.yml create mode 100644 gateway/src/main/resources/bootstrap.yml create mode 100644 integration-front/src/main/java/top/kuanghua/integrationfront/config/Knife4jConfiguration.java delete mode 100644 integration-front/src/main/java/top/kuanghua/integrationfront/config/Swagger2Config.java create mode 100644 integration-front/src/main/java/top/kuanghua/integrationfront/controller/PairmentController.java create mode 100644 integration-front/src/main/java/top/kuanghua/integrationfront/entity/Pairment.java create mode 100644 integration-front/src/main/java/top/kuanghua/integrationfront/entity/Repair.java create mode 100644 integration-front/src/main/java/top/kuanghua/integrationfront/entity/Replacement.java create mode 100644 integration-front/src/main/java/top/kuanghua/integrationfront/mapper/PairmentMapper.java create mode 100644 integration-front/src/main/java/top/kuanghua/integrationfront/mapper/RepairMapper.java create mode 100644 integration-front/src/main/java/top/kuanghua/integrationfront/mapper/ReplacementMapper.java create mode 100644 integration-front/src/main/java/top/kuanghua/integrationfront/service/PairmentService.java rename {ty-common/src/main/java/top/kuanghua/khcomomon => integration-front/src/main/java/top/kuanghua/integrationfront}/utils/CodecUtils.java (88%) create mode 100644 integration-front/src/main/java/top/kuanghua/integrationfront/vo/PairmentVo.java create mode 100644 integration-front/src/main/resources/application-db.yml create mode 100644 integration-front/src/main/resources/application-rabbit.yml create mode 100644 integration-front/src/main/resources/application-redis.yml create mode 100644 integration-front/src/main/resources/application-seata.yml create mode 100644 integration-front/src/main/resources/mapper/PairmentMapper.xml delete mode 100644 nacos_config_export_20220115133818.zip delete mode 100644 springboot-cloud-mapping.json delete mode 100644 ty-auth/src/main/java/top/kuanghua/tyauth/config/BaseConfig.java delete mode 100644 ty-auth/src/main/java/top/kuanghua/tyauth/config/Swagger2Config.java delete mode 100644 ty-auth/src/main/java/top/kuanghua/tyauth/controller/TestGetTokenController.java delete mode 100644 ty-auth/src/main/java/top/kuanghua/tyauth/service/TokenService.java delete mode 100644 ty-auth/src/main/resources/application.yml delete mode 100644 ty-common/pom.xml delete mode 100644 ty-common/src/main/java/top/kuanghua/controller/HstrixController.java delete mode 100644 ty-common/src/main/java/top/kuanghua/feign/integrationfront/feign/UserFeign.java delete mode 100644 ty-common/src/main/java/top/kuanghua/feign/tyauth/feign/TestGetTokenFeign.java delete mode 100644 ty-common/src/main/java/top/kuanghua/feign/tyauth/feign/TokenFeign.java delete mode 100644 ty-common/src/main/java/top/kuanghua/khcomomon/config/TokenParseInfo.java delete mode 100644 ty-common/src/main/java/top/kuanghua/khcomomon/config/TyCommonConfig.java delete mode 100644 ty-common/src/main/java/top/kuanghua/khcomomon/entity/BCrypt.java delete mode 100644 ty-common/src/main/java/top/kuanghua/khcomomon/entity/CacheKey.java delete mode 100644 ty-common/src/main/java/top/kuanghua/khcomomon/entity/CommonParamsSelf.java delete mode 100644 ty-common/src/main/java/top/kuanghua/khcomomon/entity/HttpClient.java delete mode 100644 ty-common/src/main/java/top/kuanghua/khcomomon/entity/IdWorker.java delete mode 100644 ty-common/src/main/java/top/kuanghua/khcomomon/entity/Result.java delete mode 100644 ty-common/src/main/java/top/kuanghua/khcomomon/utils/ChineseUtils.java delete mode 100644 ty-common/src/main/java/top/kuanghua/khcomomon/utils/DateUtilSelf.java delete mode 100644 ty-common/src/main/java/top/kuanghua/khcomomon/utils/IdWorker.java delete mode 100644 ty-common/src/main/java/top/kuanghua/khcomomon/utils/JwtUtil.java delete mode 100644 ty-common/src/main/java/top/kuanghua/khcomomon/utils/NumberUtilsSelf.java delete mode 100644 ty-common/src/main/java/top/kuanghua/khcomomon/utils/RandomValueUtil.java delete mode 100644 ty-common/src/main/java/top/kuanghua/khcomomon/utils/RedisClientUtils.java delete mode 100644 ty-common/src/main/java/top/kuanghua/khcomomon/utils/ThreadUtils.java delete mode 100644 ty-common/src/main/resources/application-dev.yml delete mode 100644 ty-common/src/main/resources/application-prod.yml delete mode 100644 ty-common/src/main/resources/application-test.yml delete mode 100644 ty-example/src/main/java/top/kuanghua/tyexample/ExampleApplication.java delete mode 100644 ty-example/src/main/java/top/kuanghua/tyexample/config/BaseConfig.java delete mode 100644 ty-example/src/main/java/top/kuanghua/tyexample/config/RabbitDelayConfig.java delete mode 100644 ty-example/src/main/java/top/kuanghua/tyexample/config/SmsProperties.java delete mode 100644 ty-example/src/main/java/top/kuanghua/tyexample/config/Swagger2Config.java delete mode 100644 ty-example/src/main/java/top/kuanghua/tyexample/controller/GetTokenFromOtherService.java delete mode 100644 ty-example/src/main/java/top/kuanghua/tyexample/controller/HystrixRibbonController.java delete mode 100644 ty-example/src/main/java/top/kuanghua/tyexample/controller/RabbitDelayController.java delete mode 100644 ty-example/src/main/java/top/kuanghua/tyexample/controller/RedisTestController.java delete mode 100644 ty-example/src/main/java/top/kuanghua/tyexample/controller/SeataTestController.java delete mode 100644 ty-example/src/main/java/top/kuanghua/tyexample/controller/SendEmailController.java delete mode 100644 ty-example/src/main/java/top/kuanghua/tyexample/entity/ErrorCollection.java delete mode 100644 ty-example/src/main/java/top/kuanghua/tyexample/listener/CanalDataEventListener.java delete mode 100644 ty-example/src/main/java/top/kuanghua/tyexample/listener/RabbitDelayListener.java delete mode 100644 ty-example/src/main/java/top/kuanghua/tyexample/listener/SmsListener.java delete mode 100644 ty-example/src/main/java/top/kuanghua/tyexample/mapper/ErrorCollectionMapper.java delete mode 100644 ty-example/src/main/java/top/kuanghua/tyexample/service/RabbitDelayService.java delete mode 100644 ty-example/src/main/java/top/kuanghua/tyexample/service/SeataTestService.java delete mode 100644 ty-example/src/main/java/top/kuanghua/tyexample/service/SendEmailService.java delete mode 100644 ty-example/src/main/java/top/kuanghua/tyexample/service/SendMsgService.java delete mode 100644 ty-example/src/main/java/top/kuanghua/tyexample/service/UploadService.java delete mode 100644 ty-example/src/main/java/top/kuanghua/tyexample/utils/SendSmsUtils.java delete mode 100644 ty-example/src/main/resources/bootstrap.yml delete mode 100644 ty-example/src/test/java/top/kuanghua/tyexample/service/CacheAvalancheServiceTest.java delete mode 100644 ty-gateway/pom.xml delete mode 100644 ty-gateway/ty-gateway-one/pom.xml delete mode 100644 ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/config/BaseConfig.java delete mode 100644 ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/config/JwtProperties.java delete mode 100644 ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/config/SpecialHystrixGatewayFilterFactory.java delete mode 100644 ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/config/SwaggerDocConfig.java delete mode 100644 ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/config/SwaggerHandler.java delete mode 100644 ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/config/SwaggerHeaderFilter.java delete mode 100644 ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/config/SwaggerProvider.java delete mode 100644 ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/utils/ChangeObjectUtils.java delete mode 100644 ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/utils/JwtUtilsKh.java delete mode 100644 ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/utils/RsaUtils.java delete mode 100644 ty-gateway/ty-gateway-one/src/main/resources/application.yml delete mode 100644 ty-gateway/ty-gateway-one/src/main/resources/bootstrap.yml create mode 100644 velocity-tmp-dir/back-vms/mybatis-plus-multb/controllerMul.vm create mode 100644 velocity-tmp-dir/back-vms/mybatis-plus-multb/entity.vm create mode 100644 velocity-tmp-dir/back-vms/mybatis-plus-multb/entityMul.vm create mode 100644 velocity-tmp-dir/back-vms/mybatis-plus-multb/entityVo.vm create mode 100644 velocity-tmp-dir/back-vms/mybatis-plus-multb/mapper.vm create mode 100644 velocity-tmp-dir/back-vms/mybatis-plus-multb/mapperMul.vm create mode 100644 velocity-tmp-dir/back-vms/mybatis-plus-multb/serviceMul.vm create mode 100644 velocity-tmp-dir/back-vms/mybatis-plus-multb/utils.vm create mode 100644 velocity-tmp-dir/back-vms/mybatis-plus-multb/xmlMul.vm create mode 100644 velocity-tmp-dir/back-vms/mybatis-plus/controller.vm create mode 100644 velocity-tmp-dir/back-vms/mybatis-plus/entity.vm create mode 100644 velocity-tmp-dir/back-vms/mybatis-plus/mapper.vm create mode 100644 velocity-tmp-dir/back-vms/mybatis-plus/service.vm create mode 100644 velocity-tmp-dir/back-vms/mybatis-plus/utils.vm rename ty-example/src/main/resources/application.yml => velocity-tmp-dir/back-vms/mybatis-plus/xml.vm (100%) create mode 100644 velocity-tmp-dir/front-vms/element-plus/CRUD.vm create mode 100644 velocity-tmp-dir/front-vms/element-plus/CRUDForm.vm create mode 100644 velocity-tmp-dir/front-vms/element-plus/formUtils.vm create mode 100644 velocity-tmp-dir/front-vms/element-plus/queryUtils.vm create mode 100644 velocity-tmp-dir/front-vms/element-plus/tableUtils.vm create mode 100644 velocity-tmp-dir/front-vms/element-plus/utils.vm create mode 100644 velocity-tmp-dir/json-data/brandData.json create mode 100644 velocity-tmp-dir/json-data/cascadeData.json create mode 100644 velocity-tmp-dir/json-data/data.json create mode 100644 velocity-tmp-dir/json-data/multiTableData.json create mode 100644 velocity-tmp-dir/json-data/tb_brand.json diff --git a/.gitignore b/.gitignore index 67f963d..6bb120a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,11 @@ .history .idea +target node_modules .DS_Store dist dist-ssr *.local -target -*.iml \ No newline at end of file +yarn* +pnpm* +coverage diff --git a/README-zh_CN.md b/README-zh_CN.md index 1322dab..7f52489 100644 --- a/README-zh_CN.md +++ b/README-zh_CN.md @@ -11,16 +11,11 @@ 本架构为springCloud微服务架构,提供基本的jwt权限认证,token更新,以及各微服务之间调用,以及提供企业级的使用例子 ```text -spring-boot:2.1.4.RELEASE -spring-cloud:Greenwich.SR1 -spring-cloud-starter-gateway:2.1.1.RELEASE -nacos:2.1.3.RELEASE -mybatis-plus:3.3.2 -rabbitmq:3.7-management -redis:3.2.9 +spring-boot:2.4.13 +spring-cloud:2020.0.5 +mybatis-plus: 3.3.2 mysql:5.7 -seata:1.4.2 -canal:1.2.1 +knife4j:2.0.9 ``` > 以上部分版本后续会升级 @@ -49,7 +44,7 @@ to look doc ---- #### 开发接口和nacos地址 -[swager文档地址](http://8.135.1.141/micro-service-doc/swagger-ui.html) +[swager文档地址](https://github.jzfai.top/micro-service-doc/doc.html) [nacos地址](http://8.135.1.141:8848/nacos/) @@ -67,16 +62,17 @@ github 地址: https://github.com/jzfai/micro-service-plus.git #### 目前实现的微服务(后续还会新增新的微服务) -##### ty - gateway - one +##### gateway: 网关微服务。使用的是spring - cloud - starter - gateway,相对于zull网关来说性能更好。主要实现了,权限控制和拦截,jwt token解析和校验, swagger文件整合,使用令牌技术请求限流等。可启动多个实例 -##### ty - auth + +##### auth-pom 权限服务。jwt token生成,解析,校验等,默认配置3天有效期,少于一天自动续约 -##### ty - example +##### basic-func: 提供一些例子。包括,rabbitmq延时队列,goFastDFS文件上传,canal, seata分部式事务,短信发送,邮件发送等。 @@ -84,9 +80,9 @@ swagger文件整合,使用令牌技术请求限流等。可启动多个实例 数据整合。vue3 - admin - plus 数据来源 -##### easycode - temp +##### velocity-tmp-dir -easycode前后端模板 +velocity 前后端模板 #### 如何运行 @@ -95,6 +91,7 @@ easycode前后端模板 ``` git clone https://github.com/jzfai/micro-service-plus.git //maven 下载依赖,即可运行 +建议先运行下 maven insall 避免出现依赖不在情况 ``` 如何配合vue3-admin-plus ,前后端一起开发 @@ -107,9 +104,9 @@ pnpm i pnpm run test #micro-service-plus 至少需要运行 -ty-auth -ty-gateway-one -ty-integration-front +basic-func +gateway +integration-front 以上三个服务 ``` diff --git a/README.md b/README.md index 884ff1f..c039d60 100644 --- a/README.md +++ b/README.md @@ -10,23 +10,16 @@ this architecture is the springCloud microservice architecture, which provides b token update, and calls between microservices, as well as enterprise-level usage examples. ```text -spring-boot:2.1.4.RELEASE -spring-cloud:Greenwich.SR1 -spring-cloud-starter-gateway:2.1.1.RELEASE -nacos:2.1.3.RELEASE +spring-boot:2.4.13 +spring-cloud:2020.0.5 mybatis-plus: 3.3.2 -rabbitmq:3.7-management -redis: 3.2.9 mysql:5.7 -seata:1.4.2 -canal:1.2.1 +knife4j:2.0.9 ``` > some of the above versions will be upgraded in the future -## Doc and Example - -[swager文档地址](http://8.135.1.141/micro-service-doc/swagger-ui.html) +## Example ![1642222390648](http://8.135.1.141/file/micro-service-assets/1642222390648.png) @@ -54,10 +47,9 @@ to look doc ---- ## Interface documentation and nacos address -[swager文档地址](http://8.135.1.141/micro-service-doc/swagger-ui.html) - -[nacos地址](http://8.135.1.141:8848/nacos/) +[swager文档地址](https://github.jzfai.top/micro-service-doc/doc.html) +[nacos地址](https://github.jzfai.top/nacos/) naocs: 用户名:jzfai; 密码:123456 ## Online experience address @@ -72,19 +64,19 @@ github 地址: https://github.com/jzfai/micro-service-plus.git ## Introduction to Microservices -##### ty-gateway-one: +##### gateway: gateway Microservices. The spring-cloud-starter-gateway is used, which has better performance than the zull gateway. It mainly implements permission control and interception, jwt token parsing and verification, swagger file integration, and request current limiting using token technology. Can start multiple -##### ty-auth: +##### auth-pom: permission service. jwt token generation, parsing, verification, etc., the default configuration is valid for 3 days, and the contract is automatically renewed if it is less than one day (if you are interested here, you can view the source code) -##### ty-example: +##### basic-func: provide some examples. Including, rabbitmq delay queue, goFastDFS file upload, canal, seata partial transaction, SMS sending, mail sending, etc. @@ -112,11 +104,12 @@ pnpm i pnpm run test #micro-service-plus At least need to run -ty-auth -ty-gateway-one -ty-integration-front +basic-func +gateway +integration-front The above three service +建议先运行下 maven insall 避免出现依赖不在情况 ``` > Note: Select the environment in Maven Projects->Profies. Currently online is a package built in the prod environment, please do not select. diff --git a/auth-pom/pom.xml b/auth-pom/pom.xml new file mode 100644 index 0000000..74210e2 --- /dev/null +++ b/auth-pom/pom.xml @@ -0,0 +1,32 @@ + + + + micro-service-plus + top.kuanghua + 1.0-SNAPSHOT + + 4.0.0 + + auth-pom + + + + top.kuanghua + common-pom + 1.0-SNAPSHOT + + + io.jsonwebtoken + jjwt + 0.9.0 + + + + com.github.xiaoymin + knife4j-aggregation-spring-boot-starter + 2.0.9 + + + \ No newline at end of file diff --git a/ty-auth/src/main/java/top/kuanghua/tyauth/controller/TokenController.java b/auth-pom/src/main/java/top/kuanghua/authpom/controller/TokenController.java similarity index 89% rename from ty-auth/src/main/java/top/kuanghua/tyauth/controller/TokenController.java rename to auth-pom/src/main/java/top/kuanghua/authpom/controller/TokenController.java index 12e59ca..f04f5a3 100644 --- a/ty-auth/src/main/java/top/kuanghua/tyauth/controller/TokenController.java +++ b/auth-pom/src/main/java/top/kuanghua/authpom/controller/TokenController.java @@ -1,64 +1,64 @@ -package top.kuanghua.tyauth.controller; - -import io.jsonwebtoken.Claims; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.*; -import top.kuanghua.khcomomon.entity.ResResult; -import top.kuanghua.tyauth.service.TokenService; - -import java.util.Map; - -/** - * @Title: TokenController - * @Description: - * @Auther: kuanghua - * @create 2021/1/31 16:31 - */ - -@RestController -@RequestMapping("token") -@Api(tags = "token相关") -@Slf4j -public class TokenController { - - @Autowired - private TokenService tokenService; - - /* - * 解析token - * */ - @ApiOperation("获取token信息") - @PostMapping("parseToken") - public ResResult parseToken(@RequestParam("jwtToken") String jwtToken) { - Claims claims = this.tokenService.parseToken(jwtToken); - return new ResResult().success(claims); - } - - /* - * 生成token - * */ - @ApiOperation("生成token") - @PostMapping("generateToken") - //@RequestHeader("authorize_token") String authorize_token - public ResResult generateToken(@RequestBody Map tokenMap) { - String generateToken = this.tokenService.generateToken(tokenMap); - return new ResResult().success(generateToken); - } - - /* - * 更新token - * */ - @ApiOperation("更新token") - @PostMapping("updateToken") - public ResResult updateToken(@RequestBody Map map) { - String updateToken = this.tokenService.updateToken(map); -// System.out.println("生成信息的token"+updateToken); -// System.out.println("生成信息的token"+map.toString()); - return new ResResult().success(updateToken); - } -} - - +package top.kuanghua.authpom.controller; + +import io.jsonwebtoken.Claims; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; +import top.kuanghua.authpom.service.TokenService; +import top.kuanghua.commonpom.entity.ResResult; + +import java.util.Map; + +/** + * @Title: TokenController + * @Description: + * @Auther: kuanghua + * @create 2021/1/31 16:31 + */ + +@RestController +@RequestMapping("token") +@Api(tags = "token相关") +@Slf4j +public class TokenController { + + @Autowired + private TokenService tokenService; + + /* + * 解析token + * */ + @ApiOperation("获取token信息") + @PostMapping("parseToken") + public ResResult parseToken(@RequestParam("jwtToken") String jwtToken) { + Claims claims = this.tokenService.parseToken(jwtToken); + return new ResResult().success(claims); + } + + /* + * 生成token + * */ + @ApiOperation("生成token") + @PostMapping("generateToken") + //@RequestHeader("authorize_token") String authorize_token + public ResResult generateToken(@RequestBody Map tokenMap) { + String generateToken = this.tokenService.generateToken(tokenMap); + return new ResResult().success(generateToken); + } + + /* + * 更新token + * */ + @ApiOperation("更新token") + @PostMapping("updateToken") + public ResResult updateToken(@RequestBody Map map) { + String updateToken = this.tokenService.updateToken(map); +// System.out.println("生成信息的token"+updateToken); +// System.out.println("生成信息的token"+map.toString()); + return new ResResult().success(updateToken); + } +} + + diff --git a/auth-pom/src/main/java/top/kuanghua/authpom/service/TokenService.java b/auth-pom/src/main/java/top/kuanghua/authpom/service/TokenService.java new file mode 100644 index 0000000..edb82d4 --- /dev/null +++ b/auth-pom/src/main/java/top/kuanghua/authpom/service/TokenService.java @@ -0,0 +1,50 @@ +package top.kuanghua.authpom.service; + +import io.jsonwebtoken.Claims; +import org.springframework.stereotype.Service; +import top.kuanghua.authpom.utils.JwtUtilsSelf; + +import java.util.Map; + +/** + * @Title: TokenService + * @Description: + * @Auther: kuanghua + * @create 2021/1/31 16:19 + */ +@Service +public class TokenService { + + private static final String AUTHORIZE_TOKEN = "AUTHORIZE_TOKEN"; + + public String generateToken(Map map) { + try { + return JwtUtilsSelf.createJWT(map, null); + } catch (Exception e) { + throw new RuntimeException("token生成有误"); + } + } + + /* + * 更新token + * */ + public String updateToken(Map map) { + try { + String updateToken = JwtUtilsSelf.createJWT(map, null); + return updateToken; + } catch (Exception e) { + throw new RuntimeException("token更新有误"); + } + } + /* + * 解析token + * */ + public Claims parseToken(String jwtToken) { + try { + Claims claims = JwtUtilsSelf.parseJWT(jwtToken); + return claims; + } catch (Exception e) { + throw new RuntimeException("token解析错误"); + } + } +} diff --git a/ty-auth/src/main/java/top/kuanghua/tyauth/utils/JwtUtilsSelf.java b/auth-pom/src/main/java/top/kuanghua/authpom/utils/JwtUtilsSelf.java similarity index 95% rename from ty-auth/src/main/java/top/kuanghua/tyauth/utils/JwtUtilsSelf.java rename to auth-pom/src/main/java/top/kuanghua/authpom/utils/JwtUtilsSelf.java index 7c482af..476819b 100644 --- a/ty-auth/src/main/java/top/kuanghua/tyauth/utils/JwtUtilsSelf.java +++ b/auth-pom/src/main/java/top/kuanghua/authpom/utils/JwtUtilsSelf.java @@ -1,94 +1,94 @@ -package top.kuanghua.tyauth.utils; - -import io.jsonwebtoken.Claims; -import io.jsonwebtoken.JwtBuilder; -import io.jsonwebtoken.Jwts; -import io.jsonwebtoken.SignatureAlgorithm; - -import javax.crypto.SecretKey; -import javax.crypto.spec.SecretKeySpec; -import java.util.Base64; -import java.util.Date; -import java.util.Map; - -/** - * 描述 - * - * @author kuanghua - * @version 1.0 - * @package entity * - * @since 1.0 - */ -public class JwtUtilsSelf { - - //https://www.cnblogs.com/passedbylove/p/11207827.html - //有效期为 - public static final Long JWT_TTL = 259200000L;//60 * 60 * 1000 * 24 * 3 三天 - //Jwt令牌信息 - public static final String JWT_KEY = "kh@Login(Auth}*^31)&kuanghua%"; - - /** - * 生成令牌 - * //* @param id - * //* @param subject - * - * @param ttlMillis - * @return - */ - public static String createJWT(Map userInfo, Long ttlMillis) { - //指定算法 - SignatureAlgorithm signatureAlgorithm = SignatureAlgorithm.HS256; - //当前系统时间 - long nowMillis = System.currentTimeMillis(); - //令牌签发时间 - Date now = new Date(nowMillis); - //如果令牌有效期为null,则默认设置有效期1小时 - if (ttlMillis == null) { - ttlMillis = JwtUtilsSelf.JWT_TTL; - } - //令牌过期时间设置 - long expMillis = nowMillis + ttlMillis; - Date expDate = new Date(expMillis); - - //生成秘钥 - SecretKey secretKey = generalKey(); - - //封装Jwt令牌信息 - JwtBuilder builder = Jwts.builder() - //.setId(id) - //.setSubject(subject) // 主题 可以是JSON数据 - //.setIssuer("admin") // 签发者 - .setIssuedAt(now) // 签发时间 - .signWith(signatureAlgorithm, secretKey) // 签名算法以及密匙 - .setExpiration(expDate); // 设置过期时间 - - JwtBuilder jwtBuilder = builder.addClaims(userInfo); - return builder.compact(); - } - - /** - * 生成加密 secretKey - * - * @return - */ - public static SecretKey generalKey() { - byte[] encodedKey = Base64.getEncoder().encode(JwtUtilsSelf.JWT_KEY.getBytes()); - SecretKey key = new SecretKeySpec(encodedKey, 0, encodedKey.length, "AES"); - return key; - } - - /** - * 解析令牌数据 - * - * @param jwt - * @return - * @throws Exception - */ - public static Claims parseJWT(String jwt) throws Exception { - SecretKey secretKey = generalKey(); - return Jwts.parser() - .setSigningKey(secretKey) - .parseClaimsJws(jwt) - .getBody(); - } -} +package top.kuanghua.authpom.utils; + +import io.jsonwebtoken.Claims; +import io.jsonwebtoken.JwtBuilder; +import io.jsonwebtoken.Jwts; +import io.jsonwebtoken.SignatureAlgorithm; + +import javax.crypto.SecretKey; +import javax.crypto.spec.SecretKeySpec; +import java.util.Base64; +import java.util.Date; +import java.util.Map; + +/** + * 描述 + * + * @author kuanghua + * @version 1.0 + * @package entity * + * @since 1.0 + */ +public class JwtUtilsSelf { + + //https://www.cnblogs.com/passedbylove/p/11207827.html + //有效期为 + public static final Long JWT_TTL = 259200000L;//60 * 60 * 1000 * 24 * 3 三天 + //Jwt令牌信息 + public static final String JWT_KEY = "kh@Login(Auth}*^31)&kuanghua%"; + + /** + * 生成令牌 + * //* @param id + * //* @param subject + * + * @param ttlMillis + * @return + */ + public static String createJWT(Map userInfo, Long ttlMillis) { + //指定算法 + SignatureAlgorithm signatureAlgorithm = SignatureAlgorithm.HS256; + //当前系统时间 + long nowMillis = System.currentTimeMillis(); + //令牌签发时间 + Date now = new Date(nowMillis); + //如果令牌有效期为null,则默认设置有效期1小时 + if (ttlMillis == null) { + ttlMillis = JwtUtilsSelf.JWT_TTL; + } + //令牌过期时间设置 + long expMillis = nowMillis + ttlMillis; + Date expDate = new Date(expMillis); + + //生成秘钥 + SecretKey secretKey = generalKey(); + + //封装Jwt令牌信息 + JwtBuilder builder = Jwts.builder() + //.setId(id) + //.setSubject(subject) // 主题 可以是JSON数据 + //.setIssuer("admin") // 签发者 + .setIssuedAt(now) // 签发时间 + .signWith(signatureAlgorithm, secretKey) // 签名算法以及密匙 + .setExpiration(expDate); // 设置过期时间 + + JwtBuilder jwtBuilder = builder.addClaims(userInfo); + return builder.compact(); + } + + /** + * 生成加密 secretKey + * + * @return + */ + public static SecretKey generalKey() { + byte[] encodedKey = Base64.getEncoder().encode(JwtUtilsSelf.JWT_KEY.getBytes()); + SecretKey key = new SecretKeySpec(encodedKey, 0, encodedKey.length, "AES"); + return key; + } + + /** + * 解析令牌数据 + * + * @param jwt + * @return + * @throws Exception + */ + public static Claims parseJWT(String jwt) throws Exception { + SecretKey secretKey = generalKey(); + return Jwts.parser() + .setSigningKey(secretKey) + .parseClaimsJws(jwt) + .getBody(); + } +} diff --git a/ty-auth/src/main/main12.iml b/auth-pom/src/main/main12.iml similarity index 100% rename from ty-auth/src/main/main12.iml rename to auth-pom/src/main/main12.iml diff --git a/auth-pom/src/main/resources/application.yml b/auth-pom/src/main/resources/application.yml new file mode 100644 index 0000000..d3a13fc --- /dev/null +++ b/auth-pom/src/main/resources/application.yml @@ -0,0 +1,11 @@ +server: + port: ${envpt.tomcatPortPre}0131 + +#jwt相关 +jwt-properties: + secret: kh@Login(Auth}*^31)&kuanghua% # 登录校验的密钥(盐) + # 60 * 60 * 1000 * 24 * 3 三天 + expire: 259200000L; + + + diff --git a/ty-auth/src/main/resources/bootstrap.yml b/auth-pom/src/main/resources/bootstrap.yml similarity index 92% rename from ty-auth/src/main/resources/bootstrap.yml rename to auth-pom/src/main/resources/bootstrap.yml index bc12133..f32e54b 100644 --- a/ty-auth/src/main/resources/bootstrap.yml +++ b/auth-pom/src/main/resources/bootstrap.yml @@ -1,29 +1,29 @@ -spring: - application: - name: @project.artifactId@ - profiles: - active: @activatedProperties@ - cloud: - nacos: - config: - enabled: true - namespace: @nacosNamespace@ - group: @nacosGroup@ - username: @nacosUsername@ - password: @nacosPassword@ - server-addr: @nacosIpPort@ - prefix: @project.artifactId@ - file-extension: yml - # 用于共享的配置文件 - shared-configs: - - data-id: application-main.yml - group: @nacosGroup@ - refresh: true - discovery: - namespace: @nacosNamespace@ - group: @nacosGroup@ - username: @nacosUsername@ - password: @nacosPassword@ - server-addr: @nacosIpPort@ - weight: @nacosWeight@ +spring: + application: + name: @project.artifactId@ + profiles: + active: @activatedProperties@,main + cloud: + nacos: + config: + enabled: true + namespace: @nacosNamespace@ + group: @nacosGroup@ + username: @nacosUsername@ + password: @nacosPassword@ + server-addr: @nacosIpPort@ + prefix: @project.artifactId@ + file-extension: yml + # 用于共享的配置文件 + shared-configs: + - data-id: application-main.yml + group: @nacosGroup@ + refresh: true + discovery: + namespace: @nacosNamespace@ + group: @nacosGroup@ + username: @nacosUsername@ + password: @nacosPassword@ + server-addr: @nacosIpPort@ + weight: @nacosWeight@ ip: @nacosDiscoveryIp@ \ No newline at end of file diff --git a/ty-auth/src/main/resources/rsa.pri b/auth-pom/src/main/resources/rsa.pri similarity index 100% rename from ty-auth/src/main/resources/rsa.pri rename to auth-pom/src/main/resources/rsa.pri diff --git a/ty-auth/src/main/resources/rsa.pub b/auth-pom/src/main/resources/rsa.pub similarity index 100% rename from ty-auth/src/main/resources/rsa.pub rename to auth-pom/src/main/resources/rsa.pub diff --git a/ty-example/pom.xml b/basis-func/pom.xml similarity index 63% rename from ty-example/pom.xml rename to basis-func/pom.xml index b63dc78..7914137 100644 --- a/ty-example/pom.xml +++ b/basis-func/pom.xml @@ -1,6 +1,6 @@ - micro-service-plus @@ -9,47 +9,37 @@ 4.0.0 - ty-example + basis-func + + top.kuanghua - ty-common + common-pom 1.0-SNAPSHOT - - com.aliyun - aliyun-java-sdk-core - 4.5.3 + net.lingala.zip4j + zip4j + 2.9.1 - - org.springframework.boot - spring-boot-starter-mail + org.apache.velocity + velocity-engine-core + 2.3 - - - com.github.tobato - fastdfs-client - 1.27.2 + org.apache.velocity.tools + velocity-tools-generic + 3.1 - cn.hutool hutool-all 4.5.1 - - - - com.xpand - starter-canal - 0.0.1-SNAPSHOT - - ${project.artifactId} @@ -63,10 +53,14 @@ org.springframework.boot spring-boot-maven-plugin + + org.apache.maven.plugins + maven-resources-plugin + 3.1.0 + org.apache.maven.plugins maven-surefire-plugin - 2.22.1 true diff --git a/basis-func/src/main/java/top/kuanghua/basisfunc/BasisFuncApplication.java b/basis-func/src/main/java/top/kuanghua/basisfunc/BasisFuncApplication.java new file mode 100644 index 0000000..951cb74 --- /dev/null +++ b/basis-func/src/main/java/top/kuanghua/basisfunc/BasisFuncApplication.java @@ -0,0 +1,17 @@ +package top.kuanghua.basisfunc; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * @Title: VgApplication + * @Description: + * @Auther: kuanghua + * @create 2022/6/1 21:19 + */ +@SpringBootApplication +public class BasisFuncApplication { + public static void main(String[] args) { + SpringApplication.run(BasisFuncApplication.class, args); + } +} diff --git a/basis-func/src/main/java/top/kuanghua/basisfunc/config/BaseConfig.java b/basis-func/src/main/java/top/kuanghua/basisfunc/config/BaseConfig.java new file mode 100644 index 0000000..e869698 --- /dev/null +++ b/basis-func/src/main/java/top/kuanghua/basisfunc/config/BaseConfig.java @@ -0,0 +1,17 @@ +package top.kuanghua.basisfunc.config; + +import org.mybatis.spring.annotation.MapperScan; +import org.springframework.cloud.openfeign.EnableFeignClients; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; + + +@Configuration +@ComponentScan(basePackages = { + "top.kuanghua.commonpom", + "top.kuanghua.basisfunc" +}) +@MapperScan(basePackages = {"top.kuanghua.basisfunc.mapper"}) +public class BaseConfig { + +} diff --git a/basis-func/src/main/java/top/kuanghua/basisfunc/config/Knife4jConfiguration.java b/basis-func/src/main/java/top/kuanghua/basisfunc/config/Knife4jConfiguration.java new file mode 100644 index 0000000..0c7ceda --- /dev/null +++ b/basis-func/src/main/java/top/kuanghua/basisfunc/config/Knife4jConfiguration.java @@ -0,0 +1,39 @@ +package top.kuanghua.basisfunc.config; + +import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import springfox.documentation.builders.ApiInfoBuilder; +import springfox.documentation.builders.PathSelectors; +import springfox.documentation.builders.RequestHandlerSelectors; +import springfox.documentation.service.ApiInfo; +import springfox.documentation.service.Contact; +import springfox.documentation.spi.DocumentationType; +import springfox.documentation.spring.web.plugins.Docket; +import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc; + +@Configuration +@EnableSwagger2WebMvc +@EnableKnife4j +public class Knife4jConfiguration { + @Bean + public Docket createRestApi() { + return new Docket(DocumentationType.SWAGGER_2) + .useDefaultResponseMessages(false) + .apiInfo(apiInfo()) + .select().apis(RequestHandlerSelectors.basePackage("top.kuanghua.basisfunc")) + .paths(PathSelectors.any()) + .build(); + } + + private ApiInfo apiInfo() { + return new ApiInfoBuilder() + .description("Kinfe4j 集成测试文档") + .contact(new Contact("熊猫哥", "https://github.com/jzfai/", "869653722@qq.com")) + .version("v1.1.0") + .title("API测试文档") + .build(); + } + +} + diff --git a/basis-func/src/main/java/top/kuanghua/basisfunc/controller/DataBaseController.java b/basis-func/src/main/java/top/kuanghua/basisfunc/controller/DataBaseController.java new file mode 100644 index 0000000..1b5f96b --- /dev/null +++ b/basis-func/src/main/java/top/kuanghua/basisfunc/controller/DataBaseController.java @@ -0,0 +1,48 @@ +package top.kuanghua.basisfunc.controller; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import top.kuanghua.basisfunc.service.DataBaseService; +import top.kuanghua.commonpom.entity.ResResult; + +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.Map; + +/** + * @Title: DataBaseController + * @Description: + * @Auther: kuanghua + * @create 2022/6/3 8:53 + */ +@Api(tags = "获取数据库表和字段信息") +@RestController +@RequestMapping("dataBase") +public class DataBaseController { + @Resource + private DataBaseService dataBaseService; + + @GetMapping("getAllDatabaseOrTable/{dbName}") + @ApiOperation(value = "mysql获取所有表") + public ResResult getAllTableFromDb(@PathVariable String dbName) { + ArrayList allTableFromDb = this.dataBaseService.getAllTableFromDb(dbName); + return new ResResult().success(allTableFromDb); + } + + /** + * @param dbName + * @param tbName + * @return + */ + @GetMapping("getAllDatabaseOrTable/{dbName}/{tbName}") + @ApiOperation(value = "mysql获取表及字段信息") + public ResResult getAllColumnFromTb(@PathVariable String dbName, @PathVariable String tbName) { + ArrayList allColumnFromTb = this.dataBaseService.getAllColumnFromTb(dbName, tbName); + return new ResResult().success(allColumnFromTb); + + } +} diff --git a/basis-func/src/main/java/top/kuanghua/basisfunc/controller/GeneratorController.java b/basis-func/src/main/java/top/kuanghua/basisfunc/controller/GeneratorController.java new file mode 100644 index 0000000..2c07931 --- /dev/null +++ b/basis-func/src/main/java/top/kuanghua/basisfunc/controller/GeneratorController.java @@ -0,0 +1,115 @@ +package top.kuanghua.basisfunc.controller; + +import com.alibaba.fastjson.JSON; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; +import top.kuanghua.basisfunc.service.GeneratorCustromService; +import top.kuanghua.basisfunc.service.GeneratorService; +import top.kuanghua.basisfunc.utils.GeneratorTempUtils; +import top.kuanghua.commonpom.utils.ObjSelfUtils; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; +import java.util.List; +import java.util.Map; + +/** + * @author 猫哥 + * @email kuanghua@aulton.com + * @date 2022-06-06 13:39 + * @Copyright Copyright (c) aulton Inc. All Rights Reserved. + **/ +@Api(tags = "模板生成") +@RestController +@RequestMapping("generator") +public class GeneratorController { + @Resource + private GeneratorService generatorService; + + @Resource + private GeneratorCustromService generatorCustromService; + + @ApiOperation(value = "生成前后端模版") + @PostMapping("generatorFrontBackTempZip") + public void generatorFrontBackTempZip(HttpServletResponse response, @RequestBody Map generatorData) { + //生成模板 + String exportFilePath = this.generatorService.generatorFrontBackTempZip(generatorData); + response.setContentType("application/zip"); + response.setCharacterEncoding("utf-8"); + response.setHeader("Access-Control-Expose-Headers", "exportFileName"); + response.setHeader("exportFileName", "font-back-temp-" + ObjSelfUtils.getCurrentDateTimeTrim() + ".zip"); + //你压缩包路径 + GeneratorTempUtils.downloadZip(response, exportFilePath); + } + + @ApiOperation(value = "生成前端模版") + @PostMapping("generatorFrontTempZip") + public void generatorFrontTempZip(HttpServletResponse response, @RequestBody Map generatorData) { + //生成模板 + String exportFilePath = this.generatorService.generatorFrontTempZip(generatorData); + response.setContentType("application/zip"); + response.setCharacterEncoding("utf-8"); + response.setHeader("Access-Control-Expose-Headers", "exportFileName"); + response.setHeader("exportFileName", "front-temp-" + ObjSelfUtils.getCurrentDateTimeTrim() + ".zip"); + //你压缩包路径 + GeneratorTempUtils.downloadZip(response, exportFilePath); + } + + @ApiOperation(value = "生成后端模版") + @PostMapping("generatorBackTempZip") + public void generatorBackTempZip(HttpServletResponse response, @RequestBody Map generatorData) { + //生成模板 + String exportFilePath = this.generatorService.generatorBackTempZip(generatorData); + response.setContentType("application/zip"); + response.setCharacterEncoding("utf-8"); + response.setHeader("Access-Control-Expose-Headers", "exportFileName"); + response.setHeader("exportFileName", "back-temp-" + ObjSelfUtils.getCurrentDateTimeTrim() + ".zip"); + //你压缩包路径 + GeneratorTempUtils.downloadZip(response, exportFilePath); + } + + /*自定义模版*/ + @ApiOperation(value = "生成前端自定义模版") + @PostMapping("generatorFrontCustomTemp") + public void generatorFrontCustomTemp(HttpServletResponse response, @RequestParam("file") List files, @RequestParam("jsonData") String jsonData) { + Map JsonMap = JSON.parseObject(jsonData, Map.class); + //生成模板 + String exportFilePath = generatorCustromService.generatorFrontCustomTemp(files, JsonMap); + response.setContentType("application/zip"); + response.setCharacterEncoding("utf-8"); + response.setHeader("Access-Control-Expose-Headers", "exportFileName"); + response.setHeader("exportFileName", "custom-front-temp-" + ObjSelfUtils.getCurrentDateTimeTrim() + ".zip"); + //你压缩包路径 + GeneratorTempUtils.downloadZip(response, exportFilePath); + } + + @ApiOperation(value = "生成后端自定义模版") + @PostMapping("generatorBackCustomTemp") + public void generatorBackCustomTemp(HttpServletResponse response, @RequestParam("file") List files, @RequestParam("jsonData") String jsonData) { + Map JsonMap = JSON.parseObject(jsonData, Map.class); + //生成模板 + String exportFilePath = generatorCustromService.generatorBackCustomTemp(files, JsonMap); + response.setContentType("application/zip"); + response.setCharacterEncoding("utf-8"); + response.setHeader("Access-Control-Expose-Headers", "exportFileName"); + response.setHeader("exportFileName", "custom-back-temp-" + ObjSelfUtils.getCurrentDateTimeTrim() + ".zip"); + //你压缩包路径 + GeneratorTempUtils.downloadZip(response, exportFilePath); + } + + @ApiOperation(value = "自定义生成模版(只提供数据源能力,导入的模版是什么则返回什么, 返回后会对模版里的插槽字段进行填充)") + @PostMapping("generatorCustomTemp") + public void generatorCustomTemp(HttpServletResponse response, @RequestParam("file") List files, @RequestParam("jsonData") String jsonData) { + Map JsonMap = JSON.parseObject(jsonData, Map.class); + //生成模板 + String exportFilePath = generatorCustromService.generatorCustomTemp(files, JsonMap); + response.setContentType("application/zip"); + response.setCharacterEncoding("utf-8"); + response.setHeader("Access-Control-Expose-Headers", "exportFileName"); + response.setHeader("exportFileName", "custom-temp-" + ObjSelfUtils.getCurrentDateTimeTrim() + ".zip"); + //你压缩包路径 + GeneratorTempUtils.downloadZip(response, exportFilePath); + } +} diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/controller/GoFastDFSController.java b/basis-func/src/main/java/top/kuanghua/basisfunc/controller/GoFastDFSController.java similarity index 89% rename from ty-example/src/main/java/top/kuanghua/tyexample/controller/GoFastDFSController.java rename to basis-func/src/main/java/top/kuanghua/basisfunc/controller/GoFastDFSController.java index 5f9e1a5..2d59264 100644 --- a/ty-example/src/main/java/top/kuanghua/tyexample/controller/GoFastDFSController.java +++ b/basis-func/src/main/java/top/kuanghua/basisfunc/controller/GoFastDFSController.java @@ -1,4 +1,4 @@ -package top.kuanghua.tyexample.controller; +package top.kuanghua.basisfunc.controller; import cn.hutool.core.io.resource.InputStreamResource; import cn.hutool.http.HttpUtil; @@ -11,7 +11,7 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; -import top.kuanghua.khcomomon.entity.ResResult; +import top.kuanghua.commonpom.entity.ResResult; import java.io.IOException; import java.util.HashMap; @@ -36,7 +36,8 @@ public ResResult goFastfdfs(@RequestParam("file") MultipartFile file) { InputStreamResource isr = new InputStreamResource(file.getInputStream(), file.getOriginalFilename()); Map params = new HashMap<>(); params.put("file", isr); - params.put("path", "86501729"); + params.put("name", file.getOriginalFilename()); + params.put("size", file.getSize()); params.put("output", "json"); String resp = HttpUtil.post("http://8.135.1.141:8080/group1/upload", params); Map coversMap = JSON.parseObject(resp, Map.class); diff --git a/basis-func/src/main/java/top/kuanghua/basisfunc/mapper/DataBaseMapper.java b/basis-func/src/main/java/top/kuanghua/basisfunc/mapper/DataBaseMapper.java new file mode 100644 index 0000000..955359c --- /dev/null +++ b/basis-func/src/main/java/top/kuanghua/basisfunc/mapper/DataBaseMapper.java @@ -0,0 +1,35 @@ +package top.kuanghua.basisfunc.mapper; + +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; + +import java.util.ArrayList; +import java.util.Map; + +/** + * @Title: DataBaseMapper + * @Description: + * @Auther: kuanghua + * @create 2022/6/3 8:38 + */ +public interface DataBaseMapper { + + /** + * mysql获取所有表 + * + * @param dbName + * @return + */ + @Select("SELECT table_schema,table_name,table_comment,create_time,update_time FROM information_schema.tables WHERE TABLE_SCHEMA = #{dbName}") + ArrayList getAllTableFromDb(@Param("dbName") String dbName); + + + /** + * mysql获取表所有字段信息 + * + * @param tbName + * @return + */ + @Select("SELECT table_schema,table_name,column_name,is_nullable,data_type,column_type,column_key,extra,column_comment FROM INFORMATION_SCHEMA.COLUMNS COL Where TABLE_SCHEMA=#{dbName} AND COL.TABLE_NAME=#{tbName}") + ArrayList getAllColumnFromTb(@Param("dbName") String dbName, @Param("tbName") String tbName); +} diff --git a/basis-func/src/main/java/top/kuanghua/basisfunc/service/DataBaseService.java b/basis-func/src/main/java/top/kuanghua/basisfunc/service/DataBaseService.java new file mode 100644 index 0000000..2011e90 --- /dev/null +++ b/basis-func/src/main/java/top/kuanghua/basisfunc/service/DataBaseService.java @@ -0,0 +1,40 @@ +package top.kuanghua.basisfunc.service; + +import org.springframework.stereotype.Service; +import top.kuanghua.basisfunc.mapper.DataBaseMapper; + +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.Map; + +/** + * @Title: DataBaseService + * @Description: + * @Auther: kuanghua + * @create 2022/6/3 8:50 + * https://blog.csdn.net/qq_39323945/article/details/124661309 + */ +@Service +public class DataBaseService { + @Resource + private DataBaseMapper dataBaseMapper; + + /** + * @param dbName + * @return + */ + public ArrayList getAllTableFromDb(String dbName) { + ArrayList allTableFromDb = this.dataBaseMapper.getAllTableFromDb(dbName); + return allTableFromDb; + } + + /** + * @param dbName + * @param tbName + * @return + */ + public ArrayList getAllColumnFromTb(String dbName, String tbName) { + ArrayList allColumnFromTb = this.dataBaseMapper.getAllColumnFromTb(dbName, tbName); + return allColumnFromTb; + } +} diff --git a/basis-func/src/main/java/top/kuanghua/basisfunc/service/GeneratorCustromService.java b/basis-func/src/main/java/top/kuanghua/basisfunc/service/GeneratorCustromService.java new file mode 100644 index 0000000..ce7496d --- /dev/null +++ b/basis-func/src/main/java/top/kuanghua/basisfunc/service/GeneratorCustromService.java @@ -0,0 +1,315 @@ +package top.kuanghua.basisfunc.service; + +import com.alibaba.fastjson.JSON; +import org.apache.velocity.Template; +import org.apache.velocity.context.Context; +import org.jetbrains.annotations.NotNull; +import org.springframework.stereotype.Service; +import org.springframework.web.multipart.MultipartFile; +import top.kuanghua.basisfunc.utils.GeneratorTempUtils; +import top.kuanghua.commonpom.utils.ObjSelfUtils; + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +/** + * @author 猫哥 + * @date 2022-06-06 13:31 + **/ +@Service +public class GeneratorCustromService { + + /** + * mybatis-plus多表生成模版 + */ + public void generatorMybatisPlusMulTemp(Map jsonData, String tmpSaveDir) { + Context context = getContext(jsonData); + Map dbTableConfig = ObjSelfUtils.changeToMap(jsonData.get("dbTableConfig")); + ArrayList> multiTableConfig = ObjSelfUtils.changeToArrayMap(jsonData.get("multiTableConfig")); + multiTableConfig.forEach((fItem) -> { + //entity + FileWriter entityWriter = null; + try { + Template entityTemp = GeneratorTempUtils.getTmpSaveDirTemp(tmpSaveDir, "entity.vm"); + context.put("currentTbConfig", fItem); + context.put("tableFieldArr", fItem.get("tableFieldArr")); + entityWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusMulDir("entity") + fItem.get("tableNameCase") + ".java"); + entityTemp.merge(context, entityWriter); + entityWriter.close(); + + //single-mapper + Template mapperTemp = GeneratorTempUtils.getTmpSaveDirTemp(tmpSaveDir, "mapper.vm"); + FileWriter mapperWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusMulDir("mapper") + fItem.get("tableNameCase") + "Mapper.java"); + mapperTemp.merge(context, mapperWriter); + mapperWriter.close(); + } catch (IOException e) { + throw new RuntimeException(" mybatis-plus多表生成模版报错" + e); + } + }); + String tbName = dbTableConfig.get("multiTableNameCase").toString(); + try { + //controller + Template controllerTemp = GeneratorTempUtils.getTmpSaveDirTemp(tmpSaveDir, "controllerMul.vm"); + FileWriter controllerWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusMulDir("controller") + tbName + "Controller.java"); + controllerTemp.merge(context, controllerWriter); + controllerWriter.close(); + //service + Template serviceTemp = GeneratorTempUtils.getTmpSaveDirTemp(tmpSaveDir, "serviceMul.vm"); + FileWriter serviceWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusMulDir("service") + tbName + "Service.java"); + serviceTemp.merge(context, serviceWriter); + serviceWriter.close(); + + //mul-entity + Template mapperMulTemp = GeneratorTempUtils.getTmpSaveDirTemp(tmpSaveDir, "mapperMul.vm"); + FileWriter mapperMulWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusMulDir("mapper") + tbName + "Mapper.java"); + mapperMulTemp.merge(context, mapperMulWriter); + mapperMulWriter.close(); + + //entity-vo + Template entityVoTemp = GeneratorTempUtils.getTmpSaveDirTemp(tmpSaveDir, "entityVo.vm"); + FileWriter entityVoWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusMulDir("vo") + tbName + "Vo.java"); + entityVoTemp.merge(context, entityVoWriter); + entityVoWriter.close(); + + //entity-mul + Template entityMulTemp = GeneratorTempUtils.getTmpSaveDirTemp(tmpSaveDir, "entityMul.vm"); + FileWriter entityMulWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusMulDir("entity") + tbName + ".java"); + entityMulTemp.merge(context, entityMulWriter); + entityMulWriter.close(); + //xml + Template xmlTemp = GeneratorTempUtils.getTmpSaveDirTemp(tmpSaveDir, "xmlMul.vm"); + FileWriter xmlWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusMulDir("xml") + tbName + "Mapper.xml"); + xmlTemp.merge(context, xmlWriter); + xmlWriter.close(); + + String exportFilePath = GeneratorTempUtils.getOutputZipPath() + ObjSelfUtils.getCurrentDateTimeTrim() + ".zip"; + //生成zip包 + GeneratorTempUtils.createZipFile(exportFilePath, GeneratorTempUtils.getNeedZipDir()); + + } catch (IOException e) { + throw new RuntimeException("生成实体类报错" + e); + } + } + + @NotNull + private Context getContext(Map jsonData) { + Context context = GeneratorTempUtils.getVelocityContext(); + context.put("totalData", jsonData); + context.put("projectOrAuthor", jsonData.get("projectOrAuthor")); + context.put("multiTableConfig", jsonData.get("multiTableConfig")); + context.put("queryConfig", jsonData.get("queryConfig")); + context.put("tableConfig", jsonData.get("tableConfig")); + context.put("formConfig", jsonData.get("formConfig")); + context.put("dbTableConfig", jsonData.get("dbTableConfig")); + return context; + } + + /** + * Mybatis-plus单表生成模版 + */ + public void generatorMybatisPlusTemp(Map jsonData, String tmpSaveDir) { + try { + Context context = getContext(jsonData); + Map dbTableConfig = JSON.parseObject(JSON.toJSONString(jsonData.get("dbTableConfig")), Map.class); + String tbName = dbTableConfig.get("tableNameCase").toString(); + //entity + Template entityTemp = GeneratorTempUtils.getTmpSaveDirTemp(tmpSaveDir, "entity.vm"); + FileWriter entityWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusDir("entity") + tbName + ".java"); + entityTemp.merge(context, entityWriter); + entityWriter.close(); + //controller + Template controllerTemp = GeneratorTempUtils.getTmpSaveDirTemp(tmpSaveDir, "controller.vm"); + FileWriter controllerWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusDir("controller") + tbName + "Controller.java"); + controllerTemp.merge(context, controllerWriter); + controllerWriter.close(); + //service + Template serviceTemp = GeneratorTempUtils.getTmpSaveDirTemp(tmpSaveDir, "service.vm"); + FileWriter serviceWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusDir("service") + tbName + "Service.java"); + serviceTemp.merge(context, serviceWriter); + serviceWriter.close(); + //mapper + Template mapperTemp = GeneratorTempUtils.getTmpSaveDirTemp(tmpSaveDir, "mapper.vm"); + FileWriter mapperWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusDir("mapper") + tbName + "Mapper.java"); + mapperTemp.merge(context, mapperWriter); + mapperWriter.close(); + } catch (IOException e) { + throw new RuntimeException("Mybatis-plus单表生成模版报错" + e); + } + } + + /** + * element-plus多表生成模版 + */ + public void generatorElementPlusTemp(Map jsonData, String tmpSaveDir) { + try { + Context context = getContext(jsonData); + Template template = GeneratorTempUtils.getTmpSaveDirTemp(tmpSaveDir, "CRUD.vm"); + FileWriter fileWriter = new FileWriter(GeneratorTempUtils.getExportElementPlusDir("") + "CRUD.vue"); + template.merge(context, fileWriter); + fileWriter.close(); + //第二个模板 + Template addModal = GeneratorTempUtils.getTmpSaveDirTemp(tmpSaveDir, "CRUDForm.vm"); + FileWriter addModalWriter = new FileWriter(GeneratorTempUtils.getExportElementPlusDir("") + "CRUDForm.vue"); + addModal.merge(context, addModalWriter); + addModalWriter.close(); + } catch (IOException e) { + throw new RuntimeException("element-plus多表生成模版报错" + e); + } + } + + /** + * 生成my模版 + * + * @param jsonData + * @return + */ + public String generatorBackTempZip(Map jsonData, String tmpSaveDir) { + Map commonConfig = JSON.parseObject(JSON.toJSONString(jsonData.get("commonConfig")), Map.class); + if ("true".equals(commonConfig.get("isTableMulChoose").toString())) { + //生成前端模板 + generatorMybatisPlusMulTemp(jsonData, tmpSaveDir); + } else { + /*单表*/ + //生成前端模板 + generatorMybatisPlusTemp(jsonData, tmpSaveDir); + } + String exportFilePath = GeneratorTempUtils.getOutputZipPath() + ObjSelfUtils.getCurrentDateTimeTrim() + ".zip"; + //生成zip包 + GeneratorTempUtils.createZipFile(exportFilePath, GeneratorTempUtils.getNeedZipDir()); + return exportFilePath; + } + + /** + * 生成前端模版 + * + * @param jsonData + * @return + */ + public String generatorFrontTempZip(Map jsonData, String tmpSaveDir) { + Map commonConfig = JSON.parseObject(JSON.toJSONString(jsonData.get("commonConfig")), Map.class); + //多表 + if ("true".equals(commonConfig.get("isTableMulChoose").toString())) { + //生成前端模板 + generatorElementPlusTemp(jsonData, tmpSaveDir); + } else { + /*单表*/ + //生成前端模板 + generatorElementPlusTemp(jsonData, tmpSaveDir); + } + String exportFilePath = GeneratorTempUtils.getOutputZipPath() + ObjSelfUtils.getCurrentDateTimeTrim() + ".zip"; + //生成zip包 + GeneratorTempUtils.createZipFile(exportFilePath, GeneratorTempUtils.getNeedZipDir()); + return exportFilePath; + } + +// /** +// * 生成前后端模版 +// * +// * @param jsonData +// * @return +// */ +// public String generatorFrontBackTempZip(Map jsonData, String tmpSaveDir) { +// Map commonConfig = JSON.parseObject(JSON.toJSONString(jsonData.get("commonConfig")), Map.class); +// //多表 +// if ("true".equals(commonConfig.get("isTableMulChoose").toString())) { +// //生成前端模板 +// generatorElementPlusTemp(jsonData, tmpSaveDir); +// //生成后端模板 +// generatorMybatisPlusMulTemp(jsonData, tmpSaveDir); +// } else { +// /*单表*/ +// //生成前端模板 +// generatorElementPlusTemp(jsonData, tmpSaveDir); +// //生成后端模板 +// generatorMybatisPlusTemp(jsonData, tmpSaveDir); +// } +// +// String exportFilePath = GeneratorTempUtils.getOutputZipPath() + ObjSelfUtils.getCurrentDateTimeTrim() + ".zip"; +// //生成zip包 +// GeneratorTempUtils.createZipFile(exportFilePath, GeneratorTempUtils.getNeedZipDir()); +// return exportFilePath; +// } + + /** + * 生成前端自定义模版 + * + * @param files + * @param jsonData + * @return + */ + public String generatorFrontCustomTemp(List files, Map jsonData) { + String tempSaveDir = getSaveDir(files); + String tempZip = generatorFrontTempZip(jsonData, tempSaveDir); + GeneratorTempUtils.deleteDir(tempSaveDir); + return tempZip; + } + + /** + * 生成后端自定义模版 + * + * @param files + * @param jsonData + * @return + */ + public String generatorBackCustomTemp(List files, Map jsonData) { + String tempSaveDir = getSaveDir(files); + String tempZip = generatorBackTempZip(jsonData, tempSaveDir); + GeneratorTempUtils.deleteDir(tempSaveDir); + return tempZip; + } + + + /** + * 接收文件并保存文件到本地 + * + * @param files + * @return 保存后的文件路径 + */ + private String getSaveDir(List files) { + String tmpSaveDir = GeneratorTempUtils.getTmpSaveDir(); + for (MultipartFile file : files) { + String filename = file.getOriginalFilename(); + File f = new File(tmpSaveDir + filename); + //保存文件 + try { + file.transferTo(f); + } catch (IOException e) { + e.printStackTrace(); + } + } + return tmpSaveDir; + } + + + /** + * 只提供数据源能力,导入的模版是什么则返回什么, 返回后会对模版里的插槽字段进行填充 + * + * @param files + * @param jsonData + * @return + */ + public String generatorCustomTemp(List files, Map jsonData) { + Context context = getContext(jsonData); + String tempSaveDir = getSaveDir(files); + files.forEach((file) -> { + String originalFilename = file.getOriginalFilename(); + Template xmlTemp = GeneratorTempUtils.getTmpSaveDirTemp(tempSaveDir, originalFilename); + try { + FileWriter xmlWriter = new FileWriter(GeneratorTempUtils.getExportFileDir() + originalFilename); + xmlTemp.merge(context, xmlWriter); + xmlWriter.close(); + } catch (IOException e) { + throw new RuntimeException("生成临时模版报错" + e); + } + }); + String exportFilePath = GeneratorTempUtils.getOutputZipPath() + ObjSelfUtils.getCurrentDateTimeTrim() + ".zip"; + GeneratorTempUtils.createZipFile(exportFilePath, GeneratorTempUtils.getNeedZipDir()); + GeneratorTempUtils.deleteDir(tempSaveDir); + return exportFilePath; + } + +} diff --git a/basis-func/src/main/java/top/kuanghua/basisfunc/service/GeneratorService.java b/basis-func/src/main/java/top/kuanghua/basisfunc/service/GeneratorService.java new file mode 100644 index 0000000..1ae5b40 --- /dev/null +++ b/basis-func/src/main/java/top/kuanghua/basisfunc/service/GeneratorService.java @@ -0,0 +1,232 @@ +package top.kuanghua.basisfunc.service; + +import com.alibaba.fastjson.JSON; +import org.apache.velocity.Template; +import org.apache.velocity.context.Context; +import org.springframework.stereotype.Service; +import top.kuanghua.basisfunc.utils.GeneratorTempUtils; +import top.kuanghua.commonpom.utils.ObjSelfUtils; + +import java.io.FileWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Map; + +/** + * @author 猫哥 + * @date 2022-06-06 13:31 + **/ +@Service +public class GeneratorService { + + /** + * mybatis-plus多表生成模版 + */ + public void generatorMybatisPlusMulTemp(Map jsonData) { + Context context = getContext(jsonData); + Map dbTableConfig = ObjSelfUtils.changeToMap(jsonData.get("dbTableConfig")); + ArrayList> multiTableConfig = ObjSelfUtils.changeToArrayMap(jsonData.get("multiTableConfig")); + multiTableConfig.forEach((fItem) -> { + //entity + FileWriter entityWriter = null; + try { + Template entityTemp = GeneratorTempUtils.getMybatisPlusMulTbTemp("entity.vm"); + context.put("currentTbConfig", fItem); + context.put("tableFieldArr", fItem.get("tableFieldArr")); + entityWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusMulDir("entity") + fItem.get("tableNameCase") + ".java"); + entityTemp.merge(context, entityWriter); + entityWriter.close(); + + //single-mapper + Template mapperTemp = GeneratorTempUtils.getMybatisPlusMulTbTemp("mapper.vm"); + FileWriter mapperWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusMulDir("mapper") + fItem.get("tableNameCase") + "Mapper.java"); + mapperTemp.merge(context, mapperWriter); + mapperWriter.close(); + } catch (IOException e) { + throw new RuntimeException(" mybatis-plus多表生成模版报错" + e); + } + }); + String tbName = dbTableConfig.get("multiTableNameCase").toString(); + try { + //controller + Template controllerTemp = GeneratorTempUtils.getMybatisPlusMulTbTemp("controllerMul.vm"); + FileWriter controllerWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusMulDir("controller") + tbName + "Controller.java"); + controllerTemp.merge(context, controllerWriter); + controllerWriter.close(); + //service + Template serviceTemp = GeneratorTempUtils.getMybatisPlusMulTbTemp("serviceMul.vm"); + FileWriter serviceWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusMulDir("service") + tbName + "Service.java"); + serviceTemp.merge(context, serviceWriter); + serviceWriter.close(); + + //mul-entity + Template mapperMulTemp = GeneratorTempUtils.getMybatisPlusMulTbTemp("mapperMul.vm"); + FileWriter mapperMulWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusMulDir("mapper") + tbName + "Mapper.java"); + mapperMulTemp.merge(context, mapperMulWriter); + mapperMulWriter.close(); + + //entity-vo + Template entityVoTemp = GeneratorTempUtils.getMybatisPlusMulTbTemp("entityVo.vm"); + FileWriter entityVoWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusMulDir("vo") + tbName + "Vo.java"); + entityVoTemp.merge(context, entityVoWriter); + entityVoWriter.close(); + + //entity-mul + Template entityMulTemp = GeneratorTempUtils.getMybatisPlusMulTbTemp("entityMul.vm"); + FileWriter entityMulWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusMulDir("entity") + tbName + ".java"); + entityMulTemp.merge(context, entityMulWriter); + entityMulWriter.close(); + //xml + Template xmlTemp = GeneratorTempUtils.getMybatisPlusMulTbTemp("xmlMul.vm"); + FileWriter xmlWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusMulDir("xml") + tbName + "Mapper.xml"); + xmlTemp.merge(context, xmlWriter); + xmlWriter.close(); + + String exportFilePath = GeneratorTempUtils.getOutputZipPath() + ObjSelfUtils.getCurrentDateTimeTrim() + ".zip"; + //生成zip包 + GeneratorTempUtils.createZipFile(exportFilePath, GeneratorTempUtils.getNeedZipDir()); + } catch (IOException e) { + throw new RuntimeException("生成实体类报错" + e); + } + } + + /** + * Mybatis-plus单表生成模版 + */ + public void generatorMybatisPlusTemp(Map jsonData) { + try { + Context context = getContext(jsonData); + Map dbTableConfig = JSON.parseObject(JSON.toJSONString(jsonData.get("dbTableConfig")), Map.class); + String tbName = dbTableConfig.get("tableNameCase").toString(); + //entity + Template entityTemp = GeneratorTempUtils.getMybatisPlusTemp("entity.vm"); + FileWriter entityWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusDir("entity") + tbName + ".java"); + entityTemp.merge(context, entityWriter); + entityWriter.close(); + //controller + Template controllerTemp = GeneratorTempUtils.getMybatisPlusTemp("controller.vm"); + FileWriter controllerWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusDir("controller") + tbName + "Controller.java"); + controllerTemp.merge(context, controllerWriter); + controllerWriter.close(); + //service + Template serviceTemp = GeneratorTempUtils.getMybatisPlusTemp("service.vm"); + FileWriter serviceWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusDir("service") + tbName + "Service.java"); + serviceTemp.merge(context, serviceWriter); + serviceWriter.close(); + //mapper + Template mapperTemp = GeneratorTempUtils.getMybatisPlusTemp("mapper.vm"); + FileWriter mapperWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusDir("mapper") + tbName + "Mapper.java"); + mapperTemp.merge(context, mapperWriter); + mapperWriter.close(); + } catch (IOException e) { + throw new RuntimeException("Mybatis-plus单表生成模版报错" + e); + } + } + + /** + * element-plus多表生成模版 + */ + public void generatorElementPlusTemp(Map jsonData) { + try { + Context context = getContext(jsonData); + Template template = GeneratorTempUtils.getElementPlusTemp("CRUD.vm"); + FileWriter fileWriter = new FileWriter(GeneratorTempUtils.getExportElementPlusDir("") + "CRUD.vue"); + template.merge(context, fileWriter); + fileWriter.close(); + //第二个模板 + Template addModal = GeneratorTempUtils.getElementPlusTemp("CRUDForm.vm"); + FileWriter addModalWriter = new FileWriter(GeneratorTempUtils.getExportElementPlusDir("") + "CRUDForm.vue"); + addModal.merge(context, addModalWriter); + addModalWriter.close(); + } catch (IOException e) { + throw new RuntimeException("element-plus多表生成模版报错" + e); + } + } + + /** + * 生成后端模版 + * + * @param jsonData + * @return + */ + public String generatorBackTempZip(Map jsonData) { + Map commonConfig = JSON.parseObject(JSON.toJSONString(jsonData.get("commonConfig")), Map.class); + if ("true".equals(commonConfig.get("isTableMulChoose").toString())) { + //多表模版 + generatorMybatisPlusMulTemp(jsonData); + } else { + /*单表*/ + generatorMybatisPlusTemp(jsonData); + } + String exportFilePath = GeneratorTempUtils.getOutputZipPath() + ObjSelfUtils.getCurrentDateTimeTrim() + ".zip"; + //生成zip包 + GeneratorTempUtils.createZipFile(exportFilePath, GeneratorTempUtils.getNeedZipDir()); + return exportFilePath; + } + + /** + * 生成前端模版 + * + * @param jsonData + * @return + */ + public String generatorFrontTempZip(Map jsonData) { + Map commonConfig = JSON.parseObject(JSON.toJSONString(jsonData.get("commonConfig")), Map.class); + //多表 + if ("true".equals(commonConfig.get("isTableMulChoose").toString())) { + //生成前端模板 + generatorElementPlusTemp(jsonData); + } else { + /*单表*/ + //生成前端模板 + generatorElementPlusTemp(jsonData); + } + String exportFilePath = GeneratorTempUtils.getOutputZipPath() + ObjSelfUtils.getCurrentDateTimeTrim() + ".zip"; + GeneratorTempUtils.createZipFile(exportFilePath, GeneratorTempUtils.getNeedZipDir()); + return exportFilePath; + } + + /** + * 生成前后端模版 + * + * @param jsonData + * @return + */ + public String generatorFrontBackTempZip(Map jsonData) { + Map commonConfig = JSON.parseObject(JSON.toJSONString(jsonData.get("commonConfig")), Map.class); + //多表 + if ("true".equals(commonConfig.get("isTableMulChoose").toString())) { + //生成前端模板 + generatorElementPlusTemp(jsonData); + //生成后端模板 + generatorMybatisPlusMulTemp(jsonData); + } else { + /*单表*/ + //生成前端模板 + generatorElementPlusTemp(jsonData); + //生成后端模板 + generatorMybatisPlusTemp(jsonData); + } + + String exportFilePath = GeneratorTempUtils.getOutputZipPath() + ObjSelfUtils.getCurrentDateTimeTrim() + ".zip"; + //生成zip包 + GeneratorTempUtils.createZipFile(exportFilePath, GeneratorTempUtils.getNeedZipDir()); + return exportFilePath; + } + + + private Context getContext(Map jsonData) { + Context context = GeneratorTempUtils.getVelocityContext(); + context.put("totalData", jsonData); + context.put("projectOrAuthor", jsonData.get("projectOrAuthor")); + context.put("commonConfig", jsonData.get("commonConfig")); + context.put("multiTableConfig", jsonData.get("multiTableConfig")); + context.put("dbTableConfig", jsonData.get("dbTableConfig")); + context.put("apiConfig", jsonData.get("apiConfig")); + context.put("queryConfig", jsonData.get("queryConfig")); + context.put("tableConfig", jsonData.get("tableConfig")); + context.put("formConfig", jsonData.get("formConfig")); + return context; + } + +} diff --git a/basis-func/src/main/java/top/kuanghua/basisfunc/utils/GeneratorTempUtils.java b/basis-func/src/main/java/top/kuanghua/basisfunc/utils/GeneratorTempUtils.java new file mode 100644 index 0000000..799bb7d --- /dev/null +++ b/basis-func/src/main/java/top/kuanghua/basisfunc/utils/GeneratorTempUtils.java @@ -0,0 +1,353 @@ +package top.kuanghua.basisfunc.utils; + +import lombok.extern.log4j.Log4j2; +import net.lingala.zip4j.ZipFile; +import net.lingala.zip4j.exception.ZipException; +import org.apache.tomcat.util.http.fileupload.IOUtils; +import org.apache.velocity.Template; +import org.apache.velocity.app.VelocityEngine; +import org.apache.velocity.context.Context; +import org.apache.velocity.runtime.RuntimeConstants; +import org.apache.velocity.tools.ToolManager; +import org.springframework.util.StreamUtils; + +import javax.servlet.http.HttpServletResponse; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.nio.charset.StandardCharsets; +import java.util.UUID; + +/** + * @Title: FrontVmsUtils + * @Description: 前端模板生成工具类 + * @Auther: kuanghua + * @create 2022-05-17 13:57 + */ +@Log4j2 +public class GeneratorTempUtils { + //velocity tools配置文件路径 + public static final String ToolManagerConfigPath = "velocity-tools.xml"; + public static final String VelocityTemplateDir = "D:\\github\\velocity-tmp-dir\\"; + public static final String VelocityTemplateDirMac = "/deploy/velocity-tmp-dir/"; + public static final String ElementPlusDir = "front-vms" + File.separator + "element-plus"; + public static final String MybatisPlusDir = "back-vms" + File.separator + "mybatis-plus"; + public static final String MybatisPlusMulTbDir = "back-vms" + File.separator + "mybatis-plus-multb"; + + //win + public static final String ExportFileDir = "D:\\temp-dir\\export-dir\\"; + public static final String NeedZipDir = "D:\\temp-dir\\export-dir\\"; + public static final String OutputZipPath = "D:\\temp-dir\\"; + public static final String TmpSaveDir = "D:\\temp-dir\\"; + //mac和Linux + public static final String MacExportFileDir = "/tmp/export-dir/"; + public static final String MacNeedZipDir = "/tmp/export-dir/"; + public static final String MacOutputZipPath = "/tmp/"; + public static final String MacTmpSaveDir = "/tmp/"; + + /** + * @return + * @author 邝华 + * @date 2022-06-10 13:54 + */ + public static String getExportFileDir(String dir) { + String os = System.getProperty("os.name"); + String path = ""; + if (os.toLowerCase().startsWith("win")) { + path = ExportFileDir + dir + File.separator; + } else { + path = MacExportFileDir + dir + File.separator; + } + return fileMkdir(path); + } + + public static String getExportMybatisPlusMulDir(String dir) { + String os = System.getProperty("os.name"); + String path = ""; + if (os.toLowerCase().startsWith("win")) { + path = ExportFileDir + "mybatis-plus-mul" + File.separator + dir + File.separator; + } else { + path = MacExportFileDir + "mybatis-plus-mul" + File.separator + dir + File.separator; + } + return fileMkdir(path); + } + + public static String getExportMybatisPlusDir(String dir) { + String os = System.getProperty("os.name"); + String path = ""; + if (os.toLowerCase().startsWith("win")) { + path = ExportFileDir + "mybatis-plus" + File.separator + dir + File.separator; + } else { + path = MacExportFileDir + "mybatis-plus" + File.separator + dir + File.separator; + } + return fileMkdir(path); + } + + public static String getExportElementPlusDir(String dir) { + String os = System.getProperty("os.name"); + String path = ""; + if (os.toLowerCase().startsWith("win")) { + path = ExportFileDir + "element-plus" + File.separator + dir + File.separator; + } else { + path = MacExportFileDir + "element-plus" + File.separator + dir + File.separator; + } + return fileMkdir(path); + } + + /** + * @return + * @author 邝华 + * @date 2022-06-26 13:54 + */ + public static String getExportFileDir() { + String os = System.getProperty("os.name"); + String path = ""; + if (os.toLowerCase().startsWith("win")) { + path = ExportFileDir; + } else { + path = MacExportFileDir; + } + return fileMkdir(path); + } + + /** + * 获取临时存储目录路径 + * + * @return + * @author 邝华 + * @date 2022-06-10 13:54 + */ + public static String getTmpSaveDir() { + String os = System.getProperty("os.name"); + String path = ""; + String uuid = UUID.randomUUID().toString().replaceAll("-", ""); + if (os.toLowerCase().startsWith("win")) { + path = TmpSaveDir + uuid + File.separator; + } else { + path = MacTmpSaveDir + uuid + File.separator; + } + return fileMkdir(path); + } + + /** + * @return + * @author 邝华 + * @date 2022-06-10 13:53 + */ + public static String getNeedZipDir() { + String os = System.getProperty("os.name"); + String path = ""; + if (os.toLowerCase().startsWith("win")) { + path = NeedZipDir; + } else { + path = MacNeedZipDir; + } + return fileMkdir(path); + } + + /** + * @return + * @author 邝华 + * @date 2022-06-10 13:53 + */ + public static String getOutputZipPath() { + String os = System.getProperty("os.name"); + String path = ""; + if (os.toLowerCase().startsWith("win")) { + path = OutputZipPath; + } else { + path = MacOutputZipPath; + } + return fileMkdir(path); + } + + /** + * @return + * @author 邝华 + * @date 2022-06-10 13:56 + */ + public static String fileMkdir(String path) { + File file = new File(path); + if (!file.exists()) { + file.mkdirs(); + } + return path; + } + + + /** + * @return + * @author 邝华 + * @date 2022-06-10 13:56 + */ + public static String getTemplateDir(String dirPath) { + String os = System.getProperty("os.name"); + String path = ""; + if (os.toLowerCase().startsWith("win")) { + path = VelocityTemplateDir + dirPath; + } else { + path = VelocityTemplateDirMac + dirPath; + } + return fileMkdir(path); + } + + + /** + * @return velocity Context + */ + public static Context getVelocityContext() { + // 加载toolbox + ToolManager manager = new ToolManager(); + manager.configure(ToolManagerConfigPath); + return manager.createContext(); + } + + /** + * @param response + * @param exportFilePath 导出文件的路径 + */ + public static void downloadZip(HttpServletResponse response, String exportFilePath) { + File file = new File(exportFilePath); + if (!file.exists()) { + throw new RuntimeException("文件不存在"); + } + try { + ZipFile zipFile = new ZipFile(file); + InputStream fis = new FileInputStream(zipFile.getFile()); + IOUtils.copy(fis, response.getOutputStream()); + fis.close(); + } catch (Exception e) { + e.printStackTrace(); + } + log.info(exportFilePath + "被删除了"); + log.info(getNeedZipDir() + "被删除了"); + deleteFile(exportFilePath); + deleteDir(getNeedZipDir()); + } + + /** + * 删除导出后文件夹下的文件 + * + * @return + * @author 邝华 + * @email kuanghua@aulton.com + * @date 2022-06-10 14:13 + */ + public static void deleteDir(String path) { + File directory = new File(path); + deleteDeepDir(directory); + } + + public static void deleteDeepDir(File directory) { + //获取目录下所有文件和目录 + File files[] = directory.listFiles(); + for (File file : files) { + if (file.isDirectory()) { + deleteDeepDir(file); + } else { + file.delete(); + log.info(file.getName() + "::文件已删除"); + } + } + //最终把该目录也删除 + directory.delete(); + log.info(directory.getName() + "::目录已删除"); + } + + /** + * 删除文件 + * + * @param path 要删除的文件路径 + * @return + * @author 邝华 + * @email kuanghua@aulton.com + * @date 2022-06-13 11:22 + */ + public static void deleteFile(String path) { + File file = new File(path); + if (file.exists()) { + file.delete();//只有为空的文件夹才能执行true + } + } + + /** + * @param tempName 模板名称 + * @return Template + */ + public static Template getMybatisPlusTemp(String tempName) { + VelocityEngine ve = new VelocityEngine(); + ve.setProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, getTemplateDir(MybatisPlusDir)); + ve.init(); + return ve.getTemplate(tempName); + } + + /** + * @param tempName 模板名称 + * @return Template + */ + public static Template getTmpSaveDirTemp(String tmpSaveDir, String tempName) { + VelocityEngine ve = new VelocityEngine(); + ve.setProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, tmpSaveDir); + ve.init(); + return ve.getTemplate(tempName); + } + + /** + * @param tempName 模板名称 + * @return Template + */ + public static Template getMybatisPlusMulTbTemp(String tempName) { + VelocityEngine ve = new VelocityEngine(); + ve.setProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, getTemplateDir(MybatisPlusMulTbDir)); + ve.init(); + return ve.getTemplate(tempName); + } + + + /** + * @param tempName 模板名称 + * @return Template + */ + public static Template getElementPlusTemp(String tempName) { + VelocityEngine ve = new VelocityEngine(); + ve.setProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, getTemplateDir(ElementPlusDir)); + ve.init(); + return ve.getTemplate(tempName); + } +// +// /** +// * 获取JsonData下的目录路径 +// * +// * @return 得到的目录名称 +// */ +// public static String getJsonDataDirPath() { +// return ClassUtils.getDefaultClassLoader().getResource("json-data").getPath() + File.separator; +// } + + /** + * @param filePath 相对于resource的路径 + * @return 读取的文件内容 + * @throws IOException + */ + public static String readFileToString(String filePath) throws IOException { + FileInputStream fileInputStream = new FileInputStream(new File(filePath)); +// ClassPathResource classPathResource = new ClassPathResource(filePath); +// InputStream inputStream = classPathResource.getInputStream(); + String s = StreamUtils.copyToString(fileInputStream, StandardCharsets.UTF_8); + fileInputStream.close(); + return s; + } + + /** + * @param outputZipPath 导出zip包的路径 如 file://xxx.zip + * @param needZipDir 需要压缩的目录名字 如 file://doc + */ + public static void createZipFile(String outputZipPath, String needZipDir) { + try { + new ZipFile(outputZipPath).addFolder(new File(needZipDir)); + } catch (ZipException e) { + throw new RuntimeException("压缩文件夹报错" + e); + } + } +} diff --git a/basis-func/src/main/resources/application-db.yml b/basis-func/src/main/resources/application-db.yml new file mode 100644 index 0000000..842d8ed --- /dev/null +++ b/basis-func/src/main/resources/application-db.yml @@ -0,0 +1,39 @@ +spring: + datasource: + driver-class-name: com.p6spy.engine.spy.P6SpyDriver + url: jdbc:p6spy:mysql://${envpt.mysqlIp}:${envpt.mysqlPort}/micro-service-plus?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8&useSSL=false + username: root + password: root123 + hikari: + max-lifetime: 28830000 # 一个连接的生命时长(毫秒),超时而且没被使用则被释放(retired),缺省:30分钟,建议设置比数据库超时时长少30秒,参考MySQL wait_timeout参数(show variables like '%timeout%';) + maximum-pool-size: 9 # 连接池中允许的最大连接数。缺省值:10;推荐的公式:((core_count * 2) + effective_spindle_count) + +mybatis-plus: + mapper-locations: classpath:/mapper/*Mapper.xml + #实体扫描,多个package用逗号或者分号分隔 + #typeAliasesPackage: top.kuanghua.tyuser.entity + #typeEnumsPackage: com.baomidou.springboot.entity.enums + global-config: + #刷新mapper 调试神器 + db-config: + #主键类型 0:"数据库ID自增", 1:"用户输入ID",2:"全局唯一ID (数字类型唯一ID)", 3:"全局唯一ID UUID"; + id-type: AUTO + #字段策略 0:"忽略判断",1:"非 NULL 判断"),2:"非空判断" + field-strategy: not_empty + #驼峰下划线转换 + column-underline: true + #数据库大写下划线转换 + #capital-mode: true + #逻辑删除配置 + logic-delete-field: deleted # 逻辑已删除值(默认为 1) + logic-delete-value: 1 # 逻辑已删除值(默认为 1) + logic-not-delete-value: 0 # 逻辑未删除值(默认为 0) + db-type: mysql + refresh: true + #自定义填充策略接口实现 + #meta-object-handler: com.baomidou.springboot.xxx + #自定义SQL注入器 + sql-injector: com.baomidou.mybatisplus.extension.injector.methods.LogicDeleteByIdWithFill + configuration: + map-underscore-to-camel-case: true + cache-enabled: false \ No newline at end of file diff --git a/basis-func/src/main/resources/application.yml b/basis-func/src/main/resources/application.yml new file mode 100644 index 0000000..7b0a0f2 --- /dev/null +++ b/basis-func/src/main/resources/application.yml @@ -0,0 +1,2 @@ +server: + port: ${envpt.tomcatPortPre}0121 \ No newline at end of file diff --git a/basis-func/src/main/resources/bootstrap.yml b/basis-func/src/main/resources/bootstrap.yml new file mode 100644 index 0000000..f38cf92 --- /dev/null +++ b/basis-func/src/main/resources/bootstrap.yml @@ -0,0 +1,15 @@ +spring: + application: + name: @project.artifactId@ + profiles: + active: @activatedProperties@,main,db + cloud: + nacos: + discovery: + namespace: @nacosNamespace@ + group: @nacosGroup@ + username: @nacosUsername@ + password: @nacosPassword@ + server-addr: @nacosIpPort@ + weight: @nacosWeight@ + diff --git a/basis-func/src/main/resources/mapper/RepairInfoMapper.xml b/basis-func/src/main/resources/mapper/RepairInfoMapper.xml new file mode 100644 index 0000000..962b471 --- /dev/null +++ b/basis-func/src/main/resources/mapper/RepairInfoMapper.xml @@ -0,0 +1,69 @@ + + + + + + + + + rp + . + sn + ,rp.equip_type, rp.replacement_id, rp.express_id, rp.problem_classification_id + ,rp.current_status, rp.problem_description, + rp.feedback_time, rp.proposer, rp.contact_info, rp.recovery_date, + rp.return_date, rp.problems_analyzed, rp.reason, rp.processing_method, rp.remarks, + rm.new_sn_id + + + + + + + \ No newline at end of file diff --git a/basis-func/src/main/resources/velocity-tools.xml b/basis-func/src/main/resources/velocity-tools.xml new file mode 100644 index 0000000..891958c --- /dev/null +++ b/basis-func/src/main/resources/velocity-tools.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/basis-func/src/test/java/top/kuanghua/basisfunc/service/GeneratorServiceTest.java b/basis-func/src/test/java/top/kuanghua/basisfunc/service/GeneratorServiceTest.java new file mode 100644 index 0000000..4e5b939 --- /dev/null +++ b/basis-func/src/test/java/top/kuanghua/basisfunc/service/GeneratorServiceTest.java @@ -0,0 +1,180 @@ +package top.kuanghua.basisfunc.service; + +import com.alibaba.fastjson.JSON; +import org.apache.velocity.Template; +import org.apache.velocity.context.Context; +import org.junit.jupiter.api.Test; +import top.kuanghua.basisfunc.utils.GeneratorTempUtils; +import top.kuanghua.commonpom.utils.ObjSelfUtils; + +import java.io.FileWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Map; + +/** + * @Title: BackVmsMulTableServiceTest + * @Description: + * @Auther: kuanghua + * @create 2022/6/26 11:11 + */ +public class GeneratorServiceTest { + + /** + * mybatis-plus多表生成模版 + */ + @Test + public void generatorMybatisPlusMulTemp() throws IOException { + String string = GeneratorTempUtils.readFileToString("D:\\github\\velocity-tmp-dir\\json-data\\" + "multiTableData.json"); + Map jsonData = JSON.parseObject(string, Map.class); + Context context = GeneratorTempUtils.getVelocityContext(); + context.put("totalData", jsonData); + context.put("projectOrAuthor", jsonData.get("projectOrAuthor")); + context.put("multiTableConfig", jsonData.get("multiTableConfig")); + context.put("queryConfig", jsonData.get("queryConfig")); + context.put("tableConfig", jsonData.get("tableConfig")); + context.put("formConfig", jsonData.get("formConfig")); + context.put("dbTableConfig", jsonData.get("dbTableConfig")); + + Map dbTableConfig = ObjSelfUtils.changeToMap(jsonData.get("dbTableConfig")); + ArrayList> multiTableConfig = ObjSelfUtils.changeToArrayMap(jsonData.get("multiTableConfig")); + + multiTableConfig.forEach((fItem) -> { + //entity + FileWriter entityWriter = null; + try { + Template entityTemp = GeneratorTempUtils.getMybatisPlusMulTbTemp("entity.vm"); + context.put("currentTbConfig", fItem); + context.put("tableFieldArr", fItem.get("tableFieldArr")); + entityWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusMulDir("entity") + fItem.get("tableNameCase") + ".java"); + entityTemp.merge(context, entityWriter); + entityWriter.close(); + + //single-mapper + Template mapperTemp = GeneratorTempUtils.getMybatisPlusMulTbTemp("mapper.vm"); + FileWriter mapperWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusMulDir("mapper") + fItem.get("tableNameCase") + "Mapper.java"); + mapperTemp.merge(context, mapperWriter); + mapperWriter.close(); + } catch (IOException e) { + throw new RuntimeException("生成实体类报错" + e); + } + }); + String tbName = dbTableConfig.get("multiTableNameCase").toString(); + + try { + //controller + Template controllerTemp = GeneratorTempUtils.getMybatisPlusMulTbTemp("controllerMul.vm"); + FileWriter controllerWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusMulDir("controller") + tbName + "Controller.java"); + controllerTemp.merge(context, controllerWriter); + controllerWriter.close(); + //service + Template serviceTemp = GeneratorTempUtils.getMybatisPlusMulTbTemp("serviceMul.vm"); + FileWriter serviceWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusMulDir("service") + tbName + "Service.java"); + serviceTemp.merge(context, serviceWriter); + serviceWriter.close(); + + //mul-entity + Template mapperMulTemp = GeneratorTempUtils.getMybatisPlusMulTbTemp("mapperMul.vm"); + FileWriter mapperMulWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusMulDir("mapper") + tbName + "Mapper.java"); + mapperMulTemp.merge(context, mapperMulWriter); + mapperMulWriter.close(); + + //entity-vo + Template entityVoTemp = GeneratorTempUtils.getMybatisPlusMulTbTemp("entityVo.vm"); + FileWriter entityVoWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusMulDir("vo") + tbName + "Vo.java"); + entityVoTemp.merge(context, entityVoWriter); + entityVoWriter.close(); + + //entity-mul + Template entityMulTemp = GeneratorTempUtils.getMybatisPlusMulTbTemp("entityMul.vm"); + FileWriter entityMulWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusMulDir("entity") + tbName + ".java"); + entityMulTemp.merge(context, entityMulWriter); + entityMulWriter.close(); + //xml + Template xmlTemp = GeneratorTempUtils.getMybatisPlusMulTbTemp("xmlMul.vm"); + FileWriter xmlWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusMulDir("xml") + tbName + "Mapper.xml"); + xmlTemp.merge(context, xmlWriter); + xmlWriter.close(); + + String exportFilePath = GeneratorTempUtils.getOutputZipPath() + ObjSelfUtils.getCurrentDateTimeTrim() + ".zip"; + //生成zip包 + GeneratorTempUtils.createZipFile(exportFilePath, GeneratorTempUtils.getNeedZipDir()); + + } catch (IOException e) { + throw new RuntimeException("生成实体类报错" + e); + } + } + + /** + * element-plus单表生成模版 + */ + @Test + public void generatorMybatisPlusTemp() throws IOException { + String string = GeneratorTempUtils.readFileToString("D:\\github\\velocity-tmp-dir\\json-data\\" + "tb_brand.json"); + Map jsonData = JSON.parseObject(string, Map.class); + + Context context = GeneratorTempUtils.getVelocityContext(); + context.put("configData", jsonData); + context.put("projectOrAuthor", jsonData.get("projectOrAuthor")); + context.put("dbTableConfig", jsonData.get("dbTableConfig")); + context.put("apiConfig", jsonData.get("apiConfig")); + context.put("queryConfig", jsonData.get("queryConfig")); + context.put("tableConfig", jsonData.get("tableConfig")); + context.put("formConfig", jsonData.get("formConfig")); + context.put("commonConfig", jsonData.get("commonConfig")); + + + Map dbTableConfig = JSON.parseObject(JSON.toJSONString(jsonData.get("dbTableConfig")), Map.class); + + String tbName = dbTableConfig.get("tableNameCase").toString(); + //entity + Template entityTemp = GeneratorTempUtils.getMybatisPlusTemp("entity.vm"); + FileWriter entityWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusDir("entity") + tbName + ".java"); + entityTemp.merge(context, entityWriter); + entityWriter.close(); + //controller + Template controllerTemp = GeneratorTempUtils.getMybatisPlusTemp("controller.vm"); + FileWriter controllerWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusDir("controller") + tbName + "Controller.java"); + controllerTemp.merge(context, controllerWriter); + controllerWriter.close(); + //service + Template serviceTemp = GeneratorTempUtils.getMybatisPlusTemp("service.vm"); + FileWriter serviceWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusDir("service") + tbName + "Service.java"); + serviceTemp.merge(context, serviceWriter); + serviceWriter.close(); + //mapper + Template mapperTemp = GeneratorTempUtils.getMybatisPlusTemp("mapper.vm"); + FileWriter mapperWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusDir("mapper") + tbName + "Mapper.java"); + mapperTemp.merge(context, mapperWriter); + mapperWriter.close(); + } + + + /** + * element-plus多表生成模版 + */ + @Test + public void generatorElementPlusTemp() throws IOException { + String string = GeneratorTempUtils.readFileToString("D:\\github\\velocity-tmp-dir\\json-data\\" + "tb_brand.json"); + Map jsonData = JSON.parseObject(string, Map.class); + Context context = GeneratorTempUtils.getVelocityContext(); + context.put("configData", jsonData); + context.put("companyOrAuthor", jsonData.get("companyOrAuthor")); + context.put("dbTableConfig", jsonData.get("dbTableConfig")); + context.put("apiConfig", jsonData.get("apiConfig")); + context.put("queryConfig", jsonData.get("queryConfig")); + context.put("tableConfig", jsonData.get("tableConfig")); + context.put("formConfig", jsonData.get("formConfig")); + context.put("commonConfig", jsonData.get("commonConfig")); + Template template = GeneratorTempUtils.getElementPlusTemp("CRUD.vm"); + FileWriter fileWriter = new FileWriter(GeneratorTempUtils.getExportElementPlusDir("") + "CRUD.vue"); + template.merge(context, fileWriter); + fileWriter.close(); + //第二个模板 + Template addModal = GeneratorTempUtils.getElementPlusTemp("CRUDForm.vm"); + FileWriter addModalWriter = new FileWriter(GeneratorTempUtils.getExportElementPlusDir("") + "CRUDForm.vue"); + addModal.merge(context, addModalWriter); + addModalWriter.close(); + } + +} \ No newline at end of file diff --git a/common-pom/pom.xml b/common-pom/pom.xml new file mode 100644 index 0000000..77f1901 --- /dev/null +++ b/common-pom/pom.xml @@ -0,0 +1,78 @@ + + + + micro-service-plus + top.kuanghua + 1.0-SNAPSHOT + + 4.0.0 + + common-pom + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-validation + + + + + + + org.springframework.cloud + spring-cloud-starter-openfeign + + + org.springframework.cloud + spring-cloud-starter-loadbalancer + + + com.github.ben-manes.caffeine + caffeine + 2.6.2 + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-discovery + + + org.springframework.cloud + spring-cloud-starter-netflix-ribbon + + + + + + mysql + mysql-connector-java + + + + com.baomidou + mybatis-plus-boot-starter + 3.3.2 + + + p6spy + p6spy + 3.9.1 + + + + org.springframework.boot + spring-boot-starter-data-redis + + + + com.github.xiaoymin + knife4j-spring-boot-starter + 2.0.9 + + + \ No newline at end of file diff --git a/ty-common/src/main/java/top/kuanghua/feign/config/FeignConfiguration.java b/common-pom/src/main/java/top/kuanghua/commonpom/config/FeignConfiguration.java similarity index 89% rename from ty-common/src/main/java/top/kuanghua/feign/config/FeignConfiguration.java rename to common-pom/src/main/java/top/kuanghua/commonpom/config/FeignConfiguration.java index 80eac4d..140bf3e 100644 --- a/ty-common/src/main/java/top/kuanghua/feign/config/FeignConfiguration.java +++ b/common-pom/src/main/java/top/kuanghua/commonpom/config/FeignConfiguration.java @@ -1,4 +1,4 @@ -package top.kuanghua.feign.config; +package top.kuanghua.commonpom.config; import feign.RequestInterceptor; import feign.RequestTemplate; @@ -27,7 +27,9 @@ public void apply(RequestTemplate template) { while (headerNames.hasMoreElements()) { String name = headerNames.nextElement(); String values = request.getHeader(name); - + if (name.equals("content-length")){ + continue; + } template.header(name, values); } } diff --git a/ty-common/src/main/java/top/kuanghua/khcomomon/config/MetaObjectHandlerConfig.java b/common-pom/src/main/java/top/kuanghua/commonpom/config/MetaObjectHandlerConfig.java similarity index 95% rename from ty-common/src/main/java/top/kuanghua/khcomomon/config/MetaObjectHandlerConfig.java rename to common-pom/src/main/java/top/kuanghua/commonpom/config/MetaObjectHandlerConfig.java index 6c6dce1..24a9a8c 100644 --- a/ty-common/src/main/java/top/kuanghua/khcomomon/config/MetaObjectHandlerConfig.java +++ b/common-pom/src/main/java/top/kuanghua/commonpom/config/MetaObjectHandlerConfig.java @@ -1,4 +1,4 @@ -package top.kuanghua.khcomomon.config; +package top.kuanghua.commonpom.config; import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler; import lombok.extern.slf4j.Slf4j; diff --git a/ty-common/src/main/java/top/kuanghua/khcomomon/config/MybatisPlusConfig.java b/common-pom/src/main/java/top/kuanghua/commonpom/config/MybatisPlusConfig.java similarity index 97% rename from ty-common/src/main/java/top/kuanghua/khcomomon/config/MybatisPlusConfig.java rename to common-pom/src/main/java/top/kuanghua/commonpom/config/MybatisPlusConfig.java index 5378349..e675026 100644 --- a/ty-common/src/main/java/top/kuanghua/khcomomon/config/MybatisPlusConfig.java +++ b/common-pom/src/main/java/top/kuanghua/commonpom/config/MybatisPlusConfig.java @@ -1,5 +1,4 @@ -package top.kuanghua.khcomomon.config; - +package top.kuanghua.commonpom.config; import com.baomidou.mybatisplus.autoconfigure.ConfigurationCustomizer; import com.baomidou.mybatisplus.extension.MybatisMapWrapperFactory; @@ -44,7 +43,7 @@ public OptimisticLockerInterceptor optimisticLockerInterceptor() { /*map转驼峰*/ @Bean - public ConfigurationCustomizer mybatisConfigurationCustomizer(){ + public ConfigurationCustomizer mybatisConfigurationCustomizer() { return new ConfigurationCustomizer() { @Override public void customize(org.apache.ibatis.session.Configuration configuration) { @@ -54,5 +53,4 @@ public void customize(org.apache.ibatis.session.Configuration configuration) { } - } diff --git a/ty-common/src/main/java/top/kuanghua/khcomomon/entity/KHCommonPageParams.java b/common-pom/src/main/java/top/kuanghua/commonpom/entity/CommonPageParams.java similarity index 68% rename from ty-common/src/main/java/top/kuanghua/khcomomon/entity/KHCommonPageParams.java rename to common-pom/src/main/java/top/kuanghua/commonpom/entity/CommonPageParams.java index 93859f2..866b997 100644 --- a/ty-common/src/main/java/top/kuanghua/khcomomon/entity/KHCommonPageParams.java +++ b/common-pom/src/main/java/top/kuanghua/commonpom/entity/CommonPageParams.java @@ -1,4 +1,4 @@ -package top.kuanghua.khcomomon.entity; +package top.kuanghua.commonpom.entity; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -12,24 +12,26 @@ */ @Data @ApiModel -public class KHCommonPageParams { +public class CommonPageParams { @ApiModelProperty("页数") - private Integer pageSize; + private Integer pageSize; @ApiModelProperty("页码") - private Integer pageNum; + private Integer pageNum; + public Integer getPageSize() { - if(pageSize ==null ){ + if (pageSize == null) { return 10; - }else{ + } else { return pageSize; } } + public Integer getPageNum() { - if(pageSize ==null){ + if (pageSize == null) { return 1; - }else{ + } else { return pageNum; } } diff --git a/ty-common/src/main/java/top/kuanghua/khcomomon/entity/PageResult.java b/common-pom/src/main/java/top/kuanghua/commonpom/entity/PageResult.java similarity index 93% rename from ty-common/src/main/java/top/kuanghua/khcomomon/entity/PageResult.java rename to common-pom/src/main/java/top/kuanghua/commonpom/entity/PageResult.java index 17f2f1f..67f169a 100644 --- a/ty-common/src/main/java/top/kuanghua/khcomomon/entity/PageResult.java +++ b/common-pom/src/main/java/top/kuanghua/commonpom/entity/PageResult.java @@ -1,4 +1,4 @@ -package top.kuanghua.khcomomon.entity; +package top.kuanghua.commonpom.entity; import java.util.List; diff --git a/ty-common/src/main/java/top/kuanghua/khcomomon/entity/ResResult.java b/common-pom/src/main/java/top/kuanghua/commonpom/entity/ResResult.java similarity index 69% rename from ty-common/src/main/java/top/kuanghua/khcomomon/entity/ResResult.java rename to common-pom/src/main/java/top/kuanghua/commonpom/entity/ResResult.java index 082ab6a..1b71683 100644 --- a/ty-common/src/main/java/top/kuanghua/khcomomon/entity/ResResult.java +++ b/common-pom/src/main/java/top/kuanghua/commonpom/entity/ResResult.java @@ -1,4 +1,4 @@ -package top.kuanghua.khcomomon.entity; +package top.kuanghua.commonpom.entity; import lombok.AllArgsConstructor; import lombok.Data; @@ -22,30 +22,30 @@ public class ResResult implements Serializable { private String msg;//返回消息 private T data;//返回数据 - public ResResult success(Object data) { + public ResResult success(Object data) { this.flag = true; - this.code = StatusCode.OK; + this.code = top.kuanghua.commonpom.entity.StatusCode.OK; this.data = (T) data; return this; } - public ResResult success() { + public ResResult success() { this.flag = true; - this.code = StatusCode.OK; + this.code = top.kuanghua.commonpom.entity.StatusCode.OK; this.msg = "操作成功!"; return this; } - public ResResult error(String msg) { + public ResResult error(String msg) { this.flag = false; - this.code = StatusCode.ERROR; + this.code = top.kuanghua.commonpom.entity.StatusCode.ERROR; this.msg = msg; return this; } public ResResult(String msg, Object data) { this.flag = true; - this.code = StatusCode.OK; + this.code = top.kuanghua.commonpom.entity.StatusCode.OK; this.msg = msg; this.data = (T) data; } @@ -58,7 +58,7 @@ public ResResult(boolean flag, Integer code, String msg) { public ResResult() { this.flag = true; - this.code = StatusCode.OK; + this.code = top.kuanghua.commonpom.entity.StatusCode.OK; this.msg = "操作成功!"; } diff --git a/ty-common/src/main/java/top/kuanghua/khcomomon/entity/KHCommonParams.java b/common-pom/src/main/java/top/kuanghua/commonpom/entity/SelfCommonParams.java similarity index 62% rename from ty-common/src/main/java/top/kuanghua/khcomomon/entity/KHCommonParams.java rename to common-pom/src/main/java/top/kuanghua/commonpom/entity/SelfCommonParams.java index fbbad77..6625c78 100644 --- a/ty-common/src/main/java/top/kuanghua/khcomomon/entity/KHCommonParams.java +++ b/common-pom/src/main/java/top/kuanghua/commonpom/entity/SelfCommonParams.java @@ -1,4 +1,4 @@ -package top.kuanghua.khcomomon.entity; +package top.kuanghua.commonpom.entity; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -12,9 +12,9 @@ */ @Data @ApiModel -public class KHCommonParams extends KHCommonPageParams{ +public class SelfCommonParams extends top.kuanghua.commonpom.entity.CommonPageParams { @ApiModelProperty("开始时间") - private String startTime; + private String startTime; @ApiModelProperty("结束时间") - private String endTime; + private String endTime; } diff --git a/ty-common/src/main/java/top/kuanghua/khcomomon/entity/StatusCode.java b/common-pom/src/main/java/top/kuanghua/commonpom/entity/StatusCode.java similarity index 92% rename from ty-common/src/main/java/top/kuanghua/khcomomon/entity/StatusCode.java rename to common-pom/src/main/java/top/kuanghua/commonpom/entity/StatusCode.java index 587a48f..4c63336 100644 --- a/ty-common/src/main/java/top/kuanghua/khcomomon/entity/StatusCode.java +++ b/common-pom/src/main/java/top/kuanghua/commonpom/entity/StatusCode.java @@ -1,4 +1,4 @@ -package top.kuanghua.khcomomon.entity; +package top.kuanghua.commonpom.entity; /** * 返回码 diff --git a/ty-common/src/main/java/top/kuanghua/khcomomon/exception/BaseExceptionHandler.java b/common-pom/src/main/java/top/kuanghua/commonpom/exception/BaseExceptionHandler.java similarity index 80% rename from ty-common/src/main/java/top/kuanghua/khcomomon/exception/BaseExceptionHandler.java rename to common-pom/src/main/java/top/kuanghua/commonpom/exception/BaseExceptionHandler.java index da5ad7c..ea0552f 100644 --- a/ty-common/src/main/java/top/kuanghua/khcomomon/exception/BaseExceptionHandler.java +++ b/common-pom/src/main/java/top/kuanghua/commonpom/exception/BaseExceptionHandler.java @@ -1,14 +1,14 @@ -package top.kuanghua.khcomomon.exception; +package top.kuanghua.commonpom.exception; import org.springframework.validation.ObjectError; import org.springframework.web.bind.MethodArgumentNotValidException; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.RestControllerAdvice; -import top.kuanghua.khcomomon.entity.ResResult; +import top.kuanghua.commonpom.entity.ResResult; /* -* 全局异常处理 -* */ + * 全局异常处理 + * */ @RestControllerAdvice public class BaseExceptionHandler { /*** @@ -19,8 +19,9 @@ public class BaseExceptionHandler { @ExceptionHandler(MethodArgumentNotValidException.class) public ResResult MethodArgumentNotValidExceptionHandler(MethodArgumentNotValidException e) { ObjectError objectError = e.getBindingResult().getAllErrors().get(0); - return new ResResult().error(objectError.getDefaultMessage()); + return new ResResult().error(objectError.getDefaultMessage()); } + @ExceptionHandler(value = Exception.class) public ResResult error(Exception e) { e.printStackTrace(); diff --git a/common-pom/src/main/java/top/kuanghua/commonpom/feign/tyauth/TokenFeign.java b/common-pom/src/main/java/top/kuanghua/commonpom/feign/tyauth/TokenFeign.java new file mode 100644 index 0000000..42b93fa --- /dev/null +++ b/common-pom/src/main/java/top/kuanghua/commonpom/feign/tyauth/TokenFeign.java @@ -0,0 +1,43 @@ +//package top.kuanghua.commonpom.feign.tyauth; +// +//import org.springframework.cloud.openfeign.FeignClient; +//import org.springframework.web.bind.annotation.PostMapping; +//import org.springframework.web.bind.annotation.RequestBody; +//import org.springframework.web.bind.annotation.RequestParam; +//import top.kuanghua.commonpom.config.FeignConfiguration; +//import top.kuanghua.commonpom.entity.ResResult; +// +//import java.util.Map; +// +///** +// * @Title: TokenController +// * @Description: +// * @Auther: kuanghua +// * @create 2021/1/31 16:31 +// */ +// +// +////FeignConfiguration.class -> forward req params of include the token +//@FeignClient(name="ty-auth",configuration = FeignConfiguration.class,path = "token") +//public interface TokenFeign { +// +// /* +// * parse token +// * */ +// @PostMapping("parseToken") +// ResResult parseToken(@RequestParam("jwtToken") String jwtToken); +// +// /* +// * create token +// * */ +// @PostMapping("generateToken") +// ResResult generateToken(@RequestBody Map map); +// +// /* +// * update token +// * */ +// @PostMapping("updateToken") +// ResResult updateToken(@RequestBody Map map); +//} +// +// diff --git a/common-pom/src/main/java/top/kuanghua/commonpom/utils/ObjSelfUtils.java b/common-pom/src/main/java/top/kuanghua/commonpom/utils/ObjSelfUtils.java new file mode 100644 index 0000000..2c0689b --- /dev/null +++ b/common-pom/src/main/java/top/kuanghua/commonpom/utils/ObjSelfUtils.java @@ -0,0 +1,178 @@ +package top.kuanghua.commonpom.utils; + +import com.alibaba.fastjson.JSON; +import org.apache.commons.lang3.StringUtils; +import org.springframework.web.multipart.MultipartFile; +import top.kuanghua.commonpom.entity.ResResult; + +import java.io.File; +import java.lang.reflect.Array; +import java.text.SimpleDateFormat; +import java.util.*; + +/** + * 从jwt解析得到的数据是Object类型,转换为具体类型可能出现空指针, + * 这个工具类进行了一些转换 + */ +public class ObjSelfUtils { + /*类型转换*/ + public static String toString(Object obj) { + if (obj == null) { + return null; + } + return obj.toString(); + } + + public static Long toLong(Object obj) { + if (obj == null) { + return 0L; + } + if (obj instanceof Double || obj instanceof Float) { + return Long.valueOf(StringUtils.substringBefore(obj.toString(), ".")); + } + if (obj instanceof Number) { + return Long.valueOf(obj.toString()); + } + if (obj instanceof String) { + return Long.valueOf(obj.toString()); + } else { + return 0L; + } + } + + public static Integer toInt(Object obj) { + return toLong(obj).intValue(); + } + + /*非空判断*/ + public static boolean isNotEmpty(Object obj) { + return !isEmpty(obj); + } + + public static boolean isEmpty(Object obj) { + if (obj == null) { + return true; + } else if (obj.getClass().isArray()) { + return Array.getLength(obj) == 0; + } else if (obj instanceof CharSequence) { + return ((CharSequence) obj).length() == 0; + } else if (obj instanceof Collection) { + return ((Collection) obj).isEmpty(); + } else { + return obj instanceof Map ? ((Map) obj).isEmpty() : false; + } + } + + //解析请求数据 + public static ResResult parseRes(Object resResult) { + ResResult res = JSON.parseObject(JSON.toJSONString(resResult), ResResult.class); + return res; + } + + //解析请求数据到data + public static Map parseResToData(Object result) { + ResResult resResult = parseRes(result); + if (resResult.isFlag()) { + return JSON.parseObject(JSON.toJSONString(resResult.getData()), Map.class); + } else { + throw new RuntimeException(resResult.getMsg()); + } + } + + //解析请求数据到data + public static Map parseResToMap(ResResult resResult) { + if (resResult.isFlag()) { + return JSON.parseObject(JSON.toJSONString(resResult.getData()), Map.class); + } else { + throw new RuntimeException(resResult.getMsg()); + } + } + + public static List parseResToList(ResResult resResult) { + if (resResult.isFlag()) { + return JSON.parseObject(JSON.toJSONString(resResult.getData()), List.class); + } else { + throw new RuntimeException(resResult.getMsg()); + } + } + + //将一般的数据转化为map + public static Map changeToMap(Object resResult) { + return JSON.parseObject(JSON.toJSONString(resResult), Map.class); + } + + /** + * 将Object数据转化为 ArrayList + * + * @param resResult + * @return + */ + public static ArrayList> changeToArrayMap(Object resResult) { + return JSON.parseObject(JSON.toJSONString(resResult), ArrayList.class); + } + + public static ArrayList changeToArrayString(Object resResult) { + return JSON.parseObject(JSON.toJSONString(resResult), ArrayList.class); + } + + public static ArrayList changeToArrayInteger(Object resResult) { + return JSON.parseObject(JSON.toJSONString(resResult), ArrayList.class); + } + + /** + * @return 时间年月日 + */ + public static String getCurrentDateTimeTrim() { + SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmss");//设置日期格式 + return df.format(new Date()); + } + + /** + * @return 时间年月日 + */ + public static String getCurrentDateTime() { + SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格式 + return df.format(new Date()); + } + + /** + * @return 当前年月 + */ + public static String getCurrentDate() { + SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");//设置日期格式 + return df.format(new Date()); + } + + /** + * @param date + * @return + */ + public static String formatDateTime(Date date) { + SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格式 + return df.format(date); + } + + + /** + * MultipartFile change to file + * + * @param multiFile + * @return + */ + public static File MultipartFileToFile(MultipartFile multiFile) { + // 获取文件名 + String fileName = multiFile.getOriginalFilename(); + // 获取文件后缀 + String prefix = fileName.substring(fileName.lastIndexOf(".")); + // 若须要防止生成的临时文件重复,能够在文件名后添加随机码 + + try { + File file = File.createTempFile(fileName, prefix); + multiFile.transferTo(file); + return file; + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } +} \ No newline at end of file diff --git a/ty-common/src/main/java/top/kuanghua/khcomomon/utils/ObjectUtilsSelf.java b/common-pom/src/main/java/top/kuanghua/commonpom/utils/SelfObjUtils.java similarity index 64% rename from ty-common/src/main/java/top/kuanghua/khcomomon/utils/ObjectUtilsSelf.java rename to common-pom/src/main/java/top/kuanghua/commonpom/utils/SelfObjUtils.java index b8422c0..45375ad 100644 --- a/ty-common/src/main/java/top/kuanghua/khcomomon/utils/ObjectUtilsSelf.java +++ b/common-pom/src/main/java/top/kuanghua/commonpom/utils/SelfObjUtils.java @@ -1,23 +1,20 @@ -package top.kuanghua.khcomomon.utils; +package top.kuanghua.commonpom.utils; import com.alibaba.fastjson.JSON; import org.apache.commons.lang3.StringUtils; import org.springframework.web.multipart.MultipartFile; -import top.kuanghua.khcomomon.entity.ResResult; +import top.kuanghua.commonpom.entity.ResResult; import java.io.File; import java.lang.reflect.Array; import java.text.SimpleDateFormat; -import java.util.Collection; -import java.util.Date; -import java.util.List; -import java.util.Map; +import java.util.*; /** * 从jwt解析得到的数据是Object类型,转换为具体类型可能出现空指针, * 这个工具类进行了一些转换 */ -public class ObjectUtilsSelf { +public class SelfObjUtils { /*类型转换*/ public static String toString(Object obj) { if (obj == null) { @@ -58,53 +55,81 @@ public static boolean isEmpty(Object obj) { } else if (obj.getClass().isArray()) { return Array.getLength(obj) == 0; } else if (obj instanceof CharSequence) { - return ((CharSequence)obj).length() == 0; + return ((CharSequence) obj).length() == 0; } else if (obj instanceof Collection) { - return ((Collection)obj).isEmpty(); + return ((Collection) obj).isEmpty(); } else { - return obj instanceof Map ? ((Map)obj).isEmpty() : false; + return obj instanceof Map ? ((Map) obj).isEmpty() : false; } } //解析请求数据 - public static ResResult parseRes(Object resResult){ + public static ResResult parseRes(Object resResult) { ResResult res = JSON.parseObject(JSON.toJSONString(resResult), ResResult.class); return res; } + //解析请求数据到data - public static Map parseResToData(Object result){ + public static Map parseResToData(Object result) { ResResult resResult = parseRes(result); if (resResult.isFlag()) { return JSON.parseObject(JSON.toJSONString(resResult.getData()), Map.class); - }else{ - throw new RuntimeException(resResult.getMsg()); + } else { + throw new RuntimeException(resResult.getMsg()); } } + //解析请求数据到data - public static Map parseResToMap(ResResult resResult){ + public static Map parseResToMap(ResResult resResult) { if (resResult.isFlag()) { return JSON.parseObject(JSON.toJSONString(resResult.getData()), Map.class); - }else{ - throw new RuntimeException(resResult.getMsg()); + } else { + throw new RuntimeException(resResult.getMsg()); } } - public static List parseResToList(ResResult resResult){ + + public static List parseResToList(ResResult resResult) { if (resResult.isFlag()) { return JSON.parseObject(JSON.toJSONString(resResult.getData()), List.class); - }else{ - throw new RuntimeException(resResult.getMsg()); + } else { + throw new RuntimeException(resResult.getMsg()); } } + //将一般的数据转化为map - public static Map changeToMap(Object resResult){ - Map res = JSON.parseObject(JSON.toJSONString(resResult), Map.class); - return res; + public static Map changeToMap(Object resResult) { + return JSON.parseObject(JSON.toJSONString(resResult), Map.class); + } + + /** + * 将Object数据转化为 ArrayList + * + * @param resResult + * @return + */ + public static ArrayList> changeToArrayMap(Object resResult) { + return JSON.parseObject(JSON.toJSONString(resResult), ArrayList.class); + } + + public static ArrayList changeToArrayString(Object resResult) { + return JSON.parseObject(JSON.toJSONString(resResult), ArrayList.class); + } + + public static ArrayList changeToArrayInteger(Object resResult) { + return JSON.parseObject(JSON.toJSONString(resResult), ArrayList.class); } /** * @return 时间年月日 */ - public static String getCurrentDateTime(){ + public static String getCurrentDateTimeTrim() { + SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmss");//设置日期格式 + return df.format(new Date()); + } + /** + * @return 时间年月日 + */ + public static String getCurrentDateTime() { SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格式 return df.format(new Date()); } @@ -112,7 +137,7 @@ public static String getCurrentDateTime(){ /** * @return 当前年月 */ - public static String getCurrentDate(){ + public static String getCurrentDate() { SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");//设置日期格式 return df.format(new Date()); } @@ -121,14 +146,15 @@ public static String getCurrentDate(){ * @param date * @return */ - public static String formatDateTime(Date date){ + public static String formatDateTime(Date date) { SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格式 return df.format(date); } /** - * MultipartFile change to file + * MultipartFile change to file + * * @param multiFile * @return */ diff --git a/common-pom/src/main/resources/application-main.yml b/common-pom/src/main/resources/application-main.yml new file mode 100644 index 0000000..7c6bef4 --- /dev/null +++ b/common-pom/src/main/resources/application-main.yml @@ -0,0 +1,17 @@ +envpt: + baseLinuxIp: 8.135.1.141 + mysqlIp: ${envpt.baseLinuxIp} + mysqlPort: 3306 + redisIp: ${envpt.baseLinuxIp} + redisPort: 6379 + rabbitIp: ${envpt.baseLinuxIp} + rabbitPort: 5675 + tomcatPortPre: 2 + +spring: + main: + allow-bean-definition-overriding: true + #解决查询时间和返回的时间不一致问题 + jackson: + date-format: yyyy-MM-dd HH:mm:ss + time-zone: GMT+8 diff --git a/ty-common/src/main/resources/config/banner.txt b/common-pom/src/main/resources/config/banner.txt similarity index 98% rename from ty-common/src/main/resources/config/banner.txt rename to common-pom/src/main/resources/config/banner.txt index 1a1dcb9..9cab9d3 100644 --- a/ty-common/src/main/resources/config/banner.txt +++ b/common-pom/src/main/resources/config/banner.txt @@ -1,7 +1,7 @@ - . ____ _ __ _ _ - /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ -( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ - \\/ ___)| |_)| | | | | || (_| | ) ) ) )----☺ ☺ ☺ ☺ ☺ ☺ ☺ ☺ ☺ - ' |____| .__|_| |_|_| |_\__, | / / / / - =========|_|==============|___/=/_/_/_/ + . ____ _ __ _ _ + /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ +( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ + \\/ ___)| |_)| | | | | || (_| | ) ) ) )----☺ ☺ ☺ ☺ ☺ ☺ ☺ ☺ ☺ + ' |____| .__|_| |_|_| |_\__, | / / / / + =========|_|==============|___/=/_/_/_/ :: new general micro service construct:: (v2.2.4RELEASE) \ No newline at end of file diff --git a/ty-common/src/main/resources/config/emp.properties b/common-pom/src/main/resources/config/emp.properties similarity index 91% rename from ty-common/src/main/resources/config/emp.properties rename to common-pom/src/main/resources/config/emp.properties index c9f9905..32cda57 100644 --- a/ty-common/src/main/resources/config/emp.properties +++ b/common-pom/src/main/resources/config/emp.properties @@ -1 +1 @@ -emp.age=30 +emp.age=30 diff --git a/ty-common/src/main/resources/logs/logback-spring.xml b/common-pom/src/main/resources/logs/logback-spring.xml similarity index 100% rename from ty-common/src/main/resources/logs/logback-spring.xml rename to common-pom/src/main/resources/logs/logback-spring.xml diff --git a/ty-common/src/main/resources/spy.properties b/common-pom/src/main/resources/spy.properties similarity index 98% rename from ty-common/src/main/resources/spy.properties rename to common-pom/src/main/resources/spy.properties index b38335b..9e311eb 100644 --- a/ty-common/src/main/resources/spy.properties +++ b/common-pom/src/main/resources/spy.properties @@ -1,23 +1,23 @@ -modulelist=com.baomidou.mybatisplus.extension.p6spy.MybatisPlusLogFactory,com.p6spy.engine.outage.P6OutageFactory -# \u81EA\u5B9A\u4E49\u65E5\u5FD7\u6253\u5370 -logMessageFormat=com.baomidou.mybatisplus.extension.p6spy.P6SpyLogger -#\u65E5\u5FD7\u8F93\u51FA\u5230\u63A7\u5236\u53F0 -appender=com.baomidou.mybatisplus.extension.p6spy.StdoutLogger -# \u4F7F\u7528\u65E5\u5FD7\u7CFB\u7EDF\u8BB0\u5F55 sql -#appender=com.p6spy.engine.spy.appender.Slf4JLogger -# \u8BBE\u7F6E p6spy driver \u4EE3\u7406 -deregisterdrivers=true -# \u53D6\u6D88JDBC URL\u524D\u7F00 -useprefix=true -# \u914D\u7F6E\u8BB0\u5F55 Log \u4F8B\u5916,\u53EF\u53BB\u6389\u7684\u7ED3\u679C\u96C6\u6709error,info,batch,debug,statement,commit,rollback,result,resultset. -excludecategories=info,debug,result,commit,resultset -# \u65E5\u671F\u683C\u5F0F -dateformat=yyyy-MM-dd HH:mm:ss -# \u5B9E\u9645\u9A71\u52A8\u53EF\u591A\u4E2A -#driverlist=org.h2.Driver -# \u662F\u5426\u5F00\u542F\u6162SQL\u8BB0\u5F55 -outagedetection=true -# \u6162SQL\u8BB0\u5F55\u6807\u51C6 2 \u79D2 -outagedetectioninterval=1 -# \u771F\u5B9EJDBC driver +modulelist=com.baomidou.mybatisplus.extension.p6spy.MybatisPlusLogFactory,com.p6spy.engine.outage.P6OutageFactory +# \u81EA\u5B9A\u4E49\u65E5\u5FD7\u6253\u5370 +logMessageFormat=com.baomidou.mybatisplus.extension.p6spy.P6SpyLogger +#\u65E5\u5FD7\u8F93\u51FA\u5230\u63A7\u5236\u53F0 +appender=com.baomidou.mybatisplus.extension.p6spy.StdoutLogger +# \u4F7F\u7528\u65E5\u5FD7\u7CFB\u7EDF\u8BB0\u5F55 sql +#appender=com.p6spy.engine.spy.appender.Slf4JLogger +# \u8BBE\u7F6E p6spy driver \u4EE3\u7406 +deregisterdrivers=true +# \u53D6\u6D88JDBC URL\u524D\u7F00 +useprefix=true +# \u914D\u7F6E\u8BB0\u5F55 Log \u4F8B\u5916,\u53EF\u53BB\u6389\u7684\u7ED3\u679C\u96C6\u6709error,info,batch,debug,statement,commit,rollback,result,resultset. +excludecategories=info,debug,result,commit,resultset +# \u65E5\u671F\u683C\u5F0F +dateformat=yyyy-MM-dd HH:mm:ss +# \u5B9E\u9645\u9A71\u52A8\u53EF\u591A\u4E2A +#driverlist=org.h2.Driver +# \u662F\u5426\u5F00\u542F\u6162SQL\u8BB0\u5F55 +outagedetection=true +# \u6162SQL\u8BB0\u5F55\u6807\u51C6 2 \u79D2 +outagedetectioninterval=1 +# \u771F\u5B9EJDBC driver driverlist=com.mysql.cj.jdbc.Driver \ No newline at end of file diff --git a/easycode-temp/controller.mv b/easycode-temp/controller.mv deleted file mode 100644 index 6564d95..0000000 --- a/easycode-temp/controller.mv +++ /dev/null @@ -1,140 +0,0 @@ -##导入宏定义 -$!init -$!define - -##设置表后缀(宏定义) -#setTableSuffix("Controller") - -##保存文件(宏定义) -#save("/controller", "Controller.java") - -##包路径(宏定义) -#setPackageSuffix("controller") - -##定义服务名 -#set($serviceName = $!tool.append($!tool.firstLowerCase($!tableInfo.name), "Service")) - -##定义实体对象名 -#set($entityName = $!tool.firstLowerCase($!tableInfo.name)) - - -import org.apache.commons.lang3.StringUtils; -import top.kuanghua.khcomomon.entity.CommonParams; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.extension.api.ApiController; -import com.baomidou.mybatisplus.extension.api.R; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -##import $!{tableInfo.savePackageName}api.entity.$!tableInfo.name; -import $!{tableInfo.savePackageName}.service.$!{tableInfo.name}Service; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import java.io.Serializable; -import java.util.*; - -##表注释(宏定义) -@Api(tags = "$!{tableInfo.comment}($!{tableInfo.name})") -@RestController -@RequestMapping("$!tool.firstLowerCase($!tableInfo.name)") -public class $!{tableInfo.name}Controller { - -@Resource -private $!{tableInfo.name}Service $!{serviceName}; - -/** -* 分页查询所有数据 -* @param $!entityName 查询实体 -* @return 所有数据 -*/ -@GetMapping("selectPage") -@ApiOperation(value = "分页查询所有数据") -public ResResult selectPage($!{tableInfo.name} $!entityName, CommonParams commonParams) { -QueryWrapper<$!{tableInfo.name}> queryWrapper = new QueryWrapper<>(); -#foreach($column in $tableInfo.fullColumn) - #if( $!column.comment ) - if(ObjectUtils.isNotEmpty($!{entityName}.get$!{tool.firstUpperCase($column.name)}())) { - queryWrapper.like("$!{tool.hump2Underline($column.name)}",$!{entityName}.get$!{tool.firstUpperCase($column.name)}()); - } - #end -#end - -#set($StringBj="") -#foreach($column in $tableInfo.fullColumn) - #if( $!column.comment ) - #set($StringBj=$!{StringBj}+$!{tool.hump2Underline($column.name)}+",") - #end -#end - - - -if(StringUtils.isNotEmpty(commonParams.getStartTime())) { -queryWrapper.between("create_time",commonParams.getStartTime(),commonParams.getEndTime()); -queryWrapper.or().orderByDesc("create_time"); -} - -queryWrapper.select("$StringBj.substring(0,$StringBj.lastIndexOf(','))"); -Page<$!{tableInfo.name}> $!{entityName}Page = this.$!{entityName}Service.selectPage(commonParams.getPageNum(), commonParams.getPageSize(), queryWrapper); -return new ResResult().success($!{entityName}Page); -} - -/** -* 通过主键查询单条数据 -* @param id 主键 -* @return 单条数据 -*/ -@GetMapping("selectById") -@ApiOperation(value = "通过id主键查询单条数据") -public ResResult selectById(@RequestParam("id") Integer id) { -return new ResResult().success(this.$!{serviceName}.selectById(id)); -} - -/** -* @Description: 根据id数组查询品牌列表 -* @Param: idList id数组 -* @return: ids列表数据 -*/ -@ApiOperation(value = "根据id数组查询品牌列表") -@PostMapping("selectBatchIds") -public ResResult selectBatchIds(@RequestParam("idList") List - idList) { - return new ResResult().success(this.$!{serviceName}.selectBatchIds(idList)); - } - /** - * 新增数据 - * @param $!entityName 实体对象 - * @return 新增结果 - */ - @ApiOperation(value = "新增数据") - @PostMapping("insert") - public ResResult insert(@RequestBody $!{tableInfo.name} $!entityName) { - return new ResResult().success(this.$!{serviceName}.insert($!entityName)); - } - - /** - * 修改数据 - * @param $!entityName 实体对象 - * @return 修改结果 - */ - @ApiOperation(value = "根据id修改数据") - @PutMapping("updateById") - public ResResult updateById(@RequestBody $!{tableInfo.name} $!entityName) { - return new ResResult().success(this.$!{serviceName}.updateById($!entityName)); - } - - /** - * 删除数据 - * @param idList 主键结合 - * @return 删除结果 - */ - @ApiOperation(value = "根据id数组删除数据") - @DeleteMapping("deleteBatchIds") - public ResResult deleteBatchIds(@RequestBody List - idList) { - return new ResResult().success(this.$!{serviceName}.deleteBatchIds(idList)); - } - @DeleteMapping("deleteById") - @ApiOperation(value = "根据id删除数据") - public ResResult deleteById(@RequestParam("id") Integer id) { - return new ResResult().success(this.$!{serviceName}.deleteById(id)); - } - } \ No newline at end of file diff --git a/easycode-temp/element-form.mv b/easycode-temp/element-form.mv deleted file mode 100644 index ee97b17..0000000 --- a/easycode-temp/element-form.mv +++ /dev/null @@ -1,303 +0,0 @@ -##导入宏定义 -$!init -$!define -##定义实体对象名 -#set($entityName = $!tool.firstLowerCase($!tableInfo.name)) -#set($serviceName = 'rbox-service') - -##保存文件(宏定义) -#save($!{entityName}, "Form.vue") - - - - - diff --git a/easycode-temp/element-table.mv b/easycode-temp/element-table.mv deleted file mode 100644 index 92b49c5..0000000 --- a/easycode-temp/element-table.mv +++ /dev/null @@ -1,300 +0,0 @@ -##导入宏定义 -$!init -$!define -##定义实体对象名 -#set($entityName = $!tool.firstLowerCase($!tableInfo.name)) -#set($serviceName = 'rbox-service') - -##保存文件(宏定义) -#save($!{entityName}, ".vue") - - - - - diff --git a/easycode-temp/entity.mv b/easycode-temp/entity.mv deleted file mode 100644 index 451ce4f..0000000 --- a/easycode-temp/entity.mv +++ /dev/null @@ -1,56 +0,0 @@ -##导入宏定义 -$!init -$!define - -##保存文件(宏定义) -#save("/entity", ".java") - -##包路径(宏定义) -#setPackageSuffix("entity") - -##自动导入包(全局变量) -##$!autoImport -import com.baomidou.mybatisplus.extension.activerecord.Model; -import java.io.Serializable; -import lombok.Data; -##表注释(宏定义) -#tableComment("表实体类") -@Data -@ApiModel("$!tableInfo.comment") -@TableName(value = "tb_$!{tool.hump2Underline($tableInfo.name)}") -public class $!{tableInfo.name} extends Model<$!{tableInfo.name}> { -#foreach($column in $tableInfo.fullColumn) - #if( $!column.comment ) - #set($listSize=$!{column.comment.split(';')}) - #if( $!listSize.size() > 0 ) - @ApiModelProperty(value="$!listSize[0]") - #end - #if($column.name.indexOf("updateTime") != -1) - @TableField(fill = FieldFill.UPDATE) - #end - #if($column.name.indexOf("createTime") != -1) - @TableField(fill = FieldFill.INSERT) - #end - #if($column.name.indexOf("isDeleted") != -1) - @TableLogic - @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) - #end - #end -private $!{tool.getClsNameByFullName($column.type)} $!{column.name}; -#end -###foreach($column in $tableInfo.fullColumn) -###getSetMethod($column) -###end -#foreach($column in $tableInfo.pkColumn) -/** -* 获取主键值 -* -* @return 主键值 -*/ -@Override -protected Serializable pkVal() { -return this.$!column.name; -} - #break -#end -} diff --git a/easycode-temp/mapper.mv b/easycode-temp/mapper.mv deleted file mode 100644 index 875226c..0000000 --- a/easycode-temp/mapper.mv +++ /dev/null @@ -1,19 +0,0 @@ -##导入宏定义 -$!init -$!define - -##设置表后缀(宏定义) -#setTableSuffix("Mapper") - -##保存文件(宏定义) -#save("/mapper", "Mapper.java") - -##包路径(宏定义) -#setPackageSuffix("mapper") - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; - -##表注释(宏定义) -public interface $!{tableName} extends BaseMapper<$!tableInfo.name> { - -} \ No newline at end of file diff --git a/easycode-temp/service.mv b/easycode-temp/service.mv deleted file mode 100644 index fa646ee..0000000 --- a/easycode-temp/service.mv +++ /dev/null @@ -1,54 +0,0 @@ -##导入宏定义 -$!init -$!define - -##设置表后缀(宏定义) -#setTableSuffix("Service") - -##保存文件(宏定义) -#save("/service", "Service.java") -##定义服务名 -##定义实体对象名 -#set($entityName = $!tool.firstLowerCase($!tableInfo.name)) -##包路径(宏定义) -#setPackageSuffix("service") -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -/** -* ($!{tableInfo.name}) -* @author kuanghua -* @since $time.currTime() -*/ -@Service -public class $!{tableInfo.name}Service{ - - @Resource - private $!{tableInfo.name}Mapper $!{entityName}Mapper; - - public Page<$!{tableInfo.name}> selectPage(Integer pageNum, Integer pageSize, QueryWrapper<$!{tableInfo.name}> queryWrapper) { - return this.$!{entityName}Mapper.selectPage(new Page<$!{tableInfo.name}>(pageNum, pageSize),queryWrapper); - } - - public $!{tableInfo.name} selectById(Integer id) { - return this.$!{entityName}Mapper.selectById(id); - } - - public List<$!{tableInfo.name}> selectBatchIds(List idList) { - return this.$!{entityName}Mapper.selectBatchIds(idList); - } - - public int insert($!{tableInfo.name} $!{entityName}) { - return this.$!{entityName}Mapper.insert($!{entityName}); - } - - public int updateById($!{tableInfo.name} $!{entityName}) { - return this.$!{entityName}Mapper.updateById($!{entityName}); - } - - public int deleteById(Integer id) { - return this.$!{entityName}Mapper.deleteById(id); - } - - public int deleteBatchIds(List idList) { - return this.$!{entityName}Mapper.deleteBatchIds(idList); - } -} \ No newline at end of file diff --git a/ty-auth/pom.xml b/gateway/pom.xml similarity index 53% rename from ty-auth/pom.xml rename to gateway/pom.xml index c04f8eb..0e4b8f4 100644 --- a/ty-auth/pom.xml +++ b/gateway/pom.xml @@ -9,20 +9,39 @@ 4.0.0 - ty-auth - + gateway top.kuanghua - ty-common + common-pom 1.0-SNAPSHOT + + top.kuanghua + auth-pom + 1.0-SNAPSHOT + + + org.springframework.cloud + spring-cloud-starter-gateway + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework + spring-webmvc + + + org.apache.tomcat.embed + tomcat-embed-core + + + - - ${project.artifactId} - src/main/resources @@ -34,10 +53,14 @@ org.springframework.boot spring-boot-maven-plugin + + org.apache.maven.plugins + maven-resources-plugin + 3.1.0 + org.apache.maven.plugins maven-surefire-plugin - 2.22.1 true diff --git a/ty-auth/src/main/java/top/kuanghua/tyauth/AuthApplication.java b/gateway/src/main/java/top/kuanghua/gateway/GatewayApplication.java similarity index 58% rename from ty-auth/src/main/java/top/kuanghua/tyauth/AuthApplication.java rename to gateway/src/main/java/top/kuanghua/gateway/GatewayApplication.java index 35c4842..e736d4a 100644 --- a/ty-auth/src/main/java/top/kuanghua/tyauth/AuthApplication.java +++ b/gateway/src/main/java/top/kuanghua/gateway/GatewayApplication.java @@ -1,12 +1,18 @@ -package top.kuanghua.tyauth; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; - -@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class}) -public class AuthApplication { - public static void main(String[] args) { - SpringApplication.run(AuthApplication.class,args); - } -} +package top.kuanghua.gateway; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; + +/** + * @Title: GatewayTwoApplication + * @Description: + * @Auther: kuanghua + * @create 2020/10/27 10:32 + */ +@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class}) +public class GatewayApplication { + public static void main(String[] args) { + SpringApplication.run(GatewayApplication.class, args); + } +} diff --git a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/GatewayOneApplication.java b/gateway/src/main/java/top/kuanghua/gateway/config/BaseConfig.java similarity index 57% rename from ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/GatewayOneApplication.java rename to gateway/src/main/java/top/kuanghua/gateway/config/BaseConfig.java index 4b46482..b0873f4 100644 --- a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/GatewayOneApplication.java +++ b/gateway/src/main/java/top/kuanghua/gateway/config/BaseConfig.java @@ -1,40 +1,46 @@ -package top.kuanghua.gatewaytwo; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; -import org.springframework.cloud.gateway.filter.ratelimit.KeyResolver; -import org.springframework.context.annotation.Bean; -import org.springframework.http.server.reactive.ServerHttpRequest; -import org.springframework.web.server.ServerWebExchange; -import reactor.core.publisher.Mono; - -/** - * @Title: GatewayTwoApplication - * @Description: - * @Auther: kuanghua - * @create 2020/10/27 10:32 - */ -@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class}) -public class GatewayOneApplication { - public static void main(String[] args) { - SpringApplication.run(GatewayOneApplication.class, args); - } - - //创建一个ipKeyResolver 指定用户的IP - @Bean(name = "ipKeyResolver") - public KeyResolver keyResolver() { - return new KeyResolver() { - @Override - public Mono resolve(ServerWebExchange exchange) { - //1.获取请求request对象 - ServerHttpRequest request = exchange.getRequest(); - //2.从request中获取ip地址 - String hostString = request.getRemoteAddress().getHostString(); - //3.返回 - return Mono.just(hostString); - } - }; - } - -} +package top.kuanghua.gateway.config; + +import org.springframework.cloud.gateway.filter.ratelimit.KeyResolver; +import org.springframework.cloud.openfeign.EnableFeignClients; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.server.reactive.ServerHttpRequest; +import org.springframework.web.server.ServerWebExchange; +import reactor.core.publisher.Mono; + +/** + * @Title: BaseConfig + * @Description: + * @Auther: kuanghua + * @create 2020/8/23 21:52 + */ +/* + * 总结:1.@Configuration 下的@ComponentScan回将包下带有@Component扫描变成配置类, + * 而@SpringBootApplication扫描的只会变成普通类 + * */ +@Configuration +@ComponentScan(basePackages = { + "top.kuanghua.commonpom", + "top.kuanghua.authpom", + "top.kuanghua.gateway" +}) +@EnableFeignClients(basePackages = {"top.kuanghua.commonpom.feign"}) +public class BaseConfig { + //创建一个ipKeyResolver 指定用户的IP + @Bean(name = "ipKeyResolver") + public KeyResolver keyResolver() { + return new KeyResolver() { + @Override + public Mono resolve(ServerWebExchange exchange) { + //1.获取请求request对象 + ServerHttpRequest request = exchange.getRequest(); + //2.从request中获取ip地址 + String hostString = request.getRemoteAddress().getHostString(); + //3.返回 + return Mono.just(hostString); + } + }; + } + +} diff --git a/gateway/src/main/java/top/kuanghua/gateway/config/MySwaggerResourceProvider.java b/gateway/src/main/java/top/kuanghua/gateway/config/MySwaggerResourceProvider.java new file mode 100644 index 0000000..0d7bff7 --- /dev/null +++ b/gateway/src/main/java/top/kuanghua/gateway/config/MySwaggerResourceProvider.java @@ -0,0 +1,64 @@ +package top.kuanghua.gateway.config; + +import lombok.RequiredArgsConstructor; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.cloud.gateway.route.RouteLocator; +import org.springframework.stereotype.Component; +import springfox.documentation.swagger.web.SwaggerResource; +import springfox.documentation.swagger.web.SwaggerResourcesProvider; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Component +@RequiredArgsConstructor +public class MySwaggerResourceProvider implements SwaggerResourcesProvider { + + /** + * swagger2默认的url后缀 + */ + private static final String SWAGGER2_URL = "/v2/api-docs"; + + /** + * 路由定位器 + */ + private final RouteLocator routeLocator; + + /** + * 网关应用名称 + */ + @Value("${spring.application.name}") + private String gatewayName; + + /** + * 获取 Swagger 资源 + */ + @Override + public List get() { + List resources = new ArrayList<>(); + List> routeInfoList = new ArrayList>(); + // 1. 获取路由Uri 中的Host=> 服务注册则为服务名=》app-service001 + routeLocator.getRoutes() + .filter(route -> route.getUri().getHost() != null) + .filter(route -> !gatewayName.equals(route.getUri().getHost())) + .subscribe(route -> { + HashMap hashMap = new HashMap<>(); + hashMap.put("serviceId", route.getUri().getHost()); + hashMap.put("serviceName", route.getMetadata().get("name").toString()); + routeInfoList.add(hashMap); + }); + // 2. 创建自定义资源 + routeInfoList.forEach((feMap) -> { + String serviceUrl = "/micro-service-api/" + feMap.get("serviceId") + SWAGGER2_URL; // 后台访问添加服务名前缀 + SwaggerResource swaggerResource = new SwaggerResource(); // 创建Swagger 资源 + swaggerResource.setUrl(serviceUrl); // 设置访问地址 + swaggerResource.setName(feMap.get("serviceName")); // 设置名称 + swaggerResource.setSwaggerVersion("2.0.9"); + resources.add(swaggerResource); + }); + return resources; + } +} + diff --git a/gateway/src/main/java/top/kuanghua/gateway/controller/SwaggerResourceController.java b/gateway/src/main/java/top/kuanghua/gateway/controller/SwaggerResourceController.java new file mode 100644 index 0000000..009e595 --- /dev/null +++ b/gateway/src/main/java/top/kuanghua/gateway/controller/SwaggerResourceController.java @@ -0,0 +1,24 @@ +package top.kuanghua.gateway.controller; + +import lombok.RequiredArgsConstructor; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import springfox.documentation.swagger.web.SwaggerResource; +import top.kuanghua.gateway.config.MySwaggerResourceProvider; + +import java.util.List; + +@RestController +@RequestMapping("/swagger-resources") +@RequiredArgsConstructor +public class SwaggerResourceController { + private final MySwaggerResourceProvider swaggerResourceProvider; + + @RequestMapping + public ResponseEntity> swaggerResources() { + return new ResponseEntity<>(swaggerResourceProvider.get(), HttpStatus.OK); + } +} + diff --git a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/filter/AuthorizeFilterAfter.java b/gateway/src/main/java/top/kuanghua/gateway/filter/AuthorizeFilterAfter.java similarity index 85% rename from ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/filter/AuthorizeFilterAfter.java rename to gateway/src/main/java/top/kuanghua/gateway/filter/AuthorizeFilterAfter.java index ff859cf..4e1ed83 100644 --- a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/filter/AuthorizeFilterAfter.java +++ b/gateway/src/main/java/top/kuanghua/gateway/filter/AuthorizeFilterAfter.java @@ -1,135 +1,133 @@ -package top.kuanghua.gatewaytwo.filter; - -import com.alibaba.fastjson.JSON; -import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; -import org.joda.time.DateTime; -import org.reactivestreams.Publisher; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.cloud.gateway.filter.GatewayFilterChain; -import org.springframework.cloud.gateway.filter.GlobalFilter; -import org.springframework.core.Ordered; -import org.springframework.core.io.buffer.DataBuffer; -import org.springframework.core.io.buffer.DataBufferFactory; -import org.springframework.core.io.buffer.DataBufferUtils; -import org.springframework.core.io.buffer.DefaultDataBufferFactory; -import org.springframework.http.server.reactive.ServerHttpRequest; -import org.springframework.http.server.reactive.ServerHttpResponse; -import org.springframework.http.server.reactive.ServerHttpResponseDecorator; -import org.springframework.stereotype.Component; -import org.springframework.web.server.ServerWebExchange; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; -import top.kuanghua.feign.tyauth.feign.TokenFeign; -import top.kuanghua.khcomomon.utils.ObjectUtilsSelf; - -import javax.annotation.Resource; -import java.net.URLDecoder; -import java.nio.charset.Charset; -import java.util.List; -import java.util.Map; - -/** - * @Title: AuthorizeFilter - * @Description: - * @Auther: kuanghua - * @create 2020/9/8 21:26 - */ -@Slf4j -@Component -public class AuthorizeFilterAfter implements GlobalFilter, Ordered { - - @Value("#{'${filter.allowPaths:}'.empty ? null : '${filter.allowPaths:}'.split(',')}") - private List allowPaths; - - @Resource - private TokenFeign tokenFeign; - - @Value("${token-properties.renewTokenMinute}") - private int renewTokenMinute; - - @Override - public Mono filter(ServerWebExchange exchange, GatewayFilterChain chain) { - ServerHttpRequest request = exchange.getRequest(); - ServerHttpResponse response = exchange.getResponse(); - DataBufferFactory bufferFactory = response.bufferFactory(); - String path = request.getURI().getPath(); - - //白名单拦截 - for (String allowPath : allowPaths) { - if (StringUtils.contains(path, allowPath)) { - return chain.filter(exchange); - } - } - - - //获取token信息比较exp和当前时间进行比较 - ServerHttpResponseDecorator decoratedResponse = null; - try { - decoratedResponse = new ServerHttpResponseDecorator(response) { - @Override - public Mono writeWith(Publisher body) { - if (body instanceof Flux) { - Flux fluxBody = (Flux) body; - return super.writeWith(fluxBody.buffer().map(dataBuffers -> { - DataBufferFactory dataBufferFactory = new DefaultDataBufferFactory(); - DataBuffer join = dataBufferFactory.join(dataBuffers); - byte[] content = new byte[join.readableByteCount()]; - join.read(content); - // 释放掉内存 - DataBufferUtils.release(join); - String str = new String(content, Charset.forName("UTF-8")); - // log.info("返回体:{}", str); - //todo 拦截到的返回体内容,可以随意去操作了 - //2.1.2 如果小于一个小时 刷新token - //String jwtToken = request.getHeaders().getFirst("AUTHORIZE_TOKEN"); - Long expValue = null; - Map dataMap = null; - try { - String tokenInfo = request.getHeaders().getFirst("TOKEN_INFO"); - dataMap = JSON.parseObject(URLDecoder.decode(tokenInfo, "utf-8"), Map.class); - expValue = ObjectUtilsSelf.toLong(ObjectUtilsSelf.toString(dataMap.get("exp")) + "000"); - } catch (Exception e) { - e.printStackTrace(); - } - Long currentData = DateTime.now().plusMinutes(renewTokenMinute).getMillis(); - Map strMap = JSON.parseObject(str, Map.class); - if (ObjectUtils.isNotEmpty(expValue) && expValue < currentData) { - String generateToken = null; - try { - //调用ty-auth进行生成 - dataMap.remove("exp"); - dataMap.remove("iat"); - Object object = tokenFeign.updateToken(dataMap); - if (ObjectUtilsSelf.isEmpty(object)) { - return bufferFactory.wrap(str.getBytes()); - } - Map map = JSON.parseObject(JSON.toJSONString(object), Map.class); - generateToken = ObjectUtilsSelf.toString(map.get("data")); - } catch (Exception e) { - log.error(e.toString()); - } - strMap.put("isNeedUpdateToken", true); - strMap.put("updateToken", generateToken); - } - response.getHeaders().setContentLength(JSON.toJSONString(strMap).getBytes().length); - return bufferFactory.wrap(JSON.toJSONString(strMap).getBytes()); - })); - } - // if body is not a flux. never got there. - return super.writeWith(body); - } - }; - } catch (Exception e) { - return chain.filter(exchange); - } - return chain.filter(exchange.mutate().response(decoratedResponse).build()); - } - - /*-1代表请求后触发*/ - @Override - public int getOrder() { - return -1; - } -} +package top.kuanghua.gateway.filter; + +import com.alibaba.fastjson.JSON; +import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.joda.time.DateTime; +import org.reactivestreams.Publisher; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.cloud.gateway.filter.GatewayFilterChain; +import org.springframework.cloud.gateway.filter.GlobalFilter; +import org.springframework.core.Ordered; +import org.springframework.core.io.buffer.DataBuffer; +import org.springframework.core.io.buffer.DataBufferFactory; +import org.springframework.core.io.buffer.DataBufferUtils; +import org.springframework.core.io.buffer.DefaultDataBufferFactory; +import org.springframework.http.server.reactive.ServerHttpRequest; +import org.springframework.http.server.reactive.ServerHttpResponse; +import org.springframework.http.server.reactive.ServerHttpResponseDecorator; +import org.springframework.stereotype.Component; +import org.springframework.web.server.ServerWebExchange; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; +import top.kuanghua.authpom.service.TokenService; +import top.kuanghua.commonpom.utils.ObjSelfUtils; + +import javax.annotation.Resource; +import java.net.URLDecoder; +import java.nio.charset.Charset; +import java.util.List; +import java.util.Map; + +/** + * @Title: AuthorizeFilter + * @Description: + * @Auther: kuanghua + * @create 2020/9/8 21:26 + */ +@Slf4j +@Component +public class AuthorizeFilterAfter implements GlobalFilter, Ordered { + + @Value("#{'${filter.afterNeedFilterPaths:}'.empty ? null : '${filter.afterNeedFilterPaths:}'.split(',')}") + private List afterNeedFilterPaths; + + @Resource + private TokenService tokenService; + + @Value("${token-properties.renewTokenMinute}") + private int renewTokenMinute; + + @Override + public Mono filter(ServerWebExchange exchange, GatewayFilterChain chain) { + ServerHttpRequest request = exchange.getRequest(); + ServerHttpResponse response = exchange.getResponse(); + DataBufferFactory bufferFactory = response.bufferFactory(); + String path = request.getURI().getPath(); + + //白名单拦截 + for (String allowPath : afterNeedFilterPaths) { + if (!StringUtils.contains(path, allowPath)) { + return chain.filter(exchange); + } + } + //获取token信息比较exp和当前时间进行比较 + ServerHttpResponseDecorator decoratedResponse = null; + try { + decoratedResponse = new ServerHttpResponseDecorator(response) { + @Override + public Mono writeWith(Publisher body) { + if (body instanceof Flux) { + Flux fluxBody = (Flux) body; + return super.writeWith(fluxBody.buffer().map(dataBuffers -> { + DataBufferFactory dataBufferFactory = new DefaultDataBufferFactory(); + DataBuffer join = dataBufferFactory.join(dataBuffers); + byte[] content = new byte[join.readableByteCount()]; + join.read(content); + // 释放掉内存 + DataBufferUtils.release(join); + String str = new String(content, Charset.forName("UTF-8")); + // log.info("返回体:{}", str); + //todo 拦截到的返回体内容,可以随意去操作了 + //2.1.2 如果小于一个小时 刷新token + //String jwtToken = request.getHeaders().getFirst("AUTHORIZE_TOKEN"); + Long expValue = null; + Map dataMap = null; + try { + String tokenInfo = request.getHeaders().getFirst("TOKEN_INFO"); + dataMap = JSON.parseObject(URLDecoder.decode(tokenInfo, "utf-8"), Map.class); + expValue = ObjSelfUtils.toLong(ObjSelfUtils.toString(dataMap.get("exp")) + "000"); + } catch (Exception e) { + e.printStackTrace(); + } + Long currentData = DateTime.now().plusMinutes(renewTokenMinute).getMillis(); + Map strMap = JSON.parseObject(str, Map.class); + if (ObjectUtils.isNotEmpty(expValue) && expValue < currentData) { + String generateToken = null; + try { + //调用ty-auth进行生成 + dataMap.remove("exp"); + dataMap.remove("iat"); + Object object = tokenService.updateToken(dataMap); + if (ObjSelfUtils.isEmpty(object)) { + return bufferFactory.wrap(str.getBytes()); + } + Map map = JSON.parseObject(JSON.toJSONString(object), Map.class); + generateToken = ObjSelfUtils.toString(map.get("data")); + } catch (Exception e) { + log.error(e.toString()); + } + strMap.put("isNeedUpdateToken", true); + strMap.put("updateToken", generateToken); + } + response.getHeaders().setContentLength(JSON.toJSONString(strMap).getBytes().length); + return bufferFactory.wrap(JSON.toJSONString(strMap).getBytes()); + })); + } + // if body is not a flux. never got there. + return super.writeWith(body); + } + }; + } catch (Exception e) { + return chain.filter(exchange); + } + return chain.filter(exchange.mutate().response(decoratedResponse).build()); + } + + /*-1代表请求后触发*/ + @Override + public int getOrder() { + return -1; + } +} diff --git a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/filter/AuthorizeFilterBefore.java b/gateway/src/main/java/top/kuanghua/gateway/filter/AuthorizeFilterBefore.java similarity index 81% rename from ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/filter/AuthorizeFilterBefore.java rename to gateway/src/main/java/top/kuanghua/gateway/filter/AuthorizeFilterBefore.java index e902ea0..1aa2af6 100644 --- a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/filter/AuthorizeFilterBefore.java +++ b/gateway/src/main/java/top/kuanghua/gateway/filter/AuthorizeFilterBefore.java @@ -1,119 +1,108 @@ -package top.kuanghua.gatewaytwo.filter; - -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.cloud.gateway.filter.GatewayFilterChain; -import org.springframework.cloud.gateway.filter.GlobalFilter; -import org.springframework.core.Ordered; -import org.springframework.core.io.buffer.DataBuffer; -import org.springframework.http.server.reactive.ServerHttpRequest; -import org.springframework.http.server.reactive.ServerHttpResponse; -import org.springframework.stereotype.Component; -import org.springframework.util.ObjectUtils; -import org.springframework.web.server.ServerWebExchange; -import reactor.core.publisher.Mono; -import top.kuanghua.feign.tyauth.feign.TokenFeign; -import top.kuanghua.khcomomon.utils.ObjectUtilsSelf; - -import javax.annotation.Resource; -import java.io.UnsupportedEncodingException; -import java.net.URLEncoder; -import java.nio.charset.StandardCharsets; -import java.util.List; -import java.util.Map; - -/** - * @Title: AuthorizeFilter - * @Description: - * @Auther: kuanghua - * @create 2020/9/8 21:26 - */ -@Slf4j -@Component -//https://www.cnblogs.com/javastack/archive/2020/10/23/13862164.html -//https://www.jianshu.com/p/f3383e7b1faf -//https://blog.csdn.net/weixin_41187876/article/details/103645102?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromBaidu-1.control&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromBaidu-1.control -/* -* @Value("#{'${scio.cloud.list}'.split(',')}") -private List list; -@Value("#{${scio.cloud.maps}}") -private Map maps; -* */ -public class AuthorizeFilterBefore implements GlobalFilter, Ordered { - - private static final String AUTHORIZE_TOKEN = "AUTHORIZE_TOKEN"; - @Value("#{'${filter.allowPaths:}'.empty ? null : '${filter.allowPaths:}'.split(',')}") - private List allowPaths; - - @Resource - private TokenFeign tokenFeign; - - @Override - public Mono filter(ServerWebExchange exchange, GatewayFilterChain chain) { - ServerHttpRequest request = exchange.getRequest(); - ServerHttpResponse response = exchange.getResponse(); - - String path = request.getURI().getPath(); - - //1.白名单放行 - for (String allowPath : allowPaths) { - if (StringUtils.contains(path, allowPath)) { - return chain.filter(exchange); - } - } - //2.解析jwt token放行 - String jwtToken = request.getHeaders().getFirst(AUTHORIZE_TOKEN); - - if (ObjectUtils.isEmpty(jwtToken)) { - JSONObject message = new JSONObject(); - message.put("code", 403); - message.put("msg", "token为空"); - DataBuffer buffer = getDataBuffer(response, message); - return response.writeWith(Mono.just(buffer)); - } - //2.1 将解析到的jwt数据保存到线程中(转发过去的服务都能接收) - try { - //调用feign服务进行解析 - Object resResult = tokenFeign.parseToken(jwtToken); - - Map tokenInfo = ObjectUtilsSelf.parseResToData(resResult); - log.info("解析的token数据", tokenInfo.toString()); - //将信息设置到头部 - ServerHttpRequest httpRequest = exchange.getRequest().mutate().headers(httpHeaders -> { - String decode = ""; - try { - decode = URLEncoder.encode(JSON.toJSONString(tokenInfo), "utf-8"); - } catch (UnsupportedEncodingException e) { - e.printStackTrace(); - } - httpHeaders.add("TOKEN_INFO", decode); - }).build(); - //将信息设置到线程中 - ServerWebExchange build = exchange.mutate().request(httpRequest).build(); - return chain.filter(build); - } catch (Exception e) { - JSONObject message = new JSONObject(); - message.put("code", 403); - message.put("msg", "token解析失败" + e.getMessage()); - log.error("token解析失败" + e); - return response.writeWith(Mono.just(getDataBuffer(response, message))); - } - } - - private DataBuffer getDataBuffer(ServerHttpResponse response, JSONObject message) { - byte[] bits = message.toJSONString().getBytes(StandardCharsets.UTF_8); - DataBuffer buffer = response.bufferFactory().wrap(bits); - //response.setStatusCode(HttpStatus.UNAUTHORIZED); - //指定编码,否则在浏览器中会中文乱码 - response.getHeaders().add("Content-Type", "text/plain;charset=UTF-8"); - return buffer; - } - - @Override - public int getOrder() { - return 1; - } -} +package top.kuanghua.gateway.filter; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.cloud.gateway.filter.GatewayFilterChain; +import org.springframework.cloud.gateway.filter.GlobalFilter; +import org.springframework.core.Ordered; +import org.springframework.core.io.buffer.DataBuffer; +import org.springframework.http.server.reactive.ServerHttpRequest; +import org.springframework.http.server.reactive.ServerHttpResponse; +import org.springframework.stereotype.Component; +import org.springframework.util.ObjectUtils; +import org.springframework.web.server.ServerWebExchange; +import reactor.core.publisher.Mono; +import top.kuanghua.authpom.service.TokenService; +import top.kuanghua.commonpom.utils.ObjSelfUtils; + +import javax.annotation.Resource; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.List; +import java.util.Map; + +/** + * @Title: AuthorizeFilter + * @Description: + * @Auther: kuanghua + * @create 2020/9/8 21:26 + */ +@Slf4j +@Component +public class AuthorizeFilterBefore implements GlobalFilter, Ordered { + + private static final String AUTHORIZE_TOKEN = "AUTHORIZE_TOKEN"; + @Value("#{'${filter.allowPaths:}'.empty ? null : '${filter.allowPaths:}'.split(',')}") + private List allowPaths; + + @Resource + private TokenService tokenService; + + @Override + public Mono filter(ServerWebExchange exchange, GatewayFilterChain chain) { + ServerHttpRequest request = exchange.getRequest(); + ServerHttpResponse response = exchange.getResponse(); + + String path = request.getURI().getPath(); + log.info(path); + //1.白名单放行 + for (String allowPath : allowPaths) { + if (StringUtils.contains(path, allowPath)) { + return chain.filter(exchange); + } + } + //2.解析jwt token放行 + String jwtToken = request.getHeaders().getFirst(AUTHORIZE_TOKEN); + + if (ObjectUtils.isEmpty(jwtToken)) { + JSONObject message = new JSONObject(); + message.put("code", 403); + message.put("msg", "token为空"); + DataBuffer buffer = getDataBuffer(response, message); + return response.writeWith(Mono.just(buffer)); + } + //2.1 将解析到的jwt数据保存到线程中(转发过去的服务都能接收) + try { + //调用feign服务进行解析 + Object resResult = tokenService.parseToken(jwtToken); + + Map tokenInfo = ObjSelfUtils.changeToMap(resResult); + log.info("解析的token数据", tokenInfo.toString()); + //将信息设置到头部 + ServerHttpRequest httpRequest = exchange.getRequest().mutate().headers(httpHeaders -> { + String decode = ""; + try { + decode = URLEncoder.encode(JSON.toJSONString(tokenInfo), "utf-8"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + httpHeaders.add("TOKEN_INFO", decode); + }).build(); + //将信息设置到线程中 + ServerWebExchange build = exchange.mutate().request(httpRequest).build(); + return chain.filter(build); + } catch (Exception e) { + JSONObject message = new JSONObject(); + message.put("code", 403); + message.put("msg", "token解析失败" + e.getMessage()); + log.error("token解析失败" + e); + return response.writeWith(Mono.just(getDataBuffer(response, message))); + } + } + private DataBuffer getDataBuffer(ServerHttpResponse response, JSONObject message) { + byte[] bits = message.toJSONString().getBytes(StandardCharsets.UTF_8); + DataBuffer buffer = response.bufferFactory().wrap(bits); + //response.setStatusCode(HttpStatus.UNAUTHORIZED); + //指定编码,否则在浏览器中会中文乱码 + response.getHeaders().add("Content-Type", "text/plain;charset=UTF-8"); + return buffer; + } + @Override + public int getOrder() { + return 1; + } +} diff --git a/gateway/src/main/resources/application.yml b/gateway/src/main/resources/application.yml new file mode 100644 index 0000000..ca61614 --- /dev/null +++ b/gateway/src/main/resources/application.yml @@ -0,0 +1,58 @@ +server: + port: ${envpt.tomcatPortPre}0156 +spring: + cloud: + gateway: + # globalcors: + # corsConfigurations: + # '[/**]': + # allow-credentials: true + # allowed-origin-patterns: "*" + # allowed-headers: "*" + # allowed-methods: + # - OPTIONS + # - GET + # - POST + # - PUT + # - DELETE + # #max-age: 3600 + routes: + - id: integration-front + uri: lb://integration-front + metadata: + name: "集成前端服务" + predicates: + - Path=/micro-service-api/integration-front/** + filters: + - StripPrefix=2 + - id: basis-func + uri: lb://basis-func + metadata: + name: "基础功能服务" + predicates: + - Path=/micro-service-api/basis-func/** + filters: + - StripPrefix=2 +management: + endpoint: + gateway: + enabled: true + web: + exposure: + include: true + + +#白名单过滤 +filter: + afterNeedFilterPaths: user + allowPaths: swagger,docs,userRegister,userLogin,sendEmailCode,registry,login,loginOut,insertUser,export,excel,file,zip + +#默认3天时间告知前端刷新token +token-properties: + renewTokenMinute: 3440 + + + + + + diff --git a/gateway/src/main/resources/bootstrap.yml b/gateway/src/main/resources/bootstrap.yml new file mode 100644 index 0000000..d92ceb4 --- /dev/null +++ b/gateway/src/main/resources/bootstrap.yml @@ -0,0 +1,15 @@ +spring: + application: + name: @project.artifactId@ + profiles: + active: @activatedProperties@,main + cloud: + nacos: + discovery: + namespace: @nacosNamespace@ + group: @nacosGroup@ + username: @nacosUsername@ + password: @nacosPassword@ + server-addr: @nacosIpPort@ + weight: @nacosWeight@ + ip: @nacosDiscoveryIp@ diff --git a/integration-front/pom.xml b/integration-front/pom.xml index 8fea0ed..af765c7 100644 --- a/integration-front/pom.xml +++ b/integration-front/pom.xml @@ -8,29 +8,33 @@ 1.0-SNAPSHOT 4.0.0 - integration-front - - com.alibaba - easyexcel - 3.0.1 + top.kuanghua + common-pom + 1.0-SNAPSHOT top.kuanghua - ty-common + auth-pom 1.0-SNAPSHOT + + com.alibaba + easyexcel + 3.0.1 + + + + + - ${project.artifactId} - src/main/resources - true @@ -39,11 +43,14 @@ org.springframework.boot spring-boot-maven-plugin - + + org.apache.maven.plugins + maven-resources-plugin + 3.1.0 + org.apache.maven.plugins maven-surefire-plugin - 2.22.1 true diff --git a/integration-front/src/main/java/top/kuanghua/integrationfront/IntegrationFrontApplication.java b/integration-front/src/main/java/top/kuanghua/integrationfront/IntegrationFrontApplication.java index ac8b53d..e6fb78b 100644 --- a/integration-front/src/main/java/top/kuanghua/integrationfront/IntegrationFrontApplication.java +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/IntegrationFrontApplication.java @@ -1,6 +1,5 @@ package top.kuanghua.integrationfront; -import io.seata.spring.annotation.datasource.EnableAutoDataSourceProxy; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -11,7 +10,6 @@ * @create 2020/11/7 20:07 */ @SpringBootApplication -@EnableAutoDataSourceProxy public class IntegrationFrontApplication { public static void main(String[] args) { SpringApplication.run(IntegrationFrontApplication.class, args); diff --git a/integration-front/src/main/java/top/kuanghua/integrationfront/config/BaseConfig.java b/integration-front/src/main/java/top/kuanghua/integrationfront/config/BaseConfig.java index 6d960e2..309ec76 100644 --- a/integration-front/src/main/java/top/kuanghua/integrationfront/config/BaseConfig.java +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/config/BaseConfig.java @@ -5,22 +5,14 @@ import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; -/** - * @Title: BaseConfig - * @Description: - * @Auther: kuanghua - * @create 2020/8/23 21:52 - */ -/* - * 总结:1.@Configuration 下的@ComponentScan回将包下带有@Component扫描变成配置类, - * 而@SpringBootApplication扫描的只会变成普通类 - * */ + @Configuration -//扫描公用包的配置和自身的配置类 -@ComponentScan(basePackages = {"top.kuanghua.khcomomon", "top.kuanghua.integrationfront"}) -//feign扫描 -@EnableFeignClients(basePackages = {"top.kuanghua.feign.tyauth"}) -//mapper包扫描 +@ComponentScan(basePackages = { + "top.kuanghua.commonpom", + "top.kuanghua.authpom", + "top.kuanghua.integrationfront" +}) +@EnableFeignClients(basePackages = {"top.kuanghua.commonpom.feign.tyauth"}) @MapperScan(basePackages = {"top.kuanghua.integrationfront.mapper"}) public class BaseConfig { diff --git a/integration-front/src/main/java/top/kuanghua/integrationfront/config/Knife4jConfiguration.java b/integration-front/src/main/java/top/kuanghua/integrationfront/config/Knife4jConfiguration.java new file mode 100644 index 0000000..fa9eb0b --- /dev/null +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/config/Knife4jConfiguration.java @@ -0,0 +1,39 @@ +package top.kuanghua.integrationfront.config; + +import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import springfox.documentation.builders.ApiInfoBuilder; +import springfox.documentation.builders.PathSelectors; +import springfox.documentation.builders.RequestHandlerSelectors; +import springfox.documentation.service.ApiInfo; +import springfox.documentation.service.Contact; +import springfox.documentation.spi.DocumentationType; +import springfox.documentation.spring.web.plugins.Docket; +import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc; + +@Configuration +@EnableSwagger2WebMvc +@EnableKnife4j +public class Knife4jConfiguration { + @Bean + public Docket createRestApi() { + return new Docket(DocumentationType.SWAGGER_2) + .useDefaultResponseMessages(false) + .apiInfo(apiInfo()) + .select().apis(RequestHandlerSelectors.basePackage("top.kuanghua.integrationfront")) + .paths(PathSelectors.any()) + .build(); + } + + private ApiInfo apiInfo() { + return new ApiInfoBuilder() + .description("Kinfe4j 集成测试文档") + .contact(new Contact("熊猫哥", "https://github.com/jzfai/", "869653722@qq.com")) + .version("v1.1.0") + .title("API测试文档") + .build(); + } + +} + diff --git a/integration-front/src/main/java/top/kuanghua/integrationfront/config/Swagger2Config.java b/integration-front/src/main/java/top/kuanghua/integrationfront/config/Swagger2Config.java deleted file mode 100644 index 0f38531..0000000 --- a/integration-front/src/main/java/top/kuanghua/integrationfront/config/Swagger2Config.java +++ /dev/null @@ -1,56 +0,0 @@ -package top.kuanghua.integrationfront.config; - -import io.swagger.annotations.ApiOperation; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.stereotype.Component; -import springfox.documentation.builders.ApiInfoBuilder; -import springfox.documentation.builders.PathSelectors; -import springfox.documentation.builders.RequestHandlerSelectors; -import springfox.documentation.service.ApiInfo; -import springfox.documentation.service.Contact; -import springfox.documentation.spi.DocumentationType; -import springfox.documentation.spring.web.plugins.Docket; -import springfox.documentation.swagger2.annotations.EnableSwagger2; - -@Component -@EnableSwagger2 //开启在线接口文档 -//配置包扫描 -public class Swagger2Config { - private boolean swagger_is_enable = true; -// @Value("${.ipAddr}") -// private String ipAddr; - @Value("${server.port}") - private String port; - - @Bean - public Docket api() { - return new Docket(DocumentationType.SWAGGER_2) - .enable(swagger_is_enable) - //.host(this.ipAddr + ":" + this.port) - .apiInfo(apiInfo()) - .select() - .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)) - //.apis(basePackage("top.kuanghua.swagger.controller")) - .paths(PathSelectors.any()) - .build(); - } - - /** - * 构建 api文档的详细信息函数 - * - * @return - */ - private ApiInfo apiInfo() { - return new ApiInfoBuilder() - .title("标题:swagger文档") - .description("描述:新一代的微服务架构") - .contact(new Contact("jzfai", null, "869653722@qq.com")) - .version("版本号:2.8") - .build(); - } - - /** - * http://localhost:8080/swagger-ui.html - */ -} diff --git a/integration-front/src/main/java/top/kuanghua/integrationfront/controller/BrandController.java b/integration-front/src/main/java/top/kuanghua/integrationfront/controller/BrandController.java index 89d3974..73229e0 100644 --- a/integration-front/src/main/java/top/kuanghua/integrationfront/controller/BrandController.java +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/controller/BrandController.java @@ -8,10 +8,10 @@ import io.swagger.annotations.ApiOperation; import org.apache.commons.lang3.StringUtils; import org.springframework.web.bind.annotation.*; +import top.kuanghua.commonpom.entity.ResResult; +import top.kuanghua.commonpom.entity.SelfCommonParams; import top.kuanghua.integrationfront.entity.Brand; import top.kuanghua.integrationfront.service.BrandService; -import top.kuanghua.khcomomon.entity.KHCommonParams; -import top.kuanghua.khcomomon.entity.ResResult; import javax.annotation.Resource; import java.util.List; @@ -32,7 +32,7 @@ public class BrandController { */ @GetMapping("selectPage") @ApiOperation(value = "分页查询所有数据") - public ResResult selectPage(Brand brand, KHCommonParams commonParams) { + public ResResult selectPage(Brand brand, SelfCommonParams commonParams) { QueryWrapper queryWrapper = new QueryWrapper<>(); if (ObjectUtils.isNotEmpty(brand.getId())) { queryWrapper.like("id", brand.getId()); diff --git a/integration-front/src/main/java/top/kuanghua/integrationfront/controller/ErrorCollectionController.java b/integration-front/src/main/java/top/kuanghua/integrationfront/controller/ErrorCollectionController.java index 47283aa..94bb5d8 100644 --- a/integration-front/src/main/java/top/kuanghua/integrationfront/controller/ErrorCollectionController.java +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/controller/ErrorCollectionController.java @@ -8,10 +8,10 @@ import io.swagger.annotations.ApiOperation; import org.apache.commons.lang3.StringUtils; import org.springframework.web.bind.annotation.*; +import top.kuanghua.commonpom.entity.ResResult; +import top.kuanghua.commonpom.entity.SelfCommonParams; import top.kuanghua.integrationfront.entity.ErrorCollection; import top.kuanghua.integrationfront.service.ErrorCollectionService; -import top.kuanghua.khcomomon.entity.KHCommonParams; -import top.kuanghua.khcomomon.entity.ResResult; import javax.annotation.Resource; import java.util.List; @@ -32,7 +32,7 @@ public class ErrorCollectionController { */ @GetMapping("selectPage") @ApiOperation(value = "分页查询所有数据") - public ResResult selectPage(ErrorCollection errorCollection, KHCommonParams khCommonParams) { + public ResResult selectPage(ErrorCollection errorCollection, SelfCommonParams khCommonParams) { QueryWrapper queryWrapper = new QueryWrapper<>(); if (ObjectUtils.isNotEmpty(errorCollection.getErrorLog())) { queryWrapper.like("error_log", errorCollection.getErrorLog()); diff --git a/integration-front/src/main/java/top/kuanghua/integrationfront/controller/PairmentController.java b/integration-front/src/main/java/top/kuanghua/integrationfront/controller/PairmentController.java new file mode 100644 index 0000000..38e3e7f --- /dev/null +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/controller/PairmentController.java @@ -0,0 +1,89 @@ +package top.kuanghua.integrationfront.controller; + +import com.alibaba.fastjson.JSON; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.web.bind.annotation.*; +import top.kuanghua.commonpom.entity.ResResult; +import top.kuanghua.commonpom.entity.SelfCommonParams; +import top.kuanghua.integrationfront.entity.Pairment; +import top.kuanghua.integrationfront.service.PairmentService; +import top.kuanghua.integrationfront.vo.PairmentVo; + +import javax.annotation.Resource; +import java.util.Map; + +/** + * 多表中实体类的注释Controller + * + * @author 熊猫哥 + * @since 2022-06-25 10:32:12 + */ +@Api(tags = "维修信息") +@RestController +@RequestMapping("pairment") +public class PairmentController { + @Resource + private PairmentService pairmentService; + + @ApiOperation(value = "多表测试") + @GetMapping("selectPairment") + public Page selectPairment(SelfCommonParams commonParams, PairmentVo pairmentVo) { + Map pairmentMap = JSON.parseObject(JSON.toJSONString(pairmentVo), Map.class); + return pairmentService.selectPairment(commonParams, pairmentMap); + } + + + /** + * 新增数据 + * + * @param pairment 实体对象 + * @return 新增结果 + */ + @ApiOperation(value = "新增数据") + @PostMapping("insert") + public ResResult insert(@RequestBody Pairment pairment) { + this.pairmentService.insert(pairment); + return new ResResult().success(); + } + + + /** + * 通过主键查询单条数据 + * + * @param sn 主键 + * @return 单条数据 + */ + @GetMapping("selectByKey") + @ApiOperation(value = "通过联合key查询连表数据") + public ResResult selectByKey(@RequestParam("sn") String sn) { + return new ResResult().success(pairmentService.selectByKey(sn)); + } + + /** + * 修改数据 + * + * @param pairment 实体对象 + * @return 修改结果 + */ + @ApiOperation(value = "根据sn修改数据") + @PutMapping("updateByKey") + public ResResult updateByKey(@RequestBody Pairment pairment) { + this.pairmentService.updateByKey(pairment); + return new ResResult().success(); + } + + + /** + * 删除项根据主键key + * + * @param sn + * @return + */ + @DeleteMapping("deleteByKey") + public ResResult deleteByKey(@RequestParam("sn") String sn) { + this.pairmentService.deleteByKey(sn); + return new ResResult().success(); + } +} diff --git a/integration-front/src/main/java/top/kuanghua/integrationfront/controller/UserController.java b/integration-front/src/main/java/top/kuanghua/integrationfront/controller/UserController.java index 888ea63..673c3aa 100644 --- a/integration-front/src/main/java/top/kuanghua/integrationfront/controller/UserController.java +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/controller/UserController.java @@ -10,13 +10,12 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.*; import springfox.documentation.annotations.ApiIgnore; -import top.kuanghua.feign.tyauth.feign.TokenFeign; +import top.kuanghua.commonpom.entity.ResResult; +import top.kuanghua.commonpom.entity.SelfCommonParams; import top.kuanghua.integrationfront.entity.User; import top.kuanghua.integrationfront.mapper.MultiPageMapper; import top.kuanghua.integrationfront.mapper.UserMapper; import top.kuanghua.integrationfront.service.UserService; -import top.kuanghua.khcomomon.entity.KHCommonParams; -import top.kuanghua.khcomomon.entity.ResResult; import javax.annotation.Resource; import javax.validation.Valid; @@ -40,9 +39,6 @@ public class UserController { private MultiPageMapper multiPageMapper; - @Resource - private TokenFeign tokenFeign; - /** * 分页查询所有数据 * @@ -51,7 +47,7 @@ public class UserController { */ @GetMapping("selectPage") @ApiOperation(value = "分页查询数据") - public ResResult selectPage(User user, KHCommonParams commonParams) { + public ResResult selectPage(User user, SelfCommonParams commonParams) { QueryWrapper queryWrapper = new QueryWrapper<>(); if (StringUtils.isNotEmpty(user.getUsername())) { queryWrapper.like("username", user.getUsername()); diff --git a/integration-front/src/main/java/top/kuanghua/integrationfront/controller/VciController.java b/integration-front/src/main/java/top/kuanghua/integrationfront/controller/VciController.java index 8d93778..718e320 100644 --- a/integration-front/src/main/java/top/kuanghua/integrationfront/controller/VciController.java +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/controller/VciController.java @@ -14,9 +14,10 @@ import top.kuanghua.integrationfront.excel.imp.VciExcelImp; import top.kuanghua.integrationfront.service.VciService; import top.kuanghua.integrationfront.vo.ExcelCheckResult; -import top.kuanghua.khcomomon.entity.CommonParamsSelf; -import top.kuanghua.khcomomon.entity.ResResult; -import top.kuanghua.khcomomon.utils.ObjectUtilsSelf; +import top.kuanghua.commonpom.entity.SelfCommonParams; +import top.kuanghua.commonpom.entity.ResResult; +import top.kuanghua.commonpom.utils.SelfObjUtils; + import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; @@ -41,7 +42,7 @@ public class VciController { */ @GetMapping("selectPage") @ApiOperation(value = "分页查询所有数据") - public ResResult selectPage(Vci vci, CommonParamsSelf commonParams) { + public ResResult selectPage(Vci vci, SelfCommonParams commonParams) { QueryWrapper queryWrapper = new QueryWrapper<>(); if (ObjectUtils.isNotEmpty(vci.getSn())) { queryWrapper.like("sn", vci.getSn()); @@ -144,7 +145,7 @@ public ResResult importExcel(@RequestBody List vciExcelBo) { @ApiOperation("导出excel") @GetMapping("exportExcel") - public void exportExcel(HttpServletResponse response, Vci vci, CommonParamsSelf commonParams) throws IOException { + public void exportExcel(HttpServletResponse response, Vci vci, SelfCommonParams commonParams) throws IOException { QueryWrapper queryWrapper = new QueryWrapper<>(); if (ObjectUtils.isNotEmpty(vci.getSn())) { queryWrapper.like("sn", vci.getSn()); @@ -167,7 +168,7 @@ public void exportExcel(HttpServletResponse response, Vci vci, CommonParamsSelf response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); response.setCharacterEncoding("utf-8"); - String fileName = URLEncoder.encode("Vci导出数据", "UTF-8") + "-" + ObjectUtilsSelf.getCurrentDateTime(); + String fileName = URLEncoder.encode("Vci导出数据", "UTF-8") + "-" + SelfObjUtils.getCurrentDateTime(); response.setHeader("Access-Control-Expose-Headers", "exportFileName"); response.setHeader("exportFileName", fileName + ".xlsx"); EasyExcel.write(response.getOutputStream(), VciExcelImp.class).sheet("模板").doWrite(vciPage.getRecords()); diff --git a/integration-front/src/main/java/top/kuanghua/integrationfront/entity/Brand.java b/integration-front/src/main/java/top/kuanghua/integrationfront/entity/Brand.java index 95f7886..c288ca7 100644 --- a/integration-front/src/main/java/top/kuanghua/integrationfront/entity/Brand.java +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/entity/Brand.java @@ -1,7 +1,5 @@ package top.kuanghua.integrationfront.entity; -import java.util.Date; - import com.baomidou.mybatisplus.annotation.FieldFill; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; @@ -11,6 +9,7 @@ import lombok.Data; import java.io.Serializable; +import java.util.Date; /** * 品牌表(Brand)表实体类 @@ -32,12 +31,13 @@ public class Brand extends Model { private String letter; @ApiModelProperty(value = "排序") private Integer seq; - @ApiModelProperty(value = "创建时间",hidden = true) + @ApiModelProperty(value = "创建时间", hidden = true) @TableField(fill = FieldFill.INSERT) private Date createTime; - @ApiModelProperty(value = "更新时间",hidden = true) + @ApiModelProperty(value = "更新时间", hidden = true) @TableField(fill = FieldFill.UPDATE) private Date updateTime; + /** * 获取主键值 * diff --git a/integration-front/src/main/java/top/kuanghua/integrationfront/entity/ErrorCollection.java b/integration-front/src/main/java/top/kuanghua/integrationfront/entity/ErrorCollection.java index ec1827a..1b25daa 100644 --- a/integration-front/src/main/java/top/kuanghua/integrationfront/entity/ErrorCollection.java +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/entity/ErrorCollection.java @@ -1,7 +1,5 @@ package top.kuanghua.integrationfront.entity; -import java.util.Date; - import com.baomidou.mybatisplus.annotation.FieldFill; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; @@ -10,6 +8,8 @@ import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import java.util.Date; + /** * error_log_collection(ErrorCollection)表实体类 * @author kuanghua diff --git a/integration-front/src/main/java/top/kuanghua/integrationfront/entity/Pairment.java b/integration-front/src/main/java/top/kuanghua/integrationfront/entity/Pairment.java new file mode 100644 index 0000000..db76671 --- /dev/null +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/entity/Pairment.java @@ -0,0 +1,63 @@ +package top.kuanghua.integrationfront.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Date; + +/** + * 售后维修表实体类 + * + * @author 熊猫哥 + * @since 2022-06-25 10:32:12 + */ +@Data +@ApiModel("售后维修表") +@TableName(value = "tb_repair") +public class Pairment { + @ApiModelProperty(value = "ID") + private Integer id; + @ApiModelProperty(value = "SN_ID") + private String sn; + @ApiModelProperty(value = "设备类型") + private Integer equipType; + @ApiModelProperty(value = "换件_ID") + private String replacementId; + @ApiModelProperty(value = "快递信息ID") + private String expressId; + @ApiModelProperty(value = "问题归类id") + private String problemClassificationId; + @ApiModelProperty(value = "目前状态") + private Integer currentStatus; + @ApiModelProperty(value = "问题描述") + private String problemDescription; + @ApiModelProperty(value = "反馈时间") + private Date feedbackTime; + @ApiModelProperty(value = "提出人") + private String proposer; + @ApiModelProperty(value = "联系方式") + private String contactInfo; + @ApiModelProperty(value = "回收日期") + private Date recoveryDate; + @ApiModelProperty(value = "返回日期") + private Date returnDate; + @ApiModelProperty(value = "返修分析的问题") + private String problemsAnalyzed; + @ApiModelProperty(value = "返修分析的原因") + private String reason; + @ApiModelProperty(value = "处理方法") + private String processingMethod; + @ApiModelProperty(value = "备注") + private String remarks; + @ApiModelProperty(value = "创建时间") + private Date createTime; + @ApiModelProperty(value = "更新时间") + private Date updateTime; + @ApiModelProperty(value = "新SN_ID") + private String newSnId; + @ApiModelProperty(value = "深度") + private Integer depth; + +} diff --git a/integration-front/src/main/java/top/kuanghua/integrationfront/entity/Repair.java b/integration-front/src/main/java/top/kuanghua/integrationfront/entity/Repair.java new file mode 100644 index 0000000..87f0447 --- /dev/null +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/entity/Repair.java @@ -0,0 +1,70 @@ +package top.kuanghua.integrationfront.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.extension.activerecord.Model; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** + * 售后维修表实体类 + * + * @author 熊猫哥 + * @since 2022-06-25 10:32:12 + */ +@Data +@ApiModel("售后维修表") +@TableName(value = "tb_repair") +public class Repair extends Model { + @ApiModelProperty(value = "ID") + private Integer id; + @ApiModelProperty(value = "SN_ID") + private String sn; + @ApiModelProperty(value = "设备类型") + private Integer equipType; + @ApiModelProperty(value = "换件_ID") + private String replacementId; + @ApiModelProperty(value = "快递信息ID") + private String expressId; + @ApiModelProperty(value = "问题归类id") + private String problemClassificationId; + @ApiModelProperty(value = "目前状态") + private Integer currentStatus; + @ApiModelProperty(value = "问题描述") + private String problemDescription; + @ApiModelProperty(value = "反馈时间") + private Date feedbackTime; + @ApiModelProperty(value = "提出人") + private String proposer; + @ApiModelProperty(value = "联系方式") + private String contactInfo; + @ApiModelProperty(value = "回收日期") + private Date recoveryDate; + @ApiModelProperty(value = "返回日期") + private Date returnDate; + @ApiModelProperty(value = "返修分析的问题") + private String problemsAnalyzed; + @ApiModelProperty(value = "返修分析的原因") + private String reason; + @ApiModelProperty(value = "处理方法") + private String processingMethod; + @ApiModelProperty(value = "备注") + private String remarks; + @ApiModelProperty(value = "创建时间") + private Date createTime; + @ApiModelProperty(value = "更新时间") + private Date updateTime; + + /** + * 获取主键值 + * + * @return 主键值 + */ + @Override + protected Serializable pkVal() { + return this.id; + } +} diff --git a/integration-front/src/main/java/top/kuanghua/integrationfront/entity/Replacement.java b/integration-front/src/main/java/top/kuanghua/integrationfront/entity/Replacement.java new file mode 100644 index 0000000..bcb7bfe --- /dev/null +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/entity/Replacement.java @@ -0,0 +1,46 @@ +package top.kuanghua.integrationfront.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.extension.activerecord.Model; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** + * 换件表实体类 + * + * @author 熊猫哥 + * @since 2022-06-25 10:32:12 + */ +@Data +@ApiModel("换件表") +@TableName(value = "tb_replacement") +public class Replacement extends Model { + @ApiModelProperty(value = "ID") + private Integer id; + @ApiModelProperty(value = "SN_ID") + private String sn; + @ApiModelProperty(value = "设备类型;0:T-BOX,1:VCI") + private Integer equipType; + @ApiModelProperty(value = "新SN_ID") + private String newSnId; + @ApiModelProperty(value = "深度") + private Integer depth; + @ApiModelProperty(value = "创建时间") + private Date createTime; + @ApiModelProperty(value = "更新时间") + private Date updateTime; + + /** + * 获取主键值 + * + * @return 主键值 + */ + @Override + protected Serializable pkVal() { + return this.id; + } +} diff --git a/integration-front/src/main/java/top/kuanghua/integrationfront/entity/Role.java b/integration-front/src/main/java/top/kuanghua/integrationfront/entity/Role.java index cdf87aa..a950502 100644 --- a/integration-front/src/main/java/top/kuanghua/integrationfront/entity/Role.java +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/entity/Role.java @@ -7,6 +7,7 @@ import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; + import java.io.Serializable; import java.util.Date; diff --git a/integration-front/src/main/java/top/kuanghua/integrationfront/excel/cv/VciTimeCv.java b/integration-front/src/main/java/top/kuanghua/integrationfront/excel/cv/VciTimeCv.java index 35b0ebf..fcec3ee 100644 --- a/integration-front/src/main/java/top/kuanghua/integrationfront/excel/cv/VciTimeCv.java +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/excel/cv/VciTimeCv.java @@ -5,7 +5,7 @@ import com.alibaba.excel.metadata.data.ReadCellData; import com.alibaba.excel.metadata.data.WriteCellData; import com.alibaba.excel.metadata.property.ExcelContentProperty; -import top.kuanghua.khcomomon.utils.ObjectUtilsSelf; +import top.kuanghua.commonpom.utils.SelfObjUtils; import java.text.SimpleDateFormat; import java.util.Date; @@ -22,7 +22,7 @@ public Date convertToJavaData(ReadCellData cellData, ExcelContentProperty conten @Override public WriteCellData convertToExcelData(Date value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception { - return new WriteCellData<>(ObjectUtilsSelf.formatDateTime(value)); + return new WriteCellData<>(SelfObjUtils.formatDateTime(value)); } } \ No newline at end of file diff --git a/integration-front/src/main/java/top/kuanghua/integrationfront/mapper/PairmentMapper.java b/integration-front/src/main/java/top/kuanghua/integrationfront/mapper/PairmentMapper.java new file mode 100644 index 0000000..f08bfde --- /dev/null +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/mapper/PairmentMapper.java @@ -0,0 +1,18 @@ +package top.kuanghua.integrationfront.mapper; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import org.apache.ibatis.annotations.Param; + +import java.util.Map; + +/** + * 多表中实体类的注释Mapper + * + * @author 熊猫哥 + * @since 2022-06-25 10:32:12 + */ +public interface PairmentMapper { + Page selectPairment(Page pagination, @Param("params") Map params); + + Map selectByKey(@Param("sn") String sn); +} diff --git a/integration-front/src/main/java/top/kuanghua/integrationfront/mapper/RepairMapper.java b/integration-front/src/main/java/top/kuanghua/integrationfront/mapper/RepairMapper.java new file mode 100644 index 0000000..c39c4e6 --- /dev/null +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/mapper/RepairMapper.java @@ -0,0 +1,14 @@ +package top.kuanghua.integrationfront.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import top.kuanghua.integrationfront.entity.Repair; + +/** + * 售后维修表Mapper + * + * @author 熊猫哥 + * @since 2022-06-25 10:32:12 + */ +public interface RepairMapper extends BaseMapper { + +} diff --git a/integration-front/src/main/java/top/kuanghua/integrationfront/mapper/ReplacementMapper.java b/integration-front/src/main/java/top/kuanghua/integrationfront/mapper/ReplacementMapper.java new file mode 100644 index 0000000..1fbe496 --- /dev/null +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/mapper/ReplacementMapper.java @@ -0,0 +1,14 @@ +package top.kuanghua.integrationfront.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import top.kuanghua.integrationfront.entity.Replacement; + +/** + * 换件表Mapper + * + * @author 熊猫哥 + * @since 2022-06-25 10:32:12 + */ +public interface ReplacementMapper extends BaseMapper { + +} diff --git a/integration-front/src/main/java/top/kuanghua/integrationfront/service/PairmentService.java b/integration-front/src/main/java/top/kuanghua/integrationfront/service/PairmentService.java new file mode 100644 index 0000000..1f457a9 --- /dev/null +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/service/PairmentService.java @@ -0,0 +1,76 @@ +package top.kuanghua.integrationfront.service; + +import com.alibaba.fastjson.JSON; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import top.kuanghua.commonpom.entity.SelfCommonParams; +import top.kuanghua.integrationfront.entity.Pairment; +import top.kuanghua.integrationfront.entity.Repair; +import top.kuanghua.integrationfront.entity.Replacement; +import top.kuanghua.integrationfront.mapper.PairmentMapper; +import top.kuanghua.integrationfront.mapper.RepairMapper; +import top.kuanghua.integrationfront.mapper.ReplacementMapper; + +import javax.annotation.Resource; +import java.util.Map; + +/** + * 多表中实体类的注释Service + * + * @author 熊猫哥 + * @since 2022-06-25 10:32:12 + */ +@Service +public class PairmentService { + + @Resource + private PairmentMapper pairmentMapper; + + @Resource + private RepairMapper repairMapper; + @Resource + private ReplacementMapper replacementMapper; + + + public Page selectPairment(SelfCommonParams commonParams, Map repairVo) { + return pairmentMapper.selectPairment(new Page(commonParams.getPageNum(), commonParams.getPageSize()), repairVo); + } + + public Map selectByKey(String pairment) { + return pairmentMapper.selectByKey(pairment); + } + + @Transactional + public void insert(Pairment pairment) { + this.repairMapper.insert(JSON.parseObject(JSON.toJSONString(pairment), Repair.class)); + this.replacementMapper.insert(JSON.parseObject(JSON.toJSONString(pairment), Replacement.class)); + } + + @Transactional + public void updateByKey(Pairment pairment) { + //售后维修表 + Repair repair = JSON.parseObject(JSON.toJSONString(pairment), Repair.class); + QueryWrapper repairWrapper = new QueryWrapper<>(); + repairWrapper.eq("sn", pairment.getSn()); + this.repairMapper.update(repair, repairWrapper); + //换件表 + Replacement replacement = JSON.parseObject(JSON.toJSONString(pairment), Replacement.class); + QueryWrapper replacementWrapper = new QueryWrapper<>(); + replacementWrapper.eq("sn", pairment.getSn()); + this.replacementMapper.update(replacement, replacementWrapper); + } + + @Transactional + public void deleteByKey(String sn) { + //repair + QueryWrapper repairWrapper = new QueryWrapper<>(); + repairWrapper.eq("sn", sn); + this.repairMapper.delete(repairWrapper); + //replacement + QueryWrapper replacementWrapper = new QueryWrapper<>(); + replacementWrapper.eq("sn", sn); + this.replacementMapper.delete(replacementWrapper); + } +} diff --git a/integration-front/src/main/java/top/kuanghua/integrationfront/service/UserService.java b/integration-front/src/main/java/top/kuanghua/integrationfront/service/UserService.java index 2e9ff69..4fc0708 100644 --- a/integration-front/src/main/java/top/kuanghua/integrationfront/service/UserService.java +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/service/UserService.java @@ -8,12 +8,12 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.ObjectUtils; -import top.kuanghua.feign.tyauth.feign.TokenFeign; +import top.kuanghua.authpom.service.TokenService; import top.kuanghua.integrationfront.entity.User; import top.kuanghua.integrationfront.mapper.UserMapper; -import top.kuanghua.khcomomon.entity.ResResult; -import top.kuanghua.khcomomon.utils.CodecUtils; -import top.kuanghua.khcomomon.utils.ObjectUtilsSelf; +import top.kuanghua.integrationfront.utils.CodecUtils; +import top.kuanghua.commonpom.utils.SelfObjUtils; + import javax.annotation.Resource; import java.util.HashMap; @@ -32,11 +32,10 @@ public class UserService { @Resource private UserMapper userMapper; -// @Resource -// private ExcelFeign excelFeign; + @Resource + private TokenService tokenService; @Resource - private TokenFeign tokenFeign; @Autowired private StringRedisTemplate stringRedisTemplate; @@ -105,7 +104,7 @@ public void loginOut() { // // //去ty-execl中查询用户名是否存在 // ResResult resResult = excelFeign.selectExcelByUser(username); -// List list = ObjectUtilsSelf.parseResToList(resResult); +// List list = ObjSelfUtils.parseResToList(resResult); // if (list.size() == 0) { // throw new RuntimeException(MessageFormat.format("考勤表中不存在用户名【{0}】", username)); // } @@ -113,7 +112,7 @@ public void loginOut() { // //校验验证码 // String codeInfo = stringRedisTemplate.opsForValue().get("email.code.routing.name" + email); // Map map = JSON.parseObject(codeInfo); -// if (ObjectUtilsSelf.isEmpty(map)) { +// if (ObjSelfUtils.isEmpty(map)) { // throw new RuntimeException("验证码失效,请重新获取"); // } // if (!Objects.equals(map.get("code"), code)) { @@ -156,9 +155,8 @@ public HashMap loginValid(User user) { HashMap hm = new HashMap<>(); hm.put("username", resUser.getUsername()); hm.put("email", resUser.getEmail()); - ResResult resResult = tokenFeign.generateToken(hm); - - hm.put("jwtToken", resResult.getData()); + String generateToken = tokenService.generateToken(hm); + hm.put("jwtToken", generateToken); return hm; } @@ -169,7 +167,7 @@ public void changePassword(String username, String oldPassword, String newPasswo .eq("username", username); User resUser = this.userMapper.selectOne(qw); - if (ObjectUtilsSelf.isEmpty(resUser)) { + if (SelfObjUtils.isEmpty(resUser)) { throw new RuntimeException("用户不存在"); } if (!resUser.getPassword().equals(CodecUtils.md5Hex(oldPassword, resUser.getSalt()))) { @@ -198,7 +196,7 @@ public void insertUser(String username) { .eq("username", username); User resUser = this.userMapper.selectOne(qw); - if (ObjectUtilsSelf.isEmpty(resUser)) { + if (SelfObjUtils.isEmpty(resUser)) { //添加盐设置密码为md5 User user = new User(); user.setPassword("123456"); diff --git a/ty-common/src/main/java/top/kuanghua/khcomomon/utils/CodecUtils.java b/integration-front/src/main/java/top/kuanghua/integrationfront/utils/CodecUtils.java similarity index 88% rename from ty-common/src/main/java/top/kuanghua/khcomomon/utils/CodecUtils.java rename to integration-front/src/main/java/top/kuanghua/integrationfront/utils/CodecUtils.java index 48d5407..84b2d66 100644 --- a/ty-common/src/main/java/top/kuanghua/khcomomon/utils/CodecUtils.java +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/utils/CodecUtils.java @@ -1,7 +1,7 @@ -package top.kuanghua.khcomomon.utils; +package top.kuanghua.integrationfront.utils; import org.apache.commons.codec.digest.DigestUtils; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import java.util.UUID; diff --git a/integration-front/src/main/java/top/kuanghua/integrationfront/vo/PairmentVo.java b/integration-front/src/main/java/top/kuanghua/integrationfront/vo/PairmentVo.java new file mode 100644 index 0000000..2bd6729 --- /dev/null +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/vo/PairmentVo.java @@ -0,0 +1,29 @@ +package top.kuanghua.integrationfront.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Date; + +/** + * 多表中实体类的注释实体类 + * + * @author 熊猫哥 + * @since 2022-06-25 10:32:12 + */ +@Data +@ApiModel("多表中实体类的注释") +public class PairmentVo { + @ApiModelProperty(value = "目前状态") + private Integer currentStatus; + @ApiModelProperty(value = "回收日期") + private Date recoveryDate; + @ApiModelProperty(value = "联系方式") + private String contactInfo; + @ApiModelProperty(value = "设备类型") + private Integer equipType; + @ApiModelProperty(value = "深度") + private Integer depth; + +} diff --git a/integration-front/src/main/resources/application-db.yml b/integration-front/src/main/resources/application-db.yml new file mode 100644 index 0000000..b1abd47 --- /dev/null +++ b/integration-front/src/main/resources/application-db.yml @@ -0,0 +1,45 @@ +spring: + datasource: + driver-class-name: com.p6spy.engine.spy.P6SpyDriver + url: jdbc:p6spy:mysql://${envpt.mysqlIp}:${envpt.mysqlPort}/micro-service-plus?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8&useSSL=false + username: root + password: root123 + hikari: + connection-timeout: 60000 + validation-timeout: 3000 + idle-timeout: 60000 + login-timeout: 5 + max-lifetime: 60000 + maximum-pool-size: 10 + minimum-idle: 10 + read-only: false + +mybatis-plus: + mapper-locations: classpath:/mapper/*Mapper.xml + #实体扫描,多个package用逗号或者分号分隔 + #typeAliasesPackage: top.kuanghua.tyuser.entity + #typeEnumsPackage: com.baomidou.springboot.entity.enums + global-config: + #刷新mapper 调试神器 + db-config: + #主键类型 0:"数据库ID自增", 1:"用户输入ID",2:"全局唯一ID (数字类型唯一ID)", 3:"全局唯一ID UUID"; + id-type: AUTO + #字段策略 0:"忽略判断",1:"非 NULL 判断"),2:"非空判断" + field-strategy: not_empty + #驼峰下划线转换 + column-underline: true + #数据库大写下划线转换 + #capital-mode: true + #逻辑删除配置 + logic-delete-field: deleted # 逻辑已删除值(默认为 1) + logic-delete-value: 1 # 逻辑已删除值(默认为 1) + logic-not-delete-value: 0 # 逻辑未删除值(默认为 0) + db-type: mysql + refresh: true + #自定义填充策略接口实现 + #meta-object-handler: com.baomidou.springboot.xxx + #自定义SQL注入器 + sql-injector: com.baomidou.mybatisplus.extension.injector.methods.LogicDeleteByIdWithFill + configuration: + map-underscore-to-camel-case: true + cache-enabled: false \ No newline at end of file diff --git a/integration-front/src/main/resources/application-rabbit.yml b/integration-front/src/main/resources/application-rabbit.yml new file mode 100644 index 0000000..e3421c2 --- /dev/null +++ b/integration-front/src/main/resources/application-rabbit.yml @@ -0,0 +1,8 @@ +spring: + rabbitmq: + host: ${envpt.rabbitIp} + port: ${envpt.rabbitPort} + username: Kuanghua8866 + password: Kuanghua8866 + virtual-host: / + publisher-confirm-type: correlated \ No newline at end of file diff --git a/integration-front/src/main/resources/application-redis.yml b/integration-front/src/main/resources/application-redis.yml new file mode 100644 index 0000000..b193c8b --- /dev/null +++ b/integration-front/src/main/resources/application-redis.yml @@ -0,0 +1,4 @@ +spring: + redis: + host: ${envpt.redisIp} + port: ${envpt.redisPort} \ No newline at end of file diff --git a/integration-front/src/main/resources/application-seata.yml b/integration-front/src/main/resources/application-seata.yml new file mode 100644 index 0000000..0d5c50c --- /dev/null +++ b/integration-front/src/main/resources/application-seata.yml @@ -0,0 +1,26 @@ +#seata +seata: + enabled: true + enable-auto-data-source-proxy: true + application-id: product-server + #需要和nacos中配置保持一致config.txt service.vgroupMapping.product-server-group=default + tx-service-group: product-server-group + config: + type: nacos + nacos: + #需要和server在同一个注册中心下 + serverAddr: 8.135.1.141:8848 + #需要server端(registry和config)、nacos配置client端(registry和config)保持一致 + group: SEATA_GROUP + userName: "jzfai" + password: "123456" + registry: + type: nacos + nacos: + #需要和server端保持一致,即server在nacos中的名称,默认为seata-server + application: seata-server + server-addr: 8.135.1.141:8848 + #需要server端(registry和config)、nacos配置client端(registry和config)保持一致 + group: SEATA_GROUP + userName: "jzfai" + password: "123456" \ No newline at end of file diff --git a/integration-front/src/main/resources/application.yml b/integration-front/src/main/resources/application.yml index e69de29..4864d15 100644 --- a/integration-front/src/main/resources/application.yml +++ b/integration-front/src/main/resources/application.yml @@ -0,0 +1,2 @@ +server: + port: ${envpt.tomcatPortPre}0106 \ No newline at end of file diff --git a/integration-front/src/main/resources/bootstrap.yml b/integration-front/src/main/resources/bootstrap.yml index 98d883d..cb9d248 100644 --- a/integration-front/src/main/resources/bootstrap.yml +++ b/integration-front/src/main/resources/bootstrap.yml @@ -2,40 +2,9 @@ spring: application: name: @project.artifactId@ profiles: - active: @activatedProperties@ + active: @activatedProperties@,main,db,redis cloud: nacos: - config: - enabled: true - namespace: @nacosNamespace@ - group: @nacosGroup@ - username: @nacosUsername@ - password: @nacosPassword@ - server-addr: @nacosIpPort@ - prefix: @project.artifactId@ - file-extension: yml - # 用于共享的配置文件 - shared-configs: - - data-id: application-main.yml - group: @nacosGroup@ - refresh: true - extension-configs: - - data-id: @project.artifactId@.yml - group: @nacosGroup@ - refresh: true - - data-id: application-rabbit.yml - group: @nacosGroup@ - refresh: true - - data-id: application-redis.yml - group: @nacosGroup@ - refresh: true - - data-id: application-db.yml - group: @nacosGroup@ - refresh: true - #get seata config need after db config - - data-id: application-seata.yml - group: @nacosGroup@ - refresh: true discovery: namespace: @nacosNamespace@ group: @nacosGroup@ @@ -44,7 +13,3 @@ spring: server-addr: @nacosIpPort@ weight: @nacosWeight@ - - -server: - port: ${envpt.tomcatPortPre}0106 \ No newline at end of file diff --git a/integration-front/src/main/resources/mapper/AdminMapper.xml b/integration-front/src/main/resources/mapper/AdminMapper.xml index e0c5a4e..e512173 100644 --- a/integration-front/src/main/resources/mapper/AdminMapper.xml +++ b/integration-front/src/main/resources/mapper/AdminMapper.xml @@ -1,21 +1,22 @@ - + - - - - - - - - - - - - - id, + + + + + + + + + + + + + id + , status, add_time, is_super, @@ -28,47 +29,47 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - select from tb_admin diff --git a/integration-front/src/main/resources/mapper/PairmentMapper.xml b/integration-front/src/main/resources/mapper/PairmentMapper.xml new file mode 100644 index 0000000..aa40eae --- /dev/null +++ b/integration-front/src/main/resources/mapper/PairmentMapper.xml @@ -0,0 +1,57 @@ + + + + + + + + + + + + + repair + . + current_status + ,repair.recovery_date,repair.contact_info,repair.equip_type,replacement.depth + + + + + + + \ No newline at end of file diff --git a/nacos_config_export_20220115133818.zip b/nacos_config_export_20220115133818.zip deleted file mode 100644 index d0eca68f1a8888f3ed438b34f29ec777da6133db..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 16104 zcmeHuWl){V)+X-m9tiHTvEaIK*8suY-6c2#cbDMqZoyrG1}8W{g9ZpPD2Zx&`xSN(F&mBfS8xN5 zSn1PJB7E^u$=7(|n%d^zZ(qMYi>C?9^UDDdyvJR#Q@sU!ALbY0fRLaRVN76E zxgmGxgV@e(=vzY@P3f*6UvBr$NwbnssxE3S*tM4ChWc?%(h=9tBxPnhdBo_JFf?)*u_LfP#-Rq|v{4RKh1VIVy*^aAp88d5V4|IWedbAISSTN8WOwuBJj=U$b8B zuj?xNL>U{i+(Frj^|4N2lqhvF8S7Ef3MTXVMIr3M-qmcxR|u|;-RW=MlBuVCsTjXc zAdiqnp{F{6Dh*VpS#_8#3QOcX)+dc~sxI2i9*KXMIwC@-iB(OWhqf>V(oC-L^2(gw zuUzzT+T~;ezzL$ty7Q(>BL&}Hi4h_}AIh3H)WIsPJ2$0Y_NL$gHQ+9HLDyrXb#?nq zXLT`M8qhTp+J0ou-{8bP^Z?8^*m@s+Y{Ba!=i@BLohQki$~HtNej3~3Ep1+%;fclV zY}WfipdB>9XNKME-YTw5wIo4M?~Rh07d!KgG}fv5`&{fZOHi?_&TNJC{-GJq-{2$4 z;0uPZDD^z*!uUR)j~Ff4YD|)p(77 z{vpnkX%!-D9jmyz#Q1pn3NH)5gv$X+9Y0Q`wM99m1RhILfm#IPC6F4g!>=m`y*CyEajC&jH)Bv- z&%K++CaoEQnPrAJ^rPMNT}a9Sat3L(ff-9nK>@~#i-gPcdw&WSC$B3~W(w&{m^J88 z{4?kvJ>ygSS6nJ|6brqn*>Ew^W7Y2vv_qT{_P4kI;%gs-)s{RMbU2UZ4QI09lq8-t z64+}D>BG~etE(X}38{J^$pu@JlKOj@l`W7VA;aW4()GI<0!RiVjEiH+TMIc@Og?co zm}(&hIP#F2vC42FzUReexS&`MUX*W7tyI&w2_8B2XR|q_th`X>S$4^4vlt~LntgLT z7xZOgQo-uB$a&324Wu>eola%qGRMSyLd5OETQv>rK1f&V<@*JCLXciRZn_*GPG!RZ z{Ytz?T#jqu=^nLu?`nk(!`E$an|FuS3CqoIxRtP4qe!pz^cCFZ(-2PD8I5gjZkB|b zV@{wZ$qGE_#9zN4I0OkiIHXGxL64@9HR}c95mN3+dmPSs?>z54)kZ8j-isYdrdYV( z!q|W>5{PeYy)V;V!3a$AZiaKRO*+%R6!m0PyW#esl@#5w5UcMy-cmT?_|nzFe-3~B zrrSax4bnj@xSNipfN9|49^L*Yku1_!S@gi3fQSVOHf4IgW1d<2648l#rb1^96j{&vSmy{=L|x)M|7nYEP+K4x8{z=`HWRt6BB>Gat0xOnX>Rr z1m9!UGr8WwNX_&w=a8mgJkaIpbb;!bfFbe-{j~WWR3Tt`N~j$)eoC1?IuCX@fq0No zriD-iPUHh4vAilAAfsdyR0Xm`x{Iuz_!@i{Bz009&LXxuoOP_%e}Uo+_pv9rB;rlN z(!*SOV*?%5oB>H8-vzWtd&>u^g!UueYER_1dCQ9gZ+*QVk7=uGmfew@M#`gGHJ4A3 ziNd-U1$+*giJDa~=K7qq;~RAMpl=nRiTifqLiXnuVfR)an<68@`ua9;ifAB>q9^kw zOV`-J!D$-r3L9UXjFm&$h4y&4qV=h`c-LMMh|FAj;d%kMI79R`O;FHr+LKzVx07jQ zLJK6>8<{9m(!&w@2STiY^e~JTZDpa23GSDfRD5U7$oKajjz@=2i@RCHILHR%L-V^T z{0q8M&GgeC{b8|Pu=oV03UuS_O_Py4_928x-|ar*!RRxI2%H7#LFIXR=2au8kR_M~ zpi@f=11Hnq6vOPeZJtww6z5idDb>*~S94Kt*%gzZsM_hgUwOnvV&fK!u~cl5s^kMc z{q0;9B}Dq-VOTG|_}uyGUa<}mTur;|k&QmnCPawDoUaUl`789^l!tuiy<>NEui^(? zO!1clWuOPs-6^T5aQSm&!P~nXuYzAhI)Rc%%)kuJOQgEyL*SDO7H~3K&Xa~3>_YU$ z7?ot;AV|(UQ{A<<7P!wmJ5*DKM~}GJQD298V+4I0UND4&mEN0@*Qo|mhmf{;?@pyY zgcgd^#SqjVtW)9h8!ysO6dn#fabgklU-2Tv-|(Wnp1!`B<2P=!8skOkW2ctX))QA>k@vu^+$e#D5op*z*kF~RL$}lbWe3wG?UA4kfO0pbs z3L~|a(@GTGAb#i2-?+XwWb^s!ry2J>egB;6$^ULmMuuh%-(C{HCR zGeiefi-Ey%7A94OpYN?H9wsqNyMb6bL`GKvAnG)wUfR9w;MG{ z*)eb`cKXQ4W+Il!+jhEFqN-SFqX~)Hx|5#ftv#F!-67Qjpe62N=H2^d-UY59=Mr5) zm?O{gF|S%~04;Ve7>t)=07@`?aohw}m$vN|`A`^C0>Cs4wThMRw6A_LW)k%S>gYJF zOV37Tu{UaLA(~{})T{NyjhE)QT1^8KWFPHgmtG`(fk+5nvWt#}U&|lpKi1l-MU5qU z@ZWYWCn`Jndda_7pK*0;fBspes?DQC$D?xJ#->sG4(G7aXVsj?s(rP){#{3+@pzxl zT4jU9GmVHv_1caT{vzjNHGZu8_Ezk>dtnnJ%pT0wsSi47f=5S`P=eN|hQ4Woq#6D? zOpse%87W_Uv@nYjlv($OgrZJh3(#px3#TcGp&O(0J_+;CV~859yQgv; zhWO4d_Bf2j65rxFC^A8(Q4S1$U<@7uWW&6Pe`z9)*BLaKN41Ns!v0ZO;eK8|M`*ZN z)QuqozjJ*gzOnm>Cr%zrrJse!fOYeYfoYhN5#@)pasP z#Qs!j#}htbp~8%s`QtO|;L>$W$W+YGHnPs@PGf5l<%+nG$B9Ar?u59Rw@`7IeK1+i z>+N(g?YK&nAeS6D4;W-ub9AT6AdNjkl8Bf5N03~2L94;^8uZ*K2$+?9>l*OZ6DzFh zkk$PBGbUs9wlJi|PCuvH4Yrb}PWX$bEZZvS#f=JOHt!WseAwjonp%8V@oAfLZ$IE)gwK4Zus-uHfr=ba zNs&Zh5)AMW%E_??=SahaSof8#6{L7&$C=NHbe?;Wxpc4pF724V%h+w)&eydWr>2W% z-?*tvKOw0f90Y_1_OG}J{|~t7i52vm98G^?Bw2bIDf*h<7-^7^rdmaN z&HLy>1n8{0i%}lLfvMPVjdD%{VVU~Fsou7W@F@`$NTa}AfD8W$_vM0LAfwtPPuA?2 zqu0`igw)!}Cs#g??ytNV#BuSMqX-yv!~t)8K|@$rK+*c);N+Yg`Ciqa}|HhCYlUEx(Pb;1JONRV8Q*|_QaQrb<{U<2@Cn*0XDE}uY{|^hw zDStX7ej&#H7o+l@GmT#t^?xKR|HDJ)*SNe~RZ|XM48vP&gFjq4A7U$_InS+11S2#j zkA^yAL}@m-`pY~~_3Fa-_@a6UbZW8`e5g{OyeXN+ta2SHg^GAKN_W<2#ZloyVCD*& zZW~my)!dZ3$+%I6gYh`W07MKZ>d_%_??)lv5M^z)34)u{nPd7eb2>gc(}$%mpEAag z9!>E4K1ocFRoF>gcECs|!oEx`jj}B}#hKmEO5Rm6eceM+L8(54rp!{o0SDWBs*+c@ zdw`#`1M}&*vv-FEmm{3m)w<2BVs#6L4&QxW%9=&F8t;5{V*^cER7P(1*zi#8a490e zQs68Mpyko~og%$gQF^@laIl!Ocj1-kE*Il$JNWK|jYSyk9s{Iuy~~G;sU@FJ5LVN~ zN?M}airf#V!UC;dd*ZH;X>$$YvZB0SOa_UqC7pagJl?LUZP;pCZYdLEi!e!O0>N|~ zDl!I!Vqn$DgQ=|hk>ehN!d?bwSTr&FH_7%yjan`OgfJA5>8Uyg{o@RB(aVhsHKe`S zd02Q}EXQZDW+<4VIU|%v|ZpuLd38<<=vox++qb~&!5?3mC1rgKU)r)2x|wcGvx2N|6S1q;z8_YUeNWpW~Jx2o;bN!Z0=O*fYX9 zjjbB=V@Kmx%8dp3QCLq&LrS1yjOiRCf=EY=kH*6jOWrQAym{FjFFccNN8ymE0GPUW^}f=Q8CQlxgH=H1IR}``VOG_=Mtr4gX{CZc$(>b`cj|QXs#UV?$)P6 zta}@e6E7#bwT}fC^`W&7wdcm=?zeFnYry@6a~rL<$oZEP(l{t$nI7_DD=M${ zcdBdK8J8~3r*`>OwuujRSYdVki@8FGSC;W&I2WMbWR|r+4&OR+Lh4I9i7@eUTUbnXE6KXt}%wt;|MG9 zPDvik@1TZlQmb?hYYl?OlQrm~r!AJ)f5Z7^vhl8xb6R;|MZzHN<0rogy!20JZ;X)~ z@umf=4#{g!T2Ur+6Ewi^5{=xoYLz)_ZGB!PM4%_Rs#SMjXKd=51V_!)?oTzBurmDy1KH&E+QsN``{!T+(!15>Bjm;J!u)soHgr(IoljlpRu*qN z?hjjs=Nj7EG~DV<7zsHUwWatF-A#hO6yo^d?}g2BsJup6kWf2|{**Yf3f^e*Wo}v- zS)<^!VRC3S>1%{A@b%F13=$JPeg0z~DxAvQ){2NrBJ$dYAP89wZ7x3LHnfb{*xCjg z>_j0wov$0mqHK>sbUxRstMslPrk44?Whw)hGg0$T$`AnIuQC;aKRSf|Q&W{^fATVn zT=lGMEq_yTtfEI`@tHA#zQmj%C3e@~^~Es-lnslD3uuZOs;&@6IV3ZuR8wB1Xce{W z<-AHLK@-wfQh8O6kAf^PGJ^74)hm!IGeBE;Dc0!m(dY1dmIWQXVk;)ZXSI!zOb!>i z8=b;{xM)xWv)9mAuUPdqP$kx{z7&%Mds!A{lOTK{c*wd^CNmJfb&Rn62wA1+B&z#b zw-f;9zsf(yV2e0U!5DR5kvurakCk>`_o7>n=TKmh_tOdCA=_{?YPDwfoNhxr=Dj~{jx|b?V>TB){30#8Mz>Q zXSd6`qNW?9eR6Iv%_ai(RYmT)Q^xHD_P33&3LU0a2?_$@@>D+hugi(Q1TI#3X4c=5 zcQ54?S$r{^cCigYU=H??C}AtZ`$NJK`7jK)=WU&b?v_!>8BQ+7#pNZ60?c-jog(Xn zGU%~1WHD2C{)>v81#T%BE0>s+?`=#7pv42|%bh1&#&3+r?@&6_W9B}i2(e>rVQmXK zmFT~%WNE%LrAQj`N|Ca#mhqfWyo-A#K{KdD{K!f?>fTW&&zD6gMUsV4)Fhh=3j`!S zdsj?ixumR3JB5&oM~MGShWS%7(%gKR9NmTJn+W0nm>wZTF_c5@?E`6kV*JPDF;Dg{ z700^cr}emPCYRfvY+MKL#FEu$6tw+{e0N>j#HFz8vx|##Up8dZS$FpIk9Y6pY=E;V zIpH>4?OU8Kc-MI`9ugEsI03O>!<;k4G!d=x-$huYijdc$=xWnIb8gNNQ`6AUq2OYx z(eyUT`_2o(4th;H19-gAd0#5=KN4k@T{%BQK3j`WW6wQOt#g3L+Fb$8tkUU8cz3cD z;j+5bWAIyKxSaUMxYrXL@xe}H;){K}o@wCCB$)NJyf!~^a&58p^wpKzU4d@j#$J~o zJ>*lp1fEU!l7J9BI+u+T`R3VpEGQ8Y1Pxf6?f}Gzd0zRFP(VxVXTu_W&Jk0ofc-RG zvN{*J+meiZ!R>d0ZP#h|2(Q{MnJ%Chg^UtV^cknaj|3tTMY!1b?NZz{dhOcysEjt< zNR6EBdMud0J{n`Rl4mLl5YpF(5e7cOq;_GQ1VCAy4F0KYz5B+OhR(xh_$bocS_c9B zEObt%WCy<9g=1A6_jPoryL^=DqjJXdb=2(E5yN|FHmlS6ffsgL+YJ5`kHFv&HB12f z`6@w-w^fiF6Fc~lSTNWoqdo-;Ug!i-$*oTNIOEVm=KiVz{?TfCeO`M)WL143l1nak zW!(Lvu3ErAAuu=9M)~Vj+K}6{eJAo7pUk4vzTpe&6=;=3Z#*?huwpR*Sk^H?iq|AW zP3)&JY5`w`lcEPmy!;@X*9GrHi@YUEkl^8LLmZ36y+}}{w`-9z-jS-fX_ihAscG0! zUGYK^Fs#&E*}3#gA%?He(`*q?--^T+HbKAun)VzIKjzv2tO17e&(JWvCfKsEuaTPD z(k|G*zQpz3kCNPFB))iU%iNohxNlv2D<$0QYQgHwb^zeXvv8k4jkE&7-Ooz5KmJw_ zAPxbCw|NrX;GzC%2mfvA;b5fasP}CPuPBblc0YAR#C=9av~--Lz+{p^$EFLXeRf*S zZonPQJkLH&?ME9@85oVC*8g#wYVtKjlc{GwRCRvU8Fsp}MsYxbRO_d$Oox*f4m$-h zFfig2ep%_#wgfYs+OQ=oVpWiokVNVtyDGyQGArG1TZm<9CFpoe;b@8=f-U`|i?VvN ziZC`pT0!$Bc>_m_dlkpp?5x>)1qLnyg)%3(y9m}n5iJHEfV+%uDlp|0h%viwBE)@# znnRpM)br0{R584xw!tkW0wHx1LKuZ;Jm&|i%t*`j0V&G1CX1?U*`tsh>Li>&y31T? z8x7pnrGoU_S3Om0b`yKe2S|~GU!R-n^|qDhr^G=p$DxY|j=rfOGs-Wn4&UeH8`D!4 zq3BYf={+3tncMfp#7a;Uk|(WAImIFMW%4WEzH|0=F>>%SAr+#dX@Nr8%UAj;2KibM zRTpHMXNK9UE50duXa@_NEcUCW){O1)$_I}gt1F+_@P@8dK08gBlZTXz&BjuNleuag z|Gsegn8!X)lUr0cUW(;B-^C!;{ z#~@dc5cIsr-|t!EXi!VHsr2w*$J+3v@T`yKRDlTu=BUVs;_E2}lCi?BXPss|$%^n9 zt@WFX;^Gd8WvwY|qvLnZCdO7MFHx#jiG=7F48uKHppEBZlgK8>iU`COnqJ@dc1=`V zU0qzwC+Zs0yrx7r-s{3Ap{5}bJHN)H=!#=;O~->}I4nSr`RtLLCXs0WRPRr-(hy?s zL_a!tyb@}Sj%KpM#xBVxt^7R2dz-64ql%0*O!>|Y9@+$?l<{ggBV+iA@Wg0cfBV{d z`xMK&HSm(E_V&T6U6sDQm>}tPM2vBzuYK{T-KC|NsO|H^Lq|hf(8H8~lZ($ZE$>%( zM$>fAlpQX-*u~N;W_Z>%W|r-TI(Bxx%f5NFxLv#Abm{?b?N&(X= zH4|b$u>v61&CvUo5e39RzIHCA>_`d{KW?-`^-U#GX)&%dJSW2z60%-YI$*df9o~`R z%R$l}eN#KM08t}%DoOges?MIJ8OjtA!8%Q8$u2s&Lb5c%mct|^F_GxEqnxC9NGopo zaMFByMK4pU5jbhfWRIG`lz@*Mtjne<@vHrDi>h574FXjS)eIwI2eV59^+z7t9F)gX zSY2;uo@FT$9Txlb_(>=tM1*-B&`^wh3{81`LQu600puHIK`=1W{~R5rY+?EU0C$sl zJ%;$sCsy9|n5(uU;7;Tf>ofD(X)CeU7^evbI_hGQG7_AjRrV_b;F=ZTR=&_9Dp_>E^aF{EeN3)Ulqmj`bD1G-=j!`vFvU;h z^akRqE3dw+p3Lrst?oE9x)v&`o6GZbZP;0(9pN==7oKC)(-DMY3tNTA>m(iArYf0k zrmej$FbkuZ5fdl-7_LQ1w)iRE3bnkC0SE;Rotja3%9+?zT=5jbMu3|LSHY!)T&Z?S z!&0*~)aQLH;3+3<1HV}9e{b}4vRsPX3AnqjoLOi`orWAmD=d@8=ikHG>07Lso>Fsg zl}GSeViRgFBIPK|9>u1_q`Hj&lwOJjpvTF@N_VHzRO58$(&t1sYILGf-6$rCryeN7 za1gWkV#FbstSIyY;L#kIOxDbrED~(_8WE~Z4m|SlBUJ<3A%RT3fQVye6=@`*KA7St z@Lksc)c_J&HS-#(4;G>W;q&JpA)dW3@m-I}q@=Fkpd^K-j8iPiOz$g;yDnm0TEyQ# zFHdNT2at8jr%3XF7Z}4@zvV5p$pS&QSL)co0ua7yN78O)5$HBYLul#auP(7j3qHPo zM#J5Dyzjn!>f3tO?QuR4)Jl zX@~!-aQ$bQ@n6jOAK4M{v&{Ifm+_Cx_@5^;{u0UjC^KSo{7;#&oTgPBL)Z-rG8@x1QisT_w-pD1$7>%U;G?Sd^{f0wvn^*2eme#iE$ik@jmS` z=ZTwfmvPVCQ4-4h?px#4j8RRI7At)x_DBG?b4Z#Wm%VrrlH9kmx-vCs2ZTYJazGXk+K z&Sq7w&q5onFUjBWVUBrOS`)FZb%bno^z=ixRGg)#M~jTxSs~OXtV77K&)ftRPS!Te!PtJylVBS0fBpsv3{sgr7-KK#lGXes6ixqkCU{-B6?EL zbF^=?NsTh(0_d8vc)W`+h6tCceHkn|fCCU1N9Y&D1~K)^kVO5ltbv@{fD00c|@ zqiyEILwXZv<^0L>Xv}S{ri)ksR4#O$BS9!keh4@Ac)WO{2;oQ(;fUHUVSZ9oZlprU zew(3siEk4{U-&kp@kHFVwzhI}U!*Aa;sium&}s307FyC2tH>Bih&a&qk0z^!knzl=-TO&?VS zI)dkWs*oda|H9JFuciBZx904v+tqWf`Gg4SW(|vRdeQpJrtbX;o<+EVt6YB{U7EYw z;>Z}<6QiT8u8&Q!3;kcQ--*_nxv`+DW(g^$^Z84GXUb#BgGnf5!_K3eAJW;y#QCoj zY7OdT^9d3xeSXfM<$dvj8aEN!24s6!Aqid`a+{IQ=piw_mlP9ow<*ETx3+I+-M%<} z`_bg7Z(d-UH%}`(CSA%^FBz6e4?eLjme4i+)rWGapc@pbU9JXpu1t&QwCTJ#m_t=x z%~b#EG!-vUJ>~!tl?C;r1YX4E4z?Yi*?V6$ystB(s6n+@%$h5AzZEEkAwKHvKB-+j z|CYS@3v>JJ@B2$m-vrJd$A96vpS;wMfZyK^_|~cZ`@nkgx4#7Z zttst4+faO#`|4$_!;y2KKpMy{l5>erykqCnxp-{lK!6|zi-n0aoHh% z0QqYI|1;kAjjrEXdw(C9h`&zpyXyJRK;PTrM+282{Rs3+`O)xi4f0L-`F-@D{|(@O z%_2WqIT_>cK>y4n-*+SYxbkP1e}MV#+2mVx@%s?R`(wa=Agd-xoxFGzU7#-$4GaBjIPvKX*is zC+mE_=3kDPf7cOlss0A=f5#Dz{}%Mm9P#^n^+!i^qW*)4{&yU)lHrd5|9wYnWBg;J tzi`CwgNh#=v5EN)!2WxVc*gcOkl#5X - 4.0.0 @@ -9,24 +9,20 @@ pom 1.0-SNAPSHOT - ty-common - ty-gateway - ty-auth + auth-pom + common-pom + gateway integration-front - ty-example - - + basis-func - org.springframework.boot spring-boot-starter-parent - 2.1.4.RELEASE - + 2.4.13 - Greenwich.SR1 + 2020.0.5 @@ -36,37 +32,32 @@ spring-cloud-dependencies ${spring-cloud.version} pom - import com.alibaba.cloud spring-cloud-alibaba-dependencies - 2.1.3.RELEASE + 2.2.3.RELEASE pom import - - org.springframework.boot spring-boot-starter-test - - com.alibaba - fastjson - 1.2.79 + org.springframework.cloud + spring-cloud-starter-bootstrap - + - io.jsonwebtoken - jjwt - 0.9.0 + com.alibaba + fastjson + 2.0.3 org.projectlombok @@ -77,14 +68,18 @@ joda-time joda-time + 2.10.5 - - org.apache.commons - commons-lang3 - - + + + + + + + + + - dev @@ -102,7 +97,6 @@ test - true @@ -119,19 +113,19 @@ - - - - - - - - - - - - - - + + prod + + prod + 8.135.1.141 + ${baseLinuxIp}:8848 + 1000 + 127.0.0.1 + df87d91b-b1ab-4720-8e1c-5a147edc6ddc + nacos-group-${activatedProperties} + jzfai + 123456 + + diff --git a/springboot-cloud-mapping.json b/springboot-cloud-mapping.json deleted file mode 100644 index c970a57..0000000 --- a/springboot-cloud-mapping.json +++ /dev/null @@ -1,113 +0,0 @@ -{ - "git": { - "branch": "dc8e0454e3d0299e7002610a3f82af001013e959", - "commit": { - "id": "dc8e045", - "time": "2022-01-02T10:10:06Z" - } - }, - "build": { - "version": "0.0.1-SNAPSHOT", - "artifact": "start-site", - "versions": { - "spring-boot": "2.6.2", - "initializr": "0.12.0-SNAPSHOT" - }, - "name": "start.spring.io website", - "time": "2022-01-02T10:11:21.501Z", - "group": "io.spring.start" - }, - "bom-ranges": { - "azure": { - "3.2.0": "Spring Boot >=2.3.0.M1 and <2.4.0-M1", - "3.5.0": "Spring Boot >=2.4.0.M1 and <2.5.0-M1", - "3.10.0": "Spring Boot >=2.5.0.M1 and <2.6.0-M1" - }, - "codecentric-spring-boot-admin": { - "2.4.3": "Spring Boot >=2.3.0.M1 and <2.5.0-M1", - "2.5.5": "Spring Boot >=2.5.0.M1 and <2.6.0-M1" - }, - "solace-spring-boot": { - "1.1.0": "Spring Boot >=2.3.0.M1 and <2.6.0-M1" - }, - "solace-spring-cloud": { - "1.1.1": "Spring Boot >=2.3.0.M1 and <2.4.0-M1", - "2.1.0": "Spring Boot >=2.4.0.M1 and <2.6.0-M1" - }, - "spring-cloud": { - "Hoxton.SR12": "Spring Boot >=2.2.0.RELEASE and <2.4.0.M1", - "2020.0.5": "Spring Boot >=2.4.0.M1 and <2.6.0-M1", - "2021.0.0-M1": "Spring Boot >=2.6.0-M1 and <2.6.0-M3", - "2021.0.0-M3": "Spring Boot >=2.6.0-M3 and <2.6.0-RC1", - "2021.0.0-RC1": "Spring Boot >=2.6.0-RC1 and <2.6.1", - "2021.0.0": "Spring Boot >=2.6.1 and <2.6.3-SNAPSHOT", - "2021.0.1-SNAPSHOT": "Spring Boot >=2.6.3-SNAPSHOT and <2.7.0-M1" - }, - "spring-cloud-gcp": { - "2.0.7": "Spring Boot >=2.4.0-M1 and <2.6.0-M1" - }, - "spring-cloud-services": { - "2.3.0.RELEASE": "Spring Boot >=2.3.0.RELEASE and <2.4.0-M1", - "2.4.1": "Spring Boot >=2.4.0-M1 and <2.5.0-M1", - "3.3.0": "Spring Boot >=2.5.0-M1 and <2.6.0-M1" - }, - "spring-geode": { - "1.3.12.RELEASE": "Spring Boot >=2.3.0.M1 and <2.4.0-M1", - "1.4.13": "Spring Boot >=2.4.0-M1 and <2.5.0-M1", - "1.5.7": "Spring Boot >=2.5.0-M1 and <2.6.0-M1", - "1.6.1": "Spring Boot >=2.6.0-M1 and <2.7.0-M1" - }, - "vaadin": { - "14.8.1": "Spring Boot >=2.1.0.RELEASE and <2.8.0-M1" - }, - "wavefront": { - "2.0.2": "Spring Boot >=2.1.0.RELEASE and <2.4.0-M1", - "2.1.1": "Spring Boot >=2.4.0-M1 and <2.5.0-M1", - "2.2.2": "Spring Boot >=2.5.0-M1 and <2.7.0-M1" - } - }, - "dependency-ranges": { - "native": { - "0.9.0": "Spring Boot >=2.4.3 and <2.4.4", - "0.9.1": "Spring Boot >=2.4.4 and <2.4.5", - "0.9.2": "Spring Boot >=2.4.5 and <2.5.0-M1", - "0.10.0": "Spring Boot >=2.5.0-M1 and <2.5.2", - "0.10.1": "Spring Boot >=2.5.2 and <2.5.3", - "0.10.2": "Spring Boot >=2.5.3 and <2.5.4", - "0.10.3": "Spring Boot >=2.5.4 and <2.5.5", - "0.10.4": "Spring Boot >=2.5.5 and <2.5.6", - "0.10.5": "Spring Boot >=2.5.6 and <2.5.9-SNAPSHOT", - "0.10.6-SNAPSHOT": "Spring Boot >=2.5.9-SNAPSHOT and <2.6.0-M1", - "0.11.0-M1": "Spring Boot >=2.6.0-M1 and <2.6.0-RC1", - "0.11.0-M2": "Spring Boot >=2.6.0-RC1 and <2.6.0", - "0.11.0-RC1": "Spring Boot >=2.6.0 and <2.6.1", - "0.11.0": "Spring Boot >=2.6.1 and <2.6.2", - "0.11.1": "Spring Boot >=2.6.2 and <2.6.3-SNAPSHOT", - "0.11.2-SNAPSHOT": "Spring Boot >=2.6.3-SNAPSHOT and <2.7.0-M1" - }, - "okta": { - "1.4.0": "Spring Boot >=2.2.0.RELEASE and <2.4.0-M1", - "1.5.1": "Spring Boot >=2.4.0-M1 and <2.4.1", - "2.0.1": "Spring Boot >=2.4.1 and <2.5.0-M1", - "2.1.4": "Spring Boot >=2.5.0-M1 and <2.6.0-M1" - }, - "mybatis": { - "2.1.4": "Spring Boot >=2.1.0.RELEASE and <2.5.0-M1", - "2.2.1": "Spring Boot >=2.5.0-M1" - }, - "camel": { - "3.5.0": "Spring Boot >=2.3.0.M1 and <2.4.0-M1", - "3.10.0": "Spring Boot >=2.4.0.M1 and <2.5.0-M1", - "3.13.0": "Spring Boot >=2.5.0.M1 and <2.6.0-M1", - "3.14.0": "Spring Boot >=2.6.0.M1 and <2.7.0-M1" - }, - "picocli": { - "4.6.2": "Spring Boot >=2.4.0.RELEASE and <2.6.0-M1" - }, - "open-service-broker": { - "3.2.0": "Spring Boot >=2.3.0.M1 and <2.4.0-M1", - "3.3.1": "Spring Boot >=2.4.0-M1 and <2.5.0-M1", - "3.4.0-M2": "Spring Boot >=2.5.0-M1 and <2.6.0-M1" - } - } -} \ No newline at end of file diff --git a/ty-auth/src/main/java/top/kuanghua/tyauth/config/BaseConfig.java b/ty-auth/src/main/java/top/kuanghua/tyauth/config/BaseConfig.java deleted file mode 100644 index 1e13944..0000000 --- a/ty-auth/src/main/java/top/kuanghua/tyauth/config/BaseConfig.java +++ /dev/null @@ -1,21 +0,0 @@ -package top.kuanghua.tyauth.config; - -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; - -/** - * @Title: BaseConfig - * @Description: - * @Auther: kuanghua - * @create 2020/8/23 21:52 - */ -/* - * 总结:1.@Configuration 下的@ComponentScan回将包下带有@Component扫描变成配置类, - * 而@SpringBootApplication扫描的只会变成普通类 - * */ -@Configuration -//扫描公用包的配置和自身的配置类 -@ComponentScan(basePackages = {"top.kuanghua.khcomomon"}) -public class BaseConfig { - -} diff --git a/ty-auth/src/main/java/top/kuanghua/tyauth/config/Swagger2Config.java b/ty-auth/src/main/java/top/kuanghua/tyauth/config/Swagger2Config.java deleted file mode 100644 index 0a0c936..0000000 --- a/ty-auth/src/main/java/top/kuanghua/tyauth/config/Swagger2Config.java +++ /dev/null @@ -1,54 +0,0 @@ -package top.kuanghua.tyauth.config; - -import io.swagger.annotations.ApiOperation; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.stereotype.Component; -import springfox.documentation.builders.ApiInfoBuilder; -import springfox.documentation.builders.PathSelectors; -import springfox.documentation.builders.RequestHandlerSelectors; -import springfox.documentation.service.ApiInfo; -import springfox.documentation.service.Contact; -import springfox.documentation.spi.DocumentationType; -import springfox.documentation.spring.web.plugins.Docket; -import springfox.documentation.swagger2.annotations.EnableSwagger2; - -@Component -@EnableSwagger2 //开启在线接口文档 -//配置包扫描 -public class Swagger2Config { - private boolean swagger_is_enable = true; - - @Value("${server.port}") - private String port; - - @Bean - public Docket api() { - return new Docket(DocumentationType.SWAGGER_2) - .enable(swagger_is_enable) - //.host(this.ipAddr + ":" + this.port) - .apiInfo(apiInfo()) - .select() - .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)) - //.apis(basePackage("top.kuanghua.swagger.controller")) - .paths(PathSelectors.any()) - .build(); - } - - /** - * 构建 api文档的详细信息函数 - * - * @return - */ - private ApiInfo apiInfo() { - return new ApiInfoBuilder() - .title("micro-service-plus") - .description("描述:新一代的微服务架构") - .contact(new Contact("jzfai", null, "869653722@qq.com")) - .version("版本号:2.9") - .build(); - } - /** - * http://localhost:8080/swagger-ui.html - */ -} diff --git a/ty-auth/src/main/java/top/kuanghua/tyauth/controller/TestGetTokenController.java b/ty-auth/src/main/java/top/kuanghua/tyauth/controller/TestGetTokenController.java deleted file mode 100644 index e596f80..0000000 --- a/ty-auth/src/main/java/top/kuanghua/tyauth/controller/TestGetTokenController.java +++ /dev/null @@ -1,47 +0,0 @@ -package top.kuanghua.tyauth.controller; - -import com.alibaba.fastjson.JSON; -import lombok.extern.slf4j.Slf4j; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; -import springfox.documentation.annotations.ApiIgnore; -import top.kuanghua.khcomomon.entity.ResResult; - -import java.io.UnsupportedEncodingException; -import java.net.URLDecoder; -import java.util.Map; - -/** - * @Title: TokenController - * @Description: - * @Auther: kuanghua - * @create 2021/1/31 16:31 - */ - -@RestController -@RequestMapping("feignTest") -@Slf4j -public class TestGetTokenController { - /* - * 解析token - * */ - @PostMapping("getTokenInfo") - public ResResult getTokenInfo( - @ApiIgnore @RequestHeader("TOKEN_INFO") String TOKEN_INFO, - @ApiIgnore @RequestHeader("AUTHORIZE_TOKEN") String AUTHORIZE_TOKEN - ) { - Map tokenInfo=null; - try { - tokenInfo = JSON.parseObject(URLDecoder.decode(TOKEN_INFO, "utf-8"), Map.class); - log.info(tokenInfo.toString()); - } catch (UnsupportedEncodingException e) { - e.printStackTrace(); - } - log.info(AUTHORIZE_TOKEN); - return new ResResult().success(tokenInfo.toString()); - } -} - - diff --git a/ty-auth/src/main/java/top/kuanghua/tyauth/service/TokenService.java b/ty-auth/src/main/java/top/kuanghua/tyauth/service/TokenService.java deleted file mode 100644 index 43e0b20..0000000 --- a/ty-auth/src/main/java/top/kuanghua/tyauth/service/TokenService.java +++ /dev/null @@ -1,70 +0,0 @@ -package top.kuanghua.tyauth.service; - -import io.jsonwebtoken.Claims; -import org.springframework.stereotype.Service; -import top.kuanghua.tyauth.utils.JwtUtilsSelf; - -import java.util.Map; - -/** - * @Title: TokenService - * @Description: - * @Auther: kuanghua - * @create 2021/1/31 16:19 - */ -@Service -public class TokenService { - - private static final String AUTHORIZE_TOKEN="AUTHORIZE_TOKEN"; -// @Value("#{'${filter.allowPaths:}'.empty ? null : '${filter.allowPaths:}'.split(',')}") -// private List allowPaths; -// @Value("${jwt-properties.pubKeyPath}") -// private String pubKeyPath; -// @Value("${jwt-properties.priKeyPath}") -// private String priKeyPath; - - -// @PostConstruct -// public void postConstruct(){ -// try { -// String classPath = ResourceUtils.getURL("classpath:").getPath(); -// this.pubKeyPath=classPath+""; -// this.priKeyPath=classPath+""; -// } catch (Exception e) { -// throw new RuntimeException(); -// } -// } - - /* - * 生成token - * */ - public String generateToken(Map map){ - try { - return JwtUtilsSelf.createJWT(map,null); - } catch (Exception e) { - throw new RuntimeException("token生成有误"); - } - } - /* - * 更新token - * */ - public String updateToken(Map map){ - try { - String updateToken = JwtUtilsSelf.createJWT(map, null); - return updateToken; - } catch (Exception e) { - throw new RuntimeException("token更新有误"); - } - } - /* - * 解析token - * */ - public Claims parseToken(String jwtToken){ - try { - Claims claims = JwtUtilsSelf.parseJWT(jwtToken); - return claims; - } catch (Exception e) { - throw new RuntimeException("token解析错误"); - } - } -} diff --git a/ty-auth/src/main/resources/application.yml b/ty-auth/src/main/resources/application.yml deleted file mode 100644 index d3f5a12..0000000 --- a/ty-auth/src/main/resources/application.yml +++ /dev/null @@ -1 +0,0 @@ - diff --git a/ty-common/pom.xml b/ty-common/pom.xml deleted file mode 100644 index e94f862..0000000 --- a/ty-common/pom.xml +++ /dev/null @@ -1,142 +0,0 @@ - - - - micro-service-plus - top.kuanghua - 1.0-SNAPSHOT - - 4.0.0 - - ty-common - - - - org.springframework.boot - spring-boot-starter-web - - - - com.alibaba.cloud - spring-cloud-starter-alibaba-nacos-config - - - com.alibaba.cloud - spring-cloud-starter-alibaba-nacos-discovery - - - - mysql - mysql-connector-java - - - - com.baomidou - mybatis-plus-boot-starter - 3.3.2 - - - p6spy - p6spy - 3.9.1 - - - - org.springframework.boot - spring-boot-starter-data-redis - - - - - - - - org.springframework.cloud - spring-cloud-starter-netflix-hystrix - - - - org.springframework.cloud - spring-cloud-starter-openfeign - - - org.springframework.boot - spring-boot-starter-amqp - - - - - - - - - - - - - - - - - - - - - - - com.github.wxpay - wxpay-sdk - 0.0.3 - - - - org.apache.httpcomponents - httpclient - - - - io.springfox - springfox-swagger2 - 2.9.2 - - - io.springfox - springfox-swagger-ui - 2.9.2 - - - - io.swagger - swagger-annotations - 1.5.21 - - - io.swagger - swagger-models - 1.5.21 - - - - - org.springframework.boot - spring-boot-devtools - - - - com.alibaba.cloud - spring-cloud-starter-alibaba-seata - - - io.seata - seata-spring-boot-starter - - - - - io.seata - seata-spring-boot-starter - 1.4.2 - - - \ No newline at end of file diff --git a/ty-common/src/main/java/top/kuanghua/controller/HstrixController.java b/ty-common/src/main/java/top/kuanghua/controller/HstrixController.java deleted file mode 100644 index fddc203..0000000 --- a/ty-common/src/main/java/top/kuanghua/controller/HstrixController.java +++ /dev/null @@ -1,26 +0,0 @@ -package top.kuanghua.controller; - -import io.swagger.annotations.ApiOperation; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; -import top.kuanghua.khcomomon.entity.ResResult; - -/** - * @Title: hstrixController - * @Description: - * @Auther: kuanghua - * @create 2022-01-08 18:15 - */ -@RestController -public class HstrixController { - @ApiOperation(value = "") - @RequestMapping("/fallback") - public ResResult fallback() { - ResResult resResult = new ResResult(); - //设置20010为熔断状态吗 - resResult.setCode(20010); - resResult.setMsg("接口发生了熔断"); - resResult.setFlag(false); - return resResult; - } -} \ No newline at end of file diff --git a/ty-common/src/main/java/top/kuanghua/feign/integrationfront/feign/UserFeign.java b/ty-common/src/main/java/top/kuanghua/feign/integrationfront/feign/UserFeign.java deleted file mode 100644 index e2a6fc8..0000000 --- a/ty-common/src/main/java/top/kuanghua/feign/integrationfront/feign/UserFeign.java +++ /dev/null @@ -1,15 +0,0 @@ -package top.kuanghua.feign.integrationfront.feign; - -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import top.kuanghua.feign.config.FeignConfiguration; -import top.kuanghua.khcomomon.entity.ResResult; - -@FeignClient(name="integration-front",configuration = FeignConfiguration.class) -@RequestMapping("user") -public interface UserFeign { - @PostMapping("insertUser") - ResResult insertUser(@RequestParam("username") String username); -} diff --git a/ty-common/src/main/java/top/kuanghua/feign/tyauth/feign/TestGetTokenFeign.java b/ty-common/src/main/java/top/kuanghua/feign/tyauth/feign/TestGetTokenFeign.java deleted file mode 100644 index 17e523a..0000000 --- a/ty-common/src/main/java/top/kuanghua/feign/tyauth/feign/TestGetTokenFeign.java +++ /dev/null @@ -1,14 +0,0 @@ -package top.kuanghua.feign.tyauth.feign; - -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import top.kuanghua.feign.config.FeignConfiguration; -import top.kuanghua.khcomomon.entity.ResResult; - -@FeignClient(name = "ty-auth", configuration = FeignConfiguration.class) -@RequestMapping("feignTest") -public interface TestGetTokenFeign { - @PostMapping("getTokenInfo") - public ResResult getTokenInfo(); -} \ No newline at end of file diff --git a/ty-common/src/main/java/top/kuanghua/feign/tyauth/feign/TokenFeign.java b/ty-common/src/main/java/top/kuanghua/feign/tyauth/feign/TokenFeign.java deleted file mode 100644 index 4c2b8d2..0000000 --- a/ty-common/src/main/java/top/kuanghua/feign/tyauth/feign/TokenFeign.java +++ /dev/null @@ -1,45 +0,0 @@ -package top.kuanghua.feign.tyauth.feign; - -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import top.kuanghua.feign.config.FeignConfiguration; -import top.kuanghua.khcomomon.entity.ResResult; - -import java.util.Map; - -/** - * @Title: TokenController - * @Description: - * @Auther: kuanghua - * @create 2021/1/31 16:31 - */ - - -//FeignConfiguration.class -> forward req params of include the token -@FeignClient(name="ty-auth",configuration = FeignConfiguration.class) -@RequestMapping("token") -public interface TokenFeign { - - /* - * parse token - * */ - @PostMapping("parseToken") - ResResult parseToken(@RequestParam("jwtToken") String jwtToken); - - /* - * create token - * */ - @PostMapping("generateToken") - ResResult generateToken(@RequestBody Map map); - - /* - * update token - * */ - @PostMapping("updateToken") - ResResult updateToken(@RequestBody Map map); -} - - diff --git a/ty-common/src/main/java/top/kuanghua/khcomomon/config/TokenParseInfo.java b/ty-common/src/main/java/top/kuanghua/khcomomon/config/TokenParseInfo.java deleted file mode 100644 index 704d981..0000000 --- a/ty-common/src/main/java/top/kuanghua/khcomomon/config/TokenParseInfo.java +++ /dev/null @@ -1,26 +0,0 @@ -package top.kuanghua.khcomomon.config; - -import java.util.Map; - -/** - * @Title: TokenParseInfo - * @Description: - * @Auther: kuanghua - * @create 2021/3/15 14:37 - */ -public class TokenParseInfo { - // 定义一个线程域,存放登录用户 - private static final ThreadLocal t1 = new ThreadLocal<>(); - - public TokenParseInfo(Map map) { - t1.set(map); - } - - public static Map getT1() { - return t1.get(); - } - - public static void removeT1() { - t1.remove(); - } -} diff --git a/ty-common/src/main/java/top/kuanghua/khcomomon/config/TyCommonConfig.java b/ty-common/src/main/java/top/kuanghua/khcomomon/config/TyCommonConfig.java deleted file mode 100644 index e770241..0000000 --- a/ty-common/src/main/java/top/kuanghua/khcomomon/config/TyCommonConfig.java +++ /dev/null @@ -1,25 +0,0 @@ -package top.kuanghua.khcomomon.config; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import top.kuanghua.khcomomon.utils.IdWorker; - -; - -/** - * @Title: TyCommonConfig - * @Description: - * @Auther: kuanghua - * @create 2020/12/22 15:49 - */ -@Configuration -public class TyCommonConfig { - /*** - * IdWorker - * @return - */ - @Bean - public IdWorker idWorker() { - return new IdWorker(0, 0); - } -} diff --git a/ty-common/src/main/java/top/kuanghua/khcomomon/entity/BCrypt.java b/ty-common/src/main/java/top/kuanghua/khcomomon/entity/BCrypt.java deleted file mode 100644 index 7a234e8..0000000 --- a/ty-common/src/main/java/top/kuanghua/khcomomon/entity/BCrypt.java +++ /dev/null @@ -1,792 +0,0 @@ -// Copyright (c) 2006 Damien Miller -// -// Permission to use, copy, modify, and distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -package top.kuanghua.khcomomon.entity; - -import java.io.UnsupportedEncodingException; -import java.security.SecureRandom; - -/** - * BCrypt implements OpenBSD-style Blowfish password hashing using - * the scheme described in "A Future-Adaptable Password Scheme" by - * Niels Provos and David Mazieres. - *

- * This password hashing system tries to thwart off-line password - * cracking using a computationally-intensive hashing algorithm, - * based on Bruce Schneier's Blowfish cipher. The work factor of - * the algorithm is parameterised, so it can be increased as - * computers get faster. - *

- * Usage is really simple. To hash a password for the first time, - * call the hashpw method with a random salt, like this: - *

- * - * String pw_hash = BCrypt.hashpw(plain_password, BCrypt.gensalt());
- *
- *

- * To check whether a plaintext password matches one that has been - * hashed previously, use the checkpw method: - *

- * - * if (BCrypt.checkpw(candidate_password, stored_hash))
- *     System.out.println("It matches");
- * else
- *     System.out.println("It does not match");
- *
- *

- * The gensalt() method takes an optional parameter (log_rounds) - * that determines the computational complexity of the hashing: - *

- * - * String strong_salt = BCrypt.gensalt(10)
- * String stronger_salt = BCrypt.gensalt(12)
- *
- *

- * The amount of work increases exponentially (2**log_rounds), so - * each increment is twice as much work. The default log_rounds is - * 10, and the valid range is 4 to 30. - * - * @version 0.2 - */ -public class BCrypt { - // BCrypt parameters - private static final int GENSALT_DEFAULT_LOG2_ROUNDS = 10; - private static final int BCRYPT_SALT_LEN = 16; - - // Blowfish parameters - private static final int BLOWFISH_NUM_ROUNDS = 16; - - // Initial contents of key schedule - private static final int P_orig[] = { - 0x243f6a88, 0x85a308d3, 0x13198a2e, 0x03707344, - 0xa4093822, 0x299f31d0, 0x082efa98, 0xec4e6c89, - 0x452821e6, 0x38d01377, 0xbe5466cf, 0x34e90c6c, - 0xc0ac29b7, 0xc97c50dd, 0x3f84d5b5, 0xb5470917, - 0x9216d5d9, 0x8979fb1b - }; - private static final int S_orig[] = { - 0xd1310ba6, 0x98dfb5ac, 0x2ffd72db, 0xd01adfb7, - 0xb8e1afed, 0x6a267e96, 0xba7c9045, 0xf12c7f99, - 0x24a19947, 0xb3916cf7, 0x0801f2e2, 0x858efc16, - 0x636920d8, 0x71574e69, 0xa458fea3, 0xf4933d7e, - 0x0d95748f, 0x728eb658, 0x718bcd58, 0x82154aee, - 0x7b54a41d, 0xc25a59b5, 0x9c30d539, 0x2af26013, - 0xc5d1b023, 0x286085f0, 0xca417918, 0xb8db38ef, - 0x8e79dcb0, 0x603a180e, 0x6c9e0e8b, 0xb01e8a3e, - 0xd71577c1, 0xbd314b27, 0x78af2fda, 0x55605c60, - 0xe65525f3, 0xaa55ab94, 0x57489862, 0x63e81440, - 0x55ca396a, 0x2aab10b6, 0xb4cc5c34, 0x1141e8ce, - 0xa15486af, 0x7c72e993, 0xb3ee1411, 0x636fbc2a, - 0x2ba9c55d, 0x741831f6, 0xce5c3e16, 0x9b87931e, - 0xafd6ba33, 0x6c24cf5c, 0x7a325381, 0x28958677, - 0x3b8f4898, 0x6b4bb9af, 0xc4bfe81b, 0x66282193, - 0x61d809cc, 0xfb21a991, 0x487cac60, 0x5dec8032, - 0xef845d5d, 0xe98575b1, 0xdc262302, 0xeb651b88, - 0x23893e81, 0xd396acc5, 0x0f6d6ff3, 0x83f44239, - 0x2e0b4482, 0xa4842004, 0x69c8f04a, 0x9e1f9b5e, - 0x21c66842, 0xf6e96c9a, 0x670c9c61, 0xabd388f0, - 0x6a51a0d2, 0xd8542f68, 0x960fa728, 0xab5133a3, - 0x6eef0b6c, 0x137a3be4, 0xba3bf050, 0x7efb2a98, - 0xa1f1651d, 0x39af0176, 0x66ca593e, 0x82430e88, - 0x8cee8619, 0x456f9fb4, 0x7d84a5c3, 0x3b8b5ebe, - 0xe06f75d8, 0x85c12073, 0x401a449f, 0x56c16aa6, - 0x4ed3aa62, 0x363f7706, 0x1bfedf72, 0x429b023d, - 0x37d0d724, 0xd00a1248, 0xdb0fead3, 0x49f1c09b, - 0x075372c9, 0x80991b7b, 0x25d479d8, 0xf6e8def7, - 0xe3fe501a, 0xb6794c3b, 0x976ce0bd, 0x04c006ba, - 0xc1a94fb6, 0x409f60c4, 0x5e5c9ec2, 0x196a2463, - 0x68fb6faf, 0x3e6c53b5, 0x1339b2eb, 0x3b52ec6f, - 0x6dfc511f, 0x9b30952c, 0xcc814544, 0xaf5ebd09, - 0xbee3d004, 0xde334afd, 0x660f2807, 0x192e4bb3, - 0xc0cba857, 0x45c8740f, 0xd20b5f39, 0xb9d3fbdb, - 0x5579c0bd, 0x1a60320a, 0xd6a100c6, 0x402c7279, - 0x679f25fe, 0xfb1fa3cc, 0x8ea5e9f8, 0xdb3222f8, - 0x3c7516df, 0xfd616b15, 0x2f501ec8, 0xad0552ab, - 0x323db5fa, 0xfd238760, 0x53317b48, 0x3e00df82, - 0x9e5c57bb, 0xca6f8ca0, 0x1a87562e, 0xdf1769db, - 0xd542a8f6, 0x287effc3, 0xac6732c6, 0x8c4f5573, - 0x695b27b0, 0xbbca58c8, 0xe1ffa35d, 0xb8f011a0, - 0x10fa3d98, 0xfd2183b8, 0x4afcb56c, 0x2dd1d35b, - 0x9a53e479, 0xb6f84565, 0xd28e49bc, 0x4bfb9790, - 0xe1ddf2da, 0xa4cb7e33, 0x62fb1341, 0xcee4c6e8, - 0xef20cada, 0x36774c01, 0xd07e9efe, 0x2bf11fb4, - 0x95dbda4d, 0xae909198, 0xeaad8e71, 0x6b93d5a0, - 0xd08ed1d0, 0xafc725e0, 0x8e3c5b2f, 0x8e7594b7, - 0x8ff6e2fb, 0xf2122b64, 0x8888b812, 0x900df01c, - 0x4fad5ea0, 0x688fc31c, 0xd1cff191, 0xb3a8c1ad, - 0x2f2f2218, 0xbe0e1777, 0xea752dfe, 0x8b021fa1, - 0xe5a0cc0f, 0xb56f74e8, 0x18acf3d6, 0xce89e299, - 0xb4a84fe0, 0xfd13e0b7, 0x7cc43b81, 0xd2ada8d9, - 0x165fa266, 0x80957705, 0x93cc7314, 0x211a1477, - 0xe6ad2065, 0x77b5fa86, 0xc75442f5, 0xfb9d35cf, - 0xebcdaf0c, 0x7b3e89a0, 0xd6411bd3, 0xae1e7e49, - 0x00250e2d, 0x2071b35e, 0x226800bb, 0x57b8e0af, - 0x2464369b, 0xf009b91e, 0x5563911d, 0x59dfa6aa, - 0x78c14389, 0xd95a537f, 0x207d5ba2, 0x02e5b9c5, - 0x83260376, 0x6295cfa9, 0x11c81968, 0x4e734a41, - 0xb3472dca, 0x7b14a94a, 0x1b510052, 0x9a532915, - 0xd60f573f, 0xbc9bc6e4, 0x2b60a476, 0x81e67400, - 0x08ba6fb5, 0x571be91f, 0xf296ec6b, 0x2a0dd915, - 0xb6636521, 0xe7b9f9b6, 0xff34052e, 0xc5855664, - 0x53b02d5d, 0xa99f8fa1, 0x08ba4799, 0x6e85076a, - 0x4b7a70e9, 0xb5b32944, 0xdb75092e, 0xc4192623, - 0xad6ea6b0, 0x49a7df7d, 0x9cee60b8, 0x8fedb266, - 0xecaa8c71, 0x699a17ff, 0x5664526c, 0xc2b19ee1, - 0x193602a5, 0x75094c29, 0xa0591340, 0xe4183a3e, - 0x3f54989a, 0x5b429d65, 0x6b8fe4d6, 0x99f73fd6, - 0xa1d29c07, 0xefe830f5, 0x4d2d38e6, 0xf0255dc1, - 0x4cdd2086, 0x8470eb26, 0x6382e9c6, 0x021ecc5e, - 0x09686b3f, 0x3ebaefc9, 0x3c971814, 0x6b6a70a1, - 0x687f3584, 0x52a0e286, 0xb79c5305, 0xaa500737, - 0x3e07841c, 0x7fdeae5c, 0x8e7d44ec, 0x5716f2b8, - 0xb03ada37, 0xf0500c0d, 0xf01c1f04, 0x0200b3ff, - 0xae0cf51a, 0x3cb574b2, 0x25837a58, 0xdc0921bd, - 0xd19113f9, 0x7ca92ff6, 0x94324773, 0x22f54701, - 0x3ae5e581, 0x37c2dadc, 0xc8b57634, 0x9af3dda7, - 0xa9446146, 0x0fd0030e, 0xecc8c73e, 0xa4751e41, - 0xe238cd99, 0x3bea0e2f, 0x3280bba1, 0x183eb331, - 0x4e548b38, 0x4f6db908, 0x6f420d03, 0xf60a04bf, - 0x2cb81290, 0x24977c79, 0x5679b072, 0xbcaf89af, - 0xde9a771f, 0xd9930810, 0xb38bae12, 0xdccf3f2e, - 0x5512721f, 0x2e6b7124, 0x501adde6, 0x9f84cd87, - 0x7a584718, 0x7408da17, 0xbc9f9abc, 0xe94b7d8c, - 0xec7aec3a, 0xdb851dfa, 0x63094366, 0xc464c3d2, - 0xef1c1847, 0x3215d908, 0xdd433b37, 0x24c2ba16, - 0x12a14d43, 0x2a65c451, 0x50940002, 0x133ae4dd, - 0x71dff89e, 0x10314e55, 0x81ac77d6, 0x5f11199b, - 0x043556f1, 0xd7a3c76b, 0x3c11183b, 0x5924a509, - 0xf28fe6ed, 0x97f1fbfa, 0x9ebabf2c, 0x1e153c6e, - 0x86e34570, 0xeae96fb1, 0x860e5e0a, 0x5a3e2ab3, - 0x771fe71c, 0x4e3d06fa, 0x2965dcb9, 0x99e71d0f, - 0x803e89d6, 0x5266c825, 0x2e4cc978, 0x9c10b36a, - 0xc6150eba, 0x94e2ea78, 0xa5fc3c53, 0x1e0a2df4, - 0xf2f74ea7, 0x361d2b3d, 0x1939260f, 0x19c27960, - 0x5223a708, 0xf71312b6, 0xebadfe6e, 0xeac31f66, - 0xe3bc4595, 0xa67bc883, 0xb17f37d1, 0x018cff28, - 0xc332ddef, 0xbe6c5aa5, 0x65582185, 0x68ab9802, - 0xeecea50f, 0xdb2f953b, 0x2aef7dad, 0x5b6e2f84, - 0x1521b628, 0x29076170, 0xecdd4775, 0x619f1510, - 0x13cca830, 0xeb61bd96, 0x0334fe1e, 0xaa0363cf, - 0xb5735c90, 0x4c70a239, 0xd59e9e0b, 0xcbaade14, - 0xeecc86bc, 0x60622ca7, 0x9cab5cab, 0xb2f3846e, - 0x648b1eaf, 0x19bdf0ca, 0xa02369b9, 0x655abb50, - 0x40685a32, 0x3c2ab4b3, 0x319ee9d5, 0xc021b8f7, - 0x9b540b19, 0x875fa099, 0x95f7997e, 0x623d7da8, - 0xf837889a, 0x97e32d77, 0x11ed935f, 0x16681281, - 0x0e358829, 0xc7e61fd6, 0x96dedfa1, 0x7858ba99, - 0x57f584a5, 0x1b227263, 0x9b83c3ff, 0x1ac24696, - 0xcdb30aeb, 0x532e3054, 0x8fd948e4, 0x6dbc3128, - 0x58ebf2ef, 0x34c6ffea, 0xfe28ed61, 0xee7c3c73, - 0x5d4a14d9, 0xe864b7e3, 0x42105d14, 0x203e13e0, - 0x45eee2b6, 0xa3aaabea, 0xdb6c4f15, 0xfacb4fd0, - 0xc742f442, 0xef6abbb5, 0x654f3b1d, 0x41cd2105, - 0xd81e799e, 0x86854dc7, 0xe44b476a, 0x3d816250, - 0xcf62a1f2, 0x5b8d2646, 0xfc8883a0, 0xc1c7b6a3, - 0x7f1524c3, 0x69cb7492, 0x47848a0b, 0x5692b285, - 0x095bbf00, 0xad19489d, 0x1462b174, 0x23820e00, - 0x58428d2a, 0x0c55f5ea, 0x1dadf43e, 0x233f7061, - 0x3372f092, 0x8d937e41, 0xd65fecf1, 0x6c223bdb, - 0x7cde3759, 0xcbee7460, 0x4085f2a7, 0xce77326e, - 0xa6078084, 0x19f8509e, 0xe8efd855, 0x61d99735, - 0xa969a7aa, 0xc50c06c2, 0x5a04abfc, 0x800bcadc, - 0x9e447a2e, 0xc3453484, 0xfdd56705, 0x0e1e9ec9, - 0xdb73dbd3, 0x105588cd, 0x675fda79, 0xe3674340, - 0xc5c43465, 0x713e38d8, 0x3d28f89e, 0xf16dff20, - 0x153e21e7, 0x8fb03d4a, 0xe6e39f2b, 0xdb83adf7, - 0xe93d5a68, 0x948140f7, 0xf64c261c, 0x94692934, - 0x411520f7, 0x7602d4f7, 0xbcf46b2e, 0xd4a20068, - 0xd4082471, 0x3320f46a, 0x43b7d4b7, 0x500061af, - 0x1e39f62e, 0x97244546, 0x14214f74, 0xbf8b8840, - 0x4d95fc1d, 0x96b591af, 0x70f4ddd3, 0x66a02f45, - 0xbfbc09ec, 0x03bd9785, 0x7fac6dd0, 0x31cb8504, - 0x96eb27b3, 0x55fd3941, 0xda2547e6, 0xabca0a9a, - 0x28507825, 0x530429f4, 0x0a2c86da, 0xe9b66dfb, - 0x68dc1462, 0xd7486900, 0x680ec0a4, 0x27a18dee, - 0x4f3ffea2, 0xe887ad8c, 0xb58ce006, 0x7af4d6b6, - 0xaace1e7c, 0xd3375fec, 0xce78a399, 0x406b2a42, - 0x20fe9e35, 0xd9f385b9, 0xee39d7ab, 0x3b124e8b, - 0x1dc9faf7, 0x4b6d1856, 0x26a36631, 0xeae397b2, - 0x3a6efa74, 0xdd5b4332, 0x6841e7f7, 0xca7820fb, - 0xfb0af54e, 0xd8feb397, 0x454056ac, 0xba489527, - 0x55533a3a, 0x20838d87, 0xfe6ba9b7, 0xd096954b, - 0x55a867bc, 0xa1159a58, 0xcca92963, 0x99e1db33, - 0xa62a4a56, 0x3f3125f9, 0x5ef47e1c, 0x9029317c, - 0xfdf8e802, 0x04272f70, 0x80bb155c, 0x05282ce3, - 0x95c11548, 0xe4c66d22, 0x48c1133f, 0xc70f86dc, - 0x07f9c9ee, 0x41041f0f, 0x404779a4, 0x5d886e17, - 0x325f51eb, 0xd59bc0d1, 0xf2bcc18f, 0x41113564, - 0x257b7834, 0x602a9c60, 0xdff8e8a3, 0x1f636c1b, - 0x0e12b4c2, 0x02e1329e, 0xaf664fd1, 0xcad18115, - 0x6b2395e0, 0x333e92e1, 0x3b240b62, 0xeebeb922, - 0x85b2a20e, 0xe6ba0d99, 0xde720c8c, 0x2da2f728, - 0xd0127845, 0x95b794fd, 0x647d0862, 0xe7ccf5f0, - 0x5449a36f, 0x877d48fa, 0xc39dfd27, 0xf33e8d1e, - 0x0a476341, 0x992eff74, 0x3a6f6eab, 0xf4f8fd37, - 0xa812dc60, 0xa1ebddf8, 0x991be14c, 0xdb6e6b0d, - 0xc67b5510, 0x6d672c37, 0x2765d43b, 0xdcd0e804, - 0xf1290dc7, 0xcc00ffa3, 0xb5390f92, 0x690fed0b, - 0x667b9ffb, 0xcedb7d9c, 0xa091cf0b, 0xd9155ea3, - 0xbb132f88, 0x515bad24, 0x7b9479bf, 0x763bd6eb, - 0x37392eb3, 0xcc115979, 0x8026e297, 0xf42e312d, - 0x6842ada7, 0xc66a2b3b, 0x12754ccc, 0x782ef11c, - 0x6a124237, 0xb79251e7, 0x06a1bbe6, 0x4bfb6350, - 0x1a6b1018, 0x11caedfa, 0x3d25bdd8, 0xe2e1c3c9, - 0x44421659, 0x0a121386, 0xd90cec6e, 0xd5abea2a, - 0x64af674e, 0xda86a85f, 0xbebfe988, 0x64e4c3fe, - 0x9dbc8057, 0xf0f7c086, 0x60787bf8, 0x6003604d, - 0xd1fd8346, 0xf6381fb0, 0x7745ae04, 0xd736fccc, - 0x83426b33, 0xf01eab71, 0xb0804187, 0x3c005e5f, - 0x77a057be, 0xbde8ae24, 0x55464299, 0xbf582e61, - 0x4e58f48f, 0xf2ddfda2, 0xf474ef38, 0x8789bdc2, - 0x5366f9c3, 0xc8b38e74, 0xb475f255, 0x46fcd9b9, - 0x7aeb2661, 0x8b1ddf84, 0x846a0e79, 0x915f95e2, - 0x466e598e, 0x20b45770, 0x8cd55591, 0xc902de4c, - 0xb90bace1, 0xbb8205d0, 0x11a86248, 0x7574a99e, - 0xb77f19b6, 0xe0a9dc09, 0x662d09a1, 0xc4324633, - 0xe85a1f02, 0x09f0be8c, 0x4a99a025, 0x1d6efe10, - 0x1ab93d1d, 0x0ba5a4df, 0xa186f20f, 0x2868f169, - 0xdcb7da83, 0x573906fe, 0xa1e2ce9b, 0x4fcd7f52, - 0x50115e01, 0xa70683fa, 0xa002b5c4, 0x0de6d027, - 0x9af88c27, 0x773f8641, 0xc3604c06, 0x61a806b5, - 0xf0177a28, 0xc0f586e0, 0x006058aa, 0x30dc7d62, - 0x11e69ed7, 0x2338ea63, 0x53c2dd94, 0xc2c21634, - 0xbbcbee56, 0x90bcb6de, 0xebfc7da1, 0xce591d76, - 0x6f05e409, 0x4b7c0188, 0x39720a3d, 0x7c927c24, - 0x86e3725f, 0x724d9db9, 0x1ac15bb4, 0xd39eb8fc, - 0xed545578, 0x08fca5b5, 0xd83d7cd3, 0x4dad0fc4, - 0x1e50ef5e, 0xb161e6f8, 0xa28514d9, 0x6c51133c, - 0x6fd5c7e7, 0x56e14ec4, 0x362abfce, 0xddc6c837, - 0xd79a3234, 0x92638212, 0x670efa8e, 0x406000e0, - 0x3a39ce37, 0xd3faf5cf, 0xabc27737, 0x5ac52d1b, - 0x5cb0679e, 0x4fa33742, 0xd3822740, 0x99bc9bbe, - 0xd5118e9d, 0xbf0f7315, 0xd62d1c7e, 0xc700c47b, - 0xb78c1b6b, 0x21a19045, 0xb26eb1be, 0x6a366eb4, - 0x5748ab2f, 0xbc946e79, 0xc6a376d2, 0x6549c2c8, - 0x530ff8ee, 0x468dde7d, 0xd5730a1d, 0x4cd04dc6, - 0x2939bbdb, 0xa9ba4650, 0xac9526e8, 0xbe5ee304, - 0xa1fad5f0, 0x6a2d519a, 0x63ef8ce2, 0x9a86ee22, - 0xc089c2b8, 0x43242ef6, 0xa51e03aa, 0x9cf2d0a4, - 0x83c061ba, 0x9be96a4d, 0x8fe51550, 0xba645bd6, - 0x2826a2f9, 0xa73a3ae1, 0x4ba99586, 0xef5562e9, - 0xc72fefd3, 0xf752f7da, 0x3f046f69, 0x77fa0a59, - 0x80e4a915, 0x87b08601, 0x9b09e6ad, 0x3b3ee593, - 0xe990fd5a, 0x9e34d797, 0x2cf0b7d9, 0x022b8b51, - 0x96d5ac3a, 0x017da67d, 0xd1cf3ed6, 0x7c7d2d28, - 0x1f9f25cf, 0xadf2b89b, 0x5ad6b472, 0x5a88f54c, - 0xe029ac71, 0xe019a5e6, 0x47b0acfd, 0xed93fa9b, - 0xe8d3c48d, 0x283b57cc, 0xf8d56629, 0x79132e28, - 0x785f0191, 0xed756055, 0xf7960e44, 0xe3d35e8c, - 0x15056dd4, 0x88f46dba, 0x03a16125, 0x0564f0bd, - 0xc3eb9e15, 0x3c9057a2, 0x97271aec, 0xa93a072a, - 0x1b3f6d9b, 0x1e6321f5, 0xf59c66fb, 0x26dcf319, - 0x7533d928, 0xb155fdf5, 0x03563482, 0x8aba3cbb, - 0x28517711, 0xc20ad9f8, 0xabcc5167, 0xccad925f, - 0x4de81751, 0x3830dc8e, 0x379d5862, 0x9320f991, - 0xea7a90c2, 0xfb3e7bce, 0x5121ce64, 0x774fbe32, - 0xa8b6e37e, 0xc3293d46, 0x48de5369, 0x6413e680, - 0xa2ae0810, 0xdd6db224, 0x69852dfd, 0x09072166, - 0xb39a460a, 0x6445c0dd, 0x586cdecf, 0x1c20c8ae, - 0x5bbef7dd, 0x1b588d40, 0xccd2017f, 0x6bb4e3bb, - 0xdda26a7e, 0x3a59ff45, 0x3e350a44, 0xbcb4cdd5, - 0x72eacea8, 0xfa6484bb, 0x8d6612ae, 0xbf3c6f47, - 0xd29be463, 0x542f5d9e, 0xaec2771b, 0xf64e6370, - 0x740e0d8d, 0xe75b1357, 0xf8721671, 0xaf537d5d, - 0x4040cb08, 0x4eb4e2cc, 0x34d2466a, 0x0115af84, - 0xe1b00428, 0x95983a1d, 0x06b89fb4, 0xce6ea048, - 0x6f3f3b82, 0x3520ab82, 0x011a1d4b, 0x277227f8, - 0x611560b1, 0xe7933fdc, 0xbb3a792b, 0x344525bd, - 0xa08839e1, 0x51ce794b, 0x2f32c9b7, 0xa01fbac9, - 0xe01cc87e, 0xbcc7d1f6, 0xcf0111c3, 0xa1e8aac7, - 0x1a908749, 0xd44fbd9a, 0xd0dadecb, 0xd50ada38, - 0x0339c32a, 0xc6913667, 0x8df9317c, 0xe0b12b4f, - 0xf79e59b7, 0x43f5bb3a, 0xf2d519ff, 0x27d9459c, - 0xbf97222c, 0x15e6fc2a, 0x0f91fc71, 0x9b941525, - 0xfae59361, 0xceb69ceb, 0xc2a86459, 0x12baa8d1, - 0xb6c1075e, 0xe3056a0c, 0x10d25065, 0xcb03a442, - 0xe0ec6e0e, 0x1698db3b, 0x4c98a0be, 0x3278e964, - 0x9f1f9532, 0xe0d392df, 0xd3a0342b, 0x8971f21e, - 0x1b0a7441, 0x4ba3348c, 0xc5be7120, 0xc37632d8, - 0xdf359f8d, 0x9b992f2e, 0xe60b6f47, 0x0fe3f11d, - 0xe54cda54, 0x1edad891, 0xce6279cf, 0xcd3e7e6f, - 0x1618b166, 0xfd2c1d05, 0x848fd2c5, 0xf6fb2299, - 0xf523f357, 0xa6327623, 0x93a83531, 0x56cccd02, - 0xacf08162, 0x5a75ebb5, 0x6e163697, 0x88d273cc, - 0xde966292, 0x81b949d0, 0x4c50901b, 0x71c65614, - 0xe6c6c7bd, 0x327a140a, 0x45e1d006, 0xc3f27b9a, - 0xc9aa53fd, 0x62a80f00, 0xbb25bfe2, 0x35bdd2f6, - 0x71126905, 0xb2040222, 0xb6cbcf7c, 0xcd769c2b, - 0x53113ec0, 0x1640e3d3, 0x38abbd60, 0x2547adf0, - 0xba38209c, 0xf746ce76, 0x77afa1c5, 0x20756060, - 0x85cbfe4e, 0x8ae88dd8, 0x7aaaf9b0, 0x4cf9aa7e, - 0x1948c25c, 0x02fb8a8c, 0x01c36ae4, 0xd6ebe1f9, - 0x90d4f869, 0xa65cdea0, 0x3f09252d, 0xc208e69f, - 0xb74e6132, 0xce77e25b, 0x578fdfe3, 0x3ac372e6 - }; - - // bcrypt IV: "OrpheanBeholderScryDoubt". The C implementation calls - // this "ciphertext", but it is really plaintext or an IV. We keep - // the name to make code comparison easier. - static private final int bf_crypt_ciphertext[] = { - 0x4f727068, 0x65616e42, 0x65686f6c, - 0x64657253, 0x63727944, 0x6f756274 - }; - - // Table for Base64 encoding - static private final char base64_code[] = { - '.', '/', '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', '0', '1', '2', '3', '4', '5', - '6', '7', '8', '9' - }; - - // Table for Base64 decoding - static private final byte index_64[] = { - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 0, 1, 54, 55, - 56, 57, 58, 59, 60, 61, 62, 63, -1, -1, - -1, -1, -1, -1, -1, 2, 3, 4, 5, 6, - 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, - 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, - -1, -1, -1, -1, -1, -1, 28, 29, 30, - 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, - 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, - 51, 52, 53, -1, -1, -1, -1, -1 - }; - - // Expanded Blowfish key - private int P[]; - private int S[]; - - /** - * Encode a byte array using bcrypt's slightly-modified base64 - * encoding scheme. Note that this is *not* compatible with - * the standard MIME-base64 encoding. - * - * @param d the byte array to encode - * @param len the number of bytes to encode - * @return base64-encoded string - * @exception IllegalArgumentException if the length is invalid - */ - private static String encode_base64(byte d[], int len) - throws IllegalArgumentException { - int off = 0; - StringBuffer rs = new StringBuffer(); - int c1, c2; - - if (len <= 0 || len > d.length) { - throw new IllegalArgumentException("Invalid len"); - } - while (off < len) { - c1 = d[off++] & 0xff; - rs.append(base64_code[(c1 >> 2) & 0x3f]); - c1 = (c1 & 0x03) << 4; - if (off >= len) { - rs.append(base64_code[c1 & 0x3f]); - break; - } - c2 = d[off++] & 0xff; - c1 |= (c2 >> 4) & 0x0f; - rs.append(base64_code[c1 & 0x3f]); - c1 = (c2 & 0x0f) << 2; - if (off >= len) { - rs.append(base64_code[c1 & 0x3f]); - break; - } - c2 = d[off++] & 0xff; - c1 |= (c2 >> 6) & 0x03; - rs.append(base64_code[c1 & 0x3f]); - rs.append(base64_code[c2 & 0x3f]); - } - return rs.toString(); - } - - /** - * Look up the 3 bits base64-encoded by the specified character, - * range-checking againt conversion table - * @param x the base64-encoded value - * @return the decoded value of x - */ - private static byte char64(char x) { - if ((int)x < 0 || (int)x > index_64.length) { - return -1; - } - return index_64[(int)x]; - } - - /** - * Decode a string encoded using bcrypt's base64 scheme to a - * byte array. Note that this is *not* compatible with - * the standard MIME-base64 encoding. - * @param s the string to decode - * @param maxolen the maximum number of bytes to decode - * @return an array containing the decoded bytes - * @throws IllegalArgumentException if maxolen is invalid - */ - private static byte[] decode_base64(String s, int maxolen) - throws IllegalArgumentException { - StringBuffer rs = new StringBuffer(); - int off = 0, slen = s.length(), olen = 0; - byte ret[]; - byte c1, c2, c3, c4, o; - - if (maxolen <= 0) { - throw new IllegalArgumentException("Invalid maxolen"); - } - while (off < slen - 1 && olen < maxolen) { - c1 = char64(s.charAt(off++)); - c2 = char64(s.charAt(off++)); - if (c1 == -1 || c2 == -1) { - break; - } - o = (byte)(c1 << 2); - o |= (c2 & 0x30) >> 4; - rs.append((char)o); - if (++olen >= maxolen || off >= slen) { - break; - } - c3 = char64(s.charAt(off++)); - if (c3 == -1) { - break; - } - o = (byte)((c2 & 0x0f) << 4); - o |= (c3 & 0x3c) >> 2; - rs.append((char)o); - if (++olen >= maxolen || off >= slen) { - break; - } - c4 = char64(s.charAt(off++)); - o = (byte)((c3 & 0x03) << 6); - o |= c4; - rs.append((char)o); - ++olen; - } - - ret = new byte[olen]; - for (off = 0; off < olen; off++) { - ret[off] = (byte) rs.charAt(off); - } - return ret; - } - - /** - * Blowfish encipher a single 64-bit block encoded as - * two 32-bit halves - * @param lr an array containing the two 32-bit half blocks - * @param off the position in the array of the blocks - */ - private final void encipher(int lr[], int off) { - int i, n, l = lr[off], r = lr[off + 1]; - - l ^= P[0]; - for (i = 0; i <= BLOWFISH_NUM_ROUNDS - 2;) { - // Feistel substitution on left word - n = S[(l >> 24) & 0xff]; - n += S[0x100 | ((l >> 16) & 0xff)]; - n ^= S[0x200 | ((l >> 8) & 0xff)]; - n += S[0x300 | (l & 0xff)]; - r ^= n ^ P[++i]; - - // Feistel substitution on right word - n = S[(r >> 24) & 0xff]; - n += S[0x100 | ((r >> 16) & 0xff)]; - n ^= S[0x200 | ((r >> 8) & 0xff)]; - n += S[0x300 | (r & 0xff)]; - l ^= n ^ P[++i]; - } - lr[off] = r ^ P[BLOWFISH_NUM_ROUNDS + 1]; - lr[off + 1] = l; - } - - /** - * Cycically extract a word of key material - * @param data the string to extract the data from - * @param offp a "pointer" (as a one-entry array) to the - * current offset into data - * @return the next word of material from data - */ - private static int streamtoword(byte data[], int offp[]) { - int i; - int word = 0; - int off = offp[0]; - - for (i = 0; i < 4; i++) { - word = (word << 8) | (data[off] & 0xff); - off = (off + 1) % data.length; - } - - offp[0] = off; - return word; - } - - /** - * Initialise the Blowfish key schedule - */ - private void init_key() { - P = (int[])P_orig.clone(); - S = (int[])S_orig.clone(); - } - - /** - * Key the Blowfish cipher - * @param key an array containing the key - */ - private void key(byte key[]) { - int i; - int koffp[] = { 0 }; - int lr[] = { 0, 0 }; - int plen = P.length, slen = S.length; - - for (i = 0; i < plen; i++) { - P[i] = P[i] ^ streamtoword(key, koffp); - } - for (i = 0; i < plen; i += 2) { - encipher(lr, 0); - P[i] = lr[0]; - P[i + 1] = lr[1]; - } - - for (i = 0; i < slen; i += 2) { - encipher(lr, 0); - S[i] = lr[0]; - S[i + 1] = lr[1]; - } - } - - /** - * Perform the "enhanced key schedule" step described by - * Provos and Mazieres in "A Future-Adaptable Password Scheme" - * http://www.openbsd.org/papers/bcrypt-paper.ps - * @param data salt information - * @param key password information - */ - private void ekskey(byte data[], byte key[]) { - int i; - int koffp[] = { 0 }, doffp[] = { 0 }; - int lr[] = { 0, 0 }; - int plen = P.length, slen = S.length; - - for (i = 0; i < plen; i++) { - P[i] = P[i] ^ streamtoword(key, koffp); - } - for (i = 0; i < plen; i += 2) { - lr[0] ^= streamtoword(data, doffp); - lr[1] ^= streamtoword(data, doffp); - encipher(lr, 0); - P[i] = lr[0]; - P[i + 1] = lr[1]; - } - - for (i = 0; i < slen; i += 2) { - lr[0] ^= streamtoword(data, doffp); - lr[1] ^= streamtoword(data, doffp); - encipher(lr, 0); - S[i] = lr[0]; - S[i + 1] = lr[1]; - } - } - - /** - * Perform the central password hashing step in the - * bcrypt scheme - * @param password the password to hash - * @param salt the binary salt to hash with the password - * @param log_rounds the binary logarithm of the number - * of rounds of hashing to apply - * @param cdata the plaintext to encrypt - * @return an array containing the binary hashed password - */ - public byte[] crypt_raw(byte password[], byte salt[], int log_rounds, - int cdata[]) { - int rounds, i, j; - int clen = cdata.length; - byte ret[]; - - if (log_rounds < 4 || log_rounds > 30) { - throw new IllegalArgumentException("Bad number of rounds"); - } - rounds = 1 << log_rounds; - if (salt.length != BCRYPT_SALT_LEN) { - throw new IllegalArgumentException("Bad salt length"); - } - init_key(); - ekskey(salt, password); - for (i = 0; i != rounds; i++) { - key(password); - key(salt); - } - - for (i = 0; i < 64; i++) { - for (j = 0; j < (clen >> 1); j++) { - encipher(cdata, j << 1); - } - } - - ret = new byte[clen * 4]; - for (i = 0, j = 0; i < clen; i++) { - ret[j++] = (byte)((cdata[i] >> 24) & 0xff); - ret[j++] = (byte)((cdata[i] >> 16) & 0xff); - ret[j++] = (byte)((cdata[i] >> 8) & 0xff); - ret[j++] = (byte)(cdata[i] & 0xff); - } - return ret; - } - - /** - * Hash a password using the OpenBSD bcrypt scheme - * @param password the password to hash - * @param salt the salt to hash with (perhaps generated - * using BCrypt.gensalt) - * @return the hashed password - */ - public static String hashpw(String password, String salt) { - BCrypt B; - String real_salt; - byte passwordb[], saltb[], hashed[]; - char minor = (char)0; - int rounds, off = 0; - StringBuffer rs = new StringBuffer(); - - if (salt.charAt(0) != '$' || salt.charAt(1) != '2') { - throw new IllegalArgumentException("Invalid salt version"); - } - if (salt.charAt(2) == '$') { - off = 3; - } else { - minor = salt.charAt(2); - if (minor != 'a' || salt.charAt(3) != '$') { - throw new IllegalArgumentException("Invalid salt revision"); - } - off = 4; - } - - // Extract number of rounds - if (salt.charAt(off + 2) > '$') { - throw new IllegalArgumentException("Missing salt rounds"); - } - rounds = Integer.parseInt(salt.substring(off, off + 2)); - - real_salt = salt.substring(off + 3, off + 25); - try { - passwordb = (password + (minor >= 'a' ? "\000" : "")).getBytes("UTF-8"); - } catch (UnsupportedEncodingException uee) { - throw new AssertionError("UTF-8 is not supported"); - } - - saltb = decode_base64(real_salt, BCRYPT_SALT_LEN); - - B = new BCrypt(); - hashed = B.crypt_raw(passwordb, saltb, rounds, - (int[])bf_crypt_ciphertext.clone()); - - rs.append("$2"); - if (minor >= 'a') { - rs.append(minor); - } - rs.append("$"); - if (rounds < 10) { - rs.append("0"); - } - if (rounds > 30) { - throw new IllegalArgumentException( - "rounds exceeds maximum (30)"); - } - rs.append(Integer.toString(rounds)); - rs.append("$"); - rs.append(encode_base64(saltb, saltb.length)); - rs.append(encode_base64(hashed, - bf_crypt_ciphertext.length * 4 - 1)); - return rs.toString(); - } - - /** - * Generate a salt for use with the BCrypt.hashpw() method - * @param log_rounds the log2 of the number of rounds of - * hashing to apply - the work factor therefore increases as - * 2**log_rounds. - * @param random an instance of SecureRandom to use - * @return an encoded salt value - */ - public static String gensalt(int log_rounds, SecureRandom random) { - StringBuffer rs = new StringBuffer(); - byte rnd[] = new byte[BCRYPT_SALT_LEN]; - - random.nextBytes(rnd); - - rs.append("$2a$"); - if (log_rounds < 10) { - rs.append("0"); - } - if (log_rounds > 30) { - throw new IllegalArgumentException( - "log_rounds exceeds maximum (30)"); - } - rs.append(Integer.toString(log_rounds)); - rs.append("$"); - rs.append(encode_base64(rnd, rnd.length)); - return rs.toString(); - } - - /** - * Generate a salt for use with the BCrypt.hashpw() method - * @param log_rounds the log2 of the number of rounds of - * hashing to apply - the work factor therefore increases as - * 2**log_rounds. - * @return an encoded salt value - */ - public static String gensalt(int log_rounds) { - return gensalt(log_rounds, new SecureRandom()); - } - - /** - * Generate a salt for use with the BCrypt.hashpw() method, - * selecting a reasonable default for the number of hashing - * rounds to apply - * @return an encoded salt value - */ - public static String gensalt() { - return gensalt(GENSALT_DEFAULT_LOG2_ROUNDS); - } - - /** - * Check that a plaintext password matches a previously hashed - * one - * @param plaintext the plaintext password to verify - * @param hashed the previously-hashed password - * @return true if the passwords match, false otherwise - */ - public static boolean checkpw(String plaintext, String hashed) { - byte hashed_bytes[]; - byte try_bytes[]; - try { - String try_pw = hashpw(plaintext, hashed); - hashed_bytes = hashed.getBytes("UTF-8"); - try_bytes = try_pw.getBytes("UTF-8"); - } catch (UnsupportedEncodingException uee) { - return false; - } - if (hashed_bytes.length != try_bytes.length) { - return false; - } - byte ret = 0; - for (int i = 0; i < try_bytes.length; i++) { - ret |= hashed_bytes[i] ^ try_bytes[i]; - } - return ret == 0; - } -} diff --git a/ty-common/src/main/java/top/kuanghua/khcomomon/entity/CacheKey.java b/ty-common/src/main/java/top/kuanghua/khcomomon/entity/CacheKey.java deleted file mode 100644 index e5af96e..0000000 --- a/ty-common/src/main/java/top/kuanghua/khcomomon/entity/CacheKey.java +++ /dev/null @@ -1,24 +0,0 @@ -package top.kuanghua.khcomomon.entity; - -/**** - * @Author:kuanghua - * @Description: - *****/ -public class CacheKey { - - /** - * 商品分类 - */ - public static String CATEGORY="CATEGORY"; - - /** - * 品牌缓存 - */ - public static String BRAND="BRAND"; - - /** - * 规格 - */ - public static String SPEC="SPEC"; - -} diff --git a/ty-common/src/main/java/top/kuanghua/khcomomon/entity/CommonParamsSelf.java b/ty-common/src/main/java/top/kuanghua/khcomomon/entity/CommonParamsSelf.java deleted file mode 100644 index 2185366..0000000 --- a/ty-common/src/main/java/top/kuanghua/khcomomon/entity/CommonParamsSelf.java +++ /dev/null @@ -1,20 +0,0 @@ -package top.kuanghua.khcomomon.entity; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -/** - * @Title: CommonParams - * @Description: - * @Auther: kuanghua - * @create 2020/12/15 12:01 - */ -@Data -@ApiModel -public class CommonParamsSelf extends KHCommonPageParams{ - @ApiModelProperty("开始时间") - private String startTime; - @ApiModelProperty("结束时间") - private String endTime; -} diff --git a/ty-common/src/main/java/top/kuanghua/khcomomon/entity/HttpClient.java b/ty-common/src/main/java/top/kuanghua/khcomomon/entity/HttpClient.java deleted file mode 100644 index 70c9d3a..0000000 --- a/ty-common/src/main/java/top/kuanghua/khcomomon/entity/HttpClient.java +++ /dev/null @@ -1,170 +0,0 @@ -package top.kuanghua.khcomomon.entity; - -import org.apache.http.Consts; -import org.apache.http.HttpEntity; -import org.apache.http.NameValuePair; -import org.apache.http.ParseException; -import org.apache.http.client.ClientProtocolException; -import org.apache.http.client.entity.UrlEncodedFormEntity; -import org.apache.http.client.methods.*; -import org.apache.http.conn.ssl.SSLConnectionSocketFactory; -import org.apache.http.conn.ssl.TrustStrategy; -import org.apache.http.entity.StringEntity; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.impl.client.HttpClients; -import org.apache.http.message.BasicNameValuePair; -import org.apache.http.ssl.SSLContextBuilder; -import org.apache.http.util.EntityUtils; - -import javax.net.ssl.SSLContext; -import java.io.IOException; -import java.security.cert.CertificateException; -import java.security.cert.X509Certificate; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; - -/***** - * @Author: kuanghua - * @Description: entity - ****/ -public class HttpClient { - private String url; - private Map param; - private int statusCode; - private String content; - private String xmlParam; - private boolean isHttps; - - public boolean isHttps() { - return isHttps; - } - - public void setHttps(boolean isHttps) { - this.isHttps = isHttps; - } - - public String getXmlParam() { - return xmlParam; - } - - public void setXmlParam(String xmlParam) { - this.xmlParam = xmlParam; - } - - public HttpClient(String url, Map param) { - this.url = url; - this.param = param; - } - - public HttpClient(String url) { - this.url = url; - } - - public void setParameter(Map map) { - param = map; - } - - public void addParameter(String key, String value) { - if (param == null) - param = new HashMap(); - param.put(key, value); - } - - public void post() throws ClientProtocolException, IOException { - HttpPost http = new HttpPost(url); - setEntity(http); - execute(http); - } - - public void put() throws ClientProtocolException, IOException { - HttpPut http = new HttpPut(url); - setEntity(http); - execute(http); - } - - public void get() throws ClientProtocolException, IOException { - if (param != null) { - StringBuilder url = new StringBuilder(this.url); - boolean isFirst = true; - for (String key : param.keySet()) { - if (isFirst) { - url.append("?"); - }else { - url.append("&"); - } - url.append(key).append("=").append(param.get(key)); - } - this.url = url.toString(); - } - HttpGet http = new HttpGet(url); - execute(http); - } - - /** - * set http post,put param - */ - private void setEntity(HttpEntityEnclosingRequestBase http) { - if (param != null) { - List nvps = new LinkedList(); - for (String key : param.keySet()) { - nvps.add(new BasicNameValuePair(key, param.get(key))); // 参数 - } - http.setEntity(new UrlEncodedFormEntity(nvps, Consts.UTF_8)); // 设置参数 - } - if (xmlParam != null) { - http.setEntity(new StringEntity(xmlParam, Consts.UTF_8)); - } - } - - private void execute(HttpUriRequest http) throws ClientProtocolException, - IOException { - CloseableHttpClient httpClient = null; - try { - if (isHttps) { - SSLContext sslContext = new SSLContextBuilder() - .loadTrustMaterial(null, new TrustStrategy() { - // 信任所有 - @Override - public boolean isTrusted(X509Certificate[] chain, - String authType) - throws CertificateException { - return true; - } - }).build(); - SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory( - sslContext); - httpClient = HttpClients.custom().setSSLSocketFactory(sslsf) - .build(); - } else { - httpClient = HttpClients.createDefault(); - } - CloseableHttpResponse response = httpClient.execute(http); - try { - if (response != null) { - if (response.getStatusLine() != null) { - statusCode = response.getStatusLine().getStatusCode(); - } - HttpEntity entity = response.getEntity(); - // 响应内容 - content = EntityUtils.toString(entity, Consts.UTF_8); - } - } finally { - response.close(); - } - } catch (Exception e) { - e.printStackTrace(); - } finally { - httpClient.close(); - } - } - - public int getStatusCode() { - return statusCode; - } - - public String getContent() throws ParseException, IOException { - return content; - } -} \ No newline at end of file diff --git a/ty-common/src/main/java/top/kuanghua/khcomomon/entity/IdWorker.java b/ty-common/src/main/java/top/kuanghua/khcomomon/entity/IdWorker.java deleted file mode 100644 index a741d39..0000000 --- a/ty-common/src/main/java/top/kuanghua/khcomomon/entity/IdWorker.java +++ /dev/null @@ -1,172 +0,0 @@ -package top.kuanghua.khcomomon.entity; - -import java.lang.management.ManagementFactory; -import java.net.InetAddress; -import java.net.NetworkInterface; - -/** - *

名称:IdWorker.java

- *

描述:分布式自增长ID

- *
- *     Twitter的 Snowflake JAVA实现方案
- * 
- * 核心代码为其IdWorker这个类实现,其原理结构如下,我分别用一个0表示一位,用—分割开部分的作用: - * 1||0---0000000000 0000000000 0000000000 0000000000 0 --- 00000 ---00000 ---000000000000 - * 在上面的字符串中,第一位为未使用(实际上也可作为long的符号位),接下来的41位为毫秒级时间, - * 然后5位datacenter标识位,5位机器ID(并不算标识符,实际是为线程标识), - * 然后12位该毫秒内的当前毫秒内的计数,加起来刚好64位,为一个Long型。 - * 这样的好处是,整体上按照时间自增排序,并且整个分布式系统内不会产生ID碰撞(由datacenter和机器ID作区分), - * 并且效率较高,经测试,snowflake每秒能够产生26万ID左右,完全满足需要。 - *

- * 64位ID (42(毫秒)+5(机器ID)+5(业务编码)+12(重复累加)) - * - * @author Polim - */ -public class IdWorker { - // 时间起始标记点,作为基准,一般取系统的最近时间(一旦确定不能变动) - private final static long twepoch = 1288834974657L; - // 机器标识位数 - private final static long workerIdBits = 5L; - // 数据中心标识位数 - private final static long datacenterIdBits = 5L; - // 机器ID最大值 - private final static long maxWorkerId = -1L ^ (-1L << workerIdBits); - // 数据中心ID最大值 - private final static long maxDatacenterId = -1L ^ (-1L << datacenterIdBits); - // 毫秒内自增位 - private final static long sequenceBits = 12L; - // 机器ID偏左移12位 - private final static long workerIdShift = sequenceBits; - // 数据中心ID左移17位 - private final static long datacenterIdShift = sequenceBits + workerIdBits; - // 时间毫秒左移22位 - private final static long timestampLeftShift = sequenceBits + workerIdBits + datacenterIdBits; - - private final static long sequenceMask = -1L ^ (-1L << sequenceBits); - /* 上次生产id时间戳 */ - private static long lastTimestamp = -1L; - // 0,并发控制 - private long sequence = 0L; - - private final long workerId; - // 数据标识id部分 - private final long datacenterId; - - public IdWorker(){ - this.datacenterId = getDatacenterId(maxDatacenterId); - this.workerId = getMaxWorkerId(datacenterId, maxWorkerId); - } - /** - * @param workerId - * 工作机器ID - * @param datacenterId - * 序列号 - */ - public IdWorker(long workerId, long datacenterId) { - if (workerId > maxWorkerId || workerId < 0) { - throw new IllegalArgumentException(String.format("worker Id can't be greater than %d or less than 0", maxWorkerId)); - } - if (datacenterId > maxDatacenterId || datacenterId < 0) { - throw new IllegalArgumentException(String.format("datacenter Id can't be greater than %d or less than 0", maxDatacenterId)); - } - this.workerId = workerId; - this.datacenterId = datacenterId; - } - /** - * 获取下一个ID - * - * @return - */ - public synchronized long nextId() { - long timestamp = timeGen(); - if (timestamp < lastTimestamp) { - throw new RuntimeException(String.format("Clock moved backwards. Refusing to generate id for %d milliseconds", lastTimestamp - timestamp)); - } - - if (lastTimestamp == timestamp) { - // 当前毫秒内,则+1 - sequence = (sequence + 1) & sequenceMask; - if (sequence == 0) { - // 当前毫秒内计数满了,则等待下一秒 - timestamp = tilNextMillis(lastTimestamp); - } - } else { - sequence = 0L; - } - lastTimestamp = timestamp; - // ID偏移组合生成最终的ID,并返回ID - long nextId = ((timestamp - twepoch) << timestampLeftShift) - | (datacenterId << datacenterIdShift) - | (workerId << workerIdShift) | sequence; - - return nextId; - } - - private long tilNextMillis(final long lastTimestamp) { - long timestamp = this.timeGen(); - while (timestamp <= lastTimestamp) { - timestamp = this.timeGen(); - } - return timestamp; - } - - private long timeGen() { - return System.currentTimeMillis(); - } - - /** - *

- * 获取 maxWorkerId - *

- */ - protected static long getMaxWorkerId(long datacenterId, long maxWorkerId) { - StringBuffer mpid = new StringBuffer(); - mpid.append(datacenterId); - String name = ManagementFactory.getRuntimeMXBean().getName(); - if (!name.isEmpty()) { - /* - * GET jvmPid - */ - mpid.append(name.split("@")[0]); - } - /* - * MAC + PID 的 hashcode 获取16个低位 - */ - return (mpid.toString().hashCode() & 0xffff) % (maxWorkerId + 1); - } - - /** - *

- * 数据标识id部分 - *

- */ - protected static long getDatacenterId(long maxDatacenterId) { - long id = 0L; - try { - InetAddress ip = InetAddress.getLocalHost(); - NetworkInterface network = NetworkInterface.getByInetAddress(ip); - if (network == null) { - id = 1L; - } else { - byte[] mac = network.getHardwareAddress(); - id = ((0x000000FF & (long) mac[mac.length - 1]) - | (0x0000FF00 & (((long) mac[mac.length - 2]) << 8))) >> 6; - id = id % (maxDatacenterId + 1); - } - } catch (Exception e) { - // System.out.println(" getDatacenterId: " + e.getMessage()); - } - return id; - } - - - public static void main(String[] args) { - //推特 26万个不重复的ID - //参数1 参数2 是在0 -31 之间 - IdWorker idWorker = new IdWorker(0,1); - for (int i = 0; i <100 ; i++) { - System.out.println(idWorker.nextId());//用于生成唯一的ID - } - } - -} \ No newline at end of file diff --git a/ty-common/src/main/java/top/kuanghua/khcomomon/entity/Result.java b/ty-common/src/main/java/top/kuanghua/khcomomon/entity/Result.java deleted file mode 100644 index 62ddcc2..0000000 --- a/ty-common/src/main/java/top/kuanghua/khcomomon/entity/Result.java +++ /dev/null @@ -1,69 +0,0 @@ -package top.kuanghua.khcomomon.entity; - -import java.io.Serializable; - -/** - * 描述 - * - * @author 三国的包子 - * @version 1.0 - * @package entity * - * @since 1.0 - */ -public class Result implements Serializable { - private boolean flag;//是否成功 - private Integer code;//返回码 - private String msg;//返回消息 - private T data;//返回数据 - - public Result(boolean flag, Integer code, String msg, Object data) { - this.flag = flag; - this.code = code; - this.msg = msg; - this.data = (T) data; - } - - public Result(boolean flag, Integer code, String msg) { - this.flag = flag; - this.code = code; - this.msg = msg; - } - - public Result() { - this.flag = true; - this.code = StatusCode.OK; - this.msg = "操作成功!"; - } - - public boolean isFlag() { - return flag; - } - - public void setFlag(boolean flag) { - this.flag = flag; - } - - public Integer getCode() { - return code; - } - - public void setCode(Integer code) { - this.code = code; - } - - public String getMessage() { - return msg; - } - - public void setMessage(String msg) { - this.msg = msg; - } - - public T getData() { - return data; - } - - public void setData(T data) { - this.data = data; - } -} diff --git a/ty-common/src/main/java/top/kuanghua/khcomomon/utils/ChineseUtils.java b/ty-common/src/main/java/top/kuanghua/khcomomon/utils/ChineseUtils.java deleted file mode 100644 index 15036ed..0000000 --- a/ty-common/src/main/java/top/kuanghua/khcomomon/utils/ChineseUtils.java +++ /dev/null @@ -1,65 +0,0 @@ -package top.kuanghua.khcomomon.utils; - -import java.io.UnsupportedEncodingException; -import java.util.Random; - -/*** - * - * @Author:kuanghua - * - ****/ -public class ChineseUtils { - - private static Random random = null; - - private static Random getRandomInstance() { - if (random == null) { - random = new Random(System.currentTimeMillis()); - } - return random; - } - - public static String getChinese() { - String str = null; - int highPos, lowPos; - Random random = getRandomInstance(); - highPos = (176 + Math.abs(random.nextInt(39))); - lowPos = 161 + Math.abs(random.nextInt(93)); - byte[] b = new byte[2]; - b[0] = (new Integer(highPos)).byteValue(); - b[1] = (new Integer(lowPos)).byteValue(); - try { - str = new String(b, "GB2312"); - } catch (UnsupportedEncodingException e) { - e.printStackTrace(); - } - return str; - } - - public static String getFixedLengthChinese(int length) { - String str = ""; - for (int i = length; i > 0; i--) { - str = str + ChineseUtils.getChinese(); - } - return str; - } - - public static String getRandomLengthChiness(int start, int end) { - String str = ""; - int length = new Random().nextInt(end + 1); - if (length < start) { - str = getRandomLengthChiness(start, end); - } else { - for (int i = 0; i < length; i++) { - str = str + getChinese(); - } - } - return str; - } - - public static void main(String args[]) { -// System.out.println(ChineseUtils.getChinese()); -// System.out.println(ChineseUtils.getFixedLengthChinese(20)); -// System.out.println(ChineseUtils.getRandomLengthChiness(2, 5)); - } -} diff --git a/ty-common/src/main/java/top/kuanghua/khcomomon/utils/DateUtilSelf.java b/ty-common/src/main/java/top/kuanghua/khcomomon/utils/DateUtilSelf.java deleted file mode 100644 index 8d0c2de..0000000 --- a/ty-common/src/main/java/top/kuanghua/khcomomon/utils/DateUtilSelf.java +++ /dev/null @@ -1,164 +0,0 @@ -package top.kuanghua.khcomomon.utils; - -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.*; - -/*** - * @Description: 时间操作工具类 - * @Author:kuanghua - ****/ -public class DateUtilSelf { - - //时间格式 - public static final String PATTERN_YYYYMMDDHH = "yyyyMMddHH"; - public static final String PATTERN_YYYY_MM_DDHHMM = "yyyy-MM-dd HH:mm"; - /*** - * 从yyyy-MM-dd HH:mm格式转成yyyyMMddHH格式 - * @param dateStr - * @return - */ - public static String formatStr(String dateStr,String opattern,String npattern){ - SimpleDateFormat simpleDateFormat = new SimpleDateFormat(opattern); - try { - Date date = simpleDateFormat.parse(dateStr); - simpleDateFormat = new SimpleDateFormat(npattern); - return simpleDateFormat.format(date); - } catch (ParseException e) { - e.printStackTrace(); - } - return null; - } - - /*获取当前时间*/ - public static String getCurrentTime(){ - SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm"); - String format = simpleDateFormat.format(new Date()); - return format; - } - - /*** - * 获取指定日期的凌晨 - * @return - */ - public static Date toDayStartHour(Date date){ - Calendar calendar = Calendar.getInstance(); - calendar.setTime(date); - calendar.set(Calendar.HOUR_OF_DAY, 0); - calendar.set(Calendar.MINUTE, 0); - calendar.set(Calendar.SECOND, 0); - calendar.set(Calendar.MILLISECOND, 0); - Date start = calendar.getTime(); - return start; - } - - - /*** - * 时间增加N分钟 - * @param date - * @param minutes - * @return - */ - public static Date addDateMinutes(Date date,int minutes){ - Calendar calendar = Calendar.getInstance(); - calendar.setTime(date); - calendar.add(Calendar.MINUTE, minutes);// 24小时制 - date = calendar.getTime(); - return date; - } - - /*** - * 时间递增N小时 - * @param hour - * @return - */ - public static Date addDateHour(Date date,int hour){//Jota-time - Calendar calendar = Calendar.getInstance(); - calendar.setTime(date); - calendar.add(Calendar.HOUR, hour);// 24小时制 - date = calendar.getTime(); - return date; - } - - /*** - * 获取时间菜单 - * @return - */ - public static List getDateMenus(){ - //定义一个List集合,存储所有时间段 - List dates = getDates(12); - //判断当前时间属于哪个时间范围 - Date now = new Date(); - for (Date cdate : dates) { - //开始时间<=当前时间<开始时间+2小时 - if(cdate.getTime()<=now.getTime() && now.getTime() dateMenus = new ArrayList(); - for (int i = 0; i <5 ; i++) { - dateMenus.add(addDateHour(now,i*2)); - } - return dateMenus; - } - - /*** - * 指定时间往后N个时间间隔 - * @param hours - * @return - */ - public static List getDates(int hours) { - List dates = new ArrayList(); - //循环12次 - Date date = toDayStartHour(new Date()); //凌晨 - for (int i = 0; i 集合中 - dates.add(addDateHour(date,i*2)); - } - return dates; - } - - /*** - * 时间转换(yyyyMMddHH) - * @param date - * @param pattern - * @return - */ - public static String data2str(Date date, String pattern){ - SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern); - return simpleDateFormat.format(date); - } - - - /** - * 计算时间差 - * @param startTime - * @param endTime - * @param format - * @return 两个时间的差(小时,分钟等) - * @throws ParseException - */ - public static HashMap dateDiff(String startTime, String endTime, String format) throws ParseException { - //按照dao传入的格式生成一个simpledateformate对象 - SimpleDateFormat sd = new SimpleDateFormat(format); - long nd = 1000 * 24 * 60 * 60;//一天的毫秒数 - long nh = 1000 * 60 * 60;//一小时的毫秒数 - long nm = 1000 * 60;//一分钟的毫秒数 - long ns = 1000;//一秒钟的毫秒数long diff;try { - //获得两个时间的毫秒时间差异 - long diff = sd.parse(endTime).getTime() - sd.parse(startTime).getTime(); - long day = diff / nd;//计算差多少天 - long hour = diff % nd / nh;//计算差多少小时 - long min = diff % nd % nh / nm;//计算差多少分钟 - long sec = diff % nd % nh % nm / ns;//计算差多少秒//输出结果 - HashMap map = new HashMap<>(); - map.put("day",day); - map.put("hour",hour); - map.put("min",min>=10?min:'0'+min); - map.put("sec",sec); - return map; - } -} diff --git a/ty-common/src/main/java/top/kuanghua/khcomomon/utils/IdWorker.java b/ty-common/src/main/java/top/kuanghua/khcomomon/utils/IdWorker.java deleted file mode 100644 index 520a05f..0000000 --- a/ty-common/src/main/java/top/kuanghua/khcomomon/utils/IdWorker.java +++ /dev/null @@ -1,163 +0,0 @@ -package top.kuanghua.khcomomon.utils; - -import java.lang.management.ManagementFactory; -import java.net.InetAddress; -import java.net.NetworkInterface; - -/** - *

名称:IdWorker.java

- *

描述:分布式自增长ID

- *
- *     Twitter的 Snowflake JAVA实现方案
- * 
- * 核心代码为其IdWorker这个类实现,其原理结构如下,我分别用一个0表示一位,用—分割开部分的作用: - * 1||0---0000000000 0000000000 0000000000 0000000000 0 --- 00000 ---00000 ---000000000000 - * 在上面的字符串中,第一位为未使用(实际上也可作为long的符号位),接下来的41位为毫秒级时间, - * 然后5位datacenter标识位,5位机器ID(并不算标识符,实际是为线程标识), - * 然后12位该毫秒内的当前毫秒内的计数,加起来刚好64位,为一个Long型。 - * 这样的好处是,整体上按照时间自增排序,并且整个分布式系统内不会产生ID碰撞(由datacenter和机器ID作区分), - * 并且效率较高,经测试,snowflake每秒能够产生26万ID左右,完全满足需要。 - *

- * 64位ID (42(毫秒)+5(机器ID)+5(业务编码)+12(重复累加)) - * - * @author Polim - */ -public class IdWorker { - // 时间起始标记点,作为基准,一般取系统的最近时间(一旦确定不能变动) - private final static long twepoch = 1288834974657L; - // 机器标识位数 - private final static long workerIdBits = 5L; - // 数据中心标识位数 - private final static long datacenterIdBits = 5L; - // 机器ID最大值 - private final static long maxWorkerId = -1L ^ (-1L << workerIdBits); - // 数据中心ID最大值 - private final static long maxDatacenterId = -1L ^ (-1L << datacenterIdBits); - // 毫秒内自增位 - private final static long sequenceBits = 12L; - // 机器ID偏左移12位 - private final static long workerIdShift = sequenceBits; - // 数据中心ID左移17位 - private final static long datacenterIdShift = sequenceBits + workerIdBits; - // 时间毫秒左移22位 - private final static long timestampLeftShift = sequenceBits + workerIdBits + datacenterIdBits; - - private final static long sequenceMask = -1L ^ (-1L << sequenceBits); - /* 上次生产id时间戳 */ - private static long lastTimestamp = -1L; - // 0,并发控制 - private long sequence = 0L; - - private final long workerId; - // 数据标识id部分 - private final long datacenterId; - - public IdWorker() { - this.datacenterId = getDatacenterId(maxDatacenterId); - this.workerId = getMaxWorkerId(datacenterId, maxWorkerId); - } - - /** - * @param workerId 工作机器ID - * @param datacenterId 序列号 - */ - public IdWorker(long workerId, long datacenterId) { - if (workerId > maxWorkerId || workerId < 0) { - throw new IllegalArgumentException(String.format("worker Id can't be greater than %d or less than 0", maxWorkerId)); - } - if (datacenterId > maxDatacenterId || datacenterId < 0) { - throw new IllegalArgumentException(String.format("datacenter Id can't be greater than %d or less than 0", maxDatacenterId)); - } - this.workerId = workerId; - this.datacenterId = datacenterId; - } - - /** - * 获取下一个ID - * - * @return - */ - public synchronized long nextId() { - long timestamp = timeGen(); - if (timestamp < lastTimestamp) { - throw new RuntimeException(String.format("Clock moved backwards. Refusing to generate id for %d milliseconds", lastTimestamp - timestamp)); - } - - if (lastTimestamp == timestamp) { - // 当前毫秒内,则+1 - sequence = (sequence + 1) & sequenceMask; - if (sequence == 0) { - // 当前毫秒内计数满了,则等待下一秒 - timestamp = tilNextMillis(lastTimestamp); - } - } else { - sequence = 0L; - } - lastTimestamp = timestamp; - // ID偏移组合生成最终的ID,并返回ID - long nextId = ((timestamp - twepoch) << timestampLeftShift) - | (datacenterId << datacenterIdShift) - | (workerId << workerIdShift) | sequence; - - return nextId; - } - - private long tilNextMillis(final long lastTimestamp) { - long timestamp = this.timeGen(); - while (timestamp <= lastTimestamp) { - timestamp = this.timeGen(); - } - return timestamp; - } - - private long timeGen() { - return System.currentTimeMillis(); - } - - /** - *

- * 获取 maxWorkerId - *

- */ - protected static long getMaxWorkerId(long datacenterId, long maxWorkerId) { - StringBuffer mpid = new StringBuffer(); - mpid.append(datacenterId); - String name = ManagementFactory.getRuntimeMXBean().getName(); - if (!name.isEmpty()) { - /* - * GET jvmPid - */ - mpid.append(name.split("@")[0]); - } - /* - * MAC + PID 的 hashcode 获取16个低位 - */ - return (mpid.toString().hashCode() & 0xffff) % (maxWorkerId + 1); - } - - /** - *

- * 数据标识id部分 - *

- */ - protected static long getDatacenterId(long maxDatacenterId) { - long id = 0L; - try { - InetAddress ip = InetAddress.getLocalHost(); - NetworkInterface network = NetworkInterface.getByInetAddress(ip); - if (network == null) { - id = 1L; - } else { - byte[] mac = network.getHardwareAddress(); - id = ((0x000000FF & (long) mac[mac.length - 1]) - | (0x0000FF00 & (((long) mac[mac.length - 2]) << 8))) >> 6; - id = id % (maxDatacenterId + 1); - } - } catch (Exception e) { - //System.out.println(" getDatacenterId: " + e.getMessage()); - } - return id; - } - - -} \ No newline at end of file diff --git a/ty-common/src/main/java/top/kuanghua/khcomomon/utils/JwtUtil.java b/ty-common/src/main/java/top/kuanghua/khcomomon/utils/JwtUtil.java deleted file mode 100644 index ff2f3f7..0000000 --- a/ty-common/src/main/java/top/kuanghua/khcomomon/utils/JwtUtil.java +++ /dev/null @@ -1,104 +0,0 @@ -package top.kuanghua.khcomomon.utils; - -import io.jsonwebtoken.Claims; -import io.jsonwebtoken.JwtBuilder; -import io.jsonwebtoken.Jwts; -import io.jsonwebtoken.SignatureAlgorithm; - -import javax.crypto.SecretKey; -import javax.crypto.spec.SecretKeySpec; -import java.util.Base64; -import java.util.Date; -import java.util.Map; - -/** - * 描述 - * - * @author kuanghua - * @version 1.0 - * @package entity * - * @since 1.0 - */ -public class JwtUtil { - //有效期为 - public static final Long JWT_TTL = 3600000L;// 60 * 60 *1000 一个小时 - - //Jwt令牌信息 - public static final String JWT_KEY = "@Kuanghua8866"; - - /** - * 生成令牌 - //* @param id - //* @param subject - * @param ttlMillis - * @return - */ - public static String createJWT(Map userInfo, Long ttlMillis) { - //指定算法 - SignatureAlgorithm signatureAlgorithm = SignatureAlgorithm.HS256; - //当前系统时间 - long nowMillis = System.currentTimeMillis(); - //令牌签发时间 - Date now = new Date(nowMillis); - //如果令牌有效期为null,则默认设置有效期1小时 - if (ttlMillis == null) { - ttlMillis = JwtUtil.JWT_TTL; - } - //令牌过期时间设置 - long expMillis = nowMillis + ttlMillis; - Date expDate = new Date(expMillis); - - //生成秘钥 - SecretKey secretKey = generalKey(); - - //封装Jwt令牌信息 - JwtBuilder builder = Jwts.builder() - //.setId(id) - //.setSubject(subject) // 主题 可以是JSON数据 - //.setIssuer("admin") // 签发者 - .setIssuedAt(now) // 签发时间 - .signWith(signatureAlgorithm, secretKey) // 签名算法以及密匙 - .setExpiration(expDate); // 设置过期时间 - - JwtBuilder jwtBuilder = builder.addClaims(userInfo); - return builder.compact(); - } - - /** - * 生成加密 secretKey - * - * @return - */ - public static SecretKey generalKey() { - byte[] encodedKey = Base64.getEncoder().encode(JwtUtil.JWT_KEY.getBytes()); - SecretKey key = new SecretKeySpec(encodedKey, 0, encodedKey.length, "AES"); - return key; - } - - /** - * 解析令牌数据 - * - * @param jwt - * @return - * @throws Exception - */ - public static Claims parseJWT(String jwt) throws Exception { - SecretKey secretKey = generalKey(); - return Jwts.parser() - .setSigningKey(secretKey) - .parseClaimsJws(jwt) - .getBody(); - } -// public static void main(String[] args) { -// String jwt = JwtUtil.createJWT("weiyibiaoshi", ) -// System.out.println(jwt); -// try { -// Claims claims = JwtUtil.parseJWT(jwt); -// System.out.println(claims); -// } catch (Exception e) { -// e.printStackTrace(); -// } -// -// -// } -} diff --git a/ty-common/src/main/java/top/kuanghua/khcomomon/utils/NumberUtilsSelf.java b/ty-common/src/main/java/top/kuanghua/khcomomon/utils/NumberUtilsSelf.java deleted file mode 100644 index eaae4c6..0000000 --- a/ty-common/src/main/java/top/kuanghua/khcomomon/utils/NumberUtilsSelf.java +++ /dev/null @@ -1,73 +0,0 @@ -package top.kuanghua.khcomomon.utils; - -import java.math.BigDecimal; -import java.math.RoundingMode; -import java.util.ArrayList; -import java.util.List; -import java.util.Random; -import java.util.regex.MatchResult; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * @author: HuYi.Zhang - * @create: 2018-04-25 09:13 - **/ -public class NumberUtilsSelf { - - public static boolean isInt(Double num) { - return num.intValue() == num; - } - - /** - * 判断字符串是否是数值格式 - * - * @param str - * @return - */ - public static boolean isDigit(String str) { - if (str == null || str.trim().equals("")) { - return false; - } - return str.matches("^\\d+$"); - } - - /** - * 将一个小数精确到指定位数 - * - * @param num - * @param scale - * @return - */ - public static double scale(double num, int scale) { - BigDecimal bd = new BigDecimal(num); - return bd.setScale(scale, RoundingMode.HALF_UP).doubleValue(); - } - - // 从字符串中根据正则表达式寻找,返回找到的数字数组 - public static Double[] searchNumber(String value, String regex) { - List doubles = new ArrayList<>(); - Pattern pattern = Pattern.compile(regex); - Matcher matcher = pattern.matcher(value); - if (matcher.find()) { - MatchResult result = matcher.toMatchResult(); - for (int i = 1; i <= result.groupCount(); i++) { - doubles.add(Double.valueOf(result.group(i))); - } - } - return doubles.toArray(new Double[doubles.size()]); - } - - /** - * 生成指定位数的随机数字 - * - * @param len - * @return - */ - public static String generateCode(int len) { - len = Math.min(len, 8); - int min = Double.valueOf(Math.pow(10, len - 1)).intValue(); - int num = new Random().nextInt(Double.valueOf(Math.pow(10, len + 1)).intValue() - 1) + min; - return String.valueOf(num).substring(0, len); - } -} diff --git a/ty-common/src/main/java/top/kuanghua/khcomomon/utils/RandomValueUtil.java b/ty-common/src/main/java/top/kuanghua/khcomomon/utils/RandomValueUtil.java deleted file mode 100644 index d35f22d..0000000 --- a/ty-common/src/main/java/top/kuanghua/khcomomon/utils/RandomValueUtil.java +++ /dev/null @@ -1,126 +0,0 @@ -package top.kuanghua.khcomomon.utils; - -/*** - * - * @Author:kuanghua - * - ****/ -public class RandomValueUtil { - public static String base = "abcdefghijklmnopqrstuvwxyz0123456789"; - private static String firstName="赵钱孙李周吴郑王冯陈褚卫蒋沈韩杨朱秦尤许何吕施张孔曹严华金魏陶姜戚谢邹喻柏水窦章云苏潘葛奚范彭郎鲁韦昌马苗凤花方俞任袁柳酆鲍史唐费廉岑薛雷贺倪汤滕殷罗毕郝邬安常乐于时傅皮卞齐康伍余元卜顾孟平黄和穆萧尹姚邵湛汪祁毛禹狄米贝明臧计伏成戴谈宋茅庞熊纪舒屈项祝董梁杜阮蓝闵席季麻强贾路娄危江童颜郭梅盛林刁钟徐邱骆高夏蔡田樊胡凌霍虞万支柯咎管卢莫经房裘缪干解应宗宣丁贲邓郁单杭洪包诸左石崔吉钮龚程嵇邢滑裴陆荣翁荀羊於惠甄魏加封芮羿储靳汲邴糜松井段富巫乌焦巴弓牧隗山谷车侯宓蓬全郗班仰秋仲伊宫宁仇栾暴甘钭厉戎祖武符刘姜詹束龙叶幸司韶郜黎蓟薄印宿白怀蒲台从鄂索咸籍赖卓蔺屠蒙池乔阴郁胥能苍双闻莘党翟谭贡劳逄姬申扶堵冉宰郦雍却璩桑桂濮牛寿通边扈燕冀郏浦尚农温别庄晏柴瞿阎充慕连茹习宦艾鱼容向古易慎戈廖庚终暨居衡步都耿满弘匡国文寇广禄阙东殴殳沃利蔚越夔隆师巩厍聂晁勾敖融冷訾辛阚那简饶空曾毋沙乜养鞠须丰巢关蒯相查后江红游竺权逯盖益桓公万俟司马上官欧阳夏侯诸葛闻人东方赫连皇甫尉迟公羊澹台公冶宗政濮阳淳于仲孙太叔申屠公孙乐正轩辕令狐钟离闾丘长孙慕容鲜于宇文司徒司空亓官司寇仉督子车颛孙端木巫马公西漆雕乐正壤驷公良拓拔夹谷宰父谷粱晋楚阎法汝鄢涂钦段干百里东郭南门呼延归海羊舌微生岳帅缑亢况后有琴梁丘左丘东门西门商牟佘佴伯赏南宫墨哈谯笪年爱阳佟第五言福百家姓续"; - private static String girl="秀娟英华慧巧美娜静淑惠珠翠雅芝玉萍红娥玲芬芳燕彩春菊兰凤洁梅琳素云莲真环雪荣爱妹霞香月莺媛艳瑞凡佳嘉琼勤珍贞莉桂娣叶璧璐娅琦晶妍茜秋珊莎锦黛青倩婷姣婉娴瑾颖露瑶怡婵雁蓓纨仪荷丹蓉眉君琴蕊薇菁梦岚苑婕馨瑗琰韵融园艺咏卿聪澜纯毓悦昭冰爽琬茗羽希宁欣飘育滢馥筠柔竹霭凝晓欢霄枫芸菲寒伊亚宜可姬舒影荔枝思丽 "; - public static String boy="伟刚勇毅俊峰强军平保东文辉力明永健世广志义兴良海山仁波宁贵福生龙元全国胜学祥才发武新利清飞彬富顺信子杰涛昌成康星光天达安岩中茂进林有坚和彪博诚先敬震振壮会思群豪心邦承乐绍功松善厚庆磊民友裕河哲江超浩亮政谦亨奇固之轮翰朗伯宏言若鸣朋斌梁栋维启克伦翔旭鹏泽晨辰士以建家致树炎德行时泰盛雄琛钧冠策腾楠榕风航弘"; - public static final String[] email_suffix="@gmail.com,@yahoo.com,@msn.com,@hotmail.com,@aol.com,@ask.com,@live.com,@qq.com,@0355.net,@163.com,@163.net,@263.net,@3721.net,@yeah.net,@googlemail.com,@126.com,@sina.com,@sohu.com,@yahoo.com.cn".split(","); - - public static int getNum(int start,int end) { - return (int)(Math.random()*(end-start+1)+start); - } - - /*** - * - * Project Name: recruit-helper-util - *

随机生成Email - * - * @author youqiang.xiong - * @date 2018年5月23日 下午2:13:06 - * @version v1.0 - * @since - * @param lMin - * 最小长度 - * @param lMax - * 最大长度 - * @return - */ - public static String getEmail(int lMin,int lMax) { - int length=getNum(lMin,lMax); - StringBuffer sb = new StringBuffer(); - for (int i = 0; i < length; i++) { - int number = (int)(Math.random()*base.length()); - sb.append(base.charAt(number)); - } - sb.append(email_suffix[(int)(Math.random()*email_suffix.length)]); - return sb.toString(); - } - - private static String[] telFirst="134,135,136,137,138,139,150,151,152,157,158,159,130,131,132,155,156,133,153".split(","); - - /*** - * - * Project Name: recruit-helper-util - *

随机生成手机号码 - * - * @author youqiang.xiong - * @date 2018年5月23日 下午2:14:17 - * @version v1.0 - * @since - * @return - */ - public static String getTelephone() { - int index=getNum(0,telFirst.length-1); - String first=telFirst[index]; - String second=String.valueOf(getNum(1,888)+10000).substring(1); - String thrid=String.valueOf(getNum(1,9100)+10000).substring(1); - return first+second+thrid; - } - - /*** - * - * Project Name: recruit-helper-util - *

随机生成8位电话号码 - * - * @author youqiang.xiong - * @date 2018年5月23日 下午2:15:31 - * @version v1.0 - * @since - * @return - */ - public static String getLandline() { - int index=getNum(0,telFirst.length-1); - String first=telFirst[index]; - String second=String.valueOf(getNum(1,888)+10000).substring(1); - String thrid=String.valueOf(getNum(1,9100)+10000).substring(1); - return first+second+thrid; - } - - - - /** - * 返回中文姓名 - */ - public static String name_sex = ""; - - /*** - * - * Project Name: recruit-helper-util - *

返回中文姓名 - * - * @author youqiang.xiong - * @date 2018年5月23日 下午2:16:16 - * @version v1.0 - * @since - * @return - */ - public static String getChineseName() { - int index = getNum(0, firstName.length() - 1); - String first = firstName.substring(index, index + 1); - int sex = getNum(0, 1); - String str = boy; - int length = boy.length(); - if (sex == 0) { - str = girl; - length = girl.length(); - name_sex = "女"; - } else { - name_sex = "男"; - } - index = getNum(0, length - 1); - String second = str.substring(index, index + 1); - int hasThird = getNum(0, 1); - String third = ""; - if (hasThird == 1) { - index = getNum(0, length - 1); - third = str.substring(index, index + 1); - } - return first + second + third; - } -} diff --git a/ty-common/src/main/java/top/kuanghua/khcomomon/utils/RedisClientUtils.java b/ty-common/src/main/java/top/kuanghua/khcomomon/utils/RedisClientUtils.java deleted file mode 100644 index 841c22b..0000000 --- a/ty-common/src/main/java/top/kuanghua/khcomomon/utils/RedisClientUtils.java +++ /dev/null @@ -1,577 +0,0 @@ -package top.kuanghua.khcomomon.utils; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.redis.core.RedisTemplate; -import org.springframework.stereotype.Component; -import org.springframework.util.CollectionUtils; - -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.TimeUnit; - -/** - * Redis工具类 - */ -@Component -public class RedisClientUtils { - - @Autowired - 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; - } - } - - /** - * 根据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)); - } - } - } - - public void del(Integer key) { - this.del(String.valueOf(key)); - } - - // ============================String============================= - - /** - * 普通缓存获取 - * - * @param key 键 - * @return 值 - */ - public Object get(String key) { - return key == null ? null : redisTemplate.opsForValue().get(key); - } - - public Object get(Integer key) { - return this.get(String.valueOf(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; - } - } - - public boolean set(Integer key, Object value) { - return this.set(String.valueOf(key), value); - } - - /** - * 普通缓存放入并设置时间 - * - * @param key 键 - * @param value 值 - * @param time 时间(秒) time要大于0 如果time小于等于0 将设置无限期 - * @return true成功 false 失败 - */ - public boolean set(String key, Object value, long time) { - try { - if (time > 0) { - redisTemplate.opsForValue().set(key, value, time, 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, String item, Object value, long time) { - try { - redisTemplate.opsForHash().put(key, item, value); - if (time > 0) { - expire(key, time); - } - return true; - } catch (Exception 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; - } - } -} diff --git a/ty-common/src/main/java/top/kuanghua/khcomomon/utils/ThreadUtils.java b/ty-common/src/main/java/top/kuanghua/khcomomon/utils/ThreadUtils.java deleted file mode 100644 index cbdb057..0000000 --- a/ty-common/src/main/java/top/kuanghua/khcomomon/utils/ThreadUtils.java +++ /dev/null @@ -1,13 +0,0 @@ -package top.kuanghua.khcomomon.utils; - -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; - -public class ThreadUtils { - - private static final ExecutorService es = Executors.newFixedThreadPool(10); - - public static void execute(Runnable runnable) { - es.submit(runnable); - } -} \ No newline at end of file diff --git a/ty-common/src/main/resources/application-dev.yml b/ty-common/src/main/resources/application-dev.yml deleted file mode 100644 index 0397283..0000000 --- a/ty-common/src/main/resources/application-dev.yml +++ /dev/null @@ -1,7 +0,0 @@ -spring: - main: - allow-bean-definition-overriding: true - #解决查询时间和返回的时间不一致问题 - jackson: - date-format: yyyy-MM-dd HH:mm:ss - time-zone: GMT+8 \ No newline at end of file diff --git a/ty-common/src/main/resources/application-prod.yml b/ty-common/src/main/resources/application-prod.yml deleted file mode 100644 index 0397283..0000000 --- a/ty-common/src/main/resources/application-prod.yml +++ /dev/null @@ -1,7 +0,0 @@ -spring: - main: - allow-bean-definition-overriding: true - #解决查询时间和返回的时间不一致问题 - jackson: - date-format: yyyy-MM-dd HH:mm:ss - time-zone: GMT+8 \ No newline at end of file diff --git a/ty-common/src/main/resources/application-test.yml b/ty-common/src/main/resources/application-test.yml deleted file mode 100644 index 0397283..0000000 --- a/ty-common/src/main/resources/application-test.yml +++ /dev/null @@ -1,7 +0,0 @@ -spring: - main: - allow-bean-definition-overriding: true - #解决查询时间和返回的时间不一致问题 - jackson: - date-format: yyyy-MM-dd HH:mm:ss - time-zone: GMT+8 \ No newline at end of file diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/ExampleApplication.java b/ty-example/src/main/java/top/kuanghua/tyexample/ExampleApplication.java deleted file mode 100644 index 4d0b9d6..0000000 --- a/ty-example/src/main/java/top/kuanghua/tyexample/ExampleApplication.java +++ /dev/null @@ -1,19 +0,0 @@ -package top.kuanghua.tyexample; - -import com.xpand.starter.canal.annotation.EnableCanalClient; -import io.seata.spring.annotation.datasource.EnableAutoDataSourceProxy; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.scheduling.annotation.EnableAsync; -import org.springframework.scheduling.annotation.EnableScheduling; - -@SpringBootApplication -@EnableScheduling -@EnableAsync -@EnableCanalClient -@EnableAutoDataSourceProxy -public class ExampleApplication { - public static void main(String[] args) { - SpringApplication.run(ExampleApplication.class, args); - } -} diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/config/BaseConfig.java b/ty-example/src/main/java/top/kuanghua/tyexample/config/BaseConfig.java deleted file mode 100644 index bac5ac1..0000000 --- a/ty-example/src/main/java/top/kuanghua/tyexample/config/BaseConfig.java +++ /dev/null @@ -1,27 +0,0 @@ -package top.kuanghua.tyexample.config; - -import org.mybatis.spring.annotation.MapperScan; -import org.springframework.cloud.openfeign.EnableFeignClients; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; - -/** - * @Title: BaseConfig - * @Description: - * @Auther: kuanghua - * @create 2020/8/23 21:52 - */ -/* - * 总结:1.@Configuration 下的@ComponentScan回将包下带有@Component扫描变成配置类, - * 而@SpringBootApplication扫描的只会变成普通类 - * */ -@Configuration -//扫描公用包的配置和自身的配置类 -@ComponentScan(basePackages = {"top.kuanghua.khcomomon"}) -//mapper scanning -@MapperScan(basePackages = {"top.kuanghua.tyexample.mapper"}) -//feign scanning -@EnableFeignClients(basePackages = {"top.kuanghua.feign.integrationfront", "top.kuanghua.feign.tyauth",}) -public class BaseConfig { - -} diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/config/RabbitDelayConfig.java b/ty-example/src/main/java/top/kuanghua/tyexample/config/RabbitDelayConfig.java deleted file mode 100644 index 1959f7f..0000000 --- a/ty-example/src/main/java/top/kuanghua/tyexample/config/RabbitDelayConfig.java +++ /dev/null @@ -1,67 +0,0 @@ -package top.kuanghua.tyexample.config; - -import lombok.extern.slf4j.Slf4j; -import org.springframework.amqp.core.*; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -import java.util.HashMap; -import java.util.Map; - -/** - * @Title: Configuration - * @Description: - * @Auther: kuanghua - * @create 2022/1/05 10:04 - */ -@Configuration -@Slf4j -public class RabbitDelayConfig { - - /*死信部分*/ - public static final String ORDER_DELAY_QUEUE = "queue.delay.user.order"; - public static final String ORDER_DELAY_EXCHANGE = "exchange.delay.user.order"; - public static final String ORDER_DELAY_ROUTING_KEY = "delay_order"; - /*普通交换机*/ - public static final String ORDER_QUEUE_NAME = "queue.user.order"; - public static final String ORDER_EXCHANGE_NAME = "exchange.user.order"; - public static final String ORDER_ROUTING_KEY = "order"; - - /* - * DELAY_EXCHANGE - * 死信交换机原理:发送到死信交换机(在有效期时间内接收信息不进行转发,超时则进行转发到其他队列) - * */ - @Bean - public Queue delayOrderQueue() { - Map params = new HashMap<>(); - // 转发的队列交换机的名称 - params.put("x-dead-letter-exchange", ORDER_EXCHANGE_NAME); - // 转发的队列队列的路由名称 - params.put("x-dead-letter-routing-key", ORDER_ROUTING_KEY); - return new Queue(ORDER_DELAY_QUEUE, true, false, false, params); - } - @Bean - public DirectExchange orderDelayExchange() { - return new DirectExchange(ORDER_DELAY_EXCHANGE); - } - - - @Bean - public Binding dlxBinding() { - return BindingBuilder.bind(delayOrderQueue()).to(orderDelayExchange()).with(ORDER_DELAY_ROUTING_KEY); - } - - /*普通交换机*/ - @Bean - public Queue orderQueue() { - return new Queue(ORDER_QUEUE_NAME, true); - } - @Bean - public TopicExchange orderTopicExchange() { - return new TopicExchange(ORDER_EXCHANGE_NAME); - } - @Bean - public Binding orderBinding() { - return BindingBuilder.bind(orderQueue()).to(orderTopicExchange()).with(ORDER_ROUTING_KEY); - } -} diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/config/SmsProperties.java b/ty-example/src/main/java/top/kuanghua/tyexample/config/SmsProperties.java deleted file mode 100644 index ab4ad5e..0000000 --- a/ty-example/src/main/java/top/kuanghua/tyexample/config/SmsProperties.java +++ /dev/null @@ -1,25 +0,0 @@ -package top.kuanghua.tyexample.config; - -import lombok.Data; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.stereotype.Component; - -/** - * @Title: SmsProperties - * @Description: - * @Auther:jzfai - * @Version: 1.0 - * @create 2020/3/13 18:19 - */ -@Component -@ConfigurationProperties(prefix = "kuanghua.sms") -@Data -public class SmsProperties { - String accessKeyId; - - String accessKeySecret; - - String signName; - - String verifyCodeTemplate; -} diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/config/Swagger2Config.java b/ty-example/src/main/java/top/kuanghua/tyexample/config/Swagger2Config.java deleted file mode 100644 index 85efbcf..0000000 --- a/ty-example/src/main/java/top/kuanghua/tyexample/config/Swagger2Config.java +++ /dev/null @@ -1,55 +0,0 @@ -package top.kuanghua.tyexample.config; - -import io.swagger.annotations.ApiOperation; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.stereotype.Component; -import springfox.documentation.builders.ApiInfoBuilder; -import springfox.documentation.builders.PathSelectors; -import springfox.documentation.builders.RequestHandlerSelectors; -import springfox.documentation.service.ApiInfo; -import springfox.documentation.service.Contact; -import springfox.documentation.spi.DocumentationType; -import springfox.documentation.spring.web.plugins.Docket; -import springfox.documentation.swagger2.annotations.EnableSwagger2; - -@Component -@EnableSwagger2 //开启在线接口文档 -//配置包扫描 -public class Swagger2Config { - private boolean swagger_is_enable = true; - - @Value("${server.port}") - private String port; - - @Bean - public Docket api() { - return new Docket(DocumentationType.SWAGGER_2) - .enable(swagger_is_enable) - //.host(this.ipAddr + ":" + this.port) - .apiInfo(apiInfo()) - .select() - .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)) - //.apis(basePackage("top.kuanghua.swagger.controller")) - .paths(PathSelectors.any()) - .build(); - } - - /** - * 构建 api文档的详细信息函数 - * - * @return - */ - private ApiInfo apiInfo() { - return new ApiInfoBuilder() - .title("micro-service-plus") - .description("描述:新一代的微服务架构") - .contact(new Contact("kuanghua", null, "869653722@qq.com")) - .version("版本号:2.9") - .build(); - } - - /** - * http://localhost:8080/swagger-ui.html - */ -} diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/controller/GetTokenFromOtherService.java b/ty-example/src/main/java/top/kuanghua/tyexample/controller/GetTokenFromOtherService.java deleted file mode 100644 index 204e161..0000000 --- a/ty-example/src/main/java/top/kuanghua/tyexample/controller/GetTokenFromOtherService.java +++ /dev/null @@ -1,35 +0,0 @@ -package top.kuanghua.tyexample.controller; - -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import lombok.extern.slf4j.Slf4j; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; -import top.kuanghua.feign.tyauth.feign.TestGetTokenFeign; -import top.kuanghua.khcomomon.entity.ResResult; - -import javax.annotation.Resource; - -/** - * @Title: GetTokenFromOtherService - * @Description: - * @Auther: kuanghua - * @create 2022-01-14 17:31 - */ -@RestController -@Api(tags = "feign转发请求头测试") -@RequestMapping("testFeign") -@Slf4j -public class GetTokenFromOtherService { - @Resource - private TestGetTokenFeign testGetTokenFeign; - - @ApiOperation(value = "获取token信息(需要配置gateway拦截,然后用postman在头部添加token进行测试,token可以从vue3-admin-plus中获取)") - @PostMapping("getTokenFromService") - public ResResult getTokenFromService() { - ResResult tokenInfo = testGetTokenFeign.getTokenInfo(); - log.info(tokenInfo.getData().toString()); - return new ResResult<>().success(tokenInfo); - } -} diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/controller/HystrixRibbonController.java b/ty-example/src/main/java/top/kuanghua/tyexample/controller/HystrixRibbonController.java deleted file mode 100644 index ced9bb3..0000000 --- a/ty-example/src/main/java/top/kuanghua/tyexample/controller/HystrixRibbonController.java +++ /dev/null @@ -1,31 +0,0 @@ -package top.kuanghua.tyexample.controller; - -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; -import top.kuanghua.khcomomon.entity.ResResult; - -/** - * @Title: HystrixRibbonController - * @Description: - * @Auther: kuanghua - * @create 2022-01-08 17:20 - */ -@Api(tags = "HystrixRibbon和限流测试") -@RestController -@RequestMapping("hystrixRibbon") -public class HystrixRibbonController { - @ApiOperation(value = "测试Hystrix熔断和Ribbon") - @GetMapping("timeoutTest") - public ResResult timeoutTest() { - try { - Thread.sleep(10000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - return new ResResult<>().success(); - - } -} diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/controller/RabbitDelayController.java b/ty-example/src/main/java/top/kuanghua/tyexample/controller/RabbitDelayController.java deleted file mode 100644 index a67d5f4..0000000 --- a/ty-example/src/main/java/top/kuanghua/tyexample/controller/RabbitDelayController.java +++ /dev/null @@ -1,35 +0,0 @@ -package top.kuanghua.tyexample.controller; - -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; -import top.kuanghua.khcomomon.entity.ResResult; -import top.kuanghua.tyexample.service.RabbitDelayService; - -import javax.annotation.Resource; - -/** - * @Title: RabbitDelayController - * @Description: - * @Auther: kuanghua - * @create 2022-01-06 17:23 - */ -@Api(tags = "延时队列") -@RestController -@RequestMapping("delayQueue") -public class RabbitDelayController { - - @Resource - private RabbitDelayService rabbitDelayService; - - @ApiOperation(value = "测试延时队列") - @GetMapping("convertAndSend") - public ResResult convertAndSend(@ApiParam("延时时间(s)") @RequestParam("time") Integer time) { - rabbitDelayService.convertAndSend(time); - return new ResResult().success(); - } -} diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/controller/RedisTestController.java b/ty-example/src/main/java/top/kuanghua/tyexample/controller/RedisTestController.java deleted file mode 100644 index ea895c9..0000000 --- a/ty-example/src/main/java/top/kuanghua/tyexample/controller/RedisTestController.java +++ /dev/null @@ -1,131 +0,0 @@ -package top.kuanghua.tyexample.controller; - -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.redis.core.BoundHashOperations; -import org.springframework.data.redis.core.RedisTemplate; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; -import top.kuanghua.khcomomon.entity.ResResult; -import top.kuanghua.khcomomon.utils.ObjectUtilsSelf; -import top.kuanghua.khcomomon.utils.RedisClientUtils; -import top.kuanghua.tyexample.entity.ErrorCollection; -import top.kuanghua.tyexample.mapper.ErrorCollectionMapper; - -import javax.annotation.PostConstruct; -import javax.annotation.Resource; -import java.text.MessageFormat; -import java.util.List; -import java.util.concurrent.TimeUnit; - -/** - * @Title: CacheAvalancheController - * @Description: - * @Auther: kuanghua - * @create 2022-01-09 16:48 - */ -@Api(tags = "缓存击穿和雪崩,redis锁") -@RestController -@RequestMapping("redisCache") -public class RedisTestController { - - @Resource - private ErrorCollectionMapper errorCollectionMapper; - - @Autowired - private RedisTemplate redisTemplate; - - @Resource - private RedisClientUtils redisClient; - - - private Integer orderCount = 10; - private String redisCountKey = "orderCo"; - - - @PostConstruct - public void intParam() { - BoundHashOperations hashKey = redisTemplate.boundHashOps("hashKey"); - hashKey.increment(redisCountKey, orderCount); - } - - /* redis缓存击穿问题 - * 1. 当用户根据key 查询数据时,先查询缓存,如果缓存有命中,返回, - 2. 但是如果缓存没有命中直接穿过缓存层,访问数据层 如果有,则存储指缓存, - 3. 但是同样如果没有命中,(也就是数据库中也没有数据)直接返回用户,但是不缓存 - 这就是缓存的穿透。如果某一个key 请求量很大,但是存储层也没有数据,大量的请求都会达到存储层就会造成数据库压力巨大,有可能宕机的情况。 - - - 缓存雪崩 - 如果缓存集中在一段时间内失效,发生大量的缓存穿透,所有的查询都落在数据库上,造成了缓存雪崩。 - 这个没有完美解决办法,但可以分析用户行为,尽量让失效时间点均匀分布。 - + 限流 加锁排队 - - 在缓存失效后,通过对某一个key加锁或者是队列 来控制key的线程访问的数量。例如:某一个key 只允许一个线程进行 操作。 - - + 限流 - - 在缓存失效后,某一个key 做count统计限流,达到一定的阈值,直接丢弃,不再查询数据库。例如:令牌桶算法。等等。 - - + 数据预热 - - 在缓存失效应当尽量避免某一段时间,可以先进行数据预热,比如某些热门的商品。提前在上线之前,或者开放给用户使用之前,先进行loading 缓存中,这样用户使用的时候,直接从缓存中获取。要注意的是,要更加业务来进行过期时间的设置 ,尽量均匀。 - - + 做缓存降级(二级缓存策略) - - 当分布式缓存失效的时候,可以采用本地缓存,本地缓存没有再查询数据库。这种方式,可以避免很多数据分布式缓存没有,就直接打到数据库的情况。 - - * */ - - @ApiOperation(value = "查询错误日志") - @GetMapping("queryErrorLogList") - public ResResult queryErrorLogList() { - String key = "queryErrorLogList"; - /* - * 解决缓存穿透带来的问题 - * 1.查询值为空的时候也设置到redis的key上 - * 2.给空值的key设定过期时间(为了避免过多的KEY 存储在redis中) - * */ - if (redisTemplate.hasKey(key)) { - List redisList = redisTemplate.opsForList().range(key, 0, -1); - return new ResResult().success(redisList); - } else { - List ecList = errorCollectionMapper.selectList(null); - //无论ecList是否为空都设置到redis的key上,解决缓存穿透带来的雪崩问题 - //如果为空,一般情况下都需要设置一个过期时间,例如:5分钟失效。(为了避免过多的KEY 存储在redis中) - redisTemplate.opsForList().leftPushAll(key, ecList); - if (ObjectUtilsSelf.isEmpty(ecList)) { - //此处设置为20s,进行测试 - redisTemplate.expire(key, 20, TimeUnit.SECONDS); - } else { - //此处设置为20s,进行测试,不为空时可以不设置过期时间,根据业务需求进行设置 - redisTemplate.expire(key, 20, TimeUnit.SECONDS); - } - return new ResResult().success(ecList); - - } - } - - - @ApiOperation(value = "并发请求改接口测试redis锁") - @GetMapping("testRedisLock") - public void testRedisLock() throws InterruptedException { - //订单超卖问题 -// orderCount--; -// if (orderCount >= 0) { -// Thread.sleep(1000); -// System.out.println(MessageFormat.format("订单还剩{0}", orderCount)); -// } - - /*用redis锁*/ - BoundHashOperations hashKey = redisTemplate.boundHashOps("hashKey"); - Long decrement = hashKey.increment(redisCountKey, -1); - if (decrement >= 0) { - System.out.println(MessageFormat.format("redis订单还剩{0}", decrement)); - } - - } - -} diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/controller/SeataTestController.java b/ty-example/src/main/java/top/kuanghua/tyexample/controller/SeataTestController.java deleted file mode 100644 index 006e993..0000000 --- a/ty-example/src/main/java/top/kuanghua/tyexample/controller/SeataTestController.java +++ /dev/null @@ -1,30 +0,0 @@ -package top.kuanghua.tyexample.controller; - -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; -import top.kuanghua.tyexample.service.SeataTestService; - -/** - * @Title: SeataTestController - * @Description: - * @Auther: kuanghua - * @create 2022-01-10 15:05 - */ - -@Api(tags = "seata测试") -@RestController -@RequestMapping("seataTest") -public class SeataTestController { - @Autowired - private SeataTestService seataTestService; - - @ApiOperation(value = "测试seata回滚") - @GetMapping("test-seata-rollback") - public void testSeataRollback() { - seataTestService.testSeataRollback(); - } -} diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/controller/SendEmailController.java b/ty-example/src/main/java/top/kuanghua/tyexample/controller/SendEmailController.java deleted file mode 100644 index afbb0f0..0000000 --- a/ty-example/src/main/java/top/kuanghua/tyexample/controller/SendEmailController.java +++ /dev/null @@ -1,50 +0,0 @@ -package top.kuanghua.tyexample.controller; - -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.*; -import org.springframework.web.multipart.MultipartFile; -import top.kuanghua.khcomomon.entity.ResResult; -import top.kuanghua.tyexample.service.SendEmailService; - -import javax.mail.MessagingException; -import java.io.IOException; - -/** - * @Title: SendEmailController - * @Description: - * @Auther: kuanghua - * @create 2020/8/20 22:41 - */ -@Api(tags = "发送邮件") -@RestController -@RequestMapping("email") -public class SendEmailController { - - @Autowired - private SendEmailService sendEmailService; - - @ApiOperation(value = "发送普通文本邮件") - @GetMapping("sendEmailText") - public ResResult sendEmailText(@RequestParam(name = "subject", defaultValue = "这是主题") String subject, - @RequestParam(name = "text", defaultValue = "发送的文本(这是测试文本)") String text, - @RequestParam(name = "sendTo", defaultValue = "1319404169@qq.com") String sendTo) { - sendEmailService.sendEmailText(subject, text, sendTo); - return new ResResult().success("发送邮件成功"); - } - - @ApiOperation(value = "发送文本邮件(可以带附件)", notes = "可以带附件 ") - @PostMapping("sendMimeMail") - public ResResult sendMimeMail(@RequestParam(name = "subject", defaultValue = "这是主题") String subject, - @RequestParam(name = "text", defaultValue = "发送的文本(这是测试文本)") String text, - @RequestParam(name = "sendTo", defaultValue = "1319404169@qq.com") String sendTo, - MultipartFile file) - throws IOException, MessagingException, InterruptedException { - if (file.getOriginalFilename().isEmpty()) { - return new ResResult().error("文件上传空"); - } - sendEmailService.sendMimeMail(subject, text, sendTo, file); - return new ResResult().success("发送邮件成功"); - } -} diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/entity/ErrorCollection.java b/ty-example/src/main/java/top/kuanghua/tyexample/entity/ErrorCollection.java deleted file mode 100644 index afe96e0..0000000 --- a/ty-example/src/main/java/top/kuanghua/tyexample/entity/ErrorCollection.java +++ /dev/null @@ -1,36 +0,0 @@ -package top.kuanghua.tyexample.entity; - -import com.baomidou.mybatisplus.annotation.FieldFill; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableName; -import com.baomidou.mybatisplus.extension.activerecord.Model; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -import java.util.Date; - -/** - * error_log_collection(ErrorCollection)表实体类 - * - * @author kuanghua - * @since 2021-10-08 11:37:25 - */ -@Data -@ApiModel("错误日志相关") -@TableName(value = "tb_error_collection") -public class ErrorCollection extends Model { - @ApiModelProperty(value = "id主键") - private Long id; - @ApiModelProperty(value = "错误日志") - private String errorLog; - @ApiModelProperty(value = "页面路径") - private String pageUrl; - @ApiModelProperty(value = "当前版本") - private String version; - @ApiModelProperty(value = "浏览器类型", hidden = true) - private String browserType; - @TableField(fill = FieldFill.INSERT) - @ApiModelProperty(value = "创建时间", hidden = true) - private Date createTime; -} diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/listener/CanalDataEventListener.java b/ty-example/src/main/java/top/kuanghua/tyexample/listener/CanalDataEventListener.java deleted file mode 100644 index 5bef611..0000000 --- a/ty-example/src/main/java/top/kuanghua/tyexample/listener/CanalDataEventListener.java +++ /dev/null @@ -1,53 +0,0 @@ -package top.kuanghua.tyexample.listener; - -import com.alibaba.otter.canal.protocol.CanalEntry; -import com.xpand.starter.canal.annotation.*; - -/** - * @Title: CanalDataEventListener - * @Description: - * @Auther: kuanghua - * @create 2020/9/1 22:43 - */ -@CanalEventListener -public class CanalDataEventListener { -// @InsertListenPoint -// public void onEventInsert(CanalEntry.EventType eventType, CanalEntry.RowData rowData) { -// for (CanalEntry.Column column : rowData.getAfterColumnsList()) { -// System.out.println("新增" + column.getName() + ":获取的数据" + column.getValue()); -// } -// } -// -// @UpdateListenPoint -// public void onEventUpdate(CanalEntry.EventType eventType, CanalEntry.RowData rowData) { -// for (CanalEntry.Column column : rowData.getBeforeColumnsList()) { -// System.out.println("修改前" + column.getName() + ":获取的数据" + column.getValue()); -// } -// for (CanalEntry.Column column : rowData.getAfterColumnsList()) { -// System.out.println("修改后" + column.getName() + ":获取的数据" + column.getValue()); -// } -// } -// -// @DeleteListenPoint -// public void onEventDelete(CanalEntry.EventType eventType, CanalEntry.RowData rowData) { -// for (CanalEntry.Column column : rowData.getBeforeColumnsList()) { -// System.out.println("删除前" + column.getName() + ":获取的数据" + column.getValue()); -// } -// } - - //自定义监听 - @ListenPoint( - eventType = {CanalEntry.EventType.DELETE, CanalEntry.EventType.UPDATE,CanalEntry.EventType.UPDATE}, //监听类型 - schema = {"micro-service-plus"},//Library - table = {"tb_error_collection"}, //table - destination = "example" //指定实例的地址 - ) - public void onEventCustomUpdate(CanalEntry.EventType eventType, CanalEntry.RowData rowData) { - for (CanalEntry.Column column : rowData.getBeforeColumnsList()) { - System.out.println("自定义前" + column.getName() + ":获取的数据" + column.getValue()); - } - for (CanalEntry.Column column : rowData.getAfterColumnsList()) { - System.out.println("自定义后" + column.getName() + ":获取的数据" + column.getValue()); - } - } -} diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/listener/RabbitDelayListener.java b/ty-example/src/main/java/top/kuanghua/tyexample/listener/RabbitDelayListener.java deleted file mode 100644 index de4130d..0000000 --- a/ty-example/src/main/java/top/kuanghua/tyexample/listener/RabbitDelayListener.java +++ /dev/null @@ -1,29 +0,0 @@ -package top.kuanghua.tyexample.listener; - -import lombok.extern.slf4j.Slf4j; -import org.springframework.amqp.rabbit.annotation.RabbitListener; -import org.springframework.stereotype.Component; -import top.kuanghua.tyexample.config.RabbitDelayConfig; - -/** - * @Title: orderDelayQueue - * @Description: - * @Auther: kuanghua - * @create 2021/1/18 10:27 - */ -@Component -@Slf4j -public class RabbitDelayListener { - @RabbitListener(queues = {RabbitDelayConfig.ORDER_QUEUE_NAME}) - public void ORDER_QUEUE_NAME( String outTradeno) { - /* - * 微信服务器查询订单,并更新订单状态 - * */ - log.info("receive the Delay info "+outTradeno); - } - // note: not dill the msg will re to redirect ORDER_QUEUE_NAME - // @RabbitListener(queues = {RabbitDelayConfig.ORDER_DELAY_QUEUE}) - // public void ORDER_DELAY_QUEUE( String outTradeno) { - // log.info("ORDER_DELAY_QUEUE"+outTradeno); - // } -} diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/listener/SmsListener.java b/ty-example/src/main/java/top/kuanghua/tyexample/listener/SmsListener.java deleted file mode 100644 index 317bb47..0000000 --- a/ty-example/src/main/java/top/kuanghua/tyexample/listener/SmsListener.java +++ /dev/null @@ -1,50 +0,0 @@ -package top.kuanghua.tyexample.listener; - - -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang.StringUtils; -import org.springframework.amqp.rabbit.annotation.Exchange; -import org.springframework.amqp.rabbit.annotation.Queue; -import org.springframework.amqp.rabbit.annotation.QueueBinding; -import org.springframework.amqp.rabbit.annotation.RabbitListener; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.stereotype.Component; -import top.kuanghua.tyexample.config.SmsProperties; -import top.kuanghua.tyexample.utils.SendSmsUtils; - - -import java.util.Map; - -@Component -@EnableConfigurationProperties(SmsProperties.class) -@Slf4j -public class SmsListener { - - @Autowired - private SendSmsUtils smsUtils; - - @Autowired - private SmsProperties smsProperties; - - @RabbitListener( - bindings = @QueueBinding(value = @Queue(value = "kuanghua.sms.queue", durable = "true"), - exchange = @Exchange(value = "kuanghua.sms.exchange", ignoreDeclarationExceptions = "true",durable = "true"), - key = {"sms.verify.code"}) - ) - public void listenSms(Map msg) throws Exception { - if (msg == null || msg.size() <= 0) { - // 放弃处理 - return; - } - String phone = msg.get("phone"); - String code = msg.get("code"); - if (StringUtils.isBlank(phone) || StringUtils.isBlank(code)) { - // 放弃处理 - log.error("发送短信mq phone或code字段为空"); - return; - } - // 发送短信 - this.smsUtils.sendMsg(phone,code,smsProperties.getSignName(),smsProperties.getVerifyCodeTemplate()); - } -} \ No newline at end of file diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/mapper/ErrorCollectionMapper.java b/ty-example/src/main/java/top/kuanghua/tyexample/mapper/ErrorCollectionMapper.java deleted file mode 100644 index 49b5aba..0000000 --- a/ty-example/src/main/java/top/kuanghua/tyexample/mapper/ErrorCollectionMapper.java +++ /dev/null @@ -1,9 +0,0 @@ -package top.kuanghua.tyexample.mapper; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import top.kuanghua.tyexample.entity.ErrorCollection; - - -public interface ErrorCollectionMapper extends BaseMapper { - -} diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/service/RabbitDelayService.java b/ty-example/src/main/java/top/kuanghua/tyexample/service/RabbitDelayService.java deleted file mode 100644 index 084da36..0000000 --- a/ty-example/src/main/java/top/kuanghua/tyexample/service/RabbitDelayService.java +++ /dev/null @@ -1,33 +0,0 @@ -package top.kuanghua.tyexample.service; - -import lombok.extern.slf4j.Slf4j; -import org.springframework.amqp.rabbit.core.RabbitTemplate; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import top.kuanghua.tyexample.config.RabbitDelayConfig; - -/** - * @Title: RabbitDelayService - * @Description: - * @Auther: kuanghua - * @create 2022-01-06 17:18 - */ -@Service -public class RabbitDelayService { - - @Autowired - private RabbitTemplate rabbitTemplate; - - /** - * @param time 延时的时间 - * 死信延时转发队列 - */ - public void convertAndSend(Integer time){ - rabbitTemplate.convertAndSend(RabbitDelayConfig.ORDER_DELAY_EXCHANGE, RabbitDelayConfig.ORDER_DELAY_ROUTING_KEY, "发送的数据", message -> { - // 如果配置了 params.put("x-message-ttl", 5 * 1000); 那么这一句也可以省略,具体根据业务需要是声明 Queue 的时候就指定好延迟时间还是在发送自己控制时间 - message.getMessageProperties().setExpiration(time * 1000 + ""); - return message; - }); - } -} - diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/service/SeataTestService.java b/ty-example/src/main/java/top/kuanghua/tyexample/service/SeataTestService.java deleted file mode 100644 index 5040928..0000000 --- a/ty-example/src/main/java/top/kuanghua/tyexample/service/SeataTestService.java +++ /dev/null @@ -1,26 +0,0 @@ -package top.kuanghua.tyexample.service; - -import io.seata.spring.annotation.GlobalTransactional; -import org.springframework.stereotype.Service; -import top.kuanghua.feign.integrationfront.feign.UserFeign; - -import javax.annotation.Resource; - -/** - * @Title: SeataTestService - * @Description: - * @Auther: kuanghua - * @create 2022-01-10 15:09 - */ -@Service -public class SeataTestService { - - @Resource - private UserFeign userFeign; - - @GlobalTransactional(rollbackFor = Exception.class) - public void testSeataRollback(){ - userFeign.insertUser("jzfai"); - int i=10/0; - } -} diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/service/SendEmailService.java b/ty-example/src/main/java/top/kuanghua/tyexample/service/SendEmailService.java deleted file mode 100644 index 2dc1f96..0000000 --- a/ty-example/src/main/java/top/kuanghua/tyexample/service/SendEmailService.java +++ /dev/null @@ -1,99 +0,0 @@ -package top.kuanghua.tyexample.service; - - -import org.springframework.beans.factory.annotation.Value; -import org.springframework.mail.SimpleMailMessage; -import org.springframework.mail.javamail.JavaMailSenderImpl; -import org.springframework.mail.javamail.MimeMessageHelper; -import org.springframework.scheduling.annotation.Async; -import org.springframework.stereotype.Service; -import org.springframework.web.multipart.MultipartFile; -import top.kuanghua.khcomomon.utils.ObjectUtilsSelf; - -import javax.annotation.Resource; -import javax.mail.MessagingException; -import javax.mail.internet.MimeMessage; -import java.io.File; -import java.io.IOException; - -/** - * @Title: SendEmailService - * @Description: - * @Auther: kuanghua - * @create 2020/8/20 22:09 - */ -@Service -public class SendEmailService { - - @Resource - private JavaMailSenderImpl javaMailSender; - - @Value("${spring.mail.username}") - private String sendForm; - - /** - * @Description: 发送文本邮件 - * @Param: subject 主题 - * @Param: text 发送的文本 - * @Param: sendForm 发送人 - * @Param: sendTo 发送给谁 - * @return: - * @Date: 2020-08-20 - */ - @Async - public void sendEmailText(String subject, String text, String sendTo) { - //封装简单的邮件内容 - SimpleMailMessage simpleMailMessage = new SimpleMailMessage(); - //邮件主题 - simpleMailMessage.setSubject(subject); - simpleMailMessage.setText(text); - //发件人和收件人 - simpleMailMessage.setFrom(sendForm); - simpleMailMessage.setTo(sendTo); - //发送 - javaMailSender.send(simpleMailMessage); - //demo - //sendEmailText("邮件主题测试setSubject","邮件主题测试setText","869653722@qq.com","1319404169@qq.com") - } - - /** - * @Description: 发送附件邮件 - * @Param: * @param null - * @return: - * @Date: 2020-08-20 - */ - @Async - public void sendMimeMail(String subject, String text, String sendTo, MultipartFile file) - throws MessagingException, IOException { - // String path = ResourceUtils.getURL("classpath:").getPath(); - // System.out.println(path + file.getOriginalFilename()); - //先将文件保存在本地 - //file.transferTo(filePath); - - File toFile = ObjectUtilsSelf.MultipartFileToFile(file); - //创建一个发送复杂消息对象 - MimeMessage mimeMessage = javaMailSender.createMimeMessage(); - //通过消息帮助对象,来设置发送的内容 - MimeMessageHelper messageHelper = new MimeMessageHelper(mimeMessage, true, "UTF-8"); - //邮件主题 - messageHelper.setSubject(subject); - //第2个参数为true表示是html - messageHelper.setText(text, true); - //上传文件 (文件名,File或IO对象) - String filename = file.getOriginalFilename(); - - messageHelper.addAttachment(filename, toFile); - //发件人和收件人 - messageHelper.setFrom(sendForm); - messageHelper.setTo(sendTo); - //发送 - javaMailSender.send(mimeMessage); - //发完后清空文件 - //filePath.delete(); - } - //@Scheduled(cron = "*/1 * * * * *") - //public void scheduled() { - //this.sendEmailText("邮件主题测试setSubject", "邮件主题测试setText", "869653722@qq.com", "1319404169@qq.com"); - //System.out.println("邮件发送了好烦啊"); - // } -} diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/service/SendMsgService.java b/ty-example/src/main/java/top/kuanghua/tyexample/service/SendMsgService.java deleted file mode 100644 index 088f049..0000000 --- a/ty-example/src/main/java/top/kuanghua/tyexample/service/SendMsgService.java +++ /dev/null @@ -1,42 +0,0 @@ -package top.kuanghua.tyexample.service; - -import lombok.extern.slf4j.Slf4j; -import org.springframework.amqp.core.AmqpTemplate; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.redis.core.StringRedisTemplate; -import org.springframework.stereotype.Service; -import top.kuanghua.khcomomon.utils.NumberUtilsSelf; - -import java.util.HashMap; -import java.util.Map; -import java.util.concurrent.TimeUnit; - -/** - * @Title: SendMsgService - * @Description: - * @Auther: - * @create 2020/8/20 11:26 - */ -@Service -@Slf4j -public class SendMsgService { - - @Autowired - protected AmqpTemplate amqpTemplate; - - @Autowired - private StringRedisTemplate stringRedisTemplate; - - public void sendMsg(String phone) { - String code = NumberUtilsSelf.generateCode(6); - Map smsMap = new HashMap(); - smsMap.put("phone", phone); - smsMap.put("code", code); - amqpTemplate.convertAndSend("kuanghua.sms.exchange", "sms.verify.code", smsMap); - stringRedisTemplate.opsForValue().set("user:code:phone:" + phone, code, 60, TimeUnit.SECONDS); - log.info("发送短信的code" + code); - } -} - - - diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/service/UploadService.java b/ty-example/src/main/java/top/kuanghua/tyexample/service/UploadService.java deleted file mode 100644 index 11ef1e9..0000000 --- a/ty-example/src/main/java/top/kuanghua/tyexample/service/UploadService.java +++ /dev/null @@ -1,92 +0,0 @@ -package top.kuanghua.tyexample.service; - - -import com.alibaba.fastjson.JSON; -import com.github.tobato.fastdfs.domain.fdfs.MetaData; -import com.github.tobato.fastdfs.domain.fdfs.StorePath; -import com.github.tobato.fastdfs.service.FastFileStorageClient; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang.StringUtils; -import org.springframework.stereotype.Service; -import org.springframework.web.multipart.MultipartFile; - -import javax.annotation.Resource; -import javax.imageio.ImageIO; -import java.awt.image.BufferedImage; -import java.io.IOException; -import java.util.*; - -/** - * @Title: UploadService - * @Description: - * @Auther:jzfai - * @Version: 1.0 - * @create 2020/3/4 21:58 - */ -@Service -@Slf4j -public class UploadService { - - @Resource - private FastFileStorageClient storageClient; - - //private static final List CONTENT_TYPES = Arrays.asList("image/jpeg", "image/gif"); - - public String upload(MultipartFile file) throws IOException { - String originalFilename = file.getOriginalFilename(); - //检验文件类型 -// String contentType = file.getContentType(); -// if (!CONTENT_TYPES.contains(contentType)) { -// //文件类型不合法 -// log.info("文件类型不合法:{}", originalFilename); -// throw new RuntimeException("文件内容不合法"); -// } - //检验文件内容 - BufferedImage bufferedImage = ImageIO.read(file.getInputStream()); - if (bufferedImage == null) { - log.info("文件不能为空:{}", originalFilename); - throw new RuntimeException("文件不能为空"); - } - //保存到服务器 - //file.transferTo(new File("D:\\java\\javaproject\\pinyou\\pinyou-upload\\src\\main\\resources\\static\\" + originalFilename)); - //上传到FastDfs - String ext = StringUtils.substringAfterLast(originalFilename, "."); - HashSet metaData = new HashSet<>(); - metaData.add(new MetaData("name", file.getOriginalFilename())); - metaData.add(new MetaData("createTime", JSON.toJSONString(new Date()))); - StorePath storePath = this.storageClient.uploadFile(file.getInputStream(), file.getSize(), ext, metaData); - return storePath.getFullPath(); - } - - public Map uploadGetMetaData(MultipartFile file) throws IOException { - String originalFilename = file.getOriginalFilename(); - //检验文件类型 - String contentType = file.getContentType(); -// if (!CONTENT_TYPES.contains(contentType)) { -// //文件类型不合法 -// log.info("文件类型不合法:{}", originalFilename); -// } - //检验文件内容 - BufferedImage bufferedImage = ImageIO.read(file.getInputStream()); - if (bufferedImage == null) { - log.info("文件内容不合法:{}", originalFilename); - } - //保存到服务器 - //file.transferTo(new File("D:\\java\\javaproject\\pinyou\\pinyou-upload\\src\\main\\resources\\static\\" + originalFilename)); - //上传到FastDfs - String ext = StringUtils.substringAfterLast(originalFilename, "."); - HashSet metaData = new HashSet<>(); - metaData.add(new MetaData("name", file.getOriginalFilename())); - StorePath storePath = this.storageClient.uploadFile(file.getInputStream(), file.getSize(), ext, metaData); - //获取数据源信息 - Set metadata = this.storageClient.getMetadata(storePath.getGroup(), storePath.getPath()); - ArrayList metaDataArrayList = new ArrayList<>(metadata); - String name = metaDataArrayList.get(0).getValue(); - //拼接name和url返回 - Map hashMap = new HashMap<>(); - hashMap.put("name", name); - hashMap.put("url", storePath.getFullPath()); - hashMap.put("group", storePath.getGroup()); - return hashMap; - } -} diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/utils/SendSmsUtils.java b/ty-example/src/main/java/top/kuanghua/tyexample/utils/SendSmsUtils.java deleted file mode 100644 index 876ab4f..0000000 --- a/ty-example/src/main/java/top/kuanghua/tyexample/utils/SendSmsUtils.java +++ /dev/null @@ -1,54 +0,0 @@ -package top.kuanghua.tyexample.utils; - -import com.alibaba.fastjson.JSON; -import com.aliyuncs.CommonRequest; -import com.aliyuncs.CommonResponse; -import com.aliyuncs.DefaultAcsClient; -import com.aliyuncs.IAcsClient; -import com.aliyuncs.http.MethodType; -import com.aliyuncs.profile.DefaultProfile; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; -import top.kuanghua.tyexample.config.SmsProperties; - -import java.util.Map; - - -@Component -@Slf4j -public class SendSmsUtils { - - @Autowired - private SmsProperties smsProperties; - - public void sendMsg(String phone, String code, String signName, String codeTemplate){ - DefaultProfile profile = DefaultProfile.getProfile("cn-hangzhou", smsProperties.getAccessKeyId(), smsProperties.getAccessKeySecret()); - IAcsClient client = new DefaultAcsClient(profile); - CommonRequest request = new CommonRequest(); - request.setSysMethod(MethodType.POST); - request.setSysDomain("dysmsapi.aliyuncs.com"); - request.setSysVersion("2017-05-25"); - request.setSysAction("SendSms"); - request.putQueryParameter("RegionId", "cn-hangzhou"); - request.putQueryParameter("PhoneNumbers", phone); - request.putQueryParameter("SignName", signName); - request.putQueryParameter("TemplateCode", codeTemplate); - request.putQueryParameter("TemplateParam", "{\"code\":\""+code+"\"}"); - try { - CommonResponse response = client.getCommonResponse(request); - String data = response.getData(); - Map map = JSON.parseObject(data, Map.class); - if (map.get("Code").equals("OK")){ - log.warn("发送短信成功 "+data); - }else{ - // 记录失败日志 - log.error("发送短信失败 "+data); - } - } catch (Exception e) { - // 记录失败日志 - log.error("发送短信失败 "+e.getMessage()); - throw new RuntimeException("发送短信失败 "+e.getMessage()); - } - } -} diff --git a/ty-example/src/main/resources/bootstrap.yml b/ty-example/src/main/resources/bootstrap.yml deleted file mode 100644 index 191e96f..0000000 --- a/ty-example/src/main/resources/bootstrap.yml +++ /dev/null @@ -1,46 +0,0 @@ -spring: - application: - name: @project.artifactId@ - profiles: - active: "" - cloud: - nacos: - config: - enabled: true - namespace: @nacosNamespace@ - group: @nacosGroup@ - username: @nacosUsername@ - password: @nacosPassword@ - server-addr: @nacosIpPort@ - prefix: @project.artifactId@ - file-extension: yml - # 用于共享的配置文件 - shared-configs: - - data-id: application-main.yml - group: @nacosGroup@ - refresh: true - # 额外的配置文件 - extension-configs: - #get mysql config - - data-id: application-db.yml - group: @nacosGroup@ - refresh: true - - data-id: application-rabbit.yml - group: @nacosGroup@ - refresh: true - #get redis config - - data-id: application-redis.yml - group: @nacosGroup@ - refresh: true - #get seata config need after db config - - data-id: application-seata.yml - group: @nacosGroup@ - refresh: true - discovery: - namespace: @nacosNamespace@ - group: @nacosGroup@ - username: @nacosUsername@ - password: @nacosPassword@ - server-addr: @nacosIpPort@ - weight: @nacosWeight@ - ip: @nacosDiscoveryIp@ \ No newline at end of file diff --git a/ty-example/src/test/java/top/kuanghua/tyexample/service/CacheAvalancheServiceTest.java b/ty-example/src/test/java/top/kuanghua/tyexample/service/CacheAvalancheServiceTest.java deleted file mode 100644 index 4f3b9c6..0000000 --- a/ty-example/src/test/java/top/kuanghua/tyexample/service/CacheAvalancheServiceTest.java +++ /dev/null @@ -1,32 +0,0 @@ -package top.kuanghua.tyexample.service; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.data.redis.core.RedisTemplate; -import org.springframework.test.context.junit4.SpringRunner; - -/** - * @Title: CacheAvalancheServiceTest - * @Description: - * @Auther: kuanghua - * @create 2022-01-09 16:35 - */ -@SpringBootTest -@RunWith(SpringRunner.class) -public class CacheAvalancheServiceTest { - - @Autowired - private RedisTemplate redisTemplate; - - @Test - public void test() throws InterruptedException { - redisTemplate.opsForValue().set("fai", "1"); - String fai = (String) redisTemplate.opsForValue().get("fai"); - System.out.println(fai); - //Thread.sleep(10000); - } - - -} \ No newline at end of file diff --git a/ty-gateway/pom.xml b/ty-gateway/pom.xml deleted file mode 100644 index 2d78d62..0000000 --- a/ty-gateway/pom.xml +++ /dev/null @@ -1,44 +0,0 @@ - - - - micro-service-plus - top.kuanghua - 1.0-SNAPSHOT - - 4.0.0 - - ty-gateway - pom - - ty-gateway-one - - - - - top.kuanghua - ty-common - 1.0-SNAPSHOT - - - org.springframework.cloud - spring-cloud-starter-gateway - - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework - spring-webmvc - - - org.apache.tomcat.embed - tomcat-embed-core - - - - - \ No newline at end of file diff --git a/ty-gateway/ty-gateway-one/pom.xml b/ty-gateway/ty-gateway-one/pom.xml deleted file mode 100644 index 4154a68..0000000 --- a/ty-gateway/ty-gateway-one/pom.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - ty-gateway - top.kuanghua - 1.0-SNAPSHOT - - 4.0.0 - ty-gateway-one - - - ${project.artifactId} - - - - src/main/resources - - true - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - org.apache.maven.plugins - maven-surefire-plugin - 2.22.1 - - true - - - - - \ No newline at end of file diff --git a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/config/BaseConfig.java b/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/config/BaseConfig.java deleted file mode 100644 index 6effeec..0000000 --- a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/config/BaseConfig.java +++ /dev/null @@ -1,23 +0,0 @@ -package top.kuanghua.gatewaytwo.config; - -import org.springframework.cloud.openfeign.EnableFeignClients; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; - -/** - * @Title: BaseConfig - * @Description: - * @Auther: kuanghua - * @create 2020/8/23 21:52 - */ -/* - * 总结:1.@Configuration 下的@ComponentScan回将包下带有@Component扫描变成配置类, - * 而@SpringBootApplication扫描的只会变成普通类 - * */ -@Configuration -//dao包扫描 -@ComponentScan(basePackages = {"top.kuanghua.khcomomon"}) -@EnableFeignClients(basePackages = {"top.kuanghua.feign"}) -public class BaseConfig { - -} diff --git a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/config/JwtProperties.java b/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/config/JwtProperties.java deleted file mode 100644 index 9bf7775..0000000 --- a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/config/JwtProperties.java +++ /dev/null @@ -1,54 +0,0 @@ -package top.kuanghua.gatewaytwo.config; - - -import lombok.Data; -import lombok.extern.slf4j.Slf4j; -import org.springframework.boot.context.properties.ConfigurationProperties; -import top.kuanghua.gatewaytwo.utils.RsaUtils; - -import javax.annotation.PostConstruct; -import java.io.File; -import java.security.PrivateKey; -import java.security.PublicKey; - - -@Data -@Slf4j -@ConfigurationProperties(prefix = "jwt-properties") -public class JwtProperties { - private String secret; - private String pubKeyPath; - private String priKeyPath; - private PublicKey publicKey; - private PrivateKey privateKey; - private Integer expire; - private String cookieName; - private Integer cookieMaxAge; - - @PostConstruct - public void init() throws Exception { -// String classPath = ResourceUtils.getURL("classpath:").getPath(); -// String pubKeyPath=classPath+"\\rsafile\\rsa.pub"; -// String priKeyPath=classPath+"\\rsafile\\rsa.pri"; - File pubKeyFile = new File(pubKeyPath); - File priKeyFile = new File(priKeyPath); - if (!pubKeyFile.exists() || !priKeyFile.exists()) { - File fileParent = pubKeyFile.getParentFile(); - if (!fileParent.exists()) { - fileParent.mkdirs(); - } - throw new RuntimeException("秘钥文件不存在"); - // 获取公钥和私钥 - /*秘钥最好不要跟换*/ -// try { -// RsaUtils.generateKey(pubKeyPath, priKeyPath, secret); -// } catch (Exception e) { -// log.error("生成秘钥失败"); -// //e.printStackTrace(); -// }r - } - //读取公钥和私钥文件 - this.publicKey = RsaUtils.getPublicKey(pubKeyPath); - this.privateKey = RsaUtils.getPrivateKey(priKeyPath); - } -} \ No newline at end of file diff --git a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/config/SpecialHystrixGatewayFilterFactory.java b/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/config/SpecialHystrixGatewayFilterFactory.java deleted file mode 100644 index 440d247..0000000 --- a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/config/SpecialHystrixGatewayFilterFactory.java +++ /dev/null @@ -1,241 +0,0 @@ -package top.kuanghua.gatewaytwo.config; - -import com.netflix.hystrix.HystrixCommandGroupKey; -import com.netflix.hystrix.HystrixCommandKey; -import com.netflix.hystrix.HystrixCommandProperties; -import com.netflix.hystrix.HystrixObservableCommand; -import com.netflix.hystrix.exception.HystrixRuntimeException; -import org.springframework.beans.factory.ObjectProvider; -import org.springframework.cloud.gateway.filter.GatewayFilter; -import org.springframework.cloud.gateway.filter.GatewayFilterChain; -import org.springframework.cloud.gateway.filter.factory.AbstractGatewayFilterFactory; -import org.springframework.core.annotation.AnnotatedElementUtils; -import org.springframework.http.server.reactive.ServerHttpRequest; -import org.springframework.stereotype.Component; -import org.springframework.web.bind.annotation.ResponseStatus; -import org.springframework.web.reactive.DispatcherHandler; -import org.springframework.web.server.ResponseStatusException; -import org.springframework.web.server.ServerWebExchange; -import org.springframework.web.util.UriComponentsBuilder; -import reactor.core.publisher.Mono; -import rx.Observable; -import rx.RxReactiveStreams; -import rx.Subscription; - -import java.math.BigDecimal; -import java.net.URI; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.concurrent.TimeoutException; -import java.util.function.Function; - -import static org.springframework.cloud.gateway.support.ServerWebExchangeUtils.GATEWAY_REQUEST_URL_ATTR; -import static org.springframework.cloud.gateway.support.ServerWebExchangeUtils.containsEncodedParts; - -@Component -public class SpecialHystrixGatewayFilterFactory extends AbstractGatewayFilterFactory { - - private static final String NAME = "SpecialHystrix"; - - private final ObjectProvider dispatcherHandler; - - public SpecialHystrixGatewayFilterFactory(ObjectProvider dispatcherHandler) { - super(Config.class); - this.dispatcherHandler = dispatcherHandler; - } - - @Override - public List shortcutFieldOrder() { - return Collections.singletonList(NAME_KEY); - } - - @Override - public GatewayFilter apply(Config config) { - return (exchange, chain) -> { - ServerHttpRequest request = exchange.getRequest(); - String path = request.getPath().pathWithinApplication().value(); - Map timeoutMap = config.getTimeout(); - Integer timeout = null; - if (timeoutMap != null) { - //对rest接口通配符url进行转换 暂只配置url 末尾为数字的的接口--- - path = config.wildCard(path); - timeout = timeoutMap.get(path); - } - - MyRouteHystrixCommand command; - if (timeout == null) { - //没有定义时间的接口将使用配置的default时间 - command = new MyRouteHystrixCommand(config.getFallbackUri(), exchange, chain, path); - } else { - //有配置时间的接口将使用配置的时间 - command = new MyRouteHystrixCommand(config.getFallbackUri(), exchange, chain, timeout, path); - } - - return Mono.create(s -> { - Subscription sub = command.toObservable().subscribe(s::success, s::error, s::success); - s.onCancel(sub::unsubscribe); - }).onErrorResume((Function>) throwable -> { - if (throwable instanceof HystrixRuntimeException) { - HystrixRuntimeException e = (HystrixRuntimeException) throwable; - HystrixRuntimeException.FailureType failureType = e.getFailureType(); - switch (failureType) { - case TIMEOUT: - return Mono.error(new TimeoutException("接口请求超时了")); - case COMMAND_EXCEPTION: { - Throwable cause = e.getCause(); - if (cause instanceof ResponseStatusException || AnnotatedElementUtils - .findMergedAnnotation(cause.getClass(), ResponseStatus.class) != null) { - return Mono.error(cause); - } - } - default: - break; - } - } - return Mono.error(throwable); - }).then(); - }; - } - - @Override - public String name() { - return NAME; - } - - private class MyRouteHystrixCommand extends HystrixObservableCommand { - - private final URI fallbackUri; - private final ServerWebExchange exchange; - private final GatewayFilterChain chain; - - public MyRouteHystrixCommand(URI fallbackUri, ServerWebExchange exchange, GatewayFilterChain chain, - String key) { - super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey(key)) - .andCommandKey(HystrixCommandKey.Factory.asKey(key))); - this.fallbackUri = fallbackUri; - this.exchange = exchange; - this.chain = chain; - - } - - public MyRouteHystrixCommand(URI fallbackUri, ServerWebExchange exchange, GatewayFilterChain chain, - int timeout, - String key) { - //***出现通配符的情况**// - super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey(key)) - .andCommandKey(HystrixCommandKey.Factory.asKey(key)) - .andCommandPropertiesDefaults(HystrixCommandProperties.Setter().withExecutionTimeoutInMilliseconds(timeout))); - this.fallbackUri = fallbackUri; - this.exchange = exchange; - this.chain = chain; - - } - - @Override - protected Observable construct() { - return RxReactiveStreams.toObservable(this.chain.filter(exchange)); - } - - @Override - protected Observable resumeWithFallback() { - if (null == fallbackUri) { - return super.resumeWithFallback(); - } - URI uri = exchange.getRequest().getURI(); - boolean encoded = containsEncodedParts(uri); - URI requestUrl = UriComponentsBuilder.fromUri(uri) - .host(null) - .port(null) - .uri(this.fallbackUri) - .build(encoded) - .toUri(); - exchange.getAttributes().put(GATEWAY_REQUEST_URL_ATTR, requestUrl); - - ServerHttpRequest request = this.exchange.getRequest().mutate().uri(requestUrl).build(); - ServerWebExchange mutated = exchange.mutate().request(request).build(); - DispatcherHandler dispatcherHandler = SpecialHystrixGatewayFilterFactory.this.dispatcherHandler.getIfAvailable(); - return RxReactiveStreams.toObservable(dispatcherHandler.handle(mutated)); - } - } - - public static class Config { - - private String id; - private URI fallbackUri; - /** - * url -> timeout ms - */ - private Map timeout; - - public String getId() { - return id; - } - - public Config setId(String id) { - this.id = id; - return this; - } - - public URI getFallbackUri() { - return fallbackUri; - } - - public Config setFallbackUri(URI fallbackUri) { - if (fallbackUri != null && !"forward".equals(fallbackUri.getScheme())) { - throw new IllegalArgumentException("Hystrix Filter currently only supports 'forward' URIs, found " + fallbackUri); - } - this.fallbackUri = fallbackUri; - return this; - } - - public Map getTimeout() { - return timeout; - } - - public Config setTimeout(Map timeout) { - //YAML解析的时候MAP的KEY不支持'/',这里只能用'-'替代 - Map tempTimeout = new HashMap<>(timeout.size()); - for (String key : timeout.keySet()) { - Integer value = timeout.get(key); - - key = key.replace("-", "/"); - if (!key.startsWith("/")) { - key = "/" + key; - } - /** 末尾有动态传参 **/ - if (key.endsWith("/")) { - key = key + "**"; - } - tempTimeout.put(key, value); - } - this.timeout = tempTimeout; - return this; - } - - - public String wildCard(String path) { - String replace = path; - String[] split = path.split("/"); - if (split.length > 0) { - String wildcard = split[split.length - 1]; - boolean numeric = isNumeric(wildcard); - if (numeric) { - replace = path.replace(wildcard, "**"); - } - } - return replace; - } - - private boolean isNumeric(String str) { - String bigStr; - try { - bigStr = new BigDecimal(str).toString(); - } catch (Exception e) { - return false;//异常 说明包含非数字。 - } - return true; - } - } -} \ No newline at end of file diff --git a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/config/SwaggerDocConfig.java b/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/config/SwaggerDocConfig.java deleted file mode 100644 index 6a125b4..0000000 --- a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/config/SwaggerDocConfig.java +++ /dev/null @@ -1,21 +0,0 @@ -package top.kuanghua.gatewaytwo.config; - -import lombok.Data; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.context.annotation.Configuration; -import org.springframework.stereotype.Component; - -import java.util.*; -/** - * @Title: SwaggerDocConfig - * @Description: - * @Auther: kuanghua - * @create 2021/9/14 13:36 - */ - -@Component -@ConfigurationProperties(prefix = "swagger-doc") -@Data -public class SwaggerDocConfig { - private Map serviceMap; -} diff --git a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/config/SwaggerHandler.java b/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/config/SwaggerHandler.java deleted file mode 100644 index 8a630ff..0000000 --- a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/config/SwaggerHandler.java +++ /dev/null @@ -1,49 +0,0 @@ -package top.kuanghua.gatewaytwo.config; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; -import reactor.core.publisher.Mono; -import springfox.documentation.swagger.web.*; - -import java.util.Optional; - -/** - * @introduce: Swagger处理器 - * @author: kuanghua - * @date: 2020/6/4 - **/ -@RestController -@RequestMapping("/swagger-resources") -public class SwaggerHandler { - @Autowired(required = false) - private SecurityConfiguration securityConfiguration; - @Autowired(required = false) - private UiConfiguration uiConfiguration; - private final SwaggerResourcesProvider swaggerResources; - - @Autowired - public SwaggerHandler(SwaggerResourcesProvider swaggerResources) { - this.swaggerResources = swaggerResources; - } - - @GetMapping("/configuration/security") - public Mono> securityConfiguration() { - return Mono.just(new ResponseEntity<>( - Optional.ofNullable(securityConfiguration).orElse(SecurityConfigurationBuilder.builder().build()), HttpStatus.OK)); - } - - @GetMapping("/configuration/ui") - public Mono> uiConfiguration() { - return Mono.just(new ResponseEntity<>( - Optional.ofNullable(uiConfiguration).orElse(UiConfigurationBuilder.builder().build()), HttpStatus.OK)); - } - - @GetMapping("") - public Mono swaggerResources() { - return Mono.just((new ResponseEntity<>(swaggerResources.get(), HttpStatus.OK))); - } -} diff --git a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/config/SwaggerHeaderFilter.java b/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/config/SwaggerHeaderFilter.java deleted file mode 100644 index a9df815..0000000 --- a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/config/SwaggerHeaderFilter.java +++ /dev/null @@ -1,34 +0,0 @@ -package top.kuanghua.gatewaytwo.config; - -import org.springframework.cloud.gateway.filter.GatewayFilter; -import org.springframework.cloud.gateway.filter.factory.AbstractGatewayFilterFactory; -import org.springframework.http.server.reactive.ServerHttpRequest; -import org.springframework.stereotype.Component; -import org.springframework.util.StringUtils; -import org.springframework.web.server.ServerWebExchange; - -/** - * @introduce: swagger请求头过滤器 - * @author: kuanghua - * @date: 2020/6/4 - **/ -@Component -public class SwaggerHeaderFilter extends AbstractGatewayFilterFactory { - - private static final String HEADER_NAME = "X-Forwarded-Prefix"; - - @Override - public GatewayFilter apply(Object config) { - return (exchange, chain) -> { - ServerHttpRequest request = exchange.getRequest(); - String path = request.getURI().getPath(); - if (!StringUtils.endsWithIgnoreCase(path, SwaggerProvider.API_URI)) { - return chain.filter(exchange); - } - String basePath = path.substring(0, path.lastIndexOf(SwaggerProvider.API_URI)); - ServerHttpRequest newRequest = request.mutate().header(HEADER_NAME, basePath).build(); - ServerWebExchange newExchange = exchange.mutate().request(newRequest).build(); - return chain.filter(newExchange); - }; - } -} diff --git a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/config/SwaggerProvider.java b/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/config/SwaggerProvider.java deleted file mode 100644 index 00de5e7..0000000 --- a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/config/SwaggerProvider.java +++ /dev/null @@ -1,62 +0,0 @@ -package top.kuanghua.gatewaytwo.config; - -import lombok.AllArgsConstructor; -import org.springframework.context.annotation.Primary; -import org.springframework.stereotype.Component; -import springfox.documentation.swagger.web.SwaggerResource; -import springfox.documentation.swagger.web.SwaggerResourcesProvider; - -import java.util.ArrayList; -import java.util.List; - -/** - * @introduce: gateway集成各微服务swagger - * @author: kuanghua - * @date: 2020/6/4 - **/ -@Component -@Primary -@AllArgsConstructor -public class SwaggerProvider implements SwaggerResourcesProvider { - - static final String API_URI = "/v2/api-docs"; -// private final RouteLocator routeLocator; -// private final GatewayProperties gatewayProperties; - - - private SwaggerDocConfig swaggerDocConfig; - - /** - * @return - */ - @Override - public List get() { - List resources = new ArrayList<>(); - //List routes = new ArrayList<>(); - swaggerDocConfig.getServiceMap().entrySet().stream().forEach(mapEntry -> { - /*设置swagger服务路径*/ - resources.add(createResource(mapEntry.getValue().toString(), mapEntry.getKey(), "2.9")); - }); - -// routeLocator.getRoutes().subscribe(route -> { -// System.out.println("routeLocator"); -// System.out.println(route); -// route.getId(); -// }); -// gatewayProperties.getRoutes().stream().forEach(item -> { -// System.out.println("gatewayProperties"); -// item.getId(); -// System.out.println(item); -// }); - - return resources; - } - - private SwaggerResource createResource(String name, String location, String version) { - SwaggerResource swaggerResource = new SwaggerResource(); - swaggerResource.setName(name); - swaggerResource.setLocation("/api/" + location + "/v2/api-docs"); - swaggerResource.setSwaggerVersion(version); - return swaggerResource; - } -} diff --git a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/utils/ChangeObjectUtils.java b/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/utils/ChangeObjectUtils.java deleted file mode 100644 index 05e3d69..0000000 --- a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/utils/ChangeObjectUtils.java +++ /dev/null @@ -1,38 +0,0 @@ -package top.kuanghua.gatewaytwo.utils; - -import org.apache.commons.lang3.StringUtils; - -/** - * 从jwt解析得到的数据是Object类型,转换为具体类型可能出现空指针, - * 这个工具类进行了一些转换 - */ -public class ChangeObjectUtils { - - public static String toString(Object obj) { - if (obj == null) { - return null; - } - return obj.toString(); - } - - public static Long toLong(Object obj) { - if (obj == null) { - return 0L; - } - if (obj instanceof Double || obj instanceof Float) { - return Long.valueOf(StringUtils.substringBefore(obj.toString(), ".")); - } - if (obj instanceof Number) { - return Long.valueOf(obj.toString()); - } - if (obj instanceof String) { - return Long.valueOf(obj.toString()); - } else { - return 0L; - } - } - - public static Integer toInt(Object obj) { - return toLong(obj).intValue(); - } -} \ No newline at end of file diff --git a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/utils/JwtUtilsKh.java b/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/utils/JwtUtilsKh.java deleted file mode 100644 index e7e51c3..0000000 --- a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/utils/JwtUtilsKh.java +++ /dev/null @@ -1,42 +0,0 @@ -package top.kuanghua.gatewaytwo.utils; - -import io.jsonwebtoken.*; -import org.joda.time.DateTime; - -import java.security.PrivateKey; -import java.security.PublicKey; -import java.util.Map; - -/** - * @Title: JwtUtilsKh - * @Description: - * @Auther: kuanghua - * @create 2020/9/11 12:08 - */ - -public class JwtUtilsKh { - public static String generateToken(Map hashMap, PrivateKey privateKey, int expireMinutes) throws Exception { - JwtBuilder jwtBuilder = Jwts.builder() - .setExpiration(DateTime.now().plusMinutes(expireMinutes).toDate()) - .signWith(SignatureAlgorithm.RS256, privateKey); - jwtBuilder.addClaims(hashMap); - //将jwt返回 - return jwtBuilder.compact(); - } - public static String updateToken(Map hashMap, PrivateKey privateKey, int expireMinutes) throws Exception { - hashMap.remove("exp"); - JwtBuilder jwtBuilder = Jwts.builder() - .setExpiration(DateTime.now().plusMinutes(expireMinutes).toDate()) - .signWith(SignatureAlgorithm.RS256, privateKey); - jwtBuilder.addClaims(hashMap); - //将jwt返回 - return jwtBuilder.compact(); - } - public static Jws parserToken(String token, PublicKey publicKey){ - return Jwts.parser().setSigningKey(publicKey).parseClaimsJws(token); - } - /*获取jwt的载荷*/ - public static Claims parserTokenGetBody(String token, PublicKey publicKey){ - return Jwts.parser().setSigningKey(publicKey).parseClaimsJws(token).getBody(); - } -} diff --git a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/utils/RsaUtils.java b/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/utils/RsaUtils.java deleted file mode 100644 index 42005d9..0000000 --- a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/utils/RsaUtils.java +++ /dev/null @@ -1,92 +0,0 @@ -package top.kuanghua.gatewaytwo.utils; - -import java.io.File; -import java.io.IOException; -import java.nio.file.Files; -import java.security.*; -import java.security.spec.PKCS8EncodedKeySpec; -import java.security.spec.X509EncodedKeySpec; - -public class RsaUtils { - /** - * 从文件中读取公钥 - * - * @param filename 公钥保存路径,相对于classpath - * @return 公钥对象 - * @throws Exception - */ - public static PublicKey getPublicKey(String filename) throws Exception { - byte[] bytes = readFile(filename); - return getPublicKey(bytes); - } - - /** - * 从文件中读取密钥 - * - * @param filename 私钥保存路径,相对于classpath - * @return 私钥对象 - * @throws Exception - */ - public static PrivateKey getPrivateKey(String filename) throws Exception { - byte[] bytes = readFile(filename); - return getPrivateKey(bytes); - } - /** - * 获取公钥 - * - * @param bytes 公钥的字节形式 - * @return - * @throws Exception - */ - public static PublicKey getPublicKey(byte[] bytes) throws Exception { - X509EncodedKeySpec spec = new X509EncodedKeySpec(bytes); - KeyFactory factory = KeyFactory.getInstance("RSA"); - return factory.generatePublic(spec); - } - /** - * 获取密钥 - * - * @param bytes 私钥的字节形式 - * @return - * @throws Exception - */ - public static PrivateKey getPrivateKey(byte[] bytes) throws Exception { - PKCS8EncodedKeySpec spec = new PKCS8EncodedKeySpec(bytes); - KeyFactory factory = KeyFactory.getInstance("RSA"); - return factory.generatePrivate(spec); - } - - /** - * 根据密文,生存rsa公钥和私钥,并写入指定文件 - * - * @param publicKeyFilename 公钥文件路径 - * @param privateKeyFilename 私钥文件路径 - * @param secret 生成密钥的密文 - * @throws IOException - * @throws NoSuchAlgorithmException - */ - public static void generateKey(String publicKeyFilename, String privateKeyFilename, String secret) throws Exception { - KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA"); - SecureRandom secureRandom = new SecureRandom(secret.getBytes()); - keyPairGenerator.initialize(1024, secureRandom); - KeyPair keyPair = keyPairGenerator.genKeyPair(); - // 获取公钥并写出 - byte[] publicKeyBytes = keyPair.getPublic().getEncoded(); - writeFile(publicKeyFilename, publicKeyBytes); - // 获取私钥并写出 - byte[] privateKeyBytes = keyPair.getPrivate().getEncoded(); - writeFile(privateKeyFilename, privateKeyBytes); - } - - private static byte[] readFile(String fileName) throws Exception { - return Files.readAllBytes(new File(fileName).toPath()); - } - - private static void writeFile(String destPath, byte[] bytes) throws IOException { - File dest = new File(destPath); - if (!dest.exists()) { - dest.createNewFile(); - } - Files.write(dest.toPath(), bytes); - } -} \ No newline at end of file diff --git a/ty-gateway/ty-gateway-one/src/main/resources/application.yml b/ty-gateway/ty-gateway-one/src/main/resources/application.yml deleted file mode 100644 index e69de29..0000000 diff --git a/ty-gateway/ty-gateway-one/src/main/resources/bootstrap.yml b/ty-gateway/ty-gateway-one/src/main/resources/bootstrap.yml deleted file mode 100644 index e6c3e43..0000000 --- a/ty-gateway/ty-gateway-one/src/main/resources/bootstrap.yml +++ /dev/null @@ -1,38 +0,0 @@ -spring: - application: - name: @project.artifactId@ - profiles: - active: @activatedProperties@ - cloud: - nacos: - config: - enabled: true - namespace: @nacosNamespace@ - group: @nacosGroup@ - username: @nacosUsername@ - password: @nacosPassword@ - server-addr: @nacosIpPort@ - prefix: @project.artifactId@ - file-extension: yml - # 用于共享的配置文件 - shared-configs: - - data-id: application-main.yml - group: @nacosGroup@ - refresh: true - extension-configs: - - data-id: application-rabbit.yml - group: @nacosGroup@ - refresh: true - - data-id: application-redis.yml - group: @nacosGroup@ - refresh: true - discovery: - namespace: @nacosNamespace@ - group: @nacosGroup@ - username: @nacosUsername@ - password: @nacosPassword@ - server-addr: @nacosIpPort@ - weight: @nacosWeight@ - ip: @nacosDiscoveryIp@ - - diff --git a/velocity-tmp-dir/back-vms/mybatis-plus-multb/controllerMul.vm b/velocity-tmp-dir/back-vms/mybatis-plus-multb/controllerMul.vm new file mode 100644 index 0000000..70e3008 --- /dev/null +++ b/velocity-tmp-dir/back-vms/mybatis-plus-multb/controllerMul.vm @@ -0,0 +1,75 @@ +package ${projectOrAuthor.packageName}.controller; +import java.util.Map; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +/** +* ${dbTableConfig.multiTableDesc}Controller +* +* @author ${projectOrAuthor.author} +* @since ${projectOrAuthor.dataTime} +*/ +@Api(tags = "维修信息") +@RestController +@RequestMapping("${dbTableConfig.multiTableName}") +public class ${dbTableConfig.multiTableNameCase}Controller { +@Resource +private ${dbTableConfig.multiTableNameCase}Service ${dbTableConfig.multiTableName}Service; + +@ApiOperation(value = "分页查询${dbTableConfig.multiTableDesc}") +@GetMapping("select${dbTableConfig.multiTableNameCase}") +public Page< Map > select${dbTableConfig.multiTableNameCase}(SelfCommonParams commonParams, ${dbTableConfig.multiTableNameCase}Vo ${dbTableConfig.multiTableName}Vo) { +Map ${dbTableConfig.multiTableName}Map = JSON.parseObject(JSON.toJSONString(${dbTableConfig.multiTableName}Vo), Map.class); +return ${dbTableConfig.multiTableName}Service.select${dbTableConfig.multiTableNameCase}(commonParams, ${dbTableConfig.multiTableName}Map); +} + +/** +* 新增数据 +* +* @param ${dbTableConfig.multiTableName} 实体对象 +* @return 新增结果 +*/ +@ApiOperation(value = "新增${dbTableConfig.multiTableDesc}") +@PostMapping("insert") +public ResResult insert(@RequestBody ${dbTableConfig.multiTableNameCase} ${dbTableConfig.multiTableName}) { +this.${dbTableConfig.multiTableName}Service.insert(${dbTableConfig.multiTableName}); +return new ResResult().success(); +} + + +/** +* 通过主键查询单条数据 +* +* @param ${dbTableConfig.associationKey} 主键 +* @return 单条数据 +*/ +@GetMapping("selectByKey") +@ApiOperation(value = "通过联合key查询详情") +public ResResult selectByKey(@RequestParam("${dbTableConfig.associationKey}") ${dbTableConfig.associationKeyType} ${dbTableConfig.associationKey}) { +return new ResResult().success(${dbTableConfig.multiTableName}Service.selectByKey(${dbTableConfig.associationKey})); +} + +/** +* 修改数据 +* +* @param ${dbTableConfig.multiTableName} 实体对象 +* @return 修改结果 +*/ +@ApiOperation(value = "根据${dbTableConfig.associationKey}修改数据") +@PutMapping("updateByKey") +public ResResult updateByKey(@RequestBody ${dbTableConfig.multiTableNameCase} ${dbTableConfig.multiTableName}) { +this.${dbTableConfig.multiTableName}Service.updateByKey(${dbTableConfig.multiTableName}); +return new ResResult().success(); +} + + +/** +* 删除项根据主键key +* @param ${dbTableConfig.associationKey} +* @return +*/ +@ApiOperation(value = "根据联合key删除数据") +@DeleteMapping("deleteByKey") +public ResResult deleteByKey(@RequestParam("${dbTableConfig.associationKey}") ${dbTableConfig.associationKeyType} ${dbTableConfig.associationKey}) { +this.${dbTableConfig.multiTableName}Service.deleteByKey(${dbTableConfig.associationKey}); +return new ResResult().success(); +} +} diff --git a/velocity-tmp-dir/back-vms/mybatis-plus-multb/entity.vm b/velocity-tmp-dir/back-vms/mybatis-plus-multb/entity.vm new file mode 100644 index 0000000..197fdbe --- /dev/null +++ b/velocity-tmp-dir/back-vms/mybatis-plus-multb/entity.vm @@ -0,0 +1,37 @@ +package ${projectOrAuthor.packageName}.entity; +import java.util.*; +/** +* ${currentTbConfig.tableDesc}实体类 +* +* @author ${projectOrAuthor.author} +* @since ${projectOrAuthor.dataTime} +*/ +@Data +@ApiModel("${currentTbConfig.tableDesc}") +@TableName(value = "${currentTbConfig.originTableName}") +public class ${currentTbConfig.tableNameCase} extends Model< ${currentTbConfig.tableNameCase} > { +#foreach($item in $dbTableConfig.tableFieldArr) + #if($item.field=="createTime") + @ApiModelProperty(value = "$item.desc",hidden = true) + @TableField(fill = FieldFill.INSERT) + private ${item.type} $item.field; + #elseif($item.field=="updateTime") + @ApiModelProperty(value = "$item.desc",hidden = true) + @TableField(fill = FieldFill.UPDATE) + private ${item.type} $item.field; + #else + @ApiModelProperty(value = "$item.desc") + private ${item.type} $item.field; + #end +#end + +/** +* 获取主键值 +* +* @return 主键值 +*/ +@Override +protected Serializable pkVal() { +return this.${currentTbConfig.uniKey}; +} +} diff --git a/velocity-tmp-dir/back-vms/mybatis-plus-multb/entityMul.vm b/velocity-tmp-dir/back-vms/mybatis-plus-multb/entityMul.vm new file mode 100644 index 0000000..ab3938e --- /dev/null +++ b/velocity-tmp-dir/back-vms/mybatis-plus-multb/entityMul.vm @@ -0,0 +1,29 @@ +package ${projectOrAuthor.packageName}.entity; +import java.util.*; +/** +* ${dbTableConfig.tableDesc}实体类 +* +* @author ${projectOrAuthor.author} +* @since ${projectOrAuthor.dataTime} +*/ +@Data +@ApiModel("${dbTableConfig.tableDesc}") +@TableName(value = "${dbTableConfig.originTableName}") +public class ${dbTableConfig.multiTableNameCase}{ +#foreach($mtcItem in $multiTableConfig) + #foreach($item in $mtcItem.tableFieldArr) + #if($item.field=="createTime") + @ApiModelProperty(value = "$item.desc",hidden = true) + @TableField(fill = FieldFill.INSERT) + private ${item.type} $item.field; + #elseif($item.field=="updateTime") + @ApiModelProperty(value = "$item.desc",hidden = true) + @TableField(fill = FieldFill.UPDATE) + private ${item.type} $item.field; + #else + @ApiModelProperty(value = "$item.desc") + private ${item.type} $item.field; + #end + #end +#end +} diff --git a/velocity-tmp-dir/back-vms/mybatis-plus-multb/entityVo.vm b/velocity-tmp-dir/back-vms/mybatis-plus-multb/entityVo.vm new file mode 100644 index 0000000..b1e98e1 --- /dev/null +++ b/velocity-tmp-dir/back-vms/mybatis-plus-multb/entityVo.vm @@ -0,0 +1,19 @@ +package ${projectOrAuthor.packageName}.entity; +import java.util.*; +/** +* ${dbTableConfig.multiTableDesc}实体类 +* +* @author ${projectOrAuthor.author} +* @since ${projectOrAuthor.dataTime} +*/ +@Data +@ApiModel("${dbTableConfig.multiTableDesc}") +public class ${dbTableConfig.multiTableNameCase}Vo { +#foreach($mtcItem in $multiTableConfig) + #foreach( $tfItem in $mtcItem.tableFormArr) + @ApiModelProperty(value = "$tfItem.desc") + private ${tfItem.type} $tfItem.field; + #end +#end + +} diff --git a/velocity-tmp-dir/back-vms/mybatis-plus-multb/mapper.vm b/velocity-tmp-dir/back-vms/mybatis-plus-multb/mapper.vm new file mode 100644 index 0000000..b7b7f94 --- /dev/null +++ b/velocity-tmp-dir/back-vms/mybatis-plus-multb/mapper.vm @@ -0,0 +1,10 @@ +package ${projectOrAuthor.packageName}.mapper; +/** +* ${currentTbConfig.tableDesc}Mapper +* +* @author ${projectOrAuthor.author} +* @since ${projectOrAuthor.dataTime} +*/ +public interface ${currentTbConfig.tableNameCase}Mapper extends BaseMapper< ${currentTbConfig.tableNameCase} > { + +} diff --git a/velocity-tmp-dir/back-vms/mybatis-plus-multb/mapperMul.vm b/velocity-tmp-dir/back-vms/mybatis-plus-multb/mapperMul.vm new file mode 100644 index 0000000..689cc2b --- /dev/null +++ b/velocity-tmp-dir/back-vms/mybatis-plus-multb/mapperMul.vm @@ -0,0 +1,16 @@ +#set($firstTbConfig=$multiTableConfig[0]) +package ${projectOrAuthor.packageName}.mapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import org.apache.ibatis.annotations.Param; +import java.util.*; +/** +* ${dbTableConfig.multiTableDesc}Mapper +* +* @author ${projectOrAuthor.author} +* @since ${projectOrAuthor.dataTime} +*/ +public interface ${dbTableConfig.multiTableNameCase}Mapper { +Page< Map > select${dbTableConfig.multiTableNameCase}(Page< Map > pagination,@Param("params") Map params); + +Map selectByKey(@Param("${firstTbConfig.associationKey}") String ${firstTbConfig.associationKey}); +} diff --git a/velocity-tmp-dir/back-vms/mybatis-plus-multb/serviceMul.vm b/velocity-tmp-dir/back-vms/mybatis-plus-multb/serviceMul.vm new file mode 100644 index 0000000..71ccf12 --- /dev/null +++ b/velocity-tmp-dir/back-vms/mybatis-plus-multb/serviceMul.vm @@ -0,0 +1,57 @@ +package ${projectOrAuthor.packageName}.service; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import java.util.*; +import com.alibaba.fastjson.JSON; +/** +* ${dbTableConfig.multiTableDesc}Service +* +* @author ${projectOrAuthor.author} +* @since ${projectOrAuthor.dataTime} +*/ +@Service +public class ${dbTableConfig.multiTableNameCase}Service { + +@Resource +private ${dbTableConfig.multiTableNameCase}Mapper ${dbTableConfig.multiTableName}Mapper; + +#foreach( $mtcItem in $multiTableConfig) +@Resource +private ${mtcItem.tableNameCase}Mapper ${mtcItem.tableName}Mapper; +#end + +public Page< Map > select${dbTableConfig.multiTableNameCase}(SelfCommonParams commonParams, Map repairVo) { + return ${dbTableConfig.multiTableName}Mapper.select${dbTableConfig.multiTableNameCase}(new Page< Map >(commonParams.getPageNum(), commonParams.getPageSize()), repairVo); +} + +public Map selectByKey(String ${dbTableConfig.multiTableName}) { + return ${dbTableConfig.multiTableName}Mapper.selectByKey(${dbTableConfig.multiTableName}); +} + +@Transactional +public void insert(${dbTableConfig.multiTableNameCase} ${dbTableConfig.multiTableName}) { + #foreach( $mtcItem in $multiTableConfig) + this.${mtcItem.tableName}Mapper.insert(JSON.parseObject(JSON.toJSONString(${dbTableConfig.multiTableName}), ${mtcItem.tableNameCase}.class)); + #end +} + +@Transactional +public void updateByKey(${dbTableConfig.multiTableNameCase} ${dbTableConfig.multiTableName}) { +#foreach( $mtcItem in $multiTableConfig) + //${mtcItem.tableDesc} + ${mtcItem.tableNameCase} ${mtcItem.tableName} = JSON.parseObject(JSON.toJSONString(${dbTableConfig.multiTableName}), ${mtcItem.tableNameCase}.class); + QueryWrapper<${mtcItem.tableNameCase}> ${mtcItem.tableName}Wrapper = new QueryWrapper<>(); + ${mtcItem.tableName}Wrapper.eq("sn", ${dbTableConfig.multiTableName}.getSn()); + this.${mtcItem.tableName}Mapper.update(${mtcItem.tableName}, ${mtcItem.tableName}Wrapper); +#end +} + +@Transactional +public void deleteByKey(${dbTableConfig.associationKeyType} ${dbTableConfig.associationKey}) { + #foreach( $mtcItem in $multiTableConfig) + //${mtcItem.tableName} + QueryWrapper<${mtcItem.tableNameCase}> ${mtcItem.tableName}Wrapper = new QueryWrapper<>(); + ${mtcItem.tableName}Wrapper.eq("${dbTableConfig.orgAssociationKey}", ${dbTableConfig.associationKey}); + this.${mtcItem.tableName}Mapper.delete(${mtcItem.tableName}Wrapper); + #end + } +} diff --git a/velocity-tmp-dir/back-vms/mybatis-plus-multb/utils.vm b/velocity-tmp-dir/back-vms/mybatis-plus-multb/utils.vm new file mode 100644 index 0000000..758add7 --- /dev/null +++ b/velocity-tmp-dir/back-vms/mybatis-plus-multb/utils.vm @@ -0,0 +1,8 @@ +#macro(getOriginField) + #foreach($fItem in $multiTableConfig) + #foreach($tableShowArrItem in ${fItem.tableShowArr})${fItem.tableName}.${tableShowArrItem.originField},#end + #end +#end +#set($originFieldString="#getOriginField()") +#set($lenth=$originFieldString.length() - 1) +#set($xmlSelectString=$originFieldString.substring(0,$lenth)) diff --git a/velocity-tmp-dir/back-vms/mybatis-plus-multb/xmlMul.vm b/velocity-tmp-dir/back-vms/mybatis-plus-multb/xmlMul.vm new file mode 100644 index 0000000..c9c3353 --- /dev/null +++ b/velocity-tmp-dir/back-vms/mybatis-plus-multb/xmlMul.vm @@ -0,0 +1,60 @@ +#parse("utils.vm") +#set($firstTbConfig=$multiTableConfig[0]) + + + + + #foreach($fItem in $multiTableConfig) + #foreach($tableShowArrItem in ${fItem.tableShowArr}) + + #end + #end + + + ${xmlSelectString} + + + + + \ No newline at end of file diff --git a/velocity-tmp-dir/back-vms/mybatis-plus/controller.vm b/velocity-tmp-dir/back-vms/mybatis-plus/controller.vm new file mode 100644 index 0000000..5c4cbef --- /dev/null +++ b/velocity-tmp-dir/back-vms/mybatis-plus/controller.vm @@ -0,0 +1,112 @@ +#parse("utils.vm") +package ${projectOrAuthor.packageName}.controller; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +/** +* ${dbTableConfig.tableDesc}Controller +* +* @author ${projectOrAuthor.author} +* @since ${projectOrAuthor.dataTime} +*/ +@Api(tags = "${dbTableConfig.tableDesc}(${dbTableConfig.tableNameCase})") +@RestController +@RequestMapping("${dbTableConfig.tableName}") +public class ${dbTableConfig.tableNameCase}Controller { + +@Resource +private ${dbTableConfig.tableNameCase}Service ${dbTableConfig.tableName}Service; + +/** +* 分页查询所有数据 +* +* @param ${dbTableConfig.tableName} 查询实体 +* @return ResResult +*/ +@GetMapping("selectPage") +@ApiOperation(value = "分页查询所有数据") +public ResResult selectPage(${dbTableConfig.tableNameCase} $dbTableConfig.tableName, SelfCommonParams commonParams) { +QueryWrapper <${dbTableConfig.tableNameCase}> queryWrapper = new QueryWrapper<>(); +#foreach($item in $queryConfig) + #if(${item.originField}=="create_time") + //${item.desc} + queryWrapper.orderByDesc("$item.originField"); + if (ObjSelfUtils.isNotEmpty(commonParams.getStartTime())) { + queryWrapper.between("create_time", commonParams.getStartTime(), commonParams.getEndTime()); + } + #else + //${item.desc} + if (ObjSelfUtils.isNotEmpty(${dbTableConfig.tableName}.get${item.fieldCase}())) { + queryWrapper.like("${item.originField}", ${dbTableConfig.tableName}.get${item.fieldCase}()); + } + #end +#end + +queryWrapper.select("$selectString"); + +Page <${dbTableConfig.tableNameCase}> ${dbTableConfig.tableName}Page = this.${dbTableConfig.tableName}Service.selectPage(commonParams.getPageNum(), commonParams.getPageSize(),queryWrapper); +return new ResResult().success(${dbTableConfig.tableName}Page); +} + +/** +* 通过主键查询单条数据 +* +* @param id 主键 +* @return 单条数据 +*/ +@GetMapping("selectById") +@ApiOperation(value = "通过id主键查询单条数据") +public ResResult selectById(@RequestParam("id") ${dbTableConfig.uniKeyType} id) { +return new ResResult().success(this.${dbTableConfig.tableName}Service.selectById(id)); +} + +/** +* @Description: 根据id数组查询品牌列表 +* @Param: idList id数组 +* @return: ids列表数据 +*/ +@ApiOperation(value = "根据id数组查询品牌列表") +@PostMapping("selectBatchIds") +public ResResult selectBatchIds(@RequestParam("idList") List< ${dbTableConfig.uniKeyType} > idList) { +return new ResResult().success(this.${dbTableConfig.tableName}Service.selectBatchIds(idList)); +} + +/** +* 新增数据 +* +* @param ${dbTableConfig.tableName} 实体对象 +* @return 新增结果 +*/ +@ApiOperation(value = "新增数据") +@PostMapping("insert") +public ResResult insert(@RequestBody ${dbTableConfig.tableNameCase} ${dbTableConfig.tableName}) { +return new ResResult().success(this.${dbTableConfig.tableName}Service.insert(${dbTableConfig.tableName})); +} + +/** +* 修改数据 +* +* @param ${dbTableConfig.tableName} 实体对象 +* @return 修改结果 +*/ +@ApiOperation(value = "根据id修改数据") +@PutMapping("updateById") +public ResResult updateById(@RequestBody ${dbTableConfig.tableNameCase} ${dbTableConfig.tableName}) { +return new ResResult().success(this.${dbTableConfig.tableName}Service.updateById(${dbTableConfig.tableName})); +} + +/** +* 删除数据 +* +* @param idList 主键结合 +* @return 删除结果 +*/ +@ApiOperation(value = "根据id数组删除数据") +@DeleteMapping("deleteBatchIds") +public ResResult deleteBatchIds(@RequestBody List< ${dbTableConfig.uniKeyType} > idList) { +return new ResResult().success(this.${dbTableConfig.tableName}Service.deleteBatchIds(idList)); +} + +@DeleteMapping("deleteById") +public ResResult deleteById(@RequestParam("id") ${dbTableConfig.uniKeyType} id) { +return new ResResult().success(this.${dbTableConfig.tableName}Service.deleteById(id)); +} +} diff --git a/velocity-tmp-dir/back-vms/mybatis-plus/entity.vm b/velocity-tmp-dir/back-vms/mybatis-plus/entity.vm new file mode 100644 index 0000000..d1a16b5 --- /dev/null +++ b/velocity-tmp-dir/back-vms/mybatis-plus/entity.vm @@ -0,0 +1,37 @@ +package ${projectOrAuthor.packageName}.entity; +import java.util.Date; +/** +* ${dbTableConfig.tableDesc}实体类 +* +* @author ${projectOrAuthor.author} +* @since ${projectOrAuthor.dataTime} +*/ +@Data +@ApiModel("${dbTableConfig.tableDesc}") +@TableName(value = "${dbTableConfig.originTableName}") +public class ${dbTableConfig.tableNameCase} extends Model< ${dbTableConfig.tableNameCase} > { +#foreach($item in $dbTableConfig.tableFieldArr) + #if($item.field=="createTime") + @ApiModelProperty(value = "$item.desc",hidden = true) + @TableField(fill = FieldFill.INSERT) + private ${item.type} $item.field; + #elseif($item.field=="updateTime") + @ApiModelProperty(value = "$item.desc",hidden = true) + @TableField(fill = FieldFill.UPDATE) + private ${item.type} $item.field; + #else + @ApiModelProperty(value = "$item.desc") + private ${item.type} $item.field; + #end +#end + +/** +* 获取主键值 +* +* @return 主键值 +*/ +@Override +protected Serializable pkVal() { +return this.${dbTableConfig.uniKey}; +} +} diff --git a/velocity-tmp-dir/back-vms/mybatis-plus/mapper.vm b/velocity-tmp-dir/back-vms/mybatis-plus/mapper.vm new file mode 100644 index 0000000..12cb2ad --- /dev/null +++ b/velocity-tmp-dir/back-vms/mybatis-plus/mapper.vm @@ -0,0 +1,10 @@ +package ${projectOrAuthor.packageName}.mapper; +/** +* ${dbTableConfig.tableDesc}Mapper +* +* @author ${projectOrAuthor.author} +* @since ${projectOrAuthor.dataTime} +*/ +public interface ${dbTableConfig.tableNameCase}Mapper extends BaseMapper< ${dbTableConfig.tableNameCase} > { + +} diff --git a/velocity-tmp-dir/back-vms/mybatis-plus/service.vm b/velocity-tmp-dir/back-vms/mybatis-plus/service.vm new file mode 100644 index 0000000..1ecde1e --- /dev/null +++ b/velocity-tmp-dir/back-vms/mybatis-plus/service.vm @@ -0,0 +1,42 @@ +package ${projectOrAuthor.packageName}.service; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +/** +* ${dbTableConfig.tableDesc}Service +* +* @author ${projectOrAuthor.author} +* @since ${projectOrAuthor.dataTime} +*/ +@Service +public class ${dbTableConfig.tableNameCase}Service { + +@Resource +private ${dbTableConfig.tableNameCase}Mapper ${dbTableConfig.tableName}Mapper; + +public Page< ${dbTableConfig.tableNameCase} > selectPage(${dbTableConfig.uniKeyType} pageNum, ${dbTableConfig.uniKeyType} pageSize, QueryWrapper< ${dbTableConfig.tableNameCase} > queryWrapper) { +return this.${dbTableConfig.tableName}Mapper.selectPage(new Page< ${dbTableConfig.tableNameCase} >(pageNum, pageSize), queryWrapper); +} + +public ${dbTableConfig.tableNameCase} selectById(${dbTableConfig.uniKeyType} id) { +return this.${dbTableConfig.tableName}Mapper.selectById(id); +} + +public List< ${dbTableConfig.tableNameCase} > selectBatchIds(List< ${dbTableConfig.uniKeyType} > idList) { +return this.${dbTableConfig.tableName}Mapper.selectBatchIds(idList); +} + +public int insert(${dbTableConfig.tableNameCase} ${dbTableConfig.tableName}) { +return this.${dbTableConfig.tableName}Mapper.insert(${dbTableConfig.tableName}); +} + +public int updateById(${dbTableConfig.tableNameCase} ${dbTableConfig.tableName}) { +return this.${dbTableConfig.tableName}Mapper.updateById(${dbTableConfig.tableName}); +} + +public int deleteById(${dbTableConfig.uniKeyType} id) { +return this.${dbTableConfig.tableName}Mapper.deleteById(id); +} + +public int deleteBatchIds(List< ${dbTableConfig.uniKeyType} > idList) { +return this.${dbTableConfig.tableName}Mapper.deleteBatchIds(idList); +} +} diff --git a/velocity-tmp-dir/back-vms/mybatis-plus/utils.vm b/velocity-tmp-dir/back-vms/mybatis-plus/utils.vm new file mode 100644 index 0000000..11faccf --- /dev/null +++ b/velocity-tmp-dir/back-vms/mybatis-plus/utils.vm @@ -0,0 +1,6 @@ +#macro(getOriginField) + #foreach($item in $formConfig)$item.originField,#end +#end +#set($originFieldString="#getOriginField()") +#set($lenth=$originFieldString.length() - 1) +#set($selectString=$originFieldString.substring(0,$lenth)) \ No newline at end of file diff --git a/ty-example/src/main/resources/application.yml b/velocity-tmp-dir/back-vms/mybatis-plus/xml.vm similarity index 100% rename from ty-example/src/main/resources/application.yml rename to velocity-tmp-dir/back-vms/mybatis-plus/xml.vm diff --git a/velocity-tmp-dir/front-vms/element-plus/CRUD.vm b/velocity-tmp-dir/front-vms/element-plus/CRUD.vm new file mode 100644 index 0000000..99e3d0d --- /dev/null +++ b/velocity-tmp-dir/front-vms/element-plus/CRUD.vm @@ -0,0 +1,96 @@ +#parse("queryUtils.vm") +#parse("tableUtils.vm") +#parse("utils.vm") + + + + \ No newline at end of file diff --git a/velocity-tmp-dir/front-vms/element-plus/CRUDForm.vm b/velocity-tmp-dir/front-vms/element-plus/CRUDForm.vm new file mode 100644 index 0000000..0d72de3 --- /dev/null +++ b/velocity-tmp-dir/front-vms/element-plus/CRUDForm.vm @@ -0,0 +1,87 @@ +#parse("formUtils.vm") + + + + + \ No newline at end of file diff --git a/velocity-tmp-dir/front-vms/element-plus/formUtils.vm b/velocity-tmp-dir/front-vms/element-plus/formUtils.vm new file mode 100644 index 0000000..0bc16a2 --- /dev/null +++ b/velocity-tmp-dir/front-vms/element-plus/formUtils.vm @@ -0,0 +1,268 @@ +##生成form item +#parse("utils.vm") +#macro(formTemp) +#foreach($item in $formConfig) + #if($item.componentType=="input") ##input + + + + #elseif($item.componentType=="textarea") ##textarea + + + + #elseif($item.componentType=="select") ##select + + + #foreach($enum in $item.optionDataArr) + + #end + + + #elseif($item.componentType=="selectApi") ##selectApi + + + + + + #elseif($item.componentType=="radio") ##radio + + + #foreach($enum in $item.optionDataArr) + ${enum.label} + #end + + + #elseif($item.componentType=="checkbox") ##checkbox + + + #foreach($enum in $item.optionDataArr) + + #end + + + #elseif($item.componentType=="switch") ##switch + + + + #elseif($item.componentType=="cascaderApi") ##cascader + + + + #elseif($item.componentType=="datetimerange") ##datetimerange + + + + #elseif($item.componentType=="datetime") ##datetime + + + + #elseif($item.componentType=="date") ##date + + + + #elseif($item.componentType=="uploadImage") ##uploadImage + +
+ +
+ + + 上传 + + +
{{ chooseFileName }}
+
+
+
+ #end +#end +#end +##rule校验 +#macro(rulesData) +#foreach($item in $formConfig) +#if($item.rule=="notNull")##必填 + $item.field:{required: true, message:"${item.desc}不能为空",trigger:["blur", "change"]}, + #elseif ($item.rule=="number")##只允许输入数字 + $item.field:[{required: true, message: "请输入${item.desc}", trigger: "blur"},{pattern: + /^[1-9]\d*$/,message: "${item.desc}为正整数",trigger: "blur",}], + #elseif ($item.rule=="positiveNumber")##只允许输入正数(允许带两位小数) + $item.field:[{required: true, message: "请输入${item.desc}", trigger: "blur"},{pattern: + /^[1-9]\d*$/,message: "${item.desc}为正整数",trigger: "blur",}], +#end +#end +#end +##保存请求接口 +#macro(insertReq) +const insertReq = () => { +const data = JSON.parse(JSON.stringify(subForm)) +delete data.id +axiosReq({ +url: '${apiConfig.insertApi}', +data: data, +method: '${apiConfig.insertApiType}', +bfLoading: true +}).then(() => { +elMessage('保存成功') +emit('selectPageReq') +emit('hideComp') +}) +} +#end +##保存请求接口 +#macro(updateReq) +const updateReq = () => { +return axiosReq({ +url: '${apiConfig.updateApi}', +data: subForm, +method: '${apiConfig.updateApiType}', +bfLoading: true +}).then(() => { +elMessage('更新成功') +emit('selectPageReq') +emit('hideComp') +}) +} +#end +##上传图片,一张图片 +#macro(fileUploadSave) +/*上传图片(单张))*/ +const refSettingFile = $ref(null) +const goUploadFile = () => { +refSettingFile.click() +} +const fileUploadSave = () => { +const formData = new FormData() +formData.append('file', refSettingFile.files[0]) +axiosReq({ +url: '${commonConfig.upFileApi}', +timeout: 30000, +data: formData, +method: 'post', +bfLoading: true, +isUploadFile: true +}) +.then((resData) => { +let { path } = resData.data +const filename = refSettingFile.value +chooseFileName = filename.slice(filename.lastIndexOf('\\') + 1) +subForm.image = `${import.meta.env.VITE_APP_IMAGE_URL}/${path}` +refSettingFile.value = '' +}) +.catch(() => { +chooseFileName = '' +subForm.image = '' +refSettingFile.value = '' +}) +} +#end +##生成form item +#macro(formScript) + #foreach($item in $formConfig) + #if($item.componentType=="uploadImage") + #fileUploadSave() + #elseif($item.componentType=="selectApi") ##selectApi + //下拉数据选择 + let select${item.fieldCase} = $ref([]) + const select${item.fieldCase}Req = () => { + let reqConfig = { + url: '${item.api}', + method: '${item.method}' + } + axiosReq(reqConfig).then((resData) => { + select${item.fieldCase} = resData.data + }) + } + #elseif($item.componentType=="cascaderApi") ##cascaderApi + //级联数据处理 + let cascade${item.fieldCase} = $ref([]) + const cascadeProps = { + multiple: false, + value: '${item}', + label: '${item.label}', + children: '${item.children}' + } + const cascade${item.fieldCase}Req = () => { + let reqConfig = { + url: '${item.api}', + method: '${item.method}' + } + axiosReq(reqConfig).then((resData) => { + cascade${item.fieldCase} = resData.data + }) + } + const handleCascade = (data) => { + console.log(data) + } + #elseif($item.componentType=="datetimerange") ##datetimerange + //时间packing + let startEndArr=$ref([]) + const dateTimePacking = (timeArr) => { + startEndArr= timeArr + if (timeArr && timeArr.length === 2) { + subForm.startTime = timeArr[0] + subForm.endTime = timeArr[1] + } else { + subForm.startTime = '' + subForm.endTime = '' + } + } + #end + #end +#end +##onMouted需要调用的请求 +#macro(onMountedScript) + #foreach($item in $formConfig) + #if($item.componentType=="selectApi")##selectApi + select${item.fieldCase}Req() + #elseif($item.componentType=="cascaderApi") ##cascader + cascade${item.fieldCase}Req() + #end + #end +#end \ No newline at end of file diff --git a/velocity-tmp-dir/front-vms/element-plus/queryUtils.vm b/velocity-tmp-dir/front-vms/element-plus/queryUtils.vm new file mode 100644 index 0000000..ad034f8 --- /dev/null +++ b/velocity-tmp-dir/front-vms/element-plus/queryUtils.vm @@ -0,0 +1,139 @@ +##生成查询表单数据 +#macro(queryItem) + #foreach($item in $queryConfig) + #if($item.componentType=="input") ##input + + + + #elseif($item.componentType=="select") ##select + + + #foreach($enum in $item.optionDataArr) + + #end + + + #elseif($item.componentType=="selectApi") ##selectApi + + + + + + #elseif($item.componentType=="cascaderApi") ##cascaderApi + + + + #elseif($item.componentType=="datetimerange") ##datetimerange + + + + #elseif($item.componentType=="datetime") ##datetime + + + + #elseif($item.componentType=="date") ##date + + + + #end + #end +#end +##生成queryScript +#macro(queryScript) + #foreach($item in $queryConfig) + #if($item.componentType=="selectApi")##selectApi + let select${item.fieldCase} = $ref([]) + const select${item.fieldCase}Req = () => { + let reqConfig = { + url: '${item.api}', + method: '${item.method}', + } + axiosReq(reqConfig).then((resData) => { + select${item.fieldCase} = resData.data + }) + } + #elseif($item.componentType=="cascaderApi") ##cascader + let cascade${item.fieldCase} = $ref([]) + const cascadeProps = { + multiple: false, + value: '${item}', + label: '${item.label}', + children: '${item.children}' + } + const cascade${item.fieldCase}Req = () => { + let reqConfig = { + url: '${item.api}', + method: '${item.method}' + } + axiosReq(reqConfig).then((resData) => { + cascade${item.fieldCase} = resData.data + }) + } + const handleCascade = (data) => { + console.log(data) + } + #elseif($item.componentType=="datetimerange") ##datetimerange + + let selectStartEndArr=$ref([]) + const dateTimePacking = (timeArr) => { + selectStartEndArr= timeArr + if (timeArr && timeArr.length === 2) { + searchForm.startTime = timeArr[0] + searchForm.endTime = timeArr[1] + } else { + searchForm.startTime = '' + searchForm.endTime = '' + } + } + #end + #end +#end +##onMouted需要调用的请求 +#macro(onMountedScript) +onMounted(()=>{ +selectPageReq() + #foreach($item in $queryConfig) + #if($item.componentType=="selectApi")##selectApi + select${item.fieldCase}Req() + #elseif($item.componentType=="cascaderApi") ##cascader + cascade${item.fieldCase}Req() + #end + #end +}) +#end \ No newline at end of file diff --git a/velocity-tmp-dir/front-vms/element-plus/tableUtils.vm b/velocity-tmp-dir/front-vms/element-plus/tableUtils.vm new file mode 100644 index 0000000..3d8cb94 --- /dev/null +++ b/velocity-tmp-dir/front-vms/element-plus/tableUtils.vm @@ -0,0 +1,214 @@ +##表格列项 +#macro(tableColumnItemTemp) + #if($commonConfig.isTableMulChoose) + + #end + #foreach($item in $tableConfig) + #if($item.componentType=="input") ##input + + #elseif($item.componentType=="select") ##select + + + + #elseif($item.componentType=="image") ##image + + + + #end + #end +#end + +##请求表格数据 +#macro(selectPageReq) +let selectPageReq = () => { +const data = Object.assign(searchForm, { +pageNum: pageNum, +pageSize: pageSize +}) +let reqConfig = { +url: '${apiConfig.queryApi}', +method: '${apiConfig.queryApiType}', +data, +isParams: true +} +axiosReq(reqConfig).then((resData) => { +usertableData = resData.data?.records +totalPage = resData.data?.total +}) +} +#end +##删除相关 +#macro(deleteByIdReq) + #if($commonConfig.isDelete) + let deleteByIdReq = (id) => { + return axiosReq({ + url: '${apiConfig.deleteApi}', + data: { id: id }, + isParams: true, + method: '${apiConfig.deleteApiType}', + bfLoading: true + }) + } + let tableDelClick = (row) => { + elConfirm('确定', `您确定要删除【${row.name}】吗?`) + .then(() => { + deleteByIdReq(row.id).then(() => { + selectPageReq() + elMessage(`【${row.name}】删除成功`) + }) + }) + .catch(() => {}) + } + #end +#end +##多个删除 +#macro(multiDelReq) + #if($commonConfig.isMulDelete) + const refuserTable = $ref(null) + const multiDelBtnClick = () => { + let rowDeleteIdArr = [] + let deleteNameTitle = '' + rowDeleteIdArr = multipleSelection.map((mItem) => { + deleteNameTitle = deleteNameTitle + mItem.name + ',' + return mItem.id + }) + if (rowDeleteIdArr.length === 0) { + elMessage('表格选项不能为空', 'warning') + return + } + let stringLength = deleteNameTitle.length - 1 + elConfirm('删除', `您确定要删除${deleteNameTitle}吗`) + .then(() => { + const data = rowDeleteIdArr + axiosReq({ + url: `${apiConfig.deleteMultiApi}`, + data, + method: '${apiConfig.deleteMultiApiType}', + bfLoading: true + }).then((res) => { + elMessage('删除成功') + selectPageReq() + }) + }) + .catch(() => {}) + } + #end +#end +##详情modal +#macro(detailScript) + #if($commonConfig.isDetail) + let detailData = $ref({}) + let dialogTitle =$ref("") + let detailDialog =$ref(false) + let tableDetailClick = (row) => { + dialogTitle = `详情【${row.name}】` + getDetailByIdReq(row.id).then((resData) => { + detailData = resData.data + detailDialog = true + }) + } + let getDetailByIdReq = (id) => { + return axiosReq({ + url: '${apiConfig.detailApi}', + data: { id }, + isParams: true, + method: '${apiConfig.detailApiType}' + }) + } + #end +#end +##table操作 +#macro(tableGlobalOperatorTemp) + #if($commonConfig.isAdd) + + + + + 增加 + + #end + #if($commonConfig.isMulDelete) + + + + + 删除 + + #end +#end +#macro(tableOperatorTemp) + #if($commonConfig.isEdit) + 编辑 + #end + #if($commonConfig.isDetail) + 详情 + #end + #if($commonConfig.isDelete) + 删除 + #end +#end +##分页 +#macro(tablePaginationTemp) + #if($commonConfig.isPagination) +
+ +
+ #end +#end +##详情 +#macro(tableDetailTemp) + #if($commonConfig.isDetail) + + #foreach($item in $formConfig) +
+
$item.desc:{{ detailData.$item.field }}
+
+ #end + +
+ #end +#end +##编辑和添加 +#macro(tableAddEditScript) + #if($commonConfig.isEdit) + let tableEditClick = (row) => { + getDetailByIdReq(row.id).then((resData) => { + showFrom = true + nextTick(() => { + refCRUDForm.showModal(true, resData.data) + }) + }) + } + #end + #if($commonConfig.isAdd) + let showFrom = $ref(false) + const refCRUDForm = $ref(null) + let addBtnClick = () => { + showFrom = true + nextTick(() => { + refCRUDForm.showModal() + }) + } + const hideComp = () => { + showFrom = false + } + #end +#end \ No newline at end of file diff --git a/velocity-tmp-dir/front-vms/element-plus/utils.vm b/velocity-tmp-dir/front-vms/element-plus/utils.vm new file mode 100644 index 0000000..dd49408 --- /dev/null +++ b/velocity-tmp-dir/front-vms/element-plus/utils.vm @@ -0,0 +1,30 @@ +##根据数组某个key分组 +#macro(groupArrByKey $arrs $group_key) + #set($gabkMap={}) + #foreach($ai in $arrs) + #if(!$!gabkMap[$ai[$group_key]]) + #set($gabkMap[$ai[$group_key]] = [$ai]) + #else + #set($gabkMap[$ai[$group_key]][-1] = [$ai]) + #end + #end +#end +##根据数组某个deep key分组 +#macro(groupArrByDeepKey $arrs $group_key $group_deep_key) + #set($gabkDeepMap={}) + #foreach($ai in $arrs) + #if(!$!gabkDeepMap[$ai[$group_key][$group_deep_key]]) + #set($gabkDeepMap[$ai[$group_key][$group_deep_key]] = [$ai]) + #else + #set($gabkDeepMap[$ai[$group_key][$group_deep_key]][-1] = [$ai]) + #end + #end +#end + + +##form key +#macro(fromDataProp) + #foreach($item in $formConfig) + $item.field:"", + #end +#end diff --git a/velocity-tmp-dir/json-data/brandData.json b/velocity-tmp-dir/json-data/brandData.json new file mode 100644 index 0000000..bca0430 --- /dev/null +++ b/velocity-tmp-dir/json-data/brandData.json @@ -0,0 +1,135 @@ +{ + "projectOrAuthor": { + "author": "熊猫哥", + "packageName": "top.kuanghua.vg", + "serviceName": "integration-front", + "dataTime": "2021-09-15 11:54:49" + }, + "commonConfig": { + "upFileApi": "/ty-example/upload/file", + "isAdd": true, + "isDelete": true, + "isMulDelete": true, + "isEdit": true, + "isPagination": true, + "isDetail": true, + "isTableMulChoose": true + }, + "dbTableConfig":[ + { + "tableName": "brand", + "originTableName": "tb_brand", + "tableDesc": "品牌表", + "tableNameCase": "Brand", + "uniKey": "id", + "associationKey": "sn" + } + ], + "apiConfig": { + "queryApi": "/integration-front/brand/selectPage", + "queryApiType": "get", + "insertApi": "/integration-front/brand/insert", + "insertApiType": "post", + "updateApi": "/integration-front/brand/updateById", + "updateApiType": "update", + "deleteApi": "/integration-front/brand/deleteById", + "deleteApiType": "delete", + "deleteMultiApi": "/integration-front/brand/deleteBatchIds", + "deleteMultiApiType": "delete", + "detailApi": "/integration-front/brand/selectById", + "detailApiType": "get" + }, + "queryConfig": [ + { + "field": "name", + "originField": "name", + "fieldCase": "Name", + "desc": "品牌名称", + "width": 100, + "componentType": "input" + } + ], + "tableConfig": [ + { + "field": "name", + "desc": "品牌名称", + "width": 100, + "componentType": "input" + }, + { + "field": "image", + "desc": "品牌图片地址", + "width": 140, + "componentType": "image" + }, + { + "field": "letter", + "desc": "首字母", + "width": 80, + "componentType": "input" + }, + { + "field": "seq", + "desc": "排序", + "width": 80, + "componentType": "input" + }, + { + "field": "createTime", + "desc": "创建时间", + "width": 140, + "componentType": "input" + }, + { + "field": "updateTime", + "desc": "更新时间", + "width": 140, + "componentType": "input" + } + ], + "formConfig": [ + { + "field": "id", + "type": "Integer", + "originField": "id", + "desc": "主键", + "width": 100 + }, + { + "field": "name", + "type": "String", + "desc": "品牌名称", + "originField": "name", + "componentType": "input", + "rule": "isNotNull", + "width": 200 + }, + { + "field": "image", + "type": "String", + "desc": "品牌图片地址", + "originField": "image", + "componentType": "uploadImage", + "width": 200, + "rule": "isNotNull" + }, + { + "field": "letter", + "type": "String", + "desc": "品牌的首字母", + "originField": "letter", + "componentType": "input", + "width": 200, + "rule": "isNotNull" + }, + { + "field": "seq", + "type": "Integer", + "desc": "排序", + "originField": "seq", + "componentType": "textarea", + "width": 200, + "rule": "isNotNull" + } + ] +} diff --git a/velocity-tmp-dir/json-data/cascadeData.json b/velocity-tmp-dir/json-data/cascadeData.json new file mode 100644 index 0000000..bbd8e21 --- /dev/null +++ b/velocity-tmp-dir/json-data/cascadeData.json @@ -0,0 +1,16 @@ +[ + { + "value": "guide", + "label": "Guide", + "children": [ + { + "value": "feedback", + "label": "Feedback" + }, + { + "value": "consistency", + "label": "Consistency" + } + ] + } +] \ No newline at end of file diff --git a/velocity-tmp-dir/json-data/data.json b/velocity-tmp-dir/json-data/data.json new file mode 100644 index 0000000..e81f60a --- /dev/null +++ b/velocity-tmp-dir/json-data/data.json @@ -0,0 +1,192 @@ +{ + "projectOrAuthor": { + "author": "熊猫哥", + "dataTime": "2021-09-15 11:54:49" + }, + "dbTableConfig": { + "tableName": "brand", + "originTableName": "tb_brand", + "tableDesc": "品牌表", + "tableNameCase": "Brand", + "uniKey": "id" + }, + "commonConfig": { + "upFileApi": "/ty-example/upload/file", + "isAdd": true, + "isDelete": true, + "isMulDelete": true, + "isEdit": true, + "isPagination": true, + "isDetail": true, + "isTableMulChoose": true + }, + "apiConfig": { + "queryApi": "/integration-front/brand/selectPage", + "queryApiType": "get", + "insertApi": "/integration-front/brand/insert", + "insertApiType": "post", + "updateApi": "/integration-front/brand/updateById", + "updateApiType": "update", + "deleteApi": "/integration-front/brand/deleteById", + "deleteApiType": "delete", + "deleteMultiApi": "/integration-front/brand/deleteBatchIds", + "deleteMultiApiType": "delete", + "detailApi": "/integration-front/brand/selectById", + "detailApiType": "get" + }, + "queryConfig": [ + { + "field": "name", + "originField": "name", + "fieldCase": "Name", + "desc": "品牌名字", + "width": 100, + "componentType": "input" + }, + { + "field": "select", + "desc": "select", + "width": 100, + "componentType": "select", + "selectKey": "id", + "selectLabel": "label", + "queryApi": "/integration-front/VmsTemplate/selectApiDemo", + "queryApiType": "get" + }, + { + "field": "selectApi", + "desc": "selectApi", + "width": 100, + "componentType": "selectApi", + "selectKey": "id", + "selectLabel": "label", + "queryApi": "/integration-front/VmsTemplate/selectApiDemo", + "queryApiType": "get" + }, + { + "field": "cascader", + "desc": "cascader", + "width": 100, + "componentType": "cascader", + "value": "value", + "label": "label", + "children": "children", + "queryApi": "/integration-front/VmsTemplate/cascadeApiDemo", + "queryApiType": "get" + }, + { + "field": "createTime", + "desc": "时间日期选择", + "width": 100, + "componentType": "datetimerange" + } + ], + "tableConfig": [ + { + "field": "name", + "desc": "品牌名称", + "width": 100, + "componentType": "input" + }, + { + "field": "image", + "desc": "品牌图片地址", + "width": 140, + "componentType": "image" + }, + { + "field": "letter", + "desc": "首字母", + "width": 80, + "componentType": "input" + }, + { + "field": "seq", + "desc": "排序", + "width": 80, + "componentType": "input" + }, + { + "field": "createTime", + "desc": "创建时间", + "width": 140, + "componentType": "input" + }, + { + "field": "updateTime", + "desc": "更新时间", + "width": 140, + "componentType": "input" + } + ], + "formConfig": [ + { + "field": "selectApi", + "desc": "selectApi", + "width": 100, + "componentType": "selectApi", + "selectKey": "id", + "selectLabel": "label", + "queryApi": "/integration-front/VmsTemplate/selectApiDemo", + "queryApiType": "get", + "rule": "isNotNull" + }, + { + "field": "cascader", + "desc": "cascader", + "width": 100, + "componentType": "cascader", + "value": "value", + "label": "label", + "children": "children", + "queryApi": "/integration-front/VmsTemplate/cascadeApiDemo", + "queryApiType": "get", + "rule": "isNotNull" + }, + { + "field": "name", + "desc": "品牌名称", + "componentType": "input", + "rule": "isNotNull", + "width": 200 + }, + { + "field": "image", + "desc": "品牌图片地址", + "componentType": "uploadImage", + "width": 200, + "rule": "isNotNull" + }, + { + "field": "carTypeList", + "desc": "可兼容车型", + "componentType": "select", + "optionDataArr": [ + { + "desc": "未出库", + "value": "0" + }, + { + "desc": "已出库", + "value": "1" + } + ], + "rule": "isNotNull", + "width": 200 + }, + { + "field": "letter", + "desc": "品牌的首字母", + "componentType": "input", + "width": 200, + "rule": "isNotNull" + }, + { + "field": "seq", + "desc": "排序", + "componentType": "textarea", + "width": 200, + "rule": "isNotNull" + } + ] +} diff --git a/velocity-tmp-dir/json-data/multiTableData.json b/velocity-tmp-dir/json-data/multiTableData.json new file mode 100644 index 0000000..cea2d48 --- /dev/null +++ b/velocity-tmp-dir/json-data/multiTableData.json @@ -0,0 +1,3076 @@ +{ + "projectOrAuthor": { + "author": "熊猫哥", + "packageName": "top.kuanghua.integrationfront", + "serviceName": "integration-front", + "dataTime": "2022-06-25 10:32:12", + "modalTitle": "我是modal的title", + "isMultiTable": true + }, + "commonConfig": { + "upFileApi": "/ty-example/upload/file", + "isAdd": "true", + "isDelete": "true", + "isMulDelete": "true", + "isEdit": "true", + "isPagination": "true", + "isDetail": "true", + "isTableMulChoose": "true" + }, + "multiTableConfig": [ + { + "tableName": "repair", + "originTableName": "tb_repair", + "tableDesc": "售后维修表", + "tableNameCase": "Repair", + "uniKey": "id", + "tableFieldArr": [ + { + "columnType": "int(11)", + "isNullable": "NO", + "dataType": "int", + "extra": "auto_increment", + "columnComment": "ID", + "columnKey": "PRI", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "id", + "field": "id", + "desc": "ID", + "fieldCase": "", + "originField": "id", + "tbName": "id", + "type": "Integer" + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "SN_ID", + "columnKey": "UNI", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "sn", + "field": "sn", + "desc": "SN_ID", + "fieldCase": "", + "originField": "sn", + "tbName": "sn", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "int(4)", + "isNullable": "YES", + "dataType": "int", + "extra": "", + "columnComment": "设备类型;0:T-BOX,1:VCI", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "equip_type", + "field": "equipType", + "desc": "设备类型", + "fieldCase": "EquipType", + "originField": "equip_type", + "tbName": "equip_type", + "type": "Integer", + "componentType": "select", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "0:T-BOX,1:VCI", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [ + { + "value": "0:T-BOX" + }, + { + "value": "1:VCI" + } + ] + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "换件_ID", + "columnKey": "MUL", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "replacement_id", + "field": "replacementId", + "desc": "换件_ID", + "fieldCase": "ReplacementId", + "originField": "replacement_id", + "tbName": "replacement_id", + "type": "String", + "componentType": "", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "快递信息ID", + "columnKey": "MUL", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "express_id", + "field": "expressId", + "desc": "快递信息ID", + "fieldCase": "ExpressId", + "originField": "express_id", + "tbName": "express_id", + "type": "String" + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "问题归类id", + "columnKey": "MUL", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "problem_classification_id", + "field": "problemClassificationId", + "desc": "问题归类id", + "fieldCase": "ProblemClassificationId", + "originField": "problem_classification_id", + "tbName": "problem_classification_id", + "type": "String" + }, + { + "columnType": "int(4)", + "isNullable": "YES", + "dataType": "int", + "extra": "", + "columnComment": "目前状态;0:报废,1:在用,2:维修,3:更换,4:替换件", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "current_status", + "field": "currentStatus", + "desc": "目前状态", + "fieldCase": "CurrentStatus", + "originField": "current_status", + "tbName": "current_status", + "type": "Integer", + "componentType": "select", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "0:报废,1:在用,2:维修,3:更换,4:替换件", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [ + { + "value": "0:报废" + }, + { + "value": "1:在用" + }, + { + "value": "2:维修" + }, + { + "value": "3:更换" + }, + { + "value": "4:替换件" + } + ] + }, + { + "columnType": "varchar(1024)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "问题描述", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "problem_description", + "field": "problemDescription", + "desc": "问题描述", + "fieldCase": "ProblemDescription", + "originField": "problem_description", + "tbName": "problem_description", + "type": "String" + }, + { + "columnType": "datetime", + "isNullable": "YES", + "dataType": "datetime", + "extra": "", + "columnComment": "反馈时间", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "feedback_time", + "field": "feedbackTime", + "desc": "反馈时间", + "fieldCase": "FeedbackTime", + "originField": "feedback_time", + "tbName": "feedback_time", + "type": "Date" + }, + { + "columnType": "varchar(50)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "提出人", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "proposer", + "field": "proposer", + "desc": "提出人", + "fieldCase": "", + "originField": "proposer", + "tbName": "proposer", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "varchar(50)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "联系方式", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "contact_info", + "field": "contactInfo", + "desc": "联系方式", + "fieldCase": "ContactInfo", + "originField": "contact_info", + "tbName": "contact_info", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "datetime", + "isNullable": "YES", + "dataType": "datetime", + "extra": "", + "columnComment": "回收日期", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "recovery_date", + "field": "recoveryDate", + "desc": "回收日期", + "fieldCase": "RecoveryDate", + "originField": "recovery_date", + "tbName": "recovery_date", + "type": "Date", + "componentType": "datetime", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "datetime", + "isNullable": "YES", + "dataType": "datetime", + "extra": "", + "columnComment": "返回日期", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "return_date", + "field": "returnDate", + "desc": "返回日期", + "fieldCase": "ReturnDate", + "originField": "return_date", + "tbName": "return_date", + "type": "Date" + }, + { + "columnType": "varchar(1024)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "返修分析的问题", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "problems_analyzed", + "field": "problemsAnalyzed", + "desc": "返修分析的问题", + "fieldCase": "ProblemsAnalyzed", + "originField": "problems_analyzed", + "tbName": "problems_analyzed", + "type": "String" + }, + { + "columnType": "varchar(1024)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "返修分析的原因", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "reason", + "field": "reason", + "desc": "返修分析的原因", + "fieldCase": "", + "originField": "reason", + "tbName": "reason", + "type": "String" + }, + { + "columnType": "varchar(1024)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "处理方法", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "processing_method", + "field": "processingMethod", + "desc": "处理方法", + "fieldCase": "ProcessingMethod", + "originField": "processing_method", + "tbName": "processing_method", + "type": "String" + }, + { + "columnType": "varchar(1024)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "备注", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "remarks", + "field": "remarks", + "desc": "备注", + "fieldCase": "", + "originField": "remarks", + "tbName": "remarks", + "type": "String" + }, + { + "columnType": "datetime", + "isNullable": "YES", + "dataType": "datetime", + "extra": "", + "columnComment": "创建时间", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "create_time", + "field": "createTime", + "desc": "创建时间", + "fieldCase": "CreateTime", + "originField": "create_time", + "tbName": "create_time", + "type": "Date" + }, + { + "columnType": "datetime", + "isNullable": "YES", + "dataType": "datetime", + "extra": "", + "columnComment": "更新时间", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "update_time", + "field": "updateTime", + "desc": "更新时间", + "fieldCase": "UpdateTime", + "originField": "update_time", + "tbName": "update_time", + "type": "Date" + } + ], + "orgUniKey": "id", + "uniKeyType": "Integer", + "priKeyArr": [ + "id", + "sn", + "replacement_id", + "express_id", + "problem_classification_id" + ], + "priKeyItemArr": [ + { + "columnType": "int(11)", + "isNullable": "NO", + "dataType": "int", + "extra": "auto_increment", + "columnComment": "ID", + "columnKey": "PRI", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "id", + "field": "id", + "desc": "ID", + "fieldCase": "", + "originField": "id", + "tbName": "id", + "type": "Integer" + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "SN_ID", + "columnKey": "UNI", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "sn", + "field": "sn", + "desc": "SN_ID", + "fieldCase": "", + "originField": "sn", + "tbName": "sn", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "换件_ID", + "columnKey": "MUL", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "replacement_id", + "field": "replacementId", + "desc": "换件_ID", + "fieldCase": "ReplacementId", + "originField": "replacement_id", + "tbName": "replacement_id", + "type": "String", + "componentType": "", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "快递信息ID", + "columnKey": "MUL", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "express_id", + "field": "expressId", + "desc": "快递信息ID", + "fieldCase": "ExpressId", + "originField": "express_id", + "tbName": "express_id", + "type": "String" + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "问题归类id", + "columnKey": "MUL", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "problem_classification_id", + "field": "problemClassificationId", + "desc": "问题归类id", + "fieldCase": "ProblemClassificationId", + "originField": "problem_classification_id", + "tbName": "problem_classification_id", + "type": "String" + } + ], + "orgAssociationKey": "sn", + "associationKey": "sn", + "associationKeyCase": "ProblemClassificationId", + "associationKeyType": "String", + "multiTableNameCase": null, + "tableQueryArr": [ + { + "columnType": "int(4)", + "isNullable": "YES", + "dataType": "int", + "extra": "", + "columnComment": "目前状态;0:报废,1:在用,2:维修,3:更换,4:替换件", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "current_status", + "field": "currentStatus", + "desc": "目前状态", + "fieldCase": "CurrentStatus", + "originField": "current_status", + "tbName": "current_status", + "type": "Integer", + "componentType": "select", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "0:报废,1:在用,2:维修,3:更换,4:替换件", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [ + { + "value": "0:报废" + }, + { + "value": "1:在用" + }, + { + "value": "2:维修" + }, + { + "value": "3:更换" + }, + { + "value": "4:替换件" + } + ] + }, + { + "columnType": "datetime", + "isNullable": "YES", + "dataType": "datetime", + "extra": "", + "columnComment": "回收日期", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "recovery_date", + "field": "recoveryDate", + "desc": "回收日期", + "fieldCase": "RecoveryDate", + "originField": "recovery_date", + "tbName": "recovery_date", + "type": "Date", + "componentType": "datetime", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "varchar(50)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "联系方式", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "contact_info", + "field": "contactInfo", + "desc": "联系方式", + "fieldCase": "ContactInfo", + "originField": "contact_info", + "tbName": "contact_info", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "int(4)", + "isNullable": "YES", + "dataType": "int", + "extra": "", + "columnComment": "设备类型;0:T-BOX,1:VCI", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "equip_type", + "field": "equipType", + "desc": "设备类型", + "fieldCase": "EquipType", + "originField": "equip_type", + "tbName": "equip_type", + "type": "Integer", + "componentType": "select", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "0:T-BOX,1:VCI", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [ + { + "value": "0:T-BOX" + }, + { + "value": "1:VCI" + } + ] + } + ], + "tableShowArr": [ + { + "columnType": "int(4)", + "isNullable": "YES", + "dataType": "int", + "extra": "", + "columnComment": "目前状态;0:报废,1:在用,2:维修,3:更换,4:替换件", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "current_status", + "field": "currentStatus", + "desc": "目前状态", + "fieldCase": "CurrentStatus", + "originField": "current_status", + "tbName": "current_status", + "type": "Integer", + "componentType": "select", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "0:报废,1:在用,2:维修,3:更换,4:替换件", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [ + { + "value": "0:报废" + }, + { + "value": "1:在用" + }, + { + "value": "2:维修" + }, + { + "value": "3:更换" + }, + { + "value": "4:替换件" + } + ] + }, + { + "columnType": "datetime", + "isNullable": "YES", + "dataType": "datetime", + "extra": "", + "columnComment": "回收日期", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "recovery_date", + "field": "recoveryDate", + "desc": "回收日期", + "fieldCase": "RecoveryDate", + "originField": "recovery_date", + "tbName": "recovery_date", + "type": "Date", + "componentType": "datetime", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "varchar(50)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "联系方式", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "contact_info", + "field": "contactInfo", + "desc": "联系方式", + "fieldCase": "ContactInfo", + "originField": "contact_info", + "tbName": "contact_info", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "int(4)", + "isNullable": "YES", + "dataType": "int", + "extra": "", + "columnComment": "设备类型;0:T-BOX,1:VCI", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "equip_type", + "field": "equipType", + "desc": "设备类型", + "fieldCase": "EquipType", + "originField": "equip_type", + "tbName": "equip_type", + "type": "Integer", + "componentType": "select", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "0:T-BOX,1:VCI", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [ + { + "value": "0:T-BOX" + }, + { + "value": "1:VCI" + } + ] + } + ], + "tableFormArr": [ + { + "columnType": "int(4)", + "isNullable": "YES", + "dataType": "int", + "extra": "", + "columnComment": "目前状态;0:报废,1:在用,2:维修,3:更换,4:替换件", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "current_status", + "field": "currentStatus", + "desc": "目前状态", + "fieldCase": "CurrentStatus", + "originField": "current_status", + "tbName": "current_status", + "type": "Integer", + "componentType": "select", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "0:报废,1:在用,2:维修,3:更换,4:替换件", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [ + { + "value": "0:报废" + }, + { + "value": "1:在用" + }, + { + "value": "2:维修" + }, + { + "value": "3:更换" + }, + { + "value": "4:替换件" + } + ] + }, + { + "columnType": "datetime", + "isNullable": "YES", + "dataType": "datetime", + "extra": "", + "columnComment": "回收日期", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "recovery_date", + "field": "recoveryDate", + "desc": "回收日期", + "fieldCase": "RecoveryDate", + "originField": "recovery_date", + "tbName": "recovery_date", + "type": "Date", + "componentType": "datetime", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "varchar(50)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "联系方式", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "contact_info", + "field": "contactInfo", + "desc": "联系方式", + "fieldCase": "ContactInfo", + "originField": "contact_info", + "tbName": "contact_info", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "int(4)", + "isNullable": "YES", + "dataType": "int", + "extra": "", + "columnComment": "设备类型;0:T-BOX,1:VCI", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "equip_type", + "field": "equipType", + "desc": "设备类型", + "fieldCase": "EquipType", + "originField": "equip_type", + "tbName": "equip_type", + "type": "Integer", + "componentType": "select", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "0:T-BOX,1:VCI", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [ + { + "value": "0:T-BOX" + }, + { + "value": "1:VCI" + } + ] + } + ] + }, + { + "tableName": "replacement", + "originTableName": "tb_replacement", + "tableDesc": "换件表", + "tableNameCase": "Replacement", + "uniKey": "id", + "tableFieldArr": [ + { + "columnType": "int(11)", + "isNullable": "NO", + "dataType": "int", + "extra": "auto_increment", + "columnComment": "ID", + "columnKey": "PRI", + "tableSchema": "micro-service-plus", + "tableName": "tb_replacement", + "columnName": "id", + "field": "id", + "desc": "ID", + "fieldCase": "", + "originField": "id", + "tbName": "id", + "type": "Integer" + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "SN_ID", + "columnKey": "UNI", + "tableSchema": "micro-service-plus", + "tableName": "tb_replacement", + "columnName": "sn", + "field": "sn", + "desc": "SN_ID", + "fieldCase": "", + "originField": "sn", + "tbName": "sn", + "type": "String" + }, + { + "columnType": "int(4)", + "isNullable": "YES", + "dataType": "int", + "extra": "", + "columnComment": "设备类型;0:T-BOX,1:VCI", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_replacement", + "columnName": "equip_type", + "field": "equipType", + "desc": "设备类型;0:T-BOX,1:VCI", + "fieldCase": "EquipType", + "originField": "equip_type", + "tbName": "equip_type", + "type": "Integer" + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "新SN_ID", + "columnKey": "MUL", + "tableSchema": "micro-service-plus", + "tableName": "tb_replacement", + "columnName": "new_sn_id", + "field": "newSnId", + "desc": "新SN_ID", + "fieldCase": "NewSnId", + "originField": "new_sn_id", + "tbName": "new_sn_id", + "type": "String", + "componentType": "", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "int(11)", + "isNullable": "YES", + "dataType": "int", + "extra": "", + "columnComment": "深度;(换件次数)", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_replacement", + "columnName": "depth", + "field": "depth", + "desc": "深度", + "fieldCase": "", + "originField": "depth", + "tbName": "depth", + "type": "Integer", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "datetime", + "isNullable": "YES", + "dataType": "datetime", + "extra": "", + "columnComment": "创建时间", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_replacement", + "columnName": "create_time", + "field": "createTime", + "desc": "创建时间", + "fieldCase": "CreateTime", + "originField": "create_time", + "tbName": "create_time", + "type": "Date" + }, + { + "columnType": "datetime", + "isNullable": "YES", + "dataType": "datetime", + "extra": "", + "columnComment": "更新时间", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_replacement", + "columnName": "update_time", + "field": "updateTime", + "desc": "更新时间", + "fieldCase": "UpdateTime", + "originField": "update_time", + "tbName": "update_time", + "type": "Date" + } + ], + "orgUniKey": "id", + "uniKeyType": "Integer", + "priKeyArr": [ + "id", + "sn", + "new_sn_id" + ], + "priKeyItemArr": [ + { + "columnType": "int(11)", + "isNullable": "NO", + "dataType": "int", + "extra": "auto_increment", + "columnComment": "ID", + "columnKey": "PRI", + "tableSchema": "micro-service-plus", + "tableName": "tb_replacement", + "columnName": "id", + "field": "id", + "desc": "ID", + "fieldCase": "", + "originField": "id", + "tbName": "id", + "type": "Integer" + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "SN_ID", + "columnKey": "UNI", + "tableSchema": "micro-service-plus", + "tableName": "tb_replacement", + "columnName": "sn", + "field": "sn", + "desc": "SN_ID", + "fieldCase": "", + "originField": "sn", + "tbName": "sn", + "type": "String" + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "新SN_ID", + "columnKey": "MUL", + "tableSchema": "micro-service-plus", + "tableName": "tb_replacement", + "columnName": "new_sn_id", + "field": "newSnId", + "desc": "新SN_ID", + "fieldCase": "NewSnId", + "originField": "new_sn_id", + "tbName": "new_sn_id", + "type": "String", + "componentType": "", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + } + ], + "orgAssociationKey": "sn", + "associationKey": "sn", + "associationKeyCase": "NewSnId", + "associationKeyType": "String", + "multiTableNameCase": "Pair", + "tableQueryArr": [ + { + "columnType": "int(11)", + "isNullable": "YES", + "dataType": "int", + "extra": "", + "columnComment": "深度;(换件次数)", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_replacement", + "columnName": "depth", + "field": "depth", + "desc": "深度", + "fieldCase": "", + "originField": "depth", + "tbName": "depth", + "type": "Integer", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + } + ], + "tableShowArr": [ + { + "columnType": "int(11)", + "isNullable": "YES", + "dataType": "int", + "extra": "", + "columnComment": "深度;(换件次数)", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_replacement", + "columnName": "depth", + "field": "depth", + "desc": "深度", + "fieldCase": "", + "originField": "depth", + "tbName": "depth", + "type": "Integer", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + } + ], + "tableFormArr": [ + { + "columnType": "int(11)", + "isNullable": "YES", + "dataType": "int", + "extra": "", + "columnComment": "深度;(换件次数)", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_replacement", + "columnName": "depth", + "field": "depth", + "desc": "深度", + "fieldCase": "", + "originField": "depth", + "tbName": "depth", + "type": "Integer", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + } + ] + } + ], + "dbTableConfig": { + "multiTableName": "pairment", + "multiTableDesc": "多表中实体类的注释", + "tableName": "repair", + "originTableName": "tb_repair", + "tableDesc": "售后维修表", + "tableNameCase": "Repair", + "uniKey": "id", + "tableFieldArr": [ + { + "columnType": "int(11)", + "isNullable": "NO", + "dataType": "int", + "extra": "auto_increment", + "columnComment": "ID", + "columnKey": "PRI", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "id", + "field": "id", + "desc": "ID", + "fieldCase": "", + "originField": "id", + "tbName": "id", + "type": "Integer" + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "SN_ID", + "columnKey": "UNI", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "sn", + "field": "sn", + "desc": "SN_ID", + "fieldCase": "", + "originField": "sn", + "tbName": "sn", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "int(4)", + "isNullable": "YES", + "dataType": "int", + "extra": "", + "columnComment": "设备类型;0:T-BOX,1:VCI", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "equip_type", + "field": "equipType", + "desc": "设备类型", + "fieldCase": "EquipType", + "originField": "equip_type", + "tbName": "equip_type", + "type": "Integer", + "componentType": "select", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "0:T-BOX,1:VCI", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [ + { + "value": "0:T-BOX" + }, + { + "value": "1:VCI" + } + ] + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "换件_ID", + "columnKey": "MUL", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "replacement_id", + "field": "replacementId", + "desc": "换件_ID", + "fieldCase": "ReplacementId", + "originField": "replacement_id", + "tbName": "replacement_id", + "type": "String", + "componentType": "", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "快递信息ID", + "columnKey": "MUL", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "express_id", + "field": "expressId", + "desc": "快递信息ID", + "fieldCase": "ExpressId", + "originField": "express_id", + "tbName": "express_id", + "type": "String" + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "问题归类id", + "columnKey": "MUL", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "problem_classification_id", + "field": "problemClassificationId", + "desc": "问题归类id", + "fieldCase": "ProblemClassificationId", + "originField": "problem_classification_id", + "tbName": "problem_classification_id", + "type": "String" + }, + { + "columnType": "int(4)", + "isNullable": "YES", + "dataType": "int", + "extra": "", + "columnComment": "目前状态;0:报废,1:在用,2:维修,3:更换,4:替换件", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "current_status", + "field": "currentStatus", + "desc": "目前状态", + "fieldCase": "CurrentStatus", + "originField": "current_status", + "tbName": "current_status", + "type": "Integer", + "componentType": "select", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "0:报废,1:在用,2:维修,3:更换,4:替换件", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [ + { + "value": "0:报废" + }, + { + "value": "1:在用" + }, + { + "value": "2:维修" + }, + { + "value": "3:更换" + }, + { + "value": "4:替换件" + } + ] + }, + { + "columnType": "varchar(1024)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "问题描述", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "problem_description", + "field": "problemDescription", + "desc": "问题描述", + "fieldCase": "ProblemDescription", + "originField": "problem_description", + "tbName": "problem_description", + "type": "String" + }, + { + "columnType": "datetime", + "isNullable": "YES", + "dataType": "datetime", + "extra": "", + "columnComment": "反馈时间", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "feedback_time", + "field": "feedbackTime", + "desc": "反馈时间", + "fieldCase": "FeedbackTime", + "originField": "feedback_time", + "tbName": "feedback_time", + "type": "Date" + }, + { + "columnType": "varchar(50)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "提出人", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "proposer", + "field": "proposer", + "desc": "提出人", + "fieldCase": "", + "originField": "proposer", + "tbName": "proposer", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "varchar(50)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "联系方式", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "contact_info", + "field": "contactInfo", + "desc": "联系方式", + "fieldCase": "ContactInfo", + "originField": "contact_info", + "tbName": "contact_info", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "datetime", + "isNullable": "YES", + "dataType": "datetime", + "extra": "", + "columnComment": "回收日期", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "recovery_date", + "field": "recoveryDate", + "desc": "回收日期", + "fieldCase": "RecoveryDate", + "originField": "recovery_date", + "tbName": "recovery_date", + "type": "Date", + "componentType": "datetime", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "datetime", + "isNullable": "YES", + "dataType": "datetime", + "extra": "", + "columnComment": "返回日期", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "return_date", + "field": "returnDate", + "desc": "返回日期", + "fieldCase": "ReturnDate", + "originField": "return_date", + "tbName": "return_date", + "type": "Date" + }, + { + "columnType": "varchar(1024)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "返修分析的问题", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "problems_analyzed", + "field": "problemsAnalyzed", + "desc": "返修分析的问题", + "fieldCase": "ProblemsAnalyzed", + "originField": "problems_analyzed", + "tbName": "problems_analyzed", + "type": "String" + }, + { + "columnType": "varchar(1024)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "返修分析的原因", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "reason", + "field": "reason", + "desc": "返修分析的原因", + "fieldCase": "", + "originField": "reason", + "tbName": "reason", + "type": "String" + }, + { + "columnType": "varchar(1024)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "处理方法", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "processing_method", + "field": "processingMethod", + "desc": "处理方法", + "fieldCase": "ProcessingMethod", + "originField": "processing_method", + "tbName": "processing_method", + "type": "String" + }, + { + "columnType": "varchar(1024)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "备注", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "remarks", + "field": "remarks", + "desc": "备注", + "fieldCase": "", + "originField": "remarks", + "tbName": "remarks", + "type": "String" + }, + { + "columnType": "datetime", + "isNullable": "YES", + "dataType": "datetime", + "extra": "", + "columnComment": "创建时间", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "create_time", + "field": "createTime", + "desc": "创建时间", + "fieldCase": "CreateTime", + "originField": "create_time", + "tbName": "create_time", + "type": "Date" + }, + { + "columnType": "datetime", + "isNullable": "YES", + "dataType": "datetime", + "extra": "", + "columnComment": "更新时间", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "update_time", + "field": "updateTime", + "desc": "更新时间", + "fieldCase": "UpdateTime", + "originField": "update_time", + "tbName": "update_time", + "type": "Date" + } + ], + "orgUniKey": "id", + "uniKeyType": "Integer", + "priKeyArr": [ + "id", + "sn", + "replacement_id", + "express_id", + "problem_classification_id" + ], + "priKeyItemArr": [ + { + "columnType": "int(11)", + "isNullable": "NO", + "dataType": "int", + "extra": "auto_increment", + "columnComment": "ID", + "columnKey": "PRI", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "id", + "field": "id", + "desc": "ID", + "fieldCase": "", + "originField": "id", + "tbName": "id", + "type": "Integer" + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "SN_ID", + "columnKey": "UNI", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "sn", + "field": "sn", + "desc": "SN_ID", + "fieldCase": "", + "originField": "sn", + "tbName": "sn", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "换件_ID", + "columnKey": "MUL", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "replacement_id", + "field": "replacementId", + "desc": "换件_ID", + "fieldCase": "ReplacementId", + "originField": "replacement_id", + "tbName": "replacement_id", + "type": "String", + "componentType": "", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "快递信息ID", + "columnKey": "MUL", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "express_id", + "field": "expressId", + "desc": "快递信息ID", + "fieldCase": "ExpressId", + "originField": "express_id", + "tbName": "express_id", + "type": "String" + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "问题归类id", + "columnKey": "MUL", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "problem_classification_id", + "field": "problemClassificationId", + "desc": "问题归类id", + "fieldCase": "ProblemClassificationId", + "originField": "problem_classification_id", + "tbName": "problem_classification_id", + "type": "String" + } + ], + "orgAssociationKey": "sn", + "associationKey": "sn", + "associationKeyCase": "ProblemClassificationId", + "associationKeyType": "String", + "multiTableNameCase": "Pairment", + "tableQueryArr": [ + { + "columnType": "int(4)", + "isNullable": "YES", + "dataType": "int", + "extra": "", + "columnComment": "目前状态;0:报废,1:在用,2:维修,3:更换,4:替换件", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "current_status", + "field": "currentStatus", + "desc": "目前状态", + "fieldCase": "CurrentStatus", + "originField": "current_status", + "tbName": "current_status", + "type": "Integer", + "componentType": "select", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "0:报废,1:在用,2:维修,3:更换,4:替换件", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [ + { + "value": "0:报废" + }, + { + "value": "1:在用" + }, + { + "value": "2:维修" + }, + { + "value": "3:更换" + }, + { + "value": "4:替换件" + } + ] + }, + { + "columnType": "datetime", + "isNullable": "YES", + "dataType": "datetime", + "extra": "", + "columnComment": "回收日期", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "recovery_date", + "field": "recoveryDate", + "desc": "回收日期", + "fieldCase": "RecoveryDate", + "originField": "recovery_date", + "tbName": "recovery_date", + "type": "Date", + "componentType": "datetime", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "varchar(50)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "联系方式", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "contact_info", + "field": "contactInfo", + "desc": "联系方式", + "fieldCase": "ContactInfo", + "originField": "contact_info", + "tbName": "contact_info", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "int(4)", + "isNullable": "YES", + "dataType": "int", + "extra": "", + "columnComment": "设备类型;0:T-BOX,1:VCI", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "equip_type", + "field": "equipType", + "desc": "设备类型", + "fieldCase": "EquipType", + "originField": "equip_type", + "tbName": "equip_type", + "type": "Integer", + "componentType": "select", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "0:T-BOX,1:VCI", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [ + { + "value": "0:T-BOX" + }, + { + "value": "1:VCI" + } + ] + } + ], + "tableShowArr": [ + { + "columnType": "int(4)", + "isNullable": "YES", + "dataType": "int", + "extra": "", + "columnComment": "目前状态;0:报废,1:在用,2:维修,3:更换,4:替换件", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "current_status", + "field": "currentStatus", + "desc": "目前状态", + "fieldCase": "CurrentStatus", + "originField": "current_status", + "tbName": "current_status", + "type": "Integer", + "componentType": "select", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "0:报废,1:在用,2:维修,3:更换,4:替换件", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [ + { + "value": "0:报废" + }, + { + "value": "1:在用" + }, + { + "value": "2:维修" + }, + { + "value": "3:更换" + }, + { + "value": "4:替换件" + } + ] + }, + { + "columnType": "datetime", + "isNullable": "YES", + "dataType": "datetime", + "extra": "", + "columnComment": "回收日期", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "recovery_date", + "field": "recoveryDate", + "desc": "回收日期", + "fieldCase": "RecoveryDate", + "originField": "recovery_date", + "tbName": "recovery_date", + "type": "Date", + "componentType": "datetime", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "varchar(50)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "联系方式", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "contact_info", + "field": "contactInfo", + "desc": "联系方式", + "fieldCase": "ContactInfo", + "originField": "contact_info", + "tbName": "contact_info", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "int(4)", + "isNullable": "YES", + "dataType": "int", + "extra": "", + "columnComment": "设备类型;0:T-BOX,1:VCI", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "equip_type", + "field": "equipType", + "desc": "设备类型", + "fieldCase": "EquipType", + "originField": "equip_type", + "tbName": "equip_type", + "type": "Integer", + "componentType": "select", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "0:T-BOX,1:VCI", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [ + { + "value": "0:T-BOX" + }, + { + "value": "1:VCI" + } + ] + } + ], + "tableFormArr": [ + { + "columnType": "int(4)", + "isNullable": "YES", + "dataType": "int", + "extra": "", + "columnComment": "目前状态;0:报废,1:在用,2:维修,3:更换,4:替换件", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "current_status", + "field": "currentStatus", + "desc": "目前状态", + "fieldCase": "CurrentStatus", + "originField": "current_status", + "tbName": "current_status", + "type": "Integer", + "componentType": "select", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "0:报废,1:在用,2:维修,3:更换,4:替换件", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [ + { + "value": "0:报废" + }, + { + "value": "1:在用" + }, + { + "value": "2:维修" + }, + { + "value": "3:更换" + }, + { + "value": "4:替换件" + } + ] + }, + { + "columnType": "datetime", + "isNullable": "YES", + "dataType": "datetime", + "extra": "", + "columnComment": "回收日期", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "recovery_date", + "field": "recoveryDate", + "desc": "回收日期", + "fieldCase": "RecoveryDate", + "originField": "recovery_date", + "tbName": "recovery_date", + "type": "Date", + "componentType": "datetime", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "varchar(50)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "联系方式", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "contact_info", + "field": "contactInfo", + "desc": "联系方式", + "fieldCase": "ContactInfo", + "originField": "contact_info", + "tbName": "contact_info", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "int(4)", + "isNullable": "YES", + "dataType": "int", + "extra": "", + "columnComment": "设备类型;0:T-BOX,1:VCI", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "equip_type", + "field": "equipType", + "desc": "设备类型", + "fieldCase": "EquipType", + "originField": "equip_type", + "tbName": "equip_type", + "type": "Integer", + "componentType": "select", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "0:T-BOX,1:VCI", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [ + { + "value": "0:T-BOX" + }, + { + "value": "1:VCI" + } + ] + } + ] + }, + "apiConfig": { + "queryApi": "/integration-front/pairment/selectPage", + "queryApiType": "get", + "insertApi": "/insert", + "insertApiType": "post", + "updateApi": "/integration-front/pairment/updateById", + "updateApiType": "update", + "deleteApi": "/integration-front/pairment/deleteById", + "deleteApiType": "delete", + "deleteMultiApi": "/integration-front/pairment/deleteBatchIds", + "deleteMultiApiType": "delete", + "detailApi": "/integration-front/pairment/selectById", + "detailApiType": "get" + }, + "queryConfig": [ + { + "columnType": "int(4)", + "isNullable": "YES", + "dataType": "int", + "extra": "", + "columnComment": "目前状态;0:报废,1:在用,2:维修,3:更换,4:替换件", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "current_status", + "field": "currentStatus", + "desc": "目前状态", + "fieldCase": "CurrentStatus", + "originField": "current_status", + "tbName": "current_status", + "type": "Integer", + "componentType": "select", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "0:报废,1:在用,2:维修,3:更换,4:替换件", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [ + { + "value": "0:报废" + }, + { + "value": "1:在用" + }, + { + "value": "2:维修" + }, + { + "value": "3:更换" + }, + { + "value": "4:替换件" + } + ] + }, + { + "columnType": "datetime", + "isNullable": "YES", + "dataType": "datetime", + "extra": "", + "columnComment": "回收日期", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "recovery_date", + "field": "recoveryDate", + "desc": "回收日期", + "fieldCase": "RecoveryDate", + "originField": "recovery_date", + "tbName": "recovery_date", + "type": "Date", + "componentType": "datetime", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "varchar(50)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "联系方式", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "contact_info", + "field": "contactInfo", + "desc": "联系方式", + "fieldCase": "ContactInfo", + "originField": "contact_info", + "tbName": "contact_info", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "int(4)", + "isNullable": "YES", + "dataType": "int", + "extra": "", + "columnComment": "设备类型;0:T-BOX,1:VCI", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "equip_type", + "field": "equipType", + "desc": "设备类型", + "fieldCase": "EquipType", + "originField": "equip_type", + "tbName": "equip_type", + "type": "Integer", + "componentType": "select", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "0:T-BOX,1:VCI", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [ + { + "value": "0:T-BOX" + }, + { + "value": "1:VCI" + } + ] + }, + { + "columnType": "int(11)", + "isNullable": "YES", + "dataType": "int", + "extra": "", + "columnComment": "深度;(换件次数)", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_replacement", + "columnName": "depth", + "field": "depth", + "desc": "深度", + "fieldCase": "", + "originField": "depth", + "tbName": "depth", + "type": "Integer", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + } + ], + "tableConfig": [ + { + "columnType": "int(4)", + "isNullable": "YES", + "dataType": "int", + "extra": "", + "columnComment": "目前状态;0:报废,1:在用,2:维修,3:更换,4:替换件", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "current_status", + "field": "currentStatus", + "desc": "目前状态", + "fieldCase": "CurrentStatus", + "originField": "current_status", + "tbName": "current_status", + "type": "Integer", + "componentType": "select", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "0:报废,1:在用,2:维修,3:更换,4:替换件", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [ + { + "value": "0:报废" + }, + { + "value": "1:在用" + }, + { + "value": "2:维修" + }, + { + "value": "3:更换" + }, + { + "value": "4:替换件" + } + ] + }, + { + "columnType": "varchar(50)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "提出人", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "proposer", + "field": "proposer", + "desc": "提出人", + "fieldCase": "", + "originField": "proposer", + "tbName": "proposer", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "datetime", + "isNullable": "YES", + "dataType": "datetime", + "extra": "", + "columnComment": "回收日期", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "recovery_date", + "field": "recoveryDate", + "desc": "回收日期", + "fieldCase": "RecoveryDate", + "originField": "recovery_date", + "tbName": "recovery_date", + "type": "Date", + "componentType": "datetime", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "varchar(50)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "联系方式", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "contact_info", + "field": "contactInfo", + "desc": "联系方式", + "fieldCase": "ContactInfo", + "originField": "contact_info", + "tbName": "contact_info", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "SN_ID", + "columnKey": "UNI", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "sn", + "field": "sn", + "desc": "SN_ID", + "fieldCase": "", + "originField": "sn", + "tbName": "sn", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "int(4)", + "isNullable": "YES", + "dataType": "int", + "extra": "", + "columnComment": "设备类型;0:T-BOX,1:VCI", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "equip_type", + "field": "equipType", + "desc": "设备类型", + "fieldCase": "EquipType", + "originField": "equip_type", + "tbName": "equip_type", + "type": "Integer", + "componentType": "select", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "0:T-BOX,1:VCI", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [ + { + "value": "0:T-BOX" + }, + { + "value": "1:VCI" + } + ] + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "换件_ID", + "columnKey": "MUL", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "replacement_id", + "field": "replacementId", + "desc": "换件_ID", + "fieldCase": "ReplacementId", + "originField": "replacement_id", + "tbName": "replacement_id", + "type": "String", + "componentType": "", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "int(11)", + "isNullable": "YES", + "dataType": "int", + "extra": "", + "columnComment": "深度;(换件次数)", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_replacement", + "columnName": "depth", + "field": "depth", + "desc": "深度", + "fieldCase": "", + "originField": "depth", + "tbName": "depth", + "type": "Integer", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "新SN_ID", + "columnKey": "MUL", + "tableSchema": "micro-service-plus", + "tableName": "tb_replacement", + "columnName": "new_sn_id", + "field": "newSnId", + "desc": "新SN_ID", + "fieldCase": "NewSnId", + "originField": "new_sn_id", + "tbName": "new_sn_id", + "type": "String", + "componentType": "", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + } + ], + "formConfig": [ + { + "columnType": "int(4)", + "isNullable": "YES", + "dataType": "int", + "extra": "", + "columnComment": "目前状态;0:报废,1:在用,2:维修,3:更换,4:替换件", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "current_status", + "field": "currentStatus", + "desc": "目前状态", + "fieldCase": "CurrentStatus", + "originField": "current_status", + "tbName": "current_status", + "type": "Integer", + "componentType": "select", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "0:报废,1:在用,2:维修,3:更换,4:替换件", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [ + { + "value": "0:报废" + }, + { + "value": "1:在用" + }, + { + "value": "2:维修" + }, + { + "value": "3:更换" + }, + { + "value": "4:替换件" + } + ] + }, + { + "columnType": "varchar(50)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "提出人", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "proposer", + "field": "proposer", + "desc": "提出人", + "fieldCase": "", + "originField": "proposer", + "tbName": "proposer", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "datetime", + "isNullable": "YES", + "dataType": "datetime", + "extra": "", + "columnComment": "回收日期", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "recovery_date", + "field": "recoveryDate", + "desc": "回收日期", + "fieldCase": "RecoveryDate", + "originField": "recovery_date", + "tbName": "recovery_date", + "type": "Date", + "componentType": "datetime", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "varchar(50)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "联系方式", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "contact_info", + "field": "contactInfo", + "desc": "联系方式", + "fieldCase": "ContactInfo", + "originField": "contact_info", + "tbName": "contact_info", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "SN_ID", + "columnKey": "UNI", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "sn", + "field": "sn", + "desc": "SN_ID", + "fieldCase": "", + "originField": "sn", + "tbName": "sn", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "换件_ID", + "columnKey": "MUL", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "replacement_id", + "field": "replacementId", + "desc": "换件_ID", + "fieldCase": "ReplacementId", + "originField": "replacement_id", + "tbName": "replacement_id", + "type": "String", + "componentType": "", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "int(11)", + "isNullable": "YES", + "dataType": "int", + "extra": "", + "columnComment": "深度;(换件次数)", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_replacement", + "columnName": "depth", + "field": "depth", + "desc": "深度", + "fieldCase": "", + "originField": "depth", + "tbName": "depth", + "type": "Integer", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "新SN_ID", + "columnKey": "MUL", + "tableSchema": "micro-service-plus", + "tableName": "tb_replacement", + "columnName": "new_sn_id", + "field": "newSnId", + "desc": "新SN_ID", + "fieldCase": "NewSnId", + "originField": "new_sn_id", + "tbName": "new_sn_id", + "type": "String", + "componentType": "", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "int(4)", + "isNullable": "YES", + "dataType": "int", + "extra": "", + "columnComment": "设备类型;0:T-BOX,1:VCI", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "equip_type", + "field": "equipType", + "desc": "设备类型", + "fieldCase": "EquipType", + "originField": "equip_type", + "tbName": "equip_type", + "type": "Integer", + "componentType": "select", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "0:T-BOX,1:VCI", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [ + { + "value": "0:T-BOX" + }, + { + "value": "1:VCI" + } + ] + } + ] +} \ No newline at end of file diff --git a/velocity-tmp-dir/json-data/tb_brand.json b/velocity-tmp-dir/json-data/tb_brand.json new file mode 100644 index 0000000..fbff052 --- /dev/null +++ b/velocity-tmp-dir/json-data/tb_brand.json @@ -0,0 +1,877 @@ +{ + "projectOrAuthor": { + "author": "熊猫哥", + "packageName": "top.kuanghua.integrationfront", + "serviceName": "integration-front", + "dataTime": "2022-06-22 10:02:51", + "modalTitle": "我是modal的title", + "isMultiTable": false + }, + "commonConfig": { + "upFileApi": "/ty-example/upload/file", + "isAdd": "true", + "isDelete": "true", + "isMulDelete": "true", + "isEdit": "true", + "isPagination": "true", + "isDetail": "true", + "isTableMulChoose": "true" + }, + "multiTableConfig": [ + { + "tableName": "brand", + "originTableName": "tb_brand", + "tableDesc": "品牌表", + "tableNameCase": "Brand", + "uniKey": "id", + "tableFieldArr": [ + { + "columnType": "int(11)", + "isNullable": "NO", + "dataType": "int", + "extra": "auto_increment", + "columnComment": "id", + "columnKey": "PRI", + "tableSchema": "micro-service-plus", + "tableName": "tb_brand", + "columnName": "id", + "field": "id", + "fieldCase": "Id", + "originField": "id", + "tbName": "id", + "type": "Integer", + "componentType": "", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "desc": "id", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "varchar(100)", + "isNullable": "NO", + "dataType": "varchar", + "extra": "", + "columnComment": "品牌名称", + "columnKey": "PRI", + "tableSchema": "micro-service-plus", + "tableName": "tb_brand", + "columnName": "name", + "field": "name", + "fieldCase": "Name", + "originField": "name", + "tbName": "name", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "desc": "品牌名称", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "varchar(1000)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "品牌图片地址", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_brand", + "columnName": "image", + "field": "image", + "fieldCase": "Image", + "originField": "image", + "tbName": "image", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "desc": "品牌图片地址", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "char(1)", + "isNullable": "YES", + "dataType": "char", + "extra": "", + "columnComment": "品牌的首字母", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_brand", + "columnName": "letter", + "field": "letter", + "fieldCase": "Letter", + "originField": "letter", + "tbName": "letter", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "desc": "品牌的首字母", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "int(11)", + "isNullable": "YES", + "dataType": "int", + "extra": "", + "columnComment": "排序", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_brand", + "columnName": "seq", + "field": "seq", + "fieldCase": "Seq", + "originField": "seq", + "tbName": "seq", + "type": "Integer", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "desc": "排序", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "datetime", + "isNullable": "YES", + "dataType": "datetime", + "extra": "on update CURRENT_TIMESTAMP", + "columnComment": "创建时间", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_brand", + "columnName": "create_time", + "field": "createTime", + "fieldCase": "Createtime", + "originField": "create_time", + "tbName": "create_time", + "type": "Long" + }, + { + "columnType": "datetime", + "isNullable": "YES", + "dataType": "datetime", + "extra": "on update CURRENT_TIMESTAMP", + "columnComment": "更新时间", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_brand", + "columnName": "update_time", + "field": "updateTime", + "fieldCase": "Updatetime", + "originField": "update_time", + "tbName": "update_time", + "type": "Long" + } + ], + "orgUniKey": "id", + "uniKeyType": "Integer", + "priKeyArr": [ + "id", + "name" + ], + "priKeyItemArr": [ + { + "columnType": "int(11)", + "isNullable": "NO", + "dataType": "int", + "extra": "auto_increment", + "columnComment": "id", + "columnKey": "PRI", + "tableSchema": "micro-service-plus", + "tableName": "tb_brand", + "columnName": "id", + "field": "id", + "fieldCase": "Id", + "originField": "id", + "tbName": "id", + "type": "Integer", + "componentType": "", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "desc": "id", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "varchar(100)", + "isNullable": "NO", + "dataType": "varchar", + "extra": "", + "columnComment": "品牌名称", + "columnKey": "PRI", + "tableSchema": "micro-service-plus", + "tableName": "tb_brand", + "columnName": "name", + "field": "name", + "fieldCase": "Name", + "originField": "name", + "tbName": "name", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "desc": "品牌名称", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + } + ], + "orgAssociationKey": "name", + "associationKey": "name", + "associationKeyType": "String", + "tableQueryArr": [ + { + "columnType": "varchar(100)", + "isNullable": "NO", + "dataType": "varchar", + "extra": "", + "columnComment": "品牌名称", + "columnKey": "PRI", + "tableSchema": "micro-service-plus", + "tableName": "tb_brand", + "columnName": "name", + "field": "name", + "fieldCase": "Name", + "originField": "name", + "tbName": "name", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "desc": "品牌名称", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + } + ], + "tableShowArr": [ + { + "columnType": "varchar(100)", + "isNullable": "NO", + "dataType": "varchar", + "extra": "", + "columnComment": "品牌名称", + "columnKey": "PRI", + "tableSchema": "micro-service-plus", + "tableName": "tb_brand", + "columnName": "name", + "field": "name", + "fieldCase": "Name", + "originField": "name", + "tbName": "name", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "desc": "品牌名称", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + } + ], + "tableFormArr": [ + { + "columnType": "varchar(100)", + "isNullable": "NO", + "dataType": "varchar", + "extra": "", + "columnComment": "品牌名称", + "columnKey": "PRI", + "tableSchema": "micro-service-plus", + "tableName": "tb_brand", + "columnName": "name", + "field": "name", + "fieldCase": "Name", + "originField": "name", + "tbName": "name", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "desc": "品牌名称", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + } + ] + } + ], + "dbTableConfig": { + "tableName": "brand", + "originTableName": "tb_brand", + "tableDesc": "品牌表", + "tableNameCase": "Brand", + "uniKey": "id", + "orgUniKey": "id", + "uniKeyType": "Integer", + "orgAssociationKey": "name", + "multiTableName": "rand", + "multiTableNameCase": "Rand", + "multiTableDesc": "多表中实体类的注释", + "associationKey": "name", + "associationKeyCase": "Name", + "associationKeyType": "String", + "tableFieldArr": [ + { + "columnType": "int(11)", + "isNullable": "NO", + "dataType": "int", + "extra": "auto_increment", + "columnComment": "id", + "columnKey": "PRI", + "tableSchema": "micro-service-plus", + "tableName": "tb_brand", + "columnName": "id", + "field": "id", + "fieldCase": "Id", + "originField": "id", + "tbName": "id", + "type": "Integer", + "componentType": "", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "desc": "id", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "varchar(100)", + "isNullable": "NO", + "dataType": "varchar", + "extra": "", + "columnComment": "品牌名称", + "columnKey": "PRI", + "tableSchema": "micro-service-plus", + "tableName": "tb_brand", + "columnName": "name", + "field": "name", + "fieldCase": "Name", + "originField": "name", + "tbName": "name", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "desc": "品牌名称", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "varchar(1000)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "品牌图片地址", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_brand", + "columnName": "image", + "field": "image", + "fieldCase": "Image", + "originField": "image", + "tbName": "image", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "desc": "品牌图片地址", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "char(1)", + "isNullable": "YES", + "dataType": "char", + "extra": "", + "columnComment": "品牌的首字母", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_brand", + "columnName": "letter", + "field": "letter", + "fieldCase": "Letter", + "originField": "letter", + "tbName": "letter", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "desc": "品牌的首字母", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "int(11)", + "isNullable": "YES", + "dataType": "int", + "extra": "", + "columnComment": "排序", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_brand", + "columnName": "seq", + "field": "seq", + "fieldCase": "Seq", + "originField": "seq", + "tbName": "seq", + "type": "Integer", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "desc": "排序", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "datetime", + "desc": "创建时间", + "isNullable": "YES", + "dataType": "datetime", + "extra": "on update CURRENT_TIMESTAMP", + "columnComment": "创建时间", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_brand", + "columnName": "create_time", + "field": "createTime", + "fieldCase": "Createtime", + "originField": "create_time", + "tbName": "create_time", + "type": "Date" + }, + { + "columnType": "datetime", + "desc": "更新时间", + "isNullable": "YES", + "dataType": "datetime", + "extra": "on update CURRENT_TIMESTAMP", + "columnComment": "更新时间", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_brand", + "columnName": "update_time", + "field": "updateTime", + "fieldCase": "Updatetime", + "originField": "update_time", + "tbName": "update_time", + "type": "Date" + } + ] + }, + "apiConfig": { + "queryApi": "/integration-front/brand/selectPage", + "queryApiType": "get", + "insertApi": "/insert", + "insertApiType": "post", + "updateApi": "/integration-front/brand/updateById", + "updateApiType": "update", + "deleteApi": "/integration-front/brand/deleteById", + "deleteApiType": "delete", + "deleteMultiApi": "/integration-front/brand/deleteBatchIds", + "deleteMultiApiType": "delete", + "detailApi": "/integration-front/brand/selectById", + "detailApiType": "get" + }, + "queryConfig": [ + { + "columnType": "varchar(100)", + "isNullable": "NO", + "dataType": "varchar", + "extra": "", + "columnComment": "品牌名称", + "columnKey": "PRI", + "tableSchema": "micro-service-plus", + "tableName": "tb_brand", + "columnName": "name", + "field": "name", + "fieldCase": "Name", + "originField": "name", + "tbName": "name", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "desc": "品牌名称", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + } + ], + "tableConfig": [ + { + "columnType": "varchar(100)", + "isNullable": "NO", + "dataType": "varchar", + "extra": "", + "columnComment": "品牌名称", + "columnKey": "PRI", + "tableSchema": "micro-service-plus", + "tableName": "tb_brand", + "columnName": "name", + "field": "name", + "fieldCase": "Name", + "originField": "name", + "tbName": "name", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "desc": "品牌名称", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "varchar(1000)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "品牌图片地址", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_brand", + "columnName": "image", + "field": "image", + "fieldCase": "Image", + "originField": "image", + "tbName": "image", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "desc": "品牌图片地址", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "char(1)", + "isNullable": "YES", + "dataType": "char", + "extra": "", + "columnComment": "品牌的首字母", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_brand", + "columnName": "letter", + "field": "letter", + "fieldCase": "Letter", + "originField": "letter", + "tbName": "letter", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "desc": "品牌的首字母", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "int(11)", + "isNullable": "YES", + "dataType": "int", + "extra": "", + "columnComment": "排序", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_brand", + "columnName": "seq", + "field": "seq", + "fieldCase": "Seq", + "originField": "seq", + "tbName": "seq", + "type": "Integer", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "desc": "排序", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + } + ], + "formConfig": [ + { + "columnType": "int(11)", + "isNullable": "NO", + "dataType": "int", + "extra": "auto_increment", + "columnComment": "id", + "columnKey": "PRI", + "tableSchema": "micro-service-plus", + "tableName": "tb_brand", + "columnName": "id", + "field": "id", + "fieldCase": "Id", + "originField": "id", + "tbName": "id", + "type": "Integer", + "componentType": "", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "desc": "id", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "varchar(100)", + "isNullable": "NO", + "dataType": "varchar", + "extra": "", + "columnComment": "品牌名称", + "columnKey": "PRI", + "tableSchema": "micro-service-plus", + "tableName": "tb_brand", + "columnName": "name", + "field": "name", + "fieldCase": "Name", + "originField": "name", + "tbName": "name", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "desc": "品牌名称", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "varchar(1000)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "品牌图片地址", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_brand", + "columnName": "image", + "field": "image", + "fieldCase": "Image", + "originField": "image", + "tbName": "image", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "desc": "品牌图片地址", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "char(1)", + "isNullable": "YES", + "dataType": "char", + "extra": "", + "columnComment": "品牌的首字母", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_brand", + "columnName": "letter", + "field": "letter", + "fieldCase": "Letter", + "originField": "letter", + "tbName": "letter", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "desc": "品牌的首字母", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "int(11)", + "isNullable": "YES", + "dataType": "int", + "extra": "", + "columnComment": "排序", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_brand", + "columnName": "seq", + "field": "seq", + "fieldCase": "Seq", + "originField": "seq", + "tbName": "seq", + "type": "Integer", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "desc": "排序", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + } + ] +} \ No newline at end of file