Skip to content

Commit

Permalink
Merge branch 'EnjoyTripKorea:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
DebbieIsFree authored May 21, 2024
2 parents f5e846d + e6945d7 commit f899385
Show file tree
Hide file tree
Showing 28 changed files with 303 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import com.example.EnjoyTripBackend.dto.airplane.AirplaneRequestDto;
import com.example.EnjoyTripBackend.dto.airplane.AirplaneResponseDto;
import com.example.EnjoyTripBackend.service.AirplaneService;
import com.example.EnjoyTripBackend.util.LimitedSizePagination;
import com.example.EnjoyTripBackend.util.argumentresolver.LimitedSizePagination;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Pageable;
import org.springframework.data.web.PageableDefault;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.example.EnjoyTripBackend.controller;

import com.example.EnjoyTripBackend.dto.ResponseResult;
import com.example.EnjoyTripBackend.dto.camping.CampingResponseDto;
import com.example.EnjoyTripBackend.service.CampingService;
import com.example.EnjoyTripBackend.util.argumentresolver.LimitedSizePagination;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Pageable;
import org.springframework.data.web.PageableDefault;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api")
@RequiredArgsConstructor
public class CampingController {

private final CampingService campingService;

@GetMapping("/camping")
@LimitedSizePagination(maxSize = 20)
public ResponseEntity<ResponseResult<List<CampingResponseDto>>> findAll(@PageableDefault(size = 6) Pageable pageable) {
return ResponseEntity.ok().body(campingService.findAll(pageable));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import com.example.EnjoyTripBackend.dto.golf.GolfRequestDto;
import com.example.EnjoyTripBackend.dto.golf.GolfResponseDto;
import com.example.EnjoyTripBackend.service.GolfService;
import com.example.EnjoyTripBackend.util.LimitedSizePagination;
import com.example.EnjoyTripBackend.util.argumentresolver.LimitedSizePagination;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Pageable;
import org.springframework.data.web.PageableDefault;
Expand All @@ -32,9 +32,9 @@ public ResponseEntity<NonPagingResponseResult<GolfResponseDto>> golfDetail(@Path
return ResponseEntity.ok().body(golfService.findById(id));
}

@GetMapping("/golf/search")
@PostMapping("/golf/search")
@LimitedSizePagination(maxSize = 20)
public ResponseEntity<ResponseResult<List<GolfResponseDto>>> golfSearchList(@PageableDefault(size = 20) Pageable pageable, @RequestBody GolfRequestDto golfRequestDto){
public ResponseEntity<ResponseResult<List<GolfResponseDto>>> golfSearchList(@PageableDefault(size = 6) Pageable pageable, @RequestBody GolfRequestDto golfRequestDto){
return ResponseEntity.ok().body(golfService.golfSearchList(pageable, golfRequestDto));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.example.EnjoyTripBackend.dto.member.LoginRequestDto;
import com.example.EnjoyTripBackend.dto.member.SignUpRequestDto;
import com.example.EnjoyTripBackend.service.MemberService;
import com.example.EnjoyTripBackend.util.SessionConst;
import com.example.EnjoyTripBackend.util.argumentresolver.SessionConst;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpSession;
import jakarta.validation.Valid;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.example.EnjoyTripBackend.controller;

import com.example.EnjoyTripBackend.service.PaymentService;
import com.example.EnjoyTripBackend.util.SessionUser;
import com.example.EnjoyTripBackend.util.argumentresolver.SessionUser;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import com.example.EnjoyTripBackend.dto.place.PlaceSearchwordRequestDto;
import com.example.EnjoyTripBackend.service.PlaceService;
import com.example.EnjoyTripBackend.service.S3Service;
import com.example.EnjoyTripBackend.util.SessionUser;
import com.example.EnjoyTripBackend.util.argumentresolver.SessionUser;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Pageable;
import org.springframework.data.web.PageableDefault;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.example.EnjoyTripBackend.domain;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class Camping extends BaseTimeDomain{

private Long id;
private String name;
private String shortIntro;
private String Intro;
private String zipcode;
private String address;
private double latitude;
private double longitude;
private String imageUrl;
private String homepage;
private String tel;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.example.EnjoyTripBackend.dto.camping;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.*;

@Getter
@Builder
@NoArgsConstructor
@AllArgsConstructor
@JsonIgnoreProperties(ignoreUnknown = true)
public class CampItemDto {
private String facltNm;
private String intro;
private String tel;
private String zipcode;
private double mapY;
private double mapX;
private String lineIntro;
private String firstImageUrl;
private String addr1;
private String homepage;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.example.EnjoyTripBackend.dto.camping;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.*;
import java.util.List;

@Getter
@NoArgsConstructor
@AllArgsConstructor
@JsonIgnoreProperties(ignoreUnknown = true)
public class CampingResponse {
private Response response;

@Getter
@NoArgsConstructor
@AllArgsConstructor
@JsonIgnoreProperties(ignoreUnknown = true)
public static class Response {
private BodyDto body;

@Getter
@NoArgsConstructor
@AllArgsConstructor
@JsonIgnoreProperties(ignoreUnknown = true)
public static class BodyDto {
private ItemsDto items;
}

@Getter
@NoArgsConstructor
@AllArgsConstructor
@JsonIgnoreProperties(ignoreUnknown = true)
public static class ItemsDto {
private List<CampItemDto> item;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.example.EnjoyTripBackend.dto.camping;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@NoArgsConstructor
@AllArgsConstructor
public class CampingResponseDto {

private String name;
private String Intro;
private String zipcode;
private String address;
private double latitude;
private double longitude;
private String imageUrl;
private String homepage;

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
@AllArgsConstructor
public class GolfResponseDto {

private Long golf_id;
private String golfclub_name;
private Long golfId;
private String golfclubName;
private String location;
private String date;
private String golf_imageUrl;
private String green_fee_week;
private String green_fee_weekend;
private String golfImageUrl;
private String greenFeeWeek;
private String greenFeeWeekend;
private double latitude;
private double longitude;
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ public enum ErrorCode {
FAIL_COMMUNICATE_TOSSPAYMENT_API(HttpStatus.INTERNAL_SERVER_ERROR,"토스페이먼트 API와의 통신에 실패하였습니다."),
FAIL_COMMUNICATE_EXTERNAL_API(HttpStatus.INTERNAL_SERVER_ERROR,"외부 API와의 통신에 실패하였습니다."),
Limited_Size_Pagination(HttpStatus.INTERNAL_SERVER_ERROR,"최대 페이징 사이지를 초과하였습니다."),
FAIL_INSERT_AIRPLANE_DATA(HttpStatus.INTERNAL_SERVER_ERROR, "데이터베이스에 항공권 데이터 저장에 실패하였습니다");
FAIL_INSERT_AIRPLANE_DATA(HttpStatus.INTERNAL_SERVER_ERROR, "데이터베이스에 항공권 데이터 저장에 실패하였습니다"),
FAIL_INSERT_CAMPING_DATA(HttpStatus.INTERNAL_SERVER_ERROR, "데이터베이스에 캠핑 데이터 저장에 실패하였습니다");

private final HttpStatus httpstatus;
private final String message;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.example.EnjoyTripBackend.exception.EnjoyTripException;
import com.example.EnjoyTripBackend.exception.ErrorCode;
import com.example.EnjoyTripBackend.util.SessionConst;
import com.example.EnjoyTripBackend.util.argumentresolver.SessionConst;
import com.fasterxml.jackson.databind.ObjectMapper;
import jakarta.servlet.*;
import jakarta.servlet.http.HttpServletRequest;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.example.EnjoyTripBackend.filter;

import com.example.EnjoyTripBackend.util.LimitedPageableArgumentResolver;
import com.example.EnjoyTripBackend.util.SessionUserArgumentResolver;
import com.example.EnjoyTripBackend.util.argumentresolver.LimitedPageableArgumentResolver;
import com.example.EnjoyTripBackend.util.argumentresolver.SessionUserArgumentResolver;
import com.fasterxml.jackson.databind.ObjectMapper;
import jakarta.servlet.Filter;
import lombok.extern.slf4j.Slf4j;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.example.EnjoyTripBackend.repository;

import com.example.EnjoyTripBackend.domain.Camping;
import com.example.EnjoyTripBackend.dto.PageRequestList;
import com.example.EnjoyTripBackend.dto.camping.CampingResponseDto;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

@Mapper
public interface CampingRepository {
Long save(Camping camping);
Long findTotalCount();
List<CampingResponseDto> findAll(PageRequestList<?> requestList);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.example.EnjoyTripBackend.service;

import com.example.EnjoyTripBackend.domain.Camping;
import com.example.EnjoyTripBackend.dto.PageRequestList;
import com.example.EnjoyTripBackend.dto.ResponseResult;
import com.example.EnjoyTripBackend.dto.camping.CampingResponseDto;
import com.example.EnjoyTripBackend.repository.CampingRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@RequiredArgsConstructor
@Transactional(readOnly = true)
public class CampingService {

private final CampingRepository campingRepository;

@Transactional
public Long save(Camping camping) {
return campingRepository.save(camping);
}

public ResponseResult<List<CampingResponseDto>> findAll(Pageable pageable) {
PageRequestList<?> requestList = PageRequestList.builder()
.pageable(pageable)
.build();

long totalCount = campingRepository.findTotalCount();
int totalPages = (int) Math.ceil((double) totalCount / pageable.getPageSize());
return ResponseResult.of("캠핑 정보 게시글 목록입니다.", campingRepository.findAll(requestList),totalPages);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.example.EnjoyTripBackend.util;

import com.example.EnjoyTripBackend.util.collector.AirplaneInfoCollector;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.example.EnjoyTripBackend.util;
package com.example.EnjoyTripBackend.util.argumentresolver;

import com.example.EnjoyTripBackend.exception.EnjoyTripException;
import com.example.EnjoyTripBackend.exception.ErrorCode;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.example.EnjoyTripBackend.util;
package com.example.EnjoyTripBackend.util.argumentresolver;

import java.lang.annotation.*;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.example.EnjoyTripBackend.util;
package com.example.EnjoyTripBackend.util.argumentresolver;

public class SessionConst {
public static final String LOGIN_MEMBER = "loginMember";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.example.EnjoyTripBackend.util;
package com.example.EnjoyTripBackend.util.argumentresolver;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.example.EnjoyTripBackend.util;
package com.example.EnjoyTripBackend.util.argumentresolver;

import jakarta.servlet.http.HttpServletRequest;
import lombok.extern.slf4j.Slf4j;
Expand All @@ -8,7 +8,7 @@
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.method.support.ModelAndViewContainer;

import static com.example.EnjoyTripBackend.util.SessionConst.LOGIN_MEMBER;
import static com.example.EnjoyTripBackend.util.argumentresolver.SessionConst.LOGIN_MEMBER;

@Slf4j
public class SessionUserArgumentResolver implements HandlerMethodArgumentResolver {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.example.EnjoyTripBackend.util;
package com.example.EnjoyTripBackend.util.collector;

import com.example.EnjoyTripBackend.domain.Airplane;
import com.example.EnjoyTripBackend.dto.airplane.AirplaneResponseDto;
Expand Down
Loading

0 comments on commit f899385

Please sign in to comment.