no message

This commit is contained in:
kittapath 2024-10-18 16:11:22 +07:00
parent f7c7012ffe
commit f2d2e7b025
5 changed files with 26 additions and 3 deletions

View file

@ -1022,6 +1022,7 @@ export class CommandController extends Controller {
body: `${command.issue}`,
receiverUserIds: profiles,
payload: "", //แนบไฟล์
notiLink: "", //แนบไฟล์
isSendMail: true,
isSendInbox: true,
isSendNotification: true,

View file

@ -5,6 +5,7 @@ import { CommandSend } from "./CommandSend";
import { CommandSalary } from "./CommandSalary";
import { CommandRecive } from "./CommandRecive";
import { ProfileSalary } from "./ProfileSalary";
import { ProfileSalaryHistory } from "./ProfileSalaryHistory";
@Entity("command")
export class Command extends EntityBase {
@ -155,6 +156,9 @@ export class Command extends EntityBase {
@OneToMany(() => ProfileSalary, (profileSalary) => profileSalary.command)
profileSalarys: ProfileSalary[];
@OneToMany(() => ProfileSalaryHistory, (profileSalaryHistory) => profileSalaryHistory.command)
profileSalaryHistorys: ProfileSalaryHistory[];
}
export class CreateCommand {

View file

@ -194,6 +194,7 @@ export class CreateProfileSalary {
positionType: string | null;
positionLevel: string | null;
refCommandNo: string | null;
commandId: string | null;
// commandType?: string | null;
templateDoc: string | null;
}

View file

@ -1,6 +1,7 @@
import { Entity, Column, JoinColumn, ManyToOne, Double } from "typeorm";
import { EntityBase } from "./base/Base";
import { ProfileSalary } from "./ProfileSalary";
import { Command } from "./Command";
@Entity("profileSalaryHistory")
export class ProfileSalaryHistory extends EntityBase {
@ -127,6 +128,18 @@ export class ProfileSalaryHistory extends EntityBase {
})
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)
@JoinColumn({ name: "profileSalaryId" })
histories: ProfileSalary;

View file

@ -9,7 +9,8 @@ import { RequestWithUser } from "../middlewares/user";
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;
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.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)), {
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 { data, token, user } = JSON.parse(msg.content.toString());
@ -82,6 +85,7 @@ async function handler(msg: amqp.ConsumeMessage): Promise<boolean> { //----> con
commandAffectDate: command.commandAffectDate,
commandNo: command.commandNo,
commandYear: command.commandYear,
commandId: command.id,
templateDoc: command.positionDetail,
amount: x.amount,
positionSalaryAmount: x.positionSalaryAmount,