Compare commits

..

No commits in common. "a87d8c2295463fce94aee04f2a3ae94571711ea2" and "53fcee7adad8f6554648f833465291b15701955c" have entirely different histories.

17 changed files with 142 additions and 181 deletions

View File

@ -4,10 +4,10 @@ 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.domain.request.RequestFile;
import com.mcwl.resource.domain.vo.FileVo;
import com.mcwl.resource.service.impl.FileServiceImpl;
import com.mcwl.web.controller.common.OssUtil;
import com.obs.services.ObsClient;
import com.obs.services.exception.ObsException;
import com.obs.services.model.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -116,20 +116,22 @@ public class FileController {
/**
*
* @param name
* @param type
* @return
*/
@PostMapping("/selectFileName")
@GetMapping("/selectFileName")
@ApiOperation(value = "根据文件名查找是否存在并返回秘钥")
public AjaxResult selectFileName(@RequestBody FileVo fileVo){
public AjaxResult selectFileName(@RequestParam String name,String type){
return fileService.selectFileName(fileVo.getName(), fileVo.getType());
return fileService.selectFileName(name,type);
}
@PostMapping("/selectFile")
@GetMapping("/selectFile")
@ApiOperation(value = "根据文件名查找是否存在")
public AjaxResult selectFile(@RequestBody FileVo fileVo){
public AjaxResult selectFile(@RequestParam String name,String type){
return fileService.selectFile(fileVo.getName(), fileVo.getType());
return fileService.selectFile(name,type);
}
@GetMapping("/download")
@ -292,4 +294,44 @@ public class FileController {
}
@GetMapping("/test")
public R test(@RequestParam String filePath,String objectkey){
try {
UploadFileRequest request = new UploadFileRequest(bucketName, objectkey);
// 设置待上传的本地文件localfile为待上传的本地文件路径需要指定到具体带文件后缀的文件名
request.setUploadFile(filePath);
// 设置分段上传时的最大并发数
request.setTaskNum(5);
// 设置分段大小为10MB
request.setPartSize(10 * 1024 * 1024);
// 开启断点续传模式
request.setEnableCheckpoint(true);
// 进行断点续传上传
CompleteMultipartUploadResult result = obsClient.uploadFile(request);
log.info("上传完成:{}",result);
System.out.println("UploadFile successfully");
} catch (ObsException e) {
// 发生异常时可再次调用断点续传上传接口进行重新上传
System.out.println("UploadFile 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("UploadFile failed");
// 其他异常信息打印
e.printStackTrace();
}
return R.ok();
}
}

View File

@ -2,6 +2,7 @@ package com.mcwl.web.controller.resource;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.github.pagehelper.PageInfo;
import com.mcwl.common.constant.HttpStatus;
import com.mcwl.common.core.controller.BaseController;
import com.mcwl.common.core.domain.AjaxResult;
import com.mcwl.common.core.domain.R;
@ -117,21 +118,21 @@ public class MallProductController extends BaseController {
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,"文件内容重复");
// }
// }
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();

View File

@ -2,9 +2,11 @@ package com.mcwl.web.controller.resource;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.pagehelper.PageInfo;
import com.mcwl.common.constant.HttpStatus;
import com.mcwl.common.core.controller.BaseController;
import com.mcwl.common.core.domain.R;
import com.mcwl.resource.domain.WorkFlow;
import com.mcwl.resource.domain.WorkFlowVersion;
import com.mcwl.resource.domain.dto.AddRequestWorkFlow;
import com.mcwl.resource.domain.request.RequestWorkFlow;
import com.mcwl.resource.domain.response.ResponseWorkFlow;
@ -99,21 +101,21 @@ public class WorkFlowController extends BaseController {
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,"文件内容重复");
// }
// }
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);

View File

@ -180,7 +180,7 @@ mqtt:
#用户头像与背景
mcwl:
encryptUrl: http://113.45.190.154:9090/encryptAndUpload
encryptUrl: http://113.45.190.154:9090/encrypt_and_upload
user:
avatar: https://ybl2112.oss-cn-beijing.aliyuncs.com/2025/MARCH/10/7/53/3f5cc1d7-b062-4a22-9f7e-d442bc6dcf42.png
backgroundImg: https://ybl2112.oss-cn-beijing.aliyuncs.com/2025/MARCH/10/8/2/c8387681-8138-4a29-a1c9-4a143da34c5a.png

View File

@ -1,17 +1,15 @@
package com.mcwl.framework.interceptor;
import com.alibaba.fastjson2.JSON;
import com.mcwl.common.annotation.RepeatSubmit;
import com.mcwl.common.constant.HttpStatus;
import com.mcwl.common.core.domain.AjaxResult;
import com.mcwl.common.utils.ServletUtils;
import java.lang.reflect.Method;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Component;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.HandlerInterceptor;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.lang.reflect.Method;
import com.alibaba.fastjson2.JSON;
import com.mcwl.common.annotation.RepeatSubmit;
import com.mcwl.common.core.domain.AjaxResult;
import com.mcwl.common.utils.ServletUtils;
/**
*
@ -33,7 +31,7 @@ public abstract class RepeatSubmitInterceptor implements HandlerInterceptor
{
if (this.isRepeatSubmit(request, annotation))
{
AjaxResult ajaxResult = AjaxResult.error(HttpStatus.SHOW_ERROR_MSG,annotation.message());
AjaxResult ajaxResult = AjaxResult.error(annotation.message());
ServletUtils.renderString(response, JSON.toJSONString(ajaxResult));
return false;
}

View File

@ -198,14 +198,7 @@ public class ModelVersion extends BaseEntity {
*/
@ApiModelProperty(value = "是否收藏")
@TableField(exist = false)
private Integer isCollect;
/**
*
*/
@ApiModelProperty(value = "是否下载")
@TableField(exist = false)
private Integer isDownload;
private Integer isCollect = 0;
/**
* hash
@ -213,10 +206,4 @@ public class ModelVersion extends BaseEntity {
@ApiModelProperty(value = "文件hash")
private String fileHash;
@ApiModelProperty(value = "加密后文件新名字")
private String encryptionFileName;
@ApiModelProperty(value = "加密后文件大小")
private String encryptionFileSize;
}

View File

@ -47,11 +47,6 @@ public class RequestFile {
/**
*
*/
private String encryptionFileSize;
/**
*
*/
private String encryptionFileName;
private String encryptFileSize;
}

View File

@ -32,12 +32,6 @@ public class ResponseCollect {
@ApiModelProperty(value = "文件名")
private String fileName;
@ApiModelProperty(value = "加密后文件名")
private String encryptionFileName;
@ApiModelProperty(value = "是否加密 0不加密 1加密")
private Integer isEncrypt;
@ApiModelProperty(value = "模型名")
private String productName;
@ -59,6 +53,6 @@ public class ResponseCollect {
private Integer isDownload;
@ApiModelProperty(value = "触发词")
private String triggerWords;
private String triggerWords = "-";
}

View File

@ -1,28 +0,0 @@
package com.mcwl.resource.domain.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
*
*
* @author DaiZibo
* @date 2025/3/22
* @apiNote
*/
@NoArgsConstructor
@AllArgsConstructor
@Data
public class FileVo {
@ApiModelProperty("文件名字")
private String name;
@ApiModelProperty("文件类型 model/workflow")
private String type;
}

View File

@ -27,6 +27,4 @@ public interface ModelVersionMapper extends BaseMapper<ModelVersion> {
ModelVersion selectByProductId(@Param("id") Long id);
ModelVersion selectByEncryptionFileName(@Param("name") String name);
}

View File

@ -78,17 +78,9 @@ public class CollectServiceImpl implements CollectService {
//校验是否下载
for (ResponseCollect collect : responseCollectList) {
//校验是否加密
if (collect.getIsEncrypt() == 1){
collect.setFileName(collect.getEncryptionFileName());
}
collect.setIsDownload(downloadRecordService.selectDownloadByUser(userIdMax,collect.getId(),0));
//翻译类型
collect.setType(DictInit.getDictValue(DictConstants.MODE_VERSION_TYPE,collect.getType()));
if (collect.getTriggerWords() == null){
collect.setTriggerWords("-");
}
}
return R.ok(responseCollectList);

View File

@ -5,9 +5,10 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mcwl.common.constant.DictConstants;
import com.mcwl.common.constant.HttpStatus;
import com.mcwl.common.core.domain.R;
import com.mcwl.common.core.domain.entity.SysUser;
import com.mcwl.common.utils.SecurityUtils;
import com.mcwl.common.utils.StringUtils;
import com.mcwl.resource.domain.DownloadRecord;
import com.mcwl.resource.domain.*;
import com.mcwl.resource.domain.request.RequestDownload;
import com.mcwl.resource.domain.vo.PageVo;
import com.mcwl.resource.mapper.*;
@ -58,43 +59,43 @@ public class DownloadRecordServiceImpl implements DownloadRecordService {
downloadRecord.setUserId(SecurityUtils.getUserId());
downloadRecord.setCreateTime(new Date());
// //获取作品信息
// if (downloadRecord.getProductType() == 0){
//
// //查询文件/名称信息
// ModelVersion modelVersion = modelVersionMapper.selectById(downloadRecord.getProductId());
// downloadRecord.setFileName(modelVersion.getFileName());
// downloadRecord.setFileSize(modelVersion.getFileSize());
// downloadRecord.setModelVersionType(modelVersion.getModelVersionType()+"");
//
// //根据版本查找封面信息
// ModelProduct modelProduct = modelMapper.selectById(modelVersion.getModelId());
// downloadRecord.setCover(modelProduct.getSurfaceUrl());
// downloadRecord.setProductName(modelProduct.getModelName());
//
// //查询作者信息
// SysUser sysUser = sysUserMapper.selectUserById(modelProduct.getUserId());
// downloadRecord.setAuthorName(sysUser.getNickName());
//
// }else {
//
// //查询文件/名称信息
// WorkFlowVersion workFlowVersion = workFlowVersionMapper.selectById(downloadRecord.getProductId());
// downloadRecord.setFileName(workFlowVersion.getFileName());
// downloadRecord.setFileSize(workFlowVersion.getFileSize());
//
//
// //根据版本查找封面信息
// WorkFlow workFlow = workFlowMapper.selectById(workFlowVersion.getWorkFlowId());
// downloadRecord.setCover(workFlow.getCoverPath());
// downloadRecord.setProductName(workFlow.getWorkflowName());
//
//
// //查询作者信息
// SysUser sysUser = sysUserMapper.selectUserById(workFlow.getUserId());
// downloadRecord.setAuthorName(sysUser.getNickName());
//
// }
//获取作品信息
if (downloadRecord.getProductType() == 0){
//查询文件/名称信息
ModelVersion modelVersion = modelVersionMapper.selectById(downloadRecord.getProductId());
downloadRecord.setFileName(modelVersion.getFileName());
downloadRecord.setFileSize(modelVersion.getFileSize());
downloadRecord.setModelVersionType(modelVersion.getModelVersionType()+"");
//根据版本查找封面信息
ModelProduct modelProduct = modelMapper.selectById(modelVersion.getModelId());
downloadRecord.setCover(modelProduct.getSurfaceUrl());
downloadRecord.setProductName(modelProduct.getModelName());
//查询作者信息
SysUser sysUser = sysUserMapper.selectUserById(modelProduct.getUserId());
downloadRecord.setAuthorName(sysUser.getNickName());
}else {
//查询文件/名称信息
WorkFlowVersion workFlowVersion = workFlowVersionMapper.selectById(downloadRecord.getProductId());
downloadRecord.setFileName(workFlowVersion.getFileName());
downloadRecord.setFileSize(workFlowVersion.getFileSize());
//根据版本查找封面信息
WorkFlow workFlow = workFlowMapper.selectById(workFlowVersion.getWorkFlowId());
downloadRecord.setCover(workFlow.getCoverPath());
downloadRecord.setProductName(workFlow.getWorkflowName());
//查询作者信息
SysUser sysUser = sysUserMapper.selectUserById(workFlow.getUserId());
downloadRecord.setAuthorName(sysUser.getNickName());
}
downloadRecordMapper.insert(downloadRecord);

View File

@ -38,7 +38,7 @@ public class FileServiceImpl implements FileService {
if (type.equals("model")) {
ModelVersion modelVersion = versionMapper.selectByEncryptionFileName(name);
ModelVersion modelVersion = versionMapper.selectByFileName(name);
if (modelVersion == null) {
return AjaxResult.error("文件不存在");
@ -121,9 +121,7 @@ public class FileServiceImpl implements FileService {
ModelVersion modelVersion = ModelVersion.builder().id(requestFile.getId())
.keyRate(requestFile.getKeyRate())
.encryptionFilePath(requestFile.getEncryptionFilePath())
.encryptionObjectKey(requestFile.getEncryptionObjectKey())
.encryptionFileName(requestFile.getEncryptionFileName())
.encryptionFileSize(requestFile.getEncryptionFileSize()).build();
.encryptionObjectKey(requestFile.getEncryptionObjectKey()).build();
versionMapper.updateById(modelVersion);

View File

@ -27,7 +27,10 @@ import com.mcwl.resource.domain.response.ResponseModelProduct;
import com.mcwl.resource.domain.vo.MallProductVo;
import com.mcwl.resource.domain.vo.ModelVo;
import com.mcwl.resource.domain.vo.PageVo;
import com.mcwl.resource.mapper.*;
import com.mcwl.resource.mapper.ModelLikeMapper;
import com.mcwl.resource.mapper.ModelMapper;
import com.mcwl.resource.mapper.ModelVersionMapper;
import com.mcwl.resource.mapper.SysUserAttentionMapper;
import com.mcwl.resource.service.ModelService;
import com.mcwl.resource.service.ToActivityService;
import com.mcwl.system.init.DictInit;
@ -62,8 +65,6 @@ public class ModelServiceImpl extends ServiceImpl<ModelMapper,ModelProduct> impl
@Autowired
private ISysUserService sysUserService;
@Autowired
private DownloadRecordServiceImpl downloadRecordService;
@Autowired
private ThreadPoolTaskExecutor threadPoolTaskExecutor;
@ -130,9 +131,6 @@ public class ModelServiceImpl extends ServiceImpl<ModelMapper,ModelProduct> impl
if (userIdMax == 0){
//收藏为空
modelVersion.setIsCollect(0);
//下载为空
modelVersion.setIsDownload(0);
}else {
//查询是否收藏
Collect collect = collectService.selectCollectById(modelVersion.getId(), userIdMax, 0);
@ -144,9 +142,6 @@ public class ModelServiceImpl extends ServiceImpl<ModelMapper,ModelProduct> impl
modelVersion.setIsCollect(1);
}
//校验是否下载
modelVersion.setIsDownload(downloadRecordService.selectDownloadByUser(userIdMax,modelVersion.getModelId(),0));
}
responseModelProduct.setModelVersion(modelVersion);
@ -278,7 +273,6 @@ public class ModelServiceImpl extends ServiceImpl<ModelMapper,ModelProduct> impl
//校验是否实名
SysUser sysUser = sysUserService.selectUserInfoById(SecurityUtils.getUserId());
log.info("查询到的个人数据:{}",sysUser);
if (StringUtils.isEmpty(sysUser.getName())){
return R.fail(HttpStatus.SHOW_ERROR_MSG,"实名制后才可以发布");

View File

@ -100,14 +100,9 @@ public class ModelVersionServiceImpl extends ServiceImpl< ModelVersionMapper,Mo
Long userIdMax = SecurityUtils.getUserIdMax();
if (userIdMax != 0){
//擦掉敏感数据
for (ModelVersion modelVersion : modelVersions) {
modelVersion.setObjectKey("");
modelVersion.setEncryptionObjectKey("");
modelVersion.setFilePath("");
modelVersion.setEncryptionFilePath("");
modelVersion.setKeyRate("");
//模型字典 0 工作流字典 1
Integer type = 0;
//校验是否收藏
@ -139,11 +134,7 @@ public class ModelVersionServiceImpl extends ServiceImpl< ModelVersionMapper,Mo
}
if (modelVersion.getIsEncrypt() == 1){
if (StringUtils.isEmpty(modelVersion.getEncryptionFilePath())){
return R.fail(HttpStatus.SHOW_ERROR_MSG,"该模型加密未完成,请稍后再试");
}
return R.ok(modelVersion.getEncryptionFilePath(),modelVersion.getEncryptionFileName());
return R.ok(modelVersion.getEncryptionFilePath());
}
return R.ok(modelVersion.getFilePath(),modelVersion.getFileName());
}

View File

@ -26,8 +26,7 @@
</select>
<select id="selectCollectModel" resultType="com.mcwl.resource.domain.response.ResponseCollect">
SELECT c.product_id as id,m.surface_url as file_path,v.file_name,m.model_name as product_name,u.nick_name,
v.file_size,c.create_time,v.model_version_type as type,v.trigger_words,v.is_encrypt,v.encryption_file_name
SELECT c.product_id as id,m.surface_url as file_path,v.file_name,m.model_name as product_name,u.nick_name,v.file_size,c.create_time,v.model_version_type as type,v.trigger_words
FROM collect as c
LEFT JOIN model_version as v on c.product_id = v.id
LEFT JOIN model as m on v.model_id = m.id

View File

@ -58,8 +58,5 @@
<select id="selectByProductId" resultType="com.mcwl.resource.domain.ModelVersion">
SELECT * FROM model_version WHERE model_id = #{id} LIMIT 1
</select>
<select id="selectByEncryptionFileName" resultType="com.mcwl.resource.domain.ModelVersion">
select key_rate,is_encrypt from model_version where encryption_file_name = #{name}
</select>
</mapper>