init project
This commit is contained in:
parent
8bd9406a18
commit
e386b978c3
|
|
@ -0,0 +1 @@
|
|||
/target/
|
||||
44
README.md
44
README.md
|
|
@ -1 +1,43 @@
|
|||
#tcwm-java
|
||||
**项目说明**
|
||||
- sqx-fast是一个轻量级的,前后端分离的Java快速开发平台,能快速开发项目并交付
|
||||
- 支持MySQL、PostgreSQL等主流数据库
|
||||
<br>
|
||||
|
||||
|
||||
**具有如下特点**
|
||||
- 友好的代码结构及注释,便于阅读及二次开发
|
||||
- 实现前后端分离,通过token进行数据交互,前端再也不用关注后端技术
|
||||
- 灵活的权限控制,可控制到页面或按钮,满足绝大部分的权限需求
|
||||
- 页面交互使用Vue2.x,极大的提高了开发效率
|
||||
- 引入API模板,根据token作为登录令牌,极大的方便了APP接口开发
|
||||
- 引入swagger文档支持,方便编写API接口文档
|
||||
<br>
|
||||
|
||||
邮箱jar包导入执行下面的命令,将路径改为你电脑项目的路径
|
||||
mvn install:install-file -Dfile=D:\workspace\paotui5.0\lib\mail.jar -DgroupId=mail -DartifactId=email -Dversion=20220902 -Dpackaging=jar
|
||||
|
||||
|
||||
|
||||
**技术选型:**
|
||||
- 核心框架:Spring Boot 2.6
|
||||
- 安全框架:Apache Shiro 1.4
|
||||
- 视图框架:Spring MVC 5.0
|
||||
- 持久层框架:MyBatis 3.3
|
||||
- 数据库连接池:Druid 1.0
|
||||
- 日志管理:SLF4J 1.7、Log4j
|
||||
- 页面交互:Vue2.x
|
||||
<br>
|
||||
|
||||
|
||||
**后端部署**
|
||||
- 通过git下载源码
|
||||
- idea、eclipse需安装lombok插件,不然会提示找不到entity的get set方法
|
||||
- 创建数据库sqx_fast,数据库编码为UTF-8
|
||||
- 执行db/mysql.sql文件,初始化数据
|
||||
- 修改application-dev.yml,更新MySQL账号和密码
|
||||
- Eclipse、IDEA运行sqxApplication.java,则可启动项目
|
||||
- Swagger文档路径:http://localhost:8082/sqx_fast/swagger/index.html
|
||||
- Swagger注解路径:http://localhost:8082/sqx_fast/swagger-ui.html
|
||||
|
||||
|
||||
<br>
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1,496 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.sqx</groupId>
|
||||
<artifactId>tcwm3.0</artifactId>
|
||||
<version>3.0.0</version>
|
||||
<packaging>jar</packaging>
|
||||
<description>sqx_fast</description>
|
||||
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.6.11</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.2.0</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.10.1</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>3.4.0</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.83</fastjson.version>
|
||||
<hutool.version>4.1.1</hutool.version>
|
||||
<lombok.version>1.18.4</lombok.version>
|
||||
|
||||
|
||||
<!--wagon plugin 配置-->
|
||||
<!--<service-path>/work/sz</service-path>
|
||||
<pack-name>${project.artifactId}-${project.version}.jar</pack-name>
|
||||
<remote-addr>192.168.1.10:22</remote-addr>
|
||||
<remote-username>root</remote-username>
|
||||
<remote-passwd>123456</remote-passwd>-->
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.gavaghan</groupId>
|
||||
<artifactId>geodesy</artifactId>
|
||||
<version>1.1.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hibernate.validator</groupId>
|
||||
<artifactId>hibernate-validator</artifactId>
|
||||
<version>6.2.3.Final</version>
|
||||
</dependency>
|
||||
<!--<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-core</artifactId>
|
||||
<version>5.2.9.RELEASE</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-beans</artifactId>
|
||||
<version>5.2.9.RELEASE</version>
|
||||
</dependency>-->
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-websocket</artifactId>
|
||||
<version>5.1.2.RELEASE</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.getui.push</groupId>
|
||||
<artifactId>restful-sdk</artifactId>
|
||||
<version>1.0.0.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-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>org.springframework.boot</groupId>-->
|
||||
<!--<artifactId>spring-boot-devtools</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.github.qcloudsms</groupId>
|
||||
<artifactId>qcloudsms</artifactId>
|
||||
<version>1.0.6</version>
|
||||
</dependency>
|
||||
<!--阿里云短信-->
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>aliyun-java-sdk-core</artifactId>
|
||||
<version>4.5.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.aliyun.oss</groupId>
|
||||
<artifactId>aliyun-sdk-oss</artifactId>
|
||||
<version>3.4.0</version>
|
||||
</dependency>
|
||||
<!-- 苹果工具类 -->
|
||||
<dependency>
|
||||
<groupId>com.auth0</groupId>
|
||||
<artifactId>java-jwt</artifactId>
|
||||
<version>3.8.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.auth0</groupId>
|
||||
<artifactId>jwks-rsa</artifactId>
|
||||
<version>0.12.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.jsonwebtoken</groupId>
|
||||
<artifactId>jjwt</artifactId>
|
||||
<version>0.9.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.sf.json-lib</groupId>
|
||||
<artifactId>json-lib</artifactId>
|
||||
<version>2.4</version>
|
||||
<classifier>jdk15</classifier>
|
||||
</dependency>
|
||||
<!-- 集成支付宝sdk -->
|
||||
<dependency>
|
||||
<groupId>com.alipay.sdk</groupId>
|
||||
<artifactId>alipay-sdk-java</artifactId>
|
||||
<version>4.10.29.ALL</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.wxpay</groupId>
|
||||
<artifactId>wxpay-sdk</artifactId>
|
||||
<version>0.0.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.liyiorg</groupId>
|
||||
<artifactId>weixin-popular</artifactId>
|
||||
<version>2.8.25</version>
|
||||
</dependency>
|
||||
<!--oracle驱动-->
|
||||
<dependency>
|
||||
<groupId>com.oracle</groupId>
|
||||
<artifactId>ojdbc6</artifactId>
|
||||
<version>${oracle.version}</version>
|
||||
</dependency>
|
||||
<!--mssql驱动-->
|
||||
<dependency>
|
||||
<groupId>com.microsoft.sqlserver</groupId>
|
||||
<artifactId>sqljdbc4</artifactId>
|
||||
<version>${mssql.version}</version>
|
||||
</dependency>
|
||||
<!--postgresql驱动-->
|
||||
<dependency>
|
||||
<groupId>org.postgresql</groupId>
|
||||
<artifactId>postgresql</artifactId>
|
||||
</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>
|
||||
<dependency>
|
||||
<groupId>org</groupId>
|
||||
<artifactId>jaudiotagger</artifactId>
|
||||
<version>2.0.3</version>
|
||||
</dependency>
|
||||
|
||||
<!--二维码生成架包引用-->
|
||||
<!-- https://mvnrepository.com/artifact/com.google.zxing/core -->
|
||||
<dependency>
|
||||
<groupId>com.google.zxing</groupId>
|
||||
<artifactId>core</artifactId>
|
||||
<version>3.3.3</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/com.google.zxing/javase -->
|
||||
<dependency>
|
||||
<groupId>com.google.zxing</groupId>
|
||||
<artifactId>javase</artifactId>
|
||||
<version>3.3.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.binarywang</groupId>
|
||||
<artifactId>weixin-java-mp</artifactId>
|
||||
<version>3.6.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.binarywang</groupId>
|
||||
<artifactId>weixin-java-pay</artifactId>
|
||||
<version>3.6.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.pagehelper</groupId>
|
||||
<artifactId>pagehelper-spring-boot-starter</artifactId>
|
||||
<version>1.4.1</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>mybatis-spring</artifactId>
|
||||
<groupId>org.mybatis</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>mybatis</artifactId>
|
||||
<groupId>org.mybatis</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.dozermapper</groupId>
|
||||
<artifactId>dozer-core</artifactId>
|
||||
<version>6.4.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.wxpay</groupId>
|
||||
<artifactId>wxpay-sdk</artifactId>
|
||||
<version>0.0.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml</artifactId>
|
||||
<version>4.0.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml</artifactId>
|
||||
<version>4.0.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml</artifactId>
|
||||
<version>4.0.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||
</dependency>
|
||||
<!--<dependency>-->
|
||||
<!--<groupId>com.baidu.aip</groupId>-->
|
||||
<!-- <artifactId>java-sdk</artifactId>-->
|
||||
<!-- <version>4.11.3</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>
|
||||
<command><![CDATA[nohup java -jar ${service-path}/${pack-name} --spring.profiles.active=test > ${service-path}/sz.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>sqx/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>https://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>https://maven.aliyun.com/nexus/content/groups/public/</url>
|
||||
<releases>
|
||||
<enabled>true</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
|
||||
</project>
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
package com.sqx;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
|
||||
|
||||
@EnableScheduling
|
||||
@SpringBootApplication
|
||||
public class SqxApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(SqxApplication.class, args);
|
||||
System.out.println("(♥◠‿◠)ノ゙ 同城外卖项目启动成功 ლ(´ڡ`ლ)゙ \n"+
|
||||
" _ \n" +
|
||||
" | | \n" +
|
||||
" ___ | | __\n" +
|
||||
" / _ \\| |/ /\n" +
|
||||
"| (_) | < \n" +
|
||||
" \\___/|_|\\_\\");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
package com.sqx.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 "";
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
package com.sqx.common.aspect;
|
||||
|
||||
import com.sqx.common.exception.SqxException;
|
||||
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(* com.sqx.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 SqxException("Redis服务异常");
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,92 @@
|
|||
package com.sqx.common.aspect;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.sqx.common.utils.HttpContextUtils;
|
||||
import com.sqx.common.utils.IPUtils;
|
||||
import com.sqx.common.annotation.SysLog;
|
||||
import com.sqx.modules.sys.entity.SysLogEntity;
|
||||
import com.sqx.modules.sys.entity.SysUserEntity;
|
||||
import com.sqx.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(com.sqx.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,52 @@
|
|||
package com.sqx.common.exception;
|
||||
|
||||
/**
|
||||
* 自定义异常
|
||||
*
|
||||
*/
|
||||
public class SqxException extends RuntimeException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String msg;
|
||||
private int code = 500;
|
||||
|
||||
public SqxException(String msg) {
|
||||
super(msg);
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public SqxException(String msg, Throwable e) {
|
||||
super(msg, e);
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public SqxException(String msg, int code) {
|
||||
super(msg);
|
||||
this.msg = msg;
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public SqxException(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,55 @@
|
|||
package com.sqx.common.exception;
|
||||
|
||||
import com.sqx.common.utils.Result;
|
||||
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 SqxExceptionHandler {
|
||||
private Logger logger = LoggerFactory.getLogger(getClass());
|
||||
|
||||
/**
|
||||
* 处理自定义异常
|
||||
*/
|
||||
@ExceptionHandler(SqxException.class)
|
||||
public Result handleException(SqxException e){
|
||||
Result r = new Result();
|
||||
r.put("code", e.getCode());
|
||||
r.put("msg", e.getMessage());
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
@ExceptionHandler(NoHandlerFoundException.class)
|
||||
public Result handlerNoFoundException(Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
return Result.error(404, "路径不存在,请检查路径是否正确");
|
||||
}
|
||||
|
||||
@ExceptionHandler(DuplicateKeyException.class)
|
||||
public Result handleDuplicateKeyException(DuplicateKeyException e){
|
||||
logger.error(e.getMessage(), e);
|
||||
return Result.error("数据库中已存在该记录");
|
||||
}
|
||||
|
||||
@ExceptionHandler(AuthorizationException.class)
|
||||
public Result handleAuthorizationException(AuthorizationException e){
|
||||
logger.error(e.getMessage(), e);
|
||||
return Result.error("没有权限,请联系管理员授权");
|
||||
}
|
||||
|
||||
@ExceptionHandler(Exception.class)
|
||||
public Result handleException(Exception e){
|
||||
logger.error(e.getMessage(), e);
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
package com.sqx.common.utils;
|
||||
|
||||
/**
|
||||
* 系统参数相关Key
|
||||
*
|
||||
*/
|
||||
public class ConfigConstant {
|
||||
/**
|
||||
* 云存储配置KEY
|
||||
*/
|
||||
public final static String CLOUD_STORAGE_CONFIG_KEY = "CLOUD_STORAGE_CONFIG_KEY";
|
||||
}
|
||||
|
|
@ -0,0 +1,110 @@
|
|||
package com.sqx.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 enum MenuType {
|
||||
/**
|
||||
* 目录
|
||||
*/
|
||||
CATALOG(0),
|
||||
/**
|
||||
* 菜单
|
||||
*/
|
||||
MENU(1),
|
||||
/**
|
||||
* 按钮
|
||||
*/
|
||||
BUTTON(2);
|
||||
|
||||
private int value;
|
||||
|
||||
MenuType(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 定时任务状态
|
||||
*/
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,157 @@
|
|||
package com.sqx.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_TIME_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();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
package com.sqx.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");
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
package com.sqx.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);
|
||||
}
|
||||
|
||||
|
||||
return ip;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
package com.sqx.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;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,101 @@
|
|||
package com.sqx.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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,175 @@
|
|||
package com.sqx.common.utils;
|
||||
|
||||
import cn.hutool.extra.qrcode.BufferedImageLuminanceSource;
|
||||
import com.google.zxing.*;
|
||||
import com.google.zxing.Result;
|
||||
import com.google.zxing.common.BitMatrix;
|
||||
import com.google.zxing.common.HybridBinarizer;
|
||||
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.*;
|
||||
import java.awt.geom.RoundRectangle2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.util.Hashtable;
|
||||
|
||||
/**
|
||||
* 二维码生成解析工具类
|
||||
|
||||
* @date 2020/02/12 09:37
|
||||
*/
|
||||
public class QRCodeUtil {
|
||||
|
||||
//编码格式,采用utf-8
|
||||
private static final String UNICODE = "utf-8";
|
||||
//图片格式
|
||||
private static final String FORMAT = "JPG";
|
||||
//二维码宽度,单位:像素pixels
|
||||
private static final int QRCODE_WIDTH = 300;
|
||||
//二维码高度,单位:像素pixels
|
||||
private static final int QRCODE_HEIGHT = 300;
|
||||
//LOGO宽度,单位:像素pixels
|
||||
private static final int LOGO_WIDTH = 100;
|
||||
//LOGO高度,单位:像素pixels
|
||||
private static final int LOGO_HEIGHT = 100;
|
||||
|
||||
/**
|
||||
* 生成二维码图片
|
||||
* @param content 二维码内容
|
||||
* @param logoPath 图片地址
|
||||
* @param needCompress 是否压缩
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
private static BufferedImage createImage(String content, String logoPath, boolean needCompress) throws Exception {
|
||||
Hashtable<EncodeHintType, Object> hints = new Hashtable<EncodeHintType, Object>();
|
||||
hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H);
|
||||
hints.put(EncodeHintType.CHARACTER_SET, UNICODE);
|
||||
hints.put(EncodeHintType.MARGIN, 1);
|
||||
BitMatrix bitMatrix = new MultiFormatWriter().encode(content, BarcodeFormat.QR_CODE, QRCODE_WIDTH, QRCODE_HEIGHT,
|
||||
hints);
|
||||
int width = bitMatrix.getWidth();
|
||||
int height = bitMatrix.getHeight();
|
||||
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
|
||||
for (int x = 0; x < width; x++) {
|
||||
for (int y = 0; y < height; y++) {
|
||||
image.setRGB(x, y, bitMatrix.get(x, y) ? 0xFF000000 : 0xFFFFFFFF);
|
||||
}
|
||||
}
|
||||
if (logoPath == null || "".equals(logoPath)) {
|
||||
return image;
|
||||
}
|
||||
// 插入图片
|
||||
QRCodeUtil.insertImage(image, logoPath, needCompress);
|
||||
return image;
|
||||
}
|
||||
|
||||
/**
|
||||
* 插入LOGO
|
||||
* @param source 二维码图片
|
||||
* @param logoPath LOGO图片地址
|
||||
* @param needCompress 是否压缩
|
||||
* @throws Exception
|
||||
*/
|
||||
private static void insertImage(BufferedImage source, String logoPath, boolean needCompress) throws Exception {
|
||||
File file = new File(logoPath);
|
||||
if (!file.exists()) {
|
||||
throw new Exception("logo file not found.");
|
||||
}
|
||||
Image src = ImageIO.read(new File(logoPath));
|
||||
int width = src.getWidth(null);
|
||||
int height = src.getHeight(null);
|
||||
if (needCompress) { // 压缩LOGO
|
||||
if (width > LOGO_WIDTH) {
|
||||
width = LOGO_WIDTH;
|
||||
}
|
||||
if (height > LOGO_HEIGHT) {
|
||||
height = LOGO_HEIGHT;
|
||||
}
|
||||
Image image = src.getScaledInstance(width, height, Image.SCALE_SMOOTH);
|
||||
BufferedImage tag = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
|
||||
Graphics g = tag.getGraphics();
|
||||
g.drawImage(image, 0, 0, null); // 绘制缩小后的图
|
||||
g.dispose();
|
||||
src = image;
|
||||
}
|
||||
// 插入LOGO
|
||||
Graphics2D graph = source.createGraphics();
|
||||
int x = (QRCODE_WIDTH - width) / 2;
|
||||
int y = (QRCODE_HEIGHT - height) / 2;
|
||||
graph.drawImage(src, x, y, width, height, null);
|
||||
Shape shape = new RoundRectangle2D.Float(x, y, width, width, 6, 6);
|
||||
graph.setStroke(new BasicStroke(3f));
|
||||
graph.draw(shape);
|
||||
graph.dispose();
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成二维码(内嵌LOGO)
|
||||
* 调用者指定二维码文件名
|
||||
* @param content 二维码的内容
|
||||
* @param logoPath 中间图片地址
|
||||
* @param destPath 存储路径
|
||||
* @param fileName 文件名称
|
||||
* @param needCompress 是否压缩
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public static String encode(String content, String logoPath, String destPath, String fileName, boolean needCompress) throws Exception {
|
||||
BufferedImage image = QRCodeUtil.createImage(content, logoPath, needCompress);
|
||||
mkdirs(destPath);
|
||||
//文件名称通过传递
|
||||
fileName = fileName.substring(0, fileName.indexOf(".")>0?fileName.indexOf("."):fileName.length())
|
||||
+ "." + FORMAT.toLowerCase();
|
||||
ImageIO.write(image, FORMAT, new File(destPath + "/" + fileName));
|
||||
return fileName;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建文件夹, mkdirs会自动创建多层目录,区别于mkdir.(mkdir如果父目录不存在则会抛出异常)
|
||||
* @param destPath
|
||||
*/
|
||||
public static void mkdirs(String destPath) {
|
||||
File file = new File(destPath);
|
||||
if (!file.exists() && !file.isDirectory()) {
|
||||
file.mkdirs();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析二维码
|
||||
* @param path 二维码图片路径
|
||||
* @return String 二维码内容
|
||||
* @throws Exception
|
||||
*/
|
||||
public static String decode(String path) throws Exception {
|
||||
File file = new File(path);
|
||||
BufferedImage image = ImageIO.read(file);
|
||||
if (image == null) {
|
||||
return null;
|
||||
}
|
||||
BufferedImageLuminanceSource source = new BufferedImageLuminanceSource(image);
|
||||
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
|
||||
Result result;
|
||||
Hashtable<DecodeHintType, Object> hints = new Hashtable<DecodeHintType, Object>();
|
||||
hints.put(DecodeHintType.CHARACTER_SET, UNICODE);
|
||||
result = new MultiFormatReader().decode(bitmap, hints);
|
||||
return result.getText();
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试
|
||||
* @param args
|
||||
* @throws Exception
|
||||
*/
|
||||
public static void main(String[] args) throws Exception {
|
||||
String text = "http://47.105.101.72:8088";
|
||||
//不含Logo
|
||||
// QRCodeUtil.encode(text, null, "/Users/kyson/Downloads", "qrcode", true);
|
||||
//含Logo,指定二维码图片名
|
||||
QRCodeUtil.encode(text, "/Users/kyson/Downloads/宋康.jpg", "/Users/kyson/Downloads", "qrcode1", true);
|
||||
// System.out.println(QRCodeUtil.decode("d:\\cc\\qrcode1.jpg"));
|
||||
// System.out.println(QRCodeUtil.encode(text, null, "/Users/kyson/Downloads", "qrcode", true));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,68 @@
|
|||
package com.sqx.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 com.sqx.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.valueOf(params.get(Constant.PAGE)));
|
||||
}
|
||||
if(params.get(Constant.LIMIT) != null){
|
||||
limit = Long.parseLong(String.valueOf(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;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
package com.sqx.common.utils;
|
||||
|
||||
/**
|
||||
* Redis所有Keys
|
||||
*
|
||||
*/
|
||||
public class RedisKeys {
|
||||
|
||||
public static String getSysConfigKey(String key){
|
||||
return "sys:config:" + key;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,90 @@
|
|||
package com.sqx.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);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
package com.sqx.common.utils;
|
||||
|
||||
import org.apache.http.HttpStatus;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 返回数据
|
||||
*
|
||||
*/
|
||||
public class Result extends HashMap<String, Object> {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public Result () {
|
||||
put("code", 0);
|
||||
put("msg", "success");
|
||||
}
|
||||
public static Result upStatus(Integer rows) {
|
||||
return rows > 0 ? success() : error();
|
||||
}
|
||||
public static Result error() {
|
||||
return error(HttpStatus.SC_INTERNAL_SERVER_ERROR, "未知异常,请联系管理员");
|
||||
}
|
||||
|
||||
public static Result error(String msg) {
|
||||
return error(HttpStatus.SC_INTERNAL_SERVER_ERROR, msg);
|
||||
}
|
||||
|
||||
public static Result error(int code, String msg) {
|
||||
Result r = new Result();
|
||||
r.put("code", code);
|
||||
r.put("msg", msg);
|
||||
return r;
|
||||
}
|
||||
|
||||
public static Result success(String msg) {
|
||||
Result r = new Result();
|
||||
r.put("msg", msg);
|
||||
return r;
|
||||
}
|
||||
|
||||
public static Result success(Map<String, Object> map) {
|
||||
Result r = new Result();
|
||||
r.putAll(map);
|
||||
return r;
|
||||
}
|
||||
|
||||
public static Result success() {
|
||||
return new Result();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result put(String key, Object value) {
|
||||
super.put(key, value);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
package com.sqx.common.utils;
|
||||
|
||||
import com.sqx.common.exception.SqxException;
|
||||
import com.sqx.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 SqxException("验证码已失效");
|
||||
}
|
||||
getSession().removeAttribute(key);
|
||||
return kaptcha.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
package com.sqx.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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
package com.sqx.common.validator;
|
||||
|
||||
import com.sqx.common.exception.SqxException;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
/**
|
||||
* 数据校验
|
||||
*
|
||||
*/
|
||||
public class Assert {
|
||||
|
||||
public static void isBlank(String str, String message) {
|
||||
if (StringUtils.isBlank(str)) {
|
||||
throw new SqxException(message);
|
||||
}
|
||||
}
|
||||
|
||||
public static void isNull(Object object, String message) {
|
||||
if (object == null) {
|
||||
throw new SqxException(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
package com.sqx.common.validator;
|
||||
|
||||
import com.sqx.common.exception.SqxException;
|
||||
|
||||
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 SqxException 校验不通过,则报SqxException异常
|
||||
*/
|
||||
public static void validateEntity(Object object, Class<?>... groups)
|
||||
throws SqxException {
|
||||
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 SqxException(msg.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
package com.sqx.common.validator.group;
|
||||
|
||||
/**
|
||||
* 新增数据 Group
|
||||
*
|
||||
*/
|
||||
public interface AddGroup {
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
package com.sqx.common.validator.group;
|
||||
|
||||
/**
|
||||
* 阿里云
|
||||
*
|
||||
*/
|
||||
public interface AliyunGroup {
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
package com.sqx.common.validator.group;
|
||||
|
||||
import javax.validation.GroupSequence;
|
||||
|
||||
/**
|
||||
* 定义校验顺序,如果AddGroup组失败,则UpdateGroup组不会再校验
|
||||
*
|
||||
*/
|
||||
@GroupSequence({AddGroup.class, UpdateGroup.class})
|
||||
public interface Group {
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
package com.sqx.common.validator.group;
|
||||
|
||||
/**
|
||||
* 腾讯云
|
||||
*
|
||||
*/
|
||||
public interface QcloudGroup {
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
package com.sqx.common.validator.group;
|
||||
|
||||
/**
|
||||
* 七牛
|
||||
*
|
||||
*/
|
||||
public interface QiniuGroup {
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
package com.sqx.common.validator.group;
|
||||
|
||||
/**
|
||||
* 更新数据 Group
|
||||
*
|
||||
*/
|
||||
|
||||
public interface UpdateGroup {
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,526 @@
|
|||
package com.sqx.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);
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
package com.sqx.common.xss;
|
||||
|
||||
import com.sqx.common.exception.SqxException;
|
||||
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 SqxException("包含非法字符");
|
||||
}
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
package com.sqx.common.xss;
|
||||
|
||||
import org.apache.http.HttpStatus;
|
||||
|
||||
import javax.servlet.*;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* XSS过滤
|
||||
*
|
||||
*/
|
||||
public class XssFilter implements Filter {
|
||||
|
||||
@Override
|
||||
public void init(FilterConfig config) throws ServletException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
|
||||
throws IOException, ServletException {
|
||||
HttpServletRequest hreq = (HttpServletRequest) request;
|
||||
String requestURI = hreq.getRequestURI();
|
||||
String method = hreq.getMethod();
|
||||
System.err.println("当前请求的方法是:"+method+",请求地址是:"+requestURI);
|
||||
|
||||
HttpServletResponse hresp = (HttpServletResponse) response;
|
||||
|
||||
//跨域
|
||||
hresp.setHeader("Access-Control-Allow-Origin", "*");
|
||||
|
||||
|
||||
//跨域 Header
|
||||
|
||||
hresp.setHeader("Access-Control-Allow-Methods", "*");
|
||||
|
||||
hresp.setHeader("Access-Control-Allow-Headers", "*");
|
||||
|
||||
// Filter 只是链式处理,请求依然转发到目的地址。
|
||||
|
||||
chain.doFilter(request, response);
|
||||
|
||||
|
||||
|
||||
/*XssHttpServletRequestWrapper xssRequest = new XssHttpServletRequestWrapper(
|
||||
(HttpServletRequest) request);
|
||||
chain.doFilter(xssRequest, response);*/
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,138 @@
|
|||
package com.sqx.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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
package com.sqx.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.cors.CorsConfiguration;
|
||||
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
|
||||
import org.springframework.web.filter.CorsFilter;
|
||||
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
|
||||
/**CorsConfig
|
||||
* 跨域设置
|
||||
*/
|
||||
@Configuration
|
||||
public class CorsConfig implements WebMvcConfigurer {
|
||||
|
||||
/*private CorsConfiguration buildConfig() {
|
||||
CorsConfiguration corsConfiguration = new CorsConfiguration();
|
||||
// 1允许任何域名使用
|
||||
corsConfiguration.addAllowedOrigin("*");
|
||||
// 2允许任何头
|
||||
corsConfiguration.addAllowedHeader("*");
|
||||
// 3允许任何方法(post、get等)
|
||||
corsConfiguration.addAllowedMethod("*");
|
||||
return corsConfiguration;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public CorsFilter corsFilter() {
|
||||
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
|
||||
source.registerCorsConfiguration("/**", buildConfig());
|
||||
return new CorsFilter(source);
|
||||
}*/
|
||||
|
||||
|
||||
@Override
|
||||
public void addCorsMappings(CorsRegistry registry) {
|
||||
registry.addMapping("/**")
|
||||
.allowedOriginPatterns("*")
|
||||
.allowCredentials(true)
|
||||
.allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS")
|
||||
.maxAge(3600);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
package com.sqx.config;
|
||||
|
||||
import com.sqx.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;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
package com.sqx.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;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
package com.sqx.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();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
package com.sqx.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();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,104 @@
|
|||
package com.sqx.config;
|
||||
|
||||
import com.sqx.modules.sys.oauth2.OAuth2Filter;
|
||||
import com.sqx.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("/webjars/**", "anon");
|
||||
filterMap.put("/druid/**", "anon");
|
||||
filterMap.put("/app/wxPay/notifyJsApi", "anon");
|
||||
filterMap.put("/app/wxPay/notifyMp", "anon");
|
||||
filterMap.put("/app/wxPay/notify", "anon");
|
||||
filterMap.put("/app/aliPay/notifyApp", "anon");
|
||||
filterMap.put("/app/**", "anon");
|
||||
filterMap.put("/activity/**", "anon");
|
||||
filterMap.put("/banner/**", "anon");
|
||||
filterMap.put("/courseClassification/selectCourseClassification", "anon");
|
||||
filterMap.put("/sys/login", "anon");
|
||||
filterMap.put("/sys/adminLogin", "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("/chatSocket/**", "anon");
|
||||
filterMap.put("/websocket/**", "anon");
|
||||
filterMap.put("/search/**", "anon");
|
||||
filterMap.put("/alioss/**","anon");
|
||||
filterMap.put("/adminerrand","anon");
|
||||
filterMap.put("/invite/**","anon");
|
||||
filterMap.put("/app/shoptype/**","anon");
|
||||
filterMap.put("/app/shop/**","anon");
|
||||
filterMap.put("/admin/shoptype/**","anon");
|
||||
filterMap.put("/ordersChat/**","anon");
|
||||
filterMap.put("/wbsocket/**","anon");
|
||||
filterMap.put("/shop/illegalType/**","anon");
|
||||
filterMap.put("/shop/ordersChat/**","anon");
|
||||
filterMap.put("/app/ordersChat/**","anon");
|
||||
filterMap.put("/timedtask/**","anon");
|
||||
filterMap.put("/admin/ordermessage/**","anon");
|
||||
filterMap.put("/admin/goodsShop/quickGoodsShop","anon");
|
||||
filterMap.put("/admin/goodsShop/selectGoodsShop","anon");
|
||||
filterMap.put("/admin/goodsShop/updateGoodsShop","anon");
|
||||
|
||||
filterMap.put("/admin/goods/**","anon");
|
||||
filterMap.put("/selfGoodsRule/**","anon");
|
||||
//
|
||||
filterMap.put("/**", "oauth2");
|
||||
filterMap.put("/shop/ordersChat/selectShopAllUnreadCount", "oauth2");
|
||||
//filterMap.put("/app/userinfo","anon");
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
package com.sqx.config;
|
||||
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
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.ApiInfo;
|
||||
import springfox.documentation.service.ApiKey;
|
||||
import springfox.documentation.spi.DocumentationType;
|
||||
import springfox.documentation.spring.web.plugins.Docket;
|
||||
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static com.google.common.collect.Lists.newArrayList;
|
||||
|
||||
@Configuration
|
||||
@EnableSwagger2
|
||||
public class SwaggerConfig implements WebMvcConfigurer {
|
||||
|
||||
@Bean
|
||||
public Docket createRestApi() {
|
||||
return new Docket(DocumentationType.SWAGGER_2)
|
||||
.apiInfo(apiInfo())
|
||||
.select()
|
||||
//加了ApiOperation注解的类,才生成接口文档
|
||||
.apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
|
||||
//包下的类,才生成接口文档
|
||||
//.apis(RequestHandlerSelectors.basePackage("com.sqx.controller"))
|
||||
.paths(PathSelectors.any())
|
||||
.build()
|
||||
.securitySchemes(security());
|
||||
}
|
||||
|
||||
private ApiInfo apiInfo() {
|
||||
return new ApiInfoBuilder()
|
||||
.title("")
|
||||
.description("sqx-fast文档")
|
||||
.termsOfServiceUrl("")
|
||||
.version("3.0.0")
|
||||
.build();
|
||||
}
|
||||
|
||||
private List<ApiKey> security() {
|
||||
return newArrayList(
|
||||
new ApiKey("token", "token", "header")
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
package com.sqx.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,61 @@
|
|||
package com.sqx.datasource.aspect;
|
||||
|
||||
|
||||
import com.sqx.datasource.annotation.DataSource;
|
||||
import com.sqx.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(com.sqx.datasource.annotation.DataSource) " +
|
||||
"|| @within(com.sqx.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,47 @@
|
|||
package com.sqx.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,15 @@
|
|||
package com.sqx.datasource.config;
|
||||
|
||||
import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;
|
||||
|
||||
/**
|
||||
* 多数据源
|
||||
*/
|
||||
public class DynamicDataSource extends AbstractRoutingDataSource {
|
||||
|
||||
@Override
|
||||
protected Object determineCurrentLookupKey() {
|
||||
return DynamicContextHolder.peek();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
package com.sqx.datasource.config;
|
||||
|
||||
import com.alibaba.druid.pool.DruidDataSource;
|
||||
import com.sqx.datasource.properties.DataSourceProperties;
|
||||
import com.sqx.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,44 @@
|
|||
package com.sqx.datasource.config;
|
||||
|
||||
import com.alibaba.druid.pool.DruidDataSource;
|
||||
import com.sqx.datasource.properties.DataSourceProperties;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
||||
/**
|
||||
* DruidDataSource
|
||||
*
|
||||
*/
|
||||
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,192 @@
|
|||
package com.sqx.datasource.properties;
|
||||
|
||||
/**
|
||||
* 多数据源属性
|
||||
*
|
||||
*/
|
||||
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,22 @@
|
|||
package com.sqx.datasource.properties;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 多数据源属性
|
||||
*/
|
||||
@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,75 @@
|
|||
package com.sqx.modules.activityManage.controller;
|
||||
|
||||
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.activityManage.entity.ActivityManage;
|
||||
import com.sqx.modules.activityManage.service.ActivityManageService;
|
||||
import com.sqx.modules.goods.entity.GoodsShop;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 活动管理
|
||||
* </p>
|
||||
*
|
||||
* @author 吴畅
|
||||
* @since 2022-11-04
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/admin/activityManage/")
|
||||
public class AdminActivityManageController {
|
||||
@Autowired
|
||||
private ActivityManageService activityManageService;
|
||||
|
||||
@PostMapping("addActivity")
|
||||
@ApiOperation("添加活动")
|
||||
public Result addActivity(ActivityManage activityManage) {
|
||||
return activityManageService.addActivity(activityManage);
|
||||
}
|
||||
|
||||
@PostMapping("updateActivity")
|
||||
@ApiOperation("修改活动")
|
||||
public Result updateActivity(ActivityManage activityManage) {
|
||||
return activityManageService.updateActivity(activityManage);
|
||||
}
|
||||
|
||||
@PostMapping("deleteActivity")
|
||||
@ApiOperation("删除活动")
|
||||
public Result deleteActivity(Long activityId) {
|
||||
return activityManageService.deleteActivity(activityId);
|
||||
}
|
||||
|
||||
@GetMapping("getActivityList")
|
||||
@ApiOperation("获取活动列表")
|
||||
public Result getActivityList(Integer page, Integer limit, ActivityManage activityManage) {
|
||||
return Result.success().put("data", activityManageService.getActivityList(page, limit, activityManage));
|
||||
}
|
||||
@GetMapping("getActivityInfo")
|
||||
@ApiOperation("获取活动信息")
|
||||
public Result getActivityInfo(Long activityId){
|
||||
return Result.success().put("data", activityManageService.getActivityInfo(activityId));
|
||||
|
||||
}
|
||||
@GetMapping("getShoActivityShopList")
|
||||
@ApiOperation("根据活动查找商家列表")
|
||||
public Result getShoActivityShopList(Integer page, Integer limit, GoodsShop goodsShop) {
|
||||
return Result.success().put("data", activityManageService.getAdminShoActivityShopList(page, limit, goodsShop));
|
||||
}
|
||||
@GetMapping("cancelActivityShop")
|
||||
@ApiOperation("删除活动中的商家")
|
||||
public Result cancelActivityShop(Long activityId,Long shopId){
|
||||
return activityManageService.cancelActivityShop(activityId,shopId);
|
||||
}
|
||||
@GetMapping("shopJoinActivity")
|
||||
@ApiOperation("将商家加入活动")
|
||||
private Result shopJoinActivity(Long shopId, Long activityId) {
|
||||
return activityManageService.shopJoinActivity(shopId, activityId,1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
package com.sqx.modules.activityManage.controller.app;
|
||||
|
||||
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.activityManage.entity.ActivityManage;
|
||||
import com.sqx.modules.activityManage.service.ActivityManageService;
|
||||
import com.sqx.modules.goods.entity.GoodsShop;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 活动管理
|
||||
* </p>
|
||||
*
|
||||
* @author 吴畅
|
||||
* @since 2022-11-04
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/app/activityManage/")
|
||||
public class AppActivityManageController {
|
||||
@Autowired
|
||||
private ActivityManageService activityManageService;
|
||||
|
||||
|
||||
@GetMapping("getActivityList")
|
||||
@ApiOperation("获取活动列表")
|
||||
public Result getActivityList(Integer page, Integer limit, ActivityManage activityManage) {
|
||||
activityManage.setIsEnable(1);
|
||||
return Result.success().put("data", activityManageService.getActivityList(page, limit, activityManage));
|
||||
}
|
||||
|
||||
@GetMapping("getActivityInfo")
|
||||
@ApiOperation("获取活动信息")
|
||||
public Result getActivityInfo(Long activityId) {
|
||||
return Result.success().put("data", activityManageService.getActivityInfo(activityId));
|
||||
}
|
||||
|
||||
@GetMapping("getShoActivityShopList")
|
||||
@ApiOperation("根据活动查找商家列表")
|
||||
public Result getShoActivityShopList(Integer page, Integer limit,Double lng,Double lat, GoodsShop goodsShop) {
|
||||
return Result.success().put("data", activityManageService.getShoActivityShopList(page, limit,lng,lat ,goodsShop));
|
||||
}
|
||||
|
||||
@GetMapping("shopJoinActivity")
|
||||
@ApiOperation("商户主动加入活动")
|
||||
private Result shopJoinActivity(Long shopId, Long activityId) {
|
||||
return activityManageService.shopJoinActivity(shopId, activityId,0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
package com.sqx.modules.activityManage.dao;
|
||||
|
||||
import com.sqx.modules.activityManage.entity.ActivityManage;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author www.javacoder.top
|
||||
* @since 2022-11-04
|
||||
*/
|
||||
@Mapper
|
||||
public interface ActivityManageDao extends BaseMapper<ActivityManage> {
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,66 @@
|
|||
package com.sqx.modules.activityManage.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.SqlCondition;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* </p>
|
||||
*
|
||||
* @author www.javacoder.top
|
||||
* @since 2022-11-04
|
||||
*/
|
||||
@Data
|
||||
public class ActivityManage implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 活动id
|
||||
*/
|
||||
@TableId(value = "activity_id", type = IdType.AUTO)
|
||||
private Long activityId;
|
||||
|
||||
/**
|
||||
* 活动标题
|
||||
*/
|
||||
@TableField(condition = SqlCondition.LIKE)
|
||||
private String activityTitle;
|
||||
|
||||
/**
|
||||
* 活动内容介绍
|
||||
*/
|
||||
private String activityContent;
|
||||
|
||||
/**
|
||||
* 活动图片
|
||||
*/
|
||||
private String activityImage;
|
||||
|
||||
/**
|
||||
* 是否启用(0否 1是)
|
||||
*/
|
||||
private Integer isEnable;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private Date updateTime;
|
||||
/**
|
||||
* 是否允许商户主动加入 0否 1是
|
||||
*/
|
||||
private Integer isAllowShop;
|
||||
}
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
package com.sqx.modules.activityManage.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.activityManage.entity.ActivityManage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.sqx.modules.goods.entity.GoodsShop;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author www.javacoder.top
|
||||
* @since 2022-11-04
|
||||
*/
|
||||
public interface ActivityManageService extends IService<ActivityManage> {
|
||||
|
||||
Result addActivity(ActivityManage activityManage);
|
||||
|
||||
Result updateActivity(ActivityManage activityManage);
|
||||
|
||||
Result deleteActivity(Long activityId);
|
||||
|
||||
IPage<ActivityManage> getActivityList(Integer page, Integer limit, ActivityManage activityManage);
|
||||
|
||||
|
||||
ActivityManage getActivityInfo(Long activityId);
|
||||
|
||||
IPage<GoodsShop> getShoActivityShopList(Integer page, Integer limit, Double lng, Double lat, GoodsShop goodsShop);
|
||||
|
||||
IPage<GoodsShop> getAdminShoActivityShopList(Integer page, Integer limit, GoodsShop goodsShop);
|
||||
|
||||
Result cancelActivityShop(Long activityId, Long shopId);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param shopId
|
||||
* @param activityId
|
||||
* @param auth 1表示是管理员给活动中添加商铺
|
||||
* @return
|
||||
*/
|
||||
Result shopJoinActivity(Long shopId, Long activityId, Integer auth);
|
||||
|
||||
Result addShopActivity(Long activityId, Long shopId);
|
||||
}
|
||||
|
|
@ -0,0 +1,209 @@
|
|||
package com.sqx.modules.activityManage.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.activityManage.entity.ActivityManage;
|
||||
import com.sqx.modules.activityManage.dao.ActivityManageDao;
|
||||
import com.sqx.modules.activityManage.service.ActivityManageService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.sqx.modules.app.entity.UserEntity;
|
||||
import com.sqx.modules.app.service.UserService;
|
||||
import com.sqx.modules.common.entity.CommonInfo;
|
||||
import com.sqx.modules.common.service.CommonInfoService;
|
||||
import com.sqx.modules.goods.dao.GoodsShopDao;
|
||||
import com.sqx.modules.goods.entity.GoodsShop;
|
||||
import com.sqx.modules.goods.service.GoodsShopService;
|
||||
import com.sqx.modules.utils.HttpClientUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author www.javacoder.top
|
||||
* @since 2022-11-04
|
||||
*/
|
||||
@Service
|
||||
public class ActivityManageServiceImpl extends ServiceImpl<ActivityManageDao, ActivityManage> implements ActivityManageService {
|
||||
@Autowired
|
||||
private ActivityManageDao activityManageDao;
|
||||
@Autowired
|
||||
private GoodsShopService goodsShopService;
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
@Autowired
|
||||
private GoodsShopDao goodsShopDao;
|
||||
@Autowired
|
||||
private CommonInfoService commonInfoService;
|
||||
@Override
|
||||
public Result addActivity(ActivityManage activityManage) {
|
||||
activityManage.setCreateTime(new Date());
|
||||
activityManage.setUpdateTime(new Date());
|
||||
return Result.upStatus(activityManageDao.insert(activityManage));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result updateActivity(ActivityManage activityManage) {
|
||||
if (activityManage.getActivityId() == null) {
|
||||
return Result.error("活动id不能为空");
|
||||
}
|
||||
return Result.upStatus(activityManageDao.updateById(activityManage));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result deleteActivity(Long activityId) {
|
||||
|
||||
return Result.upStatus(activityManageDao.deleteById(activityId));
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<ActivityManage> getActivityList(Integer page, Integer limit, ActivityManage activityManage) {
|
||||
IPage<ActivityManage> pages;
|
||||
if (page != null && limit != null) {
|
||||
pages = new Page<>(page, limit);
|
||||
} else {
|
||||
pages = new Page<>();
|
||||
}
|
||||
return activityManageDao.selectPage(pages, new QueryWrapper<>(activityManage));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActivityManage getActivityInfo(Long activityId) {
|
||||
|
||||
return activityManageDao.selectById(activityId);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<GoodsShop> getShoActivityShopList(Integer page, Integer limit, Double lng, Double lat, GoodsShop goodsShop) {
|
||||
Page<GoodsShop> pages;
|
||||
if (page != null && limit != null) {
|
||||
pages = new Page<>(page, limit);
|
||||
} else {
|
||||
pages = new Page<>();
|
||||
}
|
||||
//如果没有经纬度,则默认为北京的经纬度
|
||||
if(lng==null && lat==null){
|
||||
lng = 121.47;
|
||||
lat = 31.23;
|
||||
}
|
||||
|
||||
goodsShop.setShopLng(lng);
|
||||
goodsShop.setShopLat(lat);
|
||||
|
||||
|
||||
String way = commonInfoService.findOne(416).getValue();
|
||||
if("1".equals(way)){
|
||||
CommonInfo one = commonInfoService.findOne(235);
|
||||
String url = "https://apis.map.qq.com/ws/geocoder/v1/";
|
||||
Map<String, String> maps = new HashMap<>();
|
||||
maps.put("location", lat + "," + lng);
|
||||
maps.put("key", one.getValue());
|
||||
String data = HttpClientUtil.doGet(url, maps);
|
||||
JSONObject jsonObject = JSON.parseObject(data);
|
||||
String status = jsonObject.getString("status");
|
||||
if ("0".equals(status)) {
|
||||
JSONObject result = jsonObject.getJSONObject("result");
|
||||
JSONObject adInfo = result.getJSONObject("ad_info");
|
||||
String city = (String)adInfo.get("city");
|
||||
goodsShop.setCity(city);
|
||||
return goodsShopDao.getShoActivityShopList(pages, goodsShop);
|
||||
}
|
||||
}else{
|
||||
String value = commonInfoService.findOne(417).getValue();
|
||||
String url="http://api.tianditu.gov.cn/geocoder";
|
||||
Map<String,String> param=new HashMap<>();
|
||||
JSONObject postStr=new JSONObject();
|
||||
postStr.put("lon",lng);
|
||||
postStr.put("lat",lat);
|
||||
postStr.put("ver","1");
|
||||
param.put("postStr",postStr.toJSONString());
|
||||
param.put("type","geocode");
|
||||
param.put("tk",value);
|
||||
String s = HttpClientUtil.doGet(url,param);
|
||||
JSONObject jsonObject = JSONObject.parseObject(s);
|
||||
String status = jsonObject.getString("status");
|
||||
if("0".equals(status)){
|
||||
JSONObject result = jsonObject.getJSONObject("result");
|
||||
JSONObject addressComponent = result.getJSONObject("addressComponent");
|
||||
String city = addressComponent.getString("city");
|
||||
String province = addressComponent.getString("province");
|
||||
String county = addressComponent.getString("county");
|
||||
if(StringUtils.isEmpty(city)){
|
||||
if("新疆维吾尔自治区".equals(province) || "台湾省".equals(province)){
|
||||
city = addressComponent.getString("county");
|
||||
}else{
|
||||
city = addressComponent.getString("province");
|
||||
}
|
||||
}
|
||||
goodsShop.setCity(city);
|
||||
return goodsShopDao.getShoActivityShopList(pages, goodsShop);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public IPage<GoodsShop> getAdminShoActivityShopList(Integer page, Integer limit, GoodsShop goodsShop) {
|
||||
Page<GoodsShop> pages;
|
||||
if (page != null && limit != null) {
|
||||
pages = new Page<>(page, limit);
|
||||
} else {
|
||||
pages = new Page<>();
|
||||
}
|
||||
return goodsShopDao.getAdminShoActivityShopList(pages, goodsShop);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Result cancelActivityShop(Long activityId, Long shopId) {
|
||||
return Result.upStatus(goodsShopService.cancelActivityShop(activityId, shopId));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result shopJoinActivity(Long shopId, Long activityId, Integer auth) {
|
||||
ActivityManage activityManage = activityManageDao.selectById(activityId);
|
||||
if (activityManage == null) {
|
||||
return Result.error("当前活动不存在");
|
||||
}
|
||||
if (auth != 1) {
|
||||
if (activityManage.getIsAllowShop() == 0) {
|
||||
return Result.error("当前活动不允许商家自行加入");
|
||||
}
|
||||
}
|
||||
|
||||
GoodsShop goodsShop = new GoodsShop();
|
||||
goodsShop.setShopId(shopId);
|
||||
goodsShop.setActivityId(activityId);
|
||||
goodsShopService.updateById(goodsShop);
|
||||
return Result.success();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result addShopActivity(Long activityId, Long shopId) {
|
||||
UserEntity entity = new UserEntity();
|
||||
|
||||
userService.updateById(entity);
|
||||
return Result.success();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
package com.sqx.modules.address.controller;
|
||||
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.address.entity.Address;
|
||||
import com.sqx.modules.address.service.AddressService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@RestController
|
||||
@Api(value = "管理端-地址", tags = {"管理端-地址"})
|
||||
@RequestMapping(value = "/admin/address")
|
||||
public class AdminAddressController {
|
||||
|
||||
@Autowired
|
||||
private AddressService addressService;
|
||||
|
||||
@ApiOperation("用户地址列表")
|
||||
@GetMapping(value = "selectAddressList")
|
||||
public Result selectAddressList(Integer page, Integer limit, Long userId){
|
||||
|
||||
return addressService.selectAddressList(userId, page, limit);
|
||||
}
|
||||
|
||||
@ApiOperation("添加")
|
||||
@PostMapping(value = "insertAddress")
|
||||
public Result insertAddress(@RequestBody Address address){
|
||||
|
||||
return addressService.insertAddress(address);
|
||||
}
|
||||
|
||||
@ApiOperation("修改")
|
||||
@PostMapping(value = "updateAddress")
|
||||
public Result updateAddress(@RequestBody Address address){
|
||||
|
||||
return addressService.updateAddress(address);
|
||||
}
|
||||
|
||||
@ApiOperation("删除")
|
||||
@PostMapping(value = "deleteAddress")
|
||||
public Result deleteAddress(Long addressId){
|
||||
|
||||
return addressService.deleteAddress(addressId);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,138 @@
|
|||
package com.sqx.modules.address.controller.app;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.address.entity.Address;
|
||||
import com.sqx.modules.address.service.AddressService;
|
||||
import com.sqx.modules.app.annotation.Login;
|
||||
import com.sqx.modules.common.entity.CommonInfo;
|
||||
import com.sqx.modules.common.service.CommonInfoService;
|
||||
import com.sqx.modules.utils.HttpClientUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@Api(value = "用户端-地址", tags = {"用户端-地址"})
|
||||
@RequestMapping(value = "/app/address")
|
||||
@Slf4j
|
||||
public class AddressController {
|
||||
|
||||
@Autowired
|
||||
private AddressService addressService;
|
||||
@Autowired
|
||||
private CommonInfoService commonInfoService;
|
||||
|
||||
@Login
|
||||
@ApiOperation("获取地址列表")
|
||||
@GetMapping(value = "/selectAddressList")
|
||||
public Result selectAddressList(@RequestAttribute Long userId, Integer page, Integer limit){
|
||||
|
||||
return addressService.selectAddressList(userId, page, limit);
|
||||
}
|
||||
|
||||
@ApiOperation("查看单个地址信息")
|
||||
@GetMapping(value = "/selectAddressById")
|
||||
public Result selectAddressById(Long addressId){
|
||||
|
||||
return addressService.selectAddressById(addressId);
|
||||
}
|
||||
|
||||
@Login
|
||||
@ApiOperation("新增地址")
|
||||
@PostMapping(value = "/insertAddress")
|
||||
public Result insertAddress(@RequestAttribute Long userId, @RequestBody Address address){
|
||||
address.setUserId(userId);
|
||||
return addressService.insertAddress(address);
|
||||
}
|
||||
|
||||
@Login
|
||||
@ApiOperation("修改地址")
|
||||
@PostMapping(value = "/updateAddress")
|
||||
public Result updateAddress(@RequestAttribute Long userId, @RequestBody Address address){
|
||||
address.setUserId(userId);
|
||||
return addressService.updateAddress(address);
|
||||
}
|
||||
|
||||
@Login
|
||||
@ApiOperation("删除地址")
|
||||
@PostMapping(value = "/deleteAddress")
|
||||
public Result deleteAddress(Long addressId){
|
||||
|
||||
return addressService.deleteAddress(addressId);
|
||||
}
|
||||
|
||||
@Login
|
||||
@ApiOperation("搜索地址")
|
||||
@GetMapping(value = "searchAddress")
|
||||
public Result searchAddress(@RequestAttribute Long userId, Integer page, Integer limit, String impotr){
|
||||
|
||||
return addressService.searchAddress(userId, page, limit, impotr);
|
||||
}
|
||||
|
||||
@GetMapping("/selectCity")
|
||||
@ApiOperation("根据经纬度获取城市")
|
||||
public Result selectCity(String lat,String lng){
|
||||
String way = commonInfoService.findOne(416).getValue();
|
||||
if("1".equals(way)){
|
||||
CommonInfo one = commonInfoService.findOne(235);
|
||||
String url = "https://apis.map.qq.com/ws/geocoder/v1/";
|
||||
Map<String, String> maps = new HashMap<>();
|
||||
maps.put("location", lat + "," + lng);
|
||||
maps.put("key", one.getValue());
|
||||
String data = HttpClientUtil.doGet(url, maps);
|
||||
JSONObject jsonObject = JSON.parseObject(data);
|
||||
String status = jsonObject.getString("status");
|
||||
if ("0".equals(status)) {
|
||||
JSONObject result = jsonObject.getJSONObject("result");
|
||||
JSONObject adInfo = result.getJSONObject("ad_info");
|
||||
return Result.success().put("data", adInfo);
|
||||
} else {
|
||||
log.error("转换失败!!!原因:" + jsonObject.getString("message"));
|
||||
}
|
||||
return Result.error("获取定位失败!");
|
||||
}else{
|
||||
String value = commonInfoService.findOne(417).getValue();
|
||||
String url="http://api.tianditu.gov.cn/geocoder";
|
||||
Map<String,String> param=new HashMap<>();
|
||||
JSONObject postStr=new JSONObject();
|
||||
postStr.put("lon",lng);
|
||||
postStr.put("lat",lat);
|
||||
postStr.put("ver","1");
|
||||
param.put("postStr",postStr.toJSONString());
|
||||
param.put("type","geocode");
|
||||
param.put("tk",value);
|
||||
String s = HttpClientUtil.doGet(url,param);
|
||||
JSONObject jsonObject = JSONObject.parseObject(s);
|
||||
String status = jsonObject.getString("status");
|
||||
if("0".equals(status)){
|
||||
JSONObject result = jsonObject.getJSONObject("result");
|
||||
JSONObject addressComponent = result.getJSONObject("addressComponent");
|
||||
String province = addressComponent.getString("province");
|
||||
String city = addressComponent.getString("city");
|
||||
String county = addressComponent.getString("county");
|
||||
if(StringUtils.isEmpty(city)){
|
||||
if("新疆维吾尔自治区".equals(province) || "台湾省".equals(province)){
|
||||
city = addressComponent.getString("county");
|
||||
}else{
|
||||
city = addressComponent.getString("province");
|
||||
}
|
||||
}
|
||||
JSONObject jsonObject1=new JSONObject();
|
||||
jsonObject1.put("province",province);
|
||||
jsonObject1.put("city",city);
|
||||
jsonObject1.put("district",county);
|
||||
return Result.success().put("data", jsonObject1);
|
||||
}
|
||||
return Result.error("获取定位失败!");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
package com.sqx.modules.address.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.sqx.modules.address.entity.Address;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface AddressDao extends BaseMapper<Address> {
|
||||
|
||||
IPage<Address> selectAddressList(Page<Address> pages, Long userId);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
package com.sqx.modules.address.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class Address implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
|
||||
@ApiModelProperty("主键id")
|
||||
private Long addressId;
|
||||
|
||||
|
||||
@ApiModelProperty("用户id")
|
||||
private Long userId;
|
||||
|
||||
|
||||
@ApiModelProperty("用户姓名")
|
||||
private String userName;
|
||||
|
||||
|
||||
@ApiModelProperty("用户电话")
|
||||
private String userPhone;
|
||||
|
||||
|
||||
@ApiModelProperty("用户地址")
|
||||
private String province;
|
||||
|
||||
@ApiModelProperty("用户地址")
|
||||
private String city;
|
||||
|
||||
@ApiModelProperty("用户地址")
|
||||
private String district;
|
||||
|
||||
|
||||
@ApiModelProperty("用户详细地址(用户手动输入的地址)")
|
||||
private String addressDetail;
|
||||
|
||||
@ApiModelProperty("经度")
|
||||
private Double lng;
|
||||
|
||||
@ApiModelProperty("维度")
|
||||
private Double lat;
|
||||
|
||||
|
||||
@ApiModelProperty("创建时间")
|
||||
private String createTime;
|
||||
|
||||
|
||||
@ApiModelProperty("是否删除(0:未删除;1:删除)")
|
||||
private Integer deleteFlag;
|
||||
|
||||
|
||||
@ApiModelProperty("默认地址 0:非默认 1:默认")
|
||||
private Integer addressDefault;
|
||||
|
||||
|
||||
@ApiModelProperty("修改时间")
|
||||
private String updateTime;
|
||||
|
||||
public Address() {}
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
package com.sqx.modules.address.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.address.entity.Address;
|
||||
|
||||
public interface AddressService extends IService<Address> {
|
||||
|
||||
Result selectAddressList(Long userId, Integer page, Integer limit);
|
||||
|
||||
Result insertAddress(Address address);
|
||||
|
||||
Result updateAddress(Address address);
|
||||
|
||||
Result selectAddressById(Long addressId);
|
||||
|
||||
Result deleteAddress(Long addressId);
|
||||
|
||||
Result searchAddress(Long userId, Integer page, Integer limit, String impotr);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,94 @@
|
|||
package com.sqx.modules.address.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.sqx.common.utils.PageUtils;
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.address.dao.AddressDao;
|
||||
import com.sqx.modules.address.entity.Address;
|
||||
import com.sqx.modules.address.service.AddressService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
@Service
|
||||
public class AddressServiceImpl extends ServiceImpl<AddressDao, Address> implements AddressService {
|
||||
|
||||
@Autowired
|
||||
private AddressDao addressDao;
|
||||
|
||||
@Override
|
||||
public Result selectAddressList(Long userId, Integer page, Integer limit) {
|
||||
Page<Address> pages=new Page<>(page,limit);
|
||||
PageUtils pageUtils = new PageUtils(addressDao.selectAddressList(pages, userId));
|
||||
return Result.success().put("data", pageUtils);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public Result insertAddress(Address address) {
|
||||
String format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
|
||||
address.setCreateTime(format);
|
||||
address.setUpdateTime(format);
|
||||
address.setDeleteFlag(0);
|
||||
//如果该条地址不是默认地址,则直接添加
|
||||
if(address.getAddressDefault()==0){
|
||||
baseMapper.insert(address);
|
||||
return Result.success();
|
||||
}else {
|
||||
Address address1 = new Address();
|
||||
address1.setAddressDefault(0);
|
||||
//先按userId将该用户的所有地址改为非默认
|
||||
baseMapper.update(address1, new QueryWrapper<Address>().eq("user_id", address.getUserId()));
|
||||
//再添加默认地址
|
||||
baseMapper.insert(address);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public Result updateAddress(Address address) {
|
||||
String format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
|
||||
address.setUpdateTime(format);
|
||||
//如果该条地址不是默认地址,则直接修改
|
||||
if(address.getAddressDefault()==0){
|
||||
baseMapper.update(address, new QueryWrapper<Address>().eq("address_id", address.getAddressId()));
|
||||
}else {
|
||||
Address address1 = new Address();
|
||||
address1.setAddressDefault(0);
|
||||
//先按userId将该用户的所有地址改为非默认
|
||||
baseMapper.update(address1, new QueryWrapper<Address>().eq("user_id", address.getUserId()));
|
||||
//再修改
|
||||
baseMapper.update(address, new QueryWrapper<Address>().eq("address_id", address.getAddressId()));
|
||||
}
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result selectAddressById(Long addressId) {
|
||||
Address address = baseMapper.selectById(addressId);
|
||||
return Result.success().put("data", address);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result deleteAddress(Long addressId) {
|
||||
baseMapper.deleteById(addressId);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result searchAddress(Long userId, Integer page, Integer limit, String impotr) {
|
||||
Page<Address> pages = new Page<>(page, limit);
|
||||
PageUtils pageUtils = new PageUtils(baseMapper.selectPage(pages, new QueryWrapper<Address>()
|
||||
.like("address_detail", impotr)
|
||||
.eq("user_id", userId)
|
||||
.orderByDesc("create_time")));
|
||||
return Result.success().put("data", pageUtils);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
package com.sqx.modules.app.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* app登录效验
|
||||
*/
|
||||
@Target(ElementType.METHOD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
public @interface Login {
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
package com.sqx.modules.app.annotation;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* 登录用户信息
|
||||
*
|
||||
*/
|
||||
@Target(ElementType.PARAMETER)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface LoginUser {
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
package com.sqx.modules.app.config;
|
||||
|
||||
import com.sqx.modules.app.interceptor.AuthorizationInterceptor;
|
||||
import com.sqx.modules.app.resolver.LoginUserHandlerMethodArgumentResolver;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* MVC配置
|
||||
*
|
||||
*/
|
||||
@Configuration
|
||||
public class WebMvcConfig implements WebMvcConfigurer {
|
||||
@Autowired
|
||||
private AuthorizationInterceptor authorizationInterceptor;
|
||||
@Autowired
|
||||
private LoginUserHandlerMethodArgumentResolver loginUserHandlerMethodArgumentResolver;
|
||||
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
registry.addInterceptor(authorizationInterceptor).addPathPatterns("/app/**");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
|
||||
argumentResolvers.add(loginUserHandlerMethodArgumentResolver);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,70 @@
|
|||
package com.sqx.modules.app.controller;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.app.entity.App;
|
||||
import com.sqx.modules.app.service.AppService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* APP登录授权
|
||||
*
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/appinfo")
|
||||
@Api(value = "APP升级管理", tags = {"APP升级管理"})
|
||||
public class AppUpgradeController {
|
||||
|
||||
@Autowired
|
||||
private AppService iAppService;
|
||||
|
||||
@RequestMapping(value = "/list", method = RequestMethod.GET)
|
||||
@ApiOperation("管理平台升级详情")
|
||||
@ResponseBody
|
||||
public Result list(Integer page,Integer limit) {
|
||||
IPage<App> pages =new Page<>(page,limit);
|
||||
return Result.success().put("data",iAppService.page(pages));
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
|
||||
@ApiOperation("管理平台升级详情")
|
||||
@ResponseBody
|
||||
public Result getBanner(@PathVariable Long id) {
|
||||
return Result.success().put("data",iAppService.selectAppById(id));
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/save", method = RequestMethod.POST)
|
||||
@ApiOperation("管理平台添加升级信息")
|
||||
@ResponseBody
|
||||
public Result addBanner(@RequestBody App app) {
|
||||
if(app.getId()!=null){
|
||||
iAppService.updateAppById(app);
|
||||
}else{
|
||||
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
app.setCreateAt(sdf.format(new Date()));
|
||||
iAppService.insertApp(app);
|
||||
}
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/delete/{id}", method = RequestMethod.GET)
|
||||
@ApiOperation("管理平台删除升级信息")
|
||||
public Result deleteBanner(@PathVariable Long id) {
|
||||
iAppService.deleteAppById(id);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,217 @@
|
|||
package com.sqx.modules.app.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.app.annotation.Login;
|
||||
import com.sqx.modules.app.entity.UserEntity;
|
||||
import com.sqx.modules.app.entity.UserMoney;
|
||||
import com.sqx.modules.app.response.HomeMessageResponse;
|
||||
import com.sqx.modules.app.response.UserMessageResponse;
|
||||
import com.sqx.modules.app.service.UserMoneyDetailsService;
|
||||
import com.sqx.modules.app.service.UserMoneyService;
|
||||
import com.sqx.modules.app.service.UserService;
|
||||
import com.sqx.modules.pay.service.PayDetailsService;
|
||||
import com.sqx.modules.utils.fieYun.FeiYunUtils;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author fang
|
||||
* @date 2020/7/30
|
||||
*/
|
||||
@RestController
|
||||
@Api(value = "用户管理", tags = {"用户管理"})
|
||||
@RequestMapping(value = "/user")
|
||||
public class UserController {
|
||||
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
@Autowired
|
||||
private UserMoneyDetailsService userMoneyDetailsService;
|
||||
@Autowired
|
||||
private UserMoneyService userMoneyService;
|
||||
@Autowired
|
||||
private PayDetailsService payDetailsService;
|
||||
|
||||
@RequestMapping(value = "/{userId}", method = RequestMethod.GET)
|
||||
@ApiOperation("获取用户详细信息")
|
||||
@ResponseBody
|
||||
public Result selectUserById(@ApiParam("用户id") @PathVariable Long userId) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
UserEntity userEntity = userService.queryByUserId(userId);
|
||||
UserMoney userMoney = userMoneyService.selectUserMoneyByUserId(userId);
|
||||
Double money = 0.0;
|
||||
if (userMoney != null) {
|
||||
money = userMoney.getMoney().doubleValue();
|
||||
}
|
||||
//查询用户钱包
|
||||
Double m = money;
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
String date = simpleDateFormat.format(new Date());
|
||||
//查询本月充值
|
||||
Double consume = payDetailsService.instantselectSumPay(date, userId);
|
||||
//查询本月提现
|
||||
Double income = userMoneyDetailsService.monthIncome(date, userId);
|
||||
//查询邀请人数
|
||||
int count = userService.queryInviterCount(userEntity.getInvitationCode());
|
||||
map.put("userEntity", userEntity);
|
||||
map.put("money", m);
|
||||
map.put("consume", consume);
|
||||
map.put("income", income);
|
||||
map.put("count", count);
|
||||
return Result.success().put("data", map);
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/selectUserList", method = RequestMethod.GET)
|
||||
@ApiOperation("查询所有用户列表")
|
||||
@ResponseBody
|
||||
public Result selectUserList(Integer page, Integer limit,
|
||||
@ApiParam("用户id 手机号 昵称 模糊搜索") String phone,
|
||||
@ApiParam("性别 1男 2女") Integer sex,
|
||||
@ApiParam("来源 ") String platform,
|
||||
@ApiParam("手机终端") String sysPhone,
|
||||
@ApiParam("状态 1正常 2封禁") Integer status,
|
||||
@ApiParam("用户类型 1普通用户 2骑手") Integer type,
|
||||
@ApiParam("用户昵称") String userName,
|
||||
@ApiParam("是否是会员")Integer isVip,
|
||||
@ApiParam("是否是商户管理员")Integer shopAdminFlag,String nickName) {
|
||||
return Result.success().put("data", userService.selectUserPage(page, limit, phone, sex, platform, sysPhone, status, type, userName, isVip, shopAdminFlag,nickName));
|
||||
}
|
||||
|
||||
@ApiOperation("修改用户是否是门店用户")
|
||||
@GetMapping(value = "updateShopAdminFlag")
|
||||
public Result updateShopAdminFlag(Long userId, Integer shopAdminFlag){
|
||||
|
||||
return userService.updateShopAdminFlag(userId, shopAdminFlag);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/deleteUserByUserId/{userId}", method = RequestMethod.POST)
|
||||
@ApiOperation("删除用户")
|
||||
@ResponseBody
|
||||
public Result deleteUserByUserId(@PathVariable("userId") Long userId) {
|
||||
userService.removeById(userId);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/updateUserByUserId", method = RequestMethod.POST)
|
||||
@ApiOperation("修改用户")
|
||||
@ResponseBody
|
||||
public Result updateUserByUserId(@RequestBody UserEntity userEntity) {
|
||||
userService.updateById(userEntity);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/updateUserStatusByUserId", method = RequestMethod.GET)
|
||||
@ApiOperation("禁用或启用用户")
|
||||
@ResponseBody
|
||||
public Result updateUserByUserId(Long userId) {
|
||||
UserEntity byId = userService.getById(userId);
|
||||
if (byId.getStatus().equals(1)) {
|
||||
byId.setStatus(2);
|
||||
} else {
|
||||
byId.setStatus(1);
|
||||
}
|
||||
userService.updateById(byId);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取openid
|
||||
*
|
||||
* @param code 微信code
|
||||
* @return openid
|
||||
*/
|
||||
@GetMapping("/openId/{code:.+}/{userId}")
|
||||
@ApiOperation("根据code获取openid")
|
||||
public Result getOpenid(@PathVariable("code") String code, @PathVariable("userId") Long userId) {
|
||||
return userService.getOpenId(code, userId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 信息分析
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/homeMessage")
|
||||
@ApiOperation("信息分析")
|
||||
public Result homeMessage() {
|
||||
HomeMessageResponse homeMessageResponse = new HomeMessageResponse();
|
||||
// 0查总 1查天 2查月 3查年
|
||||
//设置总用户人数
|
||||
homeMessageResponse.setTotalUsers(userService.queryUserCount(0, null));
|
||||
//设置今日新增
|
||||
homeMessageResponse.setNewToday(userService.queryUserCount(1, null));
|
||||
//设置本月新增
|
||||
homeMessageResponse.setNewMonth(userService.queryUserCount(2, null));
|
||||
//设置本年新增
|
||||
homeMessageResponse.setNewYear(userService.queryUserCount(3, null));
|
||||
|
||||
//设置总收入
|
||||
homeMessageResponse.setTotalRevenue(userService.queryPayMoney(0));
|
||||
//设置今日收入
|
||||
homeMessageResponse.setTodayRevenue(userService.queryPayMoney(1));
|
||||
//设置本月收入
|
||||
homeMessageResponse.setMonthRevenue(userService.queryPayMoney(2));
|
||||
//设置本年收入
|
||||
homeMessageResponse.setYearRevenue(userService.queryPayMoney(3));
|
||||
|
||||
return Result.success().put("data", homeMessageResponse);
|
||||
}
|
||||
|
||||
/**
|
||||
* 接单分析
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/takingOrdersMessage")
|
||||
@ApiOperation("接单分析")
|
||||
public Result takingOrdersMessage(Long page, Long limit, String date, Long type) {
|
||||
Page<Map<String, Object>> iPage = new Page<>(page, limit);
|
||||
return userService.takingOrdersMessage(iPage, type, date);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户分析
|
||||
*/
|
||||
@GetMapping("/userMessage")
|
||||
@ApiOperation("用户分析")
|
||||
public Result userMessage(String date, int type) {
|
||||
UserMessageResponse userMessageResponse = new UserMessageResponse();
|
||||
userMessageResponse.setTotalNumber(userService.queryUserCount(type, date));
|
||||
userMessageResponse.setVipUserNumber(userService.userMessage(date, type));
|
||||
userMessageResponse.setUserNumber(userService.queryUserCount(type, date) - userService.userMessage(date, type));
|
||||
return Result.success().put("data", userMessageResponse);
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/updateShopClientId", method = RequestMethod.POST)
|
||||
@ApiOperation("商家端绑定消息推送clientId")
|
||||
@ResponseBody
|
||||
public Result updateShopClientId(@RequestParam String clientId, @RequestAttribute Long userId,Integer sysPhone) {
|
||||
UserEntity userEntity = userService.selectUserById(userId);
|
||||
if (userEntity != null) {
|
||||
userService.updateUserShopClientIdIsNull(clientId);
|
||||
userEntity.setShopClientId(clientId);
|
||||
userEntity.setSysPhone(sysPhone);
|
||||
userService.updateById(userEntity);
|
||||
return Result.success();
|
||||
}
|
||||
return Result.error("用户不存在!");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
package com.sqx.modules.app.controller;
|
||||
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.app.service.UserFollowService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/userFollow")
|
||||
@Api(value = "关注|粉丝", tags = {"关注|粉丝"})
|
||||
public class UserFollowController {
|
||||
@Autowired
|
||||
private UserFollowService userFollowService;
|
||||
|
||||
|
||||
/**
|
||||
* 查看我的关注
|
||||
*/
|
||||
@GetMapping("/selectMyFollow")
|
||||
@ApiOperation("查看我的关注")
|
||||
public Result selectMyFollow(Long userId, Long page, Long limit) {
|
||||
return userFollowService.selectMyFollow(userId, page, limit);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看我的粉丝
|
||||
*/
|
||||
@GetMapping("/selectFans")
|
||||
@ApiOperation("查看我的粉丝")
|
||||
public Result selectFans(Long userId, Long page, Long limit) {
|
||||
return userFollowService.selectFans(userId, page, limit);
|
||||
}
|
||||
|
||||
/**
|
||||
* 关注 / 取消关注
|
||||
**/
|
||||
|
||||
@PostMapping("/insert")
|
||||
@ApiOperation("关注/取消关注")
|
||||
public Result insert(Long userId, Long followUserId) {
|
||||
return userFollowService.insert(userId, followUserId);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
package com.sqx.modules.app.controller;
|
||||
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.app.service.UserMoneyDetailsService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/Details")
|
||||
|
||||
@Api("钱包明细")
|
||||
public class UserMoneyDetailsController {
|
||||
@Autowired
|
||||
private UserMoneyDetailsService userMoneyDetailsService;
|
||||
|
||||
@ApiOperation("钱包明细")
|
||||
@GetMapping("/queryUserMoneyDetails")
|
||||
public Result queryUserMoneyDetails(Integer page, Integer limit, Long userId, Integer classify, Integer type) {
|
||||
|
||||
return userMoneyDetailsService.queryUserMoneyDetails(page, limit, userId,classify,type);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
package com.sqx.modules.app.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.sqx.common.utils.PageUtils;
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.app.entity.VipDetails;
|
||||
import com.sqx.modules.app.service.VipDetailsService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@RestController
|
||||
@Api(value = "会员管理", tags = {"会员管理"})
|
||||
@RequestMapping(value = "/vipDetails")
|
||||
public class VipDetailsController {
|
||||
|
||||
@Autowired
|
||||
private VipDetailsService vipDetailsService;
|
||||
|
||||
@ApiParam("添加会员的详情信息")
|
||||
@PostMapping("/insertVipDetails")
|
||||
public Result insertVipDetails(@RequestBody VipDetails vipDetails) {
|
||||
return vipDetailsService.insertVipDetails(vipDetails);
|
||||
}
|
||||
|
||||
|
||||
@ApiParam("修改会员的详情信息")
|
||||
@PostMapping("/updateVipDetails")
|
||||
public Result updateVipDetails(@RequestBody VipDetails vipDetails) {
|
||||
vipDetailsService.updateById(vipDetails);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@ApiParam("删除的详情信息")
|
||||
@PostMapping("/deleteVipDetails")
|
||||
public Result deleteVipDetails(Long id) {
|
||||
vipDetailsService.removeById(id);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@ApiParam("查询会员列表")
|
||||
@GetMapping("/selectVipDetailsList")
|
||||
public Result selectVipDetailsList(Integer page,Integer limit) {
|
||||
return Result.success().put("data",new PageUtils(vipDetailsService.page(new Page<>(page,limit))));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,146 @@
|
|||
package com.sqx.modules.app.controller.app;
|
||||
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.app.annotation.Login;
|
||||
import com.sqx.modules.app.annotation.LoginUser;
|
||||
import com.sqx.modules.app.entity.UserEntity;
|
||||
import com.sqx.modules.app.service.AppService;
|
||||
import com.sqx.modules.app.service.UserService;
|
||||
import com.sqx.modules.common.entity.CommonInfo;
|
||||
import com.sqx.modules.common.service.CommonInfoService;
|
||||
import com.sqx.modules.utils.MD5Util;
|
||||
import com.sqx.modules.utils.fieYun.FeiYunUtils;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* APP登录授权
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/app/user")
|
||||
@Api(value = "APP管理", tags = {"APP管理"})
|
||||
public class AppController {
|
||||
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
@Autowired
|
||||
private AppService appService;
|
||||
@Autowired
|
||||
private CommonInfoService commonInfoService;
|
||||
|
||||
@Login
|
||||
@RequestMapping(value = "/updatePwd", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
@ApiOperation("用户端修改密码")
|
||||
public Result updatePwd(@LoginUser UserEntity user, String pwd, String oldPwd) {
|
||||
if (!user.getPassword().equals(MD5Util.md5Encrypt32Upper(oldPwd))) {
|
||||
return Result.error("原始密码不正确!");
|
||||
}
|
||||
if (pwd.equals(oldPwd)) {
|
||||
return Result.error("新密码不能与旧密码相同!");
|
||||
}
|
||||
user.setPassword(MD5Util.md5Encrypt32Upper(pwd));
|
||||
userService.updateById(user);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@Login
|
||||
@RequestMapping(value = "/updatePhone", method = RequestMethod.POST)
|
||||
@ApiOperation("用户端换绑手机号")
|
||||
@ResponseBody
|
||||
public Result updatePhone(@RequestAttribute("userId") Long userId, @RequestParam String phone, @RequestParam String msg) {
|
||||
return userService.updatePhone(phone, msg, userId);
|
||||
}
|
||||
|
||||
@Login
|
||||
@RequestMapping(value = "/updateUser", method = RequestMethod.POST)
|
||||
@ApiOperation("用户修改个人信息")
|
||||
@ResponseBody
|
||||
public Result updateUserImageUrl(@RequestAttribute("userId") Long userId,@RequestBody UserEntity userEntity) {
|
||||
userEntity.setUserId(userId);
|
||||
userService.updateById(userEntity);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
|
||||
@Login
|
||||
@RequestMapping(value = "/updateUserImageUrl", method = RequestMethod.POST)
|
||||
@ApiOperation("用户修改头像")
|
||||
@ResponseBody
|
||||
public Result updateUserImageUrl(@LoginUser UserEntity user, String avatar) {
|
||||
user.setAvatar(avatar);
|
||||
userService.updateById(user);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@Login
|
||||
@RequestMapping(value = "/updateUserName", method = RequestMethod.POST)
|
||||
@ApiOperation("用户修改昵称")
|
||||
@ResponseBody
|
||||
public Result updateUserName(@LoginUser UserEntity user, String userName) {
|
||||
user.setUserName(userName);
|
||||
userService.updateById(user);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@Login
|
||||
@RequestMapping(value = "/selectUserById", method = RequestMethod.GET)
|
||||
@ApiOperation("获取用户详细信息")
|
||||
@ResponseBody
|
||||
public Result selectUserById(@RequestAttribute("userId") Long userId, @LoginUser UserEntity user) {
|
||||
return Result.success().put("data", user);
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/selectNewApp", method = RequestMethod.GET)
|
||||
@ApiOperation("升级检测")
|
||||
@ResponseBody
|
||||
public Result selectNewApp() {
|
||||
return Result.success().put("data", appService.selectNewApp());
|
||||
}
|
||||
|
||||
@Login
|
||||
@RequestMapping(value = "/updateClientId", method = RequestMethod.POST)
|
||||
@ApiOperation("用户端绑定消息推送clientId")
|
||||
@ResponseBody
|
||||
public Result updateClientId(@RequestParam String clientId, @RequestAttribute Long userId,Integer sysPhone) {
|
||||
UserEntity userEntity = userService.getById(userId);
|
||||
if (userEntity != null) {
|
||||
//检查是否有其他用户设置这个clientId 如果有 则清除其他用户
|
||||
userService.updateUserClientIdIsNull(clientId);
|
||||
userEntity.setClientid(clientId);
|
||||
userEntity.setSysPhone(sysPhone);
|
||||
userService.updateById(userEntity);
|
||||
return Result.success();
|
||||
}
|
||||
return Result.error("用户不存在!");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Login
|
||||
@RequestMapping(value = "/updateRiderClientId", method = RequestMethod.POST)
|
||||
@ApiOperation("骑手端绑定消息推送clientId")
|
||||
@ResponseBody
|
||||
public Result updateRiderClientId(@RequestParam String clientId, @RequestAttribute Long userId,Integer sysPhone) {
|
||||
UserEntity userEntity = userService.selectUserById(userId);
|
||||
if (userEntity != null) {
|
||||
userService.updateUserRiderClientIdIsNull(clientId);
|
||||
userEntity.setRiderClientid(clientId);
|
||||
userEntity.setSysPhone(sysPhone);
|
||||
userService.updateById(userEntity);
|
||||
return Result.success();
|
||||
}
|
||||
return Result.error("用户不存在!");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,269 @@
|
|||
package com.sqx.modules.app.controller.app;
|
||||
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.app.entity.UserEntity;
|
||||
import com.sqx.modules.app.service.IAppleService;
|
||||
import com.sqx.modules.app.service.UserService;
|
||||
import com.sqx.modules.app.utils.UserConstantInterface;
|
||||
import com.sqx.modules.app.utils.WxPhone;
|
||||
import com.sqx.modules.common.entity.CommonInfo;
|
||||
import com.sqx.modules.common.service.CommonInfoService;
|
||||
import com.sqx.modules.utils.HttpClientUtil;
|
||||
import com.sqx.modules.utils.MD5Util;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import weixin.popular.api.SnsAPI;
|
||||
import weixin.popular.bean.sns.SnsToken;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* APP登录授权
|
||||
*
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/app/Login")
|
||||
@Api("APP登录接口")
|
||||
@Slf4j
|
||||
public class AppLoginController {
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
@Autowired
|
||||
private IAppleService appleService;
|
||||
@Autowired
|
||||
private CommonInfoService commonInfoService;
|
||||
|
||||
@ApiOperation("用户端微信小程序登陆")
|
||||
@RequestMapping(value = "/wxLogin", method = RequestMethod.GET)
|
||||
public Result wxLogin(@ApiParam("小程序code码") String code){
|
||||
return userService.wxLogin(code,1);
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation("用户端小程序登录新增或修改个人信息")
|
||||
@RequestMapping(value = "/insertWxUser", method = RequestMethod.POST)
|
||||
public Result insertWxUser(@RequestBody UserEntity userInfo){
|
||||
userInfo.setUserType(1);
|
||||
return userService.wxRegister(userInfo);
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation("跑腿师傅微信小程序登陆")
|
||||
@RequestMapping(value = "/wxRiderLogin", method = RequestMethod.GET)
|
||||
public Result wxRiderLogin(@ApiParam("小程序code码") String code){
|
||||
return userService.wxLogin(code,2);
|
||||
}
|
||||
|
||||
@ApiOperation("商户端微信小程序登陆")
|
||||
@RequestMapping(value = "/wxShopLogin", method = RequestMethod.GET)
|
||||
public Result wxShopLogin(@ApiParam("小程序code码") String code){
|
||||
return userService.wxLogin(code,3);
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation("跑腿师傅小程序登录新增或修改个人信息")
|
||||
@RequestMapping(value = "/insertWxRiderUser", method = RequestMethod.POST)
|
||||
public Result insertWxRiderUser(@RequestBody UserEntity userInfo){
|
||||
userInfo.setUserType(2);
|
||||
return userService.wxRegister(userInfo);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@RequestMapping(value = "/appleLogin", method = RequestMethod.GET)
|
||||
@ApiOperation("苹果登陆获取appleUserId")
|
||||
public Result loginVerify(@RequestParam("identityToken") String identityToken) {
|
||||
try {
|
||||
log.info("苹果token:{}", identityToken);
|
||||
JSONObject jsonObject = JSON.parseObject(identityToken);
|
||||
JSONObject userInfo = jsonObject.getJSONObject("userInfo");
|
||||
String identityTokens = userInfo.getString("identityToken");
|
||||
return appleService.getAppleUserInfo(identityTokens);
|
||||
} catch (Exception e) {
|
||||
log.error("苹果token校验失败:{}", identityToken, e);
|
||||
return Result.error("苹果账号验证失败,请退出重试!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation("苹果登录")
|
||||
@RequestMapping(value = "/insertAppleUser", method = RequestMethod.GET)
|
||||
public Result insertAppleUser(@RequestParam String appleId){
|
||||
return userService.iosRegister(appleId);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/iosBindMobile", method = RequestMethod.POST)
|
||||
@ApiOperation("苹果登录绑定手机号")
|
||||
@ResponseBody
|
||||
public Result iosBindMobile(@RequestParam String phone,@RequestParam String code,@RequestParam String appleId,@RequestParam String platform,@RequestParam Integer sysPhone) {
|
||||
return userService.iosBindMobile(phone, code, appleId, platform, sysPhone);
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/wxAppLogin", method = RequestMethod.POST)
|
||||
@ApiOperation("微信APP登录")
|
||||
@ResponseBody
|
||||
public Result wxAppLogin(@RequestParam String wxOpenId,@RequestParam String token) {
|
||||
return userService.wxAppLogin(wxOpenId,token);
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/wxBindMobile", method = RequestMethod.POST)
|
||||
@ApiOperation("微信登录绑定手机号")
|
||||
@ResponseBody
|
||||
public Result wxBindMobile(@RequestParam String phone,@RequestParam String code,@RequestParam String wxOpenId,@RequestParam String token,@RequestParam String platform,@RequestParam Integer sysPhone) {
|
||||
return userService.wxBindMobile(phone, code, wxOpenId, token, platform, sysPhone);
|
||||
}
|
||||
|
||||
@GetMapping("/wxOpenIdLogin")
|
||||
@ApiOperation("公众号openId登录")
|
||||
public Result wxOpenIdLogin(String openId, Integer userType){
|
||||
return userService.wxOpenIdLogin(openId, userType);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/registerCode", method = RequestMethod.POST)
|
||||
@ApiOperation("app或h5注册或登录")
|
||||
@ResponseBody
|
||||
public Result registerCode(String phone, String msg, String platform, Integer sysPhone, String password,@ApiParam("") Integer userType,String openId) {
|
||||
return userService.registerCode(phone, msg, platform, sysPhone, password, userType,openId);
|
||||
}
|
||||
|
||||
@ApiOperation("用户端发送验证码")
|
||||
@RequestMapping(value = "/sendMsg/{phone}/{state}", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public Result sendMsg(@PathVariable String phone,@ApiParam("验证码类型 login 登录或忘记密码时传递") @PathVariable String state) {
|
||||
return userService.sendMsg(phone, state);
|
||||
}
|
||||
|
||||
@ApiOperation("解密手机号")
|
||||
@RequestMapping(value = "/selectPhone",method = RequestMethod.POST)
|
||||
public Result getPhoneNumberBeanS5(@RequestBody WxPhone wxPhone) {
|
||||
return UserConstantInterface.decryptS5(wxPhone.getDecryptData(), wxPhone.getKey(), wxPhone.getIv());
|
||||
}
|
||||
@ApiParam("登录app")
|
||||
@RequestMapping(value = "/loginApp",method = RequestMethod.POST)
|
||||
public Result loginApp(@RequestParam String phone,@RequestParam String password){
|
||||
return userService.loginApp(phone,password);
|
||||
}
|
||||
|
||||
@ApiOperation("用户端忘记密码")
|
||||
@RequestMapping(value = "/forgetPwd", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public Result forgetPwd(String pwd, String phone, String msg) {
|
||||
return userService.forgetPwd(pwd, phone, msg);
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/selectCity")
|
||||
@ApiOperation("根据经纬度获取城市")
|
||||
public Result selectCity(String lat, String lng) {
|
||||
String way = commonInfoService.findOne(416).getValue();
|
||||
if("1".equals(way)){
|
||||
CommonInfo one = commonInfoService.findOne(235);
|
||||
String url = "https://apis.map.qq.com/ws/geocoder/v1/";
|
||||
Map<String, String> maps = new HashMap<>();
|
||||
maps.put("location", lat + "," + lng);
|
||||
maps.put("key", one.getValue());
|
||||
String data = HttpClientUtil.doGet(url, maps);
|
||||
JSONObject jsonObject = JSON.parseObject(data);
|
||||
String status = jsonObject.getString("status");
|
||||
if ("0".equals(status)) {
|
||||
JSONObject result = jsonObject.getJSONObject("result");
|
||||
JSONObject adInfo = result.getJSONObject("ad_info");
|
||||
return Result.success().put("data", adInfo);
|
||||
} else {
|
||||
log.error("转换失败!!!原因:" + jsonObject.getString("message"));
|
||||
}
|
||||
return Result.error("获取定位失败!");
|
||||
}else{
|
||||
String value = commonInfoService.findOne(417).getValue();
|
||||
String url="http://api.tianditu.gov.cn/geocoder";
|
||||
Map<String,String> param=new HashMap<>();
|
||||
JSONObject postStr=new JSONObject();
|
||||
postStr.put("lon",lng);
|
||||
postStr.put("lat",lat);
|
||||
postStr.put("ver","1");
|
||||
param.put("postStr",postStr.toJSONString());
|
||||
param.put("type","geocode");
|
||||
param.put("tk",value);
|
||||
String s = HttpClientUtil.doGet(url,param);
|
||||
JSONObject jsonObject = JSONObject.parseObject(s);
|
||||
String status = jsonObject.getString("status");
|
||||
if("0".equals(status)){
|
||||
JSONObject result = jsonObject.getJSONObject("result");
|
||||
JSONObject addressComponent = result.getJSONObject("addressComponent");
|
||||
String province = addressComponent.getString("province");
|
||||
String city = addressComponent.getString("city");
|
||||
String county = addressComponent.getString("county");
|
||||
if(StringUtils.isEmpty(city)){
|
||||
if("新疆维吾尔自治区".equals(province) || "台湾省".equals(province)){
|
||||
city = addressComponent.getString("county");
|
||||
}else{
|
||||
city = addressComponent.getString("province");
|
||||
}
|
||||
}
|
||||
JSONObject jsonObject1=new JSONObject();
|
||||
jsonObject1.put("province",province);
|
||||
jsonObject1.put("city",city);
|
||||
jsonObject1.put("district",county);
|
||||
return Result.success().put("data", jsonObject1);
|
||||
}
|
||||
return Result.error("获取定位失败!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/getOpenId")
|
||||
@ApiOperation("公众号根据code换取openId")
|
||||
public Result getOpenId(String code) {
|
||||
try {
|
||||
|
||||
CommonInfo one = commonInfoService.findOne(5);
|
||||
CommonInfo two = commonInfoService.findOne(21);
|
||||
SnsToken snsToken = SnsAPI.oauth2AccessToken(one.getValue(), two.getValue(), code);
|
||||
String openid = snsToken.getOpenid();
|
||||
return Result.success().put("data",openid);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("GET_OPENID_FAIL");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@GetMapping("/getRiderOpenId")
|
||||
@ApiOperation("公众号根据code换取openId")
|
||||
public Result getRiderOpenId(String code) {
|
||||
try {
|
||||
CommonInfo one = commonInfoService.findOne(262);
|
||||
CommonInfo two = commonInfoService.findOne(263);
|
||||
SnsToken snsToken = SnsAPI.oauth2AccessToken(one.getValue(), two.getValue(), code);
|
||||
String openid = snsToken.getOpenid();
|
||||
return Result.success().put("data",openid);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("GET_OPENID_FAIL");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/bindOpenId")
|
||||
@ApiOperation("用户绑定公众号openId")
|
||||
public Result bindOpenId(Long userId,String openId){
|
||||
UserEntity userEntity=new UserEntity();
|
||||
userEntity.setUserId(userId);
|
||||
userEntity.setOpenId(openId);
|
||||
userService.updateById(userEntity);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
package com.sqx.modules.app.controller.app;
|
||||
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.app.annotation.Login;
|
||||
import com.sqx.modules.app.service.UserFollowService;
|
||||
import io.swagger.annotations.Api;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/app/userFollow")
|
||||
@Api("app 关注")
|
||||
public class AppUserFollowController {
|
||||
|
||||
@Autowired
|
||||
private UserFollowService userFollowService;
|
||||
|
||||
/**
|
||||
* 关注 / 取消关注
|
||||
**/
|
||||
|
||||
@RequestMapping("/insert")
|
||||
@Login
|
||||
public Result insert(@RequestAttribute Long userId, @RequestParam Long followUserId) {
|
||||
return userFollowService.insert(userId, followUserId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看我的关注
|
||||
*/
|
||||
@RequestMapping("/selectMyFollow")
|
||||
@Login
|
||||
public Result selectMyFollow(@RequestAttribute Long userId,Long page,Long limit) {
|
||||
return userFollowService.selectMyFollow(userId,page,limit);
|
||||
}
|
||||
/**
|
||||
* 查看我的粉丝
|
||||
*/
|
||||
@RequestMapping("/selectFans")
|
||||
@Login
|
||||
public Result selectFans(@RequestAttribute Long userId,Long page,Long limit) {
|
||||
return userFollowService.selectFans(userId,page,limit);
|
||||
}
|
||||
/**
|
||||
* 查看我是否关注
|
||||
*/
|
||||
@RequestMapping("/selectFollowUser")
|
||||
@Login
|
||||
public Result selectFollowUser(@RequestAttribute Long userId,@RequestParam Long followUserId) {
|
||||
return userFollowService.selectFollowUser(userId,followUserId);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,80 @@
|
|||
package com.sqx.modules.app.controller.app;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.app.annotation.Login;
|
||||
import com.sqx.modules.app.dao.UserDao;
|
||||
import com.sqx.modules.app.entity.UserEntity;
|
||||
import com.sqx.modules.app.service.UserMoneyService;
|
||||
import com.sqx.modules.sys.controller.AbstractController;
|
||||
import com.sqx.modules.sys.entity.SysUserEntity;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/app/userMoney")
|
||||
@Api(tags={"用户端-钱包"})
|
||||
public class AppUserMoneyController extends AbstractController {
|
||||
|
||||
@Autowired
|
||||
private UserMoneyService userMoneyService;
|
||||
@Autowired
|
||||
private UserDao userDao;
|
||||
|
||||
@GetMapping("/selectMyMoney")
|
||||
@Login
|
||||
@ApiOperation("我的钱包余额")
|
||||
public Result selectMyMoney(@RequestAttribute Long userId) {
|
||||
return Result.success().put("data", userMoneyService.selectUserMoneyByUserId(userId));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 我的收益
|
||||
*/
|
||||
@GetMapping("/selectMyProfit")
|
||||
@Login
|
||||
@ApiOperation("我的收益")
|
||||
public Result selectMyProfit(@RequestAttribute Long userId) {
|
||||
return Result.success().put("data", userMoneyService.selectMyProfit(userId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 余额明细
|
||||
*/
|
||||
@GetMapping("/balanceDetailed")
|
||||
@Login
|
||||
@ApiOperation("余额明细")
|
||||
public Result balanceDetailed(@RequestAttribute Long userId, Integer page, Integer limit, Integer classify) {
|
||||
|
||||
return userMoneyService.balanceDetailed(userId, page, limit, classify);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 收益明细
|
||||
*/
|
||||
@GetMapping("/profitDetailed")
|
||||
@Login
|
||||
@ApiOperation("收益明细")
|
||||
public Result profitDetailed(@RequestAttribute Long userId, Long page, Long limit) {
|
||||
if (page != null || limit != null) {
|
||||
return Result.error("分页条件为空");
|
||||
} else {
|
||||
IPage ipage = new Page(page, limit);
|
||||
return Result.success().put("data", userMoneyService.profitDetailed(userId, ipage));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
package com.sqx.modules.app.controller.app;
|
||||
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.app.annotation.Login;
|
||||
import com.sqx.modules.app.service.UserVipService;
|
||||
import com.sqx.modules.sys.controller.AbstractController;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@Api(value = "app 用户会员信息", tags = {"app 用户会员信息"})
|
||||
@RequestMapping(value = "/app/UserVip")
|
||||
public class AppUserVipController extends AbstractController {
|
||||
@Autowired
|
||||
private UserVipService userVipService;
|
||||
|
||||
@Login
|
||||
@GetMapping("/selectUserVip")
|
||||
@ApiOperation("查询用户会员信息")
|
||||
public Result selectUserVip(@RequestAttribute Long userId) {
|
||||
return Result.success().put("data", userVipService.selectUserVipByUserId(userId));
|
||||
}
|
||||
|
||||
@Login
|
||||
@GetMapping("/isUserVip")
|
||||
@ApiOperation("查询用户是否是会员")
|
||||
public Result isUserVip(@RequestAttribute Long userId) {
|
||||
return userVipService.isUserVip(userId);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
package com.sqx.modules.app.controller.app;
|
||||
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.app.annotation.Login;
|
||||
import com.sqx.modules.app.entity.VipDetails;
|
||||
import com.sqx.modules.app.service.VipDetailsService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/app/VipDetails")
|
||||
|
||||
@Api("app 会员详情信息")
|
||||
public class AppVipDetailsController {
|
||||
@Autowired
|
||||
private VipDetailsService appVipDetailsService;
|
||||
/**
|
||||
* 查询会员的详情信息
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Login
|
||||
@ApiParam("查询会员的详情信息")
|
||||
@GetMapping("/selectVipDetails")
|
||||
public Result selectVipDetails() {
|
||||
return appVipDetailsService.selectVipDetails();
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加会员的详情信息
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Login
|
||||
@ApiParam("添加会员的详情信息")
|
||||
@GetMapping("/insertVipDetails")
|
||||
public Result insertVipDetails(VipDetails vipDetails) {
|
||||
return appVipDetailsService.insertVipDetails(vipDetails);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
package com.sqx.modules.app.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.sqx.modules.app.entity.App;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户升级
|
||||
*
|
||||
*/
|
||||
@Mapper
|
||||
public interface AppDao extends BaseMapper<App> {
|
||||
|
||||
List<App> selectNewApp();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
package com.sqx.modules.app.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.sqx.modules.app.entity.Msg;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 用户
|
||||
*
|
||||
*/
|
||||
@Mapper
|
||||
public interface MsgDao extends BaseMapper<Msg> {
|
||||
|
||||
Msg findByPhone(String phone);
|
||||
|
||||
Msg findByPhoneAndCode(String phone, String msg);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
package com.sqx.modules.app.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.sqx.modules.app.entity.UserBrowse;
|
||||
import com.sqx.modules.app.response.UserFollowResponse;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Mapper
|
||||
public interface UserBrowseDao extends BaseMapper<UserBrowse> {
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
package com.sqx.modules.app.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.sqx.modules.app.entity.UserEntity;
|
||||
import com.sqx.modules.app.entity.UserMoney;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Mapper
|
||||
public interface UserCashOutDao extends BaseMapper<UserEntity> {
|
||||
|
||||
UserMoney findBalanceById(@Param("userId") Long userId);
|
||||
|
||||
int updateMoney(@Param("type") int type, @Param("userId") Long userId, @Param("money") Double moneySum);
|
||||
|
||||
int updateRetreatMoney(@Param("userId") Long userId,@Param("sumMoney") BigDecimal sumMoney);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
package com.sqx.modules.app.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.sqx.modules.app.entity.UserCertification;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Mapper
|
||||
public interface UserCertificationDao extends BaseMapper<UserCertification> {
|
||||
|
||||
IPage<Map<String, Object>> queryCertification(IPage iPage, @Param("status") String status, @Param("name") String name);
|
||||
|
||||
IPage<Map<String, Object>> queryUserCertification(IPage iPage, @Param("name") String name,@Param("phone")String phone);
|
||||
}
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
package com.sqx.modules.app.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.app.entity.UserEntity;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 用户
|
||||
*/
|
||||
@Mapper
|
||||
public interface UserDao extends BaseMapper<UserEntity> {
|
||||
|
||||
|
||||
IPage<UserEntity> selectUserPage(Page<UserEntity> page, String search, Integer sex, String platform, String sysPhone, Integer status,
|
||||
Integer type, String userName, Integer isVip, Integer shopAdminFlag,String nickName);
|
||||
|
||||
int queryInviterCount(@Param("inviterCode") String inviterCode);
|
||||
|
||||
int queryUserCount(@Param("type") int type, @Param("date") String date);
|
||||
|
||||
Double queryPayMoney(@Param("type") int type, @Param("date") String date);
|
||||
|
||||
IPage<Map<String, Object>> queryCourseOrder(Page iPage, @Param("type") int type, @Param("date") String date);
|
||||
|
||||
int userMessage(String date, int type);
|
||||
|
||||
int insertUser(UserEntity userEntity);
|
||||
|
||||
IPage<Map<String, Object>> takingOrdersMessage(Page<Map<String, Object>> iPage, @Param("type") Long type, @Param("date") String date);
|
||||
|
||||
|
||||
IPage<UserEntity> selectUserList(Page<UserEntity> iPage, String userName);
|
||||
|
||||
|
||||
int updateCashDeposit(@Param("userId") Long userId,@Param("cashDeposit") Double cashDeposit);
|
||||
|
||||
void updateMoney(Integer type, Long userId, Double money);
|
||||
|
||||
UserEntity selectUserById(Long userId);
|
||||
|
||||
IPage<UserEntity> selectUser(Page<UserEntity> pages, String userName, String phone);
|
||||
|
||||
int topUpMoney(@Param("classify") Integer classify, @Param("orderId") String out_trade_no, @Param("money") Double money, @Param("userId") Long userId, @Param("state") Integer state, @Param("date") String date, @Param("date1") String date1, @Param("type") Integer type);
|
||||
|
||||
int certification(@Param("userId") Long userId,@Param("phone") String phone, @Param("userName") String userName,
|
||||
@Param("identityCardNumber") String identityCardNumber,@Param("identityCardFront") String identityCardFront,
|
||||
@Param("identityCardVerso") String identityCardVerso, @Param("selfIdentityCard") String selfIdentityCard,
|
||||
@Param("format") String format,@Param("checkNumber") String checkNumber, @Param("cashDeposit") BigDecimal cashDeposit);
|
||||
|
||||
Result shopBindingQrCode(Long userId, String cashQrCode);
|
||||
|
||||
void userFeedback(Integer feedbackType,Long userId, String userEmail, Integer feedbackScore, String feedbackMessage, String format);
|
||||
|
||||
int addRedPacket(@Param("userId") Long userId, @Param("redPacketType")String redPacketType, @Param("minimumAmount")BigDecimal minimumAmount,@Param("redPacketAmount") BigDecimal redPacketAmount,@Param("redPacketTitle") String redPacketTitle,@Param("expirationTime") String expirationTime, @Param("createTime")String createTime);
|
||||
|
||||
int updateOldUser(Long userId);
|
||||
|
||||
UserEntity selectUserMessage(Long userId);
|
||||
|
||||
List<UserEntity> selectVipOverdue(String date);
|
||||
|
||||
int updateUserClientIdIsNull(String clientid);
|
||||
|
||||
int updateUserRiderClientIdIsNull(String clientid);
|
||||
|
||||
int updateUserShopClientIdIsNull(String clientid);
|
||||
|
||||
List<UserEntity> selectRiderUserByOnLineFlag(String distance,String lng,String lat);
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
package com.sqx.modules.app.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.sqx.modules.app.entity.UserFollow;
|
||||
import com.sqx.modules.app.response.UserFollowResponse;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Mapper
|
||||
public interface UserFollowDao extends BaseMapper<UserFollow> {
|
||||
|
||||
IPage<Map<String, Object>> selectMyFollow(IPage iPage, Long userId);
|
||||
|
||||
IPage<Map<String, Object>> selectFans(IPage iPage, Long userId);
|
||||
|
||||
List<UserFollowResponse> selectMyFollow1(Long userId);
|
||||
|
||||
List<UserFollowResponse> selectFans1(Long userId);
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
package com.sqx.modules.app.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.sqx.modules.app.entity.UserMoney;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Mapper
|
||||
public interface UserMoneyDao extends BaseMapper<UserMoney> {
|
||||
|
||||
void updateMayMoney(@Param("type") Integer type, @Param("userId") Long userId, @Param("money") Double money);
|
||||
|
||||
int addMoney(@Param("userId") Long userId, @Param("money") BigDecimal money);
|
||||
|
||||
UserMoney selectMoney(@Param("userId") Long userId);
|
||||
|
||||
int addUserMoney(@Param("userId") Long userId,@Param("money") BigDecimal money, @Param("type") Integer type);
|
||||
|
||||
int updateUserBalance(@Param("userId") Long userId,@Param("money") BigDecimal money, @Param("type") Integer type);
|
||||
|
||||
int updateCashDeposit(@Param("userId") Long userId,@Param("money") BigDecimal money, @Param("type") Integer type);
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
package com.sqx.modules.app.dao;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.sqx.modules.app.entity.UserMoneyDetails;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
@Mapper
|
||||
public interface UserMoneyDetailsDao extends BaseMapper<UserMoneyDetails> {
|
||||
|
||||
Double monthIncome(@Param("date") String date,@Param("userId") Long userId);
|
||||
|
||||
Double selectMyProfit(Long userId);
|
||||
|
||||
IPage<UserMoneyDetails> selectUserMoneyDetails(Page<UserMoneyDetails> pages,@Param("userId") Long userId, @Param("classify") Integer classify);
|
||||
|
||||
IPage<UserMoneyDetails> selectPwCashDetails(Page<UserMoneyDetails> pages, @Param("userName") String userName, @Param("date") String date,
|
||||
@Param("dateType") String dateType,@Param("zhifubao") String zhifubao, @Param("zhifubaoName") String zhifubaoName,
|
||||
@Param("userId") Long userId);
|
||||
|
||||
IPage<UserMoneyDetails> selectShopCashDeposit(Page<UserMoneyDetails> pages, Long shopId, Integer classify);
|
||||
|
||||
IPage<UserMoneyDetails> selectShopCashDepositList(Page<UserMoneyDetails> pages, Long shopId);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
package com.sqx.modules.app.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.sqx.modules.app.entity.UserVip;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface UserVipDao extends BaseMapper<UserVip> {
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
package com.sqx.modules.app.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.sqx.modules.app.entity.UserVisitor;
|
||||
import com.sqx.modules.app.response.UserFollowResponse;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Mapper
|
||||
public interface UserVisitorDao extends BaseMapper<UserVisitor> {
|
||||
IPage<Map<String, Object>> selectMyVisitor(IPage iPage, Long userId);
|
||||
|
||||
List<UserFollowResponse> selectMyVisitor1(Long userId);
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
package com.sqx.modules.app.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.sqx.modules.app.entity.VipDetails;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface VipDetailsDao extends BaseMapper<VipDetails> {
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
package com.sqx.modules.app.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.sqx.modules.app.entity.VipDiscount;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface VipDiscountDao extends BaseMapper<VipDiscount> {
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
package com.sqx.modules.app.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 广告位
|
||||
*/
|
||||
@Data
|
||||
public class App implements Serializable {
|
||||
@TableId
|
||||
private Long id;
|
||||
|
||||
private String createAt;
|
||||
|
||||
private String androidWgtUrl;
|
||||
|
||||
private String iosWgtUrl;
|
||||
|
||||
private String wgtUrl;
|
||||
|
||||
private String version;
|
||||
|
||||
private String iosVersion;
|
||||
|
||||
private String method;
|
||||
|
||||
private String des;
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
package com.sqx.modules.app.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class AppUserInfo {
|
||||
|
||||
|
||||
|
||||
private String openid;
|
||||
private String nickname;
|
||||
private int sex;
|
||||
private String province;
|
||||
private String city;
|
||||
private String country;
|
||||
private String headimgurl;
|
||||
private String unionid;
|
||||
private List<String> privilege;
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
package com.sqx.modules.app.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author fang
|
||||
* @date 2020/7/10
|
||||
*/
|
||||
@Data
|
||||
@TableName("msg")
|
||||
public class Msg implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId
|
||||
private Long id;
|
||||
|
||||
private String code;
|
||||
|
||||
private String phone;
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
package com.sqx.modules.app.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @description user_browse
|
||||
* @author liyuan
|
||||
* @date 2021-08-12
|
||||
*/
|
||||
@Data
|
||||
@ApiModel("user_browse")
|
||||
public class UserBrowse implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
/**
|
||||
* 浏览访客id
|
||||
*/
|
||||
@ApiModelProperty("浏览访客id")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
@ApiModelProperty("用户id")
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 被浏览id
|
||||
*/
|
||||
@ApiModelProperty("被浏览id")
|
||||
private Long byBrowseId;
|
||||
|
||||
|
||||
/**
|
||||
* 接单id
|
||||
*/
|
||||
@ApiModelProperty("接单id")
|
||||
private Long takingId;
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@ApiModelProperty("更新时间")
|
||||
private String updateTime;
|
||||
|
||||
public UserBrowse() {}
|
||||
}
|
||||
|
|
@ -0,0 +1,82 @@
|
|||
package com.sqx.modules.app.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author liyuan
|
||||
* @description user_certification
|
||||
* @date 2021-08-13
|
||||
*/
|
||||
@Data
|
||||
@ApiModel("user_certification")
|
||||
public class UserCertification implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
/**
|
||||
* 用户实名认证id
|
||||
*/
|
||||
@ApiModelProperty("用户实名认证id")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 真实姓名
|
||||
*/
|
||||
@ApiModelProperty("真实姓名")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 身份证号码
|
||||
*/
|
||||
@ApiModelProperty("身份证号码")
|
||||
private String idNumber;
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
@ApiModelProperty("用户id")
|
||||
private Long userId;
|
||||
|
||||
@TableField(exist = false)
|
||||
private UserEntity userEntity;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@ApiModelProperty("创建时间")
|
||||
private String createTime;
|
||||
/**
|
||||
* 正面
|
||||
*/
|
||||
private String front;
|
||||
/**
|
||||
* 反面
|
||||
*/
|
||||
private String back;
|
||||
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
private Long status;
|
||||
|
||||
/**
|
||||
* 说明
|
||||
*/
|
||||
private String remek;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
private String updateTime;
|
||||
|
||||
public UserCertification() {
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
package com.sqx.modules.app.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
public class UserDetails {
|
||||
/**
|
||||
* 本月订单数量
|
||||
*/
|
||||
private int monthlyOrderNum;
|
||||
/**
|
||||
* 本月充值金额
|
||||
*/
|
||||
private BigDecimal monthlyRechargeMoney;
|
||||
/**
|
||||
*本月提现数量
|
||||
*/
|
||||
private int monthWithdrawalNum;
|
||||
/**
|
||||
* 本月提现金额
|
||||
*/
|
||||
private BigDecimal monthlyWithdrawalMoney;
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,261 @@
|
|||
package com.sqx.modules.app.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
|
||||
/**
|
||||
* 用户
|
||||
*
|
||||
*/
|
||||
@Data
|
||||
@ApiModel("用户")
|
||||
@TableName("tb_user")
|
||||
public class UserEntity implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
|
||||
@ApiModelProperty("用户id")
|
||||
private Long userId;
|
||||
|
||||
|
||||
@ApiModelProperty("用户名")
|
||||
private String userName;
|
||||
|
||||
|
||||
@ApiModelProperty("用户类型 1用户 2骑手师傅")
|
||||
private Integer userType;
|
||||
|
||||
|
||||
@ApiModelProperty("手机号")
|
||||
private String phone;
|
||||
|
||||
|
||||
@ApiModelProperty("头像")
|
||||
private String avatar;
|
||||
|
||||
|
||||
@ApiModelProperty("昵称")
|
||||
private String nickName;
|
||||
|
||||
|
||||
@ApiModelProperty("性别 1男 2女")
|
||||
private Integer sex;
|
||||
|
||||
|
||||
@ApiModelProperty("年龄")
|
||||
private Integer age;
|
||||
|
||||
|
||||
@ApiModelProperty("保证金")
|
||||
private BigDecimal cashDeposit;
|
||||
|
||||
|
||||
@ApiModelProperty("账户余额")
|
||||
private BigDecimal balance;
|
||||
|
||||
|
||||
@ApiModelProperty("证件号码")
|
||||
private String identityCardNumber;
|
||||
|
||||
|
||||
@ApiModelProperty("身份证正面图片")
|
||||
private String identityCardFront;
|
||||
|
||||
|
||||
@ApiModelProperty("身份证反面图片")
|
||||
private String identityCardVerso;
|
||||
|
||||
|
||||
@ApiModelProperty("手持身份证正面图片")
|
||||
private String selfIdentityCard;
|
||||
|
||||
|
||||
@ApiModelProperty("实名认证审核状态(0:待审核;1:审核通过;2:审核不通过)")
|
||||
private String checkCertification;
|
||||
|
||||
|
||||
@ApiModelProperty("实名认证审核说明")
|
||||
private String checkCertificationMessage;
|
||||
|
||||
|
||||
@ApiModelProperty("邀请码")
|
||||
private String invitationCode;
|
||||
|
||||
|
||||
@ApiModelProperty("邀请人邀请码")
|
||||
private String inviterCode;
|
||||
|
||||
|
||||
@ApiModelProperty("微信app openid")
|
||||
private String wxOpenId;
|
||||
|
||||
|
||||
@ApiModelProperty("rider_wx_open_id")
|
||||
private String riderWxOpenId;
|
||||
|
||||
|
||||
@ApiModelProperty("普通用户微信小程序openid")
|
||||
private String openId;
|
||||
|
||||
|
||||
@ApiModelProperty("骑手用户微信小程序openid")
|
||||
private String riderOpenId;
|
||||
|
||||
@ApiModelProperty("商家用户微信小程序openid")
|
||||
private String shopOpenId;
|
||||
|
||||
|
||||
@ApiModelProperty("密码")
|
||||
private String password;
|
||||
|
||||
|
||||
@ApiModelProperty("苹果id")
|
||||
private String appleId;
|
||||
|
||||
|
||||
@ApiModelProperty("手机类型 1安卓 2ios")
|
||||
private Integer sysPhone;
|
||||
|
||||
|
||||
@ApiModelProperty("状态 1正常 2禁用")
|
||||
private Integer status;
|
||||
|
||||
|
||||
@ApiModelProperty("来源 app 小程序 公众号")
|
||||
private String platform;
|
||||
|
||||
|
||||
@ApiModelProperty("积分")
|
||||
private Integer jifen;
|
||||
|
||||
|
||||
@ApiModelProperty("设备id")
|
||||
private String clientid;
|
||||
|
||||
|
||||
@ApiModelProperty("骑手设备id")
|
||||
private String riderClientid;
|
||||
|
||||
@ApiModelProperty("商家设备id")
|
||||
private String shopClientId;
|
||||
|
||||
|
||||
@ApiModelProperty("支付宝名字")
|
||||
private String zhiFuBaoName;
|
||||
|
||||
|
||||
@ApiModelProperty("支付宝账号")
|
||||
private String zhiFuBao;
|
||||
|
||||
|
||||
@ApiModelProperty("创建时间")
|
||||
private String createTime;
|
||||
|
||||
|
||||
@ApiModelProperty("更新时间")
|
||||
private String updateTime;
|
||||
|
||||
|
||||
@ApiModelProperty("用户类型")
|
||||
private Integer type;
|
||||
|
||||
|
||||
@ApiModelProperty("用户提交实名认证时间")
|
||||
private String auditTime;
|
||||
|
||||
|
||||
@ApiModelProperty("该用户是否是跑腿新用户 1:是新用户 2:是老用户")
|
||||
private Integer newUserFlag;
|
||||
|
||||
|
||||
@ApiModelProperty("该用户是否是外卖新用户 1:是新用户 2:是老用户")
|
||||
private Integer newUserFlagWm;
|
||||
|
||||
|
||||
@ApiModelProperty("骑手当前经度")
|
||||
private Double stationLng;
|
||||
|
||||
|
||||
@ApiModelProperty("骑手当前维度")
|
||||
private Double stationLat;
|
||||
|
||||
|
||||
@ApiModelProperty("骑手是否上线 1:上线 2:未上线")
|
||||
private Integer onLineFlag;
|
||||
|
||||
|
||||
@ApiModelProperty("实名认证支付保证金订单号")
|
||||
private String checkNumber;
|
||||
|
||||
|
||||
@ApiModelProperty("是否是门店用户 1是")
|
||||
private Integer shopAdminFlag;
|
||||
|
||||
|
||||
@ApiModelProperty("门店管理员id")
|
||||
private Long adminUserId;
|
||||
|
||||
@ApiModelProperty("用户提现二维码")
|
||||
@TableField(value = "cash_qr_code")
|
||||
private String cashQrCode;
|
||||
|
||||
@ApiModelProperty("是否推送消息")
|
||||
private Integer isSendMsg;
|
||||
|
||||
private String msg;
|
||||
|
||||
@ApiModelProperty("是否是会员 0不是 1是")
|
||||
private Integer isVip;
|
||||
|
||||
@ApiModelProperty("会员到期时间")
|
||||
private String vipExpirationTime;
|
||||
|
||||
@TableField(exist = false)
|
||||
private BigDecimal money;
|
||||
|
||||
@TableField(exist = false)
|
||||
private BigDecimal integralNum;
|
||||
|
||||
//本月下单数量
|
||||
@TableField(exist = false)
|
||||
private Integer orderMonth;
|
||||
|
||||
//本月接单数量
|
||||
@TableField(exist = false)
|
||||
private Integer joinOrderMonth;
|
||||
|
||||
//本月充值
|
||||
@TableField(exist = false)
|
||||
private BigDecimal topUpMonth;
|
||||
|
||||
//骑手收入
|
||||
@TableField(exist = false)
|
||||
private BigDecimal riderMoney;
|
||||
|
||||
//提现金额
|
||||
@TableField(exist = false)
|
||||
private BigDecimal cashMoney;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String indentNumber;
|
||||
|
||||
@TableField(exist = false)
|
||||
private Double distance;
|
||||
|
||||
@TableField(exist = false)
|
||||
private Integer shopStatus;
|
||||
|
||||
@TableField(exist = false)
|
||||
private Long shopId;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
package com.sqx.modules.app.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @description user_follow
|
||||
* @author liyuan
|
||||
* @date 2021-08-12
|
||||
*/
|
||||
@Data
|
||||
@ApiModel("user_follow")
|
||||
public class UserFollow implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@ApiModelProperty("id")
|
||||
private Long followId;
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
@ApiModelProperty("用户id")
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 关注用户id
|
||||
*/
|
||||
@ApiModelProperty("关注用户id")
|
||||
private Long followUserId;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@ApiModelProperty("创建时间")
|
||||
private String createTime;
|
||||
|
||||
public UserFollow() {}
|
||||
}
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
package com.sqx.modules.app.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
@TableName("user_money")
|
||||
@ApiModel("用户钱包")
|
||||
public class UserMoney implements Serializable {
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
@ApiModelProperty("主键id")
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
@ApiModelProperty("用户id")
|
||||
@TableField("user_id")
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 钱包金额
|
||||
*/
|
||||
@ApiModelProperty("钱包金额")
|
||||
private BigDecimal money;
|
||||
|
||||
/**
|
||||
* 累计收入金额
|
||||
*//*
|
||||
@ApiModelProperty("累计收入金额")
|
||||
@TableField("income_money")
|
||||
private BigDecimal IncomeMoney;
|
||||
|
||||
*//**
|
||||
* 累计提现金额
|
||||
*//*
|
||||
@ApiModelProperty("累计提现金额")
|
||||
@TableField("withdraw_deposit_money")
|
||||
private BigDecimal withdrawDepositMoney;*/
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,82 @@
|
|||
package com.sqx.modules.app.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
@TableName("user_money_details")
|
||||
@ApiModel("钱包详情")
|
||||
public class UserMoneyDetails implements Serializable {
|
||||
/**
|
||||
* 钱包详情id
|
||||
*/
|
||||
@ApiModelProperty("钱包详情id")
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
@TableField("user_id")
|
||||
@ApiModelProperty("用户id")
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 商户id
|
||||
*/
|
||||
@TableField("shop_id")
|
||||
@ApiModelProperty("商户id")
|
||||
private Long shopId;
|
||||
|
||||
/**
|
||||
* 标题
|
||||
*/
|
||||
@ApiModelProperty("标题")
|
||||
private String title;
|
||||
/**
|
||||
* 类别 1保证金 (后续再加)
|
||||
*/
|
||||
|
||||
@ApiModelProperty("类别 1骑手保证金 2商户保证金 3钱包明细")
|
||||
private Integer classify;
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
@ApiModelProperty("类型 1.钱包收入 2.钱包支出")
|
||||
private Integer type;
|
||||
/**
|
||||
* 状态 1待支付 2已到账 3取消
|
||||
*/
|
||||
@ApiModelProperty("状态 1待支付 2已到账 3取消")
|
||||
private Integer state;
|
||||
/**
|
||||
* 金额
|
||||
*/
|
||||
@ApiModelProperty("金额")
|
||||
private BigDecimal money;
|
||||
/**
|
||||
* 内容
|
||||
*/
|
||||
@ApiModelProperty("内容")
|
||||
private String content;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField("create_time")
|
||||
@ApiModelProperty("创建时间")
|
||||
private String createTime;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String userName;
|
||||
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue