diff --git a/src/main/java/sast/evento/service/impl/DepartmentServiceImpl.java b/src/main/java/sast/evento/service/impl/DepartmentServiceImpl.java index 3f25156..833419d 100644 --- a/src/main/java/sast/evento/service/impl/DepartmentServiceImpl.java +++ b/src/main/java/sast/evento/service/impl/DepartmentServiceImpl.java @@ -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; @@ -56,6 +57,7 @@ public List 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"); diff --git a/src/main/java/sast/evento/service/impl/EventServiceImpl.java b/src/main/java/sast/evento/service/impl/EventServiceImpl.java index e6a478b..eb58746 100644 --- a/src/main/java/sast/evento/service/impl/EventServiceImpl.java +++ b/src/main/java/sast/evento/service/impl/EventServiceImpl.java @@ -3,6 +3,8 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import jakarta.annotation.Resource; +import org.springframework.cache.annotation.CacheEvict; +import org.springframework.cache.annotation.Cacheable; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import sast.evento.common.enums.ActionState; @@ -108,6 +110,7 @@ public List getNewest() { // 获取活动列表(分页) @Override + @Cacheable(value = "event", key = "#page + #size") public PageModel getEvents(Integer page, Integer size) { if (page == null || page < 0 || size == null || size < 0) { throw new LocalRunTimeException(ErrorEnum.PARAM_ERROR); @@ -147,6 +150,7 @@ public List getSubscribed(String userId) { @Transactional(rollbackFor = Exception.class) @Override + @CacheEvict(value = "event") public Integer addEvent(EventModel eventModel, String userId) { Event event = new Event(eventModel); /* 检测必需参数是否存在 */ @@ -204,6 +208,7 @@ public Integer addEvent(EventModel eventModel, String userId) { @Transactional(rollbackFor = Exception.class) @Override + @CacheEvict(value = "event") public Boolean deleteEvent(Integer eventId) { if (eventId == null) { throw new LocalRunTimeException(ErrorEnum.PARAM_ERROR); @@ -223,6 +228,7 @@ public Boolean deleteEvent(Integer eventId) { @Transactional(rollbackFor = Exception.class) @Override + @CacheEvict(value = "event") public Boolean updateEvent(EventModel eventModel) { Event event = new Event(eventModel); @@ -313,6 +319,7 @@ public Boolean updateEvent(EventModel eventModel) { } @Override + @CacheEvict(value = "event") public void updateEvent(Event event) { UpdateWrapper updateWrapper = new UpdateWrapper<>(); updateWrapper.eq("id", event.getId()); @@ -321,6 +328,7 @@ public void updateEvent(Event event) { @Override + @CacheEvict(value = "event") public Boolean cancelEvent(Integer eventId) { if (eventId == null) { throw new LocalRunTimeException(ErrorEnum.PARAM_ERROR); diff --git a/src/main/java/sast/evento/service/impl/EventTypeServiceImpl.java b/src/main/java/sast/evento/service/impl/EventTypeServiceImpl.java index 0c8431d..44e84a7 100644 --- a/src/main/java/sast/evento/service/impl/EventTypeServiceImpl.java +++ b/src/main/java/sast/evento/service/impl/EventTypeServiceImpl.java @@ -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; @@ -51,6 +52,7 @@ public List getAllEventType() { } @Override + @CacheEvict(value = "event") public Boolean editEventType(EventType eventType) { UpdateWrapper updateWrapper = new UpdateWrapper<>(); updateWrapper.eq("id", eventType.getId()); diff --git a/src/main/java/sast/evento/service/impl/LocationServiceImpl.java b/src/main/java/sast/evento/service/impl/LocationServiceImpl.java index c812709..f589797 100644 --- a/src/main/java/sast/evento/service/impl/LocationServiceImpl.java +++ b/src/main/java/sast/evento/service/impl/LocationServiceImpl.java @@ -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; @@ -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); diff --git a/src/main/java/sast/evento/service/impl/PermissionServiceImpl.java b/src/main/java/sast/evento/service/impl/PermissionServiceImpl.java index d7da776..1c5bc5e 100644 --- a/src/main/java/sast/evento/service/impl/PermissionServiceImpl.java +++ b/src/main/java/sast/evento/service/impl/PermissionServiceImpl.java @@ -2,6 +2,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import fun.feellmoose.enums.Organization; import jakarta.annotation.Resource; import org.springframework.stereotype.Service; import sast.evento.common.enums.ActionState; @@ -15,7 +16,6 @@ import sast.evento.model.treeDataNodeDTO.TreeDataNode; import sast.evento.service.PermissionService; import sast.evento.service.PermissionServiceCacheAble; -import sast.sastlink.sdk.enums.Organization; import java.util.*; import java.util.stream.Collectors;