<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.fzm.mall.server.admin.distribution.mapper.CompanyMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.fzm.mall.server.admin.distribution.model.Company">
        <id column="id" property="id" />
        <result column="company_name" property="companyName" />
        <result column="exp_name" property="expName" />
        <result column="company_id" property="companyId" />
        <result column="company_code" property="companyCode" />
        <result column="cooperation_network" property="cooperationNetwork" />
        <result column="network_address" property="networkAddress" />
        <result column="network_phone" property="networkPhone" />
        <result column="merchant_id" property="merchantId" />
        <result column="create_time" property="createTime" />
        <result column="update_time" property="updateTime" />
    </resultMap>

    <select id="read" resultMap="BaseResultMap">
        select c.*, e.exp_name
        from distribution_company c
        left join distribution_express e on c.company_name = e.simple_name
        where company_id = #{companyId} and merchant_id = #{merchantId}
    </select>

    <select id="list" resultMap="BaseResultMap">
        select c.*, e.exp_name
        from distribution_company c
        left join distribution_express e on c.company_name = e.simple_name
        where merchant_id = #{merchantId}
        order by c.create_time desc
    </select>
</mapper>
