no message

This commit is contained in:
Kittapath 2024-02-28 14:46:17 +07:00
parent 6ed7265094
commit 8339e6ce6d
4 changed files with 32 additions and 25 deletions

View file

@ -28,6 +28,7 @@ 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")
@ -772,30 +773,25 @@ export class SalaryPeriodController extends Controller {
const salaryProfile = await this.salaryProfileRepository.find({ const salaryProfile = await this.salaryProfileRepository.find({
where: { salaryOrgId: In(salaryOrg.map((x) => x.id)) }, where: { salaryOrgId: In(salaryOrg.map((x) => x.id)) },
}); });
await this.salaryOrgRepository.remove(salaryOrg);
await this.salaryProfileRepository.remove(salaryProfile); await this.salaryProfileRepository.remove(salaryProfile);
await this.salaryOrgRepository.remove(salaryOrg);
console.log("11111111111111111111111");
let orgs = await new CallAPI().GetData(request, "org/active/root/id"); let orgs = await new CallAPI().GetData(request, "org/active/root/id");
console.log("22222222222222222222222"); let total = 1000;
let orgProfiles: any; let _orgProfiles = await new CallAPI().PostData(request, "org/profile/salary/gen", {
await new CallAPI() page: 1,
.PostData(request, "org/profile/salary/gen", { pageSize: 1000,
page: 1, keyword: "",
pageSize: 100, });
keyword: "", let orgProfiles = _orgProfiles.data;
}) total = _orgProfiles.total;
.then((x) => { if (total > 1000) {
orgProfiles = x.data; const page = Math.ceil(total / 1000);
});
console.log("333333333333333333333");
if (orgProfiles.total > 100) {
const page = Math.ceil(orgProfiles.total.length / 100);
for (let index = 2; index <= page; index++) { for (let index = 2; index <= page; index++) {
await new CallAPI() await new CallAPI()
.PostData(request, "org/profile/salary/gen", { .PostData(request, "org/profile/salary/gen", {
page: index, page: index,
pageSize: 100, pageSize: 1000,
keyword: "", keyword: "",
}) })
.then((x) => { .then((x) => {
@ -803,9 +799,7 @@ export class SalaryPeriodController extends Controller {
}); });
} }
} }
console.log("44444444444444444444444");
let revisionId = await new CallAPI().GetData(request, "org/revision/latest"); let revisionId = await new CallAPI().GetData(request, "org/revision/latest");
console.log("55555555555555555555555");
salaryPeriod.revisionId = revisionId; salaryPeriod.revisionId = revisionId;
await this.salaryPeriodRepository.save(salaryPeriod); await this.salaryPeriodRepository.save(salaryPeriod);

View file

@ -37,11 +37,13 @@ export class SalaryOrg extends EntityBase {
snapshot: string; snapshot: string;
@Column({ @Column({
default: 0,
comment: "จำนวนคนทั้งหมด", comment: "จำนวนคนทั้งหมด",
}) })
total: number; total: number;
@Column({ @Column({
default: 0,
comment: "15%ของจำนวนคน(จำนวนเต็ม)", comment: "15%ของจำนวนคน(จำนวนเต็ม)",
}) })
fifteenPercent: number; fifteenPercent: number;

View file

@ -35,17 +35,12 @@ class CallAPI {
const token = request.headers.authorization; const token = request.headers.authorization;
const url = process.env.API + path; const url = process.env.API + path;
try { try {
console.log("response"); const response = await axios.post(url, sendData, {
console.log(url);
console.log("response");
const response = await axios.post(url, {
headers: { headers: {
Authorization: `Bearer ${token}`, Authorization: `Bearer ${token}`,
"Content-Type": "application/json", "Content-Type": "application/json",
}, },
json: sendData,
}); });
console.log(response);
return response.data.result; return response.data.result;
} catch (error) { } catch (error) {
throw error; throw error;

View file

@ -0,0 +1,16 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class UpdateTableSalaryProfileAddRevision31709105846886 implements MigrationInterface {
name = 'UpdateTableSalaryProfileAddRevision31709105846886'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`salaryOrg\` CHANGE \`total\` \`total\` int NOT NULL COMMENT 'จำนวนคนทั้งหมด' DEFAULT '0'`);
await queryRunner.query(`ALTER TABLE \`salaryOrg\` CHANGE \`fifteenPercent\` \`fifteenPercent\` int NOT NULL COMMENT '15%ของจำนวนคน(จำนวนเต็ม)' DEFAULT '0'`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`salaryOrg\` CHANGE \`fifteenPercent\` \`fifteenPercent\` int NOT NULL COMMENT '15%ของจำนวนคน(จำนวนเต็ม)'`);
await queryRunner.query(`ALTER TABLE \`salaryOrg\` CHANGE \`total\` \`total\` int NOT NULL COMMENT 'จำนวนคนทั้งหมด'`);
}
}