diff --git a/mcwl-admin/src/main/java/com/mcwl/web/controller/communityCenter/DownloadFile.java b/mcwl-admin/src/main/java/com/mcwl/web/controller/communityCenter/DownloadFile.java new file mode 100644 index 0000000..1c6cf13 --- /dev/null +++ b/mcwl-admin/src/main/java/com/mcwl/web/controller/communityCenter/DownloadFile.java @@ -0,0 +1,67 @@ +package com.mcwl.web.controller.communityCenter; + +import com.mcwl.common.core.domain.R; +import com.obs.services.ObsClient; +import com.obs.services.exception.ObsException; +import com.obs.services.model.DownloadFileRequest; +import com.obs.services.model.DownloadFileResult; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +/** + * @author DaiZibo + * @date 2025/3/8 + * @apiNote + */ + +@RequestMapping("/downFile") +@RestController +public class DownloadFile { + + @Autowired + private ObsClient obsClient; + + @Value("${huawei.obs.bucketName}") + private String bucketName; + + @GetMapping("/down") + public R down(@RequestParam String objectKey, String path) { + + try { + DownloadFileRequest request = new DownloadFileRequest(bucketName, objectKey); + // 设置下载对象的本地文件路径 + request.setDownloadFile(path); + // 设置分段下载时的最大并发数 + request.setTaskNum(10); + // 设置分段大小为10MB + request.setPartSize(10 * 1024 * 1024); + // 开启断点续传模式 + request.setEnableCheckpoint(true); + // 进行断点续传下载 + DownloadFileResult result = obsClient.downloadFile(request); + System.out.println("downloadFile successfully"); + System.out.println("Etag:" + result.getObjectMetadata().getEtag()); + } catch (ObsException e) { + System.out.println("downloadFile failed"); + // 请求失败,打印http状态码 + System.out.println("HTTP Code:" + e.getResponseCode()); + // 请求失败,打印服务端错误码 + System.out.println("Error Code:" + e.getErrorCode()); + // 请求失败,打印详细错误信息 + System.out.println("Error Message:" + e.getErrorMessage()); + // 请求失败,打印请求id + System.out.println("Request ID:" + e.getErrorRequestId()); + System.out.println("Host ID:" + e.getErrorHostId()); + e.printStackTrace(); + } catch (Exception e) { + System.out.println("downloadFile failed"); + // 其他异常信息打印 + e.printStackTrace(); + } + return R.ok(); + } +} diff --git a/mcwl-admin/src/main/java/com/mcwl/web/controller/communityCenter/PlaFormController.java b/mcwl-admin/src/main/java/com/mcwl/web/controller/communityCenter/PlaFormController.java index 64e34af..6e914f3 100644 --- a/mcwl-admin/src/main/java/com/mcwl/web/controller/communityCenter/PlaFormController.java +++ b/mcwl-admin/src/main/java/com/mcwl/web/controller/communityCenter/PlaFormController.java @@ -17,6 +17,7 @@ import javax.validation.constraints.NotNull; import java.util.List; /** + * 官方app * @Author:ChenYan * @Project:mcwl-ai * @Package:com.mcwl.web.controller.communityCenter @@ -36,7 +37,7 @@ public class PlaFormController extends BaseController { /** * 平台官方联系列表 */ - @ApiOperation(value = "模型列表") + @ApiOperation(value = "官方连接方式二维码列表") @PostMapping("/list") public List list(@RequestBody PlatForm platForm) { diff --git a/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/FileController.java b/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/FileController.java index 11ac6bb..00f61bb 100644 --- a/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/FileController.java +++ b/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/FileController.java @@ -1,6 +1,7 @@ package com.mcwl.web.controller.resource; import com.mcwl.common.core.domain.AjaxResult; +import com.mcwl.common.core.domain.R; import com.mcwl.common.utils.obs.ObsUtils; import com.mcwl.resource.service.impl.FileServiceImpl; import com.mcwl.web.controller.common.OssUtil; @@ -251,4 +252,15 @@ public class FileController { } } + /** + * 校验文件内容时候重复 + * @return + */ + @ApiOperation(value = "校验文件hash是否重复") + @GetMapping("/selectHash") + public R selectHash(String hashCode,Integer type){ + + return fileService.selectHash(hashCode,type); + } + } diff --git a/mcwl-admin/src/main/resources/application-dev.yml b/mcwl-admin/src/main/resources/application-dev.yml index beea40a..892dace 100644 --- a/mcwl-admin/src/main/resources/application-dev.yml +++ b/mcwl-admin/src/main/resources/application-dev.yml @@ -143,11 +143,11 @@ mall: alipayCertPath: cert/dev/alipayPublicCert.crt # 沙箱支付宝根证书路径 alipayRootCertPath: cert/dev/alipayRootCert.crt - notifyUrl: https://53a65908.r27.cpolar.top/ali/pay/notify + notifyUrl: http://1.13.246.108:8080/ali/pay/notify # 沙箱支付宝网关 gatewayUrl: https://openapi-sandbox.dl.alipaydev.com/gateway.do # 绑定回调 - bindUrl: https://4b0ca615.r27.cpolar.top/ali/pay/callback + bindUrl: http://1.13.246.108:8080/ali/pay/callback huawei: obs: diff --git a/mcwl-framework/src/main/java/com/mcwl/framework/config/SecurityConfig.java b/mcwl-framework/src/main/java/com/mcwl/framework/config/SecurityConfig.java index 1dacc75..ca930ce 100644 --- a/mcwl-framework/src/main/java/com/mcwl/framework/config/SecurityConfig.java +++ b/mcwl-framework/src/main/java/com/mcwl/framework/config/SecurityConfig.java @@ -158,7 +158,8 @@ public class SecurityConfig { "/WorkFlowVersion/selectVersionByWorkId", "/memberLevel/list", "/memberLevel/getMemberBenefitList", - "/attention/selectAttentionList" + "/attention/selectAttentionList", + "/downFile/down" ).permitAll() // 静态资源,可匿名访问 .antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll() diff --git a/mcwl-resource/src/main/java/com/mcwl/resource/domain/ModelVersion.java b/mcwl-resource/src/main/java/com/mcwl/resource/domain/ModelVersion.java index fe6f809..8a03506 100644 --- a/mcwl-resource/src/main/java/com/mcwl/resource/domain/ModelVersion.java +++ b/mcwl-resource/src/main/java/com/mcwl/resource/domain/ModelVersion.java @@ -201,4 +201,10 @@ public class ModelVersion extends BaseEntity { @TableField(exist = false) private Integer isCollect = 1; + /** + * 文件hash + */ + @ApiModelProperty(value = "文件hash") + private String fileHash; + } diff --git a/mcwl-resource/src/main/java/com/mcwl/resource/domain/WorkFlowVersion.java b/mcwl-resource/src/main/java/com/mcwl/resource/domain/WorkFlowVersion.java index d533006..364023d 100644 --- a/mcwl-resource/src/main/java/com/mcwl/resource/domain/WorkFlowVersion.java +++ b/mcwl-resource/src/main/java/com/mcwl/resource/domain/WorkFlowVersion.java @@ -104,4 +104,10 @@ public class WorkFlowVersion { @TableField(exist = false) @ApiModelProperty(value = "是否收藏") private Integer isCollect =1; + + /** + * 文件hash + */ + @ApiModelProperty(value = "文件hash") + private String fileHash; } diff --git a/mcwl-resource/src/main/java/com/mcwl/resource/mapper/ModelVersionMapper.java b/mcwl-resource/src/main/java/com/mcwl/resource/mapper/ModelVersionMapper.java index a705a72..85376e8 100644 --- a/mcwl-resource/src/main/java/com/mcwl/resource/mapper/ModelVersionMapper.java +++ b/mcwl-resource/src/main/java/com/mcwl/resource/mapper/ModelVersionMapper.java @@ -23,4 +23,6 @@ public interface ModelVersionMapper extends BaseMapper { void addModelVersion (ModelVersion modelVersion); + ModelVersion selectByHash(@Param("hashCode") String hashCode); + } diff --git a/mcwl-resource/src/main/java/com/mcwl/resource/mapper/ReportMapper.java b/mcwl-resource/src/main/java/com/mcwl/resource/mapper/ReportMapper.java index b9df916..14c5d9f 100644 --- a/mcwl-resource/src/main/java/com/mcwl/resource/mapper/ReportMapper.java +++ b/mcwl-resource/src/main/java/com/mcwl/resource/mapper/ReportMapper.java @@ -13,5 +13,5 @@ import org.apache.ibatis.annotations.Param; @Mapper public interface ReportMapper extends BaseMapper { - void updateStatus(@Param("productId") Long productId, @Param("type") Integer type); + void updateStatus(@Param("productId") Long productId, @Param("type") Integer type, @Param("status") Integer status); } 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 966a214..1e3dd5a 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 @@ -26,4 +26,6 @@ public interface WorkFlowVersionMapper extends BaseMapper { WorkFlowVersion selectByFileName(@Param("name") String name); + WorkFlowVersion selectByHash(@Param("hashCode") String hashCode); + } diff --git a/mcwl-resource/src/main/java/com/mcwl/resource/service/FileService.java b/mcwl-resource/src/main/java/com/mcwl/resource/service/FileService.java index 461332e..c56a6eb 100644 --- a/mcwl-resource/src/main/java/com/mcwl/resource/service/FileService.java +++ b/mcwl-resource/src/main/java/com/mcwl/resource/service/FileService.java @@ -1,6 +1,7 @@ package com.mcwl.resource.service; import com.mcwl.common.core.domain.AjaxResult; +import com.mcwl.common.core.domain.R; /** * @author DaiZibo @@ -12,4 +13,6 @@ public interface FileService { AjaxResult selectFileName(String name, String type); AjaxResult selectFile(String name, String type); + + R selectHash(String hashCode, Integer type); } diff --git a/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/FileServiceImpl.java b/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/FileServiceImpl.java index f1773f7..d6b55ab 100644 --- a/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/FileServiceImpl.java +++ b/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/FileServiceImpl.java @@ -1,6 +1,7 @@ package com.mcwl.resource.service.impl; import com.mcwl.common.core.domain.AjaxResult; +import com.mcwl.common.core.domain.R; import com.mcwl.common.utils.StringUtils; import com.mcwl.resource.domain.ModelVersion; import com.mcwl.resource.domain.WorkFlowVersion; @@ -85,4 +86,27 @@ public class FileServiceImpl implements FileService { return AjaxResult.error("type不合法"); } + + @Override + public R selectHash(String hashCode, Integer type) { + + //0模型 1工作流 + if (type == 0){ + + ModelVersion modelVersion = versionMapper.selectByHash(hashCode); + if (modelVersion != null){ + + return R.ok(0); + } + return R.ok(1); + }else { + + WorkFlowVersion workFlowVersion = workFlowVersionMapper.selectByHash(hashCode); + if (workFlowVersion != null){ + + return R.ok(0); + } + return R.ok(1); + } + } } 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 b135291..0acbb04 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 @@ -9,7 +9,6 @@ import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.github.pagehelper.PageInfo; -import com.mcwl.common.constant.Constants; import com.mcwl.common.constant.DictConstants; import com.mcwl.common.constant.HttpStatus; import com.mcwl.common.core.domain.R; @@ -18,7 +17,6 @@ import com.mcwl.common.core.page.TableDataInfo; import com.mcwl.common.utils.SecurityUtils; import com.mcwl.common.utils.StringUtils; import com.mcwl.common.utils.baidu.BaiduCensor; -import com.mcwl.common.utils.http.HttpUtils; import com.mcwl.resource.domain.ModelProduct; import com.mcwl.resource.domain.ModelVersion; import com.mcwl.resource.domain.SysUserAttention; @@ -42,7 +40,10 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; import org.springframework.stereotype.Service; -import java.util.*; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Objects; /**模型 业务实现层 @@ -301,7 +302,7 @@ public class ModelServiceImpl extends ServiceImpl impl private void audit(RequestModel requestModel) { // 执行审核操作 -// threadPoolTaskExecutor.submit(() -> { + threadPoolTaskExecutor.submit(() -> { ModelProduct modelProduct = requestModel.getModelProduct(); if (modelProduct != null){ @@ -437,41 +438,41 @@ public class ModelServiceImpl extends ServiceImpl impl String key = modelVersion.getObjectKey(); //审核成功,查看时候加密,拉取文件到ui - if (modelVersion.getIsEncrypt() == 1){ +// if (modelVersion.getIsEncrypt() == 1){ +// +// //调用加密/创建参数 +// HashMap param = new HashMap<>(); +// param.put("object_key",modelVersion.getObjectKey()); +// param.put("model_id",modelVersion.getId()+""); +// param.put("file_type", Constants.MODEL); +// +// String s = HttpUtils.pythonPost("http://1.13.246.108:9090/encrypt_and_upload", param); +// +// JSONObject jsonObject = JSONObject.parseObject(s); +// JSONObject data = JSONObject.parseObject(jsonObject.getString("data")); +// String objectKey = data.getString("objectKey"); +// String path = data.getString("path"); +// String secretKey = data.getString("secret_key"); +// +// key = objectKey; +// +// ModelVersion modelVersion1 = ModelVersion.builder().id(modelVersion.getId()) +// .encryptionObjectKey(objectKey) +// .encryptionFilePath(path) +// .keyRate(secretKey).build(); +// //更新加密后数据 +// modelVersionMapper.updateById(modelVersion1); +// } - //调用加密/创建参数 - HashMap param = new HashMap<>(); - param.put("object_key",modelVersion.getObjectKey()); - param.put("model_id",modelVersion.getId()+""); - param.put("file_type", Constants.MODEL); - - String s = HttpUtils.pythonPost("http://1.13.246.108:9090/encrypt_and_upload", param); - - JSONObject jsonObject = JSONObject.parseObject(s); - JSONObject data = JSONObject.parseObject(jsonObject.getString("data")); - String objectKey = data.getString("objectKey"); - String path = data.getString("path"); - String secretKey = data.getString("secret_key"); - - key = objectKey; - - ModelVersion modelVersion1 = ModelVersion.builder().id(modelVersion.getId()) - .encryptionObjectKey(objectKey) - .encryptionFilePath(path) - .keyRate(secretKey).build(); - //更新加密后数据 - modelVersionMapper.updateById(modelVersion1); - } - - //调用ui拉取文件接口 - log.info("开始拉取文件..."); - HashMap hashMap = new HashMap<>(); - hashMap.put("objectKey",key); - log.info("整体版本数据:{}",modelVersion); - log.info("拉取文件数据:{}",key); - hashMap.put("type",DictInit.getDictValue(DictConstants.MODEL_TYPE,modelProduct.getModelType()+"")); - String s = HttpUtils.pythonPost("http://1.13.246.108:8188/api/experiment/models/upload", hashMap); - log.info("文件拉取结果:{}",s); +// //调用ui拉取文件接口 +// log.info("开始拉取文件..."); +// HashMap hashMap = new HashMap<>(); +// hashMap.put("objectKey",key); +// log.info("整体版本数据:{}",modelVersion); +// log.info("拉取文件数据:{}",key); +// hashMap.put("type",DictInit.getDictValue(DictConstants.MODEL_TYPE,modelProduct.getModelType()+"")); +// String s = HttpUtils.pythonPost("http://1.13.246.108:8188/api/experiment/models/upload", hashMap); +// log.info("文件拉取结果:{}",s); //修改为合格 modelProduct.setAuditText(""); @@ -481,7 +482,7 @@ public class ModelServiceImpl extends ServiceImpl impl } } -// }); + }); } diff --git a/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/ReportServiceImpl.java b/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/ReportServiceImpl.java index cc65666..c8791ef 100644 --- a/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/ReportServiceImpl.java +++ b/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/ReportServiceImpl.java @@ -89,7 +89,7 @@ public class ReportServiceImpl implements ReportService { public void updateStatus(Long productId,Integer type,Integer status,String text) { //修改所有同类举报申请 - reportMapper.updateStatus(productId,type); + reportMapper.updateStatus(productId,type,status); if (status == 2){ //修改状态回退 diff --git a/mcwl-resource/src/main/resources/mapper/resource/ModelVersionMapper.xml b/mcwl-resource/src/main/resources/mapper/resource/ModelVersionMapper.xml index c499ea9..a6ec866 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 + is_exclusive_model, sample_image_paths, hide_image_gen_info, del_flag,file_size,file_hash ) VALUES ( @@ -17,7 +17,7 @@ #{isFree}, #{isPublic}, #{isEncrypt}, #{isOnlineUse}, #{allowDownloadImage}, #{allowSoftwareUse}, #{allowFusion}, #{allowCommercialUse}, #{allowUsage}, #{isExclusiveModel}, - #{sampleImagePaths}, #{hideImageGenInfo},'0',#{fileSize} + #{sampleImagePaths}, #{hideImageGenInfo},'0',#{fileSize},#{fileHash} ) @@ -51,5 +51,8 @@ + diff --git a/mcwl-resource/src/main/resources/mapper/resource/ReportMapper.xml b/mcwl-resource/src/main/resources/mapper/resource/ReportMapper.xml index 6432af8..0060e54 100644 --- a/mcwl-resource/src/main/resources/mapper/resource/ReportMapper.xml +++ b/mcwl-resource/src/main/resources/mapper/resource/ReportMapper.xml @@ -7,7 +7,7 @@ UPDATE report - SET status = 0 + SET status = #{status} WHERE product_id = #{productId} and type = #{type} diff --git a/mcwl-resource/src/main/resources/mapper/resource/WorkFlowVersionMapper.xml b/mcwl-resource/src/main/resources/mapper/resource/WorkFlowVersionMapper.xml index ad16fe9..a484879 100644 --- a/mcwl-resource/src/main/resources/mapper/resource/WorkFlowVersionMapper.xml +++ b/mcwl-resource/src/main/resources/mapper/resource/WorkFlowVersionMapper.xml @@ -7,11 +7,11 @@ INSERT INTO work_flow_version (version_name,version_description,file_path,image_paths,hide_gen_info,del_flag, - work_flow_id,file_name,file_size) + work_flow_id,file_name,file_size,file_hash) VALUES (#{item.versionName}, #{item.versionDescription}, #{item.filePath}, #{item.imagePaths},#{item.hideGenInfo}, - 0,#{workFlow.id},#{item.fileName},#{item.fileSize}) + 0,#{workFlow.id},#{item.fileName},#{item.fileSize},#{item.fileHash}) @@ -26,4 +26,8 @@ + +