mybatis批量修改数据,批量插入数据,批量删除数据,多表查询
连接地址
1.批量修改数据
//批量修改产品信息数据,参数是map集合对象
Integer batchUpateProductInfo(Map<String,Object> map);
<!--批量修改产品信息数据-->
<update id="batchUpateProductInfo" parameterType="java.util.Map">
update ${tableName}
<set>
status = #{status,jdbcType=INTEGER},
last_operator = #{lastOperator,jdbcType=VARCHAR},
last_operator_id = #{lastOperatorId,jdbcType=INTEGER},
display_status = #{displayStatus,jdbcType=INTEGER},
last_operator_time =#{lastOperatorTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP}
</set>
where ${target} IN
<foreach collection="ids" item="item" index="index" open="(" close=")" separator=",">
#{item}
</foreach>
</update>
2.批量新增数据
/**
* 批量新增企业联系人
* @param uacEnterpiseContactList
* @return
*/
Integer batchAddEnterpiseContact(List<UacEnterpiseContact> enterpiseContactList);
<!-- 批量插入企业联系人信息 -->
<insert id="batchAddEnterpiseContact" parameterType="java.util.List">
insert into enterpise_contact
(version,
name,
enterpise_id,
dept,
position,
email,
gender,
phone,
hobby,
address,
remark,
creator,
creator_id,
created_time,
last_operator,
last_operator_id,
last_operator_time,
update_time,
status)
values
<foreach collection="list" item="t" index="index" separator=",">
(
#{t.version,jdbcType=BIGINT},
#{t.name,jdbcType=VARCHAR},
#{t.enterpiseId,jdbcType=BIGINT},
#{t.dept,jdbcType=VARCHAR},
#{t.position,jdbcType=VARCHAR},
#{t.email,jdbcType=VARCHAR},
#{t.gender,jdbcType=INTEGER},
#{t.phone,jdbcType=VARCHAR},
#{t.hobby,jdbcType=VARCHAR},
#{t.address,jdbcType=VARCHAR},
#{t.remark,jdbcType=VARCHAR},
#{t.creator,jdbcType=VARCHAR},
#{t.creatorId,jdbcType=BIGINT},
#{t.createdTime,jdbcType=TIMESTAMP},
#{t.lastOperator,jdbcType=VARCHAR},
#{t.lastOperatorId,jdbcType=BIGINT},
#{t.lastOperatorTime,jdbcType=TIMESTAMP},
#{t.updateTime,jdbcType=TIMESTAMP},
#{t.status,jdbcType=INTEGER}
)
</foreach>
</insert>
3.批量删除数据
/**
* 批量删除企业联系人
* @param map
* @return
*/
Integer batchDeleteEnterpiseContact(Map<String, Object> map);
<!--批量删除企业联系人-->
<delete id="batchDeleteEnterpiseContact" parameterType="java.util.Map">
delete from enterpise_contact
where ${target} IN
<foreach collection="ids" item="item" index="index" open="(" close=")" separator=",">
#{item}
</foreach>
</delete>
4.多表查询
<resultMap id="relationFlowMap" type="com.focus.service.vo.FlowTemRelVo">
<id column="flowId" jdbcType="BIGINT" property="flowId"></id>
<result column="flowName" jdbcType="VARCHAR" property="flowName"></result>
<collection property="sccFileRelTemVoList" ofType="com.focus.service.vo.FileRelTemVo">
<id column="id" jdbcType="BIGINT" property="id"></id>
<result column="fileName" jdbcType="VARCHAR" property="fileName"></result>
</collection>
</resultMap>
<select id="getRelationFlowByNameAndEntId" resultMap="relationFlowMap">
select
t1.id flowId,
t1.name flowName,
t3.id,
t3.name fileName
from
scc_flow t1
left join
scc_flow_file t2
on
t1.id = t2.flow_id
left join
scc_file t3
on t2.file_id = t3.id
<where>
t1.status = 0
and t1.enterpise_id = #{enterpiseId}
<if test="name != null and name != ''">
and (t1.name like concat('%',#{name},'%') escape '/' or t3.name like concat('%',#{name},'%') escape '/')
</if>
</where>
order by t1.name
</select>