package com.genersoft.iot.vmp.gb28181.dao;
import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel;
import com.genersoft.iot.vmp.gb28181.bean.Group;
import com.genersoft.iot.vmp.gb28181.bean.Region;
import com.genersoft.iot.vmp.gb28181.bean.RegionTree;
import org.apache.ibatis.annotations.*;
import java.util.List;
import java.util.Set;
@Mapper
public interface RegionMapper {
    @Insert("INSERT INTO wvp_common_region (device_id, name, parent_id, parent_device_id, create_time, update_time) " +
            "VALUES (#{deviceId}, #{name}, #{parentId}, #{parentDeviceId}, #{createTime}, #{updateTime})")
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    void add(Region region);
    @Delete("DELETE FROM wvp_common_region WHERE id=#{id}")
    int delete(@Param("id") int id);
    @Update(" UPDATE wvp_common_region " +
            " SET update_time=#{updateTime}, device_id=#{deviceId}, name=#{name}, parent_id=#{parentId}, parent_device_id=#{parentDeviceId}" +
            " WHERE id = #{id}")
    int update(Region region);
    @Select(value = {" "})
    List query(@Param("query") String query, @Param("parentId") String parentId);
    @Select("SELECT * from wvp_common_region WHERE parent_id = #{parentId} ORDER BY id ")
    List getChildren(@Param("parentId") Integer parentId);
    @Select("SELECT * from wvp_common_region WHERE id = #{id} ")
    Region queryOne(@Param("id") int id);
    @Select(" select dc.civil_code as civil_code " +
            " from wvp_device_channel dc " +
            " where dc.civil_code not in " +
            " (select device_id from wvp_common_region)")
    List getUninitializedCivilCode();
    @Select(" ")
    List queryInList(Set codes);
    @Insert(" ")
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    int batchAdd(List regionList);
    @Select(" ")
    List queryForTree(@Param("query") String query, @Param("parentId") Integer parentId);
    @Delete("")
    void batchDelete(List allChildren);
    @Select(" ")
    List queryInRegionListByDeviceId(List regionList);
    @Select(" ")
    List queryByPlatform(@Param("platformId") Integer platformId);
    @Update(value = " ", databaseId = "mysql")
    @Update( value = " ", databaseId = "kingbase")
    @Update( value = " ", databaseId = "postgresql")
    void updateParentId(List regionListForAdd);
    @Update(" ")
    void updateChild(@Param("parentId") int parentId, @Param("parentDeviceId") String parentDeviceId);
    @Select("SELECT * from wvp_common_region WHERE device_id = #{deviceId} ")
    Region queryByDeviceId(@Param("deviceId") String deviceId);
    @Select(" ")
    Set queryParentInChannelList(Set regionSet);
    @Select(" ")
    Set queryByChannelList(List channelList);
    @Select(" ")
    Set queryNotShareRegionForPlatformByChannelList(List channelList, @Param("platformId") Integer platformId);
    @Select(" ")
    Set queryNotShareRegionForPlatformByRegionList(Set allRegion, @Param("platformId") Integer platformId);
}