package com.prolog.cs.biz.inbound.utils;

import com.prolog.framework.authority.core.dto.UserDTO;
import com.prolog.framework.authority.user.UserTemplate;
import com.prolog.framework.utils.AssertUtils;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
public class UserUtils {

	@Resource
	private UserTemplate template;

	public String getEnterpriseId() {
		return getUserDTO().getEnterpriseId();
	}

	public String getEnterpriseId(UserDTO userDTO) {
		return userDTO.getEnterpriseId();
	}

	public String getUserId() {
		return getUserDTO().getId();
	}

	public String getUserId(UserDTO userDTO) {
		return userDTO.getId();
	}

	public String getUserName() {
		return getUserDTO().getUsername();
	}

	public String getUserName(UserDTO userDTO) {
		return userDTO.getEnterpriseId();
	}

	public UserDTO getUserDTO() {
		UserDTO userDTO = null;
		userDTO = new UserDTO();
//		int nextInt = new Random().nextInt(2); // 0和1随机
//		int nextInt = 1;
//		String val = String.valueOf(nextInt);
//		userDTO.setEnterpriseId("1");
//		userDTO.setUsername(val);
//		userDTO.setId(val);
		userDTO = template.getUserDTO();
		AssertUtils.notNull(userDTO, "用户信息为空!");

		return userDTO;
	}

}
