Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature/#81-teammember-add-delete #88

Merged
merged 4 commits into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -23,34 +23,26 @@ public class TeamController {
private final TeamCommandService teamCommandService;
//팀 생성
@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
Loading