no message
This commit is contained in:
parent
f7c7012ffe
commit
f2d2e7b025
5 changed files with 26 additions and 3 deletions
|
|
@ -1022,6 +1022,7 @@ export class CommandController extends Controller {
|
||||||
body: `${command.issue}`,
|
body: `${command.issue}`,
|
||||||
receiverUserIds: profiles,
|
receiverUserIds: profiles,
|
||||||
payload: "", //แนบไฟล์
|
payload: "", //แนบไฟล์
|
||||||
|
notiLink: "", //แนบไฟล์
|
||||||
isSendMail: true,
|
isSendMail: true,
|
||||||
isSendInbox: true,
|
isSendInbox: true,
|
||||||
isSendNotification: true,
|
isSendNotification: true,
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import { CommandSend } from "./CommandSend";
|
||||||
import { CommandSalary } from "./CommandSalary";
|
import { CommandSalary } from "./CommandSalary";
|
||||||
import { CommandRecive } from "./CommandRecive";
|
import { CommandRecive } from "./CommandRecive";
|
||||||
import { ProfileSalary } from "./ProfileSalary";
|
import { ProfileSalary } from "./ProfileSalary";
|
||||||
|
import { ProfileSalaryHistory } from "./ProfileSalaryHistory";
|
||||||
|
|
||||||
@Entity("command")
|
@Entity("command")
|
||||||
export class Command extends EntityBase {
|
export class Command extends EntityBase {
|
||||||
|
|
@ -155,6 +156,9 @@ export class Command extends EntityBase {
|
||||||
|
|
||||||
@OneToMany(() => ProfileSalary, (profileSalary) => profileSalary.command)
|
@OneToMany(() => ProfileSalary, (profileSalary) => profileSalary.command)
|
||||||
profileSalarys: ProfileSalary[];
|
profileSalarys: ProfileSalary[];
|
||||||
|
|
||||||
|
@OneToMany(() => ProfileSalaryHistory, (profileSalaryHistory) => profileSalaryHistory.command)
|
||||||
|
profileSalaryHistorys: ProfileSalaryHistory[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export class CreateCommand {
|
export class CreateCommand {
|
||||||
|
|
|
||||||
|
|
@ -194,6 +194,7 @@ export class CreateProfileSalary {
|
||||||
positionType: string | null;
|
positionType: string | null;
|
||||||
positionLevel: string | null;
|
positionLevel: string | null;
|
||||||
refCommandNo: string | null;
|
refCommandNo: string | null;
|
||||||
|
commandId: string | null;
|
||||||
// commandType?: string | null;
|
// commandType?: string | null;
|
||||||
templateDoc: string | null;
|
templateDoc: string | null;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import { Entity, Column, JoinColumn, ManyToOne, Double } from "typeorm";
|
import { Entity, Column, JoinColumn, ManyToOne, Double } from "typeorm";
|
||||||
import { EntityBase } from "./base/Base";
|
import { EntityBase } from "./base/Base";
|
||||||
import { ProfileSalary } from "./ProfileSalary";
|
import { ProfileSalary } from "./ProfileSalary";
|
||||||
|
import { Command } from "./Command";
|
||||||
|
|
||||||
@Entity("profileSalaryHistory")
|
@Entity("profileSalaryHistory")
|
||||||
export class ProfileSalaryHistory extends EntityBase {
|
export class ProfileSalaryHistory extends EntityBase {
|
||||||
|
|
@ -127,6 +128,18 @@ export class ProfileSalaryHistory extends EntityBase {
|
||||||
})
|
})
|
||||||
order: number;
|
order: number;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
length: 40,
|
||||||
|
comment: "คีย์นอก(FK)ของตาราง command",
|
||||||
|
default: null,
|
||||||
|
})
|
||||||
|
commandId: string;
|
||||||
|
|
||||||
|
@ManyToOne(() => Command, (command) => command.profileSalaryHistorys)
|
||||||
|
@JoinColumn({ name: "commandId" })
|
||||||
|
command: Command;
|
||||||
|
|
||||||
@ManyToOne(() => ProfileSalary, (profileSalary) => profileSalary.profileSalaryHistories)
|
@ManyToOne(() => ProfileSalary, (profileSalary) => profileSalary.profileSalaryHistories)
|
||||||
@JoinColumn({ name: "profileSalaryId" })
|
@JoinColumn({ name: "profileSalaryId" })
|
||||||
histories: ProfileSalary;
|
histories: ProfileSalary;
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,8 @@ import { RequestWithUser } from "../middlewares/user";
|
||||||
|
|
||||||
export let sendToQueue: (payload: any) => void;
|
export let sendToQueue: (payload: any) => void;
|
||||||
|
|
||||||
export async function init() { //----> (1) Producer
|
export async function init() {
|
||||||
|
//----> (1) Producer
|
||||||
if (!process.env.AMQ_URL || !process.env.AMQ_QUEUE) return;
|
if (!process.env.AMQ_URL || !process.env.AMQ_QUEUE) return;
|
||||||
|
|
||||||
const { AMQ_URL: url, AMQ_QUEUE: queue } = process.env; //----> (1.2) get url and queue from .env
|
const { AMQ_URL: url, AMQ_QUEUE: queue } = process.env; //----> (1.2) get url and queue from .env
|
||||||
|
|
@ -21,7 +22,8 @@ export async function init() { //----> (1) Producer
|
||||||
channel.assertQueue(queue, { durable: true }); //----> (1.5) assert queue and set durable (if "true" save to disk on RabbitMQ)
|
channel.assertQueue(queue, { durable: true }); //----> (1.5) assert queue and set durable (if "true" save to disk on RabbitMQ)
|
||||||
channel.prefetch(1);
|
channel.prefetch(1);
|
||||||
|
|
||||||
sendToQueue = (payload: any, persistent = true) => { //----> (2) sendQueue To RabbitMQ and set persistent (if "true" redo the failed queue when server run again)
|
sendToQueue = (payload: any, persistent = true) => {
|
||||||
|
//----> (2) sendQueue To RabbitMQ and set persistent (if "true" redo the failed queue when server run again)
|
||||||
channel.sendToQueue(queue, Buffer.from(JSON.stringify(payload)), {
|
channel.sendToQueue(queue, Buffer.from(JSON.stringify(payload)), {
|
||||||
persistent,
|
persistent,
|
||||||
});
|
});
|
||||||
|
|
@ -52,7 +54,8 @@ function createConsumer( //----> consumer
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handler(msg: amqp.ConsumeMessage): Promise<boolean> { //----> condition before process consumer
|
async function handler(msg: amqp.ConsumeMessage): Promise<boolean> {
|
||||||
|
//----> condition before process consumer
|
||||||
const repo = AppDataSource.getRepository(Command);
|
const repo = AppDataSource.getRepository(Command);
|
||||||
const { data, token, user } = JSON.parse(msg.content.toString());
|
const { data, token, user } = JSON.parse(msg.content.toString());
|
||||||
|
|
||||||
|
|
@ -82,6 +85,7 @@ async function handler(msg: amqp.ConsumeMessage): Promise<boolean> { //----> con
|
||||||
commandAffectDate: command.commandAffectDate,
|
commandAffectDate: command.commandAffectDate,
|
||||||
commandNo: command.commandNo,
|
commandNo: command.commandNo,
|
||||||
commandYear: command.commandYear,
|
commandYear: command.commandYear,
|
||||||
|
commandId: command.id,
|
||||||
templateDoc: command.positionDetail,
|
templateDoc: command.positionDetail,
|
||||||
amount: x.amount,
|
amount: x.amount,
|
||||||
positionSalaryAmount: x.positionSalaryAmount,
|
positionSalaryAmount: x.positionSalaryAmount,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue