|
|
@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.etotem.cfc.common.Result;
|
|
|
import com.etotem.cfc.dto.CreateProductOrderDTO;
|
|
|
import com.etotem.cfc.dto.CreateTaskDTO;
|
|
|
+import com.etotem.cfc.dto.FamilyTaskCreateDTO;
|
|
|
import com.etotem.cfc.dto.ProductOrderDTO;
|
|
|
import com.etotem.cfc.dto.TaskReviewDTO;
|
|
|
import com.etotem.cfc.entity.*;
|
|
|
@@ -2274,4 +2275,61 @@ return points; // 达到每日扣分上限:不扣分,任务完成仍发放
|
|
|
}
|
|
|
return taskMapper.selectList(wrapper);
|
|
|
}
|
|
|
+
|
|
|
+ /** 工作台-admin 任务新增:family_id/creator_id 固定来自服务端,status 默认 pending */
|
|
|
+ public Long createAdminFamilyTask(Long familyId, Long adminUserId, FamilyTaskCreateDTO dto) {
|
|
|
+ Task t = new Task();
|
|
|
+ t.setFamilyId(familyId);
|
|
|
+ t.setCreatorId(adminUserId);
|
|
|
+ t.setTitle(dto.getTitle());
|
|
|
+ t.setDescription(dto.getDescription());
|
|
|
+ t.setCategory(dto.getCategory());
|
|
|
+ t.setPoints(dto.getPoints());
|
|
|
+ t.setDuration(dto.getDuration());
|
|
|
+ t.setTaskType(dto.getTaskType());
|
|
|
+ t.setFrequency(dto.getFrequency());
|
|
|
+ t.setMaxFrequency(dto.getMaxFrequency());
|
|
|
+ t.setNeedReview(dto.getNeedReview());
|
|
|
+ t.setReviewType(dto.getReviewType());
|
|
|
+ t.setCompleteTypes(dto.getCompleteTypes() == null ? null : String.join(",", dto.getCompleteTypes()));
|
|
|
+ t.setExecutorType(dto.getExecutorType());
|
|
|
+ t.setExecutorId(dto.getExecutorId());
|
|
|
+ t.setMemberId(dto.getMemberId());
|
|
|
+ t.setRepeatType(dto.getRepeatType());
|
|
|
+ t.setDeadline(dto.getDeadline());
|
|
|
+ t.setStatus("pending");
|
|
|
+ t.setSourceType("admin");
|
|
|
+ t.setCreatedAt(new Date());
|
|
|
+ t.setUpdatedAt(new Date());
|
|
|
+ taskMapper.insert(t);
|
|
|
+ return t.getId();
|
|
|
+ }
|
|
|
+
|
|
|
+ /** 工作台-admin 任务编辑:任务存在且 family_id 与 URL 一致,否则拒绝(防跨家庭越权) */
|
|
|
+ public boolean updateAdminFamilyTask(Long taskId, Long familyId, FamilyTaskCreateDTO dto) {
|
|
|
+ Task t = taskMapper.selectById(taskId);
|
|
|
+ if (t == null) throw new RuntimeException("任务不存在");
|
|
|
+ if (t.getFamilyId() == null || !t.getFamilyId().equals(familyId)) {
|
|
|
+ throw new RuntimeException("任务不属于该家庭");
|
|
|
+ }
|
|
|
+ t.setTitle(dto.getTitle());
|
|
|
+ t.setDescription(dto.getDescription());
|
|
|
+ t.setCategory(dto.getCategory());
|
|
|
+ t.setPoints(dto.getPoints());
|
|
|
+ t.setDuration(dto.getDuration());
|
|
|
+ t.setTaskType(dto.getTaskType());
|
|
|
+ t.setFrequency(dto.getFrequency());
|
|
|
+ t.setMaxFrequency(dto.getMaxFrequency());
|
|
|
+ t.setNeedReview(dto.getNeedReview());
|
|
|
+ t.setReviewType(dto.getReviewType());
|
|
|
+ if (dto.getCompleteTypes() != null) t.setCompleteTypes(String.join(",", dto.getCompleteTypes()));
|
|
|
+ t.setExecutorType(dto.getExecutorType());
|
|
|
+ t.setExecutorId(dto.getExecutorId());
|
|
|
+ t.setMemberId(dto.getMemberId());
|
|
|
+ t.setRepeatType(dto.getRepeatType());
|
|
|
+ t.setDeadline(dto.getDeadline());
|
|
|
+ t.setUpdatedAt(new Date());
|
|
|
+ return taskMapper.updateById(t) > 0;
|
|
|
+ }
|
|
|
+
|
|
|
}
|