新增PC端资源中心

master
Diyu0904 2025-03-12 11:27:23 +08:00
parent b27884e889
commit ad6ca564c5
11 changed files with 97 additions and 10 deletions

View File

@ -2,6 +2,7 @@ package com.mcwl.web.controller.resource;
import com.mcwl.common.core.domain.R; import com.mcwl.common.core.domain.R;
import com.mcwl.resource.domain.Collect; import com.mcwl.resource.domain.Collect;
import com.mcwl.resource.domain.vo.PageVo;
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 io.swagger.annotations.ApiOperation;
@ -41,4 +42,11 @@ public class CollectController {
} }
public R selectCollect(@RequestBody PageVo pageVo){
return R.ok();
}
} }

View File

@ -1,6 +1,7 @@
package com.mcwl.resource.domain.response; package com.mcwl.resource.domain.response;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.mcwl.resource.domain.ModelVersion;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
@ -80,4 +81,10 @@ public class ResponseModelProduct {
@ApiModelProperty(value = "发布人头像") @ApiModelProperty(value = "发布人头像")
private String avatar; private String avatar;
/**
*
*/
@ApiModelProperty(value = "版本对象")
private ModelVersion modelVersion;
} }

View File

@ -1,6 +1,7 @@
package com.mcwl.resource.domain.response; package com.mcwl.resource.domain.response;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.mcwl.resource.domain.WorkFlowVersion;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
@ -67,7 +68,7 @@ public class ResponseWorkFlow {
* *
*/ */
@ApiModelProperty(value = "作品点赞数量") @ApiModelProperty(value = "作品点赞数量")
private Integer likeCount = 0; private Integer likeNum = 0;
/** /**
* *
@ -80,4 +81,10 @@ public class ResponseWorkFlow {
*/ */
@ApiModelProperty(value = "发布人头像") @ApiModelProperty(value = "发布人头像")
private String avatar; private String avatar;
/**
*
*/
@ApiModelProperty(value = "工作流版本")
private WorkFlowVersion workFlowVersion;
} }

View File

@ -32,4 +32,7 @@ public class PageVo {
private Integer order; private Integer order;
@ApiModelProperty(value = "条件过滤") @ApiModelProperty(value = "条件过滤")
private Long type; private Long type;
@ApiModelProperty("0查询 1不查询 是否收藏/下载")
private Integer isCollect;
} }

View File

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

View File

@ -28,4 +28,6 @@ public interface WorkFlowVersionMapper extends BaseMapper<WorkFlowVersion> {
WorkFlowVersion selectByHash(@Param("hashCode") String hashCode); WorkFlowVersion selectByHash(@Param("hashCode") String hashCode);
WorkFlowVersion selectByWorkFlowId(@Param("id") Long id);
} }

View File

