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