<?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="cn.com.countrygarden.bi.main.dao.project.ProjectJointPlanMapper">
    <resultMap id="BaseResultMap" type="cn.com.countrygarden.bi.main.model.project.ProjectJointPlan">
        <!--
          WARNING - @mbg.generated
        -->
        <id column="id" jdbcType="INTEGER" property="id"/>
        <result column="name" jdbcType="VARCHAR" property="name"/>
        <result column="gmt_create" jdbcType="TIMESTAMP" property="createdDate"/>
        <result column="created_by" jdbcType="VARCHAR" property="createdBy"/>
        <result column="gmt_modified" jdbcType="TIMESTAMP" property="updatedDate"/>
        <result column="modified_by" jdbcType="VARCHAR" property="updatedBy"/>
         <result column="sort" jdbcType="INTEGER" property="sort"/>
           <result column="level" jdbcType="INTEGER" property="level"/>
           <result column="is_suspicious" jdbcType="INTEGER" property="isSuspicious"/>
           
    </resultMap>

	<select id="findOneProjectJointPlan"   resultMap="BaseResultMap" parameterType="int">
		SELECT
			id,
			name,
			sort,
			level,
			is_suspicious
		FROM
			project_joint_plan
		WHERE 
			id = #{id}
	</select>
    <select id="search" resultMap="BaseResultMap">
       SELECT
		id,
		name,
		sort,
		is_suspicious
		FROM
			project_joint_plan
		WHERE
			is_delete = '0' AND menu_id = #{menuId}
		order by sort
    </select>
     
    <insert id="add">
    	INSERT INTO project_joint_plan (name,level,sort,gmt_create,create_by,gmt_modified,modified_by)
       	VALUES
        ( #{name}, #{level},#{sort},#{createdDate},#{createdBy},#{updatedDate},#{updatedBy})
    </insert>
    <update id='update' parameterType="cn.com.countrygarden.bi.main.model.project.ProjectJointPlan" >
    	UPDATE 
    		project_joint_plan
    	SET
    		<if test="name != null and name != ''" >
    			name = #{name},
    		</if>
    		<if test="name != null and name != ''" >
    			sort = #{sort},
    		</if>
    		<if test="level != null and level != ''" >
    			level = #{level},
    		</if>
    		<if test="isSuspicious != null" >
    			is_suspicious=#{isSuspicious},
    		</if>
    		gmt_modified = #{updatedDate},modified_by = #{updatedBy}
    	WHERE	
    		id = #{id}
    </update>
    <delete id="deletePlan" parameterType="int">
    	DELETE FROM project_joint_plan WHERE id = #{id}
    </delete>
</mapper>