-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from WE-ARE-RACCOONS/RAC-78
RAC-78 feat: νμκ°μ λ° λ‘κ·ΈμΈ
- Loading branch information
Showing
18 changed files
with
323 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
src/main/java/com/postgraduate/domain/senior/application/dto/req/SeniorProfileRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.postgraduate.domain.senior.application.dto.req; | ||
|
||
import jakarta.validation.constraints.NotNull; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class SeniorProfileRequest { | ||
@NotNull | ||
private String info; | ||
@NotNull | ||
private String target; | ||
@NotNull | ||
private String chatLink; | ||
@NotNull | ||
private String time; | ||
@NotNull | ||
private int term; | ||
} |
32 changes: 32 additions & 0 deletions
32
src/main/java/com/postgraduate/domain/senior/application/dto/req/SeniorSignUpRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.postgraduate.domain.senior.application.dto.req; | ||
|
||
import jakarta.validation.constraints.NotNull; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class SeniorSignUpRequest { | ||
@NotNull | ||
private String college; | ||
@NotNull | ||
private String major; | ||
@NotNull | ||
private String postgradu; | ||
@NotNull | ||
private String professor; | ||
@NotNull | ||
private String lab; | ||
@NotNull | ||
private String field; | ||
@NotNull | ||
private String certification; | ||
@NotNull | ||
private String account; | ||
@NotNull | ||
private String bank; | ||
@NotNull | ||
private String rrn; | ||
} |
24 changes: 24 additions & 0 deletions
24
src/main/java/com/postgraduate/domain/senior/application/mapper/SeniorMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.postgraduate.domain.senior.application.mapper; | ||
|
||
import com.postgraduate.domain.senior.application.dto.req.SeniorSignUpRequest; | ||
import com.postgraduate.domain.senior.domain.entity.Senior; | ||
import com.postgraduate.domain.user.domain.entity.User; | ||
|
||
public class SeniorMapper { | ||
|
||
public static Senior mapToSenior(User user, SeniorSignUpRequest request) { | ||
return Senior.builder() | ||
.user(user) | ||
.college(request.getCollege()) | ||
.major(request.getMajor()) | ||
.postgradu(request.getPostgradu()) | ||
.professor(request.getProfessor()) | ||
.lab(request.getLab()) | ||
.field(request.getField()) | ||
.certification(request.getCertification()) | ||
.account(request.getAccount()) | ||
.bank(request.getBank()) | ||
.rrn(request.getRrn()) | ||
.build(); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
src/main/java/com/postgraduate/domain/senior/application/usecase/SeniorSignUpUseCase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.postgraduate.domain.senior.application.usecase; | ||
|
||
import com.postgraduate.domain.senior.application.dto.req.SeniorSignUpRequest; | ||
import com.postgraduate.domain.senior.domain.service.SeniorSaveService; | ||
import com.postgraduate.domain.user.domain.entity.User; | ||
import com.postgraduate.domain.user.domain.entity.constant.Role; | ||
import com.postgraduate.domain.user.domain.service.UserUpdateService; | ||
import com.postgraduate.global.auth.AuthDetails; | ||
import com.postgraduate.global.config.security.util.SecurityUtils; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@Service | ||
@Transactional | ||
@RequiredArgsConstructor | ||
public class SeniorSignUpUseCase { | ||
private final UserUpdateService userUpdateService; | ||
private final SeniorSaveService seniorSaveService; | ||
private final SecurityUtils securityUtils; | ||
|
||
public void signUp(AuthDetails authDetails, SeniorSignUpRequest request) { | ||
User user = securityUtils.getLoggedInUser(authDetails); | ||
userUpdateService.updateRole(user.getUserId(), Role.SENIOR); | ||
seniorSaveService.saveSenior(user, request); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/main/java/com/postgraduate/domain/senior/application/usecase/SeniorUpdateUseCase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.postgraduate.domain.senior.application.usecase; | ||
|
||
import com.postgraduate.domain.senior.application.dto.req.SeniorProfileRequest; | ||
import com.postgraduate.domain.senior.domain.entity.Senior; | ||
import com.postgraduate.domain.senior.domain.service.SeniorGetService; | ||
import com.postgraduate.domain.senior.domain.service.SeniorSaveService; | ||
import com.postgraduate.domain.user.domain.entity.User; | ||
import com.postgraduate.domain.user.domain.service.UserGetService; | ||
import com.postgraduate.global.auth.AuthDetails; | ||
import com.postgraduate.global.config.security.util.SecurityUtils; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@Service | ||
@Transactional | ||
@RequiredArgsConstructor | ||
public class SeniorUpdateUseCase { | ||
private final SeniorSaveService seniorSaveService; | ||
private final SeniorGetService seniorGetService; | ||
private final SecurityUtils securityUtils; | ||
|
||
public void updateProfile(AuthDetails authDetails, SeniorProfileRequest request) { | ||
User user = securityUtils.getLoggedInUser(authDetails); | ||
Senior senior = seniorGetService.byUser(user); | ||
seniorSaveService.saveSenior(senior, request); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
src/main/java/com/postgraduate/domain/senior/domain/entity/repository/SeniorRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.postgraduate.domain.senior.domain.entity.repository; | ||
|
||
import com.postgraduate.domain.senior.domain.entity.Senior; | ||
import com.postgraduate.domain.user.domain.entity.User; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
import java.util.Optional; | ||
|
||
public interface SeniorRepository extends JpaRepository<Senior, Long> { | ||
Optional<Senior> findByUser(User user); | ||
} |
17 changes: 17 additions & 0 deletions
17
src/main/java/com/postgraduate/domain/senior/domain/service/SeniorGetService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.postgraduate.domain.senior.domain.service; | ||
|
||
import com.postgraduate.domain.senior.domain.entity.Senior; | ||
import com.postgraduate.domain.senior.domain.entity.repository.SeniorRepository; | ||
import com.postgraduate.domain.user.domain.entity.User; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class SeniorGetService { | ||
private final SeniorRepository seniorRepository; | ||
|
||
public Senior byUser(User user) { | ||
return seniorRepository.findByUser(user).orElseThrow(/**μμΈ μ²λ¦¬**/); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
src/main/java/com/postgraduate/domain/senior/domain/service/SeniorSaveService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.postgraduate.domain.senior.domain.service; | ||
|
||
import com.postgraduate.domain.senior.application.dto.req.SeniorProfileRequest; | ||
import com.postgraduate.domain.senior.application.dto.req.SeniorSignUpRequest; | ||
import com.postgraduate.domain.senior.application.mapper.SeniorMapper; | ||
import com.postgraduate.domain.senior.domain.entity.Senior; | ||
import com.postgraduate.domain.senior.domain.entity.repository.SeniorRepository; | ||
import com.postgraduate.domain.user.domain.entity.User; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class SeniorSaveService { | ||
private final SeniorRepository seniorRepository; | ||
|
||
public Senior saveSenior(User user, SeniorSignUpRequest request) { | ||
Senior senior = SeniorMapper.mapToSenior(user, request); | ||
return seniorRepository.save(senior); | ||
} | ||
|
||
public Senior saveSenior(Senior senior, SeniorProfileRequest request) { | ||
senior.updateProfile(request.getInfo(), request.getTarget(), request.getChatLink(), request.getTime(), request.getTerm()); | ||
return seniorRepository.save(senior); | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
src/main/java/com/postgraduate/domain/senior/presentation/SeniorController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package com.postgraduate.domain.senior.presentation; | ||
|
||
import com.postgraduate.domain.senior.application.dto.req.SeniorProfileRequest; | ||
import com.postgraduate.domain.senior.application.dto.req.SeniorSignUpRequest; | ||
import com.postgraduate.domain.senior.application.usecase.SeniorSignUpUseCase; | ||
import com.postgraduate.domain.senior.application.usecase.SeniorUpdateUseCase; | ||
import com.postgraduate.global.auth.AuthDetails; | ||
import com.postgraduate.global.dto.ResponseDto; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.security.core.annotation.AuthenticationPrincipal; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import static com.postgraduate.domain.senior.presentation.constant.SeniorResponseMessage.SUCCESS_SENIOR_SIGN_UP_MESSAGE; | ||
import static com.postgraduate.domain.senior.presentation.constant.SeniorResponseMessage.SUCCESS_UPDATE_PROFILE_MESSAGE; | ||
import static org.springframework.http.HttpStatus.OK; | ||
|
||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/senior") | ||
@Tag(name = "SENIOR Controller") | ||
public class SeniorController { | ||
private final SeniorSignUpUseCase signUpUseCase; | ||
private final SeniorUpdateUseCase updateUseCase; | ||
|
||
@PostMapping("/signup") | ||
@Operation(summary = "λνμμ κ°μ ", description = "λνμμ νμκ°μ ") | ||
public ResponseDto singUpSenior(@AuthenticationPrincipal AuthDetails authDetails, | ||
@RequestBody SeniorSignUpRequest request) { | ||
signUpUseCase.signUp(authDetails, request); | ||
return ResponseDto.create(OK.value(), SUCCESS_SENIOR_SIGN_UP_MESSAGE.getMessage()); | ||
} | ||
|
||
@PatchMapping("/profile") | ||
@Operation(summary = "λνμμ νλ‘ν λ±λ‘", description = "μκ°κΈ, μΆμ²λμ, μ€νμ±ν λ°© λ§ν¬, κ°λ₯ μκ°λ, μν΅μκ°") | ||
public ResponseDto singUpSenior(@AuthenticationPrincipal AuthDetails authDetails, | ||
@RequestBody SeniorProfileRequest request) { | ||
updateUseCase.updateProfile(authDetails, request); | ||
return ResponseDto.create(OK.value(), SUCCESS_UPDATE_PROFILE_MESSAGE.getMessage()); | ||
} | ||
} |
Oops, something went wrong.