command add position
This commit is contained in:
parent
388d6488f8
commit
a462f2bddd
3 changed files with 83 additions and 23 deletions
|
|
@ -53,7 +53,15 @@ import { PosMasterAct } from "../entities/PosMasterAct";
|
|||
import { sendToQueue } from "../services/rabbitmq";
|
||||
import { PosLevel } from "../entities/PosLevel";
|
||||
import { PosType } from "../entities/PosType";
|
||||
import { addUserRoles, createUser, getRoles, deleteUser, enableStatus, getUserByUsername, getRoleMappings } from "../keycloak";
|
||||
import {
|
||||
addUserRoles,
|
||||
createUser,
|
||||
getRoles,
|
||||
deleteUser,
|
||||
enableStatus,
|
||||
getUserByUsername,
|
||||
getRoleMappings,
|
||||
} from "../keycloak";
|
||||
import { ProfileEducation, CreateProfileEducation } from "../entities/ProfileEducation";
|
||||
import { ProfileEducationHistory } from "../entities/ProfileEducationHistory";
|
||||
import { CreateProfileCertificate, ProfileCertificate } from "../entities/ProfileCertificate";
|
||||
|
|
@ -452,6 +460,9 @@ export class CommandController extends Controller {
|
|||
amountSpecial: x.amountSpecial,
|
||||
positionSalaryAmount: x.positionSalaryAmount,
|
||||
mouthSalaryAmount: x.mouthSalaryAmount,
|
||||
position: x.position,
|
||||
posType: x.posType,
|
||||
posLevel: x.posLevel,
|
||||
})),
|
||||
};
|
||||
return new HttpSuccess(_command);
|
||||
|
|
@ -1819,6 +1830,9 @@ export class CommandController extends Controller {
|
|||
amountSpecial?: Double | null;
|
||||
positionSalaryAmount?: Double | null;
|
||||
mouthSalaryAmount?: Double | null;
|
||||
position?: string | null;
|
||||
posType?: string | null;
|
||||
posLevel?: string | null;
|
||||
}[];
|
||||
},
|
||||
@Request() request: RequestWithUser,
|
||||
|
|
@ -2564,7 +2578,7 @@ export class CommandController extends Controller {
|
|||
//คำสั่งบรรจุกลับเข้ารับราชการ หรือ ผู้ออกไปรับราชการทหารกลับเข้ารับราชการ solutionเดิม ให้ enable user เปลี่ยนเป็นสร้าง user ใหม่เลยเพราะยังไงตอนถูกพักก็ถูกลบ user
|
||||
if (returnWork && item.isGovernment) {
|
||||
let userKeycloakId;
|
||||
const checkUser = await getUserByUsername(profile.citizenId)
|
||||
const checkUser = await getUserByUsername(profile.citizenId);
|
||||
//ถ้ายังไม่มี user keycloak ให้สร้างใหม่
|
||||
if (checkUser.length == 0) {
|
||||
userKeycloakId = await createUser(profile.citizenId, profile.citizenId, {
|
||||
|
|
@ -2585,16 +2599,18 @@ export class CommandController extends Controller {
|
|||
);
|
||||
}
|
||||
profile.roleKeycloaks = result && roleKeycloak ? [roleKeycloak] : [];
|
||||
profile.keycloak = userKeycloakId && typeof userKeycloakId === "string" ? userKeycloakId : "";;
|
||||
profile.keycloak =
|
||||
userKeycloakId && typeof userKeycloakId === "string" ? userKeycloakId : "";
|
||||
}
|
||||
//ถ้ามีอยู่แล้วให้ใช้อันเดิม
|
||||
else {
|
||||
const rolesData = await getRoleMappings(checkUser[0].id);
|
||||
if(rolesData) {
|
||||
if (rolesData) {
|
||||
const _roleKeycloak = await this.roleKeycloakRepo.find({
|
||||
where: { name: In(rolesData.map((x:any) => x.name)) }
|
||||
where: { name: In(rolesData.map((x: any) => x.name)) },
|
||||
});
|
||||
profile.roleKeycloaks = _roleKeycloak && _roleKeycloak.length > 0 ? _roleKeycloak : [];
|
||||
profile.roleKeycloaks =
|
||||
_roleKeycloak && _roleKeycloak.length > 0 ? _roleKeycloak : [];
|
||||
}
|
||||
profile.keycloak = checkUser[0].id;
|
||||
}
|
||||
|
|
@ -3925,9 +3941,9 @@ export class CommandController extends Controller {
|
|||
item.bodyProfile.birthDate == null
|
||||
? _null
|
||||
: calculateRetireLaw(item.bodyProfile.birthDate);
|
||||
|
||||
const checkUser = await getUserByUsername(profile.citizenId)
|
||||
if(checkUser.length == 0) {
|
||||
|
||||
const checkUser = await getUserByUsername(profile.citizenId);
|
||||
if (checkUser.length == 0) {
|
||||
const userKeycloakId = await createUser(profile.citizenId, profile.citizenId, {
|
||||
firstName: profile.firstName,
|
||||
lastName: profile.lastName,
|
||||
|
|
@ -3945,15 +3961,16 @@ export class CommandController extends Controller {
|
|||
})),
|
||||
);
|
||||
profile.roleKeycloaks = result && roleKeycloak ? [roleKeycloak] : [];
|
||||
profile.keycloak = userKeycloakId && typeof userKeycloakId === "string" ? userKeycloakId : "";
|
||||
}
|
||||
else {
|
||||
profile.keycloak =
|
||||
userKeycloakId && typeof userKeycloakId === "string" ? userKeycloakId : "";
|
||||
} else {
|
||||
const rolesData = await getRoleMappings(checkUser[0].id);
|
||||
if(rolesData) {
|
||||
if (rolesData) {
|
||||
const _roleKeycloak = await this.roleKeycloakRepo.find({
|
||||
where: { name: In(rolesData.map((x:any) => x.name)) }
|
||||
where: { name: In(rolesData.map((x: any) => x.name)) },
|
||||
});
|
||||
profile.roleKeycloaks = _roleKeycloak && _roleKeycloak.length > 0 ? _roleKeycloak : [];
|
||||
profile.roleKeycloaks =
|
||||
_roleKeycloak && _roleKeycloak.length > 0 ? _roleKeycloak : [];
|
||||
}
|
||||
profile.keycloak = checkUser[0].id;
|
||||
}
|
||||
|
|
@ -4325,8 +4342,8 @@ export class CommandController extends Controller {
|
|||
|
||||
if (positionNew != null) {
|
||||
// Create Keycloak
|
||||
const checkUser = await getUserByUsername(profile.citizenId)
|
||||
if(checkUser.length == 0) {
|
||||
const checkUser = await getUserByUsername(profile.citizenId);
|
||||
if (checkUser.length == 0) {
|
||||
const userKeycloakId = await createUser(profile.citizenId, profile.citizenId, {
|
||||
firstName: profile.firstName,
|
||||
lastName: profile.lastName,
|
||||
|
|
@ -4348,17 +4365,18 @@ export class CommandController extends Controller {
|
|||
})),
|
||||
);
|
||||
// if (!result) throw new Error("Failed. Cannot set user's role.");
|
||||
profile.keycloak = userKeycloakId && typeof userKeycloakId == "string" ? userKeycloakId : "";
|
||||
profile.keycloak =
|
||||
userKeycloakId && typeof userKeycloakId == "string" ? userKeycloakId : "";
|
||||
profile.roleKeycloaks = result && roleKeycloak ? [roleKeycloak] : [];
|
||||
// End Create Keycloak
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
const rolesData = await getRoleMappings(checkUser[0].id);
|
||||
if(rolesData) {
|
||||
if (rolesData) {
|
||||
const _roleKeycloak = await this.roleKeycloakRepo.find({
|
||||
where: { name: In(rolesData.map((x:any) => x.name)) }
|
||||
where: { name: In(rolesData.map((x: any) => x.name)) },
|
||||
});
|
||||
profile.roleKeycloaks = _roleKeycloak && _roleKeycloak.length > 0 ? _roleKeycloak : [];
|
||||
profile.roleKeycloaks =
|
||||
_roleKeycloak && _roleKeycloak.length > 0 ? _roleKeycloak : [];
|
||||
}
|
||||
profile.keycloak = checkUser[0].id;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,6 +36,30 @@ export class CommandRecive extends EntityBase {
|
|||
})
|
||||
lastName: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "ตำแหน่ง",
|
||||
length: 255,
|
||||
default: null,
|
||||
})
|
||||
position: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "ประเภท",
|
||||
length: 255,
|
||||
default: null,
|
||||
})
|
||||
posType: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "ระดับ",
|
||||
length: 255,
|
||||
default: null,
|
||||
})
|
||||
posLevel: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "ลำดับแสดงผล",
|
||||
|
|
|
|||
18
src/migration/1737715789621-UpdateCommandAddPosition.ts
Normal file
18
src/migration/1737715789621-UpdateCommandAddPosition.ts
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class UpdateCommandAddPosition1737715789621 implements MigrationInterface {
|
||||
name = 'UpdateCommandAddPosition1737715789621'
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE \`commandRecive\` ADD \`position\` varchar(255) NULL COMMENT 'ตำแหน่ง'`);
|
||||
await queryRunner.query(`ALTER TABLE \`commandRecive\` ADD \`posType\` varchar(255) NULL COMMENT 'ประเภท'`);
|
||||
await queryRunner.query(`ALTER TABLE \`commandRecive\` ADD \`posLevel\` varchar(255) NULL COMMENT 'ระดับ'`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE \`commandRecive\` DROP COLUMN \`posLevel\``);
|
||||
await queryRunner.query(`ALTER TABLE \`commandRecive\` DROP COLUMN \`posType\``);
|
||||
await queryRunner.query(`ALTER TABLE \`commandRecive\` DROP COLUMN \`position\``);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue