Merge branch 'warunee-dev' into develop

* warunee-dev:
  add auth sync by menu

# Conflicts:
#	src/controllers/AuthSysController.ts
This commit is contained in:
Warunee Tamkoo 2024-06-12 13:25:53 +07:00
commit 225063e8b7
2 changed files with 50 additions and 11 deletions

View file

@ -27,11 +27,25 @@ export class AuthSysController extends Controller {
@Get("list")
public async listAuthSys() {
const getList = await this.authSysRepo.find();
const getList = await this.authSysRepo.find({
select: ["id", "parentId", "sysName", "sysDescription", "order"],
});
if (!getList || getList.length === 0) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
}
return new HttpSuccess(getList);
const lists = getList
.filter((x) => x.parentId == null)
.map((item) => {
return {
...item,
children: getList.filter((x) => x.parentId == item.id).sort((a, b) => a.order - b.order),
};
})
.sort((a, b) => a.order - b.order);
return new HttpSuccess(lists);
}
@Get("{systemId}")

View file

@ -1,12 +1,4 @@
import {
Entity,
Column,
OneToMany,
CreateDateColumn,
UpdateDateColumn,
PrimaryColumn,
} from "typeorm";
import { AuthRoleAttr } from "./AuthRoleAttr";
import { Entity, Column, CreateDateColumn, UpdateDateColumn, PrimaryColumn } from "typeorm";
@Entity("authSys")
export class AuthSys {
@ -16,6 +8,36 @@ export class AuthSys {
})
id: string;
@Column({
comment: "Id ของเมนูหลักถ้าเป็นเมนูหลักจะเป็นค่า null",
nullable: true,
default: null,
length: 255,
})
parentId!: string;
@Column({
comment: "ชื่อ icon",
nullable: true,
default: null,
length: 100,
})
icon!: string;
@Column({
comment: "path url ของระบบ",
nullable: true,
default: null,
length: 255,
})
path!: string;
@Column({
comment: "ลำดับการแสดงผล",
default: 0,
})
order: number;
@CreateDateColumn({ comment: "สร้างข้อมูลเมื่อ" })
createdAt!: Date;
@ -66,6 +88,9 @@ export class CreateAuthSys {
@PrimaryColumn()
id: string;
@Column()
parentId: string;
@Column()
sysName: string;