-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Feat: customException 구현 * Feat: responseDto 구현 * Feat: 내 근처 킥보드 주차장 찾기 API 구현 * Fix: BoardingRecord 도메인 수정 * Feat: Spring Security, JWT Cookie, 소셜 로그인 기능 구현 * Feat: Spring Security, JWT Cookie, 소셜 로그인 기능 구현 * Fix: 코드 에러 수정 * Refactor: 아직 사용하지 않는 코드 삭제 * Feat: oauth2 의존성 추가 * Chore: Credentials 추가 * ✨ [Feature] - 서버 날짜 설정 및 유저 닉네임 설정 (#15) * Feat: 스프링 서버 시간 한국으로 설정 * Feat: 사용자 닉네임 지정 로직 추가 * Fix: 초기 포인트 설정 * Fix: nickname 에러 수정 (#18) * Fix: BoardingRecord 도메인 수정 * Feat: 디펜던시 추가 * Feat: ErrorCode 추가 * Feat: Image API 구현 * Feat: WebClientConfig 구현 * Feat: S3ClientConfig 구현 * Feat: BoardingRecord API 구현 * Feat: 주차장 예측 결과 관련 기능 추가 * Feat: 탑승 기록 저장 API 구현 * Fix: 디렉토리 경로 수정 * Feat: 코드 리팩터링 진행 --------- Co-authored-by: Jang99u <[email protected]> Co-authored-by: 민장규 <[email protected]>
- Loading branch information
1 parent
829de04
commit d626bdc
Showing
41 changed files
with
633 additions
and
55 deletions.
There are no files selected for viewing
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,32 @@ | ||
package ice.spot.config; | ||
|
||
import com.amazonaws.auth.AWSStaticCredentialsProvider; | ||
import com.amazonaws.auth.BasicAWSCredentials; | ||
import com.amazonaws.services.s3.AmazonS3Client; | ||
import com.amazonaws.services.s3.AmazonS3ClientBuilder; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Configuration | ||
public class S3Config { | ||
|
||
@Value("${cloud.aws.credentials.access-key}") | ||
private String accessKey; | ||
|
||
@Value("${cloud.aws.credentials.secret-key}") | ||
private String secretKey; | ||
|
||
@Value("${cloud.aws.region.static}") | ||
private String region; | ||
|
||
@Bean | ||
public AmazonS3Client amazonS3Client() { | ||
BasicAWSCredentials credentials = new BasicAWSCredentials(accessKey, secretKey); | ||
|
||
return (AmazonS3Client) AmazonS3ClientBuilder.standard() | ||
.withCredentials(new AWSStaticCredentialsProvider(credentials)) | ||
.withRegion(region) | ||
.build(); | ||
} | ||
} |
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,22 @@ | ||
package ice.spot.config; | ||
|
||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.http.HttpHeaders; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.web.reactive.function.client.WebClient; | ||
|
||
@Configuration | ||
public class WebClientConfig { | ||
|
||
@Bean | ||
public WebClient webClient(WebClient.Builder builder) { | ||
return builder | ||
.baseUrl("https://detectingkickboard11-prediction.cognitiveservices.azure.com") | ||
.defaultHeaders(httpHeaders -> { | ||
httpHeaders.add(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE); | ||
httpHeaders.add("Prediction-Key", "17482dedf9834e0c958d0e88a3bf940d"); | ||
}) | ||
.build(); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
src/main/java/ice/spot/controller/BoardingRecordController.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,40 @@ | ||
package ice.spot.controller; | ||
|
||
import ice.spot.annotation.UserId; | ||
import ice.spot.dto.boardingrecord.request.BoardingRecordRequest; | ||
import ice.spot.dto.global.ResponseDto; | ||
import ice.spot.service.BoardingRecordService; | ||
import ice.spot.service.ImageService; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.web.bind.annotation.*; | ||
import org.springframework.web.multipart.MultipartFile; | ||
|
||
import java.io.IOException; | ||
|
||
@Slf4j | ||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/api") | ||
public class BoardingRecordController { | ||
|
||
private final ImageService imageService; | ||
private final BoardingRecordService boardingRecordService; | ||
|
||
@PostMapping("/boarding-record") | ||
public ResponseDto<?> saveBoardingRecord ( | ||
@UserId Long userId, | ||
@RequestPart(value = "image", required = false) MultipartFile multipartFile, | ||
@RequestPart(value = "dto") BoardingRecordRequest boardingRecordRequest | ||
) throws IOException { | ||
Long imageId = imageService.saveImage(multipartFile); | ||
|
||
return ResponseDto.created(boardingRecordService | ||
.saveBoardingRecord(userId, imageId, boardingRecordRequest)); | ||
} | ||
|
||
@GetMapping("/boarding-record") | ||
public ResponseDto<?> getBoardingRecord (@UserId Long userId) { | ||
return ResponseDto.ok(boardingRecordService.boardingRecordList(userId)); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/main/java/ice/spot/controller/ParkingLotController.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,21 @@ | ||
package ice.spot.controller; | ||
|
||
import ice.spot.dto.global.ResponseDto; | ||
import ice.spot.service.ParkingLotService; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/api") | ||
public class ParkingLotController { | ||
private final ParkingLotService parkingLotService; | ||
|
||
@GetMapping("/kickboard") | ||
public ResponseDto<?> parkingLotList(@RequestParam Double lat, @RequestParam Double lon) { | ||
return ResponseDto.ok(parkingLotService.parkingLotList(lat, lon)); | ||
} | ||
} |
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,52 @@ | ||
package ice.spot.domain; | ||
|
||
import jakarta.persistence.*; | ||
import lombok.AccessLevel; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.util.UUID; | ||
|
||
@Entity | ||
@Getter | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@Table(name = "image") | ||
public class Image { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "id") | ||
private Long id; | ||
|
||
@Column(name = "origin_name") | ||
private String originName; | ||
|
||
@Column(name = "stored_name") | ||
private String storedName; | ||
|
||
@Column(name = "image_url") | ||
private String imageUrl; | ||
|
||
@OneToOne(mappedBy = "image") | ||
private BoardingRecord boardingRecord; | ||
|
||
public Image(String originName) { | ||
this.originName = originName; | ||
this.storedName = getFileName(originName); | ||
this.imageUrl = ""; | ||
} | ||
|
||
public void setAccessUrl(String imageUrl) { | ||
this.imageUrl = imageUrl; | ||
} | ||
|
||
public String extractExtension(String originName) { | ||
int index = originName.lastIndexOf('.'); | ||
|
||
return originName.substring(index, originName.length()); | ||
} | ||
|
||
public String getFileName(String originName) { | ||
return UUID.randomUUID() + "." + extractExtension(originName); | ||
} | ||
|
||
} |
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
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,17 @@ | ||
package ice.spot.domain.type; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
public enum ParkingLotResult { | ||
|
||
CORRECT_PARKING_LOT(0, "올바른 주차구역에 주차되었습니다."), | ||
WRONG_PARKING_LOT(1, "올바르지 않은 주차구역입니다."), | ||
NOT_FOUND_KICKBOARD(2, "킥보드가 인식되지 않습니다."), | ||
; | ||
|
||
private final Integer code; | ||
private final String message; | ||
} |
10 changes: 10 additions & 0 deletions
10
src/main/java/ice/spot/dto/boardingrecord/request/BoardingRecordRequest.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,10 @@ | ||
package ice.spot.dto.boardingrecord.request; | ||
|
||
import lombok.Builder; | ||
|
||
@Builder | ||
public record BoardingRecordRequest( | ||
Double distance, | ||
Integer time | ||
) { | ||
} |
14 changes: 14 additions & 0 deletions
14
src/main/java/ice/spot/dto/boardingrecord/response/BoardingRecordListResponse.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 ice.spot.dto.boardingrecord.response; | ||
|
||
import ice.spot.dto.user.response.PersonResponse; | ||
import lombok.Builder; | ||
|
||
import java.util.List; | ||
|
||
@Builder | ||
public record BoardingRecordListResponse( | ||
PersonResponse personResponse, | ||
|
||
List<BoardingRecordResponse> boardingRecordResponseList | ||
) { | ||
} |
26 changes: 26 additions & 0 deletions
26
src/main/java/ice/spot/dto/boardingrecord/response/BoardingRecordResponse.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,26 @@ | ||
package ice.spot.dto.boardingrecord.response; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import lombok.Builder; | ||
|
||
@Builder | ||
public record BoardingRecordResponse( | ||
@JsonProperty("created_at") | ||
String createdAt, | ||
|
||
@JsonProperty("image") | ||
String image, | ||
|
||
@JsonProperty("distance") | ||
Double distance, | ||
|
||
@JsonProperty("time") | ||
Integer time, | ||
|
||
@JsonProperty("point") | ||
Integer point | ||
) { | ||
public static BoardingRecordResponse of(String createdAt, String image, Double distance, Integer time, Integer point) { | ||
return new BoardingRecordResponse(createdAt, image, distance, time, point); | ||
} | ||
} |
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
Oops, something went wrong.