mybatis参数map包含list,取数时遍历list

mybatis xml文件:

<update id="chooseconfirm" parameterType="java.util.Map">

UPDATE BarcodeScan SET confirmuser=#{account},confirmdate=NOW()

WHERE ID in

<foreach collection="IDlist" index="index" item="item"

open="(" separator="," close=")">

#{item}

foreach>

update>

 

mapper文件:

 

int chooseconfirm(@Param("account") String account,@Param("IDlist") List IDlist);

serviceImpl文件:

 

@Override

public Object chooseconfirm(Map data) {

int rs=0;

try {

String IDid=data.get("ID")==null?"":data.get("ID").toString();

String account=data.get("account")==null?"":data.get("account").toString();

if(IDid.length()==0) {

return faileResultMap("参数:ID不能为空");

}else if(account.length()==0) {

return faileResultMap("参数:用户账号不能为空");

}else {

List IDlist=new ArrayList();

String[] strs=IDid.split(",");

for(int i=0,len=strs.length;i<len;i++){

IDlist.add(strs[i].toString());

}

rs=barcodeScanMapper.chooseconfirm(account,IDlist);

return result(rs);

}

 

} catch (Exception e) {

e.printStackTrace();

return result(rs);

}

}

 

ps:想认识博主么?想了解学习更多知识么?不妨关注微信公众号:面向对象缘来是你

mybatis参数map包含list,取数时遍历list_第1张图片

 

 

 

 

你可能感兴趣的:(mybatis详解,java)