-แก้ไขระบบ Login Add
All checks were successful
Build Docker Image / Build Docker Image (push) Successful in 3m19s

This commit is contained in:
x2Skyz
2025-11-21 15:00:37 +07:00
parent 2237163847
commit 02b1a6f31b
3 changed files with 27 additions and 13 deletions

View File

@@ -27,13 +27,13 @@ export class accountingAdd {
let latSeq = [] let latSeq = []
try { try {
let token = req.headers.authorization?.split(' ')[1]; let token = req.headers.authorization?.split(' ')[1];
const decoded = verifyToken(token); var decoded = verifyToken(token);
let actnum = req.body.request.actnum; let actnum = req.body.request.actnum;
database = decoded.organization; database = decoded.organization;
aryResult = await this.accountingAddService.getAccountingAdd(database, actnum); aryResult = await this.accountingAddService.getAccountingAdd(database, actnum);
latSeq = await this.accountingAddService.getLatestAccountingSeq(database); latSeq = await this.accountingAddService.genNum(database);
} catch (error) { } catch (error) {
idx = 1; idx = 1;
} finally { } finally {
@@ -41,7 +41,7 @@ export class accountingAdd {
// if (!aryResult) return sendError('ไม่พบการมีอยู่ของข้อมูล', 'Cannot Find Any Data'); // if (!aryResult) return sendError('ไม่พบการมีอยู่ของข้อมูล', 'Cannot Find Any Data');
if (aryResult == 0) { if (aryResult == 0) {
let prommis = await this.makeArySave(req, latSeq[0].actseq); let prommis = await this.makeArySave(req, latSeq, decoded.id);
return prommis return prommis
} else { } else {
return sendError('คีย์หลักซ้ำในระบบ', 'Duplicate Primary Key'); return sendError('คีย์หลักซ้ำในระบบ', 'Duplicate Primary Key');
@@ -50,11 +50,11 @@ export class accountingAdd {
} }
async makeArySave(req, seq) { async makeArySave(req, seq, actnum) {
let arysave = { let arysave = {
methods: 'post', methods: 'post',
actseq: seq + 1, actseq: seq,
actnum: req.body.request.actnum, actnum: actnum,
actacpdtm: req.body.request.actacpdtm, actacpdtm: req.body.request.actacpdtm,
actcat: req.body.request.actcat, actcat: req.body.request.actcat,
actqty: req.body.request.actqty, actqty: req.body.request.actqty,

View File

@@ -20,16 +20,30 @@ export class AccountingAddService {
return result return result
} }
async getLatestAccountingSeq(database) { // async getLatestAccountingSeq(database) {
// const sql = `
// SELECT
// actseq
// FROM ${database}.actmst
// WHERE actseq=(SELECT max(actseq) FROM ${database}.actmst)
// `
// const params = []
// const result = await this.generalService.executeQueryParam(database, sql, params);
// return result
// }
async genNum(database) {
const sql = ` const sql = `
SELECT SELECT
actseq MAX(actseq) as max_seq
FROM ${database}.actmst FROM ${database}.actmst
WHERE actseq=(SELECT max(actseq) FROM ${database}.actmst)
` `
const params = [] const params = []
const result = await this.generalService.executeQueryParam(database, sql, params); const aryResult = await this.generalService.executeQueryParam(database, sql, params);
return result
const lastSeq = aryResult[0]?.max_seq || 0;
return lastSeq + 1;
} }
} }

View File

@@ -6,7 +6,7 @@ export class LoginService {
constructor() { constructor() {
this.generalService = new GeneralService() this.generalService = new GeneralService()
} }
async verifyLogin(database, username) { async verifyLogin(database, username, password) {
this.generalService.devhint(2, 'loginservice.js', `verifyLogin() start for username=${username}`) this.generalService.devhint(2, 'loginservice.js', `verifyLogin() start for username=${username}`)
let user = null let user = null