แก้apiข้อมูลหลัก
This commit is contained in:
parent
73e07dfed6
commit
6b78a365fa
26 changed files with 1816 additions and 988 deletions
|
|
@ -24,6 +24,7 @@ import HttpError from "../interfaces/http-error";
|
|||
import { ProfileInsigniaHistory } from "../entities/ProfileInsigniaHistory";
|
||||
import { RequestWithUser } from "../middlewares/user";
|
||||
import { Profile } from "../entities/Profile";
|
||||
import { Insignia } from "../entities/Insignia";
|
||||
|
||||
@Route("api/v1/org/profile/insignia")
|
||||
@Tags("ProfileInsignia")
|
||||
|
|
@ -32,6 +33,7 @@ export class ProfileInsigniaController extends Controller {
|
|||
private profileRepo = AppDataSource.getRepository(Profile);
|
||||
private insigniaRepo = AppDataSource.getRepository(ProfileInsignia);
|
||||
private insigniaHistoryRepo = AppDataSource.getRepository(ProfileInsigniaHistory);
|
||||
private insigniaMetaRepo = AppDataSource.getRepository(Insignia);
|
||||
|
||||
@Get("{profileId}")
|
||||
@Example({
|
||||
|
|
@ -157,6 +159,13 @@ export class ProfileInsigniaController extends Controller {
|
|||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
}
|
||||
|
||||
const insignia = await this.insigniaMetaRepo.findOne({
|
||||
where: { id: body.insigniaId },
|
||||
});
|
||||
if (!insignia) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลเครื่องราชฯ นี้");
|
||||
}
|
||||
|
||||
const data = new ProfileInsignia();
|
||||
|
||||
const meta = {
|
||||
|
|
@ -183,6 +192,13 @@ export class ProfileInsigniaController extends Controller {
|
|||
|
||||
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
|
||||
const insignia = await this.insigniaMetaRepo.findOne({
|
||||
where: { id: body.insigniaId },
|
||||
});
|
||||
if (!insignia) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลเครื่องราชฯ นี้");
|
||||
}
|
||||
|
||||
const history = new ProfileInsigniaHistory();
|
||||
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue