哪达尔后台代码初始化
commit
9dbb99c964
|
|
@ -0,0 +1,2 @@
|
||||||
|
/target/**
|
||||||
|
.idea/**
|
||||||
|
|
@ -0,0 +1,543 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<groupId>com.gfwl</groupId>
|
||||||
|
<artifactId>talents</artifactId>
|
||||||
|
<version>0.0.1</version>
|
||||||
|
|
||||||
|
<name>talents</name>
|
||||||
|
<description>gfwl project for Spring Boot</description>
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-parent</artifactId>
|
||||||
|
<version>2.2.2.RELEASE</version>
|
||||||
|
<relativePath/>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<java.version>1.8</java.version>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
|
<skipTests>true</skipTests>
|
||||||
|
<shiro-spring.version>1.6.0</shiro-spring.version>
|
||||||
|
<shiro-redis.version>3.2.3</shiro-redis.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<!-- spring-boot-devtools -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-devtools</artifactId>
|
||||||
|
<scope>runtime</scope>
|
||||||
|
<optional>true</optional>
|
||||||
|
|
||||||
|
</dependency>
|
||||||
|
<!-- spring-boot-test -->
|
||||||
|
<!-- <dependency>-->
|
||||||
|
<!-- <groupId>org.springframework.boot</groupId>-->
|
||||||
|
<!-- <artifactId>spring-boot-starter-test</artifactId>-->
|
||||||
|
<!-- <scope>test</scope>-->
|
||||||
|
<!-- <exclusions>-->
|
||||||
|
<!-- <exclusion>-->
|
||||||
|
<!-- <artifactId>asm</artifactId>-->
|
||||||
|
<!-- <groupId>org.ow2.asm</groupId>-->
|
||||||
|
<!-- </exclusion>-->
|
||||||
|
<!-- <exclusion>-->
|
||||||
|
<!-- <groupId>org.slf4j</groupId>-->
|
||||||
|
<!-- <artifactId>slf4j-log4j12</artifactId>-->
|
||||||
|
<!-- </exclusion>-->
|
||||||
|
<!-- </exclusions>-->
|
||||||
|
<!-- </dependency>-->
|
||||||
|
<!-- web -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- mysql -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>mysql</groupId>
|
||||||
|
<artifactId>mysql-connector-java</artifactId>
|
||||||
|
<scope>runtime</scope>
|
||||||
|
</dependency>
|
||||||
|
<!-- druid -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba</groupId>
|
||||||
|
<artifactId>druid-spring-boot-starter</artifactId>
|
||||||
|
<version>1.1.9</version>
|
||||||
|
</dependency>
|
||||||
|
<!-- mybatis-plus -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.baomidou</groupId>
|
||||||
|
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||||
|
<version>3.3.1</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- fastjson -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba</groupId>
|
||||||
|
<artifactId>fastjson</artifactId>
|
||||||
|
<version>1.2.47</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 工具-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
<version>1.16.18</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>commons-codec</groupId>
|
||||||
|
<artifactId>commons-codec</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.bouncycastle</groupId>
|
||||||
|
<artifactId>bcprov-jdk15on</artifactId>
|
||||||
|
<version>1.55</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.httpcomponents</groupId>
|
||||||
|
<artifactId>httpclient</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.httpcomponents</groupId>
|
||||||
|
<artifactId>httpcore</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>redis.clients</groupId>
|
||||||
|
<artifactId>jedis</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>io.lettuce</groupId>
|
||||||
|
<artifactId>lettuce-core</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>redis.clients</groupId>
|
||||||
|
<artifactId>jedis</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.commons</groupId>
|
||||||
|
<artifactId>commons-pool2</artifactId>
|
||||||
|
<version>2.6.2</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- https://mvnrepository.com/artifact/com.thoughtworks.xstream/xstream -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.thoughtworks.xstream</groupId>
|
||||||
|
<artifactId>xstream</artifactId>
|
||||||
|
<version>1.4.10</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- shiro -->
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.shiro</groupId>
|
||||||
|
<artifactId>shiro-spring</artifactId>
|
||||||
|
<version>${shiro-spring.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.crazycake</groupId>
|
||||||
|
<artifactId>shiro-redis</artifactId>
|
||||||
|
<version>${shiro-redis.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!--模板引擎beetl-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.ibeetl</groupId>
|
||||||
|
<artifactId>beetl</artifactId>
|
||||||
|
<version>3.0.16.RELEASE</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 图形验证码 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.whvcse</groupId>
|
||||||
|
<artifactId>easy-captcha</artifactId>
|
||||||
|
<version>1.6.2</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>commons-codec</groupId>
|
||||||
|
<artifactId>commons-codec</artifactId>
|
||||||
|
<version>1.9</version>
|
||||||
|
</dependency>
|
||||||
|
<!-- 从request获取设备信息 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>eu.bitwalker</groupId>
|
||||||
|
<artifactId>UserAgentUtils</artifactId>
|
||||||
|
<version>1.21</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 获取文件类型 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.tika</groupId>
|
||||||
|
<artifactId>tika-core</artifactId>
|
||||||
|
<version>1.20</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.livesense</groupId>
|
||||||
|
<artifactId>jodconverter-core</artifactId>
|
||||||
|
<version>1.0.5</version>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<artifactId>commons-io</artifactId>
|
||||||
|
<groupId>commons-io</groupId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<artifactId>juh</artifactId>
|
||||||
|
<groupId>org.openoffice</groupId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<artifactId>ridl</artifactId>
|
||||||
|
<groupId>org.openoffice</groupId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<artifactId>unoil</artifactId>
|
||||||
|
<groupId>org.openoffice</groupId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.hutool</groupId>
|
||||||
|
<artifactId>hutool-all</artifactId>
|
||||||
|
<version>5.3.10</version>
|
||||||
|
</dependency>
|
||||||
|
<!--Hutool工具ExcelUtil依赖这个 https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.poi</groupId>
|
||||||
|
<artifactId>poi-ooxml</artifactId>
|
||||||
|
<version>4.1.0</version>
|
||||||
|
</dependency>
|
||||||
|
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.commons</groupId>
|
||||||
|
<artifactId>commons-lang3</artifactId>
|
||||||
|
<version>3.4</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- aop -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-aop</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jdom</groupId>
|
||||||
|
<artifactId>jdom</artifactId>
|
||||||
|
<version>2.0.2</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 发送邮件 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-mail</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.aliyun</groupId>
|
||||||
|
<artifactId>aliyun-java-sdk-core</artifactId>
|
||||||
|
<version>4.4.6</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- https://mvnrepository.com/artifact/com.github.xiaoymin/knife4j-spring-boot-starter -->
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.xiaoymin</groupId>
|
||||||
|
<artifactId>knife4j-spring-boot-starter</artifactId>
|
||||||
|
<version>2.0.4</version>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<artifactId>swagger-models</artifactId>
|
||||||
|
<groupId>io.swagger</groupId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.xiaoymin</groupId>
|
||||||
|
<artifactId>knife4j-spring-ui</artifactId>
|
||||||
|
<version>2.0.4</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.springfox</groupId>
|
||||||
|
<artifactId>springfox-swagger2</artifactId>
|
||||||
|
<version>2.9.2</version>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<artifactId>swagger-annotations</artifactId>
|
||||||
|
<groupId>io.swagger</groupId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<artifactId>swagger-models</artifactId>
|
||||||
|
<groupId>io.swagger</groupId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.swagger</groupId>
|
||||||
|
<artifactId>swagger-annotations</artifactId>
|
||||||
|
<version>1.5.21</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.swagger</groupId>
|
||||||
|
<artifactId>swagger-models</artifactId>
|
||||||
|
<version>1.5.21</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.springfox</groupId>
|
||||||
|
<artifactId>springfox-swagger-ui</artifactId>
|
||||||
|
<version>2.9.2</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.tencentcloudapi</groupId>
|
||||||
|
<artifactId>tencentcloud-sdk-java</artifactId>
|
||||||
|
<version>3.1.113</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- <dependency>-->
|
||||||
|
<!-- <groupId>com.github.tencentyun</groupId>-->
|
||||||
|
<!-- <artifactId>tls-sig-api-v2</artifactId>-->
|
||||||
|
<!-- <version>1.1</version>-->
|
||||||
|
<!-- </dependency>-->
|
||||||
|
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.coobird</groupId>
|
||||||
|
<artifactId>thumbnailator</artifactId>
|
||||||
|
<version>0.4.8</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.gitee.qdbp.thirdparty</groupId>
|
||||||
|
<artifactId>ueditor</artifactId>
|
||||||
|
<version>1.4.3.3</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.aliyun.oss</groupId>
|
||||||
|
<artifactId>aliyun-sdk-oss</artifactId>
|
||||||
|
<version>3.10.2</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.aliyun</groupId>
|
||||||
|
<artifactId>aliyun-java-sdk-core</artifactId>
|
||||||
|
<version>4.5.3</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- IOS 登录 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.jsonwebtoken</groupId>
|
||||||
|
<artifactId>jjwt</artifactId>
|
||||||
|
<version>0.9.1</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.auth0</groupId>
|
||||||
|
<artifactId>jwks-rsa</artifactId>
|
||||||
|
<version>0.9.0</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.commons</groupId>
|
||||||
|
<artifactId>commons-crypto</artifactId>
|
||||||
|
<version>1.0.0</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>dom4j</groupId>
|
||||||
|
<artifactId>dom4j</artifactId>
|
||||||
|
<version>1.6.1</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.commons</groupId>
|
||||||
|
<artifactId>commons-crypto</artifactId>
|
||||||
|
<version>1.0.0</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>jaxen</groupId>
|
||||||
|
<artifactId>jaxen</artifactId>
|
||||||
|
<version>1.1.6</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- https://mvnrepository.com/artifact/me.zhyd.oauth/JustAuth -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>me.zhyd.oauth</groupId>
|
||||||
|
<artifactId>JustAuth</artifactId>
|
||||||
|
<version>1.15.9</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
<!--pdf-->
|
||||||
|
<!-- <dependency>-->
|
||||||
|
<!-- <groupId>com.itextpdf</groupId>-->
|
||||||
|
<!-- <artifactId>itextpdf</artifactId>-->
|
||||||
|
<!-- <version>5.5.13.2</version>-->
|
||||||
|
<!-- </dependency>-->
|
||||||
|
<!-- <dependency>-->
|
||||||
|
<!-- <groupId>com.itextpdf.tool</groupId>-->
|
||||||
|
<!-- <artifactId>xmlworker</artifactId>-->
|
||||||
|
<!-- <version>5.5.13.2</version>-->
|
||||||
|
<!-- </dependency>-->
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-freemarker</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!--itext-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.itextpdf</groupId>
|
||||||
|
<artifactId>itext-asian</artifactId>
|
||||||
|
<version>5.2.0</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.xhtmlrenderer</groupId>
|
||||||
|
<artifactId>core-renderer</artifactId>
|
||||||
|
<version>R8</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.javen205</groupId>
|
||||||
|
<artifactId>IJPay-WxPay</artifactId>
|
||||||
|
<version>2.9.7</version>
|
||||||
|
</dependency>
|
||||||
|
<!-- <!–微信小程序进行解密加密的用户信息 –>-->
|
||||||
|
<!-- <dependency>-->
|
||||||
|
<!-- <groupId>org.codehaus.xfire</groupId>-->
|
||||||
|
<!-- <artifactId>xfire-core</artifactId>-->
|
||||||
|
<!-- <version>1.2.6</version>-->
|
||||||
|
<!-- </dependency>-->
|
||||||
|
<!-- <dependency>-->
|
||||||
|
<!-- <groupId>org.bouncycastle</groupId>-->
|
||||||
|
<!-- <artifactId>bcprov-jdk16</artifactId>-->
|
||||||
|
<!-- <version>1.46</version>-->
|
||||||
|
<!-- </dependency>-->
|
||||||
|
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.peak</groupId>
|
||||||
|
<artifactId>peak-tools</artifactId>
|
||||||
|
<version>1.0.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
<!-- <dependency>-->
|
||||||
|
<!-- <groupId>com.peak</groupId>-->
|
||||||
|
<!-- <artifactId>peak-tool</artifactId>-->
|
||||||
|
<!-- <version>1.0.0-SNAPSHOT</version>-->
|
||||||
|
<!--<!– <scope>system</scope>–>-->
|
||||||
|
<!--<!– <systemPath>${project.basedir}/src/main/resource/lib/peak-tool-1.0.3.jar</systemPath>–>-->
|
||||||
|
<!-- </dependency>-->
|
||||||
|
|
||||||
|
|
||||||
|
<!-- https://mvnrepository.com/artifact/net.sdruskat/net.sdruskat.fragment.sun.misc -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.sdruskat</groupId>
|
||||||
|
<artifactId>net.sdruskat.fragment.sun.misc</artifactId>
|
||||||
|
<version>1.0.0</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.afterturn</groupId>
|
||||||
|
<artifactId>easypoi-base</artifactId>
|
||||||
|
<version>4.4.0</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.afterturn</groupId>
|
||||||
|
<artifactId>easypoi-annotation</artifactId>
|
||||||
|
<version>4.4.0</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.afterturn</groupId>
|
||||||
|
<artifactId>easypoi-web</artifactId>
|
||||||
|
<version>4.4.0</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba</groupId>
|
||||||
|
<artifactId>easyexcel</artifactId>
|
||||||
|
<version>3.2.0</version>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<artifactId>poi-ooxml-schemas</artifactId>
|
||||||
|
<groupId>org.apache.poi</groupId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.poi</groupId>
|
||||||
|
<artifactId>poi-ooxml</artifactId>
|
||||||
|
<version>5.0.0</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>maven-public</id>
|
||||||
|
<name>Nexus Central</name>
|
||||||
|
<!-- 虚拟的URL形式,指向镜像的URL-->
|
||||||
|
<url>https://nexus.mrzin.cn/repository/maven-public/</url>
|
||||||
|
<layout>default</layout>
|
||||||
|
<!-- 表示可以从这个仓库下载releases版本的构件-->
|
||||||
|
<releases>
|
||||||
|
<enabled>true</enabled>
|
||||||
|
<updatePolicy>always</updatePolicy>
|
||||||
|
</releases>
|
||||||
|
<snapshots>
|
||||||
|
<enabled>true</enabled>
|
||||||
|
<updatePolicy>always</updatePolicy>
|
||||||
|
</snapshots>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
<version>2.7.17</version>
|
||||||
|
<configuration>
|
||||||
|
<includeSystemScope>true</includeSystemScope>
|
||||||
|
<fork>true</fork>
|
||||||
|
</configuration>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<goals>
|
||||||
|
<goal>repackage</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
|
||||||
|
<resources>
|
||||||
|
<resource>
|
||||||
|
<directory>src/main/resource</directory>
|
||||||
|
<includes>
|
||||||
|
<include>**</include>
|
||||||
|
</includes>
|
||||||
|
</resource>
|
||||||
|
</resources>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
|
||||||
|
</project>
|
||||||
|
|
@ -0,0 +1,54 @@
|
||||||
|
package com;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.mybatis.spring.annotation.MapperScan;
|
||||||
|
import org.mybatis.spring.annotation.MapperScans;
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||||
|
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||||
|
import org.springframework.scheduling.annotation.EnableAsync;
|
||||||
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||||
|
import org.springframework.util.ResourceUtils;
|
||||||
|
import springfox.documentation.spring.web.SpringfoxWebMvcConfiguration;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName TalentsApplication
|
||||||
|
* @Description: TODO
|
||||||
|
* @Author jianpòlan
|
||||||
|
* @Date 7-27 第5周
|
||||||
|
* @Version V1.0
|
||||||
|
**/
|
||||||
|
@Slf4j
|
||||||
|
@EnableAsync
|
||||||
|
@MapperScans({@MapperScan("com.gfwl.**.mapper")})
|
||||||
|
@SpringBootApplication
|
||||||
|
@EnableScheduling
|
||||||
|
@ConditionalOnClass(SpringfoxWebMvcConfiguration.class)
|
||||||
|
public class TalentsApplication {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
|
||||||
|
String path = "classpath:peak_config.properties";
|
||||||
|
try {
|
||||||
|
File file = ResourceUtils.getFile(path);
|
||||||
|
System.out.println(file.getAbsolutePath());
|
||||||
|
Properties properties = new Properties();
|
||||||
|
// properties.load(new FileInputStream(file.getAbsolutePath()));
|
||||||
|
properties.load(new InputStreamReader(new FileInputStream(file.getAbsolutePath()), "UTF-8"));
|
||||||
|
// PropertyUtil.initProperties(properties);
|
||||||
|
log.info("初始化第三方配置完成");
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
SpringApplication application = new SpringApplicationBuilder(TalentsApplication.class).build(args);
|
||||||
|
application.run();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,50 @@
|
||||||
|
package com.gfwl.admin.base;
|
||||||
|
|
||||||
|
import com.gfwl.admin.entity.User;
|
||||||
|
import org.apache.shiro.SecurityUtils;
|
||||||
|
import org.apache.shiro.subject.Subject;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Controller基类
|
||||||
|
* Created by wangfan on 2017-06-10 10:10
|
||||||
|
*/
|
||||||
|
public class BaseController {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取当前登录的user
|
||||||
|
*/
|
||||||
|
public User getLoginUser() {
|
||||||
|
Subject subject = SecurityUtils.getSubject( );
|
||||||
|
if (subject == null) return null;
|
||||||
|
Object object = subject.getPrincipal( );
|
||||||
|
if (object != null) return (User) object;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取当前登录的userId
|
||||||
|
*/
|
||||||
|
public Integer getLoginUserId() {
|
||||||
|
User loginUser = getLoginUser( );
|
||||||
|
return loginUser == null ? null : loginUser.getUserId( );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取当前登录的userId String
|
||||||
|
*/
|
||||||
|
public String getLoginUserIdStr() {
|
||||||
|
User loginUser = getLoginUser( );
|
||||||
|
return loginUser == null ? "" : String.valueOf(loginUser.getUserId( ));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取后台用户所属小区 权限数据
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String getLoginUserOrganizationId() {
|
||||||
|
User loginUser = getLoginUser( );
|
||||||
|
return loginUser == null ? null : loginUser.getOrganizationId( );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,52 @@
|
||||||
|
package com.gfwl.admin.base;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量修改通用参数
|
||||||
|
* Created by wangfan on 2020-03-13 0:11
|
||||||
|
*/
|
||||||
|
public class BatchParam<T> implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
/**
|
||||||
|
* 主键id集合
|
||||||
|
*/
|
||||||
|
private List<Serializable> ids;
|
||||||
|
/**
|
||||||
|
* 批量修改多个字段
|
||||||
|
*/
|
||||||
|
private T data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通用批量修改方法
|
||||||
|
*
|
||||||
|
* @param service IService
|
||||||
|
* @param idName id字段名称
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public boolean update(IService<T> service, String idName) {
|
||||||
|
if (data == null) return false;
|
||||||
|
return service.update(data, new UpdateWrapper<T>().in(idName, this.getIds()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Serializable> getIds() {
|
||||||
|
return ids;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIds(List<Serializable> ids) {
|
||||||
|
this.ids = ids;
|
||||||
|
}
|
||||||
|
|
||||||
|
public T getData() {
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setData(T data) {
|
||||||
|
this.data = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,103 @@
|
||||||
|
package com.gfwl.admin.base;
|
||||||
|
|
||||||
|
import com.gfwl.config.consts.Constants;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 接口返回结果对象
|
||||||
|
* Created by wangfan on 2017-06-10 10:10
|
||||||
|
*/
|
||||||
|
public class JsonResult extends HashMap<String, Object> {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
private static final String CODE_NAME = "code"; // 状态码字段名称
|
||||||
|
private static final String MSG_NAME = "msg"; // 状态信息字段名称
|
||||||
|
private static final String DATA_NAME = "data"; // 数据字段名称
|
||||||
|
private static final int DEFAULT_OK_CODE = Constants.RESULT_OK_CODE; // 默认成功码
|
||||||
|
private static final int DEFAULT_ERROR_CODE = Constants.RESULT_ERROR_CODE; // 默认失败码
|
||||||
|
private static final String DEFAULT_OK_MSG = "操作成功"; // 默认成功msg
|
||||||
|
private static final String DEFAULT_ERROR_MSG = "操作失败"; // 默认失败msg
|
||||||
|
|
||||||
|
private JsonResult() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回成功
|
||||||
|
*/
|
||||||
|
public static JsonResult ok() {
|
||||||
|
return ok(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回成功
|
||||||
|
*/
|
||||||
|
public static JsonResult ok(String message) {
|
||||||
|
return ok(DEFAULT_OK_CODE, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回成功
|
||||||
|
*/
|
||||||
|
public static JsonResult ok(int code, String message) {
|
||||||
|
if (message == null) message = DEFAULT_OK_MSG;
|
||||||
|
JsonResult jsonResult = new JsonResult();
|
||||||
|
jsonResult.put(CODE_NAME, code);
|
||||||
|
jsonResult.put(MSG_NAME, message);
|
||||||
|
return jsonResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回失败
|
||||||
|
*/
|
||||||
|
public static JsonResult error() {
|
||||||
|
return error(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回失败
|
||||||
|
*/
|
||||||
|
public static JsonResult error(String message) {
|
||||||
|
return error(DEFAULT_ERROR_CODE, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回失败
|
||||||
|
*/
|
||||||
|
public static JsonResult error(int code, String message) {
|
||||||
|
if (message == null) message = DEFAULT_ERROR_MSG;
|
||||||
|
return ok(code, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public JsonResult setCode(Integer code) {
|
||||||
|
return put(CODE_NAME, code);
|
||||||
|
}
|
||||||
|
|
||||||
|
public JsonResult setMsg(String message) {
|
||||||
|
return put(MSG_NAME, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public JsonResult setData(Object object) {
|
||||||
|
return put(DATA_NAME, object);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getCode(int code) {
|
||||||
|
Object o = get(CODE_NAME);
|
||||||
|
return o == null ? null : Integer.parseInt(o.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMsg() {
|
||||||
|
Object o = get(MSG_NAME);
|
||||||
|
return o == null ? null : o.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object getData() {
|
||||||
|
return get(DATA_NAME);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JsonResult put(String key, Object object) {
|
||||||
|
if (key != null && object != null) super.put(key, object);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,444 @@
|
||||||
|
package com.gfwl.admin.base;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 列表分页、排序、搜索通用接收参数封装
|
||||||
|
* Created by wangfan on 2019-04-26 10:34
|
||||||
|
*/
|
||||||
|
public class PageParam<T> extends Page<T> {
|
||||||
|
private static final String FILED_PAGE = "page"; // 第几页参数名称
|
||||||
|
private static final String FILED_LIMIT = "limit"; // 每页显示数量参数名称
|
||||||
|
private static final String FILED_SORT = "sort"; // 排序字段参数名称
|
||||||
|
private static final String FILED_ORDER = "order"; // 排序方式参数名称
|
||||||
|
private static final String VALUE_ORDER_ASC = "asc"; // 表示升序的值
|
||||||
|
private static final String VALUE_ORDER_DESC = "desc"; // 表示降序的值
|
||||||
|
private static final Pattern HUMP_PATTERN = Pattern.compile("[A-Z]"); // 驼峰转下划线正则匹配
|
||||||
|
/**
|
||||||
|
* 除分页、排序外的其他参数
|
||||||
|
*/
|
||||||
|
private Map<String, Object> pageData;
|
||||||
|
/**
|
||||||
|
* 是否把字段名称驼峰转下划线
|
||||||
|
*/
|
||||||
|
private boolean needToLine = true;
|
||||||
|
|
||||||
|
public PageParam() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public PageParam(HttpServletRequest request) {
|
||||||
|
init(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PageParam(HttpServletRequest request, boolean needToLine) {
|
||||||
|
setNeedToLine(needToLine);
|
||||||
|
init(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isNeedToLine() {
|
||||||
|
return needToLine;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PageParam<T> setNeedToLine(boolean needToLine) {
|
||||||
|
this.needToLine = needToLine;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, Object> getPageData() {
|
||||||
|
return pageData;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPageData(Map<String, Object> data) {
|
||||||
|
this.pageData = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 从request中获取参数并填充到PageParam中
|
||||||
|
*/
|
||||||
|
public PageParam<T> init(HttpServletRequest request) {
|
||||||
|
String sortValue = null, orderValue = null;
|
||||||
|
Map<String, Object> map = new HashMap<>();
|
||||||
|
Enumeration<String> names = request.getParameterNames();
|
||||||
|
while (names.hasMoreElements()) {
|
||||||
|
String name = names.nextElement();
|
||||||
|
String value = request.getParameter(name);
|
||||||
|
if (value == null || value.isEmpty() || value.replace(" ", "").isEmpty()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (FILED_PAGE.equals(name)) {
|
||||||
|
setCurrent(Long.parseLong(value));
|
||||||
|
} else if (FILED_LIMIT.equals(name)) {
|
||||||
|
setSize(Long.parseLong(value));
|
||||||
|
} else if (FILED_SORT.equals(name)) {
|
||||||
|
sortValue = (needToLine ? humpToLine(value) : value);
|
||||||
|
} else if (FILED_ORDER.equals(name)) {
|
||||||
|
orderValue = value;
|
||||||
|
} else {
|
||||||
|
map.put(name, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
setPageData(map);
|
||||||
|
// 同步排序方式到MyBatisPlus中
|
||||||
|
if (sortValue != null) {
|
||||||
|
if (VALUE_ORDER_DESC.equals(orderValue)) {
|
||||||
|
setOrder(sortValue, false);
|
||||||
|
} else/* if (VALUE_ORDER_ASC.equals(orderValue))*/ {
|
||||||
|
setOrder(sortValue, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取升序排序的字段
|
||||||
|
*/
|
||||||
|
public List<String> getOrderAscs() {
|
||||||
|
List<String> ascs = new ArrayList<>();
|
||||||
|
List<OrderItem> orders = getOrders();
|
||||||
|
if (orders != null) {
|
||||||
|
for (OrderItem order : orders) {
|
||||||
|
if (order.isAsc()) ascs.add(order.getColumn());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ascs;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取降序排序的字段
|
||||||
|
*/
|
||||||
|
public List<String> getOrderDescs() {
|
||||||
|
List<String> descs = new ArrayList<>();
|
||||||
|
List<OrderItem> orders = getOrders();
|
||||||
|
if (orders != null) {
|
||||||
|
for (OrderItem order : orders) {
|
||||||
|
if (!order.isAsc()) descs.add(order.getColumn());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return descs;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 增加asc排序方式
|
||||||
|
*/
|
||||||
|
public PageParam<T> addOrderAsc(String... ascs) {
|
||||||
|
if (ascs != null) {
|
||||||
|
List<String> tAscs = getOrderAscs();
|
||||||
|
List<OrderItem> orderItems = new ArrayList<>();
|
||||||
|
for (String column : ascs) {
|
||||||
|
if (!tAscs.contains(column)) {
|
||||||
|
OrderItem orderItem = new OrderItem();
|
||||||
|
orderItem.setAsc(true);
|
||||||
|
orderItem.setColumn(column);
|
||||||
|
orderItems.add(orderItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (getOrders() == null) {
|
||||||
|
setOrders(orderItems);
|
||||||
|
} else {
|
||||||
|
getOrders().addAll(orderItems);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 增加desc排序方式
|
||||||
|
*/
|
||||||
|
public PageParam<T> addOrderDesc(String... descs) {
|
||||||
|
if (descs != null) {
|
||||||
|
List<String> tDescs = getOrderDescs();
|
||||||
|
List<OrderItem> orderItems = new ArrayList<>();
|
||||||
|
for (String column : descs) {
|
||||||
|
if (!tDescs.contains(column)) {
|
||||||
|
OrderItem orderItem = new OrderItem();
|
||||||
|
orderItem.setAsc(false);
|
||||||
|
orderItem.setColumn(column);
|
||||||
|
orderItems.add(orderItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (getOrders() == null) {
|
||||||
|
setOrders(orderItems);
|
||||||
|
} else {
|
||||||
|
getOrders().addAll(orderItems);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 移除某个排序字段
|
||||||
|
*/
|
||||||
|
public PageParam<T> removeOrder(String order, Boolean isAsc) {
|
||||||
|
List<OrderItem> orderItems = getOrders();
|
||||||
|
if (orderItems != null) {
|
||||||
|
Iterator<OrderItem> iterator = orderItems.iterator();
|
||||||
|
while (iterator.hasNext()) {
|
||||||
|
OrderItem item = iterator.next();
|
||||||
|
if (isAsc == null || isAsc == item.isAsc()) {
|
||||||
|
if (order.equals(item.getColumn())) iterator.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置排序方式
|
||||||
|
*/
|
||||||
|
public PageParam<T> setOrder(String order, boolean isAsc) {
|
||||||
|
List<OrderItem> orderItems = new ArrayList<>();
|
||||||
|
if (order != null) {
|
||||||
|
OrderItem orderItem = new OrderItem();
|
||||||
|
orderItem.setAsc(isAsc);
|
||||||
|
orderItem.setColumn(order);
|
||||||
|
orderItems.add(orderItem);
|
||||||
|
}
|
||||||
|
setOrders(orderItems);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置默认排序方式
|
||||||
|
*/
|
||||||
|
public PageParam<T> setDefaultOrder(String[] ascs, String[] descs) {
|
||||||
|
List<OrderItem> orderItems = getOrders();
|
||||||
|
if (orderItems == null || orderItems.size() == 0) {
|
||||||
|
addOrderAsc(ascs);
|
||||||
|
addOrderDesc(descs);
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 往pageData里面增加参数
|
||||||
|
*/
|
||||||
|
public PageParam<T> put(String key, Object value) {
|
||||||
|
if (pageData == null) pageData = new HashMap<>();
|
||||||
|
pageData.put(key, value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取pageData里面参数
|
||||||
|
*/
|
||||||
|
public Object get(String key) {
|
||||||
|
return pageData.get(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getString(String key) {
|
||||||
|
Object o = pageData.get(key);
|
||||||
|
if (o != null) return String.valueOf(o);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getInt(String key) {
|
||||||
|
String str = getString(key);
|
||||||
|
if (str != null) return Integer.parseInt(str);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getLong(String key) {
|
||||||
|
String str = getString(key);
|
||||||
|
if (str != null) return Long.parseLong(str);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Float getFloat(String key) {
|
||||||
|
String str = getString(key);
|
||||||
|
if (str != null) return Float.parseFloat(str);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Double getDouble(String key) {
|
||||||
|
String str = getString(key);
|
||||||
|
if (str != null) return Double.parseDouble(str);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getBoolean(String key) {
|
||||||
|
String str = getString(key);
|
||||||
|
if (str != null) return Boolean.parseBoolean(str);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构建查询条件
|
||||||
|
*
|
||||||
|
* @param excludes 不包含的参数
|
||||||
|
* @return QueryWrapper
|
||||||
|
*/
|
||||||
|
public QueryWrapper<T> getWrapper(String... excludes) {
|
||||||
|
List<String> exList = Arrays.asList(excludes);
|
||||||
|
QueryWrapper<T> queryWrapper = new QueryWrapper<T>();
|
||||||
|
for (String key : pageData.keySet()) {
|
||||||
|
if (!exList.contains(key)) buildWrapper(queryWrapper, key, getString(key));
|
||||||
|
}
|
||||||
|
return queryWrapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构建查询条件
|
||||||
|
*
|
||||||
|
* @param columns 只包含的参数
|
||||||
|
* @return QueryWrapper
|
||||||
|
*/
|
||||||
|
public QueryWrapper<T> getWrapperWith(String... columns) {
|
||||||
|
List<String> keyList = Arrays.asList(columns);
|
||||||
|
QueryWrapper<T> queryWrapper = new QueryWrapper<T>();
|
||||||
|
for (String key : pageData.keySet()) {
|
||||||
|
if (keyList.contains(key)) buildWrapper(queryWrapper, key, getString(key));
|
||||||
|
}
|
||||||
|
return queryWrapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 逐个构建QueryWrapper
|
||||||
|
*/
|
||||||
|
private void buildWrapper(QueryWrapper<T> queryWrapper, String key, String value) {
|
||||||
|
if (value == null || "deleted".equals(key)) return;
|
||||||
|
if (Arrays.asList("id", "sortNumber", "state").contains(key) || key.endsWith("Id")) {
|
||||||
|
queryWrapper.eq(needToLine ? humpToLine(key) : key, value);
|
||||||
|
} else if ("createTimeStart".equals(key)) {
|
||||||
|
queryWrapper.ge("create_time", value);
|
||||||
|
} else if ("createTimeEnd".equals(key)) {
|
||||||
|
queryWrapper.le("create_time", value);
|
||||||
|
} else {
|
||||||
|
queryWrapper.like(needToLine ? humpToLine(key) : key, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构建排序的QueryWrapper
|
||||||
|
*
|
||||||
|
* @param queryWrapper 搜索条件的wrapper
|
||||||
|
* @return QueryWrapper
|
||||||
|
*/
|
||||||
|
public QueryWrapper<T> getOrderWrapper(QueryWrapper<T> queryWrapper) {
|
||||||
|
if (queryWrapper == null) queryWrapper = new QueryWrapper<T>();
|
||||||
|
queryWrapper.orderByAsc(getOrderAscs().toArray(new String[0]));
|
||||||
|
queryWrapper.orderByDesc(getOrderDescs().toArray(new String[0]));
|
||||||
|
return queryWrapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构建包含排序的查询条件
|
||||||
|
*
|
||||||
|
* @return QueryWrapper
|
||||||
|
*/
|
||||||
|
public QueryWrapper<T> getOrderWrapper() {
|
||||||
|
return getOrderWrapper(getWrapper());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取不分页的参数,包含排序和pageData
|
||||||
|
*
|
||||||
|
* @return Map
|
||||||
|
*/
|
||||||
|
public Map<String, Object> getNoPageParam() {
|
||||||
|
Map<String, Object> map = new HashMap<>();
|
||||||
|
map.put("pageData", this.pageData);
|
||||||
|
List<OrderItem> orders = getOrders();
|
||||||
|
if (orders != null && orders.size() > 0) map.put("orders", orders);
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取查询结果中第一条数据
|
||||||
|
*/
|
||||||
|
public T getOne(List<T> records) {
|
||||||
|
return records == null || records.size() == 0 ? null : records.get(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 代码排序查询结果,实现类似SQL语句的排序效果
|
||||||
|
*/
|
||||||
|
public List<T> sortRecords(List<T> records) {
|
||||||
|
if (records == null || records.size() <= 1) return records;
|
||||||
|
List<OrderItem> orderItems = getOrders();
|
||||||
|
if (orderItems != null) {
|
||||||
|
Comparator<T> comparator = null;
|
||||||
|
for (OrderItem order : orderItems) {
|
||||||
|
if (order.getColumn() != null) {
|
||||||
|
Function keyExtractor = t -> getFieldValue(t, needToLine ? lineToHump(order.getColumn()) : order.getColumn());
|
||||||
|
if (comparator == null) {
|
||||||
|
if (order.isAsc()) {
|
||||||
|
comparator = Comparator.comparing(keyExtractor);
|
||||||
|
} else {
|
||||||
|
comparator = Comparator.comparing(keyExtractor, Comparator.reverseOrder());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (order.isAsc()) {
|
||||||
|
comparator.thenComparing(keyExtractor);
|
||||||
|
} else {
|
||||||
|
comparator.thenComparing(keyExtractor, Comparator.reverseOrder());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (comparator != null) {
|
||||||
|
return records.stream().sorted(comparator).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return records;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 驼峰转下划线
|
||||||
|
*/
|
||||||
|
public static String humpToLine(String str) {
|
||||||
|
if (str == null) return null;
|
||||||
|
Matcher matcher = HUMP_PATTERN.matcher(str);
|
||||||
|
StringBuffer sb = new StringBuffer();
|
||||||
|
while (matcher.find()) {
|
||||||
|
matcher.appendReplacement(sb, "_" + matcher.group(0).toLowerCase());
|
||||||
|
}
|
||||||
|
matcher.appendTail(sb);
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 下划线转驼峰
|
||||||
|
*/
|
||||||
|
public static String lineToHump(String str) {
|
||||||
|
if (str == null) return null;
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
String[] ss = str.split("_");
|
||||||
|
sb.append(ss[0]);
|
||||||
|
for (int i = 1; i < ss.length; i++) {
|
||||||
|
if (ss[i].length() > 0) sb.append(ss[i].substring(0, 1).toUpperCase());
|
||||||
|
if (ss[i].length() > 1) sb.append(ss[i].substring(1));
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取对象某个字段的值
|
||||||
|
*
|
||||||
|
* @param t 对象
|
||||||
|
* @param field 字段
|
||||||
|
* @return Object
|
||||||
|
*/
|
||||||
|
public static Object getFieldValue(Object t, String field) {
|
||||||
|
if (t == null || field == null) return null;
|
||||||
|
try {
|
||||||
|
Field clazzField = t.getClass().getDeclaredField(field);
|
||||||
|
clazzField.setAccessible(true);
|
||||||
|
return clazzField.get(t);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,83 @@
|
||||||
|
package com.gfwl.admin.base;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询通用返回结果
|
||||||
|
* Created by wangfan on 2017-06-10 10:10
|
||||||
|
*/
|
||||||
|
public class PageResult<T> implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
/**
|
||||||
|
* 状态码
|
||||||
|
*/
|
||||||
|
private int code = 0;
|
||||||
|
/**
|
||||||
|
* 提示信息
|
||||||
|
*/
|
||||||
|
private String msg;
|
||||||
|
/**
|
||||||
|
* 总数量
|
||||||
|
*/
|
||||||
|
private long count;
|
||||||
|
/**
|
||||||
|
* 当前页数据
|
||||||
|
*/
|
||||||
|
private List<T> data;
|
||||||
|
|
||||||
|
public PageResult() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public PageResult(List<T> rows) {
|
||||||
|
this(rows, rows == null ? 0 : rows.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
public PageResult(List<T> rows, long total) {
|
||||||
|
this.count = total;
|
||||||
|
this.data = rows;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PageResult(int code, List<T> rows, long total) {
|
||||||
|
this.code = code;
|
||||||
|
this.count = total;
|
||||||
|
this.data = rows;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCode() {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PageResult setCode(int code) {
|
||||||
|
this.code = code;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMsg() {
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PageResult setMsg(String msg) {
|
||||||
|
this.msg = msg;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getCount() {
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PageResult setCount(long count) {
|
||||||
|
this.count = count;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<T> getData() {
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PageResult setData(List<T> data) {
|
||||||
|
this.data = data;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,66 @@
|
||||||
|
package com.gfwl.admin.controller;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.gfwl.admin.base.JsonResult;
|
||||||
|
import com.gfwl.config.annotation.OperLog;
|
||||||
|
import com.gfwl.utils.aliyun.OSSClientUtil;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @Date 2020/7/22
|
||||||
|
* @Description: TODO
|
||||||
|
* @Version 1.0
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/aliyunossfile")
|
||||||
|
public class AliyunOSSFileController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private OSSClientUtil ossClientUtil;
|
||||||
|
|
||||||
|
@PostMapping("/upload")
|
||||||
|
@ApiOperation(value = "上传文件", httpMethod = "POST")
|
||||||
|
JsonResult upload(@RequestParam MultipartFile file){
|
||||||
|
try {
|
||||||
|
|
||||||
|
String uploadFolder = ossClientUtil.getAliyunConfig( ).getUploadFolder( );
|
||||||
|
String result = ossClientUtil.uploadObject2OSS(ossClientUtil.getOSSClient( ), file, uploadFolder);
|
||||||
|
|
||||||
|
return JsonResult.ok("上传成功").put("url",ossClientUtil.getAliyunConfig().getUrlPrefix() + uploadFolder + result)
|
||||||
|
.put("fileName",file.getName());
|
||||||
|
//return JsonResult.ok(ossClientUtil.getAliyunConfig().getUrlPrefix() + ossClientUtil.getAliyunConfig().getUploadFolder() + result);
|
||||||
|
}catch (Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
return JsonResult.error(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 上传文件
|
||||||
|
*/
|
||||||
|
@OperLog(value = "文件管理WangEditor", desc = "上传文件WangEditor", param = false, result = true)
|
||||||
|
@ResponseBody
|
||||||
|
@PostMapping("/uploadWangEditor")
|
||||||
|
public JSONObject uploadWangEditor(@RequestParam MultipartFile file){
|
||||||
|
|
||||||
|
String uploadFolder = ossClientUtil.getAliyunConfig( ).getUploadFolder( );
|
||||||
|
String result = ossClientUtil.uploadObject2OSS(ossClientUtil.getOSSClient( ), file, uploadFolder);
|
||||||
|
|
||||||
|
|
||||||
|
JSONArray jsonArray=new JSONArray();
|
||||||
|
jsonArray.add(ossClientUtil.getAliyunConfig().getUrlPrefix() + uploadFolder + result);
|
||||||
|
JSONObject jsonObject=new JSONObject();
|
||||||
|
jsonObject.put("data", jsonArray);
|
||||||
|
jsonObject.put("errno",0);
|
||||||
|
|
||||||
|
System.out.println(jsonObject.toJSONString());
|
||||||
|
return jsonObject;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,172 @@
|
||||||
|
package com.gfwl.admin.controller;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.gfwl.admin.base.BaseController;
|
||||||
|
import com.gfwl.admin.base.JsonResult;
|
||||||
|
import com.gfwl.admin.base.PageParam;
|
||||||
|
import com.gfwl.admin.base.PageResult;
|
||||||
|
import com.gfwl.config.annotation.OperLog;
|
||||||
|
import com.gfwl.utils.CoreUtil;
|
||||||
|
import com.gfwl.admin.entity.Dictionary;
|
||||||
|
import com.gfwl.admin.service.DictionaryService;
|
||||||
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字典管理
|
||||||
|
* Created by wangfan on 2020-03-14 11:29:03
|
||||||
|
*/
|
||||||
|
@Controller
|
||||||
|
@RequestMapping("/sys/dict")
|
||||||
|
public class DictionaryController extends BaseController {
|
||||||
|
@Autowired
|
||||||
|
private DictionaryService dictionaryService;
|
||||||
|
|
||||||
|
@RequiresPermissions("sys:dict:view")
|
||||||
|
@RequestMapping()
|
||||||
|
public String view() {
|
||||||
|
return "system/dictionary.html";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询字典
|
||||||
|
*/
|
||||||
|
@OperLog(value = "字典管理", desc = "分页查询")
|
||||||
|
@RequiresPermissions("sys:dict:list")
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/page")
|
||||||
|
public PageResult<Dictionary> page(HttpServletRequest request) {
|
||||||
|
PageParam<Dictionary> pageParam = new PageParam<>(request);
|
||||||
|
return new PageResult<>(dictionaryService.page(pageParam, pageParam.getWrapper()).getRecords(), pageParam.getTotal());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询全部字典
|
||||||
|
*/
|
||||||
|
@OperLog(value = "字典管理", desc = "查询全部")
|
||||||
|
@RequiresPermissions("sys:dict:list")
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/list")
|
||||||
|
public JsonResult list(HttpServletRequest request) {
|
||||||
|
PageParam<Dictionary> pageParam = new PageParam<>(request);
|
||||||
|
return JsonResult.ok().setData(dictionaryService.list(pageParam.getOrderWrapper()));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据id查询字典
|
||||||
|
*/
|
||||||
|
@OperLog(value = "字典管理", desc = "根据id查询")
|
||||||
|
@RequiresPermissions("sys:dict:list")
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/get")
|
||||||
|
public JsonResult get(Integer id) {
|
||||||
|
return JsonResult.ok().setData(dictionaryService.getById(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加字典
|
||||||
|
*/
|
||||||
|
@OperLog(value = "字典管理", desc = "添加", param = false, result = true)
|
||||||
|
@RequiresPermissions("sys:dict:save")
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/save")
|
||||||
|
public JsonResult save(Dictionary dictionary) {
|
||||||
|
if (dictionaryService.count(new QueryWrapper<Dictionary>().eq("dict_code", dictionary.getDictCode())) > 0) {
|
||||||
|
return JsonResult.error("字典标识已存在");
|
||||||
|
}
|
||||||
|
if (dictionaryService.count(new QueryWrapper<Dictionary>().eq("dict_name", dictionary.getDictName())) > 0) {
|
||||||
|
return JsonResult.error("字典名称已存在");
|
||||||
|
}
|
||||||
|
if (dictionaryService.save(dictionary)) {
|
||||||
|
return JsonResult.ok("添加成功");
|
||||||
|
}
|
||||||
|
return JsonResult.error("添加失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改字典
|
||||||
|
*/
|
||||||
|
@OperLog(value = "字典管理", desc = "修改", param = false, result = true)
|
||||||
|
@RequiresPermissions("sys:dict:update")
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/update")
|
||||||
|
public JsonResult update(Dictionary dictionary) {
|
||||||
|
if (dictionaryService.count(new QueryWrapper<Dictionary>().eq("dict_code", dictionary.getDictCode())
|
||||||
|
.ne("dict_id", dictionary.getDictId())) > 0) {
|
||||||
|
return JsonResult.error("字典代码已存在");
|
||||||
|
}
|
||||||
|
if (dictionaryService.count(new QueryWrapper<Dictionary>().eq("dict_name", dictionary.getDictName())
|
||||||
|
.ne("dict_id", dictionary.getDictId())) > 0) {
|
||||||
|
return JsonResult.error("字典名称已存在");
|
||||||
|
}
|
||||||
|
if (dictionaryService.updateById(dictionary)) {
|
||||||
|
return JsonResult.ok("修改成功");
|
||||||
|
}
|
||||||
|
return JsonResult.error("修改失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除字典
|
||||||
|
*/
|
||||||
|
@OperLog(value = "字典管理", desc = "删除", result = true)
|
||||||
|
@RequiresPermissions("sys:dict:remove")
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/remove")
|
||||||
|
public JsonResult remove(Integer id) {
|
||||||
|
if (dictionaryService.removeById(id)) {
|
||||||
|
return JsonResult.ok("删除成功");
|
||||||
|
}
|
||||||
|
return JsonResult.error("删除失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量添加字典
|
||||||
|
*/
|
||||||
|
@OperLog(value = "字典管理", desc = "批量添加", param = false, result = true)
|
||||||
|
@RequiresPermissions("sys:dict:save")
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/saveBatch")
|
||||||
|
public JsonResult saveBatch(@RequestBody List<Dictionary> list) {
|
||||||
|
// 对集合本身进行非空和重复校验
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append(CoreUtil.listCheckBlank(list, "dictCode", "字典标识"));
|
||||||
|
sb.append(CoreUtil.listCheckBlank(list, "dictName", "字典名称"));
|
||||||
|
sb.append(CoreUtil.listCheckRepeat(list, "dictCode", "字典标识"));
|
||||||
|
sb.append(CoreUtil.listCheckRepeat(list, "dictName", "字典名称"));
|
||||||
|
if (sb.length() != 0) return JsonResult.error(sb.toString());
|
||||||
|
// 数据库层面校验
|
||||||
|
if (dictionaryService.count(new QueryWrapper<Dictionary>().in("dict_code",
|
||||||
|
list.stream().map(Dictionary::getDictCode).collect(Collectors.toList()))) > 0) {
|
||||||
|
return JsonResult.error("字典标识已存在");
|
||||||
|
}
|
||||||
|
if (dictionaryService.count(new QueryWrapper<Dictionary>().in("dict_name",
|
||||||
|
list.stream().map(Dictionary::getDictName).collect(Collectors.toList()))) > 0) {
|
||||||
|
return JsonResult.error("字典名称已存在");
|
||||||
|
}
|
||||||
|
if (dictionaryService.saveBatch(list)) {
|
||||||
|
return JsonResult.ok("添加成功");
|
||||||
|
}
|
||||||
|
return JsonResult.error("添加失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除字典
|
||||||
|
*/
|
||||||
|
@OperLog(value = "字典管理", desc = "批量删除", result = true)
|
||||||
|
@RequiresPermissions("sys:dict:remove")
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/removeBatch")
|
||||||
|
public JsonResult removeBatch(@RequestBody List<Integer> ids) {
|
||||||
|
if (dictionaryService.removeByIds(ids)) {
|
||||||
|
return JsonResult.ok("删除成功");
|
||||||
|
}
|
||||||
|
return JsonResult.error("删除失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,160 @@
|
||||||
|
package com.gfwl.admin.controller;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.gfwl.admin.base.BaseController;
|
||||||
|
import com.gfwl.admin.base.JsonResult;
|
||||||
|
import com.gfwl.admin.base.PageParam;
|
||||||
|
import com.gfwl.admin.base.PageResult;
|
||||||
|
import com.gfwl.config.annotation.OperLog;
|
||||||
|
import com.gfwl.admin.entity.DictionaryData;
|
||||||
|
import com.gfwl.admin.service.DictionaryDataService;
|
||||||
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字典项管理
|
||||||
|
* Created by wangfan on 2020-03-14 11:29:04
|
||||||
|
*/
|
||||||
|
@Controller
|
||||||
|
@RequestMapping("/sys/dictdata")
|
||||||
|
public class DictionaryDataController extends BaseController {
|
||||||
|
@Autowired
|
||||||
|
private DictionaryDataService dictionaryDataService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询字典项
|
||||||
|
*/
|
||||||
|
@OperLog(value = "字典项管理", desc = "分页查询")
|
||||||
|
@RequiresPermissions("sys:dict:list")
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/page")
|
||||||
|
public PageResult<DictionaryData> page(HttpServletRequest request) {
|
||||||
|
PageParam<DictionaryData> pageParam = new PageParam<>(request);
|
||||||
|
return dictionaryDataService.listPage(pageParam);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询全部字典项
|
||||||
|
*/
|
||||||
|
@OperLog(value = "字典项管理", desc = "查询全部")
|
||||||
|
@RequiresPermissions("sys:dict:list")
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/list")
|
||||||
|
public JsonResult list(HttpServletRequest request) {
|
||||||
|
PageParam<DictionaryData> pageParam = new PageParam<>(request);
|
||||||
|
List<DictionaryData> records = dictionaryDataService.listAll(pageParam.getNoPageParam());
|
||||||
|
return JsonResult.ok().setData(pageParam.sortRecords(records));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据id查询字典项
|
||||||
|
*/
|
||||||
|
@OperLog(value = "字典项管理", desc = "根据id查询")
|
||||||
|
@RequiresPermissions("sys:dict:list")
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/get")
|
||||||
|
public JsonResult get(Integer id) {
|
||||||
|
PageParam<DictionaryData> pageParam = new PageParam<>();
|
||||||
|
pageParam.put("dictDataId", id);
|
||||||
|
List<DictionaryData> records = dictionaryDataService.listAll(pageParam.getNoPageParam());
|
||||||
|
return JsonResult.ok().setData(pageParam.getOne(records));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加字典项
|
||||||
|
*/
|
||||||
|
@OperLog(value = "字典项管理", desc = "添加", param = false, result = true)
|
||||||
|
@RequiresPermissions("sys:dict:save")
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/save")
|
||||||
|
public JsonResult add(DictionaryData dictionaryData) {
|
||||||
|
if (dictionaryDataService.count(new QueryWrapper<DictionaryData>()
|
||||||
|
.eq("dict_id", dictionaryData.getDictId())
|
||||||
|
.eq("dict_data_name", dictionaryData.getDictDataName())) > 0) {
|
||||||
|
return JsonResult.error("字典项名称已存在");
|
||||||
|
}
|
||||||
|
if (dictionaryDataService.count(new QueryWrapper<DictionaryData>()
|
||||||
|
.eq("dict_id", dictionaryData.getDictId())
|
||||||
|
.eq("dict_data_code", dictionaryData.getDictDataCode())) > 0) {
|
||||||
|
return JsonResult.error("字典项标识已存在");
|
||||||
|
}
|
||||||
|
if (dictionaryDataService.save(dictionaryData)) {
|
||||||
|
return JsonResult.ok("添加成功");
|
||||||
|
}
|
||||||
|
return JsonResult.error("添加失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改字典项
|
||||||
|
*/
|
||||||
|
@OperLog(value = "字典项管理", desc = "修改", param = false, result = true)
|
||||||
|
@RequiresPermissions("sys:dict:update")
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/update")
|
||||||
|
public JsonResult update(DictionaryData dictionaryData) {
|
||||||
|
if (dictionaryDataService.count(new QueryWrapper<DictionaryData>()
|
||||||
|
.eq("dict_id", dictionaryData.getDictId())
|
||||||
|
.eq("dict_data_name", dictionaryData.getDictDataName())
|
||||||
|
.ne("dict_data_id", dictionaryData.getDictDataId())) > 0) {
|
||||||
|
return JsonResult.error("字典项名称已存在");
|
||||||
|
}
|
||||||
|
if (dictionaryDataService.count(new QueryWrapper<DictionaryData>()
|
||||||
|
.eq("dict_id", dictionaryData.getDictId())
|
||||||
|
.eq("dict_data_code", dictionaryData.getDictDataCode())
|
||||||
|
.ne("dict_data_id", dictionaryData.getDictDataId())) > 0) {
|
||||||
|
return JsonResult.error("字典项标识已存在");
|
||||||
|
}
|
||||||
|
if (dictionaryDataService.updateById(dictionaryData)) {
|
||||||
|
return JsonResult.ok("修改成功");
|
||||||
|
}
|
||||||
|
return JsonResult.error("修改失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除字典项
|
||||||
|
*/
|
||||||
|
@OperLog(value = "字典项管理", desc = "删除", result = true)
|
||||||
|
@RequiresPermissions("sys:dict:remove")
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/remove")
|
||||||
|
public JsonResult remove(Integer id) {
|
||||||
|
if (dictionaryDataService.removeById(id)) {
|
||||||
|
return JsonResult.ok("删除成功");
|
||||||
|
}
|
||||||
|
return JsonResult.error("删除失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量添加字典项
|
||||||
|
*/
|
||||||
|
@OperLog(value = "字典项管理", desc = "批量添加", param = false, result = true)
|
||||||
|
@RequiresPermissions("sys:dict:save")
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/saveBatch")
|
||||||
|
public JsonResult saveBatch(@RequestBody List<DictionaryData> dictDataList) {
|
||||||
|
if (dictionaryDataService.saveBatch(dictDataList)) {
|
||||||
|
return JsonResult.ok("添加成功");
|
||||||
|
}
|
||||||
|
return JsonResult.error("添加失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除字典项
|
||||||
|
*/
|
||||||
|
@OperLog(value = "字典项管理", desc = "批量删除", result = true)
|
||||||
|
@RequiresPermissions("sys:dict:remove")
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/removeBatch")
|
||||||
|
public JsonResult removeBatch(@RequestBody List<Integer> ids) {
|
||||||
|
if (dictionaryDataService.removeByIds(ids)) {
|
||||||
|
return JsonResult.ok("删除成功");
|
||||||
|
}
|
||||||
|
return JsonResult.error("删除失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,47 @@
|
||||||
|
package com.gfwl.admin.controller;
|
||||||
|
|
||||||
|
import com.gfwl.config.annotation.OperLog;
|
||||||
|
import com.gfwl.admin.base.JsonResult;
|
||||||
|
import com.gfwl.admin.service.EmailService;
|
||||||
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
|
||||||
|
import javax.mail.MessagingException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 邮件功能
|
||||||
|
* Created by wangfan on 2020-03-21 0:37
|
||||||
|
*/
|
||||||
|
@Controller
|
||||||
|
@RequestMapping("/sys/email")
|
||||||
|
public class EmailController {
|
||||||
|
@Autowired
|
||||||
|
private EmailService emailService;
|
||||||
|
|
||||||
|
@RequiresPermissions("sys:email:view")
|
||||||
|
@RequestMapping()
|
||||||
|
public String view() {
|
||||||
|
return "system/email.html";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送邮件
|
||||||
|
*/
|
||||||
|
@OperLog(value = "邮件功能", desc = "发送邮件", result = true, param = false)
|
||||||
|
@RequiresPermissions("sys:email:view")
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/send")
|
||||||
|
public JsonResult send(String title, String html, String email) {
|
||||||
|
try {
|
||||||
|
emailService.sendFullTextEmail(title, html, new String[]{email});
|
||||||
|
return JsonResult.ok("发送成功");
|
||||||
|
} catch (MessagingException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return JsonResult.error("发送失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,68 @@
|
||||||
|
package com.gfwl.admin.controller;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.gfwl.admin.base.JsonResult;
|
||||||
|
import com.gfwl.config.annotation.OperLog;
|
||||||
|
import com.gfwl.config.consts.Global;
|
||||||
|
import com.gfwl.utils.FileUploadUtil;
|
||||||
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件服务器
|
||||||
|
* Created by wangfan on 2018-12-24 16:10
|
||||||
|
*/
|
||||||
|
@Controller
|
||||||
|
@RequestMapping("/file")
|
||||||
|
public class FileController {
|
||||||
|
|
||||||
|
@RequiresPermissions("sys:file:view")
|
||||||
|
@RequestMapping("/manage")
|
||||||
|
public String view() {
|
||||||
|
return "system/file.html";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 上传文件
|
||||||
|
*/
|
||||||
|
@OperLog(value = "文件管理", desc = "上传文件", param = false, result = true)
|
||||||
|
@ResponseBody
|
||||||
|
@PostMapping("/upload")
|
||||||
|
public JsonResult upload(@RequestParam MultipartFile file) {
|
||||||
|
return FileUploadUtil.upload(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 上传文件
|
||||||
|
*/
|
||||||
|
@OperLog(value = "文件管理Plus", desc = "上传文件plus", param = false, result = true)
|
||||||
|
@ResponseBody
|
||||||
|
@PostMapping("/uploadplus")
|
||||||
|
public JSONObject uploadPlus(@RequestParam("imgFile") MultipartFile file){
|
||||||
|
JsonResult jsonResult=FileUploadUtil.upload(file);
|
||||||
|
|
||||||
|
JSONObject jsonObject=new JSONObject();
|
||||||
|
jsonObject.put("url", Global.base_img_url+jsonResult.get("url"));
|
||||||
|
jsonObject.put("error",jsonResult.get("code"));
|
||||||
|
|
||||||
|
System.out.println(jsonObject.toJSONString());
|
||||||
|
return jsonObject;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 上传base64文件
|
||||||
|
*/
|
||||||
|
@OperLog(value = "文件管理", desc = "上传base64文件", param = false, result = true)
|
||||||
|
@ResponseBody
|
||||||
|
@PostMapping("/upload/base64")
|
||||||
|
public JsonResult uploadBase64(String base64) {
|
||||||
|
return FileUploadUtil.upload(base64);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,75 @@
|
||||||
|
package com.gfwl.admin.controller;
|
||||||
|
|
||||||
|
import com.gfwl.config.annotation.OperLog;
|
||||||
|
import com.gfwl.admin.base.BaseController;
|
||||||
|
import com.gfwl.admin.base.JsonResult;
|
||||||
|
import com.gfwl.admin.base.PageParam;
|
||||||
|
import com.gfwl.admin.base.PageResult;
|
||||||
|
import com.gfwl.admin.entity.LoginRecord;
|
||||||
|
import com.gfwl.admin.service.LoginRecordService;
|
||||||
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 登录日志
|
||||||
|
* Created by wangfan on 2018-12-24 16:10
|
||||||
|
*/
|
||||||
|
@Controller
|
||||||
|
@RequestMapping("/sys/loginRecord")
|
||||||
|
public class LoginRecordController extends BaseController {
|
||||||
|
@Autowired
|
||||||
|
private LoginRecordService loginRecordService;
|
||||||
|
|
||||||
|
@RequiresPermissions("sys:login_record:view")
|
||||||
|
@RequestMapping()
|
||||||
|
public String view() {
|
||||||
|
return "system/login-record.html";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询登录日志
|
||||||
|
*/
|
||||||
|
@OperLog(value = "登录日志", desc = "分页查询")
|
||||||
|
@RequiresPermissions("sys:login_record:view")
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/page")
|
||||||
|
public PageResult<LoginRecord> page(HttpServletRequest request) {
|
||||||
|
PageParam<LoginRecord> pageParam = new PageParam<>(request);
|
||||||
|
pageParam.setDefaultOrder(null, new String[]{"create_time"});
|
||||||
|
return loginRecordService.listPage(pageParam);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询全部登录日志
|
||||||
|
*/
|
||||||
|
@OperLog(value = "登录日志", desc = "查询全部")
|
||||||
|
@RequiresPermissions("sys:login_record:view")
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/list")
|
||||||
|
public JsonResult list(HttpServletRequest request) {
|
||||||
|
PageParam<LoginRecord> pageParam = new PageParam<>(request);
|
||||||
|
List<LoginRecord> records = loginRecordService.listAll(pageParam.getNoPageParam());
|
||||||
|
return JsonResult.ok().setData(pageParam.sortRecords(records));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据id查询登录日志
|
||||||
|
*/
|
||||||
|
@OperLog(value = "登录日志", desc = "根据id查询")
|
||||||
|
@RequiresPermissions("sys:login_record:view")
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/get")
|
||||||
|
public JsonResult get(Integer id) {
|
||||||
|
PageParam<LoginRecord> pageParam = new PageParam<>();
|
||||||
|
pageParam.put("id", id);
|
||||||
|
List<LoginRecord> records = loginRecordService.listAll(pageParam.getNoPageParam());
|
||||||
|
return JsonResult.ok().setData(pageParam.getOne(records));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,125 @@
|
||||||
|
package com.gfwl.admin.controller;
|
||||||
|
|
||||||
|
import com.gfwl.admin.base.BaseController;
|
||||||
|
import com.gfwl.admin.base.JsonResult;
|
||||||
|
import com.gfwl.admin.entity.LoginRecord;
|
||||||
|
import com.gfwl.admin.entity.Menu;
|
||||||
|
import com.gfwl.admin.service.LoginRecordService;
|
||||||
|
import com.gfwl.admin.service.MenuService;
|
||||||
|
import com.wf.captcha.utils.CaptchaUtil;
|
||||||
|
import org.apache.shiro.SecurityUtils;
|
||||||
|
import org.apache.shiro.authc.*;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.web.servlet.error.ErrorController;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.ui.Model;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.web.servlet.ModelAndView;
|
||||||
|
import org.springframework.web.servlet.view.RedirectView;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 首页、登录、验证码等
|
||||||
|
* Created by wangfan on 2018-12-24 16:10
|
||||||
|
*/
|
||||||
|
@Controller
|
||||||
|
public class MainController extends BaseController implements ErrorController {
|
||||||
|
@Autowired
|
||||||
|
private MenuService menuService;
|
||||||
|
@Autowired
|
||||||
|
private LoginRecordService loginRecordService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户登录
|
||||||
|
*/
|
||||||
|
@ResponseBody
|
||||||
|
@PostMapping("/login")
|
||||||
|
public JsonResult login(String username, String password, String code, Boolean remember, HttpServletRequest request) {
|
||||||
|
if (username == null || username.trim( ).isEmpty( )) return JsonResult.error("请输入账号");
|
||||||
|
if (!CaptchaUtil.ver(code, request)) {
|
||||||
|
loginRecordService.saveAsync(username, LoginRecord.TYPE_ERROR, "验证码错误", request);
|
||||||
|
return JsonResult.error("验证码不正确");
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
if (remember == null) remember = false;
|
||||||
|
SecurityUtils.getSubject( ).login(new UsernamePasswordToken(username, password, remember));
|
||||||
|
loginRecordService.saveAsync(username, request);
|
||||||
|
return JsonResult.ok("登录成功");
|
||||||
|
} catch (IncorrectCredentialsException ice) {
|
||||||
|
loginRecordService.saveAsync(username, LoginRecord.TYPE_ERROR, "密码错误", request);
|
||||||
|
return JsonResult.error("密码错误");
|
||||||
|
} catch (UnknownAccountException uae) {
|
||||||
|
loginRecordService.saveAsync(username, LoginRecord.TYPE_ERROR, "账号不存在", request);
|
||||||
|
return JsonResult.error("账号不存在");
|
||||||
|
} catch (LockedAccountException e) {
|
||||||
|
loginRecordService.saveAsync(username, LoginRecord.TYPE_ERROR, "账号被锁定", request);
|
||||||
|
return JsonResult.error("账号被锁定");
|
||||||
|
} catch (ExcessiveAttemptsException eae) {
|
||||||
|
loginRecordService.saveAsync(username, LoginRecord.TYPE_ERROR, "操作频繁", request);
|
||||||
|
return JsonResult.error("操作频繁,请稍后再试");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 登录页
|
||||||
|
*/
|
||||||
|
@GetMapping("/login")
|
||||||
|
public ModelAndView login() {
|
||||||
|
if (getLoginUser( ) != null) {
|
||||||
|
ModelAndView modelAndView = new ModelAndView(new RedirectView("index"));
|
||||||
|
return modelAndView;
|
||||||
|
}
|
||||||
|
ModelAndView modelAndView = new ModelAndView( );
|
||||||
|
modelAndView.setViewName("login.html");
|
||||||
|
return modelAndView;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主页
|
||||||
|
*/
|
||||||
|
@RequestMapping({"/", "/index"})
|
||||||
|
public String index(Model model) {
|
||||||
|
// 左侧菜单
|
||||||
|
List<Menu> menus = menuService.getUserMenu(getLoginUserId( ), Menu.TYPE_MENU);
|
||||||
|
model.addAttribute("menus", menuService.toMenuTree(menus, 0));
|
||||||
|
return "index.html";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 图形验证码
|
||||||
|
*/
|
||||||
|
@RequestMapping("/assets/captcha")
|
||||||
|
public void captcha(HttpServletRequest request, HttpServletResponse response) {
|
||||||
|
try {
|
||||||
|
CaptchaUtil.out(5, request, response);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace( );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主页弹窗页面
|
||||||
|
*/
|
||||||
|
@RequestMapping("/tpl/{name}")
|
||||||
|
public String tpl(@PathVariable("name") String name) {
|
||||||
|
return "index/" + name + ".html";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 错误页
|
||||||
|
*/
|
||||||
|
@RequestMapping("/error")
|
||||||
|
public String error() {
|
||||||
|
return "error/404.html";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getErrorPath() {
|
||||||
|
return "/error";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,152 @@
|
||||||
|
package com.gfwl.admin.controller;
|
||||||
|
|
||||||
|
import com.gfwl.admin.base.*;
|
||||||
|
import com.gfwl.config.annotation.OperLog;
|
||||||
|
import com.gfwl.admin.entity.Menu;
|
||||||
|
import com.gfwl.admin.service.MenuService;
|
||||||
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 菜单管理
|
||||||
|
* Created by wangfan on 2018-12-24 16:10
|
||||||
|
*/
|
||||||
|
@Controller
|
||||||
|
@RequestMapping("/sys/menu")
|
||||||
|
public class MenuController extends BaseController {
|
||||||
|
@Autowired
|
||||||
|
private MenuService menuService;
|
||||||
|
|
||||||
|
@RequiresPermissions("sys:menu:view")
|
||||||
|
@RequestMapping()
|
||||||
|
public String view() {
|
||||||
|
return "system/menu.html";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询菜单
|
||||||
|
*/
|
||||||
|
@OperLog(value = "菜单管理", desc = "分页查询")
|
||||||
|
@RequiresPermissions("sys:menu:list")
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/page")
|
||||||
|
public PageResult<Menu> page(HttpServletRequest request) {
|
||||||
|
PageParam<Menu> pageParam = new PageParam<>(request);
|
||||||
|
pageParam.setDefaultOrder(new String[]{"sort_number"}, null);
|
||||||
|
return menuService.listPage(pageParam);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询全部菜单
|
||||||
|
*/
|
||||||
|
@OperLog(value = "菜单管理", desc = "查询全部")
|
||||||
|
@RequiresPermissions("sys:menu:list")
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/list")
|
||||||
|
public JsonResult list(HttpServletRequest request) {
|
||||||
|
PageParam<Menu> pageParam = new PageParam<>(request);
|
||||||
|
pageParam.setDefaultOrder(new String[]{"sort_number"}, null);
|
||||||
|
return JsonResult.ok().setData(menuService.list(pageParam.getOrderWrapper()));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据id查询菜单
|
||||||
|
*/
|
||||||
|
@OperLog(value = "菜单管理", desc = "根据id查询")
|
||||||
|
@RequiresPermissions("sys:menu:list")
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/get")
|
||||||
|
public JsonResult get(Integer id) {
|
||||||
|
return JsonResult.ok().setData(menuService.getById(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加菜单
|
||||||
|
*/
|
||||||
|
@OperLog(value = "菜单管理", desc = "添加", param = false, result = true)
|
||||||
|
@RequiresPermissions("sys:menu:save")
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/save")
|
||||||
|
public JsonResult save(Menu menu) {
|
||||||
|
if (menuService.save(menu)) {
|
||||||
|
return JsonResult.ok("添加成功");
|
||||||
|
}
|
||||||
|
return JsonResult.error("添加失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改菜单
|
||||||
|
*/
|
||||||
|
@OperLog(value = "菜单管理", desc = "修改", param = false, result = true)
|
||||||
|
@RequiresPermissions("sys:menu:update")
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/update")
|
||||||
|
public JsonResult update(Menu menu) {
|
||||||
|
if (menuService.updateById(menu)) {
|
||||||
|
return JsonResult.ok("修改成功");
|
||||||
|
}
|
||||||
|
return JsonResult.error("修改失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除菜单
|
||||||
|
*/
|
||||||
|
@OperLog(value = "菜单管理", desc = "删除", result = true)
|
||||||
|
@RequiresPermissions("sys:menu:remove")
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/remove")
|
||||||
|
public JsonResult remove(Integer id) {
|
||||||
|
if (menuService.removeById(id)) {
|
||||||
|
return JsonResult.ok("删除成功");
|
||||||
|
}
|
||||||
|
return JsonResult.error("删除失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量添加菜单
|
||||||
|
*/
|
||||||
|
@OperLog(value = "菜单管理", desc = "批量添加", param = false, result = true)
|
||||||
|
@RequiresPermissions("sys:menu:save")
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/saveBatch")
|
||||||
|
public JsonResult saveBatch(@RequestBody List<Menu> menuList) {
|
||||||
|
if (menuService.saveBatch(menuList)) {
|
||||||
|
return JsonResult.ok("添加成功");
|
||||||
|
}
|
||||||
|
return JsonResult.error("添加失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量修改菜单
|
||||||
|
*/
|
||||||
|
@OperLog(value = "菜单管理", desc = "批量修改", result = true)
|
||||||
|
@RequiresPermissions("sys:menu:update")
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/updateBatch")
|
||||||
|
public JsonResult updateBatch(@RequestBody BatchParam<Menu> batchParam) {
|
||||||
|
if (batchParam.update(menuService, "menu_id")) {
|
||||||
|
return JsonResult.ok("修改成功");
|
||||||
|
}
|
||||||
|
return JsonResult.error("修改失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除菜单
|
||||||
|
*/
|
||||||
|
@OperLog(value = "菜单管理", desc = "批量删除", result = true)
|
||||||
|
@RequiresPermissions("sys:menu:remove")
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/removeBatch")
|
||||||
|
public JsonResult removeBatch(@RequestBody List<Integer> ids) {
|
||||||
|
if (menuService.removeByIds(ids)) {
|
||||||
|
return JsonResult.ok("删除成功");
|
||||||
|
}
|
||||||
|
return JsonResult.error("删除失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,75 @@
|
||||||
|
package com.gfwl.admin.controller;
|
||||||
|
|
||||||
|
import com.gfwl.config.annotation.OperLog;
|
||||||
|
import com.gfwl.admin.base.BaseController;
|
||||||
|
import com.gfwl.admin.base.JsonResult;
|
||||||
|
import com.gfwl.admin.base.PageParam;
|
||||||
|
import com.gfwl.admin.base.PageResult;
|
||||||
|
import com.gfwl.admin.entity.OperRecord;
|
||||||
|
import com.gfwl.admin.service.OperRecordService;
|
||||||
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 操作日志
|
||||||
|
* Created by wangfan on 2018-12-24 16:10
|
||||||
|
*/
|
||||||
|
@Controller
|
||||||
|
@RequestMapping("/sys/operRecord")
|
||||||
|
public class OperRecordController extends BaseController {
|
||||||
|
@Autowired
|
||||||
|
private OperRecordService operLogService;
|
||||||
|
|
||||||
|
@RequiresPermissions("sys:oper_record:view")
|
||||||
|
@RequestMapping()
|
||||||
|
public String view() {
|
||||||
|
return "system/oper-record.html";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询操作日志
|
||||||
|
*/
|
||||||
|
@OperLog(value = "操作日志", desc = "分页查询")
|
||||||
|
@RequiresPermissions("sys:oper_record:view")
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/page")
|
||||||
|
public PageResult<OperRecord> page(HttpServletRequest request) {
|
||||||
|
PageParam<OperRecord> pageParam = new PageParam<>(request);
|
||||||
|
pageParam.setDefaultOrder(null, new String[]{"create_time"});
|
||||||
|
return operLogService.listPage(pageParam);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询全部操作日志
|
||||||
|
*/
|
||||||
|
@OperLog(value = "操作日志", desc = "查询全部")
|
||||||
|
@RequiresPermissions("sys:oper_record:view")
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/list")
|
||||||
|
public JsonResult list(HttpServletRequest request) {
|
||||||
|
PageParam<OperRecord> pageParam = new PageParam<>(request);
|
||||||
|
List<OperRecord> records = operLogService.listAll(pageParam.getNoPageParam());
|
||||||
|
return JsonResult.ok().setData(pageParam.sortRecords(records));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据id查询操作日志
|
||||||
|
*/
|
||||||
|
@OperLog(value = "操作日志", desc = "根据id查询")
|
||||||
|
@RequiresPermissions("sys:oper_record:view")
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/get")
|
||||||
|
public JsonResult get(Integer id) {
|
||||||
|
PageParam<OperRecord> pageParam = new PageParam<>();
|
||||||
|
pageParam.put("id", id);
|
||||||
|
List<OperRecord> records = operLogService.listAll(pageParam.getNoPageParam());
|
||||||
|
return JsonResult.ok().setData(pageParam.getOne(records));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,200 @@
|
||||||
|
package com.gfwl.admin.controller;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.gfwl.admin.base.*;
|
||||||
|
import com.gfwl.config.annotation.OperLog;
|
||||||
|
import com.gfwl.admin.entity.Organization;
|
||||||
|
import com.gfwl.admin.service.DictionaryDataService;
|
||||||
|
import com.gfwl.admin.service.OrganizationService;
|
||||||
|
import com.gfwl.admin.service.RoleService;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.ui.Model;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 组织机构管理
|
||||||
|
* Created by AutoGenerator on 2020-03-14 11:29:04
|
||||||
|
*/
|
||||||
|
@Controller
|
||||||
|
@RequestMapping("/sys/organization")
|
||||||
|
public class OrganizationController extends BaseController {
|
||||||
|
@Autowired
|
||||||
|
private OrganizationService organizationService;
|
||||||
|
@Autowired
|
||||||
|
private DictionaryDataService dictionaryDataService;
|
||||||
|
@Autowired
|
||||||
|
private RoleService roleService;
|
||||||
|
|
||||||
|
@RequiresPermissions("sys:org:view")
|
||||||
|
@RequestMapping()
|
||||||
|
public String view(Model model) {
|
||||||
|
model.addAttribute("sexList", dictionaryDataService.listByDictCode("sex"));
|
||||||
|
model.addAttribute("organizationTypeList", dictionaryDataService.listByDictCode("organization_type"));
|
||||||
|
model.addAttribute("rolesJson", JSON.toJSONString(roleService.list( )));
|
||||||
|
return "system/organization.html";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询组织机构
|
||||||
|
*/
|
||||||
|
@OperLog(value = "机构管理", desc = "分页查询")
|
||||||
|
@RequiresPermissions("sys:org:list")
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/page")
|
||||||
|
public PageResult<Organization> page(HttpServletRequest request) {
|
||||||
|
PageParam<Organization> pageParam = new PageParam<>(request);
|
||||||
|
return organizationService.listPage(pageParam);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询全部组织机构
|
||||||
|
*/
|
||||||
|
@OperLog(value = "机构管理", desc = "查询全部")
|
||||||
|
@RequiresPermissions("sys:org:list")
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/list")
|
||||||
|
public JsonResult list(HttpServletRequest request) {
|
||||||
|
PageParam<Organization> pageParam = new PageParam<>(request);
|
||||||
|
List<Organization> records = organizationService.listAll(pageParam.getNoPageParam( ));
|
||||||
|
return JsonResult.ok( ).setData(pageParam.sortRecords(records));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据id查询组织机构
|
||||||
|
*/
|
||||||
|
@OperLog(value = "机构管理", desc = "根据id查询")
|
||||||
|
@RequiresPermissions("sys:org:list")
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/get")
|
||||||
|
public JsonResult get(Integer id) {
|
||||||
|
PageParam<Organization> pageParam = new PageParam<>( );
|
||||||
|
pageParam.put("organizationId", id);
|
||||||
|
List<Organization> records = organizationService.listAll(pageParam.getNoPageParam( ));
|
||||||
|
return JsonResult.ok( ).setData(pageParam.getOne(records));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加组织机构
|
||||||
|
*/
|
||||||
|
@OperLog(value = "机构管理", desc = "添加", param = false, result = true)
|
||||||
|
@RequiresPermissions("sys:org:save")
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/save")
|
||||||
|
public JsonResult add(Organization organization) {
|
||||||
|
if (StringUtils.isEmpty(organization.getParentId( ))) {
|
||||||
|
organization.setParentId(String.valueOf(10000));
|
||||||
|
}
|
||||||
|
|
||||||
|
//计算ID
|
||||||
|
Integer parentNumber = organization.getParentId( ).length() / 5;
|
||||||
|
Integer number=organizationService.getByParentId((parentNumber+1)*5,organization.getParentId( ));
|
||||||
|
Integer organizationId=10000+number;
|
||||||
|
String organizationStr=organization.getParentId()+organizationId;
|
||||||
|
|
||||||
|
organization.setOrganizationId(organizationStr);
|
||||||
|
|
||||||
|
if (organizationService.count(new QueryWrapper<Organization>( )
|
||||||
|
.eq("organization_name", organization.getOrganizationName( ))
|
||||||
|
.eq("parent_id", organization.getParentId( ))) > 0) {
|
||||||
|
return JsonResult.error("机构名称已存在");
|
||||||
|
}
|
||||||
|
if (organizationService.save(organization)) {
|
||||||
|
return JsonResult.ok("添加成功");
|
||||||
|
}
|
||||||
|
return JsonResult.error("添加失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改组织机构
|
||||||
|
*/
|
||||||
|
@OperLog(value = "机构管理", desc = "修改", param = false, result = true)
|
||||||
|
@RequiresPermissions("sys:org:update")
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/update")
|
||||||
|
public JsonResult update(Organization organization) {
|
||||||
|
if (organizationService.count(new QueryWrapper<Organization>( )
|
||||||
|
.eq("organization_name", organization.getOrganizationName( ))
|
||||||
|
.eq("parent_id", organization.getParentId( ))
|
||||||
|
.ne("organization_id", organization.getOrganizationId( ))) > 0) {
|
||||||
|
return JsonResult.error("机构名称已存在");
|
||||||
|
}
|
||||||
|
|
||||||
|
Organization one = organizationService.getOne(new QueryWrapper<Organization>( ).eq("organization_id", organization.getOrganizationId( )));
|
||||||
|
if(one==null){
|
||||||
|
return JsonResult.error("修改失败");
|
||||||
|
}
|
||||||
|
organization.setId(one.getId());
|
||||||
|
if (organizationService.updateById(organization)) {
|
||||||
|
return JsonResult.ok("修改成功");
|
||||||
|
}
|
||||||
|
return JsonResult.error("修改失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除组织机构
|
||||||
|
*/
|
||||||
|
@OperLog(value = "机构管理", desc = "删除", result = true)
|
||||||
|
@RequiresPermissions("sys:org:remove")
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/remove")
|
||||||
|
public JsonResult remove(Integer id) {
|
||||||
|
if (organizationService.removeById(id)) {
|
||||||
|
return JsonResult.ok("删除成功");
|
||||||
|
}
|
||||||
|
return JsonResult.error("删除失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量添加组织机构
|
||||||
|
*/
|
||||||
|
@OperLog(value = "机构管理", desc = "批量添加", param = false, result = true)
|
||||||
|
@RequiresPermissions("sys:org:save")
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/saveBatch")
|
||||||
|
public JsonResult saveBatch(@RequestBody List<Organization> organizationList) {
|
||||||
|
if (organizationService.saveBatch(organizationList)) {
|
||||||
|
return JsonResult.ok("添加成功");
|
||||||
|
}
|
||||||
|
return JsonResult.error("添加失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量修改组织机构
|
||||||
|
*/
|
||||||
|
@OperLog(value = "机构管理", desc = "批量修改", result = true)
|
||||||
|
@RequiresPermissions("sys:org:update")
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/updateBatch")
|
||||||
|
public JsonResult updateBatch(@RequestBody BatchParam<Organization> batchParam) {
|
||||||
|
if (batchParam.update(organizationService, "organization_id")) {
|
||||||
|
return JsonResult.ok("修改成功");
|
||||||
|
}
|
||||||
|
return JsonResult.error("修改失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除组织机构
|
||||||
|
*/
|
||||||
|
@OperLog(value = "机构管理", desc = "批量删除", result = true)
|
||||||
|
@RequiresPermissions("sys:org:remove")
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/removeBatch")
|
||||||
|
public JsonResult removeBatch(@RequestBody List<Integer> ids) {
|
||||||
|
if (organizationService.removeByIds(ids)) {
|
||||||
|
return JsonResult.ok("删除成功");
|
||||||
|
}
|
||||||
|
return JsonResult.error("删除失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,172 @@
|
||||||
|
package com.gfwl.admin.controller;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.gfwl.admin.base.BaseController;
|
||||||
|
import com.gfwl.admin.base.JsonResult;
|
||||||
|
import com.gfwl.admin.base.PageParam;
|
||||||
|
import com.gfwl.admin.base.PageResult;
|
||||||
|
import com.gfwl.config.annotation.OperLog;
|
||||||
|
import com.gfwl.utils.CoreUtil;
|
||||||
|
import com.gfwl.admin.entity.Role;
|
||||||
|
import com.gfwl.admin.service.RoleService;
|
||||||
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 角色管理
|
||||||
|
* Created by wangfan on 2018-12-24 16:10
|
||||||
|
*/
|
||||||
|
@Controller
|
||||||
|
@RequestMapping("/sys/role")
|
||||||
|
public class RoleController extends BaseController {
|
||||||
|
@Autowired
|
||||||
|
private RoleService roleService;
|
||||||
|
|
||||||
|
@RequiresPermissions("sys:role:view")
|
||||||
|
@RequestMapping()
|
||||||
|
public String view() {
|
||||||
|
return "system/role.html";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询角色
|
||||||
|
*/
|
||||||
|
@OperLog(value = "角色管理", desc = "分页查询")
|
||||||
|
@RequiresPermissions("sys:role:list")
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/page")
|
||||||
|
public PageResult<Role> page(HttpServletRequest request) {
|
||||||
|
PageParam<Role> pageParam = new PageParam<>(request);
|
||||||
|
return new PageResult<>(roleService.page(pageParam, pageParam.getWrapper()).getRecords(), pageParam.getTotal());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询全部角色
|
||||||
|
*/
|
||||||
|
@OperLog(value = "角色管理", desc = "查询全部")
|
||||||
|
@RequiresPermissions("sys:role:list")
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/list")
|
||||||
|
public JsonResult list(HttpServletRequest request) {
|
||||||
|
PageParam<Role> pageParam = new PageParam<>(request);
|
||||||
|
return JsonResult.ok().setData(roleService.list(pageParam.getOrderWrapper()));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据id查询角色
|
||||||
|
*/
|
||||||
|
@OperLog(value = "角色管理", desc = "根据id查询")
|
||||||
|
@RequiresPermissions("sys:role:list")
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/get")
|
||||||
|
public JsonResult get(Integer id) {
|
||||||
|
return JsonResult.ok().setData(roleService.getById(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加角色
|
||||||
|
*/
|
||||||
|
@OperLog(value = "角色管理", desc = "添加", param = false, result = true)
|
||||||
|
@RequiresPermissions("sys:role:save")
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/save")
|
||||||
|
public JsonResult save(Role role) {
|
||||||
|
if (roleService.count(new QueryWrapper<Role>().eq("role_code", role.getRoleCode())) > 0) {
|
||||||
|
return JsonResult.error("角色标识已存在");
|
||||||
|
}
|
||||||
|
if (roleService.count(new QueryWrapper<Role>().eq("role_name", role.getRoleName())) > 0) {
|
||||||
|
return JsonResult.error("角色名称已存在");
|
||||||
|
}
|
||||||
|
if (roleService.save(role)) {
|
||||||
|
return JsonResult.ok("添加成功");
|
||||||
|
}
|
||||||
|
return JsonResult.error("添加失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改角色
|
||||||
|
*/
|
||||||
|
@OperLog(value = "角色管理", desc = "修改", param = false, result = true)
|
||||||
|
@RequiresPermissions("sys:role:update")
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/update")
|
||||||
|
public JsonResult update(Role role) {
|
||||||
|
if (roleService.count(new QueryWrapper<Role>().eq("role_code", role.getRoleCode())
|
||||||
|
.ne("role_id", role.getRoleId())) > 0) {
|
||||||
|
return JsonResult.error("角色标识已存在");
|
||||||
|
}
|
||||||
|
if (roleService.count(new QueryWrapper<Role>().eq("role_name", role.getRoleName())
|
||||||
|
.ne("role_id", role.getRoleId())) > 0) {
|
||||||
|
return JsonResult.error("角色名称已存在");
|
||||||
|
}
|
||||||
|
if (roleService.updateById(role)) {
|
||||||
|
return JsonResult.ok("修改成功");
|
||||||
|
}
|
||||||
|
return JsonResult.error("修改失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除角色
|
||||||
|
*/
|
||||||
|
@OperLog(value = "角色管理", desc = "删除", result = true)
|
||||||
|
@RequiresPermissions("sys:role:remove")
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/remove")
|
||||||
|
public JsonResult remove(Integer id) {
|
||||||
|
if (roleService.removeById(id)) {
|
||||||
|
return JsonResult.ok("删除成功");
|
||||||
|
}
|
||||||
|
return JsonResult.error("删除失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量添加角色
|
||||||
|
*/
|
||||||
|
@OperLog(value = "角色管理", desc = "批量添加", param = false, result = true)
|
||||||
|
@RequiresPermissions("sys:role:save")
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/saveBatch")
|
||||||
|
public JsonResult saveBatch(@RequestBody List<Role> list) {
|
||||||
|
// 对集合本身进行非空和重复校验
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append(CoreUtil.listCheckBlank(list, "roleCode", "角色标识"));
|
||||||
|
sb.append(CoreUtil.listCheckBlank(list, "roleName", "角色名称"));
|
||||||
|
sb.append(CoreUtil.listCheckRepeat(list, "roleCode", "角色标识"));
|
||||||
|
sb.append(CoreUtil.listCheckRepeat(list, "roleName", "角色名称"));
|
||||||
|
if (sb.length() != 0) return JsonResult.error(sb.toString());
|
||||||
|
// 数据库层面校验
|
||||||
|
if (roleService.count(new QueryWrapper<Role>().in("role_code",
|
||||||
|
list.stream().map(Role::getRoleCode).collect(Collectors.toList()))) > 0) {
|
||||||
|
return JsonResult.error("角色标识已存在");
|
||||||
|
}
|
||||||
|
if (roleService.count(new QueryWrapper<Role>().in("role_name",
|
||||||
|
list.stream().map(Role::getRoleName).collect(Collectors.toList()))) > 0) {
|
||||||
|
return JsonResult.error("角色名称已存在");
|
||||||
|
}
|
||||||
|
if (roleService.saveBatch(list)) {
|
||||||
|
return JsonResult.ok("添加成功");
|
||||||
|
}
|
||||||
|
return JsonResult.error("添加失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除角色
|
||||||
|
*/
|
||||||
|
@OperLog(value = "角色管理", desc = "批量删除", result = true)
|
||||||
|
@RequiresPermissions("sys:role:remove")
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/removeBatch")
|
||||||
|
public JsonResult removeBatch(@RequestBody List<Integer> ids) {
|
||||||
|
if (roleService.removeByIds(ids)) {
|
||||||
|
return JsonResult.ok("删除成功");
|
||||||
|
}
|
||||||
|
return JsonResult.error("删除失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,116 @@
|
||||||
|
package com.gfwl.admin.controller;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||||
|
import com.gfwl.config.annotation.OperLog;
|
||||||
|
import com.gfwl.admin.base.BaseController;
|
||||||
|
import com.gfwl.admin.base.JsonResult;
|
||||||
|
import com.gfwl.config.exception.BusinessException;
|
||||||
|
import com.gfwl.admin.entity.Menu;
|
||||||
|
import com.gfwl.admin.entity.RoleMenu;
|
||||||
|
import com.gfwl.admin.service.MenuService;
|
||||||
|
import com.gfwl.admin.service.RoleMenuService;
|
||||||
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 角色菜单管理
|
||||||
|
* Created by wangfan on 2018-12-24 16:10
|
||||||
|
*/
|
||||||
|
@Controller
|
||||||
|
@RequestMapping("/sys/role/menu")
|
||||||
|
public class RoleMenuController extends BaseController {
|
||||||
|
@Autowired
|
||||||
|
private RoleMenuService roleMenuService;
|
||||||
|
@Autowired
|
||||||
|
private MenuService menuService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询角色菜单
|
||||||
|
*/
|
||||||
|
@OperLog(value = "角色管理", desc = "查询角色菜单")
|
||||||
|
@RequiresPermissions("sys:role:list")
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/list")
|
||||||
|
public JsonResult list(Integer roleId) {
|
||||||
|
List<Menu> menus = menuService.list(new QueryWrapper<Menu>().orderByAsc("sort_number"));
|
||||||
|
List<RoleMenu> roleMenus = roleMenuService.list(new QueryWrapper<RoleMenu>().eq("role_id", roleId));
|
||||||
|
for (Menu menu : menus) {
|
||||||
|
menu.setOpen(true);
|
||||||
|
menu.setChecked(false);
|
||||||
|
for (RoleMenu roleMenu : roleMenus) {
|
||||||
|
if (menu.getMenuId().equals(roleMenu.getMenuId())) {
|
||||||
|
menu.setChecked(true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return JsonResult.ok().setData(menus);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加角色菜单
|
||||||
|
*/
|
||||||
|
@OperLog(value = "角色管理", desc = "添加角色菜单")
|
||||||
|
@RequiresPermissions("sys:role:update")
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/save")
|
||||||
|
public JsonResult addRoleAuth(Integer roleId, Integer menuId) {
|
||||||
|
RoleMenu roleMenu = new RoleMenu();
|
||||||
|
roleMenu.setRoleId(roleId);
|
||||||
|
roleMenu.setMenuId(menuId);
|
||||||
|
if (roleMenuService.save(roleMenu)) {
|
||||||
|
return JsonResult.ok();
|
||||||
|
}
|
||||||
|
return JsonResult.error();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 移除角色菜单
|
||||||
|
*/
|
||||||
|
@OperLog(value = "角色管理", desc = "移除角色菜单")
|
||||||
|
@RequiresPermissions("sys:role:update")
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/delete")
|
||||||
|
public JsonResult removeRoleAuth(Integer roleId, Integer menuId) {
|
||||||
|
if (roleMenuService.remove(new UpdateWrapper<RoleMenu>()
|
||||||
|
.eq("role_id", roleId).eq("menuId", menuId))) {
|
||||||
|
return JsonResult.ok();
|
||||||
|
}
|
||||||
|
return JsonResult.error();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量修改角色菜单
|
||||||
|
*/
|
||||||
|
@OperLog(value = "角色管理", desc = "修改角色菜单")
|
||||||
|
@RequiresPermissions("sys:role:update")
|
||||||
|
@Transactional
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/update/{id}")
|
||||||
|
public JsonResult setRoleAuth(@PathVariable("id") Integer roleId, @RequestBody List<Integer> menuIds) {
|
||||||
|
roleMenuService.remove(new UpdateWrapper<RoleMenu>().eq("role_id", roleId));
|
||||||
|
if (menuIds.size() > 0) {
|
||||||
|
List<RoleMenu> roleMenuList = new ArrayList<>();
|
||||||
|
for (Integer menuId : menuIds) {
|
||||||
|
RoleMenu roleMenu = new RoleMenu();
|
||||||
|
roleMenu.setRoleId(roleId);
|
||||||
|
roleMenu.setMenuId(menuId);
|
||||||
|
roleMenuList.add(roleMenu);
|
||||||
|
}
|
||||||
|
if (roleMenuService.saveBatch(roleMenuList)) {
|
||||||
|
return JsonResult.ok("保存成功");
|
||||||
|
} else {
|
||||||
|
throw new BusinessException("操作失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return JsonResult.ok("保存成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,76 @@
|
||||||
|
package com.gfwl.admin.controller;
|
||||||
|
|
||||||
|
import com.baidu.ueditor.ActionEnter;
|
||||||
|
import com.gfwl.admin.base.JsonResult;
|
||||||
|
import com.gfwl.config.consts.Global;
|
||||||
|
import com.gfwl.utils.FileUploadUtil;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @Date 2020/9/24
|
||||||
|
* @Description: TODO
|
||||||
|
* @Version 1.0
|
||||||
|
*/
|
||||||
|
@Controller
|
||||||
|
public class UeditorServerController {
|
||||||
|
|
||||||
|
// 读取配置文件中配置的上传文件保存地址
|
||||||
|
@Value("${file.save.location}")
|
||||||
|
private String ueditorUrl;
|
||||||
|
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping(value = "/config")
|
||||||
|
public Object config(HttpServletRequest request, HttpServletResponse response, String action) {
|
||||||
|
response.setContentType("application/json");
|
||||||
|
//String rootPath = ClassUtils.getDefaultClassLoader( ).getResource("").getPath( ) + "static/assets/libs/ueditor2/php";
|
||||||
|
|
||||||
|
// String rootPath = request.getSession( ).getServletContext( ).getRealPath("/");
|
||||||
|
String rootPath=ueditorUrl;
|
||||||
|
System.out.println(rootPath);
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (action.equals("uploadimage")) {
|
||||||
|
MultipartHttpServletRequest multipartHttpServletRequest = (MultipartHttpServletRequest) request;
|
||||||
|
MultipartFile multipartFile = multipartHttpServletRequest.getFile("upfile");
|
||||||
|
|
||||||
|
//调用图片上传
|
||||||
|
JsonResult jsonResult = FileUploadUtil.upload(multipartFile);
|
||||||
|
|
||||||
|
String imgName = multipartFile.getOriginalFilename( );
|
||||||
|
String hz = imgName.substring(imgName.indexOf("."));
|
||||||
|
|
||||||
|
Map<String, Object> map = new HashMap<String, Object>( );
|
||||||
|
map.put("original", multipartFile.getOriginalFilename( ));
|
||||||
|
map.put("name", multipartFile.getOriginalFilename( ));
|
||||||
|
map.put("url", Global.base_img_url + jsonResult.get("url"));
|
||||||
|
map.put("size", multipartFile.getSize( ));
|
||||||
|
map.put("type", "." + hz);
|
||||||
|
map.put("state", "SUCCESS");
|
||||||
|
return map;
|
||||||
|
} else {
|
||||||
|
String exec = new ActionEnter(request, rootPath).exec( );
|
||||||
|
PrintWriter writer = response.getWriter( );
|
||||||
|
writer.write(exec);
|
||||||
|
writer.flush( );
|
||||||
|
writer.close( );
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace( );
|
||||||
|
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,422 @@
|
||||||
|
package com.gfwl.admin.controller;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import cn.hutool.poi.excel.ExcelReader;
|
||||||
|
import cn.hutool.poi.excel.ExcelUtil;
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.gfwl.admin.base.*;
|
||||||
|
import com.gfwl.admin.entity.DictionaryData;
|
||||||
|
import com.gfwl.admin.entity.Organization;
|
||||||
|
import com.gfwl.admin.entity.Role;
|
||||||
|
import com.gfwl.admin.entity.User;
|
||||||
|
import com.gfwl.admin.service.DictionaryDataService;
|
||||||
|
import com.gfwl.admin.service.OrganizationService;
|
||||||
|
import com.gfwl.admin.service.RoleService;
|
||||||
|
import com.gfwl.admin.service.UserService;
|
||||||
|
import com.gfwl.config.annotation.OperLog;
|
||||||
|
import com.gfwl.utils.CoreUtil;
|
||||||
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.ui.Model;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户管理
|
||||||
|
* Created by wangfan on 2018-12-24 16:10
|
||||||
|
*/
|
||||||
|
@Controller
|
||||||
|
@RequestMapping("/sys/user")
|
||||||
|
public class UserController extends BaseController {
|
||||||
|
@Autowired
|
||||||
|
private UserService userService;
|
||||||
|
@Autowired
|
||||||
|
private DictionaryDataService dictionaryDataService;
|
||||||
|
@Autowired
|
||||||
|
private RoleService roleService;
|
||||||
|
@Autowired
|
||||||
|
private OrganizationService organizationService;
|
||||||
|
|
||||||
|
@RequiresPermissions("sys:user:view")
|
||||||
|
@RequestMapping()
|
||||||
|
public String view(Model model) {
|
||||||
|
model.addAttribute("sexList", dictionaryDataService.listByDictCode("sex"));
|
||||||
|
model.addAttribute("organizationTypeList", dictionaryDataService.listByDictCode("organization_type"));
|
||||||
|
model.addAttribute("rolesJson", JSON.toJSONString(roleService.list( )));
|
||||||
|
return "system/user.html";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 个人中心
|
||||||
|
*/
|
||||||
|
@RequestMapping("/info")
|
||||||
|
public String userInfo(Model model) {
|
||||||
|
model.addAttribute("user", userService.getFullById(getLoginUserId( )));
|
||||||
|
model.addAttribute("sexList", dictionaryDataService.listByDictCode("sex"));
|
||||||
|
return "index/user-info.html";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询用户
|
||||||
|
*/
|
||||||
|
@OperLog(value = "用户管理", desc = "分页查询")
|
||||||
|
@RequiresPermissions("sys:user:list")
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/page")
|
||||||
|
public PageResult<User> page(HttpServletRequest request) {
|
||||||
|
PageParam<User> pageParam = new PageParam<>(request);
|
||||||
|
pageParam.setDefaultOrder(null, new String[]{"create_time"});
|
||||||
|
return userService.listPage(pageParam);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询全部用户
|
||||||
|
*/
|
||||||
|
@OperLog(value = "用户管理", desc = "查询全部")
|
||||||
|
@RequiresPermissions("sys:user:list")
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/list")
|
||||||
|
public JsonResult list(HttpServletRequest request) {
|
||||||
|
PageParam<User> pageParam = new PageParam<>(request);
|
||||||
|
List<User> records = userService.listAll(pageParam.getNoPageParam( ));
|
||||||
|
return JsonResult.ok( ).setData(pageParam.sortRecords(records));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据id查询用户
|
||||||
|
*/
|
||||||
|
@OperLog(value = "用户管理", desc = "根据id查询")
|
||||||
|
@RequiresPermissions("sys:user:list")
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/get")
|
||||||
|
public JsonResult get(Integer id) {
|
||||||
|
PageParam<User> pageParam = new PageParam<>( );
|
||||||
|
pageParam.put("userId", id);
|
||||||
|
List<User> records = userService.listAll(pageParam.getNoPageParam( ));
|
||||||
|
return JsonResult.ok( ).setData(pageParam.getOne(records));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加用户
|
||||||
|
*/
|
||||||
|
@OperLog(value = "用户管理", desc = "添加", param = false, result = true)
|
||||||
|
@RequiresPermissions("sys:user:save")
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/save")
|
||||||
|
public JsonResult save(@RequestBody User user) {
|
||||||
|
user.setState(0);
|
||||||
|
user.setPassword(userService.encodePsw(user.getPassword( )));
|
||||||
|
if (userService.saveUser(user)) {
|
||||||
|
return JsonResult.ok("添加成功");
|
||||||
|
}
|
||||||
|
return JsonResult.error("添加失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改用户
|
||||||
|
*/
|
||||||
|
@OperLog(value = "用户管理", desc = "修改", param = false, result = true)
|
||||||
|
@RequiresPermissions("sys:user:update")
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/update")
|
||||||
|
public JsonResult update(@RequestBody User user) {
|
||||||
|
user.setState(null); // 状态不能修改
|
||||||
|
user.setPassword(null); // 密码不能修改
|
||||||
|
user.setUsername(null); // 账号不能修改
|
||||||
|
if (userService.updateUser(user)) {
|
||||||
|
return JsonResult.ok("修改成功");
|
||||||
|
}
|
||||||
|
return JsonResult.error("修改失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除用户
|
||||||
|
*/
|
||||||
|
@OperLog(value = "用户管理", desc = "删除", result = true)
|
||||||
|
@RequiresPermissions("sys:user:remove")
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/remove")
|
||||||
|
public JsonResult remove(Integer id) {
|
||||||
|
if (userService.removeById(id)) {
|
||||||
|
return JsonResult.ok("删除成功");
|
||||||
|
}
|
||||||
|
return JsonResult.error("删除失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量修改用户
|
||||||
|
*/
|
||||||
|
@OperLog(value = "用户管理", desc = "批量修改", param = false, result = true)
|
||||||
|
@RequiresPermissions("sys:user:update")
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/updateBatch")
|
||||||
|
public JsonResult updateBatch(@RequestBody BatchParam<User> batchParam) {
|
||||||
|
// 不能修改的字段
|
||||||
|
batchParam.getData( ).setPassword(null);
|
||||||
|
batchParam.getData( ).setState(null);
|
||||||
|
batchParam.getData( ).setUsername(null);
|
||||||
|
batchParam.getData( ).setPhone(null);
|
||||||
|
batchParam.getData( ).setEmail(null);
|
||||||
|
if (batchParam.update(userService, "user_id")) {
|
||||||
|
return JsonResult.ok("修改成功");
|
||||||
|
}
|
||||||
|
return JsonResult.error("修改失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除用户
|
||||||
|
*/
|
||||||
|
@OperLog(value = "用户管理", desc = "批量删除", result = true)
|
||||||
|
@RequiresPermissions("sys:user:remove")
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/deleteBatch")
|
||||||
|
public JsonResult deleteBatch(@RequestBody List<Integer> ids) {
|
||||||
|
if (userService.removeByIds(ids)) {
|
||||||
|
return JsonResult.ok("删除成功");
|
||||||
|
}
|
||||||
|
return JsonResult.error("删除失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改用户状态
|
||||||
|
*/
|
||||||
|
@OperLog(value = "用户管理", desc = "修改状态", result = true)
|
||||||
|
@RequiresPermissions("sys:user:update")
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/state/update")
|
||||||
|
public JsonResult updateState(Integer id, Integer state) {
|
||||||
|
if (state == null || (state != 0 && state != 1)) {
|
||||||
|
return JsonResult.error("状态值不正确");
|
||||||
|
}
|
||||||
|
User user = new User( );
|
||||||
|
user.setUserId(id);
|
||||||
|
user.setState(state);
|
||||||
|
if (userService.updateById(user)) {
|
||||||
|
return JsonResult.ok("修改成功");
|
||||||
|
}
|
||||||
|
return JsonResult.error("修改失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量修改用户状态
|
||||||
|
*/
|
||||||
|
@OperLog(value = "用户管理", desc = "批量修改状态", result = true)
|
||||||
|
@RequiresPermissions("sys:user:update")
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/state/updateBatch")
|
||||||
|
public JsonResult updateStateBatch(@RequestBody BatchParam<User> batchParam) {
|
||||||
|
User user = new User( );
|
||||||
|
user.setState(batchParam.getData( ).getState( ));
|
||||||
|
if (user.getState( ) == null || (user.getState( ) != 0 && user.getState( ) != 1)) {
|
||||||
|
return JsonResult.error("状态值不正确");
|
||||||
|
}
|
||||||
|
if (batchParam.update(userService, "user_id")) {
|
||||||
|
return JsonResult.ok("修改成功");
|
||||||
|
}
|
||||||
|
return JsonResult.error("修改失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 重置密码
|
||||||
|
*/
|
||||||
|
@OperLog(value = "用户管理", desc = "重置密码", param = false, result = true)
|
||||||
|
@RequiresPermissions("sys:user:update")
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/psw/reset")
|
||||||
|
public JsonResult resetPsw(Integer id, String password) {
|
||||||
|
User user = new User( );
|
||||||
|
user.setUserId(id);
|
||||||
|
user.setPassword(userService.encodePsw(password));
|
||||||
|
if (userService.updateById(user)) {
|
||||||
|
return JsonResult.ok("重置成功");
|
||||||
|
} else {
|
||||||
|
return JsonResult.error("重置失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量重置密码
|
||||||
|
*/
|
||||||
|
@OperLog(value = "用户管理", desc = "批量重置密码", param = false, result = true)
|
||||||
|
@RequiresPermissions("sys:user:update")
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/psw/resetBatch")
|
||||||
|
public JsonResult resetPswBatch(@RequestBody BatchParam<User> batchParam) {
|
||||||
|
User user = new User( );
|
||||||
|
user.setPassword(userService.encodePsw(batchParam.getData( ).getPassword( )));
|
||||||
|
if (batchParam.update(userService, "user_id")) {
|
||||||
|
return JsonResult.ok("重置成功");
|
||||||
|
} else {
|
||||||
|
return JsonResult.error("重置失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改自己密码
|
||||||
|
*/
|
||||||
|
@OperLog(value = "用户管理", desc = "修改自己密码", param = false, result = true)
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/psw/update")
|
||||||
|
public JsonResult updatePsw(String oldPsw, String newPsw) {
|
||||||
|
if (StrUtil.hasBlank(oldPsw, newPsw)) {
|
||||||
|
return JsonResult.error("参数不能为空");
|
||||||
|
}
|
||||||
|
if (getLoginUserId( ) == null) {
|
||||||
|
return JsonResult.error("未登录");
|
||||||
|
}
|
||||||
|
if (!userService.comparePsw(userService.getById(getLoginUserId( )).getPassword( ), oldPsw)) {
|
||||||
|
return JsonResult.error("原密码输入不正确");
|
||||||
|
}
|
||||||
|
User user = new User( );
|
||||||
|
user.setUserId(getLoginUserId( ));
|
||||||
|
user.setPassword(userService.encodePsw(newPsw));
|
||||||
|
if (userService.updateById(user)) {
|
||||||
|
return JsonResult.ok("修改成功");
|
||||||
|
}
|
||||||
|
return JsonResult.error("修改失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改自己资料
|
||||||
|
*/
|
||||||
|
@OperLog(value = "用户管理", desc = "修改个人信息", param = false, result = true)
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/info/update")
|
||||||
|
public JsonResult updateInfo(User user) {
|
||||||
|
user.setUserId(getLoginUserId( ));
|
||||||
|
// 不能修改的字段
|
||||||
|
user.setState(null);
|
||||||
|
user.setPassword(null);
|
||||||
|
user.setUsername(null);
|
||||||
|
user.setOrganizationId(null);
|
||||||
|
if (userService.updateById(user)) {
|
||||||
|
User loginUser = getLoginUser( );
|
||||||
|
if (user.getNickName( ) != null) loginUser.setNickName(user.getNickName( ));
|
||||||
|
if (user.getAvatar( ) != null) loginUser.setAvatar(user.getAvatar( ));
|
||||||
|
return JsonResult.ok("保存成功");
|
||||||
|
}
|
||||||
|
return JsonResult.error("保存失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* excel导入用户
|
||||||
|
*/
|
||||||
|
@Transactional
|
||||||
|
@OperLog(value = "用户管理", desc = "excel导入", param = false, result = true)
|
||||||
|
@RequiresPermissions("sys:user:save")
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/import")
|
||||||
|
public JsonResult importBatch(MultipartFile file) {
|
||||||
|
StringBuilder sb = new StringBuilder( );
|
||||||
|
try {
|
||||||
|
// 读取excel
|
||||||
|
int startRow = 1;
|
||||||
|
ExcelReader reader = ExcelUtil.getReader(file.getInputStream( ), 0);
|
||||||
|
List<List<Object>> list = reader.read(startRow);
|
||||||
|
// 进行非空和重复检查
|
||||||
|
sb.append(CoreUtil.excelCheckBlank(list, startRow, 0, 1, 2, 3, 4));
|
||||||
|
sb.append(CoreUtil.excelCheckRepeat(list, startRow, 0, 5));
|
||||||
|
if (!sb.toString( ).isEmpty( )) return JsonResult.error(sb.toString( ));
|
||||||
|
// 进行数据库层面检查
|
||||||
|
List<User> users = new ArrayList<>( );
|
||||||
|
for (int i = 0; i < list.size( ); i++) {
|
||||||
|
List<Object> objects = list.get(i);
|
||||||
|
String username = String.valueOf(objects.get(0)); // 账号
|
||||||
|
String password = String.valueOf(objects.get(1)); // 密码
|
||||||
|
String nickName = String.valueOf(objects.get(2)); // 用户名
|
||||||
|
String sexName = String.valueOf(objects.get(3)); // 性别
|
||||||
|
String roleName = String.valueOf(objects.get(4)); // 角色名
|
||||||
|
String phone = String.valueOf(objects.get(5)); // 手机号
|
||||||
|
String orgName = String.valueOf(objects.get(6)); // 组织机构
|
||||||
|
// String orgName = String.valueOf(objects.get(7)); // 组织机构
|
||||||
|
if (userService.count(new QueryWrapper<User>( ).eq("username", username)) > 0) {
|
||||||
|
sb.append("第");
|
||||||
|
sb.append(i + startRow + 1);
|
||||||
|
sb.append("行第1");
|
||||||
|
sb.append("列账号已存在;\r\n");
|
||||||
|
}
|
||||||
|
if (StrUtil.isNotBlank(phone) && userService.count(new QueryWrapper<User>( ).eq("phone", phone)) > 0) {
|
||||||
|
sb.append("第");
|
||||||
|
sb.append(i + startRow + 1);
|
||||||
|
sb.append("行第6");
|
||||||
|
sb.append("列手机号已存在;\r\n");
|
||||||
|
}
|
||||||
|
// if (StrUtil.isNotBlank(email) && userService.count(new QueryWrapper<User>( ).eq("email", email)) > 0) {
|
||||||
|
// sb.append("第");
|
||||||
|
// sb.append(i + startRow + 1);
|
||||||
|
// sb.append("行第7");
|
||||||
|
// sb.append("列邮箱已存在;\r\n");
|
||||||
|
// }
|
||||||
|
User user = new User( );
|
||||||
|
user.setUsername(username);
|
||||||
|
user.setNickName(nickName);
|
||||||
|
user.setPassword(userService.encodePsw(password));
|
||||||
|
user.setState(0);
|
||||||
|
user.setPhone(phone);
|
||||||
|
// user.setEmail(email);
|
||||||
|
DictionaryData sexDictData = dictionaryDataService.listByDictCodeAndName("sex", sexName);
|
||||||
|
if (sexDictData == null) {
|
||||||
|
sb.append("第");
|
||||||
|
sb.append(i + startRow + 1);
|
||||||
|
sb.append("行第4");
|
||||||
|
sb.append("列性别不存在;\r\n");
|
||||||
|
} else {
|
||||||
|
user.setSex(sexDictData.getDictDataId( ));
|
||||||
|
}
|
||||||
|
Role role = roleService.getOne(new QueryWrapper<Role>( ).eq("role_name", roleName), false);
|
||||||
|
if (role == null) {
|
||||||
|
sb.append("第");
|
||||||
|
sb.append(i + startRow + 1);
|
||||||
|
sb.append("行第5");
|
||||||
|
sb.append("列角色不存在;\r\n");
|
||||||
|
} else {
|
||||||
|
user.setRoleIds(Collections.singletonList(role.getRoleId( )));
|
||||||
|
}
|
||||||
|
Organization org = organizationService.getOne(new QueryWrapper<Organization>( ).eq("organization_full_name", orgName), false);
|
||||||
|
if (org == null) {
|
||||||
|
sb.append("第");
|
||||||
|
sb.append(i + startRow + 1);
|
||||||
|
sb.append("行第8");
|
||||||
|
sb.append("列角色不存在;\r\n");
|
||||||
|
} else {
|
||||||
|
user.setOrganizationId(org.getOrganizationId( ));
|
||||||
|
}
|
||||||
|
users.add(user);
|
||||||
|
}
|
||||||
|
if (!sb.toString( ).isEmpty( )) return JsonResult.error(sb.toString( ));
|
||||||
|
// 开始添加用户
|
||||||
|
int okNum = 0, errorNum = 0;
|
||||||
|
for (User user : users) {
|
||||||
|
if (userService.saveUser(user)) okNum++;
|
||||||
|
else errorNum++;
|
||||||
|
}
|
||||||
|
return JsonResult.ok("导入完成,成功" + okNum + "条,失败" + errorNum + "条");
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace( );
|
||||||
|
}
|
||||||
|
return JsonResult.error("导入失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param args
|
||||||
|
*/
|
||||||
|
public static void main(String[] args) {
|
||||||
|
System.out.println(getWeek(new Date( )));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getWeek(Date date) {
|
||||||
|
GregorianCalendar g = new GregorianCalendar( );
|
||||||
|
g.setTime(date);
|
||||||
|
System.out.println(g.get(Calendar.DAY_OF_WEEK));
|
||||||
|
return g.get(Calendar.WEEK_OF_YEAR);//获得周数
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,131 @@
|
||||||
|
package com.gfwl.admin.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字典
|
||||||
|
* Created by wangfan on 2020-03-14 11:29:03
|
||||||
|
*/
|
||||||
|
@TableName("gf_sys_dictionary")
|
||||||
|
public class Dictionary implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
/**
|
||||||
|
* 字典id
|
||||||
|
*/
|
||||||
|
@TableId(value = "dict_id", type = IdType.AUTO)
|
||||||
|
private Integer dictId;
|
||||||
|
/**
|
||||||
|
* 字典标识
|
||||||
|
*/
|
||||||
|
private String dictCode;
|
||||||
|
/**
|
||||||
|
* 字典名称
|
||||||
|
*/
|
||||||
|
private String dictName;
|
||||||
|
/**
|
||||||
|
* 排序号
|
||||||
|
*/
|
||||||
|
private Integer sortNumber;
|
||||||
|
/**
|
||||||
|
* 备注
|
||||||
|
*/
|
||||||
|
private String comments;
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
private Date createTime;
|
||||||
|
/**
|
||||||
|
* 修改时间
|
||||||
|
*/
|
||||||
|
private Date updateTime;
|
||||||
|
/**
|
||||||
|
* 是否删除,0否,1是
|
||||||
|
*/
|
||||||
|
@TableLogic
|
||||||
|
private Integer deleted;
|
||||||
|
|
||||||
|
public Integer getDictId() {
|
||||||
|
return dictId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDictId(Integer dictId) {
|
||||||
|
this.dictId = dictId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDictCode() {
|
||||||
|
return dictCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDictCode(String dictCode) {
|
||||||
|
this.dictCode = dictCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDictName() {
|
||||||
|
return dictName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDictName(String dictName) {
|
||||||
|
this.dictName = dictName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getSortNumber() {
|
||||||
|
return sortNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSortNumber(Integer sortNumber) {
|
||||||
|
this.sortNumber = sortNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getComments() {
|
||||||
|
return comments;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setComments(String comments) {
|
||||||
|
this.comments = comments;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getDeleted() {
|
||||||
|
return deleted;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDeleted(Integer deleted) {
|
||||||
|
this.deleted = deleted;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getCreateTime() {
|
||||||
|
return createTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCreateTime(Date createTime) {
|
||||||
|
this.createTime = createTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getUpdateTime() {
|
||||||
|
return updateTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUpdateTime(Date updateTime) {
|
||||||
|
this.updateTime = updateTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Dictionary{" +
|
||||||
|
", dictId=" + dictId +
|
||||||
|
", dictCode=" + dictCode +
|
||||||
|
", dictName=" + dictName +
|
||||||
|
", sortNumber=" + sortNumber +
|
||||||
|
", comments=" + comments +
|
||||||
|
", createTime=" + createTime +
|
||||||
|
", updateTime=" + updateTime +
|
||||||
|
", deleted=" + deleted +
|
||||||
|
"}";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,169 @@
|
||||||
|
package com.gfwl.admin.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字典项
|
||||||
|
* Created by wangfan on 2020-03-14 11:29:04
|
||||||
|
*/
|
||||||
|
@TableName("gf_sys_dictionary_data")
|
||||||
|
public class DictionaryData implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
/**
|
||||||
|
* 字典项id
|
||||||
|
*/
|
||||||
|
@TableId(value = "dict_data_id", type = IdType.AUTO)
|
||||||
|
private Integer dictDataId;
|
||||||
|
/**
|
||||||
|
* 字典id
|
||||||
|
*/
|
||||||
|
private Integer dictId;
|
||||||
|
/**
|
||||||
|
* 字典项标识
|
||||||
|
*/
|
||||||
|
private String dictDataCode;
|
||||||
|
/**
|
||||||
|
* 字典项名称
|
||||||
|
*/
|
||||||
|
private String dictDataName;
|
||||||
|
/**
|
||||||
|
* 排序号
|
||||||
|
*/
|
||||||
|
private Integer sortNumber;
|
||||||
|
/**
|
||||||
|
* 备注
|
||||||
|
*/
|
||||||
|
private String comments;
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
private Date createTime;
|
||||||
|
/**
|
||||||
|
* 修改时间
|
||||||
|
*/
|
||||||
|
private Date updateTime;
|
||||||
|
/**
|
||||||
|
* 是否删除,0否,1是
|
||||||
|
*/
|
||||||
|
@TableLogic
|
||||||
|
private Integer deleted;
|
||||||
|
/**
|
||||||
|
* 字典代码
|
||||||
|
*/
|
||||||
|
@TableField(exist = false)
|
||||||
|
private String dictCode;
|
||||||
|
/**
|
||||||
|
* 字典名称
|
||||||
|
*/
|
||||||
|
@TableField(exist = false)
|
||||||
|
private String dictName;
|
||||||
|
|
||||||
|
public Integer getDictDataId() {
|
||||||
|
return dictDataId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDictDataId(Integer dictDataId) {
|
||||||
|
this.dictDataId = dictDataId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getDictId() {
|
||||||
|
return dictId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDictId(Integer dictId) {
|
||||||
|
this.dictId = dictId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDictDataCode() {
|
||||||
|
return dictDataCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDictDataCode(String dictDataCode) {
|
||||||
|
this.dictDataCode = dictDataCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDictDataName() {
|
||||||
|
return dictDataName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDictDataName(String dictDataName) {
|
||||||
|
this.dictDataName = dictDataName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getSortNumber() {
|
||||||
|
return sortNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSortNumber(Integer sortNumber) {
|
||||||
|
this.sortNumber = sortNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getComments() {
|
||||||
|
return comments;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setComments(String comments) {
|
||||||
|
this.comments = comments;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getCreateTime() {
|
||||||
|
return createTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCreateTime(Date createTime) {
|
||||||
|
this.createTime = createTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getUpdateTime() {
|
||||||
|
return updateTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUpdateTime(Date updateTime) {
|
||||||
|
this.updateTime = updateTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getDeleted() {
|
||||||
|
return deleted;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDeleted(Integer deleted) {
|
||||||
|
this.deleted = deleted;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDictCode() {
|
||||||
|
return dictCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDictCode(String dictCode) {
|
||||||
|
this.dictCode = dictCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDictName() {
|
||||||
|
return dictName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDictName(String dictName) {
|
||||||
|
this.dictName = dictName;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "DictionaryData{" +
|
||||||
|
", dictDataId=" + dictDataId +
|
||||||
|
", dictId=" + dictId +
|
||||||
|
", dictDataCode=" + dictDataCode +
|
||||||
|
", dictDataName=" + dictDataName +
|
||||||
|
", sortNumber=" + sortNumber +
|
||||||
|
", comments=" + comments +
|
||||||
|
", createTime=" + createTime +
|
||||||
|
", updateTime=" + updateTime +
|
||||||
|
", deleted=" + deleted +
|
||||||
|
", dictCode=" + dictCode +
|
||||||
|
", dictName=" + dictName +
|
||||||
|
"}";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,173 @@
|
||||||
|
package com.gfwl.admin.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 java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 登录日志
|
||||||
|
* Created by wangfan on 2018-12-24 16:10
|
||||||
|
*/
|
||||||
|
@TableName("gf_sys_login_record")
|
||||||
|
public class LoginRecord implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
public static final int TYPE_LOGIN = 0; // 登录
|
||||||
|
public static final int TYPE_ERROR = 1; // 登录失败
|
||||||
|
public static final int TYPE_LOGOUT = 2; // 退出登录
|
||||||
|
public static final int TYPE_REFRESH = 3; // 刷新token
|
||||||
|
/**
|
||||||
|
* 主键id
|
||||||
|
*/
|
||||||
|
@TableId(value = "id", type = IdType.AUTO)
|
||||||
|
private Integer id;
|
||||||
|
/**
|
||||||
|
* 用户id
|
||||||
|
*/
|
||||||
|
private String username;
|
||||||
|
/**
|
||||||
|
* 操作系统
|
||||||
|
*/
|
||||||
|
private String os;
|
||||||
|
/**
|
||||||
|
* 设备名
|
||||||
|
*/
|
||||||
|
private String device;
|
||||||
|
/**
|
||||||
|
* 浏览器类型
|
||||||
|
*/
|
||||||
|
private String browser;
|
||||||
|
/**
|
||||||
|
* ip地址
|
||||||
|
*/
|
||||||
|
private String ip;
|
||||||
|
/**
|
||||||
|
* 操作类型,0登录成功,1登录失败,2退出登录,3刷新token
|
||||||
|
*/
|
||||||
|
private Integer operType;
|
||||||
|
/**
|
||||||
|
* 备注
|
||||||
|
*/
|
||||||
|
private String comments;
|
||||||
|
/**
|
||||||
|
* 操作时间
|
||||||
|
*/
|
||||||
|
private Date createTime;
|
||||||
|
/**
|
||||||
|
* 修改时间
|
||||||
|
*/
|
||||||
|
private Date updateTime;
|
||||||
|
/**
|
||||||
|
* 用户昵称
|
||||||
|
*/
|
||||||
|
@TableField(exist = false)
|
||||||
|
private String nickName;
|
||||||
|
|
||||||
|
public Integer getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(Integer id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getOs() {
|
||||||
|
return os;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOs(String os) {
|
||||||
|
this.os = os;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDevice() {
|
||||||
|
return device;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDevice(String device) {
|
||||||
|
this.device = device;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBrowser() {
|
||||||
|
return browser;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBrowser(String browser) {
|
||||||
|
this.browser = browser;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getIp() {
|
||||||
|
return ip;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIp(String ip) {
|
||||||
|
this.ip = ip;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getOperType() {
|
||||||
|
return operType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOperType(Integer operType) {
|
||||||
|
this.operType = operType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getComments() {
|
||||||
|
return comments;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setComments(String comments) {
|
||||||
|
this.comments = comments;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getCreateTime() {
|
||||||
|
return createTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCreateTime(Date createTime) {
|
||||||
|
this.createTime = createTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getUpdateTime() {
|
||||||
|
return updateTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUpdateTime(Date updateTime) {
|
||||||
|
this.updateTime = updateTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUsername() {
|
||||||
|
return username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUsername(String username) {
|
||||||
|
this.username = username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNickName() {
|
||||||
|
return nickName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNickName(String nickName) {
|
||||||
|
this.nickName = nickName;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "LoginRecord{" +
|
||||||
|
", id=" + id +
|
||||||
|
", os=" + os +
|
||||||
|
", device=" + device +
|
||||||
|
", browser=" + browser +
|
||||||
|
", ip=" + ip +
|
||||||
|
", operType=" + operType +
|
||||||
|
", comments=" + comments +
|
||||||
|
", createTime=" + createTime +
|
||||||
|
", updateTime=" + updateTime +
|
||||||
|
", username=" + username +
|
||||||
|
", nickName=" + nickName +
|
||||||
|
"}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,259 @@
|
||||||
|
package com.gfwl.admin.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 菜单
|
||||||
|
* Created by AutoGenerator on 2018-12-24 16:10
|
||||||
|
*/
|
||||||
|
@TableName("gf_sys_menu")
|
||||||
|
public class Menu implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
public static final int TYPE_MENU = 0; // 菜单类型
|
||||||
|
public static final int TYPE_BTN = 1; // 按钮类型
|
||||||
|
/**
|
||||||
|
* 菜单id
|
||||||
|
*/
|
||||||
|
@TableId(value = "menu_id", type = IdType.AUTO)
|
||||||
|
private Integer menuId;
|
||||||
|
/**
|
||||||
|
* 上级id,0是顶级
|
||||||
|
*/
|
||||||
|
private Integer parentId;
|
||||||
|
/**
|
||||||
|
* 菜单名称
|
||||||
|
*/
|
||||||
|
private String menuName;
|
||||||
|
/**
|
||||||
|
* 菜单图标
|
||||||
|
*/
|
||||||
|
private String menuIcon;
|
||||||
|
/**
|
||||||
|
* 图标颜色
|
||||||
|
*/
|
||||||
|
private String iconColor;
|
||||||
|
/**
|
||||||
|
* 菜单地址
|
||||||
|
*/
|
||||||
|
private String path;
|
||||||
|
/**
|
||||||
|
* 打开位置
|
||||||
|
*/
|
||||||
|
private String target;
|
||||||
|
/**
|
||||||
|
* 是否隐藏,0否,1是
|
||||||
|
*/
|
||||||
|
private Integer hide;
|
||||||
|
/**
|
||||||
|
* 排序号
|
||||||
|
*/
|
||||||
|
private Integer sortNumber;
|
||||||
|
/**
|
||||||
|
* 权限标识
|
||||||
|
*/
|
||||||
|
private String authority;
|
||||||
|
/**
|
||||||
|
* 菜单类型,0菜单,1按钮
|
||||||
|
*/
|
||||||
|
private Integer menuType;
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
private Date createTime;
|
||||||
|
/**
|
||||||
|
* 修改时间
|
||||||
|
*/
|
||||||
|
private Date updateTime;
|
||||||
|
/**
|
||||||
|
* 是否删除,0否,1是
|
||||||
|
*/
|
||||||
|
@TableLogic
|
||||||
|
private Integer deleted;
|
||||||
|
/**
|
||||||
|
* 上级菜单名称
|
||||||
|
*/
|
||||||
|
@TableField(exist = false)
|
||||||
|
private String parentName;
|
||||||
|
/**
|
||||||
|
* 子菜单
|
||||||
|
*/
|
||||||
|
@TableField(exist = false)
|
||||||
|
private List<Menu> children;
|
||||||
|
/**
|
||||||
|
* 回显选中状态,0未选中,1选中
|
||||||
|
*/
|
||||||
|
@TableField(exist = false)
|
||||||
|
private Boolean checked;
|
||||||
|
@TableField(exist = false)
|
||||||
|
private Boolean open;
|
||||||
|
|
||||||
|
public Integer getMenuId() {
|
||||||
|
return menuId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMenuId(Integer menuId) {
|
||||||
|
this.menuId = menuId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getParentId() {
|
||||||
|
return parentId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setParentId(Integer parentId) {
|
||||||
|
this.parentId = parentId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMenuName() {
|
||||||
|
return menuName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMenuName(String menuName) {
|
||||||
|
this.menuName = menuName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getIconColor() {
|
||||||
|
return iconColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIconColor(String iconColor) {
|
||||||
|
this.iconColor = iconColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPath() {
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPath(String path) {
|
||||||
|
this.path = path;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMenuIcon() {
|
||||||
|
return menuIcon;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMenuIcon(String menuIcon) {
|
||||||
|
this.menuIcon = menuIcon;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getSortNumber() {
|
||||||
|
return sortNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSortNumber(Integer sortNumber) {
|
||||||
|
this.sortNumber = sortNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTarget() {
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTarget(String target) {
|
||||||
|
this.target = target;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getHide() {
|
||||||
|
return hide;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHide(Integer hide) {
|
||||||
|
this.hide = hide;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAuthority() {
|
||||||
|
return authority;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAuthority(String authority) {
|
||||||
|
this.authority = authority;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getMenuType() {
|
||||||
|
return menuType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMenuType(Integer menuType) {
|
||||||
|
this.menuType = menuType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getCreateTime() {
|
||||||
|
return createTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCreateTime(Date createTime) {
|
||||||
|
this.createTime = createTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getUpdateTime() {
|
||||||
|
return updateTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUpdateTime(Date updateTime) {
|
||||||
|
this.updateTime = updateTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getDeleted() {
|
||||||
|
return deleted;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDeleted(Integer deleted) {
|
||||||
|
this.deleted = deleted;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getParentName() {
|
||||||
|
return parentName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setParentName(String parentName) {
|
||||||
|
this.parentName = parentName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Menu> getChildren() {
|
||||||
|
return children;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setChildren(List<Menu> children) {
|
||||||
|
this.children = children;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getChecked() {
|
||||||
|
return checked;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setChecked(Boolean checked) {
|
||||||
|
this.checked = checked;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getOpen() {
|
||||||
|
return open;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOpen(Boolean open) {
|
||||||
|
this.open = open;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Menu{" +
|
||||||
|
", menuId=" + menuId +
|
||||||
|
", parentId=" + parentId +
|
||||||
|
", menuName=" + menuName +
|
||||||
|
", path=" + path +
|
||||||
|
", menuIcon=" + menuIcon +
|
||||||
|
", iconColor=" + iconColor +
|
||||||
|
", sortNumber=" + sortNumber +
|
||||||
|
", target=" + target +
|
||||||
|
", hide=" + hide +
|
||||||
|
", authority=" + authority +
|
||||||
|
", menuType=" + menuType +
|
||||||
|
", createTime=" + createTime +
|
||||||
|
", updateTime=" + updateTime +
|
||||||
|
", deleted=" + deleted +
|
||||||
|
", parentName=" + parentName +
|
||||||
|
"}";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,247 @@
|
||||||
|
package com.gfwl.admin.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 java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 操作日志
|
||||||
|
* Created by wangfan on 2018-12-24 16:10
|
||||||
|
*/
|
||||||
|
@TableName("gf_sys_oper_record")
|
||||||
|
public class OperRecord implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
/**
|
||||||
|
* 主键id
|
||||||
|
*/
|
||||||
|
@TableId(value = "id", type = IdType.AUTO)
|
||||||
|
private Integer id;
|
||||||
|
/**
|
||||||
|
* 用户id
|
||||||
|
*/
|
||||||
|
private Integer userId;
|
||||||
|
/**
|
||||||
|
* 模块
|
||||||
|
*/
|
||||||
|
private String model;
|
||||||
|
/**
|
||||||
|
* 方法
|
||||||
|
*/
|
||||||
|
private String description;
|
||||||
|
/**
|
||||||
|
* 请求地址
|
||||||
|
*/
|
||||||
|
private String url;
|
||||||
|
/**
|
||||||
|
* 请求方式
|
||||||
|
*/
|
||||||
|
private String requestMethod;
|
||||||
|
/**
|
||||||
|
* 调用方法
|
||||||
|
*/
|
||||||
|
private String operMethod;
|
||||||
|
/**
|
||||||
|
* 请求参数
|
||||||
|
*/
|
||||||
|
private String param;
|
||||||
|
/**
|
||||||
|
* 返回结果
|
||||||
|
*/
|
||||||
|
private String result;
|
||||||
|
/**
|
||||||
|
* ip地址
|
||||||
|
*/
|
||||||
|
private String ip;
|
||||||
|
/**
|
||||||
|
* 消耗时间,单位毫秒
|
||||||
|
*/
|
||||||
|
private Long spendTime;
|
||||||
|
/**
|
||||||
|
* 状态,0成功,1异常
|
||||||
|
*/
|
||||||
|
private Integer state;
|
||||||
|
/**
|
||||||
|
* 备注
|
||||||
|
*/
|
||||||
|
private String comments;
|
||||||
|
/**
|
||||||
|
* 操作时间
|
||||||
|
*/
|
||||||
|
private Date createTime;
|
||||||
|
/**
|
||||||
|
* 修改时间
|
||||||
|
*/
|
||||||
|
private Date updateTime;
|
||||||
|
/**
|
||||||
|
* 用户昵称
|
||||||
|
*/
|
||||||
|
@TableField(exist = false)
|
||||||
|
private String nickName;
|
||||||
|
/**
|
||||||
|
* 用户账号
|
||||||
|
*/
|
||||||
|
@TableField(exist = false)
|
||||||
|
private String username;
|
||||||
|
|
||||||
|
public Integer getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(Integer id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getUserId() {
|
||||||
|
return userId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUserId(Integer userId) {
|
||||||
|
this.userId = userId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getModel() {
|
||||||
|
return model;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setModel(String model) {
|
||||||
|
this.model = model;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDescription(String description) {
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUrl() {
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUrl(String url) {
|
||||||
|
this.url = url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRequestMethod() {
|
||||||
|
return requestMethod;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRequestMethod(String requestMethod) {
|
||||||
|
this.requestMethod = requestMethod;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getOperMethod() {
|
||||||
|
return operMethod;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOperMethod(String operMethod) {
|
||||||
|
this.operMethod = operMethod;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getParam() {
|
||||||
|
return param;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setParam(String param) {
|
||||||
|
this.param = param;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getResult() {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setResult(String result) {
|
||||||
|
this.result = result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getIp() {
|
||||||
|
return ip;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIp(String ip) {
|
||||||
|
this.ip = ip;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getSpendTime() {
|
||||||
|
return spendTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSpendTime(Long spendTime) {
|
||||||
|
this.spendTime = spendTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getState() {
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setState(Integer state) {
|
||||||
|
this.state = state;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getComments() {
|
||||||
|
return comments;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setComments(String comments) {
|
||||||
|
this.comments = comments;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getCreateTime() {
|
||||||
|
return createTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCreateTime(Date createTime) {
|
||||||
|
this.createTime = createTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getUpdateTime() {
|
||||||
|
return updateTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUpdateTime(Date updateTime) {
|
||||||
|
this.updateTime = updateTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNickName() {
|
||||||
|
return nickName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNickName(String nickName) {
|
||||||
|
this.nickName = nickName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUsername() {
|
||||||
|
return username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUsername(String username) {
|
||||||
|
this.username = username;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "LoginRecord{" +
|
||||||
|
", id=" + id +
|
||||||
|
", userId=" + userId +
|
||||||
|
", model=" + model +
|
||||||
|
", description=" + description +
|
||||||
|
", url=" + url +
|
||||||
|
", requestMethod=" + requestMethod +
|
||||||
|
", operMethod=" + operMethod +
|
||||||
|
", param=" + param +
|
||||||
|
", result=" + result +
|
||||||
|
", ip=" + ip +
|
||||||
|
", spendTime=" + spendTime +
|
||||||
|
", state=" + state +
|
||||||
|
", comments=" + comments +
|
||||||
|
", createTime=" + createTime +
|
||||||
|
", updateTime=" + updateTime +
|
||||||
|
", nickName=" + nickName +
|
||||||
|
"}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,108 @@
|
||||||
|
package com.gfwl.admin.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 组织机构
|
||||||
|
* Created by AutoGenerator on 2020-03-14 11:29:04
|
||||||
|
*/
|
||||||
|
@ToString
|
||||||
|
@Data
|
||||||
|
@TableName("gf_sys_organization")
|
||||||
|
public class Organization implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@TableId(value = "id", type = IdType.AUTO)
|
||||||
|
private Integer id;
|
||||||
|
/**
|
||||||
|
* 机构id
|
||||||
|
*/
|
||||||
|
@TableField(value = "organization_id")
|
||||||
|
private String organizationId;
|
||||||
|
/**
|
||||||
|
* 上级id,0是顶级
|
||||||
|
*/
|
||||||
|
private String parentId;
|
||||||
|
/**
|
||||||
|
* 机构名称
|
||||||
|
*/
|
||||||
|
private String organizationName;
|
||||||
|
/**
|
||||||
|
* 机构全称
|
||||||
|
*/
|
||||||
|
private String organizationFullName;
|
||||||
|
/**
|
||||||
|
* 机构类型
|
||||||
|
*/
|
||||||
|
private Integer organizationType;
|
||||||
|
/**
|
||||||
|
* 负责人id
|
||||||
|
*/
|
||||||
|
private Integer leaderId;
|
||||||
|
/**
|
||||||
|
* 排序号
|
||||||
|
*/
|
||||||
|
private Integer sortNumber;
|
||||||
|
/**
|
||||||
|
* 备注
|
||||||
|
*/
|
||||||
|
private String comments;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 公司名称
|
||||||
|
*/
|
||||||
|
private String companyName;
|
||||||
|
/**
|
||||||
|
* 公司电话
|
||||||
|
*/
|
||||||
|
private String companyPhone;
|
||||||
|
/**
|
||||||
|
* 负责人姓名
|
||||||
|
*/
|
||||||
|
private String responsibleName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 负责人联系电话
|
||||||
|
*/
|
||||||
|
private String responsiblePhone;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
private Date createTime;
|
||||||
|
/**
|
||||||
|
* 修改时间
|
||||||
|
*/
|
||||||
|
private Date updateTime;
|
||||||
|
/**
|
||||||
|
* 是否删除,0否,1是
|
||||||
|
*/
|
||||||
|
@TableLogic
|
||||||
|
private Integer deleted;
|
||||||
|
/**
|
||||||
|
* 负责人姓名
|
||||||
|
*/
|
||||||
|
@TableField(exist = false)
|
||||||
|
private String leaderName;
|
||||||
|
/**
|
||||||
|
* 负责人账号
|
||||||
|
*/
|
||||||
|
@TableField(exist = false)
|
||||||
|
private String leaderAccount;
|
||||||
|
/**
|
||||||
|
* 上级名称
|
||||||
|
*/
|
||||||
|
@TableField(exist = false)
|
||||||
|
private String parentName;
|
||||||
|
/**
|
||||||
|
* 机构类型名称
|
||||||
|
*/
|
||||||
|
@TableField(exist = false)
|
||||||
|
private String organizationTypeName;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,140 @@
|
||||||
|
package com.gfwl.admin.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 角色
|
||||||
|
* Created by AutoGenerator on 2018-12-24 16:10
|
||||||
|
*/
|
||||||
|
@TableName("gf_sys_role")
|
||||||
|
public class Role implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
/**
|
||||||
|
* 角色id
|
||||||
|
*/
|
||||||
|
@TableId(value = "role_id", type = IdType.AUTO)
|
||||||
|
private Integer roleId;
|
||||||
|
/**
|
||||||
|
* 角色名称
|
||||||
|
*/
|
||||||
|
private String roleName;
|
||||||
|
/**
|
||||||
|
* 角色标识
|
||||||
|
*/
|
||||||
|
private String roleCode;
|
||||||
|
/**
|
||||||
|
* 备注
|
||||||
|
*/
|
||||||
|
private String comments;
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
private Date createTime;
|
||||||
|
/**
|
||||||
|
* 修改时间
|
||||||
|
*/
|
||||||
|
private Date updateTime;
|
||||||
|
/**
|
||||||
|
* 是否删除,0否,1是
|
||||||
|
*/
|
||||||
|
@TableLogic
|
||||||
|
private Integer deleted;
|
||||||
|
/**
|
||||||
|
* 用户id
|
||||||
|
*/
|
||||||
|
@TableField(exist = false)
|
||||||
|
private Integer userId;
|
||||||
|
|
||||||
|
public Role() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public Role(Integer roleId, String roleName) {
|
||||||
|
this(roleId, roleName, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Role(Integer roleId, String roleName, String comments) {
|
||||||
|
this.roleId = roleId;
|
||||||
|
this.roleName = roleName;
|
||||||
|
this.comments = comments;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getRoleId() {
|
||||||
|
return roleId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRoleId(Integer roleId) {
|
||||||
|
this.roleId = roleId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRoleName() {
|
||||||
|
return roleName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRoleName(String roleName) {
|
||||||
|
this.roleName = roleName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRoleCode() {
|
||||||
|
return roleCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRoleCode(String roleCode) {
|
||||||
|
this.roleCode = roleCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getComments() {
|
||||||
|
return comments;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setComments(String comments) {
|
||||||
|
this.comments = comments;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getCreateTime() {
|
||||||
|
return createTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCreateTime(Date createTime) {
|
||||||
|
this.createTime = createTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getUpdateTime() {
|
||||||
|
return updateTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUpdateTime(Date updateTime) {
|
||||||
|
this.updateTime = updateTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getDeleted() {
|
||||||
|
return deleted;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDeleted(Integer deleted) {
|
||||||
|
this.deleted = deleted;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getUserId() {
|
||||||
|
return userId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUserId(Integer userId) {
|
||||||
|
this.userId = userId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Role{" +
|
||||||
|
", roleId=" + roleId +
|
||||||
|
", roleName=" + roleName +
|
||||||
|
", comments=" + comments +
|
||||||
|
", createTime=" + createTime +
|
||||||
|
", updateTime=" + updateTime +
|
||||||
|
", deleted=" + deleted +
|
||||||
|
", userId=" + userId +
|
||||||
|
"}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,90 @@
|
||||||
|
package com.gfwl.admin.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 角色权限
|
||||||
|
* Created by AutoGenerator on 2018-12-24 16:10
|
||||||
|
*/
|
||||||
|
@TableName("gf_sys_role_menu")
|
||||||
|
public class RoleMenu implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
/**
|
||||||
|
* 主键id
|
||||||
|
*/
|
||||||
|
@TableId(value = "id", type = IdType.AUTO)
|
||||||
|
private Integer id;
|
||||||
|
/**
|
||||||
|
* 角色id
|
||||||
|
*/
|
||||||
|
private Integer roleId;
|
||||||
|
/**
|
||||||
|
* 菜单id
|
||||||
|
*/
|
||||||
|
private Integer menuId;
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
private Date createTime;
|
||||||
|
/**
|
||||||
|
* 修改时间
|
||||||
|
*/
|
||||||
|
private Date updateTime;
|
||||||
|
|
||||||
|
public Integer getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(Integer id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getRoleId() {
|
||||||
|
return roleId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRoleId(Integer roleId) {
|
||||||
|
this.roleId = roleId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getMenuId() {
|
||||||
|
return menuId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMenuId(Integer menuId) {
|
||||||
|
this.menuId = menuId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getCreateTime() {
|
||||||
|
return createTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCreateTime(Date createTime) {
|
||||||
|
this.createTime = createTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getUpdateTime() {
|
||||||
|
return updateTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUpdateTime(Date updateTime) {
|
||||||
|
this.updateTime = updateTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "RoleAuthorities{" +
|
||||||
|
", id=" + id +
|
||||||
|
", roleId=" + roleId +
|
||||||
|
", menuId=" + menuId +
|
||||||
|
", createTime=" + createTime +
|
||||||
|
", updateTime=" + updateTime +
|
||||||
|
"}";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,122 @@
|
||||||
|
package com.gfwl.admin.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户
|
||||||
|
* Created by AutoGenerator on 2018-12-24 16:10
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@TableName("gf_sys_user")
|
||||||
|
public class User implements Serializable {
|
||||||
|
private static final long serialVersionUID = 242146703513492331L;
|
||||||
|
/**
|
||||||
|
* 用户id
|
||||||
|
*/
|
||||||
|
@TableId(value = "user_id", type = IdType.AUTO)
|
||||||
|
private Integer userId;
|
||||||
|
/**
|
||||||
|
* 账号
|
||||||
|
*/
|
||||||
|
private String username;
|
||||||
|
/**
|
||||||
|
* 密码
|
||||||
|
*/
|
||||||
|
private String password;
|
||||||
|
/**
|
||||||
|
* 昵称
|
||||||
|
*/
|
||||||
|
private String nickName;
|
||||||
|
/**
|
||||||
|
* 头像
|
||||||
|
*/
|
||||||
|
private String avatar;
|
||||||
|
/**
|
||||||
|
* 性别
|
||||||
|
*/
|
||||||
|
private Integer sex;
|
||||||
|
/**
|
||||||
|
* 手机号
|
||||||
|
*/
|
||||||
|
private String phone;
|
||||||
|
/**
|
||||||
|
* 邮箱
|
||||||
|
*/
|
||||||
|
private String email;
|
||||||
|
/**
|
||||||
|
* 邮箱是否验证,0否,1是
|
||||||
|
*/
|
||||||
|
private Integer emailVerified;
|
||||||
|
/**
|
||||||
|
* 真实姓名
|
||||||
|
*/
|
||||||
|
private String trueName;
|
||||||
|
/**
|
||||||
|
* 身份证号
|
||||||
|
*/
|
||||||
|
private String idCard;
|
||||||
|
/**
|
||||||
|
* 出生日期
|
||||||
|
*/
|
||||||
|
private Date birthday;
|
||||||
|
/**
|
||||||
|
* 个人简介
|
||||||
|
*/
|
||||||
|
private String introduction;
|
||||||
|
/**
|
||||||
|
* 机构id
|
||||||
|
*/
|
||||||
|
private String organizationId;
|
||||||
|
/**
|
||||||
|
* 状态,0正常,1冻结
|
||||||
|
*/
|
||||||
|
private Integer state;
|
||||||
|
/**
|
||||||
|
* 注册时间
|
||||||
|
*/
|
||||||
|
private Date createTime;
|
||||||
|
/**
|
||||||
|
* 修改时间
|
||||||
|
*/
|
||||||
|
private Date updateTime;
|
||||||
|
/**
|
||||||
|
* 是否删除,0否,1是
|
||||||
|
*/
|
||||||
|
@TableLogic
|
||||||
|
private Integer deleted;
|
||||||
|
/**
|
||||||
|
* 权限列表
|
||||||
|
*/
|
||||||
|
@TableField(exist = false)
|
||||||
|
private List<String> authorities;
|
||||||
|
/**
|
||||||
|
* 角色列表
|
||||||
|
*/
|
||||||
|
@TableField(exist = false)
|
||||||
|
private List<Role> roles;
|
||||||
|
/**
|
||||||
|
* 角色id
|
||||||
|
*/
|
||||||
|
@TableField(exist = false)
|
||||||
|
private List<Integer> roleIds;
|
||||||
|
/**
|
||||||
|
* 机构名称
|
||||||
|
*/
|
||||||
|
@TableField(exist = false)
|
||||||
|
private String organizationName;
|
||||||
|
/**
|
||||||
|
* 性别名称
|
||||||
|
*/
|
||||||
|
@TableField(exist = false)
|
||||||
|
private String sexName;
|
||||||
|
|
||||||
|
public Integer getId() {
|
||||||
|
return userId;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,104 @@
|
||||||
|
package com.gfwl.admin.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 java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户角色
|
||||||
|
* Created by AutoGenerator on 2018-12-24 16:10
|
||||||
|
*/
|
||||||
|
@TableName("gf_sys_user_role")
|
||||||
|
public class UserRole implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
/**
|
||||||
|
* 主键id
|
||||||
|
*/
|
||||||
|
@TableId(value = "id", type = IdType.AUTO)
|
||||||
|
private Integer id;
|
||||||
|
/**
|
||||||
|
* 用户id
|
||||||
|
*/
|
||||||
|
private Integer userId;
|
||||||
|
/**
|
||||||
|
* 角色id
|
||||||
|
*/
|
||||||
|
private Integer roleId;
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
private Date createTime;
|
||||||
|
/**
|
||||||
|
* 修改时间
|
||||||
|
*/
|
||||||
|
private Date updateTime;
|
||||||
|
/**
|
||||||
|
* 角色名称
|
||||||
|
*/
|
||||||
|
@TableField(exist = false)
|
||||||
|
private String roleName;
|
||||||
|
|
||||||
|
public Integer getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(Integer id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getUserId() {
|
||||||
|
return userId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUserId(Integer userId) {
|
||||||
|
this.userId = userId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getRoleId() {
|
||||||
|
return roleId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRoleId(Integer roleId) {
|
||||||
|
this.roleId = roleId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getCreateTime() {
|
||||||
|
return createTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCreateTime(Date createTime) {
|
||||||
|
this.createTime = createTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getUpdateTime() {
|
||||||
|
return updateTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUpdateTime(Date updateTime) {
|
||||||
|
this.updateTime = updateTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRoleName() {
|
||||||
|
return roleName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRoleName(String roleName) {
|
||||||
|
this.roleName = roleName;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "UserRole{" +
|
||||||
|
", id=" + id +
|
||||||
|
", userId=" + userId +
|
||||||
|
", roleId=" + roleId +
|
||||||
|
", createTime=" + createTime +
|
||||||
|
", updateTime=" + updateTime +
|
||||||
|
", roleName=" + roleName +
|
||||||
|
"}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,27 @@
|
||||||
|
package com.gfwl.admin.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.gfwl.admin.base.PageParam;
|
||||||
|
import com.gfwl.admin.entity.DictionaryData;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字典项Mapper接口
|
||||||
|
* Created by wangfan on 2020-03-14 11:29:04
|
||||||
|
*/
|
||||||
|
public interface DictionaryDataMapper extends BaseMapper<DictionaryData> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询
|
||||||
|
*/
|
||||||
|
List<DictionaryData> listPage(@Param("page") PageParam<DictionaryData> page);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询全部
|
||||||
|
*/
|
||||||
|
List<DictionaryData> listAll(@Param("page") Map<String, Object> page);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
package com.gfwl.admin.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.gfwl.admin.entity.Dictionary;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字典Mapper接口
|
||||||
|
* Created by wangfan on 2020-03-14 11:29:03
|
||||||
|
*/
|
||||||
|
public interface DictionaryMapper extends BaseMapper<Dictionary> {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,27 @@
|
||||||
|
package com.gfwl.admin.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.gfwl.admin.base.PageParam;
|
||||||
|
import com.gfwl.admin.entity.LoginRecord;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 登录日志Mapper接口
|
||||||
|
* Created by wangfan on 2018-12-24 16:10
|
||||||
|
*/
|
||||||
|
public interface LoginRecordMapper extends BaseMapper<LoginRecord> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询
|
||||||
|
*/
|
||||||
|
List<LoginRecord> listPage(@Param("page") PageParam<LoginRecord> page);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询全部
|
||||||
|
*/
|
||||||
|
List<LoginRecord> listAll(@Param("page") Map<String, Object> page);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
package com.gfwl.admin.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.gfwl.admin.base.PageParam;
|
||||||
|
import com.gfwl.admin.entity.Menu;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 菜单Mapper接口
|
||||||
|
* Created by wangfan on 2018-12-24 16:10
|
||||||
|
*/
|
||||||
|
public interface MenuMapper extends BaseMapper<Menu> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询
|
||||||
|
*/
|
||||||
|
List<Menu> listPage(@Param("page") PageParam<Menu> page);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据用户id查询
|
||||||
|
*/
|
||||||
|
List<Menu> listByUserId(@Param("userId") Integer userId, @Param("menuType") Integer menuType);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,27 @@
|
||||||
|
package com.gfwl.admin.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.gfwl.admin.base.PageParam;
|
||||||
|
import com.gfwl.admin.entity.OperRecord;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 操作日志Mapper接口
|
||||||
|
* Created by wangfan on 2018-12-24 16:10
|
||||||
|
*/
|
||||||
|
public interface OperRecordMapper extends BaseMapper<OperRecord> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询
|
||||||
|
*/
|
||||||
|
List<OperRecord> listPage(@Param("page") PageParam<OperRecord> page);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询全部
|
||||||
|
*/
|
||||||
|
List<OperRecord> listAll(@Param("page") Map<String, Object> page);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,30 @@
|
||||||
|
package com.gfwl.admin.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.gfwl.admin.base.PageParam;
|
||||||
|
import com.gfwl.admin.entity.Organization;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 组织机构Mapper接口
|
||||||
|
* Created by wangfan on 2020-03-14 11:29:04
|
||||||
|
*/
|
||||||
|
public interface OrganizationMapper extends BaseMapper<Organization> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询
|
||||||
|
*/
|
||||||
|
List<Organization> listPage(@Param("page") PageParam<Organization> page);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询全部
|
||||||
|
*/
|
||||||
|
List<Organization> listAll(@Param("page") Map<String, Object> page);
|
||||||
|
|
||||||
|
|
||||||
|
Integer getByParentId(@Param("number") Integer number,@Param("parentId") String parentId);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
package com.gfwl.admin.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.gfwl.admin.entity.Role;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 角色Mapper接口
|
||||||
|
* Created by wangfan on 2018-12-24 16:10
|
||||||
|
*/
|
||||||
|
public interface RoleMapper extends BaseMapper<Role> {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
package com.gfwl.admin.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.gfwl.admin.entity.RoleMenu;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 角色权限Mapper接口
|
||||||
|
* Created by wangfan on 2018-12-24 16:10
|
||||||
|
*/
|
||||||
|
public interface RoleMenuMapper extends BaseMapper<RoleMenu> {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,27 @@
|
||||||
|
package com.gfwl.admin.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.gfwl.admin.base.PageParam;
|
||||||
|
import com.gfwl.admin.entity.User;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户Mapper接口
|
||||||
|
* Created by wangfan on 2018-12-24 16:10
|
||||||
|
*/
|
||||||
|
public interface UserMapper extends BaseMapper<User> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询
|
||||||
|
*/
|
||||||
|
List<User> listPage(@Param("page") PageParam<User> page);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询全部
|
||||||
|
*/
|
||||||
|
List<User> listAll(@Param("page") Map<String, Object> page);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
package com.gfwl.admin.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.gfwl.admin.entity.Role;
|
||||||
|
import com.gfwl.admin.entity.UserRole;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户角色Mapper接口
|
||||||
|
* Created by wangfan on 2018-12-24 16:10
|
||||||
|
*/
|
||||||
|
public interface UserRoleMapper extends BaseMapper<UserRole> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量添加用户角色
|
||||||
|
*/
|
||||||
|
int insertBatch(@Param("userId") Integer userId, @Param("roleIds") List<Integer> roleIds);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量查询用户角色
|
||||||
|
*/
|
||||||
|
List<Role> listByUserIds(@Param("userIds") List<Integer> userIds);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询某个用户的角色
|
||||||
|
*/
|
||||||
|
List<Role> listByUserId(@Param("userId") Integer userId);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,37 @@
|
||||||
|
package com.gfwl.admin.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.gfwl.admin.base.PageParam;
|
||||||
|
import com.gfwl.admin.base.PageResult;
|
||||||
|
import com.gfwl.admin.entity.DictionaryData;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字典项服务类
|
||||||
|
* Created by wangfan on 2020-03-14 11:29:04
|
||||||
|
*/
|
||||||
|
public interface DictionaryDataService extends IService<DictionaryData> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 关联分页查询
|
||||||
|
*/
|
||||||
|
PageResult<DictionaryData> listPage(PageParam<DictionaryData> page);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 关联查询所有
|
||||||
|
*/
|
||||||
|
List<DictionaryData> listAll(Map<String, Object> page);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据字典代码查询字典项
|
||||||
|
*/
|
||||||
|
List<DictionaryData> listByDictCode(String dictCode);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据字典代码和字典项名称查询字典项
|
||||||
|
*/
|
||||||
|
DictionaryData listByDictCodeAndName(String dictCode, String name);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
package com.gfwl.admin.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.gfwl.admin.entity.Dictionary;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字典服务类
|
||||||
|
* Created by wangfan on 2020-03-14 11:29:03
|
||||||
|
*/
|
||||||
|
public interface DictionaryService extends IService<Dictionary> {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,42 @@
|
||||||
|
package com.gfwl.admin.service;
|
||||||
|
|
||||||
|
import javax.mail.MessagingException;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送邮件
|
||||||
|
* Created by wangfan on 2019-06-19 04:07
|
||||||
|
*/
|
||||||
|
public interface EmailService {
|
||||||
|
/**
|
||||||
|
* 发送普通邮件
|
||||||
|
*
|
||||||
|
* @param title 标题
|
||||||
|
* @param content 内容
|
||||||
|
* @param toEmails 收件人
|
||||||
|
*/
|
||||||
|
void sendTextEmail(String title, String content, String[] toEmails);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送富文本邮件
|
||||||
|
*
|
||||||
|
* @param title 标题
|
||||||
|
* @param html 富文本
|
||||||
|
* @param toEmails 收件人
|
||||||
|
*/
|
||||||
|
void sendFullTextEmail(String title, String html, String[] toEmails) throws MessagingException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送html模板邮件
|
||||||
|
*
|
||||||
|
* @param title 标题
|
||||||
|
* @param htmlPath html路径
|
||||||
|
* @param map 填充数据
|
||||||
|
* @param toEmails 收件人
|
||||||
|
* @throws MessagingException MessagingException
|
||||||
|
* @throws IOException IOException
|
||||||
|
*/
|
||||||
|
void sendHtmlEmail(String title, String htmlPath, Map<String, Object> map, String[] toEmails) throws MessagingException, IOException;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,46 @@
|
||||||
|
package com.gfwl.admin.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.gfwl.admin.base.PageParam;
|
||||||
|
import com.gfwl.admin.base.PageResult;
|
||||||
|
import com.gfwl.admin.entity.LoginRecord;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 登录日志服务类
|
||||||
|
* Created by wangfan on 2018-12-24 16:10
|
||||||
|
*/
|
||||||
|
public interface LoginRecordService extends IService<LoginRecord> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 关联分页查询
|
||||||
|
*/
|
||||||
|
PageResult<LoginRecord> listPage(PageParam<LoginRecord> page);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 关联查询所有
|
||||||
|
*/
|
||||||
|
List<LoginRecord> listAll(Map<String, Object> page);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加登录日志
|
||||||
|
*
|
||||||
|
* @param username 用户账号
|
||||||
|
* @param type 操作类型
|
||||||
|
* @param comments 备注
|
||||||
|
* @param request HttpServletRequest
|
||||||
|
*/
|
||||||
|
void saveAsync(String username, Integer type, String comments, HttpServletRequest request);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加登录成功的登录日志
|
||||||
|
*
|
||||||
|
* @param username 用户账号
|
||||||
|
* @param request HttpServletRequest
|
||||||
|
*/
|
||||||
|
void saveAsync(String username, HttpServletRequest request);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,39 @@
|
||||||
|
package com.gfwl.admin.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.gfwl.admin.base.PageParam;
|
||||||
|
import com.gfwl.admin.base.PageResult;
|
||||||
|
import com.gfwl.admin.entity.Menu;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 菜单服务类
|
||||||
|
* Created by wangfan on 2018-12-24 16:10
|
||||||
|
*/
|
||||||
|
public interface MenuService extends IService<Menu> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 关联分页查询菜单
|
||||||
|
*/
|
||||||
|
PageResult<Menu> listPage(PageParam<Menu> pageParam);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据用户id查询菜单列表
|
||||||
|
*
|
||||||
|
* @param userId 用户id
|
||||||
|
* @param menuType 菜单类型,为null不筛选
|
||||||
|
* @return List<Menu>
|
||||||
|
*/
|
||||||
|
List<Menu> getUserMenu(Integer userId, Integer menuType);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 转化为树形结构
|
||||||
|
*
|
||||||
|
* @param menus 菜单list
|
||||||
|
* @param parentId 最顶级id
|
||||||
|
* @return List<Menu>
|
||||||
|
*/
|
||||||
|
List<Menu> toMenuTree(List<Menu> menus, Integer parentId);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
package com.gfwl.admin.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.gfwl.admin.base.PageParam;
|
||||||
|
import com.gfwl.admin.base.PageResult;
|
||||||
|
import com.gfwl.admin.entity.OperRecord;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 操作日志服务类
|
||||||
|
* Created by wangfan on 2018-12-24 16:10
|
||||||
|
*/
|
||||||
|
public interface OperRecordService extends IService<OperRecord> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 关联分页查询
|
||||||
|
*/
|
||||||
|
PageResult<OperRecord> listPage(PageParam<OperRecord> page);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 关联查询所有
|
||||||
|
*/
|
||||||
|
List<OperRecord> listAll(Map<String, Object> page);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 异步添加
|
||||||
|
*/
|
||||||
|
void saveAsync(OperRecord operRecord);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,45 @@
|
||||||
|
package com.gfwl.admin.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.gfwl.admin.base.PageParam;
|
||||||
|
import com.gfwl.admin.base.PageResult;
|
||||||
|
import com.gfwl.admin.entity.Organization;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 组织机构服务类
|
||||||
|
* Created by wangfan on 2020-03-14 11:29:04
|
||||||
|
*/
|
||||||
|
public interface OrganizationService extends IService<Organization> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 关联分页查询
|
||||||
|
*/
|
||||||
|
PageResult<Organization> listPage(PageParam<Organization> page);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 关联查询所有
|
||||||
|
*/
|
||||||
|
List<Organization> listAll(Map<String, Object> page);
|
||||||
|
|
||||||
|
Integer getByParentId(Integer number,String parentId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据OrganizationId 查询名称
|
||||||
|
* @param organizationId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
String getByOrganizationId(String organizationId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据机构类型获取数据
|
||||||
|
* @param organizationType
|
||||||
|
* @param organizationId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<Organization> getByOrganizationType(Integer organizationType,String organizationId);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
package com.gfwl.admin.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.gfwl.admin.entity.RoleMenu;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 角色菜单服务类
|
||||||
|
* Created by wangfan on 2018-12-24 16:10
|
||||||
|
*/
|
||||||
|
public interface RoleMenuService extends IService<RoleMenu> {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
package com.gfwl.admin.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.gfwl.admin.entity.Role;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 角色服务类
|
||||||
|
* Created by wangfan on 2018-12-24 16:10
|
||||||
|
*/
|
||||||
|
public interface RoleService extends IService<Role> {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
package com.gfwl.admin.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.gfwl.admin.entity.UserRole;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户角色服务类
|
||||||
|
* Created by wangfan on 2018-12-24 16:10
|
||||||
|
*/
|
||||||
|
public interface UserRoleService extends IService<UserRole> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询用户的角色id
|
||||||
|
*/
|
||||||
|
Integer[] getRoleIds(String userId);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,66 @@
|
||||||
|
package com.gfwl.admin.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.gfwl.admin.base.PageParam;
|
||||||
|
import com.gfwl.admin.base.PageResult;
|
||||||
|
import com.gfwl.admin.entity.User;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户服务类
|
||||||
|
* Created by wangfan on 2018-12-24 16:10
|
||||||
|
*/
|
||||||
|
public interface UserService extends IService<User> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据账号查询用户
|
||||||
|
*/
|
||||||
|
User getByUsername(String username);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据id查询用户(关联查询)
|
||||||
|
*/
|
||||||
|
User getFullById(Integer userId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询用户角色和权限
|
||||||
|
*/
|
||||||
|
User selectRoleAndAuth(User user);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 关联分页查询用户
|
||||||
|
*/
|
||||||
|
PageResult<User> listPage(PageParam<User> page);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 关联查询全部用户
|
||||||
|
*/
|
||||||
|
List<User> listAll(Map<String, Object> page);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加用户(包含角色)
|
||||||
|
*/
|
||||||
|
boolean saveUser(User user);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改用户(包含角色)
|
||||||
|
*/
|
||||||
|
boolean updateUser(User user);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 比较用户密码
|
||||||
|
*
|
||||||
|
* @param dbPsw 数据库存储的密码
|
||||||
|
* @param inputPsw 用户输入的密码
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
boolean comparePsw(String dbPsw, String inputPsw);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* md5加密用户密码
|
||||||
|
*/
|
||||||
|
String encodePsw(String psw);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,48 @@
|
||||||
|
package com.gfwl.admin.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.gfwl.admin.base.PageParam;
|
||||||
|
import com.gfwl.admin.base.PageResult;
|
||||||
|
import com.gfwl.admin.mapper.DictionaryDataMapper;
|
||||||
|
import com.gfwl.admin.entity.DictionaryData;
|
||||||
|
import com.gfwl.admin.service.DictionaryDataService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字典项服务实现类
|
||||||
|
* Created by wangfan on 2020-03-14 11:29:04
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class DictionaryDataServiceImpl extends ServiceImpl<DictionaryDataMapper, DictionaryData> implements DictionaryDataService {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageResult<DictionaryData> listPage(PageParam<DictionaryData> page) {
|
||||||
|
List<DictionaryData> records = baseMapper.listPage(page);
|
||||||
|
return new PageResult<>(records, page.getTotal());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<DictionaryData> listAll(Map<String, Object> page) {
|
||||||
|
return baseMapper.listAll(page);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<DictionaryData> listByDictCode(String dictCode) {
|
||||||
|
PageParam<DictionaryData> pageParam = new PageParam<>();
|
||||||
|
pageParam.put("dictCode", dictCode).setDefaultOrder(new String[]{"sort_number"}, null);
|
||||||
|
List<DictionaryData> records = baseMapper.listAll(pageParam.getNoPageParam());
|
||||||
|
return pageParam.sortRecords(records);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DictionaryData listByDictCodeAndName(String dictCode, String dictDataName) {
|
||||||
|
PageParam<DictionaryData> pageParam = new PageParam<>();
|
||||||
|
pageParam.put("dictCode", dictCode).put("dictDataName", dictDataName);
|
||||||
|
List<DictionaryData> records = baseMapper.listAll(pageParam.getNoPageParam());
|
||||||
|
return pageParam.getOne(records);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
package com.gfwl.admin.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.gfwl.admin.mapper.DictionaryMapper;
|
||||||
|
import com.gfwl.admin.entity.Dictionary;
|
||||||
|
import com.gfwl.admin.service.DictionaryService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字典服务实现类
|
||||||
|
* Created by wangfan on 2020-03-14 11:29:03
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class DictionaryServiceImpl extends ServiceImpl<DictionaryMapper, Dictionary> implements DictionaryService {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,64 @@
|
||||||
|
package com.gfwl.admin.service.impl;
|
||||||
|
|
||||||
|
import com.gfwl.admin.service.EmailService;
|
||||||
|
import org.beetl.core.Configuration;
|
||||||
|
import org.beetl.core.GroupTemplate;
|
||||||
|
import org.beetl.core.Template;
|
||||||
|
import org.beetl.core.resource.ClasspathResourceLoader;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.mail.SimpleMailMessage;
|
||||||
|
import org.springframework.mail.javamail.JavaMailSender;
|
||||||
|
import org.springframework.mail.javamail.MimeMessageHelper;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.mail.MessagingException;
|
||||||
|
import javax.mail.internet.MimeMessage;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送邮件
|
||||||
|
* Created by wangfan on 2019-06-19 04:07
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class EmailServiceImpl implements EmailService {
|
||||||
|
@Value("${spring.mail.username}")
|
||||||
|
private String formEmail; // 发件人
|
||||||
|
@Autowired
|
||||||
|
private JavaMailSender mailSender;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sendTextEmail(String title, String content, String[] toEmails) {
|
||||||
|
SimpleMailMessage message = new SimpleMailMessage();
|
||||||
|
message.setFrom(formEmail);
|
||||||
|
message.setTo(toEmails);
|
||||||
|
message.setSubject(title);
|
||||||
|
message.setText(content);
|
||||||
|
mailSender.send(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sendFullTextEmail(String title, String html, String[] toEmails) throws MessagingException {
|
||||||
|
MimeMessage mimeMessage = mailSender.createMimeMessage();
|
||||||
|
MimeMessageHelper helper = new MimeMessageHelper(mimeMessage, true);
|
||||||
|
helper.setFrom(formEmail);
|
||||||
|
helper.setTo(toEmails);
|
||||||
|
helper.setSubject(title);
|
||||||
|
// 发送邮件
|
||||||
|
helper.setText(html, true);
|
||||||
|
mailSender.send(mimeMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sendHtmlEmail(String title, String htmlPath, Map<String, Object> map, String[] toEmails) throws MessagingException, IOException {
|
||||||
|
ClasspathResourceLoader resourceLoader = new ClasspathResourceLoader("templates/");
|
||||||
|
Configuration cfg = Configuration.defaultConfiguration();
|
||||||
|
GroupTemplate gt = new GroupTemplate(resourceLoader, cfg);
|
||||||
|
Template t = gt.getTemplate(htmlPath); // 加载html模板
|
||||||
|
t.binding(map); // 填充数据
|
||||||
|
String html = t.render(); // 获得渲染后的html
|
||||||
|
sendFullTextEmail(title, html, toEmails); // 发送邮件
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,59 @@
|
||||||
|
package com.gfwl.admin.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.gfwl.admin.base.PageParam;
|
||||||
|
import com.gfwl.admin.base.PageResult;
|
||||||
|
import com.gfwl.utils.UserAgentGetter;
|
||||||
|
import com.gfwl.admin.mapper.LoginRecordMapper;
|
||||||
|
import com.gfwl.admin.entity.LoginRecord;
|
||||||
|
import com.gfwl.admin.service.LoginRecordService;
|
||||||
|
import org.springframework.scheduling.annotation.Async;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 登录日志服务实现类
|
||||||
|
* Created by wangfan on 2018-12-24 16:10
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class LoginRecordServiceImpl extends ServiceImpl<LoginRecordMapper, LoginRecord> implements LoginRecordService {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageResult<LoginRecord> listPage(PageParam<LoginRecord> page) {
|
||||||
|
List<LoginRecord> records = baseMapper.listPage(page);
|
||||||
|
return new PageResult<>(records, page.getTotal());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<LoginRecord> listAll(Map<String, Object> page) {
|
||||||
|
return baseMapper.listAll(page);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void saveAsync(String username, Integer type, String comments, HttpServletRequest request) {
|
||||||
|
LoginRecord loginRecord = new LoginRecord();
|
||||||
|
loginRecord.setUsername(username);
|
||||||
|
loginRecord.setOperType(type);
|
||||||
|
loginRecord.setComments(comments);
|
||||||
|
UserAgentGetter agentGetter = new UserAgentGetter(request);
|
||||||
|
loginRecord.setOs(agentGetter.getOS());
|
||||||
|
loginRecord.setDevice(agentGetter.getDevice());
|
||||||
|
loginRecord.setBrowser(agentGetter.getBrowser());
|
||||||
|
loginRecord.setIp(agentGetter.getIp());
|
||||||
|
saveAsync(loginRecord);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void saveAsync(String username, HttpServletRequest request) {
|
||||||
|
saveAsync(username, LoginRecord.TYPE_LOGIN, null, request);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Async
|
||||||
|
public void saveAsync(LoginRecord loginRecord) {
|
||||||
|
baseMapper.insert(loginRecord);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,41 @@
|
||||||
|
package com.gfwl.admin.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.gfwl.admin.base.PageParam;
|
||||||
|
import com.gfwl.admin.base.PageResult;
|
||||||
|
import com.gfwl.admin.mapper.MenuMapper;
|
||||||
|
import com.gfwl.admin.entity.Menu;
|
||||||
|
import com.gfwl.admin.service.MenuService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 菜单服务实现类
|
||||||
|
* Created by wangfan on 2018-12-24 16:10
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements MenuService {
|
||||||
|
@Override
|
||||||
|
public PageResult<Menu> listPage(PageParam<Menu> pageParam) {
|
||||||
|
return new PageResult<>(baseMapper.listPage(pageParam), pageParam.getTotal());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Menu> getUserMenu(Integer userId, Integer menuType) {
|
||||||
|
return baseMapper.listByUserId(userId, menuType);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Menu> toMenuTree(List<Menu> menus, Integer parentId) {
|
||||||
|
List<Menu> list = new ArrayList<>();
|
||||||
|
for (Menu menu : menus) {
|
||||||
|
if (parentId.equals(menu.getParentId())) {
|
||||||
|
menu.setChildren(toMenuTree(menus, menu.getMenuId()));
|
||||||
|
list.add(menu);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,39 @@
|
||||||
|
package com.gfwl.admin.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.gfwl.admin.base.PageParam;
|
||||||
|
import com.gfwl.admin.base.PageResult;
|
||||||
|
import com.gfwl.admin.entity.OperRecord;
|
||||||
|
import com.gfwl.admin.mapper.OperRecordMapper;
|
||||||
|
import com.gfwl.admin.service.OperRecordService;
|
||||||
|
import org.springframework.scheduling.annotation.Async;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 操作日志服务实现类
|
||||||
|
* Created by wangfan on 2018-12-24 16:10
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class OperRecordServiceImpl extends ServiceImpl<OperRecordMapper, OperRecord> implements OperRecordService {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageResult<OperRecord> listPage(PageParam<OperRecord> page) {
|
||||||
|
List<OperRecord> records = baseMapper.listPage(page);
|
||||||
|
return new PageResult<>(records, page.getTotal());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<OperRecord> listAll(Map<String, Object> page) {
|
||||||
|
return baseMapper.listAll(page);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Async
|
||||||
|
@Override
|
||||||
|
public void saveAsync(OperRecord operRecord) {
|
||||||
|
baseMapper.insert(operRecord);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,59 @@
|
||||||
|
package com.gfwl.admin.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.gfwl.admin.base.PageParam;
|
||||||
|
import com.gfwl.admin.base.PageResult;
|
||||||
|
import com.gfwl.admin.mapper.OrganizationMapper;
|
||||||
|
import com.gfwl.admin.entity.Organization;
|
||||||
|
import com.gfwl.admin.service.OrganizationService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 组织机构服务实现类
|
||||||
|
* Created by wangfan on 2020-03-14 11:29:04
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class OrganizationServiceImpl extends ServiceImpl<OrganizationMapper, Organization> implements OrganizationService {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageResult<Organization> listPage(PageParam<Organization> page) {
|
||||||
|
List<Organization> records = baseMapper.listPage(page);
|
||||||
|
return new PageResult<>(records, page.getTotal( ));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Organization> listAll(Map<String, Object> page) {
|
||||||
|
return baseMapper.listAll(page);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer getByParentId(Integer number, String parentId) {
|
||||||
|
return baseMapper.getByParentId(number, parentId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getByOrganizationId(String organizationId) {
|
||||||
|
|
||||||
|
LambdaQueryWrapper<Organization> queryWrapper = new QueryWrapper<Organization>( ).lambda( )
|
||||||
|
.eq(Organization::getOrganizationId, organizationId);
|
||||||
|
|
||||||
|
Organization organization = baseMapper.selectOne(queryWrapper);
|
||||||
|
if (organization != null) {
|
||||||
|
return organization.getOrganizationName( );
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Organization> getByOrganizationType(Integer organizationType, String organizationId) {
|
||||||
|
LambdaQueryWrapper<Organization> queryWrapper = new QueryWrapper<Organization>( ).lambda( )
|
||||||
|
.eq(Organization::getOrganizationType, organizationType)
|
||||||
|
.likeRight(Organization::getOrganizationId,organizationId);
|
||||||
|
return baseMapper.selectList(queryWrapper);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
package com.gfwl.admin.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.gfwl.admin.mapper.RoleMenuMapper;
|
||||||
|
import com.gfwl.admin.entity.RoleMenu;
|
||||||
|
import com.gfwl.admin.service.RoleMenuService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 角色菜单服务实现类
|
||||||
|
* Created by wangfan on 2018-12-24 16:10
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class RoleMenuServiceImpl extends ServiceImpl<RoleMenuMapper, RoleMenu> implements RoleMenuService {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
package com.gfwl.admin.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.gfwl.admin.mapper.RoleMapper;
|
||||||
|
import com.gfwl.admin.entity.Role;
|
||||||
|
import com.gfwl.admin.service.RoleService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 角色服务实现类
|
||||||
|
* Created by wangfan on 2018-12-24 16:10
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements RoleService {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,29 @@
|
||||||
|
package com.gfwl.admin.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.gfwl.admin.mapper.UserRoleMapper;
|
||||||
|
import com.gfwl.admin.entity.UserRole;
|
||||||
|
import com.gfwl.admin.service.UserRoleService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户角色服务实现类
|
||||||
|
* Created by wangfan on 2018-12-24 16:10
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class UserRoleServiceImpl extends ServiceImpl<UserRoleMapper, UserRole> implements UserRoleService {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer[] getRoleIds(String userId) {
|
||||||
|
List<UserRole> userRoles = baseMapper.selectList(new QueryWrapper<UserRole>().eq("user_id", userId));
|
||||||
|
Integer[] roleIds = new Integer[userRoles.size()];
|
||||||
|
for (int i = 0; i < userRoles.size(); i++) {
|
||||||
|
roleIds[i] = userRoles.get(i).getRoleId();
|
||||||
|
}
|
||||||
|
return roleIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,168 @@
|
||||||
|
package com.gfwl.admin.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.gfwl.admin.base.PageParam;
|
||||||
|
import com.gfwl.admin.base.PageResult;
|
||||||
|
import com.gfwl.config.exception.BusinessException;
|
||||||
|
import com.gfwl.admin.entity.Menu;
|
||||||
|
import com.gfwl.admin.mapper.MenuMapper;
|
||||||
|
import com.gfwl.admin.mapper.UserMapper;
|
||||||
|
import com.gfwl.admin.mapper.UserRoleMapper;
|
||||||
|
import com.gfwl.admin.entity.Role;
|
||||||
|
import com.gfwl.admin.entity.User;
|
||||||
|
import com.gfwl.admin.entity.UserRole;
|
||||||
|
import com.gfwl.admin.service.UserService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.util.DigestUtils;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户服务实现类
|
||||||
|
* Created by wangfan on 2018-12-24 16:10
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {
|
||||||
|
@Autowired
|
||||||
|
private UserRoleMapper userRoleMapper;
|
||||||
|
@Autowired
|
||||||
|
private MenuMapper menuMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public User getByUsername(String username) {
|
||||||
|
return baseMapper.selectOne(new QueryWrapper<User>().eq("username", username));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public User getFullById(Integer userId) {
|
||||||
|
List<User> userList = baseMapper.listAll(new PageParam<User>().put("userId", userId).getNoPageParam());
|
||||||
|
if (userList == null || userList.size() == 0) return null;
|
||||||
|
return selectRoleAndAuth(userList.get(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public User selectRoleAndAuth(User user) {
|
||||||
|
user.setRoles(userRoleMapper.listByUserId(user.getUserId()));
|
||||||
|
List<Menu> menus = menuMapper.listByUserId(user.getUserId(), null);
|
||||||
|
List<String> auths = new ArrayList<>();
|
||||||
|
for (Menu menu : menus) {
|
||||||
|
auths.add(menu.getAuthority());
|
||||||
|
}
|
||||||
|
user.setAuthorities(auths);
|
||||||
|
return user;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageResult<User> listPage(PageParam<User> page) {
|
||||||
|
List<User> users = baseMapper.listPage(page);
|
||||||
|
// 查询用户的角色
|
||||||
|
selectUserRoles(users);
|
||||||
|
return new PageResult<>(users, page.getTotal());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<User> listAll(Map<String, Object> page) {
|
||||||
|
List<User> users = baseMapper.listAll(page);
|
||||||
|
// 查询用户的角色
|
||||||
|
selectUserRoles(users);
|
||||||
|
return users;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
@Override
|
||||||
|
public boolean saveUser(User user) {
|
||||||
|
if (user.getUsername() != null && baseMapper.selectCount(new QueryWrapper<User>()
|
||||||
|
.eq("username", user.getUsername())) > 0) {
|
||||||
|
throw new BusinessException("账号已存在");
|
||||||
|
}
|
||||||
|
if (user.getPhone() != null && baseMapper.selectCount(new QueryWrapper<User>()
|
||||||
|
.eq("phone", user.getPhone())) > 0) {
|
||||||
|
throw new BusinessException("手机号已存在");
|
||||||
|
}
|
||||||
|
if (user.getEmail() != null && baseMapper.selectCount(new QueryWrapper<User>()
|
||||||
|
.eq("email", user.getEmail())) > 0) {
|
||||||
|
throw new BusinessException("邮箱已存在");
|
||||||
|
}
|
||||||
|
boolean result = baseMapper.insert(user) > 0;
|
||||||
|
if (result && user.getRoleIds() != null) {
|
||||||
|
addUserRoles(user.getUserId(), user.getRoleIds(), false);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
@Override
|
||||||
|
public boolean updateUser(User user) {
|
||||||
|
if (user.getUsername() != null && baseMapper.selectCount(new QueryWrapper<User>()
|
||||||
|
.eq("username", user.getUsername()).ne("user_id", user.getUserId())) > 0) {
|
||||||
|
throw new BusinessException("账号已存在");
|
||||||
|
}
|
||||||
|
if (user.getPhone() != null && baseMapper.selectCount(new QueryWrapper<User>()
|
||||||
|
.eq("phone", user.getPhone()).ne("user_id", user.getUserId())) > 0) {
|
||||||
|
throw new BusinessException("手机号已存在");
|
||||||
|
}
|
||||||
|
if (user.getEmail() != null && baseMapper.selectCount(new QueryWrapper<User>()
|
||||||
|
.eq("email", user.getEmail()).ne("user_id", user.getUserId())) > 0) {
|
||||||
|
throw new BusinessException("邮箱已存在");
|
||||||
|
}
|
||||||
|
boolean result = baseMapper.updateById(user) > 0;
|
||||||
|
if (result && user.getRoleIds() != null) {
|
||||||
|
addUserRoles(user.getUserId(), user.getRoleIds(), true);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean comparePsw(String dbPsw, String inputPsw) {
|
||||||
|
return dbPsw != null && dbPsw.equals(encodePsw(inputPsw));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String encodePsw(String psw) {
|
||||||
|
if (psw == null) return null;
|
||||||
|
return DigestUtils.md5DigestAsHex(psw.getBytes());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询用户的角色
|
||||||
|
*/
|
||||||
|
private void selectUserRoles(List<User> users) {
|
||||||
|
if (users != null && users.size() > 0) {
|
||||||
|
List<Integer> userIds = new ArrayList<>();
|
||||||
|
for (User one : users) {
|
||||||
|
userIds.add(one.getUserId());
|
||||||
|
}
|
||||||
|
List<Role> userRoles = userRoleMapper.listByUserIds(userIds);
|
||||||
|
for (User user : users) {
|
||||||
|
List<Role> roles = new ArrayList<>();
|
||||||
|
for (Role userRole : userRoles) {
|
||||||
|
if (user.getUserId().equals(userRole.getUserId())) {
|
||||||
|
roles.add(userRole);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
user.setRoles(roles);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加用户角色
|
||||||
|
*/
|
||||||
|
private void addUserRoles(Integer userId, List<Integer> roleIds, boolean deleteOld) {
|
||||||
|
if (deleteOld) {
|
||||||
|
userRoleMapper.delete(new UpdateWrapper<UserRole>().eq("user_id", userId));
|
||||||
|
}
|
||||||
|
if (roleIds.size() > 0) {
|
||||||
|
if (userRoleMapper.insertBatch(userId, roleIds) < roleIds.size()) {
|
||||||
|
throw new BusinessException("操作失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,40 @@
|
||||||
|
package com.gfwl.api;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName ApiConst
|
||||||
|
* @Description: TODO
|
||||||
|
* @Author alang
|
||||||
|
* @Date 8-8 第2周
|
||||||
|
* @Version V1.0
|
||||||
|
**/
|
||||||
|
public interface ApiConst {
|
||||||
|
|
||||||
|
|
||||||
|
interface LOGIN_TYPE {
|
||||||
|
String WX = "e4f7795638ff4abc909215e0bdbebda7";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 小程序登录参数
|
||||||
|
*/
|
||||||
|
interface APPLETS_LOIN{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 小程序APPID
|
||||||
|
*/
|
||||||
|
String appId = "wx6f0154623d89cecd";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 小程序秘钥
|
||||||
|
*/
|
||||||
|
String secret = "0e0dcb9c9eb0cfd61c4178421693b7ae";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 支付方式
|
||||||
|
*/
|
||||||
|
interface PAY_TYPE {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,178 @@
|
||||||
|
package com.gfwl.api.base;
|
||||||
|
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.gfwl.common.entity.BusUser;
|
||||||
|
import com.gfwl.config.consts.Global;
|
||||||
|
import com.gfwl.config.exception.ApiException;
|
||||||
|
import com.gfwl.config.redis.RedisUtils;
|
||||||
|
import com.gfwl.utils.aliyun.SendSmsUtil;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName BaseApiController
|
||||||
|
* @Description: TODO
|
||||||
|
* @Author jianpòlan
|
||||||
|
* @Date 6-24 第4周
|
||||||
|
* @Version V1.0
|
||||||
|
**/
|
||||||
|
@Slf4j
|
||||||
|
public class BaseApiController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
protected RedisUtils redis;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
protected HttpServletRequest request;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
protected SendSmsUtil smsUtil;
|
||||||
|
|
||||||
|
|
||||||
|
protected boolean isNull(String str) {
|
||||||
|
return StringUtils.isBlank(str) || StringUtils.isEmpty(str) || str.replace(" ", "").length( ) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean isNull(Object obj) {
|
||||||
|
|
||||||
|
return obj == null || isNull(obj.toString( ));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected String getToken() {
|
||||||
|
return request.getHeader(Global.header_key);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected BusUser getLoginUser() {
|
||||||
|
Object userJson = redis.get(Global.redis_login + getToken( ));
|
||||||
|
if (userJson == null) {
|
||||||
|
throw new ApiException(CodesEnum.NOT_LOGIN, CodesEnum.NOT_LOGIN.getMessage( ));
|
||||||
|
}
|
||||||
|
redis.expire(Global.redis_login + getToken( ), Global.login_expire_time);
|
||||||
|
return JSONObject.parseObject(userJson.toString( ), BusUser.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean logout() {
|
||||||
|
Object userJson = redis.get(Global.redis_login + getToken( ));
|
||||||
|
if (userJson != null) {
|
||||||
|
redis.del(Global.redis_login + getToken( ));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected String getUserId() {
|
||||||
|
return getLoginUser( ).getId( );
|
||||||
|
}
|
||||||
|
|
||||||
|
// protected String getUserIdNoThrow() {
|
||||||
|
// Object userJson = redis.get(Global.redis_login + getToken( ));
|
||||||
|
// if (userJson == null) {
|
||||||
|
// return "1";
|
||||||
|
// } else {
|
||||||
|
// redis.expire(Global.redis_login + getToken( ), Global.login_expire_time);
|
||||||
|
// UserInfo userInfo = JSONObject.parseObject(userJson.toString( ), UserInfo.class);
|
||||||
|
// return userInfo.getId( );
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
////
|
||||||
|
//// protected String getUserId_Not_Exception() {
|
||||||
|
//// String token = getToken( );
|
||||||
|
//// if (isNull(token)) {
|
||||||
|
//// throw new ApiException(CodesEnum.NOT_LOGIN, CodesEnum.NOT_LOGIN.getMessage( ));
|
||||||
|
//// }
|
||||||
|
//// Object userJson = redis.get(Global.redis_login + token);
|
||||||
|
//// if (userJson == null) {
|
||||||
|
//// throw new ApiException(CodesEnum.NOT_LOGIN, CodesEnum.NOT_LOGIN.getMessage( ));
|
||||||
|
//// }
|
||||||
|
//// return JSONObject.parseObject(userJson.toString( ), UserInfo.class).getId( );
|
||||||
|
//// }
|
||||||
|
////
|
||||||
|
protected void saveUserInfo(String token, BusUser userInfo) {
|
||||||
|
expireOldLogin(userInfo);
|
||||||
|
setKey(Global.redis_login + token, JSONObject.toJSONString(userInfo), Global.login_expire_time);
|
||||||
|
setKey(Global.header_key_extend + userInfo.getId( ), token);// key 用户ID value 用户token
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新用户
|
||||||
|
*
|
||||||
|
* @param userInfo
|
||||||
|
*/
|
||||||
|
protected void updateRedisUserInfo(BusUser userInfo) {
|
||||||
|
Object o = redis.get(Global.header_key_extend + userInfo.getId( )); // token
|
||||||
|
if (o != null) {
|
||||||
|
setKey(Global.redis_login + o, JSONObject.toJSONString(userInfo), Global.login_expire_time);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void expireOldLogin(BusUser userInfo) {
|
||||||
|
//获取用户token
|
||||||
|
Object o = redis.get(Global.header_key_extend + userInfo.getId( )); // token
|
||||||
|
if (o != null) {
|
||||||
|
redis.set(Global.redis_login + (String) o, "expire", 60); // 设置用户token
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setKey(String key, String value) {
|
||||||
|
redis.set(key, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setKey(String key, String value, long second) {
|
||||||
|
redis.set(key, value, second);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Object getKey(String key) {
|
||||||
|
return redis.get(key) == null ? null : redis.get(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// protected UserInfo getUserById(String userId){
|
||||||
|
// Object o = redis.get(String.format(ScheduledConfig.user_info_format, userId));
|
||||||
|
// if(o == null){
|
||||||
|
// UserInfo userInfo = userInfoService.getById(userId);
|
||||||
|
// if(userInfo != null){
|
||||||
|
// redis.set(String.format(ScheduledConfig.user_info_format, userInfo.getId()), JSONObject.toJSONString(userInfo));
|
||||||
|
// return userInfo;
|
||||||
|
// }
|
||||||
|
// return null;
|
||||||
|
// }
|
||||||
|
// return JSONObject.parseObject(o.toString(), UserInfo.class);
|
||||||
|
// }
|
||||||
|
|
||||||
|
protected void isNullObjAndThrow(Object object) {
|
||||||
|
if (isNull(object)) {
|
||||||
|
throw new ApiException(CodesEnum.DATA_NOT_FOUND, CodesEnum.DATA_NOT_FOUND.getMessage( ));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void isNullParams(Object object) {
|
||||||
|
if (isNull(object)) {
|
||||||
|
throw new ApiException(CodesEnum.PARAMS_ERROR, CodesEnum.PARAMS_ERROR.getMessage( ));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void isNullObjAndThrow(Object object, CodesEnum codesEnum) {
|
||||||
|
if (isNull(object)) {
|
||||||
|
throw new ApiException(codesEnum, codesEnum.getMessage( ));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void isNullObjAndThrow(Object object, String message) {
|
||||||
|
if (isNull(object)) {
|
||||||
|
throw new ApiException(CodesEnum.PARAMS_ERROR, message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void throwException(boolean object, String message) {
|
||||||
|
if (object) {
|
||||||
|
throw new ApiException(CodesEnum.PARAMS_ERROR, message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
package com.gfwl.api.base;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName BaseEntity
|
||||||
|
* @Description: TODO
|
||||||
|
* @Author jianpòlan
|
||||||
|
* @Date 6-4 第1周
|
||||||
|
* @Version V1.0
|
||||||
|
**/
|
||||||
|
@Data
|
||||||
|
@ApiModel
|
||||||
|
public abstract class BaseEntity <T extends Model<T>> extends Model<T> {
|
||||||
|
|
||||||
|
@ApiModelProperty(notes = "数据ID")
|
||||||
|
@TableId(value = "id",type= IdType.ASSIGN_UUID)
|
||||||
|
protected String id;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Serializable pkVal() {
|
||||||
|
return this.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,67 @@
|
||||||
|
package com.gfwl.api.base;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.enums.IEnum;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonValue;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName Codes
|
||||||
|
* @Description: TODO
|
||||||
|
* @Author alang
|
||||||
|
* @Date 6-24 第4周
|
||||||
|
* @Version V1.0
|
||||||
|
**/
|
||||||
|
@ApiModel(description = "返回状态值")
|
||||||
|
public enum CodesEnum implements IEnum<Integer> {
|
||||||
|
SUCCESS(200, "操作成功!"),
|
||||||
|
ERROR(500, "服务器错误!"),
|
||||||
|
FAILED(501, "服务器错误!"),
|
||||||
|
TOKEN_NOT_EXISTS(502, "token不存在!"),
|
||||||
|
PARAMS_ERROR(503, "参数不正确或丢失!"),
|
||||||
|
PHONE_PARSING_FAILED(504, "手机号解析失败!"),
|
||||||
|
WX_ERROR(505, "微信调用错误,详细请看微信返回值!"),
|
||||||
|
NOT_LOGIN(506, "未登录!"),
|
||||||
|
USER_NOT_FOUND(507, "用户不存在!"),
|
||||||
|
DX_SEND_ERROR(508, "短信发送异常!"),
|
||||||
|
CODE_ERROR(509, "验证码错误!"),
|
||||||
|
ALREADY_BIND(510, "手机号已绑定!"),
|
||||||
|
DATA_NOT_FOUND(511, "数据不存在!"),
|
||||||
|
IMAGE_RESOURCE_NOT_FOUND(512, "图片不存在!"),
|
||||||
|
ALREADY_REGISTER(513, "手机号已注册!"),
|
||||||
|
PHONE_NOT_MATCH(514, "手机号不匹配!"),
|
||||||
|
DATA_ALREADY_EXISTS(515, "数据已存在!"),
|
||||||
|
UPLOAD_ERROR(516, "文件上传出错!"),
|
||||||
|
CREATE_LIVE_ERROR(517, "创建直播失败!"),
|
||||||
|
OTHER_LOGIN(518, "您的账号在其他设备登陆 需要您重新登陆验证!"),
|
||||||
|
ILLEGAL_NICKNAME(519, "昵称中含有非法内容,请修改后重试!"),
|
||||||
|
ALREADY_APPLY(520, "已预约!"),
|
||||||
|
FOOD_NO_ERROR(521, "商品不存在!"),
|
||||||
|
FOOD_NO_INVENT_ERROR(522, "库存不足!"),
|
||||||
|
NO_REPEAT_SUBMIT(523, "重复提交!"),
|
||||||
|
ORDER_NO_PAY(524, "订单无法支付!"),
|
||||||
|
ORDER_NO_EVALUATION(525, "订单无法评价!"),
|
||||||
|
|
||||||
|
|
||||||
|
TENCENT_ERROR(600, "TENCENT_ERROR!"),
|
||||||
|
CALLBACK_ERROR(700, "支付回调参数解析异常!"),
|
||||||
|
NOT_IMPLEMENTS(1000, "方法未全部实现,如需使用请联系开发者!"),
|
||||||
|
;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private Integer code;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private String message;
|
||||||
|
|
||||||
|
CodesEnum(int code, String message) {
|
||||||
|
this.code = code;
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@JsonValue
|
||||||
|
public Integer getValue() {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,49 @@
|
||||||
|
package com.gfwl.api.base;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||||
|
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName DataEntity
|
||||||
|
* @Description: TODO
|
||||||
|
* @Author jianpòlan
|
||||||
|
* @Date 6-4 第1周
|
||||||
|
* @Version V1.0
|
||||||
|
**/
|
||||||
|
@Data
|
||||||
|
@ApiModel
|
||||||
|
public class DataEntity<T extends Model<T>> extends BaseEntity<T> {
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "数据创建时间", notes = "数据创建时间", dataType="java.lang.String")
|
||||||
|
@JsonFormat(pattern="yyyy/MM/dd HH:mm:ss",timezone="GMT+8")
|
||||||
|
@TableField(value = "create_date",fill = FieldFill.INSERT)
|
||||||
|
protected Date createDate;
|
||||||
|
|
||||||
|
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
|
||||||
|
@ApiModelProperty(value = "数据修改时间", notes = "数据修改时间", dataType="java.lang.String")
|
||||||
|
@TableField(value = "update_date",fill = FieldFill.INSERT_UPDATE)
|
||||||
|
protected Date updateDate;
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
@TableLogic
|
||||||
|
@ApiModelProperty("逻辑删除标识(0:未删除,1:已删除)")
|
||||||
|
@TableField(value = "deleted")
|
||||||
|
protected Boolean deleted = false;
|
||||||
|
|
||||||
|
// @JsonIgnore
|
||||||
|
// @Version
|
||||||
|
// @ApiModelProperty("数据版本")
|
||||||
|
// @TableField(value = "version",fill = FieldFill.UPDATE)
|
||||||
|
// private Integer version=0;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,64 @@
|
||||||
|
package com.gfwl.api.base;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName DataEntity
|
||||||
|
* @Description: TODO
|
||||||
|
* @Author jianpòlan
|
||||||
|
* @Date 6-4 第1周
|
||||||
|
* @Version V1.0
|
||||||
|
**/
|
||||||
|
@ApiModel(value = "接口统一返回类")
|
||||||
|
@Data
|
||||||
|
public class R<T> implements Serializable {
|
||||||
|
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "状态码")
|
||||||
|
private CodesEnum code = CodesEnum.SUCCESS;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "数据")
|
||||||
|
private T data;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "中文说明")
|
||||||
|
private String message = "请求成功";
|
||||||
|
|
||||||
|
public R(){}
|
||||||
|
|
||||||
|
public R(T data) {
|
||||||
|
this.data = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public R(CodesEnum code, String message){
|
||||||
|
this.code = code;
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public R(CodesEnum code, String message, T data){
|
||||||
|
this.code = code;
|
||||||
|
this.message = message;
|
||||||
|
this.data = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static<T> R<T> success() {
|
||||||
|
return new R();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static<T> R<T> success(T data) {
|
||||||
|
return new R(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static<T> R<T> failed(CodesEnum code, String message) {
|
||||||
|
return new R(code, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static<T> R<T> failed() {
|
||||||
|
return new R(CodesEnum.FAILED, CodesEnum.FAILED.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,159 @@
|
||||||
|
package com.gfwl.api.controller;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
|
import com.gfwl.api.base.BaseApiController;
|
||||||
|
import com.gfwl.api.vo.order.OrderTableDTO;
|
||||||
|
import com.gfwl.api.vo.order.OrderTableNoOrderParm;
|
||||||
|
import com.gfwl.common.entity.BusFood;
|
||||||
|
import com.gfwl.common.entity.BusOrder;
|
||||||
|
import com.gfwl.common.entity.BusSellTime;
|
||||||
|
import com.gfwl.common.entity.BusTables;
|
||||||
|
import com.gfwl.common.service.BusFoodService;
|
||||||
|
import com.gfwl.common.service.BusOrderService;
|
||||||
|
import com.gfwl.common.service.BusSellTimeService;
|
||||||
|
import com.gfwl.common.service.BusTablesService;
|
||||||
|
import com.gfwl.config.consts.Global;
|
||||||
|
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiImplicitParam;
|
||||||
|
import io.swagger.annotations.ApiImplicitParams;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @className: BusFoodContrller
|
||||||
|
*
|
||||||
|
* Created by 小明
|
||||||
|
* @create: 2023-05-30 21:43
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@Api(
|
||||||
|
value = "商品接口",
|
||||||
|
tags = {"商品接口"},
|
||||||
|
produces = "application/json"
|
||||||
|
)
|
||||||
|
@ApiSupport(author = Global.interface_author)
|
||||||
|
@RequestMapping("/api/v2/food")
|
||||||
|
public class BusFoodContrller extends BaseApiController {
|
||||||
|
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
BusFoodService busFoodService;
|
||||||
|
@Resource
|
||||||
|
private BusSellTimeService busSellTimeService;
|
||||||
|
@Resource
|
||||||
|
private BusOrderService orderService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private BusTablesService tablesService;
|
||||||
|
|
||||||
|
@ApiOperation(httpMethod = "GET", value = "获取一天的桌子", protocols = "http")
|
||||||
|
@ApiImplicitParams({
|
||||||
|
@ApiImplicitParam(name = "shellId", value = "时间端ID", dataType = "String", paramType = "String", required = true),
|
||||||
|
@ApiImplicitParam(name = "sellDate", value = "日期:yyyy-MM-dd", dataType = "String", paramType = "String", required = true)
|
||||||
|
})
|
||||||
|
@GetMapping("tableAllDate/{shellId}/{sellDate}")
|
||||||
|
public List<BusTables> tableAllDate(@PathVariable("shellId") String shellId, @PathVariable("sellDate") String sellDate) {
|
||||||
|
List<BusTables> tablesList = tablesService.list(Wrappers.<BusTables>lambdaQuery()
|
||||||
|
.eq(BusTables::getParentId, shellId)
|
||||||
|
.apply("DATE_FORMAT(sell_date,'%Y-%m-%d')={0}", sellDate)
|
||||||
|
.orderByAsc(BusTables::getTables, BusTables::getFloors)
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
return tablesList;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ApiOperation(httpMethod = "GET", value = "售卖时间", protocols = "http")
|
||||||
|
@ApiImplicitParam(name = "type", value = "类型1.午餐 2 晚餐", dataType = "String", paramType = "String", required = true)
|
||||||
|
@GetMapping("querySellTime/{type}/{mealData}")
|
||||||
|
public List<BusSellTime> querySellTime(@PathVariable("type") Integer type, @PathVariable("mealData") String meadlData) {
|
||||||
|
List<BusSellTime> list = busSellTimeService.list(Wrappers.<BusSellTime>lambdaQuery().eq(BusSellTime::getType, type)
|
||||||
|
.eq(BusSellTime::getStates, 1)
|
||||||
|
.orderByAsc(BusSellTime::getBeginTime));
|
||||||
|
|
||||||
|
list.forEach(item -> {
|
||||||
|
|
||||||
|
// Integer openTabeleCount = tablesService.getOpenTabele(meadlData, item.getId());
|
||||||
|
|
||||||
|
Integer openTabeleCount = 24;
|
||||||
|
|
||||||
|
Integer order = orderService.getOrder(meadlData, item.getId());
|
||||||
|
if (order < openTabeleCount) {
|
||||||
|
item.setIsSeat(1);
|
||||||
|
} else {
|
||||||
|
item.setIsSeat(2);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(httpMethod = "GET", value = "菜品", protocols = "http")
|
||||||
|
@ApiImplicitParam(name = "type", value = "类型:1早餐 2 晚餐 3 外卖", dataType = "String", paramType = "String", required = true)
|
||||||
|
@GetMapping("queryFood/{type}")
|
||||||
|
public List<BusFood> queryFood(@PathVariable("type") Integer type) {
|
||||||
|
return busFoodService.list(Wrappers.<BusFood>lambdaQuery().eq(BusFood::getType, type)
|
||||||
|
.orderByAsc(BusFood::getSort)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(httpMethod = "GET", value = "菜品主食物", protocols = "http")
|
||||||
|
@ApiImplicitParam(name = "type", value = "类型:1早餐 2 晚餐 3 外卖", dataType = "String", paramType = "String", required = true)
|
||||||
|
@GetMapping("queryFoodZhu/{type}")
|
||||||
|
public List<BusFood> queryFoodZhu(@PathVariable("type") Integer type) {
|
||||||
|
return busFoodService.list(Wrappers.<BusFood>lambdaQuery().eq(BusFood::getType, type)
|
||||||
|
.eq(BusFood::getIsZhu, 1)
|
||||||
|
.orderByAsc(BusFood::getSort)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(httpMethod = "GET", value = "获取餐桌已经购买过的位置", protocols = "http")
|
||||||
|
@ApiImplicitParam(name = "mealDate", value = "日期:yyyy-MM-dd", dataType = "String", paramType = "String", required = true)
|
||||||
|
@GetMapping("tableDTOList/{mealDate}")
|
||||||
|
public List<OrderTableDTO> tableDTOList(@PathVariable("mealDate") String mealDate) {
|
||||||
|
|
||||||
|
List<BusOrder> orderList = orderService.list(Wrappers.<BusOrder>lambdaQuery()
|
||||||
|
.eq(BusOrder::getEffective, 2)
|
||||||
|
.apply("DATE_FORMAT(meal_date,'%Y-%m-%d')={0}", mealDate)
|
||||||
|
);
|
||||||
|
|
||||||
|
List<OrderTableDTO> dtoList = new ArrayList<>();
|
||||||
|
orderList.forEach(item -> {
|
||||||
|
OrderTableDTO dto = new OrderTableDTO();
|
||||||
|
dto.setMealId(item.getMealId());
|
||||||
|
dto.setFloor(item.getFloor());
|
||||||
|
dto.setTable(item.getTable());
|
||||||
|
dtoList.add(dto);
|
||||||
|
});
|
||||||
|
|
||||||
|
return dtoList;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(httpMethod = "POST", value = "获取时间已经购买过的位置", protocols = "http")
|
||||||
|
@PostMapping("tableDtoOrder")
|
||||||
|
public List<OrderTableDTO> tableDtoOrder(@RequestBody OrderTableNoOrderParm parm) {
|
||||||
|
List<BusOrder> orderList = orderService.list(Wrappers.<BusOrder>lambdaQuery()
|
||||||
|
.eq(BusOrder::getEffective, 2)
|
||||||
|
// .eq(BusOrder::getFloor, parm.getFloor())
|
||||||
|
.eq(BusOrder::getMealId, parm.getMealId())
|
||||||
|
.eq(BusOrder::getMealDate, parm.getMealDate())
|
||||||
|
// .apply("DATE_FORMAT(meal_date,'%Y-%m-%d')={0}", parm.getMealDate())
|
||||||
|
);
|
||||||
|
|
||||||
|
List<OrderTableDTO> dtoList = new ArrayList<>();
|
||||||
|
orderList.forEach(item -> {
|
||||||
|
OrderTableDTO dto = new OrderTableDTO();
|
||||||
|
dto.setMealId(item.getMealId());
|
||||||
|
dto.setFloor(item.getFloor());
|
||||||
|
dto.setTable(item.getTable());
|
||||||
|
dtoList.add(dto);
|
||||||
|
});
|
||||||
|
|
||||||
|
return dtoList;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,68 @@
|
||||||
|
package com.gfwl.api.controller;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
|
import com.gfwl.api.base.BaseApiController;
|
||||||
|
import com.gfwl.api.base.DataEntity;
|
||||||
|
import com.gfwl.common.entity.BusBasicsCity;
|
||||||
|
import com.gfwl.common.entity.BusNotice;
|
||||||
|
import com.gfwl.common.service.BusBasicsCityService;
|
||||||
|
import com.gfwl.common.service.BusNoticeService;
|
||||||
|
import com.gfwl.config.consts.Global;
|
||||||
|
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @className: NoticeController
|
||||||
|
*
|
||||||
|
* Created by 小明
|
||||||
|
* @create: 2023-05-30 09:46
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@Api(
|
||||||
|
value = "通知接口",
|
||||||
|
tags = {"通知接口"},
|
||||||
|
produces = "application/json"
|
||||||
|
)
|
||||||
|
@ApiSupport(author = Global.interface_author)
|
||||||
|
@RequestMapping("/api/v2/notice")
|
||||||
|
public class BusNoticeApiController extends BaseApiController {
|
||||||
|
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private BusNoticeService noticeService;
|
||||||
|
@Resource
|
||||||
|
private BusBasicsCityService busBasicsCityService;
|
||||||
|
|
||||||
|
@ApiOperation(value = "获取通知", httpMethod = "GET", protocols = "HTTP")
|
||||||
|
@GetMapping("getNotice")
|
||||||
|
public BusNotice getNotice() {
|
||||||
|
return noticeService.getOne(Wrappers.<BusNotice>lambdaQuery().orderByDesc(DataEntity::getCreateDate).last("limit 1"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "城市数据", httpMethod = "GET", protocols = "HTTP")
|
||||||
|
@GetMapping("queryCity")
|
||||||
|
public List<BusBasicsCity> queryCity() {
|
||||||
|
List<BusBasicsCity> list = busBasicsCityService.list();
|
||||||
|
return streamToTree(list, "0");
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<BusBasicsCity> streamToTree(List<BusBasicsCity> treeList, String parentId) {
|
||||||
|
List<BusBasicsCity> list = treeList.stream()
|
||||||
|
.filter(parent -> parent.getParentId().equals(parentId))
|
||||||
|
.map(child -> {
|
||||||
|
child.setCityList(streamToTree(treeList, child.getId()));
|
||||||
|
return child;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,101 @@
|
||||||
|
package com.gfwl.api.controller;
|
||||||
|
|
||||||
|
import com.gfwl.api.ApiConst;
|
||||||
|
import com.gfwl.api.base.BaseApiController;
|
||||||
|
import com.gfwl.api.vo.user.UserBindPhoneDto;
|
||||||
|
import com.gfwl.api.vo.user.UserLogin;
|
||||||
|
import com.gfwl.api.vo.user.UserUdpVo;
|
||||||
|
import com.gfwl.common.entity.BusUser;
|
||||||
|
import com.gfwl.common.service.BusUserService;
|
||||||
|
import com.gfwl.config.consts.Global;
|
||||||
|
import com.gfwl.utils.wx.WxLoginEntity;
|
||||||
|
import com.gfwl.utils.wx.WxUtil;
|
||||||
|
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @className: UserController
|
||||||
|
*
|
||||||
|
* Created by 小明
|
||||||
|
* @create: 2023-05-30 10:42
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@Api(
|
||||||
|
value = "用户接口",
|
||||||
|
tags = {"用户接口"},
|
||||||
|
produces = "application/json"
|
||||||
|
)
|
||||||
|
@ApiSupport(author = Global.interface_author)
|
||||||
|
@RequestMapping("/api/v1/user")
|
||||||
|
public class BusUserApiController extends BaseApiController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
protected WxUtil wxUtil;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private BusUserService userService;
|
||||||
|
|
||||||
|
@ApiOperation(httpMethod = "POST", value = "用户登录", protocols = "http")
|
||||||
|
@PostMapping("/login")
|
||||||
|
public Map<String, Object> login(@RequestBody UserLogin login) {
|
||||||
|
Map<String, Object> map = new HashMap<>();
|
||||||
|
isNullObjAndThrow(login.getCode(), "wxCode不能为空");
|
||||||
|
BusUser busUser = null;
|
||||||
|
if (ApiConst.LOGIN_TYPE.WX.equalsIgnoreCase(login.getType())) {
|
||||||
|
isNullParams(login.getCode());
|
||||||
|
WxLoginEntity wxLoginEntity = wxUtil.wxLogin(login.getCode());
|
||||||
|
busUser = userService.getByOpenId(wxLoginEntity.getOpenid());
|
||||||
|
if (isNull(busUser)) {
|
||||||
|
map.put("openId", wxLoginEntity.getOpenid());
|
||||||
|
busUser = new BusUser();
|
||||||
|
busUser.setOpenId(wxLoginEntity.getOpenid());
|
||||||
|
busUser.insert();
|
||||||
|
}
|
||||||
|
|
||||||
|
map.put("sessionKey", wxLoginEntity.getSession_key());
|
||||||
|
}
|
||||||
|
|
||||||
|
String token = UUID.randomUUID().toString();
|
||||||
|
map.put("uid", busUser.getId());
|
||||||
|
map.put("token", token);
|
||||||
|
saveUserInfo(token, busUser);
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "绑定用户信息", httpMethod = "POST", protocols = "HTTP")
|
||||||
|
@PostMapping("updUser")
|
||||||
|
public BusUser updUser(@RequestBody UserUdpVo udpVo) {
|
||||||
|
BusUser busUser = getLogUser();
|
||||||
|
isNullObjAndThrow(busUser, "用户不存在");
|
||||||
|
busUser.setHeads(udpVo.getHead());
|
||||||
|
busUser.setNickName(udpVo.getUserName());
|
||||||
|
boolean b = busUser.updateById();
|
||||||
|
|
||||||
|
busUser.setOpenId("");
|
||||||
|
|
||||||
|
return busUser;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "绑定手机号", httpMethod = "POST", protocols = "HTTP")
|
||||||
|
@PostMapping("bindPhone")
|
||||||
|
public boolean bindPhone(@RequestBody UserBindPhoneDto dto) {
|
||||||
|
Map<String, Object> stringObjectMap = wxUtil.wxgetPhone(dto.getEncryptedData(), dto.getIv(), dto.getSessionKey());
|
||||||
|
BusUser busUser = userService.getById(dto.getUid());
|
||||||
|
isNullObjAndThrow(busUser, "用户不存在");
|
||||||
|
busUser.setPhones(String.valueOf(stringObjectMap.get("phoneNumber")));
|
||||||
|
return busUser.updateById();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "获取登陆用户信息", httpMethod = "GET", protocols = "HTTP")
|
||||||
|
@GetMapping("getLogUser")
|
||||||
|
public BusUser getLogUser() {
|
||||||
|
return userService.getById(getUserId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,168 @@
|
||||||
|
package com.gfwl.api.controller;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.gfwl.api.base.BaseApiController;
|
||||||
|
import com.gfwl.api.base.CodesEnum;
|
||||||
|
import com.gfwl.api.base.DataEntity;
|
||||||
|
import com.gfwl.api.vo.order.OrderEvaluationDTO;
|
||||||
|
import com.gfwl.api.vo.order.OrderResertDTO;
|
||||||
|
import com.gfwl.common.entity.BusOrder;
|
||||||
|
import com.gfwl.common.service.BusOrderAddressService;
|
||||||
|
import com.gfwl.common.service.BusOrderDetailService;
|
||||||
|
import com.gfwl.common.service.BusOrderService;
|
||||||
|
import com.gfwl.config.consts.Global;
|
||||||
|
import com.gfwl.config.exception.ApiException;
|
||||||
|
import com.gfwl.config.pay.WxPayBean;
|
||||||
|
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
|
||||||
|
import com.ijpay.core.enums.SignType;
|
||||||
|
import com.ijpay.core.kit.WxPayKit;
|
||||||
|
import com.ijpay.wxpay.WxPayApi;
|
||||||
|
import com.ijpay.wxpay.model.RefundModel;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiImplicitParam;
|
||||||
|
import io.swagger.annotations.ApiImplicitParams;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @className: OrderApiController
|
||||||
|
*
|
||||||
|
* Created by 小明
|
||||||
|
* @create: 2023-05-31 01:25
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@Api(
|
||||||
|
value = "订单列表",
|
||||||
|
tags = {"订单列表"},
|
||||||
|
produces = "application/json"
|
||||||
|
)
|
||||||
|
@ApiSupport(author = Global.interface_author)
|
||||||
|
@RequestMapping("/api/v1/order")
|
||||||
|
public class OrderApiController extends BaseApiController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private BusOrderService orderService;
|
||||||
|
@Resource
|
||||||
|
private BusOrderAddressService busOrderAddressService;
|
||||||
|
@Resource
|
||||||
|
private BusOrderDetailService busOrderDetailService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private WxPayBean wxPayBean;
|
||||||
|
|
||||||
|
@ApiOperation(value = "评价")
|
||||||
|
@PostMapping("evaluation")
|
||||||
|
public boolean evaluation(@RequestBody OrderEvaluationDTO evaluationDTO) {
|
||||||
|
BusOrder byId = orderService.getById(evaluationDTO.getOrderId());
|
||||||
|
if (byId.getIsEvaluation() != 1) {
|
||||||
|
throw new ApiException(CodesEnum.ORDER_NO_EVALUATION);
|
||||||
|
}
|
||||||
|
byId.setIsEvaluation(2);
|
||||||
|
byId.setEvaluationTime(new Date());
|
||||||
|
byId.setEvaluationNumber(evaluationDTO.getEvaluationNumber());
|
||||||
|
byId.setEvaluationContent(evaluationDTO.getEvaluationContent());
|
||||||
|
|
||||||
|
return byId.updateById();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(httpMethod = "GET", value = "取消订单", protocols = "http")
|
||||||
|
@ApiImplicitParam(name = "orderId", value = "订单ID", dataType = "Integer")
|
||||||
|
@GetMapping("/clearOrder")
|
||||||
|
public boolean clearOrder(@RequestParam("orderId") String orderId) {
|
||||||
|
BusOrder byId = orderService.getById(orderId);
|
||||||
|
if (byId.getIsEvaluation() != 1) {
|
||||||
|
throw new ApiException(CodesEnum.ORDER_NO_EVALUATION);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Map<String, String> params = RefundModel.builder()
|
||||||
|
.appid(wxPayBean.getAppId())
|
||||||
|
.mch_id(wxPayBean.getMchId())
|
||||||
|
.nonce_str(WxPayKit.generateStr())
|
||||||
|
.out_trade_no(byId.getOutTradeId())
|
||||||
|
.out_refund_no(byId.getOutTradeId())
|
||||||
|
.total_fee(String.valueOf(byId.getPrices().multiply(BigDecimal.valueOf(100)).intValue()))
|
||||||
|
.refund_fee(String.valueOf(byId.getPrices().multiply(BigDecimal.valueOf(100)).intValue()))
|
||||||
|
.notify_url(wxPayBean.getDomain().concat("api/v1/pay/refundNotify"))
|
||||||
|
.build()
|
||||||
|
.createSign(wxPayBean.getPartnerKey(), SignType.MD5);
|
||||||
|
String refundStr = WxPayApi.orderRefund(false, params, wxPayBean.getCertPath(), wxPayBean.getMchId());
|
||||||
|
|
||||||
|
Map<String, String> refundParam = WxPayKit.xmlToMap(refundStr);
|
||||||
|
System.out.println(refundStr);
|
||||||
|
if (refundParam.get("result_code").equals("SUCCESS")) {
|
||||||
|
byId.setStates(4);
|
||||||
|
return byId.updateById();
|
||||||
|
} else {
|
||||||
|
throw new ApiException(CodesEnum.WX_ERROR, refundParam.get("err_code_des"));
|
||||||
|
}
|
||||||
|
//<xml><return_code><![CDATA[SUCCESS]]></return_code>
|
||||||
|
//<return_msg><![CDATA[OK]]></return_msg>
|
||||||
|
//<appid><![CDATA[wxeea982992956b3b0]]></appid>
|
||||||
|
//<mch_id><![CDATA[1645216188]]></mch_id>
|
||||||
|
//<nonce_str><![CDATA[84KcfiRBPZemE3Rf]]></nonce_str>
|
||||||
|
//<sign><![CDATA[856BCE70F058E95F3762969A84B15A38]]></sign>
|
||||||
|
//<result_code><![CDATA[FAIL]]></result_code>
|
||||||
|
//<err_code><![CDATA[NOTENOUGH]]></err_code>
|
||||||
|
//<err_code_des><![CDATA[基本账户余额不足,请充值后重新发起]]></err_code_des>
|
||||||
|
//</xml>
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(httpMethod = "GET", value = "订单列表", protocols = "http")
|
||||||
|
@ApiImplicitParams({
|
||||||
|
@ApiImplicitParam(name = "state", value = "1.即将开始2 待评价 3 退款", dataType = "Integer"),
|
||||||
|
@ApiImplicitParam(name = "page", value = "页码", dataType = "Integer"),
|
||||||
|
@ApiImplicitParam(name = "pageSize", value = "分页大小", dataType = "Integer")
|
||||||
|
})
|
||||||
|
@GetMapping("/queryOrderList")
|
||||||
|
public IPage<OrderResertDTO> queryOrderList(@RequestParam("page") Integer page,
|
||||||
|
@RequestParam("pageSize") Integer pageSize,
|
||||||
|
@RequestParam("state") Integer state) {
|
||||||
|
|
||||||
|
|
||||||
|
Page<BusOrder> orderPage = orderService.page(new Page<>(page, pageSize), Wrappers.<BusOrder>lambdaQuery()
|
||||||
|
.and(state == 1, wrapper -> wrapper.eq(BusOrder::getStates, 2).or(state == 1,
|
||||||
|
wrapper2 -> wrapper2.eq(BusOrder::getStates, 1)
|
||||||
|
.eq(BusOrder::getOrderType, 2)
|
||||||
|
))
|
||||||
|
.in(state == 1, BusOrder::getStates, 1, 2)
|
||||||
|
// .and(state == 2, wrapper -> wrapper.eq(BusOrder::getStates, 7).or().eq(BusOrder::getIsEvaluation, 1))
|
||||||
|
.eq(state == 2, BusOrder::getStates, 7)
|
||||||
|
.in(state == 3, BusOrder::getStates, 4, 5, 6, 8)
|
||||||
|
.eq(BusOrder::getUserId, getUserId())
|
||||||
|
.orderByDesc(DataEntity::getCreateDate)
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
List<OrderResertDTO> dtoList = new ArrayList<>();
|
||||||
|
|
||||||
|
orderPage.getRecords().forEach(item -> {
|
||||||
|
OrderResertDTO dto = new OrderResertDTO();
|
||||||
|
dto.setOrderInfo(item);
|
||||||
|
dto.setOrderAddress(busOrderAddressService.getByOrderId(item.getId()));
|
||||||
|
dto.setOrderDetailList(busOrderDetailService.queryByOrderId(item.getId()));
|
||||||
|
dtoList.add(dto);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
IPage<OrderResertDTO> iPage = new Page<>();
|
||||||
|
iPage.setCurrent(orderPage.getCurrent());
|
||||||
|
iPage.setPages(orderPage.getPages());
|
||||||
|
iPage.setTotal(orderPage.getTotal());
|
||||||
|
iPage.setSize(orderPage.getSize());
|
||||||
|
iPage.setRecords(dtoList);
|
||||||
|
|
||||||
|
return iPage;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,310 @@
|
||||||
|
package com.gfwl.api.controller;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
|
import com.gfwl.api.base.BaseApiController;
|
||||||
|
import com.gfwl.api.base.CodesEnum;
|
||||||
|
import com.gfwl.api.vo.order.OrderAppointDTO;
|
||||||
|
import com.gfwl.api.vo.order.OrderTakeOutDTO;
|
||||||
|
import com.gfwl.common.entity.BusOrder;
|
||||||
|
import com.gfwl.common.entity.BusOrderAddress;
|
||||||
|
import com.gfwl.common.entity.BusOrderDetail;
|
||||||
|
import com.gfwl.common.entity.BusSellTime;
|
||||||
|
import com.gfwl.common.service.*;
|
||||||
|
import com.gfwl.config.consts.Global;
|
||||||
|
import com.gfwl.config.exception.ApiException;
|
||||||
|
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @className: OrderApiController
|
||||||
|
*
|
||||||
|
* Created by 小明
|
||||||
|
* @create: 2023-05-30 22:46
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@Api(
|
||||||
|
value = "下单接口",
|
||||||
|
tags = {"下单接口"},
|
||||||
|
produces = "application/json"
|
||||||
|
)
|
||||||
|
@ApiSupport(author = Global.interface_author)
|
||||||
|
@RequestMapping("/api/v1/orderCreate")
|
||||||
|
public class OrderCreateApiController extends BaseApiController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private BusOrderService orderService;
|
||||||
|
@Resource
|
||||||
|
private BusOrderDetailService orderDetailService;
|
||||||
|
@Resource
|
||||||
|
private BusOrderAddressService orderAddressService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private BusFoodService foodService;
|
||||||
|
@Resource
|
||||||
|
private BusSellTimeService sellTimeService;
|
||||||
|
|
||||||
|
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
@ApiOperation(value = "创建预约订单", httpMethod = "POST", protocols = "HTTP")
|
||||||
|
@PostMapping("appoint")
|
||||||
|
public BusOrder createAppoint(@RequestBody OrderAppointDTO dto) {
|
||||||
|
if (dto.getDtoList().size() < 1) {
|
||||||
|
throw new ApiException(CodesEnum.PARAMS_ERROR);
|
||||||
|
}
|
||||||
|
//校验桌子和时间是否有人购买
|
||||||
|
boolean order = orderService.isOrder(dto.getMealDate(), dto.getMealId(), dto.getFloor(), dto.getTable());
|
||||||
|
if (order) {
|
||||||
|
throw new ApiException(CodesEnum.ALREADY_APPLY);
|
||||||
|
}
|
||||||
|
List<BusOrderDetail> detailList = new ArrayList<>();
|
||||||
|
//校验库存 设置商品价格
|
||||||
|
foodService.isCheckInventory(dto, detailList);
|
||||||
|
|
||||||
|
//处理就餐时间
|
||||||
|
BusSellTime sellTime = sellTimeService.getById(dto.getMealId());
|
||||||
|
isNullObjAndThrow(sellTime);
|
||||||
|
|
||||||
|
//计算每一个商品的价格
|
||||||
|
final BigDecimal[] prices = {BigDecimal.ZERO};
|
||||||
|
detailList.forEach(item -> {
|
||||||
|
prices[0] = prices[0].add(item.getFees());
|
||||||
|
});
|
||||||
|
|
||||||
|
Date mealDate = DateUtil.parseDate(dto.getMealDate());
|
||||||
|
|
||||||
|
BusOrder busOrder = new BusOrder();
|
||||||
|
busOrder.setUserId(getUserId());
|
||||||
|
busOrder.setTradeId(getTradeId());
|
||||||
|
busOrder.setPrices(prices[0]);
|
||||||
|
busOrder.setType(1);
|
||||||
|
busOrder.setStates(1);
|
||||||
|
busOrder.setPeopleNumber(dto.getPeopleNumber());
|
||||||
|
busOrder.setMealId(dto.getMealId());
|
||||||
|
busOrder.setMealTime(sellTime.getBeginTime() + "-" + sellTime.getEndTime());
|
||||||
|
busOrder.setMealDate(mealDate);
|
||||||
|
busOrder.setFloor(dto.getFloor());
|
||||||
|
busOrder.setTable(dto.getTable());
|
||||||
|
busOrder.setNames(dto.getNames());
|
||||||
|
busOrder.setPhones(dto.getPhones());
|
||||||
|
busOrder.setIsEvaluation(1);
|
||||||
|
busOrder.setEffective(1);
|
||||||
|
busOrder.setOrderType(1);
|
||||||
|
busOrder.setIsAudit(2);
|
||||||
|
|
||||||
|
boolean insert = busOrder.insert();
|
||||||
|
if (!insert) {
|
||||||
|
throw new ApiException(CodesEnum.ERROR, "订单创建失败");
|
||||||
|
}
|
||||||
|
detailList.forEach(item -> {
|
||||||
|
item.setOrderId(busOrder.getId());
|
||||||
|
});
|
||||||
|
boolean b = orderDetailService.saveBatch(detailList);
|
||||||
|
if (!b) {
|
||||||
|
throw new ApiException(CodesEnum.ERROR, "订单创建失败");
|
||||||
|
}
|
||||||
|
return busOrder;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ApiOperation(value = "创建外卖订单", httpMethod = "POST", protocols = "HTTP")
|
||||||
|
@PostMapping("takeOut")
|
||||||
|
public BusOrder createTakeOut(@RequestBody OrderTakeOutDTO dto) {
|
||||||
|
if (dto.getDtoList().size() < 1) {
|
||||||
|
throw new ApiException(CodesEnum.PARAMS_ERROR);
|
||||||
|
}
|
||||||
|
List<BusOrderDetail> detailList = new ArrayList<>();
|
||||||
|
//校验库存 设置商品价格
|
||||||
|
foodService.isCheckInventoryV2(dto.getDtoList(), detailList);
|
||||||
|
|
||||||
|
//计算每一个商品的价格
|
||||||
|
final BigDecimal[] prices = {BigDecimal.ZERO};
|
||||||
|
detailList.forEach(item -> {
|
||||||
|
prices[0] = prices[0].add(item.getFees());
|
||||||
|
});
|
||||||
|
|
||||||
|
BusOrder busOrder = new BusOrder();
|
||||||
|
busOrder.setUserId(getUserId());
|
||||||
|
// busOrder.setTradeId(IdUtil.simpleUUID().toUpperCase());
|
||||||
|
busOrder.setTradeId(getTradeId());
|
||||||
|
busOrder.setPrices(prices[0]);
|
||||||
|
busOrder.setType(2);
|
||||||
|
busOrder.setStates(1);
|
||||||
|
busOrder.setMealDate(new Date());
|
||||||
|
busOrder.setIsEvaluation(1);
|
||||||
|
busOrder.setEffective(1);
|
||||||
|
busOrder.setNames(dto.getNames());
|
||||||
|
busOrder.setPhones(dto.getPhones());
|
||||||
|
busOrder.setOrderType(1);
|
||||||
|
busOrder.setIsAudit(2);
|
||||||
|
boolean insert = busOrder.insert();
|
||||||
|
if (!insert) {
|
||||||
|
throw new ApiException(CodesEnum.ERROR, "订单创建失败");
|
||||||
|
}
|
||||||
|
detailList.forEach(item -> {
|
||||||
|
item.setOrderId(busOrder.getId());
|
||||||
|
});
|
||||||
|
boolean b = orderDetailService.saveBatch(detailList);
|
||||||
|
if (!b) {
|
||||||
|
throw new ApiException(CodesEnum.ERROR, "订单创建失败");
|
||||||
|
}
|
||||||
|
//生成地址
|
||||||
|
BusOrderAddress address = new BusOrderAddress();
|
||||||
|
address.setOrderId(busOrder.getId());
|
||||||
|
address.setType(dto.getType());
|
||||||
|
address.setSelfDate(dto.getSelfDate());
|
||||||
|
address.setProvince(dto.getProvince());
|
||||||
|
address.setCity(dto.getCity());
|
||||||
|
address.setAddress(dto.getAddress());
|
||||||
|
address.setNames(dto.getNames());
|
||||||
|
address.setPhones(dto.getPhones());
|
||||||
|
address.setProvinceId(dto.getProvinceId());
|
||||||
|
address.setCityId(dto.getCityId());
|
||||||
|
boolean insert1 = address.insert();
|
||||||
|
if (!insert1) {
|
||||||
|
throw new ApiException(CodesEnum.ERROR, "订单创建失败");
|
||||||
|
}
|
||||||
|
return busOrder;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "修改订单-外卖订单", httpMethod = "POST", protocols = "HTTP")
|
||||||
|
@PostMapping("editTakeOut/{orderId}")
|
||||||
|
public BusOrder editTakeOut(@PathVariable("orderId") String orderId, @RequestBody OrderTakeOutDTO dto) {
|
||||||
|
BusOrder byId = orderService.getById(orderId);
|
||||||
|
isNullObjAndThrow(byId);
|
||||||
|
|
||||||
|
if (dto.getDtoList().size() < 1) {
|
||||||
|
throw new ApiException(CodesEnum.PARAMS_ERROR);
|
||||||
|
}
|
||||||
|
List<BusOrderDetail> detailList = new ArrayList<>();
|
||||||
|
//校验库存 设置商品价格
|
||||||
|
foodService.isCheckInventoryV2(dto.getDtoList(), detailList);
|
||||||
|
|
||||||
|
//计算每一个商品的价格
|
||||||
|
final BigDecimal[] prices = {BigDecimal.ZERO};
|
||||||
|
detailList.forEach(item -> {
|
||||||
|
prices[0] = prices[0].add(item.getFees());
|
||||||
|
});
|
||||||
|
|
||||||
|
BusOrder busOrder = new BusOrder();
|
||||||
|
busOrder.setUserId(getUserId());
|
||||||
|
// busOrder.setTradeId(IdUtil.simpleUUID().toUpperCase());
|
||||||
|
busOrder.setTradeId(getTradeId());
|
||||||
|
busOrder.setPrices(prices[0]);
|
||||||
|
busOrder.setType(2);
|
||||||
|
busOrder.setStates(1);
|
||||||
|
busOrder.setMealDate(new Date());
|
||||||
|
busOrder.setIsEvaluation(1);
|
||||||
|
busOrder.setEffective(1);
|
||||||
|
busOrder.setNames(dto.getNames());
|
||||||
|
busOrder.setPhones(dto.getPhones());
|
||||||
|
busOrder.setOrderType(2);
|
||||||
|
busOrder.setOldOrderId(byId.getId());
|
||||||
|
busOrder.setIsAudit(1);
|
||||||
|
boolean insert = busOrder.insert();
|
||||||
|
|
||||||
|
if (!insert) {
|
||||||
|
throw new ApiException(CodesEnum.ERROR, "订单创建失败");
|
||||||
|
}
|
||||||
|
detailList.forEach(item -> {
|
||||||
|
item.setOrderId(busOrder.getId());
|
||||||
|
});
|
||||||
|
boolean b = orderDetailService.saveBatch(detailList);
|
||||||
|
if (!b) {
|
||||||
|
throw new ApiException(CodesEnum.ERROR, "订单创建失败");
|
||||||
|
}
|
||||||
|
//生成地址
|
||||||
|
BusOrderAddress address = new BusOrderAddress();
|
||||||
|
address.setOrderId(busOrder.getId());
|
||||||
|
address.setType(dto.getType());
|
||||||
|
address.setSelfDate(dto.getSelfDate());
|
||||||
|
address.setProvince(dto.getProvince());
|
||||||
|
address.setCity(dto.getCity());
|
||||||
|
address.setAddress(dto.getAddress());
|
||||||
|
address.setNames(dto.getNames());
|
||||||
|
address.setPhones(dto.getPhones());
|
||||||
|
address.setProvinceId(dto.getProvinceId());
|
||||||
|
address.setCityId(dto.getCityId());
|
||||||
|
boolean insert1 = address.insert();
|
||||||
|
if (!insert1) {
|
||||||
|
throw new ApiException(CodesEnum.ERROR, "订单创建失败");
|
||||||
|
}
|
||||||
|
return busOrder;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
@ApiOperation(value = "修改订单--预约订单", httpMethod = "POST", protocols = "HTTP")
|
||||||
|
@PostMapping("editAppoint/{orderId}")
|
||||||
|
public BusOrder editAppoint(@PathVariable("orderId") String orderId, @RequestBody OrderAppointDTO dto) {
|
||||||
|
BusOrder byId = orderService.getById(orderId);
|
||||||
|
isNullObjAndThrow(byId);
|
||||||
|
|
||||||
|
int count = orderService.count(Wrappers.<BusOrder>lambdaQuery().eq(BusOrder::getOldOrderId, byId.getId()));
|
||||||
|
if(count>0){
|
||||||
|
throw new ApiException(CodesEnum.ERROR, "订单已经修改过,不能在进行修改");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
List<BusOrderDetail> detailList = new ArrayList<>();
|
||||||
|
//校验库存 设置商品价格
|
||||||
|
foodService.isCheckInventory(dto, detailList);
|
||||||
|
|
||||||
|
//处理就餐时间
|
||||||
|
BusSellTime sellTime = sellTimeService.getById(dto.getMealId());
|
||||||
|
isNullObjAndThrow(sellTime);
|
||||||
|
//计算每一个商品的价格
|
||||||
|
final BigDecimal[] prices = {BigDecimal.ZERO};
|
||||||
|
detailList.forEach(item -> {
|
||||||
|
prices[0] = prices[0].add(item.getFees());
|
||||||
|
});
|
||||||
|
|
||||||
|
Date mealDate = DateUtil.parseDate(dto.getMealDate());
|
||||||
|
|
||||||
|
BusOrder busOrder = new BusOrder();
|
||||||
|
busOrder.setUserId(getUserId());
|
||||||
|
busOrder.setTradeId(getTradeId());
|
||||||
|
busOrder.setPrices(prices[0]);
|
||||||
|
busOrder.setType(1);
|
||||||
|
busOrder.setStates(1);
|
||||||
|
busOrder.setPeopleNumber(dto.getPeopleNumber());
|
||||||
|
busOrder.setMealId(dto.getMealId());
|
||||||
|
busOrder.setMealTime(sellTime.getBeginTime() + "-" + sellTime.getEndTime());
|
||||||
|
busOrder.setMealDate(mealDate);
|
||||||
|
busOrder.setFloor(dto.getFloor());
|
||||||
|
busOrder.setTable(dto.getTable());
|
||||||
|
busOrder.setNames(dto.getNames());
|
||||||
|
busOrder.setPhones(dto.getPhones());
|
||||||
|
busOrder.setIsEvaluation(1);
|
||||||
|
busOrder.setEffective(1);
|
||||||
|
busOrder.setOrderType(2);
|
||||||
|
busOrder.setOldOrderId(byId.getId());
|
||||||
|
busOrder.setIsAudit(1);
|
||||||
|
boolean insert = busOrder.insert();
|
||||||
|
if (!insert) {
|
||||||
|
throw new ApiException(CodesEnum.ERROR, "订单创建失败");
|
||||||
|
}
|
||||||
|
detailList.forEach(item -> {
|
||||||
|
item.setOrderId(busOrder.getId());
|
||||||
|
});
|
||||||
|
boolean b = orderDetailService.saveBatch(detailList);
|
||||||
|
if (!b) {
|
||||||
|
throw new ApiException(CodesEnum.ERROR, "订单创建失败");
|
||||||
|
}
|
||||||
|
return busOrder;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private String getTradeId() {
|
||||||
|
return new SimpleDateFormat("yyyyMMddHHmmssSSS").format(new Date()).toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,411 @@
|
||||||
|
//package com.gfwl.api.controller;
|
||||||
|
//
|
||||||
|
//import com.alibaba.fastjson.JSON;
|
||||||
|
//import com.gfwl.api.base.CodesEnum;
|
||||||
|
//import com.gfwl.api.vo.pay.PayInfo;
|
||||||
|
//import com.gfwl.common.entity.BusUser;
|
||||||
|
//import com.gfwl.common.service.BusFoodService;
|
||||||
|
//import com.gfwl.common.service.BusOrderDetailService;
|
||||||
|
//import com.gfwl.common.service.BusOrderService;
|
||||||
|
//import com.gfwl.config.consts.Global;
|
||||||
|
//import com.gfwl.config.exception.ApiException;
|
||||||
|
//import com.gfwl.config.pay.WxPayBean;
|
||||||
|
//import com.gfwl.config.redis.RedisUtils;
|
||||||
|
//import com.github.xiaoymin.knife4j.annotations.ApiSupport;
|
||||||
|
//import com.ijpay.core.enums.SignType;
|
||||||
|
//import com.ijpay.core.enums.TradeType;
|
||||||
|
//import com.ijpay.core.kit.IpKit;
|
||||||
|
//import com.ijpay.core.kit.WxPayKit;
|
||||||
|
//import com.ijpay.wxpay.WxPayApi;
|
||||||
|
//import com.ijpay.wxpay.WxPayApiConfig;
|
||||||
|
//import com.ijpay.wxpay.WxPayApiConfigKit;
|
||||||
|
//import com.ijpay.wxpay.model.UnifiedOrderModel;
|
||||||
|
//import io.swagger.annotations.Api;
|
||||||
|
//import io.swagger.annotations.ApiImplicitParam;
|
||||||
|
//import lombok.extern.slf4j.Slf4j;
|
||||||
|
//import org.apache.commons.lang3.StringUtils;
|
||||||
|
//import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
//import org.springframework.stereotype.Controller;
|
||||||
|
//import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
//import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
|
//import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
//import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
//
|
||||||
|
//import javax.annotation.Resource;
|
||||||
|
//import javax.servlet.http.HttpServletRequest;
|
||||||
|
//import java.util.Map;
|
||||||
|
//
|
||||||
|
///**
|
||||||
|
// * @className: OrderController
|
||||||
|
// *
|
||||||
|
// * Created by 小明
|
||||||
|
// * @create: 2023-05-30 18:27
|
||||||
|
// */
|
||||||
|
//@Slf4j
|
||||||
|
//@Controller
|
||||||
|
//@Api(
|
||||||
|
// value = "支付接口",
|
||||||
|
// tags = {"支付接口"},
|
||||||
|
// produces = "application/json"
|
||||||
|
//)
|
||||||
|
//@ApiSupport(author = Global.interface_author)
|
||||||
|
//@RequestMapping("/api/v1/pay")
|
||||||
|
//public class PayController extends AbstractWxPayApiController {
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// private final static int OK = 200;
|
||||||
|
//
|
||||||
|
///* @Resource
|
||||||
|
// WxPayV3Bean wxPayV3Bean;*/
|
||||||
|
//
|
||||||
|
// @Resource
|
||||||
|
// private WxPayBean wxPayBean;
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public WxPayApiConfig getApiConfig() {
|
||||||
|
// WxPayApiConfig apiConfig;
|
||||||
|
// try {
|
||||||
|
// apiConfig = WxPayApiConfigKit.getApiConfig(wxPayBean.getAppId());
|
||||||
|
// } catch (Exception e) {
|
||||||
|
// apiConfig = WxPayApiConfig.builder()
|
||||||
|
// .appId(wxPayBean.getAppId())
|
||||||
|
// .mchId(wxPayBean.getMchId())
|
||||||
|
// .partnerKey(wxPayBean.getPartnerKey())
|
||||||
|
// .certPath(wxPayBean.getCertPath())
|
||||||
|
// .domain(wxPayBean.getDomain())
|
||||||
|
// .build();
|
||||||
|
// }
|
||||||
|
//// notifyUrl = apiConfig.getDomain().concat("/api/v1/pay/payNotify");
|
||||||
|
// return apiConfig;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Resource
|
||||||
|
// private BusOrderService orderService;
|
||||||
|
// @Resource
|
||||||
|
// private BusFoodService foodService;
|
||||||
|
// @Resource
|
||||||
|
// private BusOrderDetailService orderDetailService;
|
||||||
|
//
|
||||||
|
// @Autowired
|
||||||
|
// protected RedisUtils redis;
|
||||||
|
// @Autowired
|
||||||
|
// protected HttpServletRequest request;
|
||||||
|
//
|
||||||
|
// protected String getToken() {
|
||||||
|
// return request.getHeader(Global.header_key);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// protected BusUser getLoginUser() {
|
||||||
|
// Object userJson = redis.get(Global.redis_login + getToken());
|
||||||
|
// if (userJson == null) {
|
||||||
|
// throw new ApiException(CodesEnum.NOT_LOGIN, CodesEnum.NOT_LOGIN.getMessage());
|
||||||
|
// }
|
||||||
|
// redis.expire(Global.redis_login + getToken(), Global.login_expire_time);
|
||||||
|
// return com.alibaba.fastjson.JSONObject.parseObject(userJson.toString(), BusUser.class);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @RequestMapping(value = "/miniAppPay", method = {RequestMethod.POST, RequestMethod.GET})
|
||||||
|
// @ApiImplicitParam(name = "orderId", value = "订单ID", dataType = "String", paramType = "String", required = true)
|
||||||
|
// @ResponseBody
|
||||||
|
// public PayInfo miniAppPay(HttpServletRequest request, @RequestParam(value = "orderId", required = true, defaultValue = "") String orderId) {
|
||||||
|
// //需要通过授权来获取openId
|
||||||
|
//
|
||||||
|
// BusUser loginUser = getLoginUser();
|
||||||
|
//
|
||||||
|
// String ip = IpKit.getRealIp(request);
|
||||||
|
// if (StringUtils.isBlank(ip)) {
|
||||||
|
// ip = "127.0.0.1";
|
||||||
|
// }
|
||||||
|
//// 统一下单构建请求参数
|
||||||
|
// Map<String, String> params = UnifiedOrderModel
|
||||||
|
// .builder()
|
||||||
|
// .appid(wxPayBean.getAppId())
|
||||||
|
// .mch_id(wxPayBean.getMchId())
|
||||||
|
// .nonce_str(WxPayKit.generateStr())
|
||||||
|
// .body("IJPay 让支付触手可及-小程序支付")
|
||||||
|
// .attach("Node.js 版:https://gitee.com/javen205/TNWXX")
|
||||||
|
// .out_trade_no(WxPayKit.generateStr())
|
||||||
|
// .total_fee("1000")
|
||||||
|
// .spbill_create_ip(ip)
|
||||||
|
// .notify_url("https://baidu.com")
|
||||||
|
// .trade_type(TradeType.JSAPI.getTradeType())
|
||||||
|
// .openid(loginUser.getOpenId())
|
||||||
|
// .build()
|
||||||
|
// .createSign(wxPayBean.getPartnerKey(), SignType.HMACSHA256);
|
||||||
|
//
|
||||||
|
// String xmlResult = WxPayApi.pushOrder(false, params);
|
||||||
|
//
|
||||||
|
// log.error(xmlResult);
|
||||||
|
//
|
||||||
|
//// 将请求返回的 xml 数据转为 Map,方便后面逻辑获取数据
|
||||||
|
// Map<String, String> resultMap = WxPayKit.xmlToMap(xmlResult);
|
||||||
|
//// 判断返回的结果
|
||||||
|
// String returnCode = resultMap.get("return_code");
|
||||||
|
// String returnMsg = resultMap.get("return_msg");
|
||||||
|
//// if (!WxPayKit.codeIsOk(returnCode)) {
|
||||||
|
//// return new AjaxResult().addError(returnMsg);
|
||||||
|
//// }
|
||||||
|
//// String resultCode = resultMap.get("result_code");
|
||||||
|
//// if (!WxPayKit.codeIsOk(resultCode)) {
|
||||||
|
//// return new AjaxResult().addError(returnMsg);
|
||||||
|
//// }
|
||||||
|
//
|
||||||
|
//// 以下字段在return_code 和result_code都为SUCCESS的时候有返回
|
||||||
|
// String prepayId = resultMap.get("prepay_id");
|
||||||
|
//// 二次签名,构建公众号唤起支付的参数,这里的签名方式要与上面统一下单请求签名方式保持一致
|
||||||
|
// Map<String, String> map = WxPayKit.prepayIdCreateSign(prepayId,
|
||||||
|
// wxPayBean.getAppId(), wxPayBean.getPartnerKey(), SignType.HMACSHA256);
|
||||||
|
//// 将二次签名构建的数据返回给前端并唤起公众号支付
|
||||||
|
// String jsonStr = JSON.toJSONString(map);
|
||||||
|
//
|
||||||
|
// PayInfo payInfo = PayInfo.builder()
|
||||||
|
// .appId(map.get("appId"))
|
||||||
|
// .timeStamp(map.get("timeStamp"))
|
||||||
|
// .signType(map.get("signType"))
|
||||||
|
// .packages(map.get("package"))
|
||||||
|
// .paySign(map.get("paySign"))
|
||||||
|
// .nonceStr(map.get("nonceStr"))
|
||||||
|
// .tradeId(params.get("out_trade_no"))
|
||||||
|
// .build();
|
||||||
|
//
|
||||||
|
// return payInfo;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @ResponseBody
|
||||||
|
// @ApiOperation(value = "支付", httpMethod = "GET", protocols = "HTTP")
|
||||||
|
// @ApiImplicitParam(name = "orderId", value = "订单ID", dataType = "String", paramType = "String", required = true)
|
||||||
|
// @GetMapping("/pay")
|
||||||
|
// public PayInfo pay(@RequestParam(value = "orderId", required = true, defaultValue = "") String orderId) {
|
||||||
|
// BusOrder busOrder = orderService.getById(orderId);
|
||||||
|
//// isNullObjAndThrow(busOrder);
|
||||||
|
// if (busOrder.getStates() != 1 && busOrder.getStates() != 3) {
|
||||||
|
// throw new ApiException(CodesEnum.ORDER_NO_PAY);
|
||||||
|
// }
|
||||||
|
// //校验订单库存
|
||||||
|
// List<BusOrderDetail> orderDetails = orderDetailService.list(Wrappers.<BusOrderDetail>lambdaQuery().eq(BusOrderDetail::getOrderId, busOrder.getId()));
|
||||||
|
// foodService.isCheckInventoryFood(orderDetails);
|
||||||
|
//
|
||||||
|
// BusUser loginUser = getLoginUser();
|
||||||
|
// String outReadeNo = PayKit.generateStr();
|
||||||
|
//
|
||||||
|
// try {
|
||||||
|
// String timeExpire = DateTimeZoneUtil.dateToTimeZone(System.currentTimeMillis() + 1000 * 60 * 3);
|
||||||
|
// UnifiedOrderModel unifiedOrderModel = new UnifiedOrderModel()
|
||||||
|
// .setAppid(wxPayV3Bean.getAppId())
|
||||||
|
// .setMchid(wxPayV3Bean.getMchId())
|
||||||
|
// .setDescription("哪哒尔商品支付")
|
||||||
|
// .setOut_trade_no(outReadeNo)
|
||||||
|
// .setTime_expire(timeExpire)
|
||||||
|
// .setAttach("哪哒尔商品支付订单购买")
|
||||||
|
// .setNotify_url(wxPayV3Bean.getDomain().concat("/api/v1/pay/payNotify"))
|
||||||
|
// .setAmount(new Amount()
|
||||||
|
// .setTotal(busOrder.getPrices().multiply(BigDecimal.valueOf(100)).intValue())
|
||||||
|
// .setCurrency("CNY")
|
||||||
|
// )
|
||||||
|
// .setPayer(new Payer().setOpenid(loginUser.getOpenId()));
|
||||||
|
//
|
||||||
|
// log.info("统一下单参数 {}", JSONUtil.toJsonStr(unifiedOrderModel));
|
||||||
|
// IJPayHttpResponse response = WxPayApi.v3(
|
||||||
|
// RequestMethodEnum.POST,
|
||||||
|
// WxDomainEnum.CHINA.toString(),
|
||||||
|
// BasePayApiEnum.JS_API_PAY.toString(),
|
||||||
|
// wxPayV3Bean.getMchId(),
|
||||||
|
// getSerialNumber(),
|
||||||
|
// null,
|
||||||
|
// wxPayV3Bean.getKeyPath(),
|
||||||
|
// JSONUtil.toJsonStr(unifiedOrderModel)
|
||||||
|
// );
|
||||||
|
// log.info("统一下单响应 {}", response);
|
||||||
|
// // 根据证书序列号查询对应的证书来验证签名结果
|
||||||
|
// boolean verifySignature = WxPayKit.verifySignature(response, wxPayV3Bean.getPlatformCertPath());
|
||||||
|
// log.info("verifySignature: {}", verifySignature);
|
||||||
|
// if (response.getStatus() == OK && verifySignature) {
|
||||||
|
// String body = response.getBody();
|
||||||
|
// JSONObject jsonObject = JSONUtil.parseObj(body);
|
||||||
|
// String prepayId = jsonObject.getStr("prepay_id");
|
||||||
|
// Map<String, String> map = WxPayKit.jsApiCreateSign(wxPayV3Bean.getAppId(), prepayId, wxPayV3Bean.getKeyPath());
|
||||||
|
// log.info("唤起支付参数:{}", map);
|
||||||
|
//
|
||||||
|
// PayInfo payInfo = PayInfo.builder()
|
||||||
|
// .appId(map.get("appId"))
|
||||||
|
// .timeStamp(map.get("timeStamp"))
|
||||||
|
// .signType(map.get("signType"))
|
||||||
|
// .packages(map.get("package"))
|
||||||
|
// .paySign(map.get("paySign"))
|
||||||
|
// .nonceStr(map.get("nonceStr"))
|
||||||
|
// .tradeId(busOrder.getTradeId())
|
||||||
|
// .build();
|
||||||
|
//
|
||||||
|
// //修改订单第三方订单号
|
||||||
|
// busOrder.setOutTradeId(orderId);
|
||||||
|
// busOrder.updateById();
|
||||||
|
// return payInfo;
|
||||||
|
// } else {
|
||||||
|
// throw new ApiException(CodesEnum.ORDER_NO_PAY, "下单失败");
|
||||||
|
// }
|
||||||
|
// } catch (Exception e) {
|
||||||
|
// e.printStackTrace();
|
||||||
|
// throw new ApiException(CodesEnum.ORDER_NO_PAY);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//// @RequestMapping(value = "/payNotify", method = {org.springframework.web.bind.annotation.RequestMethod.POST, org.springframework.web.bind.annotation.RequestMethod.GET})
|
||||||
|
//// @ResponseBody
|
||||||
|
//// public void payNotify(HttpServletRequest request, HttpServletResponse response) {
|
||||||
|
//// Map<String, String> map = new HashMap<>(12);
|
||||||
|
//// try {
|
||||||
|
//// String timestamp = request.getHeader("Wechatpay-Timestamp");
|
||||||
|
//// String nonce = request.getHeader("Wechatpay-Nonce");
|
||||||
|
//// String serialNo = request.getHeader("Wechatpay-Serial");
|
||||||
|
//// String signature = request.getHeader("Wechatpay-Signature");
|
||||||
|
////
|
||||||
|
//// log.info("timestamp:{} nonce:{} serialNo:{} signature:{}", timestamp, nonce, serialNo, signature);
|
||||||
|
//// String result = HttpKit.readData(request);
|
||||||
|
//// log.info("支付通知密文 {}", result);
|
||||||
|
////
|
||||||
|
//// // 需要通过证书序列号查找对应的证书,verifyNotify 中有验证证书的序列号
|
||||||
|
//// String plainText = WxPayKit.verifyNotify(serialNo, result, signature, nonce, timestamp,
|
||||||
|
//// wxPayV3Bean.getApiKey3(), wxPayV3Bean.getPlatformCertPath());
|
||||||
|
////
|
||||||
|
//// log.info("支付通知明文 {}", plainText);
|
||||||
|
////
|
||||||
|
//// //{"mchid":"1582016391","appid":"wx51a69eb75daf10ab","out_trade_no":"32b42214fef54ddebc9ffcb5bcaa8c8f",
|
||||||
|
//// // "transaction_id":"4200001831202305083598654721","trade_type":"JSAPI","trade_state":"SUCCESS",
|
||||||
|
//// // "trade_state_desc":"支付成功","bank_type":"OTHERS","attach":"商品支付","success_time":"2023-05-08T21:15:41+08:00",
|
||||||
|
//// // "payer":{"openid":"oVINv55rQ61qkn3oBheBI79cLvVY"},"amount":{"total":20,"payer_total":20,"currency":"CNY","payer_currency":"CNY"}}
|
||||||
|
////
|
||||||
|
//// if (StrUtil.isNotEmpty(plainText)) {
|
||||||
|
////
|
||||||
|
//// JSONObject jsonObject = JSONUtil.parseObj(plainText);
|
||||||
|
//// JSONObject amount = jsonObject.getJSONObject("amount");
|
||||||
|
////
|
||||||
|
//// String outTradeNo = jsonObject.getStr("out_trade_no");
|
||||||
|
//// String transactionId = jsonObject.getStr("transaction_id");
|
||||||
|
//// String amountTotal = amount.getStr("total");
|
||||||
|
////
|
||||||
|
//// if ("SUCCESS".equals(jsonObject.getStr("trade_state"))) {
|
||||||
|
//// orderService.paySuccess(outTradeNo, transactionId);
|
||||||
|
//// } else {
|
||||||
|
//// //支付失败
|
||||||
|
//// orderService.payFail(outTradeNo);
|
||||||
|
//// }
|
||||||
|
//// response.setStatus(200);
|
||||||
|
//// response.setStatus(200);
|
||||||
|
//// map.put("code", "SUCCESS");
|
||||||
|
//// map.put("message", "SUCCESS");
|
||||||
|
//// } else {
|
||||||
|
//// response.setStatus(500);
|
||||||
|
//// map.put("code", "ERROR");
|
||||||
|
//// map.put("message", "签名错误");
|
||||||
|
//// }
|
||||||
|
//// response.setHeader("Content-type", ContentType.JSON.toString());
|
||||||
|
//// response.getOutputStream().write(JSONUtil.toJsonStr(map).getBytes(StandardCharsets.UTF_8));
|
||||||
|
//// response.flushBuffer();
|
||||||
|
//// } catch (Exception e) {
|
||||||
|
//// e.printStackTrace();
|
||||||
|
//// }
|
||||||
|
//// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// /* private String getSerialNumber() {
|
||||||
|
// if (StrUtil.isEmpty(serialNo)) {
|
||||||
|
// // 获取证书序列号
|
||||||
|
// X509Certificate certificate = PayKit.getCertificate(wxPayV3Bean.getCertPath());
|
||||||
|
// if (null != certificate) {
|
||||||
|
// serialNo = certificate.getSerialNumber().toString(16).toUpperCase();
|
||||||
|
// // 提前两天检查证书是否有效
|
||||||
|
// boolean isValid = PayKit.checkCertificateIsValid(certificate, wxPayV3Bean.getMchId(), -2);
|
||||||
|
// log.info("证书是否可用 {} 证书有效期为 {}", isValid, DateUtil.format(certificate.getNotAfter(), DatePattern.NORM_DATETIME_PATTERN));
|
||||||
|
// }
|
||||||
|
// System.out.println("输出证书信息:\n" + certificate.toString());
|
||||||
|
// // 输出关键信息,截取部分并进行标记
|
||||||
|
// System.out.println("证书序列号:" + certificate.getSerialNumber().toString(16));
|
||||||
|
// System.out.println("版本号:" + certificate.getVersion());
|
||||||
|
// System.out.println("签发者:" + certificate.getIssuerDN());
|
||||||
|
// System.out.println("有效起始日期:" + certificate.getNotBefore());
|
||||||
|
// System.out.println("有效终止日期:" + certificate.getNotAfter());
|
||||||
|
// System.out.println("主体名:" + certificate.getSubjectDN());
|
||||||
|
// System.out.println("签名算法:" + certificate.getSigAlgName());
|
||||||
|
// System.out.println("签名:" + certificate.getSignature().toString());
|
||||||
|
// }
|
||||||
|
// System.out.println("serialNo:" + serialNo);
|
||||||
|
// return serialNo;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @ApiOperation(value = "支付2", httpMethod = "GET", protocols = "HTTP")
|
||||||
|
// @RequestMapping("/get")
|
||||||
|
// @ResponseBody
|
||||||
|
// public R<String> v3Get() {
|
||||||
|
// // 获取平台证书列表
|
||||||
|
// try {
|
||||||
|
// IJPayHttpResponse response = WxPayApi.v3(
|
||||||
|
// RequestMethodEnum.GET,
|
||||||
|
// WxDomainEnum.CHINA.toString(),
|
||||||
|
// OtherApiEnum.GET_CERTIFICATES.toString(),
|
||||||
|
// wxPayV3Bean.getMchId(),
|
||||||
|
// getSerialNumber(),
|
||||||
|
// null,
|
||||||
|
// wxPayV3Bean.getKeyPath(),
|
||||||
|
// ""
|
||||||
|
// );
|
||||||
|
//
|
||||||
|
// String timestamp = response.getHeader("Wechatpay-Timestamp");
|
||||||
|
// String nonceStr = response.getHeader("Wechatpay-Nonce");
|
||||||
|
// String serialNumber = response.getHeader("Wechatpay-Serial");
|
||||||
|
// String signature = response.getHeader("Wechatpay-Signature");
|
||||||
|
//
|
||||||
|
// String body = response.getBody();
|
||||||
|
// int status = response.getStatus();
|
||||||
|
//
|
||||||
|
// log.info("serialNumber: {}", serialNumber);
|
||||||
|
// log.info("status: {}", status);
|
||||||
|
// log.info("body: {}", body);
|
||||||
|
// int isOk = 200;
|
||||||
|
// if (status == isOk) {
|
||||||
|
// JSONObject jsonObject = JSONUtil.parseObj(body);
|
||||||
|
// JSONArray dataArray = jsonObject.getJSONArray("data");
|
||||||
|
// // 默认认为只有一个平台证书
|
||||||
|
// JSONObject encryptObject = dataArray.getJSONObject(0);
|
||||||
|
// JSONObject encryptCertificate = encryptObject.getJSONObject("encrypt_certificate");
|
||||||
|
// String associatedData = encryptCertificate.getStr("associated_data");
|
||||||
|
// String cipherText = encryptCertificate.getStr("ciphertext");
|
||||||
|
// String nonce = encryptCertificate.getStr("nonce");
|
||||||
|
// String serialNo = encryptObject.getStr("serial_no");
|
||||||
|
// final String platSerialNo = savePlatformCert(associatedData, nonce, cipherText, wxPayV3Bean.getPlatformCertPath());
|
||||||
|
// log.info("平台证书序列号: {} serialNo: {}", platSerialNo, serialNo);
|
||||||
|
// }
|
||||||
|
// // 根据证书序列号查询对应的证书来验证签名结果
|
||||||
|
// boolean verifySignature = WxPayKit.verifySignature(response, wxPayV3Bean.getPlatformCertPath());
|
||||||
|
// System.out.println("verifySignature:" + verifySignature);
|
||||||
|
// return R.success(body);
|
||||||
|
// } catch (Exception e) {
|
||||||
|
// e.printStackTrace();
|
||||||
|
// return null;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// private String savePlatformCert(String associatedData, String nonce, String cipherText, String certPath) {
|
||||||
|
// try {
|
||||||
|
// AesUtil aesUtil = new AesUtil(wxPayV3Bean.getApiKey3().getBytes(StandardCharsets.UTF_8));
|
||||||
|
// // 平台证书密文解密
|
||||||
|
// // encrypt_certificate 中的 associated_data nonce ciphertext
|
||||||
|
// String publicKey = aesUtil.decryptToString(
|
||||||
|
// associatedData.getBytes(StandardCharsets.UTF_8),
|
||||||
|
// nonce.getBytes(StandardCharsets.UTF_8),
|
||||||
|
// cipherText
|
||||||
|
// );
|
||||||
|
// // 保存证书
|
||||||
|
// FileWriter writer = new FileWriter(certPath);
|
||||||
|
// writer.write(publicKey);
|
||||||
|
// // 获取平台证书序列号
|
||||||
|
// X509Certificate certificate = PayKit.getCertificate(new ByteArrayInputStream(publicKey.getBytes()));
|
||||||
|
// return certificate.getSerialNumber().toString(16).toUpperCase();
|
||||||
|
// } catch (Exception e) {
|
||||||
|
// e.printStackTrace();
|
||||||
|
// return e.getMessage();
|
||||||
|
// }
|
||||||
|
// }*/
|
||||||
|
//
|
||||||
|
//}
|
||||||
|
|
@ -0,0 +1,213 @@
|
||||||
|
//package com.gfwl.api.controller;
|
||||||
|
//
|
||||||
|
//import cn.hutool.core.date.DatePattern;
|
||||||
|
//import cn.hutool.core.date.DateUtil;
|
||||||
|
//import cn.hutool.core.util.StrUtil;
|
||||||
|
//import cn.hutool.http.ContentType;
|
||||||
|
//import cn.hutool.json.JSONObject;
|
||||||
|
//import cn.hutool.json.JSONUtil;
|
||||||
|
//import com.gfwl.api.base.BaseApiController;
|
||||||
|
//import com.gfwl.api.base.CodesEnum;
|
||||||
|
//import com.gfwl.api.base.R;
|
||||||
|
//import com.gfwl.common.entity.BusOrder;
|
||||||
|
//import com.gfwl.common.service.BusOrderService;
|
||||||
|
//import com.gfwl.config.consts.Global;
|
||||||
|
//import com.gfwl.config.exception.ApiException;
|
||||||
|
//import com.gfwl.config.pay.WxPayV3Bean;
|
||||||
|
//import com.github.xiaoymin.knife4j.annotations.ApiSupport;
|
||||||
|
//import com.ijpay.core.IJPayHttpResponse;
|
||||||
|
//import com.ijpay.core.enums.RequestMethodEnum;
|
||||||
|
//import com.ijpay.core.kit.HttpKit;
|
||||||
|
//import com.ijpay.core.kit.PayKit;
|
||||||
|
//import com.ijpay.core.kit.WxPayKit;
|
||||||
|
//import com.ijpay.wxpay.WxPayApi;
|
||||||
|
//import com.ijpay.wxpay.enums.WxDomainEnum;
|
||||||
|
//import com.ijpay.wxpay.enums.v3.BasePayApiEnum;
|
||||||
|
//import com.ijpay.wxpay.model.v3.RefundAmount;
|
||||||
|
//import com.ijpay.wxpay.model.v3.RefundGoodsDetail;
|
||||||
|
//import com.ijpay.wxpay.model.v3.RefundModel;
|
||||||
|
//import io.swagger.annotations.Api;
|
||||||
|
//import io.swagger.annotations.ApiImplicitParam;
|
||||||
|
//import io.swagger.annotations.ApiOperation;
|
||||||
|
//import lombok.extern.slf4j.Slf4j;
|
||||||
|
//import org.springframework.stereotype.Controller;
|
||||||
|
//import org.springframework.web.bind.annotation.*;
|
||||||
|
//
|
||||||
|
//import javax.annotation.Resource;
|
||||||
|
//import javax.servlet.http.HttpServletRequest;
|
||||||
|
//import javax.servlet.http.HttpServletResponse;
|
||||||
|
//import java.math.BigDecimal;
|
||||||
|
//import java.nio.charset.StandardCharsets;
|
||||||
|
//import java.security.cert.X509Certificate;
|
||||||
|
//import java.util.ArrayList;
|
||||||
|
//import java.util.HashMap;
|
||||||
|
//import java.util.List;
|
||||||
|
//import java.util.Map;
|
||||||
|
//
|
||||||
|
///**
|
||||||
|
// * @className: PayRefundController
|
||||||
|
// *
|
||||||
|
// * Created by 小明
|
||||||
|
// * @create: 2023-04-26 19:36
|
||||||
|
// */
|
||||||
|
//@Slf4j
|
||||||
|
//@Controller
|
||||||
|
//@Api(
|
||||||
|
// value = "退款接口",
|
||||||
|
// tags = {"退款接口"},
|
||||||
|
// produces = "application/json"
|
||||||
|
//)
|
||||||
|
//@ApiSupport(author = Global.interface_author)
|
||||||
|
//@RequestMapping("/api/v1/payrefund")
|
||||||
|
//public class PayRefundController extends BaseApiController {
|
||||||
|
// @Resource
|
||||||
|
// WxPayV3Bean wxPayV3Bean;
|
||||||
|
//
|
||||||
|
// private final static int OK = 200;
|
||||||
|
//
|
||||||
|
// String serialNo;
|
||||||
|
//
|
||||||
|
// @Resource
|
||||||
|
// private BusOrderService orderService;
|
||||||
|
//
|
||||||
|
// @ResponseBody
|
||||||
|
// @ApiImplicitParam(name = "orderId", value = "订单ID", dataType = "String", paramType = "String", required = true)
|
||||||
|
// @ApiOperation(value = "退款", httpMethod = "GET", protocols = "HTTP")
|
||||||
|
// @GetMapping("/refund")
|
||||||
|
// public R<String> refund(@RequestParam(required = true) String orderId) {
|
||||||
|
// BusOrder busOrder = orderService.getById(orderId);
|
||||||
|
// if (busOrder == null) {
|
||||||
|
// throw new ApiException(CodesEnum.DATA_NOT_FOUND, "订单不存在");
|
||||||
|
// }
|
||||||
|
// if (busOrder.getStates() == 3 || busOrder.getStates() == 1) {
|
||||||
|
// throw new ApiException(CodesEnum.ERROR, "订单未支付");
|
||||||
|
// }
|
||||||
|
// if (busOrder.getStates() > 3) {
|
||||||
|
// throw new ApiException(CodesEnum.ERROR, "订单无法退款");
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// try {
|
||||||
|
// String outRefundNo = PayKit.generateStr();
|
||||||
|
// log.info("商户退款单号: {}", outRefundNo);
|
||||||
|
//
|
||||||
|
// int refundAmount = busOrder.getPrices().multiply(BigDecimal.valueOf(100)).intValue();
|
||||||
|
// List<RefundGoodsDetail> list = new ArrayList<>();
|
||||||
|
// RefundGoodsDetail refundGoodsDetail = new RefundGoodsDetail()
|
||||||
|
// .setMerchant_goods_id(busOrder.getTradeId())
|
||||||
|
// .setGoods_name("菜品")
|
||||||
|
// .setUnit_price(refundAmount)
|
||||||
|
// .setRefund_amount(refundAmount)
|
||||||
|
// .setRefund_quantity(1);
|
||||||
|
// list.add(refundGoodsDetail);
|
||||||
|
//
|
||||||
|
// RefundModel refundModel = new RefundModel()
|
||||||
|
// .setOut_refund_no(outRefundNo)
|
||||||
|
// .setReason("主动退款")
|
||||||
|
// .setNotify_url(wxPayV3Bean.getDomain().concat("/api/v1/payrefund/refundNotify"))
|
||||||
|
// .setAmount(new RefundAmount().setRefund(1).setTotal(refundAmount).setCurrency("CNY"))
|
||||||
|
// .setGoods_detail(list);
|
||||||
|
//
|
||||||
|
// refundModel.setOut_trade_no(busOrder.getOutTradeId());
|
||||||
|
//
|
||||||
|
// log.info("退款参数 {}", JSONUtil.toJsonStr(refundModel));
|
||||||
|
// IJPayHttpResponse response = WxPayApi.v3(
|
||||||
|
// RequestMethodEnum.POST,
|
||||||
|
// WxDomainEnum.CHINA.toString(),
|
||||||
|
// BasePayApiEnum.REFUND.toString(),
|
||||||
|
// wxPayV3Bean.getMchId(),
|
||||||
|
// getSerialNumber(),
|
||||||
|
// null,
|
||||||
|
// wxPayV3Bean.getKeyPath(),
|
||||||
|
// JSONUtil.toJsonStr(refundModel)
|
||||||
|
// );
|
||||||
|
// // 根据证书序列号查询对应的证书来验证签名结果
|
||||||
|
// boolean verifySignature = WxPayKit.verifySignature(response, wxPayV3Bean.getPlatformCertPath());
|
||||||
|
// log.info("verifySignature: {}", verifySignature);
|
||||||
|
// log.info("退款响应 {}", response);
|
||||||
|
//
|
||||||
|
// if (verifySignature) {
|
||||||
|
// return R.success(response.getBody());
|
||||||
|
// }
|
||||||
|
// } catch (Exception e) {
|
||||||
|
// e.printStackTrace();
|
||||||
|
// return R.failed(CodesEnum.FAILED, e.getMessage());
|
||||||
|
// }
|
||||||
|
// return null;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @RequestMapping(value = "/refundNotify", method = {RequestMethod.POST, RequestMethod.GET})
|
||||||
|
// @ResponseBody
|
||||||
|
// public void payNotify(HttpServletRequest request, HttpServletResponse response) {
|
||||||
|
// Map<String, String> map = new HashMap<>(12);
|
||||||
|
// try {
|
||||||
|
// String timestamp = request.getHeader("Wechatpay-Timestamp");
|
||||||
|
// String nonce = request.getHeader("Wechatpay-Nonce");
|
||||||
|
// String serialNo = request.getHeader("Wechatpay-Serial");
|
||||||
|
// String signature = request.getHeader("Wechatpay-Signature");
|
||||||
|
//
|
||||||
|
// log.info("timestamp:{} nonce:{} serialNo:{} signature:{}", timestamp, nonce, serialNo, signature);
|
||||||
|
// String result = HttpKit.readData(request);
|
||||||
|
// log.info("退款支付通知密文 {}", result);
|
||||||
|
//
|
||||||
|
// // 需要通过证书序列号查找对应的证书,verifyNotify 中有验证证书的序列号
|
||||||
|
// String plainText = WxPayKit.verifyNotify(serialNo, result, signature, nonce, timestamp,
|
||||||
|
// wxPayV3Bean.getApiKey3(), wxPayV3Bean.getPlatformCertPath());
|
||||||
|
//
|
||||||
|
// log.info("退款支付通知密文 {}", plainText);
|
||||||
|
//
|
||||||
|
// // 退款支付通知密文 {"mchid":"1582016391","out_trade_no":"32b42214fef54ddebc9ffcb5bcaa8c8f",
|
||||||
|
// // "transaction_id":"4200001831202305083598654721","out_refund_no":"bda33e5787274f4a83028ac14a3a3a27",
|
||||||
|
// // "refund_id":"50300605442023050834217678691","refund_status":"SUCCESS","success_time":"2023-05-08T21:49:38+08:00",
|
||||||
|
// // "amount":{"total":20,"refund":1,"payer_total":20,"payer_refund":1},"user_received_account":"支付用户零钱"}
|
||||||
|
//
|
||||||
|
//// 退款支付通知密文 {"mchid":"1582016391","out_trade_no":"c75cda04f14546eb89af0b0d0fb9dfdc","transaction_id":"4200001849202305083972538302",
|
||||||
|
//// "out_refund_no":"f19fed3e88fa44db83f4dc1fba52438f","refund_id":"50300705502023050834214807784","refund_status":"SUCCESS",
|
||||||
|
//// "success_time":"2023-05-08T22:40:46+08:00","amount":{"total":20,"refund":1,"payer_total":20,"payer_refund":1},"user_received_account":"支付用户零钱"}
|
||||||
|
//
|
||||||
|
// if (StrUtil.isNotEmpty(plainText)) {
|
||||||
|
//
|
||||||
|
// JSONObject jsonObject = JSONUtil.parseObj(plainText);
|
||||||
|
// JSONObject amount = jsonObject.getJSONObject("amount");
|
||||||
|
//
|
||||||
|
// String outTradeNo = jsonObject.getStr("out_trade_no");
|
||||||
|
// String transactionId = jsonObject.getStr("out_refund_no");
|
||||||
|
// String amountTotal = amount.getStr("total");
|
||||||
|
//
|
||||||
|
// if ("SUCCESS".equals(jsonObject.getStr("refund_status"))) {
|
||||||
|
// orderService.refundSuccess(outTradeNo, transactionId);
|
||||||
|
// } else {
|
||||||
|
// //支付失败
|
||||||
|
// orderService.refundFail(outTradeNo);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// response.setStatus(200);
|
||||||
|
// map.put("code", "SUCCESS");
|
||||||
|
// map.put("message", "SUCCESS");
|
||||||
|
// } else {
|
||||||
|
// response.setStatus(500);
|
||||||
|
// map.put("code", "ERROR");
|
||||||
|
// map.put("message", "签名错误");
|
||||||
|
// }
|
||||||
|
// response.setHeader("Content-type", ContentType.JSON.toString());
|
||||||
|
// response.getOutputStream().write(JSONUtil.toJsonStr(map).getBytes(StandardCharsets.UTF_8));
|
||||||
|
// response.flushBuffer();
|
||||||
|
// } catch (Exception e) {
|
||||||
|
// e.printStackTrace();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// private String getSerialNumber() {
|
||||||
|
// if (StrUtil.isEmpty(serialNo)) {
|
||||||
|
// // 获取证书序列号
|
||||||
|
// X509Certificate certificate = PayKit.getCertificate(wxPayV3Bean.getCertPath());
|
||||||
|
// if (null != certificate) {
|
||||||
|
// serialNo = certificate.getSerialNumber().toString(16).toUpperCase();
|
||||||
|
// // 提前两天检查证书是否有效
|
||||||
|
// boolean isValid = PayKit.checkCertificateIsValid(certificate, wxPayV3Bean.getMchId(), -2);
|
||||||
|
// log.info("证书是否可用 {} 证书有效期为 {}", isValid, DateUtil.format(certificate.getNotAfter(), DatePattern.NORM_DATETIME_PATTERN));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// return serialNo;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//}
|
||||||
|
|
@ -0,0 +1,366 @@
|
||||||
|
package com.gfwl.api.controller;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
|
import com.gfwl.api.base.BaseApiController;
|
||||||
|
import com.gfwl.api.base.CodesEnum;
|
||||||
|
import com.gfwl.api.vo.pay.PayInfo;
|
||||||
|
import com.gfwl.common.entity.BusOrder;
|
||||||
|
import com.gfwl.common.entity.BusOrderDetail;
|
||||||
|
import com.gfwl.common.entity.BusUser;
|
||||||
|
import com.gfwl.common.service.BusFoodService;
|
||||||
|
import com.gfwl.common.service.BusOrderDetailService;
|
||||||
|
import com.gfwl.common.service.BusOrderService;
|
||||||
|
import com.gfwl.config.consts.Global;
|
||||||
|
import com.gfwl.config.exception.ApiException;
|
||||||
|
import com.gfwl.config.pay.WxPayBean;
|
||||||
|
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
|
||||||
|
import com.ijpay.core.enums.SignType;
|
||||||
|
import com.ijpay.core.kit.HttpKit;
|
||||||
|
import com.ijpay.core.kit.IpKit;
|
||||||
|
import com.ijpay.core.kit.PayKit;
|
||||||
|
import com.ijpay.core.kit.WxPayKit;
|
||||||
|
import com.ijpay.wxpay.WxPayApi;
|
||||||
|
import com.ijpay.wxpay.model.RefundModel;
|
||||||
|
import com.ijpay.wxpay.model.UnifiedOrderModel;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiImplicitParam;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.BufferedOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @className: PayV3Controller
|
||||||
|
*
|
||||||
|
* Created by 小
|
||||||
|
* @create: 2023-06-02 14:23
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Controller
|
||||||
|
@Api(
|
||||||
|
value = "支付接口",
|
||||||
|
tags = {"支付接口"},
|
||||||
|
produces = "application/json"
|
||||||
|
)
|
||||||
|
@ApiSupport(author = Global.interface_author)
|
||||||
|
@RequestMapping("/api/v1/pay")
|
||||||
|
public class PayV3Controller extends BaseApiController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
WxPayBean wxPayBean;
|
||||||
|
@Resource
|
||||||
|
private BusOrderService orderService;
|
||||||
|
@Resource
|
||||||
|
BusFoodService foodService;
|
||||||
|
@Resource
|
||||||
|
private BusOrderDetailService orderDetailService;
|
||||||
|
|
||||||
|
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
@RequestMapping(value = "/miniAppPay", method = {RequestMethod.POST, RequestMethod.GET})
|
||||||
|
@ApiImplicitParam(name = "orderId", value = "订单ID", dataType = "String", paramType = "String", required = true)
|
||||||
|
@ResponseBody
|
||||||
|
public PayInfo miniAppPay(@RequestParam(value = "orderId", required = true, defaultValue = "") String orderId) {
|
||||||
|
BusOrder busOrder = orderService.getById(orderId);
|
||||||
|
isNullObjAndThrow(busOrder);
|
||||||
|
if (busOrder.getStates() != 1 && busOrder.getStates() != 3) {
|
||||||
|
throw new ApiException(CodesEnum.ORDER_NO_PAY);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (1 == busOrder.getOrderType() && 2 != busOrder.getIsAudit()) {
|
||||||
|
throw new ApiException(CodesEnum.ORDER_NO_PAY);
|
||||||
|
}
|
||||||
|
//校验订单库存
|
||||||
|
List<BusOrderDetail> orderDetails = orderDetailService.list(Wrappers.<BusOrderDetail>lambdaQuery().eq(BusOrderDetail::getOrderId, busOrder.getId()));
|
||||||
|
foodService.isCheckInventoryFood(busOrder,orderDetails);
|
||||||
|
|
||||||
|
BusUser loginUser = getLoginUser();
|
||||||
|
String outReadeNo = PayKit.generateStr();
|
||||||
|
|
||||||
|
try {
|
||||||
|
String ip = IpKit.getRealIp(request);
|
||||||
|
if (StringUtils.isBlank(ip)) {
|
||||||
|
ip = "127.0.0.1";
|
||||||
|
}
|
||||||
|
// 统一下单构建请求参数
|
||||||
|
Map<String, String> params = UnifiedOrderModel
|
||||||
|
.builder()
|
||||||
|
.appid(wxPayBean.getAppId())
|
||||||
|
.mch_id(wxPayBean.getMchId())
|
||||||
|
.nonce_str(WxPayKit.generateStr())
|
||||||
|
.body("哪哒尔商品支付")
|
||||||
|
.attach("哪哒尔")
|
||||||
|
.out_trade_no(outReadeNo)
|
||||||
|
.total_fee(String.valueOf(busOrder.getPrices().multiply(BigDecimal.valueOf(100)).intValue()))
|
||||||
|
.spbill_create_ip(ip)
|
||||||
|
.notify_url(wxPayBean.getDomain().concat("api/v1/pay/payNotify"))
|
||||||
|
.trade_type(com.ijpay.core.enums.TradeType.JSAPI.getTradeType())
|
||||||
|
.openid(loginUser.getOpenId())
|
||||||
|
.build()
|
||||||
|
.createSign(wxPayBean.getPartnerKey(), SignType.HMACSHA256);
|
||||||
|
|
||||||
|
String xmlResult = WxPayApi.pushOrder(false, params);
|
||||||
|
|
||||||
|
log.error(xmlResult);
|
||||||
|
|
||||||
|
Map<String, String> result = WxPayKit.xmlToMap(xmlResult);
|
||||||
|
|
||||||
|
String returnCode = result.get("return_code");
|
||||||
|
String returnMsg = result.get("return_msg");
|
||||||
|
if (!WxPayKit.codeIsOk(returnCode)) {
|
||||||
|
throw new ApiException(CodesEnum.WX_ERROR, returnMsg);
|
||||||
|
}
|
||||||
|
String resultCode = result.get("result_code");
|
||||||
|
if (!WxPayKit.codeIsOk(resultCode)) {
|
||||||
|
throw new ApiException(CodesEnum.WX_ERROR, returnMsg);
|
||||||
|
}
|
||||||
|
// 以下字段在 return_code 和 result_code 都为 SUCCESS 的时候有返回
|
||||||
|
String prepayId = result.get("prepay_id");
|
||||||
|
Map<String, String> map = WxPayKit.miniAppPrepayIdCreateSign(wxPayBean.getAppId(), prepayId,
|
||||||
|
wxPayBean.getPartnerKey(), SignType.HMACSHA256);
|
||||||
|
String jsonStr = JSON.toJSONString(map);
|
||||||
|
log.info("小程序支付的参数:" + jsonStr);
|
||||||
|
PayInfo payInfo = PayInfo.builder()
|
||||||
|
.appId(map.get("appId"))
|
||||||
|
.timeStamp(map.get("timeStamp"))
|
||||||
|
.signType(map.get("signType"))
|
||||||
|
.packages(map.get("package"))
|
||||||
|
.paySign(map.get("paySign"))
|
||||||
|
.nonceStr(map.get("nonceStr"))
|
||||||
|
.tradeId(busOrder.getTradeId())
|
||||||
|
.build();
|
||||||
|
|
||||||
|
|
||||||
|
busOrder.setOutTradeId(outReadeNo);
|
||||||
|
busOrder.updateById();
|
||||||
|
return payInfo;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
throw new ApiException(CodesEnum.ORDER_NO_PAY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// @RequestMapping(value = "/miniAppPay", method = {RequestMethod.POST, RequestMethod.GET})
|
||||||
|
// @ApiImplicitParam(name = "orderId", value = "订单ID", dataType = "String", paramType = "String", required = true)
|
||||||
|
// @ResponseBody
|
||||||
|
// public PaymentResponse miniAppPay(@RequestParam(value = "orderId", required = true, defaultValue = "") String orderId) {
|
||||||
|
//
|
||||||
|
// BusOrder busOrder = orderService.getById(orderId);
|
||||||
|
// isNullObjAndThrow(busOrder);
|
||||||
|
// if (busOrder.getStates() != 1 && busOrder.getStates() != 3) {
|
||||||
|
// throw new ApiException(CodesEnum.ORDER_NO_PAY);
|
||||||
|
// }
|
||||||
|
// //校验订单库存
|
||||||
|
// List<BusOrderDetail> orderDetails = orderDetailService.list(Wrappers.<BusOrderDetail>lambdaQuery().eq(BusOrderDetail::getOrderId, busOrder.getId()));
|
||||||
|
// foodService.isCheckInventoryFood(orderDetails);
|
||||||
|
//
|
||||||
|
// BusUser loginUser = getLoginUser();
|
||||||
|
//
|
||||||
|
// String tradeNo = IdUtil.simpleUUID();
|
||||||
|
//
|
||||||
|
// String productId = busOrder.getTradeId();
|
||||||
|
// PaymentRequest paymentRequest = new PaymentRequest(
|
||||||
|
// busOrder.getPrices(), loginUser.getOpenId(), "购买菜品", productId, tradeNo,
|
||||||
|
// wxPayBean.getDomain().concat("api/v1/pay/payNotify")
|
||||||
|
// );
|
||||||
|
// paymentRequest.setAmount(busOrder.getPrices());
|
||||||
|
// paymentRequest.setOpenId(loginUser.getOpenId());
|
||||||
|
// paymentRequest.setBody("购买菜品");
|
||||||
|
// paymentRequest.setProductId(productId);
|
||||||
|
// paymentRequest.setTradeNo(tradeNo);
|
||||||
|
// paymentRequest.setNotifyUrl(wxPayBean.getDomain().concat("api/v1/pay/payNotify"));
|
||||||
|
// paymentRequest.setIpAddress(IpUtil.getIpAddr(request));
|
||||||
|
//
|
||||||
|
// System.out.println("支付编号:" + tradeNo);
|
||||||
|
//
|
||||||
|
// PaymentResponse paymentResponse = PayUtil.wxMiniPay(paymentRequest);
|
||||||
|
//
|
||||||
|
// log.info("paymentResponse:::" + paymentResponse.toString());
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// JSONObject jsonObject = JSON.parseObject(paymentResponse.getOrderStr());
|
||||||
|
//
|
||||||
|
// //修改订单第三方订单号
|
||||||
|
// busOrder.setOutTradeId(jsonObject.getString("out_trade_no"));
|
||||||
|
// busOrder.updateById();
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// return paymentResponse;
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
@RequestMapping(value = "/payNotify", method = {org.springframework.web.bind.annotation.RequestMethod.POST, org.springframework.web.bind.annotation.RequestMethod.GET})
|
||||||
|
public void payNotify(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
||||||
|
Map<String, String> map = new HashMap<>(12);
|
||||||
|
|
||||||
|
String resXml = "<xml><return_code><![CDATA[FAIL]]></return_code><return_msg><![CDATA[失败]]></return_msg></xml> ";
|
||||||
|
|
||||||
|
try {
|
||||||
|
String xmlMsg = HttpKit.readData(request);
|
||||||
|
log.info("支付通知=" + xmlMsg);
|
||||||
|
Map<String, String> params = WxPayKit.xmlToMap(xmlMsg);
|
||||||
|
|
||||||
|
String returnCode = params.get("return_code");
|
||||||
|
|
||||||
|
// 注意重复通知的情况,同一订单号可能收到多次通知,请注意一定先判断订单状态
|
||||||
|
// 注意此处签名方式需与统一下单的签名类型一致
|
||||||
|
if (WxPayKit.verifyNotify(params, wxPayBean.getPartnerKey(), SignType.HMACSHA256)) {
|
||||||
|
if (WxPayKit.codeIsOk(returnCode)) {
|
||||||
|
// 更新订单信息
|
||||||
|
String tradeNo = params.get("out_trade_no");
|
||||||
|
String transactionId = params.get("transaction_id");
|
||||||
|
if ("SUCCESS".equals(params.get("result_code"))) {
|
||||||
|
//支付成功
|
||||||
|
orderService.paySuccess(tradeNo, transactionId);
|
||||||
|
//对老订单进行退款
|
||||||
|
oldOrderTuikuan(tradeNo);
|
||||||
|
} else {
|
||||||
|
//支付失败
|
||||||
|
orderService.payFail(tradeNo);
|
||||||
|
}
|
||||||
|
// 发送通知等
|
||||||
|
resXml = "<xml><return_code><![CDATA[SUCCESS]]></return_code><return_msg><![CDATA[OK]]></return_msg></xml> ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BufferedOutputStream out = new BufferedOutputStream(response.getOutputStream());
|
||||||
|
out.write(resXml.getBytes());
|
||||||
|
out.flush();
|
||||||
|
out.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void oldOrderTuikuan(String tradeNo) {
|
||||||
|
BusOrder busOrder = orderService.getOne(Wrappers.<BusOrder>lambdaQuery().eq(BusOrder::getOutTradeId, tradeNo));
|
||||||
|
if (busOrder != null && StringUtils.isNotEmpty(busOrder.getOldOrderId())) {
|
||||||
|
//对老订单进行退款
|
||||||
|
BusOrder oldOrder = orderService.getById(busOrder.getOldOrderId());
|
||||||
|
if (oldOrder != null && oldOrder.getEffective() == 2 && oldOrder.getStates() == 2) {
|
||||||
|
//进行退款
|
||||||
|
Map<String, String> params = RefundModel.builder()
|
||||||
|
.appid(wxPayBean.getAppId())
|
||||||
|
.mch_id(wxPayBean.getMchId())
|
||||||
|
.nonce_str(WxPayKit.generateStr())
|
||||||
|
.out_trade_no(oldOrder.getOutTradeId())
|
||||||
|
.out_refund_no(oldOrder.getOutTradeId())
|
||||||
|
.total_fee(String.valueOf(oldOrder.getPrices().multiply(BigDecimal.valueOf(100)).intValue()))
|
||||||
|
.refund_fee(String.valueOf(oldOrder.getPrices().multiply(BigDecimal.valueOf(100)).intValue()))
|
||||||
|
.notify_url(wxPayBean.getDomain().concat("api/v1/pay/refundNotify"))
|
||||||
|
.build()
|
||||||
|
.createSign(wxPayBean.getPartnerKey(), SignType.MD5);
|
||||||
|
String refundStr = WxPayApi.orderRefund(false, params, wxPayBean.getCertPath(), wxPayBean.getMchId());
|
||||||
|
|
||||||
|
Map<String, String> refundParam = WxPayKit.xmlToMap(refundStr);
|
||||||
|
System.out.println(refundStr);
|
||||||
|
if (refundParam.get("result_code").equals("SUCCESS")) {
|
||||||
|
oldOrder.setStates(4);
|
||||||
|
oldOrder.updateById();
|
||||||
|
System.out.println("更新订单退款成功:" + oldOrder.getId());
|
||||||
|
} else {
|
||||||
|
System.out.println("更新订单退款失败:" + oldOrder.getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// @RequestMapping(value = "/payNotify", method = {org.springframework.web.bind.annotation.RequestMethod.POST, org.springframework.web.bind.annotation.RequestMethod.GET})
|
||||||
|
// public void payNotify(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
||||||
|
// String resXml = "";
|
||||||
|
// try {
|
||||||
|
// CallbackParams callbackParams = PaymentUtils.getCallbackParams(TradeType.WX, wxPayBean.getPartnerKey(), null, request);
|
||||||
|
// System.out.println(DateUtil.date() + "微信支付回调::" + callbackParams.toString());
|
||||||
|
//
|
||||||
|
// if (callbackParams.isTradeStatus()) {
|
||||||
|
// orderService.paySuccess(callbackParams.getTradeNo(), callbackParams.getOutTradeNo());
|
||||||
|
// } else {
|
||||||
|
// //支付失败
|
||||||
|
// orderService.payFail(callbackParams.getTradeNo());
|
||||||
|
// }
|
||||||
|
// resXml = "<xml><return_code><![CDATA[SUCCESS]]></return_code><return_msg><![CDATA[OK]]></return_msg></xml> ";
|
||||||
|
// } catch (Exception e) {
|
||||||
|
// resXml = "<xml><return_code><![CDATA[FAIL]]></return_code><return_msg><![CDATA[" + e.getMessage() + "]]></return_msg></xml> ";
|
||||||
|
// }
|
||||||
|
// BufferedOutputStream out = new BufferedOutputStream(response.getOutputStream());
|
||||||
|
// out.write(resXml.getBytes());
|
||||||
|
// out.flush();
|
||||||
|
// out.close();
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
@RequestMapping(value = "/refundNotify", method = {RequestMethod.POST, RequestMethod.GET})
|
||||||
|
public void refundNotify (HttpServletRequest request, HttpServletResponse response) throws IOException {
|
||||||
|
|
||||||
|
String xmlMsg = HttpKit.readData(request);
|
||||||
|
log.info("退款通知=" + xmlMsg);
|
||||||
|
Map<String, String> params = WxPayKit.xmlToMap(xmlMsg);
|
||||||
|
|
||||||
|
String returnCode = params.get("return_code");
|
||||||
|
// 注意重复通知的情况,同一订单号可能收到多次通知,请注意一定先判断订单状态
|
||||||
|
if (WxPayKit.codeIsOk(returnCode)) {
|
||||||
|
String reqInfo = params.get("req_info");
|
||||||
|
String decryptData = WxPayKit.decryptData(reqInfo, wxPayBean.getPartnerKey());
|
||||||
|
log.info("退款通知解密后的数据=" + decryptData);
|
||||||
|
// 更新订单信息
|
||||||
|
|
||||||
|
|
||||||
|
Map<String, String> reqInfoResut = WxPayKit.xmlToMap(decryptData);
|
||||||
|
|
||||||
|
String tradeNo = reqInfoResut.get("out_trade_no");
|
||||||
|
String transactionId = reqInfoResut.get("transaction_id");
|
||||||
|
|
||||||
|
if ("SUCCESS".equals(reqInfoResut.get("refund_status"))) {
|
||||||
|
//退款成功
|
||||||
|
orderService.refundSuccess(tradeNo, transactionId);
|
||||||
|
} else {
|
||||||
|
//退款失败
|
||||||
|
orderService.refundFail(tradeNo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 发送通知等
|
||||||
|
String resXml = "<xml><return_code><![CDATA[SUCCESS]]></return_code><return_msg><![CDATA[OK]]></return_msg></xml> ";
|
||||||
|
BufferedOutputStream out = new BufferedOutputStream(response.getOutputStream());
|
||||||
|
out.write(resXml.getBytes());
|
||||||
|
out.flush();
|
||||||
|
out.close();
|
||||||
|
|
||||||
|
// String resXml = "";
|
||||||
|
// try {
|
||||||
|
// CallbackParams callbackParams = PaymentUtils.getCallbackParams(TradeType.WX, wxPayBean.getPartnerKey(), null, request);
|
||||||
|
// System.out.println(DateUtil.date() + "微信退款回调::" + callbackParams.toString());
|
||||||
|
//
|
||||||
|
// if (callbackParams.isTradeStatus()) {
|
||||||
|
// orderService.refundSuccess(callbackParams.getTradeNo(), callbackParams.getOutTradeNo());
|
||||||
|
// } else {
|
||||||
|
// //支付失败
|
||||||
|
// orderService.refundFail(callbackParams.getTradeNo());
|
||||||
|
// }
|
||||||
|
// resXml = "<xml><return_code><![CDATA[SUCCESS]]></return_code><return_msg><![CDATA[OK]]></return_msg></xml> ";
|
||||||
|
// } catch (Exception e) {
|
||||||
|
// resXml = "<xml><return_code><![CDATA[FAIL]]></return_code><return_msg><![CDATA[" + e.getMessage() + "]]></return_msg></xml> ";
|
||||||
|
// }
|
||||||
|
// BufferedOutputStream out = new BufferedOutputStream(response.getOutputStream());
|
||||||
|
// out.write(resXml.getBytes());
|
||||||
|
// out.flush();
|
||||||
|
// out.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,47 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2019-2020 Zheng Jie
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package com.gfwl.api.utils;
|
||||||
|
|
||||||
|
import java.io.Closeable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Zheng Jie
|
||||||
|
* @website https://eladmin.vip
|
||||||
|
* @description 用于关闭各种连接,缺啥补啥
|
||||||
|
* @date 2021-03-05
|
||||||
|
**/
|
||||||
|
public class CloseUtil {
|
||||||
|
|
||||||
|
public static void close(Closeable closeable) {
|
||||||
|
if (null != closeable) {
|
||||||
|
try {
|
||||||
|
closeable.close();
|
||||||
|
} catch (Exception e) {
|
||||||
|
// 静默关闭
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void close(AutoCloseable closeable) {
|
||||||
|
if (null != closeable) {
|
||||||
|
try {
|
||||||
|
closeable.close();
|
||||||
|
} catch (Exception e) {
|
||||||
|
// 静默关闭
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,387 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2019-2020 Zheng Jie
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package com.gfwl.api.utils;
|
||||||
|
|
||||||
|
import cn.hutool.core.io.IoUtil;
|
||||||
|
import cn.hutool.core.util.IdUtil;
|
||||||
|
import cn.hutool.poi.excel.BigExcelWriter;
|
||||||
|
import cn.hutool.poi.excel.ExcelUtil;
|
||||||
|
import org.apache.poi.util.IOUtils;
|
||||||
|
import org.apache.poi.xssf.streaming.SXSSFSheet;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
import javax.servlet.ServletOutputStream;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.*;
|
||||||
|
import java.security.MessageDigest;
|
||||||
|
import java.text.DecimalFormat;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* File工具类,扩展 hutool 工具包
|
||||||
|
*
|
||||||
|
* @author Zheng Jie
|
||||||
|
* @date 2018-12-27
|
||||||
|
*/
|
||||||
|
public class FileUtil extends cn.hutool.core.io.FileUtil {
|
||||||
|
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(FileUtil.class);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 系统临时目录
|
||||||
|
* <br>
|
||||||
|
* windows 包含路径分割符,但Linux 不包含,
|
||||||
|
* 在windows \\==\ 前提下,
|
||||||
|
* 为安全起见 同意拼装 路径分割符,
|
||||||
|
* <pre>
|
||||||
|
* java.io.tmpdir
|
||||||
|
* windows : C:\Users/xxx\AppData\Local\Temp\
|
||||||
|
* linux: /temp
|
||||||
|
* </pre>
|
||||||
|
*/
|
||||||
|
public static final String SYS_TEM_DIR = System.getProperty("java.io.tmpdir") + File.separator;
|
||||||
|
/**
|
||||||
|
* 定义GB的计算常量
|
||||||
|
*/
|
||||||
|
private static final int GB = 1024 * 1024 * 1024;
|
||||||
|
/**
|
||||||
|
* 定义MB的计算常量
|
||||||
|
*/
|
||||||
|
private static final int MB = 1024 * 1024;
|
||||||
|
/**
|
||||||
|
* 定义KB的计算常量
|
||||||
|
*/
|
||||||
|
private static final int KB = 1024;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 格式化小数
|
||||||
|
*/
|
||||||
|
private static final DecimalFormat DF = new DecimalFormat("0.00");
|
||||||
|
|
||||||
|
public static final String IMAGE = "图片";
|
||||||
|
public static final String TXT = "文档";
|
||||||
|
public static final String MUSIC = "音乐";
|
||||||
|
public static final String VIDEO = "视频";
|
||||||
|
public static final String OTHER = "其他";
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MultipartFile转File
|
||||||
|
*/
|
||||||
|
public static File toFile(MultipartFile multipartFile) {
|
||||||
|
// 获取文件名
|
||||||
|
String fileName = multipartFile.getOriginalFilename();
|
||||||
|
// 获取文件后缀
|
||||||
|
String prefix = "." + getExtensionName(fileName);
|
||||||
|
File file = null;
|
||||||
|
try {
|
||||||
|
// 用uuid作为文件名,防止生成的临时文件重复
|
||||||
|
file = new File(SYS_TEM_DIR + IdUtil.simpleUUID() + prefix);
|
||||||
|
// MultipartFile to File
|
||||||
|
multipartFile.transferTo(file);
|
||||||
|
} catch (IOException e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
return file;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取文件扩展名,不带 .
|
||||||
|
*/
|
||||||
|
public static String getExtensionName(String filename) {
|
||||||
|
if ((filename != null) && (filename.length() > 0)) {
|
||||||
|
int dot = filename.lastIndexOf('.');
|
||||||
|
if ((dot > -1) && (dot < (filename.length() - 1))) {
|
||||||
|
return filename.substring(dot + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return filename;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Java文件操作 获取不带扩展名的文件名
|
||||||
|
*/
|
||||||
|
public static String getFileNameNoEx(String filename) {
|
||||||
|
if ((filename != null) && (filename.length() > 0)) {
|
||||||
|
int dot = filename.lastIndexOf('.');
|
||||||
|
if ((dot > -1) && (dot < (filename.length()))) {
|
||||||
|
return filename.substring(0, dot);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return filename;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件大小转换
|
||||||
|
*/
|
||||||
|
public static String getSize(long size) {
|
||||||
|
String resultSize;
|
||||||
|
if (size / GB >= 1) {
|
||||||
|
//如果当前Byte的值大于等于1GB
|
||||||
|
resultSize = DF.format(size / (float) GB) + "GB ";
|
||||||
|
} else if (size / MB >= 1) {
|
||||||
|
//如果当前Byte的值大于等于1MB
|
||||||
|
resultSize = DF.format(size / (float) MB) + "MB ";
|
||||||
|
} else if (size / KB >= 1) {
|
||||||
|
//如果当前Byte的值大于等于1KB
|
||||||
|
resultSize = DF.format(size / (float) KB) + "KB ";
|
||||||
|
} else {
|
||||||
|
resultSize = size + "B ";
|
||||||
|
}
|
||||||
|
return resultSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* inputStream 转 File
|
||||||
|
*/
|
||||||
|
static File inputStreamToFile(InputStream ins, String name){
|
||||||
|
File file = new File(SYS_TEM_DIR + name);
|
||||||
|
if (file.exists()) {
|
||||||
|
return file;
|
||||||
|
}
|
||||||
|
OutputStream os = null;
|
||||||
|
try {
|
||||||
|
os = new FileOutputStream(file);
|
||||||
|
int bytesRead;
|
||||||
|
int len = 8192;
|
||||||
|
byte[] buffer = new byte[len];
|
||||||
|
while ((bytesRead = ins.read(buffer, 0, len)) != -1) {
|
||||||
|
os.write(buffer, 0, bytesRead);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
CloseUtil.close(os);
|
||||||
|
CloseUtil.close(ins);
|
||||||
|
}
|
||||||
|
return file;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将文件名解析成文件的上传路径
|
||||||
|
*/
|
||||||
|
public static File upload(MultipartFile file, String filePath) {
|
||||||
|
Date date = new Date();
|
||||||
|
SimpleDateFormat format = new SimpleDateFormat("yyyyMMddhhmmssS");
|
||||||
|
// 过滤非法文件名
|
||||||
|
String name = getFileNameNoEx(verifyFilename(file.getOriginalFilename()));
|
||||||
|
String suffix = getExtensionName(file.getOriginalFilename());
|
||||||
|
String nowStr = "-" + format.format(date);
|
||||||
|
try {
|
||||||
|
String fileName = name + nowStr + "." + suffix;
|
||||||
|
String path = filePath + fileName;
|
||||||
|
// getCanonicalFile 可解析正确各种路径
|
||||||
|
File dest = new File(path).getCanonicalFile();
|
||||||
|
// 检测是否存在目录
|
||||||
|
if (!dest.getParentFile().exists()) {
|
||||||
|
if (!dest.getParentFile().mkdirs()) {
|
||||||
|
System.out.println("was not successful.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 文件写入
|
||||||
|
file.transferTo(dest);
|
||||||
|
return dest;
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出excel
|
||||||
|
*/
|
||||||
|
public static void downloadExcel(List<Map<String, Object>> list, HttpServletResponse response) throws IOException {
|
||||||
|
String tempPath = SYS_TEM_DIR + IdUtil.fastSimpleUUID() + ".xlsx";
|
||||||
|
File file = new File(tempPath);
|
||||||
|
BigExcelWriter writer = ExcelUtil.getBigWriter(file);
|
||||||
|
// 一次性写出内容,使用默认样式,强制输出标题
|
||||||
|
writer.write(list, true);
|
||||||
|
SXSSFSheet sheet = (SXSSFSheet)writer.getSheet();
|
||||||
|
//上面需要强转SXSSFSheet 不然没有trackAllColumnsForAutoSizing方法
|
||||||
|
sheet.trackAllColumnsForAutoSizing();
|
||||||
|
//列宽自适应
|
||||||
|
writer.autoSizeColumnAll();
|
||||||
|
//response为HttpServletResponse对象
|
||||||
|
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8");
|
||||||
|
//test.xls是弹出下载对话框的文件名,不能为中文,中文请自行编码
|
||||||
|
response.setHeader("Content-Disposition", "attachment;filename=file.xlsx");
|
||||||
|
ServletOutputStream out = response.getOutputStream();
|
||||||
|
// 终止后删除临时文件
|
||||||
|
file.deleteOnExit();
|
||||||
|
writer.flush(out, true);
|
||||||
|
//此处记得关闭输出Servlet流
|
||||||
|
IoUtil.close(out);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getFileType(String type) {
|
||||||
|
String documents = "txt doc pdf ppt pps xlsx xls docx";
|
||||||
|
String music = "mp3 wav wma mpa ram ra aac aif m4a";
|
||||||
|
String video = "avi mpg mpe mpeg asf wmv mov qt rm mp4 flv m4v webm ogv ogg";
|
||||||
|
String image = "bmp dib pcp dif wmf gif jpg tif eps psd cdr iff tga pcd mpt png jpeg";
|
||||||
|
if (image.contains(type)) {
|
||||||
|
return IMAGE;
|
||||||
|
} else if (documents.contains(type)) {
|
||||||
|
return TXT;
|
||||||
|
} else if (music.contains(type)) {
|
||||||
|
return MUSIC;
|
||||||
|
} else if (video.contains(type)) {
|
||||||
|
return VIDEO;
|
||||||
|
} else {
|
||||||
|
return OTHER;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断两个文件是否相同
|
||||||
|
*/
|
||||||
|
public static boolean check(File file1, File file2) {
|
||||||
|
String img1Md5 = getMd5(file1);
|
||||||
|
String img2Md5 = getMd5(file2);
|
||||||
|
if(img1Md5 != null){
|
||||||
|
return img1Md5.equals(img2Md5);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断两个文件是否相同
|
||||||
|
*/
|
||||||
|
public static boolean check(String file1Md5, String file2Md5) {
|
||||||
|
return file1Md5.equals(file2Md5);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static byte[] getByte(File file) {
|
||||||
|
// 得到文件长度
|
||||||
|
byte[] b = new byte[(int) file.length()];
|
||||||
|
InputStream in = null;
|
||||||
|
try {
|
||||||
|
in = new FileInputStream(file);
|
||||||
|
try {
|
||||||
|
System.out.println(in.read(b));
|
||||||
|
} catch (IOException e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
return null;
|
||||||
|
} finally {
|
||||||
|
CloseUtil.close(in);
|
||||||
|
}
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String getMd5(byte[] bytes) {
|
||||||
|
// 16进制字符
|
||||||
|
char[] hexDigits = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
|
||||||
|
try {
|
||||||
|
MessageDigest mdTemp = MessageDigest.getInstance("MD5");
|
||||||
|
mdTemp.update(bytes);
|
||||||
|
byte[] md = mdTemp.digest();
|
||||||
|
int j = md.length;
|
||||||
|
char[] str = new char[j * 2];
|
||||||
|
int k = 0;
|
||||||
|
// 移位 输出字符串
|
||||||
|
for (byte byte0 : md) {
|
||||||
|
str[k++] = hexDigits[byte0 >>> 4 & 0xf];
|
||||||
|
str[k++] = hexDigits[byte0 & 0xf];
|
||||||
|
}
|
||||||
|
return new String(str);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 下载文件
|
||||||
|
*
|
||||||
|
* @param request /
|
||||||
|
* @param response /
|
||||||
|
* @param file /
|
||||||
|
*/
|
||||||
|
public static void downloadFile(HttpServletRequest request, HttpServletResponse response, File file, boolean deleteOnExit) {
|
||||||
|
response.setCharacterEncoding(request.getCharacterEncoding());
|
||||||
|
response.setContentType("application/octet-stream");
|
||||||
|
FileInputStream fis = null;
|
||||||
|
try {
|
||||||
|
fis = new FileInputStream(file);
|
||||||
|
response.setHeader("Content-Disposition", "attachment; filename=" + file.getName());
|
||||||
|
IOUtils.copy(fis, response.getOutputStream());
|
||||||
|
response.flushBuffer();
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
} finally {
|
||||||
|
if (fis != null) {
|
||||||
|
try {
|
||||||
|
fis.close();
|
||||||
|
if (deleteOnExit) {
|
||||||
|
file.deleteOnExit();
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 验证并过滤非法的文件名
|
||||||
|
* @param fileName 文件名
|
||||||
|
* @return 文件名
|
||||||
|
*/
|
||||||
|
public static String verifyFilename(String fileName) {
|
||||||
|
// 过滤掉特殊字符
|
||||||
|
fileName = fileName.replaceAll("[\\\\/:*?\"<>|~\\s]", "");
|
||||||
|
|
||||||
|
// 去掉文件名开头和结尾的空格和点
|
||||||
|
fileName = fileName.trim().replaceAll("^[. ]+|[. ]+$", "");
|
||||||
|
|
||||||
|
// 不允许文件名超过255(在Mac和Linux中)或260(在Windows中)个字符
|
||||||
|
int maxFileNameLength = 255;
|
||||||
|
if (System.getProperty("os.name").startsWith("Windows")) {
|
||||||
|
maxFileNameLength = 260;
|
||||||
|
}
|
||||||
|
if (fileName.length() > maxFileNameLength) {
|
||||||
|
fileName = fileName.substring(0, maxFileNameLength);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 过滤掉控制字符
|
||||||
|
fileName = fileName.replaceAll("[\\p{Cntrl}]", "");
|
||||||
|
|
||||||
|
// 过滤掉 ".." 路径
|
||||||
|
fileName = fileName.replaceAll("\\.{2,}", "");
|
||||||
|
|
||||||
|
// 去掉文件名开头的 ".."
|
||||||
|
fileName = fileName.replaceAll("^\\.+/", "");
|
||||||
|
|
||||||
|
// 保留文件名中最后一个 "." 字符,过滤掉其他 "."
|
||||||
|
fileName = fileName.replaceAll("^(.*)(\\.[^.]*)$", "$1").replaceAll("\\.", "") +
|
||||||
|
fileName.replaceAll("^(.*)(\\.[^.]*)$", "$2");
|
||||||
|
|
||||||
|
return fileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static String getMd5(File file) {
|
||||||
|
return getMd5(getByte(file));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,67 @@
|
||||||
|
package com.gfwl.api.utils;
|
||||||
|
|
||||||
|
import cn.hutool.http.useragent.Browser;
|
||||||
|
import cn.hutool.http.useragent.UserAgent;
|
||||||
|
import cn.hutool.http.useragent.UserAgentUtil;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.net.InetAddress;
|
||||||
|
import java.net.UnknownHostException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @className: IpUtil
|
||||||
|
*
|
||||||
|
* Created by 小明
|
||||||
|
* @create: 2023-06-02 15:24
|
||||||
|
*/
|
||||||
|
public class IpUtil {
|
||||||
|
|
||||||
|
|
||||||
|
private IpUtil(){}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取请求地址IP
|
||||||
|
* @return IP
|
||||||
|
*/
|
||||||
|
public static String getIpAddr(HttpServletRequest request) {
|
||||||
|
String ipAddress = null;
|
||||||
|
try {
|
||||||
|
ipAddress = request.getHeader("x-forwarded-for");
|
||||||
|
if (ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) {
|
||||||
|
ipAddress = request.getHeader("Proxy-Client-IP");
|
||||||
|
}
|
||||||
|
if (ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) {
|
||||||
|
ipAddress = request.getHeader("WL-Proxy-Client-IP");
|
||||||
|
}
|
||||||
|
if (ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) {
|
||||||
|
ipAddress = request.getRemoteAddr();
|
||||||
|
if (ipAddress.equals("127.0.0.1")) {
|
||||||
|
// 根据网卡取本机配置的IP
|
||||||
|
InetAddress inet = null;
|
||||||
|
try {
|
||||||
|
inet = InetAddress.getLocalHost();
|
||||||
|
} catch (UnknownHostException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
ipAddress = inet.getHostAddress();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 对于通过多个代理的情况,第一个IP为客户端真实IP,多个IP按照','分割
|
||||||
|
if (ipAddress != null && ipAddress.length() > 15) { // "***.***.***.***".length()
|
||||||
|
// = 15
|
||||||
|
if (ipAddress.indexOf(",") > 0) {
|
||||||
|
ipAddress = ipAddress.substring(0, ipAddress.indexOf(","));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
ipAddress="";
|
||||||
|
}
|
||||||
|
return ipAddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Browser getBrowser(HttpServletRequest request){
|
||||||
|
String ua = request.getHeader("User-Agent");
|
||||||
|
UserAgent userAgent = UserAgentUtil.parse(ua);
|
||||||
|
return userAgent.getBrowser();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,44 @@
|
||||||
|
package com.gfwl.api.vo.order;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @className: OrderAppointDTO
|
||||||
|
*
|
||||||
|
* Created by 小明
|
||||||
|
* @create: 2023-05-30 22:47
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@ApiModel("预约订单")
|
||||||
|
public class OrderAppointDTO {
|
||||||
|
|
||||||
|
@ApiModelProperty("就餐人数")
|
||||||
|
private Integer peopleNumber;
|
||||||
|
|
||||||
|
@ApiModelProperty("就餐日期")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
|
||||||
|
private String mealDate;
|
||||||
|
|
||||||
|
@ApiModelProperty("就餐时间ID")
|
||||||
|
private String mealId;
|
||||||
|
|
||||||
|
@ApiModelProperty("楼层")
|
||||||
|
private String floor;
|
||||||
|
|
||||||
|
@ApiModelProperty("桌子")
|
||||||
|
private String table;
|
||||||
|
|
||||||
|
@ApiModelProperty("就餐人")
|
||||||
|
private String names;
|
||||||
|
|
||||||
|
@ApiModelProperty("联系电话")
|
||||||
|
private String phones;
|
||||||
|
|
||||||
|
@ApiModelProperty("订单详情")
|
||||||
|
private List<OrderDetailDTO> dtoList;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
package com.gfwl.api.vo.order;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @className: OrderDetailDTO
|
||||||
|
*
|
||||||
|
* Created by 小明
|
||||||
|
* @create: 2023-05-30 22:49
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@ApiModel("订单商品详情")
|
||||||
|
public class OrderDetailDTO {
|
||||||
|
|
||||||
|
@ApiModelProperty("商品ID")
|
||||||
|
private String foodId;
|
||||||
|
|
||||||
|
@ApiModelProperty("数量")
|
||||||
|
private Integer number;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,33 @@
|
||||||
|
package com.gfwl.api.vo.order;
|
||||||
|
|
||||||
|
import com.gfwl.common.entity.BusOrder;
|
||||||
|
import com.gfwl.common.entity.BusOrderAddress;
|
||||||
|
import com.gfwl.common.entity.BusOrderDetail;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @className: OrderEditDto
|
||||||
|
*
|
||||||
|
* Created by 小明
|
||||||
|
* @create: 2023-07-05 21:07
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@ApiModel("订单修改")
|
||||||
|
public class OrderEditDto {
|
||||||
|
|
||||||
|
@ApiModelProperty("修改的原订单")
|
||||||
|
private String orderId;
|
||||||
|
|
||||||
|
@ApiModelProperty("订单详情")
|
||||||
|
private BusOrder busOrder;
|
||||||
|
|
||||||
|
@ApiModelProperty("订单菜单")
|
||||||
|
private List<BusOrderDetail> orderDetailList;
|
||||||
|
|
||||||
|
@ApiModelProperty("订单地址")
|
||||||
|
private BusOrderAddress address;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
package com.gfwl.api.vo.order;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @className: OrderEvaluationDTO
|
||||||
|
*
|
||||||
|
* Created by 小明
|
||||||
|
* @create: 2023-05-31 01:26
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@ApiModel("订单评价")
|
||||||
|
public class OrderEvaluationDTO {
|
||||||
|
|
||||||
|
@ApiModelProperty("订单ID")
|
||||||
|
private String orderId;
|
||||||
|
|
||||||
|
@ApiModelProperty("评价星星")
|
||||||
|
private Integer evaluationNumber;
|
||||||
|
|
||||||
|
@ApiModelProperty("评价内容")
|
||||||
|
private String evaluationContent;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,30 @@
|
||||||
|
package com.gfwl.api.vo.order;
|
||||||
|
|
||||||
|
import com.gfwl.common.entity.BusOrder;
|
||||||
|
import com.gfwl.common.entity.BusOrderAddress;
|
||||||
|
import com.gfwl.common.entity.BusOrderDetail;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @className: OrderResrtDTO
|
||||||
|
*
|
||||||
|
* Created by 小明
|
||||||
|
* @create: 2023-06-05 19:32
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@ApiModel("订单列表")
|
||||||
|
public class OrderResertDTO {
|
||||||
|
|
||||||
|
@ApiModelProperty("订单信息")
|
||||||
|
private BusOrder orderInfo;
|
||||||
|
|
||||||
|
@ApiModelProperty("订单地址")
|
||||||
|
private BusOrderAddress orderAddress;
|
||||||
|
|
||||||
|
@ApiModelProperty("商品列表")
|
||||||
|
private List<BusOrderDetail> orderDetailList;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,25 @@
|
||||||
|
package com.gfwl.api.vo.order;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @className: OrderTableDTO
|
||||||
|
*
|
||||||
|
* Created by 小明
|
||||||
|
* @create: 2023-05-31 01:35
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@ApiModel("每日已购买过的位置")
|
||||||
|
public class OrderTableDTO {
|
||||||
|
|
||||||
|
@ApiModelProperty("就餐时间ID")
|
||||||
|
private String mealId;
|
||||||
|
|
||||||
|
@ApiModelProperty("楼层")
|
||||||
|
private String floor;
|
||||||
|
|
||||||
|
@ApiModelProperty("桌子")
|
||||||
|
private String table;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,25 @@
|
||||||
|
package com.gfwl.api.vo.order;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @className: OrderTableNoOrderDTO
|
||||||
|
*
|
||||||
|
* Created by 小明
|
||||||
|
* @create: 2023-05-31 23:32
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@ApiModel("查询桌子订购过的桌子")
|
||||||
|
public class OrderTableNoOrderParm {
|
||||||
|
|
||||||
|
@ApiModelProperty("日期:yyyy-MM-dd")
|
||||||
|
private String mealDate;
|
||||||
|
|
||||||
|
@ApiModelProperty("时间")
|
||||||
|
private String mealId;
|
||||||
|
|
||||||
|
@ApiModelProperty("楼层")
|
||||||
|
private String floor;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,51 @@
|
||||||
|
package com.gfwl.api.vo.order;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @className: OrderTakeOutDTO
|
||||||
|
*
|
||||||
|
* Created by 小明
|
||||||
|
* @create: 2023-05-31 00:18
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@ApiModel("创建外卖订单")
|
||||||
|
public class OrderTakeOutDTO {
|
||||||
|
|
||||||
|
@ApiModelProperty("类型:1 自提2 配送")
|
||||||
|
private Integer type;
|
||||||
|
|
||||||
|
@ApiModelProperty("自提时间:yyyy-MM-dd HH:mm:ss")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
private Date selfDate;
|
||||||
|
|
||||||
|
@ApiModelProperty("省")
|
||||||
|
private String province;
|
||||||
|
|
||||||
|
@ApiModelProperty("市")
|
||||||
|
private String city;
|
||||||
|
|
||||||
|
@ApiModelProperty("地址")
|
||||||
|
private String address;
|
||||||
|
|
||||||
|
@ApiModelProperty("就餐人")
|
||||||
|
private String names;
|
||||||
|
|
||||||
|
@ApiModelProperty("联系电话")
|
||||||
|
private String phones;
|
||||||
|
|
||||||
|
@ApiModelProperty("省ID")
|
||||||
|
private String provinceId;
|
||||||
|
|
||||||
|
@ApiModelProperty("市ID")
|
||||||
|
private String cityId;
|
||||||
|
|
||||||
|
@ApiModelProperty("订单详情")
|
||||||
|
private List<OrderDetailDTO> dtoList;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,30 @@
|
||||||
|
package com.gfwl.api.vo.pay;
|
||||||
|
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @className: PayInfo
|
||||||
|
*
|
||||||
|
* Created by 小明
|
||||||
|
* @create: 2023-04-18 14:52
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
public class PayInfo {
|
||||||
|
|
||||||
|
private String tradeId;
|
||||||
|
|
||||||
|
private String timeStamp;
|
||||||
|
|
||||||
|
private String signType;
|
||||||
|
|
||||||
|
private String packages;
|
||||||
|
|
||||||
|
private String paySign;
|
||||||
|
|
||||||
|
private String nonceStr;
|
||||||
|
|
||||||
|
private String appId;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
package com.gfwl.api.vo.user;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @className: UserBindPhoneDto
|
||||||
|
*
|
||||||
|
* Created by 小明
|
||||||
|
* @create: 2023-06-14 22:45
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class UserBindPhoneDto {
|
||||||
|
|
||||||
|
@ApiModelProperty("id")
|
||||||
|
private String uid;
|
||||||
|
|
||||||
|
@ApiModelProperty("完整用户信息的加密数据")
|
||||||
|
private String encryptedData;
|
||||||
|
|
||||||
|
@ApiModelProperty("加密算法的初始向量")
|
||||||
|
private String iv;
|
||||||
|
|
||||||
|
@ApiModelProperty("sessionKey 登陆时候返回")
|
||||||
|
private String sessionKey;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
package com.gfwl.api.vo.user;
|
||||||
|
|
||||||
|
import com.gfwl.api.ApiConst;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @className: UserLogin
|
||||||
|
*
|
||||||
|
* Created by 小明
|
||||||
|
* @create: 2023-05-30 23:56
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class UserLogin {
|
||||||
|
|
||||||
|
@ApiModelProperty("登录类型:微信(" + ApiConst.LOGIN_TYPE.WX + ")")
|
||||||
|
private String type;
|
||||||
|
|
||||||
|
@ApiModelProperty("code:微信登录code")
|
||||||
|
private String code;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,23 @@
|
||||||
|
package com.gfwl.api.vo.user;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @className: UserUdpVo
|
||||||
|
*
|
||||||
|
* Created by 小明
|
||||||
|
* @create: 2023-05-30 11:31
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class UserUdpVo {
|
||||||
|
|
||||||
|
@ApiModelProperty("昵称")
|
||||||
|
private String userName;
|
||||||
|
|
||||||
|
@ApiModelProperty("头像")
|
||||||
|
private String head;
|
||||||
|
|
||||||
|
@ApiModelProperty("用户性别1 男 2 女 3 保密")
|
||||||
|
private Integer age;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,111 @@
|
||||||
|
package com.gfwl.app.controller;
|
||||||
|
|
||||||
|
|
||||||
|
import com.gfwl.admin.base.*;
|
||||||
|
import com.gfwl.common.entity.BusBasicsCity;
|
||||||
|
import com.gfwl.common.service.BusBasicsCityService;
|
||||||
|
import com.gfwl.config.annotation.OperLog;
|
||||||
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.ui.Model;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 城市数据管理
|
||||||
|
* Created by 小明 on 2023-05-29 01:46:37
|
||||||
|
*/
|
||||||
|
@Controller
|
||||||
|
@RequestMapping("/app/busBasicsCity")
|
||||||
|
public class BusBasicsCityController extends BaseController {
|
||||||
|
@Autowired
|
||||||
|
private BusBasicsCityService busBasicsCityService;
|
||||||
|
|
||||||
|
@RequiresPermissions("common:busBasicsCity:view")
|
||||||
|
@RequestMapping()
|
||||||
|
public String view() {
|
||||||
|
return "app/busBasicsCity.html";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@RequiresPermissions("common:busBasicsCity:view")
|
||||||
|
@RequestMapping("view2")
|
||||||
|
public String view2(@RequestParam("parentId") String parentId, Model model) {
|
||||||
|
model.addAttribute("parentId", parentId);
|
||||||
|
return "app/busBasicsCity2.html";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询城市数据
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("common:busBasicsCity:list")
|
||||||
|
@OperLog(value = "城市数据管理", desc = "分页查询")
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/page")
|
||||||
|
public PageResult<BusBasicsCity> page(HttpServletRequest request) {
|
||||||
|
PageParam<BusBasicsCity> pageParam = new PageParam<>(request);
|
||||||
|
return new PageResult<>(busBasicsCityService.page(pageParam, pageParam.getWrapper()).getRecords(), pageParam.getTotal());
|
||||||
|
//return busBasicsCityService.listPage(pageParam); // 使用关联查询
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询全部城市数据
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("common:busBasicsCity:list")
|
||||||
|
@OperLog(value = "城市数据管理", desc = "查询全部")
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/list")
|
||||||
|
public JsonResult list(HttpServletRequest request) {
|
||||||
|
PageParam<BusBasicsCity> pageParam = new PageParam<>(request);
|
||||||
|
return JsonResult.ok().setData(busBasicsCityService.list(pageParam.getOrderWrapper()));
|
||||||
|
//List<BusBasicsCity> records = busBasicsCityService.listAll(pageParam.getNoPageParam()); // 使用关联查询
|
||||||
|
//return JsonResult.ok().setData(pageParam.sortRecords(records));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加城市数据
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("common:busBasicsCity:save")
|
||||||
|
@OperLog(value = "城市数据管理", desc = "添加", param = false, result = true)
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/save")
|
||||||
|
public JsonResult save(BusBasicsCity busBasicsCity) {
|
||||||
|
if (busBasicsCityService.save(busBasicsCity)) {
|
||||||
|
return JsonResult.ok("添加成功");
|
||||||
|
}
|
||||||
|
return JsonResult.error("添加失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改城市数据
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("common:busBasicsCity:update")
|
||||||
|
@OperLog(value = "城市数据管理", desc = "修改", param = false, result = true)
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/update")
|
||||||
|
public JsonResult update(BusBasicsCity busBasicsCity) {
|
||||||
|
if (busBasicsCityService.updateById(busBasicsCity)) {
|
||||||
|
return JsonResult.ok("修改成功");
|
||||||
|
}
|
||||||
|
return JsonResult.error("修改失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除城市数据
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("common:busBasicsCity:remove")
|
||||||
|
@OperLog(value = "城市数据管理", desc = "删除", result = true)
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/remove")
|
||||||
|
public JsonResult remove(String id) {
|
||||||
|
if (busBasicsCityService.removeById(id)) {
|
||||||
|
return JsonResult.ok("删除成功");
|
||||||
|
}
|
||||||
|
return JsonResult.error("删除失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,120 @@
|
||||||
|
package com.gfwl.app.controller;
|
||||||
|
|
||||||
|
import com.gfwl.admin.base.BaseController;
|
||||||
|
import com.gfwl.admin.base.JsonResult;
|
||||||
|
import com.gfwl.admin.base.PageParam;
|
||||||
|
import com.gfwl.admin.base.PageResult;
|
||||||
|
import com.gfwl.common.entity.BusFood;
|
||||||
|
import com.gfwl.common.service.BusFoodService;
|
||||||
|
import com.gfwl.config.annotation.OperLog;
|
||||||
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 商品信息管理
|
||||||
|
* Created by 小明 on 2023-05-29 01:46:37
|
||||||
|
*/
|
||||||
|
@Controller
|
||||||
|
@RequestMapping("/common/busFood")
|
||||||
|
public class BusFoodController extends BaseController {
|
||||||
|
@Autowired
|
||||||
|
private BusFoodService busFoodService;
|
||||||
|
|
||||||
|
@RequiresPermissions("common:busFood:view")
|
||||||
|
@RequestMapping()
|
||||||
|
public String view() {
|
||||||
|
return "app/busFood.html";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询商品信息
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("common:busFood:list")
|
||||||
|
@OperLog(value = "商品信息管理", desc = "分页查询")
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/page")
|
||||||
|
public PageResult<BusFood> page(HttpServletRequest request) {
|
||||||
|
PageParam<BusFood> pageParam = new PageParam<>(request);
|
||||||
|
return new PageResult<>(busFoodService.page(pageParam, pageParam.getWrapper()).getRecords(), pageParam.getTotal());
|
||||||
|
//return busFoodService.listPage(pageParam); // 使用关联查询
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询全部商品信息
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("common:busFood:list")
|
||||||
|
@OperLog(value = "商品信息管理", desc = "查询全部")
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/list")
|
||||||
|
public JsonResult list(HttpServletRequest request) {
|
||||||
|
PageParam<BusFood> pageParam = new PageParam<>(request);
|
||||||
|
return JsonResult.ok().setData(busFoodService.list(pageParam.getOrderWrapper()));
|
||||||
|
//List<BusFood> records = busFoodService.listAll(pageParam.getNoPageParam()); // 使用关联查询
|
||||||
|
//return JsonResult.ok().setData(pageParam.sortRecords(records));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据id查询商品信息
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("common:busFood:list")
|
||||||
|
@OperLog(value = "商品信息管理", desc = "根据id查询")
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/get")
|
||||||
|
public JsonResult get(Integer id) {
|
||||||
|
return JsonResult.ok().setData(busFoodService.getById(id));
|
||||||
|
// 使用关联查询
|
||||||
|
//PageParam<BusFood> pageParam = new PageParam<>();
|
||||||
|
//pageParam.put("id", id);
|
||||||
|
//List<BusFood> records = busFoodService.listAll(pageParam.getNoPageParam());
|
||||||
|
//return JsonResult.ok().setData(pageParam.getOne(records));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加商品信息
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("common:busFood:save")
|
||||||
|
@OperLog(value = "商品信息管理", desc = "添加", param = false, result = true)
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/save")
|
||||||
|
public JsonResult save(BusFood busFood) {
|
||||||
|
busFood.setIsZhu(1);
|
||||||
|
if (busFoodService.save(busFood)) {
|
||||||
|
return JsonResult.ok("添加成功");
|
||||||
|
}
|
||||||
|
return JsonResult.error("添加失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改商品信息
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("common:busFood:update")
|
||||||
|
@OperLog(value = "商品信息管理", desc = "修改", param = false, result = true)
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/update")
|
||||||
|
public JsonResult update(BusFood busFood) {
|
||||||
|
busFood.setIsZhu(1);
|
||||||
|
if (busFoodService.updateById(busFood)) {
|
||||||
|
return JsonResult.ok("修改成功");
|
||||||
|
}
|
||||||
|
return JsonResult.error("修改失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除商品信息
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("common:busFood:remove")
|
||||||
|
@OperLog(value = "商品信息管理", desc = "删除", result = true)
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/remove")
|
||||||
|
public JsonResult remove(String id) {
|
||||||
|
if (busFoodService.removeById(id)) {
|
||||||
|
return JsonResult.ok("删除成功");
|
||||||
|
}
|
||||||
|
return JsonResult.error("删除失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,157 @@
|
||||||
|
package com.gfwl.app.controller;
|
||||||
|
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
|
import com.gfwl.admin.base.BaseController;
|
||||||
|
import com.gfwl.admin.base.JsonResult;
|
||||||
|
import com.gfwl.admin.base.PageParam;
|
||||||
|
import com.gfwl.admin.base.PageResult;
|
||||||
|
import com.gfwl.api.base.BaseEntity;
|
||||||
|
import com.gfwl.common.entity.BusFoodInventory;
|
||||||
|
import com.gfwl.common.entity.BusSellTime;
|
||||||
|
import com.gfwl.common.service.BusFoodInventoryService;
|
||||||
|
import com.gfwl.common.service.BusSellTimeService;
|
||||||
|
import com.gfwl.config.annotation.OperLog;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.ui.Model;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 商品库存管理
|
||||||
|
* Created by 小明 on 2023-06-25 18:38:10
|
||||||
|
*/
|
||||||
|
@Controller
|
||||||
|
@RequestMapping("/app/busFoodInventory")
|
||||||
|
public class BusFoodInventoryController extends BaseController {
|
||||||
|
@Resource
|
||||||
|
private BusFoodInventoryService busFoodInventoryService;
|
||||||
|
@Resource
|
||||||
|
private BusSellTimeService sellTimeService;
|
||||||
|
|
||||||
|
// @RequiresPermissions("common:busFoodInventory:view")
|
||||||
|
@RequestMapping("")
|
||||||
|
public String view(Model model, @RequestParam("foodId") String foodId) {
|
||||||
|
model.addAttribute("foodId", foodId);
|
||||||
|
model.addAttribute("entityList", sellTimeService.list(Wrappers.<BusSellTime>lambdaQuery().eq(BusSellTime::getStates, 1)));
|
||||||
|
return "app/busFoodInventory.html";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询商品库存
|
||||||
|
*/
|
||||||
|
// @RequiresPermissions("common:busFoodInventory:list")
|
||||||
|
@OperLog(value = "商品库存管理", desc = "分页查询")
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/page")
|
||||||
|
public PageResult<BusFoodInventory> page(HttpServletRequest request) {
|
||||||
|
PageParam<BusFoodInventory> pageParam = new PageParam<>(request);
|
||||||
|
pageParam.setOrder("sell_date", false);
|
||||||
|
return new PageResult<>(busFoodInventoryService.page(pageParam, pageParam.getWrapper()).getRecords(), pageParam.getTotal());
|
||||||
|
//return busFoodInventoryService.listPage(pageParam); // 使用关联查询
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询全部商品库存
|
||||||
|
*/
|
||||||
|
// @RequiresPermissions("common:busFoodInventory:list")
|
||||||
|
@OperLog(value = "商品库存管理", desc = "查询全部")
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/list")
|
||||||
|
public JsonResult list(HttpServletRequest request) {
|
||||||
|
PageParam<BusFoodInventory> pageParam = new PageParam<>(request);
|
||||||
|
return JsonResult.ok().setData(busFoodInventoryService.list(pageParam.getOrderWrapper()));
|
||||||
|
//List<BusFoodInventory> records = busFoodInventoryService.listAll(pageParam.getNoPageParam()); // 使用关联查询
|
||||||
|
//return JsonResult.ok().setData(pageParam.sortRecords(records));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据id查询商品库存
|
||||||
|
*/
|
||||||
|
// @RequiresPermissions("common:busFoodInventory:list")
|
||||||
|
@OperLog(value = "商品库存管理", desc = "根据id查询")
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/get")
|
||||||
|
public JsonResult get(Integer id) {
|
||||||
|
return JsonResult.ok().setData(busFoodInventoryService.getById(id));
|
||||||
|
// 使用关联查询
|
||||||
|
//PageParam<BusFoodInventory> pageParam = new PageParam<>();
|
||||||
|
//pageParam.put("id", id);
|
||||||
|
//List<BusFoodInventory> records = busFoodInventoryService.listAll(pageParam.getNoPageParam());
|
||||||
|
//return JsonResult.ok().setData(pageParam.getOne(records));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加商品库存
|
||||||
|
*/
|
||||||
|
// @RequiresPermissions("common:busFoodInventory:save")
|
||||||
|
@OperLog(value = "商品库存管理", desc = "添加", param = false, result = true)
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/save")
|
||||||
|
public JsonResult save(BusFoodInventory busFoodInventory) {
|
||||||
|
|
||||||
|
int count = busFoodInventoryService.count(Wrappers.<BusFoodInventory>lambdaQuery().
|
||||||
|
eq(BusFoodInventory::getSellDate, busFoodInventory.getSellDate())
|
||||||
|
.eq(BusFoodInventory::getSellId, busFoodInventory.getSellId())
|
||||||
|
.eq(BusFoodInventory::getFoodId, busFoodInventory.getFoodId())
|
||||||
|
);
|
||||||
|
|
||||||
|
if (count > 0) {
|
||||||
|
return JsonResult.error("时间段已经存在");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BusSellTime byId = sellTimeService.getById(busFoodInventory.getSellId());
|
||||||
|
busFoodInventory.setMealTime(byId.getBeginTime() + "-" + byId.getEndTime());
|
||||||
|
if (busFoodInventoryService.save(busFoodInventory)) {
|
||||||
|
return JsonResult.ok("添加成功");
|
||||||
|
}
|
||||||
|
return JsonResult.error("添加失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改商品库存
|
||||||
|
*/
|
||||||
|
// @RequiresPermissions("common:busFoodInventory:update")
|
||||||
|
@OperLog(value = "商品库存管理", desc = "修改", param = false, result = true)
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/update")
|
||||||
|
public JsonResult update(BusFoodInventory busFoodInventory) {
|
||||||
|
int count = busFoodInventoryService.count(Wrappers.<BusFoodInventory>lambdaQuery().
|
||||||
|
eq(BusFoodInventory::getSellDate, busFoodInventory.getSellDate())
|
||||||
|
.eq(BusFoodInventory::getSellId, busFoodInventory.getSellId())
|
||||||
|
.eq(BusFoodInventory::getFoodId, busFoodInventory.getFoodId())
|
||||||
|
.ne(BaseEntity::getId, busFoodInventory.getId())
|
||||||
|
);
|
||||||
|
|
||||||
|
if (count > 0) {
|
||||||
|
return JsonResult.error("时间端已经存在");
|
||||||
|
}
|
||||||
|
|
||||||
|
BusSellTime byId = sellTimeService.getById(busFoodInventory.getSellId());
|
||||||
|
busFoodInventory.setMealTime(byId.getBeginTime() + "-" + byId.getEndTime());
|
||||||
|
if (busFoodInventoryService.updateById(busFoodInventory)) {
|
||||||
|
return JsonResult.ok("修改成功");
|
||||||
|
}
|
||||||
|
return JsonResult.error("修改失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除商品库存
|
||||||
|
*/
|
||||||
|
// @RequiresPermissions("common:busFoodInventory:remove")
|
||||||
|
@OperLog(value = "商品库存管理", desc = "删除", result = true)
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/remove")
|
||||||
|
public JsonResult remove(String id) {
|
||||||
|
if (busFoodInventoryService.removeById(id)) {
|
||||||
|
return JsonResult.ok("删除成功");
|
||||||
|
}
|
||||||
|
return JsonResult.error("删除失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,118 @@
|
||||||
|
package com.gfwl.app.controller;
|
||||||
|
|
||||||
|
|
||||||
|
import com.gfwl.admin.base.*;
|
||||||
|
import com.gfwl.common.entity.BusNotice;
|
||||||
|
import com.gfwl.common.service.BusNoticeService;
|
||||||
|
import com.gfwl.config.annotation.OperLog;
|
||||||
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 消息通知管理
|
||||||
|
* Created by 小明 on 2023-05-29 01:46:37
|
||||||
|
*/
|
||||||
|
@Controller
|
||||||
|
@RequestMapping("/app/busNotice")
|
||||||
|
public class BusNoticeController extends BaseController {
|
||||||
|
@Autowired
|
||||||
|
private BusNoticeService busNoticeService;
|
||||||
|
|
||||||
|
@RequiresPermissions("common:busNotice:view")
|
||||||
|
@RequestMapping()
|
||||||
|
public String view() {
|
||||||
|
return "app/busNotice.html";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询消息通知
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("common:busNotice:list")
|
||||||
|
@OperLog(value = "消息通知管理", desc = "分页查询")
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/page")
|
||||||
|
public PageResult<BusNotice> page(HttpServletRequest request) {
|
||||||
|
PageParam<BusNotice> pageParam = new PageParam<>(request);
|
||||||
|
return new PageResult<>(busNoticeService.page(pageParam, pageParam.getWrapper()).getRecords(), pageParam.getTotal());
|
||||||
|
//return busNoticeService.listPage(pageParam); // 使用关联查询
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询全部消息通知
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("common:busNotice:list")
|
||||||
|
@OperLog(value = "消息通知管理", desc = "查询全部")
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/list")
|
||||||
|
public JsonResult list(HttpServletRequest request) {
|
||||||
|
PageParam<BusNotice> pageParam = new PageParam<>(request);
|
||||||
|
return JsonResult.ok().setData(busNoticeService.list(pageParam.getOrderWrapper()));
|
||||||
|
//List<BusNotice> records = busNoticeService.listAll(pageParam.getNoPageParam()); // 使用关联查询
|
||||||
|
//return JsonResult.ok().setData(pageParam.sortRecords(records));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据id查询消息通知
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("common:busNotice:list")
|
||||||
|
@OperLog(value = "消息通知管理", desc = "根据id查询")
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/get")
|
||||||
|
public JsonResult get(Integer id) {
|
||||||
|
return JsonResult.ok().setData(busNoticeService.getById(id));
|
||||||
|
// 使用关联查询
|
||||||
|
//PageParam<BusNotice> pageParam = new PageParam<>();
|
||||||
|
//pageParam.put("id", id);
|
||||||
|
//List<BusNotice> records = busNoticeService.listAll(pageParam.getNoPageParam());
|
||||||
|
//return JsonResult.ok().setData(pageParam.getOne(records));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加消息通知
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("common:busNotice:save")
|
||||||
|
@OperLog(value = "消息通知管理", desc = "添加", param = false, result = true)
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/save")
|
||||||
|
public JsonResult save(BusNotice busNotice) {
|
||||||
|
if (busNoticeService.save(busNotice)) {
|
||||||
|
return JsonResult.ok("添加成功");
|
||||||
|
}
|
||||||
|
return JsonResult.error("添加失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改消息通知
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("common:busNotice:update")
|
||||||
|
@OperLog(value = "消息通知管理", desc = "修改", param = false, result = true)
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/update")
|
||||||
|
public JsonResult update(BusNotice busNotice) {
|
||||||
|
if (busNoticeService.updateById(busNotice)) {
|
||||||
|
return JsonResult.ok("修改成功");
|
||||||
|
}
|
||||||
|
return JsonResult.error("修改失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除消息通知
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("common:busNotice:remove")
|
||||||
|
@OperLog(value = "消息通知管理", desc = "删除", result = true)
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/remove")
|
||||||
|
public JsonResult remove(String id) {
|
||||||
|
if (busNoticeService.removeById(id)) {
|
||||||
|
return JsonResult.ok("删除成功");
|
||||||
|
}
|
||||||
|
return JsonResult.error("删除失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,123 @@
|
||||||
|
package com.gfwl.app.controller;
|
||||||
|
|
||||||
|
import com.gfwl.admin.base.BaseController;
|
||||||
|
import com.gfwl.admin.base.JsonResult;
|
||||||
|
import com.gfwl.admin.base.PageParam;
|
||||||
|
import com.gfwl.admin.base.PageResult;
|
||||||
|
import com.gfwl.common.entity.BusOrderAddress;
|
||||||
|
import com.gfwl.common.service.BusOrderAddressService;
|
||||||
|
import com.gfwl.config.annotation.OperLog;
|
||||||
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.ui.Model;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单配送地址管理
|
||||||
|
* Created by 小明 on 2023-05-29 01:46:37
|
||||||
|
*/
|
||||||
|
@Controller
|
||||||
|
@RequestMapping("/app/busOrderAddress")
|
||||||
|
public class BusOrderAddressController extends BaseController {
|
||||||
|
@Autowired
|
||||||
|
private BusOrderAddressService busOrderAddressService;
|
||||||
|
|
||||||
|
@RequiresPermissions("common:busOrderAddress:view")
|
||||||
|
@RequestMapping()
|
||||||
|
public String view(Model model, @RequestParam("orderId") String orderId) {
|
||||||
|
model.addAttribute("orderId", orderId);
|
||||||
|
return "app/busOrderAddress.html";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询订单配送地址
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("common:busOrderAddress:list")
|
||||||
|
@OperLog(value = "订单配送地址管理", desc = "分页查询")
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/page")
|
||||||
|
public PageResult<BusOrderAddress> page(HttpServletRequest request) {
|
||||||
|
PageParam<BusOrderAddress> pageParam = new PageParam<>(request);
|
||||||
|
return new PageResult<>(busOrderAddressService.page(pageParam, pageParam.getWrapper()).getRecords(), pageParam.getTotal());
|
||||||
|
//return busOrderAddressService.listPage(pageParam); // 使用关联查询
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询全部订单配送地址
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("common:busOrderAddress:list")
|
||||||
|
@OperLog(value = "订单配送地址管理", desc = "查询全部")
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/list")
|
||||||
|
public JsonResult list(HttpServletRequest request) {
|
||||||
|
PageParam<BusOrderAddress> pageParam = new PageParam<>(request);
|
||||||
|
return JsonResult.ok().setData(busOrderAddressService.list(pageParam.getOrderWrapper()));
|
||||||
|
//List<BusOrderAddress> records = busOrderAddressService.listAll(pageParam.getNoPageParam()); // 使用关联查询
|
||||||
|
//return JsonResult.ok().setData(pageParam.sortRecords(records));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据id查询订单配送地址
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("common:busOrderAddress:list")
|
||||||
|
@OperLog(value = "订单配送地址管理", desc = "根据id查询")
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/get")
|
||||||
|
public JsonResult get(Integer id) {
|
||||||
|
return JsonResult.ok().setData(busOrderAddressService.getById(id));
|
||||||
|
// 使用关联查询
|
||||||
|
//PageParam<BusOrderAddress> pageParam = new PageParam<>();
|
||||||
|
//pageParam.put("id", id);
|
||||||
|
//List<BusOrderAddress> records = busOrderAddressService.listAll(pageParam.getNoPageParam());
|
||||||
|
//return JsonResult.ok().setData(pageParam.getOne(records));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加订单配送地址
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("common:busOrderAddress:save")
|
||||||
|
@OperLog(value = "订单配送地址管理", desc = "添加", param = false, result = true)
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/save")
|
||||||
|
public JsonResult save(BusOrderAddress busOrderAddress) {
|
||||||
|
if (busOrderAddressService.save(busOrderAddress)) {
|
||||||
|
return JsonResult.ok("添加成功");
|
||||||
|
}
|
||||||
|
return JsonResult.error("添加失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改订单配送地址
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("common:busOrderAddress:update")
|
||||||
|
@OperLog(value = "订单配送地址管理", desc = "修改", param = false, result = true)
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/update")
|
||||||
|
public JsonResult update(BusOrderAddress busOrderAddress) {
|
||||||
|
if (busOrderAddressService.updateById(busOrderAddress)) {
|
||||||
|
return JsonResult.ok("修改成功");
|
||||||
|
}
|
||||||
|
return JsonResult.error("修改失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除订单配送地址
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("common:busOrderAddress:remove")
|
||||||
|
@OperLog(value = "订单配送地址管理", desc = "删除", result = true)
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/remove")
|
||||||
|
public JsonResult remove(String id) {
|
||||||
|
if (busOrderAddressService.removeById(id)) {
|
||||||
|
return JsonResult.ok("删除成功");
|
||||||
|
}
|
||||||
|
return JsonResult.error("删除失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,235 @@
|
||||||
|
package com.gfwl.app.controller;
|
||||||
|
|
||||||
|
|
||||||
|
import cn.afterturn.easypoi.excel.ExcelExportUtil;
|
||||||
|
import cn.afterturn.easypoi.excel.entity.ExportParams;
|
||||||
|
import cn.hutool.poi.excel.ExcelUtil;
|
||||||
|
import com.gfwl.admin.base.BaseController;
|
||||||
|
import com.gfwl.admin.base.JsonResult;
|
||||||
|
import com.gfwl.admin.base.PageParam;
|
||||||
|
import com.gfwl.admin.base.PageResult;
|
||||||
|
import com.gfwl.app.vo.BusOrderExcelVO;
|
||||||
|
import com.gfwl.app.vo.BusOrderVO;
|
||||||
|
import com.gfwl.common.entity.BusOrder;
|
||||||
|
import com.gfwl.common.service.BusOrderService;
|
||||||
|
import com.gfwl.config.annotation.OperLog;
|
||||||
|
import com.gfwl.config.consts.Global;
|
||||||
|
import com.gfwl.config.pay.WxPayBean;
|
||||||
|
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
|
||||||
|
import com.ijpay.core.enums.SignType;
|
||||||
|
import com.ijpay.core.kit.WxPayKit;
|
||||||
|
import com.ijpay.wxpay.WxPayApi;
|
||||||
|
import com.ijpay.wxpay.model.RefundModel;
|
||||||
|
import com.peak.core.domain.response.R;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.apache.poi.ss.usermodel.Workbook;
|
||||||
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单表管理
|
||||||
|
* Created by 小明 on 2023-05-29 01:46:37
|
||||||
|
*/
|
||||||
|
@Controller
|
||||||
|
@Api(
|
||||||
|
value = "订单管理列表",
|
||||||
|
tags = {"订单管理列表"},
|
||||||
|
produces = "application/json"
|
||||||
|
)
|
||||||
|
@ApiSupport(author = Global.interface_author)
|
||||||
|
@RequestMapping("/app/busOrder")
|
||||||
|
public class BusOrderController extends BaseController {
|
||||||
|
@Autowired
|
||||||
|
private BusOrderService busOrderService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private WxPayBean wxPayBean;
|
||||||
|
|
||||||
|
@RequiresPermissions("common:busOrder:view")
|
||||||
|
@RequestMapping()
|
||||||
|
public String view() {
|
||||||
|
return "app/busOrder.html";
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequiresPermissions("common:busOrder:view")
|
||||||
|
@RequestMapping("takeout")
|
||||||
|
public String takeoutView() {
|
||||||
|
return "app/busOrder-takeout.html";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询订单表
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("common:busOrder:list")
|
||||||
|
@OperLog(value = "订单表管理", desc = "分页查询")
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/page")
|
||||||
|
public PageResult<BusOrder> page(HttpServletRequest request) {
|
||||||
|
PageParam<BusOrder> pageParam = new PageParam<>(request);
|
||||||
|
// return new PageResult<>(busOrderService.page(pageParam, pageParam.getWrapper()).getRecords(), pageParam.getTotal());
|
||||||
|
return busOrderService.listPage(pageParam);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询全部订单表
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("common:busOrder:list")
|
||||||
|
@OperLog(value = "订单表管理", desc = "查询全部")
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/list")
|
||||||
|
public JsonResult list(HttpServletRequest request) {
|
||||||
|
PageParam<BusOrder> pageParam = new PageParam<>(request);
|
||||||
|
return JsonResult.ok().setData(busOrderService.list(pageParam.getOrderWrapper()));
|
||||||
|
//List<BusOrder> records = busOrderService.listAll(pageParam.getNoPageParam()); // 使用关联查询
|
||||||
|
//return JsonResult.ok().setData(pageParam.sortRecords(records));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据id查询订单表
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("common:busOrder:list")
|
||||||
|
@OperLog(value = "订单表管理", desc = "根据id查询")
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/get")
|
||||||
|
public JsonResult get(Integer id) {
|
||||||
|
return JsonResult.ok().setData(busOrderService.getById(id));
|
||||||
|
// 使用关联查询
|
||||||
|
//PageParam<BusOrder> pageParam = new PageParam<>();
|
||||||
|
//pageParam.put("id", id);
|
||||||
|
//List<BusOrder> records = busOrderService.listAll(pageParam.getNoPageParam());
|
||||||
|
//return JsonResult.ok().setData(pageParam.getOne(records));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加订单表
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("common:busOrder:save")
|
||||||
|
@OperLog(value = "订单表管理", desc = "添加", param = false, result = true)
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/save")
|
||||||
|
public JsonResult save(BusOrder busOrder) {
|
||||||
|
if (busOrderService.save(busOrder)) {
|
||||||
|
return JsonResult.ok("添加成功");
|
||||||
|
}
|
||||||
|
return JsonResult.error("添加失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改订单表
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("common:busOrder:update")
|
||||||
|
@OperLog(value = "订单表管理", desc = "修改", param = false, result = true)
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/update")
|
||||||
|
public JsonResult update(BusOrder busOrder) {
|
||||||
|
if (busOrderService.updateById(busOrder)) {
|
||||||
|
return JsonResult.ok("修改成功");
|
||||||
|
}
|
||||||
|
return JsonResult.error("修改失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除订单表
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("common:busOrder:remove")
|
||||||
|
@OperLog(value = "订单表管理", desc = "删除", result = true)
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/remove")
|
||||||
|
public JsonResult remove(String id) {
|
||||||
|
if (busOrderService.removeById(id)) {
|
||||||
|
return JsonResult.ok("删除成功");
|
||||||
|
}
|
||||||
|
return JsonResult.error("删除失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@RequiresPermissions("common:busOrder:remove")
|
||||||
|
@OperLog(value = "使用订单", desc = "使用", result = true)
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/employ")
|
||||||
|
public JsonResult employ(String id) {
|
||||||
|
BusOrder byId = busOrderService.getById(id);
|
||||||
|
if (byId == null) {
|
||||||
|
return JsonResult.error("使用失败");
|
||||||
|
}
|
||||||
|
if (2 != byId.getStates()) {
|
||||||
|
return JsonResult.error("订单未支付或退款、使用,无法使用");
|
||||||
|
}
|
||||||
|
byId.setStates(7);
|
||||||
|
|
||||||
|
if (byId.updateById()) {
|
||||||
|
return JsonResult.ok("使用成功");
|
||||||
|
}
|
||||||
|
return JsonResult.error("使用失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
@ResponseBody
|
||||||
|
@ApiOperation(httpMethod = "GET", value = "取消订单", protocols = "http")
|
||||||
|
@GetMapping("/clearOrder")
|
||||||
|
public JsonResult clearOrder(String orderId) {
|
||||||
|
BusOrder byId = busOrderService.getById(orderId);
|
||||||
|
if (byId.getIsEvaluation() != 1) {
|
||||||
|
return JsonResult.error("退款失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, String> params = RefundModel.builder()
|
||||||
|
.appid(wxPayBean.getAppId())
|
||||||
|
.mch_id(wxPayBean.getMchId())
|
||||||
|
.nonce_str(WxPayKit.generateStr())
|
||||||
|
.out_trade_no(byId.getOutTradeId())
|
||||||
|
.out_refund_no(byId.getOutTradeId())
|
||||||
|
.total_fee(String.valueOf(byId.getPrices().multiply(BigDecimal.valueOf(100)).intValue()))
|
||||||
|
.refund_fee(String.valueOf(byId.getPrices().multiply(BigDecimal.valueOf(100)).intValue()))
|
||||||
|
.notify_url(wxPayBean.getDomain().concat("api/v1/pay/refundNotify"))
|
||||||
|
.build()
|
||||||
|
.createSign(wxPayBean.getPartnerKey(), SignType.MD5);
|
||||||
|
String refundStr = WxPayApi.orderRefund(false, params, wxPayBean.getCertPath(), wxPayBean.getMchId());
|
||||||
|
|
||||||
|
Map<String, String> refundParam = WxPayKit.xmlToMap(refundStr);
|
||||||
|
System.out.println(refundStr);
|
||||||
|
if (refundParam.get("result_code").equals("SUCCESS")) {
|
||||||
|
byId.setStates(4);
|
||||||
|
byId.updateById();
|
||||||
|
return JsonResult.ok("退款提交成功");
|
||||||
|
} else {
|
||||||
|
return JsonResult.error("退款失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ResponseBody
|
||||||
|
@ApiOperation(httpMethod = "POST", value = "审核", protocols = "http")
|
||||||
|
@PostMapping("/audit")
|
||||||
|
public JsonResult audit(BusOrder busOrder) {
|
||||||
|
BusOrder byId = busOrderService.getById(busOrder.getId());
|
||||||
|
if (byId.getOrderType() != 2 || byId.getIsAudit() != 1) {
|
||||||
|
return JsonResult.error("无法进行审核");
|
||||||
|
}
|
||||||
|
byId.setIsAudit(busOrder.getIsAudit());
|
||||||
|
byId.setReason(busOrder.getReason());
|
||||||
|
if (byId.updateById()) {
|
||||||
|
return JsonResult.ok("审核成功");
|
||||||
|
} else {
|
||||||
|
return JsonResult.error("审核失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(httpMethod = "POST", value = "导出")
|
||||||
|
@PostMapping(value = "/export")
|
||||||
|
public void export(@RequestBody BusOrderVO data, HttpServletResponse response) throws IOException {
|
||||||
|
busOrderService.export(data,response);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,108 @@
|
||||||
|
package com.gfwl.app.controller;
|
||||||
|
|
||||||
|
import com.gfwl.admin.base.*;
|
||||||
|
import com.gfwl.common.entity.BusOrderDetail;
|
||||||
|
import com.gfwl.common.service.BusOrderDetailService;
|
||||||
|
import com.gfwl.config.annotation.OperLog;
|
||||||
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.ui.Model;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单详情表管理
|
||||||
|
* Created by 小明 on 2023-05-29 01:46:37
|
||||||
|
*/
|
||||||
|
@Controller
|
||||||
|
@RequestMapping("/app/busOrderDetail")
|
||||||
|
public class BusOrderDetailController extends BaseController {
|
||||||
|
@Autowired
|
||||||
|
private BusOrderDetailService busOrderDetailService;
|
||||||
|
|
||||||
|
@RequiresPermissions("app:busOrderDetail:view")
|
||||||
|
@RequestMapping()
|
||||||
|
public String view(Model model,@RequestParam("orderId") String orderId) {
|
||||||
|
model.addAttribute("orderId",orderId);
|
||||||
|
return "app/busOrderDetail.html";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询订单详情表
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("common:busOrderDetail:list")
|
||||||
|
@OperLog(value = "订单详情表管理", desc = "分页查询")
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/page")
|
||||||
|
public PageResult<BusOrderDetail> page(HttpServletRequest request) {
|
||||||
|
PageParam<BusOrderDetail> pageParam = new PageParam<>(request);
|
||||||
|
return new PageResult<>(busOrderDetailService.page(pageParam, pageParam.getWrapper()).getRecords(), pageParam.getTotal());
|
||||||
|
//return busOrderDetailService.listPage(pageParam); // 使用关联查询
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询全部订单详情表
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("common:busOrderDetail:list")
|
||||||
|
@OperLog(value = "订单详情表管理", desc = "查询全部")
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/list")
|
||||||
|
public JsonResult list(HttpServletRequest request) {
|
||||||
|
PageParam<BusOrderDetail> pageParam = new PageParam<>(request);
|
||||||
|
return JsonResult.ok().setData(busOrderDetailService.list(pageParam.getOrderWrapper()));
|
||||||
|
//List<BusOrderDetail> records = busOrderDetailService.listAll(pageParam.getNoPageParam()); // 使用关联查询
|
||||||
|
//return JsonResult.ok().setData(pageParam.sortRecords(records));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据id查询订单详情表
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("common:busOrderDetail:list")
|
||||||
|
@OperLog(value = "订单详情表管理", desc = "根据id查询")
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/get")
|
||||||
|
public JsonResult get(Integer id) {
|
||||||
|
return JsonResult.ok().setData(busOrderDetailService.getById(id));
|
||||||
|
// 使用关联查询
|
||||||
|
//PageParam<BusOrderDetail> pageParam = new PageParam<>();
|
||||||
|
//pageParam.put("id", id);
|
||||||
|
//List<BusOrderDetail> records = busOrderDetailService.listAll(pageParam.getNoPageParam());
|
||||||
|
//return JsonResult.ok().setData(pageParam.getOne(records));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加订单详情表
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("common:busOrderDetail:save")
|
||||||
|
@OperLog(value = "订单详情表管理", desc = "添加", param = false, result = true)
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/save")
|
||||||
|
public JsonResult save(BusOrderDetail busOrderDetail) {
|
||||||
|
if (busOrderDetailService.save(busOrderDetail)) {
|
||||||
|
return JsonResult.ok("添加成功");
|
||||||
|
}
|
||||||
|
return JsonResult.error("添加失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改订单详情表
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("common:busOrderDetail:update")
|
||||||
|
@OperLog(value = "订单详情表管理", desc = "修改", param = false, result = true)
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/update")
|
||||||
|
public JsonResult update(BusOrderDetail busOrderDetail) {
|
||||||
|
if (busOrderDetailService.updateById(busOrderDetail)) {
|
||||||
|
return JsonResult.ok("修改成功");
|
||||||
|
}
|
||||||
|
return JsonResult.error("修改失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue