no message

This commit is contained in:
kittapath 2024-09-26 19:46:09 +07:00
parent 5ae266659a
commit 7d3839a195

View file

@ -19,7 +19,7 @@ import HttpSuccess from "../interfaces/http-success";
import HttpStatusCode from "../interfaces/http-status";
import HttpError from "../interfaces/http-error";
import { Command } from "../entities/Command";
import { Brackets, LessThan, MoreThan, Double } from "typeorm";
import { Brackets, LessThan, MoreThan, Double, In } from "typeorm";
import { CommandType } from "../entities/CommandType";
import { CommandSend } from "../entities/CommandSend";
import { Profile } from "../entities/Profile";
@ -111,7 +111,7 @@ export class CommandController extends Controller {
: `${commandTypeId}`,
},
)
.orderBy("command.createdAt", "ASC")
.orderBy("command.createdAt", "DESC")
.skip((page - 1) * pageSize)
.take(pageSize)
.getManyAndCount();
@ -699,7 +699,10 @@ export class CommandController extends Controller {
if (!command) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลคำสั่งนี้");
}
await this.commandSendCCRepository.delete({ commandSend: { commandId: command.id } });
const commandSend = await this.commandSendRepository.find({
where: { commandId: id },
});
await this.commandSendCCRepository.delete({ commandSendId: In(commandSend.map((x) => x.id)) });
await this.commandReciveRepository.delete({ commandId: command.id });
await this.commandSendRepository.delete({ commandId: command.id });
await this.commandRepository.delete(command.id);