Merge branch 'develop' into adiDev
This commit is contained in:
commit
543ef19664
7 changed files with 351 additions and 10 deletions
50
src/controllers/ChangePositionController.ts
Normal file
50
src/controllers/ChangePositionController.ts
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
import {
|
||||
Controller,
|
||||
Get,
|
||||
Post,
|
||||
Put,
|
||||
Delete,
|
||||
Patch,
|
||||
Route,
|
||||
Security,
|
||||
Tags,
|
||||
Body,
|
||||
Path,
|
||||
Request,
|
||||
Example,
|
||||
SuccessResponse,
|
||||
Response,
|
||||
Query,
|
||||
} from "tsoa";
|
||||
import { AppDataSource } from "../database/data-source";
|
||||
import HttpSuccess from "../interfaces/http-success";
|
||||
import HttpStatusCode from "../interfaces/http-status";
|
||||
import { Equal, ILike, In, IsNull, Like, Not, Brackets, MoreThan } from "typeorm";
|
||||
import { ChangePosition } from "../entities/ChangePosition";
|
||||
|
||||
@Route("api/v1/placement/change-position")
|
||||
@Tags("Switch")
|
||||
@Security("bearerAuth")
|
||||
@Response(
|
||||
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
||||
"เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง",
|
||||
)
|
||||
@SuccessResponse(HttpStatusCode.OK, "สำเร็จ")
|
||||
export class ChangePositionController extends Controller {
|
||||
private ChangePositionRepository = AppDataSource.getRepository(ChangePosition);
|
||||
|
||||
/**
|
||||
* API รายการออกคำสั่งย้ายสับเปลี่ยนตำแหน่ง
|
||||
*
|
||||
* @summary API รายการออกคำสั่งย้ายสับเปลี่ยนตำแหน่ง
|
||||
*
|
||||
*/
|
||||
@Get("")
|
||||
async GetChangePositionLists() {
|
||||
|
||||
const data = await this.ChangePositionRepository.find();
|
||||
return new HttpSuccess(data);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -22,6 +22,18 @@ export class ProfileAvatarController extends Controller {
|
|||
return new HttpSuccess(lists);
|
||||
}
|
||||
|
||||
@Get("profileId/{id}")
|
||||
async getProfile(@Path() id: string) {
|
||||
const profile = await this.profileRepository.findOne({
|
||||
select: ["avatar", "avatarName"],
|
||||
where: { id },
|
||||
});
|
||||
|
||||
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
|
||||
return new HttpSuccess(profile);
|
||||
}
|
||||
|
||||
@Get("select/{profileId}/{id}")
|
||||
public async selectAvatar(@Path() profileId: string, @Path() id: string) {
|
||||
const result = await this.avatarRepository.findOneBy({ id: id });
|
||||
|
|
|
|||
|
|
@ -496,15 +496,27 @@ export class ProfileController extends Controller {
|
|||
|
||||
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
|
||||
const _caregiver = await this.profileRepo.find({
|
||||
relations: { posLevel: true, posType: true },
|
||||
});
|
||||
const _commander = await this.profileRepo.find({
|
||||
relations: { posLevel: true, posType: true },
|
||||
});
|
||||
const _chairman = await this.profileRepo.find({
|
||||
relations: { posLevel: true, posType: true },
|
||||
});
|
||||
const _caregiver = await this.profileRepo
|
||||
.createQueryBuilder("profile")
|
||||
.leftJoinAndSelect("profile.posLevel", "posLevel")
|
||||
.leftJoinAndSelect("profile.posType", "posType")
|
||||
.skip((1 - 1) * 20)
|
||||
.take(20)
|
||||
.getMany();
|
||||
const _commander = await this.profileRepo
|
||||
.createQueryBuilder("profile")
|
||||
.leftJoinAndSelect("profile.posLevel", "posLevel")
|
||||
.leftJoinAndSelect("profile.posType", "posType")
|
||||
.skip((1 - 1) * 20)
|
||||
.take(20)
|
||||
.getMany();
|
||||
const _chairman = await this.profileRepo
|
||||
.createQueryBuilder("profile")
|
||||
.leftJoinAndSelect("profile.posLevel", "posLevel")
|
||||
.leftJoinAndSelect("profile.posType", "posType")
|
||||
.skip((1 - 1) * 20)
|
||||
.take(20)
|
||||
.getMany();
|
||||
|
||||
const caregiver = _caregiver.map((_data) => ({
|
||||
id: _data.id,
|
||||
|
|
|
|||
|
|
@ -556,7 +556,11 @@ export class ProfileEmployeeController extends Controller {
|
|||
const exists =
|
||||
!!body.citizenId &&
|
||||
(await this.profileRepo.findOne({
|
||||
where: { id: Not(id), citizenId: body.citizenId },
|
||||
where: {
|
||||
id: Not(id),
|
||||
citizenId: body.citizenId,
|
||||
employeeClass: String(body.employeeClass)
|
||||
},
|
||||
}));
|
||||
|
||||
if (exists) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue