Commit 3c5917a6cd8de2cce82ffb506f71ec34d0c89a6b

Authored by owen
2 parents a9e82276 ac55a965

Merge remote-tracking branch 'origin/feature/mall_product' into feature/mall_product

Showing 55 changed files with 269 additions and 431 deletions
yudao-framework/yudao-spring-boot-starter-job/src/main/java/cn/iocoder/yudao/framework/quartz/config/YudaoQuartzAutoConfiguration.java
1 package cn.iocoder.yudao.framework.quartz.config; 1 package cn.iocoder.yudao.framework.quartz.config;
2 2
3 -import cn.iocoder.yudao.framework.quartz.core.job.JobLogJobHandler;  
4 -import cn.iocoder.yudao.framework.quartz.core.job.LogJobProperties;  
5 import cn.iocoder.yudao.framework.quartz.core.scheduler.SchedulerManager; 3 import cn.iocoder.yudao.framework.quartz.core.scheduler.SchedulerManager;
6 import lombok.extern.slf4j.Slf4j; 4 import lombok.extern.slf4j.Slf4j;
7 import org.quartz.Scheduler; 5 import org.quartz.Scheduler;
8 import org.springframework.boot.autoconfigure.AutoConfiguration; 6 import org.springframework.boot.autoconfigure.AutoConfiguration;
9 -import org.springframework.boot.context.properties.EnableConfigurationProperties;  
10 import org.springframework.context.annotation.Bean; 7 import org.springframework.context.annotation.Bean;
11 import org.springframework.scheduling.annotation.EnableScheduling; 8 import org.springframework.scheduling.annotation.EnableScheduling;
12 9
@@ -18,7 +15,6 @@ import java.util.Optional; @@ -18,7 +15,6 @@ import java.util.Optional;
18 @AutoConfiguration 15 @AutoConfiguration
19 @EnableScheduling // 开启 Spring 自带的定时任务 16 @EnableScheduling // 开启 Spring 自带的定时任务
20 @Slf4j 17 @Slf4j
21 -@EnableConfigurationProperties(LogJobProperties.class)  
22 public class YudaoQuartzAutoConfiguration { 18 public class YudaoQuartzAutoConfiguration {
23 19
24 @Bean 20 @Bean
@@ -30,10 +26,4 @@ public class YudaoQuartzAutoConfiguration { @@ -30,10 +26,4 @@ public class YudaoQuartzAutoConfiguration {
30 return new SchedulerManager(scheduler.get()); 26 return new SchedulerManager(scheduler.get());
31 } 27 }
32 28
33 - // TODO @j-sentinel:这个 job,先拿到 infra biz 里面实现哈;  
34 - @Bean  
35 - public JobLogJobHandler jobLogJobHandler(LogJobProperties logJobProperties){  
36 - return new JobLogJobHandler(logJobProperties);  
37 - }  
38 -  
39 } 29 }
yudao-framework/yudao-spring-boot-starter-job/src/main/java/cn/iocoder/yudao/framework/quartz/core/job/JobLogJobHandler.java deleted
1 -package cn.iocoder.yudao.framework.quartz.core.job;  
2 -  
3 -import cn.iocoder.yudao.framework.quartz.core.handler.JobHandler;  
4 -import cn.iocoder.yudao.framework.quartz.core.service.JobLogFrameworkService;  
5 -import lombok.AllArgsConstructor;  
6 -import lombok.extern.slf4j.Slf4j;  
7 -  
8 -import javax.annotation.Resource;  
9 -  
10 -// TODO @j-sentinel:名字和项目里其它保持统一,可以叫 JobLogCleanJob,不用带 handler 哈  
11 -/**  
12 - * // TODO @j-sentinel:要写下类注释噢,就是这个类要干啥;然后下面两个应该是 @author 和 @since  
13 - * @Author: j-sentinel  
14 - * @Date: 2023/9/30 20:40  
15 - */  
16 -@Slf4j  
17 -@AllArgsConstructor  
18 -public class JobLogJobHandler implements JobHandler {  
19 -  
20 - private LogJobProperties logJobProperties;  
21 -  
22 - public JobLogJobHandler(LogJobProperties logJobProperties) {  
23 - this.logJobProperties = logJobProperties;  
24 - }  
25 -  
26 - @Resource  
27 - private JobLogFrameworkService jobLogFrameworkService;  
28 -  
29 - @Override  
30 - public String execute(String param) throws Exception {  
31 - Integer integer = jobLogFrameworkService.timingJobCleanLog(logJobProperties.getJobCleanRetainDay());  
32 - log.info("定时执行清理定时任务日志数量({})个",integer);  
33 - return String.format("定时执行清理定时任务日志数量 %s 个", integer);  
34 - }  
35 -}  
yudao-framework/yudao-spring-boot-starter-job/src/main/java/cn/iocoder/yudao/framework/quartz/core/job/LogJobProperties.java deleted
1 -package cn.iocoder.yudao.framework.quartz.core.job;  
2 -  
3 -import lombok.Data;  
4 -import org.springframework.boot.context.properties.ConfigurationProperties;  
5 -  
6 -// TODO @j-sentinel:这个配置类,先暂时不做,每个 Job 里面定一个静态类。其实不是所有的变量,都需要配置化,因为它本身基本也不会改动。  
7 -/**  
8 - * @Author: j-sentinel  
9 - * @Date: 2023/9/30 16:17  
10 - */  
11 -@Data  
12 -@ConfigurationProperties(prefix = "yudao.clean-job")  
13 -public class LogJobProperties {  
14 -  
15 - private int accessRetainDay = 7;  
16 -  
17 - private int errorRetainDay = 8;  
18 -  
19 - private int jobCleanRetainDay = 7;  
20 -  
21 -}  
yudao-framework/yudao-spring-boot-starter-job/src/main/java/cn/iocoder/yudao/framework/quartz/core/service/JobLogFrameworkService.java
@@ -40,11 +40,4 @@ public interface JobLogFrameworkService { @@ -40,11 +40,4 @@ public interface JobLogFrameworkService {
40 @NotNull(message = "结束时间不能为空") LocalDateTime endTime, 40 @NotNull(message = "结束时间不能为空") LocalDateTime endTime,
41 @NotNull(message = "运行时长不能为空") Integer duration, 41 @NotNull(message = "运行时长不能为空") Integer duration,
42 boolean success, String result); 42 boolean success, String result);
43 -  
44 - /**  
45 - * 清理 @param jobCleanRetainDay 天的访问日志  
46 - *  
47 - * @param jobCleanRetainDay 超过多少天就进行清理  
48 - */  
49 - Integer timingJobCleanLog(Integer jobCleanRetainDay);  
50 } 43 }
yudao-framework/yudao-spring-boot-starter-web/pom.xml
@@ -61,12 +61,6 @@ @@ -61,12 +61,6 @@
61 <artifactId>jsoup</artifactId> 61 <artifactId>jsoup</artifactId>
62 </dependency> 62 </dependency>
63 63
64 - <!-- Job 定时任务相关 -->  
65 - <!-- TODO @j-sentinel:去掉这个依赖哈; -->  
66 - <dependency>  
67 - <groupId>cn.iocoder.boot</groupId>  
68 - <artifactId>yudao-spring-boot-starter-job</artifactId>  
69 - </dependency>  
70 </dependencies> 64 </dependencies>
71 65
72 </project> 66 </project>
yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/config/YudaoApiLogAutoConfiguration.java
1 package cn.iocoder.yudao.framework.apilog.config; 1 package cn.iocoder.yudao.framework.apilog.config;
2 2
3 import cn.iocoder.yudao.framework.apilog.core.filter.ApiAccessLogFilter; 3 import cn.iocoder.yudao.framework.apilog.core.filter.ApiAccessLogFilter;
4 -import cn.iocoder.yudao.framework.apilog.core.job.ApiAccessLogJobHandler;  
5 -import cn.iocoder.yudao.framework.apilog.core.job.ApiErrorLogJobHandler;  
6 import cn.iocoder.yudao.framework.apilog.core.service.ApiAccessLogFrameworkService; 4 import cn.iocoder.yudao.framework.apilog.core.service.ApiAccessLogFrameworkService;
7 import cn.iocoder.yudao.framework.apilog.core.service.ApiAccessLogFrameworkServiceImpl; 5 import cn.iocoder.yudao.framework.apilog.core.service.ApiAccessLogFrameworkServiceImpl;
8 import cn.iocoder.yudao.framework.apilog.core.service.ApiErrorLogFrameworkService; 6 import cn.iocoder.yudao.framework.apilog.core.service.ApiErrorLogFrameworkService;
9 import cn.iocoder.yudao.framework.apilog.core.service.ApiErrorLogFrameworkServiceImpl; 7 import cn.iocoder.yudao.framework.apilog.core.service.ApiErrorLogFrameworkServiceImpl;
10 import cn.iocoder.yudao.framework.common.enums.WebFilterOrderEnum; 8 import cn.iocoder.yudao.framework.common.enums.WebFilterOrderEnum;
11 -import cn.iocoder.yudao.framework.quartz.core.job.LogJobProperties;  
12 import cn.iocoder.yudao.framework.web.config.WebProperties; 9 import cn.iocoder.yudao.framework.web.config.WebProperties;
13 import cn.iocoder.yudao.framework.web.config.YudaoWebAutoConfiguration; 10 import cn.iocoder.yudao.framework.web.config.YudaoWebAutoConfiguration;
14 import cn.iocoder.yudao.module.infra.api.logger.ApiAccessLogApi; 11 import cn.iocoder.yudao.module.infra.api.logger.ApiAccessLogApi;
@@ -34,16 +31,6 @@ public class YudaoApiLogAutoConfiguration { @@ -34,16 +31,6 @@ public class YudaoApiLogAutoConfiguration {
34 return new ApiErrorLogFrameworkServiceImpl(apiErrorLogApi); 31 return new ApiErrorLogFrameworkServiceImpl(apiErrorLogApi);
35 } 32 }
36 33
37 - @Bean  
38 - public ApiAccessLogJobHandler apiAccessLogJobHandler(LogJobProperties logJobProperties) {  
39 - return new ApiAccessLogJobHandler(logJobProperties);  
40 - }  
41 -  
42 - @Bean  
43 - public ApiErrorLogJobHandler apiErrorLogJobHandler(LogJobProperties logJobProperties) {  
44 - return new ApiErrorLogJobHandler(logJobProperties);  
45 - }  
46 -  
47 /** 34 /**
48 * 创建 ApiAccessLogFilter Bean,记录 API 请求日志 35 * 创建 ApiAccessLogFilter Bean,记录 API 请求日志
49 */ 36 */
yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/job/ApiAccessLogJobHandler.java deleted
1 -package cn.iocoder.yudao.framework.apilog.core.job;  
2 -  
3 -import cn.iocoder.yudao.framework.apilog.core.service.ApiAccessLogFrameworkService;  
4 -import cn.iocoder.yudao.framework.quartz.core.handler.JobHandler;  
5 -import cn.iocoder.yudao.framework.quartz.core.job.LogJobProperties;  
6 -import lombok.AllArgsConstructor;  
7 -import lombok.extern.slf4j.Slf4j;  
8 -  
9 -import javax.annotation.Resource;  
10 -  
11 -// TODO @j-sentinel:同 JobLogJobHandler  
12 -/**  
13 - * @Author: j-sentinel  
14 - * @Date: 2023/9/30 16:13  
15 - */  
16 -@Slf4j  
17 -@AllArgsConstructor  
18 -public class ApiAccessLogJobHandler implements JobHandler {  
19 -  
20 - private LogJobProperties logJobProperties;  
21 -  
22 - public ApiAccessLogJobHandler(LogJobProperties logJobProperties) {  
23 - this.logJobProperties = logJobProperties;  
24 - }  
25 -  
26 - @Resource  
27 - private ApiAccessLogFrameworkService apiAccessLogFrameworkService;  
28 -  
29 - @Override  
30 - public String execute(String param) throws Exception {  
31 - apiAccessLogFrameworkService.jobCleanAccessLog(logJobProperties.getAccessRetainDay());  
32 - return "";  
33 - }  
34 -  
35 -}  
yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/job/ApiErrorLogJobHandler.java deleted
1 -package cn.iocoder.yudao.framework.apilog.core.job;  
2 -  
3 -import cn.iocoder.yudao.framework.apilog.core.service.ApiErrorLogFrameworkService;  
4 -import cn.iocoder.yudao.framework.quartz.core.handler.JobHandler;  
5 -import cn.iocoder.yudao.framework.quartz.core.job.LogJobProperties;  
6 -import lombok.AllArgsConstructor;  
7 -import lombok.extern.slf4j.Slf4j;  
8 -  
9 -import javax.annotation.Resource;  
10 -  
11 -// TODO @j-sentinel:同 JobLogJobHandler  
12 -/**  
13 - * @Author: j-sentinel  
14 - * @Date: 2023/9/30 16:13  
15 - */  
16 -@Slf4j  
17 -@AllArgsConstructor  
18 -public class ApiErrorLogJobHandler implements JobHandler {  
19 -  
20 - private LogJobProperties logJobProperties;  
21 -  
22 - public ApiErrorLogJobHandler(LogJobProperties logJobProperties) {  
23 - this.logJobProperties = logJobProperties;  
24 - }  
25 -  
26 - @Resource  
27 - private ApiErrorLogFrameworkService apiErrorLogFrameworkService;  
28 -  
29 - @Override  
30 - public String execute(String param) throws Exception {  
31 - apiErrorLogFrameworkService.jobCleanErrorLog(logJobProperties.getErrorRetainDay());  
32 - return "";  
33 - }  
34 -  
35 -}  
yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/service/ApiAccessLogFrameworkService.java
@@ -13,11 +13,4 @@ public interface ApiAccessLogFrameworkService { @@ -13,11 +13,4 @@ public interface ApiAccessLogFrameworkService {
13 * @param apiAccessLog API 访问日志 13 * @param apiAccessLog API 访问日志
14 */ 14 */
15 void createApiAccessLog(ApiAccessLog apiAccessLog); 15 void createApiAccessLog(ApiAccessLog apiAccessLog);
16 -  
17 - /**  
18 - * 清理 @param accessLogJobDay 天的访问日志  
19 - *  
20 - * @param accessLogJobDay 超过多少天就进行清理  
21 - */  
22 - void jobCleanAccessLog(Integer accessLogJobDay);  
23 } 16 }
yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/service/ApiAccessLogFrameworkServiceImpl.java
@@ -25,9 +25,4 @@ public class ApiAccessLogFrameworkServiceImpl implements ApiAccessLogFrameworkSe @@ -25,9 +25,4 @@ public class ApiAccessLogFrameworkServiceImpl implements ApiAccessLogFrameworkSe
25 apiAccessLogApi.createApiAccessLog(reqDTO); 25 apiAccessLogApi.createApiAccessLog(reqDTO);
26 } 26 }
27 27
28 - @Override  
29 - public void jobCleanAccessLog(Integer accessLogJobDay) {  
30 - apiAccessLogApi.jobCleanAccessLog(accessLogJobDay);  
31 - }  
32 -  
33 } 28 }
yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/service/ApiErrorLogFrameworkService.java
@@ -13,11 +13,4 @@ public interface ApiErrorLogFrameworkService { @@ -13,11 +13,4 @@ public interface ApiErrorLogFrameworkService {
13 * @param apiErrorLog API 错误日志 13 * @param apiErrorLog API 错误日志
14 */ 14 */
15 void createApiErrorLog(ApiErrorLog apiErrorLog); 15 void createApiErrorLog(ApiErrorLog apiErrorLog);
16 -  
17 - /**  
18 - * 清理 @param errorLogJobDay 天的访问日志  
19 - *  
20 - * @param errorLogJobDay 超过多少天就进行清理  
21 - */  
22 - void jobCleanErrorLog(Integer errorLogJobDay);  
23 } 16 }
yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/service/ApiErrorLogFrameworkServiceImpl.java
@@ -25,9 +25,4 @@ public class ApiErrorLogFrameworkServiceImpl implements ApiErrorLogFrameworkServ @@ -25,9 +25,4 @@ public class ApiErrorLogFrameworkServiceImpl implements ApiErrorLogFrameworkServ
25 apiErrorLogApi.createApiErrorLog(reqDTO); 25 apiErrorLogApi.createApiErrorLog(reqDTO);
26 } 26 }
27 27
28 - @Override  
29 - public void jobCleanErrorLog(Integer errorLogJobDay) {  
30 - apiErrorLogApi.jobCleanErrorLog(errorLogJobDay);  
31 - }  
32 -  
33 } 28 }
yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/api/logger/ApiAccessLogApi.java
@@ -18,12 +18,4 @@ public interface ApiAccessLogApi { @@ -18,12 +18,4 @@ public interface ApiAccessLogApi {
18 */ 18 */
19 void createApiAccessLog(@Valid ApiAccessLogCreateReqDTO createDTO); 19 void createApiAccessLog(@Valid ApiAccessLogCreateReqDTO createDTO);
20 20
21 - // TODO @j-sentinel:这个我们先提供接口在 API,而是 infra 模块自己清理先哈;  
22 - /**  
23 - * 清理 @param accessLogJobDay 天的访问日志  
24 - *  
25 - * @param accessLogJobDay 超过多少天就进行清理  
26 - */  
27 - void jobCleanAccessLog(Integer accessLogJobDay);  
28 -  
29 } 21 }
yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/api/logger/ApiErrorLogApi.java
@@ -18,12 +18,4 @@ public interface ApiErrorLogApi { @@ -18,12 +18,4 @@ public interface ApiErrorLogApi {
18 */ 18 */
19 void createApiErrorLog(@Valid ApiErrorLogCreateReqDTO createDTO); 19 void createApiErrorLog(@Valid ApiErrorLogCreateReqDTO createDTO);
20 20
21 - // TODO @j-sentinel:这个我们先提供接口在 API,而是 infra 模块自己清理先哈;  
22 - /**  
23 - * 清理 @param errorLogJobDay 天的访问日志  
24 - *  
25 - * @param errorLogJobDay 超过多少天就进行清理  
26 - */  
27 - void jobCleanErrorLog(Integer errorLogJobDay);  
28 -  
29 } 21 }
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/api/logger/ApiAccessLogApiImpl.java
@@ -24,9 +24,4 @@ public class ApiAccessLogApiImpl implements ApiAccessLogApi { @@ -24,9 +24,4 @@ public class ApiAccessLogApiImpl implements ApiAccessLogApi {
24 apiAccessLogService.createApiAccessLog(createDTO); 24 apiAccessLogService.createApiAccessLog(createDTO);
25 } 25 }
26 26
27 - @Override  
28 - public void jobCleanAccessLog(Integer accessLogJobDay) {  
29 - apiAccessLogService.jobCleanAccessLog(accessLogJobDay);  
30 - }  
31 -  
32 } 27 }
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/api/logger/ApiErrorLogApiImpl.java
@@ -24,9 +24,4 @@ public class ApiErrorLogApiImpl implements ApiErrorLogApi { @@ -24,9 +24,4 @@ public class ApiErrorLogApiImpl implements ApiErrorLogApi {
24 apiErrorLogService.createApiErrorLog(createDTO); 24 apiErrorLogService.createApiErrorLog(createDTO);
25 } 25 }
26 26
27 - @Override  
28 - public void jobCleanErrorLog(Integer errorLogJobDay) {  
29 - apiErrorLogService.jobCleanErrorLog(errorLogJobDay);  
30 - }  
31 -  
32 } 27 }
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/job/JobLogMapper.java
@@ -6,9 +6,11 @@ import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; @@ -6,9 +6,11 @@ import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
6 import cn.iocoder.yudao.module.infra.controller.admin.job.vo.log.JobLogExportReqVO; 6 import cn.iocoder.yudao.module.infra.controller.admin.job.vo.log.JobLogExportReqVO;
7 import cn.iocoder.yudao.module.infra.controller.admin.job.vo.log.JobLogPageReqVO; 7 import cn.iocoder.yudao.module.infra.controller.admin.job.vo.log.JobLogPageReqVO;
8 import cn.iocoder.yudao.module.infra.dal.dataobject.job.JobLogDO; 8 import cn.iocoder.yudao.module.infra.dal.dataobject.job.JobLogDO;
  9 +import org.apache.ibatis.annotations.Delete;
