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>
相关推荐
pianmian137 分钟前
类(JavaBean类)和对象
java
我叫小白菜1 小时前
【Java_EE】单例模式、阻塞队列、线程池、定时器
java·开发语言
Albert Edison2 小时前
【最新版】IntelliJ IDEA 2025 创建 SpringBoot 项目
java·spring boot·intellij-idea
超级小忍2 小时前
JVM 中的垃圾回收算法及垃圾回收器详解
java·jvm
weixin_446122462 小时前
JAVA内存区域划分
java·开发语言·redis
勤奋的小王同学~3 小时前
(javaEE初阶)计算机是如何组成的:CPU基本工作流程 CPU介绍 CPU执行指令的流程 寄存器 程序 进程 进程控制块 线程 线程的执行
java·java-ee
TT哇3 小时前
JavaEE==网站开发
java·redis·java-ee
2401_826097623 小时前
JavaEE-Linux环境部署
java·linux·java-ee
缘来是庄3 小时前
设计模式之访问者模式
java·设计模式·访问者模式
Bug退退退1234 小时前
RabbitMQ 高级特性之死信队列
java·分布式·spring·rabbitmq