<?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.system.mapper.publicservice.TPublicServiceDiscussMapper">

    <resultMap type="com.ruoyi.system.domain.publicservice.TPublicServiceDiscuss" id="TPublicServiceDiscussResult">
        <result property="discussId"    column="discuss_id"    />
        <result property="discussName"    column="discuss_name"    />
        <result property="discussPhone"    column="discuss_phone"    />
        <result property="discussCode"    column="discuss_code"    />
        <result property="belongArea"    column="belong_area"    />
        <result property="address"    column="address"    />
        <result property="discussDesc"    column="discuss_desc"    />
        <result property="discussResult"    column="discuss_result"    />
        <result property="genTask"    column="gen_task"    />
        <result property="checkAnonymous"    column="check_anonymous"    />
        <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="valid"    column="valid"    />
        <result property="projectId"    column="project_id"    />
        <result property="projectName"    column="project_name"    />
        <result property="projectAdvise"    column="project_advise"    />
        <result property="projectStatus"    column="project_status"    />
        <result property="longitude"    column="longitude"    />
        <result property="latitude"    column="latitude"    />
    </resultMap>

    <sql id="selectTPublicServiceDiscussVo">
        select discuss_id, discuss_name, discuss_phone, discuss_code, belong_area, address, discuss_desc, discuss_result, gen_task, check_anonymous, create_by, create_time, update_by, update_time, valid, project_id, project_name, project_advise, project_status, longitude, latitude from t_public_service_discuss
    </sql>

    <select id="list" parameterType="com.ruoyi.system.domain.publicservice.TPublicServiceDiscuss" resultMap="TPublicServiceDiscussResult">
        <include refid="selectTPublicServiceDiscussVo"/>
        <where>
            <if test="discussName != null  and discussName != ''"> and discuss_name like concat('%', #{discussName}, '%')</if>
            <if test="discussPhone != null  and discussPhone != ''"> and discuss_phone = #{discussPhone}</if>
            <if test="discussCode != null  and discussCode != ''"> and discuss_code = #{discussCode}</if>
            <if test="belongArea != null  and belongArea != ''"> and belong_area = #{belongArea}</if>
            <if test="address != null  and address != ''"> and address = #{address}</if>
            <if test="discussDesc != null  and discussDesc != ''"> and discuss_desc = #{discussDesc}</if>
            <if test="discussResult != null  and discussResult != ''"> and discuss_result = #{discussResult}</if>
            <if test="genTask != null  and genTask != ''"> and gen_task = #{genTask}</if>
            <if test="checkAnonymous != null  and checkAnonymous != ''"> and check_anonymous = #{checkAnonymous}</if>
            <if test="createBy != null  and createBy != ''"> and create_by = #{createBy}</if>
            <if test="createTime != null "> and create_time = #{createTime}</if>
            <if test="updateBy != null  and updateBy != ''"> and update_by = #{updateBy}</if>
            <if test="updateTime != null "> and update_time = #{updateTime}</if>
            <if test="valid != null "> and valid = #{valid}</if>
            <if test="projectId != null  and projectId != ''"> and project_id = #{projectId}</if>
            <if test="projectName != null  and projectName != ''"> and project_name like concat('%', #{projectName}, '%')</if>
            <if test="projectAdvise != null  and projectAdvise != ''"> and project_advise = #{projectAdvise}</if>
            <if test="projectStatus != null  and projectStatus != ''"> and project_status = #{projectStatus}</if>
            <if test="longitude != null  and longitude != ''"> and longitude = #{longitude}</if>
            <if test="latitude != null  and latitude != ''"> and latitude = #{latitude}</if>
        </where>
    </select>

    <select id="getObjectById" resultMap="TPublicServiceDiscussResult">
        <include refid="selectTPublicServiceDiscussVo"/>
        where discuss_id = #{discussId}
    </select>

    <insert id="save" parameterType="com.ruoyi.system.domain.publicservice.TPublicServiceDiscuss" useGeneratedKeys="true" keyProperty="discussId">
        insert into t_public_service_discuss
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="discussId != null">discuss_id,</if>
            <if test="discussName != null">discuss_name,</if>
            <if test="discussPhone != null">discuss_phone,</if>
            <if test="discussCode != null">discuss_code,</if>
            <if test="belongArea != null">belong_area,</if>
            <if test="address != null">address,</if>
            <if test="discussDesc != null">discuss_desc,</if>
            <if test="discussResult != null">discuss_result,</if>
            <if test="genTask != null">gen_task,</if>
            <if test="checkAnonymous != null">check_anonymous,</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="valid != null">valid,</if>
            <if test="projectId != null">project_id,</if>
            <if test="projectName != null">project_name,</if>
            <if test="projectAdvise != null">project_advise,</if>
            <if test="projectStatus != null">project_status,</if>
            <if test="longitude != null">longitude,</if>
            <if test="latitude != null">latitude,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="discussId != null">#{discussId},</if>
            <if test="discussName != null">#{discussName},</if>
            <if test="discussPhone != null">#{discussPhone},</if>
            <if test="discussCode != null">#{discussCode},</if>
            <if test="belongArea != null">#{belongArea},</if>
            <if test="address != null">#{address},</if>
            <if test="discussDesc != null">#{discussDesc},</if>
            <if test="discussResult != null">#{discussResult},</if>
            <if test="genTask != null">#{genTask},</if>
            <if test="checkAnonymous != null">#{checkAnonymous},</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="valid != null">#{valid},</if>
            <if test="projectId != null">#{projectId},</if>
            <if test="projectName != null">#{projectName},</if>
            <if test="projectAdvise != null">#{projectAdvise},</if>
            <if test="projectStatus != null">#{projectStatus},</if>
            <if test="longitude != null">#{longitude},</if>
            <if test="latitude != null">#{latitude},</if>
         </trim>
    </insert>

    <update id="update" parameterType="com.ruoyi.system.domain.publicservice.TPublicServiceDiscuss">
        update t_public_service_discuss
        <trim prefix="SET" suffixOverrides=",">
            <if test="discussName != null">discuss_name = #{discussName},</if>
            <if test="discussPhone != null">discuss_phone = #{discussPhone},</if>
            <if test="discussCode != null">discuss_code = #{discussCode},</if>
            <if test="belongArea != null">belong_area = #{belongArea},</if>
            <if test="address != null">address = #{address},</if>
            <if test="discussDesc != null">discuss_desc = #{discussDesc},</if>
            <if test="discussResult != null">discuss_result = #{discussResult},</if>
            <if test="genTask != null">gen_task = #{genTask},</if>
            <if test="checkAnonymous != null">check_anonymous = #{checkAnonymous},</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="valid != null">valid = #{valid},</if>
            <if test="projectId != null">project_id = #{projectId},</if>
            <if test="projectName != null">project_name = #{projectName},</if>
            <if test="projectAdvise != null">project_advise = #{projectAdvise},</if>
            <if test="projectStatus != null">project_status = #{projectStatus},</if>
            <if test="longitude != null">longitude = #{longitude},</if>
            <if test="latitude != null">latitude = #{latitude},</if>
        </trim>
        where discuss_id = #{discussId}
    </update>

    <delete id="remove">
        delete from t_public_service_discuss
        where discuss_id = #{discussId}
    </delete>

    <delete id="batchRemove">
        delete from t_public_service_discuss where
        discuss_id in
        <foreach item="discussId" collection="discussId" open="(" separator="," close=")">
            #{discussId}
        </foreach>
    </delete>

    <select id="getMaxNo" parameterType="com.ruoyi.system.domain.publicservice.TPublicServiceDiscuss" resultMap="TPublicServiceDiscussResult">
        select max(find_code) find_code
        from t_public_service_ifind
    </select>
</mapper>
