47 Commits

Author SHA1 Message Date
kkazuya
f10f9f83de [EDIT] URLパターンを変更しました。 2026-09-24 10:52:52 +09:00
kkazuya
6fb4ac0161 [EDIT] コース選択画面へのヘッダーの追加と、ラジオボタンのcheckedを追加しました。 2026-09-24 10:51:49 +09:00
kkazuya
428cb0fd64 [EDIT] コース選択のデフォルトをバランスコースにするよう編集しました。ログイン済みのユーザーがコースを変更できるようにしました。 2026-09-24 10:50:39 +09:00
kkazuya
df28fa8ccd Merge branch 's-morimto' of https://gitea.it-college.co.jp/2026_09_5H_Spring_KIZAKI/Monegement into k-kobayashi 2026-09-24 10:46:45 +09:00
41aa5a5b7b [EDIT]Bootstrapの追加 2026-09-24 10:45:00 +09:00
s-choi
5ca3226dfa [FIX] userに目標が紐づけられない問題を修正しました。 2026-09-24 10:41:38 +09:00
ff896c77cb Merge branch 's-choi' of https://gitea.it-college.co.jp/2026_09_5H_Spring_KIZAKI/Monegement into s-morimto 2026-09-24 10:39:30 +09:00
s-choi
65d80e6306 [FIX] 目標カラムの条件と読み取れない問題を修正しました。 2026-09-24 10:39:03 +09:00
1197955f70 Merge branch 's-choi' of https://gitea.it-college.co.jp/2026_09_5H_Spring_KIZAKI/Monegement into s-morimto 2026-09-24 10:20:58 +09:00
336adf0dec Merge branch 's-choi' of https://gitea.it-college.co.jp/2026_09_5H_Spring_KIZAKI/Monegement into n-kawahito 2026-09-24 10:20:26 +09:00
s-choi
642cd7ee69 [STYLE] 余計な行をけしました。 2026-09-24 10:19:27 +09:00
52fe77a5b4 [EDIT]パスワード再設定のバグ修正 2026-09-24 10:12:02 +09:00
ac85c2dc23 Merge branch 's-choi' of https://gitea.it-college.co.jp/2026_09_5H_Spring_KIZAKI/Monegement into s-morimto 2026-09-24 10:11:19 +09:00
s-choi
21ca1a72e2 [FIX] 送り先の修正及び変数名、表示法の修正 2026-09-24 10:03:30 +09:00
s-choi
56bb709921 [ADD] 会員登録のためのHTMLファイル追加 2026-09-24 10:02:53 +09:00
s-choi
e2ddffcc60 [HOTFIX] 質問の読み込み、コース名のセッション変数登録、DB登録機能追加など。 2026-09-24 10:02:22 +09:00
s-choi
51310bae25 [FIX] 会員登録の際、コースを直接設定するようにしました。 2026-09-24 10:01:15 +09:00
s-choi
08c2c06f4a [FIX] コーディングルールと異なる変数名を修正しました。 2026-09-24 10:00:36 +09:00
s-choi
06c2d35512 [EDIT] 名前をもとに情報を取得する機能を追加しました。 2026-09-24 09:59:58 +09:00
s-choi
4192faecc2 [ADD] 質問リストを受け取るメソッドを作成しました。 2026-09-24 09:59:21 +09:00
s-choi
19218d868c [FIX] mapping errorを修正しました。 2026-09-24 09:58:38 +09:00
8282331339 [EDIT]パスワード再設定までの遷移のバグ修正 2026-09-24 09:41:04 +09:00
1759c45fea [EDIT]URLの修正 2026-09-18 16:14:08 +09:00
44ac862bdb Merge branch 's-choi' of https://gitea.it-college.co.jp/2026_09_5H_Spring_KIZAKI/Monegement into k-oshita 2026-09-18 16:11:57 +09:00
s-choi
5939e75f86 Merge branch 'k-kobayashi' of https://gitea.it-college.co.jp/2026_09_5H_Spring_KIZAKI/Monegement into s-choi
# Conflicts:
#	src/main/java/com/example/demo/app/presentation/controller/CourseController.java
2026-09-18 16:11:27 +09:00
ed7a3a67b7 [EDIT]メニュー画面で現在高の表示をできる用にしました。 2026-09-18 16:11:20 +09:00
s-choi
41c5f6e99e Merge branch 'n-kawahito' of https://gitea.it-college.co.jp/2026_09_5H_Spring_KIZAKI/Monegement into s-choi 2026-09-18 16:08:28 +09:00
s-choi
af3e171006 [EDIT] セッションチェック機能をつけました。 2026-09-18 16:08:07 +09:00
79b1abeac6 [EDIT]二次実装である支出分析の年月表示を実装しました 2026-09-18 16:03:32 +09:00
1d010dc02b [ADD]プロフィール編集の作成 2026-09-18 16:01:33 +09:00
s-choi
d308f14df4 [ADD] セッションチェックAOPを追加しました。 2026-09-18 15:51:48 +09:00
s-choi
a36705d83f [ADD] カスタム例外を追加しました。 2026-09-18 15:51:21 +09:00
s-choi
ab802cdb25 [DELETE/ADD] 例外Handlerを再作成しました。 2026-09-18 15:50:26 +09:00
s-choi
1160af5711 Merge branch 'k-oshita' of https://gitea.it-college.co.jp/2026_09_5H_Spring_KIZAKI/Monegement into s-choi 2026-09-18 15:36:18 +09:00
s-choi
d2cf2e6e98 [EDIT] 一覧画面でのつき選択機能を追加しました。 2026-09-18 15:35:53 +09:00
69213bcf9c [EDIT] 目標の編集画面で期限の値が渡せてない問題の修正をしました。 2026-09-18 15:26:51 +09:00
e0a7a3496f [FIX]本文の空白を作成しました 2026-09-18 15:10:55 +09:00
f35a3e03d7 Merge branch 's-choi' of https://gitea.it-college.co.jp/2026_09_5H_Spring_KIZAKI/Monegement into n-kawahito 2026-09-18 15:10:15 +09:00
9a1d7144a8 [FIX]本文の空白を作成しました 2026-09-18 15:09:56 +09:00
s-choi
d83559e937 [EDIT] headerとの間隔を調整しました。 2026-09-18 15:06:49 +09:00
s-choi
db65afe184 [EDIT] userIdでUserEntity情報を取得するメソッドを追加しました。 2026-09-18 15:06:16 +09:00
s-choi
34e9a17273 [FIX] userの整合性を修正・変換メソッドを追加しました。 2026-09-18 15:05:44 +09:00
s-choi
3378f81a2d [EDIT] 月転換機能を追加しました。現在セッションユーザーの目標に関する情報をメニューで取得するように変更しました。 2026-09-18 15:05:11 +09:00
f588e29b46 [EDIT]プロフィールの編集 2026-09-18 14:57:43 +09:00
11fbec6d8c [EDIT]目標のヘッダーとフッターを表示するように変更。 2026-09-18 14:45:59 +09:00
2372c81ddd Merge branch 's-morimto' of https://gitea.it-college.co.jp/2026_09_5H_Spring_KIZAKI/Monegement into k-oshita 2026-09-18 14:44:40 +09:00
d8ea1acf2f [EDIT]達成率が画面に表示されるようにしました 2026-09-18 14:35:06 +09:00
53 changed files with 1300 additions and 326 deletions

View File

@@ -0,0 +1,11 @@
package com.example.demo.aop.aspect;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface SessionCheck {
}

View File

@@ -0,0 +1,41 @@
package com.example.demo.aop.aspect;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpSession;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.example.demo.exception.NoSessionException;
@Aspect
@Component
public class SessionCheckAspect {
HttpServletRequest request;
@Autowired
public SessionCheckAspect(HttpServletRequest request) {
this.request = request;
}
@Pointcut("@annotation(com.example.demo.aop.aspect.SessionCheck)")
public void sessionCheckMethod() {
}
@Before("sessionCheckMethod()")
public void checkSession() {
HttpSession session = request.getSession(false);
if (session == null || session.getAttribute("loginUser") == null) {
throw new NoSessionException("不正なログインです");
}
}
}

View File

