<if test="peopleType != null and peopleType == 1">
<if test="userIds != null">
and (
<foreach collection="userIds" item="entity" separator="or">
b.PUBLIC_PEOPLE = #{entity}
</foreach>
)
</if>
</if>
完整
<select id="examQuery" resultMap="GhaExExamQueryDTOMap">
select
a.ID_ as groupID, a.GROUP_NAME as groupName, b.ID_,b.ISDELETED,b.TENANTID,b.OPTIME,b.OPER,b.CANCEL_TIME,
b.UPDATETIME,b.UPDATOR,b.GROUP_ID,b.EXAM_NAME,b.EXPLAINS,b.PUBLIC_PEOPLE,b.PUBLIC_TIME,b.EXAM_STATUS,b.RECYCLE_IS,
(select count(1) from gha_ex_my_exam where EXAM_ID = b.ID_) as answerNumber,
c.ID_ as c_ID_,c.ISDELETED as c_ISDELETED,c.TENANTID as c_TENANTID,c.OPTIME as c_OPTIME,c.OPER as c_OPER, c.UPDATETIME as c_UPDATETIME,c.UPDATOR as c_UPDATOR,c.TOPIC_ID as c_TOPIC_ID,c.TOPIC_SORT as c_TOPIC_SORT,c.EXAM_ID as c_EXAM_ID
from gha_ex_exam_group a left join gha_ex_exam b on a.ID_ = b.GROUP_ID and b.ISDELETED = '0'
left join gha_ex_exam_question_sort c on b.ID_ = c.EXAM_ID and c.ISDELETED = '0'
<where>
a.ISDELETED = '0'
<if test="nameAndId != null and nameAndId != ''">
and (b.EXAM_NAME like concat('%',#{nameAndId},'%') or b.ID_ = #{nameAndId})
</if>
<if test="keyWord !=null and keyWord != ''">
and b.EXAM_NAME like concat('%',#{keyWord},'%')
</if>
<if test="conditions != null">
and (
<foreach collection="conditions" item="entity" separator="or">
b.EXAM_STATUS = #{entity}
</foreach>
)
</if>
<if test="peopleType != null and peopleType == 1">
<if test="userIds != null">
and (
<foreach collection="userIds" item="entity" separator="or">
b.PUBLIC_PEOPLE = #{entity}
</foreach>
)
</if>
</if>
<if test="peopleType != null and peopleType == 2">
<if test="userIds != null">
and (
<foreach collection="userIds" item="entity" separator="or">
b.OPER = #{entity}
</foreach>
)
</if>
</if>
<if test="examId != null">
and b.ID_ = #{examId}
</if>
</where>
order by a.OPTIME desc ,b.OPTIME desc
</select>