1.删除任务缓存
Showing
2 changed files
with
15 additions
and
30 deletions
| ... | @@ -65,22 +65,22 @@ public class TaskOperationController { | ... | @@ -65,22 +65,22 @@ public class TaskOperationController { |
| 65 | /** | 65 | /** |
| 66 | * 修改任务 | 66 | * 修改任务 |
| 67 | * | 67 | * |
| 68 | * @param task 消息 | 68 | * @param content 消息 |
| 69 | */ | 69 | */ |
| 70 | @PostMapping(value = "/updateTask") | 70 | @PostMapping(value = "/updateTask") |
| 71 | @ApiOperation("修改任务") | 71 | @ApiOperation("修改任务") |
| 72 | @AnonymousAccess | 72 | @AnonymousAccess |
| 73 | public void updateTask(@RequestBody @Validated Task task) { | 73 | public void updateTask(@RequestBody @Validated Task content) { |
| 74 | log.info("taskOperation ==>> updateTask ==>> param ==>> {}", task); | 74 | log.info("taskOperation ==>> updateTask ==>> param ==>> {}", content); |
| 75 | Long id = task.getId(); | 75 | Long id = content.getId(); |
| 76 | TaskDTO taskDTO = this.taskOperationService.findById(id); | 76 | TaskDTO taskDTO = this.taskOperationService.findById(id); |
| 77 | if (Objects.nonNull(taskDTO.getId())) { | 77 | if (Objects.nonNull(taskDTO.getId())) { |
| 78 | task.setCode(taskDTO.getCode()); | 78 | content.setCode(taskDTO.getCode()); |
| 79 | Task task_ = new Task(); | 79 | Task task = new Task(); |
| 80 | BeanUtils.copyProperties(taskDTO, task_); | 80 | BeanUtils.copyProperties(taskDTO, task); |
| 81 | task_.copy(task); | 81 | task.copy(content); |
| 82 | // 修改任务 | 82 | // 修改任务 |
| 83 | this.taskOperationService.updateTask(task_); | 83 | this.taskOperationService.updateTask(task); |
| 84 | } | 84 | } |
| 85 | } | 85 | } |
| 86 | 86 | ... | ... |
| ... | @@ -47,6 +47,7 @@ import org.springframework.beans.BeanUtils; | ... | @@ -47,6 +47,7 @@ import org.springframework.beans.BeanUtils; |
| 47 | import org.springframework.beans.factory.annotation.Autowired; | 47 | import org.springframework.beans.factory.annotation.Autowired; |
| 48 | import org.springframework.beans.factory.annotation.Value; | 48 | import org.springframework.beans.factory.annotation.Value; |
| 49 | import org.springframework.cache.annotation.CacheEvict; | 49 | import org.springframework.cache.annotation.CacheEvict; |
| 50 | import org.springframework.data.redis.core.RedisTemplate; | ||
| 50 | import org.springframework.data.redis.core.StringRedisTemplate; | 51 | import org.springframework.data.redis.core.StringRedisTemplate; |
| 51 | import org.springframework.data.redis.core.ValueOperations; | 52 | import org.springframework.data.redis.core.ValueOperations; |
| 52 | import org.springframework.stereotype.Service; | 53 | import org.springframework.stereotype.Service; |
| ... | @@ -99,7 +100,7 @@ public class TaskOperationServiceImpl implements TaskOperationService { | ... | @@ -99,7 +100,7 @@ public class TaskOperationServiceImpl implements TaskOperationService { |
| 99 | private static final Integer POINTS_MIN = 1; | 100 | private static final Integer POINTS_MIN = 1; |
| 100 | 101 | ||
| 101 | @Override | 102 | @Override |
| 102 | @CacheEvict(cacheNames = RedisKeyConstants.cacheTaskByEvent, key = "#task.event") | 103 | // @CacheEvict(cacheNames = RedisKeyConstants.cacheTaskByEvent, key = "#task.event") |
| 103 | public TaskDTO createTask(Task task) { | 104 | public TaskDTO createTask(Task task) { |
| 104 | Long taskTemplateId = task.getTaskTemplateId(); | 105 | Long taskTemplateId = task.getTaskTemplateId(); |
| 105 | TaskTemplateDTO taskTemplateDTO = this.taskTemplateService.findById(taskTemplateId); | 106 | TaskTemplateDTO taskTemplateDTO = this.taskTemplateService.findById(taskTemplateId); |
| ... | @@ -107,29 +108,14 @@ public class TaskOperationServiceImpl implements TaskOperationService { | ... | @@ -107,29 +108,14 @@ public class TaskOperationServiceImpl implements TaskOperationService { |
| 107 | task.setTaskTemplateCode(taskTemplateDTO.getCode()); | 108 | task.setTaskTemplateCode(taskTemplateDTO.getCode()); |
| 108 | Task task_ = TaskBuilder.build(task); | 109 | Task task_ = TaskBuilder.build(task); |
| 109 | TaskDTO taskDTO = this.taskService.create(task_); | 110 | TaskDTO taskDTO = this.taskService.create(task_); |
| 110 | if (Objects.nonNull(taskDTO.getId())) { | ||
| 111 | task_.setId(taskDTO.getId()); | ||
| 112 | this.createTaskAttr(task_); | ||
| 113 | } | ||
| 114 | 111 | ||
| 115 | ((TaskOperationServiceImpl) AopContext.currentProxy()).asyncCreateTask(task_); | 112 | ((TaskOperationServiceImpl) AopContext.currentProxy()).asyncCreateTask(task_); |
| 116 | 113 | ||
| 117 | return taskDTO; | 114 | return taskDTO; |
| 118 | } | 115 | } |
| 119 | 116 | ||
| 120 | /** | ||
| 121 | * | ||
| 122 | * @param task 任务 | ||
| 123 | */ | ||
| 124 | private void createTaskAttr(Task task) { | ||
| 125 | TaskAttr taskAttr = new TaskAttr(); | ||
| 126 | // taskAttr.setAttrStr(task.getAttr()); | ||
| 127 | taskAttr.setTaskId(task.getId()); | ||
| 128 | this.taskAttrService.create(taskAttr); | ||
| 129 | } | ||
| 130 | |||
| 131 | @Override | 117 | @Override |
| 132 | @CacheEvict(cacheNames = RedisKeyConstants.cacheTaskByEvent, key = "#task.event") | 118 | // @CacheEvict(cacheNames = RedisKeyConstants.cacheTaskByEventAndMemberLevelAndVip, key = "#task.event") |
| 133 | public TaskDTO updateTask(Task task) { | 119 | public TaskDTO updateTask(Task task) { |
| 134 | Long taskTemplateId = task.getTaskTemplateId(); | 120 | Long taskTemplateId = task.getTaskTemplateId(); |
| 135 | TaskTemplateDTO taskTemplateDTO = this.taskTemplateService.findById(taskTemplateId); | 121 | TaskTemplateDTO taskTemplateDTO = this.taskTemplateService.findById(taskTemplateId); |
| ... | @@ -149,18 +135,17 @@ public class TaskOperationServiceImpl implements TaskOperationService { | ... | @@ -149,18 +135,17 @@ public class TaskOperationServiceImpl implements TaskOperationService { |
| 149 | * @param task 任务 | 135 | * @param task 任务 |
| 150 | */ | 136 | */ |
| 151 | private void updateTaskAttr(Task task) { | 137 | private void updateTaskAttr(Task task) { |
| 152 | /* List<String> attr = task.getAttr(); | ||
| 153 | TaskAttrDTO taskAttrDTO = this.taskAttrService.findByTaskId(task.getId()); | 138 | TaskAttrDTO taskAttrDTO = this.taskAttrService.findByTaskId(task.getId()); |
| 154 | if (Objects.nonNull(taskAttrDTO.getId())) { | 139 | if (Objects.nonNull(taskAttrDTO.getId())) { |
| 155 | TaskAttr taskAttr = new TaskAttr(); | 140 | TaskAttr taskAttr = new TaskAttr(); |
| 156 | BeanUtils.copyProperties(taskAttrDTO, taskAttr); | 141 | BeanUtils.copyProperties(taskAttrDTO, taskAttr); |
| 157 | taskAttr.setAttrStr(); | 142 | taskAttr.setAttrStr(task.getAttr()); |
| 158 | this.taskAttrService.update(taskAttr); | 143 | this.taskAttrService.update(taskAttr); |
| 159 | }*/ | 144 | } |
| 160 | } | 145 | } |
| 161 | 146 | ||
| 162 | @Override | 147 | @Override |
| 163 | @CacheEvict(cacheNames = RedisKeyConstants.cacheTaskByEvent, key = "#task.event") | 148 | // @CacheEvict(cacheNames = RedisKeyConstants.cacheTaskByEvent, key = "#task.event") |
| 164 | public Integer deleteTask(Task task) { | 149 | public Integer deleteTask(Task task) { |
| 165 | Long id = task.getId(); | 150 | Long id = task.getId(); |
| 166 | TaskDTO taskDTO = this.findById(id); | 151 | TaskDTO taskDTO = this.findById(id); | ... | ... |
-
Please register or sign in to post a comment