<?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.jeeplus.modules.workcontent.dao.WorkContentContractTermDao">
    
	<sql id="workContentContractTermColumns">
		a.id AS "id",
		a.contract_id AS "contractId",
		a.title AS "title",
		a.content AS "content",
		a.tnumber AS "tnumber",
		a.del_flag AS "delFlag"
	</sql>
	
	<sql id="workContentContractTermJoins">
	</sql>
	
    
	<select id="get" resultType="WorkContentContractTerm" >
		SELECT 
			<include refid="workContentContractTermColumns"/>
		FROM work_content_contract_term a
		<include refid="workContentContractTermJoins"/>
		WHERE a.id = #{id}
	</select>
	
	<select id="findList" resultType="WorkContentContractTerm" >
		SELECT 
			<include refid="workContentContractTermColumns"/>
		FROM work_content_contract_term a
		<include refid="workContentContractTermJoins"/>
		<where>
            <if test="contractId != null and contractId !=''">
                AND a.contract_id = #{contractId}
            </if>
			AND a.del_flag = #{DEL_FLAG_NORMAL}
		</where>
		<choose>
			<when test="page !=null and page.orderBy != null and page.orderBy != ''">
				ORDER BY ${page.orderBy}
			</when>
			<otherwise>
			</otherwise>
		</choose>
	</select>
	
	<select id="findAllList" resultType="WorkContentContractTerm" >
		SELECT 
			<include refid="workContentContractTermColumns"/>
		FROM work_content_contract_term a
		<include refid="workContentContractTermJoins"/>
		<where>
			a.del_flag = #{DEL_FLAG_NORMAL}
		</where>		
		<choose>
			<when test="page !=null and page.orderBy != null and page.orderBy != ''">
				ORDER BY ${page.orderBy}
			</when>
			<otherwise>
			</otherwise>
		</choose>
	</select>
	
	<insert id="insert">
		INSERT INTO work_content_contract_term(
			id,
			contract_id,
			title,
			content,
			tnumber,
			del_flag
		) VALUES (
			#{id},
			#{contractId},
			#{title},
			#{content},
			#{tnumber},
			#{delFlag}
		)
	</insert>
	
	<update id="update">
		UPDATE work_content_contract_term SET 	
			contract_id = #{contractId},
			title = #{title},
			content = #{content},
			tnumber = #{tnumber}
		WHERE id = #{id}
	</update>
	
	
	<!--物理删除-->
	<update id="delete">
		DELETE FROM work_content_contract_term
		WHERE id = #{id}
	</update>
	
	<!--逻辑删除-->
	<update id="deleteByLogic">
		UPDATE work_content_contract_term SET 
			del_flag = #{DEL_FLAG_DELETE}
		WHERE id = #{id}
	</update>
	
	
	<!-- 根据实体名称和字段名称和字段值获取唯一记录 -->
	<select id="findUniqueByProperty" resultType="WorkContentContractTerm" statementType="STATEMENT">
		select * FROM work_content_contract_term  where ${propertyName} = '${value}'
	</select>
	
</mapper>