<?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.superdesk.uniorder.dao.mapper.unified.UnifiedProjectTargetMapper">
	<resultMap id="BaseResultMap" type="cn.superdesk.uniorder.dao.entity.unified.UnifiedProjectTarget">
		<id column="id" property="id" jdbcType="BIGINT"/>
		<result column="project_id" property="projectId" jdbcType="BIGINT"/>
		<result column="yearly" property="yearly" jdbcType="INTEGER"/>
		<result column="monthly" property="monthly" jdbcType="INTEGER"/>
		<result column="okr_target" property="okrTarget" jdbcType="DECIMAL"/>
		<result column="kpi_target" property="kpiTarget" jdbcType="DECIMAL"/>
		<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
		<result column="create_user_id" property="createUserId" jdbcType="BIGINT"/>
		<result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
		<result column="update_user_id" property="updateUserId" jdbcType="BIGINT"/>
	</resultMap>
	<resultMap id="VoResultMap" type="cn.superdesk.uniorder.dto.vo.unified.UnifiedProjectTargetVo">
		<id column="id" property="id" jdbcType="BIGINT"/>
		<result column="project_id" property="projectId" jdbcType="BIGINT"/>
		<result column="yearly" property="yearly" jdbcType="INTEGER"/>
		<result column="monthly" property="monthly" jdbcType="INTEGER"/>
		<result column="okr_target" property="okrTarget" jdbcType="DECIMAL"/>
		<result column="kpi_target" property="kpiTarget" jdbcType="DECIMAL"/>
		<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
		<result column="create_user_id" property="createUserId" jdbcType="BIGINT"/>
		<result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
		<result column="update_user_id" property="updateUserId" jdbcType="BIGINT"/>
	</resultMap>
	<sql id="Base_Column_List">
    id, project_id, yearly, monthly, okr_target, kpi_target, create_time, create_user_id, 
    update_time, update_user_id
  </sql>
	<select id="getData" resultMap="VoResultMap">
		select
		<include refid="Base_Column_List"/>
		from unified_project_target
		where 1=1
		<if test="projectId != null and projectId != ''">
			and project_id = #{projectId,jdbcType=BIGINT}
		</if>

	</select>
	<select id="selectByProjectIdAndMonth" resultMap="BaseResultMap">
		select
		<include refid="Base_Column_List"/>
		from unified_project_target
		where 1=1
		<if test="projectId != null and projectId != ''">
			and project_id = #{projectId,jdbcType=BIGINT}
		</if>
		<if test="yearly != null and yearly != ''">
			and yearly = #{yearly,jdbcType=INTEGER}
		</if>
		<if test="monthly != null and monthly != ''">
			and monthly = #{monthly,jdbcType=INTEGER}
		</if>
	</select>

	<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">
		select
		<include refid="Base_Column_List"/>
		from unified_project_target
		where id = #{id,jdbcType=BIGINT}
	</select>
	<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
    delete from unified_project_target
    where id = #{id,jdbcType=BIGINT}
  </delete>
	<insert id="insert" parameterType="cn.superdesk.uniorder.dao.entity.unified.UnifiedProjectTarget">
		<selectKey resultType="java.lang.Long" keyProperty="id" order="AFTER">
			SELECT LAST_INSERT_ID()
		</selectKey>
		insert into unified_project_target (project_id, yearly, monthly,
		okr_target, kpi_target, create_time,
		create_user_id, update_time, update_user_id
		)
		values (#{projectId,jdbcType=BIGINT}, #{yearly,jdbcType=INTEGER}, #{monthly,jdbcType=INTEGER},
		#{okrTarget,jdbcType=DECIMAL}, #{kpiTarget,jdbcType=DECIMAL}, #{createTime,jdbcType=TIMESTAMP},
		#{createUserId,jdbcType=BIGINT}, #{updateTime,jdbcType=TIMESTAMP}, #{updateUserId,jdbcType=BIGINT}
		)
	</insert>
	<insert id="insertSelective" parameterType="cn.superdesk.uniorder.dao.entity.unified.UnifiedProjectTarget">
		<selectKey resultType="java.lang.Long" keyProperty="id" order="AFTER">
			SELECT LAST_INSERT_ID()
		</selectKey>
		insert into unified_project_target
		<trim prefix="(" suffix=")" suffixOverrides=",">
			<if test="projectId != null">
				project_id,
			</if>
			<if test="yearly != null">
				yearly,
			</if>
			<if test="monthly != null">
				monthly,
			</if>
			<if test="okrTarget != null">
				okr_target,
			</if>
			<if test="kpiTarget != null">
				kpi_target,
			</if>
			<if test="createTime != null">
				create_time,
			</if>
			<if test="createUserId != null">
				create_user_id,
			</if>
			<if test="updateTime != null">
				update_time,
			</if>
			<if test="updateUserId != null">
				update_user_id,
			</if>
		</trim>
		<trim prefix="values (" suffix=")" suffixOverrides=",">
			<if test="projectId != null">
				#{projectId,jdbcType=BIGINT},
			</if>
			<if test="yearly != null">
				#{yearly,jdbcType=INTEGER},
			</if>
			<if test="monthly != null">
				#{monthly,jdbcType=INTEGER},
			</if>
			<if test="okrTarget != null">
				#{okrTarget,jdbcType=DECIMAL},
			</if>
			<if test="kpiTarget != null">
				#{kpiTarget,jdbcType=DECIMAL},
			</if>
			<if test="createTime != null">
				#{createTime,jdbcType=TIMESTAMP},
			</if>
			<if test="createUserId != null">
				#{createUserId,jdbcType=BIGINT},
			</if>
			<if test="updateTime != null">
				#{updateTime,jdbcType=TIMESTAMP},
			</if>
			<if test="updateUserId != null">
				#{updateUserId,jdbcType=BIGINT},
			</if>
		</trim>
	</insert>
	<update id="updateByPrimaryKeySelective"
	        parameterType="cn.superdesk.uniorder.dao.entity.unified.UnifiedProjectTarget">
		update unified_project_target
		<set>
			<if test="projectId != null">
				project_id = #{projectId,jdbcType=BIGINT},
			</if>
			<if test="yearly != null">
				yearly = #{yearly,jdbcType=INTEGER},
			</if>
			<if test="monthly != null">
				monthly = #{monthly,jdbcType=INTEGER},
			</if>
			<if test="okrTarget != null">
				okr_target = #{okrTarget,jdbcType=DECIMAL},
			</if>
			<if test="kpiTarget != null">
				kpi_target = #{kpiTarget,jdbcType=DECIMAL},
			</if>
			<if test="createTime != null">
				create_time = #{createTime,jdbcType=TIMESTAMP},
			</if>
			<if test="createUserId != null">
				create_user_id = #{createUserId,jdbcType=BIGINT},
			</if>
			<if test="updateTime != null">
				update_time = #{updateTime,jdbcType=TIMESTAMP},
			</if>
			<if test="updateUserId != null">
				update_user_id = #{updateUserId,jdbcType=BIGINT},
			</if>
		</set>
		where id = #{id,jdbcType=BIGINT}
	</update>
	<update id="updateByPrimaryKey" parameterType="cn.superdesk.uniorder.dao.entity.unified.UnifiedProjectTarget">
    update unified_project_target
    set project_id = #{projectId,jdbcType=BIGINT},
      yearly = #{yearly,jdbcType=INTEGER},
      monthly = #{monthly,jdbcType=INTEGER},
      okr_target = #{okrTarget,jdbcType=DECIMAL},
      kpi_target = #{kpiTarget,jdbcType=DECIMAL},
      create_time = #{createTime,jdbcType=TIMESTAMP},
      create_user_id = #{createUserId,jdbcType=BIGINT},
      update_time = #{updateTime,jdbcType=TIMESTAMP},
      update_user_id = #{updateUserId,jdbcType=BIGINT}
    where id = #{id,jdbcType=BIGINT}
  </update>
</mapper>