fix กรณีเรียกใช้ api มากกว่า 1 เมนู
This commit is contained in:
parent
fb007073ce
commit
76e2de989e
2 changed files with 96 additions and 9 deletions
|
|
@ -147,8 +147,7 @@ export class InsigniaController extends Controller {
|
|||
* @param {string} id Id เครื่องราชอิสริยาภรณ์
|
||||
*/
|
||||
@Get("{id}")
|
||||
async GetInsigniaById(@Path() id: string, @Request() request: RequestWithUser) {
|
||||
await new permission().PermissionGet(request, "SYS_INSIGNIA_RECORD");
|
||||
async GetInsigniaById(@Path() id: string) {
|
||||
const insignia = await this.insigniaRepository.findOne({
|
||||
relations: ["insigniaType"],
|
||||
select: [
|
||||
|
|
@ -187,8 +186,7 @@ export class InsigniaController extends Controller {
|
|||
*
|
||||
*/
|
||||
@Get()
|
||||
async GetInsignia(@Request() request: RequestWithUser) {
|
||||
await new permission().PermissionList(request, "SYS_INSIGNIA_RECORD");
|
||||
async GetInsignia() {
|
||||
const insigniaAll = await this.insigniaRepository.find({
|
||||
relations: ["insigniaType"],
|
||||
select: [
|
||||
|
|
@ -220,6 +218,65 @@ export class InsigniaController extends Controller {
|
|||
return new HttpSuccess(mapInsigniaAll);
|
||||
}
|
||||
|
||||
/**
|
||||
* API รายการเครื่องราชอิสริยาภรณ์ (เช็คสิทธิ์)
|
||||
*
|
||||
* @summary ORG_ - รายการเครื่องราชอิสริยาภรณ์ (ADMIN) #เช็คสิทธิ์
|
||||
*
|
||||
* @param {string} path เมนูเช็คสิทธิ์
|
||||
*/
|
||||
@Get("path/{path}")
|
||||
async GetInsigniaPath(@Path() path: string, @Request() request: RequestWithUser) {
|
||||
path = path.toLocaleUpperCase();
|
||||
let getPermission: string = "";
|
||||
if(path == "MANAGE") {
|
||||
getPermission = "SYS_INSIGNIA_MANAGE"
|
||||
}
|
||||
else if(path == "RECORD") {
|
||||
getPermission = "SYS_INSIGNIA_RECORD"
|
||||
}
|
||||
else if(path == "ALLOCATE") {
|
||||
getPermission = "SYS_INSIGNIA_ALLOCATE"
|
||||
}
|
||||
else if(path == "BORROW") {
|
||||
getPermission = "SYS_INSIGNIA_BORROW"
|
||||
}
|
||||
else {
|
||||
getPermission = "SYS_INSIGNIA_MANAGE"
|
||||
}
|
||||
await new permission().PermissionList(request, getPermission);
|
||||
const insigniaAll = await this.insigniaRepository.find({
|
||||
relations: ["insigniaType"],
|
||||
select: [
|
||||
"id",
|
||||
"name",
|
||||
"shortName",
|
||||
"createdAt",
|
||||
"lastUpdatedAt",
|
||||
"lastUpdateFullName",
|
||||
"isActive",
|
||||
"note",
|
||||
"insigniaTypeId",
|
||||
],
|
||||
where: { isActive: true },
|
||||
order: { level: "ASC" },
|
||||
});
|
||||
|
||||
const mapInsigniaAll = insigniaAll.map((item) => ({
|
||||
id: item.id,
|
||||
name: item.name,
|
||||
shortName: item.shortName,
|
||||
insigniaTypeId: item.insigniaTypeId ?? null,
|
||||
insigniaTypeName: item.insigniaType == null ? null : item.insigniaType.name, //ลำดับชั้นเครื่องราช
|
||||
createdAt: item.createdAt,
|
||||
lastUpdatedAt: item.lastUpdatedAt,
|
||||
lastUpdateFullName: item.lastUpdateFullName,
|
||||
isActive: item.isActive,
|
||||
note: item.note,
|
||||
}));
|
||||
return new HttpSuccess(mapInsigniaAll);
|
||||
}
|
||||
|
||||
/**
|
||||
* API จัดลำดับแสดงผลเครื่องราชอิสริยาภรณ์
|
||||
*
|
||||
|
|
|
|||
|
|
@ -161,8 +161,7 @@ export class InsigniaTypeController extends Controller {
|
|||
* @param {string} id Id ลำดับชั้นเครื่องราชอิสริยาภรณ์
|
||||
*/
|
||||
@Get("{id}")
|
||||
async GetInsigniaTypeById(@Path() id: string, @Request() request: RequestWithUser) {
|
||||
await new permission().PermissionGet(request, "SYS_INSIGNIA_RECORD");
|
||||
async GetInsigniaTypeById(@Path() id: string) {
|
||||
const insigniaType = await this.insigniaTypeRepository.findOne({
|
||||
relations: ["insignias"],
|
||||
select: ["id", "name", "createdAt", "lastUpdatedAt", "lastUpdateFullName", "isActive"],
|
||||
|
|
@ -183,13 +182,44 @@ export class InsigniaTypeController extends Controller {
|
|||
* @summary ORG_ - รายการลำดับชั้นเครื่องราชอิสริยาภรณ์ (ADMIN) #
|
||||
*
|
||||
*/
|
||||
@Get("")
|
||||
async GetInsigniaType(@Request() request: RequestWithUser) {
|
||||
await new permission().PermissionList(request, "SYS_INSIGNIA_RECORD");
|
||||
@Get()
|
||||
async GetInsigniaType() {
|
||||
const insigniaTypeAll = await this.insigniaTypeRepository.find({
|
||||
select: ["id", "name", "createdAt", "lastUpdatedAt", "lastUpdateFullName", "isActive"],
|
||||
order: { name: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(insigniaTypeAll);
|
||||
}
|
||||
|
||||
/**
|
||||
* API รายการลำดับชั้นเครื่องราชอิสริยาภรณ์ (เช็คสิทธิ์)
|
||||
*
|
||||
* @summary ORG_ - รายการลำดับชั้นเครื่องราชอิสริยาภรณ์ (ADMIN) #เช็คสิทธิ์
|
||||
*
|
||||
* @param {string} path เมนูเช็คสิทธิ์
|
||||
*/
|
||||
@Get("path/{path}")
|
||||
async GetInsigniaTypePath(@Path() path: string, @Request() request: RequestWithUser) {
|
||||
path = path.toLocaleUpperCase();
|
||||
let getPermission: string = "";
|
||||
if(path == "RECORD") {
|
||||
getPermission = "SYS_INSIGNIA_RECORD"
|
||||
}
|
||||
else if(path == "ALLOCATE") {
|
||||
getPermission = "SYS_INSIGNIA_ALLOCATE"
|
||||
}
|
||||
else if(path == "BORROW") {
|
||||
getPermission = "SYS_INSIGNIA_BORROW"
|
||||
}
|
||||
else {
|
||||
getPermission = "SYS_INSIGNIA_RECORD"
|
||||
}
|
||||
await new permission().PermissionList(request, getPermission);
|
||||
const insigniaTypeAll = await this.insigniaTypeRepository.find({
|
||||
select: ["id", "name", "createdAt", "lastUpdatedAt", "lastUpdateFullName", "isActive"],
|
||||
where: {isActive : true},
|
||||
order: { name: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(insigniaTypeAll);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue