Merge branch 'develop' of github.com:Frappet/hrms-api-org into develop
This commit is contained in:
commit
536cfaa240
4 changed files with 76 additions and 43 deletions
|
|
@ -67,8 +67,8 @@ async function main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
// const cronTime_Oct = "0 0 1 10 *";
|
// const cronTime_Oct = "0 0 1 10 *";
|
||||||
// Test #1892
|
// Test #1912
|
||||||
const cronTime_Oct = "0 0 31 10 *";
|
const cronTime_Oct = "0 0 4 11 *";
|
||||||
cron.schedule(cronTime_Oct, async () => {
|
cron.schedule(cronTime_Oct, async () => {
|
||||||
try {
|
try {
|
||||||
const commandController = new CommandController();
|
const commandController = new CommandController();
|
||||||
|
|
|
||||||
|
|
@ -1477,24 +1477,6 @@ export class CommandController extends Controller {
|
||||||
}
|
}
|
||||||
// @Get("XXX")
|
// @Get("XXX")
|
||||||
async cronjobUpdateRetirementStatus(/*@Request() request: RequestWithUser*/) {
|
async cronjobUpdateRetirementStatus(/*@Request() request: RequestWithUser*/) {
|
||||||
// let body = {
|
|
||||||
// client_id: "gettoken",
|
|
||||||
// client_secret: process.env.AUTH_ACCOUNT_SECRET,
|
|
||||||
// grant_type: "client_credentials",
|
|
||||||
// };
|
|
||||||
// const postData = querystring.stringify(body);
|
|
||||||
// const response = await axios.post(
|
|
||||||
// `${process.env.KC_URL}/realms/${process.env.KC_REALMS}/protocol/openid-connect/token`,
|
|
||||||
// postData,
|
|
||||||
// {
|
|
||||||
// headers: {
|
|
||||||
// "Content-Type": "application/x-www-form-urlencoded",
|
|
||||||
// api_key: process.env.API_KEY,
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// );
|
|
||||||
// const adminToken = response.data.access_token;
|
|
||||||
// const adminToken = request.headers["authorization"]?.replace("Bearer ", "");
|
|
||||||
const adminToken = await getToken() ?? "";
|
const adminToken = await getToken() ?? "";
|
||||||
const today = new Date();
|
const today = new Date();
|
||||||
today.setUTCHours(0, 0, 0, 0);
|
today.setUTCHours(0, 0, 0, 0);
|
||||||
|
|
@ -1668,32 +1650,30 @@ export class CommandController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
async posMasterRetire(profileId: string, type: string, _Date: Date) {
|
async posMasterRetire(profileId: string, type: string, _Date: Date) {
|
||||||
const orgRevision = await this.orgRevisionRepo.findOne({
|
const revisionIsCurrent = await this.orgRevisionRepo.findOne({
|
||||||
where: { orgRevisionIsCurrent: true, orgRevisionIsDraft: false },
|
where: { orgRevisionIsCurrent: true, orgRevisionIsDraft: false },
|
||||||
});
|
});
|
||||||
if (orgRevision) {
|
if (revisionIsCurrent) {
|
||||||
let _posMaster: any = null;
|
let _posMaster: any = null;
|
||||||
let _position: any = null;
|
|
||||||
if (type == "OFFICER") {
|
if (type == "OFFICER") {
|
||||||
_posMaster = await this.posMasterRepository.findOne({
|
_posMaster = await this.posMasterRepository.findOne({
|
||||||
where: {
|
where: {
|
||||||
orgRevisionId: orgRevision.id,
|
orgRevisionId: revisionIsCurrent.id,
|
||||||
current_holderId: profileId,
|
current_holderId: profileId,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
if (_posMaster) {
|
if (_posMaster) {
|
||||||
_position = await this.positionRepository.findOne({
|
await this.positionRepository.update(
|
||||||
where: {
|
{
|
||||||
posMasterId: _posMaster.id,
|
posMasterId: _posMaster.id,
|
||||||
positionIsSelected: true,
|
positionIsSelected: true,
|
||||||
},
|
},
|
||||||
});
|
{
|
||||||
if (_position) {
|
positionIsSelected: false,
|
||||||
_position.positionIsSelected = false;
|
lastUpdateFullName: "System Administrator",
|
||||||
_position.lastUpdateFullName = "System Administrator";
|
lastUpdatedAt: _Date,
|
||||||
_position.lastUpdatedAt = _Date;
|
}
|
||||||
await this.positionRepository.save(_position);
|
);
|
||||||
}
|
|
||||||
_posMaster.isSit = false;
|
_posMaster.isSit = false;
|
||||||
_posMaster.current_holderId = null;
|
_posMaster.current_holderId = null;
|
||||||
_posMaster.lastUpdateFullName = "System Administrator";
|
_posMaster.lastUpdateFullName = "System Administrator";
|
||||||
|
|
@ -1701,26 +1681,57 @@ export class CommandController extends Controller {
|
||||||
await this.posMasterRepository.save(_posMaster);
|
await this.posMasterRepository.save(_posMaster);
|
||||||
await CreatePosMasterHistoryOfficer(_posMaster.id, null);
|
await CreatePosMasterHistoryOfficer(_posMaster.id, null);
|
||||||
}
|
}
|
||||||
|
const revisionIsDraft = await this.orgRevisionRepo.findOne({
|
||||||
|
where: { orgRevisionIsCurrent: false, orgRevisionIsDraft: true },
|
||||||
|
});
|
||||||
|
if (revisionIsDraft) {
|
||||||
|
_posMaster = null;
|
||||||
|
_posMaster = await this.posMasterRepository.findOne({
|
||||||
|
where: {
|
||||||
|
orgRevisionId: revisionIsDraft.id,
|
||||||
|
next_holderId: profileId,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if (_posMaster) {
|
||||||
|
await this.positionRepository.update(
|
||||||
|
{
|
||||||
|
posMasterId: _posMaster.id,
|
||||||
|
positionIsSelected: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
positionIsSelected: false,
|
||||||
|
lastUpdateFullName: "System Administrator",
|
||||||
|
lastUpdatedAt: _Date,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
_posMaster.isSit = false;
|
||||||
|
_posMaster.next_holderId = null;
|
||||||
|
_posMaster.lastUpdateFullName = "System Administrator";
|
||||||
|
_posMaster.lastUpdatedAt = _Date;
|
||||||
|
await this.posMasterRepository.save(_posMaster);
|
||||||
|
await CreatePosMasterHistoryOfficer(_posMaster.id, null);
|
||||||
|
}
|
||||||
|
// console.log("clear posMaster & position 'Draf' success")
|
||||||
|
}
|
||||||
} else if (type == "EMPLOYEE") {
|
} else if (type == "EMPLOYEE") {
|
||||||
_posMaster = await this.employeePosMasterRepository.findOne({
|
_posMaster = await this.employeePosMasterRepository.findOne({
|
||||||
where: {
|
where: {
|
||||||
orgRevisionId: orgRevision.id,
|
orgRevisionId: revisionIsCurrent.id,
|
||||||
current_holderId: profileId,
|
current_holderId: profileId,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
if (_posMaster) {
|
if (_posMaster) {
|
||||||
_position = await this.employeePositionRepository.findOne({
|
await this.employeePositionRepository.update(
|
||||||
where: {
|
{
|
||||||
posMasterId: _posMaster.id,
|
posMasterId: _posMaster.id,
|
||||||
positionIsSelected: true,
|
positionIsSelected: true,
|
||||||
},
|
},
|
||||||
});
|
{
|
||||||
if (_position) {
|
positionIsSelected: false,
|
||||||
_position.positionIsSelected = false;
|
lastUpdateFullName: "System Administrator",
|
||||||
_position.lastUpdateFullName = "System Administrator";
|
lastUpdatedAt: _Date,
|
||||||
_position.lastUpdatedAt = _Date;
|
}
|
||||||
await this.employeePositionRepository.save(_position);
|
);
|
||||||
}
|
|
||||||
_posMaster.isSit = false;
|
_posMaster.isSit = false;
|
||||||
_posMaster.current_holderId = null;
|
_posMaster.current_holderId = null;
|
||||||
_posMaster.lastUpdateFullName = "System Administrator";
|
_posMaster.lastUpdateFullName = "System Administrator";
|
||||||
|
|
@ -1729,6 +1740,7 @@ export class CommandController extends Controller {
|
||||||
await CreatePosMasterHistoryEmployee(_posMaster.id, null);
|
await CreatePosMasterHistoryEmployee(_posMaster.id, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// console.log("clear posMaster & position 'Current' success")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,13 @@ export class AuthRole extends EntityBase {
|
||||||
})
|
})
|
||||||
roleDescription: string;
|
roleDescription: string;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
comment: "ข้อมูลที่ role admin สามารถเห็นได้",
|
||||||
|
default: null,
|
||||||
|
})
|
||||||
|
isAdminVisibled: boolean;
|
||||||
|
|
||||||
@OneToMany(() => AuthRoleAttr, (authRoleAttr) => authRoleAttr.authRoleAttrForRole)
|
@OneToMany(() => AuthRoleAttr, (authRoleAttr) => authRoleAttr.authRoleAttrForRole)
|
||||||
authRoles: AuthRoleAttr[];
|
authRoles: AuthRoleAttr[];
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||||
|
|
||||||
|
export class AddFieldIsAdminVisibledTableAuthRole1762165716863 implements MigrationInterface {
|
||||||
|
name = 'AddFieldIsAdminVisibledTableAuthRole1762165716863'
|
||||||
|
|
||||||
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`ALTER TABLE \`authRole\` ADD \`isAdminVisibled\` tinyint NULL COMMENT 'ข้อมูลที่ role admin สามารถเห็นได้'`);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`ALTER TABLE \`authRole\` DROP COLUMN \`isAdminVisibled\``);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue