Skip to content

Commit

Permalink
feat: subject collection score and comment (#746)
Browse files Browse the repository at this point in the history
* build: upgrade to v0.20.7

* feat: add column 'comment' and 'score' in table 'subject_collection' and add dml for flyway migration sql.

* feat: add SubjectCollectionRepositoryTest

* feat: 条目收藏分数后台接口

* build: gen new api-client v20.7.0

* optimize: 分数范围配置为0到10

* feat: console条目详情页SubjectDetails.vue完成条目收藏中评分和评论的对接

* docs: update CHANGELOG.MD

* test: disable unit test in SubjectCollectionServiceTest
  • Loading branch information
chivehao authored Dec 8, 2024
1 parent f340701 commit 694a615
Show file tree
Hide file tree
Showing 57 changed files with 853 additions and 467 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

更新日志文档,版本顺序从新到旧,最新版本在最前(上)面。

# 0.20.7

## 新特性

- 新增Console条目收藏的评分和评论支持

# 0.20.6

## 新特性
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,9 @@ public class SubjectCollection {
private String cover;
@JsonProperty("air_time")
private LocalDateTime airTime;
private String comment;
/**
* Subject score, from 0 to 10.
*/
private Integer score;
}
11 changes: 11 additions & 0 deletions api/src/main/java/run/ikaros/api/infra/utils/StringUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,15 @@ public static String generateRandomStr(int length) {
return sb.toString();
}

/**
* 判断是否经过Base64编码.
*
* @param str 字符串
* @return 是否
*/
public static boolean isBase64Encoded(String str) {
// 判断字符串是否符合Base64编码规则
String regex = "^[A-Za-z0-9+/=]+$";
return str.matches(regex) && str.length() % 4 == 0;
}
}
2 changes: 1 addition & 1 deletion console/packages/api-client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ npm publish
选择当前目录下的更改进行`git add .`

```bash
git commit -am "build: gen new api-client v20.6.0"
git commit -am "build: gen new api-client v20.7.0"
```

