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>
相关推荐
星辰离彬14 分钟前
Java 与 MySQL 性能优化:MySQL连接池参数优化与性能提升
java·服务器·数据库·后端·mysql·性能优化
半桔14 分钟前
【Linux手册】从接口到管理:Linux文件系统的核心操作指南
android·java·linux·开发语言·面试·系统架构
nightunderblackcat23 分钟前
新手向:实现ATM模拟系统
java·开发语言·spring boot·spring cloud·tomcat·maven·intellij-idea
Bug退退退12328 分钟前
RabbitMQ 高级特性之延迟队列
java·spring·rabbitmq·java-rabbitmq
先睡32 分钟前
RabbitMQ
java
笑衬人心。33 分钟前
Java 17 新特性笔记
java·开发语言·笔记
麦兜*1 小时前
Spring Boot 企业级动态权限全栈深度解决方案,设计思路,代码分析
java·spring boot·后端·spring·spring cloud·性能优化·springcloud
ruan1145143 小时前
MySQL4种隔离级别
java·开发语言·mysql
Hellyc6 小时前
基于模板设计模式开发优惠券推送功能以及对过期优惠卷进行定时清理
java·数据库·设计模式·rocketmq