|
|
|
@ -0,0 +1,74 @@
|
|
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2018-2999 广州市蓝海创新科技有限公司 All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* https://www.mall4j.com/
|
|
|
|
|
*
|
|
|
|
|
* 未经允许,不可做商业用途!
|
|
|
|
|
*
|
|
|
|
|
* 版权所有,侵权必究!
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
package com.yami.shop.service.impl;
|
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.cache.annotation.CacheEvict;
|
|
|
|
|
import org.springframework.cache.annotation.Cacheable;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
import com.yami.shop.bean.model.IndexImg;
|
|
|
|
|
import com.yami.shop.dao.IndexImgMapper;
|
|
|
|
|
import com.yami.shop.service.IndexImgService;
|
|
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* IndexImgServiceImpl 是IndexImgService接口的具体实现类。
|
|
|
|
|
* 它继承自MyBatis-Plus提供的ServiceImpl,并实现了IndexImgService接口中定义的方法。
|
|
|
|
|
* 该服务负责处理与首页图片(IndexImg)相关的业务逻辑。
|
|
|
|
|
*
|
|
|
|
|
* @author lgh on 2018/11/26.
|
|
|
|
|
*/
|
|
|
|
|
@Service
|
|
|
|
|
public class IndexImgServiceImpl extends ServiceImpl<IndexImgMapper, IndexImg> implements IndexImgService {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* indexImgMapper是通过Spring自动装配的DAO层组件,
|
|
|
|
|
* 用于执行对IndexImg实体对应的数据库表的操作。
|
|
|
|
|
*/
|
|
|
|
|
@Autowired
|
|
|
|
|
private IndexImgMapper indexImgMapper;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* deleteIndexImgByIds方法实现了根据给定ID列表批量删除首页图片的功能。
|
|
|
|
|
* 它调用了indexImgMapper中的deleteIndexImgByIds方法来执行实际的删除操作。
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public void deleteIndexImgByIds(Long[] ids) {
|
|
|
|
|
indexImgMapper.deleteIndexImgByIds(ids);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* listIndexImg方法返回所有首页图片的列表。
|
|
|
|
|
* 使用了@Cacheable注解以启用Spring Cache缓存机制,
|
|
|
|
|
* 这样可以避免重复查询数据库,提高性能。
|
|
|
|
|
* 当首次调用此方法时,结果会被缓存起来;
|
|
|
|
|
* 后续相同请求将直接从缓存中读取数据,直到缓存失效或被手动清除。
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
@Cacheable(cacheNames = "indexImg", key = "'indexImg'")
|
|
|
|
|
public List<IndexImg> listIndexImg() {
|
|
|
|
|
return indexImgMapper.listIndexImg();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* removeIndexImgCache方法用于清除首页图片的缓存。
|
|
|
|
|
* 使用了@CacheEvict注解,当调用此方法时会清除指定名称的缓存,
|
|
|
|
|
* 确保在需要的时候缓存内容是最新的。
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
@CacheEvict(cacheNames = "indexImg", key = "'indexImg'")
|
|
|
|
|
public void removeIndexImgCache() {
|
|
|
|
|
// 方法体为空,因为实际的缓存清除工作由@CacheEvict注解完成。
|
|
|
|
|
}
|
|
|
|
|
}
|