diff --git a/BE/error/src/main/java/com/example/demo/auth/application/config/LoginConfig.java b/BE/error/src/main/java/com/example/demo/auth/application/config/LoginConfig.java index 0e0ce860..8be16e27 100644 --- a/BE/error/src/main/java/com/example/demo/auth/application/config/LoginConfig.java +++ b/BE/error/src/main/java/com/example/demo/auth/application/config/LoginConfig.java @@ -26,7 +26,7 @@ public void addInterceptors(InterceptorRegistry registry) { registry .addInterceptor(memberAuthInterceptor()) .addPathPatterns("/api/**") - .excludePathPatterns("/api/auth/**", "/api/calendar/public/**"); + .excludePathPatterns("/api/auth/**", "/api/calendar/public/**", "/api/filter"); registry .addInterceptor(reissueAuthInterceptor()) .addPathPatterns("/auth/reissue") diff --git a/BE/error/src/main/java/com/example/demo/filter/application/dto/CreateFilterRequest.java b/BE/error/src/main/java/com/example/demo/filter/application/dto/CreateFilterRequest.java new file mode 100644 index 00000000..a1bdc887 --- /dev/null +++ b/BE/error/src/main/java/com/example/demo/filter/application/dto/CreateFilterRequest.java @@ -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; +} diff --git a/BE/error/src/main/java/com/example/demo/filter/application/dto/CreateFilterResponse.java b/BE/error/src/main/java/com/example/demo/filter/application/dto/CreateFilterResponse.java new file mode 100644 index 00000000..b5fb7e63 --- /dev/null +++ b/BE/error/src/main/java/com/example/demo/filter/application/dto/CreateFilterResponse.java @@ -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; +} + + diff --git a/BE/error/src/main/java/com/example/demo/filter/application/model/FilterModel.java b/BE/error/src/main/java/com/example/demo/filter/application/model/FilterModel.java new file mode 100644 index 00000000..249a211f --- /dev/null +++ b/BE/error/src/main/java/com/example/demo/filter/application/model/FilterModel.java @@ -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; +} diff --git a/BE/error/src/main/java/com/example/demo/filter/application/model/converter/FilterEntityConverter.java b/BE/error/src/main/java/com/example/demo/filter/application/model/converter/FilterEntityConverter.java new file mode 100644 index 00000000..4f704dac --- /dev/null +++ b/BE/error/src/main/java/com/example/demo/filter/application/model/converter/FilterEntityConverter.java @@ -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 { + + @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(); + } +} diff --git a/BE/error/src/main/java/com/example/demo/filter/application/model/converter/FilterRequestConverter.java b/BE/error/src/main/java/com/example/demo/filter/application/model/converter/FilterRequestConverter.java new file mode 100644 index 00000000..eb9051cb --- /dev/null +++ b/BE/error/src/main/java/com/example/demo/filter/application/model/converter/FilterRequestConverter.java @@ -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 { + + + @Override + public FilterModel from(CreateFilterRequest source) { + return FilterModel.builder() + .filterId(source.getFilterId()) + .filterName(source.getFilterName()) + .filterColor(source.getFilterColor()) + .build(); + } + + + + + + +} diff --git a/BE/error/src/main/java/com/example/demo/filter/application/model/converter/FilterResponseConverter.java b/BE/error/src/main/java/com/example/demo/filter/application/model/converter/FilterResponseConverter.java new file mode 100644 index 00000000..4db57377 --- /dev/null +++ b/BE/error/src/main/java/com/example/demo/filter/application/model/converter/FilterResponseConverter.java @@ -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(); + } + +} diff --git a/BE/error/src/main/java/com/example/demo/filter/application/service/FilterService.java b/BE/error/src/main/java/com/example/demo/filter/application/service/FilterService.java new file mode 100644 index 00000000..5cee9196 --- /dev/null +++ b/BE/error/src/main/java/com/example/demo/filter/application/service/FilterService.java @@ -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()); + } +} diff --git a/BE/error/src/main/java/com/example/demo/filter/application/usecase/CreateFilterUsecase.java b/BE/error/src/main/java/com/example/demo/filter/application/usecase/CreateFilterUsecase.java new file mode 100644 index 00000000..5161f3bd --- /dev/null +++ b/BE/error/src/main/java/com/example/demo/filter/application/usecase/CreateFilterUsecase.java @@ -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); +} diff --git a/BE/error/src/main/java/com/example/demo/filter/persistence/FilterEntity.java b/BE/error/src/main/java/com/example/demo/filter/persistence/FilterEntity.java new file mode 100644 index 00000000..bc432e09 --- /dev/null +++ b/BE/error/src/main/java/com/example/demo/filter/persistence/FilterEntity.java @@ -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; +} diff --git a/BE/error/src/main/java/com/example/demo/filter/persistence/FilterRepository.java b/BE/error/src/main/java/com/example/demo/filter/persistence/FilterRepository.java new file mode 100644 index 00000000..17529180 --- /dev/null +++ b/BE/error/src/main/java/com/example/demo/filter/persistence/FilterRepository.java @@ -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 { +} diff --git a/BE/error/src/main/java/com/example/demo/filter/presentation/FilterController.java b/BE/error/src/main/java/com/example/demo/filter/presentation/FilterController.java new file mode 100644 index 00000000..1d71a6db --- /dev/null +++ b/BE/error/src/main/java/com/example/demo/filter/presentation/FilterController.java @@ -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> createFilter( + @RequestBody CreateFilterRequest request) { + CreateFilterResponse response = createFilterUsecase.createFilter(request); + return ApiResponseGenerator.success(response, HttpStatus.OK, MessageCode.CREATE); + } + + + + + + + + + + + + + + + + + + + + + + + + + + + +}