Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
07717bf
trudging through the mud to have something presentable
christhomas1190 May 9, 2025
16b231a
checkpoint?
christhomas1190 May 9, 2025
4743c8d
checkpoint
christhomas1190 May 9, 2025
4fcb6db
pictures not working
christhomas1190 May 9, 2025
3558a19
CHECKPOINT
christhomas1190 May 9, 2025
af5e88d
comments work
christhomas1190 May 11, 2025
8a06afa
checkpoint done for the night?
christhomas1190 May 11, 2025
99ef608
checkpoint
christhomas1190 May 12, 2025
87db49a
slider looks good
christhomas1190 May 12, 2025
d3d99b7
image slider cleaned up
christhomas1190 May 12, 2025
aac743e
favorites is a clickable category
christhomas1190 May 12, 2025
57abfb0
hamburger made
christhomas1190 May 13, 2025
b016070
lunchtime
christhomas1190 May 13, 2025
79766b1
checkpoint
christhomas1190 May 13, 2025
5c97f7d
slider reaches across
christhomas1190 May 13, 2025
a004b67
checkpoint
christhomas1190 May 14, 2025
c5fbef2
ticker fixed
christhomas1190 May 14, 2025
1c8f776
checkpoint
christhomas1190 May 14, 2025
45083d6
Qr code added
christhomas1190 May 14, 2025
f5037d8
working on stock api
christhomas1190 Jun 1, 2025
e3c15c2
still working on the ticker
christhomas1190 Jun 1, 2025
0d5bded
starting web congif
christhomas1190 Jun 7, 2025
93b97c3
corsMappings added
christhomas1190 Jun 7, 2025
2aee5cc
ticker slider code uncommented
christhomas1190 Jun 7, 2025
ad4439b
progress on the stockgit add .
christhomas1190 Jun 7, 2025
733d1e2
stocks working had too mane requests taking a break
christhomas1190 Jun 7, 2025
d20e09d
attempting changes
christhomas1190 Jun 8, 2025
8980f20
checkpoint
christhomas1190 Jun 8, 2025
92299e8
stock working
christhomas1190 Jun 10, 2025
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 .idea/BrandonGrahamDay.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions CKC/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
<artifactId>spring-boot-starter-web</artifactId>
</dependency>


<!-- MySQL Connector -->
<dependency>
<groupId>com.mysql</groupId>
Expand All @@ -47,13 +48,17 @@
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.15.3</version>
<version>2.17.0</version> <!-- Or latest stable -->
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.15.3</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
</dependency>

<!-- Spring Boot DevTools (hot reload) -->
<dependency>
Expand Down Expand Up @@ -123,4 +128,4 @@
</plugins>
</build>

</project>
</project>
107 changes: 66 additions & 41 deletions CKC/src/main/java/rocks/zipcode/CKC/Articles/Articles.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@

package rocks.zipcode.CKC.Articles;

import jakarta.persistence.*;

import java.util.Date;

