sort จังหวัด อำเภอ ตำบล

This commit is contained in:
Bright 2024-11-27 10:37:26 +07:00
parent b4b49b7378
commit 0fa198a771
3 changed files with 30 additions and 5 deletions

View file

@ -41,7 +41,10 @@ export class ProvinceController extends Controller {
async GetResult() {
const _province = await this.provinceRepository.find({
select: ["id", "name", "createdAt", "lastUpdatedAt", "createdFullName", "lastUpdateFullName"],
order: { createdAt: "DESC" },
order: {
name: "ASC",
createdAt: "DESC"
},
});
return new HttpSuccess(_province);
}
@ -57,8 +60,16 @@ export class ProvinceController extends Controller {
async GetById(@Path() id: string) {
const _province = await this.provinceRepository.findOne({
where: { id },
select: ["id", "name"],
select: ["id", "name", "createdAt"],
relations: { districts: true },
order: {
name: "ASC",
createdAt: "DESC",
districts: {
name: "ASC",
createdAt: "DESC"
}
},
});
if (!_province) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลจังหวัดนี้");