diff --git a/dao/src/main/java/cn/bunny/dao/entity/log/ScheduleExecuteLog.java b/dao/src/main/java/cn/bunny/dao/entity/log/schedule/ScheduleExecuteLog.java similarity index 69% rename from dao/src/main/java/cn/bunny/dao/entity/log/ScheduleExecuteLog.java rename to dao/src/main/java/cn/bunny/dao/entity/log/schedule/ScheduleExecuteLog.java index 1c6b13b..c359f01 100644 --- a/dao/src/main/java/cn/bunny/dao/entity/log/ScheduleExecuteLog.java +++ b/dao/src/main/java/cn/bunny/dao/entity/log/schedule/ScheduleExecuteLog.java @@ -1,11 +1,14 @@ -package cn.bunny.dao.entity.log; +package cn.bunny.dao.entity.log.schedule; -import cn.bunny.dao.common.entity.BaseEntity; -import com.baomidou.mybatisplus.annotation.TableName; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; +import org.bson.types.ObjectId; +import org.springframework.data.annotation.Id; +import org.springframework.data.mongodb.core.mapping.Document; +import org.springframework.data.mongodb.core.mapping.FieldType; +import org.springframework.data.mongodb.core.mapping.MongoId; /** *

@@ -18,9 +21,13 @@ import lombok.experimental.Accessors; @Getter @Setter @Accessors(chain = true) -@TableName("log_quartz_execute") +@Document(collection = "log_quartz_execute") @Schema(name = "QuartzExecuteLog对象", title = "调度任务执行日志", description = "调度任务执行日志") -public class ScheduleExecuteLog extends BaseEntity { +public class ScheduleExecuteLog { + + @Id + @MongoId(targetType = FieldType.STRING) + private ObjectId id; @Schema(name = "jobName", title = "任务名称") private String jobName; diff --git a/dao/src/main/java/cn/bunny/dao/entity/log/ScheduleExecuteLogJson.java b/dao/src/main/java/cn/bunny/dao/entity/log/schedule/ScheduleExecuteLogJson.java similarity index 95% rename from dao/src/main/java/cn/bunny/dao/entity/log/ScheduleExecuteLogJson.java rename to dao/src/main/java/cn/bunny/dao/entity/log/schedule/ScheduleExecuteLogJson.java index d521931..2e3468f 100644 --- a/dao/src/main/java/cn/bunny/dao/entity/log/ScheduleExecuteLogJson.java +++ b/dao/src/main/java/cn/bunny/dao/entity/log/schedule/ScheduleExecuteLogJson.java @@ -1,4 +1,4 @@ -package cn.bunny.dao.entity.log; +package cn.bunny.dao.entity.log.schedule; import io.swagger.v3.oas.annotations.media.Schema; import lombok.AllArgsConstructor; diff --git a/dao/src/main/java/cn/bunny/dao/entity/system/SystemLog.java b/dao/src/main/java/cn/bunny/dao/entity/system/SystemLog.java deleted file mode 100644 index f56b6ab..0000000 --- a/dao/src/main/java/cn/bunny/dao/entity/system/SystemLog.java +++ /dev/null @@ -1,55 +0,0 @@ -package cn.bunny.dao.entity.system; - -import cn.bunny.dao.common.entity.BaseEntity; -import com.baomidou.mybatisplus.annotation.TableName; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Getter; -import lombok.Setter; -import lombok.experimental.Accessors; - -/** - *

- * 系统日志表 - *

- * - * @author Bunny - * @since 2024-05-31 - */ -@Getter -@Setter -@Accessors(chain = true) -@TableName("system_log") -@Schema(name = "SystemLog对象", title = "系统日志表", description = "系统日志表") -public class SystemLog extends BaseEntity { - - @Schema(name = "classPath", title = "所在类路径") - private String classPath; - - @Schema(name = "methodName", title = "执行方法名称") - private String methodName; - - @Schema(name = "args", title = "入参内容") - private String args; - - @Schema(name = "result", title = "返回参数") - private String result; - - @Schema(name = "errorStack", title = "报错堆栈") - private String errorStack; - - @Schema(name = "errorMessage", title = "报错") - private String errorMessage; - - @Schema(name = "email", title = "邮箱") - private String email; - - @Schema(name = "nickname", title = "用户名") - private String nickname; - - @Schema(name = "token", title = "当前用户token") - private String token; - - @Schema(name = "ipAddress", title = "当前用户IP地址") - private String ipAddress; - -} \ No newline at end of file diff --git a/dao/src/main/java/cn/bunny/dao/vo/log/QuartzExecuteLogVo.java b/dao/src/main/java/cn/bunny/dao/vo/log/ScheduleExecuteLogVo.java similarity index 66% rename from dao/src/main/java/cn/bunny/dao/vo/log/QuartzExecuteLogVo.java rename to dao/src/main/java/cn/bunny/dao/vo/log/ScheduleExecuteLogVo.java index ef3e9e5..32f772f 100644 --- a/dao/src/main/java/cn/bunny/dao/vo/log/QuartzExecuteLogVo.java +++ b/dao/src/main/java/cn/bunny/dao/vo/log/ScheduleExecuteLogVo.java @@ -1,16 +1,20 @@ package cn.bunny.dao.vo.log; -import cn.bunny.dao.common.vo.BaseUserVo; import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; -@EqualsAndHashCode(callSuper = true) @Data @AllArgsConstructor @NoArgsConstructor @Builder -@Schema(name = "QuartzExecuteLogVo对象", title = "调度任务执行日志返回对象", description = "调度任务执行日志返回对象") -public class QuartzExecuteLogVo extends BaseUserVo { +@Schema(name = "ScheduleExecuteLogVo对象", title = "调度任务执行日志返回对象", description = "调度任务执行日志返回对象") +public class ScheduleExecuteLogVo { + + @Schema(name = "id", title = "id") + private String id; @Schema(name = "jobName", title = "任务名称") private String jobName; @@ -31,6 +35,6 @@ public class QuartzExecuteLogVo extends BaseUserVo { private String executeResult; @Schema(name = "duration", title = "执行时间") - private Integer duration; + private Long duration; } diff --git a/service/src/main/java/cn/bunny/services/aop/JobExecuteAop.java b/service/src/main/java/cn/bunny/services/aop/JobExecuteAop.java index 30c94af..b4002cd 100644 --- a/service/src/main/java/cn/bunny/services/aop/JobExecuteAop.java +++ b/service/src/main/java/cn/bunny/services/aop/JobExecuteAop.java @@ -1,10 +1,10 @@ package cn.bunny.services.aop; -import cn.bunny.dao.entity.log.ScheduleExecuteLog; -import cn.bunny.dao.entity.log.ScheduleExecuteLogJson; +import cn.bunny.dao.entity.log.schedule.ScheduleExecuteLog; +import cn.bunny.dao.entity.log.schedule.ScheduleExecuteLogJson; import cn.bunny.dao.pojo.constant.LocalDateTimeConstant; import cn.bunny.dao.pojo.enums.JobEnums; -import cn.bunny.services.mapper.schedule.ScheduleExecuteLogMapper; +import cn.bunny.services.repository.ScheduleExecuteLogRepository; import com.alibaba.fastjson2.JSON; import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.annotation.Around; @@ -27,7 +27,7 @@ public class JobExecuteAop { private static final DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(LocalDateTimeConstant.YYYY_MM_DD_HH_MM_SS); @Autowired - private ScheduleExecuteLogMapper scheduleExecuteLogMapper; + private ScheduleExecuteLogRepository scheduleExecuteLogRepository; @Around(value = "pointCut()") public Object aroundMethod(ProceedingJoinPoint joinPoint) { @@ -65,7 +65,7 @@ public class JobExecuteAop { executeLogJson.setOperationTime(startExecuteTime); executeLogJson.setExecuteParams(jobDataMap); executeLog.setExecuteResult(JSON.toJSONString(executeLogJson)); - scheduleExecuteLogMapper.insert(executeLog); + scheduleExecuteLogRepository.insert(executeLog); // 执行... result = joinPoint.proceed(); @@ -98,7 +98,7 @@ public class JobExecuteAop { executeLog.setId(null); executeLog.setExecuteResult(JSON.toJSONString(executeLogJson)); executeLog.setDuration(Duration.between(startLocalDateTime, endLocalDateTime).toSeconds()); - scheduleExecuteLogMapper.insert(executeLog); + scheduleExecuteLogRepository.insert(executeLog); } @Pointcut("execution(* cn.bunny.services.quartz.*.execute(..))") diff --git a/service/src/main/java/cn/bunny/services/controller/schedule/ScheduleExecuteLogController.java b/service/src/main/java/cn/bunny/services/controller/log/ScheduleExecuteLogController.java similarity index 76% rename from service/src/main/java/cn/bunny/services/controller/schedule/ScheduleExecuteLogController.java rename to service/src/main/java/cn/bunny/services/controller/log/ScheduleExecuteLogController.java index a9ce9d7..509f9d5 100644 --- a/service/src/main/java/cn/bunny/services/controller/schedule/ScheduleExecuteLogController.java +++ b/service/src/main/java/cn/bunny/services/controller/log/ScheduleExecuteLogController.java @@ -1,18 +1,17 @@ -package cn.bunny.services.controller.schedule; +package cn.bunny.services.controller.log; import cn.bunny.dao.dto.log.ScheduleExecuteLogDto; -import cn.bunny.dao.entity.log.ScheduleExecuteLog; import cn.bunny.dao.pojo.result.PageResult; import cn.bunny.dao.pojo.result.Result; import cn.bunny.dao.pojo.result.ResultCodeEnum; -import cn.bunny.dao.vo.log.QuartzExecuteLogVo; +import cn.bunny.dao.vo.log.ScheduleExecuteLogVo; import cn.bunny.services.aop.annotation.ExcludeRequestLog; -import cn.bunny.services.service.schedule.ScheduleExecuteLogService; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import cn.bunny.services.service.log.ScheduleExecuteLogService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.PageRequest; import org.springframework.web.bind.annotation.*; import reactor.core.publisher.Mono; @@ -37,20 +36,23 @@ public class ScheduleExecuteLogController { @ExcludeRequestLog @Operation(summary = "分页查询调度任务执行日志", description = "分页查询调度任务执行日志") @GetMapping("getQuartzExecuteLogList/{page}/{limit}") - public Mono>> getQuartzExecuteLogList( + public Mono>> getQuartzExecuteLogList( @Parameter(name = "page", description = "当前页", required = true) @PathVariable("page") Integer page, @Parameter(name = "limit", description = "每页记录数", required = true) @PathVariable("limit") Integer limit, ScheduleExecuteLogDto dto) { - Page pageParams = new Page<>(page, limit); - PageResult pageResult = scheduleExecuteLogService.getQuartzExecuteLogList(pageParams, dto); + // 设置分页参数 + page = page - 1; + PageRequest pageable = PageRequest.of(page < 0 ? 0 : page, limit); + + PageResult pageResult = scheduleExecuteLogService.getQuartzExecuteLogList(pageable, dto); return Mono.just(Result.success(pageResult)); } @Operation(summary = "删除调度任务执行日志", description = "删除调度任务执行日志") @DeleteMapping("deleteQuartzExecuteLog") - public Mono> deleteQuartzExecuteLog(@RequestBody List ids) { + public Mono> deleteQuartzExecuteLog(@RequestBody List ids) { scheduleExecuteLogService.deleteQuartzExecuteLog(ids); return Mono.just(Result.success(ResultCodeEnum.DELETE_SUCCESS)); } diff --git a/service/src/main/java/cn/bunny/services/controller/system/UserLoginLogController.java b/service/src/main/java/cn/bunny/services/controller/log/UserLoginLogController.java similarity index 96% rename from service/src/main/java/cn/bunny/services/controller/system/UserLoginLogController.java rename to service/src/main/java/cn/bunny/services/controller/log/UserLoginLogController.java index 16ead69..b97e39a 100644 --- a/service/src/main/java/cn/bunny/services/controller/system/UserLoginLogController.java +++ b/service/src/main/java/cn/bunny/services/controller/log/UserLoginLogController.java @@ -1,4 +1,4 @@ -package cn.bunny.services.controller.system; +package cn.bunny.services.controller.log; import cn.bunny.dao.dto.log.UserLoginLogDto; import cn.bunny.dao.entity.log.UserLoginLog; @@ -8,7 +8,7 @@ import cn.bunny.dao.pojo.result.ResultCodeEnum; import cn.bunny.dao.vo.log.UserLoginLogLocalVo; import cn.bunny.dao.vo.log.UserLoginLogVo; import cn.bunny.services.aop.annotation.ExcludeRequestLog; -import cn.bunny.services.service.system.UserLoginLogService; +import cn.bunny.services.service.log.UserLoginLogService; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; diff --git a/service/src/main/java/cn/bunny/services/controller/system/UserRequestLogController.java b/service/src/main/java/cn/bunny/services/controller/log/UserRequestLogController.java similarity index 84% rename from service/src/main/java/cn/bunny/services/controller/system/UserRequestLogController.java rename to service/src/main/java/cn/bunny/services/controller/log/UserRequestLogController.java index 0bb9b15..dbc20b0 100644 --- a/service/src/main/java/cn/bunny/services/controller/system/UserRequestLogController.java +++ b/service/src/main/java/cn/bunny/services/controller/log/UserRequestLogController.java @@ -1,17 +1,16 @@ -package cn.bunny.services.controller.system; +package cn.bunny.services.controller.log; import cn.bunny.dao.dto.log.UserRequestLogDto; import cn.bunny.dao.pojo.result.PageResult; import cn.bunny.dao.pojo.result.Result; import cn.bunny.dao.vo.log.UserRequestLogVo; import cn.bunny.services.aop.annotation.ExcludeRequestLog; -import cn.bunny.services.service.system.UserRequestLogService; +import cn.bunny.services.service.log.UserRequestLogService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.PageRequest; -import org.springframework.data.domain.Pageable; import org.springframework.web.bind.annotation.*; import reactor.core.publisher.Mono; @@ -36,15 +35,18 @@ public class UserRequestLogController { @Operation(summary = "分页查询用户请求日志", description = "分页查询用户请求日志") @ExcludeRequestLog @GetMapping("getRequestLogList/{page}/{limit}") - public Mono>> getRequestLogList( + public Result> getRequestLogList( @Parameter(name = "page", description = "当前页", required = true) @PathVariable("page") Integer page, @Parameter(name = "limit", description = "每页记录数", required = true) @PathVariable("limit") Integer limit, UserRequestLogDto dto) { - Pageable pageable = PageRequest.of(page, limit); + // 设置分页参数 + page = page - 1; + PageRequest pageable = PageRequest.of(page < 0 ? 0 : page, limit); + PageResult pageResult = userRequestLogService.getRequestLogList(pageable, dto); - return Mono.just(Result.success(pageResult)); + return Result.success(pageResult); } @Operation(summary = "删除用户请求日志", description = "删除用户请求日志") diff --git a/service/src/main/java/cn/bunny/services/mapper/schedule/ScheduleExecuteLogMapper.java b/service/src/main/java/cn/bunny/services/mapper/schedule/ScheduleExecuteLogMapper.java deleted file mode 100644 index 11de5b0..0000000 --- a/service/src/main/java/cn/bunny/services/mapper/schedule/ScheduleExecuteLogMapper.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.bunny.services.mapper.schedule; - -import cn.bunny.dao.dto.log.ScheduleExecuteLogDto; -import cn.bunny.dao.entity.log.ScheduleExecuteLog; -import cn.bunny.dao.vo.log.QuartzExecuteLogVo; -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; - -import java.util.List; - -/** - *

- * 调度任务执行日志 Mapper 接口 - *

- * - * @author Bunny - * @since 2024-10-18 12:56:39 - */ -@Mapper -public interface ScheduleExecuteLogMapper extends BaseMapper { - - /** - * * 分页查询调度任务执行日志内容 - * - * @param pageParams 调度任务执行日志分页参数 - * @param dto 调度任务执行日志查询表单 - * @return 调度任务执行日志分页结果 - */ - IPage selectListByPage(@Param("page") Page pageParams, @Param("dto") ScheduleExecuteLogDto dto); - - /** - * 物理删除调度任务执行日志 - * - * @param ids 删除 id 列表 - */ - void deleteBatchIdsWithPhysics(List ids); -} diff --git a/service/src/main/java/cn/bunny/services/repository/ScheduleExecuteLogRepository.java b/service/src/main/java/cn/bunny/services/repository/ScheduleExecuteLogRepository.java new file mode 100644 index 0000000..ae1d814 --- /dev/null +++ b/service/src/main/java/cn/bunny/services/repository/ScheduleExecuteLogRepository.java @@ -0,0 +1,9 @@ +package cn.bunny.services.repository; + +import cn.bunny.dao.entity.log.schedule.ScheduleExecuteLog; +import org.bson.types.ObjectId; +import org.springframework.data.mongodb.repository.MongoRepository; + +public interface ScheduleExecuteLogRepository extends MongoRepository { + +} \ No newline at end of file diff --git a/service/src/main/java/cn/bunny/services/repository/UserRequestLogRepository.java b/service/src/main/java/cn/bunny/services/repository/UserRequestLogRepository.java index e9a7363..0cd22fa 100644 --- a/service/src/main/java/cn/bunny/services/repository/UserRequestLogRepository.java +++ b/service/src/main/java/cn/bunny/services/repository/UserRequestLogRepository.java @@ -5,5 +5,5 @@ import org.bson.types.ObjectId; import org.springframework.data.mongodb.repository.MongoRepository; public interface UserRequestLogRepository extends MongoRepository { - } + diff --git a/service/src/main/java/cn/bunny/services/service/log/ScheduleExecuteLogService.java b/service/src/main/java/cn/bunny/services/service/log/ScheduleExecuteLogService.java new file mode 100644 index 0000000..1bec013 --- /dev/null +++ b/service/src/main/java/cn/bunny/services/service/log/ScheduleExecuteLogService.java @@ -0,0 +1,33 @@ +package cn.bunny.services.service.log; + +import cn.bunny.dao.dto.log.ScheduleExecuteLogDto; +import cn.bunny.dao.pojo.result.PageResult; +import cn.bunny.dao.vo.log.ScheduleExecuteLogVo; +import org.springframework.data.domain.PageRequest; + +import java.util.List; + +/** + *

+ * 调度任务执行日志 服务类 + *

+ * + * @author Bunny + * @since 2024-10-18 12:56:39 + */ +public interface ScheduleExecuteLogService { + + /** + * * 获取调度任务执行日志列表 + * + * @return 调度任务执行日志返回列表 + */ + PageResult getQuartzExecuteLogList(PageRequest pageable, ScheduleExecuteLogDto dto); + + /** + * * 删除|批量删除调度任务执行日志类型 + * + * @param ids 删除id列表 + */ + void deleteQuartzExecuteLog(List ids); +} diff --git a/service/src/main/java/cn/bunny/services/service/system/UserLoginLogService.java b/service/src/main/java/cn/bunny/services/service/log/UserLoginLogService.java similarity index 96% rename from service/src/main/java/cn/bunny/services/service/system/UserLoginLogService.java rename to service/src/main/java/cn/bunny/services/service/log/UserLoginLogService.java index d7bd053..f2d5d59 100644 --- a/service/src/main/java/cn/bunny/services/service/system/UserLoginLogService.java +++ b/service/src/main/java/cn/bunny/services/service/log/UserLoginLogService.java @@ -1,4 +1,4 @@ -package cn.bunny.services.service.system; +package cn.bunny.services.service.log; import cn.bunny.dao.dto.log.UserLoginLogDto; import cn.bunny.dao.entity.log.UserLoginLog; diff --git a/service/src/main/java/cn/bunny/services/service/system/UserRequestLogService.java b/service/src/main/java/cn/bunny/services/service/log/UserRequestLogService.java similarity index 72% rename from service/src/main/java/cn/bunny/services/service/system/UserRequestLogService.java rename to service/src/main/java/cn/bunny/services/service/log/UserRequestLogService.java index c831173..03a5f28 100644 --- a/service/src/main/java/cn/bunny/services/service/system/UserRequestLogService.java +++ b/service/src/main/java/cn/bunny/services/service/log/UserRequestLogService.java @@ -1,9 +1,9 @@ -package cn.bunny.services.service.system; +package cn.bunny.services.service.log; import cn.bunny.dao.dto.log.UserRequestLogDto; import cn.bunny.dao.pojo.result.PageResult; import cn.bunny.dao.vo.log.UserRequestLogVo; -import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.PageRequest; import java.util.List; @@ -16,7 +16,7 @@ public interface UserRequestLogService { * @param dto 表单查询 * @return 分页结果 */ - PageResult getRequestLogList(Pageable pageable, UserRequestLogDto dto); + PageResult getRequestLogList(PageRequest pageable, UserRequestLogDto dto); /** * 删除用户请求日志 diff --git a/service/src/main/java/cn/bunny/services/service/log/impl/ScheduleExecuteLogServiceImpl.java b/service/src/main/java/cn/bunny/services/service/log/impl/ScheduleExecuteLogServiceImpl.java new file mode 100644 index 0000000..81b73c6 --- /dev/null +++ b/service/src/main/java/cn/bunny/services/service/log/impl/ScheduleExecuteLogServiceImpl.java @@ -0,0 +1,78 @@ +package cn.bunny.services.service.log.impl; + +import cn.bunny.dao.dto.log.ScheduleExecuteLogDto; +import cn.bunny.dao.entity.log.schedule.ScheduleExecuteLog; +import cn.bunny.dao.pojo.result.PageResult; +import cn.bunny.dao.vo.log.ScheduleExecuteLogVo; +import cn.bunny.services.repository.ScheduleExecuteLogRepository; +import cn.bunny.services.service.log.ScheduleExecuteLogService; +import org.bson.types.ObjectId; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Example; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + *

+ * 调度任务执行日志 服务实现类 + *

+ * + * @author Bunny + * @since 2024-10-18 12:56:39 + */ +@Service +public class ScheduleExecuteLogServiceImpl implements ScheduleExecuteLogService { + + @Autowired + private ScheduleExecuteLogRepository scheduleExecuteLogRepository; + + /** + * * 调度任务执行日志 服务实现类 + * + * @param pageable 调度任务执行日志分页查询page对象 + * @param dto 调度任务执行日志分页查询对象 + * @return 查询分页调度任务执行日志返回对象 + */ + @Override + public PageResult getQuartzExecuteLogList(PageRequest pageable, ScheduleExecuteLogDto dto) { + // 封装条件 + ScheduleExecuteLog scheduleExecuteLog = new ScheduleExecuteLog(); + BeanUtils.copyProperties(dto, scheduleExecuteLog); + + // 构建条件 + Example example = Example.of(scheduleExecuteLog); + Page page = scheduleExecuteLogRepository.findAll(example, pageable); + + // 设置返回结果 + List list = page.getContent().stream().map(executeLog -> { + ScheduleExecuteLogVo vo = new ScheduleExecuteLogVo(); + BeanUtils.copyProperties(executeLog, vo); + + String hexString = executeLog.getId().toHexString(); + vo.setId(hexString); + return vo; + }).toList(); + + return PageResult.builder() + .list(list) + .pageNo((long) page.getNumber()) + .pageSize((long) page.getSize()) + .total(page.getTotalElements()) + .build(); + } + + /** + * 删除|批量删除调度任务执行日志 + * + * @param ids 删除id列表 + */ + @Override + public void deleteQuartzExecuteLog(List ids) { + List idList = ids.stream().map(ObjectId::new).toList(); + scheduleExecuteLogRepository.deleteAllById(idList); + } +} diff --git a/service/src/main/java/cn/bunny/services/service/system/impl/UserLoginLogServiceImpl.java b/service/src/main/java/cn/bunny/services/service/log/impl/UserLoginLogServiceImpl.java similarity index 96% rename from service/src/main/java/cn/bunny/services/service/system/impl/UserLoginLogServiceImpl.java rename to service/src/main/java/cn/bunny/services/service/log/impl/UserLoginLogServiceImpl.java index a708f3f..c3ae95d 100644 --- a/service/src/main/java/cn/bunny/services/service/system/impl/UserLoginLogServiceImpl.java +++ b/service/src/main/java/cn/bunny/services/service/log/impl/UserLoginLogServiceImpl.java @@ -1,4 +1,4 @@ -package cn.bunny.services.service.system.impl; +package cn.bunny.services.service.log.impl; import cn.bunny.common.service.context.BaseContext; import cn.bunny.dao.dto.log.UserLoginLogDto; @@ -7,7 +7,7 @@ import cn.bunny.dao.pojo.result.PageResult; import cn.bunny.dao.vo.log.UserLoginLogLocalVo; import cn.bunny.dao.vo.log.UserLoginLogVo; import cn.bunny.services.mapper.system.UserLoginLogMapper; -import cn.bunny.services.service.system.UserLoginLogService; +import cn.bunny.services.service.log.UserLoginLogService; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; diff --git a/service/src/main/java/cn/bunny/services/service/system/impl/UserRequestLogServiceImpl.java b/service/src/main/java/cn/bunny/services/service/log/impl/UserRequestLogServiceImpl.java similarity index 88% rename from service/src/main/java/cn/bunny/services/service/system/impl/UserRequestLogServiceImpl.java rename to service/src/main/java/cn/bunny/services/service/log/impl/UserRequestLogServiceImpl.java index 1689824..e0a7d7b 100644 --- a/service/src/main/java/cn/bunny/services/service/system/impl/UserRequestLogServiceImpl.java +++ b/service/src/main/java/cn/bunny/services/service/log/impl/UserRequestLogServiceImpl.java @@ -1,17 +1,17 @@ -package cn.bunny.services.service.system.impl; +package cn.bunny.services.service.log.impl; import cn.bunny.dao.dto.log.UserRequestLogDto; import cn.bunny.dao.entity.log.UserRequestLog; import cn.bunny.dao.pojo.result.PageResult; import cn.bunny.dao.vo.log.UserRequestLogVo; import cn.bunny.services.repository.UserRequestLogRepository; -import cn.bunny.services.service.system.UserRequestLogService; +import cn.bunny.services.service.log.UserRequestLogService; import org.bson.types.ObjectId; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Example; import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.PageRequest; import org.springframework.stereotype.Service; import java.util.List; @@ -30,7 +30,7 @@ public class UserRequestLogServiceImpl implements UserRequestLogService { * @return 分页结果 */ @Override - public PageResult getRequestLogList(Pageable pageable, UserRequestLogDto dto) { + public PageResult getRequestLogList(PageRequest pageable, UserRequestLogDto dto) { // 封装条件 UserRequestLog userRequestLog = new UserRequestLog(); BeanUtils.copyProperties(dto, userRequestLog); @@ -38,6 +38,7 @@ public class UserRequestLogServiceImpl implements UserRequestLogService { // 构建条件 Example example = Example.of(userRequestLog); Page page = userRequestLogRepository.findAll(example, pageable); + List content = page.getContent().stream().map(requestLog -> { UserRequestLogVo vo = new UserRequestLogVo(); BeanUtils.copyProperties(requestLog, vo); diff --git a/service/src/main/java/cn/bunny/services/service/schedule/ScheduleExecuteLogService.java b/service/src/main/java/cn/bunny/services/service/schedule/ScheduleExecuteLogService.java deleted file mode 100644 index 212730e..0000000 --- a/service/src/main/java/cn/bunny/services/service/schedule/ScheduleExecuteLogService.java +++ /dev/null @@ -1,35 +0,0 @@ -package cn.bunny.services.service.schedule; - -import cn.bunny.dao.dto.log.ScheduleExecuteLogDto; -import cn.bunny.dao.entity.log.ScheduleExecuteLog; -import cn.bunny.dao.pojo.result.PageResult; -import cn.bunny.dao.vo.log.QuartzExecuteLogVo; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.baomidou.mybatisplus.extension.service.IService; - -import java.util.List; - -/** - *

- * 调度任务执行日志 服务类 - *

- * - * @author Bunny - * @since 2024-10-18 12:56:39 - */ -public interface ScheduleExecuteLogService extends IService { - - /** - * * 获取调度任务执行日志列表 - * - * @return 调度任务执行日志返回列表 - */ - PageResult getQuartzExecuteLogList(Page pageParams, ScheduleExecuteLogDto dto); - - /** - * * 删除|批量删除调度任务执行日志类型 - * - * @param ids 删除id列表 - */ - void deleteQuartzExecuteLog(List ids); -} diff --git a/service/src/main/java/cn/bunny/services/service/schedule/impl/ScheduleExecuteLogServiceImpl.java b/service/src/main/java/cn/bunny/services/service/schedule/impl/ScheduleExecuteLogServiceImpl.java deleted file mode 100644 index 40a138b..0000000 --- a/service/src/main/java/cn/bunny/services/service/schedule/impl/ScheduleExecuteLogServiceImpl.java +++ /dev/null @@ -1,55 +0,0 @@ -package cn.bunny.services.service.schedule.impl; - -import cn.bunny.dao.dto.log.ScheduleExecuteLogDto; -import cn.bunny.dao.entity.log.ScheduleExecuteLog; -import cn.bunny.dao.pojo.result.PageResult; -import cn.bunny.dao.vo.log.QuartzExecuteLogVo; -import cn.bunny.services.mapper.schedule.ScheduleExecuteLogMapper; -import cn.bunny.services.service.schedule.ScheduleExecuteLogService; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import org.springframework.stereotype.Service; - -import java.util.List; - -/** - *

- * 调度任务执行日志 服务实现类 - *

- * - * @author Bunny - * @since 2024-10-18 12:56:39 - */ -@Service -public class ScheduleExecuteLogServiceImpl extends ServiceImpl implements ScheduleExecuteLogService { - - /** - * * 调度任务执行日志 服务实现类 - * - * @param pageParams 调度任务执行日志分页查询page对象 - * @param dto 调度任务执行日志分页查询对象 - * @return 查询分页调度任务执行日志返回对象 - */ - @Override - public PageResult getQuartzExecuteLogList(Page pageParams, ScheduleExecuteLogDto dto) { - IPage page = baseMapper.selectListByPage(pageParams, dto); - - return PageResult.builder() - .list(page.getRecords()) - .pageNo(page.getCurrent()) - .pageSize(page.getSize()) - .total(page.getTotal()) - .build(); - } - - /** - * 删除|批量删除调度任务执行日志 - * - * @param ids 删除id列表 - */ - @Override - public void deleteQuartzExecuteLog(List ids) { - baseMapper.deleteBatchIdsWithPhysics(ids); - } -} diff --git a/service/src/main/resources/banner.txt b/service/src/main/resources/banner.txt index e8d5472..dd4fcfa 100644 --- a/service/src/main/resources/banner.txt +++ b/service/src/main/resources/banner.txt @@ -1,6 +1,10 @@ + _ _ | |__ _ _ _ __ _ __ _ _ (_) __ ___ ____ _ | '_ \| | | | '_ \| '_ \| | | | | |/ _` \ \ / / _` | | |_) | |_| | | | | | | | |_| | | | (_| |\ V | (_| | |_.__/ \__,_|_| |_|_| |_|\__, | _/ |\__,_| \_/ \__,_| - |___/ |__/ \ No newline at end of file + |___/ |__/ +${AnsiColor.BRIGHT_GREEN} +SpringBoot Version: ${spring-boot.version}${spring-boot.formatted-version} +${AnsiColor.BLACK} \ No newline at end of file diff --git a/service/src/main/resources/mapper/schedule/ScheduleExecuteLogMapper.xml b/service/src/main/resources/mapper/schedule/ScheduleExecuteLogMapper.xml deleted file mode 100644 index 40ba81b..0000000 --- a/service/src/main/resources/mapper/schedule/ScheduleExecuteLogMapper.xml +++ /dev/null @@ -1,66 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - id, create_time, update_time, create_user, update_user, is_deleted, job_name, job_group, job_class_name, cron_expression, trigger_name, execute_result, duration - - - - - - - - delete - from log_quartz_execute - where id in - - #{id} - - - - diff --git a/service/src/test/java/cn/bunny/services/service/system/impl/UserRequestLogServiceImplTest.java b/service/src/test/java/cn/bunny/services/service/system/impl/UserRequestLogServiceImplTest.java new file mode 100644 index 0000000..9175d97 --- /dev/null +++ b/service/src/test/java/cn/bunny/services/service/system/impl/UserRequestLogServiceImplTest.java @@ -0,0 +1,30 @@ +package cn.bunny.services.service.system.impl; + +import cn.bunny.dao.entity.log.UserRequestLog; +import cn.bunny.services.repository.UserRequestLogRepository; +import com.alibaba.fastjson2.JSON; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.data.domain.Example; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; + +@SpringBootTest +class UserRequestLogServiceImplTest { + + @Autowired + private UserRequestLogRepository userRequestLogRepository; + + @Test + void getRequestLogList() { + // 封装条件 + UserRequestLog userRequestLog = new UserRequestLog(); + PageRequest pageable = PageRequest.of(0, 150); + + // 构建条件 + Example example = Example.of(userRequestLog); + Page page = userRequestLogRepository.findAll(example, pageable); + page.getContent().forEach(item -> System.out.println(JSON.toJSONString(item))); + } +} \ No newline at end of file