https://nannan408.iteye.com/blog/2170470java
https://blog.csdn.net/xingzhishen/article/details/86424395sql
参数的数据结构是一个ArrayList<Map<String, Integer>>,须要以String,Integer为条件批量更新数据库的数据.数据库
将参数封装到叫作JsonData的qv中,JsonData的关键代码是json
private ArrayList<Map<String, Integer>> usersPlatforms;
public ArrayList<Map<String, Integer>> getUsersPlatforms() {
return usersPlatforms;
}
public void setUsersPlatforms(ArrayList<Map<String, Integer>> usersPlatforms) {
this.usersPlatforms = usersPlatforms;
}
Mapper中的方法是:数据结构
updateXxxx(JsonData jsonData);
Mapper.xml的sql是:app
<update id="updateXxxx" parameterType="JsonData">
UPDATE xxx SET `xx` = 10
<where>
<foreach collection="usersPlatforms" item="userPlatform" open="" close="" separator="OR">
<foreach collection="userPlatform.keys" item="key" open=" user_id = " close="" separator="">
#{key}
</foreach>
<foreach collection="userPlatform.values" item="value" open=" AND platform = " close="" separator="">
#{value}
</foreach>
</foreach>
</where>
</update>
----------------------------------- ----------------------------------- ----------------------------------- -----------------------------------测试
1.前言.
如题.
2.代码.
(1)mapper.xml. this
(2)interface spa
(3)
测试类: .net
2.批量更新.
大部分传list就能够了,传map也能够,但map也要解析成list,能够自行研究map,这里介绍通用的list传值方法:
(1)mapper
(2)xml
(3)测试类