Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
19bff02
CLAP-104 CI/CD : dev 환경 cd 스크립트 checkout 버전수정
hyoseong-Choi Jan 23, 2025
a3fe141
Merge branch 'develop' of https://github.com/TaskFlow-CLAP/TaskFlow-S…
hyoseong-Choi Jan 23, 2025
87ee143
Merge branch 'develop' of https://github.com/TaskFlow-CLAP/TaskFlow-S…
hyoseong-Choi Jan 23, 2025
0a5bdf1
Merge branch 'develop' of https://github.com/TaskFlow-CLAP/TaskFlow-S…
hyoseong-Choi Jan 23, 2025
c97d37c
CLAP-110 Feature : 담당자별 작업 처리량 조회 API 구현
hyoseong-Choi Jan 23, 2025
73bd762
CLAP-111 Refactor : 통계 조회 API 리팩토링 및 기능 수정
hyoseong-Choi Jan 23, 2025
60ebc4a
내 작업한 내용에 대한 설명
nano-mm Jan 23, 2025
a88a6bf
내 작업한 내용에 대한 설명
nano-mm Jan 23, 2025
1bf4ffb
Resolve merge conflict in application.yml
nano-mm Jan 23, 2025
283e5a5
담당자 조회 API 구현
nano-mm Jan 24, 2025
0ec9b91
Merge branch 'develop' of https://github.com/TaskFlow-CLAP/TaskFlow-S…
hyoseong-Choi Jan 24, 2025
2a9eed4
CLAP-111 Refactor : 통계 조회 API 주소 통합, 리팩토링, 예외처리
hyoseong-Choi Jan 24, 2025
ea99e9f
CLAP-111 Test : 테스트코드 및 설정 수정
hyoseong-Choi Jan 24, 2025
0bf52d6
Merge branch 'develop' of https://github.com/TaskFlow-CLAP/TaskFlow-S…
hyoseong-Choi Jan 24, 2025
0372f2c
Merge branch 'develop' of https://github.com/TaskFlow-CLAP/TaskFlow-S…
hyoseong-Choi Jan 24, 2025
24c582d
Bug : 프로퍼티파일 수정
hyoseong-Choi Jan 24, 2025
680428a
CLAP-111 refactor : 통계 컨트롤러 스웨거 수정 및 2차 카테고리별 통계 수정
hyoseong-Choi Jan 24, 2025
836ae3f
CLAP-125 Feature : 1차 카테고리 추가 API
hyoseong-Choi Jan 24, 2025
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
@@ -0,0 +1,36 @@
package clap.server.adapter.inbound.web.admin;

import clap.server.adapter.inbound.security.SecurityUserDetails;
import clap.server.adapter.inbound.web.dto.admin.AddMainCategoryRequest;
import clap.server.application.port.inbound.management.AddMainCategoryUsecase;
import clap.server.common.annotation.architecture.WebAdapter;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.annotation.Secured;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

