diff --git a/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/CollectController.java b/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/CollectController.java index a8d9d10..f8e7841 100644 --- a/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/CollectController.java +++ b/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/CollectController.java @@ -4,9 +4,13 @@ import com.mcwl.common.core.domain.R; import com.mcwl.resource.domain.Collect; import com.mcwl.resource.service.impl.CollectServiceImpl; import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; /** * 收藏 @@ -24,6 +28,12 @@ public class CollectController { @Autowired private CollectServiceImpl collectService; + /** + * 添加收藏 + * @param collect + * @return + */ + @ApiOperation(value = "添加收藏") @PostMapping("/addCollect") public R addCollect(@RequestBody Collect collect){ diff --git a/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/DownloadRecordController.java b/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/DownloadRecordController.java new file mode 100644 index 0000000..bd30612 --- /dev/null +++ b/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/DownloadRecordController.java @@ -0,0 +1,79 @@ +package com.mcwl.web.controller.resource; + +import com.mcwl.common.core.domain.R; +import com.mcwl.resource.domain.DownloadRecord; +import com.mcwl.resource.domain.vo.PageVo; +import com.mcwl.resource.service.impl.DownloadRecordServiceImpl; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +/** + * 文件下载记录 + * @author DaiZibo + * @date 2025/3/6 + * @apiNote + */ + + +@Slf4j +@Api(tags = "文件下载记录") +@RestController +@RequestMapping("/downloadRecord") +public class DownloadRecordController { + + + @Autowired + private DownloadRecordServiceImpl downloadRecordService; + + + /** + * 新增下载记录 + * @param downloadRecord + * @return + */ + @ApiOperation(value = "新增下载记录") + @PostMapping("/addDownloadRecord") + public R addDownloadRecord(@RequestBody DownloadRecord downloadRecord){ + + return downloadRecordService.addDownloadRecord(downloadRecord); + } + + /** + * 查询下载记录 + * @param pageVo + * @return + */ + @ApiOperation(value = "下载记录") + @PostMapping("/selectDownloadRecord") + public R selectDownloadRecord(@RequestBody PageVo pageVo){ + + return downloadRecordService.selectDownloadRecord(pageVo); + } + + + /** + * 修改下载状态 + * @return + */ + @ApiOperation(value = "修改下载状态") + @PostMapping("/updateDownloadRecord") + public R updateDownloadRecord(@RequestBody DownloadRecord downloadRecord){ + + return downloadRecordService.updateDownloadRecord(downloadRecord); + } + + /** + * 批量删除下载记录 + * @param ids + * @return + */ + @ApiOperation(value = "批量删除下载记录") + @GetMapping("/deleteDownloadRecord") + public R deleteDownloadRecord(@RequestParam String ids){ + + return downloadRecordService.deleteDownloadRecord(ids); + } +} 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 10b29b9..11ac6bb 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 @@ -4,6 +4,8 @@ import com.mcwl.common.core.domain.AjaxResult; import com.mcwl.common.utils.obs.ObsUtils; import com.mcwl.resource.service.impl.FileServiceImpl; import com.mcwl.web.controller.common.OssUtil; +import com.obs.services.ObsClient; +import com.obs.services.model.*; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; @@ -11,8 +13,10 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; -import java.io.IOException; +import java.io.*; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; /** @@ -35,6 +39,9 @@ public class FileController { @Autowired private ObsUtils obsUtils; + @Autowired + private ObsClient obsClient; + /*** * * 图片 @@ -128,4 +135,120 @@ public class FileController { return AjaxResult.success(); } + + + /** + * 启动上传任务 + */ + @GetMapping("/getUploadId/{objectKey}") + public String getUploadId(@PathVariable("objectKey")String objectKey) { + InitiateMultipartUploadRequest request = new InitiateMultipartUploadRequest("<桶名称>", objectKey); + ObjectMetadata metadata = new ObjectMetadata(); + metadata.addUserMetadata("property", "property-value"); + metadata.setContentType("text/plain"); + request.setMetadata(metadata); + InitiateMultipartUploadResult result = obsClient.initiateMultipartUpload(request); + String uploadId = result.getUploadId(); + return uploadId; + } + + /** + * 分片上传 + */ + @PostMapping("/chunk") + public Map splitFileUpload( + @RequestParam("objectKey")String objectKey, + @RequestParam("file") MultipartFile file, + @RequestParam("chunk") int chunk, + @RequestParam("uploadId") String uploadId) throws Exception { + File file1 = multipartFileToFile(file); + Map map = uploadChunk(uploadId, file1, chunk, objectKey); + return map; + } + + /** + * 合并上传 + */ + @PostMapping("/completeUpload") + public CompleteMultipartUploadResult completeUpload( + @RequestParam("objectKey")String objectKey, + @RequestParam("uploadId") String uploadId, + @RequestBody List> mapList + ) { + List partEtags = new ArrayList<>(); + for(Map map: mapList ){ + PartEtag part1 = new PartEtag(); + part1.setPartNumber(Integer.valueOf(map.get("partNumber"))); + part1.seteTag(map.get("etag")); + partEtags.add(part1); + } + CompleteMultipartUploadRequest request = new CompleteMultipartUploadRequest( + "<桶名称>", objectKey, uploadId, partEtags); + CompleteMultipartUploadResult result = obsClient.completeMultipartUpload(request); + return result; + } + + /** + * 取消任务上传 + */ + @GetMapping("/cancelUpload") + public void cancelUpload( + @RequestParam("objectKey")String objectKey, + @RequestParam("uploadId") String uploadId + ){ + AbortMultipartUploadRequest request = new AbortMultipartUploadRequest("<桶名称>", objectKey, uploadId); + obsClient.abortMultipartUpload(request); + } + + public Map uploadChunk(String uploadId, File file,int chunk, String objectKey){ + // Endpoint以北京四为例,其他地区请按实际情况填写。 + Map map = new HashMap<>(); + UploadPartRequest request = new UploadPartRequest("<桶名称>", objectKey); + request.setUploadId(uploadId); + request.setPartNumber(chunk); + request.setFile(file); + request.setPartSize(5 * 1024 * 1024L); + UploadPartResult result = obsClient.uploadPart(request); + map.put("etag",result.getEtag()); + map.put("partNumber",String.valueOf(result.getPartNumber())); + return map; + } + + /** + * MultipartFile 转 File + * + * @param file + * @throws Exception + */ + public static File multipartFileToFile(MultipartFile file) throws Exception { + + File toFile = null; + if (file.equals("") || file.getSize() <= 0) { + file = null; + } else { + InputStream ins = null; + ins = file.getInputStream(); + toFile = new File(file.getOriginalFilename()); + inputStreamToFile(ins, toFile); + ins.close(); + } + return toFile; + } + + //获取流文件 + private static void inputStreamToFile(InputStream ins, File file) { + try { + OutputStream os = new FileOutputStream(file); + int bytesRead = 0; + byte[] buffer = new byte[8192]; + while ((bytesRead = ins.read(buffer, 0, 8192)) != -1) { + os.write(buffer, 0, bytesRead); + } + os.close(); + ins.close(); + } catch (Exception e) { + e.printStackTrace(); + } + } + } diff --git a/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/ModelVersionController.java b/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/ModelVersionController.java index abc93e4..1e2f9d4 100644 --- a/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/ModelVersionController.java +++ b/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/ModelVersionController.java @@ -6,7 +6,6 @@ import com.mcwl.common.core.page.TableDataInfo; import com.mcwl.resource.domain.ModelVersion; import com.mcwl.resource.service.ModelVersionService; import io.swagger.annotations.Api; -import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @@ -96,7 +95,7 @@ public class ModelVersionController extends BaseController { * @param id * @return */ - @ApiModelProperty(value = "下载模型文件") + @ApiOperation(value = "下载模型文件") @GetMapping("/modelFileDownload") public R modelFileDownload(@RequestParam Long id){ diff --git a/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/ToActivityController.java b/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/ToActivityController.java index e41ef1e..6b94c7f 100644 --- a/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/ToActivityController.java +++ b/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/ToActivityController.java @@ -1,7 +1,6 @@ package com.mcwl.web.controller.resource; import com.mcwl.common.core.controller.BaseController; -import com.mcwl.common.core.domain.AjaxResult; import com.mcwl.common.core.domain.R; import com.mcwl.common.core.page.TableDataInfo; import com.mcwl.resource.domain.ToActivity; @@ -26,7 +25,7 @@ import java.util.List; */ @Api(tags = "活动") @RestController -@RequestMapping("ToActivity") +@RequestMapping("/ToActivity") public class ToActivityController extends BaseController { @Autowired private ToActivityService toActivityService; @@ -38,7 +37,7 @@ public class ToActivityController extends BaseController { @PostMapping("/list") public TableDataInfo list(@RequestBody ToActivity toActivity) { -// startPage(); + List list = toActivityService.selectToActivityList(toActivity); return getDataTable(list); } diff --git a/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/WorkFlowVersionController.java b/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/WorkFlowVersionController.java index 84aba8e..c6a76fd 100644 --- a/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/WorkFlowVersionController.java +++ b/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/WorkFlowVersionController.java @@ -4,7 +4,6 @@ import com.mcwl.common.core.domain.R; import com.mcwl.resource.domain.WorkFlowVersion; import com.mcwl.resource.service.WorkFlowVersionService; import io.swagger.annotations.Api; -import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; @@ -47,7 +46,7 @@ public class WorkFlowVersionController { * @param id * @return */ - @ApiModelProperty("下载工作流") + @ApiOperation("下载工作流") @GetMapping("/workFlowFileDownload") public R workFlowFileDownload(@RequestParam Long id){ diff --git a/mcwl-admin/src/main/resources/application.yml b/mcwl-admin/src/main/resources/application.yml index 9a99fc0..311a165 100644 --- a/mcwl-admin/src/main/resources/application.yml +++ b/mcwl-admin/src/main/resources/application.yml @@ -57,9 +57,9 @@ spring: servlet: multipart: # 单个文件大小 - max-file-size: 1024MB + max-file-size: 40GB # 设置总上传的文件大小 - max-request-size: 1024MB + max-request-size: 40GB # 服务模块 devtools: restart: diff --git a/mcwl-common/src/main/java/com/mcwl/common/utils/obs/ObsUtils.java b/mcwl-common/src/main/java/com/mcwl/common/utils/obs/ObsUtils.java index 714624f..f46abc5 100644 --- a/mcwl-common/src/main/java/com/mcwl/common/utils/obs/ObsUtils.java +++ b/mcwl-common/src/main/java/com/mcwl/common/utils/obs/ObsUtils.java @@ -69,7 +69,7 @@ public class ObsUtils { now.getYear() + "/" + now.getMonth() + "/" + now.getDayOfMonth() + "/" - + uuid + "_" + + uuid + "/" + name; return url; } diff --git a/mcwl-resource/src/main/java/com/mcwl/resource/domain/DownloadRecord.java b/mcwl-resource/src/main/java/com/mcwl/resource/domain/DownloadRecord.java new file mode 100644 index 0000000..ee76c6b --- /dev/null +++ b/mcwl-resource/src/main/java/com/mcwl/resource/domain/DownloadRecord.java @@ -0,0 +1,97 @@ +package com.mcwl.resource.domain; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.springframework.format.annotation.DateTimeFormat; + +import java.util.Date; + +/** + * 下载记录表 + * + * @author DaiZibo + * @date 2025/3/6 + * @apiNote + */ + +@TableName("download_record") +@Builder +@Data +@NoArgsConstructor +@AllArgsConstructor +public class DownloadRecord { + + /** + * 主键ID + */ + @ApiModelProperty(value = "主键ID") + private Long id; + + /** + * 下载作品ID + */ + @ApiModelProperty(value = "下载作品ID") + private Long productId; + + /** + * 下载人ID + */ + @ApiModelProperty(value = "下载人ID") + private Long userId; + + /** + * 作品类型(0模型 1工作流) + */ + @ApiModelProperty(value = "作品类型(0模型 1工作流)") + private Long productType; + + /** + * 文件名字 + */ + @ApiModelProperty(value = "文件名字") + private String fileName; + + /** + * 封面图 + */ + @ApiModelProperty(value = "封面图") + private String cover; + + /** + * 作者名字 + */ + @ApiModelProperty(value = "作者名字") + private String authorName; + + /** + * 网站地址 + */ + @ApiModelProperty(value = "网站地址") + private String website; + + /** + * 文件大小 + */ + @ApiModelProperty(value = "文件大小") + private String fileSize; + + /** + * 状态(下载中,已暂停,下载完成) + */ + @ApiModelProperty(value = "状态(下载中,已暂停,下载完成)") + private Long status; + + /** + * 创建日期 + */ + @DateTimeFormat(pattern = "yyyy-MM-dd") + @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") + @ApiModelProperty(value = "创建日期") + private Date createTime; + +} diff --git a/mcwl-resource/src/main/java/com/mcwl/resource/domain/ModelProduct.java b/mcwl-resource/src/main/java/com/mcwl/resource/domain/ModelProduct.java index 2c68bb2..d55e3ea 100644 --- a/mcwl-resource/src/main/java/com/mcwl/resource/domain/ModelProduct.java +++ b/mcwl-resource/src/main/java/com/mcwl/resource/domain/ModelProduct.java @@ -11,8 +11,6 @@ import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; -import java.util.List; - /** * 模型表 * @Author:ChenYan @@ -144,13 +142,13 @@ public class ModelProduct extends BaseEntity { private Double productPrice; - - /** - * 翻译后标签 - */ - @ApiModelProperty(value = "翻译后标签") - @TableField(exist = false) - private List styleList; +// +// /** +// * 翻译后标签 +// */ +// @ApiModelProperty(value = "翻译后标签") +// @TableField(exist = false) +// private List styleList; /** @@ -161,11 +159,12 @@ public class ModelProduct extends BaseEntity { private Integer isAttention; - /** + /**R * 是否点赞 0未点赞 1点赞 */ @ApiModelProperty(value = "是否点赞 0未点赞 1点赞") @TableField(exist = false) private Integer isLike; + } 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 f35041a..fe6f809 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 @@ -194,5 +194,11 @@ public class ModelVersion extends BaseEntity { @TableField(exist = false) private ArrayList highList; + /** + * 是否收藏 + */ + @ApiModelProperty(value = "是否收藏") + @TableField(exist = false) + private Integer isCollect = 1; } 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 5d148b5..d533006 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 @@ -97,4 +97,11 @@ public class WorkFlowVersion { */ @ApiModelProperty(value = "文件大小") private String fileSize; + + /** + * 是否收藏 + */ + @TableField(exist = false) + @ApiModelProperty(value = "是否收藏") + private Integer isCollect =1; } diff --git a/mcwl-resource/src/main/java/com/mcwl/resource/mapper/CollectMapper.java b/mcwl-resource/src/main/java/com/mcwl/resource/mapper/CollectMapper.java index 40bedec..e0ee250 100644 --- a/mcwl-resource/src/main/java/com/mcwl/resource/mapper/CollectMapper.java +++ b/mcwl-resource/src/main/java/com/mcwl/resource/mapper/CollectMapper.java @@ -15,4 +15,6 @@ import org.apache.ibatis.annotations.Param; public interface CollectMapper extends BaseMapper { Collect selectCollect(@Param("userId") Long userId, @Param("productId") Long productId, @Param("productType") Long productType); + Collect selectCollectById(@Param("modelId") Long modelId, @Param("userIdMax") Long userIdMax, @Param("type") Integer type); + } diff --git a/mcwl-resource/src/main/java/com/mcwl/resource/mapper/DownloadRecordMapper.java b/mcwl-resource/src/main/java/com/mcwl/resource/mapper/DownloadRecordMapper.java new file mode 100644 index 0000000..8c239df --- /dev/null +++ b/mcwl-resource/src/main/java/com/mcwl/resource/mapper/DownloadRecordMapper.java @@ -0,0 +1,17 @@ +package com.mcwl.resource.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.mcwl.resource.domain.DownloadRecord; +import org.apache.ibatis.annotations.Mapper; + +/** + * @author DaiZibo + * @date 2025/3/6 + * @apiNote + */ + +@Mapper +public interface DownloadRecordMapper extends BaseMapper { + void updateDownloadRecord(DownloadRecord downloadRecord); + +} diff --git a/mcwl-resource/src/main/java/com/mcwl/resource/service/CollectService.java b/mcwl-resource/src/main/java/com/mcwl/resource/service/CollectService.java index 9b4521c..5406a8e 100644 --- a/mcwl-resource/src/main/java/com/mcwl/resource/service/CollectService.java +++ b/mcwl-resource/src/main/java/com/mcwl/resource/service/CollectService.java @@ -12,4 +12,6 @@ import com.mcwl.resource.domain.Collect; public interface CollectService { R addCollect(Collect collect); + + Collect selectCollectById(Long modelId, Long userIdMax,Integer type); } diff --git a/mcwl-resource/src/main/java/com/mcwl/resource/service/DownloadRecordService.java b/mcwl-resource/src/main/java/com/mcwl/resource/service/DownloadRecordService.java new file mode 100644 index 0000000..7effcfb --- /dev/null +++ b/mcwl-resource/src/main/java/com/mcwl/resource/service/DownloadRecordService.java @@ -0,0 +1,22 @@ +package com.mcwl.resource.service; + +import com.mcwl.common.core.domain.R; +import com.mcwl.resource.domain.DownloadRecord; +import com.mcwl.resource.domain.vo.PageVo; + +/** + * @author DaiZibo + * @date 2025/3/6 + * @apiNote + */ + + +public interface DownloadRecordService { + R addDownloadRecord(DownloadRecord downloadRecord); + + R selectDownloadRecord(PageVo pageVo); + + R updateDownloadRecord(DownloadRecord downloadRecord); + + R deleteDownloadRecord(String ids); +} diff --git a/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/CollectServiceImpl.java b/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/CollectServiceImpl.java index e87d292..b394831 100644 --- a/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/CollectServiceImpl.java +++ b/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/CollectServiceImpl.java @@ -8,6 +8,8 @@ import com.mcwl.resource.service.CollectService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.Date; + /** * 收藏实现层 * @author DaiZibo @@ -26,7 +28,8 @@ public class CollectServiceImpl implements CollectService { public R addCollect(Collect collect) { Collect collect1 = collectMapper.selectCollect(SecurityUtils.getUserId(),collect.getProductId(),collect.getProductType()); - + collect.setUserId(SecurityUtils.getUserId()); + collect.setCreateTime(new Date()); if (collect1 == null){ //执行收藏 collectMapper.insert(collect); @@ -38,4 +41,10 @@ public class CollectServiceImpl implements CollectService { return R.ok(1); } + + @Override + public Collect selectCollectById(Long modelId, Long userIdMax,Integer type) { + + return collectMapper.selectCollectById(modelId,userIdMax,type); + } } diff --git a/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/DownloadRecordServiceImpl.java b/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/DownloadRecordServiceImpl.java new file mode 100644 index 0000000..f6de285 --- /dev/null +++ b/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/DownloadRecordServiceImpl.java @@ -0,0 +1,138 @@ +package com.mcwl.resource.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +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.*; +import com.mcwl.resource.domain.vo.PageVo; +import com.mcwl.resource.mapper.*; +import com.mcwl.resource.service.DownloadRecordService; +import com.mcwl.system.mapper.SysUserMapper; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.Arrays; +import java.util.Date; +import java.util.List; +import java.util.stream.Collectors; + +/** + * 下载记录实现层 + * + * @author DaiZibo + * @date 2025/3/6 + * @apiNote + */ + +@Service +public class DownloadRecordServiceImpl implements DownloadRecordService { + + @Autowired + private DownloadRecordMapper downloadRecordMapper; + + @Autowired + private ModelVersionMapper modelVersionMapper; + + @Autowired + private WorkFlowVersionMapper workFlowVersionMapper; + + @Autowired + private WorkFlowMapper workFlowMapper; + + @Autowired + private SysUserMapper sysUserMapper; + + @Autowired + private ModelMapper modelMapper; + + @Override + public R addDownloadRecord(DownloadRecord downloadRecord) { + + //获取下载人 + 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()); + + //根据版本查找封面信息 + ModelProduct modelProduct = modelMapper.selectById(modelVersion.getModelId()); + downloadRecord.setCover(modelProduct.getSurfaceUrl()); + + //查询作者信息 + 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()); + + //查询作者信息 + SysUser sysUser = sysUserMapper.selectUserById(workFlow.getUserId()); + downloadRecord.setAuthorName(sysUser.getNickName()); + + } + + downloadRecordMapper.insert(downloadRecord); + + return R.ok(); + } + + @Override + public R selectDownloadRecord(PageVo pageVo) { + + //分页查询数据 + Page page = new Page<>(); + page.setSize(pageVo.getPageSize()); + page.setPages(pageVo.getPageNumber()); + + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(DownloadRecord::getUserId,SecurityUtils.getUserId()); + wrapper.eq(pageVo.getType() != null,DownloadRecord::getProductType,pageVo.getType()); + + Page downloadRecordPage = downloadRecordMapper.selectPage(page, wrapper); + + return R.ok(downloadRecordPage); + } + + @Override + public R updateDownloadRecord(DownloadRecord downloadRecord) { + + downloadRecordMapper.updateDownloadRecord(downloadRecord); + + return R.ok(); + } + + @Override + public R deleteDownloadRecord(String ids) { + + if (StringUtils.isNotBlank(ids)) { + List idList = Arrays.stream(ids.split(",")) + .filter(StringUtils::isNotBlank) + .map(Long::valueOf) + .collect(Collectors.toList()); + + if (!idList.isEmpty()) { + downloadRecordMapper.deleteBatchIds(idList); + } + return R.ok(); + } + + return R.fail("请选择要删除的数据"); + } +} 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 c000fd6..f1773f7 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 @@ -11,6 +11,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; /** + * 文件实现层 * @author DaiZibo * @date 2025/2/14 * @apiNote 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 05c37c4..b135291 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 @@ -467,6 +467,8 @@ public class ModelServiceImpl extends ServiceImpl impl 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); @@ -502,16 +504,17 @@ public class ModelServiceImpl extends ServiceImpl impl //标签 - if (StringUtils.isNotEmpty(modelProduct.getTags())){ - ArrayList strings = new ArrayList<>(); - String[] split = modelProduct.getTags().split(","); - for (String s : split) { - if (s != ""){ - strings.add(s); - } - } - modelProduct.setStyleList(strings); - } +// if (StringUtils.isNotEmpty(modelProduct.getTags())){ +// ArrayList strings = new ArrayList<>(); +// String[] split = modelProduct.getTags().split(","); +// for (String s : split) { +// if (s != ""){ +// strings.add(s); +// } +// } +// modelProduct.setStyleList(strings); +// } +// modelProduct.setStyleList(new ArrayList<>()); //功能 if (StringUtils.isNotEmpty(modelProduct.getFunctions())){ diff --git a/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/ModelVersionServiceImpl.java b/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/ModelVersionServiceImpl.java index 78b4731..8bbe8c1 100644 --- a/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/ModelVersionServiceImpl.java +++ b/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/ModelVersionServiceImpl.java @@ -4,8 +4,11 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.mcwl.common.constant.DictConstants; import com.mcwl.common.core.domain.R; +import com.mcwl.common.utils.SecurityUtils; import com.mcwl.common.utils.StringUtils; +import com.mcwl.resource.domain.Collect; import com.mcwl.resource.domain.ModelVersion; +import com.mcwl.resource.mapper.ModelMapper; import com.mcwl.resource.mapper.ModelVersionMapper; import com.mcwl.resource.service.ModelVersionService; import com.mcwl.system.init.DictInit; @@ -29,6 +32,12 @@ public class ModelVersionServiceImpl extends ServiceImpl< ModelVersionMapper,Mo @Autowired private ModelVersionService modelVersionService; + @Autowired + private CollectServiceImpl collectService; + + @Autowired + private ModelMapper modelMapper; + @Autowired private ModelVersionMapper modelVersionMapper; @@ -87,9 +96,23 @@ public class ModelVersionServiceImpl extends ServiceImpl< ModelVersionMapper,Mo List modelVersions = baseMapper.selectList(modelVersionLambdaQueryWrapper); -// for (ModelVersion modelVersion : modelVersions) { -// -// } + Long userIdMax = SecurityUtils.getUserIdMax(); + if (userIdMax != 0){ + + for (ModelVersion modelVersion : modelVersions) { + modelVersion.setFilePath(""); + modelVersion.setEncryptionFilePath(""); + //模型字典 0 工作流字典 1 + Integer type = 0; + //校验是否收藏 + Collect collect = collectService.selectCollectById(modelVersion.getModelId(),userIdMax,type); + if (collect != null ){ + modelVersion.setIsCollect(0); + } + } + + } + return modelVersions; } @@ -98,11 +121,19 @@ public class ModelVersionServiceImpl extends ServiceImpl< ModelVersionMapper,Mo public R modelFileDownload(Long id) { ModelVersion modelVersion = modelVersionMapper.selectById(id); + + if (modelVersion == null){ + return R.fail("文件为空"); + } + if (modelVersion.getAllowDownloadImage().equals(0)){ return R.fail("此文件不可下载"); } - return R.ok(); + if (modelVersion.getIsEncrypt() == 1){ + return R.ok(modelVersion.getEncryptionFilePath()); + } + return R.ok(modelVersion.getFilePath(),modelVersion.getFileName()); } 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 a02931c..67d9656 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 @@ -334,6 +334,7 @@ public class WorkFlowServiceImpl extends ServiceImpl i LambdaQueryWrapper lambdaQueryWrapper = Wrappers.lambdaQuery() .like(StringUtils.isNotBlank(pageVo.getName()), WorkFlow::getWorkflowName, pageVo.getName()) + .eq(WorkFlow::getAuditStatus,1) .eq(WorkFlow::getDelFlag, 0); if (pageVo.getOrder() == 1) { diff --git a/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/WorkFlowVersionServiceImpl.java b/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/WorkFlowVersionServiceImpl.java index 8adfd5b..eb677d5 100644 --- a/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/WorkFlowVersionServiceImpl.java +++ b/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/WorkFlowVersionServiceImpl.java @@ -2,6 +2,8 @@ package com.mcwl.resource.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.mcwl.common.core.domain.R; +import com.mcwl.common.utils.SecurityUtils; +import com.mcwl.resource.domain.Collect; import com.mcwl.resource.domain.WorkFlow; import com.mcwl.resource.domain.WorkFlowVersion; import com.mcwl.resource.mapper.WorkFlowMapper; @@ -14,6 +16,7 @@ import java.util.List; /** * 工作流版本 业务实现层 + * * @author DaiZibo * @date 2025/1/9 * @apiNote @@ -28,33 +31,50 @@ public class WorkFlowVersionServiceImpl implements WorkFlowVersionService { @Autowired private WorkFlowMapper workFlowMapper; + @Autowired + private CollectServiceImpl collectService; + + @Override public R> selectVersionByWorkId(Long workId) { LambdaQueryWrapper workFlowVersionLambdaQueryWrapper = new LambdaQueryWrapper<>(); - workFlowVersionLambdaQueryWrapper.eq(WorkFlowVersion::getDelFlag,0); - workFlowVersionLambdaQueryWrapper.eq(WorkFlowVersion::getWorkFlowId,workId); + workFlowVersionLambdaQueryWrapper.eq(WorkFlowVersion::getDelFlag, 0); + workFlowVersionLambdaQueryWrapper.eq(WorkFlowVersion::getWorkFlowId, workId); List workFlowVersions = workFlowVersionMapper.selectList(workFlowVersionLambdaQueryWrapper); + Long userIdMax = SecurityUtils.getUserIdMax(); + if (userIdMax != 0) { + for (WorkFlowVersion workFlowVersion : workFlowVersions) { + workFlowVersion.setFilePath(""); + //模型字典 0 工作流字典 1 + Integer type = 0; + //校验是否收藏 + Collect collect = collectService.selectCollectById(workFlowVersion.getWorkFlowId(), userIdMax, type); + if (collect != null) { + workFlowVersion.setIsCollect(0); + } + } + } return R.ok(workFlowVersions); - } +} @Override public R workFlowFileDownload(Long id) { //查找数据 WorkFlowVersion workFlowVersion = workFlowVersionMapper.selectById(id); - if (workFlowVersion == null){ + if (workFlowVersion == null) { return R.fail("文件不存在"); } WorkFlow workFlow = workFlowMapper.selectById(workFlowVersion.getWorkFlowId()); - if (workFlow.getDownload().equals(1)){ + if (workFlow.getDownload().equals(1)) { return R.fail("该文件不允许下载"); } - return R.ok(workFlowVersion.getFilePath()); + return R.ok(workFlowVersion.getFilePath(), workFlowVersion.getFileName()); } } diff --git a/mcwl-resource/src/main/resources/mapper/resource/CollectMapper.xml b/mcwl-resource/src/main/resources/mapper/resource/CollectMapper.xml index bda0de4..c2324a8 100644 --- a/mcwl-resource/src/main/resources/mapper/resource/CollectMapper.xml +++ b/mcwl-resource/src/main/resources/mapper/resource/CollectMapper.xml @@ -10,4 +10,10 @@ FROM collect where product_id = #{productId} and user_id = #{userId} and product_type = #{productType} + + diff --git a/mcwl-resource/src/main/resources/mapper/resource/DownloadRecordMapper.xml b/mcwl-resource/src/main/resources/mapper/resource/DownloadRecordMapper.xml new file mode 100644 index 0000000..362f921 --- /dev/null +++ b/mcwl-resource/src/main/resources/mapper/resource/DownloadRecordMapper.xml @@ -0,0 +1,14 @@ + + + + + + + UPDATE download_record + SET file_size = #{fileSize}, + status = #{status} + WHERE id = #{id} + + diff --git a/mcwl-resource/src/main/resources/mapper/resource/ModelMapper.xml b/mcwl-resource/src/main/resources/mapper/resource/ModelMapper.xml index 9f1db12..cb82366 100644 --- a/mcwl-resource/src/main/resources/mapper/resource/ModelMapper.xml +++ b/mcwl-resource/src/main/resources/mapper/resource/ModelMapper.xml @@ -93,6 +93,7 @@ LEFT JOIN sys_user as u on m.user_id = u.user_id WHERE m.del_flag = 0 + and audit_status = 1 and m.model_name like CONCAT('%', #{name}, '%') diff --git a/mcwl-system/src/main/java/com/mcwl/system/service/impl/SysUserServiceImpl.java b/mcwl-system/src/main/java/com/mcwl/system/service/impl/SysUserServiceImpl.java index 4331292..9892e3e 100644 --- a/mcwl-system/src/main/java/com/mcwl/system/service/impl/SysUserServiceImpl.java +++ b/mcwl-system/src/main/java/com/mcwl/system/service/impl/SysUserServiceImpl.java @@ -612,9 +612,10 @@ public class SysUserServiceImpl implements ISysUserService @Override public SysUser selectUserInfoById(Long userId) { SysUser sysUser = userMapper.selectUserInfoById(userId); - - SysUser sysUser1 = selectUserById(sysUser.getInviterUserId()); - sysUser.setInvitationName(sysUser1.getNickName()); + if (sysUser.getInviterUserId() != null){ + SysUser sysUser1 = selectUserById(sysUser.getInviterUserId()); + sysUser.setInvitationName(sysUser1.getNickName()); + } return sysUser; }