feature/5-drop-command (#17)
#5 Reviewed-on: https://gitea.vylpes.xyz/External/card-drop/pulls/17 Co-authored-by: Ethan Lane <ethan@vylpes.com> Co-committed-by: Ethan Lane <ethan@vylpes.com>
This commit is contained in:
parent
51d97bacd5
commit
58d1541e47
21 changed files with 382 additions and 48 deletions
47
src/database/entities/app/Inventory.ts
Normal file
47
src/database/entities/app/Inventory.ts
Normal file
|
@ -0,0 +1,47 @@
|
|||
import { Column, Entity } from "typeorm";
|
||||
import AppBaseEntity from "../../../contracts/AppBaseEntity";
|
||||
import AppDataSource from "../../dataSources/appDataSource";
|
||||
|
||||
@Entity()
|
||||
export default class Inventory extends AppBaseEntity {
|
||||
constructor(userId: string, cardNumber: string, quantity: number, claimId: string) {
|
||||
super();
|
||||
|
||||
this.UserId = userId;
|
||||
this.CardNumber = cardNumber;
|
||||
this.Quantity = quantity;
|
||||
this.ClaimId = claimId;
|
||||
}
|
||||
|
||||
@Column()
|
||||
UserId: string;
|
||||
|
||||
@Column()
|
||||
CardNumber: string;
|
||||
|
||||
@Column()
|
||||
Quantity: number;
|
||||
|
||||
@Column()
|
||||
ClaimId: string;
|
||||
|
||||
public SetQuantity(quantity: number) {
|
||||
this.Quantity = quantity;
|
||||
}
|
||||
|
||||
public static async FetchOneByCardNumberAndUserId(userId: string, cardNumber: string): Promise<Inventory | null> {
|
||||
const repository = AppDataSource.getRepository(Inventory);
|
||||
|
||||
const single = await repository.findOne({ where: { UserId: userId, CardNumber: cardNumber }});
|
||||
|
||||
return single;
|
||||
}
|
||||
|
||||
public static async FetchOneByClaimId(claimId: string): Promise<Inventory | null> {
|
||||
const repository = AppDataSource.getRepository(Inventory);
|
||||
|
||||
const single = await repository.findOne({ where: { ClaimId: claimId }});
|
||||
|
||||
return single;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue