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

    <resultMap type="com.ruoyi.system.domain.publicservice.TPublicServiceDemand" id="TPublicServiceDemandResult">
        <result property="demandId"    column="demand_id"    />
        <result property="demandType"    column="demand_type"    />
        <result property="demandName"    column="demand_name"    />
        <result property="demandDesc"    column="demand_desc"    />
        <result property="planPrice"    column="plan_price"    />
        <result property="planPriceEnd"    column="plan_price_end"    />
        <result property="demandOwner"    column="demand_owner"    />
        <result property="demandPhone"    column="demand_phone"    />
        <result property="demandStatus"    column="demand_status"    />
        <result property="valid"    column="valid"    />
        <result property="createTime"    column="create_time"    />
        <result property="createBy"    column="create_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="demandCode"    column="demand_code"    />
    </resultMap>

    <sql id="selectTPublicServiceDemandVo">
        select demand_id, demand_type, demand_name, demand_desc, plan_price, plan_price_end, demand_owner, demand_phone, demand_status, valid, create_time, create_by, update_time, update_by, demand_code from t_public_service_demand
    </sql>

    <select id="list" parameterType="com.ruoyi.system.domain.publicservice.TPublicServiceDemand" resultMap="TPublicServiceDemandResult">
        <include refid="selectTPublicServiceDemandVo"/>
        <where>
            <if test="demandType != null  and demandType != ''"> and demand_type = #{demandType}</if>
            <if test="demandName != null  and demandName != ''"> and demand_name like concat('%', #{demandName}, '%')</if>
            <if test="demandDesc != null  and demandDesc != ''"> and demand_desc = #{demandDesc}</if>
            <if test="planPrice != null  and planPrice != ''"> and plan_price = #{planPrice}</if>
            <if test="planPriceEnd != null  and planPriceEnd != ''"> and plan_price_end = #{planPriceEnd}</if>
            <if test="demandOwner != null  and demandOwner != ''"> and demand_owner = #{demandOwner}</if>
            <if test="demandPhone != null  and demandPhone != ''"> and demand_phone = #{demandPhone}</if>
            <if test="demandStatus != null  and demandStatus != ''"> and demand_status = #{demandStatus}</if>
            <if test="valid != null "> and valid = #{valid}</if>
            <if test="createTime != null "> and create_time = #{createTime}</if>
            <if test="createBy != null  and createBy != ''"> and create_by = #{createBy}</if>
            <if test="updateTime != null "> and update_time = #{updateTime}</if>
            <if test="updateBy != null  and updateBy != ''"> and update_by = #{updateBy}</if>
            <if test="demandCode != null  and demandCode != ''"> and demand_code = #{demandCode}</if>
        </where>
    </select>

    <select id="getObjectById" resultMap="TPublicServiceDemandResult">
        <include refid="selectTPublicServiceDemandVo"/>
        where demand_id = #{demandId}
    </select>

    <insert id="save" parameterType="com.ruoyi.system.domain.publicservice.TPublicServiceDemand">
        insert into t_public_service_demand
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="demandId != null ">demand_id,</if>
            <if test="demandType != null  and demandType != ''">demand_type,</if>
            <if test="demandName != null  and demandName != ''">demand_name,</if>
            <if test="demandDesc != null  and demandDesc != ''">demand_desc,</if>
            <if test="planPrice != null  and planPrice != ''">plan_price,</if>
            <if test="planPriceEnd != null  and planPriceEnd != ''">plan_price_end,</if>
            <if test="demandOwner != null  and demandOwner != ''">demand_owner,</if>
            <if test="demandPhone != null  and demandPhone != ''">demand_phone,</if>
            <if test="demandStatus != null  and demandStatus != ''">demand_status,</if>
            <if test="valid != null ">valid,</if>
            <if test="createTime != null ">create_time,</if>
            <if test="createBy != null  and createBy != ''">create_by,</if>
            <if test="updateTime != null ">update_time,</if>
            <if test="updateBy != null  and updateBy != ''">update_by,</if>
            <if test="demandCode != null  and demandCode != ''">demand_code,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="demandId != null ">#{demandId},</if>
            <if test="demandType != null  and demandType != ''">#{demandType},</if>
            <if test="demandName != null  and demandName != ''">#{demandName},</if>
            <if test="demandDesc != null  and demandDesc != ''">#{demandDesc},</if>
            <if test="planPrice != null  and planPrice != ''">#{planPrice},</if>
            <if test="planPriceEnd != null  and planPriceEnd != ''">#{planPriceEnd},</if>
            <if test="demandOwner != null  and demandOwner != ''">#{demandOwner},</if>
            <if test="demandPhone != null  and demandPhone != ''">#{demandPhone},</if>
            <if test="demandStatus != null  and demandStatus != ''">#{demandStatus},</if>
            <if test="valid != null ">#{valid},</if>
            <if test="createTime != null ">#{createTime},</if>
            <if test="createBy != null  and createBy != ''">#{createBy},</if>
            <if test="updateTime != null ">#{updateTime},</if>
            <if test="updateBy != null  and updateBy != ''">#{updateBy},</if>
            <if test="demandCode != null  and demandCode != ''">#{demandCode},</if>
         </trim>
    </insert>

    <update id="update" parameterType="com.ruoyi.system.domain.publicservice.TPublicServiceDemand">
        update t_public_service_demand
        <trim prefix="SET" suffixOverrides=",">
            <if test="demandType != null and demandType != ''">demand_type = #{demandType},</if>
            <if test="demandName != null and demandName != ''">demand_name = #{demandName},</if>
            <if test="demandDesc != null and demandDesc != ''">demand_desc = #{demandDesc},</if>
            <if test="planPrice != null and planPrice != ''">plan_price = #{planPrice},</if>
            <if test="planPriceEnd != null and planPriceEnd != ''">plan_price_end = #{planPriceEnd},</if>
            <if test="demandOwner != null and demandOwner != ''">demand_owner = #{demandOwner},</if>
            <if test="demandPhone != null and demandPhone != ''">demand_phone = #{demandPhone},</if>
            <if test="demandStatus != null and demandStatus != ''">demand_status = #{demandStatus},</if>
            <if test="valid != null">valid = #{valid},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="createBy != null and createBy != ''">create_by = #{createBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
            <if test="demandCode != null and demandCode != ''">demand_code = #{demandCode},</if>
        </trim>
        where demand_id = #{demandId}
    </update>

    <delete id="remove">
        delete from t_public_service_demand
        where demand_id = #{demandId}
    </delete>

    <delete id="batchRemove">
        delete from t_public_service_demand where
        demand_id in
        <foreach item="demandId" collection="demandId" open="(" separator="," close=")">
            #{demandId}
        </foreach>
    </delete>

    <select id="getMaxNo" resultMap="TPublicServiceDemandResult">
        select max(demand_code) demand_code
        from t_public_service_demand
    </select>

</mapper>
