package com.palmnest.service.estateserve.impl;

import com.palmnest.dao.estateserve.EnterpriseAuditDao;
import com.palmnest.model.EnterpriseAudit;
import com.palmnest.model.EnterpriseInfo;
import com.palmnest.service.estateserve.EnterpriseAuditManager;
import com.palmnest.service.impl.GenericManagerImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * 企业入驻/企业迁出审批单服务接口实现类
 *
 * @author longmeizhen
 */
@Slf4j
@Service("enterpriseAuditManager")
public class EnterpriseAuditManagerImpl extends GenericManagerImpl<EnterpriseAudit, Integer> implements EnterpriseAuditManager {


	private EnterpriseAuditDao enterpriseAuditDao;

	@Autowired
	public void setEnterpriseAuditDao(EnterpriseAuditDao enterpriseAuditDao) {
		this.enterpriseAuditDao = enterpriseAuditDao;
		this.dao = enterpriseAuditDao;
	}

	@Override
	public List<EnterpriseAudit> getEnterAuditList(String type, int soursId)
			throws Exception {
		return enterpriseAuditDao.getEnterAuditList(type, soursId);
	}

	@Override
	public String saveEnterAudit(Object sourceInfo, int type) throws Exception {
		EnterpriseAudit audit = new EnterpriseAudit();
		if (sourceInfo instanceof EnterpriseInfo) {
			EnterpriseInfo enterInfo = (EnterpriseInfo) sourceInfo;
			audit.setCreator(enterInfo.getCreator());
			audit.setSourseId(enterInfo.getId());
		}
		if (type == 0) {//申请
			audit.setContent("提交入驻申请");
			audit.setCreateTime(new Date());
			audit.setType("1");
		} else if (type == 1) {//客服人员指定对应的客服

		}
		enterpriseAuditDao.save(audit);
		return null;
	}
}
