0522f25d156fa4e736e35ed73ac89295c0917bfc.svn-base 1.14 KB
package com.phxl.modules.goods.service.interfaceLog;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.phxl.common.response.PlatFormResponse;
import com.phxl.modules.goods.dao.interfaceLog.InterfaceLogDao;
import com.phxl.modules.goods.entity.interfaceLog.InterfaceLog;

@Service
public class InterfaceLogService {

	@Autowired
	private InterfaceLogDao interfaceLogDao;
	
	public void saveLog(String method, String params, String id){
		InterfaceLog interfaceLog = new InterfaceLog();
		interfaceLog.setId(id);
		interfaceLog.setRequestMethod(method);
		interfaceLog.setRequestTime(new Date());
		interfaceLog.setRequestParam(params);
		interfaceLogDao.insert(interfaceLog);
	}
	
	public void setResultLog(PlatFormResponse hisResponse, String id, String exception){
		InterfaceLog interfaceLog = new InterfaceLog();
		interfaceLog.setId(id);
		interfaceLog.setResultCode(hisResponse.getFlag());
		interfaceLog.setResultContent(hisResponse.getMsg());
		if(exception != null){
			interfaceLog.setException(exception);
		}
		interfaceLogDao.update(interfaceLog);
	}
	
}