Merge branch 'feature/admin' into preview

# Conflicts:
#	mcwl-admin/src/main/java/com/mcwl/web/controller/resource/MallProductController.java
#	mcwl-admin/src/main/java/com/mcwl/web/controller/resource/ModelVersionController.java
master
Diyu0904 2025-02-14 13:41:14 +08:00
commit 57bdbdca3b
11 changed files with 106 additions and 50 deletions

View File

@ -1,5 +1,6 @@
package com.mcwl.web.controller.resource; 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.controller.BaseController;
import com.mcwl.common.core.domain.AjaxResult; import com.mcwl.common.core.domain.AjaxResult;
import com.mcwl.common.core.domain.R; 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.core.page.TableDataInfo;
import com.mcwl.common.utils.SecurityUtils; import com.mcwl.common.utils.SecurityUtils;
import com.mcwl.resource.domain.ModelProduct; import com.mcwl.resource.domain.ModelProduct;
import com.mcwl.resource.domain.ModelVersion;
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.mapper.ModelVersionMapper;
import com.mcwl.resource.service.*; import com.mcwl.resource.service.*;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.validation.Valid; import javax.validation.Valid;
@ -55,6 +57,9 @@ public class MallProductController extends BaseController {
@Autowired @Autowired
private ModelImageLikeService modelImageLikeService; private ModelImageLikeService modelImageLikeService;
@Autowired
private ModelVersionMapper modelVersionMapper;
/** /**
* *
@ -68,16 +73,27 @@ public class MallProductController extends BaseController {
@ApiOperation(value = "模型详情") @ApiOperation(value = "模型详情")
@PostMapping("finbyid") @GetMapping("finbyid")
public R<ModelProduct> finbyid(@RequestBody ModelProduct modelVersion) { public AjaxResult finbyid(@Valid @NotNull(message = "模型id不能为空") @RequestParam Long id) {
ModelProduct modelVersion1 = modelService.getById(modelVersion.getId());
return R.ok(modelVersion1); RequestModel requestModel = new RequestModel();
ModelProduct modelVersion1 = modelService.getById(id);
LambdaQueryWrapper<ModelVersion> modelVersionLambdaQueryWrapper = new LambdaQueryWrapper<>();
modelVersionLambdaQueryWrapper.eq(ModelVersion::getModelId,id);
modelVersionLambdaQueryWrapper.eq(ModelVersion::getDelFlag,"0");
List<ModelVersion> modelVersions = modelVersionMapper.selectList(modelVersionLambdaQueryWrapper);
requestModel.setModelProduct(modelVersion1);
requestModel.setModelVersionList(modelVersions);
return AjaxResult.success(requestModel);
} }
@ApiOperation(value = "添加模型") @ApiOperation(value = "添加模型")
@PostMapping("/insert") @PostMapping("/insert")
public R<String> addupdateModel(@RequestBody RequestModel requestModel) { public AjaxResult addupdateModel(@RequestBody RequestModel requestModel) {
ModelProduct modelProduct = requestModel.getModelProduct(); ModelProduct modelProduct = requestModel.getModelProduct();
Long userId = SecurityUtils.getUserId(); Long userId = SecurityUtils.getUserId();
modelProduct.setUserId(userId); modelProduct.setUserId(userId);
@ -87,7 +103,7 @@ public class MallProductController extends BaseController {
@ApiOperation(value = "修改模型") @ApiOperation(value = "修改模型")
@PostMapping("/update") @PostMapping("/update")
public R<Object> updateModel(@RequestBody RequestModel requestModel) { public AjaxResult updateModel(@RequestBody RequestModel requestModel) {
ModelProduct modelProduct = requestModel.getModelProduct(); ModelProduct modelProduct = requestModel.getModelProduct();
Long userId = SecurityUtils.getUserId(); Long userId = SecurityUtils.getUserId();
@ -95,15 +111,15 @@ public class MallProductController extends BaseController {
modelProduct.setUpdateBy(getUsername()); modelProduct.setUpdateBy(getUsername());
modelService.updaModel(requestModel); modelService.updaModel(requestModel);
return R.ok(); return AjaxResult.success("修改成功");
} }
@ApiOperation(value = "删除模型") @ApiOperation(value = "删除模型")
@GetMapping("delete") @GetMapping("delete")
public R<Object> delete(@Valid @NotNull(message = "模型id不能为空") Long id) { public AjaxResult delete(@Valid @NotNull(message = "模型id不能为空") @RequestParam Long id) {
modelService.removeById(id); modelService.removeById(id);
return R.ok(); return AjaxResult.success();
} }
/** /**
@ -114,7 +130,7 @@ public class MallProductController extends BaseController {
*/ */
@ApiOperation(value = "查询模型详情") @ApiOperation(value = "查询模型详情")
@GetMapping("/selectModelById") @GetMapping("/selectModelById")
public R<ModelProduct> selectModelById(@RequestParam Long id) { public AjaxResult selectModelById(@Valid @NotNull(message = "模型id不能为空") @RequestParam Long id) {
return modelService.selectModelById(id); return modelService.selectModelById(id);
} }
@ -129,9 +145,9 @@ public class MallProductController extends BaseController {
*/ */
@ApiOperation(value = "设置模型置顶状态") @ApiOperation(value = "设置模型置顶状态")
@GetMapping("/{id}/top") @GetMapping("/{id}/top")
public R<Object> setModelTop(@PathVariable Long id, @RequestParam boolean isTop) { public AjaxResult setModelTop(@PathVariable Long id, @RequestParam boolean isTop) {
modelService.setModelTop(id, isTop); modelService.setModelTop(id, isTop);
return R.ok(); return AjaxResult.success();
} }

View File

@ -53,13 +53,13 @@ public class ModelVersionController extends BaseController {
@ApiOperation(value = "模型版本详情") @ApiOperation(value = "模型版本详情")
@GetMapping("finbyid") @GetMapping("finbyid")
public R<ModelVersion> finbyid(@RequestParam Long id) public R<List<ModelVersion>> finbyid(@RequestParam Long id)
{ {
ModelVersion modelVersion1 = modelVersionService.getById(id); List<ModelVersion> modelVersionList = modelVersionService.finbyid(id);
return R.ok(modelVersion1); return R.ok(modelVersionList);
} }

View File

@ -47,8 +47,8 @@ public class ModelVersion extends BaseEntity {
/** /**
* ID * ID
*/ */
@ApiModelProperty(value = "模型类型ID") @ApiModelProperty(value = "基础模型")
private Long modelType; private Long modelVersionType;
/** /**
* *
*/ */
@ -152,13 +152,13 @@ public class ModelVersion extends BaseEntity {
/** /**
* *
*/ */
@ApiModelProperty(value = "审核状态") // @ApiModelProperty(value = "审核状态")
private Integer auditStatus; // private Integer auditStatus;
/** // /**
* // * 审核失败原因
*/ // */
@ApiModelProperty(value = "审核失败原因") // @ApiModelProperty(value = "审核失败原因")
private String auditText; // private String auditText;
/** /**
* 0 2 * 0 2
*/ */

View File

@ -170,10 +170,18 @@ public class WorkFlow {
private List<String> typeList; private List<String> typeList;
/** /**
* 0 1 * 0 1
*/ */
@ApiModelProperty(value = "是否关注 0关注 1关注") @ApiModelProperty(value = "是否关注 0关注 1关注")
@TableField(exist = false) @TableField(exist = false)
private Integer isAttention; private Integer isAttention;
/**
* 0 1
*/
@ApiModelProperty(value = "是否点赞 0未点赞 1点赞")
@TableField(exist = false)
private Integer isLike;
} }

View File

@ -22,4 +22,6 @@ public interface ModelVersionService extends IService<ModelVersion> {
R<List<ModelVersion>> selectByModelId(Long modelId); R<List<ModelVersion>> selectByModelId(Long modelId);
List<ModelVersion> finbyid(Long id);
} }

View File

@ -20,4 +20,6 @@ public interface WorkFlowLikeService extends IService<WorkFlowLike> {
void like(Long imageId); void like(Long imageId);
TableDataInfo listByPage(PageDomain pageDomain); TableDataInfo listByPage(PageDomain pageDomain);
WorkFlowLike selectWorkFlowLikeById(Long userId, Long id);
} }

View File

@ -187,7 +187,7 @@ public class ModelServiceImpl extends ServiceImpl<ModelMapper,ModelProduct> impl
@Override @Override
public R<String> addModel(RequestModel requestModel) { public R<String> addModel(RequestModel requestModel) {
//获取封面图 //获取封面图
String filePath = requestModel.getModelVersionList().get(0).getFilePath(); String filePath = requestModel.getModelVersionList().get(0).getSampleImagePaths();
String[] split = filePath.split(","); String[] split = filePath.split(",");
ModelProduct modelProduct = requestModel.getModelProduct(); ModelProduct modelProduct = requestModel.getModelProduct();
modelProduct.setSurfaceUrl(split[0]); modelProduct.setSurfaceUrl(split[0]);
@ -226,7 +226,7 @@ public class ModelServiceImpl extends ServiceImpl<ModelMapper,ModelProduct> impl
//批量修改 //批量修改
for (ModelVersion modelVersion : requestModel.getModelVersionList()) { for (ModelVersion modelVersion : requestModel.getModelVersionList()) {
modelVersion.setAuditStatus(3);
modelVersionMapper.updateById(modelVersion); modelVersionMapper.updateById(modelVersion);
} }
@ -304,9 +304,9 @@ public class ModelServiceImpl extends ServiceImpl<ModelMapper,ModelProduct> impl
} }
//修改为合格 //修改为合格
modelProduct.setAuditText(""); // modelProduct.setAuditText("");
modelProduct.setAuditStatus(modelProduct.getJurisdiction()); // modelProduct.setAuditStatus(modelProduct.getJurisdiction());
baseMapper.updateById(modelProduct); // baseMapper.updateById(modelProduct);
} }
} }

View File

@ -79,5 +79,21 @@ public class ModelVersionServiceImpl extends ServiceImpl< ModelVersionMapper,Mo
return R.ok(modelVersions); return R.ok(modelVersions);
} }
@Override
public List<ModelVersion> finbyid(Long id) {
LambdaQueryWrapper<ModelVersion> modelVersionLambdaQueryWrapper = new LambdaQueryWrapper<>();
modelVersionLambdaQueryWrapper.eq(ModelVersion::getModelId,id);
modelVersionLambdaQueryWrapper.eq(ModelVersion::getDelFlag,0);
List<ModelVersion> modelVersions = baseMapper.selectList(modelVersionLambdaQueryWrapper);
for (ModelVersion modelVersion : modelVersions) {
}
return modelVersions;
}
} }

View File

@ -1,6 +1,7 @@
package com.mcwl.resource.service.impl; package com.mcwl.resource.service.impl;
import cn.hutool.core.bean.BeanUtil; 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.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 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.exception.ServiceException;
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.resource.domain.ModelLike;
import com.mcwl.resource.domain.ModelProduct;
import com.mcwl.resource.domain.WorkFlow; import com.mcwl.resource.domain.WorkFlow;
import com.mcwl.resource.domain.WorkFlowLike; import com.mcwl.resource.domain.WorkFlowLike;
import com.mcwl.resource.domain.vo.ModelLikeVo;
import com.mcwl.resource.domain.vo.WorkFlowLikeVo; import com.mcwl.resource.domain.vo.WorkFlowLikeVo;
import com.mcwl.resource.mapper.WorkFlowLikeMapper; import com.mcwl.resource.mapper.WorkFlowLikeMapper;
import com.mcwl.resource.mapper.WorkFlowMapper; import com.mcwl.resource.mapper.WorkFlowMapper;
@ -134,6 +132,16 @@ public class WorkFlowLikeServiceImpl extends ServiceImpl<WorkFlowLikeMapper, Wor
return tableDataInfo; return tableDataInfo;
} }
@Override
public WorkFlowLike selectWorkFlowLikeById(Long userId, Long id) {
LambdaQueryWrapper<WorkFlowLike> workFlowLikeLambdaQueryWrapper = new LambdaQueryWrapper<>();
workFlowLikeLambdaQueryWrapper.eq(WorkFlowLike::getWorkFlowId,id);
workFlowLikeLambdaQueryWrapper.eq(WorkFlowLike::getUserId,userId);
return baseMapper.selectOne(workFlowLikeLambdaQueryWrapper);
}
private Page<WorkFlowLike> initPage(PageDomain pageDomain) { private Page<WorkFlowLike> initPage(PageDomain pageDomain) {
Page<WorkFlowLike> page = new Page<>(pageDomain.getPageNum(), pageDomain.getPageSize()); Page<WorkFlowLike> page = new Page<>(pageDomain.getPageNum(), pageDomain.getPageSize());

View File

@ -20,6 +20,7 @@ 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.SysUserAttention;
import com.mcwl.resource.domain.WorkFlow; import com.mcwl.resource.domain.WorkFlow;
import com.mcwl.resource.domain.WorkFlowLike;
import com.mcwl.resource.domain.WorkFlowVersion; 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;
@ -29,7 +30,6 @@ import com.mcwl.resource.domain.vo.WorkFlowVo;
import com.mcwl.resource.mapper.SysUserAttentionMapper; import com.mcwl.resource.mapper.SysUserAttentionMapper;
import com.mcwl.resource.mapper.WorkFlowMapper; import com.mcwl.resource.mapper.WorkFlowMapper;
import com.mcwl.resource.mapper.WorkFlowVersionMapper; import com.mcwl.resource.mapper.WorkFlowVersionMapper;
import com.mcwl.resource.service.ToActivityService;
import com.mcwl.resource.service.WorkFlowService; import com.mcwl.resource.service.WorkFlowService;
import com.mcwl.system.init.DictInit; import com.mcwl.system.init.DictInit;
import com.mcwl.system.service.ISysUserService; import com.mcwl.system.service.ISysUserService;
@ -62,7 +62,7 @@ public class WorkFlowServiceImpl extends ServiceImpl<WorkFlowMapper, WorkFlow> i
private WorkFlowVersionMapper workFlowVersionMapper; private WorkFlowVersionMapper workFlowVersionMapper;
@Autowired @Autowired
private ToActivityService toActivityService; private WorkFlowLikeServiceImpl workFlowLikeService;
@Autowired @Autowired
private SysUserAttentionMapper sysUserAttentionMapper; private SysUserAttentionMapper sysUserAttentionMapper;
@ -163,9 +163,9 @@ public class WorkFlowServiceImpl extends ServiceImpl<WorkFlowMapper, WorkFlow> i
} }
//修改为合格 //修改为合格
workFlow.setAuditText(""); // workFlow.setAuditText("");
workFlow.setAuditStatus(workFlow.getJurisdiction()); // workFlow.setAuditStatus(workFlow.getJurisdiction());
flowMapper.updateById(workFlow); // flowMapper.updateById(workFlow);
} }
} }
@ -383,16 +383,22 @@ public class WorkFlowServiceImpl extends ServiceImpl<WorkFlowMapper, WorkFlow> i
ArrayList<String> strings = new ArrayList<>(); ArrayList<String> strings = new ArrayList<>();
String[] split = workFlow.getType().split(","); String[] split = workFlow.getType().split(",");
for (String s : split) { for (String s : split) {
if (s != "") { if (s.equals("")) {
strings.add(DictInit.getDictValue(DictConstants.WORK_FLOW_TYPE_CHILD, s)); strings.add(DictInit.getDictValue(DictConstants.WORK_FLOW_TYPE_CHILD, s));
} }
} }
workFlow.setTypeList(strings); workFlow.setTypeList(strings);
} }
workFlow.setIsAttention(0); workFlow.setIsAttention(1);
SysUserAttention sysUserAttention = sysUserAttentionMapper.selectAttention(SecurityUtils.getUserId(), workFlow.getUserId()); SysUserAttention sysUserAttention = sysUserAttentionMapper.selectAttention(SecurityUtils.getUserId(), workFlow.getUserId());
if (sysUserAttention == null){ 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); return R.ok(workFlow);
} }

