缓存管理器3
This commit is contained in:
@@ -5,6 +5,8 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.sqx.modules.common.entity.CommonInfo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -13,10 +15,11 @@ import java.util.List;
|
||||
* @date 2020/7/8
|
||||
*/
|
||||
@Mapper
|
||||
@CacheConfig(cacheNames = "common")
|
||||
public interface CommonInfoDao extends BaseMapper<CommonInfo> {
|
||||
|
||||
List<CommonInfo> findByCondition(@Param("condition") String condition);
|
||||
|
||||
@Cacheable(key = "#type")
|
||||
CommonInfo findOne(@Param("type") int type);
|
||||
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ public class CommonInfoServiceImpl extends ServiceImpl<CommonInfoDao, CommonInfo
|
||||
private CourseService courseService;
|
||||
|
||||
|
||||
|
||||
@CacheEvict(key = "#commonInfo.id")
|
||||
@Override
|
||||
public Result update(CommonInfo commonInfo) {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
@@ -48,20 +48,19 @@ public class CommonInfoServiceImpl extends ServiceImpl<CommonInfoDao, CommonInfo
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@Cacheable(key = "#type")
|
||||
@Override
|
||||
public CommonInfo findOne(int type) {
|
||||
return commonInfoDao.findOne(type);
|
||||
}
|
||||
|
||||
@CacheEvict
|
||||
@CacheEvict(key = "#id")
|
||||
@Override
|
||||
public Result delete(long id) {
|
||||
commonInfoDao.deleteById(id);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@CacheEvict
|
||||
@CacheEvict(key = "#commonInfo.id")
|
||||
@Override
|
||||
public Result updateBody(CommonInfo commonInfo) {
|
||||
commonInfoDao.updateById(commonInfo);
|
||||
|
||||
Reference in New Issue
Block a user