Skip to content

Commit

Permalink
[FEAT] Share (위치 공유 여부 구현)
Browse files Browse the repository at this point in the history
  • Loading branch information
jinjoo-lab committed Oct 17, 2023
1 parent fe89141 commit bb1160b
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.twtw.backend.domain.group.dto.request.JoinGroupDto;
import com.twtw.backend.domain.group.dto.request.MakeGroupDto;
import com.twtw.backend.domain.group.dto.response.GroupInfoDto;
import com.twtw.backend.domain.group.dto.response.ShareInfo;
import com.twtw.backend.domain.group.service.GroupService;

import org.springframework.http.ResponseEntity;
Expand Down Expand Up @@ -35,9 +36,14 @@ public ResponseEntity<GroupInfoDto> joinGroup(@RequestBody JoinGroupDto joinGrou
return ResponseEntity.ok(groupService.joinGroup(joinGroupDto));
}

@PutMapping("/share/{group}")
@PutMapping("/share/{id}")
public ResponseEntity<Void> changeShare(@PathVariable UUID id){
groupService.changeShare(id);
return ResponseEntity.ok().build();
}

@GetMapping("/share/{id}")
public ResponseEntity<ShareInfo> getshare(@PathVariable UUID id){
return ResponseEntity.ok(groupService.getShare(id));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.twtw.backend.domain.group.dto.response;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.util.UUID;

@Getter
@NoArgsConstructor
@AllArgsConstructor
public class ShareInfo {
private UUID groupId;
private UUID memberId;
private Boolean share;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.twtw.backend.domain.group.dto.request.MakeGroupDto;
import com.twtw.backend.domain.group.dto.response.GroupInfoDto;
import com.twtw.backend.domain.group.dto.response.ShareInfo;
import com.twtw.backend.domain.group.entity.Group;
import com.twtw.backend.domain.group.entity.GroupMember;
import com.twtw.backend.domain.member.entity.Member;
Expand All @@ -21,6 +22,10 @@ public Group toGroupEntity(MakeGroupDto groupDto) {
}

public GroupInfoDto toGroupInfo(Group group){
return new GroupInfoDto(group.getId(),group.getLeader(),group.getName(),group.getGroupImage());
return new GroupInfoDto(group.getId(),group.getLeaderId(),group.getName(),group.getGroupImage());
}

public ShareInfo toShareInfo(GroupMember groupMember){
return new ShareInfo(groupMember.getGroup().getId(),groupMember.getMember().getId(),groupMember.getShare());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.twtw.backend.domain.group.dto.request.JoinGroupDto;
import com.twtw.backend.domain.group.dto.request.MakeGroupDto;
import com.twtw.backend.domain.group.dto.response.GroupInfoDto;
import com.twtw.backend.domain.group.dto.response.ShareInfo;
import com.twtw.backend.domain.group.entity.Group;
import com.twtw.backend.domain.group.entity.GroupMember;
import com.twtw.backend.domain.group.mapper.GroupMapper;
Expand Down Expand Up @@ -64,7 +65,13 @@ public void changeShare(UUID id){
groupMember.changeShare();
}

public void removeGroup(UUID groupId) {
// TODO()
@Transactional
public ShareInfo getShare(UUID id){
Member member = this.authService.getMemberByJwt();
GroupInfoDto groupInfo = getGroupById(id);

GroupMember groupMember = groupMemberRepository.findByGroupIdAndMemberId(groupInfo.getGroupId(),member.getId()).orElseThrow(EntityNotFoundException::new);

return groupMapper.toShareInfo(groupMember);
}
}

0 comments on commit bb1160b

Please sign in to comment.