package com.imdroid.secapi.dto;

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 org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface TrafficCardMapper extends BaseMapper<TrafficCard> {

    @Select("select * from traffic_cards where iccid = #{iccid} limit 1")
    TrafficCard findByIccid(String iccid);

    @Update("UPDATE traffic_cards SET " +
            "updatetime = #{updatetime}, " +
            "msisdn = #{msisdn}, " +
            "status = #{status}, " +
            "remaining = #{remaining}, " +
            "total = #{total}, " +
            "used = #{used} " +
            "WHERE iccid = #{iccid}")
    int updateCardInfo(TrafficCard trafficCard);

    @Update("UPDATE traffic_cards SET querystatus = #{querystatus} WHERE iccid = #{iccid}")
    int updateQueryStatus(String iccid,int queryStatus);

    @Update("UPDATE traffic_cards SET " +
            "updatetime = #{updatetime}, " +
            "remaining = #{remaining}, " +
            "total = #{total}, " +
            "used = #{used} " +
            "WHERE iccid = #{iccid} AND iccid IS NOT NULL AND iccid != ''")
    int updateCardTrafficInfo(TrafficCard trafficCard);
}