Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
d08054f
[Fix] #58 cd-workflow dockerFile 방식 수정
Shinjongyun May 27, 2025
549e7bf
[HotFix] #58 cd-workflow dockerfile 방식 수정
Shinjongyun May 27, 2025
64902c7
[HotFix] #58 docker-compose에서 하이푼 제거
Shinjongyun May 27, 2025
cb7111a
[HotFix] #58 docker 빌드 시 필요한 환경변수 주입
Shinjongyun May 27, 2025
f4fbbf7
[HotFix] #58 cd-workflow 마지막 outputText 수정
Shinjongyun May 27, 2025
b0a28ec
[HotFix] #58 ec2에서 compose시 하이푼 제거
Shinjongyun May 27, 2025
bbefae9
[HotFix] #58 ec2에서 compose시 하이푼 롤백
Shinjongyun May 27, 2025
f31aee7
[HotFix] #58 docker image 태그 추가
Shinjongyun May 27, 2025
58b76ac
[Fix] #58 DockerFile 롤백
Shinjongyun May 27, 2025
5d122b0
Merge branch 'main' into fix/#58-cd-final-check
Shinjongyun May 27, 2025
f0c25fd
Merge pull request #60 from KUIT-BARO/fix/#58-cd-final-check
Shinjongyun May 27, 2025
08e6a1a
[HotFix] #58 메일 환경 변수 추가
Shinjongyun May 27, 2025
3b7afaf
[HotFix] #58 workflow application-secret.yml 복호화 추가
Shinjongyun May 27, 2025
2a778c3
[HotFix] #58 workflow application-secret.yml 롤백
Shinjongyun May 27, 2025
869a3e8
[HotFix] #58 application.yml profile prod로 변경
Shinjongyun May 27, 2025
1857b3b
[HotFix] #58 application.yml profile prod로 최종 변경
Shinjongyun May 27, 2025
7253059
[HotFix] #58 application.yml prod url 수정
Shinjongyun May 27, 2025
43e14ee
[HotFix] #58 인증번호 검증 post로 변경
Shinjongyun Jun 1, 2025
596ead2
[Feat] #61 중복 장소 검증 로직 추가
Shinjongyun Jun 1, 2025
9375dc9
[Fix] #61 회원가입 스웨거 수정
Shinjongyun Jun 1, 2025
2cc67d1
[Fix] #61 중복 장소 검증 로직 수정
Shinjongyun Jun 1, 2025
996379a
HotFix: SuggestedEndDate 오타
Shinjongyun Jul 26, 2025
1f816bc
[Fix] #63 UserService CurrentUserId 적용
Shinjongyun Aug 6, 2025
16676c7
[Fix] #64 ScheduleService CurrentUserId 적용
Shinjongyun Aug 6, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 24 additions & 15 deletions .github/workflows/cd-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@ jobs:
- name: "👏🏻 grant execute permission for gradlew"
run: chmod +x gradlew

- name: "🔐 Copy Secret"
env:
OCCUPY_SECRET: ${{ secrets.OCCUPY_SECRET }}
OCCUPY_SECRET_DIR: src/main/resources
OCCUPY_SECRET_DIR_FILE_NAME: application-secret.yml
run: |
mkdir -p $OCCUPY_SECRET_DIR
echo $OCCUPY_SECRET | base64 --decode > $OCCUPY_SECRET_DIR/$OCCUPY_SECRET_DIR_FILE_NAME

- name: "🐘 build with Gradle (without test)"
run: ./gradlew clean build -x test --stacktrace

Expand All @@ -34,25 +43,24 @@ jobs:
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: "🔐 Copy Secret"
env:
OCCUPY_SECRET: ${{ secrets.OCCUPY_SECRET }}
OCCUPY_SECRET_DIR: src/main/resources
OCCUPY_SECRET_DIR_FILE_NAME: application-secret.yml

