171 Commits

Author SHA1 Message Date
kkazuya
640240db92 Merge branch 's-choi' of https://gitea.it-college.co.jp/2026_09_5H_Spring_KIZAKI/Monegement into k-kobayashi 2026-09-29 15:25:22 +09:00
s-choi
bbee55f58f [FIX] 未達成の履歴がメニューに表示される問題を修正しました。 2026-09-29 15:24:56 +09:00
kkazuya
f319fcb9f8 [EDIT] 固定費登録の収支区分とカテゴリーを入力必須にしました 2026-09-29 15:22:15 +09:00
78d3042299 [EDIT]マージ跡を消しました 2026-09-29 15:13:56 +09:00
ead133ba65 Merge branch 's-choi' of https://gitea.it-college.co.jp/2026_09_5H_Spring_KIZAKI/Monegement into n-kawahito
# Conflicts:
#	src/main/resources/templates/select_course.html
2026-09-29 15:13:04 +09:00
00c3041d95 [FIX]収支の選択に合わせてカテゴリが出るようにしました。 2026-09-29 15:11:35 +09:00
s-choi
65b4a9e54a [EDIT] コース削除機能を追加しました。 2026-09-29 15:09:08 +09:00
s-choi
515c789399 [EDIT] コースの情報を配分入力画面でも渡されるようにしました。 2026-09-29 15:08:49 +09:00
s-choi
7299ee0d06 [EDIT] 余計な機能を削除しました。 2026-09-29 15:08:16 +09:00
s-choi
fa0bfa7c90 [FIX] 配分まで入力してもらったあと、保存されるように修正しました。コース削除機能を追加しました。 2026-09-29 15:07:58 +09:00
s-choi
a911eaabc5 [EDIT] courseIdによる削除クエリを追加しました。 2026-09-29 15:07:10 +09:00
d27d8afbb3 Merge branch 'k-kobayashi' of https://gitea.it-college.co.jp/2026_09_5H_Spring_KIZAKI/Monegement into n-kawahito 2026-09-29 14:48:01 +09:00
kkazuya
d291306599 [FIX] 取引更新画面のカテゴリ表示不備を修正しました。 2026-09-29 14:47:37 +09:00
04b15c4397 Merge branch 'k-kobayashi' of https://gitea.it-college.co.jp/2026_09_5H_Spring_KIZAKI/Monegement into n-kawahito 2026-09-29 14:38:33 +09:00
kkazuya
5c87473e55 [FIX] 固定費一覧画面の新規登録ボタンの遷移先を修正しました。 2026-09-29 14:35:31 +09:00
e6b1e676a6 [FIX]達成期限が過ぎた場合、未達成として履歴に表示するように設計 2026-09-29 14:18:59 +09:00
b666b32214 [FIX]URLの河川を削除しました。 2026-09-29 13:38:52 +09:00
fd469405bc Merge branch 'k-kobayashi' of https://gitea.it-college.co.jp/2026_09_5H_Spring_KIZAKI/Monegement into n-kawahito 2026-09-29 13:18:23 +09:00
a995a41656 [FIX]デザインの修正 2026-09-29 13:17:44 +09:00
kkazuya
fd1b098e3c [FIX] 取引登録の収支区分の初期値を修正しました。 2026-09-29 13:15:40 +09:00
kkazuya
0b9eff82c5 [EDIT] 二次実装に伴う定数の追加と、AOPのクラスも定数クラスを参照するよう編集しました。 2026-09-29 13:06:31 +09:00
s-choi
52cf2b0a84 Merge branch 'k-kobayashi' of https://gitea.it-college.co.jp/2026_09_5H_Spring_KIZAKI/Monegement into s-choi 2026-09-29 12:53:49 +09:00
150b6287c4 Merge branch 'k-kobayashi' of https://gitea.it-college.co.jp/2026_09_5H_Spring_KIZAKI/Monegement into n-kawahito 2026-09-29 12:53:21 +09:00
kkazuya
000c1fa464 Merge branch 'n-kawahito' of https://gitea.it-college.co.jp/2026_09_5H_Spring_KIZAKI/Monegement into k-kobayashi 2026-09-29 12:45:53 +09:00
kkazuya
81b426b579 Merge branch 's-choi' of https://gitea.it-college.co.jp/2026_09_5H_Spring_KIZAKI/Monegement into k-kobayashi 2026-09-29 12:45:37 +09:00
kkazuya
104fa5e319 [EDIT] SessionKeyWordを追加しました。コントローラ側でそれを参照するよう修正しました。 2026-09-29 12:44:56 +09:00
kkazuya
fb031e5255 [EDIT] 目標名と目標説明入力欄のrequiredを外しました。 2026-09-29 12:42:23 +09:00
kkazuya
cb5d228db4 [EDIT] 収支区分の値について、支出が0、収入が1になっていなかった箇所を修正しました。 2026-09-29 12:40:17 +09:00
438ff59bc2 [FIX]画面デザインの不具合を調整しました。 2026-09-29 11:32:22 +09:00
s-choi
f5c410b352 [FIX] 脱退したらログインできないように修正しました。 2026-09-29 11:31:25 +09:00
kkazuya
18c51d3a65 [FIX] カテゴリー登録の際、カテゴリー名と収支区分の入力を必須にしました。 2026-09-29 11:22:41 +09:00
kkazuya
0162f2f679 [EDIT] コース作成で、配分の合計が100%でないと登録できないように修正しました。 2026-09-29 11:19:37 +09:00
94b526a045 Merge branch 's-choi' of https://gitea.it-college.co.jp/2026_09_5H_Spring_KIZAKI/Monegement into n-kawahito 2026-09-29 11:15:50 +09:00
s-choi
31d80388af [HOTFIX] 開発者ツールエラーのため、ファイルを追加しました。 2026-09-29 11:15:31 +09:00
4a9a1d0898 [FIX]コース選択画面のデザイン修正 2026-09-29 11:13:13 +09:00
759df536a5 Merge branch 's-choi' of https://gitea.it-college.co.jp/2026_09_5H_Spring_KIZAKI/Monegement into n-kawahito 2026-09-29 11:00:07 +09:00
s-choi
bce2d01e48 [HOTFIX] エラー処理を行いました。 2026-09-29 10:59:49 +09:00
s-choi
6ee8a3aa59 [EDIT] エラー処理にセッション破棄を改めて追加しました。 2026-09-29 10:57:28 +09:00
98ebb86673 Merge branch 's-choi' of https://gitea.it-college.co.jp/2026_09_5H_Spring_KIZAKI/Monegement into n-kawahito 2026-09-29 10:55:37 +09:00
s-choi
84e55d7606 [HOTFIX] エラー処理を行いました。 2026-09-29 10:54:33 +09:00
3a825196e1 Merge branch 's-choi' of https://gitea.it-college.co.jp/2026_09_5H_Spring_KIZAKI/Monegement into n-kawahito 2026-09-29 10:22:16 +09:00
s-choi
aad285f9ba [HOTFIX] AOPの例外処理を修正しました。 2026-09-29 10:21:59 +09:00
s-choi
f1e48b02f9 [STYLE] padding-top を調整しました。 2026-09-29 10:03:24 +09:00
718b90cee6 Merge branch 's-choi' of https://gitea.it-college.co.jp/2026_09_5H_Spring_KIZAKI/Monegement into n-kawahito 2026-09-29 10:02:56 +09:00
s-choi
60e0694731 [FIX] 会員登録の段階で目標が登録されるように修正しました。 2026-09-29 09:44:42 +09:00
s-choi
b09fd95c31 [FIX] Default値設定及び必要ないカラムを削除しました。 2026-09-29 09:44:18 +09:00
s-choi
65282cdcb2 [FIX] カラムの文字数を制限しました。 2026-09-29 09:43:45 +09:00
74b7032ffc [FIX]デザインを修正しました 2026-09-28 17:06:13 +09:00
s-choi
0687a1837e [STYLE] 重複コードを削除しました。 2026-09-28 16:40:38 +09:00
s-choi
2a4150c883 [STYLE] 重複コードを削除しました。 2026-09-28 16:37:04 +09:00
s-choi
add6a85c64 Merge branch 'n-kawahito' of https://gitea.it-college.co.jp/2026_09_5H_Spring_KIZAKI/Monegement into s-choi 2026-09-28 16:35:05 +09:00
s-choi
fd74dee965 [FIX] 固定費で登録する際、収支区分が自動で入るように修正しました。 2026-09-28 16:32:02 +09:00
s-choi
7aa8e31bfd [EDIT] プロフィール編集画面の項目を修正しました。(パスワード→生年月日)、ボタンのテキストを変更しました。(確認→確定) 2026-09-28 16:04:31 +09:00
s-choi
e3af89a694 [STYLE] コース一覧の下部の間隔を調整しました。 2026-09-28 16:03:19 +09:00
s-choi
efdaacbb27 [FIX] エラー画面でセッション廃棄されない問題を修正しました。 2026-09-28 15:51:16 +09:00
154e6787d4 [FIX]取引新規登録ボタンを一つにし、デザインを統一しました 2026-09-28 15:37:41 +09:00
75f2f7c8d0 Merge branch 's-choi' of https://gitea.it-college.co.jp/2026_09_5H_Spring_KIZAKI/Monegement into n-kawahito 2026-09-28 15:35:54 +09:00
ac101172d2 [EDIT]生年月日の情報取得用コードの追記 2026-09-28 15:35:30 +09:00
s-choi
d7a0aac355 [FIX] 下部の文字が隠れる問題を修正しました。 2026-09-28 15:26:36 +09:00
s-choi
a45045d008 [EDIT] 他人が作成したコースは見えないように修正しました。 2026-09-28 15:23:27 +09:00
s-choi
17074c3132 [ADD] コースの作成者を管理するためのテーブルを追加しました。 2026-09-28 15:22:44 +09:00
s-choi
34172aecc9 [FIX] 目標金額が現在所持金より低かった場合、エラーを表示するように修正しました。 2026-09-28 11:45:23 +09:00
s-choi
e5af64b53b [FIX] 目標登録の画面でボタンのテキストを修正しました。 2026-09-28 11:15:22 +09:00
s-choi
b76be8f38a [FIX] 収支登録の際、収支項目を分けました。金額の最少額は1円に設定しました。 2026-09-28 11:11:28 +09:00
s-choi
47185d8f26 Merge branch 'k-kobayashi' of https://gitea.it-college.co.jp/2026_09_5H_Spring_KIZAKI/Monegement into s-choi 2026-09-28 10:54:05 +09:00
kkazuya
0f800da9a3 [FIX] 誤字を修正しました。 2026-09-28 10:53:41 +09:00
s-choi
546206317d [FIX] エラーメッセージが表示されるように修正しました。 2026-09-28 10:53:07 +09:00
kkazuya
d764da2ebf Merge branch 's-choi' of https://gitea.it-college.co.jp/2026_09_5H_Spring_KIZAKI/Monegement into k-kobayashi 2026-09-28 10:52:52 +09:00
kkazuya
b83f360781 [EDIT] 二次機能の定数部分を、定数クラスを参照するよう修正しました。 2026-09-28 10:52:42 +09:00
kkazuya
42c4d7c273 [EDIT] 二次機能まで含めた定数クラスを作成しました。 2026-09-28 10:51:34 +09:00
kkazuya
cfbf56cf4e [EDIT] HTMLファイル名のハイフンをアンダースコアに変更しました。 2026-09-28 10:51:02 +09:00
s-choi
503ac3f3db [FIX] 新規会員登録画面での生年月日のmax値を今日の日付へ変更しました。新規会員登録画面で一回コースを選択したら、変更できないように修正しました。 2026-09-28 10:45:13 +09:00
s-choi
d5b18ae3ad [FIX] 会員登録の生年月日、今日以降の日付は選べないようにしました。 2026-09-28 10:03:06 +09:00
s-choi
efe93e010d [STYLE] 余計な文章を削除しました。 2026-09-28 10:02:23 +09:00
s-choi
054eeb7f7a 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
#	src/main/java/com/example/demo/app/presentation/controller/GoalController.java
#	src/main/java/com/example/demo/app/presentation/controller/LoginController.java
#	src/main/java/com/example/demo/app/presentation/controller/PasswordResetController.java
#	src/main/java/com/example/demo/app/presentation/controller/TransactionController.java
#	src/main/resources/templates/select_course.html
2026-09-25 17:09:35 +09:00
s-choi
5be30572cb [FIX] ログインの際、DBに保存されているパスワードが平文だったらハッシュ化して再保存するようにデモ用コードを追加しました。 2026-09-25 16:49:09 +09:00
kkazuya
6d0cad2454 [EDIT] パスワードの文字数上限を24文字に変更しました。 2026-09-25 16:44:57 +09:00
s-choi
04a6b6dedb [EDIT] ログインしてないユーザのヘッダーを修正しました。 2026-09-25 16:12:00 +09:00
s-choi
2c445c1904 [FIX] ログインしてるユーザーはパスワード再設定後プロフィール画面に戻るように修正・パスワード再設定の際ハッシュ化処理 2026-09-25 16:09:36 +09:00
s-choi
cd4321ef8c [EDIT] ログインしてるユーザはログインページにアクセスできないように修正しました。 2026-09-25 15:54:57 +09:00
s-choi
65bab96432 [HOTFIX] 目標がない人は目標画面へ遷移できないバグを修正しました。 2026-09-25 15:41:06 +09:00
kkazuya
d911334107 [FIX] 目標名、目標説明が必須になっていたバグを修正、目標金額の最小値を1に変更しました。 2026-09-25 15:35:12 +09:00
kkazuya
b9bf0da507 [HOTFIX] 目標が更新できないバグを修正しました。 2026-09-25 15:22:19 +09:00
s-choi
2b3cecf55d [FIX] 目標がない人はログインできないバグを修正しました。 2026-09-25 15:14:39 +09:00
s-choi
9872405377 [EDIT] 会員登録・ログインにパスワード暗号化機能を追加しました。 2026-09-25 15:14:21 +09:00
s-choi
b9742d87c0 [EDIT] いらないパラメータを削除しました。 2026-09-25 15:13:38 +09:00
s-choi
cdc5ea21c7 [EDIT] パスワード暗号化のための依存性を追加しました。 2026-09-25 15:12:17 +09:00
kkazuya
ff21efa943 [EDIT] 全コントローラに定数を反映させました。 2026-09-25 14:59:27 +09:00
kkazuya
a0ef7145d2 [FIX] 定数クラスの誤字を修正しました。 2026-09-25 14:58:09 +09:00
s-choi
29749c444a [HOTFIX] 目標がなかった場合、ログインできない問題を修正しました。 2026-09-25 14:39:03 +09:00
s-choi
073ee12f03 [STYLE] グラフなどのCSS結合 2026-09-25 14:38:38 +09:00
s-choi
1438c94406 [STYLE] 目標作成画面のCSS結合 2026-09-25 14:38:21 +09:00
s-choi
65290c0189 [STYLE] bodyの間隔を調整しました。 2026-09-25 14:38:00 +09:00
s-choi
e0759c0f6b [FIX] 目標資金・現在高・達成率・達成期限が表示されないバグを修正しました。 2026-09-25 14:14:44 +09:00
s-choi
d526dc2e60 [STYLE] CSSを結合しました。 2026-09-25 13:56:09 +09:00
kkazuya
d7c9346b88 [ADD] TransitionTargetPageNameKeyword.javaを作成しました。 2026-09-25 13:16:52 +09:00
kkazuya
18eeb82cac [ADD] PageReturnAttributeKeyword.javaを作成しました。 2026-09-25 13:16:19 +09:00
kkazuya
b18ee5ee82 [ADD] SessionKeyword.javaを追加しました。 2026-09-25 13:15:43 +09:00
kkazuya
6fda1af754 [EDIT] コース選択画面のデザインを修正しました。 2026-09-25 12:57:44 +09:00
kkazuya
90c5dbe8b2 [EDIT] コーディングルールに反する表記を修正しました。 2026-09-25 12:56:58 +09:00
s-choi
29d879e3b7 Merge branch 's-morimto' of https://gitea.it-college.co.jp/2026_09_5H_Spring_KIZAKI/Monegement into s-choi 2026-09-25 12:52:48 +09:00
s-choi
f33d4412a7 Merge branch 'k-oshita' of https://gitea.it-college.co.jp/2026_09_5H_Spring_KIZAKI/Monegement into s-choi 2026-09-25 12:52:17 +09:00
s-choi
573b7969b7 Merge branch 'k-kobayashi' of https://gitea.it-college.co.jp/2026_09_5H_Spring_KIZAKI/Monegement into s-choi
# Conflicts:
#	src/main/resources/templates/goal_view.html
#	src/main/resources/templates/menu.html
#	src/main/resources/templates/select_course.html
#	src/main/resources/templates/transaction_detail.html
2026-09-25 12:51:53 +09:00
s-choi
29d93d5453 [UPDATE] 2次機能を実装しました。 2026-09-25 12:41:52 +09:00
907b7c1f9b [FIX]登録できない問題の修正をしました 2026-09-24 16:43:46 +09:00
3dba5e5322 [FIX]未ログイン時にヘッダー押下でログイン画面へ遷移するよう修正しました。 2026-09-24 16:02:10 +09:00
kkazuya
1e0cc3a953 [EDIT] 金額入力等の入力制限を追加しました。 2026-09-24 15:57:46 +09:00
kkazuya
67906caf90 [FIX] 取引登録の日付の初期値が表示されない不具合を修正しました 2026-09-24 15:40:09 +09:00
s-choi
95bfd4ed0e [ADD] カテゴリの一覧・作成・修正画面を作成しました。 2026-09-24 15:34:43 +09:00
s-choi
3e6a7f5a74 [EDIT] CategoryのCRUD機能を追加しました。 2026-09-24 15:34:18 +09:00
s-choi
4a574294b7 [EDIT] デフォルトカテゴリ・カスタムカテゴリ両方取得できるように変更しました。 2026-09-24 15:33:37 +09:00
s-choi
b8886fe47b [EDIT] Category一覧への遷移ボタンを追加しました。 2026-09-24 15:32:57 +09:00
s-choi
c44a679213 [EDIT] categoryテーブルにUser・削除フラグを追加しました 2026-09-24 15:32:34 +09:00
kkazuya
0f057bcd36 [EDIT] バランスコースのIDを名前から検索するよう修正しました 2026-09-24 15:25:21 +09:00
s-choi
fb9847a834 Merge branch 'k-kobayashi' of https://gitea.it-college.co.jp/2026_09_5H_Spring_KIZAKI/Monegement into s-choi 2026-09-24 15:24:09 +09:00
d0e14ce2dc [ADD]全画面共通cssファイルを作成しました 2026-09-24 15:18:56 +09:00
ab2bb89d24 [EDIT]スマホ画面のデザインに統一しました 2026-09-24 15:18:15 +09:00
s-choi
58da1fcbfc [ADD] 目標作成画面の追加及び遷移ボタン追加 2026-09-24 14:10:12 +09:00
s-choi
ec862f8271 [FIX] デフォルトで目標達成現状を0に明示化 2026-09-24 14:09:52 +09:00
s-choi
918b7f7218 [EDIT] 目標の一覧を受け取るように修正・作成と削除機能の追加 2026-09-24 14:09:22 +09:00
e0b0109a2b Merge branch 's-choi' of https://gitea.it-college.co.jp/2026_09_5H_Spring_KIZAKI/Monegement into k-oshita 2026-09-24 13:39:17 +09:00
s-choi
76e3fc2345 [FIX] Goalテーブルの変更に合わせてUserメソッドの修正をおこないました。 2026-09-24 13:32:23 +09:00
bcafdbe067 Merge branch 's-choi' of https://gitea.it-college.co.jp/2026_09_5H_Spring_KIZAKI/Monegement into k-oshita 2026-09-24 13:22:18 +09:00
s-choi
e9d3e16157 [EDIT] 変更したテーブルに合わせてメソッドを修正しました。 2026-09-24 13:20:14 +09:00
s-choi
70ad3678a5 [EDIT] Userテーブルを修正しました。 2026-09-24 13:19:53 +09:00
s-choi
b2b290a998 [EDIT] 目標テーブルを修正しました。 2026-09-24 13:19:23 +09:00
s-choi
1debde25f2 [EDIT] menu画面での目標表示を削除しました。 2026-09-24 13:19:04 +09:00
s-choi
714ffba31f [EDIT] ショートカット機能を適用しました。 2026-09-24 12:43:45 +09:00
s-choi
430f456866 [ADD] ショートカット機能のCRDを作成しました。 2026-09-24 12:43:19 +09:00
s-choi
003e03c0c1 [ADD] ショートカットのためのサービスとレポジトリを作成しました。 2026-09-24 12:42:50 +09:00
s-choi
060102d2b1 [ADD] 固定費登録画面を追加しました。 2026-09-24 12:42:22 +09:00
s-choi
f5b88de9e6 [ADD] 固定費一覧画面を追加しました。 2026-09-24 12:42:14 +09:00
s-choi
68bfbc195d [EDIT] 固定費一覧への遷移ボタンを追加しました。 2026-09-24 12:42:02 +09:00
s-choi
11a8fbf665 [ADD] ショートカット機能のためのEntity/Model/Formを追加しました。 2026-09-24 12:41:31 +09:00
3760bf352d Merge branch 'k-kobayashi' of https://gitea.it-college.co.jp/2026_09_5H_Spring_KIZAKI/Monegement into k-oshita 2026-09-24 12:30:04 +09:00
kkazuya
87fbc67a02 Merge branch 'n-kawahito' of https://gitea.it-college.co.jp/2026_09_5H_Spring_KIZAKI/Monegement into k-kobayashi 2026-09-24 11:05:52 +09:00
kkazuya
2139cad2b7 [EDIT] コース変更画面のみフッターが表示されるよう修正しました。 2026-09-24 11:05:26 +09:00
2fcc56b24b Merge branch 's-morimto' of https://gitea.it-college.co.jp/2026_09_5H_Spring_KIZAKI/Monegement into n-kawahito 2026-09-24 11:01:36 +09:00
3b97d1f432 [EDIT]認証画面のフッターの削除 2026-09-24 10:55:03 +09:00
8fa363ad56 Merge branch 'k-kobayashi' of https://gitea.it-college.co.jp/2026_09_5H_Spring_KIZAKI/Monegement into n-kawahito 2026-09-24 10:53:24 +09:00
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
149f9b220c Merge branch 's-morimto' of https://gitea.it-college.co.jp/2026_09_5H_Spring_KIZAKI/Monegement into n-kawahito 2026-09-24 10:47:05 +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
76e91f0bf0 Merge branch 's-choi' of https://gitea.it-college.co.jp/2026_09_5H_Spring_KIZAKI/Monegement into k-oshita 2026-09-24 10:19:55 +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
kkazuya
31a6ce44a4 [EDIT] コース選択機能を修正しました 2026-09-18 16:04:53 +09:00
97 changed files with 5081 additions and 1224 deletions

View File

@@ -83,6 +83,11 @@
<artifactId>spring-boot-starter-webmvc-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mindrot</groupId>
<artifactId>jbcrypt</artifactId>
<version>0.4</version>
</dependency>
</dependencies>
<build>

View File

@@ -10,6 +10,7 @@ import org.aspectj.lang.annotation.Pointcut;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.example.demo.app.presentation.controller.pageproperty.SessionKeyword;
import com.example.demo.exception.NoSessionException;
@@ -32,7 +33,7 @@ public class SessionCheckAspect {
public void checkSession() {
HttpSession session = request.getSession(false);
if (session == null || session.getAttribute("loginUser") == null) {
if (session == null || session.getAttribute(SessionKeyword.LOGIN_USER) == null) {
throw new NoSessionException("不正なログインです");
}

View File

@@ -4,12 +4,16 @@ package com.example.demo.aop.handler;
import java.util.logging.Level;
import java.util.logging.Logger;
import jakarta.servlet.http.HttpSession;
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.app.presentation.controller.pageproperty.PageReturnAttributeKeyword;
import com.example.demo.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword;
import com.example.demo.exception.NoSessionException;
@ControllerAdvice
@@ -28,34 +32,36 @@ public class GlobalExceptionHandler {
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE_ILLEGAL_TRANSITION, e);
model.addAttribute(
"errorMessage",
PageReturnAttributeKeyword.ERROR_MESSAGE,
"システムエラーが発生しました。"
+ "初めからやり直してください。");
return "error";
return TransitionTargetPageNameKeyword.REDIRECT + TransitionTargetPageNameKeyword.LOGIN;
}
@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());
public String handleBadRequestException(Model model, Exception e, HttpSession session) {
model.addAttribute(PageReturnAttributeKeyword.ERROR, SEVERE_ERROR_MESSAGE_BAD_REQUEST);
model.addAttribute(PageReturnAttributeKeyword.STATUS, HttpStatus.BAD_REQUEST.value());
e.printStackTrace();
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE_ILLEGAL_TRANSITION, e);
return "error";
System.out.println("session invalidated");
session.invalidate();
return TransitionTargetPageNameKeyword.ERROR_HTML;
}
@ExceptionHandler(Exception.class)
public String AllException(Model model, Exception e) {
model.addAttribute("error", SEVERE_ERROR_MESSAGE_BAD_REQUEST);
public String AllException(Model model, Exception e, HttpSession session) {
e.printStackTrace();
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE_ILLEGAL_TRANSITION, e);
return "error";
System.out.println("session invalidated exception");
session.invalidate();
return TransitionTargetPageNameKeyword.ERROR_HTML;
}
}

