<?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.test.project.mapper.ProjectMaintenenceMapper">
    
	<sql id="projectMaintenenceColumns">
		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.del_flag AS "delFlag",
		a.project_type AS "projectType",
		a.project_code AS "projectCode",
		a.report_code AS "reportCode",
		a.module AS "module",
		a.feedbacker AS "feedbacker",
		a.feedbacker_dep AS "feedbackerDep",
		a.phone_num AS "phoneNum",
		a.qq_id AS "qqId",
		a.weixin_id AS "weixinId",
		a.problem_desc AS "problemDesc",
		a.deal_status AS "dealStatus",
		a.deal_plan AS "dealPlan"
	</sql>
	
	<sql id="projectMaintenenceJoins">
		
	</sql>
    <resultMap type="ProjectMaintenence" id="ProjectMaintenenceResult" autoMapping="true">
    	<result column="problem_desc" property="problemDesc"   typeHandler="com.jeeplus.core.mapper.ConvertBlobTypeHandler"/>
    	<result column="deal_plan" property="dealPlan"   typeHandler="com.jeeplus.core.mapper.ConvertBlobTypeHandler"/>
    </resultMap>
    
	<select id="get" resultMap="ProjectMaintenenceResult" >
		SELECT 
			<include refid="projectMaintenenceColumns"/>
		FROM xg_project_maintenence a
		<include refid="projectMaintenenceJoins"/>
		WHERE a.id = #{id}
	</select>
	
	<select id="findList" resultMap="ProjectMaintenenceResult" >
		SELECT 
			<include refid="projectMaintenenceColumns"/>
		FROM xg_project_maintenence a
		<include refid="projectMaintenenceJoins"/>
		<where>
			a.del_flag = #{DEL_FLAG_NORMAL}
			${dataScope}
			<if test="projectCode != null and projectCode != ''">
				AND a.project_code = #{projectCode}
			</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" resultMap="ProjectMaintenenceResult" >
		SELECT 
			<include refid="projectMaintenenceColumns"/>
		FROM xg_project_maintenence a
		<include refid="projectMaintenenceJoins"/>
		<where>
			a.del_flag = #{DEL_FLAG_NORMAL}
			${dataScope}
		</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 xg_project_maintenence(
			id,
			create_by,
			create_date,
			update_by,
			update_date,
			del_flag,
			project_type,
			project_code,
			report_code,
			module,
			feedbacker,
			feedbacker_dep,
			phone_num,
			qq_id,
			weixin_id,
			problem_desc,
			deal_status,
			deal_plan
		) VALUES (
			#{id},
			#{createBy.id},
			#{createDate},
			#{updateBy.id},
			#{updateDate},
			#{delFlag},
			#{projectType},
			#{projectCode},
			#{reportCode},
			#{module},
			#{feedbacker},
			#{feedbackerDep},
			#{phoneNum},
			#{qqId},
			#{weixinId},
			#{problemDesc},
			#{dealStatus},
			#{dealPlan}
		)
	</insert>
	
	<update id="update">
		UPDATE xg_project_maintenence SET
			update_by = #{updateBy.id},
			update_date = #{updateDate},
			project_type = #{projectType},
			project_code = #{projectCode},
			report_code = #{reportCode},
			module = #{module},
			feedbacker = #{feedbacker},
			feedbacker_dep = #{feedbackerDep},
			phone_num = #{phoneNum},
			qq_id = #{qqId},
			weixin_id = #{weixinId},
			problem_desc = #{problemDesc},
			deal_status = #{dealStatus},
			deal_plan = #{dealPlan}
		WHERE id = #{id}
	</update>
	
	
	<!--物理删除-->
	<update id="delete">
		DELETE FROM xg_project_maintenence
		WHERE id = #{id}
	</update>
	
	<!--逻辑删除-->
	<update id="deleteByLogic">
		UPDATE xg_project_maintenence SET
			del_flag = #{DEL_FLAG_DELETE}
		WHERE id = #{id}
	</update>
	
	
	<!-- 根据实体名称和字段名称和字段值获取唯一记录 -->
	<select id="findUniqueByProperty" resultType="projectMaintenence" statementType="STATEMENT">
		select * FROM xg_project_maintenence  where ${propertyName} = '${value}'
	</select>
	
</mapper>