From 66cc252f43b951e3eedb22b4f4c19686dbfeb96f Mon Sep 17 00:00:00 2001 From: typ Date: Wed, 8 Apr 2026 19:31:02 +0800 Subject: [PATCH] start... --- .gitignore | 33 +++++++++++++++++++++++++++++++++ logs/springboot-logback-error.log | 35 +++++++++++++++++++++++++++++++++++ logs/springboot-logback-info.log | 148 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ logs/springboot-logback/error/2022-06-25-0.log.gz | Bin 0 -> 883 bytes logs/springboot-logback/error/2022-12-27-0.log.gz | Bin 0 -> 2725 bytes logs/springboot-logback/info/2022-10-28-0.log.gz | Bin 0 -> 14565 bytes logs/springboot-logback/info/2022-12-27-0.log.gz | Bin 0 -> 1279 bytes mvnw | 310 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ mvnw.cmd | 182 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ pom.xml | 146 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/main/java/com/meishu/MeishuApplication.java | 22 ++++++++++++++++++++++ src/main/java/com/meishu/common/Code.java | 45 +++++++++++++++++++++++++++++++++++++++++++++ src/main/java/com/meishu/common/ResponseData.java | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/main/java/com/meishu/common/ResponseVO.java | 21 +++++++++++++++++++++ src/main/java/com/meishu/common/configure/MybatisPlusConfig.java | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/main/java/com/meishu/common/configure/RemoteProperties.java | 36 ++++++++++++++++++++++++++++++++++++ src/main/java/com/meishu/common/configure/WebLogAspect.java | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/main/java/com/meishu/common/constant/Code.java | 33 +++++++++++++++++++++++++++++++++ src/main/java/com/meishu/common/constant/WxConstant.java | 35 +++++++++++++++++++++++++++++++++++ src/main/java/com/meishu/common/exception/GlobalExceptionHandler.java | 119 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/main/java/com/meishu/common/exception/HttpException.java | 45 +++++++++++++++++++++++++++++++++++++++++++++ src/main/java/com/meishu/common/handler/MetaHandler.java | 26 ++++++++++++++++++++++++++ src/main/java/com/meishu/common/interceptor/AuthenticationInterceptor.java | 18 ++++++++++++++++++ src/main/java/com/meishu/common/interceptor/LoginRequired.java | 20 ++++++++++++++++++++ src/main/java/com/meishu/config/IpWhitelistInterceptor.java | 41 +++++++++++++++++++++++++++++++++++++++++ src/main/java/com/meishu/config/WebConfig.java | 21 +++++++++++++++++++++ src/main/java/com/meishu/controller/AuthController.java | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/main/java/com/meishu/controller/TestController.java | 36 ++++++++++++++++++++++++++++++++++++ src/main/java/com/meishu/controller/TicketController.java | 43 +++++++++++++++++++++++++++++++++++++++++++ src/main/java/com/meishu/mapper/AuthTicketMapper.java | 9 +++++++++ src/main/java/com/meishu/model/AuthTicket.java | 26 ++++++++++++++++++++++++++ src/main/java/com/meishu/service/AuthTicketService.java | 8 ++++++++ src/main/java/com/meishu/service/impl/AuthTicketServiceImpl.java | 11 +++++++++++ src/main/java/com/meishu/util/BaseModel.java | 35 +++++++++++++++++++++++++++++++++++ src/main/java/com/meishu/util/CodeGenerator.java | 126 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/main/java/com/meishu/util/Result.java | 24 ++++++++++++++++++++++++ src/main/java/com/meishu/util/excel/ExcelColumnUtil.java | 21 +++++++++++++++++++++ src/main/java/com/meishu/util/excel/ExcelUtil.java | 574 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/main/resources/application-dev.properties | 31 +++++++++++++++++++++++++++++++ src/main/resources/application-prod.properties | 31 +++++++++++++++++++++++++++++++ src/main/resources/application.properties | 37 +++++++++++++++++++++++++++++++++++++ src/main/resources/code.properties | 43 +++++++++++++++++++++++++++++++++++++++++++ src/main/resources/logback-spring.xml | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/main/resources/mapper/AuthTicketMapper.xml | 4 ++++ src/main/resources/mybatis-plus.properties | 12 ++++++++++++ src/main/resources/mybatis.xml | 9 +++++++++ src/main/resources/templates/controller.java.ftl | 41 +++++++++++++++++++++++++++++++++++++++++ src/main/resources/templates/entity.java.ftl | 156 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/main/resources/templates/mapper.java.ftl | 22 ++++++++++++++++++++++ src/main/resources/templates/mapper.xml.ftl | 39 +++++++++++++++++++++++++++++++++++++++ src/main/resources/templates/service.java.ftl | 20 ++++++++++++++++++++ src/main/resources/templates/serviceImpl.java.ftl | 26 ++++++++++++++++++++++++++ 52 files changed, 3027 insertions(+) create mode 100644 .gitignore create mode 100644 logs/springboot-logback-error.log create mode 100644 logs/springboot-logback-info.log create mode 100644 logs/springboot-logback/error/2022-06-25-0.log.gz create mode 100644 logs/springboot-logback/error/2022-12-27-0.log.gz create mode 100644 logs/springboot-logback/info/2022-10-28-0.log.gz create mode 100644 logs/springboot-logback/info/2022-12-27-0.log.gz create mode 100644 mvnw create mode 100644 mvnw.cmd create mode 100644 pom.xml create mode 100644 src/main/java/com/meishu/MeishuApplication.java create mode 100644 src/main/java/com/meishu/common/Code.java create mode 100644 src/main/java/com/meishu/common/ResponseData.java create mode 100644 src/main/java/com/meishu/common/ResponseVO.java create mode 100644 src/main/java/com/meishu/common/configure/MybatisPlusConfig.java create mode 100644 src/main/java/com/meishu/common/configure/RemoteProperties.java create mode 100644 src/main/java/com/meishu/common/configure/WebLogAspect.java create mode 100644 src/main/java/com/meishu/common/constant/Code.java create mode 100644 src/main/java/com/meishu/common/constant/WxConstant.java create mode 100644 src/main/java/com/meishu/common/exception/GlobalExceptionHandler.java create mode 100644 src/main/java/com/meishu/common/exception/HttpException.java create mode 100644 src/main/java/com/meishu/common/handler/MetaHandler.java create mode 100644 src/main/java/com/meishu/common/interceptor/AuthenticationInterceptor.java create mode 100644 src/main/java/com/meishu/common/interceptor/LoginRequired.java create mode 100644 src/main/java/com/meishu/config/IpWhitelistInterceptor.java create mode 100644 src/main/java/com/meishu/config/WebConfig.java create mode 100644 src/main/java/com/meishu/controller/AuthController.java create mode 100644 src/main/java/com/meishu/controller/TestController.java create mode 100644 src/main/java/com/meishu/controller/TicketController.java create mode 100644 src/main/java/com/meishu/mapper/AuthTicketMapper.java create mode 100644 src/main/java/com/meishu/model/AuthTicket.java create mode 100644 src/main/java/com/meishu/service/AuthTicketService.java create mode 100644 src/main/java/com/meishu/service/impl/AuthTicketServiceImpl.java create mode 100644 src/main/java/com/meishu/util/BaseModel.java create mode 100644 src/main/java/com/meishu/util/CodeGenerator.java create mode 100644 src/main/java/com/meishu/util/Result.java create mode 100644 src/main/java/com/meishu/util/excel/ExcelColumnUtil.java create mode 100644 src/main/java/com/meishu/util/excel/ExcelUtil.java create mode 100644 src/main/resources/application-dev.properties create mode 100644 src/main/resources/application-prod.properties create mode 100644 src/main/resources/application.properties create mode 100644 src/main/resources/code.properties create mode 100644 src/main/resources/logback-spring.xml create mode 100644 src/main/resources/mapper/AuthTicketMapper.xml create mode 100644 src/main/resources/mybatis-plus.properties create mode 100644 src/main/resources/mybatis.xml create mode 100644 src/main/resources/templates/controller.java.ftl create mode 100644 src/main/resources/templates/entity.java.ftl create mode 100644 src/main/resources/templates/mapper.java.ftl create mode 100644 src/main/resources/templates/mapper.xml.ftl create mode 100644 src/main/resources/templates/service.java.ftl create mode 100644 src/main/resources/templates/serviceImpl.java.ftl diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..549e00a --- /dev/null +++ b/.gitignore @@ -0,0 +1,33 @@ +HELP.md +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ diff --git a/logs/springboot-logback-error.log b/logs/springboot-logback-error.log new file mode 100644 index 0000000..455f101 --- /dev/null +++ b/logs/springboot-logback-error.log @@ -0,0 +1,35 @@ +2026-04-02 20:33:04,264 [main] ERROR org.springframework.boot.SpringApplication:871 - Application run failed +org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'authController': Injection of autowired dependencies failed; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'auth.ticket-expire' in value "${auth.ticket-expire}" + at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:405) + at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1413) + at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:601) + at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:524) + at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) + at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) + at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) + at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) + at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:944) + at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918) + at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583) + at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:144) + at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:782) + at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:774) + at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:439) + at org.springframework.boot.SpringApplication.run(SpringApplication.java:339) + at org.springframework.boot.SpringApplication.run(SpringApplication.java:1340) + at org.springframework.boot.SpringApplication.run(SpringApplication.java:1329) + at com.meishu.MeishuApplication.main(MeishuApplication.java:19) +Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'auth.ticket-expire' in value "${auth.ticket-expire}" + at org.springframework.util.PropertyPlaceholderHelper.parseStringValue(PropertyPlaceholderHelper.java:178) + at org.springframework.util.PropertyPlaceholderHelper.replacePlaceholders(PropertyPlaceholderHelper.java:124) + at org.springframework.core.env.AbstractPropertyResolver.doResolvePlaceholders(AbstractPropertyResolver.java:239) + at org.springframework.core.env.AbstractPropertyResolver.resolveRequiredPlaceholders(AbstractPropertyResolver.java:210) + at org.springframework.context.support.PropertySourcesPlaceholderConfigurer.lambda$processProperties$0(PropertySourcesPlaceholderConfigurer.java:175) + at org.springframework.beans.factory.support.AbstractBeanFactory.resolveEmbeddedValue(AbstractBeanFactory.java:936) + at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1321) + at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1300) + at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:657) + at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:640) + at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:119) + at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:399) + ... 18 common frames omitted diff --git a/logs/springboot-logback-info.log b/logs/springboot-logback-info.log new file mode 100644 index 0000000..580a2ef --- /dev/null +++ b/logs/springboot-logback-info.log @@ -0,0 +1,148 @@ +2026-04-02 20:33:01,023 [main] INFO com.meishu.MeishuApplication:55 - Starting MeishuApplication using Java 1.8.0_201 on LAPTOP-KO8E5S7F with PID 15008 (D:\code\authen\target\classes started by everior in D:\code\authen) +2026-04-02 20:33:01,029 [main] INFO com.meishu.MeishuApplication:679 - The following profiles are active: dev +2026-04-02 20:33:02,202 [main] INFO org.springframework.boot.web.embedded.tomcat.TomcatWebServer:108 - Tomcat initialized with port(s): 23451 (http) +2026-04-02 20:33:02,212 [main] INFO org.apache.coyote.http11.Http11NioProtocol:173 - Initializing ProtocolHandler ["http-nio-23451"] +2026-04-02 20:33:02,212 [main] INFO org.apache.catalina.core.StandardService:173 - Starting service [Tomcat] +2026-04-02 20:33:02,215 [main] INFO org.apache.catalina.core.StandardEngine:173 - Starting Servlet engine: [Apache Tomcat/9.0.45] +2026-04-02 20:33:02,290 [main] INFO org.apache.catalina.core.ContainerBase.[Tomcat].[localhost].[/]:173 - Initializing Spring embedded WebApplicationContext +2026-04-02 20:33:02,290 [main] INFO org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext:289 - Root WebApplicationContext: initialization completed in 1209 ms +2026-04-02 20:33:02,469 [main] INFO com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure:56 - Init DruidDataSource +2026-04-02 20:33:03,589 [main] INFO com.alibaba.druid.pool.DruidDataSource:994 - {dataSource-1} inited +2026-04-02 20:33:04,223 [main] WARN org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext:591 - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'authController': Injection of autowired dependencies failed; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'auth.ticket-expire' in value "${auth.ticket-expire}" +2026-04-02 20:33:04,223 [main] INFO com.alibaba.druid.pool.DruidDataSource:2029 - {dataSource-1} closing ... +2026-04-02 20:33:04,228 [main] INFO com.alibaba.druid.pool.DruidDataSource:2101 - {dataSource-1} closed +2026-04-02 20:33:04,230 [main] INFO org.apache.catalina.core.StandardService:173 - Stopping service [Tomcat] +2026-04-02 20:33:04,242 [main] INFO org.springframework.boot.autoconfigure.logging.ConditionEvaluationReportLoggingListener:136 - + +Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled. +2026-04-02 20:33:04,264 [main] ERROR org.springframework.boot.SpringApplication:871 - Application run failed +org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'authController': Injection of autowired dependencies failed; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'auth.ticket-expire' in value "${auth.ticket-expire}" + at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:405) + at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1413) + at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:601) + at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:524) + at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) + at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) + at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) + at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) + at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:944) + at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918) + at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583) + at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:144) + at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:782) + at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:774) + at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:439) + at org.springframework.boot.SpringApplication.run(SpringApplication.java:339) + at org.springframework.boot.SpringApplication.run(SpringApplication.java:1340) + at org.springframework.boot.SpringApplication.run(SpringApplication.java:1329) + at com.meishu.MeishuApplication.main(MeishuApplication.java:19) +Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'auth.ticket-expire' in value "${auth.ticket-expire}" + at org.springframework.util.PropertyPlaceholderHelper.parseStringValue(PropertyPlaceholderHelper.java:178) + at org.springframework.util.PropertyPlaceholderHelper.replacePlaceholders(PropertyPlaceholderHelper.java:124) + at org.springframework.core.env.AbstractPropertyResolver.doResolvePlaceholders(AbstractPropertyResolver.java:239) + at org.springframework.core.env.AbstractPropertyResolver.resolveRequiredPlaceholders(AbstractPropertyResolver.java:210) + at org.springframework.context.support.PropertySourcesPlaceholderConfigurer.lambda$processProperties$0(PropertySourcesPlaceholderConfigurer.java:175) + at org.springframework.beans.factory.support.AbstractBeanFactory.resolveEmbeddedValue(AbstractBeanFactory.java:936) + at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1321) + at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1300) + at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:657) + at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:640) + at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:119) + at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:399) + ... 18 common frames omitted +2026-04-02 20:34:32,085 [main] INFO com.meishu.MeishuApplication:55 - Starting MeishuApplication using Java 1.8.0_201 on LAPTOP-KO8E5S7F with PID 8480 (D:\code\authen\target\classes started by everior in D:\code\authen) +2026-04-02 20:34:32,088 [main] INFO com.meishu.MeishuApplication:679 - The following profiles are active: dev +2026-04-02 20:34:33,281 [main] INFO org.springframework.boot.web.embedded.tomcat.TomcatWebServer:108 - Tomcat initialized with port(s): 23451 (http) +2026-04-02 20:34:33,290 [main] INFO org.apache.coyote.http11.Http11NioProtocol:173 - Initializing ProtocolHandler ["http-nio-23451"] +2026-04-02 20:34:33,291 [main] INFO org.apache.catalina.core.StandardService:173 - Starting service [Tomcat] +2026-04-02 20:34:33,291 [main] INFO org.apache.catalina.core.StandardEngine:173 - Starting Servlet engine: [Apache Tomcat/9.0.45] +2026-04-02 20:34:33,368 [main] INFO org.apache.catalina.core.ContainerBase.[Tomcat].[localhost].[/]:173 - Initializing Spring embedded WebApplicationContext +2026-04-02 20:34:33,368 [main] INFO org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext:289 - Root WebApplicationContext: initialization completed in 1155 ms +2026-04-02 20:34:33,535 [main] INFO com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure:56 - Init DruidDataSource +2026-04-02 20:34:34,603 [main] INFO com.alibaba.druid.pool.DruidDataSource:994 - {dataSource-1} inited +2026-04-02 20:34:35,326 [main] INFO org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor:181 - Initializing ExecutorService 'applicationTaskExecutor' +2026-04-02 20:34:35,530 [main] INFO org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler:181 - Initializing ExecutorService 'taskScheduler' +2026-04-02 20:34:35,571 [main] INFO org.apache.coyote.http11.Http11NioProtocol:173 - Starting ProtocolHandler ["http-nio-23451"] +2026-04-02 20:34:35,587 [main] INFO org.springframework.boot.web.embedded.tomcat.TomcatWebServer:220 - Tomcat started on port(s): 23451 (http) with context path '' +2026-04-02 20:34:35,598 [main] INFO com.meishu.MeishuApplication:61 - Started MeishuApplication in 4.165 seconds (JVM running for 5.098) +2026-04-02 20:35:25,091 [http-nio-23451-exec-1] INFO org.apache.catalina.core.ContainerBase.[Tomcat].[localhost].[/]:173 - Initializing Spring DispatcherServlet 'dispatcherServlet' +2026-04-02 20:35:25,091 [http-nio-23451-exec-1] INFO org.springframework.web.servlet.DispatcherServlet:525 - Initializing Servlet 'dispatcherServlet' +2026-04-02 20:35:25,092 [http-nio-23451-exec-1] INFO org.springframework.web.servlet.DispatcherServlet:547 - Completed initialization in 1 ms +2026-04-02 20:37:39,119 [SpringContextShutdownHook] INFO org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler:218 - Shutting down ExecutorService 'taskScheduler' +2026-04-02 20:37:39,122 [SpringContextShutdownHook] INFO org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor:218 - Shutting down ExecutorService 'applicationTaskExecutor' +2026-04-02 20:37:39,122 [SpringContextShutdownHook] INFO com.alibaba.druid.pool.DruidDataSource:2029 - {dataSource-1} closing ... +2026-04-02 20:37:39,128 [SpringContextShutdownHook] INFO com.alibaba.druid.pool.DruidDataSource:2101 - {dataSource-1} closed +2026-04-02 20:37:43,483 [main] INFO com.meishu.MeishuApplication:55 - Starting MeishuApplication using Java 1.8.0_201 on LAPTOP-KO8E5S7F with PID 16092 (D:\code\authen\target\classes started by everior in D:\code\authen) +2026-04-02 20:37:43,486 [main] INFO com.meishu.MeishuApplication:679 - The following profiles are active: dev +2026-04-02 20:37:44,604 [main] INFO org.springframework.boot.web.embedded.tomcat.TomcatWebServer:108 - Tomcat initialized with port(s): 23451 (http) +2026-04-02 20:37:44,613 [main] INFO org.apache.coyote.http11.Http11NioProtocol:173 - Initializing ProtocolHandler ["http-nio-23451"] +2026-04-02 20:37:44,614 [main] INFO org.apache.catalina.core.StandardService:173 - Starting service [Tomcat] +2026-04-02 20:37:44,614 [main] INFO org.apache.catalina.core.StandardEngine:173 - Starting Servlet engine: [Apache Tomcat/9.0.45] +2026-04-02 20:37:44,699 [main] INFO org.apache.catalina.core.ContainerBase.[Tomcat].[localhost].[/]:173 - Initializing Spring embedded WebApplicationContext +2026-04-02 20:37:44,699 [main] INFO org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext:289 - Root WebApplicationContext: initialization completed in 1157 ms +2026-04-02 20:37:44,907 [main] INFO com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure:56 - Init DruidDataSource +2026-04-02 20:37:46,130 [main] INFO com.alibaba.druid.pool.DruidDataSource:994 - {dataSource-1} inited +2026-04-02 20:37:46,885 [main] INFO org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor:181 - Initializing ExecutorService 'applicationTaskExecutor' +2026-04-02 20:37:47,101 [main] INFO org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler:181 - Initializing ExecutorService 'taskScheduler' +2026-04-02 20:37:47,153 [main] INFO org.apache.coyote.http11.Http11NioProtocol:173 - Starting ProtocolHandler ["http-nio-23451"] +2026-04-02 20:37:47,172 [main] INFO org.springframework.boot.web.embedded.tomcat.TomcatWebServer:220 - Tomcat started on port(s): 23451 (http) with context path '' +2026-04-02 20:37:47,186 [main] INFO com.meishu.MeishuApplication:61 - Started MeishuApplication in 4.279 seconds (JVM running for 5.158) +2026-04-02 20:37:47,581 [http-nio-23451-exec-1] INFO org.apache.catalina.core.ContainerBase.[Tomcat].[localhost].[/]:173 - Initializing Spring DispatcherServlet 'dispatcherServlet' +2026-04-02 20:37:47,581 [http-nio-23451-exec-1] INFO org.springframework.web.servlet.DispatcherServlet:525 - Initializing Servlet 'dispatcherServlet' +2026-04-02 20:37:47,582 [http-nio-23451-exec-1] INFO org.springframework.web.servlet.DispatcherServlet:547 - Completed initialization in 1 ms +2026-04-02 20:38:03,639 [http-nio-23451-exec-1] INFO com.meishu.common.configure.WebLogAspect:36 - ####requestUrl : http://localhost:23451/auth/login +2026-04-02 20:38:03,639 [http-nio-23451-exec-1] INFO com.meishu.common.configure.WebLogAspect:37 - ####requestParam : [null, null, org.apache.catalina.session.StandardSessionFacade@4ed238fa] +2026-04-02 20:38:31,946 [http-nio-23451-exec-2] INFO com.meishu.common.configure.WebLogAspect:36 - ####requestUrl : http://localhost:23451/auth/login +2026-04-02 20:38:31,947 [http-nio-23451-exec-2] INFO com.meishu.common.configure.WebLogAspect:37 - ####requestParam : [null, null, org.apache.catalina.session.StandardSessionFacade@4ed238fa] +2026-04-02 20:39:29,019 [http-nio-23451-exec-3] INFO com.meishu.common.configure.WebLogAspect:36 - ####requestUrl : http://localhost:23451/auth/login +2026-04-02 20:39:29,020 [http-nio-23451-exec-3] INFO com.meishu.common.configure.WebLogAspect:37 - ####requestParam : [admin,admin, 123456,123456, org.apache.catalina.session.StandardSessionFacade@4ed238fa] +2026-04-02 20:39:34,431 [http-nio-23451-exec-4] INFO com.meishu.common.configure.WebLogAspect:36 - ####requestUrl : http://localhost:23451/auth/login +2026-04-02 20:39:34,432 [http-nio-23451-exec-4] INFO com.meishu.common.configure.WebLogAspect:37 - ####requestParam : [admin,admin, 123456,123456, org.apache.catalina.session.StandardSessionFacade@4ed238fa] +2026-04-02 20:39:51,850 [http-nio-23451-exec-5] INFO com.meishu.common.configure.WebLogAspect:36 - ####requestUrl : http://localhost:23451/auth/login +2026-04-02 20:39:51,850 [http-nio-23451-exec-5] INFO com.meishu.common.configure.WebLogAspect:37 - ####requestParam : [admin, 123456, org.apache.catalina.session.StandardSessionFacade@4ed238fa] +2026-04-02 20:41:37,024 [SpringContextShutdownHook] INFO org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler:218 - Shutting down ExecutorService 'taskScheduler' +2026-04-02 20:41:37,027 [SpringContextShutdownHook] INFO org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor:218 - Shutting down ExecutorService 'applicationTaskExecutor' +2026-04-02 20:41:37,028 [SpringContextShutdownHook] INFO com.alibaba.druid.pool.DruidDataSource:2029 - {dataSource-1} closing ... +2026-04-02 20:41:37,034 [SpringContextShutdownHook] INFO com.alibaba.druid.pool.DruidDataSource:2101 - {dataSource-1} closed +2026-04-02 20:41:41,405 [main] INFO com.meishu.MeishuApplication:55 - Starting MeishuApplication using Java 1.8.0_201 on LAPTOP-KO8E5S7F with PID 15396 (D:\code\authen\target\classes started by everior in D:\code\authen) +2026-04-02 20:41:41,408 [main] INFO com.meishu.MeishuApplication:679 - The following profiles are active: dev +2026-04-02 20:41:42,527 [main] INFO org.springframework.boot.web.embedded.tomcat.TomcatWebServer:108 - Tomcat initialized with port(s): 23451 (http) +2026-04-02 20:41:42,536 [main] INFO org.apache.coyote.http11.Http11NioProtocol:173 - Initializing ProtocolHandler ["http-nio-23451"] +2026-04-02 20:41:42,537 [main] INFO org.apache.catalina.core.StandardService:173 - Starting service [Tomcat] +2026-04-02 20:41:42,537 [main] INFO org.apache.catalina.core.StandardEngine:173 - Starting Servlet engine: [Apache Tomcat/9.0.45] +2026-04-02 20:41:42,610 [main] INFO org.apache.catalina.core.ContainerBase.[Tomcat].[localhost].[/]:173 - Initializing Spring embedded WebApplicationContext +2026-04-02 20:41:42,611 [main] INFO org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext:289 - Root WebApplicationContext: initialization completed in 1150 ms +2026-04-02 20:41:42,794 [main] INFO com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure:56 - Init DruidDataSource +2026-04-02 20:41:43,916 [main] INFO com.alibaba.druid.pool.DruidDataSource:994 - {dataSource-1} inited +2026-04-02 20:41:44,670 [main] INFO org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor:181 - Initializing ExecutorService 'applicationTaskExecutor' +2026-04-02 20:41:44,914 [main] INFO org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler:181 - Initializing ExecutorService 'taskScheduler' +2026-04-02 20:41:44,953 [main] INFO org.apache.coyote.http11.Http11NioProtocol:173 - Starting ProtocolHandler ["http-nio-23451"] +2026-04-02 20:41:44,972 [main] INFO org.springframework.boot.web.embedded.tomcat.TomcatWebServer:220 - Tomcat started on port(s): 23451 (http) with context path '' +2026-04-02 20:41:44,984 [main] INFO com.meishu.MeishuApplication:61 - Started MeishuApplication in 4.101 seconds (JVM running for 4.963) +2026-04-02 20:41:45,060 [http-nio-23451-exec-1] INFO org.apache.catalina.core.ContainerBase.[Tomcat].[localhost].[/]:173 - Initializing Spring DispatcherServlet 'dispatcherServlet' +2026-04-02 20:41:45,060 [http-nio-23451-exec-1] INFO org.springframework.web.servlet.DispatcherServlet:525 - Initializing Servlet 'dispatcherServlet' +2026-04-02 20:41:45,060 [http-nio-23451-exec-1] INFO org.springframework.web.servlet.DispatcherServlet:547 - Completed initialization in 0 ms +2026-04-02 20:41:45,096 [http-nio-23451-exec-1] INFO com.meishu.common.configure.WebLogAspect:36 - ####requestUrl : http://localhost:23451/auth/getTicket +2026-04-02 20:41:45,097 [http-nio-23451-exec-1] INFO com.meishu.common.configure.WebLogAspect:37 - ####requestParam : [erp, org.apache.catalina.session.StandardSessionFacade@3e6afc05] +2026-04-02 20:42:28,485 [http-nio-23451-exec-2] INFO com.meishu.common.configure.WebLogAspect:36 - ####requestUrl : http://localhost:23451/auth/getTicket +2026-04-02 20:42:28,486 [http-nio-23451-exec-2] INFO com.meishu.common.configure.WebLogAspect:37 - ####requestParam : [erp, org.apache.catalina.session.StandardSessionFacade@3e6afc05] +2026-04-02 20:43:27,638 [http-nio-23451-exec-5] INFO com.meishu.common.configure.WebLogAspect:36 - ####requestUrl : http://localhost:23451/auth/getTicket +2026-04-02 20:43:27,639 [http-nio-23451-exec-5] INFO com.meishu.common.configure.WebLogAspect:37 - ####requestParam : [erp, org.apache.catalina.session.StandardSessionFacade@44c46392] +2026-04-02 20:47:11,506 [http-nio-23451-exec-8] INFO com.meishu.common.configure.WebLogAspect:36 - ####requestUrl : http://localhost:23451/auth/login +2026-04-02 20:47:11,507 [http-nio-23451-exec-8] INFO com.meishu.common.configure.WebLogAspect:37 - ####requestParam : [admin, 123456, org.apache.catalina.session.StandardSessionFacade@44c46392] +2026-04-02 20:47:56,976 [http-nio-23451-exec-10] INFO com.meishu.common.configure.WebLogAspect:36 - ####requestUrl : http://localhost:23451/auth/getTicket +2026-04-02 20:47:56,977 [http-nio-23451-exec-10] INFO com.meishu.common.configure.WebLogAspect:37 - ####requestParam : [erp, org.apache.catalina.session.StandardSessionFacade@44c46392] +2026-04-02 20:48:55,094 [http-nio-23451-exec-1] INFO com.meishu.common.configure.WebLogAspect:36 - ####requestUrl : http://localhost:23451/auth/verifyTicket +2026-04-02 20:48:55,095 [http-nio-23451-exec-1] INFO com.meishu.common.configure.WebLogAspect:37 - ####requestParam : [cc5b215dccdb4b16ad3b0b064767f8e1] +2026-04-02 20:49:00,082 [http-nio-23451-exec-4] INFO com.meishu.common.configure.WebLogAspect:36 - ####requestUrl : http://localhost:23451/auth/verifyTicket +2026-04-02 20:49:00,083 [http-nio-23451-exec-4] INFO com.meishu.common.configure.WebLogAspect:37 - ####requestParam : [cc5b215dccdb4b16ad3b0b064767f82] +2026-04-02 20:52:39,710 [http-nio-23451-exec-5] INFO com.meishu.common.configure.WebLogAspect:36 - ####requestUrl : http://localhost:23451/auth/verifyTicket +2026-04-02 20:52:39,710 [http-nio-23451-exec-5] INFO com.meishu.common.configure.WebLogAspect:37 - ####requestParam : [cc5b215dccdb4b16ad3b0b064767f81] +2026-04-02 20:53:17,294 [http-nio-23451-exec-6] INFO com.meishu.common.configure.WebLogAspect:36 - ####requestUrl : http://localhost:23451/auth/verifyTicket +2026-04-02 20:53:17,294 [http-nio-23451-exec-6] INFO com.meishu.common.configure.WebLogAspect:37 - ####requestParam : [cc5b215dccdb4b16ad3b0b064767f81] +2026-04-02 20:53:37,085 [http-nio-23451-exec-7] INFO com.meishu.common.configure.WebLogAspect:36 - ####requestUrl : http://localhost:23451/auth/verifyTicket +2026-04-02 20:53:37,086 [http-nio-23451-exec-7] INFO com.meishu.common.configure.WebLogAspect:37 - ####requestParam : [cc5b215dccdb4b16ad3b0b064767f8e1] +2026-04-02 21:47:40,024 [SpringContextShutdownHook] INFO org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler:218 - Shutting down ExecutorService 'taskScheduler' +2026-04-02 21:47:40,027 [SpringContextShutdownHook] INFO org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor:218 - Shutting down ExecutorService 'applicationTaskExecutor' +2026-04-02 21:47:40,027 [SpringContextShutdownHook] INFO com.alibaba.druid.pool.DruidDataSource:2029 - {dataSource-1} closing ... +2026-04-02 21:47:40,029 [SpringContextShutdownHook] INFO com.alibaba.druid.pool.DruidDataSource:2101 - {dataSource-1} closed diff --git a/logs/springboot-logback/error/2022-06-25-0.log.gz b/logs/springboot-logback/error/2022-06-25-0.log.gz new file mode 100644 index 0000000..ed2f256 Binary files /dev/null and b/logs/springboot-logback/error/2022-06-25-0.log.gz differ diff --git a/logs/springboot-logback/error/2022-12-27-0.log.gz b/logs/springboot-logback/error/2022-12-27-0.log.gz new file mode 100644 index 0000000..376c1b6 Binary files /dev/null and b/logs/springboot-logback/error/2022-12-27-0.log.gz differ diff --git a/logs/springboot-logback/info/2022-10-28-0.log.gz b/logs/springboot-logback/info/2022-10-28-0.log.gz new file mode 100644 index 0000000..b02af10 Binary files /dev/null and b/logs/springboot-logback/info/2022-10-28-0.log.gz differ diff --git a/logs/springboot-logback/info/2022-12-27-0.log.gz b/logs/springboot-logback/info/2022-12-27-0.log.gz new file mode 100644 index 0000000..5f2e783 Binary files /dev/null and b/logs/springboot-logback/info/2022-12-27-0.log.gz differ diff --git a/mvnw b/mvnw new file mode 100644 index 0000000..a16b543 --- /dev/null +++ b/mvnw @@ -0,0 +1,310 @@ +#!/bin/sh +# ---------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# ---------------------------------------------------------------------------- + +# ---------------------------------------------------------------------------- +# Maven Start Up Batch script +# +# Required ENV vars: +# ------------------ +# JAVA_HOME - location of a JDK home dir +# +# Optional ENV vars +# ----------------- +# M2_HOME - location of maven2's installed home dir +# MAVEN_OPTS - parameters passed to the Java VM when running Maven +# e.g. to debug Maven itself, use +# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +# MAVEN_SKIP_RC - flag to disable loading of mavenrc files +# ---------------------------------------------------------------------------- + +if [ -z "$MAVEN_SKIP_RC" ] ; then + + if [ -f /etc/mavenrc ] ; then + . /etc/mavenrc + fi + + if [ -f "$HOME/.mavenrc" ] ; then + . "$HOME/.mavenrc" + fi + +fi + +# OS specific support. $var _must_ be set to either true or false. +cygwin=false; +darwin=false; +mingw=false +case "`uname`" in + CYGWIN*) cygwin=true ;; + MINGW*) mingw=true;; + Darwin*) darwin=true + # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home + # See https://developer.apple.com/library/mac/qa/qa1170/_index.html + if [ -z "$JAVA_HOME" ]; then + if [ -x "/usr/libexec/java_home" ]; then + export JAVA_HOME="`/usr/libexec/java_home`" + else + export JAVA_HOME="/Library/Java/Home" + fi + fi + ;; +esac + +if [ -z "$JAVA_HOME" ] ; then + if [ -r /etc/gentoo-release ] ; then + JAVA_HOME=`java-config --jre-home` + fi +fi + +if [ -z "$M2_HOME" ] ; then + ## resolve links - $0 may be a link to maven's home + PRG="$0" + + # need this for relative symlinks + while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG="`dirname "$PRG"`/$link" + fi + done + + saveddir=`pwd` + + M2_HOME=`dirname "$PRG"`/.. + + # make it fully qualified + M2_HOME=`cd "$M2_HOME" && pwd` + + cd "$saveddir" + # echo Using m2 at $M2_HOME +fi + +# For Cygwin, ensure paths are in UNIX format before anything is touched +if $cygwin ; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --unix "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --unix "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --unix "$CLASSPATH"` +fi + +# For Mingw, ensure paths are in UNIX format before anything is touched +if $mingw ; then + [ -n "$M2_HOME" ] && + M2_HOME="`(cd "$M2_HOME"; pwd)`" + [ -n "$JAVA_HOME" ] && + JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" +fi + +if [ -z "$JAVA_HOME" ]; then + javaExecutable="`which javac`" + if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then + # readlink(1) is not available as standard on Solaris 10. + readLink=`which readlink` + if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then + if $darwin ; then + javaHome="`dirname \"$javaExecutable\"`" + javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" + else + javaExecutable="`readlink -f \"$javaExecutable\"`" + fi + javaHome="`dirname \"$javaExecutable\"`" + javaHome=`expr "$javaHome" : '\(.*\)/bin'` + JAVA_HOME="$javaHome" + export JAVA_HOME + fi + fi +fi + +if [ -z "$JAVACMD" ] ; then + if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + else + JAVACMD="`which java`" + fi +fi + +if [ ! -x "$JAVACMD" ] ; then + echo "Error: JAVA_HOME is not defined correctly." >&2 + echo " We cannot execute $JAVACMD" >&2 + exit 1 +fi + +if [ -z "$JAVA_HOME" ] ; then + echo "Warning: JAVA_HOME environment variable is not set." +fi + +CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher + +# traverses directory structure from process work directory to filesystem root +# first directory with .mvn subdirectory is considered project base directory +find_maven_basedir() { + + if [ -z "$1" ] + then + echo "Path not specified to find_maven_basedir" + return 1 + fi + + basedir="$1" + wdir="$1" + while [ "$wdir" != '/' ] ; do + if [ -d "$wdir"/.mvn ] ; then + basedir=$wdir + break + fi + # workaround for JBEAP-8937 (on Solaris 10/Sparc) + if [ -d "${wdir}" ]; then + wdir=`cd "$wdir/.."; pwd` + fi + # end of workaround + done + echo "${basedir}" +} + +# concatenates all lines of a file +concat_lines() { + if [ -f "$1" ]; then + echo "$(tr -s '\n' ' ' < "$1")" + fi +} + +BASE_DIR=`find_maven_basedir "$(pwd)"` +if [ -z "$BASE_DIR" ]; then + exit 1; +fi + +########################################################################################## +# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +# This allows using the maven wrapper in projects that prohibit checking in binary data. +########################################################################################## +if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found .mvn/wrapper/maven-wrapper.jar" + fi +else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." + fi + if [ -n "$MVNW_REPOURL" ]; then + jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + else + jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + fi + while IFS="=" read key value; do + case "$key" in (wrapperUrl) jarUrl="$value"; break ;; + esac + done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" + if [ "$MVNW_VERBOSE" = true ]; then + echo "Downloading from: $jarUrl" + fi + wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" + if $cygwin; then + wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` + fi + + if command -v wget > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found wget ... using wget" + fi + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + wget "$jarUrl" -O "$wrapperJarPath" + else + wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" + fi + elif command -v curl > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found curl ... using curl" + fi + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + curl -o "$wrapperJarPath" "$jarUrl" -f + else + curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f + fi + + else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Falling back to using Java to download" + fi + javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" + # For Cygwin, switch paths to Windows format before running javac + if $cygwin; then + javaClass=`cygpath --path --windows "$javaClass"` + fi + if [ -e "$javaClass" ]; then + if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Compiling MavenWrapperDownloader.java ..." + fi + # Compiling the Java class + ("$JAVA_HOME/bin/javac" "$javaClass") + fi + if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + # Running the downloader + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Running MavenWrapperDownloader.java ..." + fi + ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") + fi + fi + fi +fi +########################################################################################## +# End of extension +########################################################################################## + +export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} +if [ "$MVNW_VERBOSE" = true ]; then + echo $MAVEN_PROJECTBASEDIR +fi +MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" + +# For Cygwin, switch paths to Windows format before running java +if $cygwin; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --path --windows "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --windows "$CLASSPATH"` + [ -n "$MAVEN_PROJECTBASEDIR" ] && + MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` +fi + +# Provide a "standardized" way to retrieve the CLI args that will +# work with both Windows and non-Windows executions. +MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" +export MAVEN_CMD_LINE_ARGS + +WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +exec "$JAVACMD" \ + $MAVEN_OPTS \ + -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ + "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ + ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/mvnw.cmd b/mvnw.cmd new file mode 100644 index 0000000..c8d4337 --- /dev/null +++ b/mvnw.cmd @@ -0,0 +1,182 @@ +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM https://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Maven Start Up Batch script +@REM +@REM Required ENV vars: +@REM JAVA_HOME - location of a JDK home dir +@REM +@REM Optional ENV vars +@REM M2_HOME - location of maven2's installed home dir +@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending +@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven +@REM e.g. to debug Maven itself, use +@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM ---------------------------------------------------------------------------- + +@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' +@echo off +@REM set title of command window +title %0 +@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' +@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% + +@REM set %HOME% to equivalent of $HOME +if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") + +@REM Execute a user defined script before this one +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre +@REM check for pre script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" +if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" +:skipRcPre + +@setlocal + +set ERROR_CODE=0 + +@REM To isolate internal variables from possible post scripts, we use another setlocal +@setlocal + +@REM ==== START VALIDATION ==== +if not "%JAVA_HOME%" == "" goto OkJHome + +echo. +echo Error: JAVA_HOME not found in your environment. >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +:OkJHome +if exist "%JAVA_HOME%\bin\java.exe" goto init + +echo. +echo Error: JAVA_HOME is set to an invalid directory. >&2 +echo JAVA_HOME = "%JAVA_HOME%" >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +@REM ==== END VALIDATION ==== + +:init + +@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". +@REM Fallback to current working directory if not found. + +set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% +IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir + +set EXEC_DIR=%CD% +set WDIR=%EXEC_DIR% +:findBaseDir +IF EXIST "%WDIR%"\.mvn goto baseDirFound +cd .. +IF "%WDIR%"=="%CD%" goto baseDirNotFound +set WDIR=%CD% +goto findBaseDir + +:baseDirFound +set MAVEN_PROJECTBASEDIR=%WDIR% +cd "%EXEC_DIR%" +goto endDetectBaseDir + +:baseDirNotFound +set MAVEN_PROJECTBASEDIR=%EXEC_DIR% +cd "%EXEC_DIR%" + +:endDetectBaseDir + +IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig + +@setlocal EnableExtensions EnableDelayedExpansion +for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a +@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% + +:endReadAdditionalConfig + +SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" +set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" +set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + +FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( + IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B +) + +@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +@REM This allows using the maven wrapper in projects that prohibit checking in binary data. +if exist %WRAPPER_JAR% ( + if "%MVNW_VERBOSE%" == "true" ( + echo Found %WRAPPER_JAR% + ) +) else ( + if not "%MVNW_REPOURL%" == "" ( + SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + ) + if "%MVNW_VERBOSE%" == "true" ( + echo Couldn't find %WRAPPER_JAR%, downloading it ... + echo Downloading from: %DOWNLOAD_URL% + ) + + powershell -Command "&{"^ + "$webclient = new-object System.Net.WebClient;"^ + "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ + "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ + "}"^ + "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ + "}" + if "%MVNW_VERBOSE%" == "true" ( + echo Finished downloading %WRAPPER_JAR% + ) +) +@REM End of extension + +@REM Provide a "standardized" way to retrieve the CLI args that will +@REM work with both Windows and non-Windows executions. +set MAVEN_CMD_LINE_ARGS=%* + +%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* +if ERRORLEVEL 1 goto error +goto end + +:error +set ERROR_CODE=1 + +:end +@endlocal & set ERROR_CODE=%ERROR_CODE% + +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost +@REM check for post script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" +if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" +:skipRcPost + +@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' +if "%MAVEN_BATCH_PAUSE%" == "on" pause + +if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% + +exit /B %ERROR_CODE% diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..6dad048 --- /dev/null +++ b/pom.xml @@ -0,0 +1,146 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 2.4.5 + + + com.meishu + meishu + 0.0.1-SNAPSHOT + meishu + Demo project for Spring Boot + + + UTF-8 + UTF-8 + 1.8 + 3.3.0 + 3.3.2 + 1.2.58 + 2.0.0 + 3.13 + 1.1.0 + 4.4.6 + 3.9 + 1.1.22 + 3.10.3 + + + + + org.springframework.boot + spring-boot-starter + + + + org.freemarker + freemarker + + + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.boot + spring-boot-starter-aop + + + + org.springframework.boot + spring-boot-configuration-processor + true + + + + mysql + mysql-connector-java + runtime + + + + com.alibaba + druid-spring-boot-starter + ${druid.version} + + + + org.springframework.boot + spring-boot-starter-jdbc + + + + org.projectlombok + lombok + + + + + cn.hutool + hutool-all + 5.8.20 + + + + com.baomidou + mybatis-plus-boot-starter + ${mybatis-plus.version} + + + + com.baomidou + mybatis-plus-generator + ${generator.version} + + + + com.alibaba + fastjson + ${fastjson.version} + + + + org.apache.poi + poi-ooxml + ${poi-ooxml.version} + + + + org.apache.commons + commons-lang3 + ${lang3.version} + + + + + io.github.resilience4j + resilience4j-spring-boot2 + 1.7.1 + + + + + auth + + + org.springframework.boot + spring-boot-maven-plugin + 2.2.6.RELEASE + + + + org.projectlombok + lombok + + + + + + + + diff --git a/src/main/java/com/meishu/MeishuApplication.java b/src/main/java/com/meishu/MeishuApplication.java new file mode 100644 index 0000000..cc702bd --- /dev/null +++ b/src/main/java/com/meishu/MeishuApplication.java @@ -0,0 +1,22 @@ +package com.meishu; + +import com.alibaba.druid.support.http.StatViewServlet; +import org.mybatis.spring.annotation.MapperScan; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.web.servlet.ServletRegistrationBean; +import org.springframework.context.annotation.Bean; +import org.springframework.scheduling.annotation.EnableScheduling; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@SpringBootApplication +@MapperScan(basePackages = {"com.meishu.mapper"}) +@EnableScheduling +public class MeishuApplication { + + public static void main(String[] args) { + SpringApplication.run(MeishuApplication.class, args); + } + +} diff --git a/src/main/java/com/meishu/common/Code.java b/src/main/java/com/meishu/common/Code.java new file mode 100644 index 0000000..8aa1868 --- /dev/null +++ b/src/main/java/com/meishu/common/Code.java @@ -0,0 +1,45 @@ +package com.meishu.common; + +public enum Code { + + USERNAMENOTFOUND(10001, "用户不存在"), + BADCREDENTIALS(10002,"账户或者密码错误"), + ACCOUNTEXPIRED(10003,"账户过期"), + LOCKEDEXCEPTION(10004, "账户已锁定"), + DISABLEDEXCEPTION(10005,"账户已禁用"), + ACCESSDENIED(10006,"无权限访问"), + AUTHENTICATION(10007,"身份验证异常"), + NOHANDLERFOUND(10008,"找不到相应的视图处理器"), + PARAM_INVALID(10009, "参数不合法"), + TOKEN_EXCEPTION(10010, "Token不合法"), + TOKEN_EXPIRED(10011, "Token已过期"), + OSS_ERROR(10012, "OSS文件上传异常"), + Network_ERROR(90000, "网络请求失败"), + SERVER_INTERNAL_ERROR(99999, "服务器内部错误"), + ; + + private Integer code; + + private String message; + + Code(Integer code, String message) { + this.code = code; + this.message = message; + } + + public Integer getCode() { + return code; + } + + public void setCode(Integer code) { + this.code = code; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } +} diff --git a/src/main/java/com/meishu/common/ResponseData.java b/src/main/java/com/meishu/common/ResponseData.java new file mode 100644 index 0000000..c80c3a8 --- /dev/null +++ b/src/main/java/com/meishu/common/ResponseData.java @@ -0,0 +1,54 @@ +package com.meishu.common; + +import com.meishu.common.configure.RemoteProperties; +import lombok.Data; +import org.springframework.boot.context.properties.EnableConfigurationProperties; + +/** + * 返回数据 + * + * @author DengMin + * @date 2019/08/27 13:57 + **/ +@Data +@EnableConfigurationProperties(RemoteProperties.class) +public class ResponseData { + + public static ResponseVO generateCreatedResponse(int code) { + return (ResponseVO) ResponseVO.builder() + .code(code) + .message(RemoteProperties.getMessage(code)) + .build(); + } + + public static ResponseVO generateCreatedResponse(int code, String message) { + return (ResponseVO) ResponseVO.builder() + .code(code) + .message(message) + .build(); + } + + public static ResponseVO generateCreatedResponse(int code, T data) { + return (ResponseVO) ResponseVO.builder() + .code(code) + .message(RemoteProperties.getMessage(code)) + .data(data) + .build(); + } + + public static ResponseVO generateCreatedResponse(int code, String message, T data) { + return (ResponseVO) ResponseVO.builder() + .code(code) + .message(message) + .data(data) + .build(); + } + + public static ResponseVO generateCreatedResponse(int code, String message, String path) { + return (ResponseVO) ResponseVO.builder() + .code(code) + .message(message) + .path(path) + .build(); + } +} \ No newline at end of file diff --git a/src/main/java/com/meishu/common/ResponseVO.java b/src/main/java/com/meishu/common/ResponseVO.java new file mode 100644 index 0000000..7cc4173 --- /dev/null +++ b/src/main/java/com/meishu/common/ResponseVO.java @@ -0,0 +1,21 @@ +package com.meishu.common; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class ResponseVO { + + private Integer code; + + private String message; + + private T data; + + private String path; +} \ No newline at end of file diff --git a/src/main/java/com/meishu/common/configure/MybatisPlusConfig.java b/src/main/java/com/meishu/common/configure/MybatisPlusConfig.java new file mode 100644 index 0000000..a95a738 --- /dev/null +++ b/src/main/java/com/meishu/common/configure/MybatisPlusConfig.java @@ -0,0 +1,54 @@ +package com.meishu.common.configure; + +import com.baomidou.mybatisplus.annotation.DbType; +import com.baomidou.mybatisplus.core.config.GlobalConfig; +import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor; +import com.meishu.common.handler.MetaHandler; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * @author: tuyp + * @create: 2020-08-12 12:01 + */ +@Configuration +@ConditionalOnClass(value = {PaginationInterceptor.class}) +public class MybatisPlusConfig { + + /** + * 分页 + * @return + */ + @Bean + public PaginationInterceptor paginationInterceptor(){ + PaginationInterceptor paginationInterceptor = new PaginationInterceptor(); + paginationInterceptor.setDialectType(DbType.MYSQL.getDb()); + return paginationInterceptor; + } +// +// /** +// * 打印 sql +// */ +// @Bean +// public PerformanceInterceptor performanceInterceptor() { +// PerformanceInterceptor performanceInterceptor = new PerformanceInterceptor(); +// //格式化sql语句 +// Properties properties = new Properties(); +// properties.setProperty("format", "false"); +// performanceInterceptor.setProperties(properties); +// return performanceInterceptor; +// } + + /** + * 自动填充功能 + * @return + */ + @Bean + public GlobalConfig globalConfig() { + GlobalConfig globalConfig = new GlobalConfig(); + globalConfig.setMetaObjectHandler(new MetaHandler()); + return globalConfig; + } + +} diff --git a/src/main/java/com/meishu/common/configure/RemoteProperties.java b/src/main/java/com/meishu/common/configure/RemoteProperties.java new file mode 100644 index 0000000..043c5e9 --- /dev/null +++ b/src/main/java/com/meishu/common/configure/RemoteProperties.java @@ -0,0 +1,36 @@ +package com.meishu.common.configure; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.PropertySource; +import org.springframework.stereotype.Component; + +import java.util.HashMap; +import java.util.Map; + +/** + *

