原
spring boot +swagger+mssql +lombok+mybatis的List<Dto> 参数
分类:
Java
一、参数为list实体model时(注意list参数一定要用对应的类型接收传回的参数,不然会报错)
接口效果
注意list参数默认是必填,想不填必须在@RequestParam等接收参数里改
二、list参数在mapper.xml里面的写法
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!--这个是接口路径集dao层--> <mapper namespace="com.example.My10_18.mapper.IForms_UserInfoMapper"> <!-- 添加--> <insert id="addF_User"> insert Forms_UserInfo values <foreach collection="listInput" item="item" separator=","> (#{item.forms_id},#{item.userinfo_id}) </foreach> </insert> <!--删除--> <delete id="delF_User"> delete Forms_UserInfo <where> <if test="forms_ids!=null and forms_ids.size()>0"> and <foreach collection="forms_ids" item="item" separator="or">forms_id=#{item}</foreach> </if> <if test="userinfo_ids!=null and userinfo_ids.size()>0"> and <foreach collection="userinfo_ids" item="item" separator="or">userinfo_id=#{item}</foreach> </if> </where> </delete> <!-- 修改--> <update id="updateF_UserByForms_id"> <!-- update Forms_UserInfo set userinfo_id=1 where userinfo_id=2--> update Forms_UserInfo set userinfo_id=#{NForms_ids} where userinfo_id=#{OForms_ids} </update> <select id="queryFormsByAll" resultType="Forms_UserInfo"> <!-- select* from Forms_UserInfo where forms_id=1 and userinfo_id in(1,2)--> select* from Forms_UserInfo <where> <if test="forms_ids!=null and forms_ids.size()>0"> and <foreach collection="forms_ids" item="item" separator="or">forms_id=#{item}</foreach> </if> <if test="userinfo_ids!=null and userinfo_ids.size()>0">and userinfo_id in <foreach collection="userinfo_ids" item="item" open="(" separator="," close=")">#{item}</foreach> </if> </where> </select> <!--分页查询--> <select id="queryFormsByPages" resultType="Forms_UserInfo"> <!-- select* from Forms_UserInfo where forms_id=1 and userinfo_id in(1,2)--> select top ${row}* from Forms_UserInfo <where> <if test="forms_ids!=null and forms_ids.size()>0"> and <foreach collection="forms_ids" item="item" separator="or">forms_id=#{item}</foreach> </if> <if test="userinfo_ids!=null and userinfo_ids.size()>0">and userinfo_id in <foreach collection="userinfo_ids" item="item" open="(" separator="," close=")">#{item}</foreach> </if> and Id not in(select top(2*(#{page}-1))Id from Forms_UserInfo order by Id) </where> </select> </mapper>
评价
排名
6
文章
6
粉丝
16
评论
8
{{item.articleTitle}}
{{item.blogName}} : {{item.content}}
ICP备案 :渝ICP备18016597号-1
网站信息:2018-2024TNBLOG.NET
技术交流:群号656732739
联系我们:contact@tnblog.net
公网安备:50010702506256
欢迎加群交流技术