View File

@@ -1,5 +1,12 @@
package com.example.demo.app.domain.model;
import java.util.List;
import com.example.demo.app.infra.entity.AllocationEntity;
import com.example.demo.app.infra.entity.CategoryEntity;
import com.example.demo.app.infra.entity.CourseEntity;
import com.example.demo.app.presentation.form.AllocationForm;
import lombok.AllArgsConstructor;
import lombok.Getter;
@@ -11,4 +18,25 @@ public class AllocationModel {
private Long courseId;
private Integer allocationRatio;
public static AllocationModel convertFrom(AllocationEntity allocationEntity) {
return new AllocationModel(allocationEntity.getCategoryEntity().getCategoryId(), allocationEntity.getCourseEntity().getCourseId(), allocationEntity.getAllocationRatio());
}
public static List<AllocationModel> convertFrom(List<AllocationEntity> allocationEntityList){
return allocationEntityList.stream().map(AllocationModel::convertFrom).toList();
}
public static AllocationModel convertFrom1(AllocationForm allocationForm) {
return new AllocationModel(allocationForm.getCategoryId(), allocationForm.getCourseId(), allocationForm.getAllocationRatio());
}
public static List<AllocationModel> convertFrom1(List<AllocationForm> allocationFormList){
return allocationFormList.stream().map(AllocationModel::convertFrom1).toList();
}
public static AllocationEntity convertTo(CategoryEntity categoryEntity, CourseEntity courseEntity, Integer allocationRatio) {
return new AllocationEntity(categoryEntity, courseEntity, allocationRatio);
}
}

View File

@@ -3,6 +3,7 @@ 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.UserEntity;
import lombok.AllArgsConstructor;
import lombok.Getter;
@@ -27,4 +28,15 @@ public class CategoryModel {
return categoryEntityList.stream().map(CategoryModel::convertFrom).toList();
}
public static CategoryEntity convertTo(CategoryModel categoryModel, UserEntity userEntity) {
return new CategoryEntity(
categoryModel.getCategoryId(),
categoryModel.getCategoryName(),
categoryModel.getTransactionType(),
userEntity,
0,
null,
null);
}
}

View File

@@ -25,4 +25,11 @@ public class CourseModel {
public static List<CourseModel> convertFrom(List<CourseEntity> courseEntityList) {
return courseEntityList.stream().map(CourseModel::convertFrom).toList();
}
public static CourseEntity convertTo(CourseModel courseModel) {
return new CourseEntity(
courseModel.getCourseId(),
courseModel.getCourseName(),
courseModel.getDescription());
}
}

View File

@@ -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<FixedCostModel> convertFrom(List<FixedCostEntity> 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());
}
}

View File

@@ -1,8 +1,11 @@
package com.example.demo.app.domain.model;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
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;
@@ -26,7 +29,13 @@ public class GoalModel {
private Integer achievementRate; // 達成率
public static GoalModel convertFrom(GoalEntity goalEntity) {
private Integer currentAmount; // 現在の資産
private Long userId;
private List<Integer> savingList;
public static GoalModel convertFrom(GoalEntity goalEntity, int achievementRate, int currentAmount) {
return new GoalModel(
goalEntity.getGoalId(),
goalEntity.getGoalTitle(),
@@ -34,18 +43,21 @@ public class GoalModel {
goalEntity.getTargetAmount(),
goalEntity.getDeadline(),
goalEntity.getGoalComplete(),
null);
achievementRate,
currentAmount,
goalEntity.getUserEntity().getUserId(),
new ArrayList<>());
}
public static GoalEntity convertTo(GoalModel goalModel) {
public static GoalEntity convertTo(GoalModel goalModel, UserEntity userEntity) {
return new GoalEntity(
goalModel.getGoalId(),
goalModel.getGoalTitle(),
goalModel.getGoalSubtitle(),
goalModel.getTargetAmount(),
goalModel.getDeadline(),
goalModel.getGoalComplete(),
null);
0,
userEntity);
}
public static GoalModel convertFrom(GoalForm goalForm) {
@@ -56,7 +68,9 @@ public class GoalModel {
goalForm.getTargetAmount(),
goalForm.getDeadline(),
goalForm.getGoalComplete()
,null);
,null,null,
goalForm.getUserId(),
new ArrayList<>());
}
}

View File

@@ -20,7 +20,6 @@ public class UserModel {
private Integer saving;
private Integer annualIncome;
private Integer monthlyBudget;
private Long goalId;
private Long courseId;
private Integer deleteFlag;
@@ -36,7 +35,6 @@ public class UserModel {
userEntity.getSaving(),
userEntity.getAnnualIncome(),
userEntity.getMonthlyBudget(),
userEntity.getGoalEntity().getGoalId(),
userEntity.getCourseEntity().getCourseId(),
userEntity.getDeleteFlag()
);

View File

@@ -13,4 +13,12 @@ public interface CategoryService {
public CategoryModel findOneByCategoryName(String categoryName);
public CategoryModel findByTransactionId(Long transactionId);
public List<CategoryModel> findAllByuserId(Long userId);
public void delete(Long categoryId);
public CategoryModel save(CategoryModel categoryModel, Long userId);
public List<CategoryModel> findAllExceptCustom();
}

View File

@@ -3,9 +3,24 @@ package com.example.demo.app.domain.service;
import java.util.List;
import com.example.demo.app.domain.model.CourseModel;
import com.example.demo.app.presentation.form.AllocationFormList;
public interface CourseService {
public List<CourseModel> findAll();
public CourseModel findById(Long courseId);
public Long findByName(String courName);
public CourseModel save(CourseModel courseModel, Long userId, AllocationFormList allocationFormList);
public List<CourseModel> findAllByUserId(Long userId);
public List<CourseModel> findAllByNull();
public String deleteCourse(Long courseId, Long userId);
}

View File

@@ -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<FixedCostModel> findAllByUserId(Long userId);
public FixedCostModel save(FixedCostModel fixedCostModel);
public void delete(Long fixedCostId);
public FixedCostModel findById(Long fixedCostId);
}

View File

@@ -1,16 +1,24 @@
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<GoalModel> getGoalByUserId(Long userId);
GoalModel createGoal(GoalModel goalModel);
public GoalModel createGoal(GoalModel goalModel, Long userId);
GoalModel updateGoal(GoalModel goalModel);
GoalModel updateGoal(GoalModel goalModel, Long userId);
public void delete(Long goalId);
public void updateGoalComplete(Long userId);
public int getCurrentAmount(Long userId);
// void deleteGoal(Long goalId);

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

@@ -5,7 +5,7 @@ import com.example.demo.app.presentation.form.UserForm;
public interface UserService {
void register(UserForm userForm);
public void register(UserForm userForm, Long courseId);
public void updateCourse(Long userId, Long courseId);

View File

@@ -8,6 +8,8 @@ import com.example.demo.app.domain.model.AllocationModel;
import com.example.demo.app.domain.service.AllocationService;
import com.example.demo.app.infra.entity.AllocationEntity;
import com.example.demo.app.infra.repository.AllocationRepository;
import com.example.demo.app.infra.repository.CategoryRepository;
import com.example.demo.app.infra.repository.CourseRepository;
import lombok.RequiredArgsConstructor;
@@ -15,10 +17,13 @@ import lombok.RequiredArgsConstructor;
@RequiredArgsConstructor
public class AllocationServiceImpl implements AllocationService {
AllocationRepository allocationRepository;
private final AllocationRepository allocationRepository;
private final CategoryRepository categoryRepository;
private final CourseRepository courseRepository;
public List<AllocationModel> findAll(){
public List<AllocationModel> findAll() {
return AllocationEntity.createAllocationModelList(allocationRepository.findAll());
}
}

View File

@@ -9,6 +9,7 @@ import com.example.demo.app.domain.model.CategoryModel;
import com.example.demo.app.domain.service.CategoryService;
import com.example.demo.app.infra.entity.CategoryEntity;
import com.example.demo.app.infra.repository.CategoryRepository;
import com.example.demo.app.infra.repository.UserRepository;
import lombok.RequiredArgsConstructor;
@@ -17,6 +18,7 @@ import lombok.RequiredArgsConstructor;
public class CategoryServiceImpl implements CategoryService {
private final CategoryRepository categoryRepository;
private final UserRepository userRepository;
public List<CategoryModel> findAll() {
@@ -52,5 +54,29 @@ public class CategoryServiceImpl implements CategoryService {
return CategoryModel.convertFrom(categoryRepository.findByTransactionId(transactionId));
}
public List<CategoryModel> findAllByuserId(Long userId) {
return CategoryModel.convertFrom(categoryRepository.findByUserId(userId));
}
public void delete(Long categoryId) {
categoryRepository.deleteById(categoryId);
}
public CategoryModel save(CategoryModel categoryModel, Long userId) {
return CategoryModel.convertFrom(
categoryRepository.save(CategoryModel.convertTo(categoryModel, userRepository.findById(userId).get())));
}
public List<CategoryModel> findAllExceptCustom() {
return CategoryModel.convertFrom(categoryRepository.findAllExceptCustom());
}
}

View File

@@ -1,13 +1,25 @@
package com.example.demo.app.domain.service.impl;
import java.util.ArrayList;
import java.util.List;
import jakarta.transaction.Transactional;
import org.springframework.stereotype.Service;
import com.example.demo.app.domain.model.AllocationModel;
import com.example.demo.app.domain.model.CourseModel;
import com.example.demo.app.domain.service.CourseService;
import com.example.demo.app.infra.entity.AllocationEntity;
import com.example.demo.app.infra.entity.CourseEntity;
import com.example.demo.app.infra.entity.CourseOwnerEntity;
import com.example.demo.app.infra.entity.UserEntity;
import com.example.demo.app.infra.repository.AllocationRepository;
import com.example.demo.app.infra.repository.CategoryRepository;
import com.example.demo.app.infra.repository.CourseOwnerRepository;
import com.example.demo.app.infra.repository.CourseRepository;
import com.example.demo.app.infra.repository.UserRepository;
import com.example.demo.app.presentation.form.AllocationFormList;
import lombok.RequiredArgsConstructor;
@@ -15,10 +27,121 @@ import lombok.RequiredArgsConstructor;
@RequiredArgsConstructor
public class CourseServiceImpl implements CourseService {
private final CourseRepository courseRepository;
private final AllocationRepository allocationRepository;
public List<CourseModel> findAll(){
private final CourseRepository courseRepository;
private final UserRepository userRepository;
private final CourseOwnerRepository courseOwnerRepository;
private final CategoryRepository categoryRepository;
public List<CourseModel> findAll() {
return CourseEntity.createCourseModelList(courseRepository.findAll());
}
public List<CourseModel> findAllByUserId(Long userId) {
return CourseModel.convertFrom(courseRepository.findAllByUserId(userId));
}
public List<CourseModel> findAllByNull() {
return CourseModel.convertFrom(courseRepository.findAllByNull());
}
public CourseModel findById(Long courseId) {
return CourseModel.convertFrom(courseRepository.findByCourseId(courseId));
}
public Long findByName(String courseName) {
return courseRepository.findByCourseName(courseName).getCourseId();
}
@Transactional
public CourseModel save(CourseModel courseModel, Long userId, AllocationFormList allocationFormList) {
List<UserEntity> userEntityList = new ArrayList<>();
userEntityList.add(userRepository.findById(userId).get());
CourseEntity result = courseRepository.save(CourseModel.convertTo(courseModel));
List<AllocationModel> allocationModelList = new ArrayList<>();
allocationModelList.add(new AllocationModel(allocationFormList.getCategoryId4(),
result.getCourseId(),
allocationFormList.getAllocationRatio4()));
allocationModelList.add(new AllocationModel(allocationFormList.getCategoryId5(),
result.getCourseId(),
allocationFormList.getAllocationRatio5()));
allocationModelList.add(new AllocationModel(allocationFormList.getCategoryId6(),
result.getCourseId(),
allocationFormList.getAllocationRatio6()));
allocationModelList.add(new AllocationModel(allocationFormList.getCategoryId7(),
result.getCourseId(),
allocationFormList.getAllocationRatio7()));
allocationModelList.add(new AllocationModel(allocationFormList.getCategoryId8(),
result.getCourseId(),
allocationFormList.getAllocationRatio8()));
allocationModelList.add(new AllocationModel(allocationFormList.getCategoryId9(),
result.getCourseId(),
allocationFormList.getAllocationRatio9()));
allocationModelList.add(new AllocationModel(allocationFormList.getCategoryId10(),
result.getCourseId(),
allocationFormList.getAllocationRatio10()));
allocationModelList.add(new AllocationModel(allocationFormList.getCategoryId11(),
result.getCourseId(),
allocationFormList.getAllocationRatio11()));
allocationModelList.stream().forEach(allocation -> {
System.out.println(allocation.getCourseId());
});
UserEntity user = userRepository.findById(userId).orElse(null);
user.setCourseEntity(result);
UserEntity userResult = userRepository.save(user);
CourseOwnerEntity courseOwnerEntity = new CourseOwnerEntity();
courseOwnerEntity.setUserEntity(userResult);
courseOwnerEntity.setCourseEntity(result);
courseOwnerRepository.save(courseOwnerEntity);
List<AllocationEntity> allocationEntityList = new ArrayList<>();
allocationModelList.forEach(allocationModel -> {
allocationEntityList.add(
AllocationModel.convertTo(
categoryRepository.findById(allocationModel.getCategoryId()).get(),
courseRepository.findById(allocationModel.getCourseId()).get(),
allocationModel.getAllocationRatio()));
});
List<AllocationModel> resultList = new ArrayList<>();
for (AllocationEntity allocationEntity : allocationEntityList) {
resultList.add(AllocationModel.convertFrom(allocationRepository.save(allocationEntity)));
}
return CourseModel.convertFrom(result);
}
@Transactional
public String deleteCourse(Long courseId, Long userId) {
UserEntity userEntity = userRepository.findById(userId).orElse(null);
System.out.println("***********************ここでエラー1");
if (userEntity.getCourseEntity().getCourseId() == courseId) {
return "selected";
}
System.out.println("***********************ここでエラー2");
allocationRepository.deleteByCourseId(courseId);
System.out.println("***********************ここでエラー3");
courseOwnerRepository.deleteByCourseId(courseId);
System.out.println("***********************ここでエラー4");
courseRepository.deleteById(courseId);
System.out.println("***********************ここでエラー5");
return "ok";
}
}

View File

@@ -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<FixedCostModel> 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());
}
}

View File

@@ -1,5 +1,10 @@
package com.example.demo.app.domain.service.impl;
import java.util.ArrayList;
import java.util.List;
import jakarta.transaction.Transactional;
import org.springframework.stereotype.Service;
import com.example.demo.app.domain.model.GoalModel;
@@ -7,6 +12,7 @@ import com.example.demo.app.domain.service.GoalService;
import com.example.demo.app.infra.entity.GoalEntity;
import com.example.demo.app.infra.entity.UserEntity;
import com.example.demo.app.infra.repository.GoalRepository;
import com.example.demo.app.infra.repository.TransactionRepository;
import com.example.demo.app.infra.repository.UserRepository;
import lombok.RequiredArgsConstructor;
@@ -17,18 +23,19 @@ public class GoalServiceImpl implements GoalService {
private final GoalRepository goalRepository;
private final UserRepository userRepository;
private final TransactionRepository transactionRepository;
@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<GoalModel> getGoalByUserId(Long userId) {
UserEntity userEntity = userRepository.findById(userId).orElseThrow();
GoalEntity goalEntity = userEntity.getGoalEntity();
List<GoalEntity> goalEntityList = goalRepository.findAllByUserId(userId);
// 収支の合計を計算(収入はプラス、支出はマイナス)
int transactionTotal = userEntity.getTransactionEntityList().stream()
@@ -42,41 +49,95 @@ 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<GoalModel> goalModelList = new ArrayList<GoalModel>();
return new GoalModel(
goalModel.getGoalId(),
goalModel.getGoalTitle(),
goalModel.getGoalSubtitle(),
goalModel.getTargetAmount(),
goalModel.getDeadline(),
goalModel.getGoalComplete(),
achievementRate);
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) {
public GoalModel createGoal(GoalModel goalModel, Long userId) {
GoalEntity goalEntity = GoalModel.convertTo(goalModel);
UserEntity userEntity = userRepository.findById(userId).orElseThrow();
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;
if (currentAmount >= goalModel.getTargetAmount()) {
return null;
}
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);
}
public void delete(Long goalId) {
goalRepository.deleteById(goalId);
}
@Transactional
public void updateGoalComplete(Long userId) {
UserEntity userEntity = userRepository.findById(userId).orElseThrow();
List<GoalEntity> goalEntityList = goalRepository.findAllByUserId(userId);
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;
goalEntityList.stream().forEach(goalEntity -> {
if (goalEntity.getTargetAmount() <= currentAmount) {
goalRepository.updateCompleteByGoalId(goalEntity.getGoalId());
}
});
}
public int getCurrentAmount(Long userId) {
UserEntity userEntity = userRepository.findById(userId).orElseThrow();
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;
return currentAmount;
}
}

View File

@@ -1,5 +1,6 @@
package com.example.demo.app.domain.service.impl;
import org.mindrot.jbcrypt.BCrypt;
import org.springframework.stereotype.Service;
import com.example.demo.app.domain.model.LoginModel;
@@ -13,19 +14,43 @@ import lombok.RequiredArgsConstructor;
@RequiredArgsConstructor
public class LoginServiceImpl implements LoginService {
private final UserRepository userRepository;
private final UserRepository userRepository;
@Override
public LoginModel login(String mailAddress, String password) {
@Override
public LoginModel login(String mailAddress, String password) {
UserEntity userEntity = userRepository.findByMailAddressAndPassword(
mailAddress,
password).orElse(null);
UserEntity userEntity = userRepository
.findByMailAddress(mailAddress)
.orElse(null);
if (userEntity == null) {
return null;
}
if (userEntity == null) {
return null;
} else if (userEntity.getDeleteFlag() == 1) {
return null;
}
boolean isValidPassword = false;
if (userEntity.getPassword().length() <= 24) {
if (userEntity.getPassword().equals(password)) {
userEntity.setPassword(BCrypt.hashpw(password, BCrypt.gensalt()));
userRepository.save(userEntity);
isValidPassword = true;
} else {
return null;
}
} else {
isValidPassword = BCrypt.checkpw(password, userEntity.getPassword());
}
if (!isValidPassword) {
return null;
}
return new LoginModel(userEntity.getUserId());
}
return new LoginModel(userEntity.getUserId());
}
}

View File

@@ -1,5 +1,6 @@
package com.example.demo.app.domain.service.impl;
import org.mindrot.jbcrypt.BCrypt;
import org.springframework.stereotype.Service;
import com.example.demo.app.domain.service.PasswordResetService;
@@ -13,30 +14,31 @@ import lombok.RequiredArgsConstructor;
@RequiredArgsConstructor
public class PasswordResetServiceImpl implements PasswordResetService {
private final UserRepository userRepository;
private final UserRepository userRepository;
@Override
public boolean resetPassword(
Long userId,
PasswordResetForm passwordResetForm) {
@Override
public boolean resetPassword(
Long userId,
PasswordResetForm passwordResetForm) {
if (!passwordResetForm.getPassword()
.equals(passwordResetForm.getPasswordConfirm())) {
return false;
}
if (!passwordResetForm.getPassword()
.equals(passwordResetForm.getPasswordConfirm())) {
return false;
}
UserEntity userEntity =
userRepository.findById(userId).orElse(null);
UserEntity userEntity = userRepository.findById(userId).orElse(null);
if (userEntity == null) {
return false;
}
if (userEntity == null) {
return false;
}
userEntity.setPassword(
passwordResetForm.getPassword());
String passwordHashed = BCrypt.hashpw(passwordResetForm.getPassword(), BCrypt.gensalt());
userRepository.save(userEntity);
userEntity.setPassword(
passwordHashed);
return true;
}
userRepository.save(userEntity);
return true;
}
}

View File

@@ -58,6 +58,7 @@ public class ProfileServiceImpl implements ProfileService{
userEntity.setSaving(profileEditForm.getSaving());
userEntity.setAnnualIncome(profileEditForm.getAnnualIncome());
userEntity.setMonthlyBudget(profileEditForm.getMonthlyBudget());
userEntity.setBirthDate(profileEditForm.getBirthDate());
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

@@ -1,5 +1,6 @@
package com.example.demo.app.domain.service.impl;
import org.mindrot.jbcrypt.BCrypt;
import org.springframework.stereotype.Service;
import com.example.demo.app.domain.model.UserModel;
@@ -16,7 +17,6 @@ import com.example.demo.app.presentation.form.UserForm;
import lombok.RequiredArgsConstructor;
@Service
@RequiredArgsConstructor
public class UserServiceImpl implements UserService {
@@ -26,37 +26,40 @@ 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();
UserEntity userEntity = new UserEntity();
userEntity.setUserName(userForm.getUserName());
userEntity.setMailAddress(userForm.getMailAddress());
userEntity.setPassword(userForm.getPassword());
userEntity.setSecretQuestionAnswer(userForm.getSecretAnswer());
userEntity.setBirthDate(userForm.getBirthDate());
userEntity.setSaving(userForm.getSaving());
userEntity.setBirthDate(userForm. getBirthDate());
userEntity.setSaving(userForm.getSaving());
userEntity.setAnnualIncome(userForm.getAnnualIncome());
userEntity.setMonthlyBudget(userForm.getMonthlyBudget());
userEntity.setUserName(userForm.getUserName());
userEntity.setMailAddress(userForm.getMailAddress());
QuestionEntity questionEntity =
questionRepository.findById(userForm.getSecretQuestionId()).orElse(null);
String passwordHashed = BCrypt.hashpw(userForm.getPassword(), BCrypt.gensalt());
GoalEntity goalEntity =
goalRepository.findById(userForm.getGoalId()).orElse(null);
userEntity.setPassword(passwordHashed);
userEntity.setSecretQuestionAnswer(userForm.getSecretAnswer());
userEntity.setBirthDate(userForm.getBirthDate());
userEntity.setSaving(userForm.getSaving());
userEntity.setBirthDate(userForm.getBirthDate());
userEntity.setSaving(userForm.getSaving());
userEntity.setAnnualIncome(userForm.getAnnualIncome());
userEntity.setMonthlyBudget(userForm.getMonthlyBudget());
CourseEntity courseEntity =
courseRepository.findById(userForm.getCourseId()).orElse(null);
QuestionEntity questionEntity = questionRepository.findById(userForm.getSecretQuestionId()).orElse(null);
userEntity.setQuestionEntity(questionEntity);
userEntity.setGoalEntity(goalEntity);
userEntity.setCourseEntity(courseEntity);
GoalEntity goalEntity = new GoalEntity();
goalEntity.setTargetAmount(Integer.parseInt(String.valueOf(userForm.getGoalId())));
userEntity.setDeleteFlag(0);
CourseEntity courseEntity = courseRepository.findById(courseId).orElse(null);
userRepository.save(userEntity);
userEntity.setQuestionEntity(questionEntity);
userEntity.setCourseEntity(courseEntity);
userEntity.setDeleteFlag(0);
goalEntity.setUserEntity(userRepository.save(userEntity));
goalRepository.save(goalEntity);
}
@Override
@@ -70,12 +73,8 @@ public class UserServiceImpl implements UserService {
userRepository.save(userEntity);
}
public UserModel findByUserId(Long userId) {
return UserModel.convertFrom(userRepository.findById(userId).get());
}
}

View File

@@ -4,9 +4,12 @@ import java.util.List;
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.OneToMany;
import jakarta.persistence.Table;
@@ -26,12 +29,19 @@ public class CategoryEntity {
@Column(name = "category_id")
private Long categoryId;
@Column(name = "category_name", nullable = false)
@Column(name = "category_name", nullable = false, length = 50)
private String categoryName;
@Column(name = "transaction_type", nullable = false)
private Integer transactionType;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "user_id")
private UserEntity userEntity;
@Column(name = "delete_flag")
private Integer deleteFlag;
@OneToMany(mappedBy = "categoryEntity")
private List<TransactionEntity> transactionEntity;

View File

@@ -7,7 +7,6 @@ import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.OneToMany;
import jakarta.persistence.Table;
import com.example.demo.app.domain.model.CourseModel;
@@ -28,16 +27,13 @@ public class CourseEntity {
@Column(name = "course_id")
private Long courseId;
@Column(name = "course_name", nullable = false)
@Column(name = "course_name", nullable = false, length = 50)
private String courseName;
@Column(name = "description", nullable = false)
private String description;
@OneToMany(mappedBy = "courseEntity")
private List<UserEntity> userEntity;
public static List<CourseModel> createCourseModelList(List<CourseEntity> courseEntityList) {
return courseEntityList

View File

@@ -0,0 +1,37 @@
package com.example.demo.app.infra.entity;
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.OneToOne;
import jakarta.persistence.Table;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Entity
@Table(name = "course_owner_t")
@Data
@NoArgsConstructor
@AllArgsConstructor
public class CourseOwnerEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long courseOwnerId;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "user_id")
private UserEntity userEntity;
@OneToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "course_id")
private CourseEntity courseEntity;
}

