Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Be #123

Merged
merged 15 commits into from
Jul 23, 2024
Merged

Be #123

Show file tree
Hide file tree
Changes from all commits
Commits
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
Expand Up @@ -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")
Expand Down
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;
}
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;
}


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;
}
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();
}
}
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();
}






}
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();
}

}
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());
}
}
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);
}
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;
}
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> {
}
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);
}



























}
Loading