Skip to content

Commit

Permalink
[merge] 모임 개설 후 리턴값으로 해당 모임 아이디 반환하도록 수정
Browse files Browse the repository at this point in the history
[fix] 모임 개설 후 리턴값으로 해당 모임 아이디 반환하도록 수정
  • Loading branch information
lreowy authored Jul 17, 2024
2 parents b0be7ad + 749631a commit aa7e6fa
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/main/java/com/pickple/server/api/guest/domain/Guest.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import jakarta.persistence.OneToMany;
import jakarta.persistence.OneToOne;
import jakarta.persistence.Table;
import jakarta.validation.constraints.Size;
import java.util.ArrayList;
import java.util.List;
import lombok.AccessLevel;
Expand Down Expand Up @@ -41,6 +42,7 @@ public class Guest extends BaseTimeEntity {

private String nickname;

@Size(max = 500)
private String imageUrl;

@Builder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.pickple.server.api.moim.domain.enums.Category;
import com.pickple.server.api.moim.dto.request.MoimCreateRequest;
import com.pickple.server.api.moim.dto.response.MoimByCategoryResponse;
import com.pickple.server.api.moim.dto.response.MoimCreateResponse;
import com.pickple.server.api.moim.dto.response.MoimDescriptionResponse;
import com.pickple.server.api.moim.dto.response.MoimDetailResponse;
import com.pickple.server.api.moim.dto.response.MoimListByHostGetResponse;
Expand Down Expand Up @@ -32,9 +33,10 @@ public class MoimController implements MoimControllerDocs {
private final MoimCommandService moimCommandService;

@PostMapping("/v1/moim")
public ApiResponseDto createMoim(@HostId Long hostId, @RequestBody MoimCreateRequest moimCreateRequest) {
moimCommandService.createMoim(hostId, moimCreateRequest);
return ApiResponseDto.success(SuccessCode.MOIM_CREATE_SUCCESS);
public ApiResponseDto<MoimCreateResponse> createMoim(@HostId Long hostId,
@RequestBody MoimCreateRequest moimCreateRequest) {
return ApiResponseDto.success(SuccessCode.MOIM_CREATE_SUCCESS,
moimCommandService.createMoim(hostId, moimCreateRequest));
}

@GetMapping("/v1/moim/categories")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
package com.pickple.server.api.moim.domain;

import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Size;
import lombok.Getter;

@Getter
public class ImageInfo {

@Size(max = 500)
@NotBlank(message = "이미지가 비어있습니다.")
private String imageUrl1;

@Size(max = 500)
private String imageUrl2;

@Size(max = 500)
private String imageUrl3;

}
2 changes: 2 additions & 0 deletions src/main/java/com/pickple/server/api/moim/domain/Moim.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.pickple.server.api.notice.domain.Notice;
import com.pickple.server.global.common.domain.BaseTimeEntity;
import jakarta.persistence.CascadeType;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
Expand Down Expand Up @@ -63,6 +64,7 @@ public class Moim extends BaseTimeEntity {

private String title;

@Column(length = 2000)
private String description;

@JdbcTypeCode(SqlTypes.JSON)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.pickple.server.api.moim.dto.response;

import lombok.Builder;

@Builder
public record MoimCreateResponse(
Long moimId
) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.pickple.server.api.moim.domain.Moim;
import com.pickple.server.api.moim.domain.enums.MoimState;
import com.pickple.server.api.moim.dto.request.MoimCreateRequest;
import com.pickple.server.api.moim.dto.response.MoimCreateResponse;
import com.pickple.server.api.moim.repository.MoimRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
Expand All @@ -18,7 +19,7 @@ public class MoimCommandService {
private final HostRepository hostRepository;
private final MoimRepository moimRepository;

public void createMoim(Long hostId, MoimCreateRequest request) {
public MoimCreateResponse createMoim(Long hostId, MoimCreateRequest request) {
Host host = hostRepository.findHostByIdOrThrow(hostId);
Moim moim = Moim.builder()
.host(host)
Expand All @@ -36,5 +37,8 @@ public void createMoim(Long hostId, MoimCreateRequest request) {
.moimState(MoimState.ONGOING.getMoimState())
.build();
moimRepository.save(moim);
return MoimCreateResponse.builder()
.moimId(moim.getId())
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
import jakarta.validation.constraints.Size;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Builder;
Expand All @@ -34,7 +35,9 @@ public class Notice extends BaseTimeEntity {

private String title;

@Size(max = 500)
private String content;

@Size(max = 500)
private String imageUrl;
}

0 comments on commit aa7e6fa

Please sign in to comment.