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

매물 검색 기능 구현 #129

Merged
merged 1 commit into from
May 30, 2024
Merged
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
@@ -1,5 +1,24 @@
package com.ajou.hertz.domain.instrument.controller;

import static com.ajou.hertz.common.constant.GlobalConstants.API_VERSION_HEADER_NAME;

import java.net.URI;

import org.springdoc.core.annotations.ParameterObject;
import org.springframework.data.domain.Page;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.ajou.hertz.common.auth.UserPrincipal;
import com.ajou.hertz.domain.instrument.acoustic_and_classic_guitar.dto.AcousticAndClassicGuitarDto;
import com.ajou.hertz.domain.instrument.acoustic_and_classic_guitar.dto.request.AcousticAndClassicGuitarFilterConditions;
Expand Down Expand Up @@ -38,6 +57,7 @@
import com.ajou.hertz.domain.instrument.mapper.InstrumentMapper;
import com.ajou.hertz.domain.instrument.service.InstrumentCommandService;
import com.ajou.hertz.domain.instrument.service.InstrumentQueryService;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Content;
Expand All @@ -47,16 +67,6 @@
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.data.domain.Page;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.*;

import java.net.URI;

import static com.ajou.hertz.common.constant.GlobalConstants.API_VERSION_HEADER_NAME;

@Tag(name = "중고 악기 관련 API")
@RequiredArgsConstructor
Expand Down Expand Up @@ -129,10 +139,14 @@ public Page<ElectricGuitarResponse> findElectricGuitarsV1(
@Parameter(
description = "정렬 기준"
) @RequestParam InstrumentSortOption sort,
@ParameterObject @Valid @ModelAttribute ElectricGuitarFilterConditions filterConditions
@ParameterObject @Valid @ModelAttribute ElectricGuitarFilterConditions filterConditions,
@Parameter(
description = "검색 키워드(검색어)",
example = "펜더"
) @RequestParam(required = false) String searchKeyword
) {
return instrumentQueryService
.findElectricGuitarDtos(page, size, sort, filterConditions)
.findElectricGuitarDtos(page, size, sort, filterConditions, searchKeyword)
.map(InstrumentMapper::toElectricGuitarResponse);
}

Expand All @@ -153,10 +167,14 @@ public Page<BassGuitarResponse> findBassGuitarsV1(
@Parameter(
description = "정렬 기준"
) @RequestParam InstrumentSortOption sort,
@ParameterObject @Valid @ModelAttribute BassGuitarFilterConditions filterConditions
@ParameterObject @Valid @ModelAttribute BassGuitarFilterConditions filterConditions,
@Parameter(
description = "검색 키워드(검색어)",
example = "펜더"
) @RequestParam(required = false) String searchKeyword
) {
return instrumentQueryService
.findBassGuitarDtos(page, size, sort, filterConditions)
.findBassGuitarDtos(page, size, sort, filterConditions, searchKeyword)
.map(InstrumentMapper::toBassGuitarResponse);
}

Expand All @@ -177,10 +195,14 @@ public Page<AcousticAndClassicGuitarResponse> findAcousticAndClassicGuitarsV1(
@Parameter(
description = "정렬 기준"
) @RequestParam InstrumentSortOption sort,
@ParameterObject @Valid @ModelAttribute AcousticAndClassicGuitarFilterConditions filterConditions
@ParameterObject @Valid @ModelAttribute AcousticAndClassicGuitarFilterConditions filterConditions,
@Parameter(
description = "검색 키워드(검색어)",
example = "펜더"
) @RequestParam(required = false) String searchKeyword
) {
return instrumentQueryService
.findAcousticAndClassicGuitarDtos(page, size, sort, filterConditions)
.findAcousticAndClassicGuitarDtos(page, size, sort, filterConditions, searchKeyword)
.map(InstrumentMapper::toAcousticAndClassicGuitarResponse);
}

