Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HEENDY-61-user-QR-API] 유저용 QR코드 생성 및 memberId UUID로 받기 #17

Merged
merged 9 commits into from
Feb 26, 2024
12 changes: 11 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,17 @@
<artifactId>spring-context-support</artifactId>
<version>${org.springframework-version}</version>
</dependency>

<!-- QR Code generator -->
<dependency>
<groupId>com.google.zxing</groupId>
<artifactId>core</artifactId>
<version>3.5.0</version>
</dependency>
<dependency>
<groupId>com.google.zxing</groupId>
<artifactId>javase</artifactId>
<version>3.5.0</version>
</dependency>
</dependencies>

<build>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/hyundai/app/aop/ExceptionAdvice.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
@Component
public class ExceptionAdvice {

@AfterThrowing(pointcut = "execution(* com.livarter.app.service.*.*()) ", throwing = "e")
@AfterThrowing(pointcut = "execution(* com.hyundai.app.*.*()) ", throwing = "e")
public void throwExceptionInService(Exception e) {
log.error("Exception 발생 : " + e);
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/hyundai/app/aop/LogAdvice.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
@Component
public class LogAdvice {

@Around("execution(* com.hyundai.app.controller.*.*())")
@Around("execution(* com.hyundai.app.*.*())")
public Object logInController(ProceedingJoinPoint pjp) {

log.debug("--------------컨트롤러 시작--------------" + new Date());
Expand All @@ -36,7 +36,7 @@ public Object logInController(ProceedingJoinPoint pjp) {
return result;
}

@Around("execution(* com.hyundai.app.service.*.*())")
@Around("execution(* com.hyundai.app.*.*())")
public Object logInService(ProceedingJoinPoint pjp) {
log.debug("--------------서비스 시작--------------" + new Date());
long startTime = System.currentTimeMillis();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class CouponController {

@ApiOperation("사용자용 쿠폰 전체 조회 API")
@GetMapping
public AdventureOfHeendyResponse<List<Coupon>> findCouponList(@ApiIgnore @MemberId Integer memberId) {
public AdventureOfHeendyResponse<List<Coupon>> findCouponList(@ApiIgnore @MemberId String memberId) {
return AdventureOfHeendyResponse.success("사용자의 쿠폰 목록을 가져왔습니다.", couponService.findMemberCouponList(memberId));
}
}
6 changes: 3 additions & 3 deletions src/main/java/com/hyundai/app/coupon/domain/MemberCoupon.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@
*/
public class MemberCoupon extends BaseEntity {
private int id;
private int memberId;
private String memberId;
private int couponId;
private int isUsed;
private String channelType;
private LocalDate expiredAt;

public MemberCoupon(int memberId, int couponId, String channelType) {
public MemberCoupon(String memberId, int couponId, String channelType) {
this.memberId = memberId;
this.couponId = couponId;
this.channelType = channelType;
}

public static MemberCoupon of(int memberId, int couponId, String channelType) {
public static MemberCoupon of(String memberId, int couponId, String channelType) {
return new MemberCoupon(memberId, couponId, channelType);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ public interface CouponMapper {

Coupon findById(int couponId);

List<Coupon> findMemberCouponList(Integer memberId);
List<Coupon> findMemberCouponList(String memberId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public List<Coupon> findCouponList(int storeId) {
return couponList;
}

public List<Coupon> findMemberCouponList(Integer memberId) {
public List<Coupon> findMemberCouponList(String memberId) {
List<Coupon> couponList = couponMapper.findMemberCouponList(memberId);
for (Coupon coupon: couponList) {
CouponType couponType = coupon.getCouponType();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public AdventureOfHeendyResponse<EventDetailResDto> findCurrentEventByEventType(

@PostMapping("{eventId}/participate")
@ApiOperation("유저용 이벤트 참여 API")
public AdventureOfHeendyResponse<EventParticipateResDto> participateEvent(@ApiIgnore @MemberId Integer memberId,
public AdventureOfHeendyResponse<EventParticipateResDto> participateEvent(@ApiIgnore @MemberId String memberId,
@PathVariable int eventId){
return AdventureOfHeendyResponse.success("이벤트 참여에 성공했습니다.", eventService.participateEvent(memberId, eventId));
}
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/com/hyundai/app/event/domain/MemberEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
public class MemberEvent extends BaseEntity {
private int id;
private int eventId;
private int memberId;
private String memberId;

public MemberEvent(int eventId, int memberId) {
public MemberEvent(int eventId, String memberId) {
this.eventId = eventId;
this.memberId = memberId;
}

public static MemberEvent of(int eventId, int memberId) {
public static MemberEvent of(int eventId, String memberId) {
return new MemberEvent(eventId, memberId);
}
}
}
8 changes: 4 additions & 4 deletions src/main/java/com/hyundai/app/event/service/EventService.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class EventService {

public EventDetailResDto findCurrentEventByEventType(EventType eventType) {
EventDetailResDto eventDetailResDto = eventMapper.findCurrentEventByEventType(eventType);
if (eventDetailResDto != null) {
if (eventDetailResDto == null) {
log.error("해당 타입의 이벤트가 존재하지 않습니다.");
throw new AdventureOfHeendyException(ErrorCode.EVENT_NOT_EXIST);
}
Expand Down Expand Up @@ -131,7 +131,7 @@ public Void delete(int storeId, int eventId) {
return null;
}

public EventParticipateResDto participateEvent(Integer memberId, int eventId) {
public EventParticipateResDto participateEvent(String memberId, int eventId) {
EventDetailResDto eventDetailResDto = findAvailableEvent(eventId);
EventParticipateResDto eventVisitResDto = EventParticipateResDto.of(eventDetailResDto);
if (eventDetailResDto.getRewardType() == RewardType.COUPON) {
Expand All @@ -152,12 +152,12 @@ private Coupon findCoupon(int couponId) {
return coupon;
}

private void saveMemberCoupon(int memberId, int couponId, String channelType) {
private void saveMemberCoupon(String memberId, int couponId, String channelType) {
MemberCoupon memberCoupon = MemberCoupon.of(memberId, couponId, channelType);
memberCouponMapper.saveMemberCoupon(memberCoupon);
}

private void visitEvent(int memberId, int eventId) {
private void visitEvent(String memberId, int eventId) {
MemberEvent memberEvent = MemberEvent.of(eventId, memberId);
memberEventMapper.saveMemberEvent(memberEvent);
eventMapper.increaseVisitedCount(eventId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,21 @@ public class FriendController {

@GetMapping
@ApiOperation("전체 친구 리스트 조회 API")
public AdventureOfHeendyResponse<FriendListResDto> findFriendList(@ApiIgnore @MemberId Integer memberId) {
public AdventureOfHeendyResponse<FriendListResDto> findFriendList(@ApiIgnore @MemberId String memberId) {
return AdventureOfHeendyResponse.success("친구 목록을 가져왔습니다.", friendService.findFriendList(memberId));
}

@GetMapping("/{friendId}")
@ApiOperation("특정 친구 조회 API")
public AdventureOfHeendyResponse<FriendDetailResDto> find(@ApiIgnore @MemberId Integer memberId,
@PathVariable final int friendId) {
public AdventureOfHeendyResponse<FriendDetailResDto> find(@ApiIgnore @MemberId String memberId,
@PathVariable final String friendId) {
return AdventureOfHeendyResponse.success("친구 흰디에 방문했습니다.", friendService.findFriend(memberId, friendId));
}

@PostMapping("/{friendId}/mbti")
@ApiOperation("친구 MBTI 작성 API")
public AdventureOfHeendyResponse<String> saveMbti(@ApiIgnore @MemberId Integer memberId,
@PathVariable final int friendId,
public AdventureOfHeendyResponse<String> saveMbti(@ApiIgnore @MemberId String memberId,
@PathVariable final String friendId,
@Valid @RequestBody final MbtiSaveReqDto mbtiSaveReqDto) {
return AdventureOfHeendyResponse.success("친구 MBTI를 저장했습니다.", friendService.updateMbti(memberId, friendId, mbtiSaveReqDto));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
*/
public class ConnectionGame extends BaseEntity {
private int id;
private int fromMemberId;
private int toMemberId;
private String fromMemberId;
private String toMemberId;
private int winnerId;
private int diceToMember;
private int diceFromMember;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class MemberConnection extends BaseEntity {
private int id;
private int fromMemberId;
private int toMemberId;
private String fromMemberId;
private String toMemberId;
private int isDeleted;
private String mbtiId;

@Builder
public MemberConnection(int fromMemberId, int toMemberId) {
public MemberConnection(String fromMemberId, String toMemberId) {
this.fromMemberId = fromMemberId;
this.toMemberId = toMemberId;
}

@Builder
public MemberConnection(int fromMemberId, int toMemberId, String mbtiId) {
public MemberConnection(String fromMemberId, String toMemberId, String mbtiId) {
this.fromMemberId = fromMemberId;
this.toMemberId = toMemberId;
this.mbtiId = mbtiId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
@NoArgsConstructor
@AllArgsConstructor
public class FriendDetailResDto {
private int id;
private String id;
private String nickname;
private String imgUrl;
private String characterImgUrl;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/hyundai/app/friend/dto/FriendDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
@Getter
@AllArgsConstructor
public class FriendDto {
private int memberId;
private int friendId;
private String memberId;
private String friendId;
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
public interface FriendMapper {
MemberConnection findConnection(FriendDto friendDto);
int save(MemberConnection memberConnection);
List<FriendDetailResDto> findFriendList(int memberId);
List<FriendDetailResDto> findFriendList(String memberId);
int updateMbti(MemberConnection savedMemberConnection);
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ public class FriendService {
private final MbtiMapper mbtiMapper;
private final GameMapper gameMapper;

public FriendListResDto findFriendList(int memberId) {
public FriendListResDto findFriendList(String memberId) {
List<FriendDetailResDto> friendDetailResDto = friendMapper.findFriendList(memberId);
FriendListResDto friendListResDto = new FriendListResDto(friendDetailResDto);
return friendListResDto;
}

public FriendDetailResDto findFriend(int memberId, int friendId) {
public FriendDetailResDto findFriend(String memberId, String friendId) {
FriendDto friendDto = new FriendDto(memberId, friendId);
if (!isFriend(friendDto)) {
saveConnection(friendDto);
Expand Down Expand Up @@ -89,7 +89,7 @@ private String findMbtiByFriend(FriendDto friendDto) {
return mbtiMapper.findMbtiByFriend(friendDto);
}

public String updateMbti(int memberId, int friendId, MbtiSaveReqDto mbtiSaveReqDto) {
public String updateMbti(String memberId, String friendId, MbtiSaveReqDto mbtiSaveReqDto) {
String mbtiId = mbtiMapper.findIdByMbtiScore(mbtiSaveReqDto);
MemberConnection savedMemberConnection = new MemberConnection(
memberId,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package com.hyundai.app.member.controller;

import com.hyundai.app.common.AdventureOfHeendyResponse;
import com.hyundai.app.member.dto.MemberResDto;
import com.hyundai.app.member.service.MemberService;
import com.hyundai.app.security.methodparam.MemberId;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import lombok.extern.log4j.Log4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
Expand All @@ -21,6 +22,7 @@
*/
@Log4j
@Api("회원 관련 API")
@RequiredArgsConstructor
@RestController
@RequestMapping("/api/v1/members")
public class MemberController {
Expand All @@ -31,9 +33,31 @@ public class MemberController {

@GetMapping
@ApiOperation("회원 정보 조회 API")
public ResponseEntity<MemberResDto> login(@ApiIgnore @MemberId Integer memberId) {
public ResponseEntity<MemberResDto> login(@ApiIgnore @MemberId String memberId) {
log.debug("회원 정보 조회 : " + memberId);
MemberResDto memberResDto = memberService.getMemberInfo(memberId);
return new ResponseEntity<>(memberResDto, HttpStatus.ACCEPTED);
}
}

/**
* @author 엄상은
* @since 2024/02/26
* QR 생성 테스트 API
*/
@PostMapping("/qr")
@ApiOperation("QR 생성 테스트용 API")
public AdventureOfHeendyResponse<String> generateQr(@ApiIgnore @MemberId String memberId) {
return AdventureOfHeendyResponse.success("큐알 생성 성공", memberService.generateQrCodeAndUploadToS3(memberId));
}

/**
* @author 엄상은
* @since 2024/02/26
* QR 조회 API
*/
@GetMapping("/qr")
@ApiOperation("QR 조회 API")
public AdventureOfHeendyResponse<String> findQr(@ApiIgnore @MemberId String memberId) {
return AdventureOfHeendyResponse.success("QR코드 조회를 성공하였습니다", memberService.findQrUrl(memberId));
}
}
12 changes: 11 additions & 1 deletion src/main/java/com/hyundai/app/member/domain/Member.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,21 @@
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class Member extends BaseEntity {

private int id;
private String id;
private String email;
private String nickname;
private Role role;
private String refreshToken;
private String oauthId;
private String imgUrl;
private String qrUrl;

/**
* @author 엄상은
* @since 2024/02/26
* 회원 QR 업데이트
*/
public void updateQrUrl(String qrUrl) {
this.qrUrl = qrUrl;
}
}
5 changes: 3 additions & 2 deletions src/main/java/com/hyundai/app/member/mapper/MemberMapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
public interface MemberMapper {

void saveMember(Member member);
Member findById(int id);
Member findById(String id);
Member findByOauthId(String oauthId);
}
void updateQrUrl(Member member);
}
Loading
Loading