package com.cxyxiaomo.epp.common.vo;

import com.cxyxiaomo.epp.common.pojo.User;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.springframework.beans.BeanUtils;

import java.io.Serializable;
import java.time.LocalDateTime;

// 数据库关系映射

@Data
@NoArgsConstructor
@Accessors(chain = true) // 链式写法
// 微服务必须要实现Serializable
public class UserVO implements Serializable {
    private Integer id;
    private String username;
    private String realname;
    private String idNumber;
    private String phoneNumber;
    private Integer role;
    private String buildingId;
    private String doorplate;
    private String permission;
    private LocalDateTime permissionTime;

    public static UserVO convertFrom(User user) {
        if (user == null) {
            return null;
        }
        UserVO userVO = new UserVO();
        BeanUtils.copyProperties(user, userVO);
        return userVO;
    }
}