+ * 读取状态码 + *

+ * + * @author DengMin + * @date Created in 2020/08/24 + */ +@Component +@ConfigurationProperties(prefix = "meishu") +@PropertySource(value = "classpath:code.properties", encoding = "UTF-8") +public class RemoteProperties { + + private static Map codeMessage = new HashMap<>(); + + public static String getMessage(Integer code) { + return codeMessage.get(code); + } + + public Map getCodeMessage() { + return codeMessage; + } + + public void setCodeMessage(Map codeMessage) { + RemoteProperties.codeMessage = codeMessage; + } +} \ No newline at end of file diff --git a/src/main/java/com/meishu/common/configure/WebLogAspect.java b/src/main/java/com/meishu/common/configure/WebLogAspect.java new file mode 100644 index 0000000..c4deaf1 --- /dev/null +++ b/src/main/java/com/meishu/common/configure/WebLogAspect.java @@ -0,0 +1,56 @@ +package com.meishu.common.configure; + +import org.aspectj.lang.JoinPoint; +import org.aspectj.lang.annotation.*; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; +import org.springframework.web.context.request.RequestAttributes; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; + +import javax.servlet.http.HttpServletRequest; +import java.util.Arrays; + +@Aspect +@Component +public class WebLogAspect { + + private final Logger logger = LoggerFactory.getLogger(WebLogAspect.class); + + @Pointcut("execution(public * com.meishu.controller.*.*(..))")//切入点描述 这个是controller包的切入点 + public void controllerLog(){}//签名,可以理解成这个切入点的一个名称 + + @Pointcut("execution(public * com.meishu.controller.*.*(..))") + public void serviceImplLog(){} + + @Before("controllerLog()") //在切入点的方法run之前要干的 + public void logBeforeController(JoinPoint joinPoint) { + + + RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes(); + //这个RequestContextHolder是Springmvc提供来获得请求的东西 + HttpServletRequest request = ((ServletRequestAttributes)requestAttributes).getRequest(); + + // 记录下请求内容 + logger.info("####requestUrl : " + request.getRequestURL().toString()); + logger.info("####requestParam : " + Arrays.toString(joinPoint.getArgs())); + + } + +// @Around("serviceImplLog()") +// public Object afterController(ProceedingJoinPoint proceedingJoinPoint) { +// +// Object result = null; +// +// try{ +// result = proceedingJoinPoint.proceed(); +// logger.info("====reulst"+result); +// }catch (Throwable e){ +// MyException myException =(MyException)e; +// throw myException; +// } +// return result; +// } + +} \ No newline at end of file diff --git a/src/main/java/com/meishu/common/constant/Code.java b/src/main/java/com/meishu/common/constant/Code.java new file mode 100644 index 0000000..58388c5 --- /dev/null +++ b/src/main/java/com/meishu/common/constant/Code.java @@ -0,0 +1,33 @@ +package com.meishu.common.constant; + +import lombok.Getter; + +@Getter +public enum Code { + + USERNAMENOTFOUND(1001, "用户不存在"), + BADCREDENTIALS(1002,"账户或者密码错误"), + ACCOUNTEXPIRED(1003,"账户过期"), + LOCKEDEXCEPTION(1004, "账户已锁定"), + DISABLEDEXCEPTION(1005,"账户已禁用"), + ACCESSDENIED(1006,"无权限访问"), + AUTHENTICATION(1007,"身份验证异常"), + NOHANDLERFOUND(1008,"找不到相应的视图处理器"), + PARAM_INVALID(1009, "参数不合法"), + TOKEN_EXCEPTION(1010, "无效的令牌"), + TOKEN_EXPIRED(1011, "令牌已过期"), + TOKEN_VERIFICATION_FAILED(1013, "令牌验证失败"), + OSS_ERROR(1012, "OSS文件上传异常"), + Network_ERROR(9000, "网络请求失败"), + SERVER_INTERNAL_ERROR(99999, "服务器内部错误"), + ; + + private Integer code; + + private String message; + + Code(Integer code, String message) { + this.code = code; + this.message = message; + } +} diff --git a/src/main/java/com/meishu/common/constant/WxConstant.java b/src/main/java/com/meishu/common/constant/WxConstant.java new file mode 100644 index 0000000..b9ad76d --- /dev/null +++ b/src/main/java/com/meishu/common/constant/WxConstant.java @@ -0,0 +1,35 @@ +package com.meishu.common.constant; + +public class WxConstant { + + /** + * app id + */ + public static final String APPID = "wx75ec06e9ce50ef73"; + + /** + * 秘钥 + */ + public static final String SECRENT = "c039d32804278503474dfcf7cb3944b9"; + + /** + * 获取访问用户身份 + */ + public static final String GETUSERINFO = "https://qyapi.weixin.qq.com/cgi-bin/user/getuserinfo?access_token={access_token}&code={code}"; + + /** + * 读取成员 + */ + public static final String GET = "https://qyapi.weixin.qq.com/cgi-bin/user/get?access_token={access_token}&userid={userid}"; + + /** + * 获取access_token + */ + public static final String GET_SUITE_TOKEN = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={appid}&secret={secret}"; + + + /** + * 扫码登陆回调地址 + */ + public static final String QR_REDIRECT_URL = "http://massadmin.youkehulian.com"; +} diff --git a/src/main/java/com/meishu/common/exception/GlobalExceptionHandler.java b/src/main/java/com/meishu/common/exception/GlobalExceptionHandler.java new file mode 100644 index 0000000..3f5e20d --- /dev/null +++ b/src/main/java/com/meishu/common/exception/GlobalExceptionHandler.java @@ -0,0 +1,119 @@ +package com.meishu.common.exception; + +import com.baomidou.mybatisplus.core.toolkit.StringUtils; +import com.meishu.common.ResponseData; +import com.meishu.common.ResponseVO; +import com.meishu.common.configure.RemoteProperties; +import com.meishu.common.constant.Code; +import lombok.extern.slf4j.Slf4j; +import org.apache.poi.ss.formula.functions.T; +import org.springframework.http.converter.HttpMessageNotReadableException; +import org.springframework.validation.BindException; +import org.springframework.web.HttpRequestMethodNotSupportedException; +import org.springframework.web.bind.MethodArgumentNotValidException; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.RestControllerAdvice; +import org.springframework.web.servlet.NoHandlerFoundException; + +import javax.servlet.http.HttpServletRequest; +import java.util.ArrayList; +import java.util.List; + +/** + * 异常处理 + * @author DengMin + * @date 2020/07/14 + **/ +@Slf4j +@RestControllerAdvice +public class GlobalExceptionHandler { + + /** + * 自定义异常 + * @param e + * @return + */ + @ExceptionHandler(value = HttpException.class) + public ResponseVO handlerException(HttpServletRequest request, HttpException e) { + String message = RemoteProperties.getMessage(e.getCode()); + if(StringUtils.isBlank(message)) { + message = e.getMessage(); + } + String url = request.getRequestURI(); + return ResponseData.generateCreatedResponse(e.getCode(), message, url); + } + + /** + * 404 + * @param request + * @return + */ + @ExceptionHandler(value = NoHandlerFoundException.class) + public ResponseVO NoHandlerFoundException(HttpServletRequest request) { + String url = request.getRequestURI(); + return ResponseData.generateCreatedResponse(Code.NOHANDLERFOUND.getCode(), Code.NOHANDLERFOUND.getMessage(), url); + } + + /** + * 请求方式错误 + * @param request + * @return + */ + @ExceptionHandler(value = HttpRequestMethodNotSupportedException.class) + public ResponseVO HttpRequestMethodNotSupportedException(HttpServletRequest request) { + String url = request.getRequestURI(); + return ResponseData.generateCreatedResponse(Code.NOHANDLERFOUND.getCode(), Code.NOHANDLERFOUND.getMessage(), url); + } + + /** + * 参数不合法 + * @param e + * @return + */ + @ExceptionHandler(MethodArgumentNotValidException.class) + public ResponseVO validateException(MethodArgumentNotValidException e){ + final List errList = new ArrayList<>(); + e.getBindingResult().getAllErrors().stream().forEach(x -> { + errList.add(x.getDefaultMessage()); + }); + return ResponseData.generateCreatedResponse(Code.PARAM_INVALID.getCode(), Code.PARAM_INVALID.getMessage(), errList.toString()); + } + + /** + * JSON 序列化异常 + * @param e + * @return + */ + @ExceptionHandler(HttpMessageNotReadableException.class) + public ResponseVO exceptionHandler(HttpMessageNotReadableException e) { + log.error(e.getMessage()); + return ResponseData.generateCreatedResponse(Code.PARAM_INVALID.getCode(), Code.PARAM_INVALID.getMessage()+":{"+e.getMessage()+"}"); + } + + /** + * 校验异常 + * @param e + * @return + */ + @ExceptionHandler(BindException.class) + public ResponseVO BindException(BindException e){ + final List errList = new ArrayList<>(); + e.getBindingResult().getAllErrors().stream().forEach(x -> { + errList.add(x.getDefaultMessage()); + }); + return ResponseData.generateCreatedResponse(Code.PARAM_INVALID.getCode(), Code.PARAM_INVALID.getMessage(), errList.toString()); + } + + /** + * 服务器内部错误 + * @return + */ + @ExceptionHandler(value = Exception.class) + public ResponseVO serverInternalError(Exception e, HttpServletRequest request) { + String url = request.getRequestURI(); +// log.error("path:"+url); +// log.error("---- error message: ---"+e.printStackTrace();); + e.printStackTrace(); + return ResponseData.generateCreatedResponse(Code.SERVER_INTERNAL_ERROR.getCode(), Code.SERVER_INTERNAL_ERROR.getMessage(), url); + } +} \ No newline at end of file diff --git a/src/main/java/com/meishu/common/exception/HttpException.java b/src/main/java/com/meishu/common/exception/HttpException.java new file mode 100644 index 0000000..d38b63a --- /dev/null +++ b/src/main/java/com/meishu/common/exception/HttpException.java @@ -0,0 +1,45 @@ +package com.meishu.common.exception; + + +import com.meishu.common.configure.RemoteProperties; + +/** + * 异常处理 + * @author DengMin + * @date 2020/08/12 + **/ +public class HttpException extends RuntimeException{ + + private Integer code; + + private String message; + + public Integer getCode() { + return code; + } + + public void setCode(Integer code) { + this.code = code; + } + + @Override + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public HttpException(Integer code) { + super(RemoteProperties.getMessage(code)); + String message = RemoteProperties.getMessage(code); + this.message = message; + this.code = code; + } + + public HttpException(Integer code, String message) { + this.message = message; + this.code = code; + } +} diff --git a/src/main/java/com/meishu/common/handler/MetaHandler.java b/src/main/java/com/meishu/common/handler/MetaHandler.java new file mode 100644 index 0000000..3b697e8 --- /dev/null +++ b/src/main/java/com/meishu/common/handler/MetaHandler.java @@ -0,0 +1,26 @@ +package com.meishu.common.handler; + +import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler; +import org.apache.ibatis.reflection.MetaObject; +import org.springframework.stereotype.Component; + +import java.time.LocalDateTime; + +/** + * 填充配置 + * @author DengMin + * @date 2020/07/21 + **/ +@Component +public class MetaHandler implements MetaObjectHandler { + + @Override + public void insertFill(MetaObject metaObject) { + this.setFieldValByName("createTime", LocalDateTime.now(), metaObject); + } + + @Override + public void updateFill(MetaObject metaObject) { + this.setFieldValByName("updateTime", LocalDateTime.now(), metaObject); + } +} diff --git a/src/main/java/com/meishu/common/interceptor/AuthenticationInterceptor.java b/src/main/java/com/meishu/common/interceptor/AuthenticationInterceptor.java new file mode 100644 index 0000000..b924752 --- /dev/null +++ b/src/main/java/com/meishu/common/interceptor/AuthenticationInterceptor.java @@ -0,0 +1,18 @@ +package com.meishu.common.interceptor; + +import org.springframework.stereotype.Component; +import org.springframework.web.servlet.HandlerInterceptor; + +/** + *

+ * 鉴权拦截器 + *

+ * + * @author DengMin + * @since 2021/4/14 + */ +@Component +public class AuthenticationInterceptor implements HandlerInterceptor { + + +} diff --git a/src/main/java/com/meishu/common/interceptor/LoginRequired.java b/src/main/java/com/meishu/common/interceptor/LoginRequired.java new file mode 100644 index 0000000..0dab707 --- /dev/null +++ b/src/main/java/com/meishu/common/interceptor/LoginRequired.java @@ -0,0 +1,20 @@ +package com.meishu.common.interceptor; + +import java.lang.annotation.*; + +/** + *

+ * 自定义验证登陆注解 + *

+ * + * @author DengMin + * @since 2020/12/18 + */ +@Target({ElementType.METHOD}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +public @interface LoginRequired { + + String[] value(); +} \ No newline at end of file diff --git a/src/main/java/com/meishu/config/IpWhitelistInterceptor.java b/src/main/java/com/meishu/config/IpWhitelistInterceptor.java new file mode 100644 index 0000000..d75218b --- /dev/null +++ b/src/main/java/com/meishu/config/IpWhitelistInterceptor.java @@ -0,0 +1,41 @@ +package com.meishu.config; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; +import org.springframework.web.servlet.HandlerInterceptor; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.util.Arrays; +import java.util.List; + +/** + * ip白名单拦截 + */ +@Component +public class IpWhitelistInterceptor implements HandlerInterceptor { + +// @Value("${auth.ip-whitelist}") +// private String ipWhitelist; + + @Override + public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { + String ip = getClientIp(request); + List allowIps = Arrays.asList("127.0.0.1,192.168.1.100".split(",")); + +// if (!allowIps.contains(ip)) { +// response.setContentType("application/json;charset=utf-8"); +// response.getWriter().write("{\"code\":403,\"msg\":\"非法IP禁止访问\"}"); +// return false; +// } + return true; + } + + private String getClientIp(HttpServletRequest request) { + String ip = request.getHeader("X-Forwarded-For"); + if (ip == null || ip.isEmpty() || "unknown".equalsIgnoreCase(ip)) { + ip = request.getRemoteAddr(); + } + if (ip != null && ip.contains(",")) ip = ip.split(",")[0].trim(); + return ip; + } +} \ No newline at end of file diff --git a/src/main/java/com/meishu/config/WebConfig.java b/src/main/java/com/meishu/config/WebConfig.java new file mode 100644 index 0000000..1c15ff9 --- /dev/null +++ b/src/main/java/com/meishu/config/WebConfig.java @@ -0,0 +1,21 @@ +package com.meishu.config; + + +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.InterceptorRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; +import javax.annotation.Resource; + +/** + * 拦截器配置 + */ +@Configuration +public class WebConfig implements WebMvcConfigurer { + @Resource + private IpWhitelistInterceptor ipInterceptor; + + @Override + public void addInterceptors(InterceptorRegistry registry) { + registry.addInterceptor(ipInterceptor).addPathPatterns("/**"); + } +} \ No newline at end of file diff --git a/src/main/java/com/meishu/controller/AuthController.java b/src/main/java/com/meishu/controller/AuthController.java new file mode 100644 index 0000000..0a4cd09 --- /dev/null +++ b/src/main/java/com/meishu/controller/AuthController.java @@ -0,0 +1,71 @@ +package com.meishu.controller; + +import cn.hutool.core.lang.UUID; +import com.meishu.model.AuthTicket; +import com.meishu.service.AuthTicketService; +import com.meishu.util.Result; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import javax.annotation.Resource; +import javax.servlet.http.HttpSession; +import java.time.LocalDateTime; +import java.util.HashMap; +import java.util.Map; + +/** + * 登陆 获取ticket + */ +@RestController +@RequestMapping("/auth") +public class AuthController { + @Resource + private AuthTicketService ticketService; + +// @Value("${auth.ticket-expire}") +// private Integer expireSec; + + // 模拟登录 + @PostMapping("/login") + public Result login(String username, String password, HttpSession session) { + if (!"admin".equals(username) || !"123456".equals(password)) { + return Result.fail("账号密码错误"); + } + session.setAttribute("user", username); + return Result.success("登录成功"); + } + + // 获取免登Ticket + @GetMapping("/getTicket") + public Result getTicket(String platform, HttpSession session) { + String user = (String) session.getAttribute("user"); + if (user == null) return Result.fail("请先登录"); + + String ticket = UUID.fastUUID().toString(true); + LocalDateTime expire = LocalDateTime.now().plusSeconds(300); + + AuthTicket authTicket = new AuthTicket(); + authTicket.setTicket(ticket); + authTicket.setUsername(user); + authTicket.setPlatform(platform); + authTicket.setExpireTime(expire); + authTicket.setUsed(0); + + ticketService.save(authTicket); + + Map map = new HashMap<>(); + map.put("ticket", ticket); + map.put("redirectUrl", getRedirect(platform)); + return Result.success(map); + } + + private String getRedirect(String platform) { + switch (platform) { + case "erp": return "https://erp.xxx.com/callback"; + case "crm": return "https://crm.xxx.com/callback"; + default: return ""; + } + } +} \ No newline at end of file diff --git a/src/main/java/com/meishu/controller/TestController.java b/src/main/java/com/meishu/controller/TestController.java new file mode 100644 index 0000000..f8fd794 --- /dev/null +++ b/src/main/java/com/meishu/controller/TestController.java @@ -0,0 +1,36 @@ +package com.meishu.controller; + +import io.github.resilience4j.circuitbreaker.annotation.CircuitBreaker; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("/test") +public class TestController { + + // 熔断注解 + @PostMapping("rongduan") + @CircuitBreaker(name = "orderService", fallbackMethod = "fallback") + public String createOrder(String orderNo) { + System.out.println("===== 真正执行业务:用户" + "提交 ====="); + + // 模拟接口很慢(2秒) + try { + Thread.sleep(2000); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + } + + // 也可以模拟失败 + // throw new RuntimeException("提交失败"); + + return "提交成功"; + } + + // 降级方法 + public String fallback(String orderNo, Throwable t) { + return "服务熔断降级:" + orderNo; + } + +} diff --git a/src/main/java/com/meishu/controller/TicketController.java b/src/main/java/com/meishu/controller/TicketController.java new file mode 100644 index 0000000..bd7a075 --- /dev/null +++ b/src/main/java/com/meishu/controller/TicketController.java @@ -0,0 +1,43 @@ +package com.meishu.controller; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.meishu.model.AuthTicket; +import com.meishu.service.AuthTicketService; +import com.meishu.util.Result; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import javax.annotation.Resource; +import java.time.LocalDateTime; +import java.util.HashMap; +import java.util.Map; + +/** + * 三方验证ticket + */ +@RestController +@RequestMapping("/auth") +public class TicketController { + @Resource + private AuthTicketService ticketService; + + @GetMapping("/verifyTicket") + public Result verifyTicket(String ticket) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(AuthTicket::getTicket, ticket); + AuthTicket t = ticketService.getOne(wrapper); + + if (t == null) return Result.fail("Ticket不存在"); + if (t.getUsed() == 1) return Result.fail("Ticket已使用"); + if (t.getExpireTime().isBefore(LocalDateTime.now())) return Result.fail("Ticket已过期"); + + // 标记已使用 + t.setUsed(1); + ticketService.updateById(t); + + Map map = new HashMap<>(); + map.put("username", t.getUsername()); + map.put("platform", t.getPlatform()); + return Result.success(map); + } +} \ No newline at end of file diff --git a/src/main/java/com/meishu/mapper/AuthTicketMapper.java b/src/main/java/com/meishu/mapper/AuthTicketMapper.java new file mode 100644 index 0000000..f5c86c9 --- /dev/null +++ b/src/main/java/com/meishu/mapper/AuthTicketMapper.java @@ -0,0 +1,9 @@ +package com.meishu.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.meishu.model.AuthTicket; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface AuthTicketMapper extends BaseMapper { +} \ No newline at end of file diff --git a/src/main/java/com/meishu/model/AuthTicket.java b/src/main/java/com/meishu/model/AuthTicket.java new file mode 100644 index 0000000..8517a2e --- /dev/null +++ b/src/main/java/com/meishu/model/AuthTicket.java @@ -0,0 +1,26 @@ +package com.meishu.model; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; +import java.time.LocalDateTime; + +@Data +@TableName("auth_ticket") +public class AuthTicket { + + @TableId(type = IdType.AUTO) + + private Long id; + + private String ticket; + + private String username; + + private String platform; + + private LocalDateTime expireTime; + + private Integer used; +} \ No newline at end of file diff --git a/src/main/java/com/meishu/service/AuthTicketService.java b/src/main/java/com/meishu/service/AuthTicketService.java new file mode 100644 index 0000000..c055450 --- /dev/null +++ b/src/main/java/com/meishu/service/AuthTicketService.java @@ -0,0 +1,8 @@ +package com.meishu.service; + + +import com.baomidou.mybatisplus.extension.service.IService; +import com.meishu.model.AuthTicket; + +public interface AuthTicketService extends IService { +} \ No newline at end of file diff --git a/src/main/java/com/meishu/service/impl/AuthTicketServiceImpl.java b/src/main/java/com/meishu/service/impl/AuthTicketServiceImpl.java new file mode 100644 index 0000000..3c8e57c --- /dev/null +++ b/src/main/java/com/meishu/service/impl/AuthTicketServiceImpl.java @@ -0,0 +1,11 @@ +package com.meishu.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.meishu.mapper.AuthTicketMapper; +import com.meishu.model.AuthTicket; +import com.meishu.service.AuthTicketService; +import org.springframework.stereotype.Service; + +@Service +public class AuthTicketServiceImpl extends ServiceImpl implements AuthTicketService { +} \ No newline at end of file diff --git a/src/main/java/com/meishu/util/BaseModel.java b/src/main/java/com/meishu/util/BaseModel.java new file mode 100644 index 0000000..c68c7c2 --- /dev/null +++ b/src/main/java/com/meishu/util/BaseModel.java @@ -0,0 +1,35 @@ +package com.meishu.util; + +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.FieldStrategy; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableLogic; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Data; + +import java.time.LocalDateTime; + +@Data +public abstract class BaseModel { + + /** + * 创建时间 + */ + @JsonIgnore + @TableField(insertStrategy = FieldStrategy.NEVER, updateStrategy = FieldStrategy.NEVER, value = "create_time", fill = FieldFill.INSERT) + private LocalDateTime createTime; + + /** + * 更新时间 + */ + @JsonIgnore + @TableField(insertStrategy = FieldStrategy.NEVER, updateStrategy = FieldStrategy.NEVER, value = "update_time", fill = FieldFill.UPDATE) + private LocalDateTime updateTime; + + /** + * 删除时间 + */ + @JsonIgnore + @TableLogic + private LocalDateTime deleteTime; +} diff --git a/src/main/java/com/meishu/util/CodeGenerator.java b/src/main/java/com/meishu/util/CodeGenerator.java new file mode 100644 index 0000000..2e41d93 --- /dev/null +++ b/src/main/java/com/meishu/util/CodeGenerator.java @@ -0,0 +1,126 @@ +package com.meishu.util; + +import com.baomidou.mybatisplus.annotation.DbType; +import com.baomidou.mybatisplus.core.exceptions.MybatisPlusException; +import com.baomidou.mybatisplus.core.toolkit.StringPool; +import com.baomidou.mybatisplus.core.toolkit.StringUtils; +import com.baomidou.mybatisplus.generator.AutoGenerator; +import com.baomidou.mybatisplus.generator.InjectionConfig; +import com.baomidou.mybatisplus.generator.config.*; +import com.baomidou.mybatisplus.generator.config.po.TableInfo; +import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy; +import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine; + +import java.util.ArrayList; +import java.util.List; +import java.util.ResourceBundle; +import java.util.Scanner; + +/** + * Mybatis-Plus CodeGenerator + * + * @author DengMin + * @date 2020/07/02 + **/ +public class CodeGenerator { + + public static String scanner(String tip) { + StringBuilder help = new StringBuilder(); + help.append("1.生成全部表 2.输入需要生成表名"); + System.out.println(help.toString()); + Scanner scanner = new Scanner(System.in); + Integer ipt = Integer.valueOf(scanner.next()); + if(ipt == 1) { + return ""; + } else if(ipt == 2) { + StringBuilder help1 = new StringBuilder(); + help1.append("请输入" + tip + ":"); + System.out.println(help1.toString()); + Scanner scanner1 = new Scanner(System.in); + if (scanner1.hasNext()) { + String name = scanner1.next(); + if (StringUtils.isNotEmpty(name)) { + return name; + } + } + throw new MybatisPlusException("请输入正确的" + tip + "!"); + } + return scanner(tip); + } + + public static void main(String[] args) { + final ResourceBundle rb = ResourceBundle.getBundle("mybatis-plus"); + // 代码生成器 + AutoGenerator mpg = new AutoGenerator(); + + // 全局配置 + GlobalConfig gc = new GlobalConfig(); + gc.setOutputDir(System.getProperty("user.dir") + rb.getString("outputDir")); + gc.setOpen(false); + gc.setBaseResultMap(true); + gc.setBaseColumnList(true); + gc.setAuthor(rb.getString("author")); + gc.setMapperName("%sMapper"); + gc.setEntityName("%sDO"); + gc.setServiceName("%sService"); + gc.setServiceImplName("%sServiceImpl"); + gc.setControllerName("%sController"); + mpg.setGlobalConfig(gc); + + // 数据源配置 + DataSourceConfig dsc = new DataSourceConfig(); + dsc.setDbType(DbType.MYSQL); + dsc.setUrl(rb.getString("url")); + dsc.setDriverName(rb.getString("driverName")); + dsc.setUsername(rb.getString("userName")); + dsc.setPassword(rb.getString("password")); + mpg.setDataSource(dsc); + + // 包配置 + PackageConfig pc = new PackageConfig(); + pc.setParent(rb.getString("setParent")); + pc.setController("controller"); + pc.setService("service"); + pc.setServiceImpl("service.impl"); + pc.setEntity("model"); + pc.setMapper("mapper"); + mpg.setPackageInfo(pc); + + // 自定义配置 + InjectionConfig cfg = new InjectionConfig() { + @Override + public void initMap() { + // to do nothing + } + }; + List focList = new ArrayList<>(); + focList.add(new FileOutConfig("/templates/mapper.xml.ftl") { + @Override + public String outputFile(TableInfo tableInfo) { + // 自定义输入文件名称 + return System.getProperty("user.dir")+ rb.getString("mapperPath") + tableInfo.getMapperName() + StringPool.DOT_XML; + } + }); + cfg.setFileOutConfigList(focList); + mpg.setCfg(cfg); + mpg.setTemplate(new TemplateConfig().setXml(null)); + + // 策略配置 + StrategyConfig strategy = new StrategyConfig(); + strategy.setNaming(NamingStrategy.underline_to_camel); + strategy.setColumnNaming(NamingStrategy.underline_to_camel); + strategy.setSuperEntityClass(BaseModel.class); + strategy.setEntityLombokModel(true); + strategy.setRestControllerStyle(true); + String [] tables = scanner("表名,多个英文逗号分割").split(","); + if(StringUtils.isNotBlank(tables[0])) { + strategy.setInclude(tables); + } + strategy.setControllerMappingHyphenStyle(true); + mpg.setStrategy(strategy); + mpg.setTemplateEngine(new FreemarkerTemplateEngine()); + mpg.execute(); + } + + +} \ No newline at end of file diff --git a/src/main/java/com/meishu/util/Result.java b/src/main/java/com/meishu/util/Result.java new file mode 100644 index 0000000..c326387 --- /dev/null +++ b/src/main/java/com/meishu/util/Result.java @@ -0,0 +1,24 @@ +package com.meishu.util; + +import lombok.Data; + +@Data +public class Result { + private int code; + private String msg; + private T data; + + public static Result success(T data) { + Result r = new Result<>(); + r.setCode(200); + r.setMsg("成功"); + r.setData(data); + return r; + } + public static Result fail(String msg) { + Result r = new Result<>(); + r.setCode(500); + r.setMsg(msg); + return r; + } +} \ No newline at end of file diff --git a/src/main/java/com/meishu/util/excel/ExcelColumnUtil.java b/src/main/java/com/meishu/util/excel/ExcelColumnUtil.java new file mode 100644 index 0000000..256820b --- /dev/null +++ b/src/main/java/com/meishu/util/excel/ExcelColumnUtil.java @@ -0,0 +1,21 @@ +package com.meishu.util.excel; + +import java.lang.annotation.*; + +/** + *

+ * excel 字段 + *

+ * + * @author DengMin + * @date Created in 2020/08/28 + */ +@Target({ElementType.FIELD}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface ExcelColumnUtil { + + String value() default ""; + + int col() default 0; +} diff --git a/src/main/java/com/meishu/util/excel/ExcelUtil.java b/src/main/java/com/meishu/util/excel/ExcelUtil.java new file mode 100644 index 0000000..3334bf9 --- /dev/null +++ b/src/main/java/com/meishu/util/excel/ExcelUtil.java @@ -0,0 +1,574 @@ +package com.meishu.util.excel; + +import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.BooleanUtils; +import org.apache.commons.lang3.CharUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.math.NumberUtils; +import org.apache.poi.hssf.usermodel.HSSFDateUtil; +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.*; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.springframework.http.MediaType; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; +import org.springframework.web.multipart.MultipartFile; + +import javax.servlet.http.HttpServletResponse; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.lang.reflect.Constructor; +import java.lang.reflect.Field; +import java.math.BigDecimal; +import java.net.URLEncoder; +import java.util.*; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +/** + * Excel工具 + * + * @author DengMin + * @date 2019/08/27 13:57 + **/ +@Slf4j +public class ExcelUtil { + + private final static String EXCEL2003 = "xls"; + + private final static String EXCEL2007 = "xlsx"; + + /** + * 导入excel文件 + * + * @param path + * @param cls + * @param file + * @param + * @return + */ + public static List readExcelWithoutTitle(String path, Class cls, MultipartFile file) { + String fileName = file.getOriginalFilename(); + if (!fileName.matches("^.+\\.(?i)(xls)$") && !fileName.matches("^.+\\.(?i)(xlsx)$")) { + log.info("上传文件格式不正确"); +// throw new HTTPException(10022); + } + + List dataList = new ArrayList<>(); + Workbook workbook = null; + try { + InputStream is = file.getInputStream(); + if (fileName.endsWith(EXCEL2007)) { + // FileInputStream is = new FileInputStream(new File(path)); + workbook = new XSSFWorkbook(is); + } + + if (fileName.endsWith(EXCEL2003)) { + // FileInputStream is = new FileInputStream(new File(path)); + workbook = new HSSFWorkbook(is); + } + + if (workbook != null) { + Map> classMap = new HashMap<>(); + List fields = Stream.of(cls.getDeclaredFields()).collect(Collectors.toList()); + fields.forEach(field -> { + ExcelColumnUtil annotation = field.getAnnotation(ExcelColumnUtil.class); + if (annotation != null) { + String value = annotation.value(); + if (StringUtils.isBlank(value)) { + return; + } + + if (!classMap.containsKey(value)) { + classMap.put(value, new ArrayList<>()); + } + + field.setAccessible(true); + classMap.get(value).add(field); + } + }); + //索引-->columns + Map> reflectionMap = new HashMap<>(); + //默认读取第一个sheet + Sheet sheet = workbook.getSheetAt(0); + + boolean firstRow = true; + for (int i = 1; i <= sheet.getLastRowNum(); i++) { + Row row = sheet.getRow(i); + //提取标题 + if (firstRow) { + for (int j = 0; j <= row.getLastCellNum(); j++) { + Cell cell = row.getCell(j); + String cellValue = getCellValue(cell); + if (classMap.containsKey(cellValue)) { + reflectionMap.put(j, classMap.get(cellValue)); + } + } + + firstRow = false; + } else { + //忽略空白行 + if (row == null) { + continue; + } + + try { + T t = cls.newInstance(); + //判断是否为空白行 + boolean allBlank = true; + for (int j = 0; j <= row.getLastCellNum(); j++) { + if (reflectionMap.containsKey(j)) { + Cell cell = row.getCell(j); + String cellValue = getCellValue(cell); + if (StringUtils.isNotBlank(cellValue)) { + allBlank = false; + } + List fieldList = reflectionMap.get(j); + fieldList.forEach(x -> { + try { + handleField(t, cellValue, x); + } catch (Exception e) { + e.printStackTrace(); + log.error(String.format("reflect field:%s value:%s exception!", x.getName(), cellValue), e); + } + }); + } + } + + if (!allBlank) { + dataList.add(t); + } + } catch (Exception e) { + e.printStackTrace(); + log.error(String.format("parse row:%s exception!", i), e); + } + } + } + } + } catch (Exception e) { + e.printStackTrace(); + log.error(String.format("parse excel exception!"), e); + } finally { + if (workbook != null) { + try { + workbook.close(); + } catch (Exception e) { + e.printStackTrace(); + log.error(String.format("parse excel exception!"), e); + } + } + } + return dataList; + } + + /** + * 导入excel文件 + * @param path + * @param cls + * @param file + * @param + * @return + */ + public static List readExcel(String path, Class cls, MultipartFile file) { + String fileName = file.getOriginalFilename(); + if(!fileName.matches("^.+\\.(?i)(xls)$") && !fileName.matches("^.+\\.(?i)(xlsx)$")) { + log.info("上传文件格式不正确"); +// throw new HTTPException(10022); + } + + List dataList = new ArrayList<>(); + Workbook workbook = null; + try { + InputStream is = file.getInputStream(); + if (fileName.endsWith(EXCEL2007)) { + // FileInputStream is = new FileInputStream(new File(path)); + workbook = new XSSFWorkbook(is); + } + + if(fileName.endsWith(EXCEL2003)) { + // FileInputStream is = new FileInputStream(new File(path)); + workbook = new HSSFWorkbook(is); + } + + if (workbook != null) { + Map> classMap = new HashMap<>(); + List fields = Stream.of(cls.getDeclaredFields()).collect(Collectors.toList()); + fields.forEach(field -> { + ExcelColumnUtil annotation = field.getAnnotation(ExcelColumnUtil.class); + if (annotation != null) { + String value = annotation.value(); + if(StringUtils.isBlank(value)) { + return; + } + + if(!classMap.containsKey(value)) { + classMap.put(value, new ArrayList<>()); + } + + field.setAccessible(true); + classMap.get(value).add(field); + } + }); + //索引-->columns + Map> reflectionMap = new HashMap<>(); + //默认读取第一个sheet + Sheet sheet = workbook.getSheetAt(0); + + boolean firstRow = true; + for (int i = 0; i <= sheet.getLastRowNum(); i++) { + Row row = sheet.getRow(i); + //提取标题 + if (firstRow) { + for (int j = 0; j <= row.getLastCellNum(); j++) { + Cell cell = row.getCell(j); + String cellValue = getCellValue(cell); + if (classMap.containsKey(cellValue)) { + reflectionMap.put(j, classMap.get(cellValue)); + } + } + + firstRow = false; + } else { + //忽略空白行 + if (row == null) { + continue; + } + + try { + T t = cls.newInstance(); + //判断是否为空白行 + boolean allBlank = true; + for (int j = 0; j <= row.getLastCellNum(); j++) { + if (reflectionMap.containsKey(j)) { + Cell cell = row.getCell(j); + String cellValue = getCellValue(cell); + if (StringUtils.isNotBlank(cellValue)) { + allBlank = false; + } + List fieldList = reflectionMap.get(j); + fieldList.forEach(x -> { + try { + handleField(t, cellValue, x); + } catch (Exception e) { + e.printStackTrace(); + log.error(String.format("reflect field:%s value:%s exception!", x.getName(), cellValue), e); + } + }); + } + } + + if(!allBlank) { + dataList.add(t); + } + } catch (Exception e) { + e.printStackTrace(); + log.error(String.format("parse row:%s exception!", i), e); + } + } + } + } + } catch (Exception e) { + e.printStackTrace(); + log.error(String.format("parse excel exception!"), e); + } finally { + if (workbook != null) { + try { + workbook.close(); + } catch (Exception e) { + e.printStackTrace(); + log.error(String.format("parse excel exception!"), e); + } + } + } + return dataList; + } + + /** + * 导出excel文件 + * @param list + * @param cls + * @param + */ + public static void writeExcel1(List> list, Class cls){ + ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); + HttpServletResponse response = servletRequestAttributes.getResponse(); + Field[] fields = cls.getDeclaredFields(); + List fieldList = Arrays.stream(fields) + .filter(field -> { + ExcelColumnUtil annotation = field.getAnnotation(ExcelColumnUtil.class); + if (annotation != null && annotation.col() > 0) { + field.setAccessible(true); + return true; + } + return false; + }).sorted(Comparator.comparing(field -> { + int col = 0; + ExcelColumnUtil annotation = field.getAnnotation(ExcelColumnUtil.class); + if (annotation != null) { + col = annotation.col(); + } + return col; + })).collect(Collectors.toList()); + + Workbook wb = new XSSFWorkbook(); + for(int i = 0; i map = list.get(i); + String[] name = map.get("name").toString().split("-"); + Sheet sheet = wb.createSheet(name[0]); + AtomicInteger ai = new AtomicInteger(); + + { + Row row = sheet.createRow(ai.getAndIncrement()); + AtomicInteger aj = new AtomicInteger(); + //写入头部 + fieldList.forEach(field -> { + ExcelColumnUtil annotation = field.getAnnotation(ExcelColumnUtil.class); + String columnName = ""; + if (annotation != null) { + columnName = annotation.value(); + } + + Cell cell = row.createCell(aj.getAndIncrement()); + + CellStyle cellStyle = wb.createCellStyle(); + cellStyle.setFillForegroundColor(IndexedColors.PALE_BLUE.getIndex()); // 前景颜色 + setStyle(cellStyle); + + Font font = wb.createFont(); + font.setBoldweight(Font.BOLDWEIGHT_BOLD); + cellStyle.setFont(font); + cell.setCellStyle(cellStyle); + cell.setCellValue(columnName); + }); + } + + List dataList = (List) map.get("data"); + if (CollectionUtils.isNotEmpty(dataList)) { + dataList.forEach(t -> { + Row row1 = sheet.createRow(ai.getAndIncrement()); + AtomicInteger aj = new AtomicInteger(); + fieldList.forEach(field -> { + Class type = field.getType(); + Object value = ""; + try { + value = field.get(t); + } catch (Exception e) { + e.printStackTrace(); + } + Cell cell = row1.createCell(aj.getAndIncrement()); + + CellStyle cellStyle = wb.createCellStyle(); + setStyle(cellStyle); + cell.setCellStyle(cellStyle); + + if (value != null) { + if (type == Date.class) { + cell.setCellValue(value.toString()); + } else { + cell.setCellValue(value.toString()); + } + cell.setCellValue(value.toString()); + } + }); + }); + } + + // 单元格赋值后设置自动调整宽度 + for(int j = 0; j < dataList.size(); j++) { + sheet.autoSizeColumn(j); + } + } + + // 冻结窗格 + //wb.getSheet(fileName).createFreezePane(1, 1, 0, 1); + // 浏览器下载excel + buildExcelDocument(System.currentTimeMillis() + "." + EXCEL2007, wb, response); + // 生成excel文件 + // buildExcelFile(".\\default.xlsx",wb); + } + + /** + * 导出excel文件 + * @param list + * @param cls + * @param + */ + public static void writeExcel(List list, Class cls) { + ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); + HttpServletResponse response = servletRequestAttributes.getResponse(); + Field[] fields = cls.getDeclaredFields(); + List fieldList = Arrays.stream(fields).filter(field -> { + ExcelColumnUtil annotation = field.getAnnotation(ExcelColumnUtil.class); + if(annotation != null) { + field.setAccessible(true); + return true; + } + return false; + }).sorted(Comparator.comparing(field -> { + int col = 0; + ExcelColumnUtil annotation = field.getAnnotation(ExcelColumnUtil.class); + if(annotation != null) { + col = annotation.col(); + } + return col; + })).collect(Collectors.toList()); + + Workbook wb = new XSSFWorkbook(); + Sheet sheet = wb.createSheet(); + AtomicInteger ai = new AtomicInteger(); + { + Row row = sheet.createRow(ai.getAndIncrement()); + AtomicInteger at = new AtomicInteger(); + fieldList.forEach(field -> { + ExcelColumnUtil annotation = field.getAnnotation(ExcelColumnUtil.class); + String columnName = ""; + if (annotation != null) { + columnName = annotation.value(); + } + Cell cell = row.createCell(at.getAndIncrement()); + CellStyle cellStyle = wb.createCellStyle(); + cellStyle.setFillForegroundColor(IndexedColors.PALE_BLUE.getIndex()); + Font font = wb.createFont(); + font.setBoldweight(Font.BOLDWEIGHT_BOLD); + cellStyle.setFont(font); + cell.setCellStyle(cellStyle); + cell.setCellValue(columnName); + }); + + if (list != null) { + list.forEach(data -> { + Row r = sheet.createRow(ai.getAndIncrement()); + AtomicInteger a = new AtomicInteger(); + fieldList.forEach(field -> { + try { + Class type = field.getType(); + Object value = field.get(data); + Cell cell = r.createCell(a.getAndIncrement()); + if (value != null) { + cell.setCellValue(value.toString()); + } + } catch (IllegalAccessException e) { + e.printStackTrace(); + } + }); + }); + for (int i = 0; i < list.size(); i++) { + sheet.autoSizeColumn(i); + } + } + String fileName = String.valueOf(new Date().getTime()); + buildExcelDocument(fileName + "." + EXCEL2007, wb, response); + } + } + + + private static void setStyle(CellStyle cellStyle) { + // 水平居中 + cellStyle.setAlignment(CellStyle.ALIGN_CENTER); + // 垂直居中 + cellStyle.setVerticalAlignment(CellStyle.ALIGN_CENTER); + // 边框 + cellStyle.setBorderTop(CellStyle.BORDER_THIN); + // 边框 + cellStyle.setBorderLeft(CellStyle.BORDER_THIN); + // 边框 + cellStyle.setBorderRight(CellStyle.BORDER_THIN); + // 边框 + cellStyle.setBorderBottom(CellStyle.BORDER_THIN); + } + + private static void handleField(T t, String value, Field field) throws Exception { + Class type = field.getType(); + if (type == null || type == void.class || StringUtils.isBlank(value)) { + return; + } + if (type == Object.class) { + field.set(t, value); + //数字类型 + } else if (type.getSuperclass() == null || type.getSuperclass() == Number.class) { + if (type == int.class || type == Integer.class) { + field.set(t, NumberUtils.toInt(value)); + } else if (type == long.class || type == Long.class) { + field.set(t, NumberUtils.toLong(value)); + } else if (type == byte.class || type == Byte.class) { + field.set(t, NumberUtils.toByte(value)); + } else if (type == short.class || type == Short.class) { + field.set(t, NumberUtils.toShort(value)); + } else if (type == double.class || type == Double.class) { + field.set(t, NumberUtils.toDouble(value)); + } else if (type == float.class || type == Float.class) { + field.set(t, NumberUtils.toFloat(value)); + } else if (type == char.class || type == Character.class) { + field.set(t, CharUtils.toChar(value)); + } else if (type == boolean.class) { + field.set(t, BooleanUtils.toBoolean(value)); + } else if (type == BigDecimal.class) { + field.set(t, new BigDecimal(value)); + } + } else if (type == Boolean.class) { + field.set(t, BooleanUtils.toBoolean(value)); + } else if (type == Date.class) { + // + field.set(t, value); + } else if (type == String.class) { + field.set(t, value); + } else { + Constructor constructor = type.getConstructor(String.class); + field.set(t, constructor.newInstance(value)); + } + } + + private static String getCellValue(Cell cell) { + if (cell == null) { + return ""; + } + + if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) { + if (DateUtil.isCellDateFormatted(cell)) { + return HSSFDateUtil.getJavaDate(cell.getNumericCellValue()).toString(); + } else { + return new BigDecimal(cell.getNumericCellValue()).toString(); + } + } else if (cell.getCellType() == Cell.CELL_TYPE_STRING) { + return StringUtils.trimToEmpty(cell.getStringCellValue()); + } else if (cell.getCellType() == Cell.CELL_TYPE_FORMULA) { + return StringUtils.trimToEmpty(cell.getCellFormula()); + } else if (cell.getCellType() == Cell.CELL_TYPE_BLANK) { + return ""; + } else if (cell.getCellType() == Cell.CELL_TYPE_BOOLEAN) { + return String.valueOf(cell.getBooleanCellValue()); + } else if (cell.getCellType() == Cell.CELL_TYPE_ERROR) { + return "ERROR"; + } else { + return cell.toString().trim(); + } + } + + private static void buildExcelDocument(String fileName, Workbook wb, HttpServletResponse response){ + try { + response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE); + response.setHeader("Content-Disposition", "attachment;filename="+ URLEncoder.encode(fileName, "utf-8")); + response.flushBuffer(); + wb.write(response.getOutputStream()); + } catch (IOException e) { + log.error(String.format("downLoad excel exception"), e); + } + } + + private static void buildExcelFile(String path, Workbook wb){ + File file = new File(path); + if (file.exists()) { + file.delete(); + } + + try { + wb.write(new FileOutputStream(file)); + } catch (Exception e) { + log.error(String.format("downLoad excel exception"), e); + } + } +} diff --git a/src/main/resources/application-dev.properties b/src/main/resources/application-dev.properties new file mode 100644 index 0000000..1c9c506 --- /dev/null +++ b/src/main/resources/application-dev.properties @@ -0,0 +1,31 @@ +# 本地环境配置 + +# 端口号 +server.port=23451 + +# 数据源配置 +spring.datasource.url=jdbc:mysql://116.62.57.92:3306/meishu?autoReconnect=true&useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8 +spring.datasource.type=com.alibaba.druid.pool.DruidDataSource +spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver +spring.datasource.username=devloper +spring.datasource.password=dev@1553$ + +spring.datasource.druid.initialSize=5 +spring.datasource.druid.minIdle=5 +spring.datasource.druid.maxActive=20 +spring.datasource.druid.maxWait=60000 +spring.datasource.druid.timeBetweenEvictionRunsMillis=60000 +spring.datasource.druid.minEvictableIdleTimeMillis=300000 +spring.datasource.druid.validationQuery=SELECT 1 FROM DUAL +spring.datasource.druid.testWhileIdle=true +spring.datasource.druid.testOnBorrow=false +spring.datasource.druid.testOnReturn=false +spring.datasource.druid.poolPreparedStatements=true +spring.datasource.druid.maxPoolPreparedStatementPerConnectionSize=20 +spring.datasource.druid.useGlobalDataSourceStat=true + +# 控制台日志打印 +mybatis-plus.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl + +auth.ip-whitelist = 127.0.0.1,192.168.1.100 +auth-expire = 300 #ticket 有效期 300秒 \ No newline at end of file diff --git a/src/main/resources/application-prod.properties b/src/main/resources/application-prod.properties new file mode 100644 index 0000000..409531e --- /dev/null +++ b/src/main/resources/application-prod.properties @@ -0,0 +1,31 @@ +# 生产环境配置 + +# 端口号 +server.port=23451 + +# 数据源配置 +spring.datasource.url=jdbc:mysql://rm-uf69w46mo6agw0ahao.mysql.rds.aliyuncs.com:3306/meishu?autoReconnect=true&useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8 +spring.datasource.type=com.alibaba.druid.pool.DruidDataSource +spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver +spring.datasource.username=ykadmin_new +spring.datasource.password=youkedb608@good + +spring.datasource.druid.initialSize=5 +spring.datasource.druid.minIdle=5 +spring.datasource.druid.maxActive=20 +spring.datasource.druid.maxWait=60000 +spring.datasource.druid.timeBetweenEvictionRunsMillis=60000 +spring.datasource.druid.minEvictableIdleTimeMillis=300000 +spring.datasource.druid.validationQuery=SELECT 1 FROM DUAL +spring.datasource.druid.testWhileIdle=true +spring.datasource.druid.testOnBorrow=false +spring.datasource.druid.testOnReturn=false +spring.datasource.druid.poolPreparedStatements=true +spring.datasource.druid.maxPoolPreparedStatementPerConnectionSize=20 +spring.datasource.druid.useGlobalDataSourceStat=true + +# 控制台日志打印 +mybatis-plus.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl + +spring.servlet.multipart.max-file-size=2048KB +spring.servlet.multipart.max-request-size=4098KB diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties new file mode 100644 index 0000000..eed7c85 --- /dev/null +++ b/src/main/resources/application.properties @@ -0,0 +1,37 @@ +# 环境配置 +spring.profiles.active=dev + +# 文件编码 UTF8 +spring.mandatory-file-encoding=UTF-8 +spring.jackson.time-zone=GMT+8 + +# 404 交给异常处理器处理 +spring.mvc.throw-exception-if-no-handler-found=true +# 关闭静态资源的映射 +spring.resources.add-mappings=false + +# 关闭banner打印getOneReport +mybatis-plus.global-config.banner=false + +# mybatis-plus相关配置 +mybatis-plus.mapper-locations=classpath:mapper/*.xml +# 是否开启自动驼峰命名规则映射 +mybatis-plus.configuration.map-underscore-to-camel-case=true +# 如果查询结果中包含空值的列,则 MyBatis 在映射的时候,不会映射这个字段 +mybatis-plus.configuration.call-setters-on-nulls=true + +# 逻辑删除 +mybatis-plus.global-config.db-config.logic-delete-value=NOW() +mybatis-plus.global-config.db-config.logic-not-delete-value=NULL + +#日志配置 +logging.config=classpath:logback-spring.xml + +resilience4j.circuitbreaker.configs.default.failure-rate-threshold=50 +resilience4j.circuitbreaker.configs.default.sliding-window-size=5 +resilience4j.circuitbreaker.configs.default.minimum-number-of-calls=10 +resilience4j.circuitbreaker.configs.default.max-wait-duration-in-half-open-state = 10000 +resilience4j.circuitbreaker.configs.default.permitted-number-of-calls-in-half-open-state=3 +resilience4j.circuitbreaker.configs.default.slow-call-rate-threshold=100 +resilience4j.circuitbreaker.configs.default.slow-call-duration-threshold=1500 +resilience4j.circuitbreaker.configs.instances.base-config=default \ No newline at end of file diff --git a/src/main/resources/code.properties b/src/main/resources/code.properties new file mode 100644 index 0000000..153ad1c --- /dev/null +++ b/src/main/resources/code.properties @@ -0,0 +1,43 @@ +meishu.code-message[0]=成功 + +meishu.code-message[1010]=无效的令牌 + +meishu.code-message[10003]=验证码错误 +meishu.code-message[10010]=学生信息不存在 +meishu.code-message[10011]=成员信息不存在 +meishu.code-message[10013]=账户已冻结,请联系账户管理员 +meishu.code-message[10014]=该学生已存在,请勿重复添加 +meishu.code-message[10015]=校区不存在 +meishu.code-message[10016]=当前位置不在打卡范围内 +meishu.code-message[10017]=今日已完成签到 +meishu.code-message[10018]=家长信息不存在 +meishu.code-message[10019]=院校不存在 +meishu.code-message[10020]=您已注册过账号,请直接登录 +meishu.code-message[10021]=信息不存在 + + +meishu.code-message[20001]=该部门已存在 + + +meishu.code-message[30001]=该知识点已存在 +meishu.code-message[30002]=该知识点已被课程使用,无法删除 +meishu.code-message[30003]=已添加至课程,无法删除 + + +meishu.code-message[40001]=已超过测试时间 + +meishu.code-message[50001]=压缩失败 + +meishu.code-message[60001]=该成员已存在,请勿重复添加 +meishu.code-message[60002]=请返回上级填写学生届数 + +meishu.code-message[70001]=该标签类型已存在 +meishu.code-message[70002]=该标签类型下还有标签,无法删除 + +meishu.code-message[80002]=其他老师已评价 + +meishu.code-message[90001]=考试已存在 + +meishu.code-message[10001]=账户密码不正确 + + diff --git a/src/main/resources/logback-spring.xml b/src/main/resources/logback-spring.xml new file mode 100644 index 0000000..dfd4cbb --- /dev/null +++ b/src/main/resources/logback-spring.xml @@ -0,0 +1,72 @@ + + + + + ${APP_NAME} + + + + + debug + + + %d [%t] %5p %c:%L - %m%n + UTF-8 + + + + ${LOG_PATH}${APP_NAME}-info.log + + %d [%t] %5p %c:%L - %m%n + + + + 100MB + + ${LOG_PATH}${APP_NAME}/info/%d{yyyy-MM-dd}-%i.log.gz + + 30 + + + + ${LOG_PATH}${APP_NAME}-error.log + + error + + + %d [%t] %5p %c:%L - %m%n + + + + 256MB + + ${LOG_PATH}${APP_NAME}/error/%d{yyyy-MM-dd}-%i.log.gz + + 30 + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/mapper/AuthTicketMapper.xml b/src/main/resources/mapper/AuthTicketMapper.xml new file mode 100644 index 0000000..6b0b14c --- /dev/null +++ b/src/main/resources/mapper/AuthTicketMapper.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/src/main/resources/mybatis-plus.properties b/src/main/resources/mybatis-plus.properties new file mode 100644 index 0000000..1c24fdb --- /dev/null +++ b/src/main/resources/mybatis-plus.properties @@ -0,0 +1,12 @@ +# 此处为本项目src所在路径(代码生成器输出路径) +outputDir=\\src\\main\\java +author=Tuyp +# 父的包名 +setParent=com.meishu +# mapper.xml文件生成路径 +mapperPath=/src/main/resources/mapper/ +# 数据库地址 +url=jdbc:mysql://116.62.57.92:3306/meishu?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&useSSL=false&allowMultiQueries=true&useAffectedRows=true&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true +driverName=com.mysql.cj.jdbc.Driver +userName=devloper +password=dev@1553$ \ No newline at end of file diff --git a/src/main/resources/mybatis.xml b/src/main/resources/mybatis.xml new file mode 100644 index 0000000..68f74a9 --- /dev/null +++ b/src/main/resources/mybatis.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/src/main/resources/templates/controller.java.ftl b/src/main/resources/templates/controller.java.ftl new file mode 100644 index 0000000..28e7070 --- /dev/null +++ b/src/main/resources/templates/controller.java.ftl @@ -0,0 +1,41 @@ +package ${package.Controller}; + + +import org.springframework.web.bind.annotation.RequestMapping; + +<#if restControllerStyle> +import org.springframework.web.bind.annotation.RestController; +<#else> +import org.springframework.stereotype.Controller; + +<#if superControllerClassPackage??> +import ${superControllerClassPackage}; + +import io.swagger.annotations.Api; + +/** + *

+ * ${table.comment!} 前端控制器 + *

+ * + * @author ${author} + * @since ${date} + */ +<#if restControllerStyle> +@RestController +@Api(tags = "${table.comment!}") +<#else> +@Controller + +@RequestMapping("<#if package.ModuleName?? && package.ModuleName != "">/${package.ModuleName}/<#if controllerMappingHyphenStyle??>${controllerMappingHyphen}<#else>${table.entityPath}") +<#if kotlin> +class ${table.controllerName}<#if superControllerClass??> : ${superControllerClass}() +<#else> +<#if superControllerClass??> +public class ${table.controllerName} extends ${superControllerClass} { +<#else> +public class ${table.controllerName} { + + +} + diff --git a/src/main/resources/templates/entity.java.ftl b/src/main/resources/templates/entity.java.ftl new file mode 100644 index 0000000..c63bcc4 --- /dev/null +++ b/src/main/resources/templates/entity.java.ftl @@ -0,0 +1,156 @@ +package ${package.Entity}; + +<#list table.importPackages as pkg> +import ${pkg}; + +<#if swagger2> +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +<#if entityLombokModel> +import lombok.Data; +import lombok.EqualsAndHashCode; + <#if chainModel> +import lombok.experimental.Accessors; + + + +/** + *

+ * ${table.comment!} + *

+ * + * @author ${author} + * @since ${date} + */ +<#if entityLombokModel> +@Data + <#if superEntityClass??> +@EqualsAndHashCode(callSuper = true) + <#else> +@EqualsAndHashCode(callSuper = false) + + <#if chainModel> +@Accessors(chain = true) + + +<#if table.convert> +@TableName("${table.name}") + +<#if swagger2> +@ApiModel(value="${entity}对象", description="${table.comment!}") + +<#if superEntityClass??> +public class ${entity} extends ${superEntityClass}<#if activeRecord><${entity}> { +<#elseif activeRecord> +public class ${entity} extends Model<${entity}> { +<#else> +public class ${entity} implements Serializable { + + +<#if entitySerialVersionUID> + private static final long serialVersionUID = 1L; + +<#-- ---------- BEGIN 字段循环遍历 ----------> +<#list table.fields as field> + <#if field.keyFlag> + <#assign keyPropertyName="${field.propertyName}"/> + + + <#if field.comment!?length gt 0> + <#if swagger2> + @ApiModelProperty(value = "${field.comment}") + <#else> + /** + * ${field.comment} + */ + + + <#if field.keyFlag> + <#-- 主键 --> + <#if field.keyIdentityFlag> + @TableId(value = "${field.annotationColumnName}", type = IdType.AUTO) + <#elseif idType??> + @TableId(value = "${field.annotationColumnName}", type = IdType.${idType}) + <#elseif field.convert> + @TableId("${field.annotationColumnName}") + + <#-- 普通字段 --> + <#elseif field.fill??> + <#-- ----- 存在字段填充设置 -----> + <#if field.convert> + @TableField(value = "${field.annotationColumnName}", fill = FieldFill.${field.fill}) + <#else> + @TableField(fill = FieldFill.${field.fill}) + + <#elseif field.convert> + @TableField("${field.annotationColumnName}") + + <#-- 乐观锁注解 --> + <#if (versionFieldName!"") == field.name> + @Version + + <#-- 逻辑删除注解 --> + <#if (logicDeleteFieldName!"") == field.name> + @TableLogic + + private ${field.propertyType} ${field.propertyName}; + +<#------------ END 字段循环遍历 ----------> + +<#if !entityLombokModel> + <#list table.fields as field> + <#if field.propertyType == "boolean"> + <#assign getprefix="is"/> + <#else> + <#assign getprefix="get"/> + + public ${field.propertyType} ${getprefix}${field.capitalName}() { + return ${field.propertyName}; + } + + <#if chainModel> + public ${entity} set${field.capitalName}(${field.propertyType} ${field.propertyName}) { + <#else> + public void set${field.capitalName}(${field.propertyType} ${field.propertyName}) { + + this.${field.propertyName} = ${field.propertyName}; + <#if chainModel> + return this; + + } + + + +<#if entityColumnConstant> + <#list table.fields as field> + public static final String ${field.name?upper_case} = "${field.name}"; + + + +<#if activeRecord> + @Override + protected Serializable pkVal() { + <#if keyPropertyName??> + return this.${keyPropertyName}; + <#else> + return null; + + } + + +<#if !entityLombokModel> + @Override + public String toString() { + return "${entity}{" + + <#list table.fields as field> + <#if field_index==0> + "${field.propertyName}=" + ${field.propertyName} + + <#else> + ", ${field.propertyName}=" + ${field.propertyName} + + + + "}"; + } + +} diff --git a/src/main/resources/templates/mapper.java.ftl b/src/main/resources/templates/mapper.java.ftl new file mode 100644 index 0000000..be08c59 --- /dev/null +++ b/src/main/resources/templates/mapper.java.ftl @@ -0,0 +1,22 @@ +package ${package.Mapper}; + +import ${package.Entity}.${entity}; +import ${superMapperClassPackage}; +import org.springframework.stereotype.Repository; + +/** + *

+ * ${table.comment!} Mapper 接口 + *

+ * + * @author ${author} + * @since ${date} + */ +<#if kotlin> +interface ${table.mapperName} : ${superMapperClass}<${entity}> +<#else> + @Repository +public interface ${table.mapperName} extends ${superMapperClass}<${entity}> { + +} + diff --git a/src/main/resources/templates/mapper.xml.ftl b/src/main/resources/templates/mapper.xml.ftl new file mode 100644 index 0000000..04c2359 --- /dev/null +++ b/src/main/resources/templates/mapper.xml.ftl @@ -0,0 +1,39 @@ + + + + +<#if enableCache> + + + + +<#if baseResultMap> + + +<#list table.fields as field> +<#if field.keyFlag><#--生成主键排在第一位--> + + + +<#list table.commonFields as field><#--生成公共字段 --> + + +<#list table.fields as field> +<#if !field.keyFlag><#--生成普通字段 --> + + + + + + +<#if baseColumnList> + + +<#list table.commonFields as field> + ${field.columnName}, + + ${table.fieldNames} + + + + diff --git a/src/main/resources/templates/service.java.ftl b/src/main/resources/templates/service.java.ftl new file mode 100644 index 0000000..e3232f3 --- /dev/null +++ b/src/main/resources/templates/service.java.ftl @@ -0,0 +1,20 @@ +package ${package.Service}; + +import ${package.Entity}.${entity}; +import ${superServiceClassPackage}; + +/** + *

+ * ${table.comment!} 服务类 + *

+ * + * @author ${author} + * @since ${date} + */ +<#if kotlin> +interface ${table.serviceName} : ${superServiceClass}<${entity}> +<#else> +public interface ${table.serviceName} extends ${superServiceClass}<${entity}> { + +} + diff --git a/src/main/resources/templates/serviceImpl.java.ftl b/src/main/resources/templates/serviceImpl.java.ftl new file mode 100644 index 0000000..aeebd14 --- /dev/null +++ b/src/main/resources/templates/serviceImpl.java.ftl @@ -0,0 +1,26 @@ +package ${package.ServiceImpl}; + +import ${package.Entity}.${entity}; +import ${package.Mapper}.${table.mapperName}; +import ${package.Service}.${table.serviceName}; +import ${superServiceImplClassPackage}; +import org.springframework.stereotype.Service; + +/** + *

+ * ${table.comment!} 服务实现类 + *

+ * + * @author ${author} + * @since ${date} + */ +@Service +<#if kotlin> +open class ${table.serviceImplName} : ${superServiceImplClass}<${table.mapperName}, ${entity}>(), ${table.serviceName} { + +} +<#else> +public class ${table.serviceImplName} extends ${superServiceImplClass}<${table.mapperName}, ${entity}> implements ${table.serviceName} { + +} + -- libgit2 0.25.0