Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:f-lab-edu/kbo-ticketing into dev…
Browse files Browse the repository at this point in the history
…elop
  • Loading branch information
princenim committed May 30, 2024
2 parents 064e1ec + bf5f051 commit fd423a0
Show file tree
Hide file tree
Showing 11 changed files with 91 additions and 10 deletions.
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
//jwt
implementation group: 'io.jsonwebtoken', name: 'jjwt', version: '0.12.5'
// spring-boot-starter-cache
implementation 'org.springframework.boot:spring-boot-starter-cache'
}

tasks.named('test') {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.kboticketing.kboticketing.config;

import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.cache.RedisCacheConfiguration;
import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
import org.springframework.data.redis.serializer.RedisSerializationContext;
import org.springframework.data.redis.serializer.StringRedisSerializer;

/**
* @author hazel
*/
@EnableCaching
@Configuration
public class RedisCacheConfig {

@Bean
public RedisCacheConfiguration redisCacheConfiguration() {
return RedisCacheConfiguration.defaultCacheConfig()
.disableCachingNullValues()
.serializeKeysWith(
RedisSerializationContext.SerializationPair.fromSerializer(
new StringRedisSerializer())
)
.serializeValuesWith(
RedisSerializationContext.SerializationPair.fromSerializer(
new GenericJackson2JsonRedisSerializer()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.springframework.data.redis.connection.RedisStandaloneConfiguration;
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
import org.springframework.data.redis.serializer.StringRedisSerializer;

/**
Expand Down Expand Up @@ -39,9 +40,10 @@ public RedisConnectionFactory redisConnectionFactory() {
RedisTemplate<?, ?> redisTemplate = new RedisTemplate<>();
redisTemplate.setConnectionFactory(redisConnectionFactory());

// 일반적인 key:value의 경우 직렬화 기본 (JdkSerializationRedisSerializer)
//String으로 직렬화
redisTemplate.setKeySerializer(new StringRedisSerializer());
redisTemplate.setValueSerializer(new StringRedisSerializer());
//JSON으로 직렬화
redisTemplate.setValueSerializer(new GenericJackson2JsonRedisSerializer());

return redisTemplate;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,28 @@
package com.kboticketing.kboticketing.domain;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

/**
* @author hazel
*/
@Getter
@RequiredArgsConstructor
public class ScheduleInfo {

private final Integer scheduleId;
private final String scheduleName;
private final String date;
private final String stadiumName;

@JsonCreator
public ScheduleInfo(@JsonProperty("scheduleId") Integer scheduleId,
@JsonProperty("scheduleName") String scheduleName,
@JsonProperty("date") String date,
@JsonProperty("stadiumName") String stadiumName) {
this.scheduleId = scheduleId;
this.scheduleName = scheduleName;
this.date = date;
this.stadiumName = stadiumName;
}
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,27 @@
package com.kboticketing.kboticketing.domain;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

/**
* @author hazel
*/
@RequiredArgsConstructor
@Getter
public class ScheduleTeam {

private final Integer scheduleId;
private final String scheduleName;
private final String stadiumName;
private final String date;

@JsonCreator
public ScheduleTeam(@JsonProperty("scheduleId") Integer scheduleId,
@JsonProperty("scheduleName") String scheduleName,
@JsonProperty("stadiumName") String stadiumName, @JsonProperty("date") String date) {
this.scheduleId = scheduleId;
this.scheduleName = scheduleName;
this.stadiumName = stadiumName;
this.date = date;
}
}
13 changes: 11 additions & 2 deletions src/main/java/com/kboticketing/kboticketing/domain/SeatGrade.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,27 @@
package com.kboticketing.kboticketing.domain;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

/**
* @author hazel
*/
@Getter
@RequiredArgsConstructor
@EqualsAndHashCode
public class SeatGrade {

private final Integer seatGradeId;
private final String seatGradeName;
private final String seatCount;

@JsonCreator
public SeatGrade(@JsonProperty("seatGradeId") Integer seatGradeId,
@JsonProperty("seatGradeName") String seatGradeName,
@JsonProperty("seatCount") String seatCount) {
this.seatGradeId = seatGradeId;
this.seatGradeName = seatGradeName;
this.seatCount = seatCount;
}
}
10 changes: 8 additions & 2 deletions src/main/java/com/kboticketing/kboticketing/domain/Team.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
package com.kboticketing.kboticketing.domain;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

/**
* @author hazel
*/
@RequiredArgsConstructor
@Getter
public class Team {

private final Integer teamId;
private final String name;

@JsonCreator
public Team(@JsonProperty("teamId") Integer teamId, @JsonProperty("name") String name) {
this.teamId = teamId;
this.name = name;
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
package com.kboticketing.kboticketing.dto;

import java.time.LocalDateTime;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.ToString;

/**
* @author hazel
*/
@Getter
@EqualsAndHashCode
@ToString
public class ScheduleQueryParamDto {

private final Integer teamId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.kboticketing.kboticketing.dto.ScheduleQueryParamDto;
import java.util.ArrayList;
import lombok.RequiredArgsConstructor;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

/**
Expand All @@ -18,10 +19,12 @@ public class ScheduleService {

private final ScheduleMapper scheduleMapper;

@Cacheable(value = "schedules/", key = "#scheduleQueryParamDto.toString()")
public ArrayList<ScheduleTeam> getSchedules(ScheduleQueryParamDto scheduleQueryParamDto) {
return scheduleMapper.selectSchedules(scheduleQueryParamDto);
}

@Cacheable(value = "schedules/", key = "#id")
public ScheduleInfo getSchedule(String id) {
return scheduleMapper.selectInfo(id);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import java.util.Collections;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.script.DefaultRedisScript;
import org.springframework.stereotype.Service;
Expand Down Expand Up @@ -38,6 +39,7 @@ public ReservationSeatDto getSeatsByGrade(String scheduleId, String seatGradeId)
return new ReservationSeatDto(reservedSeat);
}

@Cacheable(value = "seat-grades/", key = "#id")
public SeatGrade getSeatGrade(String id) {
return seatMapper.selectSeatGrade(id);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.kboticketing.kboticketing.domain.Team;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

/**
Expand All @@ -15,6 +16,7 @@ public class TeamService {

private final TeamMapper teamMapper;

@Cacheable(value = "teams/")
public List<Team> getTeams() {
return teamMapper.selectTeams();
}
Expand Down

0 comments on commit fd423a0

Please sign in to comment.