Commit 0ed9ae9d authored by chaiwat's avatar chaiwat

add

parent 3a60b1d8
......@@ -14,7 +14,7 @@ const {
} = require("../services/funcCallback");
const responseCode = require("../configs/responseCode");
const { pushMessage } = require('../services/lineApi');
const { pushMessage } = require("../services/lineApi");
const router = express.Router();
......@@ -65,7 +65,7 @@ router.get("/all", (request, response, next) => {
// Get By Member
router.get("/getbymember", (request, response, next) => {
let data = request.query;
console.log(data)
console.log(data);
try {
callGetByMember(data, function (err, datas, status) {
if (status == responseCode.SUCCESS) {
......@@ -216,7 +216,7 @@ router.get("/getspare-detailid", (request, response, next) => {
router.delete("/delete-spare", async (request, response, next) => {
try {
let data = request.body;
console.log('555',data)
console.log("555", data);
callDeleteSpare(data, function (err, datas, status) {
if (status == responseCode.SUCCESS) {
......@@ -244,7 +244,8 @@ router.put("/update-detail", (request, response, next) => {
try {
callUpdateDetail(data, function (err, datas, status) {
// console.log(status)
pushMessage(datas)
// console.log('datas', datas.status)
if (status == responseCode.SUCCESS) {
response.json({
code: 200,
......@@ -252,6 +253,10 @@ router.put("/update-detail", (request, response, next) => {
total: datas.length,
data: datas,
});
if (datas[0].status === "สำเร็จ") {
pushMessage(datas);
}
} else {
response.json({
code: 400,
......@@ -264,5 +269,4 @@ router.put("/update-detail", (request, response, next) => {
}
});
module.exports = router;
......@@ -638,7 +638,7 @@ function getByMember(data, callback) {
let sql = `SELECT * FROM repairdetails AS a
INNER JOIN member AS b ON a.member_tel = b.member_tel
INNER JOIN garage AS c ON a.garageID = c.garageID
WHERE a.member_tel = ${memberTel} ORDER BY a.repair_date ASC `;
WHERE a.member_tel = ${memberTel} ORDER BY a.repair_date DESC `;
db.query(sql, function (err, rows) {
if (err) return callback(err);
......@@ -658,7 +658,7 @@ function getByGarage(data, callback) {
let sql = `SELECT * FROM repairdetails AS a
INNER JOIN member AS b ON a.member_tel = b.member_tel
INNER JOIN garage AS c ON a.garageID = c.garageID
WHERE a.garageID = "${garageID}" ORDER BY repair_date ASC`;
WHERE a.garageID = "${garageID}" ORDER BY repair_date DESC`;
db.query(sql, function (err, rows) {
if (err) return callback(err);
......
......@@ -2,7 +2,7 @@ const request = require("request");
const responseCode = require("../configs/responseCode");
async function pushMessage(data) {
console.log("data in pushMessage ", data[0]);
// console.log("data in pushMessage ", data[0]);
let headers = {
"Content-Type": "application/json",
Authorization:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment