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