Merge branch 'feature/community-center' into preview

master
yang 2025-01-22 15:53:11 +08:00
commit bcf7cb7e3d
26 changed files with 830 additions and 50 deletions

View File

@ -0,0 +1,63 @@
package com.mcwl.web.controller.communityCenter;
import com.mcwl.common.core.domain.AjaxResult;
import com.mcwl.common.core.page.TableDataInfo;
import com.mcwl.communityCenter.domain.dto.*;
import com.mcwl.communityCenter.service.QuestionCommentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.Valid;
/**
*
*/
@Api(tags = "提问评论")
@RestController
@RequestMapping("questionComment")
@RequiredArgsConstructor
public class QuestionCommentController {
private final QuestionCommentService questionCommentService;
/**
*
*/
@PostMapping("comment")
@ApiOperation(value = "新增提问评论")
public AjaxResult comment(@Valid @RequestBody QuestionCommentRes questionCommentRes) {
return questionCommentService.comment(questionCommentRes);
}
/**
*
* @param questionCommentPageRes
* @return
*/
@PostMapping("list")
@ApiOperation(value = "获取提问评论列表")
public TableDataInfo list(@RequestBody @Valid QuestionCommentPageRes questionCommentPageRes) {
return questionCommentService.listByPage(questionCommentPageRes);
}
/**
*
*/
@PostMapping("adopt")
@ApiOperation(value = "采纳评论")
public AjaxResult adopt(@Valid @RequestBody QuestionCommentAdoptRes questionCommentAdoptRes) {
return questionCommentService.adopt(questionCommentAdoptRes);
}
}

View File

