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