|
|
@@ -14,14 +14,17 @@ import java.util.Map;
|
|
|
@RequestMapping("/api/growth-task")
|
|
|
public class GrowthTaskController {
|
|
|
|
|
|
- @Resource
|
|
|
- private GrowthTaskService growthTaskService;
|
|
|
+ @Resource
|
|
|
+ private GrowthTaskService growthTaskService;
|
|
|
|
|
|
- @Resource
|
|
|
- private GrowthTaskMapper growthTaskMapper;
|
|
|
+ @Resource
|
|
|
+ private GrowthTaskMapper growthTaskMapper;
|
|
|
|
|
|
- @Resource
|
|
|
- private com.etotem.cfc.mapper.TaskMapper taskMapper;
|
|
|
+ @Resource
|
|
|
+ private com.etotem.cfc.mapper.TaskMapper taskMapper;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private com.etotem.cfc.service.TaskService taskService;
|
|
|
|
|
|
@PostMapping("/list")
|
|
|
public Result<List<Map<String, Object>>> list(@RequestAttribute("userId") Long userId,
|
|
|
@@ -29,32 +32,59 @@ public class GrowthTaskController {
|
|
|
return Result.success(growthTaskService.getTaskList(userId, params));
|
|
|
}
|
|
|
|
|
|
- @PostMapping("/claim")
|
|
|
- public Result<String> claim(@RequestAttribute("userId") Long userId,
|
|
|
- @RequestBody Map<String, Long> params) {
|
|
|
+ @PostMapping("/claim")
|
|
|
+ public Result<String> claim(@RequestAttribute("userId") Long userId,
|
|
|
+ @RequestBody Map<String, Long> params) {
|
|
|
// 统一任务系统:奖励自动发放,无 claimed 概念
|
|
|
return Result.success("奖励已自动发放");
|
|
|
- }
|
|
|
-
|
|
|
- @PostMapping("/accept-dynamic")
|
|
|
- public Result<Map<String, Object>> acceptDynamic(@RequestAttribute("userId") Long userId,
|
|
|
- @RequestBody Map<String, Object> params) {
|
|
|
- Object taskIdObj = params.get("taskId");
|
|
|
- if (taskIdObj == null) {
|
|
|
- return Result.error("taskId不能为空");
|
|
|
- }
|
|
|
- Long taskId = ((Number) taskIdObj).longValue();
|
|
|
- // 统一任务系统:AI 任务已迁入 tasks 表(source_type=ai)
|
|
|
- com.etotem.cfc.entity.Task task = taskMapper.selectById(taskId);
|
|
|
- if (task == null) {
|
|
|
- return Result.error("任务不存在");
|
|
|
- }
|
|
|
- Map<String, Object> taskInfo = new java.util.HashMap<>();
|
|
|
- taskInfo.put("id", task.getId());
|
|
|
- taskInfo.put("title", task.getTitle());
|
|
|
- taskInfo.put("description", task.getDescription());
|
|
|
- taskInfo.put("dimension", task.getDimensionCode());
|
|
|
- taskInfo.put("rewardPoints", task.getPoints());
|
|
|
- return Result.success(taskInfo);
|
|
|
- }
|
|
|
- }
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/accept-dynamic")
|
|
|
+ public Result<Map<String, Object>> acceptDynamic(@RequestAttribute("userId") Long userId,
|
|
|
+ @RequestBody Map<String, Object> params) {
|
|
|
+ Object taskIdObj = params.get("taskId");
|
|
|
+ if (taskIdObj == null) {
|
|
|
+ return Result.error("taskId不能为空");
|
|
|
+ }
|
|
|
+ Long taskId = ((Number) taskIdObj).longValue();
|
|
|
+ // 统一任务系统:AI 任务已迁入 tasks 表(source_type=ai)
|
|
|
+ com.etotem.cfc.entity.Task task = taskMapper.selectById(taskId);
|
|
|
+ if (task == null) {
|
|
|
+ return Result.error("任务不存在");
|
|
|
+ }
|
|
|
+ Map<String, Object> taskInfo = new java.util.HashMap<>();
|
|
|
+ taskInfo.put("id", task.getId());
|
|
|
+ taskInfo.put("title", task.getTitle());
|
|
|
+ taskInfo.put("description", task.getDescription());
|
|
|
+ taskInfo.put("dimension", task.getDimensionCode());
|
|
|
+ taskInfo.put("rewardPoints", task.getPoints());
|
|
|
+ return Result.success(taskInfo);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 方案任务打卡提交(SC-C-05 任务打卡⭐,能力键 child.task.checkin)。
|
|
|
+ *
|
|
|
+ * <p>委托统一任务系统 {@code TaskService.completeTask} 完成打卡提交:幂等(T24-A)、
|
|
|
+ * 发奖/审核流转/逾期限均走既有链路;本端点只做入参承载与结果包装。</p>
|
|
|
+ *
|
|
|
+ * @param dto 打卡提交入参(memberId/taskId + photoUrl/content 凭证)
|
|
|
+ */
|
|
|
+ @PostMapping("/checkin")
|
|
|
+ public Result<Map<String, Object>> checkin(@RequestBody com.etotem.cfc.dto.TaskCheckinDTO dto,
|
|
|
+ @RequestAttribute(value = "currentMemberId", required = false) Long currentMemberId) {
|
|
|
+ if (dto == null) {
|
|
|
+ return Result.error("打卡入参不能为空");
|
|
|
+ }
|
|
|
+ if (dto.getTaskId() == null) {
|
|
|
+ return Result.error("taskId不能为空");
|
|
|
+ }
|
|
|
+ Long memberId = dto.getMemberId() != null ? dto.getMemberId() : currentMemberId;
|
|
|
+ Map<String, Object> result = taskService.completeTask(dto.getTaskId(), memberId,
|
|
|
+ dto.getPhotoUrl(), dto.getContent(),
|
|
|
+ dto.getContentType() != null ? dto.getContentType() : "text");
|
|
|
+ if (result != null) {
|
|
|
+ return Result.success(result);
|
|
|
+ }
|
|
|
+ return Result.error("任务不存在、无权完成或状态已变更");
|
|
|
+ }
|
|
|
+ }
|