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

    <resultMap type="SzxcXqInfo" id="SzxcXqInfoResult">
        <result property="id"    column="id"    />
        <result property="name"    column="name"    />
        <result property="xqType"    column="xq_type"    />
        <result property="ldNum"    column="ld_num"    />
        <result property="jzArea"    column="jz_area"    />
        <result property="zdArea"    column="zd_area"    />
        <result property="wyType"    column="wy_type"    />
        <result property="wyResponse"    column="wy_response"    />
        <result property="wyPhone"    column="wy_phone"    />
        <result property="xqAddress"    column="xq_address"    />
        <result property="buildDate"    column="build_date"    />
        <result property="xqDescribe"    column="xq_describe"    />
        <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="selectSzxcXqInfoVo">
        select id, name, xq_type, ld_num, jz_area, zd_area, wy_type, wy_response, wy_phone, xq_address, build_date, xq_describe, create_by, create_time, update_by, update_time, dept_id, dept_name, user_id from szxc_xq_info
    </sql>

    <select id="selectSzxcXqInfoList" parameterType="SzxcXqInfo" resultMap="SzxcXqInfoResult">
        <include refid="selectSzxcXqInfoVo"/> as x
        <where>
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="xqType != null  and xqType != ''"> and xq_type = #{xqType}</if>
            <if test="ldNum != null "> and ld_num = #{ldNum}</if>
            <if test="jzArea != null  and jzArea != ''"> and jz_area = #{jzArea}</if>
            <if test="zdArea != null  and zdArea != ''"> and zd_area = #{zdArea}</if>
            <if test="wyType != null  and wyType != ''"> and wy_type = #{wyType}</if>
            <if test="wyResponse != null  and wyResponse != ''"> and wy_response = #{wyResponse}</if>
            <if test="wyPhone != null  and wyPhone != ''"> and wy_phone = #{wyPhone}</if>
            <if test="xqAddress != null  and xqAddress != ''"> and xq_address = #{xqAddress}</if>
            <if test="buildDate != null "> and build_date = #{buildDate}</if>
            <if test="xqDescribe != null  and xqDescribe != ''"> and xq_describe = #{xqDescribe}</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="selectSzxcXqInfoById" parameterType="Long" resultMap="SzxcXqInfoResult">
        <include refid="selectSzxcXqInfoVo"/>
        where id = #{id}
    </select>

    <insert id="insertSzxcXqInfo" parameterType="SzxcXqInfo" useGeneratedKeys="true" keyProperty="id">
        insert into szxc_xq_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="name != null">name,</if>
            <if test="xqType != null">xq_type,</if>
            <if test="ldNum != null">ld_num,</if>
            <if test="jzArea != null">jz_area,</if>
            <if test="zdArea != null">zd_area,</if>
            <if test="wyType != null">wy_type,</if>
            <if test="wyResponse != null">wy_response,</if>
            <if test="wyPhone != null">wy_phone,</if>
            <if test="xqAddress != null">xq_address,</if>
            <if test="buildDate != null">build_date,</if>
            <if test="xqDescribe != null">xq_describe,</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="name != null">#{name},</if>
            <if test="xqType != null">#{xqType},</if>
            <if test="ldNum != null">#{ldNum},</if>
            <if test="jzArea != null">#{jzArea},</if>
            <if test="zdArea != null">#{zdArea},</if>
            <if test="wyType != null">#{wyType},</if>
            <if test="wyResponse != null">#{wyResponse},</if>
            <if test="wyPhone != null">#{wyPhone},</if>
            <if test="xqAddress != null">#{xqAddress},</if>
            <if test="buildDate != null">#{buildDate},</if>
            <if test="xqDescribe != null">#{xqDescribe},</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="updateSzxcXqInfo" parameterType="SzxcXqInfo">
        update szxc_xq_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="name != null">name = #{name},</if>
            <if test="xqType != null">xq_type = #{xqType},</if>
            <if test="ldNum != null">ld_num = #{ldNum},</if>
            <if test="jzArea != null">jz_area = #{jzArea},</if>
            <if test="zdArea != null">zd_area = #{zdArea},</if>
            <if test="wyType != null">wy_type = #{wyType},</if>
            <if test="wyResponse != null">wy_response = #{wyResponse},</if>
            <if test="wyPhone != null">wy_phone = #{wyPhone},</if>
            <if test="xqAddress != null">xq_address = #{xqAddress},</if>
            <if test="buildDate != null">build_date = #{buildDate},</if>
            <if test="xqDescribe != null">xq_describe = #{xqDescribe},</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="deleteSzxcXqInfoById" parameterType="Long">
        delete from szxc_xq_info where id = #{id}
    </delete>

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