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

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.hotent.surveyinfo.model.CostSurveyTemplateHeaders">
        <id column="id" property="id" />
    <result column="survey_template_id" property="surveyTemplateId" />
    <result column="field_name" property="fieldName" />
		<result column="field_ename" property="fieldEname" />
    <result column="field_type" property="fieldType" />
    <result column="format" property="format" />
    <result column="is_required" property="isRequired" />
    <result column="is_audit_period" property="isAuditPeriod" />
    <result column="is_dict" property="isDict" />
    <result column="create_time" property="createTime" />
    <result column="update_time" property="updateTime" />
    <result column="order_num" property="orderNum" />
		<result column="dictid" property="dictid" />
		<result column="field_typelen" property="fieldTypelen" />
		<result column="field_typenointlen" property="fieldTypenointlen" />
		<result column="tabtype" property="tabtype" />
		<result column="dict_code" property="dictCode" />
		<result column="area_code" property="areaCode" />
		<result column="area_level" property="areaLevel" />
		<result column="column_comment" property="columnComment" />
		<result column="column_type" property="columnType" />
		<result column="create_by" property="createBy" />
		<result column="update_by" property="updateBy" />
		<result column="version_id" property="versionId" />
		<result column="showVisible" property="showVisible" />


	</resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id,tabtype, survey_template_id, field_name, field_ename,field_type, field_typelen,field_typenointlen,format, is_required, is_audit_period, is_dict, create_time, update_time, order_num,dictid,dict_code,area_code,area_level,column_comment,column_type,create_by,update_by,version_id,showVisible
    </sql>

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

	<select id="selectBySurveyTemplateId" resultType="com.hotent.surveyinfo.model.CostSurveyTemplateHeaders">
		SELECT
		<include refid="Base_Column_List"/>
		FROM cost_survey_template_headers
		WHERE survey_template_id = #{surveyTemplateId}
		ORDER BY order_num ASC
	</select>

	<select id="selectBySurveyTemplateIdAndVersion" resultType="com.hotent.surveyinfo.model.CostSurveyTemplateHeaders">
		SELECT * FROM cost_survey_template_headers
		WHERE survey_template_id = #{surveyTemplateId} AND version_id = #{version}
	</select>
</mapper>
