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

    <resultMap type="com.ruoyi.system.domain.publicservice.TPublicServiceResource" id="TPublicServiceResourceResult">
        <result property="resId"    column="res_id"    />
        <result property="resType"    column="res_type"    />
        <result property="resName"    column="res_name"    />
        <result property="resAddress"    column="res_address"    />
        <result property="resDesc"    column="res_desc"    />
        <result property="resPriceType"    column="res_price_type"    />
        <result property="resPrice"    column="res_price"    />
        <result property="resPriceEnd"    column="res_price_end"    />
        <result property="resStatus"    column="res_status"    />
        <result property="resOwner"    column="res_owner"    />
        <result property="resPhone"    column="res_phone"    />
        <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="resCode"    column="res_code"    />
        <result property="typeName"    column="type_name"    />
        <result property="longitude"    column="longitude"    />
        <result property="latitude"    column="latitude"    />
        <result property="headProfile"    column="head_profile"    />
    </resultMap>

    <sql id="selectTPublicServiceResourceVo">
        select res_id, res_type, res_name, res_address, res_desc, res_price_type, res_price, res_price_end, res_status, res_owner, res_phone, valid, create_time, create_by, update_time, update_by, res_code, type_name, longitude, latitude, head_profile from t_public_service_resource
    </sql>

    <select id="list" parameterType="com.ruoyi.system.domain.publicservice.TPublicServiceResource" resultMap="TPublicServiceResourceResult">
        <include refid="selectTPublicServiceResourceVo"/>
        <where>
            <if test="resType != null  and resType != ''"> and res_type = #{resType}</if>
            <if test="resName != null  and resName != ''"> and res_name like concat('%', #{resName}, '%')</if>
            <if test="resAddress != null  and resAddress != ''"> and res_address = #{resAddress}</if>
            <if test="resDesc != null  and resDesc != ''"> and res_desc = #{resDesc}</if>
            <if test="resPriceType != null  and resPriceType != ''"> and res_price_type = #{resPriceType}</if>
            <if test="resPrice != null  and resPrice != ''"> and res_price = #{resPrice}</if>
            <if test="resPriceEnd != null  and resPriceEnd != ''"> and res_price_end = #{resPriceEnd}</if>
            <if test="resStatus != null  and resStatus != ''"> and res_status = #{resStatus}</if>
            <if test="resOwner != null  and resOwner != ''"> and res_owner = #{resOwner}</if>
            <if test="resPhone != null  and resPhone != ''"> and res_phone = #{resPhone}</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="resCode != null  and resCode != ''"> and res_code = #{resCode}</if>
            <if test="typeName != null  and typeName != ''"> and type_name like concat('%', #{typeName}, '%')</if>
            <if test="longitude != null  and longitude != ''"> and longitude = #{longitude}</if>
            <if test="latitude != null  and latitude != ''"> and latitude = #{latitude}</if>
            <if test="headProfile != null  and headProfile != ''"> and head_profile = #{headProfile}</if>
        </where>
        <if test="orderColumn != null  and orderColumn != '' and orderType != null and orderType != '' ">
            order by  ${orderColumn}+0  ${orderType} </if>
        <if test="orderColumn == null  or orderColumn == ''">
            order by res_id desc
        </if>
    </select>

    <select id="getObjectById" resultMap="TPublicServiceResourceResult">
        <include refid="selectTPublicServiceResourceVo"/>
        where res_id = #{resId}
    </select>

    <insert id="save" parameterType="com.ruoyi.system.domain.publicservice.TPublicServiceResource" useGeneratedKeys="true" keyProperty="resId">
        insert into t_public_service_resource
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="resId != null ">res_id,</if>
            <if test="resType != null  and resType != ''">res_type,</if>
            <if test="resName != null  and resName != ''">res_name,</if>
            <if test="resAddress != null  and resAddress != ''">res_address,</if>
            <if test="resDesc != null  and resDesc != ''">res_desc,</if>
            <if test="resPriceType != null  and resPriceType != ''">res_price_type,</if>
            <if test="resPrice != null  and resPrice != ''">res_price,</if>
            <if test="resPriceEnd != null  and resPriceEnd != ''">res_price_end,</if>
            <if test="resStatus != null  and resStatus != ''">res_status,</if>
            <if test="resOwner != null  and resOwner != ''">res_owner,</if>
            <if test="resPhone != null  and resPhone != ''">res_phone,</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="resCode != null  and resCode != ''">res_code,</if>
            <if test="typeName != null  and typeName != ''">type_name,</if>
            <if test="longitude != null  and longitude != ''">longitude,</if>
            <if test="latitude != null  and latitude != ''">latitude,</if>
            <if test="headProfile != null  and headProfile != ''">head_profile,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="resId != null ">#{resId},</if>
            <if test="resType != null  and resType != ''">#{resType},</if>
            <if test="resName != null  and resName != ''">#{resName},</if>
            <if test="resAddress != null  and resAddress != ''">#{resAddress},</if>
            <if test="resDesc != null  and resDesc != ''">#{resDesc},</if>
            <if test="resPriceType != null  and resPriceType != ''">#{resPriceType},</if>
            <if test="resPrice != null  and resPrice != ''">#{resPrice},</if>
            <if test="resPriceEnd != null  and resPriceEnd != ''">#{resPriceEnd},</if>
            <if test="resStatus != null  and resStatus != ''">#{resStatus},</if>
            <if test="resOwner != null  and resOwner != ''">#{resOwner},</if>
            <if test="resPhone != null  and resPhone != ''">#{resPhone},</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="resCode != null  and resCode != ''">#{resCode},</if>
            <if test="typeName != null  and typeName != ''">#{typeName},</if>
            <if test="longitude != null  and longitude != ''">#{longitude},</if>
            <if test="latitude != null  and latitude != ''">#{latitude},</if>
            <if test="headProfile != null  and headProfile != ''">#{headProfile},</if>
        </trim>
    </insert>

    <update id="update" parameterType="com.ruoyi.system.domain.publicservice.TPublicServiceResource">
        update t_public_service_resource
        <trim prefix="SET" suffixOverrides=",">
            <if test="resType != null and resType != ''">res_type = #{resType},</if>
            <if test="resName != null and resName != ''">res_name = #{resName},</if>
            <if test="resAddress != null and resAddress != ''">res_address = #{resAddress},</if>
            <if test="resDesc != null and resDesc != ''">res_desc = #{resDesc},</if>
            <if test="resPriceType != null and resPriceType != ''">res_price_type = #{resPriceType},</if>
            <if test="resPrice != null and resPrice != ''">res_price = #{resPrice},</if>
            <if test="resPriceEnd != null and resPriceEnd != ''">res_price_end = #{resPriceEnd},</if>
            <if test="resStatus != null and resStatus != ''">res_status = #{resStatus},</if>
            <if test="resOwner != null and resOwner != ''">res_owner = #{resOwner},</if>
            <if test="resPhone != null and resPhone != ''">res_phone = #{resPhone},</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="resCode != null and resCode != ''">res_code = #{resCode},</if>
            <if test="typeName != null and typeName != ''">type_name = #{typeName},</if>
            <if test="longitude != null and longitude != ''">longitude = #{longitude},</if>
            <if test="latitude != null and latitude != ''">latitude = #{latitude},</if>
            <if test="headProfile != null and headProfile != ''">head_profile = #{headProfile},</if>
        </trim>
        where res_id = #{resId}
    </update>

    <delete id="remove">
        delete from t_public_service_resource
        where res_id = #{resId}
    </delete>

    <delete id="batchRemove">
        delete from t_public_service_resource where
        res_id in
        <foreach item="resId" collection="resId" open="(" separator="," close=")">
            #{resId}
        </foreach>
    </delete>

    <select id="getMaxNo" parameterType="com.ruoyi.system.domain.publicservice.TPublicServiceResource" resultMap="TPublicServiceResourceResult">
        select max(res_code) res_code
        from t_public_service_resource
    </select>
</mapper>
