<?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.ResponsibilityDepartmentMapper">

	<!-- 可根据自己的需求，是否要使用 -->
    <resultMap type="com.kcim.dao.model.ResponsibilityDepartment" id="responsibilityDepartmentMap">
        <result property="id" column="id" jdbcType="INTEGER"/>
        <result property="responsibilityId" column="responsibility_id" jdbcType="INTEGER"/>
        <result property="departmentId" column="department_id" jdbcType="INTEGER"/>
        <result property="hospId" column="hosp_id" jdbcType="INTEGER"/>
        <result property="createTime" column="create_time" jdbcType="BIGINT"/>
        <result property="deleteTime" column="delete_time" jdbcType="BIGINT"/>
    </resultMap>


    <select id="getDepartByCenterId" resultType="com.kcim.vo.DepartVO">
        select sd.id as departmentId,concat(sd.department_name,sd.department_code) as departmentName
            from cost_responsibility_department crd left join  sys_department sd on sd.id = crd.department_id
        where crd.responsibility_id = #{responsibilityId} and crd.delete_time = 0 and sd.delete_time = 0
    </select>
    <select id="getResponsibility" resultType="com.kcim.vo.ResponsibilityDepartIdVO">
        SELECT
            b.department_id,
            b.responsibility_id,
            a.responsibility_code,
            a.responsibility_name,
            a.share_level,
            a.share_id
        FROM
            cost_responsibility a
                INNER JOIN cost_responsibility_department b ON a.id = b.responsibility_id
                AND b.delete_time = 0
                AND b.hosp_id = #{hospId}
        WHERE
            a.hosp_id = #{hospId}
          AND a.delete_time = 0
    </select>


</mapper>