<?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.oa.mapper.CmcAssessContentMapper">
    
    <resultMap type="CmcAssessContent" id="CmcAssessContentResult">
        <result property="contentId"    column="content_id"    />
        <result property="role"    column="role"    />
        <result property="familiar"    column="familiar"    />
        <result property="remark"    column="remark"    />
        <result property="workload"    column="workload"    />
        <result property="skill"    column="skill"    />
        <result property="quality"    column="quality"    />
        <result property="assessment"    column="assessment"    />
        <result property="advice"    column="advice"    />
    </resultMap>

    <sql id="selectCmcAssessContentVo">
        select content_id, role, familiar, remark, workload, skill, quality, assessment, advice from cmc_assess_content
    </sql>

    <select id="selectCmcAssessContentList" parameterType="CmcAssessContent" resultMap="CmcAssessContentResult">
        <include refid="selectCmcAssessContentVo"/>
        <where>  
            <if test="role != null  and role != ''"> and role = #{role}</if>
            <if test="familiar != null  and familiar != ''"> and familiar = #{familiar}</if>
            <if test="workload != null  and workload != ''"> and workload = #{workload}</if>
            <if test="skill != null  and skill != ''"> and skill = #{skill}</if>
            <if test="quality != null  and quality != ''"> and quality = #{quality}</if>
            <if test="assessment != null  and assessment != ''"> and assessment = #{assessment}</if>
            <if test="advice != null  and advice != ''"> and advice = #{advice}</if>
        </where>
    </select>
    
    <select id="selectCmcAssessContentByContentId" parameterType="String" resultMap="CmcAssessContentResult">
        <include refid="selectCmcAssessContentVo"/>
        where content_id like concat('%', #{content_id}, '%')
    </select>
        
    <insert id="insertCmcAssessContent" parameterType="CmcAssessContent">
        insert into cmc_assess_content
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="contentId != null">content_id,</if>
            <if test="role != null">role,</if>
            <if test="familiar != null">familiar,</if>
            <if test="remark != null">remark,</if>
            <if test="workload != null">workload,</if>
            <if test="skill != null">skill,</if>
            <if test="quality != null">quality,</if>
            <if test="assessment != null">assessment,</if>
            <if test="advice != null">advice,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="contentId != null">#{contentId},</if>
            <if test="role != null">#{role},</if>
            <if test="familiar != null">#{familiar},</if>
            <if test="remark != null">#{remark},</if>
            <if test="workload != null">#{workload},</if>
            <if test="skill != null">#{skill},</if>
            <if test="quality != null">#{quality},</if>
            <if test="assessment != null">#{assessment},</if>
            <if test="advice != null">#{advice},</if>
         </trim>
    </insert>

    <update id="updateCmcAssessContent" parameterType="CmcAssessContent">
        update cmc_assess_content
        <trim prefix="SET" suffixOverrides=",">
            <if test="role != null">role = #{role},</if>
            <if test="familiar != null">familiar = #{familiar},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="workload != null">workload = #{workload},</if>
            <if test="skill != null">skill = #{skill},</if>
            <if test="quality != null">quality = #{quality},</if>
            <if test="assessment != null">assessment = #{assessment},</if>
            <if test="advice != null">advice = #{advice},</if>
        </trim>
        where content_id = #{contentId}
    </update>

    <delete id="deleteCmcAssessContentByContentId" parameterType="String">
        delete from cmc_assess_content where content_id = #{contentId}
    </delete>

    <delete id="deleteCmcAssessContentByContentIds" parameterType="String">
        delete from cmc_assess_content where content_id in 
        <foreach item="contentId" collection="array" open="(" separator="," close=")">
            #{contentId}
        </foreach>
    </delete>
</mapper>