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 9bb5795..5465f97 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 @@ -1,16 +1,12 @@ package com.mcwl.web.controller.resource; import com.mcwl.common.core.domain.AjaxResult; -import com.mcwl.resource.service.impl.ModelVersionServiceImpl; -import com.mcwl.resource.service.impl.WorkFlowVersionServiceImpl; +import com.mcwl.resource.service.impl.FileServiceImpl; import com.mcwl.web.controller.common.OssUtil; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import java.util.HashMap; @@ -30,10 +26,7 @@ import java.util.Map; public class FileController { @Autowired - private ModelVersionServiceImpl modelVersionService; - - @Autowired - private WorkFlowVersionServiceImpl workFlowVersionService; + private FileServiceImpl fileService; /*** * @@ -102,4 +95,17 @@ public class FileController { } + /** + * 根据文件名查找是否存在 + * @param name + * @param type + * @return + */ + @GetMapping("/selectFileName") + @ApiOperation(value = "根据文件名查找是否存在") + public AjaxResult selectFileName(@RequestParam String name,String type){ + + return fileService.selectFileName(name,type); + } + } 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 a11d6f4..deb118b 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 @@ -147,4 +147,19 @@ public class ModelProduct extends BaseEntity { private List styleList; + /** + * 是否关注 0未关注 1关注 + */ + @ApiModelProperty(value = "是否关注 0未关注 1关注") + @TableField(exist = false) + private Integer isAttention; + + + /** + * 是否点赞 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 8715ab7..b5dc1b7 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 @@ -149,6 +149,14 @@ public class ModelVersion extends BaseEntity { */ @ApiModelProperty(value = "是否隐藏图片生成信息") private Integer hideImageGenInfo; + + /** + * 文件解密秘钥 + */ + @TableField(exist = false) + @ApiModelProperty(value = "文件解密秘钥") + private String keyRate; + /** * 审核状态 */ @@ -170,4 +178,5 @@ public class ModelVersion extends BaseEntity { @TableField(exist = false) private ArrayList highList; + } 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 b418856..65aab7c 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 @@ -1,5 +1,6 @@ package com.mcwl.resource.domain; +import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import io.swagger.annotations.ApiModel; @@ -83,4 +84,11 @@ public class WorkFlowVersion { */ @ApiModelProperty("文件名字") private String fileName; + + /** + * 解密文件秘钥 + */ + @TableField(exist = false) + @ApiModelProperty("解密文件秘钥") + private String keyRate; } diff --git a/mcwl-resource/src/main/java/com/mcwl/resource/mapper/ModelLikeMapper.java b/mcwl-resource/src/main/java/com/mcwl/resource/mapper/ModelLikeMapper.java index 63e780d..a42474f 100644 --- a/mcwl-resource/src/main/java/com/mcwl/resource/mapper/ModelLikeMapper.java +++ b/mcwl-resource/src/main/java/com/mcwl/resource/mapper/ModelLikeMapper.java @@ -2,6 +2,7 @@ package com.mcwl.resource.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.mcwl.resource.domain.ModelLike; +import com.mcwl.resource.domain.WorkFlowLike; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -18,4 +19,7 @@ public interface ModelLikeMapper extends BaseMapper { ModelLike getLike(@Param("userId") Long userId, @Param("modelId") Long modelId); void updateDelFlagById(ModelLike modelLike); + + WorkFlowLike selectModelLikeById(@Param("userId") Long userId, @Param("id") Long id); + } diff --git a/mcwl-resource/src/main/java/com/mcwl/resource/mapper/ModelVersionMapper.java b/mcwl-resource/src/main/java/com/mcwl/resource/mapper/ModelVersionMapper.java index 70ca73c..cb01620 100644 --- a/mcwl-resource/src/main/java/com/mcwl/resource/mapper/ModelVersionMapper.java +++ b/mcwl-resource/src/main/java/com/mcwl/resource/mapper/ModelVersionMapper.java @@ -22,4 +22,6 @@ public interface ModelVersionMapper extends BaseMapper { void updateByName(ModelVersion modelVersion); + ModelVersion selectByFileName(@Param("name") String name); + } diff --git a/mcwl-resource/src/main/java/com/mcwl/resource/mapper/WorkFlowVersionMapper.java b/mcwl-resource/src/main/java/com/mcwl/resource/mapper/WorkFlowVersionMapper.java index 263dfa3..966a214 100644 --- a/mcwl-resource/src/main/java/com/mcwl/resource/mapper/WorkFlowVersionMapper.java +++ b/mcwl-resource/src/main/java/com/mcwl/resource/mapper/WorkFlowVersionMapper.java @@ -24,4 +24,6 @@ public interface WorkFlowVersionMapper extends BaseMapper { void updateByName(WorkFlowVersion workFlowVersion); + WorkFlowVersion selectByFileName(@Param("name") String name); + } diff --git a/mcwl-resource/src/main/java/com/mcwl/resource/service/FileService.java b/mcwl-resource/src/main/java/com/mcwl/resource/service/FileService.java new file mode 100644 index 0000000..7ae27e7 --- /dev/null +++ b/mcwl-resource/src/main/java/com/mcwl/resource/service/FileService.java @@ -0,0 +1,13 @@ +package com.mcwl.resource.service; + +import com.mcwl.common.core.domain.AjaxResult; + +/** + * @author DaiZibo + * @date 2025/2/14 + * @apiNote + */ + +public interface FileService { + AjaxResult selectFileName(String name, String type); +} 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 new file mode 100644 index 0000000..ecd1040 --- /dev/null +++ b/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/FileServiceImpl.java @@ -0,0 +1,51 @@ +package com.mcwl.resource.service.impl; + +import com.mcwl.common.core.domain.AjaxResult; +import com.mcwl.resource.domain.ModelVersion; +import com.mcwl.resource.domain.WorkFlowVersion; +import com.mcwl.resource.mapper.ModelVersionMapper; +import com.mcwl.resource.mapper.WorkFlowVersionMapper; +import com.mcwl.resource.service.FileService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +/** + * @author DaiZibo + * @date 2025/2/14 + * @apiNote + */ + +@Service +public class FileServiceImpl implements FileService { + + @Autowired + private ModelVersionMapper versionMapper; + + @Autowired + private WorkFlowVersionMapper workFlowVersionMapper; + + @Override + public AjaxResult selectFileName(String name, String type) { + + if (type.equals("model")) { + + ModelVersion modelVersion = versionMapper.selectByFileName(name); + if (modelVersion == null) { + + return AjaxResult.error("文件不存在"); + } + + return AjaxResult.success(modelVersion.getKeyRate()); + }else if (type.equals("work")){ + WorkFlowVersion workFlowVersion = workFlowVersionMapper.selectByFileName(name); + if (workFlowVersion == null) { + + return AjaxResult.error("文件不存在"); + } + + return AjaxResult.success(workFlowVersion.getKeyRate()); + } + + return AjaxResult.error("type不合法"); + } +} diff --git a/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/ModelLikeServiceImpl.java b/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/ModelLikeServiceImpl.java index e1f32a1..826a572 100644 --- a/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/ModelLikeServiceImpl.java +++ b/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/ModelLikeServiceImpl.java @@ -76,7 +76,7 @@ public class ModelLikeServiceImpl extends ServiceImpl impl @Autowired private ThreadPoolTaskExecutor threadPoolTaskExecutor; + @Autowired + private SysUserAttentionMapper sysUserAttentionMapper; + + @Autowired + private ModelLikeMapper modelLikeMapper; + /** * 设置模型置顶状态 * @@ -460,6 +469,18 @@ public class ModelServiceImpl extends ServiceImpl impl modelProduct.setActivityId(toActivityService.getById(modelProduct.getActivityId()).getActivityName()); } + modelProduct.setIsAttention(1); + SysUserAttention sysUserAttention = sysUserAttentionMapper.selectAttention(SecurityUtils.getUserId(), modelProduct.getUserId()); + if (sysUserAttention == null){ + modelProduct.setIsAttention(0); + } + + WorkFlowLike workFlowLike = modelLikeMapper.selectModelLikeById(SecurityUtils.getUserId(),modelProduct.getId()); + modelProduct.setIsLike(1); + if (workFlowLike == null){ + modelProduct.setIsLike(0); + } + return R.ok(modelProduct); } diff --git a/mcwl-resource/src/main/resources/mapper/resource/ModelLikeMapper.xml b/mcwl-resource/src/main/resources/mapper/resource/ModelLikeMapper.xml index 4032bd8..23340a5 100644 --- a/mcwl-resource/src/main/resources/mapper/resource/ModelLikeMapper.xml +++ b/mcwl-resource/src/main/resources/mapper/resource/ModelLikeMapper.xml @@ -23,4 +23,8 @@ from model_like where user_id = #{userId} and model_id = #{modelId} + + diff --git a/mcwl-resource/src/main/resources/mapper/resource/ModelVersionMapper.xml b/mcwl-resource/src/main/resources/mapper/resource/ModelVersionMapper.xml index a301ed2..b5df23e 100644 --- a/mcwl-resource/src/main/resources/mapper/resource/ModelVersionMapper.xml +++ b/mcwl-resource/src/main/resources/mapper/resource/ModelVersionMapper.xml @@ -31,4 +31,8 @@ where version_name = #{versionName} and model_id = #{modelId} + + diff --git a/mcwl-resource/src/main/resources/mapper/resource/WorkFlowVersionMapper.xml b/mcwl-resource/src/main/resources/mapper/resource/WorkFlowVersionMapper.xml index 3f85537..ce31f57 100644 --- a/mcwl-resource/src/main/resources/mapper/resource/WorkFlowVersionMapper.xml +++ b/mcwl-resource/src/main/resources/mapper/resource/WorkFlowVersionMapper.xml @@ -22,4 +22,8 @@ audit_text = #{auditText} where version_name = #{versionName} and work_flow_id = #{workFlowId} + +