<?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.szxc.mapper.SzxcPublicActivilyMapper">
    
    <resultMap type="SzxcPublicActivily" id="SzxcPublicActivilyResult">
        <result property="id"    column="id"    />
        <result property="title"    column="title"    />
        <result property="leader"    column="leader"    />
        <result property="phone"    column="phone"    />
        <result property="content"    column="content"    />
        <result property="startTime"    column="start_time"    />
        <result property="endTime"    column="end_time"    />
        <result property="createBy"    column="create_by"    />
        <result property="remark"    column="remark"    />
        <result property="status"    column="status"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="deptId"    column="dept_id"    />
        <result property="deptName"    column="dept_name"    />
        <result property="userId"    column="user_id"    />
    </resultMap>

    <sql id="selectSzxcPublicActivilyVo">
        select id, title, leader, phone, content, start_time, end_time, create_by, remark, status, create_time, update_by, update_time, dept_id, dept_name, user_id from szxc_public_activily
    </sql>

    <select id="selectSzxcPublicActivilyList" parameterType="SzxcPublicActivily" resultMap="SzxcPublicActivilyResult">
        <include refid="selectSzxcPublicActivilyVo"/>
        <where>  
            <if test="title != null  and title != ''"> and title = #{title}</if>
            <if test="leader != null  and leader != ''"> and leader = #{leader}</if>
            <if test="phone != null  and phone != ''"> and phone = #{phone}</if>
            <if test="content != null  and content != ''"> and content = #{content}</if>
            <if test="startTime != null "> and start_time = #{startTime}</if>
            <if test="endTime != null "> and end_time = #{endTime}</if>
            <if test="status != null  and status != ''"> and status = #{status}</if>
            <if test="deptId != null "> and dept_id = #{deptId}</if>
            <if test="deptName != null  and deptName != ''"> and dept_name like concat('%', #{deptName}, '%')</if>
            <if test="userId != null "> and user_id = #{userId}</if>
        </where>
    </select>
    
    <select id="selectSzxcPublicActivilyById" parameterType="Long" resultMap="SzxcPublicActivilyResult">
        <include refid="selectSzxcPublicActivilyVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertSzxcPublicActivily" parameterType="SzxcPublicActivily" useGeneratedKeys="true" keyProperty="id">
        insert into szxc_public_activily
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="title != null and title != ''">title,</if>
            <if test="leader != null">leader,</if>
            <if test="phone != null">phone,</if>
            <if test="content != null">content,</if>
            <if test="startTime != null">start_time,</if>
            <if test="endTime != null">end_time,</if>
            <if test="createBy != null">create_by,</if>
            <if test="remark != null">remark,</if>
            <if test="status != null">status,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="deptId != null">dept_id,</if>
            <if test="deptName != null">dept_name,</if>
            <if test="userId != null">user_id,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="title != null and title != ''">#{title},</if>
            <if test="leader != null">#{leader},</if>
            <if test="phone != null">#{phone},</if>
            <if test="content != null">#{content},</if>
            <if test="startTime != null">#{startTime},</if>
            <if test="endTime != null">#{endTime},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="remark != null">#{remark},</if>
            <if test="status != null">#{status},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="deptId != null">#{deptId},</if>
            <if test="deptName != null">#{deptName},</if>
            <if test="userId != null">#{userId},</if>
         </trim>
    </insert>

    <update id="updateSzxcPublicActivily" parameterType="SzxcPublicActivily">
        update szxc_public_activily
        <trim prefix="SET" suffixOverrides=",">
            <if test="title != null and title != ''">title = #{title},</if>
            <if test="leader != null">leader = #{leader},</if>
            <if test="phone != null">phone = #{phone},</if>
            <if test="content != null">content = #{content},</if>
            <if test="startTime != null">start_time = #{startTime},</if>
            <if test="endTime != null">end_time = #{endTime},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="status != null">status = #{status},</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="deptId != null">dept_id = #{deptId},</if>
            <if test="deptName != null">dept_name = #{deptName},</if>
            <if test="userId != null">user_id = #{userId},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteSzxcPublicActivilyById" parameterType="Long">
        delete from szxc_public_activily where id = #{id}
    </delete>

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