From 8a4885222d6e417425f1a1b8ee50cf9672b6cc19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A3=BC=EC=96=B4=EC=A7=84=EC=82=AC=EB=9E=91=28eojinjoo?= =?UTF-8?q?=29?= Date: Tue, 23 May 2023 00:39:33 +0900 Subject: [PATCH 1/3] del: api v1 --- .../v1/application/auth/AuthUseCaseImpl.java | 64 -------- .../v1/application/auth/EncryptService.java | 19 --- .../application/mission/MissionServiceV1.java | 155 ------------------ .../v1/application/rank/RankServiceV1.java | 61 ------- .../v1/application/stamp/StampServiceV1.java | 151 ----------------- .../app/v1/application/user/UserUseCase.java | 12 -- .../v1/application/user/UserUseCaseImpl.java | 36 ---- .../v1/application/user/dto/LogInUserDto.java | 10 -- .../application/user/dto/SignUpUserDto.java | 24 --- .../user/service/UserServiceV1.java | 34 ---- .../postgres/MissionRepositoryV1.java | 14 -- .../postgres/StampRepositoryV1.java | 15 -- .../interfaces/postgres/UserRepositoryV1.java | 14 -- .../app/v1/presentation/BaseController.java | 23 --- .../presentation/auth/AuthControllerV1.java | 64 -------- .../auth/dto/ChangeNicknameRequestDto.java | 16 -- .../auth/dto/ChangePasswordRequestDto.java | 14 -- .../firebase/FirebaseControllerV1.java | 31 ---- .../firebase/dto/FirebaseResponseDto.java | 33 ---- .../mission/MissionControllerV1.java | 95 ----------- .../mission/dto/GetAllMissionResponseDto.java | 30 ---- .../mission/dto/MissionRequestDto.java | 18 -- .../mission/dto/MissionResponseDto.java | 19 --- .../presentation/rank/RankControllerV1.java | 48 ------ .../rank/dto/FindAllRanksResponseDto.java | 19 --- .../rank/dto/FindRankResponseDto.java | 22 --- .../rank/dto/UserProfileRequestDto.java | 14 -- .../presentation/stamp/StampControllerV1.java | 117 ------------- .../stamp/dto/StampRequestDto.java | 15 -- .../stamp/dto/StampResponseDto.java | 18 -- .../presentation/user/UserControllerV1.java | 56 ------- .../user/request/CreateUserRequest.java | 18 -- .../user/request/LogInUserRequest.java | 19 --- .../user/response/LoginResponse.java | 16 -- .../user/response/SignUpResponse.java | 15 -- 35 files changed, 1329 deletions(-) delete mode 100644 src/main/java/org/sopt/app/v1/application/auth/AuthUseCaseImpl.java delete mode 100644 src/main/java/org/sopt/app/v1/application/auth/EncryptService.java delete mode 100644 src/main/java/org/sopt/app/v1/application/mission/MissionServiceV1.java delete mode 100644 src/main/java/org/sopt/app/v1/application/rank/RankServiceV1.java delete mode 100644 src/main/java/org/sopt/app/v1/application/stamp/StampServiceV1.java delete mode 100644 src/main/java/org/sopt/app/v1/application/user/UserUseCase.java delete mode 100644 src/main/java/org/sopt/app/v1/application/user/UserUseCaseImpl.java delete mode 100644 src/main/java/org/sopt/app/v1/application/user/dto/LogInUserDto.java delete mode 100644 src/main/java/org/sopt/app/v1/application/user/dto/SignUpUserDto.java delete mode 100644 src/main/java/org/sopt/app/v1/application/user/service/UserServiceV1.java delete mode 100644 src/main/java/org/sopt/app/v1/interfaces/postgres/MissionRepositoryV1.java delete mode 100644 src/main/java/org/sopt/app/v1/interfaces/postgres/StampRepositoryV1.java delete mode 100644 src/main/java/org/sopt/app/v1/interfaces/postgres/UserRepositoryV1.java delete mode 100644 src/main/java/org/sopt/app/v1/presentation/BaseController.java delete mode 100644 src/main/java/org/sopt/app/v1/presentation/auth/AuthControllerV1.java delete mode 100644 src/main/java/org/sopt/app/v1/presentation/auth/dto/ChangeNicknameRequestDto.java delete mode 100644 src/main/java/org/sopt/app/v1/presentation/auth/dto/ChangePasswordRequestDto.java delete mode 100644 src/main/java/org/sopt/app/v1/presentation/firebase/FirebaseControllerV1.java delete mode 100644 src/main/java/org/sopt/app/v1/presentation/firebase/dto/FirebaseResponseDto.java delete mode 100644 src/main/java/org/sopt/app/v1/presentation/mission/MissionControllerV1.java delete mode 100644 src/main/java/org/sopt/app/v1/presentation/mission/dto/GetAllMissionResponseDto.java delete mode 100644 src/main/java/org/sopt/app/v1/presentation/mission/dto/MissionRequestDto.java delete mode 100644 src/main/java/org/sopt/app/v1/presentation/mission/dto/MissionResponseDto.java delete mode 100644 src/main/java/org/sopt/app/v1/presentation/rank/RankControllerV1.java delete mode 100644 src/main/java/org/sopt/app/v1/presentation/rank/dto/FindAllRanksResponseDto.java delete mode 100644 src/main/java/org/sopt/app/v1/presentation/rank/dto/FindRankResponseDto.java delete mode 100644 src/main/java/org/sopt/app/v1/presentation/rank/dto/UserProfileRequestDto.java delete mode 100644 src/main/java/org/sopt/app/v1/presentation/stamp/StampControllerV1.java delete mode 100644 src/main/java/org/sopt/app/v1/presentation/stamp/dto/StampRequestDto.java delete mode 100644 src/main/java/org/sopt/app/v1/presentation/stamp/dto/StampResponseDto.java delete mode 100644 src/main/java/org/sopt/app/v1/presentation/user/UserControllerV1.java delete mode 100644 src/main/java/org/sopt/app/v1/presentation/user/request/CreateUserRequest.java delete mode 100644 src/main/java/org/sopt/app/v1/presentation/user/request/LogInUserRequest.java delete mode 100644 src/main/java/org/sopt/app/v1/presentation/user/response/LoginResponse.java delete mode 100644 src/main/java/org/sopt/app/v1/presentation/user/response/SignUpResponse.java diff --git a/src/main/java/org/sopt/app/v1/application/auth/AuthUseCaseImpl.java b/src/main/java/org/sopt/app/v1/application/auth/AuthUseCaseImpl.java deleted file mode 100644 index a6a56a75..00000000 --- a/src/main/java/org/sopt/app/v1/application/auth/AuthUseCaseImpl.java +++ /dev/null @@ -1,64 +0,0 @@ -package org.sopt.app.v1.application.auth; - -import java.util.Optional; -import lombok.RequiredArgsConstructor; -import org.sopt.app.common.exception.v1.DbException; -import org.sopt.app.common.exception.v1.ExistUserException; -import org.sopt.app.common.exception.v1.UserNotFoundException; -import org.sopt.app.domain.entity.User; -import org.sopt.app.v1.interfaces.postgres.UserRepositoryV1; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -@Service -@RequiredArgsConstructor -public class AuthUseCaseImpl { - - private final UserRepositoryV1 userRepositoryV1; - private final EncryptService encryptService; - - public void validate(String nickname, String email) { - if (nickname != null) { - validateNickname(nickname); - } - if (email != null) { - validateEmail(email); - } - } - - @Transactional - public void changePassword(String userId, String password) { - User user = userRepositoryV1.findUserById(Long.parseLong(userId)).orElseThrow(); - user.password = encryptService.encode(password); - } - - @Transactional - public void changeNickname(String userId, String nickname) { - User user = userRepositoryV1.findUserById(Long.parseLong(userId)).orElseThrow(); - user.nickname = nickname; - } - - private void validateEmail(String email) throws UserNotFoundException { - Optional user = userRepositoryV1.findUserByEmail(email); - if (user.isPresent()) { - throw new ExistUserException("이미 등록된 이메일입니다."); - } - } - - private void validateNickname(String nickname) { - Optional user = userRepositoryV1.findUserByNickname(nickname); - if (user.isPresent()) { - throw new ExistUserException("사용 중인 닉네임입니다."); - } - - } - - @Transactional - public void deleteUser(String userId) { - try { - userRepositoryV1.deleteById(Long.parseLong(userId)); - } catch (Exception e) { - throw new DbException(e); - } - } -} diff --git a/src/main/java/org/sopt/app/v1/application/auth/EncryptService.java b/src/main/java/org/sopt/app/v1/application/auth/EncryptService.java deleted file mode 100644 index 9bee1c39..00000000 --- a/src/main/java/org/sopt/app/v1/application/auth/EncryptService.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.sopt.app.v1.application.auth; - -import org.springframework.security.crypto.bcrypt.BCrypt; -import org.springframework.security.crypto.password.PasswordEncoder; -import org.springframework.stereotype.Component; - -@Component -public class EncryptService implements PasswordEncoder { - - @Override - public String encode(CharSequence rawPassword) { - return BCrypt.hashpw(rawPassword.toString(), BCrypt.gensalt()); - } - - @Override - public boolean matches(CharSequence rawPassword, String encodedPassword) { - return BCrypt.checkpw(rawPassword.toString(), encodedPassword); - } -} \ No newline at end of file diff --git a/src/main/java/org/sopt/app/v1/application/mission/MissionServiceV1.java b/src/main/java/org/sopt/app/v1/application/mission/MissionServiceV1.java deleted file mode 100644 index 714aac56..00000000 --- a/src/main/java/org/sopt/app/v1/application/mission/MissionServiceV1.java +++ /dev/null @@ -1,155 +0,0 @@ -package org.sopt.app.v1.application.mission; - -import java.util.ArrayList; -import java.util.Comparator; -import java.util.List; -import java.util.function.Predicate; -import java.util.stream.Collectors; -import lombok.RequiredArgsConstructor; -import org.sopt.app.domain.entity.Mission; -import org.sopt.app.domain.entity.Stamp; -import org.sopt.app.v1.interfaces.postgres.MissionRepositoryV1; -import org.sopt.app.v1.interfaces.postgres.StampRepositoryV1; -import org.sopt.app.v1.presentation.mission.dto.GetAllMissionResponseDto; -import org.sopt.app.v1.presentation.mission.dto.MissionRequestDto; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -@Service -@RequiredArgsConstructor -public class MissionServiceV1 { - - private final MissionRepositoryV1 missionRepositoryV1; - private final StampRepositoryV1 stampRepositoryV1; - - - public List findAllMission(String userId) { - List completedStamps = stampRepositoryV1.findAllByUserId(Long.parseLong(userId)); - List missions = missionRepositoryV1.findAll(); - return missions.stream() - .map(mission -> - GetAllMissionResponseDto.builder() - .id(mission.getId()) - .title(mission.getTitle()) - .level(mission.getLevel()) - .profileImage(mission.getProfileImage()) - .isCompleted(isCompletedMission(mission.getId(), completedStamps)) - .build()) - .sorted(Comparator.comparing(GetAllMissionResponseDto::getLevel)) - .collect(Collectors.toList()); - } - - private Boolean isCompletedMission(Long missionId, List completedStamps) { - return completedStamps.stream().anyMatch( - stamp -> stamp.getMissionId().equals(missionId)); - } - - - // 게시글 작성 - 이미지 미포함 - @Transactional - public Mission uploadMission(MissionRequestDto missionRequestDto) { - Mission mission = this.convertMission(missionRequestDto); - return missionRepositoryV1.save(mission); - } - - // 게시글 작성 - 이미지 포함 - @Transactional - public Mission uploadMissionWithImg(MissionRequestDto missionRequestDto, List imgPaths) { - - List imgList = new ArrayList<>(imgPaths); - Mission mission = this.convertMissionImg(missionRequestDto, imgList); - return missionRepositoryV1.save(mission); - - } - - - //Mission 완료한 미션만 불러오기 - @Transactional - public List getCompleteMission(String userId) { - - //헤더에서 받은 userId로 Stamp 테이블에서 달성한 미션번호 가져오기 - List stampList = stampRepositoryV1.findAllByUserId(Long.valueOf(userId)); - - //달성한 미션번호리스트 - List missionIdList = new ArrayList<>(); - for (Stamp stamp : stampList) { - missionIdList.add(stamp.getMissionId()); - } - - return missionRepositoryV1.findMissionIn(missionIdList); - } - -// private void getCompleteMission(List stampList, Mission mission) { -// -// mission. -// -// -//// coupon.updateUseCoupon( -//// couponUsedCommand -//// .getCpnNoList() -//// .stream() -//// .filter((CouponUsed command) -> -//// command.getCouponNumber().equals(coupon.getCouponId())) -//// .findAny().orElseThrow(IllegalArgumentException::new)); -// } - - /** - * 미완료 미션만 불러오기 - */ - @Transactional - public List getIncompleteMission(String userId) { - - //전체 미션 조회하기 - List missionList = missionRepositoryV1.findAll(); - List allMissionList = new ArrayList<>(); - for (Mission mission : missionList) { - allMissionList.add(mission.getId()); - } - - //stamp에서 userId로 달성한 mission 조회하기 - List stampList = stampRepositoryV1.findAllByUserId(Long.valueOf(userId)); - List completeMissionIdList = new ArrayList<>(); - for (Stamp stamp : stampList) { - completeMissionIdList.add(stamp.getMissionId()); - } - - //두 리스트 비교해서 중복값 제거 - List inCompleteIdList = allMissionList.stream() - .filter(all -> completeMissionIdList.stream().noneMatch(Predicate.isEqual(all))) - .toList(); - -// noneMatch: 중복 X -// anyMatch: 중복 O -// List oldList = Arrays.asList("1", "2", "3", "4"); -// List newList = Arrays.asList("3", "4", "5", "6"); -// -// List resultList1 = oldList.stream() -// .filter(old -> newList.stream().noneMatch(Predicate.isEqual(old))) -// .collect(Collectors.toList()); -// -// System.out.println(resultList1); // [1, 2] - - return missionRepositoryV1.findMissionIn(inCompleteIdList); - } - - - //Mission Entity 양식에 맞게 데이터 세팅 - private Mission convertMissionImg(MissionRequestDto missionRequestDto, List imgList) { - return Mission.builder() - .title(missionRequestDto.getTitle()) - .level(missionRequestDto.getLevel()) - .display(true) - .profileImage(imgList) - .build(); - } - - private Mission convertMission(MissionRequestDto missionRequestDto) { - - return Mission.builder() - .title(missionRequestDto.getTitle()) - .level(missionRequestDto.getLevel()) - .display(true) - .build(); - } - -} diff --git a/src/main/java/org/sopt/app/v1/application/rank/RankServiceV1.java b/src/main/java/org/sopt/app/v1/application/rank/RankServiceV1.java deleted file mode 100644 index 3d8c428f..00000000 --- a/src/main/java/org/sopt/app/v1/application/rank/RankServiceV1.java +++ /dev/null @@ -1,61 +0,0 @@ -package org.sopt.app.v1.application.rank; - -import static org.sopt.app.common.ResponseCode.INVALID_RESPONSE; - -import java.util.Comparator; -import java.util.List; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.stream.Collectors; -import lombok.RequiredArgsConstructor; -import org.sopt.app.common.exception.v1.ApiException; -import org.sopt.app.domain.entity.User; -import org.sopt.app.v1.application.mission.MissionServiceV1; -import org.sopt.app.v1.interfaces.postgres.UserRepositoryV1; -import org.sopt.app.v1.presentation.rank.dto.FindAllRanksResponseDto; -import org.sopt.app.v1.presentation.rank.dto.FindRankResponseDto; -import org.springframework.stereotype.Service; - -@Service -@RequiredArgsConstructor -public class RankServiceV1 { - - private final UserRepositoryV1 userRepositoryV1; - - private final MissionServiceV1 missionServiceV1; - - //User 한마디 등록하기 - public User updateProfileMessage(Long userId, String profileMessage) { - - User user = userRepositoryV1.findUserById(userId) - .orElseThrow(() -> new ApiException(INVALID_RESPONSE)); - - user.updateProfileMessage(profileMessage); - return userRepositoryV1.save(user); - } - - public List findRanks() { - List users = userRepositoryV1.findAll(); - AtomicInteger rankPoint = new AtomicInteger(1); - return users.stream().sorted( - Comparator.comparing(User::getPoints).reversed()) - .map(user -> FindAllRanksResponseDto.builder() - .rank(rankPoint.getAndIncrement()) - .userId(user.getId()) - .nickname(user.getNickname()) - .point(user.getPoints()) - .profileMessage(user.getProfileMessage()) - .build()) - .collect(Collectors.toList()); - } - - public FindRankResponseDto findRankById(Long userId) { - User user = userRepositoryV1.findUserById(userId).orElseThrow(() -> new ApiException(INVALID_RESPONSE)); - return FindRankResponseDto.builder() - .userId(userId) - .nickname(user.getNickname()) - .profileMessage(user.getProfileMessage()) - .userMissions(missionServiceV1.getCompleteMission(String.valueOf(userId))) - .build(); - } - -} diff --git a/src/main/java/org/sopt/app/v1/application/stamp/StampServiceV1.java b/src/main/java/org/sopt/app/v1/application/stamp/StampServiceV1.java deleted file mode 100644 index dab19c57..00000000 --- a/src/main/java/org/sopt/app/v1/application/stamp/StampServiceV1.java +++ /dev/null @@ -1,151 +0,0 @@ -package org.sopt.app.v1.application.stamp; - -import static org.sopt.app.common.ResponseCode.DUPLICATE_STAMP; -import static org.sopt.app.common.ResponseCode.INVALID_RESPONSE; - -import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.List; -import lombok.RequiredArgsConstructor; -import org.sopt.app.common.exception.v1.ApiException; -import org.sopt.app.domain.entity.Mission; -import org.sopt.app.domain.entity.Stamp; -import org.sopt.app.domain.entity.User; -import org.sopt.app.v1.interfaces.postgres.MissionRepositoryV1; -import org.sopt.app.v1.interfaces.postgres.StampRepositoryV1; -import org.sopt.app.v1.interfaces.postgres.UserRepositoryV1; -import org.sopt.app.v1.presentation.stamp.dto.StampRequestDto; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.util.StringUtils; - -@Service -@RequiredArgsConstructor -public class StampServiceV1 { - - private final StampRepositoryV1 stampRepositoryV1; - - private final UserRepositoryV1 userRepositoryV1; - - private final MissionRepositoryV1 missionRepositoryV1; - - public Stamp findStamp(String userId, Long missionId) { - return stampRepositoryV1.findByUserIdAndMissionId(Long.valueOf(userId), missionId); - } - - @Transactional - public Stamp uploadStamp(StampRequestDto stampRequestDto, List imgPaths, String userId, - Long missionId) { - List imgList = new ArrayList<>(imgPaths); - Stamp stamp = this.convertStampImg(stampRequestDto, imgList, userId, missionId); - - //랭크 관련 점수 처리 - User user = userRepositoryV1.findUserById(Long.valueOf(userId)) - .orElseThrow(() -> new ApiException(INVALID_RESPONSE)); - - //미션 랭크점수 알아오기 - Mission mission = missionRepositoryV1.findById(missionId) - .orElseThrow(() -> new ApiException(INVALID_RESPONSE)); - - user.addPoints(mission.getLevel()); - userRepositoryV1.save(user); - - return stampRepositoryV1.save(stamp); - } - - //사진 수정 할 경우 - @Transactional - public Stamp editStampWithImg(StampRequestDto stampRequestDto, List imgPaths, - String userId, - Long missionId) { - - Stamp stamp = stampRepositoryV1.findByUserIdAndMissionId(Long.valueOf(userId), missionId); - - if (StringUtils.hasText(stampRequestDto.getContents())) { - stamp.changeContents(stampRequestDto.getContents()); - } - stamp.changeImages(imgPaths); - stamp.setUpdatedAt(LocalDateTime.now()); - - return stampRepositoryV1.save(stamp); - } - - - //사진 수정 안할 경우 - @Transactional - public Stamp editStampContents(StampRequestDto stampRequestDto, String userId, - Long missionId) { - - Stamp stamp = stampRepositoryV1.findByUserIdAndMissionId(Long.valueOf(userId), missionId); - - if (StringUtils.hasText(stampRequestDto.getContents())) { - stamp.changeContents(stampRequestDto.getContents()); - } - - stamp.setUpdatedAt(LocalDateTime.now()); - return stampRepositoryV1.save(stamp); - } - - - //Stamp 삭제 by stampId - @Transactional - public void deleteByStampId(Long stampId) { - - Stamp stamp = stampRepositoryV1.findById(stampId) - .orElseThrow(() -> new ApiException(INVALID_RESPONSE)); - - //랭크 관련 점수 처리 - User user = userRepositoryV1.findUserById(stamp.getUserId()) - .orElseThrow(() -> new ApiException(INVALID_RESPONSE)); - - //미션 랭크점수 알아오기 - Mission mission = missionRepositoryV1.findById(stamp.getMissionId()) - .orElseThrow(() -> new ApiException(INVALID_RESPONSE)); - - user.minusPoints(mission.getLevel()); - userRepositoryV1.save(user); - - stampRepositoryV1.deleteById(stampId); - } - - - //스탬프 중복 검사체크 - @Transactional - public void checkDuplicateStamp(String userId, Long missionId) { - Stamp stamp = stampRepositoryV1.findByUserIdAndMissionId(Long.valueOf(userId), missionId); - - if (stamp != null) { - throw new ApiException(DUPLICATE_STAMP); - } - } - - - //Stamp 삭제 All by UserId - @Transactional - public void deleteStampByUserId(Long userId) { - - //스탬프 전부삭제 - stampRepositoryV1.deleteAllByUserId(userId); - - //해당 스탬프로 얻었던 점수 모두 초기화 - User user = userRepositoryV1.findUserById(userId) - .orElseThrow(() -> new ApiException(INVALID_RESPONSE)); - user.initializePoints(); - userRepositoryV1.save(user); - - } - - - //Stamp Entity 양식에 맞게 데이터 세팅 - private Stamp convertStampImg(StampRequestDto stampRequestDto, List imgList, - String userId, Long missionId) { - return Stamp.builder() - .contents(stampRequestDto.getContents()) - .createdAt(LocalDateTime.now()) - .images(imgList) - .missionId(missionId) - .userId(Long.valueOf(userId)) - .build(); - } - -} diff --git a/src/main/java/org/sopt/app/v1/application/user/UserUseCase.java b/src/main/java/org/sopt/app/v1/application/user/UserUseCase.java deleted file mode 100644 index 72c2beec..00000000 --- a/src/main/java/org/sopt/app/v1/application/user/UserUseCase.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.sopt.app.v1.application.user; - -import org.sopt.app.domain.entity.User; -import org.sopt.app.v1.application.user.dto.LogInUserDto; -import org.sopt.app.v1.application.user.dto.SignUpUserDto; - -public interface UserUseCase { - - Long signUp(SignUpUserDto userDto); - - User logIn(LogInUserDto userDto); -} diff --git a/src/main/java/org/sopt/app/v1/application/user/UserUseCaseImpl.java b/src/main/java/org/sopt/app/v1/application/user/UserUseCaseImpl.java deleted file mode 100644 index 43bbd419..00000000 --- a/src/main/java/org/sopt/app/v1/application/user/UserUseCaseImpl.java +++ /dev/null @@ -1,36 +0,0 @@ -package org.sopt.app.v1.application.user; - -import lombok.RequiredArgsConstructor; -import org.sopt.app.common.exception.v1.UserNotFoundException; -import org.sopt.app.domain.entity.User; -import org.sopt.app.v1.application.auth.EncryptService; -import org.sopt.app.v1.application.user.dto.LogInUserDto; -import org.sopt.app.v1.application.user.dto.SignUpUserDto; -import org.sopt.app.v1.application.user.service.UserServiceV1; -import org.springframework.stereotype.Component; - -@Component -@RequiredArgsConstructor -public class UserUseCaseImpl implements UserUseCase { - - private final UserServiceV1 userServiceV1; - private final EncryptService encryptService; - - @Override - public Long signUp(SignUpUserDto userDto) { - String encodedPassword = encryptService.encode(userDto.getPassword()); - return userServiceV1.create(userDto, encodedPassword); - } - - @Override - public User logIn(LogInUserDto userDto) { - User user = userServiceV1.findUserByEmail(userDto.email()); - - boolean matches = encryptService.matches(userDto.password(), user.getPassword()); - if (!matches) { - throw new UserNotFoundException("아이디/비밀번호를 확인해주세요."); - } - - return user; - } -} diff --git a/src/main/java/org/sopt/app/v1/application/user/dto/LogInUserDto.java b/src/main/java/org/sopt/app/v1/application/user/dto/LogInUserDto.java deleted file mode 100644 index bcd6d5e3..00000000 --- a/src/main/java/org/sopt/app/v1/application/user/dto/LogInUserDto.java +++ /dev/null @@ -1,10 +0,0 @@ -package org.sopt.app.v1.application.user.dto; - - -import lombok.Builder; - -public record LogInUserDto(String email, String password) { - @Builder - public LogInUserDto { - } -} diff --git a/src/main/java/org/sopt/app/v1/application/user/dto/SignUpUserDto.java b/src/main/java/org/sopt/app/v1/application/user/dto/SignUpUserDto.java deleted file mode 100644 index 25526f7d..00000000 --- a/src/main/java/org/sopt/app/v1/application/user/dto/SignUpUserDto.java +++ /dev/null @@ -1,24 +0,0 @@ -package org.sopt.app.v1.application.user.dto; - -import lombok.Builder; -import lombok.Getter; -import org.sopt.app.domain.enums.OsType; - -@Getter -public class SignUpUserDto { - - private final String nickname; - private final String email; - private final String password; - private final OsType osType; - private final String clientToken; - - @Builder - public SignUpUserDto(String nickname, String email, String password, OsType osType, String clientToken) { - this.nickname = nickname; - this.email = email; - this.password = password; - this.osType = osType; - this.clientToken = clientToken; - } -} diff --git a/src/main/java/org/sopt/app/v1/application/user/service/UserServiceV1.java b/src/main/java/org/sopt/app/v1/application/user/service/UserServiceV1.java deleted file mode 100644 index 9b50ca9a..00000000 --- a/src/main/java/org/sopt/app/v1/application/user/service/UserServiceV1.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.sopt.app.v1.application.user.service; - -import lombok.RequiredArgsConstructor; -import org.sopt.app.common.exception.v1.UserNotFoundException; -import org.sopt.app.domain.entity.User; -import org.sopt.app.v1.application.user.dto.SignUpUserDto; -import org.sopt.app.v1.interfaces.postgres.UserRepositoryV1; -import org.springframework.stereotype.Service; - -@Service -@RequiredArgsConstructor -public class UserServiceV1 { - - private final UserRepositoryV1 userRepositoryV1; - - public Long create(SignUpUserDto userDto, String password) { - User user = userRepositoryV1.save(User.builder() - .username("") - .nickname(userDto.getNickname()) - .email(userDto.getEmail()) - .password(password) - .osType(null) - .points(0L) - .clientToken(userDto.getClientToken()) - .build()); - - return user.getId(); - } - - public User findUserByEmail(String email) throws UserNotFoundException { - return userRepositoryV1.findUserByEmail(email) - .orElseThrow(() -> new UserNotFoundException("아이디/비밀번호를 확인해주세요.")); - } -} diff --git a/src/main/java/org/sopt/app/v1/interfaces/postgres/MissionRepositoryV1.java b/src/main/java/org/sopt/app/v1/interfaces/postgres/MissionRepositoryV1.java deleted file mode 100644 index e4f8add5..00000000 --- a/src/main/java/org/sopt/app/v1/interfaces/postgres/MissionRepositoryV1.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.sopt.app.v1.interfaces.postgres; - -import java.util.List; -import org.sopt.app.domain.entity.Mission; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.data.jpa.repository.Query; -import org.springframework.data.repository.query.Param; - -public interface MissionRepositoryV1 extends JpaRepository { - - @Query("select m from Mission m where m.id in :missions") - List findMissionIn(@Param("missions") List missions); - -} diff --git a/src/main/java/org/sopt/app/v1/interfaces/postgres/StampRepositoryV1.java b/src/main/java/org/sopt/app/v1/interfaces/postgres/StampRepositoryV1.java deleted file mode 100644 index 27c35a54..00000000 --- a/src/main/java/org/sopt/app/v1/interfaces/postgres/StampRepositoryV1.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.sopt.app.v1.interfaces.postgres; - -import java.util.List; -import org.sopt.app.domain.entity.Stamp; -import org.springframework.data.jpa.repository.JpaRepository; - -public interface StampRepositoryV1 extends JpaRepository { - - List findAllByUserId(Long userId); - - Stamp findByUserIdAndMissionId(Long userId, Long missionId); - - void deleteAllByUserId(Long userId); - -} diff --git a/src/main/java/org/sopt/app/v1/interfaces/postgres/UserRepositoryV1.java b/src/main/java/org/sopt/app/v1/interfaces/postgres/UserRepositoryV1.java deleted file mode 100644 index 95061450..00000000 --- a/src/main/java/org/sopt/app/v1/interfaces/postgres/UserRepositoryV1.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.sopt.app.v1.interfaces.postgres; - -import java.util.Optional; -import org.sopt.app.domain.entity.User; -import org.springframework.data.jpa.repository.JpaRepository; - -public interface UserRepositoryV1 extends JpaRepository { - - Optional findUserByEmail(String email); - - Optional findUserByNickname(String nickname); - - Optional findUserById(Long userId); -} diff --git a/src/main/java/org/sopt/app/v1/presentation/BaseController.java b/src/main/java/org/sopt/app/v1/presentation/BaseController.java deleted file mode 100644 index e1420082..00000000 --- a/src/main/java/org/sopt/app/v1/presentation/BaseController.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.sopt.app.v1.presentation; - -import static org.sopt.app.common.ResponseCode.SUCCESS; -import static org.sopt.app.common.constants.Constants.RESULT_CODE; - -import java.nio.charset.StandardCharsets; -import lombok.AllArgsConstructor; -import org.springframework.http.HttpHeaders; -import org.springframework.http.MediaType; -import org.springframework.stereotype.Controller; - - -@Controller -@AllArgsConstructor -public class BaseController { - - protected HttpHeaders getSuccessHeaders() { - HttpHeaders headers = new HttpHeaders(); - headers.setContentType(new MediaType("application", "json", StandardCharsets.UTF_8)); - headers.set(RESULT_CODE, SUCCESS.getResponseCode()); - return headers; - } -} diff --git a/src/main/java/org/sopt/app/v1/presentation/auth/AuthControllerV1.java b/src/main/java/org/sopt/app/v1/presentation/auth/AuthControllerV1.java deleted file mode 100644 index 136a38d1..00000000 --- a/src/main/java/org/sopt/app/v1/presentation/auth/AuthControllerV1.java +++ /dev/null @@ -1,64 +0,0 @@ -package org.sopt.app.v1.presentation.auth; - - -import lombok.RequiredArgsConstructor; -import org.sopt.app.v1.application.auth.AuthUseCaseImpl; -import org.sopt.app.v1.presentation.auth.dto.ChangeNicknameRequestDto; -import org.sopt.app.v1.presentation.auth.dto.ChangePasswordRequestDto; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PatchMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -@RestController -@RequiredArgsConstructor -public class AuthControllerV1 { - - private final AuthUseCaseImpl authUseCase; - - /** - * 닉네임, 이메일 검증 API - */ - @GetMapping(value = "/api/v1/auth") - public void check(@RequestParam(value = "nickname", required = false) String nickname, - @RequestParam(value = "email", required = false) String email) { - authUseCase.validate(nickname, email); - } - - /** - * 비밀번호 변경 - */ - - @PatchMapping(value = "/api/v1/auth/password") - public void changePassword( - @RequestHeader(name = "userId") String userId, - @RequestBody ChangePasswordRequestDto changePasswordRequestDto - ) { - authUseCase.changePassword(userId, changePasswordRequestDto.getPassword()); - } - - /** - * 닉네임 변경 - */ - @PatchMapping(value = "/api/v1/auth/nickname") - public void changeNickname( - @RequestHeader(name = "userId") String userId, - @RequestBody ChangeNicknameRequestDto changeNicknameRequestDto - ) { - String nickname = changeNicknameRequestDto.getNickname(); - authUseCase.changeNickname(userId, nickname); - } - - /** - * 탈퇴하기 - */ - @DeleteMapping(value = "/api/v1/auth/withdraw") - public void withdraw( - @RequestHeader(name = "userId") String userId - ) { - authUseCase.deleteUser(userId); - } -} \ No newline at end of file diff --git a/src/main/java/org/sopt/app/v1/presentation/auth/dto/ChangeNicknameRequestDto.java b/src/main/java/org/sopt/app/v1/presentation/auth/dto/ChangeNicknameRequestDto.java deleted file mode 100644 index 1630088f..00000000 --- a/src/main/java/org/sopt/app/v1/presentation/auth/dto/ChangeNicknameRequestDto.java +++ /dev/null @@ -1,16 +0,0 @@ -package org.sopt.app.v1.presentation.auth.dto; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; - -@Getter -@AllArgsConstructor -@NoArgsConstructor -@Builder -public class ChangeNicknameRequestDto { - - private String nickname; - -} diff --git a/src/main/java/org/sopt/app/v1/presentation/auth/dto/ChangePasswordRequestDto.java b/src/main/java/org/sopt/app/v1/presentation/auth/dto/ChangePasswordRequestDto.java deleted file mode 100644 index ee796a70..00000000 --- a/src/main/java/org/sopt/app/v1/presentation/auth/dto/ChangePasswordRequestDto.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.sopt.app.v1.presentation.auth.dto; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; - -@Getter -@AllArgsConstructor -@NoArgsConstructor -@Builder -public class ChangePasswordRequestDto { - String password; -} diff --git a/src/main/java/org/sopt/app/v1/presentation/firebase/FirebaseControllerV1.java b/src/main/java/org/sopt/app/v1/presentation/firebase/FirebaseControllerV1.java deleted file mode 100644 index 4c0027aa..00000000 --- a/src/main/java/org/sopt/app/v1/presentation/firebase/FirebaseControllerV1.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.sopt.app.v1.presentation.firebase; - - -import lombok.RequiredArgsConstructor; -import org.sopt.app.v1.presentation.firebase.dto.FirebaseResponseDto; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -@RequiredArgsConstructor -public class FirebaseControllerV1 { - - - /** - * firebase 연동을 위한 정보 GET - * - * @return - */ - @GetMapping(value = "/api/v1/firebase") - public FirebaseResponseDto getfirebaseInfo() { - - return FirebaseResponseDto.builder() - .iosForceUpdateVersion("1.0.0") - .iosAppVersion("1.0.2") - .androidForceUpdateVersion("1.0.0") - .androidAppVersion("1.0.0") - .notice("안녕하세요, makers입니다. \n 현재 미션 수정/등록이 불가능한 이슈가 확인되어 원인 파악 중에 있습니다. \n 앱 이용에 불편을 드린 점 죄송합니다. \n 빠른 시일 내 복구 후 재공지 드리겠습니다.") - .imgUrl(null) - .build(); - } -} diff --git a/src/main/java/org/sopt/app/v1/presentation/firebase/dto/FirebaseResponseDto.java b/src/main/java/org/sopt/app/v1/presentation/firebase/dto/FirebaseResponseDto.java deleted file mode 100644 index af7e00b1..00000000 --- a/src/main/java/org/sopt/app/v1/presentation/firebase/dto/FirebaseResponseDto.java +++ /dev/null @@ -1,33 +0,0 @@ -package org.sopt.app.v1.presentation.firebase.dto; - - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; - -@Getter -@AllArgsConstructor -@NoArgsConstructor -@Builder -public class FirebaseResponseDto { - - @JsonProperty("iOS_force_update_version") - private String iosForceUpdateVersion; - - @JsonProperty( "iOS_app_version") - private String iosAppVersion; - - @JsonProperty("android_force_update_version") - private String androidForceUpdateVersion; - - @JsonProperty( "android_app_version") - private String androidAppVersion; - - private String notice; - - @JsonProperty("img_url") - private String imgUrl; - -} diff --git a/src/main/java/org/sopt/app/v1/presentation/mission/MissionControllerV1.java b/src/main/java/org/sopt/app/v1/presentation/mission/MissionControllerV1.java deleted file mode 100644 index 2f920b57..00000000 --- a/src/main/java/org/sopt/app/v1/presentation/mission/MissionControllerV1.java +++ /dev/null @@ -1,95 +0,0 @@ -package org.sopt.app.v1.presentation.mission; - - -import java.util.List; -import lombok.AllArgsConstructor; -import org.sopt.app.application.s3.S3Service; -import org.sopt.app.domain.entity.Mission; -import org.sopt.app.v1.application.mission.MissionServiceV1; -import org.sopt.app.v1.presentation.BaseController; -import org.sopt.app.v1.presentation.mission.dto.MissionRequestDto; -import org.sopt.app.v1.presentation.mission.dto.MissionResponseDto; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestPart; -import org.springframework.web.bind.annotation.ResponseBody; -import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.multipart.MultipartFile; - -@RestController -@AllArgsConstructor -@RequestMapping("/api/v1/mission") -public class MissionControllerV1 extends BaseController { - - private final MissionServiceV1 missionServiceV1; - private final S3Service s3Service; - - - /** - * 전체 mission 조회하기 - */ - @GetMapping(value = "/all") - @ResponseBody - public ResponseEntity findAllMission(@RequestHeader("userId") String userId) { - return new ResponseEntity<>(missionServiceV1.findAllMission(userId), getSuccessHeaders(), - HttpStatus.OK); - } - - - /** - * 미션 업로드 하기 - */ - @PostMapping() - public ResponseEntity uploadMission( - @RequestPart("missionContent") MissionRequestDto missionRequestDto, - @RequestPart(name = "imgUrl", required = false) List multipartFiles) { - - //MultipartFile을 리스트에 넣어줬기 때문에 List 내부의 이미지파일에 isEmpty()를 적용해야 한다. - int checkNum = 1; - for (MultipartFile image : multipartFiles) { - if (image.isEmpty()) { - checkNum = 0; - } - } - - MissionResponseDto result = MissionResponseDto.builder().build(); - if (checkNum == 0) { - Mission mission = missionServiceV1.uploadMission(missionRequestDto); - result.setMissionId(mission.getId()); - } else { - List imgPaths = s3Service.uploadDeprecated(multipartFiles); - Mission uploadMissionWithImg = missionServiceV1.uploadMissionWithImg(missionRequestDto, - imgPaths); - result.setMissionId(uploadMissionWithImg.getId()); - } - - return new ResponseEntity<>(result, getSuccessHeaders(), HttpStatus.OK); - } - - - /** - * 완료 미션만 조회하기 - */ - @GetMapping("complete") - public ResponseEntity findCompleteMission(@RequestHeader("userId") String userId) { - - List resultMission = missionServiceV1.getCompleteMission(userId); - - return new ResponseEntity<>(resultMission, getSuccessHeaders(), HttpStatus.OK); - } - - /** - * 미완료 미션만 조회하기 - */ - @GetMapping("incomplete") - public ResponseEntity findInCompleteMission(@RequestHeader("userId") String userId) { - List resultMission = missionServiceV1.getIncompleteMission(userId); - - return new ResponseEntity<>(resultMission, getSuccessHeaders(), HttpStatus.OK); - } - -} diff --git a/src/main/java/org/sopt/app/v1/presentation/mission/dto/GetAllMissionResponseDto.java b/src/main/java/org/sopt/app/v1/presentation/mission/dto/GetAllMissionResponseDto.java deleted file mode 100644 index d0d46948..00000000 --- a/src/main/java/org/sopt/app/v1/presentation/mission/dto/GetAllMissionResponseDto.java +++ /dev/null @@ -1,30 +0,0 @@ -package org.sopt.app.v1.presentation.mission.dto; - -import java.util.List; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -@Getter -@Setter -@NoArgsConstructor -public class GetAllMissionResponseDto { - - private Long id; - private String title; - private Integer level; - private List profileImage; - private Boolean isCompleted; - - - @Builder - public GetAllMissionResponseDto( - Long id, String title, Integer level, List profileImage, Boolean isCompleted) { - this.id = id; - this.title = title; - this.level = level; - this.profileImage = profileImage; - this.isCompleted = isCompleted; - } -} diff --git a/src/main/java/org/sopt/app/v1/presentation/mission/dto/MissionRequestDto.java b/src/main/java/org/sopt/app/v1/presentation/mission/dto/MissionRequestDto.java deleted file mode 100644 index 8952d5ff..00000000 --- a/src/main/java/org/sopt/app/v1/presentation/mission/dto/MissionRequestDto.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.sopt.app.v1.presentation.mission.dto; - - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; - -@Getter -@Builder -@AllArgsConstructor -@NoArgsConstructor -public class MissionRequestDto { - - private String title; // 미션 제목 - private Integer level; // 미션 레벨 - -} diff --git a/src/main/java/org/sopt/app/v1/presentation/mission/dto/MissionResponseDto.java b/src/main/java/org/sopt/app/v1/presentation/mission/dto/MissionResponseDto.java deleted file mode 100644 index 4e946c51..00000000 --- a/src/main/java/org/sopt/app/v1/presentation/mission/dto/MissionResponseDto.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.sopt.app.v1.presentation.mission.dto; - - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -@Getter -@Setter -@Builder -@AllArgsConstructor -@NoArgsConstructor -public class MissionResponseDto { - - private Long missionId; - -} diff --git a/src/main/java/org/sopt/app/v1/presentation/rank/RankControllerV1.java b/src/main/java/org/sopt/app/v1/presentation/rank/RankControllerV1.java deleted file mode 100644 index 38933171..00000000 --- a/src/main/java/org/sopt/app/v1/presentation/rank/RankControllerV1.java +++ /dev/null @@ -1,48 +0,0 @@ -package org.sopt.app.v1.presentation.rank; - -import java.util.List; -import lombok.RequiredArgsConstructor; -import org.sopt.app.domain.entity.User; -import org.sopt.app.v1.application.rank.RankServiceV1; -import org.sopt.app.v1.presentation.BaseController; -import org.sopt.app.v1.presentation.rank.dto.FindAllRanksResponseDto; -import org.sopt.app.v1.presentation.rank.dto.FindRankResponseDto; -import org.sopt.app.v1.presentation.rank.dto.UserProfileRequestDto; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -@RequiredArgsConstructor -@RequestMapping("/api/v1/rank") -public class RankControllerV1 extends BaseController { - - private final RankServiceV1 rankServiceV1; - - /** - * 한마디 편집하기 - */ - @PostMapping("/profileMessage") - public User updateUserProfileMessage( - @RequestHeader Long userId, - @RequestBody UserProfileRequestDto userProfileRequestDto - ) { - - return rankServiceV1 - .updateProfileMessage(userId, userProfileRequestDto.getProfileMessage()); - } - - @GetMapping("") - public List findRanks() { - return rankServiceV1.findRanks(); - } - - @GetMapping("/detail") - public FindRankResponseDto findRankById( - @RequestHeader Long userId) { - return rankServiceV1.findRankById(userId); - } -} diff --git a/src/main/java/org/sopt/app/v1/presentation/rank/dto/FindAllRanksResponseDto.java b/src/main/java/org/sopt/app/v1/presentation/rank/dto/FindAllRanksResponseDto.java deleted file mode 100644 index 4af1bbb1..00000000 --- a/src/main/java/org/sopt/app/v1/presentation/rank/dto/FindAllRanksResponseDto.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.sopt.app.v1.presentation.rank.dto; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; - -@Getter -@AllArgsConstructor -@NoArgsConstructor -@Builder -public class FindAllRanksResponseDto { - private Integer rank; - private Long userId; - private String nickname; - private Long point; - - private String profileMessage; -} diff --git a/src/main/java/org/sopt/app/v1/presentation/rank/dto/FindRankResponseDto.java b/src/main/java/org/sopt/app/v1/presentation/rank/dto/FindRankResponseDto.java deleted file mode 100644 index c1df87c9..00000000 --- a/src/main/java/org/sopt/app/v1/presentation/rank/dto/FindRankResponseDto.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.sopt.app.v1.presentation.rank.dto; - -import java.util.List; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; -import org.sopt.app.domain.entity.Mission; - -@Getter -@Builder -@AllArgsConstructor -@NoArgsConstructor -public class FindRankResponseDto { - - private Long userId; - private String nickname; - private String profileMessage; - - private List userMissions; - -} diff --git a/src/main/java/org/sopt/app/v1/presentation/rank/dto/UserProfileRequestDto.java b/src/main/java/org/sopt/app/v1/presentation/rank/dto/UserProfileRequestDto.java deleted file mode 100644 index 942d0fc7..00000000 --- a/src/main/java/org/sopt/app/v1/presentation/rank/dto/UserProfileRequestDto.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.sopt.app.v1.presentation.rank.dto; - -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; - -@Getter -@NoArgsConstructor -@AllArgsConstructor -public class UserProfileRequestDto { - - private String profileMessage; - -} diff --git a/src/main/java/org/sopt/app/v1/presentation/stamp/StampControllerV1.java b/src/main/java/org/sopt/app/v1/presentation/stamp/StampControllerV1.java deleted file mode 100644 index d7c17d19..00000000 --- a/src/main/java/org/sopt/app/v1/presentation/stamp/StampControllerV1.java +++ /dev/null @@ -1,117 +0,0 @@ -package org.sopt.app.v1.presentation.stamp; - -import java.util.List; -import lombok.AllArgsConstructor; -import org.sopt.app.application.s3.S3Service; -import org.sopt.app.domain.entity.Stamp; -import org.sopt.app.v1.application.stamp.StampServiceV1; -import org.sopt.app.v1.presentation.BaseController; -import org.sopt.app.v1.presentation.stamp.dto.StampRequestDto; -import org.sopt.app.v1.presentation.stamp.dto.StampResponseDto; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestPart; -import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.multipart.MultipartFile; - -@RestController -@AllArgsConstructor -@RequestMapping("/api/v1/stamp") -public class StampControllerV1 extends BaseController { - - private final StampServiceV1 stampServiceV1; - - private final S3Service s3Service; - - - /** - * stamp 조회 missionId, userId로 stamp 조회하기 - */ - @GetMapping("/{missionId}") - public Stamp findStampByMissionAndUserId( - @RequestHeader("userId") String userId, - @PathVariable Long missionId) { - - return stampServiceV1.findStamp(userId, missionId); - } - - /** - * 미션 달성을 위해 내용을 Stamp 내용 등록 - */ - @PostMapping("/{missionId}") - public ResponseEntity uploadStamp( - @RequestHeader("userId") String userId, - @PathVariable Long missionId, - @RequestPart("stampContent") StampRequestDto stampRequestDto, - @RequestPart(name = "imgUrl", required = false) List multipartFiles - ) { - - //스탬프 중복 검사체크 - stampServiceV1.checkDuplicateStamp(userId, missionId); - - List imgPaths = s3Service.uploadDeprecated(multipartFiles); - Stamp uploadStamp = stampServiceV1.uploadStamp(stampRequestDto, - imgPaths, userId, missionId); - - return new ResponseEntity<>(uploadStamp, getSuccessHeaders(), HttpStatus.OK); - } - - - @PutMapping("/{missionId}") - public ResponseEntity editStamp( - @RequestHeader("userId") String userId, - @PathVariable Long missionId, - @RequestPart(value = "stampContent", required = false) StampRequestDto stampRequestDto, - @RequestPart(name = "imgUrl", required = false) List multipartFiles - - ) { - //MultipartFile을 리스트에 넣어줬기 때문에 List 내부의 이미지파일에 isEmpty()를 적용해야 한다. - int checkNum = 1; - for (MultipartFile image : multipartFiles) { - if (image.isEmpty()) { - checkNum = 0; - } - } - - StampResponseDto result = StampResponseDto.builder().build(); - if (checkNum == 0) { - - Stamp stamp = stampServiceV1.editStampContents(stampRequestDto, userId, missionId); - result.setStampId(stamp.getId()); - - } else { - - List imgPaths = s3Service.uploadDeprecated(multipartFiles); - Stamp uploadStamp = stampServiceV1.editStampWithImg(stampRequestDto, - imgPaths, userId, missionId); - - result.setStampId(uploadStamp.getId()); - } - return new ResponseEntity<>(result, getSuccessHeaders(), HttpStatus.OK); - } - - /** - * Stamp 개별 삭제 - */ - @DeleteMapping("/{stampId}") - public ResponseEntity deleteStampById(@PathVariable Long stampId) { - stampServiceV1.deleteByStampId(stampId); - return new ResponseEntity<>("{}", getSuccessHeaders(), HttpStatus.OK); - } - - /** - * 전체 Stamp삭제 - */ - @DeleteMapping("/all") - public ResponseEntity deleteStampByUserId(@RequestHeader Long userId) { - stampServiceV1.deleteStampByUserId(userId); - return new ResponseEntity<>("{}", getSuccessHeaders(), HttpStatus.OK); - } -} diff --git a/src/main/java/org/sopt/app/v1/presentation/stamp/dto/StampRequestDto.java b/src/main/java/org/sopt/app/v1/presentation/stamp/dto/StampRequestDto.java deleted file mode 100644 index 8ef7adef..00000000 --- a/src/main/java/org/sopt/app/v1/presentation/stamp/dto/StampRequestDto.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.sopt.app.v1.presentation.stamp.dto; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; - -@Getter -@Builder -@AllArgsConstructor -@NoArgsConstructor -public class StampRequestDto { - - private String contents; // 스탬프 내용 -} diff --git a/src/main/java/org/sopt/app/v1/presentation/stamp/dto/StampResponseDto.java b/src/main/java/org/sopt/app/v1/presentation/stamp/dto/StampResponseDto.java deleted file mode 100644 index 57fae49b..00000000 --- a/src/main/java/org/sopt/app/v1/presentation/stamp/dto/StampResponseDto.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.sopt.app.v1.presentation.stamp.dto; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -@Getter -@Setter -@Builder -@AllArgsConstructor -@NoArgsConstructor -public class StampResponseDto { - - private Long stampId; - -} diff --git a/src/main/java/org/sopt/app/v1/presentation/user/UserControllerV1.java b/src/main/java/org/sopt/app/v1/presentation/user/UserControllerV1.java deleted file mode 100644 index f61f18c2..00000000 --- a/src/main/java/org/sopt/app/v1/presentation/user/UserControllerV1.java +++ /dev/null @@ -1,56 +0,0 @@ -package org.sopt.app.v1.presentation.user; - -import javax.validation.Valid; -import lombok.RequiredArgsConstructor; -import org.sopt.app.domain.entity.User; -import org.sopt.app.v1.application.user.UserUseCase; -import org.sopt.app.v1.application.user.dto.LogInUserDto; -import org.sopt.app.v1.application.user.dto.SignUpUserDto; -import org.sopt.app.v1.presentation.user.request.LogInUserRequest; -import org.sopt.app.v1.presentation.user.response.LoginResponse; -import org.sopt.app.v1.presentation.user.response.SignUpResponse; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RestController; - -@RestController -@RequiredArgsConstructor -public class UserControllerV1 { - - private final UserUseCase userUseCase; - - /** - * 이메일 회원가입 - */ - @PostMapping(value = "/api/v1/user/signup") - public SignUpResponse signUp2(@RequestBody SignUpUserDto request) { - Long userId = userUseCase.signUp(SignUpUserDto.builder() - .nickname(request.getNickname()) - .email(request.getEmail()) - .password(request.getPassword()) - .osType(request.getOsType()) - .clientToken(request.getClientToken()) - .build()); - - return SignUpResponse.builder() - .userId(userId) - .build(); - } - - - /** - * 로그인 - */ - @PostMapping(value = "/api/v1/user/login") - public LoginResponse signIn2(@Valid @RequestBody LogInUserRequest request) { - - User user = userUseCase.logIn(LogInUserDto.builder() - .email(request.getEmail()) - .password(request.getPassword()) - .build()); - return LoginResponse.builder() - .userId(user.getId()) - .profileMessage(user.getProfileMessage()) - .build(); - } -} diff --git a/src/main/java/org/sopt/app/v1/presentation/user/request/CreateUserRequest.java b/src/main/java/org/sopt/app/v1/presentation/user/request/CreateUserRequest.java deleted file mode 100644 index 099ba336..00000000 --- a/src/main/java/org/sopt/app/v1/presentation/user/request/CreateUserRequest.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.sopt.app.v1.presentation.user.request; - -import com.sun.istack.NotNull; -import lombok.Getter; -import org.sopt.app.domain.enums.OsType; - -@Getter -public class CreateUserRequest { - - @NotNull - private String nickname; - @NotNull - private String email; - @NotNull - private String password; - private OsType osType; - private String clientToken; -} diff --git a/src/main/java/org/sopt/app/v1/presentation/user/request/LogInUserRequest.java b/src/main/java/org/sopt/app/v1/presentation/user/request/LogInUserRequest.java deleted file mode 100644 index fb6af1c7..00000000 --- a/src/main/java/org/sopt/app/v1/presentation/user/request/LogInUserRequest.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.sopt.app.v1.presentation.user.request; - -import javax.validation.constraints.NotBlank; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -@Getter -@Setter -@NoArgsConstructor -@AllArgsConstructor -public class LogInUserRequest { - - @NotBlank(message = "아이디나 비밀번호는 필수 입력 값입니다.") - private String email; - @NotBlank(message = "아이디나 비밀번호는 필수 입력 값입니다.") - private String password; -} diff --git a/src/main/java/org/sopt/app/v1/presentation/user/response/LoginResponse.java b/src/main/java/org/sopt/app/v1/presentation/user/response/LoginResponse.java deleted file mode 100644 index 2ffb719d..00000000 --- a/src/main/java/org/sopt/app/v1/presentation/user/response/LoginResponse.java +++ /dev/null @@ -1,16 +0,0 @@ -package org.sopt.app.v1.presentation.user.response; - -import lombok.Builder; -import lombok.Getter; - -@Getter -public class LoginResponse { - private Long userId; - private String profileMessage; - - @Builder - public LoginResponse(Long userId, String profileMessage) { - this.userId = userId; - this.profileMessage = profileMessage; - } -} diff --git a/src/main/java/org/sopt/app/v1/presentation/user/response/SignUpResponse.java b/src/main/java/org/sopt/app/v1/presentation/user/response/SignUpResponse.java deleted file mode 100644 index e4245b98..00000000 --- a/src/main/java/org/sopt/app/v1/presentation/user/response/SignUpResponse.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.sopt.app.v1.presentation.user.response; - -import lombok.Builder; -import lombok.Getter; -import lombok.Setter; - -@Getter -@Builder -@Setter -public class SignUpResponse { - - private Long userId; - - -} From 58e435ee1edbedd1eca337be168cb999c407937e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A3=BC=EC=96=B4=EB=9E=91?= <63996052+ozzing@users.noreply.github.com> Date: Mon, 5 Jun 2023 22:40:45 +0900 Subject: [PATCH 2/3] =?UTF-8?q?2=EA=B8=B0=20=EC=9D=B8=EC=88=98=EC=9D=B8?= =?UTF-8?q?=EA=B3=84=20README=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 91 +++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 71 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index fb773c3c..18430a06 100644 --- a/README.md +++ b/README.md @@ -2,36 +2,87 @@ > 🚀 SOPT 공식 앱으로, 출석/공지/네트워킹 미션 등 다양한 기능을 제공합니다. -## 1.솝탬프 : 네트워킹 미션 +![image](https://github.com/sopt-makers/sopt-backend/assets/63996052/e00e6014-04c4-4da5-81ec-85ab6b2a270b) + +# PRODUCT +### [1기] 솝탬프 : 네트워킹 미션 솝트 네트워킹을 활성화시키기 위해 스탬프 미션 및 인증 플랫폼 제공 스크린샷 2023-03-03 오전 12 34 02 +### [2기] 공식앱 : 출석/공지/메이커스 -## 2. 프로젝트 설치 -- java version: 17 -- springboot: 2.7.4 (3점대로 올리는 것 추천) - -### Quick start -> local 에서 docker postgres 를 우선 실행해야합니다. [ wiki 참고 ](https://github.com/sopt-makers/app-server/wiki/Local에서-Docker-postgres-실행하는-법) -``` -git clone https://github.com/sopt-makers/app-server.git - -./gradlew clean build +활동 기수를 위한 출석/공지 기능과 메이커스 프로덕트 링크 제공 -java -jar -Dspring.profiles.active=local build/libs/app-server-0.0.1-SNAPSHOT.jar +스크린샷 2023-03-03 오전 12 34 02 -``` -http://localhost:8080 으로 접속 가능합니다. +# PROJECT +- java version: 17 +- springboot: 2.7.4 -## 3. 부록 +# DEPLOY +- [local] deploy + - docker postgres 실행 + - git clone https://github.com/sopt-makers/app-server.git (최초 실행) + - ./gradlew clean build + - java -jar -Dspring.profiles.active=local build/libs/app-server-0.0.1-SNAPSHOT.jar + - http://localhost:8080 +- [dev] deploy + - dev 서버 접속 + - git pull origin dev + - ./gradlew clean build + - java -jar -Dspring.profiles.active=local build/libs/app-server-0.0.1-SNAPSHOT.jar + - https://app.dev.sopt.org +- [main] github actions + - 배포 조건: main branch에 merge 되거나, makers-app-develop 태그 빌드하는 경우
+ - gradle build -> s3 에 jar 업로드 -> codedeploy 배포 + - https://app.sopt.org -3-1. github actions +# FOLDERING -배포 조건: main branch에 merge 되거나, makers-app-develop 태그 빌드하는 경우
-- gradle build -> s3 에 jar 업로드 -> codedeploy 배포 +```tsx +app-server +│ .gitignore +│ appspec.yml +│ build.gradle +│ gradlew +│ gradlew.bat +│ README.md +│ settings.gradle +│ +└─src/main + │ + ├─java/org/sopt/app + │ │ AppApplication + │ ├─application + │ ├─common + │ ├─domain + │ ├─interfaces.postgres + │ └─presentation + │ + └─resources + │ application.yml + │ application-local.yml + │ application-prod.yml + └─database +``` -3-2. API 문서 [바로가기](https://parangjy.notion.site/166132ae964d4bc483c71e507497bb9c) +# SECRETS +- 인수인계 담당자에게 아래 항목들을 요청해주세요! (2기 [ozzing](https://github.com/ozzing)) + - application-prod.yml + - application-local.yml + - main database info + - dev database info + - makers.app.pem key +- AWS 관련 권한은 현 기수 AWS 담당자에게 적절한 권한을 요청해주세요! + - ex) s3 access key, secret key +- 이 외에도 필요한 항목이 있으면 요청해주세요! -3-3. 유스케이스 [바로가기](https://github.com/sopt-makers/app-server/wiki/솝탬프-프로젝트-유스케이스) \ No newline at end of file +# ETC +- Playground OAuth [바로가기](https://www.notion.so/parangjy/3596d3abc6304004a07d1fc79981d8bc) +- docker postgres 실행 방법 [바로가기](https://github.com/sopt-makers/app-server/wiki/Local에서-Docker-postgres-실행하는-법) +- 2기 Swagger [바로가기](https://app.dev.sopt.org/swagger-ui/index.html) +- 2기 API 문서 [바로가기](https://parangjy.notion.site/3278da92a8f646aea4eba1d0f5a45f43?v=15ca2103aaec4bbaaaea7808c872484c) +- 1기 솝탬프 유스케이스 [바로가기](https://github.com/sopt-makers/app-server/wiki/솝탬프-프로젝트-유스케이스) +- 1기 API 문서 [바로가기](https://parangjy.notion.site/166132ae964d4bc483c71e507497bb9c) From f23f0ea5b3f5441afaf731272d3c0180185d1074 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A3=BC=EC=96=B4=EB=9E=91?= <63996052+ozzing@users.noreply.github.com> Date: Tue, 6 Jun 2023 00:42:47 +0900 Subject: [PATCH 3/3] Update README.md --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 18430a06..550eab9c 100644 --- a/README.md +++ b/README.md @@ -72,9 +72,10 @@ app-server - 인수인계 담당자에게 아래 항목들을 요청해주세요! (2기 [ozzing](https://github.com/ozzing)) - application-prod.yml - application-local.yml - - main database info + - prod database info - dev database info - - makers.app.pem key + - prod pem key + - dev pem key - AWS 관련 권한은 현 기수 AWS 담당자에게 적절한 권한을 요청해주세요! - ex) s3 access key, secret key - 이 외에도 필요한 항목이 있으면 요청해주세요!