<!--批量插入-->
<insert id="insertBatch" parameterType="com.deppon.tps.module.departmentbase.shared.domain.DepartmentEntity">
<!--获取随机生成的主键id-->
<selectKey keyProperty="id" resultType="string" order="BEFORE">
select sys_guid() as ID from dual
</selectKey>
INSERT INTO t_org_department(
<!--需要插入的列-->
<include refid="insert_param"/>
)
select sys_guid() as ID ,A.* from(
<!--遍历list循环插入其中-->
<foreach collection="list" item="item" index="index" separator="UNION ALL" >
select
#{item.dept_code,jdbcType=VARCHAR},
#{item.dept_name,jdbcType=VARCHAR},
#{item.dept_attribute,jdbcType=VARCHAR}
from dual
</foreach> )A
</insert>
<!--批量修改-->
<update id="updateBatch" parameterType="com.deppon.tps.module.departmentbase.shared.domain.DepartmentEntity">
UPDATE t_org_department set
<foreach collection="list" item="item" index="index" separator=" " open="DEPT_CODE = CASE" close="end,">
WHEN id = #{item.id} then #{item.dept_code,jdbcType=VARCHAR}
</foreach>
<foreach collection="list" item="item" index="index" separator=" " open="DEPT_NAME = CASE" close="end,">
WHEN id = #{item.id} then #{item.dept_name,jdbcType=VARCHAR}
</foreach>
<foreach collection="list" item="item" index="index" separator=" " open="DEPT_ATTRIBUTE = CASE" close="end">
WHEN id = #{item.id} then #{item.dept_attribute,jdbcType=VARCHAR}
</foreach>
WHERE id IN (
<foreach collection="list" item="item" index="index" separator=",">
#{item.id}
</foreach>
)
</update>
orcal 批量插入与批量修改
最新推荐文章于 2024-07-18 19:28:01 发布