Mybatis 同时传入对象和多个参数
程序员文章站
2022-07-15 14:36:03
...
接口文件使用 @param 注解
/**
* @author lenovo
*@param ContingencyPlanApplyVo cv 对象
*@param String territoryCode 参数
*@return List<ContingencyPlanApplyVo>
*/
List<ContingencyPlanApplyVo> findContingencyPlan(@Param("cv")ContingencyPlanApplyVo cv,
@Param("territoryCode")String territoryCode);
在mapper.xml 传入的参数不止一个时候 就不要使用parameterType
<select id="findContingencyPlan" resultType="cn.com.xx.xx.xx.vo.ContingencyPlanApplyVo">
SELECT
TS. ID
FROM
T_CONTINGENCY_SB ts
LEFT JOIN T_COMPANY_INFO ti ON TS.COMP_ID = TI. ID
LEFT JOIN T_S_USER us ON TS.COMP_ID = US.COMP_ID
LEFT JOIN T_S_TERRITORY tt ON US.TERRITORY_ID = TT. ID
<where>
<if test="cv.compName != null and cv.compName != ''">
AND TI.COMPNAME LIKE '%${cv.compName}%'
</if>
<if test="territoryCode != null and territoryCode != ''">
AND TT.TERRITORYCODE LIKE '%${territoryCode}%'
</if>
</where>
</select>