diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..01edbc4 --- /dev/null +++ b/.classpath @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b83d222 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/target/ diff --git a/.project b/.project new file mode 100644 index 0000000..242df50 --- /dev/null +++ b/.project @@ -0,0 +1,23 @@ + + + next-transactions + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + + diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..4c28b1a --- /dev/null +++ b/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,4 @@ +eclipse.preferences.version=1 +encoding//src/main/java=UTF-8 +encoding//src/test/java=UTF-8 +encoding/=UTF-8 diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..d59e09c --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,5 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/.settings/org.eclipse.m2e.core.prefs b/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 0000000..14b697b --- /dev/null +++ b/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..daf68c6 --- /dev/null +++ b/pom.xml @@ -0,0 +1,46 @@ + + 4.0.0 + de.tilman + next-transactions + 0.0.1-SNAPSHOT + + + org.springframework.boot + spring-boot-starter-parent + 1.3.3.RELEASE + + + + + org.springframework.boot + spring-boot-starter-data-rest + + + org.springframework.boot + spring-boot-starter-data-jpa + + + com.h2database + h2 + + + org.springframework.boot + spring-boot-starter-security + + + + + 1.8 + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + \ No newline at end of file diff --git a/src/main/java/de/tilman/transactions/Application.java b/src/main/java/de/tilman/transactions/Application.java new file mode 100644 index 0000000..0517cd4 --- /dev/null +++ b/src/main/java/de/tilman/transactions/Application.java @@ -0,0 +1,13 @@ +package de.tilman.transactions; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class Application { + + public static void main(String[] args) { + SpringApplication.run(Application.class); + } + +} diff --git a/src/main/java/de/tilman/transactions/domain/Account.java b/src/main/java/de/tilman/transactions/domain/Account.java new file mode 100644 index 0000000..19ebcc5 --- /dev/null +++ b/src/main/java/de/tilman/transactions/domain/Account.java @@ -0,0 +1,70 @@ +package de.tilman.transactions.domain; + +import java.util.List; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.JoinTable; +import javax.persistence.ManyToMany; +import javax.persistence.ManyToOne; +import javax.persistence.OneToMany; + +@Entity +public class Account { + + @Id + @GeneratedValue + private Long id; + + private String name; + + @ManyToOne + private User owner; + + @OneToMany + private List categories; + + @ManyToMany + @JoinTable(name = "account_user", joinColumns = @JoinColumn(name = "account_id", referencedColumnName = "id"), inverseJoinColumns = @JoinColumn(name = "user_id", referencedColumnName = "id")) + private List users; + + + public Long getId() { + return id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public User getOwner() { + return owner; + } + + public void setOwner(User owner) { + this.owner = owner; + } + + public List getCategories() { + return categories; + } + + public void setCategories(List categories) { + this.categories = categories; + } + + public List getUsers() { + return users; + } + + public void setUsers(List users) { + this.users = users; + } + +} diff --git a/src/main/java/de/tilman/transactions/domain/Category.java b/src/main/java/de/tilman/transactions/domain/Category.java new file mode 100644 index 0000000..190775a --- /dev/null +++ b/src/main/java/de/tilman/transactions/domain/Category.java @@ -0,0 +1,50 @@ +package de.tilman.transactions.domain; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.ManyToOne; + +@Entity +public class Category { + + @Id + @GeneratedValue + private Long id; + + @ManyToOne + private Account account; + + private String name; + + private Integer position; + + public Account getAccount() { + return account; + } + + public void setAccount(Account account) { + this.account = account; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Integer getPosition() { + return position; + } + + public void setPosition(Integer position) { + this.position = position; + } + + public Long getId() { + return id; + } + +} diff --git a/src/main/java/de/tilman/transactions/domain/Transaction.java b/src/main/java/de/tilman/transactions/domain/Transaction.java new file mode 100644 index 0000000..05f38cf --- /dev/null +++ b/src/main/java/de/tilman/transactions/domain/Transaction.java @@ -0,0 +1,85 @@ +package de.tilman.transactions.domain; + +import java.math.BigDecimal; +import java.util.Date; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.ManyToOne; + +@Entity +public class Transaction { + + @Id + @GeneratedValue + private Long id; + + private BigDecimal amount; + + private Date date; + + private String description; + + @ManyToOne + private User creditor; + + @ManyToOne + private Account account; + + @ManyToOne + private Category category; + + public Long getId() { + return id; + } + + public BigDecimal getAmount() { + return amount; + } + + public void setAmount(BigDecimal amount) { + this.amount = amount; + } + + public Date getDate() { + return date; + } + + public void setDate(Date date) { + this.date = date; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public User getCreditor() { + return creditor; + } + + public void setCreditor(User creditor) { + this.creditor = creditor; + } + + public Account getAccount() { + return account; + } + + public void setAccount(Account account) { + this.account = account; + } + + public Category getCategory() { + return category; + } + + public void setCategory(Category category) { + this.category = category; + } + +} diff --git a/src/main/java/de/tilman/transactions/domain/User.java b/src/main/java/de/tilman/transactions/domain/User.java new file mode 100644 index 0000000..0c2528f --- /dev/null +++ b/src/main/java/de/tilman/transactions/domain/User.java @@ -0,0 +1,40 @@ +package de.tilman.transactions.domain; + +import java.util.List; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.OneToMany; + +@Entity +public class User { + + @Id + @GeneratedValue + private Long id; + + private String name; + + @OneToMany + private List accounts; + + + public Long getId() { + return id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public List getAccounts() { + return accounts; + } + + +}