批量增改查,记录下,方便拷贝

这篇博客主要展示了如何使用Java DAO层进行批量插入、单条插入、更新确认以及根据ID列表查询和更新数据库记录。内容涵盖了SQL语句的编写,包括SELECT、INSERT和UPDATE语句的使用,以及在循环中处理ID列表的方法。
摘要由CSDN通过智能技术生成

Dao:public Integer batchInsert(@Param(“list”) List list);

INSERT INTO td_tt_register( id, provincename, cityname, areaname, realname, idcard, phone, bankname, banknum, bankbranch, affiliatedcompany, rolename, update_time ) SELECT #{a.id}, #{a.provincename}, #{a.cityname}, #{a.areaname}, #{a.realname}, #{a.idcard}, #{a.phone}, #{a.bankname}, #{a.banknum}, #{a.bankbranch}, #{a.affiliatedcompany}, #{a.rolename}, now() from dual

Dao:int insertAllInfo(@Param(“tdPayInfoList”) List tdPayInfoList);


INSERT INTO td_pay_info(
id,
sysName,
sysCardNo,
sysMobile,
sysBankName,
sysBankCode,
sysCity,
sysCounty,
applyTime,
applyMoney,
orderCodes,
payState
) VALUES

(
#{a.id},
#{a.sysname},
#{a.syscardno},
#{a.sysmobile},
#{a.sysbankname},
#{a.sysbankcode},
#{a.syscity},
#{a.syscounty},
#{a.applytime},
#{a.applymoney},
#{a.orderCodes},
#{a.payState}
)

Dao:public int updateConfirm(@Param("idList") List<String> idList);

<update id="updateConfirm">
	update td_order_cj SET yh_qrFlag = '1',update_date = now()
	where id in
	<foreach collection="idList" item="item" index="index" separator="," open="(" close=")">
		#{item}
	</foreach>
</update>

Dao: public List<TdOrderInfoNews> findAllListByIds(@Param("idList") List<String> idList);
<select id="findAllListByIds" resultType="TdOrderInfoNews">
 	SELECT 
 	<include refid="tdOrderInfoNewColumns"/>
 	 ,b.money as money	
	 ,b.qrFlag AS qrFlag
	 ,b.yh_qrFlag AS yhQrFlag
	 ,b.cjtype as cjType
	 ,b.id as cjid
	 ,b.ycyy AS ycyy
	 ,b.xf_time as xfTime
 	FROM `td_order_cj` b LEFT JOIN `td_order_info_new` a ON b.`order_no` = a.id
 	where b.id in
	<foreach item="item" index="index" collection="idList"
			 open="(" separator="," close=")">
		#{item}
	</foreach>
</select>

Dao:int updateOrderMaterials(@Param(“wzOrderList”) List wzOrderList);



UPDATE wc_whlist_d SET
num = (num-#{item.number}),
update_date = now(),
update_by = #{item.updateBy.id}
WHERE orgid = #{item.orgPid}
AND s_id = #{item.lId}
AND price = #{item.price}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值