From c5175df9b49ae0a8b126f8e91fb4a39ce7d4915f Mon Sep 17 00:00:00 2001
From: wuqiping <wuqiping@qq.com>
Date: Wed, 03 Mar 2021 10:13:46 +0800
Subject: [PATCH] 初始化
---
screen-api/src/main/java/com/moral/api/config/kafka/KafkaProducerConfig.java | 55
screen-common/src/main/java/com/moral/redis/RedisUtil.java | 380 +++++
screen-api/src/main/java/com/moral/api/exception/BusinessException.java | 72 +
screen-api/src/main/java/com/moral/api/service/impl/TestServiceImpl.java | 53
screen-api/src/main/java/com/moral/api/mapper/TestMapper.java | 16
screen-api/pom.xml | 69
myBatisPlusGenerator/pom.xml | 66
screen-api/src/main/resources/application-dev.yml | 101 +
screen-manage/src/main/java/com/moral/api/entity/Test.java | 51
screen-api/src/main/java/com/moral/api/constant/TopicConstants.java | 11
screen-manage/src/main/java/com/moral/api/config/redis/RedisConfig.java | 42
screen-api/src/main/java/com/moral/api/entity/Test.java | 51
screen-manage/src/main/java/com/moral/api/service/TestService.java | 24
screen-common/src/main/java/com/moral/util/DateUtils.java | 1267 ++++++++++++++++++
screen-manage/src/main/java/com/moral/ScreenManageBootstrap.java | 42
screen-api/src/main/resources/logback-spring.xml | 56
screen-api/src/main/java/com/moral/api/Swagger2.java | 34
screen-manage/src/main/resources/logback-spring.xml | 56
screen-api/src/main/java/com/moral/api/config/datasource/DataSourceConfig.java | 23
screen-api/src/main/java/com/moral/api/kafka/consumer/KafkaConsumer.java | 37
screen-common/pom.xml | 75 +
screen-manage/src/main/resources/application-dev.yml | 101 +
screen-api/src/main/java/com/moral/api/config/kafka/KafkaConsumerConfig.java | 67
screen-api/src/main/java/com/moral/api/config/redis/RedisConfig.java | 42
screen-manage/src/main/java/com/moral/api/config/mybatis/MybatisPlusConfig.java | 22
screen-manage/src/main/java/com/moral/api/constant/TopicConstants.java | 11
myBatisPlusGenerator/src/main/java/com/moral/CodeGenerator.java | 134 +
screen-manage/src/main/java/com/moral/api/exception/BusinessException.java | 72 +
.gitignore | 8
screen-api/src/main/java/com/moral/api/exception/GlobalExceptionHandler.java | 37
screen-manage/src/main/java/com/moral/api/service/impl/TestServiceImpl.java | 52
screen-api/src/main/java/com/moral/ScreenApiBootstrap.java | 40
pom.xml | 108 +
moral.iml | 2
screen-manage/src/main/java/com/moral/api/kafka/consumer/KafkaConsumer.java | 37
screen-manage/src/main/java/com/moral/api/config/kafka/KafkaProducerConfig.java | 55
myBatisPlusGenerator/src/main/resources/templates/mapper.xml.ftl | 39
screen-manage/src/main/java/com/moral/api/config/datasource/DataSourceConfig.java | 23
screen-common/src/main/java/com/moral/constant/Constants.java | 29
screen-common/src/main/java/com/moral/util/SpringContextUtils.java | 65
screen-common/src/main/java/com/moral/constant/ResultMessage.java | 130 +
screen-manage/pom.xml | 72 +
screen-api/src/main/java/com/moral/api/controller/TestController.java | 99 +
screen-api/src/main/java/com/moral/api/config/mybatis/MybatisPlusConfig.java | 22
screen-manage/src/main/java/com/moral/api/config/kafka/KafkaConsumerConfig.java | 67
screen-common/src/main/java/com/moral/util/PageResult.java | 34
screen-manage/src/main/java/com/moral/api/controller/TestController.java | 99 +
screen-manage/src/main/java/com/moral/api/exception/GlobalExceptionHandler.java | 35
screen-api/src/main/java/com/moral/api/service/TestService.java | 25
screen-manage/src/main/java/com/moral/api/Swagger2.java | 34
screen-manage/src/main/java/com/moral/api/mapper/TestMapper.java | 16
51 files changed, 4,158 insertions(+), 0 deletions(-)
diff --git a/.gitignore b/.gitignore
index f112f7f..9a8a286 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,3 +9,11 @@
# Project files, i.e. `.project`, `.actionScriptProperties` and `.flexProperties`
# should NOT be excluded as they contain compiler settings and other important
# information for Eclipse / Flash Builder.
+/.idea/
+/screen-api/target/
+/screen-common/target/
+/screen-manage/target/
+/.idea/
+myBatisPlusGenerator/src/test/
+screen-common/src/main/resources/
+screen-manage/src/test/
diff --git a/moral.iml b/moral.iml
new file mode 100644
index 0000000..78b2cc5
--- /dev/null
+++ b/moral.iml
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module type="JAVA_MODULE" version="4" />
\ No newline at end of file
diff --git a/myBatisPlusGenerator/pom.xml b/myBatisPlusGenerator/pom.xml
new file mode 100644
index 0000000..83d93d9
--- /dev/null
+++ b/myBatisPlusGenerator/pom.xml
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <parent>
+ <artifactId>screen</artifactId>
+ <groupId>org.moral</groupId>
+ <version>1.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>myBatisPlusGenerator</artifactId>
+
+
+ <dependencies>
+
+ <!--lombok������-->
+ <dependency>
+ <groupId>org.projectlombok</groupId>
+ <artifactId>lombok</artifactId>
+ <optional>true</optional>
+ </dependency>
+
+ <!--mybatis-plus-->
+ <dependency>
+ <groupId>com.baomidou</groupId>
+ <artifactId>mybatis-plus-boot-starter</artifactId>
+ <version>3.3.2</version>
+ </dependency>
+
+ <!--���������������-->
+ <dependency>
+ <groupId>com.baomidou</groupId>
+ <artifactId>mybatis-plus-generator</artifactId>
+ <version>3.3.2</version>
+ </dependency>
+
+ <!-- velocity ������������, ������ -->
+ <dependency>
+ <groupId>org.apache.velocity</groupId>
+ <artifactId>velocity-engine-core</artifactId>
+ <version>2.0</version>
+ </dependency>
+
+ <!-- freemarker ������������ -->
+ <dependency>
+ <groupId>org.freemarker</groupId>
+ <artifactId>freemarker</artifactId>
+ <version>2.3.23</version>
+ </dependency>
+
+ <!--mysql������-->
+ <dependency>
+ <groupId>mysql</groupId>
+ <artifactId>mysql-connector-java</artifactId>
+ <scope>runtime</scope>
+ </dependency>
+
+ <!--���������-->
+ <dependency>
+ <groupId>com.alibaba</groupId>
+ <artifactId>druid</artifactId>
+ <version>1.1.5</version>
+ </dependency>
+ </dependencies>
+</project>
\ No newline at end of file
diff --git a/myBatisPlusGenerator/src/main/java/com/moral/CodeGenerator.java b/myBatisPlusGenerator/src/main/java/com/moral/CodeGenerator.java
new file mode 100644
index 0000000..305c72e
--- /dev/null
+++ b/myBatisPlusGenerator/src/main/java/com/moral/CodeGenerator.java
@@ -0,0 +1,134 @@
+package com.moral;
+
+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;
+
+
+public class CodeGenerator {
+
+ /**
+ * <p>
+ * ���������������������
+ * </p>
+ */
+ 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();
+ //String projectPath = System.getProperty("user.dir");
+ String projectPath="E:\\workspace\\moral\\screen-api";
+ gc.setOutputDir(projectPath + "/src/main/java");
+ gc.setAuthor("moral");
+ gc.setOpen(false);
+ // service ������������
+ gc.setServiceName("%sService");
+ // service impl ������������
+ gc.setServiceImplName("%sServiceImpl");
+ // ������������������������������ %s ���������������������������������
+ gc.setMapperName("%sMapper");
+ gc.setXmlName("%sMapper");
+ gc.setFileOverride(true);
+ gc.setActiveRecord(true);
+ // XML ������������
+ gc.setEnableCache(false);
+ // XML ResultMap
+ gc.setBaseResultMap(true);
+ // XML columList
+ gc.setBaseColumnList(false);
+ // gc.setSwagger2(true); ������������ Swagger2 ������
+ mpg.setGlobalConfig(gc);
+
+ // ���������������
+ DataSourceConfig dsc = new DataSourceConfig();
+ dsc.setUrl("jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=UTC");
+ dsc.setDriverName("com.mysql.cj.jdbc.Driver");
+ dsc.setUsername("root");
+ dsc.setPassword("123456");
+ mpg.setDataSource(dsc);
+
+ // ���������
+ PackageConfig pc = new PackageConfig();
+ pc.setParent("com.moral.api");
+ pc.setEntity("entity");
+ pc.setService("service");
+ pc.setServiceImpl("service.impl");
+ pc.setController("controller");
+ mpg.setPackageInfo(pc);
+
+ // ���������������
+ InjectionConfig cfg = new InjectionConfig() {
+ @Override
+ public void initMap() {
+ // to do nothing
+ }
+ };
+
+ // ��������������������� freemarker
+ String templatePath = "/templates/mapper.xml.ftl";
+ // ��������������������� velocity
+ // String templatePath = "/templates/mapper.xml.vm";
+
+ // ���������������������
+ List<FileOutConfig> focList = new ArrayList<>();
+ // ���������������������������������
+ focList.add(new FileOutConfig(templatePath) {
+ @Override
+ public String outputFile(TableInfo tableInfo) {
+ // ������������������������ ��� ��������� Entity ��������������������������������� xml ������������������������������������
+ String moduleName = pc.getModuleName() == null ? "" : pc.getModuleName();
+ return projectPath + "/src/main/resources/mapper/" + moduleName
+ + "/" + tableInfo.getEntityName() + "Mapper" + StringPool.DOT + "xml";
+ }
+ });
+ cfg.setFileOutConfigList(focList);
+ mpg.setCfg(cfg);
+
+ // ������������
+ TemplateConfig templateConfig = new TemplateConfig();
+
+ templateConfig.setController("");
+ templateConfig.setXml(null);
+ mpg.setTemplate(templateConfig);
+
+ // ������������
+ StrategyConfig strategy = new StrategyConfig();
+ strategy.setNaming(NamingStrategy.underline_to_camel);
+ strategy.setColumnNaming(NamingStrategy.underline_to_camel);
+ strategy.setEntityLombokModel(true);
+ strategy.setRestControllerStyle(true);
+ //strategy.setInclude(scanner("���������������������������������").split(","));
+ strategy.setControllerMappingHyphenStyle(true);
+ // strategy.setTablePrefix(pc.getModuleName() + "_");
+ mpg.setStrategy(strategy);
+ mpg.setTemplateEngine(new FreemarkerTemplateEngine());
+ mpg.execute();
+ }
+
+}
diff --git a/myBatisPlusGenerator/src/main/resources/templates/mapper.xml.ftl b/myBatisPlusGenerator/src/main/resources/templates/mapper.xml.ftl
new file mode 100644
index 0000000..9dc8071
--- /dev/null
+++ b/myBatisPlusGenerator/src/main/resources/templates/mapper.xml.ftl
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="${package.Mapper}.${table.mapperName}">
+
+ <#if enableCache>
+ <!-- ������������������ -->
+ <cache type="${cacheClassName}"/>
+
+ </#if>
+ <#if baseResultMap>
+ <!-- ������������������������ -->
+ <resultMap id="BaseResultMap" type="${package.Entity}.${entity}">
+ <#list table.fields as field>
+ <#if field.keyFlag><#--���������������������������-->
+ <id column="${field.name}" property="${field.propertyName}" />
+ </#if>
+ </#list>
+ <#list table.commonFields as field><#--������������������ -->
+ <result column="${field.name}" property="${field.propertyName}" />
+ </#list>
+ <#list table.fields as field>
+ <#if !field.keyFlag><#--������������������ -->
+ <result column="${field.name}" property="${field.propertyName}" />
+ </#if>
+ </#list>
+ </resultMap>
+
+ </#if>
+ <#if baseColumnList>
+ <!-- ��������������������� -->
+ <sql id="Base_Column_List">
+ <#list table.commonFields as field>
+ ${field.columnName},
+ </#list>
+ ${table.fieldNames}
+ </sql>
+
+ </#if>
+</mapper>
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..5128e22
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,108 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.moral</groupId>
+ <artifactId>screen</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <modules>
+ <module>screen-common</module>
+ <module>screen-api</module>
+ <module>myBatisPlusGenerator</module>
+ <module>screen-manage</module>
+
+ </modules>
+ <packaging>pom</packaging>
+
+ <parent>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-parent</artifactId>
+ <version>2.1.13.RELEASE</version>
+ </parent>
+
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+ <java.version>1.8</java.version>
+ <com.alibaba.version>1.2.46</com.alibaba.version>
+ <maven-filtering.version>1.1</maven-filtering.version>
+ <maven-common-artifact-filters.version>1.4</maven-common-artifact-filters.version>
+ <maven-resources-plugin.version>2.6</maven-resources-plugin.version>
+ <maven-filtering.version>1.1</maven-filtering.version>
+ <maven-common-artifact-filters.version>1.4</maven-common-artifact-filters.version>
+ <maven-dependency-tree.version>2.1</maven-dependency-tree.version>
+ <maven-shared-incremental.version>1.1</maven-shared-incremental.version>
+ <spring-web.version>4.1.6.RELEASE</spring-web.version>
+ <com.alibaba.druid.version>1.1.5</com.alibaba.druid.version>
+ <org.mybatis-plus.spring.boot.version>3.3.2</org.mybatis-plus.spring.boot.version>
+ <org.projectlombok.version>1.16.18</org.projectlombok.version>
+ <io.springfox.version>2.7.0</io.springfox.version>
+ <swagger-bootstrap-ui.version>1.9.6</swagger-bootstrap-ui.version>
+ <spring.kafka.version>2.2.2</spring.kafka.version>
+ </properties>
+
+
+ <dependencies>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-web</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>io.springfox</groupId>
+ <artifactId>springfox-swagger2</artifactId>
+ <version>${io.springfox.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>io.springfox</groupId>
+ <artifactId>springfox-swagger-ui</artifactId>
+ <version>${io.springfox.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>com.github.xiaoymin</groupId>
+ <artifactId>swagger-bootstrap-ui</artifactId>
+ <version>${swagger-bootstrap-ui.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.projectlombok</groupId>
+ <artifactId>lombok</artifactId>
+ <version>${org.projectlombok.version}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>com.baomidou</groupId>
+ <artifactId>mybatis-plus-boot-starter</artifactId>
+ <version>${org.mybatis-plus.spring.boot.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.kafka</groupId>
+ <artifactId>spring-kafka</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.kafka</groupId>
+ <artifactId>kafka-streams</artifactId>
+ <version>${spring.kafka.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.kafka</groupId>
+ <artifactId>kafka-clients</artifactId>
+ <version>${spring.kafka.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>com.alibaba</groupId>
+ <artifactId>druid</artifactId>
+ <version>${com.alibaba.druid.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>mysql</groupId>
+ <artifactId>mysql-connector-java</artifactId>
+ <scope>runtime</scope>
+ </dependency>
+ </dependencies>
+
+
+</project>
\ No newline at end of file
diff --git a/screen-api/pom.xml b/screen-api/pom.xml
new file mode 100644
index 0000000..51edb55
--- /dev/null
+++ b/screen-api/pom.xml
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <parent>
+ <artifactId>screen</artifactId>
+ <groupId>org.moral</groupId>
+ <version>1.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>screen-api</artifactId>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.moral</groupId>
+ <artifactId>screen-common</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <finalName>screen-api</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-maven-plugin</artifactId>
+
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>${java.version}</source>
+ <target>${java.version}</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-resources-plugin</artifactId>
+ <version>${maven-resources-plugin.version}</version>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven.shared</groupId>
+ <artifactId>maven-filtering</artifactId>
+ <version>${maven-filtering.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.shared</groupId>
+ <artifactId>maven-common-artifact-filters</artifactId>
+ <version>${maven-common-artifact-filters.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.shared</groupId>
+ <artifactId>maven-dependency-tree</artifactId>
+ <version>${maven-dependency-tree.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.shared</groupId>
+ <artifactId>maven-shared-incremental</artifactId>
+ <version>${maven-shared-incremental.version}</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+
+ </plugins>
+ </build>
+
+
+</project>
\ No newline at end of file
diff --git a/screen-api/src/main/java/com/moral/ScreenApiBootstrap.java b/screen-api/src/main/java/com/moral/ScreenApiBootstrap.java
new file mode 100644
index 0000000..26351cd
--- /dev/null
+++ b/screen-api/src/main/java/com/moral/ScreenApiBootstrap.java
@@ -0,0 +1,40 @@
+package com.moral;
+
+import com.moral.util.SpringContextUtils;
+import org.mybatis.spring.annotation.MapperScan;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.web.servlet.FilterRegistrationBean;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.annotation.Bean;
+import org.springframework.transaction.annotation.EnableTransactionManagement;
+import org.springframework.web.cors.CorsConfiguration;
+import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
+import org.springframework.web.filter.CorsFilter;
+import java.util.Arrays;
+
+
+@MapperScan("com.moral.api.mapper")
+@SpringBootApplication
+@EnableTransactionManagement
+public class ScreenApiBootstrap {
+ public static void main(String[] args) {
+ ApplicationContext applicationContext = SpringApplication.run(ScreenApiBootstrap.class, args);
+ SpringContextUtils.setApplicationContext(applicationContext);
+ }
+ @Bean
+ public FilterRegistrationBean<CorsFilter> corsFilter() {
+ FilterRegistrationBean<CorsFilter> corsFilterFilterRegistrationBean = new FilterRegistrationBean<>();
+ UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
+ CorsConfiguration corsConfiguration = new CorsConfiguration();
+ corsConfiguration.addAllowedHeader("*");
+ corsConfiguration.addAllowedOrigin("*");
+ corsConfiguration.setAllowedMethods(Arrays.asList("POST", "PUT", "GET", "OPTIONS", "DELETE"));
+ corsConfiguration.setAllowCredentials(true);
+ corsConfiguration.setMaxAge(3600L);
+ source.registerCorsConfiguration("/**", corsConfiguration);
+ corsFilterFilterRegistrationBean.setFilter(new CorsFilter(source));
+ corsFilterFilterRegistrationBean.setOrder(-1);
+ return corsFilterFilterRegistrationBean;
+ }
+}
diff --git a/screen-api/src/main/java/com/moral/api/Swagger2.java b/screen-api/src/main/java/com/moral/api/Swagger2.java
new file mode 100644
index 0000000..d555f16
--- /dev/null
+++ b/screen-api/src/main/java/com/moral/api/Swagger2.java
@@ -0,0 +1,34 @@
+package com.moral.api;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import springfox.documentation.builders.ApiInfoBuilder;
+import springfox.documentation.builders.PathSelectors;
+import springfox.documentation.builders.RequestHandlerSelectors;
+import springfox.documentation.service.ApiInfo;
+import springfox.documentation.spi.DocumentationType;
+import springfox.documentation.spring.web.plugins.Docket;
+import springfox.documentation.swagger2.annotations.EnableSwagger2;
+
+
+@Configuration
+@EnableSwagger2
+public class Swagger2 {
+ @Bean
+ public Docket petApi() {
+ return new Docket(DocumentationType.SWAGGER_2)
+ .apiInfo(apiInfo())
+ .select()
+ .apis(RequestHandlerSelectors.basePackage("com.moral.api"))
+ .paths(PathSelectors.any())
+ .build();
+ }
+ private ApiInfo apiInfo() {
+ return new ApiInfoBuilder()
+ .title("������������������")
+ .description("������������������")
+ .version("1.0")
+ .build();
+ }
+
+}
diff --git a/screen-api/src/main/java/com/moral/api/config/datasource/DataSourceConfig.java b/screen-api/src/main/java/com/moral/api/config/datasource/DataSourceConfig.java
new file mode 100644
index 0000000..9a85aa8
--- /dev/null
+++ b/screen-api/src/main/java/com/moral/api/config/datasource/DataSourceConfig.java
@@ -0,0 +1,23 @@
+package com.moral.api.config.datasource;
+
+import com.alibaba.druid.pool.DruidDataSource;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Primary;
+
+import javax.sql.DataSource;
+
+
+@Configuration
+public class DataSourceConfig {
+
+ @Primary
+ @Bean(name = "primaryDataSource")
+ @Qualifier("primaryDataSource")
+ @ConfigurationProperties(prefix = "spring.datasource")
+ public DataSource primaryDataSource(){
+ return new DruidDataSource();
+ }
+}
diff --git a/screen-api/src/main/java/com/moral/api/config/kafka/KafkaConsumerConfig.java b/screen-api/src/main/java/com/moral/api/config/kafka/KafkaConsumerConfig.java
new file mode 100644
index 0000000..e5ae67b
--- /dev/null
+++ b/screen-api/src/main/java/com/moral/api/config/kafka/KafkaConsumerConfig.java
@@ -0,0 +1,67 @@
+package com.moral.api.config.kafka;
+
+import org.apache.kafka.clients.consumer.ConsumerConfig;
+import org.apache.kafka.common.serialization.StringDeserializer;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.kafka.annotation.EnableKafka;
+import org.springframework.kafka.config.ConcurrentKafkaListenerContainerFactory;
+import org.springframework.kafka.config.KafkaListenerContainerFactory;
+import org.springframework.kafka.core.ConsumerFactory;
+import org.springframework.kafka.core.DefaultKafkaConsumerFactory;
+import org.springframework.kafka.listener.ConcurrentMessageListenerContainer;
+import org.springframework.kafka.listener.ContainerProperties;
+import java.util.HashMap;
+import java.util.Map;
+
+/*@Configuration
+@EnableKafka*/
+public class KafkaConsumerConfig {
+ @Value("${kafka.consumer.servers}")
+ private String servers;
+ @Value("${kafka.consumer.enable.auto.commit}")
+ private boolean enableAutoCommit;
+ @Value("${kafka.consumer.session.timeout}")
+ private String sessionTimeout;
+ @Value("${kafka.consumer.auto.commit.interval}")
+ private String autoCommitInterval;
+ @Value("${kafka.consumer.group.id}")
+ private String groupId;
+ @Value("${kafka.consumer.auto.offset.reset}")
+ private String autoOffsetReset;
+ @Value("${kafka.consumer.concurrency}")
+ private int concurrency;
+
+ @Bean
+ public KafkaListenerContainerFactory<ConcurrentMessageListenerContainer<String, String>> kafkaListenerContainerFactory() {
+ ConcurrentKafkaListenerContainerFactory<String, String> factory = new ConcurrentKafkaListenerContainerFactory<>();
+ factory.setConsumerFactory(consumerFactory());
+ factory.setConcurrency(concurrency);
+ factory.getContainerProperties().setPollTimeout(1500);
+ factory.getContainerProperties().setAckMode(ContainerProperties.AckMode.MANUAL_IMMEDIATE);
+
+ /*factory.setBatchListener(true);//@KafkaListener ������������ ���������������������Kafka���������������������ConsumerConfig.MAX_POLL_RECORDS_CONFIG
+ factory.getContainerProperties().setAckMode(ContainerProperties.AckMode.MANUAL_IMMEDIATE);//������������������������������*/
+ return factory;
+ }
+
+ public ConsumerFactory<String, String> consumerFactory() {
+ return new DefaultKafkaConsumerFactory<>(consumerConfigs());
+ }
+
+
+ public Map<String, Object> consumerConfigs() {
+ Map<String, Object> propsMap = new HashMap<>();
+ propsMap.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, servers);
+ propsMap.put(ConsumerConfig.ENABLE_AUTO_COMMIT_CONFIG, enableAutoCommit);
+ propsMap.put(ConsumerConfig.AUTO_COMMIT_INTERVAL_MS_CONFIG, autoCommitInterval);
+ propsMap.put(ConsumerConfig.SESSION_TIMEOUT_MS_CONFIG, sessionTimeout);
+ propsMap.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class);
+ propsMap.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class);
+ propsMap.put(ConsumerConfig.GROUP_ID_CONFIG, groupId);
+ propsMap.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, autoOffsetReset);
+ return propsMap;
+ }
+}
diff --git a/screen-api/src/main/java/com/moral/api/config/kafka/KafkaProducerConfig.java b/screen-api/src/main/java/com/moral/api/config/kafka/KafkaProducerConfig.java
new file mode 100644
index 0000000..ef5b141
--- /dev/null
+++ b/screen-api/src/main/java/com/moral/api/config/kafka/KafkaProducerConfig.java
@@ -0,0 +1,55 @@
+package com.moral.api.config.kafka;
+
+import org.apache.kafka.clients.producer.ProducerConfig;
+import org.apache.kafka.common.serialization.StringSerializer;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.kafka.annotation.EnableKafka;
+import org.springframework.kafka.core.DefaultKafkaProducerFactory;
+import org.springframework.kafka.core.KafkaTemplate;
+import org.springframework.kafka.core.ProducerFactory;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/*@Configuration
+@EnableKafka*/
+public class KafkaProducerConfig {
+ @Value("${kafka.producer.servers}")
+ private String servers;
+ @Value("${kafka.producer.retries}")
+ private int retries;
+ @Value("${kafka.producer.batch.size}")
+ private int batchSize;
+ @Value("${kafka.producer.linger}")
+ private int linger;
+ @Value("${kafka.producer.buffer.memory}")
+ private int bufferMemory;
+
+
+ public Map<String, Object> producerConfigs() {
+ Map<String, Object> props = new HashMap<>();
+ props.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, servers);
+ props.put(ProducerConfig.RETRIES_CONFIG, retries);
+ props.put(ProducerConfig.BATCH_SIZE_CONFIG, batchSize);
+ props.put(ProducerConfig.LINGER_MS_CONFIG, linger);
+ props.put(ProducerConfig.BUFFER_MEMORY_CONFIG, bufferMemory);
+ props.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class);
+ props.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, StringSerializer.class);
+ return props;
+ }
+
+ public ProducerFactory<String, String> producerFactory() {
+ return new DefaultKafkaProducerFactory<>(producerConfigs());
+ }
+
+ @Bean
+ public KafkaTemplate<String, String> kafkaTemplate() {
+ return new KafkaTemplate<String, String>(producerFactory());
+ }
+
+}
+
+
+
diff --git a/screen-api/src/main/java/com/moral/api/config/mybatis/MybatisPlusConfig.java b/screen-api/src/main/java/com/moral/api/config/mybatis/MybatisPlusConfig.java
new file mode 100644
index 0000000..4a253f7
--- /dev/null
+++ b/screen-api/src/main/java/com/moral/api/config/mybatis/MybatisPlusConfig.java
@@ -0,0 +1,22 @@
+package com.moral.api.config.mybatis;
+
+import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+
+
+@Configuration
+public class MybatisPlusConfig {
+
+ /**
+ * ������������
+ */
+ @Bean
+ public PaginationInterceptor paginationInterceptor() {
+ PaginationInterceptor page = new PaginationInterceptor();
+ return page;
+ }
+
+
+}
diff --git a/screen-api/src/main/java/com/moral/api/config/redis/RedisConfig.java b/screen-api/src/main/java/com/moral/api/config/redis/RedisConfig.java
new file mode 100644
index 0000000..b63690d
--- /dev/null
+++ b/screen-api/src/main/java/com/moral/api/config/redis/RedisConfig.java
@@ -0,0 +1,42 @@
+package com.moral.api.config.redis;
+
+import com.fasterxml.jackson.annotation.JsonAutoDetect;
+import com.fasterxml.jackson.annotation.PropertyAccessor;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.data.redis.connection.RedisConnectionFactory;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.data.redis.core.StringRedisTemplate;
+import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
+import org.springframework.data.redis.serializer.StringRedisSerializer;
+
+
+@Configuration
+public class RedisConfig {
+
+ @Bean(name="redisTemplate")
+ @ConditionalOnMissingBean(StringRedisTemplate.class) //������������������ ���������������������RedisTemplate ������������ ������������������
+ public RedisTemplate<String,Object> stringRedisTemplate(RedisConnectionFactory redisConnectionFactory) {
+ RedisTemplate<String, Object> redisTemplate = new RedisTemplate<String, Object>();
+ redisTemplate.setConnectionFactory(redisConnectionFactory);
+ Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class);
+ ObjectMapper objectMapper = new ObjectMapper();
+ objectMapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
+ objectMapper.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
+ jackson2JsonRedisSerializer.setObjectMapper(objectMapper);
+ StringRedisSerializer stringRedisSerializer = new StringRedisSerializer();
+ // key������String������������������
+ redisTemplate.setKeySerializer(stringRedisSerializer);
+ // hash���key���������String������������������
+ redisTemplate.setHashKeySerializer(stringRedisSerializer);
+ // valuevalue������jackson���������������
+ redisTemplate.setValueSerializer(jackson2JsonRedisSerializer);
+ // hash���value������jackson���������������
+ redisTemplate.setHashValueSerializer(jackson2JsonRedisSerializer);
+ redisTemplate.afterPropertiesSet();
+ redisTemplate.afterPropertiesSet();
+ return redisTemplate;
+ }
+}
diff --git a/screen-api/src/main/java/com/moral/api/constant/TopicConstants.java b/screen-api/src/main/java/com/moral/api/constant/TopicConstants.java
new file mode 100644
index 0000000..770d60e
--- /dev/null
+++ b/screen-api/src/main/java/com/moral/api/constant/TopicConstants.java
@@ -0,0 +1,11 @@
+package com.moral.api.constant;
+
+public class TopicConstants {
+ /**
+ * Test ������
+ */
+ public static final String TEST_TOPIC_MESSAGE = "test_topic";
+
+
+
+}
diff --git a/screen-api/src/main/java/com/moral/api/controller/TestController.java b/screen-api/src/main/java/com/moral/api/controller/TestController.java
new file mode 100644
index 0000000..fd85e5e
--- /dev/null
+++ b/screen-api/src/main/java/com/moral/api/controller/TestController.java
@@ -0,0 +1,99 @@
+package com.moral.api.controller;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.moral.api.entity.Test;
+import com.moral.api.service.TestService;
+import com.moral.constant.ResultMessage;
+import com.moral.redis.RedisUtil;
+import com.moral.util.PageResult;
+import io.swagger.annotations.*;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.kafka.core.KafkaTemplate;
+import org.springframework.web.bind.annotation.*;
+
+
+@Slf4j
+@Api(tags = {"������"})
+@RestController
+@RequestMapping("/api")
+public class TestController {
+
+ @Autowired
+ private KafkaTemplate kafkaTemplate;
+
+ @Autowired
+ private TestService testService;
+ /**
+ * name ������
+ * email ������
+ * mobile ���������
+ */
+ @ApiOperation(value = "������������", notes = "������������")
+ @RequestMapping(value = "/saveTest", method = RequestMethod.POST)
+ public ResultMessage save() {
+
+ Test test=new Test();
+ test.setEmail("test@qq.com");
+ test.setName("name");
+ test.setMobile("13965898745");
+ testService.save(test);
+ return ResultMessage.ok();
+
+ }
+ /**
+ * page ���������
+ * size ������������
+ */
+ @ApiOperation(value = "������", notes = "������")
+ @ApiImplicitParams({
+ @ApiImplicitParam(name="page",value="������������",required=true,paramType="path",dataType="Int"),
+ @ApiImplicitParam(name="size",value="������������",required=true,paramType="path",dataType="Int")
+ })
+ @RequestMapping(value = "search/{page}/{size}", method = RequestMethod.GET)
+ public ResultMessage findBypage(@PathVariable("page") Integer page, @PathVariable("size") Integer size) {
+
+ log.info("page is:"+ page+" size is:"+size);
+ //������������������������
+ Page<Test> userPage = testService.selectByPage(null, page, size);
+ //������������������������
+ PageResult<Test> pageResult = new PageResult<>(
+ userPage.getTotal(), userPage.getPages(),userPage.getRecords()
+ );
+ //������������
+ return ResultMessage.ok(pageResult);
+ }
+
+
+ /**
+ * redis������
+ */
+ @ApiOperation(value = "redis������", notes = "redis������")
+ @RequestMapping(value = "redis", method = RequestMethod.GET)
+ public ResultMessage testRedis() {
+ RedisUtil.set("redistest","test");
+ return ResultMessage.ok(RedisUtil.get("redistest"));
+
+ }
+
+ /**
+ * ������
+ */
+ @ApiOperation(value = "������������", notes = "������������")
+ @RequestMapping(value = "saveTest", method = RequestMethod.GET)
+ public ResultMessage saveTest() throws Exception{
+ testService.saveTest();
+ return ResultMessage.ok();
+
+ }
+
+ /**
+ * kafka������
+ */
+ @ApiOperation(value = "kafka������", notes = "kafka������")
+ @RequestMapping(value = "kafkaTest", method = RequestMethod.GET)
+ public void kafkaTest() {
+ kafkaTemplate.send("test_topic","test111111111111111");
+ }
+
+}
diff --git a/screen-api/src/main/java/com/moral/api/entity/Test.java b/screen-api/src/main/java/com/moral/api/entity/Test.java
new file mode 100644
index 0000000..05ff045
--- /dev/null
+++ b/screen-api/src/main/java/com/moral/api/entity/Test.java
@@ -0,0 +1,51 @@
+package com.moral.api.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.extension.activerecord.Model;
+import com.baomidou.mybatisplus.annotation.TableId;
+import java.io.Serializable;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * <p>
+ *
+ * </p>
+ *
+ * @author moral
+ * @since 2021-03-01
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+public class Test extends Model<Test> {
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * ������
+ */
+ @TableId(value = "id", type = IdType.AUTO)
+ private Integer id;
+
+ /**
+ * ������
+ */
+ private String name;
+
+ /**
+ * ������
+ */
+ private String email;
+
+ /**
+ * ���������
+ */
+ private String mobile;
+
+
+ @Override
+ protected Serializable pkVal() {
+ return this.id;
+ }
+
+}
diff --git a/screen-api/src/main/java/com/moral/api/exception/BusinessException.java b/screen-api/src/main/java/com/moral/api/exception/BusinessException.java
new file mode 100644
index 0000000..1b289fc
--- /dev/null
+++ b/screen-api/src/main/java/com/moral/api/exception/BusinessException.java
@@ -0,0 +1,72 @@
+package com.moral.api.exception;
+
+/**
+ * @author
+ * @site
+ * @company
+ * @create 2021-02-26 11:20
+ */
+public class BusinessException extends RuntimeException {
+
+ /**
+ * ���������
+ */
+ private String code;
+
+ /**
+ * ������������
+ */
+ private String msg;
+
+ /** */
+ private static final long serialVersionUID = 1L;
+
+ public BusinessException() {
+ super();
+ }
+
+ public BusinessException(String msg) {
+ super(msg);
+ this.msg = msg;
+ }
+
+ public BusinessException(Throwable t) {
+ super(t);
+ }
+
+ public BusinessException(String msg, Throwable t) {
+ super(msg);
+ this.msg = msg;
+ }
+
+ public BusinessException(String code, String msg) {
+ super(msg);
+ this.code = code;
+ this.msg = msg;
+ }
+
+ public BusinessException(String code, String msg, Throwable t) {
+ super(msg, t);
+ this.code = code;
+ this.msg = msg;
+ }
+
+ /**
+ * Getter method for property <tt>code</tt>.
+ *
+ * @return property value of code
+ */
+ public String getCode() {
+ return code;
+ }
+
+ /**
+ * Getter method for property <tt>msg</tt>.
+ *
+ * @return property value of msg
+ */
+ public String getMsg() {
+ return msg;
+ }
+
+}
diff --git a/screen-api/src/main/java/com/moral/api/exception/GlobalExceptionHandler.java b/screen-api/src/main/java/com/moral/api/exception/GlobalExceptionHandler.java
new file mode 100644
index 0000000..b712ee8
--- /dev/null
+++ b/screen-api/src/main/java/com/moral/api/exception/GlobalExceptionHandler.java
@@ -0,0 +1,37 @@
+package com.moral.api.exception;
+
+import com.moral.constant.Constants;
+import com.moral.constant.ResultMessage;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.ControllerAdvice;
+import org.springframework.web.bind.annotation.ExceptionHandler;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.ResponseStatus;
+
+
+@ControllerAdvice
+@ResponseBody
+public class GlobalExceptionHandler {
+ /**
+ * ������������������
+ */
+ @ExceptionHandler
+ @ResponseBody
+ @ResponseStatus(HttpStatus.OK)
+ public ResultMessage handleException(Exception ex) {
+ ex.printStackTrace();
+ return ResultMessage.fail(Constants.CODE_OPERATION_FAILED, "������������");
+ }
+
+ /**
+ * ������BusinessException������
+ */
+ @ExceptionHandler({BusinessException.class})
+ @ResponseBody
+ @ResponseStatus(HttpStatus.OK)
+ public ResultMessage handleUserNotExistException(BusinessException ex) {
+ return ResultMessage.fail(Constants.CODE_OPERATION_FAILED, "������������������������");
+ }
+
+}
diff --git a/screen-api/src/main/java/com/moral/api/kafka/consumer/KafkaConsumer.java b/screen-api/src/main/java/com/moral/api/kafka/consumer/KafkaConsumer.java
new file mode 100644
index 0000000..af6c8cc
--- /dev/null
+++ b/screen-api/src/main/java/com/moral/api/kafka/consumer/KafkaConsumer.java
@@ -0,0 +1,37 @@
+package com.moral.api.kafka.consumer;
+
+import com.moral.api.constant.TopicConstants;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.kafka.clients.consumer.ConsumerRecord;
+import org.springframework.kafka.annotation.KafkaListener;
+import org.springframework.kafka.support.Acknowledgment;
+import org.springframework.stereotype.Component;
+
+import java.util.Random;
+
+@Component
+@Slf4j
+public class KafkaConsumer {
+
+/* *//**
+ * ���������������������������������
+ * @param record
+ * @param ack
+ * @throws Exception
+ *//*
+ @KafkaListener(topics = TopicConstants.TEST_TOPIC_MESSAGE,groupId = "test")
+ public void listenTest(ConsumerRecord<String, String> record , Acknowledgment ack) throws Exception {
+ String msg = record.value();
+ System.out.println(msg);
+ if (new Random().nextInt(100)<50){
+ log.info(String.format("kafka ������������������---------------- listen1 topic = %s, offset = %d, value = %s ", record.topic(), record.offset(), record.value()));
+ ack.acknowledge();
+ }
+
+ }*/
+
+
+
+
+
+}
diff --git a/screen-api/src/main/java/com/moral/api/mapper/TestMapper.java b/screen-api/src/main/java/com/moral/api/mapper/TestMapper.java
new file mode 100644
index 0000000..46e1799
--- /dev/null
+++ b/screen-api/src/main/java/com/moral/api/mapper/TestMapper.java
@@ -0,0 +1,16 @@
+package com.moral.api.mapper;
+
+import com.moral.api.entity.Test;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * <p>
+ * Mapper ������
+ * </p>
+ *
+ * @author moral
+ * @since 2021-02-25
+ */
+public interface TestMapper extends BaseMapper<Test> {
+
+}
diff --git a/screen-api/src/main/java/com/moral/api/service/TestService.java b/screen-api/src/main/java/com/moral/api/service/TestService.java
new file mode 100644
index 0000000..79f276b
--- /dev/null
+++ b/screen-api/src/main/java/com/moral/api/service/TestService.java
@@ -0,0 +1,25 @@
+package com.moral.api.service;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.moral.api.entity.Test;
+import com.baomidou.mybatisplus.extension.service.IService;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+/**
+ * <p>
+ * ���������
+ * </p>
+ *
+ * @author moral
+ * @since 2021-02-25
+ */
+@Service
+@Transactional
+public interface TestService extends IService<Test> {
+
+ Page<Test> selectByPage(Test test, Integer page, Integer size);
+
+ @Transactional
+ void saveTest() throws Exception;
+}
diff --git a/screen-api/src/main/java/com/moral/api/service/impl/TestServiceImpl.java b/screen-api/src/main/java/com/moral/api/service/impl/TestServiceImpl.java
new file mode 100644
index 0000000..df13f64
--- /dev/null
+++ b/screen-api/src/main/java/com/moral/api/service/impl/TestServiceImpl.java
@@ -0,0 +1,53 @@
+package com.moral.api.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.moral.api.entity.Test;
+import com.moral.api.exception.BusinessException;
+import com.moral.api.mapper.TestMapper;
+import com.moral.api.service.TestService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+/**
+ * <p>
+ * ���������������
+ * </p>
+ *
+ * @author moral
+ * @since 2021-02-25
+ */
+@Service
+public class TestServiceImpl extends ServiceImpl<TestMapper, Test> implements TestService {
+
+ @Autowired
+ private TestMapper testMapper;
+ @Override
+ public Page<Test> selectByPage(Test test, Integer page, Integer size) {
+ //������������������
+ Page<Test> pageData = new Page<>(page, size);
+ //������������������
+ IPage<Test> users = testMapper.selectPage(pageData, new QueryWrapper<>(test));
+ //���������������������������������
+ pageData.setRecords(users.getRecords());
+ //������������
+ return pageData;
+ }
+
+ @Override
+ @Transactional
+ public void saveTest() throws Exception{
+ Test t=new Test();
+ t.setName("aaaa");
+ t.setMobile("139652555");
+ t.setEmail("33@qq.com");
+ testMapper.insert(t);
+ if ("aaaa".equals(t.getName())){
+ throw new BusinessException("aaaa���������������������������������");
+ }
+
+ }
+}
diff --git a/screen-api/src/main/resources/application-dev.yml b/screen-api/src/main/resources/application-dev.yml
new file mode 100644
index 0000000..67627c3
--- /dev/null
+++ b/screen-api/src/main/resources/application-dev.yml
@@ -0,0 +1,101 @@
+server:
+ port: 8081
+ tomcat:
+ uri-encoding: UTF-8
+ #���������������
+ min-spare-threads: 500
+ #���������������
+ max-threads: 2500
+ #���������������
+ max-connections: 6500
+ #������������������������
+ accept-count: 1000
+spring:
+ profiles:
+ active: dev
+ application:
+ name: screen-api
+ redis:
+ #cluster:
+ #nodes: 47.112.126.78:7001,47.112.126.78:7002,47.112.126.132:7003,47.112.126.132:7004,47.112.132.193:7005,47.112.132.193:7006
+ #password: test
+ #timeout: 500
+ host: 127.0.0.1
+ port: 6379
+ password: 123456
+ timeout: 30000
+ jedis:
+ pool:
+ max-active: 256
+ max-wait: 30000
+ max-idle: 64
+ min-idle: 32
+ lettuce:
+ pool:
+ max-active: 256
+ max-idle: 64
+ max-wait: 30000
+ min-idle: 32
+ datasource:
+ minIdle: 1
+ time-between-eviction-runs-millis: 60000
+ max-active: 20
+ test-while-idle: true
+ validation-query: select 'x'
+ filters: stat
+ type: com.alibaba.druid.pool.DruidDataSource
+ max-wait: 60000
+ url: jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=UTC
+ password: 123456
+ test-on-borrow: false
+ sql-script-encoding: utf-8
+ pool-prepared-statements: true
+ min-evictable-idle-time-millis: 300000
+ initial-size: 1
+ driver-class-name: com.mysql.cj.jdbc.Driver
+ max-conn-lifetime-millis: 20
+ test-on-return: false
+ username: root
+
+mybatis-plus:
+ mapper-locations: classpath:mapper/*.xml
+ global-config:
+ db-config:
+ id-type: auto
+ field-strategy: NOT_EMPTY
+ db-type: MYSQL
+ configuration:
+ map-underscore-to-camel-case: true
+ call-setters-on-nulls: true
+ log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
+
+kafka:
+ listener:
+ ack-mode: manual_immediate
+ consumer:
+ auto:
+ commit:
+ interval: 100
+ offset:
+ reset: latest
+ concurrency: 3
+ enable:
+ auto:
+ commit: false
+ group:
+ id: test
+ servers: 192.168.0.16:9092,192.168.0.17:9092,192.168.0.18:9092
+ session:
+ timeout: 6000
+ topic: test_topic
+ zookeeper:
+ connect: 192.168.0.16:2181,192.168.0.17:2181,192.168.0.18:2181
+ producer:
+ batch:
+ size: 4096
+ buffer:
+ memory: 40960
+ linger: 1
+ retries: 0
+ servers: 192.168.0.16:9092,192.168.0.17:9092,192.168.0.18:9092
+
diff --git a/screen-api/src/main/resources/logback-spring.xml b/screen-api/src/main/resources/logback-spring.xml
new file mode 100644
index 0000000..efd0d87
--- /dev/null
+++ b/screen-api/src/main/resources/logback-spring.xml
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<configuration>
+ <include resource="org/springframework/boot/logging/logback/defaults.xml"/>
+
+ <springProperty scope="context" name="springAppName" source="spring.application.name"/>
+ <!-- ��������������������������������� -->
+ <property name="LOG_FILE" value="home/moral/soft/log/${springAppName}"/>
+ <!-- ������������������������������ -->
+ <property name="CONSOLE_LOG_PATTERN"
+ value="%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}) [%X{logseq}]{faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr([${springAppName}]){yellow} %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}"/>
+
+ <property name="FILE_LOG_PATTERN"
+ value="%d{yyyy-MM-dd HH:mm:ss.SSS} [%X{logseq}] [%thread] %X{T} [%level] %logger.%method:%line %msg%n"/>
+
+ <!-- ���������Appender -->
+ <appender name="console" class="ch.qos.logback.core.ConsoleAppender">
+ <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
+ <level>INFO</level>
+ </filter>
+ <encoder>
+ <pattern>${CONSOLE_LOG_PATTERN}</pattern>
+ <charset>utf8</charset>
+ </encoder>
+ </appender>
+ <!-- ������������Appender -->
+ <appender name="screenApiLog" class="ch.qos.logback.classic.sift.SiftingAppender">
+ <discriminator>
+ <key>taskId</key>
+ <defaultValue>default</defaultValue>
+ </discriminator>
+ <sift>
+ <appender name="file" class="ch.qos.logback.core.rolling.RollingFileAppender">
+
+ <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
+ <level>INFO</level>
+ </filter>
+ <file>${LOG_FILE}/%d{yyyy-MM-dd}/${springAppName}.log</file>
+ <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
+ <maxFileSize>30MB</maxFileSize>
+ <fileNamePattern>${LOG_FILE}/%d{yyyy-MM-dd}/${springAppName}-%d{yyyy-MM-dd}.log%i.log</fileNamePattern>
+ <maxHistory>30</maxHistory>
+ </rollingPolicy>
+ <encoder>
+ <pattern>${FILE_LOG_PATTERN}</pattern>
+ <charset>utf8</charset>
+ </encoder>
+ </appender>
+ </sift>
+ </appender>
+
+
+ <root level="INFO">
+ <appender-ref ref="console"/>
+ <appender-ref ref="screenApiLog"/>
+ </root>
+</configuration>
diff --git a/screen-common/pom.xml b/screen-common/pom.xml
new file mode 100644
index 0000000..5fed457
--- /dev/null
+++ b/screen-common/pom.xml
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <parent>
+ <artifactId>screen</artifactId>
+ <groupId>org.moral</groupId>
+ <version>1.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>screen-common</artifactId>
+
+ <properties>
+
+ <spring-boot-starter-data-redis.version>2.1.3.RELEASE</spring-boot-starter-data-redis.version>
+ <jedis.version>2.9.0</jedis.version>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-data-redis</artifactId>
+ <version>${spring-boot-starter-data-redis.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>redis.clients</groupId>
+ <artifactId>jedis</artifactId>
+ <version>${jedis.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>com.alibaba</groupId>
+ <artifactId>fastjson</artifactId>
+ <version>${com.alibaba.version}</version>
+ </dependency>
+ </dependencies>
+
+
+ <build>
+ <finalName>screen-common</finalName>
+ <plugins>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-resources-plugin</artifactId>
+ <version>${maven-resources-plugin.version}</version>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven.shared</groupId>
+ <artifactId>maven-filtering</artifactId>
+ <version>${maven-filtering.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.shared</groupId>
+ <artifactId>maven-common-artifact-filters</artifactId>
+ <version>${maven-common-artifact-filters.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.shared</groupId>
+ <artifactId>maven-dependency-tree</artifactId>
+ <version>${maven-dependency-tree.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.shared</groupId>
+ <artifactId>maven-shared-incremental</artifactId>
+ <version>${maven-shared-incremental.version}</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+
+ </plugins>
+
+ </build>
+
+</project>
\ No newline at end of file
diff --git a/screen-common/src/main/java/com/moral/constant/Constants.java b/screen-common/src/main/java/com/moral/constant/Constants.java
new file mode 100644
index 0000000..d824510
--- /dev/null
+++ b/screen-common/src/main/java/com/moral/constant/Constants.java
@@ -0,0 +1,29 @@
+package com.moral.constant;
+
+/**
+ * ������������������
+ */
+public class Constants {
+
+ /**
+ * ������������
+ */
+ public static final String MSG_OPERATION_SUCCESS = "���������������";
+
+ /**
+ * ������������
+ */
+ public static final String MSG_OPERATION_FAILED = "���������������";
+
+ /**
+ * ������������code
+ */
+ public static final int CODE_OPERATION_SUCCESS = 0;
+ /**
+ * ������������code
+ */
+ public static final int CODE_OPERATION_FAILED = -1;
+
+
+
+}
diff --git a/screen-common/src/main/java/com/moral/constant/ResultMessage.java b/screen-common/src/main/java/com/moral/constant/ResultMessage.java
new file mode 100644
index 0000000..bc1d2f5
--- /dev/null
+++ b/screen-common/src/main/java/com/moral/constant/ResultMessage.java
@@ -0,0 +1,130 @@
+package com.moral.constant;
+
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+import java.util.HashMap;
+
+@ApiModel("������������������")
+public class ResultMessage<T> {
+
+ /**
+ * ���������
+ */
+ @ApiModelProperty("code")
+ private int code;
+ /**
+ * ������������
+ */
+ @ApiModelProperty("msg")
+ private String msg;
+ /**
+ * ������������
+ */
+ @ApiModelProperty("������������")
+ private T data;
+
+ public static ResultMessage ok() {
+ ResultMessage resultMessage = new ResultMessage();
+ resultMessage.setCode(Constants.CODE_OPERATION_SUCCESS);
+ resultMessage.setMessage(Constants.MSG_OPERATION_SUCCESS);
+ resultMessage.setData(new HashMap<>());
+ return resultMessage;
+ }
+
+ public static ResultMessage ok(String msg) {
+ ResultMessage resultMessage = new ResultMessage();
+ resultMessage.setCode(Constants.CODE_OPERATION_SUCCESS);
+ resultMessage.setMessage(msg);
+ resultMessage.setData(new HashMap<>());
+ return resultMessage;
+ }
+
+ public static ResultMessage ok(int code, String msg) {
+ ResultMessage resultMessage = new ResultMessage();
+ resultMessage.setCode(code);
+ resultMessage.setMessage(msg);
+ resultMessage.setData(new HashMap<>());
+ return resultMessage;
+ }
+
+ public static <T> ResultMessage<T> ok(int code, T data) {
+ ResultMessage resultMessage = new ResultMessage();
+ resultMessage.setCode(code);
+ resultMessage.setData(data == null? new HashMap<>():data);
+ return resultMessage;
+ }
+
+ public static <T> ResultMessage<T> ok(T data) {
+ ResultMessage resultMessage = new ResultMessage();
+ resultMessage.setCode(Constants.CODE_OPERATION_SUCCESS);
+ resultMessage.setMessage(Constants.MSG_OPERATION_SUCCESS);
+ resultMessage.setData(data == null ?new HashMap<>():data);
+ return resultMessage;
+ }
+
+ public static <T> ResultMessage<T> ok(int code, String msg, T data) {
+ ResultMessage resultMessage = new ResultMessage();
+ resultMessage.setCode(code);
+ resultMessage.setMessage(msg);
+ resultMessage.setData(data == null?new HashMap<>():data);
+ return resultMessage;
+ }
+
+ public static ResultMessage fail() {
+ ResultMessage resultMessage = new ResultMessage();
+ resultMessage.setCode(Constants.CODE_OPERATION_FAILED);
+ resultMessage.setMessage(Constants.MSG_OPERATION_FAILED);
+ resultMessage.setData(new HashMap<>());
+ return resultMessage;
+ }
+
+ public static ResultMessage fail(String msg) {
+ ResultMessage resultMessage = new ResultMessage();
+ resultMessage.setCode(Constants.CODE_OPERATION_FAILED);
+ resultMessage.setMessage(msg);
+ resultMessage.setData(new HashMap<>());
+ return resultMessage;
+ }
+
+ public static ResultMessage fail(int code, String msg) {
+ ResultMessage resultMessage = new ResultMessage();
+ resultMessage.setCode(code);
+ resultMessage.setMessage(msg);
+ resultMessage.setData(new HashMap<>());
+ return resultMessage;
+ }
+
+ public static <T> ResultMessage<T> fail(T data) {
+ ResultMessage resultMessage = new ResultMessage();
+ resultMessage.setCode(Constants.CODE_OPERATION_FAILED);
+ resultMessage.setMessage(Constants.MSG_OPERATION_FAILED);
+ resultMessage.setData(data == null ?new HashMap<>():data);
+ return resultMessage;
+ }
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public String getMessage() {
+ return msg;
+ }
+
+ public void setMessage(String message) {
+ this.msg = message;
+ }
+
+ public T getData() {
+ return data;
+ }
+
+ public void setData(T data) {
+ this.data = data;
+ }
+}
diff --git a/screen-common/src/main/java/com/moral/redis/RedisUtil.java b/screen-common/src/main/java/com/moral/redis/RedisUtil.java
new file mode 100644
index 0000000..f39cc12
--- /dev/null
+++ b/screen-common/src/main/java/com/moral/redis/RedisUtil.java
@@ -0,0 +1,380 @@
+package com.moral.redis;
+
+
+import com.moral.util.SpringContextUtils;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.util.CollectionUtils;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.TimeUnit;
+
+
+public final class RedisUtil {
+
+ @SuppressWarnings("rawtypes")
+ private static RedisTemplate redisTemplate = SpringContextUtils.getBeanByName("redisTemplate");
+
+ // =============================common============================
+ /**
+ * ������������������������key
+ *
+ * @param: key
+ * @param: time
+ * @return: boolean
+ * @author: wuqp
+ * @date: 2021/02/24 9:46
+ */
+ public static boolean expire(String key, long time) {
+ try {
+ if (time > 0) {
+ redisTemplate.expire(key, time, TimeUnit.SECONDS);
+ }
+ return true;
+ } catch (Exception e) {
+ e.printStackTrace();
+ return false;
+ }
+ }
+
+ /**
+ * ������������������������key
+ *
+ * @param: key
+ * @param: time
+ * @return: long
+ * @author: wuqp
+ * @date: 2021/02/24 9:46
+ */
+ public long getExpire(String key) {
+ return redisTemplate.getExpire(key, TimeUnit.SECONDS);
+ }
+
+ /**
+ * ������key
+ *
+ * @param: key
+ * @return: boolean
+ * @author: wuqp
+ * @date: 2021/02/24 9:46
+ */
+ public boolean hasKey(String key) {
+ try {
+ return redisTemplate.hasKey(key);
+ } catch (Exception e) {
+ e.printStackTrace();
+ return false;
+ }
+ }
+
+ /**
+ * ������������
+ *
+ * @param: key
+ * @param: time
+ * @return: boolean
+ * @author: wuqp
+ * @date: 2021/02/24 9:46
+ */
+ @SuppressWarnings("unchecked")
+ public void del(String... key) {
+ if (key != null && key.length > 0) {
+ if (key.length == 1) {
+ redisTemplate.delete(key[0]);
+ } else {
+ redisTemplate.delete(CollectionUtils.arrayToList(key));
+ }
+ }
+ }
+
+ // ============================String=============================
+ /**
+ * ������string���������������
+ *
+ * @param: key
+ * @param: time
+ * @return: Object
+ * @author: wuqp
+ * @date: 2021/02/24 9:46
+ */
+ public static Object get(String key) {
+ return key == null ? null : redisTemplate.opsForValue().get(key);
+ }
+
+ /**
+ * ������string���������������
+ *
+ * @param: key
+ * @param: value
+ * @return: boolean
+ * @author: wuqp
+ * @date: 2021/02/24 9:46
+ */
+ public static boolean set(String key, Object value) {
+ try {
+ redisTemplate.opsForValue().set(key, value);
+ return true;
+ } catch (Exception e) {
+ e.printStackTrace();
+ return false;
+ }
+ }
+
+ /**
+ * ������string������������������������������
+ *
+ * @param: key
+ * @param: value
+ * @param: time
+ * @return: boolean
+ * @author: wuqp
+ * @date: 2021/02/24 9:46
+ */
+ public static boolean set(String key, Object value, long time) {
+ try {
+ if (time > 0) {
+ redisTemplate.opsForValue().set(key, value, time, TimeUnit.SECONDS);
+ } else {
+ set(key, value);
+ }
+ return true;
+ } catch (Exception e) {
+ e.printStackTrace();
+ return false;
+ }
+ }
+
+
+ // ================================Map=================================
+ public Object hget(String key, String item) {
+ return redisTemplate.opsForHash().get(key, item);
+ }
+
+ public Map<Object, Object> hmget(String key) {
+ return redisTemplate.opsForHash().entries(key);
+ }
+
+ public boolean hmset(String key, Map<String, Object> map) {
+ try {
+ redisTemplate.opsForHash().putAll(key, map);
+ return true;
+ } catch (Exception e) {
+ e.printStackTrace();
+ return false;
+ }
+ }
+
+ public boolean hmset(String key, Map<String, Object> map, long time) {
+ try {
+ redisTemplate.opsForHash().putAll(key, map);
+ if (time > 0) {
+ expire(key, time);
+ }
+ return true;
+ } catch (Exception e) {
+ e.printStackTrace();
+ return false;
+ }
+ }
+
+ public boolean hset(String key, String item, Object value) {
+ try {
+ redisTemplate.opsForHash().put(key, item, value);
+ return true;
+ } catch (Exception e) {
+ e.printStackTrace();
+ return false;
+ }
+ }
+
+ public boolean hset(String key, String item, Object value, long time) {
+ try {
+ redisTemplate.opsForHash().put(key, item, value);
+ if (time > 0) {
+ expire(key, time);
+ }
+ return true;
+ } catch (Exception e) {
+ e.printStackTrace();
+ return false;
+ }
+ }
+
+ public void hdel(String key, Object... item) {
+ redisTemplate.opsForHash().delete(key, item);
+ }
+
+ public boolean hHasKey(String key, String item) {
+ return redisTemplate.opsForHash().hasKey(key, item);
+ }
+
+ public double hincr(String key, String item, double by) {
+ return redisTemplate.opsForHash().increment(key, item, by);
+ }
+
+ public double hdecr(String key, String item, double by) {
+ return redisTemplate.opsForHash().increment(key, item, -by);
+ }
+
+ // ============================set=============================
+ public Set<Object> sGet(String key) {
+ try {
+ return redisTemplate.opsForSet().members(key);
+ } catch (Exception e) {
+ e.printStackTrace();
+ return null;
+ }
+ }
+
+ public boolean sHasKey(String key, Object value) {
+ try {
+ return redisTemplate.opsForSet().isMember(key, value);
+ } catch (Exception e) {
+ e.printStackTrace();
+ return false;
+ }
+ }
+
+ public long sSet(String key, Object... values) {
+ try {
+ return redisTemplate.opsForSet().add(key, values);
+ } catch (Exception e) {
+ e.printStackTrace();
+ return 0;
+ }
+ }
+
+ public long sSetAndTime(String key, long time, Object... values) {
+ try {
+ Long count = redisTemplate.opsForSet().add(key, values);
+ if (time > 0)
+ expire(key, time);
+ return count;
+ } catch (Exception e) {
+ e.printStackTrace();
+ return 0;
+ }
+ }
+
+ public long sGetSetSize(String key) {
+ try {
+ return redisTemplate.opsForSet().size(key);
+ } catch (Exception e) {
+ e.printStackTrace();
+ return 0;
+ }
+ }
+
+ public long setRemove(String key, Object... values) {
+ try {
+ Long count = redisTemplate.opsForSet().remove(key, values);
+ return count;
+ } catch (Exception e) {
+ e.printStackTrace();
+ return 0;
+ }
+ }
+
+ // ===============================list=================================
+ public List<Object> lGet(String key, long start, long end) {
+ try {
+ return redisTemplate.opsForList().range(key, start, end);
+ } catch (Exception e) {
+ e.printStackTrace();
+ return null;
+ }
+ }
+
+ public long lGetListSize(String key) {
+ try {
+ return redisTemplate.opsForList().size(key);
+ } catch (Exception e) {
+ e.printStackTrace();
+ return 0;
+ }
+ }
+
+ public Object lGetIndex(String key, long index) {
+ try {
+ return redisTemplate.opsForList().index(key, index);
+ } catch (Exception e) {
+ e.printStackTrace();
+ return null;
+ }
+ }
+
+ public boolean lSet(String key, Object value) {
+ try {
+ redisTemplate.opsForList().rightPush(key, value);
+ return true;
+ } catch (Exception e) {
+ e.printStackTrace();
+ return false;
+ }
+ }
+
+ public boolean lSet(String key, Object value, long time) {
+ try {
+ redisTemplate.opsForList().rightPush(key, value);
+ if (time > 0)
+ expire(key, time);
+ return true;
+ } catch (Exception e) {
+ e.printStackTrace();
+ return false;
+ }
+ }
+
+ public boolean lSet(String key, List<Object> value) {
+ try {
+ redisTemplate.opsForList().rightPushAll(key, value);
+ return true;
+ } catch (Exception e) {
+ e.printStackTrace();
+ return false;
+ }
+ }
+
+ public boolean lSet(String key, List<Object> value, long time) {
+ try {
+ redisTemplate.opsForList().rightPushAll(key, value);
+ if (time > 0)
+ expire(key, time);
+ return true;
+ } catch (Exception e) {
+ e.printStackTrace();
+ return false;
+ }
+ }
+
+ public boolean lUpdateIndex(String key, long index, Object value) {
+ try {
+ redisTemplate.opsForList().set(key, index, value);
+ return true;
+ } catch (Exception e) {
+ e.printStackTrace();
+ return false;
+ }
+ }
+
+ public long lRemove(String key, long count, Object value) {
+ try {
+ Long remove = redisTemplate.opsForList().remove(key, count, value);
+ return remove;
+ } catch (Exception e) {
+ e.printStackTrace();
+ return 0;
+ }
+ }
+
+ public Set<String> keys(String pattern) {
+ try {
+ Set<String> set = redisTemplate.keys(pattern);
+ return set;
+ } catch (Exception e) {
+ e.printStackTrace();
+ return null;
+ }
+ }
+}
diff --git a/screen-common/src/main/java/com/moral/util/DateUtils.java b/screen-common/src/main/java/com/moral/util/DateUtils.java
new file mode 100644
index 0000000..69f256d
--- /dev/null
+++ b/screen-common/src/main/java/com/moral/util/DateUtils.java
@@ -0,0 +1,1267 @@
+package com.moral.util;
+
+
+
+import org.springframework.util.StringUtils;
+
+import java.math.BigDecimal;
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.time.Instant;
+import java.time.LocalDateTime;
+import java.time.ZoneId;
+import java.time.ZonedDateTime;
+import java.util.*;
+
+
+public class DateUtils {
+ /** ������������(yyyy-MM-dd) */
+ public static final String yyyy_MM_dd_EN = "yyyy-MM-dd";
+ /** ������������(yyyy/MM/dd) */
+ public static final String yyyy_MM_dd_decline = "yyyy/MM/dd";
+ /** ������������(yyyyMMdd) */
+ public static final String yyyyMMdd_EN = "yyyyMMdd";
+ /** ������������(yyyy-MM) */
+ public static final String yyyy_MM_EN = "yyyy-MM";
+ /** ������������(yyyyMM) */
+ public static final String yyyyMM_EN = "yyyyMM";
+ /** ������������(yyyy-MM-dd HH:mm:ss) */
+ public static final String yyyy_MM_dd_HH_mm_ss_EN = "yyyy-MM-dd HH:mm:ss";
+ /** ������������(yyyy-MM-dd HH:mm:ss.S) */
+ public static final String yyyy_MM_dd_HH_mm_ss_S_EN = "yyyy-MM-dd HH:mm:ss.S";
+ /** ������������(yyyyMMddHHmmss) */
+ public static final String yyyyMMddHHmmss_EN = "yyyyMMddHHmmss";
+ /** ������������(yyyy���MM���dd���) */
+ public static final String yyyy_MM_dd_CN = "yyyy���MM���dd���";
+ /** ������������(yyyy���MM���dd���HH���mm���ss���) */
+ public static final String yyyy_MM_dd_HH_mm_ss_CN = "yyyy���MM���dd���HH���mm���ss���";
+ /** ������������(yyyy���MM���dd���HH���mm���) */
+ public static final String yyyy_MM_dd_HH_mm_CN = "yyyy���MM���dd���HH���mm���";
+ /** ������boss��������������������������������� */
+ public static final String BJBOSS_DATE = "yyyy-MM-dd'T'HH:mm:ss'Z'";
+ /** ������������(HH:mm:ss) */
+ public static final String HH_mm_ss_EN = "HH:mm:ss";
+ /** DateFormat������ */
+ private static Map<String, DateFormat> dateFormatMap = new HashMap<String, DateFormat>();
+
+ /**
+ * ������DateFormat
+ *
+ * @param formatStr
+ * @return
+ */
+ public static DateFormat getDateFormat(String formatStr) {
+ DateFormat df = dateFormatMap.get(formatStr);
+ if (df == null) {
+ df = new SimpleDateFormat(formatStr);
+ dateFormatMap.put(formatStr, df);
+ }
+ return df;
+ }
+
+ public static Date getDate() {
+ return Calendar.getInstance().getTime();
+ }
+
+ /**
+ * ������������formatStr������������������dateTimeStr���Date������ dateTimeStr���������formatStr���������
+ *
+ * @param dateTimeStr
+ * @param formatStr
+ * @return
+ */
+ public static Date getDate(String dateTimeStr, String formatStr) {
+ try {
+ if (dateTimeStr == null || dateTimeStr.equals("")) {
+ return null;
+ }
+ DateFormat sdf = getDateFormat(formatStr);
+ return sdf.parse(dateTimeStr);
+ } catch (ParseException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ * ������dateTimeStr���Date������
+ *
+ * @param dateTimeStr
+ * @return
+ */
+ public static Date convertDate(String dateTimeStr) {
+ try {
+ if (dateTimeStr == null || dateTimeStr.equals("")) {
+ return null;
+ }
+ DateFormat sdf = getDateFormat(yyyy_MM_dd_EN);
+ Date d = sdf.parse(dateTimeStr);
+ return d;
+ } catch (ParseException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ * ���������������������������������������"yyyy-MM-dd"���������dateTimeStr���Date������ dateTimeStr���������"yyyy-MM-dd"���������
+ *
+ * @param dateTimeStr
+ * @return
+ */
+ public static Date getDate(String dateTimeStr) {
+ return getDate(dateTimeStr, yyyy_MM_dd_EN);
+ }
+
+ /**
+ * ���YYYYMMDD���������Date������
+ *
+ * @param date
+ * @return
+ * @throws Exception
+ */
+ public static Date transferDate(String date) throws Exception {
+ if (date == null || date.length() < 1)
+ return null;
+
+ if (date.length() != 8)
+ throw new Exception("������������������");
+ String con = "-";
+
+ String yyyy = date.substring(0, 4);
+ String mm = date.substring(4, 6);
+ String dd = date.substring(6, 8);
+
+ int month = Integer.parseInt(mm);
+ int day = Integer.parseInt(dd);
+ if (month < 1 || month > 12 || day < 1 || day > 31)
+ throw new Exception("������������������");
+
+ String str = yyyy + con + mm + con + dd;
+ return getDate(str, yyyy_MM_dd_EN);
+ }
+
+ /**
+ * ���Date���������������������yyyy-mm-dd hh:mm:ss���������������
+ *
+ * @param date
+ * @return
+ */
+ public static String dateToDateString(Date date) {
+ return dateToDateString(date, yyyy_MM_dd_HH_mm_ss_EN);
+ }
+
+ /**
+ * ���Date���������������������yyyymmddhhmmss���������������
+ *
+ * @param date
+ * @return
+ */
+ public static String dateToDateFullString(Date date) {
+ if (null == date)
+ return null;
+ else
+ return dateToDateString(date, yyyyMMddHHmmss_EN);
+ }
+
+ /**
+ * ���Date���������formatStr������������������
+ *
+ * @param date
+ * @param formatStr
+ * @return
+ */
+ public static String dateToDateString(Date date, String formatStr) {
+ DateFormat df = getDateFormat(formatStr);
+ return df.format(date);
+ }
+
+ /**
+ * ���String���������formatStr������������������
+ *
+ * @param date
+ * @param formatStr1
+ * @param formatStr2
+ * @return
+ */
+ public static String stringToDateString(String date, String formatStr1, String formatStr2) {
+ Date d = getDate(date, formatStr1);
+ DateFormat df = getDateFormat(formatStr2);
+ return df.format(d);
+ }
+
+ /**
+ * ������������������yyyy-MM-dd���������
+ *
+ * @return
+ */
+ public static String getCurDate() {
+ return dateToDateString(new Date(), yyyy_MM_dd_EN);
+ }
+
+ /**
+ * ������������������
+ *
+ * @return
+ */
+ public static String getCurDate(String formatStr) {
+ return dateToDateString(new Date(), formatStr);
+ }
+
+ /**
+ * ������������������yyyy���MM���dd������������
+ *
+ * @return
+ */
+ public static String getCurCNDate() {
+ return dateToDateString(new Date(), yyyy_MM_dd_CN);
+ }
+
+ /**
+ * ������������������������yyyy-MM-dd HH:mm:ss���������
+ *
+ * @return
+ */
+ public static String getCurDateTime() {
+ return dateToDateString(new Date(), yyyy_MM_dd_HH_mm_ss_EN);
+ }
+
+ /**
+ * ������������������������yyyy���MM���dd���HH���mm���ss������������
+ *
+ * @return
+ */
+ public static String getCurZhCNDateTime() {
+ return dateToDateString(new Date(), yyyy_MM_dd_HH_mm_ss_CN);
+ }
+
+ /**
+ * ������������"yyyy-MM-dd HH:mm:ss"������������������������������������������,time2-time1
+ *
+ * @param time1
+ * @param time2
+ * @return
+ */
+ public static long compareDateStr(String time1, String time2) {
+ Date d1 = getDate(time1);
+ Date d2 = getDate(time2);
+ return d2.getTime() - d1.getTime();
+ }
+
+ /**
+ * ���������������������������������������
+ *
+ * @param time1
+ * @param time2
+ * @param format
+ * @return
+ */
+ public static long compareDateStr(String time1, String time2, String format) {
+ Date d1 = getDate(time1, format);
+ Date d2 = getDate(time2, format);
+ return d2.getTime() - d1.getTime();
+ }
+
+ /**
+ * ������������������������������������������������
+ *
+ * @param time
+ * @param format
+ * @return
+ */
+ public static long compareDateNow(String time, String format) {
+ Date date = getDate(time, format);
+ return new Date().getTime() - date.getTime();
+ }
+
+ /**
+ * ������������"yyyy-MM-dd HH:mm:ss"������������������������������������������,time2-time1
+ *
+ * @param time1
+ * @param time2
+ * @return
+ */
+ public static long compareDateStr(Date time1, Date time2) {
+ return time2.getTime() - time1.getTime();
+ }
+
+ /**
+ * nows������������date������ ���true
+ *
+ * @param nows
+ * @param date
+ * @return
+ */
+ public static boolean isTimeBefor(Date nows, Date date) {
+ long hous = nows.getTime() - date.getTime();
+ if (hous > 0) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * ������������������������������������������������������
+ *
+ * @param hours
+ * @return
+ */
+ public static long getMicroSec(BigDecimal hours) {
+ BigDecimal bd;
+ bd = hours.multiply(new BigDecimal(3600 * 1000));
+ return bd.longValue();
+ }
+
+ /**
+ * ������������������years���������������(formatStr)������������
+ *
+ * @param years
+ * @param formatStr
+ * @return
+ */
+ public static String getDateStringOfYear(int years, String formatStr) {
+ Calendar now = Calendar.getInstance(TimeZone.getDefault());
+ now.setTime(new Date());
+ now.add(Calendar.YEAR, years);
+ return dateToDateString(now.getTime(), formatStr);
+ }
+
+ /**
+ * ������������������mon���������������(formatStr)������������
+ *
+ * @param months
+ * @param formatStr
+ * @return
+ */
+ public static String getDateStringOfMon(int months, String formatStr) {
+ Calendar now = Calendar.getInstance(TimeZone.getDefault());
+ now.setTime(new Date());
+ now.add(Calendar.MONTH, months);
+ return dateToDateString(now.getTime(), formatStr);
+ }
+
+ /**
+ * ������������������days���������������(formatStr)������������
+ *
+ * @param days
+ * @param formatStr
+ * @return
+ */
+ public static String getDateStringOfDay(int days, String formatStr) {
+ Calendar now = Calendar.getInstance(TimeZone.getDefault());
+ now.setTime(new Date());
+ now.add(Calendar.DATE, days);
+ return dateToDateString(now.getTime(), formatStr);
+ }
+
+ /**
+ * ���������������������������
+ *
+ * @param date
+ * @return
+ */
+ public static int theDateIsToday(String date, String format) {
+ String theDate = stringToDateString(date, format, yyyyMMdd_EN);
+ String today = getDateStringOfDay(0, yyyyMMdd_EN);
+ if (theDate.equals(today)) {
+ return 1;
+ } else {
+ return 0;
+ }
+ }
+
+ /**
+ * ������������������hours������������������(formatStr)������������
+ *
+ * @param hours
+ * @param formatStr
+ * @return
+ */
+ public static String getDateStringOfHour(int hours, String formatStr) {
+ Calendar now = Calendar.getInstance(TimeZone.getDefault());
+ now.setTime(new Date());
+ now.add(Calendar.HOUR_OF_DAY, hours);
+ return dateToDateString(now.getTime(), formatStr);
+ }
+
+ /**
+ * ������������������mon���������������(formatStr)������������
+ *
+ * @param date
+ * @param mon
+ * @param formatStr
+ * @return
+ */
+ public static String getDateOfMon(String date, int mon, String formatStr) {
+ Calendar now = Calendar.getInstance(TimeZone.getDefault());
+ now.setTime(getDate(date, formatStr));
+ now.add(Calendar.MONTH, mon);
+ return dateToDateString(now.getTime(), formatStr);
+ }
+
+ /**
+ * ������������������day���������������(formatStr)������������
+ *
+ * @param date
+ * @param day
+ * @param formatStr
+ * @return
+ */
+ public static String getDateOfDay(String date, int day, String formatStr) {
+ Calendar now = Calendar.getInstance(TimeZone.getDefault());
+ now.setTime(getDate(date, formatStr));
+ now.add(Calendar.DATE, day);
+ return dateToDateString(now.getTime(), formatStr);
+ }
+
+ public static Date getDate(Date beginDate, int ds) {
+ if (ds == 0)
+ return new Date();
+ try {
+ SimpleDateFormat dft = new SimpleDateFormat("yyyy-MM-dd");
+ Calendar date = Calendar.getInstance();
+ date.setTime(beginDate);
+ date.set(Calendar.DATE, date.get(Calendar.DATE) - ds);
+ Date endDate = dft.parse(dft.format(date.getTime()));
+ return endDate;
+ } catch (ParseException e) {
+ e.printStackTrace();
+ }
+ return new Date();
+ }
+
+ public static String getAfterNDays(Date date, int n, String formateStr) {
+ SimpleDateFormat sdf = new SimpleDateFormat(formateStr);
+ Calendar calendar = new GregorianCalendar();
+ calendar.setTime(date);
+ calendar.add(Calendar.DATE, n);
+ return sdf.format(calendar.getTime());
+ }
+
+ /**
+ * ������������������mins������������������(formatStr)������������
+ *
+ * @param date
+ * @param mins
+ * @param formatStr
+ * @return
+ */
+ public static String getDateOfMin(String date, int mins, String formatStr) {
+ Calendar now = Calendar.getInstance(TimeZone.getDefault());
+ now.setTime(getDate(date, formatStr));
+ now.add(Calendar.SECOND, mins * 60);
+ return dateToDateString(now.getTime(), formatStr);
+ }
+
+ /**
+ * ������������������mins������������������������
+ *
+ * @param date
+ * @param mins
+ * @return
+ */
+ public static Date getDateOfMin(Date date, int mins) {
+ Calendar now = Calendar.getInstance(TimeZone.getDefault());
+ now.setTime(date);
+ now.add(Calendar.SECOND, mins * 60);
+ return now.getTime();
+ }
+
+ /**
+ * ������������������mins������������������(formatStr)������������
+ *
+ * @param mins
+ * @param formatStr
+ * @return
+ */
+ public static String getDateStringOfMin(int mins, String formatStr) {
+ Calendar now = Calendar.getInstance(TimeZone.getDefault());
+ now.setTime(new Date());
+ now.add(Calendar.MINUTE, mins);
+ return dateToDateString(now.getTime(), formatStr);
+ }
+
+ /**
+ * ������������������mins������������������������
+ *
+ * @param mins
+ * @return
+ */
+ public static Date getDateOfMin(int mins) {
+ Calendar now = Calendar.getInstance(TimeZone.getDefault());
+ now.setTime(new Date());
+ now.add(Calendar.MINUTE, mins);
+ return now.getTime();
+ }
+
+ /**
+ * ������������������sec���������������(formatStr)������������
+ *
+ * @param sec
+ * @param formatStr
+ * @return
+ */
+ public static String getDateStringOfSec(int sec, String formatStr) {
+ Calendar now = Calendar.getInstance(TimeZone.getDefault());
+ now.setTime(new Date());
+ now.add(Calendar.SECOND, sec);
+ return dateToDateString(now.getTime(), formatStr);
+ }
+
+ /**
+ * ���������������������������������
+ *
+ * @return
+ */
+ public static int getMonthDay(Date date) {
+ Calendar c = Calendar.getInstance();
+ c.setTime(date);
+ return c.getActualMaximum(Calendar.DAY_OF_MONTH);
+
+ }
+
+ /**
+ * ���������������������������������
+ *
+ * @return
+ */
+ public static int getCurentMonthDay() {
+ Date date = Calendar.getInstance().getTime();
+ return getMonthDay(date);
+ }
+
+ /**
+ * ��������������������������������� yyyy-mm-dd
+ *
+ * @return
+ */
+ public static int getMonthDay(String date) {
+ Date strDate = getDate(date, yyyy_MM_dd_EN);
+ return getMonthDay(strDate);
+ }
+
+ /**
+ * ������19xx,20xx������������
+ *
+ * @param d
+ * @return
+ */
+ public static int getYear(Date d) {
+ Calendar now = Calendar.getInstance(TimeZone.getDefault());
+ now.setTime(d);
+ return now.get(Calendar.YEAR);
+ }
+
+ /**
+ * ���������������1-12���
+ *
+ * @param d
+ * @return
+ */
+ public static int getMonth(Date d) {
+ Calendar now = Calendar.getInstance(TimeZone.getDefault());
+ now.setTime(d);
+ return now.get(Calendar.MONTH) + 1;
+ }
+
+ /**
+ * ������xxxx-xx-xx������
+ *
+ * @param d
+ * @return
+ */
+ public static int getDay(Date d) {
+ Calendar now = Calendar.getInstance(TimeZone.getDefault());
+ now.setTime(d);
+ return now.get(Calendar.DAY_OF_MONTH);
+ }
+
+ /**
+ * ������Date������������(24������)
+ *
+ * @param d
+ * @return
+ */
+ public static int getHour(Date d) {
+ Calendar now = Calendar.getInstance(TimeZone.getDefault());
+ now.setTime(d);
+ return now.get(Calendar.HOUR_OF_DAY);
+ }
+
+ /**
+ * ������Date������������
+ *
+ * @param d
+ * @return
+ */
+ public static int getMin(Date d) {
+ Calendar now = Calendar.getInstance(TimeZone.getDefault());
+ now.setTime(d);
+ return now.get(Calendar.MINUTE);
+ }
+
+ /**
+ * ������Date���������
+ *
+ * @param d
+ * @return
+ */
+ public static int getSecond(Date d) {
+ Calendar now = Calendar.getInstance(TimeZone.getDefault());
+ now.setTime(d);
+ return now.get(Calendar.SECOND);
+ }
+
+ /**
+ * ������������������
+ *
+ * @return yyyy-MM-dd
+ */
+ public static String getMondayOfThisWeek() {
+ Calendar c = Calendar.getInstance();
+ int day_of_week = c.get(Calendar.DAY_OF_WEEK) - 1;
+ if (day_of_week == 0)
+ day_of_week = 7;
+ c.add(Calendar.DATE, -day_of_week + 1);
+ return dateToDateString(c.getTime(), yyyy_MM_dd_EN);
+ }
+
+ /**
+ * ������������������
+ *
+ * @return yyyy-MM-dd
+ */
+ public static String getSundayOfThisWeek() {
+ Calendar c = Calendar.getInstance();
+ int day_of_week = c.get(Calendar.DAY_OF_WEEK) - 1;
+ if (day_of_week == 0)
+ day_of_week = 7;
+ c.add(Calendar.DATE, -day_of_week + 7);
+ return dateToDateString(c.getTime());
+ }
+
+ /**
+ * ���������������(*)
+ *
+ * @return yyyy-MM-dd
+ */
+ public static String getDayOfThisWeek(int num) {
+ Calendar c = Calendar.getInstance();
+ int day_of_week = c.get(Calendar.DAY_OF_WEEK) - 1;
+ if (day_of_week == 0)
+ day_of_week = 7;
+ c.add(Calendar.DATE, -day_of_week + num);
+ return dateToDateString(c.getTime(), yyyy_MM_dd_EN);
+ }
+
+ /**
+ * ���������������������
+ *
+ * @return yyyy-MM-dd
+ */
+ public static String getDayOfThisMoon(String num) {
+ String date = dateToDateString(new Date(), yyyy_MM_EN);
+ date = date + "-" + num;
+ return date;
+ }
+
+ /**
+ * ���������������������������������
+ *
+ * @param beginDate
+ * @param endDate
+ * @return
+ */
+ public static long getQuotByDays(String beginDate, String endDate) {
+ long quot = 0;
+ DateFormat df = getDateFormat(yyyy_MM_dd_EN);
+ try {
+ Date d1 = df.parse(beginDate);
+ Date d2 = df.parse(endDate);
+ quot = d2.getTime() - d1.getTime();
+ quot = quot / 1000 / 60 / 60 / 24;
+ } catch (ParseException e) {
+ throw new RuntimeException(e);
+ }
+ return quot;
+ }
+
+ /**
+ * ���������������������������������������������������
+ *
+ * @param date
+ * @param days
+ * @return
+ */
+ public static String getDateAddDay(String date, int days, String format) {
+ DateFormat df = getDateFormat(format);
+ try {
+ Calendar cal = Calendar.getInstance();
+ cal.setTime(df.parse(date));
+ cal.set(Calendar.DAY_OF_YEAR, cal.get(Calendar.DAY_OF_YEAR) + days);
+
+ date = df.format(cal.getTime());
+ } catch (ParseException e) {
+ throw new RuntimeException(e);
+ }
+ return date;
+ }
+
+ /**
+ * ������������������������������
+ *
+ * @return
+ */
+ public static Date getLastDayOfCurrMonth() {
+ Calendar cal = Calendar.getInstance();
+ cal.add(Calendar.MONTH, 1);
+ cal.set(Calendar.DAY_OF_MONTH, 0);
+
+ return cal.getTime();
+ }
+
+ /**
+ * ���������������������������������������������������
+ *
+ * @param date
+ * @param m
+ * @return
+ */
+ public static String getDateAddMonth(String date, int m) {
+ DateFormat df = getDateFormat(yyyyMM_EN);
+ try {
+ Calendar cal = Calendar.getInstance();
+ cal.setTime(df.parse(date));
+ cal.add(Calendar.MONTH, m);
+ date = df.format(cal.getTime());
+ } catch (ParseException e) {
+ throw new RuntimeException(e);
+ }
+ return date;
+ }
+
+ /**
+ * ������������������������������
+ *
+ * @param year
+ * @param month
+ * @return
+ */
+ public static String getFirstDayOfMonth(int year, int month) {
+ Calendar cal = Calendar.getInstance();
+ // ������������
+ cal.set(Calendar.YEAR, year);
+ // ������������
+ cal.set(Calendar.MONTH, month - 1);
+ // ������������������������
+ int lastDay = cal.getActualMinimum(Calendar.DAY_OF_MONTH);
+ // ������������������������������������
+ cal.set(Calendar.DAY_OF_MONTH, lastDay);
+ // ���������������
+ DateFormat df = getDateFormat(yyyy_MM_dd_EN);
+ return df.format(cal.getTime());
+ }
+
+ /**
+ * ������������������������������
+ *
+ * @param year
+ * @param month
+ * @return
+ */
+ public static String getLastDayOfMonth(int year, int month) {
+ Calendar cal = Calendar.getInstance();
+ // ������������
+ cal.set(Calendar.YEAR, year);
+ // ������������
+ cal.set(Calendar.MONTH, month - 1);
+ // ������������������������
+ int lastDay = cal.getActualMaximum(Calendar.DAY_OF_MONTH);
+ // ������������������������������������
+ cal.set(Calendar.DAY_OF_MONTH, lastDay);
+ // ���������������
+ DateFormat df = getDateFormat(yyyy_MM_dd_EN);
+ return df.format(cal.getTime());
+ }
+
+ /**
+ * ������������������
+ *
+ * @param date
+ * @return
+ * @throws ParseException
+ */
+ public static String getYesterday(Date date) throws ParseException {
+ DateFormat df = getDateFormat(yyyy_MM_dd_EN);
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTime(df.parse(df.format(date)));
+ calendar.add(Calendar.DAY_OF_MONTH, -1);
+ return df.format(calendar.getTime());
+ }
+
+
+ /**
+ * 10���������������������
+ *
+ * @param dateInt
+ * @param format
+ * @return
+ */
+ public static String getIntToStr(String dateInt, String format) {
+ DateFormat df = getDateFormat(format);
+ long times = Integer.parseInt(dateInt) * 1000L;
+ Date date = new Date(times);
+ return df.format(date);
+ }
+
+ /**
+ * ������ 10������������
+ *
+ * @return
+ */
+ public static Integer getDateInt() {
+ return (int) (System.currentTimeMillis() / 1000);
+ }
+
+ /**
+ * 13���������������������
+ *
+ * @param time
+ * @param format
+ * @return
+ */
+ public static String getLongToStr(long time, String format) {
+ Date date = new Date(time);
+ return dateToDateString(date, format);
+ }
+
+ /**
+ * ������������������������������������
+ *
+ * @param start
+ * @param end
+ * @return
+ */
+ public static int getIntervalSec(int start, int end) {
+ return (end - start) * 60 * 60;
+ }
+
+ /**
+ * ���������������������������������
+ *
+ * @param time
+ * @return
+ */
+ public static String getMillsStr(long time) {
+ String timeStr = String.valueOf(time);
+ String suffix = timeStr.substring(0, timeStr.length() - 3);
+ String prefix = timeStr.substring(timeStr.length() - 3, timeStr.length());
+ return suffix + "." + prefix;
+ }
+
+ /**
+ * ���������������������������������������������
+ *
+ * @param timeStr
+ * @param formatStr
+ * @return
+ */
+ public static String longToString(String timeStr, String formatStr) {
+ long times = Long.parseLong(timeStr.replace(".", ""));
+ Date date = new Date(times);
+ return dateToDateString(date, formatStr);
+ }
+
+ /**
+ * ������������������������
+ *
+ * @return
+ */
+ public static Long getTodayTime() {
+ Calendar todayStart = Calendar.getInstance();
+ todayStart.set(Calendar.HOUR_OF_DAY, 0);
+ todayStart.set(Calendar.MINUTE, 0);
+ todayStart.set(Calendar.SECOND, 0);
+ todayStart.set(Calendar.MILLISECOND, 0);
+ return todayStart.getTime().getTime();
+ }
+
+ public static Integer getTodayInt() {
+ return (int) (getTodayTime() / 1000);
+ }
+
+ /**
+ * ������������������������
+ *
+ * @return
+ */
+ public static Long getEndTime() {
+ Calendar todayEnd = Calendar.getInstance();
+ todayEnd.set(Calendar.HOUR, 23);
+ todayEnd.set(Calendar.MINUTE, 59);
+ todayEnd.set(Calendar.SECOND, 59);
+ todayEnd.set(Calendar.MILLISECOND, 999);
+ return todayEnd.getTime().getTime();
+ }
+
+ public static Integer getTomorrowInt() {
+ return (int) (getTomorrowTime() / 1000);
+ }
+
+ /**
+ * ���������������������������
+ *
+ * @return
+ */
+ public static Long getTomorrowTime() {
+ Calendar cal = Calendar.getInstance();
+ cal.setTime(new Date());
+ cal.set(Calendar.HOUR_OF_DAY, 0);
+ cal.set(Calendar.MINUTE, 0);
+ cal.set(Calendar.SECOND, 0);
+ cal.set(Calendar.MILLISECOND, 0);
+ cal.add(Calendar.DAY_OF_MONTH, 1);
+ return cal.getTime().getTime();
+ }
+
+ /**
+ * ���������������������������������
+ *
+ * @param hour
+ * @return
+ */
+ public static Long getPointHourTime(int hour) {
+ Calendar todayStart = Calendar.getInstance();
+ todayStart.set(Calendar.HOUR_OF_DAY, hour);
+ todayStart.set(Calendar.MINUTE, 0);
+ todayStart.set(Calendar.SECOND, 0);
+ todayStart.set(Calendar.MILLISECOND, 0);
+ return todayStart.getTime().getTime();
+ }
+
+ /**
+ * ������������n���������h������
+ *
+ * @param days
+ * @param hour
+ * @return
+ */
+ public static Long getPointDateHourTime(int days, int hour) {
+ Calendar todayStart = Calendar.getInstance();
+ todayStart.add(Calendar.DATE, days);
+ todayStart.set(Calendar.HOUR_OF_DAY, hour);
+ todayStart.set(Calendar.MINUTE, 0);
+ todayStart.set(Calendar.SECOND, 0);
+ todayStart.set(Calendar.MILLISECOND, 0);
+ return todayStart.getTime().getTime();
+ }
+
+ /**
+ * ���������������������
+ *
+ * @param time
+ * @return
+ */
+ public static Integer hourTosec(String time) {
+ if ("null".equals(time) || StringUtils.isEmpty(time)) {
+ return null;
+ }
+ if (time.length() <= 5) {
+ time += ":00";
+ }
+ int index1 = time.indexOf(":");
+ int index2 = time.indexOf(":", index1 + 1);
+ int hh = Integer.parseInt(time.substring(0, index1));
+ int mi = Integer.parseInt(time.substring(index1 + 1, index2));
+ int ss = Integer.parseInt(time.substring(index2 + 1));
+ return hh * 60 * 60 + mi * 60 + ss;
+ }
+
+ /**
+ * ���������������������
+ *
+ * @param time
+ * @return
+ */
+ public static Integer minTosec(String time) {
+ if (time.length() <= 5) {
+ time += ":00";
+ }
+ int index1 = time.indexOf(":");
+ int index2 = time.indexOf(":", index1 + 1);
+ int mi = Integer.parseInt(time.substring(0, index1));
+ int ss = Integer.parseInt(time.substring(index1 + 1, index2));
+ return mi * 60 + ss;
+ }
+
+
+
+ public static boolean isDate(String dateTimeStr, String formatStr) {
+ DateFormat df = getDateFormat(formatStr);
+ try {
+ df.parse(dateTimeStr);
+ return true;
+ } catch (Exception e) {
+ return false;
+ }
+ }
+
+ /**
+ * ���������������������������������
+ *
+ * @param strDate
+ * ������������ yyyy-MM-dd HH:mm:ss
+ * @param strDateBegin
+ * ������������ 00:00:00
+ * @param strDateEnd
+ * ������������ 00:05:00
+ * @return
+ */
+ public static boolean isInDate(String strDate, String strDateBegin, String strDateEnd) {
+ // ���������������������������
+ int strDateH = Integer.parseInt(strDate.substring(11, 13));
+ int strDateM = Integer.parseInt(strDate.substring(14, 16));
+ int strDateS = Integer.parseInt(strDate.substring(17, 19));
+ // ���������������������������
+ int strDateBeginH = Integer.parseInt(strDateBegin.substring(0, 2));
+ int strDateBeginM = Integer.parseInt(strDateBegin.substring(3, 5));
+ int strDateBeginS = Integer.parseInt(strDateBegin.substring(6, 8));
+ // ���������������������������
+ int strDateEndH = Integer.parseInt(strDateEnd.substring(0, 2));
+ int strDateEndM = Integer.parseInt(strDateEnd.substring(3, 5));
+ int strDateEndS = Integer.parseInt(strDateEnd.substring(6, 8));
+ if ((strDateH >= strDateBeginH && strDateH <= strDateEndH)) {
+ // ������������������������������������������������������������������
+ if (strDateH > strDateBeginH && strDateH < strDateEndH) {
+ return true;
+ // ������������������������������������������������������������������������������������
+ } else if (strDateH == strDateBeginH && strDateM >= strDateBeginM && strDateM <= strDateEndM) {
+ return true;
+ // ������������������������������������������������������������������������������������������������������������������������
+ } else if (strDateH == strDateBeginH && strDateM == strDateBeginM && strDateS >= strDateBeginS
+ && strDateS <= strDateEndS) {
+ return true;
+ }
+ // ���������������������������������������������������������������������������������������������������������������������������
+ else if (strDateH >= strDateBeginH && strDateH == strDateEndH && strDateM <= strDateEndM) {
+ return true;
+ // ������������������������������������������������������������������������������������������������������������������������������������������������������������
+ } else if (strDateH >= strDateBeginH && strDateH == strDateEndH && strDateM == strDateEndM
+ && strDateS <= strDateEndS) {
+ return true;
+ } else {
+ return false;
+ }
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * ���������������������������������
+ *
+ * @param date
+ * ������������ yyyy-MM-dd HH:mm:ss
+ * @param strDateBegin
+ * ������������ 00:00:00
+ * @param strDateEnd
+ * ������������ 00:05:00
+ * @return
+ */
+ public static boolean isInDate(Date date, String strDateBegin, String strDateEnd) {
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+ String strDate = sdf.format(date);
+ // ���������������������������
+ int strDateH = Integer.parseInt(strDate.substring(11, 13));
+ int strDateM = Integer.parseInt(strDate.substring(14, 16));
+ int strDateS = Integer.parseInt(strDate.substring(17, 19));
+ // ���������������������������
+ int strDateBeginH = Integer.parseInt(strDateBegin.substring(0, 2));
+ int strDateBeginM = Integer.parseInt(strDateBegin.substring(3, 5));
+ int strDateBeginS = Integer.parseInt(strDateBegin.substring(6, 8));
+ // ���������������������������
+ int strDateEndH = Integer.parseInt(strDateEnd.substring(0, 2));
+ int strDateEndM = Integer.parseInt(strDateEnd.substring(3, 5));
+ int strDateEndS = Integer.parseInt(strDateEnd.substring(6, 8));
+ if ((strDateH >= strDateBeginH && strDateH <= strDateEndH)) {
+ // ������������������������������������������������������������������
+ if (strDateH > strDateBeginH && strDateH < strDateEndH) {
+ return true;
+ // ������������������������������������������������������������������������������������
+ } else if (strDateH == strDateBeginH && strDateM >= strDateBeginM && strDateM <= strDateEndM) {
+ return true;
+ // ������������������������������������������������������������������������������������������������������������������������
+ } else if (strDateH == strDateBeginH && strDateM == strDateBeginM && strDateS >= strDateBeginS
+ && strDateS <= strDateEndS) {
+ return true;
+ }
+ // ���������������������������������������������������������������������������������������������������������������������������
+ else if (strDateH >= strDateBeginH && strDateH == strDateEndH && strDateM <= strDateEndM) {
+ return true;
+ // ������������������������������������������������������������������������������������������������������������������������������������������������������������
+ } else if (strDateH >= strDateBeginH && strDateH == strDateEndH && strDateM == strDateEndM
+ && strDateS <= strDateEndS) {
+ return true;
+ } else {
+ return false;
+ }
+ } else {
+ return false;
+ }
+ }
+
+ public static boolean isInTime(int time, int begin, int end) {
+ if (time >= begin && time < end) {
+ return true;
+ }
+ return false;
+ }
+
+ public static int getMinutest(String begin, String format) {
+ String nowMinutes = getCurDate("HH:mm");
+ long time = compareDateStr("09:00", nowMinutes, "HH:mm");
+ return (int) time;
+ }
+
+ /**
+ * <p>
+ * Title: addDays
+ * </p>
+ * <p>
+ * Description: ������������
+ * </p>
+ *
+ * @param days
+ * @return
+ */
+ public static Date addDays(Date date, int days) {
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTime(date);
+ calendar.add(Calendar.DATE, days);
+ return calendar.getTime();
+ }
+
+ /**
+ * <p>
+ * Title: addMonths
+ * </p>
+ * <p>
+ * Description: ������������
+ * </p>
+ *
+ * @param date
+ * @param months
+ * @return
+ */
+ public static Date addMonths(Date date, int months) {
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTime(date);
+ calendar.add(Calendar.MONTH, months);
+ return calendar.getTime();
+ }
+
+ /**
+ * <p>
+ * Title: getDays
+ * </p>
+ * <p>
+ * Description: ���������������������������������������
+ * </p>
+ *
+ * @param minDate
+ * @param maxDate
+ * @return
+ */
+ public static int getDays(Date minDate, Date maxDate) {
+ int days = 0;
+ if (null == minDate || null == maxDate)
+ return days;
+ days = (int) ((maxDate.getTime() - minDate.getTime()) / (24 * 60 * 60 * 1000));
+ return days;
+ }
+
+ /**
+ * ������������ date
+ *
+ * @param longDate ���������
+ * @return
+ */
+ public static Date getConversionDateByLong(long longDate) {
+ //1529398742830
+ ZoneId zid = ZoneId.systemDefault();
+ LocalDateTime time = LocalDateTime.ofInstant(Instant.ofEpochMilli(longDate), zid);
+ ZonedDateTime zdt = time.atZone(zid);
+ Date date = Date.from(zdt.toInstant());
+ return date;
+ }
+
+ /**
+ * yyyyMMdd ��� yyyy_MM_dd
+ *
+ * @param strData ���������
+ * @return
+ */
+ public static String getdatefor_yyyy_MM_dd(String strData) {
+ //1529398742830
+ //20180205
+ String yyyy_MM_dd="";
+ if (null == strData || strData.length()==0) {
+ return yyyy_MM_dd;
+ }else {
+ String yyyy = strData.substring(0, 4);
+ String mm = strData.substring(4, 6);
+ String dd = strData.substring(6, 8);
+ yyyy_MM_dd = yyyy+"-"+mm +"-"+dd;
+ }
+ return yyyy_MM_dd;
+ }
+
+ public static String getdatefor_HH_mm_ss(String strData) {
+ //1529398742830
+ //20180205
+ String HH_mm_ss="";
+ if (null == strData || strData.length()==0) {
+ return HH_mm_ss;
+ }else {
+ String HH = strData.substring(0, 2);
+ String mm = strData.substring(2, 4);
+ String ss = strData.substring(4, 6);
+ HH_mm_ss = HH+":"+mm +":"+ss;
+ }
+ return HH_mm_ss;
+ }
+
+ /**
+ * yyyyMMdd
+ *
+ * @return
+ */
+ public static String getdatefor_yyyyMMdd() {
+ Date newdate = new Date();
+ SimpleDateFormat dft = new SimpleDateFormat("yyyyMMdd");
+ String date = dft.format(newdate);
+ return date;
+ }
+
+ /**
+ * yyyyMMdd
+ *
+ * @return
+ */
+ public static String getdatefor_yyyy_MM_dd() {
+ Date newdate = new Date();
+ SimpleDateFormat dft = new SimpleDateFormat("yyyy-MM-dd");
+ String date = dft.format(newdate);
+ return date;
+ }
+
+
+
+ public static void main(String[] args) {
+ Date newdate = new Date();
+ SimpleDateFormat dft = new SimpleDateFormat("yyyyMMdd");
+ String date = dft.format(newdate);
+ System.out.println(date);
+// return endDate;
+ }
+}
diff --git a/screen-common/src/main/java/com/moral/util/PageResult.java b/screen-common/src/main/java/com/moral/util/PageResult.java
new file mode 100644
index 0000000..2bbc687
--- /dev/null
+++ b/screen-common/src/main/java/com/moral/util/PageResult.java
@@ -0,0 +1,34 @@
+package com.moral.util;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * ���������������
+ */
+@Data
+@ApiModel("���������������������")
+public class PageResult<T> {
+
+ @ApiModelProperty("���������")
+ private Long total;
+ @ApiModelProperty("���������")
+ private Long totalPage;
+ @ApiModelProperty("���������������")
+ private List<T> items;
+ public PageResult(Long total, List<T> items) {
+ this.total = total;
+ this.items = items;
+ }
+
+ public PageResult(Long total, Long totalPage, List<T> items) {
+ this.total = total;
+ this.totalPage = totalPage;
+ this.items = items;
+ }
+
+
+}
\ No newline at end of file
diff --git a/screen-common/src/main/java/com/moral/util/SpringContextUtils.java b/screen-common/src/main/java/com/moral/util/SpringContextUtils.java
new file mode 100644
index 0000000..8274ca7
--- /dev/null
+++ b/screen-common/src/main/java/com/moral/util/SpringContextUtils.java
@@ -0,0 +1,65 @@
+package com.moral.util;
+
+import org.springframework.beans.BeansException;
+import org.springframework.context.ApplicationContext;
+
+import java.lang.annotation.Annotation;
+import java.util.Map;
+
+
+public class SpringContextUtils {
+
+ private static ApplicationContext applicationContext;
+
+ public SpringContextUtils() {
+ }
+
+ /**
+ * ������applicationContext������
+ *
+ * @return
+ */
+ public static ApplicationContext getApplicationContext() {
+ return applicationContext;
+ }
+
+
+ public static void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
+ SpringContextUtils.applicationContext = applicationContext;
+ }
+
+
+ /**
+ * ������ bean ��� name ���������������
+ *
+ * @param beanName bean name
+ * @param <T>
+ * @return
+ */
+ @SuppressWarnings("unchecked")
+ public static <T> T getBeanByName(String beanName) {
+ return (T) applicationContext.getBean(beanName);
+ }
+
+
+ /**
+ * ������ bean ��� ������ ���������������
+ *
+ * @param requiredType
+ * @param <T>
+ * @return
+ */
+ @SuppressWarnings("unchecked")
+ public static <T> T getBeanByClass(Class<?> requiredType) {
+ return (T) applicationContext.getBean(requiredType);
+ }
+
+ public static <T> Map<String, T> getBeansByClass(Class<T> cls) {
+ return applicationContext.getBeansOfType(cls);
+ }
+
+ public static Map<String, Object> getBeansByAnnotation(Class<? extends Annotation> annotationCls) {
+ return applicationContext.getBeansWithAnnotation(annotationCls);
+ }
+
+}
diff --git a/screen-manage/pom.xml b/screen-manage/pom.xml
new file mode 100644
index 0000000..165d0b7
--- /dev/null
+++ b/screen-manage/pom.xml
@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <parent>
+ <artifactId>screen</artifactId>
+ <groupId>org.moral</groupId>
+ <version>1.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>screen-manage</artifactId>
+
+
+ <dependencies>
+ <dependency>
+ <groupId>org.moral</groupId>
+ <artifactId>screen-common</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <scope>compile</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <finalName>screen-manage</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-maven-plugin</artifactId>
+
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>${java.version}</source>
+ <target>${java.version}</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-resources-plugin</artifactId>
+ <version>${maven-resources-plugin.version}</version>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven.shared</groupId>
+ <artifactId>maven-filtering</artifactId>
+ <version>${maven-filtering.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.shared</groupId>
+ <artifactId>maven-common-artifact-filters</artifactId>
+ <version>${maven-common-artifact-filters.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.shared</groupId>
+ <artifactId>maven-dependency-tree</artifactId>
+ <version>${maven-dependency-tree.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.shared</groupId>
+ <artifactId>maven-shared-incremental</artifactId>
+ <version>${maven-shared-incremental.version}</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+
+ </plugins>
+ </build>
+
+
+
+</project>
\ No newline at end of file
diff --git a/screen-manage/src/main/java/com/moral/ScreenManageBootstrap.java b/screen-manage/src/main/java/com/moral/ScreenManageBootstrap.java
new file mode 100644
index 0000000..097d490
--- /dev/null
+++ b/screen-manage/src/main/java/com/moral/ScreenManageBootstrap.java
@@ -0,0 +1,42 @@
+package com.moral;
+
+
+import com.moral.util.SpringContextUtils;
+import org.mybatis.spring.annotation.MapperScan;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.web.servlet.FilterRegistrationBean;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.annotation.Bean;
+import org.springframework.transaction.annotation.EnableTransactionManagement;
+import org.springframework.web.cors.CorsConfiguration;
+import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
+import org.springframework.web.filter.CorsFilter;
+
+import java.util.Arrays;
+
+
+@MapperScan("com.moral.api.mapper")
+@EnableTransactionManagement
+@SpringBootApplication
+public class ScreenManageBootstrap {
+ public static void main(String[] args) {
+ ApplicationContext applicationContext = SpringApplication.run(ScreenManageBootstrap.class, args);
+ SpringContextUtils.setApplicationContext(applicationContext);
+ }
+ @Bean
+ public FilterRegistrationBean<CorsFilter> corsFilter() {
+ FilterRegistrationBean<CorsFilter> corsFilterFilterRegistrationBean = new FilterRegistrationBean<>();
+ UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
+ CorsConfiguration corsConfiguration = new CorsConfiguration();
+ corsConfiguration.addAllowedHeader("*");
+ corsConfiguration.addAllowedOrigin("*");
+ corsConfiguration.setAllowedMethods(Arrays.asList("POST", "PUT", "GET", "OPTIONS", "DELETE"));
+ corsConfiguration.setAllowCredentials(true);
+ corsConfiguration.setMaxAge(3600L);
+ source.registerCorsConfiguration("/**", corsConfiguration);
+ corsFilterFilterRegistrationBean.setFilter(new CorsFilter(source));
+ corsFilterFilterRegistrationBean.setOrder(-1);
+ return corsFilterFilterRegistrationBean;
+ }
+}
diff --git a/screen-manage/src/main/java/com/moral/api/Swagger2.java b/screen-manage/src/main/java/com/moral/api/Swagger2.java
new file mode 100644
index 0000000..90bb77e
--- /dev/null
+++ b/screen-manage/src/main/java/com/moral/api/Swagger2.java
@@ -0,0 +1,34 @@
+package com.moral.api;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import springfox.documentation.builders.ApiInfoBuilder;
+import springfox.documentation.builders.PathSelectors;
+import springfox.documentation.builders.RequestHandlerSelectors;
+import springfox.documentation.service.ApiInfo;
+import springfox.documentation.spi.DocumentationType;
+import springfox.documentation.spring.web.plugins.Docket;
+import springfox.documentation.swagger2.annotations.EnableSwagger2;
+
+
+@Configuration
+@EnableSwagger2
+public class Swagger2 {
+ @Bean
+ public Docket petApi() {
+ return new Docket(DocumentationType.SWAGGER_2)
+ .apiInfo(apiInfo())
+ .select()
+ .apis(RequestHandlerSelectors.basePackage("com.moral.api"))
+ .paths(PathSelectors.any())
+ .build();
+ }
+ private ApiInfo apiInfo() {
+ return new ApiInfoBuilder()
+ .title("������������������������")
+ .description("������������������������")
+ .version("1.0")
+ .build();
+ }
+
+}
diff --git a/screen-manage/src/main/java/com/moral/api/config/datasource/DataSourceConfig.java b/screen-manage/src/main/java/com/moral/api/config/datasource/DataSourceConfig.java
new file mode 100644
index 0000000..9a85aa8
--- /dev/null
+++ b/screen-manage/src/main/java/com/moral/api/config/datasource/DataSourceConfig.java
@@ -0,0 +1,23 @@
+package com.moral.api.config.datasource;
+
+import com.alibaba.druid.pool.DruidDataSource;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Primary;
+
+import javax.sql.DataSource;
+
+
+@Configuration
+public class DataSourceConfig {
+
+ @Primary
+ @Bean(name = "primaryDataSource")
+ @Qualifier("primaryDataSource")
+ @ConfigurationProperties(prefix = "spring.datasource")
+ public DataSource primaryDataSource(){
+ return new DruidDataSource();
+ }
+}
diff --git a/screen-manage/src/main/java/com/moral/api/config/kafka/KafkaConsumerConfig.java b/screen-manage/src/main/java/com/moral/api/config/kafka/KafkaConsumerConfig.java
new file mode 100644
index 0000000..e5ae67b
--- /dev/null
+++ b/screen-manage/src/main/java/com/moral/api/config/kafka/KafkaConsumerConfig.java
@@ -0,0 +1,67 @@
+package com.moral.api.config.kafka;
+
+import org.apache.kafka.clients.consumer.ConsumerConfig;
+import org.apache.kafka.common.serialization.StringDeserializer;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.kafka.annotation.EnableKafka;
+import org.springframework.kafka.config.ConcurrentKafkaListenerContainerFactory;
+import org.springframework.kafka.config.KafkaListenerContainerFactory;
+import org.springframework.kafka.core.ConsumerFactory;
+import org.springframework.kafka.core.DefaultKafkaConsumerFactory;
+import org.springframework.kafka.listener.ConcurrentMessageListenerContainer;
+import org.springframework.kafka.listener.ContainerProperties;
+import java.util.HashMap;
+import java.util.Map;
+
+/*@Configuration
+@EnableKafka*/
+public class KafkaConsumerConfig {
+ @Value("${kafka.consumer.servers}")
+ private String servers;
+ @Value("${kafka.consumer.enable.auto.commit}")
+ private boolean enableAutoCommit;
+ @Value("${kafka.consumer.session.timeout}")
+ private String sessionTimeout;
+ @Value("${kafka.consumer.auto.commit.interval}")
+ private String autoCommitInterval;
+ @Value("${kafka.consumer.group.id}")
+ private String groupId;
+ @Value("${kafka.consumer.auto.offset.reset}")
+ private String autoOffsetReset;
+ @Value("${kafka.consumer.concurrency}")
+ private int concurrency;
+
+ @Bean
+ public KafkaListenerContainerFactory<ConcurrentMessageListenerContainer<String, String>> kafkaListenerContainerFactory() {
+ ConcurrentKafkaListenerContainerFactory<String, String> factory = new ConcurrentKafkaListenerContainerFactory<>();
+ factory.setConsumerFactory(consumerFactory());
+ factory.setConcurrency(concurrency);
+ factory.getContainerProperties().setPollTimeout(1500);
+ factory.getContainerProperties().setAckMode(ContainerProperties.AckMode.MANUAL_IMMEDIATE);
+
+ /*factory.setBatchListener(true);//@KafkaListener ������������ ���������������������Kafka���������������������ConsumerConfig.MAX_POLL_RECORDS_CONFIG
+ factory.getContainerProperties().setAckMode(ContainerProperties.AckMode.MANUAL_IMMEDIATE);//������������������������������*/
+ return factory;
+ }
+
+ public ConsumerFactory<String, String> consumerFactory() {
+ return new DefaultKafkaConsumerFactory<>(consumerConfigs());
+ }
+
+
+ public Map<String, Object> consumerConfigs() {
+ Map<String, Object> propsMap = new HashMap<>();
+ propsMap.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, servers);
+ propsMap.put(ConsumerConfig.ENABLE_AUTO_COMMIT_CONFIG, enableAutoCommit);
+ propsMap.put(ConsumerConfig.AUTO_COMMIT_INTERVAL_MS_CONFIG, autoCommitInterval);
+ propsMap.put(ConsumerConfig.SESSION_TIMEOUT_MS_CONFIG, sessionTimeout);
+ propsMap.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class);
+ propsMap.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class);
+ propsMap.put(ConsumerConfig.GROUP_ID_CONFIG, groupId);
+ propsMap.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, autoOffsetReset);
+ return propsMap;
+ }
+}
diff --git a/screen-manage/src/main/java/com/moral/api/config/kafka/KafkaProducerConfig.java b/screen-manage/src/main/java/com/moral/api/config/kafka/KafkaProducerConfig.java
new file mode 100644
index 0000000..ef5b141
--- /dev/null
+++ b/screen-manage/src/main/java/com/moral/api/config/kafka/KafkaProducerConfig.java
@@ -0,0 +1,55 @@
+package com.moral.api.config.kafka;
+
+import org.apache.kafka.clients.producer.ProducerConfig;
+import org.apache.kafka.common.serialization.StringSerializer;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.kafka.annotation.EnableKafka;
+import org.springframework.kafka.core.DefaultKafkaProducerFactory;
+import org.springframework.kafka.core.KafkaTemplate;
+import org.springframework.kafka.core.ProducerFactory;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/*@Configuration
+@EnableKafka*/
+public class KafkaProducerConfig {
+ @Value("${kafka.producer.servers}")
+ private String servers;
+ @Value("${kafka.producer.retries}")
+ private int retries;
+ @Value("${kafka.producer.batch.size}")
+ private int batchSize;
+ @Value("${kafka.producer.linger}")
+ private int linger;
+ @Value("${kafka.producer.buffer.memory}")
+ private int bufferMemory;
+
+
+ public Map<String, Object> producerConfigs() {
+ Map<String, Object> props = new HashMap<>();
+ props.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, servers);
+ props.put(ProducerConfig.RETRIES_CONFIG, retries);
+ props.put(ProducerConfig.BATCH_SIZE_CONFIG, batchSize);
+ props.put(ProducerConfig.LINGER_MS_CONFIG, linger);
+ props.put(ProducerConfig.BUFFER_MEMORY_CONFIG, bufferMemory);
+ props.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class);
+ props.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, StringSerializer.class);
+ return props;
+ }
+
+ public ProducerFactory<String, String> producerFactory() {
+ return new DefaultKafkaProducerFactory<>(producerConfigs());
+ }
+
+ @Bean
+ public KafkaTemplate<String, String> kafkaTemplate() {
+ return new KafkaTemplate<String, String>(producerFactory());
+ }
+
+}
+
+
+
diff --git a/screen-manage/src/main/java/com/moral/api/config/mybatis/MybatisPlusConfig.java b/screen-manage/src/main/java/com/moral/api/config/mybatis/MybatisPlusConfig.java
new file mode 100644
index 0000000..4a253f7
--- /dev/null
+++ b/screen-manage/src/main/java/com/moral/api/config/mybatis/MybatisPlusConfig.java
@@ -0,0 +1,22 @@
+package com.moral.api.config.mybatis;
+
+import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+
+
+@Configuration
+public class MybatisPlusConfig {
+
+ /**
+ * ������������
+ */
+ @Bean
+ public PaginationInterceptor paginationInterceptor() {
+ PaginationInterceptor page = new PaginationInterceptor();
+ return page;
+ }
+
+
+}
diff --git a/screen-manage/src/main/java/com/moral/api/config/redis/RedisConfig.java b/screen-manage/src/main/java/com/moral/api/config/redis/RedisConfig.java
new file mode 100644
index 0000000..b63690d
--- /dev/null
+++ b/screen-manage/src/main/java/com/moral/api/config/redis/RedisConfig.java
@@ -0,0 +1,42 @@
+package com.moral.api.config.redis;
+
+import com.fasterxml.jackson.annotation.JsonAutoDetect;
+import com.fasterxml.jackson.annotation.PropertyAccessor;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.data.redis.connection.RedisConnectionFactory;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.data.redis.core.StringRedisTemplate;
+import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
+import org.springframework.data.redis.serializer.StringRedisSerializer;
+
+
+@Configuration
+public class RedisConfig {
+
+ @Bean(name="redisTemplate")
+ @ConditionalOnMissingBean(StringRedisTemplate.class) //������������������ ���������������������RedisTemplate ������������ ������������������
+ public RedisTemplate<String,Object> stringRedisTemplate(RedisConnectionFactory redisConnectionFactory) {
+ RedisTemplate<String, Object> redisTemplate = new RedisTemplate<String, Object>();
+ redisTemplate.setConnectionFactory(redisConnectionFactory);
+ Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class);
+ ObjectMapper objectMapper = new ObjectMapper();
+ objectMapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
+ objectMapper.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
+ jackson2JsonRedisSerializer.setObjectMapper(objectMapper);
+ StringRedisSerializer stringRedisSerializer = new StringRedisSerializer();
+ // key������String������������������
+ redisTemplate.setKeySerializer(stringRedisSerializer);
+ // hash���key���������String������������������
+ redisTemplate.setHashKeySerializer(stringRedisSerializer);
+ // valuevalue������jackson���������������
+ redisTemplate.setValueSerializer(jackson2JsonRedisSerializer);
+ // hash���value������jackson���������������
+ redisTemplate.setHashValueSerializer(jackson2JsonRedisSerializer);
+ redisTemplate.afterPropertiesSet();
+ redisTemplate.afterPropertiesSet();
+ return redisTemplate;
+ }
+}
diff --git a/screen-manage/src/main/java/com/moral/api/constant/TopicConstants.java b/screen-manage/src/main/java/com/moral/api/constant/TopicConstants.java
new file mode 100644
index 0000000..770d60e
--- /dev/null
+++ b/screen-manage/src/main/java/com/moral/api/constant/TopicConstants.java
@@ -0,0 +1,11 @@
+package com.moral.api.constant;
+
+public class TopicConstants {
+ /**
+ * Test ������
+ */
+ public static final String TEST_TOPIC_MESSAGE = "test_topic";
+
+
+
+}
diff --git a/screen-manage/src/main/java/com/moral/api/controller/TestController.java b/screen-manage/src/main/java/com/moral/api/controller/TestController.java
new file mode 100644
index 0000000..8a437f5
--- /dev/null
+++ b/screen-manage/src/main/java/com/moral/api/controller/TestController.java
@@ -0,0 +1,99 @@
+package com.moral.api.controller;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.moral.api.entity.Test;
+import com.moral.api.service.TestService;
+import com.moral.constant.ResultMessage;
+import com.moral.redis.RedisUtil;
+import com.moral.util.PageResult;
+import io.swagger.annotations.*;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.kafka.core.KafkaTemplate;
+import org.springframework.web.bind.annotation.*;
+
+
+@Slf4j
+@Api(tags = {"������������"})
+@RestController
+@RequestMapping("/manage")
+public class TestController {
+
+ @Autowired
+ private KafkaTemplate kafkaTemplate;
+
+ @Autowired
+ private TestService testService;
+ /**
+ * name ������
+ * email ������
+ * mobile ���������
+ */
+ @ApiOperation(value = "������������", notes = "������������")
+ @RequestMapping(value = "/saveTest", method = RequestMethod.POST)
+ public ResultMessage save() {
+
+ Test test=new Test();
+ test.setEmail("test@qq.com");
+ test.setName("name");
+ test.setMobile("13965898745");
+ testService.save(test);
+ return ResultMessage.ok();
+
+ }
+ /**
+ * page ���������
+ * size ������������
+ */
+ @ApiOperation(value = "������", notes = "������")
+ @ApiImplicitParams({
+ @ApiImplicitParam(name="page",value="������������",required=true,paramType="path",dataType="Int"),
+ @ApiImplicitParam(name="size",value="������������",required=true,paramType="path",dataType="Int")
+ })
+ @RequestMapping(value = "search/{page}/{size}", method = RequestMethod.GET)
+ public ResultMessage findBypage(@PathVariable("page") Integer page, @PathVariable("size") Integer size) {
+
+ log.info("page is:"+ page+" size is:"+size);
+ //������������������������
+ Page<Test> userPage = testService.selectByPage(null, page, size);
+ //������������������������
+ PageResult<Test> pageResult = new PageResult<>(
+ userPage.getTotal(), userPage.getPages(),userPage.getRecords()
+ );
+ //������������
+ return ResultMessage.ok(pageResult);
+ }
+
+
+ /**
+ * redis������
+ */
+ @ApiOperation(value = "redis������", notes = "redis������")
+ @RequestMapping(value = "redis", method = RequestMethod.GET)
+ public ResultMessage testRedis() {
+ RedisUtil.set("redistest","test");
+ return ResultMessage.ok(RedisUtil.get("redistest"));
+
+ }
+
+ /**
+ * ������
+ */
+ @ApiOperation(value = "������������", notes = "������������")
+ @RequestMapping(value = "saveTest", method = RequestMethod.GET)
+ public ResultMessage saveTest() throws Exception{
+ testService.saveTest();
+ return ResultMessage.ok();
+
+ }
+
+ /**
+ * kafka������
+ */
+ @ApiOperation(value = "kafka������", notes = "kafka������")
+ @RequestMapping(value = "kafkaTest", method = RequestMethod.GET)
+ public void kafkaTest() {
+ kafkaTemplate.send("test_topic","test111111111111111");
+ }
+
+}
diff --git a/screen-manage/src/main/java/com/moral/api/entity/Test.java b/screen-manage/src/main/java/com/moral/api/entity/Test.java
new file mode 100644
index 0000000..05ff045
--- /dev/null
+++ b/screen-manage/src/main/java/com/moral/api/entity/Test.java
@@ -0,0 +1,51 @@
+package com.moral.api.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.extension.activerecord.Model;
+import com.baomidou.mybatisplus.annotation.TableId;
+import java.io.Serializable;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * <p>
+ *
+ * </p>
+ *
+ * @author moral
+ * @since 2021-03-01
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+public class Test extends Model<Test> {
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * ������
+ */
+ @TableId(value = "id", type = IdType.AUTO)
+ private Integer id;
+
+ /**
+ * ������
+ */
+ private String name;
+
+ /**
+ * ������
+ */
+ private String email;
+
+ /**
+ * ���������
+ */
+ private String mobile;
+
+
+ @Override
+ protected Serializable pkVal() {
+ return this.id;
+ }
+
+}
diff --git a/screen-manage/src/main/java/com/moral/api/exception/BusinessException.java b/screen-manage/src/main/java/com/moral/api/exception/BusinessException.java
new file mode 100644
index 0000000..1b289fc
--- /dev/null
+++ b/screen-manage/src/main/java/com/moral/api/exception/BusinessException.java
@@ -0,0 +1,72 @@
+package com.moral.api.exception;
+
+/**
+ * @author
+ * @site
+ * @company
+ * @create 2021-02-26 11:20
+ */
+public class BusinessException extends RuntimeException {
+
+ /**
+ * ���������
+ */
+ private String code;
+
+ /**
+ * ������������
+ */
+ private String msg;
+
+ /** */
+ private static final long serialVersionUID = 1L;
+
+ public BusinessException() {
+ super();
+ }
+
+ public BusinessException(String msg) {
+ super(msg);
+ this.msg = msg;
+ }
+
+ public BusinessException(Throwable t) {
+ super(t);
+ }
+
+ public BusinessException(String msg, Throwable t) {
+ super(msg);
+ this.msg = msg;
+ }
+
+ public BusinessException(String code, String msg) {
+ super(msg);
+ this.code = code;
+ this.msg = msg;
+ }
+
+ public BusinessException(String code, String msg, Throwable t) {
+ super(msg, t);
+ this.code = code;
+ this.msg = msg;
+ }
+
+ /**
+ * Getter method for property <tt>code</tt>.
+ *
+ * @return property value of code
+ */
+ public String getCode() {
+ return code;
+ }
+
+ /**
+ * Getter method for property <tt>msg</tt>.
+ *
+ * @return property value of msg
+ */
+ public String getMsg() {
+ return msg;
+ }
+
+}
diff --git a/screen-manage/src/main/java/com/moral/api/exception/GlobalExceptionHandler.java b/screen-manage/src/main/java/com/moral/api/exception/GlobalExceptionHandler.java
new file mode 100644
index 0000000..f9293f8
--- /dev/null
+++ b/screen-manage/src/main/java/com/moral/api/exception/GlobalExceptionHandler.java
@@ -0,0 +1,35 @@
+package com.moral.api.exception;
+
+import com.moral.constant.Constants;
+import com.moral.constant.ResultMessage;
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.ControllerAdvice;
+import org.springframework.web.bind.annotation.ExceptionHandler;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.ResponseStatus;
+
+
+@ControllerAdvice
+@ResponseBody
+public class GlobalExceptionHandler {
+ /**
+ * ������������������
+ */
+ @ExceptionHandler
+ @ResponseBody
+ @ResponseStatus(HttpStatus.OK)
+ public ResultMessage handleException(Exception ex) {
+ return ResultMessage.fail(Constants.CODE_OPERATION_FAILED, "������������");
+ }
+
+ /**
+ * ������BusinessException������
+ */
+ @ExceptionHandler({BusinessException.class})
+ @ResponseBody
+ @ResponseStatus(HttpStatus.OK)
+ public ResultMessage handleUserNotExistException(BusinessException ex) {
+ return ResultMessage.fail(Constants.CODE_OPERATION_FAILED, "������������������������");
+ }
+
+}
diff --git a/screen-manage/src/main/java/com/moral/api/kafka/consumer/KafkaConsumer.java b/screen-manage/src/main/java/com/moral/api/kafka/consumer/KafkaConsumer.java
new file mode 100644
index 0000000..af6c8cc
--- /dev/null
+++ b/screen-manage/src/main/java/com/moral/api/kafka/consumer/KafkaConsumer.java
@@ -0,0 +1,37 @@
+package com.moral.api.kafka.consumer;
+
+import com.moral.api.constant.TopicConstants;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.kafka.clients.consumer.ConsumerRecord;
+import org.springframework.kafka.annotation.KafkaListener;
+import org.springframework.kafka.support.Acknowledgment;
+import org.springframework.stereotype.Component;
+
+import java.util.Random;
+
+@Component
+@Slf4j
+public class KafkaConsumer {
+
+/* *//**
+ * ���������������������������������
+ * @param record
+ * @param ack
+ * @throws Exception
+ *//*
+ @KafkaListener(topics = TopicConstants.TEST_TOPIC_MESSAGE,groupId = "test")
+ public void listenTest(ConsumerRecord<String, String> record , Acknowledgment ack) throws Exception {
+ String msg = record.value();
+ System.out.println(msg);
+ if (new Random().nextInt(100)<50){
+ log.info(String.format("kafka ������������������---------------- listen1 topic = %s, offset = %d, value = %s ", record.topic(), record.offset(), record.value()));
+ ack.acknowledge();
+ }
+
+ }*/
+
+
+
+
+
+}
diff --git a/screen-manage/src/main/java/com/moral/api/mapper/TestMapper.java b/screen-manage/src/main/java/com/moral/api/mapper/TestMapper.java
new file mode 100644
index 0000000..46e1799
--- /dev/null
+++ b/screen-manage/src/main/java/com/moral/api/mapper/TestMapper.java
@@ -0,0 +1,16 @@
+package com.moral.api.mapper;
+
+import com.moral.api.entity.Test;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * <p>
+ * Mapper ������
+ * </p>
+ *
+ * @author moral
+ * @since 2021-02-25
+ */
+public interface TestMapper extends BaseMapper<Test> {
+
+}
diff --git a/screen-manage/src/main/java/com/moral/api/service/TestService.java b/screen-manage/src/main/java/com/moral/api/service/TestService.java
new file mode 100644
index 0000000..5ab915b
--- /dev/null
+++ b/screen-manage/src/main/java/com/moral/api/service/TestService.java
@@ -0,0 +1,24 @@
+package com.moral.api.service;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.moral.api.entity.Test;
+import com.baomidou.mybatisplus.extension.service.IService;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+/**
+ * <p>
+ * ���������
+ * </p>
+ *
+ * @author moral
+ * @since 2021-02-25
+ */
+@Service
+@Transactional
+public interface TestService extends IService<Test> {
+
+ Page<Test> selectByPage(Test test, Integer page, Integer size);
+
+ void saveTest() throws Exception;
+}
diff --git a/screen-manage/src/main/java/com/moral/api/service/impl/TestServiceImpl.java b/screen-manage/src/main/java/com/moral/api/service/impl/TestServiceImpl.java
new file mode 100644
index 0000000..50040a8
--- /dev/null
+++ b/screen-manage/src/main/java/com/moral/api/service/impl/TestServiceImpl.java
@@ -0,0 +1,52 @@
+package com.moral.api.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.moral.api.entity.Test;
+import com.moral.api.exception.BusinessException;
+import com.moral.api.mapper.TestMapper;
+import com.moral.api.service.TestService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+/**
+ * <p>
+ * ���������������
+ * </p>
+ *
+ * @author moral
+ * @since 2021-02-25
+ */
+@Service
+public class TestServiceImpl extends ServiceImpl<TestMapper, Test> implements TestService {
+
+ @Autowired
+ private TestMapper testMapper;
+ @Override
+ public Page<Test> selectByPage(Test test, Integer page, Integer size) {
+ //������������������
+ Page<Test> pageData = new Page<>(page, size);
+ //������������������
+ IPage<Test> users = testMapper.selectPage(pageData, new QueryWrapper<>(test));
+ //���������������������������������
+ pageData.setRecords(users.getRecords());
+ //������������
+ return pageData;
+ }
+
+ @Override
+ public void saveTest() throws Exception{
+ Test t=new Test();
+ t.setName("aaaa");
+ t.setMobile("139652555");
+ t.setEmail("33@qq.com");
+ testMapper.insert(t);
+ if ("aaaa".equals(t.getName())){
+ throw new BusinessException("aaaa���������������������������������");
+ }
+
+ }
+}
diff --git a/screen-manage/src/main/resources/application-dev.yml b/screen-manage/src/main/resources/application-dev.yml
new file mode 100644
index 0000000..ac59da8
--- /dev/null
+++ b/screen-manage/src/main/resources/application-dev.yml
@@ -0,0 +1,101 @@
+server:
+ port: 8082
+ tomcat:
+ uri-encoding: UTF-8
+ #���������������
+ min-spare-threads: 500
+ #���������������
+ max-threads: 2500
+ #���������������
+ max-connections: 6500
+ #������������������������
+ accept-count: 1000
+spring:
+ profiles:
+ active: dev
+ application:
+ name: screen-manage
+ redis:
+ #cluster:
+ #nodes: 47.112.126.78:7001,47.112.126.78:7002,47.112.126.132:7003,47.112.126.132:7004,47.112.132.193:7005,47.112.132.193:7006
+ #password: test
+ #timeout: 500
+ host: 127.0.0.1
+ port: 6379
+ password: 123456
+ timeout: 30000
+ jedis:
+ pool:
+ max-active: 256
+ max-wait: 30000
+ max-idle: 64
+ min-idle: 32
+ lettuce:
+ pool:
+ max-active: 256
+ max-idle: 64
+ max-wait: 30000
+ min-idle: 32
+ datasource:
+ minIdle: 1
+ time-between-eviction-runs-millis: 60000
+ max-active: 20
+ test-while-idle: true
+ validation-query: select 'x'
+ filters: stat
+ type: com.alibaba.druid.pool.DruidDataSource
+ max-wait: 60000
+ url: jdbc:mysql://192.168.0.18:4000/test?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=UTC
+ password: 123456
+ test-on-borrow: false
+ sql-script-encoding: utf-8
+ pool-prepared-statements: true
+ min-evictable-idle-time-millis: 300000
+ initial-size: 1
+ driver-class-name: com.mysql.cj.jdbc.Driver
+ max-conn-lifetime-millis: 20
+ test-on-return: false
+ username: root
+
+mybatis-plus:
+ mapper-locations: classpath:mapper/*.xml
+ global-config:
+ db-config:
+ id-type: auto
+ field-strategy: NOT_EMPTY
+ db-type: MYSQL
+ configuration:
+ map-underscore-to-camel-case: true
+ call-setters-on-nulls: true
+ log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
+
+kafka:
+ listener:
+ ack-mode: manual_immediate
+ consumer:
+ auto:
+ commit:
+ interval: 100
+ offset:
+ reset: latest
+ concurrency: 3
+ enable:
+ auto:
+ commit: false
+ group:
+ id: test
+ servers: 192.168.0.16:9092,192.168.0.17:9092,192.168.0.18:9092
+ session:
+ timeout: 6000
+ topic: test_topic
+ zookeeper:
+ connect: 192.168.0.16:2181,192.168.0.17:2181,192.168.0.18:2181
+ producer:
+ batch:
+ size: 4096
+ buffer:
+ memory: 40960
+ linger: 1
+ retries: 0
+ servers: 192.168.0.16:9092,192.168.0.17:9092,192.168.0.18:9092
+
diff --git a/screen-manage/src/main/resources/logback-spring.xml b/screen-manage/src/main/resources/logback-spring.xml
new file mode 100644
index 0000000..9936d12
--- /dev/null
+++ b/screen-manage/src/main/resources/logback-spring.xml
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<configuration>
+ <include resource="org/springframework/boot/logging/logback/defaults.xml"/>
+
+ <springProperty scope="context" name="springAppName" source="spring.application.name"/>
+ <!-- ��������������������������������� -->
+ <property name="LOG_FILE" value="/home/moral/soft/log/${springAppName}"/>
+ <!-- ������������������������������ -->
+ <property name="CONSOLE_LOG_PATTERN"
+ value="%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}) [%X{logseq}]{faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr([${springAppName}]){yellow} %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}"/>
+
+ <property name="FILE_LOG_PATTERN"
+ value="%d{yyyy-MM-dd HH:mm:ss.SSS} [%X{logseq}] [%thread] %X{T} [%level] %logger.%method:%line %msg%n"/>
+
+ <!-- ���������Appender -->
+ <appender name="console" class="ch.qos.logback.core.ConsoleAppender">
+ <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
+ <level>INFO</level>
+ </filter>
+ <encoder>
+ <pattern>${CONSOLE_LOG_PATTERN}</pattern>
+ <charset>utf8</charset>
+ </encoder>
+ </appender>
+ <!-- ������������Appender -->
+ <appender name="screenManageLog" class="ch.qos.logback.classic.sift.SiftingAppender">
+ <discriminator>
+ <key>taskId</key>
+ <defaultValue>default</defaultValue>
+ </discriminator>
+ <sift>
+ <appender name="file" class="ch.qos.logback.core.rolling.RollingFileAppender">
+
+ <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
+ <level>INFO</level>
+ </filter>
+ <file>${LOG_FILE}/%d{yyyy-MM-dd}/${springAppName}.log</file>
+ <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
+ <maxFileSize>30MB</maxFileSize>
+ <fileNamePattern>${LOG_FILE}/%d{yyyy-MM-dd}/${springAppName}-%d{yyyy-MM-dd}.log%i.log</fileNamePattern>
+ <maxHistory>30</maxHistory>
+ </rollingPolicy>
+ <encoder>
+ <pattern>${FILE_LOG_PATTERN}</pattern>
+ <charset>utf8</charset>
+ </encoder>
+ </appender>
+ </sift>
+ </appender>
+
+
+ <root level="INFO">
+ <appender-ref ref="console"/>
+ <appender-ref ref="screenManageLog"/>
+ </root>
+</configuration>
--
Gitblit v1.8.0