Skip to content

Commit f2f6ab5

Browse files
authored
feat: scoreDesc endpoint. (#751)
* feat: scoreDesc endpoint. * feat: 条目条件查询接口实现评分降序逻辑 * docs: update CHANGELOG.MD * feat: add column 'score' in table 'subject', @see SubjectEntity * feat: add score in Subject.java * feat: subject collection score update event listener that update subject score. * build: gen new api-client v20.7.1 * feat: console展示条目详情页展示综合评分 * test: disable SubjectEndpointTest.list * test: disable SubjectRepositoryTest.update
1 parent 694a615 commit f2f6ab5

File tree

21 files changed

+205
-28
lines changed

21 files changed

+205
-28
lines changed

CHANGELOG.MD

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66

77
## 新特性
88

9-
- 新增Console条目收藏的评分和评论支持
9+
- 新增Console条目收藏的评分和评论支持 #747
10+
- 条目筛选需要添加按评分排序 最高评分 #749
11+
- console展示条目详情页展示综合评分
1012

1113
# 0.20.6
1214

api/src/main/java/run/ikaros/api/core/subject/Subject.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,8 @@ public class Subject {
3636
private Boolean nsfw;
3737
private LocalDateTime airTime;
3838
private String cover;
39+
/**
40+
* Subject score, from 0 to 10.
41+
*/
42+
private Double score;
3943
}

api/src/main/java/run/ikaros/api/core/subject/vo/FindSubjectCondition.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ public class FindSubjectCondition {
3030
* default is false.
3131
*/
3232
private Boolean updateTimeDesc;
33+
/**
34+
* default is null.
35+
*/
36+
private Boolean scoreDesc;
3337

3438
/**
3539
* init default if field value is null.

console/packages/api-client/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ npm publish
5858
选择当前目录下的更改进行`git add .`
5959

6060
```bash
61-
git commit -am "build: gen new api-client v20.7.0"
61+
git commit -am "build: gen new api-client v20.7.1"
6262
```
6363

6464
合成版(powershell),升级 package.json 版本,并启动服务端后,在 api-client 路径下:

console/packages/api-client/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@runikaros/api-client",
3-
"version": "20.7.0",
3+
"version": "20.7.1",
44
"description": "Project ikaros console api-client package",
55
"type": "module",
66
"scripts": {

console/packages/api-client/src/api/v1alpha1-collection-subject-api.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export const V1alpha1CollectionSubjectApiAxiosParamCreator = function (
5555
* @param {'WISH' | 'DOING' | 'DONE' | 'SHELVE' | 'DISCARD'} type Collection type.
5656
* @param {boolean} [isPrivate] Is private, default is false.
5757
* @param {string} [comment] Subject comment, with base64 encoded.
58-
* @param {number} [score] Subject score, from 0 to 100.
58+
* @param {number} [score] Subject score, from 0 to 10.
5959
* @param {*} [options] Override http request option.
6060
* @throws {RequiredError}
6161
*/
@@ -391,7 +391,7 @@ export const V1alpha1CollectionSubjectApiFp = function (
391391
* @param {'WISH' | 'DOING' | 'DONE' | 'SHELVE' | 'DISCARD'} type Collection type.
392392
* @param {boolean} [isPrivate] Is private, default is false.
393393
* @param {string} [comment] Subject comment, with base64 encoded.
394-
* @param {number} [score] Subject score, from 0 to 100.
394+
* @param {number} [score] Subject score, from 0 to 10.
395395
* @param {*} [options] Override http request option.
396396
* @throws {RequiredError}
397397
*/
@@ -670,7 +670,7 @@ export interface V1alpha1CollectionSubjectApiCollectSubjectRequest {
670670
readonly comment?: string;
671671

672672
/**
673-
* Subject score, from 0 to 100.
673+
* Subject score, from 0 to 10.
674674
* @type {number}
675675
* @memberof V1alpha1CollectionSubjectApiCollectSubject
676676
*/

console/packages/api-client/src/api/v1alpha1-indices-api.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -97,16 +97,16 @@ export const V1alpha1IndicesApiAxiosParamCreator = function (
9797
* Search subjects with fuzzy query
9898
* @param {string} keyword
9999
* @param {number} [limit]
100-
* @param {string} [highlightPostTag]
101100
* @param {string} [highlightPreTag]
101+
* @param {string} [highlightPostTag]
102102
* @param {*} [options] Override http request option.
103103
* @throws {RequiredError}
104104
*/
105105
searchSubject: async (
106106
keyword: string,
107107
limit?: number,
108-
highlightPostTag?: string,
109108
highlightPreTag?: string,
109+
highlightPostTag?: string,
110110
options: AxiosRequestConfig = {}
111111
): Promise<RequestArgs> => {
112112
// verify required parameter 'keyword' is not null or undefined
@@ -139,16 +139,16 @@ export const V1alpha1IndicesApiAxiosParamCreator = function (
139139
localVarQueryParameter["limit"] = limit;
140140
}
141141

142-
if (highlightPostTag !== undefined) {
143-
localVarQueryParameter["highlightPostTag"] = highlightPostTag;
142+
if (keyword !== undefined) {
143+
localVarQueryParameter["keyword"] = keyword;
144144
}
145145

146146
if (highlightPreTag !== undefined) {
147147
localVarQueryParameter["highlightPreTag"] = highlightPreTag;
148148
}
149149

150-
if (keyword !== undefined) {
151-
localVarQueryParameter["keyword"] = keyword;
150+
if (highlightPostTag !== undefined) {
151+
localVarQueryParameter["highlightPostTag"] = highlightPostTag;
152152
}
153153

154154
setSearchParams(localVarUrlObj, localVarQueryParameter);
@@ -199,25 +199,25 @@ export const V1alpha1IndicesApiFp = function (configuration?: Configuration) {
199199
* Search subjects with fuzzy query
200200
* @param {string} keyword
201201
* @param {number} [limit]
202-
* @param {string} [highlightPostTag]
203202
* @param {string} [highlightPreTag]
203+
* @param {string} [highlightPostTag]
204204
* @param {*} [options] Override http request option.
205205
* @throws {RequiredError}
206206
*/
207207
async searchSubject(
208208
keyword: string,
209209
limit?: number,
210-
highlightPostTag?: string,
211210
highlightPreTag?: string,
211+
highlightPostTag?: string,
212212
options?: AxiosRequestConfig
213213
): Promise<
214214
(axios?: AxiosInstance, basePath?: string) => AxiosPromise<SubjectHints>
215215
> {
216216
const localVarAxiosArgs = await localVarAxiosParamCreator.searchSubject(
217217
keyword,
218218
limit,
219-
highlightPostTag,
220219
highlightPreTag,
220+
highlightPostTag,
221221
options
222222
);
223223
return createRequestFunction(
@@ -265,8 +265,8 @@ export const V1alpha1IndicesApiFactory = function (
265265
.searchSubject(
266266
requestParameters.keyword,
267267
requestParameters.limit,
268-
requestParameters.highlightPostTag,
269268
requestParameters.highlightPreTag,
269+
requestParameters.highlightPostTag,
270270
options
271271
)
272272
.then((request) => request(axios, basePath));
@@ -299,14 +299,14 @@ export interface V1alpha1IndicesApiSearchSubjectRequest {
299299
* @type {string}
300300
* @memberof V1alpha1IndicesApiSearchSubject
301301
*/
302-
readonly highlightPostTag?: string;
302+
readonly highlightPreTag?: string;
303303

304304
/**
305305
*
306306
* @type {string}
307307
* @memberof V1alpha1IndicesApiSearchSubject
308308
*/
309-
readonly highlightPreTag?: string;
309+
readonly highlightPostTag?: string;
310310
}
311311

312312
/**
@@ -343,8 +343,8 @@ export class V1alpha1IndicesApi extends BaseAPI {
343343
.searchSubject(
344344
requestParameters.keyword,
345345
requestParameters.limit,
346-
requestParameters.highlightPostTag,
347346
requestParameters.highlightPreTag,
347+
requestParameters.highlightPostTag,
348348
options
349349
)
350350
.then((request) => request(this.axios, this.basePath));

console/packages/api-client/src/api/v1alpha1-subject-api.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ export const V1alpha1SubjectApiAxiosParamCreator = function (
170170
* @param {string} [time] 时间范围,格式范围类型: 2000.9-2010.8 或者 单个类型2020.8
171171
* @param {boolean} [airTimeDesc] 是否根据放送时间倒序,新番在列表前面。默认为 true.
172172
* @param {boolean} [updateTimeDesc] 是否根据更新时间倒序,默认为 true.
173+
* @param {boolean} [scoreDesc] 是否根据评分倒序,默认为空.
173174
* @param {*} [options] Override http request option.
174175
* @throws {RequiredError}
175176
*/
@@ -183,6 +184,7 @@ export const V1alpha1SubjectApiAxiosParamCreator = function (
183184
time?: string,
184185
airTimeDesc?: boolean,
185186
updateTimeDesc?: boolean,
187+
scoreDesc?: boolean,
186188
options: AxiosRequestConfig = {}
187189
): Promise<RequestArgs> => {
188190
const localVarPath = `/api/v1alpha1/subjects/condition`;
@@ -245,6 +247,10 @@ export const V1alpha1SubjectApiAxiosParamCreator = function (
245247
localVarQueryParameter["updateTimeDesc"] = updateTimeDesc;
246248
}
247249

250+
if (scoreDesc !== undefined) {
251+
localVarQueryParameter["scoreDesc"] = scoreDesc;
252+
}
253+
248254
setSearchParams(localVarUrlObj, localVarQueryParameter);
249255
let headersFromBaseOptions =
250256
baseOptions && baseOptions.headers ? baseOptions.headers : {};
@@ -491,6 +497,7 @@ export const V1alpha1SubjectApiFp = function (configuration?: Configuration) {
491497
* @param {string} [time] 时间范围,格式范围类型: 2000.9-2010.8 或者 单个类型2020.8
492498
* @param {boolean} [airTimeDesc] 是否根据放送时间倒序,新番在列表前面。默认为 true.
493499
* @param {boolean} [updateTimeDesc] 是否根据更新时间倒序,默认为 true.
500+
* @param {boolean} [scoreDesc] 是否根据评分倒序,默认为空.
494501
* @param {*} [options] Override http request option.
495502
* @throws {RequiredError}
496503
*/
@@ -504,6 +511,7 @@ export const V1alpha1SubjectApiFp = function (configuration?: Configuration) {
504511
time?: string,
505512
airTimeDesc?: boolean,
506513
updateTimeDesc?: boolean,
514+
scoreDesc?: boolean,
507515
options?: AxiosRequestConfig
508516
): Promise<
509517
(axios?: AxiosInstance, basePath?: string) => AxiosPromise<PagingWrap>
@@ -519,6 +527,7 @@ export const V1alpha1SubjectApiFp = function (configuration?: Configuration) {
519527
time,
520528
airTimeDesc,
521529
updateTimeDesc,
530+
scoreDesc,
522531
options
523532
);
524533
return createRequestFunction(
@@ -662,6 +671,7 @@ export const V1alpha1SubjectApiFactory = function (
662671
requestParameters.time,
663672
requestParameters.airTimeDesc,
664673
requestParameters.updateTimeDesc,
674+
requestParameters.scoreDesc,
665675
options
666676
)
667677
.then((request) => request(axios, basePath));
@@ -818,6 +828,13 @@ export interface V1alpha1SubjectApiListSubjectsByConditionRequest {
818828
* @memberof V1alpha1SubjectApiListSubjectsByCondition
819829
*/
820830
readonly updateTimeDesc?: boolean;
831+
832+
/**
833+
* 是否根据评分倒序,默认为空.
834+
* @type {boolean}
835+
* @memberof V1alpha1SubjectApiListSubjectsByCondition
836+
*/
837+
readonly scoreDesc?: boolean;
821838
}
822839

823840
/**
@@ -930,6 +947,7 @@ export class V1alpha1SubjectApi extends BaseAPI {
930947
requestParameters.time,
931948
requestParameters.airTimeDesc,
932949
requestParameters.updateTimeDesc,
950+
requestParameters.scoreDesc,
933951
options
934952
)
935953
.then((request) => request(this.axios, this.basePath));

console/packages/api-client/src/models/paging-wrap.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,17 @@ export interface PagingWrap {
4343
*/
4444
items: Array<object>;
4545
/**
46-
* Indicates whether current page is the first page.
46+
* Indicates whether current page is the last page.
4747
* @type {boolean}
4848
* @memberof PagingWrap
4949
*/
50-
firstPage: boolean;
50+
lastPage: boolean;
5151
/**
52-
* Indicates whether current page is the last page.
52+
* Indicates whether current page is the first page.
5353
* @type {boolean}
5454
* @memberof PagingWrap
5555
*/
56-
lastPage: boolean;
56+
firstPage: boolean;
5757
/**
5858
* Indicates whether current page has previous page.
5959
* @type {boolean}

console/packages/api-client/src/models/subject.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@ export interface Subject {
6666
* @memberof Subject
6767
*/
6868
cover?: string;
69+
/**
70+
*
71+
* @type {number}
72+
* @memberof Subject
73+
*/
74+
score?: number;
6975
/**
7076
*
7177
* @type {string}

console/src/modules/content/subject/SubjectDetails.vue

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -814,14 +814,28 @@ onMounted(fetchDatas);
814814
</el-descriptions-item>
815815
</el-descriptions>
816816
<el-descriptions
817-
v-if="subjectSyncs && subjectSyncs.length > 0"
818817
size="large"
818+
:column="2"
819819
border
820820
>
821821
<el-descriptions-item
822+
label="综合评分"
823+
>
824+
<span
825+
v-if="
826+
subject.score != undefined &&
827+
subject.score >= 0
828+
"
829+
v-text="subject.score"
830+
/>
831+
<span v-else> 无评分信息 </span>
832+
</el-descriptions-item>
833+
<el-descriptions-item
834+
822835
:label="t('module.subject.details.label.sync-platform')"
823836
>
824-
<span v-for="(sync, index) in subjectSyncs" :key="index">
837+
<span v-if="subjectSyncs && subjectSyncs.length > 0">
838+
<span v-for="(sync, index) in subjectSyncs" :key="index">
825839
{{ sync.platform }} :
826840
<span v-if="sync.platform === 'BGM_TV'">
827841
<a
@@ -835,6 +849,11 @@ onMounted(fetchDatas);
835849
{{ sync.platformId }}
836850
</span>
837851
</span>
852+
</span>
853+
<span v-else>
854+
无三方平台同步信息
855+
</span>
856+
838857
</el-descriptions-item>
839858
</el-descriptions>
840859
<el-descriptions size="large" :column="2" border>

server/src/main/java/run/ikaros/server/core/collection/SubjectCollectionImpl.java

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import run.ikaros.api.store.enums.CollectionType;
2525
import run.ikaros.api.store.enums.EpisodeGroup;
2626
import run.ikaros.api.wrap.PagingWrap;
27+
import run.ikaros.server.core.collection.event.SubjectCollectionScoreUpdateEvent;
2728
import run.ikaros.server.store.entity.BaseEntity;
2829
import run.ikaros.server.store.entity.EpisodeCollectionEntity;
2930
import run.ikaros.server.store.entity.SubjectCollectionEntity;
@@ -88,6 +89,7 @@ public Mono<Void> collect(SubjectCollection subjectCollection) {
8889
if (subjectCollection.getScore() == null) {
8990
subjectCollection.setScore(0);
9091
}
92+
final int newScore = subjectCollection.getScore();
9193
Assert.isTrue(subjectCollection.getScore() >= 0 && subjectCollection.getScore() <= 10,
9294
"subject collection score must between 0 and 10.");
9395
return findCollection(subjectCollection.getUserId(), subjectCollection.getSubjectId())
@@ -97,8 +99,21 @@ public Mono<Void> collect(SubjectCollection subjectCollection) {
9799
subjectCollectionRepository.findByUserIdAndSubjectId(
98100
subColl.getUserId(), subColl.getSubjectId())
99101
.switchIfEmpty(copyProperties(subColl, new SubjectCollectionEntity())
100-
.doOnSuccess(
101-
entity -> log.info("Create new subject collection entity: {}", entity)))
102+
.doOnSuccess(entity -> {
103+
log.info("Create new subject collection entity: {}", entity);
104+
SubjectCollectionScoreUpdateEvent event
105+
= new SubjectCollectionScoreUpdateEvent(
106+
this, entity.getSubjectId());
107+
applicationEventPublisher.publishEvent(event);
108+
}))
109+
.doOnNext(entity -> {
110+
if (entity.getScore() != newScore) {
111+
SubjectCollectionScoreUpdateEvent event
112+
= new SubjectCollectionScoreUpdateEvent(
113+
this, entity.getSubjectId());
114+
applicationEventPublisher.publishEvent(event);
115+
}
116+
})
102117
.flatMap(entity -> copyProperties(subColl, entity, "id"))
103118
)
104119
.flatMap(subjectCollectionRepository::save)

0 commit comments

Comments
 (0)