Skip to content

Commit

Permalink
[fix] 그룹 생성 시 Response 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
boo105 committed Feb 11, 2024
1 parent a300af9 commit c1b1d0e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.gdsc.jmt.domain.category.query.dto.CategoriesResponse;
import com.gdsc.jmt.domain.group.command.controller.request.CreateGroupRequest;
import com.gdsc.jmt.domain.group.command.controller.response.CreateGroupResponse;
import com.gdsc.jmt.domain.group.command.service.GroupService;
import com.gdsc.jmt.global.controller.FirstVersionRestController;
import com.gdsc.jmt.global.dto.JMTApiResponse;
Expand Down Expand Up @@ -31,8 +32,8 @@ public class GroupController {
@ApiResponse(responseCode = "200", useReturnTypeSchema = true),
})
@PostMapping(value = "/group", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
public JMTApiResponse<Null> createGroup(@ModelAttribute CreateGroupRequest createGroupRequest, @AuthenticationPrincipal UserInfo user) {
groupService.createGroup(createGroupRequest, user);
return JMTApiResponse.createResponseWithMessage(null, GroupMessage.CREATED_GROUP);
public JMTApiResponse<CreateGroupResponse> createGroup(@ModelAttribute CreateGroupRequest createGroupRequest, @AuthenticationPrincipal UserInfo user) {
Long groupCode = groupService.createGroup(createGroupRequest, user);
return JMTApiResponse.createResponseWithMessage(new CreateGroupResponse(groupCode), GroupMessage.CREATED_GROUP);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.gdsc.jmt.domain.group.command.controller.response;

import lombok.AllArgsConstructor;
import lombok.Data;

@Data
@AllArgsConstructor
public class CreateGroupResponse {
private Long groupCode;
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class GroupService {
private final S3FileService s3FileService;

@Transactional
public void createGroup(CreateGroupRequest request, UserInfo userInfo) {
public Long createGroup(CreateGroupRequest request, UserInfo userInfo) {
Optional<UserEntity> userResult = userRepository.findByEmail(userInfo.getEmail());
if(userResult.isEmpty()) {
throw new ApiException(UserMessage.USER_NOT_FOUND);
Expand All @@ -60,6 +60,8 @@ public void createGroup(CreateGroupRequest request, UserInfo userInfo) {
.role(ownerRole)
.build();
groupUserRepository.save(groupUsersEntity);

return groupEntity.getGid();
}

private void uploadImages(GroupEntity.GroupEntityBuilder groupEntityBuilder, MultipartFile groupProfileImage, MultipartFile groupBackgroundImage) {
Expand Down

0 comments on commit c1b1d0e

Please sign in to comment.