diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..5585bd3
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,244 @@
+
+
+ 4.0.0
+ com.jinhaiqimeng
+ sysManageMicroservice
+ 0.0.1-SNAPSHOT
+ war
+ sysManageMicroservice
+ 系统管理中台
+
+ 1.8
+ UTF-8
+ UTF-8
+ 2.6.13
+ 2021.0.5
+ 2021.0.5.0
+
+ 3.3.1.tmp
+ 3.3.1.tmp
+
+ 5.3.9
+
+ 3.0.0
+
+ 2.2.2
+
+ 11.10
+
+ 1.2.83
+
+ 2.2.6.RELEASE
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+
+ com.alibaba.cloud
+ spring-cloud-starter-alibaba-sentinel
+
+
+ org.springframework.boot
+ spring-boot-starter-validation
+
+
+ org.mybatis.spring.boot
+ mybatis-spring-boot-starter
+ ${mybatis.version}
+
+
+
+
+
+
+ org.springframework.cloud
+ spring-cloud-starter-openfeign
+ ${openfeign.version}
+
+
+ io.github.openfeign
+ feign-okhttp
+ ${okhttp.version}
+
+
+ org.springframework.boot
+ spring-boot-configuration-processor
+ true
+
+
+ org.projectlombok
+ lombok
+ true
+
+
+ org.springframework.boot
+ spring-boot-starter-tomcat
+ provided
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+
+ com.alibaba
+ druid-spring-boot-starter
+ 1.1.22
+
+
+
+ com.baomidou
+ mybatis-plus-boot-starter
+ ${mybatis-plus.version}
+
+
+
+ org.freemarker
+ freemarker
+
+
+
+ com.baomidou
+ mybatis-plus-generator
+ ${mybatis-generator.version}
+
+
+
+ cn.hutool
+ hutool-all
+ ${hutool.version}
+
+
+
+ io.springfox
+ springfox-boot-starter
+ ${swagger.version}
+
+
+
+ com.github.xiaoymin
+ knife4j-spring-boot-starter
+ 3.0.2
+
+
+
+ org.apache.commons
+ commons-pool2
+
+
+ org.apache.commons
+ commons-lang3
+ 3.9
+
+
+
+
+ com.alibaba
+ fastjson
+ ${fastjson.version}
+
+
+
+ mysql
+ mysql-connector-java
+ 8.0.11
+
+
+
+
+
+
+ org.springframework.cloud
+ spring-cloud-dependencies
+ ${spring-cloud.version}
+ pom
+ import
+
+
+ com.alibaba.cloud
+ spring-cloud-alibaba-dependencies
+ ${spring-cloud-alibaba.version}
+ pom
+ import
+
+
+ org.springframework.boot
+ spring-boot-dependencies
+ ${spring-boot.version}
+ pom
+ import
+
+
+
+
+
+
+ nexus
+ Nexus Repository
+ http://nexus.derunht.cn/repository/maven-public/
+
+ true
+
+
+ true
+
+
+
+
+
+
+ nexus
+ Nexus Plugin Repository
+ http://nexus.derunht.cn/repository/maven-public/
+
+ true
+
+
+ true
+
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+ 1.4.2.RELEASE
+
+
+ com.jinhaiqimeng.sysManageMicroservice.SysManageMicroserviceApplication
+
+
+
+
+ repackage
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-war-plugin
+ 3.2.3
+
+ false
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+
+
+ 8
+
+
+
+
+
+
diff --git a/src/main/java/com/jinhaiqimeng/sysManageMicroservice/ServletInitializer.java b/src/main/java/com/jinhaiqimeng/sysManageMicroservice/ServletInitializer.java
new file mode 100644
index 0000000..e09d9d7
--- /dev/null
+++ b/src/main/java/com/jinhaiqimeng/sysManageMicroservice/ServletInitializer.java
@@ -0,0 +1,13 @@
+package com.jinhaiqimeng.sysManageMicroservice;
+
+import org.springframework.boot.builder.SpringApplicationBuilder;
+import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
+
+public class ServletInitializer extends SpringBootServletInitializer {
+
+ @Override
+ protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
+ return application.sources(SysManageMicroserviceApplication.class);
+ }
+
+}
diff --git a/src/main/java/com/jinhaiqimeng/sysManageMicroservice/SysManageMicroserviceApplication.java b/src/main/java/com/jinhaiqimeng/sysManageMicroservice/SysManageMicroserviceApplication.java
new file mode 100644
index 0000000..db9bdf8
--- /dev/null
+++ b/src/main/java/com/jinhaiqimeng/sysManageMicroservice/SysManageMicroserviceApplication.java
@@ -0,0 +1,17 @@
+package com.jinhaiqimeng.sysManageMicroservice;
+
+import org.mybatis.spring.annotation.MapperScan;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.cloud.openfeign.EnableFeignClients;
+
+@MapperScan(basePackages ="com.jinhaiqimeng.sysManageMicroservice.web.dao")
+@EnableFeignClients(basePackages= "com.jinhaiqimeng.sysManageMicroservice.feign")
+@SpringBootApplication
+public class SysManageMicroserviceApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.run(SysManageMicroserviceApplication.class, args);
+ }
+
+}
diff --git a/src/main/java/com/jinhaiqimeng/sysManageMicroservice/config/FeignConfiguration.java b/src/main/java/com/jinhaiqimeng/sysManageMicroservice/config/FeignConfiguration.java
new file mode 100644
index 0000000..041bb81
--- /dev/null
+++ b/src/main/java/com/jinhaiqimeng/sysManageMicroservice/config/FeignConfiguration.java
@@ -0,0 +1,18 @@
+package com.jinhaiqimeng.sysManageMicroservice.config;
+
+import feign.Logger;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * Feign 客户端日志配置
+ */
+@Configuration
+public class FeignConfiguration {
+
+ @Bean
+ Logger.Level feignLevel() {
+ return Logger.Level.BASIC;
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/java/com/jinhaiqimeng/sysManageMicroservice/config/FeignOkHttpConfig.java b/src/main/java/com/jinhaiqimeng/sysManageMicroservice/config/FeignOkHttpConfig.java
new file mode 100644
index 0000000..9cf906d
--- /dev/null
+++ b/src/main/java/com/jinhaiqimeng/sysManageMicroservice/config/FeignOkHttpConfig.java
@@ -0,0 +1,39 @@
+package com.jinhaiqimeng.sysManageMicroservice.config;
+
+import feign.Feign;
+import okhttp3.ConnectionPool;
+import org.springframework.boot.autoconfigure.AutoConfigureBefore;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
+import org.springframework.cloud.openfeign.FeignAutoConfiguration;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import java.util.concurrent.TimeUnit;
+
+/**
+ * @ClassName OpenFeignInterfaceConfiguration
+ * @Description OpenFeignConfig 配置管理
+ * @Author chaixueteng
+ * @Date 2020/3/10 9:46
+ */
+@Configuration
+@ConditionalOnClass(Feign.class)
+@AutoConfigureBefore(FeignAutoConfiguration.class)
+public class FeignOkHttpConfig {
+
+
+ @Bean
+ public okhttp3.OkHttpClient okHttpClient(){
+ return new okhttp3.OkHttpClient.Builder()
+ //设置连接超时
+ .connectTimeout(15, TimeUnit.SECONDS)
+ //设置读超时
+ .readTimeout(15, TimeUnit.SECONDS)
+ //是否自动重连
+ .retryOnConnectionFailure(true)
+ // 最大连接数、连接存活时间、存活时间单位(分钟)
+ .connectionPool(new ConnectionPool(200, 5, TimeUnit.MINUTES))
+ //构建OkHttpClient对象
+ .build();
+ }
+}
diff --git a/src/main/java/com/jinhaiqimeng/sysManageMicroservice/config/MyBatisPlusConfig.java b/src/main/java/com/jinhaiqimeng/sysManageMicroservice/config/MyBatisPlusConfig.java
new file mode 100644
index 0000000..4237ec3
--- /dev/null
+++ b/src/main/java/com/jinhaiqimeng/sysManageMicroservice/config/MyBatisPlusConfig.java
@@ -0,0 +1,27 @@
+package com.jinhaiqimeng.sysManageMicroservice.config;
+
+import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
+import com.baomidou.mybatisplus.extension.plugins.pagination.optimize.JsqlParserCountOptimize;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.transaction.annotation.EnableTransactionManagement;
+
+/**
+ * @ClassName MyBatisPlusConfig
+ * @Description mybatisPlus配置
+ * @Author chaixueteng
+ * @Date 2020/3/11 10:33
+ */
+@Configuration
+@EnableTransactionManagement
+public class MyBatisPlusConfig {
+ /**
+ * 分页插件
+ */
+ @Bean
+ public PaginationInterceptor paginationInterceptor() {
+ PaginationInterceptor paginationInterceptor = new PaginationInterceptor();
+ paginationInterceptor.setCountSqlParser(new JsqlParserCountOptimize(true));
+ return new PaginationInterceptor();
+ }
+}
diff --git a/src/main/java/com/jinhaiqimeng/sysManageMicroservice/config/MybatisGenerator.java b/src/main/java/com/jinhaiqimeng/sysManageMicroservice/config/MybatisGenerator.java
new file mode 100644
index 0000000..ff16737
--- /dev/null
+++ b/src/main/java/com/jinhaiqimeng/sysManageMicroservice/config/MybatisGenerator.java
@@ -0,0 +1,145 @@
+package com.jinhaiqimeng.sysManageMicroservice.config;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.core.exceptions.MybatisPlusException;
+import com.baomidou.mybatisplus.core.toolkit.StringPool;
+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 org.apache.commons.lang3.StringUtils;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Scanner;
+
+/**
+ * @ClassName MybatisGenerator
+ * @Description mybatis生成器
+ * @Author chaixueteng
+ * @Date 2020/3/11 10:34
+ */
+public class MybatisGenerator {
+
+ private static final String MYSQL_URL ="jdbc:mysql://120.46.194.248:13306/jinhaiqimengdb?useSSL=false";
+ private static final String MYSQL_DRIVE ="com.mysql.jdbc.Driver";
+ private static final String MYSQL_U ="orgMicroservice_user";
+ private static final String MYSQL_P ="!XkCEn#PWFcPq$hy";
+
+
+ /**
+ *
+ * 读取控制台内容
+ *
+ */
+ @SuppressWarnings("resource")
+ public static String scanner(String tip) {
+ Scanner scanner = new Scanner(System.in);
+ StringBuilder help = new StringBuilder();
+ help.append("请输入" + tip + ":");
+ System.out.println(help.toString());
+ if (scanner.hasNext()) {
+ String ipt = scanner.next();
+ if (StringUtils.isNotEmpty(ipt)) {
+ return ipt;
+ }
+ }
+ throw new MybatisPlusException("请输入正确的" + tip + "!");
+ }
+
+ public static void main(String[] args) {
+ // 代码生成器
+ AutoGenerator mpg = new AutoGenerator();
+
+ // 全局配置
+ GlobalConfig gc = new GlobalConfig();
+ final String projectPath = System.getProperty("user.dir");
+ gc.setOutputDir(projectPath + "/src/main/java");
+ gc.setAuthor("cxj");
+ gc.setOpen(false);
+ gc.setServiceName("%sService");// service 命名方式
+ gc.setServiceImplName("%sServiceImpl");// service impl 命名方式
+ // 自定义文件命名,注意 %s 会自动填充表实体属性!
+ gc.setMapperName("%sDao");
+ gc.setXmlName("%sDao");
+ gc.setFileOverride(true);
+ gc.setActiveRecord(true);
+ gc.setEnableCache(false);// XML 二级缓存
+ gc.setBaseResultMap(true);// XML ResultMap
+ gc.setBaseColumnList(true);// XML columList
+ gc.setIdType(IdType.ASSIGN_ID);
+ gc.setSwagger2(true);
+ mpg.setGlobalConfig(gc);
+
+ // 数据源配置
+ DataSourceConfig dsc = new DataSourceConfig();
+ dsc.setUrl(MYSQL_URL);
+ // dsc.setSchemaName("public");
+ dsc.setDriverName(MYSQL_DRIVE);
+ dsc.setUsername(MYSQL_U);
+ dsc.setPassword(MYSQL_P);
+ mpg.setDataSource(dsc);
+
+ // 包配置
+ PackageConfig pc = new PackageConfig();
+ //pc.setModuleName(scanner("模块名"));
+ pc.setParent("com.jinhaiqimeng.orgMicroservice.web");
+ pc.setEntity("entity");
+ pc.setService("service");
+ pc.setServiceImpl("service.impl");
+ pc.setController("controller");// 设置控制器包名
+ pc.setMapper("dao");
+ mpg.setPackageInfo(pc);
+
+ // 自定义配置
+ InjectionConfig cfg = new InjectionConfig() {
+ @Override
+ public void initMap() {}
+ };
+
+ // 如果模板引擎是 freemarker
+ String templatePath = "/templates/mapper.xml.ftl";
+
+ // 自定义输出配置
+ List focList = new ArrayList();
+ // 自定义配置会被优先输出
+ focList.add(new FileOutConfig(templatePath) {
+ @Override
+ public String outputFile(TableInfo tableInfo) {
+ // 自定义输出文件名
+ return projectPath + "/src/main/resources/mapping/"
+ + tableInfo.getEntityName() + "Dao" + StringPool.DOT_XML;
+ }
+ });
+
+ cfg.setFileOutConfigList(focList);
+ mpg.setCfg(cfg);
+
+ // 配置模板
+ TemplateConfig templateConfig = new TemplateConfig();
+
+ templateConfig.setXml(null);
+ mpg.setTemplate(templateConfig);
+
+ // 策略配置
+ StrategyConfig strategy = new StrategyConfig();
+ strategy.setNaming(NamingStrategy.underline_to_camel);
+ //生成时 添加字段注解,解决数据库字段与实体类不一致问题 比如 mysql :f_id pojo:id
+ strategy.entityTableFieldAnnotationEnable(true);
+ strategy.setColumnNaming(NamingStrategy.underline_to_camel);
+ strategy.setRestControllerStyle(true);
+ strategy.setInclude(scanner("表名"));
+ strategy.setControllerMappingHyphenStyle(true);
+ strategy.setEntityLombokModel(true);
+ strategy.setTablePrefix("t_org_microservice");
+ strategy.setFieldPrefix("f_");
+ mpg.setStrategy(strategy);
+ mpg.setTemplateEngine(new FreemarkerTemplateEngine());
+ mpg.execute();;
+ }
+}
+
+
+
diff --git a/src/main/java/com/jinhaiqimeng/sysManageMicroservice/config/SwaggerConfig.java b/src/main/java/com/jinhaiqimeng/sysManageMicroservice/config/SwaggerConfig.java
new file mode 100644
index 0000000..f4814a7
--- /dev/null
+++ b/src/main/java/com/jinhaiqimeng/sysManageMicroservice/config/SwaggerConfig.java
@@ -0,0 +1,40 @@
+package com.jinhaiqimeng.sysManageMicroservice.config;
+
+import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import springfox.documentation.builders.ApiInfoBuilder;
+import springfox.documentation.builders.PathSelectors;
+import springfox.documentation.builders.RequestHandlerSelectors;
+import springfox.documentation.oas.annotations.EnableOpenApi;
+import springfox.documentation.spi.DocumentationType;
+import springfox.documentation.spring.web.plugins.Docket;
+
+@Configuration
+@EnableOpenApi
+@EnableKnife4j
+public class SwaggerConfig {
+
+ @Bean
+ Docket docket(){
+ // 设置 swagger的版本
+ return new Docket(DocumentationType.OAS_30)
+ // 选择生成接口文档
+ .select()
+ // 包所在的路径
+ .apis(RequestHandlerSelectors.basePackage("com.jinhaiqimeng.sysManageMicroservice.web.controller"))
+ // 当前包下所有接口都生成
+ .paths(PathSelectors.any())
+ .build()
+ // 接口文档初始化,也就是设置接口文档的详细信息,
+ .apiInfo(
+ new ApiInfoBuilder()
+ .description("系统管理中台接口文档")
+ .version("v1.0")
+ .title("API 测试文档")
+ .license("Apache 2.0")
+ .licenseUrl("http://www.apache.org/licenses/LICENSE-2.0")
+ .build()
+ );
+ }
+}
diff --git a/src/main/java/com/jinhaiqimeng/sysManageMicroservice/config/ThreadPoolTaskConfig.java b/src/main/java/com/jinhaiqimeng/sysManageMicroservice/config/ThreadPoolTaskConfig.java
new file mode 100644
index 0000000..5aa2736
--- /dev/null
+++ b/src/main/java/com/jinhaiqimeng/sysManageMicroservice/config/ThreadPoolTaskConfig.java
@@ -0,0 +1,53 @@
+package com.jinhaiqimeng.sysManageMicroservice.config;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.scheduling.annotation.EnableAsync;
+import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
+
+import java.util.concurrent.ThreadPoolExecutor;
+
+/**
+ * @ClassName ThreadPoolTaskConfig
+ * @Description 异步线程池配置
+ * @Author chaixueteng
+ * @Date 2020/3/14 14:41
+ */
+@Configuration
+@EnableAsync
+public class ThreadPoolTaskConfig {
+ /**
+ * 默认情况下,在创建了线程池后,线程池中的线程数为0,当有任务来之后,就会创建一个线程去执行任务,
+ * 当线程池中的线程数目达到corePoolSize后,就会把到达的任务放到缓存队列当中;
+ * 当队列满了,就继续创建线程,当线程数量大于等于maxPoolSize后,开始使用拒绝策略拒绝
+ */
+
+ /** 核心线程数(默认线程数) */
+ private static final int corePoolSize = 20;
+ /** 最大线程数 */
+ private static final int maxPoolSize = 100;
+ /** 允许线程空闲时间(单位:默认为秒) */
+ private static final int keepAliveTime = 10;
+ /** 缓冲队列大小 */
+ private static final int queueCapacity = 200;
+ /** 线程池名前缀 */
+ private static final String threadNamePrefix = "Async-Service-";
+
+ @Bean("taskExecutor") // bean的名称,默认为首字母小写的方法名
+ public ThreadPoolTaskExecutor taskExecutor(){
+ ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
+ executor.setCorePoolSize(corePoolSize);
+ executor.setMaxPoolSize(maxPoolSize);
+ executor.setQueueCapacity(queueCapacity);
+ executor.setKeepAliveSeconds(keepAliveTime);
+ executor.setThreadNamePrefix(threadNamePrefix);
+
+ // 线程池对拒绝任务的处理策略
+ // CallerRunsPolicy:由调用线程(提交任务的线程)处理该任务
+ executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
+ // 初始化
+ executor.initialize();
+ return executor;
+ }
+
+}
diff --git a/src/main/java/com/jinhaiqimeng/sysManageMicroservice/exception/CommonException.java b/src/main/java/com/jinhaiqimeng/sysManageMicroservice/exception/CommonException.java
new file mode 100644
index 0000000..58aa79e
--- /dev/null
+++ b/src/main/java/com/jinhaiqimeng/sysManageMicroservice/exception/CommonException.java
@@ -0,0 +1,35 @@
+package com.jinhaiqimeng.sysManageMicroservice.exception;
+
+
+/**
+ * 自定义异常
+ * @author chaixueteng
+ */
+public class CommonException extends RuntimeException {
+ private int errorCode;
+ private String msg;
+
+ public CommonException(int errorCode, String msg) {
+ super(msg);
+ this.errorCode = errorCode;
+ this.msg = msg;
+ }
+
+ public String getMsg() {
+ return msg;
+ }
+
+ public int getErrorCode() {
+ return errorCode;
+ }
+
+ /**
+ * 重新异常堆栈信息处理,避免遍历堆栈资源浪费,提供性能
+ * @return a reference to this {@code Throwable} instance.
+ * @see Throwable#printStackTrace()
+ */
+ @Override
+ public synchronized Throwable fillInStackTrace() {
+ return this;
+ }
+}
diff --git a/src/main/java/com/jinhaiqimeng/sysManageMicroservice/exception/MyControllerAdvice.java b/src/main/java/com/jinhaiqimeng/sysManageMicroservice/exception/MyControllerAdvice.java
new file mode 100644
index 0000000..3e7f18d
--- /dev/null
+++ b/src/main/java/com/jinhaiqimeng/sysManageMicroservice/exception/MyControllerAdvice.java
@@ -0,0 +1,79 @@
+package com.jinhaiqimeng.sysManageMicroservice.exception;
+
+import cn.hutool.core.util.StrUtil;
+import com.jinhaiqimeng.sysManageMicroservice.result.ResponseResult;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.validation.BindException;
+import org.springframework.validation.ObjectError;
+import org.springframework.web.bind.MethodArgumentNotValidException;
+import org.springframework.web.bind.annotation.ExceptionHandler;
+import org.springframework.web.bind.annotation.RestControllerAdvice;
+
+import javax.validation.ConstraintViolation;
+import javax.validation.ConstraintViolationException;
+import javax.validation.ValidationException;
+import java.util.concurrent.TimeoutException;
+import java.util.stream.Collectors;
+
+@RestControllerAdvice
+@Slf4j
+public class MyControllerAdvice {
+ /**
+ * 拦截Exception类的异常
+ *
+ * @param e
+ * @return
+ */
+ @ExceptionHandler(Exception.class)
+ public Object exceptionHandler(Exception e) {
+ log.error("Exception content ",e);
+ return ResponseResult.failed("系统错误,请联系管理员!");
+ }
+
+ /**
+ * 拦截TimeoutException类的异常
+ *
+ * @param e
+ * @return
+ */
+ @ExceptionHandler(TimeoutException.class)
+ public Object exceptionHandler(TimeoutException e) {
+ log.error("Exception content ",e);
+ return ResponseResult.failed("执行超时!");
+ }
+ /**
+ * 拦截 CommonException 的异常
+ *
+ * @param ex
+ * @return
+ */
+ @ExceptionHandler(CommonException.class)
+ public Object exceptionHandler(CommonException ex) {
+ return ResponseResult.failed(ex.getMsg());
+ }
+
+ @ExceptionHandler(value = {BindException.class, ValidationException.class, MethodArgumentNotValidException.class})
+ public Object handleValidatedException(Exception e) {
+ String errorMsg = StrUtil.EMPTY;
+ if (e instanceof MethodArgumentNotValidException) {
+ // BeanValidation exception
+ MethodArgumentNotValidException ex = (MethodArgumentNotValidException) e;
+ errorMsg = ex.getBindingResult().getAllErrors().stream()
+ .map(ObjectError::getDefaultMessage)
+ .collect(Collectors.joining("; "));
+ } else if (e instanceof ConstraintViolationException) {
+ // BeanValidation GET simple param
+ ConstraintViolationException ex = (ConstraintViolationException) e;
+ errorMsg = ex.getConstraintViolations().stream()
+ .map(ConstraintViolation::getMessage)
+ .collect(Collectors.joining("; "));
+ } else if (e instanceof BindException) {
+ // BeanValidation GET object param
+ BindException ex = (BindException) e;
+ errorMsg = ex.getAllErrors().stream()
+ .map(ObjectError::getDefaultMessage)
+ .collect(Collectors.joining("; "));
+ }
+ return ResponseResult.failed(errorMsg);
+ }
+}
diff --git a/src/main/java/com/jinhaiqimeng/sysManageMicroservice/result/ResponseCode.java b/src/main/java/com/jinhaiqimeng/sysManageMicroservice/result/ResponseCode.java
new file mode 100644
index 0000000..945b1f8
--- /dev/null
+++ b/src/main/java/com/jinhaiqimeng/sysManageMicroservice/result/ResponseCode.java
@@ -0,0 +1,29 @@
+package com.jinhaiqimeng.sysManageMicroservice.result;
+
+/**
+ * 响应码对象
+ *
+ * @author shengn
+ */
+public enum ResponseCode {
+
+ SUCCESS(200, "success"),
+ FAILED(1, "system internal error");
+
+ private long code;
+ private String message;
+
+ private ResponseCode(long code, String message) {
+ this.code = code;
+ this.message = message;
+ }
+
+ public long getCode() {
+ return code;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+}
diff --git a/src/main/java/com/jinhaiqimeng/sysManageMicroservice/result/ResponseResult.java b/src/main/java/com/jinhaiqimeng/sysManageMicroservice/result/ResponseResult.java
new file mode 100644
index 0000000..15a8be5
--- /dev/null
+++ b/src/main/java/com/jinhaiqimeng/sysManageMicroservice/result/ResponseResult.java
@@ -0,0 +1,98 @@
+package com.jinhaiqimeng.sysManageMicroservice.result;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import lombok.NoArgsConstructor;
+
+/**
+ * HTTP请求响应结果类
+ *
+ * @author shengn
+ */
+@NoArgsConstructor
+public class ResponseResult {
+
+ private long status;
+ private String msg;
+ private T data;
+
+ protected ResponseResult(long code, String msg, T data) {
+ this.status = code;
+ this.msg = msg;
+ this.data = data;
+ }
+
+ /**
+ * 成功返回结果
+ *
+ */
+ public static ResponseResult success() {
+ return new ResponseResult(ResponseCode.SUCCESS.getCode(), ResponseCode.SUCCESS.getMessage(), null);
+ }
+
+ /**
+ * 成功返回结果
+ *
+ * @param data 获取的数据
+ */
+ public static ResponseResult success(T data) {
+ return new ResponseResult(ResponseCode.SUCCESS.getCode(), ResponseCode.SUCCESS.getMessage(), data);
+ }
+
+ /**
+ * 成功返回结果
+ *
+ * @param data 获取的数据
+ * @param message 提示信息
+ */
+ public static ResponseResult success(T data, String message) {
+ return new ResponseResult(ResponseCode.SUCCESS.getCode(), message, data);
+ }
+
+ /**
+ * 失败返回结果
+ *
+ * @param message 提示信息
+ */
+ public static ResponseResult failed(String message) {
+ return new ResponseResult(ResponseCode.FAILED.getCode(), message, null);
+ }
+
+ public static ResponseResult failed(Long code, String message) {
+ return new ResponseResult<>(code, message, null);
+ }
+
+
+ public long getStatus() {
+ return status;
+ }
+
+ public void setStatus(long status) {
+ this.status = status;
+ }
+
+ public String getMsg() {
+ return msg;
+ }
+
+ public void setMsg(String msg) {
+ this.msg = msg;
+ }
+
+ public T getData() {
+ return data;
+ }
+
+ public void setData(T data) {
+ this.data = data;
+ }
+
+ @JsonIgnore
+ public boolean isSuccess() {
+ return ResponseCode.SUCCESS.getCode() == this.status;
+ }
+
+ @JsonIgnore
+ public boolean isFail() {
+ return !this.isSuccess();
+ }
+}
diff --git a/src/main/java/com/jinhaiqimeng/sysManageMicroservice/util/EnumSensitiveWord.java b/src/main/java/com/jinhaiqimeng/sysManageMicroservice/util/EnumSensitiveWord.java
new file mode 100644
index 0000000..6b3df69
--- /dev/null
+++ b/src/main/java/com/jinhaiqimeng/sysManageMicroservice/util/EnumSensitiveWord.java
@@ -0,0 +1,33 @@
+package com.jinhaiqimeng.sysManageMicroservice.util;
+
+import javax.validation.Constraint;
+import javax.validation.Payload;
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.*;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+/**
+ * @author cxt
+ * @date 2023-10-31 8:38
+ */
+@Target({FIELD})
+@Retention(RUNTIME)
+@Documented
+@Constraint(validatedBy = {EnumSensitiveWordValidator.class})
+public @interface EnumSensitiveWord {
+ // 默认错误消息
+ String message() default "必须为指定值";
+
+ String value() default "";
+ //1 匹配敏感词,错误信息会返回敏感词信息 2:包含敏感词
+ int type() default 2;
+
+ // 分组
+ Class>[] groups() default {};
+
+ // 负载
+ Class extends Payload>[] payload() default {};
+}
diff --git a/src/main/java/com/jinhaiqimeng/sysManageMicroservice/util/EnumSensitiveWordValidator.java b/src/main/java/com/jinhaiqimeng/sysManageMicroservice/util/EnumSensitiveWordValidator.java
new file mode 100644
index 0000000..39e9ef5
--- /dev/null
+++ b/src/main/java/com/jinhaiqimeng/sysManageMicroservice/util/EnumSensitiveWordValidator.java
@@ -0,0 +1,64 @@
+package com.jinhaiqimeng.sysManageMicroservice.util;
+
+import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.util.StrUtil;
+import com.alibaba.fastjson.JSON;
+import com.jinhaiqimeng.sysManageMicroservice.result.ResponseResult;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+
+/**
+ * @author cxt
+ * @date 2023-10-19 13:50
+ */
+@Component
+@Slf4j
+public class EnumSensitiveWordValidator implements ConstraintValidator {
+ @Autowired
+ ContentAuditingMicroservice contentAuditingMicroservice;
+
+ private int type;
+ @Override
+ public void initialize(EnumSensitiveWord constraintAnnotation) {
+ this.type = constraintAnnotation.type();
+ }
+
+ @Override
+ public boolean isValid(String value, ConstraintValidatorContext context) {
+ if (StrUtil.isBlank(value)){
+ return true;
+ }
+ PartMatchDTO partMatchDTO = new PartMatchDTO();
+ partMatchDTO.setContent(value);
+ partMatchDTO.setPartMatch(false);
+ if (1 == type){
+ ResponseResult responseResult = contentAuditingMicroservice.matchSensitiveWord(partMatchDTO);
+ if (responseResult.isFail()){
+ log.error("调用敏感词服务失败!"+responseResult.getMsg());
+ return true;
+ } else {
+ SensitiveWordsVO data1 = responseResult.getData();
+ if (CollUtil.isEmpty(data1.getSensitiveWords())){
+ return true;
+ }
+ context.disableDefaultConstraintViolation();//禁用默认的message的值
+ context.buildConstraintViolationWithTemplate("文本包含敏感词为:"+ JSON.toJSONString(data1.getSensitiveWords())).addConstraintViolation();
+ return false;
+ }
+ } else if (2 == type){
+ ResponseResult responseResult = contentAuditingMicroservice.containsSensitiveWord(partMatchDTO);
+ if (responseResult.isFail()){
+ log.error("调用敏感词服务失败!"+responseResult.getMsg());
+ return true;
+ } else {
+ boolean data1 = (boolean)responseResult.getData();
+ return !data1;
+ }
+ }
+ return false;
+ }
+}
diff --git a/src/main/java/com/jinhaiqimeng/sysManageMicroservice/util/EnumValue.java b/src/main/java/com/jinhaiqimeng/sysManageMicroservice/util/EnumValue.java
new file mode 100644
index 0000000..5d0c465
--- /dev/null
+++ b/src/main/java/com/jinhaiqimeng/sysManageMicroservice/util/EnumValue.java
@@ -0,0 +1,41 @@
+package com.jinhaiqimeng.sysManageMicroservice.util;
+
+import javax.validation.Constraint;
+import javax.validation.Payload;
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.*;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+/**
+ * 枚举校验注解
+ */
+@Target({METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER})
+@Retention(RUNTIME)
+@Documented
+@Constraint(validatedBy = {EnumValueValidator.class})
+public @interface EnumValue {
+
+ // 默认错误消息
+ String message() default "必须为指定值";
+
+ String[] strValues() default {};
+
+ int[] intValues() default {};
+
+ // 分组
+ Class>[] groups() default {};
+
+ // 负载
+ Class extends Payload>[] payload() default {};
+
+ // 指定多个时使用
+ @Target({FIELD, METHOD, PARAMETER, ANNOTATION_TYPE})
+ @Retention(RUNTIME)
+ @Documented
+ @interface List {
+ EnumValue[] value();
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/com/jinhaiqimeng/sysManageMicroservice/util/EnumValueValidator.java b/src/main/java/com/jinhaiqimeng/sysManageMicroservice/util/EnumValueValidator.java
new file mode 100644
index 0000000..2bd131b
--- /dev/null
+++ b/src/main/java/com/jinhaiqimeng/sysManageMicroservice/util/EnumValueValidator.java
@@ -0,0 +1,37 @@
+package com.jinhaiqimeng.sysManageMicroservice.util;
+
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+
+/**
+ * @author cxt
+ * @date 2023-10-19 13:50
+ */
+public class EnumValueValidator implements ConstraintValidator {
+ private String[] strValues;
+ private int[] intValues;
+
+ @Override
+ public void initialize(EnumValue constraintAnnotation) {
+ strValues = constraintAnnotation.strValues();
+ intValues = constraintAnnotation.intValues();
+ }
+
+ @Override
+ public boolean isValid(Object value, ConstraintValidatorContext context) {
+ if (value instanceof String) {
+ for (String s : strValues) {
+ if (s.equals(value)) {
+ return true;
+ }
+ }
+ } else if (value instanceof Integer) {
+ for (int s : intValues) {
+ if (s == ((Integer) value).intValue()) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+}
diff --git a/src/main/java/com/jinhaiqimeng/sysManageMicroservice/util/SpecialReplaceUtil.java b/src/main/java/com/jinhaiqimeng/sysManageMicroservice/util/SpecialReplaceUtil.java
new file mode 100644
index 0000000..9505b14
--- /dev/null
+++ b/src/main/java/com/jinhaiqimeng/sysManageMicroservice/util/SpecialReplaceUtil.java
@@ -0,0 +1,17 @@
+package com.jinhaiqimeng.sysManageMicroservice.util;
+
+import cn.hutool.core.util.StrUtil;
+
+/**
+ * @author cxt
+ * @date 2023-10-20 13:43
+ */
+public class SpecialReplaceUtil {
+
+ public static String replace(String value){
+ if (StrUtil.isNotBlank(value)){
+ value = value.replace("\\", "\\\\").replace("%", "\\%").replace("_", "\\_");
+ }
+ return value;
+ }
+}
diff --git a/src/main/java/com/jinhaiqimeng/sysManageMicroservice/web/service/impl/sysManageMicroserviceServiceImpl.java b/src/main/java/com/jinhaiqimeng/sysManageMicroservice/web/service/impl/sysManageMicroserviceServiceImpl.java
new file mode 100644
index 0000000..ad38a1b
--- /dev/null
+++ b/src/main/java/com/jinhaiqimeng/sysManageMicroservice/web/service/impl/sysManageMicroserviceServiceImpl.java
@@ -0,0 +1,31 @@
+//package com.jinhaiqimeng.sysManageMicroservice.web.service.impl;
+//
+//import cn.hutool.core.collection.CollUtil;
+//import com.google.common.collect.Lists;
+//import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.stereotype.Service;
+//
+//import java.util.List;
+//
+///**
+// * @author cxt
+// * @date 2023-10-26 12:34
+// */
+//@Service
+//public class UserServiceImpl implements UserService {
+// @Autowired
+// AllianceMemberDao allianceMemberDao;
+//
+// @Override
+// public UserDTO getUserById(Long userId) {
+// return allianceMemberDao.getUserById(userId);
+// }
+//
+// @Override
+// public List getUserByIds(List userIds) {
+// if (CollUtil.isEmpty(userIds)){
+// return Lists.newArrayList();
+// }
+// return allianceMemberDao.getUserByIds(userIds);
+// }
+//}
diff --git a/src/main/java/com/jinhaiqimeng/sysManageMicroservice/web/service/sysManageMicroserviceService.java b/src/main/java/com/jinhaiqimeng/sysManageMicroservice/web/service/sysManageMicroserviceService.java
new file mode 100644
index 0000000..5a63878
--- /dev/null
+++ b/src/main/java/com/jinhaiqimeng/sysManageMicroservice/web/service/sysManageMicroserviceService.java
@@ -0,0 +1,17 @@
+//package com.jinhaiqimeng.sysManageMicroservice.web.service;
+//
+//import com.jinhaiqimeng.sysManageMicroservice.web.dto.alliance.JoinAllianceDTO;
+//import com.baomidou.mybatisplus.extension.service.IService;
+//
+///**
+// *
+// * 联盟入会申请 服务类
+// *
+// *
+// * @author cxj
+// * @since 2023-10-20
+// */
+//public interface AllianceJoinApplyService extends IService {
+//
+// void enterprisesJoinAllianceApply(JoinAllianceDTO joinAllianceDTO);
+//}
diff --git a/src/main/resources/application-prod.yml b/src/main/resources/application-prod.yml
new file mode 100644
index 0000000..c7cf983
--- /dev/null
+++ b/src/main/resources/application-prod.yml
@@ -0,0 +1,108 @@
+# 应用服务 WEB 访问端口
+server:
+ port: 8007
+ servlet:
+ context-path: /sysManageMicroservice
+ compression:
+ enabled: true
+ min-response-size: 1024
+ mime-types:
+ - image/png
+ - image/jpeg
+ - image/jpg
+ - text/html
+ - application/javascript
+ - text/css
+ - application/octet-stream
+ - application/json
+
+spring:
+ jmx:
+ enabled: false
+ application:
+ name: sysManageMicroservice
+ http:
+ encoding:
+ charset: UTF-8
+ force: true
+ enabled: true
+ mvc:
+ pathmatch:
+ matching-strategy: ant_path_matcher
+ datasource:
+ type: com.alibaba.druid.pool.DruidDataSource
+ driver-class-name: com.mysql.cj.jdbc.Driver # mysql驱动包
+ url: jdbc:mysql://jinhaiqimengprod.internal.cn-north-4.mysql.rds.myhuaweicloud.com:13306/jinhaiqimengdb?useSSL=false&serverTimezone=Asia/Shanghai&zeroDateTimeBehavior=CONVERT_TO_NULL&allowMultiQueries=true # 数据库名称
+ username: sysManageMicroservice_user
+ password: kT7%d6$@jLsh
+ druid:
+ # 初始化大小,最小,最大
+ initial-size: 5
+ min-idle: 5
+ max-active: 20
+ # 配置获取连接等待超时的时间
+ max-wait: 60000
+ # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
+ time-between-eviction-runs-millis: 60000
+ # 配置一个连接在池中最小生存的时间,单位是毫秒
+ min-evictable-idle-time-millis: 300000
+ validation-query: SELECT 1 FROM DUAL
+ test-while-idle: true
+ test-on-borrow: false
+ test-on-return: false
+ # 打开PSCache,并且指定每个连接上PSCache的大小
+ pool-prepared-statements: true
+ max-pool-prepared-statement-per-connection-size: 20
+ # 通过connectProperties属性来打开mergeSql功能;慢SQL记录
+ connect-properties:
+ druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000
+ # 合并多个DruidDataSource的监控数据
+ use-global-data-source-stat: true
+ filters: stat,wall
+
+# redis:
+# lettuce:
+# pool:
+# max-active: 200
+# max-idle: 10
+# min-idle: -1
+# host: redis-6962c01f-a6ab-40c7-9ae1-6dcc29aeb6f3.cn-north-4.dcs.myhuaweicloud.com
+# port: 6379
+# password: juGmpEv*=p6!&*m6
+# timeout: 1000
+# database: 1
+
+ cloud:
+ sentinel:
+ transport:
+ # 控制台地址
+ dashboard: 127.0.0.1:8718
+ eager: true
+# 声明式服务
+feign:
+ # 开启okhttp客户端
+ okhttp:
+ enabled: true
+ # 请求与响应的压缩以提高通信效率
+ compression:
+ request:
+ enabled: true
+ min-request-size: 2048
+ mime-types: text/xml,application/xml,application/json
+ response:
+ enabled: true
+
+ httpclient:
+ enabled: false
+
+
+logging:
+ config: classpath:logback-spring.xml
+
+#mybatisPlus
+mybatis-plus:
+ mapper-locations: classpath:mapping/*.xml #注意:一定要对应mapper映射xml文件的所在路径
+ type-aliases-package: com.jinhaiqimeng.sysManageMicroservice.web.entity,com.jinhaiqimeng.orgMicroservice.web.dto # 注意:对应实体类的路径
+ configuration:
+ log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
+
diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml
new file mode 100644
index 0000000..9105191
--- /dev/null
+++ b/src/main/resources/application.yml
@@ -0,0 +1,110 @@
+# 应用服务 WEB 访问端口
+server:
+ port: 8007
+ servlet:
+ context-path: /sysManageMicroservice
+ encoding:
+ charset: UTF-8
+ force: true
+ enabled: true
+ compression:
+ enabled: true
+ min-response-size: 1024
+ mime-types:
+ - image/png
+ - image/jpeg
+ - image/jpg
+ - text/html
+ - application/javascript
+ - text/css
+ - application/octet-stream
+ - application/json
+
+spring:
+ jmx:
+ enabled: false
+ # 当前环境名称(注意:不可设置为 test 它是单元测试专用的名称)
+ profiles:
+ active: prod
+ application:
+ name: sysManageMicroservice
+ mvc:
+ pathmatch:
+ matching-strategy: ant_path_matcher
+ datasource:
+ type: com.alibaba.druid.pool.DruidDataSource
+ driver-class-name: com.mysql.cj.jdbc.Driver # mysql驱动包
+ url: jdbc:mysql://120.46.194.248:13306/jinhaiqimengdb?useSSL=false&serverTimezone=Asia/Shanghai&zeroDateTimeBehavior=CONVERT_TO_NULL&allowMultiQueries=true # 数据库名称
+ username: sysManageMicroservice_user
+ password: pEqzVsA$whvE
+ druid:
+ # 初始化大小,最小,最大
+ initial-size: 5
+ min-idle: 5
+ max-active: 20
+ # 配置获取连接等待超时的时间
+ max-wait: 60000
+ # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
+ time-between-eviction-runs-millis: 60000
+ # 配置一个连接在池中最小生存的时间,单位是毫秒
+ min-evictable-idle-time-millis: 300000
+ validation-query: SELECT 1 FROM DUAL
+ test-while-idle: true
+ test-on-borrow: false
+ test-on-return: false
+ # 打开PSCache,并且指定每个连接上PSCache的大小
+ pool-prepared-statements: true
+ max-pool-prepared-statement-per-connection-size: 20
+ # 通过connectProperties属性来打开mergeSql功能;慢SQL记录
+ connect-properties:
+ druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000
+ # 合并多个DruidDataSource的监控数据
+ use-global-data-source-stat: true
+ filters: stat,wall
+
+# redis:
+# lettuce:
+# pool:
+# max-active: 200
+# max-idle: 10
+# min-idle: -1
+# host: 120.46.171.171
+# port: 6379
+# password: bcd4@g2wp*PZv#&U
+# timeout: 1000
+# database: 1
+
+ cloud:
+ sentinel:
+ transport:
+ # 控制台地址
+ dashboard: 127.0.0.1:8718
+ eager: true
+# 声明式服务
+feign:
+ # 开启okhttp客户端
+ okhttp:
+ enabled: true
+ # 请求与响应的压缩以提高通信效率
+ compression:
+ request:
+ enabled: true
+ min-request-size: 2048
+ mime-types: text/xml,application/xml,application/json
+ response:
+ enabled: true
+
+ httpclient:
+ enabled: false
+
+
+logging:
+ config: classpath:logback-spring.xml
+
+#mybatisPlus
+mybatis-plus:
+ mapper-locations: classpath:mapping/*.xml #注意:一定要对应mapper映射xml文件的所在路径
+ type-aliases-package: com.jinhaiqimeng.sysManageMicroservice.web.entity,com.jinhaiqimeng.orgMicroservice.web.dto # 注意:对应实体类的路径
+ configuration:
+ log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
+
diff --git a/src/main/resources/logback-spring.xml b/src/main/resources/logback-spring.xml
new file mode 100644
index 0000000..4f10e9d
--- /dev/null
+++ b/src/main/resources/logback-spring.xml
@@ -0,0 +1,63 @@
+
+
+
+
+
+
+
+
+
+ %d{MM-dd HH:mm:ss.SSS} %-5level [%logger{50}] - %msg%n
+
+
+
+
+
+ ${log.path}/debug.log
+
+ ${log.path}/debug.%d{yyyy-MM-dd}.%i.log.zip
+ 50MB
+ 30
+
+
+ %date [%thread] %-5level [%logger{50}] %file:%line - %msg%n
+
+
+
+
+
+
+ ${log.path}/error.log
+
+ ${log.path}/error.%d{yyyy-MM-dd}.%i.log.zip
+ 50MB
+ 30
+
+
+ %date [%thread] %-5level [%logger{50}] %file:%line - %msg%n
+
+
+ ERROR
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file