๊ฐœ๋ฐœ์ผ์ง€-20 [๐Ÿ“‡์ฃผ๋ฌธ ๋„๋ฉ”์ธ : ์ฃผ๋ฌธ ์ ‘์ˆ˜&์ทจ์†Œ, ํ”ฝ์—… ์™„๋ฃŒ, ์ฃผ๋ฌธํ‘œ ํ™•์ธ]

๊น€์„ฑ์ธยท2023๋…„ 9์›” 14์ผ
0

์ฃผ๋ฌธ ๋„๋ฉ”์ธ ๊ธฐ๋Šฅ ์ •์˜ ํฌ์ŠคํŒ…


๐Ÿ“ฉ์ฃผ๋ฌธ ์ ‘์ˆ˜ ๋Œ€๊ธฐ ํ™”๋ฉด: ์ ‘์ˆ˜ & ์ทจ์†Œํ•˜๊ธฐ ๋ฒ„ํŠผ

๐Ÿ“ฉ์ฃผ๋ฌธ ์ ‘์ˆ˜ํ•˜๊ธฐ ํ›„ ์ฃผ๋ฌธ ๋ฒˆํ˜ธ์™€ ํ•จ๊ป˜ ์ฃผ๋ฌธ ์ ‘์ˆ˜ํ• ๋‹น

๐Ÿ“ฉ์ฃผ๋ฌธ ์ ‘์ˆ˜ ํ›„ ํ”ฝ์—… ์™„๋ฃŒ ๋ฒ„ํŠผ


2. [PATCH] /jat/orders/receive

