package com.uas.platform.b2b.service.impl;

import com.uas.platform.b2b.dao.*;
import com.uas.platform.b2b.model.*;
import com.uas.platform.b2b.service.EnterpriseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;
import java.util.*;

/**
 * @since 2016-9-26 21:18:35 账户中心统一管理；部分功能保留，但转移到v2目录
 * @see com.uas.platform.b2b.v2.service.impl.EnterpriseServiceImpl
 * 
 */
@Deprecated
@Service
public class EnterpriseServiceImpl implements EnterpriseService {

	@Autowired
	private EnterpriseDao enterpriseDao;

	@Override
	public Enterprise findByenBussinessCode(String enBussinessCode) {
		Enterprise enterprise = enterpriseDao.findEnterpriseByEnBussinessCode(enBussinessCode);
		if (enterprise == null) {
			throw new UsernameNotFoundException("没有找到您的账号 " + enBussinessCode);
		}
		return enterprise;
	}

	@Override
	public Enterprise findByEnUU(Long enUU) {
		return enterpriseDao.findEnterpriseByUu(enUU);
	}

	/**
	 * 通过企业名称查询企业注册信息
	 *
	 * @param name 企业名称
	 * @return
	 */
	@Override
	public List<Enterprise> findByEnName(String name) {
		return enterpriseDao.findByName(name);
	}
}
