package cn.axzo.workflow.core.conf;

import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;

/**
 * 支持动态刷新配置属性
 *
 * @author wangli
 * @since 2024/5/15 15:07
 */
@Component
@Data
@RefreshScope
public class SupportRefreshProperties {
    @Value("${workflow.apiLog.enable: false}")
    private Boolean apiLogEnable;

    @Value("${workflow.mqLog.enable: false}")
    private Boolean mqLogEnable;

    @Value("${workflow.apiLog.filterApiType:}")
    private String filterApiType;

    @Value("${workflow.api.timeout:10}")
    private Long apiTimeout;
    @Value("${workflow.mock:false}")
    private Boolean mock;
    @Value("${workflow.assignee.global:true}")
    private Boolean global;
    @Value("${workflow.assignee.key:''}")
    private String key;
    @Value("#{${workflow.assignee.map:{}}}")
    private Map<String, String> assigneeMap;

    @Value(value = "${workflow.alter.enable:false}")
    private Boolean alterEnable;
    /**
     * 节点卡住多久才告警，单位分钟
     */
    @Value("${workflow.alter.pauseDelay:30}")
    private Integer pauseDelay;
    /**
     * 业务节点暂停告警的次数, 0代表无限制
     */
    @Value(value = "${workflow.alter.retries:1}")
    private Integer alterRetries;

    /**
     * 业务节点任务执行间隔
     */
    @Value(value = "${workflow.alter.interval:60}")
    private Integer alterInterval;

    /**
     * 业务节点任务执行间隔的时间单位
     * SECONDS/HOURS/MINUTES 支持的几种单位
     */
    @Value(value = "${workflow.alter.intervalUnit:seconds}")
    private TimeUnit alterIntervalUnit;

    @Value(value = "${workflow.alter.mobiles:}")
    private List<String> alterMobiles;

    /**
     * 是否允许重复告警
     */
    @Value(value = "${workflow.alter.repeat:false}")
    private Boolean repeatAlter;

    @Value(value = "${workflow.alter.sendDingTalk:true}")
    private Boolean alterSendDingTalk;

    /**
     * 用于控制转交管理员的 API
     */
    @Value("${workflow.useNewToAdminApi:false}")
    private Boolean useNewToAdminApi;

    @Value("${workflow.sendDingTalk:true}")
    private Boolean sendDingTalk;

    @Value("${workflow.esSyncBatchSize:10}")
    private Integer esSyncBatchSize;

    @Value("${workflow.imTemplateCode:}")
    private String imTemplateCode;

}
