feat(payment-method): add

feat(card-type): add
This commit is contained in:
avicenan
2026-03-27 16:31:09 +07:00
parent a4d0f2c529
commit 489d9d5780
7 changed files with 1289 additions and 456 deletions

37
src/model/card_type.ts Normal file
View File

@ -0,0 +1,37 @@
import { SelectQueryBuilder } from "typeorm";
import CommonHelper from "../helpers/common";
import { OrmHelper } from "../helpers/orm";
import { CardType } from "entity";
export class CardTypeModel {
static async list(filterObj = {}, filterAny: string = ""): Promise<SelectQueryBuilder<any>> {
const repo = OrmHelper.DB.getRepository(CardType);
let whereAttr = [];
let whereVal: any = {};
if (filterObj) {
const filterResult = CommonHelper.handleQueryFilter(filterObj);
whereAttr = [...whereAttr, ...filterResult.whereAttr];
whereVal = { ...whereVal, ...filterResult.whereVal };
}
if (filterAny && filterAny !== "" && filterAny !== null && filterAny !== undefined) {
const filterResult = CommonHelper.handleFilter({
filter: JSON.stringify({ any: filterAny }),
col_any_eq: [],
col_any_like: ["name"],
});
if (filterResult.whereAttr && filterResult.whereAttr !== "") {
whereAttr = [...whereAttr, filterResult.whereAttr];
whereVal = { ...whereVal, ...filterResult.whereVal };
}
}
var query = repo.createQueryBuilder("card_type");
if (whereAttr.length != 0) {
query = query.where(whereAttr.join(" and "), whereVal);
}
return query;
}
}

View File

@ -0,0 +1,37 @@
import { SelectQueryBuilder } from "typeorm";
import CommonHelper from "../helpers/common";
import { OrmHelper } from "../helpers/orm";
import { PaymentMethod } from "entity";
export class PaymentMethodModel {
static async list(filterObj = {}, filterAny: string = ""): Promise<SelectQueryBuilder<any>> {
const repo = OrmHelper.DB.getRepository(PaymentMethod);
let whereAttr = [];
let whereVal: any = {};
if (filterObj) {
const filterResult = CommonHelper.handleQueryFilter(filterObj);
whereAttr = [...whereAttr, ...filterResult.whereAttr];
whereVal = { ...whereVal, ...filterResult.whereVal };
}
if (filterAny && filterAny !== "" && filterAny !== null && filterAny !== undefined) {
const filterResult = CommonHelper.handleFilter({
filter: JSON.stringify({ any: filterAny }),
col_any_eq: [],
col_any_like: ["name"],
});
if (filterResult.whereAttr && filterResult.whereAttr !== "") {
whereAttr = [...whereAttr, filterResult.whereAttr];
whereVal = { ...whereVal, ...filterResult.whereVal };
}
}
var query = repo.createQueryBuilder("payment_method");
if (whereAttr.length != 0) {
query = query.where(whereAttr.join(" and "), whereVal);
}
return query;
}
}