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

    <resultMap type="SzxcWishManage" id="SzxcWishManageResult">
        <result property="id"    column="id"    />
        <result property="applyName"    column="apply_name"    />
        <result property="applyPhone"    column="apply_phone"    />
        <result property="applyDate"    column="apply_date"    />
        <result property="title"    column="title"    />
        <result property="wishType"    column="wish_type"    />
        <result property="wishDescrib"    column="wish_describ"    />
        <result property="wishStatus"    column="wish_status"    />
        <result property="rlName"    column="rl_name"    />
        <result property="rlPhone"    column="rl_phone"    />
        <result property="rlId"    column="rl_id"    />
        <result property="auditDept"    column="audit_dept"    />
        <result property="auditDeptid"    column="audit_deptid"    />
        <result property="auditName"    column="audit_name"    />
        <result property="auditResult"    column="audit_result"    />
        <result property="auditReason"    column="audit_reason"    />
        <result property="remark"    column="remark"    />
        <result property="deptName"    column="dept_name"    />
        <result property="deptId"    column="dept_id"    />
        <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="userId"    column="user_id"    />
    </resultMap>

    <sql id="selectSzxcWishManageVo">
        select id, apply_name, apply_phone, apply_date, title, wish_type, wish_describ, wish_status, rl_name, rl_phone, rl_id, audit_dept, audit_deptid, audit_name, audit_result, audit_reason, remark, dept_name, dept_id, create_by, create_time, update_by, update_time, user_id from szxc_wish_manage
    </sql>

    <select id="selectSzxcWishManageList" parameterType="SzxcWishManage" resultMap="SzxcWishManageResult">
        <include refid="selectSzxcWishManageVo"/> as w
        <where>
            <if test="applyName != null  and applyName != ''"> and apply_name like concat('%', #{applyName}, '%')</if>
            <if test="applyPhone != null  and applyPhone != ''"> and apply_phone = #{applyPhone}</if>
            <if test="applyDate != null "> and apply_date = #{applyDate}</if>
            <if test="title != null  and title != ''"> and title = #{title}</if>
            <if test="wishType != null  and wishType != ''"> and wish_type = #{wishType}</if>
            <if test="wishDescrib != null  and wishDescrib != ''"> and wish_describ = #{wishDescrib}</if>
            <if test="wishStatus != null  and wishStatus != ''"> and wish_status = #{wishStatus}</if>
            <if test="rlName != null  and rlName != ''"> and rl_name like concat('%', #{rlName}, '%')</if>
            <if test="rlPhone != null  and rlPhone != ''"> and rl_phone = #{rlPhone}</if>
            <if test="rlId != null "> and rl_id = #{rlId}</if>
            <if test="auditDept != null  and auditDept != ''"> and audit_dept = #{auditDept}</if>
            <if test="auditDeptid != null "> and audit_deptid = #{auditDeptid}</if>
            <if test="auditName != null  and auditName != ''"> and audit_name like concat('%', #{auditName}, '%')</if>
            <if test="auditResult != null  and auditResult != ''"> and audit_result = #{auditResult}</if>
            <if test="auditReason != null  and auditReason != ''"> and audit_reason = #{auditReason}</if>
            <if test="deptName != null  and deptName != ''"> and dept_name like concat('%', #{deptName}, '%')</if>
           <!-- <if test="deptId != null "> and dept_id = #{deptId}</if>-->
            <!--<if test="deptId != null and deptId != 0">
                AND (w.dept_id = #{deptId} OR w.dept_id IN ( SELECT s.dept_id FROM sys_dept s WHERE find_in_set(#{deptId}, ancestors) ))
            </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="selectSzxcWishManageById" parameterType="Long" resultMap="SzxcWishManageResult">
        <include refid="selectSzxcWishManageVo"/>
        where id = #{id}
    </select>

    <insert id="insertSzxcWishManage" parameterType="SzxcWishManage" useGeneratedKeys="true" keyProperty="id">
        insert into szxc_wish_manage
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="applyName != null">apply_name,</if>
            <if test="applyPhone != null">apply_phone,</if>
            <if test="applyDate != null">apply_date,</if>
            <if test="title != null">title,</if>
            <if test="wishType != null">wish_type,</if>
            <if test="wishDescrib != null">wish_describ,</if>
            <if test="wishStatus != null">wish_status,</if>
            <if test="rlName != null">rl_name,</if>
            <if test="rlPhone != null">rl_phone,</if>
            <if test="rlId != null">rl_id,</if>
            <if test="auditDept != null">audit_dept,</if>
            <if test="auditDeptid != null">audit_deptid,</if>
            <if test="auditName != null">audit_name,</if>
            <if test="auditResult != null">audit_result,</if>
            <if test="auditReason != null">audit_reason,</if>
            <if test="remark != null">remark,</if>
            <if test="deptName != null">dept_name,</if>
            <if test="deptId != null">dept_id,</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="userId != null">user_id,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="applyName != null">#{applyName},</if>
            <if test="applyPhone != null">#{applyPhone},</if>
            <if test="applyDate != null">#{applyDate},</if>
            <if test="title != null">#{title},</if>
            <if test="wishType != null">#{wishType},</if>
            <if test="wishDescrib != null">#{wishDescrib},</if>
            <if test="wishStatus != null">#{wishStatus},</if>
            <if test="rlName != null">#{rlName},</if>
            <if test="rlPhone != null">#{rlPhone},</if>
            <if test="rlId != null">#{rlId},</if>
            <if test="auditDept != null">#{auditDept},</if>
            <if test="auditDeptid != null">#{auditDeptid},</if>
            <if test="auditName != null">#{auditName},</if>
            <if test="auditResult != null">#{auditResult},</if>
            <if test="auditReason != null">#{auditReason},</if>
            <if test="remark != null">#{remark},</if>
            <if test="deptName != null">#{deptName},</if>
            <if test="deptId != null">#{deptId},</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="userId != null">#{userId},</if>
        </trim>
    </insert>

    <update id="updateSzxcWishManage" parameterType="SzxcWishManage">
        update szxc_wish_manage
        <trim prefix="SET" suffixOverrides=",">
            <if test="applyName != null">apply_name = #{applyName},</if>
            <if test="applyPhone != null">apply_phone = #{applyPhone},</if>
            <if test="applyDate != null">apply_date = #{applyDate},</if>
            <if test="title != null">title = #{title},</if>
            <if test="wishType != null">wish_type = #{wishType},</if>
            <if test="wishDescrib != null">wish_describ = #{wishDescrib},</if>
            <if test="wishStatus != null">wish_status = #{wishStatus},</if>
            <if test="rlName != null">rl_name = #{rlName},</if>
            <if test="rlPhone != null">rl_phone = #{rlPhone},</if>
            <if test="rlId != null">rl_id = #{rlId},</if>
            <if test="auditDept != null">audit_dept = #{auditDept},</if>
            <if test="auditDeptid != null">audit_deptid = #{auditDeptid},</if>
            <if test="auditName != null">audit_name = #{auditName},</if>
            <if test="auditResult != null">audit_result = #{auditResult},</if>
            <if test="auditReason != null">audit_reason = #{auditReason},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="deptName != null">dept_name = #{deptName},</if>
            <if test="deptId != null">dept_id = #{deptId},</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="userId != null">user_id = #{userId},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteSzxcWishManageById" parameterType="Long">
        delete from szxc_wish_manage where id = #{id}
    </delete>

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