新增修改工作流/模型文件校验

master
Diyu0904 2025-03-18 14:28:46 +08:00
parent ed9cad897f
commit 5726a63ec7
2 changed files with 44 additions and 3 deletions

View File

@ -2,20 +2,20 @@ package com.mcwl.web.controller.resource;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.mcwl.common.constant.HttpStatus;
import com.mcwl.common.core.controller.BaseController; import com.mcwl.common.core.controller.BaseController;
import com.mcwl.common.core.domain.AjaxResult; import com.mcwl.common.core.domain.AjaxResult;
import com.mcwl.common.core.domain.R; import com.mcwl.common.core.domain.R;
import com.mcwl.common.core.page.PageDomain;
import com.mcwl.common.core.page.TableDataInfo; import com.mcwl.common.core.page.TableDataInfo;
import com.mcwl.common.utils.SecurityUtils; import com.mcwl.common.utils.SecurityUtils;
import com.mcwl.resource.domain.ModelProduct; import com.mcwl.resource.domain.ModelProduct;
import com.mcwl.resource.domain.ModelVersion; import com.mcwl.resource.domain.ModelVersion;
import com.mcwl.resource.domain.dto.ModelImagePageRes; import com.mcwl.resource.domain.dto.ModelImagePageRes;
import com.mcwl.resource.domain.response.ResponseModelProduct;
import com.mcwl.resource.domain.request.RequestModel; import com.mcwl.resource.domain.request.RequestModel;
import com.mcwl.resource.domain.response.ResponseModelProduct;
import com.mcwl.resource.domain.vo.PageVo; import com.mcwl.resource.domain.vo.PageVo;
import com.mcwl.resource.mapper.ModelVersionMapper; import com.mcwl.resource.mapper.ModelVersionMapper;
import com.mcwl.resource.service.*; import com.mcwl.resource.service.ModelService;
import com.mcwl.system.service.impl.SysUserServiceImpl; import com.mcwl.system.service.impl.SysUserServiceImpl;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
@ -95,6 +95,24 @@ public class MallProductController extends BaseController {
@ApiOperation(value = "修改模型") @ApiOperation(value = "修改模型")
@PostMapping("/update") @PostMapping("/update")
public AjaxResult updateModel(@RequestBody RequestModel requestModel) { public AjaxResult updateModel(@RequestBody RequestModel requestModel) {
for (ModelVersion modelVersion : requestModel.getModelVersionList()) {
//校验名字
ModelVersion modelVersion1 = modelVersionMapper.selectByFileName(modelVersion.getFileName());
if (modelVersion1 != null) {
return AjaxResult.error(HttpStatus.SHOW_ERROR_MSG,"文件名字重复");
}
//校验hash
ModelVersion modelVersion2 = modelVersionMapper.selectByHash(modelVersion.getFileHash());
if (modelVersion2 != null){
return AjaxResult.error(HttpStatus.SHOW_ERROR_MSG,"文件内容重复");
}
}
ModelProduct modelProduct = requestModel.getModelProduct(); ModelProduct modelProduct = requestModel.getModelProduct();
Long userId = SecurityUtils.getUserId(); Long userId = SecurityUtils.getUserId();

View File

@ -2,13 +2,16 @@ package com.mcwl.web.controller.resource;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.mcwl.common.constant.HttpStatus;
import com.mcwl.common.core.controller.BaseController; import com.mcwl.common.core.controller.BaseController;
import com.mcwl.common.core.domain.R; import com.mcwl.common.core.domain.R;
import com.mcwl.resource.domain.WorkFlow; import com.mcwl.resource.domain.WorkFlow;
import com.mcwl.resource.domain.WorkFlowVersion;
import com.mcwl.resource.domain.dto.AddRequestWorkFlow; import com.mcwl.resource.domain.dto.AddRequestWorkFlow;
import com.mcwl.resource.domain.request.RequestWorkFlow; import com.mcwl.resource.domain.request.RequestWorkFlow;
import com.mcwl.resource.domain.response.ResponseWorkFlow; import com.mcwl.resource.domain.response.ResponseWorkFlow;
import com.mcwl.resource.domain.vo.PageVo; import com.mcwl.resource.domain.vo.PageVo;
import com.mcwl.resource.mapper.WorkFlowVersionMapper;
import com.mcwl.resource.service.WorkFlowService; import com.mcwl.resource.service.WorkFlowService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
@ -40,6 +43,9 @@ public class WorkFlowController extends BaseController {
@Autowired @Autowired
private WorkFlowService workFlowService; private WorkFlowService workFlowService;
@Autowired
private WorkFlowVersionMapper workFlowVersionMapper;
/** /**
* *
@ -94,6 +100,23 @@ public class WorkFlowController extends BaseController {
@PostMapping("/updateWorkFlow") @PostMapping("/updateWorkFlow")
public R<Object> updateWorkFlow(@RequestBody RequestWorkFlow requestWorkFlow) { public R<Object> updateWorkFlow(@RequestBody RequestWorkFlow requestWorkFlow) {
for (WorkFlowVersion workFlowVersion : requestWorkFlow.getWorkFlowVersionList()) {
//校验名字
WorkFlowVersion workFlowVersion1 = workFlowVersionMapper.selectByFileName(workFlowVersion.getFileName());
if (workFlowVersion1 != null) {
return R.fail(HttpStatus.SHOW_ERROR_MSG,"文件名字重复");
}
//校验hash
WorkFlowVersion workFlowVersion2 = workFlowVersionMapper.selectByHash(workFlowVersion.getFileHash());
if (workFlowVersion2 != null){
return R.fail(HttpStatus.SHOW_ERROR_MSG,"文件内容重复");
}
}
workFlowService.updateWorkFlow(requestWorkFlow); workFlowService.updateWorkFlow(requestWorkFlow);
return R.ok(); return R.ok();