์ฃผ๋ฌธ ์ ‘์ˆ˜ ๋ฐ ์ทจ์†Œ

  • ๋‹จ์ˆœ ์‚ฌ์šฉ์ž๊ฐ€ ์ฃผ๋ฌธ ์š”์ฒญ์„ ํ•˜๊ณ  ๊ฒฐ์ œ๊ฐ€ ๋ฐœ์ƒํ•˜๋Š” ๊ฒƒ์ด ์•„๋‹ˆ๋ผ, ํŒ๋งค์ž๊ฐ€ ์ฃผ๋ฌธ ์ ‘์ˆ˜๋ฅผ ํ•ด์•ผ ๊ฒฐ์ œ๊ฐ€ ๊ฐ€๋Šฅํ•˜๋„๋ก ๋กœ์ง์„ ๊ตฌํ˜„ํ•˜๊ธฐ๋กœ ํ•˜์˜€๋‹ค.
  • ๊ตฌ๋งค ๊ด€๋ จ ํฌ์ŠคํŒ…..
  • ์š”์ฒญ ๋ฐ”๋””
    ์กฐํšŒ์‹œ์— ๋ฏธ๋ฆฌ ์‘๋‹ต์— ํฌํ•จํ–ˆ๋˜ orderIdx ๋ฅผ ํ”„๋ก ํŠธ์—์„œ ์œ ์ง€ํ•˜์—ฌ, ์ ‘์ˆ˜/ ์ทจ์†Œ๋ฅผ ํ•˜๋Š” ์ฃผ๋ฌธ์— ๋Œ€ํ•œ ์‹๋ณ„์„ ๋ฐ”๋กœ ํ•  ์ˆ˜ ์žˆ๋„๋ก ํ•˜์˜€๊ณ , ์ด๋ฅผ ์š”์ฒญ ๋ฐ”๋””์— ๋‹ด๋„๋ก ํ•˜์˜€๋‹ค.
  • OrderController.java
    ์ฃผ๋ฌธ ์ ‘์ˆ˜ ๋Œ€๊ธฐ ํ™”๋ฉด์— ๋‚˜์™€์žˆ๋Š” ์ฃผ๋ฌธ ์ ‘์ˆ˜/์ทจ์†Œํ•˜๊ธฐ ๋ฒ„ํŠผ ํด๋ฆญ์‹œ ์š”์ฒญ๋˜๋Š” API์ด๋‹ค.
    "P" :์ฃผ๋ฌธ ์ ‘์ˆ˜, "D" : ์ฃผ๋ฌธ ์ทจ์†Œ
  • OrderService.java
  1. ์˜ฌ๋ฐ”๋ฅธ ์š”์ฒญ์„ ๋ณด๋ƒˆ๋Š”์ง€ ๊ฒ€์‚ฌํ•˜๊ธฐ
  • ์ ‘์ˆ˜/์ทจ์†Œ ๋ง๊ณ  ๋‹ค๋ฅธ ์ƒํƒœ์˜ ๊ฐ’์„ ๋ณด๋ƒˆ๋Š”๊ฐ€?
  • ์ด๋ฏธ ์ฒ˜๋ฆฌ๋œ ์ƒํƒœ์˜ ์ฃผ๋ฌธ ์ธ๊ฐ€??
     @Transactional(rollbackFor = BaseException.class)
    public PatchReceRes patchRecBySellerIdx(int sellerIdx, PatchReceReq patchReceReq) throws BaseException{
        // 0)
        int storeIdx;
        try {
            storeIdx = storeDao.storeIdxBySellerIdx(sellerIdx);
        }
        catch (Exception e){
            throw new BaseException(POST_STORES_NOT_REGISTERD); // ์กด์žฌํ•˜์ง€ ์•Š์€ ๊ฐ€๊ฒŒ์ž…๋‹ˆ๋‹ค.
        }

        // 1) ์˜ฌ๋ฐ”๋ฅธ ์ ‘์ˆ˜/์กฐํšŒ ์š”์ฒญ ์ธ์ง€
        if (!patchReceReq.getStatus().equals("P") && !patchReceReq.getStatus().equals("D"))
            throw new BaseException(DATABASE_ERROR); // ์˜ฌ๋ฐ”๋ฅด์ง€ ์•Š์€ ์ฃผ๋ฌธ ์ ‘์ˆ˜/์ทจ์†Œ ์š”์ฒญ์ž…๋‹ˆ๋‹ค.

        // 2) ์กฐํšŒํ•ด์„œ ์ƒํƒœ๊ฐ€ ๋Œ€๊ธฐ ์ƒํƒœ์ธ์ง€ ํ™•์ธ
        String status;
        try{
            status = orderDao.checkOrderStatus(patchReceReq.getOrderIdx());
        }catch (Exception e){
            throw new BaseException(DATABASE_ERROR); // ์ฃผ๋ฌธ ์ •๋ณด๊ฐ€ ์˜ณ๋ฐ”๋ฅด์ง€ ์•Š์Šต๋‹ˆ๋‹ค.
        }
        if(!"W".equals(status)){
            throw new BaseException(DATABASE_ERROR); // ์ด๋ฏธ ์ฒ˜๋ฆฌ ๋˜๊ฑฐ๋‚˜, ์ฒ˜๋ฆฌ ๋˜์ง€ ์•Š์€ ์ฃผ๋ฌธ์ž…๋‹ˆ๋‹ค.
        }
  1. ์ฃผ๋ฌธ ์ ‘์ˆ˜ ์ค€๋น„
  • ์˜ค๋Š˜ ์ ‘์ˆ˜ํ•œ ๊ฐ€๊ฒŒ์˜ ์ฃผ๋ฌธ ์ค‘, ์กฐํšŒ๋ฅผ ํ–ˆ์„ ๋•Œ ์ฃผ๋ฌธ ๋ฒˆํ˜ธ๊ฐ€ ํ• ๋‹น๋œ ํ–‰์ด ์—†๋‹ค๋ฉด ์ฃผ๋ฌธ ๋ฒˆํ˜ธ ์‹œ์ž‘ from 1
  • ์˜ค๋Š˜ ์ ‘์ˆ˜ํ•œ ๊ฐ€๊ฒŒ์˜ ์ฃผ๋ฌธ ์ค‘, ์กฐํšŒ๋ฅผ ํ–ˆ์„ ๋•Œ ์ฃผ๋ฌธ ๋ฒˆํ˜ธ๊ฐ€ ํ• ๋‹น๋œ ํ–‰์ด ์žˆ๋‹ค๋ฉด ๋งˆ์ง€๋ง‰ ์ฃผ๋ถ„ ๋ฒˆํ˜ธ๋กœ๋ถ€ํ„ฐ +1
        // 4) ์ฃผ๋ฌธ๋ฒˆํ˜ธ ํ™•์ธ
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        String date = sdf.format(new Date());
        int orderSequence;
        try{
            orderSequence = orderDao.getOrderSequence(storeIdx, date);
            orderSequence += 1;
        }catch (IncorrectResultSizeDataAccessException error) { // ์ฟผ๋ฆฌ๋ฌธ์— ํ•ด๋‹นํ•˜๋Š” ๊ฒฐ๊ณผ๊ฐ€ ์—†๊ฑฐ๋‚˜ 2๊ฐœ ์ด์ƒ์ผ ๋•Œ
            orderSequence = 1;
        }catch (Exception e){
            throw new BaseException(DATABASE_ERROR);// ๋ฐ์ดํ„ฐ๋ฅผ ์—…๋ฐ์ดํŠธ ํ•˜๋Š”๋ฐ ์˜ค๋ฅ˜๊ฐ€ ์žˆ์Œ
        }
  1. ์ฃผ๋ฌธ ์ ‘์ˆ˜ ๋ฐ ์ทจ์†Œ ์ฟผ๋ฆฌ ๋‚ ๋ฆฌ๊ธฐ
  • ๊ฒฐ์ œ ๊ด€๋ จ ์ •๋ณด๋Š” PortOne API๋ฅผ ์ด์šฉํ•˜๊ธฐ๋กœ ํ–ˆ๋Š”๋ฐ ์‚ฌ์—…์ž ๋“ฑ๋ก์ฆ ์ด์Šˆ ๋•Œ๋ฌธ์— ๊ฒฐ์ œ๊ตฌํ˜„์€ ์‹ค์ œ๋กœ ํ•˜์ง€ ๋ชปํ–ˆ๋‹ค..
  • ์ฃผ๋ฌธ ์ ‘์ˆ˜์™€ ์ทจ์†Œ์— ๋Œ€ํ•œ ์ตœ์ข… ์ฟผ๋ฆฌ๋ฅผ ๋‚ ๋ฆฌ๋Š” ๋กœ์ง
        // 5) ์ฃผ๋ฌธ ์ ‘์ˆ˜ ํ˜น์€ ์ทจ์†Œ
        // ******************** ์—ฌ๊ธฐ์„œ ๊ตฌ๋งค์ •๋ณด ๋ฐœ์ƒ ์‹œ์ผœ์„œ ์ฒ˜๋ฆฌํ•ด์•ผํ•จ ********************
        int updated = 0;
        try{
            if (patchReceReq.getStatus().equals("D"))
                updated = orderDao.orderDenied(storeIdx, patchReceReq.getOrderIdx(), patchReceReq.getStatus());
            else if (patchReceReq.getStatus().equals("P"))
                updated = orderDao.orderAccepted(storeIdx, patchReceReq.getOrderIdx(), patchReceReq.getStatus(), orderSequence);
        }catch (Exception e){
            //System.out.println("1: "+ e);
            throw new BaseException(DATABASE_ERROR);// ๋ฐ์ดํ„ฐ๋ฅผ ์—…๋ฐ์ดํŠธ ํ•˜๋Š”๋ฐ ์˜ค๋ฅ˜๊ฐ€ ์žˆ์Œ
        }

        if(updated == 1){
            return new PatchReceRes(storeIdx, orderSequence);
        }else{
            //System.out.println("2: ");
            throw new BaseException(DATABASE_ERROR);
        }
    }
  • OrderDao.java
