fix: 商品分类排序

This commit is contained in:
DataCall 2024-07-18 17:15:52 +08:00
parent 86b0abaf7f
commit 5475c7d8e1
4 changed files with 4 additions and 12 deletions

View file

@ -106,6 +106,7 @@ public class ItemCategoryController extends BaseController {
@PostMapping("/update/orderNum")
public R<Void> updateOrderNum(@RequestBody List<ItemTypeTreeSelectVo> tree) {
return toAjax(itemCategoryService.updateOrderNum(tree));
itemCategoryService.updateOrderNum(tree);
return R.ok();
}
}

View file

@ -8,5 +8,4 @@ import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface ItemCategoryMapper extends BaseMapperPlus<ItemCategory, ItemCategoryVo> {
int updateOrderNum(@Param("list") List<ItemCategory> list);
}

View file

@ -213,7 +213,7 @@ public class ItemCategoryService extends ServiceImpl<ItemCategoryMapper, ItemCat
return getChildList(list, t).size() > 0;
}
public int updateOrderNum(List<ItemTypeTreeSelectVo> tree) {
public void updateOrderNum(List<ItemTypeTreeSelectVo> tree) {
List<ItemCategory> updateList = new ArrayList<>();
for (int i = 0; i < tree.size(); i++) {
ItemCategory itemType = new ItemCategory();
@ -221,6 +221,6 @@ public class ItemCategoryService extends ServiceImpl<ItemCategoryMapper, ItemCat
itemType.setOrderNum((long) i);
updateList.add(itemType);
}
return baseMapper.updateOrderNum(updateList);
saveOrUpdateBatch(updateList);
}
}

View file

@ -3,12 +3,4 @@
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.wms.mapper.ItemCategoryMapper">
<update id="updateOrderNum">
<foreach collection="list" item="item" index="index" open="" close="" separator=";">
update wms_item_type
set order_num=#{item.orderNum}
where id=#{item.id}
</foreach>
</update>
</mapper>