|
|
@@ -523,7 +523,7 @@ public class AdminFamilyOverviewControllerTest {
|
|
|
}
|
|
|
@Test void tasks_分页() {
|
|
|
when(svc.pageTasks(eq(7L), anyLong(), anyLong())).thenReturn(new Page<>());
|
|
|
- Result<Page<com.etotem.cfc.dto.TaskItemVO>> r = ctrl.getTasks(7L, 1L, 20L, "admin");
|
|
|
+ Result<Page<com.etotem.cfc.dto.TaskItemVO>> r = ctrl.getTasks(7L, null, "admin");
|
|
|
assertEquals(200, r.getCode());
|
|
|
}
|
|
|
}
|
|
|
@@ -570,14 +570,16 @@ public class AdminFamilyOverviewController {
|
|
|
@Operation(summary = "家庭任务分页")
|
|
|
@PostMapping("/families/{id}/tasks")
|
|
|
public Result<Page<TaskItemVO>> getTasks(@PathVariable Long id,
|
|
|
- @RequestParam(defaultValue = "1") Long page,
|
|
|
- @RequestParam(defaultValue = "20") Long size,
|
|
|
+ @RequestBody(required = false) Map<String, Object> params,
|
|
|
@RequestAttribute("role") String role) {
|
|
|
if (!"admin".equals(role)) return Result.error("无权限");
|
|
|
+ long page = params != null && params.get("page") != null ? ((Number) params.get("page")).longValue() : 1L;
|
|
|
+ long size = params != null && params.get("size") != null ? ((Number) params.get("size")).longValue() : 20L;
|
|
|
return Result.success(service.pageTasks(id, page, size));
|
|
|
}
|
|
|
}
|
|
|
```
|
|
|
+(import `java.util.Map`;分页参数从 `@RequestBody` body 读取——与现有 `getFamilies` 风格及前端 `data: params` 一致,非 `@RequestParam`)
|
|
|
|
|
|
> 注:`Result` 需有 `getCode()`/`getData()`(现有 `Result` 类已有 success/error;若 `getCode()` 不存在用 `r.getCode()` 或对应 getter——以实际 `Result` 类为准)。
|
|
|
|
|
|
@@ -770,6 +772,7 @@ load / loadTasks:
|
|
|
async load() { this.overview = null; const res = await getFamilyOverview(this.familyId); this.overview = res.data; this.loadTasks(1) }
|
|
|
async loadTasks(page) { this.taskPage = page; const res = await getFamilyTasks(this.familyId, { page, size: this.taskSize }); this.tasks = res.data.records; this.taskTotal = res.data.total }
|
|
|
```
|
|
|
+script 需 `import { formatDate } from '@/utils/format'`(`formatDate` 来自 `cfc-web/src/utils/format.js`,Families.vue 已同源使用)。
|
|
|
|
|
|
- [ ] **Step 2: 提交**
|
|
|
|