package com.njzscloud.common.sn;

import com.njzscloud.common.mvc.validator.Constrained;
import com.njzscloud.common.mvc.validator.Constraint;
import com.njzscloud.common.mvc.validator.ValidRule;
import jakarta.validation.constraints.NotBlank;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Accessors;

import java.util.HashMap;
import java.util.List;

@Getter
@Setter
@ToString
@Accessors(chain = true)
@Constraint
public class AddSnConfigParam implements Constrained {
    /**
     * 规则名称
     */
    @NotBlank(message = "规则名称不能为空")
    private String snname;
    /**
     * 编码名称; 字典编码：sncode
     */
    @NotBlank(message = "编码名称不能为空")
    private String sncode;

    /**
     * 配置
     */
    private List<HashMap<String, Object>> config;

    /**
     * 备注
     */
    private String memo;

    @Override
    public ValidRule[] rules() {
        return new ValidRule[]{
            ValidRule.of(() -> config != null && !config.isEmpty(), "编码规则不能为空"),
        };
    }
}
