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

View File

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

View File

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