package com.njzscloud.dispose.sys.menu.pojo.param;

import com.njzscloud.common.mvc.validator.Constrained;
import com.njzscloud.common.mvc.validator.Constraint;
import com.njzscloud.common.mvc.validator.ValidRule;
import com.njzscloud.common.security.contant.ClientCode;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;

/**
 * 添加菜单
 */
@Getter
@Setter
@Constraint
@Accessors(chain = true)
public class MenuModifyParam implements Constrained {

    /**
     * Id
     */
    private Long id;
    private ClientCode clientCode;

    /**
     * 上级 Id; 层级为 1 的节点值为 0
     */
    private Long pid;

    /**
     * 菜单名称
     */
    private String title;

    /**
     * 图标
     */
    private String icon;

    /**
     * 排序
     */
    private Integer sort;

    /**
     * 路由名称
     */
    private String routeName;

    @Override
    public ValidRule[] rules() {
        return new ValidRule[]{
            ValidRule.of(() -> id != null, "未知定要修改的菜单"),
            ValidRule.of(() -> pid == null || pid >= 0, "上级 Id 必须大于 0 或不指定"),
        };
    }
}
