add role parent

This commit is contained in:
mamoss 2025-11-29 14:56:58 +07:00
parent 072d9a6880
commit bd9c270cd7
9 changed files with 231 additions and 241 deletions

View file

@ -52,7 +52,7 @@ export class DevelopmentRequestController extends Controller {
if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
}
let query = await AppDataSource.getRepository(DevelopmentRequest)
.createQueryBuilder("developmentRequest")
.andWhere(
@ -104,16 +104,13 @@ export class DevelopmentRequestController extends Controller {
);
}),
)
.orderBy("developmentRequest.createdAt", "DESC")
.orderBy("developmentRequest.createdAt", "DESC");
if (sortBy) {
query = query.orderBy(
`developmentRequest.${sortBy}`,
descending ? "DESC" : "ASC"
);
}
if (sortBy) {
query = query.orderBy(`developmentRequest.${sortBy}`, descending ? "DESC" : "ASC");
}
const [lists, total] = await query
const [lists, total] = await query
.skip((page - 1) * pageSize)
.take(pageSize)
.getManyAndCount();
@ -166,7 +163,7 @@ export class DevelopmentRequestController extends Controller {
data.child1 != undefined && data.child1 != null
? data.child1[0] != null
? `current_holders.orgChild1Id IN (:...child1)`
: `current_holders.orgChild1Id is null`
: `current_holders.orgChild1Id is ${data.privilege == "PARENT" ? "not null" : "null"}`
: "1=1",
{
child1: data.child1,
@ -250,21 +247,17 @@ export class DevelopmentRequestController extends Controller {
);
}),
)
.orderBy("developmentRequest.createdAt", "DESC")
.orderBy("developmentRequest.createdAt", "DESC");
if (sortBy) {
query = query.orderBy(
`developmentRequest.${sortBy}`,
descending ? "DESC" : "ASC"
);
query = query.orderBy(`developmentRequest.${sortBy}`, descending ? "DESC" : "ASC");
}
const [lists, total] = await query
.skip((page - 1) * pageSize)
.take(pageSize)
.getManyAndCount();
const [lists, total] = await query
.skip((page - 1) * pageSize)
.take(pageSize)
.getManyAndCount();
const _data = lists.map((item) => ({ ...item, profile: null }));
return new HttpSuccess({ data: _data, total });
}