package org.cmh.backend.UserManagement.adpter;

import org.cmh.backend.UserManagement.model.User;
import org.cmh.backend.authentication.model.UserHS;

import java.util.List;
import java.util.stream.Collectors;

public class UserHS2User {
    public static User convert(UserHS userHS) {
        User user = new User();
        user.setId(userHS.getId());
        user.setAccount(userHS.getUsername());
        user.setPassword(userHS.getPassword());
        user.setName(userHS.getNickname());
        user.setOrganization(userHS.getDepartment());
        user.setGender(userHS.getGender());
        user.setEmail(userHS.getEmail());
        user.setPhone(userHS.getPhoneNumber());
        return user;
    }
    //不确定这个能不能用XD
    public static List<User> convertList(List<UserHS> userHSList) {
        return userHSList.stream()
                .map(UserHS2User::convert)
                .collect(Collectors.toList());
    }
}
