package com.fdkankan.download.controller; import cn.hutool.core.exceptions.ExceptionUtil; import com.alibaba.fastjson.JSONObject; import com.fdkankan.common.constant.CommonSuccessStatus; import com.fdkankan.download.service.ISceneBuildProcessLogService; import com.fdkankan.download.service.IScrbService; import com.fdkankan.web.response.ResultData; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import java.util.concurrent.CompletableFuture; /** *
* pro场景表 前端控制器 *
* * @author * @since 2022-10-17 */ @Slf4j @RestController @RequestMapping("/download/scrb") public class ScrbController { @Autowired private IScrbService scrbService; @Autowired private ISceneBuildProcessLogService sceneBuildProcessLogService; @PostMapping("/syncScene") public ResultData syncScene(@RequestBody JSONObject param){ String num = param.getString("num"); String key = param.getString("key"); CompletableFuture.runAsync(() -> { try { sceneBuildProcessLogService.clearSceneBuildProcessLog(num, "sync", "sync", null); sceneBuildProcessLogService.saveSceneBuildProcessLog(num, "sync", "sync", CommonSuccessStatus.WAITING.code(), null, null); scrbService.syncScene(param); sceneBuildProcessLogService.saveSceneBuildProcessLog(num, "sync", "sync", CommonSuccessStatus.SUCCESS.code(), null, null); } catch (Exception e) { log.error("场景同步失败,num:{}, key:{}", num, key, e); sceneBuildProcessLogService.saveSceneBuildProcessLog(num, "sync", "sync", CommonSuccessStatus.FAIL.code(), ExceptionUtil.stacktraceToString(e, 3000), null); } }); return ResultData.ok(); } }