Commit 1f257b91 by 段启岩

问答锁定

parent 4d531cdf
......@@ -179,7 +179,8 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
//1.判断自己是否发布过此问题
QueryWrapper<Question> questionQueryWrapper = new QueryWrapper<>();
questionQueryWrapper.eq("question_id", questionId)
.eq("user_id", userId);
.eq("user_id", userId)
.eq("status", 0);
Question question = getOne(questionQueryWrapper);
if (null == question) {
throw new QuestionServiceException(QuestionErrorCode.QUESTION_NOT_FOUND);
......@@ -221,7 +222,8 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
//1.判断自己是否发布过此问题
QueryWrapper<Question> questionQueryWrapper = new QueryWrapper<>();
questionQueryWrapper.eq("question_id", question.getQuestionId())
.eq("user_id", question.getUserId());
.eq("user_id", question.getUserId())
.eq("status", 0);
Question questionInDb = getOne(questionQueryWrapper);
if (null == questionInDb) {
throw new QuestionServiceException(QuestionErrorCode.QUESTION_NOT_FOUND);
......@@ -267,7 +269,11 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
@Override
public QuestionDetailDTO getQuestionDetail(String questionId, Subject subject) throws QuestionServiceException, QuestionTagServiceException {
//1.获取问题基本信息
Question question = getById(questionId);
QueryWrapper<Question> questionQueryWrapper = new QueryWrapper<>();
questionQueryWrapper.eq("question_id", questionId);
questionQueryWrapper.eq("status", 0);
Question question = getOne(questionQueryWrapper);
//2.判断是否存在此问题
if (null == question) {
......@@ -329,6 +335,7 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
IPage<Question> page = new Page<>(pageNumber, pageSize);
QueryWrapper<Question> questionQueryWrapper = new QueryWrapper<>();
questionQueryWrapper.orderByDesc("q.create_time");
questionQueryWrapper.eq("q.status", 0);
if (null != categoryId) {
questionQueryWrapper.eq("q.category_id", categoryId);
}
......@@ -339,7 +346,9 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
public IPage<Question> getUserQuestionPage(Integer pageNumber, Integer pageSize, String userId) {
IPage<Question> page = new Page<>(pageNumber, pageSize);
QueryWrapper<Question> questionQueryWrapper = new QueryWrapper<>();
questionQueryWrapper.eq("q.user_id", userId)
questionQueryWrapper
.eq("q.user_id", userId)
.eq("q.status", 0)
.orderByDesc("q.create_time");
return questionMapper.selectPageWithTags(page, questionQueryWrapper);
}
......@@ -367,6 +376,7 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
public IPage<Question> getHotsQuestionsPage(Integer pageNumber, Integer pageSize) {
IPage<Question> page = new Page<>(pageNumber, pageSize);
QueryWrapper<Question> questionQueryWrapper = new QueryWrapper<>();
questionQueryWrapper.eq("q.status", 0);
questionQueryWrapper.orderByDesc("q.view_number");
return questionMapper.selectPageWithTags(page, questionQueryWrapper);
}
......
......@@ -59,7 +59,10 @@ public class QuestionTagServiceImpl extends ServiceImpl<QuestionTagMapper, Quest
@Override
public List<Tag> getQuestionTags(String questionId) throws QuestionTagServiceException {
//1.获取问题信息
Question question = questionService.getById(questionId);
QueryWrapper<Question> questionQueryWrapper = new QueryWrapper<>();
questionQueryWrapper.eq("question_id", questionId);
questionQueryWrapper.eq("status", 0);
Question question = questionService.getOne(questionQueryWrapper);
//判断该问题是否存在
if (null == question) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment