package com.bocloud.ims.service.resource;

import com.bocloud.common.model.BocloudResult;
import com.bocloud.ims.entity.resource.ObjectRelation;
import com.bocloud.ims.interfaces.resource.ObjectRelationService;
import com.bocloud.ims.repository.resource.ObjectRelationRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 资源关系抽象service实现
 *
 * @author wangyu
 * @Version 1.0
 * @since 2017年7月6日
 */
@Service("objectRelationService")
public class ObjectRelationServiceImpl implements ObjectRelationService {

	private static Logger logger = LoggerFactory.getLogger(ObjectRelationServiceImpl.class);
	@Autowired
	private ObjectRelationRepository objectRelationRepository;

	@Override
	public BocloudResult<List<ObjectRelation>> list() {
		try {
			List<ObjectRelation> relations = objectRelationRepository.list();
			return new BocloudResult<>(true, relations, "查询成功");
		} catch (Exception e) {
			logger.error("Get error message：{}", e.getMessage());
			return new BocloudResult<>(false, e.getMessage());
		}
	}
}
