分类编辑时,清除缓存;优化代码
This commit is contained in:
parent
17c7552f7f
commit
1ecd32027e
@ -4,9 +4,6 @@ package cn.lili.modules.goods.service;
|
|||||||
import cn.lili.modules.goods.entity.dos.Category;
|
import cn.lili.modules.goods.entity.dos.Category;
|
||||||
import cn.lili.modules.goods.entity.vos.CategoryVO;
|
import cn.lili.modules.goods.entity.vos.CategoryVO;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import org.springframework.cache.annotation.CacheConfig;
|
|
||||||
import org.springframework.cache.annotation.CacheEvict;
|
|
||||||
import org.springframework.cache.annotation.Cacheable;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -16,7 +13,6 @@ import java.util.List;
|
|||||||
* @author pikachu
|
* @author pikachu
|
||||||
* @since 2020-03-02 16:44:56
|
* @since 2020-03-02 16:44:56
|
||||||
*/
|
*/
|
||||||
@CacheConfig(cacheNames = "{category}")
|
|
||||||
public interface CategoryService extends IService<Category> {
|
public interface CategoryService extends IService<Category> {
|
||||||
|
|
||||||
|
|
||||||
@ -35,7 +31,6 @@ public interface CategoryService extends IService<Category> {
|
|||||||
* @param id
|
* @param id
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Cacheable(key = "#id")
|
|
||||||
Category getCategoryById(String id);
|
Category getCategoryById(String id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -99,7 +94,6 @@ public interface CategoryService extends IService<Category> {
|
|||||||
* @param category 商品分类信息
|
* @param category 商品分类信息
|
||||||
* @return 修改结果
|
* @return 修改结果
|
||||||
*/
|
*/
|
||||||
@CacheEvict(key = "#category.id")
|
|
||||||
void updateCategory(Category category);
|
void updateCategory(Category category);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -19,6 +19,9 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
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 org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
@ -36,6 +39,7 @@ import java.util.stream.Collectors;
|
|||||||
* @since 2020-02-23 15:18:56
|
* @since 2020-02-23 15:18:56
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
|
@CacheConfig(cacheNames = "{CATEGORY}")
|
||||||
public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, Category> implements CategoryService {
|
public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, Category> implements CategoryService {
|
||||||
|
|
||||||
private static final String DELETE_FLAG_COLUMN = "delete_flag";
|
private static final String DELETE_FLAG_COLUMN = "delete_flag";
|
||||||
@ -60,6 +64,7 @@ public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, Category> i
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Cacheable(key = "#id")
|
||||||
public Category getCategoryById(String id) {
|
public Category getCategoryById(String id) {
|
||||||
return this.getById(id);
|
return this.getById(id);
|
||||||
}
|
}
|
||||||
@ -216,6 +221,7 @@ public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, Category> i
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@CacheEvict(key = "#category.id")
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void updateCategory(Category category) {
|
public void updateCategory(Category category) {
|
||||||
//判断分类佣金是否正确
|
//判断分类佣金是否正确
|
||||||
@ -242,6 +248,7 @@ public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, Category> i
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@CacheEvict(key = "#id")
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void delete(String id) {
|
public void delete(String id) {
|
||||||
this.removeById(id);
|
this.removeById(id);
|
||||||
@ -253,6 +260,7 @@ public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, Category> i
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@CacheEvict(key = "#categoryId")
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void updateCategoryStatus(String categoryId, Boolean enableOperations) {
|
public void updateCategoryStatus(String categoryId, Boolean enableOperations) {
|
||||||
//禁用子分类
|
//禁用子分类
|
||||||
@ -346,5 +354,6 @@ public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, Category> i
|
|||||||
*/
|
*/
|
||||||
private void removeCache() {
|
private void removeCache() {
|
||||||
cache.remove(CachePrefix.CATEGORY.getPrefix());
|
cache.remove(CachePrefix.CATEGORY.getPrefix());
|
||||||
|
cache.remove(CachePrefix.CATEGORY_ARRAY.getPrefix());
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -709,6 +709,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
|||||||
* @return 是否成功
|
* @return 是否成功
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public boolean checkFictitiousOrder(String pintuanId, Integer requiredNum, Boolean fictitious) {
|
public boolean checkFictitiousOrder(String pintuanId, Integer requiredNum, Boolean fictitious) {
|
||||||
Map<String, List<Order>> collect = this.queryListByPromotion(pintuanId)
|
Map<String, List<Order>> collect = this.queryListByPromotion(pintuanId)
|
||||||
.stream().collect(Collectors.groupingBy(Order::getParentOrderSn));
|
.stream().collect(Collectors.groupingBy(Order::getParentOrderSn));
|
||||||
@ -813,7 +814,6 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
|||||||
//如果为开团订单,则发布一个一小时的延时任务,时间到达后,如果未成团则自动结束(未开启虚拟成团的情况下)
|
//如果为开团订单,则发布一个一小时的延时任务,时间到达后,如果未成团则自动结束(未开启虚拟成团的情况下)
|
||||||
PintuanOrderMessage pintuanOrderMessage = new PintuanOrderMessage();
|
PintuanOrderMessage pintuanOrderMessage = new PintuanOrderMessage();
|
||||||
//开团结束时间
|
//开团结束时间
|
||||||
// long startTime = DateUtil.offsetHour(new Date(), 1).getTime();
|
|
||||||
long startTime = DateUtil.offsetMinute(new Date(), 2).getTime();
|
long startTime = DateUtil.offsetMinute(new Date(), 2).getTime();
|
||||||
pintuanOrderMessage.setOrderSn(parentOrderSn);
|
pintuanOrderMessage.setOrderSn(parentOrderSn);
|
||||||
pintuanOrderMessage.setPintuanId(pintuanId);
|
pintuanOrderMessage.setPintuanId(pintuanId);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user