<?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.ruoyi.system.mapper.MemberAssessmentInfoMapper">
    
    <resultMap type="MemberAssessmentInfo" id="MemberAssessmentInfoResult">
        <result property="memberAssessmentId"    column="member_assessment_id"    />
        <result property="userId"    column="user_id"    />
        <result property="proposalScore"    column="proposal_score"    />
        <result property="sqmyScore"    column="sqmy_score"    />
        <result property="conferenceScore"    column="conference_score"    />
        <result property="activityScore"    column="activity_score"    />
        <result property="bonusScore"    column="bonus_score"    />
        <result property="totalScore"    column="total_score"    />
        <result property="fullScore"    column="full_score"    />
        <result property="rank"    column="rank"    />
        <result property="totalPeople"    column="total_people"    />
        <result property="year"    column="year_data"    />
        <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="selectMemberAssessmentInfoVo">
        select member_assessment_id, user_id, proposal_score,full_score,total_people, sqmy_score, conference_score, activity_score, bonus_score, total_score, rank, year_data, create_by, create_time, update_by, update_time, remark from member_assessment_info
    </sql>

    <select id="selectMemberAssessmentInfoList" parameterType="MemberAssessmentInfo" resultMap="MemberAssessmentInfoResult">
        <include refid="selectMemberAssessmentInfoVo"/>
        <where>  
            <if test="userId != null "> and user_id = #{userId}</if>
            <if test="proposalScore != null  and proposalScore != ''"> and proposal_score = #{proposalScore}</if>
            <if test="sqmyScore != null  and sqmyScore != ''"> and sqmy_score = #{sqmyScore}</if>
            <if test="conferenceScore != null  and conferenceScore != ''"> and conference_score = #{conferenceScore}</if>
            <if test="activityScore != null  and activityScore != ''"> and activity_score = #{activityScore}</if>
            <if test="bonusScore != null  and bonusScore != ''"> and bonus_score = #{bonusScore}</if>
            <if test="totalScore != null  and totalScore != ''"> and total_score = #{totalScore}</if>
            <if test="rank != null  and rank != ''"> and rank = #{rank}</if>
            <if test="year != null  and year != ''"> and year_data = #{year}</if>
        </where>
    </select>
    
    <select id="selectMemberAssessmentInfoByMemberAssessmentId" parameterType="Long" resultMap="MemberAssessmentInfoResult">
        <include refid="selectMemberAssessmentInfoVo"/>
        where member_assessment_id = #{memberAssessmentId}
    </select>
        
    <insert id="insertMemberAssessmentInfo" parameterType="MemberAssessmentInfo" useGeneratedKeys="true" keyProperty="memberAssessmentId">
        insert into member_assessment_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="userId != null">user_id,</if>
            <if test="proposalScore != null">proposal_score,</if>
            <if test="sqmyScore != null">sqmy_score,</if>
            <if test="conferenceScore != null">conference_score,</if>
            <if test="activityScore != null">activity_score,</if>
            <if test="bonusScore != null">bonus_score,</if>
            <if test="totalScore != null">total_score,</if>
            <if test="fullScore != null">full_score,</if>
            <if test="totalPeople != null">total_people,</if>
            <if test="rank != null">rank,</if>
            <if test="year != null">year_data,</if>
            <if test="createBy != null">create_by,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="remark != null">remark,</if>
            create_time
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="userId != null">#{userId},</if>
            <if test="proposalScore != null">#{proposalScore},</if>
            <if test="sqmyScore != null">#{sqmyScore},</if>
            <if test="conferenceScore != null">#{conferenceScore},</if>
            <if test="activityScore != null">#{activityScore},</if>
            <if test="bonusScore != null">#{bonusScore},</if>
            <if test="totalScore != null">#{totalScore},</if>
            <if test="fullScore != null">#{fullScore},</if>
            <if test="totalPeople != null">#{totalPeople},</if>
            <if test="rank != null">#{rank},</if>
            <if test="year != null">#{year},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="remark != null">#{remark},</if>
            sysdate()
         </trim>
    </insert>

    <update id="updateMemberAssessmentInfo" parameterType="MemberAssessmentInfo">
        update member_assessment_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="userId != null">user_id = #{userId},</if>
            <if test="proposalScore != null">proposal_score = #{proposalScore},</if>
            <if test="sqmyScore != null">sqmy_score = #{sqmyScore},</if>
            <if test="conferenceScore != null">conference_score = #{conferenceScore},</if>
            <if test="activityScore != null">activity_score = #{activityScore},</if>
            <if test="bonusScore != null">bonus_score = #{bonusScore},</if>
            <if test="totalScore != null">total_score = #{totalScore},</if>
            <if test="fullScore != null">full_score = #{fullScore},</if>
            <if test="totalPeople != null">total_people = #{totalPeople},</if>
            <if test="rank != null">rank = #{rank},</if>
            <if test="year != null">year_data = #{year},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where user_id = #{userId} and year_data  = #{year}
    </update>

    <delete id="deleteMemberAssessmentInfoByMemberAssessmentId" parameterType="Long">
        delete from member_assessment_info where member_assessment_id = #{memberAssessmentId}
    </delete>

    <delete id="deleteMemberAssessmentInfoByMemberAssessmentIds" parameterType="String">
        delete from member_assessment_info where member_assessment_id in 
        <foreach item="memberAssessmentId" collection="array" open="(" separator="," close=")">
            #{memberAssessmentId}
        </foreach>
    </delete>
</mapper>