From af1d0eb74be55ac04d8fe6c71718de899e1fac71 Mon Sep 17 00:00:00 2001 From: xujun Date: Wed, 20 May 2026 16:02:13 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=A7=84=E5=88=99=E6=96=87?= =?UTF-8?q?=E4=BB=B6,=E4=BC=98=E5=8C=96=E6=96=87=E4=BB=B6=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E6=97=A5=E5=BF=97=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rules/rules.md | 10 +++++----- .../app/sys/service/impl/SysFileServiceImpl.java | 3 +++ 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/rules/rules.md b/rules/rules.md index aef2c36..db985a0 100644 --- a/rules/rules.md +++ b/rules/rules.md @@ -117,7 +117,7 @@ xtools-app-{module}-biz/ #### 3.1 注解使用规范 - 控制器类使用`@RestController`注解 -- 服务实现类使用`@Service`和`@Primary`注解 +- 服务实现类使用`@Service`注解;实现API接口时需添加`@Primary`注解 - BaseService类使用`@Component`注解 - Mapper接口使用`@Mapper`注解 - 转换器接口使用`@Mapper(componentModel = "spring")`注解(MapStruct) @@ -129,7 +129,7 @@ xtools-app-{module}-biz/ #### 3.2 继承关系规范 - BaseService类继承`ServiceImpl`(MyBatis Plus),使用`@Component`注解 -- ServiceImpl类实现Service接口,注入BaseService和Convert进行业务操作 +- ServiceImpl类实现Service接口,注入BaseService和Convert进行业务操作;实现API接口时需添加`@Primary`注解 - Controller类通过构造器注入Service接口 - API接口定义为Java interface,方法返回`Result` - 实体类继承`BaseEntity`(来自`xtools.boot.api.model.entity.BaseEntity`) @@ -179,7 +179,7 @@ xtools-app-{module}-biz/ - 主键策略统一使用`IdType.ASSIGN_ID` #### 4.4 Mapper规范 -- Mapper接口继承`BaseMapper`(MyBatis Plus) +- Mapper接口按需继承`BaseMapper`(MyBatis Plus),并非所有Mapper都需要继承 - 使用`@Mapper`注解 - 复杂查询使用MyBatis XML映射文件,放置在`resources/mapper/`目录下 - XML中使用`LambdaQueryWrapper`或动态SQL(``、``、``) @@ -272,10 +272,10 @@ xtools-app-{module}-biz/ #### 8.2 代码生成检查清单 - [ ] 实体类继承`BaseEntity`,使用`IdType.ASSIGN_ID`主键策略 -- [ ] Mapper继承`BaseMapper`,使用`@Mapper`注解 +- [ ] 需要CRUD操作的Mapper继承`BaseMapper`,使用`@Mapper`注解 - [ ] BaseService继承`ServiceImpl`,使用`@Component`注解 - [ ] Service接口定义返回`Result`的完整CRUD方法 -- [ ] ServiceImpl使用`@Service`、`@Primary`、`@RequiredArgsConstructor`注解 +- [ ] ServiceImpl使用`@Service`、`@RequiredArgsConstructor`注解;实现API接口时需添加`@Primary`注解 - [ ] Convert使用`@Mapper(componentModel = "spring")`注解 - [ ] Controller使用`@RestController`、`@Tag`、`@Operation`注解 - [ ] 所有DTO字段添加`@Schema`注解 diff --git a/xtools-app-sys/xtools-app-sys-biz/src/main/java/xtools/app/sys/service/impl/SysFileServiceImpl.java b/xtools-app-sys/xtools-app-sys-biz/src/main/java/xtools/app/sys/service/impl/SysFileServiceImpl.java index 86c3074..9a2a180 100644 --- a/xtools-app-sys/xtools-app-sys-biz/src/main/java/xtools/app/sys/service/impl/SysFileServiceImpl.java +++ b/xtools-app-sys/xtools-app-sys-biz/src/main/java/xtools/app/sys/service/impl/SysFileServiceImpl.java @@ -30,6 +30,7 @@ import xtools.boot.api.model.dto.req.IdListReq; import xtools.boot.db.mybatisplus.utils.QueryUtils; import xtools.boot.log.LogBus; import xtools.boot.log.enums.LogBusBaseType; +import xtools.boot.log.holder.LogTrackHolder; import xtools.boot.storage.base.config.StorageConfig; import xtools.boot.storage.base.service.StorageService; import xtools.boot.task.TaskBus; @@ -361,6 +362,7 @@ public class SysFileServiceImpl implements SysFileService, BaseParams { } String type = storageConfig.getType(); Set ids = new HashSet<>(list.size()); + LogTrackHolder.saveLog(false); for (SysFile item : list) { if (!Objects.equals(type, item.getStorageType())) { continue; @@ -373,6 +375,7 @@ public class SysFileServiceImpl implements SysFileService, BaseParams { } ids.add(item.getId()); } + LogTrackHolder.saveLog(true); return sysFileBaseService.getBaseMapper().deleteByIds(ids); }