修复【状态修改为“下线”后, 表格数据状态还是显示“正常”】的bug

This commit is contained in:
sjl
2021-02-01 09:07:04 +08:00
parent 992c257b77
commit 652ba9630a
2 changed files with 10 additions and 1 deletions

View File

@@ -109,6 +109,15 @@ public class CategoryController {
if(categoryName != null){
throw new YamiShopBindException("类目名称已存在!");
}
Category categoryDB = categoryService.getById(category.getCategoryId());
// 如果从下线改成正常,则需要判断上级的状态
if (Objects.equals(categoryDB.getStatus(),0) && Objects.equals(category.getStatus(),1) && !Objects.equals(category.getParentId(),0L)){
Category parentCategory = categoryService.getOne(new LambdaQueryWrapper<Category>().eq(Category::getCategoryId, category.getParentId()));
if(Objects.isNull(parentCategory) || Objects.equals(parentCategory.getStatus(),0)){
// 修改失败,上级分类不存在或者不为正常状态
throw new YamiShopBindException("修改失败,上级分类不存在或者不为正常状态");
}
}
categoryService.updateCategroy(category);
return ResponseEntity.ok().build();
}

View File

@@ -50,7 +50,7 @@
</select>
<select id="tableCategory" resultType="com.yami.shop.bean.model.Category">
select category_id ,parent_id ,category_name,pic,seq from tz_category where shop_id = #{shopId} order by seq
select category_id ,parent_id ,category_name,pic,seq,status from tz_category where shop_id = #{shopId} order by seq
</select>
<select id="listCategoryAndProdByShopId" resultMap="categoryProdMap">