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>
相关推荐
希望永不加班几秒前
如何在 SpringBoot 里自定义 Spring MVC 配置
java·spring boot·后端·spring·mvc
weixin199701080161 分钟前
“迷你京东”全栈架构设计与实现
java·大数据·python·数据库架构
东离与糖宝9 分钟前
3月20日紧急修复|Spring AI双漏洞CVE-2026-22730/22729实战防护方案
java
东离与糖宝11 分钟前
Spring Boot 4.0适配JDK 26|一键升级与常见坑速解
java
大傻^15 分钟前
Spring AI Alibaba MCP协议实战:模型上下文协议集成与工具调用
java·人工智能·后端·spring·elasticsearch·springaialibaba
Via_Neo19 分钟前
JAVA中对数的表达,将浮点数转为保留指定位数的字符串
java·开发语言
左左右右左右摇晃21 分钟前
String、StringBuffer、StringBuilder的区别
java·笔记
稻草猫.28 分钟前
MyBatis进阶:动态SQL与MyBatis Generator插件使用
java·数据库·后端·spring·mvc·mybatis
xiangpanf29 分钟前
PHP vs Go:30秒读懂核心差异
java·开发语言