보안 루피

node.js 를 이용한 웹 앱 구현 - 백엔드 구축 (2), sql.js 본문

웹/node.js

node.js 를 이용한 웹 앱 구현 - 백엔드 구축 (2), sql.js

잔망 루피 2023. 11. 26. 14:43
const { query } = require("express")

module.exports ={
    productList: {                  //Productlist : 상품 리스트 가져오는 쿼리
    query : 'select t1.*, t2.path, t3.category1, t3.category2, t3.category3 from t_product t1, t_image t2, t_category t3 where t1.id = t2.product_id and t2.type =1 and t1.category_id =t3.id'

    },
    productDetail:{

    query : 'select t1.*, t2.path, t3.category1, t3.category2, t3.category3 from t_product t1, t_image t2, t_category t3 where t1.id =? and t1.id = t2.product_id and t2.type=3 and t1.category_id=t3.id'
    }, //상품 상세정보 가져오는 쿼리

    productMainImage: { //상품 사진들 (썸네일 X)

        query : 'select * from t_image where product_id =? and type =2'
    },

    sellerList: {
    query: 'select * from t_seller'

    },

    productInsert: { //로그인한 사용자만 이 쿼리 가능, 쿼리안에서 로그인했는지 체크 코드 추가해야됨
    query: 'INSERT INTO `dev_class`.`t_product` (`id`, `product_name`, `product_price`, `delivery_price`, `add_delivery`, `tags`, `outbound_days`, `created_date`, `seller_id`, `category_id`) VALUES (?, ?, ?, ?, ?, ?, ?, ? ,?)'

    },
    productImageInsert: {
        query: 'insert into t_image (product_id,type,path) values (?,?,?)'
    },
   
    sellerList : {
        query: 'select 8 from t_seller'
       

},
    signUp:{
        query:'insert into t_user set ? on duplicate key update ?'

    }
}

//product_create.html 쿼리

sql.js 파일을 따로 생성후 DB 로 넘겨질 sql문 작성