package com.muyu.enterprise.mapper;

import com.github.yulichang.base.MPJBaseMapper;
import com.muyu.domain.Fence;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface ElectMapper extends MPJBaseMapper<Fence> {

    /**
     * 启用
     */
    @Update("update fence set status = 0 where fence_id = #{fenceId}")
    int updateFenceOn(@Param("fenceId") Long fenceId);

    /**
     * 禁用
     */
    @Update("update fence set status = 1 where fence_id = #{fenceId}")
    int updateFenceOff(@Param("fenceId") Long fenceId);

    /**
     * 回显地图
     */
    @Select("select * from fence where fence_id=#{fenceId}")
    List<Fence> mapShow(@Param("fenceId") Long fenceId);

    /**
     * 查询电子围栏(终版)
     */
    @Select("SELECT * FROM  middle m LEFT JOIN fence f ON m.fence_id = f.fence_id WHERE fence_group_id = #{fenceGroupId}")
    List<Fence> showFenceBound(@Param("fenceGroupId") Long fenceGroupId );


}
