Mapper.xml
本文章关于mapper.xml中读取传入实体类中map<String, List
> map这种入参,以及postman中如何模拟输入
传入参数如下:
Map<String, List
? 主要就是在foreach中套入一层foreach,其中clietnTag 是map名,index是map.key,后面一个foreach中item就是value中的list,随便定义什么都可,但是前面的map不能定义错,否则会找不到。
<select id="" parameterType="" resultMap="">
select
* from a
<if test="clientTag != null and clientTag != ‘‘">
and a.external_userid in
<foreach collection="clientTag" index="clientGroupId" item="ent" separator="union">
(select * from b
<if test="qrUserId != null and qrUserId != ‘‘">
and b.qr_user_id = #{qrUserId, jdbcType=VARCHAR}
</if>
and b.tag_id in
<foreach collection="ent" item="clientTagId" separator="," open="(" close=")">
#{clientTagId, jdbcType=VARCHAR}
</foreach>
)
</foreach>
</if>
</select>
PostMan模拟传入:
{
"clientTag":{
"1":["1", "2"]
},
"clientProduct":{
"1":["1", "2"]
}
}
Mapper.xml--配置map<String, List<String>>输入
原文:https://www.cnblogs.com/meditation5201314/p/14805762.html