| | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void create(StoreCategory resources) { |
| | | // 重名 |
| | | this.calculateAndSetLevel(resources); |
| | | resources.setCreateBy(SecurityUtils.getCurrentUserId()); |
| | | storeCategoryMapper.insert(resources); |
| | | } |
| | | |
| | |
| | | public void update(StoreCategory resources) { |
| | | StoreCategory storeCategory = getById(resources.getCategoryId()); |
| | | storeCategory.copy(resources); |
| | | resources.setUpdateBy(SecurityUtils.getCurrentUserId()); |
| | | storeCategoryMapper.updateById(storeCategory); |
| | | } |
| | | |
| | |
| | | * 计算并设置类目的层级 |
| | | */ |
| | | private void calculateAndSetLevel(StoreCategory category) { |
| | | |
| | | if (category == null) { |
| | | throw new IllegalArgumentException("对象不能为null"); |
| | | } |
| | | |
| | | Long parentCategoryId = category.getParentId(); |
| | | if (parentCategoryId == null) { |