sort master/list
This commit is contained in:
parent
a92f7eca09
commit
a37405ee48
1 changed files with 44 additions and 48 deletions
|
|
@ -651,7 +651,7 @@ export class PositionController extends Controller {
|
|||
try {
|
||||
const posMaster = await this.posMasterRepository.findOne({
|
||||
where: { id },
|
||||
relations: ["posType", "posLevel", "posExecutive"],
|
||||
// relations: ["posType", "posLevel", "posExecutive"],
|
||||
});
|
||||
if (!posMaster) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
|
|
@ -780,6 +780,7 @@ export class PositionController extends Controller {
|
|||
...typeCondition,
|
||||
...checkChildConditions,
|
||||
},
|
||||
order: { posMasterOrder: "DESC" },
|
||||
skip: (body.page - 1) * body.pageSize,
|
||||
take: body.pageSize,
|
||||
});
|
||||
|
|
@ -793,7 +794,7 @@ export class PositionController extends Controller {
|
|||
posMaster.map(async (posMaster) => {
|
||||
const positions = await this.positionRepository.find({
|
||||
where: { posMasterId: posMaster.id },
|
||||
relations:["posLevel","posType","posExecutive"]
|
||||
relations: ["posLevel", "posType", "posExecutive"],
|
||||
});
|
||||
|
||||
return {
|
||||
|
|
@ -819,18 +820,18 @@ export class PositionController extends Controller {
|
|||
};
|
||||
}),
|
||||
);
|
||||
return new HttpSuccess({data:formattedData,total});
|
||||
return new HttpSuccess({ data: formattedData, total });
|
||||
} catch (error) {
|
||||
return error;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* API จัดลำดับตำแหน่ง
|
||||
*
|
||||
* @summary ORG_040 - จัดลำดับตำแหน่ง (ADMIN) #43
|
||||
*
|
||||
*/
|
||||
* API จัดลำดับตำแหน่ง
|
||||
*
|
||||
* @summary ORG_040 - จัดลำดับตำแหน่ง (ADMIN) #43
|
||||
*
|
||||
*/
|
||||
@Post("sort")
|
||||
async Sort(@Body() requestBody: { id: string; type: number; sortId: string[] }) {
|
||||
try {
|
||||
|
|
@ -840,16 +841,15 @@ export class PositionController extends Controller {
|
|||
where: { orgRootId: requestBody.id },
|
||||
});
|
||||
if (!rootId?.id) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"not found rootId: " + requestBody.id,
|
||||
);
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found rootId: " + requestBody.id);
|
||||
}
|
||||
const listPosMasterId_0 = await this.posMasterRepository.find({
|
||||
where: {
|
||||
orgRootId: requestBody.id,
|
||||
orgChild1Id: IsNull(), orgChild2Id: IsNull(),
|
||||
orgChild3Id: IsNull(), orgChild4Id: IsNull(),
|
||||
where: {
|
||||
orgRootId: requestBody.id,
|
||||
orgChild1Id: IsNull(),
|
||||
orgChild2Id: IsNull(),
|
||||
orgChild3Id: IsNull(),
|
||||
orgChild4Id: IsNull(),
|
||||
},
|
||||
select: ["id", "posMasterOrder"],
|
||||
});
|
||||
|
|
@ -869,16 +869,15 @@ export class PositionController extends Controller {
|
|||
where: { orgChild1Id: requestBody.id },
|
||||
});
|
||||
if (!child1Id?.id) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"not found child1Id: " + requestBody.id,
|
||||
);
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found child1Id: " + requestBody.id);
|
||||
}
|
||||
const listPosMasterId_1 = await this.posMasterRepository.find({
|
||||
where: {
|
||||
orgRootId: Not(IsNull()),
|
||||
orgChild1Id: requestBody.id, orgChild2Id: IsNull(),
|
||||
orgChild3Id: IsNull(), orgChild4Id: IsNull(),
|
||||
where: {
|
||||
orgRootId: Not(IsNull()),
|
||||
orgChild1Id: requestBody.id,
|
||||
orgChild2Id: IsNull(),
|
||||
orgChild3Id: IsNull(),
|
||||
orgChild4Id: IsNull(),
|
||||
},
|
||||
select: ["id", "posMasterOrder"],
|
||||
});
|
||||
|
|
@ -898,16 +897,15 @@ export class PositionController extends Controller {
|
|||
where: { orgChild2Id: requestBody.id },
|
||||
});
|
||||
if (!child2Id?.id) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"not found child2Id: " + requestBody.id,
|
||||
);
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found child2Id: " + requestBody.id);
|
||||
}
|
||||
const listPosMasterId_2 = await this.posMasterRepository.find({
|
||||
where: {
|
||||
orgRootId: Not(IsNull()),
|
||||
orgChild1Id: Not(IsNull()), orgChild2Id: requestBody.id,
|
||||
orgChild3Id: IsNull(), orgChild4Id: IsNull(),
|
||||
where: {
|
||||
orgRootId: Not(IsNull()),
|
||||
orgChild1Id: Not(IsNull()),
|
||||
orgChild2Id: requestBody.id,
|
||||
orgChild3Id: IsNull(),
|
||||
orgChild4Id: IsNull(),
|
||||
},
|
||||
select: ["id", "posMasterOrder"],
|
||||
});
|
||||
|
|
@ -927,16 +925,15 @@ export class PositionController extends Controller {
|
|||
where: { orgChild3Id: requestBody.id },
|
||||
});
|
||||
if (!child3Id?.id) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"not found chil3Id: " + requestBody.id,
|
||||
);
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found chil3Id: " + requestBody.id);
|
||||
}
|
||||
const listPosMasterId_3 = await this.posMasterRepository.find({
|
||||
where: {
|
||||
orgRootId: Not(IsNull()),
|
||||
orgChild1Id: Not(IsNull()), orgChild2Id: Not(IsNull()),
|
||||
orgChild3Id: requestBody.id, orgChild4Id: IsNull(),
|
||||
where: {
|
||||
orgRootId: Not(IsNull()),
|
||||
orgChild1Id: Not(IsNull()),
|
||||
orgChild2Id: Not(IsNull()),
|
||||
orgChild3Id: requestBody.id,
|
||||
orgChild4Id: IsNull(),
|
||||
},
|
||||
select: ["id", "posMasterOrder"],
|
||||
});
|
||||
|
|
@ -956,16 +953,15 @@ export class PositionController extends Controller {
|
|||
where: { orgChild4Id: requestBody.id },
|
||||
});
|
||||
if (!child4Id?.id) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"not found child4Id: " + requestBody.id,
|
||||
);
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found child4Id: " + requestBody.id);
|
||||
}
|
||||
const listPosMasterId_4 = await this.posMasterRepository.find({
|
||||
where: {
|
||||
orgRootId: Not(IsNull()),
|
||||
orgChild1Id: Not(IsNull()), orgChild2Id: Not(IsNull()),
|
||||
orgChild3Id: Not(IsNull()), orgChild4Id: requestBody.id,
|
||||
where: {
|
||||
orgRootId: Not(IsNull()),
|
||||
orgChild1Id: Not(IsNull()),
|
||||
orgChild2Id: Not(IsNull()),
|
||||
orgChild3Id: Not(IsNull()),
|
||||
orgChild4Id: requestBody.id,
|
||||
},
|
||||
select: ["id", "posMasterOrder"],
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue