From e76ad82a951431b0f51ddc3320cc2cf48fb15fcc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E7=A3=8A?= Date: Mon, 9 Jun 2025 20:28:50 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=8E=A5=E5=8F=A3=E7=BB=99?= =?UTF-8?q?=E5=A4=A7=E6=A8=A1=E5=9E=8B=E8=B0=83=E7=94=A8=EF=BC=8C=E6=8E=A8?= =?UTF-8?q?=E9=80=81=E8=B5=84=E8=AE=AF=E5=88=B0=E5=85=A8=E9=87=8F=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/controller/CommonController.java | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/admin/src/main/java/com/jinrui/reference/admin/controller/CommonController.java b/admin/src/main/java/com/jinrui/reference/admin/controller/CommonController.java index b0f0a77..1d62ea1 100644 --- a/admin/src/main/java/com/jinrui/reference/admin/controller/CommonController.java +++ b/admin/src/main/java/com/jinrui/reference/admin/controller/CommonController.java @@ -7,19 +7,19 @@ import com.aliyuncs.profile.DefaultProfile; import com.aliyuncs.profile.IClientProfile; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; +import com.jinrui.reference.admin.model.dto.newsinfo.PublishNewsInfoDTO; import com.jinrui.reference.admin.model.dto.oss.CloseableAcsClient; import com.jinrui.reference.admin.model.entity.AdminUser; import com.jinrui.reference.admin.model.vo.oss.OssVO; import com.jinrui.reference.admin.service.AdminJwtService; import com.jinrui.reference.core.model.vo.ResultObject; +import com.jinrui.reference.core.service.NewsInfoService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Value; +import org.springframework.util.ObjectUtils; import org.springframework.util.StringUtils; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; @RestController @RequestMapping("/common") @@ -35,6 +35,7 @@ public class CommonController { private final String region; private final String bucketName; private final ObjectMapper objectMapper; + private final NewsInfoService newsInfoService; public CommonController(@Value("${oss.sts.endPoint}") String stsEndPoint, @Value("${oss.ak}") String ak, @@ -43,7 +44,8 @@ public class CommonController { @Value("${oss.endPoint}") String endPoint, @Value("${oss.region}") String region, @Value("${oss.bucketName}") String bucketName, - ObjectMapper objectMapper) { + ObjectMapper objectMapper, + NewsInfoService newsInfoService) { this.stsEndPoint = stsEndPoint; this.ak = ak; this.sk = sk; @@ -52,6 +54,7 @@ public class CommonController { this.region = region; this.bucketName = bucketName; this.objectMapper = objectMapper; + this.newsInfoService = newsInfoService; } @PostMapping("/uploadKey") @@ -117,4 +120,14 @@ public class CommonController { } return ossVO; } + + @GetMapping("/sync/{id}") + public ResultObject sync(@PathVariable("id") String id) { + try { + log.info("path: /sync/sync, method: GET, request news id: {}", id); + return newsInfoService.publish(id, 1L); + } catch (Exception e) { + return ResultObject.failed(500, "服务端错误,请联系系统管理员!"); + } + } }