-
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 #26 from pandahwang/dev
구현 완료 버전 master 브랜치에 적용
- Loading branch information
Showing
40 changed files
with
1,510 additions
and
24 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
name: Deploy To EC2 | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
Deploy: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: SSH(원격 접속)로 EC2에 접속하기 | ||
uses: appleboy/[email protected] | ||
env: | ||
APPLICATION_PROPERTIES: ${{ secrets.APPLICATION_PROPERTIES }} | ||
with: | ||
host: ${{ secrets.EC2_HOST }} | ||
username: ${{ secrets.EC2_USERNAME }} | ||
key: ${{ secrets.EC2_PRIVATE_KEY }} | ||
envs: APPLICATION_PROPERTIES | ||
script_stop: true | ||
script: | | ||
cd /home/ubuntu/LostArk | ||
rm -rf src/main/resources/application.properties | ||
git pull origin master | ||
echo "$APPLICATION_PROPERTIES" > src/main/resources/application.properties | ||
./gradlew clean build | ||
docker compose -f compose-prod.yml down | ||
docker compose -f compose-prod.yml up --build -d |
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,5 @@ | ||
FROM openjdk:17-jdk | ||
|
||
COPY build/libs/*SNAPSHOT.jar app.jar | ||
|
||
ENTRYPOINT ["java", "-jar", "/app.jar"] |
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,5 @@ | ||
FROM openjdk:17-jdk | ||
|
||
COPY build/libs/*SNAPSHOT.jar app.jar | ||
|
||
ENTRYPOINT ["java", "-jar", "-Dspring.profiles.active=prod", "/app.jar"] |
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 @@ | ||
로스트아크 직업 추천 팀 프로제트 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
services: | ||
api-server: | ||
build: | ||
context: . | ||
dockerfile: ./Dockerfile-prod | ||
ports: | ||
- 8080:8080 | ||
depends_on: | ||
cache-server: | ||
condition: service_healthy | ||
cache-server: | ||
image: redis | ||
command: redis-server --maxmemory 512mb --maxmemory-policy allkeys-lru | ||
ports: | ||
- 6379:6379 | ||
healthcheck: | ||
test: [ "CMD", "redis-cli", "ping" ] | ||
interval: 5s | ||
retries: 10 |
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,16 @@ | ||
services: | ||
api-server: | ||
build: . | ||
ports: | ||
- 8080:8080 | ||
depends_on: | ||
cache-server: | ||
condition: service_healthy | ||
cache-server: | ||
image: redis | ||
ports: | ||
- 6379:6379 | ||
healthcheck: | ||
test: [ "CMD", "redis-cli", "ping" ] | ||
interval: 5s | ||
retries: 10 |
41 changes: 41 additions & 0 deletions
41
src/main/java/com/TeamNull/LostArk/LostArk/Job/JobAttributes.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,41 @@ | ||
package com.TeamNull.LostArk.LostArk.Job; | ||
|
||
|
||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.Setter; | ||
|
||
@Getter | ||
@Setter | ||
public class JobAttributes { | ||
private final String jobName; | ||
private final int Agreeableness; | ||
private final int conscientiousness; | ||
private final int extraversion; | ||
private final int openness; | ||
private final int neuroticism; | ||
private final String color; | ||
private final String icon; | ||
|
||
@JsonCreator | ||
public JobAttributes( | ||
@JsonProperty("jobName") String jobName, | ||
@JsonProperty("Agreeableness") int Agreeableness, | ||
@JsonProperty("conscientiousness") int conscientiousness, | ||
@JsonProperty("extraversion") int extraversion, | ||
@JsonProperty("openness") int openness, | ||
@JsonProperty("neuroticism") int neuroticism, | ||
@JsonProperty("color") String color, | ||
@JsonProperty("icon") String icon) { | ||
this.jobName = jobName; | ||
this.Agreeableness = Agreeableness; | ||
this.conscientiousness = conscientiousness; | ||
this.extraversion = extraversion; | ||
this.openness = openness; | ||
this.neuroticism = neuroticism; | ||
this.color = color; | ||
this.icon = icon; | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
src/main/java/com/TeamNull/LostArk/LostArk/Job/TopFactor.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,18 @@ | ||
package com.TeamNull.LostArk.LostArk.Job; | ||
|
||
import jakarta.persistence.Embeddable; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
|
||
@Getter | ||
@Setter | ||
@Embeddable | ||
public class TopFactor { | ||
private String jobName; | ||
private double value; | ||
|
||
public TopFactor(String jobName, double value) { | ||
this.jobName = jobName; | ||
this.value = value; | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/main/java/com/TeamNull/LostArk/LostArk/Job/TopFactorConverter.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,21 @@ | ||
package com.TeamNull.LostArk.LostArk.Job; | ||
|
||
import jakarta.persistence.AttributeConverter; | ||
import jakarta.persistence.Converter; | ||
|
||
@Converter | ||
public class TopFactorConverter implements AttributeConverter<TopFactor, String> { | ||
|
||
@Override | ||
public String convertToDatabaseColumn(TopFactor topFactor) { | ||
// 예: "jobName:value" 형식으로 직렬화 | ||
return topFactor.getJobName() + ":" + topFactor.getValue(); | ||
} | ||
|
||
@Override | ||
public TopFactor convertToEntityAttribute(String dbData) { | ||
// 역직렬화: "jobName:value" 형식을 객체로 변환 | ||
String[] data = dbData.split(":"); | ||
return new TopFactor(data[0], Double.parseDouble(data[1])); | ||
} | ||
} |
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
42 changes: 42 additions & 0 deletions
42
src/main/java/com/TeamNull/LostArk/LostArk/config/RedisCacheConfig.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,42 @@ | ||
package com.TeamNull.LostArk.LostArk.config; | ||
|
||
import org.springframework.cache.CacheManager; | ||
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.cache.RedisCacheManager; | ||
import org.springframework.data.redis.connection.RedisConnectionFactory; | ||
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer; | ||
import org.springframework.data.redis.serializer.RedisSerializationContext; | ||
import org.springframework.data.redis.serializer.StringRedisSerializer; | ||
|
||
import java.time.Duration; | ||
|
||
@Configuration | ||
@EnableCaching // Spring Boot의 캐싱 설정을 활성화 | ||
public class RedisCacheConfig { | ||
@Bean | ||
public CacheManager commentCacheManager(RedisConnectionFactory redisConnectionFactory) { | ||
RedisCacheConfiguration redisCacheConfiguration = RedisCacheConfiguration | ||
.defaultCacheConfig() | ||
// Redis에 Key를 저장할 때 String으로 직렬화(변환)해서 저장 | ||
.serializeKeysWith( | ||
RedisSerializationContext.SerializationPair.fromSerializer( | ||
new StringRedisSerializer())) | ||
// Redis에 Value를 저장할 때 Json으로 직렬화(변환)해서 저장 | ||
.serializeValuesWith( | ||
RedisSerializationContext.SerializationPair.fromSerializer( | ||
new Jackson2JsonRedisSerializer<Object>(Object.class) | ||
) | ||
) | ||
// 데이터의 만료기간(TTL) 설정 | ||
.entryTtl(Duration.ofMinutes(1L)); | ||
|
||
return RedisCacheManager | ||
.RedisCacheManagerBuilder | ||
.fromConnectionFactory(redisConnectionFactory) | ||
.cacheDefaults(redisCacheConfiguration) | ||
.build(); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/main/java/com/TeamNull/LostArk/LostArk/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,23 @@ | ||
package com.TeamNull.LostArk.LostArk.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.RedisStandaloneConfiguration; | ||
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory; | ||
|
||
@Configuration | ||
public class RedisConfig { | ||
@Value("${spring.data.redis.host}") | ||
private String host; | ||
|
||
@Value("${spring.data.redis.port}") | ||
private int port; | ||
|
||
@Bean | ||
public LettuceConnectionFactory redisConnectionFactory() { | ||
// Lettuce라는 라이브러리를 활용해 Redis 연결을 관리하는 객체를 생성하고 | ||
// Redis 서버에 대한 정보(host, port)를 설정한다. | ||
return new LettuceConnectionFactory(new RedisStandaloneConfiguration(host, port)); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
src/main/java/com/TeamNull/LostArk/LostArk/config/WebConfig.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,25 @@ | ||
package com.TeamNull.LostArk.LostArk.config; | ||
|
||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.web.servlet.config.annotation.CorsRegistry; | ||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; | ||
|
||
@Configuration | ||
public class WebConfig implements WebMvcConfigurer { | ||
|
||
@Override | ||
public void addCorsMappings(CorsRegistry registry) { | ||
registry.addMapping("/**") | ||
.allowedOrigins( | ||
"http://localhost:3000", | ||
"http://52.79.232.220:3000", | ||
"http://classtest.site", | ||
"http://la.classtest.site", | ||
"https://classtest.site", | ||
"https://la.classtest.site" | ||
) | ||
.allowedMethods("GET", "POST", "PUT", "DELETE") | ||
.allowedHeaders("*") | ||
.allowCredentials(true); | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
src/main/java/com/TeamNull/LostArk/LostArk/controller/CommentController.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,4 +1,66 @@ | ||
package com.TeamNull.LostArk.LostArk.controller; | ||
|
||
import com.TeamNull.LostArk.LostArk.dto.CommentDto; | ||
import com.TeamNull.LostArk.LostArk.service.CommentService; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.cache.annotation.CacheEvict; | ||
import org.springframework.cache.annotation.Cacheable; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.data.domain.Sort; | ||
import org.springframework.data.web.PageableDefault; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
|
||
import java.util.*; | ||
|
||
|
||
@RestController | ||
@RequestMapping("/api/comment") | ||
@RequiredArgsConstructor | ||
public class CommentController { | ||
|
||
private final CommentService commentService; | ||
|
||
@Cacheable(cacheNames = "getComments", key = "'comments:page:' + #page + ':searchText:' + #searchText", cacheManager = "commentCacheManager") | ||
@GetMapping("/{page}") | ||
public Map<String, Object> commentPage(@PathVariable Integer page, | ||
@RequestParam(required = false) String searchText, | ||
@PageableDefault(size = 5, sort = "createdAt", direction = Sort.Direction.DESC) Pageable pageable) { | ||
return commentService.getComments(page, searchText, pageable); | ||
} | ||
|
||
|
||
@PostMapping("/{userID}") | ||
@CacheEvict(cacheNames = "getComments", allEntries = true, cacheManager = "commentCacheManager") | ||
public void addComment(@PathVariable("userID") UUID userID, @RequestBody CommentDto commentDto) | ||
{ | ||
commentService.getAddComment(commentDto.getContent(), | ||
commentDto.getPassword(), | ||
commentDto.getNickname(), | ||
userID | ||
); | ||
} | ||
|
||
@DeleteMapping("/delete/{userID}/{commentId}") | ||
@CacheEvict(cacheNames = "getComments", allEntries = true, cacheManager = "commentCacheManager") | ||
public ResponseEntity<String> commentDelete(@PathVariable("userID") UUID userID, | ||
@PathVariable Integer commentId, | ||
@RequestBody CommentDto dropComment) | ||
{ | ||
return commentService.getCommentDelete(userID,commentId,dropComment.getPassword()); | ||
} | ||
|
||
@PutMapping("/update/{userID}/{commentId}") | ||
@CacheEvict(cacheNames = "getComments", allEntries = true, cacheManager = "commentCacheManager") | ||
public ResponseEntity<String> commentUpdate(@PathVariable("userID") UUID userID, | ||
@PathVariable int commentId, | ||
@RequestBody CommentDto updatedComment) { | ||
return commentService.getCommentUpdate(userID, commentId, updatedComment.getPassword(), updatedComment.getContent()); | ||
} | ||
|
||
} | ||
|
||
|
||
|
||
|
28 changes: 28 additions & 0 deletions
28
src/main/java/com/TeamNull/LostArk/LostArk/controller/DataController.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,4 +1,32 @@ | ||
package com.TeamNull.LostArk.LostArk.controller; | ||
|
||
import com.TeamNull.LostArk.LostArk.dto.DataDto; | ||
import com.TeamNull.LostArk.LostArk.service.DataService; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.cache.annotation.Cacheable; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import java.lang.reflect.InvocationTargetException; | ||
import java.util.List; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/api") | ||
public class DataController { | ||
|
||
private final DataService dataService; | ||
|
||
@GetMapping("/statistics/data") | ||
|
||
public List<DataDto> read () { | ||
List<DataDto> resData = null; | ||
try { | ||
resData = dataService.read(); | ||
} catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) { | ||
e.printStackTrace(); | ||
} | ||
return resData; | ||
} | ||
} |
Oops, something went wrong.