View File

@@ -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, length = 50)
private String fixedCostName;
@Column(name = "amount", nullable = false)
private Integer amount;
}

View File

@@ -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;
@@ -27,21 +29,22 @@ public class GoalEntity {
private Long goalId;
@Column(name = "goal_title", nullable = true)
private String goalTitle;
private String goalTitle = "名前を設定してください";
@Column(name = "goal_subtitle", nullable = true)
private String goalSubtitle;
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")
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "user_id")
private UserEntity userEntity;
}

View File

@@ -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;
@@ -31,7 +30,7 @@ public class UserEntity {
@Column(name = "user_id")
private Long userId;
@Column(name = "user_name", nullable = false)
@Column(name = "user_name", nullable = false, length = 100)
private String userName;
@Column(name = "mail_address", nullable = false)
@@ -40,7 +39,7 @@ public class UserEntity {
@Column(name = "password", nullable = false)
private String password;
@Column(name = "secret_answer", nullable = false)
@Column(name = "secret_answer", nullable = false, length = 100)
private String secretQuestionAnswer;
@Column(name = "birth_date", nullable = false)
@@ -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<GoalEntity> goalEntityList;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "course_id")

View File

@@ -3,6 +3,7 @@ package com.example.demo.app.infra.repository;
import java.util.List;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import com.example.demo.app.domain.model.CourseInfoModel;
@@ -29,4 +30,8 @@ public interface AllocationRepository extends JpaRepository<AllocationEntity, Al
+ " a.categoryEntity.categoryId ASC ")
List<CourseInfoModel> findAllJoinedAllocation();
@Modifying
@Query("delete from AllocationEntity a where a.courseEntity.courseId = :courseId")
void deleteByCourseId(Long courseId);
}

View File

@@ -1,5 +1,7 @@
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.data.repository.query.Param;
@@ -15,4 +17,10 @@ public interface CategoryRepository extends JpaRepository<CategoryEntity, Long>
@Query("select c from CategoryEntity c inner join TransactionEntity t on c.categoryId = t.categoryEntity.categoryId where t.transactionId = :transactionId")
public CategoryEntity findByTransactionId(Long transactionId);
@Query("select c from CategoryEntity c where c.userEntity.userId = :userId")
public List<CategoryEntity> findByUserId(Long userId);
@Query("select c from CategoryEntity c where c.userEntity.userId is null")
public List<CategoryEntity> findAllExceptCustom();
}

View File

@@ -0,0 +1,15 @@
package com.example.demo.app.infra.repository;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import com.example.demo.app.infra.entity.CourseOwnerEntity;
public interface CourseOwnerRepository extends JpaRepository<CourseOwnerEntity, Long>{
@Modifying
@Query("delete from CourseOwnerEntity c where c.courseEntity.courseId = :courseId")
public void deleteByCourseId(Long courseId);
}

View File

@@ -1,9 +1,24 @@
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.CourseEntity;
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);
@Query("select c from CourseEntity c inner join CourseOwnerEntity o on c.courseId = o.courseEntity.courseId inner join UserEntity u on o.userEntity.userId = u.userId where u.userId = :userId")
public List<CourseEntity> findAllByUserId(Long userId);
@Query("select c from CourseEntity c where c.courseId between 1 and 6")
public List<CourseEntity> findAllByNull();
}

View File

@@ -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<FixedCostEntity, Long> {
@Query("select f from FixedCostEntity f where f.userEntity.userId = :userId")
public List<FixedCostEntity> findByUserId(Long userId);
}

View File

@@ -1,6 +1,10 @@
package com.example.demo.app.infra.repository;
import java.util.List;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import com.example.demo.app.infra.entity.GoalEntity;
@@ -8,4 +12,11 @@ import com.example.demo.app.infra.entity.GoalEntity;
@Repository
public interface GoalRepository extends JpaRepository<GoalEntity, Long> {
@Query("select g from GoalEntity g where g.userEntity.userId = :userId")
public List<GoalEntity> findAllByUserId(Long userId);
@Modifying(clearAutomatically = true, flushAutomatically = true)
@Query("update GoalEntity g set g.goalComplete = 1 where g.goalId = :goalId")
public int updateCompleteByGoalId(Long goalId);
}

View File

@@ -9,9 +9,13 @@ 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;
import com.example.demo.app.presentation.controller.pageproperty.PageReturnAttributeKeyword;
import com.example.demo.app.presentation.controller.pageproperty.SessionKeyword;
import com.example.demo.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword;
import com.example.demo.app.presentation.form.AnalysisForm;
import lombok.RequiredArgsConstructor;
@@ -23,7 +27,8 @@ public class AnalysisController {
private final AnalysisService analysisService;
@GetMapping("/analysis")
@SessionCheck
@GetMapping(TransitionTargetPageNameKeyword.ANALYSIS)
public String showAnalysis(
@RequestParam(required = false) Integer year,
@RequestParam(required = false) Integer month,
@@ -31,7 +36,7 @@ public class AnalysisController {
HttpSession session) {
//ログインユーザーの取得(セッション)
LoginModel loginUser = (LoginModel) session.getAttribute("loginUser");
LoginModel loginUser = (LoginModel) session.getAttribute(SessionKeyword.LOGIN_USER);
//初期年月表示
LocalDate nowDate = LocalDate.now();
@@ -56,15 +61,15 @@ public class AnalysisController {
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());
model.addAttribute(PageReturnAttributeKeyword.ANALYSIS_FORM, analysisForm);
model.addAttribute(PageReturnAttributeKeyword.YEAR, year);
model.addAttribute(PageReturnAttributeKeyword.MONTH, month);
model.addAttribute(PageReturnAttributeKeyword.PREVIOUS_YEAR, previousDate.getYear());
model.addAttribute(PageReturnAttributeKeyword.PREVIOUS_MONTH, previousDate.getMonthValue());
model.addAttribute(PageReturnAttributeKeyword.NEXT_YEAR, nextDate.getYear());
model.addAttribute(PageReturnAttributeKeyword.NEXT_MONTH, nextDate.getMonthValue());
return "analysis";
return TransitionTargetPageNameKeyword.ANALYSIS_HTML;
}
}

View File

@@ -10,7 +10,10 @@ import org.springframework.web.bind.annotation.PostMapping;
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.controller.pageproperty.PageReturnAttributeKeyword;
import com.example.demo.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword;
import com.example.demo.app.presentation.form.AuthenticationForm;
import com.example.demo.app.presentation.form.PasswordResetForm;
import lombok.RequiredArgsConstructor;
@@ -21,16 +24,16 @@ public class AuthenticationController {
private final AuthenticationService authenticationService;
private final QuestionRepository questionRepository;
@GetMapping("/authentication")
@GetMapping(TransitionTargetPageNameKeyword.AUTHENTICATION)
public String showAuthentication(Model model) {
model.addAttribute("authenticationForm", new AuthenticationForm());
model.addAttribute("questionList", questionRepository.findAll());
model.addAttribute(PageReturnAttributeKeyword.AUTHENTICATION_FORM, new AuthenticationForm());
model.addAttribute(PageReturnAttributeKeyword.QUESTION_LIST, questionRepository.findAll());
return "authentication";
return TransitionTargetPageNameKeyword.AUTHENTICATION_HTML;
}
@PostMapping("/authentication")
@PostMapping(TransitionTargetPageNameKeyword.AUTHENTICATION)
public String authenticate(
AuthenticationForm authenticationForm,
Model model,
@@ -40,17 +43,21 @@ public class AuthenticationController {
authenticationService.authenticate(authenticationForm);
if (authenticationModel == null) {
model.addAttribute("errorMessage", "認証情報が正しくありません。");
model.addAttribute("questionList", questionRepository.findAll());
model.addAttribute(PageReturnAttributeKeyword.ERROR_MESSAGE, "認証情報が正しくありません。");
model.addAttribute(PageReturnAttributeKeyword.QUESTION_LIST, questionRepository.findAll());
return "authentication";
return TransitionTargetPageNameKeyword.AUTHENTICATION_HTML;
}
session.setAttribute(
"passwordResetUserId",
PageReturnAttributeKeyword.PASSWOR_RESET_USER_ID,
authenticationModel.getUserId());
return "password_reset";
model.addAttribute(
PageReturnAttributeKeyword.PASSWOR_RESET_FORM,
new PasswordResetForm());
return TransitionTargetPageNameKeyword.PASSWORD_RESET_HTML;
}
}

View File

@@ -0,0 +1,90 @@
package com.example.demo.app.presentation.controller;
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.app.domain.model.LoginModel;
import com.example.demo.app.domain.service.CategoryService;
import com.example.demo.app.presentation.controller.pageproperty.PageReturnAttributeKeyword;
import com.example.demo.app.presentation.controller.pageproperty.SessionKeyword;
import com.example.demo.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword;
import com.example.demo.app.presentation.form.CategoryForm;
import lombok.RequiredArgsConstructor;
@Controller
@RequiredArgsConstructor
public class CategoryController {
private final CategoryService categoryService;
@GetMapping(TransitionTargetPageNameKeyword.CATEGORY_LIST)
public String categoryListGet(Model model, HttpSession session) {
LoginModel loginUser = (LoginModel) session.getAttribute(SessionKeyword.LOGIN_USER);
List<CategoryForm> categoryFormList = CategoryForm.convertFrom(categoryService.findAllByuserId(loginUser.getUserId()));
model.addAttribute(PageReturnAttributeKeyword.CATEGORY_FORM_LIST, categoryFormList);
return TransitionTargetPageNameKeyword.CATEGORY_LIST_HTML;
}
@GetMapping(TransitionTargetPageNameKeyword.CATEGORY_CREATE)
public String categoryCreateGet(@ModelAttribute CategoryForm categoryForm) {
return TransitionTargetPageNameKeyword.CATEGORY_CREATE_HTML;
}
@PostMapping(TransitionTargetPageNameKeyword.CATEGORY_CREATE)
public String categoryCreatePost(@ModelAttribute CategoryForm categoryForm, HttpSession session) {
LoginModel loginUser = (LoginModel) session.getAttribute(SessionKeyword.LOGIN_USER);
categoryService.save(CategoryForm.convertTo(categoryForm), loginUser.getUserId());
return TransitionTargetPageNameKeyword.REDIRECT + TransitionTargetPageNameKeyword.CATEGORY_LIST;
}
@GetMapping(TransitionTargetPageNameKeyword.CATEGORY_UPDATE)
public String categoryUpdateGet(Model model, Long categoryId) {
CategoryForm categoryForm = CategoryForm.convertFrom(categoryService.findOne(categoryId));
model.addAttribute(PageReturnAttributeKeyword.CATEGORY_ID, categoryId);
model.addAttribute(PageReturnAttributeKeyword.CATEGORY_FORM, categoryForm);
return TransitionTargetPageNameKeyword.CATEGORY_UPDATE_HTML;
}
@PostMapping(TransitionTargetPageNameKeyword.CATEGORY_UPDATE)
public String categoryUpdatePost(@ModelAttribute CategoryForm categoryForm, HttpSession session, Long categoryId) {
LoginModel loginUser = (LoginModel) session.getAttribute(SessionKeyword.LOGIN_USER);
categoryForm.setCategoryId(categoryId);
categoryService.save(CategoryForm.convertTo(categoryForm), loginUser.getUserId());
return TransitionTargetPageNameKeyword.REDIRECT + TransitionTargetPageNameKeyword.CATEGORY_LIST;
}
@PostMapping(TransitionTargetPageNameKeyword.CATEGORY_DELETE)
public String categoryDeletePost(Long categoryId) {
categoryService.delete(categoryId);
return TransitionTargetPageNameKeyword.REDIRECT + TransitionTargetPageNameKeyword.CATEGORY_LIST;
}
}

View File

@@ -1,101 +1,153 @@
package com.example.demo.app.presentation.controller;
import java.util.logging.Level;
import java.util.logging.Logger;
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 org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import com.example.demo.aop.aspect.SessionCheck;
import com.example.demo.app.domain.model.CourseModel;
import com.example.demo.app.domain.model.LoginModel;
import com.example.demo.app.domain.model.UserModel;
import com.example.demo.app.domain.service.AllocationService;
import com.example.demo.app.domain.service.CourseInfoService;
import com.example.demo.app.domain.service.CourseService;
import com.example.demo.app.domain.service.UserService;
import com.example.demo.app.presentation.controller.pageproperty.PageReturnAttributeKeyword;
import com.example.demo.app.presentation.controller.pageproperty.SessionKeyword;
import com.example.demo.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword;
import com.example.demo.app.presentation.form.AllocationFormList;
import com.example.demo.app.presentation.form.CourseForm;
import com.example.demo.app.presentation.form.CourseInfoForm;
import com.example.demo.app.presentation.form.UserForm;
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 CourseService courseService;
private final CourseInfoService courseInfoService;
private final UserService userService;
private final AllocationService allocationService;
private final HttpSession httpSession;
private final CourseService courseService;
private final CourseInfoService courseInfoService;
private final UserService userService;
@PostMapping(TransitionTargetPageNameKeyword.SHOW_SELECT_COURSE)
public String showSelectCourse(@ModelAttribute UserForm userForm, Model model, HttpSession session) {
final String MODE = "regist";
final String DEFAULT = "バランスコース";
session.setAttribute(PageReturnAttributeKeyword.USER_FORM, userForm);
model.addAttribute(PageReturnAttributeKeyword.MODE, MODE);
model.addAttribute(PageReturnAttributeKeyword.CURRENT_COURSE_ID, courseService.findByName(DEFAULT));
@PostMapping("/select/register")
public String showSelectCourse(@ModelAttribute UserModel userModel, Model model) {
model.addAttribute(PageReturnAttributeKeyword.COURSE_LIST,
CourseForm.convertFrom(courseService.findAllByNull()));
model.addAttribute(PageReturnAttributeKeyword.COURSE_INFO_LIST,
CourseInfoForm.convertFrom(courseInfoService.findAll()));
try {
return TransitionTargetPageNameKeyword.SELECT_COURSE_HTML;
model.addAttribute("mode", "select");
model.addAttribute("courseList", CourseForm.convertFrom(courseService.findAll()));
model.addAttribute("courseInfoList", CourseInfoForm.convertFrom(courseInfoService.findAll()));
}
return "select_course";
@SessionCheck
@GetMapping(TransitionTargetPageNameKeyword.COURSE)
public String showChangeCourse(Model model, HttpSession session) {
} catch (Exception e) {
// ログイン情報の破棄
httpSession.invalidate();
final String MODE = "change";
e.printStackTrace();
LoginModel loginUser = (LoginModel) session.getAttribute(SessionKeyword.LOGIN_USER);
Long userId = loginUser.getUserId();
// エラーログ出力
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e);
// エラー画面遷移
return null;
}
}
Long currentCourseId = userService.findByUserId(userId).getCourseId();
@PostMapping("/select/change")
public String showChangeCourse(Model model) {
List<CourseModel> courseModelList = new ArrayList<>(courseService.findAllByNull());
try {
List<CourseModel> tempList = courseService.findAllByUserId(userId);
model.addAttribute("mode", "change");
model.addAttribute("courseList", CourseForm.convertFrom(courseService.findAll()));
model.addAttribute("courseInfoList", CourseInfoForm.convertFrom(courseInfoService.findAll()));
tempList.forEach(courseModelList::add);
return "select_course";
model.addAttribute(PageReturnAttributeKeyword.MODE, MODE);
model.addAttribute(PageReturnAttributeKeyword.CURRENT_COURSE_ID, currentCourseId);
model.addAttribute(PageReturnAttributeKeyword.COURSE_LIST, CourseForm.convertFrom(courseModelList));
model.addAttribute(PageReturnAttributeKeyword.COURSE_INFO_LIST,
CourseInfoForm.convertFrom(courseInfoService.findAll()));
} catch (Exception e) {
// ログイン情報の破棄
httpSession.invalidate();
return TransitionTargetPageNameKeyword.SELECT_COURSE_HTML;
e.printStackTrace();
}
// エラーログ出力
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e);
// エラー画面遷移
return null;
}
}
@SessionCheck
@PostMapping(TransitionTargetPageNameKeyword.CHANGE)
public String changeCourse(@RequestParam Long courseId, HttpSession httpSession) {
@PostMapping("/change")
public String changeCourse(@RequestParam Long courseId) {
LoginModel loginUser = (LoginModel) httpSession.getAttribute(SessionKeyword.LOGIN_USER);
LoginModel loginUser = (LoginModel) httpSession.getAttribute("loginUser");
userService.updateCourse(loginUser.getUserId(), courseId);
userService.updateCourse(loginUser.getUserId(), courseId);
return TransitionTargetPageNameKeyword.REDIRECT + TransitionTargetPageNameKeyword.MENU;
}
return "redirect:/menu";
}
@SessionCheck
@GetMapping(TransitionTargetPageNameKeyword.COURSE_CREATE)
public String createCourseGet(@ModelAttribute CourseForm courseForm, HttpSession session) {
return TransitionTargetPageNameKeyword.COURSE_CREATE_HTML;
}
@SessionCheck
@PostMapping(TransitionTargetPageNameKeyword.COURSE_CREATE_RATIO)
public String createCourse(@ModelAttribute CourseForm courseForm,
@ModelAttribute AllocationFormList allocationFormList,
HttpSession session, Model model) {
LoginModel loginUser = (LoginModel) session.getAttribute(SessionKeyword.LOGIN_USER);
model.addAttribute("courseForm", courseForm);
return TransitionTargetPageNameKeyword.COURSE_CREATE_RATIO_HTML;
}
@SessionCheck
@PostMapping(TransitionTargetPageNameKeyword.COURSE_CREATE)
public String createCoursePost(@ModelAttribute CourseForm courseForm,
@ModelAttribute AllocationFormList allocationFormList, HttpSession session) {
LoginModel loginUser = (LoginModel) session.getAttribute(SessionKeyword.LOGIN_USER);
courseService.save(CourseForm.convertTo(courseForm), loginUser.getUserId(), allocationFormList);
return TransitionTargetPageNameKeyword.REDIRECT + TransitionTargetPageNameKeyword.COURSE;
}
@SessionCheck
@PostMapping("/course/delete")
public String createCoursePost(@RequestParam Long courseId, HttpSession session, Model model) {
LoginModel loginUser = (LoginModel) session.getAttribute(SessionKeyword.LOGIN_USER);
System.out.println("**********************cousrId: " + courseId);
String condition = courseService.deleteCourse(courseId, loginUser.getUserId());
if (condition.equals("selected")) {
model.addAttribute("message", "適用中のコースは選べません");
return TransitionTargetPageNameKeyword.REDIRECT + TransitionTargetPageNameKeyword.COURSE;
} else if (condition.equals("ok")) {
return TransitionTargetPageNameKeyword.REDIRECT + TransitionTargetPageNameKeyword.COURSE;
}
model.addAttribute("message", "エラーが発生しました");
return TransitionTargetPageNameKeyword.REDIRECT + TransitionTargetPageNameKeyword.COURSE;
}
}

View File

@@ -3,10 +3,13 @@ package com.example.demo.app.presentation.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import com.example.demo.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword;
@Controller
public class ErrorController {
@GetMapping("/error")
@GetMapping(TransitionTargetPageNameKeyword.ERROR)
public String showError() {
return "error";
return TransitionTargetPageNameKeyword.ERROR_HTML;
}
}

View File

@@ -0,0 +1,123 @@
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.controller.pageproperty.PageReturnAttributeKeyword;
import com.example.demo.app.presentation.controller.pageproperty.SessionKeyword;
import com.example.demo.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword;
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(TransitionTargetPageNameKeyword.FIXED_COST_LIST)
public String getFixedCostList(
HttpSession session, Model model, LocalDate today) {
LoginModel loginUser = (LoginModel) session.getAttribute(SessionKeyword.LOGIN_USER);
if (today == null) {
today = (LocalDate) session.getAttribute(PageReturnAttributeKeyword.TODAY);
}
List<FixedCostForm> fixedCostFormList = FixedCostForm.convertFrom(fixedCostService.findAllByUserId(loginUser.getUserId()));
fixedCostFormList.forEach(fixedCostForm -> fixedCostForm.setCategoryName(categoryService.findOne(fixedCostForm.getCategoryId()).getCategoryName()));
model.addAttribute(PageReturnAttributeKeyword.FIXED_COST_FORM_LIST, fixedCostFormList);
model.addAttribute(PageReturnAttributeKeyword.TODAY, today);
return TransitionTargetPageNameKeyword.FIXED_COST_HTML;
}
@SessionCheck
@GetMapping(TransitionTargetPageNameKeyword.FIXED_COST_CREATE)
public String getFixedCostCreate(
HttpSession session, @ModelAttribute FixedCostForm fixedCostForm, Model model, LocalDate today) {
List<CategoryForm> categoryFormList = CategoryForm.convertFrom(categoryService.findAll());
List<CategoryForm> expenseList = new ArrayList<CategoryForm>();
List<CategoryForm> incomeList = new ArrayList<CategoryForm>();
for (CategoryForm categoryForm : categoryFormList) {
if (categoryForm.getTransactionType() == 0) {
expenseList.add(categoryForm);
} else {
incomeList.add(categoryForm);
}
}
model.addAttribute(PageReturnAttributeKeyword.EXPENSE_LIST, expenseList);
model.addAttribute(PageReturnAttributeKeyword.INCOME_LIST, incomeList);
model.addAttribute(PageReturnAttributeKeyword.TODAY, today);
return TransitionTargetPageNameKeyword.FIXED_COST_CREATE_HTML;
}
@SessionCheck
@PostMapping(TransitionTargetPageNameKeyword.FIXED_COST_CREATE)
public String postFixedCostCreate(
HttpSession session, @ModelAttribute FixedCostForm fixedCostForm, Model model, LocalDate today) {
LoginModel loginUser = (LoginModel) session.getAttribute(SessionKeyword.LOGIN_USER);
fixedCostForm.setUserId(loginUser.getUserId());
fixedCostService.save(FixedCostForm.convertTo(fixedCostForm));
session.setAttribute(PageReturnAttributeKeyword.TODAY, today);
return TransitionTargetPageNameKeyword.REDIRECT + TransitionTargetPageNameKeyword.FIXED_COST_LIST;
}
@SessionCheck
@PostMapping(TransitionTargetPageNameKeyword.FIXED_COST_DELETE)
public String postFixedCostDelete(Long fixedCostId, LocalDate today, HttpSession session) {
fixedCostService.delete(fixedCostId);
session.setAttribute(PageReturnAttributeKeyword.TODAY, today);
return TransitionTargetPageNameKeyword.REDIRECT + TransitionTargetPageNameKeyword.FIXED_COST_LIST;
}
}

View File

@@ -1,5 +1,14 @@
package com.example.demo.app.presentation.controller;
import java.time.LocalDate;
import java.time.YearMonth;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import jakarta.servlet.http.HttpSession;
import org.springframework.stereotype.Controller;
@@ -9,65 +18,332 @@ 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.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.controller.pageproperty.PageReturnAttributeKeyword;
import com.example.demo.app.presentation.controller.pageproperty.SessionKeyword;
import com.example.demo.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword;
import com.example.demo.app.presentation.form.CategoryForm;
import com.example.demo.app.presentation.form.GoalForm;
import com.example.demo.app.presentation.form.MonthlyAchievementForm;
import com.example.demo.app.presentation.form.MonthlySavingForm;
import com.example.demo.app.presentation.form.TransactionForm;
import lombok.RequiredArgsConstructor;
@Controller
@RequiredArgsConstructor
@RequestMapping("/goal")
@RequestMapping(TransitionTargetPageNameKeyword.GOAL)
public class GoalController {
private final GoalService goalService;
private final TransactionService transactionService;
private final UserService userService;
private final CategoryService categoryService;
@SessionCheck
@GetMapping("")
public String getGoal(Model model, HttpSession session) {
public String getGoal(
Model model,
HttpSession session,
Long goalId) {
LoginModel loginUser = (LoginModel) session.getAttribute("loginUser");
LoginModel loginUser = (LoginModel) session.getAttribute(SessionKeyword.LOGIN_USER);
Long userId = loginUser.getUserId();
GoalModel goalModel = goalService.getGoalByUserId(userId);
GoalForm goalForm = GoalForm.convertFrom(goalModel);
LocalDate today = LocalDate.now();
model.addAttribute("goalForm", goalForm);
return "goal_view";
}
goalService.updateGoalComplete(userId);
@GetMapping("/edit")
public String editGoal(Model model, HttpSession session) {
List<GoalModel> goalModelList = goalService.getGoalByUserId(userId);
LoginModel loginUser = (LoginModel) session.getAttribute("loginUser");
Long userId = loginUser.getUserId();
List<GoalForm> goalFormList1 = GoalForm.convertFrom(goalModelList);
GoalModel goalModel = goalService.getGoalByUserId(userId);
GoalForm goalForm = GoalForm.convertFrom(goalModel);
List<GoalForm> goalFormList = goalFormList1.stream()
.filter(goalForm -> goalForm.getGoalComplete() == 0
&& !goalForm.getDeadline().isBefore(today))
.collect(Collectors.toList());
model.addAttribute("goalForm", goalForm);
return "goal_edit";
}
model.addAttribute(
PageReturnAttributeKeyword.GOAL_FORM_LIST,
goalFormList);
@PostMapping("/update")
public String updateGoal(@ModelAttribute GoalForm goalForm, HttpSession session) {
model.addAttribute(
PageReturnAttributeKeyword.ACHIEVEMENT_LIST,
new ArrayList<MonthlyAchievementForm>());
LoginModel loginUser = (LoginModel) session.getAttribute("loginUser");
Long userId = loginUser.getUserId();
// 本人の目標かどうかを確認してから更新する
GoalModel currentGoal = goalService.getGoalByUserId(userId);
if (!currentGoal.getGoalId().equals(goalForm.getGoalId())) {
return "redirect:/goal"; // 他人のデータを更新しようとしたら弾く
if (goalFormList.isEmpty()) {
return TransitionTargetPageNameKeyword.GOAL_VIEW_HTML;
}
GoalModel goalModel = GoalModel.convertFrom(goalForm);
goalService.updateGoal(goalModel);
GoalForm graphGoal;
return "redirect:/goal";
if (goalId == null) {
graphGoal = goalFormList.getFirst();
} else {
graphGoal = goalFormList.stream()
.filter(goal -> goal.getGoalId().equals(goalId))
.findFirst()
.orElse(
goalFormList.getFirst());
}
model.addAttribute(
PageReturnAttributeKeyword.GRAPH_GOAL,
graphGoal);
int currentAmount = graphGoal.getCurrentAmount();
int targetAmount = graphGoal.getTargetAmount();
LocalDate startDate = LocalDate.of(
LocalDate.now().getYear(),
1,
1);
Map<LocalDate, List<TransactionForm>> transactionFormMap = new HashMap<>();
transactionService
.findAllByDate(
startDate,
today,
userId)
.forEach((date, list) -> {
List<TransactionForm> transactionFormList = list.stream()
.map(transaction -> {
CategoryForm categoryForm = CategoryForm.convertFrom(
categoryService.findOne(
transaction.getCategoryId()));
return TransactionForm.convertFrom(
transaction,
categoryForm.getCategoryName(),
transactionService.findTotalExpense(
startDate,
today,
loginUser.getUserId()),
transactionService.findTotalIncome(
startDate,
today,
loginUser.getUserId()),
categoryForm.getTransactionType());
})
.collect(Collectors.toList());
transactionFormMap.put(
date,
transactionFormList);
});
List<MonthlySavingForm> monthlySavingList = new ArrayList<>();
YearMonth startMonth = YearMonth.from(startDate);
YearMonth currentMonth = YearMonth.now();
YearMonth month = currentMonth;
while (!month.isBefore(startMonth)) {
int income = 0;
int expense = 0;
for (Map.Entry<LocalDate, List<TransactionForm>> entry : transactionFormMap.entrySet()) {
YearMonth transactionMonth = YearMonth.from(entry.getKey());
if (!transactionMonth.equals(month)) {
continue;
}
for (TransactionForm transaction : entry.getValue()) {
if (transaction.getAmount() == null) {
continue;
}
if (transaction.getTransactionType() == 1) {
income += transaction.getAmount();
} else if (transaction.getTransactionType() == 0) {
expense += transaction.getAmount();
}
}
}
monthlySavingList.add(
new MonthlySavingForm(
month,
income,
expense,
currentAmount));
currentAmount = currentAmount
- income
+ expense;
month = month.minusMonths(1);
}
Collections.reverse(
monthlySavingList);
List<MonthlyAchievementForm> achievementList = new ArrayList<>();
for (MonthlySavingForm monthlySaving : monthlySavingList) {
int savingAmount = monthlySaving.getSaving();
int achievementRate = 0;
if (targetAmount > 0) {
achievementRate = (int) ((double) savingAmount
/ targetAmount
* 100);
}
achievementList.add(
new MonthlyAchievementForm(
monthlySaving.getMonth(),
savingAmount,
achievementRate));
}
model.addAttribute(
PageReturnAttributeKeyword.ACHIEVEMENT_LIST,
achievementList);
return TransitionTargetPageNameKeyword.GOAL_VIEW_HTML;
}
@SessionCheck
@GetMapping(TransitionTargetPageNameKeyword.EDIT)
public String editGoal(Model model, HttpSession session, Long goalId) {
LoginModel loginUser = (LoginModel) session.getAttribute(SessionKeyword.LOGIN_USER);
Long userId = loginUser.getUserId();
GoalForm goalForm = GoalForm.convertFrom(goalService.getGoalById(goalId));
model.addAttribute(PageReturnAttributeKeyword.GOAL_FORM, goalForm);
return TransitionTargetPageNameKeyword.GOAL_EDIT_HTML;
}
@SessionCheck
@PostMapping(TransitionTargetPageNameKeyword.UPDATE)
public String updateGoal(@ModelAttribute GoalForm goalForm, HttpSession session) {
LoginModel loginUser = (LoginModel) session.getAttribute(SessionKeyword.LOGIN_USER);
Long userId = loginUser.getUserId();
// // 本人の目標かどうかを確認してから更新する
// GoalModel currentGoal = goalService.getGoalByUserId(userId);
//
// if (!currentGoal.getGoalId().equals(goalForm.getGoalId())) {
// return "redirect:/goal"; // 他人のデータを更新しようとしたら弾く
// }
GoalModel goalModel = GoalModel.convertFrom(goalForm);
goalService.updateGoal(goalModel, userId);
return TransitionTargetPageNameKeyword.REDIRECT + TransitionTargetPageNameKeyword.GOAL;
}
@SessionCheck
@GetMapping(TransitionTargetPageNameKeyword.CREATE)
public String createGoalGet(@ModelAttribute GoalForm goalForm, HttpSession session, Model model) {
LoginModel loginUser = (LoginModel) session.getAttribute(SessionKeyword.LOGIN_USER);
Long userId = loginUser.getUserId();
int currentAmount = goalService.getCurrentAmount(userId);
model.addAttribute(PageReturnAttributeKeyword.CURRENT_AMOUNT, currentAmount);
return TransitionTargetPageNameKeyword.GOAL_CREATE_HTML;
}
@SessionCheck
@PostMapping(TransitionTargetPageNameKeyword.CREATE)
public String createGoalPost(@ModelAttribute GoalForm goalForm, HttpSession session, Model model) {
LoginModel loginUser = (LoginModel) session.getAttribute(SessionKeyword.LOGIN_USER);
Long userId = loginUser.getUserId();
if (goalService.createGoal(GoalModel.convertFrom(goalForm), userId) == null) {
model.addAttribute(PageReturnAttributeKeyword.MESSAGE, "現在所持金より高い金額を設定してください。");
return TransitionTargetPageNameKeyword.GOAL_CREATE_HTML;
}
return TransitionTargetPageNameKeyword.REDIRECT + TransitionTargetPageNameKeyword.GOAL;
}
@SessionCheck
@PostMapping(TransitionTargetPageNameKeyword.DELETE) // フラグ考慮してないため、今度修正必要
public String deleteGoal(Long goalId, Long record) {
goalService.delete(goalId);
if (record == null) {
return TransitionTargetPageNameKeyword.REDIRECT + TransitionTargetPageNameKeyword.GOAL;
} else {
return TransitionTargetPageNameKeyword.REDIRECT + TransitionTargetPageNameKeyword.GOAL
+ TransitionTargetPageNameKeyword.RECORD;
}
}
@SessionCheck
@GetMapping(TransitionTargetPageNameKeyword.RECORD)
public String getRecord(HttpSession session, Model model) {
LocalDate today = LocalDate.now();
LoginModel loginUser = (LoginModel) session.getAttribute(SessionKeyword.LOGIN_USER);
Long userId = loginUser.getUserId();
goalService.updateGoalComplete(userId);
List<GoalModel> goalModelList = goalService.getGoalByUserId(userId);
List<GoalForm> goalFormList = GoalForm.convertFrom(goalModelList);
List<GoalForm> goalCompleteFormList = new ArrayList<>();
goalFormList.stream().forEach(goalForm -> {
if (goalForm.getGoalComplete() == 1 || goalForm.getDeadline().isBefore(today)) {
goalForm.setStatus(
goalForm.getGoalComplete() == 1
? "達成"
: "未達成");
goalCompleteFormList.add(goalForm);
}
});
model.addAttribute(
PageReturnAttributeKeyword.GOAL_COMPLETE_FORM_LIST,
goalCompleteFormList);
return TransitionTargetPageNameKeyword.GOAL_RECORD_HTML;
}
}

View File

@@ -10,6 +10,9 @@ import org.springframework.web.bind.annotation.PostMapping;
import com.example.demo.app.domain.model.LoginModel;
import com.example.demo.app.domain.service.LoginService;
import com.example.demo.app.presentation.controller.pageproperty.PageReturnAttributeKeyword;
import com.example.demo.app.presentation.controller.pageproperty.SessionKeyword;
import com.example.demo.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword;
import com.example.demo.app.presentation.form.LoginForm;
import lombok.RequiredArgsConstructor;
@@ -18,35 +21,40 @@ import lombok.RequiredArgsConstructor;
@RequiredArgsConstructor
public class LoginController {
private final LoginService loginService;
private final LoginService loginService;
@GetMapping("/login")
public String showLogin(@ModelAttribute LoginForm loginForm) {
@GetMapping(TransitionTargetPageNameKeyword.LOGIN)
public String showLogin(@ModelAttribute LoginForm loginForm, HttpSession session) {
return "login";
}
if (session.getAttribute(SessionKeyword.LOGIN_USER) != null) {
return TransitionTargetPageNameKeyword.REDIRECT + TransitionTargetPageNameKeyword.MENU;
}
@PostMapping("/login")
public String login(
@ModelAttribute LoginForm loginForm,
Model model,
HttpSession session) {
return TransitionTargetPageNameKeyword.LOGIN_HTML;
LoginModel loginModel = loginService.login(
loginForm.getMailAddress(),
loginForm.getPassword());
}
if (loginModel == null) {
model.addAttribute(
"errorMessage",
"Email address or password is incorrect.");
@PostMapping(TransitionTargetPageNameKeyword.LOGIN)
public String login(
@ModelAttribute LoginForm loginForm,
Model model,
HttpSession session) {
return "login";
}
LoginModel loginModel = loginService.login(
loginForm.getMailAddress(),
loginForm.getPassword());
session.setAttribute("loginUser", loginModel);
if (loginModel == null) {
model.addAttribute(
PageReturnAttributeKeyword.ERROR_MESSAGE,
"IDまたはパスワードが間違っています.");
return "redirect:/menu";
}
return TransitionTargetPageNameKeyword.LOGIN_HTML;
}
session.setAttribute(SessionKeyword.LOGIN_USER, loginModel);
return TransitionTargetPageNameKeyword.REDIRECT + TransitionTargetPageNameKeyword.MENU;
}
}

View File

@@ -7,7 +7,11 @@ 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.controller.pageproperty.PageReturnAttributeKeyword;
import com.example.demo.app.presentation.controller.pageproperty.SessionKeyword;
import com.example.demo.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword;
import com.example.demo.app.presentation.form.PasswordResetForm;
import lombok.RequiredArgsConstructor;
@@ -17,37 +21,50 @@ import lombok.RequiredArgsConstructor;
public class PasswordResetController {
private final PasswordResetService passwordResetService;
@GetMapping("/password/reset")
@GetMapping(TransitionTargetPageNameKeyword.PASSWORD_RESET)
public String showPasswordReset(Model model) {
model.addAttribute("passwordResetForm", new PasswordResetForm());
return "password_reset";
model.addAttribute(PageReturnAttributeKeyword.PASSWOR_RESET_FORM, new PasswordResetForm());
return TransitionTargetPageNameKeyword.PASSWORD_RESET_HTML;
}
@PostMapping("/password/reset")
@PostMapping(TransitionTargetPageNameKeyword.PASSWORD_RESET)
public String resetPassword(
PasswordResetForm passwordResetForm,
Model model,
HttpSession session){
PasswordResetForm passwordResetForm,
Model model,
HttpSession session) {
Long userId =
(Long) session.getAttribute("passwordResetUserId");
Long userId = (Long) session.getAttribute(PageReturnAttributeKeyword.PASSWOR_RESET_USER_ID);
if(userId == null) {
return "redirect:/login";
if (userId == null) {
LoginModel loginUser = (LoginModel) session.getAttribute(SessionKeyword.LOGIN_USER);
if (loginUser != null) {
userId = loginUser.getUserId();
}
}
boolean isReset =
passwordResetService.resetPassword(userId, passwordResetForm);
if(!isReset) {
model.addAttribute("Message", "パスワードが一致しません。");
return "password_reset";
if (userId == null) {
return TransitionTargetPageNameKeyword.REDIRECT +
TransitionTargetPageNameKeyword.LOGIN;
}
session.removeAttribute("passwordResetUserId");
boolean isReset = passwordResetService.resetPassword(userId, passwordResetForm);
return "redirect:/login";
if (!isReset) {
model.addAttribute(PageReturnAttributeKeyword.MESSAGE, "パスワードが一致しません。");
return TransitionTargetPageNameKeyword.PASSWORD_RESET_HTML;
}
session.removeAttribute(PageReturnAttributeKeyword.PASSWOR_RESET_USER_ID);
LoginModel loginUser = (LoginModel) session.getAttribute(SessionKeyword.LOGIN_USER);
if (loginUser != null) {
return TransitionTargetPageNameKeyword.REDIRECT +
TransitionTargetPageNameKeyword.PROFILE;
}
return TransitionTargetPageNameKeyword.REDIRECT +
TransitionTargetPageNameKeyword.LOGIN;
}
}

View File

@@ -8,9 +8,13 @@ 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.controller.pageproperty.PageReturnAttributeKeyword;
import com.example.demo.app.presentation.controller.pageproperty.SessionKeyword;
import com.example.demo.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword;
import com.example.demo.app.presentation.form.ProfileEditForm;
import com.example.demo.app.presentation.form.ProfileForm;
@@ -21,25 +25,27 @@ import lombok.RequiredArgsConstructor;
public class ProfileController {
private final ProfileService profileService;
@GetMapping("/profile")
@SessionCheck
@GetMapping(TransitionTargetPageNameKeyword.PROFILE)
public String profile(Model model, HttpSession session) {
LoginModel loginUser = (LoginModel) session.getAttribute("loginUser");
LoginModel loginUser = (LoginModel) session.getAttribute(SessionKeyword.LOGIN_USER);
ProfileModel profileModel = profileService.findOne(loginUser.getUserId());
ProfileForm profileForm = ProfileForm.convertForm(profileModel);
model.addAttribute("profileForm", profileForm);
return "profile";
model.addAttribute(PageReturnAttributeKeyword.PROFILE_FORM, profileForm);
return TransitionTargetPageNameKeyword.PROFILE_HTML;
}
@GetMapping("/profile/edit")
@SessionCheck
@GetMapping(TransitionTargetPageNameKeyword.PROFILE_EDIT)
public String showEditProfile(
Model model,
HttpSession session) {
LoginModel loginUser =
(LoginModel) session.getAttribute("loginUser");
(LoginModel) session.getAttribute(SessionKeyword.LOGIN_USER);
ProfileModel profileModel =
profileService.findOne(loginUser.getUserId());
@@ -48,45 +54,47 @@ public class ProfileController {
new ProfileEditForm(
profileModel.getUserName(),
profileModel.getMailAddress(),
profileModel.getBirthDate(),
profileModel.getSaving(),
profileModel.getAnnualIncome(),
profileModel.getMonthlyBudget());
model.addAttribute("profileEditForm", profileEditForm);
return "profile_edit";
model.addAttribute(PageReturnAttributeKeyword.PROFILE_EDIT_FORM, profileEditForm);
return TransitionTargetPageNameKeyword.PROFILE_EDIT_HTML;
}
@PostMapping("/profile/edit")
@PostMapping(TransitionTargetPageNameKeyword.PROFILE_EDIT)
public String updateProfile(
@ModelAttribute ProfileEditForm profileEditForm,
HttpSession session) {
LoginModel loginUser =
(LoginModel) session.getAttribute("loginUser");
(LoginModel) session.getAttribute(SessionKeyword.LOGIN_USER);
profileService.update(
loginUser.getUserId(),
profileEditForm);
return "redirect:/profile";
return TransitionTargetPageNameKeyword.REDIRECT + TransitionTargetPageNameKeyword.PROFILE;
}
@PostMapping("/withdraw")
@PostMapping(TransitionTargetPageNameKeyword.WITHDRAW)
public String withdraw(HttpSession session) {
LoginModel loginUser =
(LoginModel) session.getAttribute("loginUser");
(LoginModel) session.getAttribute(SessionKeyword.LOGIN_USER);
profileService.withdraw(loginUser.getUserId());
session.invalidate();
return "redirect:/login";
return TransitionTargetPageNameKeyword.REDIRECT + TransitionTargetPageNameKeyword.LOGIN;
}
@PostMapping("/logout")
@PostMapping(TransitionTargetPageNameKeyword.LOGOUT)
public String logout(HttpSession session) {
session.invalidate();
return "redirect:/login";
return TransitionTargetPageNameKeyword.REDIRECT + TransitionTargetPageNameKeyword.LOGIN;
}
}

View File

@@ -3,6 +3,7 @@ package com.example.demo.app.presentation.controller;
import java.time.LocalDate;
import java.time.YearMonth;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -17,13 +18,19 @@ 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.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.controller.pageproperty.PageReturnAttributeKeyword;
import com.example.demo.app.presentation.controller.pageproperty.SessionKeyword;
import com.example.demo.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword;
import com.example.demo.app.presentation.form.CategoryForm;
import com.example.demo.app.presentation.form.Expense;
import com.example.demo.app.presentation.form.FixedCostForm;
import com.example.demo.app.presentation.form.GoalForm;
import com.example.demo.app.presentation.form.Income;
import com.example.demo.app.presentation.form.TransactionForm;
@@ -39,16 +46,18 @@ public class TransactionController {
private final CategoryService categoryService;
private final GoalService goalService;
private final UserService userService;
private final FixedCostService fixedCostService;
// 一覧画面
@GetMapping("/transaction/list")
@SessionCheck
@GetMapping(TransitionTargetPageNameKeyword.TRANSACTION_LIST)
public String transactionList(
@RequestParam(required = false, defaultValue = "0") String years,
@RequestParam(required = false, defaultValue = "0") String months,
Model model,
HttpSession session) {
LoginModel loginUser = (LoginModel) session.getAttribute("loginUser");
LoginModel loginUser = (LoginModel) session.getAttribute(SessionKeyword.LOGIN_USER);
LocalDate today = LocalDate.now();
@@ -109,27 +118,28 @@ public class TransactionController {
transactionFormMap.put(date, transactionFormList);
});
model.addAttribute("year", year);
model.addAttribute("month", month);
model.addAttribute(PageReturnAttributeKeyword.YEAR, year);
model.addAttribute(PageReturnAttributeKeyword.MONTH, month);
model.addAttribute("previousYear", previousYear);
model.addAttribute("previousMonth", previousMonth);
model.addAttribute(PageReturnAttributeKeyword.PREVIOUS_YEAR, previousYear);
model.addAttribute(PageReturnAttributeKeyword.PREVIOUS_MONTH, previousMonth);
model.addAttribute("nextYear", nextYear);
model.addAttribute("nextMonth", nextMonth);
model.addAttribute(PageReturnAttributeKeyword.NEXT_YEAR, nextYear);
model.addAttribute(PageReturnAttributeKeyword.NEXT_MONTH, nextMonth);
model.addAttribute("transactionFormMap", transactionFormMap);
model.addAttribute(PageReturnAttributeKeyword.TRANSACTION_FORM_MAP, transactionFormMap);
return "transaction_list";
return TransitionTargetPageNameKeyword.TRANSACTION_LIST_HTML;
}
// 詳細画面
@GetMapping("/transaction/detail")
@SessionCheck
@GetMapping(TransitionTargetPageNameKeyword.TRANSACTION_DETAIL)
public String findOne(@RequestParam(required = false) LocalDate todayDates, Model model, HttpSession session) {
LocalDate todayDate = (todayDates == null) ? LocalDate.now() : todayDates;
LoginModel loginUser = (LoginModel) session.getAttribute("loginUser");
LoginModel loginUser = (LoginModel) session.getAttribute(SessionKeyword.LOGIN_USER);
List<TransactionForm> transactionFormList = transactionService
.findByUserIdAndDate(todayDate, loginUser.getUserId()).stream()
@@ -170,60 +180,115 @@ public class TransactionController {
return transactionForm;
}).collect(Collectors.toList());
model.addAttribute("today", todayDate);
model.addAttribute("transactionFormList", transactionFormList);
model.addAttribute(PageReturnAttributeKeyword.TODAY, todayDate);
model.addAttribute(PageReturnAttributeKeyword.TRANSACTION_FORM_LIST, transactionFormList);
return "transaction_detail";
return TransitionTargetPageNameKeyword.TRANSACTION_DETAIL_HTML;
}
@GetMapping("/transaction/create")
@SessionCheck
@GetMapping(TransitionTargetPageNameKeyword.TRANSACTION_CREATE)
public String createOneGet(@RequestParam(defaultValue = "") LocalDate today,
Model model) {
Long fixedCostId,
Model model, HttpSession session) {
LoginModel loginUser = (LoginModel) session.getAttribute(SessionKeyword.LOGIN_USER);
if (today == null) {
today = LocalDate.now();
}
List<CategoryForm> categoryFormList = CategoryForm.convertFrom(categoryService.findAll());
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());
}
System.out.println(transactionForm.getCategoryName() + " " + transactionForm.getAmount());
List<CategoryForm> categoryFormList = new ArrayList<>(
CategoryForm.convertFrom(categoryService.findAllExceptCustom()));
model.addAttribute("transactionForm", transactionForm);
List<CategoryForm> categoryFormCustomList = CategoryForm
.convertFrom(categoryService.findAllByuserId(loginUser.getUserId()));
model.addAttribute("categoryFormList", categoryFormList);
if (!categoryFormCustomList.isEmpty()) {
for (CategoryForm form : categoryFormCustomList) {
categoryFormList.add(form);
}
}
model.addAttribute("today", today.format(DateTimeFormatter.ISO_LOCAL_DATE));
return "transaction_create";
List<CategoryForm> expenseList = new ArrayList<CategoryForm>();
List<CategoryForm> incomeList = new ArrayList<CategoryForm>();
for (CategoryForm categoryForm : categoryFormList) {
if (categoryForm.getTransactionType() == 0) {
expenseList.add(categoryForm);
} else {
incomeList.add(categoryForm);
}
}
model.addAttribute(PageReturnAttributeKeyword.EXPENSE_LIST, expenseList);
model.addAttribute(PageReturnAttributeKeyword.INCOME_LIST, incomeList);
model.addAttribute(PageReturnAttributeKeyword.TRANSACTION_FORM, transactionForm);
session.setAttribute(SessionKeyword.T_TYPE, String.valueOf(transactionForm.getTransactionType()));
model.addAttribute(PageReturnAttributeKeyword.CATEGORY_FORM_LIST, categoryFormList);
model.addAttribute(PageReturnAttributeKeyword.TODAY, today.format(DateTimeFormatter.ISO_LOCAL_DATE));
return TransitionTargetPageNameKeyword.TRANSACTION_CREATE_HTML;
}
@PostMapping("/transaction/create")
@SessionCheck
@PostMapping(TransitionTargetPageNameKeyword.TRANSACTION_CREATE)
public String createOnePost(@ModelAttribute TransactionForm transactionForm, @RequestParam LocalDate today,
Model model,
HttpSession session) {
LoginModel loginUser = (LoginModel) session.getAttribute("loginUser");
LoginModel loginUser = (LoginModel) session.getAttribute(SessionKeyword.LOGIN_USER);
transactionForm.setUserId(loginUser.getUserId());
if (transactionService.createTransaction(TransactionForm.convertTo(transactionForm)) != 0) {
return "error";
return TransitionTargetPageNameKeyword.ERROR_HTML;
}
return "redirect:/transaction/detail?todayDates=" + transactionForm.getTransactionDate();
return TransitionTargetPageNameKeyword.REDIRECT +
TransitionTargetPageNameKeyword.TRANSACTION_DETAIL +
TransitionTargetPageNameKeyword.INTERROGATION +
TransitionTargetPageNameKeyword.TODAY_DATES +
TransitionTargetPageNameKeyword.EQUAL +
transactionForm.getTransactionDate();
}
@GetMapping("/transaction/update")
@SessionCheck
@GetMapping(TransitionTargetPageNameKeyword.TRANSACTION_UPDATE)
public String updateOneGet(@RequestParam Long transactionId, @RequestParam(defaultValue = "") LocalDate today,
Model model) {
Model model, HttpSession session) {
LoginModel loginUser = (LoginModel) session.getAttribute(SessionKeyword.LOGIN_USER);
if (today == null) {
today = LocalDate.now();
}
List<CategoryForm> categoryFormList = CategoryForm.convertFrom(categoryService.findAll());
List<CategoryForm> categoryFormList = new ArrayList<>(
CategoryForm.convertFrom(categoryService.findAllExceptCustom()));
List<CategoryForm> categoryFormCustomList = CategoryForm
.convertFrom(categoryService.findAllByuserId(loginUser.getUserId()));
if (!categoryFormCustomList.isEmpty()) {
for (CategoryForm form : categoryFormCustomList) {
categoryFormList.add(form);
}
}
TransactionForm transactionForm = TransactionForm.convertFrom(
transactionService.findByTransactionId(transactionId),
@@ -232,51 +297,81 @@ public class TransactionController {
transactionService.findMoneyRecord(transactionId),
CategoryForm.convertFrom(categoryService.findByTransactionId(transactionId)).getTransactionType());
System.out.println("category: " + transactionForm.getCategoryId() + "金額: " + transactionForm.getAmount());
List<CategoryForm> expenseList = new ArrayList<CategoryForm>();
model.addAttribute("transactionId", transactionId);
List<CategoryForm> incomeList = new ArrayList<CategoryForm>();
model.addAttribute("transactionForm", transactionForm);
for (CategoryForm categoryForm : categoryFormList) {
model.addAttribute("categoryFormList", categoryFormList);
if (categoryForm.getTransactionType() == 0) {
expenseList.add(categoryForm);
} else {
incomeList.add(categoryForm);
}
model.addAttribute("today", today);
}
return "transaction_update";
model.addAttribute(PageReturnAttributeKeyword.EXPENSE_LIST, expenseList);
model.addAttribute(PageReturnAttributeKeyword.INCOME_LIST, incomeList);
model.addAttribute(PageReturnAttributeKeyword.TRANSACTION_ID, transactionId);
model.addAttribute(PageReturnAttributeKeyword.TRANSACTION_FORM, transactionForm);
model.addAttribute(PageReturnAttributeKeyword.CATEGORY_FORM_LIST, categoryFormList);
model.addAttribute(PageReturnAttributeKeyword.TODAY, today);
session.setAttribute(SessionKeyword.T_TYPE, transactionForm.getTransactionType());
return TransitionTargetPageNameKeyword.TRANSACTION_UPDATE_HTML;
}
@PostMapping("/transaction/update")
@SessionCheck
@PostMapping(TransitionTargetPageNameKeyword.TRANSACTION_UPDATE)
public String updateOnePost(@RequestParam Long transactionId, @ModelAttribute TransactionForm transactionForm,
@RequestParam LocalDate today, Model model,
HttpSession session) {
LoginModel loginUser = (LoginModel) session.getAttribute("loginUser");
LoginModel loginUser = (LoginModel) session.getAttribute(SessionKeyword.LOGIN_USER);
transactionForm.setUserId(loginUser.getUserId());
transactionForm.setTransactionId(transactionId);
if (transactionService.updateTransaction(TransactionForm.convertTo(transactionForm)) != 0) {
return "error";
return TransitionTargetPageNameKeyword.ERROR_HTML;
}
return "redirect:/transaction/detail?todayDates=" + transactionForm.getTransactionDate();
return TransitionTargetPageNameKeyword.REDIRECT +
TransitionTargetPageNameKeyword.TRANSACTION_DETAIL +
TransitionTargetPageNameKeyword.INTERROGATION +
TransitionTargetPageNameKeyword.TODAY_DATES +
TransitionTargetPageNameKeyword.EQUAL +
transactionForm.getTransactionDate();
}
@PostMapping("/transaction/delete")
@SessionCheck
@PostMapping(TransitionTargetPageNameKeyword.TRANSACTION_DELETE)
public String deleteOne(@RequestParam Long transactionId, @RequestParam LocalDate today) {
transactionService.deleteTransaction(transactionId);
return "redirect:/transaction/detail?todayDates=" + today;
return TransitionTargetPageNameKeyword.REDIRECT +
TransitionTargetPageNameKeyword.TRANSACTION_DETAIL +
TransitionTargetPageNameKeyword.INTERROGATION +
TransitionTargetPageNameKeyword.TODAY_DATES +
TransitionTargetPageNameKeyword.EQUAL +
today;
}
@GetMapping("/menu")
@SessionCheck
@GetMapping(TransitionTargetPageNameKeyword.MENU)
public String menu(HttpSession session, Model model,
@RequestParam(required = false, defaultValue = "0") String years,
@RequestParam(required = false, defaultValue = "0") String months) {
LoginModel loginUser = (LoginModel) session.getAttribute("loginUser");
LoginModel loginUser = (LoginModel) session.getAttribute(SessionKeyword.LOGIN_USER);
LocalDate today = LocalDate.now();
@@ -300,18 +395,18 @@ public class TransactionController {
int nextYear = nextYearMonth.getYear();
int nextMonth = nextYearMonth.getMonthValue();
model.addAttribute("year", year);
model.addAttribute("month", month);
model.addAttribute("day", today.getDayOfMonth());
model.addAttribute(PageReturnAttributeKeyword.YEAR, year);
model.addAttribute(PageReturnAttributeKeyword.MONTH, month);
model.addAttribute(PageReturnAttributeKeyword.DAY, today.getDayOfMonth());
model.addAttribute("lastDay", lastDay);
model.addAttribute("firstDayOfWeek", firstDayOfWeek);
model.addAttribute(PageReturnAttributeKeyword.LAST_DAY, lastDay);
model.addAttribute(PageReturnAttributeKeyword.FIRST_DAY_OF_WEEK, firstDayOfWeek);
model.addAttribute("previousYear", previousYear);
model.addAttribute("previousMonth", previousMonth);
model.addAttribute(PageReturnAttributeKeyword.PREVIOUS_YEAR, previousYear);
model.addAttribute(PageReturnAttributeKeyword.PREVIOUS_MONTH, previousMonth);
model.addAttribute("nextYear", nextYear);
model.addAttribute("nextMonth", nextMonth);
model.addAttribute(PageReturnAttributeKeyword.NEXT_YEAR, nextYear);
model.addAttribute(PageReturnAttributeKeyword.NEXT_MONTH, nextMonth);
LocalDate startDate = yearMonth.atDay(1);
LocalDate endDate = yearMonth.atEndOfMonth();
@@ -320,29 +415,51 @@ public class TransactionController {
List<Expense> expenseList = transactionService.findTotalExpenseList(startDate, endDate, loginUser.getUserId());
model.addAttribute("incomeList", incomeList);
model.addAttribute("expenseList", expenseList);
model.addAttribute(PageReturnAttributeKeyword.INCOME_LIST, incomeList);
model.addAttribute(PageReturnAttributeKeyword.EXPENSE_LIST, expenseList);
int totalIncome = transactionService.findTotalIncome(startDate, endDate, loginUser.getUserId());
int totalExpense = transactionService.findTotalExpense(startDate, endDate, loginUser.getUserId());
model.addAttribute("totalIncome", totalIncome);
model.addAttribute("totalExpense", totalExpense);
model.addAttribute(PageReturnAttributeKeyword.TOTAL_INCOME, totalIncome);
model.addAttribute(PageReturnAttributeKeyword.TOTAL_EXPENSE, totalExpense);
GoalForm goalForm = GoalForm.convertFrom(goalService.getGoalByUserId(loginUser.getUserId()));
List<GoalForm> goalForm = GoalForm.convertFrom(goalService.getGoalByUserId(loginUser.getUserId()));
UserForm userForm = UserForm.convertFrom(userService.findByUserId(loginUser.getUserId()));
model.addAttribute("achievementRate", goalForm.getAchievementRate());
List<GoalForm> resultList = goalForm.stream().filter(goal -> goal.getGoalComplete() == 0 && goal.getDeadline().isAfter(today) )
.collect(Collectors.toList());
model.addAttribute("targetAmount", goalForm.getTargetAmount());
if (!resultList.isEmpty()) {
GoalForm result = resultList.getFirst();
model.addAttribute("saving", userForm.getSaving());
model.addAttribute(PageReturnAttributeKeyword.ACHIEVEMENT_RATE, result.getAchievementRate());
model.addAttribute("deadline", goalForm.getDeadline());
model.addAttribute(PageReturnAttributeKeyword.CURRENT_AMOUNT, result.getCurrentAmount());
return "menu";
model.addAttribute(PageReturnAttributeKeyword.TARGET_AMOUNT, result.getTargetAmount());
model.addAttribute(PageReturnAttributeKeyword.SAVING, userForm.getSaving());
model.addAttribute(PageReturnAttributeKeyword.DEADLINE, result.getDeadline());
} else {
final String MESSAGE = "目標を設定してください";
model.addAttribute(PageReturnAttributeKeyword.ACHIEVEMENT_RATE, MESSAGE);
model.addAttribute(PageReturnAttributeKeyword.CURRENT_AMOUNT, MESSAGE);
model.addAttribute(PageReturnAttributeKeyword.TARGET_AMOUNT, MESSAGE);
model.addAttribute(PageReturnAttributeKeyword.SAVING, userForm.getSaving());
model.addAttribute(PageReturnAttributeKeyword.DEADLINE, MESSAGE);
}
return TransitionTargetPageNameKeyword.MENU_HTML;
}
}

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;
@@ -7,7 +9,15 @@ 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 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.controller.pageproperty.PageReturnAttributeKeyword;
import com.example.demo.app.presentation.controller.pageproperty.SessionKeyword;
import com.example.demo.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword;
import com.example.demo.app.presentation.form.UserForm;
import lombok.RequiredArgsConstructor;
@@ -16,39 +26,74 @@ import lombok.RequiredArgsConstructor;
@RequiredArgsConstructor
public class UserController {
@GetMapping("/user/register")
public String showRegister(Model model, HttpSession session) {
UserForm userForm = (UserForm) session.getAttribute("userForm");
private final UserService userService;
if(userForm == null) {
private final CourseService courseService;
private final QuestionService questionService;
@GetMapping(TransitionTargetPageNameKeyword.USER_RESISTER)
public String showRegister(Model model, HttpSession session) {
UserForm userForm = new UserForm();
List<QuestionEntity> questionList = questionService.findAll();
session.setAttribute(PageReturnAttributeKeyword.QUESTION_LIST, questionList);
model.addAttribute(PageReturnAttributeKeyword.USER_FORM, userForm);
return TransitionTargetPageNameKeyword.USER_RESISTER_HTML;
}
@PostMapping(TransitionTargetPageNameKeyword.USER_RESISTER_RETURN)
public String showRegisterReturn(@RequestParam(required = false) Long courseId, Model model, HttpSession session) {
UserForm userForm = (UserForm) session.getAttribute(PageReturnAttributeKeyword.USER_FORM);
if (userForm.getUserName().equals("")) {
userForm = new UserForm();
userForm.setCourseId(courseId);
}
model.addAttribute("userForm", userForm);
return "user_register";
if (courseId != null) {
model.addAttribute(PageReturnAttributeKeyword.SELECTED_COURSE_NAME, courseService.findById(courseId).getCourseName());
}
session.setAttribute(SessionKeyword.SELECTED_COURSE_NAME, courseService.findById(courseId).getCourseName());
model.addAttribute(PageReturnAttributeKeyword.COURSE_ID, courseId);
model.addAttribute(PageReturnAttributeKeyword.USER_FORM, userForm);
return TransitionTargetPageNameKeyword.USER_RESISTER_RETURN_HTML;
}
@PostMapping("/user/register/confirm")
@GetMapping(TransitionTargetPageNameKeyword.USER_RESISTER_CONFIRM)
public String confirmRegisterGet(@ModelAttribute UserForm userForm,
String selectedCourseName, Model model,
HttpSession session) {
model.addAttribute(PageReturnAttributeKeyword.SELECTED_COURSE_NAME, (String) session.getAttribute(SessionKeyword.SELECTED_COURSE_NAME));
session.setAttribute(SessionKeyword.QUESTION_ID, userForm.getSecretQuestionId());
return TransitionTargetPageNameKeyword.USER_RESISTER_CONFIRM_HTML;
}
@PostMapping(TransitionTargetPageNameKeyword.USER_RESISTER_COMPLETE)
public String confirmRegister(
@ModelAttribute UserForm userForm,
HttpSession session) {
@ModelAttribute UserForm userForm,
Model model,
HttpSession session) {
session.setAttribute("userForm", userForm);
Long courseId = courseService.findByName((String) session.getAttribute(SessionKeyword.SELECTED_COURSE_NAME));
return "user_register_confirm";
}
Long questionId = (Long) session.getAttribute(SessionKeyword.QUESTION_ID);
@PostMapping("/user/register/complete")
public String completeRegister(HttpSession session) {
userForm.setSecretQuestionId(questionId);
UserForm userForm =
(UserForm) session.getAttribute("userForm");
userService.register(userForm, courseId);
// DBへの登録処理
session.removeAttribute("userForm");
return "redirect:/login";
return TransitionTargetPageNameKeyword.REDIRECT + TransitionTargetPageNameKeyword.LOGIN;
}

View File

@@ -0,0 +1,66 @@
package com.example.demo.app.presentation.controller.pageproperty;
public class PageReturnAttributeKeyword {
public static final String ERROR_MESSAGE = "errorMessage";
public static final String MESSAGE = "message";
public static final String ERROR = "error";
public static final String STATUS = "status";
public static final String QUESTION_LIST = "questionList";
public static final String USER_FORM = "userForm";
public static final String SELECTED_COURSE_NAME = "selectedCourseName";
public static final String COURSE_ID = "courseId";
public static final String PASSWOR_RESET_FORM = "passwordResetForm";
public static final String PASSWOR_RESET_USER_ID = "passwordResetUserId";
public static final String AUTHENTICATION_FORM = "authenticationForm";
public static final String PROFILE_FORM = "profileForm";
public static final String PROFILE_EDIT_FORM = "profileEditForm";
public static final String MODE = "mode";
public static final String CURRENT_COURSE_ID = "currentCourseId";
public static final String COURSE_LIST = "courseList";
public static final String COURSE_INFO_LIST = "courseInfoList";
public static final String YEAR = "year";
public static final String MONTH = "month";
public static final String DAY = "day";
public static final String PREVIOUS_YEAR = "previousYear";
public static final String PREVIOUS_MONTH = "previousMonth";
public static final String LAST_DAY = "lastDay";
public static final String FIRST_DAY_OF_WEEK = "firstDayOfWeek";
public static final String NEXT_YEAR = "nextYear";
public static final String NEXT_MONTH = "nextMonth";
public static final String TODAY = "today";
public static final String TRANSACTION_FORM_MAP = "transactionFormMap";
public static final String TRANSACTION_FORM_LIST = "transactionFormList";
public static final String TRANSACTION_FORM = "transactionForm";
public static final String TRANSACTION_ID = "transactionId";
public static final String CATEGORY_FORM_LIST = "categoryFormList";
public static final String INCOME_LIST = "incomeList";
public static final String EXPENSE_LIST = "expenseList";
public static final String TOTAL_INCOME = "totalIncome";
public static final String TOTAL_EXPENSE = "totalExpense";
public static final String ACHIEVEMENT_RATE = "achievementRate";
public static final String CURRENT_AMOUNT = "currentAmount";
public static final String TARGET_AMOUNT = "targetAmount";
public static final String SAVING = "saving";
public static final String DEADLINE = "deadline";
public static final String ANALYSIS_FORM = "analysisForm";
public static final String GOAL_FORM = "goalForm";
public static final String GOAL_FORM_LIST = "goalFormList";
public static final String ACHIEVEMENT_LIST = "achievementList";
public static final String GRAPH_GOAL = "graphGoal";
public static final String GOAL_COMPLETE_FORM_LIST = "goalCompleteFormList";
public static final String CATEGORY_ID = "categoryId";
public static final String CATEGORY_FORM = "categoryForm";
public static final String FIXED_COST_FORM_LIST = "fixedCostFormList";
}

View File

@@ -0,0 +1,12 @@
package com.example.demo.app.presentation.controller.pageproperty;
public class SessionKeyword {
// SESSION情報として格納したいログイン者の情報
public static final String LOGIN_USER = "loginUser";
public static final String SELECTED_COURSE_NAME = "selectedCourseName";
public static final String QUESTION_ID = "questionId";
public static final String T_TYPE = "tType";
}

View File

@@ -0,0 +1,104 @@
package com.example.demo.app.presentation.controller.pageproperty;
public class TransitionTargetPageNameKeyword {
// HTML
public static final String ERROR_HTML = "error";
public static final String USER_RESISTER_HTML = "user_register";
public static final String USER_RESISTER_RETURN_HTML = "user_register_return";
public static final String USER_RESISTER_CONFIRM_HTML = "user_register_confirm";
public static final String LOGIN_HTML = "login";
public static final String PASSWORD_RESET_HTML = "password_reset";
public static final String AUTHENTICATION_HTML = "authentication";
public static final String MENU_HTML = "menu";
public static final String PROFILE_HTML = "profile";
public static final String PROFILE_EDIT_HTML = "profile_edit";
public static final String SELECT_COURSE_HTML = "select_course";
public static final String COURSE_CREATE_HTML = "course_create";
public static final String COURSE_CREATE_RATIO_HTML = "course_create_ratio";
public static final String TRANSACTION_LIST_HTML = "transaction_list";
public static final String TRANSACTION_DETAIL_HTML = "transaction_detail";
public static final String TRANSACTION_CREATE_HTML = "transaction_create";
public static final String TRANSACTION_UPDATE_HTML = "transaction_update";
public static final String ANALYSIS_HTML = "analysis";
public static final String GOAL_VIEW_HTML = "goal_view";
public static final String GOAL_EDIT_HTML = "goal_edit";
public static final String GOAL_CREATE_HTML = "goal_create";
public static final String GOAL_RECORD_HTML = "goal_record";
public static final String CATEGORY_LIST_HTML = "category_list";
public static final String CATEGORY_CREATE_HTML = "category_create";
public static final String CATEGORY_UPDATE_HTML = "category_update";
public static final String FIXED_COST_HTML = "fixed_cost";
public static final String FIXED_COST_CREATE_HTML = "fixed_cost_create";
// Countroller
public static final String ERROR = "/error";
public static final String USER_RESISTER = "/user/register";
public static final String USER_RESISTER_RETURN = "/user/register/return";
public static final String USER_RESISTER_CONFIRM = "/user/register/confirm";
public static final String USER_RESISTER_COMPLETE = "/user/register/complete";
public static final String REDIRECT = "redirect:";
public static final String LOGIN = "/login";
public static final String LOGOUT = "/logout";
public static final String AUTHENTICATION = "/authentication";
public static final String PASSWORD_RESET = "/password/reset";
public static final String MENU = "/menu";
public static final String PROFILE = "/profile";
public static final String PROFILE_EDIT = "/profile/edit";
public static final String WITHDRAW = "/withdraw";
public static final String SHOW_SELECT_COURSE = "/user/register/course";
public static final String COURSE = "/course";
public static final String CHANGE = "/change";
public static final String COURSE_CREATE = "/course/create";
public static final String COURSE_CREATE_RATIO = "/course/create/ratio";
public static final String INTERROGATION = "?";
public static final String EQUAL = "=";
public static final String TRANSACTION_LIST = "/transaction/list";
public static final String TRANSACTION_DETAIL = "/transaction/detail";
public static final String TRANSACTION_CREATE = "/transaction/create";
public static final String TRANSACTION_UPDATE = "/transaction/update";
public static final String TRANSACTION_DELETE = "/transaction/delete";
public static final String TODAY_DATES = "todayDates";
public static final String ANALYSIS = "/analysis";
public static final String GOAL = "/goal";
public static final String EDIT = "/edit";
public static final String UPDATE = "/update";
public static final String CREATE = "/create";
public static final String DELETE = "/delete";
public static final String RECORD = "/record";
public static final String CATEGORY_LIST = "/category/list";
public static final String CATEGORY_CREATE = "/category/create";
public static final String CATEGORY_UPDATE = "/category/update";
public static final String CATEGORY_DELETE = "/category/delete";
public static final String FIXED_COST_LIST = "/fixed-cost/list";
public static final String FIXED_COST_CREATE = "/fixed-cost/create";
public static final String FIXED_COST_DELETE = "/fixed-cost/delete";
}

View File

@@ -0,0 +1,45 @@
package com.example.demo.app.presentation.form;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class AllocationFormList {
private Long categoryId1 = 1L;
private Integer allocationRatio1;
private Long categoryId2 = 2L;
private Integer allocationRatio2;
private Long categoryId3 = 3L;
private Integer allocationRatio3;
private Long categoryId4 = 4L;
private Integer allocationRatio4;
private Long categoryId5 = 5L;
private Integer allocationRatio5;
private Long categoryId6 = 6L;
private Integer allocationRatio6;
private Long categoryId7 = 7L;
private Integer allocationRatio7;
private Long categoryId8 = 8L;
private Integer allocationRatio8;
private Long categoryId9 = 9L;
private Integer allocationRatio9;
private Long categoryId10 = 10L;
private Integer allocationRatio10;
private Long categoryId11 = 11L;
private Integer allocationRatio11;
}

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

@@ -25,4 +25,11 @@ public class CategoryForm {
return categoryModelList.stream().map(CategoryForm::convertFrom).toList();
}
public static CategoryModel convertTo(CategoryForm categoryForm) {
return new CategoryModel(
categoryForm.getCategoryId(),
categoryForm.getCategoryName(),
categoryForm.getTransactionType());
}
}

View File

@@ -30,4 +30,12 @@ public class CourseForm {
return courseModelList.stream().map(CourseForm::convertFrom).toList();
}
public static CourseModel convertTo(CourseForm courseForm) {
return new CourseModel(
courseForm.getCourseId(),
courseForm.getCourseName(),
courseForm.getDescription()
);
}
}

View File

@@ -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<FixedCostForm> convertFrom(List<FixedCostModel> 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());
}
}

View File

@@ -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;
@@ -28,8 +29,14 @@ public class GoalForm {
private Integer goalComplete;
private String status;
private Integer achievementRate; // 達成率
private Integer currentAmount; // 現在の資産
private Long userId;
public static GoalForm convertFrom(GoalModel goalModel) {
return new GoalForm(
goalModel.getGoalId(),
@@ -38,11 +45,14 @@ public class GoalForm {
goalModel.getTargetAmount(),
goalModel.getDeadline(),
goalModel.getGoalComplete(),
goalModel.getAchievementRate());
null,
goalModel.getAchievementRate(),
goalModel.getCurrentAmount(),
goalModel.getUserId());
}
// public static List<GoalForm> convertFrom(List<GoalModel> goalModelList) {
// return goalModelList.stream().map(GoalForm::convertFrom).toList();
// }
public static List<GoalForm> convertFrom(List<GoalModel> goalModelList) {
return goalModelList.stream().map(GoalForm::convertFrom).toList();
}
}

View File

@@ -0,0 +1,17 @@
package com.example.demo.app.presentation.form;
import java.time.YearMonth;
import lombok.AllArgsConstructor;
import lombok.Data;
@Data
@AllArgsConstructor
public class MonthlyAchievementForm {
private YearMonth month;
private Integer saving;
private Integer achievementRate;
}

View File

@@ -0,0 +1,19 @@
package com.example.demo.app.presentation.form;
import java.time.YearMonth;
import lombok.AllArgsConstructor;
import lombok.Data;
@Data
@AllArgsConstructor
public class MonthlySavingForm {
private YearMonth month;
private Integer income;
private Integer expense;
private Integer saving;
}

View File

@@ -1,5 +1,7 @@
package com.example.demo.app.presentation.form;
import java.time.LocalDate;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@@ -10,6 +12,7 @@ import lombok.NoArgsConstructor;
public class ProfileEditForm {
private String userName;
private String mailAddress;
private LocalDate birthDate;
private Integer saving;
private Integer annualIncome;
private Integer monthlyBudget;

View File

@@ -14,10 +14,10 @@ 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;
@@ -29,14 +29,14 @@ public class UserForm {
return new UserForm(
userModel.getUserName(),
userModel.getMailAddress(),
userModel.getBrithDate(),
userModel.getPassword(),
userModel.getSecretQuestionId(),
userModel.getSecretAnswer(),
userModel.getBrithDate(),
userModel.getSaving(),
userModel.getAnnualIncome(),
userModel.getMonthlyBudget(),
userModel.getGoalId(),
0L,
userModel.getCourseId()
);
}

View File

@@ -1,6 +1,7 @@
body {
margin: 0;
padding: 0;
padding-top:80px;
padding-bottom:120px;
}
#calendar {

View File

@@ -0,0 +1,222 @@
/* =======================
全体
======================= */
body {
padding-top: 80px;
padding-bottom: 80px;
background-color: #f8f9fa;
}
/* =======================
コンテンツ
======================= */
.main-container {
max-width: 480px;
margin: 0 auto;
padding: 0 12px;
}
/* =======================
タイトル
======================= */
.page-title {
text-align: center;
font-weight: bold;
margin-bottom: 20px;
}
/* =======================
ヘッダー
======================= */
.app-header {
background-color: #E3F2FD;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}
.app-logo {
font-size: 1.2rem;
font-weight: bold;
}
/* =======================
フッター
======================= */
.app-footer {
background-color: #E3F2FD;
border-top: 1px solid #d0d7de;
}
.a-footer {
text-decoration: none;
}
/* =======================
カード
======================= */
.app-card {
background-color: #ffffff;
border-radius: 12px;
padding: 15px;
margin-bottom: 15px;
box-shadow: 0 2px 5px rgba(0,0,0,0.08);
}
.card {
border-radius: 12px;
margin-bottom: 12px;
}
.card-body {
padding: 12px;
}
/* =======================
カレンダー
======================= */
#calendar {
width: 100%;
border-collapse: collapse;
table-layout: fixed;
}
#calendar th,
#calendar td {
border: 1px solid black;
}
th {
font-weight: bold;
height: 35px;
font-size: 13px;
text-align: center;
}
td {
width: 14%;
height: 70px;
padding: 5px;
text-align: left;
vertical-align: top;
}
td:hover {
background-color: lightblue;
}
.holiday {
color: red;
}
#today {
font-weight: bold;
background-color: bisque;
}
.calendar-title {
display: grid;
grid-template-columns: 1fr auto 1fr;
align-items: center;
text-align: center;
}
.calendar-date {
display: flex;
align-items: baseline;
gap: 10px;
}
.year {
font-size: 20px;
}
.month {
font-size: 30px;
font-weight: bold;
}
.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;
}
.month-button:last-child {
justify-self: end;
}
.date {
font-size: 13px;
font-weight: bold;
}
.income {
color: blue;
font-size: 10px;
}
.expense {
color: red;
font-size: 10px;
}
.total {
margin: 15px 10px;
padding: 10px;
border-top: 1px solid #ddd;
font-size: 16px;
text-align: right;
}
.a-calender {
text-decoration: none;
}
/* =======================
金額表示
======================= */
.plus {
color: #dc3545;
font-weight: bold;
}
.minus {
color: #0d6efd;
font-weight: bold;
}
/* =======================
テーブル
======================= */
.table {
background-color: white;
}
.table th {
vertical-align: middle;
}
.table td {
vertical-align: middle;
}
/* =======================
ボタン
======================= */
.btn {
border-radius: 10px;
}

View File

@@ -4,17 +4,18 @@
<meta name="viewport" content="width=device-width, initial-scale=1" http-equiv="Content-Type">
<title>分析画面</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" th:href="@{/css/style.css}">
</head>
<body class="pb-5 pt-5">
<body>
<div th:replace="~{header :: header}">
</div>
<div class="container mt-4">
<h2 class="text-center">支出分析</h2>
<div class="main-container">
<h2 class="page-title">支出分析</h2>
<div class="text-center">
<div class="calendar-title">
<a class="month-button" th:href="@{/analysis(year=${previousYear}, month=${previousMonth})}">
←
@@ -34,7 +35,7 @@
<table class="table text-center">
<thead>
<tr>
<th scope="col">カテゴリ別</th>
<th scope="col"></th>
<th scope="col">支出</th>
<th scope="col">前月比</th>
</tr>
@@ -46,11 +47,11 @@
0
</td>
<td th:text="${analysisForm.totalDifferenceAmount >= 0}
? '+' + ${analysisForm.totalDifferenceAmount}
? '+' + ${analysisForm.totalDifferenceAmount}
: ${analysisForm.totalDifferenceAmount}"
th:class="${analysisForm.totalDifferenceAmount >= 0}
? 'color-danger;'
: 'color-primary;'">
? 'text-danger'
: 'text-primary'">
0
</td>
</tr>
@@ -72,28 +73,26 @@
<th scope="row"
th:text="${category.categoryName}">
食費
</th>
<td th:text="'¥' + ${category.currentMonthAmount}">
0
</td>
<td>
<span th:text="${category.monthDifferenceAmount >= 0}
? '+' + ${category.monthDifferenceAmount}
? '+' + ${category.monthDifferenceAmount}
: ${category.monthDifferenceAmount}"
th:class="${category.monthDifferenceAmount >= 0}
? 'color-danger;'
: 'color-primary;'">
? 'text-danger'
: 'text-primary'">
</span>
<br>
<span th:text="${category.courseDifferenceAmount >= 0}
? '+' + ${category.courseDifferenceAmount}
? '+' + ${category.courseDifferenceAmount}
: ${category.courseDifferenceAmount}"
th:class="${category.courseDifferenceAmount >= 0}
? 'color-danger;'
: 'color-primary;'">
? 'text-danger'
: 'text-primary'">
</span>
</td>
</tr>

View File

@@ -2,58 +2,121 @@
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<meta charset="UTF-8" name="viewport" content="width=device-width, initial-scale=1" http-equiv="Content-Type">
<title>認証</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" th:href="@{/css/style.css}">
</head>
<body class="pb-5 pt-5">
<body style="padding-top:80px; padding-bottom:80px;">
<div th:replace="~{header :: header}">
</div>
<div th:replace="~{header :: header}">
</div>
<main>
<h1>本人認証確認</h1>
<div class="main-container">
<form th:action="@{/authentication}" th:object="${authenticationForm}" method="post">
<h1 class="page-title">
本人認証
</h1>
<div>
<label for="mailAddress">メールアドレス</label>
<input type="email" id="mailAddress" th:field="*{mailAddress}">
</div>
<div class="card shadow-sm">
<div>
<label for="secretQuestionId">秘密の質問</label>
<select id="secretQuestionId" th:field="*{secretQuestionId}">
<div class="card-body">
<option value="">選択してください</option>
<form th:action="@{/authentication}"
th:object="${authenticationForm}"
method="post">
<option th:each="question : ${questionList}" th:value="${question.secretQuestionId}"
th:text="${question.questionText}">
</option>
<div class="mb-3">
</select>
</div>
<label for="mailAddress"
class="form-label">
メールアドレス
</label>
<div>
<label for="secretAnswer">秘密の質問の回答</label>
<input type="text" id="secretAnswer" th:field="*{secretAnswer}">
</div>
<input type="email"
id="mailAddress"
class="form-control"
th:field="*{mailAddress}"
required>
<button type="submit">確認</button>
</div>
</form>
<div class="mb-3">
<form th:action="@{/login}" method="get">
<button type="submit">戻る</button>
</form>
</main>
<label for="secretQuestionId"
class="form-label">
秘密の質問
</label>
<script th:if="${errorMessage}" th:inline="javascript">
alert(/*[[${errorMessage}]]*/);
</script>
<select id="secretQuestionId"
class="form-select"
th:field="*{secretQuestionId}">
<div th:replace="~{footer :: footer}">
</div>
<option value="">
選択してください
</option>
<option th:each="question : ${questionList}"
th:value="${question.secretQuestionId}"
th:text="${question.questionText}">
</option>
</select>
</div>
<div class="mb-3">
<label for="secretAnswer"
class="form-label">
秘密の質問の回答
</label>
<input type="text"
id="secretAnswer"
class="form-control"
th:field="*{secretAnswer}"
required>
</div>
<div class="d-grid gap-2">
<button type="submit"
class="btn btn-primary">
確認
</button>
</div>
</form>
</div>
</div>
<div class="d-grid mt-3">
<form th:action="@{/login}"
method="get">
<button type="submit"
class="btn btn-outline-secondary w-100">
戻る
</button>
</form>
</div>
</div>
<script th:if="${errorMessage}"
th:inline="javascript">
alert(/*[[${errorMessage}]]*/);
</script>
</body>

View File

@@ -0,0 +1,59 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" name="viewport" content="width=device-width, initial-scale=1" http-equiv="Content-Type">
<title>カテゴリ登録</title>
<link rel="stylesheet" th:href="@{/css/menu.css}">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body style="padding-top:80px; padding-bottom:80px;">
<div th:replace="~{header :: header}"></div>
<div class="main-container">
<h1 class="page-title">カテゴリ登録</h1>
<div class="card shadow-sm">
<div class="card-body">
<form th:action="@{/category/create}" th:object="${categoryForm}" method="post">
<div class="mb-3">
<label class="form-label" for="categoryName">カテゴリ名</label>
<input class="form-control" type="text" id="categoryName" th:field="*{categoryName}" required>
</div>
<br>
<div class="mb-3">
<label class="form-label" for="transactionType">収入・支出</label>
<select class="form-select" id="transactionType" th:field="*{transactionType}" required>
<option value="">選択してください</option>
<option value="0">支出</option>
<option value="1">収入</option>
</select>
</div>
<br>
<div class="d-grid">
<button type="submit" class="btn btn-primary">登録</button>
</div>
</form>
</div>
</div>
</div>
<div th:replace="~{footer :: footer}"></div>
</body>
</html>

View File

@@ -0,0 +1,79 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8" name="viewport" content="width=device-width, initial-scale=1" http-equiv="Content-Type">
<title>カテゴリ一覧</title>
<link rel="stylesheet" th:href="@{/css/transaction_detail.css}">
<link rel="stylesheet" th:href="@{/css/style.css}">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body style="padding-top:80px; padding-bottom:80px;">
<div th:replace="~{header :: header}"></div>
<div class="main-container">
<div>
<ul class="list-unstyled p-0 m-0">
<li class="card shadow-sm mb-3" th:each="categoryForm : ${categoryFormList}">
<div class="card-body">
<div class="d-flex justify-content-between">
<p>
カテゴリ名:
<span class="fw-bold" th:text="${categoryForm.categoryName}"></span>
<br>
収支区分:
<span class="fw-bold" th:if="${categoryForm.transactionType == 0}"
th:text="|支出|"></span>
<span class="fw-bold" th:if="${categoryForm.transactionType == 1}"
th:text="|収入|"></span>
</p>
</div>
<div class="d-flex justify-content-end gap-2 mt-3">
<form th:action="@{/category/update}" method="get">
<input type="hidden" name="today" th:value="${today}">
<input type="hidden" name="categoryId" th:value="${categoryForm.categoryId}">
<button type="submit" class="btn btn-sm btn-primary">編集</button>
</form>
<form th:action="@{/category/delete}" method="post">
<input type="hidden" name="today" th:value="${today}">
<input type="hidden" name="categoryId" th:value="${categoryForm.categoryId}">
<button type="submit" class="btn btn-sm btn-danger">削除</button>
</form>
</div>
</div>
</li>
</ul>
</div>
<div class="d-grid mt-4">
<form th:action="@{/category/create}" method="get">
<input type="hidden"
name="today"
id="today"
th:value="${today}">
<button class="btn btn-success w-100" type="submit">
新規登録
</button>
</form>
</div>
</div>
<div th:replace="~{footer :: footer}"></div>
</body>
</html>

View File

@@ -0,0 +1,62 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" name="viewport" content="width=device-width, initial-scale=1" http-equiv="Content-Type">
<title>カテゴリ登録</title>
<link rel="stylesheet" th:href="@{/css/menu.css}">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body style="padding-top:80px; padding-bottom:80px;">
<div th:replace="~{header :: header}"></div>
<div class="main-container">
<h1 class="page-title">カテゴリ編集</h1>
<div class="card shadow-sm">
<div class="card-body">
<form th:action="@{/category/update}" th:object="${categoryForm}" method="post">
<div class="mb-3">
<label class="form-label" for="categoryName">カテゴリ名</label>
<input class="form-control" type="text" id="categoryName" th:field="*{categoryName}" required>
</div>
<br>
<div class="mb-3">
<label class="form-label" for="transactionType">収入・支出</label>
<select class="form-select" id="transactionType" th:field="*{transactionType}" required>
<option value="">選択してください</option>
<option value="0">支出</option>
<option value="1">収入</option>
</select>
</div>
<br>
<input type="hidden" name="categoryId" th:value="${categoryId}">
<div class="d-grid">
<button type="submit" class="btn btn-primary">更新</button>
</div>
</form>
</div>
</div>
</div>
<div th:replace="~{footer :: footer}"></div>
</body>
</html>

View File

@@ -0,0 +1,54 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" name="viewport" content="width=device-width, initial-scale=1" http-equiv="Content-Type">
<title>コース登録</title>
<link rel="stylesheet" th:href="@{/css/menu.css}">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body style="padding-top:80px; padding-bottom:80px;">
<div th:replace="~{header :: header}"></div>
<div class="main-container">
<h1 class="page-title">コース登録</h1>
<div class="card shadow-sm">
<div class="card-body">
<form th:action="@{/course/create/ratio}" th:object="${courseForm}" method="post">
<div class="mb-3">
<label class="form-label" for="courseName">コース名</label>
<input class="form-control" type="text" id="courseName" th:field="*{courseName}" required>
</div>
<br>
<div class="mb-3">
<label class="form-label" for="description">説明</label>
<textarea class="form-control" id="description" th:field="*{description}"
placeholder="説明を入力してください">
</textarea>
</div>
<br>
<div class="d-grid">
<button type="submit" class="btn btn-primary">登録</button>
</div>
</form>
</div>
</div>
</div>
<div th:replace="~{footer :: footer}"></div>
</body>
</html>

View File

@@ -0,0 +1,135 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" name="viewport" content="width=device-width, initial-scale=1" http-equiv="Content-Type">
<title>コース登録</title>
<link rel="stylesheet" th:href="@{/css/menu.css}">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body style="padding-top:80px; padding-bottom:120px;">
<div th:replace="~{header :: header}"></div>
<div class="main-container">
<h1 class="page-title">コース登録</h1>
<div class="card shadow-sm">
<div class="card-body">
<form th:action="@{/course/create}" th:object="${allocationFormList}" method="post">
<div class="mb-3">
<label class="form-label" for="allocationRatio4">固定費</label>
<input class="form-control" type="number" min="0" max="100" onchange="inputChange()"
id="allocationRatio4" th:field="*{allocationRatio4}" required>
</div>
<br>
<div class="mb-3">
<label class="form-label" for="allocationRatio5">食費</label>
<input class="form-control" type="number" min="0" max="100" onchange="inputChange()"
id="allocationRatio5" th:field="*{allocationRatio5}" required>
</div>
<br>
<div class="mb-3">
<label class="form-label" for="allocationRatio6">交通費</label>
<input class="form-control" type="number" min="0" max="100" onchange="inputChange()"
id="allocationRatio6" th:field="*{allocationRatio6}" required>
</div>
<br>
<div class="mb-3">
<label class="form-label" for="allocationRatio7">日用品費</label>
<input class="form-control" type="number" min="0" max="100" onchange="inputChange()"
id="allocationRatio7" th:field="*{allocationRatio7}" required>
</div>
<br>
<div class="mb-3">
<label class="form-label" for="allocationRatio8">被服/美容費</label>
<input class="form-control" type="number" min="0" max="100" onchange="inputChange()"
id="allocationRatio8" th:field="*{allocationRatio8}" required>
</div>
<br>
<div class="mb-3">
<label class="form-label" for="allocationRatio9">医療費</label>
<input class="form-control" type="number" min="0" max="100" onchange="inputChange()"
id="allocationRatio9" th:field="*{allocationRatio9}" required>
</div>
<br>
<div class="mb-3">
<label class="form-label" for="allocationRatio10">趣味/娯楽費</label>
<input class="form-control" type="number" min="0" max="100" onchange="inputChange()"
id="allocationRatio10" th:field="*{allocationRatio10}" required>
</div>
<br>
<div class="mb-3">
<label class="form-label" for="allocationRatio11">その他</label>
<input class="form-control" type="number" min="0" max="100" onchange="inputChange()"
id="allocationRatio11" th:field="*{allocationRatio11}" required>
</div>
<div class="mb-3">
<label class="form-label" for="allocationRatioTotal">合計(%)</label>
<input class="form-control" type="number" value="0" id="allocationRatioTotal" readonly>
</div>
<br>
<div class="d-grid">
<button type="submit" class="btn btn-primary" id="submit" disabled="true">登録</button>
</div>
<span th:object="${courseForm}">
<input type="hidden" id="courseName" th:field="*{courseName}" required>
<br>
<input type="hidden" id="description" th:field="*{description}">
</span>
</div>
</div>
</div>
</div>
<div th:replace="~{footer :: footer}"></div>
<script>
function inputChange() {
let total = 0;
for (let i = 4; i <= 11; i++) {
total += Number(document.getElementById(`allocationRatio${i}`).value || 0);
if (total == 100) {
document.getElementById('submit').disabled = false;
} else {
document.getElementById('submit').disabled = true;
}
}
document.getElementById("allocationRatioTotal").value = total;
}
</script>
</body>
</html>

View File

@@ -7,12 +7,6 @@
</head>
<body class="pb-5 pt-5">
<div th:replace="~{header :: header}">
</div>
</head>
<body>
<div th:replace="~{header :: header}">
</div>

View File

@@ -0,0 +1,81 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8" name="viewport" content="width=device-width, initial-scale=1" http-equiv="Content-Type">
<title>固定費詳細</title>
<link rel="stylesheet" th:href="@{/css/transaction_detail.css}">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" th:href="@{/css/style.css}">
</head>
<body style="padding-top:80px; padding-bottom:80px;">
<div th:replace="~{header :: header}"></div>
<div class="main-container">
<h2 class="page-title" th:text="${today}"></h2>
<div>
<ul class="list-unstyled p-0 m-0">
<li th:each="fixedCostForm : ${fixedCostFormList}" class="card shadow-sm mb-3">
<div class="card-body">
<div class="d-flex justify-content-between">
<p>
カテゴリ名:
<span class="fw-bold" th:text="${fixedCostForm.categoryName}"></span>
<br>
固定費名:
<span class="fw-bold" th:text="${fixedCostForm.fixedCostName}"></span>
<br>
金額:
<span class="fw-bold" th:text="${fixedCostForm.amount}"></span>
</p>
</div>
<div class="d-flex justify-content-end gap-2 mt-3">
<form th:action="@{/transaction/create}" method="get">
<input type="hidden" name="fixedCostId" th:value="${fixedCostForm.fixedCostId}">
<input type="hidden" name="today" th:value="${today}">
<button type="submit" class="btn btn-sm btn-primary">登録</button>
</form>
<form th:action="@{/fixed-cost/delete}" method="post">
<input type="hidden" name="fixedCostId" th:value="${fixedCostForm.fixedCostId}">
<input type="hidden" name="today" th:value="${today}">
<button type="submit" class="btn btn-sm btn-danger">削除</button>
</form>
</div>
</div>
</li>
</ul>
</div>
<div class="d-grid mt-4">
<form th:action="@{/fixed-cost/create}" method="get">
<input type="hidden"
name="today"
id="today"
th:value="${today}">
<button class="btn btn-success w-100" type="submit">
新規登録
</button>
</form>
</div>
</div>
<div th:replace="~{footer :: footer}"></div>
</body>
</html>

View File

@@ -0,0 +1,137 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" name="viewport" content="width=device-width, initial-scale=1" http-equiv="Content-Type">
<title>固定費登録</title>
<link rel="stylesheet" th:href="@{/css/menu.css}">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body style="padding-top:80px; padding-bottom:80px;">
<div th:replace="~{header :: header}"></div>
<div class="main-container">
<h1 class="page-title">
固定費登録
</h1>
<div class="card shadow-sm">
<div class="card-body">
<form th:action="@{/fixed-cost/create}" th:object="${fixedCostForm}" method="post">
<div class="mb-3">
<label class="form-label" for="fixedCostName">固定費名</label>
<input class="form-control" type="text" id="fixedCostName" th:field="*{fixedCostName}" required>
</div>
<div class="mb-3">
<label class="form-label" for="transactionType">収入・支出</label>
<select class="form-select" id="transactionType" required>
<option value="">選択してください</option>
<option value="0">支出</option>
<option value="1">収入</option>
</select>
</div>
<br>
<div class="mb-3">
<label class="form-label" for="categoryId">カテゴリ</label>
<select class="form-select" id="categoryId" th:field="*{categoryId}" required>
<option value="">選択してください</option>
<option class="expenseListClass" th:each="category : ${expenseList}"
th:value="${category.categoryId}" th:text="${category.categoryName}">
</option>
<option class="incomeListClass" th:each="category : ${incomeList}"
th:value="${category.categoryId}" th:text="${category.categoryName}">
</option>
</select>
</div>
<br>
<div class="mb-3">
<label class="form-label" for="amount">金額</label>
<input class="form-control" type="number" id="amount" th:field="*{amount}" min="1" placeholder="金額を入力してください"
required>
</div>
<br>
<input type="hidden" name="today" id="today" th:value="${today}">
<div class="d-grid">
<button class="btn btn-primary" type="submit">登録</button>
</div>
</form>
<div th:replace="~{footer :: footer}"></div>
<script>
const transactionType = document.getElementById("transactionType");
const categoryId = document.getElementById("categoryId");
const expenseList = document.getElementsByClassName("expenseListClass");
const incomeList = document.getElementsByClassName("incomeListClass");
transactionType.addEventListener("change", function () {
if (this.value === "0") {
for (let i = 0; i < expenseList.length; i++) {
expenseList[i].style.display = "";
}
for (let i = 0; i < incomeList.length; i++) {
incomeList[i].style.display = "none";
}
} else if (this.value === "1") {
for (let i = 0; i < expenseList.length; i++) {
expenseList[i].style.display = "none";
}
for (let i = 0; i < incomeList.length; i++) {
incomeList[i].style.display = "";
}
} else {
for (let i = 0; i < expenseList.length; i++) {
expenseList[i].style.display = "none";
}
for (let i = 0; i < incomeList.length; i++) {
incomeList[i].style.display = "none";
}
}
categoryId.value = "";
});
</script>
</body>
</html>

View File

@@ -4,32 +4,33 @@
<meta charset="UTF-8" name="viewport" content="width=device-width, initial-scale=1">
<title>フッター</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" th:href="@{/css/style.css}">
</head>
<body>
<footer th:fragment="footer" class="fixed-bottom border-top py-2" style="background-color:#E3F2FD;">
<footer th:fragment="footer" class="fixed-bottom border-top py-2 app-footer" style="background-color:#E3F2FD;">
<nav data-bs-theme="light">
<div class="card-footer text-center">
<div class="row">
<div class="col border-end">
<button type="button" class="btn btn-link text-black text-decoration-none">
<a th:href="@{/transaction/create}">入力</a>
<a th:href="@{/transaction/create}" class="a-footer">入力</a>
</button>
</div>
<div class="col border-end">
<button type="button" class="btn btn-link text-black text-decoration-none">
<a th:href="@{/transaction/list}">一覧</a>
<a th:href="@{/transaction/list}" class="a-footer">一覧</a>
</button>
</div>
<div class="col border-end">
<button type="button" class="btn btn-link text-black text-decoration-none">
<a th:href="@{/analysis}">分析</a>
<a th:href="@{/analysis}" class="a-footer">分析</a>
</button>
</div>
<div class="col border-end">
<button type="button" class="btn btn-link text-black text-decoration-none">
<a th:href="@{/goal}">目標</a>
<a th:href="@{/goal}" class="a-footer">目標</a>
</button>
</div>
</div>

View File

@@ -0,0 +1,63 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8" name="viewport" content="width=device-width, initial-scale=1" http-equiv="Content-Type">
<title>目標作成</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" th:href="@{/css/style.css}">
</head>
<body style="padding-top:80px; padding-bottom:80px;">
<div th:replace="~{header :: header}"></div>
<div class="main-container">
<h1 class="page-title">目標作成</h1>
<div class="card shadow-sm">
<div class="card-body">
<form th:action="@{/goal/create}" th:object="${goalForm}" method="post">
<input type="hidden" th:field="*{goalId}">
<div>
<label>目標名</label>
<input type="text" th:field="*{goalTitle}">
</div>
<div>
<label>目標説明</label>
<textarea th:field="*{goalSubtitle}"></textarea>
</div>
<div>
<label>目標金額</label>
<input type="number" th:field="*{targetAmount}" required min="1">
<span th:text="|所持金:${currentAmount}円|"></span>
<span th:if="${message != null}">
<span th:text="${message}" style="color: red;"></span>
</span>
</div>
<div>
<label>目標達成期限</label>
<input type="date" th:field="*{deadline}"
th:min="${#temporals.format(#temporals.createNow(), 'yyyy-MM-dd')}" required>
</div>
<button type="submit" class="btn btn-sm btn-primary w-100">登録</button>
</form>
</div>
</div>
</div>
<div th:replace="~{footer :: footer}"></div>
</body>
</html>

View File

@@ -1,43 +1,60 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<meta charset="UTF-8" name="viewport" content="width=device-width, initial-scale=1" http-equiv="Content-Type">
<title>目標編集</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" th:href="@{/css/style.css}">
</head>
<body class="pb-5 pt-5">
<body style="padding-top:80px; padding-bottom:80px;">
<div th:replace="~{header :: header}"></div>
<h1>目標編集</h1>
<div class="main-container">
<form th:action="@{/goal/update}" th:object="${goalForm}" method="post">
<input type="hidden" th:field="*{goalId}">
<h1 class="page-title">目標編集</h1>
<div class="card shadow-sm">
<div class="card-body">
<form th:action="@{/goal/update}" th:object="${goalForm}" method="post">
<input type="hidden" th:field="*{goalId}">
<div>
<label>目標名</label>
<input type="text" th:field="*{goalTitle}">
</div>
<div>
<label>目標説明</label>
<textarea th:field="*{goalSubtitle}"></textarea>
</div>
<div>
<label>目標金額</label>
<input type="number" th:field="*{targetAmount}" min="1" max="1000000000" required>
</div>
<div>
<label>目標達成期限</label>
<input type="date" th:field="*{deadline}" th:min="${#temporals.format(#temporals.createNow(), 'yyyy-MM-dd')}" required>
</div>
<div>
<input type="hidden" th:field="*{goalComplete}">
</div>
<button type="submit" class="btn btn-sm btn-primary w-100">更新する</button>
</form>
<div>
<label>目標名</label>
<input type="text" th:field="*{goalTitle}" required>
</div>
</div>
<div>
<label>目標説明</label>
<textarea th:field="*{goalSubtitle}" required></textarea>
</div>
<div>
<label>目標金額</label>
<input type="number" th:field="*{targetAmount}" required min="1">
</div>
<div>
<label>目標達成期限</label>
<input type="date" th:field="*{deadline}" th:min="${#temporals.format(#temporals.createNow(), 'yyyy-MM-dd')}" required>
</div>
<button type="submit">更新する</button>
</form>
</div>
<div th:replace="~{footer :: footer}"></div>

View File

@@ -0,0 +1,100 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8" name="viewport" content="width=device-width, initial-scale=1" http-equiv="Content-Type">
<title>目標履歴</title>
<link rel="stylesheet" th:href="@{/css/style.css}">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body style="padding-top:80px; padding-bottom:80px;">
<div th:replace="~{header :: header}"></div>
<div class="main-container">
<h2 class="page-title">目標履歴</h2>
<div class="card shadow-sm mb-3">
<div class="card-body">
<ul>
<li th:each="goalForm : ${goalCompleteFormList}" class="transaction-item">
<div class="d-flex justify-content-between">
<p>
目標名:
<span class="fw-bold" th:text="${goalForm.goalTitle}">
</span>
<br>
目標説明:
<span class="fw-bold" th:text="${goalForm.goalSubtitle}">
</span>
<br>
目標金額:
<span class="fw-bold" th:text="${goalForm.targetAmount}">
</span>
<br>
目標達成期限:
<span class="fw-bold" th:text="${goalForm.deadline}">
</span>
<br>
状態:
<span class="fw-bold" th:text="${goalForm.status}">
</span>
<br>
</p>
</form>
</div>
<div class="d-flex justify-content-end gap-2 mt-3">
<form th:action="@{/goal/delete}" method="post">
<input type="hidden" name="goalId" th:value="${goalForm.goalId}">
<input type="hidden" name="record" th:value="1">
<button class="btn btn-sm btn-danger" type="submit">
削除
</button>
</form>
</div>
</li>
</ul>
</div>
</div>
<div class="d-grid mt-4">
<form th:action="@{/goal}" method="get">
<button class="btn btn-success w-100" type="submit">
戻る
</button>
</form>
</div>
</div>
<div th:replace="~{footer :: footer}"></div>
</body>
</html>

View File

@@ -1,49 +1,216 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<meta charset="UTF-8" name="viewport" content="width=device-width, initial-scale=1" http-equiv="Content-Type">
<title>目標詳細</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" th:href="@{/css/style.css}">
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/4.4.0/chart.umd.min.js"></script>
</head>
<body class="pb-5 pt-5">
<body style="padding-top:80px; padding-bottom:80px;">
<div th:replace="~{header :: header}"></div>
<div class="main-container">
<h1>目標詳細</h1>
<h1 class="page-title">目標詳細</h1>
<table>
<div th:if="${graphGoal != null}">
<tr>
<th>目標名</th>
<td th:text="${goalForm.goalTitle}"></td>
</tr>
<h2 th:text="${graphGoal.goalTitle}"></h2>
<tr>
<th>目標説明</th>
<td th:text="${goalForm.goalSubtitle}"></td>
</tr>
<tr>
<th>目標金額</th>
<td th:text="${goalForm.targetAmount}"></td>
</tr>
<tr>
<th>目標達成期限</th>
<td th:text="${goalForm.deadline}"></td>
</tr>
<p>
目標金額:
<span th:text="${graphGoal.targetAmount}"></span>
</p>
<tr>
<th>達成率</th>
<td th:text="${goalForm.achievementRate} + '%'"></td>
</tr>
</div>
<div class="card shadow-sm mb-3">
</table>
<div style="height: 400px;">
<canvas id="myChart"></canvas>
</div>
<a th:href="@{/goal/edit}">編集する</a>
</div>
<script th:inline="javascript">
const months =
/*[[${achievementList.![month.monthValue]}]]*/[];
const achievementRates =
/*[[${achievementList.![achievementRate]}]]*/[];
const labels =
months.map(month => month + '月');
const myCt =
document.getElementById('myChart');
const myChart =
new Chart(myCt, {
type: 'bar',
data: {
labels: labels,
datasets: [
{
label: '達成率',
data: achievementRates,
backgroundColor:
'rgba(54, 162, 235, 0.5)',
borderColor:
'rgba(54, 162, 235, 1)',
borderWidth: 1
}
]
},
options: {
responsive: true,
maintainAspectRatio: false,
scales: {
y: {
beginAtZero: true,
max: 100,
ticks: {
callback: function (value) {
return value + '%';
}
}
}
}
}
});
</script>
<ul>
<li th:each="goalForm : ${goalFormList}">
<div class="d-flex justify-content-between">
<form th:action="@{/goal}" method="get" class="w-100">
<div class="table-responsive">
<table class="table mb-0">
<input type="radio" name="goalId" th:value="${goalForm.goalId}"
th:checked="${graphGoal != null and graphGoal.goalId == goalForm.goalId}"
onchange="this.form.submit()">
<tr>
<th>目標名</th>
<td th:text="${goalForm.goalTitle}"></td>
</tr>
<tr>
<th>目標説明</th>
<td th:text="${goalForm.goalSubtitle}"></td>
</tr>
<tr>
<th>目標金額</th>
<td th:text="${goalForm.targetAmount}"></td>
</tr>
<tr>
<th>目標達成期限</th>
<td th:text="${goalForm.deadline}"></td>
</tr>
<tr>
<th>達成率</th>
<td th:text="${goalForm.achievementRate} + '%'"></td>
</tr>
</table>
</div>
</form>
</div>
<div class="d-flex justify-content-end gap-2 mt-3">
<form th:action="@{/goal/edit}" method="get">
<input type="hidden" name="goalId" th:value="${goalForm.goalId}">
<button type="submit" class="btn btn-sm btn-primary">
編集
</button>
</form>
<form th:action="@{/goal/delete}" method="post">
<input type="hidden" name="goalId" th:value="${goalForm.goalId}">
<button type="submit" class="btn btn-sm btn-danger">
削除
</button>
</form>
</div>
</li>
</ul>
</div>
<div class="d-grid gap-2 mt-4">
<form th:action="@{/goal/create}" method="get">
<button type="submit" class="btn btn-success w-100">
新規登録
</button>
</form>
<form th:action="@{/goal/record}" method="get">
<button type="submit" class="btn btn-sm btn-primary w-100">
履歴
</button>
</form>
</div>
<div th:replace="~{footer :: footer}"></div>
</body>
</html>

View File

@@ -1,29 +1,34 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8" name="viewport" content="width=device-width, initial-scale=1">
<title>ヘッダー</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
<meta charset="UTF-8" name="viewport" content="width=device-width, initial-scale=1">
<title>ヘッダー</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" th:href="@{/css/style.css}">
</head>
<body>
<header th:fragment="header" class="fixed-top">
<nav class="navbar" style="background-color: #e3f2fd;" data-bs-theme="light">
<div class="container-fluid">
<a th:href="@{/menu}" class="navbar-brand fw-bold">Monegement</a>
<div class="d-flex gap-2">
<a class="btn btn-outline-primary btn-sm" th:href="@{/course}">
コース
</a>
<a class="btn btn-outline-secondary btn-sm" th:href="@{/profile}">
プロフィール
</a>
<nav class="navbar app-header" style="background-color: #e3f2fd;" data-bs-theme="light">
<div class="container-fluid">
<a th:href="@{/menu}" class="navbar-brand fw-bold">Monegement</a>
<div class="d-flex gap-2" th:if="${session.loginUser != null}">
<a class="btn btn-outline-primary btn-sm" th:href="@{/course}">
コース
</a>
<a class="btn btn-outline-secondary btn-sm" th:href="@{/profile}">
プロフィール
</a>
</div>
</div>
</div>
</nav>
</header>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>

View File

@@ -1,48 +1,101 @@
<!DOCTYPE html>
<html lang="ja"xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<meta charset="UTF-8" name="viewport" content="width=device-width, initial-scale=1" http-equiv="Content-Type">
<title>ログイン</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" th:href="@{/css/style.css}">
</head>
<body class="pb-5 pt-5">
<div th:replace="~{header :: header}">
</div>
<body style="padding-top:80px; padding-bottom:80px;">
<main>
<h1>ログイン</h1>
<div th:replace="~{header :: header}">
</div>
<div th:if="${errorMessage}" th:text="${errorMessage}"></div>
<form th:action="@{/login}" th:object="${loginForm}" method="post">
<div>
<label for="mailAddress">メールアドレス</label>
<div class="main-container">
<input type="email"
id="mailAddress"
th:field="*{mailAddress}"
required>
</div>
<h1 class="page-title">
ログイン
</h1>
<div>
<label for="password">パスワード</label>
<div class="card shadow-sm">
<input type="password"
id="password"
th:field="*{password}"
required>
</div>
<div class="card-body">
<div>
<button type="submit">ログイン</button>
</div>
</form>
<div th:if="${errorMessage}"
class="alert alert-danger">
<div>
<a th:href="@{user/register}">新規会員登録</a>
</div>
<span th:text="${errorMessage}">
</span>
</div>
<form th:action="@{/login}"
th:object="${loginForm}"
method="post">
<div class="mb-3">
<label for="mailAddress"
class="form-label">
メールアドレス
</label>
<input type="email"
id="mailAddress"
class="form-control"
th:field="*{mailAddress}"
required>
</div>
<div class="mb-3">
<label for="password"
class="form-label">
パスワード
</label>
<input type="password"
id="password"
class="form-control"
th:field="*{password}"
required>
</div>
<div class="d-grid">
<button type="submit"
class="btn btn-primary">
ログイン
</button>
</div>
</form>
</div>
</div>
<div class="text-center mt-3">
<a th:href="@{/user/register}">
新規会員登録
</a>
</div>
<div class="text-center mt-2">
<a th:href="@{/authentication}">
パスワードを忘れた方
</a>
</div>
</div>
<div>
<a th:href="@{/authentication}">パスワードを忘れた方</a>
</div>
</main>
</body>
</html>

View File

@@ -8,13 +8,12 @@
<title>Calendar</title>
<link rel="stylesheet" th:href="@{/css/menu.css}">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" th:href="@{/css/style.css}">
</head>
<body class="pb-5 pt-5">
<body>
<div th:replace="~{header :: header}"></div>
@@ -64,7 +63,7 @@
<a th:if="${week * 7 + weekDay - firstDayOfWeek + 1 >= 1
and week * 7 + weekDay - firstDayOfWeek + 1 <= lastDay}" th:href="@{/transaction/detail(
todayDates=${T(java.time.LocalDate).of(year, month, week * 7 + weekDay - firstDayOfWeek + 1)}
)}">
)}" class="a-footer">
<div
@@ -97,44 +96,67 @@
</table>
<div class="total">
<div class="card shadow-sm mb-3">
<div>
<span>収入:</span>
<span th:text="${totalIncome}"></span>
<span>円</span>
</div>
<div class="card-body">
<div>
<span>支出:</span>
<span th:text="${totalExpense}"></span>
<span>円</span>
</div>
<div class="d-flex justify-content-between mb-2">
<span>収入</span>
<span th:text="'¥' + ${totalIncome}"></span>
</div>
<div class="d-flex justify-content-between">
<span>支出</span>
<span th:text="'¥' + ${totalExpense}"></span>
</div>
</div>
</div>
<div>
<span>目標貯金</span>
<span th:text="${targetAmount}"></span>
<span>円</span>
</div>
<div>
<span>貯金額</span>
<span th:text="${saving}"></span>
<span>円</span>
<hr class="border border-primary border-2 opacity-50">
<div class="card shadow-sm mb-3">
<div class="card-body">
<div class="d-flex justify-content-between mb-2">
<span>目標資金</span>
<span th:text="'¥' + ${targetAmount}"></span>
</div>
<div class="d-flex justify-content-between mb-2">
<span>現在高</span>
<span th:text="'¥' + ${currentAmount}"></span>
</div>
<div class="d-flex justify-content-between">
<span>貯金額</span>
<span th:text="'¥' + ${saving}"></span>
</div>
</div>
</div>
<hr>
<div class="card shadow-sm">
<div class="card-body">
<div class="d-flex justify-content-between mb-2">
<span>達成率</span>
<span th:text="${achievementRate} + '%'"
class="badge bg-success">
</span>
</div>
<div class="d-flex justify-content-between">
<span>達成期限</span>
<span th:text="${deadline}"></span>
</div>
</div>
<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>

View File

@@ -1,43 +1,95 @@
<!DOCTYPE html>
<html lang="ja"xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<meta charset="UTF-8" name="viewport" content="width=device-width, initial-scale=1" http-equiv="Content-Type">
<title>パスワード再設定</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" th:href="@{/css/style.css}">
</head>
<body class="pb-5 pt-5">
<div th:replace="~{header :: header}">
</div>
<body style="padding-top:80px; padding-bottom:80px;">
<main>
<h1>パスワード再設定</h1>
<div th:replace="~{header :: header}">
</div>
<form th:action="@{/password_reset}" th:object="${passwordResetForm}" method="post">
<div>
<label for="password">新しいパスワード</label>
<input type="password"
id="password"
th:field="*{password}"
minlength="8"
maxlength="255"
required>
</div>
<div class="main-container">
<div>
<label for="passwordConfirm">パスワード確認</label>
<input type="password"
id="passwordConfirm"
th:field="*{passwordConfirm}"
minlength="8"
maxlength="255"
required>
</div>
<h1 class="page-title">
パスワード再設定
</h1>
<button type="submit">再設定</button>
</form>
<div class="card shadow-sm">
<div class="card-body">
<form th:action="@{/password/reset}"
th:object="${passwordResetForm}"
method="post">
<div class="mb-3">
<label for="password"
class="form-label">
新しいパスワード
</label>
<input type="password"
id="password"
class="form-control"
th:field="*{password}"
minlength="8"
maxlength="24"
required>
</div>
<div class="mb-3">
<label for="passwordConfirm"
class="form-label">
パスワード確認
</label>
<input type="password"
id="passwordConfirm"
class="form-control"
th:field="*{passwordConfirm}"
minlength="8"
maxlength="24"
required>
</div>
<span th:if="${message != null}">
<h4 th:text="${message}" style="color: red;"></h4>
</span>
<div class="d-grid">
<button type="submit"
class="btn btn-primary">
再設定
</button>
</div>
</form>
</div>
</div>
<div th:if="${Message}"
class="alert alert-danger mt-3">
<span th:text="${Message}">
</span>
</div>
</div>
<div th:if="${errorMessage}">
<p th:text="${errorMessage}"></p>
</div>
</main>
</body>
</html>

View File

@@ -1,67 +1,110 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<meta charset="UTF-8" name="viewport" content="width=device-width, initial-scale=1" http-equiv="Content-Type">
<title>プロフィール</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" th:href="@{/css/style.css}">
</head>
<body class="pb-5 pt-5">
<body>
<div th:replace="~{header :: header}">
</div>
<main>
<div>
<p>氏名</p>
<p th:text="${profileForm.userName}"></p>
</div>
<div class="main-container">
<div>
<p>メールアドレス</p>
<p th:text="${profileForm.mailAddress}"></p>
</div>
<h2 class="page-title">
プロフィール
</h2>
<div>
<p>生年月日</p>
<p th:text="${profileForm.birthDate}"></p>
</div>
<div class="card shadow-sm">
<div>
<p>パスワード</p>
<form th:action="@{/password/reset}" method="get">
<button type="submit">パスワード再設定</button>
</form>
</div>
<div class="card-body">
<div>
<p>貯蓄金</p>
<p th:text="${profileForm.saving}"></p>
</div>
<table class="table mb-0">
<div>
<p>年収</p>
<p th:text="${profileForm.annualIncome}"></p>
</div>
<tbody>
<div>
<p>月別使用可能額</p>
<p th:text="${profileForm.monthlyBudget}"></p>
</div>
<tr>
<th>氏名</th>
<td th:text="${profileForm.userName}"></td>
</tr>
<div>
<form th:action="@{/profile/edit}" method="get">
<button type="submit">編集</button>
</form>
</div>
<tr>
<th>メールアドレス</th>
<td th:text="${profileForm.mailAddress}"></td>
</tr>
<form th:action="@{/logout}" method="post">
<button type="submit">ログアウト</button>
</form>
<tr>
<th>生年月日</th>
<td th:text="${profileForm.birthDate}"></td>
</tr>
<form th:action="@{/withdraw}" method="post"
onsubmit="return confirm('本当に脱退しますか?');">
<button type="submit">脱退</button>
</form>
</main>
<tr>
<th>貯蓄金</th>
<td th:text="'¥' + ${profileForm.saving}"></td>
</tr>
<tr>
<th>年収</th>
<td th:text="'¥' + ${profileForm.annualIncome}"></td>
</tr>
<tr>
<th>月別使用可能額</th>
<td th:text="'¥' + ${profileForm.monthlyBudget}"></td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="d-grid gap-2 mt-4">
<form th:action="@{/profile/edit}" method="get">
<button class="btn btn-primary w-100"
type="submit">
編集
</button>
</form>
<form th:action="@{/password/reset}" method="get">
<button class="btn btn-outline-primary w-100"
type="submit">
パスワード再設定
</button>
</form>
<form th:action="@{/logout}" method="post">
<button class="btn btn-secondary w-100"
type="submit">
ログアウト
</button>
</form>
<form th:action="@{/withdraw}"
method="post"
onsubmit="return confirm('本当に脱退しますか?');">
<button class="btn btn-danger w-100"
type="submit">
脱退
</button>
</form>
</div>
<div th:replace="~{footer :: footer}">
</div>

