package com.uas.platform.b2b.support;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

import com.uas.platform.b2b.model.Enterprise;
import com.uas.platform.b2b.model.Role;
import com.uas.platform.b2b.model.User;
import com.uas.platform.core.model.Constant;

public class UserCreater {

	private static final long defaultUU = -99999L;

	/**
	 * 创建虚拟用户
	 * 
	 * @param userName
	 * @param ernterprise
	 * @return
	 */
	public static User createVirtual(String userName, Enterprise enterprise, List<Role> roles) {
		User user = new User();
		user.setUserName(userName);
		user.setUserUU(defaultUU);
		user.setEnable(Constant.YES);
		user.setIssys(Constant.YES);

		Set<Enterprise> enterprises = new HashSet<Enterprise>();
		enterprises.add(enterprise);
		user.setEnterprises(enterprises);
		user.setCurrentEnterprise();

		user.setRoles(new HashSet<Role>(roles));

		return user;
	}

	public static boolean isVirtual(User user) {
		return defaultUU == user.getUserUU();
	}

}
