Skip to content

Commit

Permalink
Some refactoring, added update description endpoint.
Browse files Browse the repository at this point in the history
  • Loading branch information
Idan-sh committed Sep 9, 2024
1 parent ccf7b21 commit 85429a4
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.MTAPizza.Sympoll.groupmanagementservice.client;

import com.MTAPizza.Sympoll.groupmanagementservice.dto.request.DeleteGroupPollsRequest;
import com.MTAPizza.Sympoll.groupmanagementservice.dto.request.poll.DeleteGroupPollsRequest;
import com.MTAPizza.Sympoll.groupmanagementservice.dto.response.poll.service.DeleteGroupPollsResponse;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestBody;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package com.MTAPizza.Sympoll.groupmanagementservice.controller;

import com.MTAPizza.Sympoll.groupmanagementservice.dto.request.GroupCreateRequest;
import com.MTAPizza.Sympoll.groupmanagementservice.dto.request.UserRoleChangeRequest;
import com.MTAPizza.Sympoll.groupmanagementservice.dto.request.UserRoleCreateRequest;
import com.MTAPizza.Sympoll.groupmanagementservice.dto.request.UserRoleDeleteRequest;
import com.MTAPizza.Sympoll.groupmanagementservice.dto.request.decription.GroupUpdateDescriptionRequest;
import com.MTAPizza.Sympoll.groupmanagementservice.dto.request.user.role.UserRoleChangeRequest;
import com.MTAPizza.Sympoll.groupmanagementservice.dto.request.user.role.UserRoleCreateRequest;
import com.MTAPizza.Sympoll.groupmanagementservice.dto.request.user.role.UserRoleDeleteRequest;
import com.MTAPizza.Sympoll.groupmanagementservice.dto.request.media.GroupUpdateProfileBannerUrlRequest;
import com.MTAPizza.Sympoll.groupmanagementservice.dto.request.media.GroupUpdateProfilePictureUrlRequest;
import com.MTAPizza.Sympoll.groupmanagementservice.dto.response.group.service.DeleteGroupResponse;
Expand Down Expand Up @@ -254,4 +255,18 @@ public String updateProfileBannerUrl(@RequestBody GroupUpdateProfileBannerUrlReq
log.debug("Request received to add banner picture url: {}", groupUpdateProfileBannerUrlRequest);
return groupService.addProfileBannerUrl(groupUpdateProfileBannerUrlRequest);
}


/**
* Save a group profile description.
* @param groupUpdateDescriptionRequest Information on the group and the description to save.
* @return the updated group's ID.
*/
@PostMapping("/description")
@ResponseStatus(HttpStatus.OK)
public String updateProfileDescription(@RequestBody GroupUpdateDescriptionRequest groupUpdateDescriptionRequest){
log.info("Received request to save a description");
log.debug("Request received to add description: {}", groupUpdateDescriptionRequest);
return groupService.updateProfileDescription(groupUpdateDescriptionRequest);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.MTAPizza.Sympoll.groupmanagementservice.dto.request.decription;

public record GroupUpdateDescriptionRequest(
String groupId,
String description
) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.MTAPizza.Sympoll.groupmanagementservice.dto.request.poll;

public record DeleteGroupPollsRequest(String groupId) {
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.MTAPizza.Sympoll.groupmanagementservice.dto.request;
package com.MTAPizza.Sympoll.groupmanagementservice.dto.request.user.role;

import java.util.UUID;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.MTAPizza.Sympoll.groupmanagementservice.dto.request;
package com.MTAPizza.Sympoll.groupmanagementservice.dto.request.user.role;

import java.util.UUID;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.MTAPizza.Sympoll.groupmanagementservice.dto.request;
package com.MTAPizza.Sympoll.groupmanagementservice.dto.request.user.role;

import java.util.UUID;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

import com.MTAPizza.Sympoll.groupmanagementservice.client.PollClient;
import com.MTAPizza.Sympoll.groupmanagementservice.client.UserClient;
import com.MTAPizza.Sympoll.groupmanagementservice.dto.request.DeleteGroupPollsRequest;
import com.MTAPizza.Sympoll.groupmanagementservice.dto.request.decription.GroupUpdateDescriptionRequest;
import com.MTAPizza.Sympoll.groupmanagementservice.dto.request.poll.DeleteGroupPollsRequest;
import com.MTAPizza.Sympoll.groupmanagementservice.dto.request.GroupCreateRequest;
import com.MTAPizza.Sympoll.groupmanagementservice.dto.request.media.GroupUpdateProfileBannerUrlRequest;
import com.MTAPizza.Sympoll.groupmanagementservice.dto.request.media.GroupUpdateProfilePictureUrlRequest;
Expand Down Expand Up @@ -344,4 +345,21 @@ public String addProfileBannerUrl(GroupUpdateProfileBannerUrlRequest groupUpdate

return groupToUpdate.getGroupId();
}

/**
* Add a profile description to a group's profile.
* @param groupUpdateDescriptionRequest Details on the group to update and the description to update.
* @return ID of the updated group.
*/
public String updateProfileDescription(GroupUpdateDescriptionRequest groupUpdateDescriptionRequest) {
Group groupToUpdate = groupRepository
.findById(groupUpdateDescriptionRequest.groupId())
.orElseThrow(
() -> new GroupNotFoundException(groupUpdateDescriptionRequest.groupId())
);

groupToUpdate.setDescription(groupUpdateDescriptionRequest.description());
groupRepository.save(groupToUpdate);

return groupToUpdate.getGroupId(); }
}

0 comments on commit 85429a4

Please sign in to comment.