package com.muyu.domain;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.muyu.common.core.web.domain.BaseEntity;
import com.muyu.common.system.domain.SysUser;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;

import java.util.Date;

/**
 * @Author：杨鹏
 * @Package：com.muyu.domain
 * @Project：cloud-vehicle
 * @name：FirmUser
 * @Date：2024/10/8 18:59
 */
@EqualsAndHashCode(callSuper = true)
@Data
@SuperBuilder
@AllArgsConstructor
@NoArgsConstructor
@TableName("sys_user")
@Tag(name = "企业用户")
public class FirmUser extends BaseEntity {

    /**
     * 用户ID
     */
    @Schema(name = "用户ID")
    @TableId(type = IdType.AUTO)
    private Long userId;
    /**
     * 部门ID
     */
    @Schema(name = "部门ID")
    private Long deptId;
    /**
     * 用户账号
     */
    @Schema(name = "用户账号")
    private String userName;
    /**
     * 用户昵称
     */
    @Schema(name = "用户昵称")
    private String nickName;
    /**
     * 用户类型（00系统用户）
     */
    @Schema(name = "用户类型（00系统用户）")
    private String userType;
    /**
     * 用户邮箱
     */
    @Schema(name = "用户邮箱")
    private String email;
    /**
     * 手机号码
     */
    @Schema(name = "手机号码")
    private String phonenumber;
    /**
     * 用户性别（0男 1女 2未知）
     */
    @Schema(name = "用户性别（0男 1女 2未知）")
    private String sex;
    /**
     * 头像地址
     */
    @Schema(name = "头像地址")
    private String avatar;
    /**
     * 密码
     */
    @Schema(name = "密码")
    private String password;
    /**
     * 帐号状态（0正常 1停用）
     */
    @Schema(name = "帐号状态（0正常 1停用）")
    private String status;
    /**
     * 删除标志（0代表存在 2代表删除）
     */
    @Schema(name = "删除标志（0代表存在 2代表删除）")
    private String delFlag;
    /**
     * 最后登录IP
     */
    @Schema(name = "最后登录IP")
    private String loginIp;
    /**
     * 最后登录时间
     */
    @Schema(name = "最后登录时间")
    private Date loginDate;

    public static FirmUser builderFirmUser(SysUser sysUser) {
        return FirmUser.builder()
                .userId(sysUser.getUserId())
                .deptId(sysUser.getDeptId())
                .userType(sysUser.getUserType())
                .userName(sysUser.getUserName())
                .nickName(sysUser.getNickName())
                .email(sysUser.getEmail())
                .phonenumber(sysUser.getPhonenumber())
                .sex(sysUser.getSex())
                .avatar(sysUser.getAvatar())
                .password(sysUser.getPassword())
                .status(sysUser.getStatus())
                .delFlag(sysUser.getDelFlag())
                .loginIp(sysUser.getLoginIp())
                .loginDate(sysUser.getLoginDate())
                .createBy(sysUser.getCreateBy())
                .createTime(sysUser.getCreateTime())
                .updateBy(sysUser.getUpdateBy())
                .updateTime(sysUser.getUpdateTime())
                .remark(sysUser.getRemark())
                .build();
    }
    public static SysUser builderSysUser(FirmUser sysUser) {
        return SysUser.builder()
                .userId(sysUser.getUserId())
                .deptId(sysUser.getDeptId())
                .userName(sysUser.getUserName())
                .userType(sysUser.getUserType())
                .nickName(sysUser.getNickName())
                .email(sysUser.getEmail())
                .phonenumber(sysUser.getPhonenumber())
                .sex(sysUser.getSex())
                .avatar(sysUser.getAvatar())
                .password(sysUser.getPassword())
                .status(sysUser.getStatus())
                .delFlag(sysUser.getDelFlag())
                .loginIp(sysUser.getLoginIp())
                .loginDate(sysUser.getLoginDate())
                .createBy(sysUser.getCreateBy())
                .createTime(sysUser.getCreateTime())
                .updateBy(sysUser.getUpdateBy())
                .updateTime(sysUser.getUpdateTime())
                .remark(sysUser.getRemark())
                .build();
    }
}
