spring boot+mybatis前台传数组,xml文件内以数组内容为查询条件
postman

controller
@PostMapping("/test")
@ApiOperationSupport(order = 13)
@ApiOperation(value = "", notes = "")
public R test(@RequestParam String[] uid) {
return solutionService.adoptAll(uid);
}
service
R adoptAll(String[] uids);
serviceImpl
@Override
public R adoptAll(String[] uids) {
return R.data(orderPledgeReleaseMapper.selectByUidArray(uids));
}
mapper
ist<OrderPledgeRelease> selectByUidArray(@Param("array")String[] array);
mappper.xml
<select id="selectByUidArray" resultType="com.example.manage.vo.OrderPledgeReleaseVO">
select
*
from order_pledge_release t
where
<if test="array !=null and array.length > 0">
t.uid in
<foreach collection="array" item = "code" open="(" separator="," close=")" index="index">
</foreach>
</if>
</select>