<?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.zcxk.evaluation.dao.EvaluationItemValueMapper">


    <resultMap type="com.zcxk.evaluation.entity.EvaluationItemValueEntity" id="EvaluationItemValueResult">
        <result property="id" column="id"/>
        <result property="tenantId" column="tenant_id"/>
        <result property="evaluationItemId" column="evaluation_item_id"/>
        <result property="type" column="type"/>
        <result property="value" column="value"/>
        <result property="valueOne" column="value_one"/>
        <result property="valueTwo" column="value_two"/>
        <result property="status" column="status"/>
        <result property="dateCreate" column="date_create"/>
        <result property="createBy" column="create_by"/>
        <result property="dateUpdate" column="date_update"/>
        <result property="updateBy" column="update_by"/>
    </resultMap>

    <!--  实体栏位  -->
    <sql id="evaluationItemValueColumns">
         a.id as "id" ,
         a.tenant_id as "tenantId" ,
         a.evaluation_item_id as "evaluationItemId" ,
         a.type as "type" ,
         a.value as "value" ,
         a.value_one as "valueOne" ,
         a.value_two as "valueTwo" ,
         a.status as "status" ,
         a.date_create as "dateCreate" ,
         a.create_by as "createBy" ,
         a.date_update as "dateUpdate" ,
         a.update_by as "updateBy" 
     </sql>


    <!--  根据主键获取实体   -->
    <select id="findEvaluationItemValueById" resultType="com.zcxk.evaluation.entity.EvaluationItemValueEntity">
        SELECT
        <include refid="evaluationItemValueColumns"/>
        FROM sc_evaluation_item_value a

        WHERE a.id = #{id} and a.status=1
    </select>

    <!--  根据获取实体List   -->
    <select id="findList" resultType="com.zcxk.evaluation.entity.EvaluationItemValueEntity">
        SELECT
        <include refid="evaluationItemValueColumns"/>
        FROM sc_evaluation_item_value a

        <where>
            <if test="evaluationItemId != null ">and a.evaluation_item_id = #{evaluationItemId}</if>
            <if test="tenantId != null ">and a.TENANT_ID = #{tenantId}</if>
        </where>
        and a.status=1
    </select>

    <!--  根据获取实体 page   -->
    <select id="findPage" resultType="com.zcxk.evaluation.entity.EvaluationItemValueEntity">
        SELECT
        <include refid="evaluationItemValueColumns"/>
        FROM sc_evaluation_item_value a

        <where>
            <if test="evaluationItemValue.evaluationItemId != null ">and a.evaluation_item_id =
                #{evaluationItemValue.evaluationItemId}
            </if>
            <if test="evaluationItemValue.dateUpdate != null ">and a.date_update = #{evaluationItemValue.dateUpdate}
            </if>
            <if test="evaluationItemValue.tenantId != null ">and a.TENANT_ID = #{evaluationItemValue.tenantId}</if>
            and a.status=1
        </where>
    </select>
    <update id="updateByItemId">
        update sc_evaluation_item_value set status=0 where evaluation_item_id = #{id}
    </update>
</mapper>