[修改]:修改了模型评估和生命周期更新的一些细节,便于和前端接口协调
This commit is contained in:
pom.xml
src/main
java
com
bipt
intelligentapplicationorchestrationservice
constant
controller
service
resources
24
pom.xml
24
pom.xml
@ -165,6 +165,30 @@
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!--阿里OSS依赖-->
|
||||
<dependency>
|
||||
<groupId>com.aliyun.oss</groupId>
|
||||
<artifactId>aliyun-sdk-oss</artifactId>
|
||||
<version>3.15.1</version>
|
||||
</dependency>
|
||||
<!--如果使用的是Java 9及以上的版本,则需要添加JAXB相关依赖。添加JAXB相关依赖-->
|
||||
<dependency>
|
||||
<groupId>javax.xml.bind</groupId>
|
||||
<artifactId>jaxb-api</artifactId>
|
||||
<version>2.3.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.activation</groupId>
|
||||
<artifactId>activation</artifactId>
|
||||
<version>1.1.1</version>
|
||||
</dependency>
|
||||
<!-- no more than 2.3.3-->
|
||||
<dependency>
|
||||
<groupId>org.glassfish.jaxb</groupId>
|
||||
<artifactId>jaxb-runtime</artifactId>
|
||||
<version>2.3.3</version> <!-- 注意:版本不超过2.3.3 -->
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
@ -10,7 +10,8 @@ public class MessageConstant {
|
||||
public static final String ERROR_DEPLOYED_TO_DESIGNING = "已部署的模型不能直接调整成设计,需先下线再设计";
|
||||
public static final String ERROR_ABANDONED_CANNOT_UPDATE = "已废弃的模型只能查看信息,不能更新生命周期";
|
||||
public static final String ERROR_TRAINING_INVALID_TRANSITION = "训练中的模型只能调整成设计和评估";
|
||||
public static final String UPDATE_FAILURE = "更新模型生命周期失败";
|
||||
public static final String LIFECYCLE_UPDATE_FAILURE = "更新模型生命周期失败";
|
||||
public static final String LIFECYCLE_UPDATE_SUCCESS = "生命周期更新成功";
|
||||
|
||||
//文件上传常量
|
||||
public static final String UPLOAD_FAILURE = "上传文件失败";
|
||||
|
@ -7,12 +7,10 @@ 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.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@Tag(name = "模型评估相关接口")
|
||||
@CrossOrigin(origins = "http://localhost:3000")
|
||||
@RestController
|
||||
@RequestMapping("/evaluation")
|
||||
@Slf4j
|
||||
|
23
src/main/java/com/bipt/intelligentapplicationorchestrationservice/controller/ModelController.java
23
src/main/java/com/bipt/intelligentapplicationorchestrationservice/controller/ModelController.java
@ -1,5 +1,6 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.controller;
|
||||
|
||||
import com.bipt.intelligentapplicationorchestrationservice.constant.MessageConstant;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.pojo.*;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.service.ModelService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
@ -52,14 +53,16 @@ public class ModelController {
|
||||
}
|
||||
|
||||
@Operation(summary = "模型更新")
|
||||
@PutMapping("/updateModel")
|
||||
public OptResult updateModel(@RequestBody ModelVersionDTO dto){
|
||||
log.info("模型更新");
|
||||
@PutMapping("/updateModel/{id}")
|
||||
public OptResult updateModel(@PathVariable("id") Long id, @RequestBody ModelVersionDTO dto) {
|
||||
log.info("模型更新,id: {}", id);
|
||||
dto.setId(id);
|
||||
modelService.updateModel(dto);
|
||||
return OptResult.success();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Operation(summary = "模型版本删除")
|
||||
@DeleteMapping("/deleteModelVersion")
|
||||
public OptResult deleteModelVersion(Long id){
|
||||
@ -70,10 +73,18 @@ public class ModelController {
|
||||
|
||||
@Operation(summary = "更新生命周期")
|
||||
@PutMapping("/updateLifeCycle")
|
||||
public OptResult updateLifeCycle(Long id,String lifeCycle){
|
||||
public OptResult updateLifeCycle(@RequestParam Long id, @RequestParam String lifeCycle){
|
||||
log.info("更新生命周期");
|
||||
modelService.updateLifeCycle(id,lifeCycle);
|
||||
return OptResult.success();
|
||||
try {
|
||||
modelService.updateLifeCycle(id,lifeCycle);
|
||||
return OptResult.success(MessageConstant.LIFECYCLE_UPDATE_SUCCESS);
|
||||
} catch (IllegalArgumentException e) {
|
||||
return OptResult.error(e.getMessage());
|
||||
} catch (RuntimeException e) {
|
||||
return OptResult.error(e.getMessage());
|
||||
} catch (Exception e){
|
||||
return OptResult.error(MessageConstant.UNKNOWN_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
@Operation(summary = "查询生命周期列表")
|
||||
|
8
src/main/java/com/bipt/intelligentapplicationorchestrationservice/service/Impl/ModelServiceImpl.java
8
src/main/java/com/bipt/intelligentapplicationorchestrationservice/service/Impl/ModelServiceImpl.java
@ -111,14 +111,14 @@ public class ModelServiceImpl implements ModelService {
|
||||
ModelLifecycle currentLifeCycle;
|
||||
ModelLifecycle targetLifeCycle;
|
||||
try {
|
||||
currentLifeCycle = ModelLifecycle.valueOf(currentLifeCycleStr.trim()); // 数据库中是英文
|
||||
targetLifeCycle = ModelLifecycle.fromDescription((lifeCycleDescription).trim()); // 前端传中文
|
||||
currentLifeCycle = ModelLifecycle.valueOf(currentLifeCycleStr.trim()); // 数据库中是英文
|
||||
targetLifeCycle = ModelLifecycle.valueOf(lifeCycleDescription.trim()); // 前端传英文代码,直接转换
|
||||
} catch (IllegalArgumentException e) {
|
||||
log.error(MessageConstant.LifeCycle_Undefined + ":{}", e.getMessage());
|
||||
throw e;
|
||||
}
|
||||
|
||||
// 2. 业务逻辑校验
|
||||
// 2. 业务逻辑校验(保持不变)
|
||||
switch (currentLifeCycle) {
|
||||
case DEPLOYED:
|
||||
if (targetLifeCycle == ModelLifecycle.DESIGNING) {
|
||||
@ -143,7 +143,7 @@ public class ModelServiceImpl implements ModelService {
|
||||
int affectedRows = modelMapper.updateLifeCycleById(id, targetLifeCycle.getDbValue());
|
||||
if (affectedRows == 0) {
|
||||
log.error("更新模型生命周期失败");
|
||||
throw new RuntimeException(MessageConstant.UPDATE_FAILURE);
|
||||
throw new RuntimeException(MessageConstant.LIFECYCLE_UPDATE_FAILURE);
|
||||
}
|
||||
|
||||
log.info("模型生命周期更新成功,新状态为: {}", targetLifeCycle);
|
||||
|
@ -18,6 +18,6 @@
|
||||
<if test="status != null">
|
||||
status=#{status}
|
||||
</if>
|
||||
where model_id=#{id}
|
||||
where id=#{id}
|
||||
</update>
|
||||
</mapper>
|
@ -41,7 +41,7 @@
|
||||
</select>
|
||||
|
||||
<!--更新模型信息-->
|
||||
<update id="updateModel">
|
||||
<update id="update">
|
||||
UPDATE model_version
|
||||
<set>
|
||||
<if test="datasetId != null">dataset_id = #{datasetId},</if>
|
||||
|
Reference in New Issue
Block a user