package cn.reghao.bnt.web.admin.model.vo;

import cn.reghao.jutil.jdk.converter.DateTimeConverter;
import cn.reghao.jutil.jdk.web.result.NotAvailable;
import cn.reghao.bnt.web.admin.model.po.User;
import lombok.Data;

/**
 * @author reghao
 * @date 2021-07-14 10:28:47
 */
@Data
public class UserVO {
    private Integer userId;
    private String username;
    private String createTime;
    private int sessionCount;
    private String lastAccess;
    private String status;
    private int roleCount;

    public UserVO(User user) {
        this.userId = user.getId();
        this.username = user.getUsername();
        this.createTime = DateTimeConverter.format(user.getCreateTime());
        this.sessionCount = 0;
        this.lastAccess = NotAvailable.na.getDesc();
        this.status = !user.getDeleted() ? "使用中" : "已删除";
        this.roleCount = user.getRole().size();
    }
}