@Entity
@Table(name="articles")
public class Articles {
Expand All @@ -13,64 +16,86 @@ public class Articles {
String title;
@Column(name="Articles_Author")
String author;
@Column(name="Articles_Thumbnail")
@Column(name = "Articles_Thumbnail", length = 1000)
String thumbnail;
@Column(name="Articles_Description")
@Column(name="Articles_Description",length = 1000)
String articleDescription;
@Column(name="Articles_Body")
@Column(name="Articles_Body",length = 100000)
String articleBody;
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "Articles_PublishedAt")
private Date publishedAt;

@Embedded
ArticlesSource source;

public Long getId() {
return id;
}
public Long getId() {
return id;
}

public void setId(Long id) {
this.id = id;
}
public String getTitle() {
return title;
}
public void setId(Long id) {
this.id = id;
}

public void setTitle(String title) {
this.title = title;
public ArticlesSource getSource() {
return source;
}
public String getTitle() {
return title;
}

public String getAuthor() {
return author;
}
public void setTitle(String title) {
this.title = title;
}

public void setAuthor(String author) {
this.author = author;
}
public String getAuthor() {
return author;
}

public String getThumbnail() {
return thumbnail;
}
public void setAuthor(String author) {
this.author = author;
}

public void setThumbnail(String thumbnail) {
this.thumbnail = thumbnail;
}
public String getThumbnail() {
return thumbnail;
}

public String getArticleBody() {
return articleBody;
}
public void setThumbnail(String thumbnail) {
this.thumbnail = thumbnail;
}

public void setArticleBody(String articleBody) {
this.articleBody = articleBody;
}
public String getArticleBody() {
return articleBody;
}

public void setArticleBody(String articleBody) {
this.articleBody = articleBody;
}

public Articles(){}
public Articles(){}

public Articles(Long id, String title, String author, String thumbnail, String articleBody) {
this.id = id;
this.title = title;
this.author = author;
this.thumbnail = thumbnail;
this.articleBody = articleBody;
public Articles(Long id, String title, String author, String thumbnail, String articleBody, Date publishedAt) {
this.id = id;
this.title = title;
this.author = author;
this.thumbnail = thumbnail;
this.articleBody = articleBody;
this.publishedAt=publishedAt;
}

public void setArticleDescription(String description) {
this.articleDescription=description;
}

public void setSource(ArticlesSource source) {
this.source = source;

}
public Date getPublishedAt() {
return publishedAt;
}

public void setArticleDescription(String description) {
public void setPublishedAt(Date publishedAt) {
this.publishedAt = publishedAt;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/articles")
@CrossOrigin(origins = "http://localhost:3000")
public class ArticlesController {

private final ArticlesRepository articlesRepository;
Expand All @@ -15,12 +17,12 @@ public class ArticlesController {
public ArticlesController(ArticlesRepository articlesRepository, ArticlesService articlesService){ this.articlesRepository = articlesRepository;
this.articlesService = articlesService; }

@GetMapping
public Iterable<Articles> getAllArticles(){ return articlesRepository.findAll(); }

@CrossOrigin(origins = "http://localhost:3000") // Allows frontend access
@GetMapping("/fetch")
public List<ArticlesDTO> fetchArticles() {
public List<Articles> getNews() {
return articlesService.fetchNews();
}
}

@GetMapping
public Iterable<Articles> getAllArticles(){ return articlesRepository.findAll(); }

}
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,4 @@ public String getContent() {
public void setContent(String content) {
this.content = content;
}
}
}
41 changes: 22 additions & 19 deletions CKC/src/main/java/rocks/zipcode/CKC/Articles/ArticlesService.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
package rocks.zipcode.CKC.Articles;

import com.fasterxml.jackson.databind.node.JsonNodeFactory;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import rocks.zipcode.CKC.Articles.ArticlesDTO;

import java.util.List;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

@Service
public class ArticlesService {
Expand All @@ -21,8 +18,9 @@ public ArticlesService(ArticlesRepository articlesRepository) {
this.articlesRepository = articlesRepository;
}

public List<ArticlesDTO> fetchNews() {
List<ArticlesDTO> dtoList = new ArrayList<>();
public List<Articles> fetchNews() {
List<Articles> savedArticles = new ArrayList<>();

try {
String url = "https://newsapi.org/v2/top-headlines?country=us&apiKey=e31ee66a0d864e2e9a447942e8af0b2c";
RestTemplate restTemplate = new RestTemplate();
Expand All @@ -33,31 +31,36 @@ public List<ArticlesDTO> fetchNews() {
JsonNode articlesNode = root.path("articles");

for (JsonNode node : articlesNode) {
ArticlesDTO dto = new ArticlesDTO();
dto.setTitle(node.path("title").asText(null));
dto.setAuthor(node.path("author").asText(null));
dto.setDescription(node.path("description").asText(null));
dto.setContent(node.path("content").asText(null));
dto.setUrlToImage(node.path("urlToImage").asText(null));
dto.setPublishedAt(node.path("publishedAt").asText(null));
Articles article = new Articles();
article.setTitle(node.path("title").asText(null));
article.setAuthor(node.path("author").asText(null));
article.setThumbnail(node.path("urlToImage").asText(null));
article.setArticleDescription(node.path("description").asText(null));
article.setArticleBody(node.path("content").asText(null));

// Handle embedded source
ArticlesSource source = new ArticlesSource();
JsonNode sourceNode = node.path("source");
if (!sourceNode.isMissingNode()) {
dto.setId(sourceNode.path("id").asText(null));
dto.setName(sourceNode.path("name").asText(null));
}
source.setId(sourceNode.path("id").asText(null));
source.setName(sourceNode.path("name").asText(null));
article.setSource(source);

dtoList.add(dto);
// Save to DB
Articles saved = articlesRepository.save(article);
savedArticles.add(saved);
}

} catch (Exception e) {
e.printStackTrace();
}
return dtoList;

return savedArticles;
}
}




//@Service
//public class ArticlesService {
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,17 @@
@Embeddable
public class ArticlesSource {

@Column(name = "source_id")
private String id;

@Column(name = "source_name")
private String name;

public ArticlesSource(){}
public ArticlesSource(String name, String id){}
public ArticlesSource(String name, String id){
this.name = name;
this.id = id;
}

public void setName(String name) {
this.name = name;
Expand Down
7 changes: 7 additions & 0 deletions CKC/src/main/java/rocks/zipcode/CKC/CkcApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.web.client.RestTemplate;


@SpringBootApplication
Expand All @@ -15,5 +18,9 @@ public static void main(String[] args) {
SpringApplication.run(CkcApplication.class, args);

}
@Bean
public RestTemplate restTemplate(RestTemplateBuilder builder) {
return builder.build();
}

}
Loading