@ -10,9 +10,7 @@ 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.dto.ModelImagePageRes;
import com.mcwl.resource.domain.request.RequestModel; import com.mcwl.resource.domain.request.RequestModel;
import com.mcwl.resource.service.ModelImageService; import com.mcwl.resource.service.*;
import com.mcwl.resource.service.ModelService;
import com.mcwl.resource.service.WorkFlowService;
import com.mcwl.web.controller.common.OssUtil; import com.mcwl.web.controller.common.OssUtil;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
@ -43,12 +41,21 @@ public class MallProductController extends BaseController {
@Autowired @Autowired
private ModelService modelService; private ModelService modelService;
@Autowired
private ModelLikeService modelLikeService;
@Autowired @Autowired
private ModelImageService modelImageService; private ModelImageService modelImageService;
@Autowired @Autowired
private WorkFlowService workFlowService; private WorkFlowService workFlowService;
@Autowired
private WorkFlowLikeService workFlowLikeService;
@Autowired
private ModelImageLikeService modelImageLikeService;
/*** /***
* *
@ -192,9 +199,9 @@ public class MallProductController extends BaseController {
/** /**
* - * -
*/ */
@ApiOperation(value = "我的发布-模型") @ApiOperation(value = "我的发布-模型列表")
@PostMapping("/selectByUserIdModel") @PostMapping("/selectByUserIdModel")
public TableDataInfo selectByUserIdModel(@RequestBody ModelImagePageRes imagePageRes) { public TableDataInfo selectByUserIdModel(@RequestBody ModelImagePageRes imagePageRes) {
@ -202,9 +209,9 @@ public class MallProductController extends BaseController {
} }
/** /**
* - * -
*/ */
@ApiOperation(value = "我的发布-工作流") @ApiOperation(value = "我的发布-工作流列表")
@PostMapping("/selectByUserIdWorkFlow") @PostMapping("/selectByUserIdWorkFlow")
public TableDataInfo selectByUserIdWorkFlow(@RequestBody ModelImagePageRes imagePageRes) { public TableDataInfo selectByUserIdWorkFlow(@RequestBody ModelImagePageRes imagePageRes) {
@ -212,9 +219,9 @@ public class MallProductController extends BaseController {
} }
/** /**
* - * -
*/ */
@ApiOperation(value = "我的发布-图片") @ApiOperation(value = "我的发布-图片列表")
@PostMapping("/selectByUserIdImage") @PostMapping("/selectByUserIdImage")
public TableDataInfo selectByUserIdImage(@RequestBody ModelImagePageRes imagePageRes) { public TableDataInfo selectByUserIdImage(@RequestBody ModelImagePageRes imagePageRes) {
@ -222,39 +229,30 @@ public class MallProductController extends BaseController {
} }
/** /**
* - * -
*/ */
@ApiOperation(value = "点赞-模型") @ApiOperation(value = "我的点赞-模型列表")
@PostMapping("/likeModel") @PostMapping("/likeModel")
public TableDataInfo likeModel(@RequestBody PageDomain pageDomain) { public TableDataInfo likeModel(@RequestBody PageDomain pageDomain) {
ModelImagePageRes imagePageRes = new ModelImagePageRes(); return modelLikeService.listByPage(pageDomain);
BeanUtil.copyProperties(pageDomain, imagePageRes);
imagePageRes.setUserId(SecurityUtils.getUserId());
return modelService.listByPage(imagePageRes);
} }
/** /**
* - * -
*/ */
@ApiOperation(value = "点赞-工作流") @ApiOperation(value = "我的点赞-工作流列表")
@PostMapping("/likeWorkFlow") @PostMapping("/likeWorkFlow")
public TableDataInfo likeWorkFlow(@RequestBody PageDomain pageDomain) { public TableDataInfo likeWorkFlow(@RequestBody PageDomain pageDomain) {
ModelImagePageRes imagePageRes = new ModelImagePageRes(); return workFlowLikeService.listByPage(pageDomain);
BeanUtil.copyProperties(pageDomain, imagePageRes);
imagePageRes.setUserId(SecurityUtils.getUserId());
return workFlowService.listByPage(imagePageRes);
} }
/** /**
* - * -
*/ */
@ApiOperation(value = "点赞-图片") @ApiOperation(value = "我的点赞-图片列表")
@PostMapping("/likeImage") @PostMapping("/likeImage")
public TableDataInfo likeImage(@RequestBody PageDomain pageDomain) { public TableDataInfo likeImage(@RequestBody PageDomain pageDomain) {
ModelImagePageRes imagePageRes = new ModelImagePageRes(); return modelImageLikeService.listByPage(pageDomain);
BeanUtil.copyProperties(pageDomain, imagePageRes);
imagePageRes.setUserId(SecurityUtils.getUserId());
return modelImageService.listByPage(imagePageRes);
} }

View File

@ -29,7 +29,7 @@ public class PageDomain
private String orderByColumn; private String orderByColumn;
/** 排序的方向desc或者asc */ /** 排序的方向desc或者asc */
@ApiModelProperty(value = "排序的方向desc或者asc", example = "asc") @ApiModelProperty(hidden = true)
private String isAsc = "asc"; private String isAsc = "asc";
/** 分页参数合理化 */ /** 分页参数合理化 */

View File

@ -19,23 +19,23 @@ import lombok.EqualsAndHashCode;
public class QuestionComment extends BaseEntity { public class QuestionComment extends BaseEntity {
@TableId @TableId
private String id; private Long id;
/** /**
* id * id
*/ */
private String tenantId; private Long tenantId;
/** /**
* id * id
*/ */
private String communityId; private Long communityId;
/** /**
* id * id
*/ */
private String questionId; private Long questionId;
/** /**
* id * id
*/ */
private String userId; private Long userId;
/** /**
* *
*/ */
@ -43,7 +43,7 @@ public class QuestionComment extends BaseEntity {
/** /**
* *
*/ */
private String isAccept; private Long isAccept;

View File

@ -0,0 +1,46 @@
package com.mcwl.communityCenter.domain.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
@Data
@ApiModel(value = "采纳请求参数")
public class QuestionCommentAdoptRes {
/**
* id
*/
@NotNull(message = "租户不能为空")
@ApiModelProperty(value = "租户ID", required = true)
private Long tenantId;
/**
* id
*/
@NotNull(message = "社区不能为空")
@ApiModelProperty(value = "社区ID", required = true)
private Long communityId;
/**
* id
*/
@NotNull(message = "提问不能为空")
@ApiModelProperty(value = "提问ID", required = true)
private Long questionId;
/**
* id
*/
@NotNull(message = "评论不能为空")
@ApiModelProperty(value = "评论ID", required = true)
private Long commentId;
}

View File

@ -0,0 +1,28 @@
package com.mcwl.communityCenter.domain.dto;
import com.mcwl.common.core.page.PageDomain;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import javax.validation.constraints.NotNull;
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "提问分页请求参数")
public class QuestionCommentPageRes extends PageDomain {
@NotNull(message = "租户不能为空")
@ApiModelProperty(value = "租户id", required = true)
private Long tenantId;
@NotNull(message = "社区不能为空")
@ApiModelProperty(value = "社区id", required = true)
private Long communityId;
@NotNull(message = "提问不能为空")
@ApiModelProperty(value = "提问ID", required = true)
private Long questionId;
}

View File

@ -0,0 +1,47 @@
package com.mcwl.communityCenter.domain.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
/**
*
*/
@Data
@ApiModel("提问评论请求参数")
public class QuestionCommentRes {
/**
* id
*/
@NotNull(message = "租户不能为空")
@ApiModelProperty(value = "租户ID", required = true)
private Long tenantId;
/**
* id
*/
@NotNull(message = "社区不能为空")
@ApiModelProperty(value = "社区ID", required = true)
private Long communityId;
/**
* id
*/
@NotNull(message = "提问不能为空")
@ApiModelProperty(value = "提问ID", required = true)
private Long questionId;
/**
*
*/
@NotBlank(message = "评论内容不能为空")
@ApiModelProperty(value = "评论内容", required = true)
private String content;
}

View File

@ -0,0 +1,46 @@
package com.mcwl.communityCenter.domain.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel(description = "提问评论")
public class QuestionCommentVo {
@ApiModelProperty(value = "id")
private Long id;
/**
* id
*/
@ApiModelProperty(value = "租户id")
private Long tenantId;
/**
* id
*/
@ApiModelProperty(value = "社区id")
private Long communityId;
/**
* id
*/
@ApiModelProperty(value = "提问id")
private Long questionId;
/**
* id
*/
@ApiModelProperty(value = "用户id")
private Long userId;
/**
*
*/
@ApiModelProperty(value = "内容")
private String content;
/**
*
*/
@ApiModelProperty(value = "是否接受")
private Long isAccept;
}

View File

@ -0,0 +1,25 @@
package com.mcwl.communityCenter.mapper;
import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mcwl.communityCenter.domain.Publish;
import com.mcwl.communityCenter.domain.Question;
import com.mcwl.communityCenter.domain.QuestionComment;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import javax.validation.constraints.NotNull;
@Mapper
public interface QuestionCommentMapper extends BaseMapper<QuestionComment> {
@InterceptorIgnore(tenantLine = "true")
Page<QuestionComment> selectByTenantIdAndCommunityIdAndQuestionIdPage(Page<QuestionComment> page,
@Param("tenantId")
Long tenantId,
@Param("communityId")
Long communityId,
@Param("questionId")
Long questionId);
}

View File

@ -0,0 +1,20 @@
package com.mcwl.communityCenter.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.communityCenter.domain.Question;
import com.mcwl.communityCenter.domain.QuestionComment;
import com.mcwl.communityCenter.domain.dto.*;
import com.mcwl.communityCenter.domain.vo.QuestionVo;
import javax.validation.Valid;
public interface QuestionCommentService extends IService<QuestionComment> {
AjaxResult comment(@Valid QuestionCommentRes questionCommentRes);
TableDataInfo listByPage(@Valid QuestionCommentPageRes questionCommentPageRes);
AjaxResult adopt(@Valid QuestionCommentAdoptRes questionCommentAdoptRes);
}

View File

@ -0,0 +1,129 @@
package com.mcwl.communityCenter.service.impl;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
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.SecurityUtils;
import com.mcwl.common.utils.StringUtils;
import com.mcwl.communityCenter.domain.Community;
import com.mcwl.communityCenter.domain.Question;
import com.mcwl.communityCenter.domain.QuestionComment;
import com.mcwl.communityCenter.domain.dto.*;
import com.mcwl.communityCenter.domain.vo.QuestionCommentVo;
import com.mcwl.communityCenter.domain.vo.QuestionVo;
import com.mcwl.communityCenter.mapper.*;
import com.mcwl.communityCenter.service.QuestionCommentService;
import com.mcwl.communityCenter.service.QuestionService;
import com.mcwl.system.service.ISysUserService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
@Service
@RequiredArgsConstructor
public class QuestionCommentServiceImpl extends ServiceImpl<QuestionCommentMapper, QuestionComment> implements QuestionCommentService {
private final QuestionMapper questionMapper;
@Override
public AjaxResult comment(QuestionCommentRes questionCommentRes) {
Long tenantId = questionCommentRes.getTenantId();
Long communityId = questionCommentRes.getCommunityId();
Long questionId = questionCommentRes.getQuestionId();
Question question = questionMapper.selectByIdAndTenantIdAndCommunityId(questionId, tenantId, communityId);
if (Objects.isNull(question)) {
return AjaxResult.error("提问不存在");
}
QuestionComment questionComment = new QuestionComment();
BeanUtil.copyProperties(questionCommentRes, questionComment);
questionComment.setUserId(SecurityUtils.getUserId());
baseMapper.insert(questionComment);
return AjaxResult.success("评论成功");
}
@Override
public TableDataInfo listByPage(QuestionCommentPageRes questionCommentPageRes) {
Page<QuestionComment> page = initPage(questionCommentPageRes);
baseMapper.selectByTenantIdAndCommunityIdAndQuestionIdPage(page, questionCommentPageRes.getTenantId(), questionCommentPageRes.getCommunityId(), questionCommentPageRes.getQuestionId());
List<QuestionComment> questionCommentList = page.getRecords();
List<QuestionCommentVo> questionCommentVoList = new ArrayList<>();
for (QuestionComment questionComment : questionCommentList) {
QuestionCommentVo questionCommentVo = new QuestionCommentVo();
BeanUtil.copyProperties(questionComment, questionCommentVo);
questionCommentVoList.add(questionCommentVo);
}
TableDataInfo tableDataInfo = new TableDataInfo();
tableDataInfo.setCode(HttpStatus.SUCCESS);
tableDataInfo.setMsg("查询成功");
tableDataInfo.setRows(questionCommentVoList);
tableDataInfo.setTotal(page.getTotal());
return tableDataInfo;
}
@Override
public AjaxResult adopt(QuestionCommentAdoptRes questionCommentAdoptRes) {
Long tenantId = questionCommentAdoptRes.getTenantId();
Long communityId = questionCommentAdoptRes.getCommunityId();
Long questionId = questionCommentAdoptRes.getQuestionId();
Long commentId = questionCommentAdoptRes.getCommentId();
// QuestionComment questionComment = baseMapper.selectByIdAndTenantIdAndCommunityIdAndQuestionIdAndCommentId(commentId, tenantId, communityId, questionId);
QuestionComment questionComment = null;
if (Objects.isNull(questionComment)) {
return AjaxResult.error("评论不存在");
}
if (questionComment.getIsAccept() == 1) {
return AjaxResult.error("该评论已被采纳");
}
return AjaxResult.success();
}
private Page<QuestionComment> initPage(QuestionCommentPageRes questionCommentPageRes) {
Page<QuestionComment> page = new Page<>(questionCommentPageRes.getPageNum(), questionCommentPageRes.getPageSize());
if (StringUtils.isBlank(questionCommentPageRes.getOrderByColumn())) {
questionCommentPageRes.setOrderByColumn("create_time");
}
boolean isAsc = Objects.equals(questionCommentPageRes.getIsAsc(), "asc");
OrderItem orderItem = new OrderItem(questionCommentPageRes.getOrderByColumn(), isAsc);
page.addOrder(orderItem);
return page;
}
}

View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.mcwl.communityCenter.mapper.QuestionCommentMapper">
<select id="selectByTenantIdAndCommunityIdAndQuestionIdPage"
resultType="com.mcwl.communityCenter.domain.QuestionComment">
select id, tenant_id, community_id, question_id, user_id, content, is_accept
from cc_question_comment
where tenant_id = #{tenantId}
and community_id = #{communityId}
and question_id = #{questionId}
and del_flag = '0'
order by create_time desc
</select>
</mapper>

View File

@ -173,7 +173,7 @@ public class WorkFlow {
* *
*/ */
@ApiModelProperty(value = "作品点赞数量") @ApiModelProperty(value = "作品点赞数量")
private Long likeCount = 0L; private Integer likeCount = 0;
/** /**
* *

View File

@ -16,11 +16,6 @@ import java.util.Date;
@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
public class ModelImagePageRes extends PageDomain { public class ModelImagePageRes extends PageDomain {
/**
* id
*/
@ApiModelProperty(value = "用户id")
private Long userId;
/** /**
* *

View File

@ -0,0 +1,50 @@
package com.mcwl.resource.domain.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
@Data
@ApiModel(description = "图片返回对象")
public class ModelImageLikeVo {
/**
* id
*/
@ApiModelProperty(value = "id", required = true)
private Long id;
/**
* ID
*/
@ApiModelProperty(value = "用户id", required = true)
private Long userId;
/**
*
*/
@ApiModelProperty(value = "用户名称", required = true)
private String userName;
/**
*
*/
@ApiModelProperty(value = "用户头像", required = true)
private String userAvatar;
/**
* id
*/
@ApiModelProperty(value = "图片id", required = true)
private Long modelImageId;
/**
* 8
*/
@ApiModelProperty(value = "图片地址最多8张切割")
private String imagePaths;
/**
*
*/
@ApiModelProperty(value = "点赞数")
private Integer likeNum;
}

View File

@ -0,0 +1,47 @@
package com.mcwl.resource.domain.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel(description = "模型返回对象")
public class ModelLikeVo {
/**
* id
*/
@ApiModelProperty(value = "id", required = true)
private Long id;
/**
* ID
*/
@ApiModelProperty(value = "用户id", required = true)
private Long userId;
/**
*
*/
@ApiModelProperty(value = "用户名称", required = true)
private String userName;
/**
*
*/
@ApiModelProperty(value = "用户头像", required = true)
private String userAvatar;
/**
* id
*/
@ApiModelProperty(value = "模型id", required = true)
private Long modelId;
/**
*
*/
@ApiModelProperty(value = "封面图")
private String surfaceUrl;
/**
*
*/
@ApiModelProperty(value = "点赞数")
private Integer likeNum;
}

View File

@ -0,0 +1,48 @@
package com.mcwl.resource.domain.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel(description = "工作流请求对象")
public class WorkFlowLikeVo {
/**
* id
*/
@ApiModelProperty(value = "id", required = true)
private Long id;
/**
* ID
*/
@ApiModelProperty(value = "用户id", required = true)
private Long userId;
/**
*
*/
@ApiModelProperty(value = "用户名称", required = true)
private String userName;
/**
*
*/
@ApiModelProperty(value = "用户头像", required = true)
private String userAvatar;
/**
* id
*/
@ApiModelProperty(value = "工作流id", required = true)
private Long workFlowId;
/**
*
*/
@ApiModelProperty(value = "封面图")
private String converPath;
/**
*
*/
@ApiModelProperty(value = "点赞数")
private Integer likeNum;
}

View File

@ -1,8 +1,11 @@
package com.mcwl.resource.service; package com.mcwl.resource.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.mcwl.common.core.page.PageDomain;
import com.mcwl.common.core.page.TableDataInfo;
import com.mcwl.resource.domain.ModelImage; import com.mcwl.resource.domain.ModelImage;
import com.mcwl.resource.domain.ModelImageLike; import com.mcwl.resource.domain.ModelImageLike;
import com.mcwl.resource.domain.dto.ModelImagePageRes;
import java.util.List; import java.util.List;
@ -16,5 +19,10 @@ public interface ModelImageLikeService extends IService<ModelImageLike> {
List<ModelImage> fetchModelImageSortedByTopStatus(); List<ModelImage> fetchModelImageSortedByTopStatus();
/**
*
* @param pageDomain
* @return
*/
TableDataInfo listByPage(PageDomain pageDomain);
} }

View File

@ -1,6 +1,8 @@
package com.mcwl.resource.service; package com.mcwl.resource.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.mcwl.common.core.page.PageDomain;
import com.mcwl.common.core.page.TableDataInfo;
import com.mcwl.resource.domain.ModelLike; import com.mcwl.resource.domain.ModelLike;
/** /**
@ -16,4 +18,10 @@ public interface ModelLikeService extends IService<ModelLike> {
void like(Long imageId); void like(Long imageId);
/**
*
* @param pageDomain
* @return
*/
TableDataInfo listByPage(PageDomain pageDomain);
} }

View File

@ -1,6 +1,8 @@
package com.mcwl.resource.service; package com.mcwl.resource.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.mcwl.common.core.page.PageDomain;
import com.mcwl.common.core.page.TableDataInfo;
import com.mcwl.resource.domain.WorkFlowLike; import com.mcwl.resource.domain.WorkFlowLike;
/** /**
@ -17,4 +19,5 @@ public interface WorkFlowLikeService extends IService<WorkFlowLike> {
void like(Long imageId); void like(Long imageId);
TableDataInfo listByPage(PageDomain pageDomain);
} }

View File

@ -1,19 +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.metadata.OrderItem;
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.AjaxResult; import com.mcwl.common.core.domain.AjaxResult;
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.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.resource.domain.ModelImage; import com.mcwl.resource.domain.ModelImage;
import com.mcwl.resource.domain.ModelImageLike; import com.mcwl.resource.domain.ModelImageLike;
import com.mcwl.resource.domain.dto.ModelImagePageRes;
import com.mcwl.resource.domain.vo.ModelImageLikeVo;
import com.mcwl.resource.domain.vo.ModelImageVo;
import com.mcwl.resource.mapper.ModelImageLikeMapper; import com.mcwl.resource.mapper.ModelImageLikeMapper;
import com.mcwl.resource.mapper.ModelImageMapper; import com.mcwl.resource.mapper.ModelImageMapper;
import com.mcwl.resource.service.ModelImageLikeService; import com.mcwl.resource.service.ModelImageLikeService;
import com.mcwl.resource.service.ModelImageService; import com.mcwl.resource.service.ModelImageService;
import com.mcwl.system.service.ISysUserService;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
@ -27,6 +41,8 @@ public class ModelImageLikeServiceImpl extends ServiceImpl<ModelImageLikeMapper,
private final ModelImageMapper modelImageMapper; private final ModelImageMapper modelImageMapper;
private final ISysUserService sysUserService;
@Override @Override
@Transactional @Transactional
public void like(Long imageId) { public void like(Long imageId) {
@ -72,4 +88,59 @@ public class ModelImageLikeServiceImpl extends ServiceImpl<ModelImageLikeMapper,
public List<ModelImage> fetchModelImageSortedByTopStatus() { public List<ModelImage> fetchModelImageSortedByTopStatus() {
return modelImageMapper.fetchModelImageSortedByTopStatus(); return modelImageMapper.fetchModelImageSortedByTopStatus();
} }
/**
*
*
* @param pageDomain
* @return
*/
@Override
public TableDataInfo listByPage(PageDomain pageDomain) {
Page<ModelImageLike> page = new Page<>(pageDomain.getPageNum(), pageDomain.getPageSize());
if (StringUtils.isEmpty(pageDomain.getOrderByColumn())) {
pageDomain.setOrderByColumn("create_time");
}
// 设置排序
boolean isAsc = Objects.equals(pageDomain.getIsAsc(), "desc");
OrderItem orderItem = new OrderItem(pageDomain.getOrderByColumn(), isAsc);
page.addOrder(orderItem);
baseMapper.selectPage(page, null);
// 获取分页数据
List<ModelImageLike> modelImageList = page.getRecords();
// ModelImage数据转为ModelImagePageVo
List<ModelImageLikeVo> modelImageLikeVoList = new ArrayList<>();
for (ModelImageLike modelImageLike : modelImageList) {
ModelImageLikeVo modelImageLikeVo = new ModelImageLikeVo();
BeanUtil.copyProperties(modelImageLike, modelImageLikeVo);
// 获取用户信息
SysUser sysUser = sysUserService.selectUserById(modelImageLike.getUserId());
modelImageLikeVo.setUserName(sysUser.getUserName());
modelImageLikeVo.setUserAvatar(sysUser.getAvatar());
// 获取图片信息
ModelImage modelImage = modelImageMapper.selectById(modelImageLike.getModelImageId());
modelImageLikeVo.setImagePaths(modelImage.getImagePaths());
modelImageLikeVo.setLikeNum(modelImage.getLikeNum());
modelImageLikeVoList.add(modelImageLikeVo);
}
// 封装分页数据
TableDataInfo rspData = new TableDataInfo();
rspData.setCode(HttpStatus.SUCCESS);
rspData.setMsg("查询成功");
rspData.setRows(modelImageLikeVoList);
rspData.setTotal(page.getTotal());
return rspData;
}
} }

View File

@ -180,13 +180,12 @@ public class ModelImageServiceImpl extends ServiceImpl<ModelImageMapper, ModelIm
imagePageRes.setOrderByColumn("create_time"); imagePageRes.setOrderByColumn("create_time");
} }
// 设置排序 // 设置排序
boolean isAsc = Objects.equals(imagePageRes.getIsAsc(), "asc"); OrderItem orderItem = OrderItem.desc(imagePageRes.getOrderByColumn());
OrderItem orderItem = new OrderItem(imagePageRes.getOrderByColumn(), isAsc);
page.addOrder(orderItem); page.addOrder(orderItem);
LambdaQueryWrapper<ModelImage> lqw = new LambdaQueryWrapper<>(); LambdaQueryWrapper<ModelImage> lqw = new LambdaQueryWrapper<>();
lqw.eq(imagePageRes.getStatus() != null, ModelImage::getStatus, imagePageRes.getStatus()) lqw.eq(imagePageRes.getStatus() != null, ModelImage::getStatus, imagePageRes.getStatus())
.eq(imagePageRes.getUserId() != null, ModelImage::getUserId, imagePageRes.getUserId()) .eq(ModelImage::getUserId, SecurityUtils.getUserId())
.ge(imagePageRes.getStartTime() != null, ModelImage::getCreateTime, imagePageRes.getStartTime()) .ge(imagePageRes.getStartTime() != null, ModelImage::getCreateTime, imagePageRes.getStartTime())
.le(imagePageRes.getEndTime() != null, ModelImage::getCreateTime, imagePageRes.getEndTime()); .le(imagePageRes.getEndTime() != null, ModelImage::getCreateTime, imagePageRes.getEndTime());

