diff --git a/mcwl-resource/src/main/java/com/mcwl/resource/domain/dto/AddWorkFlowVersion.java b/mcwl-resource/src/main/java/com/mcwl/resource/domain/dto/AddWorkFlowVersion.java index 226a061..015a526 100644 --- a/mcwl-resource/src/main/java/com/mcwl/resource/domain/dto/AddWorkFlowVersion.java +++ b/mcwl-resource/src/main/java/com/mcwl/resource/domain/dto/AddWorkFlowVersion.java @@ -66,18 +66,6 @@ public class AddWorkFlowVersion { @ApiModelProperty("删除标志(0代表存在 2代表删除)") private String delFlag; -// /** -// * 审核状态(0全部状态 1已发布-公开 2已发布-仅自己可见 3审核中 4审核未通过) -// */ -// @ApiModelProperty("审核状态(0全部状态 1已发布-公开 2已发布-仅自己可见 3审核中 4审核未通过)") -// private Integer auditStatus = 3; -// -// /** -// * 审核失败原因 -// */ -// @ApiModelProperty("审核失败原因") -// private String auditText; - /** * 模型ID */ @@ -89,4 +77,20 @@ public class AddWorkFlowVersion { */ @ApiModelProperty("文件名字") private String fileName; + + + /** + * 文件大小 + */ + @ApiModelProperty("文件名字") + private String fileSize; + + /** + * 文件标识 + */ + @ApiModelProperty("文件标识") + private String objectKey; + + @ApiModelProperty("文件hash") + private String fileHash; } diff --git a/mcwl-resource/src/main/java/com/mcwl/resource/mapper/WorkFlowVersionMapper.java b/mcwl-resource/src/main/java/com/mcwl/resource/mapper/WorkFlowVersionMapper.java index 15213a9..2a5aa71 100644 --- a/mcwl-resource/src/main/java/com/mcwl/resource/mapper/WorkFlowVersionMapper.java +++ b/mcwl-resource/src/main/java/com/mcwl/resource/mapper/WorkFlowVersionMapper.java @@ -3,6 +3,7 @@ package com.mcwl.resource.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.mcwl.resource.domain.WorkFlow; import com.mcwl.resource.domain.WorkFlowVersion; +import com.mcwl.resource.domain.dto.AddWorkFlowVersion; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -18,7 +19,7 @@ import java.util.List; @Mapper public interface WorkFlowVersionMapper extends BaseMapper { - void addWorkFlowVersion(@Param("workFlow") WorkFlow workFlow, @Param("list") List workFlowVersionList); + void addWorkFlowVersion(@Param("workFlow") WorkFlow workFlow, @Param("list") List workFlowVersionList); void updateWorkFlowVersion(WorkFlowVersion workFlowVersion); diff --git a/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/ModelServiceImpl.java b/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/ModelServiceImpl.java index f03241d..3406093 100644 --- a/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/ModelServiceImpl.java +++ b/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/ModelServiceImpl.java @@ -78,6 +78,7 @@ public class ModelServiceImpl extends ServiceImpl impl @Autowired private CollectServiceImpl collectService; + /** * 设置模型置顶状态 * @@ -275,6 +276,24 @@ public class ModelServiceImpl extends ServiceImpl impl } + for (ModelVersion modelVersion : requestModel.getModelVersionList()) { + + //校验名字 + ModelVersion modelVersion1 = modelVersionMapper.selectByFileName(modelVersion.getFileName()); + if (modelVersion1 != null) { + + return R.fail(HttpStatus.SHOW_ERROR_MSG,"文件名字重复"); + } + //校验hash + ModelVersion modelVersion2 = modelVersionMapper.selectByHash(modelVersion.getFileHash()); + if (modelVersion2 != null){ + + return R.fail(HttpStatus.SHOW_ERROR_MSG,"文件内容重复"); + } + } + + + //获取封面图 String filePath = requestModel.getModelVersionList().get(0).getSampleImagePaths(); String[] split = filePath.split(","); diff --git a/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/WorkFlowServiceImpl.java b/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/WorkFlowServiceImpl.java index 9e6c342..709b04a 100644 --- a/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/WorkFlowServiceImpl.java +++ b/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/WorkFlowServiceImpl.java @@ -21,6 +21,7 @@ import com.mcwl.common.utils.StringUtils; import com.mcwl.common.utils.baidu.BaiduCensor; import com.mcwl.resource.domain.*; import com.mcwl.resource.domain.dto.AddRequestWorkFlow; +import com.mcwl.resource.domain.dto.AddWorkFlowVersion; import com.mcwl.resource.domain.dto.ModelImagePageRes; import com.mcwl.resource.domain.request.RequestWorkFlow; import com.mcwl.resource.domain.response.ResponseWorkFlow; @@ -86,6 +87,23 @@ public class WorkFlowServiceImpl extends ServiceImpl i return R.fail(HttpStatus.SHOW_ERROR_MSG,"实名制后才可以发布"); } + + for (AddWorkFlowVersion addWorkFlowVersion : addRequestWorkFlo.getWorkFlowVersionList()) { + + //校验名字 + WorkFlowVersion workFlowVersion1 = workFlowVersionMapper.selectByFileName(addWorkFlowVersion.getFileName()); + if (workFlowVersion1 != null) { + + return R.fail(HttpStatus.SHOW_ERROR_MSG,"文件名字重复"); + } + //校验hash + WorkFlowVersion workFlowVersion2 = workFlowVersionMapper.selectByHash(addWorkFlowVersion.getFileHash()); + if (workFlowVersion2 != null){ + + return R.fail(HttpStatus.SHOW_ERROR_MSG,"文件内容重复"); + } + } + RequestWorkFlow requestWorkFlow = new RequestWorkFlow(); BeanUtil.copyProperties(addRequestWorkFlo, requestWorkFlow); // RequestWorkFlow requestWorkFlow = JSON.parseObject(JSON.toJSONString(addRequestWorkFlo), RequestWorkFlow.class); @@ -97,6 +115,7 @@ public class WorkFlowServiceImpl extends ServiceImpl i WorkFlow workFlow = requestWorkFlow.getWorkFlow(); workFlow.setUserId(SecurityUtils.getUserId()); workFlow.setCoverPath(split[0]); + workFlow.setCreateTime(new Date()); //添加模型表数据 flowMapper.insert(workFlow); @@ -104,7 +123,7 @@ public class WorkFlowServiceImpl extends ServiceImpl i log.info("获取到的入参:{}", requestWorkFlow.getWorkFlow()); //批量添加版本 - workFlowVersionMapper.addWorkFlowVersion(requestWorkFlow.getWorkFlow(), requestWorkFlow.getWorkFlowVersionList()); + workFlowVersionMapper.addWorkFlowVersion(requestWorkFlow.getWorkFlow(), addRequestWorkFlo.getWorkFlowVersionList()); audit(requestWorkFlow); diff --git a/mcwl-resource/src/main/resources/mapper/resource/ModelVersionMapper.xml b/mcwl-resource/src/main/resources/mapper/resource/ModelVersionMapper.xml index 7894cc5..23b74ee 100644 --- a/mcwl-resource/src/main/resources/mapper/resource/ModelVersionMapper.xml +++ b/mcwl-resource/src/main/resources/mapper/resource/ModelVersionMapper.xml @@ -8,7 +8,7 @@ model_id,version_name,version_description,model_version_type, file_path,file_name, trigger_words, sampling, high, vae, cfg, is_free, is_public, is_encrypt, is_online_use, allow_download_image, allow_software_use, allow_fusion, allow_commercial_use, allow_usage, - is_exclusive_model, sample_image_paths, hide_image_gen_info, del_flag,file_size,file_hash + is_exclusive_model, sample_image_paths, hide_image_gen_info, del_flag,file_size,file_hash,object_key ) VALUES ( @@ -17,7 +17,7 @@ #{isFree}, #{isPublic}, #{isEncrypt}, #{isOnlineUse}, #{allowDownloadImage}, #{allowSoftwareUse}, #{allowFusion}, #{allowCommercialUse}, #{allowUsage}, #{isExclusiveModel}, - #{sampleImagePaths}, #{hideImageGenInfo},'0',#{fileSize},#{fileHash} + #{sampleImagePaths}, #{hideImageGenInfo},'0',#{fileSize},#{fileHash},#{objectKey} )