合成版(powershell),升级 package.json 版本,并启动服务端后,在 api-client 路径下:
Expand Down
2 changes: 1 addition & 1 deletion console/packages/api-client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@runikaros/api-client",
"version": "20.6.0",
"version": "20.7.0",
"description": "Project ikaros console api-client package",
"type": "module",
"scripts": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,17 @@ export const V1alpha1CollectionSubjectApiAxiosParamCreator = function (
* @param {number} subjectId Subject id.
* @param {'WISH' | 'DOING' | 'DONE' | 'SHELVE' | 'DISCARD'} type Collection type.
* @param {boolean} [isPrivate] Is private, default is false.
* @param {string} [comment] Subject comment, with base64 encoded.
* @param {number} [score] Subject score, from 0 to 100.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
collectSubject: async (
subjectId: number,
type: "WISH" | "DOING" | "DONE" | "SHELVE" | "DISCARD",
isPrivate?: boolean,
comment?: string,
score?: number,
options: AxiosRequestConfig = {}
): Promise<RequestArgs> => {
// verify required parameter 'subjectId' is not null or undefined
Expand Down Expand Up @@ -103,6 +107,14 @@ export const V1alpha1CollectionSubjectApiAxiosParamCreator = function (
localVarQueryParameter["isPrivate"] = isPrivate;
}

if (comment !== undefined) {
localVarQueryParameter["comment"] = comment;
}

if (score !== undefined) {
localVarQueryParameter["score"] = score;
}

setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions =
baseOptions && baseOptions.headers ? baseOptions.headers : {};
Expand Down Expand Up @@ -378,13 +390,17 @@ export const V1alpha1CollectionSubjectApiFp = function (
* @param {number} subjectId Subject id.
* @param {'WISH' | 'DOING' | 'DONE' | 'SHELVE' | 'DISCARD'} type Collection type.
* @param {boolean} [isPrivate] Is private, default is false.
* @param {string} [comment] Subject comment, with base64 encoded.
* @param {number} [score] Subject score, from 0 to 100.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async collectSubject(
subjectId: number,
type: "WISH" | "DOING" | "DONE" | "SHELVE" | "DISCARD",
isPrivate?: boolean,
comment?: string,
score?: number,
options?: AxiosRequestConfig
): Promise<
(axios?: AxiosInstance, basePath?: string) => AxiosPromise<void>
Expand All @@ -393,6 +409,8 @@ export const V1alpha1CollectionSubjectApiFp = function (
subjectId,
type,
isPrivate,
comment,
score,
options
);
return createRequestFunction(
Expand Down Expand Up @@ -542,6 +560,8 @@ export const V1alpha1CollectionSubjectApiFactory = function (
requestParameters.subjectId,
requestParameters.type,
requestParameters.isPrivate,
requestParameters.comment,
requestParameters.score,
options
)
.then((request) => request(axios, basePath));
Expand Down Expand Up @@ -641,6 +661,20 @@ export interface V1alpha1CollectionSubjectApiCollectSubjectRequest {
* @memberof V1alpha1CollectionSubjectApiCollectSubject
*/
readonly isPrivate?: boolean;

/**
* Subject comment, with base64 encoded.
* @type {string}
* @memberof V1alpha1CollectionSubjectApiCollectSubject
*/
readonly comment?: string;

/**
* Subject score, from 0 to 100.
* @type {number}
* @memberof V1alpha1CollectionSubjectApiCollectSubject
*/
readonly score?: number;
}

/**
Expand Down Expand Up @@ -750,6 +784,8 @@ export class V1alpha1CollectionSubjectApi extends BaseAPI {
requestParameters.subjectId,
requestParameters.type,
requestParameters.isPrivate,
requestParameters.comment,
requestParameters.score,
options
)
.then((request) => request(this.axios, this.basePath));
Expand Down
26 changes: 13 additions & 13 deletions console/packages/api-client/src/api/v1alpha1-indices-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,16 +97,16 @@ export const V1alpha1IndicesApiAxiosParamCreator = function (
* Search subjects with fuzzy query
* @param {string} keyword
* @param {number} [limit]
* @param {string} [highlightPreTag]
* @param {string} [highlightPostTag]
* @param {string} [highlightPreTag]
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
searchSubject: async (
keyword: string,
limit?: number,
highlightPreTag?: string,
highlightPostTag?: string,
highlightPreTag?: string,
options: AxiosRequestConfig = {}
): Promise<RequestArgs> => {
// verify required parameter 'keyword' is not null or undefined
Expand Down Expand Up @@ -139,16 +139,16 @@ export const V1alpha1IndicesApiAxiosParamCreator = function (
localVarQueryParameter["limit"] = limit;
}

if (keyword !== undefined) {
localVarQueryParameter["keyword"] = keyword;
if (highlightPostTag !== undefined) {
localVarQueryParameter["highlightPostTag"] = highlightPostTag;
}

if (highlightPreTag !== undefined) {
localVarQueryParameter["highlightPreTag"] = highlightPreTag;
}

if (highlightPostTag !== undefined) {
localVarQueryParameter["highlightPostTag"] = highlightPostTag;
if (keyword !== undefined) {
localVarQueryParameter["keyword"] = keyword;
}

setSearchParams(localVarUrlObj, localVarQueryParameter);
Expand Down Expand Up @@ -199,25 +199,25 @@ export const V1alpha1IndicesApiFp = function (configuration?: Configuration) {
* Search subjects with fuzzy query
* @param {string} keyword
* @param {number} [limit]
* @param {string} [highlightPreTag]
* @param {string} [highlightPostTag]
* @param {string} [highlightPreTag]
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async searchSubject(
keyword: string,
limit?: number,
highlightPreTag?: string,
highlightPostTag?: string,
highlightPreTag?: string,
options?: AxiosRequestConfig
): Promise<
(axios?: AxiosInstance, basePath?: string) => AxiosPromise<SubjectHints>
> {
const localVarAxiosArgs = await localVarAxiosParamCreator.searchSubject(
keyword,
limit,
highlightPreTag,
highlightPostTag,
highlightPreTag,
options
);
return createRequestFunction(
Expand Down Expand Up @@ -265,8 +265,8 @@ export const V1alpha1IndicesApiFactory = function (
.searchSubject(
requestParameters.keyword,
requestParameters.limit,
requestParameters.highlightPreTag,
requestParameters.highlightPostTag,
requestParameters.highlightPreTag,
options
)
.then((request) => request(axios, basePath));
Expand Down Expand Up @@ -299,14 +299,14 @@ export interface V1alpha1IndicesApiSearchSubjectRequest {
* @type {string}
* @memberof V1alpha1IndicesApiSearchSubject
*/
readonly highlightPreTag?: string;
readonly highlightPostTag?: string;

/**
*
* @type {string}
* @memberof V1alpha1IndicesApiSearchSubject
*/
readonly highlightPostTag?: string;
readonly highlightPreTag?: string;
}

/**
Expand Down Expand Up @@ -343,8 +343,8 @@ export class V1alpha1IndicesApi extends BaseAPI {
.searchSubject(
requestParameters.keyword,
requestParameters.limit,
requestParameters.highlightPreTag,
requestParameters.highlightPostTag,
requestParameters.highlightPreTag,
options
)
.then((request) => request(this.axios, this.basePath));
Expand Down
8 changes: 4 additions & 4 deletions console/packages/api-client/src/models/paging-wrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,17 @@ export interface PagingWrap {
*/
items: Array<object>;
/**
* Indicates whether current page is the last page.
* Indicates whether current page is the first page.
* @type {boolean}
* @memberof PagingWrap
*/
lastPage: boolean;
firstPage: boolean;
/**
* Indicates whether current page is the first page.
* Indicates whether current page is the last page.
* @type {boolean}
* @memberof PagingWrap
*/
firstPage: boolean;
lastPage: boolean;
/**
* Indicates whether current page has previous page.
* @type {boolean}
Expand Down
12 changes: 12 additions & 0 deletions console/packages/api-client/src/models/subject-collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,18 @@ export interface SubjectCollection {
* @memberof SubjectCollection
*/
cover?: string;
/**
*
* @type {string}
* @memberof SubjectCollection
*/
comment?: string;
/**
*
* @type {number}
* @memberof SubjectCollection
*/
score?: number;
/**
*
* @type {number}
Expand Down
2 changes: 1 addition & 1 deletion console/src/components/image/Cropperjs.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script setup lang="ts">
import Cropper from 'cropperjs';
import 'cropperjs/dist/cropper.css';
import {onMounted, ref, watch} from 'vue';
import { onMounted, ref, watch } from 'vue';
const props = withDefaults(
defineProps<{
Expand Down
8 changes: 4 additions & 4 deletions console/src/components/image/CropperjsDialog.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<script setup lang="ts">
import {computed, ref} from 'vue';
import { computed, ref } from 'vue';
import Cropperjs from './Cropperjs.vue';
import {ElButton, ElDialog} from 'element-plus';
import {apiClient} from '@/utils/api-client';
import {randomUUID} from '@/utils/id';
import { ElButton, ElDialog } from 'element-plus';
import { apiClient } from '@/utils/api-client';
import { randomUUID } from '@/utils/id';
const props = withDefaults(
defineProps<{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script setup lang="ts">
import {ElCard, ElProgress} from 'element-plus';
import {computed, onMounted, ref, watch} from 'vue';
import { ElCard, ElProgress } from 'element-plus';
import { computed, onMounted, ref, watch } from 'vue';
const props = withDefaults(
defineProps<{
Expand Down
Loading

0 comments on commit 694a615

Please sign in to comment.