diff --git a/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/MallProductController.java b/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/MallProductController.java index 189cf3e..8ea8912 100644 --- a/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/MallProductController.java +++ b/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/MallProductController.java @@ -1,5 +1,6 @@ package com.mcwl.web.controller.resource; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.mcwl.common.core.controller.BaseController; import com.mcwl.common.core.domain.AjaxResult; import com.mcwl.common.core.domain.R; @@ -7,13 +8,14 @@ import com.mcwl.common.core.page.PageDomain; import com.mcwl.common.core.page.TableDataInfo; import com.mcwl.common.utils.SecurityUtils; import com.mcwl.resource.domain.ModelProduct; +import com.mcwl.resource.domain.ModelVersion; import com.mcwl.resource.domain.dto.ModelImagePageRes; import com.mcwl.resource.domain.request.RequestModel; +import com.mcwl.resource.mapper.ModelVersionMapper; import com.mcwl.resource.service.*; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; import javax.validation.Valid; @@ -55,6 +57,9 @@ public class MallProductController extends BaseController { @Autowired private ModelImageLikeService modelImageLikeService; + @Autowired + private ModelVersionMapper modelVersionMapper; + /** * 模型列表 @@ -68,16 +73,27 @@ public class MallProductController extends BaseController { @ApiOperation(value = "模型详情") - @PostMapping("finbyid") - public R finbyid(@RequestBody ModelProduct modelVersion) { - ModelProduct modelVersion1 = modelService.getById(modelVersion.getId()); - return R.ok(modelVersion1); + @GetMapping("finbyid") + public AjaxResult finbyid(@Valid @NotNull(message = "模型id不能为空") @RequestParam Long id) { + + RequestModel requestModel = new RequestModel(); + + ModelProduct modelVersion1 = modelService.getById(id); + + LambdaQueryWrapper modelVersionLambdaQueryWrapper = new LambdaQueryWrapper<>(); + modelVersionLambdaQueryWrapper.eq(ModelVersion::getModelId,id); + modelVersionLambdaQueryWrapper.eq(ModelVersion::getDelFlag,"0"); + List modelVersions = modelVersionMapper.selectList(modelVersionLambdaQueryWrapper); + + requestModel.setModelProduct(modelVersion1); + requestModel.setModelVersionList(modelVersions); + return AjaxResult.success(requestModel); } @ApiOperation(value = "添加模型") @PostMapping("/insert") - public R addupdateModel(@RequestBody RequestModel requestModel) { + public AjaxResult addupdateModel(@RequestBody RequestModel requestModel) { ModelProduct modelProduct = requestModel.getModelProduct(); Long userId = SecurityUtils.getUserId(); modelProduct.setUserId(userId); @@ -87,7 +103,7 @@ public class MallProductController extends BaseController { @ApiOperation(value = "修改模型") @PostMapping("/update") - public R updateModel(@RequestBody RequestModel requestModel) { + public AjaxResult updateModel(@RequestBody RequestModel requestModel) { ModelProduct modelProduct = requestModel.getModelProduct(); Long userId = SecurityUtils.getUserId(); @@ -95,15 +111,15 @@ public class MallProductController extends BaseController { modelProduct.setUpdateBy(getUsername()); modelService.updaModel(requestModel); - return R.ok(); + return AjaxResult.success("修改成功"); } @ApiOperation(value = "删除模型") @GetMapping("delete") - public R delete(@Valid @NotNull(message = "模型id不能为空") Long id) { + public AjaxResult delete(@Valid @NotNull(message = "模型id不能为空") @RequestParam Long id) { modelService.removeById(id); - return R.ok(); + return AjaxResult.success(); } /** @@ -114,7 +130,7 @@ public class MallProductController extends BaseController { */ @ApiOperation(value = "查询模型详情") @GetMapping("/selectModelById") - public R selectModelById(@RequestParam Long id) { + public AjaxResult selectModelById(@Valid @NotNull(message = "模型id不能为空") @RequestParam Long id) { return modelService.selectModelById(id); } @@ -129,9 +145,9 @@ public class MallProductController extends BaseController { */ @ApiOperation(value = "设置模型置顶状态") @GetMapping("/{id}/top") - public R setModelTop(@PathVariable Long id, @RequestParam boolean isTop) { + public AjaxResult setModelTop(@PathVariable Long id, @RequestParam boolean isTop) { modelService.setModelTop(id, isTop); - return R.ok(); + return AjaxResult.success(); } diff --git a/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/ModelVersionController.java b/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/ModelVersionController.java index 0599050..f20fb4c 100644 --- a/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/ModelVersionController.java +++ b/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/ModelVersionController.java @@ -53,13 +53,13 @@ public class ModelVersionController extends BaseController { @ApiOperation(value = "模型版本详情") @GetMapping("finbyid") - public R finbyid(@RequestParam Long id) + public R> finbyid(@RequestParam Long id) { - ModelVersion modelVersion1 = modelVersionService.getById(id); + List modelVersionList = modelVersionService.finbyid(id); - return R.ok(modelVersion1); + return R.ok(modelVersionList); } 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 f2747be..8715ab7 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 @@ -47,8 +47,8 @@ public class ModelVersion extends BaseEntity { /** * 模型类型ID */ - @ApiModelProperty(value = "模型类型ID") - private Long modelType; + @ApiModelProperty(value = "基础模型") + private Long modelVersionType; /** * 文件地址 */ @@ -152,13 +152,13 @@ public class ModelVersion extends BaseEntity { /** * 审核状态 */ - @ApiModelProperty(value = "审核状态") - private Integer auditStatus; - /** - * 审核失败原因 - */ - @ApiModelProperty(value = "审核失败原因") - private String auditText; +// @ApiModelProperty(value = "审核状态") +// private Integer auditStatus; +// /** +// * 审核失败原因 +// */ +// @ApiModelProperty(value = "审核失败原因") +// private String auditText; /** * 删除标志(0代表存在 2代表删除) */ diff --git a/mcwl-resource/src/main/java/com/mcwl/resource/domain/WorkFlow.java b/mcwl-resource/src/main/java/com/mcwl/resource/domain/WorkFlow.java index 277192a..58379e0 100644 --- a/mcwl-resource/src/main/java/com/mcwl/resource/domain/WorkFlow.java +++ b/mcwl-resource/src/main/java/com/mcwl/resource/domain/WorkFlow.java @@ -170,10 +170,18 @@ public class WorkFlow { private List typeList; /** - * 是否关注 0关注 1未关注 + * 是否关注 0未关注 1关注 */ - @ApiModelProperty(value = "是否关注 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/service/ModelVersionService.java b/mcwl-resource/src/main/java/com/mcwl/resource/service/ModelVersionService.java index 4f67dae..bb47c35 100644 --- a/mcwl-resource/src/main/java/com/mcwl/resource/service/ModelVersionService.java +++ b/mcwl-resource/src/main/java/com/mcwl/resource/service/ModelVersionService.java @@ -22,4 +22,6 @@ public interface ModelVersionService extends IService { R> selectByModelId(Long modelId); + List finbyid(Long id); + } diff --git a/mcwl-resource/src/main/java/com/mcwl/resource/service/WorkFlowLikeService.java b/mcwl-resource/src/main/java/com/mcwl/resource/service/WorkFlowLikeService.java index 04c5fe5..635c044 100644 --- a/mcwl-resource/src/main/java/com/mcwl/resource/service/WorkFlowLikeService.java +++ b/mcwl-resource/src/main/java/com/mcwl/resource/service/WorkFlowLikeService.java @@ -20,4 +20,6 @@ public interface WorkFlowLikeService extends IService { void like(Long imageId); TableDataInfo listByPage(PageDomain pageDomain); + + WorkFlowLike selectWorkFlowLikeById(Long userId, Long id); } diff --git a/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/ModelServiceImpl.java b/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/ModelServiceImpl.java index b06465c..9048a1f 100644 --- a/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/ModelServiceImpl.java +++ b/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/ModelServiceImpl.java @@ -187,7 +187,7 @@ public class ModelServiceImpl extends ServiceImpl impl @Override public R addModel(RequestModel requestModel) { //获取封面图 - String filePath = requestModel.getModelVersionList().get(0).getFilePath(); + String filePath = requestModel.getModelVersionList().get(0).getSampleImagePaths(); String[] split = filePath.split(","); ModelProduct modelProduct = requestModel.getModelProduct(); modelProduct.setSurfaceUrl(split[0]); @@ -226,7 +226,7 @@ public class ModelServiceImpl extends ServiceImpl impl //批量修改 for (ModelVersion modelVersion : requestModel.getModelVersionList()) { - modelVersion.setAuditStatus(3); + modelVersionMapper.updateById(modelVersion); } @@ -304,9 +304,9 @@ public class ModelServiceImpl extends ServiceImpl impl } //修改为合格 - modelProduct.setAuditText(""); - modelProduct.setAuditStatus(modelProduct.getJurisdiction()); - baseMapper.updateById(modelProduct); +// modelProduct.setAuditText(""); +// modelProduct.setAuditStatus(modelProduct.getJurisdiction()); +// baseMapper.updateById(modelProduct); } } diff --git a/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/ModelVersionServiceImpl.java b/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/ModelVersionServiceImpl.java index 7836296..e740447 100644 --- a/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/ModelVersionServiceImpl.java +++ b/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/ModelVersionServiceImpl.java @@ -79,5 +79,21 @@ public class ModelVersionServiceImpl extends ServiceImpl< ModelVersionMapper,Mo return R.ok(modelVersions); } + @Override + public List finbyid(Long id) { + + LambdaQueryWrapper modelVersionLambdaQueryWrapper = new LambdaQueryWrapper<>(); + modelVersionLambdaQueryWrapper.eq(ModelVersion::getModelId,id); + modelVersionLambdaQueryWrapper.eq(ModelVersion::getDelFlag,0); + + List modelVersions = baseMapper.selectList(modelVersionLambdaQueryWrapper); + + for (ModelVersion modelVersion : modelVersions) { + + } + + return modelVersions; + } + } diff --git a/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/WorkFlowLikeServiceImpl.java b/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/WorkFlowLikeServiceImpl.java index bd2cbbe..6f4c5b7 100644 --- a/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/WorkFlowLikeServiceImpl.java +++ b/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/WorkFlowLikeServiceImpl.java @@ -1,6 +1,7 @@ package com.mcwl.resource.service.impl; import cn.hutool.core.bean.BeanUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.OrderItem; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; @@ -11,11 +12,8 @@ import com.mcwl.common.core.page.TableDataInfo; import com.mcwl.common.exception.ServiceException; import com.mcwl.common.utils.SecurityUtils; import com.mcwl.common.utils.StringUtils; -import com.mcwl.resource.domain.ModelLike; -import com.mcwl.resource.domain.ModelProduct; import com.mcwl.resource.domain.WorkFlow; import com.mcwl.resource.domain.WorkFlowLike; -import com.mcwl.resource.domain.vo.ModelLikeVo; import com.mcwl.resource.domain.vo.WorkFlowLikeVo; import com.mcwl.resource.mapper.WorkFlowLikeMapper; import com.mcwl.resource.mapper.WorkFlowMapper; @@ -134,6 +132,16 @@ public class WorkFlowLikeServiceImpl extends ServiceImpl workFlowLikeLambdaQueryWrapper = new LambdaQueryWrapper<>(); + workFlowLikeLambdaQueryWrapper.eq(WorkFlowLike::getWorkFlowId,id); + workFlowLikeLambdaQueryWrapper.eq(WorkFlowLike::getUserId,userId); + + return baseMapper.selectOne(workFlowLikeLambdaQueryWrapper); + } + private Page initPage(PageDomain pageDomain) { Page page = new Page<>(pageDomain.getPageNum(), pageDomain.getPageSize()); diff --git a/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/WorkFlowServiceImpl.java b/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/WorkFlowServiceImpl.java index f691c8b..28a2b22 100644 --- a/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/WorkFlowServiceImpl.java +++ b/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/WorkFlowServiceImpl.java @@ -20,6 +20,7 @@ import com.mcwl.common.utils.StringUtils; import com.mcwl.common.utils.baidu.BaiduCensor; import com.mcwl.resource.domain.SysUserAttention; 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.ModelImagePageRes; @@ -29,7 +30,6 @@ import com.mcwl.resource.domain.vo.WorkFlowVo; import com.mcwl.resource.mapper.SysUserAttentionMapper; import com.mcwl.resource.mapper.WorkFlowMapper; import com.mcwl.resource.mapper.WorkFlowVersionMapper; -import com.mcwl.resource.service.ToActivityService; import com.mcwl.resource.service.WorkFlowService; import com.mcwl.system.init.DictInit; import com.mcwl.system.service.ISysUserService; @@ -62,7 +62,7 @@ public class WorkFlowServiceImpl extends ServiceImpl i private WorkFlowVersionMapper workFlowVersionMapper; @Autowired - private ToActivityService toActivityService; + private WorkFlowLikeServiceImpl workFlowLikeService; @Autowired private SysUserAttentionMapper sysUserAttentionMapper; @@ -163,9 +163,9 @@ public class WorkFlowServiceImpl extends ServiceImpl i } //修改为合格 - workFlow.setAuditText(""); - workFlow.setAuditStatus(workFlow.getJurisdiction()); - flowMapper.updateById(workFlow); +// workFlow.setAuditText(""); +// workFlow.setAuditStatus(workFlow.getJurisdiction()); +// flowMapper.updateById(workFlow); } } @@ -383,16 +383,22 @@ public class WorkFlowServiceImpl extends ServiceImpl i ArrayList strings = new ArrayList<>(); String[] split = workFlow.getType().split(","); for (String s : split) { - if (s != "") { + if (s.equals("")) { strings.add(DictInit.getDictValue(DictConstants.WORK_FLOW_TYPE_CHILD, s)); } } workFlow.setTypeList(strings); } - workFlow.setIsAttention(0); + workFlow.setIsAttention(1); SysUserAttention sysUserAttention = sysUserAttentionMapper.selectAttention(SecurityUtils.getUserId(), workFlow.getUserId()); if (sysUserAttention == null){ - workFlow.setIsAttention(1); + workFlow.setIsAttention(0); + } + + WorkFlowLike workFlowLike = workFlowLikeService.selectWorkFlowLikeById(SecurityUtils.getUserId(),workFlow.getId()); + workFlow.setIsLike(1); + if (workFlowLike == null){ + workFlow.setIsLike(0); } return R.ok(workFlow); } diff --git a/mcwl-resource/src/main/resources/mapper/resource/ModelVersionMapper.xml b/mcwl-resource/src/main/resources/mapper/resource/ModelVersionMapper.xml index b9dce78..a301ed2 100644 --- a/mcwl-resource/src/main/resources/mapper/resource/ModelVersionMapper.xml +++ b/mcwl-resource/src/main/resources/mapper/resource/ModelVersionMapper.xml @@ -7,22 +7,20 @@ INSERT INTO model_version ( - model_id,version_name, model_type, file_path, trigger_words, sampling, high, vae, cfg, + model_id,version_name,version_description,model_version_type, file_path,file_name, trigger_words, sampling, high, vae, cfg, is_free, is_public, is_encrypt, is_online_use, allow_download_image, allow_software_use, allow_fusion, allow_commercial_use, allow_usage, - is_exclusive_model, sample_image_paths, hide_image_gen_info, audit_status, - audit_text, del_flag + is_exclusive_model, sample_image_paths, hide_image_gen_info, del_flag ) VALUES ( - #{modelProduct.id},#{item.versionName}, #{item.modelType}, #{item.filePath}, #{item.triggerWords}, - #{item.sampling}, #{item.high}, #{item.vae}, #{item.cfg}, + #{modelProduct.id},#{item.versionName}, #{item.versionDescription},#{item.modelVersionType}, #{item.filePath}, + #{item.fileName},#{item.triggerWords},#{item.sampling}, #{item.high}, #{item.vae}, #{item.cfg}, #{item.isFree}, #{item.isPublic}, #{item.isEncrypt}, #{item.isOnlineUse}, #{item.allowDownloadImage}, #{item.allowSoftwareUse}, #{item.allowFusion}, #{item.allowCommercialUse}, #{item.allowUsage}, #{item.isExclusiveModel}, - #{item.sampleImagePaths}, #{item.hideImageGenInfo}, 3, - #{item.auditText},'0' + #{item.sampleImagePaths}, #{item.hideImageGenInfo},'0' )