package org.apereo.cas.web.landtool.log.service;
|
|
import java.util.HashMap;
|
import java.util.Map;
|
|
import org.apereo.cas.web.landtool.log.config.LogProperties;
|
import org.apereo.cas.web.landtool.utils.HttpUtils;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Service;
|
|
/**
|
* @author Tanbin
|
* @date 2018-12-12
|
*/
|
@Service
|
public class LogService {
|
@Autowired
|
private LogProperties logProperties;
|
|
public LogService() {
|
|
}
|
|
public String addLog(String userId, String clientIp, int loginType, int rStatus, String browserInfo,
|
String serviceUrl) {
|
String result = "";
|
if (!logProperties.isEnabled()) {
|
return "";
|
}
|
String url = logProperties.getLogServiceUrl();
|
Map<String, Object> params = new HashMap<>(5);
|
params.put("loginname", userId);
|
params.put("loginip", clientIp);
|
params.put("logintype", loginType);
|
params.put("rstatus", rStatus);
|
params.put("broserversion", browserInfo);
|
params.put("appurl", serviceUrl);
|
try {
|
result = HttpUtils.post(url, params);
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
return result;
|
}
|
|
}
|