InterfaceLogService.java
1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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);
}
}