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

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

postman

spring boot+mybatis前台传数组,xml文件内以数组内容为查询条件_第1张图片

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">
                #{code}
            </foreach>
        </if>
    </select>

你可能感兴趣的:(java,spring)