diff --git a/mcwl-admin/src/main/java/com/mcwl/web/controller/communityCenter/CommunityController.java b/mcwl-admin/src/main/java/com/mcwl/web/controller/communityCenter/CommunityController.java index 7a59516..c06421d 100644 --- a/mcwl-admin/src/main/java/com/mcwl/web/controller/communityCenter/CommunityController.java +++ b/mcwl-admin/src/main/java/com/mcwl/web/controller/communityCenter/CommunityController.java @@ -42,11 +42,15 @@ public class CommunityController { @ApiOperation(value = "社区详情") @GetMapping("detail") public R getCommunityDetail(@Valid + @ApiParam(value = "社区id", required = true) + @NotNull(message = "社区id不能为空") + Long tenantId, + @Valid @ApiParam(value = "社区id", required = true) @NotNull(message = "社区id不能为空") Long communityId) { - CommunityDetailVo communityDetailVo = communityService.getCommunityDetail(communityId); + CommunityDetailVo communityDetailVo = communityService.getCommunityDetail(tenantId, communityId); return R.ok(communityDetailVo); } diff --git a/mcwl-admin/src/main/java/com/mcwl/web/controller/communityCenter/PersonHomeController.java b/mcwl-admin/src/main/java/com/mcwl/web/controller/communityCenter/PersonHomeController.java index 9819708..5fb93fe 100644 --- a/mcwl-admin/src/main/java/com/mcwl/web/controller/communityCenter/PersonHomeController.java +++ b/mcwl-admin/src/main/java/com/mcwl/web/controller/communityCenter/PersonHomeController.java @@ -24,7 +24,7 @@ import javax.validation.Valid; /** * 个人主页 */ -@Api(tags = "个人主页") +@Api(tags = "社区个人主页") @RestController @RequiredArgsConstructor @RequestMapping("personHome") diff --git a/mcwl-admin/src/main/java/com/mcwl/web/controller/communityCenter/PublishCommentController.java b/mcwl-admin/src/main/java/com/mcwl/web/controller/communityCenter/PublishCommentController.java index 9837609..38db82a 100644 --- a/mcwl-admin/src/main/java/com/mcwl/web/controller/communityCenter/PublishCommentController.java +++ b/mcwl-admin/src/main/java/com/mcwl/web/controller/communityCenter/PublishCommentController.java @@ -1,12 +1,13 @@ package com.mcwl.web.controller.communityCenter; import com.mcwl.common.core.controller.BaseController; -import com.mcwl.common.core.domain.AjaxResult; import com.mcwl.common.core.domain.R; import com.mcwl.communityCenter.domain.dto.CommentDelRes; import com.mcwl.communityCenter.domain.dto.CommentDetailRes; import com.mcwl.communityCenter.domain.dto.CommentRes; +import com.mcwl.communityCenter.domain.dto.PublishCommentLikeRes; import com.mcwl.communityCenter.domain.vo.CommentVo; +import com.mcwl.communityCenter.service.PublishCommentLikeService; import com.mcwl.communityCenter.service.PublishCommentService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -30,6 +31,17 @@ import java.util.List; public class PublishCommentController extends BaseController { private final PublishCommentService publishCommentService; + private final PublishCommentLikeService publishCommentLikeService; + + /** + * 获取评论 + */ + @ApiOperation(value = "获取评论") + @PostMapping("/list") + public R> list(@RequestBody @Valid CommentDetailRes commentDetailRes) { + + return publishCommentService.getComment(commentDetailRes); + } /** @@ -46,33 +58,31 @@ public class PublishCommentController extends BaseController { } - /** - * 获取评论详情 - * - * @param commentDetailRes 评论详情请求参数 - * @return 评论详情 - */ - @ApiOperation(value = "获取评论详情") - @PostMapping("/detail") - public R> getComment(@RequestBody @Valid CommentDetailRes commentDetailRes) { - - return publishCommentService.getComment(commentDetailRes); - } - - // /** -// * 点赞或取消点赞评论 -// * @param commentDetailRes 评论请求参数 -// * @return 更新后的点赞数 +// * 获取评论详情 +// * +// * @param commentDetailRes 评论详情请求参数 +// * @return 评论详情 // */ -// @ApiOperation(value = "点赞或取消点赞评论") -// @PostMapping("/like") -// public AjaxResult like(@RequestBody @Valid CommentDetailRes commentDetailRes) { +// @ApiOperation(value = "获取评论详情") +// @PostMapping("/detail") +// public R> getComment(@RequestBody @Valid CommentDetailRes commentDetailRes) { // -// return publishCommentService.like(commentDetailRes); +// return publishCommentService.getComment(commentDetailRes); // } + /** + * 点赞或取消点赞评论 + */ + @ApiOperation(value = "点赞或取消点赞评论") + @PostMapping("/like") + public R like(@RequestBody @Valid PublishCommentLikeRes publishCommentLikeRes) { + + return publishCommentLikeService.like(publishCommentLikeRes); + } + + @ApiOperation(value = "删除评论") @PostMapping("/delete") public R delete(@RequestBody @Valid CommentDelRes commentDelRes) { diff --git a/mcwl-admin/src/main/java/com/mcwl/web/controller/communityCenter/PublishController.java b/mcwl-admin/src/main/java/com/mcwl/web/controller/communityCenter/PublishController.java index eadb01f..43e90dd 100644 --- a/mcwl-admin/src/main/java/com/mcwl/web/controller/communityCenter/PublishController.java +++ b/mcwl-admin/src/main/java/com/mcwl/web/controller/communityCenter/PublishController.java @@ -1,10 +1,12 @@ package com.mcwl.web.controller.communityCenter; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.mcwl.common.constant.HttpStatus; import com.mcwl.common.core.domain.AjaxResult; import com.mcwl.common.core.domain.R; import com.mcwl.common.core.page.TableDataInfo; +import com.mcwl.communityCenter.domain.Publish; import com.mcwl.communityCenter.domain.dto.*; import com.mcwl.communityCenter.domain.vo.PublishVo; import com.mcwl.communityCenter.service.PublishService; @@ -83,9 +85,11 @@ public class PublishController { * 删除 */ @ApiOperation(value = "删除") - @GetMapping("remove") - public R deletePublish(@NotNull(message = "id不能为空") @ApiParam(value = "id") @Valid Long id) { - publishService.removeById(id); + @PostMapping("remove") + public R deletePublish(@RequestBody @Valid PublishRemoveRes publishRemoveRes) { + Long communityId = publishRemoveRes.getCommunityId(); + Long publishId = publishRemoveRes.getPublishId(); + publishService.remove(new LambdaQueryWrapper().eq(Publish::getId, publishId).eq(Publish::getCommunityId, communityId)); return R.ok(); } @@ -114,4 +118,14 @@ public class PublishController { return R.ok(); } + /** + * 举报 + */ + @ApiOperation(value = "举报") + @PostMapping("report") + public R reportPublish(@RequestBody @Valid PublishReportRes publishReportRes) { + publishService.reportPublish(publishReportRes); + return R.ok(); + } + } diff --git a/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/domain/PublishComment.java b/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/domain/PublishComment.java index eeded62..e1be7a6 100644 --- a/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/domain/PublishComment.java +++ b/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/domain/PublishComment.java @@ -57,11 +57,5 @@ public class PublishComment extends BaseEntity { @ApiModelProperty(value = "点赞数") private Integer likeNum; - /** - * 评论类型 0发布 1提问 - */ - @ApiModelProperty(value = "评论类型 0发布 1提问") - private Integer type; - } diff --git a/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/domain/PublishReport.java b/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/domain/PublishReport.java new file mode 100644 index 0000000..b2102d3 --- /dev/null +++ b/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/domain/PublishReport.java @@ -0,0 +1,57 @@ +package com.mcwl.communityCenter.domain; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.mcwl.common.core.domain.BaseEntity; +import lombok.*; + +/** + * 举报表 + */ + +@Builder +@Data +@EqualsAndHashCode(callSuper = true) +@NoArgsConstructor +@AllArgsConstructor +@TableName("cc_report") +public class PublishReport extends BaseEntity { + + private Long id; + + /** + * 租户id + */ + private Long tenantId; + + /** + * 社区id + */ + private Long communityId; + + /** + * 发布id + */ + private Long publishId; + + /** + * 举报人 + */ + private Long userId; + + /** + * 举报类型 字典值 + */ + private Long reportType; + + /** + * 举报内容 + */ + private Long content; + + /** + * 状态(0未处理 1已处理 ) + */ + private Long status; + + +} diff --git a/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/domain/dto/CommentDelRes.java b/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/domain/dto/CommentDelRes.java index 52884b7..a10e2f2 100644 --- a/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/domain/dto/CommentDelRes.java +++ b/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/domain/dto/CommentDelRes.java @@ -32,11 +32,11 @@ public class CommentDelRes { @NotNull(message = "社区id不能为空") private Long communityId; /** - * 运营id + * 发布id */ - @ApiModelProperty(value = "运营id", required = true) - @NotNull(message = "运营id不能为空") - private Long operatorId; + @ApiModelProperty(value = "发布id", required = true) + @NotNull(message = "发id不能为空") + private Long publishId; } diff --git a/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/domain/dto/CommentDetailRes.java b/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/domain/dto/CommentDetailRes.java index e11d669..17e2324 100644 --- a/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/domain/dto/CommentDetailRes.java +++ b/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/domain/dto/CommentDetailRes.java @@ -28,11 +28,11 @@ public class CommentDetailRes { @NotNull(message = "社区id不能为空") private Long communityId; /** - * 运营id + * 发布id */ - @ApiModelProperty(value = "运营id", required = true) - @NotNull(message = "运营id不能为空") - private Long operatorId; + @ApiModelProperty(value = "发布id", required = true) + @NotNull(message = "发布id不能为空") + private Long publishId; } diff --git a/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/domain/dto/CommentLikeDetailRes.java b/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/domain/dto/CommentLikeDetailRes.java new file mode 100644 index 0000000..4c5770e --- /dev/null +++ b/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/domain/dto/CommentLikeDetailRes.java @@ -0,0 +1,44 @@ +package com.mcwl.communityCenter.domain.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotNull; + +/** + * 评论请求参数 + */ +@Data +@ApiModel(value = "评论请求参数") +public class CommentLikeDetailRes { + + + /** + * 租户id + */ + @ApiModelProperty(value = "租户id", required = true) + @NotNull(message = "租户id不能为空") + private Long tenantId; + /** + * 社区id + */ + @ApiModelProperty(value = "社区id", required = true) + @NotNull(message = "社区id不能为空") + private Long communityId; + /** + * 发布id + */ + @ApiModelProperty(value = "发布id", required = true) + @NotNull(message = "发布id不能为空") + private Long publishId; + + /** + * 评论id + */ + @ApiModelProperty(value = "评论id", required = true) + @NotNull(message = "评论id不能为空") + private Long publishCommentId; + + +} diff --git a/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/domain/dto/CommentRes.java b/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/domain/dto/CommentRes.java index 975a35a..5a6b48e 100644 --- a/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/domain/dto/CommentRes.java +++ b/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/domain/dto/CommentRes.java @@ -28,11 +28,11 @@ public class CommentRes { @NotNull(message = "社区id不能为空") private Long communityId; /** - * 运营id + * 发布id */ - @ApiModelProperty(value = "运营id", required = true) - @NotNull(message = "运营id不能为空") - private Long operatorId; + @ApiModelProperty(value = "发布id", required = true) + @NotNull(message = "发布id不能为空") + private Long publishId; /** * 内容 */ @@ -40,5 +40,11 @@ public class CommentRes { @NotBlank(message = "内容不能为空") private String content; + /** + * 父评论id + */ + @ApiModelProperty(value = "父评论id", required = true) + private Long parentId; + } diff --git a/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/domain/dto/PublishRemoveRes.java b/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/domain/dto/PublishRemoveRes.java new file mode 100644 index 0000000..ed5e833 --- /dev/null +++ b/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/domain/dto/PublishRemoveRes.java @@ -0,0 +1,30 @@ +package com.mcwl.communityCenter.domain.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotNull; + +/** + * 点赞/取消点赞请求参数 + */ +@Data +@ApiModel(value = "点赞/取消点赞请求参数") +public class PublishRemoveRes { + + /** + * 社区id + */ + @ApiModelProperty(value = "社区id", required = true) + @NotNull(message = "社区id不能为空") + private Long communityId; + + /** + * 发布id + */ + @ApiModelProperty(value = "发布id", required = true) + @NotNull(message = "发布id不能为空") + private Long publishId; + +} diff --git a/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/domain/dto/PublishReportRes.java b/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/domain/dto/PublishReportRes.java new file mode 100644 index 0000000..b4f53a0 --- /dev/null +++ b/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/domain/dto/PublishReportRes.java @@ -0,0 +1,50 @@ +package com.mcwl.communityCenter.domain.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotNull; + +/** + * 举报请求参数 + */ +@Data +@ApiModel(value = "举报请求参数") +public class PublishReportRes { + + /** + * 租户id + */ + @ApiModelProperty(value = "租户id", required = true) + @NotNull(message = "租户id不能为空") + private Long tenantId; + + /** + * 社区id + */ + @ApiModelProperty(value = "社区id", required = true) + @NotNull(message = "社区id不能为空") + private Long communityId; + + /** + * 发布id + */ + @ApiModelProperty(value = "发布id", required = true) + @NotNull(message = "发布id不能为空") + private Long publishId; + + /** + * 举报类型 + */ + @ApiModelProperty(value = "举报类型", required = true) + @NotNull(message = "举报类型不能为空") + private Integer reportType; + + /** + * 举报内容 + */ + @ApiModelProperty(value = "举报内容") + private String content; + +} diff --git a/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/domain/vo/CommentVo.java b/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/domain/vo/CommentVo.java index 8fbad90..e861e98 100644 --- a/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/domain/vo/CommentVo.java +++ b/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/domain/vo/CommentVo.java @@ -57,6 +57,12 @@ public class CommentVo { @ApiModelProperty(value = "用户头像") private String userAvatar; + /** + * 回复人名称 + */ + @ApiModelProperty(value = "回复人名称") + private String replyUserName; + /** * 父评论id */ @@ -69,6 +75,11 @@ public class CommentVo { @ApiModelProperty(value = "评论内容") private String content; + /** + * 是否点赞 + */ + @ApiModelProperty(value = "是否点赞") + private Integer isLike; /** * 评论点赞数 @@ -76,6 +87,12 @@ public class CommentVo { @ApiModelProperty(value = "评论点赞数") private Integer likeNum; + /** + * 是否接受 + */ + @ApiModelProperty(value = "是否接受") + private Integer isAccept; + /** * 评论时间 */ diff --git a/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/domain/vo/CommunityDetailVo.java b/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/domain/vo/CommunityDetailVo.java index 3844372..61019f8 100644 --- a/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/domain/vo/CommunityDetailVo.java +++ b/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/domain/vo/CommunityDetailVo.java @@ -1,12 +1,15 @@ package com.mcwl.communityCenter.domain.vo; import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; +import java.util.Date; +import java.util.List; /** * 社区返回数据 @@ -20,6 +23,12 @@ public class CommunityDetailVo { @ApiModelProperty(value = "社区id") private Long id; + /** + * 租户id + */ + @ApiModelProperty(value = "租户id") + private Long tenantId; + /** * 社区图片 */ @@ -32,38 +41,54 @@ public class CommunityDetailVo { @ApiModelProperty(value = "社区名称") private String communityName; - /** - * 社区标签id - */ - @ApiModelProperty(value = "社区标签") - @NotNull(message = "社区标签不能为空") - private Integer communityTag; - - /** - * 社区类型 - */ - @ApiModelProperty(value = "社区类型 0免费 1付费") - @NotNull(message = "社区类型不能为空") - private Integer type; - /** * 价格 */ @ApiModelProperty(value = "价格") - @NotNull(message = "价格不能为空") private Double price; - /** - * 有效期天数 - */ - @ApiModelProperty(value = "有效期天数") - @NotNull(message = "有效期天数") - private Integer validityDay; - /** * 描述 */ @ApiModelProperty(value = "描述") private String description; + /** + * 创建天数 + */ + @ApiModelProperty(value = "创建天数") + private Long createDay; + + /** + * 成员数 + */ + @ApiModelProperty(value = "成员数") + private Integer userNum; + + /** + * 成员头像 + */ + @ApiModelProperty(value = "成员头像") + private List avatarList; + + /** + * 更新内容数 + */ + @ApiModelProperty(value = "更新内容数") + private Integer updateNum; + + /** + * 最近更新时间 + */ + @ApiModelProperty(value = "最近更新时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date lastUpdateTime; + + /** + * 当前用户到期时间 + */ + @ApiModelProperty(value = "当前用户到期时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date expireTime; + } diff --git a/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/domain/vo/CommunityVo.java b/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/domain/vo/CommunityVo.java index 6a9d520..ef5f986 100644 --- a/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/domain/vo/CommunityVo.java +++ b/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/domain/vo/CommunityVo.java @@ -93,5 +93,11 @@ public class CommunityVo { @ApiModelProperty(value = "发布数量") private Integer publishNum; + /** + * 是否加入 + */ + @ApiModelProperty(value = "是否加入") + private Integer isJoin; + } diff --git a/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/domain/vo/PersonHomeVo.java b/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/domain/vo/PersonHomeVo.java index 7c3b988..71bf1ba 100644 --- a/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/domain/vo/PersonHomeVo.java +++ b/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/domain/vo/PersonHomeVo.java @@ -37,6 +37,24 @@ public class PersonHomeVo { @ApiModelProperty(value = "社区id") private Long communityId; + /** + * 用户id + */ + @ApiModelProperty(value = "用户id") + private Long userId; + + /** + * 用户名 + */ + @ApiModelProperty(value = "用户名") + private String userName; + + /** + * 用户头像 + */ + @ApiModelProperty(value = "用户头像") + private String avatar; + /** * 内容 */ @@ -69,6 +87,13 @@ public class PersonHomeVo { @ApiModelProperty(value = "点赞数") private Integer likeNum; + /** + * 是否点赞 + */ + @ApiModelProperty(value = "是否点赞") + private Integer isLike; + + /** * 是否收藏 */ @@ -81,6 +106,24 @@ public class PersonHomeVo { @ApiModelProperty(value = "评论") private List commentList; + /** + * 是否匿名 + */ + @ApiModelProperty(value = "是否匿名") + private Integer isAnonymous; + + /** + * 提问类型 0免费 1付费 + */ + @ApiModelProperty(value = "提问类型 0免费 1付费") + private Integer type; + + /** + * 付费金额 当提问类型为付费时必填 + */ + @ApiModelProperty(value = "付费金额 当提问类型为付费时必填") + private Double amount; + /** * 创建时间 */ diff --git a/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/domain/vo/PublishVo.java b/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/domain/vo/PublishVo.java index 9db9f56..6cc1aaf 100644 --- a/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/domain/vo/PublishVo.java +++ b/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/domain/vo/PublishVo.java @@ -7,6 +7,7 @@ import lombok.Data; import springfox.documentation.annotations.ApiIgnore; import java.util.Date; +import java.util.List; /** * 发布信息 @@ -105,6 +106,13 @@ public class PublishVo { @ApiModelProperty(value = "收藏") private Integer isCollect; + /** + * 评论 + */ + @ApiModelProperty(value = "评论") + private List commentList; + + @ApiModelProperty(value = "创建时间") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") private Date createTime; diff --git a/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/domain/vo/QuestionCommentVo.java b/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/domain/vo/QuestionCommentVo.java index 2ff1d5a..d2e30ab 100644 --- a/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/domain/vo/QuestionCommentVo.java +++ b/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/domain/vo/QuestionCommentVo.java @@ -1,46 +1,74 @@ package com.mcwl.communityCenter.domain.vo; +import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import java.util.Date; + @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 userName; + + /** + * 用户头像 + */ + @ApiModelProperty(value = "用户头像") + private String avatar; + /** * 内容 */ @ApiModelProperty(value = "内容") private String content; + /** * 是否接受 */ @ApiModelProperty(value = "是否接受") - private Long isAccept; + private Integer isAccept; + + /** + * 创建时间 + */ + @ApiModelProperty(value = "创建时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") + private Date createTime; } diff --git a/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/domain/vo/QuestionVo.java b/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/domain/vo/QuestionVo.java index 722f091..d42b597 100644 --- a/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/domain/vo/QuestionVo.java +++ b/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/domain/vo/QuestionVo.java @@ -1,6 +1,7 @@ package com.mcwl.communityCenter.domain.vo; +import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -8,6 +9,7 @@ import lombok.Data; import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; import java.util.Date; +import java.util.List; @Data @ApiModel(description = "问题信息") @@ -17,6 +19,12 @@ public class QuestionVo { @ApiModelProperty(value = "主键") private Long id; + /** + * 租户id + */ + @ApiModelProperty(value = "租户id") + private Long tenantId; + /** * 社区id */ @@ -54,28 +62,10 @@ public class QuestionVo { private String questionUrl; /** - * 提问时间 + * 评论 */ - @ApiModelProperty(value = "提问时间") - private Date createTime; - -// /** -// * 答复用户id -// */ -// @ApiModelProperty(value = "答复用户id") -// private Long replyUserId; -// -// /** -// * 回复内容 -// */ -// @ApiModelProperty(value = "回复内容") -// private String reply; -// -// /** -// * 回复时间 -// */ -// @ApiModelProperty(value = "回复时间") -// private Date replyTime; + @ApiModelProperty(value = "评论") + private List commentList; /** * 是否匿名 @@ -86,14 +76,21 @@ public class QuestionVo { /** * 提问类型 0免费 1付费 */ + @ApiModelProperty(value = "提问类型 0免费 1付费") private Integer type; /** * 付费金额 当提问类型为付费时必填 */ + @ApiModelProperty(value = "付费金额 当提问类型为付费时必填") private Double amount; - + /** + * 提问时间 + */ + @ApiModelProperty(value = "提问时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") + private Date createTime; diff --git a/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/mapper/CommunityMapper.java b/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/mapper/CommunityMapper.java index b871dec..f9a2efc 100644 --- a/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/mapper/CommunityMapper.java +++ b/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/mapper/CommunityMapper.java @@ -65,4 +65,7 @@ public interface CommunityMapper extends BaseMapper { @InterceptorIgnore(tenantLine = "true") void deleteCommunity(@Param("tenantId") Long tenantId, @Param("communityId") Long communityId); + + @InterceptorIgnore(tenantLine = "true") + Community getCommunity(@Param("tenantId") Long tenantId, @Param("communityId") Long communityId); } diff --git a/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/mapper/CommunityUserMapper.java b/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/mapper/CommunityUserMapper.java index 6cebd9e..3353783 100644 --- a/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/mapper/CommunityUserMapper.java +++ b/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/mapper/CommunityUserMapper.java @@ -12,6 +12,7 @@ import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; import javax.validation.constraints.NotNull; +import java.util.Date; import java.util.List; import java.util.Map; @@ -51,4 +52,12 @@ public interface CommunityUserMapper extends BaseMapper { List getAllCommunityUser(); void updateManageCommunityUser(@Param("manageCommunityUser") CommunityUser manageCommunityUser); + + @InterceptorIgnore(tenantLine = "true") + Date getExpireTime(@Param("tenantId") Long tenantId, + @Param("communityId") Long communityId, + @Param("userId") Long userId); + + @InterceptorIgnore(tenantLine = "true") + List getCommunityUserAvatar(@Param("tenantId") Long tenantId, @Param("communityId") Long communityId); } diff --git a/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/mapper/PublishCommentLikeMapper.java b/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/mapper/PublishCommentLikeMapper.java index 315a43f..6eb9fc7 100644 --- a/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/mapper/PublishCommentLikeMapper.java +++ b/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/mapper/PublishCommentLikeMapper.java @@ -3,6 +3,7 @@ package com.mcwl.communityCenter.mapper; import com.baomidou.mybatisplus.annotation.InterceptorIgnore; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.mcwl.communityCenter.domain.PublishCommentLike; +import com.mcwl.communityCenter.domain.dto.CommentLikeDetailRes; import com.mcwl.communityCenter.domain.dto.PublishCommentLikeRes; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -31,4 +32,8 @@ public interface PublishCommentLikeMapper extends BaseMapper @InterceptorIgnore(tenantLine = "true") PublishCommentLike selectLike(@Param("publishCommentLikeRes") PublishCommentLikeRes publishCommentLikeRes, @Param("userId") Long userId); + + @InterceptorIgnore(tenantLine = "true") + PublishCommentLike publishCommentLike(@Param("commentLikeDetailRes") CommentLikeDetailRes commentLikeDetailRes, + @Param("userId") Long userId); } diff --git a/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/mapper/PublishCommentMapper.java b/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/mapper/PublishCommentMapper.java index dcb2afa..ffb6a4e 100644 --- a/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/mapper/PublishCommentMapper.java +++ b/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/mapper/PublishCommentMapper.java @@ -20,23 +20,23 @@ import java.util.List; public interface PublishCommentMapper extends BaseMapper { @InterceptorIgnore(tenantLine = "true") - List selectByTenantIdAndCommunityIdAndOperatorId(@Param("tenantId") + List selectByTenantIdAndCommunityIdAndPublishIdList(@Param("tenantId") Long tenantId, @Param("communityId") Long communityId, - @Param("operatorId") - Long operatorId); + @Param("publishId") + Long publishId); @InterceptorIgnore(tenantLine = "true") - PublishComment selectByIdAndTenantIdAndCommunityIdAndOperatorId(@Param("id") + PublishComment selectByIdAndTenantIdAndCommunityIdAndPublishId(@Param("id") Long id, @Param("tenantId") Long tenantId, @Param("communityId") Long communityId, - @Param("operatorId") - Long operatorId); + @Param("publishId") + Long publishId); @InterceptorIgnore(tenantLine = "true") Integer deleteByIdAndTenantIdAndCommunityIdAndOperatorId(@Param("id") @@ -45,6 +45,6 @@ public interface PublishCommentMapper extends BaseMapper { Long tenantId, @Param("communityId") Long communityId, - @Param("operatorId") - Long operatorId); + @Param("publishId") + Long publishId); } diff --git a/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/mapper/PublishMapper.java b/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/mapper/PublishMapper.java index 8d3fcb4..9cf74f1 100644 --- a/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/mapper/PublishMapper.java +++ b/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/mapper/PublishMapper.java @@ -46,7 +46,7 @@ public interface PublishMapper extends BaseMapper { void elitePublish(@Param("communityId") Long communityId, @Param("publishId") Long publishId); @InterceptorIgnore(tenantLine = "true") - List publishList(Page page, @Param("publishPageRes") PublishPageRes publishPageRes); + List publishList(Page page, @Param("publishPageRes") PublishPageRes publishPageRes); @InterceptorIgnore(tenantLine = "true") List myPublishList(Page page, @@ -55,4 +55,7 @@ public interface PublishMapper extends BaseMapper { @InterceptorIgnore(tenantLine = "true") void insertPublish(@Param("publish") Publish publish); + + @InterceptorIgnore(tenantLine = "true") + Publish getLastPublish(@Param("tenantId") Long tenantId, @Param("communityId") Long communityId); } diff --git a/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/mapper/PublishReportMapper.java b/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/mapper/PublishReportMapper.java new file mode 100644 index 0000000..c6b8bce --- /dev/null +++ b/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/mapper/PublishReportMapper.java @@ -0,0 +1,21 @@ +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.PublishReport; +import com.mcwl.communityCenter.domain.dto.MyPublishPageRes; +import com.mcwl.communityCenter.domain.dto.PublishPageRes; +import com.mcwl.communityCenter.domain.vo.PublishVo; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +@Mapper +public interface PublishReportMapper extends BaseMapper { + + @InterceptorIgnore(tenantLine = "true") + void insertReport(@Param("publishReport") PublishReport publishReport); +} diff --git a/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/mapper/QuestionCommentMapper.java b/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/mapper/QuestionCommentMapper.java index 1285719..ad4ff95 100644 --- a/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/mapper/QuestionCommentMapper.java +++ b/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/mapper/QuestionCommentMapper.java @@ -6,10 +6,13 @@ 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 com.mcwl.communityCenter.domain.dto.QuestionDetailRes; +import com.mcwl.communityCenter.domain.vo.QuestionCommentVo; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; import javax.validation.constraints.NotNull; +import java.util.List; @Mapper public interface QuestionCommentMapper extends BaseMapper { @@ -33,4 +36,7 @@ public interface QuestionCommentMapper extends BaseMapper { Long questionId, @Param("commentId") Long commentId); + + @InterceptorIgnore(tenantLine = "true") + List getComment(@Param("questionDetailRes") QuestionDetailRes questionDetailRes); } diff --git a/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/mapper/QuestionMapper.java b/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/mapper/QuestionMapper.java index ab2a076..526d4d4 100644 --- a/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/mapper/QuestionMapper.java +++ b/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/mapper/QuestionMapper.java @@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.mcwl.communityCenter.domain.Community; import com.mcwl.communityCenter.domain.Question; import com.mcwl.communityCenter.domain.dto.QuestionPageRes; +import com.mcwl.communityCenter.domain.vo.QuestionVo; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -15,13 +16,13 @@ import java.util.List; @Mapper public interface QuestionMapper extends BaseMapper { @InterceptorIgnore(tenantLine = "true") - Page list(Page page, - @NotNull(message = "租户不能为空") - @Param("tenantId") - Long tenantId, - @NotNull(message = "社区不能为空") - @Param("communityId") - Long communityId); + List list(Page page, + @NotNull(message = "租户不能为空") + @Param("tenantId") + Long tenantId, + @NotNull(message = "社区不能为空") + @Param("communityId") + Long communityId); @InterceptorIgnore(tenantLine = "true") Question selectByIdAndTenantIdAndCommunityId(@Param("id") @@ -33,15 +34,15 @@ public interface QuestionMapper extends BaseMapper { @InterceptorIgnore(tenantLine = "true") Page listImage(Page page, - @NotNull(message = "租户不能为空") - @Param("tenantId") - Long tenantId, - @NotNull(message = "社区不能为空") - @Param("communityId") - Long communityId); + @NotNull(message = "租户不能为空") + @Param("tenantId") + Long tenantId, + @NotNull(message = "社区不能为空") + @Param("communityId") + Long communityId); @InterceptorIgnore(tenantLine = "true") - List myQuestionList(Page page, + List myQuestionList(Page page, @Param("questionPageRes") QuestionPageRes questionPageRes, @Param("userId") Long userId); } diff --git a/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/service/CommunityService.java b/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/service/CommunityService.java index 8a87f77..9d6b6f8 100644 --- a/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/service/CommunityService.java +++ b/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/service/CommunityService.java @@ -41,7 +41,7 @@ public interface CommunityService extends IService { */ R isJoinCommunity(JoinCommunityRes joinCommunityRes); - CommunityDetailVo getCommunityDetail(Long communityId); + CommunityDetailVo getCommunityDetail(Long tenantId, Long communityId); void editCommunity(@Valid EditCommunityRes editCommunityRes); } diff --git a/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/service/PublishCommentLikeService.java b/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/service/PublishCommentLikeService.java index ddb26bd..2e219ad 100644 --- a/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/service/PublishCommentLikeService.java +++ b/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/service/PublishCommentLikeService.java @@ -1,7 +1,9 @@ package com.mcwl.communityCenter.service; import com.baomidou.mybatisplus.extension.service.IService; +import com.mcwl.common.core.domain.R; import com.mcwl.communityCenter.domain.PublishCommentLike; +import com.mcwl.communityCenter.domain.dto.CommentLikeDetailRes; import com.mcwl.communityCenter.domain.dto.PublishCommentLikeRes; import org.springframework.stereotype.Service; @@ -19,5 +21,7 @@ import javax.validation.constraints.NotNull; @Service public interface PublishCommentLikeService extends IService { - void like(PublishCommentLikeRes publishCommentLikeRes); + R like(PublishCommentLikeRes publishCommentLikeRes); + + PublishCommentLike publishCommentLike(CommentLikeDetailRes commentLikeDetailRes, Long userId); } diff --git a/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/service/PublishCommentService.java b/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/service/PublishCommentService.java index c9e2a14..b029a9a 100644 --- a/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/service/PublishCommentService.java +++ b/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/service/PublishCommentService.java @@ -1,14 +1,12 @@ package com.mcwl.communityCenter.service; import com.baomidou.mybatisplus.extension.service.IService; -import com.mcwl.common.core.domain.AjaxResult; import com.mcwl.common.core.domain.R; import com.mcwl.communityCenter.domain.dto.CommentDelRes; import com.mcwl.communityCenter.domain.dto.CommentDetailRes; import com.mcwl.communityCenter.domain.dto.CommentRes; import com.mcwl.communityCenter.domain.vo.CommentVo; import com.mcwl.communityCenter.domain.PublishComment; -import org.springframework.http.ResponseEntity; import javax.validation.Valid; import java.util.List; diff --git a/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/service/PublishReportService.java b/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/service/PublishReportService.java new file mode 100644 index 0000000..a3c2694 --- /dev/null +++ b/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/service/PublishReportService.java @@ -0,0 +1,17 @@ +package com.mcwl.communityCenter.service; + +import com.baomidou.mybatisplus.annotation.InterceptorIgnore; +import com.baomidou.mybatisplus.extension.service.IService; +import com.mcwl.common.core.domain.R; +import com.mcwl.common.core.page.TableDataInfo; +import com.mcwl.communityCenter.domain.Publish; +import com.mcwl.communityCenter.domain.PublishReport; +import com.mcwl.communityCenter.domain.dto.*; +import com.mcwl.communityCenter.domain.vo.PublishVo; + +import javax.validation.Valid; + +public interface PublishReportService extends IService { + + void saveReport(PublishReport publishReport); +} diff --git a/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/service/PublishService.java b/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/service/PublishService.java index 4fc49d6..08c4255 100644 --- a/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/service/PublishService.java +++ b/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/service/PublishService.java @@ -2,6 +2,7 @@ package com.mcwl.communityCenter.service; import com.baomidou.mybatisplus.extension.service.IService; import com.mcwl.common.core.domain.AjaxResult; +import com.mcwl.common.core.domain.BaseEntity; import com.mcwl.common.core.domain.R; import com.mcwl.common.core.page.PageDomain; import com.mcwl.common.core.page.TableDataInfo; @@ -39,4 +40,8 @@ public interface PublishService extends IService { void collectPublish(@Valid PublishCollectRes publishCollectRes); TableDataInfo getPersonHomeList(@Valid PersonHomePageRes personHomePageRes); + + void reportPublish(@Valid PublishReportRes publishReportRes); + + Publish getLastPublish(Long tenantId, Long communityId); } diff --git a/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/service/QuestionCommentService.java b/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/service/QuestionCommentService.java index a60a97a..f514e4b 100644 --- a/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/service/QuestionCommentService.java +++ b/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/service/QuestionCommentService.java @@ -7,9 +7,11 @@ 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.QuestionCommentVo; import com.mcwl.communityCenter.domain.vo.QuestionVo; import javax.validation.Valid; +import java.util.List; public interface QuestionCommentService extends IService { @@ -18,4 +20,6 @@ public interface QuestionCommentService extends IService { TableDataInfo listByPage(@Valid QuestionCommentPageRes questionCommentPageRes); R adopt(@Valid QuestionCommentAdoptRes questionCommentAdoptRes); + + List getComment(QuestionDetailRes questionDetailRes); } diff --git a/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/service/impl/CommunityServiceImpl.java b/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/service/impl/CommunityServiceImpl.java index 296f3b2..d6827be 100644 --- a/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/service/impl/CommunityServiceImpl.java +++ b/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/service/impl/CommunityServiceImpl.java @@ -17,6 +17,7 @@ import com.mcwl.communityCenter.constant.AdviceConstant; import com.mcwl.communityCenter.domain.Community; import com.mcwl.communityCenter.domain.CommunityAdvice; import com.mcwl.communityCenter.domain.CommunityUser; +import com.mcwl.communityCenter.domain.Publish; import com.mcwl.communityCenter.domain.dto.*; import com.mcwl.communityCenter.domain.vo.CommunityDetailVo; import com.mcwl.communityCenter.domain.vo.CommunityVo; @@ -24,6 +25,7 @@ import com.mcwl.communityCenter.mapper.CommunityAdviceMapper; import com.mcwl.communityCenter.mapper.CommunityMapper; import com.mcwl.communityCenter.mapper.CommunityUserMapper; import com.mcwl.communityCenter.service.CommunityService; +import com.mcwl.communityCenter.service.PublishService; import com.mcwl.system.service.ISysUserService; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; @@ -35,6 +37,8 @@ import java.time.ZoneId; import java.time.temporal.ChronoUnit; import java.util.*; import java.util.concurrent.TimeUnit; +import java.util.function.Function; +import java.util.stream.Collectors; @Service @RequiredArgsConstructor @@ -48,6 +52,8 @@ public class CommunityServiceImpl extends ServiceImpl 1) { - return R.fail(HttpStatus.SHOW_ERROR_MSG,"社区还有成员,无法退出"); + return R.fail(HttpStatus.SHOW_ERROR_MSG, "社区还有成员,无法退出"); } baseMapper.quitCommunity(tenantId, communityId, userId); @@ -219,9 +225,41 @@ public class CommunityServiceImpl extends ServiceImpl avatarList = communityUserMapper.getCommunityUserAvatar(tenantId, communityId); + communityDetailVo.setAvatarList(avatarList); + + // 获取当前用户到期时间 + communityDetailVo.setExpireTime(communityUserMapper.getExpireTime(tenantId, communityId, SecurityUtils.getUserId())); + + + return communityDetailVo; } @Override @@ -232,36 +270,12 @@ public class CommunityServiceImpl extends ServiceImpl communityList, Long total) { + List myJoinCommunityList = baseMapper.getMyJoinCommunity(new Page<>(1, 100), + SecurityUtils.getUserId(), + new JoinCommunityListPageRes()); - // 查询社区加入人数,以map形式返回,key为社区id,value为加入人数 - Map communityJoinNumMap = redisCache.getCacheMap("communityJoinNumMap"); - if (communityJoinNumMap.isEmpty()) { - Map> joinMap = baseMapper.selectCommunityJoinNum(); - if (joinMap != null && !joinMap.isEmpty()) { - joinMap.forEach((key, value) -> { - communityJoinNumMap.put(key.toString(), Integer.valueOf(value.get("joinNum").toString())); - }); - redisCache.setCacheMap("communityJoinNumMap", communityJoinNumMap); - } else { - redisCache.setCacheMap("communityJoinNumMap", new HashMap<>()); - } - redisCache.expire("communityJoinNumMap", 1, TimeUnit.HOURS); - } - - // 查询社区发布数,以map形式返回,key为社区id,value为发布数 - Map communityPublishNumMap = redisCache.getCacheMap("communityPublishNumMap"); - if (communityPublishNumMap.isEmpty()) { - Map> publishMap = baseMapper.selectCommunityPublishNum(); - if (publishMap != null && !publishMap.isEmpty()) { - publishMap.forEach((key, value) -> { - communityPublishNumMap.put(key.toString(), Integer.valueOf(value.get("publishNum").toString())); - }); - redisCache.setCacheMap("communityPublishNumMap", communityPublishNumMap); - } else { - redisCache.setCacheMap("communityPublishNumMap", new HashMap<>()); - } - redisCache.expire("communityPublishNumMap", 1, TimeUnit.HOURS); - } + Map myJoinCommunityMap = myJoinCommunityList.stream() + .collect(Collectors.toMap(Community::getId, Function.identity())); List communityVoList = new ArrayList<>(); @@ -284,8 +298,15 @@ public class CommunityServiceImpl extends ServiceImpl communityJoinNumMap = redisCache.getCacheMap("communityJoinNumMap"); + if (communityJoinNumMap.isEmpty()) { + Map> joinMap = baseMapper.selectCommunityJoinNum(); + if (joinMap != null && !joinMap.isEmpty()) { + joinMap.forEach((key, value) -> { + communityJoinNumMap.put(key.toString(), Integer.valueOf(value.get("joinNum").toString())); + }); + redisCache.setCacheMap("communityJoinNumMap", communityJoinNumMap); + } else { + redisCache.setCacheMap("communityJoinNumMap", new HashMap<>()); + } + redisCache.expire("communityJoinNumMap", 1, TimeUnit.HOURS); + } + return Integer.parseInt(communityJoinNumMap.getOrDefault(communityId.toString(), 0).toString()); + + } + + private int getCommunityPublishNum(Long communityId) { + // 查询社区发布数,以map形式返回,key为社区id,value为发布数 + Map communityPublishNumMap = redisCache.getCacheMap("communityPublishNumMap"); + if (communityPublishNumMap.isEmpty()) { + Map> publishMap = baseMapper.selectCommunityPublishNum(); + if (publishMap != null && !publishMap.isEmpty()) { + publishMap.forEach((key, value) -> { + communityPublishNumMap.put(key.toString(), Integer.valueOf(value.get("publishNum").toString())); + }); + redisCache.setCacheMap("communityPublishNumMap", communityPublishNumMap); + } else { + redisCache.setCacheMap("communityPublishNumMap", new HashMap<>()); + } + redisCache.expire("communityPublishNumMap", 1, TimeUnit.HOURS); + } + return Integer.parseInt(communityPublishNumMap.getOrDefault(communityId.toString(), 0).toString()); + + } + + } diff --git a/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/service/impl/PublishCollectServiceImpl.java b/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/service/impl/PublishCollectServiceImpl.java index 756306e..2e9c4a9 100644 --- a/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/service/impl/PublishCollectServiceImpl.java +++ b/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/service/impl/PublishCollectServiceImpl.java @@ -10,18 +10,12 @@ 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.utils.SecurityUtils; -import com.mcwl.communityCenter.domain.Community; -import com.mcwl.communityCenter.domain.Publish; -import com.mcwl.communityCenter.domain.PublishCollect; -import com.mcwl.communityCenter.domain.Question; +import com.mcwl.communityCenter.domain.*; import com.mcwl.communityCenter.domain.dto.*; import com.mcwl.communityCenter.domain.vo.CommentVo; import com.mcwl.communityCenter.domain.vo.PersonHomeVo; import com.mcwl.communityCenter.domain.vo.PublishVo; -import com.mcwl.communityCenter.mapper.CommunityMapper; -import com.mcwl.communityCenter.mapper.InviteMapper; -import com.mcwl.communityCenter.mapper.PublishCollectMapper; -import com.mcwl.communityCenter.mapper.PublishMapper; +import com.mcwl.communityCenter.mapper.*; import com.mcwl.communityCenter.service.PublishCollectService; import com.mcwl.communityCenter.service.PublishCommentService; import com.mcwl.communityCenter.service.PublishService; @@ -37,6 +31,9 @@ public class PublishCollectServiceImpl extends ServiceImpl commentVoList = publishCommentService.getComment(commentDetailRes).getData(); personHomeVo.setCommentList(commentVoList); diff --git a/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/service/impl/PublishCommentLikeServiceImpl.java b/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/service/impl/PublishCommentLikeServiceImpl.java index 6669eee..0e6b34f 100644 --- a/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/service/impl/PublishCommentLikeServiceImpl.java +++ b/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/service/impl/PublishCommentLikeServiceImpl.java @@ -2,18 +2,23 @@ package com.mcwl.communityCenter.service.impl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.mcwl.common.constant.HttpStatus; +import com.mcwl.common.core.domain.R; import com.mcwl.common.exception.ServiceException; import com.mcwl.common.utils.SecurityUtils; import com.mcwl.common.utils.StringUtils; import com.mcwl.communityCenter.constant.AdviceConstant; -import com.mcwl.communityCenter.domain.CommunityAdvice; -import com.mcwl.communityCenter.domain.PublishComment; -import com.mcwl.communityCenter.domain.PublishCommentLike; +import com.mcwl.communityCenter.domain.*; +import com.mcwl.communityCenter.domain.dto.CommentLikeDetailRes; import com.mcwl.communityCenter.domain.dto.PublishCommentLikeRes; +import com.mcwl.communityCenter.mapper.CommunityAdviceMapper; +import com.mcwl.communityCenter.mapper.CommunityUserMapper; import com.mcwl.communityCenter.mapper.PublishCommentLikeMapper; import com.mcwl.communityCenter.mapper.PublishCommentMapper; +import com.mcwl.communityCenter.service.CommunityAdviceService; import com.mcwl.communityCenter.service.PublishCommentLikeService; +import com.mcwl.communityCenter.service.PublishCommentService; import lombok.RequiredArgsConstructor; +import net.bytebuddy.implementation.bytecode.Throw; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -33,14 +38,90 @@ import java.util.Objects; @RequiredArgsConstructor public class PublishCommentLikeServiceImpl extends ServiceImpl implements PublishCommentLikeService { - private final PublishCommentMapper publishCommentMapper; + private final CommunityUserMapper communityUserMapper; + + private final CommunityAdviceMapper communityAdviceMapper; + @Override @Transactional(rollbackFor = Exception.class) - public void like(PublishCommentLikeRes publishCommentLikeRes) { + public R like(PublishCommentLikeRes publishCommentLikeRes) { + Long tenantId = publishCommentLikeRes.getTenantId(); + Long communityId = publishCommentLikeRes.getCommunityId(); + Long publishId = publishCommentLikeRes.getPublishId(); + Long commentId = publishCommentLikeRes.getCommentId(); + + PublishComment publishComment = publishCommentMapper.selectByIdAndTenantIdAndCommunityIdAndPublishId(commentId, tenantId, communityId, publishId); + + if (Objects.isNull(publishComment)) { + throw new ServiceException("点赞失败,该内容不存在", HttpStatus.SHOW_ERROR_MSG); + } + CommunityUser communityUser = communityUserMapper.selectCommunityUser(tenantId, + communityId, SecurityUtils.getUserId()); + + if (Objects.isNull(communityUser)) { + throw new ServiceException("点赞失败,您不是该社区成员", HttpStatus.SHOW_ERROR_MSG); + } + + if ("1".equals(communityUser.getIsBlack())) { + throw new ServiceException("点赞失败,您已被拉黑", HttpStatus.SHOW_ERROR_MSG); + } + + PublishCommentLike publishCommentLike = baseMapper.selectLike(publishCommentLikeRes, SecurityUtils.getUserId()); + + if (Objects.isNull(publishCommentLike)) { + publishCommentLike = new PublishCommentLike(); + publishCommentLike.setTenantId(tenantId); + publishCommentLike.setCommunityId(communityId); + publishCommentLike.setPublishId(publishId); + publishCommentLike.setPublishCommentId(commentId); + publishCommentLike.setUserId(SecurityUtils.getUserId()); + baseMapper.insert(publishCommentLike); + + publishComment.setLikeNum(publishComment.getLikeNum() + 1); + publishCommentMapper.updateById(publishComment); + this.addLikeAdvice(publishComment); + return R.ok(publishComment.getLikeNum()); + } + + if (Objects.equals(publishCommentLike.getDelFlag(), "0")) { + publishCommentLike.setDelFlag("2"); + int likeNum = publishComment.getLikeNum() - 1; + likeNum = Math.max(likeNum, 0); + publishComment.setLikeNum(likeNum); + } else { + publishCommentLike.setDelFlag("0"); + publishComment.setLikeNum(publishComment.getLikeNum() + 1); + this.addLikeAdvice(publishComment); + } + + baseMapper.updateDelFlagById(publishCommentLike); + publishCommentMapper.updateById(publishComment); + + return R.ok(publishComment.getLikeNum()); + + } + + @Override + public PublishCommentLike publishCommentLike(CommentLikeDetailRes commentLikeDetailRes, Long userId) { + return baseMapper.publishCommentLike(commentLikeDetailRes, userId); + } + + private void addLikeAdvice(PublishComment publishComment) { + CommunityAdvice communityAdvice = new CommunityAdvice(); + + communityAdvice.setTenantId(publishComment.getTenantId()); + communityAdvice.setCommunityId(publishComment.getCommunityId()); + communityAdvice.setSendUserId(SecurityUtils.getUserId()); + communityAdvice.setAdviceType(AdviceConstant.LIKE); + communityAdvice.setUserId(publishComment.getUserId()); + communityAdvice.setContent(StringUtils.format("{}点赞了你的评论{}", + SecurityUtils.getLoginUser().getUser().getNickName(), publishComment.getContent())); + + communityAdviceMapper.insert(communityAdvice); } diff --git a/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/service/impl/PublishCommentServiceImpl.java b/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/service/impl/PublishCommentServiceImpl.java index dbabea0..ea9ae48 100644 --- a/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/service/impl/PublishCommentServiceImpl.java +++ b/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/service/impl/PublishCommentServiceImpl.java @@ -1,36 +1,30 @@ package com.mcwl.communityCenter.service.impl; import cn.hutool.core.bean.BeanUtil; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; 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.R; import com.mcwl.common.core.domain.entity.SysUser; import com.mcwl.common.utils.SecurityUtils; -import com.mcwl.communityCenter.domain.CommunityUser; -import com.mcwl.communityCenter.domain.Publish; +import com.mcwl.communityCenter.domain.*; import com.mcwl.communityCenter.domain.dto.CommentDelRes; import com.mcwl.communityCenter.domain.dto.CommentDetailRes; +import com.mcwl.communityCenter.domain.dto.CommentLikeDetailRes; import com.mcwl.communityCenter.domain.dto.CommentRes; import com.mcwl.communityCenter.domain.vo.CommentVo; -import com.mcwl.communityCenter.domain.PublishComment; -import com.mcwl.communityCenter.domain.PublishCommentLike; import com.mcwl.communityCenter.mapper.CommunityUserMapper; import com.mcwl.communityCenter.mapper.PublishCommentLikeMapper; import com.mcwl.communityCenter.mapper.PublishCommentMapper; import com.mcwl.communityCenter.mapper.PublishMapper; +import com.mcwl.communityCenter.service.PublishCommentLikeService; import com.mcwl.communityCenter.service.PublishCommentService; import com.mcwl.system.service.ISysUserService; import lombok.RequiredArgsConstructor; -import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import javax.validation.constraints.NotNull; -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; +import java.util.*; +import java.util.function.Function; +import java.util.stream.Collectors; /** * 评论区业务层 @@ -48,31 +42,69 @@ public class PublishCommentServiceImpl extends ServiceImpl> getComment(CommentDetailRes commentDetailRes) { Long tenantId = commentDetailRes.getTenantId(); Long communityId = commentDetailRes.getCommunityId(); - Long operatorId = commentDetailRes.getOperatorId(); + Long publishId = commentDetailRes.getPublishId(); // 查询评论 List publishComment = publishCommentMapper - .selectByTenantIdAndCommunityIdAndOperatorId(tenantId, communityId, operatorId); + .selectByTenantIdAndCommunityIdAndPublishIdList(tenantId, communityId, publishId); List commentVoList = BeanUtil.copyToList(publishComment, CommentVo.class); + Map commentVoMap = commentVoList.stream() + .collect(Collectors.toMap(CommentVo::getId, Function.identity())); + + // 收集所有需要查询的用户ID(包括回复对象ID) + Set userIds = new HashSet<>(); + for (CommentVo commentVo : commentVoList) { + userIds.add(commentVo.getUserId()); + } + // 批量查询用户信息并建立缓存映射 + Map userMap = sysUserService.selectUserByIds(userIds).stream() + .collect(Collectors.toMap(SysUser::getUserId, Function.identity())); + for (CommentVo commentVo : commentVoList) { Long userId = commentVo.getUserId(); - SysUser sysUser = sysUserService.selectUserById(userId); + SysUser sysUser = userMap.get(userId); commentVo.setUserName(sysUser.getNickName()); commentVo.setUserAvatar(sysUser.getAvatar()); + + if (commentVo.getParentId() != null) { + Long parentId = commentVo.getParentId(); + CommentVo parentCommentVo = commentVoMap.get(parentId); + if (Objects.nonNull(parentCommentVo)) { + SysUser su = userMap.get(parentCommentVo.getUserId()); + commentVo.setReplyUserName(su.getNickName()); + } + } + + CommentLikeDetailRes commentLikeDetailRes = new CommentLikeDetailRes(); + commentLikeDetailRes.setTenantId(tenantId); + commentLikeDetailRes.setCommunityId(communityId); + commentLikeDetailRes.setPublishId(publishId); + commentLikeDetailRes.setPublishCommentId(commentVo.getId()); + PublishCommentLike publishCommentLike = publishCommentLikeService.publishCommentLike(commentLikeDetailRes, SecurityUtils.getUserId()); + if (Objects.isNull(publishCommentLike)) { + commentVo.setIsLike(0); + } else { + String delFlag = publishCommentLike.getDelFlag(); + if (Objects.equals(delFlag, "0")) { + commentVo.setIsLike(1); + } else { + commentVo.setIsLike(0); + } + } } return R.ok(commentVoList); @@ -82,28 +114,27 @@ public class PublishCommentServiceImpl extends ServiceImpl addComment(CommentRes commentRes) { Long tenantId = commentRes.getTenantId(); Long communityId = commentRes.getCommunityId(); - Long operatorId = commentRes.getOperatorId(); + Long publishId = commentRes.getPublishId(); CommunityUser communityUser = communityUserMapper.selectCommunityUser(tenantId, communityId, SecurityUtils.getUserId()); if (Objects.isNull(communityUser)) { - return R.fail(HttpStatus.SHOW_ERROR_MSG,"评论失败,您不是该社区成员"); + return R.fail(HttpStatus.SHOW_ERROR_MSG, "评论失败,您不是该社区成员"); } if ("1".equals(communityUser.getIsBlack())) { - return R.fail(HttpStatus.SHOW_ERROR_MSG,"评论失败,您已被拉黑"); + return R.fail(HttpStatus.SHOW_ERROR_MSG, "评论失败,您已被拉黑"); } - Publish publish = publishMapper.selectByIdAndTenantIdAndCommunityId(operatorId, tenantId, communityId); + Publish publish = publishMapper.selectByIdAndTenantIdAndCommunityId(publishId, tenantId, communityId); if (Objects.isNull(publish)) { - return R.fail(HttpStatus.SHOW_ERROR_MSG,"评论失败,该内容不存在"); + return R.fail(HttpStatus.SHOW_ERROR_MSG, "评论失败,该内容不存在"); } PublishComment publishComment = new PublishComment(); BeanUtil.copyProperties(commentRes, publishComment); - publishComment.setPublishId(operatorId); +// publishComment.setPublishId(publishId); publishComment.setUserId(SecurityUtils.getUserId()); - publishComment.setType(0); publishCommentMapper.insert(publishComment); @@ -115,15 +146,15 @@ public class PublishCommentServiceImpl extends ServiceImpl implements PublishReportService { + + + @Override + public void saveReport(PublishReport publishReport) { + + baseMapper.insertReport(publishReport); + + } +} diff --git a/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/service/impl/PublishServiceImpl.java b/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/service/impl/PublishServiceImpl.java index 1d1d4a6..0be5cbd 100644 --- a/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/service/impl/PublishServiceImpl.java +++ b/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/service/impl/PublishServiceImpl.java @@ -58,6 +58,7 @@ public class PublishServiceImpl extends ServiceImpl impl private final QuestionService questionService; + private final PublishReportMapper publishReportMapper; @Override @@ -215,18 +216,27 @@ public class PublishServiceImpl extends ServiceImpl impl public TableDataInfo publishList(PublishPageRes publishPageRes) { Page page = this.initPage(publishPageRes); - List publishList = baseMapper.publishList(page, publishPageRes); + List publishVoList = baseMapper.publishList(page, publishPageRes); - List publishVoList = BeanUtil.copyToList(publishList, PublishVo.class); for (PublishVo publishVo : publishVoList) { - SysUser sysUser = sysUserService.selectUserById(publishVo.getUserId()); - publishVo.setUserName(sysUser.getNickName()); - publishVo.setAvatar(sysUser.getAvatar()); + + CommentDetailRes commentDetailRes = new CommentDetailRes(); + commentDetailRes.setTenantId(publishVo.getTenantId()); + commentDetailRes.setCommunityId(publishVo.getCommunityId()); + commentDetailRes.setPublishId(publishVo.getId()); + + List commentList = publishCommentService.getComment(commentDetailRes).getData(); + PublishLikeRes publishLikeRes = new PublishLikeRes(publishVo.getTenantId(), publishVo.getCommunityId(), publishVo.getId()); PublishLike publishLike = publishLikeMapper.selectPublishLike(publishLikeRes, SecurityUtils.getUserId()); if (Objects.nonNull(publishLike)) { - publishVo.setIsLike(1); + String delFlag = publishLike.getDelFlag(); + if ("0".equals(delFlag)) { + publishVo.setIsLike(1); + } else { + publishVo.setIsLike(0); + } } else { publishVo.setIsLike(0); } @@ -234,11 +244,18 @@ public class PublishServiceImpl extends ServiceImpl impl PublishCollectRes publishCollectRes = new PublishCollectRes(publishVo.getTenantId(), publishVo.getCommunityId(), publishVo.getId()); PublishCollect publishCollect = publishCollectService.getPublishCollect(publishCollectRes, SecurityUtils.getUserId()); if (Objects.nonNull(publishCollect)) { - publishVo.setIsCollect(1); + String delFlag = publishCollect.getDelFlag(); + if ("0".equals(delFlag)) { + publishVo.setIsCollect(1); + } else { + publishVo.setIsCollect(0); + } } else { publishVo.setIsCollect(0); } + + publishVo.setCommentList(commentList); } @@ -266,7 +283,7 @@ public class PublishServiceImpl extends ServiceImpl impl CommentDetailRes commentDetailRes = new CommentDetailRes(); commentDetailRes.setTenantId(myPublishPageRes.getTenantId()); commentDetailRes.setCommunityId(myPublishPageRes.getCommunityId()); - commentDetailRes.setOperatorId(publishVo.getId()); + commentDetailRes.setPublishId(publishVo.getId()); List commentVoList = publishCommentService.getComment(commentDetailRes).getData(); personHomeVo.setCommentList(commentVoList); @@ -326,7 +343,7 @@ public class PublishServiceImpl extends ServiceImpl impl communityAdvice.setTenantId(publish.getTenantId()); communityAdvice.setCommunityId(publish.getCommunityId()); communityAdvice.setSendUserId(SecurityUtils.getUserId()); - communityAdvice.setAdviceType(AdviceConstant.COMMUNITY_NOTICE); + communityAdvice.setAdviceType(AdviceConstant.LIKE); communityAdvice.setUserId(publish.getUserId()); communityAdvice.setContent(StringUtils.format("{}收藏了你发布的{}", SecurityUtils.getLoginUser().getUser().getNickName(), publish.getContent())); @@ -347,6 +364,39 @@ public class PublishServiceImpl extends ServiceImpl impl } } + @Override + public void reportPublish(PublishReportRes publishReportRes) { + Long tenantId = publishReportRes.getTenantId(); + Long communityId = publishReportRes.getCommunityId(); + Long publishId = publishReportRes.getPublishId(); + + CommunityUser communityUser = communityUserMapper.selectCommunityUser(tenantId, communityId, SecurityUtils.getUserId()); + if (Objects.isNull(communityUser)) { + throw new ServiceException("您不是该社区成员", HttpStatus.SHOW_ERROR_MSG); + } + + if ("1".equals(communityUser.getIsBlack())) { + throw new ServiceException("您已被拉黑", HttpStatus.SHOW_ERROR_MSG); + } + + Publish publish = publishMapper.selectByIdAndTenantIdAndCommunityId(publishId, tenantId, communityId); + + if (Objects.isNull(publish)) { + throw new ServiceException("该内容不存在", HttpStatus.SHOW_ERROR_MSG); + } + + PublishReport publishReport = BeanUtil.toBean(publishReportRes, PublishReport.class); + publishReport.setUserId(SecurityUtils.getUserId()); + + publishReportMapper.insertReport(publishReport); + + } + + @Override + public Publish getLastPublish(Long tenantId, Long communityId) { + return baseMapper.getLastPublish(tenantId, communityId); + } + private Page initPage(PageDomain pageDomain) { return new Page<>(pageDomain.getPageNum(), pageDomain.getPageSize()); } diff --git a/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/service/impl/QuestionCommentServiceImpl.java b/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/service/impl/QuestionCommentServiceImpl.java index f4e1b97..c4de4f8 100644 --- a/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/service/impl/QuestionCommentServiceImpl.java +++ b/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/service/impl/QuestionCommentServiceImpl.java @@ -26,6 +26,7 @@ import org.springframework.transaction.annotation.Transactional; import java.math.BigDecimal; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.Objects; @@ -74,7 +75,7 @@ public class QuestionCommentServiceImpl extends ServiceImpl getComment(QuestionDetailRes questionDetailRes) { + + return baseMapper.getComment(questionDetailRes); + } private Page initPage(QuestionCommentPageRes questionCommentPageRes) { diff --git a/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/service/impl/QuestionServiceImpl.java b/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/service/impl/QuestionServiceImpl.java index 323b740..de6d090 100644 --- a/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/service/impl/QuestionServiceImpl.java +++ b/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/service/impl/QuestionServiceImpl.java @@ -26,6 +26,7 @@ import com.mcwl.communityCenter.service.QuestionCommentService; import com.mcwl.communityCenter.service.QuestionService; import com.mcwl.system.service.ISysUserService; import lombok.RequiredArgsConstructor; +import org.springframework.context.annotation.Bean; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -101,15 +102,15 @@ public class QuestionServiceImpl extends ServiceImpl i sysUserService.updateUser(sysUser); - CommunityAdvice communityAdvice = new CommunityAdvice(); - communityAdvice.setTenantId(tenantId); - communityAdvice.setCommunityId(communityId); - communityAdvice.setSendUserId(SecurityUtils.getUserId()); - communityAdvice.setAdviceType(AdviceConstant.WAIT_ME_ANSWER); - communityAdvice.setUserId(questionUserId); - communityAdvice.setTitle(StringUtils.format("{}向你提问:", SecurityUtils.getLoginUser().getUser().getNickName())); - communityAdvice.setContent(questionRes.getContent()); - communityAdviceMapper.insert(communityAdvice); +// CommunityAdvice communityAdvice = new CommunityAdvice(); +// communityAdvice.setTenantId(tenantId); +// communityAdvice.setCommunityId(communityId); +// communityAdvice.setSendUserId(SecurityUtils.getUserId()); +// communityAdvice.setAdviceType(AdviceConstant.WAIT_ME_ANSWER); +// communityAdvice.setUserId(questionUserId); +// communityAdvice.setTitle(StringUtils.format("{}向你提问:", SecurityUtils.getLoginUser().getUser().getNickName())); +// communityAdvice.setContent(questionRes.getContent()); +// communityAdviceMapper.insert(communityAdvice); return R.ok(); @@ -121,22 +122,17 @@ public class QuestionServiceImpl extends ServiceImpl i Page page = initPage(questionPageRes); -// baseMapper.list(page, questionPageRes.getTenantId(), questionPageRes.getCommunityId(), questionPageRes.getStatus()); - baseMapper.list(page, questionPageRes.getTenantId(), questionPageRes.getCommunityId()); + List questionVoList = baseMapper.list(page, questionPageRes.getTenantId(), questionPageRes.getCommunityId()); + for (QuestionVo questionVo : questionVoList) { - // 获取分页数据 - List questionList = page.getRecords(); - // Question数据转为QuestionVo - List questionVoList = new ArrayList<>(); - for (Question question : questionList) { - QuestionVo questionVo = new QuestionVo(); - BeanUtil.copyProperties(question, questionVo); - Long questionUserId = question.getQuestionUserId(); - SysUser sysUser = sysUserService.selectUserById(questionUserId); - questionVo.setQuestionUserName(sysUser.getNickName()); - questionVo.setQuestionUserAvatar(sysUser.getAvatar()); - questionVoList.add(questionVo); + QuestionDetailRes questionDetailRes = new QuestionDetailRes(); + questionDetailRes.setTenantId(questionVo.getTenantId()); + questionDetailRes.setCommunityId(questionVo.getCommunityId()); + questionDetailRes.setQuestionId(questionVo.getId()); + List commentList = questionCommentService.getComment(questionDetailRes); + + questionVo.setCommentList(commentList); } // 封装分页信息 @@ -237,34 +233,34 @@ public class QuestionServiceImpl extends ServiceImpl i @Override public TableDataInfo myQuestionList(QuestionPageRes questionPageRes) { Page page = initPage(questionPageRes); - List questionList = baseMapper.myQuestionList(page, questionPageRes, SecurityUtils.getUserId()); + List questionList = baseMapper.myQuestionList(page, questionPageRes, SecurityUtils.getUserId()); List personHomeVoList = new ArrayList<>(); - for (Question question : questionList) { - PersonHomeVo personHomeVo = BeanUtil.toBean(question, PersonHomeVo.class); - personHomeVo.setImageUrl(question.getQuestionUrl()); + for (QuestionVo questionVo : questionList) { + PersonHomeVo personHomeVo = BeanUtil.toBean(questionVo, PersonHomeVo.class); - List commentList = new ArrayList<>(); - QuestionCommentPageRes questionCommentPageRes = new QuestionCommentPageRes(); - questionCommentPageRes.setTenantId(questionPageRes.getTenantId()); - questionCommentPageRes.setCommunityId(questionPageRes.getCommunityId()); - questionCommentPageRes.setQuestionId(question.getId()); - questionCommentPageRes.setPageNum(1); - questionCommentPageRes.setPageSize(10); + Long questionUserId = questionVo.getQuestionUserId(); + String questionUserName = questionVo.getQuestionUserName(); + String questionUserAvatar = questionVo.getQuestionUserAvatar(); + String questionUrl = questionVo.getQuestionUrl(); + + personHomeVo.setUserId(questionUserId); + personHomeVo.setUserName(questionUserName); + personHomeVo.setAvatar(questionUserAvatar); + personHomeVo.setImageUrl(questionUrl); + + + List questionCommentList = questionVo.getCommentList(); + + List commentList = BeanUtil.copyToList(questionCommentList, CommentVo.class); - TableDataInfo tableDataInfo = questionCommentService.listByPage(questionCommentPageRes); - List questionCommentList = (List) tableDataInfo.getRows(); - for (QuestionCommentVo questionCommentVo : questionCommentList) { - CommentVo commentVo = BeanUtil.toBean(questionCommentVo, CommentVo.class); - SysUser sysUser = sysUserService.selectUserById(questionCommentVo.getUserId()); - commentVo.setUserName(sysUser.getNickName()); - commentVo.setUserAvatar(sysUser.getAvatar()); - commentList.add(commentVo); - } personHomeVo.setCommentList(commentList); + personHomeVoList.add(personHomeVo); + } + // 封装分页信息 TableDataInfo rspData = new TableDataInfo(); rspData.setCode(HttpStatus.SUCCESS); diff --git a/mcwl-communityCenter/src/main/resources/mapper/communityCenter/CommunityMapper.xml b/mcwl-communityCenter/src/main/resources/mapper/communityCenter/CommunityMapper.xml index fb55a9a..34469a7 100644 --- a/mcwl-communityCenter/src/main/resources/mapper/communityCenter/CommunityMapper.xml +++ b/mcwl-communityCenter/src/main/resources/mapper/communityCenter/CommunityMapper.xml @@ -91,19 +91,7 @@ + \ No newline at end of file diff --git a/mcwl-communityCenter/src/main/resources/mapper/communityCenter/CommunityUserMapper.xml b/mcwl-communityCenter/src/main/resources/mapper/communityCenter/CommunityUserMapper.xml index 7ea994f..bc3f3e6 100644 --- a/mcwl-communityCenter/src/main/resources/mapper/communityCenter/CommunityUserMapper.xml +++ b/mcwl-communityCenter/src/main/resources/mapper/communityCenter/CommunityUserMapper.xml @@ -123,4 +123,25 @@ and ((CONVERT_TZ(NOW(), 'SYSTEM', '+08:00') >= start_time AND CONVERT_TZ(NOW(), 'SYSTEM', '+08:00') <= end_time) or (start_time is null and end_time is null)) + + \ No newline at end of file diff --git a/mcwl-communityCenter/src/main/resources/mapper/communityCenter/PublishCollectMapper.xml b/mcwl-communityCenter/src/main/resources/mapper/communityCenter/PublishCollectMapper.xml index 118c2b6..aa7cf4d 100644 --- a/mcwl-communityCenter/src/main/resources/mapper/communityCenter/PublishCollectMapper.xml +++ b/mcwl-communityCenter/src/main/resources/mapper/communityCenter/PublishCollectMapper.xml @@ -17,11 +17,17 @@ + \ No newline at end of file diff --git a/mcwl-communityCenter/src/main/resources/mapper/communityCenter/PublishCommentMapper.xml b/mcwl-communityCenter/src/main/resources/mapper/communityCenter/PublishCommentMapper.xml index cc9760d..9690d00 100644 --- a/mcwl-communityCenter/src/main/resources/mapper/communityCenter/PublishCommentMapper.xml +++ b/mcwl-communityCenter/src/main/resources/mapper/communityCenter/PublishCommentMapper.xml @@ -5,13 +5,34 @@ update cc_publish_comment set del_flag = '2' - where tenant_id = #{tenantId} + where id = #{id} + and tenant_id = #{tenantId} and community_id = #{communityId} - and publish_id = #{operatorId} - and type = 0 + and publish_id = #{publishId} - + + + - \ No newline at end of file diff --git a/mcwl-communityCenter/src/main/resources/mapper/communityCenter/PublishMapper.xml b/mcwl-communityCenter/src/main/resources/mapper/communityCenter/PublishMapper.xml index bbbf475..064e63b 100644 --- a/mcwl-communityCenter/src/main/resources/mapper/communityCenter/PublishMapper.xml +++ b/mcwl-communityCenter/src/main/resources/mapper/communityCenter/PublishMapper.xml @@ -96,30 +96,42 @@ and del_flag = '0' and file_url is not null - + select p.*, u.nick_name as user_name, u.avatar + from cc_publish p + left join sys_user u on p.user_id = u.user_id + left join cc_publish_like pl on pl.tenant_id = p.tenant_id and pl.community_id = p.community_id and p.id = + pl.publish_id + left join cc_publish_collect pc on p.id = pc.publish_id and p.tenant_id = pc.tenant_id and + p.community_id = pc.community_id - and tenant_id = #{publishPageRes.tenantId} - and community_id = #{publishPageRes.communityId} - and del_flag = '0' + and p.tenant_id = #{publishPageRes.tenantId} + and p.community_id = #{publishPageRes.communityId} + and p.del_flag = '0' - and user_id = #{publishPageRes.tenantId} + and p.user_id = #{publishPageRes.tenantId} - and is_elite = 1 + and p.is_elite = 1 - order by create_time desc + order by p.create_time desc + \ No newline at end of file diff --git a/mcwl-communityCenter/src/main/resources/mapper/communityCenter/PublishReportMapper.xml b/mcwl-communityCenter/src/main/resources/mapper/communityCenter/PublishReportMapper.xml new file mode 100644 index 0000000..0959699 --- /dev/null +++ b/mcwl-communityCenter/src/main/resources/mapper/communityCenter/PublishReportMapper.xml @@ -0,0 +1,12 @@ + + + + + + INSERT INTO cc_report(tenant_id, community_id, publish_id, user_id, report_type, content) + VALUES (#{publishReport.tenantId}, #{publishReport.communityId}, #{publishReport.publishId}, + #{publishReport.userId}, #{publishReport.reportType}, #{publishReport.content}) + + \ No newline at end of file diff --git a/mcwl-communityCenter/src/main/resources/mapper/communityCenter/QuestionCommentMapper.xml b/mcwl-communityCenter/src/main/resources/mapper/communityCenter/QuestionCommentMapper.xml index 855ef92..e3e5bdb 100644 --- a/mcwl-communityCenter/src/main/resources/mapper/communityCenter/QuestionCommentMapper.xml +++ b/mcwl-communityCenter/src/main/resources/mapper/communityCenter/QuestionCommentMapper.xml @@ -25,4 +25,14 @@ and question_id = #{questionId} and del_flag = '0' + \ No newline at end of file diff --git a/mcwl-communityCenter/src/main/resources/mapper/communityCenter/QuestionMapper.xml b/mcwl-communityCenter/src/main/resources/mapper/communityCenter/QuestionMapper.xml index 536ed0b..c8752e1 100644 --- a/mcwl-communityCenter/src/main/resources/mapper/communityCenter/QuestionMapper.xml +++ b/mcwl-communityCenter/src/main/resources/mapper/communityCenter/QuestionMapper.xml @@ -5,34 +5,16 @@ - + select q.*, u.nick_name as questionUserName, u.avatar as questionUserAvatar + from cc_question q left join sys_user u on q.question_user_id = u.user_id + where q.del_flag = '0' and tenant_id = #{tenantId} and community_id = #{communityId} - order by amount desc, create_time desc + order by q.create_time desc, amount desc - + select q.*, u.nick_name as questionUserName, u.avatar as questionUserAvatar + from cc_question q + left join sys_user u on q.question_user_id = u.user_id + where q.del_flag = '0' and tenant_id = #{questionPageRes.tenantId} and community_id = #{questionPageRes.communityId} and question_user_id = #{userId} diff --git a/mcwl-pay/src/main/java/com/mcwl/pay/service/impl/AliPayServiceImpl.java b/mcwl-pay/src/main/java/com/mcwl/pay/service/impl/AliPayServiceImpl.java index 57ef6b5..e8b4324 100644 --- a/mcwl-pay/src/main/java/com/mcwl/pay/service/impl/AliPayServiceImpl.java +++ b/mcwl-pay/src/main/java/com/mcwl/pay/service/impl/AliPayServiceImpl.java @@ -153,7 +153,6 @@ public class AliPayServiceImpl implements AliPayService { //调用支付宝的接口 AlipayTradePrecreateResponse payResponse = Factory.Payment.FaceToFace() - // 设置过期时间 .preCreate(memberLevel.getMemberName(), tradeEntity.getCode(), orderTradeDto.getAmount().toString()); @@ -161,7 +160,6 @@ public class AliPayServiceImpl implements AliPayService { if (Objects.nonNull(orderTradeDto.getPromotionId())) { redisCache.setCacheObject(tradeEntity.getCode() + "_promotionId", orderTradeDto.getPromotionId(), 15, TimeUnit.MINUTES); } -// AlipayTradePrecreateResponse payResponse = Factory.Payment.FaceToFace().preCreate("订单主题:Mac笔记本", "LS123qwe123", "19999"); //参照官方文档响应示例,解析返回结果 String httpBodyStr = payResponse.getHttpBody(); JSONObject jsonObject = JSONObject.parseObject(httpBodyStr); diff --git a/mcwl-pay/src/main/java/com/mcwl/pay/task/PayTask.java b/mcwl-pay/src/main/java/com/mcwl/pay/task/PayTask.java index 6f84b73..ecca6b3 100644 --- a/mcwl-pay/src/main/java/com/mcwl/pay/task/PayTask.java +++ b/mcwl-pay/src/main/java/com/mcwl/pay/task/PayTask.java @@ -26,6 +26,8 @@ public class PayTask { List orderTradeList = orderTradeService.lambdaQuery() .le(OrderTrade::getCreateTime, date) .and(wrapper -> wrapper + .eq(OrderTrade::getOrderStatus, 1) + .or() .eq(OrderTrade::getOrderStatus, 4) .or() .eq(OrderTrade::getPayStatus, 1) diff --git a/mcwl-system/src/main/java/com/mcwl/system/mapper/SysUserMapper.java b/mcwl-system/src/main/java/com/mcwl/system/mapper/SysUserMapper.java index 93baaa8..a9a026f 100644 --- a/mcwl-system/src/main/java/com/mcwl/system/mapper/SysUserMapper.java +++ b/mcwl-system/src/main/java/com/mcwl/system/mapper/SysUserMapper.java @@ -3,6 +3,7 @@ package com.mcwl.system.mapper; import com.mcwl.common.core.domain.entity.SysUser; import org.apache.ibatis.annotations.Param; +import java.util.Collection; import java.util.List; /** @@ -149,4 +150,6 @@ public interface SysUserMapper Integer getMonthUserCount(); List selectAllList(); + + List selectUserByIds(@Param("userIds") Collection userIds); } diff --git a/mcwl-system/src/main/java/com/mcwl/system/service/ISysUserService.java b/mcwl-system/src/main/java/com/mcwl/system/service/ISysUserService.java index 1e60934..be488c4 100644 --- a/mcwl-system/src/main/java/com/mcwl/system/service/ISysUserService.java +++ b/mcwl-system/src/main/java/com/mcwl/system/service/ISysUserService.java @@ -4,6 +4,7 @@ import com.mcwl.common.core.domain.AjaxResult; import com.mcwl.common.core.domain.entity.SysUser; import com.mcwl.system.domain.vo.UserDataVo; +import java.util.Collection; import java.util.List; /** @@ -53,6 +54,14 @@ public interface ISysUserService */ public SysUser selectUserById(Long userId); + /** + * 通过用户ID集合查询用户 + * + * @param userIds 用户ID + * @return 用户对象信息 + */ + public List selectUserByIds(Collection userIds); + /** * 根据用户ID查询用户所属角色组 * diff --git a/mcwl-system/src/main/java/com/mcwl/system/service/impl/SysUserServiceImpl.java b/mcwl-system/src/main/java/com/mcwl/system/service/impl/SysUserServiceImpl.java index a8ad1e5..1f77212 100644 --- a/mcwl-system/src/main/java/com/mcwl/system/service/impl/SysUserServiceImpl.java +++ b/mcwl-system/src/main/java/com/mcwl/system/service/impl/SysUserServiceImpl.java @@ -38,6 +38,7 @@ import org.springframework.util.CollectionUtils; import javax.validation.Validator; import java.security.SecureRandom; import java.util.ArrayList; +import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.concurrent.TimeUnit; @@ -160,6 +161,20 @@ public class SysUserServiceImpl implements ISysUserService return userMapper.selectUserById(userId); } + /** + * 通过用户ID集合查询用户 + * + * @param userIds 用户ID + * @return 用户对象信息 + */ + @Override + public List selectUserByIds(Collection userIds) { + if (userIds == null || userIds.isEmpty()) { + return Collections.emptyList(); + } + return userMapper.selectUserByIds(userIds); + } + /** * 查询用户所属角色组 * diff --git a/mcwl-system/src/main/resources/mapper/system/SysUserMapper.xml b/mcwl-system/src/main/resources/mapper/system/SysUserMapper.xml index be71c4f..fa20466 100644 --- a/mcwl-system/src/main/resources/mapper/system/SysUserMapper.xml +++ b/mcwl-system/src/main/resources/mapper/system/SysUserMapper.xml @@ -196,8 +196,15 @@ from sys_user where del_flag = '0' + - + insert into sys_user( user_id, dept_id,