View File

@@ -1,70 +1,121 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<meta charset="UTF-8" name="viewport" content="width=device-width, initial-scale=1" http-equiv="Content-Type">
<title>プロフィール編集</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" th:href="@{/css/style.css}">
</head>
<body class="pb-5 pt-5">
<body>
<div th:replace="~{header :: header}">
</div>
<main>
<h1>プロフィール編集</h1>
<div class="main-container">
<form th:action="@{/profile/edit}"th:object="${profileEditForm}"method="post">
<div>
<label>氏名</label>
<input type="text"
th:field="*{userName}"
maxlength="100"
required>
</div>
<h1 class="page-title">
プロフィール編集
</h1>
<div>
<label>メールアドレス</label>
<input type="email"
th:field="*{mailAddress}"
maxlength="255"
required>
</div>
<div class="card shadow-sm">
<div>
<label>パスワード</label>
<input type="password"
value="********"
disabled>
</div>
<form th:action="@{/profile/edit}"
th:object="${profileEditForm}"
method="post">
<div>
<label>貯蓄金</label>
<input type="number"
th:field="*{saving}"
min="0"
required>
</div>
<div class="card-body">
<div>
<label>年収</label>
<input type="number"
th:field="*{annualIncome}"
min="0"
required>
</div>
<div class="mb-3">
<label class="form-label">
氏名
</label>
<div>
<label>月別使用可能額</label>
<input type="number"
th:field="*{monthlyBudget}"
min="0"
required>
</div>
<input type="text"
class="form-control"
th:field="*{userName}"
maxlength="100"
required>
</div>
<div>
<button type="submit">確認</button>
</div>
</form>
</main>
<div class="mb-3">
<label class="form-label">
メールアドレス
</label>
<input type="email"
class="form-control"
th:field="*{mailAddress}"
maxlength="255"
required>
</div>
<div class="mb-3">
<label class="form-label">
生年月日
</label>
<input type="date"
class="form-control"
id="birthDate"
name="birthDate"
th:value="*{birthDate}"
required>
</div>
<div class="mb-3">
<label class="form-label">
貯蓄金
</label>
<input type="number"
class="form-control"
th:field="*{saving}"
min="0"
max="1000000000"
required>
</div>
<div class="mb-3">
<label class="form-label">
年収
</label>
<input type="number"
class="form-control"
th:field="*{annualIncome}"
min="0"
max="100000000"
required>
</div>
<div class="mb-3">
<label class="form-label">
月別使用可能額
</label>
<input type="number"
class="form-control"
th:field="*{monthlyBudget}"
min="0"
max="10000000"
required>
</div>
<div class="d-grid">
<button type="submit"
class="btn btn-primary">
編集
</button>
</div>
</div>
</form>
</div>
</div>
<div th:replace="~{footer :: footer}">
</div>

View File

@@ -1,52 +1,114 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
<title>コース選択</title>
</head>
<body>
<h1>コース選択</h1>
<form th:action="@{/user/register}" th:object="${userForm}" method="post">
<input type="hidden" th:field="*{userName}">
<input type="hidden" th:field="*{mailAddress}">
<input type="hidden" th:field="*{birthDate}">
<input type="hidden" th:field="*{password}">
<input type="hidden" th:field="*{secretQuestionId}">
<input type="hidden" th:field="*{secretAnswer}">
<input type="hidden" th:field="*{saving}">
<input type="hidden" th:field="*{annualIncome}">
<input type="hidden" th:field="*{monthlyBudget}">
<input type="hidden" th:field="*{targetAmount}">
<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">
<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>
</h2>
<div th:id="'collapse' + ${course.courseId}" class="accordion-collapse collapse" data-bs-parent="#accordionExample">
<div class="accordion-body">
<span th:text="${course.description}"></span>
<table border="1">
<tr>
<th>カテゴリ名</th><th>配分(%)</th>
</tr>
<tr th:each="courseInfo:${courseInfoList}" th:if="${course.courseId == courseInfo.courseId}">
<td th:text="${courseInfo.categoryName}"></td>
<td th:text="${courseInfo.allocationRatio}"></td>
</tr>
</table>
</div>
</div>
</div>
</div>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" th:href="@{/css/style.css}">
<title>コース選択</title>
</head>
<body style="padding-bottom: 120px; padding-top: 80px;">
<div th:replace="~{header :: header}"></div>
<h1 class="page-title">コース選択</h1>
<div class="d-grid gap-2 mt-4">
<th:block th:if="${mode == 'change'}">
<form th:action="@{/course/create}" method="get">
<button class="btn btn-success w-100" type="submit">
新規登録
</button>
</form>
</th:block>
<form th:action="${mode == 'regist'} ? @{/user/register/return}: @{/change}" method="post">
<th:block th:if="${mode == 'change'}">
<form th:action="@{/course/create}" method="get">
<button type="submit">新規登録</button>
</form>
</th:block>
<form th:action="${mode == 'regist'} ? @{/user/register/return}: @{/change}" id="totalForm" method="post">
<button type="submit" class="btn btn-primary w-100">確定</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}"
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>
<p style="width: 120px;"><button type="button" class="btn btn-danger w-100"
th:attr="data-course-id=${course.courseId}" onclick="deleteCourse(this)">削除</button></p>
</h2>
<div th:id="'collapse' + ${course.courseId}" class="accordion-collapse collapse"
data-bs-parent="#accordionExample" style="padding-bottom: 120px;">
<div class="accordion-body">
<span th:text="${course.description}"></span>
<table class="table table-bordered">
<tr>
<th>カテゴリ名</th>
<th>配分(%)</th>
</tr>
<tr th:each="courseInfo:${courseInfoList}"
th:if="${course.courseId == courseInfo.courseId}">
<td th:text="${courseInfo.categoryName}"></td>
<td th:text="${courseInfo.allocationRatio}"></td>
</tr>
</table>
</div>
</div>
</div>
</div>
</form>
</div>
<th:block th:if="${mode=='change'}">
<div th:replace="~{footer :: footer}"></div>
</th:block>
<script th:inline="javascript">
const message = /*[[${message}]]*/ null;
if (message != null) {
alert(message);
}
function deleteCourse(button) {
const courseId = button.dataset.courseId;
const totalForm = document.getElementById("totalForm");
const input = document.createElement("input");
const radioButtons = totalForm.querySelectorAll('input[name="courseId"]');
radioButtons.forEach(radio => {
radio.disabled = true;
});
input.type = "hidden";
input.name = "courseId";
input.value = courseId;
totalForm.appendChild(input);
totalForm.action = "/course/delete";
totalForm.method = "post";
courseId.value = courseId;
totalForm.submit();
}
</script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>

