Compare commits
16 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
eb705231b8 | ||
|
|
f8f928866e | ||
|
|
8f82ddef4c | ||
|
|
5e7fa19248 | ||
|
|
e3ae765da9 | ||
|
|
4ea611feaf | ||
|
|
d74a8e14d8 | ||
|
|
118d0d13fb | ||
|
|
24fb2067e5 | ||
|
|
b57a64fe0e | ||
|
|
7a8691ee61 | ||
|
|
d78c7bc2e7 | ||
|
|
b201802490 | ||
|
|
db5028656d | ||
|
|
4fabba3650 | ||
|
|
a3dd5c59f5 |
8 changed files with 121 additions and 20 deletions
|
|
@ -1925,6 +1925,38 @@ export class DevelopmentController extends Controller {
|
||||||
return new HttpSuccess({ data: development, total });
|
return new HttpSuccess({ data: development, total });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* API ลบรายชื่อผู้ผ่านการอบรม
|
||||||
|
*
|
||||||
|
* @summary ลบรายชื่อผู้ผ่านการอบรม
|
||||||
|
*
|
||||||
|
* @param {string} id Id ผู้ผ่านการอบรม
|
||||||
|
*/
|
||||||
|
@Delete("delete/{id}")
|
||||||
|
async DeleteDevelopmentBy(@Path() id: string, @Request() request: RequestWithUser) {
|
||||||
|
await new permission().PermissionDelete(request, "SYS_DEV_PROJECT");
|
||||||
|
const developmentHis = await this.developmentHistoryRepository.findOne({
|
||||||
|
where: { id },
|
||||||
|
});
|
||||||
|
if (!developmentHis) {
|
||||||
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลรายชื่อผู้ผ่านการอบรม");
|
||||||
|
}
|
||||||
|
if (developmentHis.isProfile) {
|
||||||
|
if (developmentHis.isDone || developmentHis.isDoneIDP) {
|
||||||
|
await new CallAPI()
|
||||||
|
.PostData(request, "/org/profile/training/delete-byId", {
|
||||||
|
type: developmentHis.type,
|
||||||
|
profileId: developmentHis.profileId,
|
||||||
|
developmentId: developmentHis.developmentId,
|
||||||
|
})
|
||||||
|
.then((x) => {})
|
||||||
|
.catch((x) => {});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
await this.developmentHistoryRepository.delete({ id });
|
||||||
|
return new HttpSuccess();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* API ลบโครงการ/หลักสูตรการฝึกอบรม
|
* API ลบโครงการ/หลักสูตรการฝึกอบรม
|
||||||
*
|
*
|
||||||
|
|
@ -2580,6 +2612,7 @@ export class DevelopmentController extends Controller {
|
||||||
where: { developmentId: id },
|
where: { developmentId: id },
|
||||||
relations: ["posLevel", "posType", "employeePosLevel", "employeePosType"],
|
relations: ["posLevel", "posType", "employeePosLevel", "employeePosType"],
|
||||||
order: {
|
order: {
|
||||||
|
no: "ASC",
|
||||||
isDone: "ASC",
|
isDone: "ASC",
|
||||||
isDoneIDP: "ASC",
|
isDoneIDP: "ASC",
|
||||||
citizenId: "ASC",
|
citizenId: "ASC",
|
||||||
|
|
@ -2587,6 +2620,7 @@ export class DevelopmentController extends Controller {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const _getDevelopment = getDevelopment.map((item) => ({
|
const _getDevelopment = getDevelopment.map((item) => ({
|
||||||
|
no: item.no,
|
||||||
id: item.id,
|
id: item.id,
|
||||||
type: item.type,
|
type: item.type,
|
||||||
idcard: item.citizenId,
|
idcard: item.citizenId,
|
||||||
|
|
|
||||||
|
|
@ -330,7 +330,7 @@ export class DevelopmentScholarshipController extends Controller {
|
||||||
id: item.id,
|
id: item.id,
|
||||||
year: item.scholarshipYear,
|
year: item.scholarshipYear,
|
||||||
citizenId: item.citizenId,
|
citizenId: item.citizenId,
|
||||||
fullName: `${item.prefix ?? ""}${item.firstName ?? ""} ${item.lastName ?? ""}`,
|
fullName: `${item.prefix ?? ""}${item.firstName ?? ""} ${item.lastName ?? ""}`.trim(),
|
||||||
position: item.position,
|
position: item.position,
|
||||||
posType: item.posType ? item.posType.posTypeName : null,
|
posType: item.posType ? item.posType.posTypeName : null,
|
||||||
posLevel: item.posLevel ? item.posLevel.posLevelName : null,
|
posLevel: item.posLevel ? item.posLevel.posLevelName : null,
|
||||||
|
|
@ -339,7 +339,7 @@ export class DevelopmentScholarshipController extends Controller {
|
||||||
scholarshipType: item.scholarshipType,
|
scholarshipType: item.scholarshipType,
|
||||||
startDate: item.startDate,
|
startDate: item.startDate,
|
||||||
endDate: item.endDate,
|
endDate: item.endDate,
|
||||||
fullNameGuarantor: `${item.guarantorPrefix ?? ""}${item.guarantorFirstName ?? ""} ${item.guarantorLastName ?? ""}` ,
|
fullNameGuarantor: `${item.guarantorPrefix ?? ""}${item.guarantorFirstName ?? ""} ${item.guarantorLastName ?? ""}`.trim(),
|
||||||
guarantorCitizenId: item.guarantorCitizenId,
|
guarantorCitizenId: item.guarantorCitizenId,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
@ -789,6 +789,9 @@ export class DevelopmentScholarshipController extends Controller {
|
||||||
if (!getDevelopment) {
|
if (!getDevelopment) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทุนการศึกษา/ฝึกอบรมนี้");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทุนการศึกษา/ฝึกอบรมนี้");
|
||||||
}
|
}
|
||||||
|
if (getDevelopment.status == "PENDING") {
|
||||||
|
getDevelopment.status = "REPORTED";
|
||||||
|
}
|
||||||
const before = structuredClone(getDevelopment);
|
const before = structuredClone(getDevelopment);
|
||||||
Object.assign(getDevelopment, requestBody);
|
Object.assign(getDevelopment, requestBody);
|
||||||
getDevelopment.lastUpdateUserId = request.user.sub;
|
getDevelopment.lastUpdateUserId = request.user.sub;
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ import { CreatePortfolio, Portfolio } from "../entities/Portfolio";
|
||||||
import { RequestWithUser } from "../middlewares/user";
|
import { RequestWithUser } from "../middlewares/user";
|
||||||
import { setLogDataDiff } from "../interfaces/utils";
|
import { setLogDataDiff } from "../interfaces/utils";
|
||||||
import { Brackets } from "typeorm";
|
import { Brackets } from "typeorm";
|
||||||
|
import CallAPI from "../interfaces/call-api";
|
||||||
@Route("api/v1/development/portfolio")
|
@Route("api/v1/development/portfolio")
|
||||||
@Tags("Portfolio")
|
@Tags("Portfolio")
|
||||||
@Security("bearerAuth")
|
@Security("bearerAuth")
|
||||||
|
|
@ -104,19 +104,21 @@ export class PortfolioController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* API รายละเอียดรายการผลงาน ใช้แสดงในรายงาน ก.พ.7/ก.ก.1
|
* API รายละเอียดรายการผลงาน ใช้แสดงในรายงาน ทปอ. สามัญ
|
||||||
*
|
*
|
||||||
* @summary รายละเอียดรายการผลงาน ใช้แสดงในรายงาน ก.พ.7/ก.ก.1
|
* @summary รายละเอียดรายการผลงาน ใช้แสดงในรายงาน ทปอ. สามัญ
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Get("kk1/{keycloak}")
|
@Get("kk1/{keycloak}")
|
||||||
async GetPortfolio(@Path() keycloak: string, @Request() request: RequestWithUser) {
|
async GetPortfolio(@Path() keycloak: string, @Request() request: RequestWithUser) {
|
||||||
const _portfolio = await this.portfolioRepository.find({
|
const _portfolio = await this.portfolioRepository.find({
|
||||||
where: { createdUserId: keycloak },
|
where: { createdUserId: keycloak },
|
||||||
select: [
|
select: {
|
||||||
"name",
|
name: true,
|
||||||
"createdAt"
|
createdAt: true,
|
||||||
],
|
position: true,
|
||||||
|
posLevel: true
|
||||||
|
},
|
||||||
order: { createdAt: "DESC" },
|
order: { createdAt: "DESC" },
|
||||||
});
|
});
|
||||||
const result =
|
const result =
|
||||||
|
|
@ -124,7 +126,8 @@ export class PortfolioController extends Controller {
|
||||||
name: x.name,
|
name: x.name,
|
||||||
year: x.createdAt.getFullYear() > 2500
|
year: x.createdAt.getFullYear() > 2500
|
||||||
? x.createdAt.getFullYear()
|
? x.createdAt.getFullYear()
|
||||||
: x.createdAt.getFullYear()+543
|
: x.createdAt.getFullYear()+543,
|
||||||
|
position: `${x.position ?? ""}${x.posLevel ?? ""}`.trim()
|
||||||
}));
|
}));
|
||||||
return new HttpSuccess(result);
|
return new HttpSuccess(result);
|
||||||
}
|
}
|
||||||
|
|
@ -153,7 +156,20 @@ export class PortfolioController extends Controller {
|
||||||
if (checkName) {
|
if (checkName) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ชื่อนี้มีอยู่ในระบบแล้ว");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ชื่อนี้มีอยู่ในระบบแล้ว");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let _position:string=""
|
||||||
|
let _posLevel:string=""
|
||||||
|
await new CallAPI()
|
||||||
|
.GetData(request, `/org/dotnet/by-keycloak/${request.user.sub}`)
|
||||||
|
.then((x) => {
|
||||||
|
_position = x.position;
|
||||||
|
_posLevel = x.posLevel;
|
||||||
|
})
|
||||||
|
.catch(() => {});
|
||||||
|
|
||||||
const before = null;
|
const before = null;
|
||||||
|
_portfolio.position = _position;
|
||||||
|
_portfolio.posLevel = _posLevel;
|
||||||
_portfolio.createdUserId = request.user.sub;
|
_portfolio.createdUserId = request.user.sub;
|
||||||
_portfolio.createdFullName = request.user.name;
|
_portfolio.createdFullName = request.user.name;
|
||||||
_portfolio.lastUpdateUserId = request.user.sub;
|
_portfolio.lastUpdateUserId = request.user.sub;
|
||||||
|
|
|
||||||
|
|
@ -628,6 +628,10 @@ export class ReportController extends Controller {
|
||||||
field: getDevelopment.field,
|
field: getDevelopment.field,
|
||||||
studyPlace: getDevelopment.studyPlace,
|
studyPlace: getDevelopment.studyPlace,
|
||||||
scholarshipType: getDevelopment.scholarshipType,
|
scholarshipType: getDevelopment.scholarshipType,
|
||||||
|
bookNo:
|
||||||
|
getDevelopment.bookNo == null
|
||||||
|
? ""
|
||||||
|
: Extension.ToThaiNumber(getDevelopment.bookNo),
|
||||||
bookNoDate:
|
bookNoDate:
|
||||||
getDevelopment.bookNoDate == null
|
getDevelopment.bookNoDate == null
|
||||||
? ""
|
? ""
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,21 @@ export class Portfolio extends EntityBase {
|
||||||
default: null,
|
default: null,
|
||||||
})
|
})
|
||||||
detail: string;
|
detail: string;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
comment: "ตำแหน่ง",
|
||||||
|
default: null,
|
||||||
|
})
|
||||||
|
position: string;
|
||||||
|
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
comment: "ระดับตำแหน่ง",
|
||||||
|
default: null,
|
||||||
|
})
|
||||||
|
posLevel: string;
|
||||||
}
|
}
|
||||||
export class CreatePortfolio {
|
export class CreatePortfolio {
|
||||||
@Column()
|
@Column()
|
||||||
|
|
|
||||||
|
|
@ -67,6 +67,16 @@ export async function expressAuthentication(
|
||||||
request.app.locals.logData.userName = payload.name;
|
request.app.locals.logData.userName = payload.name;
|
||||||
request.app.locals.logData.user = payload.preferred_username;
|
request.app.locals.logData.user = payload.preferred_username;
|
||||||
|
|
||||||
|
// เก็บค่า profileId และ orgRootDnaId จาก token (ใช้ค่าว่างถ้าไม่มี)
|
||||||
|
request.app.locals.logData.profileId = payload.profileId ?? "";
|
||||||
|
request.app.locals.logData.orgRootDnaId = payload.orgRootDnaId ?? "";
|
||||||
|
request.app.locals.logData.orgChild1DnaId = payload.orgChild1DnaId ?? "";
|
||||||
|
request.app.locals.logData.orgChild2DnaId = payload.orgChild2DnaId ?? "";
|
||||||
|
request.app.locals.logData.orgChild3DnaId = payload.orgChild3DnaId ?? "";
|
||||||
|
request.app.locals.logData.orgChild4DnaId = payload.orgChild4DnaId ?? "";
|
||||||
|
request.app.locals.logData.empType = payload.empType ?? "";
|
||||||
|
request.app.locals.logData.prefix = payload.prefix ?? "";
|
||||||
|
|
||||||
return payload;
|
return payload;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -45,21 +45,24 @@ async function logMiddleware(req: Request, res: Response, next: NextFunction) {
|
||||||
if (level === 2 && res.statusCode < 400) return;
|
if (level === 2 && res.statusCode < 400) return;
|
||||||
if (level === 3 && res.statusCode < 200) return;
|
if (level === 3 && res.statusCode < 200) return;
|
||||||
|
|
||||||
const token = req.headers["authorization"];
|
// const token = req.headers["authorization"];
|
||||||
let rootId = null;
|
// let rootId = null;
|
||||||
|
|
||||||
try {
|
// try {
|
||||||
rootId = token
|
// rootId = token
|
||||||
? await new permission().checkRootDna(token, req.app.locals.logData.userId)
|
// ? await new permission().checkOrg(token, req.app.locals.logData.userId)
|
||||||
: null;
|
// : null;
|
||||||
} catch (err) {
|
// } catch (err) {
|
||||||
console.warn("Error fetching rootId:", err);
|
// console.warn("Error fetching rootId:", err);
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
// Get rootId from token
|
||||||
|
const rootId = req.app.locals.logData?.orgRootDnaId;
|
||||||
|
|
||||||
const obj = {
|
const obj = {
|
||||||
logType: res.statusCode >= 500 ? "error" : res.statusCode >= 400 ? "warning" : "info",
|
logType: res.statusCode >= 500 ? "error" : res.statusCode >= 400 ? "warning" : "info",
|
||||||
ip: req.ip,
|
ip: req.ip,
|
||||||
rootId: rootId?.rootDnaId ?? null,
|
rootId: rootId ?? null,
|
||||||
systemName: "development",
|
systemName: "development",
|
||||||
startTimeStamp: timestamp,
|
startTimeStamp: timestamp,
|
||||||
endTimeStamp: new Date().toISOString(),
|
endTimeStamp: new Date().toISOString(),
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||||
|
|
||||||
|
export class UpdateTablePortfolioAddFieldPosition_1773974268282 implements MigrationInterface {
|
||||||
|
name = 'UpdateTablePortfolioAddFieldPosition_1773974268282'
|
||||||
|
|
||||||
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`ALTER TABLE \`portfolio\` ADD \`position\` varchar(255) NULL COMMENT 'ตำแหน่ง'`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`portfolio\` ADD \`posLevel\` varchar(255) NULL COMMENT 'ระดับตำแหน่ง'`);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`ALTER TABLE \`portfolio\` DROP COLUMN \`posLevel\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`portfolio\` DROP COLUMN \`position\``);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue