แก้ path อนุมัติเงินเดือน
This commit is contained in:
parent
c22dd4ecf2
commit
2529d7d43f
1 changed files with 84 additions and 53 deletions
|
|
@ -4,18 +4,16 @@ import {
|
||||||
Post,
|
Post,
|
||||||
Put,
|
Put,
|
||||||
Delete,
|
Delete,
|
||||||
Patch,
|
|
||||||
Route,
|
Route,
|
||||||
Security,
|
Security,
|
||||||
Tags,
|
Tags,
|
||||||
Body,
|
Body,
|
||||||
Path,
|
Path,
|
||||||
Request,
|
Request,
|
||||||
Example,
|
|
||||||
Query,
|
Query,
|
||||||
} from "tsoa";
|
} from "tsoa";
|
||||||
import { AppDataSource } from "../database/data-source";
|
import { AppDataSource } from "../database/data-source";
|
||||||
import { DeepPartial, In, IsNull, Not, Between, MoreThan, Like, Brackets } from "typeorm";
|
import { In, Not, MoreThan, Brackets } from "typeorm";
|
||||||
import HttpSuccess from "../interfaces/http-success";
|
import HttpSuccess from "../interfaces/http-success";
|
||||||
import HttpError from "../interfaces/http-error";
|
import HttpError from "../interfaces/http-error";
|
||||||
import HttpStatusCode from "../interfaces/http-status";
|
import HttpStatusCode from "../interfaces/http-status";
|
||||||
|
|
@ -28,7 +26,6 @@ import { PosLevel } from "../entities/PosLevel";
|
||||||
import { Salarys } from "../entities/Salarys";
|
import { Salarys } from "../entities/Salarys";
|
||||||
import { SalaryRanks } from "../entities/SalaryRanks";
|
import { SalaryRanks } from "../entities/SalaryRanks";
|
||||||
import CallAPI from "../interfaces/call-api";
|
import CallAPI from "../interfaces/call-api";
|
||||||
import { Int32 } from "typeorm/browser";
|
|
||||||
|
|
||||||
@Route("api/v1/salary/period")
|
@Route("api/v1/salary/period")
|
||||||
@Tags("Salary")
|
@Tags("Salary")
|
||||||
|
|
@ -1966,19 +1963,23 @@ export class SalaryPeriodController extends Controller {
|
||||||
* API เจ้าหน้าที่ส่ง ผอ
|
* API เจ้าหน้าที่ส่ง ผอ
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @param {string} orgId Guid, *Id รอบเงินเดือน
|
* @param {string} periodId Guid, *Id รอบเงินเดือน
|
||||||
|
* @param {string} rootId Guid, *Id สำนัก
|
||||||
*/
|
*/
|
||||||
@Get("officer/approve/{orgId}")
|
@Get("officer/approve/{periodId}/{rootId}")
|
||||||
async OfficerApprove(@Path() orgId: string) {
|
async OfficerApprove(@Path() periodId: string, rootId: string) {
|
||||||
const salaryOrg = await this.salaryOrgRepository.findOne({
|
const salaryPeriod = await this.salaryPeriodRepository.findOne({
|
||||||
where: { id: orgId },
|
where: { id: periodId },
|
||||||
|
relations: ["salaryOrgs"],
|
||||||
});
|
});
|
||||||
if (!salaryOrg) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลรอบผังเงินเดือนนี้");
|
if (!salaryPeriod)
|
||||||
if (salaryOrg.status != "PENDING")
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลรอบผังเงินเดือนนี้");
|
||||||
throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, "ยังไม่ไม่สามารถอนุมัติได้");
|
await Promise.all(
|
||||||
|
salaryPeriod.salaryOrgs.map(async (x) => {
|
||||||
salaryOrg.status = "WAITHEAD1";
|
x.status = "WAITHEAD1";
|
||||||
await this.salaryOrgRepository.save(salaryOrg);
|
await this.salaryPeriodRepository.save(salaryPeriod);
|
||||||
|
}),
|
||||||
|
);
|
||||||
return new HttpSuccess();
|
return new HttpSuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1987,18 +1988,25 @@ export class SalaryPeriodController extends Controller {
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @param {string} orgId Guid, *Id รอบเงินเดือน
|
* @param {string} orgId Guid, *Id รอบเงินเดือน
|
||||||
|
* @param {string} rootId Guid, *Id สำนัก
|
||||||
*/
|
*/
|
||||||
@Get("head/approve/{orgId}")
|
@Get("head/approve/{periodId}/{rootId}")
|
||||||
async HeadApprove(@Path() orgId: string) {
|
async HeadApprove(@Path() periodId: string, rootId: string) {
|
||||||
const salaryOrg = await this.salaryOrgRepository.findOne({
|
const salaryPeriod = await this.salaryPeriodRepository.findOne({
|
||||||
where: { id: orgId },
|
where: { id: periodId },
|
||||||
|
relations: ["salaryOrgs"],
|
||||||
});
|
});
|
||||||
if (!salaryOrg) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลรอบผังเงินเดือนนี้");
|
if (!salaryPeriod)
|
||||||
if (salaryOrg.status != "WAITHEAD1")
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลรอบผังเงินเดือนนี้");
|
||||||
throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, "ยังไม่ไม่สามารถอนุมัติได้");
|
|
||||||
|
|
||||||
salaryOrg.status = "WAITOWNER1";
|
await Promise.all(
|
||||||
await this.salaryOrgRepository.save(salaryOrg);
|
salaryPeriod.salaryOrgs
|
||||||
|
.filter((x) => x.rootId == rootId)
|
||||||
|
.map(async (x) => {
|
||||||
|
x.status = "WAITOWNER1";
|
||||||
|
await this.salaryPeriodRepository.save(salaryPeriod);
|
||||||
|
}),
|
||||||
|
);
|
||||||
return new HttpSuccess();
|
return new HttpSuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2007,18 +2015,25 @@ export class SalaryPeriodController extends Controller {
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @param {string} orgId Guid, *Id รอบเงินเดือน
|
* @param {string} orgId Guid, *Id รอบเงินเดือน
|
||||||
|
* @param {string} rootId Guid, *Id สำนัก
|
||||||
*/
|
*/
|
||||||
@Get("owner/approve/{orgId}")
|
@Get("owner/approve/{periodId}/{rootId}")
|
||||||
async OwnerApprove(@Path() orgId: string) {
|
async OwnerApprove(@Path() periodId: string, rootId: string) {
|
||||||
const salaryOrg = await this.salaryOrgRepository.findOne({
|
const salaryPeriod = await this.salaryPeriodRepository.findOne({
|
||||||
where: { id: orgId },
|
where: { id: periodId },
|
||||||
|
relations: ["salaryOrgs"],
|
||||||
});
|
});
|
||||||
if (!salaryOrg) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลรอบผังเงินเดือนนี้");
|
if (!salaryPeriod)
|
||||||
if (salaryOrg.status != "WAITOWNER1")
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลรอบผังเงินเดือนนี้");
|
||||||
throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, "ยังไม่ไม่สามารถอนุมัติได้");
|
|
||||||
|
|
||||||
salaryOrg.status = "REPORT";
|
await Promise.all(
|
||||||
await this.salaryOrgRepository.save(salaryOrg);
|
salaryPeriod.salaryOrgs
|
||||||
|
.filter((x) => x.rootId == rootId)
|
||||||
|
.map(async (x) => {
|
||||||
|
x.status = "REPORT";
|
||||||
|
await this.salaryPeriodRepository.save(salaryPeriod);
|
||||||
|
}),
|
||||||
|
);
|
||||||
return new HttpSuccess();
|
return new HttpSuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2027,25 +2042,33 @@ export class SalaryPeriodController extends Controller {
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @param {string} orgId Guid, *Id รอบเงินเดือน
|
* @param {string} orgId Guid, *Id รอบเงินเดือน
|
||||||
|
* @param {string} rootId Guid, *Id สำนัก
|
||||||
*/
|
*/
|
||||||
@Put("owner/comment/{orgId}")
|
@Put("owner/comment/{periodId}/{rootId}")
|
||||||
async WaitOwnerApprove(
|
async WaitOwnerApprove(
|
||||||
@Path() orgId: string,
|
@Path() periodId: string,
|
||||||
|
rootId: string,
|
||||||
@Body()
|
@Body()
|
||||||
body: {
|
body: {
|
||||||
titleRecommend: string;
|
titleRecommend: string;
|
||||||
},
|
},
|
||||||
) {
|
) {
|
||||||
const salaryOrg = await this.salaryOrgRepository.findOne({
|
const salaryPeriod = await this.salaryPeriodRepository.findOne({
|
||||||
where: { id: orgId },
|
where: { id: periodId },
|
||||||
|
relations: ["salaryOrgs"],
|
||||||
});
|
});
|
||||||
if (!salaryOrg) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลรอบผังเงินเดือนนี้");
|
if (!salaryPeriod)
|
||||||
if (salaryOrg.status != "WAITOWNER1")
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลรอบผังเงินเดือนนี้");
|
||||||
throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, "ยังไม่ไม่สามารถอนุมัติได้");
|
|
||||||
|
|
||||||
salaryOrg.status = "WAITHEAD2";
|
await Promise.all(
|
||||||
salaryOrg.ownerRecommend = body.titleRecommend;
|
salaryPeriod.salaryOrgs
|
||||||
await this.salaryOrgRepository.save(salaryOrg);
|
.filter((x) => x.rootId == rootId)
|
||||||
|
.map(async (x) => {
|
||||||
|
x.status = "WAITHEAD2";
|
||||||
|
x.ownerRecommend = body.titleRecommend;
|
||||||
|
await this.salaryPeriodRepository.save(salaryPeriod);
|
||||||
|
}),
|
||||||
|
);
|
||||||
return new HttpSuccess();
|
return new HttpSuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2054,25 +2077,33 @@ export class SalaryPeriodController extends Controller {
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @param {string} orgId Guid, *Id รอบเงินเดือน
|
* @param {string} orgId Guid, *Id รอบเงินเดือน
|
||||||
|
* @param {string} rootId Guid, *Id สำนัก
|
||||||
*/
|
*/
|
||||||
@Put("head/comment/{orgId}")
|
@Put("head/comment/{periodId}/{rootId}")
|
||||||
async WaitHeadApprove(
|
async WaitHeadApprove(
|
||||||
@Path() orgId: string,
|
@Path() periodId: string,
|
||||||
|
rootId: string,
|
||||||
@Body()
|
@Body()
|
||||||
body: {
|
body: {
|
||||||
titleRecommend: string;
|
titleRecommend: string;
|
||||||
},
|
},
|
||||||
) {
|
) {
|
||||||
const salaryOrg = await this.salaryOrgRepository.findOne({
|
const salaryPeriod = await this.salaryPeriodRepository.findOne({
|
||||||
where: { id: orgId },
|
where: { id: periodId },
|
||||||
|
relations: ["salaryOrgs"],
|
||||||
});
|
});
|
||||||
if (!salaryOrg) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลรอบผังเงินเดือนนี้");
|
if (!salaryPeriod)
|
||||||
if (salaryOrg.status != "WAITOFFICER2")
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลรอบผังเงินเดือนนี้");
|
||||||
throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, "ยังไม่ไม่สามารถอนุมัติได้");
|
|
||||||
|
|
||||||
salaryOrg.status = "REPORT";
|
await Promise.all(
|
||||||
salaryOrg.headRecommend = body.titleRecommend;
|
salaryPeriod.salaryOrgs
|
||||||
await this.salaryOrgRepository.save(salaryOrg);
|
.filter((x) => x.rootId == rootId)
|
||||||
|
.map(async (x) => {
|
||||||
|
x.status = "REPORT";
|
||||||
|
x.ownerRecommend = body.titleRecommend;
|
||||||
|
await this.salaryPeriodRepository.save(salaryPeriod);
|
||||||
|
}),
|
||||||
|
);
|
||||||
return new HttpSuccess();
|
return new HttpSuccess();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue