package com.nokia.vo;

import java.util.ArrayList;
import java.util.List;

import com.nokia.pojo.User;

import lombok.Data;

/**
 * 黑点库用户信息
 */
@Data
public class HeidiankuUserVo {
    // 登陆名
    private String loginName;
    // 用户姓名
    private String userName;
    // 省
    private String province;
    // 归属地市
    private String belongCity;
    // 赋权地市
    private String city;
    // 赋权信息
    private List<String> roles;

    public HeidiankuUserVo(User userEntity) {
        this.loginName = userEntity.getLoginName();
        this.userName = userEntity.getUserName();
        this.province = userEntity.getProvince().getAreaName();
        this.belongCity = userEntity.getCity().getAreaName();
        List<String> roles = new ArrayList<>();
        userEntity.getRoles().forEach(role -> {
            if ("heidianku".equals(role.getSystem())) {
                roles.add(role.getRoleName());
                this.city = role.getCities().get(0).getAreaName();
            }
        });
        this.roles = roles;
    }
}
