package ink.wgink.pojo.bos;

import ink.wgink.pojo.pos.DepartmentPO;
import ink.wgink.pojo.pos.GroupPO;
import ink.wgink.pojo.pos.PositionPO;
import ink.wgink.pojo.pos.RolePO;

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

/**
 * @ClassName: UserInfoBO
 * @Description: 用户
 * @Author: WangGeng
 * @Date: 2019/3/24 11:03 PM
 * @Version: 1.0
 **/
public class UserInfoBO {

    private String userId;
    private String userUsername;
    private String userName;
    private String userPhone;
    private String userAvatar;
    private String userEmail;
    private String dataRight;
    private List<String> dataUserIds;
    private List<String> rootDepartmentIds;
    private List<DepartmentPO> departments;
    private List<RolePO> roles;
    private List<GroupPO> groups;
    private List<PositionPO> positions;
    private String roleIdAndNamesValue;
    private String groupIdAndNamesValue;
    private String departmentIdAndNamesValue;
    private String positionIdAndNamesValue;
    private Object expandData;

    public String getUserId() {
        return userId == null ? "" : userId.trim();
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public String getUserUsername() {
        return userUsername == null ? "" : userUsername.trim();
    }

    public void setUserUsername(String userUsername) {
        this.userUsername = userUsername;
    }

    public String getUserName() {
        return userName == null ? "" : userName.trim();
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getUserPhone() {
        return userPhone == null ? "" : userPhone.trim();
    }

    public void setUserPhone(String userPhone) {
        this.userPhone = userPhone;
    }

    public String getUserAvatar() {
        return userAvatar == null ? "" : userAvatar;
    }

    public void setUserAvatar(String userAvatar) {
        this.userAvatar = userAvatar;
    }

    public String getUserEmail() {
        return userEmail == null ? "" : userEmail;
    }

    public void setUserEmail(String userEmail) {
        this.userEmail = userEmail;
    }

    public String getDataRight() {
        return dataRight == null ? "" : dataRight.trim();
    }

    public void setDataRight(String dataRight) {
        this.dataRight = dataRight;
    }

    public List<String> getDataUserIds() {
        return dataUserIds == null ? new ArrayList<>(0) : dataUserIds;
    }

    public void setDataUserIds(List<String> dataUserIds) {
        this.dataUserIds = dataUserIds;
    }

    public List<String> getRootDepartmentIds() {
        return rootDepartmentIds == null ? new ArrayList<>(0) : rootDepartmentIds;
    }

    public void setRootDepartmentIds(List<String> rootDepartmentIds) {
        this.rootDepartmentIds = rootDepartmentIds;
    }

    public List<DepartmentPO> getDepartments() {
        return departments == null ? new ArrayList<>(0) : departments;
    }

    public void setDepartments(List<DepartmentPO> departments) {
        this.departments = departments;
        if (departments == null || departments.isEmpty()) {
            return;
        }
        StringBuilder idSB = new StringBuilder();
        StringBuilder nameSB = new StringBuilder();
        departments.forEach(departmentBO -> {
            if (idSB.length() > 0) {
                idSB.append(",");
                nameSB.append(",");
            }
            idSB.append(departmentBO.getDepartmentId());
            nameSB.append(departmentBO.getDepartmentName());
        });
        this.departmentIdAndNamesValue = idSB.append("|").append(nameSB).toString();
    }

    public List<RolePO> getRoles() {
        return roles == null ? new ArrayList<>(0) : roles;
    }

    public void setRoles(List<RolePO> roles) {
        this.roles = roles;
        if (roles == null || roles.isEmpty()) {
            return;
        }
        StringBuilder idSB = new StringBuilder();
        StringBuilder nameSB = new StringBuilder();
        roles.forEach(roleBO -> {
            if (idSB.length() > 0) {
                idSB.append(",");
                nameSB.append(",");
            }
            idSB.append(roleBO.getRoleId());
            nameSB.append(roleBO.getRoleName());
        });
        this.roleIdAndNamesValue = idSB.append("|").append(nameSB).toString();
    }

    public List<GroupPO> getGroups() {
        return groups == null ? new ArrayList<>(0) : groups;
    }

    public void setGroups(List<GroupPO> groups) {
        this.groups = groups;
        if (groups == null || groups.isEmpty()) {
            return;
        }
        StringBuilder idSB = new StringBuilder();
        StringBuilder nameSB = new StringBuilder();
        groups.forEach(groupBO -> {
            if (idSB.length() > 0) {
                idSB.append(",");
                nameSB.append(",");
            }
            idSB.append(groupBO.getGroupId());
            nameSB.append(groupBO.getGroupName());
        });
        this.groupIdAndNamesValue = idSB.append("|").append(nameSB).toString();
    }

    public List<PositionPO> getPositions() {
        return positions == null ? new ArrayList<>(0) : positions;
    }

    public void setPositions(List<PositionPO> positions) {
        this.positions = positions;
        if (positions == null || positions.isEmpty()) {
            return;
        }
        StringBuilder idSB = new StringBuilder();
        StringBuilder nameSB = new StringBuilder();
        positions.forEach(positionBO -> {
            if (idSB.length() > 0) {
                idSB.append(",");
                nameSB.append(",");
            }
            idSB.append(positionBO.getPositionId());
            nameSB.append(positionBO.getPositionName());
        });
        this.positionIdAndNamesValue = idSB.append("|").append(nameSB).toString();
    }

    public String getRoleIdAndNamesValue() {
        return roleIdAndNamesValue == null ? "" : roleIdAndNamesValue.trim();
    }

    public String getGroupIdAndNamesValue() {
        return groupIdAndNamesValue == null ? "" : groupIdAndNamesValue.trim();
    }

    public String getDepartmentIdAndNamesValue() {
        return departmentIdAndNamesValue == null ? "" : departmentIdAndNamesValue.trim();
    }

    public String getPositionIdAndNamesValue() {
        return positionIdAndNamesValue == null ? "" : positionIdAndNamesValue.trim();
    }

    public Object getExpandData() {
        return expandData;
    }

    public void setExpandData(Object expandData) {
        this.expandData = expandData;
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder("{");
        sb.append("\"userId\":\"")
                .append(userId).append('\"');
        sb.append(",\"userUsername\":\"")
                .append(userUsername).append('\"');
        sb.append(",\"userName\":\"")
                .append(userName).append('\"');
        sb.append(",\"userPhone\":\"")
                .append(userPhone).append('\"');
        sb.append(",\"userAvatar\":\"")
                .append(userAvatar).append('\"');
        sb.append(",\"userEmail\":\"")
                .append(userEmail).append('\"');
        sb.append(",\"dataRight\":\"")
                .append(dataRight).append('\"');
        sb.append(",\"dataUserIds\":")
                .append(dataUserIds);
        sb.append(",\"rootDepartmentIds\":")
                .append(rootDepartmentIds);
        sb.append(",\"departments\":")
                .append(departments);
        sb.append(",\"roles\":")
                .append(roles);
        sb.append(",\"groups\":")
                .append(groups);
        sb.append(",\"positions\":")
                .append(positions);
        sb.append(",\"roleIdAndNamesValue\":\"")
                .append(roleIdAndNamesValue).append('\"');
        sb.append(",\"groupIdAndNamesValue\":\"")
                .append(groupIdAndNamesValue).append('\"');
        sb.append(",\"departmentIdAndNamesValue\":\"")
                .append(departmentIdAndNamesValue).append('\"');
        sb.append(",\"positionIdAndNamesValue\":\"")
                .append(positionIdAndNamesValue).append('\"');
        sb.append(",\"expandData\":")
                .append(expandData);
        sb.append('}');
        return sb.toString();
    }
}