@Tag(name = "카테고리 추가")
@WebAdapter
@RequiredArgsConstructor
public class addCategoryController {
private final AddMainCategoryUsecase addMainCategoryUsecase;

@Operation(summary = "1차 카테고리 추가")
@PostMapping("/api/maincategory")
@Secured("ROLE_ADMIN")
public void addMainCategory(@AuthenticationPrincipal SecurityUserDetails userInfo, @Validated @RequestBody AddMainCategoryRequest addMainCategoryRequest) {
addMainCategoryUsecase.addMainCategory(userInfo.getUserId(), addMainCategoryRequest.code(), addMainCategoryRequest.name());
}

// @Operation(summary = "2차 카테고리 추가")
// @PostMapping("/api/subcategory")
// @Secured("ROLE_ADMIN")
// public void addSubCategory(@Validated @RequestBody AddCategoryRequest addCategoryRequest) {
// addMainCategoryUsecase.addSubCategory(addCategoryRequest.code(), addCategoryRequest.name());
// }

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package clap.server.adapter.inbound.web.dto.admin;

import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Pattern;
import org.hibernate.validator.constraints.Length;

public record AddMainCategoryRequest(
@NotBlank @Length(max = 20)
String name,
@NotBlank @Pattern(regexp = "^[A-Z]{1,2}$", message = "올바른 카테고리 코드 형식이 아닙니다.")
String code
) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import clap.server.application.port.inbound.statistics.*;
import clap.server.common.annotation.architecture.WebAdapter;
import clap.server.exception.StatisticsException;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
Expand All @@ -16,6 +18,7 @@
import java.util.List;

import static clap.server.exception.code.StatisticsErrorCode.STATISTICS_BAD_REQUEST;
import static io.swagger.v3.oas.annotations.enums.ParameterIn.QUERY;

@Tag(name = "작업 관련 통계")
@WebAdapter
Expand All @@ -28,6 +31,9 @@ public class FindStatisticsController {
private final FindSubCategoryTaskRequestUsecase findSubCategoryTaskRequestUsecase;
private final FindManagerTaskProcessUsecase findManagerTaskProcessUsecase;

@Operation(summary = "기본 통계 API")
@Parameter(name = "periodType", description = "day, week, month", required = true, in = QUERY)
@Parameter(name = "statisticsType", description = "request-by-period, process-by-period, request-by-category, process-by-manager", required = true, in = QUERY)
@GetMapping
public ResponseEntity<List<StatisticsResponse>> aggregateTaskStatistics(@RequestParam PeriodType periodType, @RequestParam StatisticsType statisticsType) {
switch (statisticsType) {
Expand Down Expand Up @@ -62,10 +68,13 @@ public ResponseEntity<List<StatisticsResponse>> aggregateTaskStatistics(@Request
throw new StatisticsException(STATISTICS_BAD_REQUEST);
}

@Operation(summary = "1차 카테고리 하위 2차 카테고리별 통계 API")
@Parameter(name = "periodType", description = "day, week, month", required = true, in = QUERY)
@Parameter(name = "mainCategory", description = "1차 카테고리 이름", required = true, in = QUERY)
@GetMapping("/subcategory")
public ResponseEntity<List<StatisticsResponse>> aggregateSubCategoryTaskRequest(@RequestParam String period, @RequestParam String mainCategory) {
public ResponseEntity<List<StatisticsResponse>> aggregateSubCategoryTaskRequest(@RequestParam PeriodType periodType, @RequestParam String mainCategory) {
return ResponseEntity.ok(findSubCategoryTaskRequestUsecase
.aggregateSubCategoryTaskRequest(period, mainCategory)
.aggregateSubCategoryTaskRequest(periodType.getType(), mainCategory)
.entrySet()
.stream()
.map(result -> new StatisticsResponse(result.getKey(), result.getValue()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import clap.server.adapter.outbound.persistense.entity.task.CategoryEntity;
import clap.server.adapter.outbound.persistense.mapper.CategoryPersistenceMapper;
import clap.server.adapter.outbound.persistense.repository.task.CategoryRepository;
import clap.server.application.port.outbound.task.CommandCategoryPort;
import clap.server.application.port.outbound.task.LoadCategoryPort;
import clap.server.common.annotation.architecture.PersistenceAdapter;
import clap.server.domain.model.task.Category;
Expand All @@ -12,7 +13,7 @@

@PersistenceAdapter
@RequiredArgsConstructor
public class CategoryPersistenceAdapter implements LoadCategoryPort {
public class CategoryPersistenceAdapter implements LoadCategoryPort, CommandCategoryPort {

private final CategoryRepository categoryRepository;
private final CategoryPersistenceMapper categoryPersistenceMapper;
Expand All @@ -22,4 +23,9 @@ public Optional<Category> findById(Long id) {
Optional<CategoryEntity> categoryEntity = categoryRepository.findById(id);
return categoryEntity.map(categoryPersistenceMapper::toDomain);
}
}

@Override
public void save(Category category) {
categoryRepository.save(categoryPersistenceMapper.toEntity(category));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package clap.server.application.port.inbound.management;

public interface AddMainCategoryUsecase {
void addMainCategory(Long adminId, String code, String name);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package clap.server.application.port.outbound.task;

import clap.server.domain.model.task.Category;

public interface CommandCategoryPort {
void save(Category category);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package clap.server.application.service.admin;

import clap.server.application.port.inbound.management.AddMainCategoryUsecase;
import clap.server.application.port.outbound.member.LoadMemberPort;
import clap.server.application.port.outbound.task.CommandCategoryPort;
import clap.server.common.annotation.architecture.ApplicationService;
import clap.server.domain.model.member.Member;
import clap.server.domain.model.task.Category;
import clap.server.exception.ApplicationException;
import lombok.RequiredArgsConstructor;

import java.util.Optional;

import static clap.server.exception.code.MemberErrorCode.ACTIVE_MEMBER_NOT_FOUND;

@ApplicationService
@RequiredArgsConstructor
public class AddMainCategoryService implements AddMainCategoryUsecase {
private final CommandCategoryPort commandCategoryPort;
private final LoadMemberPort loadMemberPort;

@Override
public void addMainCategory(Long adminId, String code, String name) {
Optional<Member> activeMember = loadMemberPort.findActiveMemberById(adminId);
Category mainCategory = Category.createMainCategory(
activeMember.orElseThrow(() -> new ApplicationException(ACTIVE_MEMBER_NOT_FOUND)),
code, name);
commandCategoryPort.save(mainCategory);
}
}
8 changes: 8 additions & 0 deletions src/main/java/clap/server/domain/model/task/Category.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,13 @@ public class Category extends BaseTime {
private String descriptionExample;
private LocalDateTime createdAt;
private LocalDateTime updatedAt;

public static Category createMainCategory(Member admin, String code, String name) {
Category category = new Category();
category.admin = admin;
category.code = code;
category.name = name;
return category;
}
}

19 changes: 9 additions & 10 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ spring:
- swagger.yml
- redis.yml
- auth.yml
- optional:classpath:env.properties
application:
name: taskflow2
name: taskflow
elasticsearch:
uris: ${ELASTIC_URI:127.0.0.1:9200}

Expand All @@ -24,21 +23,21 @@ server:
max: 600
min-spare: 100

logging:
level:
root: INFO
taskflow.clap.server: ERROR
org:
springframework: DEBUG
#logging:
# level:
# root: INFO
# taskflow.clap.server: ERROR
# org:
# springframework: DEBUG

---
spring.config.activate.on-profile: local
logging:
level:
root: INFO
taskflow.clap.server: ERROR
org:
springframework: DEBUG
# org:
# springframework: DEBUG

---
spring.config.activate.on-profile: dev
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/mysql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ spring:

datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://${DATABASE_HOST:localhost}:${DATABASE_PORT:3306}/${DATABASE_NAME:taskflowdev}?characterEncoding=UTF-8&serverTimezone=Asia/Seoul&autoReconnect=true
url: jdbc:mysql://${DATABASE_HOST:localhost}:${DATABASE_PORT:3306}/${DATABASE_NAME:taskflow}?characterEncoding=UTF-8&serverTimezone=Asia/Seoul&autoReconnect=true
username: ${DATABASE_USERNAME}
password: ${DATABASE_PASSWORD}
data-source-properties:
Expand Down
Loading