package com.njzscloud.supervisory.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.supervisory.biz.constant.BizObj;
import com.njzscloud.supervisory.sys.role.pojo.entity.RoleEntity;
import com.njzscloud.supervisory.sys.user.contant.Gender;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Accessors;

import javax.validation.Valid;
import java.util.List;

@Getter
@Setter
@ToString
@Accessors(chain = true)
public class AddUserParam implements Constrained {
    /**
     * 业务对象; 字典代码：biz_obj
     */
    private BizObj bizObj;
    /**
     * 昵称
     */
    private String nickname;
    /**
     * 手机号
     */
    private String phone;
    /**
     * 头像
     */
    private String avatar;

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

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