Skip to content

Commit

Permalink
Merge pull request #22 from CodeURJC-DAW-2022-23/feat/databaseInitialize
Browse files Browse the repository at this point in the history
Feat/database initialize
  • Loading branch information
Vicente1215 authored Mar 4, 2023
2 parents e5dc5dd + be29b0e commit 690f7af
Show file tree
Hide file tree
Showing 30 changed files with 284 additions and 135 deletions.
78 changes: 4 additions & 74 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -157,78 +157,8 @@ typings/
Typescript/*
Webpack/*

## JetBrains ##
# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf

# AWS User-specific
.idea/**/aws.xml

# Generated files
.idea/**/contentModel.xml

# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml

# Gradle
.idea/**/gradle.xml
.idea/**/libraries

# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/artifacts
# .idea/compiler.xml
# .idea/jarRepositories.xml
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr

# CMake
cmake-build-*/

# Mongo Explorer plugin
.idea/**/mongoSettings.xml

# File-based project format
### IntelliJ IDEA ###
.idea
*.iws

# IntelliJ
out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Cursive Clojure plugin
.idea/replstate.xml

# SonarLint plugin
.idea/sonarlint/

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

# Editor-based Rest Client
.idea/httpRequests

# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser
*.iml
*.ipr
36 changes: 19 additions & 17 deletions back/src/main/java/net/daw/alist/models/Comment.java
Original file line number Diff line number Diff line change
@@ -1,43 +1,45 @@
package net.daw.alist.models;

import java.io.IOException;
import java.sql.Blob;
import java.sql.SQLException;
import java.util.Date;

import javax.persistence.*;

import com.fasterxml.jackson.annotation.JsonIgnore;

import static net.daw.alist.utils.Utils.pathToImage;

@Entity
public class Comment {

@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;

private Date date;
private String content;

@ManyToOne
private User author;
private Date date;
private String content;

@Lob
@JsonIgnore
private Blob imageFile;
private String image;
private Blob image;
private String imagePath;

public Comment() { }

public Comment(
User author,
String content,
Blob imageFile,
String image
) {
String imagePath
) throws IOException, SQLException {
this.date = new Date();
this.author = author;
this.content = content;
this.imageFile = imageFile;
this.image = image;
setImage(imagePath);
author.addComment(this);
}

public void setAuthor(User author) {
Expand All @@ -48,9 +50,9 @@ public void setContent(String content) {
this.content = content;
}

public void setImage(Blob imageFile, String image) {
this.imageFile = imageFile;
this.image = image;
public void setImage(String imagePath) throws IOException, SQLException {
this.image = pathToImage(imagePath);
this.imagePath = imagePath;
}

public Date getDate() {
Expand All @@ -65,12 +67,12 @@ public String getContent() {
return content;
}

public Blob getImageFile() {
return imageFile;
public Blob getImage() {
return image;
}

public String getImage() {
return image;
public String getImagePath() {
return imagePath;
}

}
27 changes: 22 additions & 5 deletions back/src/main/java/net/daw/alist/models/Post.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@

@Entity
public class Post {

@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;

@ManyToOne
private User author;
private Date date;
private String title;

Expand All @@ -23,27 +25,34 @@ public class Post {

@OneToMany
private Set<User> downVotes = new HashSet<>();

@ManyToMany
private List<Topic> topics = new ArrayList<>();

@OneToMany(cascade = CascadeType.ALL)
@OneToMany (orphanRemoval = true)
private List<PostItem> items = new ArrayList<>();

@OneToMany(cascade = CascadeType.ALL)
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
private List<Comment> comments = new ArrayList<>();

public Post() { }

public Post(
User author,
String title,
List<Topic> topics,
List<PostItem> items
) {
this.date = new Date();
this.author = author;
this.title = title;
this.topics = topics;
this.items = items;
author.addPost(this);
}

public void setAuthor(User author) {
this.author = author;
}

public void setTitle(String title) {
Expand All @@ -70,6 +79,10 @@ public void setComments(List<Comment> comments) {
this.comments = comments;
}

public User getAuthor() {
return author;
}

public Date getDate() {
return date;
}
Expand All @@ -93,9 +106,13 @@ public List<Topic> getTopics() {
public List<PostItem> getItems() {
return items;
}

public List<Comment> getComments() {
return comments;
}

public void addComment(Comment comment){
this.comments.add(comment);
}

}
33 changes: 19 additions & 14 deletions back/src/main/java/net/daw/alist/models/PostItem.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
package net.daw.alist.models;

import java.io.IOException;
import java.sql.Blob;
import java.sql.SQLException;

import javax.persistence.*;

import com.fasterxml.jackson.annotation.JsonIgnore;

import static net.daw.alist.utils.Utils.pathToImage;

@Entity
public class PostItem {

Expand All @@ -17,40 +21,41 @@ public class PostItem {

@Lob
@JsonIgnore
private Blob imageFile;
private String image;
private Blob image;
private String imagePath;

public PostItem() { }

public PostItem(
String description,
Blob imageFile,
String image
) {
String imagePath
) throws IOException, SQLException {
this.description = description;
this.imageFile = imageFile;
this.image = image;
setImage(imagePath);
}

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

public void setImage(Blob imageFile, String image) {
this.imageFile = imageFile;
this.image = image;
public void setImage(String imagePath) throws IOException, SQLException {
this.image = pathToImage(imagePath);
this.imagePath = imagePath;
}

public String getDescription() {
return description;
}

public Blob getImageFile() {
return imageFile;
public Blob getImage() {
return image;
}

public String getImage() {
return image;
public String getImagePath() {
return imagePath;
}

public void setImageFile(Blob generateProxy) {
}

}
Loading

0 comments on commit 690f7af

Please sign in to comment.