<?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.hotent.surveyinfo.dao.CostSurveyTemplateItemsDao">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.hotent.surveyinfo.model.CostSurveyTemplateItems">
        <id column="id" property="id" />
    <result column="survey_template_id" property="surveyTemplateId" />
<!--    <result column="name" property="name" />-->
    <result column="cell_code" property="cellCode" />

    <result column="unit" property="unit" />
    <result column="order_num" property="orderNum" />
		<result column="order_text" property="orderText" />
		<result column="headers_id" property="headersId" />
		<result column="version_id" property="versionId" />
		<result column="rkey" property="rkey" />
		<result column="rvalue" property="rvalue" />
		<result column="json_str" property="jsonStr" />

		<result column="cell_code" property="cellCode" />
		<result column="calculation_formula" property="calculationFormula" />

		<result column="calculation_template_id" property="calculationTemplateId" />
		<result column="create_time" property="createTime" />
		<result column="update_time" property="updateTime" />
		<result column="create_by" property="createBy" />
		<result column="update_by" property="updateBy" />
		<result column="project_id" property="projectId" />


		<result column="rowid" property="rowid" />
		<result column="parentid" property="parentid" />


	</resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, survey_template_id, order_text,cell_code, calculation_formula, calculation_template_id, order_num,headers_id, version_id, rkey, rvalue, json_str, calculation_formula, create_time, update_time, create_by, update_by, project_id,rowid,parentid
    </sql>

	<select id="selectPage" resultMap="BaseResultMap">
		select 
			<include refid="Base_Column_List"/> 
		from
			cost_survey_template_items
		${ew.customSqlSegment}
	</select>
	
	<select id="selectList" resultMap="BaseResultMap">
		select 
			<include refid="Base_Column_List"/> 
		from
			cost_survey_template_items
		${ew.customSqlSegment}
	</select>
	
	<select id="selectById" resultMap="BaseResultMap">
		select 
			<include refid="Base_Column_List"/> 
		from
			cost_survey_template_items
		where 
		    id = #{id}
	</select>

	<select id="selectBySurveyTemplateId" resultType="com.hotent.surveyinfo.model.CostSurveyTemplateItems">
		SELECT
		    <include refid="Base_Column_List"/>

		FROM
		    cost_survey_template_items
		WHERE survey_template_id = #{surveyTemplateId}
		ORDER BY order_num ASC
	</select>
	<select id="selectBySurveyTemplateIdAndVersion" resultType="com.hotent.surveyinfo.model.CostSurveyTemplateItems">
		SELECT * FROM cost_survey_template_items
		WHERE survey_template_id = #{surveyTemplateId} AND version_id = #{version}
	</select>
	<select id="selectBySurveyTemplateIdAndVersionAndHeadersId" resultType="com.hotent.surveyinfo.model.CostSurveyTemplateItems">
		SELECT * FROM cost_survey_template_items
		WHERE survey_template_id = #{surveyTemplateId} AND version_id = #{version} AND headers_id = #{headersId}
	</select>


</mapper>