// ํ˜„์žฌ orderIdx์˜ status ๊ฐ’์„ ํ™•์ธํ•ด์ค€๋‹ค.
    public String checkOrderStatus(int orderIdx) {
        String query = "SELECT status FROM Orders WHERE orderIdx = ?";
        return this.jdbcTemplate.queryForObject(query, String.class, orderIdx);
    }
// ๊ฐ€๊ฒŒ์˜ ์ฃผ๋ฌธ ์ค‘ ๋‚ ์งœ๊ฐ€ ์˜ค๋Š˜ ๋ฒ”์œ„ ์•ˆ์ด๊ณ , 
// ์ƒํƒœ๊ฐ€ ์ฃผ๋ฌธ ์ ‘์ˆ˜ ์ค‘/ ์™„๋ฃŒ ๋œ ๋ฐ์ดํ„ฐ ์ค‘์— ๋งˆ์ง€๋ง‰ ์ฃผ๋ฌธ์˜ ์ฃผ๋ฌธ ๋ฒˆํ˜ธ๋ฅผ ์กฐํšŒ
    public int getOrderSequence(int storeIdx, String date) {
        String query = "SELECT\n" +
                "    orderIdx,\n" +
                "    order_sequence\n" +
                "FROM Orders\n" +
                "WHERE storeIdx = ?\n" +
                "  AND DATE_FORMAT(order_time, '%Y-%m-%d') = ?\n" +
                "  AND (status = 'P' OR status = 'A')\n" +
                "ORDER BY order_sequence DESC LIMIT 1";

        Object[] params = new Object[]{storeIdx, date};

        return this.jdbcTemplate.queryForObject(query,
                (rs, rowNum) -> rs.getInt("order_sequence"), params);
    }