Expand All @@ -201,10 +223,14 @@ public Page<EffectorResponse> findEffectorsV1(
@Parameter(
description = "정렬 기준"
) @RequestParam InstrumentSortOption sort,
@ParameterObject @Valid @ModelAttribute EffectorFilterConditions filterConditions
@ParameterObject @Valid @ModelAttribute EffectorFilterConditions filterConditions,
@Parameter(
description = "검색 키워드(검색어)",
example = "펜더"
) @RequestParam(required = false) String searchKeyword
) {
return instrumentQueryService
.findEffectorDtos(page, size, sort, filterConditions)
.findEffectorDtos(page, size, sort, filterConditions, searchKeyword)
.map(InstrumentMapper::toEffectorResponse);
}

Expand All @@ -225,10 +251,14 @@ public Page<AmplifierResponse> findAmplifiersV1(
@Parameter(
description = "정렬 기준"
) @RequestParam InstrumentSortOption sort,
@ParameterObject @Valid @ModelAttribute AmplifierFilterConditions filterConditions
@ParameterObject @Valid @ModelAttribute AmplifierFilterConditions filterConditions,
@Parameter(
description = "검색 키워드(검색어)",
example = "펜더"
) @RequestParam(required = false) String searchKeyword
) {
return instrumentQueryService
.findAmplifierDtos(page, size, sort, filterConditions)
.findAmplifierDtos(page, size, sort, filterConditions, searchKeyword)
.map(InstrumentMapper::toAmplifierResponse);
}

Expand All @@ -249,10 +279,14 @@ public Page<AudioEquipmentResponse> findAudioEquipmentsV1(
@Parameter(
description = "정렬 기준"
) @RequestParam InstrumentSortOption sort,
@ParameterObject @Valid @ModelAttribute AudioEquipmentFilterConditions filterConditions
@ParameterObject @Valid @ModelAttribute AudioEquipmentFilterConditions filterConditions,
@Parameter(
description = "검색 키워드(검색어)",
example = "펜더"
) @RequestParam(required = false) String searchKeyword
) {
return instrumentQueryService
.findAudioEquipmentDtos(page, size, sort, filterConditions)
.findAudioEquipmentDtos(page, size, sort, filterConditions, searchKeyword)
.map(InstrumentMapper::toAudioEquipmentResponse);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,26 +33,26 @@ public interface InstrumentRepositoryCustom {
Optional<AudioEquipment> findAudioEquipmentById(Long id);

Page<ElectricGuitar> findElectricGuitars(
int page, int pageSize, InstrumentSortOption sort, ElectricGuitarFilterConditions filterConditions
int page, int pageSize, InstrumentSortOption sort, ElectricGuitarFilterConditions filterConditions, String searchKeyword
);

Page<BassGuitar> findBassGuitars(
int page, int pageSize, InstrumentSortOption sort, BassGuitarFilterConditions filterConditions
int page, int pageSize, InstrumentSortOption sort, BassGuitarFilterConditions filterConditions, String searchKeyword
);

Page<AcousticAndClassicGuitar> findAcousticAndClassicGuitars(
int page, int pageSize, InstrumentSortOption sort, AcousticAndClassicGuitarFilterConditions filterConditions
int page, int pageSize, InstrumentSortOption sort, AcousticAndClassicGuitarFilterConditions filterConditions, String searchKeyword
);

Page<Effector> findEffectors(
int page, int pageSize, InstrumentSortOption sort, EffectorFilterConditions filterConditions
int page, int pageSize, InstrumentSortOption sort, EffectorFilterConditions filterConditions, String searchKeyword
);

Page<Amplifier> findAmplifiers(
int page, int pageSize, InstrumentSortOption sort, AmplifierFilterConditions filterConditions
int page, int pageSize, InstrumentSortOption sort, AmplifierFilterConditions filterConditions, String searchKeyword
);

Page<AudioEquipment> findAudioEquipments(
int page, int pageSize, InstrumentSortOption sort, AudioEquipmentFilterConditions filterConditions
int page, int pageSize, InstrumentSortOption sort, AudioEquipmentFilterConditions filterConditions, String searchKeyword
);
}
Loading
Loading