From 888414050f17ab9a3971a85dd803e753c17c8ab0 Mon Sep 17 00:00:00 2001 From: joohyun Date: Mon, 6 May 2024 17:29:42 +0900 Subject: [PATCH] =?UTF-8?q?feature:#57=20=EA=B4=80=EB=A6=AC=EC=9E=90?= =?UTF-8?q?=ED=8E=98=EC=9D=B4=EC=A7=80=EC=97=90=EC=84=9C=20=ED=9A=8C?= =?UTF-8?q?=EC=9B=90=EA=B3=BC=20=EC=BF=A0=ED=8F=B0=EC=9D=84=20=EC=84=A0?= =?UTF-8?q?=ED=83=9D=ED=95=B4=20=EC=A7=81=EC=A0=91=20=EB=B0=9C=EA=B8=89=20?= =?UTF-8?q?=EA=B0=80=EB=8A=A5=ED=95=98=EA=B2=8C=20=ED=95=98=EB=8A=94=20?= =?UTF-8?q?=EB=B7=B0=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/controller/CouponController.java | 18 ++++ .../static/assets/admin/js/adminCoupon.js | 82 +++++++++++++++++++ .../templates/admin/fragment/couponModal.html | 31 +++++++ .../templates/admin/fragment/memberModal.html | 38 +++++++++ .../templates/admin/fragment/sidebar.html | 9 +- .../templates/admin/layout/layout.html | 1 + .../templates/admin/page/couponHistory.html | 7 ++ .../templates/admin/page/couponRegister.html | 49 +++++++++++ 8 files changed, 228 insertions(+), 7 deletions(-) create mode 100644 src/main/java/com/t3t/frontserver/admin/controller/CouponController.java create mode 100644 src/main/resources/static/assets/admin/js/adminCoupon.js create mode 100644 src/main/resources/templates/admin/fragment/couponModal.html create mode 100644 src/main/resources/templates/admin/fragment/memberModal.html create mode 100644 src/main/resources/templates/admin/page/couponHistory.html create mode 100644 src/main/resources/templates/admin/page/couponRegister.html diff --git a/src/main/java/com/t3t/frontserver/admin/controller/CouponController.java b/src/main/java/com/t3t/frontserver/admin/controller/CouponController.java new file mode 100644 index 0000000..5bb2179 --- /dev/null +++ b/src/main/java/com/t3t/frontserver/admin/controller/CouponController.java @@ -0,0 +1,18 @@ +package com.t3t.frontserver.admin.controller; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; + +@Controller +public class CouponController { + @GetMapping("/admin/coupons/register") + public String getRegisterView(){ + + return "admin/page/couponRegister"; + } + + @GetMapping("/admin/coupons/usageHistory") + public String getUsage(){ + return "admin/page/couponHistory"; + } +} diff --git a/src/main/resources/static/assets/admin/js/adminCoupon.js b/src/main/resources/static/assets/admin/js/adminCoupon.js new file mode 100644 index 0000000..8f0b4e5 --- /dev/null +++ b/src/main/resources/static/assets/admin/js/adminCoupon.js @@ -0,0 +1,82 @@ +/** + * 확인 버튼을 클릭했을 때 실행되는 이벤트 핸들러 + * 회원 선택 버튼과 쿠폰 선택 버튼을 생성하고 테이블에 추가 + * @author joohyun1996(이주현) + */ +document.getElementById('confirmBtn').addEventListener('click', function() { + + var count = document.getElementById('memberCount').value; + var tableBody = document.getElementById('memberButtonTable').getElementsByTagName('tbody')[0]; + tableBody.innerHTML = ''; + + for (var i = 1; i <= count; i++) { + var row = document.createElement('tr'); + // 첫 번째 열 : 참여자 선택 버튼 + var memberCell = document.createElement('td'); + var memberButton = document.createElement('button'); + memberButton.type = 'button'; + memberButton.id = 'participantButton_' + i; + memberButton.innerText = i + '번 회원 선택'; + memberButton.classList.add('btn', 'btn-secondary'); + memberButton.dataset.bsToggle = 'modal'; + memberButton.dataset.bsTarget = '#memberModal'; + memberButton.dataset.index = i; + memberButton.addEventListener('click', function() { + $('#memberModal').data('index', this.dataset.index); + fetchParticipantsAndUpdateModal(); + }); + memberCell.appendChild(memberButton); + row.appendChild(memberCell); + + // 두 번째 열 : 참여자 역할 선택 버튼 + var couponCell = document.createElement('td'); + var couponButton = document.createElement('button'); + couponButton.type = 'button'; + couponButton.id = 'couponButton_' + i; + couponButton.innerText = i + '번 쿠폰 선택'; + couponButton.classList.add('btn', 'btn-secondary'); + couponButton.dataset.bsToggle = 'modal'; + couponButton.dataset.bsTarget = '#couponModal'; + couponButton.dataset.index = i; + couponButton.addEventListener('click', function() { + $('#couponModal').data('index', this.dataset.index); + fetchParticipantRolesAndUpdateModal(); + }); + couponCell.appendChild(couponButton); + row.appendChild(couponCell); + + tableBody.appendChild(row); + } +}); + +document.getElementById('searchButton').addEventListener('click', function() { + var searchInput = document.getElementById('memberSearchInput').value; + + // 여기서 searchInput을 사용하여 회원을 검색합니다. + // 이 예제에서는 검색 결과를 담은 배열인 searchResults를 사용하겠습니다. + fetch('/at/bookstore/members?name=' + searchInput) + .then(response => response.json()) + .then(searchResults => { + var tableBody = document.getElementById('memberTable').getElementsByTagName('tbody')[0]; + tableBody.innerHTML = ''; + + for (var i = 0; i < searchResults.length; i++) { + var row = document.createElement('tr'); + + var checkBoxCell = document.createElement('td'); + checkBoxCell.innerText = searchResults[i].checkBox; + row.appendChild(checkBoxCell); + + var nameCell = document.createElement('td'); + nameCell.innerText = searchResults[i].name; + row.appendChild(nameCell); + + var emailCell = document.createElement('td'); + emailCell.innerText = searchResults[i].email; + row.appendChild(emailCell); + + tableBody.appendChild(row); + } + }) + .catch(error => console.error('Error:', error)); +}); diff --git a/src/main/resources/templates/admin/fragment/couponModal.html b/src/main/resources/templates/admin/fragment/couponModal.html new file mode 100644 index 0000000..5b5764b --- /dev/null +++ b/src/main/resources/templates/admin/fragment/couponModal.html @@ -0,0 +1,31 @@ + + + + + + \ No newline at end of file diff --git a/src/main/resources/templates/admin/fragment/memberModal.html b/src/main/resources/templates/admin/fragment/memberModal.html new file mode 100644 index 0000000..5a6ad0c --- /dev/null +++ b/src/main/resources/templates/admin/fragment/memberModal.html @@ -0,0 +1,38 @@ + + + + + + \ No newline at end of file diff --git a/src/main/resources/templates/admin/fragment/sidebar.html b/src/main/resources/templates/admin/fragment/sidebar.html index 8b488d5..afe954d 100644 --- a/src/main/resources/templates/admin/fragment/sidebar.html +++ b/src/main/resources/templates/admin/fragment/sidebar.html @@ -56,17 +56,12 @@