急着去夜跑,简单记录下,看代码
Mpper对象:
/**
* 条件查询
* @param qo qo
* @param userId userId
* @return list
*/
List<Customer> getCustomerList(@Param("qo") CustomerQO qo, @Param("userId")String userId);
xml文件:
<!-- 查询有效客户 -->
<select id="getCustomerList" parameterType="com.cyipp.skywalker.domain.qo.CustomerQO"
resultType="com.cyipp.skywalker.domain.po.Customer">
SELECT
<include refid="customerColumns"/>
FROM
customer
WHERE
status = 1 and
IF(1 in (SELECT role_id FROM sys_role_account WHERE user_id = #{userId}), 1 = 1, manager = #{userId})
<if test="qo.level != null">
and level = #{qo.level}
</if>
<if test="qo.name != null and qo.name !=''">
and name = #{qo.name}
</if>
<if test="qo.brands != null and qo.brands !=''">
and find_in_set(#{qo.brands},brands)>0
</if>
order by create_time desc
</select>