<?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.WorkContentProjectpriceDao">
    
	<sql id="workContentProjectpriceColumns">
		a.id AS "id",
		a.create_by AS "createBy.id",
		a.create_date AS "createDate",
		a.update_by AS "updateBy.id",
		a.update_date AS "updateDate",
		a.remarks AS "remarks",
		a.del_flag AS "delFlag",
		a.project_id AS "projectId",
		a.content_id AS "contentId",
		a.ptype AS "ptype",
		a.abstracts AS "abstracts",
		a.current_amt AS "currentAmt",
		a.before_amt AS "beforeAmt",
		a.after_amt AS "afterAmt",
		a.review_amt AS "reviewAmt",
		a.before_review_amt AS "beforeReviewAmt",
		a.after_review_amt AS "afterReviewAmt",
		a.stop_amt AS "stopAmt",
		a.unpay_amt AS "unpayAmt",
		a.in_account AS "inAccount",
		a.apply_date AS "applyDate",
		a.set_date AS "setDate",
		su.name AS "createBy.name"
	</sql>
	
	<sql id="workContentProjectpriceJoins">
        LEFT JOIN sys_user su on su.id = a.create_by
	</sql>
	
    
	<select id="get" resultType="WorkContentProjectprice" >
		SELECT 
			<include refid="workContentProjectpriceColumns"/>
		FROM work_content_projectprice a
		<include refid="workContentProjectpriceJoins"/>
		WHERE a.id = #{id}
	</select>
	
	<select id="findList" resultType="WorkContentProjectprice" >
		SELECT 
			<include refid="workContentProjectpriceColumns"/>
		FROM work_content_projectprice a
		<include refid="workContentProjectpriceJoins"/>
		<where>
			a.del_flag = #{DEL_FLAG_NORMAL}
			<if test="projectId != null and projectId != ''">
				AND a.project_id = #{projectId}
			</if>
			<if test="contentId != null and contentId != ''">
				AND a.content_id = #{contentId}
			</if>
		</where>
		<choose>
			<when test="page !=null and page.orderBy != null and page.orderBy != ''">
				ORDER BY ${page.orderBy}
			</when>
			<otherwise>
				ORDER BY a.update_date DESC
			</otherwise>
		</choose>
	</select>
	
	<select id="findAllList" resultType="WorkContentProjectprice" >
		SELECT 
			<include refid="workContentProjectpriceColumns"/>
		FROM work_content_projectprice a
		<include refid="workContentProjectpriceJoins"/>
		<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>
				ORDER BY a.update_date DESC
			</otherwise>
		</choose>
	</select>
	
	<insert id="insert">
		INSERT INTO work_content_projectprice(
			id,
			create_by,
			create_date,
			update_by,
			update_date,
			remarks,
			del_flag,
			project_id,
			content_id,
			ptype,
			abstracts,
			current_amt,
			before_amt,
			after_amt,
			review_amt,
			before_review_amt,
			after_review_amt,
			stop_amt,
			unpay_amt,
			in_account,
			apply_date,
			set_date
		) VALUES (
			#{id},
			#{createBy.id},
			#{createDate},
			#{updateBy.id},
			#{updateDate},
			#{remarks},
			#{delFlag},
			#{projectId},
			#{contentId},
			#{ptype},
			#{abstracts},
			#{currentAmt},
			#{beforeAmt},
			#{afterAmt},
			#{reviewAmt},
			#{beforeReviewAmt},
			#{afterReviewAmt},
			#{stopAmt},
			#{unpayAmt},
			#{inAccount},
			#{applyDate},
			#{setDate}
		)
	</insert>
	
	<update id="update">
		UPDATE work_content_projectprice SET 	
			update_by = #{updateBy.id},
			update_date = #{updateDate},
			remarks = #{remarks},
			project_id = #{projectId},
			content_id = #{contentId},
			ptype = #{ptype},
			abstracts = #{abstracts},
			current_amt = #{currentAmt},
			before_amt = #{beforeAmt},
			after_amt = #{afterAmt},
			review_amt = #{reviewAmt},
			before_review_amt = #{beforeReviewAmt},
			after_review_amt = #{afterReviewAmt},
			stop_amt = #{stopAmt},
			unpay_amt = #{unpayAmt},
			in_account = #{inAccount},
			apply_date = #{applyDate},
			set_date = #{setDate}
		WHERE id = #{id}
	</update>
	
	
	<!--物理删除-->
	<update id="delete">
		DELETE FROM work_content_projectprice
		WHERE id = #{id}
	</update>
	
	<!--逻辑删除-->
	<update id="deleteByLogic">
		UPDATE work_content_projectprice SET 
			del_flag = #{DEL_FLAG_DELETE}
		WHERE id = #{id}
	</update>
	
	
	<!-- 根据实体名称和字段名称和字段值获取唯一记录 -->
	<select id="findUniqueByProperty" resultType="WorkContentProjectprice" statementType="STATEMENT">
		select * FROM work_content_projectprice  where ${propertyName} = '${value}'
	</select>
	
</mapper>