|
| 1 | +package iampotato.iampotato.domain.owner.api; |
| 2 | + |
| 3 | +import iampotato.iampotato.domain.owner.application.OwnerService; |
| 4 | +import iampotato.iampotato.domain.owner.domain.Owner; |
| 5 | +import iampotato.iampotato.domain.owner.dto.*; |
| 6 | +import iampotato.iampotato.global.util.Result; |
| 7 | +import io.swagger.v3.oas.annotations.Operation; |
| 8 | +import io.swagger.v3.oas.annotations.tags.Tag; |
| 9 | +import lombok.RequiredArgsConstructor; |
| 10 | +import org.springframework.web.bind.annotation.GetMapping; |
| 11 | +import org.springframework.web.bind.annotation.PostMapping; |
| 12 | +import org.springframework.web.bind.annotation.PutMapping; |
| 13 | +import org.springframework.web.bind.annotation.RestController; |
| 14 | + |
| 15 | +import java.util.List; |
| 16 | +import java.util.stream.Collectors; |
| 17 | + |
| 18 | +@RestController |
| 19 | +@RequiredArgsConstructor |
| 20 | +public class OwnerApi { |
| 21 | + |
| 22 | + private final OwnerService ownerService; |
| 23 | + |
| 24 | + @Tag(name = "점주") |
| 25 | + @Operation(summary = "점주 회원가입", description = "점주의 정보를 등록할때 사용되는 API 입니다.") |
| 26 | + @PostMapping("/api/v1/owner/signUp") |
| 27 | + public Result<OwnerSignUpResponse> signUp(OwnerSignUpRequest request) { //회원 가입하는 POST API |
| 28 | + |
| 29 | + //Spring security로 Password Hash 암호화 로직 추가하기 |
| 30 | + Owner owner = Owner.builder() |
| 31 | + .loginId(request.getLoginId()) |
| 32 | + .password(request.getPassword()) |
| 33 | + .nickname(request.getNickname()) |
| 34 | + .ownerBusinessNumber(request.getOwnerBusinessNumber()) |
| 35 | + .build(); |
| 36 | + OwnerSignUpResponse response = new OwnerSignUpResponse(ownerService.signUp(owner)); |
| 37 | + |
| 38 | + return new Result<>(Result.CODE_SUCCESS, Result.MESSAGE_OK, response); |
| 39 | + } |
| 40 | + |
| 41 | + @Tag(name = "점주") |
| 42 | + @Operation(summary = "비인증 점주 가져오기", description = "관리자페이지에서 인증되지 않은 점주들의 정보를 가져올때 사용되는 API 입니다.") |
| 43 | + @GetMapping("/api/v1/owner/unauthorization") |
| 44 | + public Result<List<OwnerUnauthorizedResponse>> getUnauthorizedOwner() { |
| 45 | + |
| 46 | + List<Owner> unauthorizedOwners = ownerService.getUnauthorizedOwners(); |
| 47 | + |
| 48 | + List<OwnerUnauthorizedResponse> responses = unauthorizedOwners.stream() |
| 49 | + .map(OwnerUnauthorizedResponse::new) |
| 50 | + .collect(Collectors.toList()); |
| 51 | + |
| 52 | + return new Result<>(Result.CODE_SUCCESS, Result.MESSAGE_OK, responses); |
| 53 | + } |
| 54 | + |
| 55 | + @Tag(name = "점주") |
| 56 | + @Operation(summary = "인증하기", description = "인증되지 않은 점주를 인증할때 사용되는 API 입니다.") |
| 57 | + @PutMapping("/api/v1/owner/authorization") |
| 58 | + public Result<OwnerAuthorizeResponse> authorizeOwner(OwnerAuthorizeRequest request) { |
| 59 | + |
| 60 | + Owner owner = ownerService.authorizeOwner(request.getId()); |
| 61 | + OwnerAuthorizeResponse response = new OwnerAuthorizeResponse(owner); |
| 62 | + |
| 63 | + return new Result<>(Result.CODE_SUCCESS, Result.MESSAGE_OK, response); |
| 64 | + } |
| 65 | +} |
0 commit comments