-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #93 from zkLinkProtocol/feat-loadOtherPoints
add supplement endpoint.
- Loading branch information
Showing
6 changed files
with
180 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { Entity, Column, PrimaryColumn, Index } from "typeorm"; | ||
import { BaseEntity } from "./base.entity"; | ||
import { hexTransformer } from "../transformers/hex.transformer"; | ||
|
||
export enum SupplementPointType { | ||
DirectHold = "directHold", | ||
} | ||
|
||
@Entity({ name: "supplementPoint" }) | ||
@Index("idx_supplementPoint_1", ["address", "batchString", "type"]) | ||
export class supplementPoint extends BaseEntity { | ||
@Column({ type: "bytea", transformer: hexTransformer }) | ||
public address: string; | ||
|
||
@Column({ type: "varchar", length: 20 }) | ||
public batchString: string; | ||
|
||
@Column("decimal") | ||
public point: number; | ||
|
||
// directHold | ||
@PrimaryColumn({ type: "varchar", length: 20 }) | ||
public type: SupplementPointType; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { Injectable } from "@nestjs/common"; | ||
import { UnitOfWork } from "../unitOfWork"; | ||
import { BaseRepository } from "./base.repository"; | ||
import { | ||
SupplementPointType, | ||
supplementPoint, | ||
} from "../entities/supplementPoint.entity"; | ||
|
||
@Injectable() | ||
export class SupplementPointRepository extends BaseRepository<supplementPoint> { | ||
public constructor(unitOfWork: UnitOfWork) { | ||
super(supplementPoint, unitOfWork); | ||
} | ||
|
||
async addManyDirectPoint( | ||
points: { address: string; point: number }[], | ||
batchString: string, | ||
): Promise<void> { | ||
const insertData = points.map((item) => { | ||
return { | ||
address: item.address, | ||
point: item.point, | ||
batchString: batchString, | ||
type: SupplementPointType.DirectHold, | ||
}; | ||
}); | ||
await this.addManyOrUpdate( | ||
insertData, | ||
["point"], | ||
["address", "batchString", "type"], | ||
); | ||
} | ||
} |