Skip to content

Commit 62edde4

Browse files
authored
Merge pull request #242 from inha-iesw/develop
v1.1.8 Release
2 parents 920fcee + ea006b0 commit 62edde4

File tree

55 files changed

+1230
-2968
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+1230
-2968
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ out/
4040
application-local.yml
4141
application-dev.yml
4242
application-prod.yml
43+
application-test.yml
4344

4445
src/main/generated/
4546

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ plugins {
55
}
66

77
group = 'inha'
8-
version = '1.0.8'
8+
version = '1.2.0'
99

1010
java {
1111
toolchain {

src/main/java/inha/git/admin/api/service/AdminSearchServiceImpl.java

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99
import inha.git.mapping.domain.UserDepartment;
1010
import inha.git.mapping.domain.repository.UserDepartmentJpaRepository;
1111
import inha.git.report.api.controller.dto.response.SearchReportResponse;
12-
import inha.git.statistics.domain.UserStatistics;
13-
import inha.git.statistics.domain.repository.UserStatisticsJpaRepository;
12+
import inha.git.statistics.domain.Statistics;
13+
import inha.git.statistics.domain.enums.StatisticsType;
14+
import inha.git.statistics.domain.repository.StatisticsJpaRepository;
1415
import inha.git.user.api.mapper.UserMapper;
1516
import inha.git.user.domain.Company;
1617
import inha.git.user.domain.User;
@@ -42,8 +43,8 @@ public class AdminSearchServiceImpl implements AdminSearchService {
4243
private final UserJpaRepository userJpaRepository;
4344
private final UserMapper userMapper;
4445
private final CompanyJpaRepository companyJpaRepository;
45-
private final UserStatisticsJpaRepository userStatisticsJpaRepository;
4646
private final UserDepartmentJpaRepository userDepartmentJpaRepository;
47+
private final StatisticsJpaRepository statisticsJpaRepository;
4748

4849
/**
4950
* 관리자 사용자 조회
@@ -113,17 +114,19 @@ public inha.git.user.api.controller.dto.response.SearchUserResponse getAdminUser
113114
.orElseThrow(() -> new BaseException(NOT_COMPANY));
114115
return userMapper.toSearchCompanyUserResponse(user, position, company);
115116
} else {
116-
List<UserStatistics> userStatistics = userStatisticsJpaRepository.findByUser(user)
117-
.orElseThrow(() -> new BaseException(USER_STATISTICS_NOT_FOUND));
118-
int totalProjectCount = userStatistics.stream().mapToInt(UserStatistics::getProjectCount).sum();
119-
int totalQuestionCount = userStatistics.stream().mapToInt(UserStatistics::getQuestionCount).sum();
120-
int totalTeamCount = userStatistics.stream().mapToInt(UserStatistics::getTeamCount).sum();
117+
List<Statistics> userStatistics = statisticsJpaRepository.findByStatisticsTypeAndTargetId(StatisticsType.USER, user.getId().longValue());
118+
int localProjectCount = userStatistics.stream().mapToInt(Statistics::getLocalProjectCount).sum();
119+
int githubProjectCount = userStatistics.stream().mapToInt(Statistics::getGithubProjectCount).sum();
120+
int totalQuestionCount = userStatistics.stream().mapToInt(Statistics::getQuestionCount).sum();
121+
int totalTeamCount = userStatistics.stream().mapToInt(Statistics::getProjectParticipationCount).sum(); // 팀 참여 수는 프로젝트 참여 수로 대체
122+
123+
121124
List<SearchDepartmentResponse> searchDepartmentResponses = userMapper.departmentsToSearchDepartmentResponses(userDepartmentJpaRepository.findByUserId(user.getId())
122125
.orElseThrow(() -> new BaseException(USER_STATISTICS_NOT_FOUND))
123126
.stream()
124127
.map(UserDepartment::getDepartment)
125128
.toList());
126-
return userMapper.toSearchNonCompanyUserResponse(user, totalProjectCount, totalQuestionCount, totalTeamCount, searchDepartmentResponses, position, user.getGithubToken() != null);
129+
return userMapper.toSearchNonCompanyUserResponse(user, localProjectCount + githubProjectCount, totalQuestionCount, totalTeamCount, searchDepartmentResponses, position, user.getGithubToken() != null);
127130
}
128131
}
129132

src/main/java/inha/git/category/mapper/CategoryMapper.java

Lines changed: 0 additions & 130 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,10 @@
33
import inha.git.category.controller.dto.request.CreateCategoryRequest;
44
import inha.git.category.controller.dto.response.SearchCategoryResponse;
55
import inha.git.category.domain.Category;
6-
import inha.git.college.domain.College;
7-
import inha.git.department.domain.Department;
8-
import inha.git.field.domain.Field;
9-
import inha.git.semester.domain.Semester;
10-
import inha.git.statistics.domain.CollegeStatistics;
11-
import inha.git.statistics.domain.DepartmentStatistics;
12-
import inha.git.statistics.domain.UserCountStatistics;
13-
import inha.git.statistics.domain.UserStatistics;
14-
import inha.git.statistics.domain.id.CollegeStatisticsStatisticsId;
15-
import inha.git.statistics.domain.id.DepartmentStatisticsId;
16-
import inha.git.statistics.domain.id.UserCountStatisticsId;
17-
import inha.git.statistics.domain.id.UserStatisticsId;
18-
import inha.git.user.domain.User;
196
import org.mapstruct.Mapper;
207
import org.mapstruct.Mapping;
218
import org.mapstruct.NullValuePropertyMappingStrategy;
229

23-
import java.util.ArrayList;
2410
import java.util.List;
2511

2612
/**
@@ -38,121 +24,5 @@ public interface CategoryMapper {
3824

3925
List<SearchCategoryResponse> categoriesToSearchCategoryResponses(List<Category> categoryList);
4026

41-
default List<CollegeStatistics> createCollegeStatistics(Category category, List<College> colleges, List<Field> fields, List<Semester> semesters) {
42-
List<CollegeStatistics> statisticsList = new ArrayList<>();
43-
for (College college : colleges) {
44-
for (Semester semester : semesters) {
45-
for (Field field : fields) {
46-
CollegeStatistics statistics = CollegeStatistics.builder()
47-
.id(new CollegeStatisticsStatisticsId(college.getId(), semester.getId(), field.getId(), category.getId()))
48-
.college(college)
49-
.semester(semester)
50-
.field(field)
51-
.category(category)
52-
.projectCount(0)
53-
.githubProjectCount(0)
54-
.questionCount(0)
55-
.problemCount(0)
56-
.teamCount(0)
57-
.patentCount(0)
58-
.projectUserCount(0)
59-
.questionUserCount(0)
60-
.problemUserCount(0)
61-
.teamUserCount(0)
62-
.patentUserCount(0)
63-
.problemParticipationCount(0)
64-
.build();
65-
66-
statisticsList.add(statistics);
67-
}
68-
}
69-
}
70-
return statisticsList;
71-
}
72-
73-
default List<DepartmentStatistics> createDepartmentStatistics(Category category, List<Department> departments, List<Field> fields, List<Semester> semesters) {
74-
List<DepartmentStatistics> statisticsList = new ArrayList<>();
75-
for (Department department : departments) {
76-
for (Semester semester : semesters) {
77-
for (Field field : fields) {
78-
DepartmentStatistics statistics = DepartmentStatistics.builder()
79-
.id(new DepartmentStatisticsId(department.getId(), semester.getId(), field.getId(), category.getId()))
80-
.department(department)
81-
.semester(semester)
82-
.field(field)
83-
.category(category)
84-
.projectCount(0)
85-
.githubProjectCount(0)
86-
.questionCount(0)
87-
.problemCount(0)
88-
.teamCount(0)
89-
.patentCount(0)
90-
.projectUserCount(0)
91-
.questionUserCount(0)
92-
.problemUserCount(0)
93-
.teamUserCount(0)
94-
.patentUserCount(0)
95-
.problemParticipationCount(0)
96-
.build();
97-
statisticsList.add(statistics);
98-
}
99-
}
100-
}
101-
return statisticsList;
102-
}
103-
104-
default List<UserStatistics> createUserStatistics(Category category, List<User> users, List<Field> fields, List<Semester> semesters) {
105-
List<UserStatistics> statisticsList = new ArrayList<>();
106-
for (User user : users) {
107-
for (Semester semester : semesters) {
108-
for (Field field : fields) {
109-
UserStatistics statistics = UserStatistics.builder()
110-
.id(new UserStatisticsId(user.getId(), semester.getId(), field.getId(), category.getId()))
111-
.user(user)
112-
.semester(semester)
113-
.field(field)
114-
.category(category)
115-
.projectCount(0)
116-
.githubProjectCount(0)
117-
.questionCount(0)
118-
.problemCount(0)
119-
.teamCount(0)
120-
.patentCount(0)
121-
.build();
122-
statisticsList.add(statistics);
123-
}
124-
}
125-
}
126-
return statisticsList;
127-
}
128-
129-
default List<UserCountStatistics> createUserCountStatistics(Category category, List<Field> fields, List<Semester> semesters) {
130-
List<UserCountStatistics> statisticsList = new ArrayList<>();
131-
for (Semester semester : semesters) {
132-
for (Field field : fields) {
133-
UserCountStatistics statistics = UserCountStatistics.builder()
134-
.id(new UserCountStatisticsId(semester.getId(), field.getId(), category.getId())) // 복합 키 설정
135-
.semester(semester)
136-
.field(field)
137-
.category(category)
138-
.userProjectCount(0) // 기본 값 설정
139-
.userQuestionCount(0)
140-
.userProblemCount(0)
141-
.userTeamCount(0)
142-
.userPatentCount(0)
143-
.totalProjectCount(0)
144-
.totalGithubProjectCount(0)
145-
.totalQuestionCount(0)
146-
.totalProblemCount(0)
147-
.totalTeamCount(0)
148-
.totalPatentCount(0)
149-
.build();
150-
151-
statisticsList.add(statistics);
152-
}
153-
}
154-
return statisticsList;
155-
}
156-
15727

15828
}
Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
11
package inha.git.college.mapper;
22

3-
import inha.git.category.domain.Category;
43
import inha.git.college.controller.dto.request.CreateCollegeRequest;
54
import inha.git.college.controller.dto.response.SearchCollegeResponse;
65
import inha.git.college.domain.College;
7-
import inha.git.field.domain.Field;
8-
import inha.git.semester.domain.Semester;
9-
import inha.git.statistics.domain.CollegeStatistics;
10-
import inha.git.statistics.domain.TotalCollegeStatistics;
11-
import inha.git.statistics.domain.id.CollegeStatisticsStatisticsId;
126
import org.mapstruct.Mapper;
137
import org.mapstruct.Mapping;
148
import org.mapstruct.NullValuePropertyMappingStrategy;
@@ -31,34 +25,10 @@ public interface CollegeMapper {
3125
@Mapping(target = "id", ignore = true)
3226
College createCollegeRequestToCollege(CreateCollegeRequest createDepartmentRequest);
3327

34-
/**
35-
* College 엔티티를 SearchCollegeResponse로 변환
36-
*
37-
* @param college College
38-
* @return SearchCollegeResponse
39-
*/
40-
default CollegeStatistics createCollegeStatistics(College college, Semester semester, Field field, Category category) {
41-
return new CollegeStatistics(
42-
new CollegeStatisticsStatisticsId(college.getId(), semester.getId(), field.getId(), category.getId()), college, semester, field, category, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
43-
}
44-
4528

4629
@Mapping(source = "college.id", target = "idx")
4730
SearchCollegeResponse collegeToSearchCollegeResponse(College college);
4831

4932
List<SearchCollegeResponse> collegesToSearchCollegeResponses(List<College> collegeList);
5033

51-
@Mapping(source = "college.id", target = "collegeId")
52-
@Mapping(target = "userProjectCount", constant = "0")
53-
@Mapping(target = "userQuestionCount", constant = "0")
54-
@Mapping(target = "userProblemCount", constant = "0")
55-
@Mapping(target = "userTeamCount", constant = "0")
56-
@Mapping(target = "userPatentCount", constant = "0")
57-
@Mapping(target = "totalProjectCount", constant = "0")
58-
@Mapping(target = "totalGithubProjectCount", constant = "0")
59-
@Mapping(target = "totalQuestionCount", constant = "0")
60-
@Mapping(target = "totalProblemCount", constant = "0")
61-
@Mapping(target = "totalTeamCount", constant = "0")
62-
@Mapping(target = "totalPatentCount", constant = "0")
63-
TotalCollegeStatistics createTotalCollegeStatistics(College college);
6434
}

src/main/java/inha/git/college/service/CollegeServiceImpl.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import inha.git.college.mapper.CollegeMapper;
99
import inha.git.common.exceptions.BaseException;
1010
import inha.git.department.domain.repository.DepartmentJpaRepository;
11-
import inha.git.statistics.domain.repository.TotalCollegeStatisticsJpaRepository;
1211
import inha.git.user.domain.User;
1312
import lombok.RequiredArgsConstructor;
1413
import lombok.extern.slf4j.Slf4j;
@@ -33,7 +32,6 @@
3332
public class CollegeServiceImpl implements CollegeService {
3433

3534
private final CollegeJpaRepository collegeJpaRepository;
36-
private final TotalCollegeStatisticsJpaRepository totalCollegeStatisticsJpaRepository;
3735
private final DepartmentJpaRepository departmentJpaRepository;
3836
private final CollegeMapper collegeMapper;
3937

@@ -77,7 +75,6 @@ public SearchCollegeResponse getCollege(Integer departmentIdx) {
7775
public String createCollege(User admin, CreateCollegeRequest createDepartmentRequest) {
7876
College college = collegeJpaRepository.save
7977
(collegeMapper.createCollegeRequestToCollege(createDepartmentRequest));
80-
totalCollegeStatisticsJpaRepository.save(collegeMapper.createTotalCollegeStatistics(college));
8178
log.info("단과대 생성 성공 - 관리자: {} 단과대 이름: {}", admin.getName(), college.getName());
8279
return college.getName() + " 단과대가 생성되었습니다.";
8380
}

src/main/java/inha/git/common/code/status/ErrorStatus.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ public enum ErrorStatus implements BaseErrorCode {
237237
TOTAL_DEPARTMENT_STATISTICS_NOT_FOUND(HttpStatus.NOT_FOUND, "STATISTICS4004", "학과 전체 통계를 찾을 수 없습니다."),
238238
TOTAL_COLLEGE_STATISTICS_NOT_FOUND(HttpStatus.NOT_FOUND, "STATISTICS4005", "단과대 전체 통계를 찾을 수 없습니다."),
239239
USER_COUNT_STATISTICS_NOT_FOUND(HttpStatus.NOT_FOUND, "STATISTICS4006", "사용자 수 통계를 찾을 수 없습니다."),
240+
INVALID_ACTION_TYPE(HttpStatus.BAD_REQUEST, "STATISTICS4007", "유효하지 않은 통계 타입입니다."),
240241

241242
INVALID_APPLICATION_NUMBER(HttpStatus.BAD_REQUEST, "APPLICATION4000", "유효하지 않은 신청 번호입니다."),
242243
NOT_EXIST_PATENT(HttpStatus.BAD_REQUEST, "PATENT4000", "존재하지 않는 특허입니다."),
Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
11
package inha.git.department.api.mapper;
22

33
import inha.git.admin.api.controller.dto.response.SearchDepartmentResponse;
4-
import inha.git.category.domain.Category;
54
import inha.git.college.domain.College;
65
import inha.git.department.api.controller.dto.request.CreateDepartmentRequest;
76
import inha.git.department.domain.Department;
8-
import inha.git.field.domain.Field;
9-
import inha.git.semester.domain.Semester;
10-
import inha.git.statistics.domain.DepartmentStatistics;
11-
import inha.git.statistics.domain.TotalDepartmentStatistics;
12-
import inha.git.statistics.domain.id.DepartmentStatisticsId;
137
import org.mapstruct.Mapper;
148
import org.mapstruct.Mapping;
159
import org.mapstruct.NullValuePropertyMappingStrategy;
@@ -38,30 +32,4 @@ public interface DepartmentMapper {
3832
SearchDepartmentResponse departmentToSearchDepartmentResponse(Department department);
3933
List<SearchDepartmentResponse> departmentsToSearchDepartmentResponses(List<Department> departmentList);
4034

41-
42-
/**
43-
* Department 엔티티를 DepartmentStatistics 엔티티로 변환
44-
*
45-
* @param department Department 엔티티
46-
* @param semester Semester 엔티티
47-
* @param field Field 엔티티
48-
* @return DepartmentStatistics 엔티티
49-
*/
50-
default DepartmentStatistics createDepartmentStatistics(Department department, Semester semester, Field field, Category category) {
51-
return new DepartmentStatistics(new DepartmentStatisticsId(department.getId(), semester.getId(), field.getId(), category.getId()), department, semester, field, category, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
52-
}
53-
54-
@Mapping(source = "department.id", target = "departmentId")
55-
@Mapping(target = "userProjectCount", constant = "0")
56-
@Mapping(target = "userQuestionCount", constant = "0")
57-
@Mapping(target = "userProblemCount", constant = "0")
58-
@Mapping(target = "userTeamCount", constant = "0")
59-
@Mapping(target = "userPatentCount", constant = "0")
60-
@Mapping(target = "totalProjectCount", constant = "0")
61-
@Mapping(target = "totalGithubProjectCount", constant = "0")
62-
@Mapping(target = "totalQuestionCount", constant = "0")
63-
@Mapping(target = "totalProblemCount", constant = "0")
64-
@Mapping(target = "totalTeamCount", constant = "0")
65-
@Mapping(target = "totalPatentCount", constant = "0")
66-
TotalDepartmentStatistics createTotalDepartmentStatistics(Department department);
6735
}

src/main/java/inha/git/department/api/service/DepartmentServiceImpl.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import inha.git.department.api.mapper.DepartmentMapper;
1010
import inha.git.department.domain.Department;
1111
import inha.git.department.domain.repository.DepartmentJpaRepository;
12-
import inha.git.statistics.domain.repository.TotalDepartmentStatisticsJpaRepository;
1312
import inha.git.user.domain.User;
1413
import lombok.RequiredArgsConstructor;
1514
import lombok.extern.slf4j.Slf4j;
@@ -33,7 +32,6 @@
3332
public class DepartmentServiceImpl implements DepartmentService{
3433
private final DepartmentJpaRepository departmentJpaRepository;
3534
private final DepartmentMapper departmentMapper;
36-
private final TotalDepartmentStatisticsJpaRepository totalDepartmentStatisticsJpaRepository;
3735
private final CollegeJpaRepository collegeJpaRepository;
3836

3937
/**
@@ -73,7 +71,6 @@ public String createDepartment(User admin, CreateDepartmentRequest createDepartm
7371
throw new BaseException(DEPARTMENT_NOT_BELONG_TO_COLLEGE);
7472
}
7573
Department savedDepartment = departmentJpaRepository.save(department);
76-
totalDepartmentStatisticsJpaRepository.save(departmentMapper.createTotalDepartmentStatistics(department));
7774
log.info("학과 생성 성공 - 관리자: {} 학과명: {}", admin.getName(), savedDepartment.getName());
7875
return savedDepartment.getName() + " 학과가 생성되었습니다.";
7976
}
@@ -115,6 +112,4 @@ public String deleteDepartment(User admin, Integer departmentIdx) {
115112
log.info("학과 삭제 성공 - 관리자: {} 학과명: {}", admin.getName(), department.getName());
116113
return department.getName() + " 학과가 삭제되었습니다.";
117114
}
118-
119-
120115
}

0 commit comments

Comments
 (0)