View File

@@ -2,73 +2,178 @@
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" th:href="@{/css/menu.css}">
<meta charset="UTF-8" name="viewport" content="width=device-width, initial-scale=1" http-equiv="Content-Type">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" th:href="@{/css/style.css}">
<title>取引登録</title>
</head>
<body class="pb-5 pt-5">
<body style="padding-top:80px; padding-bottom:80px;">
<div th:replace="~{header :: header}"></div>
<h1>取引登録</h1>
<div class="main-container">
<form th:action="@{/transaction/create}" th:object="${transactionForm}" method="post">
<h1 class="page-title">
取引登録
</h1>
<div class="card shadow-sm">
<div class="card-body">
<form th:action="@{/transaction/create}" th:object="${transactionForm}" method="post">
<div class="mb-3">
<label for="transactionDate" class="form-label">
日付
</label>
<input type="date" id="transactionDate" class="form-select" name="transactionDate"
th:value="*{transactionDate}" required>
</div>
<div class="mb-3">
<label for="transactionType" class="form-label">
収入・支出
</label>
<select id="transactionType" class="form-select" name="transactionType" required>
<option value="">
選択してください
</option>
<option value="0">
支出
</option>
<option value="1">
収入
</option>
</select>
</div>
<div class="mb-3">
<label for="categoryId" class="form-label">
カテゴリ
</label>
<select id="categoryId" class="form-select" th:field="*{categoryId}" required>
<option value="">
選択してください
</option>
<option class="expenseListClass" th:each="category : ${expenseList}"
th:value="${category.categoryId}" th:text="${category.categoryName}">
</option>
<option class="incomeListClass" th:each="category : ${incomeList}"
th:value="${category.categoryId}" th:text="${category.categoryName}">
</option>
</select>
</div>
<div class="mb-3">
<label for="amount" class="form-label">
金額
</label>
<input type="number" id="amount" class="form-control" th:field="*{amount}" min="1"
max="100000000" placeholder="金額を入力してください" required>
</div>
<input type="hidden" name="today" th:value="${today}">
<div class="d-grid">
<button type="submit" class="btn btn-primary">
登録
</button>
</div>
</form>
</div>
<div>
<label for="transactionDate">日付</label>
<input type="date" id="transactionDate" name="transactionDate" th:value="*{transactionDate}">
</div>
<br>
<div>
<label for="transactionType">収入・支出</label>
<select id="transactionType" th:field="*{transactionType}">
<option value="">選択してください</option>
<option value="1">支出</option>
<option value="2">収入</option>
</select>
</div>
<br>
<div>
<label for="categoryId">カテゴリ</label>
<select id="categoryId" th:field="*{categoryId}">
<option value="">選択してください</option>
<option th:each="category : ${categoryFormList}" th:value="${category.categoryId}"
th:text="${category.categoryName}">
</option>
</select>
</div>
<br>
<div>
<label for="amount">金額</label>
<input type="number" id="amount" th:field="*{amount}" min="0" placeholder="金額を入力してください">
</div>
<br>
<input type="hidden" name="today" id="today" th:value="${today}">
<button type="submit">登録</button>
</form>
</div>
<div th:replace="~{footer :: footer}"></div>
<script th:inline="javascript">
const transactionType = document.getElementById("transactionType");
const categoryId = document.getElementById("categoryId");
const expenseList = document.getElementsByClassName("expenseListClass");
const incomeList = document.getElementsByClassName("incomeListClass");
const tType = '[[${session.tType}]]';
function toggleCategory() {
if (transactionType.value === "0") {
for (let i = 0; i < expenseList.length; i++) {
expenseList[i].style.display = "";
}
for (let i = 0; i < incomeList.length; i++) {
incomeList[i].style.display = "none";
}
} else if (transactionType.value === "1") {
for (let i = 0; i < expenseList.length; i++) {
expenseList[i].style.display = "none";
}
for (let i = 0; i < incomeList.length; i++) {
incomeList[i].style.display = "";
}
} else {
for (let i = 0; i < expenseList.length; i++) {
expenseList[i].style.display = "none";
}
for (let i = 0; i < incomeList.length; i++) {
incomeList[i].style.display = "none";
}
}
}
transactionType.addEventListener("change", function () {
toggleCategory();
categoryId.value = "";
});
if (tType == "0") {
transactionType.value = "0";
} else if (tType == "1") {
transactionType.value = "1";
}
toggleCategory();
</script>
</body>

View File

@@ -2,61 +2,151 @@
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<meta charset="UTF-8" name="viewport" content="width=device-width, initial-scale=1" http-equiv="Content-Type">
<title>収支詳細</title>
<link rel="stylesheet" th:href="@{/css/transaction_detail.css}">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" th:href="@{/css/style.css}">
</head>
<body class="pb-5 pt-5">
<body style="padding-top:80px; padding-bottom:80px;">
<div th:replace="~{header :: header}"></div>
<h1 th:text="${today}"></h1>
<div class="main-container">
<div>
<ul>
<li th:each="transactionForm : ${transactionFormList}" class="transaction-item">
<h2 class="page-title"
th:text="${today}">
</h2>
<div>
<p>
カテゴリ名:
<span th:text="${transactionForm.categoryName}"></span>
<br>
金額:
<span th:text="${transactionForm.amount}"></span>
</p>
</div>
<div th:each="transactionForm : ${transactionFormList}"
class="card shadow-sm mb-3">
<div class="transaction-buttons">
<div class="card-body">
<form th:action="@{/transaction/delete}" method="post">
<input type="hidden" name="today" th:value="${today}">
<input type="hidden" name="transactionId" th:value="${transactionForm.transactionId}">
<button type="submit">削除</button>
</form>
<div class="d-flex justify-content-between">
<form th:action="@{/transaction/update}" method="get">
<input type="hidden" name="today" th:value="${today}">
<input type="hidden" name="transactionId" th:value="${transactionForm.transactionId}">
<button type="submit">編集</button>
</form>
<span class="fw-bold"
th:text="${transactionForm.categoryName}">
</span>
</div>
<span th:text="'¥' + ${transactionForm.amount}">
</span>
</div>
<div class="d-flex justify-content-end gap-2 mt-3">
<form th:action="@{/transaction/update}"
method="get">
<input type="hidden"
name="today"
th:value="${today}">
<input type="hidden"
name="transactionId"
th:value="${transactionForm.transactionId}">
<button class="btn btn-sm btn-primary"
type="submit">
編集
</button>
</form>
<form th:action="@{/transaction/delete}"
method="post">
<input type="hidden"
name="today"
th:value="${today}">
<input type="hidden"
name="transactionId"
th:value="${transactionForm.transactionId}">
<button class="btn btn-sm btn-danger"
type="submit">
削除
</button>
</form>
</div>
</div>
</div>
<div class="d-grid mt-4">
<form th:action="@{/transaction/create}"
method="get">
<input type="hidden"
name="today"
id="today"
th:value="${today}">
<button class="btn btn-success w-100"
type="submit">
新規登録
</button>
</form>
</div>
<div class="d-grid mt-4">
<form th:action="@{/fixed-cost/list}" method="get">
<input type="hidden"
name="today"
id="today"
th:value="${today}">
<button class="btn btn-dark w-100"
type="submit">
固定費一覧
</button>
</form>
</div>
<div class="d-grid mt-4">
<form th:action="@{/category/list}"
method="get">
<input type="hidden"
name="today"
id="today"
th:value="${today}">
<button class="btn btn-dark w-100"
type="submit">
カテゴリ一覧
</button>
</form>
</div>
<hr>
<hr>
</li>
</ul>
</div>
<form th:action="@{/transaction/create}" method="get">
<input type="hidden" name="today" id="today" th:value="${today}">
<button type="submit">新規登録</button>
</form>
<div th:replace="~{footer :: footer}"></div>
</body>

View File

@@ -2,17 +2,19 @@
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<meta charset="UTF-8" name="viewport" content="width=device-width, initial-scale=1" http-equiv="Content-Type">
<title>一覧</title>
<link rel="stylesheet" th:href="@{/css/menu.css}">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" th:href="@{/css/style.css}">
</head>
<body class="pb-5 pt-5">
<body>
<div th:replace="~{header :: header}"></div>
<div class="main-container">
<div class="calendar-title">
<a class="month-button" th:href="@{/transaction/list(
@@ -40,20 +42,27 @@
<div th:each="transactionForm : ${transactionFormMap}">
<div th:each="transactionForm : ${transactionFormMap}"
th:if="${!transactionForm.value.isEmpty()}"
class="card shadow-sm mb-3">
<a th:href="@{/transaction/detail(todayDates=${transactionForm.key})}">
<h3 th:text="${transactionForm.key}"></h3>
<div class="card-body">
<a th:href="@{/transaction/detail(todayDates=${transactionForm.key})}" class="text-decoration-none">
<h3 th:text="${transactionForm.key}" class="fw-bold"></h3>
</a>
<ul>
<li th:each="transaction : ${transactionForm.value}">
<p>カテゴリ名:<span th:text="${transaction.categoryName}"></span>
<br>金額:<span th:text="${transaction.amount}"></span>
</p>
<hr />
</li>
</ul>
<div th:each="transaction : ${transactionForm.value}"
class="d-flex justify-content-between mb-2">
 
<span th:text="${transaction.categoryName}">
</span>
 
<span th:text="'¥' + ${transaction.amount}">
</span>
 
</div>
</div>
</div>
<div th:replace="~{footer :: footer}"></div>

View File

@@ -2,74 +2,221 @@
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" th:href="@{/css/menu.css}">
<meta charset="UTF-8" name="viewport" content="width=device-width, initial-scale=1" http-equiv="Content-Type">
<title>取引更新</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" th:href="@{/css/style.css}">
</head>
<body class="pb-5 pt-5">
<body style="padding-top:80px; padding-bottom:80px;">
<div th:replace="~{header :: header}"></div>
<div th:replace="~{header :: header}">
</div>
<h1>取引登録</h1>
<div class="main-container">
<form th:action="@{/transaction/update}" th:object="${transactionForm}" method="post">
<h1 class="page-title">
取引更新
</h1>
<input type="hidden" name="transactionId" th:value="${transactionId}">
<div class="card shadow-sm">
<div>
<label for="transactionDate">日付</label>
<input type="date" id="transactionDate" name="transactionDate" th:value="*{transactionDate}">
</div>
<div class="card-body">
<br>
<form th:action="@{/transaction/update}"
th:object="${transactionForm}"
method="post">
<div>
<label for="transactionType">収入・支出</label>
<input type="hidden"
name="transactionId"
th:value="${transactionId}">
<select id="transactionType" th:field="*{transactionType}">
<input type="hidden"
name="today"
th:value="${today}">
<option value="">選択してください</option>
<option value="0">支出</option>
<option value="1">収入</option>
<div class="mb-3">
<label for="transactionDate" class="form-label">
日付
</label>
<input type="date"
id="transactionDate"
class="form-control"
name="transactionDate"
th:value="*{transactionDate}"
required>
</div>
</select>
</div>
<div class="mb-3">
<br>
<label for="transactionType"
class="form-label">
収入・支出
</label>
<div>
<label for="categoryId">カテゴリ</label>
<select id="transactionType"
class="form-select"
th:field="*{transactionType}"
required>
<select id="categoryId" th:field="*{categoryId}">
<option value="">
選択してください
</option>
<option value="">選択してください</option>
<option value="0">
支出
</option>
<option th:each="category : ${categoryFormList}" th:value="${category.categoryId}"
th:text="${category.categoryName}">
</option>
<option value="1">
収入
</option>
</select>
</div>
</select>
<br>
</div>
<div>
<label for="amount">金額</label>
<div class="mb-3">
<input type="number" id="amount" th:field="*{amount}" min="0" placeholder="金額を入力してください">
</div>
<label for="categoryId"
class="form-label">
カテゴリ
</label>
<br>
<input type="hidden" name="today" id="today" th:value="${today}">
<!-- <select id="categoryId"-->
<!-- class="form-select"-->
<!-- th:field="*{categoryId}"-->
<!-- required>-->
<button type="submit">登録</button>
<!-- <option value="">-->
<!-- 選択してください-->
<!-- </option>-->
</form>
<!-- <option th:each="category : ${categoryFormList}"-->
<!-- th:value="${category.categoryId}"-->
<!-- th:text="${category.categoryName}">-->
<!-- </option>-->
<!-- </select>-->
<select id="categoryId" class="form-select" th:field="*{categoryId}" required>
<option value="">
選択してください
</option>
<option class="expenseListClass" th:each="category : ${expenseList}"
th:value="${category.categoryId}" th:text="${category.categoryName}">
</option>
<option class="incomeListClass" th:each="category : ${incomeList}"
th:value="${category.categoryId}" th:text="${category.categoryName}">
</option>
</select>
</div>
<div class="mb-4">
<label for="amount"
class="form-label">
金額
</label>
<input type="number"
id="amount"
class="form-control"
th:field="*{amount}"
min="0"
max="100000000"
placeholder="金額を入力してください"
required>
</div>
<div class="d-grid">
<button type="submit"
class="btn btn-primary">
更新
</button>
</div>
</form>
</div>
</div>
</div>
<div th:replace="~{footer :: footer}">
</div>
<script th:inline="javascript">
const transactionType = document.getElementById("transactionType");
const categoryId = document.getElementById("categoryId");
const expenseList = document.getElementsByClassName("expenseListClass");
const incomeList = document.getElementsByClassName("incomeListClass");
const tType = '[[${session.tType}]]';
function toggleCategory() {
if (transactionType.value === "0") {
for (let i = 0; i < expenseList.length; i++) {
expenseList[i].style.display = "";
}
for (let i = 0; i < incomeList.length; i++) {
incomeList[i].style.display = "none";
}
} else if (transactionType.value === "1") {
for (let i = 0; i < expenseList.length; i++) {
expenseList[i].style.display = "none";
}
for (let i = 0; i < incomeList.length; i++) {
incomeList[i].style.display = "";
}
} else {
for (let i = 0; i < expenseList.length; i++) {
expenseList[i].style.display = "none";
}
for (let i = 0; i < incomeList.length; i++) {
incomeList[i].style.display = "none";
}
}
}
transactionType.addEventListener("change", function () {
toggleCategory();
categoryId.value = "";
});
if (tType == "0") {
transactionType.value = "0";
} else if (tType == "1") {
transactionType.value = "1";
}
toggleCategory();
</script>
<div th:replace="~{footer :: footer}"></div>
</body>

View File

@@ -1,127 +1,194 @@
<!DOCTYPE html>
<html lang="ja"xmlns:th="http://www.thymeleaf.org">
<html lang="ja" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>新規会員登録</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>新規会員登録</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" th:href="@{/css/style.css}">
</head>
<body class="pb-5 pt-5">
<body style="padding-top:80px; padding-bottom:80px;">
<div th:replace="~{header :: header}">
</div>
<div class="main-container">
<h1 class="page-title">
新規会員登録
</h1>
<div class="card shadow-sm">
<div class="card-body">
<form th:action="@{/user/register/course}" th:object="${userForm}" method="post">
<div class="mb-3">
<label for="userName" class="form-label">
氏名
</label>
<input type="text" id="userName" class="form-control" th:field="*{userName}" maxlength="100"
required>
</div>
<div class="mb-3">
<label for="mailAddress" class="form-label">
メールアドレス
</label>
<input type="email" id="mailAddress" class="form-control" th:field="*{mailAddress}"
maxlength="255" required>
</div>
<div class="mb-3">
<label for="birthDate" class="form-label">
生年月日
</label>
<input type="date" id="birthDate" class="form-control" th:field="*{birthDate}" required>
</div>
<div class="mb-3">
<label for="password" class="form-label">
パスワード
</label>
<input type="password" id="password" class="form-control" th:field="*{password}" minlength="8"
maxlength="24" required>
</div>
<div class="mb-3">
<label for="secretQuestionId" class="form-label">
秘密の質問
</label>
<select id="secretQuestionId" class="form-select" 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 class="mb-3">
<label for="secretAnswer" class="form-label">
秘密の質問の回答
</label>
<input type="text" id="secretAnswer" class="form-control" th:field="*{secretAnswer}"
maxlength="100" required>
</div>
<div class="mb-3">
<label for="saving" class="form-label">
貯蓄金
</label>
<input type="number" id="saving" class="form-control" th:field="*{saving}" min="0"
max="1000000000" required>
</div>
<div class="mb-3">
<label for="annualIncome" class="form-label">
年収
</label>
<input type="number" id="annualIncome" class="form-control" th:field="*{annualIncome}" min="0"
max="100000000" required>
</div>
<div class="mb-3">
<label for="monthlyBudget" class="form-label">
月別使用可能金額
</label>
<input type="number" id="monthlyBudget" class="form-control" th:field="*{monthlyBudget}" min="0"
max="10000000" required>
</div>
<div class="mb-3">
<label for="goalId" class="form-label">
目標貯金額
</label>
<input type="number" id="goalId" class="form-control" th:field="*{goalId}" min="0"
max="1000000000" required>
</div>
<input type="hidden" th:field="*{courseId}">
<div class="d-grid gap-2 mt-4">
<button type="submit" class="btn btn-outline-primary">
コース選択
</button>
<button type="submit" class="btn btn-primary">
作成
</button>
</div>
</form>
</div>
</div>
<main>
<h1>新規会員登録</h1>
<div class="d-grid mt-3">
<form th:action="@{/user/register/confirm}" th:object="${userForm}" method="post">
<div>
<label for="userName">氏名</label>
<input type="text"
id="userName"
th:field="*{userName}"
maxlength="100"
required>
</div>
<form th:action="@{/login}" method="get">
<div>
<label for="mailAddress">メールアドレス</label>
<input type="email"
id="mailAddress"
th:field="*{mailAddress}"
maxlength="255"
required>
</div>
<button type="submit" class="btn btn-outline-secondary">
戻る
</button>
<div>
<label for="birthDate">生年月日</label>
<input type="date"
id="birthDate"
th:field="*{birthDate}"
required>
</div>
</form>
<div>
<label for="password">パスワード</label>
<input type="password"
id="password"
th:field="*{password}"
minlength="8"
maxlength="255"
required>
</div>
</div>
<div>
<label for="secretQuestionId">秘密の質問</label>
<select id="secretQuestionId"
th:field="*{secretQuestionId}"
required>
<option value="">選択してください</option>
<option th:each="question : ${questionList}"
th:value="${question.secretQuestionId}"
th:text="${question.questionText}">
</option>
</select>
</div>
</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>
<script>
<div>
<label for="annualIncome">年収</label>
<input type="number"
id="annualIncome"
th:field="*{annualIncome}"
min="0"
required>
</div>
const date = new Date();
<div>
<label for="monthlyBudget">月別使用可能金額</label>
<input type="number"
id="monthlyBudget"
th:field="*{monthlyBudget}"
min="0"
required>
</div>
const year = date.getFullYear();
const month = date.getMonth() + 1;
const day = date.getDate();
<div>
<label for="goalId">目標</label>
<input type="number"
id="goalId"
th:field="*{goalId}"
min="0"
required>
</div>
const birthDate = document.getElementById("birthDate");
<div>
<label>コース</label>
<input type="hidden" th:field="*{courseId}">
<span th:text="${selectedCourseName}">未選択</span>
<button type="submit"onclick="location.href='/course/select/register'">コース選択</button>
</div>
if (month < 10) {
if (day < 10) {
birthDate.setAttribute("max", year + "-0" + month + "-0" + day);
} else {
birthDate.setAttribute("max", year + "-0" + month + "-" + day);
}
<div>
<button type="submit">作成</button>
</div>
</form>
} else {
if (day < 10) {
birthDate.setAttribute("max", year + "-" + month + "-0" + day);
} else {
birthDate.setAttribute("max", year + "-" + month + "-" + day);
}
}
<form th:action="@{/login}" method="get">
<button type="submit">戻る</button>
</form>
</script>
</main>
</body>
</html>

View File

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

View File

@@ -0,0 +1,145 @@
<!DOCTYPE html>
<html lang="ja" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8" name="viewport" content="width=device-width, initial-scale=1" http-equiv="Content-Type">
<title>新規会員登録</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" th:href="@{/css/style.css}">
</head>
<body>
<div th:replace="~{header :: header}">
</div>
<div class="main-container">
<h1 class="page-title">新規会員登録</h1>
<div class="card shadow-sm">
<div class="card-body">
<form th:action="@{/user/register/confirm}" th:object="${userForm}" method="get">
<div class="mb-3">
<label for="userName" class="form-label">氏名</label>
<input type="text" id="userName" class="form-control" th:field="*{userName}" maxlength="100"
required>
</div>
<div class="mb-3">
<label for="mailAddress" class="form-label">メールアドレス</label>
<input type="email" id="mailAddress" class="form-control" th:field="*{mailAddress}"
maxlength="255" required>
</div>
<div class="mb-3">
<label for="birthDate" class="form-label">生年月日</label>
<input type="date" id="birthDate" name="birthDate" class="form-control" th:value="*{birthDate}"
required>
</div>
<div class="mb-3">
<label for="password" class="form-label">パスワード</label>
<input type="password" id="password" name="password" class="form-control" th:value="*{password}"
minlength="8" maxlength="24" required>
</div>
<div class="mb-3">
<label for="secretQuestionId" class="form-label">秘密の質問</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 class="mb-3">
<label for="secretAnswer" class="form-label">秘密の質問の回答</label>
<input type="text" id="secretAnswer" class="form-control" th:field="*{secretAnswer}"
maxlength="100" required>
</div>
<div class="mb-3">
<label for="saving" class="form-label">貯蓄金</label>
<input type="number" id="saving" class="form-control" th:field="*{saving}" min="0" required>
</div>
<div class="mb-3">
<label for="annualIncome" class="form-label">年収</label>
<input type="number" id="annualIncome" class="form-control" th:field="*{annualIncome}" min="0"
required>
</div>
<div class="mb-3">
<label for="monthlyBudget" class="form-label">月別使用可能金額</label>
<input type="number" id="monthlyBudget" class="form-control" th:field="*{monthlyBudget}" min="0"
required>
</div>
<div class="mb-3">
<label for="goalId" class="form-label">目標貯金額</label>
<input type="number" id="goalId" class="form-control" th:field="*{goalId}" min="0" required>
</div>
<div class="mb-4">
<label class="form-label">コース</label>
<div class="d-flex justify-content-between align-items-center">
<input type="hidden" th:field="*{courseId}">
<span th:text="${selectedCourseName}">未選択</span>
<button class="btn btn-outline-primary btn-sm" disabled>
コース選択
</button>
</div>
</div>
<div class="d-grid">
<button type="submit" class="btn btn-primary">作成</button>
</div>
</form>
</div>
</div>
<div class="d-grid mt-3">
<form th:action="@{/login}" method="get">
<button type="submit" class="btn btn-outline-secondary">戻る</button>
</form>
</div>
</div>
<script>
const date = new Date();
const year = date.getFullYear();
const month = date.getMonth() + 1;
const day = date.getDate();
const birthDate = document.getElementById("birthDate");
if (month < 10) {
if (day < 10) {
birthDate.setAttribute("max", year + "-0" + month + "-0" + day);
} else {
birthDate.setAttribute("max", year + "-0" + month + "-" + day);
}
} else {
if (day < 10) {
birthDate.setAttribute("max", year + "-" + month + "-0" + day);
} else {
birthDate.setAttribute("max", year + "-" + month + "-" + day);
}
}
</script>
</body>
</html>