联调工作流/模型

新增下载记录
新增查看下载记录
新增批量删除下载记录
联调收藏模型/工作流
master
Diyu0904 2025-03-07 13:21:43 +08:00
parent 87cc661a7f
commit daa17a6caa
27 changed files with 632 additions and 46 deletions

View File

@ -4,9 +4,13 @@ import com.mcwl.common.core.domain.R;
import com.mcwl.resource.domain.Collect; import com.mcwl.resource.domain.Collect;
import com.mcwl.resource.service.impl.CollectServiceImpl; import com.mcwl.resource.service.impl.CollectServiceImpl;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; 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 @Autowired
private CollectServiceImpl collectService; private CollectServiceImpl collectService;
/**
*
* @param collect
* @return
*/
@ApiOperation(value = "添加收藏")
@PostMapping("/addCollect") @PostMapping("/addCollect")
public R addCollect(@RequestBody Collect collect){ public R addCollect(@RequestBody Collect collect){

View File

@ -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);
}
}

View File

@ -4,6 +4,8 @@ import com.mcwl.common.core.domain.AjaxResult;
import com.mcwl.common.utils.obs.ObsUtils; import com.mcwl.common.utils.obs.ObsUtils;
import com.mcwl.resource.service.impl.FileServiceImpl; import com.mcwl.resource.service.impl.FileServiceImpl;
import com.mcwl.web.controller.common.OssUtil; 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.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; 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.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import java.io.IOException; import java.io.*;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
@ -35,6 +39,9 @@ public class FileController {
@Autowired @Autowired
private ObsUtils obsUtils; private ObsUtils obsUtils;
@Autowired
private ObsClient obsClient;
/*** /***
* *
* *
@ -128,4 +135,120 @@ public class FileController {
return AjaxResult.success(); 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<String,String> splitFileUpload(
@RequestParam("objectKey")String objectKey,
@RequestParam("file") MultipartFile file,
@RequestParam("chunk") int chunk,
@RequestParam("uploadId") String uploadId) throws Exception {
File file1 = multipartFileToFile(file);
Map<String,String> map = uploadChunk(uploadId, file1, chunk, objectKey);
return map;
}
/**
*
*/
@PostMapping("/completeUpload")
public CompleteMultipartUploadResult completeUpload(
@RequestParam("objectKey")String objectKey,
@RequestParam("uploadId") String uploadId,
@RequestBody List<Map<String,String>> mapList
) {
List<PartEtag> partEtags = new ArrayList<>();
for(Map<String,String> 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<String,String> uploadChunk(String uploadId, File file,int chunk, String objectKey){
// Endpoint以北京四为例其他地区请按实际情况填写。
Map<String,String> 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();
}
}
} }

View File

