<?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.kcim.dao.mapper.ItemMapper">

	<!-- 可根据自己的需求，是否要使用 -->
    <resultMap type="com.kcim.dao.model.Item" id="itemMap">
        <result property="id" column="id"/>
        <result property="hospId" column="hosp_id"/>
        <result property="code" column="code"/>
        <result property="name" column="name"/>
        <result property="type" column="type"/>
        <result property="nationalCode" column="national_code"/>
        <result property="standItemCode" column="stand_item_code"/>
        <result property="standItemName" column="stand_item_name"/>
        <result property="kcCode" column="kc_code"/>
        <result property="price" column="price"/>
        <result property="createUser" column="create_user"/>
        <result property="createTime" column="create_time"/>
        <result property="updateUser" column="update_user"/>
        <result property="updateTime" column="update_time"/>
        <result property="deleteUser" column="delete_user"/>
        <result property="deleteTime" column="delete_time"/>
        <result property="delFlag" column="del_flag"/>
    </resultMap>
    <select id="getRespItemList" resultType="com.kcim.dao.model.Item" parameterType="com.kcim.dao.model.Item">
        SELECT
            a.`code`,
            a.`name`,
            a.`type`,
            a.`item_type`,
            a.`price`,
            a.`national_code`,
            a.`kc_code`,
            a.`stand_item_code`,
            a.`stand_item_name`,
            a.`department_code`,
            a.`department_name`,
            b.responsibility_code
        FROM
            com_item a
                INNER JOIN cost_responsibility_department b ON a.department_code = b.department_code
        WHERE
            a.del_flag = 0
          AND a.hosp_id = #{hospId}
        GROUP BY
            a.`code`,
            a.department_code
    </select>


</mapper>