Skip to content

Commit

Permalink
SCRUM-41 feat: 판매자 마이페이지 조회
Browse files Browse the repository at this point in the history
  • Loading branch information
yeopyeop-82 committed Aug 12, 2024
1 parent 8fd015c commit c544f31
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.kakaoteck.golagola.domain.seller.controller;

import com.kakaoteck.golagola.domain.seller.dto.SellerResponse;
import com.kakaoteck.golagola.domain.seller.entity.Seller;
import com.kakaoteck.golagola.domain.seller.service.SellerService;
import com.kakaoteck.golagola.global.common.ApiResponse;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequiredArgsConstructor
@RequestMapping("/api/v1/seller")
@CrossOrigin("*")
public class SellerController {

private final SellerService sellerService;

@Operation(summary = "판매자 마이페이지 조회", description = "판매자의 정보를 조회합니다.")
@GetMapping("/mypage")
public ApiResponse<SellerResponse> getMyPage(
@AuthenticationPrincipal Seller seller
) {
return ApiResponse.onSuccess(sellerService.getMyPage(seller));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.kakaoteck.golagola.domain.seller.dto;

import com.kakaoteck.golagola.global.common.enums.Gender;
import com.kakaoteck.golagola.global.common.enums.Role;
import lombok.Builder;

import java.time.LocalDate;

@Builder
public record SellerResponse(
String nickname,
String realName,
Gender gender,
String email,
String address,
String phoneNum,
Role role,
LocalDate registerDate
) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.kakaoteck.golagola.domain.seller.service;

import com.kakaoteck.golagola.domain.seller.dto.SellerResponse;
import com.kakaoteck.golagola.domain.seller.entity.Seller;
import com.kakaoteck.golagola.domain.seller.repository.SellerRepository;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@RequiredArgsConstructor
@Transactional
@Slf4j
public class SellerService {

private final SellerRepository sellerRepository;

public SellerResponse getMyPage(Seller seller) {
return SellerResponse.builder()
.email(seller.getEmail())
.role(seller.getRole())
.address(seller.getAddress())
.registerDate(seller.getRegisterDate())
.realName(seller.getRealName())
.gender(seller.getGender())
.phoneNum(seller.getPhoneNum())
.nickname(seller.getNickname())
.build();
}
}

0 comments on commit c544f31

Please sign in to comment.