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.ValidRule;
import com.njzscloud.supervisory.user.contant.Gender;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Accessors;

import java.util.List;

@Getter
@Setter
@ToString
@Accessors(chain = true)
public class UserRegisterParam implements Constrained {

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

    /**
     * 头像
     */
    private String avatar;

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

    /**
     * 账号信息
     */
    private Account account;
    /**
     * 公司信息
     */
    private Company company;


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

    @Getter
    @Setter
    @ToString
    @Accessors(chain = true)
    public static class Account implements Constrained {
        /**
         * 邮箱
         */
        private String email;

        /**
         * 手机号
         */
        private String phone;

        /**
         * 用户名
         */
        private String username;

        /**
         * 密码
         */
        private String secret;

        @Override
        public ValidRule[] rules() {
            return new ValidRule[]{
                    ValidRule.of(() -> StrUtil.isNotBlank(username), "用户名不能为空"),
                    ValidRule.of(() -> StrUtil.isNotBlank(secret), "密码不能为空"),
            };
        }
    }

    @Getter
    @Setter
    @ToString
    @Accessors(chain = true)
    public static class Company implements Constrained {
        /**
         * 企业名称
         */
        private String companyName;

        /**
         * 统一社会信用代码; biz_company.uscc
         */
        private String uscc;

        /**
         * 营业执照; 图片
         */
        private String businessLicense;

        /**
         * 资质证明; 图片
         */
        private String certification;

        /**
         * 营业执照有效期; [开始日期，结束日期]
         */
        private List<String> businessLicenseDate;

        /**
         * 资质证明有效期; [开始日期，结束日期]
         */
        private List<String> certificationDate;

        /**
         * 法人名称
         */
        private String legalRepresentative;

        /**
         * 省; 名称
         */
        private String province;

        /**
         * 市; 名称
         */
        private String city;

        /**
         * 区; 名称
         */
        private String county;

        /**
         * 详细地址
         */
        private String address;

        /**
         * 联系人
         */
        private String contacts;

        /**
         * 联系电话
         */
        private String phoneNum;

        /**
         * 服务范围
         */
        private List<Scope> scopeList;

        @Override
        public ValidRule[] rules() {
            return new ValidRule[]{};
        }
    }


    @Getter
    @Setter
    @ToString
    @Accessors(chain = true)
    public static class Scope implements Constrained {
        /**
         * 省; 名称
         */
        private String province;

        /**
         * 市; 名称
         */
        private String city;

        /**
         * 区; 名称
         */
        private String county;

        /**
         * 街道; 名称
         */
        private String street;

        @Override
        public ValidRule[] rules() {
            return new ValidRule[]{};
        }
    }


}
