ผูก log เมนูทะเบียนประวัติ
This commit is contained in:
parent
5643cc67c4
commit
6539804937
76 changed files with 909 additions and 431 deletions
|
|
@ -20,6 +20,7 @@ import { RequestWithUser } from "../middlewares/user";
|
|||
import { Profile } from "../entities/Profile";
|
||||
import { CreateProfileNopaid, ProfileNopaid, UpdateProfileNopaid } from "../entities/ProfileNopaid";
|
||||
import permission from "../interfaces/permission";
|
||||
import { setLogDataDiff } from "../interfaces/utils";
|
||||
@Route("api/v1/org/profile/nopaid")
|
||||
@Tags("ProfileNopaid")
|
||||
@Security("bearerAuth")
|
||||
|
|
@ -75,7 +76,7 @@ export class ProfileNopaidController 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 ProfileNopaid();
|
||||
|
||||
const meta = {
|
||||
|
|
@ -91,9 +92,10 @@ export class ProfileNopaidController extends Controller {
|
|||
const history = new ProfileNopaidHistory();
|
||||
Object.assign(history, { ...data, id: undefined });
|
||||
|
||||
await this.nopaidRepository.save(data);
|
||||
await this.nopaidRepository.save(data, { data: req });
|
||||
setLogDataDiff( req, { before, after: data } )
|
||||
history.profileNopaidId = data.id;
|
||||
await this.nopaidHistoryRepository.save(history);
|
||||
await this.nopaidHistoryRepository.save(history, { data: req });
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
|
@ -107,7 +109,7 @@ export class ProfileNopaidController extends Controller {
|
|||
const record = await this.nopaidRepository.findOneBy({ id: nopaidId });
|
||||
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 ProfileNopaidHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
|
|
@ -125,8 +127,9 @@ export class ProfileNopaidController extends Controller {
|
|||
history.lastUpdatedAt = new Date();
|
||||
|
||||
await Promise.all([
|
||||
this.nopaidRepository.save(record),
|
||||
this.nopaidHistoryRepository.save(history),
|
||||
this.nopaidRepository.save(record, { data: req }),
|
||||
setLogDataDiff( req, { before, after: record } ),
|
||||
this.nopaidHistoryRepository.save(history, { data: req }),
|
||||
]);
|
||||
|
||||
return new HttpSuccess();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue