package org.example.Entity.System.Audit;

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

import java.util.Map;

import static org.example.Utils.DataTableUtil.get;
import static org.example.Utils.NativeExtensionUtils.ToInt32;
import static org.example.Utils.NativeExtensionUtils.isNullOrEmpty;

public class AuditBase {
    public AuditBase(Map<String, Object> row) {
        super();
        this.row = row;
    }

    protected Map<String, Object> row;

    public Integer getItemId() {
        return ToInt32(get(row, "id", "0"));
    }

    @JsonInclude(JsonInclude.Include.NON_NULL)
    @JsonProperty("TypeCode")
    public String getTypeCode() {
        return (String) get(row, "typecode", "");
    }

    @JsonInclude(JsonInclude.Include.NON_NULL)
    @JsonProperty("StepName")
    public String getStepName() {
        return (String) get(row, "stepname", "");
    }

    @JsonInclude(JsonInclude.Include.NON_NULL)
    @JsonProperty("StepCode")
    public String getStepCode() {
        String _stepCode = get(row, "stepcode", "") + "";
        if (isNullOrEmpty(_stepCode)) return null;
        return _stepCode;
    }

    @JsonInclude(JsonInclude.Include.NON_NULL)
    @JsonProperty("StepGroup")
    public String getStepGroup() {
        return (String) get(row, "StepGroup", "");
    }

    @JsonInclude(JsonInclude.Include.NON_NULL)
    @JsonProperty("ViewUser")
    public String getViewUser() {
        return (String) get(row, "ViewUser", "");
    }

    @JsonInclude(JsonInclude.Include.NON_NULL)
    @JsonProperty("OperUser")
    public String getOperUser() {
        return (String) get(row, "OperUser", "");
    }

    @JsonIgnore
    public String getPStepCode() {
        return (String) get(row, "PStepCode", "");
    }

}