<?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="cn.com.countrygarden.bi.main.dao.dmn.CostInformationMapper">

    <!-- 定义表名 -->
    <resultMap id="BaseResultMap" type="cn.com.countrygarden.bi.main.model.dmn.CostInformation">
        <id column="id" property="id"/>
        <result column="dnm_domain_information_id" property="dnmDomainInformationId"/>
        <result column="cost_type" property="costType"/>
        <result column="amount" property="amount"/>
        <result column="department_attributes" property="departmentAttributes"/>
        <result column="budget_department" property="budgetDepartment"/>
        <result column="remarks" property="remarks"/>
    </resultMap>

    <insert id="addCostInformation" parameterType="cn.com.countrygarden.bi.main.model.dmn.CostInformation">
        INSERT INTO dnm_cost_information (
            dnm_domain_information_id,
            cost_type,
            amount,
            department_attributes,
            budget_department,
            remarks
        ) VALUES (
                     #{dnmDomainInformationId},
                     #{costType},
                     #{amount},
                     #{departmentAttributes},
                     #{budgetDepartment},
                     #{remarks}
                 )
    </insert>

    <update id="updateByConditionById" parameterType="cn.com.countrygarden.bi.main.model.dmn.CostInformation">
        UPDATE dnm_cost_information
        SET
            dnm_domain_information_id = #{dnmDomainInformationId},
            cost_type = #{costType},
            amount = #{amount},
            department_attributes = #{departmentAttributes},
            budget_department = #{budgetDepartment},
            remarks = #{remarks}
        WHERE id = #{id}
    </update>

    <delete id="deleteCostInformationById" parameterType="java.lang.Integer">
        DELETE FROM dnm_cost_information
        WHERE id = #{id}
    </delete>

    <select id="getCostInformationBydnmId" resultMap="BaseResultMap" parameterType="java.lang.Integer">
        SELECT
            id,
            dnm_domain_information_id,
            cost_type,
            amount,
            department_attributes,
            budget_department,
            remarks
        FROM dnm_cost_information
        WHERE dnm_domain_information_id = #{id}
    </select>

</mapper>