diff --git a/src/main/java/com/zh/project0512/controller/wxApp/TaskUController.java b/src/main/java/com/zh/project0512/controller/wxApp/TaskUController.java index 68f9a17..ae3fa7e 100644 --- a/src/main/java/com/zh/project0512/controller/wxApp/TaskUController.java +++ b/src/main/java/com/zh/project0512/controller/wxApp/TaskUController.java @@ -68,11 +68,12 @@ public class TaskUController { private ICustomerActionNoteService customerActionNoteService; @Autowired private IVideoEffectSettingService videoEffectSettingService; + @Data static class ListTParam { private int pageNum; private int pageSize; - @Schema(title = "用户的任务状态", description = "0待领取;1进行中;2已完成") + @Schema(title = "用户的任务状态", description = "0待领取;1进行中;2已完成;3已结束;4我的任务") @Min(value = 0) @Max(value = 2) private Integer status; @@ -97,17 +98,42 @@ public class TaskUController { @TokenValid public Result list(@Validated @RequestBody ListTParam param, @RequestHeader String token) { QueryWrapper qw = new QueryWrapper<>(); - Integer status = param.getStatus(); String openid = new JwtUtil().parseOpenid(token); + // 提供给前端三个状态:0待领取;1进行中;2已完成;3已结束;4我的任务 + // 与sql表中task的status意义不同,这里status-- + // 0:0待领取(未接受任务且任务status为1); + // 1:进行中(已接受任务且任务status为1); + // 2:已完成(已接受任务且任务status2); + // 3:已结束(未接受任务且任务status为2); + // 4:我的任务(已接受任务且任务status2); + Integer status = param.getStatus(); qw.ne("t1.status", 0); - if (null != status) { - qw.eq("t1.status", status == 2 ? 2 : 1); - if (status == 0) { - qw.ne("(SELECT count(*)!=0 from userTask as t4,user as t5 WHERE t1.id = t4.taskId and t4.userId = t5.id and t5.openid = +'" + openid + "' )", 1); - } else if (status == 1) { + switch (status) { + case 0: + qw.eq("t1.status", 1).ne("(SELECT count(*)!=0 from userTask as t4,user as t5 WHERE t1.id = t4.taskId and t4.userId = t5.id and t5.openid = +'" + openid + "' )", 1); + break; + case 1: + qw.eq("t1.status", 1).eq("(SELECT count(*)!=0 from userTask as t4,user as t5 WHERE t1.id = t4.taskId and t4.userId = t5.id and t5.openid = +'" + openid + "' )", 1); + break; + case 2: + qw.eq("t1.status", 2).eq("(SELECT count(*)!=0 from userTask as t4,user as t5 WHERE t1.id = t4.taskId and t4.userId = t5.id and t5.openid = +'" + openid + "' )", 1); + break; + case 3: + qw.eq("t1.status", 2).ne("(SELECT count(*)!=0 from userTask as t4,user as t5 WHERE t1.id = t4.taskId and t4.userId = t5.id and t5.openid = +'" + openid + "' )", 1); + break; + case 4: qw.eq("(SELECT count(*)!=0 from userTask as t4,user as t5 WHERE t1.id = t4.taskId and t4.userId = t5.id and t5.openid = +'" + openid + "' )", 1); - } + break; + default: } +// if (null != status) { +// qw.eq("t1.status", status == 2 ? 2 : 1); +// if (status == 0) { +// qw.ne("(SELECT count(*)!=0 from userTask as t4,user as t5 WHERE t1.id = t4.taskId and t4.userId = t5.id and t5.openid = +'" + openid + "' )", 1); +// } else if (status == 1) { +// qw.eq("(SELECT count(*)!=0 from userTask as t4,user as t5 WHERE t1.id = t4.taskId and t4.userId = t5.id and t5.openid = +'" + openid + "' )", 1); +// } +// } if (null != param.getMonth()) { qw.between("t1.creatAt", LocalDateTime.now().minusMonths(param.getMonth()), LocalDateTime.now()); } else { @@ -226,21 +252,21 @@ public class TaskUController { public Result communicationEffect(@Validated @RequestBody DetTaskParam param, @RequestHeader(value = "token") String token) { String openid = new JwtUtil().parseOpenid(token); QueryWrapper