๊ฐœ๋ฐœ์ผ์ง€-28 [๐Ÿ ๊ฐ€๊ฒŒ๋„๋ฉ”์ธ(๊ตฌ๋งค์ž): ๊ฐ€๊ฒŒ's ์ƒ์„ธ ์ •๋ณด]

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

๊ฐ€๊ฒŒ ๋„๋ฉ”์ธ(๊ตฌ๋งค์ž) ๊ธฐ๋Šฅ ์ •์˜ ํฌ์ŠคํŒ…


๊ฐ€๊ฒŒ ์ƒ์„ธ ์ •๋ณด ํ™”๋ฉด

๊ฐ€๊ฒŒ ๋ฏธ๋ฆฌ ๋ณด๊ธฐ๋ฅผ ํด๋ฆญํ•˜์—ฌ, ํ•ด๋‹น ๊ฐ€๊ฒŒ ๋‚ด์˜ ์ƒ์„ธ ์ •๋ณด๋ฅผ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค,.

  • ๊ฐ€๊ฒŒ ๊ธฐ๋ณธ์ •๋ณด : ๊ฐ€๊ฒŒ ์ด๋ฆ„, ํ‰์ , ๊ตฌ๋… ์ˆ˜, ์ฃผ์†Œ, ๊ฑฐ๋ฆฌ ๋ฐ ์‹œ๊ฐ„
  • ์ƒ์„ธ ์ •๋ณด ์ข…๋ฅ˜ 3๊ฐ€์ง€:
    • ์˜ค๋Š˜์˜ ๋–จ์ด ๋ฉ”๋‰ด : ํŒ๋งค์ž๊ฐ€ ๋“ฑ๋กํ•œ ๋–จ์ด ๋ฉ”๋‰ด ๋ชฉ๋ก (๋ฉ”์ธ/์‚ฌ์ด๋“œ)
    • ๊ฐ€๊ฒŒ ์ •๋ณด : ํŒ๋งค์ž ๊ฐ€๊ฒŒ์˜ ์ •๋ณด๋“ค(๊ฐ€๊ฒŒ ๊ธฐ๋ณธ์ •๋ณด + ๊ฐ€๊ฒŒ ํ†ต๊ณ„ + ์‚ฌ์—…์ž ์ •๋ณด..+ ์›์‚ฐ์ง€)
    • ๋ฆฌ๋ทฐ : ๋ฆฌ๋ทฐ ํ‰์  ํ˜„ํ™ฉ ๋ฐ ๋ชฉ๋ก

4. [GET] /jat/app/stores/info

๊ฐ€๊ฒŒ ๊ธฐ๋ณธ ์ •๋ณด

๊ฐ€๊ฒŒ ์ƒ์„ธ ์ •๋ณด์—์„œ ๋งจ ์ƒ๋‹จ์— ํ•ญ์ƒ ๊ณ ์ •๋˜์–ด์žˆ๋Š” ๊ธฐ๋ณธ ์ •๋ณด

  • ์‘๋‹ต ๋ฐ”๋””
    • ๊ฐ€๊ฒŒId, ๊ฐ€๊ฒŒ ์ด๋ฆ„, ์นดํ…Œ๊ณ ๋ฆฌ์ข…๋ฅ˜, ๊ฐ€๊ฒŒ ๋ฒˆํ˜ธ, ์œ„/๊ฒฝ๋„, ๊ฐ€๊ฒŒ ์ฃผ์†Œ, ๊ฑฐ๋ฆฌ, ์‹œ๊ฐ„, ํ‰์ , ๊ตฌ๋…์ˆ˜, ๊ตฌ๋… ์—ฌ๋ถ€
  • ์ปจํŠธ๋กค๋Ÿฌ
  • ์„œ๋น„์Šค
    public GetAppStoreInfoRes getAppStoreInfo(int userIdx, int storeIdx, Double longitude, Double latitude) throws BaseException {
        // 1. ๊ฐ€๊ฒŒ ๊ธฐ๋ณธ ์‹๋ณ„์ •๋ณด ์กฐํšŒ
        GetAppStoreInfo storeInfo;
        try {
            storeInfo = appStoreDao.getAppStoreInfo(storeIdx);
        } catch (Exception e) {
            throw new BaseException(RESPONSE_ERROR);    // ๋ฆฌ๋ทฐ ์กฐํšŒ์— ์‹คํŒจํ•˜์˜€์Šต๋‹ˆ๋‹ค.
        }

        // 2. ๊ฐ€๊ฒŒ ๋ณ„์  ๊ฐ€์ ธ์˜ค๊ธฐ
        double starAvg;
        try {
            starAvg = appStoreDao.getStoreStar(storeIdx);
        }catch (IncorrectResultSizeDataAccessException error) { // ์ฟผ๋ฆฌ๋ฌธ์— ํ•ด๋‹นํ•˜๋Š” ๊ฒฐ๊ณผ๊ฐ€ ์—†๊ฑฐ๋‚˜ 2๊ฐœ ์ด์ƒ์ผ ๋•Œ
            starAvg = 0;
        } catch (Exception e) {
            throw new BaseException(RESPONSE_ERROR);    // ๋ฆฌ๋ทฐ ์กฐํšŒ์— ์‹คํŒจํ•˜์˜€์Šต๋‹ˆ๋‹ค.
        }

        // 3. ๊ฐ€๊ฒŒ ๊ตฌ๋… ์ˆ˜(์ฐœ ์ˆ˜)
        int subscribeCount;
        try {
            subscribeCount = appStoreDao.subscribeCount(storeIdx);
        } catch (Exception e) {
            throw new BaseException(RESPONSE_ERROR);    // ๋ฆฌ๋ทฐ ์กฐํšŒ์— ์‹คํŒจํ•˜์˜€์Šต๋‹ˆ๋‹ค.
        }

        // 4. ๊ฐ€๊ฒŒ ์›์‚ฐ์ง€
        String ingredientInfo;
        try {
            ingredientInfo = appStoreDao.getStoreAppDetailIngredientInfo(storeIdx);
        } catch (Exception e) {
            throw new BaseException(RESPONSE_ERROR);    // ๋ฆฌ๋ทฐ ์กฐํšŒ์— ์‹คํŒจํ•˜์˜€์Šต๋‹ˆ๋‹ค.
        }

        int distance = (int) locationValue.getDistance(latitude, longitude, storeInfo.getY(),  storeInfo.getX());
        int duration = locationValue.getDuration(distance);

        int subCheck;
        try{
            subCheck = subscribeDao.checkSubscribeValid(userIdx, storeIdx);
        }catch (Exception e) {
            throw new BaseException(RESPONSE_ERROR);    // ๋ฆฌ๋ทฐ ์กฐํšŒ์— ์‹คํŒจํ•˜์˜€์Šต๋‹ˆ๋‹ค.
        }

        return new GetAppStoreInfoRes(storeIdx,
                storeInfo.getStoreName(),
                storeInfo.getStoreCategory(),
                storeInfo.getStorePhone(),
                storeInfo.getX(), storeInfo.getY(),
                storeInfo.getStoreAddress(),
                distance, duration,
                starAvg,
                subscribeCount,
                ingredientInfo,
                subCheck);
    }
  1. ๊ฐ€๊ฒŒ ๊ฐ€์žฅ ๊ธฐ๋ณธ๋˜๋Š” ์ •๋ณด๋ฅผ ๊ฐ€์ ธ์˜ค๊ธฐ(๊ฐ€๊ฒŒ ์ด๋ฆ„, ๋ฒˆํ˜ธ, ์œ„/๊ฒฝ๋„, ์ฃผ์†Œ, ์นดํ…Œ๊ณ ๋ฆฌ)
  2. ๊ฐ€๊ฒŒ ๋ณ„์  ์กฐํšŒ
  3. ๊ฐ€๊ฒŒ ๊ตฌ๋… ์ˆ˜ ์กฐํšŒ
  4. ๊ฐ€๊ฒŒ ์›์‚ฐ์ง€ ์กฐํšŒ(์›์‚ฐ์ง€ ํƒญ์ด ๋”ฐ๋กœ ์žˆ๋Š”๋ฐ ์ดˆ๊ธฐ์— ํ–ˆ๋˜๊ฑฐ ๊ทธ๋Œ€๋กœ ๋‚จ์•„์žˆ์Œ..)
  5. ๊ฑฐ๋ฆฌ/ ์‹œ๊ฐ„ ๊ตฌํ•˜๊ธฐ
  6. ๊ฐ€๊ฒŒ ๊ตฌ๋… ์—ฌ๋ถ€ ์กฐํšŒ
  7. ์‘๋‹ต ๋ฐ˜ํ™˜
  • Dao
// ๊ฐ€๊ฒŒ ๊ธฐ๋ณธ ์ •๋ณด ์กฐํšŒ
    public GetAppStoreInfo getAppStoreInfo(int storeIdx){
        String query = "SELECT \n" +
                "    store_name, store_phone, x, y, store_address, categoryIdx \n" +
                "FROM Stores  S\n" +
                "WHERE storeIdx = ?";
        return this.jdbcTemplate.queryForObject(query,
                (rs, rowNum) -> new GetAppStoreInfo(
                    rs.getString("store_name"),
                    rs.getString("store_phone"),
                    rs.getInt("categoryIdx"),
                    rs.getDouble("x"),
                    rs.getDouble("y"),
                    rs.getString("store_address")
        ),storeIdx);
    }
// ๊ฐ€๊ฒŒ ๊ตฌ๋… ์ •๋ณด ์กฐํšŒ
    public double getStoreStar(int storeIdx) {
        String query = "SELECT\n" +
                "    ROUND(AVG(star), 1) AS star_average \n" +
                "FROM Review\n" +
                "WHERE storeIdx = ? AND status != 'D'";
        return this.jdbcTemplate.queryForObject(query,
                (rs, rowNum) -> rs.getDouble("star_average")
                , storeIdx);
    }
// ๊ฐ€๊ฒŒ ๊ตฌ๋…์ž ์ˆ˜
    public int subscribeCount(int storeIdx) {
        String subscribeCountQuery = "SELECT " +
                "COUNT(storeIdx) AS Subscribe_Count " +
                "FROM Subscribe WHERE storeIdx = ? AND status = 'A';";

        return this.jdbcTemplate.queryForObject(subscribeCountQuery, int.class, storeIdx);
    }
// ๊ฐ€๊ฒŒ ๊ตฌ๋… ์—ฌ๋ถ€
  public int checkSubscribeValid(int customerIdx, int storeIdx) {
        String query = "SELECT EXISTS (SELECT * FROM Subscribe WHERE customerIdx=? AND storeIdx=? AND status = 'A');";

        Object[] params = new Object[]{customerIdx, storeIdx};
        return this.jdbcTemplate.queryForObject(query, int.class, params);
    }

ํ…Œ์ŠคํŠธ


5. [GET] /jat/app/stores/info/details

๊ฐ€๊ฒŒ ๋ฉ”๋‰ด / ์ •๋ณด / ๋ฆฌ๋ทฐ

  • ์ปจํŠธ๋กค๋Ÿฌ

5-1) ๊ฐ€๊ฒŒ ๋ฉ”๋‰ด ์กฐํšŒ

  • ์‘๋‹ต ๋ฐ”๋””
    • ๊ฐ ๋ฉ”๋‰ด์—๋Š” ์ด๋ฏธ์ง€ URL, ์˜ค๋Š˜์˜ ๋ฉ”๋‰ด Idx, ๋ฉ”๋‰ด์ด๋ฆ„, ๊ตฌ์„ฑ, ๋‚จ์€๊ฐœ์ˆ˜, ์›๊ฐ€, ์„ธ์ผ, ํ• ์ธ๊ฐ€๋ฅผ ํฌํ•จํ•œ๋‹ค.
  • ์„œ๋น„์Šค
    public GetAppStoreDetailMenuRes getAppStoreDetailMenu(int storeIdx) throws BaseException { //getAppStoreDetailMenu

        List<GetAppStoreDetailMenuItem> mainMenuList, sideMenuList;

        //๋ฉ”์ธ๋ฉ”๋‰ด์กฐํšŒ
        try {
            mainMenuList = appStoreDao.getAppStoreDetailMenuList(storeIdx, "M");
        } catch (Exception e) {
            throw new BaseException(GET_MENU_ERROR);
        }
        // ๋ฉ”์ธ ๋ฉ”๋‰ด url ๊ฐ€์ ธ์˜ค๊ธฐ
        try {
            for (GetAppStoreDetailMenuItem item : mainMenuList) {
                if (item.getMenuUrl() != null && !item.getMenuUrl().equals("")) {
                    item.setMenuUrl("" + s3Client.getUrl(bucketName, item.getMenuUrl()));
                }
            }
        } catch (Exception e) {
            throw new BaseException(GET_MENU_ERROR);
        }

        try {
            sideMenuList = appStoreDao.getAppStoreDetailMenuList(storeIdx, "S");
        } catch (Exception e) {
            throw new BaseException(GET_MENU_ERROR);
        }
        // ์‚ฌ์ด๋“œ ๋ฉ”๋‰ด url ๊ฐ€์ ธ์˜ค๊ธฐ
        try {
            for (GetAppStoreDetailMenuItem item : sideMenuList) {
                if (item.getMenuUrl() != null && !item.getMenuUrl().equals("")) {
                    item.setMenuUrl("" + s3Client.getUrl(bucketName, item.getMenuUrl()));
                }
            }
        } catch (Exception e) {
            throw new BaseException(GET_MENU_ERROR);
        }

        return new GetAppStoreDetailMenuRes(storeIdx, mainMenuList, sideMenuList);

    }
  1. DB์—์„œ ๋ฉ”์ธ/์‚ฌ์ด๋“œ๋ฅผ ๊ธฐ์ค€์œผ๋กœ ๋ฉ”๋‰ด ๊ธฐ๋ณธ ์ •๋ณด๋ฅผ ์กฐํšŒํ•จ.
  2. ๋ฉ”๋‰ด์ด๋ฏธ์ง€์˜ URL์„ S3๋ฅผ ์ด์šฉํ•ด์„œ ๊ฐ€์ ธ์˜ด
  3. ๋ฐ˜ํ™˜
  • Dao
  public List<GetAppStoreDetailMenuItem> getAppStoreDetailMenuList(int storeIdx, String status){ //getAppStoreDetailMenuList

        String query ="SELECT m.storeIdx, m.menuIdx, tm.todaymenuIdx, m.menu_name, tm.remain, m.menu_url,\n" +
                "   m.composition, m.price, tm.discount, tm.price AS today_price \n" +
                "   FROM TodayMenu tm \n" +
                "   JOIN Menu m ON m.menuIdx = tm.menuIdx \n" +
                "   WHERE tm.storeIdx = ? AND tm.status = ?";

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

        return this.jdbcTemplate.query(query,
                (rs, rowNum) -> new GetAppStoreDetailMenuItem(
                    rs.getInt("menuIdx"),
                    rs.getInt("todaymenuIdx"),
                    rs.getString("menu_name"),
                    rs.getString("menu_url"),
                    rs.getString("composition"),
                    rs.getInt("remain"),
                    rs.getInt("price"),
                    rs.getInt("discount"),
                    rs.getInt("today_price")
            ),params);
    }

5-1) ํ…Œ์ŠคํŠธ


5-2) ๊ฐ€๊ฒŒ ์ •๋ณด ์กฐํšŒ

  • ์‘๋‹ต ๋ฐ”๋””
  • ์„œ๋น„์Šค
    public GetAppStoreDetailInfoRes getAppStoreDetailInfo(int storeIdx) throws BaseException {
        // 1. ๊ฐ€๊ฒŒ ์ •๋ณด
        // ์ƒํ˜ธ๋ช…, ์šด์˜์‹œ๊ฐ„, ํœด๋ฌด์ผ, ์ „ํ™”๋ฒˆํ˜ธ
        GetAppStoreDetailStoreInfo detailStoreInfo;
        try {
            detailStoreInfo = appStoreDao.getAppStoreDetailStoreInfo(storeIdx);
        } catch (Exception e) {
            throw new BaseException(GET_MENU_ERROR);
        }

        // 2. ๊ฐ€๊ฒŒ ํ†ต๊ณ„
        GetAppStoreDetailStatisticsInfo detailStatisticsInfo;
        try {
            int orderCount = appStoreDao.orderCount(storeIdx);
            int reviewCount = appStoreDao.reviewCount(storeIdx);
            int subscribeCount = appStoreDao.subscribeCount(storeIdx);
            detailStatisticsInfo =  new GetAppStoreDetailStatisticsInfo(orderCount,reviewCount, subscribeCount);

        } catch (Exception e) {
            throw new BaseException(GET_MENU_ERROR);
        }

        // 3. ์‚ฌ์—…์ž ์ •๋ณด
        GetAppStoreDetailSellerInfo detailSellerInfo;
        try {
            detailSellerInfo = appStoreDao.getStoreAppDetailSellerInfo(storeIdx);
        } catch (Exception e) {
            throw new BaseException(GET_MENU_ERROR);
        }

        // 4. ์›์‚ฐ์ง€ ์ •๋ณด
        String ingredientInfo;
        try {
            ingredientInfo = appStoreDao.getStoreAppDetailIngredientInfo(storeIdx);
        } catch (Exception e) {
            throw new BaseException(GET_MENU_ERROR);
        }

        return new GetAppStoreDetailInfoRes(storeIdx, detailStoreInfo,detailStatisticsInfo,detailSellerInfo,ingredientInfo);
    }