- name: 📝 Generate .env file
run: |
mkdir -p $OCCUPY_SECRET_DIR
echo $OCCUPY_SECRET | base64 --decode > $OCCUPY_SECRET_DIR/$OCCUPY_SECRET_DIR_FILE_NAME
echo "DOCKER_USERNAME=${{ secrets.DOCKER_USERNAME }}" >> .env
echo "DOCKER_IMAGE=${{ secrets.DOCKER_IMAGE }}" >> .env
echo "PROD_DATASOURCE_URL=${{ secrets.PROD_DATASOURCE_URL }}" >> .env
echo "PROD_DATASOURCE_USERNAME=${{ secrets.PROD_DATASOURCE_USERNAME }}" >> .env
echo "PROD_DATASOURCE_PASSWORD=${{ secrets.PROD_DATASOURCE_PASSWORD }}" >> .env
echo "REDIS_HOST=${{ secrets.REDIS_HOST }}" >> .env
echo "REDIS_PORT=${{ secrets.REDIS_PORT }}" >> .env

- name: "🐳 Docker build & push"
run: |
docker build -f Dockerfile \
-t ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_IMAGE }} .
docker compose -f docker-compose.yml --env-file .env build
docker compose -f docker-compose.yml --env-file .env push

docker push ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_IMAGE }}

