Skip to content

Commit 9ec4a26

Browse files
committed
refactor: 필드 변경에 따른 코드 구조 변경 (DASOMBE-21)
1 parent a02e9bb commit 9ec4a26

File tree

6 files changed

+82
-20
lines changed

6 files changed

+82
-20
lines changed

src/main/java/dmu/dasom/api/domain/executive/dto/ExecutiveListResponseDto.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package dmu.dasom.api.domain.executive.dto;
22

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

25-
@Schema(description = "임원진 깃허브 주소", example = "https://github.com/dasom")
26-
private String githubUrl;
26+
@Schema(description = "수정할 임원진 역할", example = "동아리 운영 총괄", nullable = true)
27+
private String role;
28+
29+
@Schema(description = "임원진 깃허브 이름", example = "DASOM")
30+
private String github_username;
31+
32+
@Schema(description = "소속 팀", example = "president, tech, academic, pr, management")
33+
private Team team;
34+
35+
private Integer sortOrder;
2736

2837
}

src/main/java/dmu/dasom/api/domain/executive/dto/ExecutiveRequestDto.java

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package dmu.dasom.api.domain.executive.dto;
22

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

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

28-
private String githubUrl;
29+
@NotBlank(message = "임원진 역할은 필수 입력 사항입니다.")
30+
@Schema(description = "임원진 역할", example = "동아리 운영 총괄")
31+
private String role;
32+
33+
@Schema(description = "임원진 깃허브 이름", example = "DASOM")
34+
private String github_username;
35+
36+
@Schema(description = "소속 팀", example = "president, tech, academic, pr, management")
37+
private Team team;
38+
39+
private Integer sortOrder;
2940

3041
public ExecutiveEntity toEntity() {
3142
return ExecutiveEntity.builder()
3243
.name(this.name)
3344
.position(this.position)
34-
.githubUrl(this.githubUrl)
45+
.role
3546
.build();
3647
}
3748
}

src/main/java/dmu/dasom/api/domain/executive/dto/ExecutiveResponseDto.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package dmu.dasom.api.domain.executive.dto;
22

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

25-
@Schema(description = "임원진 깃허브", example = "https://github.com/dasom")
26-
private String githubUrl;
26+
@Schema(description = "수정할 임원진 역할", example = "동아리 운영 총괄")
27+
private String role;
28+
29+
@Schema(description = "임원진 깃허브 이름", example = "DASOM")
30+
private String github_username;
31+
32+
@Schema(description = "소속 팀", example = "president, tech, academic, pr, management")
33+
private Team team;
34+
35+
private Integer sortOrder;
2736
}

src/main/java/dmu/dasom/api/domain/executive/dto/ExecutiveUpdateRequestDto.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package dmu.dasom.api.domain.executive.dto;
22

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

22-
@Schema(description = "수정할 임원진 깃허브 주소", example = "https://github.com/dasom", nullable = true)
23-
private String githubUrl;
23+
@Schema(description = "수정할 임원진 역할", example = "동아리 운영 총괄", nullable = true)
24+
private String role;
25+
26+
@Schema(description = "임원진 깃허브 이름", example = "DASOM")
27+
private String github_username;
28+
29+
@Schema(description = "소속 팀", example = "president, tech, academic, pr, management")
30+
private Team team;
31+
32+
private Integer sortOrder;
33+
2434
}

src/main/java/dmu/dasom/api/domain/executive/entity/ExecutiveEntity.java

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@
33
import dmu.dasom.api.domain.common.BaseEntity; // BaseEntity 상속 받음
44
import dmu.dasom.api.domain.executive.dto.ExecutiveListResponseDto;
55
import dmu.dasom.api.domain.executive.dto.ExecutiveResponseDto;
6+
import dmu.dasom.api.domain.executive.dto.ExecutiveUpdateRequestDto;
7+
import dmu.dasom.api.domain.executive.enums.Team;
68
import io.swagger.v3.oas.annotations.media.Schema;
79
import jakarta.persistence.*; // JPA 어노테이션 패키지 ( DB 매핑 관련 )
810
import lombok.*; // 보일러플레이트 코드 자동 생성 라이브러리
11+
import org.checkerframework.checker.units.qual.C;
912

1013
@Getter
1114
@Entity
@@ -28,15 +31,31 @@ public class ExecutiveEntity extends BaseEntity {
2831
@Column(nullable=false, length = 50)
2932
private String position;
3033

31-
// 깃허브 주소
32-
@Column(nullable=false, length = 255)
33-
private String githubUrl;
34+
// 역할
35+
@Column(nullable = false, length = 50)
36+
private String role;
37+
38+
// 깃허브 이름
39+
@Column(name = "github_username")
40+
private String githubUsername;
41+
42+
// 소속팀 (president/tech/academic/pr/management)
43+
@Enumerated(EnumType.STRING)
44+
@Column(nullable = false, length = 20)
45+
private Team team;
46+
47+
@Column(name = "sort_order", nullable = false)
48+
@Builder.Default
49+
private Integer sortOrder = 9999;
3450

3551
// 엔티티 업데이트 메소드
36-
public void update(String name, String position, String githubUrl) {
37-
this.name = name;
38-
this.position = position;
39-
this.githubUrl = githubUrl;
52+
public void update(ExecutiveUpdateRequestDto dto) {
53+
if (dto.getName() != null) this.name = dto.getName();
54+
if (dto.getPosition() != null) this.position = dto.getPosition();
55+
if (dto.getRole() != null) this.role = dto.getRole();
56+
if (dto.getGithub_username() != null) this.githubUsername = dto.getGithub_username();
57+
if (dto.getTeam() != null) this.team = dto.getTeam();
58+
if (dto.getSortOrder() != null) this.sortOrder = dto.getSortOrder();
4059
}
4160

4261
// 엔티티 -> DTO 변환 책임
@@ -45,7 +64,9 @@ public ExecutiveResponseDto toResponseDto() {
4564
.id(this.id)
4665
.name(this.name)
4766
.position(this.position)
48-
.githubUrl(this.githubUrl)
67+
.role(this.role)
68+
.github_username(this.githubUsername)
69+
.team(this.team)
4970
.build();
5071
}
5172

@@ -55,7 +76,9 @@ public ExecutiveListResponseDto toListResponseDto() {
5576
.id(this.id)
5677
.name(this.name)
5778
.position(this.position)
58-
.githubUrl(this.githubUrl)
79+
.role(this.role)
80+
.github_username(this.githubUsername)
81+
.team(this.team)
5982
.build();
6083
}
6184
}

src/main/java/dmu/dasom/api/domain/executive/service/ExecutiveServiceImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public ExecutiveResponseDto updateExecutive(Long id, ExecutiveUpdateRequestDto r
6262
ExecutiveEntity executive = executiveRepository.findById(id)
6363
.orElseThrow(() -> new CustomException(ErrorCode.EXECUTIVE_NOT_FOUND));
6464

65-
executive.update(requestDto.getName(), requestDto.getPosition(), requestDto.getGithubUrl());
65+
executive.update(requestDto);
6666

6767
return executive.toResponseDto();
6868
}

0 commit comments

Comments
 (0)