瀏覽代碼

批量修改

zhangyang 2 年之前
父節點
當前提交
f14e270337

+ 3 - 2
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/PoTetherController.java

@@ -143,7 +143,8 @@ public class PoTetherController extends BaseController
     @Log(title = "套系", businessType = BusinessType.INSERT)
     @PostMapping("/add")
     public AjaxResult add(@RequestBody TetherVo tetherVo,
-                          @RequestBody @Param("poUser") PoUser poUser)
+                          @RequestBody @Param("poUser") PoUser poUser,
+                          @RequestBody PoTetherandcollection poTetherandcollection)
     {
         //判断当前用户是否有操作的权限
         poUserService.checkUserAllowed(poUser);
@@ -169,7 +170,7 @@ public class PoTetherController extends BaseController
         }else{
             tetherVo.setSellStatus(0);
         }
-        poTetherService.insertPoTetherWithCollection(tetherVo);
+        poTetherService.insertPoTetherWithCollection(tetherVo,poTetherandcollection);
         return success("新增成功");
     }
 

+ 1 - 1
ruoyi-system/src/main/java/com/ruoyi/system/service/IPoTetherService.java

@@ -69,7 +69,7 @@ public interface IPoTetherService extends IService<PoTether>
      * @param tetherVo
      * @return
      */
-    void insertPoTetherWithCollection(TetherVo tetherVo);
+    void insertPoTetherWithCollection(TetherVo tetherVo,PoTetherandcollection poTetherandcollection);
 
     /**
      * 通过id查询套系信息和对应的藏品信息

+ 14 - 11
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/PoTetherServiceImpl.java

@@ -155,12 +155,11 @@ public class PoTetherServiceImpl extends ServiceImpl<PoTetherMapper,PoTether> im
      */
     @Override
     @Transactional
-    public void insertPoTetherWithCollection(TetherVo tetherVo) {
+    public void insertPoTetherWithCollection(TetherVo tetherVo,PoTetherandcollection poTetherandcollection) {
         //保存套系的基本数据到套系表tether
         this.poTetherMapper.insertPoTether(tetherVo);
         //套系包含藏品
         //保存藏品数据到中间表 批量增加
-
         System.out.println(tetherVo.getPoTetherandcollections().size());
         for (int i = 0 ; i < tetherVo.getPoTetherandcollections().size();i++) {
             System.out.println(tetherVo.getPoTetherandcollections().get(i).getCollectionTitle());
@@ -198,16 +197,20 @@ public class PoTetherServiceImpl extends ServiceImpl<PoTetherMapper,PoTether> im
         //更新po_tether表基本信息
         this.poTetherMapper.updatePoTether(tetherVo);
         //清理po_collection表数据
-//        LambdaQueryWrapper<PoTetherandcollection> lambdaQueryWrapper = new LambdaQueryWrapper<>();
-//        lambdaQueryWrapper.eq(PoTetherandcollection::getTetherId,tetherVo.getTetherId());
-//        poTetherandcollectionService.remove(lambdaQueryWrapper);
+        LambdaQueryWrapper<PoTetherandcollection> lambdaQueryWrapper = new LambdaQueryWrapper<>();
+        lambdaQueryWrapper.eq(PoTetherandcollection::getTetherId,tetherVo.getTetherId());
+        poTetherandcollectionService.remove(lambdaQueryWrapper);
 //        //添加当前提交过来的藏品数据--po_Tetherandcollection表的insert操作
-//        List<PoTetherandcollection> poTetherandcollections = tetherVo.getPoTetherandcollections();
-//        List<PoTetherandcollection> collect = poTetherandcollections.stream().map((item) -> {
-//            item.setTetherId(tetherVo.getTetherId());
-//            return item;
-//        }).collect(Collectors.toList());
-//        poTetherandcollectionService.saveBatch(collect);
+        for (int i = 0 ; i < tetherVo.getPoTetherandcollections().size();i++) {
+
+            System.out.println(tetherVo.getPoTetherandcollections().get(i).getCollectionTitle());
+            PoTetherandcollection poTetherandcollection1 = new PoTetherandcollection();
+            poTetherandcollection1.setCollectionTitle(tetherVo.getPoTetherandcollections().get(i).getCollectionTitle());
+            poTetherandcollection1.setCollectionType(tetherVo.getPoTetherandcollections().get(i).getCollectionType());
+            poTetherandcollection1.setTetherId(tetherVo.getTetherId());
+            poTetherandcollectionService.insertPoTetherandcollection(poTetherandcollection1);
+        }
+
     }