package com.lion.lionwebsite.Dao.normal;

import com.lion.lionwebsite.Domain.SubBind;
import com.lion.lionwebsite.Domain.SubUpdateRecord;
import org.apache.ibatis.annotations.*;

import java.util.ArrayList;

@Mapper
public interface SubMapper {
    @Insert("insert into sub_bind values (#{key}, #{user})")
    void insertSubBind(SubBind subBind);

    @Select("select * from sub_bind")
    ArrayList<SubBind> selectAllSubBind();

    @Select("select * from sub_bind where key=#{key}")
    SubBind selectSubBind(String key);

    @Select("select count(key) from sub_bind where key=#{key}")
    boolean selectSubBindExist(String key);

    @Select("select count(user) from sub_update_record where user=#{user}")
    Integer selectUpdateRecordCount(String user);

    @Select("select min(id) from sub_update_record where user=#{user}")
    Integer selectMinUpdateRecordId(String user);

    @Delete("delete from sub_bind where user=#{user}")
    void deleteSubBind(String user);

    @Insert("insert into sub_update_record (user, ip, UA, time, location) values (#{user}, #{ip}, #{UA}, #{time}, #{location})")
    void insertSubUpdateRecord(SubUpdateRecord subUpdateRecord);

    @Select("select * from sub_update_record")
    ArrayList<SubUpdateRecord> selectAllSubUpdateRecord();

    @Delete("delete from sub_update_record where user=#{user}")
    void deleteSubUpdateRecord(String user);

    @Delete("delete from sub_update_record where id=#{id}")
    void deleteSubUpdateRecordById(int id);
}
