<?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.xxfc.platform.campsite.mapper.CampsiteTagMapper">

	<!-- 可根据自己的需求，是否要使用 -->
    <resultMap type="com.xxfc.platform.campsite.entity.CampsiteTag" id="campsiteTagMap">
        <result property="id" column="id"/>
        <result property="parentId" column="parent_id"/>
        <result property="name" column="name"/>
        <result property="isSearch" column="is_search"/>
        <result property="rank" column="rank"/>
        <result property="crtTime" column="crt_time"/>
        <result property="updTime" column="upd_time"/>
        <result property="isDel" column="is_del"/>
        <result property="tagUrl" column="tag_url"/>
    </resultMap>

    <resultMap type="com.xxfc.platform.campsite.dto.CampsiteTagDTO" id="campsiteTagDTOMap">
        <result property="id" column="id"/>
        <result property="parentId" column="parent_id"/>
        <result property="name" column="name"/>
        <result property="isSearch" column="is_search"/>
        <result property="rank" column="rank"/>
        <result property="ctrTime" column="crt_time"/>
        <result property="updTime" column="upd_time"/>
        <result property="isDel" column="is_del"/>
        <result property="tagUrl" column="tag_url"/>
    </resultMap>

    <!--App*查询全部营地类型-->
    <select id="findAllCampsiteTags" resultType="com.xxfc.platform.campsite.dto.CampsiteTagListDTO">
        select `id`,`name` from `campsite_tag` where `is_del`=0 and `is_search`=1;
    </select>

    <!--后台*查询全部营地类型-->
    <select id="findAllCampsiteTagsBydelStatus" resultMap="campsiteTagDTOMap">
        select * from `campsite_tag` where `is_del`=0
    </select>

    <!--更新营地类型状态-->
     <update id="updateCampsiteTagStatusById">
         update `campsite_tag` set `is_del`=#{status} where `id`=#{tagId}
     </update>

    <!--更新营地类型是否作为筛选条件-->
    <update id="updateCampsiteTagIsearchStatusById">
        update `campsite_tag` set `is_search`=#{status} where `id`=#{id}
    </update>

    <!--检验营地类型名称是否存在-->
    <select id="checkTagNameExist" resultType="int">
        select count(`id`) from `campsite_tag` where `name`=#{name}
        <if test="id != null">
            and `id`!=#{id}
        </if>
    </select>
</mapper>