๊ฐ€๊ฒŒ ์ •๋ณด์—์„œ ๋ณด์ด๋Š” ๊ฐ ๋ธ”๋Ÿญ๋“ค(๊ฐ€๊ฒŒ์ •๋ณด, ํ†ต๊ณ„, ์‚ฌ์—…์ž์ •๋ณด, ์›์‚ฐ์ง€) ๋ณ„๋กœ ๋ฐ์ดํ„ฐ๋ฅผ ์กฐํšŒํ•˜์—ฌ ์‘๋‹ตํ•จ.
1. ๊ฐ€๊ฒŒ์˜ ๊ฐ€์žฅ ๊ธฐ๋ณธ์ •๋ณด(์ƒํ˜ธ๋ช…, ์šด์˜์‹œ๊ฐ„, ํœด๋ฌด์ผ, ์ „ํ™”๋ฒˆํ˜ธ)
2. ๊ฐ€๊ฒŒ ํ†ต๊ณ„๋ฅผ ๊ฐ DB ํ…Œ์ด๋ธ”์—์„œ ์ง‘๊ณ„ํ•จ์ˆ˜๋ฅผ ํ†ตํ•ด ์กฐํšŒ
3. ์‚ฌ์—…์ž ์ •๋ณด(ํŒ๋งค์ž ์ •๋ณด)
4. ์›์‚ฐ์ง€ ์ •๋ณด DB์ฟผ๋ฆฌ ํ™”

  • Dao
// ๊ฐ€๊ฒŒ ๊ธฐ๋ณธ ์ƒ์„ธ ์ •๋ณด
    public GetAppStoreDetailStoreInfo getAppStoreDetailStoreInfo(int storeIdx){
        String query = "SELECT store_name, \n" +
                "       TIME_FORMAT(store_open, '%H:%i') AS store_open, \n" + //(์ˆ˜์ •) ์šด์˜์‹œ๊ฐ„ ์ดˆ ์ž๋ฅด๊ธฐ
                "       TIME_FORMAT(store_close, '%H:%i') AS store_close, \n" +
                "       breakday, \n" +
                "       store_phone \n" +
                "FROM Stores \n" +
                "WHERE storeIdx = ?;";

        return this.jdbcTemplate.queryForObject(query,
                (rs, rowNum) -> new GetAppStoreDetailStoreInfo(
                        rs.getString("store_name"),
                        rs.getString("store_open"),
                        rs.getString("store_close"),
                        rs.getString("breakday"),
                        rs.getString("store_phone")
                ), storeIdx);
    }
// ์ฃผ๋ฌธ, ๋ฆฌ๋ทฐ, ๊ตฌ๋… ์ˆ˜ ์ง‘๊ณ„ํ•จ์ˆ˜.
    public int orderCount(int storeIdx){
        String orderCountQuery = "SELECT " +
                "COUNT(storeIdx) AS Order_Count " +
                "FROM Orders " +
                "WHERE storeIdx = ? AND status = 'A';";
        return  this.jdbcTemplate.queryForObject(orderCountQuery, int.class, storeIdx);
    }

    public int reviewCount(int storeIdx){
        String reviewCountQuery ="SELECT " +
                "COUNT(storeIdx) AS Review_Count " +
                "FROM Review " +
                "WHERE storeIdx = ? AND status <> 'D';";
        return  this.jdbcTemplate.queryForObject(reviewCountQuery, int.class, storeIdx);
    }

    public int subscribeCount(int storeIdx) {
        String subscribeCountQuery = "SELECT " +
                "COUNT(storeIdx) AS Subscribe_Count " +
                "FROM Subscribe WHERE storeIdx = ? AND status = 'A';";
        return this.jdbcTemplate.queryForObject(subscribeCountQuery, int.class, storeIdx);
    }
// ํŒ๋งค์ž ์ •๋ณด(์‚ฌ์—…์ž ๋“ฑ๋ก๋ฒˆํ˜ธ๋Š” ์•„์ง๋ฏธ์ •)
    public GetAppStoreDetailSellerInfo getStoreAppDetailSellerInfo(int storeIdx){ //getStoreAppDetailSellerInfo
        String query = "SELECT m.name AS seller_name, s.store_name, s.store_address " +
                "FROM Merchandisers m " +
                "JOIN Stores s ON m.sellerIdx = s.sellerIdx " +
                "WHERE s.storeIdx = ?";

        return this.jdbcTemplate.queryForObject(query,
                (rs, rowNum) -> new GetAppStoreDetailSellerInfo(
                        rs.getString("seller_name"),
                        rs.getString("store_name"),
                        rs.getString("store_address"),
                        "123-456-789"
                ),storeIdx);
    }
// ์›์‚ฐ์ง€ ์ •๋ณด group_concatํ•จ์ˆ˜ ์‚ฌ์šฉ
    public String getStoreAppDetailIngredientInfo(int storeIdx){ //์ž๋ฐ” ๋ฌธ๋ฒ•์œผ๋กœ ํ•˜๋‚˜๋กœ ๋ฌธ์ž์—ด  ํ•ฉ์น˜๊ธฐ //getStoreAppDetailIngredientInfo
        String query = "SELECT\n" +
                "    group_concat(ingredient_name, '(', origin, ') ') AS ingredient_info\n" +
                "FROM Ingredients\n" +
                "WHERE storeIdx = ?";

        return this.jdbcTemplate.queryForObject(query,
                (rs, rowNum) -> rs.getString("ingredient_info"),
                storeIdx);
    }

5-2) ํ…Œ์ŠคํŠธ


5-3) ๊ฐ€๊ฒŒ ๋ฆฌ๋ทฐ ์กฐํšŒ

  • ์‘๋‹ต ๋ฐ”๋””
  • ์„œ๋น„์Šค
   public GetAppStoreDetailReviewRes getAppStoreDetailReview(int storeIdx) throws BaseException { //getAppStoreDetailReview
        // 1. ๋ฆฌ๋ทฐ ํ‰๊ท  ํ‰์  ๊ตฌํ•˜๊ธฐ
        GetAppReviewStarRes reviewStar;
        try {
            reviewStar = appStoreDao.reviewStarTotal(storeIdx);
        } catch (Exception e) {
            throw new BaseException(DATABASE_ERROR);
        }

        List<StarCountRatio> starCountRatios = new ArrayList<>();
        starCountRatios.add(new StarCountRatio("๋ณ„ 5๊ฐœ", reviewStar.getStar5(), (int) (reviewStar.getStar5() * 1.0 / reviewStar.getReviews_total() * 100)));
        starCountRatios.add(new StarCountRatio("๋ณ„ 4๊ฐœ", reviewStar.getStar4(), (int) (reviewStar.getStar4() * 1.0  / reviewStar.getReviews_total() * 100)));
        starCountRatios.add(new StarCountRatio("๋ณ„ 3๊ฐœ", reviewStar.getStar3(), (int) (reviewStar.getStar3() * 1.0  / reviewStar.getReviews_total() * 100)));
        starCountRatios.add(new StarCountRatio("๋ณ„ 2๊ฐœ", reviewStar.getStar2(), (int) (reviewStar.getStar2() * 1.0  / reviewStar.getReviews_total() * 100)));
        starCountRatios.add(new StarCountRatio("๋ณ„ 1๊ฐœ", reviewStar.getStar1(), (int) (reviewStar.getStar1() * 1.0  / reviewStar.getReviews_total() * 100)));

        // 2. ๋ฆฌ๋ทฐ ๋ชฉ๋ก ์กฐํšŒ ๋ฐ url ๊ฐ€์ ธ์˜ค๊ธฐ
        List<AppReviewItems> reviewItems;
        try {
            reviewItems = appStoreDao.reviewItems(storeIdx);
            for (AppReviewItems item : reviewItems) {
                if (item.getReview_url() != null)
                    item.setReview_url("" + s3Client.getUrl(bucketName, item.getReview_url()));
                item.setOrderTodayMenu(appStoreDao.appOrderTodayMenus(item.getOrderIdx()));
            }
        } catch (Exception e) {
            throw new BaseException(RESPONSE_ERROR);    // ๋ฆฌ๋ทฐ ์กฐํšŒ์— ์‹คํŒจํ•˜์˜€์Šต๋‹ˆ๋‹ค.
        }

        try{
            LocalDateTime now = LocalDateTime.now(); //ํ˜„์žฌ ์‹œ๊ฐ„
            for(AppReviewItems reviews : reviewItems){
                DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); //DAO์—์„œ ๋ฐ›์•„์˜ค๋Š” getDate์™€ ํ˜•์‹์„ ๋งž์ถ”์–ด ์ค€๋‹ค.
                LocalDateTime reviewDate = LocalDateTime.parse(reviews.getDate(),formatter);

                Duration duration = Duration.between(reviewDate, now); // ํ˜„์žฌ ์‹œ๊ฐ„๊ณผ DB์—์„œ ๊ฐ€์ ธ์˜จ getDate ์‚ฌ์ด์˜ ์‹œ๊ฐ„

                long years = duration.toDays() / 365;
                long months = duration.toDays() / 30;
                long days = duration.toDays();
                long hours = duration.toHours();
                long minutes = duration.toMinutes();

                if (years > 0) {
                    reviews.setDate(years + "๋…„ ์ „");
                } else if (months > 0) {
                    reviews.setDate(months + "๊ฐœ์›” ์ „");;
                } else if (days > 0) {
                    reviews.setDate(days + "์ผ ์ „");
                } else if (hours > 0) {
                    reviews.setDate(hours + "์‹œ๊ฐ„ ์ „");
                } else if (minutes > 0) {
                    reviews.setDate(minutes + "๋ถ„ ์ „");
                } else {
                    reviews.setDate("๋ฐฉ๊ธˆ ์ „");
                }
            }
        }catch (Exception e){
            throw new BaseException(DATABASE_ERROR); //๋‚ ์งœ๋ฅผ ์ž˜๋ชป ์ถœ๋ ฅํ–ˆ์Šต๋‹ˆ๋‹ค.
        }

        return new GetAppStoreDetailReviewRes(storeIdx,
                reviewStar.getStar_average(),
                reviewStar.getReviews_total(),
                reviewStar.getComment_total(),
                starCountRatios,
                reviewItems);
    }
  1. ์‹œ๊ฐ„์„ Duration ํด๋ž˜์Šค๋ฅผ ํ†ตํ•ด์„œ ๋ฆฌ๋ทฐ๋ฅผ ์“ด์ง€ ์–ผ๋งˆ๋‚˜ ๋˜์—ˆ๋Š”์ง€ ํ™•์ธํ•˜๋ฉด์„œ ์ž‘์„ฑํ•˜์˜€๋‹ค.
  • Dao
