no message
This commit is contained in:
parent
966d565ac6
commit
19e23bd8b1
2 changed files with 38 additions and 24 deletions
|
|
@ -995,7 +995,7 @@ export class EmployeePositionController extends Controller {
|
|||
where: {
|
||||
posMasterId: posMaster.id,
|
||||
},
|
||||
relations: ["posLevel", "posType", "posExecutive"],
|
||||
relations: ["posLevel", "posType"],
|
||||
});
|
||||
|
||||
let profile: any;
|
||||
|
|
|
|||
|
|
@ -21,8 +21,8 @@ import HttpSuccess from "../interfaces/http-success";
|
|||
import HttpStatusCode from "../interfaces/http-status";
|
||||
import HttpError from "../interfaces/http-error";
|
||||
import { Equal, ILike, In, IsNull, Like, Not, Brackets, Between } from "typeorm";
|
||||
import { InsigniaType, CreateInsigniaType, UpdateInsigniaType } from "../entities/InsigniaType";
|
||||
import { Insignia, CreateInsignias, UpdateInsignias } from "../entities/Insignia";
|
||||
import { InsigniaType, CreateInsigniaType, UpdateInsigniaType } from "../entities/InsigniaType";
|
||||
import { Insignia, CreateInsignias, UpdateInsignias } from "../entities/Insignia";
|
||||
|
||||
@Route("api/v1/org/insignia/insignia")
|
||||
@Tags("Insignia")
|
||||
|
|
@ -33,10 +33,9 @@ import { Insignia, CreateInsignias, UpdateInsignias } from "../entities/Insigni
|
|||
)
|
||||
@SuccessResponse(HttpStatusCode.OK, "สำเร็จ")
|
||||
export class InsigniaController extends Controller {
|
||||
|
||||
private insigniaTypeRepository = AppDataSource.getRepository(InsigniaType);
|
||||
private insigniaRepository = AppDataSource.getRepository(Insignia);
|
||||
|
||||
|
||||
/**
|
||||
* API เพิ่มข้อมูลเครื่องราชอิสริยาภรณ์
|
||||
*
|
||||
|
|
@ -48,13 +47,12 @@ export class InsigniaController extends Controller {
|
|||
@Body() requestBody: CreateInsignias,
|
||||
@Request() request: { user: Record<string, any> },
|
||||
) {
|
||||
|
||||
const insignia = Object.assign(new Insignia(), requestBody);
|
||||
if (!insignia) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
}
|
||||
const insigniaType = await this.insigniaTypeRepository.findOne({
|
||||
where: { id: requestBody.insigniaTypeId},
|
||||
where: { id: requestBody.insigniaTypeId },
|
||||
});
|
||||
if (!insigniaType) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลลำดับชั้นเครื่องราชอิสริยาภรณ์นี้");
|
||||
|
|
@ -97,7 +95,7 @@ export class InsigniaController extends Controller {
|
|||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลเครื่องราชอิสริยาภรณ์นี้");
|
||||
}
|
||||
const insigniaType = await this.insigniaTypeRepository.findOne({
|
||||
where: { id: requestBody.insigniaTypeId},
|
||||
where: { id: requestBody.insigniaTypeId },
|
||||
});
|
||||
if (!insigniaType) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลลำดับชั้นเครื่องราชอิสริยาภรณ์นี้");
|
||||
|
|
@ -142,13 +140,22 @@ export class InsigniaController extends Controller {
|
|||
*
|
||||
* @summary ORG_037 - รายละเอียดเครื่องราชอิสริยาภรณ์ (ADMIN) #
|
||||
*
|
||||
* @param {string} id Id เครื่องราชอิสริยาภรณ์
|
||||
* @param {string} id Id เครื่องราชอิสริยาภรณ์
|
||||
*/
|
||||
@Get("{id}")
|
||||
async GetInsigniaById(@Path() id: string) {
|
||||
const insignia = await this.insigniaRepository.findOne({
|
||||
relations: ["insigniaType"],
|
||||
select: ["id", "name", "shortName", "createdAt", "lastUpdatedAt", "lastUpdateFullName", "isActive", "note"],
|
||||
select: [
|
||||
"id",
|
||||
"name",
|
||||
"shortName",
|
||||
"createdAt",
|
||||
"lastUpdatedAt",
|
||||
"lastUpdateFullName",
|
||||
"isActive",
|
||||
"note",
|
||||
],
|
||||
where: { id: id },
|
||||
});
|
||||
if (!insignia) {
|
||||
|
|
@ -160,11 +167,11 @@ export class InsigniaController extends Controller {
|
|||
shortName: insignia.shortName,
|
||||
insigniaTypeName: insignia.insigniaType == null ? null : insignia.insigniaType.name, //ลำดับชั้นเครื่องราช
|
||||
createdAt: insignia.createdAt,
|
||||
lastUpdatedAt: insignia.lastUpdatedAt,
|
||||
lastUpdatedAt: insignia.lastUpdatedAt,
|
||||
lastUpdateFullName: insignia.lastUpdateFullName,
|
||||
isActive: insignia.isActive,
|
||||
note: insignia.note
|
||||
}
|
||||
isActive: insignia.isActive,
|
||||
note: insignia.note,
|
||||
};
|
||||
return new HttpSuccess(mapInsignia);
|
||||
}
|
||||
|
||||
|
|
@ -174,13 +181,21 @@ export class InsigniaController extends Controller {
|
|||
* @summary ORG_ - รายการเครื่องราชอิสริยาภรณ์ (ADMIN) #
|
||||
*
|
||||
*/
|
||||
@Get("")
|
||||
@Get()
|
||||
async GetInsignia() {
|
||||
|
||||
const insigniaAll = await this.insigniaRepository.find({
|
||||
relations: ["insigniaType"],
|
||||
select: ["id", "name", "shortName", "createdAt", "lastUpdatedAt", "lastUpdateFullName", "isActive", "note"],
|
||||
order: { "level": "ASC" }
|
||||
select: [
|
||||
"id",
|
||||
"name",
|
||||
"shortName",
|
||||
"createdAt",
|
||||
"lastUpdatedAt",
|
||||
"lastUpdateFullName",
|
||||
"isActive",
|
||||
"note",
|
||||
],
|
||||
order: { level: "ASC" },
|
||||
});
|
||||
|
||||
const mapInsigniaAll = insigniaAll.map((item) => ({
|
||||
|
|
@ -189,10 +204,10 @@ export class InsigniaController extends Controller {
|
|||
shortName: item.shortName,
|
||||
insigniaTypeName: item.insigniaType == null ? null : item.insigniaType.name, //ลำดับชั้นเครื่องราช
|
||||
createdAt: item.createdAt,
|
||||
lastUpdatedAt: item.lastUpdatedAt,
|
||||
lastUpdatedAt: item.lastUpdatedAt,
|
||||
lastUpdateFullName: item.lastUpdateFullName,
|
||||
isActive: item.isActive,
|
||||
note: item.note
|
||||
isActive: item.isActive,
|
||||
note: item.note,
|
||||
}));
|
||||
return new HttpSuccess(mapInsigniaAll);
|
||||
}
|
||||
|
|
@ -205,9 +220,8 @@ export class InsigniaController extends Controller {
|
|||
*/
|
||||
@Post("sort")
|
||||
async Sort(@Body() requestBody: { insigniaTypeId: string; sortId: string[] }) {
|
||||
|
||||
const insigniaType = await this.insigniaTypeRepository.findOne({
|
||||
where: { id: requestBody.insigniaTypeId }
|
||||
where: { id: requestBody.insigniaTypeId },
|
||||
});
|
||||
if (!insigniaType) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลลำดับเครื่องราชอิสริยาภรณ์นี้");
|
||||
|
|
@ -215,7 +229,7 @@ export class InsigniaController extends Controller {
|
|||
|
||||
const insignia = await this.insigniaRepository.find({
|
||||
select: ["id", "level"],
|
||||
where: { insigniaTypeId: requestBody.insigniaTypeId }
|
||||
where: { insigniaTypeId: requestBody.insigniaTypeId },
|
||||
});
|
||||
if (!insignia) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลเครื่องราชอิสริยาภรณ์นี้");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue