<?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">

<mapper namespace="cn.iocoder.yudao.module.system.dal.mysql.biz.ElderlySyntheticAbilityMapper">
    <select id="queryPage" resultType="cn.iocoder.yudao.module.system.dal.dataobject.biz.ElderlySyntheticAbilityDO">
        select sa.* from elderly_synthetic_ability sa
        left join elderly_info e on e.id = sa.elder_id
        <where>
            1 = 1
            <if test="null != params.elderName and '' != params.elderName">
                AND e.elder_name like concat('%',#{params.elderName} ,'%')
            </if>
            <if test="null != params.elderSex and '' != params.elderSex">
                AND e.elder_sex = #{params.elderSex}
            </if>
            <if test="null != params.questionnaireName and '' != params.questionnaireName">
                AND sa.questionnaire_name like concat('%',#{params.questionnaireName} ,'%')
            </if>
            <if test="null != params.tenantIds">
                AND sa.tenant_id in
                <foreach item="id" collection="params.tenantIds" open="(" separator="," close=")">
                    #{id}
                </foreach>
            </if>
            <if test="null != params.orgType">
                AND sa.org_type = #{params.orgType}
            </if>
        </where>
        order by sa.create_date desc
    </select>
</mapper>
