代码备份
parent
9c7ffeae0b
commit
8cf52c238a
|
|
@ -0,0 +1,240 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<modules>
|
||||||
|
<module>shop-gateway</module>
|
||||||
|
<module>shop-monitor</module>
|
||||||
|
<module>shop-core</module>
|
||||||
|
<module>shop-user</module>
|
||||||
|
<module>shop-consult</module>
|
||||||
|
<module>shop-platform</module>
|
||||||
|
<module>shop-forum</module>
|
||||||
|
</modules>
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-parent</artifactId>
|
||||||
|
<version>3.0.5</version>
|
||||||
|
<relativePath/> <!-- lookup parent from repository -->
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<groupId>com.lei.shop</groupId>
|
||||||
|
<artifactId>shop-cloud</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<shop-cloud.version>1.0-SNAPSHOT</shop-cloud.version>
|
||||||
|
<maven.compiler.source>17</maven.compiler.source>
|
||||||
|
<maven.compiler.target>17</maven.compiler.target>
|
||||||
|
<java.version>17</java.version>
|
||||||
|
<spring-cloud.version>2022.0.1</spring-cloud.version>
|
||||||
|
<spring-cloud-alibaba.version>2022.0.0.0-RC1</spring-cloud-alibaba.version>
|
||||||
|
<mybatis-plus.version>3.5.3</mybatis-plus.version>
|
||||||
|
<jjwt.version>0.11.5</jjwt.version>
|
||||||
|
<xxl-job.version>2.3.1</xxl-job.version>
|
||||||
|
<elasticsearch.version>8.2.0</elasticsearch.version>
|
||||||
|
<shardingsphere-jdbc.version>5.1.1</shardingsphere-jdbc.version>
|
||||||
|
<redisson.version>3.19.1</redisson.version>
|
||||||
|
<spring-boot-admin.version>3.0.2</spring-boot-admin.version>
|
||||||
|
<springdoc-openapi.version>2.0.0</springdoc-openapi.version>
|
||||||
|
<spring-cloud-starter-bootstrap.version>3.1.1</spring-cloud-starter-bootstrap.version>
|
||||||
|
<lombok.version>1.18.28</lombok.version>
|
||||||
|
<knife4j.version>4.1.0</knife4j.version>
|
||||||
|
<netty-resolver.version>4.1.73.Final</netty-resolver.version>
|
||||||
|
<hutool-all.version>5.8.11</hutool-all.version>
|
||||||
|
|
||||||
|
<fastjson2.version>2.0.33</fastjson2.version>
|
||||||
|
<aliyun-java-sdk-core.version>4.6.3</aliyun-java-sdk-core.version>
|
||||||
|
<aliyun-java-dysms.version>2.0.23</aliyun-java-dysms.version>
|
||||||
|
<aliyun-java-oss.version>3.10.2</aliyun-java-oss.version>
|
||||||
|
|
||||||
|
|
||||||
|
<commons-httpclient.version>3.1</commons-httpclient.version>
|
||||||
|
|
||||||
|
</properties>
|
||||||
|
<dependencyManagement>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-dependencies</artifactId>
|
||||||
|
<version>${spring-cloud.version}</version>
|
||||||
|
<type>pom</type>
|
||||||
|
<scope>import</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
|
||||||
|
<version>${spring-cloud-alibaba.version}</version>
|
||||||
|
<type>pom</type>
|
||||||
|
<scope>import</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-bootstrap</artifactId>
|
||||||
|
<version>${spring-cloud-starter-bootstrap.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.baomidou</groupId>
|
||||||
|
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||||
|
<version>${mybatis-plus.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.jsonwebtoken</groupId>
|
||||||
|
<artifactId>jjwt-api</artifactId>
|
||||||
|
<version>${jjwt.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.jsonwebtoken</groupId>
|
||||||
|
<artifactId>jjwt-impl</artifactId>
|
||||||
|
<version>${jjwt.version}</version>
|
||||||
|
<scope>runtime</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.jsonwebtoken</groupId>
|
||||||
|
<artifactId>jjwt-jackson</artifactId>
|
||||||
|
<version>${jjwt.version}</version>
|
||||||
|
<scope>runtime</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>co.elastic.clients</groupId>
|
||||||
|
<artifactId>elasticsearch-java</artifactId>
|
||||||
|
<version>${elasticsearch.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.xuxueli</groupId>
|
||||||
|
<artifactId>xxl-job-core</artifactId>
|
||||||
|
<version>${xxl-job.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.shardingsphere</groupId>
|
||||||
|
<artifactId>shardingsphere-jdbc-core-spring-boot-starter</artifactId>
|
||||||
|
<version>${shardingsphere-jdbc.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.redisson</groupId>
|
||||||
|
<artifactId>redisson-spring-boot-starter</artifactId>
|
||||||
|
<version>${redisson.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.xiaoymin</groupId>
|
||||||
|
<artifactId>knife4j-gateway-spring-boot-starter</artifactId>
|
||||||
|
<version>${knife4j.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.xiaoymin</groupId>
|
||||||
|
<artifactId>knife4j-openapi3-spring-boot-starter</artifactId>
|
||||||
|
<version>${knife4j.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
<version>${lombok.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.hutool</groupId>
|
||||||
|
<artifactId>hutool-all</artifactId>
|
||||||
|
<version>${hutool-all.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!--Mac M1笔记本会报错,参考:https://github.com/netty/netty/issues/11020-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.netty</groupId>
|
||||||
|
<artifactId>netty-resolver-dns-native-macos</artifactId>
|
||||||
|
<version>${netty-resolver.version}</version>
|
||||||
|
<classifier>osx-aarch_64</classifier>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>commons-httpclient</groupId>
|
||||||
|
<artifactId>commons-httpclient</artifactId>
|
||||||
|
<version>${commons-httpclient.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.httpcomponents</groupId>
|
||||||
|
<artifactId>httpmime</artifactId>
|
||||||
|
<version>4.5</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.fastjson2</groupId>
|
||||||
|
<artifactId>fastjson2</artifactId>
|
||||||
|
<version>${fastjson2.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.aliyun</groupId>
|
||||||
|
<artifactId>aliyun-java-sdk-core</artifactId>
|
||||||
|
<version>${aliyun-java-sdk-core.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.aliyun</groupId>
|
||||||
|
<artifactId>dysmsapi20170525</artifactId>
|
||||||
|
<version>${aliyun-java-dysms.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.aliyun.oss</groupId>
|
||||||
|
<artifactId>aliyun-sdk-oss</artifactId>
|
||||||
|
<version>${aliyun-java-oss.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
</dependencies>
|
||||||
|
</dependencyManagement>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<pluginManagement>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<!--指定 Java 编译器的 -source 参数 -->
|
||||||
|
<source>${java.version}</source>
|
||||||
|
<!--指定 Java 编译器的 -target 参数 -->
|
||||||
|
<target>${java.version}</target>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</pluginManagement>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>aliyun</id>
|
||||||
|
<url>https://maven.aliyun.com/repository/public</url>
|
||||||
|
<releases>
|
||||||
|
<enabled>true</enabled>
|
||||||
|
</releases>
|
||||||
|
<snapshots>
|
||||||
|
<enabled>false</enabled>
|
||||||
|
</snapshots>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
|
<pluginRepositories>
|
||||||
|
<pluginRepository>
|
||||||
|
<id>aliyun</id>
|
||||||
|
<url>https://maven.aliyun.com/repository/public</url>
|
||||||
|
<releases>
|
||||||
|
<enabled>true</enabled>
|
||||||
|
</releases>
|
||||||
|
<snapshots>
|
||||||
|
<enabled>false</enabled>
|
||||||
|
</snapshots>
|
||||||
|
</pluginRepository>
|
||||||
|
</pluginRepositories>
|
||||||
|
|
||||||
|
</project>
|
||||||
|
|
@ -0,0 +1,33 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<parent>
|
||||||
|
<artifactId>shop-cloud</artifactId>
|
||||||
|
<groupId>com.lei.shop</groupId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<artifactId>shop-consult</artifactId>
|
||||||
|
<packaging>pom</packaging>
|
||||||
|
<modules>
|
||||||
|
<module>shop-consult-api</module>
|
||||||
|
<module>shop-consult-service</module>
|
||||||
|
</modules>
|
||||||
|
|
||||||
|
<dependencyManagement>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.lei.shop</groupId>
|
||||||
|
<artifactId>shop-common</artifactId>
|
||||||
|
<version>${project.parent.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.lei.shop</groupId>
|
||||||
|
<artifactId>shop-config</artifactId>
|
||||||
|
<version>${project.parent.version}</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</dependencyManagement>
|
||||||
|
|
||||||
|
</project>
|
||||||
|
|
@ -0,0 +1,35 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<parent>
|
||||||
|
<artifactId>shop-consult</artifactId>
|
||||||
|
<groupId>com.lei.shop</groupId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<artifactId>shop-consult-api</artifactId>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.lei.shop</groupId>
|
||||||
|
<artifactId>shop-common</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.hibernate.validator</groupId>
|
||||||
|
<artifactId>hibernate-validator</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
</project>
|
||||||
|
|
@ -0,0 +1,47 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<parent>
|
||||||
|
<artifactId>shop-consult</artifactId>
|
||||||
|
<groupId>com.lei.shop</groupId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<artifactId>shop-consult-service</artifactId>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.lei.shop</groupId>
|
||||||
|
<artifactId>shop-config</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.lei.shop</groupId>
|
||||||
|
<artifactId>shop-consult-api</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<excludes>
|
||||||
|
<exclude>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
</exclude>
|
||||||
|
</excludes>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
||||||
|
|
@ -0,0 +1,27 @@
|
||||||
|
package com.lei.shop.consult;
|
||||||
|
|
||||||
|
import org.mybatis.spring.annotation.MapperScan;
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.cache.annotation.EnableCaching;
|
||||||
|
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||||
|
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 咨询消息板块
|
||||||
|
* @className: ShopConsultApplication
|
||||||
|
* @author: 周
|
||||||
|
*
|
||||||
|
* @create: 2023-06-14 00:19
|
||||||
|
*/
|
||||||
|
@SpringBootApplication(scanBasePackages = {"com.lei.shop"})
|
||||||
|
@MapperScan("com.lei.shop.consult.common.mapper")
|
||||||
|
@EnableCaching
|
||||||
|
@EnableDiscoveryClient
|
||||||
|
@EnableFeignClients(basePackages = {"com.lei.shop.api.consult.feign"})
|
||||||
|
public class ShopConsultApplication {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SpringApplication.run(ShopConsultApplication.class, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,49 @@
|
||||||
|
package com.lei.shop.consult.common.entity;
|
||||||
|
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.lei.shop.config.base.LeiBaseEntity;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 咨询信息实体
|
||||||
|
* @className: 咨询信息
|
||||||
|
* @author: 周
|
||||||
|
*
|
||||||
|
* @create: 2023-06-13 23:24:12
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Schema(name = "咨询信息", description = "table.comment!")
|
||||||
|
@TableName("consult_data")
|
||||||
|
public class ConsultData extends LeiBaseEntity<ConsultData> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 标题
|
||||||
|
*/
|
||||||
|
@TableField("titles")
|
||||||
|
@Schema(description = "标题")
|
||||||
|
private String titles;
|
||||||
|
/**
|
||||||
|
* 图片
|
||||||
|
*/
|
||||||
|
@TableField("images")
|
||||||
|
@Schema(description = "图片")
|
||||||
|
private String images;
|
||||||
|
/**
|
||||||
|
* 简介
|
||||||
|
*/
|
||||||
|
@TableField("introduction")
|
||||||
|
@Schema(description = "简介")
|
||||||
|
private String introduction;
|
||||||
|
/**
|
||||||
|
* 内容
|
||||||
|
*/
|
||||||
|
@TableField("contents")
|
||||||
|
@Schema(description = "内容")
|
||||||
|
private String contents;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
package com.lei.shop.consult.common.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.lei.shop.config.base.LeiPage;
|
||||||
|
import com.lei.shop.consult.common.entity.ConsultData;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 咨询信息Mapper接口
|
||||||
|
* @className: 咨询信息
|
||||||
|
* @author: 周
|
||||||
|
*
|
||||||
|
* @create: 2023-06-13 23:24:12
|
||||||
|
*/
|
||||||
|
public interface ConsultDataMapper extends BaseMapper<ConsultData> {
|
||||||
|
|
||||||
|
IPage<ConsultData> listPage(@Param("page") LeiPage<ConsultData> page);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
package com.lei.shop.consult.common.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.lei.shop.common.req.PageReqDto;
|
||||||
|
import com.lei.shop.consult.common.entity.ConsultData;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 咨询信息服务类
|
||||||
|
* @className: 咨询信息
|
||||||
|
* @author: 周
|
||||||
|
* @email:
|
||||||
|
* @create: 2023-06-13 23:24:12
|
||||||
|
*/
|
||||||
|
public interface ConsultDataService extends IService<ConsultData> {
|
||||||
|
|
||||||
|
IPage<ConsultData> listPage(PageReqDto<ConsultData> t);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
package com.lei.shop.consult.common.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.lei.shop.common.req.PageReqDto;
|
||||||
|
import com.lei.shop.config.base.LeiPage;
|
||||||
|
import com.lei.shop.consult.common.entity.ConsultData;
|
||||||
|
import com.lei.shop.consult.common.mapper.ConsultDataMapper;
|
||||||
|
import com.lei.shop.consult.common.service.ConsultDataService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 咨询信息服务实现类
|
||||||
|
* @className: 咨询信息
|
||||||
|
* @author: 周
|
||||||
|
* @email:
|
||||||
|
* @create: 2023-06-13 23:24:12
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class ConsultDataServiceImpl extends ServiceImpl<ConsultDataMapper, ConsultData> implements ConsultDataService {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IPage<ConsultData> listPage(PageReqDto<ConsultData> t) {
|
||||||
|
LeiPage<ConsultData> page = new LeiPage<>(t.getPageNum(), t.getPageSize());
|
||||||
|
if (t.getSearch() != null) {
|
||||||
|
page.setSearch(t.getSearch());
|
||||||
|
}
|
||||||
|
return baseMapper.listPage(page);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,55 @@
|
||||||
|
package com.lei.shop.consult.controller;
|
||||||
|
|
||||||
|
import cn.hutool.core.lang.Assert;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.lei.shop.common.constant.ErrorCodeEnum;
|
||||||
|
import com.lei.shop.common.constant.SystemConfigConsts;
|
||||||
|
import com.lei.shop.common.req.PageReqDto;
|
||||||
|
import com.lei.shop.config.base.LeiBaseEntity;
|
||||||
|
import com.lei.shop.config.exception.BusinessException;
|
||||||
|
import com.lei.shop.consult.common.entity.ConsultData;
|
||||||
|
import com.lei.shop.consult.common.service.ConsultDataService;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
|
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @className: ConsultDataController
|
||||||
|
* @author: 周
|
||||||
|
*
|
||||||
|
* @create: 2023-06-14 00:23
|
||||||
|
*/
|
||||||
|
@Tag(name = "咨询信息", description = "咨询信息")
|
||||||
|
@SecurityRequirement(name = SystemConfigConsts.HTTP_AUTH_HEADER_NAME)
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("api/consult")
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class ConsultDataController {
|
||||||
|
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ConsultDataService consultDataService;
|
||||||
|
|
||||||
|
@Operation(summary = "咨询详情")
|
||||||
|
@PostMapping("page")
|
||||||
|
public IPage<ConsultData> page(@RequestBody PageReqDto<Integer> page) {
|
||||||
|
return consultDataService.page(new Page<>(page.getPageNum(), page.getPageSize()),
|
||||||
|
Wrappers.<ConsultData>lambdaQuery().orderByDesc(LeiBaseEntity::getCreateDate)
|
||||||
|
.select()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "咨询详情")
|
||||||
|
@GetMapping("getById/{id}")
|
||||||
|
public ConsultData getById(@Parameter(description = "内容ID") @PathVariable("id") String id) {
|
||||||
|
ConsultData byId = consultDataService.getById(id);
|
||||||
|
Assert.notNull(byId, () -> new BusinessException(ErrorCodeEnum.DATA_NOT_EXISTS));
|
||||||
|
return byId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,24 @@
|
||||||
|
server:
|
||||||
|
port: 9002
|
||||||
|
spring:
|
||||||
|
profiles:
|
||||||
|
include: common
|
||||||
|
active: dev
|
||||||
|
|
||||||
|
management:
|
||||||
|
# 端点启用配置
|
||||||
|
endpoint:
|
||||||
|
logfile:
|
||||||
|
# 启用返回日志文件内容的端点
|
||||||
|
enabled: true
|
||||||
|
# 外部日志文件路径
|
||||||
|
external-file: logs/shop-consult-service.log
|
||||||
|
|
||||||
|
springdoc:
|
||||||
|
group-configs:
|
||||||
|
- group: 'default'
|
||||||
|
paths-to-match: '/api/**'
|
||||||
|
packages-to-scan: com.lei.shop.consult.app
|
||||||
|
default-flat-param-object: false
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
spring:
|
||||||
|
application:
|
||||||
|
name: shop-consult-service
|
||||||
|
profiles:
|
||||||
|
include: common
|
||||||
|
|
||||||
|
|
@ -0,0 +1,79 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<configuration>
|
||||||
|
<!-- 彩色日志依赖的渲染类 -->
|
||||||
|
<conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter"/>
|
||||||
|
<conversionRule conversionWord="wex"
|
||||||
|
converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter"/>
|
||||||
|
<conversionRule conversionWord="wEx"
|
||||||
|
converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter"/>
|
||||||
|
<!-- 彩色日志格式 -->
|
||||||
|
<property name="CONSOLE_LOG_PATTERN"
|
||||||
|
value="${CONSOLE_LOG_PATTERN:-%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}"/>
|
||||||
|
|
||||||
|
<!-- %m输出的信息,%p日志级别,%t线程名,%d日期,%c类的全名,%i索引【从数字0开始递增】,,, -->
|
||||||
|
<!-- appender是configuration的子节点,是负责写日志的组件。 -->
|
||||||
|
<!-- ConsoleAppender:把日志输出到控制台 -->
|
||||||
|
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||||
|
<encoder>
|
||||||
|
<pattern>${CONSOLE_LOG_PATTERN}</pattern>
|
||||||
|
<!-- 控制台也要使用UTF-8,不要使用GBK,否则会中文乱码 -->
|
||||||
|
<charset>UTF-8</charset>
|
||||||
|
</encoder>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<!-- RollingFileAppender:滚动记录文件,先将日志记录到指定文件,当符合某个条件时,将日志记录到其他文件 -->
|
||||||
|
<!-- 以下的大概意思是:1.先按日期存日志,日期变了,将前一天的日志文件名重命名为XXX%日期%索引,新的日志仍然是demo.log -->
|
||||||
|
<!-- 2.如果日期没有发生变化,但是当前日志的文件大小超过1KB时,对当前日志进行分割 重命名 -->
|
||||||
|
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||||
|
|
||||||
|
<File>logs/shop-consult-service.log</File>
|
||||||
|
<!-- rollingPolicy:当发生滚动时,决定 RollingFileAppender 的行为,涉及文件移动和重命名。 -->
|
||||||
|
<!-- TimeBasedRollingPolicy: 最常用的滚动策略,它根据时间来制定滚动策略,既负责滚动也负责出发滚动 -->
|
||||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||||
|
<!-- 活动文件的名字会根据fileNamePattern的值,每隔一段时间改变一次 -->
|
||||||
|
<!-- 文件名:logs/demo.2017-12-05.0.log -->
|
||||||
|
<fileNamePattern>logs/debug.%d.%i.log</fileNamePattern>
|
||||||
|
<!-- 每产生一个日志文件,该日志文件的保存期限为30天 -->
|
||||||
|
<maxHistory>30</maxHistory>
|
||||||
|
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
|
||||||
|
<!-- maxFileSize:这是活动文件的大小,默认值是10MB,测试时可改成1KB看效果 -->
|
||||||
|
<maxFileSize>10MB</maxFileSize>
|
||||||
|
</timeBasedFileNamingAndTriggeringPolicy>
|
||||||
|
</rollingPolicy>
|
||||||
|
<encoder>
|
||||||
|
<!-- pattern节点,用来设置日志的输入格式 -->
|
||||||
|
<pattern>
|
||||||
|
%d %p (%file:%line\)- %m%n
|
||||||
|
</pattern>
|
||||||
|
<!-- 记录日志的编码:此处设置字符集 - -->
|
||||||
|
<charset>UTF-8</charset>
|
||||||
|
</encoder>
|
||||||
|
</appender>
|
||||||
|
<springProfile name="dev">
|
||||||
|
<!-- ROOT 日志级别 -->
|
||||||
|
<root level="INFO">
|
||||||
|
<appender-ref ref="STDOUT"/>
|
||||||
|
<appender-ref ref="FILE"/>
|
||||||
|
</root>
|
||||||
|
<!-- 指定项目中某个包,当有日志操作行为时的日志记录级别 -->
|
||||||
|
<!-- com.maijinjie.springboot 为根包,也就是只要是发生在这个根包下面的所有日志操作行为的权限都是DEBUG -->
|
||||||
|
<!-- 级别依次为【从高到低】:FATAL > ERROR > WARN > INFO > DEBUG > TRACE -->
|
||||||
|
<logger name="com.lei.shop" level="DEBUG" additivity="false">
|
||||||
|
<appender-ref ref="STDOUT"/>
|
||||||
|
<appender-ref ref="FILE"/>
|
||||||
|
</logger>
|
||||||
|
</springProfile>
|
||||||
|
|
||||||
|
<springProfile name="prod">
|
||||||
|
<!-- ROOT 日志级别 -->
|
||||||
|
<root level="INFO">
|
||||||
|
<appender-ref ref="FILE"/>
|
||||||
|
</root>
|
||||||
|
<!-- 指定项目中某个包,当有日志操作行为时的日志记录级别 -->
|
||||||
|
<!-- com.maijinjie.springboot 为根包,也就是只要是发生在这个根包下面的所有日志操作行为的权限都是DEBUG -->
|
||||||
|
<!-- 级别依次为【从高到低】:FATAL > ERROR > WARN > INFO > DEBUG > TRACE -->
|
||||||
|
<logger name="com.lei.shop" level="ERROR" additivity="false">
|
||||||
|
<appender-ref ref="FILE"/>
|
||||||
|
</logger>
|
||||||
|
</springProfile>
|
||||||
|
</configuration>
|
||||||
|
|
@ -0,0 +1,36 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.lei.shop.consult.common.mapper.ConsultDataMapper">
|
||||||
|
|
||||||
|
<select id="listPage" resultType="com.lei.shop.consult.common.entity.ConsultData">
|
||||||
|
select a.* from consult_data a
|
||||||
|
where a.deleted = 0
|
||||||
|
<if test="page.search != null">
|
||||||
|
<if test="page.search.id != null and page.search.id != ''">
|
||||||
|
and a.id like concat('%',#{page.search.id},'%')
|
||||||
|
</if>
|
||||||
|
<if test="page.search.createDate != null and page.search.createDate != ''">
|
||||||
|
and a.create_date like concat('%',#{page.search.createDate},'%')
|
||||||
|
</if>
|
||||||
|
<if test="page.search.updateDate != null and page.search.updateDate != ''">
|
||||||
|
and a.update_date like concat('%',#{page.search.updateDate},'%')
|
||||||
|
</if>
|
||||||
|
<if test="page.search.deleted != null and page.search.deleted != ''">
|
||||||
|
and a.deleted like concat('%',#{page.search.deleted},'%')
|
||||||
|
</if>
|
||||||
|
<if test="page.search.titles != null and page.search.titles != ''">
|
||||||
|
and a.titles like concat('%',#{page.search.titles},'%')
|
||||||
|
</if>
|
||||||
|
<if test="page.search.images != null and page.search.images != ''">
|
||||||
|
and a.images like concat('%',#{page.search.images},'%')
|
||||||
|
</if>
|
||||||
|
<if test="page.search.introduction != null and page.search.introduction != ''">
|
||||||
|
and a.introduction like concat('%',#{page.search.introduction},'%')
|
||||||
|
</if>
|
||||||
|
<if test="page.search.contents != null and page.search.contents != ''">
|
||||||
|
and a.contents like concat('%',#{page.search.contents},'%')
|
||||||
|
</if>
|
||||||
|
</if>
|
||||||
|
order by a.create_date desc
|
||||||
|
</select>
|
||||||
|
</mapper>
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<parent>
|
||||||
|
<artifactId>shop-cloud</artifactId>
|
||||||
|
<groupId>com.lei.shop</groupId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<artifactId>shop-core</artifactId>
|
||||||
|
<packaging>pom</packaging>
|
||||||
|
<modules>
|
||||||
|
<module>shop-common</module>
|
||||||
|
<module>shop-config</module>
|
||||||
|
<module>shop-sms</module>
|
||||||
|
<module>shop-pay</module>
|
||||||
|
</modules>
|
||||||
|
|
||||||
|
|
||||||
|
</project>
|
||||||
|
|
@ -0,0 +1,60 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<parent>
|
||||||
|
<artifactId>shop-core</artifactId>
|
||||||
|
<groupId>com.lei.shop</groupId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<artifactId>shop-common</artifactId>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.xiaoymin</groupId>
|
||||||
|
<artifactId>knife4j-openapi3-spring-boot-starter</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.jsonwebtoken</groupId>
|
||||||
|
<artifactId>jjwt-api</artifactId>
|
||||||
|
<version>${jjwt.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.jsonwebtoken</groupId>
|
||||||
|
<artifactId>jjwt-impl</artifactId>
|
||||||
|
<version>${jjwt.version}</version>
|
||||||
|
<scope>runtime</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.jsonwebtoken</groupId>
|
||||||
|
<artifactId>jjwt-jackson</artifactId>
|
||||||
|
<version>${jjwt.version}</version>
|
||||||
|
<scope>runtime</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.hutool</groupId>
|
||||||
|
<artifactId>hutool-all</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.fastjson2</groupId>
|
||||||
|
<artifactId>fastjson2</artifactId>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
||||||
|
|
@ -0,0 +1,73 @@
|
||||||
|
package com.lei.shop.common.auth;
|
||||||
|
|
||||||
|
import io.jsonwebtoken.Claims;
|
||||||
|
import io.jsonwebtoken.Jws;
|
||||||
|
import io.jsonwebtoken.JwtException;
|
||||||
|
import io.jsonwebtoken.Jwts;
|
||||||
|
import io.jsonwebtoken.security.Keys;
|
||||||
|
import lombok.experimental.UtilityClass;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* JWT 工具类
|
||||||
|
*
|
||||||
|
* @className: JwtUtils
|
||||||
|
* @author: 周
|
||||||
|
*
|
||||||
|
* @create: 2023-06-12 21:07
|
||||||
|
*/
|
||||||
|
@UtilityClass
|
||||||
|
@Slf4j
|
||||||
|
public class JwtUtils {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* JWT 加密密钥
|
||||||
|
*/
|
||||||
|
private static final String SECRET = "D0E3091F8C1C48F1A5C261625D0B7BDC";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 定义系统标识头常量
|
||||||
|
*/
|
||||||
|
private static final String HEADER_SYSTEM_KEY = "systemKeyHeader";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据用户ID生成JWT
|
||||||
|
*
|
||||||
|
* @param uid 用户ID
|
||||||
|
* @param systemKey 系统标识
|
||||||
|
* @return JWT
|
||||||
|
*/
|
||||||
|
public String generateToken(String uid, String systemKey) {
|
||||||
|
return Jwts.builder()
|
||||||
|
.setHeaderParam(HEADER_SYSTEM_KEY, systemKey)
|
||||||
|
.setSubject(uid)
|
||||||
|
.signWith(Keys.hmacShaKeyFor(SECRET.getBytes(StandardCharsets.UTF_8)))
|
||||||
|
.compact();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 解析JWT返回用户ID
|
||||||
|
*
|
||||||
|
* @param token JWT
|
||||||
|
* @param systemKey 系统标识
|
||||||
|
* @return 用户ID
|
||||||
|
*/
|
||||||
|
public String parseToken(String token, String systemKey) {
|
||||||
|
Jws<Claims> claimsJws;
|
||||||
|
try {
|
||||||
|
claimsJws = Jwts.parserBuilder()
|
||||||
|
.setSigningKey(Keys.hmacShaKeyFor(SECRET.getBytes(StandardCharsets.UTF_8)))
|
||||||
|
.build()
|
||||||
|
.parseClaimsJws(token);
|
||||||
|
if (Objects.equals(claimsJws.getHeader().get(HEADER_SYSTEM_KEY), systemKey)) {
|
||||||
|
return claimsJws.getBody().getSubject();
|
||||||
|
}
|
||||||
|
} catch (JwtException e) {
|
||||||
|
log.warn("JWT解析失败:{}", token);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,43 @@
|
||||||
|
package com.lei.shop.common.auth;
|
||||||
|
|
||||||
|
import com.lei.shop.common.auth.demo.UserLoginAuth;
|
||||||
|
import lombok.experimental.UtilityClass;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户信息 持有类
|
||||||
|
*
|
||||||
|
* @className: UserHolder
|
||||||
|
* @author: 周
|
||||||
|
* @email:
|
||||||
|
* @create: 2023-06-12 21:09
|
||||||
|
*/
|
||||||
|
@UtilityClass
|
||||||
|
public class UserHolder {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 当前线程用户ID
|
||||||
|
*/
|
||||||
|
private static final ThreadLocal<String> userIdTL = new ThreadLocal<>();
|
||||||
|
private static final ThreadLocal<UserLoginAuth> loginAuthTL = new ThreadLocal<>();
|
||||||
|
|
||||||
|
public void setUserId(String userId) {
|
||||||
|
userIdTL.set(userId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUserId() {
|
||||||
|
return userIdTL.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLoginAuthTL(UserLoginAuth authTL) {
|
||||||
|
loginAuthTL.set(authTL);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ThreadLocal<UserLoginAuth> getLoginAuthTL() {
|
||||||
|
return loginAuthTL;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clear() {
|
||||||
|
userIdTL.remove();
|
||||||
|
loginAuthTL.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,25 @@
|
||||||
|
package com.lei.shop.common.auth.demo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @className: UserInfo
|
||||||
|
* @author: 周
|
||||||
|
* @email:
|
||||||
|
* @create: 2023-06-16 02:11
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
public class UserLoginAuth {
|
||||||
|
|
||||||
|
@Schema(description = "用户ID")
|
||||||
|
private String userId;
|
||||||
|
|
||||||
|
@Schema(description = "店铺ID")
|
||||||
|
private String storeId;
|
||||||
|
|
||||||
|
@Schema(description = "用户类型:1 用户 2商家")
|
||||||
|
private Integer type;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,101 @@
|
||||||
|
package com.lei.shop.common.constant;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 缓存相关常量
|
||||||
|
*
|
||||||
|
* @className: CacheConsts
|
||||||
|
* @author: 周
|
||||||
|
* @email:
|
||||||
|
* @create: 2023-06-12 21:16
|
||||||
|
*/
|
||||||
|
public class CacheConsts {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 本项目 Redis 缓存前缀
|
||||||
|
*/
|
||||||
|
public static final String REDIS_CACHE_PREFIX = "Cache::Lei::";
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Caffeine 缓存管理器
|
||||||
|
*/
|
||||||
|
public static final String CAFFEINE_CACHE_MANAGER = "caffeineCacheManager";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Redis 缓存管理器
|
||||||
|
*/
|
||||||
|
public static final String REDIS_CACHE_MANAGER = "redisCacheManager";
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 短信验证码 KEY
|
||||||
|
*/
|
||||||
|
public static final String SMS_VERIFY_CODE_CACHE_KEY =
|
||||||
|
REDIS_CACHE_PREFIX + "smsVerifyCodeCache::";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户信息缓存
|
||||||
|
*/
|
||||||
|
public static final String USER_INFO_CACHE_NAME = "userInfoCache";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 作家信息缓存
|
||||||
|
*/
|
||||||
|
public static final String AUTHOR_INFO_CACHE_NAME = "authorInfoCache";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 缓存配置常量
|
||||||
|
*/
|
||||||
|
public enum CacheEnum {
|
||||||
|
|
||||||
|
USER_INFO_CACHE(2, USER_INFO_CACHE_NAME, 60 * 60 * 24, 10000),
|
||||||
|
|
||||||
|
AUTHOR_INFO_CACHE(2, AUTHOR_INFO_CACHE_NAME, 60 * 60 * 48, 1000);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 缓存类型 0-本地 1-本地和远程 2-远程
|
||||||
|
*/
|
||||||
|
private int type;
|
||||||
|
/**
|
||||||
|
* 缓存的名字
|
||||||
|
*/
|
||||||
|
private String name;
|
||||||
|
/**
|
||||||
|
* 失效时间(秒) 0-永不失效
|
||||||
|
*/
|
||||||
|
private int ttl;
|
||||||
|
/**
|
||||||
|
* 最大容量
|
||||||
|
*/
|
||||||
|
private int maxSize;
|
||||||
|
|
||||||
|
CacheEnum(int type, String name, int ttl, int maxSize) {
|
||||||
|
this.type = type;
|
||||||
|
this.name = name;
|
||||||
|
this.ttl = ttl;
|
||||||
|
this.maxSize = maxSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isLocal() {
|
||||||
|
return type <= 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isRemote() {
|
||||||
|
return type >= 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getTtl() {
|
||||||
|
return ttl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMaxSize() {
|
||||||
|
return maxSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,48 @@
|
||||||
|
package com.lei.shop.common.constant;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通用常量
|
||||||
|
*
|
||||||
|
* @className: CommonConsts
|
||||||
|
* @author: 周
|
||||||
|
* @email:
|
||||||
|
* @create: 2023-06-12 21:17
|
||||||
|
*/
|
||||||
|
public class CommonConsts {
|
||||||
|
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
public enum CONSTANT_PAY {
|
||||||
|
|
||||||
|
NOTIF_URL("http://trans.yyhome2022.com/");
|
||||||
|
|
||||||
|
|
||||||
|
private String constant;
|
||||||
|
|
||||||
|
CONSTANT_PAY(String constant) {
|
||||||
|
this.constant = constant;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
public enum SqlEnum {
|
||||||
|
|
||||||
|
LIMIT_1("limit 1"),
|
||||||
|
LIMIT_2("limit 2"),
|
||||||
|
LIMIT_5("limit 5"),
|
||||||
|
LIMIT_7("limit 7"),
|
||||||
|
LIMIT_30("limit 30"),
|
||||||
|
LIMIT_500("limit 500");
|
||||||
|
|
||||||
|
private String sql;
|
||||||
|
|
||||||
|
SqlEnum(String sql) {
|
||||||
|
this.sql = sql;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,132 @@
|
||||||
|
package com.lei.shop.common.constant;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @className: ErrorCodeEnum
|
||||||
|
* @author: 周
|
||||||
|
*
|
||||||
|
* @create: 2023-06-12 20:59
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@AllArgsConstructor
|
||||||
|
public enum ErrorCodeEnum {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 正确执行后的返回
|
||||||
|
*/
|
||||||
|
OK("00000", "一切 ok"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 一级宏观错误码,用户端错误
|
||||||
|
*/
|
||||||
|
USER_ERROR("A0001", "用户端错误"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 二级宏观错误码,用户注册错误
|
||||||
|
*/
|
||||||
|
USER_REGISTER_ERROR("A0100", "用户注册错误"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户未同意隐私协议
|
||||||
|
*/
|
||||||
|
USER_NO_AGREE_PRIVATE_ERROR("A0101", "用户未同意隐私协议"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 注册国家或地区受限
|
||||||
|
*/
|
||||||
|
USER_REGISTER_AREA_LIMIT_ERROR("A0102", "注册国家或地区受限"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户验证码错误
|
||||||
|
*/
|
||||||
|
USER_VERIFY_CODE_ERROR("A0240", "用户验证码错误"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户名已存在
|
||||||
|
*/
|
||||||
|
USER_NAME_EXIST("A0111", "用户名已存在"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户账号不存在
|
||||||
|
*/
|
||||||
|
USER_ACCOUNT_NOT_EXIST("A0201", "用户账号不存在"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户密码错误
|
||||||
|
*/
|
||||||
|
USER_PASSWORD_ERROR("A0210", "用户密码错误"),
|
||||||
|
|
||||||
|
|
||||||
|
DATA_NOT_EXISTS("A0211", "数据不存在"),
|
||||||
|
ACCESS_DENIED_EXISTS("A0212", "无权限修改"),
|
||||||
|
IDENTITY_EXISTS("A0213", "身份错误"),
|
||||||
|
SHOP_NO_OPEN_EXISTS("A0214", "用户还未开通店铺"),
|
||||||
|
SHOP_OPEN_EXISTS("A0215", "用户已经开通店铺"),
|
||||||
|
SHOP_CREATE_EXISTS("A0216", "店铺开通失败"),
|
||||||
|
|
||||||
|
ORDER_CREATE_EXISTS("A0217", "支付订单创建失败"),
|
||||||
|
PRODUCT_CREATE_EXISTS("A0218", "支付订单创建失败"),
|
||||||
|
|
||||||
|
INVENTORY_CREATE_EXISTS("A0219", "库存不足"),
|
||||||
|
ORDER_TYPE_EXISTS("A0220", "订单状态不对"),
|
||||||
|
AMOUNT_EXISTS("A0221", "金额不足"),
|
||||||
|
SAVE_EXISTS("A0222", "保存失败"),
|
||||||
|
USER_NO_AUTH_EXISTS("A0223", "用户未认证,暂时无法提交。"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 二级宏观错误码,用户请求参数错误
|
||||||
|
*/
|
||||||
|
USER_REQUEST_PARAM_ERROR("A0400", "用户请求参数错误"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户登录已过期
|
||||||
|
*/
|
||||||
|
USER_LOGIN_EXPIRED("A0230", "用户登录已过期"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 访问未授权
|
||||||
|
*/
|
||||||
|
USER_UN_AUTH("A0301", "访问未授权"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户请求服务异常
|
||||||
|
*/
|
||||||
|
USER_REQ_EXCEPTION("A0500", "用户请求服务异常"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 请求超出限制
|
||||||
|
*/
|
||||||
|
USER_REQ_MANY("A0501", "请求超出限制"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 一级宏观错误码,系统执行出错
|
||||||
|
*/
|
||||||
|
SYSTEM_ERROR("B0001", "系统执行出错"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 二级宏观错误码,系统执行超时
|
||||||
|
*/
|
||||||
|
SYSTEM_TIMEOUT_ERROR("B0100", "系统执行超时"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 一级宏观错误码,调用第三方服务出错
|
||||||
|
*/
|
||||||
|
THIRD_SERVICE_ERROR("C0001", "调用第三方服务出错"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 一级宏观错误码,中间件服务出错
|
||||||
|
*/
|
||||||
|
MIDDLEWARE_SERVICE_ERROR("C0100", "中间件服务出错");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 错误码
|
||||||
|
*/
|
||||||
|
private final String code;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 中文描述
|
||||||
|
*/
|
||||||
|
private final String message;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,39 @@
|
||||||
|
package com.lei.shop.common.constant;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @className: SystemConfigConsts
|
||||||
|
* @author: 周
|
||||||
|
*
|
||||||
|
* @create: 2023-06-12 21:14
|
||||||
|
*/
|
||||||
|
public class SystemConfigConsts {
|
||||||
|
|
||||||
|
private SystemConfigConsts() {
|
||||||
|
throw new IllegalStateException(CONST_INSTANCE_EXCEPTION_MSG);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Http 请求认证 Header
|
||||||
|
*/
|
||||||
|
public static final String HTTP_AUTH_HEADER_NAME = "Authorization";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 前台门户系统标识
|
||||||
|
*/
|
||||||
|
public static final String NOVEL_FRONT_KEY = "shopLei";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 作家管理系统标识
|
||||||
|
*/
|
||||||
|
public static final String NOVEL_AUTHOR_KEY = "author";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 后台管理系统标识
|
||||||
|
*/
|
||||||
|
public static final String NOVEL_ADMIN_KEY = "admin";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 常量类实例化异常信息
|
||||||
|
*/
|
||||||
|
public static final String CONST_INSTANCE_EXCEPTION_MSG = "Constant class";
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,33 @@
|
||||||
|
package com.lei.shop.common.json.deserializer;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.core.JsonParser;
|
||||||
|
import com.fasterxml.jackson.databind.DeserializationContext;
|
||||||
|
import com.fasterxml.jackson.databind.JsonDeserializer;
|
||||||
|
import org.springframework.boot.jackson.JsonComponent;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SON 全局反序列化器
|
||||||
|
*
|
||||||
|
* @className: GlobalJsonDeserializer
|
||||||
|
* @author: 周
|
||||||
|
*
|
||||||
|
* @create: 2023-06-12 21:06
|
||||||
|
*/
|
||||||
|
@JsonComponent
|
||||||
|
public class GlobalJsonDeserializer {
|
||||||
|
/**
|
||||||
|
* 字符串反序列化器:过滤特殊字符,解决 XSS 攻击
|
||||||
|
*/
|
||||||
|
public static class StringDeserializer extends JsonDeserializer<String> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String deserialize(JsonParser jsonParser,
|
||||||
|
DeserializationContext deserializationContext) throws IOException {
|
||||||
|
return jsonParser.getValueAsString()
|
||||||
|
.replace("<", "<")
|
||||||
|
.replace(">", ">");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
package com.lei.shop.common.json.serializer;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.core.JsonGenerator;
|
||||||
|
import com.fasterxml.jackson.databind.JsonSerializer;
|
||||||
|
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @className: UsernameSerializer
|
||||||
|
* @author: 周
|
||||||
|
* @email:
|
||||||
|
* @create: 2023-06-12 21:06
|
||||||
|
*/
|
||||||
|
public class UsernameSerializer extends JsonSerializer<String> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void serialize(String s, JsonGenerator jsonGenerator,
|
||||||
|
SerializerProvider serializerProvider) throws IOException {
|
||||||
|
jsonGenerator.writeString(s.substring(0, 4) + "****" + s.substring(8));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,28 @@
|
||||||
|
package com.lei.shop.common.req;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @className: PageReqDto
|
||||||
|
* @author: 周
|
||||||
|
*
|
||||||
|
* @create: 2023-06-12 20:53
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class PageReqDto<T> {
|
||||||
|
/**
|
||||||
|
* 请求页码,默认第 1 页
|
||||||
|
*/
|
||||||
|
@Schema(description = "请求页码,默认第 1 页")
|
||||||
|
private int pageNum = 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 每页大小,默认每页 10 条
|
||||||
|
*/
|
||||||
|
@Schema(description = "每页大小,默认每页 10 条")
|
||||||
|
private int pageSize = 10;
|
||||||
|
|
||||||
|
@Schema(description = "搜索条件")
|
||||||
|
private T search;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,105 @@
|
||||||
|
package com.lei.shop.common.resp;
|
||||||
|
|
||||||
|
import com.lei.shop.common.constant.ErrorCodeEnum;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @className: RestResp
|
||||||
|
* @author: 周
|
||||||
|
* @email:
|
||||||
|
* @create: 2023-06-12 20:57
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
public class RestResp<T> implements Serializable {
|
||||||
|
/**
|
||||||
|
* 响应码
|
||||||
|
*/
|
||||||
|
@Schema(description = "错误码,00000-没有错误")
|
||||||
|
private String code;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 响应消息
|
||||||
|
*/
|
||||||
|
@Schema(description = "响应消息")
|
||||||
|
private String message;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 响应数据
|
||||||
|
*/
|
||||||
|
@Schema(description = "响应数据")
|
||||||
|
private T data;
|
||||||
|
|
||||||
|
private RestResp() {
|
||||||
|
this.code = ErrorCodeEnum.OK.getCode();
|
||||||
|
this.message = ErrorCodeEnum.OK.getMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
private RestResp(ErrorCodeEnum errorCode) {
|
||||||
|
this.code = errorCode.getCode();
|
||||||
|
this.message = errorCode.getMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
private RestResp(ErrorCodeEnum errorCode, String message) {
|
||||||
|
this.code = errorCode.getCode();
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
private RestResp(String code, String message) {
|
||||||
|
this.code = code;
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private RestResp(T data) {
|
||||||
|
this();
|
||||||
|
this.data = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 业务处理成功,无数据返回
|
||||||
|
*/
|
||||||
|
public static RestResp<Void> ok() {
|
||||||
|
return new RestResp<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 业务处理成功,有数据返回
|
||||||
|
*/
|
||||||
|
public static <T> RestResp<T> ok(T data) {
|
||||||
|
return new RestResp<>(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 业务处理失败
|
||||||
|
*/
|
||||||
|
public static RestResp<Void> fail(ErrorCodeEnum errorCode) {
|
||||||
|
return new RestResp<>(errorCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static RestResp<Void> fail(String code, String message) {
|
||||||
|
return new RestResp<>(code, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static RestResp<Void> fail(ErrorCodeEnum errorCode, String message) {
|
||||||
|
return new RestResp<>(errorCode, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 系统错误
|
||||||
|
*/
|
||||||
|
public static RestResp<Void> error() {
|
||||||
|
return new RestResp<>(ErrorCodeEnum.SYSTEM_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断是否成功
|
||||||
|
*/
|
||||||
|
public boolean isOk() {
|
||||||
|
return Objects.equals(this.code, ErrorCodeEnum.OK.getCode());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,159 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<parent>
|
||||||
|
<artifactId>shop-core</artifactId>
|
||||||
|
<groupId>com.lei.shop</groupId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<artifactId>shop-config</artifactId>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-loadbalancer</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
|
<exclusions>
|
||||||
|
<!-- Exclude the Tomcat dependency -->
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-tomcat</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Use Undertow instead -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-undertow</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- mybatis-plus -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.baomidou</groupId>
|
||||||
|
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 缓存相关 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-cache</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.ben-manes.caffeine</groupId>
|
||||||
|
<artifactId>caffeine</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 请求参数校验相关 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.hibernate.validator</groupId>
|
||||||
|
<artifactId>hibernate-validator</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- MQ 相关 -->
|
||||||
|
<!-- <dependency>-->
|
||||||
|
<!-- <groupId>org.springframework.boot</groupId>-->
|
||||||
|
<!-- <artifactId>spring-boot-starter-amqp</artifactId>-->
|
||||||
|
<!-- </dependency>-->
|
||||||
|
|
||||||
|
<!-- ShardingSphere-JDBC -->
|
||||||
|
<!-- <dependency>-->
|
||||||
|
<!-- <groupId>org.apache.shardingsphere</groupId>-->
|
||||||
|
<!-- <artifactId>shardingsphere-jdbc-core-spring-boot-starter</artifactId>-->
|
||||||
|
<!-- <version>${shardingsphere-jdbc.version}</version>-->
|
||||||
|
<!-- </dependency>-->
|
||||||
|
|
||||||
|
<!-- Spring Boot 管理和监控 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Redisson 相关 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.redisson</groupId>
|
||||||
|
<artifactId>redisson-spring-boot-starter</artifactId>
|
||||||
|
<version>${redisson.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Aop 相关 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-aop</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- OpenAPI 3 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springdoc</groupId>
|
||||||
|
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
|
||||||
|
<version>${springdoc-openapi.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.mysql</groupId>
|
||||||
|
<artifactId>mysql-connector-j</artifactId>
|
||||||
|
<scope>runtime</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-configuration-processor</artifactId>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-bootstrap</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.lei.shop</groupId>
|
||||||
|
<artifactId>shop-common</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
</project>
|
||||||
|
|
@ -0,0 +1,94 @@
|
||||||
|
package com.lei.shop.config;
|
||||||
|
|
||||||
|
import com.github.benmanes.caffeine.cache.Caffeine;
|
||||||
|
import com.lei.shop.common.constant.CacheConsts;
|
||||||
|
import org.springframework.cache.CacheManager;
|
||||||
|
import org.springframework.cache.caffeine.CaffeineCache;
|
||||||
|
import org.springframework.cache.support.SimpleCacheManager;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.context.annotation.Primary;
|
||||||
|
import org.springframework.data.redis.cache.RedisCacheConfiguration;
|
||||||
|
import org.springframework.data.redis.cache.RedisCacheManager;
|
||||||
|
import org.springframework.data.redis.cache.RedisCacheWriter;
|
||||||
|
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||||
|
|
||||||
|
import java.time.Duration;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 缓存配置类
|
||||||
|
*
|
||||||
|
* @className: CacheConfig
|
||||||
|
* @author: 周
|
||||||
|
* @email:
|
||||||
|
* @create: 2023-06-12 21:35
|
||||||
|
*/
|
||||||
|
@Configuration
|
||||||
|
public class CacheConfig {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Caffeine 缓存管理器
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
@Primary
|
||||||
|
public CacheManager caffeineCacheManager() {
|
||||||
|
SimpleCacheManager cacheManager = new SimpleCacheManager();
|
||||||
|
|
||||||
|
List<CaffeineCache> caches = new ArrayList<>(CacheConsts.CacheEnum.values().length);
|
||||||
|
// 类型推断 var 非常适合 for 循环,JDK 10 引入,JDK 11 改进
|
||||||
|
for (var c : CacheConsts.CacheEnum.values()) {
|
||||||
|
if (c.isLocal()) {
|
||||||
|
Caffeine<Object, Object> caffeine = Caffeine.newBuilder().recordStats()
|
||||||
|
.maximumSize(c.getMaxSize());
|
||||||
|
if (c.getTtl() > 0) {
|
||||||
|
caffeine.expireAfterWrite(Duration.ofSeconds(c.getTtl()));
|
||||||
|
}
|
||||||
|
caches.add(new CaffeineCache(c.getName(), caffeine.build()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cacheManager.setCaches(caches);
|
||||||
|
return cacheManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Redis 缓存管理器
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
public CacheManager redisCacheManager(RedisConnectionFactory connectionFactory) {
|
||||||
|
RedisCacheWriter redisCacheWriter = RedisCacheWriter.nonLockingRedisCacheWriter(
|
||||||
|
connectionFactory);
|
||||||
|
|
||||||
|
RedisCacheConfiguration defaultCacheConfig = RedisCacheConfiguration.defaultCacheConfig()
|
||||||
|
.disableCachingNullValues().prefixCacheNameWith(CacheConsts.REDIS_CACHE_PREFIX);
|
||||||
|
|
||||||
|
Map<String, RedisCacheConfiguration> cacheMap = new LinkedHashMap<>(
|
||||||
|
CacheConsts.CacheEnum.values().length);
|
||||||
|
// 类型推断 var 非常适合 for 循环,JDK 10 引入,JDK 11 改进
|
||||||
|
for (var c : CacheConsts.CacheEnum.values()) {
|
||||||
|
if (c.isRemote()) {
|
||||||
|
if (c.getTtl() > 0) {
|
||||||
|
cacheMap.put(c.getName(),
|
||||||
|
RedisCacheConfiguration.defaultCacheConfig().disableCachingNullValues()
|
||||||
|
.prefixCacheNameWith(CacheConsts.REDIS_CACHE_PREFIX)
|
||||||
|
.entryTtl(Duration.ofSeconds(c.getTtl())));
|
||||||
|
} else {
|
||||||
|
cacheMap.put(c.getName(),
|
||||||
|
RedisCacheConfiguration.defaultCacheConfig().disableCachingNullValues()
|
||||||
|
.prefixCacheNameWith(CacheConsts.REDIS_CACHE_PREFIX));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
RedisCacheManager redisCacheManager = new RedisCacheManager(redisCacheWriter,
|
||||||
|
defaultCacheConfig, cacheMap);
|
||||||
|
redisCacheManager.setTransactionAware(true);
|
||||||
|
redisCacheManager.initializeCaches();
|
||||||
|
return redisCacheManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,48 @@
|
||||||
|
package com.lei.shop.config;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.DbType;
|
||||||
|
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
|
||||||
|
import org.apache.ibatis.reflection.MetaObject;
|
||||||
|
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||||
|
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @className: MybatisPlusConfig
|
||||||
|
* @author: 周
|
||||||
|
*
|
||||||
|
* @create: 2023-06-12 21:38
|
||||||
|
*/
|
||||||
|
@Configuration
|
||||||
|
@AutoConfigureAfter(DataSourceAutoConfiguration.class)
|
||||||
|
@EnableTransactionManagement
|
||||||
|
public class MybatisPlusConfig implements MetaObjectHandler {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页插件
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
public MybatisPlusInterceptor mybatisPlusInterceptor() {
|
||||||
|
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
|
||||||
|
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
|
||||||
|
return interceptor;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void insertFill(MetaObject metaObject) {
|
||||||
|
setFieldValByName("createDate", new Date(), metaObject);
|
||||||
|
setFieldValByName("updateDate", new Date(), metaObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateFill(MetaObject metaObject) {
|
||||||
|
setFieldValByName("updateDate", new Date(), metaObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
package com.lei.shop.config;
|
||||||
|
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @className: XssProperties
|
||||||
|
* @author: 周
|
||||||
|
*
|
||||||
|
* @create: 2023-06-12 21:33
|
||||||
|
*/
|
||||||
|
@ConfigurationProperties(prefix = "lei.xss")
|
||||||
|
public record XssProperties(Boolean enabled, List<String> excludes) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,24 @@
|
||||||
|
package com.lei.shop.config.annotation;
|
||||||
|
|
||||||
|
import java.lang.annotation.Documented;
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分布式锁-Key 注解
|
||||||
|
* @className: Key
|
||||||
|
* @author: 周
|
||||||
|
* @email:
|
||||||
|
* @create: 2023-06-12 21:18
|
||||||
|
*/
|
||||||
|
@Documented
|
||||||
|
@Retention(RUNTIME)
|
||||||
|
@Target({ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER})
|
||||||
|
public @interface Key {
|
||||||
|
|
||||||
|
|
||||||
|
String expr() default "";
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
package com.lei.shop.config.annotation;
|
||||||
|
|
||||||
|
import com.lei.shop.common.constant.ErrorCodeEnum;
|
||||||
|
|
||||||
|
import java.lang.annotation.Documented;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
import static java.lang.annotation.ElementType.METHOD;
|
||||||
|
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分布式锁 注解
|
||||||
|
* @className: Lock
|
||||||
|
* @author: 周
|
||||||
|
*
|
||||||
|
* @create: 2023-06-12 21:19
|
||||||
|
*/
|
||||||
|
@Documented
|
||||||
|
@Retention(RUNTIME)
|
||||||
|
@Target(METHOD)
|
||||||
|
public @interface Lock {
|
||||||
|
|
||||||
|
String prefix();
|
||||||
|
|
||||||
|
boolean isWait() default false;
|
||||||
|
|
||||||
|
long waitTime() default 3L;
|
||||||
|
|
||||||
|
ErrorCodeEnum failCode() default ErrorCodeEnum.OK;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,87 @@
|
||||||
|
package com.lei.shop.config.aspect;
|
||||||
|
|
||||||
|
import com.lei.shop.config.annotation.Key;
|
||||||
|
import com.lei.shop.config.annotation.Lock;
|
||||||
|
import com.lei.shop.config.exception.BusinessException;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.SneakyThrows;
|
||||||
|
import org.aspectj.lang.ProceedingJoinPoint;
|
||||||
|
import org.aspectj.lang.annotation.Around;
|
||||||
|
import org.aspectj.lang.annotation.Aspect;
|
||||||
|
import org.aspectj.lang.reflect.MethodSignature;
|
||||||
|
import org.redisson.api.RLock;
|
||||||
|
import org.redisson.api.RedissonClient;
|
||||||
|
import org.springframework.expression.Expression;
|
||||||
|
import org.springframework.expression.ExpressionParser;
|
||||||
|
import org.springframework.expression.common.TemplateParserContext;
|
||||||
|
import org.springframework.expression.spel.standard.SpelExpressionParser;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.lang.reflect.Parameter;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分布式锁 切面
|
||||||
|
* @className: LockAspect
|
||||||
|
* @author: 周
|
||||||
|
*
|
||||||
|
* @create: 2023-06-12 21:21
|
||||||
|
*/
|
||||||
|
@Aspect
|
||||||
|
@Component
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class LockAspect {
|
||||||
|
|
||||||
|
|
||||||
|
private final RedissonClient redissonClient;
|
||||||
|
|
||||||
|
private static final String KEY_PREFIX = "Lock";
|
||||||
|
|
||||||
|
private static final String KEY_SEPARATOR = "::";
|
||||||
|
|
||||||
|
@Around(value = "@annotation(com.lei.shop.config.annotation.Lock)")
|
||||||
|
@SneakyThrows
|
||||||
|
public Object doAround(ProceedingJoinPoint joinPoint) {
|
||||||
|
MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();
|
||||||
|
Method targetMethod = methodSignature.getMethod();
|
||||||
|
Lock lock = targetMethod.getAnnotation(Lock.class);
|
||||||
|
String lockKey = KEY_PREFIX + buildLockKey(lock.prefix(), targetMethod,
|
||||||
|
joinPoint.getArgs());
|
||||||
|
RLock rLock = redissonClient.getLock(lockKey);
|
||||||
|
if (lock.isWait() ? rLock.tryLock(lock.waitTime(), TimeUnit.SECONDS) : rLock.tryLock()) {
|
||||||
|
try {
|
||||||
|
return joinPoint.proceed();
|
||||||
|
} finally {
|
||||||
|
rLock.unlock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new BusinessException(lock.failCode());
|
||||||
|
}
|
||||||
|
|
||||||
|
private String buildLockKey(String prefix, Method method, Object[] args) {
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
if (StringUtils.hasText(prefix)) {
|
||||||
|
builder.append(KEY_SEPARATOR).append(prefix);
|
||||||
|
}
|
||||||
|
Parameter[] parameters = method.getParameters();
|
||||||
|
for (int i = 0; i < parameters.length; i++) {
|
||||||
|
builder.append(KEY_SEPARATOR);
|
||||||
|
if (parameters[i].isAnnotationPresent(Key.class)) {
|
||||||
|
com.lei.shop.config.annotation.Key key = parameters[i].getAnnotation(Key.class);
|
||||||
|
builder.append(parseKeyExpr(key.expr(), args[i]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return builder.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private String parseKeyExpr(String expr, Object arg) {
|
||||||
|
if (!StringUtils.hasText(expr)) {
|
||||||
|
return arg.toString();
|
||||||
|
}
|
||||||
|
ExpressionParser parser = new SpelExpressionParser();
|
||||||
|
Expression expression = parser.parseExpression(expr, new TemplateParserContext());
|
||||||
|
return expression.getValue(arg, String.class);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,53 @@
|
||||||
|
package com.lei.shop.config.base;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
|
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @className: LeiBaseEntity
|
||||||
|
* @author: 周
|
||||||
|
* @email:
|
||||||
|
* @create: 2023-06-13 00:48
|
||||||
|
*/
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Data
|
||||||
|
@Schema(description = "公共字端")
|
||||||
|
public class
|
||||||
|
LeiBaseEntity<T extends Model<T>> extends Model<T> {
|
||||||
|
@Schema(description = "数据ID")
|
||||||
|
@TableId(value = "id", type = IdType.ASSIGN_UUID)
|
||||||
|
protected String id;
|
||||||
|
|
||||||
|
|
||||||
|
@Schema(description = "创建时间: 搜索参数时为开始时间")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
// @JSONField(serializeUsing= SerializeFeatureDate.class)
|
||||||
|
@TableField(value = "create_date", fill = FieldFill.INSERT)
|
||||||
|
protected Date createDate;
|
||||||
|
|
||||||
|
|
||||||
|
@Schema(description = "修改时间: 搜索参数时为结束时间")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
// @JSONField(serializeUsing = SerializeFeatureDate.class)
|
||||||
|
@TableField(value = "update_date", fill = FieldFill.INSERT_UPDATE)
|
||||||
|
protected Date updateDate;
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
@TableLogic
|
||||||
|
@TableField(value = "deleted")
|
||||||
|
protected Boolean deleted = false;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Serializable pkVal() {
|
||||||
|
return this.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,80 @@
|
||||||
|
package com.lei.shop.config.base;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @className: LeiPage
|
||||||
|
* @author: 周
|
||||||
|
* @email:
|
||||||
|
* @create: 2023-06-13 23:06
|
||||||
|
*/
|
||||||
|
public class LeiPage<T> extends Page<T> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询参数
|
||||||
|
*/
|
||||||
|
private Map<String, Object> param = new HashMap<>();
|
||||||
|
|
||||||
|
private T search;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param page 页码
|
||||||
|
* @param pageSize 分页大小
|
||||||
|
*/
|
||||||
|
public LeiPage(Integer page, Integer pageSize) {
|
||||||
|
super.setCurrent(page);
|
||||||
|
super.setSize(pageSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param page 页码
|
||||||
|
* @param pageSize 分页大小
|
||||||
|
* @param param 查询参数
|
||||||
|
*/
|
||||||
|
public LeiPage(Integer page, Integer pageSize, Map<String, Object> param) {
|
||||||
|
super.setCurrent(page);
|
||||||
|
super.setSize(pageSize);
|
||||||
|
this.param = param;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LeiPage() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setParam(Map<String, Object> param) {
|
||||||
|
this.param = param;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, Object> getParam() {
|
||||||
|
return param;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IPage<T> getIPage(List<T> data) {
|
||||||
|
IPage<T> infoPage = new Page<>(getCurrent(), getSize());
|
||||||
|
infoPage.setTotal(getTotal());
|
||||||
|
infoPage.setRecords(data);
|
||||||
|
return infoPage;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getPages() {
|
||||||
|
return super.getPages();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getSize() {
|
||||||
|
return super.getSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSearch(T search) {
|
||||||
|
this.search = search;
|
||||||
|
}
|
||||||
|
|
||||||
|
public T getSearch() {
|
||||||
|
return search;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,36 @@
|
||||||
|
package com.lei.shop.config.exception;
|
||||||
|
|
||||||
|
import com.lei.shop.common.constant.ErrorCodeEnum;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @className: BusinessException
|
||||||
|
* @author: 周
|
||||||
|
*
|
||||||
|
* @create: 2023-06-12 21:22
|
||||||
|
*/
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Data
|
||||||
|
public class BusinessException extends RuntimeException {
|
||||||
|
|
||||||
|
// private final ErrorCodeEnum errorCodeEnum;
|
||||||
|
|
||||||
|
private String code;
|
||||||
|
|
||||||
|
private String message;
|
||||||
|
|
||||||
|
public BusinessException(ErrorCodeEnum errorCodeEnum) {
|
||||||
|
// 不调用父类 Throwable的fillInStackTrace() 方法生成栈追踪信息,提高应用性能
|
||||||
|
// 构造器之间的调用必须在第一行
|
||||||
|
super(errorCodeEnum.getMessage(), null, false, false);
|
||||||
|
this.code = errorCodeEnum.getCode();
|
||||||
|
this.message = errorCodeEnum.getMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
public BusinessException(ErrorCodeEnum errorCodeEnum, String message) {
|
||||||
|
super(message, null, false, false);
|
||||||
|
this.code = errorCodeEnum.getCode();
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,57 @@
|
||||||
|
package com.lei.shop.config.exception;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSON;
|
||||||
|
import com.alibaba.nacos.common.utils.CollectionUtils;
|
||||||
|
import com.lei.shop.common.constant.ErrorCodeEnum;
|
||||||
|
import com.lei.shop.common.resp.RestResp;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.validation.BindException;
|
||||||
|
import org.springframework.validation.ObjectError;
|
||||||
|
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||||
|
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @className: CommonExceptionHandler
|
||||||
|
* @author: 周
|
||||||
|
*
|
||||||
|
* @create: 2023-06-12 21:30
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@RestControllerAdvice
|
||||||
|
public class CommonExceptionHandler {
|
||||||
|
/**
|
||||||
|
* 处理数据校验异常
|
||||||
|
*/
|
||||||
|
@ExceptionHandler(BindException.class)
|
||||||
|
public RestResp<Void> handlerBindException(BindException e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
List<String> errorMessageList = new ArrayList<>();
|
||||||
|
if (CollectionUtils.isNotEmpty(e.getAllErrors())) {
|
||||||
|
for (ObjectError error : e.getAllErrors()) {
|
||||||
|
errorMessageList.add(error.getDefaultMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return RestResp.fail(ErrorCodeEnum.USER_REQUEST_PARAM_ERROR, JSON.toJSONString(errorMessageList));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理业务异常
|
||||||
|
*/
|
||||||
|
@ExceptionHandler(BusinessException.class)
|
||||||
|
public RestResp<Void> handlerBusinessException(BusinessException e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
return RestResp.fail(e.getCode(), e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理系统异常
|
||||||
|
*/
|
||||||
|
@ExceptionHandler(Exception.class)
|
||||||
|
public RestResp<Void> handlerException(Exception e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
return RestResp.error();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,70 @@
|
||||||
|
package com.lei.shop.config.filter;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||||
|
import com.lei.shop.config.XssProperties;
|
||||||
|
import com.lei.shop.config.wrapper.XssHttpServletRequestWrapper;
|
||||||
|
import jakarta.servlet.*;
|
||||||
|
import jakarta.servlet.annotation.WebFilter;
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||||
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @className: XssFilter
|
||||||
|
* @author: 周
|
||||||
|
* @email:
|
||||||
|
* @create: 2023-06-12 21:32
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
@ConditionalOnProperty(value = "lei.xss.enabled", havingValue = "true")
|
||||||
|
@WebFilter(urlPatterns = "/*", filterName = "xssFilter")
|
||||||
|
@EnableConfigurationProperties(value = {XssProperties.class})
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class XssFilter implements Filter {
|
||||||
|
|
||||||
|
private final XssProperties xssProperties;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init(FilterConfig filterConfig) throws ServletException {
|
||||||
|
Filter.super.init(filterConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse,
|
||||||
|
FilterChain filterChain) throws IOException, ServletException {
|
||||||
|
HttpServletRequest req = (HttpServletRequest) servletRequest;
|
||||||
|
if (handleExcludeUrl(req)) {
|
||||||
|
filterChain.doFilter(servletRequest, servletResponse);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
XssHttpServletRequestWrapper xssRequest = new XssHttpServletRequestWrapper(
|
||||||
|
(HttpServletRequest) servletRequest);
|
||||||
|
filterChain.doFilter(xssRequest, servletResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean handleExcludeUrl(HttpServletRequest request) {
|
||||||
|
if (CollectionUtils.isEmpty(xssProperties.excludes())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
String url = request.getServletPath();
|
||||||
|
for (String pattern : xssProperties.excludes()) {
|
||||||
|
Pattern p = Pattern.compile("^" + pattern);
|
||||||
|
Matcher m = p.matcher(url);
|
||||||
|
if (m.find()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void destroy() {
|
||||||
|
Filter.super.destroy();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,61 @@
|
||||||
|
package com.lei.shop.config.handler;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.lei.shop.common.resp.RestResp;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.core.MethodParameter;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
|
import org.springframework.http.converter.HttpMessageConverter;
|
||||||
|
import org.springframework.http.server.ServerHttpRequest;
|
||||||
|
import org.springframework.http.server.ServerHttpResponse;
|
||||||
|
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||||
|
import org.springframework.web.context.request.RequestContextHolder;
|
||||||
|
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||||
|
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
||||||
|
import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @className: AppReturnHandler
|
||||||
|
* @author: 周
|
||||||
|
*
|
||||||
|
* @create: 2023-06-12 23:27
|
||||||
|
*/
|
||||||
|
@EnableWebMvc
|
||||||
|
@Configuration
|
||||||
|
public class AppReturnHandler {
|
||||||
|
|
||||||
|
|
||||||
|
//只处理API接口包异常
|
||||||
|
@RestControllerAdvice(basePackages = {
|
||||||
|
"com.lei",
|
||||||
|
})
|
||||||
|
static class ResultResponseAdvice implements ResponseBodyAdvice<Object> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean supports(MethodParameter methodParameter, Class<? extends HttpMessageConverter<?>> aClass) {
|
||||||
|
return (((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()).getRequestURI().contains("/api/");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object beforeBodyWrite(Object body,
|
||||||
|
MethodParameter methodParameter,
|
||||||
|
MediaType mediaType,
|
||||||
|
Class<? extends HttpMessageConverter<?>> aClass,
|
||||||
|
ServerHttpRequest serverHttpRequest,
|
||||||
|
ServerHttpResponse serverHttpResponse) {
|
||||||
|
HttpServletResponse response = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getResponse();
|
||||||
|
response.setContentType("application/json;charset=utf-8");
|
||||||
|
//响应数据加密配置
|
||||||
|
if (body instanceof RestResp) {
|
||||||
|
return (RestResp) body;
|
||||||
|
}
|
||||||
|
if (body == null) {
|
||||||
|
return RestResp.ok();
|
||||||
|
} else {
|
||||||
|
return RestResp.ok(body);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,47 @@
|
||||||
|
package com.lei.shop.config.interceptor;
|
||||||
|
|
||||||
|
import com.lei.shop.common.auth.JwtUtils;
|
||||||
|
import com.lei.shop.common.auth.UserHolder;
|
||||||
|
import com.lei.shop.common.constant.SystemConfigConsts;
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
import org.springframework.web.servlet.HandlerInterceptor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @className: TokenParseInterceptor
|
||||||
|
* @author: 周
|
||||||
|
*
|
||||||
|
* @create: 2023-06-12 21:34
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class TokenParseInterceptor implements HandlerInterceptor {
|
||||||
|
|
||||||
|
@SuppressWarnings("NullableProblems")
|
||||||
|
@Override
|
||||||
|
public boolean preHandle(HttpServletRequest request, HttpServletResponse response,
|
||||||
|
Object handler) throws Exception {
|
||||||
|
// 获取登录 JWT
|
||||||
|
String token = request.getHeader(SystemConfigConsts.HTTP_AUTH_HEADER_NAME);
|
||||||
|
if (StringUtils.hasText(token)) {
|
||||||
|
// 解析 token 并保存
|
||||||
|
UserHolder.setUserId(JwtUtils.parseToken(token, SystemConfigConsts.NOVEL_FRONT_KEY));
|
||||||
|
}
|
||||||
|
return HandlerInterceptor.super.preHandle(request, response, handler);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DispatcherServlet 完全处理完请求后调用,出现异常照常调用
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("NullableProblems")
|
||||||
|
@Override
|
||||||
|
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex)
|
||||||
|
throws Exception {
|
||||||
|
// 清理当前线程保存的用户数据
|
||||||
|
UserHolder.clear();
|
||||||
|
HandlerInterceptor.super.afterCompletion(request, response, handler, ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,58 @@
|
||||||
|
package com.lei.shop.config;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.models.OpenAPI;
|
||||||
|
import io.swagger.v3.oas.models.info.Contact;
|
||||||
|
import io.swagger.v3.oas.models.info.Info;
|
||||||
|
import io.swagger.v3.oas.models.info.License;
|
||||||
|
import org.apache.commons.lang3.RandomUtils;
|
||||||
|
import org.springdoc.core.customizers.GlobalOpenApiCustomizer;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @className: OpenApiConfig
|
||||||
|
* @author: 周
|
||||||
|
* @email:
|
||||||
|
* @create: 2023-06-12 21:38
|
||||||
|
*/
|
||||||
|
@Configuration
|
||||||
|
public class knife4jConfig {
|
||||||
|
/**
|
||||||
|
* 根据@Tag 上的排序,写入x-order
|
||||||
|
*
|
||||||
|
* @return the global open api customizer
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
public GlobalOpenApiCustomizer orderGlobalOpenApiCustomizer() {
|
||||||
|
return openApi -> {
|
||||||
|
if (openApi.getTags()!=null){
|
||||||
|
openApi.getTags().forEach(tag -> {
|
||||||
|
Map<String,Object> map=new HashMap<>();
|
||||||
|
map.put("x-order", RandomUtils.nextInt(0,100));
|
||||||
|
tag.setExtensions(map);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if(openApi.getPaths()!=null){
|
||||||
|
openApi.addExtension("x-test123","333");
|
||||||
|
openApi.getPaths().addExtension("x-abb",RandomUtils.nextInt(1,100));
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public OpenAPI customOpenAPI() {
|
||||||
|
return new OpenAPI()
|
||||||
|
.info(new Info()
|
||||||
|
.title("宁波瑶瑶电商项目接口文档")
|
||||||
|
.version("1.0")
|
||||||
|
.contact(new Contact().name("小明"))
|
||||||
|
.description( "宁波瑶瑶电商项目")
|
||||||
|
.termsOfService("https://xiaoming.com")
|
||||||
|
.license(new License().name("小明")
|
||||||
|
.url("https://xiaoming.com")));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,44 @@
|
||||||
|
package com.lei.shop.config.wrapper;
|
||||||
|
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import jakarta.servlet.http.HttpServletRequestWrapper;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @className: XssHttpServletRequestWrapper
|
||||||
|
* @author: 周
|
||||||
|
* @email:
|
||||||
|
* @create: 2023-06-12 21:33
|
||||||
|
*/
|
||||||
|
public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper {
|
||||||
|
|
||||||
|
private static final Map<String, String> REPLACE_RULE = new HashMap<>();
|
||||||
|
|
||||||
|
static {
|
||||||
|
REPLACE_RULE.put("<", "<");
|
||||||
|
REPLACE_RULE.put(">", ">");
|
||||||
|
}
|
||||||
|
|
||||||
|
public XssHttpServletRequestWrapper(HttpServletRequest request) {
|
||||||
|
super(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String[] getParameterValues(String name) {
|
||||||
|
String[] values = super.getParameterValues(name);
|
||||||
|
if (values != null) {
|
||||||
|
int length = values.length;
|
||||||
|
String[] escapeValues = new String[length];
|
||||||
|
for (int i = 0; i < length; i++) {
|
||||||
|
escapeValues[i] = values[i];
|
||||||
|
int index = i;
|
||||||
|
REPLACE_RULE.forEach(
|
||||||
|
(k, v) -> escapeValues[index] = escapeValues[index].replaceAll(k, v));
|
||||||
|
}
|
||||||
|
return escapeValues;
|
||||||
|
}
|
||||||
|
return new String[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,38 @@
|
||||||
|
#--------------------- Spring Cloud 配置-------------------
|
||||||
|
spring:
|
||||||
|
cloud:
|
||||||
|
nacos:
|
||||||
|
discovery:
|
||||||
|
# server-addr: 192.168.1.100:8848
|
||||||
|
server-addr: 127.0.0.1:8848
|
||||||
|
namespace: shop-cloud
|
||||||
|
openfeign:
|
||||||
|
lazy-attributes-resolution: true
|
||||||
|
|
||||||
|
feign:
|
||||||
|
sentinel:
|
||||||
|
enabled: true
|
||||||
|
|
||||||
|
--- #--------------------------通用配置-------------------------
|
||||||
|
spring:
|
||||||
|
jackson:
|
||||||
|
generator:
|
||||||
|
write-numbers-as-strings: true
|
||||||
|
|
||||||
|
|
||||||
|
--- #---------------------自定义配置----------------------------
|
||||||
|
lei:
|
||||||
|
# XSS 过滤配置
|
||||||
|
xss:
|
||||||
|
# 过滤开关
|
||||||
|
enabled: true
|
||||||
|
# 排除链接
|
||||||
|
excludes:
|
||||||
|
- /system/notice/*
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
spring:
|
||||||
|
cloud:
|
||||||
|
nacos:
|
||||||
|
config:
|
||||||
|
# server-addr: 192.168.10.110:8848
|
||||||
|
server-addr: 127.0.0.1:8848
|
||||||
|
namespace: shop-cloud
|
||||||
|
file-extension: yml
|
||||||
|
extension-configs[0]:
|
||||||
|
data-id: shop-mysql.yml
|
||||||
|
refresh: true
|
||||||
|
extension-configs[1]:
|
||||||
|
data-id: shop-redis.yml
|
||||||
|
refresh: true
|
||||||
|
extension-configs[2]:
|
||||||
|
data-id: swagger-ui.yml
|
||||||
|
refresh: true
|
||||||
|
extension-configs[3]:
|
||||||
|
data-id: management.yml
|
||||||
|
refresh: true
|
||||||
|
extension-configs[4]:
|
||||||
|
data-id: mybatis-plus.yml
|
||||||
|
refresh: true
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,53 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<parent>
|
||||||
|
<artifactId>shop-core</artifactId>
|
||||||
|
<groupId>com.lei.shop</groupId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<artifactId>shop-pay</artifactId>
|
||||||
|
<description>支付模块</description>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<maven.compiler.source>17</maven.compiler.source>
|
||||||
|
<maven.compiler.target>17</maven.compiler.target>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.hutool</groupId>
|
||||||
|
<artifactId>hutool-all</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.httpcomponents</groupId>
|
||||||
|
<artifactId>httpmime</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
|
<exclusions>
|
||||||
|
<!-- Exclude the Tomcat dependency -->
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-tomcat</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.fastjson2</groupId>
|
||||||
|
<artifactId>fastjson2</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
||||||
|
|
@ -0,0 +1,308 @@
|
||||||
|
package com.lei.shop.pay.processor;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.URLUtil;
|
||||||
|
import cn.hutool.crypto.digest.MD5;
|
||||||
|
import com.alibaba.fastjson2.JSON;
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import com.lei.shop.pay.properties.SqbPayProperties;
|
||||||
|
import com.lei.shop.pay.utils.HttpUtil;
|
||||||
|
import com.lei.shop.pay.utils.MD5Util;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.net.URLEncoder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @className: SmsSendHandler
|
||||||
|
* @author: 周
|
||||||
|
*
|
||||||
|
* @create: 2023-06-15 16:57
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
public class SqbPaySendHandler {
|
||||||
|
|
||||||
|
|
||||||
|
public static final String API_DOMAIN = "https://vsi-api.shouqianba.com";
|
||||||
|
|
||||||
|
public static final String API_GETWAY = "https://qr.shouqianba.com/gateway?";
|
||||||
|
|
||||||
|
private static final String IS_OK = "200";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 计算字符串的MD5值
|
||||||
|
*
|
||||||
|
* @param signStr:签名字符串
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private static String getSign(String signStr) {
|
||||||
|
try {
|
||||||
|
return MD5Util.encryptMd5(signStr).toUpperCase();
|
||||||
|
} catch (UnsupportedEncodingException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 终端激活
|
||||||
|
*
|
||||||
|
* @param code:激活码
|
||||||
|
* @return {terminal_sn:"$终端号",terminal_key:"$终端密钥"}
|
||||||
|
*/
|
||||||
|
public static JSONObject activate(SqbPayProperties properties, String code) {
|
||||||
|
String url = API_DOMAIN + "/terminal/activate";
|
||||||
|
JSONObject params = new JSONObject();
|
||||||
|
try {
|
||||||
|
params.put("app_id", properties.getAppId());
|
||||||
|
params.put("code", code);
|
||||||
|
params.put("device_id", "LeiLEI0002LEI11"); //客户方收银终端序列号,需保证同一app_id下唯一,必填。为方便识别,建议格式为“品牌名+门店编号+‘POS’+POS编号“
|
||||||
|
params.put("client_sn", "LEI0211"); //客户方终端编号,一般客户方或系统给收银终端的编号,必填
|
||||||
|
params.put("name", "1号款台"); //客户方终端名称,必填
|
||||||
|
params.put("os_info", "Mac OS");
|
||||||
|
params.put("sdk_version", "Java SDK v1.0"); //SDK版本
|
||||||
|
|
||||||
|
String sign = getSign(params.toString() + properties.getVendorKey());
|
||||||
|
String result = HttpUtil.httpPost(url, params.toString(), sign, properties.getVendorSn());
|
||||||
|
JSONObject retObj = JSON.parseObject(result);
|
||||||
|
String resCode = retObj.get("result_code").toString();
|
||||||
|
if (!IS_OK.equals(resCode)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
String responseStr = retObj.get("biz_response").toString();
|
||||||
|
JSONObject terminal = JSON.parseObject(responseStr);
|
||||||
|
if (terminal.get("terminal_sn") == null || terminal.get("terminal_key") == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return terminal;
|
||||||
|
} catch (Exception e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 终端签到
|
||||||
|
*
|
||||||
|
* @param terminalSn:终端号
|
||||||
|
* @param terminalKey:终端密钥
|
||||||
|
* @param deviceId 终端ID
|
||||||
|
* @return {terminal_sn:"$终端号",terminal_key:"$终端密钥"}
|
||||||
|
*/
|
||||||
|
public static JSONObject checkin(String terminalSn, String terminalKey, String deviceId) {
|
||||||
|
String url = API_DOMAIN + "/terminal/checkin";
|
||||||
|
JSONObject params = new JSONObject();
|
||||||
|
try {
|
||||||
|
params.put("terminal_sn", terminalSn);
|
||||||
|
params.put("device_id", deviceId);
|
||||||
|
params.put("os_info", "Mac OS");
|
||||||
|
params.put("sdk_version", "Java SDK v1.0");
|
||||||
|
String sign = getSign(params.toString() + terminalKey);
|
||||||
|
|
||||||
|
System.out.println("“signBody:"+params.toString()+terminalKey);
|
||||||
|
|
||||||
|
String result = HttpUtil.httpPost(url, params.toString(), sign, terminalSn);
|
||||||
|
JSONObject retObj = JSON.parseObject(result);
|
||||||
|
|
||||||
|
System.out.println("sign:" + sign);
|
||||||
|
System.out.printf("result:" + result);
|
||||||
|
|
||||||
|
String resCode = retObj.get("result_code").toString();
|
||||||
|
if (!IS_OK.equals(resCode)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
String responseStr = retObj.get("biz_response").toString();
|
||||||
|
JSONObject terminal = JSON.parseObject(responseStr);
|
||||||
|
if (terminal.get("terminal_sn") == null || terminal.get("terminal_key") == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return terminal;
|
||||||
|
} catch (Exception e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 退款
|
||||||
|
*
|
||||||
|
* @param terminal_sn:终端号
|
||||||
|
* @param terminal_key:终端密钥
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String refund(String terminal_sn, String terminal_key) {
|
||||||
|
String url = API_DOMAIN + "/upay/v2/refund";
|
||||||
|
JSONObject params = new JSONObject();
|
||||||
|
try {
|
||||||
|
params.put("terminal_sn", terminal_sn); //收钱吧终端ID
|
||||||
|
params.put("sn", "7892259488292938"); //收钱吧系统内部唯一订单号
|
||||||
|
params.put("client_sn", "18348290098298292838"); //商户系统订单号,必须在商户系统内唯一;且长度不超过64字节
|
||||||
|
params.put("refund_amount", "1000"); //退款金额
|
||||||
|
params.put("refund_request_no", "23030349"); //商户退款所需序列号,表明是第几次退款
|
||||||
|
params.put("operator", "kay"); //门店操作员
|
||||||
|
|
||||||
|
String sign = getSign(params.toString() + terminal_key);
|
||||||
|
String result = HttpUtil.httpPost(url, params.toString(), sign, terminal_sn);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
} catch (Exception e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预下单
|
||||||
|
*
|
||||||
|
* @param json:终端号
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String precreate(JSONObject json) {
|
||||||
|
String url = API_DOMAIN + "/upay/v2/precreate";
|
||||||
|
JSONObject params = new JSONObject();
|
||||||
|
try {
|
||||||
|
params.put("terminal_sn", json.getString("terminal_sn"));
|
||||||
|
params.put("client_sn", json.getString("client_sn"));
|
||||||
|
params.put("total_amount", json.getString("total_amount"));
|
||||||
|
params.put("payway", "3");
|
||||||
|
params.put("subject", json.getString("subject"));
|
||||||
|
params.put("operator", "Obama");
|
||||||
|
params.put("notify_url", json.getString("notify_url"));
|
||||||
|
|
||||||
|
String sign = getSign(params.toString() + json.getString("terminalKey"));
|
||||||
|
return HttpUtil.httpPost(url, params.toString(), sign, json.getString("terminal_sn"));
|
||||||
|
} catch (Exception e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String query(JSONObject jsonObject) {
|
||||||
|
String url = API_DOMAIN + "/upay/v2/query";
|
||||||
|
JSONObject params = new JSONObject();
|
||||||
|
try {
|
||||||
|
params.put("terminal_sn", jsonObject.getString("terminal_sn")); //终端号
|
||||||
|
params.put("client_sn", jsonObject.getString("client_sn")); //商户系统订单号,必须在商户系统内唯一;且长度不超过64字节
|
||||||
|
|
||||||
|
String sign = getSign(params.toString() + jsonObject.getString("terminalKey"));
|
||||||
|
String result = HttpUtil.httpPost(url, params.toString(), sign, jsonObject.getString("terminal_sn"));
|
||||||
|
|
||||||
|
return result;
|
||||||
|
} catch (Exception e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getWapUrl(JSONObject json) {
|
||||||
|
//a、b、c、d、e、f、g、h、i、j、k、l、m、n、o、p、q、r、s、t、u、v、w、x、y、z
|
||||||
|
|
||||||
|
|
||||||
|
// JSONObject params = new JSONObject();
|
||||||
|
// params.put("client_sn", json.getString("client_sn"));
|
||||||
|
// params.put("operator", "Obama");
|
||||||
|
// params.put("notify_url", json.getString("notify_url"));
|
||||||
|
// params.put("return_url", json.getString("return_url"));
|
||||||
|
// params.put("subject", json.getString("subject"));
|
||||||
|
// params.put("terminal_sn", json.getString("terminal_sn"));
|
||||||
|
// params.put("total_amount", json.getString("total_amount"));
|
||||||
|
// String sign = getSign(params.toString() + json.getString("terminalKey"));
|
||||||
|
|
||||||
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
|
stringBuilder.append("client_sn=").append(json.getString("client_sn"));
|
||||||
|
stringBuilder.append("¬ify_url=").append(json.getString("notify_url"));
|
||||||
|
stringBuilder.append("&operator=").append("Obama");
|
||||||
|
stringBuilder.append("&return_url=").append(json.getString("return_url"));
|
||||||
|
stringBuilder.append("&subject=").append(json.getString("subject"));
|
||||||
|
stringBuilder.append("&terminal_sn=").append(json.getString("terminal_sn"));
|
||||||
|
stringBuilder.append("&total_amount=").append(json.getString("total_amount"));
|
||||||
|
stringBuilder.append("&key=").append(json.getString("terminalKey"));
|
||||||
|
String sign = MD5.create().digestHex(stringBuilder.toString()).toUpperCase();
|
||||||
|
|
||||||
|
//构建支付URl
|
||||||
|
StringBuilder url = new StringBuilder(SqbPaySendHandler.API_GETWAY);
|
||||||
|
|
||||||
|
url.append("client_sn=").append(json.getString("client_sn"));
|
||||||
|
url.append("¬ify_url=").append(URLEncoder.encode(json.getString("notify_url")));
|
||||||
|
url.append("&operator=").append("Obama");
|
||||||
|
url.append("&return_url=").append(URLEncoder.encode(json.getString("return_url")));
|
||||||
|
url.append("&subject=").append(json.getString("subject"));
|
||||||
|
url.append("&terminal_sn=").append(json.getString("terminal_sn"));
|
||||||
|
url.append("&total_amount=").append(json.getString("total_amount"));
|
||||||
|
|
||||||
|
|
||||||
|
url.append("&sign=").append(sign);
|
||||||
|
|
||||||
|
return url.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
|
||||||
|
System.out.println(URLEncoder.encode("https://vsi-api.shouqianba.com"));
|
||||||
|
System.out.println(URLUtil.encode("https://vsi-api.shouqianba.com"));
|
||||||
|
|
||||||
|
// JSONObject terminal = SqbPaySendHandler.checkin("100055540034310036", "a0883ef86bb167c97c8b7516a9e14f83", "LeiLEI0002LEI10"); //签到
|
||||||
|
//
|
||||||
|
// System.out.printf(JSONObject.toJSONString(terminal));
|
||||||
|
|
||||||
|
SqbPayProperties payProperties = new SqbPayProperties();
|
||||||
|
payProperties.setApiDomain("https://vsi-api.shouqianba.com");
|
||||||
|
// payProperties.setVendorSn("91801827");
|
||||||
|
// payProperties.setVendorKey("ca98c01686ec11e921794d49f5c9d6f7");
|
||||||
|
// payProperties.setAppId("2023052400005554");
|
||||||
|
|
||||||
|
payProperties.setVendorSn("91801827");
|
||||||
|
payProperties.setVendorKey("ca98c01686ec11e921794d49f5c9d6f7");
|
||||||
|
payProperties.setAppId("2023052400005554");
|
||||||
|
|
||||||
|
//宁波甬恒瑶瑶智能科技有限公司
|
||||||
|
//商户号:1680006835239
|
||||||
|
//激活码:39502713
|
||||||
|
//密钥:ca98c01686ec11e921794d49f5c9d6f7
|
||||||
|
|
||||||
|
System.out.println("---------1111111---------------");
|
||||||
|
|
||||||
|
//激活
|
||||||
|
JSONObject result = SqbPaySendHandler.activate(payProperties, "80076384");
|
||||||
|
System.out.println(result);
|
||||||
|
|
||||||
|
System.out.println("-----------2222222-------------");
|
||||||
|
|
||||||
|
// //{"terminal_sn":"100055540030638004","terminal_key":"23080665042cc7acc65e60ea13c1cd76","merchant_sn":"18956397746","merchant_name":"半夜鸡叫",
|
||||||
|
// // "store_sn":"00010101001200200046406","store_name":"半夜鸡叫"}
|
||||||
|
|
||||||
|
|
||||||
|
// JSONObject result=new JSONObject();
|
||||||
|
// result.put("terminal_sn","100055540034191815");
|
||||||
|
// result.put("terminal_key","014faf97ce3698d08107040580353ed5");
|
||||||
|
//
|
||||||
|
if (result != null) {
|
||||||
|
String terminalSN = result.getString("terminal_sn");
|
||||||
|
String terminalKey = result.getString("terminal_key");
|
||||||
|
|
||||||
|
JSONObject terminal = SqbPaySendHandler.checkin(terminalSN, terminalKey, "LeiLEI0002LEI10"); //签到
|
||||||
|
|
||||||
|
System.out.println(terminal);
|
||||||
|
// if (terminal != null) {
|
||||||
|
//
|
||||||
|
// System.out.println("-----------------33333-----------------------");
|
||||||
|
// System.out.println(terminal);
|
||||||
|
// /**
|
||||||
|
// * {"result_code":"200","biz_response":{"terminal_sn":"100055540030638004","terminal_key":"59a613b0b1168ef75574fa29a4968a4b","merchant_sn":"","merchant_name":"","store_sn":"","store_name":""}}
|
||||||
|
// */
|
||||||
|
// String new_terminal_sn = terminal.getString("terminal_sn");
|
||||||
|
// String new_terminal_key = terminal.getString("terminal_key");
|
||||||
|
//
|
||||||
|
//// handler.pay(new_terminal_sn, new_terminal_key);
|
||||||
|
//// hp.refund(new_terminal_sn, new_terminal_key);
|
||||||
|
//// hp.query(new_terminal_sn, new_terminal_key);
|
||||||
|
//// hp.cancel(new_terminal_sn, new_terminal_key);
|
||||||
|
//// handler.precreate(new_terminal_sn, new_terminal_key);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,30 @@
|
||||||
|
package com.lei.shop.pay.properties;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @className: SqbPayProperties
|
||||||
|
* @author: 周
|
||||||
|
* @email:
|
||||||
|
* @create: 2023-06-15 16:41
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Component
|
||||||
|
public class SqbPayProperties {
|
||||||
|
|
||||||
|
|
||||||
|
private String vendorSn;
|
||||||
|
private String vendorKey;
|
||||||
|
private String appId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* code
|
||||||
|
*/
|
||||||
|
private String code;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 支付地址
|
||||||
|
*/
|
||||||
|
private String apiDomain = "https://vsi-api.shouqianba.com";
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,140 @@
|
||||||
|
package com.lei.shop.pay.utils;
|
||||||
|
|
||||||
|
import org.apache.http.HttpEntity;
|
||||||
|
import org.apache.http.HttpResponse;
|
||||||
|
import org.apache.http.client.ClientProtocolException;
|
||||||
|
import org.apache.http.client.HttpClient;
|
||||||
|
import org.apache.http.client.methods.HttpGet;
|
||||||
|
import org.apache.http.client.methods.HttpPost;
|
||||||
|
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
|
||||||
|
import org.apache.http.conn.ssl.TrustStrategy;
|
||||||
|
import org.apache.http.entity.StringEntity;
|
||||||
|
import org.apache.http.impl.client.CloseableHttpClient;
|
||||||
|
import org.apache.http.impl.client.HttpClients;
|
||||||
|
import org.apache.http.ssl.SSLContextBuilder;
|
||||||
|
import org.apache.http.util.EntityUtils;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import javax.net.ssl.SSLContext;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.security.KeyManagementException;
|
||||||
|
import java.security.KeyStoreException;
|
||||||
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
import java.security.UnrecoverableKeyException;
|
||||||
|
import java.security.cert.CertificateException;
|
||||||
|
import java.security.cert.X509Certificate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @className: HttpUtil
|
||||||
|
* @author: 周
|
||||||
|
* @email:
|
||||||
|
* @create: 2023-06-15 16:52
|
||||||
|
*/
|
||||||
|
public class HttpUtil {
|
||||||
|
private static Logger log = LoggerFactory.getLogger(HttpUtil.class);
|
||||||
|
|
||||||
|
public static String httpPostWithoutException(String url, String string, String sign, String sn) {
|
||||||
|
String xmlRes = "{}";
|
||||||
|
try {
|
||||||
|
xmlRes = httpPost(url, string, sign, sn);
|
||||||
|
} catch (UnrecoverableKeyException e) {
|
||||||
|
log.error("", e);
|
||||||
|
} catch (NoSuchAlgorithmException e) {
|
||||||
|
log.error("", e);
|
||||||
|
} catch (KeyStoreException e) {
|
||||||
|
log.error("", e);
|
||||||
|
} catch (KeyManagementException e) {
|
||||||
|
log.error("", e);
|
||||||
|
}
|
||||||
|
return xmlRes;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* http POST 请求
|
||||||
|
*
|
||||||
|
* @param url:请求地址
|
||||||
|
* @param body: body实体字符串
|
||||||
|
* @param sign:签名
|
||||||
|
* @param sn: 序列号
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String httpPost(String url, String body, String sign, String sn) throws UnrecoverableKeyException, NoSuchAlgorithmException, KeyStoreException, KeyManagementException {
|
||||||
|
String xmlRes = "{}";
|
||||||
|
HttpClient client = createSSLClientDefault();
|
||||||
|
HttpPost httpost = new HttpPost(url);
|
||||||
|
try {
|
||||||
|
log.debug("Request string: " + body);
|
||||||
|
|
||||||
|
//所有请求的body都需采用UTF-8编码
|
||||||
|
StringEntity entity = new StringEntity(body, "UTF-8");//
|
||||||
|
entity.setContentType("application/json");
|
||||||
|
httpost.setEntity(entity);
|
||||||
|
|
||||||
|
//支付平台所有的API仅支持JSON格式的请求调用,HTTP请求头Content-Type设为application/json
|
||||||
|
httpost.addHeader("Content-Type", "application/json");
|
||||||
|
|
||||||
|
//支付平台所有的API调用都需要签名验证,签名首部: Authorization: sn + " " + sign
|
||||||
|
httpost.addHeader("Authorization", sn + " " + sign);
|
||||||
|
HttpResponse response = client.execute(httpost);
|
||||||
|
|
||||||
|
//所有响应也采用UTF-8编码
|
||||||
|
xmlRes = EntityUtils.toString(response.getEntity(), "UTF-8");
|
||||||
|
log.debug("Response string: " + xmlRes);
|
||||||
|
} catch (ClientProtocolException e) {
|
||||||
|
log.error("", e);
|
||||||
|
} catch (IOException e) {
|
||||||
|
log.error("", e);
|
||||||
|
}
|
||||||
|
return xmlRes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CloseableHttpClient createSSLClientDefault() {
|
||||||
|
try {
|
||||||
|
SSLContext sslContext = new SSLContextBuilder().loadTrustMaterial(null, new TrustStrategy() {
|
||||||
|
//信任所有
|
||||||
|
public boolean isTrusted(X509Certificate[] chain,
|
||||||
|
String authType) throws CertificateException {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}).build();
|
||||||
|
SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslContext);
|
||||||
|
return HttpClients.custom().setSSLSocketFactory(sslsf).build();
|
||||||
|
} catch (KeyManagementException e) {
|
||||||
|
log.error("", e);
|
||||||
|
} catch (NoSuchAlgorithmException e) {
|
||||||
|
log.error("", e);
|
||||||
|
} catch (KeyStoreException e) {
|
||||||
|
log.error("", e);
|
||||||
|
}
|
||||||
|
return HttpClients.createDefault();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String doGet(String url, String parameter) {
|
||||||
|
String uriAPI = url + "?" + parameter; //"http://XXXXX?str=I+am+get+String";
|
||||||
|
String result = "";
|
||||||
|
HttpClient client = createSSLClientDefault();
|
||||||
|
HttpGet httpRequst = new HttpGet(uriAPI);
|
||||||
|
try {
|
||||||
|
|
||||||
|
HttpResponse httpResponse = client.execute(httpRequst);//其中HttpGet是HttpUriRequst的子类
|
||||||
|
if (httpResponse.getStatusLine().getStatusCode() == 200) {
|
||||||
|
HttpEntity httpEntity = httpResponse.getEntity();
|
||||||
|
result = EntityUtils.toString(httpEntity);//取出应答字符串
|
||||||
|
// 一般来说都要删除多余的字符
|
||||||
|
result.replaceAll("\r", "");//去掉返回结果中的"\r"字符,否则会在结果字符串后面显示一个小方格
|
||||||
|
} else {
|
||||||
|
httpRequst.abort();
|
||||||
|
}
|
||||||
|
} catch (ClientProtocolException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
result = e.getMessage().toString();
|
||||||
|
} catch (IOException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
result = e.getMessage().toString();
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
package com.lei.shop.pay.utils;
|
||||||
|
|
||||||
|
import org.springframework.util.DigestUtils;
|
||||||
|
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @className: MD5Util
|
||||||
|
* @author: 周
|
||||||
|
*
|
||||||
|
* @create: 2023-06-15 16:51
|
||||||
|
*/
|
||||||
|
public class MD5Util {
|
||||||
|
|
||||||
|
public static String encryptMd5(String string) throws UnsupportedEncodingException {
|
||||||
|
return encryptMd5(string, "UTF-8");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String encryptMd5(String string, String charSet) throws UnsupportedEncodingException {
|
||||||
|
return DigestUtils.md5DigestAsHex(string.getBytes(charSet));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,57 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<parent>
|
||||||
|
<artifactId>shop-core</artifactId>
|
||||||
|
<groupId>com.lei.shop</groupId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<artifactId>shop-sms</artifactId>
|
||||||
|
<description>短信发送</description>
|
||||||
|
<properties>
|
||||||
|
<maven.compiler.source>17</maven.compiler.source>
|
||||||
|
<maven.compiler.target>17</maven.compiler.target>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.hutool</groupId>
|
||||||
|
<artifactId>hutool-all</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
|
<exclusions>
|
||||||
|
<!-- Exclude the Tomcat dependency -->
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-tomcat</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.fastjson2</groupId>
|
||||||
|
<artifactId>fastjson2</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.aliyun</groupId>
|
||||||
|
<artifactId>aliyun-java-sdk-core</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.aliyun</groupId>
|
||||||
|
<artifactId>dysmsapi20170525</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
</project>
|
||||||
|
|
@ -0,0 +1,15 @@
|
||||||
|
package com.lei.shop.sms.annotation;
|
||||||
|
|
||||||
|
import java.lang.annotation.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @className: ConditionalOnAliyunSmsEnabled
|
||||||
|
* @author: 周
|
||||||
|
* @email:
|
||||||
|
* @create: 2023-06-14 02:39
|
||||||
|
*/
|
||||||
|
@Target({ElementType.TYPE, ElementType.METHOD})
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Documented
|
||||||
|
public @interface ConditionalOnAliyunSmsEnabled {
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,43 @@
|
||||||
|
package com.lei.shop.sms.configuration;
|
||||||
|
|
||||||
|
import com.lei.shop.sms.annotation.ConditionalOnAliyunSmsEnabled;
|
||||||
|
import com.lei.shop.sms.processor.AliyunSmsSendHandler;
|
||||||
|
import com.lei.shop.sms.properties.AliyunSmsProperties;
|
||||||
|
import jakarta.annotation.PostConstruct;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @className: AliyunSmsConfiguration
|
||||||
|
* @author: 周
|
||||||
|
* @email:
|
||||||
|
* @create: 2023-06-14 02:38
|
||||||
|
*/
|
||||||
|
@Configuration(proxyBeanMethods = false)
|
||||||
|
@ConditionalOnAliyunSmsEnabled
|
||||||
|
@EnableConfigurationProperties(AliyunSmsProperties.class)
|
||||||
|
public class AliyunSmsConfiguration {
|
||||||
|
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(AliyunSmsConfiguration.class);
|
||||||
|
|
||||||
|
@PostConstruct
|
||||||
|
public void postConstruct() {
|
||||||
|
log.debug("[Herodotus] |- SDK [Sms Aliyun] Auto Configure.");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构造阿里云发送处理
|
||||||
|
*
|
||||||
|
* @param aliyunSmsProperties 配置对象
|
||||||
|
* @return 阿里云发送处理
|
||||||
|
*/
|
||||||
|
@Bean(name = "ALIYUN—SMS")
|
||||||
|
public AliyunSmsSendHandler aliyunSmsSendHandler(AliyunSmsProperties aliyunSmsProperties) {
|
||||||
|
AliyunSmsSendHandler aliyunSmsSendHandler = new AliyunSmsSendHandler(aliyunSmsProperties);
|
||||||
|
log.debug("[Herodotus] |- Bean [Aliyun Sms Send Handler] Auto Configure.");
|
||||||
|
return aliyunSmsSendHandler;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,35 @@
|
||||||
|
package com.lei.shop.sms.doman;
|
||||||
|
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通知内容
|
||||||
|
*
|
||||||
|
* @className: Template
|
||||||
|
* @author: 周
|
||||||
|
* @email:
|
||||||
|
* @create: 2023-06-14 02:43
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
public class Template {
|
||||||
|
/**
|
||||||
|
* 手机号
|
||||||
|
*/
|
||||||
|
private String phones;
|
||||||
|
/**
|
||||||
|
* 签名
|
||||||
|
*/
|
||||||
|
private String sigName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 模板code
|
||||||
|
*/
|
||||||
|
private String templateCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 参数
|
||||||
|
*/
|
||||||
|
private String templateParam;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,70 @@
|
||||||
|
package com.lei.shop.sms.processor;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSON;
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import com.aliyun.dysmsapi20170525.Client;
|
||||||
|
import com.aliyun.dysmsapi20170525.models.SendSmsRequest;
|
||||||
|
import com.aliyun.dysmsapi20170525.models.SendSmsResponse;
|
||||||
|
import com.aliyun.tea.TeaException;
|
||||||
|
import com.aliyun.teaopenapi.models.Config;
|
||||||
|
import com.lei.shop.sms.doman.Template;
|
||||||
|
import com.lei.shop.sms.properties.AliyunSmsProperties;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @className: AliyunSmsSendHandler
|
||||||
|
* @author: 周
|
||||||
|
* @email:
|
||||||
|
* @create: 2023-06-14 02:41
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
public class AliyunSmsSendHandler {
|
||||||
|
private final Client aClient;
|
||||||
|
private final AliyunSmsProperties properties;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构造阿里云短信发送处理
|
||||||
|
*
|
||||||
|
* @param properties 阿里云短信配置
|
||||||
|
*/
|
||||||
|
public AliyunSmsSendHandler(AliyunSmsProperties properties) {
|
||||||
|
this.properties = properties;
|
||||||
|
|
||||||
|
Config config = new Config()
|
||||||
|
.setAccessKeyId(this.properties.getAccessKeyId())
|
||||||
|
.setAccessKeySecret(this.properties.getAccessKeySecret());
|
||||||
|
// 访问的域名
|
||||||
|
config.endpoint = this.properties.getDomain();
|
||||||
|
try {
|
||||||
|
aClient = new Client(config);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean execute(Template template) {
|
||||||
|
|
||||||
|
JSONObject jsonObject = new JSONObject();
|
||||||
|
jsonObject.put("code", template.getTemplateParam());
|
||||||
|
|
||||||
|
com.aliyun.dysmsapi20170525.models.SendSmsRequest sendSmsRequest = new SendSmsRequest()
|
||||||
|
.setPhoneNumbers(template.getPhones())
|
||||||
|
.setSignName(this.properties.getSignName())
|
||||||
|
.setTemplateCode(template.getTemplateCode())
|
||||||
|
.setTemplateParam(jsonObject.toJSONString());
|
||||||
|
com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
|
||||||
|
try {
|
||||||
|
// 复制代码运行请自行打印 API 的返回值
|
||||||
|
SendSmsResponse sendSmsResponse = aClient.sendSmsWithOptions(sendSmsRequest, runtime);
|
||||||
|
log.info("消息发送返回值:{}", JSON.toJSONString(sendSmsResponse));
|
||||||
|
} catch (TeaException error) {
|
||||||
|
// 如有需要,请打印 error
|
||||||
|
com.aliyun.teautil.Common.assertAsString(error.message);
|
||||||
|
} catch (Exception _error) {
|
||||||
|
TeaException error = new TeaException(_error.getMessage(), _error);
|
||||||
|
// 如有需要,请打印 error
|
||||||
|
com.aliyun.teautil.Common.assertAsString(error.message);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,50 @@
|
||||||
|
package com.lei.shop.sms.properties;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @className: AliyunSmsProperties
|
||||||
|
* @author: 周
|
||||||
|
* @email:
|
||||||
|
* @create: 2023-06-14 02:30
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Component
|
||||||
|
@ConfigurationProperties(prefix ="sms.aliyun")
|
||||||
|
public class AliyunSmsProperties {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Endpoint
|
||||||
|
*/
|
||||||
|
private String regionId = "cn-hangzhou";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* accessKeyId
|
||||||
|
*/
|
||||||
|
private String accessKeyId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* accessKeySecret
|
||||||
|
*/
|
||||||
|
private String accessKeySecret;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 短信签名
|
||||||
|
*/
|
||||||
|
private String signName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 短信API产品域名(接口地址固定,无需修改)
|
||||||
|
*/
|
||||||
|
private String domain = "dysmsapi.aliyuncs.com";
|
||||||
|
|
||||||
|
private String version = "2017-05-25";
|
||||||
|
|
||||||
|
private String product = "Dysmsapi";
|
||||||
|
|
||||||
|
private String action = "SendSms";
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,36 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<parent>
|
||||||
|
<artifactId>shop-cloud</artifactId>
|
||||||
|
<groupId>com.lei.shop</groupId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|
||||||
|
<artifactId>shop-forum</artifactId>
|
||||||
|
<packaging>pom</packaging>
|
||||||
|
<modules>
|
||||||
|
<module>shop-forum-api</module>
|
||||||
|
<module>shop-forum-service</module>
|
||||||
|
</modules>
|
||||||
|
|
||||||
|
|
||||||
|
<dependencyManagement>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.lei.shop</groupId>
|
||||||
|
<artifactId>shop-common</artifactId>
|
||||||
|
<version>${project.parent.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.lei.shop</groupId>
|
||||||
|
<artifactId>shop-config</artifactId>
|
||||||
|
<version>${project.parent.version}</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</dependencyManagement>
|
||||||
|
|
||||||
|
</project>
|
||||||
|
|
@ -0,0 +1,35 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<artifactId>shop-forum</artifactId>
|
||||||
|
<groupId>com.lei.shop</groupId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>shop-forum-api</artifactId>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.lei.shop</groupId>
|
||||||
|
<artifactId>shop-common</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.hibernate.validator</groupId>
|
||||||
|
<artifactId>hibernate-validator</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
</project>
|
||||||
|
|
@ -0,0 +1,54 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<parent>
|
||||||
|
<artifactId>shop-forum</artifactId>
|
||||||
|
<groupId>com.lei.shop</groupId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<artifactId>shop-forum-service</artifactId>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.lei.shop</groupId>
|
||||||
|
<artifactId>shop-config</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.lei.shop</groupId>
|
||||||
|
<artifactId>shop-forum-api</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.lei.shop</groupId>
|
||||||
|
<artifactId>shop-user-api</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<excludes>
|
||||||
|
<exclude>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
</exclude>
|
||||||
|
</excludes>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
</project>
|
||||||
|
|
@ -0,0 +1,28 @@
|
||||||
|
package com.lei.shop.forum;
|
||||||
|
|
||||||
|
import org.mybatis.spring.annotation.MapperScan;
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.cache.annotation.EnableCaching;
|
||||||
|
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||||
|
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 论坛板块
|
||||||
|
*
|
||||||
|
* @className: ShopForumApplication
|
||||||
|
* @author: 周
|
||||||
|
* @email:
|
||||||
|
* @create: 2023-08-08 18:51
|
||||||
|
*/
|
||||||
|
@SpringBootApplication(scanBasePackages = {"com.lei.shop"})
|
||||||
|
@MapperScan("com.lei.shop.forum.common.mapper")
|
||||||
|
@EnableCaching
|
||||||
|
@EnableDiscoveryClient
|
||||||
|
@EnableFeignClients(basePackages = {"com.lei.shop.api.user.feign"})
|
||||||
|
public class ShopForumApplication {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SpringApplication.run(ShopForumApplication.class, args);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,54 @@
|
||||||
|
package com.lei.shop.forum.common.constant;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @className: ForumConstant
|
||||||
|
* @author: 周
|
||||||
|
*
|
||||||
|
* @create: 2023-08-12 10:48
|
||||||
|
*/
|
||||||
|
public class ForumConstant {
|
||||||
|
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
public enum FOLLOW_TYPE {
|
||||||
|
|
||||||
|
//关注类型: 1 用户 2 专题 3 板块 4 收藏帖子 5 喜欢帖子 6 点赞评论 7 关注圆桌
|
||||||
|
|
||||||
|
USER(1),
|
||||||
|
SUBJECT(2),
|
||||||
|
MODULE(3),
|
||||||
|
COLLECT_POST(4),
|
||||||
|
LIKE_POST(5),
|
||||||
|
GIVE_LIKE_REVIEW(6),
|
||||||
|
FOLLOW_ROUND_TABLE(7)
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
|
private Integer TYPE;
|
||||||
|
|
||||||
|
FOLLOW_TYPE(Integer type) {
|
||||||
|
this.TYPE = type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
public enum FOLLOW_REDIS {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* following 关注
|
||||||
|
* followers 被关注
|
||||||
|
*/
|
||||||
|
FOLLOWING("follow:following:{0}:{1}"),
|
||||||
|
FOLLOWERS("follow:followers:{0}:{1}");
|
||||||
|
|
||||||
|
private String key;
|
||||||
|
|
||||||
|
|
||||||
|
FOLLOW_REDIS(String key) {
|
||||||
|
this.key = key;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,37 @@
|
||||||
|
package com.lei.shop.forum.common.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.lei.shop.config.base.LeiBaseEntity;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户黑名单
|
||||||
|
*
|
||||||
|
* @className: ForumBlackUser
|
||||||
|
* @author: 周
|
||||||
|
*
|
||||||
|
* @create: 2023-09-08 10:09
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Schema(name = "用户黑名单", description = "table.comment!")
|
||||||
|
@TableName("forum_black_user")
|
||||||
|
public class ForumBlackUser extends LeiBaseEntity<ForumBlackUser> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户iD
|
||||||
|
*/
|
||||||
|
@TableField("user_id")
|
||||||
|
@Schema(description = "用户iD")
|
||||||
|
private String userId;
|
||||||
|
/**
|
||||||
|
* 黑名单用户
|
||||||
|
*/
|
||||||
|
@TableField("to_id")
|
||||||
|
@Schema(description = "黑名单用户")
|
||||||
|
private String toId;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,48 @@
|
||||||
|
package com.lei.shop.forum.common.entity;
|
||||||
|
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.lei.shop.config.base.LeiBaseEntity;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 板块浏览记录实体
|
||||||
|
* @className: 板块浏览记录
|
||||||
|
* @author: 周
|
||||||
|
*
|
||||||
|
* @create: 2023-08-30 14:20:04
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Schema(name = "板块浏览记录", description = "table.comment!")
|
||||||
|
@TableName("forum_browse_log")
|
||||||
|
public class ForumBrowseLog extends LeiBaseEntity<ForumBrowseLog> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户iD
|
||||||
|
*/
|
||||||
|
@TableField("user_id")
|
||||||
|
@Schema(description = "用户iD")
|
||||||
|
private String userId;
|
||||||
|
/**
|
||||||
|
* 类型:1 帖子. 2 板块
|
||||||
|
*/
|
||||||
|
@TableField("type")
|
||||||
|
@Schema(description = "类型:1 帖子. 2 板块")
|
||||||
|
private Integer type;
|
||||||
|
/**
|
||||||
|
* 内容ID
|
||||||
|
*/
|
||||||
|
@TableField("content_id")
|
||||||
|
@Schema(description = "内容ID")
|
||||||
|
private String contentId;
|
||||||
|
|
||||||
|
|
||||||
|
@TableField(exist = false)
|
||||||
|
@Schema(description = "搜索关键字")
|
||||||
|
private String searchKey;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,133 @@
|
||||||
|
package com.lei.shop.forum.common.entity;
|
||||||
|
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import com.lei.shop.config.base.LeiBaseEntity;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 用户文章实体
|
||||||
|
* @className: 用户文章
|
||||||
|
* @author: 周
|
||||||
|
*
|
||||||
|
* @create: 2023-08-10 02:46:50
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Schema(name = "用户文章", description = "table.comment!")
|
||||||
|
@TableName("forum_contens")
|
||||||
|
public class ForumContens extends LeiBaseEntity<ForumContens> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户ID
|
||||||
|
*/
|
||||||
|
@TableField("user_id")
|
||||||
|
@Schema(description = "用户ID")
|
||||||
|
private String userId;
|
||||||
|
/**
|
||||||
|
* 模块ID
|
||||||
|
*/
|
||||||
|
@TableField("module_parent_id")
|
||||||
|
@Schema(description = "模块ID")
|
||||||
|
private String moduleParentId;
|
||||||
|
/**
|
||||||
|
* 模块二级ID
|
||||||
|
*/
|
||||||
|
@TableField("module_id")
|
||||||
|
@Schema(description = "模块二级ID")
|
||||||
|
private String moduleId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 标题
|
||||||
|
*/
|
||||||
|
@TableField("titles")
|
||||||
|
@Schema(description = "标题")
|
||||||
|
private String titles;
|
||||||
|
/**
|
||||||
|
* 内容
|
||||||
|
*/
|
||||||
|
@TableField("contents")
|
||||||
|
@Schema(description = "内容")
|
||||||
|
private String contents;
|
||||||
|
|
||||||
|
|
||||||
|
// @TableField("text_content")
|
||||||
|
// @Schema(description = "文本内容")
|
||||||
|
// private String textContent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 图片
|
||||||
|
*/
|
||||||
|
@TableField("images")
|
||||||
|
@Schema(description = "图片")
|
||||||
|
private String images;
|
||||||
|
/**
|
||||||
|
* 文件列表
|
||||||
|
*/
|
||||||
|
@TableField("file_url")
|
||||||
|
@Schema(description = "文件列表")
|
||||||
|
private String fileUrl;
|
||||||
|
/**
|
||||||
|
* 赞同人数
|
||||||
|
*/
|
||||||
|
@TableField("endorse_number")
|
||||||
|
@Schema(description = "赞同人数")
|
||||||
|
private Integer endorseNumber;
|
||||||
|
/**
|
||||||
|
* 评论人数
|
||||||
|
*/
|
||||||
|
@TableField("review_number")
|
||||||
|
@Schema(description = "评论人数")
|
||||||
|
private Integer reviewNumber;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 浏览人数
|
||||||
|
*/
|
||||||
|
@TableField("browse_number")
|
||||||
|
@Schema(description = "浏览人数")
|
||||||
|
private Integer browseNumber;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 收藏人数
|
||||||
|
*/
|
||||||
|
@TableField("collect_number")
|
||||||
|
@Schema(description = "收藏人数")
|
||||||
|
private Integer collectNumber;
|
||||||
|
/**
|
||||||
|
* 主题ID
|
||||||
|
*/
|
||||||
|
@TableField("subject_id")
|
||||||
|
@Schema(description = "主题ID")
|
||||||
|
private String subjectId;
|
||||||
|
|
||||||
|
|
||||||
|
@TableField("labels")
|
||||||
|
@Schema(description = "标签")
|
||||||
|
private String labels;
|
||||||
|
|
||||||
|
@TableField("reply_date")
|
||||||
|
@Schema(description = "回复时间")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
private Date replyDate;
|
||||||
|
|
||||||
|
|
||||||
|
@TableField("type")
|
||||||
|
@Schema(description = "类型:1 论坛 2 圆桌")
|
||||||
|
private Integer type;
|
||||||
|
|
||||||
|
@TableField("roundtable_id")
|
||||||
|
@Schema(description = "圆桌ID")
|
||||||
|
private String roundtableId;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,56 @@
|
||||||
|
package com.lei.shop.forum.common.entity;
|
||||||
|
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.lei.shop.config.base.LeiBaseEntity;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 帖子-文件实体
|
||||||
|
* @className: 帖子-文件
|
||||||
|
* @author: 周
|
||||||
|
*
|
||||||
|
* @create: 2023-08-30 14:20:04
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Schema(name = "帖子-文件", description = "table.comment!")
|
||||||
|
@TableName("forum_contens_file")
|
||||||
|
public class ForumContensFile extends LeiBaseEntity<ForumContensFile> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户ID
|
||||||
|
*/
|
||||||
|
@TableField("user_id")
|
||||||
|
@Schema(description = "用户ID")
|
||||||
|
private String userId;
|
||||||
|
/**
|
||||||
|
* 帖子ID
|
||||||
|
*/
|
||||||
|
@TableField("content_id")
|
||||||
|
@Schema(description = "帖子ID")
|
||||||
|
private String contentId;
|
||||||
|
/**
|
||||||
|
* 帖子名称
|
||||||
|
*/
|
||||||
|
@TableField("content_name")
|
||||||
|
@Schema(description = "帖子名称")
|
||||||
|
private String contentName;
|
||||||
|
/**
|
||||||
|
* 文件名称
|
||||||
|
*/
|
||||||
|
@TableField("file_name")
|
||||||
|
@Schema(description = "文件名称")
|
||||||
|
private String fileName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件名称
|
||||||
|
*/
|
||||||
|
@TableField("file_url")
|
||||||
|
@Schema(description = "文件地址")
|
||||||
|
private String fileUrl;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,68 @@
|
||||||
|
package com.lei.shop.forum.common.entity;
|
||||||
|
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.lei.shop.config.base.LeiBaseEntity;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 文章评论实体
|
||||||
|
* @className: 文章评论
|
||||||
|
* @author: 周
|
||||||
|
* @email:
|
||||||
|
* @create: 2023-08-10 02:46:51
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Schema(name = "文章评论",description = "table.comment!")
|
||||||
|
@TableName("forum_contens_review")
|
||||||
|
public class ForumContensReview extends LeiBaseEntity<ForumContensReview> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 内容ID
|
||||||
|
*/
|
||||||
|
@TableField("content_id")
|
||||||
|
@Schema(description = "内容ID")
|
||||||
|
private String contentId;
|
||||||
|
/**
|
||||||
|
* 用户ID
|
||||||
|
*/
|
||||||
|
@TableField("user_id")
|
||||||
|
@Schema(description = "用户ID")
|
||||||
|
private String userId;
|
||||||
|
/**
|
||||||
|
* 内容
|
||||||
|
*/
|
||||||
|
@TableField("contents")
|
||||||
|
@Schema(description = "内容")
|
||||||
|
private String contents;
|
||||||
|
/**
|
||||||
|
* 点赞数
|
||||||
|
*/
|
||||||
|
@TableField("like_number")
|
||||||
|
@Schema(description = "点赞数")
|
||||||
|
private Integer likeNumber;
|
||||||
|
/**
|
||||||
|
* 状态:1 正常 2 热度
|
||||||
|
*/
|
||||||
|
@TableField("hot_type")
|
||||||
|
@Schema(description = "状态:1 正常 2 热度")
|
||||||
|
private Integer hotType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件列表
|
||||||
|
*/
|
||||||
|
@TableField("file_url")
|
||||||
|
@Schema(description = "文件列表")
|
||||||
|
private String fileUrl;
|
||||||
|
/**
|
||||||
|
* 评论ID
|
||||||
|
*/
|
||||||
|
@TableField("review_id")
|
||||||
|
@Schema(description = "评论ID")
|
||||||
|
private String reviewId;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,42 @@
|
||||||
|
package com.lei.shop.forum.common.entity;
|
||||||
|
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.lei.shop.config.base.LeiBaseEntity;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 用户关注实体
|
||||||
|
* @className: 用户关注
|
||||||
|
* @author: 周
|
||||||
|
*
|
||||||
|
* @create: 2023-08-10 02:46:51
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Schema(name = "用户关注",description = "table.comment!")
|
||||||
|
@TableName("forum_follow")
|
||||||
|
public class ForumFollow extends LeiBaseEntity<ForumFollow> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户ID
|
||||||
|
*/
|
||||||
|
@TableField("user_id")
|
||||||
|
@Schema(description = "用户ID")
|
||||||
|
private String userId;
|
||||||
|
/**
|
||||||
|
* 关注用户ID
|
||||||
|
*/
|
||||||
|
@TableField("to_id")
|
||||||
|
@Schema(description = "关注用户ID")
|
||||||
|
private String toId;
|
||||||
|
|
||||||
|
|
||||||
|
@TableField("type")
|
||||||
|
@Schema(description = "关注类型: 1 用户 2 专题 3 板块 4 收藏帖子 5 喜欢(赞同)帖子 6 点赞评论 7 关注圆桌")
|
||||||
|
private Integer type;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,75 @@
|
||||||
|
package com.lei.shop.forum.common.entity;
|
||||||
|
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import com.lei.shop.config.base.LeiBaseEntity;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 论坛消息实体
|
||||||
|
* @className: 论坛消息
|
||||||
|
* @author: 小明
|
||||||
|
*
|
||||||
|
* @create: 2023-08-15 01:59:30
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Schema(name = "论坛消息",description = "table.comment!")
|
||||||
|
@TableName("forum_message")
|
||||||
|
public class ForumMessage extends LeiBaseEntity<ForumMessage> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户ID
|
||||||
|
*/
|
||||||
|
@TableField("user_id")
|
||||||
|
@Schema(description = "用户ID")
|
||||||
|
private String userId;
|
||||||
|
/**
|
||||||
|
* 收用户ID
|
||||||
|
*/
|
||||||
|
@TableField("to_id")
|
||||||
|
@Schema(description = "收用户ID")
|
||||||
|
private String toId;
|
||||||
|
/**
|
||||||
|
* 标题
|
||||||
|
*/
|
||||||
|
@TableField("title")
|
||||||
|
@Schema(description = "标题")
|
||||||
|
private String title;
|
||||||
|
/**
|
||||||
|
* 内容
|
||||||
|
*/
|
||||||
|
@TableField("contents")
|
||||||
|
@Schema(description = "内容")
|
||||||
|
private String contents;
|
||||||
|
/**
|
||||||
|
* 是否阅读:1 未阅读 2 阅读
|
||||||
|
*/
|
||||||
|
@TableField("is_read")
|
||||||
|
@Schema(description = "是否阅读:1 未阅读 2 阅读")
|
||||||
|
private Integer isRead;
|
||||||
|
|
||||||
|
|
||||||
|
@Schema(description = "回复内容")
|
||||||
|
private String recoverContent;
|
||||||
|
|
||||||
|
@Schema(description = "回复时间")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
private Date recoverDate;
|
||||||
|
|
||||||
|
|
||||||
|
@TableField(exist = false)
|
||||||
|
@Schema(description = "用户名")
|
||||||
|
private String userName;
|
||||||
|
|
||||||
|
@TableField(exist = false)
|
||||||
|
@Schema(description = "头像")
|
||||||
|
private String avatar;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,62 @@
|
||||||
|
package com.lei.shop.forum.common.entity;
|
||||||
|
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.lei.shop.config.base.LeiBaseEntity;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 分类模块实体
|
||||||
|
* @className: 分类模块
|
||||||
|
* @author: 周
|
||||||
|
*
|
||||||
|
* @create: 2023-08-10 02:46:51
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Schema(name = "分类模块", description = "table.comment!")
|
||||||
|
@TableName("forum_module")
|
||||||
|
public class ForumModule extends LeiBaseEntity<ForumModule> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 名称
|
||||||
|
*/
|
||||||
|
@TableField("names")
|
||||||
|
@Schema(description = "名称")
|
||||||
|
private String names;
|
||||||
|
/**
|
||||||
|
* 父类ID
|
||||||
|
*/
|
||||||
|
@TableField("parent_id")
|
||||||
|
@Schema(description = "父类ID")
|
||||||
|
private String parentId;
|
||||||
|
/**
|
||||||
|
* 顺序
|
||||||
|
*/
|
||||||
|
@TableField("sort")
|
||||||
|
@Schema(description = "顺序")
|
||||||
|
private Integer sort;
|
||||||
|
/**
|
||||||
|
* 状态:1上架 2 下架
|
||||||
|
*/
|
||||||
|
@TableField("states")
|
||||||
|
@Schema(description = "状态:1上架 2 下架")
|
||||||
|
private Integer states;
|
||||||
|
/**
|
||||||
|
* ICON图
|
||||||
|
*/
|
||||||
|
@TableField("icons")
|
||||||
|
@Schema(description = "ICON图")
|
||||||
|
private String icons;
|
||||||
|
|
||||||
|
|
||||||
|
@TableField(exist = false)
|
||||||
|
@Schema(description = "标题")
|
||||||
|
private List<ForumModule> moduleList;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,94 @@
|
||||||
|
package com.lei.shop.forum.common.entity;
|
||||||
|
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import java.util.Date;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.lei.shop.config.base.LeiBaseEntity;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 论坛举报实体
|
||||||
|
* @className: 论坛举报
|
||||||
|
* @author: 小明
|
||||||
|
*
|
||||||
|
* @create: 2023-08-15 01:59:30
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Schema(name = "论坛举报",description = "table.comment!")
|
||||||
|
@TableName("forum_report")
|
||||||
|
public class ForumReport extends LeiBaseEntity<ForumReport> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户ID
|
||||||
|
*/
|
||||||
|
@TableField("user_id")
|
||||||
|
@Schema(description = "用户ID")
|
||||||
|
private String userId;
|
||||||
|
/**
|
||||||
|
* 内容Id
|
||||||
|
*/
|
||||||
|
@TableField("content_id")
|
||||||
|
@Schema(description = "内容Id")
|
||||||
|
private String contentId;
|
||||||
|
/**
|
||||||
|
* 举报内容
|
||||||
|
*/
|
||||||
|
@TableField("contents")
|
||||||
|
@Schema(description = "举报内容")
|
||||||
|
private String contents;
|
||||||
|
/**
|
||||||
|
* 举报类型:1 帖子 2 评论
|
||||||
|
*/
|
||||||
|
@TableField("type")
|
||||||
|
@Schema(description = "举报类型:1 帖子 2 评论")
|
||||||
|
private Integer type;
|
||||||
|
/**
|
||||||
|
* 举报内容
|
||||||
|
*/
|
||||||
|
@TableField("report")
|
||||||
|
@Schema(description = "举报内容")
|
||||||
|
private String report;
|
||||||
|
/**
|
||||||
|
* 举报内容
|
||||||
|
*/
|
||||||
|
@TableField("report_content")
|
||||||
|
@Schema(description = "举报内容")
|
||||||
|
private String reportContent;
|
||||||
|
/**
|
||||||
|
* 是否处理:1 提交申请 2 处理中 3 处理完成
|
||||||
|
*/
|
||||||
|
@TableField("is_handle")
|
||||||
|
@Schema(description = "是否处理:1 提交申请 2 处理中 3 处理完成")
|
||||||
|
private Integer isHandle;
|
||||||
|
/**
|
||||||
|
* 处理时间
|
||||||
|
*/
|
||||||
|
@TableField("handle_time")
|
||||||
|
@Schema(description = "处理时间")
|
||||||
|
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
|
||||||
|
private Date handleTime;
|
||||||
|
/**
|
||||||
|
* 处理结果
|
||||||
|
*/
|
||||||
|
@TableField("handle_result")
|
||||||
|
@Schema(description = "处理结果")
|
||||||
|
private Integer handleResult;
|
||||||
|
/**
|
||||||
|
* 处理天数
|
||||||
|
*/
|
||||||
|
@TableField("handle_day")
|
||||||
|
@Schema(description = "处理天数")
|
||||||
|
private String handleDay;
|
||||||
|
/**
|
||||||
|
* 举报二级内容
|
||||||
|
*/
|
||||||
|
@TableField("report_er")
|
||||||
|
@Schema(description = "举报二级内容")
|
||||||
|
private String reportEr;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,80 @@
|
||||||
|
package com.lei.shop.forum.common.entity;
|
||||||
|
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.lei.shop.config.base.LeiBaseEntity;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 论坛圆桌实体
|
||||||
|
* @className: 论坛圆桌
|
||||||
|
* @author: 小明
|
||||||
|
* @email:
|
||||||
|
* @create: 2023-08-15 01:59:30
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Schema(name = "论坛圆桌", description = "table.comment!")
|
||||||
|
@TableName("forum_roundtable")
|
||||||
|
public class ForumRoundtable extends LeiBaseEntity<ForumRoundtable> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 标题
|
||||||
|
*/
|
||||||
|
@TableField("titles")
|
||||||
|
@Schema(description = "标题")
|
||||||
|
private String titles;
|
||||||
|
/**
|
||||||
|
* 昵称
|
||||||
|
*/
|
||||||
|
@TableField("nick_name")
|
||||||
|
@Schema(description = "昵称")
|
||||||
|
private String nickName;
|
||||||
|
/**
|
||||||
|
* 头像
|
||||||
|
*/
|
||||||
|
@TableField("avatar")
|
||||||
|
@Schema(description = "头像")
|
||||||
|
private String avatar;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 模块ID
|
||||||
|
*/
|
||||||
|
@TableField("module_parent_id")
|
||||||
|
@Schema(description = "模块ID")
|
||||||
|
private String moduleParentId;
|
||||||
|
/**
|
||||||
|
* 模块二级ID
|
||||||
|
*/
|
||||||
|
@TableField("module_id")
|
||||||
|
@Schema(description = "模块二级ID")
|
||||||
|
private String moduleId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户ID
|
||||||
|
*/
|
||||||
|
@TableField("user_id")
|
||||||
|
@Schema(description = "用户ID")
|
||||||
|
private String userId;
|
||||||
|
/**
|
||||||
|
* 简介
|
||||||
|
*/
|
||||||
|
@TableField("intro")
|
||||||
|
@Schema(description = "简介")
|
||||||
|
private String intro;
|
||||||
|
/**
|
||||||
|
* 权重
|
||||||
|
*/
|
||||||
|
@TableField("sort")
|
||||||
|
@Schema(description = "权重")
|
||||||
|
private Integer sort;
|
||||||
|
|
||||||
|
|
||||||
|
@TableField(exist = false)
|
||||||
|
@Schema(description = "搜索关键字")
|
||||||
|
private String searchKey;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,42 @@
|
||||||
|
package com.lei.shop.forum.common.entity;
|
||||||
|
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.lei.shop.config.base.LeiBaseEntity;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 主题实体
|
||||||
|
* @className: 主题
|
||||||
|
* @author: 周
|
||||||
|
* @email:
|
||||||
|
* @create: 2023-08-10 02:46:51
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Schema(name = "专题", description = "table.comment!")
|
||||||
|
@TableName("forum_subject")
|
||||||
|
public class ForumSubject extends LeiBaseEntity<ForumSubject> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主题名称
|
||||||
|
*/
|
||||||
|
@TableField("names")
|
||||||
|
@Schema(description = "主题名称")
|
||||||
|
private String names;
|
||||||
|
/**
|
||||||
|
* 权重
|
||||||
|
*/
|
||||||
|
@TableField("sort")
|
||||||
|
@Schema(description = "权重")
|
||||||
|
private Integer sort;
|
||||||
|
|
||||||
|
|
||||||
|
@TableField(exist = false)
|
||||||
|
@Schema(description = "是否关注")
|
||||||
|
private Boolean isForum = false;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,95 @@
|
||||||
|
package com.lei.shop.forum.common.entity;
|
||||||
|
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import com.lei.shop.config.base.LeiBaseEntity;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 用户认证信息实体
|
||||||
|
* @className: 用户认证信息
|
||||||
|
* @author: 周
|
||||||
|
*
|
||||||
|
* @create: 2023-08-10 02:46:51
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Schema(name = "用户认证信息", description = "table.comment!")
|
||||||
|
@TableName("forum_user_auth")
|
||||||
|
public class ForumUserAuth extends LeiBaseEntity<ForumUserAuth> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户ID
|
||||||
|
*/
|
||||||
|
@TableField("user_id")
|
||||||
|
@Schema(description = "用户ID")
|
||||||
|
private String userId;
|
||||||
|
/**
|
||||||
|
* 姓名
|
||||||
|
*/
|
||||||
|
@TableField("user_name")
|
||||||
|
@Schema(description = "姓名")
|
||||||
|
private String userName;
|
||||||
|
/**
|
||||||
|
* 学校名称
|
||||||
|
*/
|
||||||
|
@TableField("school_name")
|
||||||
|
@Schema(description = "学校名称")
|
||||||
|
private String schoolName;
|
||||||
|
/**
|
||||||
|
* 专业名称
|
||||||
|
*/
|
||||||
|
@TableField("profession_name")
|
||||||
|
@Schema(description = "专业名称")
|
||||||
|
private String professionName;
|
||||||
|
/**
|
||||||
|
* 学历
|
||||||
|
*/
|
||||||
|
@TableField("education")
|
||||||
|
@Schema(description = "学历")
|
||||||
|
private String education;
|
||||||
|
/**
|
||||||
|
* 毕业时间
|
||||||
|
*/
|
||||||
|
@TableField("graduation_time")
|
||||||
|
@Schema(description = "毕业时间")
|
||||||
|
private String graduationTime;
|
||||||
|
/**
|
||||||
|
* 学历证正面
|
||||||
|
*/
|
||||||
|
@TableField("diploma_front")
|
||||||
|
@Schema(description = "学历证正面")
|
||||||
|
private String diplomaFront;
|
||||||
|
/**
|
||||||
|
* 毕业证背面
|
||||||
|
*/
|
||||||
|
@TableField("diploma_back")
|
||||||
|
@Schema(description = "毕业证背面")
|
||||||
|
private String diplomaBack;
|
||||||
|
/**
|
||||||
|
* 状态:1 审核中 2 审核成功 3 审核失败
|
||||||
|
*/
|
||||||
|
@TableField("states")
|
||||||
|
@Schema(description = "状态:1 审核中 2 审核成功 3 审核失败")
|
||||||
|
private Integer states;
|
||||||
|
/**
|
||||||
|
* 审核时间
|
||||||
|
*/
|
||||||
|
@TableField("audit_time")
|
||||||
|
@Schema(description = "审核时间")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
private Date auditTime;
|
||||||
|
/**
|
||||||
|
* 审核理由
|
||||||
|
*/
|
||||||
|
@TableField("reason")
|
||||||
|
@Schema(description = "审核理由")
|
||||||
|
private String reason;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,23 @@
|
||||||
|
package com.lei.shop.forum.common.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.lei.shop.forum.common.entity.ForumBlackUser;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @className: ForumBlackUserMapper
|
||||||
|
* @author: 周
|
||||||
|
* @email:
|
||||||
|
* @create: 2023-09-08 10:20
|
||||||
|
*/
|
||||||
|
public interface ForumBlackUserMapper extends BaseMapper<ForumBlackUser> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 真实删除用户黑名单
|
||||||
|
*
|
||||||
|
* @param userId
|
||||||
|
* @param toId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
boolean deleteBlack(@Param("userId") String userId, @Param("toId") String toId);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
package com.lei.shop.forum.common.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.lei.shop.config.base.LeiPage;
|
||||||
|
import com.lei.shop.forum.common.entity.ForumBrowseLog;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 板块浏览记录Mapper接口
|
||||||
|
* @className: 板块浏览记录
|
||||||
|
* @author: 周
|
||||||
|
* @email:
|
||||||
|
* @create: 2023-08-30 14:20:04
|
||||||
|
*/
|
||||||
|
public interface ForumBrowseLogMapper extends BaseMapper<ForumBrowseLog> {
|
||||||
|
|
||||||
|
IPage<ForumBrowseLog> listPage(@Param("page") LeiPage<ForumBrowseLog> page);
|
||||||
|
IPage<ForumBrowseLog> listPageBrowseNumber(@Param("page") LeiPage<ForumBrowseLog> page);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
package com.lei.shop.forum.common.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.lei.shop.config.base.LeiPage;
|
||||||
|
import com.lei.shop.forum.common.entity.ForumContensFile;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 帖子-文件Mapper接口
|
||||||
|
* @className: 帖子-文件
|
||||||
|
* @author: 周
|
||||||
|
* @email:
|
||||||
|
* @create: 2023-08-30 14:20:04
|
||||||
|
*/
|
||||||
|
public interface ForumContensFileMapper extends BaseMapper<ForumContensFile> {
|
||||||
|
|
||||||
|
IPage<ForumContensFile> listPage(@Param("page") LeiPage<ForumContensFile> page);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,38 @@
|
||||||
|
package com.lei.shop.forum.common.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.lei.shop.config.base.LeiPage;
|
||||||
|
import com.lei.shop.forum.common.entity.ForumContens;
|
||||||
|
import com.lei.shop.forum.dto.content.ContentInfoDto;
|
||||||
|
import com.lei.shop.forum.dto.content.ContentSearchDto;
|
||||||
|
import com.lei.shop.forum.dto.content.ContentSearchVo;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 用户文章Mapper接口
|
||||||
|
* @className: 用户文章
|
||||||
|
* @author: 周
|
||||||
|
* @email:
|
||||||
|
* @create: 2023-08-10 02:46:50
|
||||||
|
*/
|
||||||
|
public interface ForumContensMapper extends BaseMapper<ForumContens> {
|
||||||
|
|
||||||
|
IPage<ForumContens> listPage(@Param("page") LeiPage<ForumContens> page);
|
||||||
|
IPage<ContentInfoDto> queryByUserId(@Param("page") LeiPage<String> page,@Param("type") Integer type);
|
||||||
|
IPage<ContentInfoDto> queryContentInfoReattachment(@Param("page") LeiPage<String> page,@Param("type") Integer type);
|
||||||
|
|
||||||
|
IPage<ContentSearchVo> listPageSearch(@Param("page") LeiPage<ContentSearchDto> page);
|
||||||
|
IPage<ContentSearchVo> queryFollowContentIPage(@Param("page") LeiPage<String> page);
|
||||||
|
IPage<ContentSearchVo> queryHotContentIPage(@Param("page") LeiPage<String> page);
|
||||||
|
|
||||||
|
|
||||||
|
List<ContentSearchVo> listSearchIds(@Param("ids") List<String> ids);
|
||||||
|
|
||||||
|
ContentInfoDto getByContentId(@Param("contentId") String contentId);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,34 @@
|
||||||
|
package com.lei.shop.forum.common.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.lei.shop.config.base.LeiPage;
|
||||||
|
import com.lei.shop.forum.common.entity.ForumContensReview;
|
||||||
|
import com.lei.shop.forum.dto.content.ForumContensReviewSearchVO;
|
||||||
|
import com.lei.shop.forum.dto.review.ReviewSearchDto;
|
||||||
|
import com.lei.shop.forum.dto.review.ReviewVo;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 文章评论Mapper接口
|
||||||
|
* @className: 文章评论
|
||||||
|
* @author: 周
|
||||||
|
*
|
||||||
|
* @create: 2023-08-10 02:46:51
|
||||||
|
*/
|
||||||
|
public interface ForumContensReviewMapper extends BaseMapper<ForumContensReview> {
|
||||||
|
|
||||||
|
IPage<ForumContensReview> listPage(@Param("page") LeiPage<ForumContensReview> page);
|
||||||
|
|
||||||
|
|
||||||
|
List<ForumContensReviewSearchVO> searchReviewByContentIdLimit1(@Param("contentId") String contentId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取评论
|
||||||
|
* @param page
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
IPage<ReviewVo> queryReview(@Param("page") LeiPage<ReviewSearchDto> page);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,67 @@
|
||||||
|
package com.lei.shop.forum.common.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.lei.shop.config.base.LeiPage;
|
||||||
|
import com.lei.shop.forum.common.entity.ForumFollow;
|
||||||
|
import com.lei.shop.forum.dto.common.CommonSearchDto;
|
||||||
|
import com.lei.shop.forum.dto.user.UserInfo;
|
||||||
|
import com.lei.shop.forum.dto.user.UserListVo;
|
||||||
|
import org.apache.ibatis.annotations.Delete;
|
||||||
|
import org.apache.ibatis.annotations.Insert;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
import org.apache.ibatis.annotations.Select;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 用户关注Mapper接口
|
||||||
|
* @className: 用户关注
|
||||||
|
* @author: 周
|
||||||
|
* @email:
|
||||||
|
* @create: 2023-08-10 02:46:51
|
||||||
|
*/
|
||||||
|
public interface ForumFollowMapper extends BaseMapper<ForumFollow> {
|
||||||
|
|
||||||
|
IPage<ForumFollow> listPage(@Param("page") LeiPage<ForumFollow> page);
|
||||||
|
IPage<UserListVo> queryUserList(@Param("page") LeiPage<CommonSearchDto> page);
|
||||||
|
IPage<UserListVo> queryFollowUserList(@Param("page") LeiPage<String> page);
|
||||||
|
|
||||||
|
UserInfo getUserInfo(@Param("userId") String userId);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询关注信息
|
||||||
|
*
|
||||||
|
* @param fromId
|
||||||
|
* @param toId
|
||||||
|
* @param type
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Select("select id, user_id, to_id from forum_follow where user_id= #{fromId} and to_id = #{toId} and type=#{type}")
|
||||||
|
ForumFollow selectFollow(@Param("type") Integer type, @Param("fromId") String fromId, @Param("toId") String toId);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加关注信息
|
||||||
|
*
|
||||||
|
* @param fromId
|
||||||
|
* @param toId
|
||||||
|
* @param type
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Insert("insert into forum_follow (user_id, to_id, type, create_date, update_date) values(#{fromId},#{toId},#{type},now(),now())")
|
||||||
|
int saveFollow(@Param("type") Integer type, @Param("fromId") String fromId, @Param("toId") String toId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 取消关注
|
||||||
|
*
|
||||||
|
* @param fromId
|
||||||
|
* @param toId
|
||||||
|
* @param type
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Delete("delete from forum_follow where user_id= #{fromId} and to_id = #{toId} and type=#{type}")
|
||||||
|
int deleteFollow(@Param("type") Integer type, @Param("fromId") String fromId, @Param("toId") String toId);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
package com.lei.shop.forum.common.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.lei.shop.config.base.LeiPage;
|
||||||
|
import com.lei.shop.forum.common.entity.ForumMessage;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 论坛消息Mapper接口
|
||||||
|
* @className: 论坛消息
|
||||||
|
* @author: 小明
|
||||||
|
* @email:
|
||||||
|
* @create: 2023-08-15 01:59:30
|
||||||
|
*/
|
||||||
|
public interface ForumMessageMapper extends BaseMapper<ForumMessage> {
|
||||||
|
|
||||||
|
IPage<ForumMessage> listPage(@Param("page") LeiPage<ForumMessage> page);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
package com.lei.shop.forum.common.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.lei.shop.config.base.LeiPage;
|
||||||
|
import com.lei.shop.forum.common.entity.ForumModule;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 分类模块Mapper接口
|
||||||
|
* @className: 分类模块
|
||||||
|
* @author: 周
|
||||||
|
* @email:
|
||||||
|
* @create: 2023-08-10 02:46:51
|
||||||
|
*/
|
||||||
|
public interface ForumModuleMapper extends BaseMapper<ForumModule> {
|
||||||
|
|
||||||
|
IPage<ForumModule> listPage(@Param("page") LeiPage<ForumModule> page);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
package com.lei.shop.forum.common.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.lei.shop.config.base.LeiPage;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
import com.lei.shop.forum.common.entity.ForumReport;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 论坛举报Mapper接口
|
||||||
|
* @className: 论坛举报
|
||||||
|
* @author: 小明
|
||||||
|
* @email:
|
||||||
|
* @create: 2023-08-15 01:59:30
|
||||||
|
*/
|
||||||
|
public interface ForumReportMapper extends BaseMapper<ForumReport> {
|
||||||
|
|
||||||
|
IPage<ForumReport> listPage(@Param("page") LeiPage<ForumReport> page);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,25 @@
|
||||||
|
package com.lei.shop.forum.common.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.lei.shop.config.base.LeiPage;
|
||||||
|
import com.lei.shop.forum.common.entity.ForumRoundtable;
|
||||||
|
import com.lei.shop.forum.dto.roundtable.ForumRoundtableListVo;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 论坛圆桌Mapper接口
|
||||||
|
* @className: 论坛圆桌
|
||||||
|
* @author: 小明
|
||||||
|
*
|
||||||
|
* @create: 2023-08-15 01:59:30
|
||||||
|
*/
|
||||||
|
public interface ForumRoundtableMapper extends BaseMapper<ForumRoundtable> {
|
||||||
|
|
||||||
|
IPage<ForumRoundtableListVo> listPage(@Param("page") LeiPage<ForumRoundtable> page);
|
||||||
|
|
||||||
|
|
||||||
|
IPage<ForumRoundtableListVo> queryPageRoundTable(@Param("page") LeiPage<String> page);
|
||||||
|
|
||||||
|
ForumRoundtableListVo getVoById(@Param("id") String id);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
package com.lei.shop.forum.common.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.lei.shop.config.base.LeiPage;
|
||||||
|
import com.lei.shop.forum.common.entity.ForumSubject;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 主题Mapper接口
|
||||||
|
* @className: 主题
|
||||||
|
* @author: 周
|
||||||
|
* @email:
|
||||||
|
* @create: 2023-08-10 02:46:51
|
||||||
|
*/
|
||||||
|
public interface ForumSubjectMapper extends BaseMapper<ForumSubject> {
|
||||||
|
|
||||||
|
IPage<ForumSubject> listPage(@Param("page") LeiPage<ForumSubject> page);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
package com.lei.shop.forum.common.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.lei.shop.config.base.LeiPage;
|
||||||
|
import com.lei.shop.forum.common.entity.ForumUserAuth;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 用户认证信息Mapper接口
|
||||||
|
* @className: 用户认证信息
|
||||||
|
* @author: 周
|
||||||
|
* @email:
|
||||||
|
* @create: 2023-08-10 02:46:51
|
||||||
|
*/
|
||||||
|
public interface ForumUserAuthMapper extends BaseMapper<ForumUserAuth> {
|
||||||
|
|
||||||
|
IPage<ForumUserAuth> listPage(@Param("page") LeiPage<ForumUserAuth> page);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
package com.lei.shop.forum.common.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.lei.shop.forum.common.entity.ForumBlackUser;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @className: ForumBlackUserService
|
||||||
|
* @author: 周
|
||||||
|
* @email:
|
||||||
|
* @create: 2023-09-08 10:24
|
||||||
|
*/
|
||||||
|
public interface ForumBlackUserService extends IService<ForumBlackUser> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加用户黑名单
|
||||||
|
*
|
||||||
|
* @param userId
|
||||||
|
* @param toId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
boolean addBlack(String userId, String toId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 移除黑名单
|
||||||
|
*
|
||||||
|
* @param userId
|
||||||
|
* @param toId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
boolean deleteBlack(String userId, String toId);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
package com.lei.shop.forum.common.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.lei.shop.common.req.PageReqDto;
|
||||||
|
import com.lei.shop.forum.common.entity.ForumBrowseLog;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 板块浏览记录服务类
|
||||||
|
* @className: 板块浏览记录
|
||||||
|
* @author: 周
|
||||||
|
* @email:
|
||||||
|
* @create: 2023-08-30 14:20:04
|
||||||
|
*/
|
||||||
|
public interface ForumBrowseLogService extends IService<ForumBrowseLog> {
|
||||||
|
|
||||||
|
IPage<ForumBrowseLog> listPage(PageReqDto<ForumBrowseLog> t);
|
||||||
|
IPage<ForumBrowseLog> listPageBrowseNumber(PageReqDto<ForumBrowseLog> t);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加浏览量
|
||||||
|
*
|
||||||
|
* @param type
|
||||||
|
* @param userId
|
||||||
|
* @param contentId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
boolean insertBrowseLog(Integer type, String userId, String contentId);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,28 @@
|
||||||
|
package com.lei.shop.forum.common.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.lei.shop.common.req.PageReqDto;
|
||||||
|
import com.lei.shop.forum.common.entity.ForumContens;
|
||||||
|
import com.lei.shop.forum.common.entity.ForumContensFile;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 帖子-文件服务类
|
||||||
|
* @className: 帖子-文件
|
||||||
|
* @author: 周
|
||||||
|
* @email:
|
||||||
|
* @create: 2023-08-30 14:20:04
|
||||||
|
*/
|
||||||
|
public interface ForumContensFileService extends IService<ForumContensFile> {
|
||||||
|
|
||||||
|
IPage<ForumContensFile> listPage(PageReqDto<ForumContensFile> t);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加文件
|
||||||
|
* @param forumContens
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
boolean insertFile(ForumContens forumContens);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,40 @@
|
||||||
|
package com.lei.shop.forum.common.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.lei.shop.common.req.PageReqDto;
|
||||||
|
import com.lei.shop.forum.common.entity.ForumContensReview;
|
||||||
|
import com.lei.shop.forum.dto.content.ForumContensReviewSearchVO;
|
||||||
|
import com.lei.shop.forum.dto.review.ReviewSearchDto;
|
||||||
|
import com.lei.shop.forum.dto.review.ReviewVo;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 文章评论服务类
|
||||||
|
* @className: 文章评论
|
||||||
|
* @author: 周
|
||||||
|
*
|
||||||
|
* @create: 2023-08-10 02:46:51
|
||||||
|
*/
|
||||||
|
public interface ForumContensReviewService extends IService<ForumContensReview> {
|
||||||
|
|
||||||
|
IPage<ForumContensReview> listPage(PageReqDto<ForumContensReview> t);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取评论 一条
|
||||||
|
*
|
||||||
|
* @param contentId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<ForumContensReviewSearchVO> searchReviewByContentIdLimit1(String contentId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取评论
|
||||||
|
*
|
||||||
|
* @param searchDto
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
IPage<ReviewVo> queryReview(PageReqDto<ReviewSearchDto> searchDto);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,65 @@
|
||||||
|
package com.lei.shop.forum.common.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.lei.shop.common.req.PageReqDto;
|
||||||
|
import com.lei.shop.forum.common.entity.ForumContens;
|
||||||
|
import com.lei.shop.forum.dto.content.ContentInfoDto;
|
||||||
|
import com.lei.shop.forum.dto.content.ContentSearchDto;
|
||||||
|
import com.lei.shop.forum.dto.content.ContentSearchVo;
|
||||||
|
import org.springframework.scheduling.annotation.Async;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 用户文章服务类
|
||||||
|
* @className: 用户文章
|
||||||
|
* @author: 周
|
||||||
|
* @email:
|
||||||
|
* @create: 2023-08-10 02:46:50
|
||||||
|
*/
|
||||||
|
public interface ForumContensService extends IService<ForumContens> {
|
||||||
|
|
||||||
|
IPage<ForumContens> listPage(PageReqDto<ForumContens> t);
|
||||||
|
|
||||||
|
IPage<ContentSearchVo> listPageSearch(PageReqDto<ContentSearchDto> t);
|
||||||
|
IPage<ContentSearchVo> queryFollowContentIPage(PageReqDto<String> t);
|
||||||
|
IPage<ContentSearchVo> queryHotContentIPage(PageReqDto<String> t);
|
||||||
|
|
||||||
|
List<ContentSearchVo> listSearchIds(List<String> ids);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取帖子详情
|
||||||
|
*
|
||||||
|
* @param contentId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
ContentInfoDto getByContentId(String contentId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户ID
|
||||||
|
* @param userId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<ForumContens> listByUserId(String userId);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改评论数据
|
||||||
|
* @param contentId
|
||||||
|
* @param number
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Async
|
||||||
|
boolean updReviewNumber(String contentId, Integer number);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 收藏帖子
|
||||||
|
* @param t
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
IPage<ContentInfoDto> queryByUserId(PageReqDto<String> t,Integer type);
|
||||||
|
IPage<ContentInfoDto> queryContentInfoReattachment(PageReqDto<String> t,Integer type);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,79 @@
|
||||||
|
package com.lei.shop.forum.common.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.lei.shop.common.req.PageReqDto;
|
||||||
|
import com.lei.shop.forum.common.entity.ForumFollow;
|
||||||
|
import com.lei.shop.forum.dto.common.CommonSearchDto;
|
||||||
|
import com.lei.shop.forum.dto.user.UserInfo;
|
||||||
|
import com.lei.shop.forum.dto.user.UserListVo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 用户关注服务类
|
||||||
|
* @className: 用户关注
|
||||||
|
* @author: 周
|
||||||
|
* @email:
|
||||||
|
* @create: 2023-08-10 02:46:51
|
||||||
|
*/
|
||||||
|
public interface ForumFollowService extends IService<ForumFollow> {
|
||||||
|
|
||||||
|
IPage<ForumFollow> listPage(PageReqDto<ForumFollow> t);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 关注
|
||||||
|
*
|
||||||
|
* @param type 关注类型
|
||||||
|
* @param fromId 用户ID
|
||||||
|
* @param toId 被关注
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
boolean follow(Integer type, String fromId, String toId);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断是否关注
|
||||||
|
*
|
||||||
|
* @param type
|
||||||
|
* @param fromId
|
||||||
|
* @param toId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
boolean isFollow(Integer type, String fromId, String toId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取关注数
|
||||||
|
*
|
||||||
|
* @param type
|
||||||
|
* @param fromId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
long selectFollowingNumber(Integer type, String fromId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取粉丝数
|
||||||
|
*
|
||||||
|
* @param type
|
||||||
|
* @param fromId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
long selectFollowersNumber(Integer type, String fromId);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户列表
|
||||||
|
*
|
||||||
|
* @param dto
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
IPage<UserListVo> queryUserList(PageReqDto<CommonSearchDto> dto);
|
||||||
|
IPage<UserListVo> queryFollowUserList(PageReqDto<String> dto);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取用户信息
|
||||||
|
*
|
||||||
|
* @param userId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
UserInfo getUserInfo(String userId);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,25 @@
|
||||||
|
package com.lei.shop.forum.common.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.lei.shop.common.req.PageReqDto;
|
||||||
|
import com.lei.shop.forum.common.entity.ForumMessage;
|
||||||
|
import com.lei.shop.forum.dto.message.MessageToDto;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 论坛消息服务类
|
||||||
|
* @className: 论坛消息
|
||||||
|
* @author: 小明
|
||||||
|
* @email:
|
||||||
|
* @create: 2023-08-15 01:59:30
|
||||||
|
*/
|
||||||
|
public interface ForumMessageService extends IService<ForumMessage> {
|
||||||
|
|
||||||
|
IPage<ForumMessage> listPage(PageReqDto<ForumMessage> t);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送消息
|
||||||
|
* @param toDto
|
||||||
|
*/
|
||||||
|
void sendMessage(MessageToDto toDto);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,27 @@
|
||||||
|
package com.lei.shop.forum.common.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.lei.shop.common.req.PageReqDto;
|
||||||
|
import com.lei.shop.forum.common.entity.ForumModule;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 分类模块服务类
|
||||||
|
* @className: 分类模块
|
||||||
|
* @author: 周
|
||||||
|
*
|
||||||
|
* @create: 2023-08-10 02:46:51
|
||||||
|
*/
|
||||||
|
public interface ForumModuleService extends IService<ForumModule> {
|
||||||
|
|
||||||
|
IPage<ForumModule> listPage(PageReqDto<ForumModule> t);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验 模块是否存在
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
boolean isCheckModule(String id);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
package com.lei.shop.forum.common.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.lei.shop.common.req.PageReqDto;
|
||||||
|
import com.lei.shop.forum.common.entity.ForumReport;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 论坛举报服务类
|
||||||
|
* @className: 论坛举报
|
||||||
|
* @author: 小明
|
||||||
|
*
|
||||||
|
* @create: 2023-08-15 01:59:30
|
||||||
|
*/
|
||||||
|
public interface ForumReportService extends IService<ForumReport> {
|
||||||
|
|
||||||
|
IPage<ForumReport> listPage(PageReqDto<ForumReport> t);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,25 @@
|
||||||
|
package com.lei.shop.forum.common.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.lei.shop.common.req.PageReqDto;
|
||||||
|
import com.lei.shop.forum.common.entity.ForumRoundtable;
|
||||||
|
import com.lei.shop.forum.dto.roundtable.ForumRoundtableListVo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 论坛圆桌服务类
|
||||||
|
* @className: 论坛圆桌
|
||||||
|
* @author: 小明
|
||||||
|
*
|
||||||
|
* @create: 2023-08-15 01:59:30
|
||||||
|
*/
|
||||||
|
public interface ForumRoundtableService extends IService<ForumRoundtable> {
|
||||||
|
|
||||||
|
IPage<ForumRoundtableListVo> listPage(PageReqDto<ForumRoundtable> t);
|
||||||
|
|
||||||
|
|
||||||
|
ForumRoundtableListVo getVoById(String id);
|
||||||
|
|
||||||
|
IPage<ForumRoundtableListVo> queryPageRoundTable(PageReqDto<String> t);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
package com.lei.shop.forum.common.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.lei.shop.common.req.PageReqDto;
|
||||||
|
import com.lei.shop.forum.common.entity.ForumSubject;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 主题服务类
|
||||||
|
* @className: 主题
|
||||||
|
* @author: 周
|
||||||
|
*
|
||||||
|
* @create: 2023-08-10 02:46:51
|
||||||
|
*/
|
||||||
|
public interface ForumSubjectService extends IService<ForumSubject> {
|
||||||
|
|
||||||
|
IPage<ForumSubject> listPage(PageReqDto<ForumSubject> t);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,29 @@
|
||||||
|
package com.lei.shop.forum.common.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.lei.shop.common.req.PageReqDto;
|
||||||
|
import com.lei.shop.forum.common.entity.ForumUserAuth;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 用户认证信息服务类
|
||||||
|
* @className: 用户认证信息
|
||||||
|
* @author: 周
|
||||||
|
*
|
||||||
|
* @create: 2023-08-10 02:46:51
|
||||||
|
*/
|
||||||
|
public interface ForumUserAuthService extends IService<ForumUserAuth> {
|
||||||
|
|
||||||
|
IPage<ForumUserAuth> listPage(PageReqDto<ForumUserAuth> t);
|
||||||
|
|
||||||
|
ForumUserAuth getByUserId(String userId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验用户是否有认证
|
||||||
|
*
|
||||||
|
* @param userId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
boolean isCheckAuth(String userId);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,43 @@
|
||||||
|
package com.lei.shop.forum.common.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.lei.shop.forum.common.entity.ForumBlackUser;
|
||||||
|
import com.lei.shop.forum.common.mapper.ForumBlackUserMapper;
|
||||||
|
import com.lei.shop.forum.common.service.ForumBlackUserService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @className: ForumBlackUserServiceImpl
|
||||||
|
* @author: 周
|
||||||
|
* @email:
|
||||||
|
* @create: 2023-09-08 10:25
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class ForumBlackUserServiceImpl extends ServiceImpl<ForumBlackUserMapper, ForumBlackUser> implements ForumBlackUserService {
|
||||||
|
@Override
|
||||||
|
public boolean addBlack(String userId, String toId) {
|
||||||
|
|
||||||
|
Long l = baseMapper.selectCount(Wrappers.<ForumBlackUser>lambdaQuery().eq(ForumBlackUser::getUserId, userId).eq(ForumBlackUser::getToId, toId));
|
||||||
|
if (l < 0) {
|
||||||
|
|
||||||
|
ForumBlackUser user = new ForumBlackUser();
|
||||||
|
user.setUserId(userId);
|
||||||
|
user.setToId(toId);
|
||||||
|
user.insert();
|
||||||
|
|
||||||
|
ForumBlackUser userV2 = new ForumBlackUser();
|
||||||
|
userV2.setUserId(userId);
|
||||||
|
userV2.setToId(toId);
|
||||||
|
userV2.insert();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean deleteBlack(String userId, String toId) {
|
||||||
|
baseMapper.deleteBlack(userId, toId);
|
||||||
|
baseMapper.deleteBlack(toId, userId);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,63 @@
|
||||||
|
package com.lei.shop.forum.common.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.lei.shop.common.req.PageReqDto;
|
||||||
|
import com.lei.shop.config.base.LeiPage;
|
||||||
|
import com.lei.shop.forum.common.entity.ForumBrowseLog;
|
||||||
|
import com.lei.shop.forum.common.mapper.ForumBrowseLogMapper;
|
||||||
|
import com.lei.shop.forum.common.service.ForumBrowseLogService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 板块浏览记录服务实现类
|
||||||
|
* @className: 板块浏览记录
|
||||||
|
* @author: 周
|
||||||
|
* @email:
|
||||||
|
* @create: 2023-08-30 14:20:04
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class ForumBrowseLogServiceImpl extends ServiceImpl<ForumBrowseLogMapper, ForumBrowseLog> implements ForumBrowseLogService {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IPage<ForumBrowseLog> listPage(PageReqDto<ForumBrowseLog> t) {
|
||||||
|
LeiPage<ForumBrowseLog> page = new LeiPage<>(t.getPageNum(), t.getPageSize());
|
||||||
|
if (t.getSearch() != null) {
|
||||||
|
page.setSearch(t.getSearch());
|
||||||
|
}
|
||||||
|
return baseMapper.listPage(page);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IPage<ForumBrowseLog> listPageBrowseNumber(PageReqDto<ForumBrowseLog> t) {
|
||||||
|
LeiPage<ForumBrowseLog> page = new LeiPage<>(t.getPageNum(), t.getPageSize());
|
||||||
|
if (t.getSearch() != null) {
|
||||||
|
page.setSearch(t.getSearch());
|
||||||
|
}
|
||||||
|
return baseMapper.listPageBrowseNumber(page);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean insertBrowseLog(Integer type, String userId, String contentId) {
|
||||||
|
|
||||||
|
// ForumBrowseLog browseLog = baseMapper.selectOne(Wrappers.<ForumBrowseLog>lambdaQuery()
|
||||||
|
// .eq(ForumBrowseLog::getType, type)
|
||||||
|
// .eq(ForumBrowseLog::getUserId, userId)
|
||||||
|
// .eq(ForumBrowseLog::getContentId, contentId)
|
||||||
|
// );
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// if (browseLog == null) {
|
||||||
|
ForumBrowseLog browseLog = new ForumBrowseLog();
|
||||||
|
browseLog.setType(type);
|
||||||
|
browseLog.setUserId(userId);
|
||||||
|
browseLog.setContentId(contentId);
|
||||||
|
browseLog.insert();
|
||||||
|
// } else {
|
||||||
|
// browseLog.updateById();
|
||||||
|
// }
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,74 @@
|
||||||
|
package com.lei.shop.forum.common.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import cn.hutool.json.JSONArray;
|
||||||
|
import cn.hutool.json.JSONObject;
|
||||||
|
import cn.hutool.json.JSONUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.lei.shop.common.req.PageReqDto;
|
||||||
|
import com.lei.shop.config.base.LeiPage;
|
||||||
|
import com.lei.shop.forum.common.entity.ForumContens;
|
||||||
|
import com.lei.shop.forum.common.entity.ForumContensFile;
|
||||||
|
import com.lei.shop.forum.common.mapper.ForumContensFileMapper;
|
||||||
|
import com.lei.shop.forum.common.service.ForumContensFileService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 帖子-文件服务实现类
|
||||||
|
* @className: 帖子-文件
|
||||||
|
* @author: 周
|
||||||
|
* @email:
|
||||||
|
* @create: 2023-08-30 14:20:04
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class ForumContensFileServiceImpl extends ServiceImpl<ForumContensFileMapper, ForumContensFile> implements ForumContensFileService {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IPage<ForumContensFile> listPage(PageReqDto<ForumContensFile> t) {
|
||||||
|
LeiPage<ForumContensFile> page = new LeiPage<>(t.getPageNum(), t.getPageSize());
|
||||||
|
if (t.getSearch() != null) {
|
||||||
|
page.setSearch(t.getSearch());
|
||||||
|
}
|
||||||
|
return baseMapper.listPage(page);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean insertFile(ForumContens forumContens) {
|
||||||
|
List<ForumContensFile> forumContensFileList = baseMapper.selectList(Wrappers.<ForumContensFile>lambdaQuery().eq(ForumContensFile::getContentId, forumContens.getId()));
|
||||||
|
if (!forumContensFileList.isEmpty()) {
|
||||||
|
baseMapper.delete(Wrappers.<ForumContensFile>lambdaQuery().eq(ForumContensFile::getContentId, forumContens.getId()));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (StringUtils.isNotBlank(forumContens.getFileUrl())) {
|
||||||
|
|
||||||
|
JSONArray jsonArray = JSONUtil.parseArray(forumContens.getFileUrl());
|
||||||
|
|
||||||
|
jsonArray.forEach(obj -> {
|
||||||
|
JSONObject item = (JSONObject) obj;
|
||||||
|
ForumContensFile file = new ForumContensFile();
|
||||||
|
file.setUserId(forumContens.getUserId());
|
||||||
|
file.setContentId(forumContens.getId());
|
||||||
|
file.setContentName(forumContens.getTitles());
|
||||||
|
file.setFileUrl(item.getStr("url"));
|
||||||
|
// file.setFileName(forumContens.getTitles() + "-" + DateUtil.format(new Date(), "yyyy-MM-dd"));
|
||||||
|
String name = item.getStr("name");
|
||||||
|
if (org.apache.commons.lang3.StringUtils.isBlank(name)) {
|
||||||
|
name = forumContens.getTitles() + "-" + DateUtil.format(new Date(), "yyyy-MM-dd");
|
||||||
|
}
|
||||||
|
file.setFileName(name);
|
||||||
|
file.insert();
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue