diff --git a/buyer-api/src/main/resources/application.yml b/buyer-api/src/main/resources/application.yml index 43f1ad58..246a0680 100644 --- a/buyer-api/src/main/resources/application.yml +++ b/buyer-api/src/main/resources/application.yml @@ -69,10 +69,10 @@ spring: url: jdbc:mysql://127.0.0.1:3306/lilishop?useUnicode=true&characterEncoding=utf-8&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai username: root password: lilishop - maxActive: 20 - initialSize: 5 + maxActive: 50 + initialSize: 10 maxWait: 60000 - minIdle: 5 + minIdle: 10 timeBetweenEvictionRunsMillis: 60000 minEvictableIdleTimeMillis: 300000 validationQuery: SELECT 1 FROM DUAL diff --git a/config/application.yml b/config/application.yml index 5021c081..0753c11f 100644 --- a/config/application.yml +++ b/config/application.yml @@ -72,8 +72,8 @@ spring: url: jdbc:mysql://192.168.0.116:3306/lilishop?useUnicode=true&characterEncoding=utf-8&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai username: root password: lilishop - maxActive: 20 - initialSize: 5 + maxActive: 50 + initialSize: 20 maxWait: 60000 minIdle: 5 timeBetweenEvictionRunsMillis: 60000 diff --git a/framework/src/main/java/cn/lili/modules/goods/service/CategoryService.java b/framework/src/main/java/cn/lili/modules/goods/service/CategoryService.java index 4069d49d..519b0c96 100644 --- a/framework/src/main/java/cn/lili/modules/goods/service/CategoryService.java +++ b/framework/src/main/java/cn/lili/modules/goods/service/CategoryService.java @@ -4,7 +4,11 @@ package cn.lili.modules.goods.service; import cn.lili.modules.goods.entity.dos.Category; import cn.lili.modules.goods.entity.vos.CategoryVO; 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.io.Serializable; import java.util.List; /** @@ -13,6 +17,7 @@ import java.util.List; * @author pikachu * @since 2020-03-02 16:44:56 */ +@CacheConfig(cacheNames = "{category}") public interface CategoryService extends IService { @@ -25,6 +30,15 @@ public interface CategoryService extends IService { */ List dbList(String parentId); + /** + * 获取分类 + * + * @param id + * @return + */ + @Cacheable(key = "#id") + Category getCategoryById(String id); + /** * 根据分类id集合获取所有分类根据层级排序 * @@ -86,6 +100,7 @@ public interface CategoryService extends IService { * @param category 商品分类信息 * @return 修改结果 */ + @CacheEvict(key = "#category.id") void updateCategory(Category category); /** diff --git a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/CategoryServiceImpl.java b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/CategoryServiceImpl.java index ab31d983..e7c5dee0 100644 --- a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/CategoryServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/CategoryServiceImpl.java @@ -60,6 +60,11 @@ public class CategoryServiceImpl extends ServiceImpl i return this.list(new LambdaQueryWrapper().eq(Category::getParentId, parentId)); } + @Override + public Category getCategoryById(String id) { + return this.getById(id); + } + /** * 根据分类id集合获取所有分类根据层级排序 * diff --git a/framework/src/main/java/cn/lili/modules/order/cart/render/TradeBuilder.java b/framework/src/main/java/cn/lili/modules/order/cart/render/TradeBuilder.java index d6d77784..94655e3a 100644 --- a/framework/src/main/java/cn/lili/modules/order/cart/render/TradeBuilder.java +++ b/framework/src/main/java/cn/lili/modules/order/cart/render/TradeBuilder.java @@ -127,9 +127,7 @@ public class TradeBuilder { for (CartRenderStep render : cartRenderSteps) { try { if (render.step().equals(step)) { - Date date = new Date(); render.render(tradeDTO); - log.error(render.getClass().getName() + "-" + (System.currentTimeMillis() - date.getTime())); } } catch (ServiceException e) { throw e; diff --git a/framework/src/main/java/cn/lili/modules/order/cart/render/impl/CommissionRender.java b/framework/src/main/java/cn/lili/modules/order/cart/render/impl/CommissionRender.java index 4df13428..f7e7bf55 100644 --- a/framework/src/main/java/cn/lili/modules/order/cart/render/impl/CommissionRender.java +++ b/framework/src/main/java/cn/lili/modules/order/cart/render/impl/CommissionRender.java @@ -66,7 +66,7 @@ public class CommissionRender implements CartRenderStep { String categoryId = cartSkuVO.getGoodsSku().getCategoryPath() .substring(cartSkuVO.getGoodsSku().getCategoryPath().lastIndexOf(",") + 1); if (CharSequenceUtil.isNotEmpty(categoryId)) { - Double commissionRate = categoryService.getById(categoryId).getCommissionRate(); + Double commissionRate = categoryService.getCategoryById(categoryId).getCommissionRate(); priceDetailDTO.setPlatFormCommissionPoint(commissionRate); } diff --git a/framework/src/main/java/cn/lili/modules/store/service/FreightTemplateService.java b/framework/src/main/java/cn/lili/modules/store/service/FreightTemplateService.java index 75225f99..7cebb983 100644 --- a/framework/src/main/java/cn/lili/modules/store/service/FreightTemplateService.java +++ b/framework/src/main/java/cn/lili/modules/store/service/FreightTemplateService.java @@ -5,6 +5,9 @@ import cn.lili.modules.store.entity.dos.FreightTemplate; import cn.lili.modules.store.entity.vos.FreightTemplateVO; import com.baomidou.mybatisplus.core.metadata.IPage; 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; @@ -14,6 +17,7 @@ import java.util.List; * @author Bulbasaur * @since 2020-03-07 09:24:33 */ +@CacheConfig(cacheNames = "{freightTemplate}") public interface FreightTemplateService extends IService { /** @@ -38,6 +42,7 @@ public interface FreightTemplateService extends IService { * @param id 运费模板ID * @return 运费模板 */ + @Cacheable(key = "#id") FreightTemplateVO getFreightTemplate(String id); /** @@ -55,6 +60,7 @@ public interface FreightTemplateService extends IService { * @param freightTemplateVO 运费模板 * @return 运费模板 */ + @CacheEvict(key = "#freightTemplateVO.id") FreightTemplateVO editFreightTemplate(FreightTemplateVO freightTemplateVO); /** @@ -64,6 +70,7 @@ public interface FreightTemplateService extends IService { * @param id 运费模板ID * @return 操作状态 */ + @CacheEvict(key = "#freightTemplateVO.id") boolean removeFreightTemplate(String id); } \ No newline at end of file