Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
@@ -1,5 +1,6 @@
package dmu.dasom.api.domain.executive.dto;

import dmu.dasom.api.domain.executive.enums.Team;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
Expand All @@ -22,7 +23,15 @@ public class ExecutiveListResponseDto {
@Schema(description = "임원진 직책", example = "회장")
private String position;

@Schema(description = "임원진 깃허브 주소", example = "https://github.com/dasom")
private String githubUrl;
@Schema(description = "수정할 임원진 역할", example = "동아리 운영 총괄", nullable = true)
private String role;

@Schema(description = "임원진 깃허브 이름", example = "DASOM")
private String github_username;

@Schema(description = "소속 팀", example = "president, tech, academic, pr, management")
private Team team;

private Integer sortOrder;

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package dmu.dasom.api.domain.executive.dto;

import dmu.dasom.api.domain.executive.entity.ExecutiveEntity;
import dmu.dasom.api.domain.executive.enums.Team;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Size;
Expand All @@ -21,17 +22,30 @@ public class ExecutiveRequestDto {
@Schema(description = "임원진 이름", example = "김다솜")
private String name;

@NotBlank(message = "임원진 역할은 필수 입력 사항입니다.")
@Schema(description = "임원진 역할", example = "회장")
@NotBlank(message = "임원진 직책은 필수 입력 사항입니다.")
@Schema(description = "임원진 직책", example = "회장")
private String position;

private String githubUrl;
@NotBlank(message = "임원진 역할은 필수 입력 사항입니다.")
@Schema(description = "임원진 역할", example = "동아리 운영 총괄")
private String role;

@Schema(description = "임원진 깃허브 이름", example = "DASOM")
private String github_username;

@Schema(description = "소속 팀", example = "president, tech, academic, pr, management")
private Team team;

private Integer sortOrder;

public ExecutiveEntity toEntity() {
return ExecutiveEntity.builder()
.name(this.name)
.position(this.position)
.githubUrl(this.githubUrl)
.role(this.role)
.githubUsername(this.github_username)
.team(this.team)
.sortOrder(this.sortOrder)
.build();
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package dmu.dasom.api.domain.executive.dto;

import dmu.dasom.api.domain.executive.enums.Team;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
Expand All @@ -22,6 +23,14 @@ public class ExecutiveResponseDto {
@Schema(description = "임원진 직책", example = "회장")
private String position;

@Schema(description = "임원진 깃허브", example = "https://github.com/dasom")
private String githubUrl;
@Schema(description = "수정할 임원진 역할", example = "동아리 운영 총괄")
private String role;

@Schema(description = "임원진 깃허브 이름", example = "DASOM")
private String github_username;

@Schema(description = "소속 팀", example = "president, tech, academic, pr, management")
private Team team;

private Integer sortOrder;
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package dmu.dasom.api.domain.executive.dto;

import dmu.dasom.api.domain.executive.enums.Team;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.Size;
import lombok.AllArgsConstructor;
Expand All @@ -19,6 +20,15 @@ public class ExecutiveUpdateRequestDto {
@Schema(description = "수정할 임원진 직책", example = "회장", nullable = true)
private String position;

@Schema(description = "수정할 임원진 깃허브 주소", example = "https://github.com/dasom", nullable = true)
private String githubUrl;
@Schema(description = "수정할 임원진 역할", example = "동아리 운영 총괄", nullable = true)
private String role;

@Schema(description = "임원진 깃허브 이름", example = "DASOM")
private String github_username;

@Schema(description = "소속 팀", example = "president, tech, academic, pr, management")
private Team team;

private Integer sortOrder;

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@
import dmu.dasom.api.domain.common.BaseEntity; // BaseEntity 상속 받음
import dmu.dasom.api.domain.executive.dto.ExecutiveListResponseDto;
import dmu.dasom.api.domain.executive.dto.ExecutiveResponseDto;
import dmu.dasom.api.domain.executive.dto.ExecutiveUpdateRequestDto;
import dmu.dasom.api.domain.executive.enums.Team;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.persistence.*; // JPA 어노테이션 패키지 ( DB 매핑 관련 )
import lombok.*; // 보일러플레이트 코드 자동 생성 라이브러리
import org.checkerframework.checker.units.qual.C;

@Getter
@Entity
Expand All @@ -28,15 +31,31 @@ public class ExecutiveEntity extends BaseEntity {
@Column(nullable=false, length = 50)
private String position;

// 깃허브 주소
@Column(nullable=false, length = 255)
private String githubUrl;
// 역할
@Column(nullable = false, length = 50)
private String role;

// 깃허브 이름
@Column(name = "github_username")
private String githubUsername;

// 소속팀 (president/tech/academic/pr/management)
@Enumerated(EnumType.STRING)
@Column(nullable = false, length = 20)
private Team team;

@Column(name = "sort_order", nullable = false)
@Builder.Default
private Integer sortOrder = 9999;

// 엔티티 업데이트 메소드
public void update(String name, String position, String githubUrl) {
this.name = name;
this.position = position;
this.githubUrl = githubUrl;
public void update(ExecutiveUpdateRequestDto dto) {
if (dto.getName() != null) this.name = dto.getName();
if (dto.getPosition() != null) this.position = dto.getPosition();
if (dto.getRole() != null) this.role = dto.getRole();
if (dto.getGithub_username() != null) this.githubUsername = dto.getGithub_username();
if (dto.getTeam() != null) this.team = dto.getTeam();
if (dto.getSortOrder() != null) this.sortOrder = dto.getSortOrder();
}

// 엔티티 -> DTO 변환 책임
Expand All @@ -45,7 +64,9 @@ public ExecutiveResponseDto toResponseDto() {
.id(this.id)
.name(this.name)
.position(this.position)
.githubUrl(this.githubUrl)
.role(this.role)
.github_username(this.githubUsername)
.team(this.team)
.build();
}

Expand All @@ -55,7 +76,9 @@ public ExecutiveListResponseDto toListResponseDto() {
.id(this.id)
.name(this.name)
.position(this.position)
.githubUrl(this.githubUrl)
.role(this.role)
.github_username(this.githubUsername)
.team(this.team)
.build();
}
}
16 changes: 16 additions & 0 deletions src/main/java/dmu/dasom/api/domain/executive/enums/Team.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package dmu.dasom.api.domain.executive.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

@AllArgsConstructor
@Getter
public enum Team {
PRESIDENT("president"),
TECH("tech"),
ACADEMIC("academic"),
MANAGEMENT("management")
;

private String name;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import dmu.dasom.api.domain.executive.entity.ExecutiveEntity;
import dmu.dasom.api.domain.executive.repository.ExecutiveRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

Expand All @@ -31,11 +32,13 @@ public ExecutiveResponseDto getExecutiveById(Long id) {
// 임원진 전체 조회
// 이름, 직책, 깃허브 주소 출력
public List<ExecutiveListResponseDto> getAllExecutives() {
List<ExecutiveEntity> executives = executiveRepository.findAll();
// 전체 조회 시 정렬
// 기준 sortOrder -> 직책 -> 이름
Sort sort = Sort.by(Sort.Direction.ASC, "sortOrder")
.and(Sort.by(Sort.Direction.ASC, "position"))
.and(Sort.by(Sort.Direction.DESC, "name"));

List<Long> executiveIds = executives.stream()
.map(ExecutiveEntity::getId)
.toList();
List<ExecutiveEntity> executives = executiveRepository.findAll(sort);

return executives.stream()
.map(executiveEntity -> executiveEntity.toListResponseDto())
Expand All @@ -62,7 +65,7 @@ public ExecutiveResponseDto updateExecutive(Long id, ExecutiveUpdateRequestDto r
ExecutiveEntity executive = executiveRepository.findById(id)
.orElseThrow(() -> new CustomException(ErrorCode.EXECUTIVE_NOT_FOUND));

executive.update(requestDto.getName(), requestDto.getPosition(), requestDto.getGithubUrl());
executive.update(requestDto);

return executive.toResponseDto();
}
Expand Down
Loading