nh #18

Manually merged
lpz merged 2 commits from nh into main 2025-06-19 10:28:22 +08:00
13 changed files with 399 additions and 33 deletions
Showing only changes of commit f18c4e4159 - Show all commits

24
pom.xml
View File

@ -165,6 +165,30 @@
<groupId>com.fasterxml.jackson.core</groupId> <groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId> <artifactId>jackson-databind</artifactId>
</dependency> </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> </dependencies>
<build> <build>

View File

@ -10,7 +10,8 @@ public class MessageConstant {
public static final String ERROR_DEPLOYED_TO_DESIGNING = "已部署的模型不能直接调整成设计,需先下线再设计"; public static final String ERROR_DEPLOYED_TO_DESIGNING = "已部署的模型不能直接调整成设计,需先下线再设计";
public static final String ERROR_ABANDONED_CANNOT_UPDATE = "已废弃的模型只能查看信息,不能更新生命周期"; public static final String ERROR_ABANDONED_CANNOT_UPDATE = "已废弃的模型只能查看信息,不能更新生命周期";
public static final String ERROR_TRAINING_INVALID_TRANSITION = "训练中的模型只能调整成设计和评估"; 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 = "上传文件失败"; public static final String UPLOAD_FAILURE = "上传文件失败";

View File

@ -7,12 +7,10 @@ import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@Tag(name = "模型评估相关接口") @Tag(name = "模型评估相关接口")
@CrossOrigin(origins = "http://localhost:3000")
@RestController @RestController
@RequestMapping("/evaluation") @RequestMapping("/evaluation")
@Slf4j @Slf4j

View File

@ -1,5 +1,6 @@
package com.bipt.intelligentapplicationorchestrationservice.controller; package com.bipt.intelligentapplicationorchestrationservice.controller;
import com.bipt.intelligentapplicationorchestrationservice.constant.MessageConstant;
import com.bipt.intelligentapplicationorchestrationservice.pojo.*; import com.bipt.intelligentapplicationorchestrationservice.pojo.*;
import com.bipt.intelligentapplicationorchestrationservice.service.ModelService; import com.bipt.intelligentapplicationorchestrationservice.service.ModelService;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
@ -52,14 +53,16 @@ public class ModelController {
} }
@Operation(summary = "模型更新") @Operation(summary = "模型更新")
@PutMapping("/updateModel") @PutMapping("/updateModel/{id}")
public OptResult updateModel(@RequestBody ModelVersionDTO dto){ public OptResult updateModel(@PathVariable("id") Long id, @RequestBody ModelVersionDTO dto) {
log.info("模型更新"); log.info("模型更新id: {}", id);
dto.setId(id);
modelService.updateModel(dto); modelService.updateModel(dto);
return OptResult.success(); return OptResult.success();
} }
@Operation(summary = "模型版本删除") @Operation(summary = "模型版本删除")
@DeleteMapping("/deleteModelVersion") @DeleteMapping("/deleteModelVersion")
public OptResult deleteModelVersion(Long id){ public OptResult deleteModelVersion(Long id){
@ -70,10 +73,18 @@ public class ModelController {
@Operation(summary = "更新生命周期") @Operation(summary = "更新生命周期")
@PutMapping("/updateLifeCycle") @PutMapping("/updateLifeCycle")
public OptResult updateLifeCycle(Long id,String lifeCycle){ public OptResult updateLifeCycle(@RequestParam Long id, @RequestParam String lifeCycle){
log.info("更新生命周期"); log.info("更新生命周期");
modelService.updateLifeCycle(id,lifeCycle); try {
return OptResult.success(); 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 = "查询生命周期列表") @Operation(summary = "查询生命周期列表")

View File

@ -111,14 +111,14 @@ public class ModelServiceImpl implements ModelService {
ModelLifecycle currentLifeCycle; ModelLifecycle currentLifeCycle;
ModelLifecycle targetLifeCycle; ModelLifecycle targetLifeCycle;
try { try {
currentLifeCycle = ModelLifecycle.valueOf(currentLifeCycleStr.trim()); // 数据库中是英文 currentLifeCycle = ModelLifecycle.valueOf(currentLifeCycleStr.trim()); // 数据库中是英文
targetLifeCycle = ModelLifecycle.fromDescription((lifeCycleDescription).trim()); // 前端传中文 targetLifeCycle = ModelLifecycle.valueOf(lifeCycleDescription.trim()); // 前端传英文代码,直接转换
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
log.error(MessageConstant.LifeCycle_Undefined + ":{}", e.getMessage()); log.error(MessageConstant.LifeCycle_Undefined + ":{}", e.getMessage());
throw e; throw e;
} }
// 2. 业务逻辑校验 // 2. 业务逻辑校验(保持不变)
switch (currentLifeCycle) { switch (currentLifeCycle) {
case DEPLOYED: case DEPLOYED:
if (targetLifeCycle == ModelLifecycle.DESIGNING) { if (targetLifeCycle == ModelLifecycle.DESIGNING) {
@ -143,7 +143,7 @@ public class ModelServiceImpl implements ModelService {
int affectedRows = modelMapper.updateLifeCycleById(id, targetLifeCycle.getDbValue()); int affectedRows = modelMapper.updateLifeCycleById(id, targetLifeCycle.getDbValue());
if (affectedRows == 0) { if (affectedRows == 0) {
log.error("更新模型生命周期失败"); log.error("更新模型生命周期失败");
throw new RuntimeException(MessageConstant.UPDATE_FAILURE); throw new RuntimeException(MessageConstant.LIFECYCLE_UPDATE_FAILURE);
} }
log.info("模型生命周期更新成功,新状态为: {}", targetLifeCycle); log.info("模型生命周期更新成功,新状态为: {}", targetLifeCycle);

View File

@ -18,6 +18,6 @@
<if test="status != null"> <if test="status != null">
status=#{status} status=#{status}
</if> </if>
where model_id=#{id} where id=#{id}
</update> </update>
</mapper> </mapper>

View File

@ -41,7 +41,7 @@
</select> </select>
<!--更新模型信息--> <!--更新模型信息-->
<update id="updateModel"> <update id="update">
UPDATE model_version UPDATE model_version
<set> <set>
<if test="datasetId != null">dataset_id = #{datasetId},</if> <if test="datasetId != null">dataset_id = #{datasetId},</if>