服务发布

This commit is contained in:
2025-05-21 22:18:31 +08:00
parent de32099ea9
commit 5af1b7a577
9 changed files with 64 additions and 34 deletions

View File

@ -1,18 +1,21 @@
package com.bipt.intelligentapplicationorchestrationservice.controller;
import com.bipt.intelligentapplicationorchestrationservice.pojo.OptResult;
import com.bipt.intelligentapplicationorchestrationservice.pojo.ServicePublishDTO;
import com.bipt.intelligentapplicationorchestrationservice.pojo.ServicePublishVO;
import com.bipt.intelligentapplicationorchestrationservice.config.RedisConfiguration;
import com.bipt.intelligentapplicationorchestrationservice.pojo.*;
import com.bipt.intelligentapplicationorchestrationservice.service.PublishService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.transaction.annotation.Transactional;
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.List;
@Tag(name ="服务发布相关接口")
@RestController
@RequestMapping("/publish")
@ -21,6 +24,8 @@ public class publishController {
@Autowired
private PublishService publishService;
@Autowired
private RedisTemplate redisTemplate;
/**
* 新增请求发布
* @param servicePublishDTO
@ -28,11 +33,27 @@ public class publishController {
*/
@PostMapping
@Operation(summary ="新增发布请求")
@Transactional
public OptResult<ServicePublishVO> save(@RequestBody ServicePublishDTO servicePublishDTO){
log.info("模型发布请求:{}", servicePublishDTO);
publishService.save(servicePublishDTO);
ServicePublishVO servicePublishVO = publishService.getByModelId(servicePublishDTO);
return OptResult.success(servicePublishVO);
Long modelId = servicePublishDTO.getModelId();
String key="Model_" + modelId;
//查询redis是否存在GPU相关资源数据
ServicePublishVO servicePublishVO = (ServicePublishVO) redisTemplate.opsForValue().get(key);
//如果存在,直接返回,无须查询数据库
if (servicePublishVO != null){
return OptResult.success(servicePublishVO);
}
String modelConfig = publishService.getByModelId(modelId);
//todo 序列化结果提出来
ServicePublish servicePublish = new ServicePublish();
String ip = servicePublishDTO.getIp();
servicePublish.setIp(ip);
return OptResult.success();
}