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

#6 place basic dev02 #30

Closed
wants to merge 14 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
14 commits
Select commit Hold shift + click to select a range
c84ae62
[feat] ์—ฌํ–‰์ง€ ์—”ํ‹ฐํ‹ฐ 1์ฐจ ๊ตฌํ˜„
junmo95 Jan 3, 2024
c47b346
[feat] ์—ฌํ–‰์ง€ ์ปจํŠธ๋กค๋Ÿฌ 1์ฐจ ๊ตฌํ˜„
junmo95 Jan 3, 2024
4a70f0b
[feat] ์—ฌํ–‰์ง€ ์˜ˆ์™ธ 1์ฐจ ๊ตฌํ˜„
junmo95 Jan 3, 2024
ae50d20
[feat] ์—ฌํ–‰์ง€ ์„œ๋น„์Šค 1์ฐจ ๊ตฌํ˜„
junmo95 Jan 3, 2024
8aed152
[feat] ์—ฌํ–‰์ง€ ๋ ˆํฌ์ง€ํ† ๋ฆฌ 1์ฐจ ๊ตฌํ˜„
junmo95 Jan 3, 2024
662aadd
[feat] ์—ฌํ–‰์ง€ ๊ฐœ๋ฐœ ์šฉ์ด๋ฅผ ์œ„ํ•ด security ์˜ต์…˜์ถ”๊ฐ€
junmo95 Jan 3, 2024
4e04b89
Merge branch 'develop' of github.com:TripComeTrue/TripComeTrue_BE intโ€ฆ
junmo95 Jan 3, 2024
d7beb6c
Merge branch 'develop' of github.com:TripComeTrue/TripComeTrue_BE intโ€ฆ
junmo95 Jan 3, 2024
6a9e4c0
[refactor] dto ์ˆ˜์ •
junmo95 Jan 4, 2024
c823292
[refactor] update ๋กœ์ง ์ˆ˜์ •
junmo95 Jan 4, 2024
d609273
[refactor] ํ•„ํ„ฐ๋ง ๋ฐ์ดํ„ฐ ๋ฐ›์•„์˜ค๋Š” ๋ฐฉ๋ฒ• ๋ณ€๊ฒฝ
junmo95 Jan 4, 2024
3675676
[refactor] objectMapper ์„ค์ • ์ถ”๊ฐ€ & ๋ถˆํ•„์š”ํ•œ import ์ œ๊ฑฐ
junmo95 Jan 4, 2024
93043c9
[refactor] dto ๋ช… ์ˆ˜์ •
junmo95 Jan 4, 2024
ef12d1c
[refactor] place entity ์ˆ˜์ •
junmo95 Jan 4, 2024
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
Prev Previous commit
Next Next commit
[feat] ์—ฌํ–‰์ง€ ๋ ˆํฌ์ง€ํ† ๋ฆฌ 1์ฐจ ๊ตฌํ˜„
- ๊ธฐ๋ณธ์ ์ธ ํ‹€์„ ๊ตฌํ˜„ํ•˜๊ธฐ ์œ„ํ•œ ๋ ˆํฌ์ง€ํ† ๋ฆฌ ๊ตฌํ˜„
- querydsl ์ ์šฉ ๋ฐ ์ปค์Šคํ…€ ๋ ˆํฌ์ง€ํ† ๋ฆฌ
junmo95 committed Jan 3, 2024
commit 8aed1527257afa361e0a06cd006b0b8d53fb9ecc
29 changes: 29 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -31,14 +31,43 @@ dependencies {
//mysql connector
runtimeOnly 'com.mysql:mysql-connector-j'

// queryDSL ์„ค์ •
implementation 'com.querydsl:querydsl-jpa:5.0.0:jakarta'
annotationProcessor "com.querydsl:querydsl-apt:5.0.0:jakarta"
annotationProcessor "jakarta.annotation:jakarta.annotation-api"
annotationProcessor "jakarta.persistence:jakarta.persistence-api"

annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.security:spring-security-test'

// yml
implementation 'org.yaml:snakeyaml:+'

}

tasks.named('test') {
useJUnitPlatform()
}


// Querydsl ์„ค์ •๋ถ€
// ์•„๋ž˜ ๊ฒƒ๋“ค์ด ์—†์–ด๋„ ๊ธฐ๋ณธ์ ์ธ querydsl ๋™์ž‘์€ ํ•˜๋‚˜ ์ธํ…Œ๋ฆฌ์ œ์ด์—์„œ ๋นŒ๋“œ ์‹œ ๋ฐœ์ƒํ•  ๋ฌธ์ œ๋ฅผ ์˜ˆ๋ฐฉ
def generated = 'src/main/generated'

