diff --git a/src/main/java/com/example/demo/app/domain/model/FixedCostModel.java b/src/main/java/com/example/demo/app/domain/model/FixedCostModel.java new file mode 100644 index 0000000..45d57be --- /dev/null +++ b/src/main/java/com/example/demo/app/domain/model/FixedCostModel.java @@ -0,0 +1,49 @@ +package com.example.demo.app.domain.model; + +import java.util.List; + +import com.example.demo.app.infra.entity.CategoryEntity; +import com.example.demo.app.infra.entity.FixedCostEntity; +import com.example.demo.app.infra.entity.UserEntity; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public class FixedCostModel { + + private Long fixedCostId; + + private Long userId; + + private Long categoryId; + + private String fixedCostName; + + private Integer amount; + + + public static FixedCostModel convertFrom(FixedCostEntity fixedCostEntity) { + return new FixedCostModel( + fixedCostEntity.getFixedCostId(), + fixedCostEntity.getUserEntity().getUserId(), + fixedCostEntity.getCategoryEntity().getCategoryId(), + fixedCostEntity.getFixedCostName(), + fixedCostEntity.getAmount()); + } + + public static List convertFrom(List fixedCostEntityList) { + return fixedCostEntityList.stream().map(FixedCostModel::convertFrom).toList(); + } + + public static FixedCostEntity convertTo(FixedCostModel fixedCostModel, UserEntity userEntity, CategoryEntity categoryEntity) { + return new FixedCostEntity( + fixedCostModel.getFixedCostId(), + userEntity, + categoryEntity, + fixedCostModel.getFixedCostName(), + fixedCostModel.getAmount()); + } + +} diff --git a/src/main/java/com/example/demo/app/domain/model/GoalModel.java b/src/main/java/com/example/demo/app/domain/model/GoalModel.java index d128209..1d7be1f 100644 --- a/src/main/java/com/example/demo/app/domain/model/GoalModel.java +++ b/src/main/java/com/example/demo/app/domain/model/GoalModel.java @@ -3,6 +3,7 @@ package com.example.demo.app.domain.model; import java.time.LocalDate; import com.example.demo.app.infra.entity.GoalEntity; +import com.example.demo.app.infra.entity.UserEntity; import com.example.demo.app.presentation.form.GoalForm; import lombok.AllArgsConstructor; @@ -27,8 +28,10 @@ public class GoalModel { private Integer achievementRate; // 達成率 private Integer currentAmount; // 現在の資産 + + private Long userId; - public static GoalModel convertFrom(GoalEntity goalEntity) { + public static GoalModel convertFrom(GoalEntity goalEntity, int achievementRate, int currentAmount) { return new GoalModel( goalEntity.getGoalId(), goalEntity.getGoalTitle(), @@ -36,10 +39,12 @@ public class GoalModel { goalEntity.getTargetAmount(), goalEntity.getDeadline(), goalEntity.getGoalComplete(), - null,null); + achievementRate, + currentAmount, + goalEntity.getUserEntity().getUserId()); } - public static GoalEntity convertTo(GoalModel goalModel) { + public static GoalEntity convertTo(GoalModel goalModel, UserEntity userEntity) { return new GoalEntity( goalModel.getGoalId(), goalModel.getGoalTitle(), @@ -47,7 +52,7 @@ public class GoalModel { goalModel.getTargetAmount(), goalModel.getDeadline(), goalModel.getGoalComplete(), - null); + userEntity, 0); } public static GoalModel convertFrom(GoalForm goalForm) { @@ -58,7 +63,8 @@ public class GoalModel { goalForm.getTargetAmount(), goalForm.getDeadline(), goalForm.getGoalComplete() - ,null,null); + ,null,null, + goalForm.getUserId()); } } \ No newline at end of file diff --git a/src/main/java/com/example/demo/app/domain/service/FixedCostService.java b/src/main/java/com/example/demo/app/domain/service/FixedCostService.java new file mode 100644 index 0000000..52ba6fd --- /dev/null +++ b/src/main/java/com/example/demo/app/domain/service/FixedCostService.java @@ -0,0 +1,16 @@ +package com.example.demo.app.domain.service; + +import java.util.List; + +import com.example.demo.app.domain.model.FixedCostModel; + +public interface FixedCostService { + + public List findAllByUserId(Long userId); + + public FixedCostModel save(FixedCostModel fixedCostModel); + + public void delete(Long fixedCostId); + + public FixedCostModel findById(Long fixedCostId); +} diff --git a/src/main/java/com/example/demo/app/domain/service/GoalService.java b/src/main/java/com/example/demo/app/domain/service/GoalService.java index 294f7ac..500c990 100644 --- a/src/main/java/com/example/demo/app/domain/service/GoalService.java +++ b/src/main/java/com/example/demo/app/domain/service/GoalService.java @@ -1,16 +1,18 @@ package com.example.demo.app.domain.service; +import java.util.List; + import com.example.demo.app.domain.model.GoalModel; public interface GoalService { GoalModel getGoalById(Long goalId); - GoalModel getGoalByUserId(Long userId); + public List getGoalByUserId(Long userId); - GoalModel createGoal(GoalModel goalModel); + public GoalModel createGoal(GoalModel goalModel, Long userId); - GoalModel updateGoal(GoalModel goalModel); + GoalModel updateGoal(GoalModel goalModel, Long userId); // void deleteGoal(Long goalId); diff --git a/src/main/java/com/example/demo/app/domain/service/impl/FixedCostServiceImpl.java b/src/main/java/com/example/demo/app/domain/service/impl/FixedCostServiceImpl.java new file mode 100644 index 0000000..e79597d --- /dev/null +++ b/src/main/java/com/example/demo/app/domain/service/impl/FixedCostServiceImpl.java @@ -0,0 +1,48 @@ +package com.example.demo.app.domain.service.impl; + +import java.util.List; + +import org.springframework.stereotype.Service; + +import com.example.demo.app.domain.model.FixedCostModel; +import com.example.demo.app.domain.service.FixedCostService; +import com.example.demo.app.infra.repository.CategoryRepository; +import com.example.demo.app.infra.repository.FixedCostRepository; +import com.example.demo.app.infra.repository.UserRepository; + +import lombok.RequiredArgsConstructor; + +@Service +@RequiredArgsConstructor +public class FixedCostServiceImpl implements FixedCostService{ + + + private final FixedCostRepository fixedCostRepository; + private final UserRepository userRepository; + private final CategoryRepository categoryRepository; + + + public List findAllByUserId(Long userId) { + + return FixedCostModel.convertFrom(fixedCostRepository.findByUserId(userId)); + + } + + public FixedCostModel save(FixedCostModel fixedCostModel) { + + return FixedCostModel.convertFrom(fixedCostRepository.save( FixedCostModel.convertTo(fixedCostModel, userRepository.findById(fixedCostModel.getUserId()).get(), categoryRepository.findById(fixedCostModel.getCategoryId()).get()))); + + } + + public void delete(Long fixedCostId) { + + fixedCostRepository.deleteById(fixedCostId); + + } + + public FixedCostModel findById(Long fixedCostId) { + return FixedCostModel.convertFrom(fixedCostRepository.findById(fixedCostId).get()); + } + + +} diff --git a/src/main/java/com/example/demo/app/domain/service/impl/GoalServiceImpl.java b/src/main/java/com/example/demo/app/domain/service/impl/GoalServiceImpl.java index a1d31e8..0d4d75a 100644 --- a/src/main/java/com/example/demo/app/domain/service/impl/GoalServiceImpl.java +++ b/src/main/java/com/example/demo/app/domain/service/impl/GoalServiceImpl.java @@ -1,5 +1,8 @@ package com.example.demo.app.domain.service.impl; +import java.util.ArrayList; +import java.util.List; + import org.springframework.stereotype.Service; import com.example.demo.app.domain.model.GoalModel; @@ -21,14 +24,14 @@ public class GoalServiceImpl implements GoalService { @Override public GoalModel getGoalById(Long goalId) { GoalEntity goalEntity = goalRepository.findById(goalId).orElse(null); - return GoalModel.convertFrom(goalEntity); + return GoalModel.convertFrom(goalEntity, 0, 0); } @Override - public GoalModel getGoalByUserId(Long userId) { + public List getGoalByUserId(Long userId) { UserEntity userEntity = userRepository.findById(userId).orElseThrow(); - GoalEntity goalEntity = userEntity.getGoalEntity(); + List goalEntityList = goalRepository.findAllByUserId(userId); // 収支の合計を計算(収入はプラス、支出はマイナス) int transactionTotal = userEntity.getTransactionEntityList().stream() @@ -42,42 +45,38 @@ public class GoalServiceImpl implements GoalService { int currentAmount = userEntity.getSaving() + transactionTotal; // 達成率(%) = 現在の資産 ÷ 目標金額 × 100 - int achievementRate = - (goalEntity.getTargetAmount() == null) - ? 0 : - (int) ((currentAmount * 100.0) / goalEntity.getTargetAmount()); - GoalModel goalModel = GoalModel.convertFrom(goalEntity); + List goalModelList = new ArrayList(); - return new GoalModel( - goalModel.getGoalId(), - goalModel.getGoalTitle(), - goalModel.getGoalSubtitle(), - goalModel.getTargetAmount(), - goalModel.getDeadline(), - goalModel.getGoalComplete(), - achievementRate, - currentAmount); + goalEntityList.stream() + .forEach(goalEntity -> goalModelList.add(GoalModel.convertFrom(goalEntity, + (goalEntity.getTargetAmount() == null) + ? 0 + : (int) ((currentAmount * 100.0) / goalEntity.getTargetAmount()), + currentAmount))); + + + return goalModelList; } - - @Override - public GoalModel createGoal(GoalModel goalModel) { - GoalEntity goalEntity = GoalModel.convertTo(goalModel); + @Override + public GoalModel createGoal(GoalModel goalModel, Long userId) { + + GoalEntity goalEntity = GoalModel.convertTo(goalModel, userRepository.findById(userId).get()); GoalEntity savedGoalEntity = goalRepository.save(goalEntity); - return GoalModel.convertFrom(savedGoalEntity); + return GoalModel.convertFrom(savedGoalEntity, 0, 0); } @Override - public GoalModel updateGoal(GoalModel goalModel) { + public GoalModel updateGoal(GoalModel goalModel, Long userId) { - GoalEntity goalEntity = GoalModel.convertTo(goalModel); + GoalEntity goalEntity = GoalModel.convertTo(goalModel, userRepository.findById(userId).get()); GoalEntity updatedGoalEntity = goalRepository.save(goalEntity); - return GoalModel.convertFrom(updatedGoalEntity); + return GoalModel.convertFrom(updatedGoalEntity, 0, 0); } } \ No newline at end of file diff --git a/src/main/java/com/example/demo/app/infra/entity/FixedCostEntity.java b/src/main/java/com/example/demo/app/infra/entity/FixedCostEntity.java new file mode 100644 index 0000000..ef131b2 --- /dev/null +++ b/src/main/java/com/example/demo/app/infra/entity/FixedCostEntity.java @@ -0,0 +1,42 @@ +package com.example.demo.app.infra.entity; + +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Entity +@Table(name = "fixed_cost_t") +@Data +@NoArgsConstructor +@AllArgsConstructor +public class FixedCostEntity { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "fixed_cost_id") + private Long fixedCostId; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "user_id") + private UserEntity userEntity; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "category_id") + private CategoryEntity categoryEntity; + + @Column(name = "fixed_cost_name", nullable = false) + private String fixedCostName; + + @Column(name = "amount", nullable = false) + private Integer amount; +} diff --git a/src/main/java/com/example/demo/app/infra/entity/GoalEntity.java b/src/main/java/com/example/demo/app/infra/entity/GoalEntity.java index e37c562..a7bc3f4 100644 --- a/src/main/java/com/example/demo/app/infra/entity/GoalEntity.java +++ b/src/main/java/com/example/demo/app/infra/entity/GoalEntity.java @@ -4,10 +4,12 @@ import java.time.LocalDate; import jakarta.persistence.Column; import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; import jakarta.persistence.GeneratedValue; import jakarta.persistence.GenerationType; import jakarta.persistence.Id; -import jakarta.persistence.OneToOne; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; import jakarta.persistence.Table; import lombok.AllArgsConstructor; @@ -41,7 +43,10 @@ public class GoalEntity { @Column(name = "goal_complete", nullable = false) private Integer goalComplete = 0; - @OneToOne(mappedBy = "goalEntity") + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "user_id") private UserEntity userEntity; + + private Integer deleteFlag; } diff --git a/src/main/java/com/example/demo/app/infra/entity/UserEntity.java b/src/main/java/com/example/demo/app/infra/entity/UserEntity.java index 332fb61..f6d52fd 100644 --- a/src/main/java/com/example/demo/app/infra/entity/UserEntity.java +++ b/src/main/java/com/example/demo/app/infra/entity/UserEntity.java @@ -12,7 +12,6 @@ import jakarta.persistence.Id; import jakarta.persistence.JoinColumn; import jakarta.persistence.ManyToOne; import jakarta.persistence.OneToMany; -import jakarta.persistence.OneToOne; import jakarta.persistence.Table; import lombok.AllArgsConstructor; @@ -65,9 +64,8 @@ public class UserEntity { @JoinColumn(name = "secret_question_id") private QuestionEntity questionEntity; - @OneToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "goal_id") - private GoalEntity goalEntity; + @OneToMany(mappedBy = "userEntity") + private List goalEntityList; @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "course_id") diff --git a/src/main/java/com/example/demo/app/infra/repository/FixedCostRepository.java b/src/main/java/com/example/demo/app/infra/repository/FixedCostRepository.java new file mode 100644 index 0000000..fe7279d --- /dev/null +++ b/src/main/java/com/example/demo/app/infra/repository/FixedCostRepository.java @@ -0,0 +1,15 @@ +package com.example.demo.app.infra.repository; + +import java.util.List; + +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; + +import com.example.demo.app.infra.entity.FixedCostEntity; + +public interface FixedCostRepository extends JpaRepository { + + @Query("select f from FixedCostEntity f where f.userEntity.userId = :userId") + public List findByUserId(Long userId); + +} diff --git a/src/main/java/com/example/demo/app/infra/repository/GoalRepository.java b/src/main/java/com/example/demo/app/infra/repository/GoalRepository.java index c66aa15..1de888e 100644 --- a/src/main/java/com/example/demo/app/infra/repository/GoalRepository.java +++ b/src/main/java/com/example/demo/app/infra/repository/GoalRepository.java @@ -1,6 +1,9 @@ package com.example.demo.app.infra.repository; +import java.util.List; + import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; import org.springframework.stereotype.Repository; import com.example.demo.app.infra.entity.GoalEntity; @@ -8,4 +11,7 @@ import com.example.demo.app.infra.entity.GoalEntity; @Repository public interface GoalRepository extends JpaRepository { + @Query("select g from GoalEntity g where g.userEntity.userId = :userId") + public List findAllByUserId(Long userId); + } \ No newline at end of file diff --git a/src/main/java/com/example/demo/app/presentation/controller/FixedCostController.java b/src/main/java/com/example/demo/app/presentation/controller/FixedCostController.java new file mode 100644 index 0000000..5a0809b --- /dev/null +++ b/src/main/java/com/example/demo/app/presentation/controller/FixedCostController.java @@ -0,0 +1,120 @@ +package com.example.demo.app.presentation.controller; + +import java.time.LocalDate; +import java.util.ArrayList; +import java.util.List; + +import jakarta.servlet.http.HttpSession; + +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.PostMapping; + +import com.example.demo.aop.aspect.SessionCheck; +import com.example.demo.app.domain.model.LoginModel; +import com.example.demo.app.domain.service.CategoryService; +import com.example.demo.app.domain.service.FixedCostService; +import com.example.demo.app.presentation.form.CategoryForm; +import com.example.demo.app.presentation.form.FixedCostForm; + +import lombok.RequiredArgsConstructor; + +@Controller +@RequiredArgsConstructor +public class FixedCostController { + + private final FixedCostService fixedCostService; + private final CategoryService categoryService; + + @SessionCheck + @GetMapping("/fixed-cost/list") + public String getFixedCostList( + HttpSession session, Model model, LocalDate today) { + + LoginModel loginUser = (LoginModel) session.getAttribute("loginUser"); + + if (today == null) { + today = (LocalDate) session.getAttribute("today"); + } + + List fixedCostFormList = FixedCostForm.convertFrom(fixedCostService.findAllByUserId(loginUser.getUserId())); + + fixedCostFormList.forEach(fixedCostForm -> fixedCostForm.setCategoryName(categoryService.findOne(fixedCostForm.getCategoryId()).getCategoryName())); + + model.addAttribute("fixedCostFormList", fixedCostFormList); + + model.addAttribute("today", today); + + return "fixed_cost"; + } + + + @SessionCheck + @GetMapping("/fixed-cost/create") + public String getFixedCostCreate( + HttpSession session, @ModelAttribute FixedCostForm fixedCostForm, Model model, LocalDate today) { + + List categoryFormList = CategoryForm.convertFrom(categoryService.findAll()); + + List expenseList = new ArrayList(); + + List incomeList = new ArrayList(); + + for (CategoryForm categoryForm : categoryFormList) { + + if (categoryForm.getTransactionType() == 0) { + expenseList.add(categoryForm); + } else { + incomeList.add(categoryForm); + } + + } + + model.addAttribute("expenseList", expenseList); + model.addAttribute("incomeList", incomeList); + model.addAttribute("today", today); + + + return "fixed_cost_create"; + } + + + + @SessionCheck + @PostMapping("/fixed-cost/create") + public String postFixedCostCreate( + HttpSession session, @ModelAttribute FixedCostForm fixedCostForm, Model model, LocalDate today) { + + LoginModel loginUser = (LoginModel) session.getAttribute("loginUser"); + + fixedCostForm.setUserId(loginUser.getUserId()); + + fixedCostService.save(FixedCostForm.convertTo(fixedCostForm)); + + session.setAttribute("today", today); + + return "redirect:/fixed-cost/list"; + } + + + @SessionCheck + @PostMapping("/fixed-cost/delete") + public String postFixedCostDelete(Long fixedCostId, LocalDate today, HttpSession session) { + + fixedCostService.delete(fixedCostId); + + session.setAttribute("today", today); + + return "redirect:/fixed-cost/list"; + } + + + + + + + + +} diff --git a/src/main/java/com/example/demo/app/presentation/controller/GoalController.java b/src/main/java/com/example/demo/app/presentation/controller/GoalController.java index 856d77b..3657719 100644 --- a/src/main/java/com/example/demo/app/presentation/controller/GoalController.java +++ b/src/main/java/com/example/demo/app/presentation/controller/GoalController.java @@ -69,7 +69,7 @@ public class GoalController { } GoalModel goalModel = GoalModel.convertFrom(goalForm); - goalService.updateGoal(goalModel); + goalService.updateGoal(goalModel, userId); return "redirect:/goal"; } diff --git a/src/main/java/com/example/demo/app/presentation/controller/TransactionController.java b/src/main/java/com/example/demo/app/presentation/controller/TransactionController.java index 4897ccb..5b4b753 100644 --- a/src/main/java/com/example/demo/app/presentation/controller/TransactionController.java +++ b/src/main/java/com/example/demo/app/presentation/controller/TransactionController.java @@ -20,12 +20,13 @@ import org.springframework.web.bind.annotation.RequestParam; import com.example.demo.aop.aspect.SessionCheck; import com.example.demo.app.domain.model.LoginModel; import com.example.demo.app.domain.service.CategoryService; +import com.example.demo.app.domain.service.FixedCostService; import com.example.demo.app.domain.service.GoalService; import com.example.demo.app.domain.service.TransactionService; import com.example.demo.app.domain.service.UserService; import com.example.demo.app.presentation.form.CategoryForm; import com.example.demo.app.presentation.form.Expense; -import com.example.demo.app.presentation.form.GoalForm; +import com.example.demo.app.presentation.form.FixedCostForm; import com.example.demo.app.presentation.form.Income; import com.example.demo.app.presentation.form.TransactionForm; import com.example.demo.app.presentation.form.UserForm; @@ -40,6 +41,7 @@ public class TransactionController { private final CategoryService categoryService; private final GoalService goalService; private final UserService userService; + private final FixedCostService fixedCostService; // 一覧画面 @SessionCheck @@ -182,16 +184,23 @@ public class TransactionController { @SessionCheck @GetMapping("/transaction/create") public String createOneGet(@RequestParam(defaultValue = "") LocalDate today, + Long fixedCostId, Model model) { if (today == null) { today = LocalDate.now(); } + TransactionForm transactionForm = new TransactionForm(); + transactionForm.setTransactionDate(today); + if (fixedCostId != null) { + FixedCostForm fixedCostForm = FixedCostForm.convertFrom(fixedCostService.findById(fixedCostId)); + transactionForm.setCategoryId(fixedCostForm.getCategoryId()); + transactionForm.setAmount(fixedCostForm.getAmount()); + transactionForm.setTransactionType(CategoryForm.convertFrom(categoryService.findOne(fixedCostForm.getCategoryId())).getTransactionType()); + } List categoryFormList = CategoryForm.convertFrom(categoryService.findAll()); - TransactionForm transactionForm = new TransactionForm(); - transactionForm.setTransactionDate(today); System.out.println(transactionForm.getCategoryName() + " " + transactionForm.getAmount()); @@ -339,19 +348,19 @@ public class TransactionController { model.addAttribute("totalIncome", totalIncome); model.addAttribute("totalExpense", totalExpense); - GoalForm goalForm = GoalForm.convertFrom(goalService.getGoalByUserId(loginUser.getUserId())); +// List goalForm = GoalForm.convertFrom(goalService.getGoalByUserId(loginUser.getUserId())); UserForm userForm = UserForm.convertFrom(userService.findByUserId(loginUser.getUserId())); - model.addAttribute("achievementRate", goalForm.getAchievementRate()); - - model.addAttribute("currentAmount", goalForm.getCurrentAmount()); - - model.addAttribute("targetAmount", goalForm.getTargetAmount()); +// model.addAttribute("achievementRate", goalForm.getAchievementRate()); +// +// model.addAttribute("currentAmount", goalForm.getCurrentAmount()); +// +// model.addAttribute("targetAmount", goalForm.getTargetAmount()); model.addAttribute("saving", userForm.getSaving()); - model.addAttribute("deadline", goalForm.getDeadline()); +// model.addAttribute("deadline", goalForm.getDeadline()); return "menu"; } diff --git a/src/main/java/com/example/demo/app/presentation/form/FixedCostForm.java b/src/main/java/com/example/demo/app/presentation/form/FixedCostForm.java new file mode 100644 index 0000000..8c12754 --- /dev/null +++ b/src/main/java/com/example/demo/app/presentation/form/FixedCostForm.java @@ -0,0 +1,55 @@ +package com.example.demo.app.presentation.form; + +import java.util.List; + +import com.example.demo.app.domain.model.FixedCostModel; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class FixedCostForm { + + private Long fixedCostId; + + private Long userId; + + private Long categoryId; + + private String fixedCostName; + + private Integer amount; + + private String categoryName; + + + public static FixedCostForm convertFrom(FixedCostModel fixedCostModel) { + return new FixedCostForm( + fixedCostModel.getFixedCostId(), + fixedCostModel.getUserId(), + fixedCostModel.getCategoryId(), + fixedCostModel.getFixedCostName(), + fixedCostModel.getAmount(), + ""); + } + + + public static List convertFrom(List fixedCostModelList) { + return fixedCostModelList.stream().map(fixedCostModel -> FixedCostForm.convertFrom(fixedCostModel)).toList(); + } + + public static FixedCostModel convertTo(FixedCostForm fixedCostForm) { + return new FixedCostModel( + fixedCostForm.getFixedCostId(), + fixedCostForm.getUserId(), + fixedCostForm.getCategoryId(), + fixedCostForm.getFixedCostName(), + fixedCostForm.getAmount()); + } + + + +} diff --git a/src/main/java/com/example/demo/app/presentation/form/GoalForm.java b/src/main/java/com/example/demo/app/presentation/form/GoalForm.java index 5956fd6..30bad09 100644 --- a/src/main/java/com/example/demo/app/presentation/form/GoalForm.java +++ b/src/main/java/com/example/demo/app/presentation/form/GoalForm.java @@ -1,6 +1,7 @@ package com.example.demo.app.presentation.form; import java.time.LocalDate; +import java.util.List; import org.springframework.format.annotation.DateTimeFormat; @@ -31,6 +32,8 @@ public class GoalForm { private Integer achievementRate; // 達成率 private Integer currentAmount; // 現在の資産 + + private Long userId; public static GoalForm convertFrom(GoalModel goalModel) { return new GoalForm( @@ -41,11 +44,12 @@ public class GoalForm { goalModel.getDeadline(), goalModel.getGoalComplete(), goalModel.getAchievementRate(), - goalModel.getCurrentAmount()); + goalModel.getCurrentAmount(), + goalModel.getUserId()); } -// public static List convertFrom(List goalModelList) { -// return goalModelList.stream().map(GoalForm::convertFrom).toList(); -// } + public static List convertFrom(List goalModelList) { + return goalModelList.stream().map(GoalForm::convertFrom).toList(); + } } \ No newline at end of file diff --git a/src/main/resources/templates/fixed_cost.html b/src/main/resources/templates/fixed_cost.html new file mode 100644 index 0000000..e961f40 --- /dev/null +++ b/src/main/resources/templates/fixed_cost.html @@ -0,0 +1,66 @@ + + + + + + 固定費詳細 + + + + + + + +
+

+ +
+
    +
  • + +
    +

    + カテゴリ名: + +
    + 固定費名: + +
    + 金額: + +

    +
    + +
    + +
    + + + +
    + +
    + + + +
    + +
    + +
    +
    +
  • +
+
+ + + +
+ + +
+ +
+ + + \ No newline at end of file diff --git a/src/main/resources/templates/fixed_cost_create.html b/src/main/resources/templates/fixed_cost_create.html new file mode 100644 index 0000000..03e780b --- /dev/null +++ b/src/main/resources/templates/fixed_cost_create.html @@ -0,0 +1,129 @@ + + + + + + Insert title here + + + + + + + + +
+ +

取引登録

+ +
+ + +
+ + + +
+ +
+ + + +
+ + + +
+ +
+ +
+ + + + +
+ +
+ +
+ + + +
+ +
+ + + + +
+ +
+ + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/templates/menu.html b/src/main/resources/templates/menu.html index 4470464..02cc0e7 100644 --- a/src/main/resources/templates/menu.html +++ b/src/main/resources/templates/menu.html @@ -113,17 +113,17 @@ -
- 目標貯金 - - 円 -
+ + + + + -
- 現在高 - - 円 -
+ + + + +
貯金額 @@ -133,16 +133,16 @@
-
- 達成率 - - % -
-
- 達成期限 - - 円 -
+ + + + + + + + + +
diff --git a/src/main/resources/templates/transaction_detail.html b/src/main/resources/templates/transaction_detail.html index 5fa195c..03afea0 100644 --- a/src/main/resources/templates/transaction_detail.html +++ b/src/main/resources/templates/transaction_detail.html @@ -56,6 +56,10 @@ +
+ + +