-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #32 from EunChanNam/develop
release: User 제외 모든 도메인 테스트 적용
- Loading branch information
Showing
107 changed files
with
4,054 additions
and
741 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
src/main/java/com/inq/wishhair/wesharewishhair/global/config/RedisConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.inq.wishhair.wesharewishhair.global.config; | ||
|
||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.data.redis.connection.RedisConnectionFactory; | ||
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory; | ||
import org.springframework.data.redis.core.RedisTemplate; | ||
import org.springframework.data.redis.serializer.GenericToStringSerializer; | ||
import org.springframework.data.redis.serializer.StringRedisSerializer; | ||
|
||
@Configuration | ||
public class RedisConfig { | ||
|
||
@Value("${spring.data.redis.host}") | ||
public String host; | ||
@Value("${spring.data.redis.port}") | ||
public int port; | ||
|
||
@Bean | ||
public LettuceConnectionFactory lettuceConnectionFactory() { | ||
return new LettuceConnectionFactory(host, port); | ||
} | ||
|
||
@Bean | ||
public RedisTemplate<String, Long> cacheManager(RedisConnectionFactory redisConnectionFactory) { | ||
RedisTemplate<String, Long> redisTemplate = new RedisTemplate<>(); | ||
redisTemplate.setConnectionFactory(redisConnectionFactory); | ||
redisTemplate.setKeySerializer(new StringRedisSerializer()); | ||
redisTemplate.setValueSerializer(new GenericToStringSerializer<>(Long.class)); | ||
return redisTemplate; | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
src/main/java/com/inq/wishhair/wesharewishhair/global/config/SchedulerConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.inq.wishhair.wesharewishhair.global.config; | ||
|
||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.scheduling.annotation.EnableScheduling; | ||
|
||
@Configuration | ||
@EnableScheduling | ||
public class SchedulerConfig { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
src/main/java/com/inq/wishhair/wesharewishhair/global/utils/RedisUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package com.inq.wishhair.wesharewishhair.global.utils; | ||
|
||
import java.util.Optional; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.data.redis.core.RedisTemplate; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
public class RedisUtils { | ||
|
||
private final RedisTemplate<String, Long> redisTemplate; | ||
private final long expireTime; | ||
|
||
public RedisUtils( | ||
RedisTemplate<String, Long> redisTemplate, | ||
@Value("${spring.data.redis.expire-time}") long expireTime | ||
) { | ||
this.redisTemplate = redisTemplate; | ||
this.expireTime = expireTime; | ||
} | ||
|
||
public void setData(Long key, Long value) { | ||
redisTemplate | ||
.opsForValue() | ||
.set(String.valueOf(key), value, expireTime, TimeUnit.MILLISECONDS); | ||
} | ||
|
||
public void increaseData(Long key) { | ||
redisTemplate.opsForValue().increment(String.valueOf(key)); | ||
} | ||
|
||
public void decreaseData(Long key) { | ||
redisTemplate.opsForValue().decrement(String.valueOf(key)); | ||
} | ||
|
||
public Optional<Long> getData(Long key) { | ||
return Optional.ofNullable( | ||
redisTemplate.opsForValue().get(String.valueOf(key)) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
...ation/query/HairStyleQueryRepository.java → ...tyle/domain/HairStyleQueryRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 1 addition & 7 deletions
8
...java/com/inq/wishhair/wesharewishhair/hairstyle/infrastructure/WishHairJpaRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,13 @@ | ||
package com.inq.wishhair.wesharewishhair.hairstyle.infrastructure; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Modifying; | ||
import org.springframework.data.jpa.repository.Query; | ||
import org.springframework.data.repository.query.Param; | ||
|
||
import com.inq.wishhair.wesharewishhair.hairstyle.domain.wishhair.WishHair; | ||
import com.inq.wishhair.wesharewishhair.hairstyle.domain.wishhair.WishHairRepository; | ||
|
||
public interface WishHairJpaRepository extends WishHairRepository, JpaRepository<WishHair, Long> { | ||
|
||
@Modifying | ||
@Query("delete from WishHair w where w.hairStyleId = :hairStyleId and w.userId = :userId") | ||
void deleteByHairStyleIdAndUserId(@Param("hairStyleId") Long hairStyleId, | ||
@Param("userId") Long userId); | ||
void deleteByHairStyleIdAndUserId(Long hairStyleId, Long userId); | ||
|
||
boolean existsByHairStyleIdAndUserId(Long hairStyleId, Long userId); | ||
} |
Oops, something went wrong.