Skip to content

Commit 714a597

Browse files
committed
feat(SubjectsController): add type parameter to subject relations endpoint
1 parent 90db4ca commit 714a597

5 files changed

Lines changed: 7 additions & 7 deletions

File tree

flow-client/src/main/java/com/ligg/flowclient/controller/bangumi/SubjectsController.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,9 +217,10 @@ public Result<SubjectCommentsVo> subjectComments(
217217
@GetMapping("/{subjectId}/relations")
218218
public Result<SubjectRelationsVo> subjectRelationsLocal(
219219
@NotNull @PathVariable int subjectId,
220+
@RequestParam(defaultValue = "2") int type,
220221
@RequestParam(defaultValue = "20") int limit,
221222
@RequestParam(defaultValue = "0") int offset) {
222-
SubjectRelationsVo vo = bangumiService.getRelatedSubjects(subjectId, limit, offset);
223+
SubjectRelationsVo vo = bangumiService.getRelatedSubjects(subjectId, limit, offset, type);
223224
if (vo.getData() != null) {
224225
for (SubjectRelationsVo.Item item : vo.getData()) {
225226
if (item != null && item.getSubject() != null) {

flow-client/src/main/java/com/ligg/flowclient/mapper/BangumiSubjectMapper.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,5 @@ List<SearchSuggestionRow> selectSearchSuggestions(@Param("keyword") String keywo
1717
@Param("type") int type,
1818
@Param("limit") int limit);
1919

20-
IPage<SubjectRelationRow> selectRelatedSubjects(IPage<?> page, @Param("subjectId") Integer subjectId);
21-
20+
IPage<SubjectRelationRow> selectRelatedSubjects(IPage<?> page, @Param("subjectId") Integer subjectId ,@Param("type") Integer type);
2221
}

flow-client/src/main/java/com/ligg/flowclient/service/BangumiService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,5 @@ public interface BangumiService {
2828
/**
2929
* 获取关联条目
3030
*/
31-
SubjectRelationsVo getRelatedSubjects(Integer subjectId, int limit, int offset);
31+
SubjectRelationsVo getRelatedSubjects(Integer subjectId, int limit, int offset,int type);
3232
}

flow-client/src/main/java/com/ligg/flowclient/service/impl/BangumiServiceImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ public SubjectsDto searchSubjects(SearchSubjectsBody body, int limit, int offset
158158
* 获取关联条目。
159159
*/
160160
@Override
161-
public SubjectRelationsVo getRelatedSubjects(Integer subjectId, int limit, int offset) {
161+
public SubjectRelationsVo getRelatedSubjects(Integer subjectId, int limit, int offset, int type) {
162162
SubjectRelationsVo vo = new SubjectRelationsVo();
163163
if (subjectId == null || limit <= 0) {
164164
vo.setData(Collections.emptyList());
@@ -167,7 +167,7 @@ public SubjectRelationsVo getRelatedSubjects(Integer subjectId, int limit, int o
167167
}
168168

169169
IPage<SubjectRelationRow> page = subjectMapper.selectRelatedSubjects(
170-
new LimitOffsetPage<>(limit, offset), subjectId);
170+
new LimitOffsetPage<>(limit, offset), subjectId, type);
171171

172172
List<SubjectRelationRow> rows = page.getRecords();
173173
if (rows == null || rows.isEmpty()) {

flow-client/src/main/resources/mapper/BangumiSubjectMapper.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
s.images
4545
FROM bangumi_subject_relation r
4646
JOIN bangumi_subject s ON r.related_subject_id = s.id
47-
WHERE r.subject_id = #{subjectId}
47+
WHERE r.subject_id = #{subjectId} and s.type = #{type}
4848
ORDER BY r.`order`, r.related_subject_id
4949
</select>
5050

0 commit comments

Comments
 (0)