9 import org.apache.ibatis.annotations.Mapper; 10 import org.apache.ibatis.annotations.Mapper;
10 import org.apache.ibatis.annotations.Param; 11 import org.apache.ibatis.annotations.Param;
11 12
  13 +import java.time.LocalDateTime;
12 import java.util.List; 14 import java.util.List;
13 15
14 /** 16 /**
@@ -41,12 +43,14 @@ public interface JobLogMapper extends BaseMapperX&lt;JobLogDO&gt; { @@ -41,12 +43,14 @@ public interface JobLogMapper extends BaseMapperX&lt;JobLogDO&gt; {
41 ); 43 );
42 } 44 }
43 45
44 - // TODO @j-sentinel:一般来说,我们 mapper 只提供 crud 的操作,所以这个方法的命名,建议是 deleteByCreateTimeLt;  
45 - // 然后,参数是 (crateTime, count),由 service 传入  
46 - // 这里为什么有 lt 呢,这个其实是延续 spring data 的 method 描述的命名习惯,lt 表示小于;  
47 - // 另外,timingJobCleanLog 的具体 sql 这么写,性能是比较差的;可以直接 delete * from job_log where create_time < xxx order by id limit 100;  
48 - Integer timingJobCleanLog(@Param("jobCleanRetainDay") Integer jobCleanRetainDay); 46 + /**
  47 + * 物理删除指定时间之前的日志
  48 + *
  49 + * @param createTime 最大时间
  50 + * @param limit 删除条数,防止一次删除太多
  51 + * @return 删除条数
  52 + */
  53 + @Delete("DELETE FROM infra_job_log WHERE create_time < #{createTime} LIMIT #{limit}")
  54 + Integer deleteByCreateTimeLt(@Param("createTime") LocalDateTime createTime, @Param("limit") Integer limit);