# AWS 인증
- name: AWS configure credentials
- name: ✅ AWS configure credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
Expand All @@ -75,9 +83,10 @@ jobs:
"echo \"PROD_DATASOURCE_PASSWORD=${{ secrets.PROD_DATASOURCE_PASSWORD }}\" >> .env",
"echo \"REDIS_HOST=${{ secrets.REDIS_HOST }}\" >> .env",
"echo \"REDIS_PORT=${{ secrets.REDIS_PORT }}\" >> .env",
"echo \"MAIL_USERNAME=${{ secrets.MAIL_USERNAME }}\" >> .env",
"echo \"MAIL_PASSWORD=${{ secrets.MAIL_PASSWORD }}\" >> .env",
"sudo docker-compose -f docker-compose.yml --env-file .env pull",
"sudo docker-compose -f docker-compose.yml --env-file .env down || true",
"sudo docker-compose -f docker-compose.yml --env-file .env up -d",
"sudo docker image prune -f"
]'
--output text
]' --output text
6 changes: 6 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM openjdk:17
EXPOSE 8001
ARG JAR_FILE=build/libs/*.jar
COPY ${JAR_FILE} app.jar

ENTRYPOINT ["java", "-jar", "/app.jar"]
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ version: '3.8'

services:
app:
build: .
image: "${DOCKER_USERNAME}/${DOCKER_IMAGE}"
container_name: BARO_CONTAINER
ports:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;

@Service
Expand Down Expand Up @@ -66,6 +67,11 @@ public void registerPinData(PinRequestDTO request, Long userId){
Place place;
if (request.getPlaceId() == -1) {
Point placePoint = GeometryUtil.createPoint(request.getLatitude(), request.getLongitude());
Optional<Place> existingPlace = placeRepository.findPlaceByPlaceAddress(request.getPlaceAddress());

if (existingPlace.isPresent()) {
throw new CustomException(ErrorCode.PLACE_ALREADY_EXISTS);
}
place = Place.builder()
.placeName(request.getPlaceName())
.location(placePoint)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ List<Place> findByDistanceAndPlaceCategories(

Optional<Place> findPlaceById(Long id);

Optional<Place> findPlaceByPlaceAddress(String placeAddress);

@Query(value = """
SELECT NEW
konkuk.kuit.baro.domain.place.dto.response.PlaceSummaryInfoResponseDTO(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ public class SuggestedPromiseResponseDTO {
private LocalDate suggestedStartDate;

@Schema(description = "약속 제안된 끝 날짜", example = "2025-01-02")
private LocalDate SuggestedEndDate;
private LocalDate suggestedEndDate;
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public PromiseAvailableTimeResponseDTO getPromiseAvailableTime(Long promiseId) {

@Transactional
public void setPromiseAvailableTime(SetPromiseAvailableTimeRequestDTO req, Long userId, Long promiseId) {
User loginUser = userRepository.findById(1L).orElseThrow(() -> new CustomException(USER_NOT_FOUND));
User loginUser = userRepository.findById(userId).orElseThrow(() -> new CustomException(USER_NOT_FOUND));

Promise promise = promiseRepository.findById(promiseId).orElseThrow(() -> new CustomException(PROMISE_NOT_FOUND));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import konkuk.kuit.baro.domain.schedule.dto.response.GetSchedulesResponseDTO;
import konkuk.kuit.baro.domain.schedule.dto.response.SchedulesDTO;
import konkuk.kuit.baro.domain.schedule.service.ScheduleService;
import konkuk.kuit.baro.global.auth.resolver.CurrentUserId;
import konkuk.kuit.baro.global.common.annotation.CustomExceptionDescription;
import konkuk.kuit.baro.global.common.response.BaseResponse;
import lombok.RequiredArgsConstructor;
Expand All @@ -28,26 +29,29 @@ public class ScheduleController {
@Operation(summary = "일정 추가", description = "일정표에 일정을 추가합니다.")
@PostMapping("")
@CustomExceptionDescription(SCHEDULE_ADD)
public BaseResponse<Void> addSchedule(@RequestBody @Validated AddScheduleRequestDTO req){
scheduleService.addSchedule(req);
public BaseResponse<Void> addSchedule(@RequestBody @Validated AddScheduleRequestDTO req,
@CurrentUserId Long userId) {
scheduleService.addSchedule(req, userId);
return BaseResponse.ok(null);
}

@Tag(name = "My Page", description = "유저 마이페이지 관련 API")
@Operation(summary = "일정 수정", description = "일정표의 일정을 수정합니다.")
@PatchMapping("{scheduleId}")
@CustomExceptionDescription(SCHEDULE_UPDATE)
public BaseResponse<Void> updateSchedule(@PathVariable Long scheduleId, @RequestBody @Validated AddScheduleRequestDTO req){
scheduleService.updateSchedule(req, scheduleId);
public BaseResponse<Void> updateSchedule(@PathVariable Long scheduleId,
@RequestBody @Validated AddScheduleRequestDTO req,
@CurrentUserId Long userId){
scheduleService.updateSchedule(req, scheduleId, userId);
return BaseResponse.ok(null);
}

@Tag(name = "My Page", description = "유저 마이페이지 관련 API")
@Operation(summary = "일정표 조회", description = "마이페이지에서 일정표를 조회합니다.")
@GetMapping("")
@CustomExceptionDescription(GET_SCHEDULES)
public BaseResponse<GetSchedulesResponseDTO> getSchedules(){
return BaseResponse.ok(scheduleService.getSchedules());
public BaseResponse<GetSchedulesResponseDTO> getSchedules(@CurrentUserId Long userId){
return BaseResponse.ok(scheduleService.getSchedules(userId));
}

@Tag(name = "My Page", description = "유저 마이페이지 관련 API")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ public class ScheduleService {
private final UserRepository userRepository;

@Transactional
public void addSchedule(AddScheduleRequestDTO req) {
User loginUser = userRepository.findById(1L)
public void addSchedule(AddScheduleRequestDTO req, Long userId) {
User loginUser = userRepository.findById(userId)
.orElseThrow(() -> new CustomException(USER_NOT_FOUND));

validateNewSchedule(req, loginUser);
Expand All @@ -45,8 +45,8 @@ public void addSchedule(AddScheduleRequestDTO req) {
}

@Transactional
public void updateSchedule(AddScheduleRequestDTO req, Long scheduleId) {
User loginUser = userRepository.findById(1L)
public void updateSchedule(AddScheduleRequestDTO req, Long scheduleId, Long userId) {
User loginUser = userRepository.findById(userId)
.orElseThrow(() -> new CustomException(USER_NOT_FOUND));

Schedule existingSchedule = scheduleRepository.findById(scheduleId)
Expand Down Expand Up @@ -104,8 +104,8 @@ private void validateCommonScheduleRules(AddScheduleRequestDTO req) {
}
}

public GetSchedulesResponseDTO getSchedules() {
User loginUser = userRepository.findById(1L).orElseThrow(() -> new CustomException(USER_NOT_FOUND));
public GetSchedulesResponseDTO getSchedules(Long userId) {
User loginUser = userRepository.findById(userId).orElseThrow(() -> new CustomException(USER_NOT_FOUND));
List<SchedulesDTO> schedules = scheduleRepository.findAllByUserId(loginUser.getId());
return new GetSchedulesResponseDTO(
loginUser.getProfileImage(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
public class UserController {
private final UserService userService;

@Tag(name = "Auth API", description = "Auth 관련 API")
@Operation(
summary = "회원가입",
description = "회원가입을 합니다. 토큰이 필요하지 않습니다."
Expand All @@ -41,8 +42,9 @@ public BaseResponse<Void> signup(@RequestBody SignUpRequestDTO request) {
@Operation(summary = "유저 프로필 수정", description = "유저의 이름, 프로필 사진을 변경합니다.")
@PostMapping("profile")
@CustomExceptionDescription(USER_PROFILE_UPDATE)
public BaseResponse<Void> updateProfile(@RequestBody @Validated UserUpdateProfileRequestDTO req){
userService.updateProfile(req);
public BaseResponse<Void> updateProfile(@RequestBody @Validated UserUpdateProfileRequestDTO req,
@CurrentUserId Long userId){
userService.updateProfile(req, userId);
return BaseResponse.ok(null);

}
Expand All @@ -59,24 +61,25 @@ public BaseResponse<UserProfileResponseDTO> getProfile(@CurrentUserId Long userI
@Operation(summary = "마이페이지 설정 화면", description = "마이페이지에서 설정 기능 호출 시 프로필을 조회하는 기능입니다.")
@GetMapping("profile-setting")
@CustomExceptionDescription(USER_PROFILE)
public BaseResponse<UserProfileSettingResponseDTO> getProfileSetting(Long userId){
public BaseResponse<UserProfileSettingResponseDTO> getProfileSetting(@CurrentUserId Long userId){
return BaseResponse.ok(userService.getProfileSetting(userId));
}

@Tag(name = "My Page", description = "유저 마이페이지 관련 API")
@Operation(summary = "비밀번호 변경", description = "사용자의 비밀번호를 변경합니다.")
@PostMapping("password")
@CustomExceptionDescription(USER_PASSWORD_UPDATE)
public BaseResponse<Void> updatePassword(@RequestBody @Validated UserUpdatePasswordRequestDTO req){
userService.updatePassword(req);
public BaseResponse<Void> updatePassword(@RequestBody @Validated UserUpdatePasswordRequestDTO req,
@CurrentUserId Long userId){
userService.updatePassword(req, userId);
return BaseResponse.ok(null);
}

@Tag(name = "My Page", description = "유저 마이페이지 관련 API")
@Operation(summary = "회원 탈퇴", description = "사용자가 회원 탈퇴를 합니다.")
@DeleteMapping()
@CustomExceptionDescription(USER_DELETE)
public BaseResponse<Void> delete(Long userId){
public BaseResponse<Void> delete(@CurrentUserId Long userId){
userService.deleteUser(userId);
return BaseResponse.ok(null);
}
Expand All @@ -85,7 +88,7 @@ public BaseResponse<Void> delete(Long userId){
@Operation(summary = "홈 화면 조회", description = "메인 홈 화면을 조회합니다.")
@GetMapping()
@CustomExceptionDescription(USER_HOME)
public BaseResponse<UserHomePageResponseDTO> getHomePage(){
return BaseResponse.ok(userService.getHomePage(1L));
public BaseResponse<UserHomePageResponseDTO> getHomePage(@CurrentUserId Long userId){
return BaseResponse.ok(userService.getHomePage(userId));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,9 @@ public void signup(SignUpRequestDTO request){


@Transactional
public void updateProfile(UserUpdateProfileRequestDTO req) {
User loginUser = userRepository.findById(1L).orElseThrow(() -> new CustomException(USER_NOT_FOUND));
public void updateProfile(UserUpdateProfileRequestDTO req, Long userId) {
User loginUser = userRepository.findById(userId)
.orElseThrow(() -> new CustomException(USER_NOT_FOUND));

validateName(req.getNewName());

Expand All @@ -81,18 +82,18 @@ private void validateName(String name){
}

public UserProfileResponseDTO getProfile(Long userId){
User loginUser = userRepository.findById(1L).orElseThrow(() -> new CustomException(USER_NOT_FOUND));
User loginUser = userRepository.findById(userId).orElseThrow(() -> new CustomException(USER_NOT_FOUND));
return new UserProfileResponseDTO(loginUser.getName(), loginUser.getProfileImage());
}

public UserProfileSettingResponseDTO getProfileSetting(Long userId){
User loginUser = userRepository.findById(1L).orElseThrow(() -> new CustomException(USER_NOT_FOUND));
User loginUser = userRepository.findById(userId).orElseThrow(() -> new CustomException(USER_NOT_FOUND));
return new UserProfileSettingResponseDTO(loginUser.getName(), loginUser.getEmail(), loginUser.getProfileImage());
}

@Transactional
public void updatePassword(UserUpdatePasswordRequestDTO req){
User loginUser = userRepository.findById(1L).orElseThrow(() -> new CustomException(USER_NOT_FOUND));
public void updatePassword(UserUpdatePasswordRequestDTO req, Long userId){
User loginUser = userRepository.findById(userId).orElseThrow(() -> new CustomException(USER_NOT_FOUND));

validateCurrentPassword(req, loginUser);
validateNewPassword(req);
Expand Down Expand Up @@ -124,7 +125,7 @@ private void validateCurrentPassword(UserUpdatePasswordRequestDTO req, User logi

@Transactional
public void deleteUser(Long userId){
User loginUser = userRepository.findById(1L).orElseThrow(() -> new CustomException(USER_NOT_FOUND));
User loginUser = userRepository.findById(userId).orElseThrow(() -> new CustomException(USER_NOT_FOUND));
userRepository.delete(loginUser);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ public BaseResponse<Void> sendAuthCodeMail(@RequestBody MailRequestDTO mailReque
summary = "인증번호 검증",
description = "메일로 받은 인증번호를 검증합니다. 액세스 토큰이 필요합니다."
)
@GetMapping("/mail/check")
public BaseResponse<Boolean> checkAuthCode(@RequestBody CodeCheckRequestDTO checkCodeRequestDTO) {
@PostMapping("/mail/check")
public BaseResponse<Void> checkAuthCode(@RequestBody CodeCheckRequestDTO checkCodeRequestDTO) {
mailService.checkAuthCode(checkCodeRequestDTO);
return BaseResponse.ok(null);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public enum ErrorCode implements ResponseStatus {
// Place
INVALID_LOCATION(400, BAD_REQUEST.value(), "위도, 경도값이 올바르지 않습니다."),
PLACE_NOT_FOUND(401, HttpStatus.NOT_FOUND.value(), "존재하지 않는 장소입니다."),
PLACE_ALREADY_EXISTS(402, BAD_REQUEST.value(), "이미 존재하는 장소입니다"),
//Promise
PROMISE_NOT_FOUND(500, HttpStatus.NOT_FOUND.value(),"존재하지 않는 약속입니다."),
PROMISE_NOT_CONFIRMED(501, BAD_REQUEST.value(), "확정되지 않은 약속입니다."),
Expand Down
6 changes: 3 additions & 3 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ spring:
local : local-db, dev-port, common
dev: dev-db, dev-port, common
prod: prod-db, prod-port,common
active: local
active: prod
---
# 로컬용 DB
spring:
Expand Down Expand Up @@ -61,7 +61,7 @@ spring:
activate:
on-profile: prod-db
datasource:
url: ${PROD_DATASOURCE_USERNAME}
url: ${PROD_DATASOURCE_URL}
username: ${PROD_DATASOURCE_USERNAME}
password: ${PROD_DATASOURCE_PASSWORD}
driver-class-name: com.mysql.cj.jdbc.Driver
Expand Down Expand Up @@ -121,4 +121,4 @@ spring:
activate:
on-profile: prod-port
server:
port: 8001
port: 8001
Loading