Merge branch 'develop' into adiDev

This commit is contained in:
AdisakKanthawilang 2025-04-25 13:59:44 +07:00
commit 1a8aad2d5f
16 changed files with 847 additions and 7268 deletions

View file

@ -1741,12 +1741,17 @@ export class CommandController extends Controller {
return {
no: Extension.ToThaiNumber((idx + 1).toString()),
org:
(_child4 == null ? "" : _child4 + "\n") +
(_child3 == null ? "" : _child3 + "\n") +
(_child2 == null ? "" : _child2 + "\n") +
(_child1 == null ? "" : _child1 + "\n") +
(_root == null ? "" : _root),
org: commandCode != "C-PM-21"
? (_child4 == null ? "" : _child4 + "\n") +
(_child3 == null ? "" : _child3 + "\n") +
(_child2 == null ? "" : _child2 + "\n") +
(_child1 == null ? "" : _child1 + "\n") +
(_root == null ? "" : _root)
: (profile?.child4Temp == null ? "" : profile?.child4Temp + "\n") +
(profile?.child3Temp == null ? "" : profile?.child3Temp + "\n") +
(profile?.child2Temp == null ? "" : profile?.child2Temp + "\n") +
(profile?.child1Temp == null ? "" : profile?.child1Temp + "\n") +
(profile?.rootTemp == null ? "" : profile?.rootTemp),
fullName: `${x.prefix}${x.firstName} ${x.lastName}`,
citizenId: Extension.ToThaiNumber(x.citizenId),
position: profile?.position ? profile?.position : "-",
@ -1756,11 +1761,25 @@ export class CommandController extends Controller {
`${profile?.posType.posTypeShortName} ${profile?.posLevel.posLevelName}`,
)
: "-",
posNo: shortName ? Extension.ToThaiNumber(shortName) : "-",
amount: x.amount ? Extension.ToThaiNumber(x.amount.toString()) : "-",
dateRetire: profile?.dateRetire
? Extension.ToThaiNumber(Extension.ToThaiShortDate_monthYear(profile?.dateRetire))
: "-",
posNo: commandCode != "C-PM-21"
? shortName
? Extension.ToThaiNumber(shortName)
: "-"
: Extension.ToThaiNumber(`${profile?.rootShortNameTemp}${profile?.posMasterNoTemp}`) ,
amount: x.amount ? Extension.ToThaiNumber(x.amount.toLocaleString()) : "-",
dateRetire: profile?.dateRetire
? Extension.ToThaiNumber(
Extension.ToThaiShortDate_monthYear(profile?.dateRetire)
)
: profile?.birthDate && commandCode == "C-PM-21"
? Extension.ToThaiNumber(
Extension.ToThaiShortDate_monthYear(
new Date(
profile.birthDate.getFullYear() + 60, profile.birthDate.getMonth(), profile.birthDate.getDate()
)
)
)
: "-",
dateExecute: command.commandExcecuteDate
? Extension.ToThaiNumber(
Extension.ToThaiShortDate_monthYear(command.commandExcecuteDate),

View file

@ -5458,4 +5458,132 @@ export class ProfileEmployeeController extends Controller {
}
return new HttpSuccess(_profile);
}
async sendVerifyEmail(
@Request() req: RequestWithUser,
@Body()
body: {
profileId: string;
email: string;
subject: string;
},
) {
const jwt = require("jsonwebtoken");
const token = jwt.sign(
{ email_id: body.email, profileId: body.profileId },
process.env.AUTH_ACCOUNT_SECRET,
{ expiresIn: "15m" },
);
const link = process.env.VITE_URL_USER + "/verifyemail?upn=" + token;
await new CallAPI()
.PostData(req, "/placement/noti/send-mail", {
subject: body.subject,
body: link,
Email: body.email,
})
.catch((error) => {
console.error("Error calling API:", error);
});
return new HttpSuccess();
}
/**
* API
*
* @summary (USER)
*
*/
@Put("updatePhoneNumber/user")
async updatePhoneNumber(
@Request() request: RequestWithUser,
@Body()
body: {
phone: string;
},
) {
const profile = await this.profileRepo.findOne({
relations: {
posLevel: true,
posType: true,
},
where: { keycloak: request.user.sub },
});
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
const history = new ProfileEmployeeHistory();
Object.assign(profile, body);
Object.assign(history, { ...profile, id: undefined });
profile.lastUpdateUserId = request.user.sub;
profile.lastUpdateFullName = request.user.name;
profile.lastUpdatedAt = new Date();
history.lastUpdateUserId = request.user.sub;
history.lastUpdateFullName = request.user.name;
history.createdUserId = request.user.sub;
history.createdFullName = request.user.name;
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([
this.profileRepo.save(profile, { data: request }),
this.profileHistoryRepo.save(history, { data: request }),
]);
return new HttpSuccess();
}
/**
* API
*
* @summary (USER)
*
*/
@Put("updateEmail/user")
async updateEmail(
@Request() request: RequestWithUser,
@Body()
body: {
email: string;
},
) {
const profile = await this.profileRepo.findOne({
relations: {
posLevel: true,
posType: true,
},
where: { keycloak: request.user.sub },
});
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
const history = new ProfileEmployeeHistory();
Object.assign(profile, body);
Object.assign(history, { ...profile, id: undefined });
profile.statusEmail = "NOT_VERIFIED";
profile.lastUpdateUserId = request.user.sub;
profile.lastUpdateFullName = request.user.name;
profile.lastUpdatedAt = new Date();
history.lastUpdateUserId = request.user.sub;
history.lastUpdateFullName = request.user.name;
history.createdUserId = request.user.sub;
history.createdFullName = request.user.name;
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([
this.profileRepo.save(profile, { data: request }),
this.profileHistoryRepo.save(history, { data: request }),
]);
const verifyemailBody = {
profileId: profile.id,
email: body.email,
subject: "ยืนยันอีเมล",
};
this.sendVerifyEmail(request, verifyemailBody);
return new HttpSuccess();
}
}

View file

@ -4023,4 +4023,132 @@ export class ProfileEmployeeTempController extends Controller {
}
return new HttpSuccess(_profile);
}
async sendVerifyEmail(
@Request() req: RequestWithUser,
@Body()
body: {
profileId: string;
email: string;
subject: string;
},
) {
const jwt = require("jsonwebtoken");
const token = jwt.sign(
{ email_id: body.email, profileId: body.profileId },
process.env.AUTH_ACCOUNT_SECRET,
{ expiresIn: "15m" },
);
const link = process.env.VITE_URL_USER + "/verifyemail?upn=" + token;
await new CallAPI()
.PostData(req, "/placement/noti/send-mail", {
subject: body.subject,
body: link,
Email: body.email,
})
.catch((error) => {
console.error("Error calling API:", error);
});
return new HttpSuccess();
}
/**
* API
*
* @summary (USER)
*
*/
@Put("updatePhoneNumber/user")
async updatePhoneNumber(
@Request() request: RequestWithUser,
@Body()
body: {
phone: string;
},
) {
const profile = await this.profileRepo.findOne({
relations: {
posLevel: true,
posType: true,
},
where: { keycloak: request.user.sub },
});
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
const history = new ProfileEmployeeHistory();
Object.assign(profile, body);
Object.assign(history, { ...profile, id: undefined });
profile.lastUpdateUserId = request.user.sub;
profile.lastUpdateFullName = request.user.name;
profile.lastUpdatedAt = new Date();
history.lastUpdateUserId = request.user.sub;
history.lastUpdateFullName = request.user.name;
history.createdUserId = request.user.sub;
history.createdFullName = request.user.name;
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([
this.profileRepo.save(profile, { data: request }),
this.profileHistoryRepo.save(history, { data: request }),
]);
return new HttpSuccess();
}
/**
* API
*
* @summary (USER)
*
*/
@Put("updateEmail/user")
async updateEmail(
@Request() request: RequestWithUser,
@Body()
body: {
email: string;
},
) {
const profile = await this.profileRepo.findOne({
relations: {
posLevel: true,
posType: true,
},
where: { keycloak: request.user.sub },
});
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
const history = new ProfileEmployeeHistory();
Object.assign(profile, body);
Object.assign(history, { ...profile, id: undefined });
profile.statusEmail = "NOT_VERIFIED";
profile.lastUpdateUserId = request.user.sub;
profile.lastUpdateFullName = request.user.name;
profile.lastUpdatedAt = new Date();
history.lastUpdateUserId = request.user.sub;
history.lastUpdateFullName = request.user.name;
history.createdUserId = request.user.sub;
history.createdFullName = request.user.name;
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([
this.profileRepo.save(profile, { data: request }),
this.profileHistoryRepo.save(history, { data: request }),
]);
const verifyemailBody = {
profileId: profile.id,
email: body.email,
subject: "ยืนยันอีเมล",
};
this.sendVerifyEmail(request, verifyemailBody);
return new HttpSuccess();
}
}

View file

@ -632,6 +632,11 @@ export class ProfileSalaryController extends Controller {
lastUpdatedAt: new Date(),
};
const _null: any = null;
if (body.commandCode && !body.commandName) {
if (body.commandCode == "7") body.commandName = "เงินพิเศษอื่น ๆ"
else if (body.commandCode == "6") body.commandName = "เลื่อนเงินเดือนกรณีอื่น ๆ"
else if (body.commandCode == "5") body.commandName = "เลื่อนเงินเดือนตามปกติ"
}
Object.assign(data, { ...body, ...meta });
const history = new ProfileSalaryHistory();
Object.assign(history, { ...data, id: undefined });
@ -706,7 +711,11 @@ export class ProfileSalaryController extends Controller {
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_OFFICER", record.profileId);
const before = structuredClone(record);
const history = new ProfileSalaryHistory();
if (body.commandCode && !body.commandName) {
if (body.commandCode == "7") body.commandName = "เงินพิเศษอื่น ๆ"
else if (body.commandCode == "6") body.commandName = "เลื่อนเงินเดือนกรณีอื่น ๆ"
else if (body.commandCode == "5") body.commandName = "เลื่อนเงินเดือนตามปกติ"
}
Object.assign(record, body);
Object.assign(history, { ...record, id: undefined });

View file

@ -311,7 +311,11 @@ export class ProfileSalaryEmployeeController extends Controller {
createdAt: new Date(),
lastUpdatedAt: new Date(),
};
if (body.commandCode && !body.commandName) {
if (body.commandCode == "7") body.commandName = "เงินพิเศษอื่น ๆ"
else if (body.commandCode == "6") body.commandName = "เลื่อนเงินเดือนกรณีอื่น ๆ"
else if (body.commandCode == "5") body.commandName = "เลื่อนเงินเดือนตามปกติ"
}
Object.assign(data, { ...body, ...meta });
const history = new ProfileSalaryHistory();
Object.assign(history, { ...data, id: undefined });
@ -395,7 +399,11 @@ export class ProfileSalaryEmployeeController extends Controller {
);
const before = structuredClone(record);
const history = new ProfileSalaryHistory();
if (body.commandCode && !body.commandName) {
if (body.commandCode == "7") body.commandName = "เงินพิเศษอื่น ๆ"
else if (body.commandCode == "6") body.commandName = "เลื่อนเงินเดือนกรณีอื่น ๆ"
else if (body.commandCode == "5") body.commandName = "เลื่อนเงินเดือนตามปกติ"
}
Object.assign(record, body);
Object.assign(history, { ...record, id: undefined });

View file

@ -125,7 +125,11 @@ export class ProfileSalaryEmployeeTempController extends Controller {
createdAt: new Date(),
lastUpdatedAt: new Date(),
};
if (body.commandCode && !body.commandName) {
if (body.commandCode == "7") body.commandName = "เงินพิเศษอื่น ๆ"
else if (body.commandCode == "6") body.commandName = "เลื่อนเงินเดือนกรณีอื่น ๆ"
else if (body.commandCode == "5") body.commandName = "เลื่อนเงินเดือนตามปกติ"
}
Object.assign(data, { ...body, ...meta });
const history = new ProfileSalaryHistory();
Object.assign(history, { ...data, id: undefined });
@ -150,7 +154,11 @@ export class ProfileSalaryEmployeeTempController extends Controller {
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
const before = structuredClone(record);
const history = new ProfileSalaryHistory();
if (body.commandCode && !body.commandName) {
if (body.commandCode == "7") body.commandName = "เงินพิเศษอื่น ๆ"
else if (body.commandCode == "6") body.commandName = "เลื่อนเงินเดือนกรณีอื่น ๆ"
else if (body.commandCode == "5") body.commandName = "เลื่อนเงินเดือนตามปกติ"
}
Object.assign(record, body);
Object.assign(history, { ...record, id: undefined });

View file

@ -178,6 +178,14 @@ export class ProfileEmployee extends EntityBase {
})
email: string;
@Column({
nullable: true,
comment: "สถานะอีเมล", //VERIFIED = ยืนยัน, NOT_VERIFIED = ไม่ได้ยืนยัน
length: 20,
default: null,
})
statusEmail: string;
@Column({
nullable: true,
length: 20,

View file

@ -69,9 +69,11 @@ import { ViewColumn, ViewEntity } from "typeorm";
WHERE
(position.positionIsSelected = TRUE)
AND (orgRevision.orgRevisionIsCurrent = TRUE
AND orgRevision.orgRevisionIsDraft = FALSE)`
AND orgRevision.orgRevisionIsDraft = FALSE)`,
})
export class viewDirector {
@ViewColumn()
keycloakId: string;
@ViewColumn()
id: string;
@ViewColumn()
@ -113,6 +115,8 @@ export class viewDirector {
@ViewColumn()
actFullNameId: string;
@ViewColumn()
actFullNameKeycloakId: string;
@ViewColumn()
actFullName: string;
@ViewColumn()
key: string;

View file

@ -56,6 +56,8 @@ import { ViewColumn, ViewEntity } from "typeorm";
(\`position\`.\`positionIsSelected\` = TRUE)`,
})
export class viewDirectorActing {
@ViewColumn()
keycloakId: string;
@ViewColumn()
id: string;
@ViewColumn()
@ -99,6 +101,8 @@ export class viewDirectorActing {
@ViewColumn()
actFullNameId: string;
@ViewColumn()
actFullNameKeycloakId: string;
@ViewColumn()
actFullName: string;
@ViewColumn()
key: string;

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long