fix(settings): room
This commit is contained in:
@ -58,40 +58,34 @@ export class RoomController {
|
||||
|
||||
var query = await RoomModel.list(filterObj);
|
||||
|
||||
query.leftJoinAndSelect("Room.department", "department");
|
||||
query.leftJoinAndSelect("Room.serviceclass", "serviceclass");
|
||||
|
||||
if (filterAny !== "") {
|
||||
const anyVal = filterAny.includes("%") ? filterAny : `%${filterAny}%`;
|
||||
query.andWhere(
|
||||
new Brackets((qb) => {
|
||||
qb.where("Room.code ILIKE :any", { any: anyVal }).orWhere("Room.room ILIKE :any", { any: anyVal });
|
||||
}),
|
||||
);
|
||||
|
||||
query.andWhere(
|
||||
new Brackets((qb) => {
|
||||
qb.where("department.name ILIKE :any", { any: anyVal }).orWhere("department.name ILIKE :any", { any: anyVal });
|
||||
qb.where("Room.code ILIKE :searchVal", { searchVal: anyVal })
|
||||
.orWhere("Room.room ILIKE :searchVal", { searchVal: anyVal })
|
||||
.orWhere("department.name ILIKE :searchVal", { searchVal: anyVal });
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
const offset = (param.page - 1) * param.limit;
|
||||
const res_count = query;
|
||||
const res_list = query
|
||||
.leftJoinAndSelect("Room.department", "department")
|
||||
.leftJoinAndSelect("Room.serviceclass", "serviceclass")
|
||||
.orderBy("Room." + param.order_field, param.order_direction)
|
||||
.take(param.limit)
|
||||
.skip(offset);
|
||||
|
||||
if (param.with_deleted) {
|
||||
res_count.withDeleted();
|
||||
res_list.withDeleted();
|
||||
}
|
||||
|
||||
const photoBaseUrl = config.server.host_swagger + "uploads/room-picture/";
|
||||
|
||||
const current_page = param.page;
|
||||
const total_count_data = await res_count.getCount();
|
||||
const list_data = await res_list.getMany();
|
||||
const [list_data, total_count_data] = await res_list.getManyAndCount();
|
||||
const mapped_data = list_data.map((item: any) => ({
|
||||
...item,
|
||||
picture: item.picture ? photoBaseUrl + item.picture : null,
|
||||
|
||||
Reference in New Issue
Block a user