Skip to content

Commit

Permalink
Merge pull request #88 from Codiary-UMC-6th/81-feat-팀원-추가-및-삭제-기능-구현
Browse files Browse the repository at this point in the history
feature/#81-teammember-add-delete
  • Loading branch information
insa658723 authored Aug 5, 2024
2 parents 73888cf + e978ed1 commit 2db0974
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,16 @@ public static TeamResponseDTO.TeamCheckResponseDTO toTeamCheckDTO(Team team) {
.build();
}

//팀 프로필 수정
// 팀 프로필 수정
public static TeamResponseDTO.UpdateTeamDTO toUpdateTeamDTO(Team team) {
return TeamResponseDTO.UpdateTeamDTO.builder()
.name(team.getName())
.intro(team.getIntro())
.profilePhoto(team.getProfilePhoto())
.github(team.getGithub())
.email(team.getEmail())
.linkedIn(team.getLinkedin())
.discord(team.getDiscord())
.instagram(team.getInstagram())
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@

@Entity
@Getter
@Setter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@AllArgsConstructor
@Builder
public class Team {

@Id @GeneratedValue(strategy = GenerationType.IDENTITY)
Expand All @@ -35,6 +38,9 @@ public class Team {
@Column(name = "linkedin", columnDefinition = "varchar(256)")
private String linkedin;

@Column(name = "discord", columnDefinition = "varchar(256)")
private String discord;

@Column(name = "instagram", columnDefinition = "varchar(256)")
private String instagram;

Expand All @@ -47,6 +53,4 @@ public class Team {
@OneToMany(mappedBy = "team", cascade = CascadeType.ALL, orphanRemoval = true)
private List<TeamMember> teamMemberList = new ArrayList<>();



}
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ public interface TeamCommandService {
//팀 생성
Team createTeam(TeamRequestDTO.CreateTeamRequestDTO request);

//팀 프로필 수정
Team updateTeam(Long teamId);
// 팀 프로필 수정
Team updateTeam(Long teamId, TeamRequestDTO.UpdateTeamDTO request);


}
Original file line number Diff line number Diff line change
@@ -1,4 +1,45 @@
package com.codiary.backend.global.service.TeamService;

public class TeamCommandServiceImpl {
import com.codiary.backend.global.domain.entity.Team;
import com.codiary.backend.global.repository.TeamRepository;
import com.codiary.backend.global.web.dto.Team.TeamRequestDTO;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@RequiredArgsConstructor
@Service
public class TeamCommandServiceImpl implements TeamCommandService {

private final TeamRepository teamRepository;
@Override
@Transactional
public Team createTeam(TeamRequestDTO.CreateTeamRequestDTO request) {
Team team = Team.builder()
.name(request.getName())
.intro(request.getIntro())
.profilePhoto(request.getProfilePhoto())
.github(request.getGithub())
.email(request.getEmail())
.linkedin(request.getLinkedIn())
.instagram(request.getInstagram())
.build();

return teamRepository.save(team);
}

@Override
@Transactional
public Team updateTeam(Long teamId, TeamRequestDTO.UpdateTeamDTO request) {
Team team = teamRepository.findById(teamId).orElseThrow(() -> new IllegalArgumentException("Invalid team ID"));

team.setName(request.getName());
team.setIntro(request.getIntro());
team.setGithub(request.getGithub());
team.setLinkedin(request.getLinkedIn());
team.setInstagram(request.getInstagram());

return teamRepository.save(team);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -25,34 +25,26 @@ public class TeamController {
//팀 생성
@PostMapping()
@Operation(
summary = "팀 생성"
)
@Operation(summary = "팀 생성")
public ApiResponse<TeamResponseDTO.CreateTeamResponseDTO> createTeam(
@RequestBody TeamRequestDTO.CreateTeamRequestDTO request
){
Team newTeam = teamCommandService.createTeam(request);
return ApiResponse.onSuccess(
SuccessStatus.TEAM_OK,
TeamConverter.toCreateMemberDTO(newTeam)
);
TeamConverter.toCreateMemberDTO(newTeam));
}
//팀 프로필 수정
// 팀 프로필 수정
@PatchMapping("/profile/{teamId}")
@Operation(
summary = "팀 프로필 수정"
)
@Operation(summary = "팀 프로필 수정")
public ApiResponse<TeamResponseDTO.UpdateTeamDTO> updateTeam(
@RequestBody TeamRequestDTO.UpdateTeamDTO request,
@PathVariable Long teamId
){
@PathVariable Long teamId) {
Team updatedTeam = teamCommandService.updateTeam(teamId, request);
return ApiResponse.onSuccess(
SuccessStatus.TEAM_OK,
TeamConverter.toUpdateTeamDTO(
teamCommandService.updateTeam(teamId)
)
);
TeamConverter.toUpdateTeamDTO(updatedTeam));
}
*/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,12 @@ public static class CreateTeamRequestDTO { //팀 생성
private String profilePhoto;
private String intro;
private String github;
private String email;
private String linkedIn;
private String discord;
private String instagram;
}

@Getter
@Builder
@AllArgsConstructor
@NoArgsConstructor
public static class CheckTeam { //팀 조회
private Long teamId;
}

@Getter
@Builder
@AllArgsConstructor
Expand All @@ -44,4 +37,12 @@ public static class UpdateTeamDTO { //팀 프로필 수정
private String discord;
private String instagram;
}

@Getter
@Builder
@AllArgsConstructor
@NoArgsConstructor
public static class CheckTeam { //팀 조회
private Long teamId;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,27 @@ public static class CreateTeamResponseDTO { // 팀 생성
String profilePhoto;
}

@Builder
@Getter
@Builder
@NoArgsConstructor
@AllArgsConstructor
public static class TeamCheckResponseDTO { // 팀 조회
public static class UpdateTeamDTO { // 팀 프로필 수정
Long teamId;
String name;
String intro;
String profilePhoto;
String github;
String email;
String linkedIn;
String discord;
String instagram;
}

@Getter
@Builder
@Getter
@NoArgsConstructor
@AllArgsConstructor
public static class UpdateTeamDTO { // 팀 프로필 수정
public static class TeamCheckResponseDTO { // 팀 조회
Long teamId;
String name;
String intro;
Expand All @@ -47,7 +49,6 @@ public static class UpdateTeamDTO { // 팀 프로필 수정
String linkedIn;
}


@Builder
public record TeamFollowResponseDto( //팀 팔로우 기능
Long followId,
Expand Down

0 comments on commit 2db0974

Please sign in to comment.