From 4a0437939d1517c5b475db2df45b8ed6fe779c05 Mon Sep 17 00:00:00 2001 From: MaxBased Date: Wed, 20 Mar 2024 19:00:47 +0330 Subject: [PATCH] changed [Add Params] advertisingController.js --- controller/advertisingController.js | 36 ++++++++++++++++++----------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/controller/advertisingController.js b/controller/advertisingController.js index e7d25ab..f5e2879 100644 --- a/controller/advertisingController.js +++ b/controller/advertisingController.js @@ -10,7 +10,9 @@ exports.AddHomeCategory = async (req, res) => { const homeSQL = `INSERT INTO cat_home (isRahn,isEjare,metraj_Bena,metraj_Zamin,isForooshi,hasParking,hasGarage,hasBalcony,hasWc,hasTaminAbGarm,Garmayesh,Sarmayesh,sanad_Type,isRebuild,home_Direction,count_Room) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)`; - const [home, fields] = await connection.query(homeSQL, [rahn, ejare, metrajBena, metrajZamin, forooshi, parking, gerage, balcony, wc, taminAbGarm, garmayesh, sarmayesh, sanad, rebuild, direction, room]); + const values = [rahn, ejare, metrajBena, metrajZamin, forooshi, parking, gerage, balcony, wc, taminAbGarm, garmayesh, sarmayesh, sanad, rebuild, direction, room]; + + const [home, fields] = await connection.query(homeSQL,values); const homeId = home.insertId; @@ -29,9 +31,11 @@ exports.AddMobileCategory = async (req, res) => { const userId = await getUserId(phoneNumber); - const mobileSQL = `INSERT INTO cat_mobile (brand,status,count_SM,isAsl) VALUES (${brand},${status},${countSM},${Asl})`; + const mobileSQL = `INSERT INTO cat_mobile (brand, status, count_SM, isAsl) VALUES (?, ?, ?, ?)`; + + const values = [brand, status, countSM, Asl]; - const [mobile, fields] = await connection.query(mobileSQL); + const [mobile, fields] = await connection.query(mobileSQL, values); const mobileId = mobile.insertId; @@ -46,16 +50,19 @@ exports.AddMobileCategory = async (req, res) => { exports.AddCarCategory = async (req, res) => { - const { title, content, price, phoneNumber,saveDate,} = req.body; + const { title, content, price, phoneNumber, saveDate, salTolid, karkard, bimeSales, bimeBadane, tarikhBime, brand, shasiStatus, motorStatus, tarikhBimeSales, girboxType, exchange } = req.body; const userId = await getUserId(phoneNumber); - const carSQL = `INSERT INTO cat_car (sal_Tolid,karkard,isBime_Sales,isBime_Badane,payan_Bime,brand,shasi_Status,motor_Status,mohlat_BimeSales,girbox_Type,exchange) VALUES ()`; - const [car,fields]= await connection.query(carSQL); - + const carSQL = `INSERT INTO cat_car (sal_Tolid, karkard, isBime_Sales, isBime_Badane, payan_Bime, brand, shasi_Status, motor_Status, mohlat_BimeSales, girbox_Type, exchange) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`; + + const values = [salTolid, karkard, bimeSales, bimeBadane, tarikhBime, brand, shasiStatus, motorStatus, tarikhBimeSales, girboxType, exchange]; + + const [car, fields] = await connection.query(carSQL, values); + const carId = car.insertId; - + await connection.query(getSqlQueryAds(), [title, content, 0, saveDate, price, userId, carId, null, null, null]); return res.status(200).send({ 'message': "آگهی با موفقیت ثبت شد" }); @@ -64,17 +71,20 @@ exports.AddCarCategory = async (req, res) => { exports.AddEstekhdamCategory = async (req, res) => { - const { title, content, price, phoneNumber, } = req.body; + const { title, content, price, phoneNumber, homeWork, hamkariType, pardakhtType, bime, startTime, endTime, thursday, otherTime, experience, sarbazi, disablePerson } = req.body; const userId = await getUserId(phoneNumber); - const estekhdamSQL = `INSERT INTO cat_estekhdam (work_Home,hamkari_Type,shive_Pardakht,hasBime,start_Time,end_Time,thursday_Noon,other_Time,experience,sarbazi_Status,isDisable_person) VALUES ()`; + const estekhdamSQL = `INSERT INTO cat_estekhdam (work_Home, hamkari_Type, shive_Pardakht, hasBime, start_Time, end_Time, thursday_Noon, other_Time, experience, sarbazi_Status, isDisable_person) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`; + + const values = [homeWork, hamkariType, pardakhtType, bime, startTime, endTime, thursday, otherTime, experience, sarbazi, disablePerson]; + + const [estekhdam, fields] = await connection.query(estekhdamSQL, values); + - const [estekhdam,fields]= await connection.query(estekhdamSQL); - const estekhdamId = estekhdam.insertId; - + await connection.query(getSqlQueryAds(), [title, content, 0, saveDate, price, userId, null, null, null, estekhdamId]); return res.status(200).send({ 'message': "آگهی با موفقیت ثبت شد" });