<?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.SzxcHelpMapper">

    <resultMap type="SzxcHelp" id="SzxcHelpResult">
        <result property="id"    column="id"    />
        <result property="subName"    column="sub_name"    />
        <result property="subDate"    column="sub_date"    />
        <result property="phone"    column="phone"    />
        <result property="sbType"    column="sb_type"    />
        <result property="title"    column="title"    />
        <result property="content"    column="content"    />
        <result property="helpStatus"    column="help_status"    />
        <result property="handleDept"    column="handle_dept"    />
        <result property="handleDeptid"    column="handle__deptid"    />
        <result property="handleName"    column="handle__name"    />
        <result property="handleResult"    column="handle__result"    />
        <result property="handleReason"    column="handle__reason"    />
        <result property="remark"    column="remark"    />
        <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="deptId"    column="dept_id"    />
        <result property="deptName"    column="dept_name"    />
        <result property="userId"    column="user_id"    />
    </resultMap>

    <sql id="selectSzxcHelpVo">
        select id, sub_name, sub_date, phone, sb_type, title, content, help_status, handle_dept, handle__deptid, handle__name, handle__result, handle__reason, remark, create_by, create_time, update_by, update_time, dept_id, dept_name, user_id from szxc_help
    </sql>

    <select id="selectSzxcHelpList" parameterType="SzxcHelp" resultMap="SzxcHelpResult">
        <include refid="selectSzxcHelpVo"/>  as h
        <where>
            <if test="subName != null  and subName != ''"> and sub_name like concat('%', #{subName}, '%')</if>
            <if test="subDate != null "> and sub_date = #{subDate}</if>
            <if test="phone != null  and phone != ''"> and phone = #{phone}</if>
            <if test="sbType != null  and sbType != ''"> and sb_type = #{sbType}</if>
            <if test="title != null  and title != ''"> and title = #{title}</if>
            <if test="content != null  and content != ''"> and content = #{content}</if>
            <if test="helpStatus != null  and helpStatus != ''"> and help_status = #{helpStatus}</if>
            <if test="handleDept != null  and handleDept != ''"> and handle_dept = #{handleDept}</if>
            <if test="handleDeptid != null "> and handle__deptid = #{handleDeptid}</if>
            <if test="handleName != null  and handleName != ''"> and handle__name like concat('%', #{handleName}, '%')</if>
            <if test="handleResult != null  and handleResult != ''"> and handle__result = #{handleResult}</if>
            <if test="handleReason != null  and handleReason != ''"> and handle__reason = #{handleReason}</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>
            <!--数据范围过滤-->
            <if test="params.dataScope != null and params.dataScope != ''">
                ${params.dataScope}
            </if>
        </where>
    </select>

    <select id="selectSzxcHelpById" parameterType="Long" resultMap="SzxcHelpResult">
        <include refid="selectSzxcHelpVo"/>
        where id = #{id}
    </select>

    <insert id="insertSzxcHelp" parameterType="SzxcHelp" useGeneratedKeys="true" keyProperty="id">
        insert into szxc_help
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="subName != null and subName != ''">sub_name,</if>
            <if test="subDate != null">sub_date,</if>
            <if test="phone != null">phone,</if>
            <if test="sbType != null">sb_type,</if>
            <if test="title != null and title != ''">title,</if>
            <if test="content != null">content,</if>
            <if test="helpStatus != null">help_status,</if>
            <if test="handleDept != null">handle_dept,</if>
            <if test="handleDeptid != null">handle__deptid,</if>
            <if test="handleName != null">handle__name,</if>
            <if test="handleResult != null">handle__result,</if>
            <if test="handleReason != null">handle__reason,</if>
            <if test="remark != null">remark,</if>
            <if test="createBy != null">create_by,</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="subName != null and subName != ''">#{subName},</if>
            <if test="subDate != null">#{subDate},</if>
            <if test="phone != null">#{phone},</if>
            <if test="sbType != null">#{sbType},</if>
            <if test="title != null and title != ''">#{title},</if>
            <if test="content != null">#{content},</if>
            <if test="helpStatus != null">#{helpStatus},</if>
            <if test="handleDept != null">#{handleDept},</if>
            <if test="handleDeptid != null">#{handleDeptid},</if>
            <if test="handleName != null">#{handleName},</if>
            <if test="handleResult != null">#{handleResult},</if>
            <if test="handleReason != null">#{handleReason},</if>
            <if test="remark != null">#{remark},</if>
            <if test="createBy != null">#{createBy},</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="updateSzxcHelp" parameterType="SzxcHelp">
        update szxc_help
        <trim prefix="SET" suffixOverrides=",">
            <if test="subName != null and subName != ''">sub_name = #{subName},</if>
            <if test="subDate != null">sub_date = #{subDate},</if>
            <if test="phone != null">phone = #{phone},</if>
            <if test="sbType != null">sb_type = #{sbType},</if>
            <if test="title != null and title != ''">title = #{title},</if>
            <if test="content != null">content = #{content},</if>
            <if test="helpStatus != null">help_status = #{helpStatus},</if>
            <if test="handleDept != null">handle_dept = #{handleDept},</if>
            <if test="handleDeptid != null">handle__deptid = #{handleDeptid},</if>
            <if test="handleName != null">handle__name = #{handleName},</if>
            <if test="handleResult != null">handle__result = #{handleResult},</if>
            <if test="handleReason != null">handle__reason = #{handleReason},</if>
            <if test="remark != null">remark = #{remark},</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="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="deleteSzxcHelpById" parameterType="Long">
        delete from szxc_help where id = #{id}
    </delete>

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