49 55
50 - // TODO @j-serntinel:optimize table infra_job_log 就可以啦?  
51 - void optimizeTable();  
52 } 56 }
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/logger/ApiAccessLogMapper.java
@@ -6,9 +6,11 @@ import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; @@ -6,9 +6,11 @@ import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
6 import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apiaccesslog.ApiAccessLogExportReqVO; 6 import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apiaccesslog.ApiAccessLogExportReqVO;
7 import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apiaccesslog.ApiAccessLogPageReqVO; 7 import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apiaccesslog.ApiAccessLogPageReqVO;
8 import cn.iocoder.yudao.module.infra.dal.dataobject.logger.ApiAccessLogDO; 8 import cn.iocoder.yudao.module.infra.dal.dataobject.logger.ApiAccessLogDO;
  9 +import org.apache.ibatis.annotations.Delete;
9 import org.apache.ibatis.annotations.Mapper; 10 import org.apache.ibatis.annotations.Mapper;
10 import org.apache.ibatis.annotations.Param; 11 import org.apache.ibatis.annotations.Param;
11 12
  13 +import java.time.LocalDateTime;
12 import java.util.List; 14 import java.util.List;
13 15
14 /** 16 /**
@@ -45,8 +47,14 @@ public interface ApiAccessLogMapper extends BaseMapperX&lt;ApiAccessLogDO&gt; { @@ -45,8 +47,14 @@ public interface ApiAccessLogMapper extends BaseMapperX&lt;ApiAccessLogDO&gt; {
45 ); 47 );
46 } 48 }
47 49
48 - // TODO @j-sentinel:同 JobLogMapper 的一些优化点  
49 - Integer jobCleanAccessLog(@Param("accessLogJobDay") Integer accessLogJobDay); 50 + /**
  51 + * 物理删除指定时间之前的日志
  52 + *
  53 + * @param createTime 最大时间
  54 + * @param limit 删除条数,防止一次删除太多
  55 + * @return 删除条数
  56 + */
  57 + @Delete("DELETE FROM infra_api_access_log WHERE create_time < #{createTime} LIMIT #{limit}")
  58 + Integer deleteByCreateTimeLt(@Param("createTime") LocalDateTime createTime, @Param("limit") Integer limit);
50 59
51 - void optimizeTable();  
52 } 60 }
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/logger/ApiErrorLogMapper.java
@@ -6,9 +6,11 @@ import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; @@ -6,9 +6,11 @@ import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
6 import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apierrorlog.ApiErrorLogExportReqVO; 6 import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apierrorlog.ApiErrorLogExportReqVO;
7 import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apierrorlog.ApiErrorLogPageReqVO; 7 import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apierrorlog.ApiErrorLogPageReqVO;
8 import cn.iocoder.yudao.module.infra.dal.dataobject.logger.ApiErrorLogDO; 8 import cn.iocoder.yudao.module.infra.dal.dataobject.logger.ApiErrorLogDO;
  9 +import org.apache.ibatis.annotations.Delete;
9 import org.apache.ibatis.annotations.Mapper; 10 import org.apache.ibatis.annotations.Mapper;
10 import org.apache.ibatis.annotations.Param; 11 import org.apache.ibatis.annotations.Param;
11 12
  13 +import java.time.LocalDateTime;
12 import java.util.List; 14 import java.util.List;
13 15
14 /** 16 /**
@@ -43,8 +45,14 @@ public interface ApiErrorLogMapper extends BaseMapperX&lt;ApiErrorLogDO&gt; { @@ -43,8 +45,14 @@ public interface ApiErrorLogMapper extends BaseMapperX&lt;ApiErrorLogDO&gt; {
43 ); 45 );
44 } 46 }
45 47
46 - // TODO @j-sentinel:同 JobLogMapper 的一些优化点  
47 - Integer jobCleanErrorLog(@Param("errorLogJobDay") Integer errorLogJobDay); 48 + /**
  49 + * 物理删除指定时间之前的日志
  50 + *
  51 + * @param createTime 最大时间
  52 + * @param limit 删除条数,防止一次删除太多
  53 + * @return 删除条数
  54 + */
  55 + @Delete("DELETE FROM infra_api_error_log WHERE create_time < #{createTime} LIMIT #{limit}")
  56 + Integer deleteByCreateTimeLt(@Param("createTime") LocalDateTime createTime, @Param("limit")Integer limit);
