feat: 题目详情 上一题/下一题功能

This commit is contained in:
2024-03-08 16:47:13 +08:00
parent 9c93cf950d
commit 004fcf10bb
6 changed files with 45 additions and 0 deletions

View File

@@ -44,4 +44,5 @@ public interface SubjectInfoDomainService {
PageResult<SubjectInfoEs> getSubjectPageBySearch(SubjectInfoBO subjectInfoBO);
List<SubjectInfoBO> getContributeList();
}

View File

@@ -154,8 +154,22 @@ public class SubjectInfoDomainServiceImpl implements SubjectInfoDomainService {
bo.setLabelName(labelNameList);
bo.setLiked(subjectLikedDomainService.isLiked(subjectInfoBO.getId().toString(), LoginUtil.getLoginId()));
bo.setLikedCount(subjectLikedDomainService.getLikedCount(subjectInfoBO.getId().toString()));
assembleSubjectCursor(subjectInfoBO,bo);
return bo;
}
private void assembleSubjectCursor(SubjectInfoBO subjectInfoBO, SubjectInfoBO bo) {
Long categoryId = subjectInfoBO.getCategoryId();
Long labelId = subjectInfoBO.getLabelId();
Long subjectId = subjectInfoBO.getId();
if (Objects.isNull(categoryId) || Objects.isNull(labelId)) {
return;
}
Long nextSubjectId = subjectInfoService.querySubjectIdCursor(subjectId, categoryId, labelId, 1);
bo.setNextSubjectId(nextSubjectId);
Long lastSubjectId = subjectInfoService.querySubjectIdCursor(subjectId, categoryId, labelId, 0);
bo.setLastSubjectId(lastSubjectId);
}
@Override
public PageResult<SubjectInfoEs> getSubjectPageBySearch(SubjectInfoBO subjectInfoBO) {

View File

@@ -90,5 +90,10 @@ public interface SubjectInfoDao {
@Param("pageSize") Integer pageSize);
List<SubjectInfo> getContributeCount();
Long querySubjectIdCursor(@Param("subjectId") Long subjectId,
@Param("categoryId") Long categoryId,
@Param("labelId") Long labelId,
@Param("cursor") int cursor);
}

View File

@@ -50,4 +50,7 @@ public interface SubjectInfoService {
List<SubjectInfo> queryPage(SubjectInfo subjectInfo, Long categoryId, Long labelId, int start, Integer pageSize);
List<SubjectInfo> getContributeCount();
Long querySubjectIdCursor(Long subjectId, Long categoryId, Long labelId, int cursor);
}

View File

@@ -81,4 +81,9 @@ public class SubjectInfoServiceImpl implements SubjectInfoService {
public List<SubjectInfo> getContributeCount() {
return this.subjectInfoDao.getContributeCount();
}
@Override
public Long querySubjectIdCursor(Long subjectId, Long categoryId, Long labelId, int cursor) {
return this.subjectInfoDao.querySubjectIdCursor(subjectId, categoryId, labelId, cursor);
}
}

View File

@@ -140,6 +140,23 @@
and a.subject_type = #{subjectInfo.subjectType}
</if>
</select>
<select id="querySubjectIdCursor" resultType="java.lang.Long">
select a.id
from subject_info a,
subject_mapping b
where a.id = b.subject_id
and b.category_id = #{categoryId}
and b.label_id = #{labelId}
<if test="cursor !=null and cursor == 1">
and a.id > #{subjectId}
</if>
<if test="cursor !=null and cursor == 0">
and a.id &lt; #{subjectId}
</if>
limit 0,1
</select>
<select id="queryPage" resultMap="SubjectInfoMap">
select a.id,
a.subject_name,