package com.nanometer.smartlab.service; import com.nanometer.smartlab.dao.BaseMetaGroupDao; import com.nanometer.smartlab.entity.BaseMetaGroup; import com.nanometer.smartlab.exception.BusinessException; import com.nanometer.smartlab.exception.ExceptionEnumCode; import com.nanometer.smartlab.util.MessageUtil; import org.apache.log4j.Logger; import org.springframework.dao.DataAccessException; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.util.List; /** * Created by johnny on 17/8/21. */ @Service("baseMetaGroupService") public class BaseMetaGroupServiceImpl implements BaseMetaGroupService { private static Logger logger = Logger.getLogger(BaseMetaGroupService.class); @Resource(name = "baseMetaGroupDao") BaseMetaGroupDao baseMetaGroupDao; @Transactional(propagation = Propagation.REQUIRED) public List getBaseMetaGroupList() { try { return baseMetaGroupDao.getBaseMetaGroupList(); } catch (DataAccessException ex) { logger.error(ex.getMessage(), ex); throw new BusinessException(ExceptionEnumCode.DB_ERR, MessageUtil.getMessageByCode(ExceptionEnumCode.DB_ERR.getCode()), ex); } } @Override public BaseMetaGroup getBaseMetaGroupByCode(String code) { return baseMetaGroupDao.getBaseMetaGroupByCode(code); } }