fix(auth): return facility hospital when login

This commit is contained in:
avicenan
2026-06-08 17:08:32 +09:00
parent 1cc9555546
commit 5d016fbbfb

View File

@ -11,7 +11,7 @@ import dayjs from "dayjs"
import jwt from "jsonwebtoken" import jwt from "jsonwebtoken"
import fs from "fs" import fs from "fs"
import { v4 as uuidv4 } from "uuid" import { v4 as uuidv4 } from "uuid"
import { Application, EmailBody, HrmsEmployee, Menu, User, UserRefreshToken, UserRole } from "entity" import { Application, EmailBody, HospitalInformation, HrmsEmployee, Menu, User, UserRefreshToken, UserRole } from "entity"
import axios from "axios" import axios from "axios"
import CommonHelper from "../helpers/common" import CommonHelper from "../helpers/common"
import { MoreThan } from "typeorm" import { MoreThan } from "typeorm"
@ -121,12 +121,17 @@ export class AuthController {
WHERE utr.user_id = $1 AND r.deleted_at IS NULL AND utr.deleted_at IS NULL` WHERE utr.user_id = $1 AND r.deleted_at IS NULL AND utr.deleted_at IS NULL`
const rooms = await OrmHelper.DB.query(roomQuery, [user.id]) const rooms = await OrmHelper.DB.query(roomQuery, [user.id])
const facilityQuery = ` const facility = await OrmHelper.DB.getRepository(HospitalInformation).findOne({
SELECT f.id, f.facility_id, f.name, f.address, f.phone, f.code select: {
FROM hospital_information f id: true,
LIMIT 1` facility_id: true,
const facilities = await OrmHelper.DB.query(facilityQuery) name: true,
const facility = facilities[0] || null address: true,
phone: true,
code: true,
},
where: {},
})
var privateKey = fs.readFileSync("src/helpers/key/private.key") var privateKey = fs.readFileSync("src/helpers/key/private.key")