Mapper 一对多查询xml

Mapper 一对多查询

xml 复制代码
    <resultMap id="EmployeeAccountMap"
               type="cn.com.fsg.ihrm.web.vo.employeeAccount.EmployeeAccountRespVO">
        <result property="id" column="id"/>
        <result property="employeeId" column="employee_id"/>
        <result property="bankAccountName" column="bank_account_name"/>
        <result property="bankAccountCode" column="bank_account_code"/>
        <result property="bankCode" column="bank_code"/>
        <result property="bankAreaCode" column="bank_area_code"/>
        <result property="isDefault" column="is_default"/>
        <result property="tenantId" column="tenant_id"/>
        <result property="deleted" column="deleted"/>

        <collection property="list"
                    ofType="cn.com.fsg.ihrm.web.vo.employeeAccount.EmployeeAccountAttributeRespVO"
                    column="id"
                    select="queryAccountAttributeList"/>
    </resultMap>

    <!--分页查询指定行数据-->
    <select id="queryPageList" resultMap="EmployeeAccountMap">
        select
        id,employee_id,bank_account_name,bank_account_code,bank_code,bank_area_code,is_default,tenant_id,deleted
        from t_employee_account
        where
        deleted = 0
        <if test="reqVO.employeeId != null and reqVO.employeeId != ''">
            and employee_id = #{employeeId}
        </if>
        <if test="reqVO.isDefault != null and reqVO.isDefault != ''">
            and is_default = #{reqVO.isDefault}
        </if>
        <if test="reqVO.tenantId != null and reqVO.tenantId != ''">
            and tenant_id = #{reqVO.tenantId}
        </if>
    </select>


    <resultMap id="EmployeeAccountAttributeMap"
               type="cn.com.fsg.ihrm.web.vo.employeeAccount.EmployeeAccountAttributeRespVO">
        <result property="id" column="id"/>
        <result property="employeeAccountId" column="employee_account_id"/>
        <result property="employeeId" column="employee_id"/>
        <result property="attributeType" column="attribute_type"/>
        <result property="attributeValue" column="attribute_value"/>
        <result property="tenantId" column="tenant_id"/>
    </resultMap>

    <!-- 查询所有子表数据 -->
    <select id="queryAccountAttributeList" resultMap="EmployeeAccountAttributeMap">
        select
        id,employee_account_id,employee_id,attribute_type,attribute_value,tenant_id
        from t_employee_account_attribute
        where
        deleted = 0
        and employee_account_id = #{id}
    </select>
相关推荐
陈大爷(有低保)10 分钟前
UDP Socket聊天室(Java)
java·网络协议·udp
kinlon.liu23 分钟前
零信任安全架构--持续验证
java·安全·安全架构·mfa·持续验证
王哲晓44 分钟前
Linux通过yum安装Docker
java·linux·docker
java6666688881 小时前
如何在Java中实现高效的对象映射:Dozer与MapStruct的比较与优化
java·开发语言
Violet永存1 小时前
源码分析:LinkedList
java·开发语言
执键行天涯1 小时前
【经验帖】JAVA中同方法,两次调用Mybatis,一次更新,一次查询,同一事务,第一次修改对第二次的可见性如何
java·数据库·mybatis
Jarlen1 小时前
将本地离线Jar包上传到Maven远程私库上,供项目编译使用
java·maven·jar
蓑 羽1 小时前
力扣438 找到字符串中所有字母异位词 Java版本
java·算法·leetcode
Reese_Cool1 小时前
【C语言二级考试】循环结构设计
android·java·c语言·开发语言