Skip to content
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ build/
!gradle/wrapper/gradle-wrapper.jar
!**/src/main/**/build/
!**/src/test/**/build/
# Spring Boot application configuration files
src/main/resources/application-*.yml

# 추가 #
/resources/uploads/thumbnails/
### STS ###
Expand Down
5 changes: 4 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ version = '0.0.1-SNAPSHOT'

java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
languageVersion = JavaLanguageVersion.of(17)
}
}

Expand Down Expand Up @@ -60,6 +60,9 @@ dependencies {
implementation 'org.webjars:sockjs-client:1.5.1'
//Job Runr
implementation 'org.jobrunr:jobrunr-spring-boot-3-starter:7.3.2'

//MySQL
implementation 'mysql:mysql-connector-java:8.0.20'
}

tasks.named('test') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ public class Auction extends BaseEntity {
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@Version //낙관적 락
private long version;
// @Version //낙관적 락
// private long version;

@Embedded
private AuctionTime auctionTime;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ public class AuctionRepositoryCustomImpl implements AuctionRepositoryCustom {

@Override
public Page<Auction> getAuctions(Pageable pageable, AuctionRequest.SearchCondition condition) {
List<Auction> content = searchAuctions(condition);
long totalCount = buildCountQuery(condition);
List<Auction> content = searchAuctions(pageable, condition);
int totalCount = buildCountQuery(condition);
return new PageImpl<>(content, pageable, totalCount);
}

private List<Auction> searchAuctions(AuctionRequest.SearchCondition condition) {
private List<Auction> searchAuctions(Pageable pageable, AuctionRequest.SearchCondition condition) {
return queryFactory
.selectFrom(auction)
.leftJoin(auction.product, product)
Expand All @@ -57,11 +57,13 @@ private List<Auction> searchAuctions(AuctionRequest.SearchCondition condition) {
auctionStatusEq(condition.getAuctionStatus())
)
.orderBy(sortBy(condition.getSortBy()))
.offset(pageable.getOffset())
.limit(pageable.getPageSize())
.fetch();

}

private long buildCountQuery(AuctionRequest.SearchCondition condition) {
private int buildCountQuery(AuctionRequest.SearchCondition condition) {
return queryFactory
.selectFrom(auction)
.where(
Expand All @@ -73,10 +75,9 @@ private long buildCountQuery(AuctionRequest.SearchCondition condition) {
highestBidLoe(condition.getMaxPrice()),
auctionStatusEq(condition.getAuctionStatus())
)
.fetchCount();
.fetch().size();
}


private Predicate auctionCategoryEq(AuctionCategory auctionCategory) {
return auctionCategory != null ? auction.auctionCategory.eq(auctionCategory) : null;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package com.example.na0th.auction.domain.product.model;

import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
Expand All @@ -20,6 +17,7 @@ public class Product {
private Long id;
private String name;
private String description;
@Enumerated(EnumType.STRING)
private ProductCategory productCategory;

// private Auction auction;
Expand Down
30 changes: 20 additions & 10 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,38 +12,48 @@ spring:
console:
enabled: true
path: /h2-console
datasource:
url: jdbc:h2:mem:testdb
driver-class-name: org.h2.Driver
username: sa
password: sa
jpa:
hibernate:
ddl-auto: create-drop
ddl-auto: update
properties:
hibernate:
show-sql: true
format_sql: true
# jdbc:
# batch_size: 20 # 한 번에 처리할 배치 크기
# order_inserts: true # INSERT 쿼리 정렬
# order_updates: true
# default_batch_fetch_size: 100
default_batch_fetch_size: 100
# database-platform: org.hibernate.dialect.H2Dialect

database-platform: org.hibernate.dialect.H2Dialect
profiles:
include:
- jwt
- mysql
active: no-security

logging:
level:
org.hibernate.SQL: DEBUG
org.hibernate.type.descriptor.sql.BasicBinder: TRACE
# org.h2: OFF
# com.p6spy: DEBUG
# org.h2.engine: TRACE
# p6spy: info
# org.springframework.jdbc.core.JdbcTemplate: DEBUG
# org:
# springframework:
# jdbc:
# core:
# StatementCreatorUtils: TRACE
# org.hibernate.type.descriptor.sql.BasicBinder: TRACE
# org.hibernate.id.enhanced.SequenceStructure: TRACE
# org.springframework.jdbc.datasource: TRACE # JDBC 배치 로그
# com.zaxxer.hikari.HikariDataSource: DEBUG

server:
port: 8080

org :
org:
jobrunr:
job-scheduler:
enabled: true # 작업 스케줄러 활성화
Expand Down