accountingAdd*: initial (working maybe)

Signed-off-by: supphakitd <67319010028@technictrang.ac.th>
This commit is contained in:
2025-11-18 10:12:52 +07:00
parent f68c856340
commit b662469176
3 changed files with 71 additions and 4 deletions

View File

@@ -0,0 +1,41 @@
import { AccountingAddService } from '../services/accountingAddService.js'
import { sendError } from '../utils/response.js'
// import { OftenError } from '../utils/oftenError.js'
import { GeneralService } from '../share/generalservice.js';
import { trim_all_array } from '../utils/trim.js'
import { verifyToken, generateToken } from '../utils/token.js'
export class accountingAdd {
constructor() {
this.generalService = new GeneralService();
this.accountingAddService = new AccountingAddService();
}
async onNavigate(req, res) {
this.generalService.devhint(1, 'accountingAdd.js', 'onNavigate() start');
let organization = req.body.organization;
const prommis = await this.onAccountingAdd(req, res, organization);
return prommis;
}
async onAccountingAdd(req, res, database) {
let idx = -1
let aryResult = []
try {
let token = req.body.request.token;
const decoded = verifyToken(token);
let num = req.body.request.actnum;
database = decoded.organization
aryResult = await this.accountingAddService.getAccountingAdd(database, num);
} catch (error) {
idx = 1;
} finally {
if (idx === 1) return sendError('เกิดข้อผิดพลาดไม่คาดคิดเกิดขึ้น', 'Unexpected error');
if (!aryResult) return sendError('ไม่พบการมีอยู่ของข้อมูล', 'Cannot Find Any Data');
return aryResult
}
}
}

View File

@@ -1,7 +1,8 @@
import express from 'express' import express from 'express'
import { accountingSetup } from '../controllers/accountingSetup.js' import { accountingSetup } from '../controllers/accountingSetupController.js'
import { accountingSearch } from '../controllers/accountingSearch.js' import { accountingSearch } from '../controllers/accountingSearchController.js'
import { accountingSum } from '../controllers/accountingSum.js' import { accountingSum } from '../controllers/accountingSumController.js'
import { accountingAdd } from '../controllers/accountingAddController.js'
// import { authMiddleware } from '../middlewares/auth.js' // import { authMiddleware } from '../middlewares/auth.js'
// import { sendResponse } from '../utils/response.js' // import { sendResponse } from '../utils/response.js'
@@ -10,7 +11,7 @@ const router = express.Router()
const controller_accountingSetup_post = new accountingSetup() const controller_accountingSetup_post = new accountingSetup()
const controller_accountingSearch_post = new accountingSearch() const controller_accountingSearch_post = new accountingSearch()
const controller_accountingSum_post = new accountingSum() const controller_accountingSum_post = new accountingSum()
const controller_accountingAdd_post = new accountingAdd()
router.post('/accountingSetup', async (req, res) => { router.post('/accountingSetup', async (req, res) => {
const result = await controller_accountingSetup_post.onNavigate(req, res) const result = await controller_accountingSetup_post.onNavigate(req, res)
@@ -28,6 +29,10 @@ router.post('/accountingSum', async (req, res) => {
if (result) return res.json(result) if (result) return res.json(result)
}) })
router.post('/accountingAdd', async (req, res) => {
const result = await controller_accountingAdd_post.onNavigate(req, res)
if (result) return res.json(result)
})
// // =================================================== // // ===================================================
// // 🔹 BIOMETRIC LOGIN // // 🔹 BIOMETRIC LOGIN

View File

@@ -0,0 +1,21 @@
import { GeneralService } from '../share/generalservice.js'
export class AccountingAddService {
constructor() {
this.generalService = new GeneralService()
}
async getAccountingAdd(database, name) {
const sql = `
SELECT
actseq,
actnam
FROM ${database}.actmst
WHERE actnam = $1
`
const params = [name]
const result = await this.generalService.executeQueryParam(database, sql, params);
return result
}
}