// ์ฃผ๋ฌธ ๊ฑฐ์ ˆ ์ฟผ๋ฆฌ(์ƒํƒœ๊ฐ’ ๋ณ€๊ฒฝ)
    public int orderDenied(int storeIdx, int orderIdx, String status){
        String updateQuery = "UPDATE Orders SET " +
                "status = ? " +
                "WHERE storeIdx = ? AND orderIdx = ?";
        return jdbcTemplate.update(updateQuery, status, storeIdx, orderIdx);
    }
// ์ฃผ๋ฌธ ์ ‘์ˆ˜ ์ฟผ๋ฆฌ(์ฃผ๋ฌธ ๋ฒˆํ˜ธ ํ• ๋‹น ๋ฐ ์ƒํƒœ๊ฐ’ ๋ณ€๊ฒฝ)
    public int orderAccepted(int storeIdx, int orderIdx, String status, int orderSequence){
        String updateQuery = "UPDATE Orders SET " +
                "status = ?, " +
                "order_sequence = ? " +
                "WHERE storeIdx = ? AND orderIdx = ?";
        return jdbcTemplate.update(updateQuery, status, orderSequence, storeIdx, orderIdx);
    }

ํ…Œ์ŠคํŠธ

ํ…Œ์ŠคํŠธ๋Š” ๋‚˜์ค‘์— ๊ตฌ๋งค์ž์˜ ์ฃผ๋ฌธ ๊ด€๋ จ ๋„๋ฉ”์ธ ํฌ์ŠคํŒ…์„ ์ž‘์„ฑํ•˜๋ฉด ๋งํฌ๋ฅผ ๊ฑธ๊ฒ ๋‹ค.


3. [PATCH] /jat/orders/pickup

