CategoryController
/**
* 新增商品类目
* @param category 商品类目对象
* @return
*/
@ApiOperation("新增商品类目")
@PostMapping
@PreAuthorize("hasAuthority('prod:category:save')")
public Result<String> saveCategory(@RequestBody Category category) {
Boolean saved = categoryService.saveCategory(category);
return Result.handle(saved);
}
CategoryServiceImpl
@Override
@Caching(evict = {
@CacheEvict(key = ProductConstants.ALL_CATEGORY_LIST_KEY),
@CacheEvict(key = ProductConstants.FIRST_CATEGORY_LIST_KEY),
@CacheEvict(key = ProductConstants.WX_FIRST_CATEGORY)
})
public Boolean saveCategory(Category category) {
category.setCreateTime(new Date());
category.setUpdateTime(new Date());
return categoryMapper.insert(category)>0;
}