在mybatis中传多个参数,并且遍历其中的list和数组,使用map集合

xiaoxiao2021-02-28  129

1.接口,接受数组和字符串 删除时

void deleteSiteToProjectSerial(@Param("siteSerial") String[] siteSerial, @Param("projectSerial") String projectSerial);

<delete id="deleteSiteToProjectSerial"  parameterType="map">                         delete from  Project_Site where Project_Serial=${projectSerial}         and Site_Serial in         <foreach collection="siteSerial" item="item"  open="(" separator="," close=")">              #{item}                      </foreach>

  </delete>

2,接受两个对象 修改时

updateByExample(@Param("record") ProjectSite record, @Param("example") ProjectSiteQuery example);

 <update id="updateByExampleSelective" parameterType="map" >     update Project_Site     <set >       <if test="record.siteSerial != null" >         Site_Serial = #{record.siteSerial,jdbcType=VARCHAR},       </if>       <if test="record.projectSerial != null" >         Project_Serial = #{record.projectSerial,jdbcType=VARCHAR},       </if>     </set>     <if test="_parameter != null" >       <include refid="Update_By_Example_Where_Clause" />     </if>   </update>

3查询时使用工具类

List<ProjectSite> selectByExampleWithRowbounds(ProjectSiteQuery example, RowBounds rowBounds);

<select resultMap="BaseResultMap" parameterType="xfhm.core.model.projectManage.ProjectSiteQuery" id="selectByExampleWithRowbounds" >     select     <if test="distinct" >       distinct     </if>     <include refid="Base_Column_List" />     from Project_Site     <if test="_parameter != null" >       <include refid="Example_Where_Clause" />     </if>     <if test="orderByClause != null" >       order by ${orderByClause}     </if>     <if test="startRow != null" >       limit #{startRow} , #{pageSize}     </if>   </select>

转载请注明原文地址: https://www.6miu.com/read-25920.html

最新回复(0)