accountingAdd*: initial (working maybe)
Signed-off-by: supphakitd <67319010028@technictrang.ac.th>
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user