no message

This commit is contained in:
kittapath 2024-09-24 16:42:24 +07:00
parent 317920ad0d
commit b2b97aecf0
6 changed files with 225 additions and 6 deletions

View file

@ -234,6 +234,78 @@ export class CommandController extends Controller {
return new HttpSuccess();
}
/**
* API tab2
*
* @summary API tab2
*
* @param {string} id Id
*/
@Get("tab2/{id}")
async GetByIdTab2(@Path() id: string) {
const command = await this.commandRepository.findOne({
where: { id },
relations: ["commandSalary", "commandRecives"],
});
if (!command) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลคำสั่งนี้");
}
const _command = {
id: command.id,
commandSalaryId: command.commandSalaryId,
commandSalary: command.commandSalary?.name || null,
positionDetail: command.positionDetail,
sendCC: command.commandRecives
.sort((a, b) => a.order - b.order)
.map((x) => ({
citizenId: x.citizenId,
prefix: x.prefix,
fristName: x.fristName,
lastName: x.lastName,
profileId: x.profileId,
order: x.order,
})),
};
return new HttpSuccess(_command);
}
/**
* API body Tab2
*
* @summary API body Tab2
*
* @param {string} id Id
*/
@Put("tab2/{id}")
async PutTab2(
@Path() id: string,
@Body()
requestBody: {
commandNo: string | null;
commandYear: number | null;
issue: string | null;
detailHeader: string | null;
detailBody: string | null;
detailFooter: string | null;
commandAffectDate: Date | null;
commandExcecuteDate: Date | null;
},
@Request() request: RequestWithUser,
) {
const command = await this.commandRepository.findOne({ where: { id: id } });
if (!command) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลคำสั่งนี้");
}
const data = new Command();
Object.assign(data, { ...command, ...requestBody });
data.lastUpdateUserId = request.user.sub;
data.lastUpdateFullName = request.user.name;
data.lastUpdatedAt = new Date();
await this.commandRepository.save(data);
return new HttpSuccess();
}
/**
* API tab3
*
@ -526,6 +598,7 @@ export class CommandController extends Controller {
status: command.status,
isDraft: command.isDraft,
isSign: command.isSign,
isAttachment: command.isAttachment,
};
return new HttpSuccess(_command);
}
@ -568,14 +641,14 @@ export class CommandController extends Controller {
async PutSelectDraft(
@Path() id: string,
@Body()
requestBody: { sign?: boolean },
requestBody: { sign: boolean },
@Request() request: RequestWithUser,
) {
const command = await this.commandRepository.findOne({ where: { id: id } });
if (!command) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลคำสั่งนี้");
}
command.isDraft = true;
command.isDraft = requestBody.sign;
command.status = "PENDING";
command.lastUpdateUserId = request.user.sub;
command.lastUpdateFullName = request.user.name;