Merge branch 'main' of https://git.shiblysolution.id/SAUDE-TL/service-master-data
This commit is contained in:
@ -250,6 +250,11 @@ export class PharmacyInfoController {
|
||||
.uuid()
|
||||
.required()
|
||||
.label('Default Room'),
|
||||
|
||||
province: Joi.string().allow("").optional().label("Province Code"),
|
||||
city: Joi.string().allow("").optional().label("City Code"),
|
||||
subdistrict: Joi.string().allow("").optional().label("Subdistrict Code"),
|
||||
ward: Joi.string().allow("").optional().label("Ward Code"),
|
||||
});
|
||||
|
||||
const param: any = await schema.validateAsync(req.body);
|
||||
@ -264,7 +269,11 @@ export class PharmacyInfoController {
|
||||
data.phone = param.phone
|
||||
data.default_room = param.default_room_id
|
||||
data.logo = param.logo
|
||||
data.created_by = req.auth.data.name;
|
||||
data.province = param.province
|
||||
data.city = param.city
|
||||
data.subdistrict = param.subdistrict
|
||||
data.ward = param.ward
|
||||
data.created_by = req.auth?.data.name;
|
||||
|
||||
await OrmHelper.DB.manager.save(data);
|
||||
|
||||
@ -369,7 +378,11 @@ export class PharmacyInfoController {
|
||||
data.phone = param.phone
|
||||
data.default_room = param.default_room_id
|
||||
data.logo = param.logo
|
||||
data.updated_by = req.auth.data.name;
|
||||
data.province = param.province
|
||||
data.city = param.city
|
||||
data.subdistrict = param.subdistrict
|
||||
data.ward = param.ward
|
||||
data.updated_by = req.auth?.data.name;
|
||||
|
||||
await repo.save(data);
|
||||
|
||||
@ -416,7 +429,7 @@ export class PharmacyInfoController {
|
||||
|
||||
const existData = await repo.findOne({ where: { id: param.id } });
|
||||
if (existData && !param.hard) {
|
||||
existData.deleted_by = req.auth.data.name;
|
||||
existData.deleted_by = req.auth?.data.name;
|
||||
await OrmHelper.DB.manager.save(existData);
|
||||
}
|
||||
|
||||
|
||||
164
src/controllers/region.ts
Normal file
164
src/controllers/region.ts
Normal file
@ -0,0 +1,164 @@
|
||||
import { Response, NextFunction, Application } from "express";
|
||||
import { Request } from "express-jwt";
|
||||
import { ReturnHelper } from "../helpers/express/return";
|
||||
import { OrmHelper } from "../helpers/orm";
|
||||
import Joi from "joi";
|
||||
import { ILogObj, Logger } from "tslog";
|
||||
import { Language } from "../langs/lang";
|
||||
import { Paging } from "entity";
|
||||
import CommonHelper from "../helpers/common";
|
||||
import * as fastcsv from 'fast-csv';
|
||||
import dayjs from "dayjs";
|
||||
import { Province, City, Subdistrict, Ward } from "entity";
|
||||
|
||||
const log: Logger<ILogObj> = new Logger({ name: '[RegionController]', type: 'pretty' });
|
||||
|
||||
export class RegionController {
|
||||
static async province(req: Request, res: Response, next: NextFunction): Promise<Response> {
|
||||
/*
|
||||
#swagger.tags = ['Region']
|
||||
#swagger.security = [{
|
||||
"bearerAuth": []
|
||||
}]
|
||||
*/
|
||||
|
||||
try {
|
||||
const repo = OrmHelper.DB.getRepository(Province);
|
||||
|
||||
const res_count = repo.createQueryBuilder("province");
|
||||
const res_list = repo.createQueryBuilder("province");
|
||||
|
||||
const current_page = 1;
|
||||
const total_count_data = await res_count.getCount();
|
||||
const list_data = await res_list.getMany();
|
||||
const count_data = CommonHelper.countObject(list_data);
|
||||
|
||||
return ReturnHelper.successResponselist(res, 200, Language.lang.success_view, count_data, current_page, total_count_data, list_data);
|
||||
} catch (e: unknown) {
|
||||
log.error(e);
|
||||
const err = e as Error;
|
||||
|
||||
return ReturnHelper.errorResponse(res, 400, 401, Language.lang.failed_view, err.message);
|
||||
}
|
||||
}
|
||||
|
||||
static async city(req: Request, res: Response, next: NextFunction): Promise<Response> {
|
||||
/*
|
||||
#swagger.tags = ['Region']
|
||||
#swagger.security = [{
|
||||
"bearerAuth": []
|
||||
}]
|
||||
#swagger.parameters['province_code'] = {
|
||||
in: 'path',
|
||||
description: 'Province Code.',
|
||||
required: true,
|
||||
type: 'string'
|
||||
}
|
||||
*/
|
||||
|
||||
try {
|
||||
const { province_code } = req.params;
|
||||
|
||||
if (!/^\d{2}$/.test(province_code)) {
|
||||
return ReturnHelper.successResponselist(res, 200, Language.lang.success_view, 0, 1, 0, []);
|
||||
}
|
||||
|
||||
const repo = OrmHelper.DB.getRepository(City);
|
||||
const res_count = repo.createQueryBuilder("city")
|
||||
.where("city.code LIKE :province_code", { province_code: `${province_code}%` });
|
||||
const res_list = repo.createQueryBuilder("city")
|
||||
.where("city.code LIKE :province_code", { province_code: `${province_code}%` });
|
||||
|
||||
const current_page = 1;
|
||||
const total_count_data = await res_count.getCount();
|
||||
const list_data = await res_list.getMany();
|
||||
const count_data = CommonHelper.countObject(list_data);
|
||||
|
||||
return ReturnHelper.successResponselist(res, 200, Language.lang.success_view, count_data, current_page, total_count_data, list_data);
|
||||
} catch (e: unknown) {
|
||||
log.error(e);
|
||||
const err = e as Error;
|
||||
return ReturnHelper.errorResponse(res, 400, 401, Language.lang.failed_view, err.message);
|
||||
}
|
||||
}
|
||||
|
||||
static async subdistrict(req: Request, res: Response, next: NextFunction): Promise<Response> {
|
||||
/*
|
||||
#swagger.tags = ['Region']
|
||||
#swagger.security = [{
|
||||
"bearerAuth": []
|
||||
}]
|
||||
#swagger.parameters['city_code'] = {
|
||||
in: 'path',
|
||||
description: 'City Code.',
|
||||
required: true,
|
||||
type: 'string'
|
||||
}
|
||||
*/
|
||||
|
||||
try {
|
||||
const { city_code } = req.params;
|
||||
|
||||
if (!/^\d{2}\.\d{2}$/.test(city_code)) {
|
||||
return ReturnHelper.successResponselist(res, 200, Language.lang.success_view, 0, 1, 0, []);
|
||||
}
|
||||
|
||||
const repo = OrmHelper.DB.getRepository(Subdistrict);
|
||||
const res_count = repo.createQueryBuilder("subdistrict")
|
||||
.where("subdistrict.code LIKE :city_code", { city_code: `${city_code}%` });
|
||||
const res_list = repo.createQueryBuilder("subdistrict")
|
||||
.where("subdistrict.code LIKE :city_code", { city_code: `${city_code}%` });
|
||||
|
||||
const current_page = 1;
|
||||
const total_count_data = await res_count.getCount();
|
||||
const list_data = await res_list.getMany();
|
||||
const count_data = CommonHelper.countObject(list_data);
|
||||
|
||||
return ReturnHelper.successResponselist(res, 200, Language.lang.success_view, count_data, current_page, total_count_data, list_data);
|
||||
} catch (e: unknown) {
|
||||
log.error(e);
|
||||
const err = e as Error;
|
||||
return ReturnHelper.errorResponse(res, 400, 401, Language.lang.failed_view, err.message);
|
||||
}
|
||||
}
|
||||
|
||||
static async ward(req: Request, res: Response, next: NextFunction): Promise<Response> {
|
||||
/*
|
||||
#swagger.tags = ['Region']
|
||||
#swagger.security = [{
|
||||
"bearerAuth": []
|
||||
}]
|
||||
#swagger.parameters['subdistric_code'] = {
|
||||
in: 'path',
|
||||
description: 'Subdistric Code.',
|
||||
required: true,
|
||||
type: 'string'
|
||||
}
|
||||
*/
|
||||
|
||||
try {
|
||||
const { subdistric_code } = req.params;
|
||||
|
||||
if (!/^\d{2}\.\d{2}\.\d{2}$/.test(subdistric_code)) {
|
||||
return ReturnHelper.successResponselist(res, 200, Language.lang.success_view, 0, 1, 0, []);
|
||||
}
|
||||
|
||||
const repo = OrmHelper.DB.getRepository(Ward);
|
||||
const res_count = repo.createQueryBuilder("ward")
|
||||
.where("ward.code LIKE :subdistric_code", { subdistric_code: `${subdistric_code}%` });
|
||||
const res_list = repo.createQueryBuilder("ward")
|
||||
.where("ward.code LIKE :subdistric_code", { subdistric_code: `${subdistric_code}%` });
|
||||
|
||||
const current_page = 1;
|
||||
const total_count_data = await res_count.getCount();
|
||||
const list_data = await res_list.getMany();
|
||||
const count_data = CommonHelper.countObject(list_data);
|
||||
|
||||
return ReturnHelper.successResponselist(res, 200, Language.lang.success_view, count_data, current_page, total_count_data, list_data);
|
||||
} catch (e: unknown) {
|
||||
log.error(e);
|
||||
const err = e as Error;
|
||||
return ReturnHelper.errorResponse(res, 400, 401, Language.lang.failed_view, err.message);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -36,31 +36,99 @@ export class RoomToPharmacyController {
|
||||
});
|
||||
|
||||
let param: Paging = await schema.validateAsync(req.query);
|
||||
|
||||
let filter = param.filter && param.filter !== "" ? JSON.parse(param.filter) : {};
|
||||
|
||||
var query = await RoomToPharmacyModel.list(filter);
|
||||
|
||||
const offset = (param.page - 1) * param.limit;
|
||||
let limit = param.limit;
|
||||
const limit = param.limit;
|
||||
|
||||
const res_count = query;
|
||||
const res_list = query
|
||||
.orderBy("room_to_pharmacy." + param.order_field, param.order_direction)
|
||||
.offset(offset)
|
||||
.limit(limit);
|
||||
const roomQuery = OrmHelper.DB.getRepository(Room)
|
||||
.createQueryBuilder("room")
|
||||
.leftJoinAndSelect("room.department", "department")
|
||||
.leftJoinAndMapMany(
|
||||
"room.roomToPharmacies",
|
||||
RoomToPharmacy,
|
||||
"room_to_pharmacy",
|
||||
"room_to_pharmacy.room_id = room.id"
|
||||
)
|
||||
.leftJoinAndMapOne(
|
||||
"room_to_pharmacy.pharmacy_room",
|
||||
Room,
|
||||
"pharmacy_room",
|
||||
"pharmacy_room.id = room_to_pharmacy.pharmacy_room_id"
|
||||
)
|
||||
.where("department.id IN (:...departmentIds)", {
|
||||
departmentIds: [
|
||||
'42bc42a7-e2a7-4f95-a788-9d9e51a51a20',
|
||||
'3fc39ff1-b4bc-4276-92ef-def7ca9432fb',
|
||||
'a0d2ef11-6927-4e5c-8628-6acf26351071',
|
||||
]
|
||||
})
|
||||
.orderBy("room." + param.order_field, param.order_direction as "ASC" | "DESC");
|
||||
|
||||
if (param.with_deleted) {
|
||||
res_count.withDeleted();
|
||||
res_list.withDeleted();
|
||||
roomQuery.withDeleted();
|
||||
}
|
||||
|
||||
const current_page = param.page;
|
||||
const total_count_data = await res_count.getCount();
|
||||
const list_data = await res_list.getMany();
|
||||
const count_data = CommonHelper.countObject(list_data);
|
||||
// Filter tambahan jika ada
|
||||
if (filter.room) {
|
||||
roomQuery.andWhere("room.room ILIKE :room", { room: `%${filter.room}%` });
|
||||
}
|
||||
if (filter.status) {
|
||||
roomQuery.andWhere("room.status = :status", { status: filter.status });
|
||||
}
|
||||
|
||||
return ReturnHelper.successResponselist(res, 200, Language.lang.success_view, count_data, current_page, total_count_data, list_data);
|
||||
const total_count_data = await roomQuery.clone().getCount();
|
||||
|
||||
const rooms = await roomQuery
|
||||
.offset(offset)
|
||||
.limit(limit)
|
||||
.getMany();
|
||||
|
||||
// Transform: { room_name: { pharmacy_room_1: {}, pharmacy_room_2: {} } }
|
||||
const list_data_return = rooms.map((room: any) => {
|
||||
const roomToPharmacies: any[] = room.roomToPharmacies ?? [];
|
||||
|
||||
const pharmacyRooms: Record<string, any> = {};
|
||||
roomToPharmacies.forEach((rtp: any, index: number) => {
|
||||
const pharmacy: Room | null = rtp.pharmacy_room ?? null;
|
||||
pharmacyRooms[`pharmacy_room_${index + 1}`] = pharmacy ? {
|
||||
id: pharmacy.id,
|
||||
room: pharmacy.room,
|
||||
code: pharmacy.code,
|
||||
description: pharmacy.description ?? null,
|
||||
status: pharmacy.status,
|
||||
} : null;
|
||||
});
|
||||
|
||||
return {
|
||||
rooms: {
|
||||
id: room.id,
|
||||
room: room.room,
|
||||
code: room.code,
|
||||
description: room.description ?? null,
|
||||
status: room.status,
|
||||
department: room.department ? {
|
||||
id: room.department.id,
|
||||
name: room.department.name,
|
||||
} : null,
|
||||
pharmacy_rooms: Object.keys(pharmacyRooms).length > 0
|
||||
? pharmacyRooms
|
||||
: null,
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
const count_data = CommonHelper.countObject(list_data_return);
|
||||
|
||||
return ReturnHelper.successResponselist(
|
||||
res,
|
||||
200,
|
||||
Language.lang.success_view,
|
||||
count_data,
|
||||
param.page,
|
||||
total_count_data,
|
||||
list_data_return
|
||||
);
|
||||
} catch (e: unknown) {
|
||||
log.error(e);
|
||||
const err = e as Error;
|
||||
@ -194,7 +262,7 @@ export class RoomToPharmacyController {
|
||||
const data = new RoomToPharmacy()
|
||||
data.pharmacy_room = param.pharmacy_room_id;
|
||||
data.room = param.room_id;
|
||||
data.created_by = req.auth.data.name;
|
||||
data.created_by = req.auth?.data.name;
|
||||
|
||||
await OrmHelper.DB.manager.save(data);
|
||||
|
||||
@ -317,12 +385,29 @@ export class RoomToPharmacyController {
|
||||
*/
|
||||
try {
|
||||
const schema = Joi.object().keys({
|
||||
id: Joi.string().uuid().required().label("RoomToPharmacy Id"),
|
||||
id: Joi.string().uuid().required().label("Room Id"),
|
||||
});
|
||||
|
||||
let param: any = await schema.validateAsync(req.params);
|
||||
|
||||
let data = await RoomToPharmacyModel.list({ "id": param.id }).then((q) => q.getOne());
|
||||
let data = await OrmHelper.DB.getRepository(Room)
|
||||
.createQueryBuilder("room")
|
||||
.leftJoinAndSelect("room.department", "department")
|
||||
.leftJoinAndMapMany(
|
||||
"room.roomToPharmacies",
|
||||
RoomToPharmacy,
|
||||
"room_to_pharmacy",
|
||||
"room_to_pharmacy.room_id = room.id"
|
||||
)
|
||||
.leftJoinAndMapOne(
|
||||
"room_to_pharmacy.pharmacy_room",
|
||||
Room,
|
||||
"pharmacy_room",
|
||||
"pharmacy_room.id = room_to_pharmacy.pharmacy_room_id"
|
||||
)
|
||||
.where("room.id = :id", { id: param.id })
|
||||
.getOne();
|
||||
|
||||
if (!data) throw { message: "RoomToPharmacy Not Found" };
|
||||
|
||||
return ReturnHelper.successResponseAny(res, 200, Language.lang.success_view, data);
|
||||
|
||||
@ -39,28 +39,85 @@ export class UserToRoomController {
|
||||
|
||||
let filter = param.filter && param.filter !== "" ? JSON.parse(param.filter) : {};
|
||||
|
||||
var query = await UserToRoomModel.list(filter);
|
||||
|
||||
const offset = (param.page - 1) * param.limit;
|
||||
let limit = param.limit;
|
||||
const limit = param.limit;
|
||||
|
||||
const res_count = query;
|
||||
const res_list = query
|
||||
.orderBy("user_to_room." + param.order_field, param.order_direction)
|
||||
.offset(offset)
|
||||
.limit(limit);
|
||||
// Query dari User sebagai root, leftJoin ke UserToRoom → Room
|
||||
const userQuery = OrmHelper.DB.getRepository(User)
|
||||
.createQueryBuilder("user")
|
||||
.leftJoinAndSelect("user.roles", "roles")
|
||||
.leftJoinAndMapMany(
|
||||
"user.userToRooms",
|
||||
UserToRoom,
|
||||
"user_to_room",
|
||||
"user_to_room.user = user.id"
|
||||
)
|
||||
.leftJoinAndMapOne(
|
||||
"user_to_room.roomData",
|
||||
Room,
|
||||
"room",
|
||||
"room.id = user_to_room.room"
|
||||
)
|
||||
.orderBy("user." + param.order_field, param.order_direction as "ASC" | "DESC");
|
||||
|
||||
if (param.with_deleted) {
|
||||
res_count.withDeleted();
|
||||
res_list.withDeleted();
|
||||
userQuery.withDeleted();
|
||||
}
|
||||
|
||||
const current_page = param.page;
|
||||
const total_count_data = await res_count.getCount();
|
||||
const list_data = await res_list.getMany();
|
||||
const count_data = CommonHelper.countObject(list_data);
|
||||
// Filter jika ada
|
||||
if (filter.name) {
|
||||
userQuery.andWhere("user.name ILIKE :name", { name: `%${filter.name}%` });
|
||||
}
|
||||
if (filter.status) {
|
||||
userQuery.andWhere("user.status = :status", { status: filter.status });
|
||||
}
|
||||
|
||||
return ReturnHelper.successResponselist(res, 200, Language.lang.success_view, count_data, current_page, total_count_data, list_data);
|
||||
const total_count_data = await userQuery.clone().getCount();
|
||||
|
||||
const users = await userQuery
|
||||
.offset(offset)
|
||||
.limit(limit)
|
||||
.getMany();
|
||||
|
||||
// Transform data
|
||||
const list_data_return = users.map((user: any) => {
|
||||
const userToRooms: any[] = user.userToRooms ?? [];
|
||||
|
||||
const rooms: Record<string, any> = {};
|
||||
userToRooms.forEach((utr: any, index: number) => {
|
||||
const room = utr.roomData ?? null;
|
||||
rooms[`room_${index + 1}`] = room ? {
|
||||
id: room.id,
|
||||
room: room.room,
|
||||
code: room.code,
|
||||
} : null;
|
||||
});
|
||||
|
||||
return {
|
||||
id: user.id,
|
||||
name: user.name,
|
||||
username: user.username,
|
||||
email: user.email,
|
||||
status: user.status,
|
||||
roles: user.roles ? user.roles.map((role: any) => ({
|
||||
id: role.id,
|
||||
name: role.name,
|
||||
})) : [],
|
||||
rooms: Object.keys(rooms).length > 0 ? rooms : null,
|
||||
};
|
||||
});
|
||||
|
||||
const count_data = CommonHelper.countObject(list_data_return);
|
||||
|
||||
return ReturnHelper.successResponselist(
|
||||
res,
|
||||
200,
|
||||
Language.lang.success_view,
|
||||
count_data,
|
||||
param.page,
|
||||
total_count_data,
|
||||
list_data_return
|
||||
);
|
||||
} catch (e: unknown) {
|
||||
log.error(e);
|
||||
const err = e as Error;
|
||||
@ -205,7 +262,7 @@ export class UserToRoomController {
|
||||
const data = new UserToRoom()
|
||||
data.user = param.user_id;
|
||||
data.room = param.room_id;
|
||||
data.created_by = req.auth.data.name;
|
||||
data.created_by = req.auth?.data.name;
|
||||
|
||||
await OrmHelper.DB.manager.save(data);
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import config from 'config';
|
||||
import { DataSource } from "typeorm";
|
||||
import { ILogObj, Logger } from 'tslog';
|
||||
import { RefferalHospital,RegistrationFee,FareType, RoomStock, Administrativu, Aldeia, District, Menu, Munisipo, Suco, Application, Nationality, Diagnosis, DiagnosticProcedure, Room, ServiceType, ServiceClass, Service, ServiceFare, ServicePackage, Department, DoctorSchedule, MeasurementUnit, ReferenceRange, QueueMonitoring, ExaminationDetail, ExaminationType, User, UserRole, HrmsEmployee, HrmsDepartment, HrmsPosition, HrmsShift, HospitalInformation, ItemOrigin, ItemType, ItemTypeDetail, Unit, ItemCategory, ItemStatus, UsageInstructions, UsageTime, ItemClass, ItemClassDetail, GenericName, Factory, Supplier, FactoryToSupplier, ItemMaster, ItemGroup, PharmacyInfo, ItemPrice, SellingPricePercentage, PatientGroup, PatientGuarantor, InitialStock, DoctorItem, DoctorItemPackage, UserToRoom, RoomToPharmacy, PlanningVerificator, ScheduleSeries, ScheduleException, CardType, PaymentMethod } from 'entity'
|
||||
import { Province,City,Subdistrict,Ward, RefferalHospital,RegistrationFee,FareType, RoomStock, Administrativu, Aldeia, District, Menu, Munisipo, Suco, Application, Nationality, Diagnosis, DiagnosticProcedure, Room, ServiceType, ServiceClass, Service, ServiceFare, ServicePackage, Department, DoctorSchedule, MeasurementUnit, ReferenceRange, QueueMonitoring, ExaminationDetail, ExaminationType, User, UserRole, HrmsEmployee, HrmsDepartment, HrmsPosition, HrmsShift, HospitalInformation, ItemOrigin, ItemType, ItemTypeDetail, Unit, ItemCategory, ItemStatus, UsageInstructions, UsageTime, ItemClass, ItemClassDetail, GenericName, Factory, Supplier, FactoryToSupplier, ItemMaster, ItemGroup, PharmacyInfo, ItemPrice, SellingPricePercentage, PatientGroup, PatientGuarantor, InitialStock, DoctorItem, DoctorItemPackage, UserToRoom, RoomToPharmacy, PlanningVerificator, ScheduleSeries, ScheduleException, CardType, PaymentMethod } from 'entity'
|
||||
|
||||
export class OrmHelper {
|
||||
static DB: DataSource = null
|
||||
@ -54,7 +54,7 @@ export class OrmHelper {
|
||||
CardType,
|
||||
PaymentMethod,
|
||||
RegistrationFee,
|
||||
RefferalHospital
|
||||
RefferalHospital,Province,City,Subdistrict,Ward
|
||||
],
|
||||
subscribers: [],
|
||||
migrations: [],
|
||||
|
||||
@ -18,7 +18,11 @@ export class PharmacyInfoModel {
|
||||
.leftJoinAndSelect("pharmacy_info.munisipiu", "munisipiu")
|
||||
.leftJoinAndSelect("pharmacy_info.postu_admin", "postu_admin")
|
||||
.leftJoinAndSelect("pharmacy_info.suco", "suco")
|
||||
.leftJoinAndSelect("pharmacy_info.aldeia", "aldeia");
|
||||
.leftJoinAndSelect("pharmacy_info.aldeia", "aldeia")
|
||||
.leftJoinAndSelect("pharmacy_info.province", "province")
|
||||
.leftJoinAndSelect("pharmacy_info.city", "city")
|
||||
.leftJoinAndSelect("pharmacy_info.subdistrict", "subdistrict")
|
||||
.leftJoinAndSelect("pharmacy_info.ward", "ward");
|
||||
if (whereAttr.length != 0) {
|
||||
query = query.where(whereAttr.join(" and "), whereVal);
|
||||
}
|
||||
|
||||
@ -1,21 +1,20 @@
|
||||
import { SelectQueryBuilder } from "typeorm";
|
||||
import CommonHelper from "../helpers/common";
|
||||
import { OrmHelper } from "../helpers/orm";
|
||||
import { RoomToPharmacy } from "entity";
|
||||
import { RoomToPharmacy, Room } from "entity";
|
||||
|
||||
export class RoomToPharmacyModel {
|
||||
static async list(filter = {}): Promise<SelectQueryBuilder<any>> {
|
||||
|
||||
const repo = OrmHelper.DB.getRepository(RoomToPharmacy);
|
||||
let whereAttr: string[] = [];
|
||||
let whereVal: any = {};
|
||||
if (filter && Object.keys(filter).length > 0) {
|
||||
whereAttr = [...whereAttr, ...CommonHelper.handleQueryFilter(filter, "room_to_pharmacy").whereAttr];
|
||||
whereVal = { ...whereVal, ...CommonHelper.handleQueryFilter(filter, "room_to_pharmacy").whereVal };
|
||||
whereAttr = [...whereAttr, ...CommonHelper.handleQueryFilter(filter).whereAttr];
|
||||
whereVal = { ...whereVal, ...CommonHelper.handleQueryFilter(filter).whereVal };
|
||||
}
|
||||
|
||||
var query = repo.createQueryBuilder("room_to_pharmacy")
|
||||
.leftJoinAndSelect("room_to_pharmacy.room", "room")
|
||||
.leftJoinAndSelect("room_to_pharmacy.pharmacy_room", "pharmacy_room");
|
||||
var query = repo.createQueryBuilder("room_to_pharmacy");
|
||||
if (whereAttr.length != 0) {
|
||||
query = query.where(whereAttr.join(" and "), whereVal);
|
||||
}
|
||||
|
||||
@ -63,6 +63,7 @@ import { FareTypeController } from '../controllers/faretype';
|
||||
import { CardTypeController } from '../controllers/card_type';
|
||||
import { PaymentMethodController } from '../controllers/payment-method';
|
||||
import { RegistrationFeeController } from '../controllers/registrationfee';
|
||||
import { RegionController } from '../controllers/region';
|
||||
|
||||
export class RoutePrivate {
|
||||
static setup(app: express.Application) {
|
||||
@ -484,5 +485,10 @@ export class RoutePrivate {
|
||||
app.get('/api/registration-fee/detail', RegistrationFeeController.detail)
|
||||
app.post('/api/registration-fee/create', RegistrationFeeController.create)
|
||||
app.put('/api/registration-fee/update/:id', RegistrationFeeController.update)
|
||||
|
||||
app.get('/api/region/province', RegionController.province)
|
||||
app.get('/api/region/city/:province_code', RegionController.city)
|
||||
app.get('/api/region/subdistrict/:city_code', RegionController.subdistrict)
|
||||
app.get('/api/region/ward/:subdistric_code', RegionController.ward)
|
||||
}
|
||||
}
|
||||
|
||||
@ -319,6 +319,10 @@ const doc = {
|
||||
$aldeia: "Aldeia ID (UUID)",
|
||||
$phone: "Phone (string, max 30, optional)",
|
||||
$default_room_id: "Default Room ID (UUID)",
|
||||
$province: "Province Code",
|
||||
$city: "City Code",
|
||||
$subdistrict: "Subdistrict Code",
|
||||
$ward: "Ward Code",
|
||||
},
|
||||
item_price: {
|
||||
$item_master_id: "Item Master ID (required, UUID)",
|
||||
|
||||
Reference in New Issue
Block a user