|
@@ -48,7 +48,7 @@ public class QuestionSubmitServiceImpl extends ServiceImpl<QuestionSubmitMapper,
|
|
|
* 提交题目
|
|
|
*
|
|
|
* @param questionSubmitAddRequest
|
|
|
- * @param loginUser
|
|
|
+ * @param loginUserId
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
@@ -110,37 +110,36 @@ public class QuestionSubmitServiceImpl extends ServiceImpl<QuestionSubmitMapper,
|
|
|
|
|
|
// 拼接查询条件
|
|
|
queryWrapper.eq(StringUtils.isNotBlank(language), "language", language);
|
|
|
- queryWrapper.eq(ObjectUtils.isNotEmpty(userId), "userId", userId);
|
|
|
- queryWrapper.eq(ObjectUtils.isNotEmpty(questionId), "questionId", questionId);
|
|
|
+ queryWrapper.eq(ObjectUtils.isNotEmpty(userId), "user_id", userId);
|
|
|
+ queryWrapper.eq(ObjectUtils.isNotEmpty(questionId), "question_id", questionId);
|
|
|
queryWrapper.eq(QuestionSubmitStatusEnum.getEnumByValue(status) != null, "status", status);
|
|
|
- queryWrapper.eq("isDelete", false);
|
|
|
+ queryWrapper.eq("is_delete", 0);
|
|
|
queryWrapper.orderBy(SqlUtils.validSortField(sortField), sortOrder.equals(CommonConstant.SORT_ORDER_ASC),
|
|
|
sortField);
|
|
|
return queryWrapper;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public QuestionSubmitVO getQuestionSubmitVO(QuestionSubmit questionSubmit, User loginUser) {
|
|
|
+ public QuestionSubmitVO getQuestionSubmitVO(QuestionSubmit questionSubmit, Long userId) {
|
|
|
QuestionSubmitVO questionSubmitVO = QuestionSubmitVO.objToVo(questionSubmit);
|
|
|
// 脱敏:仅本人和管理员能看见自己(提交 userId 和登录用户 id 不同)提交的代码
|
|
|
- long userId = loginUser.getId();
|
|
|
- // 处理脱敏
|
|
|
- //TODO && !userService.isAdmin(loginUser)
|
|
|
- if (userId != questionSubmit.getUserId() ) {
|
|
|
+
|
|
|
+ //TODO 处理脱敏 DONE
|
|
|
+ if (userId != questionSubmit.getUserId() && !userService.isAdmin(userId)) {
|
|
|
questionSubmitVO.setCode(null);
|
|
|
}
|
|
|
return questionSubmitVO;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Page<QuestionSubmitVO> getQuestionSubmitVOPage(Page<QuestionSubmit> questionSubmitPage, User loginUser) {
|
|
|
+ public Page<QuestionSubmitVO> getQuestionSubmitVOPage(Page<QuestionSubmit> questionSubmitPage, Long loginUserId) {
|
|
|
List<QuestionSubmit> questionSubmitList = questionSubmitPage.getRecords();
|
|
|
Page<QuestionSubmitVO> questionSubmitVOPage = new Page<>(questionSubmitPage.getCurrent(), questionSubmitPage.getSize(), questionSubmitPage.getTotal());
|
|
|
if (CollectionUtils.isEmpty(questionSubmitList)) {
|
|
|
return questionSubmitVOPage;
|
|
|
}
|
|
|
List<QuestionSubmitVO> questionSubmitVOList = questionSubmitList.stream()
|
|
|
- .map(questionSubmit -> getQuestionSubmitVO(questionSubmit, loginUser))
|
|
|
+ .map(questionSubmit -> getQuestionSubmitVO(questionSubmit, loginUserId))
|
|
|
.collect(Collectors.toList());
|
|
|
questionSubmitVOPage.setRecords(questionSubmitVOList);
|
|
|
return questionSubmitVOPage;
|