package com.yem.wm.bc.change.common.pojo;

import com.yem.wm.bc.common.CommonUtils;

import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;

/**
 * @author 夜子
 * @ClassName ChangeResumeLogInfo
 * @description: TODO
 * @date 2023年08月10日
 * @version: 1.0
 */
public class ChangeResumeLogInfo {
    public static final String key_Id = "k";
    public static final String key_Name = "n";
    public static final String key_Flag = "f";
    public static final String key_Line = "l";
    public String keyId;
    public String keyName;
    public String keyFlag;
    public String keyLine;
    public ChangeResumeLogFieldInfo logFieldInfo;
    public String key_caption;
    LinkedHashMap<String, Object> linkedHashMap = new LinkedHashMap();

    public ChangeResumeLogInfo() {
    }

    public ChangeResumeLogFieldInfo getLogFieldInfo() {
        return this.logFieldInfo;
    }

    public void setLogFieldInfo(String flag, ChangeResumeLogFieldInfo logFieldInfo) {
        this.logFieldInfo = logFieldInfo;
        this.linkedHashMap.put(flag, logFieldInfo.fieldFormatJson());
    }

    public String getKey_caption() {
        return this.key_caption;
    }

    public void setKey_caption(String key_caption) {
        this.key_caption = key_caption;
    }

    public String getKeyId() {
        return this.keyId;
    }

    public void setKeyId(String keyId) {
        this.keyId = keyId;
    }

    public String getKeyName() {
        return this.keyName;
    }

    public void setKeyName(String keyName) {
        this.keyName = keyName;
    }

    public String getKeyFlag() {
        return this.keyFlag;
    }

    public void setKeyFlag(String keyFlag) {
        this.keyFlag = keyFlag;
    }

    public String getKeyLine() {
        return this.keyLine;
    }

    public void setKeyLine(String keyLine) {
        this.keyLine = keyLine;
    }

    public String formatJson() {
        StringBuilder json = new StringBuilder();
        if (CommonUtils.isNull(this.keyId)) {
            json.append("\"").append("k").append("\":\"").append("\",");
        } else {
            json.append("\"").append("k").append("\":\"").append(this.keyId).append("\",");
        }

        if (CommonUtils.isNull(this.keyName)) {
            json.append("\"").append("n").append("\":\"").append("\",");
        } else {
            json.append("\"").append("n").append("\":\"").append(this.keyName).append("\",");
        }

        if (CommonUtils.isNull(this.keyFlag)) {
            json.append("\"").append("f").append("\":\"").append("\",");
        } else {
            json.append("\"").append("f").append("\":\"").append(this.keyFlag).append("\",");
        }

        if (CommonUtils.isNull(this.keyLine)) {
            json.append("\"").append("l").append("\":\"").append("\",");
        } else {
            json.append("\"").append("l").append("\":\"").append(this.keyLine).append("\",");
        }

        if (this.linkedHashMap.size() > 0) {
            Iterator var2 = this.linkedHashMap.entrySet().iterator();

            while(var2.hasNext()) {
                Map.Entry<String, Object> entry = (Map.Entry)var2.next();
                if (entry.getValue() != null) {
                    json.append("\"").append((String)entry.getKey()).append("\":").append(entry.getValue()).append(",");
                } else {
                    json.append("\"").append((String)entry.getKey()).append("\":").append(",");
                }
            }
        }

        if (json.length() > 0) {
            json = new StringBuilder(json.substring(0, json.length() - 1));
        }

        return "{" + json + "}";
    }

    public String formatJson(String field) {
        return this.key_caption != null ? "\"" + this.key_caption + "\":[" + field + "]" : field;
    }
}
