package com.imdroid.secapi.dto;

import com.github.yulichang.base.MPJBaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface SimCardsMapper extends MPJBaseMapper<SimCard>{
    @Select({"select * from simcards where deviceid = #{deviceId} limit 1"})
    SimCard queryByDeviceId(String deviceId);

    @Select("select * from simcards where iccid = #{iccid} limit 1")
    SimCard queryByIccid(String iccid);

    @Update("UPDATE simcards SET " +
            "updatetime = #{updatetime}, " +
            "msisdn = #{msisdn}, " +
            "status = #{status}, " +
            "remaining = #{remaining}, " +
            "total = #{total}, " +
            "used = #{used} " +
            "WHERE deviceid = #{deviceid}")
    int updateSimCardInfo(SimCard simCard);

    @Update("UPDATE simcards SET " +
            "updatetime = #{updatetime}, " +
            "msisdn = #{msisdn}, " +
            "status = #{status} " +
            "WHERE deviceid = #{deviceid}")
    int updateCardStatusInfo(SimCard simCard);

    @Update("UPDATE simcards SET " +
            "updatetime = #{updatetime}, " +
            "remaining = #{remaining}, " +
            "total = #{total}, " +
            "used = #{used} " +
            "WHERE deviceid = #{deviceid}")
    int updateCardTrafficInfo(SimCard simCard);
}

