สร้างฟังก์ชันกลาง

This commit is contained in:
kittapath 2024-09-27 23:44:47 +07:00
parent 90100e3460
commit 32b50c905c
3 changed files with 77 additions and 10 deletions

View file

@ -31,6 +31,7 @@ import { Profile } from "../entities/Profile";
import { RequestWithUser } from "../middlewares/user";
import permission from "../interfaces/permission";
import { PermissionOrg } from "../entities/PermissionOrg";
import FunctionMain from "../interfaces/functionMain";
@Route("api/v1/org")
@Tags("Organization")
@ -120,7 +121,7 @@ export class OrganizationController extends Controller {
@Post("draft")
async CreateOrgRevision(
@Body() requestBody: CreateOrgRevision,
@Request() request: { user: Record<string, any> },
@Request() request: RequestWithUser,
) {
//new main revision
const revision = Object.assign(new OrgRevision(), requestBody) as OrgRevision;
@ -2261,7 +2262,7 @@ export class OrganizationController extends Controller {
id: string;
type: number;
},
@Request() request: { user: Record<string, any> },
@Request() request: RequestWithUser,
) {
if (requestBody.type == 1) {
const orgChild1 = await this.child1Repository.findOne({
@ -2515,7 +2516,7 @@ export class OrganizationController extends Controller {
* @param {string} id Id revison
*/
@Get("get/publish")
async runPublish(@Request() request: { user: Record<string, any> }) {
async runPublish(@Request() request: RequestWithUser) {
const today = new Date();
today.setHours(0, 0, 0, 0); // Set time to the beginning of the day
const orgRevisionPublish = await this.orgRevisionRepository
@ -2589,7 +2590,7 @@ export class OrganizationController extends Controller {
: item != null && item?.orgRoot != null
? `${item.orgRoot.orgRootShortName}${item.posMasterNo}`
: null;
await new CallAPI().PostData(request, "/org/profile/salary", {
await new FunctionMain().newSalaryFunction(request, {
profileId: item.next_holderId,
date: new Date(),
amount: profileSalary?.amount ?? null,
@ -4733,7 +4734,7 @@ export class OrganizationController extends Controller {
* @param {string} id
*/
@Get("approver/{id}")
async getUserRootOrg(@Path() id: string, @Request() request: { user: Record<string, any> }) {
async getUserRootOrg(@Path() id: string, @Request() request: RequestWithUser) {
if (id == "00000000-0000-0000-0000-000000000000") {
const maps = {
id: "00000000-0000-0000-0000-000000000000",