├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.md │ ├── custom.md │ └── feature_request.md └── workflows │ └── main.yml ├── .gitignore ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── doc ├── file │ ├── common.yaml │ ├── db1.yaml │ ├── feignhystrix.yaml │ ├── mail.yaml │ ├── mybatis.yaml │ ├── oauth2db.yaml │ ├── oauth_token.yaml │ ├── redis.yaml │ └── zipkindb.yaml ├── img │ ├── access_token.JPG │ ├── auth.JPG │ ├── code.JPG │ ├── oauthLogin.JPG │ ├── swagger.png │ └── token.JPG └── sql │ ├── demo │ └── sys_logistics.sql │ ├── log │ └── loginfo.sql │ ├── sso │ ├── oauth.sql │ └── user.sql │ └── zipkin │ └── zipkin-init.sql ├── javayh-demo ├── javayh-demo-api │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── javayh │ │ │ └── api │ │ │ ├── ApiApplication.java │ │ │ ├── conf │ │ │ └── ResourceServerConfiguration.java │ │ │ ├── sys │ │ │ ├── controller │ │ │ │ └── SysLogisticsController.java │ │ │ ├── dao │ │ │ │ └── SysLogisticsMapper.java │ │ │ ├── pojo │ │ │ │ ├── SysLogistics.java │ │ │ │ └── dto │ │ │ │ │ └── SysLogisticsDTO.java │ │ │ └── service │ │ │ │ ├── ISysLogisticsService.java │ │ │ │ └── impl │ │ │ │ └── SysLogisticsServiceImpl.java │ │ │ └── web │ │ │ └── ApiController.java │ │ └── resources │ │ ├── bootstrap.yml │ │ └── mapper │ │ └── sys │ │ └── SysLogisticsMapper.xml ├── javayh-demo-common │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── javayh │ │ │ └── demo │ │ │ ├── DemoApplication.java │ │ │ ├── service │ │ │ ├── DemoFallback.java │ │ │ └── DemoService.java │ │ │ └── web │ │ │ ├── Demo2Controller.java │ │ │ └── DemoCtroller.java │ │ └── resources │ │ └── bootstrap.yml ├── javayh-demo-config │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── javayh │ │ │ └── config │ │ │ ├── ConfigApplication.java │ │ │ └── web │ │ │ └── DemoCtroller.java │ │ └── resources │ │ └── bootstrap.yml ├── javayh-demo-feign │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── javayh │ │ │ └── feign │ │ │ ├── FeignApplication.java │ │ │ ├── conf │ │ │ ├── FeignConfig.java │ │ │ ├── ResourceServerConfiguration.java │ │ │ └── TokenFeignClientInterceptor.java │ │ │ ├── service │ │ │ ├── impl │ │ │ │ └── DemoFeignServiceImpl.java │ │ │ └── resource │ │ │ │ └── UserService.java │ │ │ └── web │ │ │ └── FeignCtr.java │ │ └── resources │ │ └── bootstrap.yml ├── javayh-demo-file │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── javayh │ │ │ └── file │ │ │ └── FileApplication.java │ │ └── resources │ │ └── bootstrap.yml ├── javayh-demo-mail │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── javayh │ │ │ └── mail │ │ │ ├── MailApplication.java │ │ │ └── web │ │ │ └── MailController.java │ │ └── resources │ │ ├── bootstrap.yml │ │ └── templates │ │ └── HelloMail.html └── pom.xml ├── javayh-dependencies ├── javayh-common-starter │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── javayh │ │ │ └── common │ │ │ ├── annotation │ │ │ └── JavayhBootApplication.java │ │ │ ├── config │ │ │ ├── JacksonConfig.java │ │ │ └── MyCommandLineRunner.java │ │ │ ├── constant │ │ │ ├── ConstantUtils.java │ │ │ └── EncryptConstantUtils.java │ │ │ ├── encrypt │ │ │ ├── aes │ │ │ │ └── AESUtil.java │ │ │ ├── key │ │ │ │ └── DataKeyGenerator.java │ │ │ ├── md5 │ │ │ │ └── MD5Util.java │ │ │ ├── rsa │ │ │ │ ├── HexUtil.java │ │ │ │ ├── RSAEncrypt.java │ │ │ │ └── RSAUtil.java │ │ │ └── sha │ │ │ │ └── Sha256.java │ │ │ ├── entity │ │ │ └── BaseEntity.java │ │ │ ├── exception │ │ │ ├── BaseException.java │ │ │ ├── GlobalExceptionHandler.java │ │ │ ├── annotation │ │ │ │ └── EnableAutoException.java │ │ │ ├── business │ │ │ │ └── BusinessException.java │ │ │ ├── controller │ │ │ │ └── ControllerException.java │ │ │ ├── dao │ │ │ │ └── DataAccessException.java │ │ │ ├── hystrix │ │ │ │ └── HytrixException.java │ │ │ └── service │ │ │ │ └── ServiceException.java │ │ │ ├── feign │ │ │ ├── FeignClientOkHttpConfiguration.java │ │ │ ├── FeignExceptionConfig.java │ │ │ ├── FeignFailResult.java │ │ │ └── GlobalFeignConfig.java │ │ │ ├── filter │ │ │ └── SensitiveWordFilter.java │ │ │ ├── hash │ │ │ └── ConsistentHashing.java │ │ │ ├── i18n │ │ │ ├── I18nResponseBodyAdvice.java │ │ │ ├── annotation │ │ │ │ └── EnableAutoInternationalization.java │ │ │ └── config │ │ │ │ ├── I18nProperties.java │ │ │ │ └── InternationalConfig.java │ │ │ ├── mdc │ │ │ └── MdcThreadPoolTaskExecutor.java │ │ │ ├── package-info.java │ │ │ ├── qrcode │ │ │ └── QRCodeGenerator.java │ │ │ ├── result │ │ │ ├── MessageBody.java │ │ │ └── ResultData.java │ │ │ ├── selector │ │ │ ├── ExceptionSelector.java │ │ │ ├── SpringI18nSelector.java │ │ │ └── SpringSelector.java │ │ │ └── util │ │ │ ├── DateUtils.java │ │ │ ├── IAction.java │ │ │ ├── IPUtils.java │ │ │ ├── MapUtils.java │ │ │ ├── NumberUtil.java │ │ │ ├── RandomUtil.java │ │ │ ├── Reflections.java │ │ │ ├── StringUtils.java │ │ │ ├── WebUtil.java │ │ │ ├── bean │ │ │ └── BeanUtils.java │ │ │ ├── file │ │ │ └── FileUtils.java │ │ │ ├── id │ │ │ ├── IdGen.java │ │ │ └── SnowflakeIdWorker.java │ │ │ ├── json │ │ │ └── JsonUtils.java │ │ │ ├── log │ │ │ └── Log.java │ │ │ ├── servlet │ │ │ ├── RequestHandleUtil.java │ │ │ └── RequestUtils.java │ │ │ ├── spring │ │ │ └── SpringUtils.java │ │ │ └── task │ │ │ └── ThreadTaskUtils.java │ │ └── resources │ │ ├── META-INF │ │ └── spring.factories │ │ ├── SensitiveWord.txt │ │ ├── banner.txt │ │ └── i18n │ │ ├── common │ │ ├── common.properties │ │ ├── common_en_US.properties │ │ └── common_zh_CN.properties │ │ ├── login │ │ ├── login.properties │ │ ├── login_en_US.properties │ │ └── login_zh_CN.properties │ │ └── validation │ │ ├── validation.properties │ │ ├── validation_en_US.properties │ │ └── validation_zh_CN.properties ├── javayh-data-sources-starter │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── javayh │ │ │ └── datasource │ │ │ ├── annotation │ │ │ └── DataSource.java │ │ │ ├── aop │ │ │ └── DataSourceAOP.java │ │ │ ├── conf │ │ │ └── DataSourceAutoConfig.java │ │ │ ├── constant │ │ │ └── DataSourceKey.java │ │ │ └── util │ │ │ ├── DataSourceHolder.java │ │ │ └── DynamicDataSource.java │ │ └── resources │ │ └── META-INF │ │ └── spring.factories ├── javayh-heartbeat-starter │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── javayh │ │ │ └── client │ │ │ ├── annotation │ │ │ └── EnableAutoHeartBeat.java │ │ │ ├── config │ │ │ └── HeartBeatConfig.java │ │ │ ├── encode │ │ │ └── HeartbeatEncode.java │ │ │ ├── handle │ │ │ └── EchoClientHandle.java │ │ │ ├── heart │ │ │ ├── CustomerHandleInitializer.java │ │ │ └── HeartbeatClient.java │ │ │ ├── properties │ │ │ └── HeartbeatClientProperties.java │ │ │ └── selector │ │ │ └── HeartImportSelector.java │ │ └── resources │ │ └── META-INF │ │ ├── spring-configuration-metadata.json │ │ └── spring.factories ├── javayh-kafka-starter │ └── pom.xml ├── javayh-log-starter │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── javayh │ │ │ └── log │ │ │ ├── annotation │ │ │ ├── EnableLogging.java │ │ │ └── SysLog.java │ │ │ ├── aop │ │ │ └── SysLogAop.java │ │ │ ├── conf │ │ │ └── LogAutoConfig.java │ │ │ ├── entity │ │ │ ├── LogInfoEntity.java │ │ │ └── OperationLog.java │ │ │ ├── interceptor │ │ │ └── LogInterceptor.java │ │ │ ├── log │ │ │ ├── LogError.java │ │ │ ├── LogTemplate.java │ │ │ └── LogUtils.java │ │ │ ├── mapper │ │ │ └── LogMapper.java │ │ │ └── selector │ │ │ └── LogImportSelector.java │ │ └── resources │ │ ├── META-INF │ │ └── spring.factories │ │ └── logback-spring.xml ├── javayh-mail-starter │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── javayh │ │ │ └── mail │ │ │ ├── annotation │ │ │ └── EnableMail.java │ │ │ ├── conf │ │ │ └── EmailProperties.java │ │ │ ├── entity │ │ │ └── MailDO.java │ │ │ ├── selector │ │ │ └── MailImportSelector.java │ │ │ └── server │ │ │ └── MailSend.java │ │ └── resources │ │ └── META-INF │ │ └── spring.factories ├── javayh-mybatis-starter │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── javayh │ │ │ └── mybatis │ │ │ ├── cache │ │ │ └── RedisCache.java │ │ │ ├── exception │ │ │ └── MybatisInjectionException.java │ │ │ ├── filter │ │ │ ├── IllegalSqlFilter.java │ │ │ ├── InterceptorForQuery.java │ │ │ ├── MybatisFilterAutoConfiguration.java │ │ │ ├── MybatisInterceptor.java │ │ │ └── SqlLog.java │ │ │ ├── mapper │ │ │ └── BaseMapper.java │ │ │ ├── page │ │ │ ├── PageEntity.java │ │ │ └── PageQuery.java │ │ │ ├── service │ │ │ └── IService.java │ │ │ ├── task │ │ │ ├── ForkJoinTaskUtils.java │ │ │ └── MybatisTask.java │ │ │ └── uitl │ │ │ └── Constant.java │ │ └── resources │ │ └── META-INF │ │ └── spring.factories ├── javayh-nacos-starter │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── com │ │ └── javayh │ │ └── nacos │ │ └── rule │ │ └── CustomizeRule.java ├── javayh-oauth-starter │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── javayh │ │ │ └── oauth │ │ │ ├── base │ │ │ ├── BaseSecurityConstants.java │ │ │ ├── BaseTokenEnhancer.java │ │ │ ├── BaseUserConverter.java │ │ │ ├── BaseUserDetails.java │ │ │ └── SecurityHelper.java │ │ │ ├── conf │ │ │ └── TokenFeignClientInterceptor.java │ │ │ ├── domain │ │ │ ├── TbPermission.java │ │ │ ├── TbRole.java │ │ │ └── TbUser.java │ │ │ └── exception │ │ │ └── WebException.java │ │ └── resources │ │ └── META-INF │ │ └── spring.factories ├── javayh-redis-starter │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── javayh │ │ │ └── redis │ │ │ ├── conf │ │ │ ├── RedisAutoConfig.java │ │ │ └── RedissonProperties.java │ │ │ ├── prefix │ │ │ └── KeyUtils.java │ │ │ ├── serializer │ │ │ └── RedisObjectSerializer.java │ │ │ └── util │ │ │ └── RedisUtil.java │ │ └── resources │ │ └── META-INF │ │ └── spring.factories ├── javayh-swagger-starter │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── javayh │ │ │ └── swagger │ │ │ ├── annotation │ │ │ └── EnableAutoSwagger.java │ │ │ ├── conf │ │ │ └── SwaggerConfig.java │ │ │ └── selector │ │ │ └── SwaggerSelector.java │ │ └── resources │ │ └── META-INF │ │ └── spring.factories └── pom.xml ├── javayh-monitor-center ├── javayh-heartbeat-server │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── javayh │ │ │ └── heartbeat │ │ │ ├── HeartApplication.java │ │ │ ├── config │ │ │ └── HeartBeatProperties.java │ │ │ ├── encode │ │ │ └── HeartbeatDecoder.java │ │ │ ├── handle │ │ │ └── HeartBeatSimpleHandle.java │ │ │ ├── server │ │ │ ├── HeartBeatServer.java │ │ │ └── HeartbeatInitializer.java │ │ │ └── util │ │ │ └── NettySocketHolder.java │ │ └── resources │ │ ├── META-INF │ │ └── spring-configuration-metadata.json │ │ └── bootstrap.yml ├── javayh-zipkin-center │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── javayh │ │ │ └── zipkin │ │ │ └── ZipkinApplication.java │ │ └── resources │ │ └── bootstrap.yml └── pom.xml ├── javayh-plugins ├── javayh-generator │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── com │ │ └── javayh │ │ └── generator │ │ ├── GeneratorMain.java │ │ ├── bean │ │ └── FieldBean.java │ │ ├── config │ │ └── GenerateConfig.java │ │ ├── file │ │ ├── GenBeanDTOFile.java │ │ ├── GenBeanFile.java │ │ ├── GenControllerFile.java │ │ ├── GenIServiceFile.java │ │ ├── GenMain.java │ │ ├── GenMapperJavaFile.java │ │ ├── GenMapperXmlFile.java │ │ └── GenServiceImplFile.java │ │ └── util │ │ ├── FileUtils.java │ │ ├── NameUtils.java │ │ ├── NotesUtils.java │ │ ├── StringUtil.java │ │ └── TimeUtils.java └── pom.xml ├── javayh-route ├── javayh-api-gateway │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── javayh │ │ │ └── gateway │ │ │ ├── GatewayApplication.java │ │ │ ├── conf │ │ │ ├── cosr │ │ │ │ └── GatewayCosrConfig.java │ │ │ ├── fallback │ │ │ │ └── GatewayFallbackConfig.java │ │ │ ├── limiter │ │ │ │ └── RateLimiterConfig.java │ │ │ └── swagger │ │ │ │ └── SwaggerProvider.java │ │ │ ├── filter │ │ │ └── SwaggerHeaderFilter.java │ │ │ └── handler │ │ │ ├── hystrix │ │ │ └── HystrixFallbackHandler.java │ │ │ └── swagger │ │ │ └── SwaggerHandler.java │ │ └── resources │ │ └── bootstrap.yml └── pom.xml ├── javayh-sso ├── javayh-resource │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── javayh │ │ │ └── resource │ │ │ ├── ResourceApplication.java │ │ │ ├── conf │ │ │ └── ResourceServerConfiguration.java │ │ │ ├── controller │ │ │ └── UserApi.java │ │ │ ├── mapper │ │ │ └── TbUserMapper.java │ │ │ ├── service │ │ │ ├── UserService.java │ │ │ └── impl │ │ │ │ └── UserServiceImpl.java │ │ │ └── vo │ │ │ └── UserVO.java │ │ └── resources │ │ ├── bootstrap.yml │ │ └── mapper │ │ └── user │ │ └── TbUserMapper.xml ├── javayh-server │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── javayh │ │ │ └── oauth2 │ │ │ └── server │ │ │ ├── OAuth2ServerApplication.java │ │ │ ├── conf │ │ │ ├── AuthorizationServerConfiguration.java │ │ │ ├── ResourceServerConfiguration.java │ │ │ ├── WebSecurityConfiguration.java │ │ │ └── service │ │ │ │ └── UserDetailsServiceImpl.java │ │ │ ├── mapper │ │ │ ├── TbPermissionMapper.java │ │ │ ├── TbRoleMapper.java │ │ │ └── TbUserMapper.java │ │ │ └── service │ │ │ ├── TbPermissionService.java │ │ │ ├── TbRoleService.java │ │ │ ├── TbUserService.java │ │ │ └── impl │ │ │ ├── TbPermissionServiceImpl.java │ │ │ ├── TbRoleServiceImpl.java │ │ │ └── TbUserServiceImpl.java │ │ └── resources │ │ ├── bootstrap.yml │ │ └── mapper │ │ ├── permission │ │ └── TbPermissionMapper.xml │ │ ├── role │ │ └── TbRoleMapper.xml │ │ └── user │ │ └── TbUserMapper.xml └── pom.xml └── pom.xml /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Desktop (please complete the following information):** 27 | - OS: [e.g. iOS] 28 | - Browser [e.g. chrome, safari] 29 | - Version [e.g. 22] 30 | 31 | **Smartphone (please complete the following information):** 32 | - Device: [e.g. iPhone6] 33 | - OS: [e.g. iOS8.1] 34 | - Browser [e.g. stock browser, safari] 35 | - Version [e.g. 22] 36 | 37 | **Additional context** 38 | Add any other context about the problem here. 39 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/custom.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Custom issue template 3 | about: Describe this issue template's purpose here. 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | 11 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name : test—actions 2 | on: 3 | push: 4 | branches: [main,master] 5 | pull_request: 6 | branches: [main,master] 7 | 8 | jobs: 9 | build: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - name: Checkout 13 | uses: actions/checkout@v2 14 | - name: Setup Java JDK 15 | uses: actions/checkout@v2 16 | with: 17 | java-version: '14' 18 | distribution: 'adopt' 19 | - name: Setup Maven 20 | # You may pin to the exact commit or the version. 21 | # uses: stCarolas/setup-maven@07fbbe97d97ef44336b7382563d66743297e442f 22 | uses: stCarolas/setup-maven@v.4.5 23 | - name: Build package 24 | run: mvn -DskipTests=true package -P 25 | 26 | - name: Login Registry 27 | uses: docker/login-action@v1 28 | with: 29 | registry: ghcr.io 30 | username: ${{ github.repository_owner }} 31 | password: ${{ secrets.GHCR_TOKEN }} 32 | 33 | - name: Push image 34 | run: 35 | docker push ghcr.io/shaowenchen/documents:latest 36 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # maven ignore 2 | target/ 3 | *.jar 4 | *.war 5 | *.zip 6 | *.tar 7 | *.tar.gz 8 | *.class 9 | *.project 10 | *.factorypath 11 | 12 | # eclipse ignore 13 | .settings/ 14 | .classpath 15 | target/ 16 | bin/ 17 | NewCustServSer/ 18 | SrenewSer/ 19 | sms-drugstore/ 20 | 21 | # idea ignore 22 | .idea/ 23 | *.ipr 24 | *.iml 25 | *.iws 26 | 27 | # temp ignore 28 | *.log 29 | *.cache 30 | *.diff 31 | *.patch 32 | *.tmp 33 | 34 | # system ignore 35 | .DS_Store 36 | Thumbs.db 37 | 38 | # else 39 | .springBeans 40 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | ## Contact information 2 | Contact the author via wechat: 37277553 3 | 4 | Fill in remarks: javayh 5 | 6 | ## 联系方式 7 | 通过微信联系作者: 37277553 8 | 9 | 填写备注: javayh 10 | -------------------------------------------------------------------------------- /doc/file/common.yaml: -------------------------------------------------------------------------------- 1 | ## prometheus 监控使用 2 | management: 3 | endpoints: 4 | web: 5 | exposure: 6 | include: 'prometheus' #[*] 7 | metrics: 8 | tags: 9 | application: ${spring.application.name} 10 | endpoint: 11 | health: 12 | show-details: always 13 | -------------------------------------------------------------------------------- /doc/file/db1.yaml: -------------------------------------------------------------------------------- 1 | spring: 2 | datasource: 3 | druid: 4 | url: jdbc:mysql://localhost:3306/db1?serverTimezone=CTT&characterEncoding=utf8&autoReconnect=true&useUnicode=true&useSSL=true 5 | username: root 6 | password: root 7 | driver-class-name: com.mysql.cj.jdbc.Driver 8 | initial-size: 1 9 | min-idle: 1 10 | max-active: 20 11 | max-wait: 60000 12 | time-between-eviction-runs-millis: 60000 13 | min-evictable-idle-time-millis: 30000 14 | validation-query: select '1' from dual 15 | test-while-idle: true 16 | test-on-borrow: false 17 | test-on-return: false 18 | pool-prepared-statements: false 19 | max-pool-prepared-statement-per-connection-size: 20 20 | filters: stat,wall 21 | aop-patterns: com.javayh.* 22 | web-stat-filter: 23 | enabled: true 24 | url-pattern: /* 25 | exclusions: /druid/*,*.js,*.gif,*.jpg,*.bmp,*.png,*.css,*.ico 26 | session-stat-enable: true 27 | session-stat-max-count: 10 28 | stat-view-servlet: 29 | enabled: true 30 | url-pattern: "/druid/*" 31 | reset-enable: false 32 | login-username: admin 33 | login-password: admin123 34 | -------------------------------------------------------------------------------- /doc/file/feignhystrix.yaml: -------------------------------------------------------------------------------- 1 | ## feign 服务容错 2 | feign: 3 | hystrix: 4 | enabled: true #是否开启断路器 5 | # sentinel: # 如果您使用sentinel,请将hystrix 置为false 6 | # enabled: true 7 | compression: #GZIP 请求压缩 8 | request: 9 | enabled: true 10 | mime-types: text/xml,application/xml,application/json 11 | min-request-size: 2048 12 | response: 13 | enabled: true 14 | useGzipDecoder: true 15 | client: 16 | config: 17 | feignName: 18 | connectTimeout: 5000 19 | readTimeout: 5000 20 | loggerLevel: full 21 | # errorDecoder: com.SimpleErrorDecoder 22 | # retryer: com.SimpleRetryer 23 | # requestInterceptors: 24 | # - com.FooRequestInterceptor 25 | # - com.BarRequestInterceptor 26 | # decode404: false 27 | # encoder: com.SimpleEncoder 28 | # decoder: com.SimpleDecoder 29 | # contract: com.Si 30 | httpclient: # 模式使用 31 | enabled: false 32 | okhttp: # 使用ok http 33 | enabled: true 34 | 35 | #hystrix的超时时间 36 | hystrix: 37 | command: 38 | default: 39 | execution: 40 | timeout: 41 | enabled: true 42 | isolation: 43 | thread: 44 | timeoutInMilliseconds: 30000 45 | #ribbon的超时时间 46 | ribbon: 47 | ReadTimeout: 30000 48 | ConnectTimeout: 30000 49 | # 同一实例最大重试次数,不包括首次调用。默认值为0 50 | MaxAutoRetries: 0 51 | # 同一个微服务其他实例的最大重试次数,不包括第一次调用的实例。默认值为1 52 | MaxAutoRetriesNextServer: 0 53 | # 是否所有操作(GET、POST等)都允许重试。默认值为false 54 | OkToRetryOnAllOperations: false 55 | okhttp: 56 | enabled: true -------------------------------------------------------------------------------- /doc/file/mail.yaml: -------------------------------------------------------------------------------- 1 | ## 邮件模板配置 2 | spring: 3 | mail: 4 | protocol: smtp 5 | host: smtp.qq.com 6 | # 自己的qq邮箱账号 7 | username: 372787553@qq.com 8 | # password 换成腾讯给的QQ授权码 9 | password: 10 | default-encoding: UTF-8 11 | properties: 12 | mail: 13 | smtp: 14 | auth: true 15 | starttls: 16 | enable: true 17 | required: true 18 | thymeleaf: 19 | enabled: true 20 | mode: LEGACYHTML5 21 | encoding: UTF-8 22 | prefix: classpath:/templates/ # 模板存放在资源目录的 templates/ 文件下 23 | suffix: .html # 模板后缀 24 | check-template-location: true 25 | check-template: false 26 | cache: false # 调试时关闭缓存 27 | servlet: 28 | content-type: text/html -------------------------------------------------------------------------------- /doc/file/mybatis.yaml: -------------------------------------------------------------------------------- 1 | ## mybatis 常用配置 2 | mybatis: 3 | ### xml存放路径 4 | mapper-locations: classpath*:mapper/*/*Mapper.xml 5 | configuration: 6 | cache-enabled: true 7 | lazy-loading-enabled: false 8 | aggressive-lazy-loading: true 9 | log-impl: org.apache.ibatis.logging.stdout.StdOutImpl 10 | -------------------------------------------------------------------------------- /doc/file/oauth2db.yaml: -------------------------------------------------------------------------------- 1 | ## oauth2 权限验证配置 2 | spring: 3 | datasource: 4 | druid: 5 | url: jdbc:mysql://localhost:3306/oauth2?serverTimezone=CTT&characterEncoding=utf8&autoReconnect=true&useUnicode=true&useSSL=true 6 | username: root 7 | password: root 8 | driver-class-name: com.mysql.cj.jdbc.Driver 9 | initial-size: 1 10 | min-idle: 1 11 | max-active: 20 12 | max-wait: 60000 13 | time-between-eviction-runs-millis: 60000 14 | min-evictable-idle-time-millis: 30000 15 | validation-query: select '1' from dual 16 | test-while-idle: true 17 | test-on-borrow: false 18 | test-on-return: false 19 | pool-prepared-statements: false 20 | max-pool-prepared-statement-per-connection-size: 20 21 | filters: stat,wall 22 | aop-patterns: com.javayh.* 23 | web-stat-filter: 24 | enabled: true 25 | url-pattern: /* 26 | exclusions: /druid/*,*.js,*.gif,*.jpg,*.bmp,*.png,*.css,*.ico 27 | session-stat-enable: true 28 | session-stat-max-count: 10 29 | stat-view-servlet: 30 | enabled: true 31 | url-pattern: "/druid/*" 32 | reset-enable: false 33 | login-username: admin 34 | login-password: admin123 35 | 36 | mybatis: 37 | ### xml存放路径 38 | mapper-locations: classpath*:mapper/*/*Mapper.xml -------------------------------------------------------------------------------- /doc/file/oauth_token.yaml: -------------------------------------------------------------------------------- 1 | ## oauth 客户全token检测配置 2 | security: 3 | oauth2: 4 | client: 5 | client-id: client 6 | client-secret: secret 7 | access-token-uri: http://localhost:9090/oauth/token 8 | user-authorization-uri: http://localhost:9090/oauth/authorize 9 | resource: 10 | token-info-uri: http://localhost:9090/oauth/check_token 11 | -------------------------------------------------------------------------------- /doc/file/redis.yaml: -------------------------------------------------------------------------------- 1 | ## redis配置 2 | spring: 3 | redis: 4 | ################### redis 单机版 start ########################## 5 | host: 127.0.0.1 6 | port: 6379 7 | timeout: 6000 8 | database: 1 9 | lettuce: 10 | pool: 11 | max-active: 10 # 连接池最大连接数(使用负值表示没有限制),如果赋值为-1,则表示不限制;如果pool已经分配了maxActive个jedis实例,则此时pool的状态为exhausted(耗尽) 12 | max-idle: 8 # 连接池中的最大空闲连接 ,默认值也是8 13 | max-wait: 100 # # 等待可用连接的最大时间,单位毫秒,默认值为-1,表示永不超时。如果超过等待时间,则直接抛出JedisConnectionException 14 | min-idle: 2 # 连接池中的最小空闲连接 ,默认值也是0 15 | shutdown-timeout: 100ms 16 | ################## redis 单机版 end ########################## 17 | # cluster: 18 | # nodes: 12.0.0.1:7000,12.0.0.1:7000 19 | # timeout: 1000 # 连接超时时间(毫秒) 20 | # lettuce: 21 | # pool: 22 | # max-active: 10 # 连接池最大连接数(使用负值表示没有限制),如果赋值为-1,则表示不限制;如果pool已经分配了maxActive个jedis实例,则此时pool的状态为exhausted(耗尽) 23 | # max-idle: 8 # 连接池中的最大空闲连接 ,默认值也是8 24 | # max-wait: 100 # # 等待可用连接的最大时间,单位毫秒,默认值为-1,表示永不超时。如果超过等待时间,则直接抛出JedisConnectionException 25 | # min-idle: 2 # 连接池中的最小空闲连接 ,默认值也是0 26 | # shutdown-timeout: 100ms -------------------------------------------------------------------------------- /doc/file/zipkindb.yaml: -------------------------------------------------------------------------------- 1 | spring: 2 | datasource: 3 | druid: 4 | url: jdbc:mysql://localhost:3306/zipkin?serverTimezone=CTT&characterEncoding=utf8&autoReconnect=true&useUnicode=true&useSSL=true 5 | username: root 6 | password: root 7 | driver-class-name: com.mysql.cj.jdbc.Driver 8 | initial-size: 1 9 | min-idle: 1 10 | max-active: 20 11 | max-wait: 60000 12 | time-between-eviction-runs-millis: 60000 13 | min-evictable-idle-time-millis: 30000 14 | validation-query: select '1' from dual 15 | test-while-idle: true 16 | test-on-borrow: false 17 | test-on-return: false 18 | pool-prepared-statements: false 19 | max-pool-prepared-statement-per-connection-size: 20 20 | filters: stat,wall 21 | aop-patterns: com.javayh.* 22 | web-stat-filter: 23 | enabled: true 24 | url-pattern: /* 25 | exclusions: /druid/*,*.js,*.gif,*.jpg,*.bmp,*.png,*.css,*.ico 26 | session-stat-enable: true 27 | session-stat-max-count: 10 28 | stat-view-servlet: 29 | enabled: true 30 | url-pattern: "/druid/*" 31 | reset-enable: false 32 | login-username: admin 33 | login-password: admin123 -------------------------------------------------------------------------------- /doc/img/access_token.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yanghaiji/javayh-platform/aedf95ec3ffab57c56a8870d05145838cef97805/doc/img/access_token.JPG -------------------------------------------------------------------------------- /doc/img/auth.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yanghaiji/javayh-platform/aedf95ec3ffab57c56a8870d05145838cef97805/doc/img/auth.JPG -------------------------------------------------------------------------------- /doc/img/code.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yanghaiji/javayh-platform/aedf95ec3ffab57c56a8870d05145838cef97805/doc/img/code.JPG -------------------------------------------------------------------------------- /doc/img/oauthLogin.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yanghaiji/javayh-platform/aedf95ec3ffab57c56a8870d05145838cef97805/doc/img/oauthLogin.JPG -------------------------------------------------------------------------------- /doc/img/swagger.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yanghaiji/javayh-platform/aedf95ec3ffab57c56a8870d05145838cef97805/doc/img/swagger.png -------------------------------------------------------------------------------- /doc/img/token.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yanghaiji/javayh-platform/aedf95ec3ffab57c56a8870d05145838cef97805/doc/img/token.JPG -------------------------------------------------------------------------------- /doc/sql/log/loginfo.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE `sys_log_info` ( 2 | `id` varchar(64) NOT NULL COMMENT '主键', 3 | `level` varchar(255) DEFAULT NULL COMMENT '级别', 4 | `method` varchar(255) NOT NULL COMMENT '方法名', 5 | `args` varchar(255) NOT NULL COMMENT '参数', 6 | `user_id` varchar(64) DEFAULT NULL COMMENT '操作人id', 7 | `user_name` varchar(64) DEFAULT NULL COMMENT '操作人', 8 | `create_time` varchar(255) NOT NULL, 9 | `describe` varchar(255) NOT NULL COMMENT '描述', 10 | `run_time` varchar(255) NOT NULL COMMENT '运行时间', 11 | `caller_ip` varchar(32) NOT NULL COMMENT '调用方ip', 12 | `local_host_ip` varchar(32) NOT NULL COMMENT '本地ip', 13 | PRIMARY KEY (`id`) 14 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -------------------------------------------------------------------------------- /javayh-demo/javayh-demo-api/src/main/java/com/javayh/api/ApiApplication.java: -------------------------------------------------------------------------------- 1 | package com.javayh.api; 2 | 3 | import com.javayh.common.annotation.JavayhBootApplication; 4 | import com.javayh.common.exception.annotation.EnableAutoException; 5 | import com.javayh.common.i18n.annotation.EnableAutoInternationalization; 6 | import com.javayh.swagger.annotation.EnableAutoSwagger; 7 | import org.springframework.boot.SpringApplication; 8 | 9 | /** 10 | *
11 | * 测试启动类 12 | *
13 | * 14 | * @author Dylan-haiji 15 | * @version 1.0.0 16 | * @since 2020-03-01 20:44 17 | */ 18 | @EnableAutoException 19 | @EnableAutoSwagger 20 | @EnableAutoInternationalization 21 | @JavayhBootApplication 22 | public class ApiApplication { 23 | 24 | public static void main(String[] args) { 25 | SpringApplication.run(ApiApplication.class, args); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /javayh-demo/javayh-demo-api/src/main/java/com/javayh/api/conf/ResourceServerConfiguration.java: -------------------------------------------------------------------------------- 1 | // package com.javayh.api.conf; 2 | // 3 | // import org.springframework.boot.actuate.autoconfigure.security.servlet.EndpointRequest; 4 | // import org.springframework.context.annotation.Configuration; 5 | // import 6 | // org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; 7 | // import org.springframework.security.config.annotation.web.builders.HttpSecurity; 8 | // import 9 | // org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer; 10 | // import org.springframework.security.config.http.SessionCreationPolicy; 11 | // import 12 | // org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer; 13 | // import 14 | // org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfigurerAdapter; 15 | // 16 | // @Configuration 17 | // @EnableResourceServer 18 | // @EnableGlobalMethodSecurity(prePostEnabled = true, securedEnabled = true, jsr250Enabled 19 | // = true) 20 | // public class ResourceServerConfiguration extends ResourceServerConfigurerAdapter { 21 | // 22 | // @Override 23 | // public void configure(HttpSecurity http) throws Exception { 24 | // ExpressionUrlAuthorizationConfigurer* iMapper 8 | *
* @author:Dylan 9 | * @version:V1.0 10 | * @since:2020-04-16 11 | */ 12 | @Mapper 13 | public interface SysLogisticsMapper extends BaseMapper{ 14 | } 15 | -------------------------------------------------------------------------------- /javayh-demo/javayh-demo-api/src/main/java/com/javayh/api/sys/pojo/SysLogistics.java: -------------------------------------------------------------------------------- 1 | package com.javayh.api.sys.pojo; 2 | 3 | import io.swagger.annotations.ApiModelProperty; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Builder; 6 | import lombok.Data; 7 | import lombok.NoArgsConstructor; 8 | import lombok.ToString; 9 | 10 | import java.util.Date; 11 | /** 12 | ** Bean 13 | *
* @author:Dylan 14 | * @version:V1.0 15 | * @since:2020-04-16 16 | */ 17 | @SuppressWarnings("serial") 18 | @Data 19 | @NoArgsConstructor 20 | @AllArgsConstructor 21 | @Builder 22 | @ToString 23 | public class SysLogistics implements java.io.Serializable{ 24 | 25 | /** 26 | * 27 | */ 28 | @ApiModelProperty(hidden = true) 29 | private Integer id; 30 | /** 31 | * 收件人 32 | */ 33 | @ApiModelProperty(value = "收件人") 34 | private String addresseeName; 35 | /** 36 | * 收件人地址 37 | */ 38 | @ApiModelProperty(value = "收件人地址") 39 | private String addressee; 40 | /** 41 | * 42 | */ 43 | @ApiModelProperty(hidden = true) 44 | private Integer addresseePhone; 45 | /** 46 | * 寄件人 47 | */ 48 | @ApiModelProperty(value = "寄件人") 49 | private String senderName; 50 | /** 51 | * 寄件人地址 52 | */ 53 | @ApiModelProperty(value = "寄件人地址") 54 | private String senderAdd; 55 | /** 56 | * 0,已接单,1,已发货,2,已签收 57 | */ 58 | @ApiModelProperty(value = "0,已接单,1,已发货,2,已签收") 59 | private Integer emsStatus; 60 | /** 61 | * 0,为退货,1,退货中,2,已退货 62 | */ 63 | @ApiModelProperty(value = "0,为退货,1,退货中,2,已退货") 64 | private Integer retreatStatus; 65 | /** 66 | * 退货原因 67 | */ 68 | @ApiModelProperty(value = "退货原因") 69 | private String retreatInfo; 70 | /** 71 | * 创建时间 72 | */ 73 | @ApiModelProperty(value = "创建时间") 74 | private Date createDate; 75 | /** 76 | * 77 | */ 78 | @ApiModelProperty(hidden = true) 79 | private Date updateDate; 80 | /** 81 | * 操作人 82 | */ 83 | @ApiModelProperty(value = "操作人") 84 | private String createBy; 85 | 86 | } 87 | -------------------------------------------------------------------------------- /javayh-demo/javayh-demo-api/src/main/java/com/javayh/api/sys/pojo/dto/SysLogisticsDTO.java: -------------------------------------------------------------------------------- 1 | package com.javayh.api.sys.pojo.dto; 2 | 3 | import lombok.*; 4 | import com.javayh.mybatis.page.PageEntity; 5 | 6 | import io.swagger.annotations.ApiModelProperty; 7 | import java.util.Date; 8 | /** 9 | ** Bean 10 | *
* @author:Dylan 11 | * @version:V1.0 12 | * @since:2020-04-16 13 | */ 14 | @SuppressWarnings("serial") 15 | @Data 16 | @NoArgsConstructor 17 | @AllArgsConstructor 18 | @Builder 19 | @ToString 20 | public class SysLogisticsDTO extends PageEntity implements java.io.Serializable{ 21 | 22 | /** 23 | * 24 | */ 25 | @ApiModelProperty(hidden = true) 26 | private Integer id; 27 | /** 28 | * 收件人 29 | */ 30 | @ApiModelProperty(value = "收件人") 31 | private String addresseeName; 32 | /** 33 | * 收件人地址 34 | */ 35 | @ApiModelProperty(value = "收件人地址") 36 | private String addressee; 37 | /** 38 | * 39 | */ 40 | @ApiModelProperty(hidden = true) 41 | private Integer addresseePhone; 42 | /** 43 | * 寄件人 44 | */ 45 | @ApiModelProperty(value = "寄件人") 46 | private String senderName; 47 | /** 48 | * 寄件人地址 49 | */ 50 | @ApiModelProperty(value = "寄件人地址") 51 | private String senderAdd; 52 | /** 53 | * 0,已接单,1,已发货,2,已签收 54 | */ 55 | @ApiModelProperty(value = "0,已接单,1,已发货,2,已签收") 56 | private Integer emsStatus; 57 | /** 58 | * 0,为退货,1,退货中,2,已退货 59 | */ 60 | @ApiModelProperty(value = "0,为退货,1,退货中,2,已退货") 61 | private Integer retreatStatus; 62 | /** 63 | * 退货原因 64 | */ 65 | @ApiModelProperty(value = "退货原因") 66 | private String retreatInfo; 67 | /** 68 | * 创建时间 69 | */ 70 | @ApiModelProperty(value = "创建时间") 71 | private Date createDate; 72 | /** 73 | * 74 | */ 75 | @ApiModelProperty(hidden = true) 76 | private Date updateDate; 77 | /** 78 | * 操作人 79 | */ 80 | @ApiModelProperty(value = "操作人") 81 | private String createBy; 82 | 83 | } 84 | -------------------------------------------------------------------------------- /javayh-demo/javayh-demo-api/src/main/java/com/javayh/api/sys/service/ISysLogisticsService.java: -------------------------------------------------------------------------------- 1 | package com.javayh.api.sys.service; 2 | 3 | import com.javayh.api.sys.pojo.SysLogistics; 4 | import java.util.List; 5 | import com.javayh.api.sys.pojo.dto.SysLogisticsDTO; 6 | import com.javayh.mybatis.page.PageQuery; 7 | 8 | /** 9 | ** iService 10 | *
* @author:Dylan 11 | * @version:V1.0 12 | * @since:2020-04-16 13 | */ 14 | public interface ISysLogisticsService { 15 | /** 16 | * 根据条件查找-分页 17 | */ 18 | PageQuery15 | * 16 | *
17 | * 18 | * @author Dylan-haiji 19 | * @version 1.0.0 20 | * @since 2020-03-06 9:48 21 | */ 22 | @Api("测试 API") 23 | @RestController 24 | @RequestMapping(value = "/api/") 25 | public class ApiController { 26 | 27 | @ApiOperation(value = "swagger测试", notes = "测试") 28 | @GetMapping(value = "swagger") 29 | public ResultData getSwagger() { 30 | return ResultData.success("Hello Swagger!"); 31 | } 32 | 33 | @ApiOperation(value = "二维码渲染", notes = "二维码") 34 | @RequestMapping("/test") 35 | public void getQRcode(HttpServletResponse response) throws Exception { 36 | // 参数为二维码的内容、长、宽、响应对象 37 | String text = "https://blog.csdn.net/weixin_38937840"; 38 | String logoPath = "C:\\Users\\haiyang\\Desktop\\webwxgetmsgimg.jpg"; 39 | QRCodeGenerator.outputQRCode(text, logoPath, response); 40 | } 41 | 42 | 43 | } 44 | -------------------------------------------------------------------------------- /javayh-demo/javayh-demo-api/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 6062 3 | spring: 4 | application: 5 | name: ${artifactId} 6 | main: 7 | allow-bean-definition-overriding: true #当遇到同样名字的时候,是否允许覆盖注册 8 | profiles: 9 | active: ${profile.name} 10 | cloud: 11 | nacos: 12 | discovery: 13 | server-addr: ${discovery.server-addr} 14 | namespace: ${config.namespace} 15 | # ip: ${discovery.server-ip} 16 | config: 17 | server-addr: ${config.server-addr} 18 | namespace: ${config.namespace} 19 | file-extension: yaml 20 | shared-dataids: db1.yaml,common.yaml,redis.yaml,mail.yaml,mybatis.yaml 21 | messages: 22 | basename: i18n.login.login,i18n.common.common,i18n.validation.validation 23 | # zipkin: 24 | # base-url: http://localhost:7070 25 | # # 关闭服务发现,否则Spring Cloud会把zipkin的url当做服务名称 26 | # discoveryClientEnabled: false 27 | # sender: 28 | # type: web 29 | # sleuth: 30 | # sampler: 31 | # probability: 1 # 设置抽样采集率为100%,默认为0.1,即10% 32 | 33 | 34 | -------------------------------------------------------------------------------- /javayh-demo/javayh-demo-common/pom.xml: -------------------------------------------------------------------------------- 1 | 2 |12 | * 测试启动类 13 | *
14 | * 15 | * @author Dylan-haiji 16 | * @version 1.0.0 17 | * @since 2020-03-01 20:44 18 | */ 19 | @EnableAutoSwagger 20 | @EnableAutoException 21 | @EnableAutoInternationalization 22 | @JavayhBootApplication 23 | public class DemoApplication { 24 | 25 | public static void main(String[] args) { 26 | SpringApplication.run(DemoApplication.class, args); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /javayh-demo/javayh-demo-common/src/main/java/com/javayh/demo/service/DemoFallback.java: -------------------------------------------------------------------------------- 1 | package com.javayh.demo.service; 2 | 3 | import org.springframework.stereotype.Component; 4 | 5 | /** 6 | *7 | * 8 | *
9 | * 10 | * @author Dylan-haiji 11 | * @version 1.0.0 12 | * @since 2020-03-02 13:48 13 | */ 14 | @Component 15 | public class DemoFallback implements DemoService { 16 | 17 | @Override 18 | public String getFeign() { 19 | return "error"; 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /javayh-demo/javayh-demo-common/src/main/java/com/javayh/demo/service/DemoService.java: -------------------------------------------------------------------------------- 1 | package com.javayh.demo.service; 2 | 3 | import org.springframework.cloud.openfeign.FeignClient; 4 | import org.springframework.stereotype.Service; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | 7 | /** 8 | *9 | * 10 | *
11 | * 12 | * @author Dylan-haiji 13 | * @version 1.0.0 14 | * @since 2020-03-02 13:40 15 | */ 16 | @Service 17 | @FeignClient(name = "javayh-demo-feign", fallback = DemoFallback.class) 18 | public interface DemoService { 19 | 20 | @GetMapping(value = "/feign/getfeign") 21 | String getFeign(); 22 | 23 | } 24 | -------------------------------------------------------------------------------- /javayh-demo/javayh-demo-common/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 6060 3 | spring: 4 | application: 5 | name: ${artifactId} 6 | main: 7 | allow-bean-definition-overriding: true #当遇到同样名字的时候,是否允许覆盖注册 8 | profiles: 9 | active: ${profile.name} 10 | cloud: 11 | nacos: 12 | discovery: 13 | server-addr: ${discovery.server-addr} 14 | namespace: ${config.namespace} 15 | # ip: ${discovery.server-ip} 16 | config: 17 | server-addr: ${config.server-addr} 18 | namespace: ${config.namespace} 19 | file-extension: yaml 20 | shared-dataids: redis.yaml,mail.yaml,feignhystrix.yaml 21 | messages: 22 | basename: i18n.login.login,i18n.common.common,i18n.validation.validation 23 | -------------------------------------------------------------------------------- /javayh-demo/javayh-demo-config/README.md: -------------------------------------------------------------------------------- 1 | ## javayh-demo-config 2 | 3 | 这里主要讲解nacos分布式配置中心多环节的配置 4 | ### 5 | ``` 6 | cloud: 7 | nacos: 8 | discovery: 9 | server-addr: 127.0.0.1:8848 10 | cluster-name: javayh-nacos 11 | config: 12 | group: haiji_dev 13 | server-addr: 127.0.0.1:8848 14 | prefix: javayh-demo 15 | file-extension: yml 16 | namespace: d7503bcd-e44c-475a-88d4-d28cbfb444fc 17 | shared-dataids: redis.yml 18 | ``` 19 | **配置中心实例** 20 |  21 | 22 | `spring.cloud.nacos.config.group`: 分组信息,默认是 DEFAULT_GROUP 23 | `spring.cloud.nacos.config.namespace`: 环境的唯一id 24 | `spring.cloud.nacos.config.shared-dataids`: 需要加载的共享资源 ,这里对用配置文中心的`Data ID` 25 | `spring.cloud.nacos.config.refreshable-dataids`: 与shared-dataids效果一样,但是支持自动刷新 26 | -------------------------------------------------------------------------------- /javayh-demo/javayh-demo-config/pom.xml: -------------------------------------------------------------------------------- 1 | 2 |9 | * nacos分布式中心测试 10 | *
11 | * 12 | * @author Dylan-haiji 13 | * @version 1.0.0 14 | * @since 2020-03-09 17:45 15 | */ 16 | @EnableAutoInternationalization 17 | @JavayhBootApplication 18 | public class ConfigApplication { 19 | 20 | public static void main(String[] args) { 21 | SpringApplication.run(ConfigApplication.class, args); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /javayh-demo/javayh-demo-config/src/main/java/com/javayh/config/web/DemoCtroller.java: -------------------------------------------------------------------------------- 1 | package com.javayh.config.web; 2 | 3 | import com.javayh.common.result.ResultData; 4 | import com.javayh.redis.prefix.KeyUtils; 5 | import com.javayh.redis.util.RedisUtil; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.web.bind.annotation.GetMapping; 8 | import org.springframework.web.bind.annotation.RequestMapping; 9 | import org.springframework.web.bind.annotation.RestController; 10 | 11 | /** 12 | *13 | * demo 访问 14 | *
15 | * 16 | * @author Dylan-haiji 17 | * @version 1.0.0 18 | * @since 2020-03-01 20:46 19 | */ 20 | @RestController 21 | @RequestMapping(value = "/demo/") 22 | public class DemoCtroller { 23 | 24 | @Autowired 25 | private RedisUtil redisUtil; 26 | 27 | /** 28 | *29 | * 测试Redis 30 | *
31 | * @version 1.0.0 32 | * @author Dylan-haiji 33 | * @since 2020/3/4 34 | * @param 35 | * @return com.javayh.common.result.ResultData 36 | */ 37 | @GetMapping(value = "redis") 38 | public ResultData redis() { 39 | String ceshi = KeyUtils.key("ceshi"); 40 | boolean hello_word = redisUtil.setObj(ceshi, "hello word", 100); 41 | String s = (String) redisUtil.get(ceshi); 42 | return ResultData.success(s); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /javayh-demo/javayh-demo-config/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 6064 3 | spring: 4 | application: 5 | name: ${artifactId} 6 | main: 7 | allow-bean-definition-overriding: true #当遇到同样名字的时候,是否允许覆盖注册 8 | profiles: 9 | active: ${profile.name} 10 | cloud: 11 | nacos: 12 | discovery: 13 | server-addr: ${discovery.server-addr} 14 | namespace: ${config.namespace} 15 | # ip: ${discovery.server-ip} 16 | config: 17 | server-addr: ${config.server-addr} 18 | namespace: ${config.namespace} 19 | file-extension: yaml 20 | shared-dataids: redis.yaml,mail.yaml 21 | messages: 22 | basename: i18n.login.login,i18n.common.common,i18n.validation.validation -------------------------------------------------------------------------------- /javayh-demo/javayh-demo-feign/pom.xml: -------------------------------------------------------------------------------- 1 | 2 |11 | * feign 启动类 12 | *
13 | * 14 | * @author Dylan-haiji 15 | * @version 1.0.0 16 | * @since 2020-03-02 13:34 17 | */ 18 | @EnableFeignClients 19 | @EnableAutoSwagger 20 | // @EnableAutoHeartBeat 21 | @EnableAutoInternationalization 22 | @JavayhBootApplication 23 | public class FeignApplication { 24 | 25 | public static void main(String[] args) { 26 | SpringApplication.run(FeignApplication.class, args); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /javayh-demo/javayh-demo-feign/src/main/java/com/javayh/feign/conf/FeignConfig.java: -------------------------------------------------------------------------------- 1 | //package com.javayh.feign.conf; 2 | // 3 | //import feign.RequestInterceptor; 4 | //import org.springframework.boot.context.properties.ConfigurationProperties; 5 | //import org.springframework.cloud.security.oauth2.client.feign.OAuth2FeignRequestInterceptor; 6 | //import org.springframework.context.annotation.Bean; 7 | //import org.springframework.context.annotation.Configuration; 8 | //import org.springframework.security.oauth2.client.DefaultOAuth2ClientContext; 9 | //import org.springframework.security.oauth2.client.OAuth2RestTemplate; 10 | //import org.springframework.security.oauth2.client.token.grant.client.ClientCredentialsResourceDetails; 11 | // 12 | // 13 | //@Configuration 14 | //public class FeignConfig { 15 | // @Bean 16 | // @ConfigurationProperties(prefix = "security.oauth2.client") 17 | // public ClientCredentialsResourceDetails clientCredentialsResourceDetails() { 18 | // return new ClientCredentialsResourceDetails(); 19 | // } 20 | // 21 | // @Bean 22 | // public RequestInterceptor oauth2FeignRequestInterceptor(){ 23 | // return new OAuth2FeignRequestInterceptor(new DefaultOAuth2ClientContext(), clientCredentialsResourceDetails()); 24 | // } 25 | // 26 | // @Bean 27 | // public OAuth2RestTemplate clientCredentialsRestTemplate() { 28 | // return new OAuth2RestTemplate(clientCredentialsResourceDetails()); 29 | // } 30 | //} 31 | // 32 | -------------------------------------------------------------------------------- /javayh-demo/javayh-demo-feign/src/main/java/com/javayh/feign/conf/TokenFeignClientInterceptor.java: -------------------------------------------------------------------------------- 1 | //package com.javayh.feign.conf; 2 | // 3 | //import com.javayh.common.util.servlet.RequestUtils; 4 | //import feign.RequestInterceptor; 5 | //import feign.RequestTemplate; 6 | //import org.springframework.context.annotation.Configuration; 7 | //import org.springframework.security.core.Authentication; 8 | //import org.springframework.security.core.context.SecurityContext; 9 | //import org.springframework.security.core.context.SecurityContextHolder; 10 | //import org.springframework.security.oauth2.provider.authentication.OAuth2AuthenticationDetails; 11 | //import org.springframework.web.context.request.RequestAttributes; 12 | //import org.springframework.web.context.request.RequestContextHolder; 13 | //import org.springframework.web.context.request.ServletRequestAttributes; 14 | // 15 | //import javax.servlet.http.HttpServletRequest; 16 | // 17 | ///** 18 | // *19 | // * feign添加token 20 | // *
21 | // * 22 | // * @author Dylan-haiji 23 | // * @version 1.0.0 24 | // * @since 2020-04-08 22:33 25 | // */ 26 | //@Configuration 27 | //public class TokenFeignClientInterceptor implements RequestInterceptor { 28 | // 29 | // 30 | // private final String AUTHORIZATION_HEADER = "Authorization"; 31 | // private final String BEARER_TOKEN_TYPE = "Bearer"; 32 | // 33 | // @Override 34 | // public void apply(RequestTemplate requestTemplate) { 35 | // SecurityContext securityContext = SecurityContextHolder.getContext(); 36 | // Authentication authentication = securityContext.getAuthentication(); 37 | // if (authentication != null && authentication.getDetails() instanceof OAuth2AuthenticationDetails) { 38 | // OAuth2AuthenticationDetails details = (OAuth2AuthenticationDetails) authentication.getDetails(); 39 | // requestTemplate.header(AUTHORIZATION_HEADER, String.format("%s %s", BEARER_TOKEN_TYPE, details.getTokenValue())); 40 | // } 41 | // 42 | // } 43 | // 44 | //} 45 | -------------------------------------------------------------------------------- /javayh-demo/javayh-demo-feign/src/main/java/com/javayh/feign/service/impl/DemoFeignServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.javayh.feign.service.impl; 2 | 3 | import org.springframework.stereotype.Service; 4 | import org.springframework.web.bind.annotation.GetMapping; 5 | import org.springframework.web.bind.annotation.ResponseBody; 6 | 7 | /** 8 | *9 | * 接口实现 10 | *
11 | * 12 | * @author Dylan-haiji 13 | * @version 1.0.0 14 | * @since 2020-03-02 13:37 15 | */ 16 | @Service 17 | public class DemoFeignServiceImpl { 18 | 19 | // @GetMapping(value = "/feign/getFeign") 20 | public String getFeign() { 21 | return "Feign Success"; 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /javayh-demo/javayh-demo-feign/src/main/java/com/javayh/feign/service/resource/UserService.java: -------------------------------------------------------------------------------- 1 | package com.javayh.feign.service.resource; 2 | 3 | import com.javayh.common.result.ResultData; 4 | import org.springframework.cloud.openfeign.FeignClient; 5 | import org.springframework.context.annotation.Configuration; 6 | import org.springframework.stereotype.Service; 7 | import org.springframework.web.bind.annotation.GetMapping; 8 | 9 | /** 10 | *11 | * 通过feign调用资源服务器 12 | *
13 | * 14 | * @author Dylan-haiji 15 | * @version 1.0.0 16 | * @since 2020-04-08 22:22 17 | */ 18 | 19 | @FeignClient 20 | ( name = "javayh-resource", 21 | fallback = ResourceFallback.class 22 | ) 23 | public interface UserService { 24 | 25 | /** 26 | *27 | * feign调用资源服务器 28 | *
29 | * @version 1.0.0 30 | * @author Dylan-haiji 31 | * @since 2020/4/8 32 | * @param username 33 | * @return com.javayh.common.result.ResultData 34 | */ 35 | @GetMapping(value = "/api/user/info") 36 | ResultData getByUserName(String username); 37 | } 38 | @Configuration 39 | class ResourceFallback implements UserService{ 40 | 41 | @Override 42 | public ResultData getByUserName(String username) { 43 | return ResultData.fail("service_call_exception"); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /javayh-demo/javayh-demo-feign/src/main/java/com/javayh/feign/web/FeignCtr.java: -------------------------------------------------------------------------------- 1 | package com.javayh.feign.web; 2 | 3 | import com.javayh.common.result.ResultData; 4 | import com.javayh.feign.service.impl.DemoFeignServiceImpl; 5 | import com.javayh.feign.service.resource.UserService; 6 | import io.swagger.annotations.Api; 7 | import io.swagger.annotations.ApiOperation; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.web.bind.annotation.GetMapping; 10 | import org.springframework.web.bind.annotation.RequestMapping; 11 | import org.springframework.web.bind.annotation.RestController; 12 | 13 | /** 14 | *15 | * 16 | *
17 | * 18 | * @author Dylan-haiji 19 | * @version 1.0.0 20 | * @since 2020-03-02 14:20 21 | */ 22 | @Api("测试 Swagger API") 23 | @RestController 24 | @RequestMapping(value = "/feign/") 25 | public class FeignCtr { 26 | 27 | @Autowired 28 | private DemoFeignServiceImpl demoFeignService; 29 | 30 | @Autowired 31 | private UserService userService; 32 | @ApiOperation(value = "测试 ", notes = "测试") 33 | @GetMapping(value = "getfeign") 34 | public ResultData get() { 35 | return ResultData.success(demoFeignService.getFeign()); 36 | } 37 | 38 | /** 39 | *40 | * 获取用户信息 41 | *
42 | * @version 1.0.0 43 | * @author Dylan-haiji 44 | * @since 2020/4/8 45 | * @param username 46 | * @return com.javayh.common.result.ResultData 47 | */ 48 | @GetMapping(value = "info") 49 | public ResultData getUser(String username) { 50 | return userService.getByUserName(username); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /javayh-demo/javayh-demo-feign/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 6061 3 | spring: 4 | application: 5 | name: ${artifactId} 6 | main: 7 | allow-bean-definition-overriding: true #当遇到同样名字的时候,是否允许覆盖注册 8 | profiles: 9 | active: ${profile.name} 10 | cloud: 11 | nacos: 12 | discovery: 13 | server-addr: ${discovery.server-addr} 14 | namespace: ${config.namespace} 15 | # ip: ${discovery.server-ip} 16 | config: 17 | server-addr: ${config.server-addr} 18 | namespace: ${config.namespace} 19 | file-extension: yaml 20 | shared-dataids: redis.yaml,mail.yaml,feignhystrix.yaml 21 | messages: 22 | basename: i18n.login.login,i18n.common.common,i18n.validation.validation 23 | #heartbeat: 24 | # server: 25 | # host: 127.0.0.1 26 | # port: 8001 27 | # channel-id: 101 28 | -------------------------------------------------------------------------------- /javayh-demo/javayh-demo-file/pom.xml: -------------------------------------------------------------------------------- 1 | 2 |8 | * file 启动类 9 | *
10 | * 11 | * @author Dylan-haiji 12 | * @version 1.0.0 13 | * @since 2020-05-07 14 | */ 15 | @JavayhBootApplication 16 | public class FileApplication { 17 | 18 | public static void main(String[] args) { 19 | SpringApplication.run(FileApplication.class,args); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /javayh-demo/javayh-demo-file/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 6065 3 | spring: 4 | application: 5 | name: ${artifactId} 6 | main: 7 | allow-bean-definition-overriding: true #当遇到同样名字的时候,是否允许覆盖注册 8 | profiles: 9 | active: ${profile.name} 10 | cloud: 11 | nacos: 12 | discovery: 13 | server-addr: ${discovery.server-addr} 14 | namespace: ${config.namespace} 15 | # ip: ${discovery.server-ip} 16 | config: 17 | server-addr: ${config.server-addr} 18 | namespace: ${config.namespace} 19 | file-extension: yaml 20 | shared-dataids: redis.yaml,mail.yaml,feignhystrix.yaml 21 | messages: 22 | basename: i18n.login.login,i18n.common.common,i18n.validation.validation 23 | #heartbeat: 24 | # server: 25 | # host: 127.0.0.1 26 | # port: 8001 27 | # channel-id: 101 28 | -------------------------------------------------------------------------------- /javayh-demo/javayh-demo-mail/pom.xml: -------------------------------------------------------------------------------- 1 | 2 |9 | * 10 | *
11 | * 12 | * @author Dylan-haiji 13 | * @version 1.0.0 14 | * @since 2020-03-08 14:55 15 | */ 16 | @EnableAutoInternationalization 17 | @JavayhBootApplication 18 | public class MailApplication { 19 | 20 | public static void main(String[] args) { 21 | SpringApplication.run(MailApplication.class, args); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /javayh-demo/javayh-demo-mail/src/main/java/com/javayh/mail/web/MailController.java: -------------------------------------------------------------------------------- 1 | package com.javayh.mail.web; 2 | 3 | import com.javayh.common.result.ResultData; 4 | import com.javayh.mail.entity.MailDO; 5 | import com.javayh.mail.server.MailSend; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.web.bind.annotation.PostMapping; 8 | import org.springframework.web.bind.annotation.RequestBody; 9 | import org.springframework.web.bind.annotation.RequestMapping; 10 | import org.springframework.web.bind.annotation.RestController; 11 | 12 | import java.util.HashMap; 13 | import java.util.Map; 14 | 15 | /** 16 | *17 | * 18 | *
19 | * 20 | * @author Dylan-haiji 21 | * @version 1.0.0 22 | * @since 2020-03-0:14 23 | */ 24 | @RestController 25 | @RequestMapping(value = "/mail/") 26 | public class MailController { 27 | 28 | @Autowired(required = false) 29 | private MailSend mailSenderUtil; 30 | 31 | /** 32 | *33 | * 34 | *
35 | * @version 1.0.0 36 | * @author Dylan-haiji 37 | * @since 2020/3/8 38 | * @param mailDO 39 | * @return com.javayh.common.result.ResultData 40 | */ 41 | @PostMapping(value = "send") 42 | public ResultData send(@RequestBody MailDO mailDO) { 43 | Map欢迎 同学:
5 | 6 |10 | * 成功启动后的操作 11 | *
12 | * 13 | * @author Dylan-haiji 14 | * @version 1.0.0 15 | * @since 2020-03-23 20:58 16 | */ 17 | @Slf4j 18 | public class MyCommandLineRunner implements CommandLineRunner { 19 | 20 | @Value("${spring.application.name}") 21 | private String applicationName; 22 | 23 | @Value("${server.port}") 24 | private String port; 25 | 26 | private String pr = "项目< "; 27 | 28 | private String sr = " >已启动 访问地址为:{}"; 29 | 30 | @Override 31 | public void run(String... args) throws Exception { 32 | log.info(pr + applicationName + sr, IPUtils.getHostIp() + ":" + port + "/"); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /javayh-dependencies/javayh-common-starter/src/main/java/com/javayh/common/constant/ConstantUtils.java: -------------------------------------------------------------------------------- 1 | package com.javayh.common.constant; 2 | 3 | /** 4 | *5 | * 公用常量 6 | *
7 | * 8 | * @author Dylan-haiji 9 | * @version 1.0.0 10 | * @since 2020-03-01 21:22 11 | */ 12 | public interface ConstantUtils { 13 | 14 | /** 统一消息提示 */ 15 | String SUCCESS_CODE = "0"; 16 | 17 | String FAIL_CODE = "1"; 18 | 19 | String SUCCESS_MSG = "success_msg"; 20 | 21 | String FAIL_MSG = "failure_msg"; 22 | 23 | String BUSINESS_DATA = "business_data"; 24 | 25 | String UTF = "UTF-8"; 26 | 27 | String PREFIX = "Java有货==>"; 28 | 29 | String NEWLINE = "\r\n"; 30 | 31 | int MAX_STACK_DEPTH = 100; 32 | } 33 | -------------------------------------------------------------------------------- /javayh-dependencies/javayh-common-starter/src/main/java/com/javayh/common/constant/EncryptConstantUtils.java: -------------------------------------------------------------------------------- 1 | package com.javayh.common.constant; 2 | 3 | /** 4 | *5 | * 加密常量 6 | *
7 | * 8 | * @author Dylan-haiji 9 | * @version 1.0.0 10 | * @since 2020-03-25 17:34 11 | */ 12 | public interface EncryptConstantUtils { 13 | 14 | String ALGORITHM_AES = "AES"; 15 | 16 | String INSTANCE = "AES/ECB/PKCS5Padding"; 17 | 18 | String FILL_STR = "0"; 19 | 20 | String SUFFIX_SHA = "20200202"; 21 | 22 | String SUFFIX_AES = "2020020220"; 23 | 24 | char[] HEXADECIMAL = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 25 | 'c', 'd', 'e', 'f' }; 26 | 27 | char[] DIGITS_LOWER = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 28 | 'c', 'd', 'e', 'f', 'g' }; 29 | 30 | char[] DIGITS_UPPER = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 31 | 'C', 'D', 'E', 'F', 'G' }; 32 | 33 | String MD5 = "MD5"; 34 | 35 | String KEY_ALGORITHM = "RSA"; 36 | 37 | String PUBLIC_KEY = "RSAPublicKey"; 38 | 39 | String PRIVATE_KEY = "RSAPrivateKey"; 40 | 41 | String ALGORITHM = "RSA/ECB/PKCS1Padding"; 42 | 43 | String SHA = "SHA-256"; 44 | 45 | } 46 | -------------------------------------------------------------------------------- /javayh-dependencies/javayh-common-starter/src/main/java/com/javayh/common/encrypt/key/DataKeyGenerator.java: -------------------------------------------------------------------------------- 1 | package com.javayh.common.encrypt.key; 2 | 3 | import com.javayh.common.constant.EncryptConstantUtils; 4 | import com.javayh.common.encrypt.md5.MD5Util; 5 | import lombok.extern.slf4j.Slf4j; 6 | 7 | import javax.crypto.KeyGenerator; 8 | import javax.crypto.SecretKey; 9 | import java.security.SecureRandom; 10 | 11 | /** 12 | *13 | * 系统生成datakey 14 | *
15 | * 16 | * @author Dylan-haiji 17 | * @version 1.0.0 18 | * @since 2020-03-24 15:40 19 | */ 20 | @Slf4j 21 | public class DataKeyGenerator { 22 | 23 | /** 24 | *25 | * 安全随机种子 26 | *
27 | * @version 1.0.0 28 | * @author Dylan-haiji 29 | * @since 2020/3/24 30 | * @param keySize 31 | * @param seed 32 | * @return java.lang.String 33 | */ 34 | public static String getInstanceKey(int keySize, long seed) { 35 | String key = ""; 36 | try { 37 | KeyGenerator generator = KeyGenerator 38 | .getInstance(EncryptConstantUtils.ALGORITHM_AES); 39 | SecureRandom random = new SecureRandom(); 40 | random.setSeed(seed); 41 | generator.init(keySize, random); 42 | SecretKey secretKey = generator.generateKey(); 43 | key = MD5Util.hash32(new String(secretKey.getEncoded())); 44 | } 45 | catch (Exception e) { 46 | log.error("DataKeyGenerator NoSuchAlgorithmException{}", e.getMessage()); 47 | } 48 | return key; 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /javayh-dependencies/javayh-common-starter/src/main/java/com/javayh/common/encrypt/md5/MD5Util.java: -------------------------------------------------------------------------------- 1 | package com.javayh.common.encrypt.md5; 2 | 3 | import com.javayh.common.constant.ConstantUtils; 4 | import com.javayh.common.constant.EncryptConstantUtils; 5 | import lombok.extern.slf4j.Slf4j; 6 | 7 | import java.security.MessageDigest; 8 | 9 | /** 10 | *11 | * 12 | *
13 | * 14 | * @author Dylan-haiji 15 | * @version 1.0.0 16 | * @since 2020-03-24 21:22 17 | */ 18 | @Slf4j 19 | public class MD5Util { 20 | 21 | /** 22 | *23 | * MD5 进行hash取模 24 | *
25 | * @version 1.0.0 26 | * @author Dylan-haiji 27 | * @since 2020/3/24 28 | * @param s 29 | * @return java.lang.String 30 | */ 31 | public static String hash32(String s) { 32 | try { 33 | byte[] btInput = s.getBytes(); 34 | // 获得MD5摘要算法的 MessageDigest 对象 35 | MessageDigest mdInst = MessageDigest.getInstance(EncryptConstantUtils.MD5); 36 | // 使用指定的字节更新摘要 37 | mdInst.update(btInput); 38 | // 获得密文 39 | byte[] md = mdInst.digest(); 40 | // 把密文转换成十六进制的字符串形式 41 | int j = md.length; 42 | char[] str = new char[j * 2]; 43 | int k = 0; 44 | for (int i = 0; i < j; i++) { 45 | byte byte0 = md[i]; 46 | str[k++] = EncryptConstantUtils.HEXADECIMAL[byte0 >>> 4 & 0xf]; 47 | str[k++] = EncryptConstantUtils.HEXADECIMAL[byte0 & 0xf]; 48 | } 49 | return new String(str); 50 | } 51 | catch (Exception e) { 52 | log.error("MD5 hash32 Exception {}", e.getMessage()); 53 | return null; 54 | } 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /javayh-dependencies/javayh-common-starter/src/main/java/com/javayh/common/entity/BaseEntity.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright [2020] [Yang Hai Ji of copyright owner] 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.javayh.common.entity; 17 | 18 | import com.fasterxml.jackson.annotation.JsonFormat; 19 | import lombok.AllArgsConstructor; 20 | import lombok.Data; 21 | import lombok.Getter; 22 | import lombok.NoArgsConstructor; 23 | import lombok.Setter; 24 | import org.springframework.format.annotation.DateTimeFormat; 25 | 26 | import javax.validation.constraints.Min; 27 | import java.io.Serializable; 28 | import java.util.Date; 29 | import java.util.Objects; 30 | 31 | /** 32 | *33 | * 常用字段 34 | * 35 | * @DateTimeFormat(pattern = "yyyy-MM-dd") 36 | *
37 | * @author Dylan-haiji 38 | * @version 1.0.0 39 | * @since 2020-04-03 10:43 40 | */ 41 | @AllArgsConstructor 42 | @NoArgsConstructor 43 | @Data 44 | public class BaseEntity7 | * 基础异常 8 | *
9 | * 10 | * @author Dylan-haiji 11 | * @version 1.0.0 12 | * @since 2020-03-01 21:30 13 | */ 14 | public class BaseException extends RuntimeException { 15 | 16 | private static final long serialVersionUID = 7859712770754900356L; 17 | 18 | public BaseException(String msg) { 19 | super(msg); 20 | } 21 | 22 | public BaseException(Exception e) { 23 | this(e.getMessage()); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /javayh-dependencies/javayh-common-starter/src/main/java/com/javayh/common/exception/GlobalExceptionHandler.java: -------------------------------------------------------------------------------- 1 | package com.javayh.common.exception; 2 | 3 | import com.javayh.common.result.ResultData; 4 | import com.javayh.common.util.log.Log; 5 | import lombok.extern.slf4j.Slf4j; 6 | import org.springframework.validation.FieldError; 7 | import org.springframework.web.bind.MethodArgumentNotValidException; 8 | import org.springframework.web.bind.annotation.ExceptionHandler; 9 | import org.springframework.web.bind.annotation.RestControllerAdvice; 10 | 11 | import java.sql.SQLException; 12 | import java.util.List; 13 | 14 | /** 15 | *16 | * 全局异常 17 | *
18 | * 19 | * @author Dylan-haiji 20 | * @version 1.0.0 21 | * @since 2020-03-01 21:36 22 | */ 23 | @Slf4j 24 | @RestControllerAdvice 25 | public class GlobalExceptionHandler { 26 | 27 | /** 28 | *29 | * 全局Base异常处理 30 | *
31 | * @version 1.0.0 32 | * @author Dylan 33 | * @since 2020/2/27 34 | * @param e 35 | */ 36 | @ExceptionHandler({ BaseException.class }) 37 | public ResultData customExceptionHandler(BaseException e) { 38 | Log.error("全局Base异常处理", e.getStackTrace()); 39 | return ResultData.fail(e.getMessage()); 40 | } 41 | 42 | /** 43 | *44 | * 其他类型的异常处理 45 | *
46 | * @version 1.0.0 47 | * @author Dylan 48 | * @since 2020/2/27 49 | * @param e 50 | */ 51 | @ExceptionHandler({ Exception.class }) 52 | public ResultData exceptionHandler(Exception e) { 53 | Log.error("未知的运行异常", e.getStackTrace()); 54 | return ResultData.fail(); 55 | } 56 | 57 | /** 58 | *59 | * 参数异常处理 60 | *
61 | * @version 1.0.0 62 | * @author Dylan-haiji 63 | * @since 2020/2/28 64 | * @param exception 65 | */ 66 | @ExceptionHandler(value = MethodArgumentNotValidException.class) 67 | public ResultData methodNotValidHandler(MethodArgumentNotValidException exception) { 68 | Log.error("参数异常处理", exception.getStackTrace()); 69 | List15 | * 自定义启动类注解,以免多次引用 16 | *
17 | * 18 | * @author Dylan-haiji 19 | * @version 1.0.0 20 | * @since 2020-03-02 14:35 21 | */ 22 | @Target({ ElementType.TYPE }) 23 | @Retention(RetentionPolicy.RUNTIME) 24 | @Documented 25 | @Inherited 26 | @Import({ ExceptionSelector.class }) 27 | public @interface EnableAutoException { 28 | 29 | } 30 | -------------------------------------------------------------------------------- /javayh-dependencies/javayh-common-starter/src/main/java/com/javayh/common/exception/business/BusinessException.java: -------------------------------------------------------------------------------- 1 | package com.javayh.common.exception.business; 2 | 3 | import com.javayh.common.constant.ConstantUtils; 4 | import com.javayh.common.exception.BaseException; 5 | 6 | /** 7 | *8 | * 业务参数异常 9 | *
10 | * 11 | * @author Dylan-haiji 12 | * @version 1.0.0 13 | * @since 2020-03-01 21:34 14 | */ 15 | public class BusinessException extends BaseException { 16 | 17 | public BusinessException() { 18 | super(ConstantUtils.BUSINESS_DATA); 19 | } 20 | 21 | public BusinessException(String msg) { 22 | super(msg); 23 | } 24 | 25 | } -------------------------------------------------------------------------------- /javayh-dependencies/javayh-common-starter/src/main/java/com/javayh/common/exception/controller/ControllerException.java: -------------------------------------------------------------------------------- 1 | package com.javayh.common.exception.controller; 2 | 3 | import com.javayh.common.exception.BaseException; 4 | 5 | /** 6 | *7 | * controller 异常 8 | *
9 | * 10 | * @version 1.0.0 11 | * @author Dylan-haiji 12 | * @since 2020/3/1 13 | */ 14 | public class ControllerException extends BaseException { 15 | 16 | /** 17 | * 18 | */ 19 | private static final long serialVersionUID = 1412104290896291466L; 20 | 21 | public ControllerException(String msg) { 22 | super(msg); 23 | } 24 | 25 | public ControllerException(Exception e) { 26 | this(e.getMessage()); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /javayh-dependencies/javayh-common-starter/src/main/java/com/javayh/common/exception/dao/DataAccessException.java: -------------------------------------------------------------------------------- 1 | package com.javayh.common.exception.dao; 2 | 3 | import com.javayh.common.exception.BaseException; 4 | 5 | /** 6 | *7 | * 数据库异常 8 | *
9 | * 10 | * @version 1.0.0 11 | * @author Dylan-haiji 12 | * @since 2020/3/1 13 | */ 14 | public class DataAccessException extends BaseException { 15 | 16 | private static final long serialVersionUID = 8325096920926406459L; 17 | 18 | public DataAccessException(String msg) { 19 | super(msg); 20 | } 21 | 22 | public DataAccessException(Exception e) { 23 | this(e.getMessage()); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /javayh-dependencies/javayh-common-starter/src/main/java/com/javayh/common/exception/hystrix/HytrixException.java: -------------------------------------------------------------------------------- 1 | package com.javayh.common.exception.hystrix; 2 | 3 | import com.netflix.hystrix.exception.HystrixBadRequestException; 4 | 5 | /** 6 | *7 | * feign client 避免熔断异常处理 8 | *
9 | * 10 | * @version 1.0.0 11 | * @author Dylan-haiji 12 | * @since 2020/3/1 13 | */ 14 | public class HytrixException extends HystrixBadRequestException { 15 | 16 | private static final long serialVersionUID = -2437160791033393978L; 17 | 18 | public HytrixException(String msg) { 19 | super(msg); 20 | } 21 | 22 | public HytrixException(Exception e) { 23 | this(e.getMessage()); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /javayh-dependencies/javayh-common-starter/src/main/java/com/javayh/common/exception/service/ServiceException.java: -------------------------------------------------------------------------------- 1 | package com.javayh.common.exception.service; 2 | 3 | import com.javayh.common.exception.BaseException; 4 | 5 | /** 6 | *7 | * service处理异常 controller处理 8 | *
9 | * 10 | * @version 1.0.0 11 | * @author Dylan-haiji 12 | * @since 2020/3/1 13 | */ 14 | public class ServiceException extends BaseException { 15 | 16 | /** 17 | * 18 | */ 19 | private static final long serialVersionUID = -2437160791033393978L; 20 | 21 | public ServiceException(String msg) { 22 | super(msg); 23 | } 24 | 25 | public ServiceException(Exception e) { 26 | this(e.getMessage()); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /javayh-dependencies/javayh-common-starter/src/main/java/com/javayh/common/feign/FeignClientOkHttpConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.javayh.common.feign; 2 | 3 | import feign.Feign; 4 | import okhttp3.ConnectionPool; 5 | import okhttp3.OkHttpClient; 6 | import org.springframework.boot.autoconfigure.AutoConfigureBefore; 7 | import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; 8 | import org.springframework.cloud.openfeign.FeignAutoConfiguration; 9 | import org.springframework.context.annotation.Bean; 10 | import org.springframework.context.annotation.Configuration; 11 | 12 | import java.util.concurrent.TimeUnit; 13 | 14 | /** 15 | *16 | * Feign Client 17 | *
18 | * 19 | * @author Yang Haiji 20 | * @version 1.0.0 21 | * @since 2020-05-04 12:13 22 | */ 23 | @ConditionalOnClass(Feign.class) 24 | @AutoConfigureBefore(FeignAutoConfiguration.class) 25 | public class FeignClientOkHttpConfiguration { 26 | 27 | @Bean 28 | public OkHttpClient okHttpClient() { 29 | return new OkHttpClient.Builder() 30 | // 连接超时 31 | .connectTimeout(30, TimeUnit.SECONDS) 32 | // 响应超时 33 | .readTimeout(30, TimeUnit.SECONDS) 34 | // 写超时 35 | .writeTimeout(30, TimeUnit.SECONDS) 36 | // 是否自动重连 37 | .retryOnConnectionFailure(true) 38 | // 连接池 39 | .connectionPool(new ConnectionPool()) 40 | .build(); 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /javayh-dependencies/javayh-common-starter/src/main/java/com/javayh/common/feign/FeignFailResult.java: -------------------------------------------------------------------------------- 1 | package com.javayh.common.feign; 2 | 3 | import lombok.Data; 4 | 5 | /** 6 | *7 | * feign异常返回 8 | *
9 | * 10 | * @version 1.0.0 11 | * @author Dylan-haiji 12 | * @since 2020/3/2 13 | */ 14 | @Data 15 | public class FeignFailResult { 16 | 17 | private int status; 18 | 19 | private String resp_msg; 20 | 21 | } 22 | -------------------------------------------------------------------------------- /javayh-dependencies/javayh-common-starter/src/main/java/com/javayh/common/feign/GlobalFeignConfig.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright [2020] [Yang Hai Ji of copyright owner] 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.javayh.common.feign; 17 | 18 | import feign.Logger; 19 | import feign.Request; 20 | import feign.Retryer; 21 | import org.springframework.context.annotation.Bean; 22 | 23 | import static java.util.concurrent.TimeUnit.SECONDS; 24 | 25 | /** 26 | *27 | * feign全局 日志输出 28 | *
29 | * 30 | * @version 1.0.0 31 | * @author Dylan-haiji 32 | * @since 2020/3/2 33 | */ 34 | public class GlobalFeignConfig { 35 | 36 | /** 37 | *38 | * 打印请求日志 39 | *
40 | * @version 1.0.0 41 | * @author Dylan-haiji 42 | * @since 2020/4/9 43 | * @param 44 | * @return feign.Logger.Level 45 | */ 46 | @Bean 47 | public feign.Logger.Level multipartLoggerLevel() { 48 | return feign.Logger.Level.FULL; 49 | } 50 | 51 | 52 | /** 53 | * 配置请求重试 54 | * 55 | */ 56 | @Bean 57 | public Retryer feignRetry() { 58 | return new Retryer.Default(200, SECONDS.toMillis(2), 10); 59 | } 60 | 61 | 62 | /** 63 | * 设置请求超时时间 64 | *默认 65 | * public Options() { 66 | * this(10 * 1000, 60 * 1000); 67 | * } 68 | * 69 | */ 70 | @Bean 71 | Request.Options feignOptions() { 72 | return new Request.Options(60 * 1000, 60 * 1000); 73 | } 74 | 75 | } 76 | -------------------------------------------------------------------------------- /javayh-dependencies/javayh-common-starter/src/main/java/com/javayh/common/i18n/annotation/EnableAutoInternationalization.java: -------------------------------------------------------------------------------- 1 | package com.javayh.common.i18n.annotation; 2 | 3 | import com.javayh.common.selector.SpringI18nSelector; 4 | import org.springframework.context.annotation.Import; 5 | 6 | import java.lang.annotation.Documented; 7 | import java.lang.annotation.ElementType; 8 | import java.lang.annotation.Inherited; 9 | import java.lang.annotation.Retention; 10 | import java.lang.annotation.RetentionPolicy; 11 | import java.lang.annotation.Target; 12 | 13 | /** 14 | *15 | * 自定义启动类注解,以免多次引用 16 | *
17 | * 18 | * @author Dylan-haiji 19 | * @version 1.0.0 20 | * @since 2020-03-02 14:35 21 | */ 22 | @Target({ ElementType.TYPE }) 23 | @Retention(RetentionPolicy.RUNTIME) 24 | @Documented 25 | @Inherited 26 | @Import({ SpringI18nSelector.class }) 27 | public @interface EnableAutoInternationalization { 28 | 29 | } 30 | -------------------------------------------------------------------------------- /javayh-dependencies/javayh-common-starter/src/main/java/com/javayh/common/i18n/config/I18nProperties.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright [2020] [Yang Hai Ji of copyright owner] 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.javayh.common.i18n.config; 17 | 18 | import org.springframework.boot.context.properties.ConfigurationProperties; 19 | 20 | /** 21 | *22 | * 国际化 23 | *
24 | * 25 | * @author Dylan-haiji 26 | * @version 1.0.0 27 | * @since 2020-03-27 15:23 28 | */ 29 | @ConfigurationProperties( 30 | prefix = "spring.messages", 31 | ignoreUnknownFields = true 32 | ) 33 | public class I18nProperties { 34 | 35 | private String basename; 36 | 37 | public String getBasename() { 38 | return basename; 39 | } 40 | 41 | public void setBasename(String basename) { 42 | this.basename = basename; 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /javayh-dependencies/javayh-common-starter/src/main/java/com/javayh/common/mdc/MdcThreadPoolTaskExecutor.java: -------------------------------------------------------------------------------- 1 | package com.javayh.common.mdc; 2 | 3 | import org.slf4j.MDC; 4 | import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; 5 | 6 | import java.util.Map; 7 | 8 | /** 9 | * 这是{@link ThreadPoolTaskExecutor}的一个简单替换,可以在每个任务之前设置子线程的MDC数据。 10 | * 11 | * 在记录日志的时候,一般情况下我们会使用MDC来存储每个线程的特有参数,如身份信息等,以便更好的查询日志。 12 | * 但是Logback在最新的版本中因为性能问题,不会自动的将MDC的内存传给子线程。所以Logback建议在执行异步线程前 13 | * 先通过MDC.getCopyOfContextMap()方法将MDC内存获取出来,再传给线程。 14 | * 并在子线程的执行的最开始调用MDC.setContextMap(context)方法将父线程的MDC内容传给子线程。 15 | *
16 | * https://logback.qos.ch/manual/mdc.html
17 | *
18 | * @author yuhao.wang3
19 | */
20 | public class MdcThreadPoolTaskExecutor extends ThreadPoolTaskExecutor {
21 |
22 | /**
23 | * 所有线程都会委托给这个execute方法,在这个方法中我们把父线程的MDC内容赋值给子线程
24 | * https://logback.qos.ch/manual/mdc.html#managedThreads
25 | * @param runnable
26 | */
27 | @Override
28 | public void execute(Runnable runnable) {
29 | /* 获取父线程MDC中的内容,必须在run方法之前,否则等异步线程执行的时候有可能MDC里面的值已经被清空了,这个时候就会返回null */
30 | Map
3 | * 内部支持 http://patorjk.com/software/taag/#p=display&f=Graffiti&t=Type%20Something%20
4 | *
13 | * 心跳健康消息体
14 | *
8 | * 实例化
9 | *
8 | * 实例化
9 | *
8 | * 实例化
9 | *
7 | * 其他附属操作
8 | *
18 | * 执行器
19 | *
12 | * 获取Ip
13 | *
9 | * 流水号生产
10 | *
22 | * 生产流水号
23 | *
7 | *
8 | *
18 | * 加言处理
19 | *
9 | * copy
10 | *
21 | * 对象Copy
22 | *
37 | * 对象Copy
38 | *
15 | * 文件操作
16 | *
49 | * 创建文件
50 | *
7 | * id生成器
8 | *
18 | * uuid
19 | *
32 | * 去除 - 的uuid
33 | *
15 | * Log记录
16 | *
31 | * 统一日志输出
32 | *
10 | * 获取Request
11 | *
10 | * spring获取bean
11 | *
9 | * 线程池
10 | *