package com.malk.server.h3yun;

import lombok.Data;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

@Data
@Component
@ConfigurationProperties(prefix = "h3yun")
@Slf4j
public class CYConf {

    private String engineCode;

    private String secret;
    
    /////////////////////////////// 静态方法 ///////////////////////////////

    // 按钮动作
    public enum ACTION_NAME {

        Reject("Reject"),                   // 拒绝
        Save("Save"),                       // 暂存
        Forward("Forward"),                 // 转交
        Remove("Remove"),                   // 删除
        Submit("Submit"),                   // 提交/同意 [区分是否审批节点]
        ForComment("ForComment"),           // 前加签
        TempAddition("TempAddition"),       // 后加签
        CancelInstance("CancelInstance");    // 作废 [退回不触发, 退回至发起节点, 可激活作废按钮]

        @Getter
        private String desc;

        ACTION_NAME(String desc) {
            this.desc = desc;
        }
    }

    public static boolean isSubmit(String actionName) {
        return actionName.equals(ACTION_NAME.Submit.desc);
    }

    public static boolean isReject(String actionName) {
        return actionName.equals(ACTION_NAME.Reject.desc);
    }

    public static boolean isRemove(String actionName) {
        return actionName.equals(ACTION_NAME.Remove.desc);
    }

    /**
     * 获取原附件预览地址 [只能作为在线预览, 接口传递无登录态]
     */
    public static final String getAttachmentPreviewUrl(String attachmentId) {
        return "https://www.h3yun.com/Form/DoPreview/?attachmentId=" + attachmentId;
    }
}
