新增:
int insertLableBatch(@Param("list")List<UserGroupFilterLabel> list);
<insert id="insertLableBatch" parameterType="com.sf.cps.mana.model.UserGroupFilterLabel"> insert into ti_user_group_filter_label (emp_group_id,label_type,label_code,label_name,label_symbol,label_content,label_valid,create_name,create_emp,create_time) values <foreach collection="list" item="re" separator=","> ( #{re.empGroupId,jdbcType=INTEGER}, #{re.labelType,jdbcType=VARCHAR}, #{re.labelCode,jdbcType=VARCHAR}, #{re.labelName,jdbcType=VARCHAR}, #{re.labelSymbol,jdbcType=VARCHAR}, #{re.labelContent,jdbcType=VARCHAR}, #{re.labelValid,jdbcType=INTEGER}, #{re.createName,jdbcType=VARCHAR}, #{re.createEmp,jdbcType=VARCHAR}, now() ) </foreach> </insert>
修改:
int updateLableBatch(@Param("list")List<UserGroupFilterLabel> list);
<!--批量修改-跟java循環其實是一樣的只是邏輯清晰些--> <update id="updateLableBatch" parameterType="com.sf.cps.mana.model.UserGroupFilterLabel"> <foreach collection="list" separator=";" item="item"> update ti_user_group_filter_label <set> <if test="item.empGroupId != null"> emp_group_id = #{item.empGroupId,jdbcType=INTEGER}, </if> <if test="item.labelType != null"> label_type = #{item.labelType,jdbcType=VARCHAR}, </if> <if test="item.labelCode != null"> label_code = #{item.labelCode,jdbcType=VARCHAR}, </if> <if test="item.labelName != null"> label_name = #{item.labelName,jdbcType=VARCHAR}, </if> <if test="item.labelSymbol != null"> label_symbol = #{item.labelSymbol,jdbcType=VARCHAR}, </if> <if test="item.labelContent != null"> label_content = #{item.labelContent,jdbcType=VARCHAR}, </if> <if test="item.labelValid != null"> label_valid = #{item.labelValid,jdbcType=INTEGER}, </if> <if test="item.modifyEmp != null"> modify_emp = #{item.modifyEmp,jdbcType=VARCHAR}, </if> <if test="item.modifyName != null"> modify_name = #{item.modifyName,jdbcType=VARCHAR}, </if> modify_time = now() </set> where id = #{item.id,jdbcType=INTEGER} </foreach> </update>
修改/刪除(改狀態式的刪除):
int delLableBatch(@Param("modifyEmp")String modifyEmp,@Param("modifyName")String modifyName, @Param("list")List<Integer> list);
<!--批量刪除--> <update id="delLableBatch"> update ti_user_group_filter_label <set> <if test="modifyEmp != null"> modify_emp = #{modifyEmp,jdbcType=VARCHAR}, </if> <if test="modifyName != null"> modify_name = #{modifyName,jdbcType=VARCHAR}, </if> modify_time = now(), label_valid = 0 </set> where emp_group_id in <foreach collection="list" item="item" open="(" close=")" separator=","> #{item,jdbcType=INTEGER} </foreach> </update>