Skip to content

Commit

Permalink
#273 [feat] 모임 생성 후 필명 생성하는 서비스로직 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
parkheeddong committed Mar 27, 2024
1 parent f3d177c commit dc5d4be
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
19 changes: 19 additions & 0 deletions module-domain/src/main/java/com/mile/moim/service/MoimService.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import com.mile.moim.service.dto.BestMoimListResponse;
import com.mile.moim.service.dto.ContentListResponse;
import com.mile.moim.service.dto.MoimAuthenticateResponse;
import com.mile.moim.service.dto.MoimCreateRequest;
import com.mile.moim.service.dto.MoimCreateResponse;
import com.mile.moim.service.dto.MoimCuriousPostListResponse;
import com.mile.moim.service.dto.MoimInfoModifyRequest;
import com.mile.moim.service.dto.MoimInfoResponse;
Expand Down Expand Up @@ -189,4 +191,21 @@ public MoimNameConflictCheckResponse validateMoimName(
) {
return MoimNameConflictCheckResponse.of(!moimRepository.existsByName(moimName));
}

@Transactional
public MoimCreateResponse createMoim(
final Long userId,
final MoimCreateRequest createRequest
) {
Moim moim = moimRepository.saveAndFlush(Moim.create(createRequest));
User user = userService.findById(userId);
WriterMemberJoinRequest joinRequest = WriterMemberJoinRequest.of(createRequest.writerName(), createRequest.writerNameDescription());
WriterName owner = writerNameService.getById(writerNameService.createWriterName(user, moim, joinRequest));
moim.setOwner(owner);
moim.setIdUrl(secureUrlUtil.encodeUrl(moim.getId()));
String link = "초대링크"; // 초대링크 로직 넣기
// Topic 생성 로직 넣기
return MoimCreateResponse.of(moim.getIdUrl(), link);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,17 @@

public record WriterMemberJoinRequest(
@NotBlank(message = "필명이 입력되지 않았습니다.")
@Max(value = 8, message = "필명은 최대 110자 이내로 작성해주세요.")
@Max(value = 8, message = "필명은 최대 8자 이내로 작성해주세요.")
String writerName,

@NotBlank(message = "소개 글이 입력되지 않았습니다.")
@Max(value = 110, message = "소개 글은 최대 110자 이내로 작성해주세요.")
@Max(value = 110, message = "소개 글은 최대 100자 이내로 작성해주세요.")
String writerDescription
) {
public static WriterMemberJoinRequest of(
final String writerName,
final String writerDescription
) {
return new WriterMemberJoinRequest(writerName, writerDescription);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,8 @@ public Long createWriterName(final User user, final Moim moim, final WriterMembe
writerNameRepository.saveAndFlush(writerName);
return writerName.getId();
}

public WriterName getById(final Long writerNameId) {
return writerNameRepository.getById(writerNameId);
}
}

0 comments on commit dc5d4be

Please sign in to comment.