Skip to content

Commit

Permalink
Merge pull request #94 from GuoXiCheng/dev-h
Browse files Browse the repository at this point in the history
update
  • Loading branch information
GuoXiCheng authored Jan 28, 2024
2 parents 8218fb6 + 7f3ca71 commit c358cfd
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 13 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tiny-crud",
"version": "1.1.1",
"version": "1.1.2",
"description": "Lightweight Data Repository Based on Git Issue API",
"main": "dist/bundle.cjs.js",
"module": "dist/bundle.esm.js",
Expand Down
7 changes: 1 addition & 6 deletions src/repository-lib/base/base-repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,6 @@ export abstract class BaseRepository<T extends BaseModel> {
protected cleanParams(params?: BaseParams): BaseParams | undefined {
if (params == null) return;
const copyParams = JSON.parse(JSON.stringify(params));
for (const key in copyParams) {
if (copyParams[key] == null) {
delete copyParams[key];
}
}
return Object.keys(copyParams).length > 0 ? copyParams : undefined;
}

Expand All @@ -71,7 +66,7 @@ export abstract class BaseRepository<T extends BaseModel> {
*/
async find(params?: BaseParams): Promise<T[]> {
const url = this.getRoute(RouteType.find);
const response = await this.request.get<BaseComment[]>(url, params);
const response = await this.request.get<BaseComment[]>(url, this.cleanParams(params));
return response.map((item) => this.deserialize<T>(item));
}

Expand Down
2 changes: 1 addition & 1 deletion src/repository-lib/gitee/gitee-repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class GiteeRepository<T extends BaseModel> extends BaseRepository<T> {
* @returns A promise that resolves to an array of items.
*/
async find(params?: GiteeParams): Promise<T[]> {
return super.find(this.cleanParams(params));
return super.find(params);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/repository-lib/github/github-repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class GithubRepository<T extends BaseModel> extends BaseRepository<T> {
* @returns A promise that resolves to an array of items.
*/
async find(params?: GithubParams): Promise<T[]> {
return super.find(this.cleanParams(params));
return super.find(params);
}

/**
Expand Down
8 changes: 4 additions & 4 deletions src/repository-lib/gitlab/gitlab-repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ export class GitlabRepository<T extends BaseModel> extends BaseRepository<T> {
*/
async find(params?: GitlabParams): Promise<T[]> {
const url = this.getRoute(RouteType.find);
const response = await this.request.get<BaseComment[]>(url, this.cleanParams(params));
return response.filter(item => item['system'] === false).map((item) => this.deserialize<T>(item));
const response = await this.request.get<BaseComment[]>(url, super.cleanParams(params));
return response.filter(item => item['system'] === false).map((item) => super.deserialize<T>(item));
}

/**
Expand All @@ -54,9 +54,9 @@ export class GitlabRepository<T extends BaseModel> extends BaseRepository<T> {
*/
async updateById(id: number, data: PlainObject<T>): Promise<T> {
const url = this.getRoute(RouteType.updateById, id);
const body = this.serialize<PlainObject<T>>(data);
const body = super.serialize<PlainObject<T>>(data);
const response = await this.request.put<BaseComment>(url, body);
return this.deserialize<T>(response);
return super.deserialize<T>(response);
}

/**
Expand Down

0 comments on commit c358cfd

Please sign in to comment.