parent
87cc661a7f
commit
daa17a6caa
|
@ -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){
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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<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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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){
|
||||
|
||||
|
|
|
@ -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<ToActivity> list = toActivityService.selectToActivityList(toActivity);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
|
|
@ -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){
|
||||
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -69,7 +69,7 @@ public class ObsUtils {
|
|||
now.getYear() + "/" +
|
||||
now.getMonth() + "/" +
|
||||
now.getDayOfMonth() + "/"
|
||||
+ uuid + "_"
|
||||
+ uuid + "/"
|
||||
+ name;
|
||||
return url;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
}
|
|
@ -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<String> styleList;
|
||||
//
|
||||
// /**
|
||||
// * 翻译后标签
|
||||
// */
|
||||
// @ApiModelProperty(value = "翻译后标签")
|
||||
// @TableField(exist = false)
|
||||
// private List<String> 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;
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -194,5 +194,11 @@ public class ModelVersion extends BaseEntity {
|
|||
@TableField(exist = false)
|
||||
private ArrayList<String> highList;
|
||||
|
||||
/**
|
||||
* 是否收藏
|
||||
*/
|
||||
@ApiModelProperty(value = "是否收藏")
|
||||
@TableField(exist = false)
|
||||
private Integer isCollect = 1;
|
||||
|
||||
}
|
||||
|
|
|
@ -97,4 +97,11 @@ public class WorkFlowVersion {
|
|||
*/
|
||||
@ApiModelProperty(value = "文件大小")
|
||||
private String fileSize;
|
||||
|
||||
/**
|
||||
* 是否收藏
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
@ApiModelProperty(value = "是否收藏")
|
||||
private Integer isCollect =1;
|
||||
}
|
||||
|
|
|
@ -15,4 +15,6 @@ import org.apache.ibatis.annotations.Param;
|
|||
public interface CollectMapper extends BaseMapper<Collect> {
|
||||
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);
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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("请选择要删除的数据");
|
||||
}
|
||||
}
|
|
@ -11,6 +11,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 文件实现层
|
||||
* @author DaiZibo
|
||||
* @date 2025/2/14
|
||||
* @apiNote
|
||||
|
|
|
@ -467,6 +467,8 @@ public class ModelServiceImpl extends ServiceImpl<ModelMapper,ModelProduct> impl
|
|||
log.info("开始拉取文件...");
|
||||
HashMap<String, String> 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<ModelMapper,ModelProduct> impl
|
|||
|
||||
|
||||
//标签
|
||||
if (StringUtils.isNotEmpty(modelProduct.getTags())){
|
||||
ArrayList<String> 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<String> 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())){
|
||||
|
|
|
@ -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<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;
|
||||
}
|
||||
|
@ -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());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -334,6 +334,7 @@ public class WorkFlowServiceImpl extends ServiceImpl<WorkFlowMapper, WorkFlow> i
|
|||
|
||||
LambdaQueryWrapper<WorkFlow> lambdaQueryWrapper = Wrappers.<WorkFlow>lambdaQuery()
|
||||
.like(StringUtils.isNotBlank(pageVo.getName()), WorkFlow::getWorkflowName, pageVo.getName())
|
||||
.eq(WorkFlow::getAuditStatus,1)
|
||||
.eq(WorkFlow::getDelFlag, 0);
|
||||
|
||||
if (pageVo.getOrder() == 1) {
|
||||
|
|
|
@ -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<List<WorkFlowVersion>> selectVersionByWorkId(Long workId) {
|
||||
|
||||
LambdaQueryWrapper<WorkFlowVersion> workFlowVersionLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
|
||||
workFlowVersionLambdaQueryWrapper.eq(WorkFlowVersion::getDelFlag,0);
|
||||
workFlowVersionLambdaQueryWrapper.eq(WorkFlowVersion::getWorkFlowId,workId);
|
||||
workFlowVersionLambdaQueryWrapper.eq(WorkFlowVersion::getDelFlag, 0);
|
||||
workFlowVersionLambdaQueryWrapper.eq(WorkFlowVersion::getWorkFlowId, workId);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,4 +10,10 @@
|
|||
FROM collect where product_id = #{productId} and user_id = #{userId} and product_type = #{productType}
|
||||
</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>
|
||||
|
|
|
@ -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>
|
|
@ -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
|
||||
<if test="name != null and name != ''">
|
||||
and m.model_name like CONCAT('%', #{name}, '%')
|
||||
</if>
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue