@RestResource(urlMapping='/OFSAddReportOP/*')
|
global with sharing class OFSAddReportOPRest {
|
/**
|
* sTime yyyy/MM/dd HH24:mm
|
*/
|
@HttpPost
|
global static void addReportOP() {
|
Map<String, String> requestMap = (Map<String, String>) JSON.deserializeStrict(RestContext.request.requestBody.toString(), Map<String, String>.class);
|
String repOwnerId = UserInfo.getUserId();
|
String reportId = requestMap.get('reportId');
|
String dailyReportId = requestMap.get('dailyReportId');
|
String eventCId = requestMap.get('eventCId');
|
String recordType = requestMap.get('recordType');
|
String accId = requestMap.get('accId');
|
String visitor1 = requestMap.get('visitor1');
|
String visitor2 = requestMap.get('visitor2');
|
String visitor3 = requestMap.get('visitor3');
|
String visitor4 = requestMap.get('visitor4');
|
String visitor5 = requestMap.get('visitor5');
|
String opp1Id = requestMap.get('opp1Id');
|
String opp2Id = requestMap.get('opp2Id');
|
String opp3Id = requestMap.get('opp3Id');
|
String opp4Id = requestMap.get('opp4Id');
|
String opp5Id = requestMap.get('opp5Id');
|
String reportDate = requestMap.get('reportDate');
|
|
system.debug('OFSAddReportOPRest.start');
|
RestResponse res = RestContext.response;
|
res.addHeader('Content-Type', 'application/json');
|
res.statusCode = 200;
|
if (String.isBlank(eventCId)) {
|
Map<String, String> responseMap = OFSEventEditRest.createDailyReport(requestMap);
|
if (responseMap.get('System.Label.OFSErrorStatus') == System.Label.OFSErrorFailure) {
|
String eventResponse = JSON.serialize(responseMap);
|
res.responseBody = blob.valueOf(eventResponse);
|
return;
|
}
|
eventCId = responseMap.get(System.Label.OFSErrorMessage);
|
dailyReportId = responseMap.get('drId');
|
} else {
|
Map<String, String> responseMap = OFSEventEditRest.createDailyReport(requestMap);
|
if (responseMap.get('System.Label.OFSErrorStatus') == System.Label.OFSErrorFailure) {
|
String eventResponse = JSON.serialize(responseMap);
|
res.responseBody = blob.valueOf(eventResponse);
|
return;
|
}
|
}
|
String jsonResponse;
|
try {
|
String rtnId = Add_Report.addReportOP(repOwnerId, reportId, dailyReportId, eventCId, recordType, accId, visitor1, visitor2, visitor3, visitor4,visitor5, opp1Id, opp2Id, opp3Id, opp4Id, opp5Id, reportDate);
|
// JSONを戻す
|
jsonResponse = '{"'+ System.Label.OFSErrorStatus +'": "'+ System.Label.OFSErrorSuccess +'", "'+ System.Label.OFSErrorMessage +'": "' + rtnId + '"}';
|
} catch (Exception ex) {
|
//error message:cannot update exception
|
jsonResponse = '{"'+ System.Label.OFSErrorStatus +'": "'+ System.Label.OFSErrorFailure +'", "'+ System.Label.OFSErrorMessage +'": "'+ ex +'"}';
|
}
|
res.responseBody = blob.valueOf(jsonResponse);
|
return;
|
}
|
}
|