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 1a3e1a6..d2f4d80 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,8 +1,10 @@ package com.mcwl.web.controller.resource; +import cn.hutool.core.bean.BeanUtil; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.mcwl.common.core.controller.BaseController; import com.mcwl.common.core.domain.AjaxResult; +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; @@ -12,6 +14,7 @@ import com.mcwl.resource.domain.request.RequestWorkFlow; import com.mcwl.resource.domain.vo.MallProductVo; import com.mcwl.resource.service.ModelImageService; import com.mcwl.resource.service.ModelService; +import com.mcwl.resource.service.WorkFlowService; import com.mcwl.system.service.ISysUserService; import com.mcwl.web.controller.common.OssUtil; import org.springframework.beans.factory.annotation.Autowired; @@ -23,6 +26,7 @@ import java.util.List; /** * 商品 + * * @Author:ChenYan * @Project:McWl * @Package:com.mcwl.web.controller.resource @@ -42,6 +46,9 @@ public class MallProductController extends BaseController { @Autowired private ModelImageService modelImageService; + @Autowired + private WorkFlowService workFlowService; + /*** * @@ -50,7 +57,7 @@ public class MallProductController extends BaseController { * @return */ @PostMapping("/file") - public AjaxResult Malifile(@RequestParam MultipartFile file){ + public AjaxResult Malifile(@RequestParam MultipartFile file) { String s = OssUtil.uploadMultipartFile(file); return AjaxResult.success(s); @@ -64,14 +71,12 @@ public class MallProductController extends BaseController { * @return */ @PostMapping("/zipUrlFile") - public AjaxResult zipUrlFile(@RequestParam MultipartFile file){ + public AjaxResult zipUrlFile(@RequestParam MultipartFile file) { String s = OssUtil.uploadMultipartFile(file); return AjaxResult.success(s); } - - /*** * * 下载zip @@ -79,15 +84,12 @@ public class MallProductController extends BaseController { * @return */ @PostMapping("/zipUrl") - public AjaxResult zipUrl(@RequestParam MultipartFile file){ + public AjaxResult zipUrl(@RequestParam MultipartFile file) { String s = OssUtil.uploadMultipartFile(file); return AjaxResult.success(s); } - - - /** * 模型列表 */ @@ -98,19 +100,15 @@ public class MallProductController extends BaseController { } - - @PostMapping("finbyid") - public AjaxResult finbyid(@RequestBody ModelProduct modelVersion) - { + public AjaxResult finbyid(@RequestBody ModelProduct modelVersion) { ModelProduct modelVersion1 = modelService.getById(modelVersion.getId()); return AjaxResult.success(modelVersion1); } - @PostMapping("/insert") - public AjaxResult addupdateModel(@RequestBody RequestModel requestModel){ + public AjaxResult addupdateModel(@RequestBody RequestModel requestModel) { ModelProduct modelProduct = requestModel.getModelProduct(); Long userId = SecurityUtils.getUserId(); modelProduct.setUserId(userId); @@ -119,7 +117,7 @@ public class MallProductController extends BaseController { } @PostMapping("/update") - public AjaxResult updateModel(@RequestBody RequestModel requestModel){ + public AjaxResult updateModel(@RequestBody RequestModel requestModel) { ModelProduct modelProduct = requestModel.getModelProduct(); Long userId = SecurityUtils.getUserId(); @@ -132,48 +130,71 @@ public class MallProductController extends BaseController { @PostMapping("delete") - public AjaxResult delete(@RequestBody ModelProduct modelVersion) - { + public AjaxResult delete(@RequestBody ModelProduct modelVersion) { modelService.removeById(modelVersion.getId()); return AjaxResult.success(); } - /** - * 查看用户发布的作品 - * @return - */ - @PostMapping("/selectByUserId") - public AjaxResult selectByUserId(@RequestBody MallProductVo mallProductVo){ - - Page mallProductList = modelService.selectByUserId(mallProductVo); - return AjaxResult.success(mallProductList); - } - /** * 我的发布-模型 */ @PostMapping("/selectByUserIdModel") - public AjaxResult selectByUserIdModel(@RequestBody MallProductVo mallProductVo){ + public TableDataInfo selectByUserIdModel(@RequestBody ModelImagePageRes imagePageRes) { - return AjaxResult.success(); + return modelService.listByPage(imagePageRes); } /** * 我的发布-工作流 */ @PostMapping("/selectByUserIdWorkFlow") - public AjaxResult selectByUserIdWorkFlow(@RequestBody MallProductVo mallProductVo){ + public TableDataInfo selectByUserIdWorkFlow(@RequestBody ModelImagePageRes imagePageRes) { - return AjaxResult.success(); + return workFlowService.listByPage(imagePageRes); } /** * 我的发布-图片 */ @PostMapping("/selectByUserIdImage") - public TableDataInfo selectByUserIdImage(@RequestBody ModelImagePageRes imagePageRes){ + public TableDataInfo selectByUserIdImage(@RequestBody ModelImagePageRes imagePageRes) { return modelImageService.listByPage(imagePageRes); } + + /** + * 点赞-模型 + */ + @PostMapping("/likeModel") + public TableDataInfo likeModel(@RequestBody PageDomain pageDomain) { + ModelImagePageRes imagePageRes = new ModelImagePageRes(); + BeanUtil.copyProperties(pageDomain, imagePageRes); + imagePageRes.setUserId(SecurityUtils.getUserId()); + return modelService.listByPage(imagePageRes); + } + + /** + * 点赞-工作流 + */ + @PostMapping("/likeWorkFlow") + public TableDataInfo likeWorkFlow(@RequestBody PageDomain pageDomain) { + ModelImagePageRes imagePageRes = new ModelImagePageRes(); + BeanUtil.copyProperties(pageDomain, imagePageRes); + imagePageRes.setUserId(SecurityUtils.getUserId()); + return workFlowService.listByPage(imagePageRes); + } + + /** + * 点赞-图片 + */ + @PostMapping("/likeImage") + public TableDataInfo likeImage(@RequestBody PageDomain pageDomain) { + ModelImagePageRes imagePageRes = new ModelImagePageRes(); + BeanUtil.copyProperties(pageDomain, imagePageRes); + imagePageRes.setUserId(SecurityUtils.getUserId()); + return modelImageService.listByPage(imagePageRes); + } + + } 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 b50826d..dc2875e 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 @@ -79,6 +79,10 @@ public class ModelProduct extends BaseEntity { * 生图次数 */ private Integer reals; + /** + * 封面图 + */ + private String surfaceUrl; /** * 下载次数 */ 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 456cd8a..950f983 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 @@ -35,6 +35,10 @@ public class WorkFlow { */ @TableId private Long id; + /** + * 用户id + */ + private Long userId; /** * 名称(最多30字) */ diff --git a/mcwl-resource/src/main/java/com/mcwl/resource/domain/vo/MallProductVo.java b/mcwl-resource/src/main/java/com/mcwl/resource/domain/vo/MallProductVo.java index e15c2ad..32bb858 100644 --- a/mcwl-resource/src/main/java/com/mcwl/resource/domain/vo/MallProductVo.java +++ b/mcwl-resource/src/main/java/com/mcwl/resource/domain/vo/MallProductVo.java @@ -1,6 +1,7 @@ package com.mcwl.resource.domain.vo; import com.fasterxml.jackson.annotation.JsonFormat; +import com.mcwl.common.core.page.PageDomain; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; diff --git a/mcwl-resource/src/main/java/com/mcwl/resource/domain/vo/ModelVo.java b/mcwl-resource/src/main/java/com/mcwl/resource/domain/vo/ModelVo.java index 266d35c..5945664 100644 --- a/mcwl-resource/src/main/java/com/mcwl/resource/domain/vo/ModelVo.java +++ b/mcwl-resource/src/main/java/com/mcwl/resource/domain/vo/ModelVo.java @@ -5,9 +5,17 @@ import lombok.Data; @Data public class ModelVo { /** - * 图片ID + * 模型id */ private Long id; + /** + * 模型名称 + */ + private String modelName; + /** + * 封面图 + */ + private String surfaceUrl; /** * 用户ID */ @@ -20,54 +28,14 @@ public class ModelVo { * 用户头像 */ private String userAvatar; - /** - * 图片地址(最多8张,切割) - */ - private String imagePaths; - /** - * 是否添加水印 - */ - private Integer hasWatermark; - /** - * 是否会员下载 - */ - private Integer isMemberDownload; - /** - * 是否不可下载 - */ - private Integer isNotDownloadable; - /** - * 是否隐藏生成信息 - */ - private Integer hideGenInfo; - /** - * 图片标题(最多30字) - */ - private String title; - /** - * 图片标签(多个,切割) - */ - private String tags; - /** - * 描述信息(最多500) - */ - private String description; /** * 在线生成数 */ - private Integer onlineGenNum; + private Integer reals; /** * 下载数 */ - private Integer downloadNum; - /** - * 返图数 - */ - private Integer returnNum; - /** - * 点赞数 - */ - private Integer likeNum; + private Integer numbers; diff --git a/mcwl-resource/src/main/java/com/mcwl/resource/domain/vo/WorkFlowVo.java b/mcwl-resource/src/main/java/com/mcwl/resource/domain/vo/WorkFlowVo.java new file mode 100644 index 0000000..b36fc3f --- /dev/null +++ b/mcwl-resource/src/main/java/com/mcwl/resource/domain/vo/WorkFlowVo.java @@ -0,0 +1,42 @@ +package com.mcwl.resource.domain.vo; + +import lombok.Data; + +@Data +public class WorkFlowVo { + /** + * 工作流id + */ + private Long id; + /** + * 工作流名称 + */ + private String workflowName; + /** + * 封面图 + */ + private String coverPath; + /** + * 用户ID + */ + private Long userId; + /** + * 用户名称 + */ + private String userName; + /** + * 用户头像 + */ + private String userAvatar; + /** + * 在线生成数 + */ + private Integer useNumber; + /** + * 下载数 + */ + private Integer downloadNumber; + + + +} diff --git a/mcwl-resource/src/main/java/com/mcwl/resource/service/WorkFlowService.java b/mcwl-resource/src/main/java/com/mcwl/resource/service/WorkFlowService.java index 223e663..2fff370 100644 --- a/mcwl-resource/src/main/java/com/mcwl/resource/service/WorkFlowService.java +++ b/mcwl-resource/src/main/java/com/mcwl/resource/service/WorkFlowService.java @@ -1,6 +1,10 @@ package com.mcwl.resource.service; +import com.baomidou.mybatisplus.extension.service.IService; import com.mcwl.common.core.domain.AjaxResult; +import com.mcwl.common.core.page.TableDataInfo; +import com.mcwl.resource.domain.WorkFlow; +import com.mcwl.resource.domain.dto.ModelImagePageRes; import com.mcwl.resource.domain.request.RequestWorkFlow; import com.mcwl.resource.domain.vo.PageVo; @@ -11,7 +15,7 @@ import com.mcwl.resource.domain.vo.PageVo; * @apiNote */ -public interface WorkFlowService { +public interface WorkFlowService extends IService { AjaxResult addWorkFlow(RequestWorkFlow requestWorkFlow); void updateWorkFlow(RequestWorkFlow requestWorkFlow); @@ -21,4 +25,6 @@ public interface WorkFlowService { AjaxResult selectWorkFlow(PageVo pageVo); AjaxResult selectWorkFlowById(Long id); + + TableDataInfo listByPage(ModelImagePageRes imagePageRes); } 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 c84e4a3..d9f73d1 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 @@ -20,6 +20,7 @@ import com.mcwl.resource.domain.dto.ModelImagePageRes; import com.mcwl.resource.domain.request.RequestModel; import com.mcwl.resource.domain.vo.MallProductVo; import com.mcwl.resource.domain.vo.ModelImageVo; +import com.mcwl.resource.domain.vo.ModelVo; import com.mcwl.resource.mapper.ModelMapper; import com.mcwl.resource.mapper.ModelVersionMapper; @@ -114,7 +115,6 @@ public class ModelServiceImpl extends ServiceImpl impl LambdaQueryWrapper lqw = new LambdaQueryWrapper<>(); lqw.eq(imagePageRes.getStatus() != null, ModelProduct::getAuditSatus, imagePageRes.getStatus()) .eq(imagePageRes.getUserId() != null, ModelProduct::getUserId, imagePageRes.getUserId()) - .eq(imagePageRes.getPageNum() != null, ModelProduct::getUserId, imagePageRes.getUserId()) .ge(imagePageRes.getStartTime() != null, ModelProduct::getCreateTime, imagePageRes.getStartTime()) .le(imagePageRes.getEndTime() != null, ModelProduct::getCreateTime, imagePageRes.getEndTime()); @@ -123,23 +123,23 @@ public class ModelServiceImpl extends ServiceImpl impl List modelImageList = page.getRecords(); // Model数据转为ModelPageVo - List modelImageVoList = new ArrayList<>(); + List modelVoList = new ArrayList<>(); for (ModelProduct modelImage : modelImageList) { - ModelImageVo modelImageVo = new ModelImageVo(); - BeanUtil.copyProperties(modelImage, modelImageVo); + ModelVo modelVo = new ModelVo(); + BeanUtil.copyProperties(modelImage, modelVo); // 获取用户信息 SysUser sysUser = sysUserService.selectUserById(modelImage.getUserId()); - modelImageVo.setUserId(sysUser.getUserId()); - modelImageVo.setUserName(sysUser.getUserName()); - modelImageVo.setUserAvatar(sysUser.getAvatar()); - modelImageVoList.add(modelImageVo); + modelVo.setUserId(sysUser.getUserId()); + modelVo.setUserName(sysUser.getUserName()); + modelVo.setUserAvatar(sysUser.getAvatar()); + modelVoList.add(modelVo); } // 封装分页数据 TableDataInfo rspData = new TableDataInfo(); rspData.setCode(HttpStatus.SUCCESS); rspData.setMsg("查询成功"); - rspData.setRows(modelImageVoList); + rspData.setRows(modelVoList); rspData.setTotal(page.getTotal()); return rspData; 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 b858567..e866908 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 @@ -1,20 +1,31 @@ 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.toolkit.ObjectUtils; +import com.baomidou.mybatisplus.core.metadata.OrderItem; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.mcwl.common.constant.DictConstants; +import com.mcwl.common.constant.HttpStatus; import com.mcwl.common.core.domain.AjaxResult; +import com.mcwl.common.core.domain.entity.SysUser; +import com.mcwl.common.core.page.TableDataInfo; import com.mcwl.common.utils.StringUtils; +import com.mcwl.resource.domain.ModelProduct; import com.mcwl.resource.domain.WorkFlow; import com.mcwl.resource.domain.WorkFlowVersion; +import com.mcwl.resource.domain.dto.ModelImagePageRes; import com.mcwl.resource.domain.request.RequestWorkFlow; +import com.mcwl.resource.domain.vo.ModelVo; import com.mcwl.resource.domain.vo.PageVo; +import com.mcwl.resource.domain.vo.WorkFlowVo; 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.service.ISysUserService; import com.mcwl.web.controller.init.DictInit; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; @@ -22,6 +33,8 @@ import org.springframework.stereotype.Service; import java.util.ArrayList; import java.util.Date; +import java.util.List; +import java.util.Objects; /** * 工作流 业务实现层 @@ -32,7 +45,7 @@ import java.util.Date; @Slf4j @Service -public class WorkFlowServiceImpl implements WorkFlowService { +public class WorkFlowServiceImpl extends ServiceImpl implements WorkFlowService { @Autowired private WorkFlowMapper flowMapper; @@ -43,6 +56,9 @@ public class WorkFlowServiceImpl implements WorkFlowService { @Autowired private ToActivityService toActivityService; + @Autowired + private ISysUserService sysUserService; + @Override public AjaxResult addWorkFlow(RequestWorkFlow requestWorkFlow) { @@ -173,4 +189,51 @@ public class WorkFlowServiceImpl implements WorkFlowService { return AjaxResult.success(workFlow); } + + + @Override + public TableDataInfo listByPage(ModelImagePageRes imagePageRes) { + + Page page = new Page<>(imagePageRes.getPageNum(), imagePageRes.getPageSize()); + if (StringUtils.isEmpty(imagePageRes.getOrderByColumn())) { + imagePageRes.setOrderByColumn("create_time"); + } + // 设置排序 + boolean isAsc = Objects.equals(imagePageRes.getIsAsc(), "asc"); + OrderItem orderItem = new OrderItem(imagePageRes.getOrderByColumn(), isAsc); + page.addOrder(orderItem); + + LambdaQueryWrapper lqw = new LambdaQueryWrapper<>(); + lqw.eq(imagePageRes.getStatus() != null, WorkFlow::getAuditStatus, imagePageRes.getStatus()) + .eq(imagePageRes.getUserId() != null, WorkFlow::getUserId, imagePageRes.getUserId()) + .ge(imagePageRes.getStartTime() != null, WorkFlow::getCreateTime, imagePageRes.getStartTime()) + .le(imagePageRes.getEndTime() != null, WorkFlow::getCreateTime, imagePageRes.getEndTime()); + + baseMapper.selectPage(page, lqw); + // 获取分页数据 + List workFlowList = page.getRecords(); + + // WorkFlow数据转为WorkFlowVo + List workFlowVoList = new ArrayList<>(); + for (WorkFlow workFlow : workFlowList) { + WorkFlowVo workFlowVo = new WorkFlowVo(); + BeanUtil.copyProperties(workFlow, workFlowVo); + // 获取用户信息 + SysUser sysUser = sysUserService.selectUserById(workFlow.getUserId()); + workFlowVo.setUserId(sysUser.getUserId()); + workFlowVo.setUserName(sysUser.getUserName()); + workFlowVo.setUserAvatar(sysUser.getAvatar()); + workFlowVoList.add(workFlowVo); + } + + // 封装分页数据 + TableDataInfo rspData = new TableDataInfo(); + rspData.setCode(HttpStatus.SUCCESS); + rspData.setMsg("查询成功"); + rspData.setRows(workFlowVoList); + rspData.setTotal(page.getTotal()); + + return rspData; + + } }