48 57
49 - void optimizeTable();  
50 } 58 }
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/job/job/AccessLogCleanJob.java 0 → 100644
  1 +package cn.iocoder.yudao.module.infra.job.job;
  2 +
  3 +import cn.iocoder.yudao.framework.quartz.core.handler.JobHandler;
  4 +import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore;
  5 +import cn.iocoder.yudao.module.infra.service.logger.ApiAccessLogService;
  6 +import lombok.extern.slf4j.Slf4j;
  7 +import org.springframework.stereotype.Component;
  8 +
  9 +import javax.annotation.Resource;
  10 +
  11 +/**
  12 + * 物理删除 N 天前的访问日志的 Job
  13 + *
  14 + * @author j-sentinel
  15 + */
  16 +@Component
  17 +@Slf4j
  18 +public class AccessLogCleanJob implements JobHandler {
  19 +
  20 + @Resource
  21 + private ApiAccessLogService apiAccessLogService;
  22 +
  23 + /**
  24 + * 清理超过(14)天的日志
  25 + */
  26 + private static final Integer JOB_CLEAN_RETAIN_DAY = 14;
  27 +
  28 + /**
  29 + * 每次删除间隔的条数,如果值太高可能会造成数据库的压力过大
  30 + */
  31 + private static final Integer DELETE_LIMIT = 100;
  32 +
  33 + @Override
  34 + @TenantIgnore
  35 + public String execute(String param) {
  36 + Integer count = apiAccessLogService.cleanAccessLog(JOB_CLEAN_RETAIN_DAY, DELETE_LIMIT);
  37 + log.info("[count][定时执行清理访问日志数量 ({}) 个]", count);
  38 + return String.format("定时执行清理错误日志数量 %s 个", count);
  39 + }
  40 +
  41 +}
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/job/job/ErrorLogCleanJob.java 0 → 100644
  1 +package cn.iocoder.yudao.module.infra.job.job;
  2 +
  3 +import cn.iocoder.yudao.framework.quartz.core.handler.JobHandler;
  4 +import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore;
  5 +import cn.iocoder.yudao.module.infra.service.logger.ApiErrorLogService;
  6 +import lombok.extern.slf4j.Slf4j;
  7 +import org.springframework.stereotype.Component;
  8 +
  9 +import javax.annotation.Resource;
  10 +
  11 +/**
  12 + * 物理删除 N 天前的错误日志的 Job
  13 + *
  14 + * @author j-sentinel
  15 + */
  16 +@Slf4j
  17 +@Component
  18 +public class ErrorLogCleanJob implements JobHandler {
  19 +
  20 + @Resource
  21 + private ApiErrorLogService apiErrorLogService;
  22 +
  23 + /**
  24 + * 清理超过(14)天的日志
  25 + */
  26 + private static final Integer JOB_CLEAN_RETAIN_DAY = 14;
  27 +
  28 + /**
  29 + * 每次删除间隔的条数,如果值太高可能会造成数据库的压力过大
  30 + */
  31 + private static final Integer DELETE_LIMIT = 100;
  32 +
  33 + @Override
  34 + @TenantIgnore
  35 + public String execute(String param) {
  36 + Integer count = apiErrorLogService.cleanErrorLog(JOB_CLEAN_RETAIN_DAY,DELETE_LIMIT);
  37 + log.info("[count][定时执行清理错误日志数量 ({}) 个]", count);
  38 + return String.format("定时执行清理错误日志数量 %s 个", count);
  39 + }
  40 +
  41 +}
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/job/logger/JobLogCleanJob.java 0 → 100644
  1 +package cn.iocoder.yudao.module.infra.job.logger;
  2 +
  3 +import cn.iocoder.yudao.framework.quartz.core.handler.JobHandler;
  4 +import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore;
  5 +import cn.iocoder.yudao.module.infra.service.job.JobLogService;
  6 +import lombok.extern.slf4j.Slf4j;
  7 +import org.springframework.stereotype.Component;
  8 +import javax.annotation.Resource;
  9 +
  10 +/**
  11 + * 物理删除 N 天前的任务日志的 Job
  12 + *
  13 + * @author j-sentinel
  14 + */
  15 +@Slf4j
  16 +@Component
  17 +public class JobLogCleanJob implements JobHandler {
  18 +
  19 + @Resource
  20 + private JobLogService jobLogService;
  21 +
  22 + /**
  23 + * 清理超过(14)天的日志
  24 + */
  25 + private static final Integer JOB_CLEAN_RETAIN_DAY = 14;
  26 +
  27 + /**
  28 + * 每次删除间隔的条数,如果值太高可能会造成数据库的压力过大
  29 + */
  30 + private static final Integer DELETE_LIMIT = 100;
  31 +
  32 + @Override
  33 + @TenantIgnore
  34 + public String execute(String param) {
  35 + Integer count = jobLogService.cleanJobLog(JOB_CLEAN_RETAIN_DAY, DELETE_LIMIT);
  36 + log.info("[count][定时执行清理定时任务日志数量 ({}) 个]", count);
  37 + return String.format("定时执行清理定时任务日志数量 %s 个", count);
  38 + }
  39 +
  40 +}
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/job/JobLogService.java
@@ -48,4 +48,12 @@ public interface JobLogService extends JobLogFrameworkService { @@ -48,4 +48,12 @@ public interface JobLogService extends JobLogFrameworkService {
48 */ 48 */
49 List<JobLogDO> getJobLogList(JobLogExportReqVO exportReqVO); 49 List<JobLogDO> getJobLogList(JobLogExportReqVO exportReqVO);
50 50
  51 + /**
  52 + * 清理 exceedDay 天前的任务日志
  53 + *
  54 + * @param exceedDay 超过多少天就进行清理
  55 + * @param deleteLimit 清理的间隔条数
  56 + */
  57 + Integer cleanJobLog(Integer exceedDay, Integer deleteLimit);
  58 +
51 } 59 }
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/job/JobLogServiceImpl.java
@@ -26,8 +26,6 @@ import java.util.List; @@ -26,8 +26,6 @@ import java.util.List;
26 @Slf4j 26 @Slf4j
27 public class JobLogServiceImpl implements JobLogService { 27 public class JobLogServiceImpl implements JobLogService {
28 28
29 - private static final Integer DELETE_LIMIT = 1;  
30 -  
31 @Resource 29 @Resource
32 private JobLogMapper jobLogMapper; 30 private JobLogMapper jobLogMapper;
33 31
@@ -52,21 +50,19 @@ public class JobLogServiceImpl implements JobLogService { @@ -52,21 +50,19 @@ public class JobLogServiceImpl implements JobLogService {
52 } 50 }
53 } 51 }
54 52
55 - // TODO @j-sentinel:这个 job,也可以忽略租户哈;可以直接使用 @TenantIgnore 注解;  
56 @Override 53 @Override
57 - public Integer timingJobCleanLog(Integer jobCleanRetainDay) {  
58 - Integer result = null; 54 + @SuppressWarnings("DuplicatedCode")
  55 + public Integer cleanJobLog(Integer exceedDay, Integer deleteLimit) {
59 int count = 0; 56 int count = 0;
60 - // TODO @j-sentinel:一般我们在写逻辑时,尽量避免用 while true 这种“死循环”,而是 for (int i = 0; i < Short.MAX) 类似这种;避免里面真的发生一些意外的情况,无限执行;  
61 - // 然后 for 里面,可以有个 if count < 100 未到达删除的预期条数,说明已经到底,可以 break 了;  
62 - while (result == null || DELETE_LIMIT.equals(result)){  
63 - result = jobLogMapper.timingJobCleanLog(jobCleanRetainDay);  
64 - count += result;  
65 - }  
66 - if(count > 0){  
67 - // ALTER TABLE...FORCE 会导致表重建发生,这会根据主键索引对表空间中的物理页进行排序。  
68 - // 它将行压缩到页面上并消除可用空间,同时确保数据处于主键查找的最佳顺序。  
69 - jobLogMapper.optimizeTable(); 57 + LocalDateTime expireDate = LocalDateTime.now().minusDays(exceedDay);
  58 + // 循环删除,直到没有满足条件的数据
  59 + for (int i = 0; i < Short.MAX_VALUE; i++) {
  60 + int deleteCount = jobLogMapper.deleteByCreateTimeLt(expireDate, deleteLimit);
  61 + count += deleteCount;
  62 + // 达到删除预期条数,说明到底了
  63 + if (deleteCount < deleteLimit) {
  64 + break;
  65 + }
70 } 66 }
71 return count; 67 return count;
72 } 68 }
@@ -91,5 +87,4 @@ public class JobLogServiceImpl implements JobLogService { @@ -91,5 +87,4 @@ public class JobLogServiceImpl implements JobLogService {
91 return jobLogMapper.selectList(exportReqVO); 87 return jobLogMapper.selectList(exportReqVO);
92 } 88 }
93 89
94 - // TODO @小吉祥:每天 0 点的时候,清理超过 14 天的日志;  
95 } 90 }
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/logger/ApiAccessLogService.java
@@ -39,9 +39,11 @@ public interface ApiAccessLogService { @@ -39,9 +39,11 @@ public interface ApiAccessLogService {
39 List<ApiAccessLogDO> getApiAccessLogList(ApiAccessLogExportReqVO exportReqVO); 39 List<ApiAccessLogDO> getApiAccessLogList(ApiAccessLogExportReqVO exportReqVO);
40 40
41 /** 41 /**
42 - * 清理 @param accessLogJobDay 天的访问日志 42 + * 清理 exceedDay 天前的访问日志
43 * 43 *
44 - * @param accessLogJobDay 超过多少天就进行清理 44 + * @param exceedDay 超过多少天就进行清理
  45 + * @param deleteLimit 清理的间隔条数
45 */ 46 */
46 - void jobCleanAccessLog(Integer accessLogJobDay); 47 + Integer cleanAccessLog(Integer exceedDay, Integer deleteLimit);
  48 +
47 } 49 }
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/logger/ApiAccessLogServiceImpl.java
1 package cn.iocoder.yudao.module.infra.service.logger; 1 package cn.iocoder.yudao.module.infra.service.logger;
2 2
3 import cn.iocoder.yudao.framework.common.pojo.PageResult; 3 import cn.iocoder.yudao.framework.common.pojo.PageResult;
4 -import cn.iocoder.yudao.framework.tenant.core.util.TenantUtils;  
5 import cn.iocoder.yudao.module.infra.api.logger.dto.ApiAccessLogCreateReqDTO; 4 import cn.iocoder.yudao.module.infra.api.logger.dto.ApiAccessLogCreateReqDTO;
6 import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apiaccesslog.ApiAccessLogExportReqVO; 5 import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apiaccesslog.ApiAccessLogExportReqVO;
7 import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apiaccesslog.ApiAccessLogPageReqVO; 6 import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apiaccesslog.ApiAccessLogPageReqVO;
@@ -13,6 +12,7 @@ import org.springframework.stereotype.Service; @@ -13,6 +12,7 @@ import org.springframework.stereotype.Service;
13 import org.springframework.validation.annotation.Validated; 12 import org.springframework.validation.annotation.Validated;
14 13
15 import javax.annotation.Resource; 14 import javax.annotation.Resource;
  15 +import java.time.LocalDateTime;