์ฃผ๋ฌธ ์ ‘์ˆ˜ ํ›„ ํ”ฝ์—…์™„๋ฃŒ

  • ๋„๋ฉ”์ธ ๋กœ์ง ์ƒ, ์ ‘์ˆ˜ ํ›„ ํ”ฝ์—… ์˜ˆ์ •์‹œ๊ฐ„์— ์†๋‹˜์ด ์™€์„œ ์Œ์‹์„ ๋ฐ›์•„๊ฐ€๋ฉด ์‚ฌ์žฅ๋‹˜์ด ํ”ฝ์—… ์™„๋ฃŒ ๋ฒ„ํŠผ์„ ๋ˆ„๋ฅด๋„๋ก ๊ธฐ๋Šฅ์„ ๊ตฌํ˜„ํ•˜๊ธฐ๋กœ ํ•˜์˜€๋‹ค.
  • ์š”์ฒญ ๋ฐ”๋””
  • OrderContoller.java
  • OrderService.java
  • ์ฃผ๋ฌธ์˜ ์ƒํƒœ๊ฐ’์ด ์ฒ˜๋ฆฌ์ค‘์ธ ์ฃผ๋ฌธ์ด ์•„๋‹ˆ๋ผ๋ฉด ํ”ฝ์—…์™„๋ฃŒ๊ฐ€ ๋ถˆ๊ฐ€๋Šฅํ•จ.
  • ์ฃผ๋ฌธ ์ƒํƒœ ํ™•์ธ ํ›„ ํ”ฝ์—…์™„๋ฃŒ๋กœ ์ฒ˜๋ฆฌ
    @Transactional(rollbackFor = BaseException.class)
    public PatchPickupRes pickupOrder(int sellerIdx, PatchPickupReq patchPickupReq) throws BaseException {
        //1) ์‚ฌ์šฉ์ž ๊ฐ€๊ฒŒ ์กฐํšŒ
        int storeIdx;
        try {
            storeIdx = storeDao.storeIdxBySellerIdx(sellerIdx);
        } catch (Exception e) {
            throw new BaseException(DATABASE_ERROR);
        }

        // 2) ํ•ด๋‹น ์ฃผ๋ฌธ์˜ ์ƒํƒœ๊ฐ’์„ ์กฐํšŒ
        String status;
        try {
            status = orderDao.checkOrderStatus(patchPickupReq.getOrderIdx());
        } catch (Exception e) {
            throw new BaseException(DATABASE_ERROR); // ํ•ด๋‹น ์ฃผ๋ฌธ์—๋Œ€ํ•œ ์ƒํƒœ๊ฐ’์„ ์ฐพ์„ ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค.
        }

        if (!"P".equals(status)) {// string์œผ๋กœ status๋ฅผ๊ฐ€์ ธ์™€์•ผ..... //"P" != "status" ์ด๋ ‡๊ฒŒ ํ•˜๋ฉด ๊ฒฐ๊ณผ๊ฐ€ํ•ญ์ƒ ์ฐธ์ด ๋‚˜์˜จ๋‹ค ์‹คํŒจ
            throw new BaseException(DATABASE_ERROR); // ํ•ด๋‹น ์ฃผ๋ฌธ์ด ๋Œ€๊ธฐ/์ทจ์†Œ/์™„๋ฃŒ๋œ ์ž‘์—…์ž…๋‹ˆ๋‹ค.
        }

        // ์ฃผ๋ฌธ ์ƒํƒœ ํ™•์ธ ํ›„ ์—…๋ฐ์ดํŠธ ์„ธ๋ถ„ํ™” ํ•„์š”
        int resultCount;
        try {
            resultCount = orderDao.orderPickupUpdate(patchPickupReq.getOrderIdx());
        } catch (BaseException e) {
            throw new BaseException(DATABASE_ERROR);
        }

        if (resultCount == 1)
            return new PatchPickupRes(storeIdx);
        else
            throw new BaseException(DATABASE_ERROR);
    }
  • OrderDao.java
    public String checkOrderStatus(int orderIdx) {
        String query = "SELECT status FROM Orders WHERE orderIdx = ?";
        return this.jdbcTemplate.queryForObject(query, String.class, orderIdx);
    }// ํ˜„์žฌ orderIdx์˜ status ๊ฐ’์„ ํ™•์ธํ•ด์ค€๋‹ค.
    public int orderPickupUpdate(int orderIdx) throws BaseException {
        String updatequery = "UPDATE Orders " +
                "    SET status = 'A' \n " +
                "WHERE " +
                "    orderIdx = ? AND" +
                "    status = 'P'";
        return jdbcTemplate.update(updatequery, orderIdx);
    }

ํ…Œ์ŠคํŠธ

ํ…Œ์ŠคํŠธ๋Š” ๋‚˜์ค‘์— ๊ตฌ๋งค์ž์˜ ์ฃผ๋ฌธ ๊ด€๋ จ ๋„๋ฉ”์ธ ํฌ์ŠคํŒ…์„ ์ž‘์„ฑํ•˜๋ฉด ๋งํฌ๋ฅผ ๊ฑธ๊ฒ ๋‹ค.


4. [POST] /jat/orders/bills

