package cn.axzo.msg.center.domain.entity;

import cn.axzo.msg.center.api.custombutton.ProposedButtons;
import cn.axzo.msg.center.service.enums.BizCategoryEnum;
import cn.axzo.msg.center.service.enums.BizFinalStateEnum;
import cn.axzo.msg.center.service.enums.IdentityTypeEnum;
import cn.axzo.msg.center.service.enums.OrganizationTypeEnum;
import cn.axzo.msg.center.service.enums.PendingMessageStateEnum;
import cn.axzo.msg.center.service.enums.TodoType;
import cn.axzo.msg.center.service.enums.YesOrNo;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.StringUtils;

import java.util.Date;

/**
 * 尽可能地使用已经存在的方法, 减少工作量
 *
 * @author yanglin
 */
public interface PendingRecordAdapter {

    String getIdentityCode();

    String getRequestNo();

    Long getPromoterId();

    Long getPromoterPersonId();

    String getPromoterName();

    IdentityTypeEnum getPromoterType();

    Long getExecutorId();

    Long getExecutorPersonId();

    String getExecutorName();

    IdentityTypeEnum getExecutorType();

    String getTemplateCode();

    String getTitle();

    String getContent();

    OrganizationTypeEnum getOrgType();

    Long getOrgId();

    String getOrgName();

    Long getOuId();

    PendingMessageStateEnum getState();

    BizCategoryEnum getBizCategory();

     String getBizCode();

    String getSubBizCode();

    String getBizDesc();

    String getBizFlag();

    String getBizExtParam();

    String getRouterParams();

    BizFinalStateEnum getBizFinalState();

    Date getDeadline();

    Integer getRetryCount();

    Date getHideUntil();

    PendingRecordExt getRecordExt();

    YesOrNo getIsOuIdMigrated();

    Date getCreateAt();

    Date getUpdateAt();

    default TodoType getTodoType() {
        return TodoType.EXECUTABLE;
    }

    default Boolean isRead() {
        return null;
    }

    default Long getPromoterOrgId() {
        return 0L;
    }

    default OrganizationTypeEnum getPromoterOrgType() {
        return null;
    }

    default OrganizationTypeEnum getExecutorOrgType() {
        return null;
    }

    default String getPromoterOrgName() {
        return "";
    }

    default Long getPromoterOuId() {
        return 0L;
    }

    default Todo getTodo() {
        return null;
    }

    default TodoBusiness getTodoBusiness() {
        return null;
    }

    default ProposedButtons getCustomButtons() {
        return null;
    }

    default JSONObject getBizExtParamObj() {
        return parseJsonObj(getBizExtParam());
    }

    default JSONObject getRouterParamObj() {
        return parseJsonObj(getRouterParams());
    }

    static JSONObject parseJsonObj(String json) {
        return StringUtils.isBlank(json) ? new JSONObject() : JSON.parseObject(json);
    }

}