Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
beyond-clouds
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
4
Issues
4
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
段启岩
beyond-clouds
Commits
8b8b1bf9
Commit
8b8b1bf9
authored
Feb 02, 2020
by
胡学良
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
评论列表
parent
8328e4b2
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
75 additions
and
0 deletions
+75
-0
src/main/java/cn/meteor/beyondclouds/modules/question/api/QuestionReplyCommentApi.java
+30
-0
src/main/java/cn/meteor/beyondclouds/modules/question/service/IQuestionReplyCommentService.java
+13
-0
src/main/java/cn/meteor/beyondclouds/modules/question/service/impl/QuestionReplyCommentServiceImpl.java
+32
-0
No files found.
src/main/java/cn/meteor/beyondclouds/modules/question/api/QuestionReplyCommentApi.java
View file @
8b8b1bf9
package
cn
.
meteor
.
beyondclouds
.
modules
.
question
.
api
;
package
cn
.
meteor
.
beyondclouds
.
modules
.
question
.
api
;
import
cn.meteor.beyondclouds.common.form.PageForm
;
import
cn.meteor.beyondclouds.common.vo.PageVO
;
import
cn.meteor.beyondclouds.core.annotation.Anonymous
;
import
cn.meteor.beyondclouds.core.annotation.CurrentSubject
;
import
cn.meteor.beyondclouds.core.annotation.CurrentSubject
;
import
cn.meteor.beyondclouds.core.api.Response
;
import
cn.meteor.beyondclouds.core.api.Response
;
import
cn.meteor.beyondclouds.core.bean.Subject
;
import
cn.meteor.beyondclouds.core.bean.Subject
;
import
cn.meteor.beyondclouds.modules.question.entity.QuestionReplyComment
;
import
cn.meteor.beyondclouds.modules.question.exception.QuestionReplyCommentServiceException
;
import
cn.meteor.beyondclouds.modules.question.exception.QuestionReplyCommentServiceException
;
import
cn.meteor.beyondclouds.modules.question.form.QuestionReplyCommentForm
;
import
cn.meteor.beyondclouds.modules.question.form.QuestionReplyCommentForm
;
import
cn.meteor.beyondclouds.modules.question.service.IQuestionReplyCommentService
;
import
cn.meteor.beyondclouds.modules.question.service.IQuestionReplyCommentService
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -73,4 +78,29 @@ public class QuestionReplyCommentApi {
...
@@ -73,4 +78,29 @@ public class QuestionReplyCommentApi {
return
Response
.
error
(
e
);
return
Response
.
error
(
e
);
}
}
}
}
/**
* 评论列表
* @param replyId 回复ID
* @param pageForm 分页表单
* @param parentId 父评论ID
* @return 评论列表
*/
@Anonymous
@ApiOperation
(
"评论列表"
)
@GetMapping
(
"/question/reply/{replyId}/comments"
)
public
Response
<
PageVO
<
QuestionReplyComment
>>
getReplyComments
(
@PathVariable
(
"replyId"
)
String
replyId
,
@Valid
PageForm
pageForm
,
@RequestParam
(
value
=
"parentId"
,
required
=
false
)
String
parentId
)
{
try
{
IPage
<
QuestionReplyComment
>
replyCommentPage
=
questionReplyCommentService
.
getReplyCommentPage
(
pageForm
.
getPage
(),
pageForm
.
getSize
(),
replyId
,
parentId
);
PageVO
<
QuestionReplyComment
>
questionReplyCommentPageVO
=
new
PageVO
<>(
replyCommentPage
);
return
Response
.
success
(
questionReplyCommentPageVO
);
}
catch
(
QuestionReplyCommentServiceException
e
)
{
e
.
printStackTrace
();
return
Response
.
error
(
e
);
}
}
}
}
src/main/java/cn/meteor/beyondclouds/modules/question/service/IQuestionReplyCommentService.java
View file @
8b8b1bf9
...
@@ -2,7 +2,9 @@ package cn.meteor.beyondclouds.modules.question.service;
...
@@ -2,7 +2,9 @@ package cn.meteor.beyondclouds.modules.question.service;
import
cn.meteor.beyondclouds.modules.question.entity.QuestionReplyComment
;
import
cn.meteor.beyondclouds.modules.question.entity.QuestionReplyComment
;
import
cn.meteor.beyondclouds.modules.question.exception.QuestionReplyCommentServiceException
;
import
cn.meteor.beyondclouds.modules.question.exception.QuestionReplyCommentServiceException
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
io.swagger.models.auth.In
;
/**
/**
* <p>
* <p>
...
@@ -31,4 +33,15 @@ public interface IQuestionReplyCommentService extends IService<QuestionReplyComm
...
@@ -31,4 +33,15 @@ public interface IQuestionReplyCommentService extends IService<QuestionReplyComm
* @throws QuestionReplyCommentServiceException 问题回复评论业务异常
* @throws QuestionReplyCommentServiceException 问题回复评论业务异常
*/
*/
void
deleteReplyComment
(
String
userId
,
String
commentId
)
throws
QuestionReplyCommentServiceException
;
void
deleteReplyComment
(
String
userId
,
String
commentId
)
throws
QuestionReplyCommentServiceException
;
/**
* 评论列表
* @param pageNumber 页数
* @param pageSize 页面大小
* @param replyId 回复ID
* @param parentId 父评论ID
* @return 分页对象
* @throws QuestionReplyCommentServiceException
*/
IPage
<
QuestionReplyComment
>
getReplyCommentPage
(
Integer
pageNumber
,
Integer
pageSize
,
String
replyId
,
String
parentId
)
throws
QuestionReplyCommentServiceException
;
}
}
src/main/java/cn/meteor/beyondclouds/modules/question/service/impl/QuestionReplyCommentServiceImpl.java
View file @
8b8b1bf9
...
@@ -10,13 +10,18 @@ import cn.meteor.beyondclouds.modules.question.mapper.QuestionReplyCommentMapper
...
@@ -10,13 +10,18 @@ import cn.meteor.beyondclouds.modules.question.mapper.QuestionReplyCommentMapper
import
cn.meteor.beyondclouds.modules.question.service.IQuestionReplyCommentService
;
import
cn.meteor.beyondclouds.modules.question.service.IQuestionReplyCommentService
;
import
cn.meteor.beyondclouds.modules.question.service.IQuestionReplyService
;
import
cn.meteor.beyondclouds.modules.question.service.IQuestionReplyService
;
import
cn.meteor.beyondclouds.modules.question.service.IQuestionService
;
import
cn.meteor.beyondclouds.modules.question.service.IQuestionService
;
import
cn.meteor.beyondclouds.modules.question.util.QuestionUtils
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
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
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.util.Assert
;
import
org.springframework.util.Assert
;
import
org.springframework.util.StringUtils
;
import
org.springframework.util.StringUtils
;
import
java.nio.file.Watchable
;
/**
/**
* <p>
* <p>
* 问题回复评论表 服务实现类
* 问题回复评论表 服务实现类
...
@@ -121,4 +126,31 @@ public class QuestionReplyCommentServiceImpl extends ServiceImpl<QuestionReplyCo
...
@@ -121,4 +126,31 @@ public class QuestionReplyCommentServiceImpl extends ServiceImpl<QuestionReplyCo
questionReplyCommentQueryWrapper
.
like
(
"thread"
,
questionReplyComment
.
getThread
());
questionReplyCommentQueryWrapper
.
like
(
"thread"
,
questionReplyComment
.
getThread
());
remove
(
questionReplyCommentQueryWrapper
);
remove
(
questionReplyCommentQueryWrapper
);
}
}
@Override
public
IPage
<
QuestionReplyComment
>
getReplyCommentPage
(
Integer
pageNumber
,
Integer
pageSize
,
String
replyId
,
String
parentId
)
throws
QuestionReplyCommentServiceException
{
Assert
.
notNull
(
replyId
,
"replyId must not be null"
);
IPage
<
QuestionReplyComment
>
page
=
new
Page
<>(
pageNumber
,
pageSize
);
//如果parentId为空,则只获取一级评论
if
(
null
==
parentId
)
{
QueryWrapper
<
QuestionReplyComment
>
questionReplyCommentQueryWrapper
=
new
QueryWrapper
<>();
questionReplyCommentQueryWrapper
.
eq
(
"reply_id"
,
replyId
)
.
eq
(
"depth"
,
0
)
.
orderByDesc
(
"create_time"
);
return
page
(
page
,
questionReplyCommentQueryWrapper
);
}
//如果parentId不为null,则获取其子评论
//判断父评论是否存在
QuestionReplyComment
questionReplyComment
=
getById
(
parentId
);
if
(
null
==
questionReplyComment
)
{
throw
new
QuestionReplyCommentServiceException
(
QuestionReplyCommentErrorCode
.
PARENT_COMMENT_NOT_FOUND
);
}
return
page
(
page
,
QuestionUtils
.
getWrapper
(
"parent_id"
,
parentId
));
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment