<?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.ygtx.gxt.mapper.GxtScoreProjectMapper">

    <resultMap type="GxtScoreProject" id="GxtScoreProjectResult">
        <result property="id" column="id"/>
        <result property="maintenanceType" column="maintenance_type"/>
        <result property="projectName" column="project_name"/>
        <result property="scorePerCompletion" column="score_per_completion"/>
        <result property="status" column="status"/>
        <result property="createBy" column="create_by"/>
        <result property="createTime" column="create_time"/>
        <result property="updateBy" column="update_by"/>
        <result property="updateTime" column="update_time"/>
        <result property="remark" column="remark"/>
    </resultMap>

    <sql id="selectGxtScoreProjectVo">
        select id, maintenance_type, project_name, score_per_completion, status, create_by, create_time, update_by, update_time, remark from gxt_score_project
    </sql>

    <select id="selectGxtScoreProjectList" parameterType="GxtScoreProject" resultMap="GxtScoreProjectResult">
        <include refid="selectGxtScoreProjectVo"/>
        <where>
            <if test="maintenanceType != null  and maintenanceType != ''"> and maintenance_type = #{maintenanceType}</if>
            <if test="projectName != null  and projectName != ''"> and project_name like concat('%', #{projectName}, '%')</if>
            <if test="scorePerCompletion != null "> and score_per_completion = #{scorePerCompletion}</if>
            <if test="status != null "> and status = #{status}</if>
        </where>
    </select>

    <select id="selectGxtScoreProjectById" parameterType="Long" resultMap="GxtScoreProjectResult">
        <include refid="selectGxtScoreProjectVo"/>
        where id = #{id}
    </select>

    <insert id="insertGxtScoreProject" parameterType="GxtScoreProject" useGeneratedKeys="true" keyProperty="id">
        insert into gxt_score_project
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="maintenanceType != null and maintenanceType != ''">maintenance_type,</if>
            <if test="projectName != null and projectName != ''">project_name,</if>
            <if test="scorePerCompletion != null">score_per_completion,</if>
            <if test="status != null">status,</if>
            <if test="createBy != null and createBy != ''">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null and updateBy != ''">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="remark != null">remark,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="maintenanceType != null and maintenanceType != ''">#{maintenanceType},</if>
            <if test="projectName != null and projectName != ''">#{projectName},</if>
            <if test="scorePerCompletion != null">#{scorePerCompletion},</if>
            <if test="status != null">#{status},</if>
            <if test="createBy != null and createBy != ''">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null and updateBy != ''">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="remark != null">#{remark},</if>
        </trim>
    </insert>

    <update id="updateGxtScoreProject" parameterType="GxtScoreProject">
        update gxt_score_project
        <trim prefix="SET" suffixOverrides=",">
            <if test="maintenanceType != null and maintenanceType != ''">maintenance_type = #{maintenanceType},</if>
            <if test="projectName != null and projectName != ''">project_name = #{projectName},</if>
            <if test="scorePerCompletion != null">score_per_completion = #{scorePerCompletion},</if>
            <if test="status != null">status = #{status},</if>
            <if test="createBy != null and createBy != ''">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteGxtScoreProjectById" parameterType="Long">
        delete from gxt_score_project where id = #{id}
    </delete>

    <delete id="deleteGxtScoreProjectByIds" parameterType="String">
        delete from gxt_score_project where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>

</mapper>