@ -17,10 +17,7 @@ import com.mcwl.common.core.page.TableDataInfo;
import com.mcwl.common.utils.SecurityUtils; import com.mcwl.common.utils.SecurityUtils;
import com.mcwl.common.utils.StringUtils; import com.mcwl.common.utils.StringUtils;
import com.mcwl.common.utils.baidu.BaiduCensor; import com.mcwl.common.utils.baidu.BaiduCensor;
import com.mcwl.resource.domain.ModelProduct; import com.mcwl.resource.domain.*;
import com.mcwl.resource.domain.ModelVersion;
import com.mcwl.resource.domain.SysUserAttention;
import com.mcwl.resource.domain.WorkFlowLike;
import com.mcwl.resource.domain.dto.ModelImagePageRes; import com.mcwl.resource.domain.dto.ModelImagePageRes;
import com.mcwl.resource.domain.request.RequestModel; import com.mcwl.resource.domain.request.RequestModel;
import com.mcwl.resource.domain.response.ResponseModelProduct; import com.mcwl.resource.domain.response.ResponseModelProduct;
@ -67,6 +64,7 @@ public class ModelServiceImpl extends ServiceImpl<ModelMapper,ModelProduct> impl
@Autowired @Autowired
private ISysUserService sysUserService; private ISysUserService sysUserService;
@Autowired @Autowired
private ThreadPoolTaskExecutor threadPoolTaskExecutor; private ThreadPoolTaskExecutor threadPoolTaskExecutor;
@ -76,6 +74,9 @@ public class ModelServiceImpl extends ServiceImpl<ModelMapper,ModelProduct> impl
@Autowired @Autowired
private ModelLikeMapper modelLikeMapper; private ModelLikeMapper modelLikeMapper;
@Autowired
private CollectServiceImpl collectService;
/** /**
* *
* *
@ -104,12 +105,36 @@ public class ModelServiceImpl extends ServiceImpl<ModelMapper,ModelProduct> impl
page.setPageNum(pageVo.getPageNumber()); page.setPageNum(pageVo.getPageNumber());
page.setPages(pageVo.getPageSize()); page.setPages(pageVo.getPageSize());
Long userIdMax = SecurityUtils.getUserIdMax();
List<ResponseModelProduct> responseModelProductList = postMapper.modelSquare(pageVo); List<ResponseModelProduct> responseModelProductList = postMapper.modelSquare(pageVo);
for (ResponseModelProduct responseModelProduct : responseModelProductList) { for (ResponseModelProduct responseModelProduct : responseModelProductList) {
if (responseModelProduct.getModelType() != null){ if (responseModelProduct.getModelType() != null){
responseModelProduct.setType(DictInit.getDictValue(DictConstants.MODEL_TYPE,responseModelProduct.getModelType()+"")); responseModelProduct.setType(DictInit.getDictValue(DictConstants.MODEL_TYPE,responseModelProduct.getModelType()+""));
} }
//查询该模型第一个版本信息
if (pageVo.getIsCollect() == 0){
ModelVersion modelVersion = modelVersionMapper.selectByProductId(responseModelProduct.getId());
if (userIdMax == 0){
//收藏为空
modelVersion.setIsCollect(0);
}else {
//查询是否收藏
Collect collect = collectService.selectCollectById(modelVersion.getId(), userIdMax, 0);
if (collect == null){
modelVersion.setIsCollect(0);
}
modelVersion.setIsCollect(1);
}
responseModelProduct.setModelVersion(modelVersion);
}
} }
return new PageInfo<ResponseModelProduct>(responseModelProductList); return new PageInfo<ResponseModelProduct>(responseModelProductList);

View File

@ -19,10 +19,7 @@ import com.mcwl.common.core.page.TableDataInfo;
import com.mcwl.common.utils.SecurityUtils; import com.mcwl.common.utils.SecurityUtils;
import com.mcwl.common.utils.StringUtils; import com.mcwl.common.utils.StringUtils;
import com.mcwl.common.utils.baidu.BaiduCensor; import com.mcwl.common.utils.baidu.BaiduCensor;
import com.mcwl.resource.domain.SysUserAttention; import com.mcwl.resource.domain.*;
import com.mcwl.resource.domain.WorkFlow;
import com.mcwl.resource.domain.WorkFlowLike;
import com.mcwl.resource.domain.WorkFlowVersion;
import com.mcwl.resource.domain.dto.AddRequestWorkFlow; import com.mcwl.resource.domain.dto.AddRequestWorkFlow;
import com.mcwl.resource.domain.dto.ModelImagePageRes; import com.mcwl.resource.domain.dto.ModelImagePageRes;
import com.mcwl.resource.domain.request.RequestWorkFlow; import com.mcwl.resource.domain.request.RequestWorkFlow;
@ -60,6 +57,9 @@ public class WorkFlowServiceImpl extends ServiceImpl<WorkFlowMapper, WorkFlow> i
@Autowired @Autowired
private WorkFlowMapper flowMapper; private WorkFlowMapper flowMapper;
@Autowired
private CollectServiceImpl collectService;
@Autowired @Autowired
private WorkFlowVersionMapper workFlowVersionMapper; private WorkFlowVersionMapper workFlowVersionMapper;
@ -492,10 +492,35 @@ public class WorkFlowServiceImpl extends ServiceImpl<WorkFlowMapper, WorkFlow> i
List<ResponseWorkFlow> responseWorkFlowList = baseMapper.workFlowList(pageVo); List<ResponseWorkFlow> responseWorkFlowList = baseMapper.workFlowList(pageVo);
Long userIdMax = SecurityUtils.getUserIdMax();
for (ResponseWorkFlow responseWorkFlow : responseWorkFlowList) { for (ResponseWorkFlow responseWorkFlow : responseWorkFlowList) {
responseWorkFlow.setType(DictInit.getDictValue(DictConstants.WORK_FLOW_TYPE_CHILD, responseWorkFlow.getType())); responseWorkFlow.setType(DictInit.getDictValue(DictConstants.WORK_FLOW_TYPE_CHILD, responseWorkFlow.getType()));
//查询工作流型第一个版本信息
if (pageVo.getIsCollect() == 0){
WorkFlowVersion workFlowVersion = workFlowVersionMapper.selectByWorkFlowId(responseWorkFlow.getId());
if (userIdMax == 0){
//收藏为空
workFlowVersion.setIsCollect(0);
}else {
//查询是否收藏
Collect collect = collectService.selectCollectById(workFlowVersion.getId(), userIdMax, 1);
if (collect == null){
workFlowVersion.setIsCollect(0);
} }
workFlowVersion.setIsCollect(1);
}
responseWorkFlow.setWorkFlowVersion(workFlowVersion);
}
}
return new PageInfo<ResponseWorkFlow>(responseWorkFlowList); return new PageInfo<ResponseWorkFlow>(responseWorkFlowList);

View File

@ -55,4 +55,8 @@
select * from model_version where file_hash = #{hashCode} select * from model_version where file_hash = #{hashCode}
</select> </select>
<select id="selectByProductId" resultType="com.mcwl.resource.domain.ModelVersion">
SELECT * FROM model_version WHERE model_id = #{id} LIMIT 1
</select>
</mapper> </mapper>

View File

@ -44,7 +44,7 @@
</select> </select>
<select id="workFlowList" resultType="com.mcwl.resource.domain.response.ResponseWorkFlow"> <select id="workFlowList" resultType="com.mcwl.resource.domain.response.ResponseWorkFlow">
SELECT id,w.user_id,workflow_name,type,use_number,download_number,cover_path,like_count,nick_name,avatar SELECT id,w.user_id,workflow_name,type,use_number,download_number,cover_path,like_num,nick_name,avatar
FROM work_flow as w FROM work_flow as w
LEFT JOIN sys_user u LEFT JOIN sys_user u
on w.user_id = u.user_id on w.user_id = u.user_id

View File

@ -30,4 +30,8 @@
<select id="selectByHash" resultType="com.mcwl.resource.domain.WorkFlowVersion"> <select id="selectByHash" resultType="com.mcwl.resource.domain.WorkFlowVersion">
select * from work_flow_version where file_hash = #{hashCode} select * from work_flow_version where file_hash = #{hashCode}
</select> </select>
<select id="selectByWorkFlowId" resultType="com.mcwl.resource.domain.WorkFlowVersion">
SELECT * FROM work_flow_version WHERE work_flow_id = #{id} LIMIT 1
</select>
</mapper> </mapper>