瀏覽代碼

考试安排

change 3 年之前
父節點
當前提交
bbc6d0fff5

+ 13 - 0
zhongzheng-admin/src/main/java/com/zhongzheng/controller/exam/ExamBeforeController.java

@@ -4,6 +4,7 @@ import java.util.List;
 import java.util.Arrays;
 
 import com.zhongzheng.modules.exam.bo.*;
+import com.zhongzheng.modules.exam.service.IExamBeforeGoodsService;
 import com.zhongzheng.modules.exam.service.IExamBeforeUrlService;
 import com.zhongzheng.modules.exam.vo.ExamBeforeUrlVo;
 import com.zhongzheng.modules.exam.vo.ExamNumberGoodsVo;
@@ -43,6 +44,7 @@ public class ExamBeforeController extends BaseController {
 
     private final IExamBeforeService iExamBeforeService;
     private final IExamBeforeUrlService iExamBeforeUrlService;
+    private final IExamBeforeGoodsService iExamBeforeGoodsService;
 
     /**
      * 查询前培安排列表
@@ -114,4 +116,15 @@ public class ExamBeforeController extends BaseController {
     }
 
 
+    /**
+     * 新增前培绑定商品
+     */
+    @ApiOperation("新增前培绑定商品")
+    @PreAuthorize("@ss.hasPermi('system:goods:add')")
+    @Log(title = "前培绑定商品", businessType = BusinessType.INSERT)
+    @PostMapping()
+    public AjaxResult<Void> add(@RequestBody ExamBeforeGoodsAddBo bo) {
+        return toAjax(iExamBeforeGoodsService.insertByAddBo(bo) ? 1 : 0);
+    }
+
 }

+ 1 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/exam/bo/ExamBeforeGoodsAddBo.java

@@ -29,5 +29,5 @@ public class ExamBeforeGoodsAddBo {
     private Long updateTime;
     /** $column.columnComment */
     @ApiModelProperty("$column.columnComment")
-    private Long goodsId;
+    private Long[] goodsId;
 }

+ 13 - 5
zhongzheng-system/src/main/java/com/zhongzheng/modules/exam/service/impl/ExamBeforeGoodsServiceImpl.java

@@ -3,6 +3,7 @@ package com.zhongzheng.modules.exam.service.impl;
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.util.StrUtil;
 import com.zhongzheng.common.utils.DateUtils;
+import com.zhongzheng.modules.exam.domain.ExamApplyGoods;
 import org.springframework.stereotype.Service;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@@ -66,11 +67,18 @@ public class ExamBeforeGoodsServiceImpl extends ServiceImpl<ExamBeforeGoodsMappe
 
     @Override
     public Boolean insertByAddBo(ExamBeforeGoodsAddBo bo) {
-        ExamBeforeGoods add = BeanUtil.toBean(bo, ExamBeforeGoods.class);
-        validEntityBeforeSave(add);
-        add.setCreateTime(DateUtils.getNowTime());
-        add.setUpdateTime(DateUtils.getNowTime());
-        return this.save(add);
+        LambdaQueryWrapper<ExamBeforeGoods> lqw = Wrappers.lambdaQuery();
+        lqw.eq(ExamBeforeGoods::getBeforeId, bo.getBeforeId());
+        this.remove(lqw);
+        for (Long goodsId : bo.getGoodsId()) {
+            ExamBeforeGoods add = new ExamBeforeGoods();
+            add.setCreateTime(DateUtils.getNowTime());
+            add.setUpdateTime(DateUtils.getNowTime());
+            add.setGoodsId(goodsId);
+            add.setBeforeId(bo.getBeforeId());
+            return this.save(add);
+        }
+        return true;
     }
 
     @Override

+ 1 - 1
zhongzheng-system/src/main/resources/mapper/modules/exam/ExamNumberMapper.xml

@@ -48,7 +48,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             AND en.exam_number_id = #{examNumberId}
         </if>
         <if test="goodsId != null and goodsId != ''">
-            AND  AND  (SELECT COUNT(eng.id) FROM exam_number_goods eng where eng.goods_id =#{goodsId}) > 0
+            AND  (SELECT COUNT(eng.id) FROM exam_number_goods eng where eng.goods_id =#{goodsId}) > 0
         </if>
         order by en.create_time desc
     </select>