View File

@ -1,17 +1,29 @@
package com.mcwl.resource.service.impl; package com.mcwl.resource.service.impl;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
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.PageDomain;
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.resource.domain.*; import com.mcwl.resource.domain.*;
import com.mcwl.resource.domain.vo.ModelLikeVo;
import com.mcwl.resource.mapper.ModelMapper; import com.mcwl.resource.mapper.ModelMapper;
import com.mcwl.resource.mapper.ModelLikeMapper; import com.mcwl.resource.mapper.ModelLikeMapper;
import com.mcwl.resource.service.ModelLikeService; import com.mcwl.resource.service.ModelLikeService;
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 org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List;
import java.util.Objects; import java.util.Objects;
/** /**
@ -24,6 +36,10 @@ public class ModelLikeServiceImpl extends ServiceImpl<ModelLikeMapper, ModelLike
@Autowired @Autowired
private ModelMapper modelMapper; private ModelMapper modelMapper;
@Autowired
private ISysUserService sysUserService;
@Override @Override
@Transactional @Transactional
public void like(Long modelId) { public void like(Long modelId) {
@ -61,4 +77,53 @@ public class ModelLikeServiceImpl extends ServiceImpl<ModelLikeMapper, ModelLike
model.setNumbers(model.getNumbers() + 1); model.setNumbers(model.getNumbers() + 1);
modelMapper.updateById(model); modelMapper.updateById(model);
} }
@Override
public TableDataInfo listByPage(PageDomain pageDomain) {
Page<ModelLike> page = initPage(pageDomain);
baseMapper.selectPage(page, null);
List<ModelLike> modelLikeList = page.getRecords();
List<ModelLikeVo> modelLikeVoList = new ArrayList<>();
for (ModelLike modelLike : modelLikeList) {
ModelLikeVo modelLikeVo = new ModelLikeVo();
BeanUtil.copyProperties(modelLike, modelLikeVo);
// 获取用户信息
SysUser sysUser = sysUserService.selectUserById(modelLike.getUserId());
modelLikeVo.setUserName(sysUser.getUserName());
modelLikeVo.setUserAvatar(sysUser.getAvatar());
// 获取模型信息
ModelProduct modelProduct = modelMapper.selectById(modelLike.getModelId());
modelLikeVo.setSurfaceUrl(modelProduct.getSurfaceUrl());
modelLikeVo.setLikeNum(modelProduct.getLikeNum());
modelLikeVoList.add(modelLikeVo);
}
TableDataInfo tableDataInfo = new TableDataInfo();
tableDataInfo.setRows(modelLikeVoList);
tableDataInfo.setTotal(page.getTotal());
tableDataInfo.setCode(HttpStatus.SUCCESS);
tableDataInfo.setMsg("查询成功");
return tableDataInfo;
}
private Page<ModelLike> initPage(PageDomain pageDomain) {
Page<ModelLike> page = new Page<>(pageDomain.getPageNum(), pageDomain.getPageSize());
if (StringUtils.isBlank(pageDomain.getOrderByColumn())) {
pageDomain.setOrderByColumn("create_time");
}
OrderItem orderItem = OrderItem.desc(pageDomain.getOrderByColumn());
page.addOrder(orderItem);
return page;
}
} }

View File

@ -31,6 +31,7 @@ import com.mcwl.system.init.DictInit;
import com.mcwl.system.service.ISysUserService; import com.mcwl.system.service.ISysUserService;
import lombok.extern.log4j.Log4j2; import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Sort;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -135,13 +136,12 @@ public class ModelServiceImpl extends ServiceImpl<ModelMapper,ModelProduct> impl
imagePageRes.setOrderByColumn("create_time"); imagePageRes.setOrderByColumn("create_time");
} }
// 设置排序 // 设置排序
boolean isAsc = Objects.equals(imagePageRes.getIsAsc(), "asc"); OrderItem orderItem = OrderItem.desc(imagePageRes.getOrderByColumn());
OrderItem orderItem = new OrderItem(imagePageRes.getOrderByColumn(), isAsc);
page.addOrder(orderItem); page.addOrder(orderItem);
LambdaQueryWrapper<ModelProduct> lqw = new LambdaQueryWrapper<>(); LambdaQueryWrapper<ModelProduct> lqw = new LambdaQueryWrapper<>();
lqw.eq(imagePageRes.getStatus() != null, ModelProduct::getAuditStatus, imagePageRes.getStatus()) lqw.eq(imagePageRes.getStatus() != null, ModelProduct::getAuditStatus, imagePageRes.getStatus())
.eq(imagePageRes.getUserId() != null, ModelProduct::getUserId, imagePageRes.getUserId()) .eq( ModelProduct::getUserId, SecurityUtils.getUserId())
.ge(imagePageRes.getStartTime() != null, ModelProduct::getCreateTime, imagePageRes.getStartTime()) .ge(imagePageRes.getStartTime() != null, ModelProduct::getCreateTime, imagePageRes.getStartTime())
.le(imagePageRes.getEndTime() != null, ModelProduct::getCreateTime, imagePageRes.getEndTime()); .le(imagePageRes.getEndTime() != null, ModelProduct::getCreateTime, imagePageRes.getEndTime());

View File

@ -1,18 +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.metadata.OrderItem;
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.PageDomain;
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.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.mapper.WorkFlowLikeMapper; import com.mcwl.resource.mapper.WorkFlowLikeMapper;
import com.mcwl.resource.mapper.WorkFlowMapper; import com.mcwl.resource.mapper.WorkFlowMapper;
import com.mcwl.resource.service.WorkFlowLikeService; import com.mcwl.resource.service.WorkFlowLikeService;
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 org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List;
import java.util.Objects; import java.util.Objects;
/** /**
@ -31,6 +46,9 @@ public class WorkFlowLikeServiceImpl extends ServiceImpl<WorkFlowLikeMapper, Wor
@Autowired @Autowired
private WorkFlowMapper workFlowMapper; private WorkFlowMapper workFlowMapper;
@Autowired
private ISysUserService sysUserService;
@Override @Override
@Transactional @Transactional
public void like(Long modelId) { public void like(Long modelId) {
@ -69,4 +87,53 @@ public class WorkFlowLikeServiceImpl extends ServiceImpl<WorkFlowLikeMapper, Wor
workFlowMapper.updateById(workFlow); workFlowMapper.updateById(workFlow);
} }
@Override
public TableDataInfo listByPage(PageDomain pageDomain) {
Page<WorkFlowLike> page = initPage(pageDomain);
baseMapper.selectPage(page, null);
List<WorkFlowLike> workFlowLikeList = page.getRecords();
List<WorkFlowLikeVo> modelLikeVoList = new ArrayList<>();
for (WorkFlowLike workFlowLike : workFlowLikeList) {
WorkFlowLikeVo workFlowLikeVo = new WorkFlowLikeVo();
BeanUtil.copyProperties(workFlowLike, workFlowLikeVo);
// 获取用户信息
SysUser sysUser = sysUserService.selectUserById(workFlowLike.getUserId());
workFlowLikeVo.setUserName(sysUser.getUserName());
workFlowLikeVo.setUserAvatar(sysUser.getAvatar());
// 获取工作流信息
WorkFlow workFlow = workFlowMapper.selectById(workFlowLike.getWorkFlowId());
workFlowLikeVo.setConverPath(workFlow.getCoverPath());
workFlowLikeVo.setLikeNum(workFlow.getLikeCount());
modelLikeVoList.add(workFlowLikeVo);
}
TableDataInfo tableDataInfo = new TableDataInfo();
tableDataInfo.setRows(modelLikeVoList);
tableDataInfo.setTotal(page.getTotal());
tableDataInfo.setCode(HttpStatus.SUCCESS);
tableDataInfo.setMsg("查询成功");
return tableDataInfo;
}
private Page<WorkFlowLike> initPage(PageDomain pageDomain) {
Page<WorkFlowLike> page = new Page<>(pageDomain.getPageNum(), pageDomain.getPageSize());
if (StringUtils.isBlank(pageDomain.getOrderByColumn())) {
pageDomain.setOrderByColumn("create_time");
}
OrderItem orderItem = OrderItem.desc(pageDomain.getOrderByColumn());
page.addOrder(orderItem);
return page;
}
} }

View File

@ -349,13 +349,12 @@ public class WorkFlowServiceImpl extends ServiceImpl<WorkFlowMapper, WorkFlow> i
imagePageRes.setOrderByColumn("create_time"); imagePageRes.setOrderByColumn("create_time");
} }
// 设置排序 // 设置排序
boolean isAsc = Objects.equals(imagePageRes.getIsAsc(), "asc"); OrderItem orderItem = OrderItem.desc(imagePageRes.getOrderByColumn());
OrderItem orderItem = new OrderItem(imagePageRes.getOrderByColumn(), isAsc);
page.addOrder(orderItem); page.addOrder(orderItem);
LambdaQueryWrapper<WorkFlow> lqw = new LambdaQueryWrapper<>(); LambdaQueryWrapper<WorkFlow> lqw = new LambdaQueryWrapper<>();
lqw.eq(imagePageRes.getStatus() != null, WorkFlow::getAuditStatus, imagePageRes.getStatus()) lqw.eq(imagePageRes.getStatus() != null, WorkFlow::getAuditStatus, imagePageRes.getStatus())
.eq(imagePageRes.getUserId() != null, WorkFlow::getUserId, imagePageRes.getUserId()) .eq(WorkFlow::getUserId, SecurityUtils.getUserId())
.ge(imagePageRes.getStartTime() != null, WorkFlow::getCreateTime, imagePageRes.getStartTime()) .ge(imagePageRes.getStartTime() != null, WorkFlow::getCreateTime, imagePageRes.getStartTime())
.le(imagePageRes.getEndTime() != null, WorkFlow::getCreateTime, imagePageRes.getEndTime()); .le(imagePageRes.getEndTime() != null, WorkFlow::getCreateTime, imagePageRes.getEndTime());