// ๋ฆฌ๋ทฐ ํ‰์  ๋ฐ ํ‰๊ท  ์กฐํšŒ
    public GetAppReviewStarRes reviewStarTotal(int storeIdx){
        String query ="SELECT\n" +
                "      ROUND(AVG(star),1) AS star_average,\n" +
                "      COUNT(CASE WHEN status <> 'D' THEN reviewIdx END) AS reviews_total,\n" + //(์ˆ˜์ •)D๊ฐ€ ์•„๋‹Œ ์ƒํƒœ๋งŒ ์นด์šดํŠธ ํ•˜๊ธฐ
                "      COUNT(comment) AS comment_total,\n" +
                "      COUNT(CASE WHEN star = 1 THEN 1 END) AS star1_count,\n" +
                "      COUNT(CASE WHEN star = 2 THEN 1 END) AS star2_count,\n" +
                "      COUNT(CASE WHEN star = 3 THEN 1 END) AS star3_count,\n" +
                "      COUNT(CASE WHEN star = 4 THEN 1 END) AS star4_count,\n" +
                "      COUNT(CASE WHEN star = 5 THEN 1 END) AS star5_count\n" +
                "      FROM Review\n" +
                "WHERE storeIdx = ? AND status != 'D'"; //D๊ฐ€ ์•„๋‹Œ๊ฑฐ ๋„ฃ๊ธฐ

        return this.jdbcTemplate.queryForObject(query,
                (rs, rowNum) -> new GetAppReviewStarRes(
                        storeIdx,
                        rs.getDouble("star_average"),
                        rs.getInt("reviews_total"),
                        rs.getInt("comment_total"),
                        rs.getInt("star1_count"),
                        rs.getInt("star2_count"),
                        rs.getInt("star3_count"),
                        rs.getInt("star4_count"),
                        rs.getInt("star5_count")
                )
                ,storeIdx);
    }
