mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-14 15:07:33 +08:00
support transaction tag group
This commit is contained in:
@@ -448,8 +448,8 @@ export class TransactionTagFilter {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public static create(type: TransactionTagFilterType): TransactionTagFilter {
|
||||
return new TransactionTagFilter([], type);
|
||||
public static create(tagIds: string[], type: TransactionTagFilterType): TransactionTagFilter {
|
||||
return new TransactionTagFilter(tagIds, type);
|
||||
}
|
||||
|
||||
public static of(tagId: string): TransactionTagFilter {
|
||||
|
||||
@@ -1,31 +1,39 @@
|
||||
export class TransactionTag implements TransactionTagInfoResponse {
|
||||
public id: string;
|
||||
public name: string;
|
||||
public groupId: string;
|
||||
public displayOrder: number;
|
||||
public hidden: boolean;
|
||||
|
||||
private constructor(id: string, name: string, displayOrder: number, hidden: boolean) {
|
||||
private constructor(id: string, name: string, groupId: string, displayOrder: number, hidden: boolean) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.groupId = groupId;
|
||||
this.displayOrder = displayOrder;
|
||||
this.hidden = hidden;
|
||||
}
|
||||
|
||||
public toCreateRequest(): TransactionTagCreateRequest {
|
||||
return {
|
||||
name: this.name
|
||||
name: this.name,
|
||||
groupId: this.groupId
|
||||
};
|
||||
}
|
||||
|
||||
public toModifyRequest(): TransactionTagModifyRequest {
|
||||
return {
|
||||
id: this.id,
|
||||
groupId: this.groupId,
|
||||
name: this.name
|
||||
};
|
||||
}
|
||||
|
||||
public clone(): TransactionTag {
|
||||
return new TransactionTag(this.id, this.name, this.groupId, this.displayOrder, this.hidden);
|
||||
}
|
||||
|
||||
public static of(tagResponse: TransactionTagInfoResponse): TransactionTag {
|
||||
return new TransactionTag(tagResponse.id, tagResponse.name, tagResponse.displayOrder, tagResponse.hidden);
|
||||
return new TransactionTag(tagResponse.id, tagResponse.name, tagResponse.groupId, tagResponse.displayOrder, tagResponse.hidden);
|
||||
}
|
||||
|
||||
public static ofMulti(tagResponses: TransactionTagInfoResponse[]): TransactionTag[] {
|
||||
@@ -38,22 +46,25 @@ export class TransactionTag implements TransactionTagInfoResponse {
|
||||
return tags;
|
||||
}
|
||||
|
||||
public static createNewTag(name?: string): TransactionTag {
|
||||
return new TransactionTag('', name || '', 0, false);
|
||||
public static createNewTag(name?: string, groupId?: string): TransactionTag {
|
||||
return new TransactionTag('', name || '', groupId || '0', 0, false);
|
||||
}
|
||||
}
|
||||
|
||||
export interface TransactionTagCreateRequest {
|
||||
readonly groupId: string;
|
||||
readonly name: string;
|
||||
}
|
||||
|
||||
export interface TransactionTagCreateBatchRequest {
|
||||
readonly tags: TransactionTagCreateRequest[];
|
||||
readonly groupId: string;
|
||||
readonly skipExists: boolean;
|
||||
}
|
||||
|
||||
export interface TransactionTagModifyRequest {
|
||||
readonly id: string;
|
||||
readonly groupId: string;
|
||||
readonly name: string;
|
||||
}
|
||||
|
||||
@@ -78,6 +89,7 @@ export interface TransactionTagDeleteRequest {
|
||||
export interface TransactionTagInfoResponse {
|
||||
readonly id: string;
|
||||
readonly name: string;
|
||||
readonly groupId: string;
|
||||
readonly displayOrder: number;
|
||||
readonly hidden: boolean;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
export class TransactionTagGroup implements TransactionTagGroupInfoResponse {
|
||||
public id: string;
|
||||
public name: string;
|
||||
public displayOrder: number;
|
||||
|
||||
private constructor(id: string, name: string, displayOrder: number) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.displayOrder = displayOrder;
|
||||
}
|
||||
|
||||
public toCreateRequest(): TransactionTagGroupCreateRequest {
|
||||
return {
|
||||
name: this.name
|
||||
};
|
||||
}
|
||||
|
||||
public toModifyRequest(): TransactionTagGroupModifyRequest {
|
||||
return {
|
||||
id: this.id,
|
||||
name: this.name
|
||||
};
|
||||
}
|
||||
|
||||
public clone(): TransactionTagGroup {
|
||||
return new TransactionTagGroup(this.id, this.name, this.displayOrder);
|
||||
}
|
||||
|
||||
public static of(tagGroupResponse: TransactionTagGroupInfoResponse): TransactionTagGroup {
|
||||
return new TransactionTagGroup(tagGroupResponse.id, tagGroupResponse.name, tagGroupResponse.displayOrder);
|
||||
}
|
||||
|
||||
public static ofMulti(tagGroupResponses: TransactionTagGroupInfoResponse[]): TransactionTagGroup[] {
|
||||
const tagGroups: TransactionTagGroup[] = [];
|
||||
|
||||
for (const tagGroupResponse of tagGroupResponses) {
|
||||
tagGroups.push(TransactionTagGroup.of(tagGroupResponse));
|
||||
}
|
||||
|
||||
return tagGroups;
|
||||
}
|
||||
|
||||
public static createNewTagGroup(name?: string): TransactionTagGroup {
|
||||
return new TransactionTagGroup('', name || '', 0);
|
||||
}
|
||||
}
|
||||
|
||||
export interface TransactionTagGroupCreateRequest {
|
||||
readonly name: string;
|
||||
}
|
||||
|
||||
export interface TransactionTagGroupModifyRequest {
|
||||
readonly id: string;
|
||||
readonly name: string;
|
||||
}
|
||||
|
||||
export interface TransactionTagGroupMoveRequest {
|
||||
readonly newDisplayOrders: TransactionTagGroupNewDisplayOrderRequest[];
|
||||
}
|
||||
|
||||
export interface TransactionTagGroupNewDisplayOrderRequest {
|
||||
readonly id: string;
|
||||
readonly displayOrder: number;
|
||||
}
|
||||
|
||||
export interface TransactionTagGroupDeleteRequest {
|
||||
readonly id: string;
|
||||
}
|
||||
|
||||
export interface TransactionTagGroupInfoResponse {
|
||||
readonly id: string;
|
||||
readonly name: string;
|
||||
readonly displayOrder: number;
|
||||
}
|
||||
Reference in New Issue
Block a user