|
|
@ -2,12 +2,14 @@ package com.techsor.datacenter.business.controller; |
|
|
|
|
|
|
|
|
import java.util.List; |
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
|
|
|
import com.techsor.datacenter.business.common.response.ResponseCode; |
|
|
import com.techsor.datacenter.business.configurator.interceptor.AccessRequired; |
|
|
import com.techsor.datacenter.business.configurator.interceptor.AccessRequired; |
|
|
import com.techsor.datacenter.business.configurator.interceptor.ApiTokenRequired; |
|
|
import com.techsor.datacenter.business.configurator.interceptor.ApiTokenRequired; |
|
|
import com.techsor.datacenter.business.dto.common.RepostRoidParams; |
|
|
import com.techsor.datacenter.business.dto.common.RepostRoidParams; |
|
|
import com.techsor.datacenter.business.dto.common.api.*; |
|
|
import com.techsor.datacenter.business.dto.common.api.*; |
|
|
import com.techsor.datacenter.business.dto.common.roidproblemreport.ProblemReportsSummariesSearchParams; |
|
|
import com.techsor.datacenter.business.dto.common.roidproblemreport.ProblemReportsSummariesSearchParams; |
|
|
import com.techsor.datacenter.business.service.ApiAuthService; |
|
|
import com.techsor.datacenter.business.service.ApiAuthService; |
|
|
|
|
|
import com.techsor.datacenter.business.service.schedule.ScheduleSyncSalesforceInfo; |
|
|
import com.techsor.datacenter.business.util.ApiContext; |
|
|
import com.techsor.datacenter.business.util.ApiContext; |
|
|
import com.techsor.datacenter.business.vo.common.ApiTokenVO; |
|
|
import com.techsor.datacenter.business.vo.common.ApiTokenVO; |
|
|
import org.slf4j.Logger; |
|
|
import org.slf4j.Logger; |
|
|
@ -15,13 +17,7 @@ import org.slf4j.LoggerFactory; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
import org.springframework.http.MediaType; |
|
|
import org.springframework.http.MediaType; |
|
|
import org.springframework.web.bind.annotation.PostMapping; |
|
|
import org.springframework.web.bind.annotation.*; |
|
|
import org.springframework.web.bind.annotation.RequestBody; |
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestHeader; |
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping; |
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestMethod; |
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestParam; |
|
|
|
|
|
import org.springframework.web.bind.annotation.RestController; |
|
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
import com.techsor.datacenter.business.common.response.SimpleDataResponse; |
|
|
import com.techsor.datacenter.business.common.response.SimpleDataResponse; |
|
|
@ -66,6 +62,8 @@ public class CommonController{ |
|
|
private CommonService commonService; |
|
|
private CommonService commonService; |
|
|
@Autowired |
|
|
@Autowired |
|
|
private ApiAuthService apiAuthService; |
|
|
private ApiAuthService apiAuthService; |
|
|
|
|
|
@Autowired |
|
|
|
|
|
private ScheduleSyncSalesforceInfo scheduleSyncSalesforceInfo; |
|
|
|
|
|
|
|
|
@Value("${open.api.mock}") |
|
|
@Value("${open.api.mock}") |
|
|
private String openApiMock; |
|
|
private String openApiMock; |
|
|
@ -428,4 +426,41 @@ public class CommonController{ |
|
|
@RequestHeader("X-API-KEY") String apiKey) { |
|
|
@RequestHeader("X-API-KEY") String apiKey) { |
|
|
return apiAuthService.generateToken(apiKey); |
|
|
return apiAuthService.generateToken(apiKey); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Operation(summary = "Manually trigger Salesforce data synchronization for all companies") |
|
|
|
|
|
@RequestMapping(value = "/syncSalesforce/all", method = RequestMethod.GET) |
|
|
|
|
|
public SimpleDataResponse syncAll() { |
|
|
|
|
|
|
|
|
|
|
|
SimpleDataResponse response = new SimpleDataResponse(); |
|
|
|
|
|
try { |
|
|
|
|
|
logger.info("Manual sync triggered"); |
|
|
|
|
|
scheduleSyncSalesforceInfo.syncAllCompanies(); |
|
|
|
|
|
response.setCode(ResponseCode.SUCCESS); |
|
|
|
|
|
response.setMsg("Synchronization started successfully"); |
|
|
|
|
|
response.setData(null); |
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
logger.error("Manual sync failed", e); |
|
|
|
|
|
response.setCode(ResponseCode.SERVER_ERROR); |
|
|
|
|
|
response.setMsg("Synchronization failed: " + e.getMessage()); |
|
|
|
|
|
} |
|
|
|
|
|
return response; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Operation(summary = "Manually trigger Salesforce data synchronization for a specific company") |
|
|
|
|
|
@RequestMapping(value = "/syncSalesforce/{companyId}", method = RequestMethod.GET) |
|
|
|
|
|
public SimpleDataResponse syncByCompany(@PathVariable Long companyId) { |
|
|
|
|
|
SimpleDataResponse response = new SimpleDataResponse(); |
|
|
|
|
|
try { |
|
|
|
|
|
logger.info("Manual sync triggered for company: {}", companyId); |
|
|
|
|
|
scheduleSyncSalesforceInfo.syncByCompany(companyId); |
|
|
|
|
|
response.setCode(ResponseCode.SUCCESS); |
|
|
|
|
|
response.setMsg("Synchronization started successfully for company: " + companyId); |
|
|
|
|
|
response.setData(null); |
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
logger.error("Manual sync failed for company: {}", companyId, e); |
|
|
|
|
|
response.setCode(ResponseCode.SERVER_ERROR); |
|
|
|
|
|
response.setMsg("Synchronization failed: " + e.getMessage()); |
|
|
|
|
|
} |
|
|
|
|
|
return response; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|