@ -6,7 +6,6 @@ import com.mcwl.common.core.page.TableDataInfo;
import com.mcwl.resource.domain.ModelVersion; import com.mcwl.resource.domain.ModelVersion;
import com.mcwl.resource.service.ModelVersionService; import com.mcwl.resource.service.ModelVersionService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -96,7 +95,7 @@ public class ModelVersionController extends BaseController {
* @param id * @param id
* @return * @return
*/ */
@ApiModelProperty(value = "下载模型文件") @ApiOperation(value = "下载模型文件")
@GetMapping("/modelFileDownload") @GetMapping("/modelFileDownload")
public R modelFileDownload(@RequestParam Long id){ public R modelFileDownload(@RequestParam Long id){

View File

@ -1,7 +1,6 @@
package com.mcwl.web.controller.resource; package com.mcwl.web.controller.resource;
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.R; import com.mcwl.common.core.domain.R;
import com.mcwl.common.core.page.TableDataInfo; import com.mcwl.common.core.page.TableDataInfo;
import com.mcwl.resource.domain.ToActivity; import com.mcwl.resource.domain.ToActivity;
@ -26,7 +25,7 @@ import java.util.List;
*/ */
@Api(tags = "活动") @Api(tags = "活动")
@RestController @RestController
@RequestMapping("ToActivity") @RequestMapping("/ToActivity")
public class ToActivityController extends BaseController { public class ToActivityController extends BaseController {
@Autowired @Autowired
private ToActivityService toActivityService; private ToActivityService toActivityService;
@ -38,7 +37,7 @@ public class ToActivityController extends BaseController {
@PostMapping("/list") @PostMapping("/list")
public TableDataInfo list(@RequestBody ToActivity toActivity) public TableDataInfo list(@RequestBody ToActivity toActivity)
{ {
// startPage();
List<ToActivity> list = toActivityService.selectToActivityList(toActivity); List<ToActivity> list = toActivityService.selectToActivityList(toActivity);
return getDataTable(list); return getDataTable(list);
} }

View File

@ -4,7 +4,6 @@ import com.mcwl.common.core.domain.R;
import com.mcwl.resource.domain.WorkFlowVersion; import com.mcwl.resource.domain.WorkFlowVersion;
import com.mcwl.resource.service.WorkFlowVersionService; import com.mcwl.resource.service.WorkFlowVersionService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
@ -47,7 +46,7 @@ public class WorkFlowVersionController {
* @param id * @param id
* @return * @return
*/ */
@ApiModelProperty("下载工作流") @ApiOperation("下载工作流")
@GetMapping("/workFlowFileDownload") @GetMapping("/workFlowFileDownload")
public R workFlowFileDownload(@RequestParam Long id){ public R workFlowFileDownload(@RequestParam Long id){

View File

@ -57,9 +57,9 @@ spring:
servlet: servlet:
multipart: multipart:
# 单个文件大小 # 单个文件大小
max-file-size: 1024MB max-file-size: 40GB
# 设置总上传的文件大小 # 设置总上传的文件大小
max-request-size: 1024MB max-request-size: 40GB
# 服务模块 # 服务模块
devtools: devtools:
restart: restart:

View File

@ -69,7 +69,7 @@ public class ObsUtils {
now.getYear() + "/" + now.getYear() + "/" +
now.getMonth() + "/" + now.getMonth() + "/" +
now.getDayOfMonth() + "/" now.getDayOfMonth() + "/"
+ uuid + "_" + uuid + "/"
+ name; + name;
return url; return url;
} }

View File

@ -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;
}

View File

@ -11,8 +11,6 @@ import lombok.Builder;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import java.util.List;
/** /**
* *
* @AuthorChenYan * @AuthorChenYan
@ -144,13 +142,13 @@ public class ModelProduct extends BaseEntity {
private Double productPrice; private Double productPrice;
//
/** // /**
* // * 翻译后标签
*/ // */
@ApiModelProperty(value = "翻译后标签") // @ApiModelProperty(value = "翻译后标签")
@TableField(exist = false) // @TableField(exist = false)
private List<String> styleList; // private List<String> styleList;
/** /**
@ -161,11 +159,12 @@ public class ModelProduct extends BaseEntity {
private Integer isAttention; private Integer isAttention;
/** /**R
* 0 1 * 0 1
*/ */
@ApiModelProperty(value = "是否点赞 0未点赞 1点赞") @ApiModelProperty(value = "是否点赞 0未点赞 1点赞")
@TableField(exist = false) @TableField(exist = false)
private Integer isLike; private Integer isLike;
} }

View File

@ -194,5 +194,11 @@ public class ModelVersion extends BaseEntity {
@TableField(exist = false) @TableField(exist = false)
private ArrayList<String> highList; private ArrayList<String> highList;
/**
*
*/
@ApiModelProperty(value = "是否收藏")
@TableField(exist = false)
private Integer isCollect = 1;
} }

View File

@ -97,4 +97,11 @@ public class WorkFlowVersion {
*/ */
@ApiModelProperty(value = "文件大小") @ApiModelProperty(value = "文件大小")
private String fileSize; private String fileSize;
/**
*
*/
@TableField(exist = false)
@ApiModelProperty(value = "是否收藏")
private Integer isCollect =1;
} }

View File

@ -15,4 +15,6 @@ import org.apache.ibatis.annotations.Param;
public interface CollectMapper extends BaseMapper<Collect> { public interface CollectMapper extends BaseMapper<Collect> {
Collect selectCollect(@Param("userId") Long userId, @Param("productId") Long productId, @Param("productType") Long productType); 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);
} }

View File

@ -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<DownloadRecord> {
void updateDownloadRecord(DownloadRecord downloadRecord);
}

View File

@ -12,4 +12,6 @@ import com.mcwl.resource.domain.Collect;
public interface CollectService { public interface CollectService {
R addCollect(Collect collect); R addCollect(Collect collect);
Collect selectCollectById(Long modelId, Long userIdMax,Integer type);
} }

View File

@ -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);
}

