132 lines
4.2 KiB
Markdown
132 lines
4.2 KiB
Markdown
|
|
# Refactor ClosedAreaCarApplyRepositoryImpl listPage Method
|
|||
|
|
|
|||
|
|
## TL;DR
|
|||
|
|
|
|||
|
|
按照 `ClosedAreaPersonApplyRepositoryImpl.listPage()` 的实现方式重写 `ClosedAreaCarApplyRepositoryImpl.listPage()` 方法,添加 `menuPerms` 参数处理逻辑。
|
|||
|
|
|
|||
|
|
**Deliverables**:
|
|||
|
|
- 修改 `ClosedAreaCarApplyMapper.java` - 添加 listPage 方法
|
|||
|
|
- 修改 `ClosedAreaCarApplyMapper.xml` - 添加 SQL 查询
|
|||
|
|
- 修改 `ClosedAreaCarApplyRepositoryImpl.java` - 重写 listPage 方法
|
|||
|
|
|
|||
|
|
**Estimated Effort**: Quick (3 files)
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## Context
|
|||
|
|
|
|||
|
|
### Reference Implementation
|
|||
|
|
`ClosedAreaPersonApplyRepositoryImpl.listPage()` 的实现模式:
|
|||
|
|
1. 使用 `Page<Map<String, Object>>` 创建分页对象
|
|||
|
|
2. 获取 `menuPerms` 参数:通过 `MenuEnum.getMenuKeyByPath()` 转换
|
|||
|
|
3. 调用 Mapper 的自定义 `listPage` 方法
|
|||
|
|
4. 返回 `PageHelper.pageToResponse()` 结果
|
|||
|
|
|
|||
|
|
### Business Logic
|
|||
|
|
```java
|
|||
|
|
String menuPerms = "";
|
|||
|
|
if (!org.springframework.util.ObjectUtils.isEmpty(params.get("menuPath"))) {
|
|||
|
|
menuPerms = MenuEnum.getMenuKeyByPath(params.get("menuPath").toString());
|
|||
|
|
}
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## TODOs
|
|||
|
|
|
|||
|
|
- [ ] 1. Add listPage method to ClosedAreaCarApplyMapper.java
|
|||
|
|
|
|||
|
|
**What to do**:
|
|||
|
|
添加 `listPage` 方法签名,参考 ClosedAreaPersonApplyMapper
|
|||
|
|
|
|||
|
|
**File**: `web-infrastructure/src/main/java/com/zcloud/primeport/persistence/mapper/ClosedAreaCarApplyMapper.java`
|
|||
|
|
|
|||
|
|
**Code**:
|
|||
|
|
```java
|
|||
|
|
IPage<ClosedAreaCarApplyDO> listPage(Page<Map<String, Object>> page, Map<String, Object> params, String menuPerms);
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
**Imports to add**:
|
|||
|
|
```java
|
|||
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|||
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||
|
|
import java.util.Map;
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
- [ ] 2. Add listPage SQL to ClosedAreaCarApplyMapper.xml
|
|||
|
|
|
|||
|
|
**What to do**:
|
|||
|
|
添加分页查询 SQL,参考 ClosedAreaPersonApplyMapper.xml
|
|||
|
|
|
|||
|
|
**File**: `web-infrastructure/src/main/resources/mapper/ClosedAreaCarApplyMapper.xml`
|
|||
|
|
|
|||
|
|
**Code**:
|
|||
|
|
```xml
|
|||
|
|
<select id="listPage" resultType="com.zcloud.primeport.persistence.dataobject.ClosedAreaCarApplyDO">
|
|||
|
|
select * from closed_area_car_apply c
|
|||
|
|
where c.delete_enum = 'FALSE'
|
|||
|
|
<if test="params.processOrRecord != null">
|
|||
|
|
<if test="params.processOrRecord == 1">
|
|||
|
|
AND c.audit_flag = 1
|
|||
|
|
</if>
|
|||
|
|
<if test="params.processOrRecord == 2">
|
|||
|
|
AND c.audit_flag != 1
|
|||
|
|
</if>
|
|||
|
|
</if>
|
|||
|
|
<if test="params.applyPersonUserName != null and params.applyPersonUserName != ''">
|
|||
|
|
AND c.apply_person_user_name like CONCAT('%', #{params.applyPersonUserName}, '%')
|
|||
|
|
</if>
|
|||
|
|
<if test="params.licenceNo != null and params.licenceNo != ''">
|
|||
|
|
AND c.licence_no like CONCAT('%', #{params.licenceNo}, '%')
|
|||
|
|
</if>
|
|||
|
|
</select>
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
- [ ] 3. Rewrite listPage in ClosedAreaCarApplyRepositoryImpl.java
|
|||
|
|
|
|||
|
|
**What to do**:
|
|||
|
|
按照 ClosedAreaPersonApplyRepositoryImpl 的模式重写 listPage 方法
|
|||
|
|
|
|||
|
|
**File**: `web-infrastructure/src/main/java/com/zcloud/primeport/persistence/repository/impl/ClosedAreaCarApplyRepositoryImpl.java`
|
|||
|
|
|
|||
|
|
**Code**:
|
|||
|
|
```java
|
|||
|
|
@Override
|
|||
|
|
public PageResponse<ClosedAreaCarApplyDO> listPage(Map<String, Object> params) {
|
|||
|
|
Page<Map<String, Object>> page = new Page<>(Integer.parseInt(params.get("pageIndex").toString()),
|
|||
|
|
Integer.parseInt(params.get("pageSize").toString()));
|
|||
|
|
String menuPerms = "";
|
|||
|
|
if (!org.springframework.util.ObjectUtils.isEmpty(params.get("menuPath"))) {
|
|||
|
|
menuPerms = MenuEnum.getMenuKeyByPath(params.get("menuPath").toString());
|
|||
|
|
}
|
|||
|
|
IPage<ClosedAreaCarApplyDO> result = closedAreaCarApplyMapper.listPage(page, params, menuPerms);
|
|||
|
|
return PageHelper.pageToResponse(result, result.getRecords());
|
|||
|
|
}
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
**Imports to add**:
|
|||
|
|
```java
|
|||
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||
|
|
import com.zcloud.primeport.domain.enums.MenuEnum;
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## Commit Strategy
|
|||
|
|
|
|||
|
|
- **1**: `feat(closedArea): refactor ClosedAreaCarApplyRepositoryImpl listPage with menuPerms` — 3 files
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## Success Criteria
|
|||
|
|
|
|||
|
|
### Verification Commands
|
|||
|
|
```bash
|
|||
|
|
mvn compile -pl web-infrastructure
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
### Final Checklist
|
|||
|
|
- [ ] Mapper 接口添加 listPage 方法
|
|||
|
|
- [ ] XML 添加对应 SQL
|
|||
|
|
- [ ] Repository 实现重写完成
|
|||
|
|
- [ ] 编译通过
|