package shop.alien.gateway.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import shop.alien.entity.second.LifeUserLog;

import java.util.List;

@Mapper
public interface LifeUserLogGatewayMapper extends BaseMapper<LifeUserLog> {

    /**
     * 查询时间段内同一个macip地址的登录记录
     *
     * @param starDate 开始日期
     * @param endDate 结束日期
     * @return 同一个macip地址的登录记录
     */
    @Select("SELECT user_id, user_name, mac_ip FROM life_user_log " +
            " WHERE created_time BETWEEN DATE_FORMAT(#{starDate}, '%Y-%m-%d %H:%i:%s') " +
            " AND DATE_FORMAT(#{endDate}, '%Y-%m-%d %H:%i:%s') AND mac_ip = #{macIp} " +
            " GROUP BY user_id, user_name, mac_ip ")
    List<LifeUserLog> getLifeUserLogByDate(@Param("starDate") String starDate, @Param("endDate") String endDate, @Param("macIp") String macIp);

}