feat: add address fields

This commit is contained in:
Methapon Metanipat 2024-09-11 15:06:27 +07:00
parent 730ebd6907
commit a7cafd25d0
8 changed files with 209 additions and 206 deletions

View file

@ -36,7 +36,7 @@ import {
createPermCheck,
createPermCondition,
} from "../services/permission";
import { connectOrDisconnect, connectOrNot } from "../utils/relation";
import { connectOrDisconnect, connectOrNot, whereAddressQuery } from "../utils/relation";
if (!process.env.MINIO_BUCKET) {
throw Error("Require MinIO bucket.");
@ -84,7 +84,12 @@ type UserCreate = {
address: string;
addressEN: string;
zipCode: string;
soi?: string | null;
soiEN?: string | null;
moo?: string | null;
mooEN?: string | null;
street?: string | null;
streetEN?: string | null;
email: string;
telephoneNo: string;
@ -131,7 +136,12 @@ type UserUpdate = {
address?: string;
addressEN?: string;
zipCode?: string;
soi?: string | null;
soiEN?: string | null;
moo?: string | null;
mooEN?: string | null;
street?: string | null;
streetEN?: string | null;
email?: string;
telephoneNo?: string;
@ -223,7 +233,6 @@ export class UserController extends Controller {
async getUser(
@Request() req: RequestWithUser,
@Query() userType?: UserType,
@Query() zipCode?: string,
@Query() includeBranch: boolean = false,
@Query() query: string = "",
@Query() page: number = 1,
@ -238,10 +247,10 @@ export class UserController extends Controller {
{ lastNameEN: { contains: query } },
{ email: { contains: query } },
{ telephoneNo: { contains: query } },
...whereAddressQuery(query),
],
AND: {
userRole: { not: "system" },
zipCode,
userType,
...filterStatus(status),
branch: isSystem(req.user)