-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: filter 생성 controller 기능 개발 * feat: 필터 entity 생성 * feat: filter repository 생성 * feat: filter 생성 dto 추가 * feat: filter 생성 converter 기능 개발 * feat: filter model 추가 * feat: filter 생성 서비스 기능 개발 * feat: create filter usecase 추가 * fix: CreateFilterUsecase path 수정 * fix: CreateFilterUsecase path 수정
- Loading branch information
1 parent
3c43a86
commit f81cccf
Showing
11 changed files
with
257 additions
and
0 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
BE/error/src/main/java/com/example/demo/filter/application/dto/CreateFilterRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.example.demo.filter.application.dto; | ||
|
||
|
||
import com.example.demo.common.support.dto.AbstractDto; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@Builder(toBuilder = true) | ||
public class CreateFilterRequest implements AbstractDto { | ||
private Long filterId; | ||
private String filterName; | ||
private String filterColor; | ||
} |
17 changes: 17 additions & 0 deletions
17
BE/error/src/main/java/com/example/demo/filter/application/dto/CreateFilterResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.example.demo.filter.application.dto; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
|
||
@Getter | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@Builder(toBuilder = true) | ||
public class CreateFilterResponse { | ||
private Long filterId; | ||
} | ||
|
||
|
15 changes: 15 additions & 0 deletions
15
BE/error/src/main/java/com/example/demo/filter/application/model/FilterModel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.example.demo.filter.application.model; | ||
|
||
import com.example.demo.common.support.AbstractModel; | ||
import lombok.*; | ||
|
||
@Getter | ||
@ToString | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@Builder(toBuilder = true) | ||
public class FilterModel implements AbstractModel { | ||
private Long filterId; | ||
private String filterName; | ||
private String filterColor; | ||
} |
28 changes: 28 additions & 0 deletions
28
.../main/java/com/example/demo/filter/application/model/converter/FilterEntityConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.example.demo.filter.application.model.converter; | ||
|
||
import com.example.demo.common.support.converter.AbstractEntityConverter; | ||
import com.example.demo.filter.application.model.FilterModel; | ||
import com.example.demo.filter.persistence.FilterEntity; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
public class FilterEntityConverter implements AbstractEntityConverter<FilterEntity, FilterModel> { | ||
|
||
@Override | ||
public FilterModel from(FilterEntity source) { | ||
return FilterModel.builder() | ||
.filterId(source.getFilterId()) | ||
.filterName(source.getFilterName()) | ||
.filterColor(source.getFilterColor()) | ||
.build(); | ||
} | ||
|
||
@Override | ||
public FilterEntity toEntity(FilterModel source) { | ||
return FilterEntity.builder() | ||
.filterId(source.getFilterId()) | ||
.filterName(source.getFilterName()) | ||
.filterColor(source.getFilterColor()) | ||
.build(); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
...main/java/com/example/demo/filter/application/model/converter/FilterRequestConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.example.demo.filter.application.model.converter; | ||
|
||
import com.example.demo.common.support.converter.AbstractDtoConverter; | ||
import com.example.demo.filter.application.dto.CreateFilterRequest; | ||
import com.example.demo.filter.application.dto.CreateFilterResponse; | ||
import com.example.demo.filter.application.model.FilterModel; | ||
import com.example.demo.schedule.application.model.ScheduleModel; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
public class FilterRequestConverter implements AbstractDtoConverter<CreateFilterRequest, FilterModel> { | ||
|
||
|
||
@Override | ||
public FilterModel from(CreateFilterRequest source) { | ||
return FilterModel.builder() | ||
.filterId(source.getFilterId()) | ||
.filterName(source.getFilterName()) | ||
.filterColor(source.getFilterColor()) | ||
.build(); | ||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
} |
13 changes: 13 additions & 0 deletions
13
...ain/java/com/example/demo/filter/application/model/converter/FilterResponseConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.example.demo.filter.application.model.converter; | ||
|
||
import com.example.demo.filter.application.dto.CreateFilterResponse; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
public class FilterResponseConverter { | ||
|
||
public CreateFilterResponse from(Long filterId) { | ||
return CreateFilterResponse.builder().filterId(filterId).build(); | ||
} | ||
|
||
} |
34 changes: 34 additions & 0 deletions
34
BE/error/src/main/java/com/example/demo/filter/application/service/FilterService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.example.demo.filter.application.service; | ||
|
||
import com.example.demo.filter.application.dto.CreateFilterRequest; | ||
import com.example.demo.filter.application.dto.CreateFilterResponse; | ||
import com.example.demo.filter.application.model.FilterModel; | ||
import com.example.demo.filter.application.model.converter.FilterEntityConverter; | ||
import com.example.demo.filter.application.model.converter.FilterRequestConverter; | ||
import com.example.demo.filter.application.model.converter.FilterResponseConverter; | ||
import com.example.demo.filter.persistence.FilterEntity; | ||
import com.example.demo.filter.persistence.FilterRepository; | ||
import com.example.demo.filter.application.usecase.CreateFilterUsecase; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
@Transactional(readOnly = true) | ||
public class FilterService implements CreateFilterUsecase { | ||
|
||
private final FilterRepository filterRepository; | ||
private final FilterRequestConverter requestConverter; | ||
private final FilterEntityConverter entityConverter; | ||
private final FilterResponseConverter responseConverter; | ||
|
||
|
||
@Override | ||
public CreateFilterResponse createFilter(CreateFilterRequest request) { | ||
FilterModel model = requestConverter.from(request); | ||
FilterEntity entity = entityConverter.toEntity(model); | ||
FilterEntity save = filterRepository.save(entity); | ||
return responseConverter.from(save.getFilterId()); | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
BE/error/src/main/java/com/example/demo/filter/application/usecase/CreateFilterUsecase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.example.demo.filter.application.usecase; | ||
|
||
import com.example.demo.filter.application.dto.CreateFilterRequest; | ||
import com.example.demo.filter.application.dto.CreateFilterResponse; | ||
|
||
public interface CreateFilterUsecase { | ||
CreateFilterResponse createFilter(CreateFilterRequest request); | ||
} |
30 changes: 30 additions & 0 deletions
30
BE/error/src/main/java/com/example/demo/filter/persistence/FilterEntity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.example.demo.filter.persistence; | ||
|
||
import com.example.demo.common.persistence.BaseEntity; | ||
import jakarta.persistence.*; | ||
import lombok.*; | ||
import lombok.experimental.SuperBuilder; | ||
import org.springframework.data.jpa.domain.support.AuditingEntityListener; | ||
|
||
|
||
@Getter | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@AllArgsConstructor(access = AccessLevel.PRIVATE) | ||
@ToString | ||
@Entity | ||
@SuperBuilder(toBuilder = true) | ||
@Table(name = "filter") | ||
@EntityListeners(AuditingEntityListener.class) | ||
public class FilterEntity extends BaseEntity { | ||
|
||
@Id | ||
@GeneratedValue | ||
@Column(nullable = false) | ||
private Long filterId; | ||
|
||
@Column(nullable = false) | ||
private String filterName; | ||
|
||
@Column(nullable = false) | ||
private String filterColor; | ||
} |
9 changes: 9 additions & 0 deletions
9
BE/error/src/main/java/com/example/demo/filter/persistence/FilterRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.example.demo.filter.persistence; | ||
|
||
import com.example.demo.schedule.persistence.ScheduleEntity; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@Repository | ||
public interface FilterRepository extends JpaRepository<FilterEntity, Long> { | ||
} |
57 changes: 57 additions & 0 deletions
57
BE/error/src/main/java/com/example/demo/filter/presentation/FilterController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package com.example.demo.filter.presentation; | ||
|
||
import com.example.demo.common.presentation.response.ApiResponse; | ||
import com.example.demo.common.presentation.response.ApiResponseBody; | ||
import com.example.demo.common.presentation.response.ApiResponseGenerator; | ||
import com.example.demo.common.presentation.response.MessageCode; | ||
import com.example.demo.filter.application.dto.CreateFilterRequest; | ||
import com.example.demo.filter.application.dto.CreateFilterResponse; | ||
import com.example.demo.filter.application.usecase.CreateFilterUsecase; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/api/filter") | ||
public class FilterController { | ||
|
||
private final CreateFilterUsecase createFilterUsecase; | ||
|
||
@PostMapping | ||
public ApiResponse<ApiResponseBody.SuccessBody<CreateFilterResponse>> createFilter( | ||
@RequestBody CreateFilterRequest request) { | ||
CreateFilterResponse response = createFilterUsecase.createFilter(request); | ||
return ApiResponseGenerator.success(response, HttpStatus.OK, MessageCode.CREATE); | ||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
} |