Commit 1f257b91 by 段启岩

问答锁定

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