package com.engine.organization.entity.extend.param;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Map;

/**
 * @author:dxfeng
 * @createTime: 2022/06/23
 * @version: 1.0
 */
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class ExtendInfoParams {
    /**
     * 操作表对应主键
     */
    private Long id;
    /**
     * 操作表对应的字段
     */
    private String fields;
    /**
     * 操作的表明
     */
    private String tableName;

    /**
     * 参数信息
     */
    private Map<String, Object> params;

    /**
     * Oracle主键自增序列名称
     */
    private String sequenceName;

    public String getSequenceName() {
        // 处理ORACLE表名过长，未与序列对应情况
        String sequenceName;
        switch (this.tableName) {
            case "JCL_ORG_HRMRESOURCE":
                sequenceName = "JCL_ORG_HRM_ID";
                break;
            case "JCL_ORG_HRMRESOURCEEXT_DT1":
                sequenceName = "JCL_ORG_HRMEXT_DT1_ID";
                break;
            case "JCL_FIELD_EXTENDGROUP":
                sequenceName = "JCL_FIELD_GROUP_ID";
                break;
            case "JCL_FIELD_EXTENDTITLE":
                sequenceName = "JCL_FIELD_TITLE_ID";
                break;
            case "JCL_FIELD_EXTENDINFO":
                sequenceName = "JCL_FIELD_INFO_ID";
                break;
            case "JCL_IMPORT_HISTORY_DETAIL":
                sequenceName = "JCL_IMPORT_DETAIL_ID";
                break;
            default:
                sequenceName = this.tableName + "_ID";
                break;
        }
        return sequenceName;
    }
}
