• mybatis采坑


    collection中的id需要取别名与之对应,否则出错

    <resultMap id="supplier" type="com.ch.cooker.tob.facade.pojo.dbo.SupplierOrgDbo">
        <id column="id" property="id"/>
        <result column="name" property="name"/>
        <result column="address" property="address"/>
        <result column="code" property="code"/>
        <result column="busi_name" property="busiName"/>
        <result column="handphone" property="handphone"/>
        <result column="org_a_id" property="salerId"/>
    
        <result column="licence" property="licence"/>
        <result column="permission" property="permission"/>
        <result column="status" property="status"/>
    
        <result column="date_start" property="contractDateStart"/>
        <result column="date_end" property="contractDateEnd"/>
    
        <collection property="goodsGroupVos" ofType="com.ch.cooker.tob.facade.pojo.dbo.GoodsGroupDbo" javaType="ArrayList">
            <id column="gid" property="id"/>
            <result column="group_name" property="groupName"/>
        </collection>
    </resultMap>
    
    <select id="getAllSupplier" resultMap="supplier">
        SELECT soe.id,soe.name,soe.address,soe.code,soe.busi_name,soe.handphone,soe.`enable`,
        soc.date_start,soc.date_end,soc.status,bs.licence,bs.permission,bgg.group_name,bgg.id gid
        FROM sys_org so
        LEFT JOIN sys_org_entity soe ON so.org_entity_id = soe.id
        LEFT JOIN sys_org_relation sor ON sor.org_b_id = so.id
        LEFT JOIN sys_org_contract soc ON soc.relation_id = sor.id
        LEFT JOIN busi_suppliers bs ON soe.id = bs.org_entity_id
        LEFT JOIN busi_goods_group bgg ON bgg.org_id = so.id
        <where> so.type=4
            <if test="supplier.orgId != null">
                AND so.id = #{supplier.orgId}
            </if>
    
            <if test="supplier.status != null">
                AND soe.enable = #{supplier.status}
            </if>
            <if test="supplier.name != null and supplier.name != ''">
                AND soe.name LIKE concat(concat('%',#{supplier.name}),'%')
            </if>
            <if test="supplier.salerId != null">
                AND sor.org_a_id = #{supplier.salerId}
            </if>
            <if test="current!=null">
                limit #{current},#{size}
            </if>
        </where>
    </select>

  • 相关阅读:
    回文字符串问题
    Linux添加nfs共享存储盘
    解读nginx配置
    制作自己的nginx rpm包
    linux编译安装时常见错误解决办法
    redis单机及集群安装
    nginx ssl
    vsftp配置详解
    Linux-文件系统的简单操作
    Linux-Vim编辑器
  • 原文地址:https://www.cnblogs.com/huangzhe1515023110/p/9276074.html
Copyright © 2020-2023  润新知