ผูก log เมนูทะเบียนประวัติ
This commit is contained in:
parent
5643cc67c4
commit
6539804937
76 changed files with 909 additions and 431 deletions
|
|
@ -21,6 +21,7 @@ import { RequestWithUser } from "../middlewares/user";
|
|||
import { Profile } from "../entities/Profile";
|
||||
import { CreateProfileOther, ProfileOther, UpdateProfileOther } from "../entities/ProfileOther";
|
||||
import permission from "../interfaces/permission";
|
||||
import { setLogDataDiff } from "../interfaces/utils";
|
||||
@Route("api/v1/org/profile/other")
|
||||
@Tags("ProfileOther")
|
||||
@Security("bearerAuth")
|
||||
|
|
@ -56,7 +57,6 @@ export class ProfileOtherController extends Controller {
|
|||
public async otherAdminHistory(@Path() otherId: string, @Request() req: RequestWithUser) {
|
||||
|
||||
const _record = await this.otherRepository.findOneBy({ id: otherId });
|
||||
console.log(">>>>", _record);
|
||||
if (_record) {
|
||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId);
|
||||
}
|
||||
|
|
@ -87,7 +87,7 @@ export class ProfileOtherController extends Controller {
|
|||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
}
|
||||
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_OFFICER", profile.id);
|
||||
|
||||
const before = null;
|
||||
const data = new ProfileOther();
|
||||
|
||||
const meta = {
|
||||
|
|
@ -103,9 +103,10 @@ export class ProfileOtherController extends Controller {
|
|||
const history = new ProfileOtherHistory();
|
||||
Object.assign(history, { ...data, id: undefined });
|
||||
|
||||
await this.otherRepository.save(data);
|
||||
await this.otherRepository.save(data, { data: req });
|
||||
setLogDataDiff(req, { before, after: data });
|
||||
history.profileOtherId = data.id;
|
||||
await this.otherHistoryRepository.save(history);
|
||||
await this.otherHistoryRepository.save(history, { data: req });
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
|
@ -119,7 +120,7 @@ export class ProfileOtherController extends Controller {
|
|||
const record = await this.otherRepository.findOneBy({ id: otherId });
|
||||
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_OFFICER", record.profileId);
|
||||
|
||||
const before = structuredClone(record);
|
||||
const history = new ProfileOtherHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
|
|
@ -137,8 +138,9 @@ export class ProfileOtherController extends Controller {
|
|||
history.lastUpdatedAt = new Date();
|
||||
|
||||
await Promise.all([
|
||||
this.otherRepository.save(record),
|
||||
this.otherHistoryRepository.save(history),
|
||||
this.otherRepository.save(record, { data: req }),
|
||||
setLogDataDiff(req, { before, after: record }),
|
||||
this.otherHistoryRepository.save(history, { data: req }),
|
||||
]);
|
||||
|
||||
return new HttpSuccess();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue