Merge branch 'master' into '1.0.0'
init See merge request duoji/backend-duoji-monitor!2camera_merge
commit
cb76c67b3d
@ -0,0 +1 @@
|
|||||||
|
springbootstart
|
||||||
@ -0,0 +1,21 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="CompilerConfiguration">
|
||||||
|
<annotationProcessing>
|
||||||
|
<profile name="Maven default annotation processors profile" enabled="true">
|
||||||
|
<sourceOutputDir name="target/generated-sources/annotations" />
|
||||||
|
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
||||||
|
<outputRelativeToContentRoot value="true" />
|
||||||
|
<module name="common" />
|
||||||
|
<module name="filter" />
|
||||||
|
<module name="springbootstart-web" />
|
||||||
|
</profile>
|
||||||
|
</annotationProcessing>
|
||||||
|
</component>
|
||||||
|
<component name="JavacSettings">
|
||||||
|
<option name="ADDITIONAL_OPTIONS_OVERRIDE">
|
||||||
|
<module name="filter" options="-parameters" />
|
||||||
|
<module name="springbootstart-web" options="-parameters" />
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="Encoding" addBOMForNewFiles="with NO BOM">
|
||||||
|
<file url="file://$PROJECT_DIR$" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/modules" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/modules/common" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/modules/filter" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/web" charset="UTF-8" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
@ -0,0 +1,40 @@
|
|||||||
|
<component name="InspectionProjectProfileManager">
|
||||||
|
<profile version="1.0">
|
||||||
|
<option name="myName" value="Project Default" />
|
||||||
|
<inspection_tool class="JavaDoc" enabled="true" level="WARNING" enabled_by_default="true">
|
||||||
|
<option name="TOP_LEVEL_CLASS_OPTIONS">
|
||||||
|
<value>
|
||||||
|
<option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" />
|
||||||
|
<option name="REQUIRED_TAGS" value="" />
|
||||||
|
</value>
|
||||||
|
</option>
|
||||||
|
<option name="INNER_CLASS_OPTIONS">
|
||||||
|
<value>
|
||||||
|
<option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" />
|
||||||
|
<option name="REQUIRED_TAGS" value="" />
|
||||||
|
</value>
|
||||||
|
</option>
|
||||||
|
<option name="METHOD_OPTIONS">
|
||||||
|
<value>
|
||||||
|
<option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" />
|
||||||
|
<option name="REQUIRED_TAGS" value="@return@param@throws or @exception" />
|
||||||
|
</value>
|
||||||
|
</option>
|
||||||
|
<option name="FIELD_OPTIONS">
|
||||||
|
<value>
|
||||||
|
<option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" />
|
||||||
|
<option name="REQUIRED_TAGS" value="" />
|
||||||
|
</value>
|
||||||
|
</option>
|
||||||
|
<option name="IGNORE_DEPRECATED" value="false" />
|
||||||
|
<option name="IGNORE_JAVADOC_PERIOD" value="true" />
|
||||||
|
<option name="IGNORE_DUPLICATED_THROWS" value="false" />
|
||||||
|
<option name="IGNORE_POINT_TO_ITSELF" value="false" />
|
||||||
|
<option name="myAdditionalJavadocTags" value="date" />
|
||||||
|
</inspection_tool>
|
||||||
|
<inspection_tool class="SerializableHasSerialVersionUIDField" enabled="true" level="WARNING" enabled_by_default="true">
|
||||||
|
<option name="ignoreAnonymousInnerClasses" value="false" />
|
||||||
|
<option name="superClassString" value="java.awt.Component" />
|
||||||
|
</inspection_tool>
|
||||||
|
</profile>
|
||||||
|
</component>
|
||||||
@ -0,0 +1,14 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||||
|
<component name="MavenProjectsManager">
|
||||||
|
<option name="originalFiles">
|
||||||
|
<list>
|
||||||
|
<option value="$PROJECT_DIR$/pom.xml" />
|
||||||
|
</list>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||||
|
<output url="file://$PROJECT_DIR$/out" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
@ -0,0 +1,28 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
PWD=$(cd `dirname $0`;pwd);
|
||||||
|
TARGET='test'
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
help() {
|
||||||
|
echo "Usage: $1 IMAGE."
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ $# -lt 1 ];then
|
||||||
|
help $0
|
||||||
|
fi
|
||||||
|
|
||||||
|
IMAGE=$1
|
||||||
|
|
||||||
|
if [ $# -ge 2 ];then
|
||||||
|
TARGET=$2
|
||||||
|
fi
|
||||||
|
|
||||||
|
cd $PWD/..
|
||||||
|
|
||||||
|
mvn clean package -P $TARGET
|
||||||
|
cp web/target/springbootstart-web-1.0.0.jar docker/springbootstart-1.0.0.jar
|
||||||
|
|
||||||
|
docker build -t $IMAGE docker
|
||||||
@ -0,0 +1,46 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
PWD=$(cd `dirname $0`;pwd);
|
||||||
|
|
||||||
|
IMG_NAME="springbootstart"
|
||||||
|
IMG_VER='1.0.1'
|
||||||
|
PORT=8090
|
||||||
|
|
||||||
|
if [ $# -gt 1 ];then
|
||||||
|
PORT=$2
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ $# -gt 2 ];then
|
||||||
|
IMG_VER=$3
|
||||||
|
fi
|
||||||
|
|
||||||
|
NAME="springbootstart-$IMG_VER"
|
||||||
|
|
||||||
|
run() {
|
||||||
|
echo "docker run --restart=on-failure:10 --name $NAME -d -p$PORT:8080 ${IMG_NAME}:${IMG_VER}"
|
||||||
|
docker run --restart=on-failure:10 --name $NAME -d -p$PORT:8080 ${IMG_NAME}:${IMG_VER}
|
||||||
|
}
|
||||||
|
|
||||||
|
case $1 in
|
||||||
|
start)
|
||||||
|
docker start $NAME
|
||||||
|
exit $?
|
||||||
|
;;
|
||||||
|
stop)
|
||||||
|
docker stop $NAME
|
||||||
|
exit $?
|
||||||
|
;;
|
||||||
|
rm)
|
||||||
|
docker rm $NAME
|
||||||
|
exit $?
|
||||||
|
;;
|
||||||
|
run)
|
||||||
|
run
|
||||||
|
exit $?
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Usage: run.sh {start|stop|rm|run} port version." >&2
|
||||||
|
echo "port and version are optional." >&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
@ -0,0 +1,7 @@
|
|||||||
|
FROM tonywell/alpine-jre8:1.0.0
|
||||||
|
|
||||||
|
RUN mkdir /app
|
||||||
|
WORKDIR /app
|
||||||
|
COPY springbootstart-1.0.0.jar /app/
|
||||||
|
ENTRYPOINT ["java", "-jar", "-Xms256m", "-Xmx256m", "/app/springbootstart-1.0.0.jar"]
|
||||||
|
EXPOSE 8080
|
||||||
@ -0,0 +1,21 @@
|
|||||||
|
# 返回的分页数据 请用pagehelp的PageInfo
|
||||||
|
|
||||||
|
# 引入redis
|
||||||
|
## 需要在yml文件中配置prefix指定前缀
|
||||||
|
```yaml
|
||||||
|
zhehe:
|
||||||
|
common:
|
||||||
|
redis:
|
||||||
|
prefix:
|
||||||
|
```
|
||||||
|
# 引入md5加密
|
||||||
|
## 需配置secretSalt
|
||||||
|
```yaml
|
||||||
|
zhehe:
|
||||||
|
common:
|
||||||
|
md5:
|
||||||
|
secretSalt:
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -0,0 +1,130 @@
|
|||||||
|
<?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>com.zhehekeji</groupId>
|
||||||
|
<artifactId>common</artifactId>
|
||||||
|
<version>1.0.0</version>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<java.version>1.8</java.version>
|
||||||
|
<spring-boot.version>2.1.9.RELEASE</spring-boot.version>
|
||||||
|
<fastjson.version>1.2.47</fastjson.version>
|
||||||
|
<qrcode.version>2.1</qrcode.version>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
<product.center.api>1.0.0</product.center.api>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencyManagement>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-dependencies</artifactId>
|
||||||
|
<version>${spring-boot.version}</version>
|
||||||
|
<type>pom</type>
|
||||||
|
<scope>import</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</dependencyManagement>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-autoconfigure</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-configuration-processor</artifactId>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-validation</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-aop</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||||
|
<artifactId>jackson-datatype-jsr310</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba</groupId>
|
||||||
|
<artifactId>fastjson</artifactId>
|
||||||
|
<version>${fastjson.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.google.zxing</groupId>
|
||||||
|
<artifactId>core</artifactId>
|
||||||
|
<version>${qrcode.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.google.zxing</groupId>
|
||||||
|
<artifactId>javase</artifactId>
|
||||||
|
<version>${qrcode.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.httpcomponents</groupId>
|
||||||
|
<artifactId>httpclient</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>redis.clients</groupId>
|
||||||
|
<artifactId>jedis</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.zhehekeji</groupId>
|
||||||
|
<artifactId>core</artifactId>
|
||||||
|
<version>1.0.0</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.zhehekeji</groupId>
|
||||||
|
<artifactId>base-assembly</artifactId>
|
||||||
|
<version>1.0.0</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<!--指定编译的jdk版本-->
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<source>1.8</source>
|
||||||
|
<target>1.8</target>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>nexus</id>
|
||||||
|
<name>Nexus</name>
|
||||||
|
<url>http://47.99.98.250:28888/repository/maven-public/</url>
|
||||||
|
<snapshots>
|
||||||
|
<enabled>false</enabled>
|
||||||
|
</snapshots>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
|
</project>
|
||||||
@ -0,0 +1,25 @@
|
|||||||
|
package com.zhehekeji.common;
|
||||||
|
|
||||||
|
import com.zhehekeji.common.properities.Md5Properity;
|
||||||
|
import com.zhehekeji.common.properities.RedisProperity;
|
||||||
|
import com.zhehekeji.common.util.MD5Util;
|
||||||
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description
|
||||||
|
* @Author wangyiming1031@aliyun.com
|
||||||
|
* @Date 2019/10/28 15:39
|
||||||
|
**/
|
||||||
|
@Configuration
|
||||||
|
@EnableConfigurationProperties({RedisProperity.class, Md5Properity.class})
|
||||||
|
public class CommonConfigure {
|
||||||
|
//todo 把result的version放进来
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public MD5Util md5Util(Md5Properity md5Properity){
|
||||||
|
return new MD5Util(md5Properity);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,32 @@
|
|||||||
|
package com.zhehekeji.common.constant;
|
||||||
|
|
||||||
|
public abstract class CommonConstant {
|
||||||
|
|
||||||
|
public static final Integer RESULT_ERROR_CODE = 500;
|
||||||
|
|
||||||
|
public static final String RESULT_ADD_OK_MSG = "新增成功";
|
||||||
|
|
||||||
|
public static final String RESULT_ADD_ERROR_MSG = "新增失败";
|
||||||
|
|
||||||
|
public static final String RESULT_DELETE_OK_MSG = "删除成功";
|
||||||
|
|
||||||
|
public static final String RESULT_DELETE_ERROR_MSG = "删除失败";
|
||||||
|
|
||||||
|
public static final String RESULT_EDIT_OK_MSG = "修改成功";
|
||||||
|
|
||||||
|
public static final String RESULT_EDIT_ERROR_MSG = "修改失败";
|
||||||
|
|
||||||
|
public static final String RESULT_OK_MSG = "操作成功";
|
||||||
|
|
||||||
|
public static final String RESULT_ERROR_MSG = "生成失败";
|
||||||
|
|
||||||
|
public static final String MODULE_URL = "/module";
|
||||||
|
|
||||||
|
public static final String PROJECT_URL = "/project";
|
||||||
|
|
||||||
|
public static final String ACCOUNT_URL = "/account";
|
||||||
|
|
||||||
|
public static final String ROLE_URL = "/role";
|
||||||
|
|
||||||
|
public static final String DEPARTMENT_URL = "/department";
|
||||||
|
}
|
||||||
@ -0,0 +1,17 @@
|
|||||||
|
package com.zhehekeji.common.properities;
|
||||||
|
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
|
||||||
|
@ConfigurationProperties("zhehe.common.md5")
|
||||||
|
public class Md5Properity {
|
||||||
|
|
||||||
|
private String secretSalt = "zheHeKeJi";
|
||||||
|
|
||||||
|
public String getSecretSalt() {
|
||||||
|
return secretSalt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSecretSalt(String secretSalt) {
|
||||||
|
this.secretSalt = secretSalt;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,16 @@
|
|||||||
|
package com.zhehekeji.common.properities;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
|
||||||
|
@ConfigurationProperties("zhehe.common")
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class Properity {
|
||||||
|
|
||||||
|
private String version;
|
||||||
|
|
||||||
|
private String successMsg = "SUCCESS";
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,15 @@
|
|||||||
|
package com.zhehekeji.common.properities;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
|
||||||
|
@ConfigurationProperties("zhehe.common.redis")
|
||||||
|
@Data
|
||||||
|
public class RedisProperity {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* redis前缀
|
||||||
|
*/
|
||||||
|
private String prefix;
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,54 @@
|
|||||||
|
package com.zhehekeji.common.util;
|
||||||
|
|
||||||
|
import com.zhehekeji.common.properities.Md5Properity;
|
||||||
|
|
||||||
|
import java.security.MessageDigest;
|
||||||
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
|
||||||
|
public class MD5Util {
|
||||||
|
|
||||||
|
private String salt;
|
||||||
|
|
||||||
|
public MD5Util(Md5Properity md5Properity){
|
||||||
|
this.salt = md5Properity.getSecretSalt();
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getMD5(String content) {
|
||||||
|
try {
|
||||||
|
MessageDigest digest = MessageDigest.getInstance("MD5");
|
||||||
|
digest.update(content.getBytes());
|
||||||
|
return getHashString(digest);
|
||||||
|
} catch (NoSuchAlgorithmException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取加盐md5
|
||||||
|
* @param content
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String getMD5WithSalt(String content) {
|
||||||
|
return getMD5(getMD5(content) + salt);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getHashString(MessageDigest digest) {
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
for (byte b : digest.digest()) {
|
||||||
|
builder.append(Integer.toHexString((b >> 4) & 0xf));
|
||||||
|
builder.append(Integer.toHexString(b & 0xf));
|
||||||
|
}
|
||||||
|
return builder.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检验密码是否正确
|
||||||
|
* @param password
|
||||||
|
* @param md5
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Boolean checkPassword(String password,String md5){
|
||||||
|
return md5.equals(getMD5WithSalt(password));
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,72 @@
|
|||||||
|
package com.zhehekeji.common.util;
|
||||||
|
|
||||||
|
import com.google.zxing.BarcodeFormat;
|
||||||
|
import com.google.zxing.EncodeHintType;
|
||||||
|
import com.google.zxing.MultiFormatWriter;
|
||||||
|
import com.google.zxing.WriterException;
|
||||||
|
import com.google.zxing.client.j2se.MatrixToImageWriter;
|
||||||
|
import com.google.zxing.common.BitMatrix;
|
||||||
|
import com.zhehekeji.core.util.Assert;
|
||||||
|
import org.apache.commons.codec.binary.Base64;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
|
import javax.imageio.ImageIO;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.io.*;
|
||||||
|
import java.util.Hashtable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 二维码Util
|
||||||
|
*/
|
||||||
|
public class QrUtil {
|
||||||
|
|
||||||
|
private static String BASE64 = "data:image/jpg;base64,";
|
||||||
|
|
||||||
|
public static BufferedImage createCode(String content, BarcodeFormat format,Integer width,Integer height) throws WriterException {
|
||||||
|
Assert.isTrue(!StringUtils.isEmpty(content),"二维码生成要素为空");
|
||||||
|
Hashtable<EncodeHintType, String> hints = new Hashtable<>();
|
||||||
|
hints.put(EncodeHintType.CHARACTER_SET, "utf-8");
|
||||||
|
|
||||||
|
BitMatrix bitMatrix = new MultiFormatWriter().encode(content, format , width, height, hints);
|
||||||
|
return MatrixToImageWriter.toBufferedImage(bitMatrix);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将二维码显示在web上
|
||||||
|
* @param os OutputStream
|
||||||
|
* @param extension 图片类型 jpg jpeg
|
||||||
|
* @param content 二维码要素
|
||||||
|
* @param format 二维码类型 QR_CODE : 正方形二维码
|
||||||
|
* 见 com.google.zxing.BarcodeFormat
|
||||||
|
* @param width 宽
|
||||||
|
* @param height 高
|
||||||
|
* @throws IOException
|
||||||
|
* @throws WriterException
|
||||||
|
*/
|
||||||
|
public static void outPut2Web(OutputStream os, String extension, String content, BarcodeFormat format, Integer width, Integer height) throws IOException, WriterException {
|
||||||
|
BufferedImage image = createCode(content,format,width,height);
|
||||||
|
ImageIO.write(image, extension, os);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 二维码转base64
|
||||||
|
* @param content 二维码要素
|
||||||
|
* @param format 二维码类型 QR_CODE : 正方形二维码
|
||||||
|
* @param width 宽
|
||||||
|
* @param height 高
|
||||||
|
* @param extension 图片类型 jpg/jpeg
|
||||||
|
* @return
|
||||||
|
* @throws WriterException
|
||||||
|
* @throws IOException
|
||||||
|
*/
|
||||||
|
public static String image2Base64(String content, BarcodeFormat format,Integer width,Integer height,String extension) throws WriterException, IOException {
|
||||||
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||||
|
BufferedImage image = createCode(content,format,width,height);
|
||||||
|
ImageIO.write(image, extension, outputStream);
|
||||||
|
String base = Base64.encodeBase64String(outputStream.toByteArray());
|
||||||
|
return BASE64 + base;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,33 @@
|
|||||||
|
package com.zhehekeji.common.util;
|
||||||
|
|
||||||
|
import org.springframework.beans.BeansException;
|
||||||
|
import org.springframework.context.ApplicationContext;
|
||||||
|
import org.springframework.context.ApplicationContextAware;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class SpringContextUtil implements ApplicationContextAware {
|
||||||
|
|
||||||
|
private static ApplicationContext applicationContext;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
||||||
|
SpringContextUtil.applicationContext = applicationContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T> T getBean(String id, Class<T> type) {
|
||||||
|
return applicationContext.getBean(id, type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T> T getBean(Class<T> type) {
|
||||||
|
return applicationContext.getBean(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T> Map<String, T> getBeansOfType(Class<T> type) {
|
||||||
|
return applicationContext.getBeansOfType(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,28 @@
|
|||||||
|
package com.zhehekeji.common.util;
|
||||||
|
|
||||||
|
import com.zhehekeji.core.util.Assert;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.validation.ConstraintViolation;
|
||||||
|
import javax.validation.Validator;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class ValidatorUtil {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private Validator validator;
|
||||||
|
|
||||||
|
public <T> void validate(T object, Class<?>... groups) {
|
||||||
|
Set<ConstraintViolation<T>> constraintViolations = validator.validate(object, groups);
|
||||||
|
if (!constraintViolations.isEmpty()) {
|
||||||
|
StringBuilder msg = new StringBuilder();
|
||||||
|
for (ConstraintViolation<T> violation : constraintViolations) {
|
||||||
|
msg.append(violation.getMessage()).append(";");
|
||||||
|
}
|
||||||
|
Assert.isTrue(Boolean.FALSE, msg != null ? msg.toString() : "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,79 @@
|
|||||||
|
<?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>modules</artifactId>
|
||||||
|
<groupId>com.zhehekeji</groupId>
|
||||||
|
<version>1.0.0</version>
|
||||||
|
</parent>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<groupId>com.zhehekeji</groupId>
|
||||||
|
<version>1.0.0</version>
|
||||||
|
<artifactId>filter</artifactId>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<java.version>1.8</java.version>
|
||||||
|
<spring-boot.version>2.1.9.RELEASE</spring-boot.version>
|
||||||
|
<jwt.version>0.7.0</jwt.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencyManagement>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-dependencies</artifactId>
|
||||||
|
<version>${spring-boot.version}</version>
|
||||||
|
<type>pom</type>
|
||||||
|
<scope>import</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</dependencyManagement>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-autoconfigure</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-configuration-processor</artifactId>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-aop</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.zhehekeji</groupId>
|
||||||
|
<artifactId>core</artifactId>
|
||||||
|
<version>1.0.0</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.jsonwebtoken</groupId>
|
||||||
|
<artifactId>jjwt</artifactId>
|
||||||
|
<version>${jwt.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.zhehekeji</groupId>
|
||||||
|
<artifactId>common</artifactId>
|
||||||
|
<version>1.0.0</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
||||||
@ -0,0 +1,12 @@
|
|||||||
|
package com.zhehekeji.filter;
|
||||||
|
|
||||||
|
public interface FilterConstance {
|
||||||
|
|
||||||
|
String HEADER = "token";
|
||||||
|
|
||||||
|
String JWT_KEY = "zhehekeji";
|
||||||
|
|
||||||
|
String SESSION_PREFIX = "session:";
|
||||||
|
|
||||||
|
Long SESSION_EXPIRE = 10800l;
|
||||||
|
}
|
||||||
@ -0,0 +1,67 @@
|
|||||||
|
package com.zhehekeji.filter.aspect;
|
||||||
|
|
||||||
|
import com.zhehekeji.core.pojo.HttpStatus;
|
||||||
|
import com.zhehekeji.core.util.Assert;
|
||||||
|
import com.zhehekeji.filter.FilterConstance;
|
||||||
|
import com.zhehekeji.filter.pojo.CurrentUser;
|
||||||
|
import com.zhehekeji.filter.pojo.SessionHandler;
|
||||||
|
import com.zhehekeji.filter.pojo.UserType;
|
||||||
|
import com.zhehekeji.filter.util.CurrentUserUtil;
|
||||||
|
import com.zhehekeji.filter.util.JwtUtil;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.aspectj.lang.annotation.Aspect;
|
||||||
|
import org.aspectj.lang.annotation.Before;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
import org.springframework.web.context.request.RequestContextHolder;
|
||||||
|
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description Session切面
|
||||||
|
* @Author wangyiming1031@aliyun.com
|
||||||
|
* @Date 2019/10/28 19:26
|
||||||
|
**/
|
||||||
|
@Aspect
|
||||||
|
@Component
|
||||||
|
@Slf4j
|
||||||
|
public class SessionAspect {
|
||||||
|
|
||||||
|
@Value("${zhehe.filter.enable}")
|
||||||
|
private Boolean enable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* zhehekeji..*.controller
|
||||||
|
* 匹配zhehekeji 到controller多级目录
|
||||||
|
*
|
||||||
|
* @param sessionHandler
|
||||||
|
*/
|
||||||
|
@Before("execution(public * com.zhehekeji..*.controller.*.*(..))&&@annotation(sessionHandler)")
|
||||||
|
public void handler(SessionHandler sessionHandler) {
|
||||||
|
if(!enable){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
|
||||||
|
CurrentUser currentUser = null;
|
||||||
|
String token = request.getHeader(FilterConstance.HEADER);
|
||||||
|
if (UserType.ACCOUNT.equals(sessionHandler.userType())) {
|
||||||
|
log.info("token:" + token);
|
||||||
|
if (!StringUtils.isEmpty(token)) {
|
||||||
|
currentUser = JwtUtil.getUser(request);
|
||||||
|
if (currentUser != null) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (UserType.USER.equals(sessionHandler.userType())) {
|
||||||
|
}
|
||||||
|
if (sessionHandler.login()) {
|
||||||
|
Assert.isTrue(currentUser != null, HttpStatus.UNAUTHORIZED.getCode(), HttpStatus.UNAUTHORIZED.getReasonPhrase());
|
||||||
|
}
|
||||||
|
if (sessionHandler.auth()) {
|
||||||
|
//todo 权限检验
|
||||||
|
}
|
||||||
|
CurrentUserUtil.setCurrentUser(currentUser);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,40 @@
|
|||||||
|
package com.zhehekeji.filter.pojo;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class CurrentUser {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主键
|
||||||
|
*/
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 手机号
|
||||||
|
*/
|
||||||
|
private String phone;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 账号 某些系统可能账号就是手机号
|
||||||
|
*/
|
||||||
|
private String account;
|
||||||
|
|
||||||
|
private String email;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 昵称
|
||||||
|
*/
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户类型
|
||||||
|
*/
|
||||||
|
private UserType userType;
|
||||||
|
}
|
||||||
@ -0,0 +1,25 @@
|
|||||||
|
package com.zhehekeji.filter.pojo;
|
||||||
|
|
||||||
|
import java.lang.annotation.*;
|
||||||
|
|
||||||
|
@Target(ElementType.METHOD)
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Documented
|
||||||
|
public @interface SessionHandler {
|
||||||
|
|
||||||
|
String value() default "";
|
||||||
|
|
||||||
|
UserType userType() default UserType.USER;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否检验登录
|
||||||
|
* @return true:检验 false:不检验
|
||||||
|
*/
|
||||||
|
boolean login() default true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否检验权限
|
||||||
|
* @return true:检验 false:不检验 默认检验
|
||||||
|
*/
|
||||||
|
boolean auth() default true;
|
||||||
|
}
|
||||||
@ -0,0 +1,19 @@
|
|||||||
|
package com.zhehekeji.filter.pojo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description 用户分类
|
||||||
|
* @Author wangyiming1031@aliyun.com
|
||||||
|
* @Date 2019/10/28 19:30
|
||||||
|
**/
|
||||||
|
public enum UserType {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 后台用户
|
||||||
|
*/
|
||||||
|
ACCOUNT,
|
||||||
|
/**
|
||||||
|
* 用户
|
||||||
|
*/
|
||||||
|
USER,
|
||||||
|
;
|
||||||
|
}
|
||||||
@ -0,0 +1,30 @@
|
|||||||
|
package com.zhehekeji.filter.util;
|
||||||
|
|
||||||
|
import com.zhehekeji.filter.pojo.CurrentUser;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description 当前操作人线程
|
||||||
|
* @Author wangyiming1031@aliyun.com
|
||||||
|
* @Date 2019/10/28 19:22
|
||||||
|
**/
|
||||||
|
public class CurrentUserUtil {
|
||||||
|
|
||||||
|
private static ThreadLocal<CurrentUser> currentUser = new ThreadLocal<>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取当前操作人
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static CurrentUser getCurrentUser() {
|
||||||
|
return currentUser.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setCurrentUser(CurrentUser user) {
|
||||||
|
currentUser.set(user);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void delCurrentUser() {
|
||||||
|
currentUser.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,85 @@
|
|||||||
|
package com.zhehekeji.filter.util;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.zhehekeji.filter.FilterConstance;
|
||||||
|
import com.zhehekeji.filter.pojo.CurrentUser;
|
||||||
|
import io.jsonwebtoken.Claims;
|
||||||
|
import io.jsonwebtoken.JwtBuilder;
|
||||||
|
import io.jsonwebtoken.Jwts;
|
||||||
|
import io.jsonwebtoken.SignatureAlgorithm;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description JWTUtil
|
||||||
|
* @Author wangyiming1031@aliyun.com
|
||||||
|
* @Date 2019/10/28 19:11
|
||||||
|
**/
|
||||||
|
public class JwtUtil {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成JWT
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private static String createJWT(CurrentUser currentUser) {
|
||||||
|
String userJson = JSONObject.toJSONString(currentUser);
|
||||||
|
JwtBuilder builder = Jwts.builder()
|
||||||
|
.setSubject(userJson)
|
||||||
|
.setIssuedAt(new Date())
|
||||||
|
.signWith(SignatureAlgorithm.HS256, FilterConstance.JWT_KEY);
|
||||||
|
return builder.compact();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 解析JWT
|
||||||
|
* 抛出异常 则jwt错误
|
||||||
|
* @param jwtStr
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static Claims parseJWT(String jwtStr) {
|
||||||
|
return Jwts.parser()
|
||||||
|
.setSigningKey(FilterConstance.JWT_KEY)
|
||||||
|
.parseClaimsJws(jwtStr)
|
||||||
|
.getBody();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取当前操作人
|
||||||
|
*
|
||||||
|
* @param request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static CurrentUser getUser(HttpServletRequest request) {
|
||||||
|
String token = getToken(request);
|
||||||
|
Claims claims;
|
||||||
|
try {
|
||||||
|
claims = parseJWT(token);
|
||||||
|
} catch (Exception e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
String json = claims.getSubject();
|
||||||
|
CurrentUser userInfo = JSONObject.parseObject(json, CurrentUser.class);
|
||||||
|
return userInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String getToken(HttpServletRequest request) {
|
||||||
|
return request.getHeader(FilterConstance.HEADER);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成jwt,并将jwt放入返回头
|
||||||
|
* 主要考虑的是 返回header 由用户过滤模块维护
|
||||||
|
* @param response
|
||||||
|
* @param currentUser
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String createTokenAndHeader(HttpServletResponse response,CurrentUser currentUser){
|
||||||
|
String jwt = createJWT(currentUser);
|
||||||
|
response.setHeader(FilterConstance.HEADER,jwt);
|
||||||
|
return jwt;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
zhehe:
|
||||||
|
filter:
|
||||||
|
enable: true
|
||||||
@ -0,0 +1,55 @@
|
|||||||
|
<?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>springbootstart</artifactId>
|
||||||
|
<groupId>com.zhehekeji</groupId>
|
||||||
|
<version>1.0.0</version>
|
||||||
|
</parent>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<artifactId>modules</artifactId>
|
||||||
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<java.version>1.8</java.version>
|
||||||
|
<common.version>1.0.0</common.version>
|
||||||
|
<base.assembly.version>1.0.0</base.assembly.version>
|
||||||
|
<filter.version>1.0.0</filter.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.zhehekeji</groupId>
|
||||||
|
<artifactId>base-assembly</artifactId>
|
||||||
|
<version>${base.assembly.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.zhehekeji</groupId>
|
||||||
|
<artifactId>common</artifactId>
|
||||||
|
<version>${common.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>nexus</id>
|
||||||
|
<name>Nexus</name>
|
||||||
|
<url>http://47.99.98.250:28888/repository/maven-public/</url>
|
||||||
|
<snapshots>
|
||||||
|
<enabled>false</enabled>
|
||||||
|
</snapshots>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
|
|
||||||
|
</project>
|
||||||
@ -0,0 +1,15 @@
|
|||||||
|
version: '2'
|
||||||
|
services:
|
||||||
|
backend:
|
||||||
|
image: springbootstart:1.0.0
|
||||||
|
container_name: lipo-duoji
|
||||||
|
ports:
|
||||||
|
- "8990:8099"
|
||||||
|
hostname: lipo-duoji
|
||||||
|
volumes:
|
||||||
|
- /home/work/lia/duoji/logs:/data/log/duoji
|
||||||
|
|
||||||
|
networks:
|
||||||
|
default:
|
||||||
|
external:
|
||||||
|
name: zhehe007
|
||||||
@ -0,0 +1,22 @@
|
|||||||
|
---
|
||||||
|
- name: Ensures /home/work/springbootstart/springbootstart_backend_test dir exists
|
||||||
|
file: path=/home/work/springbootstart/springbootstart_backend_test state=directory
|
||||||
|
|
||||||
|
- name: stop admin Service
|
||||||
|
shell: docker-compose -f /home/work/springbootstart/springbootstart_backend_test/docker-compose.yml down
|
||||||
|
ignore_errors: True
|
||||||
|
|
||||||
|
- name: copy admin docker-compose.yml
|
||||||
|
copy:
|
||||||
|
src: docker-compose.yml
|
||||||
|
dest: /home/work/springbootstart/springbootstart_backend_test/docker-compose.yml
|
||||||
|
backup: yes
|
||||||
|
|
||||||
|
- name: docker-pull
|
||||||
|
shell: docker pull {{ DOCKER_REPO }}/{{ IMAGE }} && docker tag {{ DOCKER_REPO }}/{{ IMAGE }} {{ IMAGE }} && docker rmi {{ DOCKER_REPO }}/{{ IMAGE }}
|
||||||
|
|
||||||
|
- name: modify docker-compose.yml
|
||||||
|
shell: cd /home/work/springbootstart/springbootstart_backend_test && sed -i "s/springbootstart:1.0.0/{{ IMAGE }}/g" docker-compose.yml
|
||||||
|
|
||||||
|
- name: start Service
|
||||||
|
shell: docker-compose -f /home/work/springbootstart/springbootstart_backend_test/docker-compose.yml up -d
|
||||||
@ -0,0 +1 @@
|
|||||||
|
192.168.1.232
|
||||||
@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
- name: deploy springbootstart
|
||||||
|
hosts: all
|
||||||
|
remote_user: work
|
||||||
|
roles:
|
||||||
|
- springbootstart-test
|
||||||
@ -0,0 +1,132 @@
|
|||||||
|
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<packaging>pom</packaging>
|
||||||
|
<modules>
|
||||||
|
<module>web</module>
|
||||||
|
<module>modules</module>
|
||||||
|
<module>modules/common</module>
|
||||||
|
<module>modules/filter</module>
|
||||||
|
</modules>
|
||||||
|
<parent>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-parent</artifactId>
|
||||||
|
<version>2.1.9.RELEASE</version>
|
||||||
|
<relativePath/>
|
||||||
|
</parent>
|
||||||
|
<groupId>com.zhehekeji</groupId>
|
||||||
|
<artifactId>springbootstart</artifactId>
|
||||||
|
<version>1.0.0</version>
|
||||||
|
<name>springbootstart</name>
|
||||||
|
<description>Demo project for Spring Boot</description>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<java.version>1.8</java.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<!--json工具 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba</groupId>
|
||||||
|
<artifactId>fastjson</artifactId>
|
||||||
|
<version>1.2.47</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.commons</groupId>
|
||||||
|
<artifactId>commons-lang3</artifactId>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<profiles>
|
||||||
|
<profile>
|
||||||
|
<!-- 测试环境 -->
|
||||||
|
<id>test</id>
|
||||||
|
<properties>
|
||||||
|
<profileActive>test</profileActive>
|
||||||
|
</properties>
|
||||||
|
<activation>
|
||||||
|
<activeByDefault>true</activeByDefault>
|
||||||
|
</activation>
|
||||||
|
</profile>
|
||||||
|
<profile>
|
||||||
|
<!-- 生产环境 -->
|
||||||
|
<id>prod</id>
|
||||||
|
<properties>
|
||||||
|
<profileActive>prod</profileActive>
|
||||||
|
</properties>
|
||||||
|
<activation>
|
||||||
|
<activeByDefault>false</activeByDefault>
|
||||||
|
</activation>
|
||||||
|
</profile>
|
||||||
|
</profiles>
|
||||||
|
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>nexus</id>
|
||||||
|
<name>Nexus</name>
|
||||||
|
<url>http://47.99.98.250:28888/repository/maven-public/</url>
|
||||||
|
<snapshots>
|
||||||
|
<enabled>false</enabled>
|
||||||
|
</snapshots>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
|
<build>
|
||||||
|
<resources>
|
||||||
|
<resource>
|
||||||
|
<directory>src/main/resources</directory>
|
||||||
|
<filtering>true</filtering>
|
||||||
|
<excludes>
|
||||||
|
<exclude>application*.yml</exclude>
|
||||||
|
</excludes>
|
||||||
|
</resource>
|
||||||
|
<resource>
|
||||||
|
<filtering>true</filtering>
|
||||||
|
<directory>src/main/resources</directory>
|
||||||
|
<includes>
|
||||||
|
<include>bootstrap.yml</include>
|
||||||
|
<include>application.yml</include>
|
||||||
|
<include>application-${profileActive}.yml</include>
|
||||||
|
</includes>
|
||||||
|
</resource>
|
||||||
|
</resources>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<!--指定编译的jdk版本-->
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<source>1.8</source>
|
||||||
|
<target>1.8</target>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<!--执行单元测试的插件-->
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<skipTests>true</skipTests>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
||||||
@ -0,0 +1,57 @@
|
|||||||
|
<?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>springbootstart</artifactId>
|
||||||
|
<groupId>com.zhehekeji</groupId>
|
||||||
|
<version>1.0.0</version>
|
||||||
|
</parent>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<artifactId>springbootstart-web</artifactId>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<java.version>1.8</java.version>
|
||||||
|
<common.version>1.0.0</common.version>
|
||||||
|
<base.assembly.version>1.0.0</base.assembly.version>
|
||||||
|
<filter.version>1.0.0</filter.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.zhehekeji</groupId>
|
||||||
|
<artifactId>base-assembly</artifactId>
|
||||||
|
<version>${base.assembly.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.zhehekeji</groupId>
|
||||||
|
<artifactId>common</artifactId>
|
||||||
|
<version>1.0.0</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.zhehekeji</groupId>
|
||||||
|
<artifactId>filter</artifactId>
|
||||||
|
<version>1.0.0</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
||||||
@ -0,0 +1,14 @@
|
|||||||
|
package com.zhehekeji.web;
|
||||||
|
|
||||||
|
import org.mybatis.spring.annotation.MapperScan;
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
|
||||||
|
@SpringBootApplication(scanBasePackages = {"com.zhehekeji"})
|
||||||
|
@MapperScan("com.zhehekeji.**.mapper.**")
|
||||||
|
public class Application {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SpringApplication springApplication = new SpringApplication(Application.class);
|
||||||
|
springApplication.run(args);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,59 @@
|
|||||||
|
package com.zhehekeji.web.config;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.mybatis.spring.SqlSessionFactoryBean;
|
||||||
|
import org.springframework.core.io.Resource;
|
||||||
|
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
|
||||||
|
import org.springframework.core.io.support.ResourcePatternResolver;
|
||||||
|
import org.springframework.core.type.classreading.CachingMetadataReaderFactory;
|
||||||
|
import org.springframework.core.type.classreading.MetadataReader;
|
||||||
|
import org.springframework.core.type.classreading.MetadataReaderFactory;
|
||||||
|
import org.springframework.util.ClassUtils;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
public class PackagesSqlSessionFactory extends SqlSessionFactoryBean {
|
||||||
|
|
||||||
|
static final String DEFAULT_RESOURCE_PATTERN = "**/*.class";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setTypeAliasesPackage(String typeAliasesPackage) {
|
||||||
|
ResourcePatternResolver resolver = (ResourcePatternResolver) new PathMatchingResourcePatternResolver();
|
||||||
|
MetadataReaderFactory metadataReaderFactory = new CachingMetadataReaderFactory(resolver);
|
||||||
|
typeAliasesPackage = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX +
|
||||||
|
ClassUtils.convertClassNameToResourcePath(typeAliasesPackage) + "/" + DEFAULT_RESOURCE_PATTERN;
|
||||||
|
|
||||||
|
//将加载多个绝对匹配的所有Resource
|
||||||
|
//将首先通过ClassLoader.getResource("META-INF")加载非模式路径部分
|
||||||
|
//然后进行遍历模式匹配
|
||||||
|
try {
|
||||||
|
List<String> result = new ArrayList<String>();
|
||||||
|
Resource[] resources = resolver.getResources(typeAliasesPackage);
|
||||||
|
if (resources != null && resources.length > 0) {
|
||||||
|
MetadataReader metadataReader = null;
|
||||||
|
for (Resource resource : resources) {
|
||||||
|
if (resource.isReadable()) {
|
||||||
|
metadataReader = metadataReaderFactory.getMetadataReader(resource);
|
||||||
|
try {
|
||||||
|
result.add(Class.forName(metadataReader.getClassMetadata().getClassName()).getPackage().getName());
|
||||||
|
} catch (ClassNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (result.size() > 0) {
|
||||||
|
super.setTypeAliasesPackage(String.join(",", result));
|
||||||
|
} else {
|
||||||
|
log.error("参数typeAliasesPackage:" + typeAliasesPackage + ",未找到任何包");
|
||||||
|
}
|
||||||
|
//logger.info("d");
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,36 @@
|
|||||||
|
package com.zhehekeji.web.config;
|
||||||
|
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.context.annotation.Profile;
|
||||||
|
import springfox.documentation.builders.ApiInfoBuilder;
|
||||||
|
import springfox.documentation.builders.RequestHandlerSelectors;
|
||||||
|
import springfox.documentation.service.ApiInfo;
|
||||||
|
import springfox.documentation.service.Contact;
|
||||||
|
import springfox.documentation.spi.DocumentationType;
|
||||||
|
import springfox.documentation.spring.web.plugins.Docket;
|
||||||
|
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
@EnableSwagger2
|
||||||
|
@Profile({"test", "dev"})
|
||||||
|
public class SwaggerConfig {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public Docket petApi() {
|
||||||
|
return new Docket(DocumentationType.SWAGGER_2)
|
||||||
|
.apiInfo(apiInfo())
|
||||||
|
.select()
|
||||||
|
//指定提供接口所在的基包
|
||||||
|
.apis(RequestHandlerSelectors.basePackage("com.zhehekeji"))
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
private ApiInfo apiInfo() {
|
||||||
|
return new ApiInfoBuilder()
|
||||||
|
.title("舵机Api")
|
||||||
|
.version("1.0.0")
|
||||||
|
.description("web 舵机Api")
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,53 @@
|
|||||||
|
package com.zhehekeji.web.controller;
|
||||||
|
|
||||||
|
import com.github.pagehelper.PageInfo;
|
||||||
|
import com.zhehekeji.core.pojo.Result;
|
||||||
|
import com.zhehekeji.core.util.Assert;
|
||||||
|
import com.zhehekeji.filter.pojo.SessionHandler;
|
||||||
|
import com.zhehekeji.filter.pojo.UserType;
|
||||||
|
import com.zhehekeji.web.entity.Order;
|
||||||
|
import com.zhehekeji.web.pojo.OrderSearch;
|
||||||
|
import com.zhehekeji.web.service.OrderService;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Api(value = "OrderController",tags = "订单管理")
|
||||||
|
@RestController(value = "OrderController")
|
||||||
|
@RequestMapping("/order")
|
||||||
|
public class OrderController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private OrderService orderService;
|
||||||
|
|
||||||
|
@ApiOperation("新增")
|
||||||
|
@PostMapping("/")
|
||||||
|
//@SessionHandler(userType = UserType.ACCOUNT)
|
||||||
|
public Result<Long> save(@RequestBody Order order){
|
||||||
|
|
||||||
|
return Result.success(orderService.add(order));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/list")
|
||||||
|
@ApiOperation(value = "查询")
|
||||||
|
//@SessionHandler(userType = UserType.ACCOUNT)
|
||||||
|
public Result<List<Order>> findRoleList(@RequestBody OrderSearch orderSearch) {
|
||||||
|
return new Result<>(orderService.orders(orderSearch));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*@GetMapping("/userCenter")
|
||||||
|
@ApiOperation("用户中心地址")
|
||||||
|
public Result<IndexVO> userCenter(){
|
||||||
|
return Result.success(applicationService.userCenter());
|
||||||
|
}*/
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,46 @@
|
|||||||
|
package com.zhehekeji.web.controller;
|
||||||
|
|
||||||
|
import com.zhehekeji.core.pojo.Result;
|
||||||
|
import com.zhehekeji.web.entity.Order;
|
||||||
|
import com.zhehekeji.web.entity.Street;
|
||||||
|
import com.zhehekeji.web.mapper.StreetMapper;
|
||||||
|
import com.zhehekeji.web.pojo.OrderSearch;
|
||||||
|
import com.zhehekeji.web.service.OrderService;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Api(value = "StreetController",tags = "巷道管理")
|
||||||
|
@RestController(value = "StreetController")
|
||||||
|
@RequestMapping("/street")
|
||||||
|
public class StreetController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private StreetMapper streetMapper;
|
||||||
|
|
||||||
|
@PostMapping("/list")
|
||||||
|
@ApiOperation(value = "巷道查询")
|
||||||
|
//@SessionHandler(userType = UserType.ACCOUNT)
|
||||||
|
public Result<List<Street>> list() {
|
||||||
|
return new Result<>(streetMapper.selectByMap(new HashMap<>(0)));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*@GetMapping("/userCenter")
|
||||||
|
@ApiOperation("用户中心地址")
|
||||||
|
public Result<IndexVO> userCenter(){
|
||||||
|
return Result.success(applicationService.userCenter());
|
||||||
|
}*/
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,14 @@
|
|||||||
|
package com.zhehekeji.web.controller;
|
||||||
|
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
public class controller {
|
||||||
|
|
||||||
|
@RequestMapping(value = "/web",method = RequestMethod.GET)
|
||||||
|
public String get(){
|
||||||
|
return "web";
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,34 @@
|
|||||||
|
package com.zhehekeji.web.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@TableName("`order`")
|
||||||
|
public class Order {
|
||||||
|
|
||||||
|
@TableId(type = IdType.AUTO)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
private Long serialNum;
|
||||||
|
|
||||||
|
@ApiModelProperty("订单号")
|
||||||
|
private String orderNum;
|
||||||
|
|
||||||
|
@ApiModelProperty("仓位号")
|
||||||
|
private String positionNum;
|
||||||
|
|
||||||
|
@ApiModelProperty("视频图片地址")
|
||||||
|
private String filePath;
|
||||||
|
|
||||||
|
private String mediaType;
|
||||||
|
|
||||||
|
private String deviceid;
|
||||||
|
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
}
|
||||||
@ -0,0 +1,24 @@
|
|||||||
|
package com.zhehekeji.web.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@TableName
|
||||||
|
public class Street {
|
||||||
|
|
||||||
|
@TableId(type = IdType.AUTO)
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
private String url1;
|
||||||
|
|
||||||
|
private String url2;
|
||||||
|
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
}
|
||||||
@ -0,0 +1,7 @@
|
|||||||
|
package com.zhehekeji.web.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.zhehekeji.web.entity.Order;
|
||||||
|
|
||||||
|
public interface OrderMapper extends BaseMapper<Order> {
|
||||||
|
}
|
||||||
@ -0,0 +1,7 @@
|
|||||||
|
package com.zhehekeji.web.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.zhehekeji.web.entity.Street;
|
||||||
|
|
||||||
|
public interface StreetMapper extends BaseMapper<Street> {
|
||||||
|
}
|
||||||
@ -0,0 +1,11 @@
|
|||||||
|
package com.zhehekeji.web.pojo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotEmpty;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class OrderSearch {
|
||||||
|
|
||||||
|
private String orderNum;
|
||||||
|
}
|
||||||
@ -0,0 +1,28 @@
|
|||||||
|
package com.zhehekeji.web.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.zhehekeji.web.entity.Order;
|
||||||
|
import com.zhehekeji.web.mapper.OrderMapper;
|
||||||
|
import com.zhehekeji.web.pojo.OrderSearch;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class OrderService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private OrderMapper orderMapper;
|
||||||
|
|
||||||
|
public List<Order> orders(OrderSearch orderSearch){
|
||||||
|
List<Order> orders = orderMapper.selectList(new QueryWrapper<Order>().eq("order_num",orderSearch.getOrderNum()));
|
||||||
|
return orders;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long add(Order order){
|
||||||
|
orderMapper.insert(order);
|
||||||
|
return order.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,32 @@
|
|||||||
|
logging:
|
||||||
|
level:
|
||||||
|
com.zhehekeji: debug
|
||||||
|
org.springframework.web: info
|
||||||
|
root: info
|
||||||
|
spring:
|
||||||
|
datasource:
|
||||||
|
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||||
|
initialSize: 15
|
||||||
|
maxActive: 20
|
||||||
|
maxPoolPreparedStatementPerConnectionSize: 20
|
||||||
|
maxWait: 60000
|
||||||
|
minEvictableIdleTimeMillis: 300000
|
||||||
|
minIdle: 15
|
||||||
|
password: lipoLiPo
|
||||||
|
poolPreparedStatements: true
|
||||||
|
testOnBorrow: true
|
||||||
|
testOnReturn: false
|
||||||
|
testWhileIdle: false
|
||||||
|
timeBetweenEvictionRunsMillis: 60000
|
||||||
|
type: com.alibaba.druid.pool.DruidDataSource
|
||||||
|
url: jdbc:mysql://47.98.255.48:8008/lipo_duoji?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=GMT%2B8
|
||||||
|
username: lipo
|
||||||
|
validationQuery: SELECT 1 FROM DUAL
|
||||||
|
zhehe:
|
||||||
|
common:
|
||||||
|
redis:
|
||||||
|
prefix: spring
|
||||||
|
filter:
|
||||||
|
enable: true
|
||||||
|
server:
|
||||||
|
port: 8099
|
||||||
@ -0,0 +1,124 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<configuration>
|
||||||
|
<property name="LOG_HOME" value="/data/log/duoji"></property>
|
||||||
|
<springProperty scope="context" name="logName" source="spring.application.name" defaultValue="localhost.log"/>
|
||||||
|
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||||
|
<encoder>
|
||||||
|
<pattern>%d %p (%file:%line\)- %m%n</pattern>
|
||||||
|
<charset>UTF-8</charset>
|
||||||
|
</encoder>
|
||||||
|
</appender>
|
||||||
|
<appender name="FILEINFO" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||||
|
<File>${LOG_HOME}/${logName}-info.log</File>
|
||||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||||
|
<fileNamePattern>${LOG_HOME}/${logName}-info-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
|
||||||
|
<maxHistory>30</maxHistory>
|
||||||
|
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
|
||||||
|
<maxFileSize>10MB</maxFileSize>
|
||||||
|
</timeBasedFileNamingAndTriggeringPolicy>
|
||||||
|
</rollingPolicy>
|
||||||
|
<encoder>
|
||||||
|
<pattern>
|
||||||
|
%d %p (%file:%line\)- %m%n
|
||||||
|
</pattern>
|
||||||
|
<charset>UTF-8</charset>
|
||||||
|
</encoder>
|
||||||
|
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||||
|
<level>info</level>
|
||||||
|
<onMatch>ACCEPT</onMatch>
|
||||||
|
<onMismatch>DENY</onMismatch>
|
||||||
|
</filter>
|
||||||
|
</appender>
|
||||||
|
<appender name="FILEWARN" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||||
|
<File>${LOG_HOME}/${logName}-warn.log</File>
|
||||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||||
|
<fileNamePattern>${LOG_HOME}/${logName}-warn-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
|
||||||
|
<maxHistory>30</maxHistory>
|
||||||
|
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
|
||||||
|
<maxFileSize>10MB</maxFileSize>
|
||||||
|
</timeBasedFileNamingAndTriggeringPolicy>
|
||||||
|
</rollingPolicy>
|
||||||
|
<encoder>
|
||||||
|
<pattern>
|
||||||
|
%d %p (%file:%line\)- %m%n
|
||||||
|
</pattern>
|
||||||
|
<charset>UTF-8</charset>
|
||||||
|
</encoder>
|
||||||
|
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||||
|
<level>warn</level>
|
||||||
|
<onMatch>ACCEPT</onMatch>
|
||||||
|
<onMismatch>DENY</onMismatch>
|
||||||
|
</filter>
|
||||||
|
</appender>
|
||||||
|
<appender name="FILEERROR" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||||
|
<File>${LOG_HOME}/${logName}-error.log</File>
|
||||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||||
|
<fileNamePattern>${LOG_HOME}/${logName}-error-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
|
||||||
|
<maxHistory>30</maxHistory>
|
||||||
|
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
|
||||||
|
<maxFileSize>10MB</maxFileSize>
|
||||||
|
</timeBasedFileNamingAndTriggeringPolicy>
|
||||||
|
</rollingPolicy>
|
||||||
|
<encoder>
|
||||||
|
<pattern>
|
||||||
|
%d %p (%file:%line\)- %m%n
|
||||||
|
</pattern>
|
||||||
|
<charset>UTF-8</charset>
|
||||||
|
</encoder>
|
||||||
|
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||||
|
<level>error</level>
|
||||||
|
<onMatch>ACCEPT</onMatch>
|
||||||
|
<onMismatch>DENY</onMismatch>
|
||||||
|
</filter>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<springProfile name="test">
|
||||||
|
<root level="INFO">
|
||||||
|
<appender-ref ref="FILEINFO"/>
|
||||||
|
<appender-ref ref="FILEWARN"/>
|
||||||
|
<appender-ref ref="FILEERROR"/>
|
||||||
|
<appender-ref ref="STDOUT"/>
|
||||||
|
</root>
|
||||||
|
</springProfile>
|
||||||
|
<springProfile name="dev">
|
||||||
|
<root level="INFO">
|
||||||
|
<appender-ref ref="FILEINFO"/>
|
||||||
|
<appender-ref ref="FILEWARN"/>
|
||||||
|
<appender-ref ref="FILEERROR"/>
|
||||||
|
<appender-ref ref="STDOUT"/>
|
||||||
|
</root>
|
||||||
|
</springProfile>
|
||||||
|
<springProfile name="loc">
|
||||||
|
<root level="INFO">
|
||||||
|
<appender-ref ref="FILEINFO"/>
|
||||||
|
<appender-ref ref="FILEWARN"/>
|
||||||
|
<appender-ref ref="FILEERROR"/>
|
||||||
|
<appender-ref ref="STDOUT"/>
|
||||||
|
</root>
|
||||||
|
</springProfile>
|
||||||
|
|
||||||
|
<springProfile name="sit">
|
||||||
|
<root level="INFO">
|
||||||
|
<appender-ref ref="FILEINFO"/>
|
||||||
|
<appender-ref ref="FILEWARN"/>
|
||||||
|
<appender-ref ref="FILEERROR"/>
|
||||||
|
</root>
|
||||||
|
</springProfile>
|
||||||
|
|
||||||
|
<springProfile name="uat">
|
||||||
|
<root level="INFO">
|
||||||
|
<appender-ref ref="FILEINFO"/>
|
||||||
|
<appender-ref ref="FILEWARN"/>
|
||||||
|
<appender-ref ref="FILEERROR"/>
|
||||||
|
</root>
|
||||||
|
</springProfile>
|
||||||
|
|
||||||
|
<springProfile name="prd">
|
||||||
|
<root level="INFO">
|
||||||
|
<appender-ref ref="FILEINFO"/>
|
||||||
|
<appender-ref ref="FILEWARN"/>
|
||||||
|
<appender-ref ref="FILEERROR"/>
|
||||||
|
<appender-ref ref="STDOUT"/>
|
||||||
|
</root>
|
||||||
|
</springProfile>
|
||||||
|
</configuration>
|
||||||
Loading…
Reference in New Issue