์ฃผ๋ฌธ ์ ‘์ˆ˜์‹œ ์ฃผ๋ฌธ ์ •๋ณด๋ฅผ ํ™•์ธํ•˜๋Š” ์ฃผ๋ฌธํ‘œ ์กฐํšŒ

  • ์ฃผ๋ฌธ์˜ ๊ฒ‰ ๋ชจ์Šต์ด์•„๋‹Œ ์ƒ์„ธ ์ •๋ณด๋ฅผ ๊ฐ„๋‹จํ•œ ํ‘œํ˜•ํƒœ๋กœ ํ‘œํ˜„ํ•˜๋Š”๋ฐ ๊ฐ’์„ ์กฐํšŒํ•˜๊ธฐ์œ„ํ•œ API
  • ์š”์ฒญ ๋ฐ”๋”” : orderIdx ํ•˜๋‚˜ ๋“ค์–ด๊ฐ€ ์žˆ๋‹ค.
  • ์‘๋‹ต ๋ฐ”๋””
  • OrderController.java
  • OrderService.java
    ์ฃผ๋ฌธํ‘œ๊ฐ€ ๋ฐœํ–‰๋˜๋Š” ์ฃผ๋ฌธ์ธ์ง€ ์‹๋ณ„ํ•˜๊ณ , ์ฃผ๋ฌธ ์ •๋ณด๋ฅผ ์กฐํšŒํ•œ ํ›„, ์ฃผ๋ฌธ์— ํฌํ•จ๋œ ๋ฉ”๋‰ด๋„ ํฌํ•จํ•˜์—ฌ ์‘๋‹ต๋ฐ”๋””์— ๋„ฃ์–ด์ค„ ๋ฐ์ดํ„ฐ๋ฅผ ์ค€๋น„
    public GetBillRes getBillsByOrderIdx(int sellerIdx, GetBillReq getBillReq) throws BaseException {
        //1. ๊ฐ€๊ฒŒ์˜ ์กด์žฌ ์—ฌ๋ถ€
        int storeIdx;
        try {
            storeIdx = storeDao.storeIdxBySellerIdx(sellerIdx);
        } catch (Exception e) {
            throw new BaseException(BaseResponseStatus.POST_STORES_NOT_REGISTERD); //๊ฐ€๊ฒŒ๊ฐ€ ๋“ฑ๋ก๋˜์–ด ์žˆ์ง€ ์•Š๋‹ค.
        }
        // 2. ์ƒํƒœ๊ฐ€ W,D์ธ ๊ฒฝ์šฐ์—๋Š” ์ฃผ๋ฌธํ‘œ๊ฐ€ ์กด์žฌํ•˜์ง€ ์•Š๋Š”๋‹ค. (์ฃผ๋ฌธ ์ ‘์ˆ˜์ฒ˜๋ฆฌ๊ฐ€ ๋œ ์ฃผ๋ฌธํ‘œ)
        String status;
        try{
            status = orderDao.checkOrderStatus(getBillReq.getOrderIdx());
        }catch (Exception e){
            throw new BaseException(BaseResponseStatus.DATABASE_ERROR); //ํ˜„์žฌ ์ƒํƒœ๊ฐ€ ์กด์žฌํ•˜์ง€ ์•Š๋Š” ๊ฒฝ์šฐ์ด๋‹ค.
        }
        if ((!status.equals("P") || !status.equals("W")) && status.equals("D")){
            throw new BaseException(BaseResponseStatus.DATABASE_ERROR); // ํ˜„์žฌ ์˜ณ๋ฐ”๋ฅด์ง€ ์•Š์€ ์ƒํƒœ์ด๋‹ค.
        }

        // 3. ์ฃผ๋ฌธ ์ •๋ณด ์กฐํšŒํ•˜๊ธฐ
        GetBillRes orderBills;
        try{
            orderBills = orderDao.getOrderBills(storeIdx, getBillReq.getOrderIdx());
        }catch (Exception e){
            throw new BaseException(BaseResponseStatus.DATABASE_ERROR);
        }

        // 4. ์ฃผ๋ฌธ์— ํฌํ•จ๋œ ๋ฉ”๋‰ด ์ •๋ณด ์กฐํšŒํ•˜๊ธฐ
        try{
orderBills.setOrderItem(orderDao.getOrderMenus(getBillReq.getOrderIdx()));

            return orderBills;
        }catch (Exception e){
            throw new BaseException(BaseResponseStatus.DATABASE_ERROR);
        }
    }
  • OrderDao.java
