Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix : Schedule API 수정 UPDATE #37

Merged
merged 9 commits into from
Mar 5, 2024
41 changes: 22 additions & 19 deletions backend/build.gradle
Original file line number Diff line number Diff line change
@@ -1,48 +1,51 @@
plugins {
id 'java'
id 'org.springframework.boot' version '3.2.1'
id 'io.spring.dependency-management' version '1.1.4'
id 'java'
id 'org.springframework.boot' version '3.2.1'
id 'io.spring.dependency-management' version '1.1.4'
}

group = 'com.isp'
version = '0.0.1-SNAPSHOT'

java {
sourceCompatibility = '17'
sourceCompatibility = '17'
}

configurations {
compileOnly {
extendsFrom annotationProcessor
}
compileOnly {
extendsFrom annotationProcessor
}
}

repositories {
mavenCentral()
mavenCentral()
}

dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-security'

compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
runtimeOnly 'com.mysql:mysql-connector-j'
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
runtimeOnly 'com.mysql:mysql-connector-j'

// jwt
// JWT
implementation 'io.jsonwebtoken:jjwt-api:0.11.5'
implementation 'io.jsonwebtoken:jjwt-impl:0.11.5'
implementation 'io.jsonwebtoken:jjwt-jackson:0.11.5'

// AWS
implementation 'io.awspring.cloud:spring-cloud-starter-aws:2.4.2'

// Open API
implementation "com.amadeus:amadeus-java:8.0.0"

testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.security:spring-security-test'

//AWS
implementation 'io.awspring.cloud:spring-cloud-starter-aws:2.4.2'

}

tasks.named('test') {
useJUnitPlatform()
useJUnitPlatform()
}
14 changes: 7 additions & 7 deletions backend/src/main/java/com/isp/backend/BackendApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@

