Skip to content

Commit 6702ee6

Browse files
authored
Merge pull request #244 from inha-iesw/develop
v1.1.9 Release
2 parents 62edde4 + 501a965 commit 6702ee6

File tree

9 files changed

+299
-787
lines changed

9 files changed

+299
-787
lines changed

README.md

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,13 @@
1313
## 목차
1414

1515
1. [**웹 서비스 소개**](#1)
16-
1. [**기술 스택**](#2)
17-
1. [**주요 기능**](#3)
18-
1. [**프로젝트 구성도**](#4)
19-
1. [**개발 팀 소개**](#5)
20-
1. [**개발 기간 및 일정**](#6)
21-
1. [**실행 방법**](#7)
16+
2. [**기술 스택**](#2)
17+
3. [**주요 기능**](#3)
18+
4. [**프로젝트 구성도**](#4)
19+
5. [**트러블 슈팅**](#5)
20+
6. [**개발 팀 소개**](#6)
21+
7. [**개발 기간 및 일정**](#7)
22+
8. [**실행 방법**](#8)
2223

2324
<br />
2425

@@ -117,8 +118,19 @@ Local 혹은 GitHub과 연동하여 프로젝트를 관리하고, 멘토링, 특
117118
<br />
118119

119120

121+
<div id='5'></div>
120122

121-
<div id="5"></div>
123+
## 🔫 트러블 슈팅
124+
125+
[**🔗 동시성 문제 해결기: 좋아요 기능에서 경험한 Redis와 비관적 락**](https://velog.io/@rbgur5288/I-OSS-%EB%8F%99%EC%8B%9C%EC%84%B1-%EB%AC%B8%EC%A0%9C-%ED%95%B4%EA%B2%B0%EA%B8%B0-%EC%A2%8B%EC%95%84%EC%9A%94-%EA%B8%B0%EB%8A%A5%EC%97%90%EC%84%9C-%EA%B2%BD%ED%97%98%ED%95%9C-Redis%EC%99%80-%EB%B9%84%EA%B4%80%EC%A0%81-%EB%9D%BD) 👈
126+
<br>
127+
128+
[**🔗 통계 최적화 여정: 실시간 쿼리에서 통합 통계 테이블로의 전환**](https://velog.io/@rbgur5288/I-OSS-%ED%86%B5%EA%B3%84-%EC%B5%9C%EC%A0%81%ED%99%94-%EC%97%AC%EC%A0%95-%EC%8B%A4%EC%8B%9C%EA%B0%84-%EC%BF%BC%EB%A6%AC%EC%97%90%EC%84%9C-%ED%86%B5%ED%95%A9-%ED%86%B5%EA%B3%84-%ED%85%8C%EC%9D%B4%EB%B8%94%EB%A1%9C%EC%9D%98-%EC%A0%84%ED%99%98) 👈
129+
<br>
130+
131+
(추가 예정)
132+
133+
<div id="6"></div>
122134

123135
## 👪 개발 팀 소개
124136

@@ -150,20 +162,19 @@ Local 혹은 GitHub과 연동하여 프로젝트를 관리하고, 멘토링, 특
150162
</table>
151163

152164

153-
<div id="6"></div>
165+
<div id="7"></div>
154166

155167
## 📅 개발 기간
156168

157169
24.08.12. ~ 운영 관리 중
158170

159171
<br />
160172

161-
<div id='7'></div>
173+
<div id='8'></div>
162174

163175
## 💻 실행 방법
164176

165177

166-
167178
### Server 실행
168179

169180
1. **원격 저장소 복제**
@@ -299,3 +310,4 @@ $ java -jar [파일명].jar
299310

300311
<br />
301312

313+

src/main/java/inha/git/project/domain/repository/ProjectJpaRepository.java

Lines changed: 63 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package inha.git.project.domain.repository;
22

33

4-
import inha.git.common.BaseEntity;
54
import inha.git.field.domain.Field;
5+
import inha.git.mapping.domain.ProjectField;
66
import inha.git.project.domain.Project;
77
import inha.git.semester.domain.Semester;
88
import inha.git.user.domain.User;
@@ -17,25 +17,83 @@
1717
import java.util.List;
1818
import java.util.Optional;
1919

20+
import static inha.git.common.BaseEntity.*;
21+
2022

2123
/**
2224
* ProjectJpaRepository는 Project 엔티티에 대한 데이터 액세스 기능을 제공.
2325
*/
2426
public interface ProjectJpaRepository extends JpaRepository<Project, Integer> {
2527

2628

27-
Optional<Project> findByIdAndState(Integer projectIdx, BaseEntity.State state);
29+
Optional<Project> findByIdAndState(Integer projectIdx, State state);
2830

2931

3032

31-
long countByUserAndSemesterAndProjectFields_FieldAndState(User user, Semester semester, Field field, BaseEntity.State state);
33+
long countByUserAndSemesterAndProjectFields_FieldAndState(User user, Semester semester, Field field, State state);
3234

3335
@Lock(LockModeType.PESSIMISTIC_WRITE)
3436
@QueryHints({@QueryHint(name = "javax.persistence.lock.timeout", value = "3000")})
3537
@Query("SELECT p FROM Project p WHERE p.id = :id AND p.state = :state")
36-
Optional<Project> findByIdAndStateWithPessimisticLock(@Param("id") Integer id, @Param("state") BaseEntity.State state);
38+
Optional<Project> findByIdAndStateWithPessimisticLock(@Param("id") Integer id, @Param("state") State state);
39+
40+
List<Project> findAllByStateOrderById(State state);
41+
@Query("SELECT DISTINCT p FROM Project p " +
42+
"JOIN FETCH p.user u " +
43+
"JOIN FETCH u.userDepartments ud " +
44+
"JOIN FETCH ud.department d " +
45+
"JOIN FETCH d.college c " +
46+
"JOIN FETCH p.semester s " +
47+
"JOIN FETCH p.category cat " +
48+
"WHERE p.state = :state " +
49+
"ORDER BY c.id ASC, d.id ASC, u.userNumber ASC")
50+
List<Project> findAllByState(@Param("state") State state);
51+
52+
@Query("SELECT DISTINCT p FROM Project p " +
53+
"JOIN FETCH p.user u " +
54+
"JOIN FETCH u.userDepartments ud " +
55+
"JOIN FETCH ud.department d " +
56+
"JOIN FETCH d.college c " +
57+
"JOIN FETCH p.semester s " +
58+
"JOIN FETCH p.category cat " +
59+
"WHERE c.id = :collegeId " +
60+
"AND p.state = :state " +
61+
"ORDER BY c.id ASC, d.id ASC, u.userNumber ASC")
62+
List<Project> findAllByUserCollegeIdAndState(
63+
@Param("collegeId") Integer collegeId,
64+
@Param("state") State state);
65+
66+
@Query("SELECT DISTINCT p FROM Project p " +
67+
"JOIN FETCH p.user u " +
68+
"JOIN FETCH u.userDepartments ud " +
69+
"JOIN FETCH ud.department d " +
70+
"JOIN FETCH d.college c " +
71+
"JOIN FETCH p.semester s " +
72+
"JOIN FETCH p.category cat " +
73+
"WHERE d.id = :departmentId " +
74+
"AND p.state = :state " +
75+
"ORDER BY c.id ASC, d.id ASC, u.userNumber ASC")
76+
List<Project> findAllByUserDepartmentIdAndState(
77+
@Param("departmentId") Integer departmentId,
78+
@Param("state") State state);
3779

80+
@Query("SELECT DISTINCT p FROM Project p " +
81+
"JOIN FETCH p.user u " +
82+
"JOIN FETCH u.userDepartments ud " +
83+
"JOIN FETCH ud.department d " +
84+
"JOIN FETCH d.college c " +
85+
"JOIN FETCH p.semester s " +
86+
"JOIN FETCH p.category cat " +
87+
"WHERE u.id = :userId " +
88+
"AND p.state = :state " +
89+
"ORDER BY p.createdAt DESC")
90+
List<Project> findAllByUserIdAndState(
91+
@Param("userId") Integer userId,
92+
@Param("state") State state);
3893

39-
List<Project> findAllByStateOrderById(BaseEntity.State state);
94+
@Query("SELECT DISTINCT pf FROM ProjectField pf " +
95+
"JOIN FETCH pf.field " +
96+
"WHERE pf.project.id IN :projectIds")
97+
List<ProjectField> findProjectFieldsByProjectIds(@Param("projectIds") List<Integer> projectIds);
4098

4199
}

src/main/java/inha/git/statistics/api/controller/StatisticsController.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,15 @@
88
import inha.git.statistics.api.service.StatisticsExcelService;
99
import inha.git.statistics.api.service.StatisticsMigrationService;
1010
import inha.git.statistics.api.service.StatisticsService;
11+
import inha.git.statistics.domain.enums.StatisticsType;
12+
import inha.git.user.domain.User;
1113
import io.swagger.v3.oas.annotations.Operation;
1214
import io.swagger.v3.oas.annotations.tags.Tag;
1315
import jakarta.servlet.http.HttpServletResponse;
1416
import lombok.RequiredArgsConstructor;
1517
import lombok.extern.slf4j.Slf4j;
1618
import org.springframework.security.access.prepost.PreAuthorize;
19+
import org.springframework.security.core.annotation.AuthenticationPrincipal;
1720
import org.springframework.validation.annotation.Validated;
1821
import org.springframework.web.bind.annotation.*;
1922

@@ -87,13 +90,14 @@ public BaseResponse<QuestionStatisticsResponse> getQuestionStatistics(@Validated
8790
* 엑셀 다운로드 API
8891
*
8992
* @param response HttpServletResponse
93+
* @param statisticsType 통계 타입
9094
*/
9195
@GetMapping("/export/excel")
9296
@PreAuthorize("hasAnyAuthority('professor:read', 'admin:read')")
9397
@Operation(summary = "엑셀 다운로드 API", description = "모든 통계 데이터를 엑셀 파일로 다운로드합니다.")
94-
public void exportToExcel(HttpServletResponse response) {
95-
log.info("엑셀 다운로드 요청");
96-
statisticsExcelService.exportToExcelFile(response);
98+
public void exportToExcel(@AuthenticationPrincipal User user, HttpServletResponse response, @RequestParam(value = "statisticsType", defaultValue = "TOTAL") StatisticsType statisticsType, @RequestParam(value = "filterId", required = false) Integer filterId) {
99+
log.info("엑셀 다운로드 요청: {}", user.getName());
100+
statisticsExcelService.exportToExcelFile(response, statisticsType, filterId);
97101
}
98102

99103
/**
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
package inha.git.statistics.api.service;
22

3+
import inha.git.statistics.domain.enums.StatisticsType;
34
import jakarta.servlet.http.HttpServletResponse;
45

56
public interface StatisticsExcelService {
67

7-
void exportToExcelFile(HttpServletResponse response);
8+
void exportToExcelFile(HttpServletResponse response, StatisticsType statisticsType, Integer filterId);
89

910

1011
}

0 commit comments

Comments
 (0)