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

import cn.hutool.core.util.StrUtil;
import com.njzscloud.common.mvc.validator.Constrained;
import com.njzscloud.common.mvc.validator.ValidRule;
import com.njzscloud.dispose.sys.user.constant.Gender;
import jakarta.validation.Valid;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Accessors;

import java.util.Set;

@Getter
@Setter
@ToString
@Accessors(chain = true)
public class AddUserParam implements Constrained {
    /**
     * 昵称
     */
    private String nickname;
    /**
     * 邮箱
     */
    private String email;
    /**
     * 手机号
     */
    private String phone;
    /**
     * 头像
     */
    private String avatar;

    /**
     * 性别; 字典代码：gender
     */
    private Gender gender;
    /**
     * 账号信息
     */
    @Valid
    private AddUserAccountParam account;
    /**
     * 角色 Id 列表
     */
    private Set<Long> roles;

    @Override
    public ValidRule[] rules() {
        return new ValidRule[]{
            ValidRule.of(() -> StrUtil.isNotBlank(nickname), "用户昵称不能为空"),
            ValidRule.of(() -> account != null, "账号信息不能为空"),
        };
    }
}
