Skip to content

Commit

Permalink
fix: 当Department/EventType/Location名字改变时清理event缓存
Browse files Browse the repository at this point in the history
  • Loading branch information
ballade0d committed Feb 16, 2024
1 parent 53adde3 commit b294b65
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import jakarta.annotation.Resource;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.stereotype.Service;
import sast.evento.common.enums.ErrorEnum;
import sast.evento.entitiy.Department;
Expand Down Expand Up @@ -56,6 +57,7 @@ public List<Department> getDepartments() {
}

@Override
@CacheEvict(value = "event")
public void putDepartment(Integer departmentId, String departmentName) {
if (departmentMapper.updateById(new Department(departmentId, departmentName)) < 1) {
throw new LocalRunTimeException(ErrorEnum.COMMON_ERROR, "update failed");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import jakarta.annotation.Resource;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.stereotype.Service;
import sast.evento.common.enums.ErrorEnum;
import sast.evento.entitiy.EventType;
Expand Down Expand Up @@ -51,6 +52,7 @@ public List<EventType> getAllEventType() {
}

@Override
@CacheEvict(value = "event")
public Boolean editEventType(EventType eventType) {
UpdateWrapper<EventType> updateWrapper = new UpdateWrapper<>();
updateWrapper.eq("id", eventType.getId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import jakarta.annotation.Resource;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.stereotype.Service;
import sast.evento.common.enums.ErrorEnum;
import sast.evento.entitiy.Location;
Expand Down Expand Up @@ -61,6 +62,7 @@ public Boolean deleteLocation(Integer id) {
}

@Override
@CacheEvict(value = "event")
public Boolean updateLocation(Location location) {
if (location == null) {
throw new LocalRunTimeException(ErrorEnum.PARAM_ERROR);
Expand Down

0 comments on commit b294b65

Please sign in to comment.