Commit 38088726 38088726521fa4be3a8877b97bcc450439e833cb by xianghan

1.删除任务缓存

1 parent 8292c0b7
......@@ -65,22 +65,22 @@ public class TaskOperationController {
/**
* 修改任务
*
* @param task 消息
* @param content 消息
*/
@PostMapping(value = "/updateTask")
@ApiOperation("修改任务")
@AnonymousAccess
public void updateTask(@RequestBody @Validated Task task) {
log.info("taskOperation ==>> updateTask ==>> param ==>> {}", task);
Long id = task.getId();
public void updateTask(@RequestBody @Validated Task content) {
log.info("taskOperation ==>> updateTask ==>> param ==>> {}", content);
Long id = content.getId();
TaskDTO taskDTO = this.taskOperationService.findById(id);
if (Objects.nonNull(taskDTO.getId())) {
task.setCode(taskDTO.getCode());
Task task_ = new Task();
BeanUtils.copyProperties(taskDTO, task_);
task_.copy(task);
content.setCode(taskDTO.getCode());
Task task = new Task();
BeanUtils.copyProperties(taskDTO, task);
task.copy(content);
// 修改任务
this.taskOperationService.updateTask(task_);
this.taskOperationService.updateTask(task);
}
}
......
......@@ -47,6 +47,7 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Service;
......@@ -99,7 +100,7 @@ public class TaskOperationServiceImpl implements TaskOperationService {
private static final Integer POINTS_MIN = 1;
@Override
@CacheEvict(cacheNames = RedisKeyConstants.cacheTaskByEvent, key = "#task.event")
// @CacheEvict(cacheNames = RedisKeyConstants.cacheTaskByEvent, key = "#task.event")
public TaskDTO createTask(Task task) {
Long taskTemplateId = task.getTaskTemplateId();
TaskTemplateDTO taskTemplateDTO = this.taskTemplateService.findById(taskTemplateId);
......@@ -107,29 +108,14 @@ public class TaskOperationServiceImpl implements TaskOperationService {
task.setTaskTemplateCode(taskTemplateDTO.getCode());
Task task_ = TaskBuilder.build(task);
TaskDTO taskDTO = this.taskService.create(task_);
if (Objects.nonNull(taskDTO.getId())) {
task_.setId(taskDTO.getId());
this.createTaskAttr(task_);
}
((TaskOperationServiceImpl) AopContext.currentProxy()).asyncCreateTask(task_);
return taskDTO;
}
/**
*
* @param task 任务
*/
private void createTaskAttr(Task task) {
TaskAttr taskAttr = new TaskAttr();
// taskAttr.setAttrStr(task.getAttr());
taskAttr.setTaskId(task.getId());
this.taskAttrService.create(taskAttr);
}
@Override
@CacheEvict(cacheNames = RedisKeyConstants.cacheTaskByEvent, key = "#task.event")
// @CacheEvict(cacheNames = RedisKeyConstants.cacheTaskByEventAndMemberLevelAndVip, key = "#task.event")
public TaskDTO updateTask(Task task) {
Long taskTemplateId = task.getTaskTemplateId();
TaskTemplateDTO taskTemplateDTO = this.taskTemplateService.findById(taskTemplateId);
......@@ -149,18 +135,17 @@ public class TaskOperationServiceImpl implements TaskOperationService {
* @param task 任务
*/
private void updateTaskAttr(Task task) {
/* List<String> attr = task.getAttr();
TaskAttrDTO taskAttrDTO = this.taskAttrService.findByTaskId(task.getId());
if (Objects.nonNull(taskAttrDTO.getId())) {
TaskAttr taskAttr = new TaskAttr();
BeanUtils.copyProperties(taskAttrDTO, taskAttr);
taskAttr.setAttrStr();
taskAttr.setAttrStr(task.getAttr());
this.taskAttrService.update(taskAttr);
}*/
}
}
@Override
@CacheEvict(cacheNames = RedisKeyConstants.cacheTaskByEvent, key = "#task.event")
// @CacheEvict(cacheNames = RedisKeyConstants.cacheTaskByEvent, key = "#task.event")
public Integer deleteTask(Task task) {
Long id = task.getId();
TaskDTO taskDTO = this.findById(id);
......