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

    <resultMap type="SzxcVisitRecard" id="SzxcVisitRecardResult">
        <result property="id"    column="id"    />
        <result property="visiterName"    column="visiter_name"    />
        <result property="submitDate"    column="submit_date"    />
        <result property="startDate"    column="start_date"    />
        <result property="endDate"    column="end_date"    />
        <result property="type"    column="type"    />
        <result property="jmId"    column="jm_id"    />
        <result property="visitObj"    column="visit_obj"    />
        <result property="title"    column="title"    />
        <result property="picture"    column="picture"    />
        <result property="content"    column="content"    />
        <result property="flowPeople"    column="flow_people"    />
        <result property="zfStatus"    column="zf_status"    />
        <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="shRemark"    column="sh_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="selectSzxcVisitRecardVo">
        select id, visiter_name, submit_date, start_date, end_date, type, jm_id, visit_obj, title, picture, content, flow_people, zf_status, audit_dept, audit_deptid, audit_name, audit_result, audit_reason, sh_remark, create_by, create_time, update_by, update_time, dept_id, dept_name, user_id from szxc_visit_recard
    </sql>

    <select id="selectSzxcVisitRecardList" parameterType="SzxcVisitRecard" resultMap="SzxcVisitRecardResult">
        <include refid="selectSzxcVisitRecardVo"/>   as v
        <where>
            <if test="visiterName != null  and visiterName != ''"> and visiter_name like concat('%', #{visiterName}, '%')</if>
            <if test="submitDate != null "> and submit_date = #{submitDate}</if>
            <if test="startDate != null "> and start_date = #{startDate}</if>
            <if test="endDate != null "> and end_date = #{endDate}</if>
            <if test="type != null  and type != ''"> and type = #{type}</if>
            <if test="jmId != null "> and jm_id = #{jmId}</if>
            <if test="visitObj != null  and visitObj != ''"> and visit_obj = #{visitObj}</if>
            <if test="title != null  and title != ''"> and title = #{title}</if>
            <if test="picture != null  and picture != ''"> and picture = #{picture}</if>
            <if test="content != null  and content != ''"> and content = #{content}</if>
            <if test="flowPeople != null  and flowPeople != ''"> and flow_people = #{flowPeople}</if>
            <if test="zfStatus != null  and zfStatus != ''"> and zf_status = #{zfStatus}</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="shRemark != null  and shRemark != ''"> and sh_remark = #{shRemark}</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="selectSzxcVisitRecardById" parameterType="Long" resultMap="SzxcVisitRecardResult">
        <include refid="selectSzxcVisitRecardVo"/>
        where id = #{id}
    </select>

    <insert id="insertSzxcVisitRecard" parameterType="SzxcVisitRecard" useGeneratedKeys="true" keyProperty="id">
        insert into szxc_visit_recard
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="visiterName != null and visiterName != ''">visiter_name,</if>
            <if test="submitDate != null">submit_date,</if>
            <if test="startDate != null">start_date,</if>
            <if test="endDate != null">end_date,</if>
            <if test="type != null">type,</if>
            <if test="jmId != null">jm_id,</if>
            <if test="visitObj != null">visit_obj,</if>
            <if test="title != null">title,</if>
            <if test="picture != null">picture,</if>
            <if test="content != null">content,</if>
            <if test="flowPeople != null">flow_people,</if>
            <if test="zfStatus != null">zf_status,</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="shRemark != null">sh_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="visiterName != null and visiterName != ''">#{visiterName},</if>
            <if test="submitDate != null">#{submitDate},</if>
            <if test="startDate != null">#{startDate},</if>
            <if test="endDate != null">#{endDate},</if>
            <if test="type != null">#{type},</if>
            <if test="jmId != null">#{jmId},</if>
            <if test="visitObj != null">#{visitObj},</if>
            <if test="title != null">#{title},</if>
            <if test="picture != null">#{picture},</if>
            <if test="content != null">#{content},</if>
            <if test="flowPeople != null">#{flowPeople},</if>
            <if test="zfStatus != null">#{zfStatus},</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="shRemark != null">#{shRemark},</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="updateSzxcVisitRecard" parameterType="SzxcVisitRecard">
        update szxc_visit_recard
        <trim prefix="SET" suffixOverrides=",">
            <if test="visiterName != null and visiterName != ''">visiter_name = #{visiterName},</if>
            <if test="submitDate != null">submit_date = #{submitDate},</if>
            <if test="startDate != null">start_date = #{startDate},</if>
            <if test="endDate != null">end_date = #{endDate},</if>
            <if test="type != null">type = #{type},</if>
            <if test="jmId != null">jm_id = #{jmId},</if>
            <if test="visitObj != null">visit_obj = #{visitObj},</if>
            <if test="title != null">title = #{title},</if>
            <if test="picture != null">picture = #{picture},</if>
            <if test="content != null">content = #{content},</if>
            <if test="flowPeople != null">flow_people = #{flowPeople},</if>
            <if test="zfStatus != null">zf_status = #{zfStatus},</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="shRemark != null">sh_remark = #{shRemark},</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="deleteSzxcVisitRecardById" parameterType="Long">
        delete from szxc_visit_recard where id = #{id}
    </delete>

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