From 4c008c7f57f745813942a495b092e2038851707d Mon Sep 17 00:00:00 2001 From: WendyYang Date: Mon, 22 Apr 2024 15:24:32 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E5=90=8D=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kq-api/pom.xml | 237 ++++++ kq-api/src/main/java/com/ningdatech/kqapi/App.java | 41 + .../kqapi/admin/controller/MatterController.java | 59 ++ .../kqapi/admin/controller/WindowController.java | 63 ++ .../kqapi/admin/controller/ZoneController.java | 63 ++ .../kqapi/admin/manage/AdminMatterManage.java | 121 +++ .../kqapi/admin/manage/WindowManage.java | 83 ++ .../ningdatech/kqapi/admin/manage/ZoneManage.java | 102 +++ .../kqapi/admin/mapper/WindowMapper.java | 23 + .../ningdatech/kqapi/admin/mapper/WindowMapper.xml | 13 + .../ningdatech/kqapi/admin/mapper/ZoneMapper.java | 16 + .../ningdatech/kqapi/admin/mapper/ZoneMapper.xml | 5 + .../admin/model/dto/MatterCountByWindowIdDTO.java | 20 + .../admin/model/dto/WindowCountByZoneIdDTO.java | 20 + .../kqapi/admin/model/entity/Window.java | 54 ++ .../ningdatech/kqapi/admin/model/entity/Zone.java | 52 ++ .../model/enumerization/HandleChannelEnum.java | 30 + .../kqapi/admin/model/req/ListWindowReq.java | 26 + .../kqapi/admin/model/req/ListZoneReq.java | 23 + .../kqapi/admin/model/req/MatterListReq.java | 35 + .../kqapi/admin/model/req/WindowSaveReq.java | 35 + .../kqapi/admin/model/req/ZoneSaveReq.java | 30 + .../kqapi/admin/model/vo/MatterDetailDTO.java | 95 +++ .../kqapi/admin/model/vo/MatterListVO.java | 34 + .../kqapi/admin/model/vo/WindowDetailVO.java | 34 + .../kqapi/admin/model/vo/ZoneDetailVO.java | 31 + .../kqapi/admin/service/IWindowService.java | 21 + .../kqapi/admin/service/IZoneService.java | 16 + .../admin/service/impl/WindowServiceImpl.java | 38 + .../kqapi/admin/service/impl/ZoneServiceImpl.java | 20 + .../ningdatech/kqapi/common/compare/Compare.java | 22 + .../kqapi/common/compare/CompareNode.java | 47 ++ .../kqapi/common/compare/CompareUtils.java | 182 +++++ .../ningdatech/kqapi/common/config/BeanConfig.java | 188 +++++ .../kqapi/common/config/ConfigurerAdapter.java | 37 + .../common/config/DingOrganizationProperties.java | 19 + .../kqapi/common/config/ProvincialProperties.java | 26 + .../kqapi/common/constant/BaseFieldConst.java | 18 + .../ningdatech/kqapi/common/constant/BizConst.java | 37 + .../kqapi/common/constant/CommonConst.java | 69 ++ .../kqapi/common/constant/DefValConst.java | 34 + .../kqapi/common/constant/DingConst.java | 14 + .../kqapi/common/constant/ProjectDeclareConst.java | 172 ++++ .../kqapi/common/constant/RegionConst.java | 50 ++ .../kqapi/common/constant/StateMachineConst.java | 14 + .../kqapi/common/converter/BaseDateConverter.java | 42 + .../converter/NdLocalDateTimeDeserializer.java | 185 +++++ .../common/converter/String2DateConverter.java | 77 ++ .../converter/String2LocalDateConverter.java | 40 + .../converter/String2LocalDateTimeConverter.java | 38 + .../converter/String2LocalTimeConverter.java | 36 + .../kqapi/common/enumeration/BoolDisplayEnum.java | 32 + .../kqapi/common/enumeration/CommonEnum.java | 39 + .../kqapi/common/enumeration/ExportOptionEnum.java | 157 ++++ .../ningdatech/kqapi/common/enumeration/IEnum.java | 42 + .../common/enumeration/ImplSubjectNatureEnum.java | 30 + .../enumeration/ProjectProcessStageEnum.java | 39 + .../kqapi/common/errorcode/AppErrorCode.java | 24 + .../kqapi/common/exception/ArgumentException.java | 38 + .../common/exception/BaseCheckedException.java | 57 ++ .../kqapi/common/exception/BaseException.java | 30 + .../common/exception/BaseUncheckedException.java | 65 ++ .../kqapi/common/exception/BizException.java | 78 ++ .../kqapi/common/exception/CommonException.java | 30 + .../kqapi/common/exception/DownloadException.java | 27 + .../kqapi/common/exception/ExportException.java | 28 + .../kqapi/common/exception/ForbiddenException.java | 33 + .../common/exception/UnauthorizedException.java | 33 + .../common/exception/code/BaseExceptionCode.java | 23 + .../kqapi/common/exception/code/ExceptionCode.java | 103 +++ .../kqapi/common/handler/BaseFieldFillHandler.java | 49 ++ .../common/handler/GlobalExceptionHandler.java | 70 ++ .../common/handler/GlobalResponseHandler.java | 59 ++ .../kqapi/common/handler/MyBatisPlusConfig.java | 29 + .../kqapi/common/helper/MatterCacheHelper.java | 25 + .../helper/basic/AbstractMatterCacheHelper.java | 188 +++++ .../common/helper/impl/MattersCacheHelperImpl.java | 46 ++ .../ningdatech/kqapi/common/model/ApiResponse.java | 123 +++ .../ningdatech/kqapi/common/model/ApiStatus.java | 26 + .../com/ningdatech/kqapi/common/model/PagePo.java | 30 + .../com/ningdatech/kqapi/common/model/PageVo.java | 63 ++ .../com/ningdatech/kqapi/common/model/Status.java | 123 +++ .../ningdatech/kqapi/common/model/entity/Item.java | 30 + .../com/ningdatech/kqapi/common/util/BizUtils.java | 133 +++ .../com/ningdatech/kqapi/common/util/CallBack.java | 25 + .../com/ningdatech/kqapi/common/util/CodeUtil.java | 27 + .../common/util/CommonInputStreamResource.java | 53 ++ .../ningdatech/kqapi/common/util/CryptUtils.java | 85 ++ .../com/ningdatech/kqapi/common/util/HttpUtil.java | 218 +++++ .../com/ningdatech/kqapi/common/util/Md5Utils.java | 52 ++ .../ningdatech/kqapi/common/util/NdDateUtils.java | 898 +++++++++++++++++++++ .../kqapi/common/util/NdJacksonModule.java | 35 + .../kqapi/common/util/RefreshKeyUtil.java | 59 ++ .../kqapi/common/util/SpringContextHolder.java | 150 ++++ .../com/ningdatech/kqapi/common/util/StrPool.java | 148 ++++ .../kqapi/open/controller/HealthController.java | 40 + .../kqapi/scheduler/contants/TaskContant.java | 14 + .../kqapi/scheduler/controller/TaskController.java | 88 ++ .../kqapi/scheduler/manage/SynManage.java | 88 ++ .../kqapi/scheduler/model/CommonLog.java | 43 + .../kqapi/scheduler/task/CheckMattersUrlTask.java | 162 ++++ .../kqapi/scheduler/task/RemoveMattersTask.java | 63 ++ .../ningdatech/kqapi/scheduler/task/SynTask.java | 205 +++++ .../ningdatech/kqapi/scheduler/utils/DateUtil.java | 37 + .../ningdatech/kqapi/security/AuthBeanConfig.java | 31 + .../ningdatech/kqapi/security/AuthProperties.java | 56 ++ .../kqapi/security/WebSecurityConfig.java | 91 +++ .../kqapi/security/config/RedisSessionConfig.java | 54 ++ .../kqapi/security/constant/AuthConst.java | 29 + .../kqapi/security/constant/AuthTypeEnum.java | 49 ++ .../kqapi/security/constant/LoginPlatformEnum.java | 28 + .../kqapi/security/facade/UserAuthLoginFacade.java | 58 ++ .../handler/DefaultExpiredSessionStrategy.java | 38 + .../handler/DefaultInvalidSessionStrategy.java | 35 + .../handler/DefaultLoginFailureHandler.java | 53 ++ .../handler/DefaultLoginSuccessHandler.java | 42 + .../handler/DefaultLogoutSuccessHandler.java | 35 + .../kqapi/security/listener/AuthEventListener.java | 82 ++ .../kqapi/security/model/UserInfoDetails.java | 69 ++ .../kqapi/security/model/WebRequestDetails.java | 55 ++ .../security/model/dto/LoginDeviceInfoDTO.java | 20 + .../kqapi/security/model/dto/UserInfoBO.java | 31 + .../security/password/PasswordAuthProvider.java | 42 + .../password/PasswordAuthSecurityConfig.java | 51 ++ .../password/PasswordLoginUserDetailService.java | 45 ++ .../password/UsernamePasswordAuthFilter.java | 57 ++ .../password/UsernamePasswordAuthToken.java | 85 ++ .../kqapi/sso/controller/SsoController.java | 36 + .../com/ningdatech/kqapi/sso/manage/SsoManage.java | 88 ++ .../ningdatech/kqapi/sso/model/dto/ReqSsoDTO.java | 25 + .../ningdatech/kqapi/sso/model/vo/SsoTokenVO.java | 29 + .../kqapi/sso/model/vo/SsoUserInfoVO.java | 154 ++++ .../ningdatech/kqapi/sso/utils/HmacAuthUtil.java | 132 +++ .../kqapi/user/controller/UserAuthController.java | 77 ++ .../kqapi/user/controller/UserInfoController.java | 100 +++ .../ningdatech/kqapi/user/helper/LoginHelper.java | 33 + .../kqapi/user/helper/UserInfoHelper.java | 23 + .../kqapi/user/manage/UserInfoManage.java | 242 ++++++ .../kqapi/user/mapper/UserAuthMapper.java | 16 + .../kqapi/user/mapper/UserAuthMapper.xml | 5 + .../kqapi/user/mapper/UserInfoMapper.java | 16 + .../kqapi/user/mapper/UserInfoMapper.xml | 5 + .../kqapi/user/model/entity/UserAuth.java | 42 + .../kqapi/user/model/entity/UserInfo.java | 69 ++ .../user/model/enumerization/AccountStatus.java | 20 + .../user/model/po/ChangeAccountStatusReq.java | 28 + .../kqapi/user/model/po/ModifyPasswordReq.java | 31 + .../kqapi/user/model/po/SaveUserReq.java | 49 ++ .../kqapi/user/model/po/UserListReq.java | 29 + .../kqapi/user/model/vo/LoginUserDetailVO.java | 28 + .../kqapi/user/model/vo/UserDetailVO.java | 44 + .../ningdatech/kqapi/user/model/vo/UserListVO.java | 38 + .../kqapi/user/service/IUserAuthService.java | 28 + .../kqapi/user/service/IUserInfoService.java | 39 + .../user/service/impl/UserAuthServiceImpl.java | 33 + .../user/service/impl/UserInfoServiceImpl.java | 22 + .../com/ningdatech/kqapi/user/util/BizUtils.java | 81 ++ .../kqapi/user/util/LoginUserContext.java | 36 + .../ningdatech/kqapi/user/util/LoginUserUtil.java | 25 + .../kqapi/zzsfw/constants/ZzsfwMenuConstant.java | 20 + ...SxAdsShareItemQltQlsxCommonIDVKqController.java | 37 + .../zzsfw/controller/KqZzsfwMenuController.java | 118 +++ .../controller/PolicyRegulationsController.java | 49 ++ .../kqapi/zzsfw/enumeration/ItemTypeEnum.java | 34 + .../kqapi/zzsfw/manage/MatterManage.java | 405 ++++++++++ .../kqapi/zzsfw/manage/PolicyManage.java | 84 ++ .../ningdatech/kqapi/zzsfw/manage/QlManage.java | 35 + .../mapper/ComponentsMatterEliminateMapper.java | 11 + .../mapper/ComponentsMatterEliminateMapper.xml | 5 + .../DscSxAdsShareItemQltQlsxCommonIDVKqMapper.java | 16 + .../DscSxAdsShareItemQltQlsxCommonIDVKqMapper.xml | 5 + .../mapper/KqZzsfwMatterDeduplicateMapper.java | 16 + .../kqapi/zzsfw/mapper/KqZzsfwMenuMapper.java | 23 + .../kqapi/zzsfw/mapper/KqZzsfwMenuMapper.xml | 15 + .../kqapi/zzsfw/mapper/KqZzsfwPolicyMapper.java | 16 + .../DscSxAdsShareItemQltQlsxCommonIDVKqDTO.java | 417 ++++++++++ .../model/dto/KqZzsfwMattersDeduplicateDTO.java | 35 + .../kqapi/zzsfw/model/dto/KqZzsfwMenuDTO.java | 50 ++ .../kqapi/zzsfw/model/dto/KqZzsfwPolicyDTO.java | 56 ++ .../entity/ComponentsMatterEliminateEntity.java | 43 + .../DscSxAdsShareItemQltQlsxCommonIDVKq.java | 422 ++++++++++ .../model/entity/KqZzsfwMattersDeduplicate.java | 51 ++ .../kqapi/zzsfw/model/entity/KqZzsfwMenu.java | 121 +++ .../kqapi/zzsfw/model/entity/KqZzsfwPolicy.java | 64 ++ .../kqapi/zzsfw/model/entity/MatterKey.java | 24 + .../kqapi/zzsfw/model/vo/MatterTopVO.java | 31 + .../ningdatech/kqapi/zzsfw/model/vo/MattersVO.java | 49 ++ .../ningdatech/kqapi/zzsfw/model/vo/TreeVO.java | 56 ++ .../ningdatech/kqapi/zzsfw/model/vo/WindowVO.java | 29 + .../ningdatech/kqapi/zzsfw/model/vo/ZoneVO.java | 29 + .../kqapi/zzsfw/model/vo/ZzsfwPolicyVO.java | 59 ++ .../service/ComponentsMatterEliminateService.java | 8 + ...DscSxAdsShareItemQltQlsxCommonIDVKqService.java | 16 + .../service/IKqZzsfwMatterDeduplicateService.java | 16 + .../kqapi/zzsfw/service/IKqZzsfwMenuService.java | 21 + .../kqapi/zzsfw/service/IKqZzsfwPolicyService.java | 16 + .../impl/ComponentsMatterEliminateServiceImpl.java | 16 + ...xAdsShareItemQltQlsxCommonIDVKqServiceImpl.java | 20 + .../impl/KqZzsfwMatterDeduplicateServiceImpl.java | 21 + .../zzsfw/service/impl/KqZzsfwMenuServiceImpl.java | 38 + .../service/impl/KqZzsfwPolicyServiceImpl.java | 21 + kq-api/src/main/resources/application-dev.yml | 142 ++++ kq-api/src/main/resources/application-pre.yml | 138 ++++ kq-api/src/main/resources/application-prod.yml | 142 ++++ kq-api/src/main/resources/application.yml | 3 + kq-api/src/main/resources/logback-spring.xml | 68 ++ kq-api/src/main/resources/security/auth-dev.yml | 38 + kq-api/src/main/resources/security/auth-prod.yml | 39 + .../test/java/com/ningdatech/kqapi/AppTests.java | 19 + .../com/ningdatech/kqapi/menu/DuplicationTest.java | 100 +++ .../kqapi/menu/ExcelSplitMergedCells.java | 60 ++ .../java/com/ningdatech/kqapi/menu/MenuTest.java | 187 +++++ .../java/com/ningdatech/kqapi/menu/PolicyTest.java | 85 ++ kq-api/src/test/resources/application-dev.yml | 123 +++ kq-api/src/test/resources/application-pre.yml | 121 +++ kq-api/src/test/resources/application-prod.yml | 123 +++ kq-api/src/test/resources/application.yml | 3 + kq-api/src/test/resources/integration/zwdd-dev.yml | 12 + .../src/test/resources/integration/zwdd-prod.yml | 12 + kq-api/src/test/resources/logback-spring.xml | 68 ++ kq-api/src/test/resources/security/auth-dev.yml | 68 ++ kq-api/src/test/resources/security/auth-prod.yml | 68 ++ kq-api/src/test/resources/wsdl-prod.xml | 120 +++ kq-api/src/test/resources/wsdl.xml | 120 +++ kq-gen/pom.xml | 60 ++ .../com/ningdatech/generator/config/CodeGen.java | 64 ++ kqapi/pom.xml | 237 ------ kqapi/src/main/java/com/ningdatech/kqapi/App.java | 41 - .../kqapi/admin/controller/MatterController.java | 59 -- .../kqapi/admin/controller/WindowController.java | 63 -- .../kqapi/admin/controller/ZoneController.java | 63 -- .../kqapi/admin/manage/AdminMatterManage.java | 121 --- .../kqapi/admin/manage/WindowManage.java | 83 -- .../ningdatech/kqapi/admin/manage/ZoneManage.java | 102 --- .../kqapi/admin/mapper/WindowMapper.java | 23 - .../ningdatech/kqapi/admin/mapper/WindowMapper.xml | 13 - .../ningdatech/kqapi/admin/mapper/ZoneMapper.java | 16 - .../ningdatech/kqapi/admin/mapper/ZoneMapper.xml | 5 - .../admin/model/dto/MatterCountByWindowIdDTO.java | 20 - .../admin/model/dto/WindowCountByZoneIdDTO.java | 20 - .../kqapi/admin/model/entity/Window.java | 54 -- .../ningdatech/kqapi/admin/model/entity/Zone.java | 52 -- .../model/enumerization/HandleChannelEnum.java | 30 - .../kqapi/admin/model/req/ListWindowReq.java | 26 - .../kqapi/admin/model/req/ListZoneReq.java | 23 - .../kqapi/admin/model/req/MatterListReq.java | 35 - .../kqapi/admin/model/req/WindowSaveReq.java | 35 - .../kqapi/admin/model/req/ZoneSaveReq.java | 30 - .../kqapi/admin/model/vo/MatterDetailDTO.java | 95 --- .../kqapi/admin/model/vo/MatterListVO.java | 34 - .../kqapi/admin/model/vo/WindowDetailVO.java | 34 - .../kqapi/admin/model/vo/ZoneDetailVO.java | 31 - .../kqapi/admin/service/IWindowService.java | 21 - .../kqapi/admin/service/IZoneService.java | 16 - .../admin/service/impl/WindowServiceImpl.java | 38 - .../kqapi/admin/service/impl/ZoneServiceImpl.java | 20 - .../ningdatech/kqapi/common/compare/Compare.java | 22 - .../kqapi/common/compare/CompareNode.java | 47 -- .../kqapi/common/compare/CompareUtils.java | 182 ----- .../ningdatech/kqapi/common/config/BeanConfig.java | 188 ----- .../kqapi/common/config/ConfigurerAdapter.java | 37 - .../common/config/DingOrganizationProperties.java | 19 - .../kqapi/common/config/ProvincialProperties.java | 26 - .../kqapi/common/constant/BaseFieldConst.java | 18 - .../ningdatech/kqapi/common/constant/BizConst.java | 37 - .../kqapi/common/constant/CommonConst.java | 69 -- .../kqapi/common/constant/DefValConst.java | 34 - .../kqapi/common/constant/DingConst.java | 14 - .../kqapi/common/constant/ProjectDeclareConst.java | 172 ---- .../kqapi/common/constant/RegionConst.java | 50 -- .../kqapi/common/constant/StateMachineConst.java | 14 - .../kqapi/common/converter/BaseDateConverter.java | 42 - .../converter/NdLocalDateTimeDeserializer.java | 185 ----- .../common/converter/String2DateConverter.java | 77 -- .../converter/String2LocalDateConverter.java | 40 - .../converter/String2LocalDateTimeConverter.java | 38 - .../converter/String2LocalTimeConverter.java | 36 - .../kqapi/common/enumeration/BoolDisplayEnum.java | 32 - .../kqapi/common/enumeration/CommonEnum.java | 39 - .../kqapi/common/enumeration/ExportOptionEnum.java | 157 ---- .../ningdatech/kqapi/common/enumeration/IEnum.java | 42 - .../common/enumeration/ImplSubjectNatureEnum.java | 30 - .../enumeration/ProjectProcessStageEnum.java | 39 - .../kqapi/common/errorcode/AppErrorCode.java | 24 - .../kqapi/common/exception/ArgumentException.java | 38 - .../common/exception/BaseCheckedException.java | 57 -- .../kqapi/common/exception/BaseException.java | 30 - .../common/exception/BaseUncheckedException.java | 65 -- .../kqapi/common/exception/BizException.java | 78 -- .../kqapi/common/exception/CommonException.java | 30 - .../kqapi/common/exception/DownloadException.java | 27 - .../kqapi/common/exception/ExportException.java | 28 - .../kqapi/common/exception/ForbiddenException.java | 33 - .../common/exception/UnauthorizedException.java | 33 - .../common/exception/code/BaseExceptionCode.java | 23 - .../kqapi/common/exception/code/ExceptionCode.java | 103 --- .../kqapi/common/handler/BaseFieldFillHandler.java | 49 -- .../common/handler/GlobalExceptionHandler.java | 70 -- .../common/handler/GlobalResponseHandler.java | 59 -- .../kqapi/common/handler/MyBatisPlusConfig.java | 29 - .../kqapi/common/helper/MatterCacheHelper.java | 25 - .../helper/basic/AbstractMatterCacheHelper.java | 188 ----- .../common/helper/impl/MattersCacheHelperImpl.java | 46 -- .../ningdatech/kqapi/common/model/ApiResponse.java | 123 --- .../ningdatech/kqapi/common/model/ApiStatus.java | 26 - .../com/ningdatech/kqapi/common/model/PagePo.java | 30 - .../com/ningdatech/kqapi/common/model/PageVo.java | 63 -- .../com/ningdatech/kqapi/common/model/Status.java | 123 --- .../ningdatech/kqapi/common/model/entity/Item.java | 30 - .../com/ningdatech/kqapi/common/util/BizUtils.java | 133 --- .../com/ningdatech/kqapi/common/util/CallBack.java | 25 - .../com/ningdatech/kqapi/common/util/CodeUtil.java | 27 - .../common/util/CommonInputStreamResource.java | 53 -- .../ningdatech/kqapi/common/util/CryptUtils.java | 85 -- .../com/ningdatech/kqapi/common/util/HttpUtil.java | 218 ----- .../com/ningdatech/kqapi/common/util/Md5Utils.java | 52 -- .../ningdatech/kqapi/common/util/NdDateUtils.java | 898 --------------------- .../kqapi/common/util/NdJacksonModule.java | 35 - .../kqapi/common/util/RefreshKeyUtil.java | 59 -- .../kqapi/common/util/SpringContextHolder.java | 150 ---- .../com/ningdatech/kqapi/common/util/StrPool.java | 148 ---- .../kqapi/open/controller/HealthController.java | 40 - .../kqapi/scheduler/contants/TaskContant.java | 14 - .../kqapi/scheduler/controller/TaskController.java | 88 -- .../kqapi/scheduler/manage/SynManage.java | 88 -- .../kqapi/scheduler/model/CommonLog.java | 43 - .../kqapi/scheduler/task/CheckMattersUrlTask.java | 162 ---- .../kqapi/scheduler/task/RemoveMattersTask.java | 63 -- .../ningdatech/kqapi/scheduler/task/SynTask.java | 205 ----- .../ningdatech/kqapi/scheduler/utils/DateUtil.java | 37 - .../ningdatech/kqapi/security/AuthBeanConfig.java | 31 - .../ningdatech/kqapi/security/AuthProperties.java | 56 -- .../kqapi/security/WebSecurityConfig.java | 91 --- .../kqapi/security/config/RedisSessionConfig.java | 54 -- .../kqapi/security/constant/AuthConst.java | 29 - .../kqapi/security/constant/AuthTypeEnum.java | 49 -- .../kqapi/security/constant/LoginPlatformEnum.java | 28 - .../kqapi/security/facade/UserAuthLoginFacade.java | 58 -- .../handler/DefaultExpiredSessionStrategy.java | 38 - .../handler/DefaultInvalidSessionStrategy.java | 35 - .../handler/DefaultLoginFailureHandler.java | 53 -- .../handler/DefaultLoginSuccessHandler.java | 42 - .../handler/DefaultLogoutSuccessHandler.java | 35 - .../kqapi/security/listener/AuthEventListener.java | 82 -- .../kqapi/security/model/UserInfoDetails.java | 69 -- .../kqapi/security/model/WebRequestDetails.java | 55 -- .../security/model/dto/LoginDeviceInfoDTO.java | 20 - .../kqapi/security/model/dto/UserInfoBO.java | 31 - .../security/password/PasswordAuthProvider.java | 42 - .../password/PasswordAuthSecurityConfig.java | 51 -- .../password/PasswordLoginUserDetailService.java | 45 -- .../password/UsernamePasswordAuthFilter.java | 57 -- .../password/UsernamePasswordAuthToken.java | 85 -- .../kqapi/sso/controller/SsoController.java | 36 - .../com/ningdatech/kqapi/sso/manage/SsoManage.java | 88 -- .../ningdatech/kqapi/sso/model/dto/ReqSsoDTO.java | 25 - .../ningdatech/kqapi/sso/model/vo/SsoTokenVO.java | 29 - .../kqapi/sso/model/vo/SsoUserInfoVO.java | 154 ---- .../ningdatech/kqapi/sso/utils/HmacAuthUtil.java | 132 --- .../kqapi/user/controller/UserAuthController.java | 77 -- .../kqapi/user/controller/UserInfoController.java | 100 --- .../ningdatech/kqapi/user/helper/LoginHelper.java | 33 - .../kqapi/user/helper/UserInfoHelper.java | 23 - .../kqapi/user/manage/UserInfoManage.java | 245 ------ .../kqapi/user/mapper/UserAuthMapper.java | 16 - .../kqapi/user/mapper/UserAuthMapper.xml | 5 - .../kqapi/user/mapper/UserInfoMapper.java | 16 - .../kqapi/user/mapper/UserInfoMapper.xml | 5 - .../kqapi/user/model/entity/UserAuth.java | 42 - .../kqapi/user/model/entity/UserInfo.java | 69 -- .../user/model/enumerization/AccountStatus.java | 20 - .../user/model/po/ChangeAccountStatusReq.java | 28 - .../kqapi/user/model/po/ModifyPasswordReq.java | 31 - .../kqapi/user/model/po/SaveUserReq.java | 49 -- .../kqapi/user/model/po/UserListReq.java | 29 - .../kqapi/user/model/vo/LoginUserDetailVO.java | 28 - .../kqapi/user/model/vo/UserDetailVO.java | 44 - .../ningdatech/kqapi/user/model/vo/UserListVO.java | 38 - .../kqapi/user/service/IUserAuthService.java | 28 - .../kqapi/user/service/IUserInfoService.java | 39 - .../user/service/impl/UserAuthServiceImpl.java | 33 - .../user/service/impl/UserInfoServiceImpl.java | 22 - .../com/ningdatech/kqapi/user/util/BizUtils.java | 81 -- .../kqapi/user/util/LoginUserContext.java | 36 - .../ningdatech/kqapi/user/util/LoginUserUtil.java | 25 - .../kqapi/zzsfw/constants/ZzsfwMenuConstant.java | 20 - ...SxAdsShareItemQltQlsxCommonIDVKqController.java | 37 - .../zzsfw/controller/KqZzsfwMenuController.java | 118 --- .../controller/PolicyRegulationsController.java | 49 -- .../kqapi/zzsfw/enumeration/ItemTypeEnum.java | 34 - .../kqapi/zzsfw/manage/MatterManage.java | 405 ---------- .../kqapi/zzsfw/manage/PolicyManage.java | 84 -- .../ningdatech/kqapi/zzsfw/manage/QlManage.java | 35 - .../mapper/ComponentsMatterEliminateMapper.java | 11 - .../mapper/ComponentsMatterEliminateMapper.xml | 5 - .../DscSxAdsShareItemQltQlsxCommonIDVKqMapper.java | 16 - .../DscSxAdsShareItemQltQlsxCommonIDVKqMapper.xml | 5 - .../mapper/KqZzsfwMatterDeduplicateMapper.java | 16 - .../kqapi/zzsfw/mapper/KqZzsfwMenuMapper.java | 23 - .../kqapi/zzsfw/mapper/KqZzsfwMenuMapper.xml | 15 - .../kqapi/zzsfw/mapper/KqZzsfwPolicyMapper.java | 16 - .../DscSxAdsShareItemQltQlsxCommonIDVKqDTO.java | 417 ---------- .../model/dto/KqZzsfwMattersDeduplicateDTO.java | 35 - .../kqapi/zzsfw/model/dto/KqZzsfwMenuDTO.java | 50 -- .../kqapi/zzsfw/model/dto/KqZzsfwPolicyDTO.java | 56 -- .../entity/ComponentsMatterEliminateEntity.java | 43 - .../DscSxAdsShareItemQltQlsxCommonIDVKq.java | 422 ---------- .../model/entity/KqZzsfwMattersDeduplicate.java | 51 -- .../kqapi/zzsfw/model/entity/KqZzsfwMenu.java | 121 --- .../kqapi/zzsfw/model/entity/KqZzsfwPolicy.java | 64 -- .../kqapi/zzsfw/model/entity/MatterKey.java | 24 - .../kqapi/zzsfw/model/vo/MatterTopVO.java | 31 - .../ningdatech/kqapi/zzsfw/model/vo/MattersVO.java | 49 -- .../ningdatech/kqapi/zzsfw/model/vo/TreeVO.java | 56 -- .../ningdatech/kqapi/zzsfw/model/vo/WindowVO.java | 29 - .../ningdatech/kqapi/zzsfw/model/vo/ZoneVO.java | 29 - .../kqapi/zzsfw/model/vo/ZzsfwPolicyVO.java | 59 -- .../service/ComponentsMatterEliminateService.java | 8 - ...DscSxAdsShareItemQltQlsxCommonIDVKqService.java | 16 - .../service/IKqZzsfwMatterDeduplicateService.java | 16 - .../kqapi/zzsfw/service/IKqZzsfwMenuService.java | 21 - .../kqapi/zzsfw/service/IKqZzsfwPolicyService.java | 16 - .../impl/ComponentsMatterEliminateServiceImpl.java | 16 - ...xAdsShareItemQltQlsxCommonIDVKqServiceImpl.java | 20 - .../impl/KqZzsfwMatterDeduplicateServiceImpl.java | 21 - .../zzsfw/service/impl/KqZzsfwMenuServiceImpl.java | 38 - .../service/impl/KqZzsfwPolicyServiceImpl.java | 21 - kqapi/src/main/resources/application-dev.yml | 142 ---- kqapi/src/main/resources/application-pre.yml | 138 ---- kqapi/src/main/resources/application-prod.yml | 142 ---- kqapi/src/main/resources/application.yml | 3 - kqapi/src/main/resources/logback-spring.xml | 68 -- kqapi/src/main/resources/security/auth-dev.yml | 38 - kqapi/src/main/resources/security/auth-prod.yml | 39 - .../test/java/com/ningdatech/kqapi/AppTests.java | 19 - .../com/ningdatech/kqapi/menu/DuplicationTest.java | 100 --- .../kqapi/menu/ExcelSplitMergedCells.java | 60 -- .../java/com/ningdatech/kqapi/menu/MenuTest.java | 187 ----- .../java/com/ningdatech/kqapi/menu/PolicyTest.java | 85 -- kqapi/src/test/resources/application-dev.yml | 123 --- kqapi/src/test/resources/application-pre.yml | 121 --- kqapi/src/test/resources/application-prod.yml | 123 --- kqapi/src/test/resources/application.yml | 3 - kqapi/src/test/resources/integration/zwdd-dev.yml | 12 - kqapi/src/test/resources/integration/zwdd-prod.yml | 12 - kqapi/src/test/resources/logback-spring.xml | 68 -- kqapi/src/test/resources/security/auth-dev.yml | 68 -- kqapi/src/test/resources/security/auth-prod.yml | 68 -- kqapi/src/test/resources/wsdl-prod.xml | 120 --- kqapi/src/test/resources/wsdl.xml | 120 --- ningda-generator/pom.xml | 60 -- .../com/ningdatech/generator/config/CodeGen.java | 64 -- pom.xml | 4 +- 453 files changed, 14541 insertions(+), 14544 deletions(-) create mode 100644 kq-api/pom.xml create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/App.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/admin/controller/MatterController.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/admin/controller/WindowController.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/admin/controller/ZoneController.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/admin/manage/AdminMatterManage.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/admin/manage/WindowManage.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/admin/manage/ZoneManage.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/admin/mapper/WindowMapper.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/admin/mapper/WindowMapper.xml create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/admin/mapper/ZoneMapper.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/admin/mapper/ZoneMapper.xml create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/admin/model/dto/MatterCountByWindowIdDTO.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/admin/model/dto/WindowCountByZoneIdDTO.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/admin/model/entity/Window.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/admin/model/entity/Zone.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/admin/model/enumerization/HandleChannelEnum.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/admin/model/req/ListWindowReq.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/admin/model/req/ListZoneReq.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/admin/model/req/MatterListReq.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/admin/model/req/WindowSaveReq.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/admin/model/req/ZoneSaveReq.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/admin/model/vo/MatterDetailDTO.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/admin/model/vo/MatterListVO.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/admin/model/vo/WindowDetailVO.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/admin/model/vo/ZoneDetailVO.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/admin/service/IWindowService.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/admin/service/IZoneService.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/admin/service/impl/WindowServiceImpl.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/admin/service/impl/ZoneServiceImpl.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/common/compare/Compare.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/common/compare/CompareNode.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/common/compare/CompareUtils.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/common/config/BeanConfig.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/common/config/ConfigurerAdapter.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/common/config/DingOrganizationProperties.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/common/config/ProvincialProperties.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/common/constant/BaseFieldConst.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/common/constant/BizConst.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/common/constant/CommonConst.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/common/constant/DefValConst.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/common/constant/DingConst.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/common/constant/ProjectDeclareConst.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/common/constant/RegionConst.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/common/constant/StateMachineConst.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/common/converter/BaseDateConverter.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/common/converter/NdLocalDateTimeDeserializer.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/common/converter/String2DateConverter.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/common/converter/String2LocalDateConverter.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/common/converter/String2LocalDateTimeConverter.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/common/converter/String2LocalTimeConverter.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/common/enumeration/BoolDisplayEnum.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/common/enumeration/CommonEnum.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/common/enumeration/ExportOptionEnum.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/common/enumeration/IEnum.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/common/enumeration/ImplSubjectNatureEnum.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/common/enumeration/ProjectProcessStageEnum.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/common/errorcode/AppErrorCode.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/common/exception/ArgumentException.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/common/exception/BaseCheckedException.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/common/exception/BaseException.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/common/exception/BaseUncheckedException.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/common/exception/BizException.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/common/exception/CommonException.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/common/exception/DownloadException.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/common/exception/ExportException.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/common/exception/ForbiddenException.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/common/exception/UnauthorizedException.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/common/exception/code/BaseExceptionCode.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/common/exception/code/ExceptionCode.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/common/handler/BaseFieldFillHandler.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/common/handler/GlobalExceptionHandler.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/common/handler/GlobalResponseHandler.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/common/handler/MyBatisPlusConfig.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/common/helper/MatterCacheHelper.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/common/helper/basic/AbstractMatterCacheHelper.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/common/helper/impl/MattersCacheHelperImpl.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/common/model/ApiResponse.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/common/model/ApiStatus.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/common/model/PagePo.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/common/model/PageVo.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/common/model/Status.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/common/model/entity/Item.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/common/util/BizUtils.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/common/util/CallBack.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/common/util/CodeUtil.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/common/util/CommonInputStreamResource.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/common/util/CryptUtils.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/common/util/HttpUtil.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/common/util/Md5Utils.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/common/util/NdDateUtils.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/common/util/NdJacksonModule.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/common/util/RefreshKeyUtil.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/common/util/SpringContextHolder.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/common/util/StrPool.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/open/controller/HealthController.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/scheduler/contants/TaskContant.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/scheduler/controller/TaskController.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/scheduler/manage/SynManage.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/scheduler/model/CommonLog.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/scheduler/task/CheckMattersUrlTask.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/scheduler/task/RemoveMattersTask.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/scheduler/task/SynTask.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/scheduler/utils/DateUtil.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/security/AuthBeanConfig.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/security/AuthProperties.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/security/WebSecurityConfig.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/security/config/RedisSessionConfig.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/security/constant/AuthConst.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/security/constant/AuthTypeEnum.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/security/constant/LoginPlatformEnum.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/security/facade/UserAuthLoginFacade.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/security/handler/DefaultExpiredSessionStrategy.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/security/handler/DefaultInvalidSessionStrategy.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/security/handler/DefaultLoginFailureHandler.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/security/handler/DefaultLoginSuccessHandler.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/security/handler/DefaultLogoutSuccessHandler.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/security/listener/AuthEventListener.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/security/model/UserInfoDetails.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/security/model/WebRequestDetails.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/security/model/dto/LoginDeviceInfoDTO.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/security/model/dto/UserInfoBO.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/security/password/PasswordAuthProvider.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/security/password/PasswordAuthSecurityConfig.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/security/password/PasswordLoginUserDetailService.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/security/password/UsernamePasswordAuthFilter.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/security/password/UsernamePasswordAuthToken.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/sso/controller/SsoController.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/sso/manage/SsoManage.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/sso/model/dto/ReqSsoDTO.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/sso/model/vo/SsoTokenVO.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/sso/model/vo/SsoUserInfoVO.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/sso/utils/HmacAuthUtil.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/user/controller/UserAuthController.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/user/controller/UserInfoController.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/user/helper/LoginHelper.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/user/helper/UserInfoHelper.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/user/manage/UserInfoManage.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/user/mapper/UserAuthMapper.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/user/mapper/UserAuthMapper.xml create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/user/mapper/UserInfoMapper.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/user/mapper/UserInfoMapper.xml create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/user/model/entity/UserAuth.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/user/model/entity/UserInfo.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/user/model/enumerization/AccountStatus.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/user/model/po/ChangeAccountStatusReq.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/user/model/po/ModifyPasswordReq.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/user/model/po/SaveUserReq.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/user/model/po/UserListReq.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/user/model/vo/LoginUserDetailVO.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/user/model/vo/UserDetailVO.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/user/model/vo/UserListVO.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/user/service/IUserAuthService.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/user/service/IUserInfoService.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/user/service/impl/UserAuthServiceImpl.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/user/service/impl/UserInfoServiceImpl.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/user/util/BizUtils.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/user/util/LoginUserContext.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/user/util/LoginUserUtil.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/constants/ZzsfwMenuConstant.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/controller/DscSxAdsShareItemQltQlsxCommonIDVKqController.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/controller/KqZzsfwMenuController.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/controller/PolicyRegulationsController.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/enumeration/ItemTypeEnum.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/manage/MatterManage.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/manage/PolicyManage.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/manage/QlManage.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/mapper/ComponentsMatterEliminateMapper.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/mapper/ComponentsMatterEliminateMapper.xml create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/mapper/DscSxAdsShareItemQltQlsxCommonIDVKqMapper.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/mapper/DscSxAdsShareItemQltQlsxCommonIDVKqMapper.xml create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/mapper/KqZzsfwMatterDeduplicateMapper.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/mapper/KqZzsfwMenuMapper.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/mapper/KqZzsfwMenuMapper.xml create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/mapper/KqZzsfwPolicyMapper.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/model/dto/DscSxAdsShareItemQltQlsxCommonIDVKqDTO.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/model/dto/KqZzsfwMattersDeduplicateDTO.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/model/dto/KqZzsfwMenuDTO.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/model/dto/KqZzsfwPolicyDTO.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/model/entity/ComponentsMatterEliminateEntity.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/model/entity/DscSxAdsShareItemQltQlsxCommonIDVKq.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/model/entity/KqZzsfwMattersDeduplicate.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/model/entity/KqZzsfwMenu.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/model/entity/KqZzsfwPolicy.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/model/entity/MatterKey.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/model/vo/MatterTopVO.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/model/vo/MattersVO.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/model/vo/TreeVO.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/model/vo/WindowVO.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/model/vo/ZoneVO.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/model/vo/ZzsfwPolicyVO.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/service/ComponentsMatterEliminateService.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/service/IDscSxAdsShareItemQltQlsxCommonIDVKqService.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/service/IKqZzsfwMatterDeduplicateService.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/service/IKqZzsfwMenuService.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/service/IKqZzsfwPolicyService.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/service/impl/ComponentsMatterEliminateServiceImpl.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/service/impl/DscSxAdsShareItemQltQlsxCommonIDVKqServiceImpl.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/service/impl/KqZzsfwMatterDeduplicateServiceImpl.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/service/impl/KqZzsfwMenuServiceImpl.java create mode 100644 kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/service/impl/KqZzsfwPolicyServiceImpl.java create mode 100644 kq-api/src/main/resources/application-dev.yml create mode 100644 kq-api/src/main/resources/application-pre.yml create mode 100644 kq-api/src/main/resources/application-prod.yml create mode 100644 kq-api/src/main/resources/application.yml create mode 100644 kq-api/src/main/resources/logback-spring.xml create mode 100644 kq-api/src/main/resources/security/auth-dev.yml create mode 100644 kq-api/src/main/resources/security/auth-prod.yml create mode 100644 kq-api/src/test/java/com/ningdatech/kqapi/AppTests.java create mode 100644 kq-api/src/test/java/com/ningdatech/kqapi/menu/DuplicationTest.java create mode 100644 kq-api/src/test/java/com/ningdatech/kqapi/menu/ExcelSplitMergedCells.java create mode 100644 kq-api/src/test/java/com/ningdatech/kqapi/menu/MenuTest.java create mode 100644 kq-api/src/test/java/com/ningdatech/kqapi/menu/PolicyTest.java create mode 100644 kq-api/src/test/resources/application-dev.yml create mode 100644 kq-api/src/test/resources/application-pre.yml create mode 100644 kq-api/src/test/resources/application-prod.yml create mode 100644 kq-api/src/test/resources/application.yml create mode 100644 kq-api/src/test/resources/integration/zwdd-dev.yml create mode 100644 kq-api/src/test/resources/integration/zwdd-prod.yml create mode 100644 kq-api/src/test/resources/logback-spring.xml create mode 100644 kq-api/src/test/resources/security/auth-dev.yml create mode 100644 kq-api/src/test/resources/security/auth-prod.yml create mode 100644 kq-api/src/test/resources/wsdl-prod.xml create mode 100644 kq-api/src/test/resources/wsdl.xml create mode 100644 kq-gen/pom.xml create mode 100644 kq-gen/src/main/java/com/ningdatech/generator/config/CodeGen.java delete mode 100644 kqapi/pom.xml delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/App.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/admin/controller/MatterController.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/admin/controller/WindowController.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/admin/controller/ZoneController.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/admin/manage/AdminMatterManage.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/admin/manage/WindowManage.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/admin/manage/ZoneManage.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/admin/mapper/WindowMapper.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/admin/mapper/WindowMapper.xml delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/admin/mapper/ZoneMapper.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/admin/mapper/ZoneMapper.xml delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/admin/model/dto/MatterCountByWindowIdDTO.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/admin/model/dto/WindowCountByZoneIdDTO.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/admin/model/entity/Window.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/admin/model/entity/Zone.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/admin/model/enumerization/HandleChannelEnum.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/admin/model/req/ListWindowReq.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/admin/model/req/ListZoneReq.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/admin/model/req/MatterListReq.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/admin/model/req/WindowSaveReq.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/admin/model/req/ZoneSaveReq.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/admin/model/vo/MatterDetailDTO.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/admin/model/vo/MatterListVO.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/admin/model/vo/WindowDetailVO.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/admin/model/vo/ZoneDetailVO.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/admin/service/IWindowService.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/admin/service/IZoneService.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/admin/service/impl/WindowServiceImpl.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/admin/service/impl/ZoneServiceImpl.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/common/compare/Compare.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/common/compare/CompareNode.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/common/compare/CompareUtils.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/common/config/BeanConfig.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/common/config/ConfigurerAdapter.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/common/config/DingOrganizationProperties.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/common/config/ProvincialProperties.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/common/constant/BaseFieldConst.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/common/constant/BizConst.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/common/constant/CommonConst.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/common/constant/DefValConst.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/common/constant/DingConst.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/common/constant/ProjectDeclareConst.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/common/constant/RegionConst.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/common/constant/StateMachineConst.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/common/converter/BaseDateConverter.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/common/converter/NdLocalDateTimeDeserializer.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/common/converter/String2DateConverter.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/common/converter/String2LocalDateConverter.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/common/converter/String2LocalDateTimeConverter.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/common/converter/String2LocalTimeConverter.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/common/enumeration/BoolDisplayEnum.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/common/enumeration/CommonEnum.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/common/enumeration/ExportOptionEnum.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/common/enumeration/IEnum.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/common/enumeration/ImplSubjectNatureEnum.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/common/enumeration/ProjectProcessStageEnum.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/common/errorcode/AppErrorCode.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/common/exception/ArgumentException.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/common/exception/BaseCheckedException.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/common/exception/BaseException.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/common/exception/BaseUncheckedException.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/common/exception/BizException.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/common/exception/CommonException.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/common/exception/DownloadException.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/common/exception/ExportException.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/common/exception/ForbiddenException.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/common/exception/UnauthorizedException.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/common/exception/code/BaseExceptionCode.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/common/exception/code/ExceptionCode.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/common/handler/BaseFieldFillHandler.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/common/handler/GlobalExceptionHandler.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/common/handler/GlobalResponseHandler.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/common/handler/MyBatisPlusConfig.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/common/helper/MatterCacheHelper.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/common/helper/basic/AbstractMatterCacheHelper.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/common/helper/impl/MattersCacheHelperImpl.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/common/model/ApiResponse.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/common/model/ApiStatus.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/common/model/PagePo.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/common/model/PageVo.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/common/model/Status.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/common/model/entity/Item.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/common/util/BizUtils.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/common/util/CallBack.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/common/util/CodeUtil.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/common/util/CommonInputStreamResource.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/common/util/CryptUtils.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/common/util/HttpUtil.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/common/util/Md5Utils.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/common/util/NdDateUtils.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/common/util/NdJacksonModule.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/common/util/RefreshKeyUtil.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/common/util/SpringContextHolder.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/common/util/StrPool.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/open/controller/HealthController.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/scheduler/contants/TaskContant.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/scheduler/controller/TaskController.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/scheduler/manage/SynManage.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/scheduler/model/CommonLog.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/scheduler/task/CheckMattersUrlTask.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/scheduler/task/RemoveMattersTask.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/scheduler/task/SynTask.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/scheduler/utils/DateUtil.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/security/AuthBeanConfig.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/security/AuthProperties.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/security/WebSecurityConfig.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/security/config/RedisSessionConfig.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/security/constant/AuthConst.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/security/constant/AuthTypeEnum.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/security/constant/LoginPlatformEnum.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/security/facade/UserAuthLoginFacade.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/security/handler/DefaultExpiredSessionStrategy.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/security/handler/DefaultInvalidSessionStrategy.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/security/handler/DefaultLoginFailureHandler.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/security/handler/DefaultLoginSuccessHandler.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/security/handler/DefaultLogoutSuccessHandler.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/security/listener/AuthEventListener.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/security/model/UserInfoDetails.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/security/model/WebRequestDetails.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/security/model/dto/LoginDeviceInfoDTO.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/security/model/dto/UserInfoBO.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/security/password/PasswordAuthProvider.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/security/password/PasswordAuthSecurityConfig.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/security/password/PasswordLoginUserDetailService.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/security/password/UsernamePasswordAuthFilter.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/security/password/UsernamePasswordAuthToken.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/sso/controller/SsoController.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/sso/manage/SsoManage.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/sso/model/dto/ReqSsoDTO.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/sso/model/vo/SsoTokenVO.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/sso/model/vo/SsoUserInfoVO.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/sso/utils/HmacAuthUtil.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/user/controller/UserAuthController.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/user/controller/UserInfoController.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/user/helper/LoginHelper.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/user/helper/UserInfoHelper.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/user/manage/UserInfoManage.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/user/mapper/UserAuthMapper.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/user/mapper/UserAuthMapper.xml delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/user/mapper/UserInfoMapper.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/user/mapper/UserInfoMapper.xml delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/user/model/entity/UserAuth.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/user/model/entity/UserInfo.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/user/model/enumerization/AccountStatus.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/user/model/po/ChangeAccountStatusReq.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/user/model/po/ModifyPasswordReq.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/user/model/po/SaveUserReq.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/user/model/po/UserListReq.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/user/model/vo/LoginUserDetailVO.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/user/model/vo/UserDetailVO.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/user/model/vo/UserListVO.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/user/service/IUserAuthService.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/user/service/IUserInfoService.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/user/service/impl/UserAuthServiceImpl.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/user/service/impl/UserInfoServiceImpl.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/user/util/BizUtils.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/user/util/LoginUserContext.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/user/util/LoginUserUtil.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/constants/ZzsfwMenuConstant.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/controller/DscSxAdsShareItemQltQlsxCommonIDVKqController.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/controller/KqZzsfwMenuController.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/controller/PolicyRegulationsController.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/enumeration/ItemTypeEnum.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/manage/MatterManage.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/manage/PolicyManage.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/manage/QlManage.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/mapper/ComponentsMatterEliminateMapper.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/mapper/ComponentsMatterEliminateMapper.xml delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/mapper/DscSxAdsShareItemQltQlsxCommonIDVKqMapper.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/mapper/DscSxAdsShareItemQltQlsxCommonIDVKqMapper.xml delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/mapper/KqZzsfwMatterDeduplicateMapper.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/mapper/KqZzsfwMenuMapper.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/mapper/KqZzsfwMenuMapper.xml delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/mapper/KqZzsfwPolicyMapper.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/model/dto/DscSxAdsShareItemQltQlsxCommonIDVKqDTO.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/model/dto/KqZzsfwMattersDeduplicateDTO.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/model/dto/KqZzsfwMenuDTO.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/model/dto/KqZzsfwPolicyDTO.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/model/entity/ComponentsMatterEliminateEntity.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/model/entity/DscSxAdsShareItemQltQlsxCommonIDVKq.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/model/entity/KqZzsfwMattersDeduplicate.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/model/entity/KqZzsfwMenu.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/model/entity/KqZzsfwPolicy.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/model/entity/MatterKey.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/model/vo/MatterTopVO.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/model/vo/MattersVO.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/model/vo/TreeVO.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/model/vo/WindowVO.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/model/vo/ZoneVO.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/model/vo/ZzsfwPolicyVO.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/service/ComponentsMatterEliminateService.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/service/IDscSxAdsShareItemQltQlsxCommonIDVKqService.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/service/IKqZzsfwMatterDeduplicateService.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/service/IKqZzsfwMenuService.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/service/IKqZzsfwPolicyService.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/service/impl/ComponentsMatterEliminateServiceImpl.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/service/impl/DscSxAdsShareItemQltQlsxCommonIDVKqServiceImpl.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/service/impl/KqZzsfwMatterDeduplicateServiceImpl.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/service/impl/KqZzsfwMenuServiceImpl.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/service/impl/KqZzsfwPolicyServiceImpl.java delete mode 100644 kqapi/src/main/resources/application-dev.yml delete mode 100644 kqapi/src/main/resources/application-pre.yml delete mode 100644 kqapi/src/main/resources/application-prod.yml delete mode 100644 kqapi/src/main/resources/application.yml delete mode 100644 kqapi/src/main/resources/logback-spring.xml delete mode 100644 kqapi/src/main/resources/security/auth-dev.yml delete mode 100644 kqapi/src/main/resources/security/auth-prod.yml delete mode 100644 kqapi/src/test/java/com/ningdatech/kqapi/AppTests.java delete mode 100644 kqapi/src/test/java/com/ningdatech/kqapi/menu/DuplicationTest.java delete mode 100644 kqapi/src/test/java/com/ningdatech/kqapi/menu/ExcelSplitMergedCells.java delete mode 100644 kqapi/src/test/java/com/ningdatech/kqapi/menu/MenuTest.java delete mode 100644 kqapi/src/test/java/com/ningdatech/kqapi/menu/PolicyTest.java delete mode 100644 kqapi/src/test/resources/application-dev.yml delete mode 100644 kqapi/src/test/resources/application-pre.yml delete mode 100644 kqapi/src/test/resources/application-prod.yml delete mode 100644 kqapi/src/test/resources/application.yml delete mode 100644 kqapi/src/test/resources/integration/zwdd-dev.yml delete mode 100644 kqapi/src/test/resources/integration/zwdd-prod.yml delete mode 100644 kqapi/src/test/resources/logback-spring.xml delete mode 100644 kqapi/src/test/resources/security/auth-dev.yml delete mode 100644 kqapi/src/test/resources/security/auth-prod.yml delete mode 100644 kqapi/src/test/resources/wsdl-prod.xml delete mode 100644 kqapi/src/test/resources/wsdl.xml delete mode 100644 ningda-generator/pom.xml delete mode 100644 ningda-generator/src/main/java/com/ningdatech/generator/config/CodeGen.java diff --git a/kq-api/pom.xml b/kq-api/pom.xml new file mode 100644 index 0000000..53905aa --- /dev/null +++ b/kq-api/pom.xml @@ -0,0 +1,237 @@ + + + 4.0.0 + + com.ningdatech + kq-value-added-project + 1.0.0 + + kq-api + 1.0.0 + + + + + + com.google.guava + guava + + + cn.hutool + hutool-all + 5.8.5 + + + + org.projectlombok + lombok + + + + com.baomidou + mybatis-plus-boot-starter + + + com.baomidou + mybatis-plus-extension + + + + org.apache.commons + commons-pool2 + ${commons-pool2.version} + + + org.apache.commons + commons-lang3 + + + com.alibaba + fastjson + + + org.apache.tomcat.embed + tomcat-embed-core + + + org.springframework.boot + spring-boot-starter-validation + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-jdbc + + + + org.springframework.boot + spring-boot-devtools + test + + + org.springframework.boot + spring-boot-starter-aop + + + + com.github.ben-manes.caffeine + caffeine + + + org.apache.httpcomponents + httpclient + + + org.apache.poi + poi + + + org.apache.poi + poi-ooxml + + + + com.aliyun.oss + aliyun-sdk-oss + 3.15.0 + + + junit + junit + test + + + org.aspectj + aspectjweaver + + + + org.springframework.boot + spring-boot-starter-test + + + org.springframework.boot + spring-boot-configuration-processor + + + + + mysql + mysql-connector-java + + + + com.github.ulisesbocchio + jasypt-spring-boot-starter + 3.0.4 + + + com.ningdatech + nd-log-starter + + + org.springframework.boot + spring-boot-starter-data-redis + + + org.springframework.session + spring-session-data-redis + + + com.ningdatech + nd-swagger2-starter + + + com.ningdatech + nd-file-starter + + + + + + + dev + + + dev + + + + test + + test + + + + pre + + pre + + + + prod + + prod + + + + + + + + src/main/resources + + **/* + + + + src/main/java + + **/*.xml + + + + src/main/lib + BOOT-INF/lib/ + + **/*.jar + + + + src/main/resources + BOOT-INF/classes/ + + + kqapi + + + org.springframework.boot + spring-boot-maven-plugin + 2.6.8 + + true + + + + + repackage + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + true + + + + + + diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/App.java b/kq-api/src/main/java/com/ningdatech/kqapi/App.java new file mode 100644 index 0000000..85ee652 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/App.java @@ -0,0 +1,41 @@ +package com.ningdatech.kqapi; + +import com.ningdatech.basic.util.SpringUtils; +import com.ningdatech.kqapi.common.util.SpringContextHolder; +import org.mybatis.spring.annotation.MapperScan; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.ApplicationContext; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.EnableAspectJAutoProxy; +import org.springframework.scheduling.annotation.EnableAsync; +import org.springframework.scheduling.annotation.EnableScheduling; +import org.springframework.transaction.annotation.EnableTransactionManagement; + +/** + * @author zpf + */ +@SpringBootApplication +@EnableAsync +@MapperScan(App.MAPPER_PACKAGES) +@EnableScheduling +@EnableTransactionManagement +@EnableAspectJAutoProxy(exposeProxy = true) +@ComponentScan(basePackages = {"com.ningdatech.kqapi","com.ningdatech.kqapi.common"}) +public class App { + + protected static final String MAPPER_PACKAGES = "com.ningdatech.kqapi.**.mapper"; + + public static void main(String[] args) { + ApplicationContext context = SpringApplication.run(App.class, args); + // 设置applicationContext + SpringUtils.setApplicationContext(context); + } + + @Bean + public SpringContextHolder springContextHolder() { + return new SpringContextHolder(); + } + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/admin/controller/MatterController.java b/kq-api/src/main/java/com/ningdatech/kqapi/admin/controller/MatterController.java new file mode 100644 index 0000000..1872f26 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/admin/controller/MatterController.java @@ -0,0 +1,59 @@ +package com.ningdatech.kqapi.admin.controller; + +import com.ningdatech.basic.model.IdVo; +import com.ningdatech.basic.model.PageVo; +import com.ningdatech.kqapi.admin.manage.AdminMatterManage; +import com.ningdatech.kqapi.admin.model.req.MatterListReq; +import com.ningdatech.kqapi.admin.model.vo.MatterDetailDTO; +import com.ningdatech.kqapi.admin.model.vo.MatterListVO; +import com.ningdatech.log.annotation.WebLog; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.*; + +/** + *

+ * MatterController + *

+ * + * @author WendyYang + * @since 16:10 2024/4/20 + */ +@Api(tags = "事项管理") +@RestController +@RequiredArgsConstructor +@RequestMapping("/api/v1/matter") +public class MatterController { + + private final AdminMatterManage matterManage; + + @DeleteMapping("/del") + @ApiOperation("删除事项") + @WebLog("删除事项") + public void del(@RequestBody IdVo id) { + matterManage.del(id); + } + + @GetMapping("/page") + @ApiOperation("事项列表") + @WebLog("事项列表") + public PageVo pageMatter(MatterListReq req) { + return matterManage.pageMatter(req); + } + + @GetMapping("/detail/{id}") + @ApiOperation("事项详情") + @WebLog("事项详情") + public MatterDetailDTO detail(@PathVariable Long id) { + return matterManage.detail(id); + } + + @PostMapping("/save") + @ApiOperation("事项保存或修改") + @WebLog("事项保存或修改") + public void saveOrUpdate(@RequestBody MatterDetailDTO req) { + matterManage.saveOrUpdate(req); + } + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/admin/controller/WindowController.java b/kq-api/src/main/java/com/ningdatech/kqapi/admin/controller/WindowController.java new file mode 100644 index 0000000..117b60f --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/admin/controller/WindowController.java @@ -0,0 +1,63 @@ +package com.ningdatech.kqapi.admin.controller; + + +import com.ningdatech.basic.model.IdVo; +import com.ningdatech.basic.model.PageVo; +import com.ningdatech.kqapi.admin.manage.WindowManage; +import com.ningdatech.kqapi.admin.model.req.ListWindowReq; +import com.ningdatech.kqapi.admin.model.req.WindowSaveReq; +import com.ningdatech.kqapi.admin.model.vo.WindowDetailVO; +import com.ningdatech.log.annotation.WebLog; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.AllArgsConstructor; +import org.springframework.web.bind.annotation.*; + +import javax.validation.Valid; +import java.util.List; + +/** + *

+ * 前端控制器 + *

+ * + * @author WendyYang + * @since 2024-04-20 + */ +@Api(tags = "窗口管理") +@RestController +@AllArgsConstructor +@RequestMapping("/api/v1/window") +public class WindowController { + + private final WindowManage windowManage; + + @PostMapping("/save") + @WebLog("窗口新增或修改") + @ApiOperation("窗口新增或修改") + public void saveOrUpdate(@RequestBody @Valid WindowSaveReq req) { + windowManage.windowSaveOrUpdate(req); + } + + @DeleteMapping("/del") + @WebLog("窗口删除") + @ApiOperation("窗口删除") + public void delete(@RequestBody IdVo id) { + windowManage.delete(id); + } + + @GetMapping("/page") + @WebLog("窗口列表") + @ApiOperation("窗口列表") + public PageVo page(ListWindowReq req) { + return windowManage.pageWindow(req); + } + + @GetMapping("/option") + @WebLog("窗口下拉选择") + @ApiOperation("窗口下拉选择") + public List option(ListWindowReq req) { + return windowManage.windowOption(req); + } + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/admin/controller/ZoneController.java b/kq-api/src/main/java/com/ningdatech/kqapi/admin/controller/ZoneController.java new file mode 100644 index 0000000..ba0eda8 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/admin/controller/ZoneController.java @@ -0,0 +1,63 @@ +package com.ningdatech.kqapi.admin.controller; + + +import com.ningdatech.basic.model.IdVo; +import com.ningdatech.basic.model.PageVo; +import com.ningdatech.kqapi.admin.manage.ZoneManage; +import com.ningdatech.kqapi.admin.model.req.ListZoneReq; +import com.ningdatech.kqapi.admin.model.req.ZoneSaveReq; +import com.ningdatech.kqapi.admin.model.vo.ZoneDetailVO; +import com.ningdatech.log.annotation.WebLog; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.AllArgsConstructor; +import org.springframework.web.bind.annotation.*; + +import javax.validation.Valid; +import java.util.List; + +/** + *

+ * 前端控制器 + *

+ * + * @author WendyYang + * @since 2024-04-20 + */ +@Api(tags = "专区管理") +@RestController +@AllArgsConstructor +@RequestMapping("/api/v1/zone") +public class ZoneController { + + private final ZoneManage zoneManage; + + @PostMapping("/save") + @WebLog("专区保存或修改") + @ApiOperation("专区保存或修改") + public void zoneSaveOrUpdate(@RequestBody @Valid ZoneSaveReq req) { + zoneManage.zoneSaveOrUpdate(req); + } + + @DeleteMapping("/del") + @WebLog("专区删除") + @ApiOperation("专区删除") + public void delete(@RequestBody IdVo id) { + zoneManage.delete(id); + } + + @GetMapping("/page") + @WebLog("专区列表") + @ApiOperation("专区列表") + public PageVo pageZone(ListZoneReq req) { + return zoneManage.pageZone(req); + } + + @GetMapping("/option") + @WebLog("专区下拉选择") + @ApiOperation("专区下拉选择") + public List zoneOption(ListZoneReq req) { + return zoneManage.zoneOption(req); + } + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/admin/manage/AdminMatterManage.java b/kq-api/src/main/java/com/ningdatech/kqapi/admin/manage/AdminMatterManage.java new file mode 100644 index 0000000..973c0f7 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/admin/manage/AdminMatterManage.java @@ -0,0 +1,121 @@ +package com.ningdatech.kqapi.admin.manage; + +import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.core.conditions.Wrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ningdatech.basic.model.IdVo; +import com.ningdatech.basic.model.PageVo; +import com.ningdatech.basic.util.CollUtils; +import com.ningdatech.kqapi.admin.model.req.MatterListReq; +import com.ningdatech.kqapi.admin.model.vo.MatterDetailDTO; +import com.ningdatech.kqapi.admin.model.vo.MatterListVO; +import com.ningdatech.kqapi.zzsfw.model.entity.KqZzsfwMenu; +import com.ningdatech.kqapi.zzsfw.service.IKqZzsfwMenuService; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Component; + +import java.util.List; + +/** + *

+ * MatterManage + *

+ * + * @author WendyYang + * @since 15:41 2024/4/20 + */ +@Component +@RequiredArgsConstructor +public class AdminMatterManage { + + private final IKqZzsfwMenuService zzsfwMenuService; + + public PageVo pageMatter(MatterListReq req) { + Wrapper query = Wrappers.lambdaQuery(KqZzsfwMenu.class) + .like(StrUtil.isNotBlank(req.getMatterName()), KqZzsfwMenu::getItemName, req.getMatterName()) + .eq(req.getZoneId() != null, KqZzsfwMenu::getZoneId, req.getZoneId()) + .eq(req.getWindowId() != null, KqZzsfwMenu::getWindowId, req.getWindowId()) + .eq(req.getMatterType() != null, KqZzsfwMenu::getType, req.getMatterType()) + .eq(req.getDepartment() != null, KqZzsfwMenu::getDepartment, req.getDepartment()) + .orderByDesc(KqZzsfwMenu::getCreateOn); + Page page = zzsfwMenuService.page(req.page(), query); + if (page.getTotal() == 0) { + return PageVo.empty(); + } + List data = CollUtils.convert(page.getRecords(), + w -> MatterListVO.builder() + .matterName(w.getItemName()) + .matterType(w.getType()) + .department(w.getDepartment()) + .zoneName(w.getZoneName()) + .windowName(w.getWindow()) + .build()); + return PageVo.of(data, page.getTotal()); + } + + public void del(IdVo id) { + zzsfwMenuService.removeById(id.getId()); + } + + public MatterDetailDTO detail(Long id) { + KqZzsfwMenu matter = zzsfwMenuService.getById(id); + if (matter == null) { + return null; + } + return MatterDetailDTO.builder() + .id(matter.getId()) + .free(matter.getFree()) + .onlinePay(matter.getOnlinePay()) + .hasUrl(matter.getHasUrl()) + .matterType(matter.getType()) + .matterName(matter.getItemName()) + .department(matter.getDepartment()) + .handleAddress(matter.getHandleAddress()) + .handleChannel(matter.getHandleChannel()) + .handleTime(matter.getHandleTime()) + .implSubjectNature(matter.getImplSubjectNature()) + .publicityMaterials(matter.getPublicityMaterials()) + .sceneDesc(matter.getSceneDesc()) + .serviceContent(matter.getServiceContent()) + .serviceObject(matter.getServiceObject()) + .serviceProcess(matter.getServiceProcess()) + .sort(matter.getSort()) + .telephone(matter.getTelephone()) + .window(matter.getWindow()) + .windowId(matter.getWindowId()) + .zoneId(matter.getZoneId()) + .zoneName(matter.getZoneName()) + .webApplyUrl(matter.getWebapplyurl()) + .build(); + } + + public void saveOrUpdate(MatterDetailDTO req) { + KqZzsfwMenu matter = new KqZzsfwMenu(); + matter.setId(req.getId()); + matter.setFree(req.getFree()); + matter.setOnlinePay(req.getOnlinePay()); + matter.setHasUrl(req.getHasUrl()); + matter.setType(req.getMatterType()); + matter.setItemName(req.getMatterName()); + matter.setDepartment(req.getDepartment()); + matter.setHandleAddress(req.getHandleAddress()); + matter.setHandleChannel(req.getHandleChannel()); + matter.setHandleTime(req.getHandleTime()); + matter.setImplSubjectNature(req.getImplSubjectNature()); + matter.setPublicityMaterials(req.getPublicityMaterials()); + matter.setSceneDesc(req.getSceneDesc()); + matter.setServiceContent(req.getServiceContent()); + matter.setServiceObject(req.getServiceObject()); + matter.setServiceProcess(req.getServiceProcess()); + matter.setSort(req.getSort()); + matter.setTelephone(req.getTelephone()); + matter.setWindow(req.getWindow()); + matter.setWindowId(req.getWindowId()); + matter.setZoneId(req.getZoneId()); + matter.setZoneName(req.getZoneName()); + matter.setWebapplyurl(req.getWebApplyUrl()); + zzsfwMenuService.saveOrUpdate(matter); + } + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/admin/manage/WindowManage.java b/kq-api/src/main/java/com/ningdatech/kqapi/admin/manage/WindowManage.java new file mode 100644 index 0000000..6cb9508 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/admin/manage/WindowManage.java @@ -0,0 +1,83 @@ +package com.ningdatech.kqapi.admin.manage; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.core.conditions.Wrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ningdatech.basic.model.IdVo; +import com.ningdatech.basic.model.PageVo; +import com.ningdatech.basic.util.CollUtils; +import com.ningdatech.kqapi.admin.model.entity.Window; +import com.ningdatech.kqapi.admin.model.req.ListWindowReq; +import com.ningdatech.kqapi.admin.model.req.WindowSaveReq; +import com.ningdatech.kqapi.admin.model.vo.WindowDetailVO; +import com.ningdatech.kqapi.admin.service.IWindowService; +import com.ningdatech.kqapi.zzsfw.service.IKqZzsfwMenuService; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Component; + +import java.util.*; +import java.util.stream.Collectors; + +/** + *

+ * WindowManage + *

+ * + * @author WendyYang + * @since 12:17 2024/4/20 + */ +@Component +@RequiredArgsConstructor +public class WindowManage { + + private final IWindowService windowService; + private final IKqZzsfwMenuService zzsfwMenuService; + + public void windowSaveOrUpdate(WindowSaveReq req) { + Window win = BeanUtil.copyProperties(req, Window.class); + windowService.saveOrUpdate(win); + } + + public void delete(IdVo id) { + windowService.removeById(id.getId()); + } + + public PageVo pageWindow(ListWindowReq req) { + Wrapper query = buildWindowQuery(req); + Page page = windowService.page(req.page(), query); + if (page.getTotal() == 0) { + return PageVo.empty(); + } + List records = page.getRecords(); + List windowIds = CollUtils.fieldList(records, Window::getId); + Map matterCountMap = zzsfwMenuService.matterCountByWindowIds(windowIds); + List data = records.stream().map(w -> { + WindowDetailVO window = BeanUtil.copyProperties(w, WindowDetailVO.class); + window.setItemCount(matterCountMap.getOrDefault(w.getId(), 0)); + return window; + }).collect(Collectors.toList()); + return PageVo.of(data, page.getTotal()); + } + + public List windowOption(ListWindowReq req) { + Wrapper query = buildWindowQuery(req); + Page page = windowService.page(req.page(), query); + if (page.getTotal() == 0) { + return Collections.emptyList(); + } + return page.getRecords().stream().map(w -> WindowDetailVO.builder() + .windowName(w.getWindowName()) + .id(w.getId()) + .build()).collect(Collectors.toList()); + } + + private static Wrapper buildWindowQuery(ListWindowReq req) { + return Wrappers.lambdaQuery(Window.class) + .like(StrUtil.isNotBlank(req.getWindowName()), Window::getWindowName, req.getWindowName()) + .eq(req.getZoneId() != null, Window::getZoneId, req.getZoneId()) + .orderByDesc(Window::getUpdateOn); + } + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/admin/manage/ZoneManage.java b/kq-api/src/main/java/com/ningdatech/kqapi/admin/manage/ZoneManage.java new file mode 100644 index 0000000..4be4204 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/admin/manage/ZoneManage.java @@ -0,0 +1,102 @@ +package com.ningdatech.kqapi.admin.manage; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.core.conditions.Wrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ningdatech.basic.model.IdVo; +import com.ningdatech.basic.model.PageVo; +import com.ningdatech.basic.util.CollUtils; +import com.ningdatech.kqapi.admin.mapper.ZoneMapper; +import com.ningdatech.kqapi.admin.model.entity.Window; +import com.ningdatech.kqapi.admin.model.entity.Zone; +import com.ningdatech.kqapi.admin.model.req.ListZoneReq; +import com.ningdatech.kqapi.admin.model.req.ZoneSaveReq; +import com.ningdatech.kqapi.admin.model.vo.ZoneDetailVO; +import com.ningdatech.kqapi.admin.service.IWindowService; +import com.ningdatech.kqapi.admin.service.IZoneService; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + *

+ * ZoneManage + *

+ * + * @author WendyYang + * @since 12:17 2024/4/20 + */ +@Component +@RequiredArgsConstructor +public class ZoneManage { + + private final IZoneService zoneService; + private final ZoneMapper zoneMapper; + private final IWindowService windowService; + + @Transactional(rollbackFor = Exception.class) + public synchronized void zoneSaveOrUpdate(ZoneSaveReq req) { + Zone zone = BeanUtil.copyProperties(req, Zone.class); + if (zone.getId() != null) { + Zone oldZone = zoneService.getById(req.getId()); + if (!StrUtil.equals(zone.getZoneName(), oldZone.getZoneName())) { + Wrapper wUpdate = Wrappers.lambdaUpdate(Window.class) + .set(Window::getZoneName, req.getZoneName()) + .eq(Window::getZoneId, req.getId()); + windowService.update(wUpdate); + } + } + zoneService.saveOrUpdate(zone); + } + + + public void delete(IdVo id) { + zoneService.removeById(id.getId()); + } + + public PageVo pageZone(ListZoneReq req) { + Wrapper query = buildZoneQuery(req); + Page page = zoneService.page(req.page(), query); + if (page.getTotal() == 0) { + return PageVo.empty(); + } + List records = page.getRecords(); + List zoneIds = CollUtils.fieldList(records, Zone::getId); + Map windowCountMap = windowService.windowCountByZoneIds(zoneIds); + List data = records.stream().map(w -> { + ZoneDetailVO zone = BeanUtil.copyProperties(w, ZoneDetailVO.class); + zone.setWindowCount(windowCountMap.getOrDefault(w.getId(), 0)); + return zone; + }).collect(Collectors.toList()); + return PageVo.of(data, page.getTotal()); + } + + public List zoneOption(ListZoneReq req) { + Wrapper query = buildZoneQuery(req); + Page page = zoneService.page(req.page(), query); + if (page.getTotal() == 0) { + return Collections.emptyList(); + } + return CollUtils.convert(page.getRecords(), + w -> ZoneDetailVO.builder() + .id(w.getId()) + .zoneName(w.getZoneName()) + .build()); + } + + private static Wrapper buildZoneQuery(ListZoneReq req) { + return Wrappers.lambdaQuery(Zone.class) + .like(StrUtil.isNotBlank(req.getZoneName()), Zone::getZoneName, req.getZoneName()) + .orderByDesc(Zone::getUpdateOn); + } + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/admin/mapper/WindowMapper.java b/kq-api/src/main/java/com/ningdatech/kqapi/admin/mapper/WindowMapper.java new file mode 100644 index 0000000..5831b18 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/admin/mapper/WindowMapper.java @@ -0,0 +1,23 @@ +package com.ningdatech.kqapi.admin.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ningdatech.kqapi.admin.model.dto.WindowCountByZoneIdDTO; +import com.ningdatech.kqapi.admin.model.entity.Window; +import org.apache.ibatis.annotations.Param; + +import java.util.Collection; +import java.util.List; + +/** + *

+ * Mapper 接口 + *

+ * + * @author WendyYang + * @since 2024-04-20 + */ +public interface WindowMapper extends BaseMapper { + + List selectWindowCountByZoneIds(@Param("zoneIds") Collection zoneIds); + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/admin/mapper/WindowMapper.xml b/kq-api/src/main/java/com/ningdatech/kqapi/admin/mapper/WindowMapper.xml new file mode 100644 index 0000000..93aef87 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/admin/mapper/WindowMapper.xml @@ -0,0 +1,13 @@ + + + + + + + diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/admin/mapper/ZoneMapper.java b/kq-api/src/main/java/com/ningdatech/kqapi/admin/mapper/ZoneMapper.java new file mode 100644 index 0000000..3f08445 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/admin/mapper/ZoneMapper.java @@ -0,0 +1,16 @@ +package com.ningdatech.kqapi.admin.mapper; + +import com.ningdatech.kqapi.admin.model.entity.Zone; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** + *

+ * Mapper 接口 + *

+ * + * @author WendyYang + * @since 2024-04-20 + */ +public interface ZoneMapper extends BaseMapper { + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/admin/mapper/ZoneMapper.xml b/kq-api/src/main/java/com/ningdatech/kqapi/admin/mapper/ZoneMapper.xml new file mode 100644 index 0000000..752a645 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/admin/mapper/ZoneMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/admin/model/dto/MatterCountByWindowIdDTO.java b/kq-api/src/main/java/com/ningdatech/kqapi/admin/model/dto/MatterCountByWindowIdDTO.java new file mode 100644 index 0000000..fd16538 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/admin/model/dto/MatterCountByWindowIdDTO.java @@ -0,0 +1,20 @@ +package com.ningdatech.kqapi.admin.model.dto; + +import lombok.Data; + +/** + *

+ * WindowCountByZoneIdDTO + *

+ * + * @author WendyYang + * @since 14:14 2024/4/20 + */ +@Data +public class MatterCountByWindowIdDTO { + + private Integer windowId; + + private Integer matterCount; + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/admin/model/dto/WindowCountByZoneIdDTO.java b/kq-api/src/main/java/com/ningdatech/kqapi/admin/model/dto/WindowCountByZoneIdDTO.java new file mode 100644 index 0000000..0abf7a0 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/admin/model/dto/WindowCountByZoneIdDTO.java @@ -0,0 +1,20 @@ +package com.ningdatech.kqapi.admin.model.dto; + +import lombok.Data; + +/** + *

+ * WindowCountByZoneIdDTO + *

+ * + * @author WendyYang + * @since 14:14 2024/4/20 + */ +@Data +public class WindowCountByZoneIdDTO { + + private Integer zoneId; + + private Integer windowCount; + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/admin/model/entity/Window.java b/kq-api/src/main/java/com/ningdatech/kqapi/admin/model/entity/Window.java new file mode 100644 index 0000000..5f78af7 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/admin/model/entity/Window.java @@ -0,0 +1,54 @@ +package com.ningdatech.kqapi.admin.model.entity; + +import com.baomidou.mybatisplus.annotation.*; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.time.LocalDateTime; + +/** + *

+ * 窗口对象 + *

+ * + * @author WendyYang + * @since 2024-04-20 + */ +@Data +@TableName("nd_window") +@ApiModel(value = "Window对象") +public class Window implements Serializable { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty("主键") + @TableId(value = "id", type = IdType.AUTO) + private Integer id; + + @ApiModelProperty("窗口名称") + private String windowName; + + @ApiModelProperty("专区ID") + private Integer zoneId; + + @ApiModelProperty("专区名称") + private String zoneName; + + @TableLogic + private Boolean deleted; + + @TableField(fill = FieldFill.INSERT) + private LocalDateTime createOn; + + @TableField(fill = FieldFill.INSERT) + private Long createBy; + + @TableField(fill = FieldFill.INSERT_UPDATE) + private LocalDateTime updateOn; + + @TableField(fill = FieldFill.INSERT_UPDATE) + private Long updateBy; + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/admin/model/entity/Zone.java b/kq-api/src/main/java/com/ningdatech/kqapi/admin/model/entity/Zone.java new file mode 100644 index 0000000..a5adbed --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/admin/model/entity/Zone.java @@ -0,0 +1,52 @@ +package com.ningdatech.kqapi.admin.model.entity; + +import com.baomidou.mybatisplus.annotation.*; + +import java.io.Serializable; +import java.time.LocalDateTime; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + *

+ * 专区对象 + *

+ * + * @author WendyYang + * @since 2024-04-20 + */ +@Data +@TableName("nd_zone") +@ApiModel(value = "Zone对象") +public class Zone implements Serializable { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty("主键") + @TableId(value = "id", type = IdType.AUTO) + private Integer id; + + @ApiModelProperty("专区名称") + private String zoneName; + + @ApiModelProperty("专区图标") + private String zoneIcon; + + @TableLogic + private Boolean deleted; + + @TableField(fill = FieldFill.INSERT) + private LocalDateTime createOn; + + @TableField(fill = FieldFill.INSERT) + private Long createBy; + + @TableField(fill = FieldFill.INSERT_UPDATE) + private LocalDateTime updateOn; + + @TableField(fill = FieldFill.INSERT_UPDATE) + private Long updateBy; + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/admin/model/enumerization/HandleChannelEnum.java b/kq-api/src/main/java/com/ningdatech/kqapi/admin/model/enumerization/HandleChannelEnum.java new file mode 100644 index 0000000..a450227 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/admin/model/enumerization/HandleChannelEnum.java @@ -0,0 +1,30 @@ +package com.ningdatech.kqapi.admin.model.enumerization; + +import com.ningdatech.kqapi.common.enumeration.IEnum; +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + *

+ * HandleChannelEnum + *

+ * + * @author WendyYang + * @since 10:09 2024/4/22 + */ +@Getter +@AllArgsConstructor +public enum HandleChannelEnum implements IEnum { + + HANDLE_ON_WINDOW(1, "现场窗口申请"), + HANDLE_ON_NETWORK(2, "全程网办"); + + private final Integer code; + private final String desc; + + @Override + public HandleChannelEnum[] all() { + return values(); + } + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/admin/model/req/ListWindowReq.java b/kq-api/src/main/java/com/ningdatech/kqapi/admin/model/req/ListWindowReq.java new file mode 100644 index 0000000..05be92b --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/admin/model/req/ListWindowReq.java @@ -0,0 +1,26 @@ +package com.ningdatech.kqapi.admin.model.req; + +import com.ningdatech.kqapi.common.model.PagePo; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + *

+ * WindowSaveReq + *

+ * + * @author WendyYang + * @since 13:25 2024/4/20 + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class ListWindowReq extends PagePo { + + @ApiModelProperty("专区ID") + private Integer zoneId; + + @ApiModelProperty("窗口名称") + private String windowName; + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/admin/model/req/ListZoneReq.java b/kq-api/src/main/java/com/ningdatech/kqapi/admin/model/req/ListZoneReq.java new file mode 100644 index 0000000..43c2b11 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/admin/model/req/ListZoneReq.java @@ -0,0 +1,23 @@ +package com.ningdatech.kqapi.admin.model.req; + +import com.ningdatech.kqapi.common.model.PagePo; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + *

+ * ListZoneReq + *

+ * + * @author WendyYang + * @since 13:25 2024/4/20 + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class ListZoneReq extends PagePo { + + @ApiModelProperty("专区名称") + private String zoneName; + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/admin/model/req/MatterListReq.java b/kq-api/src/main/java/com/ningdatech/kqapi/admin/model/req/MatterListReq.java new file mode 100644 index 0000000..3489f9f --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/admin/model/req/MatterListReq.java @@ -0,0 +1,35 @@ +package com.ningdatech.kqapi.admin.model.req; + +import com.ningdatech.kqapi.common.model.PagePo; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + *

+ * MatterListReq + *

+ * + * @author WendyYang + * @since 15:52 2024/4/20 + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class MatterListReq extends PagePo { + + @ApiModelProperty("部门") + private String department; + + @ApiModelProperty("事项名称") + private String matterName; + + @ApiModelProperty("服务类型") + private Integer matterType; + + @ApiModelProperty("专区ID") + private Integer zoneId; + + @ApiModelProperty("窗口ID") + private Integer windowId; + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/admin/model/req/WindowSaveReq.java b/kq-api/src/main/java/com/ningdatech/kqapi/admin/model/req/WindowSaveReq.java new file mode 100644 index 0000000..24d011b --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/admin/model/req/WindowSaveReq.java @@ -0,0 +1,35 @@ +package com.ningdatech.kqapi.admin.model.req; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; + +/** + *

+ * WindowSaveReq + *

+ * + * @author WendyYang + * @since 13:25 2024/4/20 + */ +@Data +public class WindowSaveReq { + + @ApiModelProperty("窗口ID") + private Integer id; + + @ApiModelProperty("专区ID") + @NotNull(message = "专区ID不能为空") + private Integer zoneId; + + @ApiModelProperty("专区名称") + @NotBlank(message = "专区名称不能为空") + private String zoneName; + + @ApiModelProperty("窗口名称") + @NotBlank(message = "窗口名称不能为空") + private String windowName; + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/admin/model/req/ZoneSaveReq.java b/kq-api/src/main/java/com/ningdatech/kqapi/admin/model/req/ZoneSaveReq.java new file mode 100644 index 0000000..c43ab01 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/admin/model/req/ZoneSaveReq.java @@ -0,0 +1,30 @@ +package com.ningdatech.kqapi.admin.model.req; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotBlank; + +/** + *

+ * ZoneSaveReq + *

+ * + * @author WendyYang + * @since 13:25 2024/4/20 + */ +@Data +public class ZoneSaveReq { + + @ApiModelProperty("专区ID") + private Integer id; + + @ApiModelProperty("专区名称") + @NotBlank(message = "专区名称不能为空") + private String zoneName; + + @ApiModelProperty("专区图标") + @NotBlank(message = "专区图标不能为空") + private String zoneIcon; + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/admin/model/vo/MatterDetailDTO.java b/kq-api/src/main/java/com/ningdatech/kqapi/admin/model/vo/MatterDetailDTO.java new file mode 100644 index 0000000..f7ec9d1 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/admin/model/vo/MatterDetailDTO.java @@ -0,0 +1,95 @@ +package com.ningdatech.kqapi.admin.model.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Builder; +import lombok.Data; + +import java.time.LocalDateTime; + +/** + *

+ * MatterDetailVO + *

+ * + * @author WendyYang + * @since 15:48 2024/4/20 + */ +@Data +@Builder +public class MatterDetailDTO { + + private Long id; + + @ApiModelProperty("事项名称") + private String matterName; + + @ApiModelProperty("专区名称") + private String zoneName; + + @ApiModelProperty("专区ID") + private Integer zoneId; + + @ApiModelProperty("窗口ID") + private Integer windowId; + + @ApiModelProperty("窗口名称") + private String windowName; + + @ApiModelProperty("部门") + private String department; + + @ApiModelProperty("事项类型") + private Integer matterType; + + @ApiModelProperty("事项链接") + private String webApplyUrl; + + @ApiModelProperty("窗口") + private String window; + + @ApiModelProperty("排序") + private Integer sort; + + @ApiModelProperty("是否在政务中心查到url") + private Integer hasUrl; + + @ApiModelProperty("服务内容") + private String serviceContent; + + @ApiModelProperty("服务流程") + private String serviceProcess; + + @ApiModelProperty("咨询电话") + private String telephone; + + @ApiModelProperty("服务对象") + private String serviceObject; + + @ApiModelProperty("是否免费") + private Boolean free; + + @ApiModelProperty("是否网上缴费") + private Boolean onlinePay; + + @ApiModelProperty("办理渠道") + private Integer handleChannel; + + @ApiModelProperty("办理地点") + private String handleAddress; + + @ApiModelProperty("办理时间") + private String handleTime; + + @ApiModelProperty("行使层级") + private String exerciseLevel; + + @ApiModelProperty("实施主体性质") + private Integer implSubjectNature; + + @ApiModelProperty("特色场景描述") + private String sceneDesc; + + @ApiModelProperty("宣传资料") + private String publicityMaterials; + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/admin/model/vo/MatterListVO.java b/kq-api/src/main/java/com/ningdatech/kqapi/admin/model/vo/MatterListVO.java new file mode 100644 index 0000000..3289663 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/admin/model/vo/MatterListVO.java @@ -0,0 +1,34 @@ +package com.ningdatech.kqapi.admin.model.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Builder; +import lombok.Data; + +/** + *

+ * MatterListVO + *

+ * + * @author WendyYang + * @since 15:48 2024/4/20 + */ +@Data +@Builder +public class MatterListVO { + + @ApiModelProperty("事项名称") + private String matterName; + + @ApiModelProperty("专区名称") + private String zoneName; + + @ApiModelProperty("窗口名称") + private String windowName; + + @ApiModelProperty("部门") + private String department; + + @ApiModelProperty("事项类型") + private Integer matterType; + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/admin/model/vo/WindowDetailVO.java b/kq-api/src/main/java/com/ningdatech/kqapi/admin/model/vo/WindowDetailVO.java new file mode 100644 index 0000000..0bf29f5 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/admin/model/vo/WindowDetailVO.java @@ -0,0 +1,34 @@ +package com.ningdatech.kqapi.admin.model.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Builder; +import lombok.Data; + +/** + *

+ * WindowDetailVO + *

+ * + * @author WendyYang + * @since 13:47 2024/4/20 + */ +@Builder +@Data +public class WindowDetailVO { + + @ApiModelProperty("窗口ID") + private Integer id; + + @ApiModelProperty("窗口名称") + private String windowName; + + @ApiModelProperty("专区ID") + private Integer zoneId; + + @ApiModelProperty("专区名称") + private String zoneName; + + @ApiModelProperty("事项数量") + private Integer itemCount; + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/admin/model/vo/ZoneDetailVO.java b/kq-api/src/main/java/com/ningdatech/kqapi/admin/model/vo/ZoneDetailVO.java new file mode 100644 index 0000000..011bcd8 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/admin/model/vo/ZoneDetailVO.java @@ -0,0 +1,31 @@ +package com.ningdatech.kqapi.admin.model.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Builder; +import lombok.Data; + +/** + *

+ * ZoneDetailVO + *

+ * + * @author WendyYang + * @since 13:48 2024/4/20 + */ +@Data +@Builder +public class ZoneDetailVO { + + @ApiModelProperty("专区ID") + private Integer id; + + @ApiModelProperty("专区名称") + private String zoneName; + + @ApiModelProperty("专区图标") + private String zoneIcon; + + @ApiModelProperty("窗口数量") + private Integer windowCount; + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/admin/service/IWindowService.java b/kq-api/src/main/java/com/ningdatech/kqapi/admin/service/IWindowService.java new file mode 100644 index 0000000..65a10a1 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/admin/service/IWindowService.java @@ -0,0 +1,21 @@ +package com.ningdatech.kqapi.admin.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.ningdatech.kqapi.admin.model.entity.Window; + +import java.util.Collection; +import java.util.Map; + +/** + *

+ * 服务类 + *

+ * + * @author WendyYang + * @since 2024-04-20 + */ +public interface IWindowService extends IService { + + Map windowCountByZoneIds(Collection zoneIds); + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/admin/service/IZoneService.java b/kq-api/src/main/java/com/ningdatech/kqapi/admin/service/IZoneService.java new file mode 100644 index 0000000..17644a5 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/admin/service/IZoneService.java @@ -0,0 +1,16 @@ +package com.ningdatech.kqapi.admin.service; + +import com.ningdatech.kqapi.admin.model.entity.Zone; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + *

+ * 服务类 + *

+ * + * @author WendyYang + * @since 2024-04-20 + */ +public interface IZoneService extends IService { + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/admin/service/impl/WindowServiceImpl.java b/kq-api/src/main/java/com/ningdatech/kqapi/admin/service/impl/WindowServiceImpl.java new file mode 100644 index 0000000..f8d5746 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/admin/service/impl/WindowServiceImpl.java @@ -0,0 +1,38 @@ +package com.ningdatech.kqapi.admin.service.impl; + +import cn.hutool.core.collection.CollUtil; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ningdatech.basic.util.CollUtils; +import com.ningdatech.kqapi.admin.mapper.WindowMapper; +import com.ningdatech.kqapi.admin.model.dto.WindowCountByZoneIdDTO; +import com.ningdatech.kqapi.admin.model.entity.Window; +import com.ningdatech.kqapi.admin.service.IWindowService; +import org.springframework.stereotype.Service; + +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.Map; + +/** + *

+ * 服务实现类 + *

+ * + * @author WendyYang + * @since 2024-04-20 + */ +@Service +public class WindowServiceImpl extends ServiceImpl implements IWindowService { + + @Override + public Map windowCountByZoneIds(Collection zoneIds) { + if (CollUtil.isEmpty(zoneIds)) { + return Collections.emptyMap(); + } + List counts = baseMapper.selectWindowCountByZoneIds(zoneIds); + return CollUtils.listToMap(counts, WindowCountByZoneIdDTO::getZoneId, + WindowCountByZoneIdDTO::getWindowCount); + } + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/admin/service/impl/ZoneServiceImpl.java b/kq-api/src/main/java/com/ningdatech/kqapi/admin/service/impl/ZoneServiceImpl.java new file mode 100644 index 0000000..ef69a5e --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/admin/service/impl/ZoneServiceImpl.java @@ -0,0 +1,20 @@ +package com.ningdatech.kqapi.admin.service.impl; + +import com.ningdatech.kqapi.admin.model.entity.Zone; +import com.ningdatech.kqapi.admin.mapper.ZoneMapper; +import com.ningdatech.kqapi.admin.service.IZoneService; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +/** + *

+ * 服务实现类 + *

+ * + * @author WendyYang + * @since 2024-04-20 + */ +@Service +public class ZoneServiceImpl extends ServiceImpl implements IZoneService { + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/common/compare/Compare.java b/kq-api/src/main/java/com/ningdatech/kqapi/common/compare/Compare.java new file mode 100644 index 0000000..d42f28c --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/common/compare/Compare.java @@ -0,0 +1,22 @@ +package com.ningdatech.kqapi.common.compare; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * 字段标记注解 + * + * @author zpf + * @since 2023/07/21 + */ +@Target(ElementType.FIELD) +@Retention(RetentionPolicy.RUNTIME) +public @interface Compare { + + /** + * 字段名称 + */ + String value(); +} \ No newline at end of file diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/common/compare/CompareNode.java b/kq-api/src/main/java/com/ningdatech/kqapi/common/compare/CompareNode.java new file mode 100644 index 0000000..f763601 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/common/compare/CompareNode.java @@ -0,0 +1,47 @@ +package com.ningdatech.kqapi.common.compare; + +/** + * @author zpf + * @since 2023/07/21 + */ +public class CompareNode { + + /** + * 字段 + */ + private String fieldKey; + + /** + * 字段值 + */ + private Object fieldValue; + + /** + * 字段名称 + */ + private String fieldName; + + public String getFieldKey() { + return fieldKey; + } + + public void setFieldKey(String fieldKey) { + this.fieldKey = fieldKey; + } + + public Object getFieldValue() { + return fieldValue; + } + + public void setFieldValue(Object fieldValue) { + this.fieldValue = fieldValue; + } + + public String getFieldName() { + return fieldName; + } + + public void setFieldName(String fieldName) { + this.fieldName = fieldName; + } +} \ No newline at end of file diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/common/compare/CompareUtils.java b/kq-api/src/main/java/com/ningdatech/kqapi/common/compare/CompareUtils.java new file mode 100644 index 0000000..344e118 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/common/compare/CompareUtils.java @@ -0,0 +1,182 @@ +package com.ningdatech.kqapi.common.compare; + +import com.alibaba.fastjson.JSONObject; + +import java.lang.reflect.Field; +import java.util.*; + +/** + * 使用须知:
+ * (1)该工具类主要用于两个同类对象的属性值比较;
+ * (2)使用本工具类前,请将对应的类属性上打上 @Compare("xxx") 注解,其中xxx为字段的表达名称;
+ * (3)为了比较灵活,只有打了该注解才会进行比较,不打的字段则不会进行比较
+ * (4)比较后,只会返回有变化的字段,无变化的字符则不返回
+ * + * @author zpf + * @since 2023/07/21 + */ +public class CompareUtils { + + private static final String COMMA = ","; + + /** + * 属性比较 + * + * @param source 源数据对象 + * @param target 目标数据对象 + * @return 对应属性值的比较变化 + */ + public String compare(T source, T target) { + return compare(source, target, null); + } + + + /** + * 属性比较 + * + * @param source 源数据对象 + * @param target 目标数据对象 + * @param ignoreCompareFields 忽略比较的字段 + * @return 对应属性值的比较变化 + */ + public String compare(T source, T target, List ignoreCompareFields) { + if (Objects.isNull(source) && Objects.isNull(target)) { + return ""; + } + Map sourceMap = this.getFiledValueMap(source); + Map targetMap = this.getFiledValueMap(target); + if (sourceMap.isEmpty() && targetMap.isEmpty()) { + return ""; + } + // 如果源数据为空,则只显示目标数据,不显示属性变化情况 + if (sourceMap.isEmpty()) { + return doEmpty(targetMap, ignoreCompareFields); + } + // 如果源数据为空,则显示属性变化情况 + String s = doCompare(sourceMap, targetMap, ignoreCompareFields); + if (!s.endsWith(COMMA)) { + return s; + } + return s.substring(0, s.length() - 1); + } + + public JSONObject compareToJson(T source, T target, List ignoreCompareFields) { + JSONObject res = new JSONObject(); + if (Objects.isNull(source) && Objects.isNull(target)) { + return res; + } + Map sourceMap = this.getFiledValueMap(source); + Map targetMap = this.getFiledValueMap(target); + if (sourceMap.isEmpty() && targetMap.isEmpty()) { + return res; + } + // 如果源数据为空,则只显示目标数据,不显示属性变化情况 + if (sourceMap.isEmpty()) { + return res; + } + + return doCompareJson(sourceMap, targetMap, ignoreCompareFields); + } + + private String doEmpty(Map targetMap, List ignoreCompareFields) { + StringBuilder sb = new StringBuilder(); + Collection values = targetMap.values(); + int size = values.size(); + int current = 0; + for (CompareNode node : values) { + current++; + Object o = Optional.ofNullable(node.getFieldValue()).orElse(""); + if (Objects.nonNull(ignoreCompareFields) && ignoreCompareFields.contains(node.getFieldKey())) { + continue; + } + if (o.toString().length() > 0) { + sb.append("[" + node.getFieldName() + ":" + o + "]"); + if (current < size) { + sb.append(COMMA); + } + } + } + return sb.toString(); + } + + private String doCompare(Map sourceMap, Map targetMap, List ignoreCompareFields) { + StringBuilder sb = new StringBuilder(); + Set keys = sourceMap.keySet(); + int size = keys.size(); + int current = 0; + for (String key : keys) { + current++; + CompareNode sn = sourceMap.get(key); + CompareNode tn = targetMap.get(key); + if (Objects.nonNull(ignoreCompareFields) && ignoreCompareFields.contains(sn.getFieldKey())) { + continue; + } + String sv = Optional.ofNullable(sn.getFieldValue()).orElse("").toString(); + String tv = Optional.ofNullable(tn.getFieldValue()).orElse("").toString(); + // 只有两者属性值不一致时, 才显示变化情况 + if (!sv.equals(tv)) { + sb.append(String.format("[%s:%s -> %s]", sn.getFieldName(), sv, tv)); + if (current < size) { + sb.append(COMMA); + } + } + } + return sb.toString(); + } + + private JSONObject doCompareJson(Map sourceMap, Map targetMap, List ignoreCompareFields) { + JSONObject res = new JSONObject(); + Set keys = sourceMap.keySet(); + int size = keys.size(); + int current = 0; + for (String key : keys) { + current++; + CompareNode sn = sourceMap.get(key); + CompareNode tn = targetMap.get(key); + if (Objects.nonNull(ignoreCompareFields) && ignoreCompareFields.contains(sn.getFieldKey())) { + continue; + } + String sv = Optional.ofNullable(sn.getFieldValue()).orElse("").toString(); + String tv = Optional.ofNullable(tn.getFieldValue()).orElse("").toString(); + // 只有两者属性值不一致时, 才显示变化情况 + if (!sv.equals(tv)) { + JSONObject valueChange = new JSONObject(); + valueChange.put("fieldKey",sn.getFieldKey()); + valueChange.put("old",tv); + valueChange.put("new",sv); + res.put(sn.getFieldName(),valueChange); + } + } + return res; + } + + private Map getFiledValueMap(T t) { + if (Objects.isNull(t)) { + return Collections.emptyMap(); + } + Field[] fields = t.getClass().getDeclaredFields(); + if (Objects.isNull(fields) || fields.length == 0) { + return Collections.emptyMap(); + } + Map map = new LinkedHashMap(); + for (Field field : fields) { + Compare compareAnnotation = field.getAnnotation(Compare.class); + if (Objects.isNull(compareAnnotation)) { + continue; + } + field.setAccessible(true); + try { + String fieldKey = field.getName(); + CompareNode node = new CompareNode(); + node.setFieldKey(fieldKey); + node.setFieldValue(field.get(t)); + node.setFieldName(compareAnnotation.value()); + map.put(field.getName(), node); + } catch (IllegalArgumentException | IllegalAccessException e) { + e.printStackTrace(); + } + } + return map; + } + +} \ No newline at end of file diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/common/config/BeanConfig.java b/kq-api/src/main/java/com/ningdatech/kqapi/common/config/BeanConfig.java new file mode 100644 index 0000000..7d5c11c --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/common/config/BeanConfig.java @@ -0,0 +1,188 @@ +package com.ningdatech.kqapi.common.config; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.json.JsonReadFeature; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; +import com.ningdatech.kqapi.common.util.NdDateUtils; +import com.ningdatech.kqapi.common.util.NdJacksonModule; +import lombok.extern.slf4j.Slf4j; +import org.apache.http.Header; +import org.apache.http.client.HttpClient; +import org.apache.http.client.config.RequestConfig; +import org.apache.http.impl.client.DefaultConnectionKeepAliveStrategy; +import org.apache.http.impl.client.DefaultHttpRequestRetryHandler; +import org.apache.http.impl.client.HttpClientBuilder; +import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; +import org.apache.http.message.BasicHeader; +import org.springframework.boot.autoconfigure.AutoConfigureBefore; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Primary; +import org.springframework.http.MediaType; +import org.springframework.http.client.ClientHttpRequestFactory; +import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; +import org.springframework.http.converter.HttpMessageConverter; +import org.springframework.http.converter.StringHttpMessageConverter; +import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder; +import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; +import org.springframework.web.client.RestTemplate; +import org.springframework.web.servlet.config.annotation.CorsRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +import java.nio.charset.StandardCharsets; +import java.text.SimpleDateFormat; +import java.time.ZoneId; +import java.util.*; +import java.util.concurrent.TimeUnit; + +/** + * @Classname BeanConfig + * @Description + * @Date 2023/3/2 9:42 + * @Created by PoffyZhang + */ +@AutoConfigureBefore(JacksonAutoConfiguration.class) +@Configuration +@Slf4j +public class BeanConfig implements WebMvcConfigurer { + + + @Bean + public RestTemplate restTemplate() { + // 添加内容转换器,使用默认的内容转换器 + RestTemplate restTemplate = new RestTemplate(httpRequestFactory()); + // 设置编码格式为UTF-8,解决中文乱码问题 + List> converterList = restTemplate.getMessageConverters(); + HttpMessageConverter converterTarget = null; + for (HttpMessageConverter item : converterList) { + if (item.getClass() == StringHttpMessageConverter.class) { + converterTarget = item; + break; + } + } + if (converterTarget != null) { + converterList.remove(converterTarget); + } + HttpMessageConverter converter = new StringHttpMessageConverter(StandardCharsets.UTF_8); + converterList.add(1, converter); + + MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter = new MappingJackson2HttpMessageConverter(); + mappingJackson2HttpMessageConverter.setSupportedMediaTypes(Arrays.asList( + MediaType.TEXT_HTML, + MediaType.TEXT_PLAIN)); + restTemplate.getMessageConverters().add(mappingJackson2HttpMessageConverter); + + log.info("-----restTemplate-----初始化完成"); + return restTemplate; + } + + @Bean + public ClientHttpRequestFactory httpRequestFactory() { + return new HttpComponentsClientHttpRequestFactory(httpClient()); + } + + @Bean + public HttpClient httpClient() { + // 长连接保持30秒 + PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager(30, TimeUnit.SECONDS); + //设置整个连接池最大连接数 根据自己的场景决定 + connectionManager.setMaxTotal(500); + //同路由的并发数,路由是对maxTotal的细分 + connectionManager.setDefaultMaxPerRoute(500); + + //requestConfig + RequestConfig requestConfig = RequestConfig.custom() + //服务器返回数据(response)的时间,超过该时间抛出read timeout + .setSocketTimeout(10000) + //连接上服务器(握手成功)的时间,超出该时间抛出connect timeout + .setConnectTimeout(5000) + //从连接池中获取连接的超时时间,超过该时间未拿到可用连接,会抛出org.apache.http.conn.ConnectionPoolTimeoutException: Timeout waiting for connection from pool + .setConnectionRequestTimeout(500) + .build(); + //headers + List
headers = new ArrayList<>(); + headers.add(new BasicHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.16 Safari/537.36")); + headers.add(new BasicHeader("Accept-Encoding", "gzip,deflate")); + headers.add(new BasicHeader("Accept-Language", "zh-CN")); + headers.add(new BasicHeader("Connection", "Keep-Alive")); + headers.add(new BasicHeader("Content-type", "application/json;charset=UTF-8")); + + return HttpClientBuilder.create() + .setDefaultRequestConfig(requestConfig) + .setConnectionManager(connectionManager) + .setDefaultHeaders(headers) + // 保持长连接配置,需要在头添加Keep-Alive + .setKeepAliveStrategy(new DefaultConnectionKeepAliveStrategy()) + //重试次数,默认是3次,没有开启 + .setRetryHandler(new DefaultHttpRequestRetryHandler(2, true)) + .build(); + } + + /** + * 全局配置 序列化和反序列化规则 + * addSerializer:序列化 (Controller 返回 给前端的json) + * 1. Long -> string + * 2. BigInteger -> string + * 3. BigDecimal -> string + * 4. date -> string + * 5. LocalDateTime -> "yyyy-MM-dd HH:mm:ss" + * 6. LocalDate -> "yyyy-MM-dd" + * 7. LocalTime -> "HH:mm:ss" + * 8. BaseEnum -> {"code": "xxx", "desc": "xxx"} + * + *

+ * addDeserializer: 反序列化 (前端调用接口时,传递到后台的json) + * 1. {"code": "xxx"} -> BaseEnum + * 2. "yyyy-MM-dd HH:mm:ss" -> LocalDateTime + * 3. "yyyy-MM-dd" -> LocalDate + * 4. "HH:mm:ss" -> LocalTime + * + * @param builder 构造器 + * @return 全局 ObjectMapper + */ + @Bean + @Primary + @ConditionalOnClass(ObjectMapper.class) + @ConditionalOnMissingBean + public ObjectMapper jacksonObjectMapper(Jackson2ObjectMapperBuilder builder) { + ObjectMapper objectMapper = builder.createXmlMapper(false).build(); + objectMapper.setLocale(Locale.CHINA) + //去掉默认的时间戳格式 + .configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false) + // 时区 + .setTimeZone(TimeZone.getTimeZone(ZoneId.systemDefault())) + //Date参数日期格式 + .setDateFormat(new SimpleDateFormat(NdDateUtils.DEFAULT_DATE_TIME_FORMAT, Locale.CHINA)) + + //该特性决定parser是否允许JSON字符串包含非引号控制字符(值小于32的ASCII字符,包含制表符和换行符)。 如果该属性关闭,则如果遇到这些字符,则会抛出异常。JSON标准说明书要求所有控制符必须使用引号,因此这是一个非标准的特性 + .configure(JsonReadFeature.ALLOW_UNESCAPED_CONTROL_CHARS.mappedFeature(), true) + // 忽略不能转义的字符 + .configure(JsonReadFeature.ALLOW_BACKSLASH_ESCAPING_ANY_CHARACTER.mappedFeature(), true) + //在使用spring boot + jpa/hibernate,如果实体字段上加有FetchType.LAZY,并使用jackson序列化为json串时,会遇到SerializationFeature.FAIL_ON_EMPTY_BEANS异常 + .configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false) + //忽略未知字段 + .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) + //单引号处理 + .configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true); + // 注册自定义模块 + objectMapper.registerModule(new NdJacksonModule()).findAndRegisterModules(); + return objectMapper; + } + + //解决跨域方式二 + static final String ORIGINS[] = new String[]{"GET", "POST", "PUT", "DELETE", "OPTIONS"}; + + @Override + public void addCorsMappings(CorsRegistry registry) { + registry.addMapping("/**") // 所有的当前站点的请求地址,都支持跨域访问。 + .allowedOriginPatterns("*") // 所有的外部域都可跨域访问。 如果是localhost则很难配置,因为在跨域请求的时候,外部域的解析可能是localhost、127.0.0.1、主机名 + .allowCredentials(true) // 是否支持跨域用户凭证 + .allowedMethods(ORIGINS) // 当前站点支持的跨域请求类型是什么 + .maxAge(3600); // 超时时长设置为1小时。 时间单位是秒。 + } +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/common/config/ConfigurerAdapter.java b/kq-api/src/main/java/com/ningdatech/kqapi/common/config/ConfigurerAdapter.java new file mode 100644 index 0000000..f0b1f32 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/common/config/ConfigurerAdapter.java @@ -0,0 +1,37 @@ +package com.ningdatech.kqapi.common.config; + +import com.alibaba.fastjson.serializer.SerializerFeature; +import com.alibaba.fastjson.support.config.FastJsonConfig; +import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.MediaType; +import org.springframework.http.converter.HttpMessageConverter; +import org.springframework.web.servlet.config.annotation.EnableWebMvc; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.List; + +/** + * @author qinxianyun + */ +@EnableWebMvc +@Configuration +public class ConfigurerAdapter implements WebMvcConfigurer { + + @Override + public void configureMessageConverters(List> converters) { + // 使用 fastjson 序列化,会导致 @JsonIgnore 失效,可以使用 @JSONField(serialize = false) 替换 + FastJsonHttpMessageConverter converter = new FastJsonHttpMessageConverter(); + List supportMediaTypeList = new ArrayList<>(); + supportMediaTypeList.add(MediaType.APPLICATION_JSON); + FastJsonConfig config = new FastJsonConfig(); + config.setDateFormat("yyyy-MM-dd HH:mm:ss"); + config.setSerializerFeatures(SerializerFeature.DisableCircularReferenceDetect); + converter.setFastJsonConfig(config); + converter.setSupportedMediaTypes(supportMediaTypeList); + converter.setDefaultCharset(StandardCharsets.UTF_8); + converters.add(converter); + } +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/common/config/DingOrganizationProperties.java b/kq-api/src/main/java/com/ningdatech/kqapi/common/config/DingOrganizationProperties.java new file mode 100644 index 0000000..5fcf9db --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/common/config/DingOrganizationProperties.java @@ -0,0 +1,19 @@ +package com.ningdatech.kqapi.common.config; + +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.Configuration; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author liuxinxin + * @date 2022/9/9 下午5:37 + */ +@Data +@Configuration +@ConfigurationProperties(prefix = "organization") +public class DingOrganizationProperties { + private List deptVisibleScopes = new ArrayList<>(); +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/common/config/ProvincialProperties.java b/kq-api/src/main/java/com/ningdatech/kqapi/common/config/ProvincialProperties.java new file mode 100644 index 0000000..cdbf17c --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/common/config/ProvincialProperties.java @@ -0,0 +1,26 @@ +package com.ningdatech.kqapi.common.config; + +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.Configuration; + +/** + * @author zpf + * @date 2023/3/2 下午5:37 + */ +@Data +@Configuration +@ConfigurationProperties(prefix = "provincial") +public class ProvincialProperties { + private String host; + + private String pushUrl; + + private String detailUrl; + + private String domainUrl; + + private String key; + + private String secret; +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/common/constant/BaseFieldConst.java b/kq-api/src/main/java/com/ningdatech/kqapi/common/constant/BaseFieldConst.java new file mode 100644 index 0000000..af3f58a --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/common/constant/BaseFieldConst.java @@ -0,0 +1,18 @@ +package com.ningdatech.kqapi.common.constant; + +/** + *

+ * 创建人修改人基础字段 + *

+ * + * @author WendyYang + * @since 17:17 2023/01/29 + */ +public interface BaseFieldConst { + + String CREATE_BY = "createBy"; + String UPDATE_BY = "updateBy"; + String CREATE_ON = "createOn"; + String UPDATE_ON = "updateOn"; + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/common/constant/BizConst.java b/kq-api/src/main/java/com/ningdatech/kqapi/common/constant/BizConst.java new file mode 100644 index 0000000..0307599 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/common/constant/BizConst.java @@ -0,0 +1,37 @@ +package com.ningdatech.kqapi.common.constant; + +import com.ningdatech.kqapi.common.model.ApiResponse; + +/** + *

+ * BizConst + *

+ * + * @author WendyYang + * @since 11:46 2024/4/20 + */ +public class BizConst { + + private BizConst() { + } + + /** + * SQL查询一条 + */ + public static final String LIMIT_1 = "limit 1"; + + public static final String COOKIE_KEY = "KQ_ZZSFW"; + + + /** + * 密码正则:长度8-20位且至少包含大写字母、小写字母、数字或特殊符号中的任意三种 + */ + public static final String REGEX_PASS = "^(?![a-zA-Z]+$)(?![A-Z0-9]+$)(?![A-Z\\W_]+$)(?![a-z0-9]+$)(?![a-z\\W_]+$)(?![0-9\\W_]+$)[a-zA-Z0-9\\W_]{8,20}$"; + + public static final String JSON_UTF8 = "application/json;charset=UTF-8"; + + public static final ApiResponse SESSION_EXPIRE = ApiResponse.of(401, "登录已超时,请重新登陆!"); + + public static final ApiResponse UNAUTHENTICATED = ApiResponse.of(401, "用户未登录!"); + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/common/constant/CommonConst.java b/kq-api/src/main/java/com/ningdatech/kqapi/common/constant/CommonConst.java new file mode 100644 index 0000000..abab570 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/common/constant/CommonConst.java @@ -0,0 +1,69 @@ +package com.ningdatech.kqapi.common.constant; + +/** + * @description: 常量 + * @author: LiuXinXin + * @date: 2022/5/5 17:31 + */ +public interface CommonConst { + + String COOKIE_KEY = "ND_JSESSION"; + + Integer EXPORT_PAGE_NUMBER = 1; + Integer EXPORT_PAGE_SIZE = 100000; + String CALL_STATUS = "status"; + String CALL_STATUS_OK_VALUE = "ok"; + + Integer COMMENT_MAX_SIZE = 163; + Integer SUB_COMMENT_SIZE_MIN = 0; + Integer SUB_COMMENT_SIZE_MAX = 160; + + String PROJECT_DECLARE = "项目申报"; + String UNIT_INNER_AUDIT = "单位内部审核"; + String PRELIMINARY_PREVIEW = "项目预审"; + + String DEPT_UNITED_REVIEW = "部门联审"; + String PROVINCE_UNITED_REVIEW = "省级部门联审"; + String ANNUAL_PLAN = "年度计划"; + String CONSTRUCTION_PLAN_REVIEW = "建设方案评审"; + String PROJECT_APPROVAL = "立项批复"; + String TENDER_PURCHASE = "招标采购"; + String PROJECT_PRELIMINARY_INSPECTION = "项目初验"; + String PROJECT_FINAL_INSPECTION = "项目终验"; + + String ARCHIVED = "归档"; + + String FILE_NAME = "name"; + String BASIS_FILE_NAME = "fileName"; + + String NULL = "null"; + + String TITLE = "title"; + + String FILE_NAME_STR = "fileName"; + String FILE_ID_STR = "fileId"; + String ID_STR = "id"; + String FILE_LIST = "fileList"; + String ITEM_BASED = "依据项:"; + String ITEM_BASED_FILE_NAME = "依据文件名:"; + String APPENDIX = "文件:"; + String NEW_CONSTRUCTION = "新建"; + String CONTINUED_CONSTRUCTION = "续建"; + String MONTH = "月"; + String ZHI = "至"; + String YEAR = "年"; + + Integer VERSION_ONE = 1; + Integer VERSION_SIZE = 2; + Integer VERSION_JUDGE = -1; + + String COPY = "副本"; + String PROJECT_REPEAT = " 项目已在其他评价计划中,请勿重复添加!"; + String APP_REPEAT = " 应用已在其他评价计划中,请勿重复添加!"; + Integer REAPPRAISAL_TYPE = 1; + Integer VERIFY_TYPE = 2; + String REPEAT = " 已在其他当前评价计划其他分组中,请勿重复添加!"; + + String NORMAL_TIME_PATTERN = "yyyy-MM-dd"; + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/common/constant/DefValConst.java b/kq-api/src/main/java/com/ningdatech/kqapi/common/constant/DefValConst.java new file mode 100644 index 0000000..69385ee --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/common/constant/DefValConst.java @@ -0,0 +1,34 @@ +package com.ningdatech.kqapi.common.constant; + + +import cn.hutool.core.text.StrPool; + +/** + * 默认值 + * + * @author PoffyZhang + */ +public interface DefValConst { + + /** + * 默认的根节点path + */ + String ROOT_PATH = StrPool.COMMA; + /** + * 默认树层级 + */ + Integer TREE_GRADE = 0; + /** + * 默认的父id + */ + Long PARENT_ID = 0L; + /** + * 默认的排序 + */ + Integer SORT_VALUE = 0; + /** + * 字典占位符 + */ + String DICT_PLACEHOLDER = "###"; + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/common/constant/DingConst.java b/kq-api/src/main/java/com/ningdatech/kqapi/common/constant/DingConst.java new file mode 100644 index 0000000..e30577d --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/common/constant/DingConst.java @@ -0,0 +1,14 @@ +package com.ningdatech.kqapi.common.constant; + +/** + * 浙政钉常量 + * + * @author CMM + * @since 2023/02/01 14:49 + */ +public interface DingConst { + /** + * 工作通知 + */ + String WORKING_NOTICE = "/message/workNotification"; +} \ No newline at end of file diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/common/constant/ProjectDeclareConst.java b/kq-api/src/main/java/com/ningdatech/kqapi/common/constant/ProjectDeclareConst.java new file mode 100644 index 0000000..d9132a6 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/common/constant/ProjectDeclareConst.java @@ -0,0 +1,172 @@ +package com.ningdatech.kqapi.common.constant; + +import java.math.BigDecimal; + +/** + * 项目申报表单数据常量key + * @return + * @author CMM + * @since 2023/01/19 10:31 + */ +public interface ProjectDeclareConst { + + /** + * 基本信息 + */ + class BasicInformation { + // 项目名称 + public static final String PROJECT_NAME = "projectName"; + // 是否一地创新全省共享项目 + public static final String INNOVATION_SHARING_PROJECT = "innovationSharingProject"; + // 是否临时增补 + public static final String TEMPORARY_SUPPLEMENT = "temporarySupplement"; + // 项目负责人 + public static final String PROJECT_LEADER = "projectLeader"; + // 项目负责人手机号 + public static final String PROJECT_LEADER_PHONE_NUMBER = "projectLeaderPhoneNumber"; + // 项目联系人 + public static final String PROJECT_CONTACT = "projectContact"; + // 项目联系人手机号 + public static final String PROJECT_CONTACT_PHONE_NUMBER = "projectContactPhoneNumber"; + // 建设单位 + public static final String CONSTRUCTION_UNIT = "constructionUnit"; + // 建设单位统一信用代码 + public static final String CONSTRUCTION_UNIT_UNIFIED_CREDIT_CODE = "constructionUnitUnifiedCreditCode"; + // 项目类型 + public static final String PROJECT_TYPE = "projectType"; + // 是否首次新建 + public static final String FIRST_NEW_CONSTRUCTION = "firstNewConstruction"; + // 预算年度 + public static final String BUDGET_YEAR = "projectYear"; + // 建设开始时间 + public static final String CONSTRUCTION_START_TIME = "constructionStartTime"; + // 建设结束时间 + public static final String CONSTRUCTION_END_TIME = "constructionEndTime"; + // 四大体系 + public static final String FOUR_SYSTEM = "fourSystem"; + // 是否数字化改革项目 + public static final String DIGITAL_REFORM_PROJECT = "digitalReformProject"; + // 建设层级 + public static final String CONSTRUCTION_HIERARCHY = "constructionHierarchy"; + // 立项依据材料 + public static final String PROJECT_BASIS_MATERIAL = "projectBasisMaterial"; + // 发改编码 + public static final String CHANGE_CODE = "changeCode"; + // 财政编码 + public static final String FISCAL_CODE = "fiscalCode"; + // 是否上云 + public static final String ON_CLOUD = "onCloud"; + // 项目简介 + public static final String PROJECT_INTRODUCTION = "projectIntroduction"; + } + + /** + * 资金申报情况 + */ + class FundDeclareInfo { + // 申报金额 + public static final String DECLARE_AMOUNT = "declareAmount"; + // 自有资金 + public static final String OWN_FUND = "ownFund"; + // 政府投资-本级财政资金 + public static final String GOVERNMENT_INVESTMENT_SAME_LEVEL_FUND = "governmentInvestmentSameLevelFund"; + // 政府投资-上级补助资金 + public static final String GOVERNMENT_INVESTMENT_SUPERIOR_FUND = "governmentInvestmentSuperiorFund"; + // 银行贷款 + public static final String BANK_LOAN = "bankLoan"; + // 其他资金 + public static final String OTHER_FUND = "otherFund"; + } + + /** + * 总投资分配情况 + */ + class TotalInvestmentAllocations { + // 软件开发 + public static final String SOFTWARE_DEVELOPMENT = "softwareDevelopment"; + // 云资源、硬件配置 + public static final String CLOUD_RESOURCE_HARDWARE_CONFIGURATION = "cloudResourceHardwareConfiguration"; + // 第三方服务 + public static final String THIRD_PARTY_SERVICE = "thirdPartyService"; + } + /** + * 年度支付计划 + */ + class AnnualPaymentPlan { + // 年度支付金额 + public static final String ANNUAL_PAYMENT_AMOUNT = "annualPaymentAmount"; + // 自有资金 + public static final String OWN_FUND = "ownFund"; + // 政府投资-本级财政资金 + public static final String GOVERNMENT_INVESTMENT_SAME_LEVEL_FUND = "governmentInvestmentSameLevelFund"; + // 政府投资-上级补助资金 + public static final String GOVERNMENT_INVESTMENT_SUPERIOR_FUND = "governmentInvestmentSuperiorFund"; + // 银行贷款 + public static final String BANK_LOAN = "bankLoan"; + // 其他 + public static final String OTHER = "other"; + } + /** + * 核心业务 + */ + class CoreBusiness { + + } + /** + * 安全投入 + */ + class SafetyInput { + // 投入项 + public static final String INPUT_ITEM = "inputItem"; + // 内容描述 + public static final String CONTENT_DESCRIPTION = "contentDescription"; + // 金额 + public static final String AMOUNT = "amount"; + } + /** + * 工程形象进度 + */ + class ProjectImageProgress { + // 第一季度 + public static final String FIRST_QUARTER = "firstQuarter"; + // 第二季度 + public static final String SECOND_QUARTER = "secondQuarter"; + // 第三季度 + public static final String THIRD_QUARTER = "thirdQuarter"; + // 第四季度 + public static final String FOURTH_QUARTER = "fourthQuarter"; + } + /** + * 附件 + */ + class Appendix { + + } + /** + * 备注 + */ + class Remark { + + } + /** + * 应用信息 + */ + class ApplicationInformation { + + } + + class Number { + public static final BigDecimal DECLARE_AMOUNT_JUDGEMENT = BigDecimal.valueOf(1000); + + //区县是500万 + public static final BigDecimal DECLARE_COUNTY_AMOUNT_JUDGEMENT = BigDecimal.valueOf(500); + + public static final Integer COUNTRY_BUILD_LEVEL = 1; + public static final Integer PROVINCE_BUILD_LEVEL = 2; + public static final Integer PROVINCE_SELF_BUILD_LEVEL = 3; + public static final Integer CITY_BUILD_LEVEL = 4; + public static final Integer CITY_SELF_BUILD_LEVEL = 5; + public static final Integer DISTRICTS_COUNTRIES_BUILD_LEVEL = 6; + public static final Integer VILLAGES_TOWNS_BUILD_LEVEL = 7; + } +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/common/constant/RegionConst.java b/kq-api/src/main/java/com/ningdatech/kqapi/common/constant/RegionConst.java new file mode 100644 index 0000000..66c5eac --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/common/constant/RegionConst.java @@ -0,0 +1,50 @@ +package com.ningdatech.kqapi.common.constant; + +/** + *

+ * RegionConst + *

+ * + * @author WendyYang + * @since 13:57 2023/3/1 + */ +public interface RegionConst { + + //---------------------------------------地区层级(缩写RL)------------------------------------------------------------- + + int RL_PROVINCE = 1; + + int RL_CITY = 2; + + int RL_COUNTY = 3; + + //---------------------------------------地区编码(缩写RC)------------------------------------------------------------- + + /** + * 丽水行政区划编码 + */ + String RC_LS = "331100"; + //丽水开发区 + String LS_KF = "331118"; + String LS_KF_IRS = "331151"; + String RC_LS_SBJ_IRS = "331101"; + //遂昌县 + String RC_SC = "331123"; + String LS_KF_NAME = "开发区"; + + /** + * 中国行政区划编码 + */ + String RC_CHINA = "100000"; + + + /** + * 浙江行政区划编码 + */ + String RC_ZJ = "330000"; + + //----------------------------------------地区父级ID(缩写PID)--------------------------------------------------------- + + long PID_CHINA = 0; + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/common/constant/StateMachineConst.java b/kq-api/src/main/java/com/ningdatech/kqapi/common/constant/StateMachineConst.java new file mode 100644 index 0000000..9cd0f1f --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/common/constant/StateMachineConst.java @@ -0,0 +1,14 @@ +package com.ningdatech.kqapi.common.constant; + +/** + * @author CMM + * @since 2023/02/07 16:24 + */ + +public class StateMachineConst { + + public static final String PROJECT_DECLARE = "projectDeclare"; + public static final String APPLICATION_DECLARE = "applicationDeclare"; + public static final String LI_SHUI_CITY_AREA_CODE = "331100"; + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/common/converter/BaseDateConverter.java b/kq-api/src/main/java/com/ningdatech/kqapi/common/converter/BaseDateConverter.java new file mode 100644 index 0000000..1b843ff --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/common/converter/BaseDateConverter.java @@ -0,0 +1,42 @@ +package com.ningdatech.kqapi.common.converter; + +import java.util.Map; +import java.util.Set; +import java.util.function.Function; + +/** + * 解决入参为 Date类型 + * + * @author WendyYang + * @date 2019-04-30 + */ +public abstract class BaseDateConverter { + + /** + * 值转换 + * + * @param source 源数据 + * @param function 回调 + * @return 转换后的数据 + */ + public T convert(String source, Function function) { + if (source == null || source.isEmpty()) { + return null; + } + String sourceTrim = source.trim(); + Set> entries = getFormat().entrySet(); + for (Map.Entry entry : entries) { + if (sourceTrim.matches(entry.getValue())) { + return function.apply(entry.getKey()); + } + } + throw new IllegalArgumentException("无效的日期参数格式:'" + sourceTrim + "'"); + } + + /** + * 获取子类 具体的格式化表达式 + * + * @return 格式化 + */ + protected abstract Map getFormat(); +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/common/converter/NdLocalDateTimeDeserializer.java b/kq-api/src/main/java/com/ningdatech/kqapi/common/converter/NdLocalDateTimeDeserializer.java new file mode 100644 index 0000000..fec700e --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/common/converter/NdLocalDateTimeDeserializer.java @@ -0,0 +1,185 @@ +package com.ningdatech.kqapi.common.converter; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.core.JsonTokenId; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.datatype.jsr310.deser.JSR310DateTimeDeserializerBase; +import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer; + +import java.io.IOException; +import java.time.*; +import java.time.format.DateTimeFormatter; + +import static com.ningdatech.kqapi.common.util.NdDateUtils.*; + + +/** + * 字段类型是LocalDateTime时,可以按照以下6种格式反序列化: + * 1. yyyy-MM-dd + * 2. yyyy年MM月dd日 + * 3. yyyy/MM/dd + * 4. yyyy-MM-dd HH:mm:ss + * 5. yyyy年MM月dd日HH时mm分ss秒 + * 6. yyyy/MM/dd HH:mm:ss + * + * @author WendyYang + * @date 2020/6/18 上午10:50 + */ +@SuppressWarnings("ALL") +public class NdLocalDateTimeDeserializer extends JSR310DateTimeDeserializerBase { + public static final NdLocalDateTimeDeserializer INSTANCE = new NdLocalDateTimeDeserializer(); + private static final long serialVersionUID = 1L; + private static final DateTimeFormatter DEFAULT_FORMATTER = DateTimeFormatter.ISO_LOCAL_DATE_TIME; + /** + * 以下是支持的6种参数格式 + */ + private static final DateTimeFormatter DEFAULT_DATE_FORMAT_DTF = DateTimeFormatter.ofPattern(DEFAULT_DATE_FORMAT); + private static final DateTimeFormatter DEFAULT_DATE_FORMAT_EN_DTF = DateTimeFormatter.ofPattern(DEFAULT_DATE_FORMAT_EN); + private static final DateTimeFormatter SLASH_DATE_FORMAT_DTF = DateTimeFormatter.ofPattern(SLASH_DATE_FORMAT); + private static final DateTimeFormatter DEFAULT_DATE_TIME_FORMAT_DTF = DateTimeFormatter.ofPattern(DEFAULT_DATE_TIME_FORMAT); + private static final DateTimeFormatter DEFAULT_DATE_TIME_FORMAT_EN_DTF = DateTimeFormatter.ofPattern(DEFAULT_DATE_TIME_FORMAT_EN); + private static final DateTimeFormatter SLASH_DATE_TIME_FORMAT_DTF = DateTimeFormatter.ofPattern(SLASH_DATE_TIME_FORMAT); + + @Override + protected JSR310DateTimeDeserializerBase withShape(JsonFormat.Shape shape) { + return this; + } + + private NdLocalDateTimeDeserializer() { + this(DEFAULT_FORMATTER); + } + + public NdLocalDateTimeDeserializer(DateTimeFormatter formatter) { + super(LocalDateTime.class, formatter); + } + + protected NdLocalDateTimeDeserializer(NdLocalDateTimeDeserializer base, Boolean leniency) { + super(base, leniency); + } + + @Override + protected NdLocalDateTimeDeserializer withLeniency(Boolean leniency) { + return new NdLocalDateTimeDeserializer(this, leniency); + } + + @Override + protected JSR310DateTimeDeserializerBase withDateFormat(DateTimeFormatter formatter) { + return new LocalDateTimeDeserializer(formatter); + } + + private LocalDateTime convert(String source) { + if (source.matches(DEFAULT_DATE_FORMAT_MATCHES)) { + return LocalDateTime.of(LocalDate.parse(source, DEFAULT_DATE_FORMAT_DTF), LocalTime.MIN); + } + if (source.matches(DEFAULT_DATE_FORMAT_EN_MATCHES)) { + return LocalDateTime.of(LocalDate.parse(source, DEFAULT_DATE_FORMAT_EN_DTF), LocalTime.MIN); + } + if (source.matches(SLASH_DATE_FORMAT_MATCHES)) { + return LocalDateTime.of(LocalDate.parse(source, SLASH_DATE_FORMAT_DTF), LocalTime.MIN); + } + if (source.matches(DEFAULT_DATE_TIME_FORMAT_MATCHES)) { + return LocalDateTime.parse(source, DEFAULT_DATE_TIME_FORMAT_DTF); + } + if (source.matches(DEFAULT_DATE_TIME_FORMAT_EN_MATCHES)) { + return LocalDateTime.parse(source, DEFAULT_DATE_TIME_FORMAT_EN_DTF); + } + if (source.matches(SLASH_DATE_TIME_FORMAT_MATCHES)) { + return LocalDateTime.parse(source, SLASH_DATE_TIME_FORMAT_DTF); + } + return null; + } + + @Override + public LocalDateTime deserialize(JsonParser parser, DeserializationContext context) throws IOException { + // 字符串 + if (parser.hasTokenId(JsonTokenId.ID_STRING)) { + String string = parser.getText().trim(); + if (string.length() == 0) { + return null; + } + + try { + if (_formatter == null) { + return convert(string); + } + if (_formatter == DEFAULT_FORMATTER) { + // JavaScript by default includes time and zone in JSON serialized Dates (UTC/ISO instant format). + if (string.length() > 10 && string.charAt(10) == 'T') { + if (string.endsWith("Z")) { + return LocalDateTime.ofInstant(Instant.parse(string), ZoneOffset.UTC); + } else { + return LocalDateTime.parse(string, DEFAULT_FORMATTER); + } + } + return convert(string); + } + + return LocalDateTime.parse(string, this._formatter); + } catch (DateTimeException e) { + return _handleDateTimeException(context, e, string); + } + } + // 数组 + if (parser.isExpectedStartArrayToken()) { + JsonToken t = parser.nextToken(); + if (t == JsonToken.END_ARRAY) { + return null; + } + if ((t == JsonToken.VALUE_STRING || t == JsonToken.VALUE_EMBEDDED_OBJECT) + && context.isEnabled(DeserializationFeature.UNWRAP_SINGLE_VALUE_ARRAYS)) { + final LocalDateTime parsed = deserialize(parser, context); + if (parser.nextToken() != JsonToken.END_ARRAY) { + handleMissingEndArrayForSingle(parser, context); + } + return parsed; + } + if (t == JsonToken.VALUE_NUMBER_INT) { + LocalDateTime result; + + int year = parser.getIntValue(); + int month = parser.nextIntValue(-1); + int day = parser.nextIntValue(-1); + int hour = parser.nextIntValue(-1); + int minute = parser.nextIntValue(-1); + + t = parser.nextToken(); + if (t == JsonToken.END_ARRAY) { + result = LocalDateTime.of(year, month, day, hour, minute); + } else { + int second = parser.getIntValue(); + t = parser.nextToken(); + if (t == JsonToken.END_ARRAY) { + result = LocalDateTime.of(year, month, day, hour, minute, second); + } else { + int partialSecond = parser.getIntValue(); + if (partialSecond < 1_000 && + !context.isEnabled(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS)) { + // value is milliseconds, convert it to nanoseconds + partialSecond *= 1_000_000; + } + if (parser.nextToken() != JsonToken.END_ARRAY) { + throw context.wrongTokenException(parser, handledType(), JsonToken.END_ARRAY, "Expected array to end"); + } + result = LocalDateTime.of(year, month, day, hour, minute, second, partialSecond); + } + } + return result; + } + context.reportInputMismatch(handledType(), "Unexpected token (%s) within Array, expected VALUE_NUMBER_INT", t); + } + // 数字 + if (parser.hasToken(JsonToken.VALUE_NUMBER_INT)) { + return Instant.ofEpochMilli(parser.getLongValue()).atZone(ZoneOffset.ofHours(8)).toLocalDateTime(); + } + // 没看懂这个是啥 + if (parser.hasToken(JsonToken.VALUE_EMBEDDED_OBJECT)) { + return (LocalDateTime) parser.getEmbeddedObject(); + } + + return _handleUnexpectedToken(context, parser, "当前参数需要数组、字符串、时间戳。"); + } + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/common/converter/String2DateConverter.java b/kq-api/src/main/java/com/ningdatech/kqapi/common/converter/String2DateConverter.java new file mode 100644 index 0000000..dd3e772 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/common/converter/String2DateConverter.java @@ -0,0 +1,77 @@ +package com.ningdatech.kqapi.common.converter; + +import com.ningdatech.kqapi.common.exception.BizException; +import lombok.extern.slf4j.Slf4j; +import org.springframework.core.convert.converter.Converter; +import org.springframework.lang.NonNull; +import org.springframework.lang.Nullable; + +import java.text.DateFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.LinkedHashMap; +import java.util.Map; + +import static com.ningdatech.kqapi.common.exception.BaseException.BASE_VALID_PARAM; +import static com.ningdatech.kqapi.common.util.NdDateUtils.*; + + +/** + * 解决入参为 Date类型 + * + * @author WendyYang + * @date 2019-04-30 + */ +@Slf4j +public class String2DateConverter extends BaseDateConverter implements Converter { + + protected static final Map FORMAT = new LinkedHashMap<>(15); + + static { + FORMAT.put(DEFAULT_YEAR_FORMAT, "^\\d{4}"); + FORMAT.put(DEFAULT_MONTH_FORMAT, "^\\d{4}-\\d{1,2}$"); + FORMAT.put(DEFAULT_DATE_FORMAT, DEFAULT_DATE_FORMAT_MATCHES); + FORMAT.put("yyyy-MM-dd HH", "^\\d{4}-\\d{1,2}-\\d{1,2} {1}\\d{1,2}"); + FORMAT.put("yyyy-MM-dd HH:mm", "^\\d{4}-\\d{1,2}-\\d{1,2} {1}\\d{1,2}:\\d{1,2}$"); + FORMAT.put(DEFAULT_DATE_TIME_FORMAT, DEFAULT_DATE_TIME_FORMAT_MATCHES); + FORMAT.put(DEFAULT_MONTH_FORMAT_SLASH, "^\\d{4}/\\d{1,2}$"); + FORMAT.put(SLASH_DATE_FORMAT, SLASH_DATE_FORMAT_MATCHES); + FORMAT.put("yyyy/MM/dd HH", "^\\d{4}/\\d{1,2}/\\d{1,2} {1}\\d{1,2}"); + FORMAT.put("yyyy/MM/dd HH:mm", "^\\d{4}/\\d{1,2}/\\d{1,2} {1}\\d{1,2}:\\d{1,2}$"); + FORMAT.put(SLASH_DATE_TIME_FORMAT, SLASH_DATE_TIME_FORMAT_MATCHES); + FORMAT.put(DEFAULT_DATE_FORMAT_EN, DEFAULT_DATE_FORMAT_EN_MATCHES); + FORMAT.put(DEFAULT_DATE_TIME_FORMAT_EN, DEFAULT_DATE_TIME_FORMAT_EN_MATCHES); + } + + /** + * 格式化日期 + * + * @param dateStr String 字符型日期 + * @param format String 格式 + * @return Date 日期 + */ + protected static Date parseDate(String dateStr, String format) { + try { + DateFormat dateFormat = new SimpleDateFormat(format); + //严格模式 + dateFormat.setLenient(false); + return dateFormat.parse(dateStr); + } catch (ParseException e) { + log.info("转换日期失败, date={}, format={}", dateStr, format, e); + throw new BizException(BASE_VALID_PARAM, e.getMessage(), e); + } + } + + @Override + protected Map getFormat() { + return FORMAT; + } + + @Override + @Nullable + public Date convert(@NonNull String source) { + return super.convert(source, key -> parseDate(source, key)); + } + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/common/converter/String2LocalDateConverter.java b/kq-api/src/main/java/com/ningdatech/kqapi/common/converter/String2LocalDateConverter.java new file mode 100644 index 0000000..55ebb74 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/common/converter/String2LocalDateConverter.java @@ -0,0 +1,40 @@ +package com.ningdatech.kqapi.common.converter; + +import org.springframework.core.convert.converter.Converter; +import org.springframework.lang.NonNull; + +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; +import java.util.LinkedHashMap; +import java.util.Map; + +import static com.ningdatech.kqapi.common.util.NdDateUtils.*; + +/** + * 解决入参为 Date类型 + * + * @author WendyYang + * @date 2019-04-30 + */ +public class String2LocalDateConverter extends BaseDateConverter implements Converter { + + protected static final Map FORMAT = new LinkedHashMap<>(5); + + static { + FORMAT.put(DEFAULT_DATE_FORMAT, DEFAULT_DATE_FORMAT_MATCHES); + FORMAT.put(SLASH_DATE_FORMAT, SLASH_DATE_FORMAT_MATCHES); + FORMAT.put(DEFAULT_DATE_FORMAT_EN, DEFAULT_DATE_FORMAT_EN_MATCHES); + } + + @Override + protected Map getFormat() { + return FORMAT; + } + + @Override + public LocalDate convert(@NonNull String source) { + return super.convert(source, (key) -> LocalDate.parse(source, DateTimeFormatter.ofPattern(key))); + } + +} + diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/common/converter/String2LocalDateTimeConverter.java b/kq-api/src/main/java/com/ningdatech/kqapi/common/converter/String2LocalDateTimeConverter.java new file mode 100644 index 0000000..3cbe5e7 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/common/converter/String2LocalDateTimeConverter.java @@ -0,0 +1,38 @@ +package com.ningdatech.kqapi.common.converter; + +import org.springframework.core.convert.converter.Converter; +import org.springframework.lang.NonNull; + +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.LinkedHashMap; +import java.util.Map; + +import static com.ningdatech.kqapi.common.util.NdDateUtils.*; + +/** + * 解决入参为 Date类型 + * + * @author WendyYang + * @date 2019-04-30 + */ +public class String2LocalDateTimeConverter extends BaseDateConverter implements Converter { + + protected static final Map FORMAT = new LinkedHashMap<>(5); + + static { + FORMAT.put(DEFAULT_DATE_TIME_FORMAT, DEFAULT_DATE_TIME_FORMAT_MATCHES); + FORMAT.put(SLASH_DATE_TIME_FORMAT, SLASH_DATE_TIME_FORMAT_MATCHES); + FORMAT.put(DEFAULT_DATE_TIME_FORMAT_EN, DEFAULT_DATE_TIME_FORMAT_EN_MATCHES); + } + + @Override + protected Map getFormat() { + return FORMAT; + } + + @Override + public LocalDateTime convert(@NonNull String source) { + return super.convert(source, (key) -> LocalDateTime.parse(source, DateTimeFormatter.ofPattern(key))); + } +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/common/converter/String2LocalTimeConverter.java b/kq-api/src/main/java/com/ningdatech/kqapi/common/converter/String2LocalTimeConverter.java new file mode 100644 index 0000000..c372d21 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/common/converter/String2LocalTimeConverter.java @@ -0,0 +1,36 @@ +package com.ningdatech.kqapi.common.converter; + +import org.springframework.core.convert.converter.Converter; + +import java.time.LocalTime; +import java.time.format.DateTimeFormatter; +import java.util.LinkedHashMap; +import java.util.Map; + +import static com.ningdatech.kqapi.common.util.NdDateUtils.DEFAULT_TIME_FORMAT; + +/** + * 解决入参为 Date类型 + * + * @author WendyYang + * @date 2019-04-30 + */ +@SuppressWarnings("all") +public class String2LocalTimeConverter extends BaseDateConverter implements Converter { + + protected static final Map FORMAT = new LinkedHashMap<>(5); + + static { + FORMAT.put(DEFAULT_TIME_FORMAT, "^\\d{1,2}:\\d{1,2}:\\d{1,2}$"); + } + + @Override + protected Map getFormat() { + return FORMAT; + } + + @Override + public LocalTime convert(String source) { + return super.convert(source, (key) -> LocalTime.parse(source, DateTimeFormatter.ofPattern(key))); + } +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/common/enumeration/BoolDisplayEnum.java b/kq-api/src/main/java/com/ningdatech/kqapi/common/enumeration/BoolDisplayEnum.java new file mode 100644 index 0000000..9c45703 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/common/enumeration/BoolDisplayEnum.java @@ -0,0 +1,32 @@ +package com.ningdatech.kqapi.common.enumeration; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * @author liuxinxin + * @date 2022/7/26 上午9:21 + */ +@AllArgsConstructor +@Getter +public enum BoolDisplayEnum { + + /** + * true + */ + Y, + + /** + * false + */ + N; + + public static boolean judgeBoolean(String key) { + return Y.name().equals(key); + } + + public static BoolDisplayEnum judgeBoolean(boolean key) { + return key ? Y : N; + } + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/common/enumeration/CommonEnum.java b/kq-api/src/main/java/com/ningdatech/kqapi/common/enumeration/CommonEnum.java new file mode 100644 index 0000000..753c33b --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/common/enumeration/CommonEnum.java @@ -0,0 +1,39 @@ +package com.ningdatech.kqapi.common.enumeration; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * @author zpf + * @date 2023/3/12 上午9:21 + */ +@AllArgsConstructor +@Getter +public enum CommonEnum { + /** + * 公共的一些枚举 + */ + YES(1,"是",1), + NO(0,"否",1), + + LS_SBJ(331100,"市本级",2), + LS_LD(331102,"莲都区",2), + LS_QT(331121,"青田县",2), + LS_JY(331122,"缙云县",2), + LS_SC(331123,"遂昌县",2), + LS_SY(331124,"松阳县",2), + LS_YH(331125,"云和县",2), + LS_QY(331126,"庆元县",2), + LS_JN(331127,"景宁畲族自治县",2), + LS_LQ(331181,"龙泉市",2), + LS_KFQ(331199,"开发区",2), + ZWDD(0,"浙政钉",3), + MOBILE(1,"短信",3); + + private Integer code; + private String desc; + private Integer groupId; + + + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/common/enumeration/ExportOptionEnum.java b/kq-api/src/main/java/com/ningdatech/kqapi/common/enumeration/ExportOptionEnum.java new file mode 100644 index 0000000..9185c77 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/common/enumeration/ExportOptionEnum.java @@ -0,0 +1,157 @@ +package com.ningdatech.kqapi.common.enumeration; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; + + +/** + * 导出选项枚举 + * + * @author CMM + * @since 2023/02/10 16:38 + */ +@Getter +@AllArgsConstructor +@NoArgsConstructor +public enum ExportOptionEnum { + /** + * 导出选项 + */ + id(1, "项目ID"), + + projectName(2, "项目名称"), + + areaCode(3, "行政区划编码"), + + area(4, "行政区划名称"), + + responsibleMan(5, "项目负责人"), + + responsibleManMobile(6, "项目负责人手机号"), + + contactName(7, "项目联系人"), + + contactPhone(8, "项目联系人手机号"), + + higherSuperOrg(9, "上级业务主管单位"), + + higherSuperOrgCode(10, "上级主管单位浙政钉ID"), + + superOrg(11, "本级主管部门"), + + superOrgCode(12, "本级主管部门浙政钉ID"), + + buildOrgName(13, "建设单位名称"), + + buildOrgZheJiangGovDingId(14, "建设单位浙政钉ID"), + + orgCreditCode(15, "建设单位统一信用代码"), + + projectType(16, "项目类型"), + + isFirst(17, "是否首次新建"), + + relatedExistsApplication(18, "关联应用"), + + relatedExistsApplicationCode(19, "关联应用IRS编码"), + + declareAmount(20, "申报金额"), + + approvedTotalInvestmentIncrease(21, "批复金额"), + + /** + * 表里没有 + */ + budgetSource(22, "预算来源"), + + projectYear(23, "预算年度"), + + projectIntroduction(24, "项目简介"), + + buildBasis(25, "立项依据"), + + buildLevel(26, "建设层级"), + + developCode(27, "发改编码"), + + financialCode(28, "财政编码"), + + /** + * 表里没有 + */ + informationValidity(29, "信息是否有效"), + + + isDigitalReform(30, "是否数字化改革项目"), + + bizDomain(31, "综合应用领域"), + + isCloud(32, "是否上云"), + + cloudType(33, "云类型"), + + fourSystems(34, "四大体系"), + isTemporaryAugment(35, "是否临时增补"), + + protectionLevel(36, "等保级别"), + + isSecretComments(37, "是否密评"), + + businessNumber(38, "业务编号"), + + businessName(39, "业务名称"), + + orgName(40, "单位名称"), + + softwareDevelopmentAmount(41, "软件开发"), + + cloudHardwarePurchaseAmount(42, "云资源、硬件购置"), + + thirdPartyAmount(43, "第三方服务"), + + safetyInputTitle(44, "投入项"), + + safetyInputDescribe(45, "内容描述"), + + safetyInputAmount(46, "金额"), + + annualPlanAmount(47, "年度支付金额"), + + annualPlanHaveAmount(48, "自有资金"), + + declareGovOwnFinanceAmount(49, "政府投资-本级财政资金"), + + declareGovSuperiorFinanceAmount(50, "政府投资-上级补助资金"), + + declareBankLendingAmount(51, "银行贷款"), + + declareOtherAmount(52, "其它资金"), + + engineeringSpeedOne(53, "第一季度"), + + engineeringSpeedTwo(54, "第二季度"), + + engineeringSpeedThree(55, "第三季度"), + + engineeringSpeedFour(56, "第四季度"), + + preliminaryPlanFile(57, "初步方案"), + + supportingMaterialsFile(58, "附件-佐证材料"), + + projectRemarks(59, "备注"), + processStatusName(60, "流程状态名称"), + processLaunchTime(61,"流程发起时间"), + processHandleTime(62,"流程处理时间"), + + projectStatusName(63,"项目状态名称"), + + createOn(64,"创建时间"), + + updateOn(65,"更新时间"); + + + private Integer code; + private String desc; +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/common/enumeration/IEnum.java b/kq-api/src/main/java/com/ningdatech/kqapi/common/enumeration/IEnum.java new file mode 100644 index 0000000..93354ee --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/common/enumeration/IEnum.java @@ -0,0 +1,42 @@ +package com.ningdatech.kqapi.common.enumeration; + +import java.util.Arrays; +import java.util.Optional; + +/** + *

+ * IEnum-通用枚举类接口 + *

+ * + * @author WendyYang + * @since 10:10 2024/4/22 + */ +public interface IEnum & IEnum> { + + E[] all(); + + C getCode(); + + V getDesc(); + + default boolean eq(C code) { + return getCode().equals(code); + } + + default Optional getByCode(C code) { + return Arrays.stream(all()) + .filter(w -> w.getCode().equals(code)) + .findFirst(); + } + + default E getNoNull(C code) { + return Arrays.stream(all()) + .filter(w -> w.getCode().equals(code)).findFirst() + .orElseThrow(() -> new IllegalArgumentException("编码对应枚举值不存在")); + } + + default V getDesc(C code) { + return getByCode(code).flatMap(w -> Optional.of(w.getDesc())).orElse(null); + } + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/common/enumeration/ImplSubjectNatureEnum.java b/kq-api/src/main/java/com/ningdatech/kqapi/common/enumeration/ImplSubjectNatureEnum.java new file mode 100644 index 0000000..7242c52 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/common/enumeration/ImplSubjectNatureEnum.java @@ -0,0 +1,30 @@ +package com.ningdatech.kqapi.common.enumeration; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + *

+ * ImplSubjectNatureEnum + *

+ * + * @author WendyYang + * @since 10:39 2024/4/22 + */ +@Getter +@AllArgsConstructor +public enum ImplSubjectNatureEnum implements IEnum { + + STATUTORY_AUTHORITIES(1, "法定机关"), + THIRD_PARTY_INTERMEDIARIES(2, "第三方中介服务"); + + private final Integer code; + private final String desc; + + + @Override + public ImplSubjectNatureEnum[] all() { + return values(); + } + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/common/enumeration/ProjectProcessStageEnum.java b/kq-api/src/main/java/com/ningdatech/kqapi/common/enumeration/ProjectProcessStageEnum.java new file mode 100644 index 0000000..8c2d16e --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/common/enumeration/ProjectProcessStageEnum.java @@ -0,0 +1,39 @@ +package com.ningdatech.kqapi.common.enumeration; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import org.apache.commons.lang3.StringUtils; + +import java.util.Objects; + +@Getter +@AllArgsConstructor +@NoArgsConstructor +public enum ProjectProcessStageEnum { + /** + * 项目流程配置 阶段枚举 + */ + ORG_INTERNAL_APPROVAL_PROCESS(1,"单位内部审批流程"), + PROJECT_PREQUALIFICATION_APPROVAL_PROCESS(2,"项目预审审批流程"), + DEPARTMENT_JOINT_APPROVAL_PROCESS(3,"部门联合审批流程"), + CONSTRUCTION_PROJECT_APPROVAL_PROCESS(4,"建设方案审批流程"), + ACCEPTANCE_DECLARATION_APPROVAL_PROCESS(5,"验收申报审批流程"), + APPLY_DELAY(6,"申请延期审批流程"), + APPLY_BORROW(7,"申请借阅审批流程"); + + private Integer code; + private String desc; + + public static String getDesc(Integer code) { + if (Objects.isNull(code)) { + return StringUtils.EMPTY; + } + for (ProjectProcessStageEnum t : ProjectProcessStageEnum.values()) { + if (code.equals(t.getCode())) { + return t.desc; + } + } + return StringUtils.EMPTY; + } +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/common/errorcode/AppErrorCode.java b/kq-api/src/main/java/com/ningdatech/kqapi/common/errorcode/AppErrorCode.java new file mode 100644 index 0000000..76df261 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/common/errorcode/AppErrorCode.java @@ -0,0 +1,24 @@ +package com.ningdatech.kqapi.common.errorcode; + +import lombok.Getter; + +/** + * @author LiuXinXin + */ +@Getter +public enum AppErrorCode { + USER(100), + + AUTH(101); + + private final Integer code; + + AppErrorCode(Integer code) { + this.code = code; + } + + public Integer getCode() { + return code; + } + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/common/exception/ArgumentException.java b/kq-api/src/main/java/com/ningdatech/kqapi/common/exception/ArgumentException.java new file mode 100644 index 0000000..16a9ab5 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/common/exception/ArgumentException.java @@ -0,0 +1,38 @@ +package com.ningdatech.kqapi.common.exception; + + +import com.ningdatech.kqapi.common.exception.code.ExceptionCode; + +/** + * 业务参数异常 + * 用于在业务中,检测到非法参数时,进行抛出的异常。 + * + * @author WendyYang + * @version 3.5.0 + */ +public class ArgumentException extends BaseUncheckedException { + + private static final long serialVersionUID = -3843907364558373817L; + + public ArgumentException(Throwable cause) { + super(cause); + } + + public ArgumentException(String message) { + super(ExceptionCode.BASE_VALID_PARAM.getCode(), message); + } + + public ArgumentException(String message, Throwable cause) { + super(ExceptionCode.BASE_VALID_PARAM.getCode(), message, cause); + } + + public ArgumentException(final String format, Object... args) { + super(ExceptionCode.BASE_VALID_PARAM.getCode(), format, args); + } + + @Override + public String toString() { + return "ArgumentException [message=" + getMessage() + ", code=" + getCode() + "]"; + } + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/common/exception/BaseCheckedException.java b/kq-api/src/main/java/com/ningdatech/kqapi/common/exception/BaseCheckedException.java new file mode 100644 index 0000000..2a80406 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/common/exception/BaseCheckedException.java @@ -0,0 +1,57 @@ +package com.ningdatech.kqapi.common.exception; + +/** + * 运行期异常基类 + * + * @author WendyYang + * @version 1.0 + */ +public abstract class BaseCheckedException extends Exception implements BaseException { + + private static final long serialVersionUID = 2706069899924648586L; + + /** + * 异常信息 + */ + private String message; + + /** + * 具体异常码 + */ + private int code; + + public BaseCheckedException(final int code, final String message) { + super(message); + this.code = code; + this.message = message; + } + + public BaseCheckedException(final int code, final String format, Object... args) { + super(String.format(format, args)); + this.code = code; + this.message = String.format(format, args); + } + + /** + * 获取 异常消息 + * + * @return 异常消息 + */ + @Override + public String getMessage() { + return message; + } + + + /** + * 获取 错误码 + * + * @return 错误码 + */ + @Override + public int getCode() { + return code; + } + + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/common/exception/BaseException.java b/kq-api/src/main/java/com/ningdatech/kqapi/common/exception/BaseException.java new file mode 100644 index 0000000..1984e77 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/common/exception/BaseException.java @@ -0,0 +1,30 @@ +package com.ningdatech.kqapi.common.exception; + +/** + * 异常接口类 + * + * @author WendyYang + * @version 1.0 + */ +public interface BaseException { + + /** + * 统一参数验证异常码 + */ + int BASE_VALID_PARAM = -9; + + /** + * 返回异常信息 + * + * @return 异常信息 + */ + String getMessage(); + + /** + * 返回异常编码 + * + * @return 异常编码 + */ + int getCode(); + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/common/exception/BaseUncheckedException.java b/kq-api/src/main/java/com/ningdatech/kqapi/common/exception/BaseUncheckedException.java new file mode 100644 index 0000000..7a848dc --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/common/exception/BaseUncheckedException.java @@ -0,0 +1,65 @@ +package com.ningdatech.kqapi.common.exception; + +import cn.hutool.core.util.StrUtil; +import com.ningdatech.kqapi.common.util.StrPool; + +/** + * 非运行期异常基类,所有自定义非运行时异常继承该类 + * + * @author WendyYang + * @version 1.0 + * @see RuntimeException + */ +public class BaseUncheckedException extends RuntimeException implements BaseException { + + private static final long serialVersionUID = -778887391066124051L; + + /** + * 异常信息 + */ + private String message; + + /** + * 具体异常码 + */ + private int code; + + public BaseUncheckedException(Throwable cause) { + super(cause); + } + + public BaseUncheckedException(final int code, Throwable cause) { + super(cause); + this.code = code; + } + + + public BaseUncheckedException(final int code, final String message) { + super(message); + this.code = code; + this.message = message; + } + + public BaseUncheckedException(final int code, final String message, Throwable cause) { + super(cause); + this.code = code; + this.message = message; + } + + public BaseUncheckedException(final int code, final String format, Object... args) { + super(StrUtil.contains(format, StrPool.BRACE) ? StrUtil.format(format, args) : String.format(format, args)); + this.code = code; + this.message = StrUtil.contains(format, StrPool.BRACE) ? StrUtil.format(format, args) : String.format(format, args); + } + + + @Override + public String getMessage() { + return message; + } + + @Override + public int getCode() { + return code; + } +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/common/exception/BizException.java b/kq-api/src/main/java/com/ningdatech/kqapi/common/exception/BizException.java new file mode 100644 index 0000000..1225466 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/common/exception/BizException.java @@ -0,0 +1,78 @@ +package com.ningdatech.kqapi.common.exception; + + +import com.ningdatech.kqapi.common.exception.code.BaseExceptionCode; + +/** + * 业务异常 + * 用于在处理业务逻辑时,进行抛出的异常。 + * + * @author WendyYang + * @version 1.0 + */ +public class BizException extends BaseUncheckedException { + + private static final long serialVersionUID = -3843907364558373817L; + + public BizException(Throwable cause) { + super(cause); + } + + public BizException(int code, Throwable cause) { + super(code, cause); + } + + public BizException(String message) { + super(-1, message); + } + + public BizException(String message, Throwable cause) { + super(-1, message, cause); + } + + public BizException(int code, String message) { + super(code, message); + } + + public BizException(int code, String message, Throwable cause) { + super(code, message, cause); + } + + public BizException(int code, String message, Object... args) { + super(code, message, args); + } + + /** + * 实例化异常 + * + * @param code 自定义异常编码 + * @param message 自定义异常消息 + * @param args 已定义异常参数 + * @return 异常实例 + */ + public static BizException wrap(int code, String message, Object... args) { + return new BizException(code, message, args); + } + + public static BizException wrap(String message, Object... args) { + return new BizException(-1, message, args); + } + + public static BizException validFail(String message, Object... args) { + return new BizException(-9, message, args); + } + + public static BizException wrap(BaseExceptionCode ex) { + return new BizException(ex.getCode(), ex.getMsg()); + } + + public static BizException wrap(BaseExceptionCode ex, Throwable cause) { + return new BizException(ex.getCode(), ex.getMsg(), cause); + } + + @Override + public String toString() { + return "BizException [message=" + getMessage() + ", code=" + getCode() + "]"; + } + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/common/exception/CommonException.java b/kq-api/src/main/java/com/ningdatech/kqapi/common/exception/CommonException.java new file mode 100644 index 0000000..e14a447 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/common/exception/CommonException.java @@ -0,0 +1,30 @@ +package com.ningdatech.kqapi.common.exception; + +/** + * 非业务异常 + * 用于在处理非业务逻辑时,进行抛出的异常。 + * + * @author WendyYang + * @version 1.0 + * @see Exception + */ +public class CommonException extends BaseCheckedException { + + + public CommonException(int code, String message) { + super(code, message); + } + + public CommonException(int code, String format, Object... args) { + super(code, format, args); + } + + public CommonException wrap(int code, String format, Object... args) { + return new CommonException(code, format, args); + } + + @Override + public String toString() { + return "BizException [message=" + getMessage() + ", code=" + getCode() + "]"; + } +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/common/exception/DownloadException.java b/kq-api/src/main/java/com/ningdatech/kqapi/common/exception/DownloadException.java new file mode 100644 index 0000000..0397cff --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/common/exception/DownloadException.java @@ -0,0 +1,27 @@ +package com.ningdatech.kqapi.common.exception; + +import com.ningdatech.kqapi.common.exception.code.ExceptionCode; + +/** + *

+ * DownloadException + *

+ * + * @author WendyYang + * @since 16:02 2024/1/8 + */ +public class DownloadException extends BaseUncheckedException { + + public DownloadException(Throwable cause) { + super(cause); + } + + public DownloadException(String message, Object... args) { + super(ExceptionCode.BAD_REQUEST.getCode(), message, args); + } + + public static DownloadException wrap(String message, Object... args) { + return new DownloadException(message, args); + } + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/common/exception/ExportException.java b/kq-api/src/main/java/com/ningdatech/kqapi/common/exception/ExportException.java new file mode 100644 index 0000000..16b76bc --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/common/exception/ExportException.java @@ -0,0 +1,28 @@ +package com.ningdatech.kqapi.common.exception; + + +import com.ningdatech.kqapi.common.exception.code.ExceptionCode; + +/** + *

+ * ExportException + *

+ * + * @author WendyYang + * @since 16:02 2024/1/8 + */ +public class ExportException extends BaseUncheckedException { + + public ExportException(Throwable cause) { + super(cause); + } + + public ExportException(String message, Object... args) { + super(ExceptionCode.BAD_REQUEST.getCode(), message, args); + } + + public static ExportException wrap(String message, Object... args) { + return new ExportException(message, args); + } + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/common/exception/ForbiddenException.java b/kq-api/src/main/java/com/ningdatech/kqapi/common/exception/ForbiddenException.java new file mode 100644 index 0000000..f744ca1 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/common/exception/ForbiddenException.java @@ -0,0 +1,33 @@ +package com.ningdatech.kqapi.common.exception; + +import com.ningdatech.kqapi.common.exception.code.BaseExceptionCode; +import com.ningdatech.kqapi.common.exception.code.ExceptionCode; + +/** + * 403 禁止访问 + * + * @author WendyYang + * @version 1.0 + */ +public class ForbiddenException extends BaseUncheckedException { + + private static final long serialVersionUID = 1L; + + public ForbiddenException(int code, String message) { + super(code, message); + } + + public static ForbiddenException wrap(BaseExceptionCode ex) { + return new ForbiddenException(ex.getCode(), ex.getMsg()); + } + + public static ForbiddenException wrap(String msg) { + return new ForbiddenException(ExceptionCode.FORBIDDEN.getCode(), msg); + } + + @Override + public String toString() { + return "ForbiddenException [message=" + getMessage() + ", code=" + getCode() + "]"; + } + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/common/exception/UnauthorizedException.java b/kq-api/src/main/java/com/ningdatech/kqapi/common/exception/UnauthorizedException.java new file mode 100644 index 0000000..3637283 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/common/exception/UnauthorizedException.java @@ -0,0 +1,33 @@ +package com.ningdatech.kqapi.common.exception; + + +import com.ningdatech.kqapi.common.exception.code.ExceptionCode; + +/** + * 401 未认证 未登录 + * + * @author WendyYang + * @version 1.0 + */ +public class UnauthorizedException extends BaseUncheckedException { + + private static final long serialVersionUID = 1L; + + public UnauthorizedException(int code, String message) { + super(code, message); + } + + public UnauthorizedException(int code, String message, Throwable cause) { + super(code, message, cause); + } + + public static UnauthorizedException wrap(String msg) { + return new UnauthorizedException(ExceptionCode.UNAUTHORIZED.getCode(), msg); + } + + @Override + public String toString() { + return "UnauthorizedException [message=" + getMessage() + ", code=" + getCode() + "]"; + } + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/common/exception/code/BaseExceptionCode.java b/kq-api/src/main/java/com/ningdatech/kqapi/common/exception/code/BaseExceptionCode.java new file mode 100644 index 0000000..eca67d6 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/common/exception/code/BaseExceptionCode.java @@ -0,0 +1,23 @@ +package com.ningdatech.kqapi.common.exception.code; + +/** + * 异常编码 + * + * @author WendyYang + * @date 2017-12-25 13:46 + */ +public interface BaseExceptionCode { + /** + * 异常编码 + * + * @return 异常编码 + */ + int getCode(); + + /** + * 异常消息 + * + * @return 异常消息 + */ + String getMsg(); +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/common/exception/code/ExceptionCode.java b/kq-api/src/main/java/com/ningdatech/kqapi/common/exception/code/ExceptionCode.java new file mode 100644 index 0000000..6a3ce13 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/common/exception/code/ExceptionCode.java @@ -0,0 +1,103 @@ +package com.ningdatech.kqapi.common.exception.code; + + +/** + * 异常编码 + * + * @author WendyYang + * @date 2017-12-13 16:22 + */ +public enum ExceptionCode implements BaseExceptionCode { + + //系统相关 start + SUCCESS(0, "成功"), + SYSTEM_BUSY(-1, "系统繁忙~请稍后再试~"), + SYSTEM_TIMEOUT(-2, "系统维护中~请稍后再试~"), + PARAM_EX(-3, "参数类型解析异常"), + SQL_EX(-4, "运行SQL出现异常"), + NULL_POINT_EX(-5, "空指针异常"), + ILLEGAL_ARGUMENT_EX(-6, "无效参数异常"), + MEDIA_TYPE_EX(-7, "请求类型异常"), + LOAD_RESOURCES_ERROR(-8, "加载资源出错"), + BASE_VALID_PARAM(-9, "统一验证参数异常"), + OPERATION_EX(-10, "操作异常"), + SERVICE_MAPPER_ERROR(-11, "Mapper类转换异常"), + CAPTCHA_ERROR(-12, "验证码校验失败"), + JSON_PARSE_ERROR(-13, "JSON解析异常"), + + + OK(200, "OK"), + BAD_REQUEST(400, "错误的请求"), + /** + * {@code 401 Unauthorized}. 需要重新登录。 + * 该HTTP状态码表示认证错误,它是为了认证设计的,而不是为了授权设计的。收到401响应,表示请求没有被认证—压根没有认证或者认证不正确—但是请重新认证和重试。(一般在响应头部包含一个WWW-Authenticate来描述如何认证)。通常由web服务器返回,而不是web应用。从性质上来说是临时的东西。(服务器要求客户端重试) + * + * @see HTTP/1.1: Authentication, section 3.1 + */ + UNAUTHORIZED(401, "未认证"), + /** 该HTTP状态码是关于授权方面的。从性质上来说是永久的东西,和应用的业务逻辑相关联。它比401更具体,更实际。收到403响应表示服务器完成认证过程,但是客户端请求没有权限去访问要求的资源。 */ + FORBIDDEN(403, "禁止访问"), + /** + * {@code 404 Not Found}. + * + * @see HTTP/1.1: Semantics and Content, section 6.5.4 + */ + NOT_FOUND(404, "没有找到资源"), + METHOD_NOT_ALLOWED(405, "不支持当前请求类型"), + + TOO_MANY_REQUESTS(429, "请求超过次数限制"), + INTERNAL_SERVER_ERROR(500, "内部服务错误"), + BAD_GATEWAY(502, "网关错误"), + GATEWAY_TIMEOUT(504, "网关超时"), + //系统相关 end + + REQUIRED_FILE_PARAM_EX(1001, "请求中必须至少包含一个有效文件"), + + DATA_SAVE_ERROR(2000, "新增数据失败"), + DATA_UPDATE_ERROR(2001, "修改数据失败"), + TOO_MUCH_DATA_ERROR(2002, "批量新增数据过多"), + //jwt token 相关 start + + JWT_BASIC_INVALID(40000, "无效的基本身份验证令牌"), + JWT_TOKEN_EXPIRED(40001, "会话超时,请重新登录"), + JWT_SIGNATURE(40002, "不合法的token,请认真比对 token 的签名"), + JWT_ILLEGAL_ARGUMENT(40003, "缺少token参数"), + JWT_GEN_TOKEN_FAIL(40004, "生成token失败"), + JWT_PARSER_TOKEN_FAIL(40005, "解析用户身份错误,请重新登录!"), + JWT_USER_INVALID(40006, "用户名或密码错误"), + JWT_USER_ENABLED(40007, "用户已经被禁用!"), + JWT_OFFLINE(40008, "您已在另一个设备登录!"), + JWT_NOT_LOGIN(40009, "登录超时,请重新登录!"), + //jwt token 相关 end + + ; + + private final int code; + private String msg; + + ExceptionCode(int code, String msg) { + this.code = code; + this.msg = msg; + } + + @Override + public int getCode() { + return code; + } + + @Override + public String getMsg() { + return msg; + } + + + public ExceptionCode build(String msg, Object... param) { + this.msg = String.format(msg, param); + return this; + } + + public ExceptionCode param(Object... param) { + msg = String.format(msg, param); + return this; + } +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/common/handler/BaseFieldFillHandler.java b/kq-api/src/main/java/com/ningdatech/kqapi/common/handler/BaseFieldFillHandler.java new file mode 100644 index 0000000..cf35c66 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/common/handler/BaseFieldFillHandler.java @@ -0,0 +1,49 @@ +package com.ningdatech.kqapi.common.handler; + +import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler; +import com.ningdatech.kqapi.user.util.LoginUserUtil; +import lombok.extern.slf4j.Slf4j; +import org.apache.ibatis.reflection.MetaObject; +import org.springframework.stereotype.Component; + +import java.time.LocalDateTime; + +import static com.ningdatech.kqapi.common.constant.BaseFieldConst.*; + + +/** + *

+ * BaseFieldFillHandler + *

+ * + * @author WendyYang + * @since 14:36 2024/4/20 + */ +@Slf4j +@Component +public class BaseFieldFillHandler implements MetaObjectHandler { + + private Long getUserId() { + if (LoginUserUtil.isLogin()) { + return LoginUserUtil.getUserId(); + } + return 0L; + } + + @Override + public void insertFill(MetaObject metaObject) { + long userId = getUserId(); + LocalDateTime now = LocalDateTime.now(); + this.fillStrategy(metaObject, CREATE_BY, userId); + this.fillStrategy(metaObject, CREATE_ON, now); + this.fillStrategy(metaObject, UPDATE_BY, userId); + this.fillStrategy(metaObject, UPDATE_ON, now); + } + + @Override + public void updateFill(MetaObject metaObject) { + this.fillStrategy(metaObject, UPDATE_BY, getUserId()); + this.fillStrategy(metaObject, UPDATE_ON, LocalDateTime.now()); + } + +} \ No newline at end of file diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/common/handler/GlobalExceptionHandler.java b/kq-api/src/main/java/com/ningdatech/kqapi/common/handler/GlobalExceptionHandler.java new file mode 100644 index 0000000..3ff67e0 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/common/handler/GlobalExceptionHandler.java @@ -0,0 +1,70 @@ +package com.ningdatech.kqapi.common.handler; + +import com.ningdatech.kqapi.common.exception.BizException; +import com.ningdatech.kqapi.common.model.ApiResponse; +import com.ningdatech.kqapi.common.model.Status; +import lombok.extern.slf4j.Slf4j; +import org.springframework.context.support.DefaultMessageSourceResolvable; +import org.springframework.http.HttpStatus; +import org.springframework.validation.BindException; +import org.springframework.web.bind.MethodArgumentNotValidException; +import org.springframework.web.bind.annotation.ControllerAdvice; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.servlet.NoHandlerFoundException; + +import javax.validation.ConstraintViolation; +import javax.validation.ConstraintViolationException; +import java.util.stream.Collectors; + +/** + *

+ * GlobalExceptionHandler + *

+ * + * @author WendyYang + * @since 15:16 2024/4/20 + */ +@Slf4j +@ControllerAdvice +@ResponseStatus(HttpStatus.BAD_REQUEST) +public class GlobalExceptionHandler { + + @ResponseBody + @ExceptionHandler(value = NoHandlerFoundException.class) + public ApiResponse noHandlerFoundException(NoHandlerFoundException e) { + return ApiResponse.ofStatus(Status.REQUEST_NOT_FOUND); + } + + @ResponseBody + @ExceptionHandler(value = {MethodArgumentNotValidException.class, BindException.class}) + public ApiResponse bindException(BindException e) { + String msg = e.getAllErrors().stream() + .map(DefaultMessageSourceResolvable::getDefaultMessage) + .collect(Collectors.joining(",")); + return ApiResponse.of(Status.BAD_REQUEST.getCode(), msg, null); + } + + @ResponseBody + @ExceptionHandler(value = ConstraintViolationException.class) + public ApiResponse constraintViolationException(ConstraintViolationException e) { + String msg = e.getConstraintViolations().stream() + .map(ConstraintViolation::getMessage) + .collect(Collectors.joining(",")); + return ApiResponse.of(Status.BAD_REQUEST.getCode(), msg, null); + } + + @ResponseBody + @ExceptionHandler(value = Exception.class) + public ApiResponse handlerException(Exception e) { + return ApiResponse.of(Status.BAD_REQUEST.getCode(), e.getMessage(), null); + } + + @ResponseBody + @ExceptionHandler(value = BizException.class) + public ApiResponse bizException(Exception e) { + return ApiResponse.of(Status.BAD_REQUEST.getCode(), e.getMessage(), null); + } + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/common/handler/GlobalResponseHandler.java b/kq-api/src/main/java/com/ningdatech/kqapi/common/handler/GlobalResponseHandler.java new file mode 100644 index 0000000..f6745b9 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/common/handler/GlobalResponseHandler.java @@ -0,0 +1,59 @@ +package com.ningdatech.kqapi.common.handler; + +import com.ningdatech.kqapi.common.model.ApiResponse; +import org.springframework.core.MethodParameter; +import org.springframework.http.MediaType; +import org.springframework.http.converter.HttpMessageConverter; +import org.springframework.http.server.ServerHttpRequest; +import org.springframework.http.server.ServerHttpResponse; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.RestControllerAdvice; +import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice; + +/** + *

+ * GlobalResponseHandler + *

+ * + * @author WendyYang + * @since 15:16 2024/4/20 + */ +@RestControllerAdvice(basePackages = { + "com.ningdatech.kqapi.admin.controller", + "com.ningdatech.kqapi.user.controller", + "com.ningdatech.kqapi.security.controller", + "com.ningdatech.kqapi.zzsfw.controller", + "com.ningdatech.kqapi.scheduler.controller" +}) +public class GlobalResponseHandler implements ResponseBodyAdvice { + + private static final String SWAGGER_CLASS_PREFIX = "springfox.documentation"; + + @Override + public boolean supports(MethodParameter methodParameter, + Class> aClass) { + return filter(methodParameter); + } + + @Override + public Object beforeBodyWrite(Object o, MethodParameter methodParameter, + MediaType mediaType, + Class> aClass, + ServerHttpRequest serverHttpRequest, + ServerHttpResponse serverHttpResponse) { + return ApiResponse.ofSuccess(o); + } + + private Boolean filter(MethodParameter methodParameter) { + Class declaringClass = methodParameter.getDeclaringClass(); + // swagger中的所有返回不进行统一封装 + if (declaringClass.getName().contains(SWAGGER_CLASS_PREFIX)) { + return false; + } + if (methodParameter.hasMethodAnnotation(ExceptionHandler.class)) { + return false; + } + // 如果本身就是使用ApiResponse返回,则不需要进行格式化 + return !methodParameter.getParameterType().equals(ApiResponse.class); + } +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/common/handler/MyBatisPlusConfig.java b/kq-api/src/main/java/com/ningdatech/kqapi/common/handler/MyBatisPlusConfig.java new file mode 100644 index 0000000..cf850e0 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/common/handler/MyBatisPlusConfig.java @@ -0,0 +1,29 @@ +package com.ningdatech.kqapi.common.handler; + +import com.baomidou.mybatisplus.annotation.DbType; +import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; +import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor; +import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class MyBatisPlusConfig { + + /** + * 插件配置 + * + * @return + */ + @Bean + public MybatisPlusInterceptor mybatisPlusInterceptor() { + MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); + + // 向MyBatis-Plus的过滤器链中添加分页拦截器,需要设置数据库类型(主要用于分页方言) +// interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.POSTGRE_SQL)); + interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL)); + // 添加乐观锁拦截器 + interceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor()); + return interceptor; + } +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/common/helper/MatterCacheHelper.java b/kq-api/src/main/java/com/ningdatech/kqapi/common/helper/MatterCacheHelper.java new file mode 100644 index 0000000..2510de0 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/common/helper/MatterCacheHelper.java @@ -0,0 +1,25 @@ +package com.ningdatech.kqapi.common.helper; + + +import com.ningdatech.kqapi.zzsfw.model.entity.KqZzsfwMattersDeduplicate; + +import java.util.List; + +/** + *

+ * MatterCacheHelper - + *

+ * + * @author ZPF + * @since 13:50 2024/1/3 + */ +public interface MatterCacheHelper { + + KqZzsfwMattersDeduplicate getMatter(String qlName, String webapplyurl); + + String getUrl(String qlName); + + List all(); + + Boolean refreshAll(); +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/common/helper/basic/AbstractMatterCacheHelper.java b/kq-api/src/main/java/com/ningdatech/kqapi/common/helper/basic/AbstractMatterCacheHelper.java new file mode 100644 index 0000000..fc73643 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/common/helper/basic/AbstractMatterCacheHelper.java @@ -0,0 +1,188 @@ +package com.ningdatech.kqapi.common.helper.basic; + +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.github.benmanes.caffeine.cache.Caffeine; +import com.github.benmanes.caffeine.cache.LoadingCache; +import com.google.common.collect.Lists; +import com.ningdatech.kqapi.common.constant.BizConst; +import com.ningdatech.kqapi.zzsfw.model.entity.ComponentsMatterEliminateEntity; +import com.ningdatech.kqapi.zzsfw.service.ComponentsMatterEliminateService; +import com.ningdatech.kqapi.zzsfw.model.entity.DscSxAdsShareItemQltQlsxCommonIDVKq; +import com.ningdatech.kqapi.zzsfw.model.entity.MatterKey; +import com.ningdatech.kqapi.zzsfw.model.entity.KqZzsfwMattersDeduplicate; +import com.ningdatech.kqapi.zzsfw.service.IDscSxAdsShareItemQltQlsxCommonIDVKqService; +import com.ningdatech.kqapi.zzsfw.service.IKqZzsfwMatterDeduplicateService; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.InitializingBean; +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.List; +import java.util.Objects; +import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; + +/** + *

+ * AbstractMatterCache + *

+ * + * @author ZPF + * @since 14:41 2023/3/1 + */ +@Slf4j +public abstract class AbstractMatterCacheHelper implements InitializingBean { + + @Autowired + private IDscSxAdsShareItemQltQlsxCommonIDVKqService kqService; + + @Autowired + private IKqZzsfwMatterDeduplicateService deduplicateService; + + protected LoadingCache mattersDupCache; + + protected LoadingCache mattersUrlCache; + + @Autowired + private ComponentsMatterEliminateService componentsMatterEliminateService; + + private final String KQ_ZZS_BASE_URL = "https://www.zjzwfw.gov.cn/zjservice-fe/#/workguide?localInnerCode=&siteCode=330000000000"; + + private Boolean initMatterCache() { + // 首先,查询ComponentsMatterEliminateEntity中isDelete不为1的qlName列表, 未被剔除 + List eliminatedQlNames = componentsMatterEliminateService.list( + Wrappers.lambdaQuery() + .select(ComponentsMatterEliminateEntity::getQlName) + .ne(ComponentsMatterEliminateEntity::getIsDelete, 1) + ).stream().map(ComponentsMatterEliminateEntity::getQlName).collect(Collectors.toList()); + + // 然后,使用eliminatedQlNames来过滤DscSxAdsShareItemQltQlsxCommonIDVKq查询 + List allMatters = kqService + .list(Wrappers.lambdaQuery() + .select(DscSxAdsShareItemQltQlsxCommonIDVKq::getRowguid, + DscSxAdsShareItemQltQlsxCommonIDVKq::getQlName, + DscSxAdsShareItemQltQlsxCommonIDVKq::getQlState, + DscSxAdsShareItemQltQlsxCommonIDVKq::getQlInnerCode, + DscSxAdsShareItemQltQlsxCommonIDVKq::getWebapplyurl) +// .eq(DscSxAdsShareItemQltQlsxCommonIDVKq::getQlState, "1") + .isNotNull(DscSxAdsShareItemQltQlsxCommonIDVKq::getWebapplyurl) + .isNotNull(DscSxAdsShareItemQltQlsxCommonIDVKq::getQlInnerCode) + .ne(DscSxAdsShareItemQltQlsxCommonIDVKq::getQlInnerCode, "") + .notIn(!eliminatedQlNames.isEmpty(), DscSxAdsShareItemQltQlsxCommonIDVKq::getQlName, eliminatedQlNames) // 过滤掉那些在eliminatedQlNames中的记录 + .orderByDesc(DscSxAdsShareItemQltQlsxCommonIDVKq::getUpdateDate)); + if (allMatters.isEmpty()) { + log.warn("事项数据未初始化"); + return Boolean.FALSE; + } + allMatters.forEach(m -> { + // 3-14日修改新的url匹配规则,取事项状态为1且qlInnerCode不为空的进行拼接,新的url规则如下 + String kq_url = KQ_ZZS_BASE_URL.replace("localInnerCode=", "localInnerCode=" + m.getQlInnerCode()); + MatterKey key = MatterKey.of(m.getQlName(),kq_url); + if(!mattersUrlCache.asMap().containsKey(m.getQlName())){ + mattersUrlCache.put(m.getQlName(),kq_url); + }else{ + String url = mattersUrlCache.get(m.getQlName()); + if(StringUtils.isNotBlank(url) && !url.equals(kq_url)){ + return; + } + } + if(mattersDupCache.asMap().containsKey(key)){ + KqZzsfwMattersDeduplicate dup = mattersDupCache.get(key); + dup.setCountNum(dup.getCountNum() + 1); + mattersDupCache.put(key,dup); + }else{ + mattersDupCache.put(key, KqZzsfwMattersDeduplicate.of(m.getQlName(),kq_url)); + } + }); + return Boolean.TRUE; + } + + protected KqZzsfwMattersDeduplicate get(String qlName, String url) { + MatterKey key = MatterKey.of(qlName, url); + return mattersDupCache.get(key); + } + + protected String getUrl(String qlName) { + return mattersUrlCache.get(qlName); + } + + protected List all() { + return Lists.newArrayList(mattersDupCache.asMap().values()); + } + + @Override + public void afterPropertiesSet() { + mattersUrlCache = Caffeine.newBuilder() + .refreshAfterWrite(7, TimeUnit.DAYS) + .maximumSize(1024 * 100) + .build(key -> { + KqZzsfwMattersDeduplicate dup = deduplicateService.getOne(Wrappers.lambdaQuery(KqZzsfwMattersDeduplicate.class) + .eq(KqZzsfwMattersDeduplicate::getQlName, key) + .last(BizConst.LIMIT_1) + .isNotNull(KqZzsfwMattersDeduplicate::getWebapplyurl)); + if (Objects.isNull(dup)) { + //查不到直接返回null + return null; + } + return dup.getWebapplyurl(); + }); + mattersDupCache = Caffeine.newBuilder() + .refreshAfterWrite(7, TimeUnit.DAYS) + .maximumSize(1024 * 100) + .build(key -> { + KqZzsfwMattersDeduplicate dup = deduplicateService.getOne(Wrappers.lambdaQuery(KqZzsfwMattersDeduplicate.class) + .eq(KqZzsfwMattersDeduplicate::getQlName, key) + .last(BizConst.LIMIT_1) + .isNotNull(KqZzsfwMattersDeduplicate::getWebapplyurl)); + if (Objects.isNull(dup)) { + //查不到直接返回null + return null; + } + return dup; + }); + // 初始化所有事项数据到缓存 +// initMatterCache(); + } + + public Boolean init() { + mattersUrlCache = Caffeine.newBuilder() + .refreshAfterWrite(7, TimeUnit.DAYS) + .maximumSize(1024 * 100) + .build(key -> { +// DscSxAdsShareItemQltQlsxCommonIDVKq matter = kqService.getOne(Wrappers.lambdaQuery(DscSxAdsShareItemQltQlsxCommonIDVKq.class) +// .eq(DscSxAdsShareItemQltQlsxCommonIDVKq::getQlName, key) +//// .eq(DscSxAdsShareItemQltQlsxCommonIDVKq::getQlState, "1") +//// .isNotNull(DscSxAdsShareItemQltQlsxCommonIDVKq::getQlInnerCodeItem) +// .isNotNull(DscSxAdsShareItemQltQlsxCommonIDVKq::getWebapplyurl) +// .orderByDesc(DscSxAdsShareItemQltQlsxCommonIDVKq::getUpdateDate) +// .last(BizConst.LIMIT_1) +// ); + KqZzsfwMattersDeduplicate dup = deduplicateService.getOne(Wrappers.lambdaQuery(KqZzsfwMattersDeduplicate.class) + .eq(KqZzsfwMattersDeduplicate::getQlName, key) + .last(BizConst.LIMIT_1) + .isNotNull(KqZzsfwMattersDeduplicate::getWebapplyurl)); + if (Objects.isNull(dup)) { + //查不到直接返回null + return null; + } + return dup.getWebapplyurl(); +// return "https://www.zjzwfw.gov.cn/zjservice-fe/#/workguide?localInnerCode="+ matter.getQlInnerCodeItem() +"&siteCode=330000000000"; + }); + mattersDupCache = Caffeine.newBuilder() + .refreshAfterWrite(7, TimeUnit.DAYS) + .maximumSize(1024 * 100) + .build(key -> { + KqZzsfwMattersDeduplicate dup = deduplicateService.getOne(Wrappers.lambdaQuery(KqZzsfwMattersDeduplicate.class) + .eq(KqZzsfwMattersDeduplicate::getQlName, key) + .last(BizConst.LIMIT_1) + .isNotNull(KqZzsfwMattersDeduplicate::getWebapplyurl)); + if (Objects.isNull(dup)) { + //查不到直接返回null + return null; + } + return dup; + }); + // 初始化所有事项数据到缓存 + return initMatterCache(); + } +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/common/helper/impl/MattersCacheHelperImpl.java b/kq-api/src/main/java/com/ningdatech/kqapi/common/helper/impl/MattersCacheHelperImpl.java new file mode 100644 index 0000000..066b5f5 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/common/helper/impl/MattersCacheHelperImpl.java @@ -0,0 +1,46 @@ +package com.ningdatech.kqapi.common.helper.impl; + +import com.ningdatech.kqapi.common.helper.MatterCacheHelper; +import com.ningdatech.kqapi.common.helper.basic.AbstractMatterCacheHelper; +import com.ningdatech.kqapi.zzsfw.model.entity.KqZzsfwMattersDeduplicate; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Component; + +import java.util.List; + +/** + * @author ZPF + * @date 2024/1/3 上午8:58 + */ +@Slf4j +@Component +public class MattersCacheHelperImpl extends AbstractMatterCacheHelper implements MatterCacheHelper { + + + @Override + public KqZzsfwMattersDeduplicate getMatter(String qlName, String webapplyurl) { + if (StringUtils.isBlank(qlName) || StringUtils.isBlank(webapplyurl)) { + return null; + } + return super.get(qlName, webapplyurl); + } + + @Override + public String getUrl(String qlName) { + if (StringUtils.isBlank(qlName)) { + return null; + } + return super.getUrl(qlName); + } + + @Override + public List all() { + return super.all(); + } + + @Override + public Boolean refreshAll() { + return super.init(); + } +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/common/model/ApiResponse.java b/kq-api/src/main/java/com/ningdatech/kqapi/common/model/ApiResponse.java new file mode 100644 index 0000000..e5968e4 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/common/model/ApiResponse.java @@ -0,0 +1,123 @@ +package com.ningdatech.kqapi.common.model; + +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + *

+ * ApiResponse - 统一的接口返回值封装 + *

+ * + * @author WendyYang + * @since 14:29 2022/9/29 + */ +@Data +@NoArgsConstructor +public class ApiResponse implements Serializable { + private static final long serialVersionUID = 532384723325394156L; + + public static final int SUCCESS_CODE = 200; + + public static final String SUCCESS_MSG = "success"; + + public static final int ERROR_CODE = 500; + + public static final String ERROR_MSG = "Internal server error"; + + /** + * 状态码 + */ + private Integer code; + + /** + * 返回内容 + */ + private String message; + + /** + * 返回数据 + */ + private T data; + + /** + * 全参构造函数 + * + * @param code 状态码 + * @param message 返回内容 + * @param data 返回数据 + */ + private ApiResponse(Integer code, String message, T data) { + this.code = code; + this.message = message; + this.data = data; + } + + /** + * 构造一个自定义的API返回 + * + * @param code 状态码 + * @param message 返回内容 + * @param data 返回数据 + * @return ApiResponse + */ + public static ApiResponse of(Integer code, String message, T data) { + return new ApiResponse(code, message, data); + } + + public static ApiResponse of(Integer code, String message) { + return of(code, message, null); + } + + /** + * 构造一个成功且不带数据的API返回 + * + * @return ApiResponse + */ + public static ApiResponse ofSuccess() { + return ofSuccess(null); + } + + /** + * 构造一个成功且带数据的API返回 + * + * @param data 返回数据 + * @return ApiResponse + */ + public static ApiResponse ofSuccess(T data) { + return ofStatus(Status.OK, data); + } + + /** + * 构造一个成功且自定义消息的API返回 + * + * @param message 返回内容 + * @return ApiResponse + */ + public static ApiResponse ofMessage(String message) { + return of(Status.OK.getCode(), message, null); + } + + /** + * 构造一个有状态的API返回 + * + * @param status 状态 {@link Status} + * @return ApiResponse + */ + public static ApiResponse ofStatus(ApiStatus status) { + return ofStatus(status, null); + } + + /** + * 构造一个有状态且带数据的API返回 + * + * @param status 状态 {@link Status} + * @param data 返回数据 + * @return ApiResponse + */ + public static ApiResponse ofStatus(ApiStatus status, T data) { + return of(status.getCode(), status.getReasonPhrase(), data); + } + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/common/model/ApiStatus.java b/kq-api/src/main/java/com/ningdatech/kqapi/common/model/ApiStatus.java new file mode 100644 index 0000000..d628085 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/common/model/ApiStatus.java @@ -0,0 +1,26 @@ +package com.ningdatech.kqapi.common.model; + +/** + *

+ * ApiStatus - 通用api状态 + *

+ * + * @author WendyYang + * @since 14:44 2022/9/29 + */ +public interface ApiStatus { + /** + * 获取code + * + * @return code + */ + Integer getCode(); + + /** + * 获取短语 + * + * @return 短语 + */ + String getReasonPhrase(); + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/common/model/PagePo.java b/kq-api/src/main/java/com/ningdatech/kqapi/common/model/PagePo.java new file mode 100644 index 0000000..7670a75 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/common/model/PagePo.java @@ -0,0 +1,30 @@ +package com.ningdatech.kqapi.common.model; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import lombok.Data; + +/** + *

+ * PagePo - 分页请求参数类 + *

+ * + * @author WendyYang + * @since 16:29 2022/9/14 + */ +@Data +public class PagePo { + + private Integer pageNumber = 1; + + private Integer pageSize = 10; + + public void page(Integer pageNumber, Integer pageSize) { + this.pageNumber = pageNumber; + this.pageSize = pageSize; + } + + public Page page() { + return Page.of(pageNumber, pageSize); + } + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/common/model/PageVo.java b/kq-api/src/main/java/com/ningdatech/kqapi/common/model/PageVo.java new file mode 100644 index 0000000..42825e3 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/common/model/PageVo.java @@ -0,0 +1,63 @@ +package com.ningdatech.kqapi.common.model; + +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; +import java.util.Collections; + +/** + *

+ * PageVo - 分页返回的包装对象 + *

+ * + * @author WendyYang + * @since 14:43 2022/9/29 + */ +@Data +@NoArgsConstructor +public class PageVo { + + private Collection records; + private Long total; + + private Boolean hasNextPage; + + public PageVo(Collection records, Boolean hasNextPage) { + this.records = records; + this.hasNextPage = hasNextPage; + } + + public PageVo(Collection records, Long total) { + this.records = records; + this.total = total; + } + + public void setTotal(Long total) { + this.total = total; + } + + public static PageVo of(Collection data, Long total) { + return new PageVo<>(data, total); + } + + public static PageVo of(Collection data, Integer total) { + return new PageVo<>(data, (long) total); + } + + /** + * 移动端无需展示总页码使用 + * + * @param data 分页数据 + * @param hasNextPage 是否有下一页 + * @author WendyYang + **/ + public static PageVo of(Collection data, Boolean hasNextPage) { + return new PageVo<>(data, hasNextPage); + } + + public static PageVo empty() { + return new PageVo<>(Collections.emptyList(), 0L); + } + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/common/model/Status.java b/kq-api/src/main/java/com/ningdatech/kqapi/common/model/Status.java new file mode 100644 index 0000000..192f7d8 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/common/model/Status.java @@ -0,0 +1,123 @@ +package com.ningdatech.kqapi.common.model; + +import lombok.Getter; + +/** + * @description: + * @author: liushuai + * @date: 2022/3/25 11:31 + */ +@Getter +public enum Status implements ApiStatus { + /** + * 正常 + */ + OK(200, "正常"), + /** + * 请求错误 + */ + BAD_REQUEST(400, "请求错误"), + /** + * Unauthorized + */ + NO_AUTHORIZATION(401, "未经授权的"), + /** + * 服务器解析不到用户请求的服务名称 + */ + REQUEST_NOT_FOUND(404, "服务不存在"), + /** + * 未知异常 + */ + UNKNOWN_ERROR(500, "服务器内部错误"), + /** + * 未定义异常 + */ + UNDEFINED(501, "未定义"), + /** + * 未定义异常 + */ + ERROR_PARAM(502, "您输入的参数有非法字符,请输入正确的参数"), + /** + * 该服务已下线 + */ + SERVICES_DISABLED(1, "服务未启用"), + /** + * 请求参数不能为空 + */ + PARAM_NOT_NULL(101, "请求参数不能为空"), + /** + * 字段名重复 + */ + COLUMN_REPEAT(112, "字段名重复,请重新填写"), + /** + * 参数不匹配 + */ + PARAM_NOT_MATCH(102, "参数不匹配"), + /** + * 权限认证参数 + */ + NO_AUT_PARAM(103, "权限参数不存在"), + /** + * 日期格式错误 + */ + DATE_FORMAT_EXCEPTION(104, "日期格式错误"), + /** + * 网络连接异常 + */ + CONNECTION_REFUSED(105, "连接拒绝"), + /** + * 登录失败 + */ + LOGIN_BAD(107, "用户登录失败,请确认用户信息"), + /** + * 流程删除失败 + */ + BAD_DELETE_PROCESS(106,"文件已进入流转流程,删除失败"), + /** + * 无可用端口 + */ + NO_PORT_AVAILABLE(111, "无可用端口"), + /** + * 文件下载异常 + */ + FILE_DOWNLOAD_EXCEPTION(607, "文件下载异常"), + /** + * 文件传输异常 + */ + FILE_TRANS_EXCEPTION(608, "文件传输异常"), + /** + * 文件名不存在 + */ + FILE_NAME_EXCEPTION(609, "文件名不存在"), + /** + * 文件名不存在 + */ + FILE_NAME_REPEAT(610, "文件名重复,请重新上传"), + /** + * 文件名不存在 + */ + FILE_DELETE_FAIL(611, "文件删除异常"), + /** + * 文件名不存在 + */ + FILE_NOT_SUPPORT(612, "不支持的文件类型,请重新上传"), + /** + * 文件名不存在 + */ + FILE_NOT_EXIT(613, "业务文件未上传,请上传业务文件"); + + /** + * 状态码 + */ + private final Integer code; + + /** + * 内容 + */ + private final String reasonPhrase; + + Status(Integer code, String reasonPhrase) { + this.code = code; + this.reasonPhrase = reasonPhrase; + } +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/common/model/entity/Item.java b/kq-api/src/main/java/com/ningdatech/kqapi/common/model/entity/Item.java new file mode 100644 index 0000000..62739be --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/common/model/entity/Item.java @@ -0,0 +1,30 @@ +package com.ningdatech.kqapi.common.model.entity; + +import lombok.Data; + +import javax.swing.*; +import java.io.Serializable; + +/** + * @Classname Item + * @Description + * @Date 2024/3/22 15:34 + * @Author PoffyZhang + */ +@Data +public class Item implements Serializable { + + private String roles; + private String permissions; + + private Boolean success; + + private String code; + + private ItemData data; + + @Data + public static class ItemData { + private Object item; + } +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/common/util/BizUtils.java b/kq-api/src/main/java/com/ningdatech/kqapi/common/util/BizUtils.java new file mode 100644 index 0000000..fc6e3f0 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/common/util/BizUtils.java @@ -0,0 +1,133 @@ +package com.ningdatech.kqapi.common.util; + +import cn.hutool.core.text.StrPool; +import cn.hutool.core.util.StrUtil; +import org.apache.commons.lang3.StringUtils; +import org.springframework.util.NumberUtils; + +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.time.LocalDateTime; +import java.time.ZoneId; +import java.util.*; +import java.util.function.Consumer; +import java.util.function.Function; +import java.util.stream.Collectors; + +import static java.util.stream.Collectors.toList; + +/** + *

+ * BizUtils + *

+ * + * @author WendyYang + * @since 17:32 2023/1/29 + */ +public class BizUtils { + + private BizUtils() { + + } + + public static > void notEmpty(T objs, Consumer consumer) { + if (objs != null && !objs.isEmpty()) { + consumer.accept(objs); + } + } + + public static List splitToNum(String str, Class aClass) { + if (StrUtil.isEmpty(str)) { + return Collections.emptyList(); + } + return Arrays.stream(str.split(StrPool.COMMA)) + .map(w -> NumberUtils.parseNumber(w, aClass)) + .collect(Collectors.toList()); + } + + public static List splitToLong(String str) { + return splitToNum(str, Long.class); + } + + + public static void notNull(T obj, Consumer consumer) { + if (obj != null) { + consumer.accept(obj); + } + } + + public static void notBlank(String str, Consumer consumer) { + if (StrUtil.isNotBlank(str)) { + consumer.accept(str); + } + } + + public static boolean getJSONType(String str) { + boolean result = false; + if (StringUtils.isNotBlank(str)) { + str = str.trim(); + if (str.startsWith("{") && str.endsWith("}")) { + result = true; + } else if (str.startsWith("[") && str.endsWith("]")) { + result = true; + } + } + return result; + } + + public static String uuid32() { + return UUID.randomUUID().toString().replace("-", ""); + } + + /** + * 对象分组取第一条 + * + * @param objs 对象集合 + * @param group 分组函数 + * @param comparator 比较器 + * @return java.util.Collection + * @author WendyYang + **/ + public static Collection groupFirst(Collection objs, Function group, Comparator comparator) { + return groupFirstMap(objs, group, comparator).values(); + } + + /** + * 对象分组取第一条 + * + * @param objs 对象集合 + * @param group 分组函数 + * @param comparator 比较器 + * @return java.util.Collection + * @author WendyYang + **/ + public static Map groupFirstMap(Collection objs, Function group, Comparator comparator) { + return objs.stream().collect(Collectors.groupingBy(group, + Collectors.collectingAndThen(toList(), w -> { + w.sort(comparator); + return w.get(0); + }))); + } + + public static LocalDateTime convertDate(Date date) { + if (Objects.nonNull(date)) { + return date.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime(); + } + return null; + } + + public static String computeRise(Integer numa, Integer numb) { + if((Objects.isNull(numb)|| numb.equals(0)) && + (Objects.isNull(numa)|| numa.equals(0))){ + return "0"; + } + if(Objects.isNull(numa) || numa.equals(0)){ + return "-100"; + } + if(Objects.isNull(numb)|| numb.equals(0)){ + return "100"; + } + return BigDecimal.valueOf((numa - numb) * 100.0).divide(BigDecimal.valueOf(numb),2, RoundingMode.CEILING) + .stripTrailingZeros().toPlainString(); + } +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/common/util/CallBack.java b/kq-api/src/main/java/com/ningdatech/kqapi/common/util/CallBack.java new file mode 100644 index 0000000..49f2bcd --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/common/util/CallBack.java @@ -0,0 +1,25 @@ +package com.ningdatech.kqapi.common.util; + +/** + * @author qinxianyun + * @see {@link SpringContextHolder} + * 针对某些初始化方法,在SpringContextHolder 初始化前时,
+ * 可提交一个 提交回调任务。
+ * 在SpringContextHolder 初始化后,进行回调使用 + */ + +public interface CallBack { + /** + * 回调执行方法 + */ + void executor(); + + /** + * 本回调任务名称 + * @return / + */ + default String getCallBackName() { + return Thread.currentThread().getId() + ":" + this.getClass().getName(); + } +} + diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/common/util/CodeUtil.java b/kq-api/src/main/java/com/ningdatech/kqapi/common/util/CodeUtil.java new file mode 100644 index 0000000..2373055 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/common/util/CodeUtil.java @@ -0,0 +1,27 @@ +package com.ningdatech.kqapi.common.util; + +import cn.hutool.core.text.StrPool; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; + +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.stream.Collectors; + +/** + * @Classname CodeUtil + * @Description + * @Date 2023/6/20 16:06 + * @Author PoffyZhang + */ +@Slf4j +public class CodeUtil { + + public static Collection convertStrToList(String str) { + if(StringUtils.isBlank(str)){ + return Collections.emptyList(); + } + return Arrays.stream(str.split(StrPool.COMMA)).collect(Collectors.toList()); + } +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/common/util/CommonInputStreamResource.java b/kq-api/src/main/java/com/ningdatech/kqapi/common/util/CommonInputStreamResource.java new file mode 100644 index 0000000..8e38ea9 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/common/util/CommonInputStreamResource.java @@ -0,0 +1,53 @@ +package com.ningdatech.kqapi.common.util; + +import org.springframework.core.io.InputStreamResource; + +import java.io.InputStream; + +public class CommonInputStreamResource extends InputStreamResource { + /*** + * 文件長度 + */ + private int length; + /*** + * 文件名稱 + */ + private String fileName; + public CommonInputStreamResource(InputStream inputStream) { + super(inputStream); + } + public CommonInputStreamResource(InputStream inputStream, int length,String fileName) { + super(inputStream); + this.length = length; + this.fileName = fileName; + } + /** + * 覆写父类方法 + * 如果不重写这个方法,并且文件有一定大小,那么服务端会出现异常 + * {@code The multi-part request contained parameter data (excluding uploaded files) that exceeded} + * + * @return + */ + @Override + public String getFilename() { + return this.fileName; + } + /** + * 覆写父类 contentLength 方法 + * 因为 {@link org.springframework.core.io.AbstractResource#contentLength()}方法会重新读取一遍文件, + * 而上传文件时,restTemplate 会通过这个方法获取大小。然后当真正需要读取内容的时候,发现已经读完,会报如下错误。 + * + * java.lang.IllegalStateException: InputStream has already been read - do not use InputStreamResource if a stream needs to be read multiple times + * at org.springframework.core.io.InputStreamResource.getInputStream(InputStreamResource.java:96) + * + *

+ * ref:com.amazonaws.services.s3.model.S3ObjectInputStream#available() + * + * @return + */ + @Override + public long contentLength() { + int estimate = length; + return estimate == 0 ? 1 : estimate; + } +} \ No newline at end of file diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/common/util/CryptUtils.java b/kq-api/src/main/java/com/ningdatech/kqapi/common/util/CryptUtils.java new file mode 100644 index 0000000..732ea34 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/common/util/CryptUtils.java @@ -0,0 +1,85 @@ +package com.ningdatech.kqapi.common.util; + +import org.apache.commons.codec.binary.Hex; + +import javax.crypto.Mac; +import javax.crypto.SecretKey; +import javax.crypto.spec.SecretKeySpec; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.security.InvalidKeyException; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; + +/** + * 加密工具 + * @author hank + */ +public class CryptUtils { + + /** + * 默认的算法 + */ + private static final String DE_KEY_MAC = "HmacMD5"; + + /** + * 默认的字符集 + */ + private static final Charset DE_CHARSET = StandardCharsets.UTF_8; + + + /** + * 使用默认的算法(HmacMD5) 得到hmac 16进制字符串 + * @param inputStr 需要加密的串 + * @param key key + * @return 16进制字符串 + * @throws Exception + */ + public static String encryptHMAC(String inputStr, String key) throws Exception { + return encryptHMAC(inputStr, key, DE_KEY_MAC); + } + /** + * 使用指定的算法得到hmac 16进制字符串 + * @param inputStr 需要加密的串 + * @param key key + * @param keyMac hmac算法 + * @return 16进制字符串 + * @throws Exception + */ + public static String encryptHMAC(String inputStr, String key, String keyMac) throws Exception { + return Hex.encodeHexString(encryptHMAC(inputStr.getBytes(DE_CHARSET), key, keyMac)); + } + + public static String MD5Encode(String origin) throws NoSuchAlgorithmException { + MessageDigest md = MessageDigest.getInstance("MD5"); + return Hex.encodeHexString(md.digest(origin.getBytes(DE_CHARSET))); + } + + private static byte[] encryptHMAC(byte[] data, String key, String keyMac) throws Exception { + + SecretKey secretKey = new SecretKeySpec(key.getBytes(DE_CHARSET), keyMac); + Mac mac = Mac.getInstance(secretKey.getAlgorithm()); + mac.init(secretKey); + return mac.doFinal(data); + } + + /** + * 生成HMAC-MD5值 + * @param data 消息数据 + * @param key 密钥 + * @return HMAC-MD5值 + * @throws NoSuchAlgorithmException + * @throws InvalidKeyException + */ + public static byte[] hmacMd5(byte[] data, byte[] key) + throws NoSuchAlgorithmException, InvalidKeyException { + SecretKeySpec signingKey = new SecretKeySpec(key, "HmacMD5"); + Mac mac = Mac.getInstance("HmacMD5"); + mac.init(signingKey); + return mac.doFinal(data); + } + + public static void main(String[] args) throws Exception{ + System.out.println("HMACStr:\n" + encryptHMAC("a", "hank")); + } +} \ No newline at end of file diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/common/util/HttpUtil.java b/kq-api/src/main/java/com/ningdatech/kqapi/common/util/HttpUtil.java new file mode 100644 index 0000000..e15b995 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/common/util/HttpUtil.java @@ -0,0 +1,218 @@ +package com.ningdatech.kqapi.common.util; + +import org.apache.http.HttpEntity; +import org.apache.http.NameValuePair; +import org.apache.http.client.config.RequestConfig; +import org.apache.http.client.entity.UrlEncodedFormEntity; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.conn.ssl.DefaultHostnameVerifier; +import org.apache.http.conn.util.PublicSuffixMatcher; +import org.apache.http.conn.util.PublicSuffixMatcherLoader; +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.util.EntityUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import java.io.IOException; +import java.net.URL; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +public class HttpUtil { + private Logger logger = LoggerFactory.getLogger(getClass()); + private RequestConfig requestConfig = RequestConfig.custom() + .setSocketTimeout(15000) + .setConnectTimeout(15000) + .setConnectionRequestTimeout(15000) + .build(); + private static HttpUtil instance = null; + private HttpUtil(){} + + public static HttpUtil getInstance(){ + if (instance == null) { + instance = new HttpUtil(); + } + return instance; + } + + /** + * 发送 post 请求 + * @param httpUrl 地址 + */ + public String sendHttpPost(String httpUrl) throws IOException { + HttpPost httpPost= new HttpPost(httpUrl);// 创建 httpPost + return sendHttpPost(httpPost); + } + + /** + * 发送 post 请求 + * @param httpUrl 地址 + * @param params 参数(格式:key1=value1&key2=value2) + */ + public String sendHttpPost(String httpUrl, String params) throws IOException { + HttpPost httpPost= new HttpPost(httpUrl);// 创建 httpPost + try { + //设置参数 + StringEntity stringEntity = new StringEntity(params, "UTF-8"); + stringEntity.setContentType("application/x-www-form-urlencoded"); + httpPost.setEntity(stringEntity); + } catch (Exception e) { + logger.error(e.getMessage()); + } + return sendHttpPost(httpPost); + } + + /** + * 发送 post 请求 + * @param httpUrl 地址 + * @param maps 参数 + */ + public String sendHttpPost(String httpUrl, Map maps) throws IOException { + HttpPost httpPost= new HttpPost(httpUrl);// 创建 httpPost + // 创建参数队列 + List nameValuePairs = new ArrayList(); + for (String key : maps.keySet()) { + nameValuePairs.add(new BasicNameValuePair(key, maps.get(key))); + } + try { + httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs, "UTF-8")); + } catch (Exception e) { + logger.error(e.getMessage()); + } + return sendHttpPost(httpPost); + } + + /** + * 发送 Post请求 + * @param httpPost + *@return + */ + private String sendHttpPost(HttpPost httpPost) throws IOException { + CloseableHttpClient httpClient = null; + CloseableHttpResponse response = null; + HttpEntity entity = null; + String responseContent = null; + try { + // 创建默认的 httpClient 实例. + httpClient = HttpClients.createDefault(); + httpPost.setConfig(requestConfig); + // 执行请求 + response = httpClient.execute(httpPost); + entity = response.getEntity(); + responseContent = EntityUtils.toString(entity, "UTF-8"); + } catch (Exception e) { + logger.error(e.getMessage()); + } finally { + httpClient.close(); + try { + // 关闭连接,释放资源 + if (response != null) { + response.close(); + } + if (httpClient != null) { + httpClient.close(); + } + } catch (IOException e) { + logger.error(e.getMessage()); + } + } + return responseContent; + } + + /** + * 发送 get 请求 + * @param httpUrl + */ + public String sendHttpGet(String httpUrl) throws IOException { + HttpGet httpGet = new HttpGet(httpUrl);// 创建 get 请求 + return sendHttpGet(httpGet); + } + + /** + * 发送 get请求 Https + * @param httpUrl + */ + public String sendHttpsGet(String httpUrl) { + HttpGet httpGet = new HttpGet(httpUrl);// 创建 get 请求 + return sendHttpsGet(httpGet); + } + + /** + * 发送 Get请求 + * @param httpGet + *@return + */ + private String sendHttpGet(HttpGet httpGet) throws IOException { + CloseableHttpClient httpClient = null; + CloseableHttpResponse response = null; + HttpEntity entity = null; + String responseContent = null; + try { + // 创建默认的 httpClient 实例. + httpClient = HttpClients.createDefault(); + httpGet.setConfig(requestConfig); + // 执行请求 + response = httpClient.execute(httpGet); + entity = response.getEntity(); + responseContent = EntityUtils.toString(entity, "UTF-8"); + } catch (Exception e) { + logger.error(e.getMessage()); + } finally { + httpClient.close(); + try { + // 关闭连接,释放资源 + if (response != null) { + response.close(); + } + if (httpClient != null) { + httpClient.close(); + } + } catch (IOException e) { + logger.error(e.getMessage()); + } + } + return responseContent; + } + + /** + * 发送 Get请求 Https + *@return + */ + private String sendHttpsGet(HttpGet httpGet) { + CloseableHttpClient httpClient = null; + CloseableHttpResponse response = null; + HttpEntity entity = null; + String responseContent = null; + try { + // 创建默认的 httpClient 实例. + PublicSuffixMatcher publicSuffixMatcher = PublicSuffixMatcherLoader.load(new + URL(httpGet.getURI().toString())); + DefaultHostnameVerifier hostnameVerifier = new DefaultHostnameVerifier(publicSuffixMatcher); + httpClient = HttpClients.custom().setSSLHostnameVerifier(hostnameVerifier).build(); + httpGet.setConfig(requestConfig); + // 执行请求 + response = httpClient.execute(httpGet); + entity = response.getEntity(); + responseContent = EntityUtils.toString(entity, "UTF-8"); + } catch (Exception e) { + logger.error(e.getMessage()); + } finally { + try { + // 关闭连接,释放资源 + if (response != null) { + response.close(); + } + if (httpClient != null) { + httpClient.close(); + } + } catch (IOException e) { + logger.error(e.getMessage()); + } + } + return responseContent; + } +} \ No newline at end of file diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/common/util/Md5Utils.java b/kq-api/src/main/java/com/ningdatech/kqapi/common/util/Md5Utils.java new file mode 100644 index 0000000..a91580b --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/common/util/Md5Utils.java @@ -0,0 +1,52 @@ +package com.ningdatech.kqapi.common.util; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.nio.charset.StandardCharsets; +import java.security.MessageDigest; + +public class Md5Utils { + private static final Logger LOGGER = LoggerFactory.getLogger(Md5Utils.class); + + public static byte[] md5(String s) { + MessageDigest algorithm; + try { + algorithm = MessageDigest.getInstance("MD5"); + algorithm.reset(); + algorithm.update(s.getBytes(StandardCharsets.UTF_8)); + return algorithm.digest(); + } catch (Exception e) { + LOGGER.error("MD5 Error...",e.getMessage()); + } + return null; + } + + private static String toHex(byte[] hash) { + if (hash == null) { + return null; + } + StringBuilder buf = new StringBuilder(hash.length * 2); + int i; + for (i = 0; i < hash.length; i++) { + if ((hash[i] & 0xff) < 0x10) { + buf.append("0"); + } + buf.append(Long.toString(hash[i] & 0xff, 16)); + } + return buf.toString(); + } + + public static String hash(String s) { + try { + String hex = toHex(md5(s)); + if (hex == null) { + return s; + } + return new String(hex.getBytes(StandardCharsets.UTF_8), StandardCharsets.UTF_8); + } catch (Exception e) { + LOGGER.error("not supported charset:", e.getMessage()); + return s; + } + } +} \ No newline at end of file diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/common/util/NdDateUtils.java b/kq-api/src/main/java/com/ningdatech/kqapi/common/util/NdDateUtils.java new file mode 100644 index 0000000..793983a --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/common/util/NdDateUtils.java @@ -0,0 +1,898 @@ +package com.ningdatech.kqapi.common.util; + +import cn.hutool.core.convert.Convert; +import cn.hutool.core.date.LocalDateTimeUtil; +import cn.hutool.core.util.StrUtil; +import com.ningdatech.kqapi.common.exception.BizException; +import lombok.extern.slf4j.Slf4j; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.time.*; +import java.time.format.DateTimeFormatter; +import java.time.temporal.ChronoUnit; +import java.util.*; +import java.util.stream.Stream; + +import static cn.hutool.core.date.DatePattern.*; + +/** + * 描述:日期工具类 + * + * @author WendyYang + * 修改时间:2018/4/24 + */ +@Slf4j +public final class NdDateUtils { + public static final String DEFAULT_YEAR_FORMAT = "yyyy"; + public static final String DEFAULT_MONTH_FORMAT = "yyyy-MM"; + public static final String DEFAULT_MONTH_FORMAT_SLASH = "yyyy/MM"; + public static final String DEFAULT_MONTH_FORMAT_EN = "yyyy年MM月"; + public static final String DEFAULT_WEEK_FORMAT = "yyyy-ww"; + public static final String DEFAULT_WEEK_FORMAT_EN = "yyyy年ww周"; + public static final String DEFAULT_DATE_FORMAT = NORM_DATE_PATTERN; + public static final String DEFAULT_DATE_FORMAT_EN = CHINESE_DATE_PATTERN; + public static final String DEFAULT_DATE_TIME_FORMAT = NORM_DATETIME_PATTERN; + public static final String DEFAULT_DATE_TIME_START_FORMAT = "yyyy-MM-dd 00:00:00"; + public static final String DEFAULT_DATE_TIME_END_FORMAT = "yyyy-MM-dd 23:59:59"; + public static final String DEFAULT_DATE_TIME_FORMAT_EN = CHINESE_DATE_TIME_PATTERN; + public static final String DEFAULT_TIME_FORMAT = NORM_TIME_PATTERN; + public static final String DAY = "DAY"; + public static final String MONTH = "MONTH"; + public static final String WEEK = "WEEK"; + + public static final String DEFAULT_DATE_FORMAT_MATCHES = "^\\d{4}-\\d{1,2}-\\d{1,2}$"; + public static final String DEFAULT_DATE_TIME_FORMAT_MATCHES = "^\\d{4}-\\d{1,2}-\\d{1,2} {1}\\d{1,2}:\\d{1,2}:\\d{1,2}$"; + public static final String DEFAULT_DATE_FORMAT_EN_MATCHES = "^\\d{4}年\\d{1,2}月\\d{1,2}日$"; + public static final String DEFAULT_DATE_TIME_FORMAT_EN_MATCHES = "^\\d{4}年\\d{1,2}月\\d{1,2}日\\d{1,2}时\\d{1,2}分\\d{1,2}秒$"; + public static final String SLASH_DATE_FORMAT_MATCHES = "^\\d{4}/\\d{1,2}/\\d{1,2}$"; + public static final String SLASH_DATE_TIME_FORMAT_MATCHES = "^\\d{4}/\\d{1,2}/\\d{1,2} {1}\\d{1,2}:\\d{1,2}:\\d{1,2}$"; + public static final String SLASH_DATE_FORMAT = "yyyy/MM/dd"; + public static final String SLASH_DATE_TIME_FORMAT = "yyyy/MM/dd HH:mm:ss"; + public static final String CRON_FORMAT = "ss mm HH dd MM ? yyyy"; + + /** + * 一个月平均天数 + */ + public static final long MAX_MONTH_DAY = 30; + /** + * 3个月平均天数 + */ + public static final long MAX_3_MONTH_DAY = 90; + /** + * 一年平均天数 + */ + public static final long MAX_YEAR_DAY = 365; + private static final Map DATE_FORMAT = new LinkedHashMap<>(5); + + //---------------------------------------------------格式化日期start------------------------------------------------- + + static { + DATE_FORMAT.put(DEFAULT_DATE_FORMAT, DEFAULT_DATE_FORMAT_MATCHES); + DATE_FORMAT.put(SLASH_DATE_FORMAT, SLASH_DATE_FORMAT_MATCHES); + DATE_FORMAT.put(DEFAULT_DATE_FORMAT_EN, DEFAULT_DATE_FORMAT_EN_MATCHES); + } + + private NdDateUtils() { + } + + /** + * 将字符串解析LocalDate + * + * @param source 源参数 + * 支持以下格式: + * yyyy-MM-dd + * yyyy/MM/dd + * yyyy年MM月dd日 + * @return 日期 + */ + public static LocalDate parse(String source) { + String sourceTrim = source.trim(); + Set> entries = DATE_FORMAT.entrySet(); + for (Map.Entry entry : entries) { + if (sourceTrim.matches(entry.getValue())) { + return LocalDate.parse(source, DateTimeFormatter.ofPattern(entry.getKey())); + } + } + throw BizException.wrap("解析日期失败, 请传递正确的日期格式"); + } + + + /** + * 转换 Date 为 cron , eg: "0 07 10 15 1 ? 2016" + * + * @param date 时间点 + * @return cron 表达式 + */ + public static String getCron(Date date) { + return format(date, CRON_FORMAT); + } + + /** + * 转换 LocalDateTime 为 cron , eg. "0 07 10 15 1 ? 2016" + * + * @param date 时间点 + * @return cron 表达式 + */ + public static String getCron(LocalDateTime date) { + return format(date, CRON_FORMAT); + } + + /** + * 格式化日期,返回格式为 yyyy-MM + * + * @param date 日期 + * @return 格式化后的字符串 + */ + public static String format(LocalDateTime date, String pattern) { + if (date == null) { + date = LocalDateTime.now(); + } + if (pattern == null) { + pattern = DEFAULT_MONTH_FORMAT; + } + return date.format(DateTimeFormatter.ofPattern(pattern)); + } + + public static String format(LocalDate date, String pattern) { + if (date == null) { + date = LocalDate.now(); + } + if (pattern == null) { + pattern = DEFAULT_MONTH_FORMAT; + } + return date.format(DateTimeFormatter.ofPattern(pattern)); + } + + /** + * 根据传入的格式格式化日期.默认格式为MM月dd日 + * + * @param d 日期 + * @param f 格式 + * @return 格式化后的字符串 + */ + public static String format(Date d, String f) { + Date date = d; + String format = f; + if (date == null) { + date = new Date(); + } + if (format == null) { + format = DEFAULT_DATE_TIME_FORMAT; + } + SimpleDateFormat df = new SimpleDateFormat(format); + return df.format(date); + } + + /** + * 格式化日期,返回格式为 yyyy-MM-dd + * + * @param date 日期 + * @return 格式化后的字符串 + */ + public static String formatAsDate(LocalDateTime date) { + return format(date, DEFAULT_DATE_FORMAT); + } + + public static String formatAsDate(LocalDate date) { + return format(date, DEFAULT_DATE_FORMAT); + } + + public static String formatAsDateEn(LocalDateTime date) { + return format(date, DEFAULT_DATE_FORMAT_EN); + } + + + public static String formatAsYearMonth(LocalDateTime date) { + return format(date, DEFAULT_MONTH_FORMAT); + } + + public static String formatAsYearMonthEn(LocalDateTime date) { + return format(date, DEFAULT_MONTH_FORMAT_EN); + } + + /** + * 格式化日期,返回格式为 yyyy-ww + * + * @param date 日期 + * @return 格式化后的字符串 + */ + public static String formatAsYearWeek(LocalDateTime date) { + return format(date, DEFAULT_WEEK_FORMAT); + } + + public static String formatAsYearWeekEn(LocalDateTime date) { + return format(date, DEFAULT_WEEK_FORMAT_EN); + } + + /** + * 格式化日期,返回格式为 yyyy-MM + * + * @param date 日期 + * @return 格式化后的字符串 + */ + public static String formatAsYearMonth(Date date) { + SimpleDateFormat df = new SimpleDateFormat(DEFAULT_MONTH_FORMAT); + return df.format(date); + } + + /** + * 格式化日期,返回格式为 yyyy-ww + * + * @param date 日期 + * @return 格式化后的字符串 + */ + public static String formatAsYearWeek(Date date) { + SimpleDateFormat df = new SimpleDateFormat(DEFAULT_WEEK_FORMAT); + return df.format(date); + } + + /** + * 格式化日期,返回格式为 HH:mm:ss 例:12:24:24 + * + * @param date 日期 + * @return 格式化后的字符串 + */ + public static String formatAsTime(Date date) { + SimpleDateFormat df = new SimpleDateFormat(DEFAULT_TIME_FORMAT); + return df.format(date); + } + + /** + * 格式化日期,返回格式为 yyyy-MM-dd + * + * @param date 日期 + * @return 格式化后的字符串 + */ + public static String formatAsDate(Date date) { + SimpleDateFormat df = new SimpleDateFormat(DEFAULT_DATE_FORMAT); + return df.format(date); + } + + /** + * 格式化日期,返回格式为 yyyy-MM-dd HH:mm:ss + * + * @param date 日期 + * @return 格式化后的字符串 + */ + public static String formatAsDateTime(Date date) { + SimpleDateFormat df = new SimpleDateFormat(DEFAULT_DATE_TIME_FORMAT); + return df.format(date); + } + + /** + * 格式化日期,返回格式为 dd ,即对应的天数. + * + * @param date 日期 + * @return 格式化后的字符串 + */ + public static String formatAsDay(Date date) { + SimpleDateFormat df = new SimpleDateFormat("dd"); + return df.format(date); + } + + //--格式化日期end----------------------------------------- + + //--解析日期start----------------------------------------- + + /** + * 将字符转换成日期 + * + * @param dateStr 日期字符串 + * @param format 解析格式 + * @return 解析后的日期 + */ + public static Date parse(String dateStr, String format) { + Date date = null; + SimpleDateFormat dateFormat = new SimpleDateFormat(format); + dateFormat.setLenient(false); + try { + date = dateFormat.parse(dateStr); + + } catch (Exception e) { + log.info("DateUtils error", e); + } + return date; + } + + /** + * 获取当月最后一天 + * + * @param date 日期 + * @return 当月最后一天 + */ + public static Date getLastDateOfMonth(Date date) { + Calendar calendar = Calendar.getInstance(); + calendar.setTime(date); + calendar.add(Calendar.MONTH, 1); + calendar.set(Calendar.DAY_OF_MONTH, 0); + return calendar.getTime(); + } + + /** + * 根据传入的String返回对应的date + * + * @param source 日期字符串 + * @return 日期 + */ + public static Date parseAsDate(String source) { + String sourceTrim = source.trim(); + Set> entries = DATE_FORMAT.entrySet(); + try { + for (Map.Entry entry : entries) { + if (sourceTrim.matches(entry.getValue())) { + return new SimpleDateFormat(entry.getKey()).parse(source); + } + } + } catch (ParseException e) { + throw BizException.wrap("解析日期失败, 请传递正确的日期格式"); + } + throw BizException.wrap("解析日期失败, 请传递正确的日期格式"); + } + + /** + * 按给定参数返回Date对象 + * + * @param dateTime 时间对象格式为("yyyy-MM-dd HH:mm:ss"); + * @return 解析后的日期 + */ + public static Date parseAsDateTime(String dateTime) { + SimpleDateFormat simpledateformat = new SimpleDateFormat(DEFAULT_DATE_TIME_FORMAT); + try { + return simpledateformat.parse(dateTime); + } catch (ParseException e) { + return null; + } + } + + /** + * 获取指定日期的开始时间 + * 如:00:00:00 + * + * @param value 日期 + * @return 解析后的日期 + */ + public static Date getDate0000(LocalDateTime value) { + return getDate0000(value.toLocalDate()); + } + + /** + * 获取指定日期的开始时间 + * 如:00:00:00 + * + * @param value 日期 + * @return 解析后的日期 + */ + public static Date getDate0000(Date value) { + return getDate0000(NdDateUtils.date2LocalDate(value)); + } + + /** + * 获取指定日期的开始时间 + * 如:00:00:00 + * + * @param value 日期 + * @return 解析后的日期 + */ + public static Date getDate0000(LocalDate value) { + LocalDateTime todayStart = LocalDateTime.of(value, LocalTime.MIN); + return NdDateUtils.localDateTime2Date(todayStart); + } + + /** + * 获取指定日期的结束时间 + * 如:23:59:59 + * + * @param value 日期 + * @return 解析后的日期 + */ + public static Date getDate2359(LocalDateTime value) { + return getDate2359(value.toLocalDate()); + + } + + /** + * 获取指定日期的结束时间 + * 如:23:59:59 + * + * @param value 日期 + * @return 解析后的日期 + */ + public static Date getDate2359(Date value) { + return getDate2359(NdDateUtils.date2LocalDate(value)); + } + + /** + * 获取指定日期的结束时间 + * 如:23:59:59 + * + * @param value 日期 + * @return 解析后的日期 + */ + public static Date getDate2359(LocalDate value) { + LocalDateTime dateEnd = LocalDateTime.of(value, LocalTime.MAX); + return NdDateUtils.localDateTime2Date(dateEnd); + } + + /** + * LocalDateTime转换为Date + * + * @param localDateTime 日期 + * @return 解析后的日期 + */ + public static Date localDateTime2Date(LocalDateTime localDateTime) { + ZoneId zoneId = ZoneId.systemDefault(); + ZonedDateTime zdt = localDateTime.atZone(zoneId); + return Date.from(zdt.toInstant()); + } + + //--解析日期 end----------------------------------------- + + + /** + * Date转换为LocalDateTime + * + * @param date 日期 + */ + public static LocalDateTime date2LocalDateTime(Date date) { + if (date == null) { + return LocalDateTime.now(); + } + Instant instant = date.toInstant(); + ZoneId zoneId = ZoneId.systemDefault(); + return instant.atZone(zoneId).toLocalDateTime(); + } + + /** + * 日期转 LocalDate + * + * @param date 日期 + * @return 解析后的日期 + */ + public static LocalDate date2LocalDate(Date date) { + if (date == null) { + return LocalDate.now(); + } + Instant instant = date.toInstant(); + ZoneId zoneId = ZoneId.systemDefault(); + return instant.atZone(zoneId).toLocalDate(); + } + + /** + * 日期转 LocalTime + * + * @param date 日期 + * @return 解析后的日期 + */ + public static LocalTime date2LocalTime(Date date) { + if (date == null) { + return LocalTime.now(); + } + Instant instant = date.toInstant(); + ZoneId zoneId = ZoneId.systemDefault(); + return instant.atZone(zoneId).toLocalTime(); + } + + + /** + * 毫秒转日期 + * + * @param epochMilli 毫秒 + * @return 解析后的日期 + */ + public static LocalDateTime getDateTimeOfTimestamp(long epochMilli) { + Instant instant = Instant.ofEpochMilli(epochMilli); + return LocalDateTime.ofInstant(instant, ZoneId.systemDefault()); + } + + /** + * 秒转日期 + * + * @param epochSecond 秒 + * @return 解析后的日期 + */ + public static LocalDateTime getDateTimeOfSecond(long epochSecond) { + Instant instant = Instant.ofEpochSecond(epochSecond); + return LocalDateTime.ofInstant(instant, ZoneId.systemDefault()); + } + + //-计算日期 start------------------------------------------ + + + /** + * 计算结束时间与当前时间间隔的天数 + * + * @param endDate 结束日期 + * @return 计算结束时间与当前时间间隔的天数 + */ + public static long until(Date endDate) { + return LocalDateTime.now().until(date2LocalDateTime(endDate), ChronoUnit.DAYS); + } + + /** + * 计算结束时间与开始时间间隔的天数 + * + * @param startDate 开始日期 + * @param endDate 结束日期 + * @return 计算结束时间与开始时间间隔的天数 + */ + public static long until(Date startDate, Date endDate) { + return date2LocalDateTime(startDate).until(date2LocalDateTime(endDate), ChronoUnit.DAYS); + } + + + /** + * 计算结束时间与开始时间间隔的天数 + * + * @param startDate 开始日期 + * @param endDate 结束日期 + * @return 计算结束时间与开始时间间隔的天数 + */ + public static long until(LocalDateTime startDate, LocalDateTime endDate) { + return startDate.until(endDate, ChronoUnit.DAYS); + } + + public static long until(LocalDate startDate, LocalDate endDate) { + return startDate.until(endDate, ChronoUnit.DAYS); + } + + /** + * 计算2个日期之间的所有的日期 yyyy-MM-dd + * 含头含尾 + * + * @param start yyyy-MM-dd + * @param end yyyy-MM-dd + * @return 日期区间的所有日期 + */ + public static List getBetweenDay(Date start, Date end) { + return getBetweenDay(date2LocalDate(start), date2LocalDate(end)); + } + + /** + * 计算2个日期之间的所有的日期 yyyy-MM-dd + * 含头含尾 + * + * @param start yyyy-MM-dd + * @param end yyyy-MM-dd + */ + public static List getBetweenDay(String start, String end) { + return getBetweenDay(LocalDate.parse(start), LocalDate.parse(end)); + } + + /** + * 计算2个日期之间的所有的日期 yyyy-MM-dd + * 含头含尾 + * + * @param startDate yyyy-MM-dd + * @param endDate yyyy-MM-dd + */ + public static List getBetweenDay(LocalDate startDate, LocalDate endDate) { + return getBetweenDay(startDate, endDate, DEFAULT_DATE_FORMAT); + } + + public static List getBetweenDayEn(LocalDate startDate, LocalDate endDate) { + return getBetweenDay(startDate, endDate, DEFAULT_DATE_FORMAT_EN); + } + + public static List getBetweenDay(LocalDate startDate, LocalDate endDate, String pattern) { + if (pattern == null) { + pattern = DEFAULT_DATE_FORMAT; + } + List list = new ArrayList<>(); + long distance = ChronoUnit.DAYS.between(startDate, endDate); + if (distance < 1) { + return list; + } + String finalPattern = pattern; + Stream.iterate(startDate, d -> d.plusDays(1)). + limit(distance + 1) + .forEach(f -> list.add(f.format(DateTimeFormatter.ofPattern(finalPattern)))); + return list; + } + + + /** + * 计算2个日期之间的所有的周 yyyy-ww + * 含头含尾 + * + * @param start yyyy-MM-dd + * @param end yyyy-MM-dd + */ + public static List getBetweenWeek(Date start, Date end) { + return getBetweenWeek(date2LocalDate(start), date2LocalDate(end)); + } + + /** + * 计算2个日期之间的所有的周 yyyy-ww + * 含头含尾 + * + * @param start yyyy-MM-dd + * @param end yyyy-MM-dd + * @return 2个日期之间的所有的周 + */ + public static List getBetweenWeek(String start, String end) { + return getBetweenWeek(LocalDate.parse(start), LocalDate.parse(end)); + } + + /** + * 计算2个日期之间的所有的周 yyyy-ww + * 含头含尾 + * + * @param startDate yyyy-MM-dd + * @param endDate yyyy-MM-dd + * @return 2个日期之间的所有的周 + */ + public static List getBetweenWeek(LocalDate startDate, LocalDate endDate) { + return getBetweenWeek(startDate, endDate, DEFAULT_WEEK_FORMAT); + } + + public static List getBetweenWeek(LocalDate startDate, LocalDate endDate, String pattern) { + List list = new ArrayList<>(); + + long distance = ChronoUnit.WEEKS.between(startDate, endDate); + if (distance < 1) { + return list; + } + Stream.iterate(startDate, d -> d.plusWeeks(1)). + limit(distance + 1).forEach(f -> list.add(f.format(DateTimeFormatter.ofPattern(pattern)))); + return list; + } + + /** + * 计算2个日期之间的所有的月 yyyy-MM + * + * @param start yyyy-MM-dd + * @param end yyyy-MM-dd + * @return 2个日期之间的所有的月 + */ + public static List getBetweenMonth(Date start, Date end) { + return getBetweenMonth(date2LocalDate(start), date2LocalDate(end)); + } + + /** + * 计算2个日期之间的所有的月 yyyy-MM + * + * @param start yyyy-MM-dd + * @param end yyyy-MM-dd + * @return 2个日期之间的所有的月 + */ + public static List getBetweenMonth(String start, String end) { + return getBetweenMonth(LocalDate.parse(start), LocalDate.parse(end)); + } + + /** + * 计算2个日期之间的所有的月 yyyy-MM + * + * @param startDate yyyy-MM-dd + * @param endDate yyyy-MM-dd + * @return 2个日期之间的所有的月 + */ + public static List getBetweenMonth(LocalDate startDate, LocalDate endDate) { + return getBetweenMonth(startDate, endDate, DEFAULT_MONTH_FORMAT); + } + + public static List getBetweenMonth(LocalDate startDate, LocalDate endDate, String pattern) { + List list = new ArrayList<>(); + long distance = ChronoUnit.MONTHS.between(startDate, endDate); + if (distance < 1) { + return list; + } + + Stream.iterate(startDate, d -> d.plusMonths(1)) + .limit(distance + 1) + .forEach(f -> list.add(f.format(DateTimeFormatter.ofPattern(pattern)))); + return list; + } + + /** + * 计算时间区间内的日期列表,并返回 + * + * @param startTime 开始 + * @param endTime 结束 + * @param dateList 日期 + * @return 计算时间区间内的日期列表 + */ + public static String calculationEn(LocalDateTime startTime, LocalDateTime endTime, List dateList) { + if (startTime == null) { + startTime = LocalDateTime.now(); + } + if (endTime == null) { + endTime = LocalDateTime.now().plusDays(30); + } + return calculationEn(startTime.toLocalDate(), endTime.toLocalDate(), dateList); + } + + public static String calculation(LocalDate startDate, LocalDate endDate, List dateList) { + if (startDate == null) { + startDate = LocalDate.now(); + } + if (endDate == null) { + endDate = LocalDate.now().plusDays(30); + } + if (dateList == null) { + dateList = new ArrayList<>(); + } + long day = until(startDate, endDate); + + String dateType; + if (day >= 0 && day <= MAX_MONTH_DAY) { + dateType = DAY; + dateList.addAll(NdDateUtils.getBetweenDay(startDate, endDate, DEFAULT_DATE_FORMAT)); + } else if (day > MAX_MONTH_DAY && day <= MAX_3_MONTH_DAY) { + dateType = WEEK; + dateList.addAll(NdDateUtils.getBetweenWeek(startDate, endDate, DEFAULT_WEEK_FORMAT)); + } else if (day > MAX_3_MONTH_DAY && day <= MAX_YEAR_DAY) { + dateType = MONTH; + dateList.addAll(NdDateUtils.getBetweenMonth(startDate, endDate, DEFAULT_MONTH_FORMAT)); + } else { + throw new BizException("日期参数只能介于0-365天之间"); + } + return dateType; + } + + public static String calculationEn(LocalDate startDate, LocalDate endDate, List dateList) { + if (startDate == null) { + startDate = LocalDate.now(); + } + if (endDate == null) { + endDate = LocalDate.now().plusDays(30); + } + if (dateList == null) { + dateList = new ArrayList<>(); + } + long day = until(startDate, endDate); + + String dateType; + if (day >= 0 && day <= MAX_MONTH_DAY) { + dateType = DAY; + dateList.addAll(NdDateUtils.getBetweenDay(startDate, endDate, DEFAULT_DATE_FORMAT_EN)); + } else if (day > MAX_MONTH_DAY && day <= MAX_3_MONTH_DAY) { + dateType = WEEK; + dateList.addAll(NdDateUtils.getBetweenWeek(startDate, endDate, DEFAULT_WEEK_FORMAT_EN)); + } else if (day > MAX_3_MONTH_DAY && day <= MAX_YEAR_DAY) { + dateType = MONTH; + dateList.addAll(NdDateUtils.getBetweenMonth(startDate, endDate, DEFAULT_MONTH_FORMAT_EN)); + } else { + throw new BizException("日期参数只能介于0-365天之间"); + } + return dateType; + } + +//----------//----------//----------//----------//----------//----------//----------//----------//----------//----------//---------- + + /** + * 计算开始时间 + * + * @param time 日期 + * @return 计算开始时间 + */ + public static LocalDateTime getStartTime(String time) { + String startTime = time; + if (time.matches("^\\d{4}-\\d{1,2}$")) { + startTime = time + "-01 00:00:00"; + } else if (time.matches("^\\d{4}-\\d{1,2}-\\d{1,2}$")) { + startTime = time + " 00:00:00"; + } else if (time.matches("^\\d{4}-\\d{1,2}-\\d{1,2} \\d{1,2}:\\d{1,2}$")) { + startTime = time + ":00"; + } else if (time.matches("^\\d{4}-\\d{1,2}-\\d{1,2}T\\d{1,2}:\\d{1,2}:\\d{1,2}.\\d{3}Z$")) { + startTime = time.replace("T", " ").substring(0, time.indexOf('.')); + } + return LocalDateTimeUtil.beginOfDay(LocalDateTime.parse(startTime, DateTimeFormatter.ofPattern(DEFAULT_DATE_TIME_FORMAT))); + } + + /** + * 计算结束时间 + * + * @param time 日期 + * @return 结束时间 精确到毫秒 + */ + public static LocalDateTime getEndTime(String time) { + String startTime = time; + if (time.matches("^\\d{4}-\\d{1,2}$")) { + Date date = NdDateUtils.parse(time, "yyyy-MM"); + date = NdDateUtils.getLastDateOfMonth(date); + startTime = NdDateUtils.formatAsDate(date) + " 23:59:59"; + } else if (time.matches("^\\d{4}-\\d{1,2}-\\d{1,2}$")) { + startTime = time + " 23:59:59"; + } else if (time.matches("^\\d{4}-\\d{1,2}-\\d{1,2} \\d{1,2}:\\d{1,2}$")) { + startTime = time + ":59"; + } else if (time.matches("^\\d{4}-\\d{1,2}-\\d{1,2}T\\d{1,2}:\\d{1,2}:\\d{1,2}.\\d{3}Z$")) { + time = time.replace("T", " ").substring(0, time.indexOf('.')); + startTime = time; + } + + return endOfDay(LocalDateTime.parse(startTime, DateTimeFormatter.ofPattern(DEFAULT_DATE_TIME_FORMAT))); + } + + public static LocalDateTime endOfDay(LocalDateTime time) { + return time.with(LocalTime.of(23, 59, 59, 999_999_000)); + } + + /** + * 判断当前时间是否在指定时间范围 + * + * @param from 开始时间 + * @param to 结束时间 + * @return 结果 + */ + public static boolean between(LocalTime from, LocalTime to) { + if (from == null) { + throw new IllegalArgumentException("开始时间不能为空"); + } + if (to == null) { + throw new IllegalArgumentException("结束时间不能为空"); + } + LocalTime now = LocalTime.now(); + return now.isAfter(from) && now.isBefore(to); + } + + /** + * 转换日期 + *

+ * 0: 今天结束的日期 + * 1m: 1分钟后的日期 + * 1h: 1小时后的日期 + * 4d: 4天后的日期 + * 2w: 2周后的日期 + * 3M: 3个月后的日期 + * 5y: 5年后的日期 + * + * @param dateTime 待转换日期 + * @param time 转换格式 如: + * 0 当天23:59:59 + * 1s 1秒后 + * 3m 3分钟后 + * 2w 2周后 + * 1h 1小时后 + * 2H 2小时后 + * 4d 4天后 + * 5M 5月后 + * 6y 6年后 + * @return 日期 + */ + public static LocalDateTime conversionDateTime(LocalDateTime dateTime, String time) { + if (StrUtil.isEmpty(time)) { + return LocalDateTime.MAX; + } + + if (dateTime == null) { + return endOfDay(LocalDateTime.now()); + } + + // 今天的23:59:59 + if (StrPool.ZERO.equals(time)) { + return endOfDay(dateTime); + } + + char unit = Character.toLowerCase(time.charAt(time.length() - 1)); + if (time.length() == 1) { + unit = 'd'; + } + Long lastTime = Convert.toLong(time.substring(0, time.length() - 1)); + + switch (unit) { + //秒 + case 's': + return dateTime.plusSeconds(lastTime); + //分 + case 'm': + return dateTime.plusMinutes(lastTime); + //时 + case 'h' | 'H': + return dateTime.plusHours(lastTime); + //周 + case 'w': + return dateTime.plusWeeks(lastTime); + //月 + case 'M': + return dateTime.plusMonths(lastTime); + //年 + case 'y': + return dateTime.plusYears(lastTime); + //天 + case 'd': + default: + return dateTime.plusDays(lastTime); + } + } +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/common/util/NdJacksonModule.java b/kq-api/src/main/java/com/ningdatech/kqapi/common/util/NdJacksonModule.java new file mode 100644 index 0000000..5a93bd4 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/common/util/NdJacksonModule.java @@ -0,0 +1,35 @@ +package com.ningdatech.kqapi.common.util; + +import com.fasterxml.jackson.databind.module.SimpleModule; +import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer; +import com.fasterxml.jackson.datatype.jsr310.deser.LocalTimeDeserializer; +import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer; +import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer; +import com.fasterxml.jackson.datatype.jsr310.ser.LocalTimeSerializer; +import com.ningdatech.kqapi.common.converter.NdLocalDateTimeDeserializer; + +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.time.format.DateTimeFormatter; + +import static com.ningdatech.kqapi.common.util.NdDateUtils.*; + +/** + * jackson 自定义序列化 & 反序列化 规则 + * + * @author WendyYang + */ +public class NdJacksonModule extends SimpleModule { + + public NdJacksonModule() { + super(); + this.addDeserializer(LocalDateTime.class, NdLocalDateTimeDeserializer.INSTANCE); + this.addDeserializer(LocalDate.class, new LocalDateDeserializer(DateTimeFormatter.ofPattern(DEFAULT_DATE_FORMAT))); + this.addDeserializer(LocalTime.class, new LocalTimeDeserializer(DateTimeFormatter.ofPattern(DEFAULT_TIME_FORMAT))); + this.addSerializer(LocalDateTime.class, new LocalDateTimeSerializer(DateTimeFormatter.ofPattern(DEFAULT_DATE_TIME_FORMAT))); + this.addSerializer(LocalDate.class, new LocalDateSerializer(DateTimeFormatter.ofPattern(DEFAULT_DATE_FORMAT))); + this.addSerializer(LocalTime.class, new LocalTimeSerializer(DateTimeFormatter.ofPattern(DEFAULT_TIME_FORMAT))); + } + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/common/util/RefreshKeyUtil.java b/kq-api/src/main/java/com/ningdatech/kqapi/common/util/RefreshKeyUtil.java new file mode 100644 index 0000000..68b33d6 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/common/util/RefreshKeyUtil.java @@ -0,0 +1,59 @@ +package com.ningdatech.kqapi.common.util; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import lombok.extern.slf4j.Slf4j; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** + * @Classname RefreshKeyUtil + * @Description + * @Date 2023/6/27 10:03 + * @Author PoffyZhang + */ +@Slf4j +public class RefreshKeyUtil { + public static String getRequestSecret(String appKey, String appSecret,Long requestTime) throws IOException { + // 刷新秘钥 + HttpUtil httpUtil = HttpUtil.getInstance(); + log.info("请求密钥" + appSecret); + String sign = Md5Utils.hash (appKey + appSecret + requestTime); + String refreshUrl = "http://interface.zjzwfw.gov.cn/gateway/app/refreshTokenByKey.htm"; + log.info(refreshUrl); + Map map = new HashMap<>(); + map.put("appKey",appKey); + map.put("sign",sign); + map.put("requestTime",requestTime + ""); + String result = httpUtil.sendHttpPost(refreshUrl,map); + log.info(result); + JSONObject dataJson = JSON.parseObject(result).getJSONObject("datas"); + if(Objects.nonNull(dataJson)){ + return dataJson.getString("requestSecret"); + } + return result; + } + + public static String refreshSecret(String appKey, String refreshSecret,Long requestTime) throws IOException { + // 刷新秘钥 + HttpUtil httpUtil = HttpUtil.getInstance(); + log.info("刷新密钥" + refreshSecret); + String refreshSign = Md5Utils.hash (appKey + refreshSecret + requestTime); + String refreshUrl = "http://interface.zjzwfw.gov.cn/gateway/app/refreshTokenBySec.htm"; + log.info(refreshUrl); + Map map = new HashMap<>(); + map.put("appKey",appKey); + map.put("sign",refreshSign); + map.put("requestTime",requestTime + ""); + String result = httpUtil.sendHttpPost(refreshUrl,map); + log.info(result); + JSONObject dataJson = JSON.parseObject(result).getJSONObject("datas"); + if(Objects.nonNull(dataJson)){ + return dataJson.getString("requestSecret"); + } + return result; + } +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/common/util/SpringContextHolder.java b/kq-api/src/main/java/com/ningdatech/kqapi/common/util/SpringContextHolder.java new file mode 100644 index 0000000..1104523 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/common/util/SpringContextHolder.java @@ -0,0 +1,150 @@ +package com.ningdatech.kqapi.common.util; + +import java.util.ArrayList; +import java.util.List; + + +import org.springframework.beans.BeansException; +import org.springframework.beans.factory.DisposableBean; +import org.springframework.context.ApplicationContext; +import org.springframework.context.ApplicationContextAware; +import org.springframework.core.env.Environment; +import org.springframework.lang.NonNull; + +import lombok.extern.slf4j.Slf4j; + +/** + * @author qinxianyun + */ +@Slf4j +public class SpringContextHolder implements ApplicationContextAware, DisposableBean { + + private static ApplicationContext applicationContext = null; + private static final List CALL_BACKS = new ArrayList<>(); + private static boolean addCallback = true; + + /** + * 针对 某些初始化方法,在SpringContextHolder 未初始化时 提交回调方法。 + * 在SpringContextHolder 初始化后,进行回调使用 + * + * @param callBack 回调函数 + */ + public synchronized static void addCallBacks(CallBack callBack) { + if (addCallback) { + SpringContextHolder.CALL_BACKS.add(callBack); + } else { + log.warn("CallBack:{} 已无法添加!立即执行", callBack.getCallBackName()); + callBack.executor(); + } + } + + /** + * 从静态变量applicationContext中取得Bean, 自动转型为所赋值对象的类型. + */ + @SuppressWarnings("unchecked") + public static T getBean(String name) { + assertContextInjected(); + return (T) applicationContext.getBean(name); + } + + /** + * 从静态变量applicationContext中取得Bean, 自动转型为所赋值对象的类型. + */ + public static T getBean(Class requiredType) { + assertContextInjected(); + return applicationContext.getBean(requiredType); + } + + /** + * 获取SpringBoot 配置信息 + * + * @param property 属性key + * @param defaultValue 默认值 + * @param requiredType 返回类型 + * @return / + */ + public static T getProperties(String property, T defaultValue, Class requiredType) { + T result = defaultValue; + try { + result = getBean(Environment.class).getProperty(property, requiredType); + } catch (Exception ignored) { + } + return result; + } + + /** + * 获取SpringBoot 配置信息 + * + * @param property 属性key + * @return / + */ + public static String getProperties(String property) { + return getProperties(property, null, String.class); + } + + /** + * 获取SpringBoot 配置信息 + * + * @param property 属性key + * @param requiredType 返回类型 + * @return / + */ + public static T getProperties(String property, Class requiredType) { + return getProperties(property, null, requiredType); + } + + /** + * 检查ApplicationContext不为空. + */ + private static void assertContextInjected() { + if (applicationContext == null) { + throw new IllegalStateException("applicationContext属性未注入, 请在applicationContext" + + ".xml中定义SpringContextHolder或在SpringBoot启动类中注册SpringContextHolder."); + } + } + + /** + * 清除SpringContextHolder中的ApplicationContext为Null. + */ + private static void clearHolder() { + log.debug("清除SpringContextHolder中的ApplicationContext:" + + applicationContext); + applicationContext = null; + } + + @Override + public void destroy() { + SpringContextHolder.clearHolder(); + } + + @Override + public void setApplicationContext(@NonNull ApplicationContext applicationContext) throws BeansException { + if (SpringContextHolder.applicationContext != null) { + log.warn("SpringContextHolder中的ApplicationContext被覆盖, 原有ApplicationContext为:" + SpringContextHolder.applicationContext); + } + SpringContextHolder.applicationContext = applicationContext; + if (addCallback) { + for (CallBack callBack : SpringContextHolder.CALL_BACKS) { + callBack.executor(); + } + CALL_BACKS.clear(); + } + SpringContextHolder.addCallback = false; + } + + /** + * 获取当前启用的配置文件 + *

    + *
  • 生产环境:prod
  • + *
  • 开发环境:dev
  • + *
+ * + * @return java.lang.String + * @author WendyYang + **/ + public static String getActiveProfile() { + String[] strings = applicationContext.getEnvironment().getActiveProfiles(); + return strings[0]; + } + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/common/util/StrPool.java b/kq-api/src/main/java/com/ningdatech/kqapi/common/util/StrPool.java new file mode 100644 index 0000000..adff4f1 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/common/util/StrPool.java @@ -0,0 +1,148 @@ +package com.ningdatech.kqapi.common.util; + + +/** + *

+ * 常用字符串 + *

+ * + * @author WendyYang + * @date 2019/07/25 + */ +public interface StrPool { + + String AMPERSAND = "&"; + String AND = "and"; + String AT = "@"; + String ASTERISK = "*"; + String STAR = "*"; + String BACK_SLASH = "\\"; + String COLON = ":"; + String COMMA = ","; + String DASH = "-"; + String DOLLAR = "$"; + String DOT = "."; + String DOTDOT = ".."; + String DOT_CLASS = ".class"; + String DOT_JAVA = ".java"; + String DOT_XML = ".xml"; + String EMPTY = ""; + String EQUALS = "="; + String FALSE = "false"; + String SLASH = "/"; + String HASH = "#"; + String HAT = "^"; + String LEFT_BRACE = "{"; + String BRACE = "{}"; + String LEFT_BRACKET = "("; + char LEFT_BRACKET_CHAR = '('; + String LEFT_CHEV = "<"; + String NEWLINE = "\n"; + String N = "n"; + String NO = "no"; + String NULL = "null"; + String OFF = "off"; + String ON = "on"; + String PERCENT = "%"; + String PIPE = "|"; + String PLUS = "+"; + String QUESTION_MARK = "?"; + String EXCLAMATION_MARK = "!"; + String QUOTE = "\""; + String RETURN = "\r"; + String TAB = "\t"; + String RIGHT_BRACE = "}"; + String RIGHT_BRACKET = ")"; + String RIGHT_CHEV = ">"; + String SEMICOLON = ";"; + String SEMICOLON_CHINA = ";"; + String SINGLE_QUOTE = "'"; + String BACKTICK = "`"; + String SPACE = " "; + String TILDA = "~"; + String LEFT_SQ_BRACKET = "["; + String RIGHT_SQ_BRACKET = "]"; + String TRUE = "true"; + String UNDERSCORE = "_"; + String UTF_8 = "UTF-8"; + String GBK = "GBK"; + String US_ASCII = "US-ASCII"; + String ISO_8859_1 = "ISO-8859-1"; + String Y = "y"; + String YES = "yes"; + String ONE = "1"; + String ZERO = "0"; + String DOLLAR_LEFT_BRACE = "${"; + String HASH_LEFT_BRACE = "#{"; + String CRLF = "\r\n"; + String HTML_NBSP = " "; + String HTML_AMP = "&"; + String HTML_QUOTE = """; + String HTML_LT = "<"; + String HTML_GT = ">"; + String STRING_TYPE_NAME = "java.lang.String"; + String LONG_TYPE_NAME = "java.lang.Long"; + String BYTE_TYPE_NAME = "java.lang.Byte"; + String CHARACTER_TYPE_NAME = "java.lang.Character"; + String INTEGER_TYPE_NAME = "java.lang.Integer"; + String SHORT_TYPE_NAME = "java.lang.Short"; + String DOUBLE_TYPE_NAME = "java.lang.Double"; + String FLOAT_TYPE_NAME = "java.lang.Float"; + String BOOLEAN_TYPE_NAME = "java.lang.Boolean"; + String SET_TYPE_NAME = "java.util.Set"; + String LIST_TYPE_NAME = "java.util.List"; + String COLLECTION_TYPE_NAME = "java.util.Collection"; + String DATE_TYPE_NAME = "java.util.Date"; + String LOCAL_DATE_TIME_TYPE_NAME = "java.time.LocalDateTime"; + String LOCAL_DATE_TYPE_NAME = "java.time.LocalDate"; + String LOCAL_TIME_TYPE_NAME = "java.time.LocalTime"; + String JAVA_TEMP_DIR = "java.io.tmpdir"; + + String ARRAY = "Array"; + String INTEGER = "Integer"; + String FLOAT = "Float"; + String DATETIME = "DateTime"; + String DATE = "Date"; + String TIME = "Time"; + String BOOLEAN = "Boolean"; + + + String HTTPS_PREFIX = "https://"; + String HTTP_PREFIX = "http://"; + String HTTPS = "https"; + String HTTP = "http"; + /** + * 编码 + */ + String UTF8 = "UTF-8"; + /** + * JSON 资源 + */ + String CONTENT_TYPE = "application/json; charset=utf-8"; + + /** + * 用于随机选的字符 + */ + String BASE_UPPER_CHAR = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + + String TEST_TOKEN = "Bearer test"; + String TEST = "test"; + String PROD = "prod"; + String DEV = "dev"; + + /** + * 默认的父id + */ + Long DEF_PARENT_ID = 0L; + + String UNKNOWN = "unknown"; + + /** + * 日期 个位数前面补0 + */ + String FORMAT_DATE_SINGLE_DIGITS = "%02d"; + /** + * 不足三位的数字前面补0 + */ + String FORMAT_NUMBER_THREE = "%03d"; +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/open/controller/HealthController.java b/kq-api/src/main/java/com/ningdatech/kqapi/open/controller/HealthController.java new file mode 100644 index 0000000..d3f8fb5 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/open/controller/HealthController.java @@ -0,0 +1,40 @@ +package com.ningdatech.kqapi.open.controller; + +import com.alibaba.fastjson.JSONObject; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.jasypt.util.text.BasicTextEncryptor; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; + +/** + *

+ * 前端控制器 + *

+ * + * @author ZPF + * @since 2023-10-27 + */ +@Slf4j +@Validated +@RestController +@RequestMapping +@RequiredArgsConstructor +public class HealthController { + + @GetMapping("/health") + public JSONObject health() { + JSONObject json = new JSONObject(); + json.put("code","200"); + json.put("area","柯桥区"); + json.put("chargePerson","李*"); + json.put("appName","企业线上平台"); + json.put("mobile","156*****306"); + json.put("time",LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); + json.put("dept","产业发展科"); + return json; + } +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/scheduler/contants/TaskContant.java b/kq-api/src/main/java/com/ningdatech/kqapi/scheduler/contants/TaskContant.java new file mode 100644 index 0000000..c853264 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/scheduler/contants/TaskContant.java @@ -0,0 +1,14 @@ +package com.ningdatech.kqapi.scheduler.contants; + +/** + * @author PoffyZhang + * @Classname TaskContant + * @Description + * @Date 2023/1/18 11:00 + */ +public interface TaskContant { + + public static final String DEV = "dev"; + public static final String PRE = "pre"; + public static final String PROD = "prod"; +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/scheduler/controller/TaskController.java b/kq-api/src/main/java/com/ningdatech/kqapi/scheduler/controller/TaskController.java new file mode 100644 index 0000000..1473d1a --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/scheduler/controller/TaskController.java @@ -0,0 +1,88 @@ +package com.ningdatech.kqapi.scheduler.controller; + + +import com.ningdatech.kqapi.scheduler.manage.SynManage; +import com.ningdatech.kqapi.scheduler.task.CheckMattersUrlTask; +import com.ningdatech.kqapi.scheduler.task.RemoveMattersTask; +import com.ningdatech.kqapi.scheduler.task.SynTask; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import java.net.MalformedURLException; +import java.net.UnknownHostException; +import java.util.Arrays; + +/** + *

+ * 前端控制器 + *

+ * + * @author ZPF + * @since 2023-10-27 + */ +@Slf4j +@Validated +@RestController +@RequestMapping("/api/v1/task/") +@Api(value = "TaskController", tags = "柯桥-定时控制器") +@RequiredArgsConstructor +public class TaskController { + private final RemoveMattersTask removeMattersTask; + + private final CheckMattersUrlTask checkMattersUrlTask; + + private final SynTask synTask; + + private final SynManage synManage; + + @ApiOperation(value = "主动调删除数据", notes = "主动调删除数据") + @GetMapping("/remove-matters") + public void removeMatters() throws UnknownHostException { + removeMattersTask.doTask(); + } + + @ApiOperation(value = "主动同步三表", notes = "主动同步三表") + @GetMapping("/syn-data") + public void synData() throws UnknownHostException { + synManage.synData(); + } + + @ApiOperation(value = "同步菜单链接数据", notes = "同步菜单链接数据") + @GetMapping("/syn") + public String synMenu() throws UnknownHostException { + synTask.synData(); + return "同步成功"; + } + + @ApiOperation(value = "剔除某个菜单组件名称数据", notes = "英文逗号','分割") + @GetMapping("/synEliminate") + public String synEliminate(String keys){ + return synTask.synEliminate(Arrays.asList(keys.split(","))); + } + + @ApiOperation(value = "同步单个菜单组件名称", notes = "同步菜单链接数据") + @GetMapping("/synSingle") + public String synSingle(String key){ + synTask.synSingle(key); + return "同步成功"; + } + + @ApiOperation(value = "同步菜单链接数据", notes = "同步菜单链接数据") + @GetMapping("/syn-menu") + public String synMenuData() throws UnknownHostException { + synTask.synMenu(); + return "同步成功"; + } + + @ApiOperation(value = "check链接", notes = "check链接") + @GetMapping("/check-url") + public String checkUrl() throws UnknownHostException, MalformedURLException { + checkMattersUrlTask.doTask(); + return "操作成功"; + } +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/scheduler/manage/SynManage.java b/kq-api/src/main/java/com/ningdatech/kqapi/scheduler/manage/SynManage.java new file mode 100644 index 0000000..b92267c --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/scheduler/manage/SynManage.java @@ -0,0 +1,88 @@ +package com.ningdatech.kqapi.scheduler.manage; + +import cn.hutool.core.bean.BeanUtil; +import com.alibaba.fastjson.JSON; +import com.ningdatech.kqapi.zzsfw.model.dto.KqZzsfwMattersDeduplicateDTO; +import com.ningdatech.kqapi.zzsfw.model.dto.KqZzsfwMenuDTO; +import com.ningdatech.kqapi.zzsfw.model.dto.KqZzsfwPolicyDTO; +import com.ningdatech.kqapi.zzsfw.model.entity.KqZzsfwMenu; +import com.ningdatech.kqapi.zzsfw.model.entity.KqZzsfwMattersDeduplicate; +import com.ningdatech.kqapi.zzsfw.model.entity.KqZzsfwPolicy; +import com.ningdatech.kqapi.zzsfw.service.IKqZzsfwMatterDeduplicateService; +import com.ningdatech.kqapi.zzsfw.service.IKqZzsfwMenuService; +import com.ningdatech.kqapi.zzsfw.service.IKqZzsfwPolicyService; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Component; +import org.springframework.web.client.RestTemplate; + +import java.util.List; + +/** + * @Classname SynManage + * @Description + * @Date 2023/12/20 15:18 + * @Author PoffyZhang + */ +@Component +@Slf4j +@RequiredArgsConstructor +public class SynManage { + + private final IKqZzsfwMatterDeduplicateService deduplicateService; + + private final IKqZzsfwMenuService menuService; + + private final IKqZzsfwPolicyService policyService; + + private final RestTemplate restTemplate; + + public void synData() { + log.info("同步数据开始"); + //1.去重数据 + List dups = deduplicateService.list(); + for(KqZzsfwMattersDeduplicate dup : dups){ + KqZzsfwMattersDeduplicateDTO dto = BeanUtil.copyProperties(dup, KqZzsfwMattersDeduplicateDTO.class); + HttpHeaders headers = new HttpHeaders(); + MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8"); + headers.setContentType(type); + headers.add("Accept", MediaType.APPLICATION_JSON.toString()); + HttpEntity formEntity = new HttpEntity(JSON.toJSONString(dto), headers); + ResponseEntity stringResponseEntity = restTemplate.postForEntity( + "http://localhost:33061/kq/api/v1/zzsfw/save-dup", formEntity, String.class); + log.info("结果:{}", JSON.toJSONString(stringResponseEntity)); + } + + //2.菜单数据 + List menus = menuService.list(); + for(KqZzsfwMenu menu : menus){ + KqZzsfwMenuDTO dto = BeanUtil.copyProperties(menu, KqZzsfwMenuDTO.class); + HttpHeaders headers = new HttpHeaders(); + MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8"); + headers.setContentType(type); + headers.add("Accept", MediaType.APPLICATION_JSON.toString()); + HttpEntity formEntity = new HttpEntity(JSON.toJSONString(dto), headers); + ResponseEntity stringResponseEntity = restTemplate.postForEntity( + "http://localhost:33061/kq/api/v1/zzsfw/save", formEntity, String.class); + log.info("结果:{}", JSON.toJSONString(stringResponseEntity)); + } + + //3.其它数据 + List policies = policyService.list(); + for(KqZzsfwPolicy policy : policies){ + KqZzsfwPolicyDTO dto = BeanUtil.copyProperties(policy, KqZzsfwPolicyDTO.class); + HttpHeaders headers = new HttpHeaders(); + MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8"); + headers.setContentType(type); + headers.add("Accept", MediaType.APPLICATION_JSON.toString()); + HttpEntity formEntity = new HttpEntity(JSON.toJSONString(dto), headers); + ResponseEntity stringResponseEntity = restTemplate.postForEntity( + "http://localhost:33061/kq/api/v1/poclicy/save", formEntity, String.class); + log.info("结果:{}", JSON.toJSONString(stringResponseEntity)); + } + } +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/scheduler/model/CommonLog.java b/kq-api/src/main/java/com/ningdatech/kqapi/scheduler/model/CommonLog.java new file mode 100644 index 0000000..3853ce8 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/scheduler/model/CommonLog.java @@ -0,0 +1,43 @@ +package com.ningdatech.kqapi.scheduler.model; + +import lombok.Data; + +@Data +public class CommonLog { + /** + * 用户id + */ + private String userId; + /** + * 用户角色(群众、企业、政府工作人员、第三方) + */ + private String userRole; + /** + * 地区编码 + */ + private String areaCode; + /** + * 操作类型(1-登录 2-离开 3-办事开始 4-办事结束) + */ + private Integer actionType; + /** + * 操作标识 + */ + private String actionId; + /** + * 操作时间 + */ + private String actionTime; + /** + * 操作时长 + */ + private Long actionDuration; + /** + * 操作状态(0-成功 1-失败) + */ + private Integer actionStatus; + /** + * 应用编码 + */ + private String appCode; +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/scheduler/task/CheckMattersUrlTask.java b/kq-api/src/main/java/com/ningdatech/kqapi/scheduler/task/CheckMattersUrlTask.java new file mode 100644 index 0000000..9f5820e --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/scheduler/task/CheckMattersUrlTask.java @@ -0,0 +1,162 @@ +package com.ningdatech.kqapi.scheduler.task; + +import cn.hutool.core.date.StopWatch; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.google.common.collect.Lists; +import com.ningdatech.kqapi.common.model.entity.Item; +import com.ningdatech.kqapi.zzsfw.model.entity.KqZzsfwMenu; +import com.ningdatech.kqapi.zzsfw.service.IKqZzsfwMenuService; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.apache.http.conn.ssl.NoopHostnameVerifier; +import org.apache.http.conn.ssl.SSLConnectionSocketFactory; +import org.apache.http.conn.ssl.TrustStrategy; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClientBuilder; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.ssl.SSLContexts; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; +import org.springframework.util.LinkedMultiValueMap; +import org.springframework.util.MultiValueMap; +import org.springframework.web.client.RestTemplate; + +import javax.net.ssl.SSLContext; +import java.net.*; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * @author ZPF + * @since 2023/08/31 18:16 + */ +@Component +@Slf4j +@RequiredArgsConstructor +public class CheckMattersUrlTask { + + @Value("${hostname}") + public String HOST; + + @Value("${spring.profiles.active}") + public String active; + + @Autowired + private IKqZzsfwMenuService menuService; + + /** + * 每天9点 开始校检 链接 是不是可行 + */ + @Scheduled(cron = "0 0 9 * * ?") + public void doTask() throws UnknownHostException, MalformedURLException { +// if (!HOST.equals(InetAddress.getLocalHost().getHostName())) { +// log.info("定时器没开启或者host不对! {}:{}", +// HOST,InetAddress.getLocalHost().getHostName()); +// return; +// } + + StopWatch stopWatch = new StopWatch(); + stopWatch.start(); + + log.info("==========开始校检事项表里的链接 会不会404 如果404就隐藏"); + + List menus = menuService.list(Wrappers.lambdaQuery(KqZzsfwMenu.class) + .eq(KqZzsfwMenu::getHasUrl, 1) + .isNotNull(KqZzsfwMenu::getWebapplyurl)); + Integer errNum = 0; + List errUrls = Lists.newArrayList(); + + for (KqZzsfwMenu menu : menus) { + RestTemplate restTemplate = new RestTemplate(generateHttpRequestFactory()); + String url = "https://www.zjzwfw.gov.cn/jpaas-zjservice-server/open-api/item/getItemDetail"; + MultiValueMap map = new LinkedMultiValueMap<>(); + + String webapplyurl = menu.getWebapplyurl(); + webapplyurl = webapplyurl.replace("/#",""); + Map queryParams = getQueryParams(new URL(webapplyurl)); + String localInnerCode = queryParams.get("localInnerCode"); + log.info("localInnerCode :{}",localInnerCode); + map.add("localInnerCode", localInnerCode); + HttpHeaders headers = new HttpHeaders(); + headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); + HttpEntity> formEntity = new HttpEntity(map, headers); + ResponseEntity response = restTemplate.postForEntity(url, formEntity, Item.class); + System.out.println(response.getBody()); + Item body = response.getBody(); + assert body != null; + Item.ItemData itemData = body.getData(); + //如果是空的 + if(Objects.isNull(itemData.getItem())){ + //隐藏 + menuService.update(Wrappers.lambdaUpdate(KqZzsfwMenu.class) + .eq(KqZzsfwMenu::getId,menu.getId()) + .set(KqZzsfwMenu::getHasUrl,0) + .set(KqZzsfwMenu::getWebapplyurl,null)); + errNum += 1; + errUrls.add(webapplyurl); + } + } + + log.info("不可用的链接有 :{}条 ,详情:{}",errNum,errUrls); + + stopWatch.stop(); + log.info("校检事项表里的链接结束====={}s",stopWatch.getTotalTimeSeconds()); + } + + public static void main(String[] args) throws Exception { + String url = "https://www.zjzwfw.gov.cn/zjservice-fe/#/workguide?localInnerCode=3bd735e2-ddfe-4377-86b3-beec85252f21&siteCode=330000000000"; + url = url.replace("/#",""); + Map queryParams = getQueryParams(new URL(url)); + System.out.println(queryParams.get("localInnerCode")); + } + + public static Map getQueryParams(URL url) { + Map queryPairs = new HashMap<>(); + String query = url.getQuery(); + String[] pairs = query.split("&"); + for (String pair : pairs) { + int idx = pair.indexOf("="); + try { + if (idx > 0) { + String key = pair.substring(0, idx); + String value = pair.substring(idx + 1); + queryPairs.put(key, value); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + return queryPairs; + } + + /** + * 通过该工厂类创建的RestTemplate发送请求时,可忽略https证书认证 + * @return 工厂 + */ + public static HttpComponentsClientHttpRequestFactory generateHttpRequestFactory(){ + try{ + TrustStrategy acceptingTrustStrategy = ((x509Certificates, authType) -> true); + SSLContext sslContext = SSLContexts.custom().loadTrustMaterial(null, acceptingTrustStrategy).build(); + SSLConnectionSocketFactory connectionSocketFactory = new SSLConnectionSocketFactory(sslContext, new NoopHostnameVerifier()); + + HttpClientBuilder httpClientBuilder = HttpClients.custom(); + httpClientBuilder.setSSLSocketFactory(connectionSocketFactory); + CloseableHttpClient httpClient = httpClientBuilder.build(); + HttpComponentsClientHttpRequestFactory factory = new HttpComponentsClientHttpRequestFactory(); + factory.setHttpClient(httpClient); + return factory; + }catch (Exception e){ + e.printStackTrace(); + } + return null; + } +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/scheduler/task/RemoveMattersTask.java b/kq-api/src/main/java/com/ningdatech/kqapi/scheduler/task/RemoveMattersTask.java new file mode 100644 index 0000000..dbbc3a7 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/scheduler/task/RemoveMattersTask.java @@ -0,0 +1,63 @@ +package com.ningdatech.kqapi.scheduler.task; + +import cn.hutool.core.date.StopWatch; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.ningdatech.kqapi.scheduler.contants.TaskContant; +import com.ningdatech.kqapi.zzsfw.model.entity.DscSxAdsShareItemQltQlsxCommonIDVKq; +import com.ningdatech.kqapi.zzsfw.service.IDscSxAdsShareItemQltQlsxCommonIDVKqService; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; +import java.net.InetAddress; +import java.net.UnknownHostException; + +/** + * @author ZPF + * @since 2023/08/31 18:16 + */ +@Component +@Slf4j +@RequiredArgsConstructor +public class RemoveMattersTask { + + @Value("${hostname}") + public String HOST; + + @Value("${spring.profiles.active}") + public String active; + + @Autowired + private IDscSxAdsShareItemQltQlsxCommonIDVKqService kqService; + + /** + * 每天 + */ + @Scheduled(cron = "0 50 14 * * ?") + public void doTask() throws UnknownHostException { + if (!HOST.equals(InetAddress.getLocalHost().getHostName())) { + log.info("定时器没开启或者host不对! {}:{}", + HOST,InetAddress.getLocalHost().getHostName()); + return; + } + if(!TaskContant.PROD.equals(active)){ + log.info("非正式环境不用删除!"); + return; + } + + StopWatch stopWatch = new StopWatch(); + stopWatch.start(); + + log.info("删除事项表 所有数据 等待新数据推上来"); + if(kqService.remove(Wrappers.lambdaQuery(DscSxAdsShareItemQltQlsxCommonIDVKq.class))){ + log.info("删除成功"); + } + + log.info("当前表里还有数据 :{}条",kqService.count()); + + stopWatch.stop(); + log.info("数据同步任务结束====={}s",stopWatch.getTotalTimeSeconds()); + } +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/scheduler/task/SynTask.java b/kq-api/src/main/java/com/ningdatech/kqapi/scheduler/task/SynTask.java new file mode 100644 index 0000000..2dbc4f6 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/scheduler/task/SynTask.java @@ -0,0 +1,205 @@ +package com.ningdatech.kqapi.scheduler.task; + +import cn.hutool.core.date.StopWatch; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.github.benmanes.caffeine.cache.LoadingCache; +import com.ningdatech.kqapi.common.constant.BizConst; +import com.ningdatech.kqapi.common.enumeration.CommonEnum; +import com.ningdatech.kqapi.common.helper.MatterCacheHelper; +import com.ningdatech.kqapi.zzsfw.model.entity.*; +import com.ningdatech.kqapi.zzsfw.service.ComponentsMatterEliminateService; +import com.ningdatech.kqapi.zzsfw.model.entity.KqZzsfwMenu; +import com.ningdatech.kqapi.zzsfw.manage.MatterManage; +import com.ningdatech.kqapi.zzsfw.service.IDscSxAdsShareItemQltQlsxCommonIDVKqService; +import com.ningdatech.kqapi.zzsfw.service.IKqZzsfwMatterDeduplicateService; +import com.ningdatech.kqapi.zzsfw.service.IKqZzsfwMenuService; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; + +import java.net.UnknownHostException; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** + * @Classname SynTask + * @Description + * @Date 2024/1/4 9:04 + * @Author PoffyZhang + */ +@Component +@Slf4j +@RequiredArgsConstructor +public class SynTask { + @Value("${hostname}") + public String HOST; + + @Value("${spring.profiles.active}") + public String active; + + @Autowired + private MatterCacheHelper matterCacheHelper; + + @Autowired + private MatterManage matterManage; + + @Autowired + private IKqZzsfwMatterDeduplicateService matterDeduplicateService; + + @Autowired + private IKqZzsfwMenuService menuService; + + @Autowired + private IDscSxAdsShareItemQltQlsxCommonIDVKqService kqService; + + @Autowired + private ComponentsMatterEliminateService componentsMatterEliminateService; + + protected LoadingCache mattersDupCache; + + private final String KQ_ZZS_BASE_URL = "https://www.zjzwfw.gov.cn/zjservice-fe/#/workguide?localInnerCode=&siteCode=330000000000"; + + /** + * 每天 + */ + @Scheduled(cron = "0 30 8 * * ?") + public void synData() throws UnknownHostException { +// if (!HOST.equals(InetAddress.getLocalHost().getHostName())) { +// log.info("定时器没开启或者host不对! {}:{}", +// HOST,InetAddress.getLocalHost().getHostName()); +// return; +// } +// if(!TaskContant.PROD.equals(active)){ +// log.info("非正式环境不用运行同步任务!"); +// return; +// } + + log.info("政务数据 ===================== 同步开始"); + StopWatch stopWatch = new StopWatch(); + stopWatch.start(); + + //1.处理 去重数据 + if(matterCacheHelper.refreshAll()){ + matterManage.removeAllDup(); + List allDup = matterCacheHelper.all(); + matterDeduplicateService.saveBatch(allDup); + + //2. 事项 + List menus = menuService.list(); + for(KqZzsfwMenu menu : menus){ + String url = matterCacheHelper.getUrl(menu.getItemName()); + if(StringUtils.isBlank(url)){ + menuService.update(Wrappers.lambdaUpdate(KqZzsfwMenu.class) + .eq(KqZzsfwMenu::getId,menu.getId()) + .set(KqZzsfwMenu::getWebapplyurl,null) + .set(KqZzsfwMenu::getHasUrl, CommonEnum.NO.getCode())); + }else{ + menuService.update(Wrappers.lambdaUpdate(KqZzsfwMenu.class) + .eq(KqZzsfwMenu::getId,menu.getId()) + .set(KqZzsfwMenu::getWebapplyurl,url) + .set(KqZzsfwMenu::getHasUrl,CommonEnum.YES.getCode())); + } + } + } + + stopWatch.stop(); + log.info("政务数据 ===================== 同步总共耗时 :{} s",stopWatch.getTotalTimeSeconds()); + } + + public void synMenu() { + //2. 事项 + List menus = menuService.list(); + for(KqZzsfwMenu menu : menus){ + String url = matterCacheHelper.getUrl(menu.getItemName()); + log.info("当前缓存的数据 : {},{}",menu.getItemName(),url); + if(StringUtils.isBlank(url)){ + menuService.update(Wrappers.lambdaUpdate(KqZzsfwMenu.class) + .eq(KqZzsfwMenu::getId,menu.getId()) + .set(KqZzsfwMenu::getWebapplyurl,null) + .set(KqZzsfwMenu::getHasUrl, CommonEnum.NO.getCode())); + }else{ + menuService.update(Wrappers.lambdaUpdate(KqZzsfwMenu.class) + .eq(KqZzsfwMenu::getId,menu.getId()) + .set(KqZzsfwMenu::getWebapplyurl,url) + .set(KqZzsfwMenu::getHasUrl,CommonEnum.YES.getCode())); + } + } + } + + public String synEliminate(List keys){ +// kqService.remove(new LambdaQueryWrapper() +// .in(DscSxAdsShareItemQltQlsxCommonIDVKq::getQlName, keys)); + // 添加剔除信息 + List entityList = new ArrayList<>(); + keys.forEach(key ->{ + ComponentsMatterEliminateEntity one = componentsMatterEliminateService.getOne(Wrappers.lambdaQuery(ComponentsMatterEliminateEntity.class) + .eq(ComponentsMatterEliminateEntity::getQlName, key)); + if (Objects.isNull(one)){ + entityList.add(new ComponentsMatterEliminateEntity(key,"1")); + } + // 删除缓存 + DscSxAdsShareItemQltQlsxCommonIDVKq matter = getSynUrl(key); + String url = KQ_ZZS_BASE_URL.replace("localInnerCode=", "localInnerCode=" + matter.getQlInnerCode()); + MatterKey matterKey = MatterKey.of(matter.getQlName(),url); + try { + mattersDupCache.invalidate(matterKey); + }catch (Exception e){ + log.error("mattersDupCache is null", e.getMessage()); + } + }); + componentsMatterEliminateService.saveBatch(entityList); + + // 删除menu表 + menuService.remove(new LambdaQueryWrapper() + .in(KqZzsfwMenu::getItemName, keys)); + + // 删除deduplicate表 + matterDeduplicateService.remove(new LambdaQueryWrapper() + .in(KqZzsfwMattersDeduplicate::getQlName, keys)); + + return "剔除成功"; + } + + public DscSxAdsShareItemQltQlsxCommonIDVKq getSynUrl(String key){ + DscSxAdsShareItemQltQlsxCommonIDVKq matter = kqService + .getOne(Wrappers.lambdaQuery(DscSxAdsShareItemQltQlsxCommonIDVKq.class) + .select(DscSxAdsShareItemQltQlsxCommonIDVKq::getRowguid, + DscSxAdsShareItemQltQlsxCommonIDVKq::getQlName, + DscSxAdsShareItemQltQlsxCommonIDVKq::getQlState, + DscSxAdsShareItemQltQlsxCommonIDVKq::getQlInnerCode, + DscSxAdsShareItemQltQlsxCommonIDVKq::getWebapplyurl) + .eq(DscSxAdsShareItemQltQlsxCommonIDVKq::getQlName, key) + .eq(DscSxAdsShareItemQltQlsxCommonIDVKq::getQlState, "1") + .isNotNull(DscSxAdsShareItemQltQlsxCommonIDVKq::getWebapplyurl) + // 确保getQlInnerCodeItem字段不为null且不为"" + .isNotNull(DscSxAdsShareItemQltQlsxCommonIDVKq::getQlInnerCode) + .ne(DscSxAdsShareItemQltQlsxCommonIDVKq::getQlInnerCode, "") + .orderByDesc(DscSxAdsShareItemQltQlsxCommonIDVKq::getUpdateDate) + .last(BizConst.LIMIT_1)); + return matter; + } + + public String synSingle(String key){ + DscSxAdsShareItemQltQlsxCommonIDVKq matter = getSynUrl(key); + String url = KQ_ZZS_BASE_URL.replace("localInnerCode=", "localInnerCode=" + matter.getQlInnerCode()); + List menus = menuService.list(Wrappers.lambdaQuery(KqZzsfwMenu.class) + .eq(KqZzsfwMenu::getItemName, key)); + menus.forEach(menu->{ + menuService.update(Wrappers.lambdaUpdate(KqZzsfwMenu.class) + .eq(KqZzsfwMenu::getId,menu.getId()) + .set(KqZzsfwMenu::getWebapplyurl,url) + .set(KqZzsfwMenu::getHasUrl,CommonEnum.YES.getCode())); + }); + // 更新缓存 + MatterKey matterKey = MatterKey.of(matter.getQlName(),url); + mattersDupCache.invalidate(matterKey); + mattersDupCache.put(matterKey, KqZzsfwMattersDeduplicate.of(matter.getQlName(),url)); + return "更新成功,rul:" + url; + } +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/scheduler/utils/DateUtil.java b/kq-api/src/main/java/com/ningdatech/kqapi/scheduler/utils/DateUtil.java new file mode 100644 index 0000000..5093758 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/scheduler/utils/DateUtil.java @@ -0,0 +1,37 @@ +package com.ningdatech.kqapi.scheduler.utils; + +import java.time.LocalDateTime; +import java.time.ZoneId; +import java.util.Calendar; +import java.util.Date; +import java.util.Objects; + +/** + * @Classname DateUtil + * @Description + * @Date 2023/8/31 15:36 + * @Author PoffyZhang + */ +public class DateUtil { + + public static Date getTodayTime(int hour){ + // 获取当前日期时间 + Calendar calendar = Calendar.getInstance(); + + // 将时间设置为凌晨 + calendar.set(Calendar.HOUR_OF_DAY, hour); + calendar.set(Calendar.MINUTE, 0); + calendar.set(Calendar.SECOND, 0); + + // 获取凌晨时间 + Date date = calendar.getTime(); + return date; + } + + public static LocalDateTime convertDateToLocal(Date date){ + if(Objects.isNull(date)){ + return null; + } + return date.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime(); + } +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/security/AuthBeanConfig.java b/kq-api/src/main/java/com/ningdatech/kqapi/security/AuthBeanConfig.java new file mode 100644 index 0000000..ee5eb87 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/security/AuthBeanConfig.java @@ -0,0 +1,31 @@ +package com.ningdatech.kqapi.security; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.security.core.session.SessionRegistry; +import org.springframework.security.core.session.SessionRegistryImpl; +import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; +import org.springframework.security.crypto.password.PasswordEncoder; + +/** + *

+ * AuthBeanConfig + *

+ * + * @author WendyYang + * @since 11:23 2024/4/20 + */ +@Configuration +public class AuthBeanConfig { + + @Bean + public PasswordEncoder passwordEncoder() { + return new BCryptPasswordEncoder(); + } + + @Bean + public SessionRegistry sessionRegistry() { + return new SessionRegistryImpl(); + } + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/security/AuthProperties.java b/kq-api/src/main/java/com/ningdatech/kqapi/security/AuthProperties.java new file mode 100644 index 0000000..9b26e9a --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/security/AuthProperties.java @@ -0,0 +1,56 @@ +package com.ningdatech.kqapi.security; + +import com.ningdatech.basic.factory.PropertySourceFactory; +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.PropertySource; +import org.springframework.stereotype.Component; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + *

+ * AuthProperties + *

+ * + * @author WendyYang + * @since 11:15 2024/4/20 + */ +@Configuration +@PropertySource(value = "classpath:security/auth-${spring.profiles.active}.yml" + , encoding = "utf-8", factory = PropertySourceFactory.class) +@ConfigurationProperties(prefix = "security.auth") +@Component +@Data +public class AuthProperties { + + private Boolean postOnlyByLogin = true; + + private String authRequireUrl; + + private String invalidSessionUrl; + + private String passwordLoginUrl; + + private String logoutUrl; + + private List ignoreAuthUrls; + + private List ignoreCsrfUrls; + + private Map> roleMap = new HashMap<>(); + + public String[] getIgnoreAuthUrlsArray() { + String[] stringArray = new String[ignoreAuthUrls.size()]; + return ignoreAuthUrls.toArray(stringArray); + } + + public String[] getIgnoreCsrfUrlsArray() { + String[] stringArray = new String[ignoreCsrfUrls.size()]; + return ignoreCsrfUrls.toArray(stringArray); + } + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/security/WebSecurityConfig.java b/kq-api/src/main/java/com/ningdatech/kqapi/security/WebSecurityConfig.java new file mode 100644 index 0000000..5718e44 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/security/WebSecurityConfig.java @@ -0,0 +1,91 @@ +package com.ningdatech.kqapi.security; + +import com.ningdatech.basic.util.NdJsonUtil; +import com.ningdatech.basic.util.StrPool; +import com.ningdatech.kqapi.common.constant.BizConst; +import com.ningdatech.kqapi.security.handler.DefaultExpiredSessionStrategy; +import com.ningdatech.kqapi.security.handler.DefaultInvalidSessionStrategy; +import com.ningdatech.kqapi.security.password.PasswordAuthSecurityConfig; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.HttpStatus; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; +import org.springframework.security.web.AuthenticationEntryPoint; +import org.springframework.security.web.authentication.logout.LogoutSuccessHandler; +import org.springframework.security.web.csrf.CookieCsrfTokenRepository; + +import java.io.PrintWriter; + +/** + *

+ * WebSecurityConfig + *

+ * + * @author WendyYang + * @since 11:07 2024/4/20 + */ +@Configuration +public class WebSecurityConfig extends WebSecurityConfigurerAdapter { + + private final AuthProperties authProperties; + private final PasswordAuthSecurityConfig passwordAuthSecurityConfig; + private final LogoutSuccessHandler logoutSuccessHandler; + private final DefaultExpiredSessionStrategy expiredSessionStrategy; + private final DefaultInvalidSessionStrategy invalidSessionStrategy; + + public WebSecurityConfig(AuthProperties authProperties, + PasswordAuthSecurityConfig passwordAuthSecurityConfig, + LogoutSuccessHandler logoutSuccessHandler, + DefaultExpiredSessionStrategy expiredSessionStrategy, + DefaultInvalidSessionStrategy invalidSessionStrategy) { + this.authProperties = authProperties; + this.passwordAuthSecurityConfig = passwordAuthSecurityConfig; + this.logoutSuccessHandler = logoutSuccessHandler; + this.expiredSessionStrategy = expiredSessionStrategy; + this.invalidSessionStrategy = invalidSessionStrategy; + } + + @Override + protected void configure(HttpSecurity http) throws Exception { + http.formLogin() + .and() + .exceptionHandling() + .authenticationEntryPoint(authenticationEntryPoint()) + .and().apply(passwordAuthSecurityConfig) + .and() + .authorizeRequests() + .antMatchers(authProperties.getIgnoreAuthUrlsArray()).permitAll() + .anyRequest() + .authenticated() + .and() + // 防止固定会话攻击,Spring security的默认配置就是如此: + // 登陆成功之后会创建一个新的会话,然后将旧的session信息复制到新的session中(客户端的sessionId变了) + .sessionManagement() + .invalidSessionStrategy(invalidSessionStrategy) + .sessionFixation() + .migrateSession() + // .invalidSessionStrategy(defaultInvalidSessionStrategy) + .maximumSessions(3) + .maxSessionsPreventsLogin(true) + .expiredSessionStrategy(expiredSessionStrategy) + .and().and().logout().logoutUrl(authProperties.getLogoutUrl()) + .logoutSuccessHandler(logoutSuccessHandler) + .deleteCookies(BizConst.COOKIE_KEY) + .and() + // 开启csrf验证,需要前端同步传入token + .csrf().csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse()) + .ignoringAntMatchers(authProperties.getIgnoreCsrfUrlsArray()); + } + + private AuthenticationEntryPoint authenticationEntryPoint() { + return (request, response, authException) -> { + response.setContentType(StrPool.CONTENT_TYPE); + response.setStatus(HttpStatus.UNAUTHORIZED.value()); + PrintWriter writer = response.getWriter(); + writer.write(NdJsonUtil.getInstance().writeValueAsString(BizConst.UNAUTHENTICATED)); + writer.flush(); + writer.close(); + }; + } + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/security/config/RedisSessionConfig.java b/kq-api/src/main/java/com/ningdatech/kqapi/security/config/RedisSessionConfig.java new file mode 100644 index 0000000..4103f92 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/security/config/RedisSessionConfig.java @@ -0,0 +1,54 @@ +package com.ningdatech.kqapi.security.config; + +import cn.hutool.core.util.StrUtil; +import com.ningdatech.basic.util.StrPool; +import com.ningdatech.kqapi.common.constant.BizConst; +import com.ningdatech.kqapi.security.constant.AuthConst; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.session.data.redis.RedisIndexedSessionRepository; +import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession; +import org.springframework.session.web.http.CookieHttpSessionIdResolver; +import org.springframework.session.web.http.DefaultCookieSerializer; + +/** + *

+ * 设置session的过期时间为一天 + *

+ * + * @author WendyYang + * @since 00:22 2023/3/2 + */ +@Configuration +@EnableRedisHttpSession( + maxInactiveIntervalInSeconds = RedisSessionConfig.SESSION_TIMEOUT, + redisNamespace = RedisSessionConfig.REDIS_NAMESPACE +) +public class RedisSessionConfig { + + static final int SESSION_TIMEOUT = 60 * 60 * 24; + + static final String REDIS_NAMESPACE = "#{redisSessionConfig.getRedisNamespace()}"; + + @Value("${nd.cache.def.keyPrefix:}") + private String keyPrefix; + + public String getRedisNamespace() { + return (StrUtil.isBlank(keyPrefix) ? StrPool.EMPTY : keyPrefix + StrPool.COLON) + RedisIndexedSessionRepository.DEFAULT_NAMESPACE; + } + + @Bean + public CookieHttpSessionIdResolver sessionIdResolver() { + // 创建 CookieHttpSessionIdResolver 对象 + CookieHttpSessionIdResolver sessionIdResolver = new CookieHttpSessionIdResolver(); + // 创建 DefaultCookieSerializer 对象 + DefaultCookieSerializer cookieSerializer = new DefaultCookieSerializer(); + cookieSerializer.setCookieName(BizConst.COOKIE_KEY); + cookieSerializer.setCookieMaxAge(AuthConst.SESSION_TIME_SECONDS); + // 设置到 sessionIdResolver 中 + sessionIdResolver.setCookieSerializer(cookieSerializer); + return sessionIdResolver; + } + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/security/constant/AuthConst.java b/kq-api/src/main/java/com/ningdatech/kqapi/security/constant/AuthConst.java new file mode 100644 index 0000000..608eafa --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/security/constant/AuthConst.java @@ -0,0 +1,29 @@ +package com.ningdatech.kqapi.security.constant; + +/** + *

+ * 授权相关常量 + *

+ * + * @author WendyYang + * @since 2023/9/1 + **/ +public class AuthConst { + + private AuthConst() { + } + + public static final Integer SESSION_TIME_SECONDS = 24 * 60 * 60 * 10; + public static final Integer SESSION_EXPIRED = 0; + + public static final String USERNAME = "username"; + + public static final String PASSWORD = "password"; + + public static final String LOGIN_PLATFORM = "loginPlatform"; + + public static final String DEVICE_MODEL = "deviceModel"; + + public static final String OPEN_ID = "openId"; + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/security/constant/AuthTypeEnum.java b/kq-api/src/main/java/com/ningdatech/kqapi/security/constant/AuthTypeEnum.java new file mode 100644 index 0000000..62b5af7 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/security/constant/AuthTypeEnum.java @@ -0,0 +1,49 @@ +package com.ningdatech.kqapi.security.constant; + +import lombok.Getter; + +/** + * @author LiuXinXin + * @date 2021/7/30 下午2:10 + */ +@Getter +public enum AuthTypeEnum { + + /** + * 手机 + 密码的认证方式 + */ + PHONE_PASSWORD("phone_password"), + + /** + * 子账号 账号 + 密码的认证方式 + */ + ACCOUNT_PASSWORD("account_password"); + + private final String key; + + AuthTypeEnum(String key) { + this.key = key; + } + + public static boolean contains(String key) { + for (AuthTypeEnum value : AuthTypeEnum.values()) { + if (key.equals(value.getKey())) { + return true; + } + } + return false; + } + + public String getKey() { + return key; + } + + public static AuthTypeEnum of(String key) { + for (AuthTypeEnum value : AuthTypeEnum.values()) { + if (key.equals(value.getKey())) { + return value; + } + } + throw new IllegalArgumentException(String.format("无效的AuthTypeEnum:%s", key)); + } +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/security/constant/LoginPlatformEnum.java b/kq-api/src/main/java/com/ningdatech/kqapi/security/constant/LoginPlatformEnum.java new file mode 100644 index 0000000..a1c755a --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/security/constant/LoginPlatformEnum.java @@ -0,0 +1,28 @@ +package com.ningdatech.kqapi.security.constant; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * @author liuxinxin + * @date 2022/11/24 下午5:45 + * 登陆平台 + */ +@Getter +@AllArgsConstructor +public enum LoginPlatformEnum { + + // PC 端 + PC_PLATFORM, + + // 驾驶员端 + DRIVER_PLATFORM, + + // 企业端 + ENTERPRISE_PLATFORM; + + public boolean eq(String platform) { + return this.name().equals(platform); + } + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/security/facade/UserAuthLoginFacade.java b/kq-api/src/main/java/com/ningdatech/kqapi/security/facade/UserAuthLoginFacade.java new file mode 100644 index 0000000..1b2ad78 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/security/facade/UserAuthLoginFacade.java @@ -0,0 +1,58 @@ +package com.ningdatech.kqapi.security.facade; + +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.ningdatech.kqapi.common.constant.BizConst; +import com.ningdatech.kqapi.security.constant.AuthTypeEnum; +import com.ningdatech.kqapi.user.model.entity.UserAuth; +import com.ningdatech.kqapi.user.model.entity.UserInfo; +import com.ningdatech.kqapi.security.model.dto.UserInfoBO; +import com.ningdatech.kqapi.user.service.IUserAuthService; +import com.ningdatech.kqapi.user.service.IUserInfoService; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Component; + +import java.util.Arrays; +import java.util.List; +import java.util.Objects; + +/** + *

+ * UserAuthLoginFacade + *

+ * + * @author WendyYang + * @since 10:14 2024/4/20 + */ +@Component +@RequiredArgsConstructor +public class UserAuthLoginFacade { + + private final IUserAuthService userAuthService; + private final IUserInfoService userInfoService; + + private static final List AUTH_TYPES = Arrays.asList(AuthTypeEnum.ACCOUNT_PASSWORD.getKey(), + AuthTypeEnum.PHONE_PASSWORD.getKey()); + + + public UserInfoBO queryUserInfoInPasswordAuth(String username) { + // 获取用户鉴权信息 + UserAuth userAuth = userAuthService.getOne(Wrappers.lambdaQuery(UserAuth.class) + .eq(UserAuth::getIdentifier, username) + .in(UserAuth::getAuthType, AUTH_TYPES) + .last(BizConst.LIMIT_1)); + if (Objects.isNull(userAuth)) { + return null; + } + // 获取用户详情信息 + UserInfo userInfo = userInfoService.getById(userAuth.getUserId()); + UserInfoBO user = new UserInfoBO(); + user.setAccountStatus(userInfo.getAccountStatus()); + user.setUserId(userInfo.getId()); + user.setRealName(userInfo.getRealName()); + user.setUsername(userInfo.getUsername()); + user.setRole(userInfo.getRole()); + user.setIdentifier(userAuth.getIdentifier()); + user.setCredential(userAuth.getCredential()); + return user; + } +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/security/handler/DefaultExpiredSessionStrategy.java b/kq-api/src/main/java/com/ningdatech/kqapi/security/handler/DefaultExpiredSessionStrategy.java new file mode 100644 index 0000000..c4bbf62 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/security/handler/DefaultExpiredSessionStrategy.java @@ -0,0 +1,38 @@ +package com.ningdatech.kqapi.security.handler; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.ningdatech.kqapi.common.constant.BizConst; +import lombok.extern.slf4j.Slf4j; +import org.springframework.security.web.session.SessionInformationExpiredEvent; +import org.springframework.security.web.session.SessionInformationExpiredStrategy; +import org.springframework.stereotype.Component; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +/** + *

+ * DefaultExpiredSessionStrategy + *

+ * + * @author WendyYang + * @since 11:33 2024/4/20 + */ +@Slf4j +@Component +public class DefaultExpiredSessionStrategy implements SessionInformationExpiredStrategy { + + private final ObjectMapper objectMapper; + + public DefaultExpiredSessionStrategy(ObjectMapper objectMapper) { + this.objectMapper = objectMapper; + } + + @Override + public void onExpiredSessionDetected(SessionInformationExpiredEvent sessionInformationExpiredEvent) throws IOException { + HttpServletResponse response = sessionInformationExpiredEvent.getResponse(); + response.setContentType(BizConst.JSON_UTF8); + response.getWriter().write(objectMapper.writeValueAsString(BizConst.SESSION_EXPIRE)); + } + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/security/handler/DefaultInvalidSessionStrategy.java b/kq-api/src/main/java/com/ningdatech/kqapi/security/handler/DefaultInvalidSessionStrategy.java new file mode 100644 index 0000000..6441b1c --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/security/handler/DefaultInvalidSessionStrategy.java @@ -0,0 +1,35 @@ +package com.ningdatech.kqapi.security.handler; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.ningdatech.kqapi.common.constant.BizConst; +import lombok.AllArgsConstructor; +import org.apache.http.HttpStatus; +import org.springframework.security.web.session.InvalidSessionStrategy; +import org.springframework.stereotype.Component; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +/** + *

+ * DefaultInvalidSessionStrategy + *

+ * + * @author WendyYang + * @since 13:52 2023/3/2 + */ +@Component +@AllArgsConstructor +public class DefaultInvalidSessionStrategy implements InvalidSessionStrategy { + + private final ObjectMapper objectMapper; + + @Override + public void onInvalidSessionDetected(HttpServletRequest request, HttpServletResponse response) throws IOException { + response.setContentType(BizConst.JSON_UTF8); + response.setStatus(HttpStatus.SC_UNAUTHORIZED); + response.getWriter().write(objectMapper.writeValueAsString(BizConst.SESSION_EXPIRE)); + } + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/security/handler/DefaultLoginFailureHandler.java b/kq-api/src/main/java/com/ningdatech/kqapi/security/handler/DefaultLoginFailureHandler.java new file mode 100644 index 0000000..2b26ac3 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/security/handler/DefaultLoginFailureHandler.java @@ -0,0 +1,53 @@ +package com.ningdatech.kqapi.security.handler; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.ningdatech.basic.model.ApiResponse; +import lombok.extern.slf4j.Slf4j; +import org.springframework.context.annotation.Primary; +import org.springframework.http.HttpStatus; +import org.springframework.security.authentication.BadCredentialsException; +import org.springframework.security.core.AuthenticationException; +import org.springframework.security.core.userdetails.UsernameNotFoundException; +import org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler; +import org.springframework.stereotype.Component; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +/** + *

+ * 登录失败处理器 + *

+ * + * @author WendyYang + * @since 00:11 2023/3/2 + */ +@Slf4j +@Primary +@Component +public class DefaultLoginFailureHandler extends SimpleUrlAuthenticationFailureHandler { + + private final ObjectMapper objectMapper; + + public DefaultLoginFailureHandler(ObjectMapper objectMapper) { + this.objectMapper = objectMapper; + } + + @Override + public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response, + AuthenticationException e) throws IOException { + response.setContentType("application/json;charset=UTF-8"); + ApiResponse apiRet; + // 所有的认证异常都可以在这里添加,目前只支持用户名密码错误异常 + if (e instanceof BadCredentialsException || e instanceof UsernameNotFoundException) { + apiRet = ApiResponse.of(ApiResponse.ERROR_CODE, e.getMessage()); + } else { + apiRet = ApiResponse.of(ApiResponse.ERROR_CODE, "登录失败,请联系管理员"); + } + + response.setStatus(HttpStatus.OK.value()); + response.getWriter().write(objectMapper.writeValueAsString(apiRet)); + } + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/security/handler/DefaultLoginSuccessHandler.java b/kq-api/src/main/java/com/ningdatech/kqapi/security/handler/DefaultLoginSuccessHandler.java new file mode 100644 index 0000000..3106c98 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/security/handler/DefaultLoginSuccessHandler.java @@ -0,0 +1,42 @@ +package com.ningdatech.kqapi.security.handler; + +import cn.hutool.core.util.CharsetUtil; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.ningdatech.basic.model.ApiResponse; +import org.springframework.context.annotation.Primary; +import org.springframework.http.MediaType; +import org.springframework.security.core.Authentication; +import org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler; +import org.springframework.stereotype.Component; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +/** + *

+ * DefaultLoginSuccessHandler + *

+ * + * @author WendyYang + * @since 11:26 2024/4/20 + */ +@Primary +@Component("defaultLoginSuccessHandler") +public class DefaultLoginSuccessHandler extends SavedRequestAwareAuthenticationSuccessHandler { + + private final ObjectMapper objectMapper; + + public DefaultLoginSuccessHandler(ObjectMapper objectMapper) { + this.objectMapper = objectMapper; + } + + @Override + public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, + Authentication authentication) throws IOException { + response.setContentType(MediaType.APPLICATION_JSON_VALUE); + response.setCharacterEncoding(CharsetUtil.UTF_8); + response.getWriter().write(objectMapper.writeValueAsString(ApiResponse.ofSuccess())); + } + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/security/handler/DefaultLogoutSuccessHandler.java b/kq-api/src/main/java/com/ningdatech/kqapi/security/handler/DefaultLogoutSuccessHandler.java new file mode 100644 index 0000000..e24d0d7 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/security/handler/DefaultLogoutSuccessHandler.java @@ -0,0 +1,35 @@ +package com.ningdatech.kqapi.security.handler; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.ningdatech.basic.model.ApiResponse; +import org.springframework.context.annotation.Primary; +import org.springframework.security.core.Authentication; +import org.springframework.security.web.authentication.logout.LogoutSuccessHandler; +import org.springframework.stereotype.Component; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +/** + *

+ * 默认的退出成功处理器 + *

+ * + * @author WendyYang + * @since 00:10 2023/3/2 + */ +@Primary +@Component +public class DefaultLogoutSuccessHandler implements LogoutSuccessHandler { + + private final ObjectMapper objectMapper = new ObjectMapper(); + + @Override + public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) + throws IOException { + // 退出成功后返回 和前端约定的Json + response.setContentType("application/json;charset=UTF-8"); + response.getWriter().write(objectMapper.writeValueAsString(ApiResponse.ofSuccess())); + } +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/security/listener/AuthEventListener.java b/kq-api/src/main/java/com/ningdatech/kqapi/security/listener/AuthEventListener.java new file mode 100644 index 0000000..fc15277 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/security/listener/AuthEventListener.java @@ -0,0 +1,82 @@ +package com.ningdatech.kqapi.security.listener; + +import cn.hutool.core.date.LocalDateTimeUtil; +import com.ningdatech.kqapi.security.model.UserInfoDetails; +import com.ningdatech.kqapi.security.model.WebRequestDetails; +import com.ningdatech.log.model.OptLogDTO; +import com.ningdatech.log.model.enumeration.LogType; +import com.ningdatech.log.service.OptLogService; +import com.ningdatech.log.util.AddressUtil; +import lombok.RequiredArgsConstructor; +import org.springframework.context.event.EventListener; +import org.springframework.scheduling.annotation.Async; +import org.springframework.security.authentication.event.AbstractAuthenticationEvent; +import org.springframework.security.authentication.event.AuthenticationSuccessEvent; +import org.springframework.security.authentication.event.LogoutSuccessEvent; +import org.springframework.security.core.Authentication; +import org.springframework.stereotype.Component; + +import java.time.LocalDateTime; +import java.time.temporal.ChronoUnit; + +/** + *

+ * AuthEventListener + *

+ * + * @author WendyYang + * @since 11:27 2024/4/20 + */ +@Component +@RequiredArgsConstructor +public class AuthEventListener { + + private final OptLogService optLogService; + + private static final String LOGIN = "用户登录"; + + private static final String LOGOUT = "退出登录"; + + @Async + @EventListener(AuthenticationSuccessEvent.class) + public void loginSuccessListener(AuthenticationSuccessEvent event) { + OptLogDTO optLog = buildOptLog(LOGIN, event); + optLogService.save(optLog); + } + + @Async + @EventListener(LogoutSuccessEvent.class) + public void logoutSuccessListener(LogoutSuccessEvent event) { + OptLogDTO optLog = buildOptLog(LOGOUT, event); + optLogService.save(optLog); + } + + private OptLogDTO buildOptLog(String description, AbstractAuthenticationEvent event) { + Authentication authentication = event.getAuthentication(); + UserInfoDetails userDetails = (UserInfoDetails) authentication.getPrincipal(); + WebRequestDetails webDetails = (WebRequestDetails) authentication.getDetails(); + OptLogDTO optLog = new OptLogDTO(); + optLog.setActionMethod(webDetails.getServletPath()); + optLog.setDescription(description); + if (event instanceof AuthenticationSuccessEvent) { + optLog.setStartTime(webDetails.getLoginTime()); + } else { + optLog.setStartTime(LocalDateTimeUtil.of(event.getTimestamp())); + } + LocalDateTime now = LocalDateTime.now(); + optLog.setFinishTime(now); + optLog.setCreateOn(now); + long consumingTime = ChronoUnit.MILLIS.between(optLog.getStartTime(), now); + optLog.setConsumingTime(consumingTime); + optLog.setHttpMethod(webDetails.getMethod()); + optLog.setUserName(userDetails.getRealName()); + optLog.setCreateBy(userDetails.getUserId()); + optLog.setRequestIp(webDetails.getRequestIp()); + optLog.setRequestUri(webDetails.getRequestUri()); + optLog.setRegionByIp(AddressUtil.getRegion(optLog.getRequestIp())); + optLog.setUa(webDetails.getUserAgent()); + optLog.setType(LogType.OPT.name()); + return optLog; + } + +} \ No newline at end of file diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/security/model/UserInfoDetails.java b/kq-api/src/main/java/com/ningdatech/kqapi/security/model/UserInfoDetails.java new file mode 100644 index 0000000..9c34ba2 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/security/model/UserInfoDetails.java @@ -0,0 +1,69 @@ +package com.ningdatech.kqapi.security.model; + +import cn.hutool.core.collection.CollectionUtil; +import com.ningdatech.basic.auth.AbstractLoginUser; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.springframework.security.core.GrantedAuthority; +import org.springframework.security.core.authority.SimpleGrantedAuthority; +import org.springframework.security.core.userdetails.UserDetails; + +import java.util.Collection; +import java.util.List; + +/** + * @author LiuXinXin + * @date 2022/8/1 下午3:32 + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class UserInfoDetails extends AbstractLoginUser implements UserDetails { + + private static final long serialVersionUID = 8576155784065239307L; + + private String password; + + private String role; + + /** + * 获取用户权限 + * + * @return + */ + @Override + public Collection getAuthorities() { + SimpleGrantedAuthority simpleGrantedAuthority = new SimpleGrantedAuthority(this.role); + return CollectionUtil.toList(simpleGrantedAuthority); + } + + @Override + public String getPassword() { + return password; + } + + @Override + public String getUsername() { + return getIdentifier(); + } + + @Override + public boolean isAccountNonExpired() { + return true; + } + + @Override + public boolean isAccountNonLocked() { + return true; + } + + @Override + public boolean isCredentialsNonExpired() { + return true; + } + + @Override + public boolean isEnabled() { + return true; + } + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/security/model/WebRequestDetails.java b/kq-api/src/main/java/com/ningdatech/kqapi/security/model/WebRequestDetails.java new file mode 100644 index 0000000..5a6e530 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/security/model/WebRequestDetails.java @@ -0,0 +1,55 @@ +package com.ningdatech.kqapi.security.model; + +import cn.hutool.core.util.StrUtil; +import cn.hutool.extra.servlet.ServletUtil; +import lombok.Getter; +import org.springframework.security.web.authentication.WebAuthenticationDetails; + +import javax.servlet.http.HttpServletRequest; +import java.time.LocalDateTime; + +/** + *

+ * WebRequestDetails + *

+ * + * @author WendyYang + * @since 2023/6/7 + **/ +@Getter +public class WebRequestDetails extends WebAuthenticationDetails { + + private static final long serialVersionUID = -4466339683132696235L; + + private final String requestIp; + + private final String requestUri; + + private final String method; + + private final String servletPath; + + private final String requestUrl; + + private final String userAgent; + + private final LocalDateTime loginTime; + + /** + * Records the remote address and will also set the session Id if a session already + * exists (it won't create one). + * + * @param request that the authentication request was received from + */ + public WebRequestDetails(HttpServletRequest request, LocalDateTime loginTime) { + super(request); + this.requestUri = request.getRequestURI(); + this.method = request.getMethod(); + this.servletPath = request.getServletPath(); + this.requestUrl = request.getRequestURL().toString(); + this.requestIp = ServletUtil.getClientIP(request); + this.userAgent = StrUtil.sub(request.getHeader("user-agent"), 0, 500); + this.loginTime = loginTime; + } + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/security/model/dto/LoginDeviceInfoDTO.java b/kq-api/src/main/java/com/ningdatech/kqapi/security/model/dto/LoginDeviceInfoDTO.java new file mode 100644 index 0000000..1c5a456 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/security/model/dto/LoginDeviceInfoDTO.java @@ -0,0 +1,20 @@ +package com.ningdatech.kqapi.security.model.dto; + +import lombok.Data; + +/** + *

+ * WechatLoginDeviceInfoDTO + *

+ * + * @author WendyYang + * @since 2023/10/31 + **/ +@Data +public class LoginDeviceInfoDTO { + + private String deviceModel; + + private String openId; + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/security/model/dto/UserInfoBO.java b/kq-api/src/main/java/com/ningdatech/kqapi/security/model/dto/UserInfoBO.java new file mode 100644 index 0000000..51227f8 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/security/model/dto/UserInfoBO.java @@ -0,0 +1,31 @@ +package com.ningdatech.kqapi.security.model.dto; + +import com.ningdatech.kqapi.user.model.enumerization.AccountStatus; +import lombok.Data; + +/** + *

+ * UserInfoBO + *

+ * + * @author WendyYang + * @since 10:16 2024/4/20 + */ +@Data +public class UserInfoBO { + + private Long userId; + + private String realName; + + private String username; + + private String identifier; + + private String credential; + + private String role; + + private AccountStatus accountStatus; + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/security/password/PasswordAuthProvider.java b/kq-api/src/main/java/com/ningdatech/kqapi/security/password/PasswordAuthProvider.java new file mode 100644 index 0000000..839e0a0 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/security/password/PasswordAuthProvider.java @@ -0,0 +1,42 @@ +package com.ningdatech.kqapi.security.password; + +import com.ningdatech.kqapi.user.helper.LoginHelper; +import lombok.Setter; +import org.springframework.security.authentication.AuthenticationProvider; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.AuthenticationException; +import org.springframework.security.core.userdetails.UserDetails; +import org.springframework.security.core.userdetails.UserDetailsService; + +/** + *

+ * UsernamePasswordAuthProvider + *

+ * + * @author LiuXinXin + * @since 2020/8/3 8:55 下午 + **/ +@Setter +public class PasswordAuthProvider implements AuthenticationProvider { + + private UserDetailsService userDetailsService; + + private LoginHelper loginHelper; + + @Override + public Authentication authenticate(Authentication authentication) throws AuthenticationException { + UsernamePasswordAuthToken authToken = (UsernamePasswordAuthToken) authentication; + + UserDetails user = userDetailsService.loadUserByUsername((String) authToken.getPrincipal()); + loginHelper.checkPassword(user, authToken); + // 校验用户是否有当前端的登陆权限 + // 将用户定义的user放入token中,这样可以在session中查询到所有自定义的用户信息 + return new UsernamePasswordAuthToken(user, user.getPassword(), user.getAuthorities()); + } + + @Override + public boolean supports(Class authentication) { + return UsernamePasswordAuthToken.class.isAssignableFrom(authentication); + } + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/security/password/PasswordAuthSecurityConfig.java b/kq-api/src/main/java/com/ningdatech/kqapi/security/password/PasswordAuthSecurityConfig.java new file mode 100644 index 0000000..b8b931f --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/security/password/PasswordAuthSecurityConfig.java @@ -0,0 +1,51 @@ +package com.ningdatech.kqapi.security.password; + +import com.ningdatech.kqapi.security.AuthProperties; +import com.ningdatech.kqapi.user.helper.LoginHelper; +import lombok.RequiredArgsConstructor; +import org.springframework.security.authentication.AuthenticationManager; +import org.springframework.security.config.annotation.SecurityConfigurerAdapter; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.core.userdetails.UserDetailsService; +import org.springframework.security.web.DefaultSecurityFilterChain; +import org.springframework.security.web.authentication.AuthenticationFailureHandler; +import org.springframework.security.web.authentication.AuthenticationSuccessHandler; +import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; +import org.springframework.stereotype.Component; + +/** + *

+ * 账号密码登陆的认证配置 + *

+ * + * @author WendyYang + * @since 09:54 2023/3/2 + */ +@Component +@RequiredArgsConstructor +public class PasswordAuthSecurityConfig extends SecurityConfigurerAdapter { + + private final AuthenticationSuccessHandler authenticationSuccessHandler; + private final AuthenticationFailureHandler authenticationFailureHandler; + private final UserDetailsService userDetailsService; + private final AuthProperties authProperties; + private final LoginHelper loginHelper; + + @Override + public void configure(HttpSecurity http) { + UsernamePasswordAuthFilter authFilter = new UsernamePasswordAuthFilter(authProperties.getPasswordLoginUrl(), + authProperties.getPostOnlyByLogin()); + AuthenticationManager authenticationManager = http.getSharedObject(AuthenticationManager.class); + authFilter.setAuthenticationManager(authenticationManager); + authFilter.setAuthenticationSuccessHandler(authenticationSuccessHandler); + authFilter.setAuthenticationFailureHandler(authenticationFailureHandler); + + PasswordAuthProvider authProvider = new PasswordAuthProvider(); + authProvider.setUserDetailsService(userDetailsService); + // 确保对密码进行加密的encoder和解密的encoder相同 + authProvider.setLoginHelper(loginHelper); + http.authenticationProvider(authProvider) + .addFilterAfter(authFilter, UsernamePasswordAuthenticationFilter.class); + } + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/security/password/PasswordLoginUserDetailService.java b/kq-api/src/main/java/com/ningdatech/kqapi/security/password/PasswordLoginUserDetailService.java new file mode 100644 index 0000000..cb7c47a --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/security/password/PasswordLoginUserDetailService.java @@ -0,0 +1,45 @@ +package com.ningdatech.kqapi.security.password; + +import com.baomidou.mybatisplus.core.toolkit.Assert; +import com.ningdatech.kqapi.security.facade.UserAuthLoginFacade; +import com.ningdatech.kqapi.security.model.UserInfoDetails; +import com.ningdatech.kqapi.security.model.dto.UserInfoBO; +import lombok.RequiredArgsConstructor; +import org.springframework.context.annotation.Primary; +import org.springframework.security.core.userdetails.UserDetailsService; +import org.springframework.security.core.userdetails.UsernameNotFoundException; +import org.springframework.stereotype.Service; + +import static com.ningdatech.kqapi.user.model.enumerization.AccountStatus.ENABLE; + +/** + *

+ * PasswordLoginUserDetailService + *

+ * + * @author WendyYang + * @since 10:20 2024/4/20 + */ +@Primary +@Service +@RequiredArgsConstructor +public class PasswordLoginUserDetailService implements UserDetailsService { + + private final UserAuthLoginFacade userAuthLoginFacade; + + @Override + public UserInfoDetails loadUserByUsername(String username) throws UsernameNotFoundException { + UserInfoBO user = userAuthLoginFacade.queryUserInfoInPasswordAuth(username); + Assert.notNull(user, "用户不存在"); + Assert.isTrue(ENABLE.equals(user.getAccountStatus()), "用户已被禁用"); + UserInfoDetails details = new UserInfoDetails(); + details.setUserId(user.getUserId()); + details.setUsername(user.getRealName()); + details.setRealName(user.getRealName()); + details.setRole(user.getRole()); + details.setIdentifier(user.getIdentifier()); + details.setPassword(user.getCredential()); + return details; + } + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/security/password/UsernamePasswordAuthFilter.java b/kq-api/src/main/java/com/ningdatech/kqapi/security/password/UsernamePasswordAuthFilter.java new file mode 100644 index 0000000..05ca02d --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/security/password/UsernamePasswordAuthFilter.java @@ -0,0 +1,57 @@ +package com.ningdatech.kqapi.security.password; + +import cn.hutool.core.util.StrUtil; +import com.ningdatech.kqapi.common.exception.BizException; +import com.ningdatech.kqapi.security.constant.AuthConst; +import com.ningdatech.kqapi.security.model.WebRequestDetails; +import org.springframework.http.HttpMethod; +import org.springframework.security.authentication.BadCredentialsException; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.AuthenticationException; +import org.springframework.security.core.userdetails.UsernameNotFoundException; +import org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter; +import org.springframework.security.web.util.matcher.AntPathRequestMatcher; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.time.LocalDateTime; + +/** + *

+ * UsernamePasswordAuthFilter + *

+ * + * @author WendyYang + * @since 2023/9/1 + **/ +public class UsernamePasswordAuthFilter extends AbstractAuthenticationProcessingFilter { + + private final Boolean postOnly; + + public UsernamePasswordAuthFilter(String processingUrl, Boolean postOnly) { + super(new AntPathRequestMatcher(processingUrl, HttpMethod.POST.name())); + this.postOnly = postOnly; + } + + @Override + public Authentication attemptAuthentication(HttpServletRequest request, HttpServletResponse response) + throws AuthenticationException { + LocalDateTime now = LocalDateTime.now(); + if (Boolean.TRUE.equals(postOnly) && !request.getMethod().equals(HttpMethod.POST.name())) { + throw BizException.wrap("请求方法错误"); + } + String username = StrUtil.trim(request.getParameter(AuthConst.USERNAME)); + String password = StrUtil.trim(request.getParameter(AuthConst.PASSWORD)); + try { + UsernamePasswordAuthToken authRequest = new UsernamePasswordAuthToken(username, password); + authRequest.setDetails(new WebRequestDetails(request, now)); + return this.getAuthenticationManager().authenticate(authRequest); + } catch (BadCredentialsException | UsernameNotFoundException e) { + throw e; + } catch (Exception e) { + throw BizException.wrap("登录失败,请联系管理员!"); + } + } + + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/security/password/UsernamePasswordAuthToken.java b/kq-api/src/main/java/com/ningdatech/kqapi/security/password/UsernamePasswordAuthToken.java new file mode 100644 index 0000000..c415acc --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/security/password/UsernamePasswordAuthToken.java @@ -0,0 +1,85 @@ +package com.ningdatech.kqapi.security.password; + +import lombok.Getter; +import lombok.Setter; +import org.springframework.security.authentication.AbstractAuthenticationToken; +import org.springframework.security.core.GrantedAuthority; +import org.springframework.security.core.SpringSecurityCoreVersion; + +import java.util.Collection; + +/** + *

+ * UsernamePasswordAuthToken + *

+ * + * @author LiuXinXin + * @since 2023/10/31 + **/ +@Getter +@Setter +public class UsernamePasswordAuthToken extends AbstractAuthenticationToken { + + private static final long serialVersionUID = SpringSecurityCoreVersion.SERIAL_VERSION_UID; + + private final Object principal; + + private final Object credentials; + + private transient String openId; + + private transient String deviceModel; + + /** + * This constructor can be safely used by any code that wishes to create a + * UsernamePasswordAuthenticationToken, as the {@link #isAuthenticated()} will return + * false. + */ + public UsernamePasswordAuthToken(String principal, String credentials) { + super(null); + this.principal = principal; + this.credentials = credentials; + setAuthenticated(false); + } + + /** + * This constructor should only be used by AuthenticationManager or AuthenticationProvider + * implementations that are satisfied with producing a trusted (i.e. {@link #isAuthenticated()} = true) + * authentication token. + * + * @param principal \ + * @param authorities \ + */ + public UsernamePasswordAuthToken(Object principal, Object credentials, + Collection authorities) { + super(authorities); + this.principal = principal; + this.credentials = credentials; + super.setAuthenticated(true); + } + + @Override + public Object getCredentials() { + return this.credentials; + } + + @Override + public Object getPrincipal() { + return this.principal; + } + + @Override + public void setAuthenticated(boolean isAuthenticated) throws IllegalArgumentException { + if (isAuthenticated) { + throw new IllegalArgumentException( + "Cannot set this token to trusted - use constructor which takes a GrantedAuthority list instead"); + } + super.setAuthenticated(false); + } + + @Override + public void eraseCredentials() { + super.eraseCredentials(); + } + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/sso/controller/SsoController.java b/kq-api/src/main/java/com/ningdatech/kqapi/sso/controller/SsoController.java new file mode 100644 index 0000000..913aa00 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/sso/controller/SsoController.java @@ -0,0 +1,36 @@ +package com.ningdatech.kqapi.sso.controller; + +import com.ningdatech.kqapi.sso.manage.SsoManage; +import com.ningdatech.kqapi.sso.model.dto.ReqSsoDTO; +import com.ningdatech.kqapi.sso.model.vo.SsoTokenVO; +import com.ningdatech.kqapi.sso.model.vo.SsoUserInfoVO; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import javax.validation.Valid; + +/** + * @author CMM + * @since 2024/04/07 11:15 + */ +@Slf4j +@Validated +@RestController +@RequestMapping("/api/v1/sso/") +@RequiredArgsConstructor +public class SsoController { + + private final SsoManage ssoManage; + + @PostMapping ("/token") + public SsoTokenVO getToken(@Valid @RequestBody ReqSsoDTO reqSsoDTO) { + return ssoManage.getToken(reqSsoDTO); + } + + @PostMapping ("/getUserInfo") + public SsoUserInfoVO getUserInfo(@Valid @RequestBody ReqSsoDTO reqSsoDTO) { + return ssoManage.getUserInfo(reqSsoDTO); + } +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/sso/manage/SsoManage.java b/kq-api/src/main/java/com/ningdatech/kqapi/sso/manage/SsoManage.java new file mode 100644 index 0000000..6f555bd --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/sso/manage/SsoManage.java @@ -0,0 +1,88 @@ +package com.ningdatech.kqapi.sso.manage; + +import java.util.Map; + +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.http.HttpEntity; +import org.springframework.stereotype.Component; +import org.springframework.util.MultiValueMap; +import org.springframework.web.client.RestTemplate; + +import com.ningdatech.kqapi.common.exception.BizException; +import com.ningdatech.kqapi.sso.model.dto.ReqSsoDTO; +import com.ningdatech.kqapi.sso.model.vo.SsoTokenVO; +import com.ningdatech.kqapi.sso.model.vo.SsoUserInfoVO; +import com.ningdatech.kqapi.sso.utils.HmacAuthUtil; + +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; + + +/** + * @author CMM + * @since 2024/04/07 11:17 + */ +@Component +@Slf4j +@RequiredArgsConstructor +public class SsoManage { + + @Value("${sso.token.internet-url}") + //@Value("${sso.token.zww-url}") + private String tokenUrl; + + @Value("${sso.user-info.internet-url}") + //@Value("${sso.user-info.zww-url}") + private String userInfoUrl; + + @Value("${sso.access-key}") + private String accessKey; + + @Value("${sso.secret-key}") + private String secretKey; + + @Value("${sso.app-id}") + private String appId; + + private final RestTemplate restTemplate; + + /** + * 基于单点登录票据换取请求 token + * + * @param reqSsoDTO \ + * @return SsoTokenVO + */ + public SsoTokenVO getToken(ReqSsoDTO reqSsoDTO) { + String ticketId = reqSsoDTO.getTicketId(); + if (StringUtils.isBlank(ticketId)){ + throw new BizException("登录票据不能为空!"); + } + Map header = HmacAuthUtil.generateHeader(tokenUrl, "POST", accessKey, secretKey); + MultiValueMap multiValueMap = HmacAuthUtil.convertToMultiValueMap(header); + reqSsoDTO.setAppId(appId); + HttpEntity httpEntity = new HttpEntity<>(reqSsoDTO, multiValueMap); + SsoTokenVO res = restTemplate.postForObject(tokenUrl, httpEntity, SsoTokenVO.class); + log.info("[RestTemplateTest-基于单点登录票据换取请求token] http request :{}", res); + return res; + } + + /** + * 基于 token 获取用户信息 + * + * @param reqSsoDTO \ + * @return SsoUserInfoVO + */ + public SsoUserInfoVO getUserInfo(ReqSsoDTO reqSsoDTO) { + String token = reqSsoDTO.getToken(); + if (StringUtils.isBlank(token)){ + throw new BizException("token不能为空!"); + } + Map header = HmacAuthUtil.generateHeader(userInfoUrl, "POST", accessKey, secretKey); + MultiValueMap multiValueMap = HmacAuthUtil.convertToMultiValueMap(header); + HttpEntity httpEntity = new HttpEntity<>(reqSsoDTO,multiValueMap); + SsoUserInfoVO res = restTemplate.postForObject(userInfoUrl, httpEntity, SsoUserInfoVO.class); + log.info("[RestTemplateTest-基于token获取用户信息] http request :{}", res); + return res; + } +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/sso/model/dto/ReqSsoDTO.java b/kq-api/src/main/java/com/ningdatech/kqapi/sso/model/dto/ReqSsoDTO.java new file mode 100644 index 0000000..b356b8c --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/sso/model/dto/ReqSsoDTO.java @@ -0,0 +1,25 @@ +package com.ningdatech.kqapi.sso.model.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotNull; + +/** + * @author CMM + * @since 2024/04/07 11:22 + */ +@Data +@ApiModel(value = "ReqTokenDTO", description = "获取Token请求实体") +public class ReqSsoDTO { + + @ApiModelProperty("单点登录票据") + private String ticketId; + + @ApiModelProperty("应用发布 ID") + private String appId; + + @ApiModelProperty("单点登录Token") + private String token; +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/sso/model/vo/SsoTokenVO.java b/kq-api/src/main/java/com/ningdatech/kqapi/sso/model/vo/SsoTokenVO.java new file mode 100644 index 0000000..41c4a8e --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/sso/model/vo/SsoTokenVO.java @@ -0,0 +1,29 @@ +package com.ningdatech.kqapi.sso.model.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author CMM + * @since 2024/04/07 11:19 + */ +@Data +@ApiModel(value = "SsoTokenVO", description = "单点登录TokenVO") +public class SsoTokenVO { + + @ApiModelProperty("错误码") + private String errorCode; + + @ApiModelProperty("错误信息") + private String errorMsg; + + @ApiModelProperty("是否成功") + private Boolean success; + + @ApiModelProperty("响应体") + private Object data; + + @ApiModelProperty("token") + private String token; +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/sso/model/vo/SsoUserInfoVO.java b/kq-api/src/main/java/com/ningdatech/kqapi/sso/model/vo/SsoUserInfoVO.java new file mode 100644 index 0000000..afb46c7 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/sso/model/vo/SsoUserInfoVO.java @@ -0,0 +1,154 @@ +package com.ningdatech.kqapi.sso.model.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +/** + * @author CMM + * @since 2024/04/07 11:19 + */ +@Data +@ApiModel(value = "SsoUserInfoVO", description = "单点登录UserInfoVO") +public class SsoUserInfoVO { + + @ApiModelProperty("错误码") + private String errorCode; + + @ApiModelProperty("错误信息") + private String errorMsg; + + @ApiModelProperty("是否成功") + private Boolean success; + + @ApiModelProperty("响应体") + private Object data; + + @ApiModelProperty("用户类型 PERSON 个人、LEGAL_PERSON 法人") + private String userType; + + @ApiModelProperty("个人用户信息 当前登录自然人的信息") + private Object personInfo; + + @ApiModelProperty("主键") + private String userId; + + @ApiModelProperty("个人姓名") + private String userName; + + @ApiModelProperty("ID_CARD:身份证,PASSPORT:护\n" + + "照,OFFICER_CARD:军官\n" + + "证,MAINLAND_TRAVEL_PERMIT_FOR\n" + + "_HONGKONG_AND_MACAO_RESIDENTS\n" + + ":港澳居民来往内地通行\n" + + "证,MAINLAND_TRAVEL_PERMIT_FOR\n" + + "_TAIWAN_RESIDENTS:台湾居民来\n" + + "往大陆通行\n" + + "证,FOREIGN_PERMANENT_RESIDENT\n" + + "_ID_CARD:外国人永久居留身份\n" + + "证,FOREIGN_PASSPORT:外籍人士\n" + + "护照,DIPLOMACY_PASSPORT:外交\n" + + "护照,OFFICIAL_PASSPORT:公务护\n" + + "照,SOLDIER_CARD:士兵\n" + + "证,OFFICER_RETIRE_CARD:军官离\n" + + "退休\n" + + "证,GANG_AO_TAI_RESIDENCE_CART\n" + + ":港澳台居民居住\n" + + "证,GANG_AO_ID_CART:港澳居民身\n" + + "份证,UNIFIED_SOCIAL_ID:统一社\n" + + "会信用代码,OTHER:其他") + private String idType; + + @ApiModelProperty("外部证件类型") + private String outerIdType; + + @ApiModelProperty("证件编号") + private String idNo; + + @ApiModelProperty("法人经办人时用户类型,评级") + private String attnUserType; + + @ApiModelProperty("手机号") + private String phone; + + @ApiModelProperty("邮箱") + private String email; + + @ApiModelProperty("民族") + private String nation; + + @ApiModelProperty("性别") + private String gender; + + @ApiModelProperty("生日") + private String birthday; + + @ApiModelProperty("身份散列值") + private String certKey; + + @ApiModelProperty("额外属性") + private Object attributes; + + @ApiModelProperty("法人用户信息,比如公司相关的信\n" + + "息") + private Object legalPersonInfo; + + @ApiModelProperty("法人名称") + private String name; + + @ApiModelProperty("社会统一信用代码") + private String unifiedSocialId; + + @ApiModelProperty("法人类型") + private String orgType; + + @ApiModelProperty("经办人姓名") + private String attnName; + + @ApiModelProperty("经办人手机号") + private String attnPhone; + + @ApiModelProperty("经办人证件类型") + private String attnIdType; + + @ApiModelProperty("经办人证件号码") + private String attnIdNo; + + @ApiModelProperty("法人代表人姓名") + private String principal; + + @ApiModelProperty("法人代表唯一键") + private String principalUserId; + + @ApiModelProperty("法人唯一键") + private String corpId; + + @ApiModelProperty("所属组织信息") + private List organizationInfoList; + + @ApiModelProperty("组织主键") + private String orgId; + + @ApiModelProperty("Alias for orgId") + private String oid; + + @ApiModelProperty("父组织主键") + private String parentId; + + @ApiModelProperty("Alias for parentId") + private String pid; + + @ApiModelProperty("组织机构全称") + private String fullName; + + @ApiModelProperty("组织后缀") + private String devCoding; + + @ApiModelProperty("是否叶子标志") + private Boolean leafFlag; + + @ApiModelProperty("排序号,从小到大") + private Integer orderBy; +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/sso/utils/HmacAuthUtil.java b/kq-api/src/main/java/com/ningdatech/kqapi/sso/utils/HmacAuthUtil.java new file mode 100644 index 0000000..d1514b7 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/sso/utils/HmacAuthUtil.java @@ -0,0 +1,132 @@ +package com.ningdatech.kqapi.sso.utils; + +import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.net.URL; +import java.net.URLEncoder; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.*; +import java.util.stream.Collectors; + +import javax.crypto.Mac; +import javax.crypto.spec.SecretKeySpec; +import javax.xml.bind.DatatypeConverter; + +import org.apache.commons.math3.util.Pair; +import org.springframework.util.LinkedMultiValueMap; +import org.springframework.util.MultiValueMap; + +import lombok.extern.slf4j.Slf4j; + +/** + * @author CMM + * @since 2024/04/07 11:28 + */ + +@Slf4j +public class HmacAuthUtil { + + /** + * 构造请求 header + * + * @param urlStr 请求url,全路径格式,比如:https://bcdsg.zj.gov.cn/api/p/v1/user.get + * @param requestMethod 请求方法,大写格式,如:GET, POST + * @param accessKey 应用的 AK + * @param secretKey 应用的 SK + * @return + */ + public static Map generateHeader(String urlStr, String requestMethod, String accessKey, String secretKey) { + log.info("params,urlStr={},requestMethod={},accessKey={},secretKey={}",urlStr,requestMethod,accessKey,secretKey); + Map header = new HashMap<>(); + try { + DateFormat dateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z", Locale.US); + dateFormat.setTimeZone(TimeZone.getTimeZone("GMT")); + String date = dateFormat.format(new Date()); + URL url = new URL(urlStr); + URI uri = new URI(url.getProtocol(), url.getHost(), url.getPath(), url.getQuery(), null); + + String canonicalQueryString = getCanonicalQueryString(uri.getQuery()); + + String message = requestMethod.toUpperCase() + "\n" + uri.getPath() + "\n" + canonicalQueryString + "\n" + accessKey + "\n" + date + "\n"; + + Mac hasher = Mac.getInstance("HmacSHA256"); + hasher.init(new SecretKeySpec(secretKey.getBytes(), "HmacSHA256")); + + byte[] hash = hasher.doFinal(message.getBytes()); + + // to lowercase hexits + DatatypeConverter.printHexBinary(hash); + + // to base64 + String sign = DatatypeConverter.printBase64Binary(hash); + header.put("X-BG-HMAC-SIGNATURE", sign); + header.put("X-BG-HMAC-ALGORITHM", "hmac-sha256"); + header.put("X-BG-HMAC-ACCESS-KEY", accessKey); + header.put("X-BG-DATE-TIME", date); + } catch (Exception e) { + log.error("generate error",e); + throw new RuntimeException("generate header error"); + } + log.info("header info,{}",header); + return header; + } + + private static String getCanonicalQueryString(String query) { + if (query == null || query.trim().length() == 0) { + return ""; + } + List> queryParamList = new ArrayList<>(); + String[] params = query.split("&"); + for (String param : params) { + int eqIndex = param.indexOf("="); + String key = param; + String value = ""; + if(eqIndex!=-1){ + key = param.substring(0, eqIndex); + value = param.substring(eqIndex+1); + } + Pair pair = new Pair<>(key, value); + queryParamList.add(pair); + } + + List> sortedParamList = queryParamList.stream().sorted(Comparator.comparing(param -> param.getKey() + "=" + Optional.ofNullable(param.getValue()).orElse(""))).collect(Collectors.toList()); + List> encodeParamList = new ArrayList<>(); + sortedParamList.stream().forEach(param -> { + try { + String key = URLEncoder.encode(param.getKey(), "utf-8"); + String value = URLEncoder.encode(Optional.ofNullable(param.getValue()).orElse(""), "utf-8") + .replaceAll("\\%2B","%20") + .replaceAll("\\+","%20") + .replaceAll("\\%21","!") + .replaceAll("\\%27","'") + .replaceAll("\\%28","(") + .replaceAll("\\%29",")") + .replaceAll("\\%7E","~") + .replaceAll("\\%25","%") + ; + encodeParamList.add(new Pair<>(key, value)); + } catch (UnsupportedEncodingException e) { + throw new RuntimeException("encoding error"); + } + }); + StringBuilder queryParamString = new StringBuilder(64); + for (Pair encodeParam : encodeParamList) { + queryParamString.append(encodeParam.getKey()).append("=").append(Optional.ofNullable(encodeParam.getValue()).orElse("")); + queryParamString.append("&"); + } + + return queryParamString.substring(0, queryParamString.length() - 1); + } + + + public static MultiValueMap convertToMultiValueMap(Map sourceMap) { + LinkedMultiValueMap multiValueMap = new LinkedMultiValueMap<>(); + + for (Map.Entry entry : sourceMap.entrySet()) { + multiValueMap.add(entry.getKey(), entry.getValue()); + } + + return multiValueMap; + } +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/user/controller/UserAuthController.java b/kq-api/src/main/java/com/ningdatech/kqapi/user/controller/UserAuthController.java new file mode 100644 index 0000000..45cef3d --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/user/controller/UserAuthController.java @@ -0,0 +1,77 @@ +package com.ningdatech.kqapi.user.controller; + + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.ningdatech.kqapi.common.constant.BizConst; +import com.ningdatech.kqapi.common.util.StrPool; +import com.ningdatech.kqapi.security.constant.AuthConst; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.Cookie; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +/** + * @author Liuxinxin + * @since 2022-11-23 + */ +@RestController +@RequestMapping("/api/v1/user/auth") +@Api(tags = {"用户鉴权-相关接口"}) +@RequiredArgsConstructor +public class UserAuthController { + + private final ObjectMapper objectMapper; + + @PostMapping(value = "/login/password", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE) + @ApiOperation(value = "账号密码的登陆方式") + @ApiImplicitParams({ + @ApiImplicitParam(name = "username", value = "用户名", required = true, paramType = "form", dataType = "String"), + @ApiImplicitParam(name = "password", value = "密码", required = true, paramType = "form", dataType = "String") + }) + public void loginByUsernameAndPassword(@RequestParam("username") String username, + @RequestParam("password") String password) { + // 不实现任何内容,只是为了出api文档 + } + + @PostMapping(value = "/logout") + @ApiOperation(value = "退出登陆") + public void logout() { + // 不实现任何内容,具体实现交由Spring Security进行管理 + } + + /** + * 当需要身份认证时,跳转到这里 + */ + @GetMapping("/auth-require") + @CrossOrigin(originPatterns = "*", allowCredentials = "true", maxAge = 3600) + public void requireAuthentication(HttpServletResponse response) throws IOException { + response.setContentType(StrPool.CONTENT_TYPE); + response.setStatus(HttpStatus.UNAUTHORIZED.value()); + response.getWriter().write(objectMapper.writeValueAsString(BizConst.UNAUTHENTICATED)); + } + + /** + * 设置session失效 + */ + @GetMapping("/invalid-session") + @CrossOrigin(originPatterns = "*", allowCredentials = "true", maxAge = 3600) + public void invalidSession(HttpServletRequest request, HttpServletResponse response) throws IOException { + response.setContentType(StrPool.CONTENT_TYPE); + Cookie cookie = new Cookie(BizConst.COOKIE_KEY, null); + cookie.setPath(request.getContextPath() + "/"); + cookie.setMaxAge(AuthConst.SESSION_EXPIRED); + response.addCookie(cookie); + response.setStatus(HttpStatus.UNAUTHORIZED.value()); + response.getWriter().write(objectMapper.writeValueAsString(BizConst.UNAUTHENTICATED)); + } + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/user/controller/UserInfoController.java b/kq-api/src/main/java/com/ningdatech/kqapi/user/controller/UserInfoController.java new file mode 100644 index 0000000..22b3a25 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/user/controller/UserInfoController.java @@ -0,0 +1,100 @@ +package com.ningdatech.kqapi.user.controller; + + +import com.ningdatech.basic.model.IdVo; +import com.ningdatech.basic.model.PageVo; +import com.ningdatech.kqapi.user.manage.UserInfoManage; +import com.ningdatech.kqapi.user.model.po.ChangeAccountStatusReq; +import com.ningdatech.kqapi.user.model.po.ModifyPasswordReq; +import com.ningdatech.kqapi.user.model.po.SaveUserReq; +import com.ningdatech.kqapi.user.model.po.UserListReq; +import com.ningdatech.kqapi.user.model.vo.LoginUserDetailVO; +import com.ningdatech.kqapi.user.model.vo.UserDetailVO; +import com.ningdatech.kqapi.user.model.vo.UserListVO; +import com.ningdatech.log.annotation.WebLog; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.*; + +import javax.validation.Valid; + +/** + *

+ * 前端控制器 + *

+ * + * @author Liuxinxin + * @since 2022-11-23 + */ +@RestController +@RequestMapping("/api/v1/user-info") +@Api(tags = {"用户信息-相关接口"}) +@RequiredArgsConstructor +public class UserInfoController { + + private final UserInfoManage userInfoManage; + + @PostMapping(value = "/save") + @ApiOperation(value = "保存用户") + @WebLog(value = "保存用户") + public void saveUser(@Valid @RequestBody SaveUserReq request) { + userInfoManage.saveUser(request); + } + + @PostMapping(value = "/changeAccountStatus") + @ApiOperation(value = "账号状态变更") + @WebLog(value = "账号状态变更") + public void changeAccountStatus(@Valid @RequestBody ChangeAccountStatusReq req) { + userInfoManage.changeAccountStatus(req); + } + + @GetMapping("detail/{userId}") + @ApiOperation("获取用户详情") + @WebLog(value = "获取用户详情") + public UserDetailVO getUserDetail(@PathVariable Long userId) { + return userInfoManage.getUserDetail(userId); + } + + @DeleteMapping("/del") + @ApiOperation("删除用户") + @WebLog(value = "删除用户") + public void deleteUser(@RequestBody IdVo req) { + userInfoManage.deleteUser(req.getId()); + } + + @PostMapping(value = "/list") + @ApiOperation(value = "用户列表筛选") + @WebLog(value = "用户列表筛选") + public PageVo listUser(@Valid @RequestBody UserListReq request) { + return userInfoManage.listUser(request); + } + + @PostMapping(value = "/basic-info") + @ApiOperation("获取用户基本信息") + @WebLog(value = "获取用户基本信息") + public LoginUserDetailVO loginUserDetail() { + return userInfoManage.loginUserDetail(); + } + + @PostMapping("/kick-off/{userId}") + @ApiOperation("踢用户下线测试接口") + public void kickOff(@Valid @PathVariable Long userId) { + userInfoManage.kickOff(userId); + } + + @PostMapping("/password/mod") + @ApiOperation("修改密码") + @WebLog(value = "修改密码") + public void changePassword(@Valid @RequestBody ModifyPasswordReq po) { + userInfoManage.changePassword(po); + } + + @PostMapping("/password/self") + @ApiOperation("修改个人密码") + @WebLog(value = "修改个人密码") + public void changeSelfPassword(@Valid @RequestBody ModifyPasswordReq po) { + userInfoManage.changeSelfPassword(po); + } + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/user/helper/LoginHelper.java b/kq-api/src/main/java/com/ningdatech/kqapi/user/helper/LoginHelper.java new file mode 100644 index 0000000..a629a9d --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/user/helper/LoginHelper.java @@ -0,0 +1,33 @@ +package com.ningdatech.kqapi.user.helper; + +import com.ningdatech.kqapi.security.password.UsernamePasswordAuthToken; +import lombok.AllArgsConstructor; +import org.springframework.security.authentication.BadCredentialsException; +import org.springframework.security.core.AuthenticationException; +import org.springframework.security.core.userdetails.UserDetails; +import org.springframework.security.crypto.password.PasswordEncoder; +import org.springframework.stereotype.Component; + +/** + *

+ * LoginHelper + *

+ * + * @author WendyYang + * @since 2023/10/31 + **/ +@Component +@AllArgsConstructor +public class LoginHelper { + + private final PasswordEncoder passwordEncoder; + + public void checkPassword(UserDetails userDetails, UsernamePasswordAuthToken authToken) + throws AuthenticationException { + String presentedPassword = authToken.getCredentials().toString(); + if (!passwordEncoder.matches(presentedPassword, userDetails.getPassword())) { + throw new BadCredentialsException("用户名或密码错误"); + } + } + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/user/helper/UserInfoHelper.java b/kq-api/src/main/java/com/ningdatech/kqapi/user/helper/UserInfoHelper.java new file mode 100644 index 0000000..1fb8e65 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/user/helper/UserInfoHelper.java @@ -0,0 +1,23 @@ +package com.ningdatech.kqapi.user.helper; + + +/** + *

+ * UserInfoHelper + *

+ * + * @author WendyYang + * @since 2023/7/11 + **/ +public class UserInfoHelper { + + private UserInfoHelper() { + } + + + + + + + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/user/manage/UserInfoManage.java b/kq-api/src/main/java/com/ningdatech/kqapi/user/manage/UserInfoManage.java new file mode 100644 index 0000000..e56d14f --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/user/manage/UserInfoManage.java @@ -0,0 +1,242 @@ +package com.ningdatech.kqapi.user.manage; + +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.lang.Assert; +import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.core.conditions.Wrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ningdatech.basic.exception.BizException; +import com.ningdatech.basic.model.PageVo; +import com.ningdatech.basic.util.CollUtils; +import com.ningdatech.kqapi.common.constant.BizConst; +import com.ningdatech.kqapi.security.constant.AuthTypeEnum; +import com.ningdatech.kqapi.security.model.UserInfoDetails; +import com.ningdatech.kqapi.user.model.entity.UserAuth; +import com.ningdatech.kqapi.user.model.entity.UserInfo; +import com.ningdatech.kqapi.user.model.enumerization.AccountStatus; +import com.ningdatech.kqapi.user.model.po.ChangeAccountStatusReq; +import com.ningdatech.kqapi.user.model.po.ModifyPasswordReq; +import com.ningdatech.kqapi.user.model.po.SaveUserReq; +import com.ningdatech.kqapi.user.model.po.UserListReq; +import com.ningdatech.kqapi.user.model.vo.UserListVO; +import com.ningdatech.kqapi.user.model.vo.LoginUserDetailVO; +import com.ningdatech.kqapi.user.model.vo.UserDetailVO; +import com.ningdatech.kqapi.user.service.IUserAuthService; +import com.ningdatech.kqapi.user.service.IUserInfoService; +import com.ningdatech.kqapi.user.util.BizUtils; +import com.ningdatech.kqapi.user.util.LoginUserUtil; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.security.crypto.password.PasswordEncoder; +import org.springframework.session.data.redis.RedisIndexedSessionRepository; +import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; + +import java.time.LocalDateTime; +import java.util.*; +import java.util.stream.Collectors; + + +/** + * @author liuxinxin + * @date 2022/11/23 下午5:04 + */ +@Slf4j +@Component +@RequiredArgsConstructor +public class UserInfoManage { + + private final IUserInfoService userInfoService; + private final IUserAuthService userAuthService; + private final PasswordEncoder passwordEncoder; + private final RedisIndexedSessionRepository redisIndexedSessionRepository; + + private static final String PASSWORD_MODIFY_DENY = "您暂无修改该用户密码的权限!"; + + + @Transactional(rollbackFor = Exception.class) + public synchronized void changeAccountStatus(ChangeAccountStatusReq req) { + UserInfo userInfo = userInfoService.getById(req.getUserId()); + if (userInfo == null || req.getAccountStatus().equals(userInfo.getAccountStatus())) { + return; + } + Wrapper update = Wrappers.lambdaUpdate(UserInfo.class) + .set(UserInfo::getAccountStatus, req.getAccountStatus()) + .eq(UserInfo::getId, req.getUserId()); + userInfoService.update(update); + // 账号禁用退出登录 + if (AccountStatus.DISABLE.equals(req.getAccountStatus())) { + kickOff(req.getUserId()); + } + } + + @Transactional(rollbackFor = Exception.class) + public synchronized void saveUser(SaveUserReq req) { + Long userId = req.getUserId(); + UserInfo oldUser = null; + if (userId == null) { + BizUtils.password(req.getPassword()); + } else { + oldUser = userInfoService.getById(userId); + } + // 校验 账号是否已经使用 + validateAuthIdentifier(req.getUserName(), userId); + validateAuthIdentifier(req.getPhoneNo(), userId); + // 新建 + UserInfo entity = new UserInfo(); + entity.setId(userId); + entity.setMobile(req.getPhoneNo()); + entity.setRealName(req.getRealName()); + entity.setUsername(req.getUserName()); + entity.setAvatarFileId(req.getAvatarFileId()); + entity.setAccountStatus(AccountStatus.ENABLE); + userInfoService.saveOrUpdate(entity); + if (userId == null) { + saveUserAuth(req, entity); + } else { + modifyAccount(req, oldUser, userId); + } + } + + private void modifyAccount(SaveUserReq req, UserInfo oldUser, Long userId) { + // 用户ID不为空时修改账号 + if (!oldUser.getMobile().equals(req.getPhoneNo())) { + Wrapper phoneAuth = Wrappers.lambdaUpdate(UserAuth.class) + .set(UserAuth::getIdentifier, req.getPhoneNo()) + .eq(UserAuth::getUserId, userId) + .eq(UserAuth::getAuthType, AuthTypeEnum.PHONE_PASSWORD); + userAuthService.update(phoneAuth); + } + if (!oldUser.getUsername().equals(req.getUserName())) { + Wrapper accountAuth = Wrappers.lambdaUpdate(UserAuth.class) + .set(UserAuth::getIdentifier, req.getUserName()) + .eq(UserAuth::getUserId, userId) + .eq(UserAuth::getAuthType, AuthTypeEnum.ACCOUNT_PASSWORD); + userAuthService.update(accountAuth); + } + } + + private void saveUserAuth(SaveUserReq req, UserInfo entity) { + String password = passwordEncoder.encode(req.getPassword()); + List auths = new ArrayList<>(); + UserAuth accountAuth = new UserAuth(); + accountAuth.setAuthType(AuthTypeEnum.ACCOUNT_PASSWORD.name()); + accountAuth.setUserId(entity.getId()); + accountAuth.setIdentifier(entity.getUsername()); + accountAuth.setCredential(password); + auths.add(accountAuth); + UserAuth phoneAuth = new UserAuth(); + phoneAuth.setAuthType(AuthTypeEnum.PHONE_PASSWORD.name()); + phoneAuth.setUserId(entity.getId()); + phoneAuth.setIdentifier(entity.getMobile()); + phoneAuth.setCredential(password); + auths.add(phoneAuth); + userAuthService.saveBatch(auths); + } + + public UserDetailVO getUserDetail(Long userId) { + UserInfo info = userInfoService.getById(userId); + Assert.notNull(info, "用户不存在"); + return UserDetailVO.builder() + .userId(info.getId()) + .realName(info.getRealName()) + .userName(info.getUsername()) + .avatarFileId(info.getAvatarFileId()) + .phoneNo(info.getMobile()) + .accountStatus(info.getAccountStatus()) + .build(); + } + + public PageVo listUser(UserListReq req) { + // 获取入参 + String realName = req.getRealName(); + // 获取区域列表 + Wrapper query = Wrappers.lambdaQuery(UserInfo.class) + .like(StrUtil.isNotBlank(realName), UserInfo::getRealName, realName) + .eq(StrUtil.isNotBlank(req.getMobile()), UserInfo::getMobile, req.getMobile()) + .orderByDesc(UserInfo::getUpdateOn); + Page page = userInfoService.page(req.page(), query); + if (page.getTotal() == 0) { + return PageVo.empty(); + } + List data = page.getRecords().stream().map(r -> { + UserListVO res = new UserListVO(); + res.setUserId(r.getId()); + res.setRealName(r.getRealName()); + res.setCreateTime(r.getCreateOn()); + res.setPhoneNo(r.getMobile()); + res.setAccountStatus(r.getAccountStatus()); + return res; + }).collect(Collectors.toList()); + return PageVo.of(data, page.getTotal()); + } + + public LoginUserDetailVO loginUserDetail() { + UserInfoDetails details = LoginUserUtil.loginUserDetail(); + LoginUserDetailVO result = new LoginUserDetailVO(); + result.setUserId(details.getUserId()); + result.setRealName(details.getRealName()); + return result; + } + + private void validateAuthIdentifier(String identifier, Long userId) { + Wrapper query = Wrappers.lambdaQuery(UserAuth.class) + .eq(UserAuth::getIdentifier, identifier) + .ne(userId != null, UserAuth::getUserId, userId) + .last(BizConst.LIMIT_1); + if (userAuthService.count(query) > 0) { + throw new BizException("当前账号已经注册"); + } + + } + + /** + * 踢用户下线 + * + * @param userId 用户ID + */ + public void kickOff(Long userId) { + List userAuthList = userAuthService.listByUserId(userId); + List identifierList = CollUtils.fieldList(userAuthList, UserAuth::getIdentifier); + if (CollectionUtil.isNotEmpty(identifierList)) { + Set allSessionIdList = new HashSet<>(); + for (String identifier : identifierList) { + Set sessionIds = redisIndexedSessionRepository.findByPrincipalName(identifier).keySet(); + allSessionIdList.addAll(sessionIds); + } + if (!allSessionIdList.isEmpty()) { + for (String sessionId : allSessionIdList) { + redisIndexedSessionRepository.deleteById(sessionId); + } + } + } + } + + @Transactional(rollbackFor = Exception.class) + public void deleteUser(Long userId) { + kickOff(userId); + userInfoService.removeById(userId); + userAuthService.removeByUserId(userId); + } + + public void changePassword(ModifyPasswordReq req) { + String password = passwordEncoder.encode(req.getPassword()); + Wrapper update = Wrappers.lambdaUpdate(UserAuth.class) + .set(UserAuth::getCredential, password) + .set(UserAuth::getUpdateOn, LocalDateTime.now()) + .eq(UserAuth::getUserId, req.getUserId()); + userAuthService.update(update); + } + + public void changeSelfPassword(ModifyPasswordReq req) { + Long userId = LoginUserUtil.getUserId(); + if (!userId.equals(req.getUserId())) { + throw BizException.wrap(PASSWORD_MODIFY_DENY); + } + changePassword(req); + } + + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/user/mapper/UserAuthMapper.java b/kq-api/src/main/java/com/ningdatech/kqapi/user/mapper/UserAuthMapper.java new file mode 100644 index 0000000..a914484 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/user/mapper/UserAuthMapper.java @@ -0,0 +1,16 @@ +package com.ningdatech.kqapi.user.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ningdatech.kqapi.user.model.entity.UserAuth; + +/** + *

+ * UserAuthMapper + *

+ * + * @author WendyYang + * @since 10:21 2024/4/20 + */ +public interface UserAuthMapper extends BaseMapper { + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/user/mapper/UserAuthMapper.xml b/kq-api/src/main/java/com/ningdatech/kqapi/user/mapper/UserAuthMapper.xml new file mode 100644 index 0000000..313ab7c --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/user/mapper/UserAuthMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/user/mapper/UserInfoMapper.java b/kq-api/src/main/java/com/ningdatech/kqapi/user/mapper/UserInfoMapper.java new file mode 100644 index 0000000..a6c54a9 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/user/mapper/UserInfoMapper.java @@ -0,0 +1,16 @@ +package com.ningdatech.kqapi.user.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ningdatech.kqapi.user.model.entity.UserInfo; + +/** + *

+ * UserInfoMapper + *

+ * + * @author WendyYang + * @since 10:21 2024/4/20 + */ +public interface UserInfoMapper extends BaseMapper { + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/user/mapper/UserInfoMapper.xml b/kq-api/src/main/java/com/ningdatech/kqapi/user/mapper/UserInfoMapper.xml new file mode 100644 index 0000000..bf56d75 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/user/mapper/UserInfoMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/user/model/entity/UserAuth.java b/kq-api/src/main/java/com/ningdatech/kqapi/user/model/entity/UserAuth.java new file mode 100644 index 0000000..d21df33 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/user/model/entity/UserAuth.java @@ -0,0 +1,42 @@ +package com.ningdatech.kqapi.user.model.entity; + +import com.baomidou.mybatisplus.annotation.*; +import io.swagger.annotations.ApiModel; +import lombok.Data; + +import java.io.Serializable; +import java.time.LocalDateTime; + +/** + *

+ * UserAuth + *

+ * + * @author WendyYang + * @since 09:57 2024/4/20 + */ +@Data +@TableName("nd_user_auth") +@ApiModel(value = "UserAuth对象") +public class UserAuth implements Serializable { + + private static final long serialVersionUID = 1L; + + @TableId(value = "id", type = IdType.AUTO) + private Long id; + + @TableField(fill = FieldFill.INSERT) + private LocalDateTime createOn; + + @TableField(fill = FieldFill.INSERT_UPDATE) + private LocalDateTime updateOn; + + private Long userId; + + private String authType; + + private String identifier; + + private String credential; + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/user/model/entity/UserInfo.java b/kq-api/src/main/java/com/ningdatech/kqapi/user/model/entity/UserInfo.java new file mode 100644 index 0000000..ec92874 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/user/model/entity/UserInfo.java @@ -0,0 +1,69 @@ +package com.ningdatech.kqapi.user.model.entity; + +import com.baomidou.mybatisplus.annotation.*; +import com.ningdatech.kqapi.user.model.enumerization.AccountStatus; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.time.LocalDateTime; + +/** + *

+ * 用户基本信息 + *

+ * + * @author Liuxinxin + * @since 2022-11-23 + */ +@Data +@TableName("nd_user_info") +@ApiModel(value = "UserInfo对象") +public class UserInfo implements Serializable { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty("主键") + @TableId(value = "id", type = IdType.AUTO) + private Long id; + + @ApiModelProperty("创建时间") + @TableField(fill = FieldFill.INSERT) + private LocalDateTime createOn; + + @ApiModelProperty("最后修改时间") + @TableField(fill = FieldFill.INSERT_UPDATE) + private LocalDateTime updateOn; + + @ApiModelProperty("创建人") + @TableField(fill = FieldFill.INSERT) + private Long createBy; + + @ApiModelProperty("最后修改人") + @TableField(fill = FieldFill.INSERT_UPDATE) + private Long updateBy; + + @ApiModelProperty("用户名") + private String username; + + @ApiModelProperty("手机") + private String mobile; + + @ApiModelProperty("用户真实姓名") + private String realName; + + @ApiModelProperty("角色") + private String role; + + @ApiModelProperty("头像文件id") + private Long avatarFileId; + + @ApiModelProperty("账号状态") + private AccountStatus accountStatus; + + @TableLogic + @ApiModelProperty("逻辑删除") + private Boolean deleted; + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/user/model/enumerization/AccountStatus.java b/kq-api/src/main/java/com/ningdatech/kqapi/user/model/enumerization/AccountStatus.java new file mode 100644 index 0000000..2e87990 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/user/model/enumerization/AccountStatus.java @@ -0,0 +1,20 @@ +package com.ningdatech.kqapi.user.model.enumerization; + +/** + *

+ * AccountStatus + *

+ * + * @author WendyYang + * @since 2023/7/21 + **/ +public enum AccountStatus { + + ENABLE, + DISABLE; + + public boolean eq(String status) { + return this.name().equals(status); + } + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/user/model/po/ChangeAccountStatusReq.java b/kq-api/src/main/java/com/ningdatech/kqapi/user/model/po/ChangeAccountStatusReq.java new file mode 100644 index 0000000..645ea79 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/user/model/po/ChangeAccountStatusReq.java @@ -0,0 +1,28 @@ +package com.ningdatech.kqapi.user.model.po; + +import com.ningdatech.kqapi.user.model.enumerization.AccountStatus; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotNull; + +/** + *

+ * ChangeAccountStatusReq + *

+ * + * @author WendyYang + * @since 2023/7/21 + **/ +@Data +public class ChangeAccountStatusReq { + + @ApiModelProperty("用户ID") + @NotNull(message = "用户ID不能为空") + private Long userId; + + @ApiModelProperty("账号状态") + @NotNull(message = "账号状态不能为空") + private AccountStatus accountStatus; + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/user/model/po/ModifyPasswordReq.java b/kq-api/src/main/java/com/ningdatech/kqapi/user/model/po/ModifyPasswordReq.java new file mode 100644 index 0000000..83a3c9d --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/user/model/po/ModifyPasswordReq.java @@ -0,0 +1,31 @@ +package com.ningdatech.kqapi.user.model.po; + +import com.ningdatech.kqapi.common.constant.BizConst; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Pattern; + +/** + *

+ * ModifyPasswordReq + *

+ * + * @author WendyYang + * @since 10:34 2024/4/20 + */ +@Data +public class ModifyPasswordReq { + + @ApiModelProperty("用户ID") + @NotNull(message = "用户ID不能为空") + private Long userId; + + @ApiModelProperty("密码") + @NotBlank(message = "密码不能为空") + @Pattern(regexp = BizConst.REGEX_PASS, message = "请输入6-10位大小写字母或数字") + private String password; + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/user/model/po/SaveUserReq.java b/kq-api/src/main/java/com/ningdatech/kqapi/user/model/po/SaveUserReq.java new file mode 100644 index 0000000..415d5af --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/user/model/po/SaveUserReq.java @@ -0,0 +1,49 @@ +package com.ningdatech.kqapi.user.model.po; + +import cn.hutool.core.lang.RegexPool; +import com.ningdatech.kqapi.user.model.enumerization.AccountStatus; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.Pattern; + +/** + *

+ * SaveUserReq + *

+ * + * @author WendyYang + * @since 10:26 2024/4/20 + */ +@Data +@ApiModel("保存用户请求PO") +public class SaveUserReq { + + @ApiModelProperty("用户id") + private Long userId; + + @NotBlank(message = "用户姓名 必填") + @ApiModelProperty("用户姓名 必填") + private String realName; + + @NotBlank(message = "手机号 必填") + @ApiModelProperty("手机号 必填") + @Pattern(regexp = RegexPool.MOBILE, message = "请输入正确的手机号") + private String phoneNo; + + @NotBlank(message = "用户登陆名 必填") + @ApiModelProperty("用户登陆名 必填") + private String userName; + + @ApiModelProperty("密码") + private String password; + + @ApiModelProperty("免冠照图片文件id") + private Long avatarFileId; + + @ApiModelProperty("账号状态") + private AccountStatus accountStatus; + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/user/model/po/UserListReq.java b/kq-api/src/main/java/com/ningdatech/kqapi/user/model/po/UserListReq.java new file mode 100644 index 0000000..60a88bb --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/user/model/po/UserListReq.java @@ -0,0 +1,29 @@ +package com.ningdatech.kqapi.user.model.po; + +import com.ningdatech.basic.model.PagePo; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + *

+ * UserListReq + *

+ * + * @author WendyYang + * @since 10:27 2024/4/20 + */ +@Data +@ApiModel("用户列表筛选PO") +@EqualsAndHashCode(callSuper = true) +public class UserListReq extends PagePo { + + @ApiModelProperty("用户姓名") + private String realName; + + @ApiModelProperty("手机号") + private String mobile; + +} + diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/user/model/vo/LoginUserDetailVO.java b/kq-api/src/main/java/com/ningdatech/kqapi/user/model/vo/LoginUserDetailVO.java new file mode 100644 index 0000000..f914631 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/user/model/vo/LoginUserDetailVO.java @@ -0,0 +1,28 @@ +package com.ningdatech.kqapi.user.model.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + *

+ * ResUserBasicInfoVO + *

+ * + * @author WendyYang + * @since 10:30 2024/4/20 + */ +@Data +@ApiModel("用户基本信息") +public class LoginUserDetailVO { + + @ApiModelProperty("用户id") + private Long userId; + + @ApiModelProperty("用户真实姓名") + private String realName; + + @ApiModelProperty("用户手机号") + private String phoneNo; + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/user/model/vo/UserDetailVO.java b/kq-api/src/main/java/com/ningdatech/kqapi/user/model/vo/UserDetailVO.java new file mode 100644 index 0000000..d08cc8e --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/user/model/vo/UserDetailVO.java @@ -0,0 +1,44 @@ +package com.ningdatech.kqapi.user.model.vo; + +import com.ningdatech.kqapi.user.model.enumerization.AccountStatus; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + *

+ * UserDetailVO + *

+ * + * @author WendyYang + * @since 09:35 2022/12/2 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class UserDetailVO { + + @ApiModelProperty("用户id") + private Long userId; + + @ApiModelProperty("用户姓名") + private String realName; + + @ApiModelProperty("手机号") + private String phoneNo; + + @ApiModelProperty("用户登陆名") + private String userName; + + @ApiModelProperty("免冠照图片文件id") + private Long avatarFileId; + + @ApiModelProperty("驾驶证信息") + private Long licenseOfDriver; + + private AccountStatus accountStatus; + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/user/model/vo/UserListVO.java b/kq-api/src/main/java/com/ningdatech/kqapi/user/model/vo/UserListVO.java new file mode 100644 index 0000000..19cbcee --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/user/model/vo/UserListVO.java @@ -0,0 +1,38 @@ +package com.ningdatech.kqapi.user.model.vo; + +import com.ningdatech.kqapi.user.model.enumerization.AccountStatus; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.time.LocalDateTime; + +/** + *

+ * ResUserListVO + *

+ * + * @author WendyYang + * @since 10:32 2024/4/20 + */ +@Data +@ApiModel("用户列表筛选VO") +public class UserListVO { + + @ApiModelProperty("用户id") + private Long userId; + + @ApiModelProperty("用户姓名") + private String realName; + + @NotBlank + @ApiModelProperty("手机号") + private String phoneNo; + + @ApiModelProperty("创建时间") + private LocalDateTime createTime; + + private AccountStatus accountStatus; + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/user/service/IUserAuthService.java b/kq-api/src/main/java/com/ningdatech/kqapi/user/service/IUserAuthService.java new file mode 100644 index 0000000..9520c7d --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/user/service/IUserAuthService.java @@ -0,0 +1,28 @@ +package com.ningdatech.kqapi.user.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.ningdatech.kqapi.user.model.entity.UserAuth; + +import java.util.List; + +/** + *

+ * 服务类 + *

+ * + * @author Liuxinxin + * @since 2022-11-23 + */ +public interface IUserAuthService extends IService { + + List listByUserId(Long userId); + + /** + * 删除用户授权信息 + * + * @param userId 用户ID + * @author WendyYang + **/ + void removeByUserId(Long userId); + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/user/service/IUserInfoService.java b/kq-api/src/main/java/com/ningdatech/kqapi/user/service/IUserInfoService.java new file mode 100644 index 0000000..c8a67dd --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/user/service/IUserInfoService.java @@ -0,0 +1,39 @@ +package com.ningdatech.kqapi.user.service; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.service.IService; +import com.ningdatech.kqapi.user.model.entity.UserInfo; +import com.ningdatech.kqapi.user.model.enumerization.AccountStatus; + +import java.util.Collection; +import java.util.List; +import java.util.Optional; + +/** + *

+ * 服务类 + *

+ * + * @author Liuxinxin + * @since 2022-11-23 + */ +public interface IUserInfoService extends IService { + + default String getRealName(Long userId) { + LambdaQueryWrapper query = Wrappers.lambdaQuery(UserInfo.class) + .select(UserInfo::getRealName) + .eq(UserInfo::getId, userId); + return Optional.ofNullable(getOne(query)) + .flatMap(w -> Optional.of(w.getRealName())) + .orElse(null); + } + + default List list(Collection userIds, AccountStatus accountStatus) { + LambdaQueryWrapper uQuery = Wrappers.lambdaQuery(UserInfo.class) + .in(UserInfo::getId, userIds) + .eq(UserInfo::getAccountStatus, accountStatus); + return list(uQuery); + } + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/user/service/impl/UserAuthServiceImpl.java b/kq-api/src/main/java/com/ningdatech/kqapi/user/service/impl/UserAuthServiceImpl.java new file mode 100644 index 0000000..05cb54c --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/user/service/impl/UserAuthServiceImpl.java @@ -0,0 +1,33 @@ +package com.ningdatech.kqapi.user.service.impl; + +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ningdatech.kqapi.user.model.entity.UserAuth; +import com.ningdatech.kqapi.user.mapper.UserAuthMapper; +import com.ningdatech.kqapi.user.service.IUserAuthService; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + *

+ * 服务实现类 + *

+ * + * @author Liuxinxin + * @since 2022-11-23 + */ +@Service +public class UserAuthServiceImpl extends ServiceImpl implements IUserAuthService { + + @Override + public List listByUserId(Long userId) { + return list(Wrappers.lambdaQuery(UserAuth.class).eq(UserAuth::getUserId, userId)); + } + + @Override + public void removeByUserId(Long userId) { + baseMapper.delete(Wrappers.lambdaQuery(UserAuth.class).eq(UserAuth::getUserId, userId)); + } + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/user/service/impl/UserInfoServiceImpl.java b/kq-api/src/main/java/com/ningdatech/kqapi/user/service/impl/UserInfoServiceImpl.java new file mode 100644 index 0000000..dbafda6 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/user/service/impl/UserInfoServiceImpl.java @@ -0,0 +1,22 @@ +package com.ningdatech.kqapi.user.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ningdatech.kqapi.user.model.entity.UserInfo; +import com.ningdatech.kqapi.user.mapper.UserInfoMapper; +import com.ningdatech.kqapi.user.service.IUserInfoService; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +/** + *

+ * 服务实现类 + *

+ * + * @author Liuxinxin + * @since 2022-11-23 + */ +@Service +@RequiredArgsConstructor +public class UserInfoServiceImpl extends ServiceImpl implements IUserInfoService { + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/user/util/BizUtils.java b/kq-api/src/main/java/com/ningdatech/kqapi/user/util/BizUtils.java new file mode 100644 index 0000000..a4722e8 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/user/util/BizUtils.java @@ -0,0 +1,81 @@ +package com.ningdatech.kqapi.user.util; + +import cn.hutool.core.util.StrUtil; +import com.ningdatech.basic.exception.BizException; +import com.ningdatech.kqapi.common.constant.BizConst; + +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.time.temporal.ChronoUnit; +import java.util.function.Consumer; +import java.util.regex.Pattern; + + +/** + *

+ * BizUtils-特殊的业务方法 + *

+ * + * @author WendyYang + * @since 20:59 2022/11/29 + */ +public class BizUtils { + + private BizUtils() { + } + + + public static void notNull(T obj, Consumer consumer) { + if (obj != null) { + consumer.accept(obj); + } + } + + public static void notNullOrZero(T number, Consumer consumer) { + if (number != null && number.intValue() != 0) { + consumer.accept(number); + } + } + + public static void notBlank(String str, Consumer consumer) { + if (StrUtil.isNotBlank(str)) { + consumer.accept(str); + } + } + + public static void password(String password) { + if (StrUtil.isBlank(password) || !Pattern.compile(BizConst.REGEX_PASS).matcher(password).matches()) { + throw BizException.wrap("请输入6-10位大小写字母或数字"); + } + } + + public static long getRestMillsToday() { + LocalDate now = LocalDate.now(); + LocalDateTime currTime = now.atTime(LocalTime.now()); + LocalDateTime nextDay = now.plusDays(1).atStartOfDay(); + return ChronoUnit.MILLIS.between(currTime, nextDay); + } + + /** + * 判断当前小时数是否在某个范围内 + * + * @param time 时间 + * @param start 开始小时数 + * @param end 结束小时数 + * @return boolean + * @author WendyYang + **/ + public static boolean betweenHours(LocalDateTime time, int start, int end) { + if (time == null) { + return false; + } + int hour = time.getHour(); + return hour >= start && end >= hour; + } + + public static boolean isBetween(LocalDateTime targetTime, LocalDateTime startTime, LocalDateTime endTime) { + return targetTime.isAfter(startTime) && targetTime.isBefore(endTime); + } + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/user/util/LoginUserContext.java b/kq-api/src/main/java/com/ningdatech/kqapi/user/util/LoginUserContext.java new file mode 100644 index 0000000..71aa34b --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/user/util/LoginUserContext.java @@ -0,0 +1,36 @@ +package com.ningdatech.kqapi.user.util; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + *

+ * LoginUserContext + *

+ * + * @author WendyYang + * @since 17:10 2023/2/24 + */ +public class LoginUserContext { + + private LoginUserContext() { + } + + private static final String PROJECT_ID = "PROJECT_ID"; + + private static final ThreadLocal> MAP = ThreadLocal.withInitial(() -> new HashMap<>(16)); + + public static List getProjectIds() { + return (List) MAP.get().get(PROJECT_ID); + } + + public static void setProjectIds(List projectIds) { + MAP.get().put(PROJECT_ID, projectIds); + } + + public static void clear() { + MAP.remove(); + } + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/user/util/LoginUserUtil.java b/kq-api/src/main/java/com/ningdatech/kqapi/user/util/LoginUserUtil.java new file mode 100644 index 0000000..ed54dc2 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/user/util/LoginUserUtil.java @@ -0,0 +1,25 @@ +package com.ningdatech.kqapi.user.util; + +import com.ningdatech.basic.auth.AbstractLoginUserUtil; +import com.ningdatech.kqapi.security.model.UserInfoDetails; + +/** + *

+ * 登录用户信息获取工具类 + *

+ * + * @author liuxinxin + * @since 12:26 2022/9/30 + */ +public class LoginUserUtil extends AbstractLoginUserUtil { + + /** + * 获取用户信息 + * + * @return \ + */ + public static UserInfoDetails loginUserDetail() { + return getLoginUserPrincipal(); + } + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/constants/ZzsfwMenuConstant.java b/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/constants/ZzsfwMenuConstant.java new file mode 100644 index 0000000..3825134 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/constants/ZzsfwMenuConstant.java @@ -0,0 +1,20 @@ +package com.ningdatech.kqapi.zzsfw.constants; + +/** + * @Classname ZzsfwMenuConstant + * @Description + * @Date 2023/10/30 10:41 + * @Author PoffyZhang + */ +public class ZzsfwMenuConstant { + + public static final String MENU_TYPE_ZONE = "zone"; + + public static final String MENU_TYPE_WINDOW = "window"; + + public static final String MENU_TYPE_DEPARTMENT = "department"; + + public static final String MENU_TYPE_MATTER = "matter"; + + public static final String MENU_ITEM_TYPE = "itemType"; +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/controller/DscSxAdsShareItemQltQlsxCommonIDVKqController.java b/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/controller/DscSxAdsShareItemQltQlsxCommonIDVKqController.java new file mode 100644 index 0000000..e5bb0d8 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/controller/DscSxAdsShareItemQltQlsxCommonIDVKqController.java @@ -0,0 +1,37 @@ +package com.ningdatech.kqapi.zzsfw.controller; + +import com.ningdatech.kqapi.zzsfw.model.dto.DscSxAdsShareItemQltQlsxCommonIDVKqDTO; +import com.ningdatech.kqapi.zzsfw.model.entity.DscSxAdsShareItemQltQlsxCommonIDVKq; +import com.ningdatech.kqapi.zzsfw.manage.QlManage; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +/** + *

+ * 省回流_政务服务_数据共享_事项基本信息表 前端控制器 + *

+ * + * @author ZPF + * @since 2023-10-25 + */ +@Slf4j +@Validated +@RestController +@RequestMapping("/api/v1/zzsfw/") +@RequiredArgsConstructor +public class DscSxAdsShareItemQltQlsxCommonIDVKqController { + + private final QlManage qlManage; + + @GetMapping("/search") + public List search(@ModelAttribute DscSxAdsShareItemQltQlsxCommonIDVKqDTO dto) { + return qlManage.search(dto); + } +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/controller/KqZzsfwMenuController.java b/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/controller/KqZzsfwMenuController.java new file mode 100644 index 0000000..99fa367 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/controller/KqZzsfwMenuController.java @@ -0,0 +1,118 @@ +package com.ningdatech.kqapi.zzsfw.controller; + +import com.ningdatech.kqapi.common.exception.BizException; +import com.ningdatech.kqapi.zzsfw.model.dto.KqZzsfwMattersDeduplicateDTO; +import com.ningdatech.kqapi.zzsfw.model.dto.KqZzsfwMenuDTO; +import com.ningdatech.kqapi.zzsfw.model.vo.MatterTopVO; +import com.ningdatech.kqapi.zzsfw.model.vo.MattersVO; +import com.ningdatech.kqapi.zzsfw.model.vo.TreeVO; +import com.ningdatech.kqapi.zzsfw.manage.MatterManage; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + +import java.io.IOException; +import java.util.List; +import java.util.Objects; + +/** + *

+ * 前端控制器 + *

+ * + * @author ZPF + * @since 2023-10-27 + */ +@Slf4j +@Validated +@RestController +@RequestMapping("/api/v1/zzsfw/") +@RequiredArgsConstructor +public class KqZzsfwMenuController { + private final MatterManage matterManage; + + @GetMapping("/matters") + public List getMatters() { + return matterManage.getMatters(); + } + + @GetMapping("/zones") + public List getZones() { + return matterManage.getZones(); + } + + @GetMapping("/windows") + public List getWindows(@RequestParam(required = false) String zoneName) { + return matterManage.getWindows(zoneName); + } + + @GetMapping("/departments") + public List getDepartments(@RequestParam(required = false) String windowName, + @RequestParam(required = false) String zoneName) { + return matterManage.getDepartments(zoneName,windowName); + } + + @GetMapping("/matter-list") + public List matterList(@RequestParam(required = false) String windowName, + @RequestParam(required = false) String zoneName, + @RequestParam(required = false) String department, + @RequestParam(required = false) Integer type) { + return matterManage.matterList(zoneName,windowName,department,type); + } + + @GetMapping("/matter/{id}") + public MattersVO matter(@PathVariable Long id) { + return matterManage.matter(id); + } + + @GetMapping("/top10") + public List topTen() { + return matterManage.topTen(); + } + + @PostMapping("/save") + public String save(@RequestBody KqZzsfwMenuDTO dto) { + return matterManage.save(dto); + } + + @GetMapping("/remove-all") + public String removeAll() { + return matterManage.removeAll(); + } + + @PostMapping("/save-dup") + public String saveDup(@RequestBody KqZzsfwMattersDeduplicateDTO dto) { + return matterManage.saveDup(dto); + } + + @GetMapping("/remove-all-dup") + public String removeAllDup() { + return matterManage.removeAllDup(); + } + + + @PostMapping("/ddl") + public String ddl(@RequestParam("sql") String sql) { + return matterManage.ddl(sql); + } + + @PostMapping("/upload-menu") + public String uploadMenu(@RequestParam("file") MultipartFile[] file) throws IOException { + if (Objects.isNull(file) || file.length == 0) { + throw new BizException("文件为空!"); + } + return matterManage.uploadMenu(file[0]); + } + + /** + * 4-10 改动的几个问题 到时候 线上直接改了 + * @return + */ + @GetMapping("/update-4-10") + public String update4_10() { + return matterManage.update4_10(); + } +} + diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/controller/PolicyRegulationsController.java b/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/controller/PolicyRegulationsController.java new file mode 100644 index 0000000..111b214 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/controller/PolicyRegulationsController.java @@ -0,0 +1,49 @@ +package com.ningdatech.kqapi.zzsfw.controller; + +import com.ningdatech.kqapi.common.model.PageVo; +import com.ningdatech.kqapi.zzsfw.model.dto.KqZzsfwPolicyDTO; +import com.ningdatech.kqapi.zzsfw.model.vo.ZzsfwPolicyVO; +import com.ningdatech.kqapi.zzsfw.manage.PolicyManage; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * @Classname PolicyRegulationsController + * @Description + * @Date 2023/11/2 9:55 + * @Author PoffyZhang + */ +@Slf4j +@Validated +@RestController +@RequestMapping("/api/v1/poclicy/") +@RequiredArgsConstructor +public class PolicyRegulationsController { + private final PolicyManage policyManage; + + @GetMapping("/list") + public PageVo list(@RequestParam(defaultValue = "1") long pageNumber, @RequestParam(defaultValue = "10") long pageSize) { + return policyManage.list(pageNumber,pageSize); + } + + @PostMapping("/save") + public String save(@RequestBody KqZzsfwPolicyDTO dto) { + return policyManage.save(dto); + } + + @PostMapping("/save-batch") + public String saveBatch(@RequestBody List dtos) { + + return policyManage.saveBatch(dtos); + } + + + @GetMapping("/remove-all") + public String removeAll() { + return policyManage.removeAll(); + } +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/enumeration/ItemTypeEnum.java b/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/enumeration/ItemTypeEnum.java new file mode 100644 index 0000000..0a14e02 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/enumeration/ItemTypeEnum.java @@ -0,0 +1,34 @@ +package com.ningdatech.kqapi.zzsfw.enumeration; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; + +import java.util.Objects; + +@Getter +@AllArgsConstructor +@NoArgsConstructor +public enum ItemTypeEnum { + /** + * 事项类型 枚举 + */ + GOV(1,"政府服务"), + ADDED(2,"增值服务"), + SPECIAL(3,"特殊服务"); + + private Integer code; + private String desc; + + public static ItemTypeEnum match(Integer code) { + if (Objects.isNull(code)) { + return null; + } + for (ItemTypeEnum t : ItemTypeEnum.values()) { + if (code.equals(t.getCode())) { + return t; + } + } + return null; + } +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/manage/MatterManage.java b/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/manage/MatterManage.java new file mode 100644 index 0000000..6bd4a8d --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/manage/MatterManage.java @@ -0,0 +1,405 @@ +package com.ningdatech.kqapi.zzsfw.manage; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.lang.Assert; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.ningdatech.kqapi.zzsfw.constants.ZzsfwMenuConstant; +import com.ningdatech.kqapi.zzsfw.model.dto.KqZzsfwMattersDeduplicateDTO; +import com.ningdatech.kqapi.zzsfw.model.dto.KqZzsfwMenuDTO; +import com.ningdatech.kqapi.zzsfw.model.entity.KqZzsfwMenu; +import com.ningdatech.kqapi.zzsfw.model.entity.KqZzsfwMattersDeduplicate; +import com.ningdatech.kqapi.zzsfw.model.vo.MatterTopVO; +import com.ningdatech.kqapi.zzsfw.model.vo.MattersVO; +import com.ningdatech.kqapi.zzsfw.model.vo.TreeVO; +import com.ningdatech.kqapi.zzsfw.enumeration.ItemTypeEnum; +import com.ningdatech.kqapi.zzsfw.service.IKqZzsfwMatterDeduplicateService; +import com.ningdatech.kqapi.zzsfw.service.IKqZzsfwMenuService; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.apache.poi.ss.usermodel.CellType; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; +import org.springframework.web.multipart.MultipartFile; + +import java.io.IOException; +import java.io.InputStream; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.Statement; +import java.text.DecimalFormat; +import java.time.LocalDateTime; +import java.util.*; +import java.util.stream.Collectors; + +/** + * @Classname MatterManage + * @Description + * @Date 2023/10/25 14:55 + * @Author PoffyZhang + */ +@Component +@Slf4j +@RequiredArgsConstructor +public class MatterManage { + + @Value("${spring.datasource.url}") + public String url; + + @Value("${spring.datasource.username}") + public String username; + + @Value("${spring.datasource.password}") + public String password; + + private final IKqZzsfwMenuService menuService; + + private final IKqZzsfwMatterDeduplicateService matterDeduplicateService; + + public List getMatters() { + List matters = menuService.list(Wrappers.lambdaQuery(KqZzsfwMenu.class) + .orderByAsc(KqZzsfwMenu::getSort)); + if(CollUtil.isEmpty(matters)){ + return Collections.emptyList(); + } + + //如果是政府类型的 就隐藏 没有链接的 + List finalMatters = matters.stream().filter(m -> Objects.nonNull(m.getType()) && + (!m.getType().equals(ItemTypeEnum.GOV.getCode()) || Objects.nonNull(m.getWebapplyurl()))) + .collect(Collectors.toList()); + Set zoneSet = new HashSet<>(); + List res = finalMatters.stream().filter(m -> zoneSet.add(m.getZoneName())).map(m -> { + TreeVO zone = new TreeVO(); + zone.setName(m.getZoneName()); + zone.setChilren(generateWindows(m, finalMatters)); + zone.setType(ZzsfwMenuConstant.MENU_TYPE_ZONE); + return zone; + }).collect(Collectors.toList()); + return res; + } + + /** + * 查询社区 + * @return + */ + public List getZones() { + List matters = menuService.list(Wrappers.lambdaQuery(KqZzsfwMenu.class) + .orderByAsc(KqZzsfwMenu::getSort)); + if(CollUtil.isEmpty(matters)){ + return Collections.emptyList(); + } + + //如果是政府类型的 就隐藏 没有链接的 + List finalMatters = matters.stream().filter(m -> Objects.nonNull(m.getType()) && + (!m.getType().equals(ItemTypeEnum.GOV.getCode()) || Objects.nonNull(m.getWebapplyurl()))) + .collect(Collectors.toList()); + Set zoneSet = new HashSet<>(); + return finalMatters.stream().filter(m -> zoneSet.add(m.getZoneName())).map(m -> { + TreeVO zone = new TreeVO(); + zone.setName(m.getZoneName()); + zone.setType(ZzsfwMenuConstant.MENU_TYPE_ZONE); + return zone; + }).collect(Collectors.toList()); + } + + public List getWindows(String zoneName) { + List matters = menuService.list(Wrappers.lambdaQuery(KqZzsfwMenu.class) + .eq(StringUtils.isNotBlank(zoneName), KqZzsfwMenu::getZoneName,zoneName) + .orderByAsc(KqZzsfwMenu::getSort)); + if(CollUtil.isEmpty(matters)){ + return Collections.emptyList(); + } + + //如果是政府类型的 就隐藏 没有链接的 + List finalMatters = matters.stream().filter(m -> Objects.nonNull(m.getType()) && + (!m.getType().equals(ItemTypeEnum.GOV.getCode()) || Objects.nonNull(m.getWebapplyurl()))) + .collect(Collectors.toList()); + + Set windowSet = new HashSet<>(); + return finalMatters.stream().filter(m -> windowSet.add(m.getWindow())) + .map(m -> { + TreeVO window = new TreeVO(); + window.setName(m.getWindow()); + window.setType(ZzsfwMenuConstant.MENU_TYPE_WINDOW); + return window; + }).collect(Collectors.toList()); + } + + public List getDepartments(String zoneName,String windowName) { + List matters = menuService.list(Wrappers.lambdaQuery(KqZzsfwMenu.class) + .eq(StringUtils.isNotBlank(windowName), KqZzsfwMenu::getWindow,windowName) + .eq(StringUtils.isNotBlank(zoneName), KqZzsfwMenu::getZoneName,zoneName) + .orderByAsc(KqZzsfwMenu::getSort)); + if(CollUtil.isEmpty(matters)){ + return Collections.emptyList(); + } + + List finalMatters = matters.stream().filter(m -> Objects.nonNull(m.getType()) && + (!m.getType().equals(ItemTypeEnum.GOV.getCode()) || Objects.nonNull(m.getWebapplyurl()))) + .collect(Collectors.toList()); + + Set departMentSet = new HashSet<>(); + return finalMatters.stream().filter(m -> departMentSet.add(m.getDepartment())) + .map(m -> { + TreeVO department = new TreeVO(); + department.setName(m.getDepartment()); + department.setType(ZzsfwMenuConstant.MENU_TYPE_DEPARTMENT); + return department; + }).collect(Collectors.toList()); + } + + public List matterList(String zoneName, String windowName, String department, Integer type) { + List matters = menuService.list(Wrappers.lambdaQuery(KqZzsfwMenu.class) + .eq(StringUtils.isNotBlank(windowName), KqZzsfwMenu::getWindow,windowName) + .eq(StringUtils.isNotBlank(zoneName), KqZzsfwMenu::getZoneName,zoneName) + .eq(StringUtils.isNotBlank(department), KqZzsfwMenu::getDepartment,department) + .eq(Objects.nonNull(type), KqZzsfwMenu::getType,type) + .orderByAsc(KqZzsfwMenu::getSort)); + if(CollUtil.isEmpty(matters)){ + return Collections.emptyList(); + } + + //如果是政府类型的 就隐藏 没有链接的 + List finalMatters = matters.stream().filter(m -> Objects.nonNull(m.getType()) && + (!m.getType().equals(ItemTypeEnum.GOV.getCode()) || Objects.nonNull(m.getWebapplyurl()))) + .collect(Collectors.toList()); + + return finalMatters.stream() + .map(m -> { + MattersVO mattersVO = BeanUtil.copyProperties(m, MattersVO.class); + mattersVO.setMatterName(m.getItemName()); + mattersVO.setId(m.getId()); + return mattersVO; + }) + .collect(Collectors.toList()); + } + + public MattersVO matter(Long id) { + KqZzsfwMenu matter = menuService.getById(id); + if(Objects.isNull(matter)){ + return null; + } + MattersVO mattersVO = BeanUtil.copyProperties(matter, MattersVO.class); + mattersVO.setMatterName(matter.getItemName()); + mattersVO.setId(matter.getId()); + return mattersVO; + } + + private List generateWindows(KqZzsfwMenu menu, List matters) { + Set windowSet = new HashSet<>(); + return matters.stream().filter(m -> StringUtils.isNotBlank(m.getZoneName()) && m.getZoneName().equals(menu.getZoneName()) + && windowSet.add(m.getWindow())) + .map(m -> { + TreeVO window = new TreeVO(); + window.setName(m.getWindow()); + window.setChilren(generateDepartment(m,matters)); + window.setType(ZzsfwMenuConstant.MENU_TYPE_WINDOW); + return window; + }).collect(Collectors.toList()); + } + + private List generateDepartment(KqZzsfwMenu menu, List matters) { + Set departmentSet = new HashSet<>(); + return matters.stream().filter( m -> StringUtils.isNotBlank(m.getWindow()) && m.getWindow().equals(menu.getWindow()) && + m.getZoneName().equals(menu.getZoneName()) && departmentSet.add(m.getDepartment())) + .map(m -> { + TreeVO department = new TreeVO(); + department.setName(m.getDepartment()); + department.setChilren(generateItemType(m,matters)); + department.setType(ZzsfwMenuConstant.MENU_TYPE_DEPARTMENT); + return department; + }).collect(Collectors.toList()); + } + + private List generateItemType(KqZzsfwMenu menu, List matters) { + Set typeSet = new HashSet<>(); + return matters.stream().filter(m -> StringUtils.isNotBlank(m.getWindow()) && m.getWindow().equals(menu.getWindow()) && + m.getZoneName().equals(menu.getZoneName()) && Objects.nonNull(m.getType()) && typeSet.add(m.getType())) + .map(m -> { + TreeVO menuType = new TreeVO(); + ItemTypeEnum itemTypeEnum = ItemTypeEnum.match(m.getType()); + if(Objects.nonNull(itemTypeEnum)){ + menuType.setName(itemTypeEnum.getDesc()); + menuType.setChilren(generateMatters(m,matters)); + menuType.setType(ZzsfwMenuConstant.MENU_ITEM_TYPE); + return menuType; + } + return null; + }) + .filter(Objects::nonNull) + .collect(Collectors.toList()); + } + + private List generateMatters(KqZzsfwMenu menu, List matters) { + return matters.stream().filter(m -> Objects.nonNull(m.getType()) && m.getType().equals(menu.getType()) && + (!m.getType().equals(ItemTypeEnum.GOV.getCode()) || Objects.nonNull(m.getHasUrl()) && m.getHasUrl() == 1) && + StringUtils.isNotBlank(m.getDepartment()) && + m.getDepartment().equals(menu.getDepartment()) && m.getWindow().equals(menu.getWindow()) && + m.getZoneName().equals(menu.getZoneName())) + .map(m -> { + TreeVO matter = new TreeVO(); + matter.setName(m.getItemName()); + matter.setUrl(m.getWebapplyurl()); + matter.setId(m.getItemRowid()); + matter.setSort(m.getSort()); + matter.setType(ZzsfwMenuConstant.MENU_TYPE_MATTER); + matter.setServiceContent(m.getServiceContent()); + matter.setServiceProcess(m.getServiceProcess()); + matter.setTelephone(m.getTelephone()); + return matter; + }).collect(Collectors.toList()); + } + + public List topTen() { + List topTen = matterDeduplicateService.list(Wrappers.lambdaQuery(KqZzsfwMattersDeduplicate.class) + .orderByDesc(KqZzsfwMattersDeduplicate::getCountNum) + .last("limit 10")); + return topTen.stream().map(m -> { + MatterTopVO vo = new MatterTopVO(); + vo.setMatterName(m.getQlName()); + vo.setWebapplyurl(m.getWebapplyurl()); + vo.setCount(m.getCountNum()); + return vo; + }).collect(Collectors.toList()); + } + + public String save(KqZzsfwMenuDTO dto) { + if(Objects.isNull(dto)){ + return "保存失败 传入为空"; + } + + KqZzsfwMenu entity = BeanUtil.copyProperties(dto, KqZzsfwMenu.class); + if(menuService.save(entity)){ + return "保存成功 :" + entity; + }else{ + return "保存失败"; + } + } + + public String saveDup(KqZzsfwMattersDeduplicateDTO dto) { + if(Objects.isNull(dto)){ + return "保存失败 传入为空"; + } + + KqZzsfwMattersDeduplicate entity = BeanUtil.copyProperties(dto, KqZzsfwMattersDeduplicate.class); + if(matterDeduplicateService.save(entity)){ + return "保存成功 :" + entity; + }else{ + return "保存失败"; + } + } + + public String removeAll() { + menuService.remove(Wrappers.lambdaQuery(KqZzsfwMenu.class)); + return "删除成功"; + } + + public String removeAllDup() { + matterDeduplicateService.remove(Wrappers.lambdaQuery(KqZzsfwMattersDeduplicate.class)); + return "删除成功"; + } + + public String uploadMenu(MultipartFile file) throws IOException { + InputStream inputStream = file.getInputStream(); + Workbook workbook = new XSSFWorkbook(inputStream); + Assert.notNull(workbook); + Row row; + //获取最大行数 + Sheet sheet = workbook.getSheetAt(0); + int rownum = sheet.getPhysicalNumberOfRows(); + //获取最大列数 + Integer num = 1; + + for (int i = 2; i < rownum; i++) { + row = sheet.getRow(i); + if (row.getZeroHeight()) { + continue; + } + System.out.println("记数:" + (num++)); + String zoneName = row.getCell(0).getStringCellValue(); + System.out.println(zoneName); + DecimalFormat decimalFormat = new DecimalFormat("#"); + Integer sort = Integer.valueOf(decimalFormat.format(row.getCell(1).getNumericCellValue())); + System.out.println(sort); + String windowName = row.getCell(2).getStringCellValue(); + System.out.println(windowName); + String department = row.getCell(3).getStringCellValue(); + System.out.println(department); + String itemName = row.getCell(4).getStringCellValue(); + System.out.println(itemName); + String serviceContent = row.getCell(5).getStringCellValue(); + System.out.println(serviceContent); + String serviceProcess = row.getCell(6).getStringCellValue(); + System.out.println(serviceProcess); + String telephone = ""; + CellType cellType = row.getCell(7).getCellType(); + if (cellType.equals(CellType.STRING)) { + telephone = row.getCell(7).getStringCellValue(); + System.out.println(telephone); + } else if (cellType.equals(CellType.NUMERIC)) { + DecimalFormat decimalFormat2 = new DecimalFormat("#.#######"); + telephone = decimalFormat2.format(row.getCell(7).getNumericCellValue()); + System.out.println(telephone); + } + KqZzsfwMenu menu = new KqZzsfwMenu(); + menu.setItemName(itemName); + menu.setZoneName(zoneName); + menu.setWindow(windowName); + menu.setDepartment(department); + menu.setServiceContent(serviceContent); + menu.setServiceProcess(serviceProcess); + menu.setTelephone(telephone); + menu.setType(ItemTypeEnum.ADDED.getCode()); + menu.setCreateOn(LocalDateTime.now()); + menu.setSort(sort); + menuService.save(menu); + } + return "upload success!"; + } + + public String ddl(String sql) { + try { + // 1. 加载数据库驱动 + Class.forName("com.mysql.cj.jdbc.Driver"); + + // 2. 建立数据库连接 + Connection connection = DriverManager.getConnection(url, username, password); + + // 3. 创建Statement对象 + Statement statement = connection.createStatement(); + + // 4. 编写并执行DDL语句(创建一个名为`users`的表) + statement.executeUpdate(sql); + + System.out.println(" Table updated successfully."); + + // 5. 关闭资源 + statement.close(); + connection.close(); + } catch (Exception e) { + e.printStackTrace(); + } + return "success!"; + } + + /** + * 4-10 数据问题 + * @return + */ + public String update4_10() { + //1.窗口后缀不是服务的 都加个服务 + List list = menuService.list(); + for (KqZzsfwMenu menu : list) { + if(StringUtils.isNotBlank(menu.getWindow()) && !menu.getWindow().endsWith("服务")){ + menu.setWindow(menu.getWindow() + "服务"); + menuService.updateById(menu); + } + } + return "success!"; + } +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/manage/PolicyManage.java b/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/manage/PolicyManage.java new file mode 100644 index 0000000..4917416 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/manage/PolicyManage.java @@ -0,0 +1,84 @@ +package com.ningdatech.kqapi.zzsfw.manage; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.collection.CollUtil; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ningdatech.kqapi.common.model.PageVo; +import com.ningdatech.kqapi.zzsfw.model.dto.KqZzsfwPolicyDTO; +import com.ningdatech.kqapi.zzsfw.model.entity.KqZzsfwPolicy; +import com.ningdatech.kqapi.zzsfw.model.vo.ZzsfwPolicyVO; +import com.ningdatech.kqapi.zzsfw.service.IKqZzsfwPolicyService; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; + +/** + * @Classname PolicyManage + * @Description + * @Date 2023/11/02 14:55 + * @Author PoffyZhang + */ +@Component +@Slf4j +@RequiredArgsConstructor +public class PolicyManage { + + private final IKqZzsfwPolicyService policyService; + + + public PageVo list(long pageNumber, long pageSize) { + Page page = Page.of(pageNumber,pageSize); + Page pageRes = policyService.page(page, Wrappers.lambdaQuery(KqZzsfwPolicy.class) + .orderByAsc(KqZzsfwPolicy::getSort)); + + if(CollUtil.isEmpty(pageRes.getRecords())){ + return PageVo.empty(); + } + List res = pageRes.getRecords().stream() + .map(p -> BeanUtil.copyProperties(p, ZzsfwPolicyVO.class)) + .collect(Collectors.toList()); + return PageVo.of(res,pageRes.getTotal()); + } + + public String save(KqZzsfwPolicyDTO dto) { + if(Objects.isNull(dto)){ + return "保存失败 传入为空"; + } + + KqZzsfwPolicy entity = BeanUtil.copyProperties(dto, KqZzsfwPolicy.class); + if(policyService.save(entity)){ + return "保存成功 :" + entity; + }else{ + return "保存失败"; + } + } + + public String removeAll() { + policyService.remove(Wrappers.lambdaQuery(KqZzsfwPolicy.class)); + return "删除成功"; + } + + /** + * 批量保存 + * @param dtos + * @return + */ + public String saveBatch(List dtos) { + if(CollUtil.isEmpty(dtos)){ + return "保存失败 传入为空"; + } + + List entitys = dtos.stream().map(d -> BeanUtil.copyProperties(d, KqZzsfwPolicy.class)) + .collect(Collectors.toList()); + if(policyService.saveBatch(entitys)){ + return "保存成功"; + }else{ + return "保存失败"; + } + } +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/manage/QlManage.java b/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/manage/QlManage.java new file mode 100644 index 0000000..d9bb2bd --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/manage/QlManage.java @@ -0,0 +1,35 @@ +package com.ningdatech.kqapi.zzsfw.manage; + +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.ningdatech.kqapi.zzsfw.model.dto.DscSxAdsShareItemQltQlsxCommonIDVKqDTO; +import com.ningdatech.kqapi.zzsfw.model.entity.DscSxAdsShareItemQltQlsxCommonIDVKq; +import com.ningdatech.kqapi.zzsfw.service.IDscSxAdsShareItemQltQlsxCommonIDVKqService; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Component; + +import java.util.*; + +/** + * @Classname MatterManage + * @Description + * @Date 2023/10/25 14:55 + * @Author PoffyZhang + */ +@Component +@Slf4j +@RequiredArgsConstructor +public class QlManage { + + private final IDscSxAdsShareItemQltQlsxCommonIDVKqService kqService; + + public List search(DscSxAdsShareItemQltQlsxCommonIDVKqDTO dto) { + List list = kqService.list(Wrappers.lambdaQuery(DscSxAdsShareItemQltQlsxCommonIDVKq.class) + .eq(StringUtils.isNotBlank(dto.getRowguid()), DscSxAdsShareItemQltQlsxCommonIDVKq::getRowguid, dto.getRowguid()) + .eq(StringUtils.isNotBlank(dto.getQlName()), DscSxAdsShareItemQltQlsxCommonIDVKq::getQlName, dto.getQlName()) + .eq(StringUtils.isNotBlank(dto.getWebapplyurl()), DscSxAdsShareItemQltQlsxCommonIDVKq::getWebapplyurl, dto.getWebapplyurl()) + ); + return list; + } +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/mapper/ComponentsMatterEliminateMapper.java b/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/mapper/ComponentsMatterEliminateMapper.java new file mode 100644 index 0000000..cd555c4 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/mapper/ComponentsMatterEliminateMapper.java @@ -0,0 +1,11 @@ +package com.ningdatech.kqapi.zzsfw.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ningdatech.kqapi.zzsfw.model.entity.ComponentsMatterEliminateEntity; + +/** + * @author wangrenkang + * @date 2024-01-15 10:53:17 + */ +public interface ComponentsMatterEliminateMapper extends BaseMapper { +} \ No newline at end of file diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/mapper/ComponentsMatterEliminateMapper.xml b/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/mapper/ComponentsMatterEliminateMapper.xml new file mode 100644 index 0000000..fec934c --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/mapper/ComponentsMatterEliminateMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/mapper/DscSxAdsShareItemQltQlsxCommonIDVKqMapper.java b/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/mapper/DscSxAdsShareItemQltQlsxCommonIDVKqMapper.java new file mode 100644 index 0000000..88b5f87 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/mapper/DscSxAdsShareItemQltQlsxCommonIDVKqMapper.java @@ -0,0 +1,16 @@ +package com.ningdatech.kqapi.zzsfw.mapper; + +import com.ningdatech.kqapi.zzsfw.model.entity.DscSxAdsShareItemQltQlsxCommonIDVKq; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** + *

+ * 省回流_政务服务_数据共享_事项基本信息表 Mapper 接口 + *

+ * + * @author ZPF + * @since 2023-10-25 + */ +public interface DscSxAdsShareItemQltQlsxCommonIDVKqMapper extends BaseMapper { + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/mapper/DscSxAdsShareItemQltQlsxCommonIDVKqMapper.xml b/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/mapper/DscSxAdsShareItemQltQlsxCommonIDVKqMapper.xml new file mode 100644 index 0000000..023cd65 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/mapper/DscSxAdsShareItemQltQlsxCommonIDVKqMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/mapper/KqZzsfwMatterDeduplicateMapper.java b/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/mapper/KqZzsfwMatterDeduplicateMapper.java new file mode 100644 index 0000000..05d3005 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/mapper/KqZzsfwMatterDeduplicateMapper.java @@ -0,0 +1,16 @@ +package com.ningdatech.kqapi.zzsfw.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ningdatech.kqapi.zzsfw.model.entity.KqZzsfwMattersDeduplicate; + +/** + *

+ * Mapper 接口 + *

+ * + * @author ZPF + * @since 2023-10-27 + */ +public interface KqZzsfwMatterDeduplicateMapper extends BaseMapper { + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/mapper/KqZzsfwMenuMapper.java b/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/mapper/KqZzsfwMenuMapper.java new file mode 100644 index 0000000..08ae623 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/mapper/KqZzsfwMenuMapper.java @@ -0,0 +1,23 @@ +package com.ningdatech.kqapi.zzsfw.mapper; + +import com.ningdatech.kqapi.admin.model.dto.MatterCountByWindowIdDTO; +import com.ningdatech.kqapi.zzsfw.model.entity.KqZzsfwMenu; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Param; + +import java.util.Collection; +import java.util.List; + +/** + *

+ * Mapper 接口 + *

+ * + * @author ZPF + * @since 2023-10-27 + */ +public interface KqZzsfwMenuMapper extends BaseMapper { + + List selectMatterCountByWindowIds(@Param("windowIds") Collection windowIds); + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/mapper/KqZzsfwMenuMapper.xml b/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/mapper/KqZzsfwMenuMapper.xml new file mode 100644 index 0000000..5e0848c --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/mapper/KqZzsfwMenuMapper.xml @@ -0,0 +1,15 @@ + + + + + + + diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/mapper/KqZzsfwPolicyMapper.java b/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/mapper/KqZzsfwPolicyMapper.java new file mode 100644 index 0000000..76a6c19 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/mapper/KqZzsfwPolicyMapper.java @@ -0,0 +1,16 @@ +package com.ningdatech.kqapi.zzsfw.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ningdatech.kqapi.zzsfw.model.entity.KqZzsfwPolicy; + +/** + *

+ * Mapper 接口 + *

+ * + * @author ZPF + * @since 2023-10-27 + */ +public interface KqZzsfwPolicyMapper extends BaseMapper { + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/model/dto/DscSxAdsShareItemQltQlsxCommonIDVKqDTO.java b/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/model/dto/DscSxAdsShareItemQltQlsxCommonIDVKqDTO.java new file mode 100644 index 0000000..cbee986 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/model/dto/DscSxAdsShareItemQltQlsxCommonIDVKqDTO.java @@ -0,0 +1,417 @@ +package com.ningdatech.kqapi.zzsfw.model.dto; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.time.LocalDateTime; + +/** + *

+ * 省回流_政务服务_数据共享_事项基本信息表 + *

+ * + * @author ZPF + * @since 2023-10-25 + */ +@Data +public class DscSxAdsShareItemQltQlsxCommonIDVKqDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty("事项唯一标识") + private String rowguid; + + @ApiModelProperty("写入同步时间") + private LocalDateTime updateDate; + + @ApiModelProperty("事项更新类型") + private String updateType; + + @ApiModelProperty("事项类型") + private String qlKind; + + @ApiModelProperty("主项编码") + private String qlMainitemId; + + @ApiModelProperty("子项编码") + private String qlSubitemId; + + @ApiModelProperty("事权层级") + private String shiquancj; + + @ApiModelProperty("行政区划代码") + private String belongxiaqucode; + + @ApiModelProperty("实施机关组织机构代码(主管部门组织机构代码)") + private String qlDepOrgcdoe; + + @ApiModelProperty("权力来源") + private String itemsource; + + @ApiModelProperty("版本号") + private String versionNumber; + + @ApiModelProperty("事项入库时间") + private LocalDateTime versionDate; + + @ApiModelProperty("事项状态生效时间") + private LocalDateTime qlEffectTime; + + @ApiModelProperty("事项内部编码") + private String qlInnerCode; + + @ApiModelProperty("事项名称") + private String qlName; + + @ApiModelProperty("事项状态") + private String qlState; + + @ApiModelProperty("法定依据(审批依据;实施依据)") + private String lawbasis; + + @ApiModelProperty("法定期限") + private Long anticipateDay; + + @ApiModelProperty("法定期限单位") + private String anticipateType; + + @ApiModelProperty("承诺期限") + private Long promiseDay; + + @ApiModelProperty("办事者到办事现场次数") + private Long applyerminCount; + + @ApiModelProperty("是否列为国家、省、市、县级行政审批制度改革试点") + private String isPilot; + + @ApiModelProperty("实施机关(主管部门名称)") + private String qlDep; + + @ApiModelProperty("实施或牵头的处(科)室名称") + private String leadDept; + + @ApiModelProperty("办件类型") + private String bjtype; + + @ApiModelProperty("本级审批性质") + private String benjispxz; + + @ApiModelProperty("办理频率") + private String handleFrequency; + + @ApiModelProperty("行政相对人性质(适用对象(行政相对人性质);服务相对人性质)") + private String xingzhenxdrxz; + + @ApiModelProperty("审批条件(申请条件;受理条件)") + private String applyCondition; + + @ApiModelProperty("办件结果文件名称(审批结果)") + private String banjianFinishfiles; + + @ApiModelProperty("咨询电话") + private String linkTel; + + @ApiModelProperty("监督投诉电话") + private String superviseTel; + + @ApiModelProperty("电脑端网上办理地址") + private String webapplyurl; + + @ApiModelProperty("网上咨询网址") + private String webconsulturl; + + @ApiModelProperty("是否收费") + private String chargeFlag; + + @ApiModelProperty("收费依据") + private String chargeBasis; + + @ApiModelProperty("法人关注点") + private String rightclassQiyezt; + + @ApiModelProperty("面向法人的对象分类") + private String rightclassQiyedx; + + @ApiModelProperty("个人关注点") + private String rightclassGerensx; + + @ApiModelProperty("面向个人的对象分类") + private String rightclassGerendx; + + @ApiModelProperty("内部流程信息") + private String inFlowInfo; + + @ApiModelProperty("业务申报材料") + private String materialInfo; + + @ApiModelProperty("材料情形说明") + private String materialCaseInfo; + + @ApiModelProperty("收费项目") + private String chargeitemInfo; + + @ApiModelProperty("常见问题解答") + private String qaInfo; + + @ApiModelProperty("受理地点信息") + private String acceptAddressInfo; + + @ApiModelProperty("交换标识") + private String syncSign; + + @ApiModelProperty("交换时间") + private LocalDateTime syncDate; + + @ApiModelProperty("交换错误描述") + private String syncErrorDesc; + + @ApiModelProperty("部门组织机构代码") + private String ouorgcode; + + @ApiModelProperty("部门编码") + private String ouguid; + + @ApiModelProperty("法人登录地址(电脑端法人认证地址)") + private String farenurl; + + @ApiModelProperty("电脑端个人认证标识") + private String gerenflag; + + @ApiModelProperty("是否统建系统(是否使用统一网上申报)") + private String isTongjian; + + @ApiModelProperty("事项编码") + private String qlFullId; + + @ApiModelProperty("委托下放") + private String entrust; + + @ApiModelProperty("委托下放说明") + private String entrustdes; + + @ApiModelProperty("最少上门次数说明") + private String applyerminCountDesc; + + @ApiModelProperty("事项所属业务类型") + private String outypecode; + + @ApiModelProperty("对外公布办理程序描述") + private String outFlowDesc; + + @ApiModelProperty("办结类型") + private String banjianFinishtype; + + @ApiModelProperty("是否允许特别程序申请") + private String isSpecialpro; + + @ApiModelProperty("删除数据标识") + private String state2; + + @ApiModelProperty("不适宜开展网上申报") + private String nosuitApply; + + @ApiModelProperty("是否接入统一办件库") + private String isUnifydo; + + @ApiModelProperty("是否是上级主管部门统建系统") + private String isUpunify; + + @ApiModelProperty("权力属性") + private String qlAtt; + + @ApiModelProperty("备注") + private String baknote; + + @ApiModelProperty("星级服务(网上办理业务模式)") + private String webapplymode; + + @ApiModelProperty("权力来源方式") + private String itemsourcetype; + + @ApiModelProperty("是否可以适用处罚简易程序") + private String isSimplepunish; + + @ApiModelProperty("是否涉及征收(税)费减免的审批") + private String isLevywaiver; + + @ApiModelProperty("征收标准") + private String feebasis; + + @ApiModelProperty("自由裁量") + private String factInfo; + + @ApiModelProperty("涉密或敏感") + private String isCs; + + @ApiModelProperty("未接入统一办件库其他原因说明") + private String unifydodes; + + @ApiModelProperty("极少业务") + private String isVlb; + + @ApiModelProperty("nounify_do") + private String nounifyDo; + + @ApiModelProperty("乡镇延伸事项的部门源事项") + private String qlInnerCodeItem; + + @ApiModelProperty("是否投资(bak1)") + private String isTouzip; + + @ApiModelProperty("行业主题分类") + private String hangyeclasstype; + + @ApiModelProperty("其他行政权力子类型") + private String qlSubKind; + + @ApiModelProperty("移动端网上办理地址") + private String appwebapplyurl; + + @ApiModelProperty("移动端网上预约地址") + private String appappointmenturl; + + @ApiModelProperty("电脑端网上预约地址") + private String appointmenturl; + + @ApiModelProperty("是否网上预约") + private String isWebappointment; + + @ApiModelProperty("网上预约时段") + private String webappointmentperiod; + + @ApiModelProperty("主要内容") + private String maincontext; + + @ApiModelProperty("共同实施单位") + private String doDept; + + @ApiModelProperty("相关附件") + private String relatedguid; + + @ApiModelProperty("相关附件信息") + private String related; + + @ApiModelProperty("是否提供快递送达") + private String isExpress; + + @ApiModelProperty("公共服务事项子类型") + private String serviceSubKind; + + @ApiModelProperty("是否列入最多跑一次事项清单") + private String ispyc; + + @ApiModelProperty("联办事项") + private String lbsx; + + @ApiModelProperty("外部流程图") + private String outFlowUrl; + + @ApiModelProperty("受理机构") + private String acpInstitution; + + @ApiModelProperty("决定机构") + private String decInstitution; + + @ApiModelProperty("涉及的内容(公共服务:主要内容)") + private String contentInvolve; + + @ApiModelProperty("适用对象说明") + private String applicableObject; + + @ApiModelProperty("行政相对人权利和义务") + private String xingzhenxdrxy; + + @ApiModelProperty("有无数量限制") + private String countLimit; + + @ApiModelProperty("数量限制情况说明") + private String countNote; + + @ApiModelProperty("禁止性要求") + private String banRequirement; + + @ApiModelProperty("事项审查类型") + private String shixiangsctype; + + @ApiModelProperty("事项审查类型说明") + private String shixiangsclx; + + @ApiModelProperty("申请方式") + private String applyType; + + @ApiModelProperty("联系电话") + private String applyTypeTel; + + @ApiModelProperty("邮箱") + private String applyTypeMail; + + @ApiModelProperty("传真") + private String applyTypeFax; + + @ApiModelProperty("办理方式") + private String handleType; + + @ApiModelProperty("手机端法人认证地址") + private String mbfarenadd; + + @ApiModelProperty("手机端个人认证标识") + private String mbgerenflag; + + @ApiModelProperty("时限说明") + private String destime; + + @ApiModelProperty("送达方式") + private String serviceMode; + + @ApiModelProperty("送达时限") + private String serviceDay; + + @ApiModelProperty("其他") + private String ununifydoOther; + + @ApiModelProperty("是否自有") + private String ishasownflow; + + @ApiModelProperty("分区") + private String dt; + + @ApiModelProperty("所属地市") + private String dscCity; + + @ApiModelProperty("所需区/县") + private String dscAdmRegion; + + @ApiModelProperty("数源单位代码") + private String dscSydepCode; + + @ApiModelProperty("数源单位") + private String dscSydepName; + + @ApiModelProperty("数据所属系统名称") + private String dscSydepSys; + + @ApiModelProperty("数源单位表名") + private String dscSydepTblname; + + @ApiModelProperty("唯一自增序列号") + private String dscBizRecordId; + + @ApiModelProperty("I插入U更新D删除") + private String dscBizOperation; + + @ApiModelProperty("源表数据同步时间") + private LocalDateTime dscBizTimestamp; + + @ApiModelProperty("数据来源表名(清洗库或基础库表名)") + private String dscDatasrTblname; + + @ApiModelProperty("业务主键MD5值(清洗增加)") + private String dscHashUnique; + + @ApiModelProperty("清洗时间(清洗增加)") + private String dscCleanTimestamp; + + @ApiModelProperty("地市仓数据入库时间") + private LocalDateTime dscDwRksj; +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/model/dto/KqZzsfwMattersDeduplicateDTO.java b/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/model/dto/KqZzsfwMattersDeduplicateDTO.java new file mode 100644 index 0000000..4ae81d0 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/model/dto/KqZzsfwMattersDeduplicateDTO.java @@ -0,0 +1,35 @@ +package com.ningdatech.kqapi.zzsfw.model.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.time.LocalDateTime; + +/** + *

+ * + *

+ * + * @author ZPF + * @since 2023-10-27 + */ +@Data +@ApiModel(value = "NdKqZzsfwMattersDeduplicate") +public class KqZzsfwMattersDeduplicateDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty("数据同步时间") + private LocalDateTime createOn; + + @ApiModelProperty("事项名称") + private String qlName; + + @ApiModelProperty("链接") + private String webapplyurl; + + @ApiModelProperty("重复数") + private Integer countNum; +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/model/dto/KqZzsfwMenuDTO.java b/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/model/dto/KqZzsfwMenuDTO.java new file mode 100644 index 0000000..3987394 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/model/dto/KqZzsfwMenuDTO.java @@ -0,0 +1,50 @@ +package com.ningdatech.kqapi.zzsfw.model.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.time.LocalDateTime; + +/** + *

+ * + *

+ * + * @author ZPF + * @since 2023-10-27 + */ +@Data +@ApiModel(value = "NdKqZzsfwMenu对象") +public class KqZzsfwMenuDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty("数据同步时间") + private LocalDateTime createOn; + + @ApiModelProperty("社区名") + private String zoneName; + + @ApiModelProperty("窗口") + private String window; + + @ApiModelProperty("部门") + private String department; + + @ApiModelProperty("事项名称") + private String itemName; + + @ApiModelProperty("事项在政务中心的rowid") + private String itemRowid; + + @ApiModelProperty("排序") + private Integer sort; + + @ApiModelProperty("链接") + private String webapplyurl; + + @ApiModelProperty("是否在政务中心查到url") + private Integer hasUrl; +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/model/dto/KqZzsfwPolicyDTO.java b/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/model/dto/KqZzsfwPolicyDTO.java new file mode 100644 index 0000000..ee30ddf --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/model/dto/KqZzsfwPolicyDTO.java @@ -0,0 +1,56 @@ +package com.ningdatech.kqapi.zzsfw.model.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.time.LocalDateTime; + +/** + *

+ * + *

+ * + * @author ZPF + * @since 2023-11-02 + */ +@Data +@ApiModel(value = "NdKqZzsfwPolicyDTO", description = "") +public class KqZzsfwPolicyDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty("数据同步时间") + private LocalDateTime createOn; + + @ApiModelProperty("抬头") + private String header; + + @ApiModelProperty("标题") + private String title; + + @ApiModelProperty("二级标题") + private String secondTitle; + + @ApiModelProperty("适用地区") + private String regionName; + + @ApiModelProperty("责任部门") + private String department; + + @ApiModelProperty("发文日期") + private String issueDate; + + @ApiModelProperty("状态") + private String status; + + @ApiModelProperty("申报时间") + private String applyTime; + + @ApiModelProperty("在线咨询url") + private String onlineConsultationUrl; + + @ApiModelProperty("排序") + private Integer sort; +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/model/entity/ComponentsMatterEliminateEntity.java b/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/model/entity/ComponentsMatterEliminateEntity.java new file mode 100644 index 0000000..7d08674 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/model/entity/ComponentsMatterEliminateEntity.java @@ -0,0 +1,43 @@ +package com.ningdatech.kqapi.zzsfw.model.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.security.Timestamp; + +// ComponentsMatterEliminateEntity.java +@Data +@TableName("components_matter_eliminate") +public class ComponentsMatterEliminateEntity { + + /** + * 事项名称剔除表,主要剔除事项url报错404链接 + */ + + @ApiModelProperty("id主键") + @TableId(type = IdType.AUTO) + private Long id; + /** + * 组件名称 + */ + private String qlName; + + /** + * 剔除时间 + */ + private Timestamp eliminateTime; + + /** + * 剔除标识,0未剔除,1已剔除 + */ + private String isDelete; + + public ComponentsMatterEliminateEntity(String qlName,String isDelete) { + this.qlName = qlName; + this.isDelete = isDelete; + } +} + diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/model/entity/DscSxAdsShareItemQltQlsxCommonIDVKq.java b/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/model/entity/DscSxAdsShareItemQltQlsxCommonIDVKq.java new file mode 100644 index 0000000..2922b59 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/model/entity/DscSxAdsShareItemQltQlsxCommonIDVKq.java @@ -0,0 +1,422 @@ +package com.ningdatech.kqapi.zzsfw.model.entity; + +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import java.io.Serializable; +import java.time.LocalDateTime; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + *

+ * 省回流_政务服务_数据共享_事项基本信息表 + *

+ * + * @author ZPF + * @since 2023-10-25 + */ +@Data +@TableName("dsc_sx_ads_share_item_qlt_qlsx_common_i_d_v_kq") +@ApiModel(value = "DscSxAdsShareItemQltQlsxCommonIDVKq对象", description = "省回流_政务服务_数据共享_事项基本信息表") +public class DscSxAdsShareItemQltQlsxCommonIDVKq implements Serializable { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty("事项唯一标识") + @TableId + private String rowguid; + + @ApiModelProperty("写入同步时间") + private LocalDateTime updateDate; + + @ApiModelProperty("事项更新类型") + private String updateType; + + @ApiModelProperty("事项类型") + private String qlKind; + + @ApiModelProperty("主项编码") + private String qlMainitemId; + + @ApiModelProperty("子项编码") + private String qlSubitemId; + + @ApiModelProperty("事权层级") + private String shiquancj; + + @ApiModelProperty("行政区划代码") + private String belongxiaqucode; + + @ApiModelProperty("实施机关组织机构代码(主管部门组织机构代码)") + private String qlDepOrgcdoe; + + @ApiModelProperty("权力来源") + private String itemsource; + + @ApiModelProperty("版本号") + private String versionNumber; + + @ApiModelProperty("事项入库时间") + private LocalDateTime versionDate; + + @ApiModelProperty("事项状态生效时间") + private LocalDateTime qlEffectTime; + + @ApiModelProperty("事项内部编码") + private String qlInnerCode; + + @ApiModelProperty("事项名称") + private String qlName; + + @ApiModelProperty("事项状态") + private String qlState; + + @ApiModelProperty("法定依据(审批依据;实施依据)") + private String lawbasis; + + @ApiModelProperty("法定期限") + private Long anticipateDay; + + @ApiModelProperty("法定期限单位") + private String anticipateType; + + @ApiModelProperty("承诺期限") + private Long promiseDay; + + @ApiModelProperty("办事者到办事现场次数") + private Long applyerminCount; + + @ApiModelProperty("是否列为国家、省、市、县级行政审批制度改革试点") + private String isPilot; + + @ApiModelProperty("实施机关(主管部门名称)") + private String qlDep; + + @ApiModelProperty("实施或牵头的处(科)室名称") + private String leadDept; + + @ApiModelProperty("办件类型") + private String bjtype; + + @ApiModelProperty("本级审批性质") + private String benjispxz; + + @ApiModelProperty("办理频率") + private String handleFrequency; + + @ApiModelProperty("行政相对人性质(适用对象(行政相对人性质);服务相对人性质)") + private String xingzhenxdrxz; + + @ApiModelProperty("审批条件(申请条件;受理条件)") + private String applyCondition; + + @ApiModelProperty("办件结果文件名称(审批结果)") + private String banjianFinishfiles; + + @ApiModelProperty("咨询电话") + private String linkTel; + + @ApiModelProperty("监督投诉电话") + private String superviseTel; + + @ApiModelProperty("电脑端网上办理地址") + private String webapplyurl; + + @ApiModelProperty("网上咨询网址") + private String webconsulturl; + + @ApiModelProperty("是否收费") + private String chargeFlag; + + @ApiModelProperty("收费依据") + private String chargeBasis; + + @ApiModelProperty("法人关注点") + private String rightclassQiyezt; + + @ApiModelProperty("面向法人的对象分类") + private String rightclassQiyedx; + + @ApiModelProperty("个人关注点") + private String rightclassGerensx; + + @ApiModelProperty("面向个人的对象分类") + private String rightclassGerendx; + + @ApiModelProperty("内部流程信息") + private String inFlowInfo; + + @ApiModelProperty("业务申报材料") + private String materialInfo; + + @ApiModelProperty("材料情形说明") + private String materialCaseInfo; + + @ApiModelProperty("收费项目") + private String chargeitemInfo; + + @ApiModelProperty("常见问题解答") + private String qaInfo; + + @ApiModelProperty("受理地点信息") + private String acceptAddressInfo; + + @ApiModelProperty("交换标识") + private String syncSign; + + @ApiModelProperty("交换时间") + private LocalDateTime syncDate; + + @ApiModelProperty("交换错误描述") + private String syncErrorDesc; + + @ApiModelProperty("部门组织机构代码") + private String ouorgcode; + + @ApiModelProperty("部门编码") + private String ouguid; + + @ApiModelProperty("法人登录地址(电脑端法人认证地址)") + private String farenurl; + + @ApiModelProperty("电脑端个人认证标识") + private String gerenflag; + + @ApiModelProperty("是否统建系统(是否使用统一网上申报)") + private String isTongjian; + + @ApiModelProperty("事项编码") + private String qlFullId; + + @ApiModelProperty("委托下放") + private String entrust; + + @ApiModelProperty("委托下放说明") + private String entrustdes; + + @ApiModelProperty("最少上门次数说明") + private String applyerminCountDesc; + + @ApiModelProperty("事项所属业务类型") + private String outypecode; + + @ApiModelProperty("对外公布办理程序描述") + private String outFlowDesc; + + @ApiModelProperty("办结类型") + private String banjianFinishtype; + + @ApiModelProperty("是否允许特别程序申请") + private String isSpecialpro; + + @ApiModelProperty("删除数据标识") + private String state2; + + @ApiModelProperty("不适宜开展网上申报") + private String nosuitApply; + + @ApiModelProperty("是否接入统一办件库") + private String isUnifydo; + + @ApiModelProperty("是否是上级主管部门统建系统") + private String isUpunify; + + @ApiModelProperty("权力属性") + private String qlAtt; + + @ApiModelProperty("备注") + private String baknote; + + @ApiModelProperty("星级服务(网上办理业务模式)") + private String webapplymode; + + @ApiModelProperty("权力来源方式") + private String itemsourcetype; + + @ApiModelProperty("是否可以适用处罚简易程序") + private String isSimplepunish; + + @ApiModelProperty("是否涉及征收(税)费减免的审批") + private String isLevywaiver; + + @ApiModelProperty("征收标准") + private String feebasis; + + @ApiModelProperty("自由裁量") + private String factInfo; + + @ApiModelProperty("涉密或敏感") + private String isCs; + + @ApiModelProperty("未接入统一办件库其他原因说明") + private String unifydodes; + + @ApiModelProperty("极少业务") + private String isVlb; + + @ApiModelProperty("nounify_do") + private String nounifyDo; + + @ApiModelProperty("乡镇延伸事项的部门源事项") + private String qlInnerCodeItem; + + @ApiModelProperty("是否投资(bak1)") + private String isTouzip; + + @ApiModelProperty("行业主题分类") + private String hangyeclasstype; + + @ApiModelProperty("其他行政权力子类型") + private String qlSubKind; + + @ApiModelProperty("移动端网上办理地址") + private String appwebapplyurl; + + @ApiModelProperty("移动端网上预约地址") + private String appappointmenturl; + + @ApiModelProperty("电脑端网上预约地址") + private String appointmenturl; + + @ApiModelProperty("是否网上预约") + private String isWebappointment; + + @ApiModelProperty("网上预约时段") + private String webappointmentperiod; + + @ApiModelProperty("主要内容") + private String maincontext; + + @ApiModelProperty("共同实施单位") + private String doDept; + + @ApiModelProperty("相关附件") + private String relatedguid; + + @ApiModelProperty("相关附件信息") + private String related; + + @ApiModelProperty("是否提供快递送达") + private String isExpress; + + @ApiModelProperty("公共服务事项子类型") + private String serviceSubKind; + + @ApiModelProperty("是否列入最多跑一次事项清单") + private String ispyc; + + @ApiModelProperty("联办事项") + private String lbsx; + + @ApiModelProperty("外部流程图") + private String outFlowUrl; + + @ApiModelProperty("受理机构") + private String acpInstitution; + + @ApiModelProperty("决定机构") + private String decInstitution; + + @ApiModelProperty("涉及的内容(公共服务:主要内容)") + private String contentInvolve; + + @ApiModelProperty("适用对象说明") + private String applicableObject; + + @ApiModelProperty("行政相对人权利和义务") + private String xingzhenxdrxy; + + @ApiModelProperty("有无数量限制") + private String countLimit; + + @ApiModelProperty("数量限制情况说明") + private String countNote; + + @ApiModelProperty("禁止性要求") + private String banRequirement; + + @ApiModelProperty("事项审查类型") + private String shixiangsctype; + + @ApiModelProperty("事项审查类型说明") + private String shixiangsclx; + + @ApiModelProperty("申请方式") + private String applyType; + + @ApiModelProperty("联系电话") + private String applyTypeTel; + + @ApiModelProperty("邮箱") + private String applyTypeMail; + + @ApiModelProperty("传真") + private String applyTypeFax; + + @ApiModelProperty("办理方式") + private String handleType; + + @ApiModelProperty("手机端法人认证地址") + private String mbfarenadd; + + @ApiModelProperty("手机端个人认证标识") + private String mbgerenflag; + + @ApiModelProperty("时限说明") + private String destime; + + @ApiModelProperty("送达方式") + private String serviceMode; + + @ApiModelProperty("送达时限") + private String serviceDay; + + @ApiModelProperty("其他") + private String ununifydoOther; + + @ApiModelProperty("是否自有") + private String ishasownflow; + + @ApiModelProperty("分区") + private String dt; + + @ApiModelProperty("所属地市") + private String dscCity; + + @ApiModelProperty("所需区/县") + private String dscAdmRegion; + + @ApiModelProperty("数源单位代码") + private String dscSydepCode; + + @ApiModelProperty("数源单位") + private String dscSydepName; + + @ApiModelProperty("数据所属系统名称") + private String dscSydepSys; + + @ApiModelProperty("数源单位表名") + private String dscSydepTblname; + + @ApiModelProperty("唯一自增序列号") + private String dscBizRecordId; + + @ApiModelProperty("I插入U更新D删除") + private String dscBizOperation; + + @ApiModelProperty("源表数据同步时间") + private LocalDateTime dscBizTimestamp; + + @ApiModelProperty("数据来源表名(清洗库或基础库表名)") + private String dscDatasrTblname; + + @ApiModelProperty("业务主键MD5值(清洗增加)") + private String dscHashUnique; + + @ApiModelProperty("清洗时间(清洗增加)") + private String dscCleanTimestamp; + + @ApiModelProperty("地市仓数据入库时间") + private LocalDateTime dscDwRksj; +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/model/entity/KqZzsfwMattersDeduplicate.java b/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/model/entity/KqZzsfwMattersDeduplicate.java new file mode 100644 index 0000000..55075af --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/model/entity/KqZzsfwMattersDeduplicate.java @@ -0,0 +1,51 @@ +package com.ningdatech.kqapi.zzsfw.model.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.time.LocalDateTime; + +/** + *

+ * + *

+ * + * @author ZPF + * @since 2023-10-27 + */ +@Data +@TableName("nd_kq_zzsfw_matters_deduplicate") +@ApiModel(value = "NdKqZzsfwMattersDeduplicate") +public class KqZzsfwMattersDeduplicate implements Serializable { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty("id主键") + @TableId(type = IdType.AUTO) + private Long id; + + @ApiModelProperty("数据同步时间") + private LocalDateTime createOn; + + @ApiModelProperty("事项名称") + private String qlName; + + @ApiModelProperty("链接") + private String webapplyurl; + + @ApiModelProperty("重复数") + private Integer countNum = 0; + + public static KqZzsfwMattersDeduplicate of(String qlName, String webapplyurl) { + KqZzsfwMattersDeduplicate dup = new KqZzsfwMattersDeduplicate(); + dup.setQlName(qlName); + dup.setWebapplyurl(webapplyurl); + dup.setCountNum(1); + return dup; + } +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/model/entity/KqZzsfwMenu.java b/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/model/entity/KqZzsfwMenu.java new file mode 100644 index 0000000..363ff1d --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/model/entity/KqZzsfwMenu.java @@ -0,0 +1,121 @@ +package com.ningdatech.kqapi.zzsfw.model.entity; + +import com.baomidou.mybatisplus.annotation.*; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.time.LocalDateTime; + +/** + *

+ * + *

+ * + * @author ZPF + * @since 2023-10-27 + */ +@Data +@TableName("nd_kq_zzsfw_menu") +@ApiModel(value = "NdKqZzsfwMenu对象") +public class KqZzsfwMenu implements Serializable { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty("id主键") + @TableId(type = IdType.AUTO) + private Long id; + + @ApiModelProperty("数据同步时间") + @TableField(fill = FieldFill.INSERT) + private LocalDateTime createOn; + + @ApiModelProperty("数据更新时间") + @TableField(fill = FieldFill.INSERT_UPDATE) + private LocalDateTime updateOn; + + @ApiModelProperty("创建人") + @TableField(fill = FieldFill.INSERT) + private Long createBy; + + @ApiModelProperty("更新人") + @TableField(fill = FieldFill.INSERT_UPDATE) + private Long updateBy; + + @ApiModelProperty("社区名") + private String zoneName; + + @ApiModelProperty("窗口") + private String window; + + @ApiModelProperty("部门") + private String department; + + @ApiModelProperty("事项名称") + private String itemName; + + @ApiModelProperty("事项在政务中心的rowid") + private String itemRowid; + + @ApiModelProperty("排序") + private Integer sort; + + @ApiModelProperty("链接") + private String webapplyurl; + + @ApiModelProperty("是否在政务中心查到url") + private Integer hasUrl; + + @ApiModelProperty("类型 1.政府服务 2.增值服务 3.特殊") + private Integer type; + + @ApiModelProperty("服务内容") + private String serviceContent; + + @ApiModelProperty("服务流程") + private String serviceProcess; + + @ApiModelProperty("咨询电话") + private String telephone; + + @ApiModelProperty("专区id") + private Integer zoneId; + + @ApiModelProperty("窗口id") + private Integer windowId; + + @ApiModelProperty("是否删除") + private Boolean deleted; + + @ApiModelProperty("服务对象") + private String serviceObject; + + @ApiModelProperty("是否免费") + private Boolean free; + + @ApiModelProperty("是否网上缴费") + private Boolean onlinePay; + + @ApiModelProperty("办理渠道") + private Integer handleChannel; + + @ApiModelProperty("办理地点") + private String handleAddress; + + @ApiModelProperty("办理时间") + private String handleTime; + + @ApiModelProperty("行使层级") + private String exerciseLevel; + + @ApiModelProperty("实施主体性质") + private Integer implSubjectNature; + + @ApiModelProperty("特色场景描述") + private String sceneDesc; + + @ApiModelProperty("宣传资料") + private String publicityMaterials; + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/model/entity/KqZzsfwPolicy.java b/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/model/entity/KqZzsfwPolicy.java new file mode 100644 index 0000000..f75a34b --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/model/entity/KqZzsfwPolicy.java @@ -0,0 +1,64 @@ +package com.ningdatech.kqapi.zzsfw.model.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.time.LocalDateTime; + +/** + *

+ * + *

+ * + * @author ZPF + * @since 2023-11-02 + */ +@Data +@TableName("nd_kq_zzsfw_policy") +@ApiModel(value = "NdKqZzsfwPolicy对象", description = "") +public class KqZzsfwPolicy implements Serializable { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty("id主键") + @TableId(type = IdType.AUTO) + private Long id; + + @ApiModelProperty("数据同步时间") + private LocalDateTime createOn; + + @ApiModelProperty("抬头") + private String header; + + @ApiModelProperty("标题") + private String title; + + @ApiModelProperty("二级标题") + private String secondTitle; + + @ApiModelProperty("适用地区") + private String regionName; + + @ApiModelProperty("责任部门") + private String department; + + @ApiModelProperty("发文日期") + private String issueDate; + + @ApiModelProperty("状态") + private String status; + + @ApiModelProperty("申报时间") + private String applyTime; + + @ApiModelProperty("在线咨询url") + private String onlineConsultationUrl; + + @ApiModelProperty("排序") + private Integer sort; +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/model/entity/MatterKey.java b/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/model/entity/MatterKey.java new file mode 100644 index 0000000..357f80a --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/model/entity/MatterKey.java @@ -0,0 +1,24 @@ +package com.ningdatech.kqapi.zzsfw.model.entity; + +import lombok.Data; + +/** + * @Classname MatterKey + * @Description + * @Date 2024/1/3 11:13 + * @Author PoffyZhang + */ +@Data +public class MatterKey { + + private String qlName; + + private String webapplyurl; + + public static MatterKey of(String qlName, String webapplyurl) { + MatterKey matterKey = new MatterKey(); + matterKey.setQlName(qlName); + matterKey.setWebapplyurl(webapplyurl); + return matterKey; + } +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/model/vo/MatterTopVO.java b/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/model/vo/MatterTopVO.java new file mode 100644 index 0000000..b478a62 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/model/vo/MatterTopVO.java @@ -0,0 +1,31 @@ +package com.ningdatech.kqapi.zzsfw.model.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; + +/** + *

+ * 事项 + *

+ * + * @author ZPF + * @since 2023-10-25 + */ +@Data +@ApiModel(value = "MatterTopVO", description = "事项top") +public class MatterTopVO implements Serializable { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty("事项名称") + private String matterName; + + @ApiModelProperty("事项链接") + private String webapplyurl; + + @ApiModelProperty("数量") + private Integer count; +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/model/vo/MattersVO.java b/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/model/vo/MattersVO.java new file mode 100644 index 0000000..24b4d13 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/model/vo/MattersVO.java @@ -0,0 +1,49 @@ +package com.ningdatech.kqapi.zzsfw.model.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; + +/** + *

+ * 事项 + *

+ * + * @author ZPF + * @since 2023-10-25 + */ +@Data +@ApiModel(value = "MattersVO", description = "事项") +public class MattersVO implements Serializable { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty("id主键") + private Long id; + + @ApiModelProperty("id") + private String rowguid; + + @ApiModelProperty("事项名称") + private String matterName; + + @ApiModelProperty("事项链接") + private String webapplyurl; + + @ApiModelProperty("排序编号") + private Integer sort; + + @ApiModelProperty("类型 1.政府服务 2.增值服务 3.特殊") + private Integer type; + + @ApiModelProperty("服务内容") + private String serviceContent; + + @ApiModelProperty("服务流程") + private String serviceProcess; + + @ApiModelProperty("咨询电话") + private String telephone; +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/model/vo/TreeVO.java b/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/model/vo/TreeVO.java new file mode 100644 index 0000000..18b020f --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/model/vo/TreeVO.java @@ -0,0 +1,56 @@ +package com.ningdatech.kqapi.zzsfw.model.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + *

+ * 树结构 + *

+ * + * @author ZPF + * @since 2023-10-25 + */ +@Data +@ApiModel(value = "TreeVO", description = "树结构") +public class TreeVO implements Serializable { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty("rowid") + private String id; + + @ApiModelProperty("名称") + private String name; + + @ApiModelProperty("类型") + private String type; + + @ApiModelProperty("链接") + private String url; + + @ApiModelProperty("链接") + private Integer sort; + + @ApiModelProperty("事项类型") + private Integer itemType; + + @ApiModelProperty("事项类型") + private Integer itemTypeName; + + @ApiModelProperty("服务内容") + private String serviceContent; + + @ApiModelProperty("服务流程") + private String serviceProcess; + + @ApiModelProperty("咨询电话") + private String telephone; + + @ApiModelProperty("子级") + private List chilren; +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/model/vo/WindowVO.java b/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/model/vo/WindowVO.java new file mode 100644 index 0000000..f982b95 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/model/vo/WindowVO.java @@ -0,0 +1,29 @@ +package com.ningdatech.kqapi.zzsfw.model.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + *

+ * 社区VO + *

+ * + * @author ZPF + * @since 2023-10-25 + */ +@Data +@ApiModel(value = "WindowVO", description = "窗口VO") +public class WindowVO implements Serializable { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty("窗口") + private String windowName; + + @ApiModelProperty("事项") + private List matters; +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/model/vo/ZoneVO.java b/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/model/vo/ZoneVO.java new file mode 100644 index 0000000..2b71c76 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/model/vo/ZoneVO.java @@ -0,0 +1,29 @@ +package com.ningdatech.kqapi.zzsfw.model.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + *

+ * 社区VO + *

+ * + * @author ZPF + * @since 2023-10-25 + */ +@Data +@ApiModel(value = "ZoneVO", description = "社区VO") +public class ZoneVO implements Serializable { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty("社区") + private String zoneName; + + @ApiModelProperty("社区") + private List windows; +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/model/vo/ZzsfwPolicyVO.java b/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/model/vo/ZzsfwPolicyVO.java new file mode 100644 index 0000000..628b9e0 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/model/vo/ZzsfwPolicyVO.java @@ -0,0 +1,59 @@ +package com.ningdatech.kqapi.zzsfw.model.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.time.LocalDateTime; + +/** + *

+ * + *

+ * + * @author ZPF + * @since 2023-11-02 + */ +@Data +@ApiModel(value = "NdKqZzsfwPolicy VO") +public class ZzsfwPolicyVO implements Serializable { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty("id主键") + private Long id; + + @ApiModelProperty("数据同步时间") + private LocalDateTime createOn; + + @ApiModelProperty("抬头") + private String header; + + @ApiModelProperty("标题") + private String title; + + @ApiModelProperty("二级标题") + private String secondTitle; + + @ApiModelProperty("适用地区") + private String regionName; + + @ApiModelProperty("责任部门") + private String department; + + @ApiModelProperty("发文日期") + private String issueDate; + + @ApiModelProperty("状态") + private String status; + + @ApiModelProperty("申报时间") + private String applyTime; + + @ApiModelProperty("在线咨询url") + private String onlineConsultationUrl; + + @ApiModelProperty("排序") + private Integer sort; +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/service/ComponentsMatterEliminateService.java b/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/service/ComponentsMatterEliminateService.java new file mode 100644 index 0000000..3129522 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/service/ComponentsMatterEliminateService.java @@ -0,0 +1,8 @@ +package com.ningdatech.kqapi.zzsfw.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.ningdatech.kqapi.zzsfw.model.entity.ComponentsMatterEliminateEntity; + +// ComponentsMatterEliminateService.java +public interface ComponentsMatterEliminateService extends IService { +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/service/IDscSxAdsShareItemQltQlsxCommonIDVKqService.java b/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/service/IDscSxAdsShareItemQltQlsxCommonIDVKqService.java new file mode 100644 index 0000000..be4be3b --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/service/IDscSxAdsShareItemQltQlsxCommonIDVKqService.java @@ -0,0 +1,16 @@ +package com.ningdatech.kqapi.zzsfw.service; + +import com.ningdatech.kqapi.zzsfw.model.entity.DscSxAdsShareItemQltQlsxCommonIDVKq; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + *

+ * 省回流_政务服务_数据共享_事项基本信息表 服务类 + *

+ * + * @author ZPF + * @since 2023-10-25 + */ +public interface IDscSxAdsShareItemQltQlsxCommonIDVKqService extends IService { + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/service/IKqZzsfwMatterDeduplicateService.java b/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/service/IKqZzsfwMatterDeduplicateService.java new file mode 100644 index 0000000..c631f97 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/service/IKqZzsfwMatterDeduplicateService.java @@ -0,0 +1,16 @@ +package com.ningdatech.kqapi.zzsfw.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.ningdatech.kqapi.zzsfw.model.entity.KqZzsfwMattersDeduplicate; + +/** + *

+ * 服务类 + *

+ * + * @author ZPF + * @since 2023-10-27 + */ +public interface IKqZzsfwMatterDeduplicateService extends IService { + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/service/IKqZzsfwMenuService.java b/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/service/IKqZzsfwMenuService.java new file mode 100644 index 0000000..67a20c5 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/service/IKqZzsfwMenuService.java @@ -0,0 +1,21 @@ +package com.ningdatech.kqapi.zzsfw.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.ningdatech.kqapi.zzsfw.model.entity.KqZzsfwMenu; + +import java.util.Collection; +import java.util.Map; + +/** + *

+ * 服务类 + *

+ * + * @author ZPF + * @since 2023-10-27 + */ +public interface IKqZzsfwMenuService extends IService { + + Map matterCountByWindowIds(Collection windowIds); + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/service/IKqZzsfwPolicyService.java b/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/service/IKqZzsfwPolicyService.java new file mode 100644 index 0000000..ee81ca9 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/service/IKqZzsfwPolicyService.java @@ -0,0 +1,16 @@ +package com.ningdatech.kqapi.zzsfw.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.ningdatech.kqapi.zzsfw.model.entity.KqZzsfwPolicy; + +/** + *

+ * 服务类 + *

+ * + * @author ZPF + * @since 2023-10-27 + */ +public interface IKqZzsfwPolicyService extends IService { + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/service/impl/ComponentsMatterEliminateServiceImpl.java b/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/service/impl/ComponentsMatterEliminateServiceImpl.java new file mode 100644 index 0000000..7042acd --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/service/impl/ComponentsMatterEliminateServiceImpl.java @@ -0,0 +1,16 @@ +package com.ningdatech.kqapi.zzsfw.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ningdatech.kqapi.zzsfw.model.entity.ComponentsMatterEliminateEntity; +import com.ningdatech.kqapi.zzsfw.mapper.ComponentsMatterEliminateMapper; +import com.ningdatech.kqapi.zzsfw.service.ComponentsMatterEliminateService; +import org.springframework.stereotype.Service; + +/** + * @author wangrenkang + * @date 2024-01-15 10:54:49 + */ +@Service +public class ComponentsMatterEliminateServiceImpl extends ServiceImpl implements ComponentsMatterEliminateService { + +} \ No newline at end of file diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/service/impl/DscSxAdsShareItemQltQlsxCommonIDVKqServiceImpl.java b/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/service/impl/DscSxAdsShareItemQltQlsxCommonIDVKqServiceImpl.java new file mode 100644 index 0000000..8af12b7 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/service/impl/DscSxAdsShareItemQltQlsxCommonIDVKqServiceImpl.java @@ -0,0 +1,20 @@ +package com.ningdatech.kqapi.zzsfw.service.impl; + +import com.ningdatech.kqapi.zzsfw.model.entity.DscSxAdsShareItemQltQlsxCommonIDVKq; +import com.ningdatech.kqapi.zzsfw.mapper.DscSxAdsShareItemQltQlsxCommonIDVKqMapper; +import com.ningdatech.kqapi.zzsfw.service.IDscSxAdsShareItemQltQlsxCommonIDVKqService; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +/** + *

+ * 省回流_政务服务_数据共享_事项基本信息表 服务实现类 + *

+ * + * @author ZPF + * @since 2023-10-25 + */ +@Service +public class DscSxAdsShareItemQltQlsxCommonIDVKqServiceImpl extends ServiceImpl implements IDscSxAdsShareItemQltQlsxCommonIDVKqService { + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/service/impl/KqZzsfwMatterDeduplicateServiceImpl.java b/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/service/impl/KqZzsfwMatterDeduplicateServiceImpl.java new file mode 100644 index 0000000..7bca6b0 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/service/impl/KqZzsfwMatterDeduplicateServiceImpl.java @@ -0,0 +1,21 @@ +package com.ningdatech.kqapi.zzsfw.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ningdatech.kqapi.zzsfw.model.entity.KqZzsfwMattersDeduplicate; +import com.ningdatech.kqapi.zzsfw.mapper.KqZzsfwMatterDeduplicateMapper; +import com.ningdatech.kqapi.zzsfw.service.IKqZzsfwMatterDeduplicateService; +import org.springframework.stereotype.Service; + +/** + *

+ * 服务实现类 + *

+ * + * @author ZPF + * @since 2023-10-27 + */ +@Service +public class KqZzsfwMatterDeduplicateServiceImpl extends ServiceImpl + implements IKqZzsfwMatterDeduplicateService { + +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/service/impl/KqZzsfwMenuServiceImpl.java b/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/service/impl/KqZzsfwMenuServiceImpl.java new file mode 100644 index 0000000..def79e7 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/service/impl/KqZzsfwMenuServiceImpl.java @@ -0,0 +1,38 @@ +package com.ningdatech.kqapi.zzsfw.service.impl; + +import cn.hutool.core.collection.CollUtil; +import com.ningdatech.basic.util.CollUtils; +import com.ningdatech.kqapi.admin.model.dto.MatterCountByWindowIdDTO; +import com.ningdatech.kqapi.zzsfw.model.entity.KqZzsfwMenu; +import com.ningdatech.kqapi.zzsfw.mapper.KqZzsfwMenuMapper; +import com.ningdatech.kqapi.zzsfw.service.IKqZzsfwMenuService; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.Map; + +/** + *

+ * 服务实现类 + *

+ * + * @author ZPF + * @since 2023-10-27 + */ +@Service +public class KqZzsfwMenuServiceImpl extends ServiceImpl implements IKqZzsfwMenuService { + + @Override + public Map matterCountByWindowIds(Collection windowIds) { + if (CollUtil.isEmpty(windowIds)) { + return Collections.emptyMap(); + } + List matterCountByWindowIds = baseMapper.selectMatterCountByWindowIds(windowIds); + return CollUtils.listToMap(matterCountByWindowIds, + MatterCountByWindowIdDTO::getWindowId, + MatterCountByWindowIdDTO::getMatterCount); + } +} diff --git a/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/service/impl/KqZzsfwPolicyServiceImpl.java b/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/service/impl/KqZzsfwPolicyServiceImpl.java new file mode 100644 index 0000000..230cdb1 --- /dev/null +++ b/kq-api/src/main/java/com/ningdatech/kqapi/zzsfw/service/impl/KqZzsfwPolicyServiceImpl.java @@ -0,0 +1,21 @@ +package com.ningdatech.kqapi.zzsfw.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ningdatech.kqapi.zzsfw.model.entity.KqZzsfwPolicy; +import com.ningdatech.kqapi.zzsfw.mapper.KqZzsfwPolicyMapper; +import com.ningdatech.kqapi.zzsfw.service.IKqZzsfwPolicyService; +import org.springframework.stereotype.Service; + +/** + *

+ * 服务实现类 + *

+ * + * @author ZPF + * @since 2023-10-27 + */ +@Service +public class KqZzsfwPolicyServiceImpl extends ServiceImpl + implements IKqZzsfwPolicyService { + +} diff --git a/kq-api/src/main/resources/application-dev.yml b/kq-api/src/main/resources/application-dev.yml new file mode 100644 index 0000000..46f263e --- /dev/null +++ b/kq-api/src/main/resources/application-dev.yml @@ -0,0 +1,142 @@ +server: + port: 33060 + servlet: + context-path: /kq + +spring: + mvc: + pathmatch: + matching-strategy: ant_path_matcher + session: + store-type: redis + redis: + namespace: "spring:session" + timeout: 864000 + redis: + timeout: 5000 + host: 47.98.125.47 + port: 26379 + database: 7 + password: Ndkj1234 + jedis: + pool: + max-active: 200 + max-idle: 500 + min-idle: 8 + max-wait: 10000 + application: + name: kq + jackson: + default-property-inclusion: non_null + time-zone: GMT+8 + date-format: yyyy-MM-dd HH:mm:ss + jpa: + properties: + hibernate: + default_schema: PUBLIC + hbm2ddl: + auto: update + show_sql: true + show-sql: true + hibernate: + ddl-auto: update + datasource: + type: com.zaxxer.hikari.HikariDataSource + driver-class-name: com.mysql.cj.jdbc.Driver + url: ENC(aMGW3+FFqxyutRz9liYjAg+A72b6IQ7/ygtxO0DmQJ/LLFZkx8r4MhN8quv9L62nQ4sH55qFg+LnQoor/t8IqBACrbfNg462YNKnRyMsBmdHHxJm7i57flIQfePLDW93Omz4LZ2PbRZTvPcLLYtnQyxXSDPwDnjexHNVXTdxwuTJPBqthsVpvyA2mnn5Szef) + username: root + password: ENC(NHFdgnNk7opRJpNnZOJs51OTXb72zU//) + # 数据源 + hikari: + # 是客户端等待连接池连接的最大毫秒数 + connection-timeout: 30000 + # 是允许连接在连接池中空闲的最长时间 + minimum-idle: 5 + # 配置最大池大小 + maximum-pool-size: 300 + # 是允许连接在连接池中空闲的最长时间(以毫秒为单位) + idle-timeout: 60000 + # 池中连接关闭后的最长生命周期(以毫秒为单位) + max-lifetime: 600000 + # 配置从池返回的连接的默认自动提交行为。默认值为true。 + auto-commit: true + # 开启连接监测泄露 + leak-detection-threshold: 500000 + # 测试连接数据库 + connection-test-query: SELECT 1 + #设置上传 单个文件的大小 + servlet: + multipart: + max-file-size: 100MB + max-request-size: 150MB +mybatis-plus: + configuration: + log-impl: org.apache.ibatis.logging.stdout.StdOutImpl + global-config: + db-config: + logic-delete-value: true + logic-not-delete-value: false + logic-delete-field: deleted +logging: + config: classpath:logback-spring.xml + #日志配置 + level: + root: info + file: + path: logs +nd: + cache: + type: REDIS + serializerType: ProtoStuff + cacheNullVal: true + def: + keyPrefix: kq + log: + enabled: true + type: DB + # 文件存储 + file: + storage-type: ALI_OSS + ali: + protocol: https:// + bucket: devplat + urlPrefix: oss-cn-hangzhou.aliyuncs.com + endpoint: oss-cn-hangzhou.aliyuncs.com + accessKeyId: LTAI4GL7uypycnBjiRn55rMG + accessKeySecret: qwYC7bW9bkStsko7qkLVnToAzj0Y98 +# 日志文件配置 +log: + path: ./logs + info: + file-size: 50MB + max-size: 5 + total-size: 200MB + error: + file-size: 10MB + max-size: 5 + total-size: 50MB + +swagger: + enabled: true + +hostname: iZbp13nwyvib53j4j1p2xoZ + +jasypt: + encryptor: + password: CodeSheep + # 指定解密算法,需要和加密时使用的算法一致 + algorithm: PBEWithMD5AndDES + # 指定initialization vector类型 + iv-generator-classname: org.jasypt.iv.NoIvGenerator +sso: + access-key: BCDSGA_c2494577610c90bdc33b95514601da2c + secret-key: BCDSGS_80bf0a606c0d2fd3201bd06a4f008250 + app-id: 2002399646 + token: + internet-url: https://ibcdsg.zj.gov.cn:8443/restapi/prod/IC33000020220329000007/uc/sso/access_token + zww-url: https://bcdsg.zj.gov.cn:8443/restapi/prod/IC33000020220329000007/uc/sso/access_token + user-info: + internet-url: https://ibcdsg.zj.gov.cn:8443/restapi/prod/IC33000020220329000008/uc/sso/getUserInfo + zww-url: https://bcdsg.zj.gov.cn:8443/restapi/prod/IC33000020220329000008/uc/sso/getUserInfo + + diff --git a/kq-api/src/main/resources/application-pre.yml b/kq-api/src/main/resources/application-pre.yml new file mode 100644 index 0000000..3d6716e --- /dev/null +++ b/kq-api/src/main/resources/application-pre.yml @@ -0,0 +1,138 @@ +server: + port: 33060 + servlet: + context-path: /kq + +spring: + mvc: + pathmatch: + matching-strategy: ant_path_matcher + session: + store-type: redis + redis: + namespace: "spring:session" + timeout: 864000 + redis: + timeout: 5000 + host: 47.98.125.47 + port: 26379 + database: 7 + password: Ndkj1234 + jedis: + pool: + max-active: 200 + max-idle: 500 + min-idle: 8 + max-wait: 10000 + application: + name: kq + jackson: + default-property-inclusion: non_null + time-zone: GMT+8 + date-format: yyyy-MM-dd HH:mm:ss + jpa: + properties: + hibernate: + default_schema: PUBLIC + hbm2ddl: + auto: update + show_sql: true + show-sql: true + hibernate: + ddl-auto: update + datasource: + type: com.zaxxer.hikari.HikariDataSource + driver-class-name: com.mysql.cj.jdbc.Driver + url: ENC(aMGW3+FFqxyutRz9liYjAg+A72b6IQ7/ygtxO0DmQJ/LLFZkx8r4MhN8quv9L62nQ4sH55qFg+LnQoor/t8IqBACrbfNg462YNKnRyMsBmdHHxJm7i57flIQfePLDW93Omz4LZ2PbRZTvPcLLYtnQyxXSDPwDnjexHNVXTdxwuTJPBqthsVpvyA2mnn5Szef) + username: root + password: NingdaKeji123! + # 数据源 + hikari: + # 是客户端等待连接池连接的最大毫秒数 + connection-timeout: 30000 + # 是允许连接在连接池中空闲的最长时间 + minimum-idle: 5 + # 配置最大池大小 + maximum-pool-size: 300 + # 是允许连接在连接池中空闲的最长时间(以毫秒为单位) + idle-timeout: 60000 + # 池中连接关闭后的最长生命周期(以毫秒为单位) + max-lifetime: 600000 + # 配置从池返回的连接的默认自动提交行为。默认值为true。 + auto-commit: true + # 开启连接监测泄露 + leak-detection-threshold: 500000 + # 测试连接数据库 + connection-test-query: SELECT 1 + #设置上传 单个文件的大小 + servlet: + multipart: + max-file-size: 100MB + max-request-size: 150MB +mybatis-plus: + configuration: + log-impl: org.apache.ibatis.logging.stdout.StdOutImpl + global-config: + db-config: + logic-delete-value: true + logic-not-delete-value: false +logging: + config: classpath:logback-spring.xml + #日志配置 + level: + root: info + file: + path: logs +nd: + cache: + type: REDIS + serializerType: ProtoStuff + cacheNullVal: true + def: + keyPrefix: kq + log: + enabled: true + type: DB + # 文件存储 + file: + storage-type: ALI_OSS + ali: + protocol: https:// + bucket: devplat + urlPrefix: oss-cn-hangzhou.aliyuncs.com + endpoint: oss-cn-hangzhou.aliyuncs.com + accessKeyId: LTAI4GL7uypycnBjiRn55rMG + accessKeySecret: qwYC7bW9bkStsko7qkLVnToAzj0Y98 +# 日志文件配置 +log: + path: ./logs + info: + file-size: 50MB + max-size: 5 + total-size: 200MB + error: + file-size: 10MB + max-size: 5 + total-size: 50MB + +swagger: + enabled: true + +hostname: iZbp13nwyvib53j4j1p2xoZ + +jasypt: + encryptor: + password: CodeSheep + algorithm: PBEWithMD5AndDES + # 指定initialization vector类型 + iv-generator-classname: org.jasypt.iv.NoIvGenerator +sso: + access-key: BCDSGA_c2494577610c90bdc33b95514601da2c + secret-key: BCDSGS_80bf0a606c0d2fd3201bd06a4f008250 + app-id: 2002399646 + token: + internet-url: https://ibcdsg.zj.gov.cn:8443/restapi/prod/IC33000020220329000007/uc/sso/access_token + zww-url: https://bcdsg.zj.gov.cn:8443/restapi/prod/IC33000020220329000007/uc/sso/access_token + user-info: + internet-url: https://ibcdsg.zj.gov.cn:8443/restapi/prod/IC33000020220329000008/uc/sso/getUserInfo + zww-url: https://bcdsg.zj.gov.cn:8443/restapi/prod/IC33000020220329000008/uc/sso/getUserInfo \ No newline at end of file diff --git a/kq-api/src/main/resources/application-prod.yml b/kq-api/src/main/resources/application-prod.yml new file mode 100644 index 0000000..56dfaa5 --- /dev/null +++ b/kq-api/src/main/resources/application-prod.yml @@ -0,0 +1,142 @@ +server: + port: 33061 + servlet: + context-path: /kq + +spring: + mvc: + pathmatch: + matching-strategy: ant_path_matcher + session: + store-type: redis + redis: + namespace: "spring:session" + timeout: 864000 + redis: + timeout: 5000 + host: 47.98.125.47 + port: 26379 + database: 7 + password: Ndkj1234 + jedis: + pool: + max-active: 200 + max-idle: 500 + min-idle: 8 + max-wait: 10000 + application: + name: kq + jackson: + default-property-inclusion: non_null + time-zone: GMT+8 + date-format: yyyy-MM-dd HH:mm:ss + jpa: + properties: + hibernate: + default_schema: PUBLIC + hbm2ddl: + auto: update + show_sql: true + show-sql: true + hibernate: + ddl-auto: update + datasource: + type: com.zaxxer.hikari.HikariDataSource + driver-class-name: com.mysql.cj.jdbc.Driver + url: ENC(gtE4OUrpgtFsh6B3aLiSp2sVSX1BYDET9Uii/wRP2RboRK0NDaYu1S7Vx30cHXFE7vecQzY1UbrSFW/BaWJvQ3XJxfDiaUxdrIDND5e+DMTjx1pUkfS8/RbXHQDE+QoOVZV1UKEtdq+khr32tlQXqkTnzmZGuZjctVmjdQxUnmI2YNpoeNlIAkDXiaCvcVYc) + username: root + password: Nd@20231116 + + # 数据源 + hikari: + # 是客户端等待连接池连接的最大毫秒数 + connection-timeout: 30000 + # 是允许连接在连接池中空闲的最长时间 + minimum-idle: 5 + # 配置最大池大小 + maximum-pool-size: 300 + # 是允许连接在连接池中空闲的最长时间(以毫秒为单位) + idle-timeout: 60000 + # 池中连接关闭后的最长生命周期(以毫秒为单位) + max-lifetime: 600000 + # 配置从池返回的连接的默认自动提交行为。默认值为true。 + auto-commit: true + # 开启连接监测泄露 + leak-detection-threshold: 500000 + # 测试连接数据库 + connection-test-query: SELECT 1 + #设置上传 单个文件的大小 + servlet: + multipart: + max-file-size: 100MB + max-request-size: 150MB +mybatis-plus: + configuration: + log-impl: org.apache.ibatis.logging.stdout.StdOutImpl + global-config: + db-config: + logic-delete-value: true + logic-not-delete-value: false + logic-delete-field: deleted +logging: + config: classpath:logback-spring.xml + #日志配置 + level: + root: info + file: + path: logs +nd: + cache: + type: REDIS + serializerType: ProtoStuff + cacheNullVal: true + def: + keyPrefix: kq + log: + enabled: true + type: DB + # 文件存储 + file: + storage-type: ALI_OSS + ali: + protocol: https:// + bucket: devplat + urlPrefix: oss-cn-hangzhou.aliyuncs.com + endpoint: oss-cn-hangzhou.aliyuncs.com + accessKeyId: LTAI4GL7uypycnBjiRn55rMG + accessKeySecret: qwYC7bW9bkStsko7qkLVnToAzj0Y98 +# 日志文件配置 +log: + path: ./logs + info: + file-size: 50MB + max-size: 5 + total-size: 200MB + error: + file-size: 10MB + max-size: 5 + total-size: 50MB + +swagger: + enabled: false + +hostname: iZut201mqskxt0mwme4tjfZ + +jasypt: + encryptor: + password: CodeSheep + algorithm: PBEWithMD5AndDES + # 指定initialization vector类型 + iv-generator-classname: org.jasypt.iv.NoIvGenerator +sso: + access-key: BCDSGA_c2494577610c90bdc33b95514601da2c + secret-key: BCDSGS_80bf0a606c0d2fd3201bd06a4f008250 + app-id: 2002399646 + token: + internet-url: https://ibcdsg.zj.gov.cn:8443/restapi/prod/IC33000020220329000007/uc/sso/access_token + zww-url: https://bcdsg.zj.gov.cn:8443/restapi/prod/IC33000020220329000007/uc/sso/access_token + user-info: + internet-url: https://ibcdsg.zj.gov.cn:8443/restapi/prod/IC33000020220329000008/uc/sso/getUserInfo + zww-url: https://bcdsg.zj.gov.cn:8443/restapi/prod/IC33000020220329000008/uc/sso/getUserInfo + + diff --git a/kq-api/src/main/resources/application.yml b/kq-api/src/main/resources/application.yml new file mode 100644 index 0000000..3d7808a --- /dev/null +++ b/kq-api/src/main/resources/application.yml @@ -0,0 +1,3 @@ +spring: + profiles: + active: dev diff --git a/kq-api/src/main/resources/logback-spring.xml b/kq-api/src/main/resources/logback-spring.xml new file mode 100644 index 0000000..75f5472 --- /dev/null +++ b/kq-api/src/main/resources/logback-spring.xml @@ -0,0 +1,68 @@ + + + + + + + + + + + ${logPath}/info.log + + ${logPath}/info-%d{yyyyMMdd}-%i.log + + ${infoFileSize} + + ${infoMaxSize} + ${infoTotalSize} + + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} -%msg%n + + + UTF-8 + + + + + + ERROR + + ${logPath}/error.log + + ${logPath}/error-%d{yyyyMMdd}-%i.log + + ${errorFileSize} + + ${errorMaxSize} + ${errorTotalSize} + + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} -%msg%n + + + UTF-8 + + + + + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} -%msg%n + + UTF-8 + + + DEBUG + + + + + + + + + diff --git a/kq-api/src/main/resources/security/auth-dev.yml b/kq-api/src/main/resources/security/auth-dev.yml new file mode 100644 index 0000000..b0fd8b5 --- /dev/null +++ b/kq-api/src/main/resources/security/auth-dev.yml @@ -0,0 +1,38 @@ +security: + auth: + auth-require-url: /api/v1/user/auth/auth-require + invalid-session-url: /api/v1/user/auth/invalid-session + password-login-url: /api/v1/user/auth/login/password + logout-url: /api/v1/user/auth/logout + ignore-auth-urls: + - /api/v1/poclicy/** + - /api/v1/zzsfw/** + - /v2/api-docs + - /swagger-ui.html + - /webjars/** + - /swagger-resources/** + - /webjars/ + - /api/v1/user/auth/register + - /api/v1/user/auth/auth-require + - /api/v1/user/auth/invalid-session + - /api/v1/user/auth/login/password + - /api/v1/user/auth/forget-password + - /doc.html + - /ok.html + - /open/api/** + - /api/v1/wechat/** + ignore-csrf-urls: + - /api/v1/poclicy/** + - /api/v1/zzsfw/** + - /api/v1/user/auth/** + - /v2/api-docs + - /swagger-ui.html + - /webjars/** + - /swagger-resources/** + - /webjars/ + - /doc.html + - /ok.html + - /api/v1/** + - /file/** + - /optLog/** + - /dict/** \ No newline at end of file diff --git a/kq-api/src/main/resources/security/auth-prod.yml b/kq-api/src/main/resources/security/auth-prod.yml new file mode 100644 index 0000000..f264900 --- /dev/null +++ b/kq-api/src/main/resources/security/auth-prod.yml @@ -0,0 +1,39 @@ +security: + auth: + auth-require-url: /api/v1/user/auth/auth-require + invalid-session-url: /api/v1/user/auth/invalid-session + password-login-url: /api/v1/user/auth/login/password + logout-url: /api/v1/user/auth/logout + ignore-auth-urls: + - /v2/api-docs + - /swagger-ui.html + - /webjars/** + - /swagger-resources/** + - /webjars/ + - /api/v1/user/auth/register + - /api/v1/user/auth/login/password + - /api/v1/user/auth/forget-password + - /doc.html + - /ok.html + - /api/v1/wechat/** + ignore-csrf-urls: + - /api/v1/user/auth/** + - /v2/api-docs + - /swagger-ui.html + - /webjars/** + - /swagger-resources/** + - /webjars/ + - /doc.html + - /ok.html + - /api/v1/** + - /file/** + - /optLog/** + - /dict/** + - /api/v1/wechat/** + role-map: + "engineer": + "project_manager": + "enterprise_admin": + "regional_general_manager": + "driver": + "super_admin": \ No newline at end of file diff --git a/kq-api/src/test/java/com/ningdatech/kqapi/AppTests.java b/kq-api/src/test/java/com/ningdatech/kqapi/AppTests.java new file mode 100644 index 0000000..a86f1d9 --- /dev/null +++ b/kq-api/src/test/java/com/ningdatech/kqapi/AppTests.java @@ -0,0 +1,19 @@ +package com.ningdatech.kqapi; + +import org.junit.runner.RunWith; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +/** + *

+ * AppRunTests + *

+ * + * @author WendyYang + * @since 19:27 2022/5/10 + */ +@RunWith(SpringRunner.class) +@SpringBootTest(classes = App.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +public class AppTests { + +} diff --git a/kq-api/src/test/java/com/ningdatech/kqapi/menu/DuplicationTest.java b/kq-api/src/test/java/com/ningdatech/kqapi/menu/DuplicationTest.java new file mode 100644 index 0000000..70a46fe --- /dev/null +++ b/kq-api/src/test/java/com/ningdatech/kqapi/menu/DuplicationTest.java @@ -0,0 +1,100 @@ +package com.ningdatech.kqapi.menu; + +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.google.common.collect.Sets; +import com.ningdatech.kqapi.AppTests; +import com.ningdatech.kqapi.zzsfw.model.entity.KqZzsfwMenu; +import com.ningdatech.kqapi.zzsfw.model.entity.KqZzsfwMattersDeduplicate; +import com.ningdatech.kqapi.zzsfw.service.IKqZzsfwMatterDeduplicateService; +import com.ningdatech.kqapi.zzsfw.service.IKqZzsfwMenuService; +import org.apache.commons.lang3.StringUtils; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.junit.Assert; +import org.junit.Test; +import org.springframework.beans.factory.annotation.Autowired; + +import java.io.FileInputStream; +import java.io.IOException; +import java.time.LocalDateTime; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; + +/** + * @Classname DuplicationTest + * @Description + * @Date 2023/11/17 10:42 + * @Author PoffyZhang + */ +public class DuplicationTest extends AppTests { + + @Autowired + private IKqZzsfwMatterDeduplicateService matterDeduplicateService; + + @Autowired + private IKqZzsfwMenuService menuService; + + @Test + public void test() throws IOException { + FileInputStream fis = new FileInputStream("C:\\Users\\PoffyZhang\\Desktop\\去重后的事项数据.xlsx"); + Workbook workbook = new XSSFWorkbook(fis); + Assert.assertNotNull(workbook); + Row row; + if (workbook != null) { + //获取最大行数 + Sheet sheet = workbook.getSheetAt(0); + int rownum = sheet.getPhysicalNumberOfRows(); + //获取第一行 + row = sheet.getRow(0); + //获取最大列数 + Integer num = 1; + + matterDeduplicateService.remove(Wrappers.lambdaQuery(KqZzsfwMattersDeduplicate.class)); + + for (int i = 2; i < rownum; i++) { + row = sheet.getRow(i); + if(row.getZeroHeight()){ + continue; + } + System.out.println("记数:" + (num++)); + System.out.println(row.getCell(0).getStringCellValue()); + System.out.println(row.getCell(1).getStringCellValue()); + Double numericCellValue = row.getCell(2).getNumericCellValue(); + + KqZzsfwMattersDeduplicate menu = new KqZzsfwMattersDeduplicate(); + menu.setWebapplyurl(row.getCell(1).getStringCellValue()); + menu.setQlName(row.getCell(0).getStringCellValue()); + menu.setCreateOn(LocalDateTime.now()); + menu.setCountNum(numericCellValue.intValue()); + + matterDeduplicateService.save(menu); + } + } + } + + @Test + public void syncUrl(){ + List menus = menuService.list(Wrappers.lambdaQuery(KqZzsfwMenu.class)); + + List list = matterDeduplicateService.list(); + + Set qlSet = Sets.newTreeSet(); + Map map = list.stream().filter(q -> qlSet.add(q.getQlName())) + .filter(q -> StringUtils.isNotBlank(q.getWebapplyurl()) && StringUtils.isNotBlank(q.getQlName())) + .collect(Collectors.toMap(q -> q.getQlName(), q -> q.getWebapplyurl())); + + for(KqZzsfwMenu menu : menus){ + String itemName = menu.getItemName(); + if(map.containsKey(itemName)){ + String url = map.get(itemName); + menu.setWebapplyurl(url); + menu.setHasUrl(1); + menuService.updateById(menu); + } + } + } +} diff --git a/kq-api/src/test/java/com/ningdatech/kqapi/menu/ExcelSplitMergedCells.java b/kq-api/src/test/java/com/ningdatech/kqapi/menu/ExcelSplitMergedCells.java new file mode 100644 index 0000000..bb3731f --- /dev/null +++ b/kq-api/src/test/java/com/ningdatech/kqapi/menu/ExcelSplitMergedCells.java @@ -0,0 +1,60 @@ +package com.ningdatech.kqapi.menu; + +import org.apache.poi.ss.usermodel.*; +import org.apache.poi.ss.util.CellRangeAddress; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; + +public class ExcelSplitMergedCells { + public static void main(String[] args) throws IOException { + // 打开Excel文件 + FileInputStream fis = new FileInputStream("C:\\Users\\PoffyZhang\\Desktop\\8.8柯桥区企业综合服务中心政务服务事项清单.xlsx"); + Workbook workbook = new XSSFWorkbook(fis); + Sheet sheet = workbook.getSheetAt(0); + + // 获取合并单元格的范围 + CellRangeAddress mergedRegion = sheet.getMergedRegion(0); // 0表示第一个合并的单元格 + int firstRow = mergedRegion.getFirstRow(); + int lastRow = mergedRegion.getLastRow(); + int firstCol = mergedRegion.getFirstColumn(); + int lastCol = mergedRegion.getLastColumn(); + + // 取消合并单元格 + sheet.removeMergedRegion(0); + Integer num = 0; + // 创建新的单元格并复制内容 + for (int i = firstRow; i <= lastRow; i++) { + Row row = sheet.getRow(i); + for (int j = firstCol; j <= lastCol; j++) { + Cell oldCell = row.getCell(j); + Cell newCell = row.createCell(j); + newCell.setCellType(oldCell.getCellType()); + switch (oldCell.getCellType()) { + case STRING: + newCell.setCellValue(oldCell.getStringCellValue()); + break; + case NUMERIC: + newCell.setCellValue(oldCell.getNumericCellValue()); + break; + case BOOLEAN: + newCell.setCellValue(oldCell.getBooleanCellValue()); + break; + case FORMULA: + newCell.setCellFormula(oldCell.getCellFormula()); + break; + default: + newCell.setCellValue(""); + } + } + } + + // 保存修改后的Excel文件 + fis.close(); + FileOutputStream fos = new FileOutputStream("C:\\Users\\PoffyZhang\\Desktop\\8.8柯桥区企业综合服务中心政务服务事项清单2.xlsx"); + workbook.write(fos); + fos.close(); + } +} \ No newline at end of file diff --git a/kq-api/src/test/java/com/ningdatech/kqapi/menu/MenuTest.java b/kq-api/src/test/java/com/ningdatech/kqapi/menu/MenuTest.java new file mode 100644 index 0000000..89ec354 --- /dev/null +++ b/kq-api/src/test/java/com/ningdatech/kqapi/menu/MenuTest.java @@ -0,0 +1,187 @@ +package com.ningdatech.kqapi.menu; + +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.ningdatech.kqapi.AppTests; +import com.ningdatech.kqapi.zzsfw.model.entity.KqZzsfwMenu; +import com.ningdatech.kqapi.zzsfw.enumeration.ItemTypeEnum; +import com.ningdatech.kqapi.zzsfw.service.IKqZzsfwMenuService; +import org.apache.poi.ss.usermodel.*; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.junit.Assert; +import org.junit.Test; +import org.springframework.beans.factory.annotation.Autowired; +import java.io.FileInputStream; +import java.io.IOException; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.Statement; +import java.text.DecimalFormat; +import java.time.LocalDateTime; + +/** + * @Classname MenuTest + * @Description + * @Date 2023/10/27 9:51 + * @Author PoffyZhang + */ +public class MenuTest extends AppTests{ // + + @Autowired + private IKqZzsfwMenuService menuService; + + @Test + public void test() throws IOException { + FileInputStream fis = new FileInputStream("C:\\Users\\PoffyZhang\\Desktop\\11.14柯桥.xlsx"); + Workbook workbook = new XSSFWorkbook(fis); + Assert.assertNotNull(workbook); + Row row; + if (workbook != null) { + //获取最大行数 + Sheet sheet = workbook.getSheetAt(0); + int rownum = sheet.getPhysicalNumberOfRows(); + //获取第一行 + row = sheet.getRow(0); + //获取最大列数 + Integer num = 1; + + menuService.remove(Wrappers.lambdaQuery(KqZzsfwMenu.class)); + + for (int i = 2; i < rownum; i++) { + row = sheet.getRow(i); + if(row.getZeroHeight()){ + continue; + } + System.out.println("记数:" + (num++)); + System.out.println(row.getCell(0).getStringCellValue()); + System.out.println(row.getCell(1).getStringCellValue()); + System.out.println(row.getCell(2).getStringCellValue()); + Double numericCellValue = row.getCell(3).getNumericCellValue(); + String itemName = row.getCell(4).getStringCellValue(); + System.out.println(itemName); + + KqZzsfwMenu menu = new KqZzsfwMenu(); + menu.setItemName(itemName); + menu.setZoneName(row.getCell(0).getStringCellValue()); + menu.setWindow(row.getCell(1).getStringCellValue()); + menu.setCreateOn(LocalDateTime.now()); + menu.setDepartment(row.getCell(2).getStringCellValue()); + menu.setSort(numericCellValue.intValue()); + + //去查询 url +// DscSxAdsShareItemQltQlsxCommonIDVKq item = itemQltQlsxCommonIDVKqService.getOne(Wrappers.lambdaQuery(DscSxAdsShareItemQltQlsxCommonIDVKq.class) +// .select(DscSxAdsShareItemQltQlsxCommonIDVKq::getRowguid, DscSxAdsShareItemQltQlsxCommonIDVKq::getWebapplyurl, DscSxAdsShareItemQltQlsxCommonIDVKq::getQlName) +// .eq(DscSxAdsShareItemQltQlsxCommonIDVKq::getQlName, itemName) +// .isNotNull(DscSxAdsShareItemQltQlsxCommonIDVKq::getWebapplyurl) +// .last("limit 1")); +// if(Objects.nonNull(item)){ + menu.setHasUrl(1); +// menu.setWebapplyurl(item.getWebapplyurl()); +// menu.setItemRowid(item.getRowguid()); +// } + + menuService.save(menu); + } + } + } + + + @Test + public void importData() throws IOException { + FileInputStream fis = new FileInputStream("C:\\Users\\PoffyZhang\\Desktop\\增值服务数据20240403.xlsx"); + Workbook workbook = new XSSFWorkbook(fis); + Assert.assertNotNull(workbook); + Row row; + if (workbook != null) { + //获取最大行数 + Sheet sheet = workbook.getSheetAt(0); + int rownum = sheet.getPhysicalNumberOfRows(); + //获取第一行 + row = sheet.getRow(0); + //获取最大列数 + Integer num = 1; + + for (int i = 2; i < rownum; i++) { + row = sheet.getRow(i); + if (row.getZeroHeight()) { + continue; + } + System.out.println("记数:" + (num++)); + String zoneName = row.getCell(0).getStringCellValue(); + System.out.println(zoneName); + DecimalFormat decimalFormat = new DecimalFormat("#"); + Integer sort = Integer.valueOf(decimalFormat.format(row.getCell(1).getNumericCellValue())); + System.out.println(sort); + String windowName = row.getCell(2).getStringCellValue(); + System.out.println(windowName); + String department = row.getCell(3).getStringCellValue(); + System.out.println(department); + String itemName = row.getCell(4).getStringCellValue(); + System.out.println(itemName); + String serviceContent = row.getCell(5).getStringCellValue(); + System.out.println(serviceContent); + String serviceProcess = row.getCell(6).getStringCellValue(); + System.out.println(serviceProcess); + String telephone = ""; + CellType cellType = row.getCell(7).getCellType(); + if(cellType.equals(CellType.STRING)){ + telephone = row.getCell(7).getStringCellValue(); + System.out.println(telephone); + }else if(cellType.equals(CellType.NUMERIC)){ + DecimalFormat decimalFormat2 = new DecimalFormat("#.#######"); + telephone = decimalFormat2.format(row.getCell(7).getNumericCellValue()); + System.out.println(telephone); + } + KqZzsfwMenu menu = new KqZzsfwMenu(); + menu.setItemName(itemName); + menu.setZoneName(zoneName); + menu.setWindow(windowName); + menu.setDepartment(department); + menu.setServiceContent(serviceContent); + menu.setServiceProcess(serviceProcess); + menu.setTelephone(telephone); + menu.setType(ItemTypeEnum.ADDED.getCode()); + menu.setCreateOn(LocalDateTime.now()); + menu.setSort(sort); +// menuService.save(menu); + } + } + + } + + + @Test + public void tableAndColumn() throws IOException { + String url = "jdbc:mysql://47.98.125.47:3306/kqzzsfw?serverTimezone=Asia/Shanghai&characterEncoding=utf8&allowPublicKeyRetrieval=true&useSSL=false"; // 你的数据库URL + String username = "root"; // 数据库用户名 + String password = "NingdaKeji123!"; // 数据库密码 + + String table = "nd_kq_zzsfw_menu"; + + try { + // 1. 加载数据库驱动 + Class.forName("com.mysql.cj.jdbc.Driver"); + + // 2. 建立数据库连接 + Connection connection = DriverManager.getConnection(url, username, password); + + // 3. 创建Statement对象 + Statement statement = connection.createStatement(); + + // 4. 编写并执行DDL语句(创建一个名为`users`的表) +// String createTableUsers = "alter table nd_kq_zzsfw_menu add column type tinyint default 1 comment '类型 1.政府服务 2.增值服务 3.特殊'"; +// String createTableUsers = "alter table nd_kq_zzsfw_menu add column service_content text comment '服务内容';"; +// String createTableUsers = "alter table nd_kq_zzsfw_menu add column service_process text comment '服务流程';"; + String createTableUsers = "alter table nd_kq_zzsfw_menu add column telephone text comment '咨询电话'"; + statement.executeUpdate(createTableUsers); + + System.out.println(" Table '" + table + "' updated successfully."); + + // 5. 关闭资源 + statement.close(); + connection.close(); + + } catch (Exception e) { + e.printStackTrace(); + } + } +} diff --git a/kq-api/src/test/java/com/ningdatech/kqapi/menu/PolicyTest.java b/kq-api/src/test/java/com/ningdatech/kqapi/menu/PolicyTest.java new file mode 100644 index 0000000..cb128b6 --- /dev/null +++ b/kq-api/src/test/java/com/ningdatech/kqapi/menu/PolicyTest.java @@ -0,0 +1,85 @@ +package com.ningdatech.kqapi.menu; + +import cn.hutool.core.date.DateUtil; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.ningdatech.kqapi.AppTests; +import com.ningdatech.kqapi.zzsfw.model.entity.KqZzsfwPolicy; +import com.ningdatech.kqapi.zzsfw.service.IKqZzsfwPolicyService; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.junit.Assert; +import org.junit.Test; +import org.springframework.beans.factory.annotation.Autowired; + +import java.io.FileInputStream; +import java.io.IOException; +import java.time.LocalDateTime; +import java.util.Objects; + +/** + * @Classname MenuTest + * @Description + * @Date 2023/10/27 9:51 + * @Author PoffyZhang + */ +public class PolicyTest extends AppTests { + + @Autowired + private IKqZzsfwPolicyService policyService; + + @Test + public void test() throws IOException { + FileInputStream fis = new FileInputStream("C:\\Users\\PoffyZhang\\Desktop\\政策条例摘录.xlsx"); + Workbook workbook = new XSSFWorkbook(fis); + Assert.assertNotNull(workbook); + Row row; + + policyService.remove(Wrappers.lambdaQuery(KqZzsfwPolicy.class)); + + if (workbook != null) { + //获取最大行数 + Sheet sheet = workbook.getSheetAt(0); + int rownum = sheet.getPhysicalNumberOfRows(); + //获取第一行 + row = sheet.getRow(0); + //获取最大列数 + Integer sort = 1; + for (int i = 2; i < rownum; i++) { + row = sheet.getRow(i); + if(row.getZeroHeight()){ + continue; + } + + String header = Objects.nonNull(row.getCell(0)) ? row.getCell(0).getStringCellValue() : null; + String title = Objects.nonNull(row.getCell(1)) ? row.getCell(1).getStringCellValue() : null; + String secondTitle = Objects.nonNull(row.getCell(2)) ? row.getCell(2).getStringCellValue() : null; + String regionName = Objects.nonNull(row.getCell(3)) ? row.getCell(3).getStringCellValue() : null; + String department = Objects.nonNull(row.getCell(4)) ? row.getCell(4).getStringCellValue() : null; + String issueDate = Objects.nonNull(row.getCell(5)) ? DateUtil.format(row.getCell(5).getDateCellValue(),"yyyy/MM/dd") : null; + String status = Objects.nonNull(row.getCell(7)) ? row.getCell(7).getStringCellValue() : null; + String applyTime = Objects.nonNull(row.getCell(8)) ? row.getCell(8).getStringCellValue() : null; + String url = Objects.nonNull(row.getCell(9)) ? row.getCell(9).getStringCellValue() : null; + + KqZzsfwPolicy policy = new KqZzsfwPolicy(); + policy.setHeader(header); + policy.setTitle(title); + policy.setSecondTitle(secondTitle); + policy.setRegionName(regionName); + policy.setDepartment(department); + policy.setIssueDate(issueDate); + policy.setStatus(status); + policy.setApplyTime(applyTime); + policy.setOnlineConsultationUrl(url); + policy.setCreateOn(LocalDateTime.now()); + policy.setSort(sort); + + policyService.save(policy); + + System.out.println("记数:" + (sort++)); + } + } + } + +} diff --git a/kq-api/src/test/resources/application-dev.yml b/kq-api/src/test/resources/application-dev.yml new file mode 100644 index 0000000..0bb9896 --- /dev/null +++ b/kq-api/src/test/resources/application-dev.yml @@ -0,0 +1,123 @@ +server: + port: 33060 + servlet: + context-path: /kq + +spring: + mvc: + pathmatch: + matching-strategy: ant_path_matcher + session: + store-type: redis + redis: + namespace: "spring:session" + timeout: 864000 + redis: + timeout: 5000 + host: 47.98.125.47 + port: 26379 + database: 7 + password: Ndkj1234 + jedis: + pool: + max-active: 200 + max-idle: 500 + min-idle: 8 + max-wait: 10000 + application: + name: kq + jackson: + default-property-inclusion: non_null + time-zone: GMT+8 + date-format: yyyy-MM-dd HH:mm:ss + jpa: + properties: + hibernate: + default_schema: PUBLIC + hbm2ddl: + auto: update + show_sql: true + show-sql: true + hibernate: + ddl-auto: update + datasource: + type: com.zaxxer.hikari.HikariDataSource + driver-class-name: com.mysql.cj.jdbc.Driver + url: jdbc:mysql://47.98.125.47:3306/kqzzsfw?serverTimezone=Asia/Shanghai&characterEncoding=utf8&allowPublicKeyRetrieval=true&useSSL=false + username: root + password: NingdaKeji123! + # 数据源 + hikari: + # 是客户端等待连接池连接的最大毫秒数 + connection-timeout: 30000 + # 是允许连接在连接池中空闲的最长时间 + minimum-idle: 5 + # 配置最大池大小 + maximum-pool-size: 300 + # 是允许连接在连接池中空闲的最长时间(以毫秒为单位) + idle-timeout: 60000 + # 池中连接关闭后的最长生命周期(以毫秒为单位) + max-lifetime: 600000 + # 配置从池返回的连接的默认自动提交行为。默认值为true。 + auto-commit: true + # 开启连接监测泄露 + leak-detection-threshold: 10000 + # 测试连接数据库 + connection-test-query: SELECT 1 + #设置上传 单个文件的大小 + servlet: + multipart: + max-file-size: 100MB + max-request-size: 150MB +mybatis-plus: + configuration: + log-impl: org.apache.ibatis.logging.stdout.StdOutImpl + global-config: + db-config: + logic-delete-value: true + logic-not-delete-value: false +logging: + config: classpath:logback-spring.xml + #日志配置 + level: + root: info + file: + path: logs +nd: + cache: + type: REDIS + serializerType: ProtoStuff + cacheNullVal: true + def: + keyPrefix: kq + log: + enabled: true + type: DB + # 文件存储 + file: + storage-type: ALI_OSS + ali: + protocol: https:// + bucket: devplat + urlPrefix: oss-cn-hangzhou.aliyuncs.com + endpoint: oss-cn-hangzhou.aliyuncs.com + accessKeyId: LTAI4GL7uypycnBjiRn55rMG + accessKeySecret: qwYC7bW9bkStsko7qkLVnToAzj0Y98 +# 日志文件配置 +log: + path: ./logs + info: + file-size: 50MB + max-size: 5 + total-size: 200MB + error: + file-size: 10MB + max-size: 5 + total-size: 50MB + +swagger: + enabled: true + +hostname: iZbp13nwyvib53j4j1p2xoZ + + diff --git a/kq-api/src/test/resources/application-pre.yml b/kq-api/src/test/resources/application-pre.yml new file mode 100644 index 0000000..908d625 --- /dev/null +++ b/kq-api/src/test/resources/application-pre.yml @@ -0,0 +1,121 @@ +server: + port: 33060 + servlet: + context-path: /kq + +spring: + mvc: + pathmatch: + matching-strategy: ant_path_matcher + session: + store-type: redis + redis: + namespace: "spring:session" + timeout: 864000 + redis: + timeout: 5000 + host: 47.98.125.47 + port: 26379 + database: 7 + password: Ndkj1234 + jedis: + pool: + max-active: 200 + max-idle: 500 + min-idle: 8 + max-wait: 10000 + application: + name: kq + jackson: + default-property-inclusion: non_null + time-zone: GMT+8 + date-format: yyyy-MM-dd HH:mm:ss + jpa: + properties: + hibernate: + default_schema: PUBLIC + hbm2ddl: + auto: update + show_sql: true + show-sql: true + hibernate: + ddl-auto: update + datasource: + type: com.zaxxer.hikari.HikariDataSource + driver-class-name: com.mysql.cj.jdbc.Driver + url: jdbc:mysql://47.98.125.47:3306/kqzzsfw?serverTimezone=Asia/Shanghai&characterEncoding=utf8&allowPublicKeyRetrieval=true&useSSL=false + username: root + password: NingdaKeji123! + # 数据源 + hikari: + # 是客户端等待连接池连接的最大毫秒数 + connection-timeout: 30000 + # 是允许连接在连接池中空闲的最长时间 + minimum-idle: 5 + # 配置最大池大小 + maximum-pool-size: 300 + # 是允许连接在连接池中空闲的最长时间(以毫秒为单位) + idle-timeout: 60000 + # 池中连接关闭后的最长生命周期(以毫秒为单位) + max-lifetime: 600000 + # 配置从池返回的连接的默认自动提交行为。默认值为true。 + auto-commit: true + # 开启连接监测泄露 + leak-detection-threshold: 5000 + # 测试连接数据库 + connection-test-query: SELECT 1 + #设置上传 单个文件的大小 + servlet: + multipart: + max-file-size: 100MB + max-request-size: 150MB +mybatis-plus: + configuration: + log-impl: org.apache.ibatis.logging.stdout.StdOutImpl + global-config: + db-config: + logic-delete-value: true + logic-not-delete-value: false +logging: + config: classpath:logback-spring.xml + #日志配置 + level: + root: info + file: + path: logs +nd: + cache: + type: REDIS + serializerType: ProtoStuff + cacheNullVal: true + def: + keyPrefix: kq + log: + enabled: true + type: DB + # 文件存储 + file: + storage-type: ALI_OSS + ali: + protocol: https:// + bucket: devplat + urlPrefix: oss-cn-hangzhou.aliyuncs.com + endpoint: oss-cn-hangzhou.aliyuncs.com + accessKeyId: LTAI4GL7uypycnBjiRn55rMG + accessKeySecret: qwYC7bW9bkStsko7qkLVnToAzj0Y98 +# 日志文件配置 +log: + path: ./logs + info: + file-size: 50MB + max-size: 5 + total-size: 200MB + error: + file-size: 10MB + max-size: 5 + total-size: 50MB + +swagger: + enabled: true + +hostname: iZbp13nwyvib53j4j1p2xoZ \ No newline at end of file diff --git a/kq-api/src/test/resources/application-prod.yml b/kq-api/src/test/resources/application-prod.yml new file mode 100644 index 0000000..68d6de2 --- /dev/null +++ b/kq-api/src/test/resources/application-prod.yml @@ -0,0 +1,123 @@ +server: + port: 33060 + servlet: + context-path: /kq + +spring: + mvc: + pathmatch: + matching-strategy: ant_path_matcher + session: + store-type: redis + redis: + namespace: "spring:session" + timeout: 864000 + redis: + timeout: 5000 + host: 47.98.125.47 + port: 26379 + database: 7 + password: Ndkj1234 + jedis: + pool: + max-active: 200 + max-idle: 500 + min-idle: 8 + max-wait: 10000 + application: + name: kq + jackson: + default-property-inclusion: non_null + time-zone: GMT+8 + date-format: yyyy-MM-dd HH:mm:ss + jpa: + properties: + hibernate: + default_schema: PUBLIC + hbm2ddl: + auto: update + show_sql: true + show-sql: true + hibernate: + ddl-auto: update + datasource: + type: com.zaxxer.hikari.HikariDataSource + driver-class-name: com.mysql.cj.jdbc.Driver + url: jdbc:mysql://10.42.248.27:3306/kqzzsfw?serverTimezone=Asia/Shanghai&characterEncoding=utf8&allowPublicKeyRetrieval=true&useSSL=false + username: root + password: Nd@20231116 + # 数据源 + hikari: + # 是客户端等待连接池连接的最大毫秒数 + connection-timeout: 30000 + # 是允许连接在连接池中空闲的最长时间 + minimum-idle: 5 + # 配置最大池大小 + maximum-pool-size: 300 + # 是允许连接在连接池中空闲的最长时间(以毫秒为单位) + idle-timeout: 60000 + # 池中连接关闭后的最长生命周期(以毫秒为单位) + max-lifetime: 600000 + # 配置从池返回的连接的默认自动提交行为。默认值为true。 + auto-commit: true + # 开启连接监测泄露 + leak-detection-threshold: 500000 + # 测试连接数据库 + connection-test-query: SELECT 1 + #设置上传 单个文件的大小 + servlet: + multipart: + max-file-size: 100MB + max-request-size: 150MB +mybatis-plus: + configuration: + log-impl: org.apache.ibatis.logging.stdout.StdOutImpl + global-config: + db-config: + logic-delete-value: true + logic-not-delete-value: false +logging: + config: classpath:logback-spring.xml + #日志配置 + level: + root: info + file: + path: logs +nd: + cache: + type: REDIS + serializerType: ProtoStuff + cacheNullVal: true + def: + keyPrefix: kq + log: + enabled: true + type: DB + # 文件存储 + file: + storage-type: ALI_OSS + ali: + protocol: https:// + bucket: devplat + urlPrefix: oss-cn-hangzhou.aliyuncs.com + endpoint: oss-cn-hangzhou.aliyuncs.com + accessKeyId: LTAI4GL7uypycnBjiRn55rMG + accessKeySecret: qwYC7bW9bkStsko7qkLVnToAzj0Y98 +# 日志文件配置 +log: + path: ./logs + info: + file-size: 50MB + max-size: 5 + total-size: 200MB + error: + file-size: 10MB + max-size: 5 + total-size: 50MB + +swagger: + enabled: true + +hostname: iZut201mqskxt0mwme4tjfZ + + diff --git a/kq-api/src/test/resources/application.yml b/kq-api/src/test/resources/application.yml new file mode 100644 index 0000000..9f96606 --- /dev/null +++ b/kq-api/src/test/resources/application.yml @@ -0,0 +1,3 @@ +spring: + profiles: + active: prod diff --git a/kq-api/src/test/resources/integration/zwdd-dev.yml b/kq-api/src/test/resources/integration/zwdd-dev.yml new file mode 100644 index 0000000..cc28814 --- /dev/null +++ b/kq-api/src/test/resources/integration/zwdd-dev.yml @@ -0,0 +1,12 @@ +#专有钉钉 +integration: + zwdd: + #扫码 + app-auth-key: ls-rebuild_dingoa-rgeWs3YVr26z + app-auth-secret: 37qCe6ylNMW0N8K2741z0c2b9vJP2gtuMRQQtZ9P + #免登/获取信息 + app-key: ls_rebuild-10c8n5X0707yFV7jURr + app-secret: gN8J3WazyXLMWKDuFmx6C4yaH5lFUY41x8rYLLo6 + #专有钉钉在开发管理工作台,右键查看网页源码realmId: '31141',浙政钉固定196729 + tenantId: 31141 + domain: openplatform.dg-work.cn \ No newline at end of file diff --git a/kq-api/src/test/resources/integration/zwdd-prod.yml b/kq-api/src/test/resources/integration/zwdd-prod.yml new file mode 100644 index 0000000..6b30e1b --- /dev/null +++ b/kq-api/src/test/resources/integration/zwdd-prod.yml @@ -0,0 +1,12 @@ +#浙政钉 +integration: + zwdd: + #扫码 + app-auth-key: ls_project_managment_din-b1Y3I1g7Rr94yX76KfFkpp18Uy4WHtU0b6rINJ3 + app-auth-secret: 75e8PMHv984KYF0Mcy6v4pxt480y73dbD7kB65dD + #免登/获取信息 + app-key: ls_project-c32LNu87v60UiANZVja + app-secret: R14QgbBr21751LTGml3Vt8oX9doPl4Lk1ROzZNfG + #专有钉钉在开发管理工作台,右键查看网页源码realmId: '31141',浙政钉固定196729 + tenantId: 196729 + domain: openplatform-pro.ding.zj.gov.cn \ No newline at end of file diff --git a/kq-api/src/test/resources/logback-spring.xml b/kq-api/src/test/resources/logback-spring.xml new file mode 100644 index 0000000..75f5472 --- /dev/null +++ b/kq-api/src/test/resources/logback-spring.xml @@ -0,0 +1,68 @@ + + + + + + + + + + + ${logPath}/info.log + + ${logPath}/info-%d{yyyyMMdd}-%i.log + + ${infoFileSize} + + ${infoMaxSize} + ${infoTotalSize} + + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} -%msg%n + + + UTF-8 + + + + + + ERROR + + ${logPath}/error.log + + ${logPath}/error-%d{yyyyMMdd}-%i.log + + ${errorFileSize} + + ${errorMaxSize} + ${errorTotalSize} + + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} -%msg%n + + + UTF-8 + + + + + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} -%msg%n + + UTF-8 + + + DEBUG + + + + + + + + + diff --git a/kq-api/src/test/resources/security/auth-dev.yml b/kq-api/src/test/resources/security/auth-dev.yml new file mode 100644 index 0000000..53ec385 --- /dev/null +++ b/kq-api/src/test/resources/security/auth-dev.yml @@ -0,0 +1,68 @@ +security: + auth: + auth-require-url: /api/v1/user/auth/auth-require + invalid-session-url: /api/v1/user/auth/invalid-session + password-login-url: /api/v1/user/auth/login + agent-login-url: /api/v1/user/auth/agent-login + logout-url: /api/v1/user/auth/logout + common-login-url: /api/v1/user/auth/common-login + ignore-auth-urls: + - /v2/api-docs + - /swagger-ui.html + - /webjars/** + - /swagger-resources/** + - /webjars/ + - /api/v1/user/auth/register + - /api/v1/user/auth/auth-require + - /api/v1/user/auth/invalid-session + - /api/v1/user/auth/login/password + - /api/v1/user/auth/forget-password + - /api/v1/user/auth/common-login + - /doc.html + - /ok.html + - /open/api/** + - /oa/** + - /wflow/** + - /sys/** + - /api/v1/verification/** + - /api/v1/expert/registration + - /api/v1/meta/dictionary/list + - /api/v1/meta/tag + - /api/v1/organization/tree-list + - /api/v1/organization/get-child-list + - /api/v1/region/tree + ignore-csrf-urls: + - /api/v1/user/auth/** + - /v2/api-docs + - /swagger-ui.html + - /webjars/** + - /swagger-resources/** + - /webjars/ + - /doc.html + - /ok.html + - /api/v1/** + - /file/** + - /optLog/** + - /dict/** + - /oa/** + - /wflow/** + - /sys/** + - /api/v1/verification/** + - /api/v1/expert/registration + - /api/v1/meta/dictionary/list + - /api/v1/meta/tag + - /api/v1/organization/tree-list + - /api/v1/organization/get-child-list + - /api/v1/region/tree + role-map: + "engineer": + "project_manager": + - /api/v1/user-info/kick-off/** + "enterprise_admin": + "regional_general_manager": + "driver": + "super_admin": + - /api/v1/user-info/save + - /api/v1/user-info/del + - /api/v1/user-info/kick-off/** + - /api/v1/user-info/password/mod \ No newline at end of file diff --git a/kq-api/src/test/resources/security/auth-prod.yml b/kq-api/src/test/resources/security/auth-prod.yml new file mode 100644 index 0000000..53ec385 --- /dev/null +++ b/kq-api/src/test/resources/security/auth-prod.yml @@ -0,0 +1,68 @@ +security: + auth: + auth-require-url: /api/v1/user/auth/auth-require + invalid-session-url: /api/v1/user/auth/invalid-session + password-login-url: /api/v1/user/auth/login + agent-login-url: /api/v1/user/auth/agent-login + logout-url: /api/v1/user/auth/logout + common-login-url: /api/v1/user/auth/common-login + ignore-auth-urls: + - /v2/api-docs + - /swagger-ui.html + - /webjars/** + - /swagger-resources/** + - /webjars/ + - /api/v1/user/auth/register + - /api/v1/user/auth/auth-require + - /api/v1/user/auth/invalid-session + - /api/v1/user/auth/login/password + - /api/v1/user/auth/forget-password + - /api/v1/user/auth/common-login + - /doc.html + - /ok.html + - /open/api/** + - /oa/** + - /wflow/** + - /sys/** + - /api/v1/verification/** + - /api/v1/expert/registration + - /api/v1/meta/dictionary/list + - /api/v1/meta/tag + - /api/v1/organization/tree-list + - /api/v1/organization/get-child-list + - /api/v1/region/tree + ignore-csrf-urls: + - /api/v1/user/auth/** + - /v2/api-docs + - /swagger-ui.html + - /webjars/** + - /swagger-resources/** + - /webjars/ + - /doc.html + - /ok.html + - /api/v1/** + - /file/** + - /optLog/** + - /dict/** + - /oa/** + - /wflow/** + - /sys/** + - /api/v1/verification/** + - /api/v1/expert/registration + - /api/v1/meta/dictionary/list + - /api/v1/meta/tag + - /api/v1/organization/tree-list + - /api/v1/organization/get-child-list + - /api/v1/region/tree + role-map: + "engineer": + "project_manager": + - /api/v1/user-info/kick-off/** + "enterprise_admin": + "regional_general_manager": + "driver": + "super_admin": + - /api/v1/user-info/save + - /api/v1/user-info/del + - /api/v1/user-info/kick-off/** + - /api/v1/user-info/password/mod \ No newline at end of file diff --git a/kq-api/src/test/resources/wsdl-prod.xml b/kq-api/src/test/resources/wsdl-prod.xml new file mode 100644 index 0000000..0302851 --- /dev/null +++ b/kq-api/src/test/resources/wsdl-prod.xml @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/kq-api/src/test/resources/wsdl.xml b/kq-api/src/test/resources/wsdl.xml new file mode 100644 index 0000000..eed87a7 --- /dev/null +++ b/kq-api/src/test/resources/wsdl.xml @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/kq-gen/pom.xml b/kq-gen/pom.xml new file mode 100644 index 0000000..3288333 --- /dev/null +++ b/kq-gen/pom.xml @@ -0,0 +1,60 @@ + + + + kq-value-added-project + com.ningdatech + 1.0.0 + + 4.0.0 + + kq-gen + + + + com.baomidou + mybatis-plus-boot-starter + + + + com.baomidou + mybatis-plus-generator + ${mybatis.plus.version} + + + + org.freemarker + freemarker + + + + + mysql + mysql-connector-java + + + + + org.apache.directory.studio + org.apache.commons.codec + 1.8 + + + junit + junit + 4.12 + test + + + + org.springframework.boot + spring-boot-starter-test + + + + org.springframework.boot + spring-boot-starter-test + + + diff --git a/kq-gen/src/main/java/com/ningdatech/generator/config/CodeGen.java b/kq-gen/src/main/java/com/ningdatech/generator/config/CodeGen.java new file mode 100644 index 0000000..9217cd5 --- /dev/null +++ b/kq-gen/src/main/java/com/ningdatech/generator/config/CodeGen.java @@ -0,0 +1,64 @@ +package com.ningdatech.generator.config; + +import com.baomidou.mybatisplus.generator.FastAutoGenerator; +import com.baomidou.mybatisplus.generator.config.OutputFile; +import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine; + +import java.util.Collections; + +/** + * @description: 自动生成code代码 + * @author: zpf + * @date: 2023/01/03 09:20 + */ +public class CodeGen { + + private static final String PATH_LXX = "/Users/liuxinxin/IdeaProjects/project-management/pmapi/src/main/java"; + private static final String PATH_YYD = "/Users/wendy/coding/java/kq-value-added-project/kqapi/src/main/java"; + private static final String PATH_LS = ""; + private static final String PATH_ZPF = "D:\\ningda\\kq-value-added-project\\kqapi\\src\\main\\java"; + private static final String PATH_CMM = "D:\\work\\project-management\\project-management\\pmapi\\src\\main\\java"; + + private static final String URL = "jdbc:mysql://47.98.125.47:3306/kqzzsfw?serverTimezone=Asia/Shanghai&characterEncoding=utf8&allowPublicKeyRetrieval=true&useSSL=false"; + private static final String USER_NAME = "root"; + private static final String PASSWORD = "NingdaKeji123!"; + + private static void generate(String author, String packageName, String path, String... tableNames) { + FastAutoGenerator.create(URL, USER_NAME, PASSWORD) + .globalConfig(builder -> { + // 设置作者 + builder.author(author) + // 开启 swagger 模式 + .enableSwagger() + // 覆盖已生成文件 + .fileOverride() + // 指定输出目录 + .outputDir(path); + }) + .packageConfig(builder -> { + // 设置父包名 + builder.parent("com.ningdatech") + // 设置父包模块名 + .moduleName("kqapi." + packageName) + // 设置mapperXml生成路径 + .pathInfo(Collections.singletonMap(OutputFile.mapperXml, + //设置自己的生成路径 + path + "/com/ningdatech/kqapi/" + packageName + "/mapper")); + }) + .strategyConfig(builder -> { + builder.addTablePrefix("nd"); + // 设置需要生成的表名 + builder.addInclude(tableNames); + }) + // 使用Freemarker引擎模板,默认的是Velocity引擎模板 + .templateEngine(new FreemarkerTemplateEngine()) + .execute(); + } + + public static void main(String[] args) { + // generate("Liuxinxin", "expert", PATH_LXX, "expert_gov_business_strip"); + // generate("ZPF", "zzsfw", PATH_ZPF, "nd_kq_zzsfw_menu"); + generate("WendyYang", "admin", PATH_YYD, "nd_window","nd_zone"); + } + +} diff --git a/kqapi/pom.xml b/kqapi/pom.xml deleted file mode 100644 index 1d58531..0000000 --- a/kqapi/pom.xml +++ /dev/null @@ -1,237 +0,0 @@ - - - 4.0.0 - - com.ningdatech - kq-value-added-project - 1.0.0 - - kqapi - 1.0.0 - - - - - - com.google.guava - guava - - - cn.hutool - hutool-all - 5.8.5 - - - - org.projectlombok - lombok - - - - com.baomidou - mybatis-plus-boot-starter - - - com.baomidou - mybatis-plus-extension - - - - org.apache.commons - commons-pool2 - ${commons-pool2.version} - - - org.apache.commons - commons-lang3 - - - com.alibaba - fastjson - - - org.apache.tomcat.embed - tomcat-embed-core - - - org.springframework.boot - spring-boot-starter-validation - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-jdbc - - - - org.springframework.boot - spring-boot-devtools - test - - - org.springframework.boot - spring-boot-starter-aop - - - - com.github.ben-manes.caffeine - caffeine - - - org.apache.httpcomponents - httpclient - - - org.apache.poi - poi - - - org.apache.poi - poi-ooxml - - - - com.aliyun.oss - aliyun-sdk-oss - 3.15.0 - - - junit - junit - test - - - org.aspectj - aspectjweaver - - - - org.springframework.boot - spring-boot-starter-test - - - org.springframework.boot - spring-boot-configuration-processor - - - - - mysql - mysql-connector-java - - - - com.github.ulisesbocchio - jasypt-spring-boot-starter - 3.0.4 - - - com.ningdatech - nd-log-starter - - - org.springframework.boot - spring-boot-starter-data-redis - - - org.springframework.session - spring-session-data-redis - - - com.ningdatech - nd-swagger2-starter - - - com.ningdatech - nd-file-starter - - - - - - - dev - - - dev - - - - test - - test - - - - pre - - pre - - - - prod - - prod - - - - - - - - src/main/resources - - **/* - - - - src/main/java - - **/*.xml - - - - src/main/lib - BOOT-INF/lib/ - - **/*.jar - - - - src/main/resources - BOOT-INF/classes/ - - - ${project.artifactId} - - - org.springframework.boot - spring-boot-maven-plugin - 2.6.8 - - true - - - - - repackage - - - - - - - org.apache.maven.plugins - maven-surefire-plugin - - true - - - - - - diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/App.java b/kqapi/src/main/java/com/ningdatech/kqapi/App.java deleted file mode 100644 index 85ee652..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/App.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.ningdatech.kqapi; - -import com.ningdatech.basic.util.SpringUtils; -import com.ningdatech.kqapi.common.util.SpringContextHolder; -import org.mybatis.spring.annotation.MapperScan; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.ApplicationContext; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.EnableAspectJAutoProxy; -import org.springframework.scheduling.annotation.EnableAsync; -import org.springframework.scheduling.annotation.EnableScheduling; -import org.springframework.transaction.annotation.EnableTransactionManagement; - -/** - * @author zpf - */ -@SpringBootApplication -@EnableAsync -@MapperScan(App.MAPPER_PACKAGES) -@EnableScheduling -@EnableTransactionManagement -@EnableAspectJAutoProxy(exposeProxy = true) -@ComponentScan(basePackages = {"com.ningdatech.kqapi","com.ningdatech.kqapi.common"}) -public class App { - - protected static final String MAPPER_PACKAGES = "com.ningdatech.kqapi.**.mapper"; - - public static void main(String[] args) { - ApplicationContext context = SpringApplication.run(App.class, args); - // 设置applicationContext - SpringUtils.setApplicationContext(context); - } - - @Bean - public SpringContextHolder springContextHolder() { - return new SpringContextHolder(); - } - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/admin/controller/MatterController.java b/kqapi/src/main/java/com/ningdatech/kqapi/admin/controller/MatterController.java deleted file mode 100644 index 1872f26..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/admin/controller/MatterController.java +++ /dev/null @@ -1,59 +0,0 @@ -package com.ningdatech.kqapi.admin.controller; - -import com.ningdatech.basic.model.IdVo; -import com.ningdatech.basic.model.PageVo; -import com.ningdatech.kqapi.admin.manage.AdminMatterManage; -import com.ningdatech.kqapi.admin.model.req.MatterListReq; -import com.ningdatech.kqapi.admin.model.vo.MatterDetailDTO; -import com.ningdatech.kqapi.admin.model.vo.MatterListVO; -import com.ningdatech.log.annotation.WebLog; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import lombok.RequiredArgsConstructor; -import org.springframework.web.bind.annotation.*; - -/** - *

- * MatterController - *

- * - * @author WendyYang - * @since 16:10 2024/4/20 - */ -@Api(tags = "事项管理") -@RestController -@RequiredArgsConstructor -@RequestMapping("/api/v1/matter") -public class MatterController { - - private final AdminMatterManage matterManage; - - @DeleteMapping("/del") - @ApiOperation("删除事项") - @WebLog("删除事项") - public void del(@RequestBody IdVo id) { - matterManage.del(id); - } - - @GetMapping("/page") - @ApiOperation("事项列表") - @WebLog("事项列表") - public PageVo pageMatter(MatterListReq req) { - return matterManage.pageMatter(req); - } - - @GetMapping("/detail/{id}") - @ApiOperation("事项详情") - @WebLog("事项详情") - public MatterDetailDTO detail(@PathVariable Long id) { - return matterManage.detail(id); - } - - @PostMapping("/save") - @ApiOperation("事项保存或修改") - @WebLog("事项保存或修改") - public void saveOrUpdate(@RequestBody MatterDetailDTO req) { - matterManage.saveOrUpdate(req); - } - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/admin/controller/WindowController.java b/kqapi/src/main/java/com/ningdatech/kqapi/admin/controller/WindowController.java deleted file mode 100644 index 117b60f..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/admin/controller/WindowController.java +++ /dev/null @@ -1,63 +0,0 @@ -package com.ningdatech.kqapi.admin.controller; - - -import com.ningdatech.basic.model.IdVo; -import com.ningdatech.basic.model.PageVo; -import com.ningdatech.kqapi.admin.manage.WindowManage; -import com.ningdatech.kqapi.admin.model.req.ListWindowReq; -import com.ningdatech.kqapi.admin.model.req.WindowSaveReq; -import com.ningdatech.kqapi.admin.model.vo.WindowDetailVO; -import com.ningdatech.log.annotation.WebLog; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import lombok.AllArgsConstructor; -import org.springframework.web.bind.annotation.*; - -import javax.validation.Valid; -import java.util.List; - -/** - *

- * 前端控制器 - *

- * - * @author WendyYang - * @since 2024-04-20 - */ -@Api(tags = "窗口管理") -@RestController -@AllArgsConstructor -@RequestMapping("/api/v1/window") -public class WindowController { - - private final WindowManage windowManage; - - @PostMapping("/save") - @WebLog("窗口新增或修改") - @ApiOperation("窗口新增或修改") - public void saveOrUpdate(@RequestBody @Valid WindowSaveReq req) { - windowManage.windowSaveOrUpdate(req); - } - - @DeleteMapping("/del") - @WebLog("窗口删除") - @ApiOperation("窗口删除") - public void delete(@RequestBody IdVo id) { - windowManage.delete(id); - } - - @GetMapping("/page") - @WebLog("窗口列表") - @ApiOperation("窗口列表") - public PageVo page(ListWindowReq req) { - return windowManage.pageWindow(req); - } - - @GetMapping("/option") - @WebLog("窗口下拉选择") - @ApiOperation("窗口下拉选择") - public List option(ListWindowReq req) { - return windowManage.windowOption(req); - } - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/admin/controller/ZoneController.java b/kqapi/src/main/java/com/ningdatech/kqapi/admin/controller/ZoneController.java deleted file mode 100644 index ba0eda8..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/admin/controller/ZoneController.java +++ /dev/null @@ -1,63 +0,0 @@ -package com.ningdatech.kqapi.admin.controller; - - -import com.ningdatech.basic.model.IdVo; -import com.ningdatech.basic.model.PageVo; -import com.ningdatech.kqapi.admin.manage.ZoneManage; -import com.ningdatech.kqapi.admin.model.req.ListZoneReq; -import com.ningdatech.kqapi.admin.model.req.ZoneSaveReq; -import com.ningdatech.kqapi.admin.model.vo.ZoneDetailVO; -import com.ningdatech.log.annotation.WebLog; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import lombok.AllArgsConstructor; -import org.springframework.web.bind.annotation.*; - -import javax.validation.Valid; -import java.util.List; - -/** - *

- * 前端控制器 - *

- * - * @author WendyYang - * @since 2024-04-20 - */ -@Api(tags = "专区管理") -@RestController -@AllArgsConstructor -@RequestMapping("/api/v1/zone") -public class ZoneController { - - private final ZoneManage zoneManage; - - @PostMapping("/save") - @WebLog("专区保存或修改") - @ApiOperation("专区保存或修改") - public void zoneSaveOrUpdate(@RequestBody @Valid ZoneSaveReq req) { - zoneManage.zoneSaveOrUpdate(req); - } - - @DeleteMapping("/del") - @WebLog("专区删除") - @ApiOperation("专区删除") - public void delete(@RequestBody IdVo id) { - zoneManage.delete(id); - } - - @GetMapping("/page") - @WebLog("专区列表") - @ApiOperation("专区列表") - public PageVo pageZone(ListZoneReq req) { - return zoneManage.pageZone(req); - } - - @GetMapping("/option") - @WebLog("专区下拉选择") - @ApiOperation("专区下拉选择") - public List zoneOption(ListZoneReq req) { - return zoneManage.zoneOption(req); - } - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/admin/manage/AdminMatterManage.java b/kqapi/src/main/java/com/ningdatech/kqapi/admin/manage/AdminMatterManage.java deleted file mode 100644 index 973c0f7..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/admin/manage/AdminMatterManage.java +++ /dev/null @@ -1,121 +0,0 @@ -package com.ningdatech.kqapi.admin.manage; - -import cn.hutool.core.util.StrUtil; -import com.baomidou.mybatisplus.core.conditions.Wrapper; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.ningdatech.basic.model.IdVo; -import com.ningdatech.basic.model.PageVo; -import com.ningdatech.basic.util.CollUtils; -import com.ningdatech.kqapi.admin.model.req.MatterListReq; -import com.ningdatech.kqapi.admin.model.vo.MatterDetailDTO; -import com.ningdatech.kqapi.admin.model.vo.MatterListVO; -import com.ningdatech.kqapi.zzsfw.model.entity.KqZzsfwMenu; -import com.ningdatech.kqapi.zzsfw.service.IKqZzsfwMenuService; -import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Component; - -import java.util.List; - -/** - *

- * MatterManage - *

- * - * @author WendyYang - * @since 15:41 2024/4/20 - */ -@Component -@RequiredArgsConstructor -public class AdminMatterManage { - - private final IKqZzsfwMenuService zzsfwMenuService; - - public PageVo pageMatter(MatterListReq req) { - Wrapper query = Wrappers.lambdaQuery(KqZzsfwMenu.class) - .like(StrUtil.isNotBlank(req.getMatterName()), KqZzsfwMenu::getItemName, req.getMatterName()) - .eq(req.getZoneId() != null, KqZzsfwMenu::getZoneId, req.getZoneId()) - .eq(req.getWindowId() != null, KqZzsfwMenu::getWindowId, req.getWindowId()) - .eq(req.getMatterType() != null, KqZzsfwMenu::getType, req.getMatterType()) - .eq(req.getDepartment() != null, KqZzsfwMenu::getDepartment, req.getDepartment()) - .orderByDesc(KqZzsfwMenu::getCreateOn); - Page page = zzsfwMenuService.page(req.page(), query); - if (page.getTotal() == 0) { - return PageVo.empty(); - } - List data = CollUtils.convert(page.getRecords(), - w -> MatterListVO.builder() - .matterName(w.getItemName()) - .matterType(w.getType()) - .department(w.getDepartment()) - .zoneName(w.getZoneName()) - .windowName(w.getWindow()) - .build()); - return PageVo.of(data, page.getTotal()); - } - - public void del(IdVo id) { - zzsfwMenuService.removeById(id.getId()); - } - - public MatterDetailDTO detail(Long id) { - KqZzsfwMenu matter = zzsfwMenuService.getById(id); - if (matter == null) { - return null; - } - return MatterDetailDTO.builder() - .id(matter.getId()) - .free(matter.getFree()) - .onlinePay(matter.getOnlinePay()) - .hasUrl(matter.getHasUrl()) - .matterType(matter.getType()) - .matterName(matter.getItemName()) - .department(matter.getDepartment()) - .handleAddress(matter.getHandleAddress()) - .handleChannel(matter.getHandleChannel()) - .handleTime(matter.getHandleTime()) - .implSubjectNature(matter.getImplSubjectNature()) - .publicityMaterials(matter.getPublicityMaterials()) - .sceneDesc(matter.getSceneDesc()) - .serviceContent(matter.getServiceContent()) - .serviceObject(matter.getServiceObject()) - .serviceProcess(matter.getServiceProcess()) - .sort(matter.getSort()) - .telephone(matter.getTelephone()) - .window(matter.getWindow()) - .windowId(matter.getWindowId()) - .zoneId(matter.getZoneId()) - .zoneName(matter.getZoneName()) - .webApplyUrl(matter.getWebapplyurl()) - .build(); - } - - public void saveOrUpdate(MatterDetailDTO req) { - KqZzsfwMenu matter = new KqZzsfwMenu(); - matter.setId(req.getId()); - matter.setFree(req.getFree()); - matter.setOnlinePay(req.getOnlinePay()); - matter.setHasUrl(req.getHasUrl()); - matter.setType(req.getMatterType()); - matter.setItemName(req.getMatterName()); - matter.setDepartment(req.getDepartment()); - matter.setHandleAddress(req.getHandleAddress()); - matter.setHandleChannel(req.getHandleChannel()); - matter.setHandleTime(req.getHandleTime()); - matter.setImplSubjectNature(req.getImplSubjectNature()); - matter.setPublicityMaterials(req.getPublicityMaterials()); - matter.setSceneDesc(req.getSceneDesc()); - matter.setServiceContent(req.getServiceContent()); - matter.setServiceObject(req.getServiceObject()); - matter.setServiceProcess(req.getServiceProcess()); - matter.setSort(req.getSort()); - matter.setTelephone(req.getTelephone()); - matter.setWindow(req.getWindow()); - matter.setWindowId(req.getWindowId()); - matter.setZoneId(req.getZoneId()); - matter.setZoneName(req.getZoneName()); - matter.setWebapplyurl(req.getWebApplyUrl()); - zzsfwMenuService.saveOrUpdate(matter); - } - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/admin/manage/WindowManage.java b/kqapi/src/main/java/com/ningdatech/kqapi/admin/manage/WindowManage.java deleted file mode 100644 index 6cb9508..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/admin/manage/WindowManage.java +++ /dev/null @@ -1,83 +0,0 @@ -package com.ningdatech.kqapi.admin.manage; - -import cn.hutool.core.bean.BeanUtil; -import cn.hutool.core.util.StrUtil; -import com.baomidou.mybatisplus.core.conditions.Wrapper; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.ningdatech.basic.model.IdVo; -import com.ningdatech.basic.model.PageVo; -import com.ningdatech.basic.util.CollUtils; -import com.ningdatech.kqapi.admin.model.entity.Window; -import com.ningdatech.kqapi.admin.model.req.ListWindowReq; -import com.ningdatech.kqapi.admin.model.req.WindowSaveReq; -import com.ningdatech.kqapi.admin.model.vo.WindowDetailVO; -import com.ningdatech.kqapi.admin.service.IWindowService; -import com.ningdatech.kqapi.zzsfw.service.IKqZzsfwMenuService; -import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Component; - -import java.util.*; -import java.util.stream.Collectors; - -/** - *

- * WindowManage - *

- * - * @author WendyYang - * @since 12:17 2024/4/20 - */ -@Component -@RequiredArgsConstructor -public class WindowManage { - - private final IWindowService windowService; - private final IKqZzsfwMenuService zzsfwMenuService; - - public void windowSaveOrUpdate(WindowSaveReq req) { - Window win = BeanUtil.copyProperties(req, Window.class); - windowService.saveOrUpdate(win); - } - - public void delete(IdVo id) { - windowService.removeById(id.getId()); - } - - public PageVo pageWindow(ListWindowReq req) { - Wrapper query = buildWindowQuery(req); - Page page = windowService.page(req.page(), query); - if (page.getTotal() == 0) { - return PageVo.empty(); - } - List records = page.getRecords(); - List windowIds = CollUtils.fieldList(records, Window::getId); - Map matterCountMap = zzsfwMenuService.matterCountByWindowIds(windowIds); - List data = records.stream().map(w -> { - WindowDetailVO window = BeanUtil.copyProperties(w, WindowDetailVO.class); - window.setItemCount(matterCountMap.getOrDefault(w.getId(), 0)); - return window; - }).collect(Collectors.toList()); - return PageVo.of(data, page.getTotal()); - } - - public List windowOption(ListWindowReq req) { - Wrapper query = buildWindowQuery(req); - Page page = windowService.page(req.page(), query); - if (page.getTotal() == 0) { - return Collections.emptyList(); - } - return page.getRecords().stream().map(w -> WindowDetailVO.builder() - .windowName(w.getWindowName()) - .id(w.getId()) - .build()).collect(Collectors.toList()); - } - - private static Wrapper buildWindowQuery(ListWindowReq req) { - return Wrappers.lambdaQuery(Window.class) - .like(StrUtil.isNotBlank(req.getWindowName()), Window::getWindowName, req.getWindowName()) - .eq(req.getZoneId() != null, Window::getZoneId, req.getZoneId()) - .orderByDesc(Window::getUpdateOn); - } - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/admin/manage/ZoneManage.java b/kqapi/src/main/java/com/ningdatech/kqapi/admin/manage/ZoneManage.java deleted file mode 100644 index 4be4204..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/admin/manage/ZoneManage.java +++ /dev/null @@ -1,102 +0,0 @@ -package com.ningdatech.kqapi.admin.manage; - -import cn.hutool.core.bean.BeanUtil; -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.StrUtil; -import com.baomidou.mybatisplus.core.conditions.Wrapper; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.ningdatech.basic.model.IdVo; -import com.ningdatech.basic.model.PageVo; -import com.ningdatech.basic.util.CollUtils; -import com.ningdatech.kqapi.admin.mapper.ZoneMapper; -import com.ningdatech.kqapi.admin.model.entity.Window; -import com.ningdatech.kqapi.admin.model.entity.Zone; -import com.ningdatech.kqapi.admin.model.req.ListZoneReq; -import com.ningdatech.kqapi.admin.model.req.ZoneSaveReq; -import com.ningdatech.kqapi.admin.model.vo.ZoneDetailVO; -import com.ningdatech.kqapi.admin.service.IWindowService; -import com.ningdatech.kqapi.admin.service.IZoneService; -import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Component; -import org.springframework.transaction.annotation.Transactional; - -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -/** - *

- * ZoneManage - *

- * - * @author WendyYang - * @since 12:17 2024/4/20 - */ -@Component -@RequiredArgsConstructor -public class ZoneManage { - - private final IZoneService zoneService; - private final ZoneMapper zoneMapper; - private final IWindowService windowService; - - @Transactional(rollbackFor = Exception.class) - public synchronized void zoneSaveOrUpdate(ZoneSaveReq req) { - Zone zone = BeanUtil.copyProperties(req, Zone.class); - if (zone.getId() != null) { - Zone oldZone = zoneService.getById(req.getId()); - if (!StrUtil.equals(zone.getZoneName(), oldZone.getZoneName())) { - Wrapper wUpdate = Wrappers.lambdaUpdate(Window.class) - .set(Window::getZoneName, req.getZoneName()) - .eq(Window::getZoneId, req.getId()); - windowService.update(wUpdate); - } - } - zoneService.saveOrUpdate(zone); - } - - - public void delete(IdVo id) { - zoneService.removeById(id.getId()); - } - - public PageVo pageZone(ListZoneReq req) { - Wrapper query = buildZoneQuery(req); - Page page = zoneService.page(req.page(), query); - if (page.getTotal() == 0) { - return PageVo.empty(); - } - List records = page.getRecords(); - List zoneIds = CollUtils.fieldList(records, Zone::getId); - Map windowCountMap = windowService.windowCountByZoneIds(zoneIds); - List data = records.stream().map(w -> { - ZoneDetailVO zone = BeanUtil.copyProperties(w, ZoneDetailVO.class); - zone.setWindowCount(windowCountMap.getOrDefault(w.getId(), 0)); - return zone; - }).collect(Collectors.toList()); - return PageVo.of(data, page.getTotal()); - } - - public List zoneOption(ListZoneReq req) { - Wrapper query = buildZoneQuery(req); - Page page = zoneService.page(req.page(), query); - if (page.getTotal() == 0) { - return Collections.emptyList(); - } - return CollUtils.convert(page.getRecords(), - w -> ZoneDetailVO.builder() - .id(w.getId()) - .zoneName(w.getZoneName()) - .build()); - } - - private static Wrapper buildZoneQuery(ListZoneReq req) { - return Wrappers.lambdaQuery(Zone.class) - .like(StrUtil.isNotBlank(req.getZoneName()), Zone::getZoneName, req.getZoneName()) - .orderByDesc(Zone::getUpdateOn); - } - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/admin/mapper/WindowMapper.java b/kqapi/src/main/java/com/ningdatech/kqapi/admin/mapper/WindowMapper.java deleted file mode 100644 index 5831b18..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/admin/mapper/WindowMapper.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.ningdatech.kqapi.admin.mapper; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.ningdatech.kqapi.admin.model.dto.WindowCountByZoneIdDTO; -import com.ningdatech.kqapi.admin.model.entity.Window; -import org.apache.ibatis.annotations.Param; - -import java.util.Collection; -import java.util.List; - -/** - *

- * Mapper 接口 - *

- * - * @author WendyYang - * @since 2024-04-20 - */ -public interface WindowMapper extends BaseMapper { - - List selectWindowCountByZoneIds(@Param("zoneIds") Collection zoneIds); - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/admin/mapper/WindowMapper.xml b/kqapi/src/main/java/com/ningdatech/kqapi/admin/mapper/WindowMapper.xml deleted file mode 100644 index 93aef87..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/admin/mapper/WindowMapper.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/admin/mapper/ZoneMapper.java b/kqapi/src/main/java/com/ningdatech/kqapi/admin/mapper/ZoneMapper.java deleted file mode 100644 index 3f08445..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/admin/mapper/ZoneMapper.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.ningdatech.kqapi.admin.mapper; - -import com.ningdatech.kqapi.admin.model.entity.Zone; -import com.baomidou.mybatisplus.core.mapper.BaseMapper; - -/** - *

- * Mapper 接口 - *

- * - * @author WendyYang - * @since 2024-04-20 - */ -public interface ZoneMapper extends BaseMapper { - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/admin/mapper/ZoneMapper.xml b/kqapi/src/main/java/com/ningdatech/kqapi/admin/mapper/ZoneMapper.xml deleted file mode 100644 index 752a645..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/admin/mapper/ZoneMapper.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/admin/model/dto/MatterCountByWindowIdDTO.java b/kqapi/src/main/java/com/ningdatech/kqapi/admin/model/dto/MatterCountByWindowIdDTO.java deleted file mode 100644 index fd16538..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/admin/model/dto/MatterCountByWindowIdDTO.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.ningdatech.kqapi.admin.model.dto; - -import lombok.Data; - -/** - *

- * WindowCountByZoneIdDTO - *

- * - * @author WendyYang - * @since 14:14 2024/4/20 - */ -@Data -public class MatterCountByWindowIdDTO { - - private Integer windowId; - - private Integer matterCount; - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/admin/model/dto/WindowCountByZoneIdDTO.java b/kqapi/src/main/java/com/ningdatech/kqapi/admin/model/dto/WindowCountByZoneIdDTO.java deleted file mode 100644 index 0abf7a0..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/admin/model/dto/WindowCountByZoneIdDTO.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.ningdatech.kqapi.admin.model.dto; - -import lombok.Data; - -/** - *

- * WindowCountByZoneIdDTO - *

- * - * @author WendyYang - * @since 14:14 2024/4/20 - */ -@Data -public class WindowCountByZoneIdDTO { - - private Integer zoneId; - - private Integer windowCount; - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/admin/model/entity/Window.java b/kqapi/src/main/java/com/ningdatech/kqapi/admin/model/entity/Window.java deleted file mode 100644 index 5f78af7..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/admin/model/entity/Window.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.ningdatech.kqapi.admin.model.entity; - -import com.baomidou.mybatisplus.annotation.*; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -import java.io.Serializable; -import java.time.LocalDateTime; - -/** - *

- * 窗口对象 - *

- * - * @author WendyYang - * @since 2024-04-20 - */ -@Data -@TableName("nd_window") -@ApiModel(value = "Window对象") -public class Window implements Serializable { - - private static final long serialVersionUID = 1L; - - @ApiModelProperty("主键") - @TableId(value = "id", type = IdType.AUTO) - private Integer id; - - @ApiModelProperty("窗口名称") - private String windowName; - - @ApiModelProperty("专区ID") - private Integer zoneId; - - @ApiModelProperty("专区名称") - private String zoneName; - - @TableLogic - private Boolean deleted; - - @TableField(fill = FieldFill.INSERT) - private LocalDateTime createOn; - - @TableField(fill = FieldFill.INSERT) - private Long createBy; - - @TableField(fill = FieldFill.INSERT_UPDATE) - private LocalDateTime updateOn; - - @TableField(fill = FieldFill.INSERT_UPDATE) - private Long updateBy; - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/admin/model/entity/Zone.java b/kqapi/src/main/java/com/ningdatech/kqapi/admin/model/entity/Zone.java deleted file mode 100644 index a5adbed..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/admin/model/entity/Zone.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.ningdatech.kqapi.admin.model.entity; - -import com.baomidou.mybatisplus.annotation.*; - -import java.io.Serializable; -import java.time.LocalDateTime; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -/** - *

- * 专区对象 - *

- * - * @author WendyYang - * @since 2024-04-20 - */ -@Data -@TableName("nd_zone") -@ApiModel(value = "Zone对象") -public class Zone implements Serializable { - - private static final long serialVersionUID = 1L; - - @ApiModelProperty("主键") - @TableId(value = "id", type = IdType.AUTO) - private Integer id; - - @ApiModelProperty("专区名称") - private String zoneName; - - @ApiModelProperty("专区图标") - private String zoneIcon; - - @TableLogic - private Boolean deleted; - - @TableField(fill = FieldFill.INSERT) - private LocalDateTime createOn; - - @TableField(fill = FieldFill.INSERT) - private Long createBy; - - @TableField(fill = FieldFill.INSERT_UPDATE) - private LocalDateTime updateOn; - - @TableField(fill = FieldFill.INSERT_UPDATE) - private Long updateBy; - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/admin/model/enumerization/HandleChannelEnum.java b/kqapi/src/main/java/com/ningdatech/kqapi/admin/model/enumerization/HandleChannelEnum.java deleted file mode 100644 index a450227..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/admin/model/enumerization/HandleChannelEnum.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.ningdatech.kqapi.admin.model.enumerization; - -import com.ningdatech.kqapi.common.enumeration.IEnum; -import lombok.AllArgsConstructor; -import lombok.Getter; - -/** - *

- * HandleChannelEnum - *

- * - * @author WendyYang - * @since 10:09 2024/4/22 - */ -@Getter -@AllArgsConstructor -public enum HandleChannelEnum implements IEnum { - - HANDLE_ON_WINDOW(1, "现场窗口申请"), - HANDLE_ON_NETWORK(2, "全程网办"); - - private final Integer code; - private final String desc; - - @Override - public HandleChannelEnum[] all() { - return values(); - } - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/admin/model/req/ListWindowReq.java b/kqapi/src/main/java/com/ningdatech/kqapi/admin/model/req/ListWindowReq.java deleted file mode 100644 index 05be92b..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/admin/model/req/ListWindowReq.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.ningdatech.kqapi.admin.model.req; - -import com.ningdatech.kqapi.common.model.PagePo; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; -import lombok.EqualsAndHashCode; - -/** - *

- * WindowSaveReq - *

- * - * @author WendyYang - * @since 13:25 2024/4/20 - */ -@Data -@EqualsAndHashCode(callSuper = true) -public class ListWindowReq extends PagePo { - - @ApiModelProperty("专区ID") - private Integer zoneId; - - @ApiModelProperty("窗口名称") - private String windowName; - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/admin/model/req/ListZoneReq.java b/kqapi/src/main/java/com/ningdatech/kqapi/admin/model/req/ListZoneReq.java deleted file mode 100644 index 43c2b11..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/admin/model/req/ListZoneReq.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.ningdatech.kqapi.admin.model.req; - -import com.ningdatech.kqapi.common.model.PagePo; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; -import lombok.EqualsAndHashCode; - -/** - *

- * ListZoneReq - *

- * - * @author WendyYang - * @since 13:25 2024/4/20 - */ -@Data -@EqualsAndHashCode(callSuper = true) -public class ListZoneReq extends PagePo { - - @ApiModelProperty("专区名称") - private String zoneName; - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/admin/model/req/MatterListReq.java b/kqapi/src/main/java/com/ningdatech/kqapi/admin/model/req/MatterListReq.java deleted file mode 100644 index 3489f9f..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/admin/model/req/MatterListReq.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.ningdatech.kqapi.admin.model.req; - -import com.ningdatech.kqapi.common.model.PagePo; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; -import lombok.EqualsAndHashCode; - -/** - *

- * MatterListReq - *

- * - * @author WendyYang - * @since 15:52 2024/4/20 - */ -@Data -@EqualsAndHashCode(callSuper = true) -public class MatterListReq extends PagePo { - - @ApiModelProperty("部门") - private String department; - - @ApiModelProperty("事项名称") - private String matterName; - - @ApiModelProperty("服务类型") - private Integer matterType; - - @ApiModelProperty("专区ID") - private Integer zoneId; - - @ApiModelProperty("窗口ID") - private Integer windowId; - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/admin/model/req/WindowSaveReq.java b/kqapi/src/main/java/com/ningdatech/kqapi/admin/model/req/WindowSaveReq.java deleted file mode 100644 index 24d011b..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/admin/model/req/WindowSaveReq.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.ningdatech.kqapi.admin.model.req; - -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; - -/** - *

- * WindowSaveReq - *

- * - * @author WendyYang - * @since 13:25 2024/4/20 - */ -@Data -public class WindowSaveReq { - - @ApiModelProperty("窗口ID") - private Integer id; - - @ApiModelProperty("专区ID") - @NotNull(message = "专区ID不能为空") - private Integer zoneId; - - @ApiModelProperty("专区名称") - @NotBlank(message = "专区名称不能为空") - private String zoneName; - - @ApiModelProperty("窗口名称") - @NotBlank(message = "窗口名称不能为空") - private String windowName; - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/admin/model/req/ZoneSaveReq.java b/kqapi/src/main/java/com/ningdatech/kqapi/admin/model/req/ZoneSaveReq.java deleted file mode 100644 index c43ab01..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/admin/model/req/ZoneSaveReq.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.ningdatech.kqapi.admin.model.req; - -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -import javax.validation.constraints.NotBlank; - -/** - *

- * ZoneSaveReq - *

- * - * @author WendyYang - * @since 13:25 2024/4/20 - */ -@Data -public class ZoneSaveReq { - - @ApiModelProperty("专区ID") - private Integer id; - - @ApiModelProperty("专区名称") - @NotBlank(message = "专区名称不能为空") - private String zoneName; - - @ApiModelProperty("专区图标") - @NotBlank(message = "专区图标不能为空") - private String zoneIcon; - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/admin/model/vo/MatterDetailDTO.java b/kqapi/src/main/java/com/ningdatech/kqapi/admin/model/vo/MatterDetailDTO.java deleted file mode 100644 index f7ec9d1..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/admin/model/vo/MatterDetailDTO.java +++ /dev/null @@ -1,95 +0,0 @@ -package com.ningdatech.kqapi.admin.model.vo; - -import io.swagger.annotations.ApiModelProperty; -import lombok.Builder; -import lombok.Data; - -import java.time.LocalDateTime; - -/** - *

- * MatterDetailVO - *

- * - * @author WendyYang - * @since 15:48 2024/4/20 - */ -@Data -@Builder -public class MatterDetailDTO { - - private Long id; - - @ApiModelProperty("事项名称") - private String matterName; - - @ApiModelProperty("专区名称") - private String zoneName; - - @ApiModelProperty("专区ID") - private Integer zoneId; - - @ApiModelProperty("窗口ID") - private Integer windowId; - - @ApiModelProperty("窗口名称") - private String windowName; - - @ApiModelProperty("部门") - private String department; - - @ApiModelProperty("事项类型") - private Integer matterType; - - @ApiModelProperty("事项链接") - private String webApplyUrl; - - @ApiModelProperty("窗口") - private String window; - - @ApiModelProperty("排序") - private Integer sort; - - @ApiModelProperty("是否在政务中心查到url") - private Integer hasUrl; - - @ApiModelProperty("服务内容") - private String serviceContent; - - @ApiModelProperty("服务流程") - private String serviceProcess; - - @ApiModelProperty("咨询电话") - private String telephone; - - @ApiModelProperty("服务对象") - private String serviceObject; - - @ApiModelProperty("是否免费") - private Boolean free; - - @ApiModelProperty("是否网上缴费") - private Boolean onlinePay; - - @ApiModelProperty("办理渠道") - private Integer handleChannel; - - @ApiModelProperty("办理地点") - private String handleAddress; - - @ApiModelProperty("办理时间") - private String handleTime; - - @ApiModelProperty("行使层级") - private String exerciseLevel; - - @ApiModelProperty("实施主体性质") - private Integer implSubjectNature; - - @ApiModelProperty("特色场景描述") - private String sceneDesc; - - @ApiModelProperty("宣传资料") - private String publicityMaterials; - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/admin/model/vo/MatterListVO.java b/kqapi/src/main/java/com/ningdatech/kqapi/admin/model/vo/MatterListVO.java deleted file mode 100644 index 3289663..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/admin/model/vo/MatterListVO.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.ningdatech.kqapi.admin.model.vo; - -import io.swagger.annotations.ApiModelProperty; -import lombok.Builder; -import lombok.Data; - -/** - *

- * MatterListVO - *

- * - * @author WendyYang - * @since 15:48 2024/4/20 - */ -@Data -@Builder -public class MatterListVO { - - @ApiModelProperty("事项名称") - private String matterName; - - @ApiModelProperty("专区名称") - private String zoneName; - - @ApiModelProperty("窗口名称") - private String windowName; - - @ApiModelProperty("部门") - private String department; - - @ApiModelProperty("事项类型") - private Integer matterType; - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/admin/model/vo/WindowDetailVO.java b/kqapi/src/main/java/com/ningdatech/kqapi/admin/model/vo/WindowDetailVO.java deleted file mode 100644 index 0bf29f5..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/admin/model/vo/WindowDetailVO.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.ningdatech.kqapi.admin.model.vo; - -import io.swagger.annotations.ApiModelProperty; -import lombok.Builder; -import lombok.Data; - -/** - *

- * WindowDetailVO - *

- * - * @author WendyYang - * @since 13:47 2024/4/20 - */ -@Builder -@Data -public class WindowDetailVO { - - @ApiModelProperty("窗口ID") - private Integer id; - - @ApiModelProperty("窗口名称") - private String windowName; - - @ApiModelProperty("专区ID") - private Integer zoneId; - - @ApiModelProperty("专区名称") - private String zoneName; - - @ApiModelProperty("事项数量") - private Integer itemCount; - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/admin/model/vo/ZoneDetailVO.java b/kqapi/src/main/java/com/ningdatech/kqapi/admin/model/vo/ZoneDetailVO.java deleted file mode 100644 index 011bcd8..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/admin/model/vo/ZoneDetailVO.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.ningdatech.kqapi.admin.model.vo; - -import io.swagger.annotations.ApiModelProperty; -import lombok.Builder; -import lombok.Data; - -/** - *

- * ZoneDetailVO - *

- * - * @author WendyYang - * @since 13:48 2024/4/20 - */ -@Data -@Builder -public class ZoneDetailVO { - - @ApiModelProperty("专区ID") - private Integer id; - - @ApiModelProperty("专区名称") - private String zoneName; - - @ApiModelProperty("专区图标") - private String zoneIcon; - - @ApiModelProperty("窗口数量") - private Integer windowCount; - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/admin/service/IWindowService.java b/kqapi/src/main/java/com/ningdatech/kqapi/admin/service/IWindowService.java deleted file mode 100644 index 65a10a1..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/admin/service/IWindowService.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.ningdatech.kqapi.admin.service; - -import com.baomidou.mybatisplus.extension.service.IService; -import com.ningdatech.kqapi.admin.model.entity.Window; - -import java.util.Collection; -import java.util.Map; - -/** - *

- * 服务类 - *

- * - * @author WendyYang - * @since 2024-04-20 - */ -public interface IWindowService extends IService { - - Map windowCountByZoneIds(Collection zoneIds); - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/admin/service/IZoneService.java b/kqapi/src/main/java/com/ningdatech/kqapi/admin/service/IZoneService.java deleted file mode 100644 index 17644a5..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/admin/service/IZoneService.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.ningdatech.kqapi.admin.service; - -import com.ningdatech.kqapi.admin.model.entity.Zone; -import com.baomidou.mybatisplus.extension.service.IService; - -/** - *

- * 服务类 - *

- * - * @author WendyYang - * @since 2024-04-20 - */ -public interface IZoneService extends IService { - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/admin/service/impl/WindowServiceImpl.java b/kqapi/src/main/java/com/ningdatech/kqapi/admin/service/impl/WindowServiceImpl.java deleted file mode 100644 index f8d5746..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/admin/service/impl/WindowServiceImpl.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.ningdatech.kqapi.admin.service.impl; - -import cn.hutool.core.collection.CollUtil; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.ningdatech.basic.util.CollUtils; -import com.ningdatech.kqapi.admin.mapper.WindowMapper; -import com.ningdatech.kqapi.admin.model.dto.WindowCountByZoneIdDTO; -import com.ningdatech.kqapi.admin.model.entity.Window; -import com.ningdatech.kqapi.admin.service.IWindowService; -import org.springframework.stereotype.Service; - -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -/** - *

- * 服务实现类 - *

- * - * @author WendyYang - * @since 2024-04-20 - */ -@Service -public class WindowServiceImpl extends ServiceImpl implements IWindowService { - - @Override - public Map windowCountByZoneIds(Collection zoneIds) { - if (CollUtil.isEmpty(zoneIds)) { - return Collections.emptyMap(); - } - List counts = baseMapper.selectWindowCountByZoneIds(zoneIds); - return CollUtils.listToMap(counts, WindowCountByZoneIdDTO::getZoneId, - WindowCountByZoneIdDTO::getWindowCount); - } - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/admin/service/impl/ZoneServiceImpl.java b/kqapi/src/main/java/com/ningdatech/kqapi/admin/service/impl/ZoneServiceImpl.java deleted file mode 100644 index ef69a5e..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/admin/service/impl/ZoneServiceImpl.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.ningdatech.kqapi.admin.service.impl; - -import com.ningdatech.kqapi.admin.model.entity.Zone; -import com.ningdatech.kqapi.admin.mapper.ZoneMapper; -import com.ningdatech.kqapi.admin.service.IZoneService; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import org.springframework.stereotype.Service; - -/** - *

- * 服务实现类 - *

- * - * @author WendyYang - * @since 2024-04-20 - */ -@Service -public class ZoneServiceImpl extends ServiceImpl implements IZoneService { - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/common/compare/Compare.java b/kqapi/src/main/java/com/ningdatech/kqapi/common/compare/Compare.java deleted file mode 100644 index d42f28c..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/common/compare/Compare.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.ningdatech.kqapi.common.compare; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * 字段标记注解 - * - * @author zpf - * @since 2023/07/21 - */ -@Target(ElementType.FIELD) -@Retention(RetentionPolicy.RUNTIME) -public @interface Compare { - - /** - * 字段名称 - */ - String value(); -} \ No newline at end of file diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/common/compare/CompareNode.java b/kqapi/src/main/java/com/ningdatech/kqapi/common/compare/CompareNode.java deleted file mode 100644 index f763601..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/common/compare/CompareNode.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.ningdatech.kqapi.common.compare; - -/** - * @author zpf - * @since 2023/07/21 - */ -public class CompareNode { - - /** - * 字段 - */ - private String fieldKey; - - /** - * 字段值 - */ - private Object fieldValue; - - /** - * 字段名称 - */ - private String fieldName; - - public String getFieldKey() { - return fieldKey; - } - - public void setFieldKey(String fieldKey) { - this.fieldKey = fieldKey; - } - - public Object getFieldValue() { - return fieldValue; - } - - public void setFieldValue(Object fieldValue) { - this.fieldValue = fieldValue; - } - - public String getFieldName() { - return fieldName; - } - - public void setFieldName(String fieldName) { - this.fieldName = fieldName; - } -} \ No newline at end of file diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/common/compare/CompareUtils.java b/kqapi/src/main/java/com/ningdatech/kqapi/common/compare/CompareUtils.java deleted file mode 100644 index 344e118..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/common/compare/CompareUtils.java +++ /dev/null @@ -1,182 +0,0 @@ -package com.ningdatech.kqapi.common.compare; - -import com.alibaba.fastjson.JSONObject; - -import java.lang.reflect.Field; -import java.util.*; - -/** - * 使用须知:
- * (1)该工具类主要用于两个同类对象的属性值比较;
- * (2)使用本工具类前,请将对应的类属性上打上 @Compare("xxx") 注解,其中xxx为字段的表达名称;
- * (3)为了比较灵活,只有打了该注解才会进行比较,不打的字段则不会进行比较
- * (4)比较后,只会返回有变化的字段,无变化的字符则不返回
- * - * @author zpf - * @since 2023/07/21 - */ -public class CompareUtils { - - private static final String COMMA = ","; - - /** - * 属性比较 - * - * @param source 源数据对象 - * @param target 目标数据对象 - * @return 对应属性值的比较变化 - */ - public String compare(T source, T target) { - return compare(source, target, null); - } - - - /** - * 属性比较 - * - * @param source 源数据对象 - * @param target 目标数据对象 - * @param ignoreCompareFields 忽略比较的字段 - * @return 对应属性值的比较变化 - */ - public String compare(T source, T target, List ignoreCompareFields) { - if (Objects.isNull(source) && Objects.isNull(target)) { - return ""; - } - Map sourceMap = this.getFiledValueMap(source); - Map targetMap = this.getFiledValueMap(target); - if (sourceMap.isEmpty() && targetMap.isEmpty()) { - return ""; - } - // 如果源数据为空,则只显示目标数据,不显示属性变化情况 - if (sourceMap.isEmpty()) { - return doEmpty(targetMap, ignoreCompareFields); - } - // 如果源数据为空,则显示属性变化情况 - String s = doCompare(sourceMap, targetMap, ignoreCompareFields); - if (!s.endsWith(COMMA)) { - return s; - } - return s.substring(0, s.length() - 1); - } - - public JSONObject compareToJson(T source, T target, List ignoreCompareFields) { - JSONObject res = new JSONObject(); - if (Objects.isNull(source) && Objects.isNull(target)) { - return res; - } - Map sourceMap = this.getFiledValueMap(source); - Map targetMap = this.getFiledValueMap(target); - if (sourceMap.isEmpty() && targetMap.isEmpty()) { - return res; - } - // 如果源数据为空,则只显示目标数据,不显示属性变化情况 - if (sourceMap.isEmpty()) { - return res; - } - - return doCompareJson(sourceMap, targetMap, ignoreCompareFields); - } - - private String doEmpty(Map targetMap, List ignoreCompareFields) { - StringBuilder sb = new StringBuilder(); - Collection values = targetMap.values(); - int size = values.size(); - int current = 0; - for (CompareNode node : values) { - current++; - Object o = Optional.ofNullable(node.getFieldValue()).orElse(""); - if (Objects.nonNull(ignoreCompareFields) && ignoreCompareFields.contains(node.getFieldKey())) { - continue; - } - if (o.toString().length() > 0) { - sb.append("[" + node.getFieldName() + ":" + o + "]"); - if (current < size) { - sb.append(COMMA); - } - } - } - return sb.toString(); - } - - private String doCompare(Map sourceMap, Map targetMap, List ignoreCompareFields) { - StringBuilder sb = new StringBuilder(); - Set keys = sourceMap.keySet(); - int size = keys.size(); - int current = 0; - for (String key : keys) { - current++; - CompareNode sn = sourceMap.get(key); - CompareNode tn = targetMap.get(key); - if (Objects.nonNull(ignoreCompareFields) && ignoreCompareFields.contains(sn.getFieldKey())) { - continue; - } - String sv = Optional.ofNullable(sn.getFieldValue()).orElse("").toString(); - String tv = Optional.ofNullable(tn.getFieldValue()).orElse("").toString(); - // 只有两者属性值不一致时, 才显示变化情况 - if (!sv.equals(tv)) { - sb.append(String.format("[%s:%s -> %s]", sn.getFieldName(), sv, tv)); - if (current < size) { - sb.append(COMMA); - } - } - } - return sb.toString(); - } - - private JSONObject doCompareJson(Map sourceMap, Map targetMap, List ignoreCompareFields) { - JSONObject res = new JSONObject(); - Set keys = sourceMap.keySet(); - int size = keys.size(); - int current = 0; - for (String key : keys) { - current++; - CompareNode sn = sourceMap.get(key); - CompareNode tn = targetMap.get(key); - if (Objects.nonNull(ignoreCompareFields) && ignoreCompareFields.contains(sn.getFieldKey())) { - continue; - } - String sv = Optional.ofNullable(sn.getFieldValue()).orElse("").toString(); - String tv = Optional.ofNullable(tn.getFieldValue()).orElse("").toString(); - // 只有两者属性值不一致时, 才显示变化情况 - if (!sv.equals(tv)) { - JSONObject valueChange = new JSONObject(); - valueChange.put("fieldKey",sn.getFieldKey()); - valueChange.put("old",tv); - valueChange.put("new",sv); - res.put(sn.getFieldName(),valueChange); - } - } - return res; - } - - private Map getFiledValueMap(T t) { - if (Objects.isNull(t)) { - return Collections.emptyMap(); - } - Field[] fields = t.getClass().getDeclaredFields(); - if (Objects.isNull(fields) || fields.length == 0) { - return Collections.emptyMap(); - } - Map map = new LinkedHashMap(); - for (Field field : fields) { - Compare compareAnnotation = field.getAnnotation(Compare.class); - if (Objects.isNull(compareAnnotation)) { - continue; - } - field.setAccessible(true); - try { - String fieldKey = field.getName(); - CompareNode node = new CompareNode(); - node.setFieldKey(fieldKey); - node.setFieldValue(field.get(t)); - node.setFieldName(compareAnnotation.value()); - map.put(field.getName(), node); - } catch (IllegalArgumentException | IllegalAccessException e) { - e.printStackTrace(); - } - } - return map; - } - -} \ No newline at end of file diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/common/config/BeanConfig.java b/kqapi/src/main/java/com/ningdatech/kqapi/common/config/BeanConfig.java deleted file mode 100644 index 7d5c11c..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/common/config/BeanConfig.java +++ /dev/null @@ -1,188 +0,0 @@ -package com.ningdatech.kqapi.common.config; - -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.json.JsonReadFeature; -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializationFeature; -import com.ningdatech.kqapi.common.util.NdDateUtils; -import com.ningdatech.kqapi.common.util.NdJacksonModule; -import lombok.extern.slf4j.Slf4j; -import org.apache.http.Header; -import org.apache.http.client.HttpClient; -import org.apache.http.client.config.RequestConfig; -import org.apache.http.impl.client.DefaultConnectionKeepAliveStrategy; -import org.apache.http.impl.client.DefaultHttpRequestRetryHandler; -import org.apache.http.impl.client.HttpClientBuilder; -import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; -import org.apache.http.message.BasicHeader; -import org.springframework.boot.autoconfigure.AutoConfigureBefore; -import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Primary; -import org.springframework.http.MediaType; -import org.springframework.http.client.ClientHttpRequestFactory; -import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; -import org.springframework.http.converter.HttpMessageConverter; -import org.springframework.http.converter.StringHttpMessageConverter; -import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder; -import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; -import org.springframework.web.client.RestTemplate; -import org.springframework.web.servlet.config.annotation.CorsRegistry; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; - -import java.nio.charset.StandardCharsets; -import java.text.SimpleDateFormat; -import java.time.ZoneId; -import java.util.*; -import java.util.concurrent.TimeUnit; - -/** - * @Classname BeanConfig - * @Description - * @Date 2023/3/2 9:42 - * @Created by PoffyZhang - */ -@AutoConfigureBefore(JacksonAutoConfiguration.class) -@Configuration -@Slf4j -public class BeanConfig implements WebMvcConfigurer { - - - @Bean - public RestTemplate restTemplate() { - // 添加内容转换器,使用默认的内容转换器 - RestTemplate restTemplate = new RestTemplate(httpRequestFactory()); - // 设置编码格式为UTF-8,解决中文乱码问题 - List> converterList = restTemplate.getMessageConverters(); - HttpMessageConverter converterTarget = null; - for (HttpMessageConverter item : converterList) { - if (item.getClass() == StringHttpMessageConverter.class) { - converterTarget = item; - break; - } - } - if (converterTarget != null) { - converterList.remove(converterTarget); - } - HttpMessageConverter converter = new StringHttpMessageConverter(StandardCharsets.UTF_8); - converterList.add(1, converter); - - MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter = new MappingJackson2HttpMessageConverter(); - mappingJackson2HttpMessageConverter.setSupportedMediaTypes(Arrays.asList( - MediaType.TEXT_HTML, - MediaType.TEXT_PLAIN)); - restTemplate.getMessageConverters().add(mappingJackson2HttpMessageConverter); - - log.info("-----restTemplate-----初始化完成"); - return restTemplate; - } - - @Bean - public ClientHttpRequestFactory httpRequestFactory() { - return new HttpComponentsClientHttpRequestFactory(httpClient()); - } - - @Bean - public HttpClient httpClient() { - // 长连接保持30秒 - PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager(30, TimeUnit.SECONDS); - //设置整个连接池最大连接数 根据自己的场景决定 - connectionManager.setMaxTotal(500); - //同路由的并发数,路由是对maxTotal的细分 - connectionManager.setDefaultMaxPerRoute(500); - - //requestConfig - RequestConfig requestConfig = RequestConfig.custom() - //服务器返回数据(response)的时间,超过该时间抛出read timeout - .setSocketTimeout(10000) - //连接上服务器(握手成功)的时间,超出该时间抛出connect timeout - .setConnectTimeout(5000) - //从连接池中获取连接的超时时间,超过该时间未拿到可用连接,会抛出org.apache.http.conn.ConnectionPoolTimeoutException: Timeout waiting for connection from pool - .setConnectionRequestTimeout(500) - .build(); - //headers - List
headers = new ArrayList<>(); - headers.add(new BasicHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.16 Safari/537.36")); - headers.add(new BasicHeader("Accept-Encoding", "gzip,deflate")); - headers.add(new BasicHeader("Accept-Language", "zh-CN")); - headers.add(new BasicHeader("Connection", "Keep-Alive")); - headers.add(new BasicHeader("Content-type", "application/json;charset=UTF-8")); - - return HttpClientBuilder.create() - .setDefaultRequestConfig(requestConfig) - .setConnectionManager(connectionManager) - .setDefaultHeaders(headers) - // 保持长连接配置,需要在头添加Keep-Alive - .setKeepAliveStrategy(new DefaultConnectionKeepAliveStrategy()) - //重试次数,默认是3次,没有开启 - .setRetryHandler(new DefaultHttpRequestRetryHandler(2, true)) - .build(); - } - - /** - * 全局配置 序列化和反序列化规则 - * addSerializer:序列化 (Controller 返回 给前端的json) - * 1. Long -> string - * 2. BigInteger -> string - * 3. BigDecimal -> string - * 4. date -> string - * 5. LocalDateTime -> "yyyy-MM-dd HH:mm:ss" - * 6. LocalDate -> "yyyy-MM-dd" - * 7. LocalTime -> "HH:mm:ss" - * 8. BaseEnum -> {"code": "xxx", "desc": "xxx"} - * - *

- * addDeserializer: 反序列化 (前端调用接口时,传递到后台的json) - * 1. {"code": "xxx"} -> BaseEnum - * 2. "yyyy-MM-dd HH:mm:ss" -> LocalDateTime - * 3. "yyyy-MM-dd" -> LocalDate - * 4. "HH:mm:ss" -> LocalTime - * - * @param builder 构造器 - * @return 全局 ObjectMapper - */ - @Bean - @Primary - @ConditionalOnClass(ObjectMapper.class) - @ConditionalOnMissingBean - public ObjectMapper jacksonObjectMapper(Jackson2ObjectMapperBuilder builder) { - ObjectMapper objectMapper = builder.createXmlMapper(false).build(); - objectMapper.setLocale(Locale.CHINA) - //去掉默认的时间戳格式 - .configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false) - // 时区 - .setTimeZone(TimeZone.getTimeZone(ZoneId.systemDefault())) - //Date参数日期格式 - .setDateFormat(new SimpleDateFormat(NdDateUtils.DEFAULT_DATE_TIME_FORMAT, Locale.CHINA)) - - //该特性决定parser是否允许JSON字符串包含非引号控制字符(值小于32的ASCII字符,包含制表符和换行符)。 如果该属性关闭,则如果遇到这些字符,则会抛出异常。JSON标准说明书要求所有控制符必须使用引号,因此这是一个非标准的特性 - .configure(JsonReadFeature.ALLOW_UNESCAPED_CONTROL_CHARS.mappedFeature(), true) - // 忽略不能转义的字符 - .configure(JsonReadFeature.ALLOW_BACKSLASH_ESCAPING_ANY_CHARACTER.mappedFeature(), true) - //在使用spring boot + jpa/hibernate,如果实体字段上加有FetchType.LAZY,并使用jackson序列化为json串时,会遇到SerializationFeature.FAIL_ON_EMPTY_BEANS异常 - .configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false) - //忽略未知字段 - .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) - //单引号处理 - .configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true); - // 注册自定义模块 - objectMapper.registerModule(new NdJacksonModule()).findAndRegisterModules(); - return objectMapper; - } - - //解决跨域方式二 - static final String ORIGINS[] = new String[]{"GET", "POST", "PUT", "DELETE", "OPTIONS"}; - - @Override - public void addCorsMappings(CorsRegistry registry) { - registry.addMapping("/**") // 所有的当前站点的请求地址,都支持跨域访问。 - .allowedOriginPatterns("*") // 所有的外部域都可跨域访问。 如果是localhost则很难配置,因为在跨域请求的时候,外部域的解析可能是localhost、127.0.0.1、主机名 - .allowCredentials(true) // 是否支持跨域用户凭证 - .allowedMethods(ORIGINS) // 当前站点支持的跨域请求类型是什么 - .maxAge(3600); // 超时时长设置为1小时。 时间单位是秒。 - } -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/common/config/ConfigurerAdapter.java b/kqapi/src/main/java/com/ningdatech/kqapi/common/config/ConfigurerAdapter.java deleted file mode 100644 index f0b1f32..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/common/config/ConfigurerAdapter.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.ningdatech.kqapi.common.config; - -import com.alibaba.fastjson.serializer.SerializerFeature; -import com.alibaba.fastjson.support.config.FastJsonConfig; -import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter; -import org.springframework.context.annotation.Configuration; -import org.springframework.http.MediaType; -import org.springframework.http.converter.HttpMessageConverter; -import org.springframework.web.servlet.config.annotation.EnableWebMvc; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; - -import java.nio.charset.StandardCharsets; -import java.util.ArrayList; -import java.util.List; - -/** - * @author qinxianyun - */ -@EnableWebMvc -@Configuration -public class ConfigurerAdapter implements WebMvcConfigurer { - - @Override - public void configureMessageConverters(List> converters) { - // 使用 fastjson 序列化,会导致 @JsonIgnore 失效,可以使用 @JSONField(serialize = false) 替换 - FastJsonHttpMessageConverter converter = new FastJsonHttpMessageConverter(); - List supportMediaTypeList = new ArrayList<>(); - supportMediaTypeList.add(MediaType.APPLICATION_JSON); - FastJsonConfig config = new FastJsonConfig(); - config.setDateFormat("yyyy-MM-dd HH:mm:ss"); - config.setSerializerFeatures(SerializerFeature.DisableCircularReferenceDetect); - converter.setFastJsonConfig(config); - converter.setSupportedMediaTypes(supportMediaTypeList); - converter.setDefaultCharset(StandardCharsets.UTF_8); - converters.add(converter); - } -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/common/config/DingOrganizationProperties.java b/kqapi/src/main/java/com/ningdatech/kqapi/common/config/DingOrganizationProperties.java deleted file mode 100644 index 5fcf9db..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/common/config/DingOrganizationProperties.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.ningdatech.kqapi.common.config; - -import lombok.Data; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.context.annotation.Configuration; - -import java.util.ArrayList; -import java.util.List; - -/** - * @author liuxinxin - * @date 2022/9/9 下午5:37 - */ -@Data -@Configuration -@ConfigurationProperties(prefix = "organization") -public class DingOrganizationProperties { - private List deptVisibleScopes = new ArrayList<>(); -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/common/config/ProvincialProperties.java b/kqapi/src/main/java/com/ningdatech/kqapi/common/config/ProvincialProperties.java deleted file mode 100644 index cdbf17c..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/common/config/ProvincialProperties.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.ningdatech.kqapi.common.config; - -import lombok.Data; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.context.annotation.Configuration; - -/** - * @author zpf - * @date 2023/3/2 下午5:37 - */ -@Data -@Configuration -@ConfigurationProperties(prefix = "provincial") -public class ProvincialProperties { - private String host; - - private String pushUrl; - - private String detailUrl; - - private String domainUrl; - - private String key; - - private String secret; -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/common/constant/BaseFieldConst.java b/kqapi/src/main/java/com/ningdatech/kqapi/common/constant/BaseFieldConst.java deleted file mode 100644 index af3f58a..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/common/constant/BaseFieldConst.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.ningdatech.kqapi.common.constant; - -/** - *

- * 创建人修改人基础字段 - *

- * - * @author WendyYang - * @since 17:17 2023/01/29 - */ -public interface BaseFieldConst { - - String CREATE_BY = "createBy"; - String UPDATE_BY = "updateBy"; - String CREATE_ON = "createOn"; - String UPDATE_ON = "updateOn"; - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/common/constant/BizConst.java b/kqapi/src/main/java/com/ningdatech/kqapi/common/constant/BizConst.java deleted file mode 100644 index 0307599..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/common/constant/BizConst.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.ningdatech.kqapi.common.constant; - -import com.ningdatech.kqapi.common.model.ApiResponse; - -/** - *

- * BizConst - *

- * - * @author WendyYang - * @since 11:46 2024/4/20 - */ -public class BizConst { - - private BizConst() { - } - - /** - * SQL查询一条 - */ - public static final String LIMIT_1 = "limit 1"; - - public static final String COOKIE_KEY = "KQ_ZZSFW"; - - - /** - * 密码正则:长度8-20位且至少包含大写字母、小写字母、数字或特殊符号中的任意三种 - */ - public static final String REGEX_PASS = "^(?![a-zA-Z]+$)(?![A-Z0-9]+$)(?![A-Z\\W_]+$)(?![a-z0-9]+$)(?![a-z\\W_]+$)(?![0-9\\W_]+$)[a-zA-Z0-9\\W_]{8,20}$"; - - public static final String JSON_UTF8 = "application/json;charset=UTF-8"; - - public static final ApiResponse SESSION_EXPIRE = ApiResponse.of(401, "登录已超时,请重新登陆!"); - - public static final ApiResponse UNAUTHENTICATED = ApiResponse.of(401, "用户未登录!"); - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/common/constant/CommonConst.java b/kqapi/src/main/java/com/ningdatech/kqapi/common/constant/CommonConst.java deleted file mode 100644 index abab570..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/common/constant/CommonConst.java +++ /dev/null @@ -1,69 +0,0 @@ -package com.ningdatech.kqapi.common.constant; - -/** - * @description: 常量 - * @author: LiuXinXin - * @date: 2022/5/5 17:31 - */ -public interface CommonConst { - - String COOKIE_KEY = "ND_JSESSION"; - - Integer EXPORT_PAGE_NUMBER = 1; - Integer EXPORT_PAGE_SIZE = 100000; - String CALL_STATUS = "status"; - String CALL_STATUS_OK_VALUE = "ok"; - - Integer COMMENT_MAX_SIZE = 163; - Integer SUB_COMMENT_SIZE_MIN = 0; - Integer SUB_COMMENT_SIZE_MAX = 160; - - String PROJECT_DECLARE = "项目申报"; - String UNIT_INNER_AUDIT = "单位内部审核"; - String PRELIMINARY_PREVIEW = "项目预审"; - - String DEPT_UNITED_REVIEW = "部门联审"; - String PROVINCE_UNITED_REVIEW = "省级部门联审"; - String ANNUAL_PLAN = "年度计划"; - String CONSTRUCTION_PLAN_REVIEW = "建设方案评审"; - String PROJECT_APPROVAL = "立项批复"; - String TENDER_PURCHASE = "招标采购"; - String PROJECT_PRELIMINARY_INSPECTION = "项目初验"; - String PROJECT_FINAL_INSPECTION = "项目终验"; - - String ARCHIVED = "归档"; - - String FILE_NAME = "name"; - String BASIS_FILE_NAME = "fileName"; - - String NULL = "null"; - - String TITLE = "title"; - - String FILE_NAME_STR = "fileName"; - String FILE_ID_STR = "fileId"; - String ID_STR = "id"; - String FILE_LIST = "fileList"; - String ITEM_BASED = "依据项:"; - String ITEM_BASED_FILE_NAME = "依据文件名:"; - String APPENDIX = "文件:"; - String NEW_CONSTRUCTION = "新建"; - String CONTINUED_CONSTRUCTION = "续建"; - String MONTH = "月"; - String ZHI = "至"; - String YEAR = "年"; - - Integer VERSION_ONE = 1; - Integer VERSION_SIZE = 2; - Integer VERSION_JUDGE = -1; - - String COPY = "副本"; - String PROJECT_REPEAT = " 项目已在其他评价计划中,请勿重复添加!"; - String APP_REPEAT = " 应用已在其他评价计划中,请勿重复添加!"; - Integer REAPPRAISAL_TYPE = 1; - Integer VERIFY_TYPE = 2; - String REPEAT = " 已在其他当前评价计划其他分组中,请勿重复添加!"; - - String NORMAL_TIME_PATTERN = "yyyy-MM-dd"; - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/common/constant/DefValConst.java b/kqapi/src/main/java/com/ningdatech/kqapi/common/constant/DefValConst.java deleted file mode 100644 index 69385ee..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/common/constant/DefValConst.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.ningdatech.kqapi.common.constant; - - -import cn.hutool.core.text.StrPool; - -/** - * 默认值 - * - * @author PoffyZhang - */ -public interface DefValConst { - - /** - * 默认的根节点path - */ - String ROOT_PATH = StrPool.COMMA; - /** - * 默认树层级 - */ - Integer TREE_GRADE = 0; - /** - * 默认的父id - */ - Long PARENT_ID = 0L; - /** - * 默认的排序 - */ - Integer SORT_VALUE = 0; - /** - * 字典占位符 - */ - String DICT_PLACEHOLDER = "###"; - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/common/constant/DingConst.java b/kqapi/src/main/java/com/ningdatech/kqapi/common/constant/DingConst.java deleted file mode 100644 index e30577d..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/common/constant/DingConst.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.ningdatech.kqapi.common.constant; - -/** - * 浙政钉常量 - * - * @author CMM - * @since 2023/02/01 14:49 - */ -public interface DingConst { - /** - * 工作通知 - */ - String WORKING_NOTICE = "/message/workNotification"; -} \ No newline at end of file diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/common/constant/ProjectDeclareConst.java b/kqapi/src/main/java/com/ningdatech/kqapi/common/constant/ProjectDeclareConst.java deleted file mode 100644 index d9132a6..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/common/constant/ProjectDeclareConst.java +++ /dev/null @@ -1,172 +0,0 @@ -package com.ningdatech.kqapi.common.constant; - -import java.math.BigDecimal; - -/** - * 项目申报表单数据常量key - * @return - * @author CMM - * @since 2023/01/19 10:31 - */ -public interface ProjectDeclareConst { - - /** - * 基本信息 - */ - class BasicInformation { - // 项目名称 - public static final String PROJECT_NAME = "projectName"; - // 是否一地创新全省共享项目 - public static final String INNOVATION_SHARING_PROJECT = "innovationSharingProject"; - // 是否临时增补 - public static final String TEMPORARY_SUPPLEMENT = "temporarySupplement"; - // 项目负责人 - public static final String PROJECT_LEADER = "projectLeader"; - // 项目负责人手机号 - public static final String PROJECT_LEADER_PHONE_NUMBER = "projectLeaderPhoneNumber"; - // 项目联系人 - public static final String PROJECT_CONTACT = "projectContact"; - // 项目联系人手机号 - public static final String PROJECT_CONTACT_PHONE_NUMBER = "projectContactPhoneNumber"; - // 建设单位 - public static final String CONSTRUCTION_UNIT = "constructionUnit"; - // 建设单位统一信用代码 - public static final String CONSTRUCTION_UNIT_UNIFIED_CREDIT_CODE = "constructionUnitUnifiedCreditCode"; - // 项目类型 - public static final String PROJECT_TYPE = "projectType"; - // 是否首次新建 - public static final String FIRST_NEW_CONSTRUCTION = "firstNewConstruction"; - // 预算年度 - public static final String BUDGET_YEAR = "projectYear"; - // 建设开始时间 - public static final String CONSTRUCTION_START_TIME = "constructionStartTime"; - // 建设结束时间 - public static final String CONSTRUCTION_END_TIME = "constructionEndTime"; - // 四大体系 - public static final String FOUR_SYSTEM = "fourSystem"; - // 是否数字化改革项目 - public static final String DIGITAL_REFORM_PROJECT = "digitalReformProject"; - // 建设层级 - public static final String CONSTRUCTION_HIERARCHY = "constructionHierarchy"; - // 立项依据材料 - public static final String PROJECT_BASIS_MATERIAL = "projectBasisMaterial"; - // 发改编码 - public static final String CHANGE_CODE = "changeCode"; - // 财政编码 - public static final String FISCAL_CODE = "fiscalCode"; - // 是否上云 - public static final String ON_CLOUD = "onCloud"; - // 项目简介 - public static final String PROJECT_INTRODUCTION = "projectIntroduction"; - } - - /** - * 资金申报情况 - */ - class FundDeclareInfo { - // 申报金额 - public static final String DECLARE_AMOUNT = "declareAmount"; - // 自有资金 - public static final String OWN_FUND = "ownFund"; - // 政府投资-本级财政资金 - public static final String GOVERNMENT_INVESTMENT_SAME_LEVEL_FUND = "governmentInvestmentSameLevelFund"; - // 政府投资-上级补助资金 - public static final String GOVERNMENT_INVESTMENT_SUPERIOR_FUND = "governmentInvestmentSuperiorFund"; - // 银行贷款 - public static final String BANK_LOAN = "bankLoan"; - // 其他资金 - public static final String OTHER_FUND = "otherFund"; - } - - /** - * 总投资分配情况 - */ - class TotalInvestmentAllocations { - // 软件开发 - public static final String SOFTWARE_DEVELOPMENT = "softwareDevelopment"; - // 云资源、硬件配置 - public static final String CLOUD_RESOURCE_HARDWARE_CONFIGURATION = "cloudResourceHardwareConfiguration"; - // 第三方服务 - public static final String THIRD_PARTY_SERVICE = "thirdPartyService"; - } - /** - * 年度支付计划 - */ - class AnnualPaymentPlan { - // 年度支付金额 - public static final String ANNUAL_PAYMENT_AMOUNT = "annualPaymentAmount"; - // 自有资金 - public static final String OWN_FUND = "ownFund"; - // 政府投资-本级财政资金 - public static final String GOVERNMENT_INVESTMENT_SAME_LEVEL_FUND = "governmentInvestmentSameLevelFund"; - // 政府投资-上级补助资金 - public static final String GOVERNMENT_INVESTMENT_SUPERIOR_FUND = "governmentInvestmentSuperiorFund"; - // 银行贷款 - public static final String BANK_LOAN = "bankLoan"; - // 其他 - public static final String OTHER = "other"; - } - /** - * 核心业务 - */ - class CoreBusiness { - - } - /** - * 安全投入 - */ - class SafetyInput { - // 投入项 - public static final String INPUT_ITEM = "inputItem"; - // 内容描述 - public static final String CONTENT_DESCRIPTION = "contentDescription"; - // 金额 - public static final String AMOUNT = "amount"; - } - /** - * 工程形象进度 - */ - class ProjectImageProgress { - // 第一季度 - public static final String FIRST_QUARTER = "firstQuarter"; - // 第二季度 - public static final String SECOND_QUARTER = "secondQuarter"; - // 第三季度 - public static final String THIRD_QUARTER = "thirdQuarter"; - // 第四季度 - public static final String FOURTH_QUARTER = "fourthQuarter"; - } - /** - * 附件 - */ - class Appendix { - - } - /** - * 备注 - */ - class Remark { - - } - /** - * 应用信息 - */ - class ApplicationInformation { - - } - - class Number { - public static final BigDecimal DECLARE_AMOUNT_JUDGEMENT = BigDecimal.valueOf(1000); - - //区县是500万 - public static final BigDecimal DECLARE_COUNTY_AMOUNT_JUDGEMENT = BigDecimal.valueOf(500); - - public static final Integer COUNTRY_BUILD_LEVEL = 1; - public static final Integer PROVINCE_BUILD_LEVEL = 2; - public static final Integer PROVINCE_SELF_BUILD_LEVEL = 3; - public static final Integer CITY_BUILD_LEVEL = 4; - public static final Integer CITY_SELF_BUILD_LEVEL = 5; - public static final Integer DISTRICTS_COUNTRIES_BUILD_LEVEL = 6; - public static final Integer VILLAGES_TOWNS_BUILD_LEVEL = 7; - } -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/common/constant/RegionConst.java b/kqapi/src/main/java/com/ningdatech/kqapi/common/constant/RegionConst.java deleted file mode 100644 index 66c5eac..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/common/constant/RegionConst.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.ningdatech.kqapi.common.constant; - -/** - *

- * RegionConst - *

- * - * @author WendyYang - * @since 13:57 2023/3/1 - */ -public interface RegionConst { - - //---------------------------------------地区层级(缩写RL)------------------------------------------------------------- - - int RL_PROVINCE = 1; - - int RL_CITY = 2; - - int RL_COUNTY = 3; - - //---------------------------------------地区编码(缩写RC)------------------------------------------------------------- - - /** - * 丽水行政区划编码 - */ - String RC_LS = "331100"; - //丽水开发区 - String LS_KF = "331118"; - String LS_KF_IRS = "331151"; - String RC_LS_SBJ_IRS = "331101"; - //遂昌县 - String RC_SC = "331123"; - String LS_KF_NAME = "开发区"; - - /** - * 中国行政区划编码 - */ - String RC_CHINA = "100000"; - - - /** - * 浙江行政区划编码 - */ - String RC_ZJ = "330000"; - - //----------------------------------------地区父级ID(缩写PID)--------------------------------------------------------- - - long PID_CHINA = 0; - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/common/constant/StateMachineConst.java b/kqapi/src/main/java/com/ningdatech/kqapi/common/constant/StateMachineConst.java deleted file mode 100644 index 9cd0f1f..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/common/constant/StateMachineConst.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.ningdatech.kqapi.common.constant; - -/** - * @author CMM - * @since 2023/02/07 16:24 - */ - -public class StateMachineConst { - - public static final String PROJECT_DECLARE = "projectDeclare"; - public static final String APPLICATION_DECLARE = "applicationDeclare"; - public static final String LI_SHUI_CITY_AREA_CODE = "331100"; - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/common/converter/BaseDateConverter.java b/kqapi/src/main/java/com/ningdatech/kqapi/common/converter/BaseDateConverter.java deleted file mode 100644 index 1b843ff..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/common/converter/BaseDateConverter.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.ningdatech.kqapi.common.converter; - -import java.util.Map; -import java.util.Set; -import java.util.function.Function; - -/** - * 解决入参为 Date类型 - * - * @author WendyYang - * @date 2019-04-30 - */ -public abstract class BaseDateConverter { - - /** - * 值转换 - * - * @param source 源数据 - * @param function 回调 - * @return 转换后的数据 - */ - public T convert(String source, Function function) { - if (source == null || source.isEmpty()) { - return null; - } - String sourceTrim = source.trim(); - Set> entries = getFormat().entrySet(); - for (Map.Entry entry : entries) { - if (sourceTrim.matches(entry.getValue())) { - return function.apply(entry.getKey()); - } - } - throw new IllegalArgumentException("无效的日期参数格式:'" + sourceTrim + "'"); - } - - /** - * 获取子类 具体的格式化表达式 - * - * @return 格式化 - */ - protected abstract Map getFormat(); -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/common/converter/NdLocalDateTimeDeserializer.java b/kqapi/src/main/java/com/ningdatech/kqapi/common/converter/NdLocalDateTimeDeserializer.java deleted file mode 100644 index fec700e..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/common/converter/NdLocalDateTimeDeserializer.java +++ /dev/null @@ -1,185 +0,0 @@ -package com.ningdatech.kqapi.common.converter; - -import com.fasterxml.jackson.annotation.JsonFormat; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.core.JsonTokenId; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.datatype.jsr310.deser.JSR310DateTimeDeserializerBase; -import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer; - -import java.io.IOException; -import java.time.*; -import java.time.format.DateTimeFormatter; - -import static com.ningdatech.kqapi.common.util.NdDateUtils.*; - - -/** - * 字段类型是LocalDateTime时,可以按照以下6种格式反序列化: - * 1. yyyy-MM-dd - * 2. yyyy年MM月dd日 - * 3. yyyy/MM/dd - * 4. yyyy-MM-dd HH:mm:ss - * 5. yyyy年MM月dd日HH时mm分ss秒 - * 6. yyyy/MM/dd HH:mm:ss - * - * @author WendyYang - * @date 2020/6/18 上午10:50 - */ -@SuppressWarnings("ALL") -public class NdLocalDateTimeDeserializer extends JSR310DateTimeDeserializerBase { - public static final NdLocalDateTimeDeserializer INSTANCE = new NdLocalDateTimeDeserializer(); - private static final long serialVersionUID = 1L; - private static final DateTimeFormatter DEFAULT_FORMATTER = DateTimeFormatter.ISO_LOCAL_DATE_TIME; - /** - * 以下是支持的6种参数格式 - */ - private static final DateTimeFormatter DEFAULT_DATE_FORMAT_DTF = DateTimeFormatter.ofPattern(DEFAULT_DATE_FORMAT); - private static final DateTimeFormatter DEFAULT_DATE_FORMAT_EN_DTF = DateTimeFormatter.ofPattern(DEFAULT_DATE_FORMAT_EN); - private static final DateTimeFormatter SLASH_DATE_FORMAT_DTF = DateTimeFormatter.ofPattern(SLASH_DATE_FORMAT); - private static final DateTimeFormatter DEFAULT_DATE_TIME_FORMAT_DTF = DateTimeFormatter.ofPattern(DEFAULT_DATE_TIME_FORMAT); - private static final DateTimeFormatter DEFAULT_DATE_TIME_FORMAT_EN_DTF = DateTimeFormatter.ofPattern(DEFAULT_DATE_TIME_FORMAT_EN); - private static final DateTimeFormatter SLASH_DATE_TIME_FORMAT_DTF = DateTimeFormatter.ofPattern(SLASH_DATE_TIME_FORMAT); - - @Override - protected JSR310DateTimeDeserializerBase withShape(JsonFormat.Shape shape) { - return this; - } - - private NdLocalDateTimeDeserializer() { - this(DEFAULT_FORMATTER); - } - - public NdLocalDateTimeDeserializer(DateTimeFormatter formatter) { - super(LocalDateTime.class, formatter); - } - - protected NdLocalDateTimeDeserializer(NdLocalDateTimeDeserializer base, Boolean leniency) { - super(base, leniency); - } - - @Override - protected NdLocalDateTimeDeserializer withLeniency(Boolean leniency) { - return new NdLocalDateTimeDeserializer(this, leniency); - } - - @Override - protected JSR310DateTimeDeserializerBase withDateFormat(DateTimeFormatter formatter) { - return new LocalDateTimeDeserializer(formatter); - } - - private LocalDateTime convert(String source) { - if (source.matches(DEFAULT_DATE_FORMAT_MATCHES)) { - return LocalDateTime.of(LocalDate.parse(source, DEFAULT_DATE_FORMAT_DTF), LocalTime.MIN); - } - if (source.matches(DEFAULT_DATE_FORMAT_EN_MATCHES)) { - return LocalDateTime.of(LocalDate.parse(source, DEFAULT_DATE_FORMAT_EN_DTF), LocalTime.MIN); - } - if (source.matches(SLASH_DATE_FORMAT_MATCHES)) { - return LocalDateTime.of(LocalDate.parse(source, SLASH_DATE_FORMAT_DTF), LocalTime.MIN); - } - if (source.matches(DEFAULT_DATE_TIME_FORMAT_MATCHES)) { - return LocalDateTime.parse(source, DEFAULT_DATE_TIME_FORMAT_DTF); - } - if (source.matches(DEFAULT_DATE_TIME_FORMAT_EN_MATCHES)) { - return LocalDateTime.parse(source, DEFAULT_DATE_TIME_FORMAT_EN_DTF); - } - if (source.matches(SLASH_DATE_TIME_FORMAT_MATCHES)) { - return LocalDateTime.parse(source, SLASH_DATE_TIME_FORMAT_DTF); - } - return null; - } - - @Override - public LocalDateTime deserialize(JsonParser parser, DeserializationContext context) throws IOException { - // 字符串 - if (parser.hasTokenId(JsonTokenId.ID_STRING)) { - String string = parser.getText().trim(); - if (string.length() == 0) { - return null; - } - - try { - if (_formatter == null) { - return convert(string); - } - if (_formatter == DEFAULT_FORMATTER) { - // JavaScript by default includes time and zone in JSON serialized Dates (UTC/ISO instant format). - if (string.length() > 10 && string.charAt(10) == 'T') { - if (string.endsWith("Z")) { - return LocalDateTime.ofInstant(Instant.parse(string), ZoneOffset.UTC); - } else { - return LocalDateTime.parse(string, DEFAULT_FORMATTER); - } - } - return convert(string); - } - - return LocalDateTime.parse(string, this._formatter); - } catch (DateTimeException e) { - return _handleDateTimeException(context, e, string); - } - } - // 数组 - if (parser.isExpectedStartArrayToken()) { - JsonToken t = parser.nextToken(); - if (t == JsonToken.END_ARRAY) { - return null; - } - if ((t == JsonToken.VALUE_STRING || t == JsonToken.VALUE_EMBEDDED_OBJECT) - && context.isEnabled(DeserializationFeature.UNWRAP_SINGLE_VALUE_ARRAYS)) { - final LocalDateTime parsed = deserialize(parser, context); - if (parser.nextToken() != JsonToken.END_ARRAY) { - handleMissingEndArrayForSingle(parser, context); - } - return parsed; - } - if (t == JsonToken.VALUE_NUMBER_INT) { - LocalDateTime result; - - int year = parser.getIntValue(); - int month = parser.nextIntValue(-1); - int day = parser.nextIntValue(-1); - int hour = parser.nextIntValue(-1); - int minute = parser.nextIntValue(-1); - - t = parser.nextToken(); - if (t == JsonToken.END_ARRAY) { - result = LocalDateTime.of(year, month, day, hour, minute); - } else { - int second = parser.getIntValue(); - t = parser.nextToken(); - if (t == JsonToken.END_ARRAY) { - result = LocalDateTime.of(year, month, day, hour, minute, second); - } else { - int partialSecond = parser.getIntValue(); - if (partialSecond < 1_000 && - !context.isEnabled(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS)) { - // value is milliseconds, convert it to nanoseconds - partialSecond *= 1_000_000; - } - if (parser.nextToken() != JsonToken.END_ARRAY) { - throw context.wrongTokenException(parser, handledType(), JsonToken.END_ARRAY, "Expected array to end"); - } - result = LocalDateTime.of(year, month, day, hour, minute, second, partialSecond); - } - } - return result; - } - context.reportInputMismatch(handledType(), "Unexpected token (%s) within Array, expected VALUE_NUMBER_INT", t); - } - // 数字 - if (parser.hasToken(JsonToken.VALUE_NUMBER_INT)) { - return Instant.ofEpochMilli(parser.getLongValue()).atZone(ZoneOffset.ofHours(8)).toLocalDateTime(); - } - // 没看懂这个是啥 - if (parser.hasToken(JsonToken.VALUE_EMBEDDED_OBJECT)) { - return (LocalDateTime) parser.getEmbeddedObject(); - } - - return _handleUnexpectedToken(context, parser, "当前参数需要数组、字符串、时间戳。"); - } - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/common/converter/String2DateConverter.java b/kqapi/src/main/java/com/ningdatech/kqapi/common/converter/String2DateConverter.java deleted file mode 100644 index dd3e772..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/common/converter/String2DateConverter.java +++ /dev/null @@ -1,77 +0,0 @@ -package com.ningdatech.kqapi.common.converter; - -import com.ningdatech.kqapi.common.exception.BizException; -import lombok.extern.slf4j.Slf4j; -import org.springframework.core.convert.converter.Converter; -import org.springframework.lang.NonNull; -import org.springframework.lang.Nullable; - -import java.text.DateFormat; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.LinkedHashMap; -import java.util.Map; - -import static com.ningdatech.kqapi.common.exception.BaseException.BASE_VALID_PARAM; -import static com.ningdatech.kqapi.common.util.NdDateUtils.*; - - -/** - * 解决入参为 Date类型 - * - * @author WendyYang - * @date 2019-04-30 - */ -@Slf4j -public class String2DateConverter extends BaseDateConverter implements Converter { - - protected static final Map FORMAT = new LinkedHashMap<>(15); - - static { - FORMAT.put(DEFAULT_YEAR_FORMAT, "^\\d{4}"); - FORMAT.put(DEFAULT_MONTH_FORMAT, "^\\d{4}-\\d{1,2}$"); - FORMAT.put(DEFAULT_DATE_FORMAT, DEFAULT_DATE_FORMAT_MATCHES); - FORMAT.put("yyyy-MM-dd HH", "^\\d{4}-\\d{1,2}-\\d{1,2} {1}\\d{1,2}"); - FORMAT.put("yyyy-MM-dd HH:mm", "^\\d{4}-\\d{1,2}-\\d{1,2} {1}\\d{1,2}:\\d{1,2}$"); - FORMAT.put(DEFAULT_DATE_TIME_FORMAT, DEFAULT_DATE_TIME_FORMAT_MATCHES); - FORMAT.put(DEFAULT_MONTH_FORMAT_SLASH, "^\\d{4}/\\d{1,2}$"); - FORMAT.put(SLASH_DATE_FORMAT, SLASH_DATE_FORMAT_MATCHES); - FORMAT.put("yyyy/MM/dd HH", "^\\d{4}/\\d{1,2}/\\d{1,2} {1}\\d{1,2}"); - FORMAT.put("yyyy/MM/dd HH:mm", "^\\d{4}/\\d{1,2}/\\d{1,2} {1}\\d{1,2}:\\d{1,2}$"); - FORMAT.put(SLASH_DATE_TIME_FORMAT, SLASH_DATE_TIME_FORMAT_MATCHES); - FORMAT.put(DEFAULT_DATE_FORMAT_EN, DEFAULT_DATE_FORMAT_EN_MATCHES); - FORMAT.put(DEFAULT_DATE_TIME_FORMAT_EN, DEFAULT_DATE_TIME_FORMAT_EN_MATCHES); - } - - /** - * 格式化日期 - * - * @param dateStr String 字符型日期 - * @param format String 格式 - * @return Date 日期 - */ - protected static Date parseDate(String dateStr, String format) { - try { - DateFormat dateFormat = new SimpleDateFormat(format); - //严格模式 - dateFormat.setLenient(false); - return dateFormat.parse(dateStr); - } catch (ParseException e) { - log.info("转换日期失败, date={}, format={}", dateStr, format, e); - throw new BizException(BASE_VALID_PARAM, e.getMessage(), e); - } - } - - @Override - protected Map getFormat() { - return FORMAT; - } - - @Override - @Nullable - public Date convert(@NonNull String source) { - return super.convert(source, key -> parseDate(source, key)); - } - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/common/converter/String2LocalDateConverter.java b/kqapi/src/main/java/com/ningdatech/kqapi/common/converter/String2LocalDateConverter.java deleted file mode 100644 index 55ebb74..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/common/converter/String2LocalDateConverter.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.ningdatech.kqapi.common.converter; - -import org.springframework.core.convert.converter.Converter; -import org.springframework.lang.NonNull; - -import java.time.LocalDate; -import java.time.format.DateTimeFormatter; -import java.util.LinkedHashMap; -import java.util.Map; - -import static com.ningdatech.kqapi.common.util.NdDateUtils.*; - -/** - * 解决入参为 Date类型 - * - * @author WendyYang - * @date 2019-04-30 - */ -public class String2LocalDateConverter extends BaseDateConverter implements Converter { - - protected static final Map FORMAT = new LinkedHashMap<>(5); - - static { - FORMAT.put(DEFAULT_DATE_FORMAT, DEFAULT_DATE_FORMAT_MATCHES); - FORMAT.put(SLASH_DATE_FORMAT, SLASH_DATE_FORMAT_MATCHES); - FORMAT.put(DEFAULT_DATE_FORMAT_EN, DEFAULT_DATE_FORMAT_EN_MATCHES); - } - - @Override - protected Map getFormat() { - return FORMAT; - } - - @Override - public LocalDate convert(@NonNull String source) { - return super.convert(source, (key) -> LocalDate.parse(source, DateTimeFormatter.ofPattern(key))); - } - -} - diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/common/converter/String2LocalDateTimeConverter.java b/kqapi/src/main/java/com/ningdatech/kqapi/common/converter/String2LocalDateTimeConverter.java deleted file mode 100644 index 3cbe5e7..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/common/converter/String2LocalDateTimeConverter.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.ningdatech.kqapi.common.converter; - -import org.springframework.core.convert.converter.Converter; -import org.springframework.lang.NonNull; - -import java.time.LocalDateTime; -import java.time.format.DateTimeFormatter; -import java.util.LinkedHashMap; -import java.util.Map; - -import static com.ningdatech.kqapi.common.util.NdDateUtils.*; - -/** - * 解决入参为 Date类型 - * - * @author WendyYang - * @date 2019-04-30 - */ -public class String2LocalDateTimeConverter extends BaseDateConverter implements Converter { - - protected static final Map FORMAT = new LinkedHashMap<>(5); - - static { - FORMAT.put(DEFAULT_DATE_TIME_FORMAT, DEFAULT_DATE_TIME_FORMAT_MATCHES); - FORMAT.put(SLASH_DATE_TIME_FORMAT, SLASH_DATE_TIME_FORMAT_MATCHES); - FORMAT.put(DEFAULT_DATE_TIME_FORMAT_EN, DEFAULT_DATE_TIME_FORMAT_EN_MATCHES); - } - - @Override - protected Map getFormat() { - return FORMAT; - } - - @Override - public LocalDateTime convert(@NonNull String source) { - return super.convert(source, (key) -> LocalDateTime.parse(source, DateTimeFormatter.ofPattern(key))); - } -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/common/converter/String2LocalTimeConverter.java b/kqapi/src/main/java/com/ningdatech/kqapi/common/converter/String2LocalTimeConverter.java deleted file mode 100644 index c372d21..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/common/converter/String2LocalTimeConverter.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.ningdatech.kqapi.common.converter; - -import org.springframework.core.convert.converter.Converter; - -import java.time.LocalTime; -import java.time.format.DateTimeFormatter; -import java.util.LinkedHashMap; -import java.util.Map; - -import static com.ningdatech.kqapi.common.util.NdDateUtils.DEFAULT_TIME_FORMAT; - -/** - * 解决入参为 Date类型 - * - * @author WendyYang - * @date 2019-04-30 - */ -@SuppressWarnings("all") -public class String2LocalTimeConverter extends BaseDateConverter implements Converter { - - protected static final Map FORMAT = new LinkedHashMap<>(5); - - static { - FORMAT.put(DEFAULT_TIME_FORMAT, "^\\d{1,2}:\\d{1,2}:\\d{1,2}$"); - } - - @Override - protected Map getFormat() { - return FORMAT; - } - - @Override - public LocalTime convert(String source) { - return super.convert(source, (key) -> LocalTime.parse(source, DateTimeFormatter.ofPattern(key))); - } -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/common/enumeration/BoolDisplayEnum.java b/kqapi/src/main/java/com/ningdatech/kqapi/common/enumeration/BoolDisplayEnum.java deleted file mode 100644 index 9c45703..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/common/enumeration/BoolDisplayEnum.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.ningdatech.kqapi.common.enumeration; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -/** - * @author liuxinxin - * @date 2022/7/26 上午9:21 - */ -@AllArgsConstructor -@Getter -public enum BoolDisplayEnum { - - /** - * true - */ - Y, - - /** - * false - */ - N; - - public static boolean judgeBoolean(String key) { - return Y.name().equals(key); - } - - public static BoolDisplayEnum judgeBoolean(boolean key) { - return key ? Y : N; - } - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/common/enumeration/CommonEnum.java b/kqapi/src/main/java/com/ningdatech/kqapi/common/enumeration/CommonEnum.java deleted file mode 100644 index 753c33b..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/common/enumeration/CommonEnum.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.ningdatech.kqapi.common.enumeration; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -/** - * @author zpf - * @date 2023/3/12 上午9:21 - */ -@AllArgsConstructor -@Getter -public enum CommonEnum { - /** - * 公共的一些枚举 - */ - YES(1,"是",1), - NO(0,"否",1), - - LS_SBJ(331100,"市本级",2), - LS_LD(331102,"莲都区",2), - LS_QT(331121,"青田县",2), - LS_JY(331122,"缙云县",2), - LS_SC(331123,"遂昌县",2), - LS_SY(331124,"松阳县",2), - LS_YH(331125,"云和县",2), - LS_QY(331126,"庆元县",2), - LS_JN(331127,"景宁畲族自治县",2), - LS_LQ(331181,"龙泉市",2), - LS_KFQ(331199,"开发区",2), - ZWDD(0,"浙政钉",3), - MOBILE(1,"短信",3); - - private Integer code; - private String desc; - private Integer groupId; - - - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/common/enumeration/ExportOptionEnum.java b/kqapi/src/main/java/com/ningdatech/kqapi/common/enumeration/ExportOptionEnum.java deleted file mode 100644 index 9185c77..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/common/enumeration/ExportOptionEnum.java +++ /dev/null @@ -1,157 +0,0 @@ -package com.ningdatech.kqapi.common.enumeration; - -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; - - -/** - * 导出选项枚举 - * - * @author CMM - * @since 2023/02/10 16:38 - */ -@Getter -@AllArgsConstructor -@NoArgsConstructor -public enum ExportOptionEnum { - /** - * 导出选项 - */ - id(1, "项目ID"), - - projectName(2, "项目名称"), - - areaCode(3, "行政区划编码"), - - area(4, "行政区划名称"), - - responsibleMan(5, "项目负责人"), - - responsibleManMobile(6, "项目负责人手机号"), - - contactName(7, "项目联系人"), - - contactPhone(8, "项目联系人手机号"), - - higherSuperOrg(9, "上级业务主管单位"), - - higherSuperOrgCode(10, "上级主管单位浙政钉ID"), - - superOrg(11, "本级主管部门"), - - superOrgCode(12, "本级主管部门浙政钉ID"), - - buildOrgName(13, "建设单位名称"), - - buildOrgZheJiangGovDingId(14, "建设单位浙政钉ID"), - - orgCreditCode(15, "建设单位统一信用代码"), - - projectType(16, "项目类型"), - - isFirst(17, "是否首次新建"), - - relatedExistsApplication(18, "关联应用"), - - relatedExistsApplicationCode(19, "关联应用IRS编码"), - - declareAmount(20, "申报金额"), - - approvedTotalInvestmentIncrease(21, "批复金额"), - - /** - * 表里没有 - */ - budgetSource(22, "预算来源"), - - projectYear(23, "预算年度"), - - projectIntroduction(24, "项目简介"), - - buildBasis(25, "立项依据"), - - buildLevel(26, "建设层级"), - - developCode(27, "发改编码"), - - financialCode(28, "财政编码"), - - /** - * 表里没有 - */ - informationValidity(29, "信息是否有效"), - - - isDigitalReform(30, "是否数字化改革项目"), - - bizDomain(31, "综合应用领域"), - - isCloud(32, "是否上云"), - - cloudType(33, "云类型"), - - fourSystems(34, "四大体系"), - isTemporaryAugment(35, "是否临时增补"), - - protectionLevel(36, "等保级别"), - - isSecretComments(37, "是否密评"), - - businessNumber(38, "业务编号"), - - businessName(39, "业务名称"), - - orgName(40, "单位名称"), - - softwareDevelopmentAmount(41, "软件开发"), - - cloudHardwarePurchaseAmount(42, "云资源、硬件购置"), - - thirdPartyAmount(43, "第三方服务"), - - safetyInputTitle(44, "投入项"), - - safetyInputDescribe(45, "内容描述"), - - safetyInputAmount(46, "金额"), - - annualPlanAmount(47, "年度支付金额"), - - annualPlanHaveAmount(48, "自有资金"), - - declareGovOwnFinanceAmount(49, "政府投资-本级财政资金"), - - declareGovSuperiorFinanceAmount(50, "政府投资-上级补助资金"), - - declareBankLendingAmount(51, "银行贷款"), - - declareOtherAmount(52, "其它资金"), - - engineeringSpeedOne(53, "第一季度"), - - engineeringSpeedTwo(54, "第二季度"), - - engineeringSpeedThree(55, "第三季度"), - - engineeringSpeedFour(56, "第四季度"), - - preliminaryPlanFile(57, "初步方案"), - - supportingMaterialsFile(58, "附件-佐证材料"), - - projectRemarks(59, "备注"), - processStatusName(60, "流程状态名称"), - processLaunchTime(61,"流程发起时间"), - processHandleTime(62,"流程处理时间"), - - projectStatusName(63,"项目状态名称"), - - createOn(64,"创建时间"), - - updateOn(65,"更新时间"); - - - private Integer code; - private String desc; -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/common/enumeration/IEnum.java b/kqapi/src/main/java/com/ningdatech/kqapi/common/enumeration/IEnum.java deleted file mode 100644 index 93354ee..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/common/enumeration/IEnum.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.ningdatech.kqapi.common.enumeration; - -import java.util.Arrays; -import java.util.Optional; - -/** - *

- * IEnum-通用枚举类接口 - *

- * - * @author WendyYang - * @since 10:10 2024/4/22 - */ -public interface IEnum & IEnum> { - - E[] all(); - - C getCode(); - - V getDesc(); - - default boolean eq(C code) { - return getCode().equals(code); - } - - default Optional getByCode(C code) { - return Arrays.stream(all()) - .filter(w -> w.getCode().equals(code)) - .findFirst(); - } - - default E getNoNull(C code) { - return Arrays.stream(all()) - .filter(w -> w.getCode().equals(code)).findFirst() - .orElseThrow(() -> new IllegalArgumentException("编码对应枚举值不存在")); - } - - default V getDesc(C code) { - return getByCode(code).flatMap(w -> Optional.of(w.getDesc())).orElse(null); - } - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/common/enumeration/ImplSubjectNatureEnum.java b/kqapi/src/main/java/com/ningdatech/kqapi/common/enumeration/ImplSubjectNatureEnum.java deleted file mode 100644 index 7242c52..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/common/enumeration/ImplSubjectNatureEnum.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.ningdatech.kqapi.common.enumeration; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -/** - *

- * ImplSubjectNatureEnum - *

- * - * @author WendyYang - * @since 10:39 2024/4/22 - */ -@Getter -@AllArgsConstructor -public enum ImplSubjectNatureEnum implements IEnum { - - STATUTORY_AUTHORITIES(1, "法定机关"), - THIRD_PARTY_INTERMEDIARIES(2, "第三方中介服务"); - - private final Integer code; - private final String desc; - - - @Override - public ImplSubjectNatureEnum[] all() { - return values(); - } - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/common/enumeration/ProjectProcessStageEnum.java b/kqapi/src/main/java/com/ningdatech/kqapi/common/enumeration/ProjectProcessStageEnum.java deleted file mode 100644 index 8c2d16e..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/common/enumeration/ProjectProcessStageEnum.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.ningdatech.kqapi.common.enumeration; - -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import org.apache.commons.lang3.StringUtils; - -import java.util.Objects; - -@Getter -@AllArgsConstructor -@NoArgsConstructor -public enum ProjectProcessStageEnum { - /** - * 项目流程配置 阶段枚举 - */ - ORG_INTERNAL_APPROVAL_PROCESS(1,"单位内部审批流程"), - PROJECT_PREQUALIFICATION_APPROVAL_PROCESS(2,"项目预审审批流程"), - DEPARTMENT_JOINT_APPROVAL_PROCESS(3,"部门联合审批流程"), - CONSTRUCTION_PROJECT_APPROVAL_PROCESS(4,"建设方案审批流程"), - ACCEPTANCE_DECLARATION_APPROVAL_PROCESS(5,"验收申报审批流程"), - APPLY_DELAY(6,"申请延期审批流程"), - APPLY_BORROW(7,"申请借阅审批流程"); - - private Integer code; - private String desc; - - public static String getDesc(Integer code) { - if (Objects.isNull(code)) { - return StringUtils.EMPTY; - } - for (ProjectProcessStageEnum t : ProjectProcessStageEnum.values()) { - if (code.equals(t.getCode())) { - return t.desc; - } - } - return StringUtils.EMPTY; - } -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/common/errorcode/AppErrorCode.java b/kqapi/src/main/java/com/ningdatech/kqapi/common/errorcode/AppErrorCode.java deleted file mode 100644 index 76df261..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/common/errorcode/AppErrorCode.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.ningdatech.kqapi.common.errorcode; - -import lombok.Getter; - -/** - * @author LiuXinXin - */ -@Getter -public enum AppErrorCode { - USER(100), - - AUTH(101); - - private final Integer code; - - AppErrorCode(Integer code) { - this.code = code; - } - - public Integer getCode() { - return code; - } - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/common/exception/ArgumentException.java b/kqapi/src/main/java/com/ningdatech/kqapi/common/exception/ArgumentException.java deleted file mode 100644 index 16a9ab5..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/common/exception/ArgumentException.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.ningdatech.kqapi.common.exception; - - -import com.ningdatech.kqapi.common.exception.code.ExceptionCode; - -/** - * 业务参数异常 - * 用于在业务中,检测到非法参数时,进行抛出的异常。 - * - * @author WendyYang - * @version 3.5.0 - */ -public class ArgumentException extends BaseUncheckedException { - - private static final long serialVersionUID = -3843907364558373817L; - - public ArgumentException(Throwable cause) { - super(cause); - } - - public ArgumentException(String message) { - super(ExceptionCode.BASE_VALID_PARAM.getCode(), message); - } - - public ArgumentException(String message, Throwable cause) { - super(ExceptionCode.BASE_VALID_PARAM.getCode(), message, cause); - } - - public ArgumentException(final String format, Object... args) { - super(ExceptionCode.BASE_VALID_PARAM.getCode(), format, args); - } - - @Override - public String toString() { - return "ArgumentException [message=" + getMessage() + ", code=" + getCode() + "]"; - } - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/common/exception/BaseCheckedException.java b/kqapi/src/main/java/com/ningdatech/kqapi/common/exception/BaseCheckedException.java deleted file mode 100644 index 2a80406..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/common/exception/BaseCheckedException.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.ningdatech.kqapi.common.exception; - -/** - * 运行期异常基类 - * - * @author WendyYang - * @version 1.0 - */ -public abstract class BaseCheckedException extends Exception implements BaseException { - - private static final long serialVersionUID = 2706069899924648586L; - - /** - * 异常信息 - */ - private String message; - - /** - * 具体异常码 - */ - private int code; - - public BaseCheckedException(final int code, final String message) { - super(message); - this.code = code; - this.message = message; - } - - public BaseCheckedException(final int code, final String format, Object... args) { - super(String.format(format, args)); - this.code = code; - this.message = String.format(format, args); - } - - /** - * 获取 异常消息 - * - * @return 异常消息 - */ - @Override - public String getMessage() { - return message; - } - - - /** - * 获取 错误码 - * - * @return 错误码 - */ - @Override - public int getCode() { - return code; - } - - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/common/exception/BaseException.java b/kqapi/src/main/java/com/ningdatech/kqapi/common/exception/BaseException.java deleted file mode 100644 index 1984e77..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/common/exception/BaseException.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.ningdatech.kqapi.common.exception; - -/** - * 异常接口类 - * - * @author WendyYang - * @version 1.0 - */ -public interface BaseException { - - /** - * 统一参数验证异常码 - */ - int BASE_VALID_PARAM = -9; - - /** - * 返回异常信息 - * - * @return 异常信息 - */ - String getMessage(); - - /** - * 返回异常编码 - * - * @return 异常编码 - */ - int getCode(); - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/common/exception/BaseUncheckedException.java b/kqapi/src/main/java/com/ningdatech/kqapi/common/exception/BaseUncheckedException.java deleted file mode 100644 index 7a848dc..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/common/exception/BaseUncheckedException.java +++ /dev/null @@ -1,65 +0,0 @@ -package com.ningdatech.kqapi.common.exception; - -import cn.hutool.core.util.StrUtil; -import com.ningdatech.kqapi.common.util.StrPool; - -/** - * 非运行期异常基类,所有自定义非运行时异常继承该类 - * - * @author WendyYang - * @version 1.0 - * @see RuntimeException - */ -public class BaseUncheckedException extends RuntimeException implements BaseException { - - private static final long serialVersionUID = -778887391066124051L; - - /** - * 异常信息 - */ - private String message; - - /** - * 具体异常码 - */ - private int code; - - public BaseUncheckedException(Throwable cause) { - super(cause); - } - - public BaseUncheckedException(final int code, Throwable cause) { - super(cause); - this.code = code; - } - - - public BaseUncheckedException(final int code, final String message) { - super(message); - this.code = code; - this.message = message; - } - - public BaseUncheckedException(final int code, final String message, Throwable cause) { - super(cause); - this.code = code; - this.message = message; - } - - public BaseUncheckedException(final int code, final String format, Object... args) { - super(StrUtil.contains(format, StrPool.BRACE) ? StrUtil.format(format, args) : String.format(format, args)); - this.code = code; - this.message = StrUtil.contains(format, StrPool.BRACE) ? StrUtil.format(format, args) : String.format(format, args); - } - - - @Override - public String getMessage() { - return message; - } - - @Override - public int getCode() { - return code; - } -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/common/exception/BizException.java b/kqapi/src/main/java/com/ningdatech/kqapi/common/exception/BizException.java deleted file mode 100644 index 1225466..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/common/exception/BizException.java +++ /dev/null @@ -1,78 +0,0 @@ -package com.ningdatech.kqapi.common.exception; - - -import com.ningdatech.kqapi.common.exception.code.BaseExceptionCode; - -/** - * 业务异常 - * 用于在处理业务逻辑时,进行抛出的异常。 - * - * @author WendyYang - * @version 1.0 - */ -public class BizException extends BaseUncheckedException { - - private static final long serialVersionUID = -3843907364558373817L; - - public BizException(Throwable cause) { - super(cause); - } - - public BizException(int code, Throwable cause) { - super(code, cause); - } - - public BizException(String message) { - super(-1, message); - } - - public BizException(String message, Throwable cause) { - super(-1, message, cause); - } - - public BizException(int code, String message) { - super(code, message); - } - - public BizException(int code, String message, Throwable cause) { - super(code, message, cause); - } - - public BizException(int code, String message, Object... args) { - super(code, message, args); - } - - /** - * 实例化异常 - * - * @param code 自定义异常编码 - * @param message 自定义异常消息 - * @param args 已定义异常参数 - * @return 异常实例 - */ - public static BizException wrap(int code, String message, Object... args) { - return new BizException(code, message, args); - } - - public static BizException wrap(String message, Object... args) { - return new BizException(-1, message, args); - } - - public static BizException validFail(String message, Object... args) { - return new BizException(-9, message, args); - } - - public static BizException wrap(BaseExceptionCode ex) { - return new BizException(ex.getCode(), ex.getMsg()); - } - - public static BizException wrap(BaseExceptionCode ex, Throwable cause) { - return new BizException(ex.getCode(), ex.getMsg(), cause); - } - - @Override - public String toString() { - return "BizException [message=" + getMessage() + ", code=" + getCode() + "]"; - } - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/common/exception/CommonException.java b/kqapi/src/main/java/com/ningdatech/kqapi/common/exception/CommonException.java deleted file mode 100644 index e14a447..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/common/exception/CommonException.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.ningdatech.kqapi.common.exception; - -/** - * 非业务异常 - * 用于在处理非业务逻辑时,进行抛出的异常。 - * - * @author WendyYang - * @version 1.0 - * @see Exception - */ -public class CommonException extends BaseCheckedException { - - - public CommonException(int code, String message) { - super(code, message); - } - - public CommonException(int code, String format, Object... args) { - super(code, format, args); - } - - public CommonException wrap(int code, String format, Object... args) { - return new CommonException(code, format, args); - } - - @Override - public String toString() { - return "BizException [message=" + getMessage() + ", code=" + getCode() + "]"; - } -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/common/exception/DownloadException.java b/kqapi/src/main/java/com/ningdatech/kqapi/common/exception/DownloadException.java deleted file mode 100644 index 0397cff..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/common/exception/DownloadException.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.ningdatech.kqapi.common.exception; - -import com.ningdatech.kqapi.common.exception.code.ExceptionCode; - -/** - *

- * DownloadException - *

- * - * @author WendyYang - * @since 16:02 2024/1/8 - */ -public class DownloadException extends BaseUncheckedException { - - public DownloadException(Throwable cause) { - super(cause); - } - - public DownloadException(String message, Object... args) { - super(ExceptionCode.BAD_REQUEST.getCode(), message, args); - } - - public static DownloadException wrap(String message, Object... args) { - return new DownloadException(message, args); - } - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/common/exception/ExportException.java b/kqapi/src/main/java/com/ningdatech/kqapi/common/exception/ExportException.java deleted file mode 100644 index 16b76bc..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/common/exception/ExportException.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.ningdatech.kqapi.common.exception; - - -import com.ningdatech.kqapi.common.exception.code.ExceptionCode; - -/** - *

- * ExportException - *

- * - * @author WendyYang - * @since 16:02 2024/1/8 - */ -public class ExportException extends BaseUncheckedException { - - public ExportException(Throwable cause) { - super(cause); - } - - public ExportException(String message, Object... args) { - super(ExceptionCode.BAD_REQUEST.getCode(), message, args); - } - - public static ExportException wrap(String message, Object... args) { - return new ExportException(message, args); - } - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/common/exception/ForbiddenException.java b/kqapi/src/main/java/com/ningdatech/kqapi/common/exception/ForbiddenException.java deleted file mode 100644 index f744ca1..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/common/exception/ForbiddenException.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.ningdatech.kqapi.common.exception; - -import com.ningdatech.kqapi.common.exception.code.BaseExceptionCode; -import com.ningdatech.kqapi.common.exception.code.ExceptionCode; - -/** - * 403 禁止访问 - * - * @author WendyYang - * @version 1.0 - */ -public class ForbiddenException extends BaseUncheckedException { - - private static final long serialVersionUID = 1L; - - public ForbiddenException(int code, String message) { - super(code, message); - } - - public static ForbiddenException wrap(BaseExceptionCode ex) { - return new ForbiddenException(ex.getCode(), ex.getMsg()); - } - - public static ForbiddenException wrap(String msg) { - return new ForbiddenException(ExceptionCode.FORBIDDEN.getCode(), msg); - } - - @Override - public String toString() { - return "ForbiddenException [message=" + getMessage() + ", code=" + getCode() + "]"; - } - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/common/exception/UnauthorizedException.java b/kqapi/src/main/java/com/ningdatech/kqapi/common/exception/UnauthorizedException.java deleted file mode 100644 index 3637283..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/common/exception/UnauthorizedException.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.ningdatech.kqapi.common.exception; - - -import com.ningdatech.kqapi.common.exception.code.ExceptionCode; - -/** - * 401 未认证 未登录 - * - * @author WendyYang - * @version 1.0 - */ -public class UnauthorizedException extends BaseUncheckedException { - - private static final long serialVersionUID = 1L; - - public UnauthorizedException(int code, String message) { - super(code, message); - } - - public UnauthorizedException(int code, String message, Throwable cause) { - super(code, message, cause); - } - - public static UnauthorizedException wrap(String msg) { - return new UnauthorizedException(ExceptionCode.UNAUTHORIZED.getCode(), msg); - } - - @Override - public String toString() { - return "UnauthorizedException [message=" + getMessage() + ", code=" + getCode() + "]"; - } - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/common/exception/code/BaseExceptionCode.java b/kqapi/src/main/java/com/ningdatech/kqapi/common/exception/code/BaseExceptionCode.java deleted file mode 100644 index eca67d6..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/common/exception/code/BaseExceptionCode.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.ningdatech.kqapi.common.exception.code; - -/** - * 异常编码 - * - * @author WendyYang - * @date 2017-12-25 13:46 - */ -public interface BaseExceptionCode { - /** - * 异常编码 - * - * @return 异常编码 - */ - int getCode(); - - /** - * 异常消息 - * - * @return 异常消息 - */ - String getMsg(); -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/common/exception/code/ExceptionCode.java b/kqapi/src/main/java/com/ningdatech/kqapi/common/exception/code/ExceptionCode.java deleted file mode 100644 index 6a3ce13..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/common/exception/code/ExceptionCode.java +++ /dev/null @@ -1,103 +0,0 @@ -package com.ningdatech.kqapi.common.exception.code; - - -/** - * 异常编码 - * - * @author WendyYang - * @date 2017-12-13 16:22 - */ -public enum ExceptionCode implements BaseExceptionCode { - - //系统相关 start - SUCCESS(0, "成功"), - SYSTEM_BUSY(-1, "系统繁忙~请稍后再试~"), - SYSTEM_TIMEOUT(-2, "系统维护中~请稍后再试~"), - PARAM_EX(-3, "参数类型解析异常"), - SQL_EX(-4, "运行SQL出现异常"), - NULL_POINT_EX(-5, "空指针异常"), - ILLEGAL_ARGUMENT_EX(-6, "无效参数异常"), - MEDIA_TYPE_EX(-7, "请求类型异常"), - LOAD_RESOURCES_ERROR(-8, "加载资源出错"), - BASE_VALID_PARAM(-9, "统一验证参数异常"), - OPERATION_EX(-10, "操作异常"), - SERVICE_MAPPER_ERROR(-11, "Mapper类转换异常"), - CAPTCHA_ERROR(-12, "验证码校验失败"), - JSON_PARSE_ERROR(-13, "JSON解析异常"), - - - OK(200, "OK"), - BAD_REQUEST(400, "错误的请求"), - /** - * {@code 401 Unauthorized}. 需要重新登录。 - * 该HTTP状态码表示认证错误,它是为了认证设计的,而不是为了授权设计的。收到401响应,表示请求没有被认证—压根没有认证或者认证不正确—但是请重新认证和重试。(一般在响应头部包含一个WWW-Authenticate来描述如何认证)。通常由web服务器返回,而不是web应用。从性质上来说是临时的东西。(服务器要求客户端重试) - * - * @see HTTP/1.1: Authentication, section 3.1 - */ - UNAUTHORIZED(401, "未认证"), - /** 该HTTP状态码是关于授权方面的。从性质上来说是永久的东西,和应用的业务逻辑相关联。它比401更具体,更实际。收到403响应表示服务器完成认证过程,但是客户端请求没有权限去访问要求的资源。 */ - FORBIDDEN(403, "禁止访问"), - /** - * {@code 404 Not Found}. - * - * @see HTTP/1.1: Semantics and Content, section 6.5.4 - */ - NOT_FOUND(404, "没有找到资源"), - METHOD_NOT_ALLOWED(405, "不支持当前请求类型"), - - TOO_MANY_REQUESTS(429, "请求超过次数限制"), - INTERNAL_SERVER_ERROR(500, "内部服务错误"), - BAD_GATEWAY(502, "网关错误"), - GATEWAY_TIMEOUT(504, "网关超时"), - //系统相关 end - - REQUIRED_FILE_PARAM_EX(1001, "请求中必须至少包含一个有效文件"), - - DATA_SAVE_ERROR(2000, "新增数据失败"), - DATA_UPDATE_ERROR(2001, "修改数据失败"), - TOO_MUCH_DATA_ERROR(2002, "批量新增数据过多"), - //jwt token 相关 start - - JWT_BASIC_INVALID(40000, "无效的基本身份验证令牌"), - JWT_TOKEN_EXPIRED(40001, "会话超时,请重新登录"), - JWT_SIGNATURE(40002, "不合法的token,请认真比对 token 的签名"), - JWT_ILLEGAL_ARGUMENT(40003, "缺少token参数"), - JWT_GEN_TOKEN_FAIL(40004, "生成token失败"), - JWT_PARSER_TOKEN_FAIL(40005, "解析用户身份错误,请重新登录!"), - JWT_USER_INVALID(40006, "用户名或密码错误"), - JWT_USER_ENABLED(40007, "用户已经被禁用!"), - JWT_OFFLINE(40008, "您已在另一个设备登录!"), - JWT_NOT_LOGIN(40009, "登录超时,请重新登录!"), - //jwt token 相关 end - - ; - - private final int code; - private String msg; - - ExceptionCode(int code, String msg) { - this.code = code; - this.msg = msg; - } - - @Override - public int getCode() { - return code; - } - - @Override - public String getMsg() { - return msg; - } - - - public ExceptionCode build(String msg, Object... param) { - this.msg = String.format(msg, param); - return this; - } - - public ExceptionCode param(Object... param) { - msg = String.format(msg, param); - return this; - } -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/common/handler/BaseFieldFillHandler.java b/kqapi/src/main/java/com/ningdatech/kqapi/common/handler/BaseFieldFillHandler.java deleted file mode 100644 index cf35c66..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/common/handler/BaseFieldFillHandler.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.ningdatech.kqapi.common.handler; - -import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler; -import com.ningdatech.kqapi.user.util.LoginUserUtil; -import lombok.extern.slf4j.Slf4j; -import org.apache.ibatis.reflection.MetaObject; -import org.springframework.stereotype.Component; - -import java.time.LocalDateTime; - -import static com.ningdatech.kqapi.common.constant.BaseFieldConst.*; - - -/** - *

- * BaseFieldFillHandler - *

- * - * @author WendyYang - * @since 14:36 2024/4/20 - */ -@Slf4j -@Component -public class BaseFieldFillHandler implements MetaObjectHandler { - - private Long getUserId() { - if (LoginUserUtil.isLogin()) { - return LoginUserUtil.getUserId(); - } - return 0L; - } - - @Override - public void insertFill(MetaObject metaObject) { - long userId = getUserId(); - LocalDateTime now = LocalDateTime.now(); - this.fillStrategy(metaObject, CREATE_BY, userId); - this.fillStrategy(metaObject, CREATE_ON, now); - this.fillStrategy(metaObject, UPDATE_BY, userId); - this.fillStrategy(metaObject, UPDATE_ON, now); - } - - @Override - public void updateFill(MetaObject metaObject) { - this.fillStrategy(metaObject, UPDATE_BY, getUserId()); - this.fillStrategy(metaObject, UPDATE_ON, LocalDateTime.now()); - } - -} \ No newline at end of file diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/common/handler/GlobalExceptionHandler.java b/kqapi/src/main/java/com/ningdatech/kqapi/common/handler/GlobalExceptionHandler.java deleted file mode 100644 index 3ff67e0..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/common/handler/GlobalExceptionHandler.java +++ /dev/null @@ -1,70 +0,0 @@ -package com.ningdatech.kqapi.common.handler; - -import com.ningdatech.kqapi.common.exception.BizException; -import com.ningdatech.kqapi.common.model.ApiResponse; -import com.ningdatech.kqapi.common.model.Status; -import lombok.extern.slf4j.Slf4j; -import org.springframework.context.support.DefaultMessageSourceResolvable; -import org.springframework.http.HttpStatus; -import org.springframework.validation.BindException; -import org.springframework.web.bind.MethodArgumentNotValidException; -import org.springframework.web.bind.annotation.ControllerAdvice; -import org.springframework.web.bind.annotation.ExceptionHandler; -import org.springframework.web.bind.annotation.ResponseBody; -import org.springframework.web.bind.annotation.ResponseStatus; -import org.springframework.web.servlet.NoHandlerFoundException; - -import javax.validation.ConstraintViolation; -import javax.validation.ConstraintViolationException; -import java.util.stream.Collectors; - -/** - *

- * GlobalExceptionHandler - *

- * - * @author WendyYang - * @since 15:16 2024/4/20 - */ -@Slf4j -@ControllerAdvice -@ResponseStatus(HttpStatus.BAD_REQUEST) -public class GlobalExceptionHandler { - - @ResponseBody - @ExceptionHandler(value = NoHandlerFoundException.class) - public ApiResponse noHandlerFoundException(NoHandlerFoundException e) { - return ApiResponse.ofStatus(Status.REQUEST_NOT_FOUND); - } - - @ResponseBody - @ExceptionHandler(value = {MethodArgumentNotValidException.class, BindException.class}) - public ApiResponse bindException(BindException e) { - String msg = e.getAllErrors().stream() - .map(DefaultMessageSourceResolvable::getDefaultMessage) - .collect(Collectors.joining(",")); - return ApiResponse.of(Status.BAD_REQUEST.getCode(), msg, null); - } - - @ResponseBody - @ExceptionHandler(value = ConstraintViolationException.class) - public ApiResponse constraintViolationException(ConstraintViolationException e) { - String msg = e.getConstraintViolations().stream() - .map(ConstraintViolation::getMessage) - .collect(Collectors.joining(",")); - return ApiResponse.of(Status.BAD_REQUEST.getCode(), msg, null); - } - - @ResponseBody - @ExceptionHandler(value = Exception.class) - public ApiResponse handlerException(Exception e) { - return ApiResponse.of(Status.BAD_REQUEST.getCode(), e.getMessage(), null); - } - - @ResponseBody - @ExceptionHandler(value = BizException.class) - public ApiResponse bizException(Exception e) { - return ApiResponse.of(Status.BAD_REQUEST.getCode(), e.getMessage(), null); - } - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/common/handler/GlobalResponseHandler.java b/kqapi/src/main/java/com/ningdatech/kqapi/common/handler/GlobalResponseHandler.java deleted file mode 100644 index f6745b9..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/common/handler/GlobalResponseHandler.java +++ /dev/null @@ -1,59 +0,0 @@ -package com.ningdatech.kqapi.common.handler; - -import com.ningdatech.kqapi.common.model.ApiResponse; -import org.springframework.core.MethodParameter; -import org.springframework.http.MediaType; -import org.springframework.http.converter.HttpMessageConverter; -import org.springframework.http.server.ServerHttpRequest; -import org.springframework.http.server.ServerHttpResponse; -import org.springframework.web.bind.annotation.ExceptionHandler; -import org.springframework.web.bind.annotation.RestControllerAdvice; -import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice; - -/** - *

- * GlobalResponseHandler - *

- * - * @author WendyYang - * @since 15:16 2024/4/20 - */ -@RestControllerAdvice(basePackages = { - "com.ningdatech.kqapi.admin.controller", - "com.ningdatech.kqapi.user.controller", - "com.ningdatech.kqapi.security.controller", - "com.ningdatech.kqapi.zzsfw.controller", - "com.ningdatech.kqapi.scheduler.controller" -}) -public class GlobalResponseHandler implements ResponseBodyAdvice { - - private static final String SWAGGER_CLASS_PREFIX = "springfox.documentation"; - - @Override - public boolean supports(MethodParameter methodParameter, - Class> aClass) { - return filter(methodParameter); - } - - @Override - public Object beforeBodyWrite(Object o, MethodParameter methodParameter, - MediaType mediaType, - Class> aClass, - ServerHttpRequest serverHttpRequest, - ServerHttpResponse serverHttpResponse) { - return ApiResponse.ofSuccess(o); - } - - private Boolean filter(MethodParameter methodParameter) { - Class declaringClass = methodParameter.getDeclaringClass(); - // swagger中的所有返回不进行统一封装 - if (declaringClass.getName().contains(SWAGGER_CLASS_PREFIX)) { - return false; - } - if (methodParameter.hasMethodAnnotation(ExceptionHandler.class)) { - return false; - } - // 如果本身就是使用ApiResponse返回,则不需要进行格式化 - return !methodParameter.getParameterType().equals(ApiResponse.class); - } -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/common/handler/MyBatisPlusConfig.java b/kqapi/src/main/java/com/ningdatech/kqapi/common/handler/MyBatisPlusConfig.java deleted file mode 100644 index cf850e0..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/common/handler/MyBatisPlusConfig.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.ningdatech.kqapi.common.handler; - -import com.baomidou.mybatisplus.annotation.DbType; -import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; -import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor; -import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -@Configuration -public class MyBatisPlusConfig { - - /** - * 插件配置 - * - * @return - */ - @Bean - public MybatisPlusInterceptor mybatisPlusInterceptor() { - MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); - - // 向MyBatis-Plus的过滤器链中添加分页拦截器,需要设置数据库类型(主要用于分页方言) -// interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.POSTGRE_SQL)); - interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL)); - // 添加乐观锁拦截器 - interceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor()); - return interceptor; - } -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/common/helper/MatterCacheHelper.java b/kqapi/src/main/java/com/ningdatech/kqapi/common/helper/MatterCacheHelper.java deleted file mode 100644 index 2510de0..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/common/helper/MatterCacheHelper.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.ningdatech.kqapi.common.helper; - - -import com.ningdatech.kqapi.zzsfw.model.entity.KqZzsfwMattersDeduplicate; - -import java.util.List; - -/** - *

- * MatterCacheHelper - - *

- * - * @author ZPF - * @since 13:50 2024/1/3 - */ -public interface MatterCacheHelper { - - KqZzsfwMattersDeduplicate getMatter(String qlName, String webapplyurl); - - String getUrl(String qlName); - - List all(); - - Boolean refreshAll(); -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/common/helper/basic/AbstractMatterCacheHelper.java b/kqapi/src/main/java/com/ningdatech/kqapi/common/helper/basic/AbstractMatterCacheHelper.java deleted file mode 100644 index fc73643..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/common/helper/basic/AbstractMatterCacheHelper.java +++ /dev/null @@ -1,188 +0,0 @@ -package com.ningdatech.kqapi.common.helper.basic; - -import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import com.github.benmanes.caffeine.cache.Caffeine; -import com.github.benmanes.caffeine.cache.LoadingCache; -import com.google.common.collect.Lists; -import com.ningdatech.kqapi.common.constant.BizConst; -import com.ningdatech.kqapi.zzsfw.model.entity.ComponentsMatterEliminateEntity; -import com.ningdatech.kqapi.zzsfw.service.ComponentsMatterEliminateService; -import com.ningdatech.kqapi.zzsfw.model.entity.DscSxAdsShareItemQltQlsxCommonIDVKq; -import com.ningdatech.kqapi.zzsfw.model.entity.MatterKey; -import com.ningdatech.kqapi.zzsfw.model.entity.KqZzsfwMattersDeduplicate; -import com.ningdatech.kqapi.zzsfw.service.IDscSxAdsShareItemQltQlsxCommonIDVKqService; -import com.ningdatech.kqapi.zzsfw.service.IKqZzsfwMatterDeduplicateService; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; -import org.springframework.beans.factory.InitializingBean; -import org.springframework.beans.factory.annotation.Autowired; - -import java.util.List; -import java.util.Objects; -import java.util.concurrent.TimeUnit; -import java.util.stream.Collectors; - -/** - *

- * AbstractMatterCache - *

- * - * @author ZPF - * @since 14:41 2023/3/1 - */ -@Slf4j -public abstract class AbstractMatterCacheHelper implements InitializingBean { - - @Autowired - private IDscSxAdsShareItemQltQlsxCommonIDVKqService kqService; - - @Autowired - private IKqZzsfwMatterDeduplicateService deduplicateService; - - protected LoadingCache mattersDupCache; - - protected LoadingCache mattersUrlCache; - - @Autowired - private ComponentsMatterEliminateService componentsMatterEliminateService; - - private final String KQ_ZZS_BASE_URL = "https://www.zjzwfw.gov.cn/zjservice-fe/#/workguide?localInnerCode=&siteCode=330000000000"; - - private Boolean initMatterCache() { - // 首先,查询ComponentsMatterEliminateEntity中isDelete不为1的qlName列表, 未被剔除 - List eliminatedQlNames = componentsMatterEliminateService.list( - Wrappers.lambdaQuery() - .select(ComponentsMatterEliminateEntity::getQlName) - .ne(ComponentsMatterEliminateEntity::getIsDelete, 1) - ).stream().map(ComponentsMatterEliminateEntity::getQlName).collect(Collectors.toList()); - - // 然后,使用eliminatedQlNames来过滤DscSxAdsShareItemQltQlsxCommonIDVKq查询 - List allMatters = kqService - .list(Wrappers.lambdaQuery() - .select(DscSxAdsShareItemQltQlsxCommonIDVKq::getRowguid, - DscSxAdsShareItemQltQlsxCommonIDVKq::getQlName, - DscSxAdsShareItemQltQlsxCommonIDVKq::getQlState, - DscSxAdsShareItemQltQlsxCommonIDVKq::getQlInnerCode, - DscSxAdsShareItemQltQlsxCommonIDVKq::getWebapplyurl) -// .eq(DscSxAdsShareItemQltQlsxCommonIDVKq::getQlState, "1") - .isNotNull(DscSxAdsShareItemQltQlsxCommonIDVKq::getWebapplyurl) - .isNotNull(DscSxAdsShareItemQltQlsxCommonIDVKq::getQlInnerCode) - .ne(DscSxAdsShareItemQltQlsxCommonIDVKq::getQlInnerCode, "") - .notIn(!eliminatedQlNames.isEmpty(), DscSxAdsShareItemQltQlsxCommonIDVKq::getQlName, eliminatedQlNames) // 过滤掉那些在eliminatedQlNames中的记录 - .orderByDesc(DscSxAdsShareItemQltQlsxCommonIDVKq::getUpdateDate)); - if (allMatters.isEmpty()) { - log.warn("事项数据未初始化"); - return Boolean.FALSE; - } - allMatters.forEach(m -> { - // 3-14日修改新的url匹配规则,取事项状态为1且qlInnerCode不为空的进行拼接,新的url规则如下 - String kq_url = KQ_ZZS_BASE_URL.replace("localInnerCode=", "localInnerCode=" + m.getQlInnerCode()); - MatterKey key = MatterKey.of(m.getQlName(),kq_url); - if(!mattersUrlCache.asMap().containsKey(m.getQlName())){ - mattersUrlCache.put(m.getQlName(),kq_url); - }else{ - String url = mattersUrlCache.get(m.getQlName()); - if(StringUtils.isNotBlank(url) && !url.equals(kq_url)){ - return; - } - } - if(mattersDupCache.asMap().containsKey(key)){ - KqZzsfwMattersDeduplicate dup = mattersDupCache.get(key); - dup.setCountNum(dup.getCountNum() + 1); - mattersDupCache.put(key,dup); - }else{ - mattersDupCache.put(key, KqZzsfwMattersDeduplicate.of(m.getQlName(),kq_url)); - } - }); - return Boolean.TRUE; - } - - protected KqZzsfwMattersDeduplicate get(String qlName, String url) { - MatterKey key = MatterKey.of(qlName, url); - return mattersDupCache.get(key); - } - - protected String getUrl(String qlName) { - return mattersUrlCache.get(qlName); - } - - protected List all() { - return Lists.newArrayList(mattersDupCache.asMap().values()); - } - - @Override - public void afterPropertiesSet() { - mattersUrlCache = Caffeine.newBuilder() - .refreshAfterWrite(7, TimeUnit.DAYS) - .maximumSize(1024 * 100) - .build(key -> { - KqZzsfwMattersDeduplicate dup = deduplicateService.getOne(Wrappers.lambdaQuery(KqZzsfwMattersDeduplicate.class) - .eq(KqZzsfwMattersDeduplicate::getQlName, key) - .last(BizConst.LIMIT_1) - .isNotNull(KqZzsfwMattersDeduplicate::getWebapplyurl)); - if (Objects.isNull(dup)) { - //查不到直接返回null - return null; - } - return dup.getWebapplyurl(); - }); - mattersDupCache = Caffeine.newBuilder() - .refreshAfterWrite(7, TimeUnit.DAYS) - .maximumSize(1024 * 100) - .build(key -> { - KqZzsfwMattersDeduplicate dup = deduplicateService.getOne(Wrappers.lambdaQuery(KqZzsfwMattersDeduplicate.class) - .eq(KqZzsfwMattersDeduplicate::getQlName, key) - .last(BizConst.LIMIT_1) - .isNotNull(KqZzsfwMattersDeduplicate::getWebapplyurl)); - if (Objects.isNull(dup)) { - //查不到直接返回null - return null; - } - return dup; - }); - // 初始化所有事项数据到缓存 -// initMatterCache(); - } - - public Boolean init() { - mattersUrlCache = Caffeine.newBuilder() - .refreshAfterWrite(7, TimeUnit.DAYS) - .maximumSize(1024 * 100) - .build(key -> { -// DscSxAdsShareItemQltQlsxCommonIDVKq matter = kqService.getOne(Wrappers.lambdaQuery(DscSxAdsShareItemQltQlsxCommonIDVKq.class) -// .eq(DscSxAdsShareItemQltQlsxCommonIDVKq::getQlName, key) -//// .eq(DscSxAdsShareItemQltQlsxCommonIDVKq::getQlState, "1") -//// .isNotNull(DscSxAdsShareItemQltQlsxCommonIDVKq::getQlInnerCodeItem) -// .isNotNull(DscSxAdsShareItemQltQlsxCommonIDVKq::getWebapplyurl) -// .orderByDesc(DscSxAdsShareItemQltQlsxCommonIDVKq::getUpdateDate) -// .last(BizConst.LIMIT_1) -// ); - KqZzsfwMattersDeduplicate dup = deduplicateService.getOne(Wrappers.lambdaQuery(KqZzsfwMattersDeduplicate.class) - .eq(KqZzsfwMattersDeduplicate::getQlName, key) - .last(BizConst.LIMIT_1) - .isNotNull(KqZzsfwMattersDeduplicate::getWebapplyurl)); - if (Objects.isNull(dup)) { - //查不到直接返回null - return null; - } - return dup.getWebapplyurl(); -// return "https://www.zjzwfw.gov.cn/zjservice-fe/#/workguide?localInnerCode="+ matter.getQlInnerCodeItem() +"&siteCode=330000000000"; - }); - mattersDupCache = Caffeine.newBuilder() - .refreshAfterWrite(7, TimeUnit.DAYS) - .maximumSize(1024 * 100) - .build(key -> { - KqZzsfwMattersDeduplicate dup = deduplicateService.getOne(Wrappers.lambdaQuery(KqZzsfwMattersDeduplicate.class) - .eq(KqZzsfwMattersDeduplicate::getQlName, key) - .last(BizConst.LIMIT_1) - .isNotNull(KqZzsfwMattersDeduplicate::getWebapplyurl)); - if (Objects.isNull(dup)) { - //查不到直接返回null - return null; - } - return dup; - }); - // 初始化所有事项数据到缓存 - return initMatterCache(); - } -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/common/helper/impl/MattersCacheHelperImpl.java b/kqapi/src/main/java/com/ningdatech/kqapi/common/helper/impl/MattersCacheHelperImpl.java deleted file mode 100644 index 066b5f5..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/common/helper/impl/MattersCacheHelperImpl.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.ningdatech.kqapi.common.helper.impl; - -import com.ningdatech.kqapi.common.helper.MatterCacheHelper; -import com.ningdatech.kqapi.common.helper.basic.AbstractMatterCacheHelper; -import com.ningdatech.kqapi.zzsfw.model.entity.KqZzsfwMattersDeduplicate; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; -import org.springframework.stereotype.Component; - -import java.util.List; - -/** - * @author ZPF - * @date 2024/1/3 上午8:58 - */ -@Slf4j -@Component -public class MattersCacheHelperImpl extends AbstractMatterCacheHelper implements MatterCacheHelper { - - - @Override - public KqZzsfwMattersDeduplicate getMatter(String qlName, String webapplyurl) { - if (StringUtils.isBlank(qlName) || StringUtils.isBlank(webapplyurl)) { - return null; - } - return super.get(qlName, webapplyurl); - } - - @Override - public String getUrl(String qlName) { - if (StringUtils.isBlank(qlName)) { - return null; - } - return super.getUrl(qlName); - } - - @Override - public List all() { - return super.all(); - } - - @Override - public Boolean refreshAll() { - return super.init(); - } -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/common/model/ApiResponse.java b/kqapi/src/main/java/com/ningdatech/kqapi/common/model/ApiResponse.java deleted file mode 100644 index e5968e4..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/common/model/ApiResponse.java +++ /dev/null @@ -1,123 +0,0 @@ -package com.ningdatech.kqapi.common.model; - -import lombok.Data; -import lombok.NoArgsConstructor; - -import java.io.Serializable; - -/** - *

- * ApiResponse - 统一的接口返回值封装 - *

- * - * @author WendyYang - * @since 14:29 2022/9/29 - */ -@Data -@NoArgsConstructor -public class ApiResponse implements Serializable { - private static final long serialVersionUID = 532384723325394156L; - - public static final int SUCCESS_CODE = 200; - - public static final String SUCCESS_MSG = "success"; - - public static final int ERROR_CODE = 500; - - public static final String ERROR_MSG = "Internal server error"; - - /** - * 状态码 - */ - private Integer code; - - /** - * 返回内容 - */ - private String message; - - /** - * 返回数据 - */ - private T data; - - /** - * 全参构造函数 - * - * @param code 状态码 - * @param message 返回内容 - * @param data 返回数据 - */ - private ApiResponse(Integer code, String message, T data) { - this.code = code; - this.message = message; - this.data = data; - } - - /** - * 构造一个自定义的API返回 - * - * @param code 状态码 - * @param message 返回内容 - * @param data 返回数据 - * @return ApiResponse - */ - public static ApiResponse of(Integer code, String message, T data) { - return new ApiResponse(code, message, data); - } - - public static ApiResponse of(Integer code, String message) { - return of(code, message, null); - } - - /** - * 构造一个成功且不带数据的API返回 - * - * @return ApiResponse - */ - public static ApiResponse ofSuccess() { - return ofSuccess(null); - } - - /** - * 构造一个成功且带数据的API返回 - * - * @param data 返回数据 - * @return ApiResponse - */ - public static ApiResponse ofSuccess(T data) { - return ofStatus(Status.OK, data); - } - - /** - * 构造一个成功且自定义消息的API返回 - * - * @param message 返回内容 - * @return ApiResponse - */ - public static ApiResponse ofMessage(String message) { - return of(Status.OK.getCode(), message, null); - } - - /** - * 构造一个有状态的API返回 - * - * @param status 状态 {@link Status} - * @return ApiResponse - */ - public static ApiResponse ofStatus(ApiStatus status) { - return ofStatus(status, null); - } - - /** - * 构造一个有状态且带数据的API返回 - * - * @param status 状态 {@link Status} - * @param data 返回数据 - * @return ApiResponse - */ - public static ApiResponse ofStatus(ApiStatus status, T data) { - return of(status.getCode(), status.getReasonPhrase(), data); - } - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/common/model/ApiStatus.java b/kqapi/src/main/java/com/ningdatech/kqapi/common/model/ApiStatus.java deleted file mode 100644 index d628085..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/common/model/ApiStatus.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.ningdatech.kqapi.common.model; - -/** - *

- * ApiStatus - 通用api状态 - *

- * - * @author WendyYang - * @since 14:44 2022/9/29 - */ -public interface ApiStatus { - /** - * 获取code - * - * @return code - */ - Integer getCode(); - - /** - * 获取短语 - * - * @return 短语 - */ - String getReasonPhrase(); - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/common/model/PagePo.java b/kqapi/src/main/java/com/ningdatech/kqapi/common/model/PagePo.java deleted file mode 100644 index 7670a75..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/common/model/PagePo.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.ningdatech.kqapi.common.model; - -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import lombok.Data; - -/** - *

- * PagePo - 分页请求参数类 - *

- * - * @author WendyYang - * @since 16:29 2022/9/14 - */ -@Data -public class PagePo { - - private Integer pageNumber = 1; - - private Integer pageSize = 10; - - public void page(Integer pageNumber, Integer pageSize) { - this.pageNumber = pageNumber; - this.pageSize = pageSize; - } - - public Page page() { - return Page.of(pageNumber, pageSize); - } - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/common/model/PageVo.java b/kqapi/src/main/java/com/ningdatech/kqapi/common/model/PageVo.java deleted file mode 100644 index 42825e3..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/common/model/PageVo.java +++ /dev/null @@ -1,63 +0,0 @@ -package com.ningdatech.kqapi.common.model; - -import lombok.Data; -import lombok.NoArgsConstructor; - -import java.util.Collection; -import java.util.Collections; - -/** - *

- * PageVo - 分页返回的包装对象 - *

- * - * @author WendyYang - * @since 14:43 2022/9/29 - */ -@Data -@NoArgsConstructor -public class PageVo { - - private Collection records; - private Long total; - - private Boolean hasNextPage; - - public PageVo(Collection records, Boolean hasNextPage) { - this.records = records; - this.hasNextPage = hasNextPage; - } - - public PageVo(Collection records, Long total) { - this.records = records; - this.total = total; - } - - public void setTotal(Long total) { - this.total = total; - } - - public static PageVo of(Collection data, Long total) { - return new PageVo<>(data, total); - } - - public static PageVo of(Collection data, Integer total) { - return new PageVo<>(data, (long) total); - } - - /** - * 移动端无需展示总页码使用 - * - * @param data 分页数据 - * @param hasNextPage 是否有下一页 - * @author WendyYang - **/ - public static PageVo of(Collection data, Boolean hasNextPage) { - return new PageVo<>(data, hasNextPage); - } - - public static PageVo empty() { - return new PageVo<>(Collections.emptyList(), 0L); - } - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/common/model/Status.java b/kqapi/src/main/java/com/ningdatech/kqapi/common/model/Status.java deleted file mode 100644 index 192f7d8..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/common/model/Status.java +++ /dev/null @@ -1,123 +0,0 @@ -package com.ningdatech.kqapi.common.model; - -import lombok.Getter; - -/** - * @description: - * @author: liushuai - * @date: 2022/3/25 11:31 - */ -@Getter -public enum Status implements ApiStatus { - /** - * 正常 - */ - OK(200, "正常"), - /** - * 请求错误 - */ - BAD_REQUEST(400, "请求错误"), - /** - * Unauthorized - */ - NO_AUTHORIZATION(401, "未经授权的"), - /** - * 服务器解析不到用户请求的服务名称 - */ - REQUEST_NOT_FOUND(404, "服务不存在"), - /** - * 未知异常 - */ - UNKNOWN_ERROR(500, "服务器内部错误"), - /** - * 未定义异常 - */ - UNDEFINED(501, "未定义"), - /** - * 未定义异常 - */ - ERROR_PARAM(502, "您输入的参数有非法字符,请输入正确的参数"), - /** - * 该服务已下线 - */ - SERVICES_DISABLED(1, "服务未启用"), - /** - * 请求参数不能为空 - */ - PARAM_NOT_NULL(101, "请求参数不能为空"), - /** - * 字段名重复 - */ - COLUMN_REPEAT(112, "字段名重复,请重新填写"), - /** - * 参数不匹配 - */ - PARAM_NOT_MATCH(102, "参数不匹配"), - /** - * 权限认证参数 - */ - NO_AUT_PARAM(103, "权限参数不存在"), - /** - * 日期格式错误 - */ - DATE_FORMAT_EXCEPTION(104, "日期格式错误"), - /** - * 网络连接异常 - */ - CONNECTION_REFUSED(105, "连接拒绝"), - /** - * 登录失败 - */ - LOGIN_BAD(107, "用户登录失败,请确认用户信息"), - /** - * 流程删除失败 - */ - BAD_DELETE_PROCESS(106,"文件已进入流转流程,删除失败"), - /** - * 无可用端口 - */ - NO_PORT_AVAILABLE(111, "无可用端口"), - /** - * 文件下载异常 - */ - FILE_DOWNLOAD_EXCEPTION(607, "文件下载异常"), - /** - * 文件传输异常 - */ - FILE_TRANS_EXCEPTION(608, "文件传输异常"), - /** - * 文件名不存在 - */ - FILE_NAME_EXCEPTION(609, "文件名不存在"), - /** - * 文件名不存在 - */ - FILE_NAME_REPEAT(610, "文件名重复,请重新上传"), - /** - * 文件名不存在 - */ - FILE_DELETE_FAIL(611, "文件删除异常"), - /** - * 文件名不存在 - */ - FILE_NOT_SUPPORT(612, "不支持的文件类型,请重新上传"), - /** - * 文件名不存在 - */ - FILE_NOT_EXIT(613, "业务文件未上传,请上传业务文件"); - - /** - * 状态码 - */ - private final Integer code; - - /** - * 内容 - */ - private final String reasonPhrase; - - Status(Integer code, String reasonPhrase) { - this.code = code; - this.reasonPhrase = reasonPhrase; - } -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/common/model/entity/Item.java b/kqapi/src/main/java/com/ningdatech/kqapi/common/model/entity/Item.java deleted file mode 100644 index 62739be..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/common/model/entity/Item.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.ningdatech.kqapi.common.model.entity; - -import lombok.Data; - -import javax.swing.*; -import java.io.Serializable; - -/** - * @Classname Item - * @Description - * @Date 2024/3/22 15:34 - * @Author PoffyZhang - */ -@Data -public class Item implements Serializable { - - private String roles; - private String permissions; - - private Boolean success; - - private String code; - - private ItemData data; - - @Data - public static class ItemData { - private Object item; - } -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/common/util/BizUtils.java b/kqapi/src/main/java/com/ningdatech/kqapi/common/util/BizUtils.java deleted file mode 100644 index fc6e3f0..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/common/util/BizUtils.java +++ /dev/null @@ -1,133 +0,0 @@ -package com.ningdatech.kqapi.common.util; - -import cn.hutool.core.text.StrPool; -import cn.hutool.core.util.StrUtil; -import org.apache.commons.lang3.StringUtils; -import org.springframework.util.NumberUtils; - -import java.math.BigDecimal; -import java.math.RoundingMode; -import java.time.LocalDateTime; -import java.time.ZoneId; -import java.util.*; -import java.util.function.Consumer; -import java.util.function.Function; -import java.util.stream.Collectors; - -import static java.util.stream.Collectors.toList; - -/** - *

- * BizUtils - *

- * - * @author WendyYang - * @since 17:32 2023/1/29 - */ -public class BizUtils { - - private BizUtils() { - - } - - public static > void notEmpty(T objs, Consumer consumer) { - if (objs != null && !objs.isEmpty()) { - consumer.accept(objs); - } - } - - public static List splitToNum(String str, Class aClass) { - if (StrUtil.isEmpty(str)) { - return Collections.emptyList(); - } - return Arrays.stream(str.split(StrPool.COMMA)) - .map(w -> NumberUtils.parseNumber(w, aClass)) - .collect(Collectors.toList()); - } - - public static List splitToLong(String str) { - return splitToNum(str, Long.class); - } - - - public static void notNull(T obj, Consumer consumer) { - if (obj != null) { - consumer.accept(obj); - } - } - - public static void notBlank(String str, Consumer consumer) { - if (StrUtil.isNotBlank(str)) { - consumer.accept(str); - } - } - - public static boolean getJSONType(String str) { - boolean result = false; - if (StringUtils.isNotBlank(str)) { - str = str.trim(); - if (str.startsWith("{") && str.endsWith("}")) { - result = true; - } else if (str.startsWith("[") && str.endsWith("]")) { - result = true; - } - } - return result; - } - - public static String uuid32() { - return UUID.randomUUID().toString().replace("-", ""); - } - - /** - * 对象分组取第一条 - * - * @param objs 对象集合 - * @param group 分组函数 - * @param comparator 比较器 - * @return java.util.Collection - * @author WendyYang - **/ - public static Collection groupFirst(Collection objs, Function group, Comparator comparator) { - return groupFirstMap(objs, group, comparator).values(); - } - - /** - * 对象分组取第一条 - * - * @param objs 对象集合 - * @param group 分组函数 - * @param comparator 比较器 - * @return java.util.Collection - * @author WendyYang - **/ - public static Map groupFirstMap(Collection objs, Function group, Comparator comparator) { - return objs.stream().collect(Collectors.groupingBy(group, - Collectors.collectingAndThen(toList(), w -> { - w.sort(comparator); - return w.get(0); - }))); - } - - public static LocalDateTime convertDate(Date date) { - if (Objects.nonNull(date)) { - return date.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime(); - } - return null; - } - - public static String computeRise(Integer numa, Integer numb) { - if((Objects.isNull(numb)|| numb.equals(0)) && - (Objects.isNull(numa)|| numa.equals(0))){ - return "0"; - } - if(Objects.isNull(numa) || numa.equals(0)){ - return "-100"; - } - if(Objects.isNull(numb)|| numb.equals(0)){ - return "100"; - } - return BigDecimal.valueOf((numa - numb) * 100.0).divide(BigDecimal.valueOf(numb),2, RoundingMode.CEILING) - .stripTrailingZeros().toPlainString(); - } -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/common/util/CallBack.java b/kqapi/src/main/java/com/ningdatech/kqapi/common/util/CallBack.java deleted file mode 100644 index 49f2bcd..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/common/util/CallBack.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.ningdatech.kqapi.common.util; - -/** - * @author qinxianyun - * @see {@link SpringContextHolder} - * 针对某些初始化方法,在SpringContextHolder 初始化前时,
- * 可提交一个 提交回调任务。
- * 在SpringContextHolder 初始化后,进行回调使用 - */ - -public interface CallBack { - /** - * 回调执行方法 - */ - void executor(); - - /** - * 本回调任务名称 - * @return / - */ - default String getCallBackName() { - return Thread.currentThread().getId() + ":" + this.getClass().getName(); - } -} - diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/common/util/CodeUtil.java b/kqapi/src/main/java/com/ningdatech/kqapi/common/util/CodeUtil.java deleted file mode 100644 index 2373055..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/common/util/CodeUtil.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.ningdatech.kqapi.common.util; - -import cn.hutool.core.text.StrPool; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; - -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.stream.Collectors; - -/** - * @Classname CodeUtil - * @Description - * @Date 2023/6/20 16:06 - * @Author PoffyZhang - */ -@Slf4j -public class CodeUtil { - - public static Collection convertStrToList(String str) { - if(StringUtils.isBlank(str)){ - return Collections.emptyList(); - } - return Arrays.stream(str.split(StrPool.COMMA)).collect(Collectors.toList()); - } -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/common/util/CommonInputStreamResource.java b/kqapi/src/main/java/com/ningdatech/kqapi/common/util/CommonInputStreamResource.java deleted file mode 100644 index 8e38ea9..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/common/util/CommonInputStreamResource.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.ningdatech.kqapi.common.util; - -import org.springframework.core.io.InputStreamResource; - -import java.io.InputStream; - -public class CommonInputStreamResource extends InputStreamResource { - /*** - * 文件長度 - */ - private int length; - /*** - * 文件名稱 - */ - private String fileName; - public CommonInputStreamResource(InputStream inputStream) { - super(inputStream); - } - public CommonInputStreamResource(InputStream inputStream, int length,String fileName) { - super(inputStream); - this.length = length; - this.fileName = fileName; - } - /** - * 覆写父类方法 - * 如果不重写这个方法,并且文件有一定大小,那么服务端会出现异常 - * {@code The multi-part request contained parameter data (excluding uploaded files) that exceeded} - * - * @return - */ - @Override - public String getFilename() { - return this.fileName; - } - /** - * 覆写父类 contentLength 方法 - * 因为 {@link org.springframework.core.io.AbstractResource#contentLength()}方法会重新读取一遍文件, - * 而上传文件时,restTemplate 会通过这个方法获取大小。然后当真正需要读取内容的时候,发现已经读完,会报如下错误。 - * - * java.lang.IllegalStateException: InputStream has already been read - do not use InputStreamResource if a stream needs to be read multiple times - * at org.springframework.core.io.InputStreamResource.getInputStream(InputStreamResource.java:96) - * - *

- * ref:com.amazonaws.services.s3.model.S3ObjectInputStream#available() - * - * @return - */ - @Override - public long contentLength() { - int estimate = length; - return estimate == 0 ? 1 : estimate; - } -} \ No newline at end of file diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/common/util/CryptUtils.java b/kqapi/src/main/java/com/ningdatech/kqapi/common/util/CryptUtils.java deleted file mode 100644 index 732ea34..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/common/util/CryptUtils.java +++ /dev/null @@ -1,85 +0,0 @@ -package com.ningdatech.kqapi.common.util; - -import org.apache.commons.codec.binary.Hex; - -import javax.crypto.Mac; -import javax.crypto.SecretKey; -import javax.crypto.spec.SecretKeySpec; -import java.nio.charset.Charset; -import java.nio.charset.StandardCharsets; -import java.security.InvalidKeyException; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; - -/** - * 加密工具 - * @author hank - */ -public class CryptUtils { - - /** - * 默认的算法 - */ - private static final String DE_KEY_MAC = "HmacMD5"; - - /** - * 默认的字符集 - */ - private static final Charset DE_CHARSET = StandardCharsets.UTF_8; - - - /** - * 使用默认的算法(HmacMD5) 得到hmac 16进制字符串 - * @param inputStr 需要加密的串 - * @param key key - * @return 16进制字符串 - * @throws Exception - */ - public static String encryptHMAC(String inputStr, String key) throws Exception { - return encryptHMAC(inputStr, key, DE_KEY_MAC); - } - /** - * 使用指定的算法得到hmac 16进制字符串 - * @param inputStr 需要加密的串 - * @param key key - * @param keyMac hmac算法 - * @return 16进制字符串 - * @throws Exception - */ - public static String encryptHMAC(String inputStr, String key, String keyMac) throws Exception { - return Hex.encodeHexString(encryptHMAC(inputStr.getBytes(DE_CHARSET), key, keyMac)); - } - - public static String MD5Encode(String origin) throws NoSuchAlgorithmException { - MessageDigest md = MessageDigest.getInstance("MD5"); - return Hex.encodeHexString(md.digest(origin.getBytes(DE_CHARSET))); - } - - private static byte[] encryptHMAC(byte[] data, String key, String keyMac) throws Exception { - - SecretKey secretKey = new SecretKeySpec(key.getBytes(DE_CHARSET), keyMac); - Mac mac = Mac.getInstance(secretKey.getAlgorithm()); - mac.init(secretKey); - return mac.doFinal(data); - } - - /** - * 生成HMAC-MD5值 - * @param data 消息数据 - * @param key 密钥 - * @return HMAC-MD5值 - * @throws NoSuchAlgorithmException - * @throws InvalidKeyException - */ - public static byte[] hmacMd5(byte[] data, byte[] key) - throws NoSuchAlgorithmException, InvalidKeyException { - SecretKeySpec signingKey = new SecretKeySpec(key, "HmacMD5"); - Mac mac = Mac.getInstance("HmacMD5"); - mac.init(signingKey); - return mac.doFinal(data); - } - - public static void main(String[] args) throws Exception{ - System.out.println("HMACStr:\n" + encryptHMAC("a", "hank")); - } -} \ No newline at end of file diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/common/util/HttpUtil.java b/kqapi/src/main/java/com/ningdatech/kqapi/common/util/HttpUtil.java deleted file mode 100644 index e15b995..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/common/util/HttpUtil.java +++ /dev/null @@ -1,218 +0,0 @@ -package com.ningdatech.kqapi.common.util; - -import org.apache.http.HttpEntity; -import org.apache.http.NameValuePair; -import org.apache.http.client.config.RequestConfig; -import org.apache.http.client.entity.UrlEncodedFormEntity; -import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.conn.ssl.DefaultHostnameVerifier; -import org.apache.http.conn.util.PublicSuffixMatcher; -import org.apache.http.conn.util.PublicSuffixMatcherLoader; -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.util.EntityUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import java.io.IOException; -import java.net.URL; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -public class HttpUtil { - private Logger logger = LoggerFactory.getLogger(getClass()); - private RequestConfig requestConfig = RequestConfig.custom() - .setSocketTimeout(15000) - .setConnectTimeout(15000) - .setConnectionRequestTimeout(15000) - .build(); - private static HttpUtil instance = null; - private HttpUtil(){} - - public static HttpUtil getInstance(){ - if (instance == null) { - instance = new HttpUtil(); - } - return instance; - } - - /** - * 发送 post 请求 - * @param httpUrl 地址 - */ - public String sendHttpPost(String httpUrl) throws IOException { - HttpPost httpPost= new HttpPost(httpUrl);// 创建 httpPost - return sendHttpPost(httpPost); - } - - /** - * 发送 post 请求 - * @param httpUrl 地址 - * @param params 参数(格式:key1=value1&key2=value2) - */ - public String sendHttpPost(String httpUrl, String params) throws IOException { - HttpPost httpPost= new HttpPost(httpUrl);// 创建 httpPost - try { - //设置参数 - StringEntity stringEntity = new StringEntity(params, "UTF-8"); - stringEntity.setContentType("application/x-www-form-urlencoded"); - httpPost.setEntity(stringEntity); - } catch (Exception e) { - logger.error(e.getMessage()); - } - return sendHttpPost(httpPost); - } - - /** - * 发送 post 请求 - * @param httpUrl 地址 - * @param maps 参数 - */ - public String sendHttpPost(String httpUrl, Map maps) throws IOException { - HttpPost httpPost= new HttpPost(httpUrl);// 创建 httpPost - // 创建参数队列 - List nameValuePairs = new ArrayList(); - for (String key : maps.keySet()) { - nameValuePairs.add(new BasicNameValuePair(key, maps.get(key))); - } - try { - httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs, "UTF-8")); - } catch (Exception e) { - logger.error(e.getMessage()); - } - return sendHttpPost(httpPost); - } - - /** - * 发送 Post请求 - * @param httpPost - *@return - */ - private String sendHttpPost(HttpPost httpPost) throws IOException { - CloseableHttpClient httpClient = null; - CloseableHttpResponse response = null; - HttpEntity entity = null; - String responseContent = null; - try { - // 创建默认的 httpClient 实例. - httpClient = HttpClients.createDefault(); - httpPost.setConfig(requestConfig); - // 执行请求 - response = httpClient.execute(httpPost); - entity = response.getEntity(); - responseContent = EntityUtils.toString(entity, "UTF-8"); - } catch (Exception e) { - logger.error(e.getMessage()); - } finally { - httpClient.close(); - try { - // 关闭连接,释放资源 - if (response != null) { - response.close(); - } - if (httpClient != null) { - httpClient.close(); - } - } catch (IOException e) { - logger.error(e.getMessage()); - } - } - return responseContent; - } - - /** - * 发送 get 请求 - * @param httpUrl - */ - public String sendHttpGet(String httpUrl) throws IOException { - HttpGet httpGet = new HttpGet(httpUrl);// 创建 get 请求 - return sendHttpGet(httpGet); - } - - /** - * 发送 get请求 Https - * @param httpUrl - */ - public String sendHttpsGet(String httpUrl) { - HttpGet httpGet = new HttpGet(httpUrl);// 创建 get 请求 - return sendHttpsGet(httpGet); - } - - /** - * 发送 Get请求 - * @param httpGet - *@return - */ - private String sendHttpGet(HttpGet httpGet) throws IOException { - CloseableHttpClient httpClient = null; - CloseableHttpResponse response = null; - HttpEntity entity = null; - String responseContent = null; - try { - // 创建默认的 httpClient 实例. - httpClient = HttpClients.createDefault(); - httpGet.setConfig(requestConfig); - // 执行请求 - response = httpClient.execute(httpGet); - entity = response.getEntity(); - responseContent = EntityUtils.toString(entity, "UTF-8"); - } catch (Exception e) { - logger.error(e.getMessage()); - } finally { - httpClient.close(); - try { - // 关闭连接,释放资源 - if (response != null) { - response.close(); - } - if (httpClient != null) { - httpClient.close(); - } - } catch (IOException e) { - logger.error(e.getMessage()); - } - } - return responseContent; - } - - /** - * 发送 Get请求 Https - *@return - */ - private String sendHttpsGet(HttpGet httpGet) { - CloseableHttpClient httpClient = null; - CloseableHttpResponse response = null; - HttpEntity entity = null; - String responseContent = null; - try { - // 创建默认的 httpClient 实例. - PublicSuffixMatcher publicSuffixMatcher = PublicSuffixMatcherLoader.load(new - URL(httpGet.getURI().toString())); - DefaultHostnameVerifier hostnameVerifier = new DefaultHostnameVerifier(publicSuffixMatcher); - httpClient = HttpClients.custom().setSSLHostnameVerifier(hostnameVerifier).build(); - httpGet.setConfig(requestConfig); - // 执行请求 - response = httpClient.execute(httpGet); - entity = response.getEntity(); - responseContent = EntityUtils.toString(entity, "UTF-8"); - } catch (Exception e) { - logger.error(e.getMessage()); - } finally { - try { - // 关闭连接,释放资源 - if (response != null) { - response.close(); - } - if (httpClient != null) { - httpClient.close(); - } - } catch (IOException e) { - logger.error(e.getMessage()); - } - } - return responseContent; - } -} \ No newline at end of file diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/common/util/Md5Utils.java b/kqapi/src/main/java/com/ningdatech/kqapi/common/util/Md5Utils.java deleted file mode 100644 index a91580b..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/common/util/Md5Utils.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.ningdatech.kqapi.common.util; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.nio.charset.StandardCharsets; -import java.security.MessageDigest; - -public class Md5Utils { - private static final Logger LOGGER = LoggerFactory.getLogger(Md5Utils.class); - - public static byte[] md5(String s) { - MessageDigest algorithm; - try { - algorithm = MessageDigest.getInstance("MD5"); - algorithm.reset(); - algorithm.update(s.getBytes(StandardCharsets.UTF_8)); - return algorithm.digest(); - } catch (Exception e) { - LOGGER.error("MD5 Error...",e.getMessage()); - } - return null; - } - - private static String toHex(byte[] hash) { - if (hash == null) { - return null; - } - StringBuilder buf = new StringBuilder(hash.length * 2); - int i; - for (i = 0; i < hash.length; i++) { - if ((hash[i] & 0xff) < 0x10) { - buf.append("0"); - } - buf.append(Long.toString(hash[i] & 0xff, 16)); - } - return buf.toString(); - } - - public static String hash(String s) { - try { - String hex = toHex(md5(s)); - if (hex == null) { - return s; - } - return new String(hex.getBytes(StandardCharsets.UTF_8), StandardCharsets.UTF_8); - } catch (Exception e) { - LOGGER.error("not supported charset:", e.getMessage()); - return s; - } - } -} \ No newline at end of file diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/common/util/NdDateUtils.java b/kqapi/src/main/java/com/ningdatech/kqapi/common/util/NdDateUtils.java deleted file mode 100644 index 793983a..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/common/util/NdDateUtils.java +++ /dev/null @@ -1,898 +0,0 @@ -package com.ningdatech.kqapi.common.util; - -import cn.hutool.core.convert.Convert; -import cn.hutool.core.date.LocalDateTimeUtil; -import cn.hutool.core.util.StrUtil; -import com.ningdatech.kqapi.common.exception.BizException; -import lombok.extern.slf4j.Slf4j; - -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.time.*; -import java.time.format.DateTimeFormatter; -import java.time.temporal.ChronoUnit; -import java.util.*; -import java.util.stream.Stream; - -import static cn.hutool.core.date.DatePattern.*; - -/** - * 描述:日期工具类 - * - * @author WendyYang - * 修改时间:2018/4/24 - */ -@Slf4j -public final class NdDateUtils { - public static final String DEFAULT_YEAR_FORMAT = "yyyy"; - public static final String DEFAULT_MONTH_FORMAT = "yyyy-MM"; - public static final String DEFAULT_MONTH_FORMAT_SLASH = "yyyy/MM"; - public static final String DEFAULT_MONTH_FORMAT_EN = "yyyy年MM月"; - public static final String DEFAULT_WEEK_FORMAT = "yyyy-ww"; - public static final String DEFAULT_WEEK_FORMAT_EN = "yyyy年ww周"; - public static final String DEFAULT_DATE_FORMAT = NORM_DATE_PATTERN; - public static final String DEFAULT_DATE_FORMAT_EN = CHINESE_DATE_PATTERN; - public static final String DEFAULT_DATE_TIME_FORMAT = NORM_DATETIME_PATTERN; - public static final String DEFAULT_DATE_TIME_START_FORMAT = "yyyy-MM-dd 00:00:00"; - public static final String DEFAULT_DATE_TIME_END_FORMAT = "yyyy-MM-dd 23:59:59"; - public static final String DEFAULT_DATE_TIME_FORMAT_EN = CHINESE_DATE_TIME_PATTERN; - public static final String DEFAULT_TIME_FORMAT = NORM_TIME_PATTERN; - public static final String DAY = "DAY"; - public static final String MONTH = "MONTH"; - public static final String WEEK = "WEEK"; - - public static final String DEFAULT_DATE_FORMAT_MATCHES = "^\\d{4}-\\d{1,2}-\\d{1,2}$"; - public static final String DEFAULT_DATE_TIME_FORMAT_MATCHES = "^\\d{4}-\\d{1,2}-\\d{1,2} {1}\\d{1,2}:\\d{1,2}:\\d{1,2}$"; - public static final String DEFAULT_DATE_FORMAT_EN_MATCHES = "^\\d{4}年\\d{1,2}月\\d{1,2}日$"; - public static final String DEFAULT_DATE_TIME_FORMAT_EN_MATCHES = "^\\d{4}年\\d{1,2}月\\d{1,2}日\\d{1,2}时\\d{1,2}分\\d{1,2}秒$"; - public static final String SLASH_DATE_FORMAT_MATCHES = "^\\d{4}/\\d{1,2}/\\d{1,2}$"; - public static final String SLASH_DATE_TIME_FORMAT_MATCHES = "^\\d{4}/\\d{1,2}/\\d{1,2} {1}\\d{1,2}:\\d{1,2}:\\d{1,2}$"; - public static final String SLASH_DATE_FORMAT = "yyyy/MM/dd"; - public static final String SLASH_DATE_TIME_FORMAT = "yyyy/MM/dd HH:mm:ss"; - public static final String CRON_FORMAT = "ss mm HH dd MM ? yyyy"; - - /** - * 一个月平均天数 - */ - public static final long MAX_MONTH_DAY = 30; - /** - * 3个月平均天数 - */ - public static final long MAX_3_MONTH_DAY = 90; - /** - * 一年平均天数 - */ - public static final long MAX_YEAR_DAY = 365; - private static final Map DATE_FORMAT = new LinkedHashMap<>(5); - - //---------------------------------------------------格式化日期start------------------------------------------------- - - static { - DATE_FORMAT.put(DEFAULT_DATE_FORMAT, DEFAULT_DATE_FORMAT_MATCHES); - DATE_FORMAT.put(SLASH_DATE_FORMAT, SLASH_DATE_FORMAT_MATCHES); - DATE_FORMAT.put(DEFAULT_DATE_FORMAT_EN, DEFAULT_DATE_FORMAT_EN_MATCHES); - } - - private NdDateUtils() { - } - - /** - * 将字符串解析LocalDate - * - * @param source 源参数 - * 支持以下格式: - * yyyy-MM-dd - * yyyy/MM/dd - * yyyy年MM月dd日 - * @return 日期 - */ - public static LocalDate parse(String source) { - String sourceTrim = source.trim(); - Set> entries = DATE_FORMAT.entrySet(); - for (Map.Entry entry : entries) { - if (sourceTrim.matches(entry.getValue())) { - return LocalDate.parse(source, DateTimeFormatter.ofPattern(entry.getKey())); - } - } - throw BizException.wrap("解析日期失败, 请传递正确的日期格式"); - } - - - /** - * 转换 Date 为 cron , eg: "0 07 10 15 1 ? 2016" - * - * @param date 时间点 - * @return cron 表达式 - */ - public static String getCron(Date date) { - return format(date, CRON_FORMAT); - } - - /** - * 转换 LocalDateTime 为 cron , eg. "0 07 10 15 1 ? 2016" - * - * @param date 时间点 - * @return cron 表达式 - */ - public static String getCron(LocalDateTime date) { - return format(date, CRON_FORMAT); - } - - /** - * 格式化日期,返回格式为 yyyy-MM - * - * @param date 日期 - * @return 格式化后的字符串 - */ - public static String format(LocalDateTime date, String pattern) { - if (date == null) { - date = LocalDateTime.now(); - } - if (pattern == null) { - pattern = DEFAULT_MONTH_FORMAT; - } - return date.format(DateTimeFormatter.ofPattern(pattern)); - } - - public static String format(LocalDate date, String pattern) { - if (date == null) { - date = LocalDate.now(); - } - if (pattern == null) { - pattern = DEFAULT_MONTH_FORMAT; - } - return date.format(DateTimeFormatter.ofPattern(pattern)); - } - - /** - * 根据传入的格式格式化日期.默认格式为MM月dd日 - * - * @param d 日期 - * @param f 格式 - * @return 格式化后的字符串 - */ - public static String format(Date d, String f) { - Date date = d; - String format = f; - if (date == null) { - date = new Date(); - } - if (format == null) { - format = DEFAULT_DATE_TIME_FORMAT; - } - SimpleDateFormat df = new SimpleDateFormat(format); - return df.format(date); - } - - /** - * 格式化日期,返回格式为 yyyy-MM-dd - * - * @param date 日期 - * @return 格式化后的字符串 - */ - public static String formatAsDate(LocalDateTime date) { - return format(date, DEFAULT_DATE_FORMAT); - } - - public static String formatAsDate(LocalDate date) { - return format(date, DEFAULT_DATE_FORMAT); - } - - public static String formatAsDateEn(LocalDateTime date) { - return format(date, DEFAULT_DATE_FORMAT_EN); - } - - - public static String formatAsYearMonth(LocalDateTime date) { - return format(date, DEFAULT_MONTH_FORMAT); - } - - public static String formatAsYearMonthEn(LocalDateTime date) { - return format(date, DEFAULT_MONTH_FORMAT_EN); - } - - /** - * 格式化日期,返回格式为 yyyy-ww - * - * @param date 日期 - * @return 格式化后的字符串 - */ - public static String formatAsYearWeek(LocalDateTime date) { - return format(date, DEFAULT_WEEK_FORMAT); - } - - public static String formatAsYearWeekEn(LocalDateTime date) { - return format(date, DEFAULT_WEEK_FORMAT_EN); - } - - /** - * 格式化日期,返回格式为 yyyy-MM - * - * @param date 日期 - * @return 格式化后的字符串 - */ - public static String formatAsYearMonth(Date date) { - SimpleDateFormat df = new SimpleDateFormat(DEFAULT_MONTH_FORMAT); - return df.format(date); - } - - /** - * 格式化日期,返回格式为 yyyy-ww - * - * @param date 日期 - * @return 格式化后的字符串 - */ - public static String formatAsYearWeek(Date date) { - SimpleDateFormat df = new SimpleDateFormat(DEFAULT_WEEK_FORMAT); - return df.format(date); - } - - /** - * 格式化日期,返回格式为 HH:mm:ss 例:12:24:24 - * - * @param date 日期 - * @return 格式化后的字符串 - */ - public static String formatAsTime(Date date) { - SimpleDateFormat df = new SimpleDateFormat(DEFAULT_TIME_FORMAT); - return df.format(date); - } - - /** - * 格式化日期,返回格式为 yyyy-MM-dd - * - * @param date 日期 - * @return 格式化后的字符串 - */ - public static String formatAsDate(Date date) { - SimpleDateFormat df = new SimpleDateFormat(DEFAULT_DATE_FORMAT); - return df.format(date); - } - - /** - * 格式化日期,返回格式为 yyyy-MM-dd HH:mm:ss - * - * @param date 日期 - * @return 格式化后的字符串 - */ - public static String formatAsDateTime(Date date) { - SimpleDateFormat df = new SimpleDateFormat(DEFAULT_DATE_TIME_FORMAT); - return df.format(date); - } - - /** - * 格式化日期,返回格式为 dd ,即对应的天数. - * - * @param date 日期 - * @return 格式化后的字符串 - */ - public static String formatAsDay(Date date) { - SimpleDateFormat df = new SimpleDateFormat("dd"); - return df.format(date); - } - - //--格式化日期end----------------------------------------- - - //--解析日期start----------------------------------------- - - /** - * 将字符转换成日期 - * - * @param dateStr 日期字符串 - * @param format 解析格式 - * @return 解析后的日期 - */ - public static Date parse(String dateStr, String format) { - Date date = null; - SimpleDateFormat dateFormat = new SimpleDateFormat(format); - dateFormat.setLenient(false); - try { - date = dateFormat.parse(dateStr); - - } catch (Exception e) { - log.info("DateUtils error", e); - } - return date; - } - - /** - * 获取当月最后一天 - * - * @param date 日期 - * @return 当月最后一天 - */ - public static Date getLastDateOfMonth(Date date) { - Calendar calendar = Calendar.getInstance(); - calendar.setTime(date); - calendar.add(Calendar.MONTH, 1); - calendar.set(Calendar.DAY_OF_MONTH, 0); - return calendar.getTime(); - } - - /** - * 根据传入的String返回对应的date - * - * @param source 日期字符串 - * @return 日期 - */ - public static Date parseAsDate(String source) { - String sourceTrim = source.trim(); - Set> entries = DATE_FORMAT.entrySet(); - try { - for (Map.Entry entry : entries) { - if (sourceTrim.matches(entry.getValue())) { - return new SimpleDateFormat(entry.getKey()).parse(source); - } - } - } catch (ParseException e) { - throw BizException.wrap("解析日期失败, 请传递正确的日期格式"); - } - throw BizException.wrap("解析日期失败, 请传递正确的日期格式"); - } - - /** - * 按给定参数返回Date对象 - * - * @param dateTime 时间对象格式为("yyyy-MM-dd HH:mm:ss"); - * @return 解析后的日期 - */ - public static Date parseAsDateTime(String dateTime) { - SimpleDateFormat simpledateformat = new SimpleDateFormat(DEFAULT_DATE_TIME_FORMAT); - try { - return simpledateformat.parse(dateTime); - } catch (ParseException e) { - return null; - } - } - - /** - * 获取指定日期的开始时间 - * 如:00:00:00 - * - * @param value 日期 - * @return 解析后的日期 - */ - public static Date getDate0000(LocalDateTime value) { - return getDate0000(value.toLocalDate()); - } - - /** - * 获取指定日期的开始时间 - * 如:00:00:00 - * - * @param value 日期 - * @return 解析后的日期 - */ - public static Date getDate0000(Date value) { - return getDate0000(NdDateUtils.date2LocalDate(value)); - } - - /** - * 获取指定日期的开始时间 - * 如:00:00:00 - * - * @param value 日期 - * @return 解析后的日期 - */ - public static Date getDate0000(LocalDate value) { - LocalDateTime todayStart = LocalDateTime.of(value, LocalTime.MIN); - return NdDateUtils.localDateTime2Date(todayStart); - } - - /** - * 获取指定日期的结束时间 - * 如:23:59:59 - * - * @param value 日期 - * @return 解析后的日期 - */ - public static Date getDate2359(LocalDateTime value) { - return getDate2359(value.toLocalDate()); - - } - - /** - * 获取指定日期的结束时间 - * 如:23:59:59 - * - * @param value 日期 - * @return 解析后的日期 - */ - public static Date getDate2359(Date value) { - return getDate2359(NdDateUtils.date2LocalDate(value)); - } - - /** - * 获取指定日期的结束时间 - * 如:23:59:59 - * - * @param value 日期 - * @return 解析后的日期 - */ - public static Date getDate2359(LocalDate value) { - LocalDateTime dateEnd = LocalDateTime.of(value, LocalTime.MAX); - return NdDateUtils.localDateTime2Date(dateEnd); - } - - /** - * LocalDateTime转换为Date - * - * @param localDateTime 日期 - * @return 解析后的日期 - */ - public static Date localDateTime2Date(LocalDateTime localDateTime) { - ZoneId zoneId = ZoneId.systemDefault(); - ZonedDateTime zdt = localDateTime.atZone(zoneId); - return Date.from(zdt.toInstant()); - } - - //--解析日期 end----------------------------------------- - - - /** - * Date转换为LocalDateTime - * - * @param date 日期 - */ - public static LocalDateTime date2LocalDateTime(Date date) { - if (date == null) { - return LocalDateTime.now(); - } - Instant instant = date.toInstant(); - ZoneId zoneId = ZoneId.systemDefault(); - return instant.atZone(zoneId).toLocalDateTime(); - } - - /** - * 日期转 LocalDate - * - * @param date 日期 - * @return 解析后的日期 - */ - public static LocalDate date2LocalDate(Date date) { - if (date == null) { - return LocalDate.now(); - } - Instant instant = date.toInstant(); - ZoneId zoneId = ZoneId.systemDefault(); - return instant.atZone(zoneId).toLocalDate(); - } - - /** - * 日期转 LocalTime - * - * @param date 日期 - * @return 解析后的日期 - */ - public static LocalTime date2LocalTime(Date date) { - if (date == null) { - return LocalTime.now(); - } - Instant instant = date.toInstant(); - ZoneId zoneId = ZoneId.systemDefault(); - return instant.atZone(zoneId).toLocalTime(); - } - - - /** - * 毫秒转日期 - * - * @param epochMilli 毫秒 - * @return 解析后的日期 - */ - public static LocalDateTime getDateTimeOfTimestamp(long epochMilli) { - Instant instant = Instant.ofEpochMilli(epochMilli); - return LocalDateTime.ofInstant(instant, ZoneId.systemDefault()); - } - - /** - * 秒转日期 - * - * @param epochSecond 秒 - * @return 解析后的日期 - */ - public static LocalDateTime getDateTimeOfSecond(long epochSecond) { - Instant instant = Instant.ofEpochSecond(epochSecond); - return LocalDateTime.ofInstant(instant, ZoneId.systemDefault()); - } - - //-计算日期 start------------------------------------------ - - - /** - * 计算结束时间与当前时间间隔的天数 - * - * @param endDate 结束日期 - * @return 计算结束时间与当前时间间隔的天数 - */ - public static long until(Date endDate) { - return LocalDateTime.now().until(date2LocalDateTime(endDate), ChronoUnit.DAYS); - } - - /** - * 计算结束时间与开始时间间隔的天数 - * - * @param startDate 开始日期 - * @param endDate 结束日期 - * @return 计算结束时间与开始时间间隔的天数 - */ - public static long until(Date startDate, Date endDate) { - return date2LocalDateTime(startDate).until(date2LocalDateTime(endDate), ChronoUnit.DAYS); - } - - - /** - * 计算结束时间与开始时间间隔的天数 - * - * @param startDate 开始日期 - * @param endDate 结束日期 - * @return 计算结束时间与开始时间间隔的天数 - */ - public static long until(LocalDateTime startDate, LocalDateTime endDate) { - return startDate.until(endDate, ChronoUnit.DAYS); - } - - public static long until(LocalDate startDate, LocalDate endDate) { - return startDate.until(endDate, ChronoUnit.DAYS); - } - - /** - * 计算2个日期之间的所有的日期 yyyy-MM-dd - * 含头含尾 - * - * @param start yyyy-MM-dd - * @param end yyyy-MM-dd - * @return 日期区间的所有日期 - */ - public static List getBetweenDay(Date start, Date end) { - return getBetweenDay(date2LocalDate(start), date2LocalDate(end)); - } - - /** - * 计算2个日期之间的所有的日期 yyyy-MM-dd - * 含头含尾 - * - * @param start yyyy-MM-dd - * @param end yyyy-MM-dd - */ - public static List getBetweenDay(String start, String end) { - return getBetweenDay(LocalDate.parse(start), LocalDate.parse(end)); - } - - /** - * 计算2个日期之间的所有的日期 yyyy-MM-dd - * 含头含尾 - * - * @param startDate yyyy-MM-dd - * @param endDate yyyy-MM-dd - */ - public static List getBetweenDay(LocalDate startDate, LocalDate endDate) { - return getBetweenDay(startDate, endDate, DEFAULT_DATE_FORMAT); - } - - public static List getBetweenDayEn(LocalDate startDate, LocalDate endDate) { - return getBetweenDay(startDate, endDate, DEFAULT_DATE_FORMAT_EN); - } - - public static List getBetweenDay(LocalDate startDate, LocalDate endDate, String pattern) { - if (pattern == null) { - pattern = DEFAULT_DATE_FORMAT; - } - List list = new ArrayList<>(); - long distance = ChronoUnit.DAYS.between(startDate, endDate); - if (distance < 1) { - return list; - } - String finalPattern = pattern; - Stream.iterate(startDate, d -> d.plusDays(1)). - limit(distance + 1) - .forEach(f -> list.add(f.format(DateTimeFormatter.ofPattern(finalPattern)))); - return list; - } - - - /** - * 计算2个日期之间的所有的周 yyyy-ww - * 含头含尾 - * - * @param start yyyy-MM-dd - * @param end yyyy-MM-dd - */ - public static List getBetweenWeek(Date start, Date end) { - return getBetweenWeek(date2LocalDate(start), date2LocalDate(end)); - } - - /** - * 计算2个日期之间的所有的周 yyyy-ww - * 含头含尾 - * - * @param start yyyy-MM-dd - * @param end yyyy-MM-dd - * @return 2个日期之间的所有的周 - */ - public static List getBetweenWeek(String start, String end) { - return getBetweenWeek(LocalDate.parse(start), LocalDate.parse(end)); - } - - /** - * 计算2个日期之间的所有的周 yyyy-ww - * 含头含尾 - * - * @param startDate yyyy-MM-dd - * @param endDate yyyy-MM-dd - * @return 2个日期之间的所有的周 - */ - public static List getBetweenWeek(LocalDate startDate, LocalDate endDate) { - return getBetweenWeek(startDate, endDate, DEFAULT_WEEK_FORMAT); - } - - public static List getBetweenWeek(LocalDate startDate, LocalDate endDate, String pattern) { - List list = new ArrayList<>(); - - long distance = ChronoUnit.WEEKS.between(startDate, endDate); - if (distance < 1) { - return list; - } - Stream.iterate(startDate, d -> d.plusWeeks(1)). - limit(distance + 1).forEach(f -> list.add(f.format(DateTimeFormatter.ofPattern(pattern)))); - return list; - } - - /** - * 计算2个日期之间的所有的月 yyyy-MM - * - * @param start yyyy-MM-dd - * @param end yyyy-MM-dd - * @return 2个日期之间的所有的月 - */ - public static List getBetweenMonth(Date start, Date end) { - return getBetweenMonth(date2LocalDate(start), date2LocalDate(end)); - } - - /** - * 计算2个日期之间的所有的月 yyyy-MM - * - * @param start yyyy-MM-dd - * @param end yyyy-MM-dd - * @return 2个日期之间的所有的月 - */ - public static List getBetweenMonth(String start, String end) { - return getBetweenMonth(LocalDate.parse(start), LocalDate.parse(end)); - } - - /** - * 计算2个日期之间的所有的月 yyyy-MM - * - * @param startDate yyyy-MM-dd - * @param endDate yyyy-MM-dd - * @return 2个日期之间的所有的月 - */ - public static List getBetweenMonth(LocalDate startDate, LocalDate endDate) { - return getBetweenMonth(startDate, endDate, DEFAULT_MONTH_FORMAT); - } - - public static List getBetweenMonth(LocalDate startDate, LocalDate endDate, String pattern) { - List list = new ArrayList<>(); - long distance = ChronoUnit.MONTHS.between(startDate, endDate); - if (distance < 1) { - return list; - } - - Stream.iterate(startDate, d -> d.plusMonths(1)) - .limit(distance + 1) - .forEach(f -> list.add(f.format(DateTimeFormatter.ofPattern(pattern)))); - return list; - } - - /** - * 计算时间区间内的日期列表,并返回 - * - * @param startTime 开始 - * @param endTime 结束 - * @param dateList 日期 - * @return 计算时间区间内的日期列表 - */ - public static String calculationEn(LocalDateTime startTime, LocalDateTime endTime, List dateList) { - if (startTime == null) { - startTime = LocalDateTime.now(); - } - if (endTime == null) { - endTime = LocalDateTime.now().plusDays(30); - } - return calculationEn(startTime.toLocalDate(), endTime.toLocalDate(), dateList); - } - - public static String calculation(LocalDate startDate, LocalDate endDate, List dateList) { - if (startDate == null) { - startDate = LocalDate.now(); - } - if (endDate == null) { - endDate = LocalDate.now().plusDays(30); - } - if (dateList == null) { - dateList = new ArrayList<>(); - } - long day = until(startDate, endDate); - - String dateType; - if (day >= 0 && day <= MAX_MONTH_DAY) { - dateType = DAY; - dateList.addAll(NdDateUtils.getBetweenDay(startDate, endDate, DEFAULT_DATE_FORMAT)); - } else if (day > MAX_MONTH_DAY && day <= MAX_3_MONTH_DAY) { - dateType = WEEK; - dateList.addAll(NdDateUtils.getBetweenWeek(startDate, endDate, DEFAULT_WEEK_FORMAT)); - } else if (day > MAX_3_MONTH_DAY && day <= MAX_YEAR_DAY) { - dateType = MONTH; - dateList.addAll(NdDateUtils.getBetweenMonth(startDate, endDate, DEFAULT_MONTH_FORMAT)); - } else { - throw new BizException("日期参数只能介于0-365天之间"); - } - return dateType; - } - - public static String calculationEn(LocalDate startDate, LocalDate endDate, List dateList) { - if (startDate == null) { - startDate = LocalDate.now(); - } - if (endDate == null) { - endDate = LocalDate.now().plusDays(30); - } - if (dateList == null) { - dateList = new ArrayList<>(); - } - long day = until(startDate, endDate); - - String dateType; - if (day >= 0 && day <= MAX_MONTH_DAY) { - dateType = DAY; - dateList.addAll(NdDateUtils.getBetweenDay(startDate, endDate, DEFAULT_DATE_FORMAT_EN)); - } else if (day > MAX_MONTH_DAY && day <= MAX_3_MONTH_DAY) { - dateType = WEEK; - dateList.addAll(NdDateUtils.getBetweenWeek(startDate, endDate, DEFAULT_WEEK_FORMAT_EN)); - } else if (day > MAX_3_MONTH_DAY && day <= MAX_YEAR_DAY) { - dateType = MONTH; - dateList.addAll(NdDateUtils.getBetweenMonth(startDate, endDate, DEFAULT_MONTH_FORMAT_EN)); - } else { - throw new BizException("日期参数只能介于0-365天之间"); - } - return dateType; - } - -//----------//----------//----------//----------//----------//----------//----------//----------//----------//----------//---------- - - /** - * 计算开始时间 - * - * @param time 日期 - * @return 计算开始时间 - */ - public static LocalDateTime getStartTime(String time) { - String startTime = time; - if (time.matches("^\\d{4}-\\d{1,2}$")) { - startTime = time + "-01 00:00:00"; - } else if (time.matches("^\\d{4}-\\d{1,2}-\\d{1,2}$")) { - startTime = time + " 00:00:00"; - } else if (time.matches("^\\d{4}-\\d{1,2}-\\d{1,2} \\d{1,2}:\\d{1,2}$")) { - startTime = time + ":00"; - } else if (time.matches("^\\d{4}-\\d{1,2}-\\d{1,2}T\\d{1,2}:\\d{1,2}:\\d{1,2}.\\d{3}Z$")) { - startTime = time.replace("T", " ").substring(0, time.indexOf('.')); - } - return LocalDateTimeUtil.beginOfDay(LocalDateTime.parse(startTime, DateTimeFormatter.ofPattern(DEFAULT_DATE_TIME_FORMAT))); - } - - /** - * 计算结束时间 - * - * @param time 日期 - * @return 结束时间 精确到毫秒 - */ - public static LocalDateTime getEndTime(String time) { - String startTime = time; - if (time.matches("^\\d{4}-\\d{1,2}$")) { - Date date = NdDateUtils.parse(time, "yyyy-MM"); - date = NdDateUtils.getLastDateOfMonth(date); - startTime = NdDateUtils.formatAsDate(date) + " 23:59:59"; - } else if (time.matches("^\\d{4}-\\d{1,2}-\\d{1,2}$")) { - startTime = time + " 23:59:59"; - } else if (time.matches("^\\d{4}-\\d{1,2}-\\d{1,2} \\d{1,2}:\\d{1,2}$")) { - startTime = time + ":59"; - } else if (time.matches("^\\d{4}-\\d{1,2}-\\d{1,2}T\\d{1,2}:\\d{1,2}:\\d{1,2}.\\d{3}Z$")) { - time = time.replace("T", " ").substring(0, time.indexOf('.')); - startTime = time; - } - - return endOfDay(LocalDateTime.parse(startTime, DateTimeFormatter.ofPattern(DEFAULT_DATE_TIME_FORMAT))); - } - - public static LocalDateTime endOfDay(LocalDateTime time) { - return time.with(LocalTime.of(23, 59, 59, 999_999_000)); - } - - /** - * 判断当前时间是否在指定时间范围 - * - * @param from 开始时间 - * @param to 结束时间 - * @return 结果 - */ - public static boolean between(LocalTime from, LocalTime to) { - if (from == null) { - throw new IllegalArgumentException("开始时间不能为空"); - } - if (to == null) { - throw new IllegalArgumentException("结束时间不能为空"); - } - LocalTime now = LocalTime.now(); - return now.isAfter(from) && now.isBefore(to); - } - - /** - * 转换日期 - *

- * 0: 今天结束的日期 - * 1m: 1分钟后的日期 - * 1h: 1小时后的日期 - * 4d: 4天后的日期 - * 2w: 2周后的日期 - * 3M: 3个月后的日期 - * 5y: 5年后的日期 - * - * @param dateTime 待转换日期 - * @param time 转换格式 如: - * 0 当天23:59:59 - * 1s 1秒后 - * 3m 3分钟后 - * 2w 2周后 - * 1h 1小时后 - * 2H 2小时后 - * 4d 4天后 - * 5M 5月后 - * 6y 6年后 - * @return 日期 - */ - public static LocalDateTime conversionDateTime(LocalDateTime dateTime, String time) { - if (StrUtil.isEmpty(time)) { - return LocalDateTime.MAX; - } - - if (dateTime == null) { - return endOfDay(LocalDateTime.now()); - } - - // 今天的23:59:59 - if (StrPool.ZERO.equals(time)) { - return endOfDay(dateTime); - } - - char unit = Character.toLowerCase(time.charAt(time.length() - 1)); - if (time.length() == 1) { - unit = 'd'; - } - Long lastTime = Convert.toLong(time.substring(0, time.length() - 1)); - - switch (unit) { - //秒 - case 's': - return dateTime.plusSeconds(lastTime); - //分 - case 'm': - return dateTime.plusMinutes(lastTime); - //时 - case 'h' | 'H': - return dateTime.plusHours(lastTime); - //周 - case 'w': - return dateTime.plusWeeks(lastTime); - //月 - case 'M': - return dateTime.plusMonths(lastTime); - //年 - case 'y': - return dateTime.plusYears(lastTime); - //天 - case 'd': - default: - return dateTime.plusDays(lastTime); - } - } -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/common/util/NdJacksonModule.java b/kqapi/src/main/java/com/ningdatech/kqapi/common/util/NdJacksonModule.java deleted file mode 100644 index 5a93bd4..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/common/util/NdJacksonModule.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.ningdatech.kqapi.common.util; - -import com.fasterxml.jackson.databind.module.SimpleModule; -import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer; -import com.fasterxml.jackson.datatype.jsr310.deser.LocalTimeDeserializer; -import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer; -import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer; -import com.fasterxml.jackson.datatype.jsr310.ser.LocalTimeSerializer; -import com.ningdatech.kqapi.common.converter.NdLocalDateTimeDeserializer; - -import java.time.LocalDate; -import java.time.LocalDateTime; -import java.time.LocalTime; -import java.time.format.DateTimeFormatter; - -import static com.ningdatech.kqapi.common.util.NdDateUtils.*; - -/** - * jackson 自定义序列化 & 反序列化 规则 - * - * @author WendyYang - */ -public class NdJacksonModule extends SimpleModule { - - public NdJacksonModule() { - super(); - this.addDeserializer(LocalDateTime.class, NdLocalDateTimeDeserializer.INSTANCE); - this.addDeserializer(LocalDate.class, new LocalDateDeserializer(DateTimeFormatter.ofPattern(DEFAULT_DATE_FORMAT))); - this.addDeserializer(LocalTime.class, new LocalTimeDeserializer(DateTimeFormatter.ofPattern(DEFAULT_TIME_FORMAT))); - this.addSerializer(LocalDateTime.class, new LocalDateTimeSerializer(DateTimeFormatter.ofPattern(DEFAULT_DATE_TIME_FORMAT))); - this.addSerializer(LocalDate.class, new LocalDateSerializer(DateTimeFormatter.ofPattern(DEFAULT_DATE_FORMAT))); - this.addSerializer(LocalTime.class, new LocalTimeSerializer(DateTimeFormatter.ofPattern(DEFAULT_TIME_FORMAT))); - } - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/common/util/RefreshKeyUtil.java b/kqapi/src/main/java/com/ningdatech/kqapi/common/util/RefreshKeyUtil.java deleted file mode 100644 index 68b33d6..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/common/util/RefreshKeyUtil.java +++ /dev/null @@ -1,59 +0,0 @@ -package com.ningdatech.kqapi.common.util; - -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; -import lombok.extern.slf4j.Slf4j; - -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -/** - * @Classname RefreshKeyUtil - * @Description - * @Date 2023/6/27 10:03 - * @Author PoffyZhang - */ -@Slf4j -public class RefreshKeyUtil { - public static String getRequestSecret(String appKey, String appSecret,Long requestTime) throws IOException { - // 刷新秘钥 - HttpUtil httpUtil = HttpUtil.getInstance(); - log.info("请求密钥" + appSecret); - String sign = Md5Utils.hash (appKey + appSecret + requestTime); - String refreshUrl = "http://interface.zjzwfw.gov.cn/gateway/app/refreshTokenByKey.htm"; - log.info(refreshUrl); - Map map = new HashMap<>(); - map.put("appKey",appKey); - map.put("sign",sign); - map.put("requestTime",requestTime + ""); - String result = httpUtil.sendHttpPost(refreshUrl,map); - log.info(result); - JSONObject dataJson = JSON.parseObject(result).getJSONObject("datas"); - if(Objects.nonNull(dataJson)){ - return dataJson.getString("requestSecret"); - } - return result; - } - - public static String refreshSecret(String appKey, String refreshSecret,Long requestTime) throws IOException { - // 刷新秘钥 - HttpUtil httpUtil = HttpUtil.getInstance(); - log.info("刷新密钥" + refreshSecret); - String refreshSign = Md5Utils.hash (appKey + refreshSecret + requestTime); - String refreshUrl = "http://interface.zjzwfw.gov.cn/gateway/app/refreshTokenBySec.htm"; - log.info(refreshUrl); - Map map = new HashMap<>(); - map.put("appKey",appKey); - map.put("sign",refreshSign); - map.put("requestTime",requestTime + ""); - String result = httpUtil.sendHttpPost(refreshUrl,map); - log.info(result); - JSONObject dataJson = JSON.parseObject(result).getJSONObject("datas"); - if(Objects.nonNull(dataJson)){ - return dataJson.getString("requestSecret"); - } - return result; - } -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/common/util/SpringContextHolder.java b/kqapi/src/main/java/com/ningdatech/kqapi/common/util/SpringContextHolder.java deleted file mode 100644 index 1104523..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/common/util/SpringContextHolder.java +++ /dev/null @@ -1,150 +0,0 @@ -package com.ningdatech.kqapi.common.util; - -import java.util.ArrayList; -import java.util.List; - - -import org.springframework.beans.BeansException; -import org.springframework.beans.factory.DisposableBean; -import org.springframework.context.ApplicationContext; -import org.springframework.context.ApplicationContextAware; -import org.springframework.core.env.Environment; -import org.springframework.lang.NonNull; - -import lombok.extern.slf4j.Slf4j; - -/** - * @author qinxianyun - */ -@Slf4j -public class SpringContextHolder implements ApplicationContextAware, DisposableBean { - - private static ApplicationContext applicationContext = null; - private static final List CALL_BACKS = new ArrayList<>(); - private static boolean addCallback = true; - - /** - * 针对 某些初始化方法,在SpringContextHolder 未初始化时 提交回调方法。 - * 在SpringContextHolder 初始化后,进行回调使用 - * - * @param callBack 回调函数 - */ - public synchronized static void addCallBacks(CallBack callBack) { - if (addCallback) { - SpringContextHolder.CALL_BACKS.add(callBack); - } else { - log.warn("CallBack:{} 已无法添加!立即执行", callBack.getCallBackName()); - callBack.executor(); - } - } - - /** - * 从静态变量applicationContext中取得Bean, 自动转型为所赋值对象的类型. - */ - @SuppressWarnings("unchecked") - public static T getBean(String name) { - assertContextInjected(); - return (T) applicationContext.getBean(name); - } - - /** - * 从静态变量applicationContext中取得Bean, 自动转型为所赋值对象的类型. - */ - public static T getBean(Class requiredType) { - assertContextInjected(); - return applicationContext.getBean(requiredType); - } - - /** - * 获取SpringBoot 配置信息 - * - * @param property 属性key - * @param defaultValue 默认值 - * @param requiredType 返回类型 - * @return / - */ - public static T getProperties(String property, T defaultValue, Class requiredType) { - T result = defaultValue; - try { - result = getBean(Environment.class).getProperty(property, requiredType); - } catch (Exception ignored) { - } - return result; - } - - /** - * 获取SpringBoot 配置信息 - * - * @param property 属性key - * @return / - */ - public static String getProperties(String property) { - return getProperties(property, null, String.class); - } - - /** - * 获取SpringBoot 配置信息 - * - * @param property 属性key - * @param requiredType 返回类型 - * @return / - */ - public static T getProperties(String property, Class requiredType) { - return getProperties(property, null, requiredType); - } - - /** - * 检查ApplicationContext不为空. - */ - private static void assertContextInjected() { - if (applicationContext == null) { - throw new IllegalStateException("applicationContext属性未注入, 请在applicationContext" + - ".xml中定义SpringContextHolder或在SpringBoot启动类中注册SpringContextHolder."); - } - } - - /** - * 清除SpringContextHolder中的ApplicationContext为Null. - */ - private static void clearHolder() { - log.debug("清除SpringContextHolder中的ApplicationContext:" - + applicationContext); - applicationContext = null; - } - - @Override - public void destroy() { - SpringContextHolder.clearHolder(); - } - - @Override - public void setApplicationContext(@NonNull ApplicationContext applicationContext) throws BeansException { - if (SpringContextHolder.applicationContext != null) { - log.warn("SpringContextHolder中的ApplicationContext被覆盖, 原有ApplicationContext为:" + SpringContextHolder.applicationContext); - } - SpringContextHolder.applicationContext = applicationContext; - if (addCallback) { - for (CallBack callBack : SpringContextHolder.CALL_BACKS) { - callBack.executor(); - } - CALL_BACKS.clear(); - } - SpringContextHolder.addCallback = false; - } - - /** - * 获取当前启用的配置文件 - *

    - *
  • 生产环境:prod
  • - *
  • 开发环境:dev
  • - *
- * - * @return java.lang.String - * @author WendyYang - **/ - public static String getActiveProfile() { - String[] strings = applicationContext.getEnvironment().getActiveProfiles(); - return strings[0]; - } - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/common/util/StrPool.java b/kqapi/src/main/java/com/ningdatech/kqapi/common/util/StrPool.java deleted file mode 100644 index adff4f1..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/common/util/StrPool.java +++ /dev/null @@ -1,148 +0,0 @@ -package com.ningdatech.kqapi.common.util; - - -/** - *

- * 常用字符串 - *

- * - * @author WendyYang - * @date 2019/07/25 - */ -public interface StrPool { - - String AMPERSAND = "&"; - String AND = "and"; - String AT = "@"; - String ASTERISK = "*"; - String STAR = "*"; - String BACK_SLASH = "\\"; - String COLON = ":"; - String COMMA = ","; - String DASH = "-"; - String DOLLAR = "$"; - String DOT = "."; - String DOTDOT = ".."; - String DOT_CLASS = ".class"; - String DOT_JAVA = ".java"; - String DOT_XML = ".xml"; - String EMPTY = ""; - String EQUALS = "="; - String FALSE = "false"; - String SLASH = "/"; - String HASH = "#"; - String HAT = "^"; - String LEFT_BRACE = "{"; - String BRACE = "{}"; - String LEFT_BRACKET = "("; - char LEFT_BRACKET_CHAR = '('; - String LEFT_CHEV = "<"; - String NEWLINE = "\n"; - String N = "n"; - String NO = "no"; - String NULL = "null"; - String OFF = "off"; - String ON = "on"; - String PERCENT = "%"; - String PIPE = "|"; - String PLUS = "+"; - String QUESTION_MARK = "?"; - String EXCLAMATION_MARK = "!"; - String QUOTE = "\""; - String RETURN = "\r"; - String TAB = "\t"; - String RIGHT_BRACE = "}"; - String RIGHT_BRACKET = ")"; - String RIGHT_CHEV = ">"; - String SEMICOLON = ";"; - String SEMICOLON_CHINA = ";"; - String SINGLE_QUOTE = "'"; - String BACKTICK = "`"; - String SPACE = " "; - String TILDA = "~"; - String LEFT_SQ_BRACKET = "["; - String RIGHT_SQ_BRACKET = "]"; - String TRUE = "true"; - String UNDERSCORE = "_"; - String UTF_8 = "UTF-8"; - String GBK = "GBK"; - String US_ASCII = "US-ASCII"; - String ISO_8859_1 = "ISO-8859-1"; - String Y = "y"; - String YES = "yes"; - String ONE = "1"; - String ZERO = "0"; - String DOLLAR_LEFT_BRACE = "${"; - String HASH_LEFT_BRACE = "#{"; - String CRLF = "\r\n"; - String HTML_NBSP = " "; - String HTML_AMP = "&"; - String HTML_QUOTE = """; - String HTML_LT = "<"; - String HTML_GT = ">"; - String STRING_TYPE_NAME = "java.lang.String"; - String LONG_TYPE_NAME = "java.lang.Long"; - String BYTE_TYPE_NAME = "java.lang.Byte"; - String CHARACTER_TYPE_NAME = "java.lang.Character"; - String INTEGER_TYPE_NAME = "java.lang.Integer"; - String SHORT_TYPE_NAME = "java.lang.Short"; - String DOUBLE_TYPE_NAME = "java.lang.Double"; - String FLOAT_TYPE_NAME = "java.lang.Float"; - String BOOLEAN_TYPE_NAME = "java.lang.Boolean"; - String SET_TYPE_NAME = "java.util.Set"; - String LIST_TYPE_NAME = "java.util.List"; - String COLLECTION_TYPE_NAME = "java.util.Collection"; - String DATE_TYPE_NAME = "java.util.Date"; - String LOCAL_DATE_TIME_TYPE_NAME = "java.time.LocalDateTime"; - String LOCAL_DATE_TYPE_NAME = "java.time.LocalDate"; - String LOCAL_TIME_TYPE_NAME = "java.time.LocalTime"; - String JAVA_TEMP_DIR = "java.io.tmpdir"; - - String ARRAY = "Array"; - String INTEGER = "Integer"; - String FLOAT = "Float"; - String DATETIME = "DateTime"; - String DATE = "Date"; - String TIME = "Time"; - String BOOLEAN = "Boolean"; - - - String HTTPS_PREFIX = "https://"; - String HTTP_PREFIX = "http://"; - String HTTPS = "https"; - String HTTP = "http"; - /** - * 编码 - */ - String UTF8 = "UTF-8"; - /** - * JSON 资源 - */ - String CONTENT_TYPE = "application/json; charset=utf-8"; - - /** - * 用于随机选的字符 - */ - String BASE_UPPER_CHAR = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - - String TEST_TOKEN = "Bearer test"; - String TEST = "test"; - String PROD = "prod"; - String DEV = "dev"; - - /** - * 默认的父id - */ - Long DEF_PARENT_ID = 0L; - - String UNKNOWN = "unknown"; - - /** - * 日期 个位数前面补0 - */ - String FORMAT_DATE_SINGLE_DIGITS = "%02d"; - /** - * 不足三位的数字前面补0 - */ - String FORMAT_NUMBER_THREE = "%03d"; -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/open/controller/HealthController.java b/kqapi/src/main/java/com/ningdatech/kqapi/open/controller/HealthController.java deleted file mode 100644 index d3f8fb5..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/open/controller/HealthController.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.ningdatech.kqapi.open.controller; - -import com.alibaba.fastjson.JSONObject; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.jasypt.util.text.BasicTextEncryptor; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import java.time.LocalDateTime; -import java.time.format.DateTimeFormatter; - -/** - *

- * 前端控制器 - *

- * - * @author ZPF - * @since 2023-10-27 - */ -@Slf4j -@Validated -@RestController -@RequestMapping -@RequiredArgsConstructor -public class HealthController { - - @GetMapping("/health") - public JSONObject health() { - JSONObject json = new JSONObject(); - json.put("code","200"); - json.put("area","柯桥区"); - json.put("chargePerson","李*"); - json.put("appName","企业线上平台"); - json.put("mobile","156*****306"); - json.put("time",LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); - json.put("dept","产业发展科"); - return json; - } -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/scheduler/contants/TaskContant.java b/kqapi/src/main/java/com/ningdatech/kqapi/scheduler/contants/TaskContant.java deleted file mode 100644 index c853264..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/scheduler/contants/TaskContant.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.ningdatech.kqapi.scheduler.contants; - -/** - * @author PoffyZhang - * @Classname TaskContant - * @Description - * @Date 2023/1/18 11:00 - */ -public interface TaskContant { - - public static final String DEV = "dev"; - public static final String PRE = "pre"; - public static final String PROD = "prod"; -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/scheduler/controller/TaskController.java b/kqapi/src/main/java/com/ningdatech/kqapi/scheduler/controller/TaskController.java deleted file mode 100644 index 1473d1a..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/scheduler/controller/TaskController.java +++ /dev/null @@ -1,88 +0,0 @@ -package com.ningdatech.kqapi.scheduler.controller; - - -import com.ningdatech.kqapi.scheduler.manage.SynManage; -import com.ningdatech.kqapi.scheduler.task.CheckMattersUrlTask; -import com.ningdatech.kqapi.scheduler.task.RemoveMattersTask; -import com.ningdatech.kqapi.scheduler.task.SynTask; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; -import java.net.MalformedURLException; -import java.net.UnknownHostException; -import java.util.Arrays; - -/** - *

- * 前端控制器 - *

- * - * @author ZPF - * @since 2023-10-27 - */ -@Slf4j -@Validated -@RestController -@RequestMapping("/api/v1/task/") -@Api(value = "TaskController", tags = "柯桥-定时控制器") -@RequiredArgsConstructor -public class TaskController { - private final RemoveMattersTask removeMattersTask; - - private final CheckMattersUrlTask checkMattersUrlTask; - - private final SynTask synTask; - - private final SynManage synManage; - - @ApiOperation(value = "主动调删除数据", notes = "主动调删除数据") - @GetMapping("/remove-matters") - public void removeMatters() throws UnknownHostException { - removeMattersTask.doTask(); - } - - @ApiOperation(value = "主动同步三表", notes = "主动同步三表") - @GetMapping("/syn-data") - public void synData() throws UnknownHostException { - synManage.synData(); - } - - @ApiOperation(value = "同步菜单链接数据", notes = "同步菜单链接数据") - @GetMapping("/syn") - public String synMenu() throws UnknownHostException { - synTask.synData(); - return "同步成功"; - } - - @ApiOperation(value = "剔除某个菜单组件名称数据", notes = "英文逗号','分割") - @GetMapping("/synEliminate") - public String synEliminate(String keys){ - return synTask.synEliminate(Arrays.asList(keys.split(","))); - } - - @ApiOperation(value = "同步单个菜单组件名称", notes = "同步菜单链接数据") - @GetMapping("/synSingle") - public String synSingle(String key){ - synTask.synSingle(key); - return "同步成功"; - } - - @ApiOperation(value = "同步菜单链接数据", notes = "同步菜单链接数据") - @GetMapping("/syn-menu") - public String synMenuData() throws UnknownHostException { - synTask.synMenu(); - return "同步成功"; - } - - @ApiOperation(value = "check链接", notes = "check链接") - @GetMapping("/check-url") - public String checkUrl() throws UnknownHostException, MalformedURLException { - checkMattersUrlTask.doTask(); - return "操作成功"; - } -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/scheduler/manage/SynManage.java b/kqapi/src/main/java/com/ningdatech/kqapi/scheduler/manage/SynManage.java deleted file mode 100644 index b92267c..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/scheduler/manage/SynManage.java +++ /dev/null @@ -1,88 +0,0 @@ -package com.ningdatech.kqapi.scheduler.manage; - -import cn.hutool.core.bean.BeanUtil; -import com.alibaba.fastjson.JSON; -import com.ningdatech.kqapi.zzsfw.model.dto.KqZzsfwMattersDeduplicateDTO; -import com.ningdatech.kqapi.zzsfw.model.dto.KqZzsfwMenuDTO; -import com.ningdatech.kqapi.zzsfw.model.dto.KqZzsfwPolicyDTO; -import com.ningdatech.kqapi.zzsfw.model.entity.KqZzsfwMenu; -import com.ningdatech.kqapi.zzsfw.model.entity.KqZzsfwMattersDeduplicate; -import com.ningdatech.kqapi.zzsfw.model.entity.KqZzsfwPolicy; -import com.ningdatech.kqapi.zzsfw.service.IKqZzsfwMatterDeduplicateService; -import com.ningdatech.kqapi.zzsfw.service.IKqZzsfwMenuService; -import com.ningdatech.kqapi.zzsfw.service.IKqZzsfwPolicyService; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.http.HttpEntity; -import org.springframework.http.HttpHeaders; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.stereotype.Component; -import org.springframework.web.client.RestTemplate; - -import java.util.List; - -/** - * @Classname SynManage - * @Description - * @Date 2023/12/20 15:18 - * @Author PoffyZhang - */ -@Component -@Slf4j -@RequiredArgsConstructor -public class SynManage { - - private final IKqZzsfwMatterDeduplicateService deduplicateService; - - private final IKqZzsfwMenuService menuService; - - private final IKqZzsfwPolicyService policyService; - - private final RestTemplate restTemplate; - - public void synData() { - log.info("同步数据开始"); - //1.去重数据 - List dups = deduplicateService.list(); - for(KqZzsfwMattersDeduplicate dup : dups){ - KqZzsfwMattersDeduplicateDTO dto = BeanUtil.copyProperties(dup, KqZzsfwMattersDeduplicateDTO.class); - HttpHeaders headers = new HttpHeaders(); - MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8"); - headers.setContentType(type); - headers.add("Accept", MediaType.APPLICATION_JSON.toString()); - HttpEntity formEntity = new HttpEntity(JSON.toJSONString(dto), headers); - ResponseEntity stringResponseEntity = restTemplate.postForEntity( - "http://localhost:33061/kq/api/v1/zzsfw/save-dup", formEntity, String.class); - log.info("结果:{}", JSON.toJSONString(stringResponseEntity)); - } - - //2.菜单数据 - List menus = menuService.list(); - for(KqZzsfwMenu menu : menus){ - KqZzsfwMenuDTO dto = BeanUtil.copyProperties(menu, KqZzsfwMenuDTO.class); - HttpHeaders headers = new HttpHeaders(); - MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8"); - headers.setContentType(type); - headers.add("Accept", MediaType.APPLICATION_JSON.toString()); - HttpEntity formEntity = new HttpEntity(JSON.toJSONString(dto), headers); - ResponseEntity stringResponseEntity = restTemplate.postForEntity( - "http://localhost:33061/kq/api/v1/zzsfw/save", formEntity, String.class); - log.info("结果:{}", JSON.toJSONString(stringResponseEntity)); - } - - //3.其它数据 - List policies = policyService.list(); - for(KqZzsfwPolicy policy : policies){ - KqZzsfwPolicyDTO dto = BeanUtil.copyProperties(policy, KqZzsfwPolicyDTO.class); - HttpHeaders headers = new HttpHeaders(); - MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8"); - headers.setContentType(type); - headers.add("Accept", MediaType.APPLICATION_JSON.toString()); - HttpEntity formEntity = new HttpEntity(JSON.toJSONString(dto), headers); - ResponseEntity stringResponseEntity = restTemplate.postForEntity( - "http://localhost:33061/kq/api/v1/poclicy/save", formEntity, String.class); - log.info("结果:{}", JSON.toJSONString(stringResponseEntity)); - } - } -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/scheduler/model/CommonLog.java b/kqapi/src/main/java/com/ningdatech/kqapi/scheduler/model/CommonLog.java deleted file mode 100644 index 3853ce8..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/scheduler/model/CommonLog.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.ningdatech.kqapi.scheduler.model; - -import lombok.Data; - -@Data -public class CommonLog { - /** - * 用户id - */ - private String userId; - /** - * 用户角色(群众、企业、政府工作人员、第三方) - */ - private String userRole; - /** - * 地区编码 - */ - private String areaCode; - /** - * 操作类型(1-登录 2-离开 3-办事开始 4-办事结束) - */ - private Integer actionType; - /** - * 操作标识 - */ - private String actionId; - /** - * 操作时间 - */ - private String actionTime; - /** - * 操作时长 - */ - private Long actionDuration; - /** - * 操作状态(0-成功 1-失败) - */ - private Integer actionStatus; - /** - * 应用编码 - */ - private String appCode; -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/scheduler/task/CheckMattersUrlTask.java b/kqapi/src/main/java/com/ningdatech/kqapi/scheduler/task/CheckMattersUrlTask.java deleted file mode 100644 index 9f5820e..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/scheduler/task/CheckMattersUrlTask.java +++ /dev/null @@ -1,162 +0,0 @@ -package com.ningdatech.kqapi.scheduler.task; - -import cn.hutool.core.date.StopWatch; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import com.google.common.collect.Lists; -import com.ningdatech.kqapi.common.model.entity.Item; -import com.ningdatech.kqapi.zzsfw.model.entity.KqZzsfwMenu; -import com.ningdatech.kqapi.zzsfw.service.IKqZzsfwMenuService; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.apache.http.conn.ssl.NoopHostnameVerifier; -import org.apache.http.conn.ssl.SSLConnectionSocketFactory; -import org.apache.http.conn.ssl.TrustStrategy; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.impl.client.HttpClientBuilder; -import org.apache.http.impl.client.HttpClients; -import org.apache.http.ssl.SSLContexts; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.http.HttpEntity; -import org.springframework.http.HttpHeaders; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; -import org.springframework.scheduling.annotation.Scheduled; -import org.springframework.stereotype.Component; -import org.springframework.util.LinkedMultiValueMap; -import org.springframework.util.MultiValueMap; -import org.springframework.web.client.RestTemplate; - -import javax.net.ssl.SSLContext; -import java.net.*; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -/** - * @author ZPF - * @since 2023/08/31 18:16 - */ -@Component -@Slf4j -@RequiredArgsConstructor -public class CheckMattersUrlTask { - - @Value("${hostname}") - public String HOST; - - @Value("${spring.profiles.active}") - public String active; - - @Autowired - private IKqZzsfwMenuService menuService; - - /** - * 每天9点 开始校检 链接 是不是可行 - */ - @Scheduled(cron = "0 0 9 * * ?") - public void doTask() throws UnknownHostException, MalformedURLException { -// if (!HOST.equals(InetAddress.getLocalHost().getHostName())) { -// log.info("定时器没开启或者host不对! {}:{}", -// HOST,InetAddress.getLocalHost().getHostName()); -// return; -// } - - StopWatch stopWatch = new StopWatch(); - stopWatch.start(); - - log.info("==========开始校检事项表里的链接 会不会404 如果404就隐藏"); - - List menus = menuService.list(Wrappers.lambdaQuery(KqZzsfwMenu.class) - .eq(KqZzsfwMenu::getHasUrl, 1) - .isNotNull(KqZzsfwMenu::getWebapplyurl)); - Integer errNum = 0; - List errUrls = Lists.newArrayList(); - - for (KqZzsfwMenu menu : menus) { - RestTemplate restTemplate = new RestTemplate(generateHttpRequestFactory()); - String url = "https://www.zjzwfw.gov.cn/jpaas-zjservice-server/open-api/item/getItemDetail"; - MultiValueMap map = new LinkedMultiValueMap<>(); - - String webapplyurl = menu.getWebapplyurl(); - webapplyurl = webapplyurl.replace("/#",""); - Map queryParams = getQueryParams(new URL(webapplyurl)); - String localInnerCode = queryParams.get("localInnerCode"); - log.info("localInnerCode :{}",localInnerCode); - map.add("localInnerCode", localInnerCode); - HttpHeaders headers = new HttpHeaders(); - headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); - HttpEntity> formEntity = new HttpEntity(map, headers); - ResponseEntity response = restTemplate.postForEntity(url, formEntity, Item.class); - System.out.println(response.getBody()); - Item body = response.getBody(); - assert body != null; - Item.ItemData itemData = body.getData(); - //如果是空的 - if(Objects.isNull(itemData.getItem())){ - //隐藏 - menuService.update(Wrappers.lambdaUpdate(KqZzsfwMenu.class) - .eq(KqZzsfwMenu::getId,menu.getId()) - .set(KqZzsfwMenu::getHasUrl,0) - .set(KqZzsfwMenu::getWebapplyurl,null)); - errNum += 1; - errUrls.add(webapplyurl); - } - } - - log.info("不可用的链接有 :{}条 ,详情:{}",errNum,errUrls); - - stopWatch.stop(); - log.info("校检事项表里的链接结束====={}s",stopWatch.getTotalTimeSeconds()); - } - - public static void main(String[] args) throws Exception { - String url = "https://www.zjzwfw.gov.cn/zjservice-fe/#/workguide?localInnerCode=3bd735e2-ddfe-4377-86b3-beec85252f21&siteCode=330000000000"; - url = url.replace("/#",""); - Map queryParams = getQueryParams(new URL(url)); - System.out.println(queryParams.get("localInnerCode")); - } - - public static Map getQueryParams(URL url) { - Map queryPairs = new HashMap<>(); - String query = url.getQuery(); - String[] pairs = query.split("&"); - for (String pair : pairs) { - int idx = pair.indexOf("="); - try { - if (idx > 0) { - String key = pair.substring(0, idx); - String value = pair.substring(idx + 1); - queryPairs.put(key, value); - } - } catch (Exception e) { - e.printStackTrace(); - } - } - return queryPairs; - } - - /** - * 通过该工厂类创建的RestTemplate发送请求时,可忽略https证书认证 - * @return 工厂 - */ - public static HttpComponentsClientHttpRequestFactory generateHttpRequestFactory(){ - try{ - TrustStrategy acceptingTrustStrategy = ((x509Certificates, authType) -> true); - SSLContext sslContext = SSLContexts.custom().loadTrustMaterial(null, acceptingTrustStrategy).build(); - SSLConnectionSocketFactory connectionSocketFactory = new SSLConnectionSocketFactory(sslContext, new NoopHostnameVerifier()); - - HttpClientBuilder httpClientBuilder = HttpClients.custom(); - httpClientBuilder.setSSLSocketFactory(connectionSocketFactory); - CloseableHttpClient httpClient = httpClientBuilder.build(); - HttpComponentsClientHttpRequestFactory factory = new HttpComponentsClientHttpRequestFactory(); - factory.setHttpClient(httpClient); - return factory; - }catch (Exception e){ - e.printStackTrace(); - } - return null; - } -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/scheduler/task/RemoveMattersTask.java b/kqapi/src/main/java/com/ningdatech/kqapi/scheduler/task/RemoveMattersTask.java deleted file mode 100644 index dbbc3a7..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/scheduler/task/RemoveMattersTask.java +++ /dev/null @@ -1,63 +0,0 @@ -package com.ningdatech.kqapi.scheduler.task; - -import cn.hutool.core.date.StopWatch; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import com.ningdatech.kqapi.scheduler.contants.TaskContant; -import com.ningdatech.kqapi.zzsfw.model.entity.DscSxAdsShareItemQltQlsxCommonIDVKq; -import com.ningdatech.kqapi.zzsfw.service.IDscSxAdsShareItemQltQlsxCommonIDVKqService; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.scheduling.annotation.Scheduled; -import org.springframework.stereotype.Component; -import java.net.InetAddress; -import java.net.UnknownHostException; - -/** - * @author ZPF - * @since 2023/08/31 18:16 - */ -@Component -@Slf4j -@RequiredArgsConstructor -public class RemoveMattersTask { - - @Value("${hostname}") - public String HOST; - - @Value("${spring.profiles.active}") - public String active; - - @Autowired - private IDscSxAdsShareItemQltQlsxCommonIDVKqService kqService; - - /** - * 每天 - */ - @Scheduled(cron = "0 50 14 * * ?") - public void doTask() throws UnknownHostException { - if (!HOST.equals(InetAddress.getLocalHost().getHostName())) { - log.info("定时器没开启或者host不对! {}:{}", - HOST,InetAddress.getLocalHost().getHostName()); - return; - } - if(!TaskContant.PROD.equals(active)){ - log.info("非正式环境不用删除!"); - return; - } - - StopWatch stopWatch = new StopWatch(); - stopWatch.start(); - - log.info("删除事项表 所有数据 等待新数据推上来"); - if(kqService.remove(Wrappers.lambdaQuery(DscSxAdsShareItemQltQlsxCommonIDVKq.class))){ - log.info("删除成功"); - } - - log.info("当前表里还有数据 :{}条",kqService.count()); - - stopWatch.stop(); - log.info("数据同步任务结束====={}s",stopWatch.getTotalTimeSeconds()); - } -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/scheduler/task/SynTask.java b/kqapi/src/main/java/com/ningdatech/kqapi/scheduler/task/SynTask.java deleted file mode 100644 index 2dbc4f6..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/scheduler/task/SynTask.java +++ /dev/null @@ -1,205 +0,0 @@ -package com.ningdatech.kqapi.scheduler.task; - -import cn.hutool.core.date.StopWatch; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import com.github.benmanes.caffeine.cache.LoadingCache; -import com.ningdatech.kqapi.common.constant.BizConst; -import com.ningdatech.kqapi.common.enumeration.CommonEnum; -import com.ningdatech.kqapi.common.helper.MatterCacheHelper; -import com.ningdatech.kqapi.zzsfw.model.entity.*; -import com.ningdatech.kqapi.zzsfw.service.ComponentsMatterEliminateService; -import com.ningdatech.kqapi.zzsfw.model.entity.KqZzsfwMenu; -import com.ningdatech.kqapi.zzsfw.manage.MatterManage; -import com.ningdatech.kqapi.zzsfw.service.IDscSxAdsShareItemQltQlsxCommonIDVKqService; -import com.ningdatech.kqapi.zzsfw.service.IKqZzsfwMatterDeduplicateService; -import com.ningdatech.kqapi.zzsfw.service.IKqZzsfwMenuService; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.scheduling.annotation.Scheduled; -import org.springframework.stereotype.Component; - -import java.net.UnknownHostException; -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; - -/** - * @Classname SynTask - * @Description - * @Date 2024/1/4 9:04 - * @Author PoffyZhang - */ -@Component -@Slf4j -@RequiredArgsConstructor -public class SynTask { - @Value("${hostname}") - public String HOST; - - @Value("${spring.profiles.active}") - public String active; - - @Autowired - private MatterCacheHelper matterCacheHelper; - - @Autowired - private MatterManage matterManage; - - @Autowired - private IKqZzsfwMatterDeduplicateService matterDeduplicateService; - - @Autowired - private IKqZzsfwMenuService menuService; - - @Autowired - private IDscSxAdsShareItemQltQlsxCommonIDVKqService kqService; - - @Autowired - private ComponentsMatterEliminateService componentsMatterEliminateService; - - protected LoadingCache mattersDupCache; - - private final String KQ_ZZS_BASE_URL = "https://www.zjzwfw.gov.cn/zjservice-fe/#/workguide?localInnerCode=&siteCode=330000000000"; - - /** - * 每天 - */ - @Scheduled(cron = "0 30 8 * * ?") - public void synData() throws UnknownHostException { -// if (!HOST.equals(InetAddress.getLocalHost().getHostName())) { -// log.info("定时器没开启或者host不对! {}:{}", -// HOST,InetAddress.getLocalHost().getHostName()); -// return; -// } -// if(!TaskContant.PROD.equals(active)){ -// log.info("非正式环境不用运行同步任务!"); -// return; -// } - - log.info("政务数据 ===================== 同步开始"); - StopWatch stopWatch = new StopWatch(); - stopWatch.start(); - - //1.处理 去重数据 - if(matterCacheHelper.refreshAll()){ - matterManage.removeAllDup(); - List allDup = matterCacheHelper.all(); - matterDeduplicateService.saveBatch(allDup); - - //2. 事项 - List menus = menuService.list(); - for(KqZzsfwMenu menu : menus){ - String url = matterCacheHelper.getUrl(menu.getItemName()); - if(StringUtils.isBlank(url)){ - menuService.update(Wrappers.lambdaUpdate(KqZzsfwMenu.class) - .eq(KqZzsfwMenu::getId,menu.getId()) - .set(KqZzsfwMenu::getWebapplyurl,null) - .set(KqZzsfwMenu::getHasUrl, CommonEnum.NO.getCode())); - }else{ - menuService.update(Wrappers.lambdaUpdate(KqZzsfwMenu.class) - .eq(KqZzsfwMenu::getId,menu.getId()) - .set(KqZzsfwMenu::getWebapplyurl,url) - .set(KqZzsfwMenu::getHasUrl,CommonEnum.YES.getCode())); - } - } - } - - stopWatch.stop(); - log.info("政务数据 ===================== 同步总共耗时 :{} s",stopWatch.getTotalTimeSeconds()); - } - - public void synMenu() { - //2. 事项 - List menus = menuService.list(); - for(KqZzsfwMenu menu : menus){ - String url = matterCacheHelper.getUrl(menu.getItemName()); - log.info("当前缓存的数据 : {},{}",menu.getItemName(),url); - if(StringUtils.isBlank(url)){ - menuService.update(Wrappers.lambdaUpdate(KqZzsfwMenu.class) - .eq(KqZzsfwMenu::getId,menu.getId()) - .set(KqZzsfwMenu::getWebapplyurl,null) - .set(KqZzsfwMenu::getHasUrl, CommonEnum.NO.getCode())); - }else{ - menuService.update(Wrappers.lambdaUpdate(KqZzsfwMenu.class) - .eq(KqZzsfwMenu::getId,menu.getId()) - .set(KqZzsfwMenu::getWebapplyurl,url) - .set(KqZzsfwMenu::getHasUrl,CommonEnum.YES.getCode())); - } - } - } - - public String synEliminate(List keys){ -// kqService.remove(new LambdaQueryWrapper() -// .in(DscSxAdsShareItemQltQlsxCommonIDVKq::getQlName, keys)); - // 添加剔除信息 - List entityList = new ArrayList<>(); - keys.forEach(key ->{ - ComponentsMatterEliminateEntity one = componentsMatterEliminateService.getOne(Wrappers.lambdaQuery(ComponentsMatterEliminateEntity.class) - .eq(ComponentsMatterEliminateEntity::getQlName, key)); - if (Objects.isNull(one)){ - entityList.add(new ComponentsMatterEliminateEntity(key,"1")); - } - // 删除缓存 - DscSxAdsShareItemQltQlsxCommonIDVKq matter = getSynUrl(key); - String url = KQ_ZZS_BASE_URL.replace("localInnerCode=", "localInnerCode=" + matter.getQlInnerCode()); - MatterKey matterKey = MatterKey.of(matter.getQlName(),url); - try { - mattersDupCache.invalidate(matterKey); - }catch (Exception e){ - log.error("mattersDupCache is null", e.getMessage()); - } - }); - componentsMatterEliminateService.saveBatch(entityList); - - // 删除menu表 - menuService.remove(new LambdaQueryWrapper() - .in(KqZzsfwMenu::getItemName, keys)); - - // 删除deduplicate表 - matterDeduplicateService.remove(new LambdaQueryWrapper() - .in(KqZzsfwMattersDeduplicate::getQlName, keys)); - - return "剔除成功"; - } - - public DscSxAdsShareItemQltQlsxCommonIDVKq getSynUrl(String key){ - DscSxAdsShareItemQltQlsxCommonIDVKq matter = kqService - .getOne(Wrappers.lambdaQuery(DscSxAdsShareItemQltQlsxCommonIDVKq.class) - .select(DscSxAdsShareItemQltQlsxCommonIDVKq::getRowguid, - DscSxAdsShareItemQltQlsxCommonIDVKq::getQlName, - DscSxAdsShareItemQltQlsxCommonIDVKq::getQlState, - DscSxAdsShareItemQltQlsxCommonIDVKq::getQlInnerCode, - DscSxAdsShareItemQltQlsxCommonIDVKq::getWebapplyurl) - .eq(DscSxAdsShareItemQltQlsxCommonIDVKq::getQlName, key) - .eq(DscSxAdsShareItemQltQlsxCommonIDVKq::getQlState, "1") - .isNotNull(DscSxAdsShareItemQltQlsxCommonIDVKq::getWebapplyurl) - // 确保getQlInnerCodeItem字段不为null且不为"" - .isNotNull(DscSxAdsShareItemQltQlsxCommonIDVKq::getQlInnerCode) - .ne(DscSxAdsShareItemQltQlsxCommonIDVKq::getQlInnerCode, "") - .orderByDesc(DscSxAdsShareItemQltQlsxCommonIDVKq::getUpdateDate) - .last(BizConst.LIMIT_1)); - return matter; - } - - public String synSingle(String key){ - DscSxAdsShareItemQltQlsxCommonIDVKq matter = getSynUrl(key); - String url = KQ_ZZS_BASE_URL.replace("localInnerCode=", "localInnerCode=" + matter.getQlInnerCode()); - List menus = menuService.list(Wrappers.lambdaQuery(KqZzsfwMenu.class) - .eq(KqZzsfwMenu::getItemName, key)); - menus.forEach(menu->{ - menuService.update(Wrappers.lambdaUpdate(KqZzsfwMenu.class) - .eq(KqZzsfwMenu::getId,menu.getId()) - .set(KqZzsfwMenu::getWebapplyurl,url) - .set(KqZzsfwMenu::getHasUrl,CommonEnum.YES.getCode())); - }); - // 更新缓存 - MatterKey matterKey = MatterKey.of(matter.getQlName(),url); - mattersDupCache.invalidate(matterKey); - mattersDupCache.put(matterKey, KqZzsfwMattersDeduplicate.of(matter.getQlName(),url)); - return "更新成功,rul:" + url; - } -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/scheduler/utils/DateUtil.java b/kqapi/src/main/java/com/ningdatech/kqapi/scheduler/utils/DateUtil.java deleted file mode 100644 index 5093758..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/scheduler/utils/DateUtil.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.ningdatech.kqapi.scheduler.utils; - -import java.time.LocalDateTime; -import java.time.ZoneId; -import java.util.Calendar; -import java.util.Date; -import java.util.Objects; - -/** - * @Classname DateUtil - * @Description - * @Date 2023/8/31 15:36 - * @Author PoffyZhang - */ -public class DateUtil { - - public static Date getTodayTime(int hour){ - // 获取当前日期时间 - Calendar calendar = Calendar.getInstance(); - - // 将时间设置为凌晨 - calendar.set(Calendar.HOUR_OF_DAY, hour); - calendar.set(Calendar.MINUTE, 0); - calendar.set(Calendar.SECOND, 0); - - // 获取凌晨时间 - Date date = calendar.getTime(); - return date; - } - - public static LocalDateTime convertDateToLocal(Date date){ - if(Objects.isNull(date)){ - return null; - } - return date.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime(); - } -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/security/AuthBeanConfig.java b/kqapi/src/main/java/com/ningdatech/kqapi/security/AuthBeanConfig.java deleted file mode 100644 index ee5eb87..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/security/AuthBeanConfig.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.ningdatech.kqapi.security; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.security.core.session.SessionRegistry; -import org.springframework.security.core.session.SessionRegistryImpl; -import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; -import org.springframework.security.crypto.password.PasswordEncoder; - -/** - *

- * AuthBeanConfig - *

- * - * @author WendyYang - * @since 11:23 2024/4/20 - */ -@Configuration -public class AuthBeanConfig { - - @Bean - public PasswordEncoder passwordEncoder() { - return new BCryptPasswordEncoder(); - } - - @Bean - public SessionRegistry sessionRegistry() { - return new SessionRegistryImpl(); - } - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/security/AuthProperties.java b/kqapi/src/main/java/com/ningdatech/kqapi/security/AuthProperties.java deleted file mode 100644 index 9b26e9a..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/security/AuthProperties.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.ningdatech.kqapi.security; - -import com.ningdatech.basic.factory.PropertySourceFactory; -import lombok.Data; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.PropertySource; -import org.springframework.stereotype.Component; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - *

- * AuthProperties - *

- * - * @author WendyYang - * @since 11:15 2024/4/20 - */ -@Configuration -@PropertySource(value = "classpath:security/auth-${spring.profiles.active}.yml" - , encoding = "utf-8", factory = PropertySourceFactory.class) -@ConfigurationProperties(prefix = "security.auth") -@Component -@Data -public class AuthProperties { - - private Boolean postOnlyByLogin = true; - - private String authRequireUrl; - - private String invalidSessionUrl; - - private String passwordLoginUrl; - - private String logoutUrl; - - private List ignoreAuthUrls; - - private List ignoreCsrfUrls; - - private Map> roleMap = new HashMap<>(); - - public String[] getIgnoreAuthUrlsArray() { - String[] stringArray = new String[ignoreAuthUrls.size()]; - return ignoreAuthUrls.toArray(stringArray); - } - - public String[] getIgnoreCsrfUrlsArray() { - String[] stringArray = new String[ignoreCsrfUrls.size()]; - return ignoreCsrfUrls.toArray(stringArray); - } - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/security/WebSecurityConfig.java b/kqapi/src/main/java/com/ningdatech/kqapi/security/WebSecurityConfig.java deleted file mode 100644 index 5718e44..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/security/WebSecurityConfig.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.ningdatech.kqapi.security; - -import com.ningdatech.basic.util.NdJsonUtil; -import com.ningdatech.basic.util.StrPool; -import com.ningdatech.kqapi.common.constant.BizConst; -import com.ningdatech.kqapi.security.handler.DefaultExpiredSessionStrategy; -import com.ningdatech.kqapi.security.handler.DefaultInvalidSessionStrategy; -import com.ningdatech.kqapi.security.password.PasswordAuthSecurityConfig; -import org.springframework.context.annotation.Configuration; -import org.springframework.http.HttpStatus; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; -import org.springframework.security.web.AuthenticationEntryPoint; -import org.springframework.security.web.authentication.logout.LogoutSuccessHandler; -import org.springframework.security.web.csrf.CookieCsrfTokenRepository; - -import java.io.PrintWriter; - -/** - *

- * WebSecurityConfig - *

- * - * @author WendyYang - * @since 11:07 2024/4/20 - */ -@Configuration -public class WebSecurityConfig extends WebSecurityConfigurerAdapter { - - private final AuthProperties authProperties; - private final PasswordAuthSecurityConfig passwordAuthSecurityConfig; - private final LogoutSuccessHandler logoutSuccessHandler; - private final DefaultExpiredSessionStrategy expiredSessionStrategy; - private final DefaultInvalidSessionStrategy invalidSessionStrategy; - - public WebSecurityConfig(AuthProperties authProperties, - PasswordAuthSecurityConfig passwordAuthSecurityConfig, - LogoutSuccessHandler logoutSuccessHandler, - DefaultExpiredSessionStrategy expiredSessionStrategy, - DefaultInvalidSessionStrategy invalidSessionStrategy) { - this.authProperties = authProperties; - this.passwordAuthSecurityConfig = passwordAuthSecurityConfig; - this.logoutSuccessHandler = logoutSuccessHandler; - this.expiredSessionStrategy = expiredSessionStrategy; - this.invalidSessionStrategy = invalidSessionStrategy; - } - - @Override - protected void configure(HttpSecurity http) throws Exception { - http.formLogin() - .and() - .exceptionHandling() - .authenticationEntryPoint(authenticationEntryPoint()) - .and().apply(passwordAuthSecurityConfig) - .and() - .authorizeRequests() - .antMatchers(authProperties.getIgnoreAuthUrlsArray()).permitAll() - .anyRequest() - .authenticated() - .and() - // 防止固定会话攻击,Spring security的默认配置就是如此: - // 登陆成功之后会创建一个新的会话,然后将旧的session信息复制到新的session中(客户端的sessionId变了) - .sessionManagement() - .invalidSessionStrategy(invalidSessionStrategy) - .sessionFixation() - .migrateSession() - // .invalidSessionStrategy(defaultInvalidSessionStrategy) - .maximumSessions(3) - .maxSessionsPreventsLogin(true) - .expiredSessionStrategy(expiredSessionStrategy) - .and().and().logout().logoutUrl(authProperties.getLogoutUrl()) - .logoutSuccessHandler(logoutSuccessHandler) - .deleteCookies(BizConst.COOKIE_KEY) - .and() - // 开启csrf验证,需要前端同步传入token - .csrf().csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse()) - .ignoringAntMatchers(authProperties.getIgnoreCsrfUrlsArray()); - } - - private AuthenticationEntryPoint authenticationEntryPoint() { - return (request, response, authException) -> { - response.setContentType(StrPool.CONTENT_TYPE); - response.setStatus(HttpStatus.UNAUTHORIZED.value()); - PrintWriter writer = response.getWriter(); - writer.write(NdJsonUtil.getInstance().writeValueAsString(BizConst.UNAUTHENTICATED)); - writer.flush(); - writer.close(); - }; - } - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/security/config/RedisSessionConfig.java b/kqapi/src/main/java/com/ningdatech/kqapi/security/config/RedisSessionConfig.java deleted file mode 100644 index 4103f92..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/security/config/RedisSessionConfig.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.ningdatech.kqapi.security.config; - -import cn.hutool.core.util.StrUtil; -import com.ningdatech.basic.util.StrPool; -import com.ningdatech.kqapi.common.constant.BizConst; -import com.ningdatech.kqapi.security.constant.AuthConst; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.session.data.redis.RedisIndexedSessionRepository; -import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession; -import org.springframework.session.web.http.CookieHttpSessionIdResolver; -import org.springframework.session.web.http.DefaultCookieSerializer; - -/** - *

- * 设置session的过期时间为一天 - *

- * - * @author WendyYang - * @since 00:22 2023/3/2 - */ -@Configuration -@EnableRedisHttpSession( - maxInactiveIntervalInSeconds = RedisSessionConfig.SESSION_TIMEOUT, - redisNamespace = RedisSessionConfig.REDIS_NAMESPACE -) -public class RedisSessionConfig { - - static final int SESSION_TIMEOUT = 60 * 60 * 24; - - static final String REDIS_NAMESPACE = "#{redisSessionConfig.getRedisNamespace()}"; - - @Value("${nd.cache.def.keyPrefix:}") - private String keyPrefix; - - public String getRedisNamespace() { - return (StrUtil.isBlank(keyPrefix) ? StrPool.EMPTY : keyPrefix + StrPool.COLON) + RedisIndexedSessionRepository.DEFAULT_NAMESPACE; - } - - @Bean - public CookieHttpSessionIdResolver sessionIdResolver() { - // 创建 CookieHttpSessionIdResolver 对象 - CookieHttpSessionIdResolver sessionIdResolver = new CookieHttpSessionIdResolver(); - // 创建 DefaultCookieSerializer 对象 - DefaultCookieSerializer cookieSerializer = new DefaultCookieSerializer(); - cookieSerializer.setCookieName(BizConst.COOKIE_KEY); - cookieSerializer.setCookieMaxAge(AuthConst.SESSION_TIME_SECONDS); - // 设置到 sessionIdResolver 中 - sessionIdResolver.setCookieSerializer(cookieSerializer); - return sessionIdResolver; - } - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/security/constant/AuthConst.java b/kqapi/src/main/java/com/ningdatech/kqapi/security/constant/AuthConst.java deleted file mode 100644 index 608eafa..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/security/constant/AuthConst.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.ningdatech.kqapi.security.constant; - -/** - *

- * 授权相关常量 - *

- * - * @author WendyYang - * @since 2023/9/1 - **/ -public class AuthConst { - - private AuthConst() { - } - - public static final Integer SESSION_TIME_SECONDS = 24 * 60 * 60 * 10; - public static final Integer SESSION_EXPIRED = 0; - - public static final String USERNAME = "username"; - - public static final String PASSWORD = "password"; - - public static final String LOGIN_PLATFORM = "loginPlatform"; - - public static final String DEVICE_MODEL = "deviceModel"; - - public static final String OPEN_ID = "openId"; - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/security/constant/AuthTypeEnum.java b/kqapi/src/main/java/com/ningdatech/kqapi/security/constant/AuthTypeEnum.java deleted file mode 100644 index 62b5af7..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/security/constant/AuthTypeEnum.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.ningdatech.kqapi.security.constant; - -import lombok.Getter; - -/** - * @author LiuXinXin - * @date 2021/7/30 下午2:10 - */ -@Getter -public enum AuthTypeEnum { - - /** - * 手机 + 密码的认证方式 - */ - PHONE_PASSWORD("phone_password"), - - /** - * 子账号 账号 + 密码的认证方式 - */ - ACCOUNT_PASSWORD("account_password"); - - private final String key; - - AuthTypeEnum(String key) { - this.key = key; - } - - public static boolean contains(String key) { - for (AuthTypeEnum value : AuthTypeEnum.values()) { - if (key.equals(value.getKey())) { - return true; - } - } - return false; - } - - public String getKey() { - return key; - } - - public static AuthTypeEnum of(String key) { - for (AuthTypeEnum value : AuthTypeEnum.values()) { - if (key.equals(value.getKey())) { - return value; - } - } - throw new IllegalArgumentException(String.format("无效的AuthTypeEnum:%s", key)); - } -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/security/constant/LoginPlatformEnum.java b/kqapi/src/main/java/com/ningdatech/kqapi/security/constant/LoginPlatformEnum.java deleted file mode 100644 index a1c755a..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/security/constant/LoginPlatformEnum.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.ningdatech.kqapi.security.constant; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -/** - * @author liuxinxin - * @date 2022/11/24 下午5:45 - * 登陆平台 - */ -@Getter -@AllArgsConstructor -public enum LoginPlatformEnum { - - // PC 端 - PC_PLATFORM, - - // 驾驶员端 - DRIVER_PLATFORM, - - // 企业端 - ENTERPRISE_PLATFORM; - - public boolean eq(String platform) { - return this.name().equals(platform); - } - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/security/facade/UserAuthLoginFacade.java b/kqapi/src/main/java/com/ningdatech/kqapi/security/facade/UserAuthLoginFacade.java deleted file mode 100644 index 1b2ad78..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/security/facade/UserAuthLoginFacade.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.ningdatech.kqapi.security.facade; - -import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import com.ningdatech.kqapi.common.constant.BizConst; -import com.ningdatech.kqapi.security.constant.AuthTypeEnum; -import com.ningdatech.kqapi.user.model.entity.UserAuth; -import com.ningdatech.kqapi.user.model.entity.UserInfo; -import com.ningdatech.kqapi.security.model.dto.UserInfoBO; -import com.ningdatech.kqapi.user.service.IUserAuthService; -import com.ningdatech.kqapi.user.service.IUserInfoService; -import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Component; - -import java.util.Arrays; -import java.util.List; -import java.util.Objects; - -/** - *

- * UserAuthLoginFacade - *

- * - * @author WendyYang - * @since 10:14 2024/4/20 - */ -@Component -@RequiredArgsConstructor -public class UserAuthLoginFacade { - - private final IUserAuthService userAuthService; - private final IUserInfoService userInfoService; - - private static final List AUTH_TYPES = Arrays.asList(AuthTypeEnum.ACCOUNT_PASSWORD.getKey(), - AuthTypeEnum.PHONE_PASSWORD.getKey()); - - - public UserInfoBO queryUserInfoInPasswordAuth(String username) { - // 获取用户鉴权信息 - UserAuth userAuth = userAuthService.getOne(Wrappers.lambdaQuery(UserAuth.class) - .eq(UserAuth::getIdentifier, username) - .in(UserAuth::getAuthType, AUTH_TYPES) - .last(BizConst.LIMIT_1)); - if (Objects.isNull(userAuth)) { - return null; - } - // 获取用户详情信息 - UserInfo userInfo = userInfoService.getById(userAuth.getUserId()); - UserInfoBO user = new UserInfoBO(); - user.setAccountStatus(userInfo.getAccountStatus()); - user.setUserId(userInfo.getId()); - user.setRealName(userInfo.getRealName()); - user.setUsername(userInfo.getUsername()); - user.setRole(userInfo.getRole()); - user.setIdentifier(userAuth.getIdentifier()); - user.setCredential(userAuth.getCredential()); - return user; - } -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/security/handler/DefaultExpiredSessionStrategy.java b/kqapi/src/main/java/com/ningdatech/kqapi/security/handler/DefaultExpiredSessionStrategy.java deleted file mode 100644 index c4bbf62..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/security/handler/DefaultExpiredSessionStrategy.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.ningdatech.kqapi.security.handler; - -import com.fasterxml.jackson.databind.ObjectMapper; -import com.ningdatech.kqapi.common.constant.BizConst; -import lombok.extern.slf4j.Slf4j; -import org.springframework.security.web.session.SessionInformationExpiredEvent; -import org.springframework.security.web.session.SessionInformationExpiredStrategy; -import org.springframework.stereotype.Component; - -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; - -/** - *

- * DefaultExpiredSessionStrategy - *

- * - * @author WendyYang - * @since 11:33 2024/4/20 - */ -@Slf4j -@Component -public class DefaultExpiredSessionStrategy implements SessionInformationExpiredStrategy { - - private final ObjectMapper objectMapper; - - public DefaultExpiredSessionStrategy(ObjectMapper objectMapper) { - this.objectMapper = objectMapper; - } - - @Override - public void onExpiredSessionDetected(SessionInformationExpiredEvent sessionInformationExpiredEvent) throws IOException { - HttpServletResponse response = sessionInformationExpiredEvent.getResponse(); - response.setContentType(BizConst.JSON_UTF8); - response.getWriter().write(objectMapper.writeValueAsString(BizConst.SESSION_EXPIRE)); - } - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/security/handler/DefaultInvalidSessionStrategy.java b/kqapi/src/main/java/com/ningdatech/kqapi/security/handler/DefaultInvalidSessionStrategy.java deleted file mode 100644 index 6441b1c..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/security/handler/DefaultInvalidSessionStrategy.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.ningdatech.kqapi.security.handler; - -import com.fasterxml.jackson.databind.ObjectMapper; -import com.ningdatech.kqapi.common.constant.BizConst; -import lombok.AllArgsConstructor; -import org.apache.http.HttpStatus; -import org.springframework.security.web.session.InvalidSessionStrategy; -import org.springframework.stereotype.Component; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; - -/** - *

- * DefaultInvalidSessionStrategy - *

- * - * @author WendyYang - * @since 13:52 2023/3/2 - */ -@Component -@AllArgsConstructor -public class DefaultInvalidSessionStrategy implements InvalidSessionStrategy { - - private final ObjectMapper objectMapper; - - @Override - public void onInvalidSessionDetected(HttpServletRequest request, HttpServletResponse response) throws IOException { - response.setContentType(BizConst.JSON_UTF8); - response.setStatus(HttpStatus.SC_UNAUTHORIZED); - response.getWriter().write(objectMapper.writeValueAsString(BizConst.SESSION_EXPIRE)); - } - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/security/handler/DefaultLoginFailureHandler.java b/kqapi/src/main/java/com/ningdatech/kqapi/security/handler/DefaultLoginFailureHandler.java deleted file mode 100644 index 2b26ac3..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/security/handler/DefaultLoginFailureHandler.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.ningdatech.kqapi.security.handler; - -import com.fasterxml.jackson.databind.ObjectMapper; -import com.ningdatech.basic.model.ApiResponse; -import lombok.extern.slf4j.Slf4j; -import org.springframework.context.annotation.Primary; -import org.springframework.http.HttpStatus; -import org.springframework.security.authentication.BadCredentialsException; -import org.springframework.security.core.AuthenticationException; -import org.springframework.security.core.userdetails.UsernameNotFoundException; -import org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler; -import org.springframework.stereotype.Component; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; - -/** - *

- * 登录失败处理器 - *

- * - * @author WendyYang - * @since 00:11 2023/3/2 - */ -@Slf4j -@Primary -@Component -public class DefaultLoginFailureHandler extends SimpleUrlAuthenticationFailureHandler { - - private final ObjectMapper objectMapper; - - public DefaultLoginFailureHandler(ObjectMapper objectMapper) { - this.objectMapper = objectMapper; - } - - @Override - public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response, - AuthenticationException e) throws IOException { - response.setContentType("application/json;charset=UTF-8"); - ApiResponse apiRet; - // 所有的认证异常都可以在这里添加,目前只支持用户名密码错误异常 - if (e instanceof BadCredentialsException || e instanceof UsernameNotFoundException) { - apiRet = ApiResponse.of(ApiResponse.ERROR_CODE, e.getMessage()); - } else { - apiRet = ApiResponse.of(ApiResponse.ERROR_CODE, "登录失败,请联系管理员"); - } - - response.setStatus(HttpStatus.OK.value()); - response.getWriter().write(objectMapper.writeValueAsString(apiRet)); - } - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/security/handler/DefaultLoginSuccessHandler.java b/kqapi/src/main/java/com/ningdatech/kqapi/security/handler/DefaultLoginSuccessHandler.java deleted file mode 100644 index 3106c98..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/security/handler/DefaultLoginSuccessHandler.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.ningdatech.kqapi.security.handler; - -import cn.hutool.core.util.CharsetUtil; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.ningdatech.basic.model.ApiResponse; -import org.springframework.context.annotation.Primary; -import org.springframework.http.MediaType; -import org.springframework.security.core.Authentication; -import org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler; -import org.springframework.stereotype.Component; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; - -/** - *

- * DefaultLoginSuccessHandler - *

- * - * @author WendyYang - * @since 11:26 2024/4/20 - */ -@Primary -@Component("defaultLoginSuccessHandler") -public class DefaultLoginSuccessHandler extends SavedRequestAwareAuthenticationSuccessHandler { - - private final ObjectMapper objectMapper; - - public DefaultLoginSuccessHandler(ObjectMapper objectMapper) { - this.objectMapper = objectMapper; - } - - @Override - public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, - Authentication authentication) throws IOException { - response.setContentType(MediaType.APPLICATION_JSON_VALUE); - response.setCharacterEncoding(CharsetUtil.UTF_8); - response.getWriter().write(objectMapper.writeValueAsString(ApiResponse.ofSuccess())); - } - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/security/handler/DefaultLogoutSuccessHandler.java b/kqapi/src/main/java/com/ningdatech/kqapi/security/handler/DefaultLogoutSuccessHandler.java deleted file mode 100644 index e24d0d7..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/security/handler/DefaultLogoutSuccessHandler.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.ningdatech.kqapi.security.handler; - -import com.fasterxml.jackson.databind.ObjectMapper; -import com.ningdatech.basic.model.ApiResponse; -import org.springframework.context.annotation.Primary; -import org.springframework.security.core.Authentication; -import org.springframework.security.web.authentication.logout.LogoutSuccessHandler; -import org.springframework.stereotype.Component; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; - -/** - *

- * 默认的退出成功处理器 - *

- * - * @author WendyYang - * @since 00:10 2023/3/2 - */ -@Primary -@Component -public class DefaultLogoutSuccessHandler implements LogoutSuccessHandler { - - private final ObjectMapper objectMapper = new ObjectMapper(); - - @Override - public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) - throws IOException { - // 退出成功后返回 和前端约定的Json - response.setContentType("application/json;charset=UTF-8"); - response.getWriter().write(objectMapper.writeValueAsString(ApiResponse.ofSuccess())); - } -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/security/listener/AuthEventListener.java b/kqapi/src/main/java/com/ningdatech/kqapi/security/listener/AuthEventListener.java deleted file mode 100644 index fc15277..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/security/listener/AuthEventListener.java +++ /dev/null @@ -1,82 +0,0 @@ -package com.ningdatech.kqapi.security.listener; - -import cn.hutool.core.date.LocalDateTimeUtil; -import com.ningdatech.kqapi.security.model.UserInfoDetails; -import com.ningdatech.kqapi.security.model.WebRequestDetails; -import com.ningdatech.log.model.OptLogDTO; -import com.ningdatech.log.model.enumeration.LogType; -import com.ningdatech.log.service.OptLogService; -import com.ningdatech.log.util.AddressUtil; -import lombok.RequiredArgsConstructor; -import org.springframework.context.event.EventListener; -import org.springframework.scheduling.annotation.Async; -import org.springframework.security.authentication.event.AbstractAuthenticationEvent; -import org.springframework.security.authentication.event.AuthenticationSuccessEvent; -import org.springframework.security.authentication.event.LogoutSuccessEvent; -import org.springframework.security.core.Authentication; -import org.springframework.stereotype.Component; - -import java.time.LocalDateTime; -import java.time.temporal.ChronoUnit; - -/** - *

- * AuthEventListener - *

- * - * @author WendyYang - * @since 11:27 2024/4/20 - */ -@Component -@RequiredArgsConstructor -public class AuthEventListener { - - private final OptLogService optLogService; - - private static final String LOGIN = "用户登录"; - - private static final String LOGOUT = "退出登录"; - - @Async - @EventListener(AuthenticationSuccessEvent.class) - public void loginSuccessListener(AuthenticationSuccessEvent event) { - OptLogDTO optLog = buildOptLog(LOGIN, event); - optLogService.save(optLog); - } - - @Async - @EventListener(LogoutSuccessEvent.class) - public void logoutSuccessListener(LogoutSuccessEvent event) { - OptLogDTO optLog = buildOptLog(LOGOUT, event); - optLogService.save(optLog); - } - - private OptLogDTO buildOptLog(String description, AbstractAuthenticationEvent event) { - Authentication authentication = event.getAuthentication(); - UserInfoDetails userDetails = (UserInfoDetails) authentication.getPrincipal(); - WebRequestDetails webDetails = (WebRequestDetails) authentication.getDetails(); - OptLogDTO optLog = new OptLogDTO(); - optLog.setActionMethod(webDetails.getServletPath()); - optLog.setDescription(description); - if (event instanceof AuthenticationSuccessEvent) { - optLog.setStartTime(webDetails.getLoginTime()); - } else { - optLog.setStartTime(LocalDateTimeUtil.of(event.getTimestamp())); - } - LocalDateTime now = LocalDateTime.now(); - optLog.setFinishTime(now); - optLog.setCreateOn(now); - long consumingTime = ChronoUnit.MILLIS.between(optLog.getStartTime(), now); - optLog.setConsumingTime(consumingTime); - optLog.setHttpMethod(webDetails.getMethod()); - optLog.setUserName(userDetails.getRealName()); - optLog.setCreateBy(userDetails.getUserId()); - optLog.setRequestIp(webDetails.getRequestIp()); - optLog.setRequestUri(webDetails.getRequestUri()); - optLog.setRegionByIp(AddressUtil.getRegion(optLog.getRequestIp())); - optLog.setUa(webDetails.getUserAgent()); - optLog.setType(LogType.OPT.name()); - return optLog; - } - -} \ No newline at end of file diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/security/model/UserInfoDetails.java b/kqapi/src/main/java/com/ningdatech/kqapi/security/model/UserInfoDetails.java deleted file mode 100644 index 9c34ba2..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/security/model/UserInfoDetails.java +++ /dev/null @@ -1,69 +0,0 @@ -package com.ningdatech.kqapi.security.model; - -import cn.hutool.core.collection.CollectionUtil; -import com.ningdatech.basic.auth.AbstractLoginUser; -import lombok.Data; -import lombok.EqualsAndHashCode; -import org.springframework.security.core.GrantedAuthority; -import org.springframework.security.core.authority.SimpleGrantedAuthority; -import org.springframework.security.core.userdetails.UserDetails; - -import java.util.Collection; -import java.util.List; - -/** - * @author LiuXinXin - * @date 2022/8/1 下午3:32 - */ -@Data -@EqualsAndHashCode(callSuper = true) -public class UserInfoDetails extends AbstractLoginUser implements UserDetails { - - private static final long serialVersionUID = 8576155784065239307L; - - private String password; - - private String role; - - /** - * 获取用户权限 - * - * @return - */ - @Override - public Collection getAuthorities() { - SimpleGrantedAuthority simpleGrantedAuthority = new SimpleGrantedAuthority(this.role); - return CollectionUtil.toList(simpleGrantedAuthority); - } - - @Override - public String getPassword() { - return password; - } - - @Override - public String getUsername() { - return getIdentifier(); - } - - @Override - public boolean isAccountNonExpired() { - return true; - } - - @Override - public boolean isAccountNonLocked() { - return true; - } - - @Override - public boolean isCredentialsNonExpired() { - return true; - } - - @Override - public boolean isEnabled() { - return true; - } - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/security/model/WebRequestDetails.java b/kqapi/src/main/java/com/ningdatech/kqapi/security/model/WebRequestDetails.java deleted file mode 100644 index 5a6e530..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/security/model/WebRequestDetails.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.ningdatech.kqapi.security.model; - -import cn.hutool.core.util.StrUtil; -import cn.hutool.extra.servlet.ServletUtil; -import lombok.Getter; -import org.springframework.security.web.authentication.WebAuthenticationDetails; - -import javax.servlet.http.HttpServletRequest; -import java.time.LocalDateTime; - -/** - *

- * WebRequestDetails - *

- * - * @author WendyYang - * @since 2023/6/7 - **/ -@Getter -public class WebRequestDetails extends WebAuthenticationDetails { - - private static final long serialVersionUID = -4466339683132696235L; - - private final String requestIp; - - private final String requestUri; - - private final String method; - - private final String servletPath; - - private final String requestUrl; - - private final String userAgent; - - private final LocalDateTime loginTime; - - /** - * Records the remote address and will also set the session Id if a session already - * exists (it won't create one). - * - * @param request that the authentication request was received from - */ - public WebRequestDetails(HttpServletRequest request, LocalDateTime loginTime) { - super(request); - this.requestUri = request.getRequestURI(); - this.method = request.getMethod(); - this.servletPath = request.getServletPath(); - this.requestUrl = request.getRequestURL().toString(); - this.requestIp = ServletUtil.getClientIP(request); - this.userAgent = StrUtil.sub(request.getHeader("user-agent"), 0, 500); - this.loginTime = loginTime; - } - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/security/model/dto/LoginDeviceInfoDTO.java b/kqapi/src/main/java/com/ningdatech/kqapi/security/model/dto/LoginDeviceInfoDTO.java deleted file mode 100644 index 1c5a456..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/security/model/dto/LoginDeviceInfoDTO.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.ningdatech.kqapi.security.model.dto; - -import lombok.Data; - -/** - *

- * WechatLoginDeviceInfoDTO - *

- * - * @author WendyYang - * @since 2023/10/31 - **/ -@Data -public class LoginDeviceInfoDTO { - - private String deviceModel; - - private String openId; - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/security/model/dto/UserInfoBO.java b/kqapi/src/main/java/com/ningdatech/kqapi/security/model/dto/UserInfoBO.java deleted file mode 100644 index 51227f8..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/security/model/dto/UserInfoBO.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.ningdatech.kqapi.security.model.dto; - -import com.ningdatech.kqapi.user.model.enumerization.AccountStatus; -import lombok.Data; - -/** - *

- * UserInfoBO - *

- * - * @author WendyYang - * @since 10:16 2024/4/20 - */ -@Data -public class UserInfoBO { - - private Long userId; - - private String realName; - - private String username; - - private String identifier; - - private String credential; - - private String role; - - private AccountStatus accountStatus; - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/security/password/PasswordAuthProvider.java b/kqapi/src/main/java/com/ningdatech/kqapi/security/password/PasswordAuthProvider.java deleted file mode 100644 index 839e0a0..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/security/password/PasswordAuthProvider.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.ningdatech.kqapi.security.password; - -import com.ningdatech.kqapi.user.helper.LoginHelper; -import lombok.Setter; -import org.springframework.security.authentication.AuthenticationProvider; -import org.springframework.security.core.Authentication; -import org.springframework.security.core.AuthenticationException; -import org.springframework.security.core.userdetails.UserDetails; -import org.springframework.security.core.userdetails.UserDetailsService; - -/** - *

- * UsernamePasswordAuthProvider - *

- * - * @author LiuXinXin - * @since 2020/8/3 8:55 下午 - **/ -@Setter -public class PasswordAuthProvider implements AuthenticationProvider { - - private UserDetailsService userDetailsService; - - private LoginHelper loginHelper; - - @Override - public Authentication authenticate(Authentication authentication) throws AuthenticationException { - UsernamePasswordAuthToken authToken = (UsernamePasswordAuthToken) authentication; - - UserDetails user = userDetailsService.loadUserByUsername((String) authToken.getPrincipal()); - loginHelper.checkPassword(user, authToken); - // 校验用户是否有当前端的登陆权限 - // 将用户定义的user放入token中,这样可以在session中查询到所有自定义的用户信息 - return new UsernamePasswordAuthToken(user, user.getPassword(), user.getAuthorities()); - } - - @Override - public boolean supports(Class authentication) { - return UsernamePasswordAuthToken.class.isAssignableFrom(authentication); - } - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/security/password/PasswordAuthSecurityConfig.java b/kqapi/src/main/java/com/ningdatech/kqapi/security/password/PasswordAuthSecurityConfig.java deleted file mode 100644 index b8b931f..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/security/password/PasswordAuthSecurityConfig.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.ningdatech.kqapi.security.password; - -import com.ningdatech.kqapi.security.AuthProperties; -import com.ningdatech.kqapi.user.helper.LoginHelper; -import lombok.RequiredArgsConstructor; -import org.springframework.security.authentication.AuthenticationManager; -import org.springframework.security.config.annotation.SecurityConfigurerAdapter; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.core.userdetails.UserDetailsService; -import org.springframework.security.web.DefaultSecurityFilterChain; -import org.springframework.security.web.authentication.AuthenticationFailureHandler; -import org.springframework.security.web.authentication.AuthenticationSuccessHandler; -import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; -import org.springframework.stereotype.Component; - -/** - *

- * 账号密码登陆的认证配置 - *

- * - * @author WendyYang - * @since 09:54 2023/3/2 - */ -@Component -@RequiredArgsConstructor -public class PasswordAuthSecurityConfig extends SecurityConfigurerAdapter { - - private final AuthenticationSuccessHandler authenticationSuccessHandler; - private final AuthenticationFailureHandler authenticationFailureHandler; - private final UserDetailsService userDetailsService; - private final AuthProperties authProperties; - private final LoginHelper loginHelper; - - @Override - public void configure(HttpSecurity http) { - UsernamePasswordAuthFilter authFilter = new UsernamePasswordAuthFilter(authProperties.getPasswordLoginUrl(), - authProperties.getPostOnlyByLogin()); - AuthenticationManager authenticationManager = http.getSharedObject(AuthenticationManager.class); - authFilter.setAuthenticationManager(authenticationManager); - authFilter.setAuthenticationSuccessHandler(authenticationSuccessHandler); - authFilter.setAuthenticationFailureHandler(authenticationFailureHandler); - - PasswordAuthProvider authProvider = new PasswordAuthProvider(); - authProvider.setUserDetailsService(userDetailsService); - // 确保对密码进行加密的encoder和解密的encoder相同 - authProvider.setLoginHelper(loginHelper); - http.authenticationProvider(authProvider) - .addFilterAfter(authFilter, UsernamePasswordAuthenticationFilter.class); - } - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/security/password/PasswordLoginUserDetailService.java b/kqapi/src/main/java/com/ningdatech/kqapi/security/password/PasswordLoginUserDetailService.java deleted file mode 100644 index cb7c47a..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/security/password/PasswordLoginUserDetailService.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.ningdatech.kqapi.security.password; - -import com.baomidou.mybatisplus.core.toolkit.Assert; -import com.ningdatech.kqapi.security.facade.UserAuthLoginFacade; -import com.ningdatech.kqapi.security.model.UserInfoDetails; -import com.ningdatech.kqapi.security.model.dto.UserInfoBO; -import lombok.RequiredArgsConstructor; -import org.springframework.context.annotation.Primary; -import org.springframework.security.core.userdetails.UserDetailsService; -import org.springframework.security.core.userdetails.UsernameNotFoundException; -import org.springframework.stereotype.Service; - -import static com.ningdatech.kqapi.user.model.enumerization.AccountStatus.ENABLE; - -/** - *

- * PasswordLoginUserDetailService - *

- * - * @author WendyYang - * @since 10:20 2024/4/20 - */ -@Primary -@Service -@RequiredArgsConstructor -public class PasswordLoginUserDetailService implements UserDetailsService { - - private final UserAuthLoginFacade userAuthLoginFacade; - - @Override - public UserInfoDetails loadUserByUsername(String username) throws UsernameNotFoundException { - UserInfoBO user = userAuthLoginFacade.queryUserInfoInPasswordAuth(username); - Assert.notNull(user, "用户不存在"); - Assert.isTrue(ENABLE.equals(user.getAccountStatus()), "用户已被禁用"); - UserInfoDetails details = new UserInfoDetails(); - details.setUserId(user.getUserId()); - details.setUsername(user.getRealName()); - details.setRealName(user.getRealName()); - details.setRole(user.getRole()); - details.setIdentifier(user.getIdentifier()); - details.setPassword(user.getCredential()); - return details; - } - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/security/password/UsernamePasswordAuthFilter.java b/kqapi/src/main/java/com/ningdatech/kqapi/security/password/UsernamePasswordAuthFilter.java deleted file mode 100644 index 05ca02d..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/security/password/UsernamePasswordAuthFilter.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.ningdatech.kqapi.security.password; - -import cn.hutool.core.util.StrUtil; -import com.ningdatech.kqapi.common.exception.BizException; -import com.ningdatech.kqapi.security.constant.AuthConst; -import com.ningdatech.kqapi.security.model.WebRequestDetails; -import org.springframework.http.HttpMethod; -import org.springframework.security.authentication.BadCredentialsException; -import org.springframework.security.core.Authentication; -import org.springframework.security.core.AuthenticationException; -import org.springframework.security.core.userdetails.UsernameNotFoundException; -import org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter; -import org.springframework.security.web.util.matcher.AntPathRequestMatcher; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.time.LocalDateTime; - -/** - *

- * UsernamePasswordAuthFilter - *

- * - * @author WendyYang - * @since 2023/9/1 - **/ -public class UsernamePasswordAuthFilter extends AbstractAuthenticationProcessingFilter { - - private final Boolean postOnly; - - public UsernamePasswordAuthFilter(String processingUrl, Boolean postOnly) { - super(new AntPathRequestMatcher(processingUrl, HttpMethod.POST.name())); - this.postOnly = postOnly; - } - - @Override - public Authentication attemptAuthentication(HttpServletRequest request, HttpServletResponse response) - throws AuthenticationException { - LocalDateTime now = LocalDateTime.now(); - if (Boolean.TRUE.equals(postOnly) && !request.getMethod().equals(HttpMethod.POST.name())) { - throw BizException.wrap("请求方法错误"); - } - String username = StrUtil.trim(request.getParameter(AuthConst.USERNAME)); - String password = StrUtil.trim(request.getParameter(AuthConst.PASSWORD)); - try { - UsernamePasswordAuthToken authRequest = new UsernamePasswordAuthToken(username, password); - authRequest.setDetails(new WebRequestDetails(request, now)); - return this.getAuthenticationManager().authenticate(authRequest); - } catch (BadCredentialsException | UsernameNotFoundException e) { - throw e; - } catch (Exception e) { - throw BizException.wrap("登录失败,请联系管理员!"); - } - } - - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/security/password/UsernamePasswordAuthToken.java b/kqapi/src/main/java/com/ningdatech/kqapi/security/password/UsernamePasswordAuthToken.java deleted file mode 100644 index c415acc..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/security/password/UsernamePasswordAuthToken.java +++ /dev/null @@ -1,85 +0,0 @@ -package com.ningdatech.kqapi.security.password; - -import lombok.Getter; -import lombok.Setter; -import org.springframework.security.authentication.AbstractAuthenticationToken; -import org.springframework.security.core.GrantedAuthority; -import org.springframework.security.core.SpringSecurityCoreVersion; - -import java.util.Collection; - -/** - *

- * UsernamePasswordAuthToken - *

- * - * @author LiuXinXin - * @since 2023/10/31 - **/ -@Getter -@Setter -public class UsernamePasswordAuthToken extends AbstractAuthenticationToken { - - private static final long serialVersionUID = SpringSecurityCoreVersion.SERIAL_VERSION_UID; - - private final Object principal; - - private final Object credentials; - - private transient String openId; - - private transient String deviceModel; - - /** - * This constructor can be safely used by any code that wishes to create a - * UsernamePasswordAuthenticationToken, as the {@link #isAuthenticated()} will return - * false. - */ - public UsernamePasswordAuthToken(String principal, String credentials) { - super(null); - this.principal = principal; - this.credentials = credentials; - setAuthenticated(false); - } - - /** - * This constructor should only be used by AuthenticationManager or AuthenticationProvider - * implementations that are satisfied with producing a trusted (i.e. {@link #isAuthenticated()} = true) - * authentication token. - * - * @param principal \ - * @param authorities \ - */ - public UsernamePasswordAuthToken(Object principal, Object credentials, - Collection authorities) { - super(authorities); - this.principal = principal; - this.credentials = credentials; - super.setAuthenticated(true); - } - - @Override - public Object getCredentials() { - return this.credentials; - } - - @Override - public Object getPrincipal() { - return this.principal; - } - - @Override - public void setAuthenticated(boolean isAuthenticated) throws IllegalArgumentException { - if (isAuthenticated) { - throw new IllegalArgumentException( - "Cannot set this token to trusted - use constructor which takes a GrantedAuthority list instead"); - } - super.setAuthenticated(false); - } - - @Override - public void eraseCredentials() { - super.eraseCredentials(); - } - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/sso/controller/SsoController.java b/kqapi/src/main/java/com/ningdatech/kqapi/sso/controller/SsoController.java deleted file mode 100644 index 913aa00..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/sso/controller/SsoController.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.ningdatech.kqapi.sso.controller; - -import com.ningdatech.kqapi.sso.manage.SsoManage; -import com.ningdatech.kqapi.sso.model.dto.ReqSsoDTO; -import com.ningdatech.kqapi.sso.model.vo.SsoTokenVO; -import com.ningdatech.kqapi.sso.model.vo.SsoUserInfoVO; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.validation.Valid; - -/** - * @author CMM - * @since 2024/04/07 11:15 - */ -@Slf4j -@Validated -@RestController -@RequestMapping("/api/v1/sso/") -@RequiredArgsConstructor -public class SsoController { - - private final SsoManage ssoManage; - - @PostMapping ("/token") - public SsoTokenVO getToken(@Valid @RequestBody ReqSsoDTO reqSsoDTO) { - return ssoManage.getToken(reqSsoDTO); - } - - @PostMapping ("/getUserInfo") - public SsoUserInfoVO getUserInfo(@Valid @RequestBody ReqSsoDTO reqSsoDTO) { - return ssoManage.getUserInfo(reqSsoDTO); - } -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/sso/manage/SsoManage.java b/kqapi/src/main/java/com/ningdatech/kqapi/sso/manage/SsoManage.java deleted file mode 100644 index 6f555bd..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/sso/manage/SsoManage.java +++ /dev/null @@ -1,88 +0,0 @@ -package com.ningdatech.kqapi.sso.manage; - -import java.util.Map; - -import org.apache.commons.lang3.StringUtils; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.http.HttpEntity; -import org.springframework.stereotype.Component; -import org.springframework.util.MultiValueMap; -import org.springframework.web.client.RestTemplate; - -import com.ningdatech.kqapi.common.exception.BizException; -import com.ningdatech.kqapi.sso.model.dto.ReqSsoDTO; -import com.ningdatech.kqapi.sso.model.vo.SsoTokenVO; -import com.ningdatech.kqapi.sso.model.vo.SsoUserInfoVO; -import com.ningdatech.kqapi.sso.utils.HmacAuthUtil; - -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; - - -/** - * @author CMM - * @since 2024/04/07 11:17 - */ -@Component -@Slf4j -@RequiredArgsConstructor -public class SsoManage { - - @Value("${sso.token.internet-url}") - //@Value("${sso.token.zww-url}") - private String tokenUrl; - - @Value("${sso.user-info.internet-url}") - //@Value("${sso.user-info.zww-url}") - private String userInfoUrl; - - @Value("${sso.access-key}") - private String accessKey; - - @Value("${sso.secret-key}") - private String secretKey; - - @Value("${sso.app-id}") - private String appId; - - private final RestTemplate restTemplate; - - /** - * 基于单点登录票据换取请求 token - * - * @param reqSsoDTO \ - * @return SsoTokenVO - */ - public SsoTokenVO getToken(ReqSsoDTO reqSsoDTO) { - String ticketId = reqSsoDTO.getTicketId(); - if (StringUtils.isBlank(ticketId)){ - throw new BizException("登录票据不能为空!"); - } - Map header = HmacAuthUtil.generateHeader(tokenUrl, "POST", accessKey, secretKey); - MultiValueMap multiValueMap = HmacAuthUtil.convertToMultiValueMap(header); - reqSsoDTO.setAppId(appId); - HttpEntity httpEntity = new HttpEntity<>(reqSsoDTO, multiValueMap); - SsoTokenVO res = restTemplate.postForObject(tokenUrl, httpEntity, SsoTokenVO.class); - log.info("[RestTemplateTest-基于单点登录票据换取请求token] http request :{}", res); - return res; - } - - /** - * 基于 token 获取用户信息 - * - * @param reqSsoDTO \ - * @return SsoUserInfoVO - */ - public SsoUserInfoVO getUserInfo(ReqSsoDTO reqSsoDTO) { - String token = reqSsoDTO.getToken(); - if (StringUtils.isBlank(token)){ - throw new BizException("token不能为空!"); - } - Map header = HmacAuthUtil.generateHeader(userInfoUrl, "POST", accessKey, secretKey); - MultiValueMap multiValueMap = HmacAuthUtil.convertToMultiValueMap(header); - HttpEntity httpEntity = new HttpEntity<>(reqSsoDTO,multiValueMap); - SsoUserInfoVO res = restTemplate.postForObject(userInfoUrl, httpEntity, SsoUserInfoVO.class); - log.info("[RestTemplateTest-基于token获取用户信息] http request :{}", res); - return res; - } -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/sso/model/dto/ReqSsoDTO.java b/kqapi/src/main/java/com/ningdatech/kqapi/sso/model/dto/ReqSsoDTO.java deleted file mode 100644 index b356b8c..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/sso/model/dto/ReqSsoDTO.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.ningdatech.kqapi.sso.model.dto; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -import javax.validation.constraints.NotNull; - -/** - * @author CMM - * @since 2024/04/07 11:22 - */ -@Data -@ApiModel(value = "ReqTokenDTO", description = "获取Token请求实体") -public class ReqSsoDTO { - - @ApiModelProperty("单点登录票据") - private String ticketId; - - @ApiModelProperty("应用发布 ID") - private String appId; - - @ApiModelProperty("单点登录Token") - private String token; -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/sso/model/vo/SsoTokenVO.java b/kqapi/src/main/java/com/ningdatech/kqapi/sso/model/vo/SsoTokenVO.java deleted file mode 100644 index 41c4a8e..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/sso/model/vo/SsoTokenVO.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.ningdatech.kqapi.sso.model.vo; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -/** - * @author CMM - * @since 2024/04/07 11:19 - */ -@Data -@ApiModel(value = "SsoTokenVO", description = "单点登录TokenVO") -public class SsoTokenVO { - - @ApiModelProperty("错误码") - private String errorCode; - - @ApiModelProperty("错误信息") - private String errorMsg; - - @ApiModelProperty("是否成功") - private Boolean success; - - @ApiModelProperty("响应体") - private Object data; - - @ApiModelProperty("token") - private String token; -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/sso/model/vo/SsoUserInfoVO.java b/kqapi/src/main/java/com/ningdatech/kqapi/sso/model/vo/SsoUserInfoVO.java deleted file mode 100644 index afb46c7..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/sso/model/vo/SsoUserInfoVO.java +++ /dev/null @@ -1,154 +0,0 @@ -package com.ningdatech.kqapi.sso.model.vo; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -import java.util.List; - -/** - * @author CMM - * @since 2024/04/07 11:19 - */ -@Data -@ApiModel(value = "SsoUserInfoVO", description = "单点登录UserInfoVO") -public class SsoUserInfoVO { - - @ApiModelProperty("错误码") - private String errorCode; - - @ApiModelProperty("错误信息") - private String errorMsg; - - @ApiModelProperty("是否成功") - private Boolean success; - - @ApiModelProperty("响应体") - private Object data; - - @ApiModelProperty("用户类型 PERSON 个人、LEGAL_PERSON 法人") - private String userType; - - @ApiModelProperty("个人用户信息 当前登录自然人的信息") - private Object personInfo; - - @ApiModelProperty("主键") - private String userId; - - @ApiModelProperty("个人姓名") - private String userName; - - @ApiModelProperty("ID_CARD:身份证,PASSPORT:护\n" + - "照,OFFICER_CARD:军官\n" + - "证,MAINLAND_TRAVEL_PERMIT_FOR\n" + - "_HONGKONG_AND_MACAO_RESIDENTS\n" + - ":港澳居民来往内地通行\n" + - "证,MAINLAND_TRAVEL_PERMIT_FOR\n" + - "_TAIWAN_RESIDENTS:台湾居民来\n" + - "往大陆通行\n" + - "证,FOREIGN_PERMANENT_RESIDENT\n" + - "_ID_CARD:外国人永久居留身份\n" + - "证,FOREIGN_PASSPORT:外籍人士\n" + - "护照,DIPLOMACY_PASSPORT:外交\n" + - "护照,OFFICIAL_PASSPORT:公务护\n" + - "照,SOLDIER_CARD:士兵\n" + - "证,OFFICER_RETIRE_CARD:军官离\n" + - "退休\n" + - "证,GANG_AO_TAI_RESIDENCE_CART\n" + - ":港澳台居民居住\n" + - "证,GANG_AO_ID_CART:港澳居民身\n" + - "份证,UNIFIED_SOCIAL_ID:统一社\n" + - "会信用代码,OTHER:其他") - private String idType; - - @ApiModelProperty("外部证件类型") - private String outerIdType; - - @ApiModelProperty("证件编号") - private String idNo; - - @ApiModelProperty("法人经办人时用户类型,评级") - private String attnUserType; - - @ApiModelProperty("手机号") - private String phone; - - @ApiModelProperty("邮箱") - private String email; - - @ApiModelProperty("民族") - private String nation; - - @ApiModelProperty("性别") - private String gender; - - @ApiModelProperty("生日") - private String birthday; - - @ApiModelProperty("身份散列值") - private String certKey; - - @ApiModelProperty("额外属性") - private Object attributes; - - @ApiModelProperty("法人用户信息,比如公司相关的信\n" + - "息") - private Object legalPersonInfo; - - @ApiModelProperty("法人名称") - private String name; - - @ApiModelProperty("社会统一信用代码") - private String unifiedSocialId; - - @ApiModelProperty("法人类型") - private String orgType; - - @ApiModelProperty("经办人姓名") - private String attnName; - - @ApiModelProperty("经办人手机号") - private String attnPhone; - - @ApiModelProperty("经办人证件类型") - private String attnIdType; - - @ApiModelProperty("经办人证件号码") - private String attnIdNo; - - @ApiModelProperty("法人代表人姓名") - private String principal; - - @ApiModelProperty("法人代表唯一键") - private String principalUserId; - - @ApiModelProperty("法人唯一键") - private String corpId; - - @ApiModelProperty("所属组织信息") - private List organizationInfoList; - - @ApiModelProperty("组织主键") - private String orgId; - - @ApiModelProperty("Alias for orgId") - private String oid; - - @ApiModelProperty("父组织主键") - private String parentId; - - @ApiModelProperty("Alias for parentId") - private String pid; - - @ApiModelProperty("组织机构全称") - private String fullName; - - @ApiModelProperty("组织后缀") - private String devCoding; - - @ApiModelProperty("是否叶子标志") - private Boolean leafFlag; - - @ApiModelProperty("排序号,从小到大") - private Integer orderBy; -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/sso/utils/HmacAuthUtil.java b/kqapi/src/main/java/com/ningdatech/kqapi/sso/utils/HmacAuthUtil.java deleted file mode 100644 index d1514b7..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/sso/utils/HmacAuthUtil.java +++ /dev/null @@ -1,132 +0,0 @@ -package com.ningdatech.kqapi.sso.utils; - -import java.io.UnsupportedEncodingException; -import java.net.URI; -import java.net.URL; -import java.net.URLEncoder; -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.*; -import java.util.stream.Collectors; - -import javax.crypto.Mac; -import javax.crypto.spec.SecretKeySpec; -import javax.xml.bind.DatatypeConverter; - -import org.apache.commons.math3.util.Pair; -import org.springframework.util.LinkedMultiValueMap; -import org.springframework.util.MultiValueMap; - -import lombok.extern.slf4j.Slf4j; - -/** - * @author CMM - * @since 2024/04/07 11:28 - */ - -@Slf4j -public class HmacAuthUtil { - - /** - * 构造请求 header - * - * @param urlStr 请求url,全路径格式,比如:https://bcdsg.zj.gov.cn/api/p/v1/user.get - * @param requestMethod 请求方法,大写格式,如:GET, POST - * @param accessKey 应用的 AK - * @param secretKey 应用的 SK - * @return - */ - public static Map generateHeader(String urlStr, String requestMethod, String accessKey, String secretKey) { - log.info("params,urlStr={},requestMethod={},accessKey={},secretKey={}",urlStr,requestMethod,accessKey,secretKey); - Map header = new HashMap<>(); - try { - DateFormat dateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z", Locale.US); - dateFormat.setTimeZone(TimeZone.getTimeZone("GMT")); - String date = dateFormat.format(new Date()); - URL url = new URL(urlStr); - URI uri = new URI(url.getProtocol(), url.getHost(), url.getPath(), url.getQuery(), null); - - String canonicalQueryString = getCanonicalQueryString(uri.getQuery()); - - String message = requestMethod.toUpperCase() + "\n" + uri.getPath() + "\n" + canonicalQueryString + "\n" + accessKey + "\n" + date + "\n"; - - Mac hasher = Mac.getInstance("HmacSHA256"); - hasher.init(new SecretKeySpec(secretKey.getBytes(), "HmacSHA256")); - - byte[] hash = hasher.doFinal(message.getBytes()); - - // to lowercase hexits - DatatypeConverter.printHexBinary(hash); - - // to base64 - String sign = DatatypeConverter.printBase64Binary(hash); - header.put("X-BG-HMAC-SIGNATURE", sign); - header.put("X-BG-HMAC-ALGORITHM", "hmac-sha256"); - header.put("X-BG-HMAC-ACCESS-KEY", accessKey); - header.put("X-BG-DATE-TIME", date); - } catch (Exception e) { - log.error("generate error",e); - throw new RuntimeException("generate header error"); - } - log.info("header info,{}",header); - return header; - } - - private static String getCanonicalQueryString(String query) { - if (query == null || query.trim().length() == 0) { - return ""; - } - List> queryParamList = new ArrayList<>(); - String[] params = query.split("&"); - for (String param : params) { - int eqIndex = param.indexOf("="); - String key = param; - String value = ""; - if(eqIndex!=-1){ - key = param.substring(0, eqIndex); - value = param.substring(eqIndex+1); - } - Pair pair = new Pair<>(key, value); - queryParamList.add(pair); - } - - List> sortedParamList = queryParamList.stream().sorted(Comparator.comparing(param -> param.getKey() + "=" + Optional.ofNullable(param.getValue()).orElse(""))).collect(Collectors.toList()); - List> encodeParamList = new ArrayList<>(); - sortedParamList.stream().forEach(param -> { - try { - String key = URLEncoder.encode(param.getKey(), "utf-8"); - String value = URLEncoder.encode(Optional.ofNullable(param.getValue()).orElse(""), "utf-8") - .replaceAll("\\%2B","%20") - .replaceAll("\\+","%20") - .replaceAll("\\%21","!") - .replaceAll("\\%27","'") - .replaceAll("\\%28","(") - .replaceAll("\\%29",")") - .replaceAll("\\%7E","~") - .replaceAll("\\%25","%") - ; - encodeParamList.add(new Pair<>(key, value)); - } catch (UnsupportedEncodingException e) { - throw new RuntimeException("encoding error"); - } - }); - StringBuilder queryParamString = new StringBuilder(64); - for (Pair encodeParam : encodeParamList) { - queryParamString.append(encodeParam.getKey()).append("=").append(Optional.ofNullable(encodeParam.getValue()).orElse("")); - queryParamString.append("&"); - } - - return queryParamString.substring(0, queryParamString.length() - 1); - } - - - public static MultiValueMap convertToMultiValueMap(Map sourceMap) { - LinkedMultiValueMap multiValueMap = new LinkedMultiValueMap<>(); - - for (Map.Entry entry : sourceMap.entrySet()) { - multiValueMap.add(entry.getKey(), entry.getValue()); - } - - return multiValueMap; - } -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/user/controller/UserAuthController.java b/kqapi/src/main/java/com/ningdatech/kqapi/user/controller/UserAuthController.java deleted file mode 100644 index 45cef3d..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/user/controller/UserAuthController.java +++ /dev/null @@ -1,77 +0,0 @@ -package com.ningdatech.kqapi.user.controller; - - -import com.fasterxml.jackson.databind.ObjectMapper; -import com.ningdatech.kqapi.common.constant.BizConst; -import com.ningdatech.kqapi.common.util.StrPool; -import com.ningdatech.kqapi.security.constant.AuthConst; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiImplicitParam; -import io.swagger.annotations.ApiImplicitParams; -import io.swagger.annotations.ApiOperation; -import lombok.RequiredArgsConstructor; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.web.bind.annotation.*; - -import javax.servlet.http.Cookie; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; - -/** - * @author Liuxinxin - * @since 2022-11-23 - */ -@RestController -@RequestMapping("/api/v1/user/auth") -@Api(tags = {"用户鉴权-相关接口"}) -@RequiredArgsConstructor -public class UserAuthController { - - private final ObjectMapper objectMapper; - - @PostMapping(value = "/login/password", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE) - @ApiOperation(value = "账号密码的登陆方式") - @ApiImplicitParams({ - @ApiImplicitParam(name = "username", value = "用户名", required = true, paramType = "form", dataType = "String"), - @ApiImplicitParam(name = "password", value = "密码", required = true, paramType = "form", dataType = "String") - }) - public void loginByUsernameAndPassword(@RequestParam("username") String username, - @RequestParam("password") String password) { - // 不实现任何内容,只是为了出api文档 - } - - @PostMapping(value = "/logout") - @ApiOperation(value = "退出登陆") - public void logout() { - // 不实现任何内容,具体实现交由Spring Security进行管理 - } - - /** - * 当需要身份认证时,跳转到这里 - */ - @GetMapping("/auth-require") - @CrossOrigin(originPatterns = "*", allowCredentials = "true", maxAge = 3600) - public void requireAuthentication(HttpServletResponse response) throws IOException { - response.setContentType(StrPool.CONTENT_TYPE); - response.setStatus(HttpStatus.UNAUTHORIZED.value()); - response.getWriter().write(objectMapper.writeValueAsString(BizConst.UNAUTHENTICATED)); - } - - /** - * 设置session失效 - */ - @GetMapping("/invalid-session") - @CrossOrigin(originPatterns = "*", allowCredentials = "true", maxAge = 3600) - public void invalidSession(HttpServletRequest request, HttpServletResponse response) throws IOException { - response.setContentType(StrPool.CONTENT_TYPE); - Cookie cookie = new Cookie(BizConst.COOKIE_KEY, null); - cookie.setPath(request.getContextPath() + "/"); - cookie.setMaxAge(AuthConst.SESSION_EXPIRED); - response.addCookie(cookie); - response.setStatus(HttpStatus.UNAUTHORIZED.value()); - response.getWriter().write(objectMapper.writeValueAsString(BizConst.UNAUTHENTICATED)); - } - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/user/controller/UserInfoController.java b/kqapi/src/main/java/com/ningdatech/kqapi/user/controller/UserInfoController.java deleted file mode 100644 index c56b5c5..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/user/controller/UserInfoController.java +++ /dev/null @@ -1,100 +0,0 @@ -package com.ningdatech.kqapi.user.controller; - - -import com.ningdatech.basic.model.IdVo; -import com.ningdatech.basic.model.PageVo; -import com.ningdatech.kqapi.user.manage.UserInfoManage; -import com.ningdatech.kqapi.user.model.po.ChangeAccountStatusReq; -import com.ningdatech.kqapi.user.model.po.ModifyPasswordReq; -import com.ningdatech.kqapi.user.model.po.SaveUserReq; -import com.ningdatech.kqapi.user.model.po.UserListReq; -import com.ningdatech.kqapi.user.model.vo.LoginUserDetailVO; -import com.ningdatech.kqapi.user.model.vo.UserDetailVO; -import com.ningdatech.kqapi.user.model.vo.UserListVO; -import com.ningdatech.log.annotation.WebLog; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import lombok.RequiredArgsConstructor; -import org.springframework.web.bind.annotation.*; - -import javax.validation.Valid; - -/** - *

- * 前端控制器 - *

- * - * @author Liuxinxin - * @since 2022-11-23 - */ -@RestController -@RequestMapping("/api/v1/user-info") -@Api(tags = {"用户信息-相关接口"}) -@RequiredArgsConstructor -public class UserInfoController { - - private final UserInfoManage userInfoManage; - - @PostMapping(value = "/save") - @ApiOperation(value = "保存用户") - @WebLog(value = "保存用户") - public void saveUser(@Valid @RequestBody SaveUserReq request) { - userInfoManage.saveUser(request); - } - - @PostMapping(value = "/changeAccountStatus") - @ApiOperation(value = "账号状态变更") - @WebLog(value = "账号状态变更") - public void changeAccountStatus(@Valid @RequestBody ChangeAccountStatusReq req) { - userInfoManage.changeAccountStatus(req); - } - - @GetMapping("detail/{userId}") - @ApiOperation("获取用户详情") - @WebLog(value = "获取用户详情") - public UserDetailVO getUserDetail(@PathVariable Long userId) { - return userInfoManage.getUserDetail(userId); - } - - @DeleteMapping("/del") - @ApiOperation("删除用户") - @WebLog(value = "删除用户") - public void deleteUser(@RequestBody IdVo req) { - userInfoManage.deleteUser(req.getId()); - } - - @PostMapping(value = "/list") - @ApiOperation(value = "用户列表筛选") - @WebLog(value = "用户列表筛选") - public PageVo listUser(@Valid @RequestBody UserListReq request) { - return userInfoManage.listUser(request); - } - - @PostMapping(value = "/basic-info") - @ApiOperation("获取用户基本信息") - @WebLog(value = "获取用户基本信息") - public LoginUserDetailVO loginUserDetail() { - return userInfoManage.loginUserDetail(); - } - - @PostMapping("/kick-off/{userId}") - @ApiOperation("踢用户下线测试接口") - public void kickOff(@Valid @PathVariable Long userId) { - userInfoManage.kickOff(userId); - } - - @PostMapping("/password/mod") - @ApiOperation("修改密码") - @WebLog(value = "修改密码") - public void changePassword(@Valid @RequestBody ModifyPasswordReq po) { - userInfoManage.changePassword(po); - } - - @PostMapping("/password/self") - @ApiOperation("修改个人密码") - @WebLog(value = "修改个人密码") - public void changePasswordByUser(@Valid @RequestBody ModifyPasswordReq po) { - userInfoManage.changePasswordByUser(po); - } - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/user/helper/LoginHelper.java b/kqapi/src/main/java/com/ningdatech/kqapi/user/helper/LoginHelper.java deleted file mode 100644 index a629a9d..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/user/helper/LoginHelper.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.ningdatech.kqapi.user.helper; - -import com.ningdatech.kqapi.security.password.UsernamePasswordAuthToken; -import lombok.AllArgsConstructor; -import org.springframework.security.authentication.BadCredentialsException; -import org.springframework.security.core.AuthenticationException; -import org.springframework.security.core.userdetails.UserDetails; -import org.springframework.security.crypto.password.PasswordEncoder; -import org.springframework.stereotype.Component; - -/** - *

- * LoginHelper - *

- * - * @author WendyYang - * @since 2023/10/31 - **/ -@Component -@AllArgsConstructor -public class LoginHelper { - - private final PasswordEncoder passwordEncoder; - - public void checkPassword(UserDetails userDetails, UsernamePasswordAuthToken authToken) - throws AuthenticationException { - String presentedPassword = authToken.getCredentials().toString(); - if (!passwordEncoder.matches(presentedPassword, userDetails.getPassword())) { - throw new BadCredentialsException("用户名或密码错误"); - } - } - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/user/helper/UserInfoHelper.java b/kqapi/src/main/java/com/ningdatech/kqapi/user/helper/UserInfoHelper.java deleted file mode 100644 index 1fb8e65..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/user/helper/UserInfoHelper.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.ningdatech.kqapi.user.helper; - - -/** - *

- * UserInfoHelper - *

- * - * @author WendyYang - * @since 2023/7/11 - **/ -public class UserInfoHelper { - - private UserInfoHelper() { - } - - - - - - - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/user/manage/UserInfoManage.java b/kqapi/src/main/java/com/ningdatech/kqapi/user/manage/UserInfoManage.java deleted file mode 100644 index 1b2f101..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/user/manage/UserInfoManage.java +++ /dev/null @@ -1,245 +0,0 @@ -package com.ningdatech.kqapi.user.manage; - -import cn.hutool.core.collection.CollectionUtil; -import cn.hutool.core.lang.Assert; -import cn.hutool.core.util.StrUtil; -import com.baomidou.mybatisplus.core.conditions.Wrapper; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.ningdatech.basic.exception.BizException; -import com.ningdatech.basic.model.PageVo; -import com.ningdatech.basic.util.CollUtils; -import com.ningdatech.kqapi.common.constant.BizConst; -import com.ningdatech.kqapi.security.constant.AuthTypeEnum; -import com.ningdatech.kqapi.security.model.UserInfoDetails; -import com.ningdatech.kqapi.user.model.entity.UserAuth; -import com.ningdatech.kqapi.user.model.entity.UserInfo; -import com.ningdatech.kqapi.user.model.enumerization.AccountStatus; -import com.ningdatech.kqapi.user.model.po.ChangeAccountStatusReq; -import com.ningdatech.kqapi.user.model.po.ModifyPasswordReq; -import com.ningdatech.kqapi.user.model.po.SaveUserReq; -import com.ningdatech.kqapi.user.model.po.UserListReq; -import com.ningdatech.kqapi.user.model.vo.UserListVO; -import com.ningdatech.kqapi.user.model.vo.LoginUserDetailVO; -import com.ningdatech.kqapi.user.model.vo.UserDetailVO; -import com.ningdatech.kqapi.user.service.IUserAuthService; -import com.ningdatech.kqapi.user.service.IUserInfoService; -import com.ningdatech.kqapi.user.util.BizUtils; -import com.ningdatech.kqapi.user.util.LoginUserUtil; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.security.crypto.password.PasswordEncoder; -import org.springframework.session.data.redis.RedisIndexedSessionRepository; -import org.springframework.stereotype.Component; -import org.springframework.transaction.annotation.Transactional; - -import java.time.LocalDateTime; -import java.util.*; -import java.util.stream.Collectors; - - -/** - * @author liuxinxin - * @date 2022/11/23 下午5:04 - */ -@Slf4j -@Component -@RequiredArgsConstructor -public class UserInfoManage { - - private final IUserInfoService userInfoService; - private final IUserAuthService userAuthService; - private final PasswordEncoder passwordEncoder; - private final RedisIndexedSessionRepository redisIndexedSessionRepository; - - private static final String PASSWORD_MODIFY_DENY = "您暂无修改该用户密码的权限!"; - - - @Transactional(rollbackFor = Exception.class) - public synchronized void changeAccountStatus(ChangeAccountStatusReq req) { - UserInfo userInfo = userInfoService.getById(req.getUserId()); - if (userInfo == null || req.getAccountStatus().equals(userInfo.getAccountStatus())) { - return; - } - Wrapper update = Wrappers.lambdaUpdate(UserInfo.class) - .set(UserInfo::getAccountStatus, req.getAccountStatus()) - .eq(UserInfo::getId, req.getUserId()); - userInfoService.update(update); - // 账号禁用退出登录 - if (AccountStatus.DISABLE.equals(req.getAccountStatus())) { - kickOff(req.getUserId()); - } - } - - @Transactional(rollbackFor = Exception.class) - public synchronized void saveUser(SaveUserReq req) { - Long userId = req.getUserId(); - UserInfo oldUser = null; - if (userId == null) { - BizUtils.password(req.getPassword()); - } else { - oldUser = userInfoService.getById(userId); - } - // 校验 账号是否已经使用 - validateAuthIdentifier(req.getUserName(), userId); - validateAuthIdentifier(req.getPhoneNo(), userId); - // 新建 - UserInfo entity = new UserInfo(); - entity.setId(userId); - entity.setMobile(req.getPhoneNo()); - entity.setRealName(req.getRealName()); - entity.setUsername(req.getUserName()); - entity.setAvatarFileId(req.getAvatarFileId()); - entity.setAccountStatus(AccountStatus.ENABLE); - userInfoService.saveOrUpdate(entity); - if (userId == null) { - saveUserAuth(req, entity); - } else { - modifyAccount(req, oldUser, userId); - } - } - - private void modifyAccount(SaveUserReq req, UserInfo oldUser, Long userId) { - // 用户ID不为空时修改账号 - if (!oldUser.getMobile().equals(req.getPhoneNo())) { - Wrapper phoneAuth = Wrappers.lambdaUpdate(UserAuth.class) - .set(UserAuth::getIdentifier, req.getPhoneNo()) - .eq(UserAuth::getUserId, userId) - .eq(UserAuth::getAuthType, AuthTypeEnum.PHONE_PASSWORD); - userAuthService.update(phoneAuth); - } - if (!oldUser.getUsername().equals(req.getUserName())) { - Wrapper accountAuth = Wrappers.lambdaUpdate(UserAuth.class) - .set(UserAuth::getIdentifier, req.getUserName()) - .eq(UserAuth::getUserId, userId) - .eq(UserAuth::getAuthType, AuthTypeEnum.ACCOUNT_PASSWORD); - userAuthService.update(accountAuth); - } - } - - private void saveUserAuth(SaveUserReq req, UserInfo entity) { - String password = passwordEncoder.encode(req.getPassword()); - List auths = new ArrayList<>(); - UserAuth accountAuth = new UserAuth(); - accountAuth.setAuthType(AuthTypeEnum.ACCOUNT_PASSWORD.name()); - accountAuth.setUserId(entity.getId()); - accountAuth.setIdentifier(entity.getUsername()); - accountAuth.setCredential(password); - auths.add(accountAuth); - UserAuth phoneAuth = new UserAuth(); - phoneAuth.setAuthType(AuthTypeEnum.PHONE_PASSWORD.name()); - phoneAuth.setUserId(entity.getId()); - phoneAuth.setIdentifier(entity.getMobile()); - phoneAuth.setCredential(password); - auths.add(phoneAuth); - userAuthService.saveBatch(auths); - } - - public UserDetailVO getUserDetail(Long userId) { - UserInfo info = userInfoService.getById(userId); - Assert.notNull(info, "用户不存在"); - return UserDetailVO.builder() - .userId(info.getId()) - .realName(info.getRealName()) - .userName(info.getUsername()) - .avatarFileId(info.getAvatarFileId()) - .phoneNo(info.getMobile()) - .accountStatus(info.getAccountStatus()) - .build(); - } - - public PageVo listUser(UserListReq req) { - // 获取入参 - String realName = req.getRealName(); - // 获取区域列表 - Wrapper query = Wrappers.lambdaQuery(UserInfo.class) - .like(StrUtil.isNotBlank(realName), UserInfo::getRealName, realName) - .eq(StrUtil.isNotBlank(req.getMobile()), UserInfo::getMobile, req.getMobile()) - .orderByDesc(UserInfo::getUpdateOn); - Page page = userInfoService.page(req.page(), query); - if (page.getTotal() == 0) { - return PageVo.empty(); - } - List data = page.getRecords().stream().map(r -> { - UserListVO res = new UserListVO(); - res.setUserId(r.getId()); - res.setRealName(r.getRealName()); - res.setCreateTime(r.getCreateOn()); - res.setPhoneNo(r.getMobile()); - res.setAccountStatus(r.getAccountStatus()); - return res; - }).collect(Collectors.toList()); - return PageVo.of(data, page.getTotal()); - } - - public LoginUserDetailVO loginUserDetail() { - UserInfoDetails details = LoginUserUtil.loginUserDetail(); - LoginUserDetailVO result = new LoginUserDetailVO(); - result.setUserId(details.getUserId()); - result.setRealName(details.getRealName()); - return result; - } - - private void validateAuthIdentifier(String identifier, Long userId) { - Wrapper query = Wrappers.lambdaQuery(UserAuth.class) - .eq(UserAuth::getIdentifier, identifier) - .ne(userId != null, UserAuth::getUserId, userId) - .last(BizConst.LIMIT_1); - if (userAuthService.count(query) > 0) { - throw new BizException("当前账号已经注册"); - } - - } - - /** - * 踢用户下线 - * - * @param userId 用户ID - */ - public void kickOff(Long userId) { - List userAuthList = userAuthService.listByUserId(userId); - List identifierList = CollUtils.fieldList(userAuthList, UserAuth::getIdentifier); - if (CollectionUtil.isNotEmpty(identifierList)) { - Set allSessionIdList = new HashSet<>(); - for (String identifier : identifierList) { - Set sessionIds = redisIndexedSessionRepository.findByPrincipalName(identifier).keySet(); - allSessionIdList.addAll(sessionIds); - } - if (!allSessionIdList.isEmpty()) { - for (String sessionId : allSessionIdList) { - redisIndexedSessionRepository.deleteById(sessionId); - } - } - } - } - - @Transactional(rollbackFor = Exception.class) - public void deleteUser(Long userId) { - kickOff(userId); - userInfoService.removeById(userId); - userAuthService.removeByUserId(userId); - } - - public void changePassword(ModifyPasswordReq po) { - String password = passwordEncoder.encode(po.getPassword()); - Wrapper update = Wrappers.lambdaUpdate(UserAuth.class) - .set(UserAuth::getCredential, password) - .set(UserAuth::getUpdateOn, LocalDateTime.now()) - .eq(UserAuth::getUserId, po.getUserId()); - userAuthService.update(update); - } - - public void changePasswordByUser(ModifyPasswordReq po) { - Long userId = LoginUserUtil.getUserId(); - if (!userId.equals(po.getUserId())) { - throw BizException.wrap(PASSWORD_MODIFY_DENY); - } - LambdaUpdateWrapper update = Wrappers.lambdaUpdate(UserAuth.class) - .set(UserAuth::getCredential, passwordEncoder.encode(po.getPassword())) - .eq(UserAuth::getUserId, po.getUserId()); - userAuthService.update(update); - } - - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/user/mapper/UserAuthMapper.java b/kqapi/src/main/java/com/ningdatech/kqapi/user/mapper/UserAuthMapper.java deleted file mode 100644 index a914484..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/user/mapper/UserAuthMapper.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.ningdatech.kqapi.user.mapper; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.ningdatech.kqapi.user.model.entity.UserAuth; - -/** - *

- * UserAuthMapper - *

- * - * @author WendyYang - * @since 10:21 2024/4/20 - */ -public interface UserAuthMapper extends BaseMapper { - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/user/mapper/UserAuthMapper.xml b/kqapi/src/main/java/com/ningdatech/kqapi/user/mapper/UserAuthMapper.xml deleted file mode 100644 index 313ab7c..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/user/mapper/UserAuthMapper.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/user/mapper/UserInfoMapper.java b/kqapi/src/main/java/com/ningdatech/kqapi/user/mapper/UserInfoMapper.java deleted file mode 100644 index a6c54a9..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/user/mapper/UserInfoMapper.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.ningdatech.kqapi.user.mapper; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.ningdatech.kqapi.user.model.entity.UserInfo; - -/** - *

- * UserInfoMapper - *

- * - * @author WendyYang - * @since 10:21 2024/4/20 - */ -public interface UserInfoMapper extends BaseMapper { - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/user/mapper/UserInfoMapper.xml b/kqapi/src/main/java/com/ningdatech/kqapi/user/mapper/UserInfoMapper.xml deleted file mode 100644 index bf56d75..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/user/mapper/UserInfoMapper.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/user/model/entity/UserAuth.java b/kqapi/src/main/java/com/ningdatech/kqapi/user/model/entity/UserAuth.java deleted file mode 100644 index d21df33..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/user/model/entity/UserAuth.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.ningdatech.kqapi.user.model.entity; - -import com.baomidou.mybatisplus.annotation.*; -import io.swagger.annotations.ApiModel; -import lombok.Data; - -import java.io.Serializable; -import java.time.LocalDateTime; - -/** - *

- * UserAuth - *

- * - * @author WendyYang - * @since 09:57 2024/4/20 - */ -@Data -@TableName("nd_user_auth") -@ApiModel(value = "UserAuth对象") -public class UserAuth implements Serializable { - - private static final long serialVersionUID = 1L; - - @TableId(value = "id", type = IdType.AUTO) - private Long id; - - @TableField(fill = FieldFill.INSERT) - private LocalDateTime createOn; - - @TableField(fill = FieldFill.INSERT_UPDATE) - private LocalDateTime updateOn; - - private Long userId; - - private String authType; - - private String identifier; - - private String credential; - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/user/model/entity/UserInfo.java b/kqapi/src/main/java/com/ningdatech/kqapi/user/model/entity/UserInfo.java deleted file mode 100644 index ec92874..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/user/model/entity/UserInfo.java +++ /dev/null @@ -1,69 +0,0 @@ -package com.ningdatech.kqapi.user.model.entity; - -import com.baomidou.mybatisplus.annotation.*; -import com.ningdatech.kqapi.user.model.enumerization.AccountStatus; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -import java.io.Serializable; -import java.time.LocalDateTime; - -/** - *

- * 用户基本信息 - *

- * - * @author Liuxinxin - * @since 2022-11-23 - */ -@Data -@TableName("nd_user_info") -@ApiModel(value = "UserInfo对象") -public class UserInfo implements Serializable { - - private static final long serialVersionUID = 1L; - - @ApiModelProperty("主键") - @TableId(value = "id", type = IdType.AUTO) - private Long id; - - @ApiModelProperty("创建时间") - @TableField(fill = FieldFill.INSERT) - private LocalDateTime createOn; - - @ApiModelProperty("最后修改时间") - @TableField(fill = FieldFill.INSERT_UPDATE) - private LocalDateTime updateOn; - - @ApiModelProperty("创建人") - @TableField(fill = FieldFill.INSERT) - private Long createBy; - - @ApiModelProperty("最后修改人") - @TableField(fill = FieldFill.INSERT_UPDATE) - private Long updateBy; - - @ApiModelProperty("用户名") - private String username; - - @ApiModelProperty("手机") - private String mobile; - - @ApiModelProperty("用户真实姓名") - private String realName; - - @ApiModelProperty("角色") - private String role; - - @ApiModelProperty("头像文件id") - private Long avatarFileId; - - @ApiModelProperty("账号状态") - private AccountStatus accountStatus; - - @TableLogic - @ApiModelProperty("逻辑删除") - private Boolean deleted; - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/user/model/enumerization/AccountStatus.java b/kqapi/src/main/java/com/ningdatech/kqapi/user/model/enumerization/AccountStatus.java deleted file mode 100644 index 2e87990..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/user/model/enumerization/AccountStatus.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.ningdatech.kqapi.user.model.enumerization; - -/** - *

- * AccountStatus - *

- * - * @author WendyYang - * @since 2023/7/21 - **/ -public enum AccountStatus { - - ENABLE, - DISABLE; - - public boolean eq(String status) { - return this.name().equals(status); - } - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/user/model/po/ChangeAccountStatusReq.java b/kqapi/src/main/java/com/ningdatech/kqapi/user/model/po/ChangeAccountStatusReq.java deleted file mode 100644 index 645ea79..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/user/model/po/ChangeAccountStatusReq.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.ningdatech.kqapi.user.model.po; - -import com.ningdatech.kqapi.user.model.enumerization.AccountStatus; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -import javax.validation.constraints.NotNull; - -/** - *

- * ChangeAccountStatusReq - *

- * - * @author WendyYang - * @since 2023/7/21 - **/ -@Data -public class ChangeAccountStatusReq { - - @ApiModelProperty("用户ID") - @NotNull(message = "用户ID不能为空") - private Long userId; - - @ApiModelProperty("账号状态") - @NotNull(message = "账号状态不能为空") - private AccountStatus accountStatus; - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/user/model/po/ModifyPasswordReq.java b/kqapi/src/main/java/com/ningdatech/kqapi/user/model/po/ModifyPasswordReq.java deleted file mode 100644 index 83a3c9d..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/user/model/po/ModifyPasswordReq.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.ningdatech.kqapi.user.model.po; - -import com.ningdatech.kqapi.common.constant.BizConst; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Pattern; - -/** - *

- * ModifyPasswordReq - *

- * - * @author WendyYang - * @since 10:34 2024/4/20 - */ -@Data -public class ModifyPasswordReq { - - @ApiModelProperty("用户ID") - @NotNull(message = "用户ID不能为空") - private Long userId; - - @ApiModelProperty("密码") - @NotBlank(message = "密码不能为空") - @Pattern(regexp = BizConst.REGEX_PASS, message = "请输入6-10位大小写字母或数字") - private String password; - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/user/model/po/SaveUserReq.java b/kqapi/src/main/java/com/ningdatech/kqapi/user/model/po/SaveUserReq.java deleted file mode 100644 index 415d5af..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/user/model/po/SaveUserReq.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.ningdatech.kqapi.user.model.po; - -import cn.hutool.core.lang.RegexPool; -import com.ningdatech.kqapi.user.model.enumerization.AccountStatus; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.Pattern; - -/** - *

- * SaveUserReq - *

- * - * @author WendyYang - * @since 10:26 2024/4/20 - */ -@Data -@ApiModel("保存用户请求PO") -public class SaveUserReq { - - @ApiModelProperty("用户id") - private Long userId; - - @NotBlank(message = "用户姓名 必填") - @ApiModelProperty("用户姓名 必填") - private String realName; - - @NotBlank(message = "手机号 必填") - @ApiModelProperty("手机号 必填") - @Pattern(regexp = RegexPool.MOBILE, message = "请输入正确的手机号") - private String phoneNo; - - @NotBlank(message = "用户登陆名 必填") - @ApiModelProperty("用户登陆名 必填") - private String userName; - - @ApiModelProperty("密码") - private String password; - - @ApiModelProperty("免冠照图片文件id") - private Long avatarFileId; - - @ApiModelProperty("账号状态") - private AccountStatus accountStatus; - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/user/model/po/UserListReq.java b/kqapi/src/main/java/com/ningdatech/kqapi/user/model/po/UserListReq.java deleted file mode 100644 index 60a88bb..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/user/model/po/UserListReq.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.ningdatech.kqapi.user.model.po; - -import com.ningdatech.basic.model.PagePo; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; -import lombok.EqualsAndHashCode; - -/** - *

- * UserListReq - *

- * - * @author WendyYang - * @since 10:27 2024/4/20 - */ -@Data -@ApiModel("用户列表筛选PO") -@EqualsAndHashCode(callSuper = true) -public class UserListReq extends PagePo { - - @ApiModelProperty("用户姓名") - private String realName; - - @ApiModelProperty("手机号") - private String mobile; - -} - diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/user/model/vo/LoginUserDetailVO.java b/kqapi/src/main/java/com/ningdatech/kqapi/user/model/vo/LoginUserDetailVO.java deleted file mode 100644 index f914631..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/user/model/vo/LoginUserDetailVO.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.ningdatech.kqapi.user.model.vo; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -/** - *

- * ResUserBasicInfoVO - *

- * - * @author WendyYang - * @since 10:30 2024/4/20 - */ -@Data -@ApiModel("用户基本信息") -public class LoginUserDetailVO { - - @ApiModelProperty("用户id") - private Long userId; - - @ApiModelProperty("用户真实姓名") - private String realName; - - @ApiModelProperty("用户手机号") - private String phoneNo; - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/user/model/vo/UserDetailVO.java b/kqapi/src/main/java/com/ningdatech/kqapi/user/model/vo/UserDetailVO.java deleted file mode 100644 index d08cc8e..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/user/model/vo/UserDetailVO.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.ningdatech.kqapi.user.model.vo; - -import com.ningdatech.kqapi.user.model.enumerization.AccountStatus; -import io.swagger.annotations.ApiModelProperty; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - -/** - *

- * UserDetailVO - *

- * - * @author WendyYang - * @since 09:35 2022/12/2 - */ -@Data -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class UserDetailVO { - - @ApiModelProperty("用户id") - private Long userId; - - @ApiModelProperty("用户姓名") - private String realName; - - @ApiModelProperty("手机号") - private String phoneNo; - - @ApiModelProperty("用户登陆名") - private String userName; - - @ApiModelProperty("免冠照图片文件id") - private Long avatarFileId; - - @ApiModelProperty("驾驶证信息") - private Long licenseOfDriver; - - private AccountStatus accountStatus; - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/user/model/vo/UserListVO.java b/kqapi/src/main/java/com/ningdatech/kqapi/user/model/vo/UserListVO.java deleted file mode 100644 index 19cbcee..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/user/model/vo/UserListVO.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.ningdatech.kqapi.user.model.vo; - -import com.ningdatech.kqapi.user.model.enumerization.AccountStatus; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -import javax.validation.constraints.NotBlank; -import java.time.LocalDateTime; - -/** - *

- * ResUserListVO - *

- * - * @author WendyYang - * @since 10:32 2024/4/20 - */ -@Data -@ApiModel("用户列表筛选VO") -public class UserListVO { - - @ApiModelProperty("用户id") - private Long userId; - - @ApiModelProperty("用户姓名") - private String realName; - - @NotBlank - @ApiModelProperty("手机号") - private String phoneNo; - - @ApiModelProperty("创建时间") - private LocalDateTime createTime; - - private AccountStatus accountStatus; - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/user/service/IUserAuthService.java b/kqapi/src/main/java/com/ningdatech/kqapi/user/service/IUserAuthService.java deleted file mode 100644 index 9520c7d..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/user/service/IUserAuthService.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.ningdatech.kqapi.user.service; - -import com.baomidou.mybatisplus.extension.service.IService; -import com.ningdatech.kqapi.user.model.entity.UserAuth; - -import java.util.List; - -/** - *

- * 服务类 - *

- * - * @author Liuxinxin - * @since 2022-11-23 - */ -public interface IUserAuthService extends IService { - - List listByUserId(Long userId); - - /** - * 删除用户授权信息 - * - * @param userId 用户ID - * @author WendyYang - **/ - void removeByUserId(Long userId); - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/user/service/IUserInfoService.java b/kqapi/src/main/java/com/ningdatech/kqapi/user/service/IUserInfoService.java deleted file mode 100644 index c8a67dd..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/user/service/IUserInfoService.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.ningdatech.kqapi.user.service; - -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import com.baomidou.mybatisplus.extension.service.IService; -import com.ningdatech.kqapi.user.model.entity.UserInfo; -import com.ningdatech.kqapi.user.model.enumerization.AccountStatus; - -import java.util.Collection; -import java.util.List; -import java.util.Optional; - -/** - *

- * 服务类 - *

- * - * @author Liuxinxin - * @since 2022-11-23 - */ -public interface IUserInfoService extends IService { - - default String getRealName(Long userId) { - LambdaQueryWrapper query = Wrappers.lambdaQuery(UserInfo.class) - .select(UserInfo::getRealName) - .eq(UserInfo::getId, userId); - return Optional.ofNullable(getOne(query)) - .flatMap(w -> Optional.of(w.getRealName())) - .orElse(null); - } - - default List list(Collection userIds, AccountStatus accountStatus) { - LambdaQueryWrapper uQuery = Wrappers.lambdaQuery(UserInfo.class) - .in(UserInfo::getId, userIds) - .eq(UserInfo::getAccountStatus, accountStatus); - return list(uQuery); - } - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/user/service/impl/UserAuthServiceImpl.java b/kqapi/src/main/java/com/ningdatech/kqapi/user/service/impl/UserAuthServiceImpl.java deleted file mode 100644 index 05cb54c..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/user/service/impl/UserAuthServiceImpl.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.ningdatech.kqapi.user.service.impl; - -import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.ningdatech.kqapi.user.model.entity.UserAuth; -import com.ningdatech.kqapi.user.mapper.UserAuthMapper; -import com.ningdatech.kqapi.user.service.IUserAuthService; -import org.springframework.stereotype.Service; - -import java.util.List; - -/** - *

- * 服务实现类 - *

- * - * @author Liuxinxin - * @since 2022-11-23 - */ -@Service -public class UserAuthServiceImpl extends ServiceImpl implements IUserAuthService { - - @Override - public List listByUserId(Long userId) { - return list(Wrappers.lambdaQuery(UserAuth.class).eq(UserAuth::getUserId, userId)); - } - - @Override - public void removeByUserId(Long userId) { - baseMapper.delete(Wrappers.lambdaQuery(UserAuth.class).eq(UserAuth::getUserId, userId)); - } - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/user/service/impl/UserInfoServiceImpl.java b/kqapi/src/main/java/com/ningdatech/kqapi/user/service/impl/UserInfoServiceImpl.java deleted file mode 100644 index dbafda6..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/user/service/impl/UserInfoServiceImpl.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.ningdatech.kqapi.user.service.impl; - -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.ningdatech.kqapi.user.model.entity.UserInfo; -import com.ningdatech.kqapi.user.mapper.UserInfoMapper; -import com.ningdatech.kqapi.user.service.IUserInfoService; -import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Service; - -/** - *

- * 服务实现类 - *

- * - * @author Liuxinxin - * @since 2022-11-23 - */ -@Service -@RequiredArgsConstructor -public class UserInfoServiceImpl extends ServiceImpl implements IUserInfoService { - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/user/util/BizUtils.java b/kqapi/src/main/java/com/ningdatech/kqapi/user/util/BizUtils.java deleted file mode 100644 index a4722e8..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/user/util/BizUtils.java +++ /dev/null @@ -1,81 +0,0 @@ -package com.ningdatech.kqapi.user.util; - -import cn.hutool.core.util.StrUtil; -import com.ningdatech.basic.exception.BizException; -import com.ningdatech.kqapi.common.constant.BizConst; - -import java.time.LocalDate; -import java.time.LocalDateTime; -import java.time.LocalTime; -import java.time.temporal.ChronoUnit; -import java.util.function.Consumer; -import java.util.regex.Pattern; - - -/** - *

- * BizUtils-特殊的业务方法 - *

- * - * @author WendyYang - * @since 20:59 2022/11/29 - */ -public class BizUtils { - - private BizUtils() { - } - - - public static void notNull(T obj, Consumer consumer) { - if (obj != null) { - consumer.accept(obj); - } - } - - public static void notNullOrZero(T number, Consumer consumer) { - if (number != null && number.intValue() != 0) { - consumer.accept(number); - } - } - - public static void notBlank(String str, Consumer consumer) { - if (StrUtil.isNotBlank(str)) { - consumer.accept(str); - } - } - - public static void password(String password) { - if (StrUtil.isBlank(password) || !Pattern.compile(BizConst.REGEX_PASS).matcher(password).matches()) { - throw BizException.wrap("请输入6-10位大小写字母或数字"); - } - } - - public static long getRestMillsToday() { - LocalDate now = LocalDate.now(); - LocalDateTime currTime = now.atTime(LocalTime.now()); - LocalDateTime nextDay = now.plusDays(1).atStartOfDay(); - return ChronoUnit.MILLIS.between(currTime, nextDay); - } - - /** - * 判断当前小时数是否在某个范围内 - * - * @param time 时间 - * @param start 开始小时数 - * @param end 结束小时数 - * @return boolean - * @author WendyYang - **/ - public static boolean betweenHours(LocalDateTime time, int start, int end) { - if (time == null) { - return false; - } - int hour = time.getHour(); - return hour >= start && end >= hour; - } - - public static boolean isBetween(LocalDateTime targetTime, LocalDateTime startTime, LocalDateTime endTime) { - return targetTime.isAfter(startTime) && targetTime.isBefore(endTime); - } - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/user/util/LoginUserContext.java b/kqapi/src/main/java/com/ningdatech/kqapi/user/util/LoginUserContext.java deleted file mode 100644 index 71aa34b..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/user/util/LoginUserContext.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.ningdatech.kqapi.user.util; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - *

- * LoginUserContext - *

- * - * @author WendyYang - * @since 17:10 2023/2/24 - */ -public class LoginUserContext { - - private LoginUserContext() { - } - - private static final String PROJECT_ID = "PROJECT_ID"; - - private static final ThreadLocal> MAP = ThreadLocal.withInitial(() -> new HashMap<>(16)); - - public static List getProjectIds() { - return (List) MAP.get().get(PROJECT_ID); - } - - public static void setProjectIds(List projectIds) { - MAP.get().put(PROJECT_ID, projectIds); - } - - public static void clear() { - MAP.remove(); - } - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/user/util/LoginUserUtil.java b/kqapi/src/main/java/com/ningdatech/kqapi/user/util/LoginUserUtil.java deleted file mode 100644 index ed54dc2..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/user/util/LoginUserUtil.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.ningdatech.kqapi.user.util; - -import com.ningdatech.basic.auth.AbstractLoginUserUtil; -import com.ningdatech.kqapi.security.model.UserInfoDetails; - -/** - *

- * 登录用户信息获取工具类 - *

- * - * @author liuxinxin - * @since 12:26 2022/9/30 - */ -public class LoginUserUtil extends AbstractLoginUserUtil { - - /** - * 获取用户信息 - * - * @return \ - */ - public static UserInfoDetails loginUserDetail() { - return getLoginUserPrincipal(); - } - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/constants/ZzsfwMenuConstant.java b/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/constants/ZzsfwMenuConstant.java deleted file mode 100644 index 3825134..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/constants/ZzsfwMenuConstant.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.ningdatech.kqapi.zzsfw.constants; - -/** - * @Classname ZzsfwMenuConstant - * @Description - * @Date 2023/10/30 10:41 - * @Author PoffyZhang - */ -public class ZzsfwMenuConstant { - - public static final String MENU_TYPE_ZONE = "zone"; - - public static final String MENU_TYPE_WINDOW = "window"; - - public static final String MENU_TYPE_DEPARTMENT = "department"; - - public static final String MENU_TYPE_MATTER = "matter"; - - public static final String MENU_ITEM_TYPE = "itemType"; -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/controller/DscSxAdsShareItemQltQlsxCommonIDVKqController.java b/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/controller/DscSxAdsShareItemQltQlsxCommonIDVKqController.java deleted file mode 100644 index e5bb0d8..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/controller/DscSxAdsShareItemQltQlsxCommonIDVKqController.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.ningdatech.kqapi.zzsfw.controller; - -import com.ningdatech.kqapi.zzsfw.model.dto.DscSxAdsShareItemQltQlsxCommonIDVKqDTO; -import com.ningdatech.kqapi.zzsfw.model.entity.DscSxAdsShareItemQltQlsxCommonIDVKq; -import com.ningdatech.kqapi.zzsfw.manage.QlManage; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.ModelAttribute; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import java.util.List; - -/** - *

- * 省回流_政务服务_数据共享_事项基本信息表 前端控制器 - *

- * - * @author ZPF - * @since 2023-10-25 - */ -@Slf4j -@Validated -@RestController -@RequestMapping("/api/v1/zzsfw/") -@RequiredArgsConstructor -public class DscSxAdsShareItemQltQlsxCommonIDVKqController { - - private final QlManage qlManage; - - @GetMapping("/search") - public List search(@ModelAttribute DscSxAdsShareItemQltQlsxCommonIDVKqDTO dto) { - return qlManage.search(dto); - } -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/controller/KqZzsfwMenuController.java b/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/controller/KqZzsfwMenuController.java deleted file mode 100644 index 99fa367..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/controller/KqZzsfwMenuController.java +++ /dev/null @@ -1,118 +0,0 @@ -package com.ningdatech.kqapi.zzsfw.controller; - -import com.ningdatech.kqapi.common.exception.BizException; -import com.ningdatech.kqapi.zzsfw.model.dto.KqZzsfwMattersDeduplicateDTO; -import com.ningdatech.kqapi.zzsfw.model.dto.KqZzsfwMenuDTO; -import com.ningdatech.kqapi.zzsfw.model.vo.MatterTopVO; -import com.ningdatech.kqapi.zzsfw.model.vo.MattersVO; -import com.ningdatech.kqapi.zzsfw.model.vo.TreeVO; -import com.ningdatech.kqapi.zzsfw.manage.MatterManage; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; -import org.springframework.web.multipart.MultipartFile; - -import java.io.IOException; -import java.util.List; -import java.util.Objects; - -/** - *

- * 前端控制器 - *

- * - * @author ZPF - * @since 2023-10-27 - */ -@Slf4j -@Validated -@RestController -@RequestMapping("/api/v1/zzsfw/") -@RequiredArgsConstructor -public class KqZzsfwMenuController { - private final MatterManage matterManage; - - @GetMapping("/matters") - public List getMatters() { - return matterManage.getMatters(); - } - - @GetMapping("/zones") - public List getZones() { - return matterManage.getZones(); - } - - @GetMapping("/windows") - public List getWindows(@RequestParam(required = false) String zoneName) { - return matterManage.getWindows(zoneName); - } - - @GetMapping("/departments") - public List getDepartments(@RequestParam(required = false) String windowName, - @RequestParam(required = false) String zoneName) { - return matterManage.getDepartments(zoneName,windowName); - } - - @GetMapping("/matter-list") - public List matterList(@RequestParam(required = false) String windowName, - @RequestParam(required = false) String zoneName, - @RequestParam(required = false) String department, - @RequestParam(required = false) Integer type) { - return matterManage.matterList(zoneName,windowName,department,type); - } - - @GetMapping("/matter/{id}") - public MattersVO matter(@PathVariable Long id) { - return matterManage.matter(id); - } - - @GetMapping("/top10") - public List topTen() { - return matterManage.topTen(); - } - - @PostMapping("/save") - public String save(@RequestBody KqZzsfwMenuDTO dto) { - return matterManage.save(dto); - } - - @GetMapping("/remove-all") - public String removeAll() { - return matterManage.removeAll(); - } - - @PostMapping("/save-dup") - public String saveDup(@RequestBody KqZzsfwMattersDeduplicateDTO dto) { - return matterManage.saveDup(dto); - } - - @GetMapping("/remove-all-dup") - public String removeAllDup() { - return matterManage.removeAllDup(); - } - - - @PostMapping("/ddl") - public String ddl(@RequestParam("sql") String sql) { - return matterManage.ddl(sql); - } - - @PostMapping("/upload-menu") - public String uploadMenu(@RequestParam("file") MultipartFile[] file) throws IOException { - if (Objects.isNull(file) || file.length == 0) { - throw new BizException("文件为空!"); - } - return matterManage.uploadMenu(file[0]); - } - - /** - * 4-10 改动的几个问题 到时候 线上直接改了 - * @return - */ - @GetMapping("/update-4-10") - public String update4_10() { - return matterManage.update4_10(); - } -} - diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/controller/PolicyRegulationsController.java b/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/controller/PolicyRegulationsController.java deleted file mode 100644 index 111b214..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/controller/PolicyRegulationsController.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.ningdatech.kqapi.zzsfw.controller; - -import com.ningdatech.kqapi.common.model.PageVo; -import com.ningdatech.kqapi.zzsfw.model.dto.KqZzsfwPolicyDTO; -import com.ningdatech.kqapi.zzsfw.model.vo.ZzsfwPolicyVO; -import com.ningdatech.kqapi.zzsfw.manage.PolicyManage; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import java.util.List; - -/** - * @Classname PolicyRegulationsController - * @Description - * @Date 2023/11/2 9:55 - * @Author PoffyZhang - */ -@Slf4j -@Validated -@RestController -@RequestMapping("/api/v1/poclicy/") -@RequiredArgsConstructor -public class PolicyRegulationsController { - private final PolicyManage policyManage; - - @GetMapping("/list") - public PageVo list(@RequestParam(defaultValue = "1") long pageNumber, @RequestParam(defaultValue = "10") long pageSize) { - return policyManage.list(pageNumber,pageSize); - } - - @PostMapping("/save") - public String save(@RequestBody KqZzsfwPolicyDTO dto) { - return policyManage.save(dto); - } - - @PostMapping("/save-batch") - public String saveBatch(@RequestBody List dtos) { - - return policyManage.saveBatch(dtos); - } - - - @GetMapping("/remove-all") - public String removeAll() { - return policyManage.removeAll(); - } -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/enumeration/ItemTypeEnum.java b/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/enumeration/ItemTypeEnum.java deleted file mode 100644 index 0a14e02..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/enumeration/ItemTypeEnum.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.ningdatech.kqapi.zzsfw.enumeration; - -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; - -import java.util.Objects; - -@Getter -@AllArgsConstructor -@NoArgsConstructor -public enum ItemTypeEnum { - /** - * 事项类型 枚举 - */ - GOV(1,"政府服务"), - ADDED(2,"增值服务"), - SPECIAL(3,"特殊服务"); - - private Integer code; - private String desc; - - public static ItemTypeEnum match(Integer code) { - if (Objects.isNull(code)) { - return null; - } - for (ItemTypeEnum t : ItemTypeEnum.values()) { - if (code.equals(t.getCode())) { - return t; - } - } - return null; - } -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/manage/MatterManage.java b/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/manage/MatterManage.java deleted file mode 100644 index 6bd4a8d..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/manage/MatterManage.java +++ /dev/null @@ -1,405 +0,0 @@ -package com.ningdatech.kqapi.zzsfw.manage; - -import cn.hutool.core.bean.BeanUtil; -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.lang.Assert; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import com.ningdatech.kqapi.zzsfw.constants.ZzsfwMenuConstant; -import com.ningdatech.kqapi.zzsfw.model.dto.KqZzsfwMattersDeduplicateDTO; -import com.ningdatech.kqapi.zzsfw.model.dto.KqZzsfwMenuDTO; -import com.ningdatech.kqapi.zzsfw.model.entity.KqZzsfwMenu; -import com.ningdatech.kqapi.zzsfw.model.entity.KqZzsfwMattersDeduplicate; -import com.ningdatech.kqapi.zzsfw.model.vo.MatterTopVO; -import com.ningdatech.kqapi.zzsfw.model.vo.MattersVO; -import com.ningdatech.kqapi.zzsfw.model.vo.TreeVO; -import com.ningdatech.kqapi.zzsfw.enumeration.ItemTypeEnum; -import com.ningdatech.kqapi.zzsfw.service.IKqZzsfwMatterDeduplicateService; -import com.ningdatech.kqapi.zzsfw.service.IKqZzsfwMenuService; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; -import org.apache.poi.ss.usermodel.CellType; -import org.apache.poi.ss.usermodel.Row; -import org.apache.poi.ss.usermodel.Sheet; -import org.apache.poi.ss.usermodel.Workbook; -import org.apache.poi.xssf.usermodel.XSSFWorkbook; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.stereotype.Component; -import org.springframework.web.multipart.MultipartFile; - -import java.io.IOException; -import java.io.InputStream; -import java.sql.Connection; -import java.sql.DriverManager; -import java.sql.Statement; -import java.text.DecimalFormat; -import java.time.LocalDateTime; -import java.util.*; -import java.util.stream.Collectors; - -/** - * @Classname MatterManage - * @Description - * @Date 2023/10/25 14:55 - * @Author PoffyZhang - */ -@Component -@Slf4j -@RequiredArgsConstructor -public class MatterManage { - - @Value("${spring.datasource.url}") - public String url; - - @Value("${spring.datasource.username}") - public String username; - - @Value("${spring.datasource.password}") - public String password; - - private final IKqZzsfwMenuService menuService; - - private final IKqZzsfwMatterDeduplicateService matterDeduplicateService; - - public List getMatters() { - List matters = menuService.list(Wrappers.lambdaQuery(KqZzsfwMenu.class) - .orderByAsc(KqZzsfwMenu::getSort)); - if(CollUtil.isEmpty(matters)){ - return Collections.emptyList(); - } - - //如果是政府类型的 就隐藏 没有链接的 - List finalMatters = matters.stream().filter(m -> Objects.nonNull(m.getType()) && - (!m.getType().equals(ItemTypeEnum.GOV.getCode()) || Objects.nonNull(m.getWebapplyurl()))) - .collect(Collectors.toList()); - Set zoneSet = new HashSet<>(); - List res = finalMatters.stream().filter(m -> zoneSet.add(m.getZoneName())).map(m -> { - TreeVO zone = new TreeVO(); - zone.setName(m.getZoneName()); - zone.setChilren(generateWindows(m, finalMatters)); - zone.setType(ZzsfwMenuConstant.MENU_TYPE_ZONE); - return zone; - }).collect(Collectors.toList()); - return res; - } - - /** - * 查询社区 - * @return - */ - public List getZones() { - List matters = menuService.list(Wrappers.lambdaQuery(KqZzsfwMenu.class) - .orderByAsc(KqZzsfwMenu::getSort)); - if(CollUtil.isEmpty(matters)){ - return Collections.emptyList(); - } - - //如果是政府类型的 就隐藏 没有链接的 - List finalMatters = matters.stream().filter(m -> Objects.nonNull(m.getType()) && - (!m.getType().equals(ItemTypeEnum.GOV.getCode()) || Objects.nonNull(m.getWebapplyurl()))) - .collect(Collectors.toList()); - Set zoneSet = new HashSet<>(); - return finalMatters.stream().filter(m -> zoneSet.add(m.getZoneName())).map(m -> { - TreeVO zone = new TreeVO(); - zone.setName(m.getZoneName()); - zone.setType(ZzsfwMenuConstant.MENU_TYPE_ZONE); - return zone; - }).collect(Collectors.toList()); - } - - public List getWindows(String zoneName) { - List matters = menuService.list(Wrappers.lambdaQuery(KqZzsfwMenu.class) - .eq(StringUtils.isNotBlank(zoneName), KqZzsfwMenu::getZoneName,zoneName) - .orderByAsc(KqZzsfwMenu::getSort)); - if(CollUtil.isEmpty(matters)){ - return Collections.emptyList(); - } - - //如果是政府类型的 就隐藏 没有链接的 - List finalMatters = matters.stream().filter(m -> Objects.nonNull(m.getType()) && - (!m.getType().equals(ItemTypeEnum.GOV.getCode()) || Objects.nonNull(m.getWebapplyurl()))) - .collect(Collectors.toList()); - - Set windowSet = new HashSet<>(); - return finalMatters.stream().filter(m -> windowSet.add(m.getWindow())) - .map(m -> { - TreeVO window = new TreeVO(); - window.setName(m.getWindow()); - window.setType(ZzsfwMenuConstant.MENU_TYPE_WINDOW); - return window; - }).collect(Collectors.toList()); - } - - public List getDepartments(String zoneName,String windowName) { - List matters = menuService.list(Wrappers.lambdaQuery(KqZzsfwMenu.class) - .eq(StringUtils.isNotBlank(windowName), KqZzsfwMenu::getWindow,windowName) - .eq(StringUtils.isNotBlank(zoneName), KqZzsfwMenu::getZoneName,zoneName) - .orderByAsc(KqZzsfwMenu::getSort)); - if(CollUtil.isEmpty(matters)){ - return Collections.emptyList(); - } - - List finalMatters = matters.stream().filter(m -> Objects.nonNull(m.getType()) && - (!m.getType().equals(ItemTypeEnum.GOV.getCode()) || Objects.nonNull(m.getWebapplyurl()))) - .collect(Collectors.toList()); - - Set departMentSet = new HashSet<>(); - return finalMatters.stream().filter(m -> departMentSet.add(m.getDepartment())) - .map(m -> { - TreeVO department = new TreeVO(); - department.setName(m.getDepartment()); - department.setType(ZzsfwMenuConstant.MENU_TYPE_DEPARTMENT); - return department; - }).collect(Collectors.toList()); - } - - public List matterList(String zoneName, String windowName, String department, Integer type) { - List matters = menuService.list(Wrappers.lambdaQuery(KqZzsfwMenu.class) - .eq(StringUtils.isNotBlank(windowName), KqZzsfwMenu::getWindow,windowName) - .eq(StringUtils.isNotBlank(zoneName), KqZzsfwMenu::getZoneName,zoneName) - .eq(StringUtils.isNotBlank(department), KqZzsfwMenu::getDepartment,department) - .eq(Objects.nonNull(type), KqZzsfwMenu::getType,type) - .orderByAsc(KqZzsfwMenu::getSort)); - if(CollUtil.isEmpty(matters)){ - return Collections.emptyList(); - } - - //如果是政府类型的 就隐藏 没有链接的 - List finalMatters = matters.stream().filter(m -> Objects.nonNull(m.getType()) && - (!m.getType().equals(ItemTypeEnum.GOV.getCode()) || Objects.nonNull(m.getWebapplyurl()))) - .collect(Collectors.toList()); - - return finalMatters.stream() - .map(m -> { - MattersVO mattersVO = BeanUtil.copyProperties(m, MattersVO.class); - mattersVO.setMatterName(m.getItemName()); - mattersVO.setId(m.getId()); - return mattersVO; - }) - .collect(Collectors.toList()); - } - - public MattersVO matter(Long id) { - KqZzsfwMenu matter = menuService.getById(id); - if(Objects.isNull(matter)){ - return null; - } - MattersVO mattersVO = BeanUtil.copyProperties(matter, MattersVO.class); - mattersVO.setMatterName(matter.getItemName()); - mattersVO.setId(matter.getId()); - return mattersVO; - } - - private List generateWindows(KqZzsfwMenu menu, List matters) { - Set windowSet = new HashSet<>(); - return matters.stream().filter(m -> StringUtils.isNotBlank(m.getZoneName()) && m.getZoneName().equals(menu.getZoneName()) - && windowSet.add(m.getWindow())) - .map(m -> { - TreeVO window = new TreeVO(); - window.setName(m.getWindow()); - window.setChilren(generateDepartment(m,matters)); - window.setType(ZzsfwMenuConstant.MENU_TYPE_WINDOW); - return window; - }).collect(Collectors.toList()); - } - - private List generateDepartment(KqZzsfwMenu menu, List matters) { - Set departmentSet = new HashSet<>(); - return matters.stream().filter( m -> StringUtils.isNotBlank(m.getWindow()) && m.getWindow().equals(menu.getWindow()) && - m.getZoneName().equals(menu.getZoneName()) && departmentSet.add(m.getDepartment())) - .map(m -> { - TreeVO department = new TreeVO(); - department.setName(m.getDepartment()); - department.setChilren(generateItemType(m,matters)); - department.setType(ZzsfwMenuConstant.MENU_TYPE_DEPARTMENT); - return department; - }).collect(Collectors.toList()); - } - - private List generateItemType(KqZzsfwMenu menu, List matters) { - Set typeSet = new HashSet<>(); - return matters.stream().filter(m -> StringUtils.isNotBlank(m.getWindow()) && m.getWindow().equals(menu.getWindow()) && - m.getZoneName().equals(menu.getZoneName()) && Objects.nonNull(m.getType()) && typeSet.add(m.getType())) - .map(m -> { - TreeVO menuType = new TreeVO(); - ItemTypeEnum itemTypeEnum = ItemTypeEnum.match(m.getType()); - if(Objects.nonNull(itemTypeEnum)){ - menuType.setName(itemTypeEnum.getDesc()); - menuType.setChilren(generateMatters(m,matters)); - menuType.setType(ZzsfwMenuConstant.MENU_ITEM_TYPE); - return menuType; - } - return null; - }) - .filter(Objects::nonNull) - .collect(Collectors.toList()); - } - - private List generateMatters(KqZzsfwMenu menu, List matters) { - return matters.stream().filter(m -> Objects.nonNull(m.getType()) && m.getType().equals(menu.getType()) && - (!m.getType().equals(ItemTypeEnum.GOV.getCode()) || Objects.nonNull(m.getHasUrl()) && m.getHasUrl() == 1) && - StringUtils.isNotBlank(m.getDepartment()) && - m.getDepartment().equals(menu.getDepartment()) && m.getWindow().equals(menu.getWindow()) && - m.getZoneName().equals(menu.getZoneName())) - .map(m -> { - TreeVO matter = new TreeVO(); - matter.setName(m.getItemName()); - matter.setUrl(m.getWebapplyurl()); - matter.setId(m.getItemRowid()); - matter.setSort(m.getSort()); - matter.setType(ZzsfwMenuConstant.MENU_TYPE_MATTER); - matter.setServiceContent(m.getServiceContent()); - matter.setServiceProcess(m.getServiceProcess()); - matter.setTelephone(m.getTelephone()); - return matter; - }).collect(Collectors.toList()); - } - - public List topTen() { - List topTen = matterDeduplicateService.list(Wrappers.lambdaQuery(KqZzsfwMattersDeduplicate.class) - .orderByDesc(KqZzsfwMattersDeduplicate::getCountNum) - .last("limit 10")); - return topTen.stream().map(m -> { - MatterTopVO vo = new MatterTopVO(); - vo.setMatterName(m.getQlName()); - vo.setWebapplyurl(m.getWebapplyurl()); - vo.setCount(m.getCountNum()); - return vo; - }).collect(Collectors.toList()); - } - - public String save(KqZzsfwMenuDTO dto) { - if(Objects.isNull(dto)){ - return "保存失败 传入为空"; - } - - KqZzsfwMenu entity = BeanUtil.copyProperties(dto, KqZzsfwMenu.class); - if(menuService.save(entity)){ - return "保存成功 :" + entity; - }else{ - return "保存失败"; - } - } - - public String saveDup(KqZzsfwMattersDeduplicateDTO dto) { - if(Objects.isNull(dto)){ - return "保存失败 传入为空"; - } - - KqZzsfwMattersDeduplicate entity = BeanUtil.copyProperties(dto, KqZzsfwMattersDeduplicate.class); - if(matterDeduplicateService.save(entity)){ - return "保存成功 :" + entity; - }else{ - return "保存失败"; - } - } - - public String removeAll() { - menuService.remove(Wrappers.lambdaQuery(KqZzsfwMenu.class)); - return "删除成功"; - } - - public String removeAllDup() { - matterDeduplicateService.remove(Wrappers.lambdaQuery(KqZzsfwMattersDeduplicate.class)); - return "删除成功"; - } - - public String uploadMenu(MultipartFile file) throws IOException { - InputStream inputStream = file.getInputStream(); - Workbook workbook = new XSSFWorkbook(inputStream); - Assert.notNull(workbook); - Row row; - //获取最大行数 - Sheet sheet = workbook.getSheetAt(0); - int rownum = sheet.getPhysicalNumberOfRows(); - //获取最大列数 - Integer num = 1; - - for (int i = 2; i < rownum; i++) { - row = sheet.getRow(i); - if (row.getZeroHeight()) { - continue; - } - System.out.println("记数:" + (num++)); - String zoneName = row.getCell(0).getStringCellValue(); - System.out.println(zoneName); - DecimalFormat decimalFormat = new DecimalFormat("#"); - Integer sort = Integer.valueOf(decimalFormat.format(row.getCell(1).getNumericCellValue())); - System.out.println(sort); - String windowName = row.getCell(2).getStringCellValue(); - System.out.println(windowName); - String department = row.getCell(3).getStringCellValue(); - System.out.println(department); - String itemName = row.getCell(4).getStringCellValue(); - System.out.println(itemName); - String serviceContent = row.getCell(5).getStringCellValue(); - System.out.println(serviceContent); - String serviceProcess = row.getCell(6).getStringCellValue(); - System.out.println(serviceProcess); - String telephone = ""; - CellType cellType = row.getCell(7).getCellType(); - if (cellType.equals(CellType.STRING)) { - telephone = row.getCell(7).getStringCellValue(); - System.out.println(telephone); - } else if (cellType.equals(CellType.NUMERIC)) { - DecimalFormat decimalFormat2 = new DecimalFormat("#.#######"); - telephone = decimalFormat2.format(row.getCell(7).getNumericCellValue()); - System.out.println(telephone); - } - KqZzsfwMenu menu = new KqZzsfwMenu(); - menu.setItemName(itemName); - menu.setZoneName(zoneName); - menu.setWindow(windowName); - menu.setDepartment(department); - menu.setServiceContent(serviceContent); - menu.setServiceProcess(serviceProcess); - menu.setTelephone(telephone); - menu.setType(ItemTypeEnum.ADDED.getCode()); - menu.setCreateOn(LocalDateTime.now()); - menu.setSort(sort); - menuService.save(menu); - } - return "upload success!"; - } - - public String ddl(String sql) { - try { - // 1. 加载数据库驱动 - Class.forName("com.mysql.cj.jdbc.Driver"); - - // 2. 建立数据库连接 - Connection connection = DriverManager.getConnection(url, username, password); - - // 3. 创建Statement对象 - Statement statement = connection.createStatement(); - - // 4. 编写并执行DDL语句(创建一个名为`users`的表) - statement.executeUpdate(sql); - - System.out.println(" Table updated successfully."); - - // 5. 关闭资源 - statement.close(); - connection.close(); - } catch (Exception e) { - e.printStackTrace(); - } - return "success!"; - } - - /** - * 4-10 数据问题 - * @return - */ - public String update4_10() { - //1.窗口后缀不是服务的 都加个服务 - List list = menuService.list(); - for (KqZzsfwMenu menu : list) { - if(StringUtils.isNotBlank(menu.getWindow()) && !menu.getWindow().endsWith("服务")){ - menu.setWindow(menu.getWindow() + "服务"); - menuService.updateById(menu); - } - } - return "success!"; - } -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/manage/PolicyManage.java b/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/manage/PolicyManage.java deleted file mode 100644 index 4917416..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/manage/PolicyManage.java +++ /dev/null @@ -1,84 +0,0 @@ -package com.ningdatech.kqapi.zzsfw.manage; - -import cn.hutool.core.bean.BeanUtil; -import cn.hutool.core.collection.CollUtil; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.ningdatech.kqapi.common.model.PageVo; -import com.ningdatech.kqapi.zzsfw.model.dto.KqZzsfwPolicyDTO; -import com.ningdatech.kqapi.zzsfw.model.entity.KqZzsfwPolicy; -import com.ningdatech.kqapi.zzsfw.model.vo.ZzsfwPolicyVO; -import com.ningdatech.kqapi.zzsfw.service.IKqZzsfwPolicyService; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -import java.util.List; -import java.util.Objects; -import java.util.stream.Collectors; - -/** - * @Classname PolicyManage - * @Description - * @Date 2023/11/02 14:55 - * @Author PoffyZhang - */ -@Component -@Slf4j -@RequiredArgsConstructor -public class PolicyManage { - - private final IKqZzsfwPolicyService policyService; - - - public PageVo list(long pageNumber, long pageSize) { - Page page = Page.of(pageNumber,pageSize); - Page pageRes = policyService.page(page, Wrappers.lambdaQuery(KqZzsfwPolicy.class) - .orderByAsc(KqZzsfwPolicy::getSort)); - - if(CollUtil.isEmpty(pageRes.getRecords())){ - return PageVo.empty(); - } - List res = pageRes.getRecords().stream() - .map(p -> BeanUtil.copyProperties(p, ZzsfwPolicyVO.class)) - .collect(Collectors.toList()); - return PageVo.of(res,pageRes.getTotal()); - } - - public String save(KqZzsfwPolicyDTO dto) { - if(Objects.isNull(dto)){ - return "保存失败 传入为空"; - } - - KqZzsfwPolicy entity = BeanUtil.copyProperties(dto, KqZzsfwPolicy.class); - if(policyService.save(entity)){ - return "保存成功 :" + entity; - }else{ - return "保存失败"; - } - } - - public String removeAll() { - policyService.remove(Wrappers.lambdaQuery(KqZzsfwPolicy.class)); - return "删除成功"; - } - - /** - * 批量保存 - * @param dtos - * @return - */ - public String saveBatch(List dtos) { - if(CollUtil.isEmpty(dtos)){ - return "保存失败 传入为空"; - } - - List entitys = dtos.stream().map(d -> BeanUtil.copyProperties(d, KqZzsfwPolicy.class)) - .collect(Collectors.toList()); - if(policyService.saveBatch(entitys)){ - return "保存成功"; - }else{ - return "保存失败"; - } - } -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/manage/QlManage.java b/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/manage/QlManage.java deleted file mode 100644 index d9bb2bd..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/manage/QlManage.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.ningdatech.kqapi.zzsfw.manage; - -import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import com.ningdatech.kqapi.zzsfw.model.dto.DscSxAdsShareItemQltQlsxCommonIDVKqDTO; -import com.ningdatech.kqapi.zzsfw.model.entity.DscSxAdsShareItemQltQlsxCommonIDVKq; -import com.ningdatech.kqapi.zzsfw.service.IDscSxAdsShareItemQltQlsxCommonIDVKqService; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; -import org.springframework.stereotype.Component; - -import java.util.*; - -/** - * @Classname MatterManage - * @Description - * @Date 2023/10/25 14:55 - * @Author PoffyZhang - */ -@Component -@Slf4j -@RequiredArgsConstructor -public class QlManage { - - private final IDscSxAdsShareItemQltQlsxCommonIDVKqService kqService; - - public List search(DscSxAdsShareItemQltQlsxCommonIDVKqDTO dto) { - List list = kqService.list(Wrappers.lambdaQuery(DscSxAdsShareItemQltQlsxCommonIDVKq.class) - .eq(StringUtils.isNotBlank(dto.getRowguid()), DscSxAdsShareItemQltQlsxCommonIDVKq::getRowguid, dto.getRowguid()) - .eq(StringUtils.isNotBlank(dto.getQlName()), DscSxAdsShareItemQltQlsxCommonIDVKq::getQlName, dto.getQlName()) - .eq(StringUtils.isNotBlank(dto.getWebapplyurl()), DscSxAdsShareItemQltQlsxCommonIDVKq::getWebapplyurl, dto.getWebapplyurl()) - ); - return list; - } -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/mapper/ComponentsMatterEliminateMapper.java b/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/mapper/ComponentsMatterEliminateMapper.java deleted file mode 100644 index cd555c4..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/mapper/ComponentsMatterEliminateMapper.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.ningdatech.kqapi.zzsfw.mapper; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.ningdatech.kqapi.zzsfw.model.entity.ComponentsMatterEliminateEntity; - -/** - * @author wangrenkang - * @date 2024-01-15 10:53:17 - */ -public interface ComponentsMatterEliminateMapper extends BaseMapper { -} \ No newline at end of file diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/mapper/ComponentsMatterEliminateMapper.xml b/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/mapper/ComponentsMatterEliminateMapper.xml deleted file mode 100644 index fec934c..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/mapper/ComponentsMatterEliminateMapper.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/mapper/DscSxAdsShareItemQltQlsxCommonIDVKqMapper.java b/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/mapper/DscSxAdsShareItemQltQlsxCommonIDVKqMapper.java deleted file mode 100644 index 88b5f87..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/mapper/DscSxAdsShareItemQltQlsxCommonIDVKqMapper.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.ningdatech.kqapi.zzsfw.mapper; - -import com.ningdatech.kqapi.zzsfw.model.entity.DscSxAdsShareItemQltQlsxCommonIDVKq; -import com.baomidou.mybatisplus.core.mapper.BaseMapper; - -/** - *

- * 省回流_政务服务_数据共享_事项基本信息表 Mapper 接口 - *

- * - * @author ZPF - * @since 2023-10-25 - */ -public interface DscSxAdsShareItemQltQlsxCommonIDVKqMapper extends BaseMapper { - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/mapper/DscSxAdsShareItemQltQlsxCommonIDVKqMapper.xml b/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/mapper/DscSxAdsShareItemQltQlsxCommonIDVKqMapper.xml deleted file mode 100644 index 023cd65..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/mapper/DscSxAdsShareItemQltQlsxCommonIDVKqMapper.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/mapper/KqZzsfwMatterDeduplicateMapper.java b/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/mapper/KqZzsfwMatterDeduplicateMapper.java deleted file mode 100644 index 05d3005..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/mapper/KqZzsfwMatterDeduplicateMapper.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.ningdatech.kqapi.zzsfw.mapper; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.ningdatech.kqapi.zzsfw.model.entity.KqZzsfwMattersDeduplicate; - -/** - *

- * Mapper 接口 - *

- * - * @author ZPF - * @since 2023-10-27 - */ -public interface KqZzsfwMatterDeduplicateMapper extends BaseMapper { - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/mapper/KqZzsfwMenuMapper.java b/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/mapper/KqZzsfwMenuMapper.java deleted file mode 100644 index 08ae623..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/mapper/KqZzsfwMenuMapper.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.ningdatech.kqapi.zzsfw.mapper; - -import com.ningdatech.kqapi.admin.model.dto.MatterCountByWindowIdDTO; -import com.ningdatech.kqapi.zzsfw.model.entity.KqZzsfwMenu; -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import org.apache.ibatis.annotations.Param; - -import java.util.Collection; -import java.util.List; - -/** - *

- * Mapper 接口 - *

- * - * @author ZPF - * @since 2023-10-27 - */ -public interface KqZzsfwMenuMapper extends BaseMapper { - - List selectMatterCountByWindowIds(@Param("windowIds") Collection windowIds); - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/mapper/KqZzsfwMenuMapper.xml b/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/mapper/KqZzsfwMenuMapper.xml deleted file mode 100644 index 5e0848c..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/mapper/KqZzsfwMenuMapper.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/mapper/KqZzsfwPolicyMapper.java b/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/mapper/KqZzsfwPolicyMapper.java deleted file mode 100644 index 76a6c19..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/mapper/KqZzsfwPolicyMapper.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.ningdatech.kqapi.zzsfw.mapper; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.ningdatech.kqapi.zzsfw.model.entity.KqZzsfwPolicy; - -/** - *

- * Mapper 接口 - *

- * - * @author ZPF - * @since 2023-10-27 - */ -public interface KqZzsfwPolicyMapper extends BaseMapper { - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/model/dto/DscSxAdsShareItemQltQlsxCommonIDVKqDTO.java b/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/model/dto/DscSxAdsShareItemQltQlsxCommonIDVKqDTO.java deleted file mode 100644 index cbee986..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/model/dto/DscSxAdsShareItemQltQlsxCommonIDVKqDTO.java +++ /dev/null @@ -1,417 +0,0 @@ -package com.ningdatech.kqapi.zzsfw.model.dto; - -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -import java.io.Serializable; -import java.time.LocalDateTime; - -/** - *

- * 省回流_政务服务_数据共享_事项基本信息表 - *

- * - * @author ZPF - * @since 2023-10-25 - */ -@Data -public class DscSxAdsShareItemQltQlsxCommonIDVKqDTO implements Serializable { - - private static final long serialVersionUID = 1L; - - @ApiModelProperty("事项唯一标识") - private String rowguid; - - @ApiModelProperty("写入同步时间") - private LocalDateTime updateDate; - - @ApiModelProperty("事项更新类型") - private String updateType; - - @ApiModelProperty("事项类型") - private String qlKind; - - @ApiModelProperty("主项编码") - private String qlMainitemId; - - @ApiModelProperty("子项编码") - private String qlSubitemId; - - @ApiModelProperty("事权层级") - private String shiquancj; - - @ApiModelProperty("行政区划代码") - private String belongxiaqucode; - - @ApiModelProperty("实施机关组织机构代码(主管部门组织机构代码)") - private String qlDepOrgcdoe; - - @ApiModelProperty("权力来源") - private String itemsource; - - @ApiModelProperty("版本号") - private String versionNumber; - - @ApiModelProperty("事项入库时间") - private LocalDateTime versionDate; - - @ApiModelProperty("事项状态生效时间") - private LocalDateTime qlEffectTime; - - @ApiModelProperty("事项内部编码") - private String qlInnerCode; - - @ApiModelProperty("事项名称") - private String qlName; - - @ApiModelProperty("事项状态") - private String qlState; - - @ApiModelProperty("法定依据(审批依据;实施依据)") - private String lawbasis; - - @ApiModelProperty("法定期限") - private Long anticipateDay; - - @ApiModelProperty("法定期限单位") - private String anticipateType; - - @ApiModelProperty("承诺期限") - private Long promiseDay; - - @ApiModelProperty("办事者到办事现场次数") - private Long applyerminCount; - - @ApiModelProperty("是否列为国家、省、市、县级行政审批制度改革试点") - private String isPilot; - - @ApiModelProperty("实施机关(主管部门名称)") - private String qlDep; - - @ApiModelProperty("实施或牵头的处(科)室名称") - private String leadDept; - - @ApiModelProperty("办件类型") - private String bjtype; - - @ApiModelProperty("本级审批性质") - private String benjispxz; - - @ApiModelProperty("办理频率") - private String handleFrequency; - - @ApiModelProperty("行政相对人性质(适用对象(行政相对人性质);服务相对人性质)") - private String xingzhenxdrxz; - - @ApiModelProperty("审批条件(申请条件;受理条件)") - private String applyCondition; - - @ApiModelProperty("办件结果文件名称(审批结果)") - private String banjianFinishfiles; - - @ApiModelProperty("咨询电话") - private String linkTel; - - @ApiModelProperty("监督投诉电话") - private String superviseTel; - - @ApiModelProperty("电脑端网上办理地址") - private String webapplyurl; - - @ApiModelProperty("网上咨询网址") - private String webconsulturl; - - @ApiModelProperty("是否收费") - private String chargeFlag; - - @ApiModelProperty("收费依据") - private String chargeBasis; - - @ApiModelProperty("法人关注点") - private String rightclassQiyezt; - - @ApiModelProperty("面向法人的对象分类") - private String rightclassQiyedx; - - @ApiModelProperty("个人关注点") - private String rightclassGerensx; - - @ApiModelProperty("面向个人的对象分类") - private String rightclassGerendx; - - @ApiModelProperty("内部流程信息") - private String inFlowInfo; - - @ApiModelProperty("业务申报材料") - private String materialInfo; - - @ApiModelProperty("材料情形说明") - private String materialCaseInfo; - - @ApiModelProperty("收费项目") - private String chargeitemInfo; - - @ApiModelProperty("常见问题解答") - private String qaInfo; - - @ApiModelProperty("受理地点信息") - private String acceptAddressInfo; - - @ApiModelProperty("交换标识") - private String syncSign; - - @ApiModelProperty("交换时间") - private LocalDateTime syncDate; - - @ApiModelProperty("交换错误描述") - private String syncErrorDesc; - - @ApiModelProperty("部门组织机构代码") - private String ouorgcode; - - @ApiModelProperty("部门编码") - private String ouguid; - - @ApiModelProperty("法人登录地址(电脑端法人认证地址)") - private String farenurl; - - @ApiModelProperty("电脑端个人认证标识") - private String gerenflag; - - @ApiModelProperty("是否统建系统(是否使用统一网上申报)") - private String isTongjian; - - @ApiModelProperty("事项编码") - private String qlFullId; - - @ApiModelProperty("委托下放") - private String entrust; - - @ApiModelProperty("委托下放说明") - private String entrustdes; - - @ApiModelProperty("最少上门次数说明") - private String applyerminCountDesc; - - @ApiModelProperty("事项所属业务类型") - private String outypecode; - - @ApiModelProperty("对外公布办理程序描述") - private String outFlowDesc; - - @ApiModelProperty("办结类型") - private String banjianFinishtype; - - @ApiModelProperty("是否允许特别程序申请") - private String isSpecialpro; - - @ApiModelProperty("删除数据标识") - private String state2; - - @ApiModelProperty("不适宜开展网上申报") - private String nosuitApply; - - @ApiModelProperty("是否接入统一办件库") - private String isUnifydo; - - @ApiModelProperty("是否是上级主管部门统建系统") - private String isUpunify; - - @ApiModelProperty("权力属性") - private String qlAtt; - - @ApiModelProperty("备注") - private String baknote; - - @ApiModelProperty("星级服务(网上办理业务模式)") - private String webapplymode; - - @ApiModelProperty("权力来源方式") - private String itemsourcetype; - - @ApiModelProperty("是否可以适用处罚简易程序") - private String isSimplepunish; - - @ApiModelProperty("是否涉及征收(税)费减免的审批") - private String isLevywaiver; - - @ApiModelProperty("征收标准") - private String feebasis; - - @ApiModelProperty("自由裁量") - private String factInfo; - - @ApiModelProperty("涉密或敏感") - private String isCs; - - @ApiModelProperty("未接入统一办件库其他原因说明") - private String unifydodes; - - @ApiModelProperty("极少业务") - private String isVlb; - - @ApiModelProperty("nounify_do") - private String nounifyDo; - - @ApiModelProperty("乡镇延伸事项的部门源事项") - private String qlInnerCodeItem; - - @ApiModelProperty("是否投资(bak1)") - private String isTouzip; - - @ApiModelProperty("行业主题分类") - private String hangyeclasstype; - - @ApiModelProperty("其他行政权力子类型") - private String qlSubKind; - - @ApiModelProperty("移动端网上办理地址") - private String appwebapplyurl; - - @ApiModelProperty("移动端网上预约地址") - private String appappointmenturl; - - @ApiModelProperty("电脑端网上预约地址") - private String appointmenturl; - - @ApiModelProperty("是否网上预约") - private String isWebappointment; - - @ApiModelProperty("网上预约时段") - private String webappointmentperiod; - - @ApiModelProperty("主要内容") - private String maincontext; - - @ApiModelProperty("共同实施单位") - private String doDept; - - @ApiModelProperty("相关附件") - private String relatedguid; - - @ApiModelProperty("相关附件信息") - private String related; - - @ApiModelProperty("是否提供快递送达") - private String isExpress; - - @ApiModelProperty("公共服务事项子类型") - private String serviceSubKind; - - @ApiModelProperty("是否列入最多跑一次事项清单") - private String ispyc; - - @ApiModelProperty("联办事项") - private String lbsx; - - @ApiModelProperty("外部流程图") - private String outFlowUrl; - - @ApiModelProperty("受理机构") - private String acpInstitution; - - @ApiModelProperty("决定机构") - private String decInstitution; - - @ApiModelProperty("涉及的内容(公共服务:主要内容)") - private String contentInvolve; - - @ApiModelProperty("适用对象说明") - private String applicableObject; - - @ApiModelProperty("行政相对人权利和义务") - private String xingzhenxdrxy; - - @ApiModelProperty("有无数量限制") - private String countLimit; - - @ApiModelProperty("数量限制情况说明") - private String countNote; - - @ApiModelProperty("禁止性要求") - private String banRequirement; - - @ApiModelProperty("事项审查类型") - private String shixiangsctype; - - @ApiModelProperty("事项审查类型说明") - private String shixiangsclx; - - @ApiModelProperty("申请方式") - private String applyType; - - @ApiModelProperty("联系电话") - private String applyTypeTel; - - @ApiModelProperty("邮箱") - private String applyTypeMail; - - @ApiModelProperty("传真") - private String applyTypeFax; - - @ApiModelProperty("办理方式") - private String handleType; - - @ApiModelProperty("手机端法人认证地址") - private String mbfarenadd; - - @ApiModelProperty("手机端个人认证标识") - private String mbgerenflag; - - @ApiModelProperty("时限说明") - private String destime; - - @ApiModelProperty("送达方式") - private String serviceMode; - - @ApiModelProperty("送达时限") - private String serviceDay; - - @ApiModelProperty("其他") - private String ununifydoOther; - - @ApiModelProperty("是否自有") - private String ishasownflow; - - @ApiModelProperty("分区") - private String dt; - - @ApiModelProperty("所属地市") - private String dscCity; - - @ApiModelProperty("所需区/县") - private String dscAdmRegion; - - @ApiModelProperty("数源单位代码") - private String dscSydepCode; - - @ApiModelProperty("数源单位") - private String dscSydepName; - - @ApiModelProperty("数据所属系统名称") - private String dscSydepSys; - - @ApiModelProperty("数源单位表名") - private String dscSydepTblname; - - @ApiModelProperty("唯一自增序列号") - private String dscBizRecordId; - - @ApiModelProperty("I插入U更新D删除") - private String dscBizOperation; - - @ApiModelProperty("源表数据同步时间") - private LocalDateTime dscBizTimestamp; - - @ApiModelProperty("数据来源表名(清洗库或基础库表名)") - private String dscDatasrTblname; - - @ApiModelProperty("业务主键MD5值(清洗增加)") - private String dscHashUnique; - - @ApiModelProperty("清洗时间(清洗增加)") - private String dscCleanTimestamp; - - @ApiModelProperty("地市仓数据入库时间") - private LocalDateTime dscDwRksj; -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/model/dto/KqZzsfwMattersDeduplicateDTO.java b/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/model/dto/KqZzsfwMattersDeduplicateDTO.java deleted file mode 100644 index 4ae81d0..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/model/dto/KqZzsfwMattersDeduplicateDTO.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.ningdatech.kqapi.zzsfw.model.dto; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -import java.io.Serializable; -import java.time.LocalDateTime; - -/** - *

- * - *

- * - * @author ZPF - * @since 2023-10-27 - */ -@Data -@ApiModel(value = "NdKqZzsfwMattersDeduplicate") -public class KqZzsfwMattersDeduplicateDTO implements Serializable { - - private static final long serialVersionUID = 1L; - - @ApiModelProperty("数据同步时间") - private LocalDateTime createOn; - - @ApiModelProperty("事项名称") - private String qlName; - - @ApiModelProperty("链接") - private String webapplyurl; - - @ApiModelProperty("重复数") - private Integer countNum; -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/model/dto/KqZzsfwMenuDTO.java b/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/model/dto/KqZzsfwMenuDTO.java deleted file mode 100644 index 3987394..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/model/dto/KqZzsfwMenuDTO.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.ningdatech.kqapi.zzsfw.model.dto; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -import java.io.Serializable; -import java.time.LocalDateTime; - -/** - *

- * - *

- * - * @author ZPF - * @since 2023-10-27 - */ -@Data -@ApiModel(value = "NdKqZzsfwMenu对象") -public class KqZzsfwMenuDTO implements Serializable { - - private static final long serialVersionUID = 1L; - - @ApiModelProperty("数据同步时间") - private LocalDateTime createOn; - - @ApiModelProperty("社区名") - private String zoneName; - - @ApiModelProperty("窗口") - private String window; - - @ApiModelProperty("部门") - private String department; - - @ApiModelProperty("事项名称") - private String itemName; - - @ApiModelProperty("事项在政务中心的rowid") - private String itemRowid; - - @ApiModelProperty("排序") - private Integer sort; - - @ApiModelProperty("链接") - private String webapplyurl; - - @ApiModelProperty("是否在政务中心查到url") - private Integer hasUrl; -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/model/dto/KqZzsfwPolicyDTO.java b/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/model/dto/KqZzsfwPolicyDTO.java deleted file mode 100644 index ee30ddf..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/model/dto/KqZzsfwPolicyDTO.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.ningdatech.kqapi.zzsfw.model.dto; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -import java.io.Serializable; -import java.time.LocalDateTime; - -/** - *

- * - *

- * - * @author ZPF - * @since 2023-11-02 - */ -@Data -@ApiModel(value = "NdKqZzsfwPolicyDTO", description = "") -public class KqZzsfwPolicyDTO implements Serializable { - - private static final long serialVersionUID = 1L; - - @ApiModelProperty("数据同步时间") - private LocalDateTime createOn; - - @ApiModelProperty("抬头") - private String header; - - @ApiModelProperty("标题") - private String title; - - @ApiModelProperty("二级标题") - private String secondTitle; - - @ApiModelProperty("适用地区") - private String regionName; - - @ApiModelProperty("责任部门") - private String department; - - @ApiModelProperty("发文日期") - private String issueDate; - - @ApiModelProperty("状态") - private String status; - - @ApiModelProperty("申报时间") - private String applyTime; - - @ApiModelProperty("在线咨询url") - private String onlineConsultationUrl; - - @ApiModelProperty("排序") - private Integer sort; -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/model/entity/ComponentsMatterEliminateEntity.java b/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/model/entity/ComponentsMatterEliminateEntity.java deleted file mode 100644 index 7d08674..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/model/entity/ComponentsMatterEliminateEntity.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.ningdatech.kqapi.zzsfw.model.entity; - -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -import java.security.Timestamp; - -// ComponentsMatterEliminateEntity.java -@Data -@TableName("components_matter_eliminate") -public class ComponentsMatterEliminateEntity { - - /** - * 事项名称剔除表,主要剔除事项url报错404链接 - */ - - @ApiModelProperty("id主键") - @TableId(type = IdType.AUTO) - private Long id; - /** - * 组件名称 - */ - private String qlName; - - /** - * 剔除时间 - */ - private Timestamp eliminateTime; - - /** - * 剔除标识,0未剔除,1已剔除 - */ - private String isDelete; - - public ComponentsMatterEliminateEntity(String qlName,String isDelete) { - this.qlName = qlName; - this.isDelete = isDelete; - } -} - diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/model/entity/DscSxAdsShareItemQltQlsxCommonIDVKq.java b/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/model/entity/DscSxAdsShareItemQltQlsxCommonIDVKq.java deleted file mode 100644 index 2922b59..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/model/entity/DscSxAdsShareItemQltQlsxCommonIDVKq.java +++ /dev/null @@ -1,422 +0,0 @@ -package com.ningdatech.kqapi.zzsfw.model.entity; - -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import java.io.Serializable; -import java.time.LocalDateTime; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -/** - *

- * 省回流_政务服务_数据共享_事项基本信息表 - *

- * - * @author ZPF - * @since 2023-10-25 - */ -@Data -@TableName("dsc_sx_ads_share_item_qlt_qlsx_common_i_d_v_kq") -@ApiModel(value = "DscSxAdsShareItemQltQlsxCommonIDVKq对象", description = "省回流_政务服务_数据共享_事项基本信息表") -public class DscSxAdsShareItemQltQlsxCommonIDVKq implements Serializable { - - private static final long serialVersionUID = 1L; - - @ApiModelProperty("事项唯一标识") - @TableId - private String rowguid; - - @ApiModelProperty("写入同步时间") - private LocalDateTime updateDate; - - @ApiModelProperty("事项更新类型") - private String updateType; - - @ApiModelProperty("事项类型") - private String qlKind; - - @ApiModelProperty("主项编码") - private String qlMainitemId; - - @ApiModelProperty("子项编码") - private String qlSubitemId; - - @ApiModelProperty("事权层级") - private String shiquancj; - - @ApiModelProperty("行政区划代码") - private String belongxiaqucode; - - @ApiModelProperty("实施机关组织机构代码(主管部门组织机构代码)") - private String qlDepOrgcdoe; - - @ApiModelProperty("权力来源") - private String itemsource; - - @ApiModelProperty("版本号") - private String versionNumber; - - @ApiModelProperty("事项入库时间") - private LocalDateTime versionDate; - - @ApiModelProperty("事项状态生效时间") - private LocalDateTime qlEffectTime; - - @ApiModelProperty("事项内部编码") - private String qlInnerCode; - - @ApiModelProperty("事项名称") - private String qlName; - - @ApiModelProperty("事项状态") - private String qlState; - - @ApiModelProperty("法定依据(审批依据;实施依据)") - private String lawbasis; - - @ApiModelProperty("法定期限") - private Long anticipateDay; - - @ApiModelProperty("法定期限单位") - private String anticipateType; - - @ApiModelProperty("承诺期限") - private Long promiseDay; - - @ApiModelProperty("办事者到办事现场次数") - private Long applyerminCount; - - @ApiModelProperty("是否列为国家、省、市、县级行政审批制度改革试点") - private String isPilot; - - @ApiModelProperty("实施机关(主管部门名称)") - private String qlDep; - - @ApiModelProperty("实施或牵头的处(科)室名称") - private String leadDept; - - @ApiModelProperty("办件类型") - private String bjtype; - - @ApiModelProperty("本级审批性质") - private String benjispxz; - - @ApiModelProperty("办理频率") - private String handleFrequency; - - @ApiModelProperty("行政相对人性质(适用对象(行政相对人性质);服务相对人性质)") - private String xingzhenxdrxz; - - @ApiModelProperty("审批条件(申请条件;受理条件)") - private String applyCondition; - - @ApiModelProperty("办件结果文件名称(审批结果)") - private String banjianFinishfiles; - - @ApiModelProperty("咨询电话") - private String linkTel; - - @ApiModelProperty("监督投诉电话") - private String superviseTel; - - @ApiModelProperty("电脑端网上办理地址") - private String webapplyurl; - - @ApiModelProperty("网上咨询网址") - private String webconsulturl; - - @ApiModelProperty("是否收费") - private String chargeFlag; - - @ApiModelProperty("收费依据") - private String chargeBasis; - - @ApiModelProperty("法人关注点") - private String rightclassQiyezt; - - @ApiModelProperty("面向法人的对象分类") - private String rightclassQiyedx; - - @ApiModelProperty("个人关注点") - private String rightclassGerensx; - - @ApiModelProperty("面向个人的对象分类") - private String rightclassGerendx; - - @ApiModelProperty("内部流程信息") - private String inFlowInfo; - - @ApiModelProperty("业务申报材料") - private String materialInfo; - - @ApiModelProperty("材料情形说明") - private String materialCaseInfo; - - @ApiModelProperty("收费项目") - private String chargeitemInfo; - - @ApiModelProperty("常见问题解答") - private String qaInfo; - - @ApiModelProperty("受理地点信息") - private String acceptAddressInfo; - - @ApiModelProperty("交换标识") - private String syncSign; - - @ApiModelProperty("交换时间") - private LocalDateTime syncDate; - - @ApiModelProperty("交换错误描述") - private String syncErrorDesc; - - @ApiModelProperty("部门组织机构代码") - private String ouorgcode; - - @ApiModelProperty("部门编码") - private String ouguid; - - @ApiModelProperty("法人登录地址(电脑端法人认证地址)") - private String farenurl; - - @ApiModelProperty("电脑端个人认证标识") - private String gerenflag; - - @ApiModelProperty("是否统建系统(是否使用统一网上申报)") - private String isTongjian; - - @ApiModelProperty("事项编码") - private String qlFullId; - - @ApiModelProperty("委托下放") - private String entrust; - - @ApiModelProperty("委托下放说明") - private String entrustdes; - - @ApiModelProperty("最少上门次数说明") - private String applyerminCountDesc; - - @ApiModelProperty("事项所属业务类型") - private String outypecode; - - @ApiModelProperty("对外公布办理程序描述") - private String outFlowDesc; - - @ApiModelProperty("办结类型") - private String banjianFinishtype; - - @ApiModelProperty("是否允许特别程序申请") - private String isSpecialpro; - - @ApiModelProperty("删除数据标识") - private String state2; - - @ApiModelProperty("不适宜开展网上申报") - private String nosuitApply; - - @ApiModelProperty("是否接入统一办件库") - private String isUnifydo; - - @ApiModelProperty("是否是上级主管部门统建系统") - private String isUpunify; - - @ApiModelProperty("权力属性") - private String qlAtt; - - @ApiModelProperty("备注") - private String baknote; - - @ApiModelProperty("星级服务(网上办理业务模式)") - private String webapplymode; - - @ApiModelProperty("权力来源方式") - private String itemsourcetype; - - @ApiModelProperty("是否可以适用处罚简易程序") - private String isSimplepunish; - - @ApiModelProperty("是否涉及征收(税)费减免的审批") - private String isLevywaiver; - - @ApiModelProperty("征收标准") - private String feebasis; - - @ApiModelProperty("自由裁量") - private String factInfo; - - @ApiModelProperty("涉密或敏感") - private String isCs; - - @ApiModelProperty("未接入统一办件库其他原因说明") - private String unifydodes; - - @ApiModelProperty("极少业务") - private String isVlb; - - @ApiModelProperty("nounify_do") - private String nounifyDo; - - @ApiModelProperty("乡镇延伸事项的部门源事项") - private String qlInnerCodeItem; - - @ApiModelProperty("是否投资(bak1)") - private String isTouzip; - - @ApiModelProperty("行业主题分类") - private String hangyeclasstype; - - @ApiModelProperty("其他行政权力子类型") - private String qlSubKind; - - @ApiModelProperty("移动端网上办理地址") - private String appwebapplyurl; - - @ApiModelProperty("移动端网上预约地址") - private String appappointmenturl; - - @ApiModelProperty("电脑端网上预约地址") - private String appointmenturl; - - @ApiModelProperty("是否网上预约") - private String isWebappointment; - - @ApiModelProperty("网上预约时段") - private String webappointmentperiod; - - @ApiModelProperty("主要内容") - private String maincontext; - - @ApiModelProperty("共同实施单位") - private String doDept; - - @ApiModelProperty("相关附件") - private String relatedguid; - - @ApiModelProperty("相关附件信息") - private String related; - - @ApiModelProperty("是否提供快递送达") - private String isExpress; - - @ApiModelProperty("公共服务事项子类型") - private String serviceSubKind; - - @ApiModelProperty("是否列入最多跑一次事项清单") - private String ispyc; - - @ApiModelProperty("联办事项") - private String lbsx; - - @ApiModelProperty("外部流程图") - private String outFlowUrl; - - @ApiModelProperty("受理机构") - private String acpInstitution; - - @ApiModelProperty("决定机构") - private String decInstitution; - - @ApiModelProperty("涉及的内容(公共服务:主要内容)") - private String contentInvolve; - - @ApiModelProperty("适用对象说明") - private String applicableObject; - - @ApiModelProperty("行政相对人权利和义务") - private String xingzhenxdrxy; - - @ApiModelProperty("有无数量限制") - private String countLimit; - - @ApiModelProperty("数量限制情况说明") - private String countNote; - - @ApiModelProperty("禁止性要求") - private String banRequirement; - - @ApiModelProperty("事项审查类型") - private String shixiangsctype; - - @ApiModelProperty("事项审查类型说明") - private String shixiangsclx; - - @ApiModelProperty("申请方式") - private String applyType; - - @ApiModelProperty("联系电话") - private String applyTypeTel; - - @ApiModelProperty("邮箱") - private String applyTypeMail; - - @ApiModelProperty("传真") - private String applyTypeFax; - - @ApiModelProperty("办理方式") - private String handleType; - - @ApiModelProperty("手机端法人认证地址") - private String mbfarenadd; - - @ApiModelProperty("手机端个人认证标识") - private String mbgerenflag; - - @ApiModelProperty("时限说明") - private String destime; - - @ApiModelProperty("送达方式") - private String serviceMode; - - @ApiModelProperty("送达时限") - private String serviceDay; - - @ApiModelProperty("其他") - private String ununifydoOther; - - @ApiModelProperty("是否自有") - private String ishasownflow; - - @ApiModelProperty("分区") - private String dt; - - @ApiModelProperty("所属地市") - private String dscCity; - - @ApiModelProperty("所需区/县") - private String dscAdmRegion; - - @ApiModelProperty("数源单位代码") - private String dscSydepCode; - - @ApiModelProperty("数源单位") - private String dscSydepName; - - @ApiModelProperty("数据所属系统名称") - private String dscSydepSys; - - @ApiModelProperty("数源单位表名") - private String dscSydepTblname; - - @ApiModelProperty("唯一自增序列号") - private String dscBizRecordId; - - @ApiModelProperty("I插入U更新D删除") - private String dscBizOperation; - - @ApiModelProperty("源表数据同步时间") - private LocalDateTime dscBizTimestamp; - - @ApiModelProperty("数据来源表名(清洗库或基础库表名)") - private String dscDatasrTblname; - - @ApiModelProperty("业务主键MD5值(清洗增加)") - private String dscHashUnique; - - @ApiModelProperty("清洗时间(清洗增加)") - private String dscCleanTimestamp; - - @ApiModelProperty("地市仓数据入库时间") - private LocalDateTime dscDwRksj; -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/model/entity/KqZzsfwMattersDeduplicate.java b/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/model/entity/KqZzsfwMattersDeduplicate.java deleted file mode 100644 index 55075af..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/model/entity/KqZzsfwMattersDeduplicate.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.ningdatech.kqapi.zzsfw.model.entity; - -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -import java.io.Serializable; -import java.time.LocalDateTime; - -/** - *

- * - *

- * - * @author ZPF - * @since 2023-10-27 - */ -@Data -@TableName("nd_kq_zzsfw_matters_deduplicate") -@ApiModel(value = "NdKqZzsfwMattersDeduplicate") -public class KqZzsfwMattersDeduplicate implements Serializable { - - private static final long serialVersionUID = 1L; - - @ApiModelProperty("id主键") - @TableId(type = IdType.AUTO) - private Long id; - - @ApiModelProperty("数据同步时间") - private LocalDateTime createOn; - - @ApiModelProperty("事项名称") - private String qlName; - - @ApiModelProperty("链接") - private String webapplyurl; - - @ApiModelProperty("重复数") - private Integer countNum = 0; - - public static KqZzsfwMattersDeduplicate of(String qlName, String webapplyurl) { - KqZzsfwMattersDeduplicate dup = new KqZzsfwMattersDeduplicate(); - dup.setQlName(qlName); - dup.setWebapplyurl(webapplyurl); - dup.setCountNum(1); - return dup; - } -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/model/entity/KqZzsfwMenu.java b/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/model/entity/KqZzsfwMenu.java deleted file mode 100644 index 363ff1d..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/model/entity/KqZzsfwMenu.java +++ /dev/null @@ -1,121 +0,0 @@ -package com.ningdatech.kqapi.zzsfw.model.entity; - -import com.baomidou.mybatisplus.annotation.*; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -import java.io.Serializable; -import java.time.LocalDateTime; - -/** - *

- * - *

- * - * @author ZPF - * @since 2023-10-27 - */ -@Data -@TableName("nd_kq_zzsfw_menu") -@ApiModel(value = "NdKqZzsfwMenu对象") -public class KqZzsfwMenu implements Serializable { - - private static final long serialVersionUID = 1L; - - @ApiModelProperty("id主键") - @TableId(type = IdType.AUTO) - private Long id; - - @ApiModelProperty("数据同步时间") - @TableField(fill = FieldFill.INSERT) - private LocalDateTime createOn; - - @ApiModelProperty("数据更新时间") - @TableField(fill = FieldFill.INSERT_UPDATE) - private LocalDateTime updateOn; - - @ApiModelProperty("创建人") - @TableField(fill = FieldFill.INSERT) - private Long createBy; - - @ApiModelProperty("更新人") - @TableField(fill = FieldFill.INSERT_UPDATE) - private Long updateBy; - - @ApiModelProperty("社区名") - private String zoneName; - - @ApiModelProperty("窗口") - private String window; - - @ApiModelProperty("部门") - private String department; - - @ApiModelProperty("事项名称") - private String itemName; - - @ApiModelProperty("事项在政务中心的rowid") - private String itemRowid; - - @ApiModelProperty("排序") - private Integer sort; - - @ApiModelProperty("链接") - private String webapplyurl; - - @ApiModelProperty("是否在政务中心查到url") - private Integer hasUrl; - - @ApiModelProperty("类型 1.政府服务 2.增值服务 3.特殊") - private Integer type; - - @ApiModelProperty("服务内容") - private String serviceContent; - - @ApiModelProperty("服务流程") - private String serviceProcess; - - @ApiModelProperty("咨询电话") - private String telephone; - - @ApiModelProperty("专区id") - private Integer zoneId; - - @ApiModelProperty("窗口id") - private Integer windowId; - - @ApiModelProperty("是否删除") - private Boolean deleted; - - @ApiModelProperty("服务对象") - private String serviceObject; - - @ApiModelProperty("是否免费") - private Boolean free; - - @ApiModelProperty("是否网上缴费") - private Boolean onlinePay; - - @ApiModelProperty("办理渠道") - private Integer handleChannel; - - @ApiModelProperty("办理地点") - private String handleAddress; - - @ApiModelProperty("办理时间") - private String handleTime; - - @ApiModelProperty("行使层级") - private String exerciseLevel; - - @ApiModelProperty("实施主体性质") - private Integer implSubjectNature; - - @ApiModelProperty("特色场景描述") - private String sceneDesc; - - @ApiModelProperty("宣传资料") - private String publicityMaterials; - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/model/entity/KqZzsfwPolicy.java b/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/model/entity/KqZzsfwPolicy.java deleted file mode 100644 index f75a34b..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/model/entity/KqZzsfwPolicy.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.ningdatech.kqapi.zzsfw.model.entity; - -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -import java.io.Serializable; -import java.time.LocalDateTime; - -/** - *

- * - *

- * - * @author ZPF - * @since 2023-11-02 - */ -@Data -@TableName("nd_kq_zzsfw_policy") -@ApiModel(value = "NdKqZzsfwPolicy对象", description = "") -public class KqZzsfwPolicy implements Serializable { - - private static final long serialVersionUID = 1L; - - @ApiModelProperty("id主键") - @TableId(type = IdType.AUTO) - private Long id; - - @ApiModelProperty("数据同步时间") - private LocalDateTime createOn; - - @ApiModelProperty("抬头") - private String header; - - @ApiModelProperty("标题") - private String title; - - @ApiModelProperty("二级标题") - private String secondTitle; - - @ApiModelProperty("适用地区") - private String regionName; - - @ApiModelProperty("责任部门") - private String department; - - @ApiModelProperty("发文日期") - private String issueDate; - - @ApiModelProperty("状态") - private String status; - - @ApiModelProperty("申报时间") - private String applyTime; - - @ApiModelProperty("在线咨询url") - private String onlineConsultationUrl; - - @ApiModelProperty("排序") - private Integer sort; -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/model/entity/MatterKey.java b/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/model/entity/MatterKey.java deleted file mode 100644 index 357f80a..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/model/entity/MatterKey.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.ningdatech.kqapi.zzsfw.model.entity; - -import lombok.Data; - -/** - * @Classname MatterKey - * @Description - * @Date 2024/1/3 11:13 - * @Author PoffyZhang - */ -@Data -public class MatterKey { - - private String qlName; - - private String webapplyurl; - - public static MatterKey of(String qlName, String webapplyurl) { - MatterKey matterKey = new MatterKey(); - matterKey.setQlName(qlName); - matterKey.setWebapplyurl(webapplyurl); - return matterKey; - } -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/model/vo/MatterTopVO.java b/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/model/vo/MatterTopVO.java deleted file mode 100644 index b478a62..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/model/vo/MatterTopVO.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.ningdatech.kqapi.zzsfw.model.vo; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -import java.io.Serializable; - -/** - *

- * 事项 - *

- * - * @author ZPF - * @since 2023-10-25 - */ -@Data -@ApiModel(value = "MatterTopVO", description = "事项top") -public class MatterTopVO implements Serializable { - - private static final long serialVersionUID = 1L; - - @ApiModelProperty("事项名称") - private String matterName; - - @ApiModelProperty("事项链接") - private String webapplyurl; - - @ApiModelProperty("数量") - private Integer count; -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/model/vo/MattersVO.java b/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/model/vo/MattersVO.java deleted file mode 100644 index 24b4d13..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/model/vo/MattersVO.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.ningdatech.kqapi.zzsfw.model.vo; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -import java.io.Serializable; - -/** - *

- * 事项 - *

- * - * @author ZPF - * @since 2023-10-25 - */ -@Data -@ApiModel(value = "MattersVO", description = "事项") -public class MattersVO implements Serializable { - - private static final long serialVersionUID = 1L; - - @ApiModelProperty("id主键") - private Long id; - - @ApiModelProperty("id") - private String rowguid; - - @ApiModelProperty("事项名称") - private String matterName; - - @ApiModelProperty("事项链接") - private String webapplyurl; - - @ApiModelProperty("排序编号") - private Integer sort; - - @ApiModelProperty("类型 1.政府服务 2.增值服务 3.特殊") - private Integer type; - - @ApiModelProperty("服务内容") - private String serviceContent; - - @ApiModelProperty("服务流程") - private String serviceProcess; - - @ApiModelProperty("咨询电话") - private String telephone; -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/model/vo/TreeVO.java b/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/model/vo/TreeVO.java deleted file mode 100644 index 18b020f..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/model/vo/TreeVO.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.ningdatech.kqapi.zzsfw.model.vo; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -import java.io.Serializable; -import java.util.List; - -/** - *

- * 树结构 - *

- * - * @author ZPF - * @since 2023-10-25 - */ -@Data -@ApiModel(value = "TreeVO", description = "树结构") -public class TreeVO implements Serializable { - - private static final long serialVersionUID = 1L; - - @ApiModelProperty("rowid") - private String id; - - @ApiModelProperty("名称") - private String name; - - @ApiModelProperty("类型") - private String type; - - @ApiModelProperty("链接") - private String url; - - @ApiModelProperty("链接") - private Integer sort; - - @ApiModelProperty("事项类型") - private Integer itemType; - - @ApiModelProperty("事项类型") - private Integer itemTypeName; - - @ApiModelProperty("服务内容") - private String serviceContent; - - @ApiModelProperty("服务流程") - private String serviceProcess; - - @ApiModelProperty("咨询电话") - private String telephone; - - @ApiModelProperty("子级") - private List chilren; -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/model/vo/WindowVO.java b/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/model/vo/WindowVO.java deleted file mode 100644 index f982b95..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/model/vo/WindowVO.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.ningdatech.kqapi.zzsfw.model.vo; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -import java.io.Serializable; -import java.util.List; - -/** - *

- * 社区VO - *

- * - * @author ZPF - * @since 2023-10-25 - */ -@Data -@ApiModel(value = "WindowVO", description = "窗口VO") -public class WindowVO implements Serializable { - - private static final long serialVersionUID = 1L; - - @ApiModelProperty("窗口") - private String windowName; - - @ApiModelProperty("事项") - private List matters; -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/model/vo/ZoneVO.java b/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/model/vo/ZoneVO.java deleted file mode 100644 index 2b71c76..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/model/vo/ZoneVO.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.ningdatech.kqapi.zzsfw.model.vo; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -import java.io.Serializable; -import java.util.List; - -/** - *

- * 社区VO - *

- * - * @author ZPF - * @since 2023-10-25 - */ -@Data -@ApiModel(value = "ZoneVO", description = "社区VO") -public class ZoneVO implements Serializable { - - private static final long serialVersionUID = 1L; - - @ApiModelProperty("社区") - private String zoneName; - - @ApiModelProperty("社区") - private List windows; -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/model/vo/ZzsfwPolicyVO.java b/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/model/vo/ZzsfwPolicyVO.java deleted file mode 100644 index 628b9e0..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/model/vo/ZzsfwPolicyVO.java +++ /dev/null @@ -1,59 +0,0 @@ -package com.ningdatech.kqapi.zzsfw.model.vo; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -import java.io.Serializable; -import java.time.LocalDateTime; - -/** - *

- * - *

- * - * @author ZPF - * @since 2023-11-02 - */ -@Data -@ApiModel(value = "NdKqZzsfwPolicy VO") -public class ZzsfwPolicyVO implements Serializable { - - private static final long serialVersionUID = 1L; - - @ApiModelProperty("id主键") - private Long id; - - @ApiModelProperty("数据同步时间") - private LocalDateTime createOn; - - @ApiModelProperty("抬头") - private String header; - - @ApiModelProperty("标题") - private String title; - - @ApiModelProperty("二级标题") - private String secondTitle; - - @ApiModelProperty("适用地区") - private String regionName; - - @ApiModelProperty("责任部门") - private String department; - - @ApiModelProperty("发文日期") - private String issueDate; - - @ApiModelProperty("状态") - private String status; - - @ApiModelProperty("申报时间") - private String applyTime; - - @ApiModelProperty("在线咨询url") - private String onlineConsultationUrl; - - @ApiModelProperty("排序") - private Integer sort; -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/service/ComponentsMatterEliminateService.java b/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/service/ComponentsMatterEliminateService.java deleted file mode 100644 index 3129522..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/service/ComponentsMatterEliminateService.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.ningdatech.kqapi.zzsfw.service; - -import com.baomidou.mybatisplus.extension.service.IService; -import com.ningdatech.kqapi.zzsfw.model.entity.ComponentsMatterEliminateEntity; - -// ComponentsMatterEliminateService.java -public interface ComponentsMatterEliminateService extends IService { -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/service/IDscSxAdsShareItemQltQlsxCommonIDVKqService.java b/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/service/IDscSxAdsShareItemQltQlsxCommonIDVKqService.java deleted file mode 100644 index be4be3b..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/service/IDscSxAdsShareItemQltQlsxCommonIDVKqService.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.ningdatech.kqapi.zzsfw.service; - -import com.ningdatech.kqapi.zzsfw.model.entity.DscSxAdsShareItemQltQlsxCommonIDVKq; -import com.baomidou.mybatisplus.extension.service.IService; - -/** - *

- * 省回流_政务服务_数据共享_事项基本信息表 服务类 - *

- * - * @author ZPF - * @since 2023-10-25 - */ -public interface IDscSxAdsShareItemQltQlsxCommonIDVKqService extends IService { - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/service/IKqZzsfwMatterDeduplicateService.java b/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/service/IKqZzsfwMatterDeduplicateService.java deleted file mode 100644 index c631f97..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/service/IKqZzsfwMatterDeduplicateService.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.ningdatech.kqapi.zzsfw.service; - -import com.baomidou.mybatisplus.extension.service.IService; -import com.ningdatech.kqapi.zzsfw.model.entity.KqZzsfwMattersDeduplicate; - -/** - *

- * 服务类 - *

- * - * @author ZPF - * @since 2023-10-27 - */ -public interface IKqZzsfwMatterDeduplicateService extends IService { - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/service/IKqZzsfwMenuService.java b/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/service/IKqZzsfwMenuService.java deleted file mode 100644 index 67a20c5..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/service/IKqZzsfwMenuService.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.ningdatech.kqapi.zzsfw.service; - -import com.baomidou.mybatisplus.extension.service.IService; -import com.ningdatech.kqapi.zzsfw.model.entity.KqZzsfwMenu; - -import java.util.Collection; -import java.util.Map; - -/** - *

- * 服务类 - *

- * - * @author ZPF - * @since 2023-10-27 - */ -public interface IKqZzsfwMenuService extends IService { - - Map matterCountByWindowIds(Collection windowIds); - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/service/IKqZzsfwPolicyService.java b/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/service/IKqZzsfwPolicyService.java deleted file mode 100644 index ee81ca9..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/service/IKqZzsfwPolicyService.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.ningdatech.kqapi.zzsfw.service; - -import com.baomidou.mybatisplus.extension.service.IService; -import com.ningdatech.kqapi.zzsfw.model.entity.KqZzsfwPolicy; - -/** - *

- * 服务类 - *

- * - * @author ZPF - * @since 2023-10-27 - */ -public interface IKqZzsfwPolicyService extends IService { - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/service/impl/ComponentsMatterEliminateServiceImpl.java b/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/service/impl/ComponentsMatterEliminateServiceImpl.java deleted file mode 100644 index 7042acd..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/service/impl/ComponentsMatterEliminateServiceImpl.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.ningdatech.kqapi.zzsfw.service.impl; - -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.ningdatech.kqapi.zzsfw.model.entity.ComponentsMatterEliminateEntity; -import com.ningdatech.kqapi.zzsfw.mapper.ComponentsMatterEliminateMapper; -import com.ningdatech.kqapi.zzsfw.service.ComponentsMatterEliminateService; -import org.springframework.stereotype.Service; - -/** - * @author wangrenkang - * @date 2024-01-15 10:54:49 - */ -@Service -public class ComponentsMatterEliminateServiceImpl extends ServiceImpl implements ComponentsMatterEliminateService { - -} \ No newline at end of file diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/service/impl/DscSxAdsShareItemQltQlsxCommonIDVKqServiceImpl.java b/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/service/impl/DscSxAdsShareItemQltQlsxCommonIDVKqServiceImpl.java deleted file mode 100644 index 8af12b7..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/service/impl/DscSxAdsShareItemQltQlsxCommonIDVKqServiceImpl.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.ningdatech.kqapi.zzsfw.service.impl; - -import com.ningdatech.kqapi.zzsfw.model.entity.DscSxAdsShareItemQltQlsxCommonIDVKq; -import com.ningdatech.kqapi.zzsfw.mapper.DscSxAdsShareItemQltQlsxCommonIDVKqMapper; -import com.ningdatech.kqapi.zzsfw.service.IDscSxAdsShareItemQltQlsxCommonIDVKqService; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import org.springframework.stereotype.Service; - -/** - *

- * 省回流_政务服务_数据共享_事项基本信息表 服务实现类 - *

- * - * @author ZPF - * @since 2023-10-25 - */ -@Service -public class DscSxAdsShareItemQltQlsxCommonIDVKqServiceImpl extends ServiceImpl implements IDscSxAdsShareItemQltQlsxCommonIDVKqService { - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/service/impl/KqZzsfwMatterDeduplicateServiceImpl.java b/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/service/impl/KqZzsfwMatterDeduplicateServiceImpl.java deleted file mode 100644 index 7bca6b0..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/service/impl/KqZzsfwMatterDeduplicateServiceImpl.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.ningdatech.kqapi.zzsfw.service.impl; - -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.ningdatech.kqapi.zzsfw.model.entity.KqZzsfwMattersDeduplicate; -import com.ningdatech.kqapi.zzsfw.mapper.KqZzsfwMatterDeduplicateMapper; -import com.ningdatech.kqapi.zzsfw.service.IKqZzsfwMatterDeduplicateService; -import org.springframework.stereotype.Service; - -/** - *

- * 服务实现类 - *

- * - * @author ZPF - * @since 2023-10-27 - */ -@Service -public class KqZzsfwMatterDeduplicateServiceImpl extends ServiceImpl - implements IKqZzsfwMatterDeduplicateService { - -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/service/impl/KqZzsfwMenuServiceImpl.java b/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/service/impl/KqZzsfwMenuServiceImpl.java deleted file mode 100644 index def79e7..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/service/impl/KqZzsfwMenuServiceImpl.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.ningdatech.kqapi.zzsfw.service.impl; - -import cn.hutool.core.collection.CollUtil; -import com.ningdatech.basic.util.CollUtils; -import com.ningdatech.kqapi.admin.model.dto.MatterCountByWindowIdDTO; -import com.ningdatech.kqapi.zzsfw.model.entity.KqZzsfwMenu; -import com.ningdatech.kqapi.zzsfw.mapper.KqZzsfwMenuMapper; -import com.ningdatech.kqapi.zzsfw.service.IKqZzsfwMenuService; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import org.springframework.stereotype.Service; - -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -/** - *

- * 服务实现类 - *

- * - * @author ZPF - * @since 2023-10-27 - */ -@Service -public class KqZzsfwMenuServiceImpl extends ServiceImpl implements IKqZzsfwMenuService { - - @Override - public Map matterCountByWindowIds(Collection windowIds) { - if (CollUtil.isEmpty(windowIds)) { - return Collections.emptyMap(); - } - List matterCountByWindowIds = baseMapper.selectMatterCountByWindowIds(windowIds); - return CollUtils.listToMap(matterCountByWindowIds, - MatterCountByWindowIdDTO::getWindowId, - MatterCountByWindowIdDTO::getMatterCount); - } -} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/service/impl/KqZzsfwPolicyServiceImpl.java b/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/service/impl/KqZzsfwPolicyServiceImpl.java deleted file mode 100644 index 230cdb1..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/service/impl/KqZzsfwPolicyServiceImpl.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.ningdatech.kqapi.zzsfw.service.impl; - -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.ningdatech.kqapi.zzsfw.model.entity.KqZzsfwPolicy; -import com.ningdatech.kqapi.zzsfw.mapper.KqZzsfwPolicyMapper; -import com.ningdatech.kqapi.zzsfw.service.IKqZzsfwPolicyService; -import org.springframework.stereotype.Service; - -/** - *

- * 服务实现类 - *

- * - * @author ZPF - * @since 2023-10-27 - */ -@Service -public class KqZzsfwPolicyServiceImpl extends ServiceImpl - implements IKqZzsfwPolicyService { - -} diff --git a/kqapi/src/main/resources/application-dev.yml b/kqapi/src/main/resources/application-dev.yml deleted file mode 100644 index 46f263e..0000000 --- a/kqapi/src/main/resources/application-dev.yml +++ /dev/null @@ -1,142 +0,0 @@ -server: - port: 33060 - servlet: - context-path: /kq - -spring: - mvc: - pathmatch: - matching-strategy: ant_path_matcher - session: - store-type: redis - redis: - namespace: "spring:session" - timeout: 864000 - redis: - timeout: 5000 - host: 47.98.125.47 - port: 26379 - database: 7 - password: Ndkj1234 - jedis: - pool: - max-active: 200 - max-idle: 500 - min-idle: 8 - max-wait: 10000 - application: - name: kq - jackson: - default-property-inclusion: non_null - time-zone: GMT+8 - date-format: yyyy-MM-dd HH:mm:ss - jpa: - properties: - hibernate: - default_schema: PUBLIC - hbm2ddl: - auto: update - show_sql: true - show-sql: true - hibernate: - ddl-auto: update - datasource: - type: com.zaxxer.hikari.HikariDataSource - driver-class-name: com.mysql.cj.jdbc.Driver - url: ENC(aMGW3+FFqxyutRz9liYjAg+A72b6IQ7/ygtxO0DmQJ/LLFZkx8r4MhN8quv9L62nQ4sH55qFg+LnQoor/t8IqBACrbfNg462YNKnRyMsBmdHHxJm7i57flIQfePLDW93Omz4LZ2PbRZTvPcLLYtnQyxXSDPwDnjexHNVXTdxwuTJPBqthsVpvyA2mnn5Szef) - username: root - password: ENC(NHFdgnNk7opRJpNnZOJs51OTXb72zU//) - # 数据源 - hikari: - # 是客户端等待连接池连接的最大毫秒数 - connection-timeout: 30000 - # 是允许连接在连接池中空闲的最长时间 - minimum-idle: 5 - # 配置最大池大小 - maximum-pool-size: 300 - # 是允许连接在连接池中空闲的最长时间(以毫秒为单位) - idle-timeout: 60000 - # 池中连接关闭后的最长生命周期(以毫秒为单位) - max-lifetime: 600000 - # 配置从池返回的连接的默认自动提交行为。默认值为true。 - auto-commit: true - # 开启连接监测泄露 - leak-detection-threshold: 500000 - # 测试连接数据库 - connection-test-query: SELECT 1 - #设置上传 单个文件的大小 - servlet: - multipart: - max-file-size: 100MB - max-request-size: 150MB -mybatis-plus: - configuration: - log-impl: org.apache.ibatis.logging.stdout.StdOutImpl - global-config: - db-config: - logic-delete-value: true - logic-not-delete-value: false - logic-delete-field: deleted -logging: - config: classpath:logback-spring.xml - #日志配置 - level: - root: info - file: - path: logs -nd: - cache: - type: REDIS - serializerType: ProtoStuff - cacheNullVal: true - def: - keyPrefix: kq - log: - enabled: true - type: DB - # 文件存储 - file: - storage-type: ALI_OSS - ali: - protocol: https:// - bucket: devplat - urlPrefix: oss-cn-hangzhou.aliyuncs.com - endpoint: oss-cn-hangzhou.aliyuncs.com - accessKeyId: LTAI4GL7uypycnBjiRn55rMG - accessKeySecret: qwYC7bW9bkStsko7qkLVnToAzj0Y98 -# 日志文件配置 -log: - path: ./logs - info: - file-size: 50MB - max-size: 5 - total-size: 200MB - error: - file-size: 10MB - max-size: 5 - total-size: 50MB - -swagger: - enabled: true - -hostname: iZbp13nwyvib53j4j1p2xoZ - -jasypt: - encryptor: - password: CodeSheep - # 指定解密算法,需要和加密时使用的算法一致 - algorithm: PBEWithMD5AndDES - # 指定initialization vector类型 - iv-generator-classname: org.jasypt.iv.NoIvGenerator -sso: - access-key: BCDSGA_c2494577610c90bdc33b95514601da2c - secret-key: BCDSGS_80bf0a606c0d2fd3201bd06a4f008250 - app-id: 2002399646 - token: - internet-url: https://ibcdsg.zj.gov.cn:8443/restapi/prod/IC33000020220329000007/uc/sso/access_token - zww-url: https://bcdsg.zj.gov.cn:8443/restapi/prod/IC33000020220329000007/uc/sso/access_token - user-info: - internet-url: https://ibcdsg.zj.gov.cn:8443/restapi/prod/IC33000020220329000008/uc/sso/getUserInfo - zww-url: https://bcdsg.zj.gov.cn:8443/restapi/prod/IC33000020220329000008/uc/sso/getUserInfo - - diff --git a/kqapi/src/main/resources/application-pre.yml b/kqapi/src/main/resources/application-pre.yml deleted file mode 100644 index 3d6716e..0000000 --- a/kqapi/src/main/resources/application-pre.yml +++ /dev/null @@ -1,138 +0,0 @@ -server: - port: 33060 - servlet: - context-path: /kq - -spring: - mvc: - pathmatch: - matching-strategy: ant_path_matcher - session: - store-type: redis - redis: - namespace: "spring:session" - timeout: 864000 - redis: - timeout: 5000 - host: 47.98.125.47 - port: 26379 - database: 7 - password: Ndkj1234 - jedis: - pool: - max-active: 200 - max-idle: 500 - min-idle: 8 - max-wait: 10000 - application: - name: kq - jackson: - default-property-inclusion: non_null - time-zone: GMT+8 - date-format: yyyy-MM-dd HH:mm:ss - jpa: - properties: - hibernate: - default_schema: PUBLIC - hbm2ddl: - auto: update - show_sql: true - show-sql: true - hibernate: - ddl-auto: update - datasource: - type: com.zaxxer.hikari.HikariDataSource - driver-class-name: com.mysql.cj.jdbc.Driver - url: ENC(aMGW3+FFqxyutRz9liYjAg+A72b6IQ7/ygtxO0DmQJ/LLFZkx8r4MhN8quv9L62nQ4sH55qFg+LnQoor/t8IqBACrbfNg462YNKnRyMsBmdHHxJm7i57flIQfePLDW93Omz4LZ2PbRZTvPcLLYtnQyxXSDPwDnjexHNVXTdxwuTJPBqthsVpvyA2mnn5Szef) - username: root - password: NingdaKeji123! - # 数据源 - hikari: - # 是客户端等待连接池连接的最大毫秒数 - connection-timeout: 30000 - # 是允许连接在连接池中空闲的最长时间 - minimum-idle: 5 - # 配置最大池大小 - maximum-pool-size: 300 - # 是允许连接在连接池中空闲的最长时间(以毫秒为单位) - idle-timeout: 60000 - # 池中连接关闭后的最长生命周期(以毫秒为单位) - max-lifetime: 600000 - # 配置从池返回的连接的默认自动提交行为。默认值为true。 - auto-commit: true - # 开启连接监测泄露 - leak-detection-threshold: 500000 - # 测试连接数据库 - connection-test-query: SELECT 1 - #设置上传 单个文件的大小 - servlet: - multipart: - max-file-size: 100MB - max-request-size: 150MB -mybatis-plus: - configuration: - log-impl: org.apache.ibatis.logging.stdout.StdOutImpl - global-config: - db-config: - logic-delete-value: true - logic-not-delete-value: false -logging: - config: classpath:logback-spring.xml - #日志配置 - level: - root: info - file: - path: logs -nd: - cache: - type: REDIS - serializerType: ProtoStuff - cacheNullVal: true - def: - keyPrefix: kq - log: - enabled: true - type: DB - # 文件存储 - file: - storage-type: ALI_OSS - ali: - protocol: https:// - bucket: devplat - urlPrefix: oss-cn-hangzhou.aliyuncs.com - endpoint: oss-cn-hangzhou.aliyuncs.com - accessKeyId: LTAI4GL7uypycnBjiRn55rMG - accessKeySecret: qwYC7bW9bkStsko7qkLVnToAzj0Y98 -# 日志文件配置 -log: - path: ./logs - info: - file-size: 50MB - max-size: 5 - total-size: 200MB - error: - file-size: 10MB - max-size: 5 - total-size: 50MB - -swagger: - enabled: true - -hostname: iZbp13nwyvib53j4j1p2xoZ - -jasypt: - encryptor: - password: CodeSheep - algorithm: PBEWithMD5AndDES - # 指定initialization vector类型 - iv-generator-classname: org.jasypt.iv.NoIvGenerator -sso: - access-key: BCDSGA_c2494577610c90bdc33b95514601da2c - secret-key: BCDSGS_80bf0a606c0d2fd3201bd06a4f008250 - app-id: 2002399646 - token: - internet-url: https://ibcdsg.zj.gov.cn:8443/restapi/prod/IC33000020220329000007/uc/sso/access_token - zww-url: https://bcdsg.zj.gov.cn:8443/restapi/prod/IC33000020220329000007/uc/sso/access_token - user-info: - internet-url: https://ibcdsg.zj.gov.cn:8443/restapi/prod/IC33000020220329000008/uc/sso/getUserInfo - zww-url: https://bcdsg.zj.gov.cn:8443/restapi/prod/IC33000020220329000008/uc/sso/getUserInfo \ No newline at end of file diff --git a/kqapi/src/main/resources/application-prod.yml b/kqapi/src/main/resources/application-prod.yml deleted file mode 100644 index 56dfaa5..0000000 --- a/kqapi/src/main/resources/application-prod.yml +++ /dev/null @@ -1,142 +0,0 @@ -server: - port: 33061 - servlet: - context-path: /kq - -spring: - mvc: - pathmatch: - matching-strategy: ant_path_matcher - session: - store-type: redis - redis: - namespace: "spring:session" - timeout: 864000 - redis: - timeout: 5000 - host: 47.98.125.47 - port: 26379 - database: 7 - password: Ndkj1234 - jedis: - pool: - max-active: 200 - max-idle: 500 - min-idle: 8 - max-wait: 10000 - application: - name: kq - jackson: - default-property-inclusion: non_null - time-zone: GMT+8 - date-format: yyyy-MM-dd HH:mm:ss - jpa: - properties: - hibernate: - default_schema: PUBLIC - hbm2ddl: - auto: update - show_sql: true - show-sql: true - hibernate: - ddl-auto: update - datasource: - type: com.zaxxer.hikari.HikariDataSource - driver-class-name: com.mysql.cj.jdbc.Driver - url: ENC(gtE4OUrpgtFsh6B3aLiSp2sVSX1BYDET9Uii/wRP2RboRK0NDaYu1S7Vx30cHXFE7vecQzY1UbrSFW/BaWJvQ3XJxfDiaUxdrIDND5e+DMTjx1pUkfS8/RbXHQDE+QoOVZV1UKEtdq+khr32tlQXqkTnzmZGuZjctVmjdQxUnmI2YNpoeNlIAkDXiaCvcVYc) - username: root - password: Nd@20231116 - - # 数据源 - hikari: - # 是客户端等待连接池连接的最大毫秒数 - connection-timeout: 30000 - # 是允许连接在连接池中空闲的最长时间 - minimum-idle: 5 - # 配置最大池大小 - maximum-pool-size: 300 - # 是允许连接在连接池中空闲的最长时间(以毫秒为单位) - idle-timeout: 60000 - # 池中连接关闭后的最长生命周期(以毫秒为单位) - max-lifetime: 600000 - # 配置从池返回的连接的默认自动提交行为。默认值为true。 - auto-commit: true - # 开启连接监测泄露 - leak-detection-threshold: 500000 - # 测试连接数据库 - connection-test-query: SELECT 1 - #设置上传 单个文件的大小 - servlet: - multipart: - max-file-size: 100MB - max-request-size: 150MB -mybatis-plus: - configuration: - log-impl: org.apache.ibatis.logging.stdout.StdOutImpl - global-config: - db-config: - logic-delete-value: true - logic-not-delete-value: false - logic-delete-field: deleted -logging: - config: classpath:logback-spring.xml - #日志配置 - level: - root: info - file: - path: logs -nd: - cache: - type: REDIS - serializerType: ProtoStuff - cacheNullVal: true - def: - keyPrefix: kq - log: - enabled: true - type: DB - # 文件存储 - file: - storage-type: ALI_OSS - ali: - protocol: https:// - bucket: devplat - urlPrefix: oss-cn-hangzhou.aliyuncs.com - endpoint: oss-cn-hangzhou.aliyuncs.com - accessKeyId: LTAI4GL7uypycnBjiRn55rMG - accessKeySecret: qwYC7bW9bkStsko7qkLVnToAzj0Y98 -# 日志文件配置 -log: - path: ./logs - info: - file-size: 50MB - max-size: 5 - total-size: 200MB - error: - file-size: 10MB - max-size: 5 - total-size: 50MB - -swagger: - enabled: false - -hostname: iZut201mqskxt0mwme4tjfZ - -jasypt: - encryptor: - password: CodeSheep - algorithm: PBEWithMD5AndDES - # 指定initialization vector类型 - iv-generator-classname: org.jasypt.iv.NoIvGenerator -sso: - access-key: BCDSGA_c2494577610c90bdc33b95514601da2c - secret-key: BCDSGS_80bf0a606c0d2fd3201bd06a4f008250 - app-id: 2002399646 - token: - internet-url: https://ibcdsg.zj.gov.cn:8443/restapi/prod/IC33000020220329000007/uc/sso/access_token - zww-url: https://bcdsg.zj.gov.cn:8443/restapi/prod/IC33000020220329000007/uc/sso/access_token - user-info: - internet-url: https://ibcdsg.zj.gov.cn:8443/restapi/prod/IC33000020220329000008/uc/sso/getUserInfo - zww-url: https://bcdsg.zj.gov.cn:8443/restapi/prod/IC33000020220329000008/uc/sso/getUserInfo - - diff --git a/kqapi/src/main/resources/application.yml b/kqapi/src/main/resources/application.yml deleted file mode 100644 index 3d7808a..0000000 --- a/kqapi/src/main/resources/application.yml +++ /dev/null @@ -1,3 +0,0 @@ -spring: - profiles: - active: dev diff --git a/kqapi/src/main/resources/logback-spring.xml b/kqapi/src/main/resources/logback-spring.xml deleted file mode 100644 index 75f5472..0000000 --- a/kqapi/src/main/resources/logback-spring.xml +++ /dev/null @@ -1,68 +0,0 @@ - - - - - - - - - - - ${logPath}/info.log - - ${logPath}/info-%d{yyyyMMdd}-%i.log - - ${infoFileSize} - - ${infoMaxSize} - ${infoTotalSize} - - - - %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} -%msg%n - - - UTF-8 - - - - - - ERROR - - ${logPath}/error.log - - ${logPath}/error-%d{yyyyMMdd}-%i.log - - ${errorFileSize} - - ${errorMaxSize} - ${errorTotalSize} - - - - %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} -%msg%n - - - UTF-8 - - - - - - - %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} -%msg%n - - UTF-8 - - - DEBUG - - - - - - - - - diff --git a/kqapi/src/main/resources/security/auth-dev.yml b/kqapi/src/main/resources/security/auth-dev.yml deleted file mode 100644 index b0fd8b5..0000000 --- a/kqapi/src/main/resources/security/auth-dev.yml +++ /dev/null @@ -1,38 +0,0 @@ -security: - auth: - auth-require-url: /api/v1/user/auth/auth-require - invalid-session-url: /api/v1/user/auth/invalid-session - password-login-url: /api/v1/user/auth/login/password - logout-url: /api/v1/user/auth/logout - ignore-auth-urls: - - /api/v1/poclicy/** - - /api/v1/zzsfw/** - - /v2/api-docs - - /swagger-ui.html - - /webjars/** - - /swagger-resources/** - - /webjars/ - - /api/v1/user/auth/register - - /api/v1/user/auth/auth-require - - /api/v1/user/auth/invalid-session - - /api/v1/user/auth/login/password - - /api/v1/user/auth/forget-password - - /doc.html - - /ok.html - - /open/api/** - - /api/v1/wechat/** - ignore-csrf-urls: - - /api/v1/poclicy/** - - /api/v1/zzsfw/** - - /api/v1/user/auth/** - - /v2/api-docs - - /swagger-ui.html - - /webjars/** - - /swagger-resources/** - - /webjars/ - - /doc.html - - /ok.html - - /api/v1/** - - /file/** - - /optLog/** - - /dict/** \ No newline at end of file diff --git a/kqapi/src/main/resources/security/auth-prod.yml b/kqapi/src/main/resources/security/auth-prod.yml deleted file mode 100644 index f264900..0000000 --- a/kqapi/src/main/resources/security/auth-prod.yml +++ /dev/null @@ -1,39 +0,0 @@ -security: - auth: - auth-require-url: /api/v1/user/auth/auth-require - invalid-session-url: /api/v1/user/auth/invalid-session - password-login-url: /api/v1/user/auth/login/password - logout-url: /api/v1/user/auth/logout - ignore-auth-urls: - - /v2/api-docs - - /swagger-ui.html - - /webjars/** - - /swagger-resources/** - - /webjars/ - - /api/v1/user/auth/register - - /api/v1/user/auth/login/password - - /api/v1/user/auth/forget-password - - /doc.html - - /ok.html - - /api/v1/wechat/** - ignore-csrf-urls: - - /api/v1/user/auth/** - - /v2/api-docs - - /swagger-ui.html - - /webjars/** - - /swagger-resources/** - - /webjars/ - - /doc.html - - /ok.html - - /api/v1/** - - /file/** - - /optLog/** - - /dict/** - - /api/v1/wechat/** - role-map: - "engineer": - "project_manager": - "enterprise_admin": - "regional_general_manager": - "driver": - "super_admin": \ No newline at end of file diff --git a/kqapi/src/test/java/com/ningdatech/kqapi/AppTests.java b/kqapi/src/test/java/com/ningdatech/kqapi/AppTests.java deleted file mode 100644 index a86f1d9..0000000 --- a/kqapi/src/test/java/com/ningdatech/kqapi/AppTests.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.ningdatech.kqapi; - -import org.junit.runner.RunWith; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit4.SpringRunner; - -/** - *

- * AppRunTests - *

- * - * @author WendyYang - * @since 19:27 2022/5/10 - */ -@RunWith(SpringRunner.class) -@SpringBootTest(classes = App.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) -public class AppTests { - -} diff --git a/kqapi/src/test/java/com/ningdatech/kqapi/menu/DuplicationTest.java b/kqapi/src/test/java/com/ningdatech/kqapi/menu/DuplicationTest.java deleted file mode 100644 index 70a46fe..0000000 --- a/kqapi/src/test/java/com/ningdatech/kqapi/menu/DuplicationTest.java +++ /dev/null @@ -1,100 +0,0 @@ -package com.ningdatech.kqapi.menu; - -import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import com.google.common.collect.Sets; -import com.ningdatech.kqapi.AppTests; -import com.ningdatech.kqapi.zzsfw.model.entity.KqZzsfwMenu; -import com.ningdatech.kqapi.zzsfw.model.entity.KqZzsfwMattersDeduplicate; -import com.ningdatech.kqapi.zzsfw.service.IKqZzsfwMatterDeduplicateService; -import com.ningdatech.kqapi.zzsfw.service.IKqZzsfwMenuService; -import org.apache.commons.lang3.StringUtils; -import org.apache.poi.ss.usermodel.Row; -import org.apache.poi.ss.usermodel.Sheet; -import org.apache.poi.ss.usermodel.Workbook; -import org.apache.poi.xssf.usermodel.XSSFWorkbook; -import org.junit.Assert; -import org.junit.Test; -import org.springframework.beans.factory.annotation.Autowired; - -import java.io.FileInputStream; -import java.io.IOException; -import java.time.LocalDateTime; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.stream.Collectors; - -/** - * @Classname DuplicationTest - * @Description - * @Date 2023/11/17 10:42 - * @Author PoffyZhang - */ -public class DuplicationTest extends AppTests { - - @Autowired - private IKqZzsfwMatterDeduplicateService matterDeduplicateService; - - @Autowired - private IKqZzsfwMenuService menuService; - - @Test - public void test() throws IOException { - FileInputStream fis = new FileInputStream("C:\\Users\\PoffyZhang\\Desktop\\去重后的事项数据.xlsx"); - Workbook workbook = new XSSFWorkbook(fis); - Assert.assertNotNull(workbook); - Row row; - if (workbook != null) { - //获取最大行数 - Sheet sheet = workbook.getSheetAt(0); - int rownum = sheet.getPhysicalNumberOfRows(); - //获取第一行 - row = sheet.getRow(0); - //获取最大列数 - Integer num = 1; - - matterDeduplicateService.remove(Wrappers.lambdaQuery(KqZzsfwMattersDeduplicate.class)); - - for (int i = 2; i < rownum; i++) { - row = sheet.getRow(i); - if(row.getZeroHeight()){ - continue; - } - System.out.println("记数:" + (num++)); - System.out.println(row.getCell(0).getStringCellValue()); - System.out.println(row.getCell(1).getStringCellValue()); - Double numericCellValue = row.getCell(2).getNumericCellValue(); - - KqZzsfwMattersDeduplicate menu = new KqZzsfwMattersDeduplicate(); - menu.setWebapplyurl(row.getCell(1).getStringCellValue()); - menu.setQlName(row.getCell(0).getStringCellValue()); - menu.setCreateOn(LocalDateTime.now()); - menu.setCountNum(numericCellValue.intValue()); - - matterDeduplicateService.save(menu); - } - } - } - - @Test - public void syncUrl(){ - List menus = menuService.list(Wrappers.lambdaQuery(KqZzsfwMenu.class)); - - List list = matterDeduplicateService.list(); - - Set qlSet = Sets.newTreeSet(); - Map map = list.stream().filter(q -> qlSet.add(q.getQlName())) - .filter(q -> StringUtils.isNotBlank(q.getWebapplyurl()) && StringUtils.isNotBlank(q.getQlName())) - .collect(Collectors.toMap(q -> q.getQlName(), q -> q.getWebapplyurl())); - - for(KqZzsfwMenu menu : menus){ - String itemName = menu.getItemName(); - if(map.containsKey(itemName)){ - String url = map.get(itemName); - menu.setWebapplyurl(url); - menu.setHasUrl(1); - menuService.updateById(menu); - } - } - } -} diff --git a/kqapi/src/test/java/com/ningdatech/kqapi/menu/ExcelSplitMergedCells.java b/kqapi/src/test/java/com/ningdatech/kqapi/menu/ExcelSplitMergedCells.java deleted file mode 100644 index bb3731f..0000000 --- a/kqapi/src/test/java/com/ningdatech/kqapi/menu/ExcelSplitMergedCells.java +++ /dev/null @@ -1,60 +0,0 @@ -package com.ningdatech.kqapi.menu; - -import org.apache.poi.ss.usermodel.*; -import org.apache.poi.ss.util.CellRangeAddress; -import org.apache.poi.xssf.usermodel.XSSFWorkbook; - -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; - -public class ExcelSplitMergedCells { - public static void main(String[] args) throws IOException { - // 打开Excel文件 - FileInputStream fis = new FileInputStream("C:\\Users\\PoffyZhang\\Desktop\\8.8柯桥区企业综合服务中心政务服务事项清单.xlsx"); - Workbook workbook = new XSSFWorkbook(fis); - Sheet sheet = workbook.getSheetAt(0); - - // 获取合并单元格的范围 - CellRangeAddress mergedRegion = sheet.getMergedRegion(0); // 0表示第一个合并的单元格 - int firstRow = mergedRegion.getFirstRow(); - int lastRow = mergedRegion.getLastRow(); - int firstCol = mergedRegion.getFirstColumn(); - int lastCol = mergedRegion.getLastColumn(); - - // 取消合并单元格 - sheet.removeMergedRegion(0); - Integer num = 0; - // 创建新的单元格并复制内容 - for (int i = firstRow; i <= lastRow; i++) { - Row row = sheet.getRow(i); - for (int j = firstCol; j <= lastCol; j++) { - Cell oldCell = row.getCell(j); - Cell newCell = row.createCell(j); - newCell.setCellType(oldCell.getCellType()); - switch (oldCell.getCellType()) { - case STRING: - newCell.setCellValue(oldCell.getStringCellValue()); - break; - case NUMERIC: - newCell.setCellValue(oldCell.getNumericCellValue()); - break; - case BOOLEAN: - newCell.setCellValue(oldCell.getBooleanCellValue()); - break; - case FORMULA: - newCell.setCellFormula(oldCell.getCellFormula()); - break; - default: - newCell.setCellValue(""); - } - } - } - - // 保存修改后的Excel文件 - fis.close(); - FileOutputStream fos = new FileOutputStream("C:\\Users\\PoffyZhang\\Desktop\\8.8柯桥区企业综合服务中心政务服务事项清单2.xlsx"); - workbook.write(fos); - fos.close(); - } -} \ No newline at end of file diff --git a/kqapi/src/test/java/com/ningdatech/kqapi/menu/MenuTest.java b/kqapi/src/test/java/com/ningdatech/kqapi/menu/MenuTest.java deleted file mode 100644 index 89ec354..0000000 --- a/kqapi/src/test/java/com/ningdatech/kqapi/menu/MenuTest.java +++ /dev/null @@ -1,187 +0,0 @@ -package com.ningdatech.kqapi.menu; - -import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import com.ningdatech.kqapi.AppTests; -import com.ningdatech.kqapi.zzsfw.model.entity.KqZzsfwMenu; -import com.ningdatech.kqapi.zzsfw.enumeration.ItemTypeEnum; -import com.ningdatech.kqapi.zzsfw.service.IKqZzsfwMenuService; -import org.apache.poi.ss.usermodel.*; -import org.apache.poi.xssf.usermodel.XSSFWorkbook; -import org.junit.Assert; -import org.junit.Test; -import org.springframework.beans.factory.annotation.Autowired; -import java.io.FileInputStream; -import java.io.IOException; -import java.sql.Connection; -import java.sql.DriverManager; -import java.sql.Statement; -import java.text.DecimalFormat; -import java.time.LocalDateTime; - -/** - * @Classname MenuTest - * @Description - * @Date 2023/10/27 9:51 - * @Author PoffyZhang - */ -public class MenuTest extends AppTests{ // - - @Autowired - private IKqZzsfwMenuService menuService; - - @Test - public void test() throws IOException { - FileInputStream fis = new FileInputStream("C:\\Users\\PoffyZhang\\Desktop\\11.14柯桥.xlsx"); - Workbook workbook = new XSSFWorkbook(fis); - Assert.assertNotNull(workbook); - Row row; - if (workbook != null) { - //获取最大行数 - Sheet sheet = workbook.getSheetAt(0); - int rownum = sheet.getPhysicalNumberOfRows(); - //获取第一行 - row = sheet.getRow(0); - //获取最大列数 - Integer num = 1; - - menuService.remove(Wrappers.lambdaQuery(KqZzsfwMenu.class)); - - for (int i = 2; i < rownum; i++) { - row = sheet.getRow(i); - if(row.getZeroHeight()){ - continue; - } - System.out.println("记数:" + (num++)); - System.out.println(row.getCell(0).getStringCellValue()); - System.out.println(row.getCell(1).getStringCellValue()); - System.out.println(row.getCell(2).getStringCellValue()); - Double numericCellValue = row.getCell(3).getNumericCellValue(); - String itemName = row.getCell(4).getStringCellValue(); - System.out.println(itemName); - - KqZzsfwMenu menu = new KqZzsfwMenu(); - menu.setItemName(itemName); - menu.setZoneName(row.getCell(0).getStringCellValue()); - menu.setWindow(row.getCell(1).getStringCellValue()); - menu.setCreateOn(LocalDateTime.now()); - menu.setDepartment(row.getCell(2).getStringCellValue()); - menu.setSort(numericCellValue.intValue()); - - //去查询 url -// DscSxAdsShareItemQltQlsxCommonIDVKq item = itemQltQlsxCommonIDVKqService.getOne(Wrappers.lambdaQuery(DscSxAdsShareItemQltQlsxCommonIDVKq.class) -// .select(DscSxAdsShareItemQltQlsxCommonIDVKq::getRowguid, DscSxAdsShareItemQltQlsxCommonIDVKq::getWebapplyurl, DscSxAdsShareItemQltQlsxCommonIDVKq::getQlName) -// .eq(DscSxAdsShareItemQltQlsxCommonIDVKq::getQlName, itemName) -// .isNotNull(DscSxAdsShareItemQltQlsxCommonIDVKq::getWebapplyurl) -// .last("limit 1")); -// if(Objects.nonNull(item)){ - menu.setHasUrl(1); -// menu.setWebapplyurl(item.getWebapplyurl()); -// menu.setItemRowid(item.getRowguid()); -// } - - menuService.save(menu); - } - } - } - - - @Test - public void importData() throws IOException { - FileInputStream fis = new FileInputStream("C:\\Users\\PoffyZhang\\Desktop\\增值服务数据20240403.xlsx"); - Workbook workbook = new XSSFWorkbook(fis); - Assert.assertNotNull(workbook); - Row row; - if (workbook != null) { - //获取最大行数 - Sheet sheet = workbook.getSheetAt(0); - int rownum = sheet.getPhysicalNumberOfRows(); - //获取第一行 - row = sheet.getRow(0); - //获取最大列数 - Integer num = 1; - - for (int i = 2; i < rownum; i++) { - row = sheet.getRow(i); - if (row.getZeroHeight()) { - continue; - } - System.out.println("记数:" + (num++)); - String zoneName = row.getCell(0).getStringCellValue(); - System.out.println(zoneName); - DecimalFormat decimalFormat = new DecimalFormat("#"); - Integer sort = Integer.valueOf(decimalFormat.format(row.getCell(1).getNumericCellValue())); - System.out.println(sort); - String windowName = row.getCell(2).getStringCellValue(); - System.out.println(windowName); - String department = row.getCell(3).getStringCellValue(); - System.out.println(department); - String itemName = row.getCell(4).getStringCellValue(); - System.out.println(itemName); - String serviceContent = row.getCell(5).getStringCellValue(); - System.out.println(serviceContent); - String serviceProcess = row.getCell(6).getStringCellValue(); - System.out.println(serviceProcess); - String telephone = ""; - CellType cellType = row.getCell(7).getCellType(); - if(cellType.equals(CellType.STRING)){ - telephone = row.getCell(7).getStringCellValue(); - System.out.println(telephone); - }else if(cellType.equals(CellType.NUMERIC)){ - DecimalFormat decimalFormat2 = new DecimalFormat("#.#######"); - telephone = decimalFormat2.format(row.getCell(7).getNumericCellValue()); - System.out.println(telephone); - } - KqZzsfwMenu menu = new KqZzsfwMenu(); - menu.setItemName(itemName); - menu.setZoneName(zoneName); - menu.setWindow(windowName); - menu.setDepartment(department); - menu.setServiceContent(serviceContent); - menu.setServiceProcess(serviceProcess); - menu.setTelephone(telephone); - menu.setType(ItemTypeEnum.ADDED.getCode()); - menu.setCreateOn(LocalDateTime.now()); - menu.setSort(sort); -// menuService.save(menu); - } - } - - } - - - @Test - public void tableAndColumn() throws IOException { - String url = "jdbc:mysql://47.98.125.47:3306/kqzzsfw?serverTimezone=Asia/Shanghai&characterEncoding=utf8&allowPublicKeyRetrieval=true&useSSL=false"; // 你的数据库URL - String username = "root"; // 数据库用户名 - String password = "NingdaKeji123!"; // 数据库密码 - - String table = "nd_kq_zzsfw_menu"; - - try { - // 1. 加载数据库驱动 - Class.forName("com.mysql.cj.jdbc.Driver"); - - // 2. 建立数据库连接 - Connection connection = DriverManager.getConnection(url, username, password); - - // 3. 创建Statement对象 - Statement statement = connection.createStatement(); - - // 4. 编写并执行DDL语句(创建一个名为`users`的表) -// String createTableUsers = "alter table nd_kq_zzsfw_menu add column type tinyint default 1 comment '类型 1.政府服务 2.增值服务 3.特殊'"; -// String createTableUsers = "alter table nd_kq_zzsfw_menu add column service_content text comment '服务内容';"; -// String createTableUsers = "alter table nd_kq_zzsfw_menu add column service_process text comment '服务流程';"; - String createTableUsers = "alter table nd_kq_zzsfw_menu add column telephone text comment '咨询电话'"; - statement.executeUpdate(createTableUsers); - - System.out.println(" Table '" + table + "' updated successfully."); - - // 5. 关闭资源 - statement.close(); - connection.close(); - - } catch (Exception e) { - e.printStackTrace(); - } - } -} diff --git a/kqapi/src/test/java/com/ningdatech/kqapi/menu/PolicyTest.java b/kqapi/src/test/java/com/ningdatech/kqapi/menu/PolicyTest.java deleted file mode 100644 index cb128b6..0000000 --- a/kqapi/src/test/java/com/ningdatech/kqapi/menu/PolicyTest.java +++ /dev/null @@ -1,85 +0,0 @@ -package com.ningdatech.kqapi.menu; - -import cn.hutool.core.date.DateUtil; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import com.ningdatech.kqapi.AppTests; -import com.ningdatech.kqapi.zzsfw.model.entity.KqZzsfwPolicy; -import com.ningdatech.kqapi.zzsfw.service.IKqZzsfwPolicyService; -import org.apache.poi.ss.usermodel.Row; -import org.apache.poi.ss.usermodel.Sheet; -import org.apache.poi.ss.usermodel.Workbook; -import org.apache.poi.xssf.usermodel.XSSFWorkbook; -import org.junit.Assert; -import org.junit.Test; -import org.springframework.beans.factory.annotation.Autowired; - -import java.io.FileInputStream; -import java.io.IOException; -import java.time.LocalDateTime; -import java.util.Objects; - -/** - * @Classname MenuTest - * @Description - * @Date 2023/10/27 9:51 - * @Author PoffyZhang - */ -public class PolicyTest extends AppTests { - - @Autowired - private IKqZzsfwPolicyService policyService; - - @Test - public void test() throws IOException { - FileInputStream fis = new FileInputStream("C:\\Users\\PoffyZhang\\Desktop\\政策条例摘录.xlsx"); - Workbook workbook = new XSSFWorkbook(fis); - Assert.assertNotNull(workbook); - Row row; - - policyService.remove(Wrappers.lambdaQuery(KqZzsfwPolicy.class)); - - if (workbook != null) { - //获取最大行数 - Sheet sheet = workbook.getSheetAt(0); - int rownum = sheet.getPhysicalNumberOfRows(); - //获取第一行 - row = sheet.getRow(0); - //获取最大列数 - Integer sort = 1; - for (int i = 2; i < rownum; i++) { - row = sheet.getRow(i); - if(row.getZeroHeight()){ - continue; - } - - String header = Objects.nonNull(row.getCell(0)) ? row.getCell(0).getStringCellValue() : null; - String title = Objects.nonNull(row.getCell(1)) ? row.getCell(1).getStringCellValue() : null; - String secondTitle = Objects.nonNull(row.getCell(2)) ? row.getCell(2).getStringCellValue() : null; - String regionName = Objects.nonNull(row.getCell(3)) ? row.getCell(3).getStringCellValue() : null; - String department = Objects.nonNull(row.getCell(4)) ? row.getCell(4).getStringCellValue() : null; - String issueDate = Objects.nonNull(row.getCell(5)) ? DateUtil.format(row.getCell(5).getDateCellValue(),"yyyy/MM/dd") : null; - String status = Objects.nonNull(row.getCell(7)) ? row.getCell(7).getStringCellValue() : null; - String applyTime = Objects.nonNull(row.getCell(8)) ? row.getCell(8).getStringCellValue() : null; - String url = Objects.nonNull(row.getCell(9)) ? row.getCell(9).getStringCellValue() : null; - - KqZzsfwPolicy policy = new KqZzsfwPolicy(); - policy.setHeader(header); - policy.setTitle(title); - policy.setSecondTitle(secondTitle); - policy.setRegionName(regionName); - policy.setDepartment(department); - policy.setIssueDate(issueDate); - policy.setStatus(status); - policy.setApplyTime(applyTime); - policy.setOnlineConsultationUrl(url); - policy.setCreateOn(LocalDateTime.now()); - policy.setSort(sort); - - policyService.save(policy); - - System.out.println("记数:" + (sort++)); - } - } - } - -} diff --git a/kqapi/src/test/resources/application-dev.yml b/kqapi/src/test/resources/application-dev.yml deleted file mode 100644 index 0bb9896..0000000 --- a/kqapi/src/test/resources/application-dev.yml +++ /dev/null @@ -1,123 +0,0 @@ -server: - port: 33060 - servlet: - context-path: /kq - -spring: - mvc: - pathmatch: - matching-strategy: ant_path_matcher - session: - store-type: redis - redis: - namespace: "spring:session" - timeout: 864000 - redis: - timeout: 5000 - host: 47.98.125.47 - port: 26379 - database: 7 - password: Ndkj1234 - jedis: - pool: - max-active: 200 - max-idle: 500 - min-idle: 8 - max-wait: 10000 - application: - name: kq - jackson: - default-property-inclusion: non_null - time-zone: GMT+8 - date-format: yyyy-MM-dd HH:mm:ss - jpa: - properties: - hibernate: - default_schema: PUBLIC - hbm2ddl: - auto: update - show_sql: true - show-sql: true - hibernate: - ddl-auto: update - datasource: - type: com.zaxxer.hikari.HikariDataSource - driver-class-name: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://47.98.125.47:3306/kqzzsfw?serverTimezone=Asia/Shanghai&characterEncoding=utf8&allowPublicKeyRetrieval=true&useSSL=false - username: root - password: NingdaKeji123! - # 数据源 - hikari: - # 是客户端等待连接池连接的最大毫秒数 - connection-timeout: 30000 - # 是允许连接在连接池中空闲的最长时间 - minimum-idle: 5 - # 配置最大池大小 - maximum-pool-size: 300 - # 是允许连接在连接池中空闲的最长时间(以毫秒为单位) - idle-timeout: 60000 - # 池中连接关闭后的最长生命周期(以毫秒为单位) - max-lifetime: 600000 - # 配置从池返回的连接的默认自动提交行为。默认值为true。 - auto-commit: true - # 开启连接监测泄露 - leak-detection-threshold: 10000 - # 测试连接数据库 - connection-test-query: SELECT 1 - #设置上传 单个文件的大小 - servlet: - multipart: - max-file-size: 100MB - max-request-size: 150MB -mybatis-plus: - configuration: - log-impl: org.apache.ibatis.logging.stdout.StdOutImpl - global-config: - db-config: - logic-delete-value: true - logic-not-delete-value: false -logging: - config: classpath:logback-spring.xml - #日志配置 - level: - root: info - file: - path: logs -nd: - cache: - type: REDIS - serializerType: ProtoStuff - cacheNullVal: true - def: - keyPrefix: kq - log: - enabled: true - type: DB - # 文件存储 - file: - storage-type: ALI_OSS - ali: - protocol: https:// - bucket: devplat - urlPrefix: oss-cn-hangzhou.aliyuncs.com - endpoint: oss-cn-hangzhou.aliyuncs.com - accessKeyId: LTAI4GL7uypycnBjiRn55rMG - accessKeySecret: qwYC7bW9bkStsko7qkLVnToAzj0Y98 -# 日志文件配置 -log: - path: ./logs - info: - file-size: 50MB - max-size: 5 - total-size: 200MB - error: - file-size: 10MB - max-size: 5 - total-size: 50MB - -swagger: - enabled: true - -hostname: iZbp13nwyvib53j4j1p2xoZ - - diff --git a/kqapi/src/test/resources/application-pre.yml b/kqapi/src/test/resources/application-pre.yml deleted file mode 100644 index 908d625..0000000 --- a/kqapi/src/test/resources/application-pre.yml +++ /dev/null @@ -1,121 +0,0 @@ -server: - port: 33060 - servlet: - context-path: /kq - -spring: - mvc: - pathmatch: - matching-strategy: ant_path_matcher - session: - store-type: redis - redis: - namespace: "spring:session" - timeout: 864000 - redis: - timeout: 5000 - host: 47.98.125.47 - port: 26379 - database: 7 - password: Ndkj1234 - jedis: - pool: - max-active: 200 - max-idle: 500 - min-idle: 8 - max-wait: 10000 - application: - name: kq - jackson: - default-property-inclusion: non_null - time-zone: GMT+8 - date-format: yyyy-MM-dd HH:mm:ss - jpa: - properties: - hibernate: - default_schema: PUBLIC - hbm2ddl: - auto: update - show_sql: true - show-sql: true - hibernate: - ddl-auto: update - datasource: - type: com.zaxxer.hikari.HikariDataSource - driver-class-name: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://47.98.125.47:3306/kqzzsfw?serverTimezone=Asia/Shanghai&characterEncoding=utf8&allowPublicKeyRetrieval=true&useSSL=false - username: root - password: NingdaKeji123! - # 数据源 - hikari: - # 是客户端等待连接池连接的最大毫秒数 - connection-timeout: 30000 - # 是允许连接在连接池中空闲的最长时间 - minimum-idle: 5 - # 配置最大池大小 - maximum-pool-size: 300 - # 是允许连接在连接池中空闲的最长时间(以毫秒为单位) - idle-timeout: 60000 - # 池中连接关闭后的最长生命周期(以毫秒为单位) - max-lifetime: 600000 - # 配置从池返回的连接的默认自动提交行为。默认值为true。 - auto-commit: true - # 开启连接监测泄露 - leak-detection-threshold: 5000 - # 测试连接数据库 - connection-test-query: SELECT 1 - #设置上传 单个文件的大小 - servlet: - multipart: - max-file-size: 100MB - max-request-size: 150MB -mybatis-plus: - configuration: - log-impl: org.apache.ibatis.logging.stdout.StdOutImpl - global-config: - db-config: - logic-delete-value: true - logic-not-delete-value: false -logging: - config: classpath:logback-spring.xml - #日志配置 - level: - root: info - file: - path: logs -nd: - cache: - type: REDIS - serializerType: ProtoStuff - cacheNullVal: true - def: - keyPrefix: kq - log: - enabled: true - type: DB - # 文件存储 - file: - storage-type: ALI_OSS - ali: - protocol: https:// - bucket: devplat - urlPrefix: oss-cn-hangzhou.aliyuncs.com - endpoint: oss-cn-hangzhou.aliyuncs.com - accessKeyId: LTAI4GL7uypycnBjiRn55rMG - accessKeySecret: qwYC7bW9bkStsko7qkLVnToAzj0Y98 -# 日志文件配置 -log: - path: ./logs - info: - file-size: 50MB - max-size: 5 - total-size: 200MB - error: - file-size: 10MB - max-size: 5 - total-size: 50MB - -swagger: - enabled: true - -hostname: iZbp13nwyvib53j4j1p2xoZ \ No newline at end of file diff --git a/kqapi/src/test/resources/application-prod.yml b/kqapi/src/test/resources/application-prod.yml deleted file mode 100644 index 68d6de2..0000000 --- a/kqapi/src/test/resources/application-prod.yml +++ /dev/null @@ -1,123 +0,0 @@ -server: - port: 33060 - servlet: - context-path: /kq - -spring: - mvc: - pathmatch: - matching-strategy: ant_path_matcher - session: - store-type: redis - redis: - namespace: "spring:session" - timeout: 864000 - redis: - timeout: 5000 - host: 47.98.125.47 - port: 26379 - database: 7 - password: Ndkj1234 - jedis: - pool: - max-active: 200 - max-idle: 500 - min-idle: 8 - max-wait: 10000 - application: - name: kq - jackson: - default-property-inclusion: non_null - time-zone: GMT+8 - date-format: yyyy-MM-dd HH:mm:ss - jpa: - properties: - hibernate: - default_schema: PUBLIC - hbm2ddl: - auto: update - show_sql: true - show-sql: true - hibernate: - ddl-auto: update - datasource: - type: com.zaxxer.hikari.HikariDataSource - driver-class-name: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://10.42.248.27:3306/kqzzsfw?serverTimezone=Asia/Shanghai&characterEncoding=utf8&allowPublicKeyRetrieval=true&useSSL=false - username: root - password: Nd@20231116 - # 数据源 - hikari: - # 是客户端等待连接池连接的最大毫秒数 - connection-timeout: 30000 - # 是允许连接在连接池中空闲的最长时间 - minimum-idle: 5 - # 配置最大池大小 - maximum-pool-size: 300 - # 是允许连接在连接池中空闲的最长时间(以毫秒为单位) - idle-timeout: 60000 - # 池中连接关闭后的最长生命周期(以毫秒为单位) - max-lifetime: 600000 - # 配置从池返回的连接的默认自动提交行为。默认值为true。 - auto-commit: true - # 开启连接监测泄露 - leak-detection-threshold: 500000 - # 测试连接数据库 - connection-test-query: SELECT 1 - #设置上传 单个文件的大小 - servlet: - multipart: - max-file-size: 100MB - max-request-size: 150MB -mybatis-plus: - configuration: - log-impl: org.apache.ibatis.logging.stdout.StdOutImpl - global-config: - db-config: - logic-delete-value: true - logic-not-delete-value: false -logging: - config: classpath:logback-spring.xml - #日志配置 - level: - root: info - file: - path: logs -nd: - cache: - type: REDIS - serializerType: ProtoStuff - cacheNullVal: true - def: - keyPrefix: kq - log: - enabled: true - type: DB - # 文件存储 - file: - storage-type: ALI_OSS - ali: - protocol: https:// - bucket: devplat - urlPrefix: oss-cn-hangzhou.aliyuncs.com - endpoint: oss-cn-hangzhou.aliyuncs.com - accessKeyId: LTAI4GL7uypycnBjiRn55rMG - accessKeySecret: qwYC7bW9bkStsko7qkLVnToAzj0Y98 -# 日志文件配置 -log: - path: ./logs - info: - file-size: 50MB - max-size: 5 - total-size: 200MB - error: - file-size: 10MB - max-size: 5 - total-size: 50MB - -swagger: - enabled: true - -hostname: iZut201mqskxt0mwme4tjfZ - - diff --git a/kqapi/src/test/resources/application.yml b/kqapi/src/test/resources/application.yml deleted file mode 100644 index 9f96606..0000000 --- a/kqapi/src/test/resources/application.yml +++ /dev/null @@ -1,3 +0,0 @@ -spring: - profiles: - active: prod diff --git a/kqapi/src/test/resources/integration/zwdd-dev.yml b/kqapi/src/test/resources/integration/zwdd-dev.yml deleted file mode 100644 index cc28814..0000000 --- a/kqapi/src/test/resources/integration/zwdd-dev.yml +++ /dev/null @@ -1,12 +0,0 @@ -#专有钉钉 -integration: - zwdd: - #扫码 - app-auth-key: ls-rebuild_dingoa-rgeWs3YVr26z - app-auth-secret: 37qCe6ylNMW0N8K2741z0c2b9vJP2gtuMRQQtZ9P - #免登/获取信息 - app-key: ls_rebuild-10c8n5X0707yFV7jURr - app-secret: gN8J3WazyXLMWKDuFmx6C4yaH5lFUY41x8rYLLo6 - #专有钉钉在开发管理工作台,右键查看网页源码realmId: '31141',浙政钉固定196729 - tenantId: 31141 - domain: openplatform.dg-work.cn \ No newline at end of file diff --git a/kqapi/src/test/resources/integration/zwdd-prod.yml b/kqapi/src/test/resources/integration/zwdd-prod.yml deleted file mode 100644 index 6b30e1b..0000000 --- a/kqapi/src/test/resources/integration/zwdd-prod.yml +++ /dev/null @@ -1,12 +0,0 @@ -#浙政钉 -integration: - zwdd: - #扫码 - app-auth-key: ls_project_managment_din-b1Y3I1g7Rr94yX76KfFkpp18Uy4WHtU0b6rINJ3 - app-auth-secret: 75e8PMHv984KYF0Mcy6v4pxt480y73dbD7kB65dD - #免登/获取信息 - app-key: ls_project-c32LNu87v60UiANZVja - app-secret: R14QgbBr21751LTGml3Vt8oX9doPl4Lk1ROzZNfG - #专有钉钉在开发管理工作台,右键查看网页源码realmId: '31141',浙政钉固定196729 - tenantId: 196729 - domain: openplatform-pro.ding.zj.gov.cn \ No newline at end of file diff --git a/kqapi/src/test/resources/logback-spring.xml b/kqapi/src/test/resources/logback-spring.xml deleted file mode 100644 index 75f5472..0000000 --- a/kqapi/src/test/resources/logback-spring.xml +++ /dev/null @@ -1,68 +0,0 @@ - - - - - - - - - - - ${logPath}/info.log - - ${logPath}/info-%d{yyyyMMdd}-%i.log - - ${infoFileSize} - - ${infoMaxSize} - ${infoTotalSize} - - - - %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} -%msg%n - - - UTF-8 - - - - - - ERROR - - ${logPath}/error.log - - ${logPath}/error-%d{yyyyMMdd}-%i.log - - ${errorFileSize} - - ${errorMaxSize} - ${errorTotalSize} - - - - %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} -%msg%n - - - UTF-8 - - - - - - - %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} -%msg%n - - UTF-8 - - - DEBUG - - - - - - - - - diff --git a/kqapi/src/test/resources/security/auth-dev.yml b/kqapi/src/test/resources/security/auth-dev.yml deleted file mode 100644 index 53ec385..0000000 --- a/kqapi/src/test/resources/security/auth-dev.yml +++ /dev/null @@ -1,68 +0,0 @@ -security: - auth: - auth-require-url: /api/v1/user/auth/auth-require - invalid-session-url: /api/v1/user/auth/invalid-session - password-login-url: /api/v1/user/auth/login - agent-login-url: /api/v1/user/auth/agent-login - logout-url: /api/v1/user/auth/logout - common-login-url: /api/v1/user/auth/common-login - ignore-auth-urls: - - /v2/api-docs - - /swagger-ui.html - - /webjars/** - - /swagger-resources/** - - /webjars/ - - /api/v1/user/auth/register - - /api/v1/user/auth/auth-require - - /api/v1/user/auth/invalid-session - - /api/v1/user/auth/login/password - - /api/v1/user/auth/forget-password - - /api/v1/user/auth/common-login - - /doc.html - - /ok.html - - /open/api/** - - /oa/** - - /wflow/** - - /sys/** - - /api/v1/verification/** - - /api/v1/expert/registration - - /api/v1/meta/dictionary/list - - /api/v1/meta/tag - - /api/v1/organization/tree-list - - /api/v1/organization/get-child-list - - /api/v1/region/tree - ignore-csrf-urls: - - /api/v1/user/auth/** - - /v2/api-docs - - /swagger-ui.html - - /webjars/** - - /swagger-resources/** - - /webjars/ - - /doc.html - - /ok.html - - /api/v1/** - - /file/** - - /optLog/** - - /dict/** - - /oa/** - - /wflow/** - - /sys/** - - /api/v1/verification/** - - /api/v1/expert/registration - - /api/v1/meta/dictionary/list - - /api/v1/meta/tag - - /api/v1/organization/tree-list - - /api/v1/organization/get-child-list - - /api/v1/region/tree - role-map: - "engineer": - "project_manager": - - /api/v1/user-info/kick-off/** - "enterprise_admin": - "regional_general_manager": - "driver": - "super_admin": - - /api/v1/user-info/save - - /api/v1/user-info/del - - /api/v1/user-info/kick-off/** - - /api/v1/user-info/password/mod \ No newline at end of file diff --git a/kqapi/src/test/resources/security/auth-prod.yml b/kqapi/src/test/resources/security/auth-prod.yml deleted file mode 100644 index 53ec385..0000000 --- a/kqapi/src/test/resources/security/auth-prod.yml +++ /dev/null @@ -1,68 +0,0 @@ -security: - auth: - auth-require-url: /api/v1/user/auth/auth-require - invalid-session-url: /api/v1/user/auth/invalid-session - password-login-url: /api/v1/user/auth/login - agent-login-url: /api/v1/user/auth/agent-login - logout-url: /api/v1/user/auth/logout - common-login-url: /api/v1/user/auth/common-login - ignore-auth-urls: - - /v2/api-docs - - /swagger-ui.html - - /webjars/** - - /swagger-resources/** - - /webjars/ - - /api/v1/user/auth/register - - /api/v1/user/auth/auth-require - - /api/v1/user/auth/invalid-session - - /api/v1/user/auth/login/password - - /api/v1/user/auth/forget-password - - /api/v1/user/auth/common-login - - /doc.html - - /ok.html - - /open/api/** - - /oa/** - - /wflow/** - - /sys/** - - /api/v1/verification/** - - /api/v1/expert/registration - - /api/v1/meta/dictionary/list - - /api/v1/meta/tag - - /api/v1/organization/tree-list - - /api/v1/organization/get-child-list - - /api/v1/region/tree - ignore-csrf-urls: - - /api/v1/user/auth/** - - /v2/api-docs - - /swagger-ui.html - - /webjars/** - - /swagger-resources/** - - /webjars/ - - /doc.html - - /ok.html - - /api/v1/** - - /file/** - - /optLog/** - - /dict/** - - /oa/** - - /wflow/** - - /sys/** - - /api/v1/verification/** - - /api/v1/expert/registration - - /api/v1/meta/dictionary/list - - /api/v1/meta/tag - - /api/v1/organization/tree-list - - /api/v1/organization/get-child-list - - /api/v1/region/tree - role-map: - "engineer": - "project_manager": - - /api/v1/user-info/kick-off/** - "enterprise_admin": - "regional_general_manager": - "driver": - "super_admin": - - /api/v1/user-info/save - - /api/v1/user-info/del - - /api/v1/user-info/kick-off/** - - /api/v1/user-info/password/mod \ No newline at end of file diff --git a/kqapi/src/test/resources/wsdl-prod.xml b/kqapi/src/test/resources/wsdl-prod.xml deleted file mode 100644 index 0302851..0000000 --- a/kqapi/src/test/resources/wsdl-prod.xml +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/kqapi/src/test/resources/wsdl.xml b/kqapi/src/test/resources/wsdl.xml deleted file mode 100644 index eed87a7..0000000 --- a/kqapi/src/test/resources/wsdl.xml +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/ningda-generator/pom.xml b/ningda-generator/pom.xml deleted file mode 100644 index 2bdf023..0000000 --- a/ningda-generator/pom.xml +++ /dev/null @@ -1,60 +0,0 @@ - - - - kq-value-added-project - com.ningdatech - 1.0.0 - - 4.0.0 - - ningda-generator - - - - com.baomidou - mybatis-plus-boot-starter - - - - com.baomidou - mybatis-plus-generator - ${mybatis.plus.version} - - - - org.freemarker - freemarker - - - - - mysql - mysql-connector-java - - - - - org.apache.directory.studio - org.apache.commons.codec - 1.8 - - - junit - junit - 4.12 - test - - - - org.springframework.boot - spring-boot-starter-test - - - - org.springframework.boot - spring-boot-starter-test - - - diff --git a/ningda-generator/src/main/java/com/ningdatech/generator/config/CodeGen.java b/ningda-generator/src/main/java/com/ningdatech/generator/config/CodeGen.java deleted file mode 100644 index 9217cd5..0000000 --- a/ningda-generator/src/main/java/com/ningdatech/generator/config/CodeGen.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.ningdatech.generator.config; - -import com.baomidou.mybatisplus.generator.FastAutoGenerator; -import com.baomidou.mybatisplus.generator.config.OutputFile; -import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine; - -import java.util.Collections; - -/** - * @description: 自动生成code代码 - * @author: zpf - * @date: 2023/01/03 09:20 - */ -public class CodeGen { - - private static final String PATH_LXX = "/Users/liuxinxin/IdeaProjects/project-management/pmapi/src/main/java"; - private static final String PATH_YYD = "/Users/wendy/coding/java/kq-value-added-project/kqapi/src/main/java"; - private static final String PATH_LS = ""; - private static final String PATH_ZPF = "D:\\ningda\\kq-value-added-project\\kqapi\\src\\main\\java"; - private static final String PATH_CMM = "D:\\work\\project-management\\project-management\\pmapi\\src\\main\\java"; - - private static final String URL = "jdbc:mysql://47.98.125.47:3306/kqzzsfw?serverTimezone=Asia/Shanghai&characterEncoding=utf8&allowPublicKeyRetrieval=true&useSSL=false"; - private static final String USER_NAME = "root"; - private static final String PASSWORD = "NingdaKeji123!"; - - private static void generate(String author, String packageName, String path, String... tableNames) { - FastAutoGenerator.create(URL, USER_NAME, PASSWORD) - .globalConfig(builder -> { - // 设置作者 - builder.author(author) - // 开启 swagger 模式 - .enableSwagger() - // 覆盖已生成文件 - .fileOverride() - // 指定输出目录 - .outputDir(path); - }) - .packageConfig(builder -> { - // 设置父包名 - builder.parent("com.ningdatech") - // 设置父包模块名 - .moduleName("kqapi." + packageName) - // 设置mapperXml生成路径 - .pathInfo(Collections.singletonMap(OutputFile.mapperXml, - //设置自己的生成路径 - path + "/com/ningdatech/kqapi/" + packageName + "/mapper")); - }) - .strategyConfig(builder -> { - builder.addTablePrefix("nd"); - // 设置需要生成的表名 - builder.addInclude(tableNames); - }) - // 使用Freemarker引擎模板,默认的是Velocity引擎模板 - .templateEngine(new FreemarkerTemplateEngine()) - .execute(); - } - - public static void main(String[] args) { - // generate("Liuxinxin", "expert", PATH_LXX, "expert_gov_business_strip"); - // generate("ZPF", "zzsfw", PATH_ZPF, "nd_kq_zzsfw_menu"); - generate("WendyYang", "admin", PATH_YYD, "nd_window","nd_zone"); - } - -} diff --git a/pom.xml b/pom.xml index 680e0a9..edb5c57 100644 --- a/pom.xml +++ b/pom.xml @@ -145,7 +145,7 @@ - kqapi - ningda-generator + kq-api + kq-gen