// ์ฃผ๋ฌธ ๊ธฐ๋ณธ์ •๋ณด
    public GetBillRes getOrderBills(int storeIdx, int orderIdx) {
        String query = "SELECT\n" +
                "    O.orderIdx, DATE_FORMAT(O.order_time, '%Y-%m-%d') AS orderDate,\n" +
                "    O.payment_status, DATE_FORMAT(O.pickup_time, '%H:%i') AS pickUpTime,\n" +
                "    O.order_sequence, \n" +
                "    O.request\n" +
                "FROM Orders O\n" +
                "WHERE O.orderIdx = ?\n";

        return this.jdbcTemplate.queryForObject(query,
                (rs, rowNum) -> new GetBillRes(
                        storeIdx,
                        rs.getInt("orderIdx"),
                        rs.getString("orderDate"),
                        rs.getString("payment_status"),
                        rs.getString("pickUpTime"),
                        rs.getInt("order_sequence"),//0, // ์ฃผ๋ฌธ ๋ฒˆํ˜ธ
                        rs.getString("request"),
                        null
                ),orderIdx);
    }
/// ์กฐ์ธ์„ ํ†ตํ•œ ์ฃผ๋ฌธ์— ํฌํ•จ๋œ ๋ฉ”๋‰ด ์กฐํšŒ
   public List<OrderMenuCnt> getOrderMenus(int orderIdx){
        String query = "SELECT M.menu_name, OL.cnt\n" +
                "FROM Orders O\n" +
                "LEFT JOIN  OrderLists OL on OL.orderIdx = O.orderIdx\n" +
                "LEFT JOIN TodayMenu TM on OL.todaymenuIdx = TM.todaymenuIdx\n" +
                "LEFT JOIN Menu M on TM.menuIdx = M.menuIdx\n" +
                "WHERE O.orderIdx = ?\n" +
                "ORDER BY O.orderIdx;";   //join ํ•  ๋•Œ ํฐ ๊ฒƒ์—์„œ ์ž‘์€ ๊ฒƒ์œผ๋กœ joinํ•˜๊ธฐ
        return this.jdbcTemplate.query(query,
                (rs, rowNum) -> new OrderMenuCnt(
                        rs.getString("menu_name"),
                        rs.getInt("cnt")
                ), orderIdx);
    }

ํ…Œ์ŠคํŠธ

ํ…Œ์ŠคํŠธ๋Š” ๋‚˜์ค‘์— ๊ตฌ๋งค์ž์˜ ์ฃผ๋ฌธ ๊ด€๋ จ ๋„๋ฉ”์ธ ํฌ์ŠคํŒ…์„ ์ž‘์„ฑํ•˜๋ฉด ๋งํฌ๋ฅผ ๊ฑธ๊ฒ ๋‹ค.


๋ณด์™„ํ•  ์ 

๋ฐฐ์น˜ ์Šค์ผ€์ค„๋Ÿฌ๋กœ ๋‚˜์ค‘์— ๋งค์ถœ์„ ์ •๋ฆฌํ•˜๊ณ  ๋‹น์ผ ๋ฐœ์ƒํ•œ ์ฃผ๋ฌธ์„ ์ดˆ๊ธฐํ™”ํ•˜๋Š” ์ž๋™ํ™” ๊ธฐ๋Šฅ์„ ์ถ”๊ฐ€ํ•ด์•ผํ•˜๋Š”๋ฐ, ๊ฐ€๊ฒŒ์˜ ๋งค์ถœ์€ ์ง€๋‚œ ์ฃผ๋ฌธ์ด๋ผ๋„ ๋ฒ”์ฃผ์•ˆ์— ๋“ค์–ด์•ผํ•˜๊ธฐ ๋–„๋ฌธ์— ๋ฐฐ์น˜ ์Šค์ผ€์ค„๋Ÿฌ๋ฅผ ์‚ฌ์šฉํ–ˆ์„ ๋•Œ ์‹๋ณ„ํ•  ์ƒํƒœ๊ฐ’์„ ์ถ”๊ฐ€ํ•ด์•ผํ•œ๋‹ค...

0๊ฐœ์˜ ๋Œ“๊ธ€