缓存
This commit is contained in:
@@ -13,6 +13,9 @@ import com.sqx.modules.course.dao.CourseDao;
|
||||
import com.sqx.modules.course.dao.CourseDetailsDao;
|
||||
import com.sqx.modules.course.entity.Course;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
@@ -23,6 +26,7 @@ import java.util.List;
|
||||
* banner图
|
||||
*/
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "banner")
|
||||
public class BannerServiceImpl extends ServiceImpl<BannerDao, Banner> implements BannerService {
|
||||
|
||||
@Autowired
|
||||
@@ -34,12 +38,14 @@ public class BannerServiceImpl extends ServiceImpl<BannerDao, Banner> implements
|
||||
|
||||
|
||||
@Override
|
||||
@Cacheable(key = "#classify")
|
||||
public List<Banner> selectBannerList(Integer classify) {
|
||||
return bannerDao.selectList(classify);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Cacheable(key = "#classify")
|
||||
public List<Banner> selectBannerLists(Integer classify) {
|
||||
return bannerDao.selectLists(classify);
|
||||
}
|
||||
@@ -51,6 +57,7 @@ public class BannerServiceImpl extends ServiceImpl<BannerDao, Banner> implements
|
||||
}
|
||||
|
||||
@Override
|
||||
@CacheEvict(cacheNames = "banner", allEntries = true)
|
||||
public int saveBody(String image, String url, Integer sort) {
|
||||
Banner banner = new Banner();
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
@@ -64,6 +71,7 @@ public class BannerServiceImpl extends ServiceImpl<BannerDao, Banner> implements
|
||||
}
|
||||
|
||||
@Override
|
||||
@CacheEvict(cacheNames = "banner", allEntries = true)
|
||||
public int insertBanner(Banner banner) {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
Date now = new Date();
|
||||
@@ -89,11 +97,13 @@ public class BannerServiceImpl extends ServiceImpl<BannerDao, Banner> implements
|
||||
}
|
||||
|
||||
@Override
|
||||
@CacheEvict(cacheNames = "banner", allEntries = true)
|
||||
public int deleteBannerById(Long id) {
|
||||
return bannerDao.deleteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
@CacheEvict(cacheNames = "banner", allEntries = true)
|
||||
public Result updateBannerStateById(Long id) {
|
||||
Banner banner = selectBannerById(id);
|
||||
if (banner != null) {
|
||||
@@ -110,6 +120,7 @@ public class BannerServiceImpl extends ServiceImpl<BannerDao, Banner> implements
|
||||
}
|
||||
|
||||
@Override
|
||||
@CacheEvict(cacheNames = "banner", allEntries = true)
|
||||
public int updateBannerById(Banner banner) {
|
||||
return bannerDao.updateById(banner);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.sqx.modules.course.controller.app;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.sqx.common.annotation.Debounce;
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.app.annotation.Login;
|
||||
import com.sqx.modules.course.service.CourseDetailsService;
|
||||
@@ -42,6 +43,7 @@ public class AppCourseController extends AbstractController {
|
||||
|
||||
@GetMapping("/selectCourseDetailsById")
|
||||
@ApiOperation("根据id查询短剧详情")
|
||||
@Debounce(interval = 5000, value = "#id,#token")
|
||||
public Result selectCourseDetailsById(Long id, String token, String courseDetailsId) {
|
||||
return courseDetailsService.selectCourseDetailsById(id, token, courseDetailsId);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user