<?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.ximai.mes.md.mapper.MdClientItemMapper">

    <select id="pageBy" resultType="com.ximai.mes.md.domain.MdClientItem">
        select
            t1.id,
            t1.client_code,
            t1.item_code,
            t1.client_item_name,
            t1.client_item_code,
            t1.create_by,
            t1.create_time,
            t1.update_by,
            t1.update_time,
            t2.item_code,
            t2.item_name
        from md_client_item t1
        left join md_item t2 on t1.item_code = t2.item_code
        where t1.client_code = #{params.clientCode}
    </select>


    <select id="getById" resultType="com.ximai.mes.md.domain.MdClientItem">
        select
            t1.id,
            t1.client_code,
            t1.item_code,
            t1.client_item_name,
            t1.client_item_code,
            t1.create_by,
            t1.create_time,
            t1.update_by,
            t1.update_time,
            t2.item_code,
            t2.item_name
        from md_client_item t1
                 left join md_item t2 on t1.item_code = t2.item_code
        where t1.id = #{id}
    </select>

    <insert id="insert">
        INSERT INTO `md_client_item`(`id`, `client_code`, `item_code`, `client_item_name`, `client_item_code`, `create_by`, `create_time`, `update_by`, `update_time`)
         VALUES (#{id}, #{clientCode}, #{itemCode}, #{clientItemName}, #{clientItemCode}, #{createBy}, #{createTime}, #{updateBy}, #{updateTime});
    </insert>

    <select id="getClientCodeListByClientCode" resultType="java.lang.String">
        select t1.item_code from md_client_item t1 where t1.client_code = #{clienCode}
    </select>

</mapper>
