Skip to content

Commit

Permalink
Merge pull request #324 from Team-Sopetit/refactor/#320-erd-architecture
Browse files Browse the repository at this point in the history
[REFACTOR] ERD/Architecture 리팩토링
  • Loading branch information
thguss authored Aug 23, 2024
2 parents 90b4203 + 9d2d530 commit c4819ec
Show file tree
Hide file tree
Showing 334 changed files with 3,941 additions and 8,297 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.soptie.server.common.config;
package com.soptie.server.api.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
Expand All @@ -11,8 +11,8 @@
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;

import com.soptie.server.auth.jwt.CustomJwtAuthenticationEntryPoint;
import com.soptie.server.auth.jwt.JwtAuthenticationFilter;
import com.soptie.server.api.web.jwt.CustomJwtAuthenticationEntryPoint;
import com.soptie.server.api.web.jwt.JwtAuthenticationFilter;

import lombok.RequiredArgsConstructor;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.soptie.server.common.config;
package com.soptie.server.api.config;

import static io.swagger.v3.oas.models.security.SecurityScheme.Type.*;

Expand Down
66 changes: 66 additions & 0 deletions src/main/java/com/soptie/server/api/controller/AuthApi.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package com.soptie.server.api.controller;

import java.security.Principal;

import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.DeleteMapping;
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.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;

import com.soptie.server.api.controller.docs.AuthApiDocs;
import com.soptie.server.api.controller.dto.request.auth.SignInRequest;
import com.soptie.server.api.controller.dto.response.SuccessResponse;
import com.soptie.server.api.controller.dto.response.auth.SignInResponse;
import com.soptie.server.api.controller.dto.response.auth.TokenGetResponse;
import com.soptie.server.api.controller.generic.SuccessMessage;
import com.soptie.server.domain.auth.AuthService;

import lombok.RequiredArgsConstructor;
import lombok.val;

@RestController
@RequiredArgsConstructor
@RequestMapping("/api/v1/auth")
public class AuthApi implements AuthApiDocs {

private final AuthService authService;

@ResponseStatus(HttpStatus.OK)
@PostMapping
public SuccessResponse<SignInResponse> signIn(
@RequestHeader("Authorization") String socialAccessToken,
@RequestBody SignInRequest request
) {
val response = authService.signIn(socialAccessToken, request);
return SuccessResponse.success(SuccessMessage.SUCCESS_SIGN_IN.getMessage(), response);
}

@ResponseStatus(HttpStatus.OK)
@PostMapping("/token")
public SuccessResponse<TokenGetResponse> reissueToken(
@RequestHeader("Authorization") String refreshToken
) {
val response = authService.reissueToken(refreshToken);
return SuccessResponse.success(SuccessMessage.SUCCESS_RECREATE_TOKEN.getMessage(), response);
}

@ResponseStatus(HttpStatus.OK)
@PostMapping("/logout")
public SuccessResponse<?> signOut(Principal principal) {
val memberId = Long.parseLong(principal.getName());
authService.signOut(memberId);
return SuccessResponse.success(SuccessMessage.SUCCESS_SIGN_OUT.getMessage());
}

@ResponseStatus(HttpStatus.OK)
@DeleteMapping
public SuccessResponse<?> withdrawal(Principal principal) {
val memberId = Long.parseLong(principal.getName());
authService.withdraw(memberId);
return SuccessResponse.success(SuccessMessage.SUCCESS_WITHDRAWAL.getMessage());
}
}
37 changes: 37 additions & 0 deletions src/main/java/com/soptie/server/api/controller/ChallengeApi.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.soptie.server.api.controller;

import java.security.Principal;

import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;

import com.soptie.server.api.controller.docs.ChallengeApiDocs;
import com.soptie.server.api.controller.dto.response.SuccessResponse;
import com.soptie.server.api.controller.dto.response.challenge.GetChallengesByMemberResponse;
import com.soptie.server.api.controller.generic.SuccessMessage;
import com.soptie.server.domain.challenge.ChallengeService;

import lombok.RequiredArgsConstructor;
import lombok.val;

@RestController
@RequiredArgsConstructor
@RequestMapping("/api/v2/routines/challenge")
public class ChallengeApi implements ChallengeApiDocs {
private final ChallengeService challengeService;

@ResponseStatus(HttpStatus.OK)
@GetMapping
public SuccessResponse<GetChallengesByMemberResponse> getChallengesByTheme(
Principal principal,
@RequestParam long themeId
) {
val memberId = Long.parseLong(principal.getName());
val response = challengeService.getChallengesByTheme(memberId, themeId);
return SuccessResponse.success(SuccessMessage.GET_CHALLENGE.getMessage(), response);
}
}
32 changes: 32 additions & 0 deletions src/main/java/com/soptie/server/api/controller/MakerApi.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.soptie.server.api.controller;

import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;

import com.soptie.server.api.controller.docs.MakerApiDocs;
import com.soptie.server.api.controller.dto.response.SuccessResponse;
import com.soptie.server.api.controller.dto.response.maker.GetMakerListResponse;
import com.soptie.server.api.controller.generic.SuccessMessage;
import com.soptie.server.domain.maker.MakerService;

import lombok.RequiredArgsConstructor;
import lombok.val;

@RestController
@RequiredArgsConstructor
@RequestMapping("/api/v2/makers")
public class MakerApi implements MakerApiDocs {

private final MakerService makerService;

@Override
@GetMapping
@ResponseStatus(HttpStatus.OK)
public SuccessResponse<GetMakerListResponse> acquireAll() {
val response = makerService.acquireAll();
return SuccessResponse.success(SuccessMessage.SUCCESS_GET_MAKER_THEME.getMessage(), response);
}
}
63 changes: 63 additions & 0 deletions src/main/java/com/soptie/server/api/controller/MemberApi.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package com.soptie.server.api.controller;

import java.security.Principal;

import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;

import com.soptie.server.api.controller.docs.MemberApiDocs;
import com.soptie.server.api.controller.dto.request.member.CreateProfileRequest;
import com.soptie.server.api.controller.dto.response.SuccessResponse;
import com.soptie.server.api.controller.dto.response.member.GetHomeInfoResponse;
import com.soptie.server.api.controller.dto.response.member.GiveMemberCottonResponse;
import com.soptie.server.api.controller.generic.SuccessMessage;
import com.soptie.server.domain.member.CottonType;
import com.soptie.server.domain.member.MemberService;

import lombok.RequiredArgsConstructor;
import lombok.val;

@RestController
@RequiredArgsConstructor
@RequestMapping("/api/v1/members")
public class MemberApi implements MemberApiDocs {

private final MemberService memberService;

@ResponseStatus(HttpStatus.CREATED)
@PostMapping
public SuccessResponse<?> createMemberProfile(
Principal principal,
@RequestBody CreateProfileRequest request
) {
val memberId = Long.parseLong(principal.getName());
memberService.createMemberProfile(memberId, request);
return SuccessResponse.success(SuccessMessage.CREATE_MEMBER_PROFILE.getMessage());
}

@ResponseStatus(HttpStatus.OK)
@PatchMapping("/cotton/{cottonType}")
public SuccessResponse<GiveMemberCottonResponse> giveCotton(
Principal principal,
@PathVariable CottonType cottonType
) {
val memberId = Long.parseLong(principal.getName());
val response = memberService.giveCotton(memberId, cottonType);
return SuccessResponse.success(SuccessMessage.GIVE_COTTON.getMessage(), response);
}

@ResponseStatus(HttpStatus.OK)
@GetMapping
public SuccessResponse<GetHomeInfoResponse> getMemberHomeInfo(Principal principal) {
val memberId = Long.parseLong(principal.getName());
val response = memberService.getMemberHomeInfo(memberId);
return SuccessResponse.success(SuccessMessage.GET_MEMBER_HOME.getMessage(), response);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package com.soptie.server.api.controller;

import java.security.Principal;

import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;

import com.soptie.server.api.controller.docs.MemberMissionApiDocs;
import com.soptie.server.api.controller.dto.request.membermission.CreateMemberMissionRequest;
import com.soptie.server.api.controller.dto.response.SuccessResponse;
import com.soptie.server.api.controller.dto.response.membermission.CreateMemberMissionResponse;
import com.soptie.server.api.controller.generic.SuccessMessage;
import com.soptie.server.domain.membermission.MemberMissionService;

import lombok.RequiredArgsConstructor;
import lombok.val;

@RestController
@RequiredArgsConstructor
@RequestMapping("/api/v1/routines/happiness/member")
public class MemberMissionApi implements MemberMissionApiDocs {
private final MemberMissionService memberMissionService;

@ResponseStatus(HttpStatus.CREATED)
@PostMapping
public SuccessResponse<CreateMemberMissionResponse> createMemberMission(
Principal principal,
@RequestBody CreateMemberMissionRequest request
) {
val memberId = Long.parseLong(principal.getName());
val response = memberMissionService.createMemberMission(memberId, request);
return SuccessResponse.success(SuccessMessage.CREATE_ROUTINE.getMessage(), response);
}

@ResponseStatus(HttpStatus.OK)
@DeleteMapping("/routine/{routineId}")
public SuccessResponse<?> deleteMemberMission(Principal principal, @PathVariable long routineId) {
val memberId = Long.parseLong(principal.getName());
memberMissionService.deleteMemberMission(memberId, routineId);
return SuccessResponse.success(SuccessMessage.DELETE_ROUTINE.getMessage());
}

@ResponseStatus(HttpStatus.OK)
@PatchMapping("/routine/{routineId}")
public SuccessResponse<?> achieveMemberMission(Principal principal, @PathVariable long routineId) {
val memberId = Long.parseLong(principal.getName());
memberMissionService.achieveMemberMission(memberId, routineId);
return SuccessResponse.success(SuccessMessage.ACHIEVE_ROUTINE.getMessage());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.soptie.server.api.controller;

import java.security.Principal;

import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.soptie.server.api.controller.docs.MemberMissionApiV2Docs;
import com.soptie.server.api.controller.dto.response.SuccessResponse;
import com.soptie.server.api.controller.generic.SuccessMessage;
import com.soptie.server.domain.membermission.MemberMissionService;

import lombok.RequiredArgsConstructor;
import lombok.val;

@RestController
@RequiredArgsConstructor
@RequestMapping("/api/v2/routines/challenge/member")
public class MemberMissionApiV2 implements MemberMissionApiV2Docs {
private final MemberMissionService memberMissionService;

@GetMapping
public ResponseEntity<?> getMemberMission(Principal principal) {
val memberId = Long.parseLong(principal.getName());
return memberMissionService.getMemberMission(memberId)
.map(response ->
ResponseEntity.ok(SuccessResponse.success(SuccessMessage.GET_ROUTINE.getMessage(), response)))
.orElseGet(() -> ResponseEntity.noContent().build());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package com.soptie.server.api.controller;

import java.security.Principal;
import java.util.List;

import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;

import com.soptie.server.api.controller.docs.MemberRoutineApiDocs;
import com.soptie.server.api.controller.dto.response.SuccessResponse;
import com.soptie.server.api.controller.dto.response.memberroutine.AchieveMemberRoutineResponse;
import com.soptie.server.api.controller.generic.SuccessMessage;
import com.soptie.server.domain.memberroutine.MemberRoutineService;

import lombok.RequiredArgsConstructor;
import lombok.val;

@RestController
@RequiredArgsConstructor
@RequestMapping("/api/v1/routines/daily/member")
public class MemberRoutineApi implements MemberRoutineApiDocs {
private final MemberRoutineService memberRoutineService;

@ResponseStatus(HttpStatus.OK)
@DeleteMapping
public SuccessResponse<?> deleteMemberRoutines(
Principal principal,
@RequestParam List<Long> routines
) {
val memberId = Long.parseLong(principal.getName());
memberRoutineService.deleteMemberRoutines(memberId, routines);
return SuccessResponse.success(SuccessMessage.DELETE_ROUTINE.getMessage());
}

@ResponseStatus(HttpStatus.OK)
@PatchMapping("/routine/{routineId}")
public SuccessResponse<AchieveMemberRoutineResponse> achieveMemberRoutine(
Principal principal,
@PathVariable long routineId
) {
val memberId = Long.parseLong(principal.getName());
val response = memberRoutineService.achieveMemberRoutine(memberId, routineId);
return SuccessResponse.success(SuccessMessage.ACHIEVE_ROUTINE.getMessage(), response);
}
}
Loading

0 comments on commit c4819ec

Please sign in to comment.