package org.example.Entity.System;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;

import java.io.Serializable;
import java.util.Map;

@JsonInclude(JsonInclude.Include.NON_NULL)
public class LoginUserInfo  {
    private static final long serialVersionUID = 1L; // 显式添加序列化ID

    // 字段保持不变
    public String UserId = "0";
    public String UserName;
    public String UserCode;
    public String SeriesId;
    public Integer ServerId = 0;
    @JsonIgnore
    public String DepCode;
    @JsonIgnore
    public String RoleId;
    @JsonIgnore
    public String RoleIds;
    @JsonIgnore
    public String InPwd = "";
    //新增
    @JsonIgnore
    public Boolean IsWeekPwd;
    @JsonIgnore
    public String PurviewStr;
    @JsonIgnore
    public String Pwd;
    @JsonIgnore
    public String ConnectionString;
    @JsonIgnore
    public String ProviderName;
    @JsonInclude(JsonInclude.Include.NON_NULL)
    @JsonProperty("Other")
    public Map<String, Object> Other;
    @JsonInclude(JsonInclude.Include.NON_NULL)
    @JsonProperty("AppIndex")
    public String AppIndex;
    @JsonIgnore
    public Object AttacInfo;
    @JsonIgnore
    public Integer LoginType;
    public Integer ClientId;
    public Integer AttendanceTime;
    @JsonIgnore
    public Boolean IsClientUser = false;
    @JsonIgnore
    public String Token;
    @JsonIgnore
    public String LoginOs;
    @JsonIgnore
    public Boolean FromToken;

    // 1. 添加显式无参构造函数（Jackson 序列化必需）
    public LoginUserInfo() {}

    // 2. 添加所有非 @JsonIgnore 字段的 getter 方法（Jackson 读取字段用）
    public String getUserId() {
        return UserId;
    }

    public String getUserName() {
        return UserName;
    }

    public String getUserCode() {
        return UserCode;
    }

    public String getSeriesId() {
        return SeriesId;
    }

    public Integer getServerId() {
        return ServerId;
    }

    public Map<String, Object> getOther() {
        return Other;
    }

    public String getAppIndex() {
        return AppIndex;
    }

    public Integer getClientId() {
        return ClientId;
    }

    public Integer getAttendanceTime() {
        return AttendanceTime;
    }

    // 3. 保留原有的 getRoleIds 方法（无需修改）
    @JsonIgnore
    public String[] getRoleIds() {
        if (RoleId == null) {
            return new String[0];
        }
        return RoleId.split(",");
    }
}