From 18edf7d13bc483922980d08baad99b6777f02b83 Mon Sep 17 00:00:00 2001 From: kssumin <201566@jnu.ac.kr> Date: Sun, 3 Nov 2024 11:55:20 +0900 Subject: [PATCH 1/2] =?UTF-8?q?chore=20:=20lint=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/util/ProgramInitializer.java | 75 ++++----- .../target/application/model/AttendModel.java | 7 +- .../application/service/AttendService.java | 7 +- .../util/PresentationInitializer.java | 148 +++++++++--------- .../application/util/TeamInitializer.java | 58 ++++--- .../eeos/team/persistence/TeamEntity.java | 4 +- .../eeos/team/persistence/TeamRepository.java | 1 - 7 files changed, 152 insertions(+), 148 deletions(-) diff --git a/eeos/src/main/java/com/blackcompany/eeos/program/application/util/ProgramInitializer.java b/eeos/src/main/java/com/blackcompany/eeos/program/application/util/ProgramInitializer.java index fbdef24b..d3ea1520 100644 --- a/eeos/src/main/java/com/blackcompany/eeos/program/application/util/ProgramInitializer.java +++ b/eeos/src/main/java/com/blackcompany/eeos/program/application/util/ProgramInitializer.java @@ -3,51 +3,54 @@ import com.blackcompany.eeos.program.application.model.ProgramAttendMode; import com.blackcompany.eeos.program.persistence.ProgramEntity; import com.blackcompany.eeos.program.persistence.ProgramRepository; +import java.util.List; +import java.util.stream.Collectors; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.boot.ApplicationArguments; import org.springframework.boot.ApplicationRunner; import org.springframework.stereotype.Component; -import java.util.List; -import java.util.stream.Collectors; - @Component @RequiredArgsConstructor @Slf4j public class ProgramInitializer implements ApplicationRunner { - private final ProgramRepository programRepository; - private final String defaultUrl = "https://github.com/JNU-econovation/weekly_presentation/tree/2024-1/2024-1/A_team/1st"; - - @Override - public void run(ApplicationArguments args) throws Exception { - System.out.println("------------Program Initializer----------"); - List programs = getPrograms(); - - if(programs.isEmpty()) return; - - programs = programs.stream() - .map(program -> { - if(program.getGithubUrl()==null){ - return program.toBuilder().githubUrl(defaultUrl).build(); - } - return program; - }) - .map(program -> { - if(program.getAttendMode()==null){ - return program.toBuilder().attendMode(ProgramAttendMode.END).build(); - } - - return program; - }) - .collect(Collectors.toList()); - - programRepository.saveAll(programs); - System.out.println("----------------------------------------------"); - } - - private List getPrograms(){ - return programRepository.findAll(); - } + private final ProgramRepository programRepository; + private final String defaultUrl = + "https://github.com/JNU-econovation/weekly_presentation/tree/2024-1/2024-1/A_team/1st"; + + @Override + public void run(ApplicationArguments args) throws Exception { + System.out.println("------------Program Initializer----------"); + List programs = getPrograms(); + + if (programs.isEmpty()) return; + + programs = + programs.stream() + .map( + program -> { + if (program.getGithubUrl() == null) { + return program.toBuilder().githubUrl(defaultUrl).build(); + } + return program; + }) + .map( + program -> { + if (program.getAttendMode() == null) { + return program.toBuilder().attendMode(ProgramAttendMode.END).build(); + } + + return program; + }) + .collect(Collectors.toList()); + + programRepository.saveAll(programs); + System.out.println("----------------------------------------------"); + } + + private List getPrograms() { + return programRepository.findAll(); + } } diff --git a/eeos/src/main/java/com/blackcompany/eeos/target/application/model/AttendModel.java b/eeos/src/main/java/com/blackcompany/eeos/target/application/model/AttendModel.java index b45dc640..1c947aeb 100644 --- a/eeos/src/main/java/com/blackcompany/eeos/target/application/model/AttendModel.java +++ b/eeos/src/main/java/com/blackcompany/eeos/target/application/model/AttendModel.java @@ -2,8 +2,6 @@ import com.blackcompany.eeos.common.application.model.MemberIdModel; import com.blackcompany.eeos.common.support.AbstractModel; -import com.blackcompany.eeos.target.application.exception.DeniedChangeAttendException; -import com.blackcompany.eeos.target.application.exception.DeniedSaveAttendException; import com.blackcompany.eeos.target.application.exception.NotSameBeforeAttendStatusException; import java.util.List; import java.util.stream.Collectors; @@ -35,8 +33,9 @@ public String getStatus() { return status.getStatus(); } - public boolean isAttended(){ - return (!this.status.equals(AttendStatus.NONRESPONSE) && !this.status.equals(AttendStatus.NONRELATED)); + public boolean isAttended() { + return (!this.status.equals(AttendStatus.NONRESPONSE) + && !this.status.equals(AttendStatus.NONRELATED)); } public boolean isRelated() { diff --git a/eeos/src/main/java/com/blackcompany/eeos/target/application/service/AttendService.java b/eeos/src/main/java/com/blackcompany/eeos/target/application/service/AttendService.java index 6dda6829..771a5e93 100644 --- a/eeos/src/main/java/com/blackcompany/eeos/target/application/service/AttendService.java +++ b/eeos/src/main/java/com/blackcompany/eeos/target/application/service/AttendService.java @@ -130,9 +130,10 @@ public QueryAttendActiveStatusResponse getAttendInfo(Long programId, String acti } private void validateAttend(ProgramModel programModel, AttendModel attendModel) { - if (programModel.getAttendMode().equals(ProgramAttendMode.END)) throw new NotStartAttendException(); - if(attendModel.isAttended()) throw new DeniedChangeAttendException(); - if(!attendModel.isRelated()) throw new DeniedSaveAttendException(); + if (programModel.getAttendMode().equals(ProgramAttendMode.END)) + throw new NotStartAttendException(); + if (attendModel.isAttended()) throw new DeniedChangeAttendException(); + if (!attendModel.isRelated()) throw new DeniedSaveAttendException(); } private ProgramModel findProgram(final Long programId) { diff --git a/eeos/src/main/java/com/blackcompany/eeos/target/application/util/PresentationInitializer.java b/eeos/src/main/java/com/blackcompany/eeos/target/application/util/PresentationInitializer.java index 3591e857..ad6e59d6 100644 --- a/eeos/src/main/java/com/blackcompany/eeos/target/application/util/PresentationInitializer.java +++ b/eeos/src/main/java/com/blackcompany/eeos/target/application/util/PresentationInitializer.java @@ -7,6 +7,10 @@ import com.blackcompany.eeos.team.application.exception.NotFoundTeamException; import com.blackcompany.eeos.team.persistence.TeamEntity; import com.blackcompany.eeos.team.persistence.TeamRepository; +import java.util.Arrays; +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; @@ -14,81 +18,83 @@ import org.springframework.boot.ApplicationRunner; import org.springframework.stereotype.Component; -import java.util.Arrays; -import java.util.List; -import java.util.Set; -import java.util.stream.Collectors; - // 기존에 저장된 Program과 Team을 매핑하는 구조 @Component @RequiredArgsConstructor @Slf4j public class PresentationInitializer implements ApplicationRunner { - private final PresentationRepository presentationRepository; - private final ProgramRepository programRepository; - private final TeamRepository teamRepository; - - @Value("${eeos.team.list}") - private String teamList; - - @Override - public void run(ApplicationArguments args) throws Exception { - System.out.println("------------Presentation Initializer----------"); - Set programs = getPrograms().stream().map(ProgramEntity::getId).collect(Collectors.toSet()); - - if(programs.isEmpty()) return; - - Set presentations = getPresentations().stream() - .map(PresentationEntity::getProgramId) - .collect(Collectors.toSet()); - - Set target = programs.stream() - .filter(programId -> !presentations.contains(programId)) - .collect(Collectors.toSet()); - - List teams= getTeams(); - teams.forEach(team->log.info(team.getName())); - - target.forEach(targetId -> - { - Set entities = - teams.stream() - .map(TeamEntity::getId) - .map(teamId -> PresentationEntity.builder() - .teamId(teamId) - .programId(targetId) - .build()) - .collect(Collectors.toSet()); - presentationRepository.saveAll(entities); - }); - - System.out.println("----------------------------------------------"); - } - - private List getTeamList(){ - return Arrays.stream(teamList.split(",")).toList(); - } - - private List getPrograms(){ - return programRepository.findAll(); - } - - private List getTeams(){ - List teams = getTeamList(); - try { - return teamRepository.findAllTeams().stream().filter(team -> teams.contains(team.getName())).toList(); - } catch (NotFoundTeamException e){ - return createTeams(); - } - } - - private List createTeams(){ - Set teams = getTeamList().stream().map(team -> TeamEntity.builder().name(team).status(false).build()).collect(Collectors.toSet()); - return teamRepository.saveAll(teams); - } - - private List getPresentations(){ - return presentationRepository.findAll(); - } + private final PresentationRepository presentationRepository; + private final ProgramRepository programRepository; + private final TeamRepository teamRepository; + + @Value("${eeos.team.list}") + private String teamList; + + @Override + public void run(ApplicationArguments args) throws Exception { + System.out.println("------------Presentation Initializer----------"); + Set programs = + getPrograms().stream().map(ProgramEntity::getId).collect(Collectors.toSet()); + + if (programs.isEmpty()) return; + + Set presentations = + getPresentations().stream() + .map(PresentationEntity::getProgramId) + .collect(Collectors.toSet()); + + Set target = + programs.stream() + .filter(programId -> !presentations.contains(programId)) + .collect(Collectors.toSet()); + + List teams = getTeams(); + teams.forEach(team -> log.info(team.getName())); + + target.forEach( + targetId -> { + Set entities = + teams.stream() + .map(TeamEntity::getId) + .map( + teamId -> + PresentationEntity.builder().teamId(teamId).programId(targetId).build()) + .collect(Collectors.toSet()); + presentationRepository.saveAll(entities); + }); + + System.out.println("----------------------------------------------"); + } + + private List getTeamList() { + return Arrays.stream(teamList.split(",")).toList(); + } + + private List getPrograms() { + return programRepository.findAll(); + } + + private List getTeams() { + List teams = getTeamList(); + try { + return teamRepository.findAllTeams().stream() + .filter(team -> teams.contains(team.getName())) + .toList(); + } catch (NotFoundTeamException e) { + return createTeams(); + } + } + + private List createTeams() { + Set teams = + getTeamList().stream() + .map(team -> TeamEntity.builder().name(team).status(false).build()) + .collect(Collectors.toSet()); + return teamRepository.saveAll(teams); + } + + private List getPresentations() { + return presentationRepository.findAll(); + } } diff --git a/eeos/src/main/java/com/blackcompany/eeos/team/application/util/TeamInitializer.java b/eeos/src/main/java/com/blackcompany/eeos/team/application/util/TeamInitializer.java index f905c19e..391ba759 100644 --- a/eeos/src/main/java/com/blackcompany/eeos/team/application/util/TeamInitializer.java +++ b/eeos/src/main/java/com/blackcompany/eeos/team/application/util/TeamInitializer.java @@ -2,6 +2,9 @@ import com.blackcompany.eeos.team.persistence.TeamEntity; import com.blackcompany.eeos.team.persistence.TeamRepository; +import java.util.Arrays; +import java.util.Set; +import java.util.stream.Collectors; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; @@ -9,40 +12,35 @@ import org.springframework.boot.ApplicationRunner; import org.springframework.stereotype.Component; -import java.util.Arrays; -import java.util.Set; -import java.util.stream.Collectors; - - // 기존 데이터베이스와의 데이터 정합성을 위한 클래스 @RequiredArgsConstructor @Slf4j @Component public class TeamInitializer implements ApplicationRunner { - private final TeamRepository teamRepository; - - @Value("${eeos.team.list}") - private String teamList; - - @Override - public void run(ApplicationArguments args) throws Exception { - System.out.println("-----------Team Initializer-----------"); - Arrays.stream(teamList.split(",")).forEach(log::info); - try { - Set newTeams = Arrays.stream(teamList.split(",")) - .map(teamName -> TeamEntity.builder().name(teamName).status(false).build()) - .collect(Collectors.toSet()); - teamRepository.saveAll(newTeams); - log.info("임시 팀이 생성되었습니다."); - } catch (Exception e){ - log.error("임시 팀이 생성되지 않았습니다."); - } - System.out.println("---------------------------------------"); - - } - - private boolean isEmptyTable(){ - return teamRepository.findAllTeams().isEmpty(); - } + private final TeamRepository teamRepository; + + @Value("${eeos.team.list}") + private String teamList; + + @Override + public void run(ApplicationArguments args) throws Exception { + System.out.println("-----------Team Initializer-----------"); + Arrays.stream(teamList.split(",")).forEach(log::info); + try { + Set newTeams = + Arrays.stream(teamList.split(",")) + .map(teamName -> TeamEntity.builder().name(teamName).status(false).build()) + .collect(Collectors.toSet()); + teamRepository.saveAll(newTeams); + log.info("임시 팀이 생성되었습니다."); + } catch (Exception e) { + log.error("임시 팀이 생성되지 않았습니다."); + } + System.out.println("---------------------------------------"); + } + + private boolean isEmptyTable() { + return teamRepository.findAllTeams().isEmpty(); + } } diff --git a/eeos/src/main/java/com/blackcompany/eeos/team/persistence/TeamEntity.java b/eeos/src/main/java/com/blackcompany/eeos/team/persistence/TeamEntity.java index 4004494d..6ba617b7 100644 --- a/eeos/src/main/java/com/blackcompany/eeos/team/persistence/TeamEntity.java +++ b/eeos/src/main/java/com/blackcompany/eeos/team/persistence/TeamEntity.java @@ -30,9 +30,7 @@ public class TeamEntity extends BaseEntity { @Column(unique = true, name = ENTITY_PREFIX + "_name", nullable = false) private String name; - @Column( - name = ENTITY_PREFIX + "_status", - nullable = false) + @Column(name = ENTITY_PREFIX + "_status", nullable = false) @Builder.Default private boolean status = true; // 현학기 활동팀 1, 아니면 0 diff --git a/eeos/src/main/java/com/blackcompany/eeos/team/persistence/TeamRepository.java b/eeos/src/main/java/com/blackcompany/eeos/team/persistence/TeamRepository.java index 0d4aba3c..167d141d 100644 --- a/eeos/src/main/java/com/blackcompany/eeos/team/persistence/TeamRepository.java +++ b/eeos/src/main/java/com/blackcompany/eeos/team/persistence/TeamRepository.java @@ -20,7 +20,6 @@ public interface TeamRepository extends JpaRepository { @Query("SELECT T FROM TeamEntity T WHERE T.status = true order by T.name") List findAllActiveTeams(); - @Query("SELECT T FROM TeamEntity T ORDER BY T.name") List findAllTeams(); } From 8e02a0f83cd19c906f2c051e1785bf2d8a1fa792 Mon Sep 17 00:00:00 2001 From: Bellmin <71818636+rlajm1203@users.noreply.github.com> Date: Mon, 4 Nov 2024 22:50:43 +0900 Subject: [PATCH 2/2] =?UTF-8?q?[CHORE]=20CI=20=ED=8C=A8=EC=8A=A4=EB=A5=BC?= =?UTF-8?q?=20=EC=9C=84=ED=95=9C=20env=20=EC=B4=88=EA=B8=B0=20=EC=84=B8?= =?UTF-8?q?=ED=8C=85=20(#178)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: bellmin --- eeos/src/main/resources/env.properties | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 eeos/src/main/resources/env.properties diff --git a/eeos/src/main/resources/env.properties b/eeos/src/main/resources/env.properties new file mode 100644 index 00000000..f2320787 --- /dev/null +++ b/eeos/src/main/resources/env.properties @@ -0,0 +1,19 @@ +SLACK_CLIENT_ID= +SLACK_CLIENT_SECRET= +CORS_URL= +COOKIE_TOKEN_DOMAIN= +COOKIE_TOKEN_PATH= +ADMIN_NAME= +ADMIN_LOGIN_ID= +ADMIN_PASSWORD= +AT_TOKEN_SECRET_KEY= +RT_TOKEN_SECRET_KEY= +AT_VALID_TIME= +RT_VALID_TIME= +BLACK_COMPANY_EEOS_BOT_TOKEN= +BLACK_COMPANY_TEST_CHANNEL_ID= +BLACK_COMPANY_NOTIFICATION_CHANNEL_ID= +ECONOVATION_NOTIFICATION_CHANNEL_ID= +ECONOVATION_SMALL_TALK_CHANNEL_ID= +ECONOVATION_EEOS_BOT_TOKEN= +ECONOVATION_TEAM_LIST=