-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from KAKAO-TOUR-API-CONTEST/develop
숙박, 식당 상세정보 조회
- Loading branch information
Showing
18 changed files
with
501 additions
and
12 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
src/main/java/com/example/ai_jeju/controller/MainViewController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package com.example.ai_jeju.controller; | ||
|
||
|
||
import com.example.ai_jeju.domain.Restaurant; | ||
import com.example.ai_jeju.domain.Stay; | ||
import com.example.ai_jeju.service.MainVIewService; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
@RestController | ||
@RequestMapping("/api") | ||
public class MainViewController { | ||
|
||
@Autowired | ||
private MainVIewService mainViewService; | ||
|
||
/* | ||
@GetMapping("/mainList") | ||
public ResponseEntity<String> signOut(@RequestBody WithdrawRequest withdrawRequest) { | ||
String response = userService.withDraw(withdrawRequest); | ||
return ResponseEntity.ok(response); | ||
}*/ | ||
|
||
/* | ||
@GetMapping("/mainList") | ||
public User getUserById(@PathVariable Long id) { | ||
return userService.getUserById(id); | ||
} | ||
*/ | ||
|
||
@GetMapping("/restaurant/detailList") | ||
public Restaurant getUserById(@RequestParam int restaurantId) { | ||
return mainViewService.getRestaurantList(restaurantId); | ||
} | ||
|
||
|
||
@GetMapping("/stay/detailList") | ||
public Stay getStayById(@RequestParam int stayId) { | ||
return mainViewService.getStayList(stayId); | ||
} | ||
|
||
} |
6 changes: 6 additions & 0 deletions
6
src/main/java/com/example/ai_jeju/controller/PhotoBookController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.example.ai_jeju.controller; | ||
|
||
public class PhotoBookController { | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.example.ai_jeju.domain; | ||
|
||
import jakarta.persistence.*; | ||
import lombok.*; | ||
|
||
import java.sql.Date; | ||
|
||
@Table(name="child") | ||
@NoArgsConstructor(access= AccessLevel.PROTECTED) //기본생성자 | ||
@Getter | ||
@Entity | ||
@AllArgsConstructor // 모든 필드를 초기화하는 생성자 | ||
@Builder // 빌더 패턴 | ||
public class Child { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "child_id", updatable = false, unique = true) | ||
private Long childId; | ||
|
||
@Column | ||
private Long userId; | ||
|
||
@Column | ||
private Date birthDate; | ||
|
||
@Column | ||
private String childName; | ||
|
||
@Column | ||
private Boolean gender; | ||
|
||
@Column | ||
private long childProfile; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package com.example.ai_jeju.domain; | ||
|
||
|
||
import jakarta.persistence.*; | ||
import lombok.*; | ||
|
||
@Table(name="restaurant") | ||
@NoArgsConstructor(access= AccessLevel.PROTECTED) //기본생성자 | ||
@Getter | ||
@Entity | ||
@AllArgsConstructor // 모든 필드를 초기화하는 생성자 | ||
@Builder // 빌더 패턴 | ||
public class Restaurant { | ||
|
||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "restaraunt_id", updatable = false, unique = true) | ||
int restarauntId; | ||
|
||
|
||
@Column(name = "name", updatable = false, unique = true) | ||
String name; | ||
|
||
@Column(name = "latitude", updatable = false, unique = true) | ||
double latitude; | ||
|
||
@Column(name = "longitude", updatable = false, unique = true) | ||
double longitude; | ||
|
||
@Column(name = "address", updatable = false, unique = true) | ||
String address; | ||
|
||
@Column(name = "chair", updatable = false, unique = true) | ||
int chair; | ||
|
||
@Column(name = "palyground", updatable = false, unique = true) | ||
int playground; | ||
|
||
@Column(name = "stroller", updatable = false, unique = true) | ||
int stroller; | ||
|
||
@Column(name = "operation_time", updatable = false, unique = true) | ||
int operationTime; | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.example.ai_jeju.domain; | ||
|
||
import jakarta.persistence.*; | ||
import lombok.*; | ||
|
||
@Table(name="stay") | ||
@NoArgsConstructor(access= AccessLevel.PROTECTED) //기본생성자 | ||
@Getter | ||
@Entity | ||
@AllArgsConstructor // 모든 필드를 초기화하는 생성자 | ||
@Builder // 빌더 패턴 | ||
public class Stay { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "stay_id", updatable = false, unique = true) | ||
int stayId; | ||
|
||
@Column(name = "name", updatable = false, unique = true) | ||
String name; | ||
|
||
@Column(name = "latitude", updatable = false, unique = true) | ||
double latitude; | ||
|
||
@Column(name = "longitude", updatable = false, unique = true) | ||
double longitude; | ||
|
||
@Column(name = "address", updatable = false, unique = true) | ||
String address; | ||
|
||
@Column(name = "bed_forchild", updatable = false, unique = true) | ||
int chair; | ||
|
||
@Column(name = "stroller", updatable = false, unique = true) | ||
int stroller; | ||
|
||
@Column(name = "operation_time", updatable = false, unique = true) | ||
int operationTime; | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 93 additions & 0 deletions
93
src/main/java/com/example/ai_jeju/handler/SignUpHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
package com.example.ai_jeju.handler; | ||
|
||
import com.example.ai_jeju.domain.Child; | ||
import com.example.ai_jeju.domain.RefreshToken; | ||
import com.example.ai_jeju.domain.User; | ||
import com.example.ai_jeju.dto.SignUpRequest; | ||
import com.example.ai_jeju.generator.NickNameGenerator; | ||
import com.example.ai_jeju.jwt.TokenProvider; | ||
import com.example.ai_jeju.repository.ChildRepository; | ||
import com.example.ai_jeju.repository.RefreshTokenRepository; | ||
import com.example.ai_jeju.repository.UserRepository; | ||
import com.example.ai_jeju.util.CookieUtil; | ||
import jakarta.servlet.http.HttpServletRequest; | ||
import jakarta.servlet.http.HttpServletResponse; | ||
import lombok.AllArgsConstructor; | ||
import org.springframework.http.HttpEntity; | ||
import org.springframework.http.ResponseEntity; | ||
|
||
import java.io.IOException; | ||
import java.time.Duration; | ||
import java.util.List; | ||
|
||
import static com.example.ai_jeju.util.CookieUtil.addCookie; | ||
|
||
|
||
@AllArgsConstructor | ||
public class SignUpHandler { | ||
public static final String REFRESH_TOKEN_COOKIE_NAME = "refresh_token"; | ||
public static final Duration REFRESH_TOKEN_DURATION = Duration.ofDays(14); | ||
public static final Duration ACCESS_TOKEN_DURATION = Duration.ofDays(1); | ||
|
||
HttpServletResponse response; | ||
|
||
|
||
UserRepository userRepository; | ||
RefreshTokenRepository refreshTokenRepository; | ||
TokenProvider tokenProvider; | ||
CookieUtil cookieUtil; | ||
ChildRepository childRepository; | ||
|
||
public String successHadler(SignUpRequest signUpRequest) throws IOException { | ||
|
||
String nick = signUpRequest.getNickname(); | ||
if(nick==null){ | ||
nick = new NickNameGenerator().getNickname(); | ||
} | ||
|
||
// Save new user using builder pattern | ||
User newUser = User.builder() | ||
.name(signUpRequest.getName()) | ||
.nickname(nick) | ||
.provider(signUpRequest.getProvider()) | ||
.email(signUpRequest.getEmail()) | ||
.profile(signUpRequest.getProfile()) | ||
.provider(signUpRequest.getProvider()) | ||
.build(); | ||
|
||
|
||
String accessToken = tokenProvider.generateToken(newUser, REFRESH_TOKEN_DURATION); | ||
/*-------------------------------------------*/ | ||
//동반아동 | ||
List<Child> childList = signUpRequest.getChild(); | ||
for(int i=0; i<childList.size(); i++){ | ||
Child child = Child.builder() | ||
.userId(newUser.getId()) | ||
.childName(childList.get(i).getChildName()) | ||
.birthDate(childList.get(i).getBirthDate()) | ||
.gender(childList.get(i).getGender()) | ||
.build(); | ||
childRepository.save(child); | ||
} | ||
|
||
userRepository.save(newUser); | ||
|
||
String refresh_token = tokenProvider.generateToken(newUser, REFRESH_TOKEN_DURATION); | ||
RefreshToken refreshToken = RefreshToken.builder() | ||
.refresh_token(refresh_token) | ||
.userId(newUser.getId()).build(); | ||
|
||
refreshTokenRepository.save(refreshToken); | ||
|
||
userRepository.save(newUser); | ||
|
||
int cookieMaxAge = (int) REFRESH_TOKEN_DURATION.toSeconds(); | ||
|
||
CookieUtil.addCookie(response, REFRESH_TOKEN_COOKIE_NAME, refresh_token, cookieMaxAge); | ||
|
||
return accessToken; | ||
} | ||
|
||
|
||
|
||
} |
13 changes: 13 additions & 0 deletions
13
src/main/java/com/example/ai_jeju/repository/ChildRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.example.ai_jeju.repository; | ||
|
||
|
||
import com.example.ai_jeju.domain.Child; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@Repository | ||
public interface ChildRepository extends JpaRepository<Child, Long> { | ||
|
||
|
||
|
||
} |
14 changes: 14 additions & 0 deletions
14
src/main/java/com/example/ai_jeju/repository/MainListRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.example.ai_jeju.repository; | ||
|
||
import com.example.ai_jeju.domain.Restaurant; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import java.util.Optional; | ||
|
||
@Repository | ||
public interface MainListRepository extends JpaRepository<Restaurant, Long> { | ||
Optional<Restaurant> findByRestarauntId(int restaurantId); | ||
|
||
} | ||
|
Oops, something went wrong.