// ๋ฆฌ๋ทฐ ๋ชฉ๋ก ์กฐํšŒ
   public List<AppReviewItems> reviewItems(int storeIdx) { //์ฝ”๋“œ ์•ˆ๋ฐ”๊ฟจ์œผ๋ฉด importํ•ด์„œ ๊ฐ€์ ธ์˜ค๊ธฐ ---> AppReviewItems ์—ฌ๊ธฐ ์•ˆ์—์žˆ๋Š” ๊ฐ’์ด ๋ฐ”๊ฟจ๊ธฐ ๋•Œ๋ฌธ์— ๋ชป ๊ฐ€์ ธ์˜ด
        String query = "SELECT\n" +
                "    O.orderIdx,\n" +
                "    R.reviewIdx,\n" +
                "    C.name,\n" +
                "    R.star ,\n" +
                "    R.created,\n" +
                "    R.contents, R.comment, R.review_url\n" +
                "FROM Orders O\n" +
                "JOIN Review R on O.orderIdx = R.orderIdx\n" +
                "JOIN Customers C ON R.customerIdx = C.customerIdx\n" +
                "WHERE\n" +
                "    R.storeIdx = ?\n" +
                "  AND O.status = 'A'\n" +
                "  AND R.status <> 'D'\n" +
                "ORDER BY created DESC;";

        return this.jdbcTemplate.query(query,
                (rs, rowNum) -> new AppReviewItems(
                        rs.getInt("orderIdx"),
                        rs.getInt("reviewIdx"),
                        null,
                        rs.getString("name"),
                        rs.getInt("star"),
                        rs.getString("created"),
                        rs.getString("contents"),
                        rs.getString("comment") == null ? "" : rs.getString("comment"),
                        rs.getString("review_url"),
                        null
                ), storeIdx);
    }
๋ฆฌ๋ทฐ๋ฅผ ์“ด ์ฃผ๋ฌธ์˜ ๋ฉ”๋‰ด ๋ชฉ๋ก ์กฐํšŒ
    public List<String> appOrderTodayMenus(int orderIdx) { 
        String query = "SELECT\n" +
                "    M.menu_name\n" +
                "FROM Orders O\n" +
                "LEFT JOIN OrderLists OL on O.orderIdx = OL.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" +
                "AND O.status = 'A'";

        return this.jdbcTemplate.queryForList(query, String.class, orderIdx);
    }

5-3) ํ…Œ์ŠคํŠธ


6. [GET] /jat/app/stores/map

queryParam : storeIdx

  • ํ•ด๋‹น ๊ฐ€๊ฒŒ์˜ ์ขŒํ‘œ(์œ„/๊ฒฝ๋„), ๊ฐ€๊ฒŒ์ด๋ฆ„์„ ๋ฐ˜ํ™˜ํ•ด์ค€๋‹ค.
    ๊ฐ„๋‹จ ๋กœ์ง์ด๋ผ ํŒจ์Šค

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