16 import java.util.List; 16 import java.util.List;
17 17
18 /** 18 /**
@@ -25,8 +25,6 @@ import java.util.List; @@ -25,8 +25,6 @@ import java.util.List;
25 @Validated 25 @Validated
26 public class ApiAccessLogServiceImpl implements ApiAccessLogService { 26 public class ApiAccessLogServiceImpl implements ApiAccessLogService {
27 27
28 - private static final Integer DELETE_LIMIT = 100;  
29 -  
30 @Resource 28 @Resource
31 private ApiAccessLogMapper apiAccessLogMapper; 29 private ApiAccessLogMapper apiAccessLogMapper;
32 30
@@ -47,22 +45,20 @@ public class ApiAccessLogServiceImpl implements ApiAccessLogService { @@ -47,22 +45,20 @@ public class ApiAccessLogServiceImpl implements ApiAccessLogService {
47 } 45 }
48 46
49 @Override 47 @Override
50 - // TODO j-sentinel:类似 JobLogServiceImpl 的建议  
51 - public void jobCleanAccessLog(Integer accessLogJobDay) {  
52 - TenantUtils.executeIgnore(() -> {  
53 - Integer result = null;  
54 - int count = 0;  
55 - while (result == null || DELETE_LIMIT.equals(result)) {  
56 - result = apiAccessLogMapper.jobCleanAccessLog(accessLogJobDay);  
57 - count += result;  
58 - }  
59 - if (count > 0) {  
60 - // ALTER TABLE...FORCE 会导致表重建发生,这会根据主键索引对表空间中的物理页进行排序。  
61 - // 它将行压缩到页面上并消除可用空间,同时确保数据处于主键查找的最佳顺序。  
62 - apiAccessLogMapper.optimizeTable(); 48 + @SuppressWarnings("DuplicatedCode")
  49 + public Integer cleanAccessLog(Integer exceedDay, Integer deleteLimit) {
  50 + int count = 0;
  51 + LocalDateTime expireDate = LocalDateTime.now().minusDays(exceedDay);
  52 + // 循环删除,直到没有满足条件的数据
  53 + for (int i = 0; i < Short.MAX_VALUE; i++) {
  54 + int deleteCount = apiAccessLogMapper.deleteByCreateTimeLt(expireDate, deleteLimit);
  55 + count += deleteCount;
  56 + // 达到删除预期条数,说明到底了
  57 + if (deleteCount < deleteLimit) {
  58 + break;
63 } 59 }
64 - log.info("定时执行清理访问日志数量({})个", count);  
65 - }); 60 + }
  61 + return count;
66 } 62 }
67 63
68 } 64 }
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/logger/ApiErrorLogService.java
@@ -48,9 +48,11 @@ public interface ApiErrorLogService { @@ -48,9 +48,11 @@ public interface ApiErrorLogService {
48 void updateApiErrorLogProcess(Long id, Integer processStatus, Long processUserId); 48 void updateApiErrorLogProcess(Long id, Integer processStatus, Long processUserId);
49 49
50 /** 50 /**
51 - * 清理 @param errorLogJobDay 天的访问日志 51 + * 清理 exceedDay 天前的错误日志
52 * 52 *
53 - * @param errorLogJobDay 超过多少天就进行清理 53 + * @param exceedDay 超过多少天就进行清理
  54 + * @param deleteLimit 清理的间隔条数
54 */ 55 */
55 - void jobCleanErrorLog(Integer errorLogJobDay); 56 + Integer cleanErrorLog(Integer exceedDay, Integer deleteLimit);
  57 +
