Skip to content

Commit

Permalink
Merge pull request #38 from Nexters/feature/33-save-pin-response
Browse files Browse the repository at this point in the history
핀 저장 시 response 수정
  • Loading branch information
emost22 authored Feb 5, 2024
2 parents 9dbb16b + 0f3baa9 commit 0297230
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 10 deletions.
17 changes: 14 additions & 3 deletions src/main/java/com/pcb/audy/domain/pin/dto/response/PinSaveRes.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
package com.pcb.audy.domain.pin.dto.response;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.AccessLevel;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

@JsonIgnoreProperties
public class PinSaveRes {}
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class PinSaveRes {
private String pinId;

@Builder
private PinSaveRes(String pinId) {
this.pinId = pinId;
}
}
10 changes: 4 additions & 6 deletions src/main/java/com/pcb/audy/domain/pin/service/PinService.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ public class PinService {

public PinSaveRes savePin(PinSaveReq pinSaveReq) {
UUID pinId = getPinId();
redisProvider.set(
getKey(pinSaveReq.getCourseId(), pinId),
Pin pin =
Pin.builder()
.pinId(pinId)
.pinName(pinSaveReq.getPinName())
Expand All @@ -37,10 +36,9 @@ public PinSaveRes savePin(PinSaveReq pinSaveReq) {
.address(pinSaveReq.getAddress())
.sequence(pinSaveReq.getSequence())
.course(getCourse(pinSaveReq.getCourseId()))
.build(),
PIN_EXPIRE_TIME);

return new PinSaveRes();
.build();
redisProvider.set(getKey(pinSaveReq.getCourseId(), pinId), pin, PIN_EXPIRE_TIME);
return PinServiceMapper.INSTANCE.toPinSaveRes(pin);
}

public PinNameUpdateRes updatePinName(PinNameUpdateReq pinNameUpdateReq) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.pcb.audy.domain.pin.service;

import com.pcb.audy.domain.pin.dto.response.PinSaveRes;
import com.pcb.audy.domain.pin.entity.Pin;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;

@Mapper
public interface PinServiceMapper {
PinServiceMapper INSTANCE = Mappers.getMapper(PinServiceMapper.class);

PinSaveRes toPinSaveRes(Pin pin);
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class PinControllerTest extends BaseMvcTest implements PinTest {
.address(TEST_ADDRESS)
.sequence(TEST_SEQUENCE)
.build();
PinSaveRes pinSaveRes = new PinSaveRes();
PinSaveRes pinSaveRes = PinSaveRes.builder().pinId(TEST_PIN_ID.toString()).build();
when(pinService.savePin(any())).thenReturn(pinSaveRes);
this.mockMvc
.perform(
Expand Down

0 comments on commit 0297230

Please sign in to comment.