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

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.uas.platform.b2b.dao.CommonDao;
import com.uas.platform.b2b.dao.FlowNodeDao;
import com.uas.platform.b2b.model.FlowNode;
import com.uas.platform.b2b.service.ApprovalFlowService;

@Service
public class ApprovalFlowServiceImpl implements ApprovalFlowService {

	@Autowired
	private FlowNodeDao flowNodeDao;

	@Autowired
	private CommonDao commonDao;

	@Override
	public Integer getMaxNodeByEnuuAndAppName(Long enuu, String appName) {
		String sql = "select max(fn_nodelev) from office$flownode where fn_enuu = " + enuu + " and fn_appname = '"
				+ appName + "'";
		Integer maxNode = commonDao.queryForObject(sql, Integer.class);
		return maxNode;
	}

	@Override
	public FlowNode getNodeInfoByEnuuAndAppNameAndNodelev(Long enuu, String appName, Integer level) {
		return flowNodeDao.findByEnuuAndAppnameAndNodelev(enuu, appName, level);
	}

	@Override
	public FlowNode getNodeInfoByEnuuAndEmcodeAndAppName(Long enuu, Long emcode, String appName) {
		return flowNodeDao.getNodeInfoByEnuuAndEmcodeAndAppname(enuu, emcode, appName);
	}

}