View File

@ -7,22 +7,20 @@
<insert id="addModelVersion"> <insert id="addModelVersion">
INSERT INTO model_version ( 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, is_free, is_public, is_encrypt, is_online_use, allow_download_image,
allow_software_use, allow_fusion, allow_commercial_use, allow_usage, allow_software_use, allow_fusion, allow_commercial_use, allow_usage,
is_exclusive_model, sample_image_paths, hide_image_gen_info, audit_status, is_exclusive_model, sample_image_paths, hide_image_gen_info, del_flag
audit_text, del_flag
) )
VALUES VALUES
<foreach collection="modelVersionList" item="item" separator=","> <foreach collection="modelVersionList" item="item" separator=",">
( (
#{modelProduct.id},#{item.versionName}, #{item.modelType}, #{item.filePath}, #{item.triggerWords}, #{modelProduct.id},#{item.versionName}, #{item.versionDescription},#{item.modelVersionType}, #{item.filePath},
#{item.sampling}, #{item.high}, #{item.vae}, #{item.cfg}, #{item.fileName},#{item.triggerWords},#{item.sampling}, #{item.high}, #{item.vae}, #{item.cfg},
#{item.isFree}, #{item.isPublic}, #{item.isEncrypt}, #{item.isOnlineUse}, #{item.isFree}, #{item.isPublic}, #{item.isEncrypt}, #{item.isOnlineUse},
#{item.allowDownloadImage}, #{item.allowSoftwareUse}, #{item.allowFusion}, #{item.allowDownloadImage}, #{item.allowSoftwareUse}, #{item.allowFusion},
#{item.allowCommercialUse}, #{item.allowUsage}, #{item.isExclusiveModel}, #{item.allowCommercialUse}, #{item.allowUsage}, #{item.isExclusiveModel},
#{item.sampleImagePaths}, #{item.hideImageGenInfo}, 3, #{item.sampleImagePaths}, #{item.hideImageGenInfo},'0'
#{item.auditText},'0'
) )
</foreach> </foreach>
</insert> </insert>