Commit 0ed9ae9d authored by chaiwat's avatar chaiwat

add

parent 3a60b1d8
...@@ -14,7 +14,7 @@ const { ...@@ -14,7 +14,7 @@ const {
} = require("../services/funcCallback"); } = require("../services/funcCallback");
const responseCode = require("../configs/responseCode"); const responseCode = require("../configs/responseCode");
const { pushMessage } = require('../services/lineApi'); const { pushMessage } = require("../services/lineApi");
const router = express.Router(); const router = express.Router();
...@@ -65,7 +65,7 @@ router.get("/all", (request, response, next) => { ...@@ -65,7 +65,7 @@ router.get("/all", (request, response, next) => {
// Get By Member // Get By Member
router.get("/getbymember", (request, response, next) => { router.get("/getbymember", (request, response, next) => {
let data = request.query; let data = request.query;
console.log(data) console.log(data);
try { try {
callGetByMember(data, function (err, datas, status) { callGetByMember(data, function (err, datas, status) {
if (status == responseCode.SUCCESS) { if (status == responseCode.SUCCESS) {
...@@ -216,7 +216,7 @@ router.get("/getspare-detailid", (request, response, next) => { ...@@ -216,7 +216,7 @@ router.get("/getspare-detailid", (request, response, next) => {
router.delete("/delete-spare", async (request, response, next) => { router.delete("/delete-spare", async (request, response, next) => {
try { try {
let data = request.body; let data = request.body;
console.log('555',data) console.log("555", data);
callDeleteSpare(data, function (err, datas, status) { callDeleteSpare(data, function (err, datas, status) {
if (status == responseCode.SUCCESS) { if (status == responseCode.SUCCESS) {
...@@ -244,7 +244,8 @@ router.put("/update-detail", (request, response, next) => { ...@@ -244,7 +244,8 @@ router.put("/update-detail", (request, response, next) => {
try { try {
callUpdateDetail(data, function (err, datas, status) { callUpdateDetail(data, function (err, datas, status) {
// console.log(status) // console.log(status)
pushMessage(datas) // console.log('datas', datas.status)
if (status == responseCode.SUCCESS) { if (status == responseCode.SUCCESS) {
response.json({ response.json({
code: 200, code: 200,
...@@ -252,6 +253,10 @@ router.put("/update-detail", (request, response, next) => { ...@@ -252,6 +253,10 @@ router.put("/update-detail", (request, response, next) => {
total: datas.length, total: datas.length,
data: datas, data: datas,
}); });
if (datas[0].status === "สำเร็จ") {
pushMessage(datas);
}
} else { } else {
response.json({ response.json({
code: 400, code: 400,
...@@ -264,5 +269,4 @@ router.put("/update-detail", (request, response, next) => { ...@@ -264,5 +269,4 @@ router.put("/update-detail", (request, response, next) => {
} }
}); });
module.exports = router; module.exports = router;
...@@ -638,7 +638,7 @@ function getByMember(data, callback) { ...@@ -638,7 +638,7 @@ function getByMember(data, callback) {
let sql = `SELECT * FROM repairdetails AS a let sql = `SELECT * FROM repairdetails AS a
INNER JOIN member AS b ON a.member_tel = b.member_tel INNER JOIN member AS b ON a.member_tel = b.member_tel
INNER JOIN garage AS c ON a.garageID = c.garageID 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) { db.query(sql, function (err, rows) {
if (err) return callback(err); if (err) return callback(err);
...@@ -658,7 +658,7 @@ function getByGarage(data, callback) { ...@@ -658,7 +658,7 @@ function getByGarage(data, callback) {
let sql = `SELECT * FROM repairdetails AS a let sql = `SELECT * FROM repairdetails AS a
INNER JOIN member AS b ON a.member_tel = b.member_tel INNER JOIN member AS b ON a.member_tel = b.member_tel
INNER JOIN garage AS c ON a.garageID = c.garageID 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) { db.query(sql, function (err, rows) {
if (err) return callback(err); if (err) return callback(err);
......
...@@ -2,7 +2,7 @@ const request = require("request"); ...@@ -2,7 +2,7 @@ const request = require("request");
const responseCode = require("../configs/responseCode"); const responseCode = require("../configs/responseCode");
async function pushMessage(data) { async function pushMessage(data) {
console.log("data in pushMessage ", data[0]); // console.log("data in pushMessage ", data[0]);
let headers = { let headers = {
"Content-Type": "application/json", "Content-Type": "application/json",
Authorization: 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