56 } 58 }
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/logger/ApiErrorLogServiceImpl.java
1 package cn.iocoder.yudao.module.infra.service.logger; 1 package cn.iocoder.yudao.module.infra.service.logger;
2 2
3 import cn.iocoder.yudao.framework.common.pojo.PageResult; 3 import cn.iocoder.yudao.framework.common.pojo.PageResult;
4 -import cn.iocoder.yudao.framework.tenant.core.util.TenantUtils;  
5 import cn.iocoder.yudao.module.infra.api.logger.dto.ApiErrorLogCreateReqDTO; 4 import cn.iocoder.yudao.module.infra.api.logger.dto.ApiErrorLogCreateReqDTO;
6 import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apierrorlog.ApiErrorLogExportReqVO; 5 import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apierrorlog.ApiErrorLogExportReqVO;
7 import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apierrorlog.ApiErrorLogPageReqVO; 6 import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apierrorlog.ApiErrorLogPageReqVO;
@@ -31,8 +30,6 @@ import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.API_ERROR_L @@ -31,8 +30,6 @@ import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.API_ERROR_L
31 @Validated 30 @Validated
32 public class ApiErrorLogServiceImpl implements ApiErrorLogService { 31 public class ApiErrorLogServiceImpl implements ApiErrorLogService {
33 32
34 - private static final Integer DELETE_LIMIT = 100;  
35 -  
36 @Resource 33 @Resource
37 private ApiErrorLogMapper apiErrorLogMapper; 34 private ApiErrorLogMapper apiErrorLogMapper;
38 35
@@ -68,22 +65,20 @@ public class ApiErrorLogServiceImpl implements ApiErrorLogService { @@ -68,22 +65,20 @@ public class ApiErrorLogServiceImpl implements ApiErrorLogService {
68 } 65 }
69 66
70 @Override 67 @Override
71 - // TODO j-sentinel:类似 JobLogServiceImpl 的建议  
72 - public void jobCleanErrorLog(Integer errorLogJobDay) {  
73 - TenantUtils.executeIgnore(() -> {  
74 - Integer result = null;  
75 - int count = 0;  
76 - while (result == null || DELETE_LIMIT.equals(result)) {  
77 - result = apiErrorLogMapper.jobCleanErrorLog(errorLogJobDay);  
78 - count += result;  
79 - }  
80 - if (count > 0) {  
81 - // ALTER TABLE...FORCE 会导致表重建发生,这会根据主键索引对表空间中的物理页进行排序。  
82 - // 它将行压缩到页面上并消除可用空间,同时确保数据处于主键查找的最佳顺序。  
83 - apiErrorLogMapper.optimizeTable(); 68 + @SuppressWarnings("DuplicatedCode")
  69 + public Integer cleanErrorLog(Integer exceedDay, Integer deleteLimit) {
  70 + int count = 0;
  71 + LocalDateTime expireDate = LocalDateTime.now().minusDays(exceedDay);
  72 + // 循环删除,直到没有满足条件的数据
  73 + for (int i = 0; i < Short.MAX_VALUE; i++) {
  74 + int deleteCount = apiErrorLogMapper.deleteByCreateTimeLt(expireDate, deleteLimit);
  75 + count += deleteCount;
  76 + // 达到删除预期条数,说明到底了
  77 + if (deleteCount < deleteLimit) {
  78 + break;
84 } 79 }
85 - log.info("定时执行清理错误日志数量({})个",count);  
86 - }); 80 + }
  81 + return count;
87 } 82 }
88 83
89 } 84 }
yudao-module-infra/yudao-module-infra-biz/src/main/resources/mapper/ApiAccessLogMapper.xml deleted
1 -<?xml version="1.0" encoding="UTF-8"?>  
2 -<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">  
3 -<mapper namespace="cn.iocoder.yudao.module.infra.dal.mysql.logger.ApiAccessLogMapper">  
4 -  
5 - <!--  
6 - 一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。  
7 - 无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。  
8 - 代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。  
9 - 文档可见:https://www.iocoder.cn/MyBatis/x-plugins/  
10 - -->  
11 -  
12 - <delete id="jobCleanAccessLog" parameterType="integer">  
13 - DELETE FROM infra_api_access_log  
14 - WHERE id IN (  
15 - SELECT * FROM (  
16 - SELECT id FROM infra_api_access_log  
17 - WHERE create_time &lt; DATE_SUB(CURDATE(), INTERVAL #{accessLogJobDay} DAY)  
18 - ORDER BY id ASC LIMIT 100  
19 - ) AS a  
20 - )  
21 - </delete>  
22 -  
23 - <select id="optimizeTable">  
24 - ALTER TABLE infra_job_log FORCE  
25 - /*  
26 - ALTER TABLE infra_job_log ENGINE = INNODB,  
27 - ALGORITHM = INPLACE,  
28 - LOCK = NONE  
29 - */  
30 - </select>  
31 -  
32 -</mapper>  
yudao-module-infra/yudao-module-infra-biz/src/main/resources/mapper/ApiErrorLogMapper.xml deleted
1 -<?xml version="1.0" encoding="UTF-8"?>  
2 -<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">  
3 -<mapper namespace="cn.iocoder.yudao.module.infra.dal.mysql.logger.ApiErrorLogMapper">  
4 -  
5 - <!--  
6 - 一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。  
7 - 无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。  
8 - 代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。  
9 - 文档可见:https://www.iocoder.cn/MyBatis/x-plugins/  
10 - -->  
11 -  
12 - <delete id="jobCleanErrorLog" parameterType="integer">  
13 - DELETE FROM infra_api_error_log  
14 - WHERE id IN (  
15 - SELECT * FROM (  
16 - SELECT id FROM infra_api_error_log  
17 - WHERE create_time &lt; DATE_SUB(CURDATE(), INTERVAL #{errorLogJobDay} DAY)  
18 - ORDER BY id ASC LIMIT 100  
19 - ) AS a  
20 - )  
21 - </delete>  
22 -  
23 - <select id="optimizeTable">  
24 - ALTER TABLE infra_api_error_log FORCE  
25 - /*  
26 - ALTER TABLE infra_api_error_log ENGINE = INNODB,  
27 - ALGORITHM = INPLACE,  
28 - LOCK = NONE  
29 - */  
30 - </select>  
31 -  
32 -</mapper>  
yudao-module-infra/yudao-module-infra-biz/src/main/resources/mapper/JobLogMapper.xml deleted
1 -<?xml version="1.0" encoding="UTF-8"?>  
2 -<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">  
3 -<mapper namespace="cn.iocoder.yudao.module.infra.dal.mysql.job.JobLogMapper">  
4 -  
5 - <!--  
6 - 一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。  
7 - 无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。  
8 - 代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。  
9 - 文档可见:https://www.iocoder.cn/MyBatis/x-plugins/  
10 - -->  
11 -  
12 - <delete id="timingJobCleanLog" parameterType="integer">  
13 - DELETE FROM infra_job_log  
14 - WHERE id IN (  
15 - SELECT * FROM (  
16 - SELECT id FROM infra_job_log  
17 - WHERE create_time &lt; DATE_SUB(CURDATE(), INTERVAL #{jobCleanRetainDay} DAY)  
18 - ORDER BY id ASC LIMIT 100  
19 - ) AS a  
20 - )  
21 - </delete>  
22 -  
23 - <select id="optimizeTable">  
24 - ALTER TABLE infra_job_log FORCE  
25 - /*  
26 - ALTER TABLE infra_job_log ENGINE = INNODB,  
27 - ALGORITHM = INPLACE,  
28 - LOCK = NONE  
29 - */  
30 - </select>  
31 -  
32 -</mapper>  
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/SeckillActivityController.java
@@ -7,8 +7,8 @@ import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi; @@ -7,8 +7,8 @@ import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi;
7 import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; 7 import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO;
8 import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.*; 8 import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.*;
9 import cn.iocoder.yudao.module.promotion.convert.seckill.seckillactivity.SeckillActivityConvert; 9 import cn.iocoder.yudao.module.promotion.convert.seckill.seckillactivity.SeckillActivityConvert;
10 -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckillactivity.SeckillActivityDO;  
11 -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckillactivity.SeckillProductDO; 10 +import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillActivityDO;
  11 +import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillProductDO;
12 import cn.iocoder.yudao.module.promotion.service.seckill.SeckillActivityService; 12 import cn.iocoder.yudao.module.promotion.service.seckill.SeckillActivityService;
13 import io.swagger.v3.oas.annotations.Operation; 13 import io.swagger.v3.oas.annotations.Operation;
14 import io.swagger.v3.oas.annotations.Parameter; 14 import io.swagger.v3.oas.annotations.Parameter;
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/SeckillConfigController.java
@@ -5,7 +5,7 @@ import cn.iocoder.yudao.framework.common.pojo.CommonResult; @@ -5,7 +5,7 @@ import cn.iocoder.yudao.framework.common.pojo.CommonResult;
5 import cn.iocoder.yudao.framework.common.pojo.PageResult; 5 import cn.iocoder.yudao.framework.common.pojo.PageResult;
6 import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.config.*; 6 import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.config.*;
7 import cn.iocoder.yudao.module.promotion.convert.seckill.seckillconfig.SeckillConfigConvert; 7 import cn.iocoder.yudao.module.promotion.convert.seckill.seckillconfig.SeckillConfigConvert;
8 -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckillconfig.SeckillConfigDO; 8 +import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillConfigDO;
9 import cn.iocoder.yudao.module.promotion.service.seckill.SeckillConfigService; 9 import cn.iocoder.yudao.module.promotion.service.seckill.SeckillConfigService;
10 import io.swagger.v3.oas.annotations.Operation; 10 import io.swagger.v3.oas.annotations.Operation;
11 import io.swagger.v3.oas.annotations.Parameter; 11 import io.swagger.v3.oas.annotations.Parameter;
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityRespVO.java
@@ -15,15 +15,19 @@ import java.util.List; @@ -15,15 +15,19 @@ import java.util.List;
15 @ToString(callSuper = true) 15 @ToString(callSuper = true)
16 public class SeckillActivityRespVO extends SeckillActivityBaseVO { 16 public class SeckillActivityRespVO extends SeckillActivityBaseVO {
17 17
18 - @Schema(description = "商品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "618大促")  
19 - private String spuName;  
20 -  
21 - @Schema(description = "商品主图", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/xx.png")  
22 - private String picUrl;  
23 -  
24 @Schema(description = "秒杀活动 id", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") 18 @Schema(description = "秒杀活动 id", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
25 private Long id; 19 private Long id;
26 20
  21 + @Schema(description = "商品名称", requiredMode = Schema.RequiredMode.REQUIRED, // 从 SPU 的 name 读取
  22 + example = "618大促")
  23 + private String spuName;
  24 + @Schema(description = "商品主图", requiredMode = Schema.RequiredMode.REQUIRED, // 从 SPU 的 picUrl 读取
  25 + example = "https://www.iocoder.cn/xx.png")
  26 + private String picUrl;
  27 + @Schema(description = "商品市场价,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, // 从 SPU 的 marketPrice 读取
  28 + example = "50")
  29 + private Integer marketPrice;
  30 +
27 @Schema(description = "秒杀商品", requiredMode = Schema.RequiredMode.REQUIRED) 31 @Schema(description = "秒杀商品", requiredMode = Schema.RequiredMode.REQUIRED)
28 private List<SeckillProductRespVO> products; 32 private List<SeckillProductRespVO> products;
29 33
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/config/SeckillConfigSimpleRespVO.java
@@ -21,4 +21,10 @@ public class SeckillConfigSimpleRespVO { @@ -21,4 +21,10 @@ public class SeckillConfigSimpleRespVO {
21 @NotNull(message = "秒杀时段名称不能为空") 21 @NotNull(message = "秒杀时段名称不能为空")
22 private String name; 22 private String name;
23 23
  24 + @Schema(description = "开始时间点", requiredMode = Schema.RequiredMode.REQUIRED, example = "09:00:00")
  25 + private String startTime;
  26 +
  27 + @Schema(description = "结束时间点", requiredMode = Schema.RequiredMode.REQUIRED, example = "16:00:00")
  28 + private String endTime;
  29 +
24 } 30 }
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/AppSeckillActivityController.java
@@ -12,9 +12,9 @@ import cn.iocoder.yudao.module.promotion.controller.app.seckill.vo.activity.AppS @@ -12,9 +12,9 @@ import cn.iocoder.yudao.module.promotion.controller.app.seckill.vo.activity.AppS
12 import cn.iocoder.yudao.module.promotion.controller.app.seckill.vo.activity.AppSeckillActivityPageReqVO; 12 import cn.iocoder.yudao.module.promotion.controller.app.seckill.vo.activity.AppSeckillActivityPageReqVO;
13 import cn.iocoder.yudao.module.promotion.controller.app.seckill.vo.activity.AppSeckillActivityRespVO; 13 import cn.iocoder.yudao.module.promotion.controller.app.seckill.vo.activity.AppSeckillActivityRespVO;
14 import cn.iocoder.yudao.module.promotion.convert.seckill.seckillactivity.SeckillActivityConvert; 14 import cn.iocoder.yudao.module.promotion.convert.seckill.seckillactivity.SeckillActivityConvert;
15 -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckillactivity.SeckillActivityDO;  
16 -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckillactivity.SeckillProductDO;  
17 -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckillconfig.SeckillConfigDO; 15 +import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillActivityDO;
  16 +import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillProductDO;
  17 +import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillConfigDO;
18 import cn.iocoder.yudao.module.promotion.service.seckill.SeckillActivityService; 18 import cn.iocoder.yudao.module.promotion.service.seckill.SeckillActivityService;
19 import cn.iocoder.yudao.module.promotion.service.seckill.SeckillConfigService; 19 import cn.iocoder.yudao.module.promotion.service.seckill.SeckillConfigService;
20 import io.swagger.v3.oas.annotations.Operation; 20 import io.swagger.v3.oas.annotations.Operation;
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/vo/activity/AppSeckillActivityRespVO.java
@@ -16,13 +16,13 @@ public class AppSeckillActivityRespVO { @@ -16,13 +16,13 @@ public class AppSeckillActivityRespVO {
16 @Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") 16 @Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048")
17 private Long spuId; 17 private Long spuId;
18 18
19 - @Schema(description = "商品图片", requiredMode = Schema.RequiredMode.REQUIRED, example = "4096")  
20 - // 从 SPU 的 picUrl 读取 19 + @Schema(description = "商品图片", requiredMode = Schema.RequiredMode.REQUIRED, // 从 SPU 的 picUrl 读取
  20 + example = "https://www.iocoder.cn/xx.png")
21 private String picUrl; 21 private String picUrl;
22 @Schema(description = "单位名", requiredMode = Schema.RequiredMode.REQUIRED, example = "个") 22 @Schema(description = "单位名", requiredMode = Schema.RequiredMode.REQUIRED, example = "个")
23 private String unitName; 23 private String unitName;
24 - @Schema(description = "商品市场价,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "50")  
25 - // 从 SPU 的 marketPrice 读取 24 + @Schema(description = "商品市场价,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, // 从 SPU 的 marketPrice 读取
  25 + example = "50")
26 private Integer marketPrice; 26 private Integer marketPrice;
27 27
28 @Schema(description = "秒杀活动状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") 28 @Schema(description = "秒杀活动状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/seckill/seckillactivity/SeckillActivityConvert.java
@@ -18,9 +18,9 @@ import cn.iocoder.yudao.module.promotion.controller.app.seckill.vo.activity.AppS @@ -18,9 +18,9 @@ import cn.iocoder.yudao.module.promotion.controller.app.seckill.vo.activity.AppS
18 import cn.iocoder.yudao.module.promotion.controller.app.seckill.vo.activity.AppSeckillActivityNowRespVO; 18 import cn.iocoder.yudao.module.promotion.controller.app.seckill.vo.activity.AppSeckillActivityNowRespVO;
19 import cn.iocoder.yudao.module.promotion.controller.app.seckill.vo.activity.AppSeckillActivityRespVO; 19 import cn.iocoder.yudao.module.promotion.controller.app.seckill.vo.activity.AppSeckillActivityRespVO;
20 import cn.iocoder.yudao.module.promotion.convert.seckill.seckillconfig.SeckillConfigConvert; 20 import cn.iocoder.yudao.module.promotion.convert.seckill.seckillconfig.SeckillConfigConvert;
21 -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckillactivity.SeckillActivityDO;  
22 -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckillactivity.SeckillProductDO;  
23 -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckillconfig.SeckillConfigDO; 21 +import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillActivityDO;
  22 +import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillProductDO;
  23 +import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillConfigDO;
24 import org.mapstruct.Mapper; 24 import org.mapstruct.Mapper;
25 import org.mapstruct.Mapping; 25 import org.mapstruct.Mapping;
26 import org.mapstruct.Mappings; 26 import org.mapstruct.Mappings;
@@ -61,7 +61,7 @@ public interface SeckillActivityConvert { @@ -61,7 +61,7 @@ public interface SeckillActivityConvert {
61 pageResult.getList().forEach(item -> { 61 pageResult.getList().forEach(item -> {
62 item.setProducts(convertList2(seckillProducts)); 62 item.setProducts(convertList2(seckillProducts));
63 MapUtils.findAndThen(spuMap, item.getSpuId(), 63 MapUtils.findAndThen(spuMap, item.getSpuId(),
64 - spu -> item.setSpuName(spu.getName()).setPicUrl(spu.getPicUrl())); 64 + spu -> item.setSpuName(spu.getName()).setPicUrl(spu.getPicUrl()).setMarketPrice(spu.getMarketPrice()));
65 }); 65 });
66 return pageResult; 66 return pageResult;
67 } 67 }
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/seckill/seckillconfig/SeckillConfigConvert.java
@@ -6,7 +6,7 @@ import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.config.Seck @@ -6,7 +6,7 @@ import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.config.Seck
6 import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.config.SeckillConfigSimpleRespVO; 6 import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.config.SeckillConfigSimpleRespVO;
7 import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.config.SeckillConfigUpdateReqVO; 7 import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.config.SeckillConfigUpdateReqVO;
8 import cn.iocoder.yudao.module.promotion.controller.app.seckill.vo.config.AppSeckillConfigRespVO; 8 import cn.iocoder.yudao.module.promotion.controller.app.seckill.vo.config.AppSeckillConfigRespVO;
9 -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckillconfig.SeckillConfigDO; 9 +import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillConfigDO;
10 import org.mapstruct.Mapper; 10 import org.mapstruct.Mapper;
11 import org.mapstruct.factory.Mappers; 11 import org.mapstruct.factory.Mappers;
12 12
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/seckill/seckillactivity/SeckillActivityDO.java renamed to yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/seckill/SeckillActivityDO.java
1 -package cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckillactivity; 1 +package cn.iocoder.yudao.module.promotion.dal.dataobject.seckill;
2 2
3 import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; 3 import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
4 import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; 4 import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/seckill/seckillconfig/SeckillConfigDO.java renamed to yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/seckill/SeckillConfigDO.java
1 -package cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckillconfig; 1 +package cn.iocoder.yudao.module.promotion.dal.dataobject.seckill;
2 2
3 import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; 3 import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
4 import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; 4 import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/seckill/seckillactivity/SeckillProductDO.java renamed to yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/seckill/SeckillProductDO.java
1 -package cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckillactivity; 1 +package cn.iocoder.yudao.module.promotion.dal.dataobject.seckill;
2 2
3 import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; 3 import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
4 import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; 4 import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
5 import cn.iocoder.yudao.framework.mybatis.core.type.LongListTypeHandler; 5 import cn.iocoder.yudao.framework.mybatis.core.type.LongListTypeHandler;
6 -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckillconfig.SeckillConfigDO;  
7 import com.baomidou.mybatisplus.annotation.KeySequence; 6 import com.baomidou.mybatisplus.annotation.KeySequence;
8 import com.baomidou.mybatisplus.annotation.TableField; 7 import com.baomidou.mybatisplus.annotation.TableField;
9 import com.baomidou.mybatisplus.annotation.TableId; 8 import com.baomidou.mybatisplus.annotation.TableId;
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/seckill/seckillactivity/SeckillActivityMapper.java
@@ -6,7 +6,7 @@ import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; @@ -6,7 +6,7 @@ import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
6 import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; 6 import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
7 import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityPageReqVO; 7 import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityPageReqVO;
8 import cn.iocoder.yudao.module.promotion.controller.app.seckill.vo.activity.AppSeckillActivityPageReqVO; 8 import cn.iocoder.yudao.module.promotion.controller.app.seckill.vo.activity.AppSeckillActivityPageReqVO;
9 -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckillactivity.SeckillActivityDO; 9 +import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillActivityDO;
10 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; 10 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
11 import org.apache.ibatis.annotations.Mapper; 11 import org.apache.ibatis.annotations.Mapper;
12 12
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/seckill/seckillactivity/SeckillProductMapper.java
1 package cn.iocoder.yudao.module.promotion.dal.mysql.seckill.seckillactivity; 1 package cn.iocoder.yudao.module.promotion.dal.mysql.seckill.seckillactivity;
2 2
3 import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; 3 import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
4 -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckillactivity.SeckillProductDO; 4 +import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillProductDO;
5 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; 5 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
6 import org.apache.ibatis.annotations.Mapper; 6 import org.apache.ibatis.annotations.Mapper;
7 7
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/seckill/seckillconfig/SeckillConfigMapper.java
@@ -4,7 +4,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; @@ -4,7 +4,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
4 import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; 4 import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
5 import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; 5 import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
6 import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.config.SeckillConfigPageReqVO; 6 import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.config.SeckillConfigPageReqVO;
7 -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckillconfig.SeckillConfigDO; 7 +import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillConfigDO;
8 import org.apache.ibatis.annotations.Mapper; 8 import org.apache.ibatis.annotations.Mapper;
9 9
10 import java.util.List; 10 import java.util.List;
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/SeckillActivityService.java
@@ -5,8 +5,8 @@ import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.Se @@ -5,8 +5,8 @@ import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.Se
5 import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityPageReqVO; 5 import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityPageReqVO;
6 import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityUpdateReqVO; 6 import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityUpdateReqVO;
7 import cn.iocoder.yudao.module.promotion.controller.app.seckill.vo.activity.AppSeckillActivityPageReqVO; 7 import cn.iocoder.yudao.module.promotion.controller.app.seckill.vo.activity.AppSeckillActivityPageReqVO;
8 -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckillactivity.SeckillActivityDO;  
9 -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckillactivity.SeckillProductDO; 8 +import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillActivityDO;
  9 +import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillProductDO;
10 10
11 import javax.validation.Valid; 11 import javax.validation.Valid;
12 import java.util.Collection; 12 import java.util.Collection;
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/SeckillActivityServiceImpl.java
@@ -14,8 +14,8 @@ import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.Se @@ -14,8 +14,8 @@ import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.Se
14 import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.product.SeckillProductBaseVO; 14 import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.product.SeckillProductBaseVO;
15 import cn.iocoder.yudao.module.promotion.controller.app.seckill.vo.activity.AppSeckillActivityPageReqVO; 15 import cn.iocoder.yudao.module.promotion.controller.app.seckill.vo.activity.AppSeckillActivityPageReqVO;
16 import cn.iocoder.yudao.module.promotion.convert.seckill.seckillactivity.SeckillActivityConvert; 16 import cn.iocoder.yudao.module.promotion.convert.seckill.seckillactivity.SeckillActivityConvert;
17 -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckillactivity.SeckillActivityDO;  
18 -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckillactivity.SeckillProductDO; 17 +import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillActivityDO;
  18 +import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillProductDO;
19 import cn.iocoder.yudao.module.promotion.dal.mysql.seckill.seckillactivity.SeckillActivityMapper; 19 import cn.iocoder.yudao.module.promotion.dal.mysql.seckill.seckillactivity.SeckillActivityMapper;
20 import cn.iocoder.yudao.module.promotion.dal.mysql.seckill.seckillactivity.SeckillProductMapper; 20 import cn.iocoder.yudao.module.promotion.dal.mysql.seckill.seckillactivity.SeckillProductMapper;
21 import cn.iocoder.yudao.module.promotion.util.PromotionUtils; 21 import cn.iocoder.yudao.module.promotion.util.PromotionUtils;
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/SeckillConfigService.java
@@ -4,7 +4,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; @@ -4,7 +4,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
4 import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.config.SeckillConfigCreateReqVO; 4 import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.config.SeckillConfigCreateReqVO;
5 import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.config.SeckillConfigPageReqVO; 5 import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.config.SeckillConfigPageReqVO;
6 import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.config.SeckillConfigUpdateReqVO; 6 import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.config.SeckillConfigUpdateReqVO;
7 -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckillconfig.SeckillConfigDO; 7 +import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillConfigDO;
8 8
9 import javax.validation.Valid; 9 import javax.validation.Valid;
10 import java.util.Collection; 10 import java.util.Collection;
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/SeckillConfigServiceImpl.java
@@ -9,7 +9,7 @@ import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.config.Seck @@ -9,7 +9,7 @@ import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.config.Seck
9 import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.config.SeckillConfigPageReqVO; 9 import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.config.SeckillConfigPageReqVO;
10 import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.config.SeckillConfigUpdateReqVO; 10 import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.config.SeckillConfigUpdateReqVO;
11 import cn.iocoder.yudao.module.promotion.convert.seckill.seckillconfig.SeckillConfigConvert; 11 import cn.iocoder.yudao.module.promotion.convert.seckill.seckillconfig.SeckillConfigConvert;
12 -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckillconfig.SeckillConfigDO; 12 +import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillConfigDO;
13 import cn.iocoder.yudao.module.promotion.dal.mysql.seckill.seckillconfig.SeckillConfigMapper; 13 import cn.iocoder.yudao.module.promotion.dal.mysql.seckill.seckillconfig.SeckillConfigMapper;
14 import org.springframework.stereotype.Service; 14 import org.springframework.stereotype.Service;
15 import org.springframework.validation.annotation.Validated; 15 import org.springframework.validation.annotation.Validated;
yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/seckillactivity/SeckillActivityServiceImplTest.java
@@ -5,7 +5,7 @@ import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; @@ -5,7 +5,7 @@ import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
5 import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityCreateReqVO; 5 import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityCreateReqVO;
6 import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityPageReqVO; 6 import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityPageReqVO;
7 import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityUpdateReqVO; 7 import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityUpdateReqVO;
8 -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckillactivity.SeckillActivityDO; 8 +import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillActivityDO;
9 import cn.iocoder.yudao.module.promotion.dal.mysql.seckill.seckillactivity.SeckillActivityMapper; 9 import cn.iocoder.yudao.module.promotion.dal.mysql.seckill.seckillactivity.SeckillActivityMapper;
10 import cn.iocoder.yudao.module.promotion.service.seckill.SeckillActivityServiceImpl; 10 import cn.iocoder.yudao.module.promotion.service.seckill.SeckillActivityServiceImpl;
11 import org.junit.jupiter.api.Disabled; 11 import org.junit.jupiter.api.Disabled;
yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/seckillconfig/SeckillConfigServiceImplTest.java
@@ -3,7 +3,7 @@ package cn.iocoder.yudao.module.promotion.service.seckillconfig; @@ -3,7 +3,7 @@ package cn.iocoder.yudao.module.promotion.service.seckillconfig;
3 import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; 3 import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
4 import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.config.SeckillConfigCreateReqVO; 4 import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.config.SeckillConfigCreateReqVO;
5 import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.config.SeckillConfigUpdateReqVO; 5 import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.config.SeckillConfigUpdateReqVO;
6 -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckillconfig.SeckillConfigDO; 6 +import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillConfigDO;
7 import cn.iocoder.yudao.module.promotion.dal.mysql.seckill.seckillconfig.SeckillConfigMapper; 7 import cn.iocoder.yudao.module.promotion.dal.mysql.seckill.seckillconfig.SeckillConfigMapper;
8 import cn.iocoder.yudao.module.promotion.service.seckill.SeckillConfigServiceImpl; 8 import cn.iocoder.yudao.module.promotion.service.seckill.SeckillConfigServiceImpl;
9 import com.fasterxml.jackson.core.JsonProcessingException; 9 import com.fasterxml.jackson.core.JsonProcessingException;
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/user/BrokerageUserRespVO.java
@@ -26,7 +26,7 @@ public class BrokerageUserRespVO extends BrokerageUserBaseVO { @@ -26,7 +26,7 @@ public class BrokerageUserRespVO extends BrokerageUserBaseVO {
26 @Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") 26 @Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四")
27 private String nickname; 27 private String nickname;
28 28
29 - // ========== 推广信息 ========== 29 + // ========== 推广信息 ========== 注意:是包括 1 + 2 级的数据
30 30
31 @Schema(description = "推广用户数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "20019") 31 @Schema(description = "推广用户数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "20019")
32 private Integer brokerageUserCount; 32 private Integer brokerageUserCount;
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/brokerage/BrokerageRecordMapper.java
@@ -68,7 +68,7 @@ public interface BrokerageRecordMapper extends BaseMapperX&lt;BrokerageRecordDO&gt; { @@ -68,7 +68,7 @@ public interface BrokerageRecordMapper extends BaseMapperX&lt;BrokerageRecordDO&gt; {
68 .in(BrokerageRecordDO::getUserId, userIds) 68 .in(BrokerageRecordDO::getUserId, userIds)
69 .eq(BrokerageRecordDO::getBizId, bizType) 69 .eq(BrokerageRecordDO::getBizId, bizType)
70 .eq(BrokerageRecordDO::getStatus, status) 70 .eq(BrokerageRecordDO::getStatus, status)
71 - .groupBy(BrokerageRecordDO::getUserId)); 71 + .groupBy(BrokerageRecordDO::getUserId)); // 按照 userId 聚合
72 return BeanUtil.copyToList(list, UserBrokerageSummaryRespBO.class); 72 return BeanUtil.copyToList(list, UserBrokerageSummaryRespBO.class);
73 // selectJoinList有BUG,会与租户插件冲突:解析SQL时,发生异常 https://gitee.com/best_handsome/mybatis-plus-join/issues/I84GYW 73 // selectJoinList有BUG,会与租户插件冲突:解析SQL时,发生异常 https://gitee.com/best_handsome/mybatis-plus-join/issues/I84GYW
74 // return selectJoinList(UserBrokerageSummaryBO.class, MPJWrappers.lambdaJoin(BrokerageRecordDO.class) 74 // return selectJoinList(UserBrokerageSummaryBO.class, MPJWrappers.lambdaJoin(BrokerageRecordDO.class)
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageUserServiceImpl.java
@@ -329,26 +329,27 @@ public class BrokerageUserServiceImpl implements BrokerageUserService { @@ -329,26 +329,27 @@ public class BrokerageUserServiceImpl implements BrokerageUserService {
329 if (bindUserId == null) { 329 if (bindUserId == null) {
330 return Collections.emptyList(); 330 return Collections.emptyList();
331 } 331 }
332 -  
333 // 先查第 1 级 332 // 先查第 1 级
334 List<Long> bindUserIds = brokerageUserMapper.selectIdListByBindUserIdIn(Collections.singleton(bindUserId)); 333 List<Long> bindUserIds = brokerageUserMapper.selectIdListByBindUserIdIn(Collections.singleton(bindUserId));
335 if (CollUtil.isEmpty(bindUserIds)) { 334 if (CollUtil.isEmpty(bindUserIds)) {
336 return Collections.emptyList(); 335 return Collections.emptyList();
337 } 336 }
338 337
  338 + // 情况一:level 为空,查询所有级别
339 if (level == null) { 339 if (level == null) {
340 - // level 为空,再查第 2 级,并合并结果 340 + // 再查第 2 级,并合并结果
341 bindUserIds.addAll(brokerageUserMapper.selectIdListByBindUserIdIn(bindUserIds)); 341 bindUserIds.addAll(brokerageUserMapper.selectIdListByBindUserIdIn(bindUserIds));
342 - } else if (level == 2) {  
343 - // 只查第 2 级  
344 - bindUserIds = brokerageUserMapper.selectIdListByBindUserIdIn(bindUserIds);  
345 - } else if (level == 1) {  
346 - // 只查第 1 级  
347 return bindUserIds; 342 return bindUserIds;
348 - } else {  
349 - throw exception(BROKERAGE_USER_LEVEL_NOT_SUPPORT);  
350 } 343 }
351 - return bindUserIds; 344 + // 情况二:level 为 1,只查询第 1 级
  345 + if (level == 1) {
  346 + return bindUserIds;
  347 + }
  348 + // 情况三:level 为 1,只查询第 2 级
  349 + if (level == 2) {
  350 + return brokerageUserMapper.selectIdListByBindUserIdIn(bindUserIds);
  351 + }
  352 + throw exception(BROKERAGE_USER_LEVEL_NOT_SUPPORT);
352 } 353 }
353 354
354 } 355 }
yudao-server/src/main/resources/application-local.yaml
@@ -214,10 +214,6 @@ yudao: @@ -214,10 +214,6 @@ yudao:
214 enable: false 214 enable: false
215 demo: false # 关闭演示模式 215 demo: false # 关闭演示模式
216 tencent-lbs-key: TVDBZ-TDILD-4ON4B-PFDZA-RNLKH-VVF6E # QQ 地图的密钥 https://lbs.qq.com/service/staticV2/staticGuide/staticDoc 216 tencent-lbs-key: TVDBZ-TDILD-4ON4B-PFDZA-RNLKH-VVF6E # QQ 地图的密钥 https://lbs.qq.com/service/staticV2/staticGuide/staticDoc
217 - clean-job:  
218 - access-retain-day: 7  
219 - error-retain-day: 8  
220 - job-clean-retain-day: 8  
221 217
222 justauth: 218 justauth:
223 enabled: true 219 enabled: true