16 changed files with 327 additions and 6 deletions
@ -0,0 +1,28 @@ |
|||||
|
package cn.nla.common.config; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.annotation.DbType; |
||||
|
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; |
||||
|
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; |
||||
|
import org.springframework.context.annotation.Bean; |
||||
|
import org.springframework.context.annotation.Configuration; |
||||
|
|
||||
|
@Configuration |
||||
|
public class MybatisPlusPageConfig { |
||||
|
// 旧版本配置
|
||||
|
// @Bean
|
||||
|
// public PaginationInterceptorpaginationInterceptor() {
|
||||
|
// return new PaginationInterceptor();
|
||||
|
// }
|
||||
|
/** |
||||
|
* 新的分⻚插件,⼀缓和⼆缓遵循mybatis的规则, |
||||
|
* 需要设置 |
||||
|
* MybatisConfiguration#useDeprecatedExecutor = |
||||
|
* false 避免缓存出现问题 |
||||
|
*/ |
||||
|
@Bean |
||||
|
public MybatisPlusInterceptor mybatisPlusInterceptor() { |
||||
|
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); |
||||
|
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL)); |
||||
|
return interceptor; |
||||
|
} |
||||
|
} |
@ -0,0 +1,16 @@ |
|||||
|
package cn.nla.common.enums; |
||||
|
|
||||
|
public enum CouponCategoryEnum { |
||||
|
/** |
||||
|
* 新人注册 |
||||
|
*/ |
||||
|
NEW_USER, |
||||
|
/** |
||||
|
* 活动任务 |
||||
|
*/ |
||||
|
TASK, |
||||
|
/** |
||||
|
* 促销劵 |
||||
|
*/ |
||||
|
PROMOTION |
||||
|
} |
@ -0,0 +1,19 @@ |
|||||
|
package cn.nla.common.enums; |
||||
|
|
||||
|
/** |
||||
|
* 优惠券状态 |
||||
|
*/ |
||||
|
public enum CouponPublishEnum { |
||||
|
/** |
||||
|
* 线上 |
||||
|
*/ |
||||
|
PUBLISH, |
||||
|
/** |
||||
|
* 草稿 |
||||
|
*/ |
||||
|
DRAFT, |
||||
|
/** |
||||
|
* 下线 |
||||
|
*/ |
||||
|
OFFLINE |
||||
|
} |
@ -0,0 +1,20 @@ |
|||||
|
package cn.nla.common.enums; |
||||
|
|
||||
|
public enum CouponStateEnum { |
||||
|
|
||||
|
/** |
||||
|
* 新的可用 |
||||
|
*/ |
||||
|
NEW, |
||||
|
|
||||
|
/** |
||||
|
* 已经使用 |
||||
|
*/ |
||||
|
USED, |
||||
|
|
||||
|
/** |
||||
|
* 过期 |
||||
|
*/ |
||||
|
EXPIRED |
||||
|
|
||||
|
} |
@ -0,0 +1,28 @@ |
|||||
|
<?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>nla-shop</artifactId> |
||||
|
<groupId>cn.nla</groupId> |
||||
|
<version>1.0-SNAPSHOT</version> |
||||
|
</parent> |
||||
|
<modelVersion>4.0.0</modelVersion> |
||||
|
<artifactId>nla-coupon-service</artifactId> |
||||
|
<description>优惠券服务模块</description> |
||||
|
<properties> |
||||
|
<maven.compiler.source>11</maven.compiler.source> |
||||
|
<maven.compiler.target>11</maven.compiler.target> |
||||
|
</properties> |
||||
|
<dependencies> |
||||
|
<dependency> |
||||
|
<groupId>cn.nla</groupId> |
||||
|
<artifactId>nla-common</artifactId> |
||||
|
<version>1.0-SNAPSHOT</version> |
||||
|
</dependency> |
||||
|
<dependency> |
||||
|
<groupId>org.projectlombok</groupId> |
||||
|
<artifactId>lombok</artifactId> |
||||
|
</dependency> |
||||
|
</dependencies> |
||||
|
</project> |
@ -0,0 +1,15 @@ |
|||||
|
package cn.nla.coupon; |
||||
|
|
||||
|
import org.mybatis.spring.annotation.MapperScan; |
||||
|
import org.springframework.boot.SpringApplication; |
||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication; |
||||
|
import org.springframework.context.annotation.ComponentScan; |
||||
|
|
||||
|
@SpringBootApplication |
||||
|
@MapperScan("cn.nla.*.mapper") |
||||
|
@ComponentScan(basePackages = {"cn.nla.*"}) |
||||
|
public class CouponApplication { |
||||
|
public static void main(String[] args) { |
||||
|
SpringApplication.run(CouponApplication.class, args); |
||||
|
} |
||||
|
} |
@ -0,0 +1,65 @@ |
|||||
|
package cn.nla.coupon.model.VO; |
||||
|
|
||||
|
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
|
import com.fasterxml.jackson.annotation.JsonProperty; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.math.BigDecimal; |
||||
|
import java.util.Date; |
||||
|
|
||||
|
@Data |
||||
|
public class CouponVO { |
||||
|
/** |
||||
|
* id |
||||
|
*/ |
||||
|
private Long id; |
||||
|
/** |
||||
|
* 优惠卷类型[NEW_USER注册赠券,TASK任务卷,PROMOTION促销劵] |
||||
|
*/ |
||||
|
private String category; |
||||
|
/** |
||||
|
* 优惠券图片 |
||||
|
*/ |
||||
|
@JsonProperty("coupon_img") |
||||
|
private String couponImg; |
||||
|
/** |
||||
|
* 优惠券标题 |
||||
|
*/ |
||||
|
@JsonProperty("coupon_title") |
||||
|
private String couponTitle; |
||||
|
/** |
||||
|
* 抵扣价格 |
||||
|
*/ |
||||
|
private BigDecimal price; |
||||
|
/** |
||||
|
* 每人限制张数 |
||||
|
*/ |
||||
|
@JsonProperty("user_limit") |
||||
|
private Integer userLimit; |
||||
|
/** |
||||
|
* 优惠券开始有效时间 |
||||
|
*/ |
||||
|
@JsonFormat(pattern = "yyyy-MM-dd hh:mm:ss",locale = "zh",timezone = "GMT+8") |
||||
|
@JsonProperty("start_time") |
||||
|
private Date startTime; |
||||
|
/** |
||||
|
* 优惠券失效时间 |
||||
|
*/ |
||||
|
@JsonFormat(pattern = "yyyy-MM-dd hh:mm:ss",locale = "zh",timezone = "GMT+8") |
||||
|
@JsonProperty("end_time") |
||||
|
private Date endTime; |
||||
|
/** |
||||
|
* 优惠券总量 |
||||
|
*/ |
||||
|
@JsonProperty("publish_count") |
||||
|
private Integer publishCount; |
||||
|
/** |
||||
|
* 库存 |
||||
|
*/ |
||||
|
private Integer stock; |
||||
|
/** |
||||
|
* 满多少才可以使用 |
||||
|
*/ |
||||
|
@JsonProperty("condition_price") |
||||
|
private BigDecimal conditionPrice; |
||||
|
} |
@ -0,0 +1,21 @@ |
|||||
|
server: |
||||
|
port: 9002 |
||||
|
spring: |
||||
|
application: |
||||
|
name: nla-coupon-service |
||||
|
#数据库配置 |
||||
|
datasource: |
||||
|
driver-class-name: com.mysql.cj.jdbc.Driver |
||||
|
url: jdbc:mysql://117.72.43.105:3306/p_nla_coupon?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai |
||||
|
username: root |
||||
|
password: Yuan625621105. |
||||
|
#配置plus打印sql⽇志 |
||||
|
mybatis-plus: |
||||
|
configuration: |
||||
|
log-impl: |
||||
|
org.apache.ibatis.logging.stdout.StdOutImpl |
||||
|
#设置⽇志级别,ERROR/WARN/INFO/DEBUG,默认是INFO以上才显示 |
||||
|
#logging: |
||||
|
# level: |
||||
|
# root: INFO |
||||
|
|
@ -0,0 +1,71 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
<configuration scan="true" scanPeriod="60 seconds" debug="false"> |
||||
|
<!-- 自定义配置: 日志存放路径 --> |
||||
|
<property name="log.path" value="./logs/nla-coupon-service"/> |
||||
|
<!-- 日志输出格式 --> |
||||
|
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n"/> |
||||
|
<!-- 控制台输出 --> |
||||
|
<appender name="console" class="ch.qos.logback.core.ConsoleAppender"> |
||||
|
<encoder> |
||||
|
<pattern>${log.pattern}</pattern> |
||||
|
</encoder> |
||||
|
</appender> |
||||
|
<!-- 系统日志输出 --> |
||||
|
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender"> |
||||
|
<file>${log.path}/info.log</file> |
||||
|
<!-- 循环政策:基于时间创建日志文件 --> |
||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> |
||||
|
<!-- 日志文件名格式 --> |
||||
|
<fileNamePattern>${log.path}/info.%d{yyyy-MM-dd}.log</fileNamePattern> |
||||
|
<!-- 日志最大的历史 60天 --> |
||||
|
<maxHistory>60</maxHistory> |
||||
|
</rollingPolicy> |
||||
|
<encoder> |
||||
|
<pattern>${log.pattern}</pattern> |
||||
|
</encoder> |
||||
|
<filter class="ch.qos.logback.classic.filter.LevelFilter"> |
||||
|
<!-- 过滤的级别 --> |
||||
|
<level>INFO</level> |
||||
|
<!-- 匹配时的操作:接收(记录) --> |
||||
|
<onMatch>ACCEPT</onMatch> |
||||
|
<!-- 不匹配时的操作:拒绝(不记录) --> |
||||
|
<onMismatch>DENY</onMismatch> |
||||
|
</filter> |
||||
|
</appender> |
||||
|
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender"> |
||||
|
<file>${log.path}/error.log</file> |
||||
|
<!-- 循环政策:基于时间创建日志文件 --> |
||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> |
||||
|
<!-- 日志文件名格式 --> |
||||
|
<fileNamePattern>${log.path}/error.%d{yyyy-MM-dd}.log</fileNamePattern> |
||||
|
<!-- 日志最大的历史 60天 --> |
||||
|
<maxHistory>60</maxHistory> |
||||
|
</rollingPolicy> |
||||
|
<encoder> |
||||
|
<pattern>${log.pattern}</pattern> |
||||
|
</encoder> |
||||
|
<filter class="ch.qos.logback.classic.filter.LevelFilter"> |
||||
|
<!-- 过滤的级别 --> |
||||
|
<level>ERROR</level> |
||||
|
<!-- 匹配时的操作:接收(记录) --> |
||||
|
<onMatch>ACCEPT</onMatch> |
||||
|
<!-- 不匹配时的操作:拒绝(不记录) --> |
||||
|
<onMismatch>DENY</onMismatch> |
||||
|
</filter> |
||||
|
</appender> |
||||
|
<!-- 自定义配置: 系统模块日志级别控制 --> |
||||
|
<logger name="cn.nla" level="info"/> |
||||
|
<!-- Spring日志级别控制 --> |
||||
|
<logger name="org.springframework" level="warn"/> |
||||
|
<logger name="io.lettuce.core.protocol" level="ERROR"/> |
||||
|
<!--自定义配置: mapper打印--> |
||||
|
<logger name="cn.nla.coupon.mapper" level="DEBUG"/> |
||||
|
<root level="info"> |
||||
|
<appender-ref ref="console"/> |
||||
|
</root> |
||||
|
<!--系统操作日志--> |
||||
|
<root level="info"> |
||||
|
<appender-ref ref="file_info"/> |
||||
|
<appender-ref ref="file_error"/> |
||||
|
</root> |
||||
|
</configuration> |
Loading…
Reference in new issue