<?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.srs.staff.mapper.SrsStaffOneStopCommunityConstructionMapper">

    <resultMap type="SrsStaffOneStopCommunityConstruction" id="SrsStaffOneStopCommunityConstructionResult">
        <result property="constructId"    column="construct_id"    />
        <result property="activityTheme"    column="activity_theme"    />
        <result property="activityProfile"    column="activity_profile"    />
        <result property="personnelType"    column="personnel_type"    />
        <result property="personnelList"    column="personnel_list"    />
        <result property="constructTime"    column="construct_time"    />
        <result property="place"    column="place"    />
        <result property="stuNumber"    column="stu_number"    />
        <result property="activityPhoto"    column="activity_photo"    />
        <result property="auditStatus"    column="audit_status"    />
        <result property="editOpinion"    column="edit_opinion"    />
        <result property="eventPromoter"    column="event_promoter"    />
        <result property="userName"    column="user_name"    />
        <result property="activePackage"    column="active_package"    />
    </resultMap>

    <sql id="selectSrsStaffOneStopCommunityConstructionVo">
        select construct_id, activity_theme, activity_profile, personnel_type, personnel_list, construct_time,
               place, stu_number, activity_photo, audit_status, edit_opinion, event_promoter,user_name,active_package from srs_staff_one_stop_community_construction
    </sql>

    <select id="selectSrsStaffOneStopCommunityConstructionList" parameterType="SrsStaffOneStopCommunityConstruction" resultMap="SrsStaffOneStopCommunityConstructionResult">
        <include refid="selectSrsStaffOneStopCommunityConstructionVo"/>
        <where>
            <if test="activityTheme != null  and activityTheme != ''"> and activity_theme like concat('%', #{activityTheme}, '%')</if>
            <if test="activityProfile != null  and activityProfile != ''"> and activity_profile = #{activityProfile}</if>
            <if test="personnelType != null  and personnelType != ''"> and personnel_type = #{personnelType}</if>
            <if test="personnelList != null  and personnelList != ''"> and personnel_list = #{personnelList}</if>
            <if test="constructTime != null "> and construct_time = #{constructTime}</if>
            <if test="startTime != null and endTime != null">
                and construct_time BETWEEN #{startTime} AND #{endTime}
            </if>
            <if test="place != null  and place != ''"> and place = #{place}</if>
            <if test="stuNumber != null "> and stu_number = #{stuNumber}</if>
            <if test="activityPhoto != null  and activityPhoto != ''"> and activity_photo = #{activityPhoto}</if>
            <if test="auditStatus != null "> and audit_status = #{auditStatus}</if>
            <if test="editOpinion != null  and editOpinion != ''"> and edit_opinion = #{editOpinion}</if>
            <if test="eventPromoter != null  and eventPromoter != ''"> and event_promoter like concat('%', #{eventPromoter}, '%')</if>
            <if test="userName != null  and userName != ''"> and user_name = #{userName}</if>
        </where>
    </select>

    <select id="selectSrsStaffOneStopCommunityConstructionByConstructId" parameterType="Long" resultMap="SrsStaffOneStopCommunityConstructionResult">
        <include refid="selectSrsStaffOneStopCommunityConstructionVo"/>
        where construct_id = #{constructId}
    </select>

    <insert id="insertSrsStaffOneStopCommunityConstruction" parameterType="SrsStaffOneStopCommunityConstruction" useGeneratedKeys="true" keyProperty="constructId">
        insert into srs_staff_one_stop_community_construction
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="activityTheme != null and activityTheme != ''">activity_theme,</if>
            <if test="activityProfile != null">activity_profile,</if>
            <if test="personnelType != null">personnel_type,</if>
            <if test="personnelList != null">personnel_list,</if>
            <if test="constructTime != null">construct_time,</if>
            <if test="place != null">place,</if>
            <if test="stuNumber != null">stu_number,</if>
            <if test="activityPhoto != null">activity_photo,</if>
            <if test="auditStatus != null">audit_status,</if>
            <if test="editOpinion != null">edit_opinion,</if>
            <if test="eventPromoter != null">event_promoter,</if>
            <if test="userName != null">user_name,</if>
            <if test="activePackage != null">active_package,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="activityTheme != null and activityTheme != ''">#{activityTheme},</if>
            <if test="activityProfile != null">#{activityProfile},</if>
            <if test="personnelType != null">#{personnelType},</if>
            <if test="personnelList != null">#{personnelList},</if>
            <if test="constructTime != null">#{constructTime},</if>
            <if test="place != null">#{place},</if>
            <if test="stuNumber != null">#{stuNumber},</if>
            <if test="activityPhoto != null">#{activityPhoto},</if>
            <if test="auditStatus != null">#{auditStatus},</if>
            <if test="editOpinion != null">#{editOpinion},</if>
            <if test="eventPromoter != null">#{eventPromoter},</if>
            <if test="userName != null">#{userName},</if>
            <if test="activePackage != null">#{activePackage},</if>
        </trim>
    </insert>

    <update id="updateSrsStaffOneStopCommunityConstruction" parameterType="SrsStaffOneStopCommunityConstruction">
        update srs_staff_one_stop_community_construction
        <trim prefix="SET" suffixOverrides=",">
            <if test="activityTheme != null and activityTheme != ''">activity_theme = #{activityTheme},</if>
            <if test="activityProfile != null">activity_profile = #{activityProfile},</if>
            <if test="personnelType != null">personnel_type = #{personnelType},</if>
            <if test="personnelList != null">personnel_list = #{personnelList},</if>
            <if test="constructTime != null">construct_time = #{constructTime},</if>
            <if test="place != null">place = #{place},</if>
            <if test="stuNumber != null">stu_number = #{stuNumber},</if>
            <if test="activityPhoto != null">activity_photo = #{activityPhoto},</if>
            <if test="auditStatus != null">audit_status = #{auditStatus},</if>
            <if test="editOpinion != null">edit_opinion = #{editOpinion},</if>
            <if test="eventPromoter != null">event_promoter = #{eventPromoter},</if>
            <if test="userName != null">user_name = #{userName},</if>
            <if test="activePackage != null">active_package = #{activePackage},</if>
        </trim>
        where construct_id = #{constructId}
    </update>

    <delete id="deleteSrsStaffOneStopCommunityConstructionByConstructId" parameterType="Long">
        delete from srs_staff_one_stop_community_construction where construct_id = #{constructId}
    </delete>

    <delete id="deleteSrsStaffOneStopCommunityConstructionByConstructIds" parameterType="String">
        delete from srs_staff_one_stop_community_construction where construct_id in
        <foreach item="constructId" collection="array" open="(" separator="," close=")">
            #{constructId}
        </foreach>
    </delete>
</mapper>