提交代码
This commit is contained in:
parent
a9f255adde
commit
83a8b49fdf
25
.gitignore
vendored
Normal file
25
.gitignore
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
# Compiled class file
|
||||
*.class
|
||||
target
|
||||
|
||||
# Log file
|
||||
*.log
|
||||
|
||||
# BlueJ files
|
||||
*.ctxt
|
||||
|
||||
# Mobile Tools for Java (J2ME)
|
||||
.mtj.tmp/
|
||||
|
||||
# Package Files #
|
||||
*.jar
|
||||
*.war
|
||||
*.ear
|
||||
*.zip
|
||||
*.tar.gz
|
||||
*.rar
|
||||
*.iml
|
||||
.idea
|
||||
|
||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||
hs_err_pid*
|
83
README.md
83
README.md
@ -33,15 +33,82 @@
|
||||
|
||||
![](https://gitee.com/virus010101/linfeng-community/raw/master/images/showPic03.png)
|
||||
|
||||
#### 3.安装教程
|
||||
#### 3.安装教程
|
||||
|
||||
1. xxxx
|
||||
2. xxxx
|
||||
3. xxxx
|
||||
1. 配置数据库和redis。先启动redis,再启动后端api服务,数据库请使用MySQL5.7,其他版本可能会有问题
|
||||
|
||||
#### 其他说明
|
||||
![](https://gitee.com/virus010101/linfeng-community/raw/master/images/step1.png)
|
||||
|
||||
1. xxxx
|
||||
2. xxxx
|
||||
3. xxxx
|
||||
![](https://gitee.com/virus010101/linfeng-community/raw/master/images/step2.png)
|
||||
|
||||
2. 配置后台前端 先npm install 下载依赖后,再npm run dev即可。
|
||||
|
||||
![](https://gitee.com/virus010101/linfeng-community/raw/master/images/step3.png)
|
||||
|
||||
#### 4.必看说明
|
||||
|
||||
1. **后台管理系统和后台管理系统后端API已经全部开源**。
|
||||
|
||||
**移动端未开源**,需要源码联系客服。
|
||||
|
||||
![](https://gitee.com/virus010101/linfeng-community/raw/master/images/mine.png)
|
||||
|
||||
2. **后台前端的代码**在**\src\main\resources\static\linfeng-community-vue**目录下!
|
||||
|
||||
3. SQL文件免费,开源不易,**请左上角star后备注gitee的用户名加QQ群获取**
|
||||
|
||||
![](https://gitee.com/virus010101/linfeng-community/raw/master/images/qrcode.png)
|
||||
|
||||
#### 5.版本更新记录
|
||||
|
||||
2022.04.17
|
||||
|
||||
**V1.2.1发布**
|
||||
|
||||
1.新增防止重复提交注解
|
||||
|
||||
2.扩大匿名访问权限
|
||||
|
||||
3.优化小程序登录
|
||||
|
||||
4.新增后台前端面板统计数据
|
||||
|
||||
5.移动端用户手机号脱敏处理
|
||||
|
||||
6.新增帖子上下架处理
|
||||
|
||||
|
||||
|
||||
2022.04.04
|
||||
|
||||
**V1.2发布**
|
||||
|
||||
1.优化私聊模块
|
||||
|
||||
2.新增置顶功能
|
||||
|
||||
3.优化UI
|
||||
|
||||
4.优化消息已读未读的处理
|
||||
|
||||
5.其他bug修复
|
||||
|
||||
|
||||
|
||||
2022.03.05
|
||||
|
||||
**V1.1发布**
|
||||
|
||||
移动端适配H5
|
||||
|
||||
移动端分享功能优化
|
||||
|
||||
移动端其他bug修复
|
||||
|
||||
|
||||
|
||||
2022.01.29
|
||||
|
||||
**V1.0发布**
|
||||
|
||||
......
|
BIN
images/mine.jpg
Normal file
BIN
images/mine.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 160 KiB |
BIN
images/qrcode.jpg
Normal file
BIN
images/qrcode.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 70 KiB |
BIN
images/step1.png
Normal file
BIN
images/step1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 175 KiB |
BIN
images/step2.png
Normal file
BIN
images/step2.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 203 KiB |
BIN
images/step3.png
Normal file
BIN
images/step3.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 122 KiB |
323
pom.xml
Normal file
323
pom.xml
Normal file
@ -0,0 +1,323 @@
|
||||
<?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>io.linfeng</groupId>
|
||||
<artifactId>linfeng-community</artifactId>
|
||||
<version>3.0.0</version>
|
||||
<packaging>jar</packaging>
|
||||
<description>林风社交论坛项目</description>
|
||||
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.2.4.RELEASE</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<java.version>1.8</java.version>
|
||||
<mybatisplus.version>3.3.1</mybatisplus.version>
|
||||
<mysql.version>8.0.17</mysql.version>
|
||||
<mssql.version>4.0</mssql.version>
|
||||
<oracle.version>11.2.0.3</oracle.version>
|
||||
<druid.version>1.1.13</druid.version>
|
||||
<quartz.version>2.3.0</quartz.version>
|
||||
<commons.lang.version>2.6</commons.lang.version>
|
||||
<commons.fileupload.version>1.2.2</commons.fileupload.version>
|
||||
<commons.io.version>2.5</commons.io.version>
|
||||
<commons.codec.version>1.10</commons.codec.version>
|
||||
<commons.configuration.version>1.10</commons.configuration.version>
|
||||
<shiro.version>1.4.0</shiro.version>
|
||||
<jwt.version>0.7.0</jwt.version>
|
||||
<kaptcha.version>0.0.9</kaptcha.version>
|
||||
<qiniu.version>7.2.23</qiniu.version>
|
||||
<aliyun.oss.version>2.8.3</aliyun.oss.version>
|
||||
<qcloud.cos.version>4.4</qcloud.cos.version>
|
||||
<swagger.version>2.7.0</swagger.version>
|
||||
<joda.time.version>2.9.9</joda.time.version>
|
||||
<gson.version>2.8.5</gson.version>
|
||||
<fastjson.version>1.2.72</fastjson.version>
|
||||
<hutool.version>4.1.1</hutool.version>
|
||||
<lombok.version>1.18.4</lombok.version>
|
||||
<!--wagon plugin 配置-->
|
||||
<service-path>/work/project</service-path>
|
||||
<pack-name>${project.artifactId}-${project.version}.jar</pack-name>
|
||||
<remote-addr>127.0.0.1:22</remote-addr>
|
||||
<remote-username>root</remote-username>
|
||||
<remote-passwd>root</remote-passwd>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<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-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-aop</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-context-support</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-configuration-processor</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
<version>${mybatisplus.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-generator</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>${mysql.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>druid-spring-boot-starter</artifactId>
|
||||
<version>${druid.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.quartz-scheduler</groupId>
|
||||
<artifactId>quartz</artifactId>
|
||||
<version>${quartz.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>com.mchange</groupId>
|
||||
<artifactId>c3p0</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-lang</groupId>
|
||||
<artifactId>commons-lang</artifactId>
|
||||
<version>${commons.lang.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-fileupload</groupId>
|
||||
<artifactId>commons-fileupload</artifactId>
|
||||
<version>${commons.fileupload.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>${commons.io.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-codec</groupId>
|
||||
<artifactId>commons-codec</artifactId>
|
||||
<version>${commons.codec.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-configuration</groupId>
|
||||
<artifactId>commons-configuration</artifactId>
|
||||
<version>${commons.configuration.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.shiro</groupId>
|
||||
<artifactId>shiro-core</artifactId>
|
||||
<version>${shiro.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.shiro</groupId>
|
||||
<artifactId>shiro-spring</artifactId>
|
||||
<version>${shiro.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.jsonwebtoken</groupId>
|
||||
<artifactId>jjwt</artifactId>
|
||||
<version>${jwt.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.axet</groupId>
|
||||
<artifactId>kaptcha</artifactId>
|
||||
<version>${kaptcha.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger2</artifactId>
|
||||
<version>${swagger.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger-ui</artifactId>
|
||||
<version>${swagger.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.qiniu</groupId>
|
||||
<artifactId>qiniu-java-sdk</artifactId>
|
||||
<version>${qiniu.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.aliyun.oss</groupId>
|
||||
<artifactId>aliyun-sdk-oss</artifactId>
|
||||
<version>${aliyun.oss.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.qcloud</groupId>
|
||||
<artifactId>cos_api</artifactId>
|
||||
<version>${qcloud.cos.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-log4j12</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>joda-time</groupId>
|
||||
<artifactId>joda-time</artifactId>
|
||||
<version>${joda.time.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
<version>${gson.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>${fastjson.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-all</artifactId>
|
||||
<version>${hutool.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>${lombok.version}</version>
|
||||
</dependency>
|
||||
<!-- Swagger第三方ui依赖 -->
|
||||
<dependency>
|
||||
<groupId>com.github.xiaoymin</groupId>
|
||||
<artifactId>swagger-bootstrap-ui</artifactId>
|
||||
<version>1.9.6</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-all</artifactId>
|
||||
<version>4.5.7</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<finalName>${project.artifactId}</finalName>
|
||||
<extensions>
|
||||
<extension>
|
||||
<groupId>org.apache.maven.wagon</groupId>
|
||||
<artifactId>wagon-ssh</artifactId>
|
||||
<version>2.8</version>
|
||||
</extension>
|
||||
</extensions>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<fork>true</fork>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<!-- 跳过单元测试 -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<skipTests>true</skipTests>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>wagon-maven-plugin</artifactId>
|
||||
<version>1.0</version>
|
||||
<configuration>
|
||||
<fromFile>target/${pack-name}</fromFile>
|
||||
<url><![CDATA[scp://${remote-username}:${remote-passwd}@${remote-addr}${service-path}]]></url>
|
||||
<commands>
|
||||
<!-- Kill Old Process -->
|
||||
<command>kill -9 `ps -ef |grep ${project.artifactId}.jar|grep -v "grep" |awk '{print $2}'`</command>
|
||||
<!-- Restart jar package,write result into linfeng.log -->
|
||||
<command><![CDATA[nohup java -jar ${service-path}/${pack-name} --spring.profiles.active=test > ${service-path}/project.log 2>&1 & ]]></command>
|
||||
<command><![CDATA[netstat -nptl]]></command>
|
||||
<command><![CDATA[ps -ef | grep java | grep -v grep]]></command>
|
||||
</commands>
|
||||
<!-- 运行命令 mvn clean package wagon:upload-single wagon:sshexec-->
|
||||
<displayCommandOutputs>true</displayCommandOutputs>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>com.spotify</groupId>
|
||||
<artifactId>docker-maven-plugin</artifactId>
|
||||
<version>0.4.14</version>
|
||||
<!--<executions>-->
|
||||
<!--<execution>-->
|
||||
<!--<phase>package</phase>-->
|
||||
<!--<goals>-->
|
||||
<!--<goal>build</goal>-->
|
||||
<!--</goals>-->
|
||||
<!--</execution>-->
|
||||
<!--</executions>-->
|
||||
<configuration>
|
||||
<imageName>project/fast</imageName>
|
||||
<dockerDirectory>${project.basedir}</dockerDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<targetPath>/</targetPath>
|
||||
<directory>${project.build.directory}</directory>
|
||||
<include>${project.build.finalName}.jar</include>
|
||||
</resource>
|
||||
</resources>
|
||||
</configuration>
|
||||
<!-- 运行命令 mvn clean package docker:build 打包并生成docker镜像 -->
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>public</id>
|
||||
<name>aliyun nexus</name>
|
||||
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
|
||||
<releases>
|
||||
<enabled>true</enabled>
|
||||
</releases>
|
||||
</repository>
|
||||
</repositories>
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>public</id>
|
||||
<name>aliyun nexus</name>
|
||||
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
|
||||
<releases>
|
||||
<enabled>true</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
|
||||
</project>
|
19
src/main/java/io/linfeng/Applications.java
Normal file
19
src/main/java/io/linfeng/Applications.java
Normal file
@ -0,0 +1,19 @@
|
||||
|
||||
package io.linfeng;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.scheduling.annotation.EnableAsync;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
|
||||
|
||||
@EnableAsync
|
||||
@EnableTransactionManagement
|
||||
@SpringBootApplication
|
||||
public class Applications {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(Applications.class, args);
|
||||
}
|
||||
|
||||
}
|
20
src/main/java/io/linfeng/common/annotation/SysLog.java
Normal file
20
src/main/java/io/linfeng/common/annotation/SysLog.java
Normal file
@ -0,0 +1,20 @@
|
||||
|
||||
package io.linfeng.common.annotation;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* 系统日志注解
|
||||
*
|
||||
*/
|
||||
@Target(ElementType.METHOD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
public @interface SysLog {
|
||||
|
||||
String value() default "";
|
||||
}
|
38
src/main/java/io/linfeng/common/aspect/RedisAspect.java
Normal file
38
src/main/java/io/linfeng/common/aspect/RedisAspect.java
Normal file
@ -0,0 +1,38 @@
|
||||
|
||||
package io.linfeng.common.aspect;
|
||||
|
||||
import io.linfeng.common.exception.LinfengException;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.annotation.Around;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* Redis切面处理类
|
||||
*
|
||||
*/
|
||||
@Aspect
|
||||
@Configuration
|
||||
public class RedisAspect {
|
||||
private Logger logger = LoggerFactory.getLogger(getClass());
|
||||
//是否开启redis缓存 true开启 false关闭
|
||||
@Value("${spring.redis.open: false}")
|
||||
private boolean open;
|
||||
|
||||
@Around("execution(* io.linfeng.common.utils.RedisUtils.*(..))")
|
||||
public Object around(ProceedingJoinPoint point) throws Throwable {
|
||||
Object result = null;
|
||||
if(open){
|
||||
try{
|
||||
result = point.proceed();
|
||||
}catch (Exception e){
|
||||
logger.error("redis error", e);
|
||||
throw new LinfengException("Redis服务异常");
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
93
src/main/java/io/linfeng/common/aspect/SysLogAspect.java
Normal file
93
src/main/java/io/linfeng/common/aspect/SysLogAspect.java
Normal file
@ -0,0 +1,93 @@
|
||||
|
||||
package io.linfeng.common.aspect;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import io.linfeng.common.annotation.SysLog;
|
||||
import io.linfeng.common.utils.HttpContextUtils;
|
||||
import io.linfeng.common.utils.IPUtils;
|
||||
import io.linfeng.modules.sys.entity.SysLogEntity;
|
||||
import io.linfeng.modules.sys.entity.SysUserEntity;
|
||||
import io.linfeng.modules.sys.service.SysLogService;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.annotation.Around;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.annotation.Pointcut;
|
||||
import org.aspectj.lang.reflect.MethodSignature;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
/**
|
||||
* 系统日志,切面处理类
|
||||
*
|
||||
*/
|
||||
@Aspect
|
||||
@Component
|
||||
public class SysLogAspect {
|
||||
@Autowired
|
||||
private SysLogService sysLogService;
|
||||
|
||||
@Pointcut("@annotation(io.linfeng.common.annotation.SysLog)")
|
||||
public void logPointCut() {
|
||||
|
||||
}
|
||||
|
||||
@Around("logPointCut()")
|
||||
public Object around(ProceedingJoinPoint point) throws Throwable {
|
||||
long beginTime = System.currentTimeMillis();
|
||||
//执行方法
|
||||
Object result = point.proceed();
|
||||
//执行时长(毫秒)
|
||||
long time = System.currentTimeMillis() - beginTime;
|
||||
|
||||
//保存日志
|
||||
saveSysLog(point, time);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private void saveSysLog(ProceedingJoinPoint joinPoint, long time) {
|
||||
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
|
||||
Method method = signature.getMethod();
|
||||
|
||||
SysLogEntity sysLog = new SysLogEntity();
|
||||
SysLog syslog = method.getAnnotation(SysLog.class);
|
||||
if(syslog != null){
|
||||
//注解上的描述
|
||||
sysLog.setOperation(syslog.value());
|
||||
}
|
||||
|
||||
//请求的方法名
|
||||
String className = joinPoint.getTarget().getClass().getName();
|
||||
String methodName = signature.getName();
|
||||
sysLog.setMethod(className + "." + methodName + "()");
|
||||
|
||||
//请求的参数
|
||||
Object[] args = joinPoint.getArgs();
|
||||
try{
|
||||
String params = new Gson().toJson(args);
|
||||
sysLog.setParams(params);
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
|
||||
//获取request
|
||||
HttpServletRequest request = HttpContextUtils.getHttpServletRequest();
|
||||
//设置IP地址
|
||||
sysLog.setIp(IPUtils.getIpAddr(request));
|
||||
|
||||
//用户名
|
||||
String username = ((SysUserEntity) SecurityUtils.getSubject().getPrincipal()).getUsername();
|
||||
sysLog.setUsername(username);
|
||||
|
||||
sysLog.setTime(time);
|
||||
sysLog.setCreateDate(new Date());
|
||||
//保存系统日志
|
||||
sysLogService.save(sysLog);
|
||||
}
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
|
||||
package io.linfeng.common.exception;
|
||||
|
||||
/**
|
||||
* 自定义异常
|
||||
*
|
||||
*/
|
||||
public class LinfengException extends RuntimeException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String msg;
|
||||
private int code = 500;
|
||||
|
||||
public LinfengException(String msg) {
|
||||
super(msg);
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public LinfengException(String msg, Throwable e) {
|
||||
super(msg, e);
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public LinfengException(String msg, int code) {
|
||||
super(msg);
|
||||
this.msg = msg;
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public LinfengException(String msg, int code, Throwable e) {
|
||||
super(msg, e);
|
||||
this.msg = msg;
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
public void setMsg(String msg) {
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(int code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
|
||||
package io.linfeng.common.exception;
|
||||
|
||||
import io.linfeng.common.utils.R;
|
||||
import org.apache.shiro.authz.AuthorizationException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.dao.DuplicateKeyException;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
import org.springframework.web.servlet.NoHandlerFoundException;
|
||||
|
||||
/**
|
||||
* 异常处理器
|
||||
*
|
||||
*/
|
||||
@RestControllerAdvice
|
||||
public class LinfengExceptionHandler {
|
||||
private Logger logger = LoggerFactory.getLogger(getClass());
|
||||
|
||||
/**
|
||||
* 处理自定义异常
|
||||
*/
|
||||
@ExceptionHandler(LinfengException.class)
|
||||
public R handleRRException(LinfengException e){
|
||||
R r = new R();
|
||||
r.put("code", e.getCode());
|
||||
r.put("msg", e.getMessage());
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
@ExceptionHandler(NoHandlerFoundException.class)
|
||||
public R handlerNoFoundException(Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
return R.error(404, "路径不存在,请检查路径是否正确");
|
||||
}
|
||||
|
||||
@ExceptionHandler(DuplicateKeyException.class)
|
||||
public R handleDuplicateKeyException(DuplicateKeyException e){
|
||||
logger.error(e.getMessage(), e);
|
||||
return R.error("数据库中已存在该记录");
|
||||
}
|
||||
|
||||
@ExceptionHandler(AuthorizationException.class)
|
||||
public R handleAuthorizationException(AuthorizationException e){
|
||||
logger.error(e.getMessage(), e);
|
||||
return R.error("没有权限,请联系管理员授权");
|
||||
}
|
||||
|
||||
@ExceptionHandler(Exception.class)
|
||||
public R handleException(Exception e){
|
||||
logger.error(e.getMessage(), e);
|
||||
return R.error();
|
||||
}
|
||||
}
|
@ -0,0 +1,79 @@
|
||||
package io.linfeng.common.response;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import io.linfeng.modules.admin.entity.AppUserEntity;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author linfeng
|
||||
* @email 3582996245@qq.com
|
||||
* @date 2022-01-25 18:51:22
|
||||
*/
|
||||
@Data
|
||||
public class AppChildrenCommentResponse implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 父级id
|
||||
*/
|
||||
private Integer pid;
|
||||
/**
|
||||
* 评论类型:1帖子
|
||||
*/
|
||||
private Integer type;
|
||||
/**
|
||||
* 评论作者ID
|
||||
*/
|
||||
private Long uid;
|
||||
/**
|
||||
* 被回复用户ID
|
||||
*/
|
||||
private Integer toUid;
|
||||
/**
|
||||
* 评论帖子ID
|
||||
*/
|
||||
private Long postId;
|
||||
/**
|
||||
* 评论内容
|
||||
*/
|
||||
private String content;
|
||||
/**
|
||||
* 评论状态
|
||||
*/
|
||||
private Integer status;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 被回复用户信息
|
||||
*/
|
||||
private AppUserEntity toUser;
|
||||
|
||||
/**
|
||||
* 评论用户信息
|
||||
*/
|
||||
private AppUserEntity userInfo;
|
||||
|
||||
/**
|
||||
* 点赞数
|
||||
*/
|
||||
private Integer thumbs;
|
||||
|
||||
/**
|
||||
* 评论是否点赞
|
||||
*/
|
||||
private Boolean isThumbs;
|
||||
}
|
@ -0,0 +1,80 @@
|
||||
package io.linfeng.common.response;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.linfeng.modules.admin.entity.AppUserEntity;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author linfeng
|
||||
* @email 3582996245@qq.com
|
||||
* @date 2022-01-25 18:51:22
|
||||
*/
|
||||
@Data
|
||||
public class AppCommentResponse implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 父级id
|
||||
*/
|
||||
private Integer pid;
|
||||
/**
|
||||
* 评论类型:1帖子
|
||||
*/
|
||||
private Integer type;
|
||||
/**
|
||||
* 评论作者ID
|
||||
*/
|
||||
private Long uid;
|
||||
/**
|
||||
* 被回复用户ID
|
||||
*/
|
||||
private Integer toUid;
|
||||
/**
|
||||
* 评论帖子ID
|
||||
*/
|
||||
private Long postId;
|
||||
/**
|
||||
* 评论内容
|
||||
*/
|
||||
private String content;
|
||||
/**
|
||||
* 评论状态
|
||||
*/
|
||||
private Integer status;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 子评论
|
||||
*/
|
||||
private List<AppChildrenCommentResponse> children;
|
||||
|
||||
/**
|
||||
* 评论用户信息
|
||||
*/
|
||||
private AppUserEntity userInfo;
|
||||
|
||||
/**
|
||||
* 点赞数
|
||||
*/
|
||||
private Integer thumbs;
|
||||
|
||||
/**
|
||||
* 评论是否点赞
|
||||
*/
|
||||
private Boolean isThumbs;
|
||||
}
|
@ -0,0 +1,96 @@
|
||||
package io.linfeng.common.response;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Data
|
||||
public class AppUserInfoResponse implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
private Integer uid;
|
||||
/**
|
||||
* 手机号
|
||||
*/
|
||||
private String mobile;
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
private String username;
|
||||
|
||||
/**
|
||||
* 头像
|
||||
*/
|
||||
private String avatar;
|
||||
/**
|
||||
* 性别(0未知,1男,2女)
|
||||
*/
|
||||
private Integer gender;
|
||||
/**
|
||||
* 省份
|
||||
*/
|
||||
private String province;
|
||||
/**
|
||||
* 城市
|
||||
*/
|
||||
private String city;
|
||||
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
private Integer status;
|
||||
/**
|
||||
* 个性签名
|
||||
*/
|
||||
private String intro;
|
||||
/**
|
||||
* 积分
|
||||
*/
|
||||
private Integer integral;
|
||||
/**
|
||||
* 最后登录ip
|
||||
*/
|
||||
private String lastLoginIp;
|
||||
/**
|
||||
* 用户标签
|
||||
*/
|
||||
private List<String> tagStr;
|
||||
/**
|
||||
* 0为普通用户 1官方账号 2马甲虚拟用户
|
||||
*/
|
||||
private Integer type;
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 创建的圈子
|
||||
*/
|
||||
private List<TopicListResponse> createTopicList;
|
||||
|
||||
/**
|
||||
* 关注
|
||||
*/
|
||||
private Integer follow;
|
||||
/**
|
||||
* 粉丝
|
||||
*/
|
||||
private Integer fans;
|
||||
/**
|
||||
* 动态数
|
||||
*/
|
||||
private Integer postNum;
|
||||
|
||||
/**
|
||||
* 是否关注
|
||||
*/
|
||||
private Boolean isFollow;
|
||||
|
||||
}
|
@ -0,0 +1,78 @@
|
||||
package io.linfeng.common.response;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Data
|
||||
public class AppUserResponse implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
private Integer uid;
|
||||
/**
|
||||
* 手机号
|
||||
*/
|
||||
private String mobile;
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
private String username;
|
||||
|
||||
/**
|
||||
* 头像
|
||||
*/
|
||||
private String avatar;
|
||||
/**
|
||||
* 性别(0未知,1男,2女)
|
||||
*/
|
||||
private Integer gender;
|
||||
/**
|
||||
* 省份
|
||||
*/
|
||||
private String province;
|
||||
/**
|
||||
* 城市
|
||||
*/
|
||||
private String city;
|
||||
|
||||
/**
|
||||
* 个性签名
|
||||
*/
|
||||
private String intro;
|
||||
/**
|
||||
* 积分
|
||||
*/
|
||||
private Integer integral;
|
||||
/**
|
||||
* 最后登录ip
|
||||
*/
|
||||
private String lastLoginIp;
|
||||
/**
|
||||
* 用户标签
|
||||
*/
|
||||
private List<String> tagStr;
|
||||
/**
|
||||
* 0为普通用户 1官方账号 2马甲虚拟用户
|
||||
*/
|
||||
private Integer type;
|
||||
/**
|
||||
* 关注
|
||||
*/
|
||||
private Integer follow;
|
||||
/**
|
||||
* 粉丝
|
||||
*/
|
||||
private Integer fans;
|
||||
/**
|
||||
* 动态数
|
||||
*/
|
||||
private Integer postNum;
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package io.linfeng.common.response;
|
||||
|
||||
import io.linfeng.modules.admin.entity.AppUserEntity;
|
||||
import io.linfeng.modules.admin.entity.MessageEntity;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author linfeng
|
||||
* @date 2022/1/28 16:47
|
||||
*/
|
||||
@Data
|
||||
public class ChatMessageListResponse implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Integer count;
|
||||
|
||||
private AppUserEntity userInfo;
|
||||
|
||||
private MessageEntity msg;
|
||||
}
|
@ -0,0 +1,72 @@
|
||||
package io.linfeng.common.response;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Data
|
||||
public class ClassTopicImageResponse implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 圈子id
|
||||
*/
|
||||
private Integer id;
|
||||
/**
|
||||
* 创建用户id
|
||||
*/
|
||||
private Integer uid;
|
||||
/**
|
||||
* 分类id
|
||||
*/
|
||||
private Integer cateId;
|
||||
/**
|
||||
* 圈子名称
|
||||
*/
|
||||
private String topicName;
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String description;
|
||||
/**
|
||||
* logo
|
||||
*/
|
||||
private String coverImage;
|
||||
/**
|
||||
* 背景图
|
||||
*/
|
||||
private String bgImage;
|
||||
/**
|
||||
* 推荐类型:0 不推荐, 1首页推荐, 2圈子页推荐
|
||||
*/
|
||||
private Integer topType;
|
||||
/**
|
||||
* 圈子状态:0 正常 ,1禁用
|
||||
*/
|
||||
private Integer status;
|
||||
/**
|
||||
* 是否首页推荐圈子内容
|
||||
*/
|
||||
private Integer indexRecommend;
|
||||
/**
|
||||
* 加入人数
|
||||
*/
|
||||
private Integer userNum;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 圈子内动态数量
|
||||
*/
|
||||
private Integer postNum;
|
||||
|
||||
/**
|
||||
* 三张展示图片
|
||||
*/
|
||||
List<String> imgList;
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
package io.linfeng.common.response;
|
||||
|
||||
import io.linfeng.modules.admin.entity.AppUserEntity;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
@Data
|
||||
public class DiscussDetailResponse implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 话题标签id
|
||||
*/
|
||||
private Integer id;
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
private Integer uid;
|
||||
/**
|
||||
* 圈子id
|
||||
*/
|
||||
private Integer topicId;
|
||||
/**
|
||||
* 标题
|
||||
*/
|
||||
private String title;
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String introduce;
|
||||
/**
|
||||
* 浏览量
|
||||
*/
|
||||
private Integer readCount;
|
||||
/**
|
||||
* 推荐位置:0 不推荐 1 首页推荐
|
||||
*/
|
||||
private Integer topType;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
private AppUserEntity userInfo;
|
||||
|
||||
/**
|
||||
* 帖子数量
|
||||
*/
|
||||
private Integer postCount;
|
||||
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
package io.linfeng.common.response;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 主页统计数据对象
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
@ApiModel(value="HomeRateResponse对象", description="主页统计数据对象")
|
||||
public class HomeRateResponse implements Serializable {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
@ApiModelProperty(value = "今日销售额")
|
||||
private Object sales;
|
||||
|
||||
@ApiModelProperty(value = "昨日销售额")
|
||||
private Object yesterdaySales;
|
||||
|
||||
@ApiModelProperty(value = "今日访问量")
|
||||
private Object pageviews;
|
||||
|
||||
@ApiModelProperty(value = "昨日访问量")
|
||||
private Object yesterdayPageviews;
|
||||
|
||||
@ApiModelProperty(value = "今日订单量")
|
||||
private Object orderNum;
|
||||
|
||||
@ApiModelProperty(value = "昨日订单量")
|
||||
private Object yesterdayOrderNum;
|
||||
|
||||
@ApiModelProperty(value = "今日新增用户")
|
||||
private Object newUserNum;
|
||||
|
||||
@ApiModelProperty(value = "昨日新增用户")
|
||||
private Object yesterdayNewUserNum;
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
package io.linfeng.common.response;
|
||||
|
||||
import io.linfeng.modules.admin.entity.AppUserEntity;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
@Data
|
||||
public class MessageListResponse implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 消息id
|
||||
*/
|
||||
private Integer mId;
|
||||
/**
|
||||
* 发送者uid
|
||||
*/
|
||||
private Integer fromUid;
|
||||
/**
|
||||
* 接收者uid
|
||||
*/
|
||||
private Integer toUid;
|
||||
/**
|
||||
* 帖子id
|
||||
*/
|
||||
private Integer postId;
|
||||
/**
|
||||
* 推送标题
|
||||
*/
|
||||
private String title;
|
||||
/**
|
||||
* 消息内容
|
||||
*/
|
||||
private String content;
|
||||
/**
|
||||
* 0未读,1已读
|
||||
*/
|
||||
private Integer status;
|
||||
/**
|
||||
* 1为点赞,2为评论 3为收藏 4为关注 5为推送文章 6私聊
|
||||
*/
|
||||
private Integer type;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 用户信息
|
||||
*/
|
||||
private AppUserEntity userInfo;
|
||||
|
||||
/**
|
||||
* 帖子的内容
|
||||
*/
|
||||
private String postContent;
|
||||
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
package io.linfeng.common.response;
|
||||
|
||||
import io.linfeng.modules.admin.entity.AppUserEntity;
|
||||
import io.linfeng.modules.admin.entity.MessageEntity;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author linfeng
|
||||
* @date 2022/2/8 21:25
|
||||
*/
|
||||
@Data
|
||||
public class MessageNoticeResponse implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Integer mId;
|
||||
/**
|
||||
* 发送者uid
|
||||
*/
|
||||
private Integer fromUid;
|
||||
/**
|
||||
* 接收者uid
|
||||
*/
|
||||
private Integer toUid;
|
||||
/**
|
||||
* 帖子id
|
||||
*/
|
||||
private Integer postId;
|
||||
/**
|
||||
* 推送标题
|
||||
*/
|
||||
private String title;
|
||||
/**
|
||||
* 消息内容
|
||||
*/
|
||||
private String content;
|
||||
/**
|
||||
* 0未读,1已读
|
||||
*/
|
||||
private Integer status;
|
||||
/**
|
||||
* 1为点赞,2为评论 3为收藏 4为关注 5为推送文章 6私聊
|
||||
*/
|
||||
private Integer type;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
private AppUserEntity userInfo;
|
||||
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
package io.linfeng.common.response;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Data
|
||||
public class MessageNumberResponse implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 总消息数量
|
||||
*/
|
||||
private Integer allCount;
|
||||
/**
|
||||
* 评论数
|
||||
*/
|
||||
private Integer comment;
|
||||
/**
|
||||
* 关注数
|
||||
*/
|
||||
private Integer follow;
|
||||
/**
|
||||
* 帖子评论点赞数
|
||||
*/
|
||||
private Integer thumbCount;
|
||||
|
||||
/**
|
||||
* 推送通知消息
|
||||
*/
|
||||
private List<MessageNoticeResponse> articleMsgList;
|
||||
|
||||
|
||||
private List<ChatMessageListResponse> chatMsgList;
|
||||
|
||||
|
||||
}
|
109
src/main/java/io/linfeng/common/response/PostDetailResponse.java
Normal file
109
src/main/java/io/linfeng/common/response/PostDetailResponse.java
Normal file
@ -0,0 +1,109 @@
|
||||
package io.linfeng.common.response;
|
||||
|
||||
import io.linfeng.modules.admin.entity.AppUserEntity;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Data
|
||||
public class PostDetailResponse implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private Integer id;
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
private Integer uid;
|
||||
/**
|
||||
* 圈子id
|
||||
*/
|
||||
private Integer topicId;
|
||||
/**
|
||||
* 话题id
|
||||
*/
|
||||
private Integer discussId;
|
||||
/**
|
||||
* 投票id
|
||||
*/
|
||||
private Integer voteId;
|
||||
/**
|
||||
* 标题
|
||||
*/
|
||||
private String title;
|
||||
/**
|
||||
* 内容
|
||||
*/
|
||||
private String content;
|
||||
/**
|
||||
* 文件
|
||||
*/
|
||||
// private String media;
|
||||
List<String> media;
|
||||
/**
|
||||
* 浏览量
|
||||
*/
|
||||
private Integer readCount;
|
||||
/**
|
||||
* 置顶
|
||||
*/
|
||||
private Integer postTop;
|
||||
/**
|
||||
* 帖子类型:1 图文 ,2视频 ,3文章,4投票
|
||||
*/
|
||||
private Integer type;
|
||||
/**
|
||||
* 地址名称
|
||||
*/
|
||||
private String address;
|
||||
/**
|
||||
* 经度
|
||||
*/
|
||||
private Double longitude;
|
||||
/**
|
||||
* 纬度
|
||||
*/
|
||||
private Double latitude;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 点赞数
|
||||
*/
|
||||
private Integer collectionCount;
|
||||
/**
|
||||
* 评论数
|
||||
*/
|
||||
private Integer commentCount;
|
||||
/**
|
||||
* 动态是否点赞
|
||||
*/
|
||||
private Boolean isCollection;
|
||||
|
||||
/**
|
||||
* 是否关注
|
||||
*/
|
||||
private Boolean isFollow;
|
||||
|
||||
/**
|
||||
* 评论是否点赞
|
||||
*/
|
||||
private Boolean isThumb;
|
||||
|
||||
/**
|
||||
* 圈子信息
|
||||
*/
|
||||
private TopicDetailResponse topicInfo;
|
||||
/**
|
||||
* 用户信息
|
||||
*/
|
||||
private AppUserEntity userInfo;
|
||||
|
||||
}
|
110
src/main/java/io/linfeng/common/response/PostListResponse.java
Normal file
110
src/main/java/io/linfeng/common/response/PostListResponse.java
Normal file
@ -0,0 +1,110 @@
|
||||
package io.linfeng.common.response;
|
||||
|
||||
import io.linfeng.modules.admin.entity.AppUserEntity;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Data
|
||||
public class PostListResponse implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private Integer id;
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
private Integer uid;
|
||||
/**
|
||||
* 圈子id
|
||||
*/
|
||||
private Integer topicId;
|
||||
/**
|
||||
* 话题id
|
||||
*/
|
||||
private Integer discussId;
|
||||
/**
|
||||
* 投票id
|
||||
*/
|
||||
private Integer voteId;
|
||||
/**
|
||||
* 标题
|
||||
*/
|
||||
private String title;
|
||||
/**
|
||||
* 内容
|
||||
*/
|
||||
private String content;
|
||||
/**
|
||||
* 文件
|
||||
*/
|
||||
// private String media;
|
||||
List<String> media;
|
||||
/**
|
||||
* 浏览量
|
||||
*/
|
||||
private Integer readCount;
|
||||
/**
|
||||
* 置顶
|
||||
*/
|
||||
private Integer postTop;
|
||||
/**
|
||||
* 帖子类型:1 图文 ,2视频 ,3文章,4投票
|
||||
*/
|
||||
private Integer type;
|
||||
/**
|
||||
* 地址名称
|
||||
*/
|
||||
private String address;
|
||||
/**
|
||||
* 经度
|
||||
*/
|
||||
private Double longitude;
|
||||
/**
|
||||
* 纬度
|
||||
*/
|
||||
private Double latitude;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 点赞数
|
||||
*/
|
||||
private Integer collectionCount;
|
||||
/**
|
||||
* 评论数
|
||||
*/
|
||||
private Integer commentCount;
|
||||
|
||||
/**
|
||||
* 用户信息
|
||||
*/
|
||||
private AppUserEntity userInfo;
|
||||
|
||||
/**
|
||||
* 话题
|
||||
*/
|
||||
private String discussTitle;
|
||||
|
||||
/**
|
||||
* 动态是否点赞
|
||||
*/
|
||||
private Boolean isCollection;
|
||||
/**
|
||||
* 投票
|
||||
*/
|
||||
private Object voteInfo;
|
||||
|
||||
/**
|
||||
* 圈子名称
|
||||
*/
|
||||
private String topicName;
|
||||
|
||||
}
|
@ -0,0 +1,121 @@
|
||||
package io.linfeng.common.response;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import io.linfeng.modules.admin.entity.AppUserEntity;
|
||||
import io.linfeng.modules.admin.entity.DiscussEntity;
|
||||
import io.linfeng.modules.app.entity.TopicTopEntity;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author linfeng
|
||||
* @date 2022/1/23 17:28
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
@ApiModel(value="TopicDetailResponse", description="圈子详情响应对象")
|
||||
public class TopicDetailResponse implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
/**
|
||||
* 圈子id
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Integer id;
|
||||
/**
|
||||
* 创建用户id
|
||||
*/
|
||||
private Integer uid;
|
||||
/**
|
||||
* 分类id
|
||||
*/
|
||||
private Integer cateId;
|
||||
/**
|
||||
* 圈子名称
|
||||
*/
|
||||
private String topicName;
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String description;
|
||||
/**
|
||||
* logo
|
||||
*/
|
||||
private String coverImage;
|
||||
/**
|
||||
* 背景图
|
||||
*/
|
||||
private String bgImage;
|
||||
/**
|
||||
* 推荐类型:0 不推荐, 1首页推荐, 2圈子页推荐
|
||||
*/
|
||||
private Integer topType;
|
||||
/**
|
||||
* 圈子状态:0 正常 ,1禁用
|
||||
*/
|
||||
private Integer status;
|
||||
/**
|
||||
* 是否首页推荐圈子内容
|
||||
*/
|
||||
private Integer indexRecommend;
|
||||
/**
|
||||
* 加入人数
|
||||
*/
|
||||
private Integer userNum;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 用户详情
|
||||
*/
|
||||
private AppUserEntity userInfo;
|
||||
|
||||
|
||||
/**
|
||||
* 圈子的内容数量
|
||||
*/
|
||||
private Integer postCount;
|
||||
/**
|
||||
* 已加入圈子的人数
|
||||
*/
|
||||
private Integer userCount;
|
||||
|
||||
/**
|
||||
* $topicPostCount = Db::name("post")->where("topic_id",$topicId)->count();
|
||||
* $topicUserCount = Db::name("user_topic")->where("topic_id",$topicId)->count();
|
||||
*/
|
||||
|
||||
/**
|
||||
* 圈子的管理员
|
||||
*/
|
||||
private List<AppUserEntity> adminList;
|
||||
|
||||
/**
|
||||
* 是否为圈主或管理员
|
||||
*/
|
||||
private Boolean isAdmin;
|
||||
|
||||
/**
|
||||
* 圈子话题
|
||||
*/
|
||||
private List<DiscussEntity> discussList;
|
||||
/**
|
||||
* 是否加入
|
||||
*/
|
||||
private Boolean isJoin;
|
||||
/**
|
||||
* 置顶内容
|
||||
*/
|
||||
private List<TopicTopEntity> topPost;
|
||||
|
||||
}
|
@ -0,0 +1,93 @@
|
||||
package io.linfeng.common.response;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import io.linfeng.modules.admin.entity.AppUserEntity;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author linfeng
|
||||
* @date 2022/1/21 17:28
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
@ApiModel(value="TopicListResponse对象", description="文章响应对象")
|
||||
public class TopicListResponse implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
/**
|
||||
* 圈子id
|
||||
*/
|
||||
// @ApiModelProperty(value = "圈子id")
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Integer id;
|
||||
/**
|
||||
* 创建用户id
|
||||
*/
|
||||
private Integer uid;
|
||||
/**
|
||||
* 分类id
|
||||
*/
|
||||
private Integer cateId;
|
||||
/**
|
||||
* 圈子名称
|
||||
*/
|
||||
private String topicName;
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String description;
|
||||
/**
|
||||
* logo
|
||||
*/
|
||||
private String coverImage;
|
||||
/**
|
||||
* 背景图
|
||||
*/
|
||||
private String bgImage;
|
||||
/**
|
||||
* 推荐类型:0 不推荐, 1首页推荐, 2圈子页推荐
|
||||
*/
|
||||
private Integer topType;
|
||||
/**
|
||||
* 圈子状态:0 正常 ,1禁用
|
||||
*/
|
||||
private Integer status;
|
||||
/**
|
||||
* 是否首页推荐圈子内容
|
||||
*/
|
||||
private Integer indexRecommend;
|
||||
/**
|
||||
* 加入人数
|
||||
*/
|
||||
private Integer userNum;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
|
||||
private AppUserEntity userInfo;
|
||||
|
||||
/**
|
||||
* 圈子的内容数量
|
||||
*/
|
||||
private Integer postCount;
|
||||
/**
|
||||
* 已加入圈子的人数
|
||||
*/
|
||||
private Integer userCount;
|
||||
|
||||
/**
|
||||
* $topicPostCount = Db::name("post")->where("topic_id",$topicId)->count();
|
||||
* $topicUserCount = Db::name("user_topic")->where("topic_id",$topicId)->count();
|
||||
*/
|
||||
}
|
116
src/main/java/io/linfeng/common/response/TopicUserResponse.java
Normal file
116
src/main/java/io/linfeng/common/response/TopicUserResponse.java
Normal file
@ -0,0 +1,116 @@
|
||||
package io.linfeng.common.response;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author linfeng
|
||||
* @email 3582996245@qq.com
|
||||
* @date 2022-01-20 12:10:43
|
||||
*/
|
||||
@Data
|
||||
@JsonIgnoreProperties(value = {"password"})
|
||||
public class TopicUserResponse implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
@TableId
|
||||
private Integer uid;
|
||||
/**
|
||||
* 手机号
|
||||
*/
|
||||
private String mobile;
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
private String username;
|
||||
/**
|
||||
* 密码
|
||||
*/
|
||||
private String password;
|
||||
/**
|
||||
* 用户组
|
||||
*/
|
||||
private Integer groupId;
|
||||
/**
|
||||
* 头像
|
||||
*/
|
||||
private String avatar;
|
||||
/**
|
||||
* 性别(0未知,1男,2女)
|
||||
*/
|
||||
private Integer gender;
|
||||
/**
|
||||
* 省份
|
||||
*/
|
||||
private String province;
|
||||
/**
|
||||
* 城市
|
||||
*/
|
||||
private String city;
|
||||
/**
|
||||
* 小程序openid
|
||||
*/
|
||||
private String openid;
|
||||
/**
|
||||
* 公众号openid
|
||||
*/
|
||||
private String mpOpenid;
|
||||
/**
|
||||
* unionid
|
||||
*/
|
||||
private String unionid;
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
private Integer status;
|
||||
/**
|
||||
* 个性签名
|
||||
*/
|
||||
private String intro;
|
||||
/**
|
||||
* 积分
|
||||
*/
|
||||
private Integer integral;
|
||||
/**
|
||||
* 最后登录ip
|
||||
*/
|
||||
private String lastLoginIp;
|
||||
/**
|
||||
* 用户标签
|
||||
*/
|
||||
private String tagStr;
|
||||
/**
|
||||
* 0为普通用户 1官方账号 2马甲虚拟用户
|
||||
*/
|
||||
private Integer type;
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private Date updateTime;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 是否为圈主或管理员
|
||||
*/
|
||||
private Boolean isAdmin;
|
||||
|
||||
/**
|
||||
* 0 关注
|
||||
* 1 互相关注
|
||||
* 2 已关注
|
||||
*/
|
||||
private Integer hasFollow;
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
package io.linfeng.common.thread;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.scheduling.annotation.AsyncConfigurer;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
|
||||
/**
|
||||
* 异步任务线程池装配类
|
||||
* @author linfeng
|
||||
* @date 2022/2/20 22:04
|
||||
*/
|
||||
@Slf4j
|
||||
@Configuration
|
||||
public class AsyncTaskExecutePool implements AsyncConfigurer {
|
||||
|
||||
/** 注入配置类 */
|
||||
private final AsyncTaskProperties config;
|
||||
|
||||
public AsyncTaskExecutePool(AsyncTaskProperties config) {
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Executor getAsyncExecutor() {
|
||||
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
|
||||
//核心线程池大小
|
||||
executor.setCorePoolSize(config.getCorePoolSize());
|
||||
//最大线程数
|
||||
executor.setMaxPoolSize(config.getMaxPoolSize());
|
||||
//队列容量
|
||||
executor.setQueueCapacity(config.getQueueCapacity());
|
||||
//活跃时间
|
||||
executor.setKeepAliveSeconds(config.getKeepAliveSeconds());
|
||||
//线程名字前缀
|
||||
executor.setThreadNamePrefix("el-async-");
|
||||
// setRejectedExecutionHandler:当pool已经达到max size的时候,如何处理新任务
|
||||
// CallerRunsPolicy:不在新线程中执行任务,而是由调用者所在的线程来执行
|
||||
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
|
||||
executor.initialize();
|
||||
return executor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
|
||||
return (throwable, method, objects) -> {
|
||||
log.error("===="+throwable.getMessage()+"====", throwable);
|
||||
log.error("exception method:"+method.getName());
|
||||
};
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package io.linfeng.common.thread;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 线程池配置属性类
|
||||
* @author linfeng
|
||||
* @date 2022/2/20 22:04
|
||||
*/
|
||||
@Data
|
||||
@Component
|
||||
@ConfigurationProperties(prefix = "task.pool")
|
||||
public class AsyncTaskProperties {
|
||||
|
||||
private int corePoolSize;
|
||||
|
||||
private int maxPoolSize;
|
||||
|
||||
private int keepAliveSeconds;
|
||||
|
||||
private int queueCapacity;
|
||||
}
|
102
src/main/java/io/linfeng/common/utils/AppPageUtils.java
Normal file
102
src/main/java/io/linfeng/common/utils/AppPageUtils.java
Normal file
@ -0,0 +1,102 @@
|
||||
|
||||
package io.linfeng.common.utils;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* App端分页工具类
|
||||
*
|
||||
*/
|
||||
public class AppPageUtils implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
/**
|
||||
* 总记录数/最后一页
|
||||
*/
|
||||
private int last_page;
|
||||
/**
|
||||
* 每页记录数
|
||||
*/
|
||||
private int per_page;
|
||||
/**
|
||||
* 总页数
|
||||
*/
|
||||
private int total;
|
||||
/**
|
||||
* 当前页数
|
||||
*/
|
||||
private int current_page;
|
||||
/**
|
||||
* 列表数据
|
||||
*/
|
||||
private List<?> data;
|
||||
|
||||
/**
|
||||
* 分页
|
||||
* @param list 列表数据
|
||||
* @param totalCount 总记录数
|
||||
* @param pageSize 每页记录数
|
||||
* @param currPage 当前页数
|
||||
*/
|
||||
public AppPageUtils(List<?> list, int totalCount, int pageSize, int currPage) {
|
||||
this.data = list;
|
||||
this.last_page = totalCount;
|
||||
this.per_page = pageSize;
|
||||
this.current_page = currPage;
|
||||
this.total = (int)Math.ceil((double)totalCount/pageSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*/
|
||||
public AppPageUtils(IPage<?> page) {
|
||||
this.data = page.getRecords();
|
||||
this.last_page = (int)page.getTotal();
|
||||
this.per_page = (int)page.getSize();
|
||||
this.current_page = (int)page.getCurrent();
|
||||
this.total = (int)page.getPages();
|
||||
}
|
||||
|
||||
|
||||
public int getLast_page() {
|
||||
return last_page;
|
||||
}
|
||||
|
||||
public void setLast_page(int last_page) {
|
||||
this.last_page = last_page;
|
||||
}
|
||||
|
||||
public int getPer_page() {
|
||||
return per_page;
|
||||
}
|
||||
|
||||
public void setPer_page(int per_page) {
|
||||
this.per_page = per_page;
|
||||
}
|
||||
|
||||
public int getTotal() {
|
||||
return total;
|
||||
}
|
||||
|
||||
public void setTotal(int total) {
|
||||
this.total = total;
|
||||
}
|
||||
|
||||
public int getCurrent_page() {
|
||||
return current_page;
|
||||
}
|
||||
|
||||
public void setCurrent_page(int current_page) {
|
||||
this.current_page = current_page;
|
||||
}
|
||||
|
||||
public List<?> getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(List<?> data) {
|
||||
this.data = data;
|
||||
}
|
||||
}
|
18
src/main/java/io/linfeng/common/utils/ConfigConstant.java
Normal file
18
src/main/java/io/linfeng/common/utils/ConfigConstant.java
Normal file
@ -0,0 +1,18 @@
|
||||
|
||||
package io.linfeng.common.utils;
|
||||
|
||||
/**
|
||||
* 系统参数相关Key
|
||||
*
|
||||
*/
|
||||
public class ConfigConstant {
|
||||
/**
|
||||
* 云存储配置KEY
|
||||
*/
|
||||
public final static String CLOUD_STORAGE_CONFIG_KEY = "CLOUD_STORAGE_CONFIG_KEY";
|
||||
/**
|
||||
* 微信小程序配置信息头
|
||||
*/
|
||||
public final static String MINIAPP = "miniapp";
|
||||
|
||||
}
|
168
src/main/java/io/linfeng/common/utils/Constant.java
Normal file
168
src/main/java/io/linfeng/common/utils/Constant.java
Normal file
@ -0,0 +1,168 @@
|
||||
|
||||
package io.linfeng.common.utils;
|
||||
|
||||
/**
|
||||
* 常量
|
||||
*
|
||||
*/
|
||||
public class Constant {
|
||||
/** 超级管理员ID */
|
||||
public static final int SUPER_ADMIN = 1;
|
||||
/**
|
||||
* 当前页码
|
||||
*/
|
||||
public static final String PAGE = "page";
|
||||
/**
|
||||
* 每页显示记录数
|
||||
*/
|
||||
public static final String LIMIT = "limit";
|
||||
/**
|
||||
* 排序字段
|
||||
*/
|
||||
public static final String ORDER_FIELD = "sidx";
|
||||
/**
|
||||
* 排序方式
|
||||
*/
|
||||
public static final String ORDER = "order";
|
||||
/**
|
||||
* 升序
|
||||
*/
|
||||
public static final String ASC = "asc";
|
||||
|
||||
|
||||
public static final String CLASSID = "classId";
|
||||
|
||||
|
||||
public static final String ORDER_DESC_ID = "id desc";
|
||||
|
||||
|
||||
public static final String ORDER_DESC_READCOUNT = "read_count desc";
|
||||
|
||||
public static final Integer NOT_READ = 0;
|
||||
public static final Integer HAS_READ = 1;
|
||||
|
||||
/**
|
||||
* 圈子是否禁用
|
||||
*/
|
||||
public static final Integer TOPIC_NORMAL = 0;
|
||||
public static final Integer TOPIC_BANNER = 1;
|
||||
/**
|
||||
* 敏感词是否开启审核
|
||||
*/
|
||||
public static final Integer SENSITIVE_CLOSE = 0;
|
||||
public static final Integer SENSITIVE_OPEN = 1;
|
||||
/**
|
||||
* 敏感词处理措施 1-禁止发布 2-需审核
|
||||
*/
|
||||
public static final Integer DEAL_BANNER = 1;
|
||||
public static final Integer DEAL_EXAMINE = 2;
|
||||
|
||||
/**
|
||||
* 1为点赞,2为评论 3为收藏 4为关注 5为推送通知 6私聊
|
||||
*/
|
||||
public static final Integer STAR = 1;
|
||||
public static final Integer COMMENT = 2;
|
||||
public static final Integer COLLECT = 3;
|
||||
public static final Integer WATCH = 4;
|
||||
public static final Integer PUSHARTICLE = 5;
|
||||
public static final Integer CHAT = 6;
|
||||
|
||||
public static final String TITLE_WATCH = "关注通知";
|
||||
public static final String TITLE_COMMENT = "评论通知";
|
||||
public static final String TITLE_STAR = "点赞通知";
|
||||
public static final String TITLE_COLLECT = "点赞收藏通知";
|
||||
public static final String TITLE_CHAT = "私聊通知";
|
||||
public static final String TITLE_VIOLATION = "违规通知";
|
||||
|
||||
|
||||
public static final String CONTENT_WATCH = "用户【{}】关注了你";
|
||||
public static final String CONTENT_STAR = "用户【{}】点赞了你的评论:{}";
|
||||
public static final String CONTENT_COMMENT = "用户【{}】评论了你的动态[{}]:{}";
|
||||
public static final String CONTENT_COMMENT_REPLY = "用户【{}】回复了你在动态[{}]下的评论:{}";
|
||||
public static final String CONTENT_POST_STAR = "用户【{}】点赞收藏了你的动态:{}";
|
||||
public static final String ADMIN_POST_DOWN = "你的动态【{}】由于违反社区规定已被删除";
|
||||
/**
|
||||
* 菜单类型
|
||||
*/
|
||||
public enum MenuType {
|
||||
/**
|
||||
* 目录
|
||||
*/
|
||||
CATALOG(0),
|
||||
/**
|
||||
* 菜单
|
||||
*/
|
||||
MENU(1),
|
||||
/**
|
||||
* 按钮
|
||||
*/
|
||||
BUTTON(2);
|
||||
|
||||
private int value;
|
||||
|
||||
MenuType(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 定时任务状态
|
||||
*
|
||||
* @author chenshun
|
||||
* @email sunlightcs@gmail.com
|
||||
* @date 2016年12月3日 上午12:07:22
|
||||
*/
|
||||
public enum ScheduleStatus {
|
||||
/**
|
||||
* 正常
|
||||
*/
|
||||
NORMAL(0),
|
||||
/**
|
||||
* 暂停
|
||||
*/
|
||||
PAUSE(1);
|
||||
|
||||
private int value;
|
||||
|
||||
ScheduleStatus(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 云服务商
|
||||
*/
|
||||
public enum CloudService {
|
||||
/**
|
||||
* 七牛云
|
||||
*/
|
||||
QINIU(1),
|
||||
/**
|
||||
* 阿里云
|
||||
*/
|
||||
ALIYUN(2),
|
||||
/**
|
||||
* 腾讯云
|
||||
*/
|
||||
QCLOUD(3);
|
||||
|
||||
private int value;
|
||||
|
||||
CloudService(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
37
src/main/java/io/linfeng/common/utils/CopyPageQueryUtil.java
Normal file
37
src/main/java/io/linfeng/common/utils/CopyPageQueryUtil.java
Normal file
@ -0,0 +1,37 @@
|
||||
package io.linfeng.common.utils;
|
||||
|
||||
import org.springframework.beans.BeanUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 分页查询复制响应对象封装
|
||||
* @author linfeng
|
||||
* @date 2022/1/23 18:02
|
||||
*/
|
||||
public class CopyPageQueryUtil {
|
||||
|
||||
public static AppPageUtils copyPageQuery(AppPageUtils page, Object object) {
|
||||
List<?> list = page.getData();
|
||||
List<Object> responseList = new ArrayList<>();
|
||||
list.forEach(l -> {
|
||||
Object objects = new Object();
|
||||
BeanUtils.copyProperties(l, objects);
|
||||
responseList.add(objects);
|
||||
});
|
||||
page.setData(responseList);
|
||||
return page;
|
||||
}
|
||||
|
||||
public static List<?> copyPageQueryList(AppPageUtils page, Object object) {
|
||||
List<?> list = page.getData();
|
||||
List<Object> responseList = new ArrayList<>();
|
||||
list.forEach(l -> {
|
||||
Object objects = new Object();
|
||||
BeanUtils.copyProperties(l, objects);
|
||||
responseList.add(objects);
|
||||
});
|
||||
return responseList;
|
||||
}
|
||||
}
|
514
src/main/java/io/linfeng/common/utils/DateUtil.java
Normal file
514
src/main/java/io/linfeng/common/utils/DateUtil.java
Normal file
@ -0,0 +1,514 @@
|
||||
package io.linfeng.common.utils;
|
||||
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Date工具类
|
||||
* @author linfeng
|
||||
* @date 2022/1/20 13:38
|
||||
*/
|
||||
public final class DateUtil {
|
||||
|
||||
public static final String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss";
|
||||
public static final String DATE_FORMAT_UTC = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'";
|
||||
public static final String DATE_FORMAT_DATE = "yyyy-MM-dd";
|
||||
public static final String DATE_FORMAT_YEAR = "yyyy";
|
||||
public static final String DATE_FORMAT_MONTH_DATE = "MM-dd";
|
||||
public static final String DATE_FORMAT_MONTH = "yyyy-MM";
|
||||
public static final String DATE_TIME_FORMAT_NUM = "yyyyMMddHHmmss";
|
||||
public static final String DATE_FORMAT_NUM = "yyyyMMdd";
|
||||
public static final String DATE_FORMAT_START = "yyyy-MM-dd 00:00:00";
|
||||
public static final String DATE_FORMAT_END = "yyyy-MM-dd 23:59:59";
|
||||
public static final String DATE_FORMAT_MONTH_START = "yyyy-MM-01 00:00:00";
|
||||
public static final String DATE_FORMAT_YEAR_START = "yyyy-01-01 00:00:00";
|
||||
public static final String DATE_FORMAT_YEAR_END = "yyyy-12-31 23:59:59";
|
||||
public static final String DATE_FORMAT_HHMMSS = "HH:mm:ss";
|
||||
public static final String DATE_FORMAT_START_PEREND = "00:00:00";
|
||||
public static final String DATE_FORMAT_END_PEREND = "23:59:59";
|
||||
public static final String DATE_FORMAT_HHMM = "yyyy-MM-dd HH:mm";
|
||||
|
||||
private DateUtil() {
|
||||
throw new IllegalStateException("Utility class");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前日期,指定格式
|
||||
* 描述:<描述函数实现的功能>.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static String nowDate() {
|
||||
return nowDate(DATE_FORMAT_NUM);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前年,指定格式
|
||||
* 描述:<描述函数实现的功能>.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static String nowYear() {
|
||||
Calendar cal = Calendar.getInstance();
|
||||
return cal.get(Calendar.YEAR) + "";
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取上一年,指定格式
|
||||
* 描述:<描述函数实现的功能>.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static String lastYear() {
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.add(Calendar.YEAR, -1);
|
||||
return cal.get(Calendar.YEAR) + "";
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前日期,指定格式
|
||||
* 描述:<描述函数实现的功能>.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static Date nowDateTime() {
|
||||
return strToDate(nowDateTimeStr(), DATE_FORMAT);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前日期,指定格式
|
||||
* 描述:<描述函数实现的功能>.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static String nowDateTimeStr() {
|
||||
return nowDate(DATE_FORMAT);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前日期,指定格式
|
||||
* 描述:<描述函数实现的功能>.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static String nowDate(String DATE_FORMAT) {
|
||||
SimpleDateFormat dft = new SimpleDateFormat(DATE_FORMAT);
|
||||
return dft.format(new Date());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前日期,指定格式
|
||||
* 描述:<描述函数实现的功能>.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static String nowDateTime(String DATE_FORMAT) {
|
||||
SimpleDateFormat dft = new SimpleDateFormat(DATE_FORMAT);
|
||||
return dft.format(new Date());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前日期,指定格式
|
||||
* 描述:<描述函数实现的功能>.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static Integer getNowTime() {
|
||||
long t = (System.currentTimeMillis()/1000L);
|
||||
return Integer.parseInt(String.valueOf(t));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前时间戳(秒级)
|
||||
* @return
|
||||
*/
|
||||
public static Long getTime() {
|
||||
return (System.currentTimeMillis()/1000L);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前日期,指定格式
|
||||
* 描述:<描述函数实现的功能>.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static Date nowDateTimeReturnDate(String DATE_FORMAT) {
|
||||
SimpleDateFormat dft = new SimpleDateFormat(DATE_FORMAT);
|
||||
return strToDate(dft.format(new Date()), DATE_FORMAT);
|
||||
}
|
||||
|
||||
/**
|
||||
* convert a date to string in a specifies fromat.
|
||||
*
|
||||
* @param date
|
||||
* @param DATE_FORMAT
|
||||
* @return
|
||||
*/
|
||||
public static String dateToStr(Date date, String DATE_FORMAT) {
|
||||
if (date == null) {
|
||||
return null;
|
||||
}
|
||||
SimpleDateFormat myFormat = new SimpleDateFormat(DATE_FORMAT);
|
||||
return myFormat.format(date);
|
||||
}
|
||||
|
||||
/**
|
||||
* parse a String to Date in a specifies fromat.
|
||||
*
|
||||
* @param dateStr
|
||||
* @param DATE_FORMAT
|
||||
* @return
|
||||
* @throws ParseException
|
||||
*/
|
||||
public static Date strToDate(String dateStr, String DATE_FORMAT) {
|
||||
SimpleDateFormat myFormat = new SimpleDateFormat(DATE_FORMAT);
|
||||
try {
|
||||
return myFormat.parse(dateStr);
|
||||
} catch (ParseException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* date add Second
|
||||
*
|
||||
* @param date
|
||||
* @param num
|
||||
* @return
|
||||
*/
|
||||
public static Date addSecond(Date date, int num) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(date);
|
||||
calendar.add(Calendar.SECOND, num);
|
||||
return calendar.getTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* date add Second return String
|
||||
*
|
||||
* @param date
|
||||
* @param num
|
||||
* @return
|
||||
*/
|
||||
public static String addSecond(Date date, int num, String DATE_FORMAT) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(date);
|
||||
calendar.add(Calendar.SECOND, num);
|
||||
return dateToStr(calendar.getTime(), DATE_FORMAT);
|
||||
}
|
||||
|
||||
/**
|
||||
* 指定日期加上天数后的日期
|
||||
*
|
||||
* @param num 为增加的天数
|
||||
* @param newDate 创建时间
|
||||
* @return
|
||||
*/
|
||||
public static final String addDay(String newDate, int num, String pattern) {
|
||||
SimpleDateFormat format = new SimpleDateFormat(pattern);
|
||||
try {
|
||||
Date currdate = format.parse(newDate);
|
||||
Calendar ca = Calendar.getInstance();
|
||||
ca.setTime(currdate);
|
||||
ca.add(Calendar.DATE, num);
|
||||
return format.format(ca.getTime());
|
||||
} catch (ParseException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 指定日期加上天数后的日期
|
||||
*
|
||||
* @param num 为增加的天数
|
||||
* @param newDate 创建时间
|
||||
* @return
|
||||
*/
|
||||
public static final String addDay(Date newDate, int num, String pattern) {
|
||||
SimpleDateFormat format = new SimpleDateFormat(pattern);
|
||||
Calendar ca = Calendar.getInstance();
|
||||
ca.setTime(newDate);
|
||||
ca.add(Calendar.DATE, num);
|
||||
return format.format(ca.getTime());
|
||||
}
|
||||
|
||||
/**
|
||||
* convert long to date
|
||||
*
|
||||
* @param date 待转换时间戳
|
||||
* @return 转换后时间
|
||||
*/
|
||||
public static Date timeStamp11ToDate(Integer date) {
|
||||
return new Date(date);
|
||||
}
|
||||
|
||||
/**
|
||||
* convert long to date string
|
||||
*
|
||||
* @param date 待转换时间戳
|
||||
* @param DATE_FORMAT 格式化时间
|
||||
* @return 格式化后的时间
|
||||
*/
|
||||
public static String timeStamp11ToDate(Integer date, String DATE_FORMAT) {
|
||||
return dateToStr(new Date(date), DATE_FORMAT);
|
||||
}
|
||||
|
||||
/**
|
||||
* compare two date String with a pattern
|
||||
*
|
||||
* @param date1
|
||||
* @param date2
|
||||
* @param pattern
|
||||
* @return
|
||||
*/
|
||||
public static int compareDate(String date1, String date2, String pattern) {
|
||||
SimpleDateFormat DATE_FORMAT = new SimpleDateFormat(pattern);
|
||||
try {
|
||||
Date dt1 = DATE_FORMAT.parse(date1);
|
||||
Date dt2 = DATE_FORMAT.parse(date2);
|
||||
if (dt1.getTime() > dt2.getTime()) {
|
||||
return 1;
|
||||
} else if (dt1.getTime() < dt2.getTime()) {
|
||||
return -1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查日期格式是否合法
|
||||
* @param date
|
||||
* @param style
|
||||
* @return
|
||||
*/
|
||||
public static boolean checkDateFormat(String date, String style) {
|
||||
SimpleDateFormat DATE_FORMAT = new SimpleDateFormat(style);
|
||||
try {
|
||||
// 设置lenient为false.
|
||||
// 否则SimpleDateFormat会比较宽松地验证日期,比如2007/02/29会被接受,并转换成2007/03/01
|
||||
DATE_FORMAT.setLenient(false);
|
||||
DATE_FORMAT.parse(date);
|
||||
return true;
|
||||
} catch (ParseException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算两个时间之间的天数差
|
||||
* @param beforeDay 开始时间
|
||||
* @param afterDay 结束时间
|
||||
* @return 相差天数
|
||||
*/
|
||||
public static long getTwoDateDays(Date beforeDay, Date afterDay) {
|
||||
SimpleDateFormat sm = new SimpleDateFormat(DATE_FORMAT_NUM);
|
||||
long days = -1;
|
||||
try {
|
||||
days = (sm.parse(sm.format(afterDay)).getTime() - sm.parse(sm.format(beforeDay)).getTime()) / (1000 * 3600 * 24);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return days;
|
||||
}
|
||||
|
||||
|
||||
//获取时间戳11位
|
||||
public static int getSecondTimestamp(Date date){
|
||||
if (null == date) {
|
||||
return 0;
|
||||
}
|
||||
String timestamp = String.valueOf(date.getTime()/1000);
|
||||
return Integer.parseInt(timestamp);
|
||||
}
|
||||
|
||||
//获取时间戳11位
|
||||
public static int getSecondTimestamp(String date){
|
||||
if (null == date) {
|
||||
return 0;
|
||||
}
|
||||
Date date1 = strToDate(date, DATE_FORMAT);
|
||||
if(date1 == null){
|
||||
return 0;
|
||||
}
|
||||
String timestamp = String.valueOf(date1.getTime()/1000);
|
||||
return Integer.parseInt(timestamp);
|
||||
}
|
||||
|
||||
//获取时间戳10位
|
||||
public static int getSecondTimestamp(Long timeMillis){
|
||||
if (null == timeMillis) {
|
||||
return 0;
|
||||
}
|
||||
String timestamp = String.valueOf(timeMillis / 1000);
|
||||
return Integer.parseInt(timestamp);
|
||||
}
|
||||
|
||||
//获取时间戳11位
|
||||
public static int getSecondTimestamp(){
|
||||
Date date = strToDate(nowDateTime(DATE_FORMAT), DATE_FORMAT);
|
||||
if (null == date) {
|
||||
return 0;
|
||||
}
|
||||
String timestamp = String.valueOf(date.getTime()/1000);
|
||||
return Integer.parseInt(timestamp);
|
||||
}
|
||||
|
||||
/** 获得昨天日期:yyyy-MM-dd HH:mm:ss */
|
||||
public static String getYesterdayStr() {
|
||||
Calendar c = Calendar.getInstance();
|
||||
c.add(Calendar.DATE, -1);
|
||||
SimpleDateFormat startSdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
return startSdf.format(c.getTime());
|
||||
}
|
||||
|
||||
/** 获得本周第一天:yyyy-MM-dd HH:mm:ss */
|
||||
public static String getWeekStartDay() {
|
||||
Calendar c = Calendar.getInstance();
|
||||
c.add(Calendar.WEEK_OF_MONTH, 0);
|
||||
c.set(Calendar.DAY_OF_WEEK, 2);
|
||||
SimpleDateFormat startSdf = new SimpleDateFormat("yyyy-MM-dd 00:00:00");
|
||||
return startSdf.format(c.getTime());
|
||||
}
|
||||
|
||||
/** 获得本周最后一天:yyyy-MM-dd HH:mm:ss */
|
||||
public static String getWeekEndDay() {
|
||||
return addDay(getWeekStartDay(), 7, DATE_FORMAT);
|
||||
}
|
||||
|
||||
/** 获得上周第一天:yyyy-MM-dd HH:mm:ss */
|
||||
public static String getLastWeekStartDay() {
|
||||
return addDay(getWeekStartDay(), -7, DATE_FORMAT);
|
||||
}
|
||||
|
||||
/** 获得上周最后一天:yyyy-MM-dd HH:mm:ss */
|
||||
public static String getLastWeekEndDay() {
|
||||
return addDay(getLastWeekStartDay(), 7, DATE_FORMAT);
|
||||
}
|
||||
|
||||
/** 获得本月最后一天:yyyy-MM-dd HH:mm:ss */
|
||||
public static String getMonthEndDay() {
|
||||
Calendar c = Calendar.getInstance();
|
||||
c.set(Calendar.DAY_OF_MONTH, c.getActualMaximum(Calendar.DAY_OF_MONTH));
|
||||
SimpleDateFormat endSdf = new SimpleDateFormat("yyyy-MM-dd 23:59:59");
|
||||
return endSdf.format(c.getTime());
|
||||
}
|
||||
|
||||
/** 获得上月第一天:yyyy-MM-dd HH:mm:ss */
|
||||
public static String getLastMonthStartDay() {
|
||||
Calendar c = Calendar.getInstance();
|
||||
c.add(Calendar.MONTH, -1);
|
||||
c.set(Calendar.DAY_OF_MONTH, 1);
|
||||
SimpleDateFormat startSdf = new SimpleDateFormat("yyyy-MM-01 00:00:00");
|
||||
return startSdf.format(c.getTime());
|
||||
}
|
||||
|
||||
/** 获得上月最后一天:yyyy-MM-dd HH:mm:ss */
|
||||
public static String getLastMonthEndDay() {
|
||||
Calendar c = Calendar.getInstance();
|
||||
c.add(Calendar.MONTH, -1);
|
||||
c.set(Calendar.DAY_OF_MONTH, c.getActualMaximum(Calendar.DAY_OF_MONTH));
|
||||
SimpleDateFormat endSdf = new SimpleDateFormat("yyyy-MM-dd 23:59:59");
|
||||
return endSdf.format(c.getTime());
|
||||
}
|
||||
|
||||
/** 获得上年第一天:yyyy-MM-dd HH:mm:ss */
|
||||
public static String getLastYearStartDay() {
|
||||
Calendar c = Calendar.getInstance();
|
||||
c.add(Calendar.YEAR, -1);
|
||||
SimpleDateFormat startSdf = new SimpleDateFormat("yyyy-01-01 00:00:00");
|
||||
return startSdf.format(c.getTime());
|
||||
}
|
||||
|
||||
/** 获得上年最后一天:yyyy-MM-dd HH:mm:ss */
|
||||
public static String getLastYearEndDay() {
|
||||
Calendar c = Calendar.getInstance();
|
||||
c.add(Calendar.YEAR, -1);
|
||||
SimpleDateFormat endSdf = new SimpleDateFormat("yyyy-12-31 23:59:59");
|
||||
return endSdf.format(c.getTime());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 两个日期之前的相差天数
|
||||
* @param starDate 开始日期
|
||||
* @param endDate 结束日期
|
||||
* @return 相差天数
|
||||
*/
|
||||
public static int daysBetween(Date starDate,Date endDate){
|
||||
|
||||
Calendar cal = Calendar.getInstance();
|
||||
|
||||
cal.setTime(starDate);
|
||||
|
||||
long time1 = cal.getTimeInMillis();
|
||||
|
||||
cal.setTime(endDate);
|
||||
|
||||
long time2 = cal.getTimeInMillis();
|
||||
|
||||
long between_days=(time2-time1)/(1000*3600*24);
|
||||
|
||||
return Integer.parseInt(String.valueOf(between_days));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定日期指定格式字符串
|
||||
*
|
||||
* @param dateStr
|
||||
* @param DATE_FORMAT
|
||||
* @return
|
||||
* @throws ParseException
|
||||
*/
|
||||
public static String appointedDayStrToFormatStr(String dateStr, String STR_DATE_FORMAT, String DATE_FORMAT) {
|
||||
Date date = DateUtil.strToDate(dateStr, STR_DATE_FORMAT);
|
||||
return DateUtil.dateToStr(date, DATE_FORMAT);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前时间小时
|
||||
* @return 当前时间小时 默认24小时
|
||||
*/
|
||||
public static int getCurrentHour(){
|
||||
int hour = Calendar.getInstance().get(Calendar.HOUR_OF_DAY);
|
||||
return hour;
|
||||
}
|
||||
|
||||
/**
|
||||
* 13位时间戳转字符串
|
||||
* @param timestamp
|
||||
* @param dateFormat
|
||||
* @return
|
||||
*/
|
||||
public static String timestamp2DateStr(Long timestamp, String dateFormat) {
|
||||
if (ObjectUtil.isNull(timestamp)) {
|
||||
return "";
|
||||
}
|
||||
if (StrUtil.isBlank(dateFormat)) {
|
||||
dateFormat = DATE_FORMAT;
|
||||
}
|
||||
Date date = new Date(timestamp);
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(dateFormat);
|
||||
return simpleDateFormat.format(date);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
158
src/main/java/io/linfeng/common/utils/DateUtils.java
Normal file
158
src/main/java/io/linfeng/common/utils/DateUtils.java
Normal file
@ -0,0 +1,158 @@
|
||||
|
||||
package io.linfeng.common.utils;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.LocalDate;
|
||||
import org.joda.time.format.DateTimeFormat;
|
||||
import org.joda.time.format.DateTimeFormatter;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 日期处理
|
||||
*
|
||||
*/
|
||||
public class DateUtils {
|
||||
/** 时间格式(yyyy-MM-dd) */
|
||||
public final static String DATE_PATTERN = "yyyy-MM-dd";
|
||||
/** 时间格式(yyyy-MM-dd HH:mm:ss) */
|
||||
public final static String DATE_TIME_PATTERN = "yyyy-MM-dd HH:mm:ss";
|
||||
|
||||
/**
|
||||
* 日期格式化 日期格式为:yyyy-MM-dd
|
||||
* @param date 日期
|
||||
* @return 返回yyyy-MM-dd格式日期
|
||||
*/
|
||||
public static String format(Date date) {
|
||||
return format(date, DATE_PATTERN);
|
||||
}
|
||||
|
||||
/**
|
||||
* 日期格式化 日期格式为:yyyy-MM-dd
|
||||
* @param date 日期
|
||||
* @param pattern 格式,如:DateUtils.DATE_TIME_PATTERN
|
||||
* @return 返回yyyy-MM-dd格式日期
|
||||
*/
|
||||
public static String format(Date date, String pattern) {
|
||||
if(date != null){
|
||||
SimpleDateFormat df = new SimpleDateFormat(pattern);
|
||||
return df.format(date);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 字符串转换成日期
|
||||
* @param strDate 日期字符串
|
||||
* @param pattern 日期的格式,如:DateUtils.DATE_TIME_PATTERN
|
||||
*/
|
||||
public static Date stringToDate(String strDate, String pattern) {
|
||||
if (StringUtils.isBlank(strDate)){
|
||||
return null;
|
||||
}
|
||||
|
||||
DateTimeFormatter fmt = DateTimeFormat.forPattern(pattern);
|
||||
return fmt.parseLocalDateTime(strDate).toDate();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据周数,获取开始日期、结束日期
|
||||
* @param week 周期 0本周,-1上周,-2上上周,1下周,2下下周
|
||||
* @return 返回date[0]开始日期、date[1]结束日期
|
||||
*/
|
||||
public static Date[] getWeekStartAndEnd(int week) {
|
||||
DateTime dateTime = new DateTime();
|
||||
LocalDate date = new LocalDate(dateTime.plusWeeks(week));
|
||||
|
||||
date = date.dayOfWeek().withMinimumValue();
|
||||
Date beginDate = date.toDate();
|
||||
Date endDate = date.plusDays(6).toDate();
|
||||
return new Date[]{beginDate, endDate};
|
||||
}
|
||||
|
||||
/**
|
||||
* 对日期的【秒】进行加/减
|
||||
*
|
||||
* @param date 日期
|
||||
* @param seconds 秒数,负数为减
|
||||
* @return 加/减几秒后的日期
|
||||
*/
|
||||
public static Date addDateSeconds(Date date, int seconds) {
|
||||
DateTime dateTime = new DateTime(date);
|
||||
return dateTime.plusSeconds(seconds).toDate();
|
||||
}
|
||||
|
||||
/**
|
||||
* 对日期的【分钟】进行加/减
|
||||
*
|
||||
* @param date 日期
|
||||
* @param minutes 分钟数,负数为减
|
||||
* @return 加/减几分钟后的日期
|
||||
*/
|
||||
public static Date addDateMinutes(Date date, int minutes) {
|
||||
DateTime dateTime = new DateTime(date);
|
||||
return dateTime.plusMinutes(minutes).toDate();
|
||||
}
|
||||
|
||||
/**
|
||||
* 对日期的【小时】进行加/减
|
||||
*
|
||||
* @param date 日期
|
||||
* @param hours 小时数,负数为减
|
||||
* @return 加/减几小时后的日期
|
||||
*/
|
||||
public static Date addDateHours(Date date, int hours) {
|
||||
DateTime dateTime = new DateTime(date);
|
||||
return dateTime.plusHours(hours).toDate();
|
||||
}
|
||||
|
||||
/**
|
||||
* 对日期的【天】进行加/减
|
||||
*
|
||||
* @param date 日期
|
||||
* @param days 天数,负数为减
|
||||
* @return 加/减几天后的日期
|
||||
*/
|
||||
public static Date addDateDays(Date date, int days) {
|
||||
DateTime dateTime = new DateTime(date);
|
||||
return dateTime.plusDays(days).toDate();
|
||||
}
|
||||
|
||||
/**
|
||||
* 对日期的【周】进行加/减
|
||||
*
|
||||
* @param date 日期
|
||||
* @param weeks 周数,负数为减
|
||||
* @return 加/减几周后的日期
|
||||
*/
|
||||
public static Date addDateWeeks(Date date, int weeks) {
|
||||
DateTime dateTime = new DateTime(date);
|
||||
return dateTime.plusWeeks(weeks).toDate();
|
||||
}
|
||||
|
||||
/**
|
||||
* 对日期的【月】进行加/减
|
||||
*
|
||||
* @param date 日期
|
||||
* @param months 月数,负数为减
|
||||
* @return 加/减几月后的日期
|
||||
*/
|
||||
public static Date addDateMonths(Date date, int months) {
|
||||
DateTime dateTime = new DateTime(date);
|
||||
return dateTime.plusMonths(months).toDate();
|
||||
}
|
||||
|
||||
/**
|
||||
* 对日期的【年】进行加/减
|
||||
*
|
||||
* @param date 日期
|
||||
* @param years 年数,负数为减
|
||||
* @return 加/减几年后的日期
|
||||
*/
|
||||
public static Date addDateYears(Date date, int years) {
|
||||
DateTime dateTime = new DateTime(date);
|
||||
return dateTime.plusYears(years).toDate();
|
||||
}
|
||||
}
|
18
src/main/java/io/linfeng/common/utils/FileCheckUtil.java
Normal file
18
src/main/java/io/linfeng/common/utils/FileCheckUtil.java
Normal file
@ -0,0 +1,18 @@
|
||||
package io.linfeng.common.utils;
|
||||
|
||||
import io.linfeng.common.exception.LinfengException;
|
||||
|
||||
/**
|
||||
* @author linfeng
|
||||
* @date 2022/2/21 10:38
|
||||
*/
|
||||
public class FileCheckUtil {
|
||||
|
||||
public static void checkSize(long maxSize, long size) {
|
||||
// 单位 M
|
||||
int len = 1024 * 1024;
|
||||
if(size > (maxSize * len)){
|
||||
throw new LinfengException("上传文件超出规定大小");
|
||||
}
|
||||
}
|
||||
}
|
25
src/main/java/io/linfeng/common/utils/HttpContextUtils.java
Normal file
25
src/main/java/io/linfeng/common/utils/HttpContextUtils.java
Normal file
@ -0,0 +1,25 @@
|
||||
|
||||
package io.linfeng.common.utils;
|
||||
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
public class HttpContextUtils {
|
||||
|
||||
public static HttpServletRequest getHttpServletRequest() {
|
||||
return ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
|
||||
}
|
||||
|
||||
public static String getDomain(){
|
||||
HttpServletRequest request = getHttpServletRequest();
|
||||
StringBuffer url = request.getRequestURL();
|
||||
return url.delete(url.length() - request.getRequestURI().length(), url.length()).toString();
|
||||
}
|
||||
|
||||
public static String getOrigin(){
|
||||
HttpServletRequest request = getHttpServletRequest();
|
||||
return request.getHeader("Origin");
|
||||
}
|
||||
}
|
61
src/main/java/io/linfeng/common/utils/IPUtil.java
Normal file
61
src/main/java/io/linfeng/common/utils/IPUtil.java
Normal file
@ -0,0 +1,61 @@
|
||||
package io.linfeng.common.utils;
|
||||
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
/**
|
||||
* IP查询工具类
|
||||
* @author linfeng
|
||||
* @date 2022/2/7 19:18
|
||||
*/
|
||||
public class IPUtil {
|
||||
|
||||
|
||||
private static final String UNKNOWN = "unknown";
|
||||
// IP归属地查询
|
||||
public static final String IP_URL = "http://whois.pconline.com.cn/ipJson.jsp?ip=%s&json=true";
|
||||
/**
|
||||
* 获取ip地址
|
||||
*/
|
||||
public static String getIp(HttpServletRequest request) {
|
||||
String ip = request.getHeader("x-forwarded-for");
|
||||
if (ip == null || ip.length() == 0 || UNKNOWN.equalsIgnoreCase(ip)) {
|
||||
ip = request.getHeader("Proxy-Client-IP");
|
||||
}
|
||||
if (ip == null || ip.length() == 0 || UNKNOWN.equalsIgnoreCase(ip)) {
|
||||
ip = request.getHeader("WL-Proxy-Client-IP");
|
||||
}
|
||||
if (ip == null || ip.length() == 0 || UNKNOWN.equalsIgnoreCase(ip)) {
|
||||
ip = request.getRemoteAddr();
|
||||
}
|
||||
String comma = ",";
|
||||
String localhost = "127.0.0.1";
|
||||
if (ip.contains(comma)) {
|
||||
ip = ip.split(",")[0];
|
||||
}
|
||||
if (localhost.equals(ip)) {
|
||||
// 获取本机真正的ip地址
|
||||
try {
|
||||
ip = InetAddress.getLocalHost().getHostAddress();
|
||||
} catch (UnknownHostException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return ip;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ip获取详细地址
|
||||
*/
|
||||
public static String getCityInfo(String ip) {
|
||||
String api = String.format(IP_URL,ip);
|
||||
JSONObject object = JSONUtil.parseObj(HttpUtil.get(api));
|
||||
return object.get("addr", String.class);
|
||||
}
|
||||
|
||||
}
|
56
src/main/java/io/linfeng/common/utils/IPUtils.java
Normal file
56
src/main/java/io/linfeng/common/utils/IPUtils.java
Normal file
@ -0,0 +1,56 @@
|
||||
|
||||
package io.linfeng.common.utils;
|
||||
|
||||
import com.alibaba.druid.util.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* IP地址
|
||||
*
|
||||
*/
|
||||
public class IPUtils {
|
||||
private static Logger logger = LoggerFactory.getLogger(IPUtils.class);
|
||||
|
||||
/**
|
||||
* 获取IP地址
|
||||
*
|
||||
* 使用Nginx等反向代理软件, 则不能通过request.getRemoteAddr()获取IP地址
|
||||
* 如果使用了多级反向代理的话,X-Forwarded-For的值并不止一个,而是一串IP地址,X-Forwarded-For中第一个非unknown的有效IP字符串,则为真实IP地址
|
||||
*/
|
||||
public static String getIpAddr(HttpServletRequest request) {
|
||||
String ip = null;
|
||||
try {
|
||||
ip = request.getHeader("x-forwarded-for");
|
||||
if (StringUtils.isEmpty(ip) || "unknown".equalsIgnoreCase(ip)) {
|
||||
ip = request.getHeader("Proxy-Client-IP");
|
||||
}
|
||||
if (StringUtils.isEmpty(ip) || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
||||
ip = request.getHeader("WL-Proxy-Client-IP");
|
||||
}
|
||||
if (StringUtils.isEmpty(ip) || "unknown".equalsIgnoreCase(ip)) {
|
||||
ip = request.getHeader("HTTP_CLIENT_IP");
|
||||
}
|
||||
if (StringUtils.isEmpty(ip) || "unknown".equalsIgnoreCase(ip)) {
|
||||
ip = request.getHeader("HTTP_X_FORWARDED_FOR");
|
||||
}
|
||||
if (StringUtils.isEmpty(ip) || "unknown".equalsIgnoreCase(ip)) {
|
||||
ip = request.getRemoteAddr();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("IPUtils ERROR ", e);
|
||||
}
|
||||
|
||||
// //使用代理,则获取第一个IP地址
|
||||
// if(StringUtils.isEmpty(ip) && ip.length() > 15) {
|
||||
// if(ip.indexOf(",") > 0) {
|
||||
// ip = ip.substring(0, ip.indexOf(","));
|
||||
// }
|
||||
// }
|
||||
|
||||
return ip;
|
||||
}
|
||||
|
||||
}
|
20
src/main/java/io/linfeng/common/utils/JsonUtils.java
Normal file
20
src/main/java/io/linfeng/common/utils/JsonUtils.java
Normal file
@ -0,0 +1,20 @@
|
||||
package io.linfeng.common.utils;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author linfeng
|
||||
* @date 2022/1/25 15:37
|
||||
*/
|
||||
public class JsonUtils {
|
||||
|
||||
|
||||
public static List<String> JsonToList(String jsonString){
|
||||
|
||||
List<String> list = JSON.parseArray(jsonString, String.class);
|
||||
return list;
|
||||
}
|
||||
}
|
18
src/main/java/io/linfeng/common/utils/MapUtils.java
Normal file
18
src/main/java/io/linfeng/common/utils/MapUtils.java
Normal file
@ -0,0 +1,18 @@
|
||||
|
||||
package io.linfeng.common.utils;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
|
||||
/**
|
||||
* Map工具类
|
||||
*
|
||||
*/
|
||||
public class MapUtils extends HashMap<String, Object> {
|
||||
|
||||
@Override
|
||||
public MapUtils put(String key, Object value) {
|
||||
super.put(key, value);
|
||||
return this;
|
||||
}
|
||||
}
|
102
src/main/java/io/linfeng/common/utils/PageUtils.java
Normal file
102
src/main/java/io/linfeng/common/utils/PageUtils.java
Normal file
@ -0,0 +1,102 @@
|
||||
|
||||
package io.linfeng.common.utils;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 分页工具类
|
||||
*
|
||||
*/
|
||||
public class PageUtils implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
/**
|
||||
* 总记录数
|
||||
*/
|
||||
private int totalCount;
|
||||
/**
|
||||
* 每页记录数
|
||||
*/
|
||||
private int pageSize;
|
||||
/**
|
||||
* 总页数
|
||||
*/
|
||||
private int 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.totalCount = totalCount;
|
||||
this.pageSize = pageSize;
|
||||
this.currPage = currPage;
|
||||
this.totalPage = (int)Math.ceil((double)totalCount/pageSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*/
|
||||
public PageUtils(IPage<?> page) {
|
||||
this.list = page.getRecords();
|
||||
this.totalCount = (int)page.getTotal();
|
||||
this.pageSize = (int)page.getSize();
|
||||
this.currPage = (int)page.getCurrent();
|
||||
this.totalPage = (int)page.getPages();
|
||||
}
|
||||
|
||||
public int getTotalCount() {
|
||||
return totalCount;
|
||||
}
|
||||
|
||||
public void setTotalCount(int totalCount) {
|
||||
this.totalCount = totalCount;
|
||||
}
|
||||
|
||||
public int getPageSize() {
|
||||
return pageSize;
|
||||
}
|
||||
|
||||
public void setPageSize(int pageSize) {
|
||||
this.pageSize = pageSize;
|
||||
}
|
||||
|
||||
public int getTotalPage() {
|
||||
return totalPage;
|
||||
}
|
||||
|
||||
public void setTotalPage(int totalPage) {
|
||||
this.totalPage = totalPage;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
69
src/main/java/io/linfeng/common/utils/Query.java
Normal file
69
src/main/java/io/linfeng/common/utils/Query.java
Normal file
@ -0,0 +1,69 @@
|
||||
|
||||
package io.linfeng.common.utils;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import io.linfeng.common.xss.SQLFilter;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 查询参数
|
||||
*
|
||||
*/
|
||||
public class Query<T> {
|
||||
|
||||
public IPage<T> getPage(Map<String, Object> params) {
|
||||
return this.getPage(params, null, false);
|
||||
}
|
||||
|
||||
public IPage<T> getPage(Map<String, Object> params, String defaultOrderField, boolean isAsc) {
|
||||
//分页参数
|
||||
long curPage = 1;
|
||||
long limit = 10;
|
||||
|
||||
if(params.get(Constant.PAGE) != null){
|
||||
curPage = Long.parseLong((String)params.get(Constant.PAGE));
|
||||
}
|
||||
if(params.get(Constant.LIMIT) != null){
|
||||
limit = Long.parseLong((String)params.get(Constant.LIMIT));
|
||||
}
|
||||
|
||||
//分页对象
|
||||
Page<T> page = new Page<>(curPage, limit);
|
||||
|
||||
//分页参数
|
||||
params.put(Constant.PAGE, page);
|
||||
|
||||
//排序字段
|
||||
//防止SQL注入(因为sidx、order是通过拼接SQL实现排序的,会有SQL注入风险)
|
||||
String orderField = SQLFilter.sqlInject((String)params.get(Constant.ORDER_FIELD));
|
||||
String order = (String)params.get(Constant.ORDER);
|
||||
|
||||
|
||||
//前端字段排序
|
||||
if(StringUtils.isNotEmpty(orderField) && StringUtils.isNotEmpty(order)){
|
||||
if(Constant.ASC.equalsIgnoreCase(order)) {
|
||||
return page.addOrder(OrderItem.asc(orderField));
|
||||
}else {
|
||||
return page.addOrder(OrderItem.desc(orderField));
|
||||
}
|
||||
}
|
||||
|
||||
//没有排序字段,则不排序
|
||||
if(StringUtils.isBlank(defaultOrderField)){
|
||||
return page;
|
||||
}
|
||||
|
||||
//默认排序
|
||||
if(isAsc) {
|
||||
page.addOrder(OrderItem.asc(defaultOrderField));
|
||||
}else {
|
||||
page.addOrder(OrderItem.desc(defaultOrderField));
|
||||
}
|
||||
|
||||
return page;
|
||||
}
|
||||
}
|
56
src/main/java/io/linfeng/common/utils/R.java
Normal file
56
src/main/java/io/linfeng/common/utils/R.java
Normal file
@ -0,0 +1,56 @@
|
||||
|
||||
package io.linfeng.common.utils;
|
||||
|
||||
import org.apache.http.HttpStatus;
|
||||
|
||||
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);
|
||||
put("msg", "success");
|
||||
}
|
||||
|
||||
public static R error() {
|
||||
return error(HttpStatus.SC_INTERNAL_SERVER_ERROR, "未知异常,请联系管理员");
|
||||
}
|
||||
|
||||
public static R error(String msg) {
|
||||
return error(HttpStatus.SC_INTERNAL_SERVER_ERROR, 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;
|
||||
}
|
||||
}
|
13
src/main/java/io/linfeng/common/utils/RedisKeys.java
Normal file
13
src/main/java/io/linfeng/common/utils/RedisKeys.java
Normal file
@ -0,0 +1,13 @@
|
||||
|
||||
package io.linfeng.common.utils;
|
||||
|
||||
/**
|
||||
* Redis所有Keys
|
||||
*
|
||||
*/
|
||||
public class RedisKeys {
|
||||
|
||||
public static String getSysConfigKey(String key){
|
||||
return "sys:config:" + key;
|
||||
}
|
||||
}
|
91
src/main/java/io/linfeng/common/utils/RedisUtils.java
Normal file
91
src/main/java/io/linfeng/common/utils/RedisUtils.java
Normal file
@ -0,0 +1,91 @@
|
||||
|
||||
package io.linfeng.common.utils;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.*;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* Redis工具类
|
||||
*
|
||||
*/
|
||||
@Component
|
||||
public class RedisUtils {
|
||||
@Autowired
|
||||
private RedisTemplate<String, Object> redisTemplate;
|
||||
@Autowired
|
||||
private ValueOperations<String, String> valueOperations;
|
||||
@Autowired
|
||||
private HashOperations<String, String, Object> hashOperations;
|
||||
@Autowired
|
||||
private ListOperations<String, Object> listOperations;
|
||||
@Autowired
|
||||
private SetOperations<String, Object> setOperations;
|
||||
@Autowired
|
||||
private ZSetOperations<String, Object> zSetOperations;
|
||||
/** 默认过期时长,单位:秒 */
|
||||
public final static long DEFAULT_EXPIRE = 60 * 60 * 24;
|
||||
/** 不设置过期时长 */
|
||||
public final static long NOT_EXPIRE = -1;
|
||||
private final static Gson gson = new Gson();
|
||||
|
||||
public void set(String key, Object value, long expire){
|
||||
valueOperations.set(key, toJson(value));
|
||||
if(expire != NOT_EXPIRE){
|
||||
redisTemplate.expire(key, expire, TimeUnit.SECONDS);
|
||||
}
|
||||
}
|
||||
|
||||
public void set(String key, Object value){
|
||||
set(key, value, DEFAULT_EXPIRE);
|
||||
}
|
||||
|
||||
public <T> T get(String key, Class<T> clazz, long expire) {
|
||||
String value = valueOperations.get(key);
|
||||
if(expire != NOT_EXPIRE){
|
||||
redisTemplate.expire(key, expire, TimeUnit.SECONDS);
|
||||
}
|
||||
return value == null ? null : fromJson(value, clazz);
|
||||
}
|
||||
|
||||
public <T> T get(String key, Class<T> clazz) {
|
||||
return get(key, clazz, NOT_EXPIRE);
|
||||
}
|
||||
|
||||
public String get(String key, long expire) {
|
||||
String value = valueOperations.get(key);
|
||||
if(expire != NOT_EXPIRE){
|
||||
redisTemplate.expire(key, expire, TimeUnit.SECONDS);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public String get(String key) {
|
||||
return get(key, NOT_EXPIRE);
|
||||
}
|
||||
|
||||
public void delete(String key) {
|
||||
redisTemplate.delete(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Object转成JSON数据
|
||||
*/
|
||||
private String toJson(Object object){
|
||||
if(object instanceof Integer || object instanceof Long || object instanceof Float ||
|
||||
object instanceof Double || object instanceof Boolean || object instanceof String){
|
||||
return String.valueOf(object);
|
||||
}
|
||||
return gson.toJson(object);
|
||||
}
|
||||
|
||||
/**
|
||||
* JSON数据,转成Object
|
||||
*/
|
||||
private <T> T fromJson(String json, Class<T> clazz){
|
||||
return gson.fromJson(json, clazz);
|
||||
}
|
||||
}
|
15
src/main/java/io/linfeng/common/utils/RequestUtils.java
Normal file
15
src/main/java/io/linfeng/common/utils/RequestUtils.java
Normal file
@ -0,0 +1,15 @@
|
||||
package io.linfeng.common.utils;
|
||||
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
public class RequestUtils {
|
||||
|
||||
public static HttpServletRequest getRequest() {
|
||||
ServletRequestAttributes ra= (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
||||
return ra.getRequest();
|
||||
}
|
||||
|
||||
}
|
53
src/main/java/io/linfeng/common/utils/ShiroUtils.java
Normal file
53
src/main/java/io/linfeng/common/utils/ShiroUtils.java
Normal file
@ -0,0 +1,53 @@
|
||||
|
||||
package io.linfeng.common.utils;
|
||||
|
||||
import io.linfeng.common.exception.LinfengException;
|
||||
import io.linfeng.modules.sys.entity.SysUserEntity;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.apache.shiro.session.Session;
|
||||
import org.apache.shiro.subject.Subject;
|
||||
|
||||
/**
|
||||
* Shiro工具类
|
||||
*
|
||||
*/
|
||||
public class ShiroUtils {
|
||||
|
||||
public static Session getSession() {
|
||||
return SecurityUtils.getSubject().getSession();
|
||||
}
|
||||
|
||||
public static Subject getSubject() {
|
||||
return SecurityUtils.getSubject();
|
||||
}
|
||||
|
||||
public static SysUserEntity getUserEntity() {
|
||||
return (SysUserEntity)SecurityUtils.getSubject().getPrincipal();
|
||||
}
|
||||
|
||||
public static Long getUserId() {
|
||||
return getUserEntity().getUserId();
|
||||
}
|
||||
|
||||
public static void setSessionAttribute(Object key, Object value) {
|
||||
getSession().setAttribute(key, value);
|
||||
}
|
||||
|
||||
public static Object getSessionAttribute(Object key) {
|
||||
return getSession().getAttribute(key);
|
||||
}
|
||||
|
||||
public static boolean isLogin() {
|
||||
return SecurityUtils.getSubject().getPrincipal() != null;
|
||||
}
|
||||
|
||||
public static String getKaptcha(String key) {
|
||||
Object kaptcha = getSessionAttribute(key);
|
||||
if(kaptcha == null){
|
||||
throw new LinfengException("验证码已失效");
|
||||
}
|
||||
getSession().removeAttribute(key);
|
||||
return kaptcha.toString();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
|
||||
package io.linfeng.common.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);
|
||||
}
|
||||
|
||||
}
|
76
src/main/java/io/linfeng/common/utils/WechatUtil.java
Normal file
76
src/main/java/io/linfeng/common/utils/WechatUtil.java
Normal file
@ -0,0 +1,76 @@
|
||||
package io.linfeng.common.utils;
|
||||
|
||||
/**
|
||||
* @author linfeng
|
||||
* @date 2022/1/20 13:15
|
||||
*/
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.PrintWriter;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
|
||||
public class WechatUtil {
|
||||
|
||||
/**
|
||||
* 获取小程序codeid换取openid
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
public static JSONObject getOpenId(String code,String appId,String secret) {
|
||||
String url = "https://api.weixin.qq.com/sns/jscode2session?appid="+ appId +"&secret=" +
|
||||
secret +"&js_code="+code+"&grant_type=authorization_code";
|
||||
PrintWriter out = null;
|
||||
BufferedReader in = null;
|
||||
String line;
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
try {
|
||||
URL realUrl = new URL(url);
|
||||
// 打开和URL之间的连接
|
||||
URLConnection conn = realUrl.openConnection();
|
||||
|
||||
// 设置通用的请求属性 设置请求格式
|
||||
//设置返回类型
|
||||
conn.setRequestProperty("contentType", "text/plain");
|
||||
//设置请求类型
|
||||
conn.setRequestProperty("content-type", "application/x-www-form-urlencoded");
|
||||
//设置超时时间
|
||||
conn.setConnectTimeout(1000);
|
||||
conn.setReadTimeout(1000);
|
||||
conn.setDoOutput(true);
|
||||
conn.connect();
|
||||
// 获取URLConnection对象对应的输出流
|
||||
out = new PrintWriter(conn.getOutputStream());
|
||||
// flush输出流的缓冲
|
||||
out.flush();
|
||||
// 定义BufferedReader输入流来读取URL的响应 设置接收格式
|
||||
in = new BufferedReader(
|
||||
new InputStreamReader(conn.getInputStream(), "UTF-8"));
|
||||
while ((line = in.readLine()) != null) {
|
||||
stringBuffer.append(line);
|
||||
}
|
||||
JSONObject jsonObject = JSONObject.parseObject(stringBuffer.toString());
|
||||
return jsonObject;
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
//使用finally块来关闭输出流、输入流
|
||||
finally {
|
||||
try {
|
||||
if (out != null) {
|
||||
out.close();
|
||||
}
|
||||
if (in != null) {
|
||||
in.close();
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
24
src/main/java/io/linfeng/common/validator/Assert.java
Normal file
24
src/main/java/io/linfeng/common/validator/Assert.java
Normal file
@ -0,0 +1,24 @@
|
||||
|
||||
package io.linfeng.common.validator;
|
||||
|
||||
import io.linfeng.common.exception.LinfengException;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
/**
|
||||
* 数据校验
|
||||
*
|
||||
*/
|
||||
public abstract class Assert {
|
||||
|
||||
public static void isBlank(String str, String message) {
|
||||
if (StringUtils.isBlank(str)) {
|
||||
throw new LinfengException(message);
|
||||
}
|
||||
}
|
||||
|
||||
public static void isNull(Object object, String message) {
|
||||
if (object == null) {
|
||||
throw new LinfengException(message);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
|
||||
package io.linfeng.common.validator;
|
||||
|
||||
import io.linfeng.common.exception.LinfengException;
|
||||
|
||||
import javax.validation.ConstraintViolation;
|
||||
import javax.validation.Validation;
|
||||
import javax.validation.Validator;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* hibernate-validator校验工具类
|
||||
*
|
||||
* 参考文档:http://docs.jboss.org/hibernate/validator/5.4/reference/en-US/html_single/
|
||||
*
|
||||
*/
|
||||
public class ValidatorUtils {
|
||||
private static Validator validator;
|
||||
|
||||
static {
|
||||
validator = Validation.buildDefaultValidatorFactory().getValidator();
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验对象
|
||||
* @param object 待校验对象
|
||||
* @param groups 待校验的组
|
||||
* @throws LinfengException 校验不通过,则报RRException异常
|
||||
*/
|
||||
public static void validateEntity(Object object, Class<?>... groups)
|
||||
throws LinfengException {
|
||||
Set<ConstraintViolation<Object>> constraintViolations = validator.validate(object, groups);
|
||||
if (!constraintViolations.isEmpty()) {
|
||||
StringBuilder msg = new StringBuilder();
|
||||
for(ConstraintViolation<Object> constraint: constraintViolations){
|
||||
msg.append(constraint.getMessage()).append("<br>");
|
||||
}
|
||||
throw new LinfengException(msg.toString());
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
|
||||
package io.linfeng.common.validator.group;
|
||||
|
||||
/**
|
||||
* 新增数据 Group
|
||||
*
|
||||
*/
|
||||
public interface AddGroup {
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
|
||||
package io.linfeng.common.validator.group;
|
||||
|
||||
/**
|
||||
* 阿里云
|
||||
*
|
||||
*/
|
||||
public interface AliyunGroup {
|
||||
}
|
13
src/main/java/io/linfeng/common/validator/group/Group.java
Normal file
13
src/main/java/io/linfeng/common/validator/group/Group.java
Normal file
@ -0,0 +1,13 @@
|
||||
|
||||
package io.linfeng.common.validator.group;
|
||||
|
||||
import javax.validation.GroupSequence;
|
||||
|
||||
/**
|
||||
* 定义校验顺序,如果AddGroup组失败,则UpdateGroup组不会再校验
|
||||
*
|
||||
*/
|
||||
@GroupSequence({AddGroup.class, UpdateGroup.class})
|
||||
public interface Group {
|
||||
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
|
||||
package io.linfeng.common.validator.group;
|
||||
|
||||
/**
|
||||
* 腾讯云
|
||||
*
|
||||
*/
|
||||
public interface QcloudGroup {
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
|
||||
package io.linfeng.common.validator.group;
|
||||
|
||||
/**
|
||||
* 七牛
|
||||
*
|
||||
*/
|
||||
public interface QiniuGroup {
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
|
||||
package io.linfeng.common.validator.group;
|
||||
|
||||
/**
|
||||
* 更新数据 Group
|
||||
*
|
||||
*/
|
||||
|
||||
public interface UpdateGroup {
|
||||
|
||||
}
|
530
src/main/java/io/linfeng/common/xss/HTMLFilter.java
Normal file
530
src/main/java/io/linfeng/common/xss/HTMLFilter.java
Normal file
@ -0,0 +1,530 @@
|
||||
package io.linfeng.common.xss;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
*
|
||||
* HTML filtering utility for protecting against XSS (Cross Site Scripting).
|
||||
*
|
||||
* This code is licensed LGPLv3
|
||||
*
|
||||
* This code is a Java port of the original work in PHP by Cal Hendersen.
|
||||
* http://code.iamcal.com/php/lib_filter/
|
||||
*
|
||||
* The trickiest part of the translation was handling the differences in regex handling
|
||||
* between PHP and Java. These resources were helpful in the process:
|
||||
*
|
||||
* http://java.sun.com/j2se/1.4.2/docs/api/java/util/regex/Pattern.html
|
||||
* http://us2.php.net/manual/en/reference.pcre.pattern.modifiers.php
|
||||
* http://www.regular-expressions.info/modifiers.html
|
||||
*
|
||||
* A note on naming conventions: instance variables are prefixed with a "v"; global
|
||||
* constants are in all caps.
|
||||
*
|
||||
* Sample use:
|
||||
* String input = ...
|
||||
* String clean = new HTMLFilter().filter( input );
|
||||
*
|
||||
* The class is not thread safe. Create a new instance if in doubt.
|
||||
*
|
||||
* If you find bugs or have suggestions on improvement (especially regarding
|
||||
* performance), please contact us. The latest version of this
|
||||
* source, and our contact details, can be found at http://xss-html-filter.sf.net
|
||||
*
|
||||
* @author Joseph O'Connell
|
||||
* @author Cal Hendersen
|
||||
* @author Michael Semb Wever
|
||||
*/
|
||||
public final class HTMLFilter {
|
||||
|
||||
/** regex flag union representing /si modifiers in php **/
|
||||
private static final int REGEX_FLAGS_SI = Pattern.CASE_INSENSITIVE | Pattern.DOTALL;
|
||||
private static final Pattern P_COMMENTS = Pattern.compile("<!--(.*?)-->", Pattern.DOTALL);
|
||||
private static final Pattern P_COMMENT = Pattern.compile("^!--(.*)--$", REGEX_FLAGS_SI);
|
||||
private static final Pattern P_TAGS = Pattern.compile("<(.*?)>", Pattern.DOTALL);
|
||||
private static final Pattern P_END_TAG = Pattern.compile("^/([a-z0-9]+)", REGEX_FLAGS_SI);
|
||||
private static final Pattern P_START_TAG = Pattern.compile("^([a-z0-9]+)(.*?)(/?)$", REGEX_FLAGS_SI);
|
||||
private static final Pattern P_QUOTED_ATTRIBUTES = Pattern.compile("([a-z0-9]+)=([\"'])(.*?)\\2", REGEX_FLAGS_SI);
|
||||
private static final Pattern P_UNQUOTED_ATTRIBUTES = Pattern.compile("([a-z0-9]+)(=)([^\"\\s']+)", REGEX_FLAGS_SI);
|
||||
private static final Pattern P_PROTOCOL = Pattern.compile("^([^:]+):", REGEX_FLAGS_SI);
|
||||
private static final Pattern P_ENTITY = Pattern.compile("&#(\\d+);?");
|
||||
private static final Pattern P_ENTITY_UNICODE = Pattern.compile("&#x([0-9a-f]+);?");
|
||||
private static final Pattern P_ENCODE = Pattern.compile("%([0-9a-f]{2});?");
|
||||
private static final Pattern P_VALID_ENTITIES = Pattern.compile("&([^&;]*)(?=(;|&|$))");
|
||||
private static final Pattern P_VALID_QUOTES = Pattern.compile("(>|^)([^<]+?)(<|$)", Pattern.DOTALL);
|
||||
private static final Pattern P_END_ARROW = Pattern.compile("^>");
|
||||
private static final Pattern P_BODY_TO_END = Pattern.compile("<([^>]*?)(?=<|$)");
|
||||
private static final Pattern P_XML_CONTENT = Pattern.compile("(^|>)([^<]*?)(?=>)");
|
||||
private static final Pattern P_STRAY_LEFT_ARROW = Pattern.compile("<([^>]*?)(?=<|$)");
|
||||
private static final Pattern P_STRAY_RIGHT_ARROW = Pattern.compile("(^|>)([^<]*?)(?=>)");
|
||||
private static final Pattern P_AMP = Pattern.compile("&");
|
||||
private static final Pattern P_QUOTE = Pattern.compile("<");
|
||||
private static final Pattern P_LEFT_ARROW = Pattern.compile("<");
|
||||
private static final Pattern P_RIGHT_ARROW = Pattern.compile(">");
|
||||
private static final Pattern P_BOTH_ARROWS = Pattern.compile("<>");
|
||||
|
||||
// @xxx could grow large... maybe use sesat's ReferenceMap
|
||||
private static final ConcurrentMap<String,Pattern> P_REMOVE_PAIR_BLANKS = new ConcurrentHashMap<String, Pattern>();
|
||||
private static final ConcurrentMap<String,Pattern> P_REMOVE_SELF_BLANKS = new ConcurrentHashMap<String, Pattern>();
|
||||
|
||||
/** set of allowed html elements, along with allowed attributes for each element **/
|
||||
private final Map<String, List<String>> vAllowed;
|
||||
/** counts of open tags for each (allowable) html element **/
|
||||
private final Map<String, Integer> vTagCounts = new HashMap<String, Integer>();
|
||||
|
||||
/** html elements which must always be self-closing (e.g. "<img />") **/
|
||||
private final String[] vSelfClosingTags;
|
||||
/** html elements which must always have separate opening and closing tags (e.g. "<b></b>") **/
|
||||
private final String[] vNeedClosingTags;
|
||||
/** set of disallowed html elements **/
|
||||
private final String[] vDisallowed;
|
||||
/** attributes which should be checked for valid protocols **/
|
||||
private final String[] vProtocolAtts;
|
||||
/** allowed protocols **/
|
||||
private final String[] vAllowedProtocols;
|
||||
/** tags which should be removed if they contain no content (e.g. "<b></b>" or "<b />") **/
|
||||
private final String[] vRemoveBlanks;
|
||||
/** entities allowed within html markup **/
|
||||
private final String[] vAllowedEntities;
|
||||
/** flag determining whether comments are allowed in input String. */
|
||||
private final boolean stripComment;
|
||||
private final boolean encodeQuotes;
|
||||
private boolean vDebug = false;
|
||||
/**
|
||||
* flag determining whether to try to make tags when presented with "unbalanced"
|
||||
* angle brackets (e.g. "<b text </b>" becomes "<b> text </b>"). If set to false,
|
||||
* unbalanced angle brackets will be html escaped.
|
||||
*/
|
||||
private final boolean alwaysMakeTags;
|
||||
|
||||
/** Default constructor.
|
||||
*
|
||||
*/
|
||||
public HTMLFilter() {
|
||||
vAllowed = new HashMap<>();
|
||||
|
||||
final ArrayList<String> a_atts = new ArrayList<String>();
|
||||
a_atts.add("href");
|
||||
a_atts.add("target");
|
||||
vAllowed.put("a", a_atts);
|
||||
|
||||
final ArrayList<String> img_atts = new ArrayList<String>();
|
||||
img_atts.add("src");
|
||||
img_atts.add("width");
|
||||
img_atts.add("height");
|
||||
img_atts.add("alt");
|
||||
vAllowed.put("img", img_atts);
|
||||
|
||||
final ArrayList<String> no_atts = new ArrayList<String>();
|
||||
vAllowed.put("b", no_atts);
|
||||
vAllowed.put("strong", no_atts);
|
||||
vAllowed.put("i", no_atts);
|
||||
vAllowed.put("em", no_atts);
|
||||
|
||||
vSelfClosingTags = new String[]{"img"};
|
||||
vNeedClosingTags = new String[]{"a", "b", "strong", "i", "em"};
|
||||
vDisallowed = new String[]{};
|
||||
vAllowedProtocols = new String[]{"http", "mailto", "https"}; // no ftp.
|
||||
vProtocolAtts = new String[]{"src", "href"};
|
||||
vRemoveBlanks = new String[]{"a", "b", "strong", "i", "em"};
|
||||
vAllowedEntities = new String[]{"amp", "gt", "lt", "quot"};
|
||||
stripComment = true;
|
||||
encodeQuotes = true;
|
||||
alwaysMakeTags = true;
|
||||
}
|
||||
|
||||
/** Set debug flag to true. Otherwise use default settings. See the default constructor.
|
||||
*
|
||||
* @param debug turn debug on with a true argument
|
||||
*/
|
||||
public HTMLFilter(final boolean debug) {
|
||||
this();
|
||||
vDebug = debug;
|
||||
|
||||
}
|
||||
|
||||
/** Map-parameter configurable constructor.
|
||||
*
|
||||
* @param conf map containing configuration. keys match field names.
|
||||
*/
|
||||
public HTMLFilter(final Map<String,Object> conf) {
|
||||
|
||||
assert conf.containsKey("vAllowed") : "configuration requires vAllowed";
|
||||
assert conf.containsKey("vSelfClosingTags") : "configuration requires vSelfClosingTags";
|
||||
assert conf.containsKey("vNeedClosingTags") : "configuration requires vNeedClosingTags";
|
||||
assert conf.containsKey("vDisallowed") : "configuration requires vDisallowed";
|
||||
assert conf.containsKey("vAllowedProtocols") : "configuration requires vAllowedProtocols";
|
||||
assert conf.containsKey("vProtocolAtts") : "configuration requires vProtocolAtts";
|
||||
assert conf.containsKey("vRemoveBlanks") : "configuration requires vRemoveBlanks";
|
||||
assert conf.containsKey("vAllowedEntities") : "configuration requires vAllowedEntities";
|
||||
|
||||
vAllowed = Collections.unmodifiableMap((HashMap<String, List<String>>) conf.get("vAllowed"));
|
||||
vSelfClosingTags = (String[]) conf.get("vSelfClosingTags");
|
||||
vNeedClosingTags = (String[]) conf.get("vNeedClosingTags");
|
||||
vDisallowed = (String[]) conf.get("vDisallowed");
|
||||
vAllowedProtocols = (String[]) conf.get("vAllowedProtocols");
|
||||
vProtocolAtts = (String[]) conf.get("vProtocolAtts");
|
||||
vRemoveBlanks = (String[]) conf.get("vRemoveBlanks");
|
||||
vAllowedEntities = (String[]) conf.get("vAllowedEntities");
|
||||
stripComment = conf.containsKey("stripComment") ? (Boolean) conf.get("stripComment") : true;
|
||||
encodeQuotes = conf.containsKey("encodeQuotes") ? (Boolean) conf.get("encodeQuotes") : true;
|
||||
alwaysMakeTags = conf.containsKey("alwaysMakeTags") ? (Boolean) conf.get("alwaysMakeTags") : true;
|
||||
}
|
||||
|
||||
private void reset() {
|
||||
vTagCounts.clear();
|
||||
}
|
||||
|
||||
private void debug(final String msg) {
|
||||
if (vDebug) {
|
||||
Logger.getAnonymousLogger().info(msg);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// my versions of some PHP library functions
|
||||
public static String chr(final int decimal) {
|
||||
return String.valueOf((char) decimal);
|
||||
}
|
||||
|
||||
public static String htmlSpecialChars(final String s) {
|
||||
String result = s;
|
||||
result = regexReplace(P_AMP, "&", result);
|
||||
result = regexReplace(P_QUOTE, """, result);
|
||||
result = regexReplace(P_LEFT_ARROW, "<", result);
|
||||
result = regexReplace(P_RIGHT_ARROW, ">", result);
|
||||
return result;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
/**
|
||||
* given a user submitted input String, filter out any invalid or restricted
|
||||
* html.
|
||||
*
|
||||
* @param input text (i.e. submitted by a user) than may contain html
|
||||
* @return "clean" version of input, with only valid, whitelisted html elements allowed
|
||||
*/
|
||||
public String filter(final String input) {
|
||||
reset();
|
||||
String s = input;
|
||||
|
||||
debug("************************************************");
|
||||
debug(" INPUT: " + input);
|
||||
|
||||
s = escapeComments(s);
|
||||
debug(" escapeComments: " + s);
|
||||
|
||||
s = balanceHTML(s);
|
||||
debug(" balanceHTML: " + s);
|
||||
|
||||
s = checkTags(s);
|
||||
debug(" checkTags: " + s);
|
||||
|
||||
s = processRemoveBlanks(s);
|
||||
debug("processRemoveBlanks: " + s);
|
||||
|
||||
s = validateEntities(s);
|
||||
debug(" validateEntites: " + s);
|
||||
|
||||
debug("************************************************\n\n");
|
||||
return s;
|
||||
}
|
||||
|
||||
public boolean isAlwaysMakeTags(){
|
||||
return alwaysMakeTags;
|
||||
}
|
||||
|
||||
public boolean isStripComments(){
|
||||
return stripComment;
|
||||
}
|
||||
|
||||
private String escapeComments(final String s) {
|
||||
final Matcher m = P_COMMENTS.matcher(s);
|
||||
final StringBuffer buf = new StringBuffer();
|
||||
if (m.find()) {
|
||||
final String match = m.group(1); //(.*?)
|
||||
m.appendReplacement(buf, Matcher.quoteReplacement("<!--" + htmlSpecialChars(match) + "-->"));
|
||||
}
|
||||
m.appendTail(buf);
|
||||
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
private String balanceHTML(String s) {
|
||||
if (alwaysMakeTags) {
|
||||
//
|
||||
// try and form html
|
||||
//
|
||||
s = regexReplace(P_END_ARROW, "", s);
|
||||
s = regexReplace(P_BODY_TO_END, "<$1>", s);
|
||||
s = regexReplace(P_XML_CONTENT, "$1<$2", s);
|
||||
|
||||
} else {
|
||||
//
|
||||
// escape stray brackets
|
||||
//
|
||||
s = regexReplace(P_STRAY_LEFT_ARROW, "<$1", s);
|
||||
s = regexReplace(P_STRAY_RIGHT_ARROW, "$1$2><", s);
|
||||
|
||||
//
|
||||
// the last regexp causes '<>' entities to appear
|
||||
// (we need to do a lookahead assertion so that the last bracket can
|
||||
// be used in the next pass of the regexp)
|
||||
//
|
||||
s = regexReplace(P_BOTH_ARROWS, "", s);
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
private String checkTags(String s) {
|
||||
Matcher m = P_TAGS.matcher(s);
|
||||
|
||||
final StringBuffer buf = new StringBuffer();
|
||||
while (m.find()) {
|
||||
String replaceStr = m.group(1);
|
||||
replaceStr = processTag(replaceStr);
|
||||
m.appendReplacement(buf, Matcher.quoteReplacement(replaceStr));
|
||||
}
|
||||
m.appendTail(buf);
|
||||
|
||||
s = buf.toString();
|
||||
|
||||
// these get tallied in processTag
|
||||
// (remember to reset before subsequent calls to filter method)
|
||||
for (String key : vTagCounts.keySet()) {
|
||||
for (int ii = 0; ii < vTagCounts.get(key); ii++) {
|
||||
s += "</" + key + ">";
|
||||
}
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
private String processRemoveBlanks(final String s) {
|
||||
String result = s;
|
||||
for (String tag : vRemoveBlanks) {
|
||||
if(!P_REMOVE_PAIR_BLANKS.containsKey(tag)){
|
||||
P_REMOVE_PAIR_BLANKS.putIfAbsent(tag, Pattern.compile("<" + tag + "(\\s[^>]*)?></" + tag + ">"));
|
||||
}
|
||||
result = regexReplace(P_REMOVE_PAIR_BLANKS.get(tag), "", result);
|
||||
if(!P_REMOVE_SELF_BLANKS.containsKey(tag)){
|
||||
P_REMOVE_SELF_BLANKS.putIfAbsent(tag, Pattern.compile("<" + tag + "(\\s[^>]*)?/>"));
|
||||
}
|
||||
result = regexReplace(P_REMOVE_SELF_BLANKS.get(tag), "", result);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private static String regexReplace(final Pattern regex_pattern, final String replacement, final String s) {
|
||||
Matcher m = regex_pattern.matcher(s);
|
||||
return m.replaceAll(replacement);
|
||||
}
|
||||
|
||||
private String processTag(final String s) {
|
||||
// ending tags
|
||||
Matcher m = P_END_TAG.matcher(s);
|
||||
if (m.find()) {
|
||||
final String name = m.group(1).toLowerCase();
|
||||
if (allowed(name)) {
|
||||
if (!inArray(name, vSelfClosingTags)) {
|
||||
if (vTagCounts.containsKey(name)) {
|
||||
vTagCounts.put(name, vTagCounts.get(name) - 1);
|
||||
return "</" + name + ">";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// starting tags
|
||||
m = P_START_TAG.matcher(s);
|
||||
if (m.find()) {
|
||||
final String name = m.group(1).toLowerCase();
|
||||
final String body = m.group(2);
|
||||
String ending = m.group(3);
|
||||
|
||||
//debug( "in a starting tag, name='" + name + "'; body='" + body + "'; ending='" + ending + "'" );
|
||||
if (allowed(name)) {
|
||||
String params = "";
|
||||
|
||||
final Matcher m2 = P_QUOTED_ATTRIBUTES.matcher(body);
|
||||
final Matcher m3 = P_UNQUOTED_ATTRIBUTES.matcher(body);
|
||||
final List<String> paramNames = new ArrayList<String>();
|
||||
final List<String> paramValues = new ArrayList<String>();
|
||||
while (m2.find()) {
|
||||
paramNames.add(m2.group(1)); //([a-z0-9]+)
|
||||
paramValues.add(m2.group(3)); //(.*?)
|
||||
}
|
||||
while (m3.find()) {
|
||||
paramNames.add(m3.group(1)); //([a-z0-9]+)
|
||||
paramValues.add(m3.group(3)); //([^\"\\s']+)
|
||||
}
|
||||
|
||||
String paramName, paramValue;
|
||||
for (int ii = 0; ii < paramNames.size(); ii++) {
|
||||
paramName = paramNames.get(ii).toLowerCase();
|
||||
paramValue = paramValues.get(ii);
|
||||
|
||||
// debug( "paramName='" + paramName + "'" );
|
||||
// debug( "paramValue='" + paramValue + "'" );
|
||||
// debug( "allowed? " + vAllowed.get( name ).contains( paramName ) );
|
||||
|
||||
if (allowedAttribute(name, paramName)) {
|
||||
if (inArray(paramName, vProtocolAtts)) {
|
||||
paramValue = processParamProtocol(paramValue);
|
||||
}
|
||||
params += " " + paramName + "=\"" + paramValue + "\"";
|
||||
}
|
||||
}
|
||||
|
||||
if (inArray(name, vSelfClosingTags)) {
|
||||
ending = " /";
|
||||
}
|
||||
|
||||
if (inArray(name, vNeedClosingTags)) {
|
||||
ending = "";
|
||||
}
|
||||
|
||||
if (ending == null || ending.length() < 1) {
|
||||
if (vTagCounts.containsKey(name)) {
|
||||
vTagCounts.put(name, vTagCounts.get(name) + 1);
|
||||
} else {
|
||||
vTagCounts.put(name, 1);
|
||||
}
|
||||
} else {
|
||||
ending = " /";
|
||||
}
|
||||
return "<" + name + params + ending + ">";
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
// comments
|
||||
m = P_COMMENT.matcher(s);
|
||||
if (!stripComment && m.find()) {
|
||||
return "<" + m.group() + ">";
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
private String processParamProtocol(String s) {
|
||||
s = decodeEntities(s);
|
||||
final Matcher m = P_PROTOCOL.matcher(s);
|
||||
if (m.find()) {
|
||||
final String protocol = m.group(1);
|
||||
if (!inArray(protocol, vAllowedProtocols)) {
|
||||
// bad protocol, turn into local anchor link instead
|
||||
s = "#" + s.substring(protocol.length() + 1, s.length());
|
||||
if (s.startsWith("#//")) {
|
||||
s = "#" + s.substring(3, s.length());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
private String decodeEntities(String s) {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
|
||||
Matcher m = P_ENTITY.matcher(s);
|
||||
while (m.find()) {
|
||||
final String match = m.group(1);
|
||||
final int decimal = Integer.decode(match).intValue();
|
||||
m.appendReplacement(buf, Matcher.quoteReplacement(chr(decimal)));
|
||||
}
|
||||
m.appendTail(buf);
|
||||
s = buf.toString();
|
||||
|
||||
buf = new StringBuffer();
|
||||
m = P_ENTITY_UNICODE.matcher(s);
|
||||
while (m.find()) {
|
||||
final String match = m.group(1);
|
||||
final int decimal = Integer.valueOf(match, 16).intValue();
|
||||
m.appendReplacement(buf, Matcher.quoteReplacement(chr(decimal)));
|
||||
}
|
||||
m.appendTail(buf);
|
||||
s = buf.toString();
|
||||
|
||||
buf = new StringBuffer();
|
||||
m = P_ENCODE.matcher(s);
|
||||
while (m.find()) {
|
||||
final String match = m.group(1);
|
||||
final int decimal = Integer.valueOf(match, 16).intValue();
|
||||
m.appendReplacement(buf, Matcher.quoteReplacement(chr(decimal)));
|
||||
}
|
||||
m.appendTail(buf);
|
||||
s = buf.toString();
|
||||
|
||||
s = validateEntities(s);
|
||||
return s;
|
||||
}
|
||||
|
||||
private String validateEntities(final String s) {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
|
||||
// validate entities throughout the string
|
||||
Matcher m = P_VALID_ENTITIES.matcher(s);
|
||||
while (m.find()) {
|
||||
final String one = m.group(1); //([^&;]*)
|
||||
final String two = m.group(2); //(?=(;|&|$))
|
||||
m.appendReplacement(buf, Matcher.quoteReplacement(checkEntity(one, two)));
|
||||
}
|
||||
m.appendTail(buf);
|
||||
|
||||
return encodeQuotes(buf.toString());
|
||||
}
|
||||
|
||||
private String encodeQuotes(final String s){
|
||||
if(encodeQuotes){
|
||||
StringBuffer buf = new StringBuffer();
|
||||
Matcher m = P_VALID_QUOTES.matcher(s);
|
||||
while (m.find()) {
|
||||
final String one = m.group(1); //(>|^)
|
||||
final String two = m.group(2); //([^<]+?)
|
||||
final String three = m.group(3); //(<|$)
|
||||
m.appendReplacement(buf, Matcher.quoteReplacement(one + regexReplace(P_QUOTE, """, two) + three));
|
||||
}
|
||||
m.appendTail(buf);
|
||||
return buf.toString();
|
||||
}else{
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
private String checkEntity(final String preamble, final String term) {
|
||||
|
||||
return ";".equals(term) && isValidEntity(preamble)
|
||||
? '&' + preamble
|
||||
: "&" + preamble;
|
||||
}
|
||||
|
||||
private boolean isValidEntity(final String entity) {
|
||||
return inArray(entity, vAllowedEntities);
|
||||
}
|
||||
|
||||
private static boolean inArray(final String s, final String[] array) {
|
||||
for (String item : array) {
|
||||
if (item != null && item.equals(s)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean allowed(final String name) {
|
||||
return (vAllowed.isEmpty() || vAllowed.containsKey(name)) && !inArray(name, vDisallowed);
|
||||
}
|
||||
|
||||
private boolean allowedAttribute(final String name, final String paramName) {
|
||||
return allowed(name) && (vAllowed.isEmpty() || vAllowed.get(name).contains(paramName));
|
||||
}
|
||||
}
|
42
src/main/java/io/linfeng/common/xss/SQLFilter.java
Normal file
42
src/main/java/io/linfeng/common/xss/SQLFilter.java
Normal file
@ -0,0 +1,42 @@
|
||||
|
||||
package io.linfeng.common.xss;
|
||||
|
||||
import io.linfeng.common.exception.LinfengException;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
/**
|
||||
* 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 LinfengException("包含非法字符");
|
||||
}
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
}
|
29
src/main/java/io/linfeng/common/xss/XssFilter.java
Normal file
29
src/main/java/io/linfeng/common/xss/XssFilter.java
Normal file
@ -0,0 +1,29 @@
|
||||
|
||||
package io.linfeng.common.xss;
|
||||
|
||||
import javax.servlet.*;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* XSS过滤
|
||||
*
|
||||
*/
|
||||
public class XssFilter implements Filter {
|
||||
|
||||
@Override
|
||||
public void init(FilterConfig config) throws ServletException {
|
||||
}
|
||||
|
||||
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
|
||||
throws IOException, ServletException {
|
||||
XssHttpServletRequestWrapper xssRequest = new XssHttpServletRequestWrapper(
|
||||
(HttpServletRequest) request);
|
||||
chain.doFilter(xssRequest, response);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,139 @@
|
||||
|
||||
package io.linfeng.common.xss;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
|
||||
import javax.servlet.ReadListener;
|
||||
import javax.servlet.ServletInputStream;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletRequestWrapper;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* XSS过滤处理
|
||||
*
|
||||
*/
|
||||
public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper {
|
||||
//没被包装过的HttpServletRequest(特殊场景,需要自己过滤)
|
||||
HttpServletRequest orgRequest;
|
||||
//html过滤
|
||||
private final static HTMLFilter htmlFilter = new HTMLFilter();
|
||||
|
||||
public XssHttpServletRequestWrapper(HttpServletRequest request) {
|
||||
super(request);
|
||||
orgRequest = request;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServletInputStream getInputStream() throws IOException {
|
||||
//非json类型,直接返回
|
||||
if(!MediaType.APPLICATION_JSON_VALUE.equalsIgnoreCase(super.getHeader(HttpHeaders.CONTENT_TYPE))){
|
||||
return super.getInputStream();
|
||||
}
|
||||
|
||||
//为空,直接返回
|
||||
String json = IOUtils.toString(super.getInputStream(), "utf-8");
|
||||
if (StringUtils.isBlank(json)) {
|
||||
return super.getInputStream();
|
||||
}
|
||||
|
||||
//xss过滤
|
||||
json = xssEncode(json);
|
||||
final ByteArrayInputStream bis = new ByteArrayInputStream(json.getBytes("utf-8"));
|
||||
return new ServletInputStream() {
|
||||
@Override
|
||||
public boolean isFinished() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReady() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setReadListener(ReadListener readListener) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int read() throws IOException {
|
||||
return bis.read();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getParameter(String name) {
|
||||
String value = super.getParameter(xssEncode(name));
|
||||
if (StringUtils.isNotBlank(value)) {
|
||||
value = xssEncode(value);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getParameterValues(String name) {
|
||||
String[] parameters = super.getParameterValues(name);
|
||||
if (parameters == null || parameters.length == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
for (int i = 0; i < parameters.length; i++) {
|
||||
parameters[i] = xssEncode(parameters[i]);
|
||||
}
|
||||
return parameters;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String,String[]> getParameterMap() {
|
||||
Map<String,String[]> map = new LinkedHashMap<>();
|
||||
Map<String,String[]> parameters = super.getParameterMap();
|
||||
for (String key : parameters.keySet()) {
|
||||
String[] values = parameters.get(key);
|
||||
for (int i = 0; i < values.length; i++) {
|
||||
values[i] = xssEncode(values[i]);
|
||||
}
|
||||
map.put(key, values);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHeader(String name) {
|
||||
String value = super.getHeader(xssEncode(name));
|
||||
if (StringUtils.isNotBlank(value)) {
|
||||
value = xssEncode(value);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
private String xssEncode(String input) {
|
||||
return htmlFilter.filter(input);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取最原始的request
|
||||
*/
|
||||
public HttpServletRequest getOrgRequest() {
|
||||
return orgRequest;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取最原始的request
|
||||
*/
|
||||
public static HttpServletRequest getOrgRequest(HttpServletRequest request) {
|
||||
if (request instanceof XssHttpServletRequestWrapper) {
|
||||
return ((XssHttpServletRequestWrapper) request).getOrgRequest();
|
||||
}
|
||||
|
||||
return request;
|
||||
}
|
||||
|
||||
}
|
19
src/main/java/io/linfeng/config/CorsConfig.java
Normal file
19
src/main/java/io/linfeng/config/CorsConfig.java
Normal file
@ -0,0 +1,19 @@
|
||||
|
||||
package io.linfeng.config;
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
@Configuration
|
||||
public class CorsConfig implements WebMvcConfigurer {
|
||||
|
||||
@Override
|
||||
public void addCorsMappings(CorsRegistry registry) {
|
||||
registry.addMapping("/**")
|
||||
.allowedOrigins("*")
|
||||
.allowCredentials(true)
|
||||
.allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS")
|
||||
.maxAge(3600);
|
||||
}
|
||||
}
|
41
src/main/java/io/linfeng/config/FilterConfig.java
Normal file
41
src/main/java/io/linfeng/config/FilterConfig.java
Normal file
@ -0,0 +1,41 @@
|
||||
|
||||
package io.linfeng.config;
|
||||
|
||||
import io.linfeng.common.xss.XssFilter;
|
||||
import org.springframework.boot.web.servlet.FilterRegistrationBean;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.filter.DelegatingFilterProxy;
|
||||
|
||||
import javax.servlet.DispatcherType;
|
||||
|
||||
/**
|
||||
* Filter配置
|
||||
*
|
||||
*/
|
||||
@Configuration
|
||||
public class FilterConfig {
|
||||
|
||||
@Bean
|
||||
public FilterRegistrationBean shiroFilterRegistration() {
|
||||
FilterRegistrationBean registration = new FilterRegistrationBean();
|
||||
registration.setFilter(new DelegatingFilterProxy("shiroFilter"));
|
||||
//该值缺省为false,表示生命周期由SpringApplicationContext管理,设置为true则表示由ServletContainer管理
|
||||
registration.addInitParameter("targetFilterLifecycle", "true");
|
||||
registration.setEnabled(true);
|
||||
registration.setOrder(Integer.MAX_VALUE - 1);
|
||||
registration.addUrlPatterns("/*");
|
||||
return registration;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public FilterRegistrationBean xssFilterRegistration() {
|
||||
FilterRegistrationBean registration = new FilterRegistrationBean();
|
||||
registration.setDispatcherTypes(DispatcherType.REQUEST);
|
||||
registration.setFilter(new XssFilter());
|
||||
registration.addUrlPatterns("/*");
|
||||
registration.setName("xssFilter");
|
||||
registration.setOrder(Integer.MAX_VALUE);
|
||||
return registration;
|
||||
}
|
||||
}
|
31
src/main/java/io/linfeng/config/KaptchaConfig.java
Normal file
31
src/main/java/io/linfeng/config/KaptchaConfig.java
Normal file
@ -0,0 +1,31 @@
|
||||
|
||||
package io.linfeng.config;
|
||||
|
||||
import com.google.code.kaptcha.impl.DefaultKaptcha;
|
||||
import com.google.code.kaptcha.util.Config;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
|
||||
/**
|
||||
* 生成验证码配置
|
||||
*
|
||||
*/
|
||||
@Configuration
|
||||
public class KaptchaConfig {
|
||||
|
||||
@Bean
|
||||
public DefaultKaptcha producer() {
|
||||
Properties properties = new Properties();
|
||||
properties.put("kaptcha.border", "no");
|
||||
properties.put("kaptcha.textproducer.font.color", "black");
|
||||
properties.put("kaptcha.textproducer.char.space", "5");
|
||||
properties.put("kaptcha.textproducer.font.names", "Arial,Courier,cmr10,宋体,楷体,微软雅黑");
|
||||
Config config = new Config(properties);
|
||||
DefaultKaptcha defaultKaptcha = new DefaultKaptcha();
|
||||
defaultKaptcha.setConfig(config);
|
||||
return defaultKaptcha;
|
||||
}
|
||||
}
|
23
src/main/java/io/linfeng/config/MybatisPlusConfig.java
Normal file
23
src/main/java/io/linfeng/config/MybatisPlusConfig.java
Normal file
@ -0,0 +1,23 @@
|
||||
|
||||
package io.linfeng.config;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* mybatis-plus配置
|
||||
*
|
||||
*/
|
||||
@Configuration
|
||||
public class MybatisPlusConfig {
|
||||
|
||||
/**
|
||||
* 分页插件
|
||||
*/
|
||||
@Bean
|
||||
public PaginationInterceptor paginationInterceptor() {
|
||||
return new PaginationInterceptor();
|
||||
}
|
||||
|
||||
}
|
55
src/main/java/io/linfeng/config/RedisConfig.java
Normal file
55
src/main/java/io/linfeng/config/RedisConfig.java
Normal file
@ -0,0 +1,55 @@
|
||||
|
||||
package io.linfeng.config;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
import org.springframework.data.redis.core.*;
|
||||
import org.springframework.data.redis.serializer.StringRedisSerializer;
|
||||
|
||||
/**
|
||||
* Redis配置
|
||||
*
|
||||
*/
|
||||
@Configuration
|
||||
public class RedisConfig {
|
||||
@Autowired
|
||||
private RedisConnectionFactory factory;
|
||||
|
||||
@Bean
|
||||
public RedisTemplate<String, Object> redisTemplate() {
|
||||
RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>();
|
||||
redisTemplate.setKeySerializer(new StringRedisSerializer());
|
||||
redisTemplate.setHashKeySerializer(new StringRedisSerializer());
|
||||
redisTemplate.setHashValueSerializer(new StringRedisSerializer());
|
||||
redisTemplate.setValueSerializer(new StringRedisSerializer());
|
||||
redisTemplate.setConnectionFactory(factory);
|
||||
return redisTemplate;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public HashOperations<String, String, Object> hashOperations(RedisTemplate<String, Object> redisTemplate) {
|
||||
return redisTemplate.opsForHash();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ValueOperations<String, String> valueOperations(RedisTemplate<String, String> redisTemplate) {
|
||||
return redisTemplate.opsForValue();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ListOperations<String, Object> listOperations(RedisTemplate<String, Object> redisTemplate) {
|
||||
return redisTemplate.opsForList();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public SetOperations<String, Object> setOperations(RedisTemplate<String, Object> redisTemplate) {
|
||||
return redisTemplate.opsForSet();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ZSetOperations<String, Object> zSetOperations(RedisTemplate<String, Object> redisTemplate) {
|
||||
return redisTemplate.opsForZSet();
|
||||
}
|
||||
}
|
79
src/main/java/io/linfeng/config/ShiroConfig.java
Normal file
79
src/main/java/io/linfeng/config/ShiroConfig.java
Normal file
@ -0,0 +1,79 @@
|
||||
|
||||
package io.linfeng.config;
|
||||
|
||||
import io.linfeng.modules.sys.oauth2.OAuth2Filter;
|
||||
import io.linfeng.modules.sys.oauth2.OAuth2Realm;
|
||||
import org.apache.shiro.mgt.SecurityManager;
|
||||
import org.apache.shiro.spring.LifecycleBeanPostProcessor;
|
||||
import org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor;
|
||||
import org.apache.shiro.spring.web.ShiroFilterFactoryBean;
|
||||
import org.apache.shiro.web.mgt.DefaultWebSecurityManager;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import javax.servlet.Filter;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Shiro配置
|
||||
*
|
||||
*/
|
||||
@Configuration
|
||||
public class ShiroConfig {
|
||||
|
||||
@Bean("securityManager")
|
||||
public SecurityManager securityManager(OAuth2Realm oAuth2Realm) {
|
||||
DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager();
|
||||
securityManager.setRealm(oAuth2Realm);
|
||||
securityManager.setRememberMeManager(null);
|
||||
return securityManager;
|
||||
}
|
||||
|
||||
@Bean("shiroFilter")
|
||||
public ShiroFilterFactoryBean shiroFilter(SecurityManager securityManager) {
|
||||
ShiroFilterFactoryBean shiroFilter = new ShiroFilterFactoryBean();
|
||||
shiroFilter.setSecurityManager(securityManager);
|
||||
|
||||
//oauth过滤
|
||||
Map<String, Filter> filters = new HashMap<>();
|
||||
filters.put("oauth2", new OAuth2Filter());
|
||||
shiroFilter.setFilters(filters);
|
||||
|
||||
Map<String, String> filterMap = new LinkedHashMap<>();
|
||||
|
||||
filterMap.put("/index.html", "anon");
|
||||
filterMap.put("/css/**", "anon");
|
||||
filterMap.put("/js/**", "anon");
|
||||
filterMap.put("/doc.html", "anon");
|
||||
filterMap.put("/v2/api-docs/**", "anon");
|
||||
filterMap.put("/webjars/**", "anon");
|
||||
filterMap.put("/druid/**", "anon");
|
||||
filterMap.put("/app/**", "anon"); //app的拦截用注解方式
|
||||
filterMap.put("/sys/login", "anon");
|
||||
filterMap.put("/swagger/**", "anon");
|
||||
filterMap.put("/v2/api-docs", "anon");
|
||||
filterMap.put("/swagger-ui.html", "anon");
|
||||
filterMap.put("/swagger-resources/**", "anon");
|
||||
filterMap.put("/captcha.jpg", "anon");
|
||||
filterMap.put("/aaa.txt", "anon");
|
||||
filterMap.put("/**", "oauth2");
|
||||
shiroFilter.setFilterChainDefinitionMap(filterMap);
|
||||
|
||||
return shiroFilter;
|
||||
}
|
||||
|
||||
@Bean("lifecycleBeanPostProcessor")
|
||||
public LifecycleBeanPostProcessor lifecycleBeanPostProcessor() {
|
||||
return new LifecycleBeanPostProcessor();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor(SecurityManager securityManager) {
|
||||
AuthorizationAttributeSourceAdvisor advisor = new AuthorizationAttributeSourceAdvisor();
|
||||
advisor.setSecurityManager(securityManager);
|
||||
return advisor;
|
||||
}
|
||||
|
||||
}
|
79
src/main/java/io/linfeng/config/SwaggerConfig.java
Normal file
79
src/main/java/io/linfeng/config/SwaggerConfig.java
Normal file
@ -0,0 +1,79 @@
|
||||
|
||||
package io.linfeng.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
import springfox.documentation.builders.ApiInfoBuilder;
|
||||
import springfox.documentation.builders.PathSelectors;
|
||||
import springfox.documentation.builders.RequestHandlerSelectors;
|
||||
import springfox.documentation.service.*;
|
||||
import springfox.documentation.spi.DocumentationType;
|
||||
import springfox.documentation.spi.service.contexts.SecurityContext;
|
||||
import springfox.documentation.spring.web.plugins.Docket;
|
||||
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Configuration
|
||||
@EnableSwagger2
|
||||
public class SwaggerConfig implements WebMvcConfigurer {
|
||||
|
||||
@Bean
|
||||
public Docket createRestApi(){
|
||||
return new Docket(DocumentationType.SWAGGER_2)
|
||||
.apiInfo(apiInfo())
|
||||
.select()
|
||||
.apis(RequestHandlerSelectors.basePackage("io.linfeng"))
|
||||
// .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
|
||||
.paths(PathSelectors.any())
|
||||
.build()
|
||||
.securityContexts(securityContexts())
|
||||
.securitySchemes(securitySchemes());
|
||||
}
|
||||
|
||||
private ApiInfo apiInfo(){
|
||||
return new ApiInfoBuilder()
|
||||
.title("林风社交论坛项目接口文档")
|
||||
.description("林风社交论坛项目接口文档")
|
||||
.contact(new Contact("linfeng","http:localhost:8080/doc.html","3582996245@qq.com"))
|
||||
.version("1.0")
|
||||
.build();
|
||||
|
||||
}
|
||||
|
||||
private List<ApiKey> securitySchemes(){
|
||||
//设置请求头信息
|
||||
List<ApiKey> result = new ArrayList<>();
|
||||
ApiKey apiKey = new ApiKey("token","token","Header");
|
||||
result.add(apiKey);
|
||||
return result;
|
||||
}
|
||||
|
||||
private List<SecurityContext> securityContexts(){
|
||||
// 设置需要认证的路径
|
||||
List<SecurityContext> result = new ArrayList<>();
|
||||
result.add(getContextByPath("/.*"));
|
||||
return result;
|
||||
}
|
||||
|
||||
private SecurityContext getContextByPath(String pathRegex) {
|
||||
return SecurityContext.builder()
|
||||
.securityReferences(defaultAuth())
|
||||
.forPaths(PathSelectors.regex(pathRegex))
|
||||
.build();
|
||||
}
|
||||
|
||||
private List<SecurityReference> defaultAuth() {
|
||||
List<SecurityReference> result = new ArrayList<>();
|
||||
AuthorizationScope authorizationScope = new AuthorizationScope("global","accessEverything");
|
||||
AuthorizationScope[] authorizationScopes = new AuthorizationScope[1];
|
||||
authorizationScopes[0] = authorizationScope;
|
||||
result.add(new SecurityReference("token",authorizationScopes));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
|
||||
|
||||
package io.linfeng.datasource.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* 多数据源注解
|
||||
*
|
||||
*/
|
||||
@Target({ElementType.METHOD, ElementType.TYPE})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
@Inherited
|
||||
public @interface DataSource {
|
||||
String value() default "";
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
|
||||
|
||||
package io.linfeng.datasource.aspect;
|
||||
|
||||
|
||||
import io.linfeng.datasource.annotation.DataSource;
|
||||
import io.linfeng.datasource.config.DynamicContextHolder;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.annotation.Around;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.annotation.Pointcut;
|
||||
import org.aspectj.lang.reflect.MethodSignature;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
/**
|
||||
* 多数据源,切面处理类
|
||||
*
|
||||
*/
|
||||
@Aspect
|
||||
@Component
|
||||
@Order(Ordered.HIGHEST_PRECEDENCE)
|
||||
public class DataSourceAspect {
|
||||
protected Logger logger = LoggerFactory.getLogger(getClass());
|
||||
|
||||
@Pointcut("@annotation(io.linfeng.datasource.annotation.DataSource) " +
|
||||
"|| @within(io.linfeng.datasource.annotation.DataSource)")
|
||||
public void dataSourcePointCut() {
|
||||
|
||||
}
|
||||
|
||||
@Around("dataSourcePointCut()")
|
||||
public Object around(ProceedingJoinPoint point) throws Throwable {
|
||||
MethodSignature signature = (MethodSignature) point.getSignature();
|
||||
Class targetClass = point.getTarget().getClass();
|
||||
Method method = signature.getMethod();
|
||||
|
||||
DataSource targetDataSource = (DataSource)targetClass.getAnnotation(DataSource.class);
|
||||
DataSource methodDataSource = method.getAnnotation(DataSource.class);
|
||||
if(targetDataSource != null || methodDataSource != null){
|
||||
String value;
|
||||
if(methodDataSource != null){
|
||||
value = methodDataSource.value();
|
||||
}else {
|
||||
value = targetDataSource.value();
|
||||
}
|
||||
|
||||
DynamicContextHolder.push(value);
|
||||
logger.debug("set datasource is {}", value);
|
||||
}
|
||||
|
||||
try {
|
||||
return point.proceed();
|
||||
} finally {
|
||||
DynamicContextHolder.poll();
|
||||
logger.debug("clean datasource");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
|
||||
|
||||
package io.linfeng.datasource.config;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Deque;
|
||||
|
||||
/**
|
||||
* 多数据源上下文
|
||||
*
|
||||
*/
|
||||
public class DynamicContextHolder {
|
||||
@SuppressWarnings("unchecked")
|
||||
private static final ThreadLocal<Deque<String>> CONTEXT_HOLDER = new ThreadLocal() {
|
||||
@Override
|
||||
protected Object initialValue() {
|
||||
return new ArrayDeque();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 获得当前线程数据源
|
||||
*
|
||||
* @return 数据源名称
|
||||
*/
|
||||
public static String peek() {
|
||||
return CONTEXT_HOLDER.get().peek();
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置当前线程数据源
|
||||
*
|
||||
* @param dataSource 数据源名称
|
||||
*/
|
||||
public static void push(String dataSource) {
|
||||
CONTEXT_HOLDER.get().push(dataSource);
|
||||
}
|
||||
|
||||
/**
|
||||
* 清空当前线程数据源
|
||||
*/
|
||||
public static void poll() {
|
||||
Deque<String> deque = CONTEXT_HOLDER.get();
|
||||
deque.poll();
|
||||
if (deque.isEmpty()) {
|
||||
CONTEXT_HOLDER.remove();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
|
||||
|
||||
package io.linfeng.datasource.config;
|
||||
|
||||
import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;
|
||||
|
||||
/**
|
||||
* 多数据源
|
||||
*
|
||||
*/
|
||||
public class DynamicDataSource extends AbstractRoutingDataSource {
|
||||
|
||||
@Override
|
||||
protected Object determineCurrentLookupKey() {
|
||||
return DynamicContextHolder.peek();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
|
||||
|
||||
package io.linfeng.datasource.config;
|
||||
|
||||
import com.alibaba.druid.pool.DruidDataSource;
|
||||
import io.linfeng.datasource.properties.DataSourceProperties;
|
||||
import io.linfeng.datasource.properties.DynamicDataSourceProperties;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 配置多数据源
|
||||
*
|
||||
*/
|
||||
@Configuration
|
||||
@EnableConfigurationProperties(DynamicDataSourceProperties.class)
|
||||
public class DynamicDataSourceConfig {
|
||||
@Autowired
|
||||
private DynamicDataSourceProperties properties;
|
||||
|
||||
@Bean
|
||||
@ConfigurationProperties(prefix = "spring.datasource.druid")
|
||||
public DataSourceProperties dataSourceProperties() {
|
||||
return new DataSourceProperties();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public DynamicDataSource dynamicDataSource(DataSourceProperties dataSourceProperties) {
|
||||
DynamicDataSource dynamicDataSource = new DynamicDataSource();
|
||||
dynamicDataSource.setTargetDataSources(getDynamicDataSource());
|
||||
|
||||
//默认数据源
|
||||
DruidDataSource defaultDataSource = DynamicDataSourceFactory.buildDruidDataSource(dataSourceProperties);
|
||||
dynamicDataSource.setDefaultTargetDataSource(defaultDataSource);
|
||||
|
||||
return dynamicDataSource;
|
||||
}
|
||||
|
||||
private Map<Object, Object> getDynamicDataSource(){
|
||||
Map<String, DataSourceProperties> dataSourcePropertiesMap = properties.getDatasource();
|
||||
Map<Object, Object> targetDataSources = new HashMap<>(dataSourcePropertiesMap.size());
|
||||
dataSourcePropertiesMap.forEach((k, v) -> {
|
||||
DruidDataSource druidDataSource = DynamicDataSourceFactory.buildDruidDataSource(v);
|
||||
targetDataSources.put(k, druidDataSource);
|
||||
});
|
||||
|
||||
return targetDataSources;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
|
||||
|
||||
package io.linfeng.datasource.config;
|
||||
|
||||
import com.alibaba.druid.pool.DruidDataSource;
|
||||
import io.linfeng.datasource.properties.DataSourceProperties;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
||||
/**
|
||||
* DruidDataSource
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public class DynamicDataSourceFactory {
|
||||
|
||||
public static DruidDataSource buildDruidDataSource(DataSourceProperties properties) {
|
||||
DruidDataSource druidDataSource = new DruidDataSource();
|
||||
druidDataSource.setDriverClassName(properties.getDriverClassName());
|
||||
druidDataSource.setUrl(properties.getUrl());
|
||||
druidDataSource.setUsername(properties.getUsername());
|
||||
druidDataSource.setPassword(properties.getPassword());
|
||||
|
||||
druidDataSource.setInitialSize(properties.getInitialSize());
|
||||
druidDataSource.setMaxActive(properties.getMaxActive());
|
||||
druidDataSource.setMinIdle(properties.getMinIdle());
|
||||
druidDataSource.setMaxWait(properties.getMaxWait());
|
||||
druidDataSource.setTimeBetweenEvictionRunsMillis(properties.getTimeBetweenEvictionRunsMillis());
|
||||
druidDataSource.setMinEvictableIdleTimeMillis(properties.getMinEvictableIdleTimeMillis());
|
||||
druidDataSource.setMaxEvictableIdleTimeMillis(properties.getMaxEvictableIdleTimeMillis());
|
||||
druidDataSource.setValidationQuery(properties.getValidationQuery());
|
||||
druidDataSource.setValidationQueryTimeout(properties.getValidationQueryTimeout());
|
||||
druidDataSource.setTestOnBorrow(properties.isTestOnBorrow());
|
||||
druidDataSource.setTestOnReturn(properties.isTestOnReturn());
|
||||
druidDataSource.setPoolPreparedStatements(properties.isPoolPreparedStatements());
|
||||
druidDataSource.setMaxOpenPreparedStatements(properties.getMaxOpenPreparedStatements());
|
||||
druidDataSource.setSharePreparedStatements(properties.isSharePreparedStatements());
|
||||
|
||||
try {
|
||||
druidDataSource.setFilters(properties.getFilters());
|
||||
druidDataSource.init();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return druidDataSource;
|
||||
}
|
||||
}
|
@ -0,0 +1,195 @@
|
||||
|
||||
|
||||
package io.linfeng.datasource.properties;
|
||||
|
||||
/**
|
||||
* 多数据源属性
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public class DataSourceProperties {
|
||||
private String driverClassName;
|
||||
private String url;
|
||||
private String username;
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* Druid默认参数
|
||||
*/
|
||||
private int initialSize = 2;
|
||||
private int maxActive = 10;
|
||||
private int minIdle = -1;
|
||||
private long maxWait = 60 * 1000L;
|
||||
private long timeBetweenEvictionRunsMillis = 60 * 1000L;
|
||||
private long minEvictableIdleTimeMillis = 1000L * 60L * 30L;
|
||||
private long maxEvictableIdleTimeMillis = 1000L * 60L * 60L * 7;
|
||||
private String validationQuery = "select 1";
|
||||
private int validationQueryTimeout = -1;
|
||||
private boolean testOnBorrow = false;
|
||||
private boolean testOnReturn = false;
|
||||
private boolean testWhileIdle = true;
|
||||
private boolean poolPreparedStatements = false;
|
||||
private int maxOpenPreparedStatements = -1;
|
||||
private boolean sharePreparedStatements = false;
|
||||
private String filters = "stat,wall";
|
||||
|
||||
public String getDriverClassName() {
|
||||
return driverClassName;
|
||||
}
|
||||
|
||||
public void setDriverClassName(String driverClassName) {
|
||||
this.driverClassName = driverClassName;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public int getInitialSize() {
|
||||
return initialSize;
|
||||
}
|
||||
|
||||
public void setInitialSize(int initialSize) {
|
||||
this.initialSize = initialSize;
|
||||
}
|
||||
|
||||
public int getMaxActive() {
|
||||
return maxActive;
|
||||
}
|
||||
|
||||
public void setMaxActive(int maxActive) {
|
||||
this.maxActive = maxActive;
|
||||
}
|
||||
|
||||
public int getMinIdle() {
|
||||
return minIdle;
|
||||
}
|
||||
|
||||
public void setMinIdle(int minIdle) {
|
||||
this.minIdle = minIdle;
|
||||
}
|
||||
|
||||
public long getMaxWait() {
|
||||
return maxWait;
|
||||
}
|
||||
|
||||
public void setMaxWait(long maxWait) {
|
||||
this.maxWait = maxWait;
|
||||
}
|
||||
|
||||
public long getTimeBetweenEvictionRunsMillis() {
|
||||
return timeBetweenEvictionRunsMillis;
|
||||
}
|
||||
|
||||
public void setTimeBetweenEvictionRunsMillis(long timeBetweenEvictionRunsMillis) {
|
||||
this.timeBetweenEvictionRunsMillis = timeBetweenEvictionRunsMillis;
|
||||
}
|
||||
|
||||
public long getMinEvictableIdleTimeMillis() {
|
||||
return minEvictableIdleTimeMillis;
|
||||
}
|
||||
|
||||
public void setMinEvictableIdleTimeMillis(long minEvictableIdleTimeMillis) {
|
||||
this.minEvictableIdleTimeMillis = minEvictableIdleTimeMillis;
|
||||
}
|
||||
|
||||
public long getMaxEvictableIdleTimeMillis() {
|
||||
return maxEvictableIdleTimeMillis;
|
||||
}
|
||||
|
||||
public void setMaxEvictableIdleTimeMillis(long maxEvictableIdleTimeMillis) {
|
||||
this.maxEvictableIdleTimeMillis = maxEvictableIdleTimeMillis;
|
||||
}
|
||||
|
||||
public String getValidationQuery() {
|
||||
return validationQuery;
|
||||
}
|
||||
|
||||
public void setValidationQuery(String validationQuery) {
|
||||
this.validationQuery = validationQuery;
|
||||
}
|
||||
|
||||
public int getValidationQueryTimeout() {
|
||||
return validationQueryTimeout;
|
||||
}
|
||||
|
||||
public void setValidationQueryTimeout(int validationQueryTimeout) {
|
||||
this.validationQueryTimeout = validationQueryTimeout;
|
||||
}
|
||||
|
||||
public boolean isTestOnBorrow() {
|
||||
return testOnBorrow;
|
||||
}
|
||||
|
||||
public void setTestOnBorrow(boolean testOnBorrow) {
|
||||
this.testOnBorrow = testOnBorrow;
|
||||
}
|
||||
|
||||
public boolean isTestOnReturn() {
|
||||
return testOnReturn;
|
||||
}
|
||||
|
||||
public void setTestOnReturn(boolean testOnReturn) {
|
||||
this.testOnReturn = testOnReturn;
|
||||
}
|
||||
|
||||
public boolean isTestWhileIdle() {
|
||||
return testWhileIdle;
|
||||
}
|
||||
|
||||
public void setTestWhileIdle(boolean testWhileIdle) {
|
||||
this.testWhileIdle = testWhileIdle;
|
||||
}
|
||||
|
||||
public boolean isPoolPreparedStatements() {
|
||||
return poolPreparedStatements;
|
||||
}
|
||||
|
||||
public void setPoolPreparedStatements(boolean poolPreparedStatements) {
|
||||
this.poolPreparedStatements = poolPreparedStatements;
|
||||
}
|
||||
|
||||
public int getMaxOpenPreparedStatements() {
|
||||
return maxOpenPreparedStatements;
|
||||
}
|
||||
|
||||
public void setMaxOpenPreparedStatements(int maxOpenPreparedStatements) {
|
||||
this.maxOpenPreparedStatements = maxOpenPreparedStatements;
|
||||
}
|
||||
|
||||
public boolean isSharePreparedStatements() {
|
||||
return sharePreparedStatements;
|
||||
}
|
||||
|
||||
public void setSharePreparedStatements(boolean sharePreparedStatements) {
|
||||
this.sharePreparedStatements = sharePreparedStatements;
|
||||
}
|
||||
|
||||
public String getFilters() {
|
||||
return filters;
|
||||
}
|
||||
|
||||
public void setFilters(String filters) {
|
||||
this.filters = filters;
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
|
||||
|
||||
package io.linfeng.datasource.properties;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 多数据源属性
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@ConfigurationProperties(prefix = "dynamic")
|
||||
public class DynamicDataSourceProperties {
|
||||
private Map<String, DataSourceProperties> datasource = new LinkedHashMap<>();
|
||||
|
||||
public Map<String, DataSourceProperties> getDatasource() {
|
||||
return datasource;
|
||||
}
|
||||
|
||||
public void setDatasource(Map<String, DataSourceProperties> datasource) {
|
||||
this.datasource = datasource;
|
||||
}
|
||||
}
|
@ -0,0 +1,111 @@
|
||||
package io.linfeng.modules.admin.controller;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import io.linfeng.modules.admin.entity.AppUserEntity;
|
||||
import io.linfeng.modules.admin.service.AppUserService;
|
||||
import io.linfeng.common.utils.PageUtils;
|
||||
import io.linfeng.common.utils.R;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author linfeng
|
||||
* @email 2445465217@qq.com
|
||||
* @date 2022-01-20 12:10:43
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("admin/user")
|
||||
public class AppUserController {
|
||||
@Autowired
|
||||
private AppUserService appUserService;
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
@RequestMapping("/list")
|
||||
@RequiresPermissions("admin:user:list")
|
||||
public R list(@RequestParam Map<String, Object> params){
|
||||
PageUtils page = appUserService.queryPage(params);
|
||||
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*/
|
||||
@RequestMapping("/info/{uid}")
|
||||
@RequiresPermissions("admin:user:info")
|
||||
public R info(@PathVariable("uid") Integer uid){
|
||||
AppUserEntity user = appUserService.getById(uid);
|
||||
|
||||
return R.ok().put("user", user);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
@RequestMapping("/save")
|
||||
@RequiresPermissions("admin:user:save")
|
||||
public R save(@RequestBody AppUserEntity user){
|
||||
appUserService.save(user);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@RequestMapping("/update")
|
||||
@RequiresPermissions("admin:user:update")
|
||||
public R update(@RequestBody AppUserEntity user){
|
||||
appUserService.updateById(user);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@RequestMapping("/delete")
|
||||
@RequiresPermissions("admin:user:delete")
|
||||
public R delete(@RequestBody Integer[] uids){
|
||||
appUserService.removeByIds(Arrays.asList(uids));
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户禁用
|
||||
*/
|
||||
@RequestMapping("/ban/{id}")
|
||||
@RequiresPermissions("admin:user:delete")
|
||||
public R ban(@PathVariable("id") Integer id){
|
||||
appUserService.ban(id);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
/**
|
||||
* 用户解除禁用
|
||||
*/
|
||||
@RequestMapping("/openBan/{id}")
|
||||
@RequiresPermissions("admin:user:delete")
|
||||
public R openBan(@PathVariable("id") Integer id){
|
||||
appUserService.openBan(id);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,88 @@
|
||||
package io.linfeng.modules.admin.controller;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import io.linfeng.modules.admin.entity.CategoryEntity;
|
||||
import io.linfeng.modules.admin.service.CategoryService;
|
||||
import io.linfeng.common.utils.PageUtils;
|
||||
import io.linfeng.common.utils.R;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author linfeng
|
||||
* @email 2445465217@qq.com
|
||||
* @date 2022-01-21 14:32:52
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("admin/category")
|
||||
public class CategoryController {
|
||||
|
||||
|
||||
@Autowired
|
||||
private CategoryService categoryService;
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
@RequiresPermissions("admin:category:list")
|
||||
public R list(@RequestParam Map<String, Object> params){
|
||||
PageUtils page = categoryService.queryPage(params);
|
||||
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*/
|
||||
@GetMapping("/info/{cateId}")
|
||||
@RequiresPermissions("admin:category:info")
|
||||
public R info(@PathVariable("cateId") Integer cateId){
|
||||
CategoryEntity category = categoryService.getById(cateId);
|
||||
|
||||
return R.ok().put("category", category);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
@PostMapping("/save")
|
||||
@RequiresPermissions("admin:category:save")
|
||||
public R save(@RequestBody CategoryEntity category){
|
||||
|
||||
categoryService.saveCategory(category);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@PostMapping("/update")
|
||||
@RequiresPermissions("admin:category:update")
|
||||
public R update(@RequestBody CategoryEntity category){
|
||||
categoryService.updateById(category);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@PostMapping("/delete")
|
||||
@RequiresPermissions("admin:category:delete")
|
||||
public R delete(@RequestBody Integer[] cateIds){
|
||||
categoryService.removeByIds(Arrays.asList(cateIds));
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,90 @@
|
||||
package io.linfeng.modules.admin.controller;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import io.linfeng.modules.admin.entity.CommentEntity;
|
||||
import io.linfeng.modules.admin.service.CommentService;
|
||||
import io.linfeng.common.utils.PageUtils;
|
||||
import io.linfeng.common.utils.R;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*评论管理
|
||||
* @author linfeng
|
||||
* @email 2445465217@qq.com
|
||||
* @date 2022-01-24 21:29:22
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("admin/comment")
|
||||
public class CommentController {
|
||||
@Autowired
|
||||
private CommentService commentService;
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
@RequestMapping("/list")
|
||||
@RequiresPermissions("admin:comment:list")
|
||||
public R list(@RequestParam Map<String, Object> params){
|
||||
PageUtils page = commentService.queryPage(params);
|
||||
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*/
|
||||
@RequestMapping("/info/{id}")
|
||||
@RequiresPermissions("admin:comment:info")
|
||||
public R info(@PathVariable("id") Long id){
|
||||
CommentEntity comment = commentService.getById(id);
|
||||
|
||||
return R.ok().put("comment", comment);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
@RequestMapping("/save")
|
||||
@RequiresPermissions("admin:comment:save")
|
||||
public R save(@RequestBody CommentEntity comment){
|
||||
commentService.save(comment);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@RequestMapping("/update")
|
||||
@RequiresPermissions("admin:comment:update")
|
||||
public R update(@RequestBody CommentEntity comment){
|
||||
commentService.updateById(comment);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@RequestMapping("/delete")
|
||||
@RequiresPermissions("admin:comment:delete")
|
||||
public R delete(@RequestBody Long[] ids){
|
||||
commentService.removeByIds(Arrays.asList(ids));
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,90 @@
|
||||
package io.linfeng.modules.admin.controller;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import io.linfeng.modules.admin.entity.DiscussEntity;
|
||||
import io.linfeng.modules.admin.service.DiscussService;
|
||||
import io.linfeng.common.utils.PageUtils;
|
||||
import io.linfeng.common.utils.R;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author linfeng
|
||||
* @email 2445465217@qq.com
|
||||
* @date 2022-01-24 13:44:37
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("admin/discuss")
|
||||
public class DiscussController {
|
||||
@Autowired
|
||||
private DiscussService discussService;
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
@RequestMapping("/list")
|
||||
@RequiresPermissions("admin:discuss:list")
|
||||
public R list(@RequestParam Map<String, Object> params){
|
||||
PageUtils page = discussService.queryPage(params);
|
||||
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*/
|
||||
@RequestMapping("/info/{id}")
|
||||
@RequiresPermissions("admin:discuss:info")
|
||||
public R info(@PathVariable("id") Integer id){
|
||||
DiscussEntity discuss = discussService.getById(id);
|
||||
|
||||
return R.ok().put("discuss", discuss);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
@RequestMapping("/save")
|
||||
@RequiresPermissions("admin:discuss:save")
|
||||
public R save(@RequestBody DiscussEntity discuss){
|
||||
discussService.save(discuss);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@RequestMapping("/update")
|
||||
@RequiresPermissions("admin:discuss:update")
|
||||
public R update(@RequestBody DiscussEntity discuss){
|
||||
discussService.updateById(discuss);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@RequestMapping("/delete")
|
||||
@RequiresPermissions("admin:discuss:delete")
|
||||
public R delete(@RequestBody Integer[] ids){
|
||||
discussService.removeByIds(Arrays.asList(ids));
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,90 @@
|
||||
package io.linfeng.modules.admin.controller;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import io.linfeng.modules.admin.entity.LinkEntity;
|
||||
import io.linfeng.modules.admin.service.LinkService;
|
||||
import io.linfeng.common.utils.PageUtils;
|
||||
import io.linfeng.common.utils.R;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author linfeng
|
||||
* @email 2445465217@qq.com
|
||||
* @date 2022-01-26 14:05:38
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("admin/link")
|
||||
public class LinkController {
|
||||
@Autowired
|
||||
private LinkService linkService;
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
@RequestMapping("/list")
|
||||
@RequiresPermissions("admin:link:list")
|
||||
public R list(@RequestParam Map<String, Object> params){
|
||||
PageUtils page = linkService.queryPage(params);
|
||||
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*/
|
||||
@RequestMapping("/info/{id}")
|
||||
@RequiresPermissions("admin:link:info")
|
||||
public R info(@PathVariable("id") Integer id){
|
||||
LinkEntity link = linkService.getById(id);
|
||||
|
||||
return R.ok().put("link", link);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
@RequestMapping("/save")
|
||||
@RequiresPermissions("admin:link:save")
|
||||
public R save(@RequestBody LinkEntity link){
|
||||
linkService.save(link);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@RequestMapping("/update")
|
||||
@RequiresPermissions("admin:link:update")
|
||||
public R update(@RequestBody LinkEntity link){
|
||||
linkService.updateById(link);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@RequestMapping("/delete")
|
||||
@RequiresPermissions("admin:link:delete")
|
||||
public R delete(@RequestBody Integer[] ids){
|
||||
linkService.removeByIds(Arrays.asList(ids));
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,90 @@
|
||||
package io.linfeng.modules.admin.controller;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import io.linfeng.modules.admin.entity.MessageEntity;
|
||||
import io.linfeng.modules.admin.service.MessageService;
|
||||
import io.linfeng.common.utils.PageUtils;
|
||||
import io.linfeng.common.utils.R;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* 消息管理
|
||||
* @author linfeng
|
||||
* @email 2445465217@qq.com
|
||||
* @date 2022-01-26 13:15:30
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("admin/message")
|
||||
public class MessageController {
|
||||
@Autowired
|
||||
private MessageService messageService;
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
@RequestMapping("/list")
|
||||
@RequiresPermissions("admin:message:list")
|
||||
public R list(@RequestParam Map<String, Object> params){
|
||||
PageUtils page = messageService.queryPage(params);
|
||||
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*/
|
||||
@RequestMapping("/info/{mId}")
|
||||
@RequiresPermissions("admin:message:info")
|
||||
public R info(@PathVariable("mId") Integer mId){
|
||||
MessageEntity message = messageService.getById(mId);
|
||||
|
||||
return R.ok().put("message", message);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
@RequestMapping("/save")
|
||||
@RequiresPermissions("admin:message:save")
|
||||
public R save(@RequestBody MessageEntity message){
|
||||
messageService.save(message);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@RequestMapping("/update")
|
||||
@RequiresPermissions("admin:message:update")
|
||||
public R update(@RequestBody MessageEntity message){
|
||||
messageService.updateById(message);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@RequestMapping("/delete")
|
||||
@RequiresPermissions("admin:message:delete")
|
||||
public R delete(@RequestBody Integer[] mIds){
|
||||
messageService.removeByIds(Arrays.asList(mIds));
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,90 @@
|
||||
package io.linfeng.modules.admin.controller;
|
||||
|
||||
import io.linfeng.common.utils.PageUtils;
|
||||
import io.linfeng.common.utils.R;
|
||||
import io.linfeng.modules.app.entity.MomentEntity;
|
||||
import io.linfeng.modules.app.service.MomentService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author linfeng
|
||||
* @date 2022/1/5 16:56
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("admin/moment")
|
||||
@Api(tags = "管理端——动态接口")
|
||||
public class MomentManageController {
|
||||
|
||||
|
||||
@Autowired
|
||||
private MomentService momentService;
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
@ApiOperation("后台——动态分页列表")
|
||||
@GetMapping("/list")
|
||||
@RequiresPermissions("app:moment:list")
|
||||
public R list(@RequestParam Map<String, Object> params){
|
||||
PageUtils page = momentService.queryPage(params);
|
||||
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*/
|
||||
@ApiOperation("后台——根据id获取动态")
|
||||
@GetMapping("/info/{id}")
|
||||
@RequiresPermissions("app:moment:info")
|
||||
public R info(@PathVariable("id") Long id){
|
||||
MomentEntity moment = momentService.getById(id);
|
||||
|
||||
return R.ok().put("moment", moment);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
@ApiOperation("后台——保存动态")
|
||||
@PostMapping("/save")
|
||||
@RequiresPermissions("app:moment:save")
|
||||
public R save(@RequestBody MomentEntity moment){
|
||||
momentService.save(moment);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@ApiOperation("后台——修改动态")
|
||||
@PostMapping("/update")
|
||||
@RequiresPermissions("app:moment:update")
|
||||
public R update(@RequestBody MomentEntity moment){
|
||||
momentService.updateById(moment);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@ApiOperation("后台——删除动态")
|
||||
@PostMapping("/delete")
|
||||
@RequiresPermissions("app:moment:delete")
|
||||
public R delete(@RequestBody Long[] ids){
|
||||
momentService.removeByIds(Arrays.asList(ids));
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,85 @@
|
||||
package io.linfeng.modules.admin.controller;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import io.linfeng.modules.admin.entity.PostEntity;
|
||||
import io.linfeng.modules.admin.service.PostService;
|
||||
import io.linfeng.common.utils.PageUtils;
|
||||
import io.linfeng.common.utils.R;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*帖子管理
|
||||
* @author linfeng
|
||||
* @email 2445465217@qq.com
|
||||
* @date 2022-01-23 20:49:55
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("admin/post")
|
||||
public class PostController {
|
||||
@Autowired
|
||||
private PostService postService;
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
@RequestMapping("/list")
|
||||
@RequiresPermissions("admin:post:list")
|
||||
public R list(@RequestParam Map<String, Object> params){
|
||||
PageUtils page = postService.queryPage(params);
|
||||
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*/
|
||||
@RequestMapping("/info/{id}")
|
||||
@RequiresPermissions("admin:post:info")
|
||||
public R info(@PathVariable("id") Integer id){
|
||||
PostEntity post = postService.getById(id);
|
||||
|
||||
return R.ok().put("post", post);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
@PostMapping("/save")
|
||||
@RequiresPermissions("admin:post:save")
|
||||
public R save(@RequestBody PostEntity post){
|
||||
postService.save(post);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@PostMapping("/update")
|
||||
@RequiresPermissions("admin:post:update")
|
||||
public R update(@RequestBody PostEntity post){
|
||||
postService.updateById(post);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@PostMapping("/delete")
|
||||
@RequiresPermissions("admin:post:delete")
|
||||
public R delete(@RequestBody Integer[] ids){
|
||||
postService.deleteByAdmin(Arrays.asList(ids));
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,90 @@
|
||||
package io.linfeng.modules.admin.controller;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import io.linfeng.modules.admin.entity.SensitiveEntity;
|
||||
import io.linfeng.modules.admin.service.SensitiveService;
|
||||
import io.linfeng.common.utils.PageUtils;
|
||||
import io.linfeng.common.utils.R;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 敏感词库信息表
|
||||
*
|
||||
* @author linfeng
|
||||
* @email 2445465217@qq.com
|
||||
* @date 2022-01-28 13:40:57
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("admin/sensitive")
|
||||
public class SensitiveController {
|
||||
@Autowired
|
||||
private SensitiveService sensitiveService;
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
@RequestMapping("/list")
|
||||
@RequiresPermissions("admin:sensitive:list")
|
||||
public R list(@RequestParam Map<String, Object> params){
|
||||
PageUtils page = sensitiveService.queryPage(params);
|
||||
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*/
|
||||
@RequestMapping("/info/{id}")
|
||||
@RequiresPermissions("admin:sensitive:info")
|
||||
public R info(@PathVariable("id") Long id){
|
||||
SensitiveEntity sensitive = sensitiveService.getById(id);
|
||||
|
||||
return R.ok().put("sensitive", sensitive);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
@RequestMapping("/save")
|
||||
@RequiresPermissions("admin:sensitive:save")
|
||||
public R save(@RequestBody SensitiveEntity sensitive){
|
||||
sensitiveService.save(sensitive);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@RequestMapping("/update")
|
||||
@RequiresPermissions("admin:sensitive:update")
|
||||
public R update(@RequestBody SensitiveEntity sensitive){
|
||||
sensitiveService.updateById(sensitive);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@RequestMapping("/delete")
|
||||
@RequiresPermissions("admin:sensitive:delete")
|
||||
public R delete(@RequestBody Long[] ids){
|
||||
sensitiveService.removeByIds(Arrays.asList(ids));
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package io.linfeng.modules.admin.controller;
|
||||
|
||||
import io.linfeng.common.utils.R;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* 后台前端首页数据统计
|
||||
* @author linfeng
|
||||
* @date 2022/4/17 16:49
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("admin/statistics")
|
||||
public class StatisticController {
|
||||
|
||||
@GetMapping("/home")
|
||||
public R index(){
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
}
|
@ -0,0 +1,93 @@
|
||||
package io.linfeng.modules.admin.controller;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import io.linfeng.modules.admin.entity.SystemEntity;
|
||||
import io.linfeng.modules.admin.service.SystemService;
|
||||
import io.linfeng.common.utils.PageUtils;
|
||||
import io.linfeng.common.utils.R;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author linfeng
|
||||
* @email 2445465217@qq.com
|
||||
* @date 2022-01-19 16:29:48
|
||||
*/
|
||||
@Api(tags = "管理端——获取配置接口")
|
||||
@RestController
|
||||
@RequestMapping("admin/system")
|
||||
public class SystemController {
|
||||
@Autowired
|
||||
private SystemService systemService;
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
@ApiOperation("后台——配置分页列表")
|
||||
@GetMapping("/list")
|
||||
@RequiresPermissions("admin:system:list")
|
||||
public R list(@RequestParam Map<String, Object> params){
|
||||
PageUtils page = systemService.queryPage(params);
|
||||
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*/
|
||||
@ApiOperation("后台——根据id获取配置详情")
|
||||
@GetMapping("/info/{config}")
|
||||
@RequiresPermissions("admin:system:info")
|
||||
public R info(@PathVariable("config") String config){
|
||||
SystemEntity system = systemService.getById(config);
|
||||
|
||||
return R.ok().put("system", system);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
@ApiOperation("后台——配置保存")
|
||||
@PostMapping("/save")
|
||||
@RequiresPermissions("admin:system:save")
|
||||
public R save(@RequestBody SystemEntity system){
|
||||
systemService.save(system);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@ApiOperation("后台——配置修改")
|
||||
@PostMapping("/update")
|
||||
@RequiresPermissions("admin:system:update")
|
||||
public R update(@RequestBody SystemEntity system){
|
||||
systemService.updateById(system);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@ApiOperation("后台——配置删除")
|
||||
@PostMapping("/delete")
|
||||
@RequiresPermissions("admin:system:delete")
|
||||
public R delete(@RequestBody String[] configs){
|
||||
systemService.removeByIds(Arrays.asList(configs));
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,90 @@
|
||||
package io.linfeng.modules.admin.controller;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import io.linfeng.modules.admin.entity.TopicEntity;
|
||||
import io.linfeng.modules.admin.service.TopicService;
|
||||
import io.linfeng.common.utils.PageUtils;
|
||||
import io.linfeng.common.utils.R;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author linfeng
|
||||
* @email 2445465217@qq.com
|
||||
* @date 2022-01-21 17:01:12
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("admin/topic")
|
||||
public class TopicController {
|
||||
@Autowired
|
||||
private TopicService topicService;
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
@RequestMapping("/list")
|
||||
@RequiresPermissions("admin:topic:list")
|
||||
public R list(@RequestParam Map<String, Object> params){
|
||||
PageUtils page = topicService.queryPage(params);
|
||||
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*/
|
||||
@RequestMapping("/info/{id}")
|
||||
@RequiresPermissions("admin:topic:info")
|
||||
public R info(@PathVariable("id") Integer id){
|
||||
TopicEntity topic = topicService.getById(id);
|
||||
|
||||
return R.ok().put("topic", topic);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
@RequestMapping("/save")
|
||||
@RequiresPermissions("admin:topic:save")
|
||||
public R save(@RequestBody TopicEntity topic){
|
||||
topicService.save(topic);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@RequestMapping("/update")
|
||||
@RequiresPermissions("admin:topic:update")
|
||||
public R update(@RequestBody TopicEntity topic){
|
||||
topicService.updateById(topic);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@RequestMapping("/delete")
|
||||
@RequiresPermissions("admin:topic:delete")
|
||||
public R delete(@RequestBody Integer[] ids){
|
||||
topicService.removeByIds(Arrays.asList(ids));
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
}
|
17
src/main/java/io/linfeng/modules/admin/dao/AppUserDao.java
Normal file
17
src/main/java/io/linfeng/modules/admin/dao/AppUserDao.java
Normal file
@ -0,0 +1,17 @@
|
||||
package io.linfeng.modules.admin.dao;
|
||||
|
||||
import io.linfeng.modules.admin.entity.AppUserEntity;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author linfeng
|
||||
* @email 3582996245@qq.com
|
||||
* @date 2022-01-20 12:10:43
|
||||
*/
|
||||
@Mapper
|
||||
public interface AppUserDao extends BaseMapper<AppUserEntity> {
|
||||
|
||||
}
|
17
src/main/java/io/linfeng/modules/admin/dao/CategoryDao.java
Normal file
17
src/main/java/io/linfeng/modules/admin/dao/CategoryDao.java
Normal file
@ -0,0 +1,17 @@
|
||||
package io.linfeng.modules.admin.dao;
|
||||
|
||||
import io.linfeng.modules.admin.entity.CategoryEntity;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author linfeng
|
||||
* @email 3582996245@qq.com
|
||||
* @date 2022-01-21 14:32:52
|
||||
*/
|
||||
@Mapper
|
||||
public interface CategoryDao extends BaseMapper<CategoryEntity> {
|
||||
|
||||
}
|
17
src/main/java/io/linfeng/modules/admin/dao/CommentDao.java
Normal file
17
src/main/java/io/linfeng/modules/admin/dao/CommentDao.java
Normal file
@ -0,0 +1,17 @@
|
||||
package io.linfeng.modules.admin.dao;
|
||||
|
||||
import io.linfeng.modules.admin.entity.CommentEntity;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author linfeng
|
||||
* @email 3582996245@qq.com
|
||||
* @date 2022-01-24 21:29:22
|
||||
*/
|
||||
@Mapper
|
||||
public interface CommentDao extends BaseMapper<CommentEntity> {
|
||||
|
||||
}
|
17
src/main/java/io/linfeng/modules/admin/dao/DiscussDao.java
Normal file
17
src/main/java/io/linfeng/modules/admin/dao/DiscussDao.java
Normal file
@ -0,0 +1,17 @@
|
||||
package io.linfeng.modules.admin.dao;
|
||||
|
||||
import io.linfeng.modules.admin.entity.DiscussEntity;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author linfeng
|
||||
* @email 3582996245@qq.com
|
||||
* @date 2022-01-24 13:44:37
|
||||
*/
|
||||
@Mapper
|
||||
public interface DiscussDao extends BaseMapper<DiscussEntity> {
|
||||
|
||||
}
|
17
src/main/java/io/linfeng/modules/admin/dao/LinkDao.java
Normal file
17
src/main/java/io/linfeng/modules/admin/dao/LinkDao.java
Normal file
@ -0,0 +1,17 @@
|
||||
package io.linfeng.modules.admin.dao;
|
||||
|
||||
import io.linfeng.modules.admin.entity.LinkEntity;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author linfeng
|
||||
* @email 3582996245@qq.com
|
||||
* @date 2022-01-26 14:05:38
|
||||
*/
|
||||
@Mapper
|
||||
public interface LinkDao extends BaseMapper<LinkEntity> {
|
||||
|
||||
}
|
17
src/main/java/io/linfeng/modules/admin/dao/MessageDao.java
Normal file
17
src/main/java/io/linfeng/modules/admin/dao/MessageDao.java
Normal file
@ -0,0 +1,17 @@
|
||||
package io.linfeng.modules.admin.dao;
|
||||
|
||||
import io.linfeng.modules.admin.entity.MessageEntity;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author linfeng
|
||||
* @email 3582996245@qq.com
|
||||
* @date 2022-01-26 13:15:30
|
||||
*/
|
||||
@Mapper
|
||||
public interface MessageDao extends BaseMapper<MessageEntity> {
|
||||
|
||||
}
|
17
src/main/java/io/linfeng/modules/admin/dao/PostDao.java
Normal file
17
src/main/java/io/linfeng/modules/admin/dao/PostDao.java
Normal file
@ -0,0 +1,17 @@
|
||||
package io.linfeng.modules.admin.dao;
|
||||
|
||||
import io.linfeng.modules.admin.entity.PostEntity;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author linfeng
|
||||
* @email 3582996245@qq.com
|
||||
* @date 2022-01-23 20:49:55
|
||||
*/
|
||||
@Mapper
|
||||
public interface PostDao extends BaseMapper<PostEntity> {
|
||||
|
||||
}
|
17
src/main/java/io/linfeng/modules/admin/dao/SensitiveDao.java
Normal file
17
src/main/java/io/linfeng/modules/admin/dao/SensitiveDao.java
Normal file
@ -0,0 +1,17 @@
|
||||
package io.linfeng.modules.admin.dao;
|
||||
|
||||
import io.linfeng.modules.admin.entity.SensitiveEntity;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 敏感词库信息表
|
||||
*
|
||||
* @author linfeng
|
||||
* @email 3582996245@qq.com
|
||||
* @date 2022-01-28 13:40:57
|
||||
*/
|
||||
@Mapper
|
||||
public interface SensitiveDao extends BaseMapper<SensitiveEntity> {
|
||||
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user