亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

使用SpringBoot+MybatisPlus做了一個單個刪除DOM,請問批量怎么刪除呢

使用SpringBoot+MybatisPlus做了一個單個刪除DOM,請問批量怎么刪除呢

慕標琳琳 2019-04-18 14:15:53
ContentCatService//刪除     public void delete(Integer id);public class ContentCatServiceImpl implements ContentCatService{//刪除     public void delete(Integer id){         List<Integer> idList = new ArrayList<>();         idList.add(id);         contentCatMapper.deleteBatchIds(idList);     }public class ContentCatController { //刪除     private SysResult delete(@PathVariable Integer id){         try {             contentCatService.delete(id);             return SysResult.ok();         }catch (Exception e){             e.printStackTrace();             return SysResult.build(201,"刪除失敗");         }請問如果改為批量刪除呢
查看完整描述

3 回答

?
慕容708150

TA貢獻1831條經驗 獲得超4個贊

批量刪除你要傳一個list
通過mybatis 的動態sql 拼接

<delete id="batchDelete" parameterType="java.util.List">
    delete from tm_user where user_id in (
    values
    <foreach collection="instances" item="item" index="index" separator=",">
        #{item.userId}
    </foreach>
    )
</delete>

批量新增差不多
<insert id="batchInsert" parameterType="java.util.List">
    insert into tm_e_coupon_instance(e_coupon_id,batch_no)
    values
    <foreach collection="instances" item="item" index="index" separator=",">
        (#{item.eCouponId},#{item.batchNo})
    </foreach>

</insert>


查看完整回答
反對 回復 2019-05-16
  • 3 回答
  • 0 關注
  • 5162 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號