package com.yuchen.saas.park.api.commons.domain;

import com.yuchen.saas.park.api.commons.enums.DoorAccessControlConfigType;
import lombok.Data;

import javax.annotation.Nullable;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Positive;

@Data(staticConstructor = "of")
public class DoorAccessControlConfigIssueTaskContext {
    private final DoorAccessControlConfigTarget target;
    private final DoorAccessControlConfigEntry entry;
    @Nullable
    private final String configValue;
    private final boolean disabled;

    public static DoorAccessControlConfigIssueTaskContext of(DoorAccessControlConfigTarget target, DoorAccessControlConfigEntry entry, String configValue) {
        return of(target, entry, configValue, false);
    }

    public static DoorAccessControlConfigIssueTaskContext ofUser(DoorAccessControlConfigTarget target, @Positive long configId, @NotBlank String configNo, boolean disabled) {
        return of(target, DoorAccessControlConfigEntry.of(DoorAccessControlConfigType.USER, configId), String.valueOf(configNo), disabled);
    }

    public static DoorAccessControlConfigIssueTaskContext ofCard(DoorAccessControlConfigTarget target, @Positive long configId, @NotBlank String no) {
        return DoorAccessControlConfigIssueTaskContext.of(target, DoorAccessControlConfigEntry.of(DoorAccessControlConfigType.CARD, configId), no);
    }

    public static DoorAccessControlConfigIssueTaskContext ofFacial(DoorAccessControlConfigTarget target, @NotBlank String facial) {
        return DoorAccessControlConfigIssueTaskContext.of(target, DoorAccessControlConfigEntry.of(DoorAccessControlConfigType.FACIAL, target.getUserId()), facial);
    }
}
