Skip to content

Commit

Permalink
Merge pull request #341 from Team-Sopetit/develop
Browse files Browse the repository at this point in the history
[DEPLOY] 실서버 배포
  • Loading branch information
thguss authored Aug 29, 2024
2 parents eb82dc9 + 12638c9 commit 19d77db
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
public class ErrorHandler {

@ExceptionHandler(SoftieException.class)
public ResponseEntity<ErrorResponse> authException(SoftieException exception) {
public ResponseEntity<ErrorResponse> softieException(SoftieException exception) {
log.error(exception.getMessage());
return ResponseEntity
.status(exception.getStatusCode())
.body(ErrorResponse.of(exception.getDefaultMessage() + "\n" + exception.getDetailMessage()));
.body(ErrorResponse.of("[" + exception.getDefaultMessage() + "] " + exception.getDetailMessage()));
}

@ExceptionHandler(RuntimeException.class)
public ResponseEntity<ErrorResponse> makerException(RuntimeException exception) {
public ResponseEntity<ErrorResponse> exception(RuntimeException exception) {
log.error(exception.getMessage());
return ResponseEntity
.status(HttpStatus.INTERNAL_SERVER_ERROR.value())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,11 @@ public void subtractCotton(CottonType type) {
case HAPPINESS -> rainbowCottonCount--;
}
}

public int getCottonCount(CottonType type) {
return switch (type) {
case DAILY -> basicCottonCount;
case HAPPINESS -> rainbowCottonCount;
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import com.soptie.server.api.controller.dto.request.member.CreateProfileRequest;
import com.soptie.server.api.controller.dto.response.member.GetHomeInfoResponse;
import com.soptie.server.api.controller.dto.response.member.GiveMemberCottonResponse;
import com.soptie.server.common.exception.ExceptionCode;
import com.soptie.server.common.exception.SoftieException;
import com.soptie.server.domain.conversation.Conversation;
import com.soptie.server.domain.doll.DollType;
import com.soptie.server.domain.memberdoll.MemberDoll;
Expand Down Expand Up @@ -42,6 +44,11 @@ public void createMemberProfile(long memberId, CreateProfileRequest request) {
@Transactional
public GiveMemberCottonResponse giveCotton(long memberId, CottonType cottonType) {
val member = memberAdapter.findById(memberId);

if (member.getCottonInfo().getCottonCount(cottonType) <= 0) {
throw new SoftieException(ExceptionCode.BAD_REQUEST, "솜뭉치가 없습니다.");
}

member.getCottonInfo().subtractCotton(cottonType);
memberAdapter.update(member);

Expand Down

0 comments on commit 19d77db

Please sign in to comment.