package com.njzscloud.supervisory.user.pojo;

import cn.hutool.core.util.StrUtil;
import com.njzscloud.common.mvc.validator.Constrained;
import com.njzscloud.common.mvc.validator.Constraint;
import com.njzscloud.common.mvc.validator.ValidRule;
import com.njzscloud.supervisory.role.pojo.SysRoleEntity;
import com.njzscloud.supervisory.user.contant.Gender;
import lombok.Getter;
import lombok.Setter;

import javax.validation.constraints.NotNull;
import java.util.List;


@Getter
@Setter
@Constraint
public class UserModifyParam implements Constrained {
    @NotNull
    private Long id;

    /**
     * 昵称
     */
    private String nickname;

    private String avatar;

    /**
     * 性别; 字典代码：gender
     */
    private Gender gender;

    private UserAccountModifyParam account;

    /**
     * 角色 Id 列表
     */
    private List<Long> roleIds;
    private List<SysRoleEntity> roles;

    @Override
    public ValidRule[] rules() {
        return new ValidRule[]{
                ValidRule.of(() -> !(StrUtil.isBlank(nickname) && gender != null), "昵称和性别至少一个有值"),
        };
    }
}