@@ -0,0 +1,61 @@
package com.example.demo.aop.handler;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.springframework.http.HttpStatus;
import org.springframework.ui.Model;
import org.springframework.web.HttpRequestMethodNotSupportedException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import com.example.demo.exception.NoSessionException;
@ControllerAdvice
public class GlobalExceptionHandler {
private final static Logger LOGGER = Logger.getLogger(GlobalExceptionHandler.class.getName());
private final String SEVERE_ERROR_MESSAGE_ILLEGAL_TRANSITION = "不正な遷移です。";
private final String SEVERE_ERROR_MESSAGE_BAD_REQUEST = "不正なリクエストです。";
@ExceptionHandler(NoSessionException.class)
public String handleNoSessionException(Model model, Exception e) {
e.printStackTrace();
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE_ILLEGAL_TRANSITION, e);
model.addAttribute(
"errorMessage",
"システムエラーが発生しました。"
+ "初めからやり直してください。");
return "error";
}
@ExceptionHandler(HttpRequestMethodNotSupportedException.class)
public String handleBadRequestException(Model model, Exception e) {
model.addAttribute("error", SEVERE_ERROR_MESSAGE_BAD_REQUEST);
model.addAttribute("status", HttpStatus.BAD_REQUEST.value());
e.printStackTrace();
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE_ILLEGAL_TRANSITION, e);
return "error";
}
@ExceptionHandler(Exception.class)
public String AllException(Model model, Exception e) {
model.addAttribute("error", SEVERE_ERROR_MESSAGE_BAD_REQUEST);
e.printStackTrace();
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE_ILLEGAL_TRANSITION, e);
return "error";
}
}

View File

@@ -24,6 +24,10 @@ public class GoalModel {
private Integer goalComplete;
private Integer achievementRate; // 達成率
private Integer currentAmount; // 現在の資産
public static GoalModel convertFrom(GoalEntity goalEntity) {
return new GoalModel(
goalEntity.getGoalId(),
@@ -31,7 +35,8 @@ public class GoalModel {
goalEntity.getGoalSubtitle(),
goalEntity.getTargetAmount(),
goalEntity.getDeadline(),
goalEntity.getGoalComplete());
goalEntity.getGoalComplete(),
null,null);
}
public static GoalEntity convertTo(GoalModel goalModel) {
@@ -52,7 +57,8 @@ public class GoalModel {
goalForm.getGoalSubtitle(),
goalForm.getTargetAmount(),
goalForm.getDeadline(),
goalForm.getGoalComplete());
goalForm.getGoalComplete()
,null,null);
}
}

View File

