parent
dda98d3f36
commit
b5dceed03b
@ -0,0 +1,31 @@
|
|||||||
|
HELP.md
|
||||||
|
target/
|
||||||
|
!.mvn/wrapper/maven-wrapper.jar
|
||||||
|
!**/src/main/**
|
||||||
|
!**/src/test/**
|
||||||
|
|
||||||
|
### STS ###
|
||||||
|
.apt_generated
|
||||||
|
.classpath
|
||||||
|
.factorypath
|
||||||
|
.project
|
||||||
|
.settings
|
||||||
|
.springBeans
|
||||||
|
.sts4-cache
|
||||||
|
|
||||||
|
### IntelliJ IDEA ###
|
||||||
|
.idea
|
||||||
|
*.iws
|
||||||
|
*.iml
|
||||||
|
*.ipr
|
||||||
|
|
||||||
|
### NetBeans ###
|
||||||
|
/nbproject/private/
|
||||||
|
/nbbuild/
|
||||||
|
/dist/
|
||||||
|
/nbdist/
|
||||||
|
/.nb-gradle/
|
||||||
|
build/
|
||||||
|
|
||||||
|
### VS Code ###
|
||||||
|
.vscode/
|
@ -0,0 +1,117 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2012-2019 the original author or authors.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
import java.net.*;
|
||||||
|
import java.io.*;
|
||||||
|
import java.nio.channels.*;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
public class MavenWrapperDownloader {
|
||||||
|
|
||||||
|
private static final String WRAPPER_VERSION = "0.5.5";
|
||||||
|
/**
|
||||||
|
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
|
||||||
|
*/
|
||||||
|
private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/"
|
||||||
|
+ WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
|
||||||
|
* use instead of the default one.
|
||||||
|
*/
|
||||||
|
private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
|
||||||
|
".mvn/wrapper/maven-wrapper.properties";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Path where the maven-wrapper.jar will be saved to.
|
||||||
|
*/
|
||||||
|
private static final String MAVEN_WRAPPER_JAR_PATH =
|
||||||
|
".mvn/wrapper/maven-wrapper.jar";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Name of the property which should be used to override the default download url for the wrapper.
|
||||||
|
*/
|
||||||
|
private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";
|
||||||
|
|
||||||
|
public static void main(String args[]) {
|
||||||
|
System.out.println("- Downloader started");
|
||||||
|
File baseDirectory = new File(args[0]);
|
||||||
|
System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());
|
||||||
|
|
||||||
|
// If the maven-wrapper.properties exists, read it and check if it contains a custom
|
||||||
|
// wrapperUrl parameter.
|
||||||
|
File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
|
||||||
|
String url = DEFAULT_DOWNLOAD_URL;
|
||||||
|
if(mavenWrapperPropertyFile.exists()) {
|
||||||
|
FileInputStream mavenWrapperPropertyFileInputStream = null;
|
||||||
|
try {
|
||||||
|
mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
|
||||||
|
Properties mavenWrapperProperties = new Properties();
|
||||||
|
mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
|
||||||
|
url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
|
||||||
|
} catch (IOException e) {
|
||||||
|
System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
|
||||||
|
} finally {
|
||||||
|
try {
|
||||||
|
if(mavenWrapperPropertyFileInputStream != null) {
|
||||||
|
mavenWrapperPropertyFileInputStream.close();
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
// Ignore ...
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
System.out.println("- Downloading from: " + url);
|
||||||
|
|
||||||
|
File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
|
||||||
|
if(!outputFile.getParentFile().exists()) {
|
||||||
|
if(!outputFile.getParentFile().mkdirs()) {
|
||||||
|
System.out.println(
|
||||||
|
"- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
|
||||||
|
try {
|
||||||
|
downloadFileFromURL(url, outputFile);
|
||||||
|
System.out.println("Done");
|
||||||
|
System.exit(0);
|
||||||
|
} catch (Throwable e) {
|
||||||
|
System.out.println("- Error downloading");
|
||||||
|
e.printStackTrace();
|
||||||
|
System.exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void downloadFileFromURL(String urlString, File destination) throws Exception {
|
||||||
|
if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) {
|
||||||
|
String username = System.getenv("MVNW_USERNAME");
|
||||||
|
char[] password = System.getenv("MVNW_PASSWORD").toCharArray();
|
||||||
|
Authenticator.setDefault(new Authenticator() {
|
||||||
|
@Override
|
||||||
|
protected PasswordAuthentication getPasswordAuthentication() {
|
||||||
|
return new PasswordAuthentication(username, password);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
URL website = new URL(urlString);
|
||||||
|
ReadableByteChannel rbc;
|
||||||
|
rbc = Channels.newChannel(website.openStream());
|
||||||
|
FileOutputStream fos = new FileOutputStream(destination);
|
||||||
|
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
|
||||||
|
fos.close();
|
||||||
|
rbc.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Binary file not shown.
@ -0,0 +1,2 @@
|
|||||||
|
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.2/apache-maven-3.6.2-bin.zip
|
||||||
|
wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar
|
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"lockfileVersion": 1
|
||||||
|
}
|
@ -0,0 +1,137 @@
|
|||||||
|
<?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>
|
||||||
|
<parent>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-parent</artifactId>
|
||||||
|
<version>2.2.2.RELEASE</version>
|
||||||
|
<relativePath/> <!-- lookup parent from repository -->
|
||||||
|
</parent>
|
||||||
|
<groupId>com.jlwl</groupId>
|
||||||
|
<!-- 导入项目的名称 -->
|
||||||
|
<artifactId>house</artifactId>
|
||||||
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
|
<name>springboot-schema</name>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<java.version>1.8</java.version>
|
||||||
|
<fastjson.version>1.2.8</fastjson.version>
|
||||||
|
<maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.mybatis.spring.boot</groupId>
|
||||||
|
<artifactId>mybatis-spring-boot-starter</artifactId>
|
||||||
|
<version>2.1.1</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-jdbc</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>mysql</groupId>
|
||||||
|
<artifactId>mysql-connector-java</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.shiro</groupId>
|
||||||
|
<artifactId>shiro-spring</artifactId>
|
||||||
|
<version>1.3.2</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.baomidou</groupId>
|
||||||
|
<artifactId>mybatis-plus</artifactId>
|
||||||
|
<version>2.3</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.baomidou</groupId>
|
||||||
|
<artifactId>mybatisplus-spring-boot-starter</artifactId>
|
||||||
|
<version>1.0.5</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.google.protobuf</groupId>
|
||||||
|
<artifactId>protobuf-java</artifactId>
|
||||||
|
<version>3.10.0</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.commons</groupId>
|
||||||
|
<artifactId>commons-lang3</artifactId>
|
||||||
|
<version>3.0</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>javax.validation</groupId>
|
||||||
|
<artifactId>validation-api</artifactId>
|
||||||
|
<version>2.0.1.Final</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>commons-io</groupId>
|
||||||
|
<artifactId>commons-io</artifactId>
|
||||||
|
<version>2.5</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.hutool</groupId>
|
||||||
|
<artifactId>hutool-all</artifactId>
|
||||||
|
<version>4.0.12</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- FastJson -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba</groupId>
|
||||||
|
<artifactId>fastjson</artifactId>
|
||||||
|
<version>${fastjson.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.microsoft.sqlserver</groupId>
|
||||||
|
<artifactId>sqljdbc4</artifactId>
|
||||||
|
<scope>4.0</scope>
|
||||||
|
<version>4.0</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.microsoft.sqlserver</groupId>
|
||||||
|
<artifactId>mssql-jdbc</artifactId>
|
||||||
|
<version>6.2.0.jre8</version>
|
||||||
|
<scope>runtime</scope>
|
||||||
|
</dependency>
|
||||||
|
<!-- 百度人工智能 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.baidu.aip</groupId>
|
||||||
|
<artifactId>java-sdk</artifactId>
|
||||||
|
<version>4.4.1</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.junit.vintage</groupId>
|
||||||
|
<artifactId>junit-vintage-engine</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
</project>
|
@ -0,0 +1,21 @@
|
|||||||
|
package com;
|
||||||
|
|
||||||
|
import org.mybatis.spring.annotation.MapperScan;
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||||
|
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
|
||||||
|
|
||||||
|
@SpringBootApplication
|
||||||
|
@MapperScan(basePackages = {"com.dao"})
|
||||||
|
public class SpringbootSchemaApplication extends SpringBootServletInitializer{
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SpringApplication.run(SpringbootSchemaApplication.class, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected SpringApplicationBuilder configure(SpringApplicationBuilder applicationBuilder) {
|
||||||
|
return applicationBuilder.sources(SpringbootSchemaApplication.class);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
package com.annotation;
|
||||||
|
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 登录用户信息
|
||||||
|
*/
|
||||||
|
@Target(ElementType.PARAMETER)
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
public @interface APPLoginUser {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
package com.annotation;
|
||||||
|
|
||||||
|
import java.lang.annotation.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 忽略Token验证
|
||||||
|
*/
|
||||||
|
@Target(ElementType.METHOD)
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Documented
|
||||||
|
public @interface IgnoreAuth {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
package com.annotation;
|
||||||
|
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 登录用户信息
|
||||||
|
*/
|
||||||
|
@Target(ElementType.PARAMETER)
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
public @interface LoginUser {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,24 @@
|
|||||||
|
|
||||||
|
package com.config;
|
||||||
|
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.mapper.MetaObjectHandler;
|
||||||
|
import com.baomidou.mybatisplus.plugins.PaginationInterceptor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mybatis-plus配置
|
||||||
|
*/
|
||||||
|
@Configuration
|
||||||
|
public class MybatisPlusConfig {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页插件
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
public PaginationInterceptor paginationInterceptor() {
|
||||||
|
return new PaginationInterceptor();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,22 @@
|
|||||||
|
package com.utils;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
public class CommonUtil {
|
||||||
|
/**
|
||||||
|
* 获取随机字符串
|
||||||
|
*
|
||||||
|
* @param num
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String getRandomString(Integer num) {
|
||||||
|
String base = "abcdefghijklmnopqrstuvwxyz0123456789";
|
||||||
|
Random random = new Random();
|
||||||
|
StringBuffer sb = new StringBuffer();
|
||||||
|
for (int i = 0; i < num; i++) {
|
||||||
|
int number = random.nextInt(base.length());
|
||||||
|
sb.append(base.charAt(number));
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
package com.utils;
|
||||||
|
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 类说明 :
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class FileUtil {
|
||||||
|
public static byte[] FileToByte(File file) throws IOException {
|
||||||
|
// 将数据转为流
|
||||||
|
@SuppressWarnings("resource")
|
||||||
|
InputStream content = new FileInputStream(file);
|
||||||
|
ByteArrayOutputStream swapStream = new ByteArrayOutputStream();
|
||||||
|
byte[] buff = new byte[100];
|
||||||
|
int rc = 0;
|
||||||
|
while ((rc = content.read(buff, 0, 100)) > 0) {
|
||||||
|
swapStream.write(buff, 0, rc);
|
||||||
|
}
|
||||||
|
// 获得二进制数组
|
||||||
|
return swapStream.toByteArray();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,42 @@
|
|||||||
|
package com.utils;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.net.HttpURLConnection;
|
||||||
|
import java.net.URL;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* HttpClient工具类
|
||||||
|
*/
|
||||||
|
public class HttpClientUtils {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param uri
|
||||||
|
* @return String
|
||||||
|
* @description get请求方式
|
||||||
|
* @author: long.he01
|
||||||
|
*/
|
||||||
|
public static String doGet(String uri) {
|
||||||
|
|
||||||
|
StringBuilder result = new StringBuilder();
|
||||||
|
try {
|
||||||
|
String res = "";
|
||||||
|
URL url = new URL(uri);
|
||||||
|
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
||||||
|
BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));
|
||||||
|
String line;
|
||||||
|
while ((line = in.readLine()) != null) {
|
||||||
|
res += line+"\n";
|
||||||
|
}
|
||||||
|
in.close();
|
||||||
|
return res;
|
||||||
|
}catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,54 @@
|
|||||||
|
package com.utils;
|
||||||
|
|
||||||
|
public class JQPageInfo{
|
||||||
|
private Integer page;
|
||||||
|
|
||||||
|
private Integer limit;
|
||||||
|
|
||||||
|
private String sidx;
|
||||||
|
|
||||||
|
private String order;
|
||||||
|
|
||||||
|
private Integer offset;
|
||||||
|
|
||||||
|
public Integer getPage() {
|
||||||
|
return page;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPage(Integer page) {
|
||||||
|
this.page = page;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getLimit() {
|
||||||
|
return limit;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLimit(Integer limit) {
|
||||||
|
this.limit = limit;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSidx() {
|
||||||
|
return sidx;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSidx(String sidx) {
|
||||||
|
this.sidx = sidx;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getOrder() {
|
||||||
|
return order;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOrder(String order) {
|
||||||
|
this.order = order;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getOffset() {
|
||||||
|
return offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOffset(Integer offset) {
|
||||||
|
this.offset = offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
package com.utils;
|
||||||
|
|
||||||
|
import cn.hutool.crypto.digest.DigestUtil;
|
||||||
|
|
||||||
|
public class MD5Util {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param text明文
|
||||||
|
* @param key密钥
|
||||||
|
* @return 密文
|
||||||
|
*/
|
||||||
|
// 带秘钥加密
|
||||||
|
public static String md5(String text) {
|
||||||
|
// 加密后的字符串
|
||||||
|
String md5str = DigestUtil.md5Hex(text);
|
||||||
|
return md5str;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,184 @@
|
|||||||
|
package com.utils;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.mapper.Wrapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mybatis-Plus工具类
|
||||||
|
*/
|
||||||
|
public class MPUtil {
|
||||||
|
public static final char UNDERLINE = '_';
|
||||||
|
|
||||||
|
|
||||||
|
//mybatis plus allEQ 表达式转换
|
||||||
|
public static Map allEQMapPre(Object bean,String pre) {
|
||||||
|
Map<String, Object> map =BeanUtil.beanToMap(bean);
|
||||||
|
return camelToUnderlineMap(map,pre);
|
||||||
|
}
|
||||||
|
|
||||||
|
//mybatis plus allEQ 表达式转换
|
||||||
|
public static Map allEQMap(Object bean) {
|
||||||
|
Map<String, Object> map =BeanUtil.beanToMap(bean);
|
||||||
|
return camelToUnderlineMap(map,"");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Wrapper allLikePre(Wrapper wrapper,Object bean,String pre) {
|
||||||
|
Map<String, Object> map =BeanUtil.beanToMap(bean);
|
||||||
|
Map result = camelToUnderlineMap(map,pre);
|
||||||
|
|
||||||
|
return genLike(wrapper,result);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Wrapper allLike(Wrapper wrapper,Object bean) {
|
||||||
|
Map result = BeanUtil.beanToMap(bean, true, true);
|
||||||
|
return genLike(wrapper,result);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static Wrapper genLike( Wrapper wrapper,Map param) {
|
||||||
|
Iterator<Map.Entry<String, Object>> it = param.entrySet().iterator();
|
||||||
|
int i=0;
|
||||||
|
while (it.hasNext()) {
|
||||||
|
if(i>0) wrapper.and();
|
||||||
|
Map.Entry<String, Object> entry = it.next();
|
||||||
|
String key = entry.getKey();
|
||||||
|
String value = (String) entry.getValue();
|
||||||
|
wrapper.like(key, value);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
return wrapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Wrapper likeOrEq(Wrapper wrapper,Object bean) {
|
||||||
|
Map result = BeanUtil.beanToMap(bean, true, true);
|
||||||
|
return genLikeOrEq(wrapper,result);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Wrapper genLikeOrEq( Wrapper wrapper,Map param) {
|
||||||
|
Iterator<Map.Entry<String, Object>> it = param.entrySet().iterator();
|
||||||
|
int i=0;
|
||||||
|
while (it.hasNext()) {
|
||||||
|
if(i>0) wrapper.and();
|
||||||
|
Map.Entry<String, Object> entry = it.next();
|
||||||
|
String key = entry.getKey();
|
||||||
|
if(entry.getValue().toString().contains("%")) {
|
||||||
|
wrapper.like(key, entry.getValue().toString().replace("%", ""));
|
||||||
|
} else {
|
||||||
|
wrapper.eq(key, entry.getValue());
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
return wrapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Wrapper allEq(Wrapper wrapper,Object bean) {
|
||||||
|
Map result = BeanUtil.beanToMap(bean, true, true);
|
||||||
|
return genEq(wrapper,result);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static Wrapper genEq( Wrapper wrapper,Map param) {
|
||||||
|
Iterator<Map.Entry<String, Object>> it = param.entrySet().iterator();
|
||||||
|
int i=0;
|
||||||
|
while (it.hasNext()) {
|
||||||
|
if(i>0) wrapper.and();
|
||||||
|
Map.Entry<String, Object> entry = it.next();
|
||||||
|
String key = entry.getKey();
|
||||||
|
wrapper.eq(key, entry.getValue());
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
return wrapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static Wrapper between(Wrapper wrapper,Map<String, Object> params) {
|
||||||
|
for(String key : params.keySet()) {
|
||||||
|
String columnName = "";
|
||||||
|
if(key.endsWith("_start")) {
|
||||||
|
columnName = key.substring(0, key.indexOf("_start"));
|
||||||
|
if(StringUtils.isNotBlank(params.get(key).toString())) {
|
||||||
|
wrapper.ge(columnName, params.get(key));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(key.endsWith("_end")) {
|
||||||
|
columnName = key.substring(0, key.indexOf("_end"));
|
||||||
|
if(StringUtils.isNotBlank(params.get(key).toString())) {
|
||||||
|
wrapper.le(columnName, params.get(key));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return wrapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Wrapper sort(Wrapper wrapper,Map<String, Object> params) {
|
||||||
|
String order = "";
|
||||||
|
if(params.get("order") != null && StringUtils.isNotBlank(params.get("order").toString())) {
|
||||||
|
order = params.get("order").toString();
|
||||||
|
}
|
||||||
|
if(params.get("sort") != null && StringUtils.isNotBlank(params.get("sort").toString())) {
|
||||||
|
if(order.equalsIgnoreCase("desc")) {
|
||||||
|
wrapper.orderDesc(Arrays.asList(params.get("sort")));
|
||||||
|
} else {
|
||||||
|
wrapper.orderAsc(Arrays.asList(params.get("sort")));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return wrapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 驼峰格式字符串转换为下划线格式字符串
|
||||||
|
*
|
||||||
|
* @param param
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String camelToUnderline(String param) {
|
||||||
|
if (param == null || "".equals(param.trim())) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
int len = param.length();
|
||||||
|
StringBuilder sb = new StringBuilder(len);
|
||||||
|
for (int i = 0; i < len; i++) {
|
||||||
|
char c = param.charAt(i);
|
||||||
|
if (Character.isUpperCase(c)) {
|
||||||
|
sb.append(UNDERLINE);
|
||||||
|
sb.append(Character.toLowerCase(c));
|
||||||
|
} else {
|
||||||
|
sb.append(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] ages) {
|
||||||
|
System.out.println(camelToUnderline("ABCddfANM"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Map camelToUnderlineMap(Map param, String pre) {
|
||||||
|
|
||||||
|
Map<String, Object> newMap = new HashMap<String, Object>();
|
||||||
|
Iterator<Map.Entry<String, Object>> it = param.entrySet().iterator();
|
||||||
|
while (it.hasNext()) {
|
||||||
|
Map.Entry<String, Object> entry = it.next();
|
||||||
|
String key = entry.getKey();
|
||||||
|
String newKey = camelToUnderline(key);
|
||||||
|
if (pre.endsWith(".")) {
|
||||||
|
newMap.put(pre + newKey, entry.getValue());
|
||||||
|
} else if (StringUtils.isEmpty(pre)) {
|
||||||
|
newMap.put(newKey, entry.getValue());
|
||||||
|
} else {
|
||||||
|
|
||||||
|
newMap.put(pre + "." + newKey, entry.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return newMap;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,101 @@
|
|||||||
|
|
||||||
|
package com.utils;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.plugins.Page;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页工具类
|
||||||
|
*/
|
||||||
|
public class PageUtils implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
//总记录数
|
||||||
|
private long total;
|
||||||
|
//每页记录数
|
||||||
|
private int pageSize;
|
||||||
|
//总页数
|
||||||
|
private long totalPage;
|
||||||
|
//当前页数
|
||||||
|
private int currPage;
|
||||||
|
//列表数据
|
||||||
|
private List<?> list;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页
|
||||||
|
* @param list 列表数据
|
||||||
|
* @param totalCount 总记录数
|
||||||
|
* @param pageSize 每页记录数
|
||||||
|
* @param currPage 当前页数
|
||||||
|
*/
|
||||||
|
public PageUtils(List<?> list, int totalCount, int pageSize, int currPage) {
|
||||||
|
this.list = list;
|
||||||
|
this.total = totalCount;
|
||||||
|
this.pageSize = pageSize;
|
||||||
|
this.currPage = currPage;
|
||||||
|
this.totalPage = (int)Math.ceil((double)totalCount/pageSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页
|
||||||
|
*/
|
||||||
|
public PageUtils(Page<?> page) {
|
||||||
|
this.list = page.getRecords();
|
||||||
|
this.total = page.getTotal();
|
||||||
|
this.pageSize = page.getSize();
|
||||||
|
this.currPage = page.getCurrent();
|
||||||
|
this.totalPage = page.getPages();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 空数据的分页
|
||||||
|
*/
|
||||||
|
public PageUtils(Map<String, Object> params) {
|
||||||
|
Page page =new Query(params).getPage();
|
||||||
|
new PageUtils(page);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public int getPageSize() {
|
||||||
|
return pageSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPageSize(int pageSize) {
|
||||||
|
this.pageSize = pageSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCurrPage() {
|
||||||
|
return currPage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCurrPage(int currPage) {
|
||||||
|
this.currPage = currPage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<?> getList() {
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setList(List<?> list) {
|
||||||
|
this.list = list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getTotalPage() {
|
||||||
|
return totalPage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTotalPage(long totalPage) {
|
||||||
|
this.totalPage = totalPage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getTotal() {
|
||||||
|
return total;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTotal(long total) {
|
||||||
|
this.total = total;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,51 @@
|
|||||||
|
package com.utils;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回数据
|
||||||
|
*/
|
||||||
|
public class R extends HashMap<String, Object> {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
public R() {
|
||||||
|
put("code", 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static R error() {
|
||||||
|
return error(500, "未知异常,请联系管理员");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static R error(String msg) {
|
||||||
|
return error(500, msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static R error(int code, String msg) {
|
||||||
|
R r = new R();
|
||||||
|
r.put("code", code);
|
||||||
|
r.put("msg", msg);
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static R ok(String msg) {
|
||||||
|
R r = new R();
|
||||||
|
r.put("msg", msg);
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static R ok(Map<String, Object> map) {
|
||||||
|
R r = new R();
|
||||||
|
r.putAll(map);
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static R ok() {
|
||||||
|
return new R();
|
||||||
|
}
|
||||||
|
|
||||||
|
public R put(String key, Object value) {
|
||||||
|
super.put(key, value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,42 @@
|
|||||||
|
|
||||||
|
package com.utils;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
import com.entity.EIException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SQL过滤
|
||||||
|
*/
|
||||||
|
public class SQLFilter {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SQL注入过滤
|
||||||
|
* @param str 待验证的字符串
|
||||||
|
*/
|
||||||
|
public static String sqlInject(String str){
|
||||||
|
if(StringUtils.isBlank(str)){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
//去掉'|"|;|\字符
|
||||||
|
str = StringUtils.replace(str, "'", "");
|
||||||
|
str = StringUtils.replace(str, "\"", "");
|
||||||
|
str = StringUtils.replace(str, ";", "");
|
||||||
|
str = StringUtils.replace(str, "\\", "");
|
||||||
|
|
||||||
|
//转换成小写
|
||||||
|
str = str.toLowerCase();
|
||||||
|
|
||||||
|
//非法字符
|
||||||
|
String[] keywords = {"master", "truncate", "insert", "select", "delete", "update", "declare", "alter", "drop"};
|
||||||
|
|
||||||
|
//判断是否包含非法字符
|
||||||
|
for(String keyword : keywords){
|
||||||
|
if(str.indexOf(keyword) != -1){
|
||||||
|
throw new EIException("包含非法字符");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,43 @@
|
|||||||
|
|
||||||
|
package com.utils;
|
||||||
|
|
||||||
|
import org.springframework.beans.BeansException;
|
||||||
|
import org.springframework.context.ApplicationContext;
|
||||||
|
import org.springframework.context.ApplicationContextAware;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Spring Context 工具类
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class SpringContextUtils implements ApplicationContextAware {
|
||||||
|
public static ApplicationContext applicationContext;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setApplicationContext(ApplicationContext applicationContext)
|
||||||
|
throws BeansException {
|
||||||
|
SpringContextUtils.applicationContext = applicationContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Object getBean(String name) {
|
||||||
|
return applicationContext.getBean(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T> T getBean(String name, Class<T> requiredType) {
|
||||||
|
return applicationContext.getBean(name, requiredType);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean containsBean(String name) {
|
||||||
|
return applicationContext.containsBean(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isSingleton(String name) {
|
||||||
|
return applicationContext.isSingleton(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Class<? extends Object> getType(String name) {
|
||||||
|
return applicationContext.getType(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
package com;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
|
||||||
|
@SpringBootTest
|
||||||
|
class SpringbootSchemaApplicationTests {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void contextLoads() {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in new issue