diff --git a/application.yml b/application.yml index e69de29..47fbb02 100644 --- a/application.yml +++ b/application.yml @@ -0,0 +1,2 @@ +server: + port: 8080 \ No newline at end of file diff --git a/build.gradle b/build.gradle index 00cb0ab..1efd9c0 100644 --- a/build.gradle +++ b/build.gradle @@ -13,10 +13,6 @@ dependencies { implementation 'org.springframework.boot:spring-boot-gradle-plugin:3.1.5' implementation 'org.springframework.boot:spring-boot-starter-web:3.1.5' implementation 'org.springframework.boot:spring-boot-starter-data-jpa:3.1.5' - implementation 'org.projectlombok:lombok:1.18.20' -// implementation 'org.apache.logging.log4j:log4j:2.8.2' - -// runtimeOnly 'mysql:mysql-connector-java' testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1' testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1' diff --git a/src/main/java/com/expensys/convertor/ExpenseToReportConvertor.java b/src/main/java/com/expensys/convertor/ExpenseToReportConvertor.java index f45fc02..ea720c6 100644 --- a/src/main/java/com/expensys/convertor/ExpenseToReportConvertor.java +++ b/src/main/java/com/expensys/convertor/ExpenseToReportConvertor.java @@ -21,10 +21,8 @@ private ExpenseToReportConvertor() { } public List prepareReportListFromExpenseList(List expenseList, ReportRequest reportRequest) { - HashMap> monthReportMap = new HashMap<>(); - HashMap> monthReportInfoMap = new HashMap<>(); + HashMap> monthReportInfoMap; - List reportInfoList = new ArrayList<>(); monthReportInfoMap = prepareReportInfoListFromExpenseListByMonth(expenseList, SpentBy.ALL); return prepareReportInfoFromReportInfoByMonth(monthReportInfoMap, reportRequest); } diff --git a/src/main/java/com/expensys/entity/CategoryMappingEntity.java b/src/main/java/com/expensys/entity/CategoryMappingEntity.java index df8e9b8..32f8a20 100644 --- a/src/main/java/com/expensys/entity/CategoryMappingEntity.java +++ b/src/main/java/com/expensys/entity/CategoryMappingEntity.java @@ -2,11 +2,7 @@ import com.expensys.model.enums.Category; import jakarta.persistence.*; -import lombok.Getter; -import lombok.Setter; -@Getter -@Setter @Entity @Table(name = "category_mappings") public class CategoryMappingEntity { @@ -24,4 +20,35 @@ public class CategoryMappingEntity { @Column(name = "main_category_type", nullable = false) Category categoryType; + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getSubCategory() { + return subCategory; + } + + public void setSubCategory(String subCategory) { + this.subCategory = subCategory; + } + + public Category getMainCategory() { + return mainCategory; + } + + public void setMainCategory(Category mainCategory) { + this.mainCategory = mainCategory; + } + + public Category getCategoryType() { + return categoryType; + } + + public void setCategoryType(Category categoryType) { + this.categoryType = categoryType; + } } diff --git a/src/main/java/com/expensys/entity/ExpenseEntity.java b/src/main/java/com/expensys/entity/ExpenseEntity.java index 273f515..5930dcb 100644 --- a/src/main/java/com/expensys/entity/ExpenseEntity.java +++ b/src/main/java/com/expensys/entity/ExpenseEntity.java @@ -2,14 +2,9 @@ import com.expensys.model.enums.Category; import jakarta.persistence.*; -import lombok.Getter; -import lombok.Setter; import java.time.LocalDate; -import java.util.Date; -@Getter -@Setter @Entity @Table(name = "expenses") public class ExpenseEntity { @@ -33,4 +28,51 @@ public class ExpenseEntity { @Column(name = "spent_by", nullable = false) String spentBy; + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public LocalDate getDate() { + return date; + } + + public void setDate(LocalDate date) { + this.date = date; + } + + public String getItem() { + return item; + } + + public void setItem(String item) { + this.item = item; + } + + public Category getCategory() { + return category; + } + + public void setCategory(Category category) { + this.category = category; + } + + public Double getSpent() { + return spent; + } + + public void setSpent(Double spent) { + this.spent = spent; + } + + public String getSpentBy() { + return spentBy; + } + + public void setSpentBy(String spentBy) { + this.spentBy = spentBy; + } } diff --git a/src/main/java/com/expensys/entity/UnknownCategoryEntity.java b/src/main/java/com/expensys/entity/UnknownCategoryEntity.java index efcd1a2..6c1e93a 100644 --- a/src/main/java/com/expensys/entity/UnknownCategoryEntity.java +++ b/src/main/java/com/expensys/entity/UnknownCategoryEntity.java @@ -2,11 +2,7 @@ import com.expensys.model.enums.Category; import jakarta.persistence.*; -import lombok.Getter; -import lombok.Setter; -@Getter -@Setter @Entity @Table(name = "unknown_category") public class UnknownCategoryEntity { @@ -21,4 +17,27 @@ public class UnknownCategoryEntity { @Column(name = "category", nullable = false) Category category; + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getItem() { + return item; + } + + public void setItem(String item) { + this.item = item; + } + + public Category getCategory() { + return category; + } + + public void setCategory(Category category) { + this.category = category; + } } diff --git a/src/main/java/com/expensys/model/Expense.java b/src/main/java/com/expensys/model/Expense.java index cb5e452..d714d30 100644 --- a/src/main/java/com/expensys/model/Expense.java +++ b/src/main/java/com/expensys/model/Expense.java @@ -2,13 +2,7 @@ import com.expensys.model.enums.Category; import com.expensys.model.enums.Month; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.Setter; -@Getter -@Setter -@AllArgsConstructor public class Expense { Month month; String subCategory; @@ -16,4 +10,51 @@ public class Expense { Double spent; String spentBy; + public Expense(Month month, String subCategory, Category category, Double spent, String spentBy) { + this.month = month; + this.subCategory = subCategory; + this.category = category; + this.spent = spent; + this.spentBy = spentBy; + } + + public Month getMonth() { + return month; + } + + public void setMonth(Month month) { + this.month = month; + } + + public String getSubCategory() { + return subCategory; + } + + public void setSubCategory(String subCategory) { + this.subCategory = subCategory; + } + + public Category getCategory() { + return category; + } + + public void setCategory(Category category) { + this.category = category; + } + + public Double getSpent() { + return spent; + } + + public void setSpent(Double spent) { + this.spent = spent; + } + + public String getSpentBy() { + return spentBy; + } + + public void setSpentBy(String spentBy) { + this.spentBy = spentBy; + } } diff --git a/src/main/java/com/expensys/model/request/ReportRequest.java b/src/main/java/com/expensys/model/request/ReportRequest.java index 574c371..c0912c3 100644 --- a/src/main/java/com/expensys/model/request/ReportRequest.java +++ b/src/main/java/com/expensys/model/request/ReportRequest.java @@ -3,17 +3,59 @@ import com.expensys.model.enums.Category; import com.expensys.model.enums.Month; import com.expensys.model.enums.SpentBy; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.Setter; -@Getter -@Setter -@AllArgsConstructor public class ReportRequest { Month month; Category category; SpentBy spentBy; Boolean showSpendByUserPercentage; int year; + + public ReportRequest(Month month, Category category, SpentBy spentBy, Boolean showSpendByUserPercentage, int year) { + this.month = month; + this.category = category; + this.spentBy = spentBy; + this.showSpendByUserPercentage = showSpendByUserPercentage; + this.year = year; + } + + public Month getMonth() { + return month; + } + + public void setMonth(Month month) { + this.month = month; + } + + public Category getCategory() { + return category; + } + + public void setCategory(Category category) { + this.category = category; + } + + public SpentBy getSpentBy() { + return spentBy; + } + + public void setSpentBy(SpentBy spentBy) { + this.spentBy = spentBy; + } + + public Boolean getShowSpendByUserPercentage() { + return showSpendByUserPercentage; + } + + public void setShowSpendByUserPercentage(Boolean showSpendByUserPercentage) { + this.showSpendByUserPercentage = showSpendByUserPercentage; + } + + public int getYear() { + return year; + } + + public void setYear(int year) { + this.year = year; + } } diff --git a/src/main/java/com/expensys/model/response/Report.java b/src/main/java/com/expensys/model/response/Report.java index f158995..fe3c244 100644 --- a/src/main/java/com/expensys/model/response/Report.java +++ b/src/main/java/com/expensys/model/response/Report.java @@ -1,16 +1,34 @@ package com.expensys.model.response; import com.expensys.model.enums.Month; -import lombok.Getter; -import lombok.Setter; -import lombok.ToString; import java.util.List; -@ToString -@Getter -@Setter public class Report { Month month; List reportInfo; + + public Month getMonth() { + return month; + } + + public void setMonth(Month month) { + this.month = month; + } + + public List getReportInfo() { + return reportInfo; + } + + public void setReportInfo(List reportInfo) { + this.reportInfo = reportInfo; + } + + @Override + public String toString() { + return "Report{" + + "month=" + month + + ", reportInfo=" + reportInfo + + '}'; + } } diff --git a/src/main/java/com/expensys/model/response/ReportInfo.java b/src/main/java/com/expensys/model/response/ReportInfo.java index 6213c2a..a3bd07d 100644 --- a/src/main/java/com/expensys/model/response/ReportInfo.java +++ b/src/main/java/com/expensys/model/response/ReportInfo.java @@ -1,16 +1,90 @@ package com.expensys.model.response; import com.expensys.model.enums.Category; -import lombok.Builder; -import lombok.Getter; -import lombok.ToString; -@Builder -@ToString -@Getter public class ReportInfo { - Category mainCategory; - String subCategory;// ignore in response when null - Double spent; - String user; + private Category mainCategory; + private String subCategory; // Ignore in response when null + private Double spent; + private String user; + + ReportInfo(){} + + public Category getMainCategory() { + return mainCategory; + } + + public String getSubCategory() { + return subCategory; + } + + public Double getSpent() { + return spent; + } + + public String getUser() { + return user; + } + + public void setMainCategory(Category mainCategory) { + this.mainCategory = mainCategory; + } + + public void setSubCategory(String subCategory) { + this.subCategory = subCategory; + } + + public void setSpent(Double spent) { + this.spent = spent; + } + + public void setUser(String user) { + this.user = user; + } + + public static class Builder { + private ReportInfo reportInfo; + + public Builder() { + this.reportInfo = new ReportInfo(); + } + + public Builder mainCategory(Category mainCategory) { + reportInfo.setMainCategory(mainCategory); + return this; + } + + public Builder subCategory(String subCategory) { + reportInfo.setSubCategory(subCategory); + return this; + } + + public Builder spent(Double spent) { + reportInfo.setSpent(spent); + return this; + } + + public Builder user(String user) { + reportInfo.setUser(user); + return this; + } + + public ReportInfo build() { + return reportInfo; + } + } + + public static Builder builder() { + return new Builder(); + } + + @Override + public String toString() { + return "ReportInfo{" + + "mainCategory=" + mainCategory + + ", subCategory='" + subCategory + '\'' + + ", spent=" + spent + + ", user='" + user + '\'' + + '}'; + } } diff --git a/src/main/java/com/expensys/repository/UnknownCategoryRepository.java b/src/main/java/com/expensys/repository/UnknownCategoryRepository.java index c325dcd..40590dd 100644 --- a/src/main/java/com/expensys/repository/UnknownCategoryRepository.java +++ b/src/main/java/com/expensys/repository/UnknownCategoryRepository.java @@ -4,5 +4,5 @@ import org.springframework.data.jpa.repository.JpaRepository; public interface UnknownCategoryRepository extends JpaRepository { - Object save(UnknownCategoryEntity unknownCategoryEntity); + UnknownCategoryEntity save(UnknownCategoryEntity unknownCategoryEntity); }