diff --git a/README.md b/README.md index fb773c3c..550eab9c 100644 --- a/README.md +++ b/README.md @@ -2,36 +2,88 @@ > ๐Ÿš€ 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 + - prod database info + - dev database info + - prod pem key + - dev 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) 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; - - -}