// querydsl QClass ํŒŒ์ผ ์ƒ์„ฑ ์œ„์น˜๋ฅผ ์ง€์ •
// ์›๋ž˜ build ๋””๋ ‰ํ† ๋ฆฌ ์•ˆ์— ์žˆ์–ด์„œ ๋ˆˆ์— ์•ˆ๋ณด์˜€์ง€๋งŒ ๊บผ๋„ค์„œ ๋‚ด๊ฐ€ ์ง€์ •ํ•œ ๋””๋ ‰ํ† ๋ฆฌ์— ๊บผ๋‚ด์˜ด
// ์ธํ…”๋ฆฌ์ œ์ด IDE์™€์˜ ๋ฌธ์ œ์ธ๋ฐ, ๋นŒ๋“œ gradle ํ• ๋•Œ ์Šค์บ” ์˜์—ญ์ด ๋‹ฌ๋ผ์„œ ์ค‘๋ณต ์Šค์บ”์ด ๋ฐœ์ƒํ•  ์ˆ˜ ์žˆ๋‹ค.
tasks.withType(JavaCompile) {
options.getGeneratedSourceOutputDirectory().set(file(generated))
}

// java source set ์— querydsl QClass ์œ„์น˜ ์ถ”๊ฐ€
sourceSets {
main.java.srcDirs += [ generated ]
}

// gradle clean ์‹œ์— QClass ๋””๋ ‰ํ† ๋ฆฌ ์‚ญ์ œ
clean {
delete file(generated)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.haejwo.tripcometrue.domain.place.dto.request;

public record PlaceFilterRequestDto(
Integer stored_count,
Integer storedCount
) {

// record๋Š” Compact Constructor๋ผ๋Š” ๊ธฐ๋Šฅ์žˆ์–ด, ์ƒ์„ฑ์ž ๋‚ด๋ถ€์˜ ๋ณ€์ˆ˜์— ๋Œ€ํ•œ ๋กœ์ง์ด ๋งˆ์ง€๋ง‰์œผ๋กœ ๋™์ž‘ํ•˜์—ฌ ๋ณ€์ˆ˜ ์ดˆ๊ธฐํ™”๋ฅผ ํ•œ๋‹ค.
public PlaceFilterRequestDto {
storedCount = stored_count;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.haejwo.tripcometrue.domain.place.repositroy;

import com.haejwo.tripcometrue.domain.place.dto.request.PlaceFilterRequestDto;
import com.haejwo.tripcometrue.domain.place.entity.Place;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;

public interface PlaceCustomRepository {

Page<Place> findPlaceWithFilter(Pageable pageable,
PlaceFilterRequestDto requestDto);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.haejwo.tripcometrue.domain.place.repositroy;

import com.haejwo.tripcometrue.domain.place.dto.request.PlaceFilterRequestDto;
import com.haejwo.tripcometrue.domain.place.entity.Place;
import com.haejwo.tripcometrue.domain.place.entity.QPlace;
import com.querydsl.core.BooleanBuilder;
import com.querydsl.core.QueryResults;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.support.QuerydslRepositorySupport;

public class PlaceCustomRepositoryImpl extends QuerydslRepositorySupport implements PlaceCustomRepository {

public PlaceCustomRepositoryImpl() {
super(Place.class);
}

@Override
public Page<Place> findPlaceWithFilter(Pageable pageable, PlaceFilterRequestDto requestDto) {

QPlace place = QPlace.place;
BooleanBuilder booleanBuilder = new BooleanBuilder();

if(requestDto.storedCount() != null && requestDto.storedCount() >= 0) {
booleanBuilder.and(place.storedCount.goe(requestDto.storedCount()));
}

QueryResults<Place> result = from(place)
.where(booleanBuilder)
.offset(pageable.getOffset())
.limit(pageable.getPageSize())
.fetchResults();

return new PageImpl<>(result.getResults(), pageable, result.getTotal());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.haejwo.tripcometrue.domain.place.repositroy;

import com.haejwo.tripcometrue.domain.place.entity.Place;
import org.springframework.data.jpa.repository.JpaRepository;

public interface PlaceRepository extends
JpaRepository<Place, Long>,
PlaceCustomRepository
{

}