add auth sync by menu
This commit is contained in:
parent
79a0d847ce
commit
2f525bae95
2 changed files with 49 additions and 14 deletions
|
|
@ -27,11 +27,21 @@ export class AuthSysController extends Controller {
|
||||||
|
|
||||||
@Get("list")
|
@Get("list")
|
||||||
public async listAuthSys() {
|
public async listAuthSys() {
|
||||||
const getList = await this.authSysRepo.find();
|
const getList = await this.authSysRepo.find({
|
||||||
// if (!getList || getList.length === 0) {
|
select: ["id", "parentId", "sysName", "sysDescription", "order"],
|
||||||
// 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}")
|
@Get("{systemId}")
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,4 @@
|
||||||
import {
|
import { Entity, Column, CreateDateColumn, UpdateDateColumn, PrimaryColumn } from "typeorm";
|
||||||
Entity,
|
|
||||||
Column,
|
|
||||||
OneToMany,
|
|
||||||
CreateDateColumn,
|
|
||||||
UpdateDateColumn,
|
|
||||||
PrimaryColumn,
|
|
||||||
} from "typeorm";
|
|
||||||
import { AuthRoleAttr } from "./AuthRoleAttr";
|
|
||||||
|
|
||||||
@Entity("authSys")
|
@Entity("authSys")
|
||||||
export class AuthSys {
|
export class AuthSys {
|
||||||
|
|
@ -16,6 +8,36 @@ export class AuthSys {
|
||||||
})
|
})
|
||||||
id: string;
|
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: "สร้างข้อมูลเมื่อ" })
|
@CreateDateColumn({ comment: "สร้างข้อมูลเมื่อ" })
|
||||||
createdAt!: Date;
|
createdAt!: Date;
|
||||||
|
|
||||||
|
|
@ -66,6 +88,9 @@ export class CreateAuthSys {
|
||||||
@PrimaryColumn()
|
@PrimaryColumn()
|
||||||
id: string;
|
id: string;
|
||||||
|
|
||||||
|
@Column()
|
||||||
|
parentId: string;
|
||||||
|
|
||||||
@Column()
|
@Column()
|
||||||
sysName: string;
|
sysName: string;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue