Skip to content

Commit

Permalink
changed [Add Params] advertisingController.js
Browse files Browse the repository at this point in the history
  • Loading branch information
Ho3einTahan committed Mar 20, 2024
1 parent c3f4e9f commit 4a04379
Showing 1 changed file with 23 additions and 13 deletions.
36 changes: 23 additions & 13 deletions controller/advertisingController.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;

Expand All @@ -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': "آگهی با موفقیت ثبت شد" });
Expand All @@ -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': "آگهی با موفقیت ثبت شد" });
Expand Down

0 comments on commit 4a04379

Please # to comment.