|
@@ -264,12 +264,12 @@ public class AdminController {
|
|
|
|
|
|
|
|
// 任务管理
|
|
// 任务管理
|
|
|
@PostMapping("/tasks")
|
|
@PostMapping("/tasks")
|
|
|
- public Result<Page<Task>> getTasks(@RequestBody Map<String, Object> params) {
|
|
|
|
|
|
|
+ public Result<Map<String, Object>> getTasks(@RequestBody Map<String, Object> params) {
|
|
|
int page = params.get("page") != null ? ((Number) params.get("page")).intValue() : 1;
|
|
int page = params.get("page") != null ? ((Number) params.get("page")).intValue() : 1;
|
|
|
int size = params.get("size") != null ? ((Number) params.get("size")).intValue() : 10;
|
|
int size = params.get("size") != null ? ((Number) params.get("size")).intValue() : 10;
|
|
|
String status = (String) params.get("status");
|
|
String status = (String) params.get("status");
|
|
|
Long familyId = params.get("familyId") != null ? ((Number) params.get("familyId")).longValue() : null;
|
|
Long familyId = params.get("familyId") != null ? ((Number) params.get("familyId")).longValue() : null;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
Page<Task> pageParam = new Page<>(page, size);
|
|
Page<Task> pageParam = new Page<>(page, size);
|
|
|
LambdaQueryWrapper<Task> wrapper = new LambdaQueryWrapper<>();
|
|
LambdaQueryWrapper<Task> wrapper = new LambdaQueryWrapper<>();
|
|
|
if (status != null && !status.isEmpty()) {
|
|
if (status != null && !status.isEmpty()) {
|
|
@@ -281,7 +281,33 @@ public class AdminController {
|
|
|
wrapper.orderByDesc(Task::getCreatedAt);
|
|
wrapper.orderByDesc(Task::getCreatedAt);
|
|
|
SortUtil.applySort(wrapper);
|
|
SortUtil.applySort(wrapper);
|
|
|
Page<Task> result = taskMapper.selectPage(pageParam, wrapper);
|
|
Page<Task> result = taskMapper.selectPage(pageParam, wrapper);
|
|
|
- return Result.success(result);
|
|
|
|
|
|
|
+
|
|
|
|
|
+ // 为每条任务填充执行者名称
|
|
|
|
|
+ java.util.List<Map<String, Object>> records = new java.util.ArrayList<>();
|
|
|
|
|
+ for (Task t : result.getRecords()) {
|
|
|
|
|
+ Map<String, Object> item = new java.util.HashMap<>();
|
|
|
|
|
+ org.springframework.beans.BeanUtils.copyProperties(t, item);
|
|
|
|
|
+ // 根据 executorType 查昵称
|
|
|
|
|
+ String executorType = t.getExecutorType();
|
|
|
|
|
+ Long executorId = t.getExecutorId();
|
|
|
|
|
+ if ("child".equals(executorType) && executorId != null) {
|
|
|
|
|
+ FamilyMember fm = familyMemberMapper.selectById(executorId);
|
|
|
|
|
+ item.put("executorName", fm != null ? fm.getNickname() : "未知成员");
|
|
|
|
|
+ } else if ("parent".equals(executorType) && executorId != null) {
|
|
|
|
|
+ User u = userMapper.selectById(executorId);
|
|
|
|
|
+ item.put("executorName", u != null ? u.getNickname() : "未知用户");
|
|
|
|
|
+ } else {
|
|
|
|
|
+ item.put("executorName", "");
|
|
|
|
|
+ }
|
|
|
|
|
+ records.add(item);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ Map<String, Object> resultMap = new java.util.HashMap<>();
|
|
|
|
|
+ resultMap.put("records", records);
|
|
|
|
|
+ resultMap.put("total", result.getTotal());
|
|
|
|
|
+ resultMap.put("current", result.getCurrent());
|
|
|
|
|
+ resultMap.put("size", result.getSize());
|
|
|
|
|
+ return Result.success(resultMap);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@PostMapping("/tasks/stats")
|
|
@PostMapping("/tasks/stats")
|