@@ -2,6 +2,8 @@ package com.example.demo.app.domain.model;
import java.time.LocalDate;
import com.example.demo.app.infra.entity.UserEntity;
import lombok.AllArgsConstructor;
import lombok.Getter;
@@ -12,7 +14,7 @@ public class UserModel {
private String userName;
private String mailAddress;
private String password;
private Integer secretQuestionId;
private Long secretQuestionId;
private String secretAnswer;
private LocalDate brithDate;
private Integer saving;
@@ -21,4 +23,22 @@ public class UserModel {
private Long goalId;
private Long courseId;
private Integer deleteFlag;
public static UserModel convertFrom(UserEntity userEntity) {
return new UserModel(
userEntity.getUserId(),
userEntity.getUserName(),
userEntity.getMailAddress(),
userEntity.getPassword(),
userEntity.getQuestionEntity().getSecretQuestionId(),
userEntity.getSecretQuestionAnswer(),
userEntity.getBirthDate(),
userEntity.getSaving(),
userEntity.getAnnualIncome(),
userEntity.getMonthlyBudget(),
userEntity.getGoalEntity().getGoalId(),
userEntity.getCourseEntity().getCourseId(),
userEntity.getDeleteFlag()
);
}
}

View File

@@ -4,6 +4,9 @@ import com.example.demo.app.domain.model.AnalysisModel;
public interface AnalysisService {
AnalysisModel getAnalysis(Long userId);
AnalysisModel getAnalysis(
Long userId,
Integer year,
Integer month);
}

View File

@@ -10,4 +10,5 @@ public interface CourseService {
public CourseModel findById(Long courseId);
public Long findByName(String courName);
}

View File

@@ -1,7 +1,10 @@
package com.example.demo.app.domain.service;
import com.example.demo.app.domain.model.ProfileModel;
import com.example.demo.app.presentation.form.ProfileEditForm;
public interface ProfileService {
ProfileModel findOne(Long userId);
void withdraw(Long userId);
void update(Long userId, ProfileEditForm profileEditForm);
}

View File

@@ -0,0 +1,9 @@
package com.example.demo.app.domain.service;
import java.util.List;
import com.example.demo.app.infra.entity.QuestionEntity;
public interface QuestionService {
public List<QuestionEntity> findAll();
}

View File

@@ -1,10 +1,13 @@
package com.example.demo.app.domain.service;
import com.example.demo.app.domain.model.UserModel;
import com.example.demo.app.presentation.form.UserForm;
public interface UserService {
void register(UserForm userForm);
void register(UserForm userForm, Long courseId);
public void updateCourse(Long userId, Long courseId);
public UserModel findByUserId(Long userId);
}

View File

@@ -30,7 +30,7 @@ public class AnalysisServiceImpl implements AnalysisService {
private final CategoryRepository categoryRepository;
@Override
public AnalysisModel getAnalysis(Long userId) {
public AnalysisModel getAnalysis(Long userId, Integer year, Integer month) {
// ユーザー情報取得、月別使用可能資金取得
UserEntity userEntity = userRepository.findById(userId).orElseThrow(() ->
@@ -44,12 +44,15 @@ public class AnalysisServiceImpl implements AnalysisService {
Integer monthlyBudget =userEntity.getMonthlyBudget();
// 今月の期間取得
LocalDate currentMonthStartDate = LocalDate.now().withDayOfMonth(1);
LocalDate currentMonthEndDate = LocalDate.now().withDayOfMonth(LocalDate.now().lengthOfMonth());
LocalDate targetDate = LocalDate.of(year, month, 1);
LocalDate currentMonthStartDate = targetDate.withDayOfMonth(1);
LocalDate currentMonthEndDate = targetDate.withDayOfMonth(targetDate.lengthOfMonth());
// 前月の期間取得
LocalDate previousMonthStartDate = LocalDate.now().minusMonths(1).withDayOfMonth(1);
LocalDate previousMonthEndDate = LocalDate.now().minusMonths(1).withDayOfMonth(LocalDate.now().minusMonths(1).lengthOfMonth());
LocalDate previousDate = targetDate.minusMonths(1);
LocalDate previousMonthStartDate = previousDate.withDayOfMonth(1);
LocalDate previousMonthEndDate = previousDate.withDayOfMonth(previousDate.lengthOfMonth());
// 今月の支出取得
Integer currentMonthTotalAmount = transactionRepository.findTotalExpense(currentMonthStartDate, currentMonthEndDate, userId);

View File

@@ -25,4 +25,8 @@ public class CourseServiceImpl implements CourseService {
public CourseModel findById(Long courseId) {
return CourseModel.convertFrom(courseRepository.findByCourseId(courseId));
}
public Long findByName(String courseName) {
return courseRepository.findByCourseName(courseName).getCourseId();
}
}

View File

@@ -29,7 +29,35 @@ public class GoalServiceImpl implements GoalService {
UserEntity userEntity = userRepository.findById(userId).orElseThrow();
GoalEntity goalEntity = userEntity.getGoalEntity();
return GoalModel.convertFrom(goalEntity);
// 収支の合計を計算(収入はプラス、支出はマイナス)
int transactionTotal = userEntity.getTransactionEntityList().stream()
.mapToInt(t -> {
int sign = t.getCategoryEntity().getTransactionType() == 1 ? 1 : -1;
return sign * t.getAmount();
})
.sum();
// 現在の資産 = 貯蓄金 + 収支合計
int currentAmount = userEntity.getSaving() + transactionTotal;
// 達成率(%) = 現在の資産 ÷ 目標金額 × 100
int achievementRate =
(goalEntity.getTargetAmount() == null)
? 0 :
(int) ((currentAmount * 100.0) / goalEntity.getTargetAmount());
GoalModel goalModel = GoalModel.convertFrom(goalEntity);
return new GoalModel(
goalModel.getGoalId(),
goalModel.getGoalTitle(),
goalModel.getGoalSubtitle(),
goalModel.getTargetAmount(),
goalModel.getDeadline(),
goalModel.getGoalComplete(),
achievementRate,
currentAmount);
}
@Override

View File

@@ -0,0 +1,42 @@
package com.example.demo.app.domain.service.impl;
import org.springframework.stereotype.Service;
import com.example.demo.app.domain.service.PasswordResetService;
import com.example.demo.app.infra.entity.UserEntity;
import com.example.demo.app.infra.repository.UserRepository;
import com.example.demo.app.presentation.form.PasswordResetForm;
import lombok.RequiredArgsConstructor;
@Service
@RequiredArgsConstructor
public class PasswordResetServiceImpl implements PasswordResetService {
private final UserRepository userRepository;
@Override
public boolean resetPassword(
Long userId,
PasswordResetForm passwordResetForm) {
if (!passwordResetForm.getPassword()
.equals(passwordResetForm.getPasswordConfirm())) {
return false;
}
UserEntity userEntity =
userRepository.findById(userId).orElse(null);
if (userEntity == null) {
return false;
}
userEntity.setPassword(
passwordResetForm.getPassword());
userRepository.save(userEntity);
return true;
}
}

View File

@@ -6,6 +6,7 @@ import com.example.demo.app.domain.model.ProfileModel;
import com.example.demo.app.domain.service.ProfileService;
import com.example.demo.app.infra.entity.UserEntity;
import com.example.demo.app.infra.repository.UserRepository;
import com.example.demo.app.presentation.form.ProfileEditForm;
import lombok.RequiredArgsConstructor;
@@ -31,4 +32,32 @@ public class ProfileServiceImpl implements ProfileService{
userEntity.getAnnualIncome(),
userEntity.getMonthlyBudget());
}
@Override
public void withdraw(Long userId) {
UserEntity userEntity = userRepository.findById(userId).orElse(null);
if (userEntity == null) {
return;
}
userEntity.setDeleteFlag(1);
userRepository.save(userEntity);
}
@Override
public void update(Long userId, ProfileEditForm profileEditForm) {
UserEntity userEntity = userRepository.findById(userId).orElse(null);
if (userEntity == null) {
return;
}
userEntity.setUserName(profileEditForm.getUserName());
userEntity.setMailAddress(profileEditForm.getMailAddress());
userEntity.setSaving(profileEditForm.getSaving());
userEntity.setAnnualIncome(profileEditForm.getAnnualIncome());
userEntity.setMonthlyBudget(profileEditForm.getMonthlyBudget());
userRepository.save(userEntity);
}
}

View File

@@ -0,0 +1,23 @@
package com.example.demo.app.domain.service.impl;
import java.util.List;
import org.springframework.stereotype.Service;
import com.example.demo.app.domain.service.QuestionService;
import com.example.demo.app.infra.entity.QuestionEntity;
import com.example.demo.app.infra.repository.QuestionRepository;
import lombok.RequiredArgsConstructor;
@Service
@RequiredArgsConstructor
public class QuestionServiceImpl implements QuestionService{
private final QuestionRepository questionRepository;
public List<QuestionEntity> findAll() {
return questionRepository.findAll();
}
}

View File

@@ -2,6 +2,7 @@ package com.example.demo.app.domain.service.impl;
import org.springframework.stereotype.Service;
import com.example.demo.app.domain.model.UserModel;
import com.example.demo.app.domain.service.UserService;
import com.example.demo.app.infra.entity.CourseEntity;
import com.example.demo.app.infra.entity.GoalEntity;
@@ -15,7 +16,6 @@ import com.example.demo.app.presentation.form.UserForm;
import lombok.RequiredArgsConstructor;
@Service
@RequiredArgsConstructor
public class UserServiceImpl implements UserService {
@@ -25,7 +25,7 @@ public class UserServiceImpl implements UserService {
private final CourseRepository courseRepository;
@Override
public void register(UserForm userForm) {
public void register(UserForm userForm, Long courseId) {
UserEntity userEntity = new UserEntity();
@@ -35,22 +35,21 @@ public class UserServiceImpl implements UserService {
userEntity.setSecretQuestionAnswer(userForm.getSecretAnswer());
userEntity.setBirthDate(userForm.getBirthDate());
userEntity.setSaving(userForm.getSaving());
userEntity.setBirthDate(userForm. getBirthDate());
userEntity.setBirthDate(userForm.getBirthDate());
userEntity.setSaving(userForm.getSaving());
userEntity.setAnnualIncome(userForm.getAnnualIncome());
userEntity.setMonthlyBudget(userForm.getMonthlyBudget());
QuestionEntity questionEntity =
questionRepository.findById(userForm.getSecretQuestionId()).orElse(null);
QuestionEntity questionEntity = questionRepository.findById(userForm.getSecretQuestionId()).orElse(null);
GoalEntity goalEntity =
goalRepository.findById(userForm.getGoalId()).orElse(null);
GoalEntity goalEntity = new GoalEntity();
goalEntity.setTargetAmount(Integer.parseInt(String.valueOf(userForm.getGoalId())));
CourseEntity courseEntity =
courseRepository.findById(userForm.getCourseId()).orElse(null);
CourseEntity courseEntity = courseRepository.findById(courseId).orElse(null);
userEntity.setQuestionEntity(questionEntity);
userEntity.setGoalEntity(goalEntity);
userEntity.setGoalEntity(goalRepository.save(
goalEntity));
userEntity.setCourseEntity(courseEntity);
userEntity.setDeleteFlag(0);
@@ -69,7 +68,8 @@ public class UserServiceImpl implements UserService {
userRepository.save(userEntity);
}
public UserModel findByUserId(Long userId) {
return UserModel.convertFrom(userRepository.findById(userId).get());
}
}

View File

@@ -32,14 +32,14 @@ public class GoalEntity {
@Column(name = "goal_subtitle", nullable = true)
private String goalSubtitle;
@Column(name = "target_amount", nullable = false)
@Column(name = "target_amount", nullable = true)
private Integer targetAmount;
@Column(name = "deadline", nullable = false)
private LocalDate deadline;
@Column(name = "deadline", nullable = true)
private LocalDate deadline = LocalDate.now().plusYears(1L);
@Column(name = "goal_complete", nullable = true)
private Integer goalComplete;
@Column(name = "goal_complete", nullable = false)
private Integer goalComplete = 0;
@OneToOne(mappedBy = "goalEntity")
private UserEntity userEntity;

View File

@@ -10,5 +10,8 @@ public interface CourseRepository extends JpaRepository<CourseEntity, Long> {
@Query("SELECT c FROM CourseEntity c WHERE c.courseId = :courseId ")
public CourseEntity findByCourseId(Long courseId);
@Query("SELECT c FROM CourseEntity c WHERE c.courseName = :courseName ")
public CourseEntity findByCourseName(String courseName);
}

View File

@@ -1,11 +1,15 @@
package com.example.demo.app.presentation.controller;
import java.time.LocalDate;
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.RequestParam;
import com.example.demo.aop.aspect.SessionCheck;
import com.example.demo.app.domain.model.AnalysisModel;
import com.example.demo.app.domain.model.LoginModel;
import com.example.demo.app.domain.service.AnalysisService;
@@ -20,19 +24,47 @@ public class AnalysisController {
private final AnalysisService analysisService;
@SessionCheck
@GetMapping("/analysis")
public String showAnalysis(Model model, HttpSession session) {
public String showAnalysis(
@RequestParam(required = false) Integer year,
@RequestParam(required = false) Integer month,
Model model,
HttpSession session) {
//ログインユーザーの取得(セッション)
LoginModel loginUser = (LoginModel) session.getAttribute("loginUser");
//初期年月表示
LocalDate nowDate = LocalDate.now();
if (year == null) {
year = nowDate.getYear();
}
if (month == null) {
month = nowDate.getMonthValue();
}
//前月・翌月作成
LocalDate targetDate = LocalDate.of(year, month, 1);
LocalDate previousDate = targetDate.minusMonths(1);
LocalDate nextDate = targetDate.plusMonths(1);
//分析結果の取得(Service)
AnalysisModel analysisModel = analysisService.getAnalysis(loginUser.getUserId());
AnalysisModel analysisModel = analysisService.getAnalysis(loginUser.getUserId(), year, month);
AnalysisForm analysisForm = AnalysisForm.convertFrom(analysisModel);
//model格納
model.addAttribute("analysisForm", analysisForm);
model.addAttribute("year", year);
model.addAttribute("month", month);
model.addAttribute("previousYear", previousDate.getYear());
model.addAttribute("previousMonth", previousDate.getMonthValue());
model.addAttribute("nextYear", nextDate.getYear());
model.addAttribute("nextMonth", nextDate.getMonthValue());
return "analysis";
}

View File

@@ -11,6 +11,7 @@ import com.example.demo.app.domain.model.AuthenticationModel;
import com.example.demo.app.domain.service.AuthenticationService;
import com.example.demo.app.infra.repository.QuestionRepository;
import com.example.demo.app.presentation.form.AuthenticationForm;
import com.example.demo.app.presentation.form.PasswordResetForm;
import lombok.RequiredArgsConstructor;
@@ -50,6 +51,10 @@ public class AuthenticationController {
"passwordResetUserId",
authenticationModel.getUserId());
model.addAttribute(
"passwordResetForm",
new PasswordResetForm());
return "password_reset";
}

View File

@@ -1,8 +1,5 @@
package com.example.demo.app.presentation.controller;
import java.util.logging.Level;
import java.util.logging.Logger;
import jakarta.servlet.http.HttpSession;
import org.springframework.stereotype.Controller;
@@ -12,6 +9,7 @@ import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
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.CourseInfoService;
import com.example.demo.app.domain.service.CourseService;
@@ -24,74 +22,53 @@ import lombok.RequiredArgsConstructor;
@Controller
//@RequestMapping("/course")
@RequiredArgsConstructor
public class CourseController {
private final static Logger LOGGER = Logger.getLogger(CourseController.class.getName());
// エラーメッセージ用の定数フィールド
private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!";
private final HttpSession httpSession;
private final CourseService courseService;
private final CourseInfoService courseInfoService;
private final UserService userService;
@GetMapping("/course/select/register")
@PostMapping("/user/register/course")
public String showSelectCourse(@ModelAttribute UserForm userForm, Model model, HttpSession session) {
try {
System.out.println(userForm.getMailAddress());
session.setAttribute("userForm", userForm);
model.addAttribute("mode", "regist");
model.addAttribute("currentCourseId", 4);
model.addAttribute("courseList", CourseForm.convertFrom(courseService.findAll()));
model.addAttribute("courseInfoList", CourseInfoForm.convertFrom(courseInfoService.findAll()));
return "select_course";
} catch (Exception e) {
// ログイン情報の破棄
httpSession.invalidate();
e.printStackTrace();
// エラーログ出力
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e);
// エラー画面遷移
return null;
}
}
@GetMapping("/select/change")
public String showChangeCourse(Model model) {
@SessionCheck
@GetMapping("/course")
public String showChangeCourse(Model model, HttpSession session) {
try {
LoginModel loginUser = (LoginModel) session.getAttribute("loginUser");
Long userId = loginUser.getUserId();
Long currentCourseId = userService.findByUserId(userId).getCourseId();
model.addAttribute("mode", "change");
model.addAttribute("currentCourseId", currentCourseId);
model.addAttribute("courseList", CourseForm.convertFrom(courseService.findAll()));
model.addAttribute("courseInfoList", CourseInfoForm.convertFrom(courseInfoService.findAll()));
return "select_course";
} catch (Exception e) {
// ログイン情報の破棄
httpSession.invalidate();
e.printStackTrace();
// エラーログ出力
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e);
// エラー画面遷移
return null;
}
}
@SessionCheck
@PostMapping("/change")
public String changeCourse(@RequestParam Long courseId) {
public String changeCourse(@RequestParam Long courseId, HttpSession httpSession) {
LoginModel loginUser = (LoginModel) httpSession.getAttribute("loginUser");

View File

@@ -9,6 +9,7 @@ import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import com.example.demo.aop.aspect.SessionCheck;
import com.example.demo.app.domain.model.GoalModel;
import com.example.demo.app.domain.model.LoginModel;
import com.example.demo.app.domain.service.GoalService;
@@ -23,14 +24,13 @@ public class GoalController {
private final GoalService goalService;
@SessionCheck
@GetMapping("")
public String getGoal(Model model, HttpSession session) {
LoginModel loginUser = (LoginModel) session.getAttribute("loginUser");
Long userId = loginUser.getUserId();
//テスト用
// Long userId = 1L;
GoalModel goalModel = goalService.getGoalByUserId(userId);
GoalForm goalForm = GoalForm.convertFrom(goalModel);
@@ -39,15 +39,13 @@ public class GoalController {
return "goal_view";
}
@SessionCheck
@GetMapping("/edit")
public String editGoal(Model model, HttpSession session) {
LoginModel loginUser = (LoginModel) session.getAttribute("loginUser");
Long userId = loginUser.getUserId();
//テスト用
// Long userId = 1L;
GoalModel goalModel = goalService.getGoalByUserId(userId);
GoalForm goalForm = GoalForm.convertFrom(goalModel);
@@ -55,15 +53,13 @@ public class GoalController {
return "goal_edit";
}
@SessionCheck
@PostMapping("/update")
public String updateGoal(@ModelAttribute GoalForm goalForm, HttpSession session) {
LoginModel loginUser = (LoginModel) session.getAttribute("loginUser");
Long userId = loginUser.getUserId();
//テスト用
// Long userId = 1L;
// 本人の目標かどうかを確認してから更新する
GoalModel currentGoal = goalService.getGoalByUserId(userId);

View File

@@ -0,0 +1,70 @@
package com.example.demo.app.presentation.controller;
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.PostMapping;
import com.example.demo.app.domain.model.LoginModel;
import com.example.demo.app.domain.service.PasswordResetService;
import com.example.demo.app.presentation.form.PasswordResetForm;
import lombok.RequiredArgsConstructor;
@Controller
@RequiredArgsConstructor
public class PasswordResetController {
private final PasswordResetService passwordResetService;
@GetMapping("/password/reset")
public String showPasswordReset(Model model) {
model.addAttribute("passwordResetForm", new PasswordResetForm());
return "password_reset";
}
@PostMapping("/password/reset")
public String resetPassword(
PasswordResetForm passwordResetForm,
Model model,
HttpSession session){
Long userId =
(Long) session.getAttribute("passwordResetUserId");
if (userId == null) {
LoginModel loginUser =
(LoginModel) session.getAttribute("loginUser");
if (loginUser != null) {
userId = loginUser.getUserId();
}
}
if (userId == null) {
return "redirect:/login";
}
boolean isReset =
passwordResetService.resetPassword(userId, passwordResetForm);
System.out.println("isReset=" + isReset);
if(!isReset) {
model.addAttribute("Message", "パスワードが一致しません。");
return "password_reset";
}
session.removeAttribute("passwordResetUserId");
LoginModel loginUser =
(LoginModel) session.getAttribute("loginUser");
if (loginUser != null) {
return "redirect:/menu";
}
return "redirect:/login";
}
}

View File

@@ -5,10 +5,14 @@ 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.model.ProfileModel;
import com.example.demo.app.domain.service.ProfileService;
import com.example.demo.app.presentation.form.ProfileEditForm;
import com.example.demo.app.presentation.form.ProfileForm;
import lombok.RequiredArgsConstructor;
@@ -18,6 +22,7 @@ import lombok.RequiredArgsConstructor;
public class ProfileController {
private final ProfileService profileService;
@SessionCheck
@GetMapping("/profile")
public String profile(Model model, HttpSession session) {
LoginModel loginUser = (LoginModel) session.getAttribute("loginUser");
@@ -29,4 +34,63 @@ public class ProfileController {
model.addAttribute("profileForm", profileForm);
return "profile";
}
@SessionCheck
@GetMapping("/profile/edit")
public String showEditProfile(
Model model,
HttpSession session) {
LoginModel loginUser =
(LoginModel) session.getAttribute("loginUser");
ProfileModel profileModel =
profileService.findOne(loginUser.getUserId());
ProfileEditForm profileEditForm =
new ProfileEditForm(
profileModel.getUserName(),
profileModel.getMailAddress(),
profileModel.getSaving(),
profileModel.getAnnualIncome(),
profileModel.getMonthlyBudget());
model.addAttribute("profileEditForm", profileEditForm);
return "profile_edit";
}
@PostMapping("/profile/edit")
public String updateProfile(
@ModelAttribute ProfileEditForm profileEditForm,
HttpSession session) {
LoginModel loginUser =
(LoginModel) session.getAttribute("loginUser");
profileService.update(
loginUser.getUserId(),
profileEditForm);
return "redirect:/profile";
}
@PostMapping("/withdraw")
public String withdraw(HttpSession session) {
LoginModel loginUser =
(LoginModel) session.getAttribute("loginUser");
profileService.withdraw(loginUser.getUserId());
session.invalidate();
return "redirect:/login";
}
@PostMapping("/logout")
public String logout(HttpSession session) {
session.invalidate();
return "redirect:/login";
}
}

View File

@@ -17,13 +17,18 @@ import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
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.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.Income;
import com.example.demo.app.presentation.form.TransactionForm;
import com.example.demo.app.presentation.form.UserForm;
import lombok.RequiredArgsConstructor;
@@ -33,46 +38,95 @@ public class TransactionController {
private final TransactionService transactionService;
private final CategoryService categoryService;
private final GoalService goalService;
private final UserService userService;
// 一覧画面
@SessionCheck
@GetMapping("/transaction/list")
public String transactionList(@RequestParam(required = false) LocalDate startDates,
@RequestParam(required = false) LocalDate endDates, Model model,
public String transactionList(
@RequestParam(required = false, defaultValue = "0") String years,
@RequestParam(required = false, defaultValue = "0") String months,
Model model,
HttpSession session) {
LocalDate startDate = (startDates == null) ? LocalDate.now().withDayOfMonth(1) : startDates;
LocalDate endDate = (endDates == null) ? LocalDate.now().withDayOfMonth(LocalDate.now().lengthOfMonth())
: endDates;
LoginModel loginUser = (LoginModel) session.getAttribute("loginUser");
LocalDate today = LocalDate.now();
int year = years.equals("0")
? today.getYear()
: Integer.parseInt(years);
int month = months.equals("0")
? today.getMonthValue()
: Integer.parseInt(months);
YearMonth yearMonth = YearMonth.of(year, month);
YearMonth previousYearMonth = yearMonth.minusMonths(1);
int previousYear = previousYearMonth.getYear();
int previousMonth = previousYearMonth.getMonthValue();
YearMonth nextYearMonth = yearMonth.plusMonths(1);
int nextYear = nextYearMonth.getYear();
int nextMonth = nextYearMonth.getMonthValue();
LocalDate startDate = yearMonth.atDay(1);
LocalDate endDate = yearMonth.atEndOfMonth();
Map<LocalDate, List<TransactionForm>> transactionFormMap = new HashMap<>();
transactionService.findAllByDate(startDate, endDate, loginUser.getUserId()).forEach((date, list) -> {
List<TransactionForm> transactionFormList = list.stream().map(transaction -> {
System.out.println(transaction.getTransactionDate());
TransactionForm transactionForm = TransactionForm.convertFrom(
transactionService
.findAllByDate(
startDate,
endDate,
loginUser.getUserId())
.forEach((date, list) -> {
List<TransactionForm> transactionFormList = list.stream()
.map(transaction -> {
CategoryForm categoryForm = CategoryForm.convertFrom(
categoryService.findOne(
transaction.getCategoryId()));
return TransactionForm.convertFrom(
transaction,
CategoryForm.convertFrom(categoryService.findOne(transaction.getCategoryId()))
.getCategoryName(),
transactionService.findTotalExpense(startDate, endDate, loginUser.getUserId()),
transactionService.findTotalIncome(startDate, endDate, loginUser.getUserId()),
CategoryForm.convertFrom(categoryService.findOne(transaction.getCategoryId()))
.getTransactionType());
System.out.println("startDate = " + startDate);
System.out.println("endDate = " + endDate);
return transactionForm;
}).collect(Collectors.toList());
categoryForm.getCategoryName(),
transactionService.findTotalExpense(
startDate,
endDate,
loginUser.getUserId()),
transactionService.findTotalIncome(
startDate,
endDate,
loginUser.getUserId()),
categoryForm.getTransactionType());
})
.collect(Collectors.toList());
transactionFormMap.put(date, transactionFormList);
});
model.addAttribute("year", year);
model.addAttribute("month", month);
model.addAttribute("previousYear", previousYear);
model.addAttribute("previousMonth", previousMonth);
model.addAttribute("nextYear", nextYear);
model.addAttribute("nextMonth", nextMonth);
model.addAttribute("transactionFormMap", transactionFormMap);
return "transaction_list";
}
// 詳細画面
@SessionCheck
@GetMapping("/transaction/detail")
public String findOne(@RequestParam(required = false) LocalDate todayDates, Model model, HttpSession session) {
@@ -125,6 +179,7 @@ public class TransactionController {
return "transaction_detail";
}
@SessionCheck
@GetMapping("/transaction/create")
public String createOneGet(@RequestParam(defaultValue = "") LocalDate today,
Model model) {
@@ -149,6 +204,7 @@ public class TransactionController {
return "transaction_create";
}
@SessionCheck
@PostMapping("/transaction/create")
public String createOnePost(@ModelAttribute TransactionForm transactionForm, @RequestParam LocalDate today,
Model model,
@@ -164,6 +220,7 @@ public class TransactionController {
}
@SessionCheck
@GetMapping("/transaction/update")
public String updateOneGet(@RequestParam Long transactionId, @RequestParam(defaultValue = "") LocalDate today,
Model model) {
@@ -183,7 +240,6 @@ public class TransactionController {
System.out.println("category: " + transactionForm.getCategoryId() + "金額: " + transactionForm.getAmount());
model.addAttribute("transactionId", transactionId);
model.addAttribute("transactionForm", transactionForm);
@@ -196,8 +252,10 @@ public class TransactionController {
}
@SessionCheck
@PostMapping("/transaction/update")
public String updateOnePost(@RequestParam Long transactionId, @ModelAttribute TransactionForm transactionForm, @RequestParam LocalDate today, Model model,
public String updateOnePost(@RequestParam Long transactionId, @ModelAttribute TransactionForm transactionForm,
@RequestParam LocalDate today, Model model,
HttpSession session) {
LoginModel loginUser = (LoginModel) session.getAttribute("loginUser");
@@ -213,6 +271,7 @@ public class TransactionController {
}
@SessionCheck
@PostMapping("/transaction/delete")
public String deleteOne(@RequestParam Long transactionId, @RequestParam LocalDate today) {
@@ -220,6 +279,7 @@ public class TransactionController {
return "redirect:/transaction/detail?todayDates=" + today;
}
@SessionCheck
@GetMapping("/menu")
public String menu(HttpSession session, Model model,
@RequestParam(required = false, defaultValue = "0") String years,
@@ -230,9 +290,8 @@ public class TransactionController {
LocalDate today = LocalDate.now();
int year = (years.equals("0")) ? today.getYear() : Integer.parseInt(years);
int month = (months.equals("0")) ? today.getMonthValue() : Integer.parseInt(months);
System.out.println("year : " + year + "month : " + month);
int month = (months.equals("0")) ? today.getMonthValue() : Integer.parseInt(months);
YearMonth yearMonth = YearMonth.of(year, month);
@@ -240,6 +299,16 @@ public class TransactionController {
int firstDayOfWeek = yearMonth.atDay(1).getDayOfWeek().getValue() % 7;
YearMonth previousYearMonth = yearMonth.minusMonths(1);
int previousYear = previousYearMonth.getYear();
int previousMonth = previousYearMonth.getMonthValue();
YearMonth nextYearMonth = yearMonth.plusMonths(1);
int nextYear = nextYearMonth.getYear();
int nextMonth = nextYearMonth.getMonthValue();
model.addAttribute("year", year);
model.addAttribute("month", month);
model.addAttribute("day", today.getDayOfMonth());
@@ -247,15 +316,20 @@ public class TransactionController {
model.addAttribute("lastDay", lastDay);
model.addAttribute("firstDayOfWeek", firstDayOfWeek);
LocalDate startDate = LocalDate.now().withDayOfMonth(1);
model.addAttribute("previousYear", previousYear);
model.addAttribute("previousMonth", previousMonth);
LocalDate endDate = LocalDate.now().withDayOfMonth(LocalDate.now().lengthOfMonth());
model.addAttribute("nextYear", nextYear);
model.addAttribute("nextMonth", nextMonth);
LocalDate startDate = yearMonth.atDay(1);
LocalDate endDate = yearMonth.atEndOfMonth();
List<Income> incomeList = transactionService.findTotalIncomeList(startDate, endDate, loginUser.getUserId());
List<Expense> expenseList = transactionService.findTotalExpenseList(startDate, endDate, loginUser.getUserId());
model.addAttribute("incomeList", incomeList);
model.addAttribute("expenseList", expenseList);
int totalIncome = transactionService.findTotalIncome(startDate, endDate, loginUser.getUserId());
@@ -265,6 +339,20 @@ public class TransactionController {
model.addAttribute("totalIncome", totalIncome);
model.addAttribute("totalExpense", totalExpense);
GoalForm 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("saving", userForm.getSaving());
model.addAttribute("deadline", goalForm.getDeadline());
return "menu";
}

View File

@@ -1,5 +1,7 @@
package com.example.demo.app.presentation.controller;
import java.util.List;
import jakarta.servlet.http.HttpSession;
import org.springframework.stereotype.Controller;
@@ -10,6 +12,9 @@ import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import com.example.demo.app.domain.service.CourseService;
import com.example.demo.app.domain.service.QuestionService;
import com.example.demo.app.domain.service.UserService;
import com.example.demo.app.infra.entity.QuestionEntity;
import com.example.demo.app.presentation.form.UserForm;
import lombok.RequiredArgsConstructor;
@@ -18,12 +23,21 @@ import lombok.RequiredArgsConstructor;
@RequiredArgsConstructor
public class UserController {
private final UserService userService;
private final CourseService courseService;
private final QuestionService questionService;
@GetMapping("/user/register")
public String showRegister(Model model, HttpSession session) {
UserForm userForm = new UserForm();
List<QuestionEntity> questionList = questionService.findAll();
session.setAttribute("questionList", questionList);
model.addAttribute("userForm", userForm);
return "user_register";
}
@@ -32,41 +46,46 @@ public class UserController {
public String showRegisterReturn(@RequestParam(required = false) Long courseId, Model model, HttpSession session) {
UserForm userForm = (UserForm) session.getAttribute("userForm");
System.out.println(
"######################################################################3" + userForm.getBirthDate());
if(userForm == null) {
if (userForm.getUserName().equals("")) {
userForm = new UserForm();
userForm.setCourseId(courseId);
}
if(courseId != null) {
if (courseId != null) {
model.addAttribute("selectedCourseName", courseService.findById(courseId).getCourseName());
}
session.setAttribute("selectedCourseName", courseService.findById(courseId).getCourseName());
model.addAttribute("courseId", courseId);
System.out.println(
"######################################################################3" + userForm.getBirthDate());
model.addAttribute("userForm", userForm);
return "user_register";
return "user_register_return";
}
@PostMapping("/user/register/confirm")
public String confirmRegister(
@ModelAttribute UserForm userForm,
@GetMapping("/user/register/confirm")
public String confirmRegisterGet(@ModelAttribute UserForm userForm,
String selectedCourseName, Model model,
HttpSession session) {
session.setAttribute("userForm", userForm);
model.addAttribute("selectedCourseName", (String) session.getAttribute("selectedCourseName"));
return "user_register_confirm";
}
@PostMapping("/user/register/complete")
public String completeRegister(HttpSession session) {
public String confirmRegister(
@ModelAttribute UserForm userForm,
Model model,
HttpSession session) {
UserForm userForm =
(UserForm) session.getAttribute("userForm");
Long courseId = courseService.findByName((String) session.getAttribute("selectedCourseName"));
// DBへの登録処理
session.removeAttribute("userForm");
userService.register(userForm, courseId);
return "redirect:/login";
}

View File

@@ -9,6 +9,6 @@ import lombok.NoArgsConstructor;
@NoArgsConstructor
public class AuthenticationForm {
private String mailAddress;
private Integer secretQuestionId;
private Long secretQuestionId;
private String secretAnswer;
}

View File

@@ -2,6 +2,8 @@ package com.example.demo.app.presentation.form;
import java.time.LocalDate;
import org.springframework.format.annotation.DateTimeFormat;
import com.example.demo.app.domain.model.GoalModel;
import lombok.AllArgsConstructor;
@@ -21,10 +23,15 @@ public class GoalForm {
private Integer targetAmount;
@DateTimeFormat(pattern = "yyyy-MM-dd")
private LocalDate deadline;
private Integer goalComplete;
private Integer achievementRate; // 達成率
private Integer currentAmount; // 現在の資産
public static GoalForm convertFrom(GoalModel goalModel) {
return new GoalForm(
goalModel.getGoalId(),
@@ -32,7 +39,9 @@ public class GoalForm {
goalModel.getGoalSubtitle(),
goalModel.getTargetAmount(),
goalModel.getDeadline(),
goalModel.getGoalComplete());
goalModel.getGoalComplete(),
goalModel.getAchievementRate(),
goalModel.getCurrentAmount());
}
// public static List<GoalForm> convertFrom(List<GoalModel> goalModelList) {

View File

@@ -0,0 +1,16 @@
package com.example.demo.app.presentation.form;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ProfileEditForm {
private String userName;
private String mailAddress;
private Integer saving;
private Integer annualIncome;
private Integer monthlyBudget;
}

View File

@@ -2,6 +2,8 @@ package com.example.demo.app.presentation.form;
import java.time.LocalDate;
import com.example.demo.app.domain.model.UserModel;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@@ -12,13 +14,30 @@ import lombok.NoArgsConstructor;
public class UserForm {
private String userName;
private String mailAddress;
private LocalDate birthDate;
private String password;
private Long secretQuestionId;
private String SecretAnswer;
private LocalDate birthDate;
private String secretAnswer;
private Integer saving;
private Integer annualIncome;
private Integer monthlyBudget;
private Long goalId;
private Long courseId;
public static UserForm convertFrom(UserModel userModel) {
return new UserForm(
userModel.getUserName(),
userModel.getMailAddress(),
userModel.getBrithDate(),
userModel.getPassword(),
userModel.getSecretQuestionId(),
userModel.getSecretAnswer(),
userModel.getSaving(),
userModel.getAnnualIncome(),
userModel.getMonthlyBudget(),
userModel.getGoalId(),
userModel.getCourseId()
);
}
}

View File

@@ -1,22 +0,0 @@
package com.example.demo.exception;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
@ControllerAdvice
public class GlobalExceptionHandler {
@ExceptionHandler(Exception.class)
public String handleException(
Exception e,
Model model) {
model.addAttribute(
"errorMessage",
"システムエラーが発生しました。"
+ "初めからやり直してください。");
return "error";
}
}

View File

@@ -0,0 +1,9 @@
package com.example.demo.exception;
public class InsufficientPermissionException extends RuntimeException {
public InsufficientPermissionException(String message) {
super(message);
}
}

View File

@@ -0,0 +1,9 @@
package com.example.demo.exception;
public class NoSessionException extends RuntimeException {
public NoSessionException(String message) {
super(message);
}
}

View File

@@ -22,7 +22,7 @@ th {
}
td {
width: 14.28%;
width: 14%;
height: 70px;
padding: 5px;
text-align: left;
@@ -42,6 +42,22 @@ td:hover {
background-color: bisque;
}
.calendar-title {
display: flex;
justify-content: center;
align-items: center;
gap: 30px;
margin: 15px 10px;
}
.calendar-date {
display: flex;
align-items: baseline;
gap: 10px;
}
.year {
font-size: 20px;
}
@@ -51,8 +67,23 @@ td:hover {
font-weight: bold;
}
.calendar-title {
margin: 15px 10px;
.month-button {
display: flex;
justify-content: center;
align-items: center;
width: 40px;
height: 40px;
font-size: 28px;
text-decoration: none;
color: #333;
border-radius: 50%;
}
.month-button:hover {
background-color: #eee;
}
.date {

View File

@@ -5,6 +5,7 @@
<title>分析画面</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body class="pb-5 pt-5">
<div th:replace="~{header :: header}">
@@ -13,6 +14,23 @@
<div class="container mt-4">
<h2 class="text-center">支出分析</h2>
<div class="text-center">
<a class="month-button" th:href="@{/analysis(year=${previousYear}, month=${previousMonth})}">
←
</a>
<div class="calendar-date">
<span class="year" th:text="|${year}年|"></span>
<span class="month" th:text="|${month}月|"></span>
</div>
<a class="month-button" th:href="@{/analysis(year=${nextYear}, month=${nextMonth})}">
→
</a>
</div>
<table class="table text-center">
<thead>
<tr>

View File

@@ -4,9 +4,15 @@
<head>
<meta charset="UTF-8">
<title>認証</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<body class="pb-5 pt-5">
<div th:replace="~{header :: header}">
</div>
<main>
<h1>本人認証確認</h1>
@@ -48,6 +54,9 @@
alert(/*[[${errorMessage}]]*/);
</script>
<div th:replace="~{footer :: footer}">
</div>
</body>
</html>

View File

@@ -5,7 +5,10 @@
<title>エラー</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<body class="pb-5 pt-5">
<div th:replace="~{header :: header}">
</div>
</head>
<body>

View File

@@ -3,8 +3,13 @@
<head>
<meta charset="UTF-8">
<title>目標編集</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<body class="pb-5 pt-5">
<div th:replace="~{header :: header}"></div>
<h1>目標編集</h1>
@@ -13,26 +18,29 @@
<div>
<label>目標名</label>
<input type="text" th:field="*{goalTitle}">
<input type="text" th:field="*{goalTitle}" required>
</div>
<div>
<label>目標説明</label>
<textarea th:field="*{goalSubtitle}"></textarea>
<textarea th:field="*{goalSubtitle}" required></textarea>
</div>
<div>
<label>目標金額</label>
<input type="number" th:field="*{targetAmount}">
<input type="number" th:field="*{targetAmount}" required min="1">
</div>
<div>
<label>目標達成期限</label>
<input type="date" th:field="*{deadline}">
<input type="date" th:field="*{deadline}" th:min="${#temporals.format(#temporals.createNow(), 'yyyy-MM-dd')}" required>
</div>
<button type="submit">更新する</button>
</form>
<div th:replace="~{footer :: footer}"></div>
</body>
</html>

View File

@@ -3,13 +3,17 @@
<head>
<meta charset="UTF-8">
<title>目標詳細</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<body class="pb-5 pt-5">
<div th:replace="~{header :: header}"></div>
<h1>目標詳細</h1>
<table>
<tr>
<th>目標名</th>
<td th:text="${goalForm.goalTitle}"></td>
@@ -27,9 +31,18 @@
<th>目標達成期限</th>
<td th:text="${goalForm.deadline}"></td>
</tr>
<tr>
<th>達成率</th>
<td th:text="${goalForm.achievementRate} + '%'"></td>
</tr>
</table>
<a th:href="@{/goal/edit}">編集する</a>
<div th:replace="~{footer :: footer}"></div>
</body>
</html>

View File

@@ -3,9 +3,12 @@
<head>
<meta charset="UTF-8">
<title>ログイン</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<header></header>
<body class="pb-5 pt-5">
<div th:replace="~{header :: header}">
</div>
<main>
<h1>ログイン</h1>

View File

@@ -14,22 +14,30 @@
</head>
<body>
<body class="pb-5 pt-5">
<div th:replace="~{header :: header}"></div>
<div class="calendar-title">
<span class="year" th:text="|${year}年|">
</span>
<a class="month-button" th:href="@{/menu(years=${previousYear}, months=${previousMonth})}">
←
</a>
<span class="month" th:text="|${month}月|">
</span>
<div class="calendar-date">
<span class="year" th:text="|${year}年|"></span>
<span class="month" th:text="|${month}月|"></span>
</div>
<a class="month-button" th:href="@{/menu(years=${nextYear}, months=${nextMonth})}">
→
</a>
</div>
<table id="calendar">
<thead>
@@ -54,21 +62,25 @@
<td th:each="weekDay : ${#numbers.sequence(0, 6)}">
<a th:if="${week * 7 + weekDay - firstDayOfWeek + 1 >= 1
and week * 7 + weekDay - firstDayOfWeek + 1 <= lastDay}"
th:href="@{/transaction/detail(
and week * 7 + weekDay - firstDayOfWeek + 1 <= lastDay}" th:href="@{/transaction/detail(
todayDates=${T(java.time.LocalDate).of(year, month, week * 7 + weekDay - firstDayOfWeek + 1)}
)}">
<div th:if="${week * 7 + weekDay - firstDayOfWeek + 1 >= 1 and week * 7 + weekDay - firstDayOfWeek + 1 <= lastDay}">
<div
th:if="${week * 7 + weekDay - firstDayOfWeek + 1 >= 1 and week * 7 + weekDay - firstDayOfWeek + 1 <= lastDay}">
<div class="date" th:text="${week * 7 + weekDay - firstDayOfWeek + 1}">
</div>
<div th:each="income : ${incomeList}" th:if="${income.date.dayOfMonth == week * 7 + weekDay - firstDayOfWeek + 1}" class="income" th:text="|収入 +${income.amount}円|">
<div th:each="income : ${incomeList}"
th:if="${income.date.dayOfMonth == week * 7 + weekDay - firstDayOfWeek + 1}"
class="income" th:text="|収入 +${income.amount}円|">
</div>
<div th:each="expense : ${expenseList}" th:if="${expense.date.dayOfMonth == week * 7 + weekDay - firstDayOfWeek + 1}" class="expense" th:text="|支出 -${expense.amount}円|">
<div th:each="expense : ${expenseList}"
th:if="${expense.date.dayOfMonth == week * 7 + weekDay - firstDayOfWeek + 1}"
class="expense" th:text="|支出 -${expense.amount}円|">
</div>
</div>
@@ -101,6 +113,37 @@
</div>
<div>
<span>目標貯金</span>
<span th:text="${targetAmount}"></span>
<span>円</span>
</div>
<div>
<span>現在高</span>
<span th:text="${currentAmount}"></span>
<span>円</span>
</div>
<div>
<span>貯金額</span>
<span th:text="${saving}"></span>
<span>円</span>
</div>
<hr>
<div>
<span>達成率</span>
<span th:text="${achievementRate}"></span>
<span>%</span>
</div>
<div>
<span>達成期限</span>
<span th:text="${deadline}"></span>
<span>円</span>
</div>
<div th:replace="~{footer :: footer}"></div>
</body>

View File

@@ -3,14 +3,18 @@
<head>
<meta charset="UTF-8">
<title>パスワード再設定</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<header></header>
<!--<body class="pb-5 pt-5">-->
<!-- <div th:replace="~{header :: header}">-->
<!-- </div>-->
<main>
<h1>パスワード再設定</h1>
<form th:action="@{/password_reset}" th:object="${passwordResetForm}" method="post">
<form th:action="@{/password/reset}" th:object="${passwordResetForm}" method="post">
<div>
<label for="password">新しいパスワード</label>
<input type="password"
@@ -34,8 +38,8 @@
<button type="submit">再設定</button>
</form>
<div th:if="${errorMessage}">
<p th:text="${errorMessage}"></p>
<div th:if="${Message}">
<p th:text="${Message}"></p>
</div>
</main>
</body>

View File

@@ -1,11 +1,15 @@
<!DOCTYPE html>
<html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>プロフィール</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<header></header>
<body class="pb-5 pt-5">
<div th:replace="~{header :: header}">
</div>
<main>
<div>
@@ -51,13 +55,18 @@
</form>
</div>
<form th:action="@{/login}" method="post">
<form th:action="@{/logout}" method="post">
<button type="submit">ログアウト</button>
</form>
<form th:action="@{/aaa}" method="post">
<form th:action="@{/withdraw}" method="post"
onsubmit="return confirm('本当に脱退しますか?');">
<button type="submit">脱退</button>
</form>
</main>
<div th:replace="~{footer :: footer}">
</div>
</body>
</html>

View File

@@ -0,0 +1,74 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>プロフィール編集</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body class="pb-5 pt-5">
<div th:replace="~{header :: header}">
</div>
<main>
<h1>プロフィール編集</h1>
<form th:action="@{/profile/edit}"th:object="${profileEditForm}"method="post">
<div>
<label>氏名</label>
<input type="text"
th:field="*{userName}"
maxlength="100"
required>
</div>
<div>
<label>メールアドレス</label>
<input type="email"
th:field="*{mailAddress}"
maxlength="255"
required>
</div>
<div>
<label>パスワード</label>
<input type="password"
value="********"
disabled>
</div>
<div>
<label>貯蓄金</label>
<input type="number"
th:field="*{saving}"
min="0"
required>
</div>
<div>
<label>年収</label>
<input type="number"
th:field="*{annualIncome}"
min="0"
required>
</div>
<div>
<label>月別使用可能額</label>
<input type="number"
th:field="*{monthlyBudget}"
min="0"
required>
</div>
<div>
<button type="submit">確認</button>
</div>
</form>
</main>
<div th:replace="~{footer :: footer}">
</div>
</body>
</html>

View File

@@ -7,16 +7,18 @@
<title>コース選択</title>
</head>
<body>
<div th:replace="~{header :: header}"></div>
<h1>コース選択</h1>
<form th:action="${mode == 'regist'} ? @{/user/register/return}: @{/change}" method="post">
<button type="submit">確定</button>
<div class="accordion" id="accordionExample">
<div class="accordion-item" th:each="course:${courseList}">
<h2 class="accordion-header d-flex align-items-center">
<input type="radio" name="courseId" th:value="${course.courseId}" class="form-check-input ms-3 me-2">
<input type="radio" name="courseId" th:value="${course.courseId}" th:checked="${course.courseId==currentCourseId}" class="form-check-input ms-3 me-2">
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" th:data-bs-target="'#collapse' + ${course.courseId}" aria-expanded="false" aria-controls="'collapse' + ${course.courseId}">
<span th:text="${course.courseName}"></span>
</button>

View File

@@ -9,7 +9,7 @@
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<body class="pb-5 pt-5">
<div th:replace="~{header :: header}"></div>

View File

@@ -9,7 +9,7 @@
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<body class="pb-5 pt-5">
<div th:replace="~{header :: header}"></div>
<h1 th:text="${today}"></h1>

View File

@@ -9,10 +9,37 @@
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<body class="pb-5 pt-5">
<div th:replace="~{header :: header}"></div>
<div class="calendar-title">
<a class="month-button" th:href="@{/transaction/list(
years=${previousYear},
months=${previousMonth}
)}">
←
</a>
<div class="calendar-date">
<span class="year" th:text="|${year}年|"></span>
<span class="month" th:text="|${month}月|"></span>
</div>
<a class="month-button" th:href="@{/transaction/list(
years=${nextYear},
months=${nextMonth}
)}">
→
</a>
</div>
<div th:each="transactionForm : ${transactionFormMap}">
<a th:href="@{/transaction/detail(todayDates=${transactionForm.key})}">

View File

@@ -9,7 +9,7 @@
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<body class="pb-5 pt-5">
<div th:replace="~{header :: header}"></div>

View File

@@ -3,14 +3,17 @@
<head>
<meta charset="UTF-8">
<title>新規会員登録</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<header></header>
<body class="pb-5 pt-5">
<div th:replace="~{header :: header}">
</div>
<main>
<h1>新規会員登録</h1>
<form th:action="@{/user/register/confirm}" th:object="${userForm}" method="post">
<form th:action="@{/user/register/course}" th:object="${userForm}" method="post">
<div>
<label for="userName">氏名</label>
<input type="text"
@@ -53,7 +56,7 @@
th:field="*{secretQuestionId}"
required>
<option value="">選択してください</option>
<option th:each="question : ${questionList}"
<option th:each="question : ${session.questionList}"
th:value="${question.secretQuestionId}"
th:text="${question.questionText}">
</option>
@@ -108,8 +111,7 @@
<div>
<label>コース</label>
<input type="hidden" th:field="*{courseId}">
<span th:text="${selectedCourseName}">未選択</span>
<button type="submit"onclick="location.href='/course/select/register'">コース選択</button>
<button type="submit">コース選択</button>
</div>
<div>

View File

@@ -1,78 +1,97 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>新規会員登録確認</title>
<meta charset="UTF-8">
<title>新規会員登録確認</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<header></header>
<body class="pb-5 pt-5">
<div th:replace="~{header :: header}">
</div>
<main>
<h1>新規会員登録確認</h1>
<form th:action="@{/user/register/complete}" th:object="${userForm}" method="post">
<div>
<p>氏名</p>
<p th:text="${user.userName}"></p>
<label for="userName">氏名</label>
<input type="text" id="userName" th:field="*{userName}" maxlength="100" readonly>
</div>
<div>
<p>メールアドレス</p>
<p th:text="${user.mailAddress}"></p>
<label for="mailAddress">メールアドレス</label>
<input type="email" id="mailAddress" th:field="*{mailAddress}" maxlength="255" readonly>
</div>
<div>
<p>生年月日</p>
<p th:text="${user.birthDate}"></p>
<label for="birthDate">生年月日</label>
<input type="date" id="birthDate" name="birthDate" th:value="*{birthDate}" required readonly>
</div>
<div>
<p>パスワード</p>
<p>********</p>
<label for="password">パスワード</label>
<input type="password" id="password" name="password" th:value="*{password}" minlength="8"
maxlength="255" required readonly>
</div>
<div>
<p>秘密の質問</p>
<p th:text="${user.secretQuestionId}"></p>
<label for="secretQuestionId">秘密の質問</label>
<select id="secretQuestionId" th:field="*{secretQuestionId}" required readonly>
<option value="">選択してください</option>
<option th:each="question : ${session.questionList}" th:value="${question.secretQuestionId}"
th:text="${question.questionText}">
</option>
</select>
</div>
<div>
<p>秘密の質問の回答</p>
<p th:text="${user.secretAnswer}"></p>
<label for="secretAnswer">秘密の質問の回答</label>
<input type="text" id="secretAnswer" th:field="*{secretAnswer}" maxlength="100" readonly>
</div>
<div>
<p>貯蓄金</p>
<p th:text="${user.saving}"></p>
<label for="saving">貯蓄金</label>
<input type="number" id="saving" th:field="*{saving}" min="0" readonly>
</div>
<div>
<p>年収</p>
<p th:text="${user.annualIncome}"></p>
<label for="annualIncome">年収</label>
<input type="number" id="annualIncome" th:field="*{annualIncome}" min="0" readonly>
</div>
<div>
<p>月別使用可能額</p>
<p th:text="${user.monthlyBudget}"></p>
<label for="monthlyBudget">月別使用可能金額</label>
<input type="number" id="monthlyBudget" th:field="*{monthlyBudget}" min="0" readonly>
</div>
<div>
<p>目標</p>
<p th:text="${user.goalId}"></p>
<label for="goalId">目標</label>
<input type="number" id="goalId" th:field="*{goalId}" min="0" readonly>
</div>
<div>
<p>コース</p>
<p th:text="${user.courseId}"></p>
<label>コース</label>
<input type="hidden" th:field="*{courseId}">
<span th:text="${selectedCourseName}">未選択</span>
<button type="submit">コース選択</button>
</div>
<div>
<button type="submit">作成</button>
</div>
<div>
<form th:action="@{/user/register}" method="get">
<button type="submit">戻る</button>
</form>
</div>
<form th:action="@{/user/register/complete}" method="post">
<button type="submit">確定</button>
</form>
</main>
</body>
</html>

View File

@@ -0,0 +1,128 @@
<!DOCTYPE html>
<html lang="ja"xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>新規会員登録</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body class="pb-5 pt-5">
<div th:replace="~{header :: header}">
</div>
<main>
<h1>新規会員登録</h1>
<form th:action="@{/user/register/confirm}" th:object="${userForm}" method="get">
<div>
<label for="userName">氏名</label>
<input type="text"
id="userName"
th:field="*{userName}"
maxlength="100"
required>
</div>
<div>
<label for="mailAddress">メールアドレス</label>
<input type="email"
id="mailAddress"
th:field="*{mailAddress}"
maxlength="255"
required>
</div>
<div>
<label for="birthDate">生年月日</label>
<input type="date" id="birthDate" name="birthDate" th:value="*{birthDate}"
required>
</div>
<div>
<label for="password">パスワード</label>
<input type="password"
id="password"
name="password"
th:value="*{password}"
minlength="8"
maxlength="255"
required>
</div>
<div>
<label for="secretQuestionId">秘密の質問</label>
<select id="secretQuestionId"
th:field="*{secretQuestionId}"
required>
<option value="">選択してください</option>
<option th:each="question : ${session.questionList}"
th:value="${question.secretQuestionId}"
th:text="${question.questionText}">
</option>
</select>
</div>
<div>
<label for="secretAnswer">秘密の質問の回答</label>
<input type="text"
id="secretAnswer"
th:field="*{secretAnswer}"
maxlength="100"
required>
</div>
<div>
<label for="saving">貯蓄金</label>
<input type="number"
id="saving"
th:field="*{saving}"
min="0"
required>
</div>
<div>
<label for="annualIncome">年収</label>
<input type="number"
id="annualIncome"
th:field="*{annualIncome}"
min="0"
required>
</div>
<div>
<label for="monthlyBudget">月別使用可能金額</label>
<input type="number"
id="monthlyBudget"
th:field="*{monthlyBudget}"
min="0"
required>
</div>
<div>
<label for="goalId">目標</label>
<input type="number"
id="goalId"
th:field="*{goalId}"
min="0"
required>
</div>
<div>
<label>コース</label>
<input type="hidden" th:field="*{courseId}">
<span th:text="${selectedCourseName}">未選択</span>
<button type="submit">コース選択</button>
</div>
<div>
<button type="submit">作成</button>
</div>
</form>
<form th:action="@{/login}" method="get">
<button type="submit">戻る</button>
</form>
</main>
</body>
</html>