package com.qmth.themis.business.bean.admin;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.util.Objects;

@ApiModel("报表-考生日志明细返回对象")
public class ExamStudentLogDetailListBean {

    @JsonSerialize(using = ToStringSerializer.class)
    @ApiModelProperty(name = "id")
    private Long id;

    @ApiModelProperty(name = "发生时间")
    private Long createTime;

    @ApiModelProperty(name = "事件类型")
    private String type;

    @ApiModelProperty(name = "详情")
    private String remark;

    @ApiModelProperty(value = "ip地址")
    private String ip;

    @ApiModelProperty(value = "国家")
    private String country;

    @ApiModelProperty(value = "地区")
    private String region;

    @ApiModelProperty(value = "省份")
    private String province;

    @ApiModelProperty(value = "城市")
    private String city;

    @ApiModelProperty(value = "运营商")
    private String isp;

    @ApiModelProperty(value = "ip是否改变")
    private Boolean ipChange;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public IPage<ExamStudentLogDetailListBean> ipChange(IPage<ExamStudentLogDetailListBean> examStudentLogDetailListBeanIPage) {
        String currentIp = examStudentLogDetailListBeanIPage.getRecords().get(0).getIp();
        for (int i = 1; i < examStudentLogDetailListBeanIPage.getRecords().size(); i++) {
            String ip = examStudentLogDetailListBeanIPage.getRecords().get(i).getIp();
            if (Objects.isNull(currentIp) || Objects.equals(currentIp.trim(), "")) {
                currentIp = ip;
                continue;
            } else if (Objects.nonNull(currentIp) && Objects.nonNull(ip) && !Objects.equals(currentIp.trim(), "") && !Objects.equals(currentIp, ip)) {
                examStudentLogDetailListBeanIPage.getRecords().get(i).setIpChange(true);
                currentIp = ip;
            }
        }
        return examStudentLogDetailListBeanIPage;
    }

    public String getIp() {
        return ip;
    }

    public void setIp(String ip) {
        this.ip = ip;
    }

    public String getCountry() {
        return country;
    }

    public void setCountry(String country) {
        this.country = country;
    }

    public String getRegion() {
        return region;
    }

    public void setRegion(String region) {
        this.region = region;
    }

    public String getProvince() {
        return province;
    }

    public void setProvince(String province) {
        this.province = province;
    }

    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    public String getIsp() {
        return isp;
    }

    public void setIsp(String isp) {
        this.isp = isp;
    }

    public Boolean getIpChange() {
        return ipChange;
    }

    public void setIpChange(Boolean ipChange) {
        this.ipChange = ipChange;
    }

    public Long getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Long createTime) {
        this.createTime = createTime;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }


}
