แก้บัญชี1 2 3

This commit is contained in:
kittapath 2024-09-17 09:51:23 +07:00
parent 471307cf3f
commit 2a73c9d440
2 changed files with 34 additions and 33 deletions

View file

@ -255,7 +255,6 @@ export class CommandTypeController extends Controller {
_commandType.lastUpdateUserId = request.user.sub; _commandType.lastUpdateUserId = request.user.sub;
_commandType.lastUpdateFullName = request.user.name; _commandType.lastUpdateFullName = request.user.name;
_commandType.lastUpdatedAt = new Date(); _commandType.lastUpdatedAt = new Date();
this.commandTypeRepository.merge(_commandType, requestBody);
await this.commandTypeRepository.save(_commandType); await this.commandTypeRepository.save(_commandType);
return new HttpSuccess(_commandType.id); return new HttpSuccess(_commandType.id);
} }
@ -282,7 +281,6 @@ export class CommandTypeController extends Controller {
_commandType.lastUpdateUserId = request.user.sub; _commandType.lastUpdateUserId = request.user.sub;
_commandType.lastUpdateFullName = request.user.name; _commandType.lastUpdateFullName = request.user.name;
_commandType.lastUpdatedAt = new Date(); _commandType.lastUpdatedAt = new Date();
this.commandTypeRepository.merge(_commandType, requestBody);
await this.commandTypeRepository.save(_commandType); await this.commandTypeRepository.save(_commandType);
return new HttpSuccess(_commandType.id); return new HttpSuccess(_commandType.id);
} }

View file

@ -1,4 +1,4 @@
import { Controller, Get, Route, Security, Tags, SuccessResponse, Response } from "tsoa"; import { Controller, Get, Route, Security, Tags, SuccessResponse, Response, Path } from "tsoa";
import { AppDataSource } from "../database/data-source"; import { AppDataSource } from "../database/data-source";
import HttpSuccess from "../interfaces/http-success"; import HttpSuccess from "../interfaces/http-success";
import HttpStatusCode from "../interfaces/http-status"; import HttpStatusCode from "../interfaces/http-status";
@ -33,19 +33,20 @@ export class ReportController extends Controller {
* @summary Report1 * @summary Report1
* *
*/ */
@Get("report1") @Get("report1/{rootId}")
async findReport1() { async findReport1(@Path() rootId: string) {
const orgRevision = await this.orgRevisionRepository.findOne({ // const orgRevision = await this.orgRevisionRepository.findOne({
where: { orgRevisionIsDraft: true, orgRevisionIsCurrent: false }, // where: { orgRevisionIsDraft: true, orgRevisionIsCurrent: false },
relations: ["orgRoots"], // relations: ["orgRoots"],
}); // });
if (!orgRevision) { // if (!orgRevision) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล"); // throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
} // }
const orgRootData = await this.orgRootRepository.find({ const orgRootData = await this.orgRootRepository.find({
where: { where: {
orgRevisionId: orgRevision.id, id: rootId,
// orgRevisionId: orgRevision.id,
}, },
order: { orgRootOrder: "ASC" }, order: { orgRootOrder: "ASC" },
relations: [ relations: [
@ -681,19 +682,20 @@ export class ReportController extends Controller {
* @summary Report2 * @summary Report2
* *
*/ */
@Get("report2") @Get("report2/{rootId}")
async findReport2() { async findReport2(@Path() rootId: string) {
const orgRevision = await this.orgRevisionRepository.findOne({ // const orgRevision = await this.orgRevisionRepository.findOne({
where: { orgRevisionIsDraft: true, orgRevisionIsCurrent: false }, // where: { orgRevisionIsDraft: true, orgRevisionIsCurrent: false },
relations: ["orgRoots"], // relations: ["orgRoots"],
}); // });
if (!orgRevision) { // if (!orgRevision) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล"); // throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
} // }
const orgRootData = await this.orgRootRepository.find({ const orgRootData = await this.orgRootRepository.find({
where: { where: {
orgRevisionId: orgRevision.id, id: rootId,
// orgRevisionId: orgRevision.id,
}, },
order: { orgRootOrder: "ASC" }, order: { orgRootOrder: "ASC" },
relations: [ relations: [
@ -2848,19 +2850,20 @@ export class ReportController extends Controller {
* @summary Report3 * @summary Report3
* *
*/ */
@Get("report3") @Get("report3/{rootId}")
async findReport3() { async findReport3(@Path() rootId: string) {
const orgRevision = await this.orgRevisionRepository.findOne({ // const orgRevision = await this.orgRevisionRepository.findOne({
where: { orgRevisionIsDraft: true, orgRevisionIsCurrent: false }, // where: { orgRevisionIsDraft: true, orgRevisionIsCurrent: false },
relations: ["orgRoots"], // relations: ["orgRoots"],
}); // });
if (!orgRevision) { // if (!orgRevision) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล"); // throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
} // }
const orgRootData = await this.orgRootRepository.find({ const orgRootData = await this.orgRootRepository.find({
where: { where: {
orgRevisionId: orgRevision.id, id: rootId,
// orgRevisionId: orgRevision.id,
}, },
order: { orgRootOrder: "ASC" }, order: { orgRootOrder: "ASC" },
relations: [ relations: [