mybatis对map集合的处理
项目中遇到批量删除,但是又需要附带其他参数,不想新增VO类可以通过map的方式来进行删除操作
例如:
对考生进行批量删除,但是考生也需要分班级,所以要带上orgCode进行过滤
//批量删除
@Transactional
public Result batchStatusDeletePlus(String[] examineeIds) {
//批量删除考生
empExamineeMapper.batchStatusDelete(examineeIds);
//批量删除考生分类中间表数据
String orgCode = EntityUtil.getOrgCode();
Map<String, Object> map = new HashMap<String, Object>();
map.put("orgCode", orgCode);
map.put("examineeIds", examineeIds);
empExamineeCatalogMapper.batchStatusDeleteByOrg(map);
//empExamineeCatalogMapper.batchDeleteByOrg(map);
return new Result();
}
xml
<!--批量状态删除-->
<update id="batchStatusDeleteByOrg" parameterType="list">
UPDATE EMP_EXAMINEE_CATALOG
SET deleteFlag =1
WHERE examineeId IN(
<foreach collection="examineeIds" item="examineeId" separator=",">
#{examineeId,jdbcType=VARCHAR}
</foreach>
)
<if test="orgCode != null and orgCode != '' ">
and orgCode = #{orgCode}
</if>
</update>