-แก้ไขระบบ Login Add
All checks were successful
Build Docker Image / Build Docker Image (push) Successful in 3m19s
All checks were successful
Build Docker Image / Build Docker Image (push) Successful in 3m19s
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user