View File

@ -8,6 +8,8 @@ import com.mcwl.resource.service.CollectService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Date;
/** /**
* *
* @author DaiZibo * @author DaiZibo
@ -26,7 +28,8 @@ public class CollectServiceImpl implements CollectService {
public R addCollect(Collect collect) { public R addCollect(Collect collect) {
Collect collect1 = collectMapper.selectCollect(SecurityUtils.getUserId(),collect.getProductId(),collect.getProductType()); Collect collect1 = collectMapper.selectCollect(SecurityUtils.getUserId(),collect.getProductId(),collect.getProductType());
collect.setUserId(SecurityUtils.getUserId());
collect.setCreateTime(new Date());
if (collect1 == null){ if (collect1 == null){
//执行收藏 //执行收藏
collectMapper.insert(collect); collectMapper.insert(collect);
@ -38,4 +41,10 @@ public class CollectServiceImpl implements CollectService {
return R.ok(1); return R.ok(1);
} }
@Override
public Collect selectCollectById(Long modelId, Long userIdMax,Integer type) {
return collectMapper.selectCollectById(modelId,userIdMax,type);
}
} }

View File

@ -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<DownloadRecord> page = new Page<>();
page.setSize(pageVo.getPageSize());
page.setPages(pageVo.getPageNumber());
LambdaQueryWrapper<DownloadRecord> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(DownloadRecord::getUserId,SecurityUtils.getUserId());
wrapper.eq(pageVo.getType() != null,DownloadRecord::getProductType,pageVo.getType());
Page<DownloadRecord> 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<Long> 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("请选择要删除的数据");
}
}

View File

@ -11,6 +11,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
/** /**
*
* @author DaiZibo * @author DaiZibo
* @date 2025/2/14 * @date 2025/2/14
* @apiNote * @apiNote

View File

@ -467,6 +467,8 @@ public class ModelServiceImpl extends ServiceImpl<ModelMapper,ModelProduct> impl
log.info("开始拉取文件..."); log.info("开始拉取文件...");
HashMap<String, String> hashMap = new HashMap<>(); HashMap<String, String> hashMap = new HashMap<>();
hashMap.put("objectKey",key); hashMap.put("objectKey",key);
log.info("整体版本数据:{}",modelVersion);
log.info("拉取文件数据:{}",key);
hashMap.put("type",DictInit.getDictValue(DictConstants.MODEL_TYPE,modelProduct.getModelType()+"")); 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); String s = HttpUtils.pythonPost("http://1.13.246.108:8188/api/experiment/models/upload", hashMap);
log.info("文件拉取结果:{}",s); log.info("文件拉取结果:{}",s);
@ -502,16 +504,17 @@ public class ModelServiceImpl extends ServiceImpl<ModelMapper,ModelProduct> impl
//标签 //标签
if (StringUtils.isNotEmpty(modelProduct.getTags())){ // if (StringUtils.isNotEmpty(modelProduct.getTags())){
ArrayList<String> strings = new ArrayList<>(); // ArrayList<String> strings = new ArrayList<>();
String[] split = modelProduct.getTags().split(","); // String[] split = modelProduct.getTags().split(",");
for (String s : split) { // for (String s : split) {
if (s != ""){ // if (s != ""){
strings.add(s); // strings.add(s);
} // }
} // }
modelProduct.setStyleList(strings); // modelProduct.setStyleList(strings);
} // }
// modelProduct.setStyleList(new ArrayList<>());
//功能 //功能
if (StringUtils.isNotEmpty(modelProduct.getFunctions())){ if (StringUtils.isNotEmpty(modelProduct.getFunctions())){

View File

@ -4,8 +4,11 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mcwl.common.constant.DictConstants; import com.mcwl.common.constant.DictConstants;
import com.mcwl.common.core.domain.R; import com.mcwl.common.core.domain.R;
import com.mcwl.common.utils.SecurityUtils;
import com.mcwl.common.utils.StringUtils; import com.mcwl.common.utils.StringUtils;
import com.mcwl.resource.domain.Collect;
import com.mcwl.resource.domain.ModelVersion; import com.mcwl.resource.domain.ModelVersion;
import com.mcwl.resource.mapper.ModelMapper;
import com.mcwl.resource.mapper.ModelVersionMapper; import com.mcwl.resource.mapper.ModelVersionMapper;
import com.mcwl.resource.service.ModelVersionService; import com.mcwl.resource.service.ModelVersionService;
import com.mcwl.system.init.DictInit; import com.mcwl.system.init.DictInit;
@ -29,6 +32,12 @@ public class ModelVersionServiceImpl extends ServiceImpl< ModelVersionMapper,Mo
@Autowired @Autowired
private ModelVersionService modelVersionService; private ModelVersionService modelVersionService;
@Autowired
private CollectServiceImpl collectService;
@Autowired
private ModelMapper modelMapper;
@Autowired @Autowired
private ModelVersionMapper modelVersionMapper; private ModelVersionMapper modelVersionMapper;
@ -87,9 +96,23 @@ public class ModelVersionServiceImpl extends ServiceImpl< ModelVersionMapper,Mo
List<ModelVersion> modelVersions = baseMapper.selectList(modelVersionLambdaQueryWrapper); List<ModelVersion> 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; return modelVersions;
} }
@ -98,11 +121,19 @@ public class ModelVersionServiceImpl extends ServiceImpl< ModelVersionMapper,Mo
public R modelFileDownload(Long id) { public R modelFileDownload(Long id) {
ModelVersion modelVersion = modelVersionMapper.selectById(id); ModelVersion modelVersion = modelVersionMapper.selectById(id);
if (modelVersion == null){
return R.fail("文件为空");
}
if (modelVersion.getAllowDownloadImage().equals(0)){ if (modelVersion.getAllowDownloadImage().equals(0)){
return R.fail("此文件不可下载"); return R.fail("此文件不可下载");
} }
return R.ok(); if (modelVersion.getIsEncrypt() == 1){
return R.ok(modelVersion.getEncryptionFilePath());
}
return R.ok(modelVersion.getFilePath(),modelVersion.getFileName());
} }

View File

@ -334,6 +334,7 @@ public class WorkFlowServiceImpl extends ServiceImpl<WorkFlowMapper, WorkFlow> i
LambdaQueryWrapper<WorkFlow> lambdaQueryWrapper = Wrappers.<WorkFlow>lambdaQuery() LambdaQueryWrapper<WorkFlow> lambdaQueryWrapper = Wrappers.<WorkFlow>lambdaQuery()
.like(StringUtils.isNotBlank(pageVo.getName()), WorkFlow::getWorkflowName, pageVo.getName()) .like(StringUtils.isNotBlank(pageVo.getName()), WorkFlow::getWorkflowName, pageVo.getName())
.eq(WorkFlow::getAuditStatus,1)
.eq(WorkFlow::getDelFlag, 0); .eq(WorkFlow::getDelFlag, 0);
if (pageVo.getOrder() == 1) { if (pageVo.getOrder() == 1) {

View File

@ -2,6 +2,8 @@ package com.mcwl.resource.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.mcwl.common.core.domain.R; 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.WorkFlow;
import com.mcwl.resource.domain.WorkFlowVersion; import com.mcwl.resource.domain.WorkFlowVersion;
import com.mcwl.resource.mapper.WorkFlowMapper; import com.mcwl.resource.mapper.WorkFlowMapper;
@ -14,6 +16,7 @@ import java.util.List;
/** /**
* *
*
* @author DaiZibo * @author DaiZibo
* @date 2025/1/9 * @date 2025/1/9
* @apiNote * @apiNote
@ -28,6 +31,10 @@ public class WorkFlowVersionServiceImpl implements WorkFlowVersionService {
@Autowired @Autowired
private WorkFlowMapper workFlowMapper; private WorkFlowMapper workFlowMapper;
@Autowired
private CollectServiceImpl collectService;
@Override @Override
public R<List<WorkFlowVersion>> selectVersionByWorkId(Long workId) { public R<List<WorkFlowVersion>> selectVersionByWorkId(Long workId) {
@ -37,6 +44,19 @@ public class WorkFlowVersionServiceImpl implements WorkFlowVersionService {
workFlowVersionLambdaQueryWrapper.eq(WorkFlowVersion::getWorkFlowId, workId); workFlowVersionLambdaQueryWrapper.eq(WorkFlowVersion::getWorkFlowId, workId);
List<WorkFlowVersion> workFlowVersions = workFlowVersionMapper.selectList(workFlowVersionLambdaQueryWrapper); List<WorkFlowVersion> 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); return R.ok(workFlowVersions);
} }
@ -55,6 +75,6 @@ public class WorkFlowVersionServiceImpl implements WorkFlowVersionService {
return R.fail("该文件不允许下载"); return R.fail("该文件不允许下载");
} }
return R.ok(workFlowVersion.getFilePath()); return R.ok(workFlowVersion.getFilePath(), workFlowVersion.getFileName());
} }
} }

View File

@ -10,4 +10,10 @@
FROM collect where product_id = #{productId} and user_id = #{userId} and product_type = #{productType} FROM collect where product_id = #{productId} and user_id = #{userId} and product_type = #{productType}
</select> </select>
<select id="selectCollectById" resultType="com.mcwl.resource.domain.Collect">
select
id,product_id,user_id,product_type
FROM collect where product_id = #{modelId} and user_id = #{userIdMax} and product_type = #{type}
</select>
</mapper> </mapper>

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.mcwl.resource.mapper.DownloadRecordMapper">
<update id="updateDownloadRecord">
UPDATE download_record
SET file_size = #{fileSize},
status = #{status}
WHERE id = #{id}
</update>
</mapper>

View File

@ -93,6 +93,7 @@
LEFT JOIN sys_user as u LEFT JOIN sys_user as u
on m.user_id = u.user_id on m.user_id = u.user_id
WHERE m.del_flag = 0 WHERE m.del_flag = 0
and audit_status = 1
<if test="name != null and name != ''"> <if test="name != null and name != ''">
and m.model_name like CONCAT('%', #{name}, '%') and m.model_name like CONCAT('%', #{name}, '%')
</if> </if>

View File

@ -612,9 +612,10 @@ public class SysUserServiceImpl implements ISysUserService
@Override @Override
public SysUser selectUserInfoById(Long userId) { public SysUser selectUserInfoById(Long userId) {
SysUser sysUser = userMapper.selectUserInfoById(userId); SysUser sysUser = userMapper.selectUserInfoById(userId);
if (sysUser.getInviterUserId() != null){
SysUser sysUser1 = selectUserById(sysUser.getInviterUserId()); SysUser sysUser1 = selectUserById(sysUser.getInviterUserId());
sysUser.setInvitationName(sysUser1.getNickName()); sysUser.setInvitationName(sysUser1.getNickName());
}
return sysUser; return sysUser;
} }