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
9 changes: 8 additions & 1 deletion dev-route/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'io.micrometer:micrometer-registry-prometheus'

implementation 'com.querydsl:querydsl-jpa:5.0.0:jakarta'
annotationProcessor "com.querydsl:querydsl-apt:${dependencyManagement.importedProperties['querydsl.version']}:jakarta"
annotationProcessor "jakarta.annotation:jakarta.annotation-api"
annotationProcessor "jakarta.persistence:jakarta.persistence-api"

}

tasks.named('test') {
Expand All @@ -70,6 +75,8 @@ task copySecret(type: Copy) {
}
into ('./src/main/resources')
}

clean {
delete file('src/main/generated')
}


Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
package com.teamdevroute.devroute;

import com.teamdevroute.devroute.video.QueryDslConfig;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Import;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
import org.springframework.scheduling.annotation.EnableScheduling;

@EnableJpaAuditing
@EnableScheduling
@SpringBootApplication
//@Import(QueryDslConfig.class)
public class DevRouteApplication {

public static void main(String[] args) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,74 +38,79 @@ public void loadVideoData(){
Long count=0L;
for (PlatformName platformname : PlatformName.values()) {
for (TechnologyStackName value : TechnologyStackName.values()) {
switch (platformname) {
case Inflearn:
if(count%3==0)
createVideo(
0L, platformname+"의 유명한 "+value+" 비디오",
"https://www.inflearn.com/course/%EA%B9%A1%EC%83%98%EC%9D%98-%EC%8C%A9%EC%B4%88%EB%B3%B4-%EC%95%88%EB%93%9C%EB%A1%9C%EC%9D%B4%EB%93%9C-part5?attributionToken=ChM1ODg3MTk1NTc2ODEzOTQ3ODQwEA0aI3JlY29tbWVuZGVfcmVjb21tZW5kZV8xNzAyNTI2NDM0MDY2IhdyZWNvbW1lbmRlZC1mb3IteW91LWN2cigAOij38dES-vHRErTx0RKy8dESqfLREq3y0RKP8tESjPLREr7y0RK78tES"
,
"https://cdn.inflearn.com/public/courses/334276/cover/87c0dc98-efe3-47ab-82ce-225a45c2e7a7/334276.png?w=420 ",
count, String.valueOf(value), String.valueOf(platformname)
);
if(count%3==1)
createVideo(
0L, platformname+"의 유명한 "+value+" 비디오",
"https://www.inflearn.com/course/vue-3-%EC%8B%9C%EC%9E%91%ED%95%98%EA%B8%B0?attributionToken=ChQxNDU5NjE4NDYyMDA0NTA0Mzc3NBANGiNyZWNvbW1lbmRlX3JlY29tbWVuZGVfMTcwMjUyNjQzNDA2NiIXcmVjb21tZW5kZWQtZm9yLXlvdS1jdnIoADoo-vHRErTx0RKy8dESu_LREozy0RL38dESj_LREqny0RKt8tESvvLREg"
,
"https://cdn.inflearn.com/public/courses/332010/cover/fffd02eb-685e-44ab-aa0d-6788349338c5/332010-eng.png?w=420",
count, String.valueOf(value), String.valueOf(platformname)
);
if(count%3==2)
createVideo(
0L, platformname+"의 유명한 "+value+" 비디오",
"https://www.inflearn.com/course/amazing-javascript-%EC%9E%85%EB%AC%B8?attributionToken=ChQxNDU5NjE4NDYyMDA0NTA0Mzc3NBANGiNyZWNvbW1lbmRlX3JlY29tbWVuZGVfMTcwMjUyNjQzNDA2NiIXcmVjb21tZW5kZWQtZm9yLXlvdS1jdnIoADoo-vHRErTx0RKy8dESu_LREozy0RL38dESj_LREqny0RKt8tESvvLREg",
"https://cdn.inflearn.com/public/courses/334104/cover/8eafc0d0-1be5-426a-be30-38bb90ccec21/334104.png?w=420" ,
count, String.valueOf(value), String.valueOf(platformname)
);

case Youtube:
if(count%3==0)
createVideo(
0L, platformname+"의 유명한 "+value+" 비디오","https://www.youtube.com/watch?v=lYmLUiBAqqM"
,"https://i.ytimg.com/vi/lYmLUiBAqqM/default.jpg",
count, String.valueOf(value), String.valueOf(platformname)
);
if(count%3==1)
createVideo(
0L, platformname+"의 유명한 "+value+" 비디오","https://www.youtube.com/watch?v=lYmLUiBAqqM"
,"https://i.ytimg.com/vi/lYmLUiBAqqM/default.jpg",
count, String.valueOf(value), String.valueOf(platformname)
);
if(count%3==2)
createVideo(
0L, platformname+"의 유명한 "+value+" 비디오","https://www.youtube.com/watch?v=lYmLUiBAqqM"
,"https://i.ytimg.com/vi/lYmLUiBAqqM/default.jpg",
count, String.valueOf(value), String.valueOf(platformname)
);
case Udemy:
if(count%3==0)
createVideo(
0L, platformname+"의 유명한 "+value+" 비디오","https://www.udemy.com/course/javascript-zero-to-expert-the-complete-modern-guide-build-real-apps/"
,"https://img-c.udemycdn.com/course/125_H/3429704_e81d_4.jpg",
count, String.valueOf(value), String.valueOf(platformname)
);
if(count%3==1)
createVideo(
0L, platformname+"의 유명한 "+value+" 비디오","https://www.udemy.com/course/complete-angular-14-course-learn-frontend-development/"
,"https://img-c.udemycdn.com/course/125_H/4844324_2d2b_4.jpg",
count, String.valueOf(value), String.valueOf(platformname)
);
if(count%3==2)
createVideo(
0L, platformname+"의 유명한 "+value+" 비디오","https://www.udemy.com/course/html-css-for-beginer/ "
,"https://img-c.udemycdn.com/course/125_H/3426600_1577.jpg",
count, String.valueOf(value), String.valueOf(platformname)
);
count += 1;
while (count < 1000) {
switch (platformname) {
case Inflearn:
if (count % 3 == 0)
createVideo(
0L, platformname + "의 유명한 " + value + " 비디오",
"https://www.inflearn.com/course/%EA%B9%A1%EC%83%98%EC%9D%98-%EC%8C%A9%EC%B4%88%EB%B3%B4-%EC%95%88%EB%93%9C%EB%A1%9C%EC%9D%B4%EB%93%9C-part5?attributionToken=ChM1ODg3MTk1NTc2ODEzOTQ3ODQwEA0aI3JlY29tbWVuZGVfcmVjb21tZW5kZV8xNzAyNTI2NDM0MDY2IhdyZWNvbW1lbmRlZC1mb3IteW91LWN2cigAOij38dES-vHRErTx0RKy8dESqfLREq3y0RKP8tESjPLREr7y0RK78tES"
,
"https://cdn.inflearn.com/public/courses/334276/cover/87c0dc98-efe3-47ab-82ce-225a45c2e7a7/334276.png?w=420 ",
count, String.valueOf(value), String.valueOf(platformname)
);
if (count % 3 == 1)
createVideo(
0L, platformname + "의 유명한 " + value + " 비디오",
"https://www.inflearn.com/course/vue-3-%EC%8B%9C%EC%9E%91%ED%95%98%EA%B8%B0?attributionToken=ChQxNDU5NjE4NDYyMDA0NTA0Mzc3NBANGiNyZWNvbW1lbmRlX3JlY29tbWVuZGVfMTcwMjUyNjQzNDA2NiIXcmVjb21tZW5kZWQtZm9yLXlvdS1jdnIoADoo-vHRErTx0RKy8dESu_LREozy0RL38dESj_LREqny0RKt8tESvvLREg"
,
"https://cdn.inflearn.com/public/courses/332010/cover/fffd02eb-685e-44ab-aa0d-6788349338c5/332010-eng.png?w=420",
count, String.valueOf(value), String.valueOf(platformname)
);
if (count % 3 == 2)
createVideo(
0L, platformname + "의 유명한 " + value + " 비디오",
"https://www.inflearn.com/course/amazing-javascript-%EC%9E%85%EB%AC%B8?attributionToken=ChQxNDU5NjE4NDYyMDA0NTA0Mzc3NBANGiNyZWNvbW1lbmRlX3JlY29tbWVuZGVfMTcwMjUyNjQzNDA2NiIXcmVjb21tZW5kZWQtZm9yLXlvdS1jdnIoADoo-vHRErTx0RKy8dESu_LREozy0RL38dESj_LREqny0RKt8tESvvLREg",
"https://cdn.inflearn.com/public/courses/334104/cover/8eafc0d0-1be5-426a-be30-38bb90ccec21/334104.png?w=420",
count, String.valueOf(value), String.valueOf(platformname)
);
break;

case Youtube:
if (count % 3 == 0)
createVideo(
0L, platformname + "의 유명한 " + value + " 비디오", "https://www.youtube.com/watch?v=lYmLUiBAqqM"
, "https://i.ytimg.com/vi/lYmLUiBAqqM/default.jpg",
count, String.valueOf(value), String.valueOf(platformname)
);
if (count % 3 == 1)
createVideo(
0L, platformname + "의 유명한 " + value + " 비디오", "https://www.youtube.com/watch?v=lYmLUiBAqqM"
, "https://i.ytimg.com/vi/lYmLUiBAqqM/default.jpg",
count, String.valueOf(value), String.valueOf(platformname)
);
if (count % 3 == 2)
createVideo(
0L, platformname + "의 유명한 " + value + " 비디오", "https://www.youtube.com/watch?v=lYmLUiBAqqM"
, "https://i.ytimg.com/vi/lYmLUiBAqqM/default.jpg",
count, String.valueOf(value), String.valueOf(platformname)
);
break;
case Udemy:
if (count % 3 == 0)
createVideo(
0L, platformname + "의 유명한 " + value + " 비디오", "https://www.udemy.com/course/javascript-zero-to-expert-the-complete-modern-guide-build-real-apps/"
, "https://img-c.udemycdn.com/course/125_H/3429704_e81d_4.jpg",
count, String.valueOf(value), String.valueOf(platformname)
);
if (count % 3 == 1)
createVideo(
0L, platformname + "의 유명한 " + value + " 비디오", "https://www.udemy.com/course/complete-angular-14-course-learn-frontend-development/"
, "https://img-c.udemycdn.com/course/125_H/4844324_2d2b_4.jpg",
count, String.valueOf(value), String.valueOf(platformname)
);
if (count % 3 == 2)
createVideo(
0L, platformname + "의 유명한 " + value + " 비디오", "https://www.udemy.com/course/html-css-for-beginer/ "
, "https://img-c.udemycdn.com/course/125_H/3426600_1577.jpg",
count, String.valueOf(value), String.valueOf(platformname)
);
break;
}
count += 1;

}
}

}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
@Bean
public CorsConfigurationSource corsConfigurationSource() {
CorsConfiguration configuration = new CorsConfiguration();
configuration.addAllowedOrigin("*");
configuration.addAllowedOrigin("https://devroute.site"); // 필요한 도메인으로 설정하세요
configuration.addAllowedMethod("*");
configuration.addAllowedHeader("*");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ private void fetchAndSaveJobs(String keyword) {
String initialUrl = API_URL + accessKey + "&keywords=" + keyword + "&start=0&count=100";
String initialResponse = restTemplate.getForObject(initialUrl, String.class);


System.out.println(initialResponse);
try {
if(isMaxApiRequest(objectMapper,initialResponse))
return;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.teamdevroute.devroute.video;

import com.querydsl.jpa.impl.JPAQueryFactory;
import jakarta.persistence.EntityManager;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.convert.ReadingConverter;

import javax.swing.text.html.parser.Entity;

@Configuration
@RequiredArgsConstructor
public class QueryDslConfig {
private final EntityManager em;
@Bean
public JPAQueryFactory jpaQueryFactory(){
return new JPAQueryFactory(em);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.teamdevroute.devroute.video.Repository;

import com.querydsl.core.types.dsl.BooleanExpression;
import com.querydsl.jpa.impl.JPAQueryFactory;
import com.teamdevroute.devroute.video.domain.Videos;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Repository;

import java.util.List;

import static com.teamdevroute.devroute.video.domain.QVideos.videos;

@Repository
@RequiredArgsConstructor
public class VideoQueryRepository {
private final JPAQueryFactory query;
public List<Videos> findLectures(String platformName,String techStack){
return query.select(videos)
.from(videos)
.where(isPlatform(platformName), isTechStack(techStack))
.fetch();
}
private BooleanExpression isPlatform(String platformName){
System.out.println(platformName);

if(platformName!=null){
return videos.platformName.eq(platformName);
}

return null;
}
private BooleanExpression isTechStack(String techStack){
if(techStack!=null)
return videos.teckStack.eq(techStack);
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,16 @@
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;
import java.util.Optional;

public interface VideoRepository extends JpaRepository<Videos,Long> {

Optional<List<Videos>> findByPlatformNameAndTeckStack(String platform_name, String teck_stack);
default Optional<List<Videos>> findTop3ByOrderByCountDesc() {
Pageable topThree = PageRequest.of(0, 3, Sort.by("count").descending());
Page<Videos> page = findAll(topThree);
return Optional.ofNullable(page.getContent().isEmpty() ? null : page.getContent());
}

List<Videos>findTop3ByOrderByCountDesc();

long count();
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,8 @@

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import jakarta.persistence.AttributeConverter;
import jakarta.persistence.Column;
import jakarta.persistence.Convert;
import jakarta.persistence.Converter;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.*;

import java.io.IOException;
import java.util.Map;
import lombok.Builder;
Expand All @@ -18,6 +12,7 @@
@Entity
@Getter
//@Setter
@Table(indexes = @Index(name="idx_count",columnList = "count"))
public class Videos {

@Id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public YoutubeVideoFetcher(RestTemplate restTemplate) {
}

public YouTubeApiResponse fetchYoutubeVideos(String value) {
// System.out.println(getYoutubeApiUrl(value));
return restTemplate.getForObject(getYoutubeApiUrl(value), YouTubeApiResponse.class);
}

Expand Down
Loading