feat:
parent
511bd96d84
commit
573ccd5ef8
|
@ -6,8 +6,10 @@ import com.mcwl.common.core.domain.AjaxResult;
|
||||||
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.dto.ModelImagePageRes;
|
||||||
import com.mcwl.resource.domain.vo.MallProductVo;
|
import com.mcwl.resource.domain.vo.MallProductVo;
|
||||||
import com.mcwl.resource.service.ModelService;
|
import com.mcwl.resource.service.ModelService;
|
||||||
|
import com.mcwl.system.service.ISysUserService;
|
||||||
import com.mcwl.web.controller.common.OssUtil;
|
import com.mcwl.web.controller.common.OssUtil;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
@ -29,8 +31,8 @@ import java.util.List;
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/model")
|
@RequestMapping("/model")
|
||||||
public class MallProductController extends BaseController {
|
public class MallProductController extends BaseController {
|
||||||
|
@Autowired
|
||||||
|
private ISysUserService sysUserService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ModelService modelService;
|
private ModelService modelService;
|
||||||
|
@ -82,14 +84,12 @@ public class MallProductController extends BaseController {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询商品列表
|
* 模型列表
|
||||||
*/
|
*/
|
||||||
@PostMapping("/list")
|
@PostMapping("/list")
|
||||||
public TableDataInfo list(@RequestBody ModelProduct mallProduct)
|
public TableDataInfo list(@RequestBody ModelImagePageRes imagePageRes) {
|
||||||
{
|
|
||||||
startPage();
|
return modelService.listByPage(imagePageRes);
|
||||||
List<ModelProduct> list = modelService.selectMallProductList(mallProduct);
|
|
||||||
return getDataTable(list);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,12 +2,16 @@ package com.mcwl.web.controller.resource;
|
||||||
|
|
||||||
import com.mcwl.common.core.domain.AjaxResult;
|
import com.mcwl.common.core.domain.AjaxResult;
|
||||||
import com.mcwl.resource.domain.ModelComment;
|
import com.mcwl.resource.domain.ModelComment;
|
||||||
|
import com.mcwl.resource.domain.vo.ModelCommentVo;
|
||||||
import com.mcwl.resource.service.ModelCommentLikeService;
|
import com.mcwl.resource.service.ModelCommentLikeService;
|
||||||
import com.mcwl.resource.service.ModelCommentService;
|
import com.mcwl.resource.service.ModelCommentService;
|
||||||
import com.mcwl.resource.service.ModelLikeService;
|
import com.mcwl.resource.service.ModelLikeService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author:ChenYan
|
* @Author:ChenYan
|
||||||
* @Project:McWl
|
* @Project:McWl
|
||||||
|
@ -27,10 +31,12 @@ public class ModelCommentController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private ModelCommentLikeService modelCommentLikeService;
|
private ModelCommentLikeService modelCommentLikeService;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 模型点赞/取消
|
* 模型点赞/取消
|
||||||
*/
|
*/
|
||||||
@GetMapping("/imageLike/{imageId}")
|
@GetMapping("/modelLike/{modelId}")
|
||||||
public AjaxResult like(@PathVariable Long imageId) {
|
public AjaxResult like(@PathVariable Long imageId) {
|
||||||
modelLikeService.like(imageId);
|
modelLikeService.like(imageId);
|
||||||
return AjaxResult.success();
|
return AjaxResult.success();
|
||||||
|
@ -57,8 +63,24 @@ public class ModelCommentController {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取模型评论
|
||||||
|
*/
|
||||||
|
@GetMapping("/comment/{modelId}")
|
||||||
|
public AjaxResult getComment(@PathVariable @NotNull(message = "模型id不能为空") Long modelId) {
|
||||||
|
List<ModelCommentVo> modelCommentList = modelCommentService.getComment(modelId);
|
||||||
|
return AjaxResult.success(modelCommentList);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除模型评论
|
||||||
|
*/
|
||||||
|
@GetMapping("/commentDelete/{commentId}")
|
||||||
|
public AjaxResult commentDelete(@PathVariable @NotNull(message = "评论id不能为空") Long commentId) {
|
||||||
|
modelCommentService.removeById(commentId);
|
||||||
|
return AjaxResult.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,22 +1,12 @@
|
||||||
package com.mcwl.web.controller.resource;
|
package com.mcwl.web.controller.resource;
|
||||||
|
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
||||||
import com.github.pagehelper.PageInfo;
|
|
||||||
import com.mcwl.common.constant.HttpStatus;
|
|
||||||
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.entity.SysUser;
|
import com.mcwl.common.core.domain.entity.SysUser;
|
||||||
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.common.utils.StringUtils;
|
|
||||||
import com.mcwl.common.utils.oss.OssUtil;
|
import com.mcwl.common.utils.oss.OssUtil;
|
||||||
import com.mcwl.resource.domain.ModelImage;
|
import com.mcwl.resource.domain.ModelImage;
|
||||||
import com.mcwl.resource.domain.ModelImageComment;
|
|
||||||
import com.mcwl.resource.domain.ModelImageCommentLike;
|
|
||||||
import com.mcwl.resource.domain.ModelImageLike;
|
|
||||||
import com.mcwl.resource.domain.dto.ModelImageCommentRes;
|
import com.mcwl.resource.domain.dto.ModelImageCommentRes;
|
||||||
import com.mcwl.resource.domain.dto.ModelImagePageRes;
|
import com.mcwl.resource.domain.dto.ModelImagePageRes;
|
||||||
import com.mcwl.resource.domain.dto.ModelImageRes;
|
import com.mcwl.resource.domain.dto.ModelImageRes;
|
||||||
|
@ -32,7 +22,6 @@ import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,66 @@
|
||||||
|
package com.mcwl.resource.domain.vo;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 评论区评论
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Data
|
||||||
|
public class ModelCommentVo {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户id
|
||||||
|
*/
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户名
|
||||||
|
*/
|
||||||
|
private String userName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户头像
|
||||||
|
*/
|
||||||
|
private String userAvatar;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 评论id
|
||||||
|
*/
|
||||||
|
private Long commentId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 评论内容
|
||||||
|
*/
|
||||||
|
private String content;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 子评论
|
||||||
|
*/
|
||||||
|
private List<ModelCommentVo> contentList = new ArrayList<>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 评论点赞数
|
||||||
|
*/
|
||||||
|
private Integer likeNum;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 评论时间
|
||||||
|
*/
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,74 @@
|
||||||
|
package com.mcwl.resource.domain.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class ModelVo {
|
||||||
|
/**
|
||||||
|
* 图片ID
|
||||||
|
*/
|
||||||
|
private Long id;
|
||||||
|
/**
|
||||||
|
* 用户ID
|
||||||
|
*/
|
||||||
|
private Long userId;
|
||||||
|
/**
|
||||||
|
* 用户名称
|
||||||
|
*/
|
||||||
|
private String userName;
|
||||||
|
/**
|
||||||
|
* 用户头像
|
||||||
|
*/
|
||||||
|
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 downloadNum;
|
||||||
|
/**
|
||||||
|
* 返图数
|
||||||
|
*/
|
||||||
|
private Integer returnNum;
|
||||||
|
/**
|
||||||
|
* 点赞数
|
||||||
|
*/
|
||||||
|
private Integer likeNum;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -2,6 +2,11 @@ package com.mcwl.resource.service;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.mcwl.resource.domain.ModelComment;
|
import com.mcwl.resource.domain.ModelComment;
|
||||||
|
import com.mcwl.resource.domain.vo.ModelCommentVo;
|
||||||
|
import com.mcwl.resource.domain.vo.ModelImageCommentVo;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author:ChenYan
|
* @Author:ChenYan
|
||||||
|
@ -14,4 +19,11 @@ import com.mcwl.resource.domain.ModelComment;
|
||||||
public interface ModelCommentService extends IService<ModelComment> {
|
public interface ModelCommentService extends IService<ModelComment> {
|
||||||
void comment(ModelComment modelComment);
|
void comment(ModelComment modelComment);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取评论
|
||||||
|
* @param imageId 图片id
|
||||||
|
* @return 评论区
|
||||||
|
*/
|
||||||
|
List<ModelCommentVo> getComment(Long imageId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,9 +2,11 @@ package com.mcwl.resource.service;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.mcwl.common.core.page.TableDataInfo;
|
||||||
import com.mcwl.common.domain.IdsParam;
|
import com.mcwl.common.domain.IdsParam;
|
||||||
import com.mcwl.resource.domain.ModelProduct;
|
import com.mcwl.resource.domain.ModelProduct;
|
||||||
import com.mcwl.resource.domain.ModelVersion;
|
import com.mcwl.resource.domain.ModelVersion;
|
||||||
|
import com.mcwl.resource.domain.dto.ModelImagePageRes;
|
||||||
import com.mcwl.resource.domain.vo.MallProductVo;
|
import com.mcwl.resource.domain.vo.MallProductVo;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -19,17 +21,10 @@ import java.util.List;
|
||||||
*/
|
*/
|
||||||
public interface ModelService extends IService<ModelProduct> {
|
public interface ModelService extends IService<ModelProduct> {
|
||||||
|
|
||||||
List<ModelProduct> selectMallProductList(ModelProduct sysJob);
|
|
||||||
|
|
||||||
int insertMallProduct(ModelProduct mallProduct);
|
|
||||||
|
|
||||||
int updateMallProduct(ModelProduct mallProduct);
|
|
||||||
|
|
||||||
|
|
||||||
void deleteMallProductByIds(IdsParam ids);
|
|
||||||
|
|
||||||
Page<ModelProduct> selectByUserId(MallProductVo mallProductVo);
|
Page<ModelProduct> selectByUserId(MallProductVo mallProductVo);
|
||||||
|
|
||||||
Page<ModelProduct> pageLike(MallProductVo mallProductVo, List<Long> list);
|
Page<ModelProduct> pageLike(MallProductVo mallProductVo, List<Long> list);
|
||||||
|
|
||||||
|
TableDataInfo listByPage(ModelImagePageRes imagePageRes);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,21 +1,33 @@
|
||||||
package com.mcwl.resource.service.impl;
|
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.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
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;
|
||||||
|
import com.mcwl.common.constant.HttpStatus;
|
||||||
|
import com.mcwl.common.core.domain.entity.SysUser;
|
||||||
|
import com.mcwl.common.core.page.TableDataInfo;
|
||||||
import com.mcwl.common.core.redis.RedisCache;
|
import com.mcwl.common.core.redis.RedisCache;
|
||||||
import com.mcwl.common.domain.IdsParam;
|
import com.mcwl.common.domain.IdsParam;
|
||||||
import com.mcwl.common.utils.SecurityUtils;
|
import com.mcwl.common.utils.SecurityUtils;
|
||||||
|
import com.mcwl.common.utils.StringUtils;
|
||||||
|
import com.mcwl.resource.domain.ModelImage;
|
||||||
import com.mcwl.resource.domain.ModelProduct;
|
import com.mcwl.resource.domain.ModelProduct;
|
||||||
|
import com.mcwl.resource.domain.dto.ModelImagePageRes;
|
||||||
import com.mcwl.resource.domain.vo.MallProductVo;
|
import com.mcwl.resource.domain.vo.MallProductVo;
|
||||||
|
import com.mcwl.resource.domain.vo.ModelImageVo;
|
||||||
import com.mcwl.resource.mapper.MallProductMapper;
|
import com.mcwl.resource.mapper.MallProductMapper;
|
||||||
|
|
||||||
import com.mcwl.resource.service.ModelService;
|
import com.mcwl.resource.service.ModelService;
|
||||||
|
import com.mcwl.system.service.ISysUserService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
|
||||||
/**模型 业务实现层
|
/**模型 业务实现层
|
||||||
|
@ -33,32 +45,10 @@ public class MallProductServiceImpl extends ServiceImpl<MallProductMapper,ModelP
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private MallProductMapper postMapper;
|
private MallProductMapper postMapper;
|
||||||
|
@Autowired
|
||||||
|
private ISysUserService sysUserService;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<ModelProduct> selectMallProductList(ModelProduct mallProduct) {
|
|
||||||
QueryWrapper<ModelProduct> queryWrapper = new QueryWrapper<>();
|
|
||||||
queryWrapper.lambda().eq(ModelProduct::getModelName, mallProduct.getModelName());
|
|
||||||
queryWrapper.lambda().eq(ModelProduct::getOriginalAuthorName, mallProduct.getOriginalAuthorName());
|
|
||||||
return postMapper.selectList(queryWrapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int insertMallProduct(ModelProduct mallProduct) {
|
|
||||||
return postMapper.insert(mallProduct);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int updateMallProduct(ModelProduct mallProduct) {
|
|
||||||
return postMapper.updateById(mallProduct);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void deleteMallProductByIds(IdsParam ids) {
|
|
||||||
postMapper.deleteBatchIds(ids.getIds());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<ModelProduct> selectByUserId(MallProductVo mallProductVo) {
|
public Page<ModelProduct> selectByUserId(MallProductVo mallProductVo) {
|
||||||
|
|
||||||
|
@ -95,4 +85,58 @@ public class MallProductServiceImpl extends ServiceImpl<MallProductMapper,ModelP
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询
|
||||||
|
*
|
||||||
|
* @param imagePageRes 分页参数
|
||||||
|
* @return 分页数据
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public TableDataInfo listByPage(ModelImagePageRes imagePageRes) {
|
||||||
|
|
||||||
|
Page<ModelProduct> 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<ModelProduct> 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());
|
||||||
|
|
||||||
|
postMapper.selectPage(page, lqw);
|
||||||
|
// 获取分页数据
|
||||||
|
List<ModelProduct> modelImageList = page.getRecords();
|
||||||
|
|
||||||
|
// Model数据转为ModelPageVo
|
||||||
|
List<ModelImageVo> modelImageVoList = new ArrayList<>();
|
||||||
|
for (ModelProduct modelImage : modelImageList) {
|
||||||
|
ModelImageVo modelImageVo = new ModelImageVo();
|
||||||
|
BeanUtil.copyProperties(modelImage, modelImageVo);
|
||||||
|
// 获取用户信息
|
||||||
|
SysUser sysUser = sysUserService.selectUserById(modelImage.getUserId());
|
||||||
|
modelImageVo.setUserId(sysUser.getUserId());
|
||||||
|
modelImageVo.setUserName(sysUser.getUserName());
|
||||||
|
modelImageVo.setUserAvatar(sysUser.getAvatar());
|
||||||
|
modelImageVoList.add(modelImageVo);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 封装分页数据
|
||||||
|
TableDataInfo rspData = new TableDataInfo();
|
||||||
|
rspData.setCode(HttpStatus.SUCCESS);
|
||||||
|
rspData.setMsg("查询成功");
|
||||||
|
rspData.setRows(modelImageVoList);
|
||||||
|
rspData.setTotal(page.getTotal());
|
||||||
|
|
||||||
|
return rspData;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,19 +1,27 @@
|
||||||
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.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.mcwl.common.core.domain.entity.SysUser;
|
||||||
import com.mcwl.common.utils.SecurityUtils;
|
import com.mcwl.common.utils.SecurityUtils;
|
||||||
import com.mcwl.resource.domain.ModelComment;
|
import com.mcwl.resource.domain.ModelComment;
|
||||||
import com.mcwl.resource.domain.ModelImageComment;
|
import com.mcwl.resource.domain.ModelImageComment;
|
||||||
import com.mcwl.resource.domain.dto.ModelImageCommentRes;
|
import com.mcwl.resource.domain.dto.ModelImageCommentRes;
|
||||||
|
import com.mcwl.resource.domain.vo.ModelCommentVo;
|
||||||
|
import com.mcwl.resource.domain.vo.ModelImageCommentVo;
|
||||||
import com.mcwl.resource.mapper.ModelCommentMapper;
|
import com.mcwl.resource.mapper.ModelCommentMapper;
|
||||||
import com.mcwl.resource.mapper.ModelImageCommentMapper;
|
import com.mcwl.resource.mapper.ModelImageCommentMapper;
|
||||||
import com.mcwl.resource.mapper.ModelImageMapper;
|
import com.mcwl.resource.mapper.ModelImageMapper;
|
||||||
import com.mcwl.resource.service.ModelCommentService;
|
import com.mcwl.resource.service.ModelCommentService;
|
||||||
|
import com.mcwl.system.service.ISysUserService;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -27,6 +35,8 @@ import java.util.Objects;
|
||||||
@Service
|
@Service
|
||||||
public class ModelCommentServiceImpl extends ServiceImpl<ModelCommentMapper, ModelComment> implements ModelCommentService {
|
public class ModelCommentServiceImpl extends ServiceImpl<ModelCommentMapper, ModelComment> implements ModelCommentService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ISysUserService sysUserService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private ModelCommentMapper modelCommentMapper;
|
private ModelCommentMapper modelCommentMapper;
|
||||||
|
|
||||||
|
@ -48,4 +58,89 @@ public class ModelCommentServiceImpl extends ServiceImpl<ModelCommentMapper, Mod
|
||||||
modelCommentMapper.insert(modelComment);
|
modelCommentMapper.insert(modelComment);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ModelCommentVo> getComment(Long imageId) {
|
||||||
|
List<ModelCommentVo> modelCommentVoList = new ArrayList<>();
|
||||||
|
|
||||||
|
// 查询所有父评论
|
||||||
|
LambdaQueryWrapper<ModelComment> lqw = new LambdaQueryWrapper<>();
|
||||||
|
lqw.eq(ModelComment::getModelId, imageId)
|
||||||
|
.isNull(ModelComment::getParentId)
|
||||||
|
.orderByDesc(ModelComment::getCreateTime);
|
||||||
|
// 添加父评论
|
||||||
|
List<ModelComment> modelCommentList = modelCommentMapper.selectList(lqw);
|
||||||
|
for (ModelComment modelComment : modelCommentList) {
|
||||||
|
ModelCommentVo modelCommentVo = getModelCommentVo(modelComment);
|
||||||
|
modelCommentVoList.add(modelCommentVo);
|
||||||
|
}
|
||||||
|
|
||||||
|
return modelCommentVoList;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构建ModelCommentVo对象
|
||||||
|
*
|
||||||
|
* @param modelComment 父评论对象
|
||||||
|
* @return ModelCommentVo对象
|
||||||
|
*/
|
||||||
|
@NotNull
|
||||||
|
private ModelCommentVo getModelCommentVo(ModelComment modelComment) {
|
||||||
|
Long userId = modelComment.getUserId();
|
||||||
|
SysUser sysUser = sysUserService.selectUserById(userId);
|
||||||
|
|
||||||
|
// 构建ModelCommentVo对象
|
||||||
|
ModelCommentVo modelCommentVo = new ModelCommentVo();
|
||||||
|
modelCommentVo.setUserId(userId);
|
||||||
|
modelCommentVo.setUserName(sysUser.getUserName());
|
||||||
|
modelCommentVo.setUserAvatar(sysUser.getAvatar());
|
||||||
|
modelCommentVo.setCommentId(modelComment.getId());
|
||||||
|
modelCommentVo.setContent(modelComment.getContent());
|
||||||
|
// 查询子评论
|
||||||
|
modelCommentVo.setContentList(getContentList(modelComment.getId()));
|
||||||
|
modelCommentVo.setLikeNum(modelComment.getLikeNum());
|
||||||
|
modelCommentVo.setCreateTime(modelComment.getCreateTime());
|
||||||
|
return modelCommentVo;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 递归查询子评论
|
||||||
|
*
|
||||||
|
* @param modelCommentId 父评论id
|
||||||
|
* @return List<ModelCommentVo>
|
||||||
|
*/
|
||||||
|
private List<ModelCommentVo> getContentList(Long modelCommentId) {
|
||||||
|
List<ModelCommentVo> modelCommentVoList = new ArrayList<>();
|
||||||
|
if (Objects.isNull(modelCommentId)) {
|
||||||
|
return modelCommentVoList;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查询子评论
|
||||||
|
LambdaQueryWrapper<ModelComment> lqw = new LambdaQueryWrapper<ModelComment>()
|
||||||
|
.eq(ModelComment::getParentId, modelCommentId)
|
||||||
|
.orderByDesc(ModelComment::getCreateTime);
|
||||||
|
|
||||||
|
List<ModelComment> modelCommentList = modelCommentMapper.selectList(lqw);
|
||||||
|
|
||||||
|
for (ModelComment modelComment : modelCommentList) {
|
||||||
|
Long userId = modelComment.getUserId();
|
||||||
|
SysUser sysUser = sysUserService.selectUserById(userId);
|
||||||
|
ModelCommentVo modelCommentVo = new ModelCommentVo();
|
||||||
|
modelCommentVo.setUserId(userId);
|
||||||
|
modelCommentVo.setUserName(sysUser.getUserName());
|
||||||
|
modelCommentVo.setUserAvatar(sysUser.getAvatar());
|
||||||
|
modelCommentVo.setCommentId(modelComment.getId());
|
||||||
|
modelCommentVo.setContent(modelComment.getContent());
|
||||||
|
modelCommentVo.setLikeNum(modelComment.getLikeNum());
|
||||||
|
modelCommentVo.setCreateTime(modelComment.getCreateTime());
|
||||||
|
|
||||||
|
|
||||||
|
modelCommentVoList.add(modelCommentVo);
|
||||||
|
}
|
||||||
|
return modelCommentVoList;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue