Merge branch 'adiDev' into develop
# Conflicts: # src/controllers/ProfileController.ts
This commit is contained in:
commit
fa36abfe85
1 changed files with 52 additions and 0 deletions
|
|
@ -21,6 +21,8 @@ import { Profile, CreateProfile, UpdateProfile } from "../entities/Profile";
|
|||
import { Brackets, In, IsNull, Like, Not } from "typeorm";
|
||||
import { OrgRevision } from "../entities/OrgRevision";
|
||||
import { PosMaster } from "../entities/PosMaster";
|
||||
import { PosLevel } from "../entities/PosLevel";
|
||||
import { PosType } from "../entities/PosType";
|
||||
|
||||
@Route("api/v1/org/profile")
|
||||
@Tags("Profile")
|
||||
|
|
@ -34,6 +36,8 @@ export class ProfileController extends Controller {
|
|||
private orgRevisionRepository = AppDataSource.getRepository(OrgRevision);
|
||||
private posMasterRepository = AppDataSource.getRepository(PosMaster);
|
||||
private profileRepository = AppDataSource.getRepository(Profile);
|
||||
private posLevelRepository = AppDataSource.getRepository(PosLevel);
|
||||
private posTypeRepository = AppDataSource.getRepository(PosType);
|
||||
|
||||
/**
|
||||
* API สร้างทะเบียนประวัติ
|
||||
|
|
@ -47,6 +51,30 @@ export class ProfileController extends Controller {
|
|||
requestBody: CreateProfile,
|
||||
@Request() request: { user: Record<string, any> },
|
||||
) {
|
||||
if (requestBody.posLevelId) {
|
||||
const checkPosLevel = await this.posLevelRepository.findOne({
|
||||
where: { id: requestBody.posLevelId },
|
||||
});
|
||||
if (!checkPosLevel) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูลใน PosLevel จากไอดีนี้ : " + requestBody.posLevelId,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (requestBody.posTypeId) {
|
||||
const checkPosType = await this.posTypeRepository.findOne({
|
||||
where: { id: requestBody.posTypeId },
|
||||
});
|
||||
if (!checkPosType) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูลใน PosType จากไอดีนี้ : " + requestBody.posTypeId,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
const profile = Object.assign(new Profile(), requestBody);
|
||||
profile.createdUserId = request.user.sub;
|
||||
|
|
@ -79,6 +107,30 @@ export class ProfileController extends Controller {
|
|||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลไอดีนี้ : " + id);
|
||||
}
|
||||
|
||||
if (requestBody.posLevelId) {
|
||||
const checkPosLevel = await this.posLevelRepository.findOne({
|
||||
where: { id: requestBody.posLevelId },
|
||||
});
|
||||
if (!checkPosLevel) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูลใน PosLevel จากไอดีนี้ : " + requestBody.posLevelId,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (requestBody.posTypeId) {
|
||||
const checkPosType = await this.posTypeRepository.findOne({
|
||||
where: { id: requestBody.posTypeId },
|
||||
});
|
||||
if (!checkPosType) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูลใน PosType จากไอดีนี้ : " + requestBody.posTypeId,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
profile.lastUpdateUserId = request.user.sub;
|
||||
profile.lastUpdateFullName = request.user.name;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue