Skip to content

Commit

Permalink
Merge pull request #50 from MarketPlace-O2O-Platform/feat/#49
Browse files Browse the repository at this point in the history
[Feat/#49] 회원 학법 조회 API 구현
  • Loading branch information
82everywin authored Nov 12, 2024
2 parents ca4ed38 + 1317a56 commit a739540
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import com.appcenter.marketplace.domain.coupon.repository.CouponRepository;
import com.appcenter.marketplace.domain.coupon.service.CouponOwnerService;
import com.appcenter.marketplace.domain.market.Market;
import com.appcenter.marketplace.domain.market.MarketRepository;
import com.appcenter.marketplace.domain.market.repository.MarketRepository;
import com.appcenter.marketplace.global.exception.CustomException;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@
import com.appcenter.marketplace.domain.market.Market;
import org.springframework.data.jpa.repository.JpaRepository;

import java.util.Optional;

public interface MarketRepository extends JpaRepository<Market,Long>, MarketRepositoryCustom{
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.appcenter.marketplace.domain.member.controller;


import com.appcenter.marketplace.domain.member.Member;
import com.appcenter.marketplace.domain.member.dto.req.MemberLoginReqDto;
import com.appcenter.marketplace.domain.member.dto.res.MemberLoginResDto;
import com.appcenter.marketplace.domain.member.service.MemberService;
Expand All @@ -9,10 +10,7 @@
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
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.RestController;
import org.springframework.web.bind.annotation.*;

import static com.appcenter.marketplace.global.common.StatusCode.*;

Expand All @@ -29,4 +27,11 @@ public ResponseEntity<CommonResponse<MemberLoginResDto>> loginMember(@RequestBod
return ResponseEntity.status(MEMBER_LOGIN_SUCCESS.getStatus())
.body(CommonResponse.from(MEMBER_LOGIN_SUCCESS.getMessage(),memberService.login(memberLoginReqDto)));
}

@Operation(summary = "학생 학번 조회", description = "마이페이지에 로그인한 회원의 학번을 조회하기 위해 사용됩니다." )
@GetMapping("/{memberId}")
public ResponseEntity<CommonResponse<MemberLoginResDto>> getMember(@PathVariable Long memberId){
return ResponseEntity.status(MEMBER_FOUND.getStatus())
.body(CommonResponse.from(MEMBER_FOUND.getMessage(),memberService.getMember(memberId)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@

public interface MemberService {
MemberLoginResDto login(MemberLoginReqDto memberLoginReqDto);
MemberLoginResDto getMember(Long studentId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ public MemberLoginResDto login(MemberLoginReqDto memberLoginReqDto) {
return MemberLoginResDto.toDto(member);
}

@Override
@Transactional
public MemberLoginResDto getMember(Long studentId) {
Member member = findMemberByMemberId(studentId);
return MemberLoginResDto.toDto(member);
}

// 학번 로그인 검증 및 형변환
private Long validateAndParseStudentId(MemberLoginReqDto memberLoginReqDto) {
// 로그인 검증
Expand All @@ -37,4 +44,8 @@ private Long validateAndParseStudentId(MemberLoginReqDto memberLoginReqDto) {
else throw new CustomException(UNAUTHORIZED_LOGIN_ERROR);

}

private Member findMemberByMemberId(Long memberId) {
return memberRepository.findById(memberId).orElseThrow(() -> new CustomException(INVALID_STUDENT_ID));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import java.util.function.Function;

import static com.appcenter.marketplace.global.common.StatusCode.*;

@Service
@RequiredArgsConstructor
public class MemberCouponServiceImpl implements MemberCouponService {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public enum StatusCode {

// Member
MEMBER_LOGIN_SUCCESS(OK, "로그인에 성공하였습니다."),
MEMBER_FOUND(OK, "회원 조회 완료"),


/* 400 BAD_REQUEST : 잘못된 요청 */
Expand All @@ -52,7 +53,7 @@ public enum StatusCode {
MARKET_NOT_EXIST(NOT_FOUND,"존재하지 않는 매장입니다."),
COUPON_NOT_EXIST(NOT_FOUND, "존재하지 않는 쿠폰입니다."),
COUPON_IS_DELETED(NOT_FOUND, "이미 삭제된 쿠폰입니다."),
IMAGE_NOT_EXIST(NOT_FOUND,"존재하지 않는 이미지입니다.");
IMAGE_NOT_EXIST(NOT_FOUND,"존재하지 않는 이미지입니다."),

/* 409 CONFLICT : 리소스 충돌 */
COUPON_ALREADY_ISSUED(CONFLICT, "이미 발급된 쿠폰입니다.");
Expand Down

0 comments on commit a739540

Please sign in to comment.