@SpringBootApplication
public class BackendApplication {
public static void main(String[] args) {
SpringApplication.run(BackendApplication.class, args);
}
public static void main(String[] args) {
SpringApplication.run(BackendApplication.class, args);
}

@Bean
public RestTemplate restTemplate(){
return new RestTemplate();
}
@Bean
public RestTemplate restTemplate() {
return new RestTemplate();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

import com.isp.backend.domain.schedule.entity.Schedule;
import jakarta.persistence.*;
import lombok.*;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.util.List;

Expand All @@ -11,23 +14,25 @@
@Entity
@Builder
@NoArgsConstructor
@Table(name="country")
@Table(name = "country")
public class Country {

@Id
@Column(name = "id", unique = true, nullable = false)
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@Column(name = "nation")
private String nation;

@Column(name = "city")
private String city;

@Column(name = "imageUrl")
private String imageUrl;

private String airportCode;

private double latitude ; // 위도

private double longitude ; // 경도

@OneToMany (mappedBy = "country")
private List<Schedule> schedules;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
import com.isp.backend.domain.country.entity.Country;
import org.springframework.data.jpa.repository.JpaRepository;

public interface CountryRepository extends JpaRepository<Country,Long> {
public interface CountryRepository extends JpaRepository<Country, Long> {

Country findIdByCity (String city); // 여행나라 이름으로 id 찾기
Country findIdByCity(String city); // 여행나라 이름으로 id 찾기

Country findCountryById (Long countryId); //
Country findCountryById(Long countryId); //

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ public class ChatGptConfig {
public static final Boolean STREAM = false;
public static final String ROLE = "user";
public static final Double TEMPERATURE = 0.6;
//public static final Double TOP_P = 1.0;
public static final String MEDIA_TYPE = "application/json; charset=UTF-8";
//completions : 질답
public static final String CHAT_URL = "https://api.openai.com/v1/chat/completions";
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,8 @@ public class ChatGptController {

@PostMapping("/question")
public ResponseEntity<ChatGptMessage> sendQuestion(@RequestBody QuestionRequestDTO questionRequestDTO) {
String code = "";
ChatGptResponseDTO chatGptResponseDTO = new ChatGptResponseDTO();
try {
chatGptResponseDTO = chatGptService.askQuestion(questionRequestDTO);
} catch (Exception e) {
code = e.getMessage();
}
chatGptResponseDTO = chatGptService.askQuestion(questionRequestDTO);
return ResponseEntity.ok(chatGptResponseDTO.getChoices().get(0).getMessage());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public HttpEntity<ChatGptRequestDTO> buildHttpEntity(ChatGptRequestDTO chatGptRe
return new HttpEntity<>(chatGptRequestDTO, httpHeaders);
}

public ChatGptResponseDTO getResponse(HttpEntity<ChatGptRequestDTO> chatGptRequestHttpEntity){
public ChatGptResponseDTO getResponse(HttpEntity<ChatGptRequestDTO> chatGptRequestHttpEntity) {

SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory();
requestFactory.setConnectTimeout(60000);
Expand All @@ -49,7 +49,8 @@ public ChatGptResponseDTO getResponse(HttpEntity<ChatGptRequestDTO> chatGptReque

return responseEntity.getBody();
}
public ChatGptResponseDTO askQuestion(QuestionRequestDTO questionRequestDTO){

public ChatGptResponseDTO askQuestion(QuestionRequestDTO questionRequestDTO) {
List<ChatGptMessage> messages = new ArrayList<>();
messages.add(ChatGptMessage.builder()
.role(ChatGptConfig.ROLE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,22 @@
@Entity
@Builder
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Table(name="image")
@Table(name = "image")
public class Image extends BaseEntity {

@Id
@Column(name="id", unique = true, nullable = false)
@Column(name = "id", unique = true, nullable = false)
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id ;
private Long id;

// @ManyToOne(fetch = FetchType.LAZY)
// @JoinColumn(name = "schedules_id", nullable = false)
// private Schedules schedules;

@Column(name = "image_name")
private String imageName ;
private String imageName;

@Column(name = "image_url")
private String imageUrl ;
private String imageUrl;

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
public class MemberController {

private final MemberService memberService;


/**
* 로그인 API
* 로그인 API
*/
@PostMapping("/login")
public ResponseEntity<String> memberLogin(@RequestBody GoogleLoginRequest request) {
Expand All @@ -30,40 +30,34 @@ public ResponseEntity<String> memberLogin(@RequestBody GoogleLoginRequest reques


/**
* 회원가입 - 추가 정보 API
* 회원가입 - 추가 정보 API
*/
@PutMapping("/signup")
public ResponseEntity<Void> signUp (@RequestBody SignUpRequest request,
@AuthenticationPrincipal CustomUserDetails customUserDetails) {
public ResponseEntity<Void> signUp(@RequestBody SignUpRequest request,
@AuthenticationPrincipal CustomUserDetails customUserDetails) {
String memberUid = customUserDetails.getUsername();
memberService.signUp(request, memberUid);
return ResponseEntity.status(HttpStatus.OK).build();
}



/**
* 토큰 재발행
* 토큰 재발행
*/
@PostMapping("/refresh")
public ResponseEntity<String> authRecreate (@RequestBody AuthRecreateRequest authRecreateRequest) {
public ResponseEntity<String> authRecreate(@RequestBody AuthRecreateRequest authRecreateRequest) {
return memberService.authRecreate(authRecreateRequest);
}


/**
* 멤버 정보 조회
* 멤버 정보 조회
*/
@GetMapping("/info")
public ResponseEntity<MemberDetailResponse> getMemberInfo (@AuthenticationPrincipal CustomUserDetails customUserDetails) {
public ResponseEntity<MemberDetailResponse> getMemberInfo(@AuthenticationPrincipal CustomUserDetails customUserDetails) {

return ResponseEntity.ok(memberService.getMemberInfo(customUserDetails.getUsername()));
}







}
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
package com.isp.backend.domain.member.dto;

import com.isp.backend.domain.member.entity.Member;
import lombok.*;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

@Getter
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
public class MemberDetailResponse {

private final String uid ;
private final String uid;

private final String name ;
private final String name;

private final String birth ;
private final String birth;

private final String phoneNumber ;
private final String phoneNumber;


public static MemberDetailResponse fromEntity(Member member){
public static MemberDetailResponse fromEntity(Member member) {
return new MemberDetailResponse(
member.getUid(),
member.getName(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
package com.isp.backend.domain.member.dto;

import com.isp.backend.domain.member.entity.Member;
import lombok.*;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

@NoArgsConstructor
@AllArgsConstructor
@Getter
public class SignUpRequest {

private String name ;
private String name;

private String birth ;
private String birth;

private String phoneNumber ;
private String phoneNumber;


public void toEntity(Member member) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,25 @@
@Builder
@Setter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Table(name="member")
@Table(name = "member")
public class Member extends BaseEntity {

@Id
@Column(name="id", unique = true, nullable = false)
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id ;
private Long id;

@Column(name = "uid", nullable = false)
private String uid ;
@Column(nullable = false)
private String uid;

@Column(name = "name")
private String name ;
private String name;

@Column(name = "birth")
private String birth ;
private String birth;

@Column(name = "phone_number")
private String phoneNumber ;
private String phoneNumber;

@Column(name = "login_type")
private String loginType ;
private String loginType;

@Builder.Default
@Column(name = "activated", nullable = false)
@Column(nullable = false)
private boolean activated = true;
}
Loading
Loading