comment workflow

This commit is contained in:
kittapath 2024-10-18 11:33:04 +07:00
parent 3fc5a73947
commit 6a23f31046
36 changed files with 32 additions and 177 deletions

View file

@ -17,11 +17,10 @@ import HttpError from "../interfaces/http-error";
import HttpStatus from "../interfaces/http-status";
import HttpSuccess from "../interfaces/http-success";
import HttpStatusCode from "../interfaces/http-status";
import { AuthRole, CreateAuthRole, UpdateAuthRole, CreateAddAuthRole } from "../entities/AuthRole";
import { AuthRole, CreateAuthRole, CreateAddAuthRole } from "../entities/AuthRole";
import { AuthRoleAttr } from "../entities/AuthRoleAttr";
import { PosMaster } from "../entities/PosMaster";
import { EmployeePosMaster } from "../entities/EmployeePosMaster";
import { promisify } from "util";
import { setLogDataDiff } from "../interfaces/utils";
const REDIS_HOST = process.env.REDIS_HOST;
@ -105,7 +104,7 @@ export class AuthRoleController extends Controller {
posMaster.lastUpdateFullName = req.user.name;
posMaster.lastUpdatedAt = new Date();
posMaster.authRoleId = body.authRoleId;
await this.posMasterRepository.save(posMaster, {data: req});
await this.posMasterRepository.save(posMaster, { data: req });
setLogDataDiff(req, { before, after: posMaster });
// เช็คว่าถ้ามีค่า current_holderId ให้ลบ key สิทธิ์ใน redis
@ -149,7 +148,7 @@ export class AuthRoleController extends Controller {
posMaster.lastUpdateFullName = req.user.name;
posMaster.lastUpdatedAt = new Date();
posMaster.authRoleId = body.authRoleId;
await this.employeePosMasterRepository.save(posMaster, {data: req});
await this.employeePosMasterRepository.save(posMaster, { data: req });
setLogDataDiff(req, { before, after: posMaster });
return new HttpSuccess();
}
@ -229,7 +228,7 @@ export class AuthRoleController extends Controller {
// ...newAttrs.map((attr) => this.authRoleAttrRepo.save(attr)),
// ]);
await this.authRoleAttrRepo.remove(roleAttrData, {data: req});
await this.authRoleAttrRepo.remove(roleAttrData, { data: req });
const newAttrs = body.authRoleAttrs.map((attr) => {
const newAttr = new AuthRoleAttr();
@ -246,7 +245,7 @@ export class AuthRoleController extends Controller {
});
const before = structuredClone(record);
await Promise.all([
this.authRoleRepo.save(record, {data: req}),
this.authRoleRepo.save(record, { data: req }),
setLogDataDiff(req, { before, after: record }),
...newAttrs.map((attr) => this.authRoleAttrRepo.save(attr)),
]);
@ -271,7 +270,7 @@ export class AuthRoleController extends Controller {
if (!result) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
}
await this.authRoleRepo.remove(result, {data: req});
await this.authRoleRepo.remove(result, { data: req });
} catch {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่สามารถลบข้อมูลได้");
}