add field
This commit is contained in:
parent
7a4b25079f
commit
c95b056562
3 changed files with 86 additions and 5 deletions
|
|
@ -23,6 +23,7 @@ import HttpError from "../interfaces/http-error";
|
|||
import { Equal, ILike, In, IsNull, Like, Not, Brackets, MoreThan } from "typeorm";
|
||||
import { RequestWithUser } from "../middlewares/user";
|
||||
import { ChangePosition, CreateChangePosition, UpdateChangePosition } from "../entities/ChangePosition";
|
||||
import { ProfileChangePosition, CreateProfileChangePosition } from "../entities/ProfileChangePosition";
|
||||
|
||||
@Route("api/v1/org/placement/change-position")
|
||||
@Tags("Placement")
|
||||
|
|
@ -33,7 +34,8 @@ import { ChangePosition, CreateChangePosition, UpdateChangePosition } from "../e
|
|||
)
|
||||
@SuccessResponse(HttpStatusCode.OK, "สำเร็จ")
|
||||
export class ChangePositionController extends Controller {
|
||||
private ChangePositionRepository = AppDataSource.getRepository(ChangePosition);
|
||||
private ChangePositionRepository = AppDataSource.getRepository(ChangePosition);
|
||||
private ProfileChangePositionRepository = AppDataSource.getRepository(ProfileChangePosition);
|
||||
|
||||
/**
|
||||
* API เพิ่มรอบย้ายสับเปลี่ยนตำแหน่ง
|
||||
|
|
@ -68,6 +70,41 @@ export class ChangePositionController extends Controller {
|
|||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* API เพิ่มเพิ่มรายชื่อผู้ที่ย้ายสับเปลี่ยนตำแหน่ง
|
||||
*
|
||||
* @summary เพิ่มเพิ่มรายชื่อผู้ที่ย้ายสับเปลี่ยนตำแหน่ง (ADMIN)
|
||||
*
|
||||
* @param {string} id Id รอบย้ายสับเปลี่ยนตำแหน่ง
|
||||
*/
|
||||
@Post("profile/{id}")
|
||||
async CreateProfileChangePosition(
|
||||
@Path() id: string,
|
||||
@Body() body: CreateProfileChangePosition,
|
||||
@Request() request: RequestWithUser,
|
||||
) {
|
||||
const changePosition = await this.ChangePositionRepository.findOneBy({ id });
|
||||
if (!changePosition) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลรอบย้ายสับเปลี่ยนตำแหน่ง");
|
||||
|
||||
const profileChangePositions: ProfileChangePosition[] = [];
|
||||
const profiles = new ProfileChangePosition();
|
||||
for (const data of body.profiles) {
|
||||
Object.assign(profiles, data);
|
||||
let positionOld = data.positionOld ? `${data.positionOld}` : "";
|
||||
let rootOld = data.rootOld ? data.positionOld ? `/${data.rootOld}` : `${data.rootOld}` : "";
|
||||
profiles.changePositionId = id;
|
||||
profiles.organizationPositionOld = `${positionOld}${rootOld}`,
|
||||
profiles.status = "WAITTING",
|
||||
profiles.createdUserId = request.user.sub;
|
||||
profiles.createdFullName = request.user.name;
|
||||
profiles.lastUpdateUserId = request.user.sub;
|
||||
profiles.lastUpdateFullName = request.user.name;
|
||||
profileChangePositions.push(profiles);
|
||||
}
|
||||
await this.ProfileChangePositionRepository.save(profileChangePositions);
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* API ลบรอบย้ายสับเปลี่ยนตำแหน่ง
|
||||
*
|
||||
|
|
@ -107,7 +144,7 @@ export class ChangePositionController extends Controller {
|
|||
) {
|
||||
|
||||
const changePosition = await this.ChangePositionRepository.findOneBy({ id });
|
||||
if (!changePosition) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
if (!changePosition) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลรอบย้ายสับเปลี่ยนตำแหน่ง");
|
||||
|
||||
const checkDuplicate = await this.ChangePositionRepository.find({
|
||||
where: {
|
||||
|
|
@ -134,7 +171,7 @@ export class ChangePositionController extends Controller {
|
|||
* @summary API รายการรอบย้ายสับเปลี่ยนตำแหน่ง (ADMIN)
|
||||
*
|
||||
*/
|
||||
@Get("")
|
||||
@Get()
|
||||
async GetChangePositionLists() {
|
||||
const data = await this.ChangePositionRepository.find();
|
||||
return new HttpSuccess(data);
|
||||
|
|
|
|||
|
|
@ -2097,6 +2097,7 @@ export class ProfileController extends Controller {
|
|||
child3ShortName: child3Holder?.orgChild3ShortName ?? null,
|
||||
child4: child4Holder?.orgChild4Name ?? null,
|
||||
child4Id: child4Holder?.id ?? null,
|
||||
child4ShortName: child4Holder?.orgChild4ShortName ?? null,
|
||||
posMasterNo: posMasterNo ?? null,
|
||||
posTypeId: item.posTypeId,
|
||||
posTypeName: item.posType?.posTypeName,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue