Merge branch 'feature/admin' into preview

feature/community-center
Diyu0904 2025-05-15 16:07:19 +08:00
commit 4d57150d2b
7 changed files with 52 additions and 2 deletions

View File

@ -1,5 +1,6 @@
package com.mcwl.web.controller.resource; package com.mcwl.web.controller.resource;
import com.mcwl.common.annotation.RepeatSubmit;
import com.mcwl.common.core.domain.R; import com.mcwl.common.core.domain.R;
import com.mcwl.resource.domain.DownloadRecord; import com.mcwl.resource.domain.DownloadRecord;
import com.mcwl.resource.domain.request.RequestDownload; import com.mcwl.resource.domain.request.RequestDownload;
@ -36,6 +37,7 @@ public class DownloadRecordController {
* @return * @return
*/ */
@ApiOperation(value = "新增下载记录") @ApiOperation(value = "新增下载记录")
@RepeatSubmit(interval = 1000)
@PostMapping("/addDownloadRecord") @PostMapping("/addDownloadRecord")
public R addDownloadRecord(@RequestBody DownloadRecord downloadRecord){ public R addDownloadRecord(@RequestBody DownloadRecord downloadRecord){
@ -85,4 +87,11 @@ public class DownloadRecordController {
return downloadRecordService.selectByFileName(requestDownload); return downloadRecordService.selectByFileName(requestDownload);
} }
@ApiOperation(value = "根据文件名删除数据")
@PostMapping("/deleteDownloadRecordByFileName")
public R deleteDownloadRecordByFileName(@RequestBody DownloadRecord downloadRecord){
return downloadRecordService.deleteDownloadRecordByFileName(downloadRecord);
}
} }

View File

@ -47,7 +47,7 @@ public class DownloadRecord {
/** /**
* 0 1 * 0 1
*/ */
@ApiModelProperty(value = "作品类型0模型 1工作流") @ApiModelProperty(value = "作品类型")
private Long productType; private Long productType;
/** /**

View File

@ -113,4 +113,11 @@ public class WorkFlowVersion {
*/ */
@ApiModelProperty(value = "文件hash") @ApiModelProperty(value = "文件hash")
private String fileHash; private String fileHash;
/**
*
*/
@ApiModelProperty(value = "是否下载")
@TableField(exist = false)
private Integer isDownload;
} }

View File

@ -24,4 +24,6 @@ public interface DownloadRecordService {
Integer selectDownloadByUser(Long userIdMax, Long id, int i); Integer selectDownloadByUser(Long userIdMax, Long id, int i);
R selectByFileName(RequestDownload requestDownload); R selectByFileName(RequestDownload requestDownload);
R deleteDownloadRecordByFileName(DownloadRecord downloadRecord);
} }

View File

@ -56,6 +56,17 @@ public class DownloadRecordServiceImpl implements DownloadRecordService {
downloadRecord.setUserId(SecurityUtils.getUserId()); downloadRecord.setUserId(SecurityUtils.getUserId());
downloadRecord.setCreateTime(new Date()); downloadRecord.setCreateTime(new Date());
//校验是否存在下载记录
LambdaQueryWrapper<DownloadRecord> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(DownloadRecord::getUserId,SecurityUtils.getUserId());
wrapper.eq(DownloadRecord::getDownloadType,downloadRecord.getDownloadType());
wrapper.eq(DownloadRecord::getProductId,downloadRecord.getProductId());
List<DownloadRecord> downloadRecords = downloadRecordMapper.selectList(wrapper);
if (StringUtils.isNotEmpty(downloadRecords)){
//记录存在直接返回
return R.ok();
}
// //获取作品信息 // //获取作品信息
// if (downloadRecord.getProductType() == 0){ // if (downloadRecord.getProductType() == 0){
// //
@ -178,4 +189,17 @@ public class DownloadRecordServiceImpl implements DownloadRecordService {
return R.ok(downloadRecords); return R.ok(downloadRecords);
} }
@Override
public R deleteDownloadRecordByFileName(DownloadRecord downloadRecord) {
LambdaQueryWrapper<DownloadRecord> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(DownloadRecord::getFileName,downloadRecord.getFileName());
wrapper.eq(DownloadRecord::getUserId,SecurityUtils.getUserId());
downloadRecordMapper.delete(wrapper);
return R.ok();
}
} }

View File

@ -76,6 +76,9 @@ public class WorkFlowServiceImpl extends ServiceImpl<WorkFlowMapper, WorkFlow> i
@Autowired @Autowired
private ThreadPoolTaskExecutor threadPoolTaskExecutor; private ThreadPoolTaskExecutor threadPoolTaskExecutor;
@Autowired
private DownloadRecordServiceImpl downloadRecordService;
@Override @Override
public R<Object> addWorkFlow(AddRequestWorkFlow addRequestWorkFlo) { public R<Object> addWorkFlow(AddRequestWorkFlow addRequestWorkFlo) {
@ -530,6 +533,9 @@ public class WorkFlowServiceImpl extends ServiceImpl<WorkFlowMapper, WorkFlow> i
if (userIdMax == 0){ if (userIdMax == 0){
//收藏为空 //收藏为空
workFlowVersion.setIsCollect(0); workFlowVersion.setIsCollect(0);
//下载为空
workFlowVersion.setIsDownload(0);
}else { }else {
//查询是否收藏 //查询是否收藏
Collect collect = collectService.selectCollectById(workFlowVersion.getId(), userIdMax, 1); Collect collect = collectService.selectCollectById(workFlowVersion.getId(), userIdMax, 1);
@ -541,6 +547,7 @@ public class WorkFlowServiceImpl extends ServiceImpl<WorkFlowMapper, WorkFlow> i
workFlowVersion.setIsCollect(1); workFlowVersion.setIsCollect(1);
} }
workFlowVersion.setIsDownload(downloadRecordService.selectDownloadByUser(userIdMax,workFlowVersion.getWorkFlowId(),1));
} }
responseWorkFlow.setWorkFlowVersion(workFlowVersion); responseWorkFlow.setWorkFlowVersion(workFlowVersion);

View File

@ -15,6 +15,7 @@
<select id="selectDownloadByUser" resultType="com.mcwl.resource.domain.DownloadRecord"> <select id="selectDownloadByUser" resultType="com.mcwl.resource.domain.DownloadRecord">
SELECT * FROM download_record WHERE user_id = #{userIdMax} SELECT * FROM download_record WHERE user_id = #{userIdMax}
and product_id = #{id} and product_id = #{id}
and product_type = #{i} and download_type = #{i}
limit 1
</select> </select>
</mapper> </mapper>